nsfwapp/backend/web/dist/assets/index-C4whm-WW.js
2026-02-25 17:46:15 +01:00

466 lines
1.8 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function oN(s,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const r=Object.getOwnPropertyDescriptor(i,n);r&&Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();var h0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Kc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function lN(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var e=s.default;if(typeof e=="function"){var t=function i(){var n=!1;try{n=this instanceof i}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return s[i]}})}),t}var _y={exports:{}},Xd={};var __;function uN(){if(__)return Xd;__=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,n,r){var a=null;if(r!==void 0&&(a=""+r),n.key!==void 0&&(a=""+n.key),"key"in n){r={};for(var u in n)u!=="key"&&(r[u]=n[u])}else r=n;return n=r.ref,{$$typeof:s,type:i,key:a,ref:n!==void 0?n:null,props:r}}return Xd.Fragment=e,Xd.jsx=t,Xd.jsxs=t,Xd}var E_;function cN(){return E_||(E_=1,_y.exports=uN()),_y.exports}var m=cN(),Ey={exports:{}},vi={};var w_;function dN(){if(w_)return vi;w_=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),y=Symbol.iterator;function v(F){return F===null||typeof F!="object"?null:(F=y&&F[y]||F["@@iterator"],typeof F=="function"?F:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,w={};function L(F,le,ge){this.props=F,this.context=le,this.refs=w,this.updater=ge||T}L.prototype.isReactComponent={},L.prototype.setState=function(F,le){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,le,"setState")},L.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function O(){}O.prototype=L.prototype;function I(F,le,ge){this.props=F,this.context=le,this.refs=w,this.updater=ge||T}var j=I.prototype=new O;j.constructor=I,S(j,L.prototype),j.isPureReactComponent=!0;var P=Array.isArray;function G(){}var N={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function k(F,le,ge){var Ie=ge.ref;return{$$typeof:s,type:F,key:le,ref:Ie!==void 0?Ie:null,props:ge}}function R(F,le){return k(F.type,le,F.props)}function Y(F){return typeof F=="object"&&F!==null&&F.$$typeof===s}function z(F){var le={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(ge){return le[ge]})}var X=/\/+/g;function re(F,le){return typeof F=="object"&&F!==null&&F.key!=null?z(""+F.key):le.toString(36)}function J(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(G,G):(F.status="pending",F.then(function(le){F.status==="pending"&&(F.status="fulfilled",F.value=le)},function(le){F.status==="pending"&&(F.status="rejected",F.reason=le)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function W(F,le,ge,Ie,Le){var Pe=typeof F;(Pe==="undefined"||Pe==="boolean")&&(F=null);var Je=!1;if(F===null)Je=!0;else switch(Pe){case"bigint":case"string":case"number":Je=!0;break;case"object":switch(F.$$typeof){case s:case e:Je=!0;break;case f:return Je=F._init,W(Je(F._payload),le,ge,Ie,Le)}}if(Je)return Le=Le(F),Je=Ie===""?"."+re(F,0):Ie,P(Le)?(ge="",Je!=null&&(ge=Je.replace(X,"$&/")+"/"),W(Le,le,ge,"",function(Ve){return Ve})):Le!=null&&(Y(Le)&&(Le=R(Le,ge+(Le.key==null||F&&F.key===Le.key?"":(""+Le.key).replace(X,"$&/")+"/")+Je)),le.push(Le)),1;Je=0;var Se=Ie===""?".":Ie+":";if(P(F))for(var Re=0;Re<F.length;Re++)Ie=F[Re],Pe=Se+re(Ie,Re),Je+=W(Ie,le,ge,Pe,Le);else if(Re=v(F),typeof Re=="function")for(F=Re.call(F),Re=0;!(Ie=F.next()).done;)Ie=Ie.value,Pe=Se+re(Ie,Re++),Je+=W(Ie,le,ge,Pe,Le);else if(Pe==="object"){if(typeof F.then=="function")return W(J(F),le,ge,Ie,Le);throw le=String(F),Error("Objects are not valid as a React child (found: "+(le==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":le)+"). If you meant to render a collection of children, use an array instead.")}return Je}function q(F,le,ge){if(F==null)return F;var Ie=[],Le=0;return W(F,Ie,"","",function(Pe){return le.call(ge,Pe,Le++)}),Ie}function Z(F){if(F._status===-1){var le=F._result;le=le(),le.then(function(ge){(F._status===0||F._status===-1)&&(F._status=1,F._result=ge)},function(ge){(F._status===0||F._status===-1)&&(F._status=2,F._result=ge)}),F._status===-1&&(F._status=0,F._result=le)}if(F._status===1)return F._result.default;throw F._result}var te=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var le=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(le))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},oe={map:q,forEach:function(F,le,ge){q(F,function(){le.apply(this,arguments)},ge)},count:function(F){var le=0;return q(F,function(){le++}),le},toArray:function(F){return q(F,function(le){return le})||[]},only:function(F){if(!Y(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return vi.Activity=g,vi.Children=oe,vi.Component=L,vi.Fragment=t,vi.Profiler=n,vi.PureComponent=I,vi.StrictMode=i,vi.Suspense=c,vi.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,vi.__COMPILER_RUNTIME={__proto__:null,c:function(F){return N.H.useMemoCache(F)}},vi.cache=function(F){return function(){return F.apply(null,arguments)}},vi.cacheSignal=function(){return null},vi.cloneElement=function(F,le,ge){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var Ie=S({},F.props),Le=F.key;if(le!=null)for(Pe in le.key!==void 0&&(Le=""+le.key),le)!K.call(le,Pe)||Pe==="key"||Pe==="__self"||Pe==="__source"||Pe==="ref"&&le.ref===void 0||(Ie[Pe]=le[Pe]);var Pe=arguments.length-2;if(Pe===1)Ie.children=ge;else if(1<Pe){for(var Je=Array(Pe),Se=0;Se<Pe;Se++)Je[Se]=arguments[Se+2];Ie.children=Je}return k(F.type,Le,Ie)},vi.createContext=function(F){return F={$$typeof:a,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:r,_context:F},F},vi.createElement=function(F,le,ge){var Ie,Le={},Pe=null;if(le!=null)for(Ie in le.key!==void 0&&(Pe=""+le.key),le)K.call(le,Ie)&&Ie!=="key"&&Ie!=="__self"&&Ie!=="__source"&&(Le[Ie]=le[Ie]);var Je=arguments.length-2;if(Je===1)Le.children=ge;else if(1<Je){for(var Se=Array(Je),Re=0;Re<Je;Re++)Se[Re]=arguments[Re+2];Le.children=Se}if(F&&F.defaultProps)for(Ie in Je=F.defaultProps,Je)Le[Ie]===void 0&&(Le[Ie]=Je[Ie]);return k(F,Pe,Le)},vi.createRef=function(){return{current:null}},vi.forwardRef=function(F){return{$$typeof:u,render:F}},vi.isValidElement=Y,vi.lazy=function(F){return{$$typeof:f,_payload:{_status:-1,_result:F},_init:Z}},vi.memo=function(F,le){return{$$typeof:d,type:F,compare:le===void 0?null:le}},vi.startTransition=function(F){var le=N.T,ge={};N.T=ge;try{var Ie=F(),Le=N.S;Le!==null&&Le(ge,Ie),typeof Ie=="object"&&Ie!==null&&typeof Ie.then=="function"&&Ie.then(G,te)}catch(Pe){te(Pe)}finally{le!==null&&ge.types!==null&&(le.types=ge.types),N.T=le}},vi.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},vi.use=function(F){return N.H.use(F)},vi.useActionState=function(F,le,ge){return N.H.useActionState(F,le,ge)},vi.useCallback=function(F,le){return N.H.useCallback(F,le)},vi.useContext=function(F){return N.H.useContext(F)},vi.useDebugValue=function(){},vi.useDeferredValue=function(F,le){return N.H.useDeferredValue(F,le)},vi.useEffect=function(F,le){return N.H.useEffect(F,le)},vi.useEffectEvent=function(F){return N.H.useEffectEvent(F)},vi.useId=function(){return N.H.useId()},vi.useImperativeHandle=function(F,le,ge){return N.H.useImperativeHandle(F,le,ge)},vi.useInsertionEffect=function(F,le){return N.H.useInsertionEffect(F,le)},vi.useLayoutEffect=function(F,le){return N.H.useLayoutEffect(F,le)},vi.useMemo=function(F,le){return N.H.useMemo(F,le)},vi.useOptimistic=function(F,le){return N.H.useOptimistic(F,le)},vi.useReducer=function(F,le,ge){return N.H.useReducer(F,le,ge)},vi.useRef=function(F){return N.H.useRef(F)},vi.useState=function(F){return N.H.useState(F)},vi.useSyncExternalStore=function(F,le,ge){return N.H.useSyncExternalStore(F,le,ge)},vi.useTransition=function(){return N.H.useTransition()},vi.version="19.2.3",vi}var A_;function J0(){return A_||(A_=1,Ey.exports=dN()),Ey.exports}var b=J0();const ii=Kc(b),k_=oN({__proto__:null,default:ii},[b]);var wy={exports:{}},Qd={},Ay={exports:{}},ky={};var C_;function hN(){return C_||(C_=1,(function(s){function e(W,q){var Z=W.length;W.push(q);e:for(;0<Z;){var te=Z-1>>>1,oe=W[te];if(0<n(oe,q))W[te]=q,W[Z]=oe,Z=te;else break e}}function t(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var q=W[0],Z=W.pop();if(Z!==q){W[0]=Z;e:for(var te=0,oe=W.length,F=oe>>>1;te<F;){var le=2*(te+1)-1,ge=W[le],Ie=le+1,Le=W[Ie];if(0>n(ge,Z))Ie<oe&&0>n(Le,ge)?(W[te]=Le,W[Ie]=Z,te=Ie):(W[te]=ge,W[le]=Z,te=le);else if(Ie<oe&&0>n(Le,Z))W[te]=Le,W[Ie]=Z,te=Ie;else break e}}return q}function n(W,q){var Z=W.sortIndex-q.sortIndex;return Z!==0?Z:W.id-q.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;s.unstable_now=function(){return r.now()}}else{var a=Date,u=a.now();s.unstable_now=function(){return a.now()-u}}var c=[],d=[],f=1,g=null,y=3,v=!1,T=!1,S=!1,w=!1,L=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function j(W){for(var q=t(d);q!==null;){if(q.callback===null)i(d);else if(q.startTime<=W)i(d),q.sortIndex=q.expirationTime,e(c,q);else break;q=t(d)}}function P(W){if(S=!1,j(W),!T)if(t(c)!==null)T=!0,G||(G=!0,z());else{var q=t(d);q!==null&&J(P,q.startTime-W)}}var G=!1,N=-1,K=5,k=-1;function R(){return w?!0:!(s.unstable_now()-k<K)}function Y(){if(w=!1,G){var W=s.unstable_now();k=W;var q=!0;try{e:{T=!1,S&&(S=!1,O(N),N=-1),v=!0;var Z=y;try{t:{for(j(W),g=t(c);g!==null&&!(g.expirationTime>W&&R());){var te=g.callback;if(typeof te=="function"){g.callback=null,y=g.priorityLevel;var oe=te(g.expirationTime<=W);if(W=s.unstable_now(),typeof oe=="function"){g.callback=oe,j(W),q=!0;break t}g===t(c)&&i(c),j(W)}else i(c);g=t(c)}if(g!==null)q=!0;else{var F=t(d);F!==null&&J(P,F.startTime-W),q=!1}}break e}finally{g=null,y=Z,v=!1}q=void 0}}finally{q?z():G=!1}}}var z;if(typeof I=="function")z=function(){I(Y)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,re=X.port2;X.port1.onmessage=Y,z=function(){re.postMessage(null)}}else z=function(){L(Y,0)};function J(W,q){N=L(function(){W(s.unstable_now())},q)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(W){W.callback=null},s.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<W?Math.floor(1e3/W):5},s.unstable_getCurrentPriorityLevel=function(){return y},s.unstable_next=function(W){switch(y){case 1:case 2:case 3:var q=3;break;default:q=y}var Z=y;y=q;try{return W()}finally{y=Z}},s.unstable_requestPaint=function(){w=!0},s.unstable_runWithPriority=function(W,q){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var Z=y;y=W;try{return q()}finally{y=Z}},s.unstable_scheduleCallback=function(W,q,Z){var te=s.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?te+Z:te):Z=te,W){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=Z+oe,W={id:f++,callback:q,priorityLevel:W,startTime:Z,expirationTime:oe,sortIndex:-1},Z>te?(W.sortIndex=Z,e(d,W),t(c)===null&&W===t(d)&&(S?(O(N),N=-1):S=!0,J(P,Z-te))):(W.sortIndex=oe,e(c,W),T||v||(T=!0,G||(G=!0,z()))),W},s.unstable_shouldYield=R,s.unstable_wrapCallback=function(W){var q=y;return function(){var Z=y;y=q;try{return W.apply(this,arguments)}finally{y=Z}}}})(ky)),ky}var D_;function fN(){return D_||(D_=1,Ay.exports=hN()),Ay.exports}var Cy={exports:{}},Kn={};var L_;function mN(){if(L_)return Kn;L_=1;var s=J0();function e(c){var d="https://react.dev/errors/"+c;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)d+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+c+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var i={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},n=Symbol.for("react.portal");function r(c,d,f){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:n,key:g==null?null:""+g,children:c,containerInfo:d,implementation:f}}var a=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(c,d){if(c==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return Kn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Kn.createPortal=function(c,d){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(e(299));return r(c,d,null,f)},Kn.flushSync=function(c){var d=a.T,f=i.p;try{if(a.T=null,i.p=2,c)return c()}finally{a.T=d,i.p=f,i.d.f()}},Kn.preconnect=function(c,d){typeof c=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,i.d.C(c,d))},Kn.prefetchDNS=function(c){typeof c=="string"&&i.d.D(c)},Kn.preinit=function(c,d){if(typeof c=="string"&&d&&typeof d.as=="string"){var f=d.as,g=u(f,d.crossOrigin),y=typeof d.integrity=="string"?d.integrity:void 0,v=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;f==="style"?i.d.S(c,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:g,integrity:y,fetchPriority:v}):f==="script"&&i.d.X(c,{crossOrigin:g,integrity:y,fetchPriority:v,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},Kn.preinitModule=function(c,d){if(typeof c=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var f=u(d.as,d.crossOrigin);i.d.M(c,{crossOrigin:f,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&i.d.M(c)},Kn.preload=function(c,d){if(typeof c=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var f=d.as,g=u(f,d.crossOrigin);i.d.L(c,f,{crossOrigin:g,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},Kn.preloadModule=function(c,d){if(typeof c=="string")if(d){var f=u(d.as,d.crossOrigin);i.d.m(c,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:f,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else i.d.m(c)},Kn.requestFormReset=function(c){i.d.r(c)},Kn.unstable_batchedUpdates=function(c,d){return c(d)},Kn.useFormState=function(c,d,f){return a.H.useFormState(c,d,f)},Kn.useFormStatus=function(){return a.H.useHostTransitionStatus()},Kn.version="19.2.3",Kn}var R_;function RA(){if(R_)return Cy.exports;R_=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),Cy.exports=mN(),Cy.exports}var I_;function pN(){if(I_)return Qd;I_=1;var s=fN(),e=J0(),t=RA();function i(o){var l="https://react.dev/errors/"+o;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)l+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+o+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function r(o){var l=o,h=o;if(o.alternate)for(;l.return;)l=l.return;else{o=l;do l=o,(l.flags&4098)!==0&&(h=l.return),o=l.return;while(o)}return l.tag===3?h:null}function a(o){if(o.tag===13){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function u(o){if(o.tag===31){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function c(o){if(r(o)!==o)throw Error(i(188))}function d(o){var l=o.alternate;if(!l){if(l=r(o),l===null)throw Error(i(188));return l!==o?null:o}for(var h=o,p=l;;){var _=h.return;if(_===null)break;var E=_.alternate;if(E===null){if(p=_.return,p!==null){h=p;continue}break}if(_.child===E.child){for(E=_.child;E;){if(E===h)return c(_),o;if(E===p)return c(_),l;E=E.sibling}throw Error(i(188))}if(h.return!==p.return)h=_,p=E;else{for(var U=!1,ee=_.child;ee;){if(ee===h){U=!0,h=_,p=E;break}if(ee===p){U=!0,p=_,h=E;break}ee=ee.sibling}if(!U){for(ee=E.child;ee;){if(ee===h){U=!0,h=E,p=_;break}if(ee===p){U=!0,p=E,h=_;break}ee=ee.sibling}if(!U)throw Error(i(189))}}if(h.alternate!==p)throw Error(i(190))}if(h.tag!==3)throw Error(i(188));return h.stateNode.current===h?o:l}function f(o){var l=o.tag;if(l===5||l===26||l===27||l===6)return o;for(o=o.child;o!==null;){if(l=f(o),l!==null)return l;o=o.sibling}return null}var g=Object.assign,y=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),I=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function z(o){return o===null||typeof o!="object"?null:(o=Y&&o[Y]||o["@@iterator"],typeof o=="function"?o:null)}var X=Symbol.for("react.client.reference");function re(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===X?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case S:return"Fragment";case L:return"Profiler";case w:return"StrictMode";case P:return"Suspense";case G:return"SuspenseList";case k:return"Activity"}if(typeof o=="object")switch(o.$$typeof){case T:return"Portal";case I:return o.displayName||"Context";case O:return(o._context.displayName||"Context")+".Consumer";case j:var l=o.render;return o=o.displayName,o||(o=l.displayName||l.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case N:return l=o.displayName||null,l!==null?l:re(o.type)||"Memo";case K:l=o._payload,o=o._init;try{return re(o(l))}catch{}}return null}var J=Array.isArray,W=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},te=[],oe=-1;function F(o){return{current:o}}function le(o){0>oe||(o.current=te[oe],te[oe]=null,oe--)}function ge(o,l){oe++,te[oe]=o.current,o.current=l}var Ie=F(null),Le=F(null),Pe=F(null),Je=F(null);function Se(o,l){switch(ge(Pe,l),ge(Le,o),ge(Ie,null),l.nodeType){case 9:case 11:o=(o=l.documentElement)&&(o=o.namespaceURI)?qS(o):0;break;default:if(o=l.tagName,l=l.namespaceURI)l=qS(l),o=KS(l,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}le(Ie),ge(Ie,o)}function Re(){le(Ie),le(Le),le(Pe)}function Ve(o){o.memoizedState!==null&&ge(Je,o);var l=Ie.current,h=KS(l,o.type);l!==h&&(ge(Le,o),ge(Ie,h))}function Ee(o){Le.current===o&&(le(Ie),le(Le)),Je.current===o&&(le(Je),qd._currentValue=Z)}var _e,yt;function ut(o){if(_e===void 0)try{throw Error()}catch(h){var l=h.stack.trim().match(/\n( *(at )?)/);_e=l&&l[1]||"",yt=-1<h.stack.indexOf(`
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
`+_e+o+yt}var pt=!1;function Fe(o,l){if(!o||pt)return"";pt=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(l){var ft=function(){throw Error()};if(Object.defineProperty(ft.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ft,[])}catch(tt){var Ye=tt}Reflect.construct(o,[],ft)}else{try{ft.call()}catch(tt){Ye=tt}o.call(ft.prototype)}}else{try{throw Error()}catch(tt){Ye=tt}(ft=o())&&typeof ft.catch=="function"&&ft.catch(function(){})}}catch(tt){if(tt&&Ye&&typeof tt.stack=="string")return[tt.stack,Ye.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var _=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");_&&_.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var E=p.DetermineComponentFrameRoot(),U=E[0],ee=E[1];if(U&&ee){var be=U.split(`
`),Ke=ee.split(`
`);for(_=p=0;p<be.length&&!be[p].includes("DetermineComponentFrameRoot");)p++;for(;_<Ke.length&&!Ke[_].includes("DetermineComponentFrameRoot");)_++;if(p===be.length||_===Ke.length)for(p=be.length-1,_=Ke.length-1;1<=p&&0<=_&&be[p]!==Ke[_];)_--;for(;1<=p&&0<=_;p--,_--)if(be[p]!==Ke[_]){if(p!==1||_!==1)do if(p--,_--,0>_||be[p]!==Ke[_]){var rt=`
`+be[p].replace(" at new "," at ");return o.displayName&&rt.includes("<anonymous>")&&(rt=rt.replace("<anonymous>",o.displayName)),rt}while(1<=p&&0<=_);break}}}finally{pt=!1,Error.prepareStackTrace=h}return(h=o?o.displayName||o.name:"")?ut(h):""}function _t(o,l){switch(o.tag){case 26:case 27:case 5:return ut(o.type);case 16:return ut("Lazy");case 13:return o.child!==l&&l!==null?ut("Suspense Fallback"):ut("Suspense");case 19:return ut("SuspenseList");case 0:case 15:return Fe(o.type,!1);case 11:return Fe(o.type.render,!1);case 1:return Fe(o.type,!0);case 31:return ut("Activity");default:return""}}function Qe(o){try{var l="",h=null;do l+=_t(o,h),h=o,o=o.return;while(o);return l}catch(p){return`
Error generating stack: `+p.message+`
`+p.stack}}var Xe=Object.prototype.hasOwnProperty,ze=s.unstable_scheduleCallback,Ze=s.unstable_cancelCallback,ct=s.unstable_shouldYield,St=s.unstable_requestPaint,se=s.unstable_now,ke=s.unstable_getCurrentPriorityLevel,De=s.unstable_ImmediatePriority,Ue=s.unstable_UserBlockingPriority,at=s.unstable_NormalPriority,dt=s.unstable_LowPriority,wt=s.unstable_IdlePriority,kt=s.log,Tt=s.unstable_setDisableYieldValue,Ft=null,Qt=null;function Zt(o){if(typeof kt=="function"&&Tt(o),Qt&&typeof Qt.setStrictMode=="function")try{Qt.setStrictMode(Ft,o)}catch{}}var Et=Math.clz32?Math.clz32:Pi,Dt=Math.log,yi=Math.LN2;function Pi(o){return o>>>=0,o===0?32:31-(Dt(o)/yi|0)|0}var Jt=256,ki=262144,gt=4194304;function V(o){var l=o&42;if(l!==0)return l;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function $(o,l,h){var p=o.pendingLanes;if(p===0)return 0;var _=0,E=o.suspendedLanes,U=o.pingedLanes;o=o.warmLanes;var ee=p&134217727;return ee!==0?(p=ee&~E,p!==0?_=V(p):(U&=ee,U!==0?_=V(U):h||(h=ee&~o,h!==0&&(_=V(h))))):(ee=p&~E,ee!==0?_=V(ee):U!==0?_=V(U):h||(h=p&~o,h!==0&&(_=V(h)))),_===0?0:l!==0&&l!==_&&(l&E)===0&&(E=_&-_,h=l&-l,E>=h||E===32&&(h&4194048)!==0)?l:_}function ie(o,l){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&l)===0}function Te(o,l){switch(o){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Be(){var o=gt;return gt<<=1,(gt&62914560)===0&&(gt=4194304),o}function ht(o){for(var l=[],h=0;31>h;h++)l.push(o);return l}function It(o,l){o.pendingLanes|=l,l!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Yt(o,l,h,p,_,E){var U=o.pendingLanes;o.pendingLanes=h,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=h,o.entangledLanes&=h,o.errorRecoveryDisabledLanes&=h,o.shellSuspendCounter=0;var ee=o.entanglements,be=o.expirationTimes,Ke=o.hiddenUpdates;for(h=U&~h;0<h;){var rt=31-Et(h),ft=1<<rt;ee[rt]=0,be[rt]=-1;var Ye=Ke[rt];if(Ye!==null)for(Ke[rt]=null,rt=0;rt<Ye.length;rt++){var tt=Ye[rt];tt!==null&&(tt.lane&=-536870913)}h&=~ft}p!==0&&pi(o,p,0),E!==0&&_===0&&o.tag!==0&&(o.suspendedLanes|=E&~(U&~l))}function pi(o,l,h){o.pendingLanes|=l,o.suspendedLanes&=~l;var p=31-Et(l);o.entangledLanes|=l,o.entanglements[p]=o.entanglements[p]|1073741824|h&261930}function oi(o,l){var h=o.entangledLanes|=l;for(o=o.entanglements;h;){var p=31-Et(h),_=1<<p;_&l|o[p]&l&&(o[p]|=l),h&=~_}}function ci(o,l){var h=l&-l;return h=(h&42)!==0?1:Bi(h),(h&(o.suspendedLanes|l))!==0?0:h}function Bi(o){switch(o){case 2:o=1;break;case 8:o=4;break;case 32:o=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:o=128;break;case 268435456:o=134217728;break;default:o=0}return o}function Gt(o){return o&=-o,2<o?8<o?(o&134217727)!==0?32:268435456:8:2}function xi(){var o=q.p;return o!==0?o:(o=window.event,o===void 0?32:g_(o.type))}function ai(o,l){var h=q.p;try{return q.p=o,l()}finally{q.p=h}}var di=Math.random().toString(36).slice(2),qt="__reactFiber$"+di,Mt="__reactProps$"+di,vt="__reactContainer$"+di,Ci="__reactEvents$"+di,ss="__reactListeners$"+di,vs="__reactHandles$"+di,xs="__reactResources$"+di,Gi="__reactMarker$"+di;function fi(o){delete o[qt],delete o[Mt],delete o[Ci],delete o[ss],delete o[vs]}function Zi(o){var l=o[qt];if(l)return l;for(var h=o.parentNode;h;){if(l=h[vt]||h[qt]){if(h=l.alternate,l.child!==null||h!==null&&h.child!==null)for(o=e_(o);o!==null;){if(h=o[qt])return h;o=e_(o)}return l}o=h,h=o.parentNode}return null}function ts(o){if(o=o[qt]||o[vt]){var l=o.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return o}return null}function $i(o){var l=o.tag;if(l===5||l===26||l===27||l===6)return o.stateNode;throw Error(i(33))}function Ji(o){var l=o[xs];return l||(l=o[xs]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function Di(o){o[Gi]=!0}var $s=new Set,Cs={};function ns(o,l){rs(o,l),rs(o+"Capture",l)}function rs(o,l){for(Cs[o]=l,o=0;o<l.length;o++)$s.add(l[o])}var Rs=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Li={},qi={};function bs(o){return Xe.call(qi,o)?!0:Xe.call(Li,o)?!1:Rs.test(o)?qi[o]=!0:(Li[o]=!0,!1)}function Kt(o,l,h){if(bs(l))if(h===null)o.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":o.removeAttribute(l);return;case"boolean":var p=l.toLowerCase().slice(0,5);if(p!=="data-"&&p!=="aria-"){o.removeAttribute(l);return}}o.setAttribute(l,""+h)}}function ds(o,l,h){if(h===null)o.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(l);return}o.setAttribute(l,""+h)}}function Fi(o,l,h,p){if(p===null)o.removeAttribute(h);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":o.removeAttribute(h);return}o.setAttributeNS(l,h,""+p)}}function Hi(o){switch(typeof o){case"bigint":case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Ge(o){var l=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Lt(o,l,h){var p=Object.getOwnPropertyDescriptor(o.constructor.prototype,l);if(!o.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var _=p.get,E=p.set;return Object.defineProperty(o,l,{configurable:!0,get:function(){return _.call(this)},set:function(U){h=""+U,E.call(this,U)}}),Object.defineProperty(o,l,{enumerable:p.enumerable}),{getValue:function(){return h},setValue:function(U){h=""+U},stopTracking:function(){o._valueTracker=null,delete o[l]}}}}function Ct(o){if(!o._valueTracker){var l=Ge(o)?"checked":"value";o._valueTracker=Lt(o,l,""+o[l])}}function Xt(o){if(!o)return!1;var l=o._valueTracker;if(!l)return!0;var h=l.getValue(),p="";return o&&(p=Ge(o)?o.checked?"true":"false":o.value),o=p,o!==h?(l.setValue(o),!0):!1}function Wt(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var _i=/[\n"\\]/g;function ei(o){return o.replace(_i,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function Ki(o,l,h,p,_,E,U,ee){o.name="",U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"?o.type=U:o.removeAttribute("type"),l!=null?U==="number"?(l===0&&o.value===""||o.value!=l)&&(o.value=""+Hi(l)):o.value!==""+Hi(l)&&(o.value=""+Hi(l)):U!=="submit"&&U!=="reset"||o.removeAttribute("value"),l!=null?In(o,U,Hi(l)):h!=null?In(o,U,Hi(h)):p!=null&&o.removeAttribute("value"),_==null&&E!=null&&(o.defaultChecked=!!E),_!=null&&(o.checked=_&&typeof _!="function"&&typeof _!="symbol"),ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?o.name=""+Hi(ee):o.removeAttribute("name")}function Ts(o,l,h,p,_,E,U,ee){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(o.type=E),l!=null||h!=null){if(!(E!=="submit"&&E!=="reset"||l!=null)){Ct(o);return}h=h!=null?""+Hi(h):"",l=l!=null?""+Hi(l):h,ee||l===o.value||(o.value=l),o.defaultValue=l}p=p??_,p=typeof p!="function"&&typeof p!="symbol"&&!!p,o.checked=ee?o.checked:!!p,o.defaultChecked=!!p,U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"&&(o.name=U),Ct(o)}function In(o,l,h){l==="number"&&Wt(o.ownerDocument)===o||o.defaultValue===""+h||(o.defaultValue=""+h)}function Wi(o,l,h,p){if(o=o.options,l){l={};for(var _=0;_<h.length;_++)l["$"+h[_]]=!0;for(h=0;h<o.length;h++)_=l.hasOwnProperty("$"+o[h].value),o[h].selected!==_&&(o[h].selected=_),_&&p&&(o[h].defaultSelected=!0)}else{for(h=""+Hi(h),l=null,_=0;_<o.length;_++){if(o[_].value===h){o[_].selected=!0,p&&(o[_].defaultSelected=!0);return}l!==null||o[_].disabled||(l=o[_])}l!==null&&(l.selected=!0)}}function Nn(o,l,h){if(l!=null&&(l=""+Hi(l),l!==o.value&&(o.value=l),h==null)){o.defaultValue!==l&&(o.defaultValue=l);return}o.defaultValue=h!=null?""+Hi(h):""}function On(o,l,h,p){if(l==null){if(p!=null){if(h!=null)throw Error(i(92));if(J(p)){if(1<p.length)throw Error(i(93));p=p[0]}h=p}h==null&&(h=""),l=h}h=Hi(l),o.defaultValue=h,p=o.textContent,p===h&&p!==""&&p!==null&&(o.value=p),Ct(o)}function Zs(o,l){if(l){var h=o.firstChild;if(h&&h===o.lastChild&&h.nodeType===3){h.nodeValue=l;return}}o.textContent=l}var pn=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ln(o,l,h){var p=l.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?p?o.setProperty(l,""):l==="float"?o.cssFloat="":o[l]="":p?o.setProperty(l,h):typeof h!="number"||h===0||pn.has(l)?l==="float"?o.cssFloat=h:o[l]=(""+h).trim():o[l]=h+"px"}function Is(o,l,h){if(l!=null&&typeof l!="object")throw Error(i(62));if(o=o.style,h!=null){for(var p in h)!h.hasOwnProperty(p)||l!=null&&l.hasOwnProperty(p)||(p.indexOf("--")===0?o.setProperty(p,""):p==="float"?o.cssFloat="":o[p]="");for(var _ in l)p=l[_],l.hasOwnProperty(_)&&h[_]!==p&&ln(o,_,p)}else for(var E in l)l.hasOwnProperty(E)&&ln(o,E,l[E])}function un(o){if(o.indexOf("-")===-1)return!1;switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Mn=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Js=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function en(o){return Js.test(""+o)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":o}function zi(){}var Pn=null;function _n(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var me=null,we=null;function ue(o){var l=ts(o);if(l&&(o=l.stateNode)){var h=o[Mt]||null;e:switch(o=l.stateNode,l.type){case"input":if(Ki(o,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),l=h.name,h.type==="radio"&&l!=null){for(h=o;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+ei(""+l)+'"][type="radio"]'),l=0;l<h.length;l++){var p=h[l];if(p!==o&&p.form===o.form){var _=p[Mt]||null;if(!_)throw Error(i(90));Ki(p,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name)}}for(l=0;l<h.length;l++)p=h[l],p.form===o.form&&Xt(p)}break e;case"textarea":Nn(o,h.value,h.defaultValue);break e;case"select":l=h.value,l!=null&&Wi(o,!!h.multiple,l,!1)}}}var pe=!1;function xe(o,l,h){if(pe)return o(l,h);pe=!0;try{var p=o(l);return p}finally{if(pe=!1,(me!==null||we!==null)&&(Jf(),me&&(l=me,o=we,we=me=null,ue(l),o)))for(l=0;l<o.length;l++)ue(o[l])}}function Oe(o,l){var h=o.stateNode;if(h===null)return null;var p=h[Mt]||null;if(p===null)return null;h=p[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(o=o.type,p=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!p;break e;default:o=!1}if(o)return null;if(h&&typeof h!="function")throw Error(i(231,l,typeof h));return h}var Q=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ne=!1;if(Q)try{var ce={};Object.defineProperty(ce,"passive",{get:function(){ne=!0}}),window.addEventListener("test",ce,ce),window.removeEventListener("test",ce,ce)}catch{ne=!1}var fe=null,Ne=null,We=null;function xt(){if(We)return We;var o,l=Ne,h=l.length,p,_="value"in fe?fe.value:fe.textContent,E=_.length;for(o=0;o<h&&l[o]===_[o];o++);var U=h-o;for(p=1;p<=U&&l[h-p]===_[E-p];p++);return We=_.slice(o,1<p?1-p:void 0)}function it(o){var l=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&l===13&&(o=13)):o=l,o===10&&(o=13),32<=o||o===13?o:0}function mt(){return!0}function Rt(){return!1}function Pt(o){function l(h,p,_,E,U){this._reactName=h,this._targetInst=_,this.type=p,this.nativeEvent=E,this.target=U,this.currentTarget=null;for(var ee in o)o.hasOwnProperty(ee)&&(h=o[ee],this[ee]=h?h(E):E[ee]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?mt:Rt,this.isPropagationStopped=Rt,this}return g(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=mt)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=mt)},persist:function(){},isPersistent:mt}),l}var Nt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ht=Pt(Nt),Vi=g({},Nt,{view:0,detail:0}),gn=Pt(Vi),yn,No,Er,hs=g({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:td,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Er&&(Er&&o.type==="mousemove"?(yn=o.screenX-Er.screenX,No=o.screenY-Er.screenY):No=yn=0,Er=o),yn)},movementY:function(o){return"movementY"in o?o.movementY:No}}),Ms=Pt(hs),En=g({},hs,{dataTransfer:0}),ba=Pt(En),sf=g({},Vi,{relatedTarget:0}),Ta=Pt(sf),Nl=g({},Nt,{animationName:0,elapsedTime:0,pseudoElement:0}),Ol=Pt(Nl),Cu=g({},Nt,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),wr=Pt(Cu),aa=g({},Nt,{data:0}),Ml=Pt(aa),nf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mp={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Pp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bp(o){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(o):(o=Pp[o])?!!l[o]:!1}function td(){return Bp}var rf=g({},Vi,{key:function(o){if(o.key){var l=nf[o.key]||o.key;if(l!=="Unidentified")return l}return o.type==="keypress"?(o=it(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?Mp[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:td,charCode:function(o){return o.type==="keypress"?it(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?it(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),af=Pt(rf),Du=g({},hs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Oo=Pt(Du),Lu=g({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:td}),eo=Pt(Lu),Fp=g({},Nt,{propertyName:0,elapsedTime:0,pseudoElement:0}),of=Pt(Fp),lf=g({},hs,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),uf=Pt(lf),Up=g({},Nt,{newState:0,oldState:0}),jp=Pt(Up),$p=[9,13,27,32],Mo=Q&&"CompositionEvent"in window,Pl=null;Q&&"documentMode"in document&&(Pl=document.documentMode);var cf=Q&&"TextEvent"in window&&!Pl,df=Q&&(!Mo||Pl&&8<Pl&&11>=Pl),hf=" ",id=!1;function Ru(o,l){switch(o){case"keyup":return $p.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ff(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Po=!1;function Hp(o,l){switch(o){case"compositionend":return ff(l);case"keypress":return l.which!==32?null:(id=!0,hf);case"textInput":return o=l.data,o===hf&&id?null:o;default:return null}}function sd(o,l){if(Po)return o==="compositionend"||!Mo&&Ru(o,l)?(o=xt(),We=Ne=fe=null,Po=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return df&&l.locale!=="ko"?null:l.data;default:return null}}var zp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function nd(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l==="input"?!!zp[o.type]:l==="textarea"}function mf(o,l,h,p){me?we?we.push(p):we=[p]:me=p,l=am(l,"onChange"),0<l.length&&(h=new Ht("onChange","change",null,h,p),o.push({event:h,listeners:l}))}var Bl=null,Bo=null;function Vp(o){jS(o,0)}function Fl(o){var l=$i(o);if(Xt(l))return o}function rd(o,l){if(o==="change")return l}var ad=!1;if(Q){var od;if(Q){var ld="oninput"in document;if(!ld){var Ul=document.createElement("div");Ul.setAttribute("oninput","return;"),ld=typeof Ul.oninput=="function"}od=ld}else od=!1;ad=od&&(!document.documentMode||9<document.documentMode)}function pf(){Bl&&(Bl.detachEvent("onpropertychange",gf),Bo=Bl=null)}function gf(o){if(o.propertyName==="value"&&Fl(Bo)){var l=[];mf(l,Bo,o,_n(o)),xe(Vp,l)}}function Gp(o,l,h){o==="focusin"?(pf(),Bl=l,Bo=h,Bl.attachEvent("onpropertychange",gf)):o==="focusout"&&pf()}function qp(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Fl(Bo)}function yf(o,l){if(o==="click")return Fl(l)}function Kp(o,l){if(o==="input"||o==="change")return Fl(l)}function jl(o,l){return o===l&&(o!==0||1/o===1/l)||o!==o&&l!==l}var Gn=typeof Object.is=="function"?Object.is:jl;function Sa(o,l){if(Gn(o,l))return!0;if(typeof o!="object"||o===null||typeof l!="object"||l===null)return!1;var h=Object.keys(o),p=Object.keys(l);if(h.length!==p.length)return!1;for(p=0;p<h.length;p++){var _=h[p];if(!Xe.call(l,_)||!Gn(o[_],l[_]))return!1}return!0}function Fo(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Ps(o,l){var h=Fo(o);o=0;for(var p;h;){if(h.nodeType===3){if(p=o+h.textContent.length,o<=l&&p>=l)return{node:h,offset:l-o};o=p}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Fo(h)}}function to(o,l){return o&&l?o===l?!0:o&&o.nodeType===3?!1:l&&l.nodeType===3?to(o,l.parentNode):"contains"in o?o.contains(l):o.compareDocumentPosition?!!(o.compareDocumentPosition(l)&16):!1:!1}function Iu(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var l=Wt(o.document);l instanceof o.HTMLIFrameElement;){try{var h=typeof l.contentWindow.location.href=="string"}catch{h=!1}if(h)o=l.contentWindow;else break;l=Wt(o.document)}return l}function ud(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l&&(l==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||l==="textarea"||o.contentEditable==="true")}var Wp=Q&&"documentMode"in document&&11>=document.documentMode,Uo=null,cd=null,jo=null,Nu=!1;function dd(o,l,h){var p=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Nu||Uo==null||Uo!==Wt(p)||(p=Uo,"selectionStart"in p&&ud(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),jo&&Sa(jo,p)||(jo=p,p=am(cd,"onSelect"),0<p.length&&(l=new Ht("onSelect","select",null,l,h),o.push({event:l,listeners:p}),l.target=Uo)))}function _a(o,l){var h={};return h[o.toLowerCase()]=l.toLowerCase(),h["Webkit"+o]="webkit"+l,h["Moz"+o]="moz"+l,h}var io={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionrun:_a("Transition","TransitionRun"),transitionstart:_a("Transition","TransitionStart"),transitioncancel:_a("Transition","TransitionCancel"),transitionend:_a("Transition","TransitionEnd")},$l={},hd={};Q&&(hd=document.createElement("div").style,"AnimationEvent"in window||(delete io.animationend.animation,delete io.animationiteration.animation,delete io.animationstart.animation),"TransitionEvent"in window||delete io.transitionend.transition);function oa(o){if($l[o])return $l[o];if(!io[o])return o;var l=io[o],h;for(h in l)if(l.hasOwnProperty(h)&&h in hd)return $l[o]=l[h];return o}var vf=oa("animationend"),$o=oa("animationiteration"),xf=oa("animationstart"),bf=oa("transitionrun"),Tf=oa("transitionstart"),Yp=oa("transitioncancel"),Sf=oa("transitionend"),fd=new Map,md="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");md.push("scrollEnd");function Ar(o,l){fd.set(o,l),ns(l,[o])}var Ho=typeof reportError=="function"?reportError:function(o){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof o=="object"&&o!==null&&typeof o.message=="string"?String(o.message):String(o),error:o});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",o);return}console.error(o)},nr=[],zo=0,pd=0;function Ou(){for(var o=zo,l=pd=zo=0;l<o;){var h=nr[l];nr[l++]=null;var p=nr[l];nr[l++]=null;var _=nr[l];nr[l++]=null;var E=nr[l];if(nr[l++]=null,p!==null&&_!==null){var U=p.pending;U===null?_.next=_:(_.next=U.next,U.next=_),p.pending=_}E!==0&&_f(h,_,E)}}function Mu(o,l,h,p){nr[zo++]=o,nr[zo++]=l,nr[zo++]=h,nr[zo++]=p,pd|=p,o.lanes|=p,o=o.alternate,o!==null&&(o.lanes|=p)}function gd(o,l,h,p){return Mu(o,l,h,p),Pu(o)}function so(o,l){return Mu(o,null,null,l),Pu(o)}function _f(o,l,h){o.lanes|=h;var p=o.alternate;p!==null&&(p.lanes|=h);for(var _=!1,E=o.return;E!==null;)E.childLanes|=h,p=E.alternate,p!==null&&(p.childLanes|=h),E.tag===22&&(o=E.stateNode,o===null||o._visibility&1||(_=!0)),o=E,E=E.return;return o.tag===3?(E=o.stateNode,_&&l!==null&&(_=31-Et(h),o=E.hiddenUpdates,p=o[_],p===null?o[_]=[l]:p.push(l),l.lane=h|536870912),E):null}function Pu(o){if(50<Ud)throw Ud=0,Kg=null,Error(i(185));for(var l=o.return;l!==null;)o=l,l=o.return;return o.tag===3?o.stateNode:null}var Vo={};function Xp(o,l,h,p){this.tag=o,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qs(o,l,h,p){return new Xp(o,l,h,p)}function yd(o){return o=o.prototype,!(!o||!o.isReactComponent)}function la(o,l){var h=o.alternate;return h===null?(h=qs(o.tag,l,o.key,o.mode),h.elementType=o.elementType,h.type=o.type,h.stateNode=o.stateNode,h.alternate=o,o.alternate=h):(h.pendingProps=l,h.type=o.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=o.flags&65011712,h.childLanes=o.childLanes,h.lanes=o.lanes,h.child=o.child,h.memoizedProps=o.memoizedProps,h.memoizedState=o.memoizedState,h.updateQueue=o.updateQueue,l=o.dependencies,h.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},h.sibling=o.sibling,h.index=o.index,h.ref=o.ref,h.refCleanup=o.refCleanup,h}function Ef(o,l){o.flags&=65011714;var h=o.alternate;return h===null?(o.childLanes=0,o.lanes=l,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=h.childLanes,o.lanes=h.lanes,o.child=h.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=h.memoizedProps,o.memoizedState=h.memoizedState,o.updateQueue=h.updateQueue,o.type=h.type,l=h.dependencies,o.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),o}function vd(o,l,h,p,_,E){var U=0;if(p=o,typeof o=="function")yd(o)&&(U=1);else if(typeof o=="string")U=YI(o,h,Ie.current)?26:o==="html"||o==="head"||o==="body"?27:5;else e:switch(o){case k:return o=qs(31,h,l,_),o.elementType=k,o.lanes=E,o;case S:return Ea(h.children,_,E,l);case w:U=8,_|=24;break;case L:return o=qs(12,h,l,_|2),o.elementType=L,o.lanes=E,o;case P:return o=qs(13,h,l,_),o.elementType=P,o.lanes=E,o;case G:return o=qs(19,h,l,_),o.elementType=G,o.lanes=E,o;default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case I:U=10;break e;case O:U=9;break e;case j:U=11;break e;case N:U=14;break e;case K:U=16,p=null;break e}U=29,h=Error(i(130,o===null?"null":typeof o,"")),p=null}return l=qs(U,h,l,_),l.elementType=o,l.type=p,l.lanes=E,l}function Ea(o,l,h,p){return o=qs(7,o,p,l),o.lanes=h,o}function Hl(o,l,h){return o=qs(6,o,null,l),o.lanes=h,o}function xd(o){var l=qs(18,null,null,0);return l.stateNode=o,l}function Go(o,l,h){return l=qs(4,o.children!==null?o.children:[],o.key,l),l.lanes=h,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}var zl=new WeakMap;function rr(o,l){if(typeof o=="object"&&o!==null){var h=zl.get(o);return h!==void 0?h:(l={value:o,source:l,stack:Qe(l)},zl.set(o,l),l)}return{value:o,source:l,stack:Qe(l)}}var qo=[],Ko=0,Bu=null,Vl=0,qn=[],ar=0,wa=null,kr=1,Bn="";function Ei(o,l){qo[Ko++]=Vl,qo[Ko++]=Bu,Bu=o,Vl=l}function Aa(o,l,h){qn[ar++]=kr,qn[ar++]=Bn,qn[ar++]=wa,wa=o;var p=kr;o=Bn;var _=32-Et(p)-1;p&=~(1<<_),h+=1;var E=32-Et(l)+_;if(30<E){var U=_-_%5;E=(p&(1<<U)-1).toString(32),p>>=U,_-=U,kr=1<<32-Et(l)+_|h<<_|p,Bn=E+o}else kr=1<<E|h<<_|p,Bn=o}function vn(o){o.return!==null&&(Ei(o,1),Aa(o,1,0))}function or(o){for(;o===Bu;)Bu=qo[--Ko],qo[Ko]=null,Vl=qo[--Ko],qo[Ko]=null;for(;o===wa;)wa=qn[--ar],qn[ar]=null,Bn=qn[--ar],qn[ar]=null,kr=qn[--ar],qn[ar]=null}function wf(o,l){qn[ar++]=kr,qn[ar++]=Bn,qn[ar++]=wa,kr=l.id,Bn=l.overflow,wa=o}var cn=null,Ss=null,Ni=!1,ka=null,lr=!1,bd=Error(i(519));function Ca(o){var l=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw C(rr(l,o)),bd}function Af(o){var l=o.stateNode,h=o.type,p=o.memoizedProps;switch(l[qt]=o,l[Mt]=p,h){case"dialog":Mi("cancel",l),Mi("close",l);break;case"iframe":case"object":case"embed":Mi("load",l);break;case"video":case"audio":for(h=0;h<$d.length;h++)Mi($d[h],l);break;case"source":Mi("error",l);break;case"img":case"image":case"link":Mi("error",l),Mi("load",l);break;case"details":Mi("toggle",l);break;case"input":Mi("invalid",l),Ts(l,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":Mi("invalid",l);break;case"textarea":Mi("invalid",l),On(l,p.value,p.defaultValue,p.children)}h=p.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||l.textContent===""+h||p.suppressHydrationWarning===!0||VS(l.textContent,h)?(p.popover!=null&&(Mi("beforetoggle",l),Mi("toggle",l)),p.onScroll!=null&&Mi("scroll",l),p.onScrollEnd!=null&&Mi("scrollend",l),p.onClick!=null&&(l.onclick=zi),l=!0):l=!1,l||Ca(o,!0)}function Td(o){for(cn=o.return;cn;)switch(cn.tag){case 5:case 31:case 13:lr=!1;return;case 27:case 3:lr=!0;return;default:cn=cn.return}}function x(o){if(o!==cn)return!1;if(!Ni)return Td(o),Ni=!0,!1;var l=o.tag,h;if((h=l!==3&&l!==27)&&((h=l===5)&&(h=o.type,h=!(h!=="form"&&h!=="button")||ly(o.type,o.memoizedProps)),h=!h),h&&Ss&&Ca(o),Td(o),l===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(i(317));Ss=JS(o)}else if(l===31){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(i(317));Ss=JS(o)}else l===27?(l=Ss,al(o.type)?(o=fy,fy=null,Ss=o):Ss=l):Ss=cn?Kr(o.stateNode.nextSibling):null;return!0}function A(){Ss=cn=null,Ni=!1}function D(){var o=ka;return o!==null&&(hr===null?hr=o:hr.push.apply(hr,o),ka=null),o}function C(o){ka===null?ka=[o]:ka.push(o)}var M=F(null),B=null,ae=null;function de(o,l,h){ge(M,l._currentValue),l._currentValue=h}function he(o){o._currentValue=M.current,le(M)}function ve(o,l,h){for(;o!==null;){var p=o.alternate;if((o.childLanes&l)!==l?(o.childLanes|=l,p!==null&&(p.childLanes|=l)):p!==null&&(p.childLanes&l)!==l&&(p.childLanes|=l),o===h)break;o=o.return}}function Ce(o,l,h,p){var _=o.child;for(_!==null&&(_.return=o);_!==null;){var E=_.dependencies;if(E!==null){var U=_.child;E=E.firstContext;e:for(;E!==null;){var ee=E;E=_;for(var be=0;be<l.length;be++)if(ee.context===l[be]){E.lanes|=h,ee=E.alternate,ee!==null&&(ee.lanes|=h),ve(E.return,h,o),p||(U=null);break e}E=ee.next}}else if(_.tag===18){if(U=_.return,U===null)throw Error(i(341));U.lanes|=h,E=U.alternate,E!==null&&(E.lanes|=h),ve(U,h,o),U=null}else U=_.child;if(U!==null)U.return=_;else for(U=_;U!==null;){if(U===o){U=null;break}if(_=U.sibling,_!==null){_.return=U.return,U=_;break}U=U.return}_=U}}function et(o,l,h,p){o=null;for(var _=l,E=!1;_!==null;){if(!E){if((_.flags&524288)!==0)E=!0;else if((_.flags&262144)!==0)break}if(_.tag===10){var U=_.alternate;if(U===null)throw Error(i(387));if(U=U.memoizedProps,U!==null){var ee=_.type;Gn(_.pendingProps.value,U.value)||(o!==null?o.push(ee):o=[ee])}}else if(_===Je.current){if(U=_.alternate,U===null)throw Error(i(387));U.memoizedState.memoizedState!==_.memoizedState.memoizedState&&(o!==null?o.push(qd):o=[qd])}_=_.return}o!==null&&Ce(l,o,h,p),l.flags|=262144}function At(o){for(o=o.firstContext;o!==null;){if(!Gn(o.context._currentValue,o.memoizedValue))return!0;o=o.next}return!1}function nt(o){B=o,ae=null,o=o.dependencies,o!==null&&(o.firstContext=null)}function Bt(o){return tn(B,o)}function mi(o,l){return B===null&&nt(o),tn(o,l)}function tn(o,l){var h=l._currentValue;if(l={context:l,memoizedValue:h,next:null},ae===null){if(o===null)throw Error(i(308));ae=l,o.dependencies={lanes:0,firstContext:l},o.flags|=524288}else ae=ae.next=l;return h}var Qn=typeof AbortController<"u"?AbortController:function(){var o=[],l=this.signal={aborted:!1,addEventListener:function(h,p){o.push(p)}};this.abort=function(){l.aborted=!0,o.forEach(function(h){return h()})}},Da=s.unstable_scheduleCallback,Gl=s.unstable_NormalPriority,Ds={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function no(){return{controller:new Qn,data:new Map,refCount:0}}function ua(o){o.refCount--,o.refCount===0&&Da(Gl,function(){o.controller.abort()})}var La=null,as=0,Gr=0,wn=null;function WR(o,l){if(La===null){var h=La=[];as=0,Gr=Jg(),wn={status:"pending",value:void 0,then:function(p){h.push(p)}}}return as++,l.then(L1,L1),l}function L1(){if(--as===0&&La!==null){wn!==null&&(wn.status="fulfilled");var o=La;La=null,Gr=0,wn=null;for(var l=0;l<o.length;l++)(0,o[l])()}}function YR(o,l){var h=[],p={status:"pending",value:null,reason:null,then:function(_){h.push(_)}};return o.then(function(){p.status="fulfilled",p.value=l;for(var _=0;_<h.length;_++)(0,h[_])(l)},function(_){for(p.status="rejected",p.reason=_,_=0;_<h.length;_++)(0,h[_])(void 0)}),p}var R1=W.S;W.S=function(o,l){mS=se(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&WR(o,l),R1!==null&&R1(o,l)};var ql=F(null);function Qp(){var o=ql.current;return o!==null?o:_s.pooledCache}function kf(o,l){l===null?ge(ql,ql.current):ge(ql,l.pool)}function I1(){var o=Qp();return o===null?null:{parent:Ds._currentValue,pool:o}}var Fu=Error(i(460)),Zp=Error(i(474)),Cf=Error(i(542)),Df={then:function(){}};function N1(o){return o=o.status,o==="fulfilled"||o==="rejected"}function O1(o,l,h){switch(h=o[h],h===void 0?o.push(l):h!==l&&(l.then(zi,zi),l=h),l.status){case"fulfilled":return l.value;case"rejected":throw o=l.reason,P1(o),o;default:if(typeof l.status=="string")l.then(zi,zi);else{if(o=_s,o!==null&&100<o.shellSuspendCounter)throw Error(i(482));o=l,o.status="pending",o.then(function(p){if(l.status==="pending"){var _=l;_.status="fulfilled",_.value=p}},function(p){if(l.status==="pending"){var _=l;_.status="rejected",_.reason=p}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw o=l.reason,P1(o),o}throw Wl=l,Fu}}function Kl(o){try{var l=o._init;return l(o._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(Wl=h,Fu):h}}var Wl=null;function M1(){if(Wl===null)throw Error(i(459));var o=Wl;return Wl=null,o}function P1(o){if(o===Fu||o===Cf)throw Error(i(483))}var Uu=null,Sd=0;function Lf(o){var l=Sd;return Sd+=1,Uu===null&&(Uu=[]),O1(Uu,o,l)}function _d(o,l){l=l.props.ref,o.ref=l!==void 0?l:null}function Rf(o,l){throw l.$$typeof===y?Error(i(525)):(o=Object.prototype.toString.call(l),Error(i(31,o==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":o)))}function B1(o){function l(Me,Ae){if(o){var qe=Me.deletions;qe===null?(Me.deletions=[Ae],Me.flags|=16):qe.push(Ae)}}function h(Me,Ae){if(!o)return null;for(;Ae!==null;)l(Me,Ae),Ae=Ae.sibling;return null}function p(Me){for(var Ae=new Map;Me!==null;)Me.key!==null?Ae.set(Me.key,Me):Ae.set(Me.index,Me),Me=Me.sibling;return Ae}function _(Me,Ae){return Me=la(Me,Ae),Me.index=0,Me.sibling=null,Me}function E(Me,Ae,qe){return Me.index=qe,o?(qe=Me.alternate,qe!==null?(qe=qe.index,qe<Ae?(Me.flags|=67108866,Ae):qe):(Me.flags|=67108866,Ae)):(Me.flags|=1048576,Ae)}function U(Me){return o&&Me.alternate===null&&(Me.flags|=67108866),Me}function ee(Me,Ae,qe,lt){return Ae===null||Ae.tag!==6?(Ae=Hl(qe,Me.mode,lt),Ae.return=Me,Ae):(Ae=_(Ae,qe),Ae.return=Me,Ae)}function be(Me,Ae,qe,lt){var ti=qe.type;return ti===S?rt(Me,Ae,qe.props.children,lt,qe.key):Ae!==null&&(Ae.elementType===ti||typeof ti=="object"&&ti!==null&&ti.$$typeof===K&&Kl(ti)===Ae.type)?(Ae=_(Ae,qe.props),_d(Ae,qe),Ae.return=Me,Ae):(Ae=vd(qe.type,qe.key,qe.props,null,Me.mode,lt),_d(Ae,qe),Ae.return=Me,Ae)}function Ke(Me,Ae,qe,lt){return Ae===null||Ae.tag!==4||Ae.stateNode.containerInfo!==qe.containerInfo||Ae.stateNode.implementation!==qe.implementation?(Ae=Go(qe,Me.mode,lt),Ae.return=Me,Ae):(Ae=_(Ae,qe.children||[]),Ae.return=Me,Ae)}function rt(Me,Ae,qe,lt,ti){return Ae===null||Ae.tag!==7?(Ae=Ea(qe,Me.mode,lt,ti),Ae.return=Me,Ae):(Ae=_(Ae,qe),Ae.return=Me,Ae)}function ft(Me,Ae,qe){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number"||typeof Ae=="bigint")return Ae=Hl(""+Ae,Me.mode,qe),Ae.return=Me,Ae;if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case v:return qe=vd(Ae.type,Ae.key,Ae.props,null,Me.mode,qe),_d(qe,Ae),qe.return=Me,qe;case T:return Ae=Go(Ae,Me.mode,qe),Ae.return=Me,Ae;case K:return Ae=Kl(Ae),ft(Me,Ae,qe)}if(J(Ae)||z(Ae))return Ae=Ea(Ae,Me.mode,qe,null),Ae.return=Me,Ae;if(typeof Ae.then=="function")return ft(Me,Lf(Ae),qe);if(Ae.$$typeof===I)return ft(Me,mi(Me,Ae),qe);Rf(Me,Ae)}return null}function Ye(Me,Ae,qe,lt){var ti=Ae!==null?Ae.key:null;if(typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint")return ti!==null?null:ee(Me,Ae,""+qe,lt);if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case v:return qe.key===ti?be(Me,Ae,qe,lt):null;case T:return qe.key===ti?Ke(Me,Ae,qe,lt):null;case K:return qe=Kl(qe),Ye(Me,Ae,qe,lt)}if(J(qe)||z(qe))return ti!==null?null:rt(Me,Ae,qe,lt,null);if(typeof qe.then=="function")return Ye(Me,Ae,Lf(qe),lt);if(qe.$$typeof===I)return Ye(Me,Ae,mi(Me,qe),lt);Rf(Me,qe)}return null}function tt(Me,Ae,qe,lt,ti){if(typeof lt=="string"&&lt!==""||typeof lt=="number"||typeof lt=="bigint")return Me=Me.get(qe)||null,ee(Ae,Me,""+lt,ti);if(typeof lt=="object"&&lt!==null){switch(lt.$$typeof){case v:return Me=Me.get(lt.key===null?qe:lt.key)||null,be(Ae,Me,lt,ti);case T:return Me=Me.get(lt.key===null?qe:lt.key)||null,Ke(Ae,Me,lt,ti);case K:return lt=Kl(lt),tt(Me,Ae,qe,lt,ti)}if(J(lt)||z(lt))return Me=Me.get(qe)||null,rt(Ae,Me,lt,ti,null);if(typeof lt.then=="function")return tt(Me,Ae,qe,Lf(lt),ti);if(lt.$$typeof===I)return tt(Me,Ae,qe,mi(Ae,lt),ti);Rf(Ae,lt)}return null}function $t(Me,Ae,qe,lt){for(var ti=null,Yi=null,zt=Ae,Si=Ae=0,ji=null;zt!==null&&Si<qe.length;Si++){zt.index>Si?(ji=zt,zt=null):ji=zt.sibling;var Xi=Ye(Me,zt,qe[Si],lt);if(Xi===null){zt===null&&(zt=ji);break}o&&zt&&Xi.alternate===null&&l(Me,zt),Ae=E(Xi,Ae,Si),Yi===null?ti=Xi:Yi.sibling=Xi,Yi=Xi,zt=ji}if(Si===qe.length)return h(Me,zt),Ni&&Ei(Me,Si),ti;if(zt===null){for(;Si<qe.length;Si++)zt=ft(Me,qe[Si],lt),zt!==null&&(Ae=E(zt,Ae,Si),Yi===null?ti=zt:Yi.sibling=zt,Yi=zt);return Ni&&Ei(Me,Si),ti}for(zt=p(zt);Si<qe.length;Si++)ji=tt(zt,Me,Si,qe[Si],lt),ji!==null&&(o&&ji.alternate!==null&&zt.delete(ji.key===null?Si:ji.key),Ae=E(ji,Ae,Si),Yi===null?ti=ji:Yi.sibling=ji,Yi=ji);return o&&zt.forEach(function(dl){return l(Me,dl)}),Ni&&Ei(Me,Si),ti}function li(Me,Ae,qe,lt){if(qe==null)throw Error(i(151));for(var ti=null,Yi=null,zt=Ae,Si=Ae=0,ji=null,Xi=qe.next();zt!==null&&!Xi.done;Si++,Xi=qe.next()){zt.index>Si?(ji=zt,zt=null):ji=zt.sibling;var dl=Ye(Me,zt,Xi.value,lt);if(dl===null){zt===null&&(zt=ji);break}o&&zt&&dl.alternate===null&&l(Me,zt),Ae=E(dl,Ae,Si),Yi===null?ti=dl:Yi.sibling=dl,Yi=dl,zt=ji}if(Xi.done)return h(Me,zt),Ni&&Ei(Me,Si),ti;if(zt===null){for(;!Xi.done;Si++,Xi=qe.next())Xi=ft(Me,Xi.value,lt),Xi!==null&&(Ae=E(Xi,Ae,Si),Yi===null?ti=Xi:Yi.sibling=Xi,Yi=Xi);return Ni&&Ei(Me,Si),ti}for(zt=p(zt);!Xi.done;Si++,Xi=qe.next())Xi=tt(zt,Me,Si,Xi.value,lt),Xi!==null&&(o&&Xi.alternate!==null&&zt.delete(Xi.key===null?Si:Xi.key),Ae=E(Xi,Ae,Si),Yi===null?ti=Xi:Yi.sibling=Xi,Yi=Xi);return o&&zt.forEach(function(aN){return l(Me,aN)}),Ni&&Ei(Me,Si),ti}function ps(Me,Ae,qe,lt){if(typeof qe=="object"&&qe!==null&&qe.type===S&&qe.key===null&&(qe=qe.props.children),typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case v:e:{for(var ti=qe.key;Ae!==null;){if(Ae.key===ti){if(ti=qe.type,ti===S){if(Ae.tag===7){h(Me,Ae.sibling),lt=_(Ae,qe.props.children),lt.return=Me,Me=lt;break e}}else if(Ae.elementType===ti||typeof ti=="object"&&ti!==null&&ti.$$typeof===K&&Kl(ti)===Ae.type){h(Me,Ae.sibling),lt=_(Ae,qe.props),_d(lt,qe),lt.return=Me,Me=lt;break e}h(Me,Ae);break}else l(Me,Ae);Ae=Ae.sibling}qe.type===S?(lt=Ea(qe.props.children,Me.mode,lt,qe.key),lt.return=Me,Me=lt):(lt=vd(qe.type,qe.key,qe.props,null,Me.mode,lt),_d(lt,qe),lt.return=Me,Me=lt)}return U(Me);case T:e:{for(ti=qe.key;Ae!==null;){if(Ae.key===ti)if(Ae.tag===4&&Ae.stateNode.containerInfo===qe.containerInfo&&Ae.stateNode.implementation===qe.implementation){h(Me,Ae.sibling),lt=_(Ae,qe.children||[]),lt.return=Me,Me=lt;break e}else{h(Me,Ae);break}else l(Me,Ae);Ae=Ae.sibling}lt=Go(qe,Me.mode,lt),lt.return=Me,Me=lt}return U(Me);case K:return qe=Kl(qe),ps(Me,Ae,qe,lt)}if(J(qe))return $t(Me,Ae,qe,lt);if(z(qe)){if(ti=z(qe),typeof ti!="function")throw Error(i(150));return qe=ti.call(qe),li(Me,Ae,qe,lt)}if(typeof qe.then=="function")return ps(Me,Ae,Lf(qe),lt);if(qe.$$typeof===I)return ps(Me,Ae,mi(Me,qe),lt);Rf(Me,qe)}return typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint"?(qe=""+qe,Ae!==null&&Ae.tag===6?(h(Me,Ae.sibling),lt=_(Ae,qe),lt.return=Me,Me=lt):(h(Me,Ae),lt=Hl(qe,Me.mode,lt),lt.return=Me,Me=lt),U(Me)):h(Me,Ae)}return function(Me,Ae,qe,lt){try{Sd=0;var ti=ps(Me,Ae,qe,lt);return Uu=null,ti}catch(zt){if(zt===Fu||zt===Cf)throw zt;var Yi=qs(29,zt,null,Me.mode);return Yi.lanes=lt,Yi.return=Me,Yi}}}var Yl=B1(!0),F1=B1(!1),Wo=!1;function Jp(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function eg(o,l){o=o.updateQueue,l.updateQueue===o&&(l.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function Yo(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function Xo(o,l,h){var p=o.updateQueue;if(p===null)return null;if(p=p.shared,(es&2)!==0){var _=p.pending;return _===null?l.next=l:(l.next=_.next,_.next=l),p.pending=l,l=Pu(o),_f(o,null,h),l}return Mu(o,p,l,h),Pu(o)}function Ed(o,l,h){if(l=l.updateQueue,l!==null&&(l=l.shared,(h&4194048)!==0)){var p=l.lanes;p&=o.pendingLanes,h|=p,l.lanes=h,oi(o,h)}}function tg(o,l){var h=o.updateQueue,p=o.alternate;if(p!==null&&(p=p.updateQueue,h===p)){var _=null,E=null;if(h=h.firstBaseUpdate,h!==null){do{var U={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};E===null?_=E=U:E=E.next=U,h=h.next}while(h!==null);E===null?_=E=l:E=E.next=l}else _=E=l;h={baseState:p.baseState,firstBaseUpdate:_,lastBaseUpdate:E,shared:p.shared,callbacks:p.callbacks},o.updateQueue=h;return}o=h.lastBaseUpdate,o===null?h.firstBaseUpdate=l:o.next=l,h.lastBaseUpdate=l}var ig=!1;function wd(){if(ig){var o=wn;if(o!==null)throw o}}function Ad(o,l,h,p){ig=!1;var _=o.updateQueue;Wo=!1;var E=_.firstBaseUpdate,U=_.lastBaseUpdate,ee=_.shared.pending;if(ee!==null){_.shared.pending=null;var be=ee,Ke=be.next;be.next=null,U===null?E=Ke:U.next=Ke,U=be;var rt=o.alternate;rt!==null&&(rt=rt.updateQueue,ee=rt.lastBaseUpdate,ee!==U&&(ee===null?rt.firstBaseUpdate=Ke:ee.next=Ke,rt.lastBaseUpdate=be))}if(E!==null){var ft=_.baseState;U=0,rt=Ke=be=null,ee=E;do{var Ye=ee.lane&-536870913,tt=Ye!==ee.lane;if(tt?(Ui&Ye)===Ye:(p&Ye)===Ye){Ye!==0&&Ye===Gr&&(ig=!0),rt!==null&&(rt=rt.next={lane:0,tag:ee.tag,payload:ee.payload,callback:null,next:null});e:{var $t=o,li=ee;Ye=l;var ps=h;switch(li.tag){case 1:if($t=li.payload,typeof $t=="function"){ft=$t.call(ps,ft,Ye);break e}ft=$t;break e;case 3:$t.flags=$t.flags&-65537|128;case 0:if($t=li.payload,Ye=typeof $t=="function"?$t.call(ps,ft,Ye):$t,Ye==null)break e;ft=g({},ft,Ye);break e;case 2:Wo=!0}}Ye=ee.callback,Ye!==null&&(o.flags|=64,tt&&(o.flags|=8192),tt=_.callbacks,tt===null?_.callbacks=[Ye]:tt.push(Ye))}else tt={lane:Ye,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},rt===null?(Ke=rt=tt,be=ft):rt=rt.next=tt,U|=Ye;if(ee=ee.next,ee===null){if(ee=_.shared.pending,ee===null)break;tt=ee,ee=tt.next,tt.next=null,_.lastBaseUpdate=tt,_.shared.pending=null}}while(!0);rt===null&&(be=ft),_.baseState=be,_.firstBaseUpdate=Ke,_.lastBaseUpdate=rt,E===null&&(_.shared.lanes=0),tl|=U,o.lanes=U,o.memoizedState=ft}}function U1(o,l){if(typeof o!="function")throw Error(i(191,o));o.call(l)}function j1(o,l){var h=o.callbacks;if(h!==null)for(o.callbacks=null,o=0;o<h.length;o++)U1(h[o],l)}var ju=F(null),If=F(0);function $1(o,l){o=mo,ge(If,o),ge(ju,l),mo=o|l.baseLanes}function sg(){ge(If,mo),ge(ju,ju.current)}function ng(){mo=If.current,le(ju),le(If)}var Cr=F(null),qr=null;function Qo(o){var l=o.alternate;ge(sn,sn.current&1),ge(Cr,o),qr===null&&(l===null||ju.current!==null||l.memoizedState!==null)&&(qr=o)}function rg(o){ge(sn,sn.current),ge(Cr,o),qr===null&&(qr=o)}function H1(o){o.tag===22?(ge(sn,sn.current),ge(Cr,o),qr===null&&(qr=o)):Zo()}function Zo(){ge(sn,sn.current),ge(Cr,Cr.current)}function Dr(o){le(Cr),qr===o&&(qr=null),le(sn)}var sn=F(0);function Nf(o){for(var l=o;l!==null;){if(l.tag===13){var h=l.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||dy(h)||hy(h)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var ro=0,Ti=null,fs=null,dn=null,Of=!1,$u=!1,Xl=!1,Mf=0,kd=0,Hu=null,XR=0;function Ks(){throw Error(i(321))}function ag(o,l){if(l===null)return!1;for(var h=0;h<l.length&&h<o.length;h++)if(!Gn(o[h],l[h]))return!1;return!0}function og(o,l,h,p,_,E){return ro=E,Ti=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,W.H=o===null||o.memoizedState===null?wT:Sg,Xl=!1,E=h(p,_),Xl=!1,$u&&(E=V1(l,h,p,_)),z1(o),E}function z1(o){W.H=Ld;var l=fs!==null&&fs.next!==null;if(ro=0,dn=fs=Ti=null,Of=!1,kd=0,Hu=null,l)throw Error(i(300));o===null||hn||(o=o.dependencies,o!==null&&At(o)&&(hn=!0))}function V1(o,l,h,p){Ti=o;var _=0;do{if($u&&(Hu=null),kd=0,$u=!1,25<=_)throw Error(i(301));if(_+=1,dn=fs=null,o.updateQueue!=null){var E=o.updateQueue;E.lastEffect=null,E.events=null,E.stores=null,E.memoCache!=null&&(E.memoCache.index=0)}W.H=AT,E=l(h,p)}while($u);return E}function QR(){var o=W.H,l=o.useState()[0];return l=typeof l.then=="function"?Cd(l):l,o=o.useState()[0],(fs!==null?fs.memoizedState:null)!==o&&(Ti.flags|=1024),l}function lg(){var o=Mf!==0;return Mf=0,o}function ug(o,l,h){l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~h}function cg(o){if(Of){for(o=o.memoizedState;o!==null;){var l=o.queue;l!==null&&(l.pending=null),o=o.next}Of=!1}ro=0,dn=fs=Ti=null,$u=!1,kd=Mf=0,Hu=null}function Zn(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dn===null?Ti.memoizedState=dn=o:dn=dn.next=o,dn}function nn(){if(fs===null){var o=Ti.alternate;o=o!==null?o.memoizedState:null}else o=fs.next;var l=dn===null?Ti.memoizedState:dn.next;if(l!==null)dn=l,fs=o;else{if(o===null)throw Ti.alternate===null?Error(i(467)):Error(i(310));fs=o,o={memoizedState:fs.memoizedState,baseState:fs.baseState,baseQueue:fs.baseQueue,queue:fs.queue,next:null},dn===null?Ti.memoizedState=dn=o:dn=dn.next=o}return dn}function Pf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Cd(o){var l=kd;return kd+=1,Hu===null&&(Hu=[]),o=O1(Hu,o,l),l=Ti,(dn===null?l.memoizedState:dn.next)===null&&(l=l.alternate,W.H=l===null||l.memoizedState===null?wT:Sg),o}function Bf(o){if(o!==null&&typeof o=="object"){if(typeof o.then=="function")return Cd(o);if(o.$$typeof===I)return Bt(o)}throw Error(i(438,String(o)))}function dg(o){var l=null,h=Ti.updateQueue;if(h!==null&&(l=h.memoCache),l==null){var p=Ti.alternate;p!==null&&(p=p.updateQueue,p!==null&&(p=p.memoCache,p!=null&&(l={data:p.data.map(function(_){return _.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),h===null&&(h=Pf(),Ti.updateQueue=h),h.memoCache=l,h=l.data[l.index],h===void 0)for(h=l.data[l.index]=Array(o),p=0;p<o;p++)h[p]=R;return l.index++,h}function ao(o,l){return typeof l=="function"?l(o):l}function Ff(o){var l=nn();return hg(l,fs,o)}function hg(o,l,h){var p=o.queue;if(p===null)throw Error(i(311));p.lastRenderedReducer=h;var _=o.baseQueue,E=p.pending;if(E!==null){if(_!==null){var U=_.next;_.next=E.next,E.next=U}l.baseQueue=_=E,p.pending=null}if(E=o.baseState,_===null)o.memoizedState=E;else{l=_.next;var ee=U=null,be=null,Ke=l,rt=!1;do{var ft=Ke.lane&-536870913;if(ft!==Ke.lane?(Ui&ft)===ft:(ro&ft)===ft){var Ye=Ke.revertLane;if(Ye===0)be!==null&&(be=be.next={lane:0,revertLane:0,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null}),ft===Gr&&(rt=!0);else if((ro&Ye)===Ye){Ke=Ke.next,Ye===Gr&&(rt=!0);continue}else ft={lane:0,revertLane:Ke.revertLane,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},be===null?(ee=be=ft,U=E):be=be.next=ft,Ti.lanes|=Ye,tl|=Ye;ft=Ke.action,Xl&&h(E,ft),E=Ke.hasEagerState?Ke.eagerState:h(E,ft)}else Ye={lane:ft,revertLane:Ke.revertLane,gesture:Ke.gesture,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},be===null?(ee=be=Ye,U=E):be=be.next=Ye,Ti.lanes|=ft,tl|=ft;Ke=Ke.next}while(Ke!==null&&Ke!==l);if(be===null?U=E:be.next=ee,!Gn(E,o.memoizedState)&&(hn=!0,rt&&(h=wn,h!==null)))throw h;o.memoizedState=E,o.baseState=U,o.baseQueue=be,p.lastRenderedState=E}return _===null&&(p.lanes=0),[o.memoizedState,p.dispatch]}function fg(o){var l=nn(),h=l.queue;if(h===null)throw Error(i(311));h.lastRenderedReducer=o;var p=h.dispatch,_=h.pending,E=l.memoizedState;if(_!==null){h.pending=null;var U=_=_.next;do E=o(E,U.action),U=U.next;while(U!==_);Gn(E,l.memoizedState)||(hn=!0),l.memoizedState=E,l.baseQueue===null&&(l.baseState=E),h.lastRenderedState=E}return[E,p]}function G1(o,l,h){var p=Ti,_=nn(),E=Ni;if(E){if(h===void 0)throw Error(i(407));h=h()}else h=l();var U=!Gn((fs||_).memoizedState,h);if(U&&(_.memoizedState=h,hn=!0),_=_.queue,gg(W1.bind(null,p,_,o),[o]),_.getSnapshot!==l||U||dn!==null&&dn.memoizedState.tag&1){if(p.flags|=2048,zu(9,{destroy:void 0},K1.bind(null,p,_,h,l),null),_s===null)throw Error(i(349));E||(ro&127)!==0||q1(p,l,h)}return h}function q1(o,l,h){o.flags|=16384,o={getSnapshot:l,value:h},l=Ti.updateQueue,l===null?(l=Pf(),Ti.updateQueue=l,l.stores=[o]):(h=l.stores,h===null?l.stores=[o]:h.push(o))}function K1(o,l,h,p){l.value=h,l.getSnapshot=p,Y1(l)&&X1(o)}function W1(o,l,h){return h(function(){Y1(l)&&X1(o)})}function Y1(o){var l=o.getSnapshot;o=o.value;try{var h=l();return!Gn(o,h)}catch{return!0}}function X1(o){var l=so(o,2);l!==null&&fr(l,o,2)}function mg(o){var l=Zn();if(typeof o=="function"){var h=o;if(o=h(),Xl){Zt(!0);try{h()}finally{Zt(!1)}}}return l.memoizedState=l.baseState=o,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ao,lastRenderedState:o},l}function Q1(o,l,h,p){return o.baseState=h,hg(o,fs,typeof p=="function"?p:ao)}function ZR(o,l,h,p,_){if($f(o))throw Error(i(485));if(o=l.action,o!==null){var E={payload:_,action:o,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(U){E.listeners.push(U)}};W.T!==null?h(!0):E.isTransition=!1,p(E),h=l.pending,h===null?(E.next=l.pending=E,Z1(l,E)):(E.next=h.next,l.pending=h.next=E)}}function Z1(o,l){var h=l.action,p=l.payload,_=o.state;if(l.isTransition){var E=W.T,U={};W.T=U;try{var ee=h(_,p),be=W.S;be!==null&&be(U,ee),J1(o,l,ee)}catch(Ke){pg(o,l,Ke)}finally{E!==null&&U.types!==null&&(E.types=U.types),W.T=E}}else try{E=h(_,p),J1(o,l,E)}catch(Ke){pg(o,l,Ke)}}function J1(o,l,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(p){eT(o,l,p)},function(p){return pg(o,l,p)}):eT(o,l,h)}function eT(o,l,h){l.status="fulfilled",l.value=h,tT(l),o.state=h,l=o.pending,l!==null&&(h=l.next,h===l?o.pending=null:(h=h.next,l.next=h,Z1(o,h)))}function pg(o,l,h){var p=o.pending;if(o.pending=null,p!==null){p=p.next;do l.status="rejected",l.reason=h,tT(l),l=l.next;while(l!==p)}o.action=null}function tT(o){o=o.listeners;for(var l=0;l<o.length;l++)(0,o[l])()}function iT(o,l){return l}function sT(o,l){if(Ni){var h=_s.formState;if(h!==null){e:{var p=Ti;if(Ni){if(Ss){t:{for(var _=Ss,E=lr;_.nodeType!==8;){if(!E){_=null;break t}if(_=Kr(_.nextSibling),_===null){_=null;break t}}E=_.data,_=E==="F!"||E==="F"?_:null}if(_){Ss=Kr(_.nextSibling),p=_.data==="F!";break e}}Ca(p)}p=!1}p&&(l=h[0])}}return h=Zn(),h.memoizedState=h.baseState=l,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:iT,lastRenderedState:l},h.queue=p,h=ST.bind(null,Ti,p),p.dispatch=h,p=mg(!1),E=Tg.bind(null,Ti,!1,p.queue),p=Zn(),_={state:l,dispatch:null,action:o,pending:null},p.queue=_,h=ZR.bind(null,Ti,_,E,h),_.dispatch=h,p.memoizedState=o,[l,h,!1]}function nT(o){var l=nn();return rT(l,fs,o)}function rT(o,l,h){if(l=hg(o,l,iT)[0],o=Ff(ao)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var p=Cd(l)}catch(U){throw U===Fu?Cf:U}else p=l;l=nn();var _=l.queue,E=_.dispatch;return h!==l.memoizedState&&(Ti.flags|=2048,zu(9,{destroy:void 0},JR.bind(null,_,h),null)),[p,E,o]}function JR(o,l){o.action=l}function aT(o){var l=nn(),h=fs;if(h!==null)return rT(l,h,o);nn(),l=l.memoizedState,h=nn();var p=h.queue.dispatch;return h.memoizedState=o,[l,p,!1]}function zu(o,l,h,p){return o={tag:o,create:h,deps:p,inst:l,next:null},l=Ti.updateQueue,l===null&&(l=Pf(),Ti.updateQueue=l),h=l.lastEffect,h===null?l.lastEffect=o.next=o:(p=h.next,h.next=o,o.next=p,l.lastEffect=o),o}function oT(){return nn().memoizedState}function Uf(o,l,h,p){var _=Zn();Ti.flags|=o,_.memoizedState=zu(1|l,{destroy:void 0},h,p===void 0?null:p)}function jf(o,l,h,p){var _=nn();p=p===void 0?null:p;var E=_.memoizedState.inst;fs!==null&&p!==null&&ag(p,fs.memoizedState.deps)?_.memoizedState=zu(l,E,h,p):(Ti.flags|=o,_.memoizedState=zu(1|l,E,h,p))}function lT(o,l){Uf(8390656,8,o,l)}function gg(o,l){jf(2048,8,o,l)}function eI(o){Ti.flags|=4;var l=Ti.updateQueue;if(l===null)l=Pf(),Ti.updateQueue=l,l.events=[o];else{var h=l.events;h===null?l.events=[o]:h.push(o)}}function uT(o){var l=nn().memoizedState;return eI({ref:l,nextImpl:o}),function(){if((es&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}function cT(o,l){return jf(4,2,o,l)}function dT(o,l){return jf(4,4,o,l)}function hT(o,l){if(typeof l=="function"){o=o();var h=l(o);return function(){typeof h=="function"?h():l(null)}}if(l!=null)return o=o(),l.current=o,function(){l.current=null}}function fT(o,l,h){h=h!=null?h.concat([o]):null,jf(4,4,hT.bind(null,l,o),h)}function yg(){}function mT(o,l){var h=nn();l=l===void 0?null:l;var p=h.memoizedState;return l!==null&&ag(l,p[1])?p[0]:(h.memoizedState=[o,l],o)}function pT(o,l){var h=nn();l=l===void 0?null:l;var p=h.memoizedState;if(l!==null&&ag(l,p[1]))return p[0];if(p=o(),Xl){Zt(!0);try{o()}finally{Zt(!1)}}return h.memoizedState=[p,l],p}function vg(o,l,h){return h===void 0||(ro&1073741824)!==0&&(Ui&261930)===0?o.memoizedState=l:(o.memoizedState=h,o=gS(),Ti.lanes|=o,tl|=o,h)}function gT(o,l,h,p){return Gn(h,l)?h:ju.current!==null?(o=vg(o,h,p),Gn(o,l)||(hn=!0),o):(ro&42)===0||(ro&1073741824)!==0&&(Ui&261930)===0?(hn=!0,o.memoizedState=h):(o=gS(),Ti.lanes|=o,tl|=o,l)}function yT(o,l,h,p,_){var E=q.p;q.p=E!==0&&8>E?E:8;var U=W.T,ee={};W.T=ee,Tg(o,!1,l,h);try{var be=_(),Ke=W.S;if(Ke!==null&&Ke(ee,be),be!==null&&typeof be=="object"&&typeof be.then=="function"){var rt=YR(be,p);Dd(o,l,rt,Ir(o))}else Dd(o,l,p,Ir(o))}catch(ft){Dd(o,l,{then:function(){},status:"rejected",reason:ft},Ir())}finally{q.p=E,U!==null&&ee.types!==null&&(U.types=ee.types),W.T=U}}function tI(){}function xg(o,l,h,p){if(o.tag!==5)throw Error(i(476));var _=vT(o).queue;yT(o,_,l,Z,h===null?tI:function(){return xT(o),h(p)})}function vT(o){var l=o.memoizedState;if(l!==null)return l;l={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ao,lastRenderedState:Z},next:null};var h={};return l.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ao,lastRenderedState:h},next:null},o.memoizedState=l,o=o.alternate,o!==null&&(o.memoizedState=l),l}function xT(o){var l=vT(o);l.next===null&&(l=o.alternate.memoizedState),Dd(o,l.next.queue,{},Ir())}function bg(){return Bt(qd)}function bT(){return nn().memoizedState}function TT(){return nn().memoizedState}function iI(o){for(var l=o.return;l!==null;){switch(l.tag){case 24:case 3:var h=Ir();o=Yo(h);var p=Xo(l,o,h);p!==null&&(fr(p,l,h),Ed(p,l,h)),l={cache:no()},o.payload=l;return}l=l.return}}function sI(o,l,h){var p=Ir();h={lane:p,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},$f(o)?_T(l,h):(h=gd(o,l,h,p),h!==null&&(fr(h,o,p),ET(h,l,p)))}function ST(o,l,h){var p=Ir();Dd(o,l,h,p)}function Dd(o,l,h,p){var _={lane:p,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if($f(o))_T(l,_);else{var E=o.alternate;if(o.lanes===0&&(E===null||E.lanes===0)&&(E=l.lastRenderedReducer,E!==null))try{var U=l.lastRenderedState,ee=E(U,h);if(_.hasEagerState=!0,_.eagerState=ee,Gn(ee,U))return Mu(o,l,_,0),_s===null&&Ou(),!1}catch{}if(h=gd(o,l,_,p),h!==null)return fr(h,o,p),ET(h,l,p),!0}return!1}function Tg(o,l,h,p){if(p={lane:2,revertLane:Jg(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},$f(o)){if(l)throw Error(i(479))}else l=gd(o,h,p,2),l!==null&&fr(l,o,2)}function $f(o){var l=o.alternate;return o===Ti||l!==null&&l===Ti}function _T(o,l){$u=Of=!0;var h=o.pending;h===null?l.next=l:(l.next=h.next,h.next=l),o.pending=l}function ET(o,l,h){if((h&4194048)!==0){var p=l.lanes;p&=o.pendingLanes,h|=p,l.lanes=h,oi(o,h)}}var Ld={readContext:Bt,use:Bf,useCallback:Ks,useContext:Ks,useEffect:Ks,useImperativeHandle:Ks,useLayoutEffect:Ks,useInsertionEffect:Ks,useMemo:Ks,useReducer:Ks,useRef:Ks,useState:Ks,useDebugValue:Ks,useDeferredValue:Ks,useTransition:Ks,useSyncExternalStore:Ks,useId:Ks,useHostTransitionStatus:Ks,useFormState:Ks,useActionState:Ks,useOptimistic:Ks,useMemoCache:Ks,useCacheRefresh:Ks};Ld.useEffectEvent=Ks;var wT={readContext:Bt,use:Bf,useCallback:function(o,l){return Zn().memoizedState=[o,l===void 0?null:l],o},useContext:Bt,useEffect:lT,useImperativeHandle:function(o,l,h){h=h!=null?h.concat([o]):null,Uf(4194308,4,hT.bind(null,l,o),h)},useLayoutEffect:function(o,l){return Uf(4194308,4,o,l)},useInsertionEffect:function(o,l){Uf(4,2,o,l)},useMemo:function(o,l){var h=Zn();l=l===void 0?null:l;var p=o();if(Xl){Zt(!0);try{o()}finally{Zt(!1)}}return h.memoizedState=[p,l],p},useReducer:function(o,l,h){var p=Zn();if(h!==void 0){var _=h(l);if(Xl){Zt(!0);try{h(l)}finally{Zt(!1)}}}else _=l;return p.memoizedState=p.baseState=_,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:_},p.queue=o,o=o.dispatch=sI.bind(null,Ti,o),[p.memoizedState,o]},useRef:function(o){var l=Zn();return o={current:o},l.memoizedState=o},useState:function(o){o=mg(o);var l=o.queue,h=ST.bind(null,Ti,l);return l.dispatch=h,[o.memoizedState,h]},useDebugValue:yg,useDeferredValue:function(o,l){var h=Zn();return vg(h,o,l)},useTransition:function(){var o=mg(!1);return o=yT.bind(null,Ti,o.queue,!0,!1),Zn().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,l,h){var p=Ti,_=Zn();if(Ni){if(h===void 0)throw Error(i(407));h=h()}else{if(h=l(),_s===null)throw Error(i(349));(Ui&127)!==0||q1(p,l,h)}_.memoizedState=h;var E={value:h,getSnapshot:l};return _.queue=E,lT(W1.bind(null,p,E,o),[o]),p.flags|=2048,zu(9,{destroy:void 0},K1.bind(null,p,E,h,l),null),h},useId:function(){var o=Zn(),l=_s.identifierPrefix;if(Ni){var h=Bn,p=kr;h=(p&~(1<<32-Et(p)-1)).toString(32)+h,l="_"+l+"R_"+h,h=Mf++,0<h&&(l+="H"+h.toString(32)),l+="_"}else h=XR++,l="_"+l+"r_"+h.toString(32)+"_";return o.memoizedState=l},useHostTransitionStatus:bg,useFormState:sT,useActionState:sT,useOptimistic:function(o){var l=Zn();l.memoizedState=l.baseState=o;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=h,l=Tg.bind(null,Ti,!0,h),h.dispatch=l,[o,l]},useMemoCache:dg,useCacheRefresh:function(){return Zn().memoizedState=iI.bind(null,Ti)},useEffectEvent:function(o){var l=Zn(),h={impl:o};return l.memoizedState=h,function(){if((es&2)!==0)throw Error(i(440));return h.impl.apply(void 0,arguments)}}},Sg={readContext:Bt,use:Bf,useCallback:mT,useContext:Bt,useEffect:gg,useImperativeHandle:fT,useInsertionEffect:cT,useLayoutEffect:dT,useMemo:pT,useReducer:Ff,useRef:oT,useState:function(){return Ff(ao)},useDebugValue:yg,useDeferredValue:function(o,l){var h=nn();return gT(h,fs.memoizedState,o,l)},useTransition:function(){var o=Ff(ao)[0],l=nn().memoizedState;return[typeof o=="boolean"?o:Cd(o),l]},useSyncExternalStore:G1,useId:bT,useHostTransitionStatus:bg,useFormState:nT,useActionState:nT,useOptimistic:function(o,l){var h=nn();return Q1(h,fs,o,l)},useMemoCache:dg,useCacheRefresh:TT};Sg.useEffectEvent=uT;var AT={readContext:Bt,use:Bf,useCallback:mT,useContext:Bt,useEffect:gg,useImperativeHandle:fT,useInsertionEffect:cT,useLayoutEffect:dT,useMemo:pT,useReducer:fg,useRef:oT,useState:function(){return fg(ao)},useDebugValue:yg,useDeferredValue:function(o,l){var h=nn();return fs===null?vg(h,o,l):gT(h,fs.memoizedState,o,l)},useTransition:function(){var o=fg(ao)[0],l=nn().memoizedState;return[typeof o=="boolean"?o:Cd(o),l]},useSyncExternalStore:G1,useId:bT,useHostTransitionStatus:bg,useFormState:aT,useActionState:aT,useOptimistic:function(o,l){var h=nn();return fs!==null?Q1(h,fs,o,l):(h.baseState=o,[o,h.queue.dispatch])},useMemoCache:dg,useCacheRefresh:TT};AT.useEffectEvent=uT;function _g(o,l,h,p){l=o.memoizedState,h=h(p,l),h=h==null?l:g({},l,h),o.memoizedState=h,o.lanes===0&&(o.updateQueue.baseState=h)}var Eg={enqueueSetState:function(o,l,h){o=o._reactInternals;var p=Ir(),_=Yo(p);_.payload=l,h!=null&&(_.callback=h),l=Xo(o,_,p),l!==null&&(fr(l,o,p),Ed(l,o,p))},enqueueReplaceState:function(o,l,h){o=o._reactInternals;var p=Ir(),_=Yo(p);_.tag=1,_.payload=l,h!=null&&(_.callback=h),l=Xo(o,_,p),l!==null&&(fr(l,o,p),Ed(l,o,p))},enqueueForceUpdate:function(o,l){o=o._reactInternals;var h=Ir(),p=Yo(h);p.tag=2,l!=null&&(p.callback=l),l=Xo(o,p,h),l!==null&&(fr(l,o,h),Ed(l,o,h))}};function kT(o,l,h,p,_,E,U){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(p,E,U):l.prototype&&l.prototype.isPureReactComponent?!Sa(h,p)||!Sa(_,E):!0}function CT(o,l,h,p){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(h,p),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(h,p),l.state!==o&&Eg.enqueueReplaceState(l,l.state,null)}function Ql(o,l){var h=l;if("ref"in l){h={};for(var p in l)p!=="ref"&&(h[p]=l[p])}if(o=o.defaultProps){h===l&&(h=g({},h));for(var _ in o)h[_]===void 0&&(h[_]=o[_])}return h}function DT(o){Ho(o)}function LT(o){console.error(o)}function RT(o){Ho(o)}function Hf(o,l){try{var h=o.onUncaughtError;h(l.value,{componentStack:l.stack})}catch(p){setTimeout(function(){throw p})}}function IT(o,l,h){try{var p=o.onCaughtError;p(h.value,{componentStack:h.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(_){setTimeout(function(){throw _})}}function wg(o,l,h){return h=Yo(h),h.tag=3,h.payload={element:null},h.callback=function(){Hf(o,l)},h}function NT(o){return o=Yo(o),o.tag=3,o}function OT(o,l,h,p){var _=h.type.getDerivedStateFromError;if(typeof _=="function"){var E=p.value;o.payload=function(){return _(E)},o.callback=function(){IT(l,h,p)}}var U=h.stateNode;U!==null&&typeof U.componentDidCatch=="function"&&(o.callback=function(){IT(l,h,p),typeof _!="function"&&(il===null?il=new Set([this]):il.add(this));var ee=p.stack;this.componentDidCatch(p.value,{componentStack:ee!==null?ee:""})})}function nI(o,l,h,p,_){if(h.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(l=h.alternate,l!==null&&et(l,h,_,!0),h=Cr.current,h!==null){switch(h.tag){case 31:case 13:return qr===null?em():h.alternate===null&&Ws===0&&(Ws=3),h.flags&=-257,h.flags|=65536,h.lanes=_,p===Df?h.flags|=16384:(l=h.updateQueue,l===null?h.updateQueue=new Set([p]):l.add(p),Xg(o,p,_)),!1;case 22:return h.flags|=65536,p===Df?h.flags|=16384:(l=h.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([p])},h.updateQueue=l):(h=l.retryQueue,h===null?l.retryQueue=new Set([p]):h.add(p)),Xg(o,p,_)),!1}throw Error(i(435,h.tag))}return Xg(o,p,_),em(),!1}if(Ni)return l=Cr.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=_,p!==bd&&(o=Error(i(422),{cause:p}),C(rr(o,h)))):(p!==bd&&(l=Error(i(423),{cause:p}),C(rr(l,h))),o=o.current.alternate,o.flags|=65536,_&=-_,o.lanes|=_,p=rr(p,h),_=wg(o.stateNode,p,_),tg(o,_),Ws!==4&&(Ws=2)),!1;var E=Error(i(520),{cause:p});if(E=rr(E,h),Fd===null?Fd=[E]:Fd.push(E),Ws!==4&&(Ws=2),l===null)return!0;p=rr(p,h),h=l;do{switch(h.tag){case 3:return h.flags|=65536,o=_&-_,h.lanes|=o,o=wg(h.stateNode,p,o),tg(h,o),!1;case 1:if(l=h.type,E=h.stateNode,(h.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||E!==null&&typeof E.componentDidCatch=="function"&&(il===null||!il.has(E))))return h.flags|=65536,_&=-_,h.lanes|=_,_=NT(_),OT(_,o,h,p),tg(h,_),!1}h=h.return}while(h!==null);return!1}var Ag=Error(i(461)),hn=!1;function Fn(o,l,h,p){l.child=o===null?F1(l,null,h,p):Yl(l,o.child,h,p)}function MT(o,l,h,p,_){h=h.render;var E=l.ref;if("ref"in p){var U={};for(var ee in p)ee!=="ref"&&(U[ee]=p[ee])}else U=p;return nt(l),p=og(o,l,h,U,E,_),ee=lg(),o!==null&&!hn?(ug(o,l,_),oo(o,l,_)):(Ni&&ee&&vn(l),l.flags|=1,Fn(o,l,p,_),l.child)}function PT(o,l,h,p,_){if(o===null){var E=h.type;return typeof E=="function"&&!yd(E)&&E.defaultProps===void 0&&h.compare===null?(l.tag=15,l.type=E,BT(o,l,E,p,_)):(o=vd(h.type,null,p,l,l.mode,_),o.ref=l.ref,o.return=l,l.child=o)}if(E=o.child,!Og(o,_)){var U=E.memoizedProps;if(h=h.compare,h=h!==null?h:Sa,h(U,p)&&o.ref===l.ref)return oo(o,l,_)}return l.flags|=1,o=la(E,p),o.ref=l.ref,o.return=l,l.child=o}function BT(o,l,h,p,_){if(o!==null){var E=o.memoizedProps;if(Sa(E,p)&&o.ref===l.ref)if(hn=!1,l.pendingProps=p=E,Og(o,_))(o.flags&131072)!==0&&(hn=!0);else return l.lanes=o.lanes,oo(o,l,_)}return kg(o,l,h,p,_)}function FT(o,l,h,p){var _=p.children,E=o!==null?o.memoizedState:null;if(o===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.mode==="hidden"){if((l.flags&128)!==0){if(E=E!==null?E.baseLanes|h:h,o!==null){for(p=l.child=o.child,_=0;p!==null;)_=_|p.lanes|p.childLanes,p=p.sibling;p=_&~E}else p=0,l.child=null;return UT(o,l,E,h,p)}if((h&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},o!==null&&kf(l,E!==null?E.cachePool:null),E!==null?$1(l,E):sg(),H1(l);else return p=l.lanes=536870912,UT(o,l,E!==null?E.baseLanes|h:h,h,p)}else E!==null?(kf(l,E.cachePool),$1(l,E),Zo(),l.memoizedState=null):(o!==null&&kf(l,null),sg(),Zo());return Fn(o,l,_,h),l.child}function Rd(o,l){return o!==null&&o.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function UT(o,l,h,p,_){var E=Qp();return E=E===null?null:{parent:Ds._currentValue,pool:E},l.memoizedState={baseLanes:h,cachePool:E},o!==null&&kf(l,null),sg(),H1(l),o!==null&&et(o,l,p,!0),l.childLanes=_,null}function zf(o,l){return l=Gf({mode:l.mode,children:l.children},o.mode),l.ref=o.ref,o.child=l,l.return=o,l}function jT(o,l,h){return Yl(l,o.child,null,h),o=zf(l,l.pendingProps),o.flags|=2,Dr(l),l.memoizedState=null,o}function rI(o,l,h){var p=l.pendingProps,_=(l.flags&128)!==0;if(l.flags&=-129,o===null){if(Ni){if(p.mode==="hidden")return o=zf(l,p),l.lanes=536870912,Rd(null,o);if(rg(l),(o=Ss)?(o=ZS(o,lr),o=o!==null&&o.data==="&"?o:null,o!==null&&(l.memoizedState={dehydrated:o,treeContext:wa!==null?{id:kr,overflow:Bn}:null,retryLane:536870912,hydrationErrors:null},h=xd(o),h.return=l,l.child=h,cn=l,Ss=null)):o=null,o===null)throw Ca(l);return l.lanes=536870912,null}return zf(l,p)}var E=o.memoizedState;if(E!==null){var U=E.dehydrated;if(rg(l),_)if(l.flags&256)l.flags&=-257,l=jT(o,l,h);else if(l.memoizedState!==null)l.child=o.child,l.flags|=128,l=null;else throw Error(i(558));else if(hn||et(o,l,h,!1),_=(h&o.childLanes)!==0,hn||_){if(p=_s,p!==null&&(U=ci(p,h),U!==0&&U!==E.retryLane))throw E.retryLane=U,so(o,U),fr(p,o,U),Ag;em(),l=jT(o,l,h)}else o=E.treeContext,Ss=Kr(U.nextSibling),cn=l,Ni=!0,ka=null,lr=!1,o!==null&&wf(l,o),l=zf(l,p),l.flags|=4096;return l}return o=la(o.child,{mode:p.mode,children:p.children}),o.ref=l.ref,l.child=o,o.return=l,o}function Vf(o,l){var h=l.ref;if(h===null)o!==null&&o.ref!==null&&(l.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(i(284));(o===null||o.ref!==h)&&(l.flags|=4194816)}}function kg(o,l,h,p,_){return nt(l),h=og(o,l,h,p,void 0,_),p=lg(),o!==null&&!hn?(ug(o,l,_),oo(o,l,_)):(Ni&&p&&vn(l),l.flags|=1,Fn(o,l,h,_),l.child)}function $T(o,l,h,p,_,E){return nt(l),l.updateQueue=null,h=V1(l,p,h,_),z1(o),p=lg(),o!==null&&!hn?(ug(o,l,E),oo(o,l,E)):(Ni&&p&&vn(l),l.flags|=1,Fn(o,l,h,E),l.child)}function HT(o,l,h,p,_){if(nt(l),l.stateNode===null){var E=Vo,U=h.contextType;typeof U=="object"&&U!==null&&(E=Bt(U)),E=new h(p,E),l.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,E.updater=Eg,l.stateNode=E,E._reactInternals=l,E=l.stateNode,E.props=p,E.state=l.memoizedState,E.refs={},Jp(l),U=h.contextType,E.context=typeof U=="object"&&U!==null?Bt(U):Vo,E.state=l.memoizedState,U=h.getDerivedStateFromProps,typeof U=="function"&&(_g(l,h,U,p),E.state=l.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(U=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),U!==E.state&&Eg.enqueueReplaceState(E,E.state,null),Ad(l,p,E,_),wd(),E.state=l.memoizedState),typeof E.componentDidMount=="function"&&(l.flags|=4194308),p=!0}else if(o===null){E=l.stateNode;var ee=l.memoizedProps,be=Ql(h,ee);E.props=be;var Ke=E.context,rt=h.contextType;U=Vo,typeof rt=="object"&&rt!==null&&(U=Bt(rt));var ft=h.getDerivedStateFromProps;rt=typeof ft=="function"||typeof E.getSnapshotBeforeUpdate=="function",ee=l.pendingProps!==ee,rt||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(ee||Ke!==U)&&CT(l,E,p,U),Wo=!1;var Ye=l.memoizedState;E.state=Ye,Ad(l,p,E,_),wd(),Ke=l.memoizedState,ee||Ye!==Ke||Wo?(typeof ft=="function"&&(_g(l,h,ft,p),Ke=l.memoizedState),(be=Wo||kT(l,h,be,p,Ye,Ke,U))?(rt||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(l.flags|=4194308)):(typeof E.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=p,l.memoizedState=Ke),E.props=p,E.state=Ke,E.context=U,p=be):(typeof E.componentDidMount=="function"&&(l.flags|=4194308),p=!1)}else{E=l.stateNode,eg(o,l),U=l.memoizedProps,rt=Ql(h,U),E.props=rt,ft=l.pendingProps,Ye=E.context,Ke=h.contextType,be=Vo,typeof Ke=="object"&&Ke!==null&&(be=Bt(Ke)),ee=h.getDerivedStateFromProps,(Ke=typeof ee=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(U!==ft||Ye!==be)&&CT(l,E,p,be),Wo=!1,Ye=l.memoizedState,E.state=Ye,Ad(l,p,E,_),wd();var tt=l.memoizedState;U!==ft||Ye!==tt||Wo||o!==null&&o.dependencies!==null&&At(o.dependencies)?(typeof ee=="function"&&(_g(l,h,ee,p),tt=l.memoizedState),(rt=Wo||kT(l,h,rt,p,Ye,tt,be)||o!==null&&o.dependencies!==null&&At(o.dependencies))?(Ke||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(p,tt,be),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(p,tt,be)),typeof E.componentDidUpdate=="function"&&(l.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof E.componentDidUpdate!="function"||U===o.memoizedProps&&Ye===o.memoizedState||(l.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||U===o.memoizedProps&&Ye===o.memoizedState||(l.flags|=1024),l.memoizedProps=p,l.memoizedState=tt),E.props=p,E.state=tt,E.context=be,p=rt):(typeof E.componentDidUpdate!="function"||U===o.memoizedProps&&Ye===o.memoizedState||(l.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||U===o.memoizedProps&&Ye===o.memoizedState||(l.flags|=1024),p=!1)}return E=p,Vf(o,l),p=(l.flags&128)!==0,E||p?(E=l.stateNode,h=p&&typeof h.getDerivedStateFromError!="function"?null:E.render(),l.flags|=1,o!==null&&p?(l.child=Yl(l,o.child,null,_),l.child=Yl(l,null,h,_)):Fn(o,l,h,_),l.memoizedState=E.state,o=l.child):o=oo(o,l,_),o}function zT(o,l,h,p){return A(),l.flags|=256,Fn(o,l,h,p),l.child}var Cg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Dg(o){return{baseLanes:o,cachePool:I1()}}function Lg(o,l,h){return o=o!==null?o.childLanes&~h:0,l&&(o|=Rr),o}function VT(o,l,h){var p=l.pendingProps,_=!1,E=(l.flags&128)!==0,U;if((U=E)||(U=o!==null&&o.memoizedState===null?!1:(sn.current&2)!==0),U&&(_=!0,l.flags&=-129),U=(l.flags&32)!==0,l.flags&=-33,o===null){if(Ni){if(_?Qo(l):Zo(),(o=Ss)?(o=ZS(o,lr),o=o!==null&&o.data!=="&"?o:null,o!==null&&(l.memoizedState={dehydrated:o,treeContext:wa!==null?{id:kr,overflow:Bn}:null,retryLane:536870912,hydrationErrors:null},h=xd(o),h.return=l,l.child=h,cn=l,Ss=null)):o=null,o===null)throw Ca(l);return hy(o)?l.lanes=32:l.lanes=536870912,null}var ee=p.children;return p=p.fallback,_?(Zo(),_=l.mode,ee=Gf({mode:"hidden",children:ee},_),p=Ea(p,_,h,null),ee.return=l,p.return=l,ee.sibling=p,l.child=ee,p=l.child,p.memoizedState=Dg(h),p.childLanes=Lg(o,U,h),l.memoizedState=Cg,Rd(null,p)):(Qo(l),Rg(l,ee))}var be=o.memoizedState;if(be!==null&&(ee=be.dehydrated,ee!==null)){if(E)l.flags&256?(Qo(l),l.flags&=-257,l=Ig(o,l,h)):l.memoizedState!==null?(Zo(),l.child=o.child,l.flags|=128,l=null):(Zo(),ee=p.fallback,_=l.mode,p=Gf({mode:"visible",children:p.children},_),ee=Ea(ee,_,h,null),ee.flags|=2,p.return=l,ee.return=l,p.sibling=ee,l.child=p,Yl(l,o.child,null,h),p=l.child,p.memoizedState=Dg(h),p.childLanes=Lg(o,U,h),l.memoizedState=Cg,l=Rd(null,p));else if(Qo(l),hy(ee)){if(U=ee.nextSibling&&ee.nextSibling.dataset,U)var Ke=U.dgst;U=Ke,p=Error(i(419)),p.stack="",p.digest=U,C({value:p,source:null,stack:null}),l=Ig(o,l,h)}else if(hn||et(o,l,h,!1),U=(h&o.childLanes)!==0,hn||U){if(U=_s,U!==null&&(p=ci(U,h),p!==0&&p!==be.retryLane))throw be.retryLane=p,so(o,p),fr(U,o,p),Ag;dy(ee)||em(),l=Ig(o,l,h)}else dy(ee)?(l.flags|=192,l.child=o.child,l=null):(o=be.treeContext,Ss=Kr(ee.nextSibling),cn=l,Ni=!0,ka=null,lr=!1,o!==null&&wf(l,o),l=Rg(l,p.children),l.flags|=4096);return l}return _?(Zo(),ee=p.fallback,_=l.mode,be=o.child,Ke=be.sibling,p=la(be,{mode:"hidden",children:p.children}),p.subtreeFlags=be.subtreeFlags&65011712,Ke!==null?ee=la(Ke,ee):(ee=Ea(ee,_,h,null),ee.flags|=2),ee.return=l,p.return=l,p.sibling=ee,l.child=p,Rd(null,p),p=l.child,ee=o.child.memoizedState,ee===null?ee=Dg(h):(_=ee.cachePool,_!==null?(be=Ds._currentValue,_=_.parent!==be?{parent:be,pool:be}:_):_=I1(),ee={baseLanes:ee.baseLanes|h,cachePool:_}),p.memoizedState=ee,p.childLanes=Lg(o,U,h),l.memoizedState=Cg,Rd(o.child,p)):(Qo(l),h=o.child,o=h.sibling,h=la(h,{mode:"visible",children:p.children}),h.return=l,h.sibling=null,o!==null&&(U=l.deletions,U===null?(l.deletions=[o],l.flags|=16):U.push(o)),l.child=h,l.memoizedState=null,h)}function Rg(o,l){return l=Gf({mode:"visible",children:l},o.mode),l.return=o,o.child=l}function Gf(o,l){return o=qs(22,o,null,l),o.lanes=0,o}function Ig(o,l,h){return Yl(l,o.child,null,h),o=Rg(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function GT(o,l,h){o.lanes|=l;var p=o.alternate;p!==null&&(p.lanes|=l),ve(o.return,l,h)}function Ng(o,l,h,p,_,E){var U=o.memoizedState;U===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:p,tail:h,tailMode:_,treeForkCount:E}:(U.isBackwards=l,U.rendering=null,U.renderingStartTime=0,U.last=p,U.tail=h,U.tailMode=_,U.treeForkCount=E)}function qT(o,l,h){var p=l.pendingProps,_=p.revealOrder,E=p.tail;p=p.children;var U=sn.current,ee=(U&2)!==0;if(ee?(U=U&1|2,l.flags|=128):U&=1,ge(sn,U),Fn(o,l,p,h),p=Ni?Vl:0,!ee&&o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&GT(o,h,l);else if(o.tag===19)GT(o,h,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}switch(_){case"forwards":for(h=l.child,_=null;h!==null;)o=h.alternate,o!==null&&Nf(o)===null&&(_=h),h=h.sibling;h=_,h===null?(_=l.child,l.child=null):(_=h.sibling,h.sibling=null),Ng(l,!1,_,h,E,p);break;case"backwards":case"unstable_legacy-backwards":for(h=null,_=l.child,l.child=null;_!==null;){if(o=_.alternate,o!==null&&Nf(o)===null){l.child=_;break}o=_.sibling,_.sibling=h,h=_,_=o}Ng(l,!0,h,null,E,p);break;case"together":Ng(l,!1,null,null,void 0,p);break;default:l.memoizedState=null}return l.child}function oo(o,l,h){if(o!==null&&(l.dependencies=o.dependencies),tl|=l.lanes,(h&l.childLanes)===0)if(o!==null){if(et(o,l,h,!1),(h&l.childLanes)===0)return null}else return null;if(o!==null&&l.child!==o.child)throw Error(i(153));if(l.child!==null){for(o=l.child,h=la(o,o.pendingProps),l.child=h,h.return=l;o.sibling!==null;)o=o.sibling,h=h.sibling=la(o,o.pendingProps),h.return=l;h.sibling=null}return l.child}function Og(o,l){return(o.lanes&l)!==0?!0:(o=o.dependencies,!!(o!==null&&At(o)))}function aI(o,l,h){switch(l.tag){case 3:Se(l,l.stateNode.containerInfo),de(l,Ds,o.memoizedState.cache),A();break;case 27:case 5:Ve(l);break;case 4:Se(l,l.stateNode.containerInfo);break;case 10:de(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,rg(l),null;break;case 13:var p=l.memoizedState;if(p!==null)return p.dehydrated!==null?(Qo(l),l.flags|=128,null):(h&l.child.childLanes)!==0?VT(o,l,h):(Qo(l),o=oo(o,l,h),o!==null?o.sibling:null);Qo(l);break;case 19:var _=(o.flags&128)!==0;if(p=(h&l.childLanes)!==0,p||(et(o,l,h,!1),p=(h&l.childLanes)!==0),_){if(p)return qT(o,l,h);l.flags|=128}if(_=l.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),ge(sn,sn.current),p)break;return null;case 22:return l.lanes=0,FT(o,l,h,l.pendingProps);case 24:de(l,Ds,o.memoizedState.cache)}return oo(o,l,h)}function KT(o,l,h){if(o!==null)if(o.memoizedProps!==l.pendingProps)hn=!0;else{if(!Og(o,h)&&(l.flags&128)===0)return hn=!1,aI(o,l,h);hn=(o.flags&131072)!==0}else hn=!1,Ni&&(l.flags&1048576)!==0&&Aa(l,Vl,l.index);switch(l.lanes=0,l.tag){case 16:e:{var p=l.pendingProps;if(o=Kl(l.elementType),l.type=o,typeof o=="function")yd(o)?(p=Ql(o,p),l.tag=1,l=HT(null,l,o,p,h)):(l.tag=0,l=kg(null,l,o,p,h));else{if(o!=null){var _=o.$$typeof;if(_===j){l.tag=11,l=MT(null,l,o,p,h);break e}else if(_===N){l.tag=14,l=PT(null,l,o,p,h);break e}}throw l=re(o)||o,Error(i(306,l,""))}}return l;case 0:return kg(o,l,l.type,l.pendingProps,h);case 1:return p=l.type,_=Ql(p,l.pendingProps),HT(o,l,p,_,h);case 3:e:{if(Se(l,l.stateNode.containerInfo),o===null)throw Error(i(387));p=l.pendingProps;var E=l.memoizedState;_=E.element,eg(o,l),Ad(l,p,null,h);var U=l.memoizedState;if(p=U.cache,de(l,Ds,p),p!==E.cache&&Ce(l,[Ds],h,!0),wd(),p=U.element,E.isDehydrated)if(E={element:p,isDehydrated:!1,cache:U.cache},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){l=zT(o,l,p,h);break e}else if(p!==_){_=rr(Error(i(424)),l),C(_),l=zT(o,l,p,h);break e}else for(o=l.stateNode.containerInfo,o.nodeType===9?o=o.body:o=o.nodeName==="HTML"?o.ownerDocument.body:o,Ss=Kr(o.firstChild),cn=l,Ni=!0,ka=null,lr=!0,h=F1(l,null,p,h),l.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(A(),p===_){l=oo(o,l,h);break e}Fn(o,l,p,h)}l=l.child}return l;case 26:return Vf(o,l),o===null?(h=n_(l.type,null,l.pendingProps,null))?l.memoizedState=h:Ni||(h=l.type,o=l.pendingProps,p=om(Pe.current).createElement(h),p[qt]=l,p[Mt]=o,Un(p,h,o),Di(p),l.stateNode=p):l.memoizedState=n_(l.type,o.memoizedProps,l.pendingProps,o.memoizedState),null;case 27:return Ve(l),o===null&&Ni&&(p=l.stateNode=t_(l.type,l.pendingProps,Pe.current),cn=l,lr=!0,_=Ss,al(l.type)?(fy=_,Ss=Kr(p.firstChild)):Ss=_),Fn(o,l,l.pendingProps.children,h),Vf(o,l),o===null&&(l.flags|=4194304),l.child;case 5:return o===null&&Ni&&((_=p=Ss)&&(p=PI(p,l.type,l.pendingProps,lr),p!==null?(l.stateNode=p,cn=l,Ss=Kr(p.firstChild),lr=!1,_=!0):_=!1),_||Ca(l)),Ve(l),_=l.type,E=l.pendingProps,U=o!==null?o.memoizedProps:null,p=E.children,ly(_,E)?p=null:U!==null&&ly(_,U)&&(l.flags|=32),l.memoizedState!==null&&(_=og(o,l,QR,null,null,h),qd._currentValue=_),Vf(o,l),Fn(o,l,p,h),l.child;case 6:return o===null&&Ni&&((o=h=Ss)&&(h=BI(h,l.pendingProps,lr),h!==null?(l.stateNode=h,cn=l,Ss=null,o=!0):o=!1),o||Ca(l)),null;case 13:return VT(o,l,h);case 4:return Se(l,l.stateNode.containerInfo),p=l.pendingProps,o===null?l.child=Yl(l,null,p,h):Fn(o,l,p,h),l.child;case 11:return MT(o,l,l.type,l.pendingProps,h);case 7:return Fn(o,l,l.pendingProps,h),l.child;case 8:return Fn(o,l,l.pendingProps.children,h),l.child;case 12:return Fn(o,l,l.pendingProps.children,h),l.child;case 10:return p=l.pendingProps,de(l,l.type,p.value),Fn(o,l,p.children,h),l.child;case 9:return _=l.type._context,p=l.pendingProps.children,nt(l),_=Bt(_),p=p(_),l.flags|=1,Fn(o,l,p,h),l.child;case 14:return PT(o,l,l.type,l.pendingProps,h);case 15:return BT(o,l,l.type,l.pendingProps,h);case 19:return qT(o,l,h);case 31:return rI(o,l,h);case 22:return FT(o,l,h,l.pendingProps);case 24:return nt(l),p=Bt(Ds),o===null?(_=Qp(),_===null&&(_=_s,E=no(),_.pooledCache=E,E.refCount++,E!==null&&(_.pooledCacheLanes|=h),_=E),l.memoizedState={parent:p,cache:_},Jp(l),de(l,Ds,_)):((o.lanes&h)!==0&&(eg(o,l),Ad(l,null,null,h),wd()),_=o.memoizedState,E=l.memoizedState,_.parent!==p?(_={parent:p,cache:p},l.memoizedState=_,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=_),de(l,Ds,p)):(p=E.cache,de(l,Ds,p),p!==_.cache&&Ce(l,[Ds],h,!0))),Fn(o,l,l.pendingProps.children,h),l.child;case 29:throw l.pendingProps}throw Error(i(156,l.tag))}function lo(o){o.flags|=4}function Mg(o,l,h,p,_){if((l=(o.mode&32)!==0)&&(l=!1),l){if(o.flags|=16777216,(_&335544128)===_)if(o.stateNode.complete)o.flags|=8192;else if(bS())o.flags|=8192;else throw Wl=Df,Zp}else o.flags&=-16777217}function WT(o,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)o.flags&=-16777217;else if(o.flags|=16777216,!u_(l))if(bS())o.flags|=8192;else throw Wl=Df,Zp}function qf(o,l){l!==null&&(o.flags|=4),o.flags&16384&&(l=o.tag!==22?Be():536870912,o.lanes|=l,Ku|=l)}function Id(o,l){if(!Ni)switch(o.tailMode){case"hidden":l=o.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?o.tail=null:h.sibling=null;break;case"collapsed":h=o.tail;for(var p=null;h!==null;)h.alternate!==null&&(p=h),h=h.sibling;p===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:p.sibling=null}}function Ns(o){var l=o.alternate!==null&&o.alternate.child===o.child,h=0,p=0;if(l)for(var _=o.child;_!==null;)h|=_.lanes|_.childLanes,p|=_.subtreeFlags&65011712,p|=_.flags&65011712,_.return=o,_=_.sibling;else for(_=o.child;_!==null;)h|=_.lanes|_.childLanes,p|=_.subtreeFlags,p|=_.flags,_.return=o,_=_.sibling;return o.subtreeFlags|=p,o.childLanes=h,l}function oI(o,l,h){var p=l.pendingProps;switch(or(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ns(l),null;case 1:return Ns(l),null;case 3:return h=l.stateNode,p=null,o!==null&&(p=o.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),he(Ds),Re(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(o===null||o.child===null)&&(x(l)?lo(l):o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,D())),Ns(l),null;case 26:var _=l.type,E=l.memoizedState;return o===null?(lo(l),E!==null?(Ns(l),WT(l,E)):(Ns(l),Mg(l,_,null,p,h))):E?E!==o.memoizedState?(lo(l),Ns(l),WT(l,E)):(Ns(l),l.flags&=-16777217):(o=o.memoizedProps,o!==p&&lo(l),Ns(l),Mg(l,_,o,p,h)),null;case 27:if(Ee(l),h=Pe.current,_=l.type,o!==null&&l.stateNode!=null)o.memoizedProps!==p&&lo(l);else{if(!p){if(l.stateNode===null)throw Error(i(166));return Ns(l),null}o=Ie.current,x(l)?Af(l):(o=t_(_,p,h),l.stateNode=o,lo(l))}return Ns(l),null;case 5:if(Ee(l),_=l.type,o!==null&&l.stateNode!=null)o.memoizedProps!==p&&lo(l);else{if(!p){if(l.stateNode===null)throw Error(i(166));return Ns(l),null}if(E=Ie.current,x(l))Af(l);else{var U=om(Pe.current);switch(E){case 1:E=U.createElementNS("http://www.w3.org/2000/svg",_);break;case 2:E=U.createElementNS("http://www.w3.org/1998/Math/MathML",_);break;default:switch(_){case"svg":E=U.createElementNS("http://www.w3.org/2000/svg",_);break;case"math":E=U.createElementNS("http://www.w3.org/1998/Math/MathML",_);break;case"script":E=U.createElement("div"),E.innerHTML="<script><\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof p.is=="string"?U.createElement("select",{is:p.is}):U.createElement("select"),p.multiple?E.multiple=!0:p.size&&(E.size=p.size);break;default:E=typeof p.is=="string"?U.createElement(_,{is:p.is}):U.createElement(_)}}E[qt]=l,E[Mt]=p;e:for(U=l.child;U!==null;){if(U.tag===5||U.tag===6)E.appendChild(U.stateNode);else if(U.tag!==4&&U.tag!==27&&U.child!==null){U.child.return=U,U=U.child;continue}if(U===l)break e;for(;U.sibling===null;){if(U.return===null||U.return===l)break e;U=U.return}U.sibling.return=U.return,U=U.sibling}l.stateNode=E;e:switch(Un(E,_,p),_){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&lo(l)}}return Ns(l),Mg(l,l.type,o===null?null:o.memoizedProps,l.pendingProps,h),null;case 6:if(o&&l.stateNode!=null)o.memoizedProps!==p&&lo(l);else{if(typeof p!="string"&&l.stateNode===null)throw Error(i(166));if(o=Pe.current,x(l)){if(o=l.stateNode,h=l.memoizedProps,p=null,_=cn,_!==null)switch(_.tag){case 27:case 5:p=_.memoizedProps}o[qt]=l,o=!!(o.nodeValue===h||p!==null&&p.suppressHydrationWarning===!0||VS(o.nodeValue,h)),o||Ca(l,!0)}else o=om(o).createTextNode(p),o[qt]=l,l.stateNode=o}return Ns(l),null;case 31:if(h=l.memoizedState,o===null||o.memoizedState!==null){if(p=x(l),h!==null){if(o===null){if(!p)throw Error(i(318));if(o=l.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(i(557));o[qt]=l}else A(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ns(l),o=!1}else h=D(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=h),o=!0;if(!o)return l.flags&256?(Dr(l),l):(Dr(l),null);if((l.flags&128)!==0)throw Error(i(558))}return Ns(l),null;case 13:if(p=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(_=x(l),p!==null&&p.dehydrated!==null){if(o===null){if(!_)throw Error(i(318));if(_=l.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(i(317));_[qt]=l}else A(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ns(l),_=!1}else _=D(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=_),_=!0;if(!_)return l.flags&256?(Dr(l),l):(Dr(l),null)}return Dr(l),(l.flags&128)!==0?(l.lanes=h,l):(h=p!==null,o=o!==null&&o.memoizedState!==null,h&&(p=l.child,_=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(_=p.alternate.memoizedState.cachePool.pool),E=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(E=p.memoizedState.cachePool.pool),E!==_&&(p.flags|=2048)),h!==o&&h&&(l.child.flags|=8192),qf(l,l.updateQueue),Ns(l),null);case 4:return Re(),o===null&&sy(l.stateNode.containerInfo),Ns(l),null;case 10:return he(l.type),Ns(l),null;case 19:if(le(sn),p=l.memoizedState,p===null)return Ns(l),null;if(_=(l.flags&128)!==0,E=p.rendering,E===null)if(_)Id(p,!1);else{if(Ws!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(E=Nf(o),E!==null){for(l.flags|=128,Id(p,!1),o=E.updateQueue,l.updateQueue=o,qf(l,o),l.subtreeFlags=0,o=h,h=l.child;h!==null;)Ef(h,o),h=h.sibling;return ge(sn,sn.current&1|2),Ni&&Ei(l,p.treeForkCount),l.child}o=o.sibling}p.tail!==null&&se()>Qf&&(l.flags|=128,_=!0,Id(p,!1),l.lanes=4194304)}else{if(!_)if(o=Nf(E),o!==null){if(l.flags|=128,_=!0,o=o.updateQueue,l.updateQueue=o,qf(l,o),Id(p,!0),p.tail===null&&p.tailMode==="hidden"&&!E.alternate&&!Ni)return Ns(l),null}else 2*se()-p.renderingStartTime>Qf&&h!==536870912&&(l.flags|=128,_=!0,Id(p,!1),l.lanes=4194304);p.isBackwards?(E.sibling=l.child,l.child=E):(o=p.last,o!==null?o.sibling=E:l.child=E,p.last=E)}return p.tail!==null?(o=p.tail,p.rendering=o,p.tail=o.sibling,p.renderingStartTime=se(),o.sibling=null,h=sn.current,ge(sn,_?h&1|2:h&1),Ni&&Ei(l,p.treeForkCount),o):(Ns(l),null);case 22:case 23:return Dr(l),ng(),p=l.memoizedState!==null,o!==null?o.memoizedState!==null!==p&&(l.flags|=8192):p&&(l.flags|=8192),p?(h&536870912)!==0&&(l.flags&128)===0&&(Ns(l),l.subtreeFlags&6&&(l.flags|=8192)):Ns(l),h=l.updateQueue,h!==null&&qf(l,h.retryQueue),h=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==h&&(l.flags|=2048),o!==null&&le(ql),null;case 24:return h=null,o!==null&&(h=o.memoizedState.cache),l.memoizedState.cache!==h&&(l.flags|=2048),he(Ds),Ns(l),null;case 25:return null;case 30:return null}throw Error(i(156,l.tag))}function lI(o,l){switch(or(l),l.tag){case 1:return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return he(Ds),Re(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 26:case 27:case 5:return Ee(l),null;case 31:if(l.memoizedState!==null){if(Dr(l),l.alternate===null)throw Error(i(340));A()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 13:if(Dr(l),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(i(340));A()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return le(sn),null;case 4:return Re(),null;case 10:return he(l.type),null;case 22:case 23:return Dr(l),ng(),o!==null&&le(ql),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 24:return he(Ds),null;case 25:return null;default:return null}}function YT(o,l){switch(or(l),l.tag){case 3:he(Ds),Re();break;case 26:case 27:case 5:Ee(l);break;case 4:Re();break;case 31:l.memoizedState!==null&&Dr(l);break;case 13:Dr(l);break;case 19:le(sn);break;case 10:he(l.type);break;case 22:case 23:Dr(l),ng(),o!==null&&le(ql);break;case 24:he(Ds)}}function Nd(o,l){try{var h=l.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var _=p.next;h=_;do{if((h.tag&o)===o){p=void 0;var E=h.create,U=h.inst;p=E(),U.destroy=p}h=h.next}while(h!==_)}}catch(ee){ls(l,l.return,ee)}}function Jo(o,l,h){try{var p=l.updateQueue,_=p!==null?p.lastEffect:null;if(_!==null){var E=_.next;p=E;do{if((p.tag&o)===o){var U=p.inst,ee=U.destroy;if(ee!==void 0){U.destroy=void 0,_=l;var be=h,Ke=ee;try{Ke()}catch(rt){ls(_,be,rt)}}}p=p.next}while(p!==E)}}catch(rt){ls(l,l.return,rt)}}function XT(o){var l=o.updateQueue;if(l!==null){var h=o.stateNode;try{j1(l,h)}catch(p){ls(o,o.return,p)}}}function QT(o,l,h){h.props=Ql(o.type,o.memoizedProps),h.state=o.memoizedState;try{h.componentWillUnmount()}catch(p){ls(o,l,p)}}function Od(o,l){try{var h=o.ref;if(h!==null){switch(o.tag){case 26:case 27:case 5:var p=o.stateNode;break;case 30:p=o.stateNode;break;default:p=o.stateNode}typeof h=="function"?o.refCleanup=h(p):h.current=p}}catch(_){ls(o,l,_)}}function Ra(o,l){var h=o.ref,p=o.refCleanup;if(h!==null)if(typeof p=="function")try{p()}catch(_){ls(o,l,_)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(_){ls(o,l,_)}else h.current=null}function ZT(o){var l=o.type,h=o.memoizedProps,p=o.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":h.autoFocus&&p.focus();break e;case"img":h.src?p.src=h.src:h.srcSet&&(p.srcset=h.srcSet)}}catch(_){ls(o,o.return,_)}}function Pg(o,l,h){try{var p=o.stateNode;LI(p,o.type,h,l),p[Mt]=l}catch(_){ls(o,o.return,_)}}function JT(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&al(o.type)||o.tag===4}function Bg(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||JT(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&al(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Fg(o,l,h){var p=o.tag;if(p===5||p===6)o=o.stateNode,l?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(o,l):(l=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,l.appendChild(o),h=h._reactRootContainer,h!=null||l.onclick!==null||(l.onclick=zi));else if(p!==4&&(p===27&&al(o.type)&&(h=o.stateNode,l=null),o=o.child,o!==null))for(Fg(o,l,h),o=o.sibling;o!==null;)Fg(o,l,h),o=o.sibling}function Kf(o,l,h){var p=o.tag;if(p===5||p===6)o=o.stateNode,l?h.insertBefore(o,l):h.appendChild(o);else if(p!==4&&(p===27&&al(o.type)&&(h=o.stateNode),o=o.child,o!==null))for(Kf(o,l,h),o=o.sibling;o!==null;)Kf(o,l,h),o=o.sibling}function eS(o){var l=o.stateNode,h=o.memoizedProps;try{for(var p=o.type,_=l.attributes;_.length;)l.removeAttributeNode(_[0]);Un(l,p,h),l[qt]=o,l[Mt]=h}catch(E){ls(o,o.return,E)}}var uo=!1,fn=!1,Ug=!1,tS=typeof WeakSet=="function"?WeakSet:Set,An=null;function uI(o,l){if(o=o.containerInfo,ay=mm,o=Iu(o),ud(o)){if("selectionStart"in o)var h={start:o.selectionStart,end:o.selectionEnd};else e:{h=(h=o.ownerDocument)&&h.defaultView||window;var p=h.getSelection&&h.getSelection();if(p&&p.rangeCount!==0){h=p.anchorNode;var _=p.anchorOffset,E=p.focusNode;p=p.focusOffset;try{h.nodeType,E.nodeType}catch{h=null;break e}var U=0,ee=-1,be=-1,Ke=0,rt=0,ft=o,Ye=null;t:for(;;){for(var tt;ft!==h||_!==0&&ft.nodeType!==3||(ee=U+_),ft!==E||p!==0&&ft.nodeType!==3||(be=U+p),ft.nodeType===3&&(U+=ft.nodeValue.length),(tt=ft.firstChild)!==null;)Ye=ft,ft=tt;for(;;){if(ft===o)break t;if(Ye===h&&++Ke===_&&(ee=U),Ye===E&&++rt===p&&(be=U),(tt=ft.nextSibling)!==null)break;ft=Ye,Ye=ft.parentNode}ft=tt}h=ee===-1||be===-1?null:{start:ee,end:be}}else h=null}h=h||{start:0,end:0}}else h=null;for(oy={focusedElem:o,selectionRange:h},mm=!1,An=l;An!==null;)if(l=An,o=l.child,(l.subtreeFlags&1028)!==0&&o!==null)o.return=l,An=o;else for(;An!==null;){switch(l=An,E=l.alternate,o=l.flags,l.tag){case 0:if((o&4)!==0&&(o=l.updateQueue,o=o!==null?o.events:null,o!==null))for(h=0;h<o.length;h++)_=o[h],_.ref.impl=_.nextImpl;break;case 11:case 15:break;case 1:if((o&1024)!==0&&E!==null){o=void 0,h=l,_=E.memoizedProps,E=E.memoizedState,p=h.stateNode;try{var $t=Ql(h.type,_);o=p.getSnapshotBeforeUpdate($t,E),p.__reactInternalSnapshotBeforeUpdate=o}catch(li){ls(h,h.return,li)}}break;case 3:if((o&1024)!==0){if(o=l.stateNode.containerInfo,h=o.nodeType,h===9)cy(o);else if(h===1)switch(o.nodeName){case"HEAD":case"HTML":case"BODY":cy(o);break;default:o.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((o&1024)!==0)throw Error(i(163))}if(o=l.sibling,o!==null){o.return=l.return,An=o;break}An=l.return}}function iS(o,l,h){var p=h.flags;switch(h.tag){case 0:case 11:case 15:ho(o,h),p&4&&Nd(5,h);break;case 1:if(ho(o,h),p&4)if(o=h.stateNode,l===null)try{o.componentDidMount()}catch(U){ls(h,h.return,U)}else{var _=Ql(h.type,l.memoizedProps);l=l.memoizedState;try{o.componentDidUpdate(_,l,o.__reactInternalSnapshotBeforeUpdate)}catch(U){ls(h,h.return,U)}}p&64&&XT(h),p&512&&Od(h,h.return);break;case 3:if(ho(o,h),p&64&&(o=h.updateQueue,o!==null)){if(l=null,h.child!==null)switch(h.child.tag){case 27:case 5:l=h.child.stateNode;break;case 1:l=h.child.stateNode}try{j1(o,l)}catch(U){ls(h,h.return,U)}}break;case 27:l===null&&p&4&&eS(h);case 26:case 5:ho(o,h),l===null&&p&4&&ZT(h),p&512&&Od(h,h.return);break;case 12:ho(o,h);break;case 31:ho(o,h),p&4&&rS(o,h);break;case 13:ho(o,h),p&4&&aS(o,h),p&64&&(o=h.memoizedState,o!==null&&(o=o.dehydrated,o!==null&&(h=vI.bind(null,h),FI(o,h))));break;case 22:if(p=h.memoizedState!==null||uo,!p){l=l!==null&&l.memoizedState!==null||fn,_=uo;var E=fn;uo=p,(fn=l)&&!E?fo(o,h,(h.subtreeFlags&8772)!==0):ho(o,h),uo=_,fn=E}break;case 30:break;default:ho(o,h)}}function sS(o){var l=o.alternate;l!==null&&(o.alternate=null,sS(l)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(l=o.stateNode,l!==null&&fi(l)),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}var Bs=null,ur=!1;function co(o,l,h){for(h=h.child;h!==null;)nS(o,l,h),h=h.sibling}function nS(o,l,h){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(Ft,h)}catch{}switch(h.tag){case 26:fn||Ra(h,l),co(o,l,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:fn||Ra(h,l);var p=Bs,_=ur;al(h.type)&&(Bs=h.stateNode,ur=!1),co(o,l,h),zd(h.stateNode),Bs=p,ur=_;break;case 5:fn||Ra(h,l);case 6:if(p=Bs,_=ur,Bs=null,co(o,l,h),Bs=p,ur=_,Bs!==null)if(ur)try{(Bs.nodeType===9?Bs.body:Bs.nodeName==="HTML"?Bs.ownerDocument.body:Bs).removeChild(h.stateNode)}catch(E){ls(h,l,E)}else try{Bs.removeChild(h.stateNode)}catch(E){ls(h,l,E)}break;case 18:Bs!==null&&(ur?(o=Bs,XS(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,h.stateNode),tc(o)):XS(Bs,h.stateNode));break;case 4:p=Bs,_=ur,Bs=h.stateNode.containerInfo,ur=!0,co(o,l,h),Bs=p,ur=_;break;case 0:case 11:case 14:case 15:Jo(2,h,l),fn||Jo(4,h,l),co(o,l,h);break;case 1:fn||(Ra(h,l),p=h.stateNode,typeof p.componentWillUnmount=="function"&&QT(h,l,p)),co(o,l,h);break;case 21:co(o,l,h);break;case 22:fn=(p=fn)||h.memoizedState!==null,co(o,l,h),fn=p;break;default:co(o,l,h)}}function rS(o,l){if(l.memoizedState===null&&(o=l.alternate,o!==null&&(o=o.memoizedState,o!==null))){o=o.dehydrated;try{tc(o)}catch(h){ls(l,l.return,h)}}}function aS(o,l){if(l.memoizedState===null&&(o=l.alternate,o!==null&&(o=o.memoizedState,o!==null&&(o=o.dehydrated,o!==null))))try{tc(o)}catch(h){ls(l,l.return,h)}}function cI(o){switch(o.tag){case 31:case 13:case 19:var l=o.stateNode;return l===null&&(l=o.stateNode=new tS),l;case 22:return o=o.stateNode,l=o._retryCache,l===null&&(l=o._retryCache=new tS),l;default:throw Error(i(435,o.tag))}}function Wf(o,l){var h=cI(o);l.forEach(function(p){if(!h.has(p)){h.add(p);var _=xI.bind(null,o,p);p.then(_,_)}})}function cr(o,l){var h=l.deletions;if(h!==null)for(var p=0;p<h.length;p++){var _=h[p],E=o,U=l,ee=U;e:for(;ee!==null;){switch(ee.tag){case 27:if(al(ee.type)){Bs=ee.stateNode,ur=!1;break e}break;case 5:Bs=ee.stateNode,ur=!1;break e;case 3:case 4:Bs=ee.stateNode.containerInfo,ur=!0;break e}ee=ee.return}if(Bs===null)throw Error(i(160));nS(E,U,_),Bs=null,ur=!1,E=_.alternate,E!==null&&(E.return=null),_.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)oS(l,o),l=l.sibling}var ca=null;function oS(o,l){var h=o.alternate,p=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:cr(l,o),dr(o),p&4&&(Jo(3,o,o.return),Nd(3,o),Jo(5,o,o.return));break;case 1:cr(l,o),dr(o),p&512&&(fn||h===null||Ra(h,h.return)),p&64&&uo&&(o=o.updateQueue,o!==null&&(p=o.callbacks,p!==null&&(h=o.shared.hiddenCallbacks,o.shared.hiddenCallbacks=h===null?p:h.concat(p))));break;case 26:var _=ca;if(cr(l,o),dr(o),p&512&&(fn||h===null||Ra(h,h.return)),p&4){var E=h!==null?h.memoizedState:null;if(p=o.memoizedState,h===null)if(p===null)if(o.stateNode===null){e:{p=o.type,h=o.memoizedProps,_=_.ownerDocument||_;t:switch(p){case"title":E=_.getElementsByTagName("title")[0],(!E||E[Gi]||E[qt]||E.namespaceURI==="http://www.w3.org/2000/svg"||E.hasAttribute("itemprop"))&&(E=_.createElement(p),_.head.insertBefore(E,_.querySelector("head > title"))),Un(E,p,h),E[qt]=o,Di(E),p=E;break e;case"link":var U=o_("link","href",_).get(p+(h.href||""));if(U){for(var ee=0;ee<U.length;ee++)if(E=U[ee],E.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&E.getAttribute("rel")===(h.rel==null?null:h.rel)&&E.getAttribute("title")===(h.title==null?null:h.title)&&E.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){U.splice(ee,1);break t}}E=_.createElement(p),Un(E,p,h),_.head.appendChild(E);break;case"meta":if(U=o_("meta","content",_).get(p+(h.content||""))){for(ee=0;ee<U.length;ee++)if(E=U[ee],E.getAttribute("content")===(h.content==null?null:""+h.content)&&E.getAttribute("name")===(h.name==null?null:h.name)&&E.getAttribute("property")===(h.property==null?null:h.property)&&E.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&E.getAttribute("charset")===(h.charSet==null?null:h.charSet)){U.splice(ee,1);break t}}E=_.createElement(p),Un(E,p,h),_.head.appendChild(E);break;default:throw Error(i(468,p))}E[qt]=o,Di(E),p=E}o.stateNode=p}else l_(_,o.type,o.stateNode);else o.stateNode=a_(_,p,o.memoizedProps);else E!==p?(E===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):E.count--,p===null?l_(_,o.type,o.stateNode):a_(_,p,o.memoizedProps)):p===null&&o.stateNode!==null&&Pg(o,o.memoizedProps,h.memoizedProps)}break;case 27:cr(l,o),dr(o),p&512&&(fn||h===null||Ra(h,h.return)),h!==null&&p&4&&Pg(o,o.memoizedProps,h.memoizedProps);break;case 5:if(cr(l,o),dr(o),p&512&&(fn||h===null||Ra(h,h.return)),o.flags&32){_=o.stateNode;try{Zs(_,"")}catch($t){ls(o,o.return,$t)}}p&4&&o.stateNode!=null&&(_=o.memoizedProps,Pg(o,_,h!==null?h.memoizedProps:_)),p&1024&&(Ug=!0);break;case 6:if(cr(l,o),dr(o),p&4){if(o.stateNode===null)throw Error(i(162));p=o.memoizedProps,h=o.stateNode;try{h.nodeValue=p}catch($t){ls(o,o.return,$t)}}break;case 3:if(cm=null,_=ca,ca=lm(l.containerInfo),cr(l,o),ca=_,dr(o),p&4&&h!==null&&h.memoizedState.isDehydrated)try{tc(l.containerInfo)}catch($t){ls(o,o.return,$t)}Ug&&(Ug=!1,lS(o));break;case 4:p=ca,ca=lm(o.stateNode.containerInfo),cr(l,o),dr(o),ca=p;break;case 12:cr(l,o),dr(o);break;case 31:cr(l,o),dr(o),p&4&&(p=o.updateQueue,p!==null&&(o.updateQueue=null,Wf(o,p)));break;case 13:cr(l,o),dr(o),o.child.flags&8192&&o.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(Xf=se()),p&4&&(p=o.updateQueue,p!==null&&(o.updateQueue=null,Wf(o,p)));break;case 22:_=o.memoizedState!==null;var be=h!==null&&h.memoizedState!==null,Ke=uo,rt=fn;if(uo=Ke||_,fn=rt||be,cr(l,o),fn=rt,uo=Ke,dr(o),p&8192)e:for(l=o.stateNode,l._visibility=_?l._visibility&-2:l._visibility|1,_&&(h===null||be||uo||fn||Zl(o)),h=null,l=o;;){if(l.tag===5||l.tag===26){if(h===null){be=h=l;try{if(E=be.stateNode,_)U=E.style,typeof U.setProperty=="function"?U.setProperty("display","none","important"):U.display="none";else{ee=be.stateNode;var ft=be.memoizedProps.style,Ye=ft!=null&&ft.hasOwnProperty("display")?ft.display:null;ee.style.display=Ye==null||typeof Ye=="boolean"?"":(""+Ye).trim()}}catch($t){ls(be,be.return,$t)}}}else if(l.tag===6){if(h===null){be=l;try{be.stateNode.nodeValue=_?"":be.memoizedProps}catch($t){ls(be,be.return,$t)}}}else if(l.tag===18){if(h===null){be=l;try{var tt=be.stateNode;_?QS(tt,!0):QS(be.stateNode,!1)}catch($t){ls(be,be.return,$t)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===o)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break e;for(;l.sibling===null;){if(l.return===null||l.return===o)break e;h===l&&(h=null),l=l.return}h===l&&(h=null),l.sibling.return=l.return,l=l.sibling}p&4&&(p=o.updateQueue,p!==null&&(h=p.retryQueue,h!==null&&(p.retryQueue=null,Wf(o,h))));break;case 19:cr(l,o),dr(o),p&4&&(p=o.updateQueue,p!==null&&(o.updateQueue=null,Wf(o,p)));break;case 30:break;case 21:break;default:cr(l,o),dr(o)}}function dr(o){var l=o.flags;if(l&2){try{for(var h,p=o.return;p!==null;){if(JT(p)){h=p;break}p=p.return}if(h==null)throw Error(i(160));switch(h.tag){case 27:var _=h.stateNode,E=Bg(o);Kf(o,E,_);break;case 5:var U=h.stateNode;h.flags&32&&(Zs(U,""),h.flags&=-33);var ee=Bg(o);Kf(o,ee,U);break;case 3:case 4:var be=h.stateNode.containerInfo,Ke=Bg(o);Fg(o,Ke,be);break;default:throw Error(i(161))}}catch(rt){ls(o,o.return,rt)}o.flags&=-3}l&4096&&(o.flags&=-4097)}function lS(o){if(o.subtreeFlags&1024)for(o=o.child;o!==null;){var l=o;lS(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),o=o.sibling}}function ho(o,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)iS(o,l.alternate,l),l=l.sibling}function Zl(o){for(o=o.child;o!==null;){var l=o;switch(l.tag){case 0:case 11:case 14:case 15:Jo(4,l,l.return),Zl(l);break;case 1:Ra(l,l.return);var h=l.stateNode;typeof h.componentWillUnmount=="function"&&QT(l,l.return,h),Zl(l);break;case 27:zd(l.stateNode);case 26:case 5:Ra(l,l.return),Zl(l);break;case 22:l.memoizedState===null&&Zl(l);break;case 30:Zl(l);break;default:Zl(l)}o=o.sibling}}function fo(o,l,h){for(h=h&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var p=l.alternate,_=o,E=l,U=E.flags;switch(E.tag){case 0:case 11:case 15:fo(_,E,h),Nd(4,E);break;case 1:if(fo(_,E,h),p=E,_=p.stateNode,typeof _.componentDidMount=="function")try{_.componentDidMount()}catch(Ke){ls(p,p.return,Ke)}if(p=E,_=p.updateQueue,_!==null){var ee=p.stateNode;try{var be=_.shared.hiddenCallbacks;if(be!==null)for(_.shared.hiddenCallbacks=null,_=0;_<be.length;_++)U1(be[_],ee)}catch(Ke){ls(p,p.return,Ke)}}h&&U&64&&XT(E),Od(E,E.return);break;case 27:eS(E);case 26:case 5:fo(_,E,h),h&&p===null&&U&4&&ZT(E),Od(E,E.return);break;case 12:fo(_,E,h);break;case 31:fo(_,E,h),h&&U&4&&rS(_,E);break;case 13:fo(_,E,h),h&&U&4&&aS(_,E);break;case 22:E.memoizedState===null&&fo(_,E,h),Od(E,E.return);break;case 30:break;default:fo(_,E,h)}l=l.sibling}}function jg(o,l){var h=null;o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==h&&(o!=null&&o.refCount++,h!=null&&ua(h))}function $g(o,l){o=null,l.alternate!==null&&(o=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==o&&(l.refCount++,o!=null&&ua(o))}function da(o,l,h,p){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)uS(o,l,h,p),l=l.sibling}function uS(o,l,h,p){var _=l.flags;switch(l.tag){case 0:case 11:case 15:da(o,l,h,p),_&2048&&Nd(9,l);break;case 1:da(o,l,h,p);break;case 3:da(o,l,h,p),_&2048&&(o=null,l.alternate!==null&&(o=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==o&&(l.refCount++,o!=null&&ua(o)));break;case 12:if(_&2048){da(o,l,h,p),o=l.stateNode;try{var E=l.memoizedProps,U=E.id,ee=E.onPostCommit;typeof ee=="function"&&ee(U,l.alternate===null?"mount":"update",o.passiveEffectDuration,-0)}catch(be){ls(l,l.return,be)}}else da(o,l,h,p);break;case 31:da(o,l,h,p);break;case 13:da(o,l,h,p);break;case 23:break;case 22:E=l.stateNode,U=l.alternate,l.memoizedState!==null?E._visibility&2?da(o,l,h,p):Md(o,l):E._visibility&2?da(o,l,h,p):(E._visibility|=2,Vu(o,l,h,p,(l.subtreeFlags&10256)!==0||!1)),_&2048&&jg(U,l);break;case 24:da(o,l,h,p),_&2048&&$g(l.alternate,l);break;default:da(o,l,h,p)}}function Vu(o,l,h,p,_){for(_=_&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var E=o,U=l,ee=h,be=p,Ke=U.flags;switch(U.tag){case 0:case 11:case 15:Vu(E,U,ee,be,_),Nd(8,U);break;case 23:break;case 22:var rt=U.stateNode;U.memoizedState!==null?rt._visibility&2?Vu(E,U,ee,be,_):Md(E,U):(rt._visibility|=2,Vu(E,U,ee,be,_)),_&&Ke&2048&&jg(U.alternate,U);break;case 24:Vu(E,U,ee,be,_),_&&Ke&2048&&$g(U.alternate,U);break;default:Vu(E,U,ee,be,_)}l=l.sibling}}function Md(o,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var h=o,p=l,_=p.flags;switch(p.tag){case 22:Md(h,p),_&2048&&jg(p.alternate,p);break;case 24:Md(h,p),_&2048&&$g(p.alternate,p);break;default:Md(h,p)}l=l.sibling}}var Pd=8192;function Gu(o,l,h){if(o.subtreeFlags&Pd)for(o=o.child;o!==null;)cS(o,l,h),o=o.sibling}function cS(o,l,h){switch(o.tag){case 26:Gu(o,l,h),o.flags&Pd&&o.memoizedState!==null&&XI(h,ca,o.memoizedState,o.memoizedProps);break;case 5:Gu(o,l,h);break;case 3:case 4:var p=ca;ca=lm(o.stateNode.containerInfo),Gu(o,l,h),ca=p;break;case 22:o.memoizedState===null&&(p=o.alternate,p!==null&&p.memoizedState!==null?(p=Pd,Pd=16777216,Gu(o,l,h),Pd=p):Gu(o,l,h));break;default:Gu(o,l,h)}}function dS(o){var l=o.alternate;if(l!==null&&(o=l.child,o!==null)){l.child=null;do l=o.sibling,o.sibling=null,o=l;while(o!==null)}}function Bd(o){var l=o.deletions;if((o.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];An=p,fS(p,o)}dS(o)}if(o.subtreeFlags&10256)for(o=o.child;o!==null;)hS(o),o=o.sibling}function hS(o){switch(o.tag){case 0:case 11:case 15:Bd(o),o.flags&2048&&Jo(9,o,o.return);break;case 3:Bd(o);break;case 12:Bd(o);break;case 22:var l=o.stateNode;o.memoizedState!==null&&l._visibility&2&&(o.return===null||o.return.tag!==13)?(l._visibility&=-3,Yf(o)):Bd(o);break;default:Bd(o)}}function Yf(o){var l=o.deletions;if((o.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];An=p,fS(p,o)}dS(o)}for(o=o.child;o!==null;){switch(l=o,l.tag){case 0:case 11:case 15:Jo(8,l,l.return),Yf(l);break;case 22:h=l.stateNode,h._visibility&2&&(h._visibility&=-3,Yf(l));break;default:Yf(l)}o=o.sibling}}function fS(o,l){for(;An!==null;){var h=An;switch(h.tag){case 0:case 11:case 15:Jo(8,h,l);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var p=h.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:ua(h.memoizedState.cache)}if(p=h.child,p!==null)p.return=h,An=p;else e:for(h=o;An!==null;){p=An;var _=p.sibling,E=p.return;if(sS(p),p===h){An=null;break e}if(_!==null){_.return=E,An=_;break e}An=E}}}var dI={getCacheForType:function(o){var l=Bt(Ds),h=l.data.get(o);return h===void 0&&(h=o(),l.data.set(o,h)),h},cacheSignal:function(){return Bt(Ds).controller.signal}},hI=typeof WeakMap=="function"?WeakMap:Map,es=0,_s=null,Oi=null,Ui=0,os=0,Lr=null,el=!1,qu=!1,Hg=!1,mo=0,Ws=0,tl=0,Jl=0,zg=0,Rr=0,Ku=0,Fd=null,hr=null,Vg=!1,Xf=0,mS=0,Qf=1/0,Zf=null,il=null,xn=0,sl=null,Wu=null,po=0,Gg=0,qg=null,pS=null,Ud=0,Kg=null;function Ir(){return(es&2)!==0&&Ui!==0?Ui&-Ui:W.T!==null?Jg():xi()}function gS(){if(Rr===0)if((Ui&536870912)===0||Ni){var o=ki;ki<<=1,(ki&3932160)===0&&(ki=262144),Rr=o}else Rr=536870912;return o=Cr.current,o!==null&&(o.flags|=32),Rr}function fr(o,l,h){(o===_s&&(os===2||os===9)||o.cancelPendingCommit!==null)&&(Yu(o,0),nl(o,Ui,Rr,!1)),It(o,h),((es&2)===0||o!==_s)&&(o===_s&&((es&2)===0&&(Jl|=h),Ws===4&&nl(o,Ui,Rr,!1)),Ia(o))}function yS(o,l,h){if((es&6)!==0)throw Error(i(327));var p=!h&&(l&127)===0&&(l&o.expiredLanes)===0||ie(o,l),_=p?pI(o,l):Yg(o,l,!0),E=p;do{if(_===0){qu&&!p&&nl(o,l,0,!1);break}else{if(h=o.current.alternate,E&&!fI(h)){_=Yg(o,l,!1),E=!1;continue}if(_===2){if(E=l,o.errorRecoveryDisabledLanes&E)var U=0;else U=o.pendingLanes&-536870913,U=U!==0?U:U&536870912?536870912:0;if(U!==0){l=U;e:{var ee=o;_=Fd;var be=ee.current.memoizedState.isDehydrated;if(be&&(Yu(ee,U).flags|=256),U=Yg(ee,U,!1),U!==2){if(Hg&&!be){ee.errorRecoveryDisabledLanes|=E,Jl|=E,_=4;break e}E=hr,hr=_,E!==null&&(hr===null?hr=E:hr.push.apply(hr,E))}_=U}if(E=!1,_!==2)continue}}if(_===1){Yu(o,0),nl(o,l,0,!0);break}e:{switch(p=o,E=_,E){case 0:case 1:throw Error(i(345));case 4:if((l&4194048)!==l)break;case 6:nl(p,l,Rr,!el);break e;case 2:hr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((l&62914560)===l&&(_=Xf+300-se(),10<_)){if(nl(p,l,Rr,!el),$(p,0,!0)!==0)break e;po=l,p.timeoutHandle=WS(vS.bind(null,p,h,hr,Zf,Vg,l,Rr,Jl,Ku,el,E,"Throttled",-0,0),_);break e}vS(p,h,hr,Zf,Vg,l,Rr,Jl,Ku,el,E,null,-0,0)}}break}while(!0);Ia(o)}function vS(o,l,h,p,_,E,U,ee,be,Ke,rt,ft,Ye,tt){if(o.timeoutHandle=-1,ft=l.subtreeFlags,ft&8192||(ft&16785408)===16785408){ft={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zi},cS(l,E,ft);var $t=(E&62914560)===E?Xf-se():(E&4194048)===E?mS-se():0;if($t=QI(ft,$t),$t!==null){po=E,o.cancelPendingCommit=$t(AS.bind(null,o,l,E,h,p,_,U,ee,be,rt,ft,null,Ye,tt)),nl(o,E,U,!Ke);return}}AS(o,l,E,h,p,_,U,ee,be)}function fI(o){for(var l=o;;){var h=l.tag;if((h===0||h===11||h===15)&&l.flags&16384&&(h=l.updateQueue,h!==null&&(h=h.stores,h!==null)))for(var p=0;p<h.length;p++){var _=h[p],E=_.getSnapshot;_=_.value;try{if(!Gn(E(),_))return!1}catch{return!1}}if(h=l.child,l.subtreeFlags&16384&&h!==null)h.return=l,l=h;else{if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function nl(o,l,h,p){l&=~zg,l&=~Jl,o.suspendedLanes|=l,o.pingedLanes&=~l,p&&(o.warmLanes|=l),p=o.expirationTimes;for(var _=l;0<_;){var E=31-Et(_),U=1<<E;p[E]=-1,_&=~U}h!==0&&pi(o,h,l)}function Jf(){return(es&6)===0?(jd(0),!1):!0}function Wg(){if(Oi!==null){if(os===0)var o=Oi.return;else o=Oi,ae=B=null,cg(o),Uu=null,Sd=0,o=Oi;for(;o!==null;)YT(o.alternate,o),o=o.return;Oi=null}}function Yu(o,l){var h=o.timeoutHandle;h!==-1&&(o.timeoutHandle=-1,NI(h)),h=o.cancelPendingCommit,h!==null&&(o.cancelPendingCommit=null,h()),po=0,Wg(),_s=o,Oi=h=la(o.current,null),Ui=l,os=0,Lr=null,el=!1,qu=ie(o,l),Hg=!1,Ku=Rr=zg=Jl=tl=Ws=0,hr=Fd=null,Vg=!1,(l&8)!==0&&(l|=l&32);var p=o.entangledLanes;if(p!==0)for(o=o.entanglements,p&=l;0<p;){var _=31-Et(p),E=1<<_;l|=o[_],p&=~E}return mo=l,Ou(),h}function xS(o,l){Ti=null,W.H=Ld,l===Fu||l===Cf?(l=M1(),os=3):l===Zp?(l=M1(),os=4):os=l===Ag?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Lr=l,Oi===null&&(Ws=1,Hf(o,rr(l,o.current)))}function bS(){var o=Cr.current;return o===null?!0:(Ui&4194048)===Ui?qr===null:(Ui&62914560)===Ui||(Ui&536870912)!==0?o===qr:!1}function TS(){var o=W.H;return W.H=Ld,o===null?Ld:o}function SS(){var o=W.A;return W.A=dI,o}function em(){Ws=4,el||(Ui&4194048)!==Ui&&Cr.current!==null||(qu=!0),(tl&134217727)===0&&(Jl&134217727)===0||_s===null||nl(_s,Ui,Rr,!1)}function Yg(o,l,h){var p=es;es|=2;var _=TS(),E=SS();(_s!==o||Ui!==l)&&(Zf=null,Yu(o,l)),l=!1;var U=Ws;e:do try{if(os!==0&&Oi!==null){var ee=Oi,be=Lr;switch(os){case 8:Wg(),U=6;break e;case 3:case 2:case 9:case 6:Cr.current===null&&(l=!0);var Ke=os;if(os=0,Lr=null,Xu(o,ee,be,Ke),h&&qu){U=0;break e}break;default:Ke=os,os=0,Lr=null,Xu(o,ee,be,Ke)}}mI(),U=Ws;break}catch(rt){xS(o,rt)}while(!0);return l&&o.shellSuspendCounter++,ae=B=null,es=p,W.H=_,W.A=E,Oi===null&&(_s=null,Ui=0,Ou()),U}function mI(){for(;Oi!==null;)_S(Oi)}function pI(o,l){var h=es;es|=2;var p=TS(),_=SS();_s!==o||Ui!==l?(Zf=null,Qf=se()+500,Yu(o,l)):qu=ie(o,l);e:do try{if(os!==0&&Oi!==null){l=Oi;var E=Lr;t:switch(os){case 1:os=0,Lr=null,Xu(o,l,E,1);break;case 2:case 9:if(N1(E)){os=0,Lr=null,ES(l);break}l=function(){os!==2&&os!==9||_s!==o||(os=7),Ia(o)},E.then(l,l);break e;case 3:os=7;break e;case 4:os=5;break e;case 7:N1(E)?(os=0,Lr=null,ES(l)):(os=0,Lr=null,Xu(o,l,E,7));break;case 5:var U=null;switch(Oi.tag){case 26:U=Oi.memoizedState;case 5:case 27:var ee=Oi;if(U?u_(U):ee.stateNode.complete){os=0,Lr=null;var be=ee.sibling;if(be!==null)Oi=be;else{var Ke=ee.return;Ke!==null?(Oi=Ke,tm(Ke)):Oi=null}break t}}os=0,Lr=null,Xu(o,l,E,5);break;case 6:os=0,Lr=null,Xu(o,l,E,6);break;case 8:Wg(),Ws=6;break e;default:throw Error(i(462))}}gI();break}catch(rt){xS(o,rt)}while(!0);return ae=B=null,W.H=p,W.A=_,es=h,Oi!==null?0:(_s=null,Ui=0,Ou(),Ws)}function gI(){for(;Oi!==null&&!ct();)_S(Oi)}function _S(o){var l=KT(o.alternate,o,mo);o.memoizedProps=o.pendingProps,l===null?tm(o):Oi=l}function ES(o){var l=o,h=l.alternate;switch(l.tag){case 15:case 0:l=$T(h,l,l.pendingProps,l.type,void 0,Ui);break;case 11:l=$T(h,l,l.pendingProps,l.type.render,l.ref,Ui);break;case 5:cg(l);default:YT(h,l),l=Oi=Ef(l,mo),l=KT(h,l,mo)}o.memoizedProps=o.pendingProps,l===null?tm(o):Oi=l}function Xu(o,l,h,p){ae=B=null,cg(l),Uu=null,Sd=0;var _=l.return;try{if(nI(o,_,l,h,Ui)){Ws=1,Hf(o,rr(h,o.current)),Oi=null;return}}catch(E){if(_!==null)throw Oi=_,E;Ws=1,Hf(o,rr(h,o.current)),Oi=null;return}l.flags&32768?(Ni||p===1?o=!0:qu||(Ui&536870912)!==0?o=!1:(el=o=!0,(p===2||p===9||p===3||p===6)&&(p=Cr.current,p!==null&&p.tag===13&&(p.flags|=16384))),wS(l,o)):tm(l)}function tm(o){var l=o;do{if((l.flags&32768)!==0){wS(l,el);return}o=l.return;var h=oI(l.alternate,l,mo);if(h!==null){Oi=h;return}if(l=l.sibling,l!==null){Oi=l;return}Oi=l=o}while(l!==null);Ws===0&&(Ws=5)}function wS(o,l){do{var h=lI(o.alternate,o);if(h!==null){h.flags&=32767,Oi=h;return}if(h=o.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!l&&(o=o.sibling,o!==null)){Oi=o;return}Oi=o=h}while(o!==null);Ws=6,Oi=null}function AS(o,l,h,p,_,E,U,ee,be){o.cancelPendingCommit=null;do im();while(xn!==0);if((es&6)!==0)throw Error(i(327));if(l!==null){if(l===o.current)throw Error(i(177));if(E=l.lanes|l.childLanes,E|=pd,Yt(o,h,E,U,ee,be),o===_s&&(Oi=_s=null,Ui=0),Wu=l,sl=o,po=h,Gg=E,qg=_,pS=p,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(o.callbackNode=null,o.callbackPriority=0,bI(at,function(){return RS(),null})):(o.callbackNode=null,o.callbackPriority=0),p=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||p){p=W.T,W.T=null,_=q.p,q.p=2,U=es,es|=4;try{uI(o,l,h)}finally{es=U,q.p=_,W.T=p}}xn=1,kS(),CS(),DS()}}function kS(){if(xn===1){xn=0;var o=sl,l=Wu,h=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||h){h=W.T,W.T=null;var p=q.p;q.p=2;var _=es;es|=4;try{oS(l,o);var E=oy,U=Iu(o.containerInfo),ee=E.focusedElem,be=E.selectionRange;if(U!==ee&&ee&&ee.ownerDocument&&to(ee.ownerDocument.documentElement,ee)){if(be!==null&&ud(ee)){var Ke=be.start,rt=be.end;if(rt===void 0&&(rt=Ke),"selectionStart"in ee)ee.selectionStart=Ke,ee.selectionEnd=Math.min(rt,ee.value.length);else{var ft=ee.ownerDocument||document,Ye=ft&&ft.defaultView||window;if(Ye.getSelection){var tt=Ye.getSelection(),$t=ee.textContent.length,li=Math.min(be.start,$t),ps=be.end===void 0?li:Math.min(be.end,$t);!tt.extend&&li>ps&&(U=ps,ps=li,li=U);var Me=Ps(ee,li),Ae=Ps(ee,ps);if(Me&&Ae&&(tt.rangeCount!==1||tt.anchorNode!==Me.node||tt.anchorOffset!==Me.offset||tt.focusNode!==Ae.node||tt.focusOffset!==Ae.offset)){var qe=ft.createRange();qe.setStart(Me.node,Me.offset),tt.removeAllRanges(),li>ps?(tt.addRange(qe),tt.extend(Ae.node,Ae.offset)):(qe.setEnd(Ae.node,Ae.offset),tt.addRange(qe))}}}}for(ft=[],tt=ee;tt=tt.parentNode;)tt.nodeType===1&&ft.push({element:tt,left:tt.scrollLeft,top:tt.scrollTop});for(typeof ee.focus=="function"&&ee.focus(),ee=0;ee<ft.length;ee++){var lt=ft[ee];lt.element.scrollLeft=lt.left,lt.element.scrollTop=lt.top}}mm=!!ay,oy=ay=null}finally{es=_,q.p=p,W.T=h}}o.current=l,xn=2}}function CS(){if(xn===2){xn=0;var o=sl,l=Wu,h=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||h){h=W.T,W.T=null;var p=q.p;q.p=2;var _=es;es|=4;try{iS(o,l.alternate,l)}finally{es=_,q.p=p,W.T=h}}xn=3}}function DS(){if(xn===4||xn===3){xn=0,St();var o=sl,l=Wu,h=po,p=pS;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?xn=5:(xn=0,Wu=sl=null,LS(o,o.pendingLanes));var _=o.pendingLanes;if(_===0&&(il=null),Gt(h),l=l.stateNode,Qt&&typeof Qt.onCommitFiberRoot=="function")try{Qt.onCommitFiberRoot(Ft,l,void 0,(l.current.flags&128)===128)}catch{}if(p!==null){l=W.T,_=q.p,q.p=2,W.T=null;try{for(var E=o.onRecoverableError,U=0;U<p.length;U++){var ee=p[U];E(ee.value,{componentStack:ee.stack})}}finally{W.T=l,q.p=_}}(po&3)!==0&&im(),Ia(o),_=o.pendingLanes,(h&261930)!==0&&(_&42)!==0?o===Kg?Ud++:(Ud=0,Kg=o):Ud=0,jd(0)}}function LS(o,l){(o.pooledCacheLanes&=l)===0&&(l=o.pooledCache,l!=null&&(o.pooledCache=null,ua(l)))}function im(){return kS(),CS(),DS(),RS()}function RS(){if(xn!==5)return!1;var o=sl,l=Gg;Gg=0;var h=Gt(po),p=W.T,_=q.p;try{q.p=32>h?32:h,W.T=null,h=qg,qg=null;var E=sl,U=po;if(xn=0,Wu=sl=null,po=0,(es&6)!==0)throw Error(i(331));var ee=es;if(es|=4,hS(E.current),uS(E,E.current,U,h),es=ee,jd(0,!1),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(Ft,E)}catch{}return!0}finally{q.p=_,W.T=p,LS(o,l)}}function IS(o,l,h){l=rr(h,l),l=wg(o.stateNode,l,2),o=Xo(o,l,2),o!==null&&(It(o,2),Ia(o))}function ls(o,l,h){if(o.tag===3)IS(o,o,h);else for(;l!==null;){if(l.tag===3){IS(l,o,h);break}else if(l.tag===1){var p=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(il===null||!il.has(p))){o=rr(h,o),h=NT(2),p=Xo(l,h,2),p!==null&&(OT(h,p,l,o),It(p,2),Ia(p));break}}l=l.return}}function Xg(o,l,h){var p=o.pingCache;if(p===null){p=o.pingCache=new hI;var _=new Set;p.set(l,_)}else _=p.get(l),_===void 0&&(_=new Set,p.set(l,_));_.has(h)||(Hg=!0,_.add(h),o=yI.bind(null,o,l,h),l.then(o,o))}function yI(o,l,h){var p=o.pingCache;p!==null&&p.delete(l),o.pingedLanes|=o.suspendedLanes&h,o.warmLanes&=~h,_s===o&&(Ui&h)===h&&(Ws===4||Ws===3&&(Ui&62914560)===Ui&&300>se()-Xf?(es&2)===0&&Yu(o,0):zg|=h,Ku===Ui&&(Ku=0)),Ia(o)}function NS(o,l){l===0&&(l=Be()),o=so(o,l),o!==null&&(It(o,l),Ia(o))}function vI(o){var l=o.memoizedState,h=0;l!==null&&(h=l.retryLane),NS(o,h)}function xI(o,l){var h=0;switch(o.tag){case 31:case 13:var p=o.stateNode,_=o.memoizedState;_!==null&&(h=_.retryLane);break;case 19:p=o.stateNode;break;case 22:p=o.stateNode._retryCache;break;default:throw Error(i(314))}p!==null&&p.delete(l),NS(o,h)}function bI(o,l){return ze(o,l)}var sm=null,Qu=null,Qg=!1,nm=!1,Zg=!1,rl=0;function Ia(o){o!==Qu&&o.next===null&&(Qu===null?sm=Qu=o:Qu=Qu.next=o),nm=!0,Qg||(Qg=!0,SI())}function jd(o,l){if(!Zg&&nm){Zg=!0;do for(var h=!1,p=sm;p!==null;){if(o!==0){var _=p.pendingLanes;if(_===0)var E=0;else{var U=p.suspendedLanes,ee=p.pingedLanes;E=(1<<31-Et(42|o)+1)-1,E&=_&~(U&~ee),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(h=!0,BS(p,E))}else E=Ui,E=$(p,p===_s?E:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(E&3)===0||ie(p,E)||(h=!0,BS(p,E));p=p.next}while(h);Zg=!1}}function TI(){OS()}function OS(){nm=Qg=!1;var o=0;rl!==0&&II()&&(o=rl);for(var l=se(),h=null,p=sm;p!==null;){var _=p.next,E=MS(p,l);E===0?(p.next=null,h===null?sm=_:h.next=_,_===null&&(Qu=h)):(h=p,(o!==0||(E&3)!==0)&&(nm=!0)),p=_}xn!==0&&xn!==5||jd(o),rl!==0&&(rl=0)}function MS(o,l){for(var h=o.suspendedLanes,p=o.pingedLanes,_=o.expirationTimes,E=o.pendingLanes&-62914561;0<E;){var U=31-Et(E),ee=1<<U,be=_[U];be===-1?((ee&h)===0||(ee&p)!==0)&&(_[U]=Te(ee,l)):be<=l&&(o.expiredLanes|=ee),E&=~ee}if(l=_s,h=Ui,h=$(o,o===l?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),p=o.callbackNode,h===0||o===l&&(os===2||os===9)||o.cancelPendingCommit!==null)return p!==null&&p!==null&&Ze(p),o.callbackNode=null,o.callbackPriority=0;if((h&3)===0||ie(o,h)){if(l=h&-h,l===o.callbackPriority)return l;switch(p!==null&&Ze(p),Gt(h)){case 2:case 8:h=Ue;break;case 32:h=at;break;case 268435456:h=wt;break;default:h=at}return p=PS.bind(null,o),h=ze(h,p),o.callbackPriority=l,o.callbackNode=h,l}return p!==null&&p!==null&&Ze(p),o.callbackPriority=2,o.callbackNode=null,2}function PS(o,l){if(xn!==0&&xn!==5)return o.callbackNode=null,o.callbackPriority=0,null;var h=o.callbackNode;if(im()&&o.callbackNode!==h)return null;var p=Ui;return p=$(o,o===_s?p:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),p===0?null:(yS(o,p,l),MS(o,se()),o.callbackNode!=null&&o.callbackNode===h?PS.bind(null,o):null)}function BS(o,l){if(im())return null;yS(o,l,!0)}function SI(){OI(function(){(es&6)!==0?ze(De,TI):OS()})}function Jg(){if(rl===0){var o=Gr;o===0&&(o=Jt,Jt<<=1,(Jt&261888)===0&&(Jt=256)),rl=o}return rl}function FS(o){return o==null||typeof o=="symbol"||typeof o=="boolean"?null:typeof o=="function"?o:en(""+o)}function US(o,l){var h=l.ownerDocument.createElement("input");return h.name=l.name,h.value=l.value,o.id&&h.setAttribute("form",o.id),l.parentNode.insertBefore(h,l),o=new FormData(o),h.parentNode.removeChild(h),o}function _I(o,l,h,p,_){if(l==="submit"&&h&&h.stateNode===_){var E=FS((_[Mt]||null).action),U=p.submitter;U&&(l=(l=U[Mt]||null)?FS(l.formAction):U.getAttribute("formAction"),l!==null&&(E=l,U=null));var ee=new Ht("action","action",null,p,_);o.push({event:ee,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(rl!==0){var be=U?US(_,U):new FormData(_);xg(h,{pending:!0,data:be,method:_.method,action:E},null,be)}}else typeof E=="function"&&(ee.preventDefault(),be=U?US(_,U):new FormData(_),xg(h,{pending:!0,data:be,method:_.method,action:E},E,be))},currentTarget:_}]})}}for(var ey=0;ey<md.length;ey++){var ty=md[ey],EI=ty.toLowerCase(),wI=ty[0].toUpperCase()+ty.slice(1);Ar(EI,"on"+wI)}Ar(vf,"onAnimationEnd"),Ar($o,"onAnimationIteration"),Ar(xf,"onAnimationStart"),Ar("dblclick","onDoubleClick"),Ar("focusin","onFocus"),Ar("focusout","onBlur"),Ar(bf,"onTransitionRun"),Ar(Tf,"onTransitionStart"),Ar(Yp,"onTransitionCancel"),Ar(Sf,"onTransitionEnd"),rs("onMouseEnter",["mouseout","mouseover"]),rs("onMouseLeave",["mouseout","mouseover"]),rs("onPointerEnter",["pointerout","pointerover"]),rs("onPointerLeave",["pointerout","pointerover"]),ns("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ns("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ns("onBeforeInput",["compositionend","keypress","textInput","paste"]),ns("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ns("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ns("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $d="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),AI=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($d));function jS(o,l){l=(l&4)!==0;for(var h=0;h<o.length;h++){var p=o[h],_=p.event;p=p.listeners;e:{var E=void 0;if(l)for(var U=p.length-1;0<=U;U--){var ee=p[U],be=ee.instance,Ke=ee.currentTarget;if(ee=ee.listener,be!==E&&_.isPropagationStopped())break e;E=ee,_.currentTarget=Ke;try{E(_)}catch(rt){Ho(rt)}_.currentTarget=null,E=be}else for(U=0;U<p.length;U++){if(ee=p[U],be=ee.instance,Ke=ee.currentTarget,ee=ee.listener,be!==E&&_.isPropagationStopped())break e;E=ee,_.currentTarget=Ke;try{E(_)}catch(rt){Ho(rt)}_.currentTarget=null,E=be}}}}function Mi(o,l){var h=l[Ci];h===void 0&&(h=l[Ci]=new Set);var p=o+"__bubble";h.has(p)||($S(l,o,2,!1),h.add(p))}function iy(o,l,h){var p=0;l&&(p|=4),$S(h,o,p,l)}var rm="_reactListening"+Math.random().toString(36).slice(2);function sy(o){if(!o[rm]){o[rm]=!0,$s.forEach(function(h){h!=="selectionchange"&&(AI.has(h)||iy(h,!1,o),iy(h,!0,o))});var l=o.nodeType===9?o:o.ownerDocument;l===null||l[rm]||(l[rm]=!0,iy("selectionchange",!1,l))}}function $S(o,l,h,p){switch(g_(l)){case 2:var _=eN;break;case 8:_=tN;break;default:_=vy}h=_.bind(null,l,h,o),_=void 0,!ne||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(_=!0),p?_!==void 0?o.addEventListener(l,h,{capture:!0,passive:_}):o.addEventListener(l,h,!0):_!==void 0?o.addEventListener(l,h,{passive:_}):o.addEventListener(l,h,!1)}function ny(o,l,h,p,_){var E=p;if((l&1)===0&&(l&2)===0&&p!==null)e:for(;;){if(p===null)return;var U=p.tag;if(U===3||U===4){var ee=p.stateNode.containerInfo;if(ee===_)break;if(U===4)for(U=p.return;U!==null;){var be=U.tag;if((be===3||be===4)&&U.stateNode.containerInfo===_)return;U=U.return}for(;ee!==null;){if(U=Zi(ee),U===null)return;if(be=U.tag,be===5||be===6||be===26||be===27){p=E=U;continue e}ee=ee.parentNode}}p=p.return}xe(function(){var Ke=E,rt=_n(h),ft=[];e:{var Ye=fd.get(o);if(Ye!==void 0){var tt=Ht,$t=o;switch(o){case"keypress":if(it(h)===0)break e;case"keydown":case"keyup":tt=af;break;case"focusin":$t="focus",tt=Ta;break;case"focusout":$t="blur",tt=Ta;break;case"beforeblur":case"afterblur":tt=Ta;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":tt=Ms;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":tt=ba;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":tt=eo;break;case vf:case $o:case xf:tt=Ol;break;case Sf:tt=of;break;case"scroll":case"scrollend":tt=gn;break;case"wheel":tt=uf;break;case"copy":case"cut":case"paste":tt=wr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":tt=Oo;break;case"toggle":case"beforetoggle":tt=jp}var li=(l&4)!==0,ps=!li&&(o==="scroll"||o==="scrollend"),Me=li?Ye!==null?Ye+"Capture":null:Ye;li=[];for(var Ae=Ke,qe;Ae!==null;){var lt=Ae;if(qe=lt.stateNode,lt=lt.tag,lt!==5&&lt!==26&&lt!==27||qe===null||Me===null||(lt=Oe(Ae,Me),lt!=null&&li.push(Hd(Ae,lt,qe))),ps)break;Ae=Ae.return}0<li.length&&(Ye=new tt(Ye,$t,null,h,rt),ft.push({event:Ye,listeners:li}))}}if((l&7)===0){e:{if(Ye=o==="mouseover"||o==="pointerover",tt=o==="mouseout"||o==="pointerout",Ye&&h!==Pn&&($t=h.relatedTarget||h.fromElement)&&(Zi($t)||$t[vt]))break e;if((tt||Ye)&&(Ye=rt.window===rt?rt:(Ye=rt.ownerDocument)?Ye.defaultView||Ye.parentWindow:window,tt?($t=h.relatedTarget||h.toElement,tt=Ke,$t=$t?Zi($t):null,$t!==null&&(ps=r($t),li=$t.tag,$t!==ps||li!==5&&li!==27&&li!==6)&&($t=null)):(tt=null,$t=Ke),tt!==$t)){if(li=Ms,lt="onMouseLeave",Me="onMouseEnter",Ae="mouse",(o==="pointerout"||o==="pointerover")&&(li=Oo,lt="onPointerLeave",Me="onPointerEnter",Ae="pointer"),ps=tt==null?Ye:$i(tt),qe=$t==null?Ye:$i($t),Ye=new li(lt,Ae+"leave",tt,h,rt),Ye.target=ps,Ye.relatedTarget=qe,lt=null,Zi(rt)===Ke&&(li=new li(Me,Ae+"enter",$t,h,rt),li.target=qe,li.relatedTarget=ps,lt=li),ps=lt,tt&&$t)t:{for(li=kI,Me=tt,Ae=$t,qe=0,lt=Me;lt;lt=li(lt))qe++;lt=0;for(var ti=Ae;ti;ti=li(ti))lt++;for(;0<qe-lt;)Me=li(Me),qe--;for(;0<lt-qe;)Ae=li(Ae),lt--;for(;qe--;){if(Me===Ae||Ae!==null&&Me===Ae.alternate){li=Me;break t}Me=li(Me),Ae=li(Ae)}li=null}else li=null;tt!==null&&HS(ft,Ye,tt,li,!1),$t!==null&&ps!==null&&HS(ft,ps,$t,li,!0)}}e:{if(Ye=Ke?$i(Ke):window,tt=Ye.nodeName&&Ye.nodeName.toLowerCase(),tt==="select"||tt==="input"&&Ye.type==="file")var Yi=rd;else if(nd(Ye))if(ad)Yi=Kp;else{Yi=qp;var zt=Gp}else tt=Ye.nodeName,!tt||tt.toLowerCase()!=="input"||Ye.type!=="checkbox"&&Ye.type!=="radio"?Ke&&un(Ke.elementType)&&(Yi=rd):Yi=yf;if(Yi&&(Yi=Yi(o,Ke))){mf(ft,Yi,h,rt);break e}zt&&zt(o,Ye,Ke),o==="focusout"&&Ke&&Ye.type==="number"&&Ke.memoizedProps.value!=null&&In(Ye,"number",Ye.value)}switch(zt=Ke?$i(Ke):window,o){case"focusin":(nd(zt)||zt.contentEditable==="true")&&(Uo=zt,cd=Ke,jo=null);break;case"focusout":jo=cd=Uo=null;break;case"mousedown":Nu=!0;break;case"contextmenu":case"mouseup":case"dragend":Nu=!1,dd(ft,h,rt);break;case"selectionchange":if(Wp)break;case"keydown":case"keyup":dd(ft,h,rt)}var Si;if(Mo)e:{switch(o){case"compositionstart":var ji="onCompositionStart";break e;case"compositionend":ji="onCompositionEnd";break e;case"compositionupdate":ji="onCompositionUpdate";break e}ji=void 0}else Po?Ru(o,h)&&(ji="onCompositionEnd"):o==="keydown"&&h.keyCode===229&&(ji="onCompositionStart");ji&&(df&&h.locale!=="ko"&&(Po||ji!=="onCompositionStart"?ji==="onCompositionEnd"&&Po&&(Si=xt()):(fe=rt,Ne="value"in fe?fe.value:fe.textContent,Po=!0)),zt=am(Ke,ji),0<zt.length&&(ji=new Ml(ji,o,null,h,rt),ft.push({event:ji,listeners:zt}),Si?ji.data=Si:(Si=ff(h),Si!==null&&(ji.data=Si)))),(Si=cf?Hp(o,h):sd(o,h))&&(ji=am(Ke,"onBeforeInput"),0<ji.length&&(zt=new Ml("onBeforeInput","beforeinput",null,h,rt),ft.push({event:zt,listeners:ji}),zt.data=Si)),_I(ft,o,Ke,h,rt)}jS(ft,l)})}function Hd(o,l,h){return{instance:o,listener:l,currentTarget:h}}function am(o,l){for(var h=l+"Capture",p=[];o!==null;){var _=o,E=_.stateNode;if(_=_.tag,_!==5&&_!==26&&_!==27||E===null||(_=Oe(o,h),_!=null&&p.unshift(Hd(o,_,E)),_=Oe(o,l),_!=null&&p.push(Hd(o,_,E))),o.tag===3)return p;o=o.return}return[]}function kI(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5&&o.tag!==27);return o||null}function HS(o,l,h,p,_){for(var E=l._reactName,U=[];h!==null&&h!==p;){var ee=h,be=ee.alternate,Ke=ee.stateNode;if(ee=ee.tag,be!==null&&be===p)break;ee!==5&&ee!==26&&ee!==27||Ke===null||(be=Ke,_?(Ke=Oe(h,E),Ke!=null&&U.unshift(Hd(h,Ke,be))):_||(Ke=Oe(h,E),Ke!=null&&U.push(Hd(h,Ke,be)))),h=h.return}U.length!==0&&o.push({event:l,listeners:U})}var CI=/\r\n?/g,DI=/\u0000|\uFFFD/g;function zS(o){return(typeof o=="string"?o:""+o).replace(CI,`
`).replace(DI,"")}function VS(o,l){return l=zS(l),zS(o)===l}function ms(o,l,h,p,_,E){switch(h){case"children":typeof p=="string"?l==="body"||l==="textarea"&&p===""||Zs(o,p):(typeof p=="number"||typeof p=="bigint")&&l!=="body"&&Zs(o,""+p);break;case"className":ds(o,"class",p);break;case"tabIndex":ds(o,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":ds(o,h,p);break;case"style":Is(o,p,E);break;case"data":if(l!=="object"){ds(o,"data",p);break}case"src":case"href":if(p===""&&(l!=="a"||h!=="href")){o.removeAttribute(h);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){o.removeAttribute(h);break}p=en(""+p),o.setAttribute(h,p);break;case"action":case"formAction":if(typeof p=="function"){o.setAttribute(h,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof E=="function"&&(h==="formAction"?(l!=="input"&&ms(o,l,"name",_.name,_,null),ms(o,l,"formEncType",_.formEncType,_,null),ms(o,l,"formMethod",_.formMethod,_,null),ms(o,l,"formTarget",_.formTarget,_,null)):(ms(o,l,"encType",_.encType,_,null),ms(o,l,"method",_.method,_,null),ms(o,l,"target",_.target,_,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){o.removeAttribute(h);break}p=en(""+p),o.setAttribute(h,p);break;case"onClick":p!=null&&(o.onclick=zi);break;case"onScroll":p!=null&&Mi("scroll",o);break;case"onScrollEnd":p!=null&&Mi("scrollend",o);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(i(61));if(h=p.__html,h!=null){if(_.children!=null)throw Error(i(60));o.innerHTML=h}}break;case"multiple":o.multiple=p&&typeof p!="function"&&typeof p!="symbol";break;case"muted":o.muted=p&&typeof p!="function"&&typeof p!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(p==null||typeof p=="function"||typeof p=="boolean"||typeof p=="symbol"){o.removeAttribute("xlink:href");break}h=en(""+p),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",h);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":p!=null&&typeof p!="function"&&typeof p!="symbol"?o.setAttribute(h,""+p):o.removeAttribute(h);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":p&&typeof p!="function"&&typeof p!="symbol"?o.setAttribute(h,""):o.removeAttribute(h);break;case"capture":case"download":p===!0?o.setAttribute(h,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?o.setAttribute(h,p):o.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?o.setAttribute(h,p):o.removeAttribute(h);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?o.removeAttribute(h):o.setAttribute(h,p);break;case"popover":Mi("beforetoggle",o),Mi("toggle",o),Kt(o,"popover",p);break;case"xlinkActuate":Fi(o,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":Fi(o,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":Fi(o,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":Fi(o,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":Fi(o,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":Fi(o,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":Fi(o,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":Fi(o,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":Fi(o,"http://www.w3.org/XML/1998/namespace","xml:space",p);break;case"is":Kt(o,"is",p);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=Mn.get(h)||h,Kt(o,h,p))}}function ry(o,l,h,p,_,E){switch(h){case"style":Is(o,p,E);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(i(61));if(h=p.__html,h!=null){if(_.children!=null)throw Error(i(60));o.innerHTML=h}}break;case"children":typeof p=="string"?Zs(o,p):(typeof p=="number"||typeof p=="bigint")&&Zs(o,""+p);break;case"onScroll":p!=null&&Mi("scroll",o);break;case"onScrollEnd":p!=null&&Mi("scrollend",o);break;case"onClick":p!=null&&(o.onclick=zi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Cs.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(_=h.endsWith("Capture"),l=h.slice(2,_?h.length-7:void 0),E=o[Mt]||null,E=E!=null?E[h]:null,typeof E=="function"&&o.removeEventListener(l,E,_),typeof p=="function")){typeof E!="function"&&E!==null&&(h in o?o[h]=null:o.hasAttribute(h)&&o.removeAttribute(h)),o.addEventListener(l,p,_);break e}h in o?o[h]=p:p===!0?o.setAttribute(h,""):Kt(o,h,p)}}}function Un(o,l,h){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Mi("error",o),Mi("load",o);var p=!1,_=!1,E;for(E in h)if(h.hasOwnProperty(E)){var U=h[E];if(U!=null)switch(E){case"src":p=!0;break;case"srcSet":_=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:ms(o,l,E,U,h,null)}}_&&ms(o,l,"srcSet",h.srcSet,h,null),p&&ms(o,l,"src",h.src,h,null);return;case"input":Mi("invalid",o);var ee=E=U=_=null,be=null,Ke=null;for(p in h)if(h.hasOwnProperty(p)){var rt=h[p];if(rt!=null)switch(p){case"name":_=rt;break;case"type":U=rt;break;case"checked":be=rt;break;case"defaultChecked":Ke=rt;break;case"value":E=rt;break;case"defaultValue":ee=rt;break;case"children":case"dangerouslySetInnerHTML":if(rt!=null)throw Error(i(137,l));break;default:ms(o,l,p,rt,h,null)}}Ts(o,E,ee,be,Ke,U,_,!1);return;case"select":Mi("invalid",o),p=U=E=null;for(_ in h)if(h.hasOwnProperty(_)&&(ee=h[_],ee!=null))switch(_){case"value":E=ee;break;case"defaultValue":U=ee;break;case"multiple":p=ee;default:ms(o,l,_,ee,h,null)}l=E,h=U,o.multiple=!!p,l!=null?Wi(o,!!p,l,!1):h!=null&&Wi(o,!!p,h,!0);return;case"textarea":Mi("invalid",o),E=_=p=null;for(U in h)if(h.hasOwnProperty(U)&&(ee=h[U],ee!=null))switch(U){case"value":p=ee;break;case"defaultValue":_=ee;break;case"children":E=ee;break;case"dangerouslySetInnerHTML":if(ee!=null)throw Error(i(91));break;default:ms(o,l,U,ee,h,null)}On(o,p,_,E);return;case"option":for(be in h)h.hasOwnProperty(be)&&(p=h[be],p!=null)&&(be==="selected"?o.selected=p&&typeof p!="function"&&typeof p!="symbol":ms(o,l,be,p,h,null));return;case"dialog":Mi("beforetoggle",o),Mi("toggle",o),Mi("cancel",o),Mi("close",o);break;case"iframe":case"object":Mi("load",o);break;case"video":case"audio":for(p=0;p<$d.length;p++)Mi($d[p],o);break;case"image":Mi("error",o),Mi("load",o);break;case"details":Mi("toggle",o);break;case"embed":case"source":case"link":Mi("error",o),Mi("load",o);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ke in h)if(h.hasOwnProperty(Ke)&&(p=h[Ke],p!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:ms(o,l,Ke,p,h,null)}return;default:if(un(l)){for(rt in h)h.hasOwnProperty(rt)&&(p=h[rt],p!==void 0&&ry(o,l,rt,p,h,void 0));return}}for(ee in h)h.hasOwnProperty(ee)&&(p=h[ee],p!=null&&ms(o,l,ee,p,h,null))}function LI(o,l,h,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var _=null,E=null,U=null,ee=null,be=null,Ke=null,rt=null;for(tt in h){var ft=h[tt];if(h.hasOwnProperty(tt)&&ft!=null)switch(tt){case"checked":break;case"value":break;case"defaultValue":be=ft;default:p.hasOwnProperty(tt)||ms(o,l,tt,null,p,ft)}}for(var Ye in p){var tt=p[Ye];if(ft=h[Ye],p.hasOwnProperty(Ye)&&(tt!=null||ft!=null))switch(Ye){case"type":E=tt;break;case"name":_=tt;break;case"checked":Ke=tt;break;case"defaultChecked":rt=tt;break;case"value":U=tt;break;case"defaultValue":ee=tt;break;case"children":case"dangerouslySetInnerHTML":if(tt!=null)throw Error(i(137,l));break;default:tt!==ft&&ms(o,l,Ye,tt,p,ft)}}Ki(o,U,ee,be,Ke,rt,E,_);return;case"select":tt=U=ee=Ye=null;for(E in h)if(be=h[E],h.hasOwnProperty(E)&&be!=null)switch(E){case"value":break;case"multiple":tt=be;default:p.hasOwnProperty(E)||ms(o,l,E,null,p,be)}for(_ in p)if(E=p[_],be=h[_],p.hasOwnProperty(_)&&(E!=null||be!=null))switch(_){case"value":Ye=E;break;case"defaultValue":ee=E;break;case"multiple":U=E;default:E!==be&&ms(o,l,_,E,p,be)}l=ee,h=U,p=tt,Ye!=null?Wi(o,!!h,Ye,!1):!!p!=!!h&&(l!=null?Wi(o,!!h,l,!0):Wi(o,!!h,h?[]:"",!1));return;case"textarea":tt=Ye=null;for(ee in h)if(_=h[ee],h.hasOwnProperty(ee)&&_!=null&&!p.hasOwnProperty(ee))switch(ee){case"value":break;case"children":break;default:ms(o,l,ee,null,p,_)}for(U in p)if(_=p[U],E=h[U],p.hasOwnProperty(U)&&(_!=null||E!=null))switch(U){case"value":Ye=_;break;case"defaultValue":tt=_;break;case"children":break;case"dangerouslySetInnerHTML":if(_!=null)throw Error(i(91));break;default:_!==E&&ms(o,l,U,_,p,E)}Nn(o,Ye,tt);return;case"option":for(var $t in h)Ye=h[$t],h.hasOwnProperty($t)&&Ye!=null&&!p.hasOwnProperty($t)&&($t==="selected"?o.selected=!1:ms(o,l,$t,null,p,Ye));for(be in p)Ye=p[be],tt=h[be],p.hasOwnProperty(be)&&Ye!==tt&&(Ye!=null||tt!=null)&&(be==="selected"?o.selected=Ye&&typeof Ye!="function"&&typeof Ye!="symbol":ms(o,l,be,Ye,p,tt));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var li in h)Ye=h[li],h.hasOwnProperty(li)&&Ye!=null&&!p.hasOwnProperty(li)&&ms(o,l,li,null,p,Ye);for(Ke in p)if(Ye=p[Ke],tt=h[Ke],p.hasOwnProperty(Ke)&&Ye!==tt&&(Ye!=null||tt!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":if(Ye!=null)throw Error(i(137,l));break;default:ms(o,l,Ke,Ye,p,tt)}return;default:if(un(l)){for(var ps in h)Ye=h[ps],h.hasOwnProperty(ps)&&Ye!==void 0&&!p.hasOwnProperty(ps)&&ry(o,l,ps,void 0,p,Ye);for(rt in p)Ye=p[rt],tt=h[rt],!p.hasOwnProperty(rt)||Ye===tt||Ye===void 0&&tt===void 0||ry(o,l,rt,Ye,p,tt);return}}for(var Me in h)Ye=h[Me],h.hasOwnProperty(Me)&&Ye!=null&&!p.hasOwnProperty(Me)&&ms(o,l,Me,null,p,Ye);for(ft in p)Ye=p[ft],tt=h[ft],!p.hasOwnProperty(ft)||Ye===tt||Ye==null&&tt==null||ms(o,l,ft,Ye,p,tt)}function GS(o){switch(o){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function RI(){if(typeof performance.getEntriesByType=="function"){for(var o=0,l=0,h=performance.getEntriesByType("resource"),p=0;p<h.length;p++){var _=h[p],E=_.transferSize,U=_.initiatorType,ee=_.duration;if(E&&ee&&GS(U)){for(U=0,ee=_.responseEnd,p+=1;p<h.length;p++){var be=h[p],Ke=be.startTime;if(Ke>ee)break;var rt=be.transferSize,ft=be.initiatorType;rt&&GS(ft)&&(be=be.responseEnd,U+=rt*(be<ee?1:(ee-Ke)/(be-Ke)))}if(--p,l+=8*(E+U)/(_.duration/1e3),o++,10<o)break}}if(0<o)return l/o/1e6}return navigator.connection&&(o=navigator.connection.downlink,typeof o=="number")?o:5}var ay=null,oy=null;function om(o){return o.nodeType===9?o:o.ownerDocument}function qS(o){switch(o){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function KS(o,l){if(o===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return o===1&&l==="foreignObject"?0:o}function ly(o,l){return o==="textarea"||o==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var uy=null;function II(){var o=window.event;return o&&o.type==="popstate"?o===uy?!1:(uy=o,!0):(uy=null,!1)}var WS=typeof setTimeout=="function"?setTimeout:void 0,NI=typeof clearTimeout=="function"?clearTimeout:void 0,YS=typeof Promise=="function"?Promise:void 0,OI=typeof queueMicrotask=="function"?queueMicrotask:typeof YS<"u"?function(o){return YS.resolve(null).then(o).catch(MI)}:WS;function MI(o){setTimeout(function(){throw o})}function al(o){return o==="head"}function XS(o,l){var h=l,p=0;do{var _=h.nextSibling;if(o.removeChild(h),_&&_.nodeType===8)if(h=_.data,h==="/$"||h==="/&"){if(p===0){o.removeChild(_),tc(l);return}p--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")p++;else if(h==="html")zd(o.ownerDocument.documentElement);else if(h==="head"){h=o.ownerDocument.head,zd(h);for(var E=h.firstChild;E;){var U=E.nextSibling,ee=E.nodeName;E[Gi]||ee==="SCRIPT"||ee==="STYLE"||ee==="LINK"&&E.rel.toLowerCase()==="stylesheet"||h.removeChild(E),E=U}}else h==="body"&&zd(o.ownerDocument.body);h=_}while(h);tc(l)}function QS(o,l){var h=o;o=0;do{var p=h.nextSibling;if(h.nodeType===1?l?(h._stashedDisplay=h.style.display,h.style.display="none"):(h.style.display=h._stashedDisplay||"",h.getAttribute("style")===""&&h.removeAttribute("style")):h.nodeType===3&&(l?(h._stashedText=h.nodeValue,h.nodeValue=""):h.nodeValue=h._stashedText||""),p&&p.nodeType===8)if(h=p.data,h==="/$"){if(o===0)break;o--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||o++;h=p}while(h)}function cy(o){var l=o.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var h=l;switch(l=l.nextSibling,h.nodeName){case"HTML":case"HEAD":case"BODY":cy(h),fi(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}o.removeChild(h)}}function PI(o,l,h,p){for(;o.nodeType===1;){var _=h;if(o.nodeName.toLowerCase()!==l.toLowerCase()){if(!p&&(o.nodeName!=="INPUT"||o.type!=="hidden"))break}else if(p){if(!o[Gi])switch(l){case"meta":if(!o.hasAttribute("itemprop"))break;return o;case"link":if(E=o.getAttribute("rel"),E==="stylesheet"&&o.hasAttribute("data-precedence"))break;if(E!==_.rel||o.getAttribute("href")!==(_.href==null||_.href===""?null:_.href)||o.getAttribute("crossorigin")!==(_.crossOrigin==null?null:_.crossOrigin)||o.getAttribute("title")!==(_.title==null?null:_.title))break;return o;case"style":if(o.hasAttribute("data-precedence"))break;return o;case"script":if(E=o.getAttribute("src"),(E!==(_.src==null?null:_.src)||o.getAttribute("type")!==(_.type==null?null:_.type)||o.getAttribute("crossorigin")!==(_.crossOrigin==null?null:_.crossOrigin))&&E&&o.hasAttribute("async")&&!o.hasAttribute("itemprop"))break;return o;default:return o}}else if(l==="input"&&o.type==="hidden"){var E=_.name==null?null:""+_.name;if(_.type==="hidden"&&o.getAttribute("name")===E)return o}else return o;if(o=Kr(o.nextSibling),o===null)break}return null}function BI(o,l,h){if(l==="")return null;for(;o.nodeType!==3;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!h||(o=Kr(o.nextSibling),o===null))return null;return o}function ZS(o,l){for(;o.nodeType!==8;)if((o.nodeType!==1||o.nodeName!=="INPUT"||o.type!=="hidden")&&!l||(o=Kr(o.nextSibling),o===null))return null;return o}function dy(o){return o.data==="$?"||o.data==="$~"}function hy(o){return o.data==="$!"||o.data==="$?"&&o.ownerDocument.readyState!=="loading"}function FI(o,l){var h=o.ownerDocument;if(o.data==="$~")o._reactRetry=l;else if(o.data!=="$?"||h.readyState!=="loading")l();else{var p=function(){l(),h.removeEventListener("DOMContentLoaded",p)};h.addEventListener("DOMContentLoaded",p),o._reactRetry=p}}function Kr(o){for(;o!=null;o=o.nextSibling){var l=o.nodeType;if(l===1||l===3)break;if(l===8){if(l=o.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return o}var fy=null;function JS(o){o=o.nextSibling;for(var l=0;o;){if(o.nodeType===8){var h=o.data;if(h==="/$"||h==="/&"){if(l===0)return Kr(o.nextSibling);l--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||l++}o=o.nextSibling}return null}function e_(o){o=o.previousSibling;for(var l=0;o;){if(o.nodeType===8){var h=o.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(l===0)return o;l--}else h!=="/$"&&h!=="/&"||l++}o=o.previousSibling}return null}function t_(o,l,h){switch(l=om(h),o){case"html":if(o=l.documentElement,!o)throw Error(i(452));return o;case"head":if(o=l.head,!o)throw Error(i(453));return o;case"body":if(o=l.body,!o)throw Error(i(454));return o;default:throw Error(i(451))}}function zd(o){for(var l=o.attributes;l.length;)o.removeAttributeNode(l[0]);fi(o)}var Wr=new Map,i_=new Set;function lm(o){return typeof o.getRootNode=="function"?o.getRootNode():o.nodeType===9?o:o.ownerDocument}var go=q.d;q.d={f:UI,r:jI,D:$I,C:HI,L:zI,m:VI,X:qI,S:GI,M:KI};function UI(){var o=go.f(),l=Jf();return o||l}function jI(o){var l=ts(o);l!==null&&l.tag===5&&l.type==="form"?xT(l):go.r(o)}var Zu=typeof document>"u"?null:document;function s_(o,l,h){var p=Zu;if(p&&typeof l=="string"&&l){var _=ei(l);_='link[rel="'+o+'"][href="'+_+'"]',typeof h=="string"&&(_+='[crossorigin="'+h+'"]'),i_.has(_)||(i_.add(_),o={rel:o,crossOrigin:h,href:l},p.querySelector(_)===null&&(l=p.createElement("link"),Un(l,"link",o),Di(l),p.head.appendChild(l)))}}function $I(o){go.D(o),s_("dns-prefetch",o,null)}function HI(o,l){go.C(o,l),s_("preconnect",o,l)}function zI(o,l,h){go.L(o,l,h);var p=Zu;if(p&&o&&l){var _='link[rel="preload"][as="'+ei(l)+'"]';l==="image"&&h&&h.imageSrcSet?(_+='[imagesrcset="'+ei(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(_+='[imagesizes="'+ei(h.imageSizes)+'"]')):_+='[href="'+ei(o)+'"]';var E=_;switch(l){case"style":E=Ju(o);break;case"script":E=ec(o)}Wr.has(E)||(o=g({rel:"preload",href:l==="image"&&h&&h.imageSrcSet?void 0:o,as:l},h),Wr.set(E,o),p.querySelector(_)!==null||l==="style"&&p.querySelector(Vd(E))||l==="script"&&p.querySelector(Gd(E))||(l=p.createElement("link"),Un(l,"link",o),Di(l),p.head.appendChild(l)))}}function VI(o,l){go.m(o,l);var h=Zu;if(h&&o){var p=l&&typeof l.as=="string"?l.as:"script",_='link[rel="modulepreload"][as="'+ei(p)+'"][href="'+ei(o)+'"]',E=_;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":E=ec(o)}if(!Wr.has(E)&&(o=g({rel:"modulepreload",href:o},l),Wr.set(E,o),h.querySelector(_)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(Gd(E)))return}p=h.createElement("link"),Un(p,"link",o),Di(p),h.head.appendChild(p)}}}function GI(o,l,h){go.S(o,l,h);var p=Zu;if(p&&o){var _=Ji(p).hoistableStyles,E=Ju(o);l=l||"default";var U=_.get(E);if(!U){var ee={loading:0,preload:null};if(U=p.querySelector(Vd(E)))ee.loading=5;else{o=g({rel:"stylesheet",href:o,"data-precedence":l},h),(h=Wr.get(E))&&my(o,h);var be=U=p.createElement("link");Di(be),Un(be,"link",o),be._p=new Promise(function(Ke,rt){be.onload=Ke,be.onerror=rt}),be.addEventListener("load",function(){ee.loading|=1}),be.addEventListener("error",function(){ee.loading|=2}),ee.loading|=4,um(U,l,p)}U={type:"stylesheet",instance:U,count:1,state:ee},_.set(E,U)}}}function qI(o,l){go.X(o,l);var h=Zu;if(h&&o){var p=Ji(h).hoistableScripts,_=ec(o),E=p.get(_);E||(E=h.querySelector(Gd(_)),E||(o=g({src:o,async:!0},l),(l=Wr.get(_))&&py(o,l),E=h.createElement("script"),Di(E),Un(E,"link",o),h.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},p.set(_,E))}}function KI(o,l){go.M(o,l);var h=Zu;if(h&&o){var p=Ji(h).hoistableScripts,_=ec(o),E=p.get(_);E||(E=h.querySelector(Gd(_)),E||(o=g({src:o,async:!0,type:"module"},l),(l=Wr.get(_))&&py(o,l),E=h.createElement("script"),Di(E),Un(E,"link",o),h.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},p.set(_,E))}}function n_(o,l,h,p){var _=(_=Pe.current)?lm(_):null;if(!_)throw Error(i(446));switch(o){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(l=Ju(h.href),h=Ji(_).hoistableStyles,p=h.get(l),p||(p={type:"style",instance:null,count:0,state:null},h.set(l,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){o=Ju(h.href);var E=Ji(_).hoistableStyles,U=E.get(o);if(U||(_=_.ownerDocument||_,U={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},E.set(o,U),(E=_.querySelector(Vd(o)))&&!E._p&&(U.instance=E,U.state.loading=5),Wr.has(o)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},Wr.set(o,h),E||WI(_,o,h,U.state))),l&&p===null)throw Error(i(528,""));return U}if(l&&p!==null)throw Error(i(529,""));return null;case"script":return l=h.async,h=h.src,typeof h=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ec(h),h=Ji(_).hoistableScripts,p=h.get(l),p||(p={type:"script",instance:null,count:0,state:null},h.set(l,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,o))}}function Ju(o){return'href="'+ei(o)+'"'}function Vd(o){return'link[rel="stylesheet"]['+o+"]"}function r_(o){return g({},o,{"data-precedence":o.precedence,precedence:null})}function WI(o,l,h,p){o.querySelector('link[rel="preload"][as="style"]['+l+"]")?p.loading=1:(l=o.createElement("link"),p.preload=l,l.addEventListener("load",function(){return p.loading|=1}),l.addEventListener("error",function(){return p.loading|=2}),Un(l,"link",h),Di(l),o.head.appendChild(l))}function ec(o){return'[src="'+ei(o)+'"]'}function Gd(o){return"script[async]"+o}function a_(o,l,h){if(l.count++,l.instance===null)switch(l.type){case"style":var p=o.querySelector('style[data-href~="'+ei(h.href)+'"]');if(p)return l.instance=p,Di(p),p;var _=g({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return p=(o.ownerDocument||o).createElement("style"),Di(p),Un(p,"style",_),um(p,h.precedence,o),l.instance=p;case"stylesheet":_=Ju(h.href);var E=o.querySelector(Vd(_));if(E)return l.state.loading|=4,l.instance=E,Di(E),E;p=r_(h),(_=Wr.get(_))&&my(p,_),E=(o.ownerDocument||o).createElement("link"),Di(E);var U=E;return U._p=new Promise(function(ee,be){U.onload=ee,U.onerror=be}),Un(E,"link",p),l.state.loading|=4,um(E,h.precedence,o),l.instance=E;case"script":return E=ec(h.src),(_=o.querySelector(Gd(E)))?(l.instance=_,Di(_),_):(p=h,(_=Wr.get(E))&&(p=g({},h),py(p,_)),o=o.ownerDocument||o,_=o.createElement("script"),Di(_),Un(_,"link",p),o.head.appendChild(_),l.instance=_);case"void":return null;default:throw Error(i(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(p=l.instance,l.state.loading|=4,um(p,h.precedence,o));return l.instance}function um(o,l,h){for(var p=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),_=p.length?p[p.length-1]:null,E=_,U=0;U<p.length;U++){var ee=p[U];if(ee.dataset.precedence===l)E=ee;else if(E!==_)break}E?E.parentNode.insertBefore(o,E.nextSibling):(l=h.nodeType===9?h.head:h,l.insertBefore(o,l.firstChild))}function my(o,l){o.crossOrigin==null&&(o.crossOrigin=l.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=l.referrerPolicy),o.title==null&&(o.title=l.title)}function py(o,l){o.crossOrigin==null&&(o.crossOrigin=l.crossOrigin),o.referrerPolicy==null&&(o.referrerPolicy=l.referrerPolicy),o.integrity==null&&(o.integrity=l.integrity)}var cm=null;function o_(o,l,h){if(cm===null){var p=new Map,_=cm=new Map;_.set(h,p)}else _=cm,p=_.get(h),p||(p=new Map,_.set(h,p));if(p.has(o))return p;for(p.set(o,null),h=h.getElementsByTagName(o),_=0;_<h.length;_++){var E=h[_];if(!(E[Gi]||E[qt]||o==="link"&&E.getAttribute("rel")==="stylesheet")&&E.namespaceURI!=="http://www.w3.org/2000/svg"){var U=E.getAttribute(l)||"";U=o+U;var ee=p.get(U);ee?ee.push(E):p.set(U,[E])}}return p}function l_(o,l,h){o=o.ownerDocument||o,o.head.insertBefore(h,l==="title"?o.querySelector("head > title"):null)}function YI(o,l,h){if(h===1||l.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(o=l.disabled,typeof l.precedence=="string"&&o==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function u_(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function XI(o,l,h,p){if(h.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var _=Ju(p.href),E=l.querySelector(Vd(_));if(E){l=E._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(o.count++,o=dm.bind(o),l.then(o,o)),h.state.loading|=4,h.instance=E,Di(E);return}E=l.ownerDocument||l,p=r_(p),(_=Wr.get(_))&&my(p,_),E=E.createElement("link"),Di(E);var U=E;U._p=new Promise(function(ee,be){U.onload=ee,U.onerror=be}),Un(E,"link",p),h.instance=E}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(h,l),(l=h.state.preload)&&(h.state.loading&3)===0&&(o.count++,h=dm.bind(o),l.addEventListener("load",h),l.addEventListener("error",h))}}var gy=0;function QI(o,l){return o.stylesheets&&o.count===0&&fm(o,o.stylesheets),0<o.count||0<o.imgCount?function(h){var p=setTimeout(function(){if(o.stylesheets&&fm(o,o.stylesheets),o.unsuspend){var E=o.unsuspend;o.unsuspend=null,E()}},6e4+l);0<o.imgBytes&&gy===0&&(gy=62500*RI());var _=setTimeout(function(){if(o.waitingForImages=!1,o.count===0&&(o.stylesheets&&fm(o,o.stylesheets),o.unsuspend)){var E=o.unsuspend;o.unsuspend=null,E()}},(o.imgBytes>gy?50:800)+l);return o.unsuspend=h,function(){o.unsuspend=null,clearTimeout(p),clearTimeout(_)}}:null}function dm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fm(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var hm=null;function fm(o,l){o.stylesheets=null,o.unsuspend!==null&&(o.count++,hm=new Map,l.forEach(ZI,o),hm=null,dm.call(o))}function ZI(o,l){if(!(l.state.loading&4)){var h=hm.get(o);if(h)var p=h.get(null);else{h=new Map,hm.set(o,h);for(var _=o.querySelectorAll("link[data-precedence],style[data-precedence]"),E=0;E<_.length;E++){var U=_[E];(U.nodeName==="LINK"||U.getAttribute("media")!=="not all")&&(h.set(U.dataset.precedence,U),p=U)}p&&h.set(null,p)}_=l.instance,U=_.getAttribute("data-precedence"),E=h.get(U)||p,E===p&&h.set(null,_),h.set(U,_),this.count++,p=dm.bind(this),_.addEventListener("load",p),_.addEventListener("error",p),E?E.parentNode.insertBefore(_,E.nextSibling):(o=o.nodeType===9?o.head:o,o.insertBefore(_,o.firstChild)),l.state.loading|=4}}var qd={$$typeof:I,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function JI(o,l,h,p,_,E,U,ee,be){this.tag=1,this.containerInfo=o,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ht(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ht(0),this.hiddenUpdates=ht(null),this.identifierPrefix=p,this.onUncaughtError=_,this.onCaughtError=E,this.onRecoverableError=U,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=be,this.incompleteTransitions=new Map}function c_(o,l,h,p,_,E,U,ee,be,Ke,rt,ft){return o=new JI(o,l,h,U,be,Ke,rt,ft,ee),l=1,E===!0&&(l|=24),E=qs(3,null,null,l),o.current=E,E.stateNode=o,l=no(),l.refCount++,o.pooledCache=l,l.refCount++,E.memoizedState={element:p,isDehydrated:h,cache:l},Jp(E),o}function d_(o){return o?(o=Vo,o):Vo}function h_(o,l,h,p,_,E){_=d_(_),p.context===null?p.context=_:p.pendingContext=_,p=Yo(l),p.payload={element:h},E=E===void 0?null:E,E!==null&&(p.callback=E),h=Xo(o,p,l),h!==null&&(fr(h,o,l),Ed(h,o,l))}function f_(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var h=o.retryLane;o.retryLane=h!==0&&h<l?h:l}}function yy(o,l){f_(o,l),(o=o.alternate)&&f_(o,l)}function m_(o){if(o.tag===13||o.tag===31){var l=so(o,67108864);l!==null&&fr(l,o,67108864),yy(o,67108864)}}function p_(o){if(o.tag===13||o.tag===31){var l=Ir();l=Bi(l);var h=so(o,l);h!==null&&fr(h,o,l),yy(o,l)}}var mm=!0;function eN(o,l,h,p){var _=W.T;W.T=null;var E=q.p;try{q.p=2,vy(o,l,h,p)}finally{q.p=E,W.T=_}}function tN(o,l,h,p){var _=W.T;W.T=null;var E=q.p;try{q.p=8,vy(o,l,h,p)}finally{q.p=E,W.T=_}}function vy(o,l,h,p){if(mm){var _=xy(p);if(_===null)ny(o,l,p,pm,h),y_(o,p);else if(sN(_,o,l,h,p))p.stopPropagation();else if(y_(o,p),l&4&&-1<iN.indexOf(o)){for(;_!==null;){var E=ts(_);if(E!==null)switch(E.tag){case 3:if(E=E.stateNode,E.current.memoizedState.isDehydrated){var U=V(E.pendingLanes);if(U!==0){var ee=E;for(ee.pendingLanes|=2,ee.entangledLanes|=2;U;){var be=1<<31-Et(U);ee.entanglements[1]|=be,U&=~be}Ia(E),(es&6)===0&&(Qf=se()+500,jd(0))}}break;case 31:case 13:ee=so(E,2),ee!==null&&fr(ee,E,2),Jf(),yy(E,2)}if(E=xy(p),E===null&&ny(o,l,p,pm,h),E===_)break;_=E}_!==null&&p.stopPropagation()}else ny(o,l,p,null,h)}}function xy(o){return o=_n(o),by(o)}var pm=null;function by(o){if(pm=null,o=Zi(o),o!==null){var l=r(o);if(l===null)o=null;else{var h=l.tag;if(h===13){if(o=a(l),o!==null)return o;o=null}else if(h===31){if(o=u(l),o!==null)return o;o=null}else if(h===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;o=null}else l!==o&&(o=null)}}return pm=o,null}function g_(o){switch(o){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ke()){case De:return 2;case Ue:return 8;case at:case dt:return 32;case wt:return 268435456;default:return 32}default:return 32}}var Ty=!1,ol=null,ll=null,ul=null,Kd=new Map,Wd=new Map,cl=[],iN="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function y_(o,l){switch(o){case"focusin":case"focusout":ol=null;break;case"dragenter":case"dragleave":ll=null;break;case"mouseover":case"mouseout":ul=null;break;case"pointerover":case"pointerout":Kd.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wd.delete(l.pointerId)}}function Yd(o,l,h,p,_,E){return o===null||o.nativeEvent!==E?(o={blockedOn:l,domEventName:h,eventSystemFlags:p,nativeEvent:E,targetContainers:[_]},l!==null&&(l=ts(l),l!==null&&m_(l)),o):(o.eventSystemFlags|=p,l=o.targetContainers,_!==null&&l.indexOf(_)===-1&&l.push(_),o)}function sN(o,l,h,p,_){switch(l){case"focusin":return ol=Yd(ol,o,l,h,p,_),!0;case"dragenter":return ll=Yd(ll,o,l,h,p,_),!0;case"mouseover":return ul=Yd(ul,o,l,h,p,_),!0;case"pointerover":var E=_.pointerId;return Kd.set(E,Yd(Kd.get(E)||null,o,l,h,p,_)),!0;case"gotpointercapture":return E=_.pointerId,Wd.set(E,Yd(Wd.get(E)||null,o,l,h,p,_)),!0}return!1}function v_(o){var l=Zi(o.target);if(l!==null){var h=r(l);if(h!==null){if(l=h.tag,l===13){if(l=a(h),l!==null){o.blockedOn=l,ai(o.priority,function(){p_(h)});return}}else if(l===31){if(l=u(h),l!==null){o.blockedOn=l,ai(o.priority,function(){p_(h)});return}}else if(l===3&&h.stateNode.current.memoizedState.isDehydrated){o.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}o.blockedOn=null}function gm(o){if(o.blockedOn!==null)return!1;for(var l=o.targetContainers;0<l.length;){var h=xy(o.nativeEvent);if(h===null){h=o.nativeEvent;var p=new h.constructor(h.type,h);Pn=p,h.target.dispatchEvent(p),Pn=null}else return l=ts(h),l!==null&&m_(l),o.blockedOn=h,!1;l.shift()}return!0}function x_(o,l,h){gm(o)&&h.delete(l)}function nN(){Ty=!1,ol!==null&&gm(ol)&&(ol=null),ll!==null&&gm(ll)&&(ll=null),ul!==null&&gm(ul)&&(ul=null),Kd.forEach(x_),Wd.forEach(x_)}function ym(o,l){o.blockedOn===l&&(o.blockedOn=null,Ty||(Ty=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,nN)))}var vm=null;function b_(o){vm!==o&&(vm=o,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){vm===o&&(vm=null);for(var l=0;l<o.length;l+=3){var h=o[l],p=o[l+1],_=o[l+2];if(typeof p!="function"){if(by(p||h)===null)continue;break}var E=ts(h);E!==null&&(o.splice(l,3),l-=3,xg(E,{pending:!0,data:_,method:h.method,action:p},p,_))}}))}function tc(o){function l(be){return ym(be,o)}ol!==null&&ym(ol,o),ll!==null&&ym(ll,o),ul!==null&&ym(ul,o),Kd.forEach(l),Wd.forEach(l);for(var h=0;h<cl.length;h++){var p=cl[h];p.blockedOn===o&&(p.blockedOn=null)}for(;0<cl.length&&(h=cl[0],h.blockedOn===null);)v_(h),h.blockedOn===null&&cl.shift();if(h=(o.ownerDocument||o).$$reactFormReplay,h!=null)for(p=0;p<h.length;p+=3){var _=h[p],E=h[p+1],U=_[Mt]||null;if(typeof E=="function")U||b_(h);else if(U){var ee=null;if(E&&E.hasAttribute("formAction")){if(_=E,U=E[Mt]||null)ee=U.formAction;else if(by(_)!==null)continue}else ee=U.action;typeof ee=="function"?h[p+1]=ee:(h.splice(p,3),p-=3),b_(h)}}}function T_(){function o(E){E.canIntercept&&E.info==="react-transition"&&E.intercept({handler:function(){return new Promise(function(U){return _=U})},focusReset:"manual",scroll:"manual"})}function l(){_!==null&&(_(),_=null),p||setTimeout(h,20)}function h(){if(!p&&!navigation.transition){var E=navigation.currentEntry;E&&E.url!=null&&navigation.navigate(E.url,{state:E.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var p=!1,_=null;return navigation.addEventListener("navigate",o),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(h,100),function(){p=!0,navigation.removeEventListener("navigate",o),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),_!==null&&(_(),_=null)}}}function Sy(o){this._internalRoot=o}xm.prototype.render=Sy.prototype.render=function(o){var l=this._internalRoot;if(l===null)throw Error(i(409));var h=l.current,p=Ir();h_(h,p,o,l,null,null)},xm.prototype.unmount=Sy.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var l=o.containerInfo;h_(o.current,2,null,o,null,null),Jf(),l[vt]=null}};function xm(o){this._internalRoot=o}xm.prototype.unstable_scheduleHydration=function(o){if(o){var l=xi();o={blockedOn:null,target:o,priority:l};for(var h=0;h<cl.length&&l!==0&&l<cl[h].priority;h++);cl.splice(h,0,o),h===0&&v_(o)}};var S_=e.version;if(S_!=="19.2.3")throw Error(i(527,S_,"19.2.3"));q.findDOMNode=function(o){var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(i(188)):(o=Object.keys(o).join(","),Error(i(268,o)));return o=d(l),o=o!==null?f(o):null,o=o===null?null:o.stateNode,o};var rN={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:W,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var bm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bm.isDisabled&&bm.supportsFiber)try{Ft=bm.inject(rN),Qt=bm}catch{}}return Qd.createRoot=function(o,l){if(!n(o))throw Error(i(299));var h=!1,p="",_=DT,E=LT,U=RT;return l!=null&&(l.unstable_strictMode===!0&&(h=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(_=l.onUncaughtError),l.onCaughtError!==void 0&&(E=l.onCaughtError),l.onRecoverableError!==void 0&&(U=l.onRecoverableError)),l=c_(o,1,!1,null,null,h,p,null,_,E,U,T_),o[vt]=l.current,sy(o),new Sy(l)},Qd.hydrateRoot=function(o,l,h){if(!n(o))throw Error(i(299));var p=!1,_="",E=DT,U=LT,ee=RT,be=null;return h!=null&&(h.unstable_strictMode===!0&&(p=!0),h.identifierPrefix!==void 0&&(_=h.identifierPrefix),h.onUncaughtError!==void 0&&(E=h.onUncaughtError),h.onCaughtError!==void 0&&(U=h.onCaughtError),h.onRecoverableError!==void 0&&(ee=h.onRecoverableError),h.formState!==void 0&&(be=h.formState)),l=c_(o,1,!0,l,h??null,p,_,be,E,U,ee,T_),l.context=d_(null),h=l.current,p=Ir(),p=Bi(p),_=Yo(p),_.callback=null,Xo(h,_,p),h=p,l.current.lanes=h,It(l,h),Ia(l),o[vt]=l.current,sy(o),new xm(l)},Qd.version="19.2.3",Qd}var N_;function gN(){if(N_)return wy.exports;N_=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),wy.exports=pN(),wy.exports}var IA=gN();function yN(...s){return s.filter(Boolean).join(" ")}const vN="inline-flex items-center justify-center font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",xN={sm:"rounded-sm",md:"rounded-md",full:"rounded-full"},bN={xs:"px-2 py-1 text-xs",sm:"px-2.5 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3.5 py-2.5 text-sm"},TN={indigo:{primary:"!bg-indigo-600 !text-white shadow-sm hover:!bg-indigo-700 focus-visible:outline-indigo-600 dark:!bg-indigo-500 dark:hover:!bg-indigo-400 dark:focus-visible:outline-indigo-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-indigo-50 text-indigo-600 shadow-xs hover:bg-indigo-100 dark:bg-indigo-500/20 dark:text-indigo-400 dark:shadow-none dark:hover:bg-indigo-500/30"},blue:{primary:"!bg-blue-600 !text-white shadow-sm hover:!bg-blue-700 focus-visible:outline-blue-600 dark:!bg-blue-500 dark:hover:!bg-blue-400 dark:focus-visible:outline-blue-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-blue-50 text-blue-600 shadow-xs hover:bg-blue-100 dark:bg-blue-500/20 dark:text-blue-400 dark:shadow-none dark:hover:bg-blue-500/30"},emerald:{primary:"!bg-emerald-600 !text-white shadow-sm hover:!bg-emerald-700 focus-visible:outline-emerald-600 dark:!bg-emerald-500 dark:hover:!bg-emerald-400 dark:focus-visible:outline-emerald-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-emerald-50 text-emerald-700 shadow-xs hover:bg-emerald-100 dark:bg-emerald-500/20 dark:text-emerald-400 dark:shadow-none dark:hover:bg-emerald-500/30"},red:{primary:"!bg-red-600 !text-white shadow-sm hover:!bg-red-700 focus-visible:outline-red-600 dark:!bg-red-500 dark:hover:!bg-red-400 dark:focus-visible:outline-red-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-red-50 text-red-700 shadow-xs hover:bg-red-100 dark:bg-red-500/20 dark:text-red-400 dark:shadow-none dark:hover:bg-red-500/30"},amber:{primary:"!bg-amber-500 !text-white shadow-sm hover:!bg-amber-600 focus-visible:outline-amber-500 dark:!bg-amber-500 dark:hover:!bg-amber-400 dark:focus-visible:outline-amber-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-amber-50 text-amber-800 shadow-xs hover:bg-amber-100 dark:bg-amber-500/20 dark:text-amber-300 dark:shadow-none dark:hover:bg-amber-500/30"}};function SN(){return m.jsxs("svg",{viewBox:"0 0 24 24",className:"size-4 animate-spin","aria-hidden":"true",children:[m.jsx("circle",{cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.25"}),m.jsx("path",{d:"M22 12a10 10 0 0 1-10 10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.9"})]})}function ri({children:s,variant:e="primary",color:t="indigo",size:i="md",rounded:n="md",leadingIcon:r,trailingIcon:a,isLoading:u=!1,disabled:c,className:d,type:f="button",...g}){const y=r||a||u?"gap-x-1.5":"";return m.jsxs("button",{type:f,disabled:c||u,className:yN(vN,xN[n],bN[i],TN[t][e],y,d),...g,children:[u?m.jsx("span",{className:"-ml-0.5",children:m.jsx(SN,{})}):r&&m.jsx("span",{className:"-ml-0.5",children:r}),m.jsx("span",{children:s}),a&&!u&&m.jsx("span",{className:"-mr-0.5",children:a})]})}function NA(s){var e,t,i="";if(typeof s=="string"||typeof s=="number")i+=s;else if(typeof s=="object")if(Array.isArray(s)){var n=s.length;for(e=0;e<n;e++)s[e]&&(t=NA(s[e]))&&(i&&(i+=" "),i+=t)}else for(t in s)s[t]&&(i&&(i+=" "),i+=t);return i}function ni(){for(var s,e,t=0,i="",n=arguments.length;t<n;t++)(s=arguments[t])&&(e=NA(s))&&(i&&(i+=" "),i+=e);return i}var Nc=RA(),_N=Object.defineProperty,EN=(s,e,t)=>e in s?_N(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Dy=(s,e,t)=>(EN(s,typeof e!="symbol"?e+"":e,t),t);let wN=class{constructor(){Dy(this,"current",this.detect()),Dy(this,"handoffState","pending"),Dy(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Ka=new wN;function Kh(s){var e;return Ka.isServer?null:s==null?document:(e=s?.ownerDocument)!=null?e:document}function sx(s){var e,t;return Ka.isServer?null:s==null?document:(t=(e=s?.getRootNode)==null?void 0:e.call(s))!=null?t:document}function OA(s){var e,t;return(t=(e=sx(s))==null?void 0:e.activeElement)!=null?t:null}function AN(s){return OA(s)===s}function ep(s){typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s).catch(e=>setTimeout(()=>{throw e}))}function Io(){let s=[],e={addEventListener(t,i,n,r){return t.addEventListener(i,n,r),e.add(()=>t.removeEventListener(i,n,r))},requestAnimationFrame(...t){let i=requestAnimationFrame(...t);return e.add(()=>cancelAnimationFrame(i))},nextFrame(...t){return e.requestAnimationFrame(()=>e.requestAnimationFrame(...t))},setTimeout(...t){let i=setTimeout(...t);return e.add(()=>clearTimeout(i))},microTask(...t){let i={current:!0};return ep(()=>{i.current&&t[0]()}),e.add(()=>{i.current=!1})},style(t,i,n){let r=t.style.getPropertyValue(i);return Object.assign(t.style,{[i]:n}),this.add(()=>{Object.assign(t.style,{[i]:r})})},group(t){let i=Io();return t(i),this.add(()=>i.dispose())},add(t){return s.includes(t)||s.push(t),()=>{let i=s.indexOf(t);if(i>=0)for(let n of s.splice(i,1))n()}},dispose(){for(let t of s.splice(0))t()}};return e}function tp(){let[s]=b.useState(Io);return b.useEffect(()=>()=>s.dispose(),[s]),s}let Tr=(s,e)=>{Ka.isServer?b.useEffect(s,e):b.useLayoutEffect(s,e)};function ku(s){let e=b.useRef(s);return Tr(()=>{e.current=s},[s]),e}let As=function(s){let e=ku(s);return ii.useCallback((...t)=>e.current(...t),[e])};function Wh(s){return b.useMemo(()=>s,Object.values(s))}let kN=b.createContext(void 0);function CN(){return b.useContext(kN)}function nx(...s){return Array.from(new Set(s.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function Lo(s,e,...t){if(s in e){let n=e[s];return typeof n=="function"?n(...t):n}let i=new Error(`Tried to handle "${s}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map(n=>`"${n}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(i,Lo),i}var f0=(s=>(s[s.None=0]="None",s[s.RenderStrategy=1]="RenderStrategy",s[s.Static=2]="Static",s))(f0||{}),El=(s=>(s[s.Unmount=0]="Unmount",s[s.Hidden=1]="Hidden",s))(El||{});function sa(){let s=LN();return b.useCallback(e=>DN({mergeRefs:s,...e}),[s])}function DN({ourProps:s,theirProps:e,slot:t,defaultTag:i,features:n,visible:r=!0,name:a,mergeRefs:u}){u=u??RN;let c=MA(e,s);if(r)return Tm(c,t,i,a,u);let d=n??0;if(d&2){let{static:f=!1,...g}=c;if(f)return Tm(g,t,i,a,u)}if(d&1){let{unmount:f=!0,...g}=c;return Lo(f?0:1,{0(){return null},1(){return Tm({...g,hidden:!0,style:{display:"none"}},t,i,a,u)}})}return Tm(c,t,i,a,u)}function Tm(s,e={},t,i,n){let{as:r=t,children:a,refName:u="ref",...c}=Ly(s,["unmount","static"]),d=s.ref!==void 0?{[u]:s.ref}:{},f=typeof a=="function"?a(e):a;"className"in c&&c.className&&typeof c.className=="function"&&(c.className=c.className(e)),c["aria-labelledby"]&&c["aria-labelledby"]===c.id&&(c["aria-labelledby"]=void 0);let g={};if(e){let y=!1,v=[];for(let[T,S]of Object.entries(e))typeof S=="boolean"&&(y=!0),S===!0&&v.push(T.replace(/([A-Z])/g,w=>`-${w.toLowerCase()}`));if(y){g["data-headlessui-state"]=v.join(" ");for(let T of v)g[`data-${T}`]=""}}if(yh(r)&&(Object.keys(au(c)).length>0||Object.keys(au(g)).length>0))if(!b.isValidElement(f)||Array.isArray(f)&&f.length>1||NN(f)){if(Object.keys(au(c)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${i} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(au(c)).concat(Object.keys(au(g))).map(y=>` - ${y}`).join(`
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(y=>` - ${y}`).join(`
`)].join(`
`))}else{let y=f.props,v=y?.className,T=typeof v=="function"?(...L)=>nx(v(...L),c.className):nx(v,c.className),S=T?{className:T}:{},w=MA(f.props,au(Ly(c,["ref"])));for(let L in g)L in w&&delete g[L];return b.cloneElement(f,Object.assign({},w,g,d,{ref:n(IN(f),d.ref)},S))}return b.createElement(r,Object.assign({},Ly(c,["ref"]),!yh(r)&&d,!yh(r)&&g),f)}function LN(){let s=b.useRef([]),e=b.useCallback(t=>{for(let i of s.current)i!=null&&(typeof i=="function"?i(t):i.current=t)},[]);return(...t)=>{if(!t.every(i=>i==null))return s.current=t,e}}function RN(...s){return s.every(e=>e==null)?void 0:e=>{for(let t of s)t!=null&&(typeof t=="function"?t(e):t.current=e)}}function MA(...s){if(s.length===0)return{};if(s.length===1)return s[0];let e={},t={};for(let i of s)for(let n in i)n.startsWith("on")&&typeof i[n]=="function"?(t[n]!=null||(t[n]=[]),t[n].push(i[n])):e[n]=i[n];if(e.disabled||e["aria-disabled"])for(let i in t)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(i)&&(t[i]=[n=>{var r;return(r=n?.preventDefault)==null?void 0:r.call(n)}]);for(let i in t)Object.assign(e,{[i](n,...r){let a=t[i];for(let u of a){if((n instanceof Event||n?.nativeEvent instanceof Event)&&n.defaultPrevented)return;u(n,...r)}}});return e}function _r(s){var e;return Object.assign(b.forwardRef(s),{displayName:(e=s.displayName)!=null?e:s.name})}function au(s){let e=Object.assign({},s);for(let t in e)e[t]===void 0&&delete e[t];return e}function Ly(s,e=[]){let t=Object.assign({},s);for(let i of e)i in t&&delete t[i];return t}function IN(s){return ii.version.split(".")[0]>="19"?s.props.ref:s.ref}function yh(s){return s===b.Fragment||s===Symbol.for("react.fragment")}function NN(s){return yh(s.type)}let ON="span";var m0=(s=>(s[s.None=1]="None",s[s.Focusable=2]="Focusable",s[s.Hidden=4]="Hidden",s))(m0||{});function MN(s,e){var t;let{features:i=1,...n}=s,r={ref:e,"aria-hidden":(i&2)===2?!0:(t=n["aria-hidden"])!=null?t:void 0,hidden:(i&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(i&4)===4&&(i&2)!==2&&{display:"none"}}};return sa()({ourProps:r,theirProps:n,slot:{},defaultTag:ON,name:"Hidden"})}let rx=_r(MN);function PN(s){return typeof s!="object"||s===null?!1:"nodeType"in s}function Al(s){return PN(s)&&"tagName"in s}function Tu(s){return Al(s)&&"accessKey"in s}function wl(s){return Al(s)&&"tabIndex"in s}function BN(s){return Al(s)&&"style"in s}function FN(s){return Tu(s)&&s.nodeName==="IFRAME"}function UN(s){return Tu(s)&&s.nodeName==="INPUT"}let PA=Symbol();function jN(s,e=!0){return Object.assign(s,{[PA]:e})}function Ja(...s){let e=b.useRef(s);b.useEffect(()=>{e.current=s},[s]);let t=As(i=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(i):n.current=i)});return s.every(i=>i==null||i?.[PA])?void 0:t}let ub=b.createContext(null);ub.displayName="DescriptionContext";function BA(){let s=b.useContext(ub);if(s===null){let e=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(e,BA),e}return s}function $N(){let[s,e]=b.useState([]);return[s.length>0?s.join(" "):void 0,b.useMemo(()=>function(t){let i=As(r=>(e(a=>[...a,r]),()=>e(a=>{let u=a.slice(),c=u.indexOf(r);return c!==-1&&u.splice(c,1),u}))),n=b.useMemo(()=>({register:i,slot:t.slot,name:t.name,props:t.props,value:t.value}),[i,t.slot,t.name,t.props,t.value]);return ii.createElement(ub.Provider,{value:n},t.children)},[e])]}let HN="p";function zN(s,e){let t=b.useId(),i=CN(),{id:n=`headlessui-description-${t}`,...r}=s,a=BA(),u=Ja(e);Tr(()=>a.register(n),[n,a.register]);let c=Wh({...a.slot,disabled:i||!1}),d={ref:u,...a.props,id:n};return sa()({ourProps:d,theirProps:r,slot:c,defaultTag:HN,name:a.name||"Description"})}let VN=_r(zN),GN=Object.assign(VN,{});var FA=(s=>(s.Space=" ",s.Enter="Enter",s.Escape="Escape",s.Backspace="Backspace",s.Delete="Delete",s.ArrowLeft="ArrowLeft",s.ArrowUp="ArrowUp",s.ArrowRight="ArrowRight",s.ArrowDown="ArrowDown",s.Home="Home",s.End="End",s.PageUp="PageUp",s.PageDown="PageDown",s.Tab="Tab",s))(FA||{});let qN=b.createContext(()=>{});function KN({value:s,children:e}){return ii.createElement(qN.Provider,{value:s},e)}let UA=class extends Map{constructor(e){super(),this.factory=e}get(e){let t=super.get(e);return t===void 0&&(t=this.factory(e),this.set(e,t)),t}};var WN=Object.defineProperty,YN=(s,e,t)=>e in s?WN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,XN=(s,e,t)=>(YN(s,e+"",t),t),jA=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Yr=(s,e,t)=>(jA(s,e,"read from private field"),t?t.call(s):e.get(s)),Ry=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},O_=(s,e,t,i)=>(jA(s,e,"write to private field"),e.set(s,t),t),Pa,uh,ch;let QN=class{constructor(e){Ry(this,Pa,{}),Ry(this,uh,new UA(()=>new Set)),Ry(this,ch,new Set),XN(this,"disposables",Io()),O_(this,Pa,e),Ka.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Yr(this,Pa)}subscribe(e,t){if(Ka.isServer)return()=>{};let i={selector:e,callback:t,current:e(Yr(this,Pa))};return Yr(this,ch).add(i),this.disposables.add(()=>{Yr(this,ch).delete(i)})}on(e,t){return Ka.isServer?()=>{}:(Yr(this,uh).get(e).add(t),this.disposables.add(()=>{Yr(this,uh).get(e).delete(t)}))}send(e){let t=this.reduce(Yr(this,Pa),e);if(t!==Yr(this,Pa)){O_(this,Pa,t);for(let i of Yr(this,ch)){let n=i.selector(Yr(this,Pa));$A(i.current,n)||(i.current=n,i.callback(n))}for(let i of Yr(this,uh).get(e.type))i(Yr(this,Pa),e)}}};Pa=new WeakMap,uh=new WeakMap,ch=new WeakMap;function $A(s,e){return Object.is(s,e)?!0:typeof s!="object"||s===null||typeof e!="object"||e===null?!1:Array.isArray(s)&&Array.isArray(e)?s.length!==e.length?!1:Iy(s[Symbol.iterator](),e[Symbol.iterator]()):s instanceof Map&&e instanceof Map||s instanceof Set&&e instanceof Set?s.size!==e.size?!1:Iy(s.entries(),e.entries()):M_(s)&&M_(e)?Iy(Object.entries(s)[Symbol.iterator](),Object.entries(e)[Symbol.iterator]()):!1}function Iy(s,e){do{let t=s.next(),i=e.next();if(t.done&&i.done)return!0;if(t.done||i.done||!Object.is(t.value,i.value))return!1}while(!0)}function M_(s){if(Object.prototype.toString.call(s)!=="[object Object]")return!1;let e=Object.getPrototypeOf(s);return e===null||Object.getPrototypeOf(e)===null}var ZN=Object.defineProperty,JN=(s,e,t)=>e in s?ZN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,P_=(s,e,t)=>(JN(s,typeof e!="symbol"?e+"":e,t),t),e5=(s=>(s[s.Push=0]="Push",s[s.Pop=1]="Pop",s))(e5||{});let t5={0(s,e){let t=e.id,i=s.stack,n=s.stack.indexOf(t);if(n!==-1){let r=s.stack.slice();return r.splice(n,1),r.push(t),i=r,{...s,stack:i}}return{...s,stack:[...s.stack,t]}},1(s,e){let t=e.id,i=s.stack.indexOf(t);if(i===-1)return s;let n=s.stack.slice();return n.splice(i,1),{...s,stack:n}}},i5=class HA extends QN{constructor(){super(...arguments),P_(this,"actions",{push:e=>this.send({type:0,id:e}),pop:e=>this.send({type:1,id:e})}),P_(this,"selectors",{isTop:(e,t)=>e.stack[e.stack.length-1]===t,inStack:(e,t)=>e.stack.includes(t)})}static new(){return new HA({stack:[]})}reduce(e,t){return Lo(t.type,t5,e,t)}};const zA=new UA(()=>i5.new());var Ny={exports:{}},Oy={};var B_;function s5(){if(B_)return Oy;B_=1;var s=J0();function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var t=typeof Object.is=="function"?Object.is:e,i=s.useSyncExternalStore,n=s.useRef,r=s.useEffect,a=s.useMemo,u=s.useDebugValue;return Oy.useSyncExternalStoreWithSelector=function(c,d,f,g,y){var v=n(null);if(v.current===null){var T={hasValue:!1,value:null};v.current=T}else T=v.current;v=a(function(){function w(P){if(!L){if(L=!0,O=P,P=g(P),y!==void 0&&T.hasValue){var G=T.value;if(y(G,P))return I=G}return I=P}if(G=I,t(O,P))return G;var N=g(P);return y!==void 0&&y(G,N)?(O=P,G):(O=P,I=N)}var L=!1,O,I,j=f===void 0?null:f;return[function(){return w(d())},j===null?void 0:function(){return w(j())}]},[d,f,g,y]);var S=i(c,v[0],v[1]);return r(function(){T.hasValue=!0,T.value=S},[S]),u(S),S},Oy}var F_;function n5(){return F_||(F_=1,Ny.exports=s5()),Ny.exports}var r5=n5();function VA(s,e,t=$A){return r5.useSyncExternalStoreWithSelector(As(i=>s.subscribe(a5,i)),As(()=>s.state),As(()=>s.state),As(e),t)}function a5(s){return s}function Yh(s,e){let t=b.useId(),i=zA.get(e),[n,r]=VA(i,b.useCallback(a=>[i.selectors.isTop(a,t),i.selectors.inStack(a,t)],[i,t]));return Tr(()=>{if(s)return i.actions.push(t),()=>i.actions.pop(t)},[i,s,t]),s?r?n:!0:!1}let ax=new Map,vh=new Map;function U_(s){var e;let t=(e=vh.get(s))!=null?e:0;return vh.set(s,t+1),t!==0?()=>j_(s):(ax.set(s,{"aria-hidden":s.getAttribute("aria-hidden"),inert:s.inert}),s.setAttribute("aria-hidden","true"),s.inert=!0,()=>j_(s))}function j_(s){var e;let t=(e=vh.get(s))!=null?e:1;if(t===1?vh.delete(s):vh.set(s,t-1),t!==1)return;let i=ax.get(s);i&&(i["aria-hidden"]===null?s.removeAttribute("aria-hidden"):s.setAttribute("aria-hidden",i["aria-hidden"]),s.inert=i.inert,ax.delete(s))}function o5(s,{allowed:e,disallowed:t}={}){let i=Yh(s,"inert-others");Tr(()=>{var n,r;if(!i)return;let a=Io();for(let c of(n=t?.())!=null?n:[])c&&a.add(U_(c));let u=(r=e?.())!=null?r:[];for(let c of u){if(!c)continue;let d=Kh(c);if(!d)continue;let f=c.parentElement;for(;f&&f!==d.body;){for(let g of f.children)u.some(y=>g.contains(y))||a.add(U_(g));f=f.parentElement}}return a.dispose},[i,e,t])}function l5(s,e,t){let i=ku(n=>{let r=n.getBoundingClientRect();r.x===0&&r.y===0&&r.width===0&&r.height===0&&t()});b.useEffect(()=>{if(!s)return;let n=e===null?null:Tu(e)?e:e.current;if(!n)return;let r=Io();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>i.current(n));a.observe(n),r.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>i.current(n));a.observe(n),r.add(()=>a.disconnect())}return()=>r.dispose()},[e,i,s])}let p0=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(s=>`${s}:not([tabindex='-1'])`).join(","),u5=["[data-autofocus]"].map(s=>`${s}:not([tabindex='-1'])`).join(",");var wo=(s=>(s[s.First=1]="First",s[s.Previous=2]="Previous",s[s.Next=4]="Next",s[s.Last=8]="Last",s[s.WrapAround=16]="WrapAround",s[s.NoScroll=32]="NoScroll",s[s.AutoFocus=64]="AutoFocus",s))(wo||{}),ox=(s=>(s[s.Error=0]="Error",s[s.Overflow=1]="Overflow",s[s.Success=2]="Success",s[s.Underflow=3]="Underflow",s))(ox||{}),c5=(s=>(s[s.Previous=-1]="Previous",s[s.Next=1]="Next",s))(c5||{});function d5(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(p0)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}function h5(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(u5)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var GA=(s=>(s[s.Strict=0]="Strict",s[s.Loose=1]="Loose",s))(GA||{});function f5(s,e=0){var t;return s===((t=Kh(s))==null?void 0:t.body)?!1:Lo(e,{0(){return s.matches(p0)},1(){let i=s;for(;i!==null;){if(i.matches(p0))return!0;i=i.parentElement}return!1}})}var m5=(s=>(s[s.Keyboard=0]="Keyboard",s[s.Mouse=1]="Mouse",s))(m5||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",s=>{s.metaKey||s.altKey||s.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",s=>{s.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:s.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Co(s){s?.focus({preventScroll:!0})}let p5=["textarea","input"].join(",");function g5(s){var e,t;return(t=(e=s?.matches)==null?void 0:e.call(s,p5))!=null?t:!1}function y5(s,e=t=>t){return s.slice().sort((t,i)=>{let n=e(t),r=e(i);if(n===null||r===null)return 0;let a=n.compareDocumentPosition(r);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function xh(s,e,{sorted:t=!0,relativeTo:i=null,skipElements:n=[]}={}){let r=Array.isArray(s)?s.length>0?sx(s[0]):document:sx(s),a=Array.isArray(s)?t?y5(s):s:e&64?h5(s):d5(s);n.length>0&&a.length>1&&(a=a.filter(v=>!n.some(T=>T!=null&&"current"in T?T?.current===v:T===v))),i=i??r?.activeElement;let u=(()=>{if(e&5)return 1;if(e&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=(()=>{if(e&1)return 0;if(e&2)return Math.max(0,a.indexOf(i))-1;if(e&4)return Math.max(0,a.indexOf(i))+1;if(e&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=e&32?{preventScroll:!0}:{},f=0,g=a.length,y;do{if(f>=g||f+g<=0)return 0;let v=c+f;if(e&16)v=(v+g)%g;else{if(v<0)return 3;if(v>=g)return 1}y=a[v],y?.focus(d),f+=u}while(y!==OA(y));return e&6&&g5(y)&&y.select(),2}function qA(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function v5(){return/Android/gi.test(window.navigator.userAgent)}function $_(){return qA()||v5()}function Sm(s,e,t,i){let n=ku(t);b.useEffect(()=>{if(!s)return;function r(a){n.current(a)}return document.addEventListener(e,r,i),()=>document.removeEventListener(e,r,i)},[s,e,i])}function KA(s,e,t,i){let n=ku(t);b.useEffect(()=>{if(!s)return;function r(a){n.current(a)}return window.addEventListener(e,r,i),()=>window.removeEventListener(e,r,i)},[s,e,i])}const H_=30;function x5(s,e,t){let i=ku(t),n=b.useCallback(function(u,c){if(u.defaultPrevented)return;let d=c(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let f=(function g(y){return typeof y=="function"?g(y()):Array.isArray(y)||y instanceof Set?y:[y]})(e);for(let g of f)if(g!==null&&(g.contains(d)||u.composed&&u.composedPath().includes(g)))return;return!f5(d,GA.Loose)&&d.tabIndex!==-1&&u.preventDefault(),i.current(u,d)},[i,e]),r=b.useRef(null);Sm(s,"pointerdown",u=>{var c,d;$_()||(r.current=((d=(c=u.composedPath)==null?void 0:c.call(u))==null?void 0:d[0])||u.target)},!0),Sm(s,"pointerup",u=>{if($_()||!r.current)return;let c=r.current;return r.current=null,n(u,()=>c)},!0);let a=b.useRef({x:0,y:0});Sm(s,"touchstart",u=>{a.current.x=u.touches[0].clientX,a.current.y=u.touches[0].clientY},!0),Sm(s,"touchend",u=>{let c={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(c.x-a.current.x)>=H_||Math.abs(c.y-a.current.y)>=H_))return n(u,()=>wl(u.target)?u.target:null)},!0),KA(s,"blur",u=>n(u,()=>FN(window.document.activeElement)?window.document.activeElement:null),!0)}function cb(...s){return b.useMemo(()=>Kh(...s),[...s])}function WA(s,e,t,i){let n=ku(t);b.useEffect(()=>{s=s??window;function r(a){n.current(a)}return s.addEventListener(e,r,i),()=>s.removeEventListener(e,r,i)},[s,e,i])}function b5(s){return b.useSyncExternalStore(s.subscribe,s.getSnapshot,s.getSnapshot)}function T5(s,e){let t=s(),i=new Set;return{getSnapshot(){return t},subscribe(n){return i.add(n),()=>i.delete(n)},dispatch(n,...r){let a=e[n].call(t,...r);a&&(t=a,i.forEach(u=>u()))}}}function S5(){let s;return{before({doc:e}){var t;let i=e.documentElement,n=(t=e.defaultView)!=null?t:window;s=Math.max(0,n.innerWidth-i.clientWidth)},after({doc:e,d:t}){let i=e.documentElement,n=Math.max(0,i.clientWidth-i.offsetWidth),r=Math.max(0,s-n);t.style(i,"paddingRight",`${r}px`)}}}function _5(){return qA()?{before({doc:s,d:e,meta:t}){function i(n){for(let r of t().containers)for(let a of r())if(a.contains(n))return!0;return!1}e.microTask(()=>{var n;if(window.getComputedStyle(s.documentElement).scrollBehavior!=="auto"){let u=Io();u.style(s.documentElement,"scrollBehavior","auto"),e.add(()=>e.microTask(()=>u.dispose()))}let r=(n=window.scrollY)!=null?n:window.pageYOffset,a=null;e.addEventListener(s,"click",u=>{if(wl(u.target))try{let c=u.target.closest("a");if(!c)return;let{hash:d}=new URL(c.href),f=s.querySelector(d);wl(f)&&!i(f)&&(a=f)}catch{}},!0),e.group(u=>{e.addEventListener(s,"touchstart",c=>{if(u.dispose(),wl(c.target)&&BN(c.target))if(i(c.target)){let d=c.target;for(;d.parentElement&&i(d.parentElement);)d=d.parentElement;u.style(d,"overscrollBehavior","contain")}else u.style(c.target,"touchAction","none")})}),e.addEventListener(s,"touchmove",u=>{if(wl(u.target)){if(UN(u.target))return;if(i(u.target)){let c=u.target;for(;c.parentElement&&c.dataset.headlessuiPortal!==""&&!(c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth);)c=c.parentElement;c.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),e.add(()=>{var u;let c=(u=window.scrollY)!=null?u:window.pageYOffset;r!==c&&window.scrollTo(0,r),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function E5(){return{before({doc:s,d:e}){e.style(s.documentElement,"overflow","hidden")}}}function z_(s){let e={};for(let t of s)Object.assign(e,t(e));return e}let hu=T5(()=>new Map,{PUSH(s,e){var t;let i=(t=this.get(s))!=null?t:{doc:s,count:0,d:Io(),meta:new Set,computedMeta:{}};return i.count++,i.meta.add(e),i.computedMeta=z_(i.meta),this.set(s,i),this},POP(s,e){let t=this.get(s);return t&&(t.count--,t.meta.delete(e),t.computedMeta=z_(t.meta)),this},SCROLL_PREVENT(s){let e={doc:s.doc,d:s.d,meta(){return s.computedMeta}},t=[_5(),S5(),E5()];t.forEach(({before:i})=>i?.(e)),t.forEach(({after:i})=>i?.(e))},SCROLL_ALLOW({d:s}){s.dispose()},TEARDOWN({doc:s}){this.delete(s)}});hu.subscribe(()=>{let s=hu.getSnapshot(),e=new Map;for(let[t]of s)e.set(t,t.documentElement.style.overflow);for(let t of s.values()){let i=e.get(t.doc)==="hidden",n=t.count!==0;(n&&!i||!n&&i)&&hu.dispatch(t.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",t),t.count===0&&hu.dispatch("TEARDOWN",t)}});function w5(s,e,t=()=>({containers:[]})){let i=b5(hu),n=e?i.get(e):void 0,r=n?n.count>0:!1;return Tr(()=>{if(!(!e||!s))return hu.dispatch("PUSH",e,t),()=>hu.dispatch("POP",e,t)},[s,e]),r}function A5(s,e,t=()=>[document.body]){let i=Yh(s,"scroll-lock");w5(i,e,n=>{var r;return{containers:[...(r=n.containers)!=null?r:[],t]}})}function k5(s=0){let[e,t]=b.useState(s),i=b.useCallback(c=>t(c),[]),n=b.useCallback(c=>t(d=>d|c),[]),r=b.useCallback(c=>(e&c)===c,[e]),a=b.useCallback(c=>t(d=>d&~c),[]),u=b.useCallback(c=>t(d=>d^c),[]);return{flags:e,setFlag:i,addFlag:n,hasFlag:r,removeFlag:a,toggleFlag:u}}var C5={},V_,G_;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((V_=process==null?void 0:C5)==null?void 0:V_.NODE_ENV)==="test"&&typeof((G_=Element?.prototype)==null?void 0:G_.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
`)),[]});var D5=(s=>(s[s.None=0]="None",s[s.Closed=1]="Closed",s[s.Enter=2]="Enter",s[s.Leave=4]="Leave",s))(D5||{});function L5(s){let e={};for(let t in s)s[t]===!0&&(e[`data-${t}`]="");return e}function R5(s,e,t,i){let[n,r]=b.useState(t),{hasFlag:a,addFlag:u,removeFlag:c}=k5(s&&n?3:0),d=b.useRef(!1),f=b.useRef(!1),g=tp();return Tr(()=>{var y;if(s){if(t&&r(!0),!e){t&&u(3);return}return(y=i?.start)==null||y.call(i,t),I5(e,{inFlight:d,prepare(){f.current?f.current=!1:f.current=d.current,d.current=!0,!f.current&&(t?(u(3),c(4)):(u(4),c(2)))},run(){f.current?t?(c(3),u(4)):(c(4),u(3)):t?c(1):u(1)},done(){var v;f.current&&M5(e)||(d.current=!1,c(7),t||r(!1),(v=i?.end)==null||v.call(i,t))}})}},[s,t,e,g]),s?[n,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[t,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function I5(s,{prepare:e,run:t,done:i,inFlight:n}){let r=Io();return O5(s,{prepare:e,inFlight:n}),r.nextFrame(()=>{t(),r.requestAnimationFrame(()=>{r.add(N5(s,i))})}),r.dispose}function N5(s,e){var t,i;let n=Io();if(!s)return n.dispose;let r=!1;n.add(()=>{r=!0});let a=(i=(t=s.getAnimations)==null?void 0:t.call(s).filter(u=>u instanceof CSSTransition))!=null?i:[];return a.length===0?(e(),n.dispose):(Promise.allSettled(a.map(u=>u.finished)).then(()=>{r||e()}),n.dispose)}function O5(s,{inFlight:e,prepare:t}){if(e!=null&&e.current){t();return}let i=s.style.transition;s.style.transition="none",t(),s.offsetHeight,s.style.transition=i}function M5(s){var e,t;return((t=(e=s.getAnimations)==null?void 0:e.call(s))!=null?t:[]).some(i=>i instanceof CSSTransition&&i.playState!=="finished")}function db(s,e){let t=b.useRef([]),i=As(s);b.useEffect(()=>{let n=[...t.current];for(let[r,a]of e.entries())if(t.current[r]!==a){let u=i(e,n);return t.current=e,u}},[i,...e])}let ip=b.createContext(null);ip.displayName="OpenClosedContext";var ma=(s=>(s[s.Open=1]="Open",s[s.Closed=2]="Closed",s[s.Closing=4]="Closing",s[s.Opening=8]="Opening",s))(ma||{});function sp(){return b.useContext(ip)}function P5({value:s,children:e}){return ii.createElement(ip.Provider,{value:s},e)}function B5({children:s}){return ii.createElement(ip.Provider,{value:null},s)}function F5(s){function e(){document.readyState!=="loading"&&(s(),document.removeEventListener("DOMContentLoaded",e))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",e),e())}let _l=[];F5(()=>{function s(e){if(!wl(e.target)||e.target===document.body||_l[0]===e.target)return;let t=e.target;t=t.closest(p0),_l.unshift(t??e.target),_l=_l.filter(i=>i!=null&&i.isConnected),_l.splice(10)}window.addEventListener("click",s,{capture:!0}),window.addEventListener("mousedown",s,{capture:!0}),window.addEventListener("focus",s,{capture:!0}),document.body.addEventListener("click",s,{capture:!0}),document.body.addEventListener("mousedown",s,{capture:!0}),document.body.addEventListener("focus",s,{capture:!0})});function YA(s){let e=As(s),t=b.useRef(!1);b.useEffect(()=>(t.current=!1,()=>{t.current=!0,ep(()=>{t.current&&e()})}),[e])}let XA=b.createContext(!1);function U5(){return b.useContext(XA)}function q_(s){return ii.createElement(XA.Provider,{value:s.force},s.children)}function j5(s){let e=U5(),t=b.useContext(ZA),[i,n]=b.useState(()=>{var r;if(!e&&t!==null)return(r=t.current)!=null?r:null;if(Ka.isServer)return null;let a=s?.getElementById("headlessui-portal-root");if(a)return a;if(s===null)return null;let u=s.createElement("div");return u.setAttribute("id","headlessui-portal-root"),s.body.appendChild(u)});return b.useEffect(()=>{i!==null&&(s!=null&&s.body.contains(i)||s==null||s.body.appendChild(i))},[i,s]),b.useEffect(()=>{e||t!==null&&n(t.current)},[t,n,e]),i}let QA=b.Fragment,$5=_r(function(s,e){let{ownerDocument:t=null,...i}=s,n=b.useRef(null),r=Ja(jN(y=>{n.current=y}),e),a=cb(n.current),u=t??a,c=j5(u),d=b.useContext(lx),f=tp(),g=sa();return YA(()=>{var y;c&&c.childNodes.length<=0&&((y=c.parentElement)==null||y.removeChild(c))}),c?Nc.createPortal(ii.createElement("div",{"data-headlessui-portal":"",ref:y=>{f.dispose(),d&&y&&f.add(d.register(y))}},g({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:QA,name:"Portal"})),c):null});function H5(s,e){let t=Ja(e),{enabled:i=!0,ownerDocument:n,...r}=s,a=sa();return i?ii.createElement($5,{...r,ownerDocument:n,ref:t}):a({ourProps:{ref:t},theirProps:r,slot:{},defaultTag:QA,name:"Portal"})}let z5=b.Fragment,ZA=b.createContext(null);function V5(s,e){let{target:t,...i}=s,n={ref:Ja(e)},r=sa();return ii.createElement(ZA.Provider,{value:t},r({ourProps:n,theirProps:i,defaultTag:z5,name:"Popover.Group"}))}let lx=b.createContext(null);function G5(){let s=b.useContext(lx),e=b.useRef([]),t=As(r=>(e.current.push(r),s&&s.register(r),()=>i(r))),i=As(r=>{let a=e.current.indexOf(r);a!==-1&&e.current.splice(a,1),s&&s.unregister(r)}),n=b.useMemo(()=>({register:t,unregister:i,portals:e}),[t,i,e]);return[e,b.useMemo(()=>function({children:r}){return ii.createElement(lx.Provider,{value:n},r)},[n])]}let q5=_r(H5),JA=_r(V5),K5=Object.assign(q5,{Group:JA});function W5(s,e=typeof document<"u"?document.defaultView:null,t){let i=Yh(s,"escape");WA(e,"keydown",n=>{i&&(n.defaultPrevented||n.key===FA.Escape&&t(n))})}function Y5(){var s;let[e]=b.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[t,i]=b.useState((s=e?.matches)!=null?s:!1);return Tr(()=>{if(!e)return;function n(r){i(r.matches)}return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[e]),t}function X5({defaultContainers:s=[],portals:e,mainTreeNode:t}={}){let i=As(()=>{var n,r;let a=Kh(t),u=[];for(let c of s)c!==null&&(Al(c)?u.push(c):"current"in c&&Al(c.current)&&u.push(c.current));if(e!=null&&e.current)for(let c of e.current)u.push(c);for(let c of(n=a?.querySelectorAll("html > *, body > *"))!=null?n:[])c!==document.body&&c!==document.head&&Al(c)&&c.id!=="headlessui-portal-root"&&(t&&(c.contains(t)||c.contains((r=t?.getRootNode())==null?void 0:r.host))||u.some(d=>c.contains(d))||u.push(c));return u});return{resolveContainers:i,contains:As(n=>i().some(r=>r.contains(n)))}}let ek=b.createContext(null);function K_({children:s,node:e}){let[t,i]=b.useState(null),n=tk(e??t);return ii.createElement(ek.Provider,{value:n},s,n===null&&ii.createElement(rx,{features:m0.Hidden,ref:r=>{var a,u;if(r){for(let c of(u=(a=Kh(r))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?u:[])if(c!==document.body&&c!==document.head&&Al(c)&&c!=null&&c.contains(r)){i(c);break}}}}))}function tk(s=null){var e;return(e=b.useContext(ek))!=null?e:s}function Q5(){let s=typeof document>"u";return"useSyncExternalStore"in k_?(e=>e.useSyncExternalStore)(k_)(()=>()=>{},()=>!1,()=>!s):!1}function np(){let s=Q5(),[e,t]=b.useState(Ka.isHandoffComplete);return e&&Ka.isHandoffComplete===!1&&t(!1),b.useEffect(()=>{e!==!0&&t(!0)},[e]),b.useEffect(()=>Ka.handoff(),[]),s?!1:e}function hb(){let s=b.useRef(!1);return Tr(()=>(s.current=!0,()=>{s.current=!1}),[]),s}var dh=(s=>(s[s.Forwards=0]="Forwards",s[s.Backwards=1]="Backwards",s))(dh||{});function Z5(){let s=b.useRef(0);return KA(!0,"keydown",e=>{e.key==="Tab"&&(s.current=e.shiftKey?1:0)},!0),s}function ik(s){if(!s)return new Set;if(typeof s=="function")return new Set(s());let e=new Set;for(let t of s.current)Al(t.current)&&e.add(t.current);return e}let J5="div";var cu=(s=>(s[s.None=0]="None",s[s.InitialFocus=1]="InitialFocus",s[s.TabLock=2]="TabLock",s[s.FocusLock=4]="FocusLock",s[s.RestoreFocus=8]="RestoreFocus",s[s.AutoFocus=16]="AutoFocus",s))(cu||{});function eO(s,e){let t=b.useRef(null),i=Ja(t,e),{initialFocus:n,initialFocusFallback:r,containers:a,features:u=15,...c}=s;np()||(u=0);let d=cb(t.current);nO(u,{ownerDocument:d});let f=rO(u,{ownerDocument:d,container:t,initialFocus:n,initialFocusFallback:r});aO(u,{ownerDocument:d,container:t,containers:a,previousActiveElement:f});let g=Z5(),y=As(O=>{if(!Tu(t.current))return;let I=t.current;(j=>j())(()=>{Lo(g.current,{[dh.Forwards]:()=>{xh(I,wo.First,{skipElements:[O.relatedTarget,r]})},[dh.Backwards]:()=>{xh(I,wo.Last,{skipElements:[O.relatedTarget,r]})}})})}),v=Yh(!!(u&2),"focus-trap#tab-lock"),T=tp(),S=b.useRef(!1),w={ref:i,onKeyDown(O){O.key=="Tab"&&(S.current=!0,T.requestAnimationFrame(()=>{S.current=!1}))},onBlur(O){if(!(u&4))return;let I=ik(a);Tu(t.current)&&I.add(t.current);let j=O.relatedTarget;wl(j)&&j.dataset.headlessuiFocusGuard!=="true"&&(sk(I,j)||(S.current?xh(t.current,Lo(g.current,{[dh.Forwards]:()=>wo.Next,[dh.Backwards]:()=>wo.Previous})|wo.WrapAround,{relativeTo:O.target}):wl(O.target)&&Co(O.target)))}},L=sa();return ii.createElement(ii.Fragment,null,v&&ii.createElement(rx,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:y,features:m0.Focusable}),L({ourProps:w,theirProps:c,defaultTag:J5,name:"FocusTrap"}),v&&ii.createElement(rx,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:y,features:m0.Focusable}))}let tO=_r(eO),iO=Object.assign(tO,{features:cu});function sO(s=!0){let e=b.useRef(_l.slice());return db(([t],[i])=>{i===!0&&t===!1&&ep(()=>{e.current.splice(0)}),i===!1&&t===!0&&(e.current=_l.slice())},[s,_l,e]),As(()=>{var t;return(t=e.current.find(i=>i!=null&&i.isConnected))!=null?t:null})}function nO(s,{ownerDocument:e}){let t=!!(s&8),i=sO(t);db(()=>{t||AN(e?.body)&&Co(i())},[t]),YA(()=>{t&&Co(i())})}function rO(s,{ownerDocument:e,container:t,initialFocus:i,initialFocusFallback:n}){let r=b.useRef(null),a=Yh(!!(s&1),"focus-trap#initial-focus"),u=hb();return db(()=>{if(s===0)return;if(!a){n!=null&&n.current&&Co(n.current);return}let c=t.current;c&&ep(()=>{if(!u.current)return;let d=e?.activeElement;if(i!=null&&i.current){if(i?.current===d){r.current=d;return}}else if(c.contains(d)){r.current=d;return}if(i!=null&&i.current)Co(i.current);else{if(s&16){if(xh(c,wo.First|wo.AutoFocus)!==ox.Error)return}else if(xh(c,wo.First)!==ox.Error)return;if(n!=null&&n.current&&(Co(n.current),e?.activeElement===n.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}r.current=e?.activeElement})},[n,a,s]),r}function aO(s,{ownerDocument:e,container:t,containers:i,previousActiveElement:n}){let r=hb(),a=!!(s&4);WA(e?.defaultView,"focus",u=>{if(!a||!r.current)return;let c=ik(i);Tu(t.current)&&c.add(t.current);let d=n.current;if(!d)return;let f=u.target;Tu(f)?sk(c,f)?(n.current=f,Co(f)):(u.preventDefault(),u.stopPropagation(),Co(d)):Co(n.current)},!0)}function sk(s,e){for(let t of s)if(t.contains(e))return!0;return!1}function nk(s){var e;return!!(s.enter||s.enterFrom||s.enterTo||s.leave||s.leaveFrom||s.leaveTo)||!yh((e=s.as)!=null?e:ak)||ii.Children.count(s.children)===1}let rp=b.createContext(null);rp.displayName="TransitionContext";var oO=(s=>(s.Visible="visible",s.Hidden="hidden",s))(oO||{});function lO(){let s=b.useContext(rp);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}function uO(){let s=b.useContext(ap);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}let ap=b.createContext(null);ap.displayName="NestingContext";function op(s){return"children"in s?op(s.children):s.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function rk(s,e){let t=ku(s),i=b.useRef([]),n=hb(),r=tp(),a=As((v,T=El.Hidden)=>{let S=i.current.findIndex(({el:w})=>w===v);S!==-1&&(Lo(T,{[El.Unmount](){i.current.splice(S,1)},[El.Hidden](){i.current[S].state="hidden"}}),r.microTask(()=>{var w;!op(i)&&n.current&&((w=t.current)==null||w.call(t))}))}),u=As(v=>{let T=i.current.find(({el:S})=>S===v);return T?T.state!=="visible"&&(T.state="visible"):i.current.push({el:v,state:"visible"}),()=>a(v,El.Unmount)}),c=b.useRef([]),d=b.useRef(Promise.resolve()),f=b.useRef({enter:[],leave:[]}),g=As((v,T,S)=>{c.current.splice(0),e&&(e.chains.current[T]=e.chains.current[T].filter(([w])=>w!==v)),e?.chains.current[T].push([v,new Promise(w=>{c.current.push(w)})]),e?.chains.current[T].push([v,new Promise(w=>{Promise.all(f.current[T].map(([L,O])=>O)).then(()=>w())})]),T==="enter"?d.current=d.current.then(()=>e?.wait.current).then(()=>S(T)):S(T)}),y=As((v,T,S)=>{Promise.all(f.current[T].splice(0).map(([w,L])=>L)).then(()=>{var w;(w=c.current.shift())==null||w()}).then(()=>S(T))});return b.useMemo(()=>({children:i,register:u,unregister:a,onStart:g,onStop:y,wait:d,chains:f}),[u,a,i,g,y,f,d])}let ak=b.Fragment,ok=f0.RenderStrategy;function cO(s,e){var t,i;let{transition:n=!0,beforeEnter:r,afterEnter:a,beforeLeave:u,afterLeave:c,enter:d,enterFrom:f,enterTo:g,entered:y,leave:v,leaveFrom:T,leaveTo:S,...w}=s,[L,O]=b.useState(null),I=b.useRef(null),j=nk(s),P=Ja(...j?[I,e,O]:e===null?[]:[e]),G=(t=w.unmount)==null||t?El.Unmount:El.Hidden,{show:N,appear:K,initial:k}=lO(),[R,Y]=b.useState(N?"visible":"hidden"),z=uO(),{register:X,unregister:re}=z;Tr(()=>X(I),[X,I]),Tr(()=>{if(G===El.Hidden&&I.current){if(N&&R!=="visible"){Y("visible");return}return Lo(R,{hidden:()=>re(I),visible:()=>X(I)})}},[R,I,X,re,N,G]);let J=np();Tr(()=>{if(j&&J&&R==="visible"&&I.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[I,R,J,j]);let W=k&&!K,q=K&&N&&k,Z=b.useRef(!1),te=rk(()=>{Z.current||(Y("hidden"),re(I))},z),oe=As(Je=>{Z.current=!0;let Se=Je?"enter":"leave";te.onStart(I,Se,Re=>{Re==="enter"?r?.():Re==="leave"&&u?.()})}),F=As(Je=>{let Se=Je?"enter":"leave";Z.current=!1,te.onStop(I,Se,Re=>{Re==="enter"?a?.():Re==="leave"&&c?.()}),Se==="leave"&&!op(te)&&(Y("hidden"),re(I))});b.useEffect(()=>{j&&n||(oe(N),F(N))},[N,j,n]);let le=!(!n||!j||!J||W),[,ge]=R5(le,L,N,{start:oe,end:F}),Ie=au({ref:P,className:((i=nx(w.className,q&&d,q&&f,ge.enter&&d,ge.enter&&ge.closed&&f,ge.enter&&!ge.closed&&g,ge.leave&&v,ge.leave&&!ge.closed&&T,ge.leave&&ge.closed&&S,!ge.transition&&N&&y))==null?void 0:i.trim())||void 0,...L5(ge)}),Le=0;R==="visible"&&(Le|=ma.Open),R==="hidden"&&(Le|=ma.Closed),N&&R==="hidden"&&(Le|=ma.Opening),!N&&R==="visible"&&(Le|=ma.Closing);let Pe=sa();return ii.createElement(ap.Provider,{value:te},ii.createElement(P5,{value:Le},Pe({ourProps:Ie,theirProps:w,defaultTag:ak,features:ok,visible:R==="visible",name:"Transition.Child"})))}function dO(s,e){let{show:t,appear:i=!1,unmount:n=!0,...r}=s,a=b.useRef(null),u=nk(s),c=Ja(...u?[a,e]:e===null?[]:[e]);np();let d=sp();if(t===void 0&&d!==null&&(t=(d&ma.Open)===ma.Open),t===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[f,g]=b.useState(t?"visible":"hidden"),y=rk(()=>{t||g("hidden")}),[v,T]=b.useState(!0),S=b.useRef([t]);Tr(()=>{v!==!1&&S.current[S.current.length-1]!==t&&(S.current.push(t),T(!1))},[S,t]);let w=b.useMemo(()=>({show:t,appear:i,initial:v}),[t,i,v]);Tr(()=>{t?g("visible"):!op(y)&&a.current!==null&&g("hidden")},[t,y]);let L={unmount:n},O=As(()=>{var P;v&&T(!1),(P=s.beforeEnter)==null||P.call(s)}),I=As(()=>{var P;v&&T(!1),(P=s.beforeLeave)==null||P.call(s)}),j=sa();return ii.createElement(ap.Provider,{value:y},ii.createElement(rp.Provider,{value:w},j({ourProps:{...L,as:b.Fragment,children:ii.createElement(lk,{ref:c,...L,...r,beforeEnter:O,beforeLeave:I})},theirProps:{},defaultTag:b.Fragment,features:ok,visible:f==="visible",name:"Transition"})))}function hO(s,e){let t=b.useContext(rp)!==null,i=sp()!==null;return ii.createElement(ii.Fragment,null,!t&&i?ii.createElement(ux,{ref:e,...s}):ii.createElement(lk,{ref:e,...s}))}let ux=_r(dO),lk=_r(cO),fb=_r(hO),bh=Object.assign(ux,{Child:fb,Root:ux});var fO=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(fO||{}),mO=(s=>(s[s.SetTitleId=0]="SetTitleId",s))(mO||{});let pO={0(s,e){return s.titleId===e.id?s:{...s,titleId:e.id}}},mb=b.createContext(null);mb.displayName="DialogContext";function lp(s){let e=b.useContext(mb);if(e===null){let t=new Error(`<${s} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,lp),t}return e}function gO(s,e){return Lo(e.type,pO,s,e)}let W_=_r(function(s,e){let t=b.useId(),{id:i=`headlessui-dialog-${t}`,open:n,onClose:r,initialFocus:a,role:u="dialog",autoFocus:c=!0,__demoMode:d=!1,unmount:f=!1,...g}=s,y=b.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(y.current||(y.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let v=sp();n===void 0&&v!==null&&(n=(v&ma.Open)===ma.Open);let T=b.useRef(null),S=Ja(T,e),w=cb(T.current),L=n?0:1,[O,I]=b.useReducer(gO,{titleId:null,descriptionId:null,panelRef:b.createRef()}),j=As(()=>r(!1)),P=As(ge=>I({type:0,id:ge})),G=np()?L===0:!1,[N,K]=G5(),k={get current(){var ge;return(ge=O.panelRef.current)!=null?ge:T.current}},R=tk(),{resolveContainers:Y}=X5({mainTreeNode:R,portals:N,defaultContainers:[k]}),z=v!==null?(v&ma.Closing)===ma.Closing:!1;o5(d||z?!1:G,{allowed:As(()=>{var ge,Ie;return[(Ie=(ge=T.current)==null?void 0:ge.closest("[data-headlessui-portal]"))!=null?Ie:null]}),disallowed:As(()=>{var ge;return[(ge=R?.closest("body > *:not(#headlessui-portal-root)"))!=null?ge:null]})});let X=zA.get(null);Tr(()=>{if(G)return X.actions.push(i),()=>X.actions.pop(i)},[X,i,G]);let re=VA(X,b.useCallback(ge=>X.selectors.isTop(ge,i),[X,i]));x5(re,Y,ge=>{ge.preventDefault(),j()}),W5(re,w?.defaultView,ge=>{ge.preventDefault(),ge.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),j()}),A5(d||z?!1:G,w,Y),l5(G,T,j);let[J,W]=$N(),q=b.useMemo(()=>[{dialogState:L,close:j,setTitleId:P,unmount:f},O],[L,j,P,f,O]),Z=Wh({open:L===0}),te={ref:S,id:i,role:u,tabIndex:-1,"aria-modal":d?void 0:L===0?!0:void 0,"aria-labelledby":O.titleId,"aria-describedby":J,unmount:f},oe=!Y5(),F=cu.None;G&&!d&&(F|=cu.RestoreFocus,F|=cu.TabLock,c&&(F|=cu.AutoFocus),oe&&(F|=cu.InitialFocus));let le=sa();return ii.createElement(B5,null,ii.createElement(q_,{force:!0},ii.createElement(K5,null,ii.createElement(mb.Provider,{value:q},ii.createElement(JA,{target:T},ii.createElement(q_,{force:!1},ii.createElement(W,{slot:Z},ii.createElement(K,null,ii.createElement(iO,{initialFocus:a,initialFocusFallback:T,containers:Y,features:F},ii.createElement(KN,{value:j},le({ourProps:te,theirProps:g,slot:Z,defaultTag:yO,features:vO,visible:L===0,name:"Dialog"})))))))))))}),yO="div",vO=f0.RenderStrategy|f0.Static;function xO(s,e){let{transition:t=!1,open:i,...n}=s,r=sp(),a=s.hasOwnProperty("open")||r!==null,u=s.hasOwnProperty("onClose");if(!a&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!a)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!r&&typeof s.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${s.open}`);if(typeof s.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${s.onClose}`);return(i!==void 0||t)&&!n.static?ii.createElement(K_,null,ii.createElement(bh,{show:i,transition:t,unmount:n.unmount},ii.createElement(W_,{ref:e,...n}))):ii.createElement(K_,null,ii.createElement(W_,{ref:e,open:i,...n}))}let bO="div";function TO(s,e){let t=b.useId(),{id:i=`headlessui-dialog-panel-${t}`,transition:n=!1,...r}=s,[{dialogState:a,unmount:u},c]=lp("Dialog.Panel"),d=Ja(e,c.panelRef),f=Wh({open:a===0}),g=As(w=>{w.stopPropagation()}),y={ref:d,id:i,onClick:g},v=n?fb:b.Fragment,T=n?{unmount:u}:{},S=sa();return ii.createElement(v,{...T},S({ourProps:y,theirProps:r,slot:f,defaultTag:bO,name:"Dialog.Panel"}))}let SO="div";function _O(s,e){let{transition:t=!1,...i}=s,[{dialogState:n,unmount:r}]=lp("Dialog.Backdrop"),a=Wh({open:n===0}),u={ref:e,"aria-hidden":!0},c=t?fb:b.Fragment,d=t?{unmount:r}:{},f=sa();return ii.createElement(c,{...d},f({ourProps:u,theirProps:i,slot:a,defaultTag:SO,name:"Dialog.Backdrop"}))}let EO="h2";function wO(s,e){let t=b.useId(),{id:i=`headlessui-dialog-title-${t}`,...n}=s,[{dialogState:r,setTitleId:a}]=lp("Dialog.Title"),u=Ja(e);b.useEffect(()=>(a(i),()=>a(null)),[i,a]);let c=Wh({open:r===0}),d={ref:u,id:i};return sa()({ourProps:d,theirProps:n,slot:c,defaultTag:EO,name:"Dialog.Title"})}let AO=_r(xO),kO=_r(TO);_r(_O);let CO=_r(wO),vc=Object.assign(AO,{Panel:kO,Title:CO,Description:GN});function DO({open:s,onClose:e,onApply:t,initialCookies:i}){const[n,r]=b.useState(""),[a,u]=b.useState(""),[c,d]=b.useState([]),f=b.useRef(!1);b.useEffect(()=>{s&&!f.current&&(r(""),u(""),d(i??[])),f.current=s},[s,i]);function g(){const T=n.trim(),S=a.trim();!T||!S||(d(w=>[...w.filter(O=>O.name!==T),{name:T,value:S}]),r(""),u(""))}function y(T){d(S=>S.filter(w=>w.name!==T))}function v(){t(c),e()}return m.jsxs(vc,{open:s,onClose:e,className:"relative z-50",children:[m.jsx("div",{className:"fixed inset-0 bg-black/40","aria-hidden":"true"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",children:m.jsxs(vc.Panel,{className:"w-full max-w-lg rounded-lg bg-white dark:bg-gray-800 p-6 shadow-xl dark:outline dark:-outline-offset-1 dark:outline-white/10",children:[m.jsx(vc.Title,{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Zusätzliche Cookies"}),m.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[m.jsx("input",{value:n,onChange:T=>r(T.target.value),placeholder:"Name (z. B. cf_clearance)",className:"col-span-1 truncate rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"}),m.jsx("input",{value:a,onChange:T=>u(T.target.value),placeholder:"Wert",className:"col-span-1 truncate sm:col-span-2 rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"})]}),m.jsx("div",{className:"mt-2",children:m.jsx(ri,{size:"sm",variant:"secondary",onClick:g,disabled:!n.trim()||!a.trim(),children:"Hinzufügen"})}),m.jsx("div",{className:"mt-4",children:c.length===0?m.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Noch keine Cookies hinzugefügt."}):m.jsxs("table",{className:"min-w-full text-sm border divide-y dark:divide-white/10",children:[m.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700/50",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Name"}),m.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Wert"}),m.jsx("th",{className:"px-3 py-2"})]})}),m.jsx("tbody",{className:"divide-y dark:divide-white/10",children:c.map(T=>m.jsxs("tr",{children:[m.jsx("td",{className:"px-3 py-2 font-mono",children:T.name}),m.jsx("td",{className:"px-3 py-2 truncate max-w-[240px]",children:T.value}),m.jsx("td",{className:"px-3 py-2 text-right",children:m.jsx("button",{onClick:()=>y(T.name),className:"text-xs text-red-600 hover:underline dark:text-red-400",children:"Entfernen"})})]},T.name))})]})}),m.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[m.jsx(ri,{variant:"secondary",onClick:e,children:"Abbrechen"}),m.jsx(ri,{variant:"primary",onClick:v,children:"Übernehmen"})]})]})})]})}function LO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const RO=b.forwardRef(LO);function cx({tabs:s,value:e,onChange:t,className:i,ariaLabel:n="Ansicht auswählen",variant:r="underline",hideCountUntilMd:a=!1}){if(!s?.length)return null;const u=s.find(y=>y.id===e)??s[0],c=ni("col-start-1 row-start-1 w-full appearance-none rounded-md bg-white py-2 pr-8 pl-3 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 dark:text-gray-100 dark:outline-white/10 dark:*:bg-gray-800 dark:focus:outline-indigo-500",r==="pillsBrand"?"dark:bg-gray-800/50":"dark:bg-white/5"),d=y=>ni(y?"bg-indigo-100 text-indigo-600 dark:bg-indigo-500/20 dark:text-indigo-400":"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-300",a?"ml-3 hidden rounded-full px-2.5 py-0.5 text-xs font-medium md:inline-block":"ml-3 rounded-full px-2.5 py-0.5 text-xs font-medium"),f=(y,v)=>v.count===void 0?null:m.jsx("span",{className:d(y),children:v.count}),g=()=>{switch(r){case"underline":case"underlineIcons":return m.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:m.jsx("nav",{"aria-label":n,className:"-mb-px flex space-x-8",children:s.map(y=>{const v=y.id===u.id,T=!!y.disabled;return m.jsxs("button",{type:"button",onClick:()=>!T&&t(y.id),disabled:T,"aria-current":v?"page":void 0,className:ni(v?"border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-white/20 dark:hover:text-gray-200",r==="underlineIcons"?"group inline-flex items-center border-b-2 px-1 py-4 text-sm font-medium":"flex items-center border-b-2 px-1 py-4 text-sm font-medium whitespace-nowrap",T&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[r==="underlineIcons"&&y.icon?m.jsx(y.icon,{"aria-hidden":"true",className:ni(v?"text-indigo-500 dark:text-indigo-400":"text-gray-400 group-hover:text-gray-500 dark:text-gray-500 dark:group-hover:text-gray-400","mr-2 -ml-0.5 size-5")}):null,m.jsx("span",{children:y.label}),f(v,y)]},y.id)})})});case"pills":case"pillsGray":case"pillsBrand":{const y=r==="pills"?"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-200":r==="pillsGray"?"bg-gray-200 text-gray-800 dark:bg-white/10 dark:text-white":"bg-indigo-100 text-indigo-700 dark:bg-indigo-500/20 dark:text-indigo-300",v=r==="pills"?"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200":r==="pillsGray"?"text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200";return m.jsx("nav",{"aria-label":n,className:"flex space-x-4",children:s.map(T=>{const S=T.id===u.id,w=!!T.disabled;return m.jsxs("button",{type:"button",onClick:()=>!w&&t(T.id),disabled:w,"aria-current":S?"page":void 0,className:ni(S?y:v,"inline-flex items-center rounded-md px-3 py-2 text-sm font-medium",w&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:[m.jsx("span",{children:T.label}),T.count!==void 0?m.jsx("span",{className:ni(S?"ml-2 bg-white/70 text-gray-900 dark:bg-white/10 dark:text-white":"ml-2 bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-300","rounded-full px-2 py-0.5 text-xs font-medium"),children:T.count}):null]},T.id)})})}case"fullWidthUnderline":return m.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:m.jsx("nav",{"aria-label":n,className:"-mb-px flex",children:s.map(y=>{const v=y.id===u.id,T=!!y.disabled;return m.jsx("button",{type:"button",onClick:()=>!T&&t(y.id),disabled:T,"aria-current":v?"page":void 0,className:ni(v?"border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-white/20 dark:hover:text-gray-300","flex-1 border-b-2 px-1 py-4 text-center text-sm font-medium",T&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:y.label},y.id)})})});case"barUnderline":return m.jsx("nav",{"aria-label":n,className:"isolate flex divide-x divide-gray-200 rounded-lg bg-white shadow-sm dark:divide-white/10 dark:bg-gray-800/50 dark:shadow-none dark:outline dark:-outline-offset-1 dark:outline-white/10",children:s.map((y,v)=>{const T=y.id===u.id,S=!!y.disabled;return m.jsxs("button",{type:"button",onClick:()=>!S&&t(y.id),disabled:S,"aria-current":T?"page":void 0,className:ni(T?"text-gray-900 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white",v===0?"rounded-l-lg":"",v===s.length-1?"rounded-r-lg":"","group relative min-w-0 flex-1 overflow-hidden px-4 py-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10 dark:hover:bg-white/5",S&&"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[m.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center justify-center",children:[m.jsx("span",{className:"min-w-0 truncate whitespace-nowrap",title:y.label,children:y.label}),y.count!==void 0?m.jsx("span",{className:"ml-2 shrink-0 tabular-nums min-w-[2.25rem] rounded-full bg-white/70 px-2 py-0.5 text-center text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-white",children:y.count}):null]}),m.jsx("span",{"aria-hidden":"true",className:ni(T?"bg-indigo-500 dark:bg-indigo-400":"bg-transparent","absolute inset-x-0 bottom-0 h-0.5")})]},y.id)})});case"simple":return m.jsx("nav",{className:"flex border-b border-gray-200 py-4 dark:border-white/10","aria-label":n,children:m.jsx("ul",{role:"list",className:"flex min-w-full flex-none gap-x-8 px-2 text-sm/6 font-semibold text-gray-500 dark:text-gray-400",children:s.map(y=>{const v=y.id===u.id,T=!!y.disabled;return m.jsx("li",{children:m.jsx("button",{type:"button",onClick:()=>!T&&t(y.id),disabled:T,"aria-current":v?"page":void 0,className:ni(v?"text-indigo-600 dark:text-indigo-400":"hover:text-gray-700 dark:hover:text-white",T&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:y.label})},y.id)})})});default:return null}};return m.jsxs("div",{className:i,children:[m.jsxs("div",{className:"grid grid-cols-1 sm:hidden",children:[m.jsx("select",{value:u.id,onChange:y=>t(y.target.value),"aria-label":n,className:c,children:s.map(y=>m.jsx("option",{value:y.id,children:y.label},y.id))}),m.jsx(RO,{"aria-hidden":"true",className:"pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end fill-gray-500 dark:fill-gray-400"})]}),m.jsx("div",{className:"hidden sm:block",children:g()})]})}function pa({header:s,footer:e,grayBody:t=!1,grayFooter:i=!1,edgeToEdgeMobile:n=!1,well:r=!1,noBodyPadding:a=!1,className:u,bodyClassName:c,children:d}){const f=r;return m.jsxs("div",{className:ni("overflow-hidden",n?"sm:rounded-lg":"rounded-lg",f?"bg-gray-50 dark:bg-gray-800 shadow-none":"bg-white shadow-sm dark:bg-gray-800 dark:shadow-none dark:outline dark:-outline-offset-1 dark:outline-white/10",u),children:[s&&m.jsx("div",{className:"shrink-0 px-4 py-5 sm:px-6 border-b border-gray-200 dark:border-white/10",children:s}),m.jsx("div",{className:ni("min-h-0",a?"p-0":"px-4 py-5 sm:p-6",t&&"bg-gray-50 dark:bg-gray-800",c),children:d}),e&&m.jsx("div",{className:ni("shrink-0 px-4 py-4 sm:px-6",i&&"bg-gray-50 dark:bg-gray-800/50","border-t border-gray-200 dark:border-white/10"),children:e})]})}function dx({checked:s,onChange:e,id:t,name:i,disabled:n,required:r,ariaLabel:a,ariaLabelledby:u,ariaDescribedby:c,size:d="default",variant:f="simple",className:g}){const y=T=>{n||e(T.target.checked)},v=ni("absolute inset-0 size-full appearance-none focus:outline-hidden",n&&"cursor-not-allowed");return d==="short"?m.jsxs("div",{className:ni("group relative inline-flex h-5 w-10 shrink-0 items-center justify-center rounded-full outline-offset-2 outline-indigo-600 has-focus-visible:outline-2 dark:outline-indigo-500",n&&"opacity-60",g),children:[m.jsx("span",{className:ni("absolute mx-auto h-4 w-9 rounded-full bg-gray-200 inset-ring inset-ring-gray-900/5 transition-colors duration-200 ease-in-out dark:bg-gray-800/50 dark:inset-ring-white/10",s&&"bg-indigo-600 dark:bg-indigo-500")}),m.jsx("span",{className:ni("absolute left-0 size-5 rounded-full border border-gray-300 bg-white shadow-xs transition-transform duration-200 ease-in-out dark:shadow-none",s&&"translate-x-5")}),m.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:y,disabled:n,required:r,"aria-label":a,"aria-labelledby":u,"aria-describedby":c,className:v})]}):m.jsxs("div",{className:ni("group relative inline-flex w-11 shrink-0 rounded-full bg-gray-200 p-0.5 inset-ring inset-ring-gray-900/5 outline-offset-2 outline-indigo-600 transition-colors duration-200 ease-in-out has-focus-visible:outline-2 dark:bg-white/5 dark:inset-ring-white/10 dark:outline-indigo-500",s&&"bg-indigo-600 dark:bg-indigo-500",n&&"opacity-60",g),children:[f==="icon"?m.jsxs("span",{className:ni("relative size-5 rounded-full bg-white shadow-xs ring-1 ring-gray-900/5 transition-transform duration-200 ease-in-out",s&&"translate-x-5"),children:[m.jsx("span",{"aria-hidden":"true",className:ni("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-in",s?"opacity-0 duration-100":"opacity-100 duration-200"),children:m.jsx("svg",{fill:"none",viewBox:"0 0 12 12",className:"size-3 text-gray-400 dark:text-gray-600",children:m.jsx("path",{d:"M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}),m.jsx("span",{"aria-hidden":"true",className:ni("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-out",s?"opacity-100 duration-200":"opacity-0 duration-100"),children:m.jsx("svg",{fill:"currentColor",viewBox:"0 0 12 12",className:"size-3 text-indigo-600 dark:text-indigo-500",children:m.jsx("path",{d:"M3.707 5.293a1 1 0 00-1.414 1.414l1.414-1.414zM5 8l-.707.707a1 1 0 001.414 0L5 8zm4.707-3.293a1 1 0 00-1.414-1.414l1.414 1.414zm-7.414 2l2 2 1.414-1.414-2-2-1.414 1.414zm3.414 2l4-4-1.414-1.414-4 4 1.414 1.414z"})})})]}):m.jsx("span",{className:ni("size-5 rounded-full bg-white shadow-xs ring-1 ring-gray-900/5 transition-transform duration-200 ease-in-out",s&&"translate-x-5")}),m.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:y,disabled:n,required:r,"aria-label":a,"aria-labelledby":u,"aria-describedby":c,className:v})]})}function To({label:s,description:e,labelPosition:t="left",id:i,className:n,...r}){const a=b.useId(),u=i??`sw-${a}`,c=`${u}-label`,d=`${u}-desc`;return t==="right"?m.jsxs("div",{className:ni("flex items-center justify-between gap-3",n),children:[m.jsx(dx,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0}),m.jsxs("div",{className:"text-sm",children:[m.jsx("label",{id:c,htmlFor:u,className:"font-medium text-gray-900 dark:text-white",children:s})," ",e?m.jsx("span",{id:d,className:"text-gray-500 dark:text-gray-400",children:e}):null]})]}):m.jsxs("div",{className:ni("flex items-center justify-between",n),children:[m.jsxs("span",{className:"flex grow flex-col",children:[m.jsx("label",{id:c,htmlFor:u,className:"text-sm/6 font-medium text-gray-900 dark:text-white",children:s}),e?m.jsx("span",{id:d,className:"text-sm text-gray-500 dark:text-gray-400",children:e}):null]}),m.jsx(dx,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0})]})}const Oc=new Map;let Y_=!1;function IO(){Y_||(Y_=!0,document.addEventListener("visibilitychange",()=>{if(document.hidden)for(const s of Oc.values())s.es&&(s.es.close(),s.es=null,s.dispatchers.clear());else for(const s of Oc.values())s.refs>0&&!s.es&&uk(s)}))}function uk(s){if(!s.es&&!document.hidden){s.es=new EventSource(s.url);for(const[e,t]of s.listeners.entries()){const i=n=>{let r=null;try{r=JSON.parse(String(n.data??"null"))}catch{return}for(const a of t)a(r)};s.dispatchers.set(e,i),s.es.addEventListener(e,i)}s.es.onerror=()=>{}}}function NO(s){s.es&&(s.es.close(),s.es=null,s.dispatchers.clear())}function OO(s){let e=Oc.get(s);return e||(e={url:s,es:null,refs:0,listeners:new Map,dispatchers:new Map},Oc.set(s,e)),e}function up(s,e,t){IO();const i=OO(s);let n=i.listeners.get(e);if(n||(n=new Set,i.listeners.set(e,n)),n.add(t),i.refs+=1,i.es){if(!i.dispatchers.has(e)){const r=a=>{let u=null;try{u=JSON.parse(String(a.data??"null"))}catch{return}for(const c of i.listeners.get(e)??[])c(u)};i.dispatchers.set(e,r),i.es.addEventListener(e,r)}}else uk(i);return()=>{const r=Oc.get(s);if(!r)return;const a=r.listeners.get(e);a&&(a.delete(t),a.size===0&&r.listeners.delete(e)),r.refs=Math.max(0,r.refs-1),r.refs===0&&(NO(r),Oc.delete(s))}}async function MO(s,e){const t=await fetch(s,{cache:"no-store",...e,headers:{"Content-Type":"application/json",...e?.headers||{}}});let i=null;try{i=await t.json()}catch{}if(!t.ok){const n=i&&(i.error||i.message)||t.statusText;throw new Error(n)}return i}function X_({startUrl:s,stopUrl:e,sseUrl:t,onTrigger:i,title:n="Task",description:r="Startet eine Hintergrundaufgabe. Fortschritt & Abbrechen oben in der Taskliste.",startLabel:a="Start",startingLabel:u="Starte…",disabled:c=!1,busy:d=!1,onFinished:f,onStart:g,onProgress:y,onDone:v,onCancelled:T,onError:S}){const[w,L]=b.useState(null),[O,I]=b.useState(!1),[j,P]=b.useState(null),G=b.useRef(null),N=b.useRef(!1),K=b.useRef(!1),k=b.useRef(!1),R=b.useRef(!1),Y=b.useRef(""),z=b.useRef(y),X=b.useRef(S);b.useEffect(()=>{z.current=y},[y]),b.useEffect(()=>{X.current=S},[S]);async function re(){if(e&&!k.current){k.current=!0;try{await fetch(e,{method:"DELETE",cache:"no-store"})}catch{}finally{k.current=!1}}}function J(){if(G.current)return G.current;const te=new AbortController;G.current=te;const oe=()=>{K.current=!0,re()};return te.signal.addEventListener("abort",oe,{once:!0}),te}function W(te){N.current||(N.current=!0,g?.(te))}b.useEffect(()=>{const te=R.current,oe=!!w?.running;if(R.current=oe,te&&!oe){const F=String(w?.error??"").trim();G.current=null,N.current=!1,K.current||F==="abgebrochen"?(K.current=!1,T?.()):F||v?.(),f?.()}},[w?.running,w?.error,f,v,T]),b.useEffect(()=>{if(!t)return;const te=up(t,"state",oe=>{if(L(oe),oe?.running){const le=J();W(le),z.current?.({done:oe?.done??0,total:oe?.total??0,currentFile:oe?.currentFile??""})}const F=String(oe?.error??"").trim();F&&F!=="abgebrochen"&&F!==Y.current&&(Y.current=F,X.current?.(F))});return()=>te()},[t]);async function q(){if(d||w?.running)return;if(P(null),I(!0),K.current=!1,Y.current="",i){try{await i()}catch(oe){const F=oe?.message??String(oe);P(F),S?.(F)}finally{I(!1)}return}if(!s){const oe="Task ist nicht konfiguriert (startUrl fehlt).";P(oe),S?.(oe),I(!1);return}const te=J();try{const oe=await MO(s,{method:"POST"});L(oe),W(te),oe?.running&&y?.({done:oe?.done??0,total:oe?.total??0,currentFile:oe?.currentFile??""})}catch(oe){G.current=null,N.current=!1;const F=oe?.message??String(oe);P(F),S?.(F)}finally{I(!1)}}const Z=!!w?.running;return m.jsxs("div",{className:"flex items-center justify-between gap-4",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n}),m.jsx("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:r}),j?m.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:j}):null]}),m.jsx("div",{className:"shrink-0",children:m.jsx(ri,{variant:"primary",onClick:q,disabled:c||d||O||Z,children:O||d?u:a})})]})}function PO(s,e){const t=Number(s??0),i=Number(e??0);return!i||i<=0?0:Math.max(0,Math.min(100,Math.round(t/i*100)))}function BO({tasks:s,onCancel:e}){const t=(s||[]).filter(i=>i.status!=="idle");return m.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-sm dark:border-white/10 dark:bg-gray-950/40",children:[m.jsx("div",{className:"flex items-start justify-between gap-3",children:m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Hintergrundaufgaben"}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Laufende Hintergrundaufgaben (z.B. Assets/Previews)."})]})}),m.jsxs("div",{className:"mt-3 space-y-3",children:[t.length===0?m.jsx("div",{className:"rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-600 dark:border-white/10 dark:bg-white/5 dark:text-gray-300",children:"Keine laufenden Aufgaben."}):null,t.map(i=>{const n=PO(i.done,i.total),r=i.status==="running",a=r&&(i.total??0)>0,u=(i.title??"").trim(),c=(i.text??"").trim();return m.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-white/5 transition-opacity duration-500 "+(i.fading?"opacity-0":"opacity-100"),children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"shrink-0",children:r&&i.cancellable&&e?m.jsx("button",{type:"button",onClick:()=>e?.(i.id),className:`inline-flex h-7 w-7 items-center justify-center rounded-md\r
text-red-700 hover:bg-red-50 hover:text-red-900\r
dark:text-red-300 dark:hover:bg-red-500/10 dark:hover:text-red-200`,title:"Abbrechen","aria-label":"Task abbrechen",children:"✕"}):i.status==="done"?m.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-green-700 dark:text-green-300",title:"Fertig","aria-label":"Fertig",children:"✓"}):m.jsx("span",{className:"inline-block h-7 w-7"})}),m.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[m.jsxs("div",{className:"min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-white",children:[u||"Aufgabe",c?m.jsxs("span",{className:"font-normal text-gray-600 dark:text-gray-300",children:[" · ",c]}):null]}),i.status==="done"?m.jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-semibold text-green-800 ring-1 ring-inset ring-green-200 dark:bg-green-500/20 dark:text-green-200 dark:ring-green-400/30",children:"fertig"}):i.status==="cancelled"?m.jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-semibold text-gray-700 ring-1 ring-inset ring-gray-200 dark:bg-white/10 dark:text-gray-200 dark:ring-white/10",children:"abgebrochen"}):i.status==="error"?m.jsx("span",{className:"shrink-0 inline-flex items-center rounded-full bg-red-100 px-2 py-0.5 text-[11px] font-semibold text-red-800 ring-1 ring-inset ring-red-200 dark:bg-red-500/20 dark:text-red-200 dark:ring-red-400/30",children:"fehler"}):null,m.jsx("div",{className:"flex-1"}),a?m.jsxs("div",{className:"shrink-0 flex items-center gap-3 text-xs text-gray-600 dark:text-gray-300",children:[m.jsxs("span",{className:"tabular-nums",children:[i.done??0,"/",i.total??0]}),m.jsxs("span",{className:"tabular-nums",children:[n,"%"]}),m.jsx("div",{className:"hidden sm:block h-2 w-40 overflow-hidden rounded-full bg-gray-200 dark:bg-white/10",children:m.jsx("div",{className:"h-full bg-indigo-500",style:{width:`${n}%`}})})]}):null]})]}),i.status==="error"&&i.err?m.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:i.err}):null]},i.id)})]})]})}const rn={recordDir:"records",doneDir:"records/done",ffmpegPath:"",autoAddToDownloadList:!0,useChaturbateApi:!1,useMyFreeCamsWatcher:!1,autoDeleteSmallDownloads:!0,autoDeleteSmallDownloadsBelowMB:200,blurPreviews:!1,teaserPlayback:"hover",teaserAudio:!1,lowDiskPauseBelowGB:5,enableNotifications:!0};function FO(s,e=52){const t=String(s??"").trim();return t?t.length<=e?t:"…"+t.slice(-(e-1)):""}function UO({onAssetsGenerated:s}){const[e,t]=b.useState(rn),[i,n]=b.useState(!1),[r,a]=b.useState(!1),[u,c]=b.useState(null),[d,f]=b.useState(null),[g,y]=b.useState(null),[v,T]=b.useState(null),S=b.useRef(null),[w,L]=b.useState({id:"generate-assets",status:"idle",title:"Assets generieren",text:"",cancellable:!0,fading:!1}),[O,I]=b.useState({id:"cleanup",status:"idle",title:"Aufräumen",text:"",cancellable:!1,fading:!1}),j=Number(e.lowDiskPauseBelowGB??rn.lowDiskPauseBelowGB??5),P=v?.pauseGB??j,G=v?.resumeGB??j+3;b.useEffect(()=>{let z=!0;return fetch("/api/settings",{cache:"no-store"}).then(async X=>{if(!X.ok)throw new Error(await X.text());return X.json()}).then(X=>{z&&t({recordDir:(X.recordDir||rn.recordDir).toString(),doneDir:(X.doneDir||rn.doneDir).toString(),ffmpegPath:String(X.ffmpegPath??rn.ffmpegPath??""),autoAddToDownloadList:X.autoAddToDownloadList??rn.autoAddToDownloadList,autoStartAddedDownloads:X.autoStartAddedDownloads??rn.autoStartAddedDownloads,useChaturbateApi:X.useChaturbateApi??rn.useChaturbateApi,useMyFreeCamsWatcher:X.useMyFreeCamsWatcher??rn.useMyFreeCamsWatcher,autoDeleteSmallDownloads:X.autoDeleteSmallDownloads??rn.autoDeleteSmallDownloads,autoDeleteSmallDownloadsBelowMB:X.autoDeleteSmallDownloadsBelowMB??rn.autoDeleteSmallDownloadsBelowMB,blurPreviews:X.blurPreviews??rn.blurPreviews,teaserPlayback:X.teaserPlayback??rn.teaserPlayback,teaserAudio:X.teaserAudio??rn.teaserAudio,lowDiskPauseBelowGB:X.lowDiskPauseBelowGB??rn.lowDiskPauseBelowGB,enableNotifications:X.enableNotifications??rn.enableNotifications})}).catch(()=>{}),()=>{z=!1}},[]),b.useEffect(()=>{let z=!0;const X=async()=>{try{const J=await fetch("/api/status/disk",{cache:"no-store"});if(!J.ok)return;const W=await J.json();z&&T(W)}catch{}};X();const re=window.setInterval(X,5e3);return()=>{z=!1,window.clearInterval(re)}},[]);async function N(z){y(null),f(null),c(z);try{window.focus();const X=await fetch(`/api/settings/browse?target=${z}`,{cache:"no-store"});if(X.status===204)return;if(!X.ok){const W=await X.text().catch(()=>"");throw new Error(W||`HTTP ${X.status}`)}const J=((await X.json()).path??"").trim();if(!J)return;t(W=>z==="record"?{...W,recordDir:J}:z==="done"?{...W,doneDir:J}:{...W,ffmpegPath:J})}catch(X){y(X?.message??String(X))}finally{c(null)}}async function K(){y(null),f(null);const z=e.recordDir.trim(),X=e.doneDir.trim(),re=(e.ffmpegPath??"").trim();if(!z||!X){y("Bitte Aufnahme-Ordner und Ziel-Ordner angeben.");return}const J=!!e.autoAddToDownloadList,W=J?!!e.autoStartAddedDownloads:!1,q=!!e.useChaturbateApi,Z=!!e.useMyFreeCamsWatcher,te=!!e.autoDeleteSmallDownloads,oe=Math.max(0,Math.min(1e5,Math.floor(Number(e.autoDeleteSmallDownloadsBelowMB??rn.autoDeleteSmallDownloadsBelowMB)))),F=!!e.blurPreviews,le=e.teaserPlayback==="still"||e.teaserPlayback==="all"||e.teaserPlayback==="hover"?e.teaserPlayback:rn.teaserPlayback,ge=!!e.teaserAudio,Ie=Math.max(1,Math.floor(Number(e.lowDiskPauseBelowGB??rn.lowDiskPauseBelowGB))),Le=!!e.enableNotifications;n(!0);try{const Pe=await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({recordDir:z,doneDir:X,ffmpegPath:re,autoAddToDownloadList:J,autoStartAddedDownloads:W,useChaturbateApi:q,useMyFreeCamsWatcher:Z,autoDeleteSmallDownloads:te,autoDeleteSmallDownloadsBelowMB:oe,blurPreviews:F,teaserPlayback:le,teaserAudio:ge,lowDiskPauseBelowGB:Ie,enableNotifications:Le})});if(!Pe.ok){const Je=await Pe.text().catch(()=>"");throw new Error(Je||`HTTP ${Pe.status}`)}f("✅ Gespeichert."),window.dispatchEvent(new CustomEvent("recorder-settings-updated"))}catch(Pe){y(Pe?.message??String(Pe))}finally{n(!1)}}function k(z,X=3500,re=500){window.setTimeout(()=>{z(J=>({...J,fading:!0})),window.setTimeout(()=>{z(J=>({...J,status:"idle",text:"",err:void 0,done:0,total:0,fading:!1}))},re)},X)}async function R(){y(null),f(null);const z=Number(e.autoDeleteSmallDownloadsBelowMB??rn.autoDeleteSmallDownloadsBelowMB??0),X=(e.doneDir||rn.doneDir).trim();if(!X){y("doneDir ist leer.");return}if(!z||z<=0){y("Mindestgröße ist 0 es würde nichts gelöscht.");return}if(window.confirm(`Aufräumen:
• Löscht Dateien in "${X}" < ${z} MB (Ordner "keep" wird übersprungen)
• Entfernt verwaiste Previews/Thumbs/Generated-Assets ohne passende Datei
Fortfahren?`)){a(!0),I(J=>({...J,status:"running",title:"Aufräumen",text:"Räume auf…",err:void 0,done:0,total:1,fading:!1}));try{const J=await fetch("/api/settings/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store"});if(!J.ok){const F=await J.text().catch(()=>"");throw new Error(F||`HTTP ${J.status}`)}const W=await J.json(),q=Number(W.scannedFiles??0),Z=Number(W.orphanIdsRemoved??0),te=Number(W.generatedOrphansRemoved??0),oe=Z+te;I(F=>({...F,status:"done",done:1,total:1,title:"Aufräumen",text:`geprüft: ${q} · Orphans: ${oe}`})),k(I)}catch(J){const W=J?.message??String(J);y(W),I(q=>({...q,status:"error",text:"Fehler beim Aufräumen.",err:W})),k(I)}finally{a(!1)}}}async function Y(){const z=S.current;if(S.current=null,L(X=>({...X,status:"cancelled",text:"Abgebrochen."})),z){z.abort();return}try{await fetch("/api/tasks/generate-assets",{method:"DELETE",cache:"no-store"})}catch{}}return m.jsx(pa,{header:m.jsxs("div",{className:"flex items-center justify-between gap-4",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Einstellungen"}),m.jsx("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:"Recorder-Konfiguration, Automatisierung und Tasks."})]}),m.jsx(ri,{variant:"primary",onClick:K,disabled:i,children:"Speichern"})]}),grayBody:!0,children:m.jsxs("div",{className:"space-y-4",children:[m.jsx(BO,{tasks:[w,O],onCancel:z=>{z==="generate-assets"&&Y()}}),g&&m.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",children:g}),d&&m.jsx("div",{className:"rounded-lg border border-green-200 bg-green-50 px-3 py-2 text-sm text-green-700 dark:border-green-500/30 dark:bg-green-500/10 dark:text-green-200",children:d}),m.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-sm dark:border-white/10 dark:bg-gray-950/40",children:[m.jsx("div",{className:"flex items-start justify-between gap-4",children:m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Aufgaben"}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Hintergrundaufgaben wie z.B. Asset/Preview-Generierung."})]})}),m.jsxs("div",{className:"mt-3 space-y-3",children:[m.jsx(X_,{title:"Assets-Generator",description:"Erzeugt fehlende Assets (thumb/preview/meta). Fortschritt & Abbrechen oben in der Taskliste.",startLabel:"Start",startingLabel:"Starte…",startUrl:"/api/tasks/generate-assets",stopUrl:"/api/tasks/generate-assets",sseUrl:"/api/tasks/assets/stream",onFinished:s,onStart:z=>{S.current=z,L(X=>({...X,status:"running",title:"Assets generieren",text:"",done:0,total:0,err:void 0,fading:!1}))},onProgress:z=>{const X=FO(z.currentFile);L(re=>({...re,status:"running",title:"Assets generieren",text:X||"",done:z.done,total:z.total}))},onDone:()=>{S.current=null,L(z=>({...z,status:"done",title:"Assets generieren"})),k(L)},onCancelled:()=>{S.current=null,L(z=>({...z,status:"cancelled",title:"Assets generieren",text:"Abgebrochen."})),k(L)},onError:z=>{S.current=null,L(X=>({...X,status:"error",title:"Assets generieren",text:"Fehler beim Generieren.",err:z})),k(L)}}),m.jsx(X_,{title:"Aufräumen",description:'Löscht Dateien im doneDir kleiner als die Mindestgröße (Ordner "keep" wird übersprungen) und entfernt verwaiste Assets.',startLabel:"Aufräumen",startingLabel:"Läuft…",onTrigger:R,busy:r,disabled:i||!e.autoDeleteSmallDownloads,onError:z=>{y(z)}})]})]}),m.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-sm dark:border-white/10 dark:bg-gray-950/40",children:[m.jsxs("div",{className:"mb-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Pfad-Einstellungen"}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Aufnahme- und Zielverzeichnisse sowie optionaler ffmpeg-Pfad."})]}),m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[m.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Aufnahme-Ordner"}),m.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[m.jsx("input",{value:e.recordDir,onChange:z=>t(X=>({...X,recordDir:z.target.value})),placeholder:"records (oder absolut: C:\\records / /mnt/data/records)",className:`min-w-0 flex-1 rounded-lg px-3 py-2 text-sm bg-white text-gray-900 ring-1 ring-gray-200
focus:outline-none focus:ring-2 focus:ring-indigo-500
dark:bg-white/10 dark:text-white dark:ring-white/10`}),m.jsx(ri,{variant:"secondary",onClick:()=>N("record"),disabled:i||u!==null,children:"Durchsuchen..."})]})]}),m.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[m.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Fertige Downloads nach"}),m.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[m.jsx("input",{value:e.doneDir,onChange:z=>t(X=>({...X,doneDir:z.target.value})),placeholder:"records/done",className:`min-w-0 flex-1 rounded-lg px-3 py-2 text-sm bg-white text-gray-900 ring-1 ring-gray-200
focus:outline-none focus:ring-2 focus:ring-indigo-500
dark:bg-white/10 dark:text-white dark:ring-white/10`}),m.jsx(ri,{variant:"secondary",onClick:()=>N("done"),disabled:i||u!==null,children:"Durchsuchen..."})]})]}),m.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[m.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"ffmpeg.exe"}),m.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[m.jsx("input",{value:e.ffmpegPath??"",onChange:z=>t(X=>({...X,ffmpegPath:z.target.value})),placeholder:"Leer = automatisch (FFMPEG_PATH / ffmpeg im PATH)",className:`min-w-0 flex-1 rounded-lg px-3 py-2 text-sm bg-white text-gray-900 ring-1 ring-gray-200
focus:outline-none focus:ring-2 focus:ring-indigo-500
dark:bg-white/10 dark:text-white dark:ring-white/10`}),m.jsx(ri,{variant:"secondary",onClick:()=>N("ffmpeg"),disabled:i||u!==null,children:"Durchsuchen..."})]})]})]})]}),m.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-sm dark:border-white/10 dark:bg-gray-950/40",children:[m.jsxs("div",{className:"mb-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Automatisierung & Anzeige"}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Verhalten beim Hinzufügen/Starten sowie Anzeigeoptionen."})]}),m.jsxs("div",{className:"space-y-3",children:[m.jsx(To,{checked:!!e.autoAddToDownloadList,onChange:z=>t(X=>({...X,autoAddToDownloadList:z,autoStartAddedDownloads:z?X.autoStartAddedDownloads:!1})),label:"Automatisch zur Downloadliste hinzufügen",description:"Neue Links/Modelle werden automatisch in die Downloadliste übernommen."}),m.jsx(To,{checked:!!e.autoStartAddedDownloads,onChange:z=>t(X=>({...X,autoStartAddedDownloads:z})),disabled:!e.autoAddToDownloadList,label:"Hinzugefügte Downloads automatisch starten",description:"Wenn ein Download hinzugefügt wurde, startet er direkt (sofern möglich)."}),m.jsx(To,{checked:!!e.useChaturbateApi,onChange:z=>t(X=>({...X,useChaturbateApi:z})),label:"Chaturbate API",description:"Wenn aktiv, pollt das Backend alle paar Sekunden die Online-Rooms API und cached die aktuell online Models."}),m.jsx(To,{checked:!!e.useMyFreeCamsWatcher,onChange:z=>t(X=>({...X,useMyFreeCamsWatcher:z})),label:"MyFreeCams Auto-Check (watched)",description:"Geht watched MyFreeCams-Models einzeln durch und startet einen Download. Wenn keine Output-Datei entsteht, ist der Stream nicht öffentlich (offline/away/private) und der Job wird wieder entfernt."}),m.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-white/10 dark:bg-white/5",children:[m.jsx(To,{checked:!!e.autoDeleteSmallDownloads,onChange:z=>t(X=>({...X,autoDeleteSmallDownloads:z,autoDeleteSmallDownloadsBelowMB:X.autoDeleteSmallDownloadsBelowMB??50})),label:"Kleine Downloads automatisch löschen",description:"Löscht fertige Downloads automatisch, wenn die Datei kleiner als die eingestellte Mindestgröße ist."}),m.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center "+(e.autoDeleteSmallDownloads?"":"opacity-50 pointer-events-none"),children:[m.jsxs("div",{className:"sm:col-span-4",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-200",children:"Mindestgröße"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Alles darunter wird gelöscht."})]}),m.jsx("div",{className:"sm:col-span-8",children:m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("input",{type:"number",min:0,step:1,value:e.autoDeleteSmallDownloadsBelowMB??50,onChange:z=>t(X=>({...X,autoDeleteSmallDownloadsBelowMB:Number(z.target.value||0)})),className:`h-9 w-32 rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900 shadow-sm
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100`}),m.jsx("span",{className:"shrink-0 text-xs text-gray-600 dark:text-gray-300",children:"MB"})]})})]})]}),m.jsx(To,{checked:!!e.blurPreviews,onChange:z=>t(X=>({...X,blurPreviews:z})),label:"Vorschaubilder blurren",description:"Weichzeichnet Vorschaubilder/Teaser (praktisch auf mobilen Geräten oder im öffentlichen Umfeld)."}),m.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[m.jsxs("div",{className:"sm:col-span-4",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-200",children:"Teaser abspielen"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Standbild spart Leistung. „Bei Hover (Standard)“: Desktop spielt bei Hover ab, Mobile im Viewport. „Alle“ kann viel CPU ziehen."})]}),m.jsxs("div",{className:"sm:col-span-8",children:[m.jsx("label",{className:"sr-only",htmlFor:"teaserPlayback",children:"Teaser abspielen"}),m.jsxs("select",{id:"teaserPlayback",value:e.teaserPlayback??"hover",onChange:z=>t(X=>({...X,teaserPlayback:z.target.value})),className:`h-9 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900 shadow-sm
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:[color-scheme:dark]`,children:[m.jsx("option",{value:"still",children:"Standbild"}),m.jsx("option",{value:"hover",children:"Bei Hover (Standard)"}),m.jsx("option",{value:"all",children:"Alle"})]})]})]}),m.jsx(To,{checked:!!e.teaserAudio,onChange:z=>t(X=>({...X,teaserAudio:z})),label:"Teaser mit Ton",description:"Wenn aktiv, werden Vorschau/Teaser nicht stumm geschaltet."}),m.jsx(To,{checked:!!e.enableNotifications,onChange:z=>t(X=>({...X,enableNotifications:z})),label:"Benachrichtigungen",description:"Wenn aktiv, zeigt das Frontend Toasts (z.B. wenn watched Models online/live gehen oder wenn ein queued Model wieder public wird)."}),m.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Speicherplatz-Notbremse"}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Aktiviert automatisch Stop + Autostart-Block bei wenig freiem Speicher (Resume bei +3 GB)."})]}),m.jsx("span",{className:"inline-flex items-center rounded-full px-2 py-1 text-[11px] font-medium "+(v?.emergency?"bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-200":"bg-green-100 text-green-800 dark:bg-green-500/20 dark:text-green-200"),title:v?.emergency?"Notfallbremse greift gerade":"OK",children:v?.emergency?"AKTIV":"OK"})]}),m.jsxs("div",{className:"mt-3 text-sm text-gray-900 dark:text-gray-200",children:[m.jsxs("div",{children:[m.jsx("span",{className:"font-medium",children:"Schwelle:"})," ","Pause unter ",m.jsx("span",{className:"tabular-nums",children:P})," GB"," · ","Resume ab"," ",m.jsx("span",{className:"tabular-nums",children:G})," ","GB"]}),m.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:v?`Frei: ${v.freeBytesHuman}${v.recordPath?` (Pfad: ${v.recordPath})`:""}`:"Status wird geladen…"}),v?.emergency&&m.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"Notfallbremse greift: laufende Downloads werden gestoppt und Autostart bleibt gesperrt, bis wieder genug frei ist."})]})]})]})]})]})})}function My(...s){return s.filter(Boolean).join(" ")}const jO={sm:{btn:"px-2.5 py-1.5 text-sm",icon:"size-5",iconOnly:"h-9 w-9"},md:{btn:"px-3 py-2 text-sm",icon:"size-5",iconOnly:"h-10 w-10"},lg:{btn:"px-3.5 py-2.5 text-sm",icon:"size-5",iconOnly:"h-11 w-11"}};function hx({items:s,value:e,onChange:t,size:i="md",className:n,ariaLabel:r="Optionen"}){const a=jO[i];return m.jsx("span",{className:My("isolate inline-flex rounded-md shadow-xs dark:shadow-none ring-1 ring-gray-300 dark:ring-gray-700 overflow-hidden",n),role:"group","aria-label":r,children:s.map((u,c)=>{const d=u.id===e,f=c===0,g=c===s.length-1,y=!u.label&&!!u.icon;return m.jsxs("button",{type:"button",disabled:u.disabled,onClick:()=>t(u.id),"aria-pressed":d,className:My("relative inline-flex items-center justify-center font-semibold leading-none focus:z-10 transition-colors",!f&&"before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-gray-300 dark:before:bg-gray-700",f&&"rounded-l-md",g&&"rounded-r-md",d?"bg-indigo-100 text-indigo-800 hover:bg-indigo-200 dark:bg-indigo-500/40 dark:text-indigo-100 dark:hover:bg-indigo-500/50":"bg-white text-gray-900 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:hover:bg-white/20","disabled:opacity-50 disabled:cursor-not-allowed",y?`p-0 ${a.iconOnly}`:a.btn),title:typeof u.label=="string"?u.label:u.srLabel,children:[y&&u.srLabel?m.jsx("span",{className:"sr-only",children:u.srLabel}):null,u.icon?m.jsx("span",{className:My("shrink-0",y?"":"-ml-0.5",d?"text-indigo-600 dark:text-indigo-200":"text-gray-400 dark:text-gray-500"),children:u.icon}):null,u.label?m.jsx("span",{className:u.icon?"ml-1.5":"",children:u.label}):null]},u.id)})})}function $O({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75"}))}const HO=b.forwardRef($O);function zO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"}))}const Q_=b.forwardRef(zO);function VO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"}))}const GO=b.forwardRef(VO);function qO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"}))}const _m=b.forwardRef(qO);function KO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"}))}const WO=b.forwardRef(KO);function YO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"}))}const XO=b.forwardRef(YO);function QO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 3.75V16.5L12 14.25 7.5 16.5V3.75m9 0H18A2.25 2.25 0 0 1 20.25 6v12A2.25 2.25 0 0 1 18 20.25H6A2.25 2.25 0 0 1 3.75 18V6A2.25 2.25 0 0 1 6 3.75h1.5m9 0h-9"}))}const Z_=b.forwardRef(QO);function ZO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5m-9-6h.008v.008H12v-.008ZM12 15h.008v.008H12V15Zm0 2.25h.008v.008H12v-.008ZM9.75 15h.008v.008H9.75V15Zm0 2.25h.008v.008H9.75v-.008ZM7.5 15h.008v.008H7.5V15Zm0 2.25h.008v.008H7.5v-.008Zm6.75-4.5h.008v.008h-.008v-.008Zm0 2.25h.008v.008h-.008V15Zm0 2.25h.008v.008h-.008v-.008Zm2.25-4.5h.008v.008H16.5v-.008Zm0 2.25h.008v.008H16.5V15Z"}))}const Em=b.forwardRef(ZO);function JO({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))}const eM=b.forwardRef(JO);function tM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))}const J_=b.forwardRef(tM);function iM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 12.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"}))}const sM=b.forwardRef(iM);function nM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"}))}const rM=b.forwardRef(nM);function aM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))}const g0=b.forwardRef(aM);function oM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 0 1-1.125-1.125M3.375 19.5h1.5C5.496 19.5 6 18.996 6 18.375m-3.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-1.5A1.125 1.125 0 0 1 18 18.375M20.625 4.5H3.375m17.25 0c.621 0 1.125.504 1.125 1.125M20.625 4.5h-1.5C18.504 4.5 18 5.004 18 5.625m3.75 0v1.5c0 .621-.504 1.125-1.125 1.125M3.375 4.5c-.621 0-1.125.504-1.125 1.125M3.375 4.5h1.5C5.496 4.5 6 5.004 6 5.625m-3.75 0v1.5c0 .621.504 1.125 1.125 1.125m0 0h1.5m-1.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m1.5-3.75C5.496 8.25 6 7.746 6 7.125v-1.5M4.875 8.25C5.496 8.25 6 8.754 6 9.375v1.5m0-5.25v5.25m0-5.25C6 5.004 6.504 4.5 7.125 4.5h9.75c.621 0 1.125.504 1.125 1.125m1.125 2.625h1.5m-1.5 0A1.125 1.125 0 0 1 18 7.125v-1.5m1.125 2.625c-.621 0-1.125.504-1.125 1.125v1.5m2.625-2.625c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125M18 5.625v5.25M7.125 12h9.75m-9.75 0A1.125 1.125 0 0 1 6 10.875M7.125 12C6.504 12 6 12.504 6 13.125m0-2.25C6 11.496 5.496 12 4.875 12M18 10.875c0 .621-.504 1.125-1.125 1.125M18 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m-12 5.25v-5.25m0 5.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125m-12 0v-1.5c0-.621-.504-1.125-1.125-1.125M18 18.375v-5.25m0 5.25v-1.5c0-.621.504-1.125 1.125-1.125M18 13.125v1.5c0 .621.504 1.125 1.125 1.125M18 13.125c0-.621.504-1.125 1.125-1.125M6 13.125v1.5c0 .621-.504 1.125-1.125 1.125M6 13.125C6 12.504 5.496 12 4.875 12m-1.5 0h1.5m-1.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M19.125 12h1.5m0 0c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h1.5m14.25 0h1.5"}))}const lM=b.forwardRef(oM);function uM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.362 5.214A8.252 8.252 0 0 1 12 21 8.25 8.25 0 0 1 6.038 7.047 8.287 8.287 0 0 0 9 9.601a8.983 8.983 0 0 1 3.361-6.867 8.21 8.21 0 0 0 3 2.48Z"}),b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18a3.75 3.75 0 0 0 .495-7.468 5.99 5.99 0 0 0-1.925 3.547 5.975 5.975 0 0 1-2.133-1.001A3.75 3.75 0 0 0 12 18Z"}))}const e2=b.forwardRef(uM);function cM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"}))}const Th=b.forwardRef(cM);function dM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 9h3.75M15 12h3.75M15 15h3.75M4.5 19.5h15a2.25 2.25 0 0 0 2.25-2.25V6.75A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25v10.5A2.25 2.25 0 0 0 4.5 19.5Zm6-10.125a1.875 1.875 0 1 1-3.75 0 1.875 1.875 0 0 1 3.75 0Zm1.294 6.336a6.721 6.721 0 0 1-3.17.789 6.721 6.721 0 0 1-3.168-.789 3.376 3.376 0 0 1 6.338 0Z"}))}const hM=b.forwardRef(dM);function fM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"}))}const mM=b.forwardRef(fM);function pM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802"}))}const gM=b.forwardRef(pM);function yM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"}))}const vM=b.forwardRef(yM);function xM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"}))}const t2=b.forwardRef(xM);function bM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}),b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1 1 15 0Z"}))}const TM=b.forwardRef(bM);function SM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"}))}const i2=b.forwardRef(SM);function _M({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 6.878V6a2.25 2.25 0 0 1 2.25-2.25h7.5A2.25 2.25 0 0 1 18 6v.878m-12 0c.235-.083.487-.128.75-.128h10.5c.263 0 .515.045.75.128m-12 0A2.25 2.25 0 0 0 4.5 9v.878m13.5-3A2.25 2.25 0 0 1 19.5 9v.878m0 0a2.246 2.246 0 0 0-.75-.128H5.25c-.263 0-.515.045-.75.128m15 0A2.25 2.25 0 0 1 21 12v6a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 18v-6c0-.98.626-1.813 1.5-2.122"}))}const EM=b.forwardRef(_M);function wM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"}))}const Py=b.forwardRef(wM);function AM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6A2.25 2.25 0 0 1 6 3.75h2.25A2.25 2.25 0 0 1 10.5 6v2.25a2.25 2.25 0 0 1-2.25 2.25H6a2.25 2.25 0 0 1-2.25-2.25V6ZM3.75 15.75A2.25 2.25 0 0 1 6 13.5h2.25a2.25 2.25 0 0 1 2.25 2.25V18a2.25 2.25 0 0 1-2.25 2.25H6A2.25 2.25 0 0 1 3.75 18v-2.25ZM13.5 6a2.25 2.25 0 0 1 2.25-2.25H18A2.25 2.25 0 0 1 20.25 6v2.25A2.25 2.25 0 0 1 18 10.5h-2.25a2.25 2.25 0 0 1-2.25-2.25V6ZM13.5 15.75a2.25 2.25 0 0 1 2.25-2.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-2.25A2.25 2.25 0 0 1 13.5 18v-2.25Z"}))}const kM=b.forwardRef(AM);function CM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"}))}const y0=b.forwardRef(CM);function DM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 0 1-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0 1 12 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m8.625-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m0 1.5v-1.5m0 0c0-.621.504-1.125 1.125-1.125m0 0h7.5"}))}const LM=b.forwardRef(DM);function RM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"}))}const s2=b.forwardRef(RM);function IM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"}))}const n2=b.forwardRef(IM);function NM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))}const OM=b.forwardRef(NM);function MM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"}))}const v0=b.forwardRef(MM);function PM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z",clipRule:"evenodd"}))}const BM=b.forwardRef(PM);function FM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),b.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const Su=b.forwardRef(FM);function UM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M12.963 2.286a.75.75 0 0 0-1.071-.136 9.742 9.742 0 0 0-3.539 6.176 7.547 7.547 0 0 1-1.705-1.715.75.75 0 0 0-1.152-.082A9 9 0 1 0 15.68 4.534a7.46 7.46 0 0 1-2.717-2.248ZM15.75 14.25a3.75 3.75 0 1 1-7.313-1.172c.628.465 1.35.81 2.133 1a5.99 5.99 0 0 1 1.925-3.546 3.75 3.75 0 0 1 3.255 3.718Z",clipRule:"evenodd"}))}const fx=b.forwardRef(UM);function jM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{d:"M7.493 18.5c-.425 0-.82-.236-.975-.632A7.48 7.48 0 0 1 6 15.125c0-1.75.599-3.358 1.602-4.634.151-.192.373-.309.6-.397.473-.183.89-.514 1.212-.924a9.042 9.042 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75A.75.75 0 0 1 15 2a2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H14.23c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23h-.777ZM2.331 10.727a11.969 11.969 0 0 0-.831 4.398 12 12 0 0 0 .52 3.507C2.28 19.482 3.105 20 3.994 20H4.9c.445 0 .72-.498.523-.898a8.963 8.963 0 0 1-.924-3.977c0-1.708.476-3.305 1.302-4.666.245-.403-.028-.959-.5-.959H4.25c-.832 0-1.612.453-1.918 1.227Z"}))}const $M=b.forwardRef(jM);function HM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{d:"m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z"}))}const _u=b.forwardRef(HM);function zM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M6.75 5.25a.75.75 0 0 1 .75-.75H9a.75.75 0 0 1 .75.75v13.5a.75.75 0 0 1-.75.75H7.5a.75.75 0 0 1-.75-.75V5.25Zm7.5 0A.75.75 0 0 1 15 4.5h1.5a.75.75 0 0 1 .75.75v13.5a.75.75 0 0 1-.75.75H15a.75.75 0 0 1-.75-.75V5.25Z",clipRule:"evenodd"}))}const VM=b.forwardRef(zM);function GM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.427 1.529-2.33 2.779-1.643l11.54 6.347c1.295.712 1.295 2.573 0 3.286L7.28 19.99c-1.25.687-2.779-.217-2.779-1.643V5.653Z",clipRule:"evenodd"}))}const qM=b.forwardRef(GM);function KM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M5.636 4.575a.75.75 0 0 1 0 1.061 9 9 0 0 0 0 12.728.75.75 0 1 1-1.06 1.06c-4.101-4.1-4.101-10.748 0-14.849a.75.75 0 0 1 1.06 0Zm12.728 0a.75.75 0 0 1 1.06 0c4.101 4.1 4.101 10.75 0 14.85a.75.75 0 1 1-1.06-1.061 9 9 0 0 0 0-12.728.75.75 0 0 1 0-1.06ZM7.757 6.697a.75.75 0 0 1 0 1.06 6 6 0 0 0 0 8.486.75.75 0 0 1-1.06 1.06 7.5 7.5 0 0 1 0-10.606.75.75 0 0 1 1.06 0Zm8.486 0a.75.75 0 0 1 1.06 0 7.5 7.5 0 0 1 0 10.606.75.75 0 0 1-1.06-1.06 6 6 0 0 0 0-8.486.75.75 0 0 1 0-1.06ZM9.879 8.818a.75.75 0 0 1 0 1.06 3 3 0 0 0 0 4.243.75.75 0 1 1-1.061 1.061 4.5 4.5 0 0 1 0-6.364.75.75 0 0 1 1.06 0Zm4.242 0a.75.75 0 0 1 1.061 0 4.5 4.5 0 0 1 0 6.364.75.75 0 0 1-1.06-1.06 3 3 0 0 0 0-4.243.75.75 0 0 1 0-1.061ZM10.875 12a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Z",clipRule:"evenodd"}))}const WM=b.forwardRef(KM);function YM({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z",clipRule:"evenodd"}))}const Mc=b.forwardRef(YM);function XM(...s){return s.filter(Boolean).join(" ")}function QM(){if(typeof document>"u")return null;const s="__swipecard_hot_fx_layer__";let e=document.getElementById(s);return e||(e=document.createElement("div"),e.id=s,e.style.position="fixed",e.style.inset="0",e.style.pointerEvents="none",e.style.zIndex="2147483647",e.style.contain="layout style paint",document.body.appendChild(e)),e}const ZM=b.forwardRef(function({children:e,enabled:t=!0,disabled:i=!1,onTap:n,onSwipeLeft:r,onSwipeRight:a,className:u,thresholdPx:c=140,thresholdRatio:d=.28,ignoreFromBottomPx:f=72,ignoreSelector:g="[data-swipe-ignore]",snapMs:y=180,commitMs:v=180,tapIgnoreSelector:T="button,a,input,textarea,select,video[controls],video[controls] *,[data-tap-ignore]",onDoubleTap:S,hotTargetSelector:w="[data-hot-target]",doubleTapMs:L=360,doubleTapMaxMovePx:O=48},I){const j=b.useRef(null),P=b.useRef(!1),G=b.useRef(0),N=b.useRef(null),K=b.useRef(0),k=b.useRef(null),R=b.useRef(null),Y=b.useRef(null),z=b.useRef({id:null,x:0,y:0,dragging:!1,captured:!1,tapIgnored:!1,noSwipe:!1}),[X,re]=b.useState(0),[J,W]=b.useState(null),[q,Z]=b.useState(0),te=b.useCallback(()=>{N.current!=null&&(cancelAnimationFrame(N.current),N.current=null),G.current=0,j.current&&(j.current.style.touchAction="pan-y"),Z(y),re(0),W(null),window.setTimeout(()=>Z(0),y)},[y]),oe=b.useCallback(async(Ee,_e)=>{N.current!=null&&(cancelAnimationFrame(N.current),N.current=null),j.current&&(j.current.style.touchAction="pan-y");const ut=j.current?.offsetWidth||360;Z(v),W(Ee==="right"?"right":"left");const pt=Ee==="right"?ut+40:-(ut+40);G.current=pt,re(pt);let Fe;_e?Fe=Promise.resolve(Ee==="right"?a():r()).catch(()=>!1):Fe=Promise.resolve(!0);const _t=new Promise(Xe=>{window.setTimeout(Xe,v)}),[,Qe]=await Promise.all([_t,Fe]);return Qe===!1?(Z(y),W(null),re(0),window.setTimeout(()=>Z(0),y),!1):!0},[v,r,a,y]),F=b.useCallback(()=>{R.current!=null&&(window.clearTimeout(R.current),R.current=null)},[]),le=b.useCallback(()=>{N.current!=null&&(cancelAnimationFrame(N.current),N.current=null),G.current=0,Z(0),re(0),W(null);try{const Ee=j.current;Ee&&(Ee.style.touchAction="pan-y")}catch{}},[]),ge=b.useCallback((Ee,_e)=>{const yt=k.current,ut=j.current;if(!yt||!ut)return;const pt=QM();if(!pt)return;let Fe=typeof Ee=="number"?Ee:window.innerWidth/2,_t=typeof _e=="number"?_e:window.innerHeight/2;const Qe=w?k.current?.querySelector(w)??ut.querySelector(w):null;let Xe=Fe,ze=_t;if(Qe){const Ft=Qe.getBoundingClientRect();Xe=Ft.left+Ft.width/2,ze=Ft.top+Ft.height/2}const Ze=Xe-Fe,ct=ze-_t,St=document.createElement("div");St.style.position="absolute",St.style.left=`${Fe}px`,St.style.top=`${_t}px`,St.style.transform="translate(-50%, -50%)",St.style.pointerEvents="none",St.style.willChange="transform, opacity",St.style.zIndex="2147483647",St.style.lineHeight="1",St.style.userSelect="none",St.style.filter="drop-shadow(0 10px 16px rgba(0,0,0,0.22))";const se=document.createElement("div");se.style.width="30px",se.style.height="30px",se.style.color="#f59e0b",se.style.display="block",St.appendChild(se),pt.appendChild(St);const ke=IA.createRoot(se);ke.render(m.jsx(fx,{className:"w-full h-full","aria-hidden":"true"})),St.getBoundingClientRect();const De=200,Ue=500,at=400,dt=De+Ue+at,wt=De/dt,kt=(De+Ue)/dt,Tt=St.animate([{transform:"translate(-50%, -50%) scale(0.15)",opacity:0,offset:0},{transform:"translate(-50%, -50%) scale(1.25)",opacity:1,offset:wt*.55},{transform:"translate(-50%, -50%) scale(1.00)",opacity:1,offset:wt},{transform:"translate(-50%, -50%) scale(1.00)",opacity:1,offset:kt},{transform:`translate(calc(-50% + ${Ze}px), calc(-50% + ${ct}px)) scale(0.85)`,opacity:.95,offset:kt+(1-kt)*.75},{transform:`translate(calc(-50% + ${Ze}px), calc(-50% + ${ct}px)) scale(0.55)`,opacity:0,offset:1}],{duration:dt,easing:"cubic-bezier(0.2, 0.9, 0.2, 1)",fill:"forwards"});Qe&&window.setTimeout(()=>{try{Qe.animate([{transform:"translateZ(0) scale(1)",filter:"brightness(1)"},{transform:"translateZ(0) scale(1.10)",filter:"brightness(1.25)",offset:.35},{transform:"translateZ(0) scale(1)",filter:"brightness(1)"}],{duration:260,easing:"cubic-bezier(0.2, 0.9, 0.2, 1)"})}catch{}},De+Ue+Math.round(at*.75)),Tt.onfinish=()=>{try{ke.unmount()}catch{}St.remove()}},[w]);b.useEffect(()=>()=>{R.current!=null&&window.clearTimeout(R.current)},[]),b.useImperativeHandle(I,()=>({swipeLeft:Ee=>oe("left",Ee?.runAction??!0),swipeRight:Ee=>oe("right",Ee?.runAction??!0),reset:()=>te()}),[oe,te]);const Ie=Math.abs(X),Le=X===0?null:X>0?"right":"left",Pe=K.current||Math.min(c,(j.current?.offsetWidth||360)*d),Je=Math.max(0,Math.min(1,Ie/Math.max(1,Pe))),Se=Math.max(0,Math.min(1,Ie/Math.max(1,Pe*1.35))),Re=Math.max(-6,Math.min(6,X/28)),Ve=X===0?1:.995;return m.jsx("div",{ref:k,className:XM("relative isolate overflow-visible rounded-lg",u),children:m.jsx("div",{ref:j,className:"relative",style:{transform:X!==0?`translate3d(${X}px,0,0) rotate(${Re}deg) scale(${Ve})`:void 0,transition:q?`transform ${q}ms ease`:void 0,touchAction:"pan-y",willChange:X!==0?"transform":void 0,boxShadow:X!==0?Le==="right"?`0 16px 34px rgba(0,0,0,0.28), 0 0 0 1px rgba(16,185,129,${.08+Je*.12})`:`0 16px 34px rgba(0,0,0,0.28), 0 0 0 1px rgba(244,63,94,${.08+Je*.12})`:void 0,borderRadius:X!==0?"12px":void 0,filter:X!==0?`saturate(${1+Je*.08}) brightness(${1+Je*.02})`:void 0},onPointerDown:Ee=>{if(!t||i)return;const _e=Ee.target;let yt=!!(T&&_e?.closest?.(T));if(g&&_e?.closest?.(g))return;let ut=!1;const pt=Ee.currentTarget,_t=Array.from(pt.querySelectorAll("video")).find(ct=>ct.controls);if(_t){const ct=_t.getBoundingClientRect();if(Ee.clientX>=ct.left&&Ee.clientX<=ct.right&&Ee.clientY>=ct.top&&Ee.clientY<=ct.bottom)if(ct.bottom-Ee.clientY<=72)ut=!0,yt=!0;else{const Ue=Ee.clientX-ct.left,at=ct.right-Ee.clientX;Ue<=64||at<=64||(ut=!0,yt=!0)}}const Xe=Ee.currentTarget.getBoundingClientRect().bottom-Ee.clientY;f&&Xe<=f&&(ut=!0),z.current={id:Ee.pointerId,x:Ee.clientX,y:Ee.clientY,dragging:!1,captured:!1,tapIgnored:yt,noSwipe:ut};const Ze=j.current?.offsetWidth||360;K.current=Math.min(c,Ze*d),G.current=0},onPointerMove:Ee=>{if(!t||i||z.current.id!==Ee.pointerId||z.current.noSwipe)return;const _e=Ee.clientX-z.current.x,yt=Ee.clientY-z.current.y;if(!z.current.dragging){if(Math.abs(yt)>Math.abs(_e)&&Math.abs(yt)>8){z.current.id=null;return}if(Math.abs(_e)<12)return;z.current.dragging=!0,Ee.currentTarget.style.touchAction="none",Z(0);try{Ee.currentTarget.setPointerCapture(Ee.pointerId),z.current.captured=!0}catch{z.current.captured=!1}}const ut=(Qe,Xe)=>{const ze=Xe*.9,Ze=Math.abs(Qe);if(Ze<=ze)return Qe;const ct=Ze-ze,St=ze+ct*.25;return Math.sign(Qe)*St},pt=j.current?.offsetWidth||360;G.current=ut(_e,pt),N.current==null&&(N.current=requestAnimationFrame(()=>{N.current=null,re(G.current)}));const Fe=K.current,_t=_e>Fe?"right":_e<-Fe?"left":null;W(Qe=>{if(Qe===_t)return Qe;if(_t)try{navigator.vibrate?.(10)}catch{}return _t})},onPointerUp:Ee=>{if(!t||i||z.current.id!==Ee.pointerId)return;const _e=K.current||Math.min(c,(j.current?.offsetWidth||360)*d),yt=z.current.dragging,ut=z.current.captured,pt=z.current.tapIgnored;if(z.current.id=null,z.current.dragging=!1,z.current.captured=!1,ut)try{Ee.currentTarget.releasePointerCapture(Ee.pointerId)}catch{}if(Ee.currentTarget.style.touchAction="pan-y",!yt){const _t=Date.now(),Qe=Y.current,Xe=Qe&&Math.hypot(Ee.clientX-Qe.x,Ee.clientY-Qe.y)<=O;if(!!S&&Qe&&_t-Qe.t<=L&&Xe){if(Y.current=null,F(),P.current)return;P.current=!0;try{ge(Ee.clientX,Ee.clientY)}catch{}requestAnimationFrame(()=>{(async()=>{try{await S?.()}finally{P.current=!1}})()});return}if(pt){Y.current={t:_t,x:Ee.clientX,y:Ee.clientY},F(),R.current=window.setTimeout(()=>{R.current=null,Y.current=null},S?L:0);return}le(),Y.current={t:_t,x:Ee.clientX,y:Ee.clientY},F(),R.current=window.setTimeout(()=>{R.current=null,Y.current=null,n?.()},S?L:0);return}const Fe=G.current;N.current!=null&&(cancelAnimationFrame(N.current),N.current=null),Fe>_e?oe("right",!0):Fe<-_e?oe("left",!0):te(),G.current=0},onPointerCancel:Ee=>{if(!(!t||i)){if(z.current.captured&&z.current.id!=null)try{Ee.currentTarget.releasePointerCapture(z.current.id)}catch{}z.current={id:null,x:0,y:0,dragging:!1,captured:!1,tapIgnored:!1,noSwipe:!1},N.current!=null&&(cancelAnimationFrame(N.current),N.current=null),G.current=0;try{Ee.currentTarget.style.touchAction="pan-y"}catch{}te()}},children:m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"relative z-10",children:e}),m.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none rounded-lg transition-opacity duration-100",style:{opacity:X===0?0:.12+Se*.18,background:Le==="right"?"linear-gradient(90deg, rgba(16,185,129,0.16) 0%, rgba(16,185,129,0.04) 45%, rgba(0,0,0,0) 100%)":Le==="left"?"linear-gradient(270deg, rgba(244,63,94,0.16) 0%, rgba(244,63,94,0.04) 45%, rgba(0,0,0,0) 100%)":"transparent"}}),m.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none rounded-lg transition-opacity duration-100",style:{opacity:J?1:0,boxShadow:J==="right"?"inset 0 0 0 1px rgba(16,185,129,0.45), inset 0 0 32px rgba(16,185,129,0.10)":J==="left"?"inset 0 0 0 1px rgba(244,63,94,0.45), inset 0 0 32px rgba(244,63,94,0.10)":"none"}})]})})})});function ck({children:s,content:e}){const t=b.useRef(null),i=b.useRef(null),[n,r]=b.useState(!1),[a,u]=b.useState(null),c=b.useRef(null),d=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},f=()=>{d(),c.current=window.setTimeout(()=>{r(!1),c.current=null},150)},g=()=>{d(),r(!0)},y=()=>{f()},v=()=>{d(),r(!1)},T=()=>{const w=t.current,L=i.current;if(!w||!L)return;const O=8,I=8,j=w.getBoundingClientRect(),P=L.getBoundingClientRect();let G=j.bottom+O;if(G+P.height>window.innerHeight-I){const k=j.top-P.height-O;k>=I?G=k:G=Math.max(I,window.innerHeight-P.height-I)}let K=j.left;K+P.width>window.innerWidth-I&&(K=window.innerWidth-P.width-I),K=Math.max(I,K),u({left:K,top:G})};b.useLayoutEffect(()=>{if(!n)return;const w=requestAnimationFrame(()=>T());return()=>cancelAnimationFrame(w)},[n]),b.useEffect(()=>{if(!n)return;const w=()=>requestAnimationFrame(()=>T());return window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),()=>{window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0)}},[n]),b.useEffect(()=>()=>d(),[]);const S=()=>typeof e=="function"?e(n,{close:v}):e;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:t,className:"inline-flex",onMouseEnter:g,onMouseLeave:y,children:s}),n&&Nc.createPortal(m.jsx("div",{ref:i,className:"fixed z-50",style:{left:a?.left??-9999,top:a?.top??-9999,visibility:a?"visible":"hidden"},onMouseEnter:g,onMouseLeave:y,children:m.jsx(pa,{className:"shadow-lg ring-1 ring-black/10 dark:ring-white/10 max-w-[calc(100vw-16px)]",noBodyPadding:!0,children:S()})}),document.body)]})}const x0=!0,JM=!1;function Nh(s,e){if(!s)return;const t=e?.muted??x0;s.muted=t,s.defaultMuted=t,s.playsInline=!0,s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","")}function b0({job:s,getFileName:e,durationSeconds:t,onDuration:i,onResolution:n,animated:r=!1,animatedMode:a="frames",animatedTrigger:u="always",autoTickMs:c=15e3,thumbStepSec:d,thumbSpread:f,thumbSamples:g,clipSeconds:y=.75,clipCount:v=12,variant:T="thumb",className:S,showPopover:w=!0,blur:L=!1,inlineVideo:O=!1,inlineNonce:I=0,inlineControls:j=!1,inlineLoop:P=!0,assetNonce:G=0,muted:N=x0,popoverMuted:K=x0,noGenerateTeaser:k,alwaysLoadStill:R=!1,teaserPreloadEnabled:Y=!1,teaserPreloadRootMargin:z="700px 0px",scrubProgressRatio:X,preferScrubProgress:re=!1}){const J=e(s.output||""),W=L?"blur-md":"",q=b.useMemo(()=>{const Ge=s?.meta;if(!Ge)return null;if(typeof Ge=="string")try{return JSON.parse(Ge)}catch{return null}return Ge},[s]),[Z,te]=b.useState(null),oe=b.useRef(new Set),F=b.useMemo(()=>!q&&!Z?null:q?Z?{...q,...Z}:q:Z,[q,Z]),le=b.useMemo(()=>{let Ge=F?.previewClips;if(typeof Ge=="string"){const Ct=Ge.trim();if(Ct.length>0)try{const Xt=JSON.parse(Ct);return Array.isArray(Xt)&&Xt.length>0,!0}catch{return!0}}if(Array.isArray(Ge)&&Ge.length>0)return!0;const Lt=F?.preview?.clips;return!!(Array.isArray(Lt)&&Lt.length>0)},[F]),[ge,Ie]=b.useState(0),Le=b.useMemo(()=>{let Ge=F?.previewClips;if(typeof Ge=="string")try{Ge=JSON.parse(Ge)}catch{Ge=null}!Array.isArray(Ge)&&Array.isArray(F?.preview?.clips)&&(Ge=F.preview.clips);const Lt=Ge;if(!Array.isArray(Lt)||Lt.length===0)return null;let Ct=0;const Xt=[];for(const Wt of Lt){const _i=Number(Wt?.startSeconds),ei=Number(Wt?.durationSeconds);if(!Number.isFinite(_i)||_i<0||!Number.isFinite(ei)||ei<=0)continue;const Ki=Ct,Ts=Ct+ei;Xt.push({start:_i,dur:ei,cumStart:Ki,cumEnd:Ts}),Ct=Ts}return Xt.length?Xt:null},[F]),Pe=b.useMemo(()=>Le?Le.map(Ge=>`${Ge.start.toFixed(3)}:${Ge.dur.toFixed(3)}`).join("|"):"",[Le]),Je=(typeof q?.videoWidth=="number"&&Number.isFinite(q.videoWidth)&&q.videoWidth>0?q.videoWidth:void 0)??(typeof s.videoWidth=="number"&&Number.isFinite(s.videoWidth)&&s.videoWidth>0?s.videoWidth:void 0),Se=(typeof q?.videoHeight=="number"&&Number.isFinite(q.videoHeight)&&q.videoHeight>0?q.videoHeight:void 0)??(typeof s.videoHeight=="number"&&Number.isFinite(s.videoHeight)&&s.videoHeight>0?s.videoHeight:void 0),Re=(typeof q?.fileSize=="number"&&Number.isFinite(q.fileSize)&&q.fileSize>0?q.fileSize:void 0)??(typeof s.sizeBytes=="number"&&Number.isFinite(s.sizeBytes)&&s.sizeBytes>0?s.sizeBytes:void 0),Ve=(typeof q?.fps=="number"&&Number.isFinite(q.fps)&&q.fps>0?q.fps:void 0)??(typeof s.fps=="number"&&Number.isFinite(s.fps)&&s.fps>0?s.fps:void 0),Ee=(typeof F?.durationSeconds=="number"&&Number.isFinite(F.durationSeconds)&&F.durationSeconds>0?F.durationSeconds:void 0)??(typeof s.durationSeconds=="number"&&Number.isFinite(s.durationSeconds)&&s.durationSeconds>0?s.durationSeconds:void 0)??(typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0),_e=typeof Ee=="number"&&Number.isFinite(Ee)&&Ee>0?Ee>1440*60?Ee/1e3:Ee:void 0,yt=typeof _e=="number"&&Number.isFinite(_e)&&_e>0,ut=typeof Je=="number"&&typeof Se=="number"&&Number.isFinite(Je)&&Number.isFinite(Se)&&Je>0&&Se>0,pt={muted:N,playsInline:!0,preload:"metadata"},[Fe,_t]=b.useState(!0),[Qe,Xe]=b.useState(!0),[ze,Ze]=b.useState(!1),[ct,St]=b.useState(!1),[se,ke]=b.useState(!0),De=b.useRef(""),Ue=b.useRef(""),at=b.useRef(null),[dt,wt]=b.useState(!1),[kt,Tt]=b.useState(!1),[Ft,Qt]=b.useState(!1),[Zt,Et]=b.useState(0),[Dt,yi]=b.useState(!1),Pi=O===!0||O==="always"?"always":O==="hover"?"hover":"never",Jt=Pi==="hover"||r&&(a==="clips"||a==="teaser")&&u==="hover",ki=Ge=>Ge.startsWith("HOT ")?Ge.slice(4):Ge,gt=b.useMemo(()=>{const Ge=e(s.output||"");if(!Ge)return"";const Lt=Ge.replace(/\.[^.]+$/,"");return ki(Lt).trim()},[s.output,e]),V=b.useMemo(()=>J?`/api/record/video?file=${encodeURIComponent(J)}`:"",[J]),$=T==="fill"?"w-full h-full":"w-20 h-16",ie=b.useRef(null),Te=b.useRef(null),Be=b.useRef(null),ht=b.useRef({inline:null,teaser:null,clips:null}),It=(Ge,Lt)=>{Lt&&ht.current[Ge]!==Lt&&(ht.current[Ge]=Lt,Ie(Ct=>Ct+1))},[Yt,pi]=b.useState(0),[,oi]=b.useState(0),ci=Ge=>Ge<0?0:Ge>1?1:Ge,Bi=(Ge,Lt,Ct=y,Xt=!1)=>{if(!Ge)return{ratio:0,globalSec:0,vvDur:0};const Wt=Number(Ge.duration);if(!(Number.isFinite(Wt)&&Wt>0))return{ratio:0,globalSec:0,vvDur:0};const ei=Number(Ge.currentTime);if(!Number.isFinite(ei)||ei<0)return{ratio:0,globalSec:0,vvDur:Wt};const Ki=Le;let Ts=0;if(Xt&&Array.isArray(Ki)&&Ki.length>0){const Wi=Ki[Ki.length-1];if(ei>=Wi.cumEnd)Ts=typeof Lt=="number"&&Number.isFinite(Lt)&&Lt>0?Lt:Wi.start+Wi.dur;else{let Nn=0,On=Ki.length-1,Zs=0;for(;Nn<=On;){const Is=Nn+On>>1,un=Ki[Is];if(ei<un.cumStart)On=Is-1;else if(ei>=un.cumEnd)Nn=Is+1;else{Zs=Is;break}}return Ts=Ki[Zs].start,{ratio:Ki.length>0?ci(Zs/Ki.length):0,globalSec:Math.max(0,Ts),vvDur:Wt}}}return Number.isFinite(Ct)&&Ct>0?Ts=Math.floor(ei/Ct)*Ct:Ts=ei,{ratio:ci(Math.min(Ts,Wt)/Wt),globalSec:Math.max(0,Ts),vvDur:Wt}},Gt=Ge=>{if(Ge){try{Ge.pause()}catch{}try{Ge.removeAttribute("src"),Ge.src="",Ge.load()}catch{}}};b.useEffect(()=>{St(!1),ke(!0),te(null),De.current="",Ue.current="",Ze(!1)},[gt,G,k]),b.useEffect(()=>{const Ge=Lt=>{const Ct=String(Lt?.detail?.file??"");!Ct||Ct!==J||(Gt(ie.current),Gt(Te.current),Gt(Be.current))};return window.addEventListener("player:release",Ge),window.addEventListener("player:close",Ge),()=>{window.removeEventListener("player:release",Ge),window.removeEventListener("player:close",Ge)}},[J]),b.useEffect(()=>{const Ge=at.current;if(!Ge)return;const Lt=new IntersectionObserver(Ct=>{const Xt=!!Ct[0]?.isIntersecting;wt(Xt),Xt&&Qt(!0)},{threshold:.01,rootMargin:"0px"});return Lt.observe(Ge),()=>Lt.disconnect()},[]),b.useEffect(()=>{const Ge=at.current;if(!Ge)return;if(!Y){Tt(dt);return}let Lt=!0;const Ct=new IntersectionObserver(Xt=>{Xt[0]?.isIntersecting&&(Tt(!0),Lt&&(Lt=!1,Ct.disconnect()))},{threshold:0,rootMargin:z});return Ct.observe(Ge),()=>Ct.disconnect()},[Y,z,dt]),b.useEffect(()=>{if(!r||a!=="frames"||!dt||document.hidden)return;const Ge=window.setInterval(()=>Et(Lt=>Lt+1),c);return()=>window.clearInterval(Ge)},[r,a,dt,c]);const xi=b.useMemo(()=>{if(!r||a!=="frames"||!yt)return null;const Ge=_e,Lt=Math.max(.25,d??3);if(f){const Wt=Math.max(4,Math.min(g??16,Math.floor(Ge))),_i=Zt%Wt,ei=Math.max(.1,Ge-Lt),Ki=Math.min(.25,ei*.02),Ts=_i/Wt*ei+Ki;return Math.min(Ge-.05,Math.max(.05,Ts))}const Ct=Math.max(Ge-.1,Lt),Xt=Zt*Lt%Ct;return Math.min(Ge-.05,Math.max(.05,Xt))},[r,a,yt,_e,Zt,d,f,g]),ai=G??0,di=b.useMemo(()=>gt?xi==null?`/api/preview?id=${encodeURIComponent(gt)}&v=${ai}`:`/api/preview?id=${encodeURIComponent(gt)}&t=${xi}&v=${ai}`:"",[gt,xi,ai]),qt=b.useMemo(()=>{if(!gt)return"";const Ge=k?"&noGenerate=1":"";return`/api/generated/teaser?id=${encodeURIComponent(gt)}${Ge}&v=${ai}`},[gt,ai,k]),Mt=Pi!=="never"&&dt&&Qe&&(Pi==="always"||Pi==="hover"&&Dt),vt=r&&dt&&!document.hidden&&Qe&&!Mt&&(u==="always"||Dt)&&(a==="teaser"&&se&&!!qt||a==="clips"&&yt),Ci=yt&&typeof _e=="number"?_e:void 0,ss=R||dt||Ft||Jt&&Dt,vs=kt||dt||Ft||Jt&&Dt;b.useEffect(()=>{let Ge=!1;if(i&&yt){const Lt=Number(_e),Ct=`${J}|dur|${Lt}`;De.current!==Ct&&(De.current=Ct,i(s,Lt),Ge=!0)}if(n&&ut){const Lt=Number(Je),Ct=Number(Se),Xt=`${J}|res|${Lt}x${Ct}`;Ue.current!==Xt&&(Ue.current=Xt,n(s,Lt,Ct),Ge=!0)}Ge&&Ze(!0)},[J,s,i,n,yt,ut,_e,Je,Se]),b.useEffect(()=>{if(!gt||!J||!r||a!=="teaser"||!vs||le||oe.current.has(J))return;let Ge=!1;const Lt=new AbortController,Ct=async Xt=>{try{const Wt=await fetch(Xt,{signal:Lt.signal,cache:"no-store",credentials:"include"});return Wt.ok?await Wt.json():null}catch{return null}};return(async()=>{const Xt=await Ct(`/api/record/done/meta?file=${encodeURIComponent(J)}`);Ge||(oe.current.add(J),Xt&&te(Xt))})(),()=>{Ge=!0,Lt.abort()}},[gt,J,r,a,vs,le]);const xs=Ge=>{Ze(!0);const Lt=Ge.currentTarget;if(i&&!yt){const Ct=Number(Lt.duration);if(Number.isFinite(Ct)&&Ct>0){const Xt=`${J}|dur|${Ct}`;De.current!==Xt&&(De.current=Xt,i(s,Ct))}}if(n&&!ut){const Ct=Number(Lt.videoWidth),Xt=Number(Lt.videoHeight);if(Number.isFinite(Ct)&&Number.isFinite(Xt)&&Ct>0&&Xt>0){const Wt=`${J}|res|${Ct}x${Xt}`;Ue.current!==Wt&&(Ue.current=Wt,n(s,Ct,Xt))}}};if(b.useEffect(()=>{_t(!0),Xe(!0),ht.current.inline=null,ht.current.teaser=null,ht.current.clips=null},[gt,G]),!V)return m.jsx("div",{className:[$,"rounded bg-gray-100 dark:bg-white/5"].join(" ")});const Gi=vs,fi=r&&a==="teaser"&&se&&!!qt&&!Mt&&vs,Zi=Mt?ie:!Mt&&vt&&a==="teaser"?Te:!Mt&&vt&&a==="clips"?Be:null,ts=!!Zi&&dt,$i=Mt?"inline":vt&&a==="teaser"?"teaser":"clips",Ji=r&&a==="frames"&&yt&&typeof xi=="number"&&Number.isFinite(xi)&&xi>=0,Di=Ji?ci(xi/_e):0,$s=!Mt&&re&&typeof X=="number"&&Number.isFinite(X),Cs=$s?ci(X):ts?Yt:Ji?Di:0,rs=!Mt&&($s||(ts||Ji)),Rs=b.useMemo(()=>{if(!yt)return null;const Ge=_e;if(!(Ge>0))return null;let Ct=F?.previewClips;if(typeof Ct=="string")try{Ct=JSON.parse(Ct)}catch{Ct=null}if(!Array.isArray(Ct)||Ct.length===0)return null;const Xt=Ct.map(Wt=>({start:Number(Wt?.startSeconds),dur:Number(Wt?.durationSeconds)})).filter(Wt=>Number.isFinite(Wt.start)&&Wt.start>=0&&Number.isFinite(Wt.dur)&&Wt.dur>0);return Xt.length?Xt.map(Wt=>{const _i=ci(Wt.start/Ge),ei=ci(Wt.dur/Ge);return{left:_i,width:ei,start:Wt.start,dur:Wt.dur}}):null},[F,yt,_e]),Li=b.useMemo(()=>{if(!r)return[];if(a!=="clips")return[];if(!yt)return[];const Ge=_e,Lt=Math.max(.25,y),Ct=Math.max(8,Math.min(v??g??12,Math.floor(Ge))),Xt=Math.max(.1,Ge-Lt),Wt=Math.min(.25,Xt*.02),_i=[];for(let ei=0;ei<Ct;ei++){const Ki=ei/Ct*Xt+Wt;_i.push(Math.min(Ge-.05,Math.max(.05,Ki)))}return _i},[r,a,yt,_e,g,y,v]),qi=b.useMemo(()=>Li.map(Ge=>Ge.toFixed(2)).join(","),[Li]),bs=b.useRef(0),Kt=b.useRef(0);b.useEffect(()=>{const Ge=Te.current;if(!Ge)return;if(!(vt&&a==="teaser")){try{Ge.pause()}catch{}return}Nh(Ge,{muted:N});const Ct=Ge.play?.();Ct&&typeof Ct.catch=="function"&&Ct.catch(()=>{})},[vt,a,qt,N]),b.useEffect(()=>{if(!ts){pi(0),oi(0);return}const Ge=Zi?.current??null;if(!Ge){pi(0),oi(0);return}let Lt=!1,Ct=null;const Xt=()=>{if(Lt||!Ge.isConnected)return;const ei=$i==="teaser"&&Array.isArray(Le)&&Le.length>0,Ki=Bi(Ge,Ci,y,ei);pi(Ki.ratio),oi(Ki.globalSec)};Xt(),Ct=window.setInterval(Xt,100);const Wt=()=>Xt(),_i=()=>Xt();return Ge.addEventListener("loadedmetadata",Wt),Ge.addEventListener("durationchange",Wt),Ge.addEventListener("timeupdate",_i),()=>{Lt=!0,Ct!=null&&window.clearInterval(Ct),Ge.removeEventListener("loadedmetadata",Wt),Ge.removeEventListener("durationchange",Wt),Ge.removeEventListener("timeupdate",_i)}},[ts,Zi,Ci,Pe,$i,Le,ge]),b.useEffect(()=>{Mt&&Nh(ie.current,{muted:N})},[Mt,N]),b.useEffect(()=>{const Ge=Be.current;if(!Ge)return;if(!(vt&&a==="clips")){vt||Ge.pause();return}if(!Li.length)return;bs.current=bs.current%Li.length,Kt.current=Li[bs.current];const Lt=()=>{try{Ge.currentTime=Kt.current}catch{}const Wt=Ge.play();Wt&&typeof Wt.catch=="function"&&Wt.catch(()=>{})},Ct=()=>Lt(),Xt=()=>{if(Li.length&&Ge.currentTime-Kt.current>=y){bs.current=(bs.current+1)%Li.length,Kt.current=Li[bs.current];try{Ge.currentTime=Kt.current+.01}catch{}}};return Ge.addEventListener("loadedmetadata",Ct),Ge.addEventListener("timeupdate",Xt),Ge.readyState>=1&&Lt(),()=>{Ge.removeEventListener("loadedmetadata",Ct),Ge.removeEventListener("timeupdate",Xt),Ge.pause()}},[vt,a,qi,y,Li]);const ds=(kt||dt)&&(i||n)&&!ze&&!Mt&&(i&&!yt||n&&!ut),Fi=!!Rs&&($i==="teaser"||!Mt&&$s&&a==="teaser"),Hi=m.jsxs("div",{ref:at,className:["group bg-gray-100 dark:bg-white/5 overflow-hidden relative",$,S??""].join(" "),onMouseEnter:Jt?()=>yi(!0):void 0,onMouseLeave:Jt?()=>yi(!1):void 0,onFocus:Jt?()=>yi(!0):void 0,onBlur:Jt?()=>yi(!1):void 0,"data-duration":yt?String(_e):void 0,"data-res":ut?`${Je}x${Se}`:void 0,"data-size":typeof Re=="number"?String(Re):void 0,"data-fps":typeof Ve=="number"?String(Ve):void 0,children:[ss&&di&&Fe?m.jsx("img",{src:di,loading:R?"eager":"lazy",decoding:"async",alt:J,className:["absolute inset-0 w-full h-full object-cover",W].filter(Boolean).join(" "),onError:()=>_t(!1)}):m.jsx("div",{className:"absolute inset-0 bg-black/10 dark:bg-white/10"}),Mt?b.createElement("video",{...pt,ref:Ge=>{ie.current=Ge,It("inline",Ge)},key:`inline-${gt}-${I}`,src:V,className:["absolute inset-0 w-full h-full object-cover",W,j?"pointer-events-auto":"pointer-events-none"].filter(Boolean).join(" "),autoPlay:!0,muted:N,controls:j,loop:P,poster:Gi&&di||void 0,onLoadedMetadata:xs,onError:()=>Xe(!1)}):null,!Mt&&fi&&!(vt&&a==="teaser")?m.jsx("video",{src:qt,className:"hidden",muted:!0,playsInline:!0,preload:"auto",onLoadedData:()=>St(!0),onCanPlay:()=>St(!0),onError:()=>{ke(!1),St(!1)}},`teaser-prewarm-${gt}`):null,!Mt&&vt&&a==="teaser"?m.jsx("video",{ref:Ge=>{Te.current=Ge,It("teaser",Ge)},src:qt,className:["absolute inset-0 w-full h-full object-cover pointer-events-none",W,ct?"opacity-100":"opacity-0","transition-opacity duration-150"].filter(Boolean).join(" "),muted:N,playsInline:!0,autoPlay:!0,loop:!0,preload:ct?"auto":"metadata",poster:Gi&&di||void 0,onLoadedData:()=>St(!0),onPlaying:()=>St(!0),onError:()=>{ke(!1),St(!1)}},`teaser-mp4-${gt}`):null,!Mt&&vt&&a==="clips"?m.jsx("video",{ref:Ge=>{Be.current=Ge,It("clips",Ge)},src:V,className:["absolute inset-0 w-full h-full object-cover pointer-events-none",W].filter(Boolean).join(" "),muted:N,playsInline:!0,preload:"metadata",poster:Gi&&di||void 0,onError:()=>Xe(!1)},`clips-${gt}-${qi}`):null,rs?m.jsxs("div",{"aria-hidden":"true",className:["absolute left-0 right-0 bottom-0 z-40 pointer-events-none","h-0.5 group-hover:h-1","transition-[height] duration-150 ease-out","rounded-none group-hover:rounded-full","bg-black/35 dark:bg-white/10","overflow-hidden group-hover:overflow-visible"].join(" "),children:[Fi?m.jsx("div",{className:"absolute inset-0",children:Rs.map((Ge,Lt)=>m.jsx("div",{className:"absolute top-0 bottom-0 bg-white/15 dark:bg-white/20",style:{left:`${Ge.left*100}%`,width:`${Ge.width*100}%`}},`seg-${Lt}-${Ge.left.toFixed(6)}-${Ge.width.toFixed(6)}`))}):null,m.jsx("div",{className:["absolute inset-0 origin-left",$i==="teaser"?"":"transition-transform duration-150 ease-out"].join(" "),style:{transform:`scaleX(${ci(Cs)})`,background:"rgba(99,102,241,0.95)"}})]}):null,ds?m.jsx("video",{src:V,preload:"metadata",muted:N,playsInline:!0,className:"hidden",onLoadedMetadata:xs}):null]});return w?m.jsx(ck,{content:Ge=>Ge&&m.jsx("div",{className:"w-[420px]",children:m.jsx("div",{className:"aspect-video",children:m.jsx("video",{src:V,className:["w-full h-full bg-black",W].filter(Boolean).join(" "),muted:K,playsInline:!0,preload:"metadata",controls:!0,autoPlay:!0,loop:!0,onClick:Lt=>Lt.stopPropagation(),onMouseDown:Lt=>Lt.stopPropagation()})})}),children:Hi}):Hi}function Ri(...s){return s.filter(Boolean).join(" ")}const e3=s=>(s||"").replaceAll("\\","/").trim().split("/").pop()||"",t3=s=>s.startsWith("HOT ")?s.slice(4):s,i3=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function s3(s){const t=t3(e3(s||"")).replace(/\.[^.]+$/,""),i=t.match(i3);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t||null}function ga({job:s,variant:e="overlay",collapseToMenu:t=!1,inlineCount:i,busy:n=!1,compact:r=!1,isHot:a=!1,isFavorite:u=!1,isLiked:c=!1,isWatching:d=!1,onToggleFavorite:f,onToggleLike:g,onToggleHot:y,onKeep:v,onDelete:T,onToggleWatch:S,onAddToDownloads:w,order:L,className:O}){const I=e==="overlay"?r?"p-1.5":"p-2":"p-1.5",j=r?"size-4":"size-5",P="h-full w-full",G=e==="table"?`inline-flex items-center justify-center rounded-md ${I} hover:bg-gray-100/70 dark:hover:bg-white/5 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/60 disabled:opacity-50 disabled:cursor-not-allowed transition-transform active:scale-95`:`inline-flex items-center justify-center rounded-md bg-white/75 ${I} text-gray-900 backdrop-blur ring-1 ring-black/10 hover:bg-white/90 dark:bg-black/40 dark:text-white dark:ring-white/10 dark:hover:bg-black/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500/60 dark:focus-visible:ring-white/40 disabled:opacity-50 disabled:cursor-not-allowed transition-transform active:scale-95`,N=e==="table"?{favOn:"text-amber-600 dark:text-amber-300",likeOn:"text-rose-600 dark:text-rose-300",hotOn:"text-amber-600 dark:text-amber-300",off:"text-gray-500 dark:text-gray-300",keep:"text-emerald-600 dark:text-emerald-300",del:"text-red-600 dark:text-red-300",watchOn:"text-sky-600 dark:text-sky-300"}:{favOn:"text-amber-600 dark:text-amber-300",likeOn:"text-rose-600 dark:text-rose-300",hotOn:"text-amber-600 dark:text-amber-300",off:"text-gray-800/90 dark:text-white/90",keep:"text-emerald-600 dark:text-emerald-200",del:"text-red-600 dark:text-red-300",watchOn:"text-sky-600 dark:text-sky-200"},K=L??["watch","favorite","like","hot","keep","delete","details"],k=gt=>K.includes(gt),R=String(s?.sourceUrl??"").trim(),Y=s3(s.output||""),z=Y?`Mehr zu ${Y} anzeigen`:"Mehr anzeigen",X=k("favorite"),re=k("like"),J=k("hot"),W=k("watch"),q=k("keep"),Z=k("delete"),te=k("details")&&!!Y,oe=k("add"),[F,le]=b.useState("idle"),ge=b.useRef(null);b.useEffect(()=>()=>{ge.current&&window.clearTimeout(ge.current)},[]);const Ie=()=>{le("ok"),ge.current&&window.clearTimeout(ge.current),ge.current=window.setTimeout(()=>le("idle"),800)},Le=async()=>{if(n||F==="busy"||!w&&!!!R)return!1;le("busy");try{let V=!0;return w?V=await w(s)!==!1:R?(window.dispatchEvent(new CustomEvent("downloads:add-url",{detail:{url:R}})),V=!0):V=!1,V?Ie():le("idle"),V}catch{return le("idle"),!1}},[Pe,Je]=b.useState(0),[Se,Re]=b.useState(4),Ve=gt=>V=>{V.preventDefault(),V.stopPropagation(),!(n||!gt)&&Promise.resolve(gt(s)).catch(()=>{})},Ee=te?m.jsxs("button",{type:"button",className:Ri(G),title:z,"aria-label":z,disabled:n,onClick:gt=>{gt.preventDefault(),gt.stopPropagation(),!n&&window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:Y}}))},children:[m.jsx("span",{className:Ri("inline-flex items-center justify-center",j),children:m.jsx(t2,{className:Ri(P,N.off)})}),m.jsx("span",{className:"sr-only",children:z})]}):null,_e=oe?m.jsxs("button",{type:"button",className:Ri(G),title:R?"URL zu Downloads hinzufügen":"Keine URL vorhanden","aria-label":"Zu Downloads hinzufügen",disabled:n||F==="busy"||!w&&!R,onClick:async gt=>{gt.preventDefault(),gt.stopPropagation(),await Le()},children:[m.jsx("span",{className:Ri("inline-flex items-center justify-center",j),children:F==="ok"?m.jsx(BM,{className:Ri(P,"text-emerald-600 dark:text-emerald-300")}):m.jsx(Q_,{className:Ri(P,N.off)})}),m.jsx("span",{className:"sr-only",children:"Zu Downloads"})]}):null,yt=X?m.jsx("button",{type:"button",className:G,title:u?"Favorit entfernen":"Als Favorit markieren","aria-label":u?"Favorit entfernen":"Als Favorit markieren","aria-pressed":u,disabled:n||!f,onClick:Ve(f),children:m.jsxs("span",{className:Ri("relative inline-block",j),children:[m.jsx(y0,{className:Ri("absolute inset-0 transition-all duration-200 ease-out motion-reduce:transition-none",u?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",P,N.off)}),m.jsx(Mc,{className:Ri("absolute inset-0 transition-all duration-200 ease-out motion-reduce:transition-none",u?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",P,N.favOn)})]})}):null,ut=re?m.jsx("button",{type:"button",className:G,title:c?"Gefällt mir entfernen":"Als Gefällt mir markieren","aria-label":c?"Gefällt mir entfernen":"Als Gefällt mir markieren","aria-pressed":c,disabled:n||!g,onClick:Ve(g),children:m.jsxs("span",{className:Ri("relative inline-block",j),children:[m.jsx(Th,{className:Ri("absolute inset-0 transition-all duration-200 ease-out motion-reduce:transition-none",c?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",P,N.off)}),m.jsx(_u,{className:Ri("absolute inset-0 transition-all duration-200 ease-out motion-reduce:transition-none",c?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",P,N.likeOn)})]})}):null,pt=J?m.jsx("button",{type:"button","data-hot-target":!0,className:G,title:a?"HOT entfernen":"Als HOT markieren","aria-label":a?"HOT entfernen":"Als HOT markieren","aria-pressed":a,disabled:n||!y,onClick:Ve(y),children:m.jsxs("span",{className:Ri("relative inline-block",j),children:[m.jsx(e2,{className:Ri("absolute inset-0 transition-all duration-200 ease-out",a?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",P,N.off)}),m.jsx(fx,{className:Ri("absolute inset-0 transition-all duration-200 ease-out",a?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",P,N.hotOn)})]})}):null,Fe=W?m.jsx("button",{type:"button",className:G,title:d?"Watched entfernen":"Als Watched markieren","aria-label":d?"Watched entfernen":"Als Watched markieren","aria-pressed":d,disabled:n||!S,onClick:Ve(S),children:m.jsxs("span",{className:Ri("relative inline-block",j),children:[m.jsx(g0,{className:Ri("absolute inset-0 transition-all duration-200 ease-out",d?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",P,N.off)}),m.jsx(Su,{className:Ri("absolute inset-0 transition-all duration-200 ease-out",d?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",P,N.watchOn)})]})}):null,_t=q?m.jsx("button",{type:"button",className:G,title:"Behalten (nach keep verschieben)","aria-label":"Behalten",disabled:n||!v,onClick:Ve(v),children:m.jsx("span",{className:Ri("inline-flex items-center justify-center",j),children:m.jsx(Z_,{className:Ri(P,N.keep)})})}):null,Qe=Z?m.jsx("button",{type:"button",className:G,title:"Löschen","aria-label":"Löschen",disabled:n||!T,onClick:Ve(T),children:m.jsx("span",{className:Ri("inline-flex items-center justify-center",j),children:m.jsx(s2,{className:Ri(P,N.del)})})}):null,Xe={details:Ee,add:_e,favorite:yt,like:ut,watch:Fe,hot:pt,keep:_t,delete:Qe},ze=t,Ze=K.filter(gt=>!!Xe[gt]),ct=ze&&typeof i!="number",ke=(r?16:20)+(e==="overlay"?r?6:8:6)*2,De=r?2:3,Ue=b.useMemo(()=>{if(!ct)return i??De;const gt=Pe||0;if(gt<=0)return Math.min(Ze.length,De);for(let V=Ze.length;V>=0;V--)if(V*ke+ke+(V>0?V*Se:0)<=gt)return V;return 0},[ct,i,De,Pe,Ze.length,ke,Se]),at=ze?Ze.slice(0,Ue):Ze,dt=ze?Ze.slice(Ue):[],[wt,kt]=b.useState(!1),Tt=b.useRef(null);b.useLayoutEffect(()=>{const gt=Tt.current;if(!gt||typeof window>"u")return;const V=()=>{const ie=Tt.current;if(!ie)return;const Te=Math.floor(ie.getBoundingClientRect().width||0);Te>0&&Je(Te);const Be=window.getComputedStyle(ie),ht=Be.columnGap||Be.gap||"0",It=parseFloat(ht);Number.isFinite(It)&&It>=0&&Re(It)};V();const $=new ResizeObserver(()=>V());return $.observe(gt),window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),$.disconnect()}},[]);const Ft=b.useRef(null),Qt=b.useRef(null),Zt=208,Et=4,Dt=8,[yi,Pi]=b.useState(null);b.useEffect(()=>{if(!wt)return;const gt=$=>{$.key==="Escape"&&kt(!1)},V=$=>{const ie=Tt.current,Te=Qt.current,Be=$.target;ie&&ie.contains(Be)||Te&&Te.contains(Be)||kt(!1)};return window.addEventListener("keydown",gt),window.addEventListener("mousedown",V),()=>{window.removeEventListener("keydown",gt),window.removeEventListener("mousedown",V)}},[wt]),b.useLayoutEffect(()=>{if(!wt){Pi(null);return}const gt=()=>{const V=Ft.current;if(!V)return;const $=V.getBoundingClientRect(),ie=window.innerWidth,Te=window.innerHeight;let Be=$.right-Zt;Be=Math.max(Dt,Math.min(Be,ie-Zt-Dt));let ht=$.bottom+Et;ht=Math.max(Dt,Math.min(ht,Te-Dt));const It=Math.max(120,Te-ht-Dt);Pi({top:ht,left:Be,maxH:It})};return gt(),window.addEventListener("resize",gt),window.addEventListener("scroll",gt,!0),()=>{window.removeEventListener("resize",gt),window.removeEventListener("scroll",gt,!0)}},[wt]);const Jt=()=>{Y&&window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:Y}}))},ki=gt=>gt==="details"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n,onClick:V=>{V.preventDefault(),V.stopPropagation(),kt(!1),Jt()},children:[m.jsx(t2,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:"Details"})]},"details"):gt==="add"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!w&&!R,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await Le()},children:[m.jsx(Q_,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:"Zu Downloads"})]},"add"):gt==="favorite"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!f,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await f?.(s)},children:[u?m.jsx(Mc,{className:Ri("size-4",N.favOn)}):m.jsx(y0,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:u?"Favorit entfernen":"Als Favorit markieren"})]},"favorite"):gt==="like"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!g,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await g?.(s)},children:[c?m.jsx(_u,{className:Ri("size-4",N.favOn)}):m.jsx(Th,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:c?"Gefällt mir entfernen":"Gefällt mir"})]},"like"):gt==="watch"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!S,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await S?.(s)},children:[d?m.jsx(Su,{className:Ri("size-4",N.favOn)}):m.jsx(g0,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:d?"Watched entfernen":"Watched"})]},"watch"):gt==="hot"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!y,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await y?.(s)},children:[a?m.jsx(fx,{className:Ri("size-4",N.favOn)}):m.jsx(e2,{className:Ri("size-4",N.off)}),m.jsx("span",{className:"truncate",children:a?"HOT entfernen":"Als HOT markieren"})]},"hot"):gt==="keep"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!v,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await v?.(s)},children:[m.jsx(Z_,{className:Ri("size-4",N.keep)}),m.jsx("span",{className:"truncate",children:"Behalten"})]},"keep"):gt==="delete"?m.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-gray-100/70 dark:hover:bg-white/5 disabled:opacity-50",disabled:n||!T,onClick:async V=>{V.preventDefault(),V.stopPropagation(),kt(!1),await T?.(s)},children:[m.jsx(s2,{className:Ri("size-4",N.del)}),m.jsx("span",{className:"truncate",children:"Löschen"})]},"delete"):null;return m.jsxs("div",{ref:Tt,className:Ri("relative flex items-center flex-nowrap",O??"gap-2"),children:[at.map(gt=>{const V=Xe[gt];return V?m.jsx(b.Fragment,{children:V},gt):null}),ze&&dt.length>0?m.jsxs("div",{className:"relative",children:[m.jsx("button",{ref:Ft,type:"button",className:G,"aria-label":"Mehr",title:"Mehr","aria-haspopup":"menu","aria-expanded":wt,disabled:n,onClick:gt=>{gt.preventDefault(),gt.stopPropagation(),!n&&kt(V=>!V)},children:m.jsx("span",{className:Ri("inline-flex items-center justify-center",j),children:m.jsx(sM,{className:Ri(P,N.off)})})}),wt&&yi&&typeof document<"u"?Nc.createPortal(m.jsx("div",{ref:Qt,role:"menu",className:"rounded-md bg-white/95 dark:bg-gray-900/95 shadow-lg ring-1 ring-black/10 dark:ring-white/10 p-1 z-[9999] overflow-auto",style:{position:"fixed",top:yi.top,left:yi.left,width:Zt,maxHeight:yi.maxH},onClick:gt=>gt.stopPropagation(),children:dt.map(ki)}),document.body):null]}):null]})}function Zr({tag:s,children:e,title:t,active:i,onClick:n,maxWidthClassName:r="max-w-[11rem]",className:a,stopPropagation:u=!0}){const c=s??(typeof e=="string"||typeof e=="number"?String(e):""),d=ni("inline-flex shrink-0 items-center truncate rounded-md px-2 py-0.5 text-xs",r,"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-200"),y=ni(d,i?"bg-sky-100 text-sky-800 dark:bg-sky-400/20 dark:text-sky-100":"",n?"cursor-pointer hover:bg-sky-100 dark:hover:bg-sky-400/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500":"",a),v=S=>S.stopPropagation(),T=u?{onPointerDown:v,onMouseDown:v}:{};return n?m.jsx("button",{type:"button",className:y,title:t??c,"aria-pressed":!!i,...T,onClick:S=>{u&&(S.preventDefault(),S.stopPropagation()),c&&n(c)},children:e??s}):m.jsx("span",{className:y,title:t??c,...T,onClick:u?v:void 0,children:e??s})}function pb({rowKey:s,tags:e,activeTagSet:t,lower:i,onToggleTagFilter:n,maxVisible:r,maxWidthClassName:a,gapPx:u=6,className:c}){const[d,f]=b.useState(!1),g=b.useRef(null),y=b.useRef(null),v=b.useRef(null);b.useEffect(()=>f(!1),[s]),b.useEffect(()=>{if(!d)return;const N=K=>{K.key==="Escape"&&f(!1)};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[d]);const T=b.useMemo(()=>typeof r=="number"&&r>0?r:Number.POSITIVE_INFINITY,[r]),S=b.useMemo(()=>[...e].sort((N,K)=>N.localeCompare(K,void 0,{sensitivity:"base"})),[e]),[w,L]=b.useState(()=>{const N=Math.min(S.length,T);return Math.min(N,6)}),O=b.useCallback(()=>{const N=g.current,K=y.current;if(!N||!K)return;const k=Math.floor(N.getBoundingClientRect().width);if(k<=0)return;const R=Math.min(S.length,T);if(R<=0){L(0);return}const z=Array.from(K.children).map(q=>q.offsetWidth).slice(0,R),X=v.current?.offsetWidth??0,re=2,J=q=>{let Z=0,te=0;for(let oe=0;oe<z.length;oe++){const F=z[oe]+(te>0?u:0);if(Z+F<=q-re)Z+=F,te++;else break}return te};let W=J(k);if(W<R){const q=X>0?X+u:0,Z=Math.max(0,k-q);W=J(Z),W=Math.max(0,W)}L(Math.max(0,Math.min(W,R)))},[S,T,u]);b.useLayoutEffect(()=>{O()},[O,S.join("\0"),a,T]),b.useEffect(()=>{const N=g.current;if(!N)return;const K=new ResizeObserver(()=>O());return K.observe(N),()=>K.disconnect()},[O]);const I=Math.min(S.length,T),j=S.slice(0,Math.min(w,I)),P=N=>N.stopPropagation(),G=S.length-j.length;return m.jsxs(m.Fragment,{children:[d?null:m.jsxs("div",{ref:g,className:["mt-2 h-6 flex items-center gap-1.5",c].filter(Boolean).join(" "),onClick:P,onMouseDown:P,onPointerDown:P,children:[m.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:m.jsx("div",{className:"flex flex-nowrap items-center gap-1.5",children:j.length>0?j.map(N=>m.jsx(Zr,{tag:N,active:t.has(i(N)),onClick:n,maxWidthClassName:a},N)):m.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"})})}),G>0?m.jsxs("button",{type:"button",className:["inline-flex shrink-0 items-center truncate rounded-md px-2 py-0.5 text-xs","cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500","bg-gray-100 text-gray-700 hover:bg-gray-200/70","dark:bg-white/10 dark:text-gray-200 dark:hover:bg-white/20"].join(" "),onClick:N=>{N.preventDefault(),N.stopPropagation(),f(!0)},title:"Alle Tags anzeigen","aria-haspopup":"dialog","aria-expanded":!1,children:["+",G]}):null]}),d?m.jsxs("div",{className:["absolute inset-0 z-30","bg-white/60 dark:bg-gray-950","px-3 py-3","pointer-events-auto"].join(" "),onClick:P,onMouseDown:P,onPointerDown:P,role:"dialog","aria-label":"Tags",children:[m.jsx("button",{type:"button",className:`\r
absolute right-2 top-2 z-10\r
rounded-md bg-gray-100/80 px-2 py-1 text-xs font-semibold text-gray-700\r
hover:bg-gray-200/80\r
dark:bg-white/10 dark:text-gray-200 dark:hover:bg-white/20\r
`,onClick:()=>f(!1),"aria-label":"Schließen",title:"Schließen",children:"✕"}),m.jsx("div",{className:"h-full overflow-auto pr-1",children:m.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.map(N=>m.jsx(Zr,{tag:N,active:t.has(i(N)),onClick:n,maxWidthClassName:a},N))})})]}):null,m.jsxs("div",{className:"absolute -left-[9999px] -top-[9999px] opacity-0 pointer-events-none",children:[m.jsx("div",{ref:y,className:"flex flex-nowrap items-center gap-1.5",children:S.slice(0,I).map(N=>m.jsx(Zr,{tag:N,active:t.has(i(N)),onClick:n,maxWidthClassName:a},N))}),m.jsx("button",{ref:v,type:"button",className:"inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-700 ring-1 ring-inset ring-gray-200",children:"+99"})]})]})}function r2(s,e,t){return Math.max(e,Math.min(t,s))}function n3(s){const e=Math.max(0,Math.floor(s)),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}function dk({imageCount:s,activeIndex:e,onActiveIndexChange:t,onIndexClick:i,className:n,stepSeconds:r=0}){const a=b.useRef(null),u=b.useRef(null),c=b.useRef(void 0),d=b.useCallback(()=>{u.current=null,t(c.current)},[t]),f=b.useCallback(P=>{c.current=P,u.current==null&&(u.current=window.requestAnimationFrame(d))},[d]);b.useEffect(()=>()=>{u.current!=null&&(window.cancelAnimationFrame(u.current),u.current=null)},[]);const g=b.useCallback(P=>{if(!a.current||s<1)return;const G=a.current.getBoundingClientRect();if(G.width<=0)return;const N=P-G.left,K=r2(N/G.width,0,.999999);return r2(Math.floor(K*s),0,s-1)},[s]),y=b.useCallback(P=>{const G=g(P.clientX);f(G)},[g,f]),v=b.useCallback(P=>{const G=g(P.clientX);f(G)},[g,f]),T=b.useCallback(()=>{f(void 0)},[f]),S=b.useCallback(P=>{P.stopPropagation();const G=g(P.clientX);f(G);try{P.currentTarget.setPointerCapture?.(P.pointerId)}catch{}},[g,f]),w=b.useCallback(P=>{if(P.stopPropagation(),!i)return;const G=g(P.clientX);typeof G=="number"&&i(G)},[g,i]);if(!s||s<1)return null;const L=typeof e=="number"?(e+.5)/s*100:void 0,O=typeof e=="number"?r>0?n3(e*r):`${e+1}/${s}`:"",I=typeof e=="number",j=typeof L=="number"?{left:`clamp(24px, ${L}%, calc(100% - 24px))`,transform:"translateX(-50%)"}:void 0;return m.jsxs("div",{ref:a,className:["relative h-7 w-full select-none touch-none cursor-col-resize","opacity-0 transition-opacity duration-150","pointer-events-none","group-hover:opacity-100 group-focus-within:opacity-100","group-hover:pointer-events-auto group-focus-within:pointer-events-auto",n].filter(Boolean).join(" "),onPointerMove:y,onPointerEnter:v,onPointerLeave:T,onPointerDown:S,onMouseDown:P=>P.stopPropagation(),onClick:w,title:I?O:`Preview scrubber (${s})`,role:"slider","aria-label":"Preview scrubber","aria-valuemin":1,"aria-valuemax":s,"aria-valuenow":typeof e=="number"?e+1:void 0,children:[m.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-white/35 ring-1 ring-white/40 backdrop-blur-[1px]",children:typeof L=="number"?m.jsx("div",{className:"absolute inset-y-0 w-[2px] bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.35)]",style:{left:`${L}%`,transform:"translateX(-50%)"}}):null}),m.jsx("div",{className:["pointer-events-none absolute bottom-[19px] z-10","rounded bg-black/70 px-1.5 py-0.5","text-[11px] leading-none text-white whitespace-nowrap","transition-opacity duration-100",I?"opacity-100":"opacity-0","[text-shadow:_0_1px_2px_rgba(0,0,0,0.9)]"].join(" "),style:j,children:O})]})}const hk=/^HOT[ \u00A0]+/i,fk=s=>String(s||"").replaceAll(" "," "),xc=s=>hk.test(fk(s)),vr=s=>fk(s).replace(hk,"");function gb(s){if(!s)return"";const e=Math.round(Number(s.w)),t=Math.round(Number(s.h));if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return"";const i=Math.min(e,t),n=Math.max(12,Math.round(i*.02)),r=a=>Math.abs(i-a)<=n;return r(4320)?"8K":r(2160)||i>=2e3?"4K":r(1440)?"1440p":r(1080)?"1080p":r(720)?"720p":r(480)?"480p":r(360)?"360p":r(240)?"240p":`${i}p`}const r3=s=>{const e=String(s??"").trim();if(!e)return[];const t=e.split(/[\n,;|]+/g).map(r=>r.trim()).filter(Boolean),i=new Set,n=[];for(const r of t){const a=r.toLowerCase();i.has(a)||(i.add(a),n.push(r))}return n};function a3(...s){for(const e of s)if(typeof e=="string"){const t=e.trim();if(t)return t}}function By(s){if(!(typeof s!="number"||!Number.isFinite(s)||s<=0))return s>1440*60?s/1e3:s}function a2(s,e,t){return Math.max(e,Math.min(t,s))}const o3=5;function l3(s){if(s<=1)return[1,1];const e=16/9;let t=1,i=s,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY;for(let a=1;a<=s;a++){const u=Math.max(1,Math.ceil(s/a)),c=a*u-s,d=a/u,f=Math.abs(d-e);(c<n||c===n&&f<r||c===n&&f===r&&u<i)&&(n=c,r=f,t=a,i=u)}return[t,i]}function u3({blurred:s,animateUnblurOnMount:e,children:t}){const[i,n]=b.useState(!e);b.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{n(!0)});return()=>cancelAnimationFrame(a)},[e]);const r=["relative will-change-[filter,transform] transition-[filter,transform,opacity] duration-180 ease-out",s?"blur-[1.5px] saturate-90 scale-[0.995]":i?"blur-0 saturate-100 scale-100":"blur-[1.5px] saturate-90 scale-[0.995]"].filter(Boolean).join(" ");return m.jsx("div",{className:r,children:t})}function c3({animateOnMount:s,children:e}){const[t,i]=b.useState(!s);return b.useEffect(()=>{if(!s)return;const n=requestAnimationFrame(()=>{i(!0)});return()=>cancelAnimationFrame(n)},[s]),m.jsx("div",{className:"will-change-[transform,opacity] transition-[transform,opacity] duration-160 ease-out motion-reduce:transition-none",style:{transform:t?"translateY(0px) scale(1) translateZ(0)":"translateY(-15px) scale(0.97) translateZ(0)",opacity:t?1:.92,transformOrigin:"top center"},children:e})}function d3({rows:s,isSmall:e,isLoading:t,teaserPlayback:i,teaserAudio:n,hoverTeaserKey:r,blurPreviews:a,durations:u,teaserKey:c,inlinePlay:d,deletingKeys:f,keepingKeys:g,removingKeys:y,swipeRefs:v,assetNonce:T,handleScrubberClickIndex:S,keyFor:w,baseName:L,modelNameFromOutput:O,runtimeOf:I,sizeBytesOf:j,formatBytes:P,lower:G,onHoverPreviewKeyChange:N,onOpenPlayer:K,openPlayer:k,startInlineAt:R,startInline:Y,tryAutoplayInline:z,registerTeaserHost:X,handleDuration:re,deleteVideo:J,keepVideo:W,modelsByKey:q,activeTagSet:Z,onToggleTagFilter:te,onToggleHot:oe,onToggleFavorite:F,onToggleLike:le,onToggleWatch:ge,enqueueDeleteVideo:Ie,enqueueKeepVideo:Le,enqueueToggleHot:Pe}){const Je=b.useCallback(se=>{const ke=se?.meta;if(!ke)return null;if(typeof ke=="string")try{return JSON.parse(ke)}catch{return null}return ke},[]),Se=b.useCallback(se=>{const ke=Je(se),De=(typeof ke?.videoWidth=="number"&&Number.isFinite(ke.videoWidth)?ke.videoWidth:0)||(typeof se.videoWidth=="number"&&Number.isFinite(se.videoWidth)?se.videoWidth:0),Ue=(typeof ke?.videoHeight=="number"&&Number.isFinite(ke.videoHeight)?ke.videoHeight:0)||(typeof se.videoHeight=="number"&&Number.isFinite(se.videoHeight)?se.videoHeight:0);return De>0&&Ue>0?{w:De,h:Ue}:null},[Je]),Re=b.useCallback(se=>{const ke=Je(se);let De=ke?.previewSprite??ke?.preview?.sprite??ke?.sprite??se?.previewSprite??se?.preview?.sprite??null;if(typeof De=="string")try{De=JSON.parse(De)}catch{De=null}const Ue=Number(De?.count??De?.frames??De?.imageCount),at=Number(De?.stepSeconds??De?.step??De?.intervalSeconds);if(Number.isFinite(Ue)&&Ue>=2)return{count:Math.max(2,Math.floor(Ue)),stepSeconds:Number.isFinite(at)&&at>0?at:5};const dt=w(se),wt=u[dt]??(typeof se?.durationSeconds=="number"?se.durationSeconds:void 0);return typeof wt=="number"&&Number.isFinite(wt)&&wt>1?{count:Math.max(2,Math.min(240,Math.floor(wt/5)+1)),stepSeconds:5}:null},[Je,w,u]),[Ve,Ee]=b.useState({}),[_e,yt]=b.useState({}),ut=b.useCallback((se,ke)=>{Ee(De=>{if(ke===void 0){if(!(se in De))return De;const Ue={...De};return delete Ue[se],Ue}return De[se]===ke?De:{...De,[se]:ke}})},[]),pt=b.useCallback(se=>{ut(se,void 0)},[ut]),Fe=b.useCallback((se,ke)=>{yt(De=>{if(ke===void 0){if(!(se in De))return De;const Ue={...De};return delete Ue[se],Ue}return De[se]===ke?De:{...De,[se]:ke}})},[]),_t=(se,ke)=>{const De=w(se),Ue=d?.key===De,at=ke?.disableInline?!1:Ue,wt=!(!ke?.forceStill&&!!n&&(at||r===De)),kt=at?d?.nonce??0:0,Tt=!!ke?.forceLoadStill,Ft=ke?.forceStill?!1:ke?.mobileStackTopOnlyVideo?i!=="still":i==="all"?!0:i==="hover"?c===De:!1,Qt=f.has(De)||g.has(De)||y.has(De),Zt=O(se.output),Et=L(se.output||""),Dt=vr(Et.replace(/\.[^.]+$/,"")).trim(),yi=G(Zt),Pi=q[yi],Jt=Je(se),ki=Re(se),gt=Ve[De],V=_e[De]===!0,$=a3(Jt?.previewSprite?.path,Jt?.previewSpritePath,Pi?.previewScrubberPath,Dt?`/api/preview-sprite/${encodeURIComponent(Dt)}`:void 0),ie=$?$.replace(/\/+$/,""):void 0,Te=Jt?.previewSprite?.stepSeconds??Jt?.previewSpriteStepSeconds,Be=typeof Te=="number"&&Number.isFinite(Te)&&Te>0?Te:ki?.stepSeconds&&ki.stepSeconds>0?ki.stepSeconds:o3,ht=By(Jt?.durationSeconds)??By(se?.durationSeconds)??By(u[De]),It=typeof ht=="number"&&ht>0?Math.max(1,Math.min(200,Math.floor(ht/Be)+1)):void 0,Yt=Jt?.previewSprite?.count??Jt?.previewSpriteCount??Pi?.previewScrubberCount??It,pi=Jt?.previewSprite?.cols??Jt?.previewSpriteCols,oi=Jt?.previewSprite?.rows??Jt?.previewSpriteRows,ci=typeof Yt=="number"&&Number.isFinite(Yt)?Math.max(0,Math.floor(Yt)):0,[Bi,Gt]=ci>1?l3(ci):[0,0],xi=Number(pi),ai=Number(oi),di=Number.isFinite(xi)&&Number.isFinite(ai)&&xi>0&&ai>0&&!(ci>1&&xi===1&&ai===1)&&(ci<=1||xi*ai>=ci),qt=di?Math.floor(xi):Bi,Mt=di?Math.floor(ai):Gt,vt=(typeof Jt?.updatedAtUnix=="number"&&Number.isFinite(Jt.updatedAtUnix)?Jt.updatedAtUnix:void 0)??(typeof Jt?.fileModUnix=="number"&&Number.isFinite(Jt.fileModUnix)?Jt.fileModUnix:void 0)??T??0,Ci=ie&&vt?`${ie}?v=${encodeURIComponent(String(vt))}`:ie||void 0,ss=!!Ci&&ci>1,vs=ss&&qt>0&&Mt>0,xs=ss?ci:0,Gi=ss?Be:0,fi=typeof gt=="number"&&xs>1?a2(gt/(xs-1),0,1):void 0,Zi=vs&&typeof gt=="number"?(()=>{const Kt=a2(gt,0,Math.max(0,ci-1)),ds=Kt%qt,Fi=Math.floor(Kt/qt),Hi=qt<=1?0:ds/(qt-1)*100,Ge=Mt<=1?0:Fi/(Mt-1)*100;return{backgroundImage:`url("${Ci}")`,backgroundRepeat:"no-repeat",backgroundSize:`${qt*100}% ${Mt*100}%`,backgroundPosition:`${Hi}% ${Ge}%`}})():void 0,ts=xc(Et),$i=!!Pi?.favorite,Ji=Pi?.liked===!0,Di=!!Pi?.watching,$s=r3(Pi?.tags),Cs=I(se),ns=P(j(se)),rs=Se(se),Rs=gb(rs),Li=`inline-prev-${encodeURIComponent(De)}`,qi=["group relative rounded-lg overflow-hidden outline-1 outline-black/5 dark:-outline-offset-1 dark:outline-white/10","bg-white dark:bg-gray-900/40","transition-all duration-200",!e&&"hover:-translate-y-0.5 hover:shadow-md dark:hover:shadow-none","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500",Qt&&"pointer-events-none opacity-70",f.has(De)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30",g.has(De)&&"ring-1 ring-emerald-300 bg-emerald-50/60 dark:bg-emerald-500/10 dark:ring-emerald-500/30",y.has(De)&&"opacity-0 translate-y-2 scale-[0.98]"].filter(Boolean).join(" "),bs=m.jsx("div",{role:"button",tabIndex:0,className:qi,onClick:e?void 0:()=>k(se),onKeyDown:Kt=>{(Kt.key==="Enter"||Kt.key===" ")&&(Kt.preventDefault(),K(se))},children:m.jsx(u3,{blurred:ke?.blur,animateUnblurOnMount:ke?.animateUnblurOnMount,children:m.jsxs(pa,{noBodyPadding:!0,className:"overflow-hidden bg-transparent",children:[m.jsx("div",{id:Li,ref:ke?.disableInline||ke?.isDecorative?void 0:X(De),className:"group/thumb relative aspect-video rounded-t-lg bg-black/5 dark:bg-white/5",onMouseEnter:e||ke?.disablePreviewHover?void 0:()=>N?.(De),onMouseLeave:()=>{!e&&!ke?.disablePreviewHover&&N?.(null),pt(De)},onClick:Kt=>{Kt.preventDefault(),Kt.stopPropagation(),!(e||ke?.disableInline)&&Y(De)},children:m.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-t-lg",children:[at?null:m.jsx("div",{className:"pointer-events-none absolute right-2 bottom-2 z-10 transition-opacity duration-150 group-hover/thumb:opacity-0 group-focus-within/thumb:opacity-0 "+(at?"opacity-0":"opacity-100"),children:m.jsxs("div",{className:"flex items-center gap-1.5 text-right text-[11px] font-semibold leading-none text-white [text-shadow:_0_1px_0_rgba(0,0,0,0.95),_1px_0_0_rgba(0,0,0,0.95),_-1px_0_0_rgba(0,0,0,0.95),_0_-1px_0_rgba(0,0,0,0.95),_1px_1px_0_rgba(0,0,0,0.8),_-1px_1px_0_rgba(0,0,0,0.8),_1px_-1px_0_rgba(0,0,0,0.8),_-1px_-1px_0_rgba(0,0,0,0.8)]",title:[Cs,rs?`${rs.w}×${rs.h}`:Rs||"",ns].filter(Boolean).join(" • "),children:[m.jsx("span",{children:Cs}),Rs?m.jsx("span",{"aria-hidden":"true",children:"•"}):null,Rs?m.jsx("span",{children:Rs}):null,m.jsx("span",{"aria-hidden":"true",children:"•"}),m.jsx("span",{children:ns})]})}),m.jsx(b0,{job:se,getFileName:Kt=>vr(L(Kt)),className:"h-full w-full",variant:"fill",durationSeconds:u[De]??se?.durationSeconds,onDuration:re,showPopover:!1,blur:at?!1:!!a,animated:Ft,animatedMode:"teaser",animatedTrigger:"always",clipSeconds:1,thumbSamples:18,inlineVideo:!ke?.disableInline&&at?"always":!1,inlineNonce:kt,inlineControls:at,inlineLoop:!1,muted:wt,popoverMuted:wt,assetNonce:T??0,alwaysLoadStill:Tt,teaserPreloadEnabled:ke?.mobileStackTopOnlyVideo||ke?.preloadTeaserWhenStill?!0:!e,teaserPreloadRootMargin:ke?.preloadTeaserWhenStill?"1200px 0px":e?"900px 0px":"700px 0px",scrubProgressRatio:fi,preferScrubProgress:V&&typeof gt=="number"}),vs&&Ci?m.jsx("img",{src:Ci,alt:"",className:"hidden",loading:"lazy",decoding:"async","aria-hidden":"true"}):null,vs&&Zi&&!at?m.jsx("div",{className:"absolute inset-x-0 top-0 bottom-[6px] z-[5]","aria-hidden":"true",children:m.jsx("div",{className:"h-full w-full",style:Zi})}):null,!ke?.isDecorative&&!ke?.disableScrubber&&!at&&xs>1?m.jsx("div",{className:"absolute inset-x-0 bottom-0 z-30 pointer-events-none opacity-100 transition-opacity duration-150",onClick:Kt=>Kt.stopPropagation(),onMouseDown:Kt=>Kt.stopPropagation(),onMouseEnter:()=>Fe(De,!0),onMouseLeave:()=>{Fe(De,!1),ut(De,void 0)},children:m.jsx(dk,{className:"pointer-events-auto px-1",imageCount:xs,activeIndex:gt,onActiveIndexChange:Kt=>ut(De,Kt),onIndexClick:Kt=>{if(e||ke?.disableInline){S(se,Kt,xs);return}const ds=Gi>0?Kt*Gi:0;if(R){R(De,ds,Li),requestAnimationFrame(()=>{z(Li)||requestAnimationFrame(()=>{z(Li)})});return}Y(De),requestAnimationFrame(()=>{z(Li)||requestAnimationFrame(()=>{z(Li)})})},stepSeconds:Gi})}):null]})}),m.jsxs("div",{className:"relative min-h-[112px] overflow-hidden px-4 py-3 border-t border-black/5 dark:border-white/10 bg-white dark:bg-gray-900",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:Zt}),m.jsxs("div",{className:"mt-0.5 flex items-start gap-2 min-w-0",children:[ts?m.jsx("span",{className:"shrink-0 self-start rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] leading-none font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null,m.jsx("span",{className:"min-w-0 truncate text-xs text-gray-500 dark:text-gray-400",children:vr(Et)||"—"})]})]}),m.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 pt-0.5",children:[Di?m.jsx(Su,{className:"size-4 text-sky-600 dark:text-sky-300"}):null,Ji?m.jsx(_u,{className:"size-4 text-rose-600 dark:text-rose-300"}):null,$i?m.jsx(Mc,{className:"size-4 text-amber-600 dark:text-amber-300"}):null]})]}),m.jsx("div",{className:"mt-2",onClick:Kt=>Kt.stopPropagation(),onMouseDown:Kt=>Kt.stopPropagation(),children:m.jsx("div",{className:"w-full",children:m.jsx("div",{className:"w-full rounded-md bg-gray-50/70 p-1 ring-1 ring-black/5 dark:bg-white/5 dark:ring-white/10",children:m.jsx(ga,{job:se,variant:"table",busy:Qt,collapseToMenu:!0,compact:!1,isHot:ts,isFavorite:$i,isLiked:Ji,isWatching:Di,onToggleWatch:ge,onToggleFavorite:F,onToggleLike:le,onToggleHot:oe,onKeep:W,onDelete:J,order:["watch","favorite","like","hot","keep","delete","details","add"],className:"w-full gap-1.5"})})})}),m.jsx("div",{className:"mt-2",onClick:Kt=>Kt.stopPropagation(),onMouseDown:Kt=>Kt.stopPropagation(),children:m.jsx(pb,{rowKey:De,tags:$s,activeTagSet:Z,lower:G,onToggleTagFilter:te})})]})]})})});return{k:De,j:se,busy:Qt,isHot:ts,inlineDomId:Li,cardInner:bs}},Qe=3,Xe=e?s.slice(0,Qe):[],Ze=e?s.slice(Qe,Qe+4):[],ct=15,St=Math.min(Xe.length,Qe)-1;return m.jsxs("div",{className:"relative",children:[e?m.jsx("div",{className:"relative overflow-y-visible touch-pan-y",style:{overflowX:"clip"},children:s.length===0?null:m.jsxs("div",{className:"relative mx-auto w-full max-w-[560px] overflow-y-visible",style:{overflowX:"clip"},children:[m.jsx("div",{className:"relative overflow-visible",style:{paddingTop:St>0?`${St}px`:void 0},children:(()=>{const se=Xe,ke=se[0],De=se.slice(1);return m.jsxs(m.Fragment,{children:[De.map((Ue,at)=>{const dt=at+1,{k:wt,cardInner:kt}=_t(Ue,{forceStill:!0,disableInline:!0,disablePreviewHover:!0,isDecorative:!0,forceLoadStill:!0,blur:!0,preloadTeaserWhenStill:!0}),Tt=dt,Ft=-(Tt*ct),Qt=1-Tt*.03,Zt=1-Tt*.14;return m.jsx("div",{className:"absolute inset-x-0 top-0 pointer-events-none will-change-[transform,opacity] transition-[transform,opacity] duration-220 ease-out motion-reduce:transition-none",style:{zIndex:20-Tt,transform:`translateY(${Ft}px) scale(${Qt}) translateZ(0)`,opacity:Zt,transformOrigin:"top center"},"aria-hidden":"true",children:m.jsxs("div",{className:"relative",children:[kt,m.jsx("div",{className:"absolute inset-0 rounded-lg bg-white/8 dark:bg-black/8"})]})},wt)}).reverse(),ke?(()=>{const Ue=ke,{k:at,busy:dt,isHot:wt,cardInner:kt,inlineDomId:Tt}=_t(Ue,{forceLoadStill:!0,mobileStackTopOnlyVideo:!0,disableScrubber:!0,animateUnblurOnMount:!0});return m.jsx("div",{className:"relative touch-pan-y",style:{zIndex:30},children:m.jsx(c3,{animateOnMount:!0,children:m.jsx(ZM,{ref:Ft=>{Ft?v.current.set(at,Ft):v.current.delete(at)},enabled:!0,disabled:dt,ignoreFromBottomPx:110,doubleTapMs:360,doubleTapMaxMovePx:48,onDoubleTap:async()=>{if(!wt){if(Pe){Pe(Ue);return}await oe?.(Ue)}},onTap:()=>{Y(at),requestAnimationFrame(()=>{z(Tt)||requestAnimationFrame(()=>z(Tt))})},onSwipeLeft:()=>Ie?Ie(Ue):J(Ue),onSwipeRight:()=>Le?Le(Ue):W(Ue),children:kt})})},at)})():null]})})()}),Ze.length>0?m.jsx("div",{className:"sr-only","aria-hidden":"true",children:Ze.map(se=>{const ke=w(se);return m.jsx("div",{className:"relative aspect-video",children:m.jsx(b0,{job:se,getFileName:L,className:"h-full w-full",showPopover:!1,blur:!!a,animated:!1,teaserPreloadEnabled:!0,teaserPreloadRootMargin:"1200px 0px",animatedMode:"teaser",animatedTrigger:"always",inlineVideo:!1,inlineControls:!1,inlineLoop:!1,muted:!0,popoverMuted:!0,assetNonce:T??0,alwaysLoadStill:!0})},`preload-still-${ke}`)})}):null]})}):m.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:s.map(se=>{const{k:ke,cardInner:De}=_t(se);return m.jsx(b.Fragment,{children:De},ke)})}),t&&s.length===0?m.jsx("div",{className:"absolute inset-0 z-20 grid place-items-center rounded-lg bg-white/50 backdrop-blur-[2px] dark:bg-gray-950/40",children:m.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-gray-200 bg-white/80 px-3 py-2 shadow-sm dark:border-white/10 dark:bg-gray-900/70",children:[m.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-white/20 dark:border-t-transparent"}),m.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:"Lade…"})]})}):null]})}function h3({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const f3=b.forwardRef(h3);function m3({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M11.78 5.22a.75.75 0 0 1 0 1.06L8.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06l-4.25-4.25a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const p3=b.forwardRef(m3);function g3({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const y3=b.forwardRef(g3);function v3({title:s,titleId:e,...t},i){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?b.createElement("title",{id:e},s):null,b.createElement("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"}))}const o2=b.forwardRef(v3);function mr(...s){return s.filter(Boolean).join(" ")}function l2(s){return s==="center"?"text-center":s==="right"?"text-right":"text-left"}function x3(s){return s==="center"?"justify-center":s==="right"?"justify-end":"justify-start"}function u2(s,e){const t=s===0,i=s===e-1;return t||i?"pl-2 pr-2":"px-2"}function c2(s){return s==null?{isNull:!0,kind:"string",value:""}:s instanceof Date?{isNull:!1,kind:"number",value:s.getTime()}:typeof s=="number"?{isNull:!1,kind:"number",value:s}:typeof s=="boolean"?{isNull:!1,kind:"number",value:s?1:0}:typeof s=="bigint"?{isNull:!1,kind:"number",value:Number(s)}:{isNull:!1,kind:"string",value:String(s).toLocaleLowerCase()}}function Sh({columns:s,rows:e,getRowKey:t,title:i,description:n,actions:r,fullWidth:a=!1,card:u=!0,striped:c=!1,stickyHeader:d=!1,compact:f=!1,isLoading:g=!1,emptyLabel:y="Keine Daten vorhanden.",className:v,rowClassName:T,onRowClick:S,onRowContextMenu:w,sort:L,onSortChange:O,defaultSort:I=null}){const j=f?"py-2":"py-4",P=f?"py-3":"py-3.5",G=L!==void 0,[N,K]=b.useState(I),k=G?L:N,R=b.useCallback(z=>{G||K(z),O?.(z)},[G,O]),Y=b.useMemo(()=>{if(!k)return e;const z=s.find(J=>J.key===k.key);if(!z)return e;const X=k.direction==="asc"?1:-1,re=e.map((J,W)=>({r:J,i:W}));return re.sort((J,W)=>{let q=0;if(z.sortFn)q=z.sortFn(J.r,W.r);else{const Z=z.sortValue?z.sortValue(J.r):J.r?.[z.key],te=z.sortValue?z.sortValue(W.r):W.r?.[z.key],oe=c2(Z),F=c2(te);oe.isNull&&!F.isNull?q=1:!oe.isNull&&F.isNull?q=-1:oe.kind==="number"&&F.kind==="number"?q=oe.value<F.value?-1:oe.value>F.value?1:0:q=String(oe.value).localeCompare(String(F.value),void 0,{numeric:!0})}return q===0?J.i-W.i:q*X}),re.map(J=>J.r)},[e,s,k]);return m.jsxs("div",{className:mr(a?"":"px-4 sm:px-6 lg:px-8",v),children:[(i||n||r)&&m.jsxs("div",{className:"sm:flex sm:items-center",children:[m.jsxs("div",{className:"sm:flex-auto",children:[i&&m.jsx("h1",{className:"text-base font-semibold text-gray-900 dark:text-white",children:i}),n&&m.jsx("p",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:n})]}),r&&m.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-16 sm:flex-none",children:r})]}),m.jsx("div",{className:mr(i||n||r?"mt-8":""),children:m.jsx("div",{className:"flow-root",children:m.jsx("div",{className:"overflow-x-auto",children:m.jsx("div",{className:mr("inline-block min-w-full align-middle",a?"":"sm:px-6 lg:px-8"),children:m.jsx("div",{className:mr(u&&"overflow-hidden shadow-sm outline-1 outline-black/5 rounded-lg dark:shadow-none dark:-outline-offset-1 dark:outline-white/10"),children:m.jsxs("table",{className:"relative min-w-full divide-y divide-gray-200 dark:divide-white/10",children:[m.jsx("thead",{className:mr(u&&"bg-gray-50/90 dark:bg-gray-800/70",d&&"sticky top-0 z-10 backdrop-blur-sm shadow-sm"),children:m.jsx("tr",{children:s.map((z,X)=>{const re=u2(X,s.length),J=!!k&&k.key===z.key,W=J?k.direction:void 0,q=z.sortable&&!z.srOnlyHeader?J?W==="asc"?"ascending":"descending":"none":void 0,Z=()=>{if(!(!z.sortable||z.srOnlyHeader))return R(J?W==="asc"?{key:z.key,direction:"desc"}:null:{key:z.key,direction:"asc"})};return m.jsx("th",{scope:"col","aria-sort":q,className:mr(P,re,"text-xs font-semibold tracking-wide text-gray-700 dark:text-gray-200 whitespace-nowrap",l2(z.align),z.widthClassName,z.headerClassName),children:z.srOnlyHeader?m.jsx("span",{className:"sr-only",children:z.header}):z.sortable?m.jsxs("button",{type:"button",onClick:Z,className:mr("group inline-flex w-full items-center gap-2 select-none rounded-md px-1.5 py-1 -my-1 hover:bg-gray-100/70 dark:hover:bg-white/5",x3(z.align)),children:[m.jsx("span",{children:z.header}),m.jsx("span",{className:mr("flex-none rounded-sm text-gray-400 dark:text-gray-500",J?"bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-white":"invisible group-hover:visible group-focus-visible:visible"),children:m.jsx(f3,{"aria-hidden":"true",className:mr("size-5 transition-transform",J&&W==="asc"&&"rotate-180")})})]}):z.header},z.key)})})}),m.jsx("tbody",{className:mr("divide-y divide-gray-200 dark:divide-white/10",u?"bg-white dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),children:g?m.jsx("tr",{children:m.jsx("td",{colSpan:s.length,className:mr(j,"px-2 text-sm text-gray-500 dark:text-gray-400"),children:"Lädt…"})}):Y.length===0?m.jsx("tr",{children:m.jsx("td",{colSpan:s.length,className:mr(j,"px-2 text-sm text-gray-500 dark:text-gray-400"),children:y})}):Y.map((z,X)=>{const re=t?t(z,X):String(X);return m.jsx("tr",{className:mr(c&&"even:bg-gray-50 dark:even:bg-gray-800/50",S&&"cursor-pointer",S&&"hover:bg-gray-50 dark:hover:bg-white/5 transition-colors",T?.(z,X)),onClick:()=>S?.(z),onContextMenu:w?J=>{J.preventDefault(),w(z,J)}:void 0,children:s.map((J,W)=>{const q=u2(W,s.length),Z=J.cell?.(z,X)??J.accessor?.(z)??z?.[J.key];return m.jsx("td",{className:mr(j,q,"text-sm whitespace-nowrap",l2(J.align),J.className,J.key===s[0]?.key?"font-medium text-gray-900 dark:text-white":"text-gray-500 dark:text-gray-400"),children:Z},J.key)})},re)})})]})})})})})})]})}function b3({rows:s,isLoading:e,keyFor:t,baseName:i,lower:n,modelNameFromOutput:r,runtimeOf:a,sizeBytesOf:u,formatBytes:c,resolutions:d,durations:f,canHover:g,teaserAudio:y,hoverTeaserKey:v,setHoverTeaserKey:T,teaserPlayback:S="hover",teaserKey:w,registerTeaserHost:L,handleDuration:O,handleResolution:I,blurPreviews:j,assetNonce:P,deletingKeys:G,keepingKeys:N,removingKeys:K,modelsByKey:k,activeTagSet:R,onToggleTagFilter:Y,onOpenPlayer:z,onSortModeChange:X,page:re,onPageChange:J,onToggleHot:W,onToggleFavorite:q,onToggleLike:Z,onToggleWatch:te,deleteVideo:oe,keepVideo:F,enqueueDeleteVideo:le,enqueueKeepVideo:ge,enqueueToggleHot:Ie}){const[Le,Pe]=b.useState(null),Je=b.useCallback(Qe=>{const Xe=Qe?.durationSeconds;if(typeof Xe=="number"&&Number.isFinite(Xe)&&Xe>0)return Xe;const ze=Date.parse(String(Qe?.startedAt||"")),Ze=Date.parse(String(Qe?.endedAt||""));if(Number.isFinite(ze)&&Number.isFinite(Ze)&&Ze>ze){const ct=(Ze-ze)/1e3;if(ct>=1&&ct<=1440*60)return ct}return Number.POSITIVE_INFINITY},[]),Se=b.useCallback(Qe=>{const Xe=String(Qe??"").trim();if(!Xe)return[];const ze=Xe.split(/[\n,;|]+/g).map(St=>St.trim()).filter(Boolean),Ze=new Set,ct=[];for(const St of ze){const se=St.toLowerCase();Ze.has(se)||(Ze.add(se),ct.push(St))}return ct.sort((St,se)=>St.localeCompare(se,void 0,{sensitivity:"base"})),ct},[]),Re=b.useCallback(Qe=>{const Xe=Qe?.meta;if(!Xe)return null;if(typeof Xe=="string")try{return JSON.parse(Xe)}catch{return null}return Xe},[]),Ve=b.useCallback(Qe=>{const Xe=Re(Qe);let ze=Xe?.previewSprite??Xe?.preview?.sprite??null;if(typeof ze=="string")try{ze=JSON.parse(ze)}catch{ze=null}const Ze=Number(ze?.count),ct=Number(ze?.stepSeconds);return!Number.isFinite(Ze)||Ze<2?null:{count:Math.max(2,Math.floor(Ze)),stepSeconds:Number.isFinite(ct)&&ct>0?ct:5}},[Re]),[Ee,_e]=b.useState({}),yt=b.useCallback((Qe,Xe)=>{_e(ze=>ze[Qe]===Xe?ze:{...ze,[Qe]:Xe})},[]),ut=b.useMemo(()=>[{key:"preview",header:"Vorschau",widthClassName:"w-[140px]",cell:Qe=>{const Xe=t(Qe),Ze=!(!!y&&v===Xe),ct=Ve(Qe),St=Ee[Xe],se=i(Qe.output||""),ke=vr(se.replace(/\.[^.]+$/,"")).trim(),De=ct&&typeof St=="number"?Math.max(0,St*ct.stepSeconds):void 0,Ue=ke&&typeof De=="number"?`/api/preview?id=${encodeURIComponent(ke)}&t=${De.toFixed(3)}&v=${P??0}`:"";return m.jsxs("div",{ref:L(Xe),className:"group relative py-1",onClick:at=>at.stopPropagation(),onMouseDown:at=>at.stopPropagation(),onMouseEnter:()=>{g&&T(Xe)},onMouseLeave:()=>{g&&T(null),yt(Xe,void 0)},children:[m.jsx(b0,{job:Qe,getFileName:i,durationSeconds:f[Xe],muted:Ze,popoverMuted:Ze,onDuration:O,onResolution:I,className:"w-28 h-16 rounded-md ring-1 ring-black/5 dark:ring-white/10",showPopover:!1,blur:j,animated:S==="all"?!0:S==="hover"?w===Xe:!1,animatedMode:"teaser",animatedTrigger:"always",assetNonce:P}),ct&&typeof St=="number"&&Ue?m.jsx("img",{src:Ue,alt:"","aria-hidden":"true",className:"pointer-events-none absolute left-0 top-1 z-[15] h-16 w-28 rounded-md object-cover ring-1 ring-black/5 dark:ring-white/10",draggable:!1}):null]})}},{key:"Model",header:"Model",sortable:!0,sortValue:Qe=>{const Xe=i(Qe.output||""),ze=xc(Xe),Ze=r(Qe.output),ct=vr(Xe);return`${Ze} ${ze?"HOT":""} ${ct}`.trim()},cell:Qe=>{const Xe=i(Qe.output||""),ze=xc(Xe),Ze=vr(Xe),ct=r(Qe.output),St=n(r(Qe.output)),se=Se(k[St]?.tags);return m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:ct}),m.jsxs("div",{className:"mt-0.5 min-w-0 text-xs text-gray-500 dark:text-gray-400",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:"truncate",title:Ze,children:Ze||"—"}),(()=>{const ke=t(Qe),De=d[ke]??null,Ue=gb(De);return Ue?m.jsx("span",{className:`shrink-0 rounded-md bg-gray-100 px-1.5 py-0.5 text-[11px] font-semibold text-gray-700 ring-1 ring-inset ring-gray-200\r
dark:bg-white/5 dark:text-gray-200 dark:ring-white/10`,title:De?`${De.w}×${De.h}`:"Auflösung",children:Ue}):null})(),ze?m.jsx("span",{className:"shrink-0 rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null]}),se.length>0?m.jsx("div",{className:"mt-1",onClick:ke=>ke.stopPropagation(),onMouseDown:ke=>ke.stopPropagation(),children:m.jsx(pb,{rowKey:t(Qe),tags:se,activeTagSet:R,lower:n,onToggleTagFilter:Y,maxWidthClassName:"max-w-[11rem]"})}):null]})]})}},{key:"completedAt",header:"Fertiggestellt am",sortable:!0,widthClassName:"w-[150px]",sortValue:Qe=>{const Xe=Date.parse(String(Qe.endedAt||""));return Number.isFinite(Xe)?Xe:Number.NEGATIVE_INFINITY},cell:Qe=>{const Xe=Date.parse(String(Qe.endedAt||""));if(!Number.isFinite(Xe))return m.jsx("span",{className:"text-xs text-gray-400",children:"—"});const ze=new Date(Xe),Ze=ze.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),ct=ze.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"});return m.jsxs("time",{dateTime:ze.toISOString(),title:`${Ze} ${ct}`,className:"tabular-nums whitespace-nowrap text-sm text-gray-900 dark:text-white",children:[m.jsx("span",{className:"font-medium",children:Ze}),m.jsx("span",{className:"mx-1 text-gray-400 dark:text-gray-600",children:"·"}),m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:ct})]})}},{key:"runtime",header:"Dauer",align:"right",sortable:!0,sortValue:Qe=>Je(Qe),cell:Qe=>m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:a(Qe)})},{key:"size",header:"Größe",align:"right",sortable:!0,sortValue:Qe=>{const Xe=u(Qe);return typeof Xe=="number"?Xe:Number.NEGATIVE_INFINITY},cell:Qe=>m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:c(u(Qe))})},{key:"actions",header:"Aktionen",align:"right",srOnlyHeader:!0,cell:Qe=>{const Xe=t(Qe),ze=G.has(Xe)||N.has(Xe)||K.has(Xe),Ze=i(Qe.output||""),ct=xc(Ze),St=n(r(Qe.output)),se=k[St],ke=!!se?.favorite,De=se?.liked===!0,Ue=!!se?.watching;return m.jsx(ga,{job:Qe,variant:"table",busy:ze,isHot:ct,isFavorite:ke,isLiked:De,isWatching:Ue,onToggleWatch:te,onToggleFavorite:q,onToggleLike:Z,onToggleHot:W?async at=>{if(!(Ie&&Ie(at)))return W(at)}:void 0,onKeep:async at=>ge&&ge(at)?!0:F(at),onDelete:async at=>le&&le(at)?!0:oe(at),order:["watch","favorite","like","hot","details","add","keep","delete"],className:"flex items-center justify-end gap-1"})}}],[t,i,f,y,v,L,g,T,O,I,j,S,w,P,n,r,k,R,Y,d,G,N,K,Ve,Ee,yt,te,q,Z,W,F,oe,u,c,a,Se,Je]),pt=b.useCallback(Qe=>{if(!Qe)return"completed_desc";const Xe=Qe,ze=String(Xe.key??Xe.columnKey??Xe.id??""),Ze=String(Xe.dir??Xe.direction??Xe.order??"").toLowerCase(),ct=Ze==="asc"||Ze==="1"||Ze==="true";return ze==="completedAt"?ct?"completed_asc":"completed_desc":ze==="runtime"?ct?"duration_asc":"duration_desc":ze==="size"?ct?"size_asc":"size_desc":ze==="Model"||ze==="video"?ct?"file_asc":"file_desc":ct?"completed_asc":"completed_desc"},[]),Fe=b.useCallback(Qe=>{Pe(Qe),X(pt(Qe)),re!==1&&J(1)},[X,pt,re,J]),_t=b.useCallback(Qe=>{const Xe=t(Qe);return["transition-all duration-300",(G.has(Xe)||K.has(Xe))&&"bg-red-50/60 dark:bg-red-500/10 pointer-events-none",G.has(Xe)&&"animate-pulse",(N.has(Xe)||K.has(Xe))&&"pointer-events-none",N.has(Xe)&&"bg-emerald-50/60 dark:bg-emerald-500/10 animate-pulse",K.has(Xe)&&"opacity-0"].filter(Boolean).join(" ")},[t,G,N,K]);return m.jsxs("div",{className:"relative",children:[m.jsx(Sh,{rows:s,columns:ut,getRowKey:Qe=>t(Qe),striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0,sort:Le,onSortChange:Fe,onRowClick:z,rowClassName:_t}),e&&s.length===0?m.jsx("div",{className:"absolute inset-0 z-20 grid place-items-center rounded-lg bg-white/50 backdrop-blur-[2px] dark:bg-gray-950/40",children:m.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-gray-200 bg-white/80 px-3 py-2 shadow-sm dark:border-white/10 dark:bg-gray-900/70",children:[m.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-white/20 dark:border-t-transparent"}),m.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:"Lade…"})]})}):null]})}function d2(...s){for(const e of s)if(typeof e=="string"){const t=e.trim();if(t)return t}}function T3(s){if(!s)return null;if(typeof s=="string")try{return JSON.parse(s)}catch{return null}return typeof s=="object"?s:null}function Fy(s){if(!(typeof s!="number"||!Number.isFinite(s)||s<=0))return s>1440*60?s/1e3:s}function h2(s,e,t){return Math.max(e,Math.min(t,s))}const S3=5;function _3(s){if(s<=1)return[1,1];const e=16/9;let t=1,i=s,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY;for(let a=1;a<=s;a++){const u=Math.max(1,Math.ceil(s/a)),c=a*u-s,d=a/u,f=Math.abs(d-e);(c<n||c===n&&f<r||c===n&&f===r&&u<i)&&(n=c,r=f,t=a,i=u)}return[t,i]}function E3({rows:s,isLoading:e,blurPreviews:t,durations:i,teaserPlayback:n,teaserAudio:r,hoverTeaserKey:a,teaserKey:u,handleDuration:c,handleScrubberClickIndex:d,keyFor:f,baseName:g,modelNameFromOutput:y,runtimeOf:v,sizeBytesOf:T,formatBytes:S,deletingKeys:w,keepingKeys:L,removingKeys:O,deletedKeys:I,registerTeaserHost:j,onHoverPreviewKeyChange:P,onOpenPlayer:G,deleteVideo:N,keepVideo:K,onToggleHot:k,lower:R,modelsByKey:Y,activeTagSet:z,onToggleTagFilter:X,onToggleFavorite:re,onToggleLike:J,onToggleWatch:W,enqueueDeleteVideo:q,enqueueKeepVideo:Z,enqueueToggleHot:te}){const oe=n==="hover"||n==="all",F=b.useCallback(Ve=>Ee=>{if(!oe){j(Ve)(null);return}j(Ve)(Ee)},[j,oe]),le=Ve=>{const Ee=String(Ve??"").trim();if(!Ee)return[];const _e=Ee.split(/[\n,;|]+/g).map(pt=>pt.trim()).filter(Boolean),yt=new Set,ut=[];for(const pt of _e){const Fe=pt.toLowerCase();yt.has(Fe)||(yt.add(Fe),ut.push(pt))}return ut},ge=b.useCallback(Ve=>{const Ee=(typeof Ve?.meta?.videoWidth=="number"&&Number.isFinite(Ve.meta.videoWidth)?Ve.meta.videoWidth:0)||(typeof Ve?.videoWidth=="number"&&Number.isFinite(Ve.videoWidth)?Ve.videoWidth:0),_e=(typeof Ve?.meta?.videoHeight=="number"&&Number.isFinite(Ve.meta.videoHeight)?Ve.meta.videoHeight:0)||(typeof Ve?.videoHeight=="number"&&Number.isFinite(Ve.videoHeight)?Ve.videoHeight:0);return Ee>0&&_e>0?{w:Ee,h:_e}:null},[]),[Ie,Le]=b.useState(null),[Pe,Je]=b.useState({}),Se=b.useCallback((Ve,Ee)=>{Je(_e=>{if(Ee===void 0){if(!(Ve in _e))return _e;const yt={..._e};return delete yt[Ve],yt}return _e[Ve]===Ee?_e:{..._e,[Ve]:Ee}})},[]),Re=b.useCallback(Ve=>{Se(Ve,void 0)},[Se]);return m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:s.map(Ve=>{const Ee=f(Ve),yt=!(!!r&&a===Ee),ut=y(Ve.output),pt=R(ut),Fe=Y[pt],_t=!!Fe?.favorite,Qe=Fe?.liked===!0,Xe=!!Fe?.watching,ze=le(Fe?.tags),Ze=g(Ve.output||""),ct=xc(Ze),St=vr(Ze),se=v(Ve),ke=S(T(Ve)),De=ge(Ve),Ue=gb(De),at=w.has(Ee)||L.has(Ee)||O.has(Ee),dt=I.has(Ee),wt=d2(Fe?.image,Fe?.imageUrl,Ve?.meta?.modelImage,Ve?.meta?.modelImageUrl),Tt=vr(g(Ve.output||"")).replace(/\.[^.]+$/,"").trim(),Ft=T3(Ve?.meta),Qt=d2(Ft?.previewSprite?.path,Ft?.previewSpritePath,Fe?.previewScrubberPath,Tt?`/api/preview-sprite/${encodeURIComponent(Tt)}`:void 0),Zt=Qt?Qt.replace(/\/+$/,""):void 0,Et=Ft?.previewSprite?.stepSeconds??Ft?.previewSpriteStepSeconds,Dt=typeof Et=="number"&&Number.isFinite(Et)&&Et>0?Et:S3,yi=Fy(Ft?.durationSeconds)??Fy(Ve?.durationSeconds)??Fy(i[Ee]),Pi=typeof yi=="number"&&yi>0?Math.max(1,Math.min(200,Math.floor(yi/Dt)+1)):void 0,Jt=Ft?.previewSprite?.count??Ft?.previewSpriteCount??Fe?.previewScrubberCount??Pi,ki=Ft?.previewSprite?.cols??Ft?.previewSpriteCols,gt=Ft?.previewSprite?.rows??Ft?.previewSpriteRows,V=typeof Jt=="number"&&Number.isFinite(Jt)?Math.max(0,Math.floor(Jt)):0,[$,ie]=V>1?_3(V):[0,0],Te=typeof ki=="number"&&Number.isFinite(ki)?Math.max(0,Math.floor(ki)):$,Be=typeof gt=="number"&&Number.isFinite(gt)?Math.max(0,Math.floor(gt)):ie,ht=(typeof Ft?.updatedAtUnix=="number"&&Number.isFinite(Ft.updatedAtUnix)?Ft.updatedAtUnix:void 0)??(typeof Ft?.fileModUnix=="number"&&Number.isFinite(Ft.fileModUnix)?Ft.fileModUnix:void 0)??0,It=Zt&&ht?`${Zt}?v=${encodeURIComponent(String(ht))}`:Zt||void 0,Yt=!!It&&V>1,pi=Yt&&Te>0&&Be>0,oi=Yt?V:0,ci=Yt?Dt:0,Bi=Yt,Gt=Pe[Ee],xi=typeof Gt=="number"&&oi>1?h2(Gt/(oi-1),0,1):void 0,ai=pi&&typeof Gt=="number"?(()=>{const vt=h2(Gt,0,Math.max(0,V-1)),Ci=vt%Te,ss=Math.floor(vt/Te),vs=Te<=1?0:Ci/(Te-1)*100,xs=Be<=1?0:ss/(Be-1)*100;return{backgroundImage:`url("${It}")`,backgroundRepeat:"no-repeat",backgroundSize:`${Te*100}% ${Be*100}%`,backgroundPosition:`${vs}% ${xs}%`}})():void 0,di=Ie===Ee&&!!wt,qt=!di&&!!ai,Mt=di||qt;return m.jsxs("div",{role:"button",tabIndex:0,className:["group relative rounded-lg overflow-hidden outline-1 outline-black/5 dark:-outline-offset-1 dark:outline-white/10","bg-white dark:bg-gray-900/40","transition-all duration-200","hover:-translate-y-0.5 hover:shadow-md dark:hover:shadow-none","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500",at&&"pointer-events-none opacity-70",w.has(Ee)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30",O.has(Ee)&&"opacity-0 translate-y-2 scale-[0.98]",dt&&"hidden"].filter(Boolean).join(" "),onClick:()=>G(Ve),onKeyDown:vt=>{(vt.key==="Enter"||vt.key===" ")&&G(Ve)},children:[m.jsx("div",{className:"group/thumb relative aspect-video rounded-t-lg bg-black/5 dark:bg-white/5",ref:F(Ee),onMouseEnter:()=>P?.(Ee),onMouseLeave:()=>{P?.(null),Re(Ee),Le(vt=>vt===Ee?null:vt)},children:m.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-t-lg",children:[m.jsx("div",{className:"absolute inset-0",children:m.jsx(b0,{job:Ve,getFileName:vt=>vr(g(vt)),durationSeconds:i[Ee]??Ve?.durationSeconds,onDuration:c,variant:"fill",showPopover:!1,blur:t,animated:Mt?!1:n==="all"?!0:n==="hover"?u===Ee:!1,animatedMode:"teaser",animatedTrigger:"always",clipSeconds:1,thumbSamples:18,muted:yt,popoverMuted:yt,scrubProgressRatio:xi,preferScrubProgress:typeof Gt=="number"})}),pi&&It?m.jsx("img",{src:It,alt:"",className:"hidden",loading:"lazy",decoding:"async","aria-hidden":"true"}):null,qt&&ai?m.jsx("div",{className:"absolute inset-x-0 top-0 bottom-[6px] z-[5]","aria-hidden":"true",children:m.jsx("div",{className:"h-full w-full",style:ai})}):null,di&&wt?m.jsxs("div",{className:"absolute inset-0 z-[6]",children:[m.jsx("img",{src:wt,alt:ut?`${ut} preview`:"Model preview",className:"h-full w-full object-cover",draggable:!1}),m.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/65 to-transparent px-2 py-1.5",children:m.jsx("div",{className:"text-[10px] font-semibold tracking-wide text-white/95",children:"MODEL PREVIEW"})})]}):null,Bi?m.jsx("div",{className:"absolute inset-x-0 bottom-0 z-30 pointer-events-none opacity-100 transition-opacity duration-150",onClick:vt=>vt.stopPropagation(),onMouseDown:vt=>vt.stopPropagation(),children:m.jsx(dk,{className:"pointer-events-auto px-1",imageCount:oi,activeIndex:Gt,onActiveIndexChange:vt=>Se(Ee,vt),onIndexClick:vt=>{Se(Ee,vt),d(Ve,vt,oi)},stepSeconds:ci})}):null,m.jsx("div",{className:"pointer-events-none absolute right-2 bottom-2 z-10 transition-opacity duration-150 group-hover/thumb:opacity-0 group-focus-within/thumb:opacity-0",children:m.jsxs("div",{className:"flex items-center gap-1.5 text-right text-[11px] font-semibold leading-none text-white [text-shadow:_0_1px_0_rgba(0,0,0,0.95),_1px_0_0_rgba(0,0,0,0.95),_-1px_0_0_rgba(0,0,0,0.95),_0_-1px_0_rgba(0,0,0,0.95),_1px_1px_0_rgba(0,0,0,0.8),_-1px_1px_0_rgba(0,0,0,0.8),_1px_-1px_0_rgba(0,0,0,0.8),_-1px_-1px_0_rgba(0,0,0,0.8)]",title:[se,De?`${De.w}×${De.h}`:Ue||"",ke].filter(Boolean).join(" • "),children:[m.jsx("span",{children:se}),Ue?m.jsx("span",{"aria-hidden":"true",children:"•"}):null,Ue?m.jsx("span",{children:Ue}):null,m.jsx("span",{"aria-hidden":"true",children:"•"}),m.jsx("span",{children:ke})]})})]})}),m.jsxs("div",{className:"relative min-h-[118px] px-4 py-3 rounded-b-lg border-t border-black/5 dark:border-white/10 bg-white dark:bg-gray-900",children:[m.jsx("div",{className:"min-w-0",children:m.jsxs("div",{className:"mt-0.5 flex items-start gap-2 min-w-0",children:[ct?m.jsx("span",{className:"shrink-0 self-start rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] leading-none font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null,m.jsx("span",{className:"min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-white",title:vr(St)||"—",children:vr(St)||"—"})]})}),m.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[m.jsx("div",{className:"min-w-0",children:m.jsx("span",{className:["block truncate text-xs text-gray-500 dark:text-gray-400",wt?"cursor-zoom-in hover:text-gray-700 dark:hover:text-gray-200":""].filter(Boolean).join(" "),title:wt?`${ut} (Hover: Model-Preview)`:ut,onMouseEnter:vt=>{vt.stopPropagation(),wt&&Le(Ee)},onMouseLeave:vt=>{vt.stopPropagation(),Le(Ci=>Ci===Ee?null:Ci)},onMouseDown:vt=>vt.stopPropagation(),onClick:vt=>vt.stopPropagation(),children:ut||"—"})}),m.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[Xe?m.jsx(Su,{className:"size-4 text-sky-600 dark:text-sky-300"}):null,Qe?m.jsx(_u,{className:"size-4 text-rose-600 dark:text-rose-300"}):null,_t?m.jsx(Mc,{className:"size-4 text-amber-600 dark:text-amber-300"}):null]})]}),m.jsx("div",{className:"mt-2",onClick:vt=>vt.stopPropagation(),onMouseDown:vt=>vt.stopPropagation(),children:m.jsx("div",{className:"w-full",children:m.jsx("div",{className:"w-full rounded-md bg-gray-50/70 p-1 ring-1 ring-black/5 dark:bg-white/5 dark:ring-white/10",children:m.jsx(ga,{job:Ve,variant:"table",busy:at,collapseToMenu:!0,compact:!0,isHot:ct,isFavorite:_t,isLiked:Qe,isWatching:Xe,onToggleWatch:W,onToggleFavorite:re,onToggleLike:J,onToggleHot:async vt=>{if(!(te&&te(vt)))return k(vt)},onKeep:async vt=>Z&&Z(vt)?!0:K(vt),onDelete:async vt=>q&&q(vt)?!0:N(vt),order:["watch","favorite","like","hot","keep","delete","details","add"],className:"w-full gap-1.5"})})})}),m.jsx("div",{className:"mt-2",onClick:vt=>vt.stopPropagation(),onMouseDown:vt=>vt.stopPropagation(),children:m.jsx(pb,{rowKey:Ee,tags:ze,activeTagSet:z,lower:R,onToggleTagFilter:X})})]})]},Ee)})}),e&&s.length===0?m.jsx("div",{className:"absolute inset-0 z-20 grid place-items-center rounded-lg bg-white/50 backdrop-blur-[2px] dark:bg-gray-950/40",children:m.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-gray-200 bg-white/80 px-3 py-2 shadow-sm dark:border-white/10 dark:bg-gray-900/70",children:[m.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-white/20 dark:border-t-transparent"}),m.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:"Lade…"})]})}):null]})}function f2(s,e,t){return Math.max(e,Math.min(t,s))}function Uy(s,e){const t=[];for(let i=s;i<=e;i++)t.push(i);return t}function w3(s,e,t,i){if(s<=1)return[1];const n=1,r=s,a=Uy(n,Math.min(t,r)),u=Uy(Math.max(r-t+1,t+1),r),c=Math.max(Math.min(e-i,r-t-i*2-1),t+1),d=Math.min(Math.max(e+i,t+i*2+2),r-t),f=[];f.push(...a),c>t+1?f.push("ellipsis"):t+1<r-t&&f.push(t+1),f.push(...Uy(c,d)),d<r-t?f.push("ellipsis"):r-t>t&&f.push(r-t),f.push(...u);const g=new Set;return f.filter(y=>{const v=String(y);return g.has(v)?!1:(g.add(v),!0)})}function A3({active:s,disabled:e,rounded:t,onClick:i,children:n,title:r}){const a=t==="l"?"rounded-l-md":t==="r"?"rounded-r-md":"";return m.jsx("button",{type:"button",disabled:e,onClick:e?void 0:i,title:r,className:ni("relative inline-flex items-center px-4 py-2 text-sm font-semibold focus:z-20 focus:outline-offset-0",a,e?"opacity-50 cursor-not-allowed":"cursor-pointer",s?"z-10 bg-indigo-600 text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:bg-indigo-500 dark:focus-visible:outline-indigo-500":"text-gray-900 inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:text-gray-200 dark:inset-ring-gray-700 dark:hover:bg-white/5"),"aria-current":s?"page":void 0,children:n})}function mx({page:s,pageSize:e,totalItems:t,onPageChange:i,siblingCount:n=1,boundaryCount:r=1,showSummary:a=!0,className:u,ariaLabel:c="Pagination",prevLabel:d="Previous",nextLabel:f="Next"}){const g=Math.max(1,Math.ceil((t||0)/Math.max(1,e||1))),y=f2(s||1,1,g);if(g<=1)return null;const v=t===0?0:(y-1)*e+1,T=Math.min(y*e,t),S=w3(g,y,r,n),w=L=>i(f2(L,1,g));return m.jsxs("div",{className:ni("flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 sm:px-6 dark:border-white/10 dark:bg-transparent",u),children:[m.jsxs("div",{className:"flex flex-1 justify-between sm:hidden",children:[m.jsx("button",{type:"button",onClick:()=>w(y-1),disabled:y<=1,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-white/10 dark:bg-white/5 dark:text-gray-200 dark:hover:bg-white/10",children:d}),m.jsx("button",{type:"button",onClick:()=>w(y+1),disabled:y>=g,className:"relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-white/10 dark:bg-white/5 dark:text-gray-200 dark:hover:bg-white/10",children:f})]}),m.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",children:[m.jsx("div",{children:a?m.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",m.jsx("span",{className:"font-medium",children:v})," to"," ",m.jsx("span",{className:"font-medium",children:T})," of"," ",m.jsx("span",{className:"font-medium",children:t})," results"]}):null}),m.jsx("div",{children:m.jsxs("nav",{"aria-label":c,className:"isolate inline-flex -space-x-px rounded-md shadow-xs dark:shadow-none",children:[m.jsxs("button",{type:"button",onClick:()=>w(y-1),disabled:y<=1,className:"relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 inset-ring inset-ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0 disabled:opacity-50 disabled:cursor-not-allowed dark:inset-ring-gray-700 dark:hover:bg-white/5",children:[m.jsx("span",{className:"sr-only",children:d}),m.jsx(p3,{"aria-hidden":"true",className:"size-5"})]}),S.map((L,O)=>L==="ellipsis"?m.jsx("span",{className:"relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-700 inset-ring inset-ring-gray-300 dark:text-gray-400 dark:inset-ring-gray-700",children:"…"},`e-${O}`):m.jsx(A3,{active:L===y,onClick:()=>w(L),rounded:"none",children:L},L)),m.jsxs("button",{type:"button",onClick:()=>w(y+1),disabled:y>=g,className:"relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 inset-ring inset-ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0 disabled:opacity-50 disabled:cursor-not-allowed dark:inset-ring-gray-700 dark:hover:bg-white/5",children:[m.jsx("span",{className:"sr-only",children:f}),m.jsx(y3,{"aria-hidden":"true",className:"size-5"})]})]})})]})]})}const mk=b.createContext(null),jy=220;function k3(s){switch(s){case"success":return{Icon:eM,cls:"text-emerald-600 dark:text-emerald-400"};case"error":return{Icon:OM,cls:"text-rose-600 dark:text-rose-400"};case"warning":return{Icon:rM,cls:"text-amber-600 dark:text-amber-400"};default:return{Icon:mM,cls:"text-sky-600 dark:text-sky-400"}}}function C3(s){switch(s){case"success":return"border-emerald-200/80 dark:border-emerald-400/20";case"error":return"border-rose-200/80 dark:border-rose-400/20";case"warning":return"border-amber-200/80 dark:border-amber-400/20";default:return"border-sky-200/80 dark:border-sky-400/20"}}function D3(s){switch(s){case"success":return{line:"bg-emerald-500 dark:bg-emerald-400",progressTrack:"bg-emerald-500/10 dark:bg-emerald-400/10",progressFill:"bg-emerald-500/70 dark:bg-emerald-400/70",iconBg:"bg-emerald-50 dark:bg-emerald-400/10"};case"error":return{line:"bg-rose-500 dark:bg-rose-400",progressTrack:"bg-rose-500/10 dark:bg-rose-400/10",progressFill:"bg-rose-500/70 dark:bg-rose-400/70",iconBg:"bg-rose-50 dark:bg-rose-400/10"};case"warning":return{line:"bg-amber-500 dark:bg-amber-400",progressTrack:"bg-amber-500/10 dark:bg-amber-400/10",progressFill:"bg-amber-500/70 dark:bg-amber-400/70",iconBg:"bg-amber-50 dark:bg-amber-400/10"};default:return{line:"bg-sky-500 dark:bg-sky-400",progressTrack:"bg-sky-500/10 dark:bg-sky-400/10",progressFill:"bg-sky-500/70 dark:bg-sky-400/70",iconBg:"bg-sky-50 dark:bg-sky-400/10"}}}function L3(s){switch(s){case"success":return"Erfolg";case"error":return"Fehler";case"warning":return"Hinweis";default:return"Info"}}function R3(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function I3({children:s,maxToasts:e=3,defaultDurationMs:t=3500,position:i="bottom-right"}){const[n,r]=b.useState([]),[a,u]=b.useState(!0),c=b.useRef({}),d=b.useRef({}),f=b.useRef({}),g=b.useRef({}),y=b.useRef({}),v=b.useCallback(k=>{const R=c.current[k];R&&(window.clearTimeout(R),delete c.current[k]);const Y=d.current[k];Y&&(window.clearTimeout(Y),delete d.current[k]),delete f.current[k],delete g.current[k],delete y.current[k]},[]),T=b.useCallback(async()=>{try{const k=await fetch("/api/settings",{cache:"no-store"});if(!k.ok)return;const R=await k.json();u(!!(R?.enableNotifications??!0))}catch{}},[]);b.useEffect(()=>{T();const k=()=>T();return window.addEventListener("recorder-settings-updated",k),()=>window.removeEventListener("recorder-settings-updated",k)},[T]),b.useEffect(()=>{a||(r(R=>R.map(Y=>Y.type==="error"?Y:{...Y,open:!1})),n.filter(R=>R.type!=="error").map(R=>R.id).forEach(R=>{v(R),d.current[R]=window.setTimeout(()=>{r(Y=>Y.filter(z=>z.id!==R)),delete d.current[R]},jy)}))},[a]);const S=b.useCallback(k=>{r(R=>R.map(Y=>Y.id===k?{...Y,open:!1}:Y)),v(k),d.current[k]=window.setTimeout(()=>{r(R=>R.filter(Y=>Y.id!==k)),delete d.current[k]},jy)},[v]),w=b.useCallback(()=>{r(k=>k.map(R=>({...R,open:!1}))),Object.keys(c.current).forEach(k=>{window.clearTimeout(c.current[k]),delete c.current[k]}),Object.keys(d.current).forEach(k=>{window.clearTimeout(d.current[k]),delete d.current[k]}),window.setTimeout(()=>r([]),jy)},[]),L=b.useCallback((k,R)=>{if(!R||R<=0)return;const Y=c.current[k];Y&&(window.clearTimeout(Y),delete c.current[k]),f.current[k]=Date.now(),g.current[k]=R,y.current[k]=!1,c.current[k]=window.setTimeout(()=>{S(k),delete c.current[k],delete f.current[k],delete g.current[k],delete y.current[k]},R)},[S]),O=b.useCallback(k=>{if(!a&&k.type!=="error")return"";const R=R3(),Y=k.durationMs??t;return r(z=>{const X=[{...k,id:R,durationMs:Y,open:!0},...z],re=Math.max(1,e),J=X.slice(0,re);return X.slice(re).forEach(q=>v(q.id)),J}),Y&&Y>0&&L(R,Y),R},[t,e,a,v,L]),I=b.useCallback(k=>{if(y.current[k])return;const R=c.current[k];if(!R)return;window.clearTimeout(R),delete c.current[k];const Y=f.current[k]??Date.now(),z=g.current[k]??0,X=Date.now()-Y,re=Math.max(0,z-X);g.current[k]=re,y.current[k]=!0},[]),j=b.useCallback(k=>{if(!y.current[k])return;const R=g.current[k]??0;if(R<=0){S(k);return}y.current[k]=!1,f.current[k]=Date.now(),c.current[k]=window.setTimeout(()=>{S(k),delete c.current[k],delete f.current[k],delete g.current[k],delete y.current[k]},R)},[S]);b.useEffect(()=>()=>{Object.values(c.current).forEach(k=>window.clearTimeout(k)),Object.values(d.current).forEach(k=>window.clearTimeout(k))},[]);const P=b.useMemo(()=>({push:O,remove:S,clear:w}),[O,S,w]),G=i==="top-right"||i==="top-left"?"items-start sm:items-start sm:justify-start":"items-end sm:items-end sm:justify-end",N=i.endsWith("left")?"sm:items-start":"sm:items-end",K=i.startsWith("top")?"top-0 bottom-auto":"bottom-0 top-auto";return m.jsxs(mk.Provider,{value:P,children:[s,m.jsx("style",{children:`
@keyframes toast-progress {
from { transform: scaleX(1); }
to { transform: scaleX(0); }
}
.toast-progress-bar {
animation-name: toast-progress;
animation-timing-function: linear;
animation-fill-mode: forwards;
transform-origin: left center;
will-change: transform;
}
`}),m.jsx("div",{"aria-live":"assertive",className:["pointer-events-none fixed z-[80] inset-x-0",K].join(" "),children:m.jsx("div",{className:["flex w-full px-3 py-4 sm:px-6 sm:py-6",G].join(" "),children:m.jsx("div",{className:["flex w-full flex-col gap-2.5 sm:gap-3",N].join(" "),children:n.map(k=>{const{Icon:R,cls:Y}=k3(k.type),z=D3(k.type),X=(k.title||"").trim()||L3(k.type),re=(k.message||"").trim(),J=(k.imageUrl||"").trim(),W=(k.imageAlt||X).trim(),q=typeof k.onClick=="function";return m.jsx(bh,{appear:!0,show:k.open,enter:"transform transition ease-out duration-250",enterFrom:"opacity-0 -translate-y-3 sm:-translate-y-2",enterTo:"opacity-100 translate-y-0",leave:"transform transition ease-in duration-200",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-2 sm:-translate-y-3",children:m.jsx("div",{role:q?"button":"status",className:["pointer-events-auto relative w-[22rem] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-xl","border bg-white dark:bg-slate-900","shadow-sm","ring-1 ring-black/5 dark:ring-white/5",q?"cursor-pointer transition-[box-shadow,transform,background-color] duration-150 hover:bg-gray-50 dark:hover:bg-slate-800/90 hover:shadow-lg hover:ring-black/10 dark:hover:ring-white/10 active:scale-[0.998]":"",C3(k.type)].join(" "),onMouseEnter:()=>I(k.id),onMouseLeave:()=>j(k.id),onFocus:()=>I(k.id),onBlur:()=>j(k.id),onClick:()=>{k.onClick&&(k.onClick(),k.closeOnClick!==!1&&S(k.id))},onKeyDown:Z=>{k.onClick&&(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),k.onClick(),k.closeOnClick!==!1&&S(k.id))},tabIndex:q?0:void 0,"aria-label":q?`${X} öffnen`:void 0,children:J?m.jsxs("div",{className:"relative pr-12 sm:pr-14",children:[m.jsxs("div",{className:"flex items-stretch",children:[m.jsx("div",{className:"shrink-0",children:m.jsx("img",{src:J,alt:W,loading:"lazy",referrerPolicy:"no-referrer",className:["h-full min-h-[72px] w-16 sm:w-[72px]","object-cover object-center","rounded-l-xl","border-r border-black/5 dark:border-white/10","bg-gray-100 dark:bg-white/5"].join(" ")})}),m.jsxs("div",{className:"min-w-0 flex-1 py-3 pl-3 pr-2 sm:py-3.5 sm:pl-3.5 sm:pr-3",children:[m.jsx("p",{className:"truncate text-sm font-semibold leading-5 text-gray-900 dark:text-white",children:X}),re?m.jsx("p",{className:"mt-0.5 text-sm leading-5 text-gray-600 dark:text-gray-300 break-words",children:re}):null]})]}),m.jsxs("button",{type:"button",onClick:Z=>{Z.stopPropagation(),S(k.id)},title:"Schließen",className:["absolute right-2 top-1/2 -translate-y-1/2","inline-flex h-9 w-9 sm:h-10 sm:w-10 items-center justify-center rounded-full","text-gray-400 hover:text-gray-700 dark:text-gray-300 dark:hover:text-white","hover:bg-gray-100 dark:hover:bg-white/10","active:scale-[0.98] active:bg-gray-200/80 dark:active:bg-white/15","transition","focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2","dark:focus-visible:ring-indigo-400 dark:focus-visible:ring-offset-slate-900"].join(" "),children:[m.jsx("span",{className:"sr-only",children:"Schließen"}),m.jsx(o2,{"aria-hidden":"true",className:"size-5.5 sm:size-6"})]})]}):m.jsxs("div",{className:"relative pr-12 py-2.5 sm:pr-14",children:[m.jsxs("div",{className:"flex items-center gap-3 px-3 sm:px-3.5",children:[m.jsx("div",{className:"shrink-0",children:m.jsx("div",{className:["inline-flex h-12 w-12 sm:h-14 sm:w-14 items-center justify-center rounded-full",z.iconBg,"ring-1 ring-black/5 dark:ring-white/10"].join(" "),children:m.jsx(R,{className:["size-5.5 sm:size-6",Y].join(" "),"aria-hidden":"true"})})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("p",{className:"truncate text-sm font-semibold leading-5 text-gray-900 dark:text-white",children:X}),re?m.jsx("p",{className:"mt-0.5 text-sm leading-5 text-gray-600 dark:text-gray-300 break-words",children:re}):null]})]}),m.jsxs("button",{type:"button",onClick:Z=>{Z.stopPropagation(),S(k.id)},title:"Schließen",className:["absolute right-2 top-1/2 -translate-y-1/2","inline-flex h-9 w-9 sm:h-10 sm:w-10 items-center justify-center rounded-full","text-gray-400 hover:text-gray-700 dark:text-gray-300 dark:hover:text-white","hover:bg-gray-100 dark:hover:bg-white/10","active:scale-[0.98] active:bg-gray-200/80 dark:active:bg-white/15","transition","focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2","dark:focus-visible:ring-indigo-400 dark:focus-visible:ring-offset-slate-900"].join(" "),children:[m.jsx("span",{className:"sr-only",children:"Schließen"}),m.jsx(o2,{"aria-hidden":"true",className:"size-5.5 sm:size-6"})]})]})})},k.id)})})})})]})}function N3(){const s=b.useContext(mk);if(!s)throw new Error("useToast must be used within <ToastProvider>");return s}function pk(){const{push:s,remove:e,clear:t}=N3(),i=n=>(r,a,u)=>s({type:n,title:r,message:a,...u});return{push:s,remove:e,clear:t,success:i("success"),error:i("error"),info:i("info"),warning:i("warning")}}function O3(s){return typeof s=="number"?s:s==="xs"?12:s==="sm"?16:s==="lg"?28:20}function m2(...s){return s.filter(Boolean).join(" ")}function p2({size:s="md",className:e,label:t,srLabel:i="Lädt…",center:n=!1}){const r=O3(s);return m.jsxs("span",{className:m2("inline-flex items-center gap-2",n&&"justify-center w-full"),role:"status","aria-live":"polite",children:[m.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",className:m2("animate-spin text-gray-500",e),"aria-hidden":"true",children:[m.jsx("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),m.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",d:"M21 12a9 9 0 0 0-9-9",opacity:"0.95"})]}),t?m.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-200",children:t}):m.jsx("span",{className:"sr-only",children:i})]})}const yb=s=>(s||"").replaceAll("\\","/"),bn=s=>{const t=yb(s).split("/");return t[t.length-1]||""},Es=s=>{const e=s?.id;return e!=null&&String(e).trim()!==""?String(e):bn(s.output||"")||String(s?.output||"")},M3=s=>{const e=yb(String(s??""));return e.includes("/.trash/")||e.endsWith("/.trash")};function g2(s){if(!Number.isFinite(s)||s<=0)return"—";const e=Math.floor(s/1e3),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}function $y(s){if(typeof s!="number"||!Number.isFinite(s)||s<=0)return"—";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0||t>=100?0:t>=10?1:2;return`${t.toFixed(n)} ${e[i]}`}function y2(s){const[e,t]=b.useState(!1);return b.useEffect(()=>{const i=window.matchMedia(s),n=()=>t(i.matches);return n(),i.addEventListener?i.addEventListener("change",n):i.addListener(n),()=>{i.removeEventListener?i.removeEventListener("change",n):i.removeListener(n)}},[s]),e}const Zd=s=>{const e=bn(s||""),t=vr(e);if(!t)return"—";const i=t.replace(/\.[^.]+$/,""),n=i.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(n?.[1])return n[1];const r=i.lastIndexOf("_");return r>0?i.slice(0,r):i},Nr=s=>(s||"").trim().toLowerCase(),P3=s=>{const e=String(s??"").trim();if(!e)return[];const t=e.split(/[\n,;|]+/g).map(r=>r.trim()).filter(Boolean),i=new Set,n=[];for(const r of t){const a=r.toLowerCase();i.has(a)||(i.add(a),n.push(r))}return n.sort((r,a)=>r.localeCompare(a,void 0,{sensitivity:"base"})),n},Hy=s=>{const e=s,t=e.sizeBytes??e.fileSizeBytes??e.bytes??e.size??null;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:null};function v2(s){return new Promise(e=>window.setTimeout(e,s))}function B3(s){return s instanceof Error?s.message||String(s):String(s??"")}function x2(s){const e=B3(s).toLowerCase();return e.includes("wird gerade verwendet")||e.includes("wird gerade abgespielt")||e.includes("sharing violation")||e.includes("used by another process")||e.includes("file in use")||e.includes("409")}async function zy(s,e){const t=await fetch(s,e);if(!t.ok){const n=(await t.text().catch(()=>"")||`HTTP ${t.status}`).trim();throw new Error(n)}return t}function F3(){const s=b.useRef([]),e=b.useRef(!1),t=b.useRef(!1),i=b.useRef(new Set),n=b.useCallback(()=>{if(t.current)return;t.current=!0;const c=()=>{t.current=!1,r()};typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback(c,{timeout:250}):setTimeout(c,0)},[]),r=b.useCallback(async()=>{if(!e.current){e.current=!0;try{for(;s.current.length>0;){const c=s.current.shift();if(c){try{await c.run()}finally{i.current.delete(c.id)}await new Promise(d=>setTimeout(d,0))}}}finally{e.current=!1,s.current.length>0&&n()}}},[n]),a=b.useCallback((c,d)=>!c||i.current.has(c)?!1:(i.current.add(c),s.current.push({id:c,run:d}),n(),!0),[n]),u=b.useCallback(c=>i.current.has(c),[]);return{enqueue:a,isQueued:u}}function U3({jobs:s,doneJobs:e,blurPreviews:t,teaserPlayback:i,teaserAudio:n,onOpenPlayer:r,onDeleteJob:a,onToggleHot:u,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,onKeepJob:g,doneTotal:y,page:v,pageSize:T,onPageChange:S,assetNonce:w,sortMode:L,onSortModeChange:O,modelsByKey:I,loadMode:j="paged"}){const P=j==="all",G=i??"hover",N=y2("(hover: hover) and (pointer: fine)"),K=pk(),k=F3(),R=b.useRef(new Map),[Y,z]=b.useState(null),[X,re]=b.useState(null),J=b.useRef(null),W=b.useRef(new WeakMap),[q,Z]=b.useState(()=>new Set),[te,oe]=b.useState(()=>new Set),[F,le]=b.useState(!1),ge=b.useRef(!1),Ie=b.useRef(!1),Le=b.useRef(0),Pe="finishedDownloads_lastUndo_v1",[Je,Se]=b.useState(()=>{if(typeof window>"u")return null;try{const Q=localStorage.getItem(Pe);if(!Q)return null;const ne=JSON.parse(Q);if(!ne||ne.v!==1||!ne.action)return null;const ce=Date.now()-Number(ne.ts||0);return!Number.isFinite(ce)||ce<0||ce>1800*1e3?(localStorage.removeItem(Pe),null):ne.action}catch{return null}}),[Re,Ve]=b.useState(!1);b.useEffect(()=>{try{if(!Je){localStorage.removeItem(Pe);return}const Q={v:1,action:Je,ts:Date.now()};localStorage.setItem(Pe,JSON.stringify(Q))}catch{}},[Je]);const[Ee,_e]=b.useState({}),[yt,ut]=b.useState(null),[pt,Fe]=b.useState(null),[_t,Qe]=b.useState(0),Xe=b.useRef(null),ze=b.useRef({pending:0,t:0,timer:0}),Ze=b.useCallback(Q=>{!Q||!Number.isFinite(Q)||(ze.current.pending+=Q,!ze.current.timer&&(ze.current.timer=window.setTimeout(()=>{ze.current.timer=0;const ne=ze.current.pending;ze.current.pending=0,ne&&window.dispatchEvent(new CustomEvent("finished-downloads:count-hint",{detail:{delta:ne}}))},120)))},[]),ct="finishedDownloads_view",St="finishedDownloads_includeKeep_v2",se="finishedDownloads_mobileOptionsOpen_v1",[ke,De]=b.useState("table"),[Ue,at]=b.useState(!1),[dt,wt]=b.useState(!1),kt=b.useRef(new Map),[Tt,Ft]=b.useState([]),Qt=b.useMemo(()=>new Set(Tt.map(Nr)),[Tt]),Zt=b.useMemo(()=>{const Q={},ne={};for(const[ce,fe]of Object.entries(I??{})){const Ne=Nr(ce),We=P3(fe?.tags);Q[Ne]=We,ne[Ne]=new Set(We.map(Nr))}return{tagsByModelKey:Q,tagSetByModelKey:ne}},[I]),[Et,Dt]=b.useState(""),yi=b.useDeferredValue(Et),Pi=b.useMemo(()=>Nr(yi).split(/\s+/g).map(Q=>Q.trim()).filter(Boolean),[yi]),Jt=b.useCallback(()=>Dt(""),[]),ki=b.useCallback(Q=>{const ne=Nr(Q);Ft(ce=>ce.some(Ne=>Nr(Ne)===ne)?ce.filter(Ne=>Nr(Ne)!==ne):[...ce,Q])},[]),V=Qt.size>0||Pi.some(Q=>Q.length>=2),$=V||P,ie=b.useCallback(async Q=>{const ne=yt==null;ne&&le(!0);try{const ce=await fetch(`/api/record/done?all=1&sort=${encodeURIComponent(L)}&withCount=1${Ue?"&includeKeep=1":""}`,{cache:"no-store",signal:Q});if(!ce.ok)return;const fe=await ce.json().catch(()=>null),Ne=Array.isArray(fe?.items)?fe.items:[],We=Number(fe?.count??fe?.totalCount??Ne.length);ut(Ne),Fe(Number.isFinite(We)?We:Ne.length)}finally{ne&&le(!1)}},[L,Ue]),Te=b.useCallback(()=>Ft([]),[]);b.useEffect(()=>{try{const Q=localStorage.getItem("finishedDownloads_pendingTags");if(!Q)return;const ne=JSON.parse(Q),ce=Array.isArray(ne)?ne.map(fe=>String(fe||"").trim()).filter(Boolean):[];if(ce.length===0)return;Nc.flushSync(()=>Ft(ce)),v!==1&&S(1)}catch{}finally{try{localStorage.removeItem("finishedDownloads_pendingTags")}catch{}}},[]);const Be=b.useCallback(()=>{Xe.current==null&&(Xe.current=window.setTimeout(()=>{Xe.current=null,Qe(Q=>Q+1)},80))},[v,T,L,Ue]);b.useEffect(()=>{if(!$)return;const Q=new AbortController,ne=window.setTimeout(()=>{ie(Q.signal).catch(()=>{})},250);return()=>{window.clearTimeout(ne),Q.abort()}},[$,ie]),b.useEffect(()=>{if(_t===0)return;const Q=new AbortController;let ne=!0,ce=!1;const fe=++Le.current,Ne=()=>{ce||(ce=!0,Le.current===fe&&(ge.current=!1,Ie.current&&(Ie.current=!1,Be())))};return Le.current===fe&&(ge.current=!0),$?((async()=>{try{await ie(Q.signal),ne&&(xi.current=0)}catch{}finally{ne&&Ne()}})(),()=>{ne=!1,Q.abort(),Ne()}):(le(!0),(async()=>{try{const We=await fetch(`/api/record/done?page=${v}&pageSize=${T}&sort=${encodeURIComponent(L)}&withCount=1${Ue?"&includeKeep=1":""}`,{cache:"no-store",signal:Q.signal});if(!ne||Q.signal.aborted)return;const xt=We.ok;if(We.ok){const it=await We.json().catch(()=>null);if(!ne||Q.signal.aborted)return;const mt=Array.isArray(it?.items)?it.items:Array.isArray(it)?it:[];ut(mt);const Rt=Number(it?.count??it?.totalCount??mt.length),Pt=Number.isFinite(Rt)&&Rt>=0?Rt:0;Fe(Pt);const Nt=Math.max(1,Math.ceil(Pt/T));if(v>Nt){S(Nt),ut(null);return}}if(xt)xi.current=0;else if(ne&&!Q.signal.aborted&&xi.current<2){xi.current+=1;const it=xi.current;window.setTimeout(()=>{Q.signal.aborted||Qe(mt=>mt+1)},400*it)}}catch{}finally{ne&&(le(!1),Ne())}})(),()=>{ne=!1,Q.abort(),Ne()})},[_t,$,ie,v,T,L,Ue,S]),b.useEffect(()=>{$||(ut(null),Fe(null))},[v,T,L,Ue,$]),b.useEffect(()=>{if(!Ue){V||(ut(null),Fe(null));return}if(V)return;const Q=new AbortController;return(async()=>{try{const ne=await fetch(`/api/record/done?page=${v}&pageSize=${T}&sort=${encodeURIComponent(L)}&withCount=1&includeKeep=1`,{cache:"no-store",signal:Q.signal});if(!ne.ok)return;const ce=await ne.json().catch(()=>null),fe=Array.isArray(ce?.items)?ce.items:[],Ne=Number(ce?.count??ce?.totalCount??fe.length);ut(fe),Fe(Number.isFinite(Ne)?Ne:fe.length)}catch{}})(),()=>Q.abort()},[Ue,V,v,T,L]),b.useEffect(()=>{try{const Q=localStorage.getItem(ct);De(Q==="table"||Q==="cards"||Q==="gallery"?Q:window.matchMedia("(max-width: 639px)").matches?"cards":"table")}catch{De("table")}},[]),b.useEffect(()=>{try{localStorage.setItem(ct,ke)}catch{}},[ke]),b.useEffect(()=>{try{const Q=localStorage.getItem(St);at(Q==="1"||Q==="true"||Q==="yes")}catch{at(!1)}},[]),b.useEffect(()=>{try{localStorage.setItem(St,Ue?"1":"0")}catch{}},[Ue]),b.useEffect(()=>{try{const Q=localStorage.getItem(se);wt(Q==="1"||Q==="true"||Q==="yes")}catch{wt(!1)}},[]),b.useEffect(()=>{try{localStorage.setItem(se,dt?"1":"0")}catch{}},[dt]);const[ht,It]=b.useState({}),Yt=b.useRef({}),pi=b.useRef(null),[oi,ci]=b.useState({}),Bi=b.useRef({}),Gt=b.useRef(null),xi=b.useRef(0);b.useEffect(()=>{Bi.current=oi},[oi]);const ai=b.useCallback(()=>{Gt.current==null&&(Gt.current=window.setTimeout(()=>{Gt.current=null,ci({...Bi.current})},200))},[]);b.useEffect(()=>()=>{Gt.current!=null&&(window.clearTimeout(Gt.current),Gt.current=null)},[]),b.useEffect(()=>{Yt.current=ht},[ht]);const di=b.useCallback(()=>{pi.current==null&&(pi.current=window.setTimeout(()=>{pi.current=null,It({...Yt.current})},200))},[]);b.useEffect(()=>()=>{pi.current!=null&&(window.clearTimeout(pi.current),pi.current=null)},[]);const[qt,Mt]=b.useState(null),vt=!n,Ci=b.useCallback(Q=>{const ce=document.getElementById(Q)?.querySelector("video");if(!ce)return!1;Nh(ce,{muted:vt});const fe=ce.play?.();return fe&&typeof fe.catch=="function"&&fe.catch(()=>{}),!0},[vt]),ss=b.useCallback(Q=>{Mt(ne=>ne?.key===Q?{key:Q,nonce:ne.nonce+1}:{key:Q,nonce:1})},[]),vs=b.useCallback((Q,ne,ce)=>{const fe=Number.isFinite(ne)&&ne>0?ne:0;Mt(We=>We?.key===Q?{key:Q,nonce:We.nonce+1}:{key:Q,nonce:1});const Ne=We=>{const it=document.getElementById(ce)?.querySelector("video");if(!it){We>0&&requestAnimationFrame(()=>Ne(We-1));return}Nh(it,{muted:vt});const mt=()=>{try{const Ht=Number(it.duration),Vi=Number.isFinite(Ht)&&Ht>0?Math.max(0,Ht-.05):fe;it.currentTime=Math.max(0,Math.min(fe,Vi))}catch{}const Nt=it.play?.();Nt&&typeof Nt.catch=="function"&&Nt.catch(()=>{})};if(it.readyState>=1){mt();return}const Rt=()=>{it.removeEventListener("loadedmetadata",Rt),mt()};it.addEventListener("loadedmetadata",Rt,{once:!0});const Pt=it.play?.();Pt&&typeof Pt.catch=="function"&&Pt.catch(()=>{})};requestAnimationFrame(()=>Ne(8))},[vt]),xs=b.useCallback(Q=>{Mt(null),r(Q)},[r]),Gi=b.useCallback((Q,ne)=>{const ce=Number.isFinite(ne)&&ne>=0?ne:0;Mt(null),r(Q,ce)},[r]),fi=b.useCallback((Q,ne,ce)=>{const fe=Number.isFinite(ne)?Math.floor(ne):0,Ne=Number.isFinite(ce)?Math.floor(ce):0;if(Ne<=0){xs(Q);return}const We=Es(Q),xt=ht[We]??Q?.durationSeconds??0;if(!Number.isFinite(xt)||xt<=0){xs(Q);return}const it=Math.max(0,Math.min(fe,Ne-1)),mt=xt/Ne,Rt=it*mt;Gi(Q,Rt)},[ht,Es,xs,Gi]),Zi=b.useCallback((Q,ne)=>{oe(ce=>{const fe=new Set(ce);return ne?fe.add(Q):fe.delete(Q),fe})},[]),ts=b.useCallback(Q=>{Z(ne=>{const ce=new Set(ne);return ce.add(Q),ce})},[]),[$i,Ji]=b.useState(()=>new Set),Di=b.useCallback((Q,ne)=>{Ji(ce=>{const fe=new Set(ce);return ne?fe.add(Q):fe.delete(Q),fe})},[]),[$s,Cs]=b.useState(()=>new Set),ns=b.useRef(new Map);b.useEffect(()=>()=>{for(const Q of ns.current.values())window.clearTimeout(Q);ns.current.clear()},[]);const rs=b.useCallback((Q,ne)=>{Cs(ce=>{const fe=new Set(ce);return ne?fe.add(Q):fe.delete(Q),fe})},[]),Rs=b.useCallback(Q=>{const ne=ns.current.get(Q);ne!=null&&(window.clearTimeout(ne),ns.current.delete(Q))},[]),Li=b.useCallback(Q=>{Rs(Q),Z(ne=>{const ce=new Set(ne);return ce.delete(Q),ce}),Cs(ne=>{const ce=new Set(ne);return ce.delete(Q),ce}),oe(ne=>{const ce=new Set(ne);return ce.delete(Q),ce}),Ji(ne=>{const ce=new Set(ne);return ce.delete(Q),ce})},[Rs]),qi=b.useCallback(Q=>{rs(Q,!0),Rs(Q);const ne=window.setTimeout(()=>{ns.current.delete(Q),ts(Q),rs(Q,!1)},320);ns.current.set(Q,ne)},[ts,rs,Rs]),bs=b.useCallback(async(Q,ne)=>{window.dispatchEvent(new CustomEvent("player:release",{detail:{file:Q}})),ne?.close&&window.dispatchEvent(new CustomEvent("player:close",{detail:{file:Q}})),await new Promise(ce=>requestAnimationFrame(()=>ce())),window.dispatchEvent(new CustomEvent("player:release",{detail:{file:Q}})),await new Promise(ce=>window.setTimeout(ce,260))},[]),Kt=b.useCallback(async(Q,ne,ce)=>{const fe=Math.max(1,ce?.attempts??4),Ne=Math.max(50,ce?.baseDelayMs??220);let We;for(let xt=1;xt<=fe;xt++)try{return await bs(Q,{close:ce?.close??!0}),xt>1?await v2(Ne*xt):await v2(80),await ne()}catch(it){if(We=it,!x2(it)||xt>=fe)throw it;continue}throw We instanceof Error?We:new Error(String(We??"Unbekannter Fehler"))},[bs]),ds=b.useCallback(async Q=>{const{file:ne,rowKey:ce,setBusy:fe,isBusyNow:Ne,optimisticRemove:We,alreadyRemoved:xt,run:it,onSuccess:mt,onError:Rt,labels:Pt}=Q;if(!ne)return K.error(Pt.invalidTitle,Pt.invalidBody),{ok:!1};if(Ne?.())return{ok:!1};fe?.(!0);try{We&&!xt&&qi(ce);const Nt=await it();return await mt?.(Nt),{ok:!0,result:Nt}}catch(Nt){if(We&&Li(ce),await Rt?.(Nt),x2(Nt))K.error(Pt.inUseTitle,`${ne} wird noch verwendet (Player/Preview). Bitte kurz warten und erneut versuchen.`);else{const Ht=Nt?.message?` — ${String(Nt.message)}`:"";K.error(Pt.failTitle,`${Pt.failPrefix??ne}${Ht}`)}return{ok:!1}}finally{fe?.(!1)}},[K,qi,Li]),Fi=b.useCallback(async(Q,ne)=>{const ce=bn(Q.output||""),fe=Es(Q);return(await ds({kind:"delete",job:Q,file:ce,rowKey:fe,setBusy:We=>Zi(fe,We),isBusyNow:()=>te.has(fe),optimisticRemove:!0,alreadyRemoved:ne?.alreadyRemoved,labels:{invalidTitle:"Löschen nicht möglich",invalidBody:"Kein Dateiname gefunden kann nicht löschen.",inUseTitle:"Löschen fehlgeschlagen",failTitle:"Löschen fehlgeschlagen",failPrefix:ce},run:async()=>a?await Kt(ce,async()=>await a(Q),{close:!0,attempts:4,baseDelayMs:220}):await(await Kt(ce,async()=>await zy(`/api/record/delete?file=${encodeURIComponent(ce)}`,{method:"POST"}),{close:!0,attempts:4,baseDelayMs:220})).json().catch(()=>null),onSuccess:async We=>{if(a){const mt=typeof We?.undoToken=="string"?We.undoToken:"";Se(mt?{kind:"delete",undoToken:mt,originalFile:ce,rowKey:fe}:null);return}const xt=We?.from==="keep"?"keep":"done",it=typeof We?.undoToken=="string"?We.undoToken:"";Se(it?{kind:"delete",undoToken:it,originalFile:ce,rowKey:fe,from:xt}:null),Be(),Ze(-1)}})).ok},[bn,Es,te,Zi,a,Kt,ds,Be,Ze]),Hi=b.useCallback(async(Q,ne)=>{const ce=bn(Q.output||""),fe=Es(Q);return(await ds({kind:"keep",job:Q,file:ce,rowKey:fe,setBusy:We=>Di(fe,We),isBusyNow:()=>$i.has(fe)||te.has(fe),optimisticRemove:!0,alreadyRemoved:ne?.alreadyRemoved,labels:{invalidTitle:"Keep nicht möglich",invalidBody:"Kein Dateiname gefunden kann nicht behalten.",inUseTitle:"Keep fehlgeschlagen",failTitle:"Keep fehlgeschlagen",failPrefix:ce},run:async()=>g?await Kt(ce,async()=>await g(Q),{close:!0,attempts:4,baseDelayMs:220}):await(await Kt(ce,async()=>await zy(`/api/record/keep?file=${encodeURIComponent(ce)}`,{method:"POST"}),{close:!0,attempts:4,baseDelayMs:220})).json().catch(()=>null),onSuccess:async We=>{const xt=typeof We?.newFile=="string"&&We.newFile?We.newFile:ce;Se({kind:"keep",keptFile:xt,originalFile:ce,rowKey:fe}),Be(),Ze(Ue?0:-1)}})).ok},[bn,Es,Di,$i,te,Kt,ds,Be,Ze,Ue]),Ge=b.useCallback((Q,ne)=>{!Q||!ne||Q===ne||_e(ce=>{const fe={...ce};for(const[Ne,We]of Object.entries(fe))(Ne===Q||Ne===ne||We===Q||We===ne)&&delete fe[Ne];return fe[Q]=ne,fe})},[]),Lt=b.useCallback((Q,ne)=>{!Q&&!ne||_e(ce=>{const fe={...ce};for(const[Ne,We]of Object.entries(fe))(Ne===Q||Ne===ne||We===Q||We===ne)&&delete fe[Ne];return fe})},[]),Ct=b.useCallback(async()=>{if(!Je||Re)return;Ve(!0);const Q=ne=>{Z(ce=>{const fe=new Set(ce);return fe.delete(ne),fe}),oe(ce=>{const fe=new Set(ce);return fe.delete(ne),fe}),Ji(ce=>{const fe=new Set(ce);return fe.delete(ne),fe}),Cs(ce=>{const fe=new Set(ce);return fe.delete(ne),fe})};try{if(Je.kind==="delete"){const ne=await fetch(`/api/record/restore?token=${encodeURIComponent(Je.undoToken)}`,{method:"POST"});if(!ne.ok){const We=await ne.text().catch(()=>"");throw new Error(We||`HTTP ${ne.status}`)}const ce=await ne.json().catch(()=>null),fe=String(ce?.restoredFile||Je.originalFile);Je.rowKey&&Q(Je.rowKey),Q(Je.originalFile),Q(fe);const Ne=Je.from==="keep"&&!Ue?0:1;Ze(Ne),Be(),Se(null);return}if(Je.kind==="keep"){const ne=await fetch(`/api/record/unkeep?file=${encodeURIComponent(Je.keptFile)}`,{method:"POST"});if(!ne.ok){const Ne=await ne.text().catch(()=>"");throw new Error(Ne||`HTTP ${ne.status}`)}const ce=await ne.json().catch(()=>null),fe=String(ce?.newFile||Je.originalFile);Je.rowKey&&Q(Je.rowKey),Q(Je.originalFile),Q(fe),Ze(1),Be(),Se(null);return}if(Je.kind==="hot"){const ne=await fetch(`/api/record/toggle-hot?file=${encodeURIComponent(Je.currentFile)}`,{method:"POST"});if(!ne.ok){const We=await ne.text().catch(()=>"");throw new Error(We||`HTTP ${ne.status}`)}const ce=await ne.json().catch(()=>null),fe=String(ce?.oldFile||Je.currentFile),Ne=String(ce?.newFile||"");Ne&&Ge(fe,Ne),Be(),Se(null);return}}catch(ne){K.error("Undo fehlgeschlagen",String(ne?.message||ne))}finally{Ve(!1)}},[Je,Re,K,Be,Ue,Ze,Ge]),[Xt,Wt]=b.useState(()=>new Set),_i=b.useCallback((Q,ne)=>{Wt(ce=>{const fe=new Set(ce);return ne?fe.add(Q):fe.delete(Q),fe})},[]),ei=b.useCallback(async Q=>{const ne=bn(Q.output||""),ce=Es(Q),fe=xt=>xc(xt)?vr(xt):`HOT ${xt}`,Ne=ne,We=fe(Ne);await ds({kind:"rename",job:Q,file:ne,rowKey:ce,setBusy:xt=>_i(ce,xt),isBusyNow:()=>Xt.has(ce),optimisticRemove:!1,labels:{invalidTitle:"HOT nicht möglich",invalidBody:"Kein Dateiname gefunden kann nicht HOT togglen.",inUseTitle:"HOT umbenennen fehlgeschlagen",failTitle:"HOT umbenennen fehlgeschlagen",failPrefix:Ne},run:async()=>(Ge(Ne,We),u?await u(Q):await(await Kt(Ne,async()=>await zy(`/api/record/toggle-hot?file=${encodeURIComponent(Ne)}`,{method:"POST"}),{close:!0,attempts:4,baseDelayMs:220})).json().catch(()=>null)),onSuccess:async xt=>{const it=typeof xt?.oldFile=="string"&&xt.oldFile?xt.oldFile:Ne,mt=typeof xt?.newFile=="string"&&xt.newFile?xt.newFile:We;it&&mt&&it!==mt&&Ge(it,mt),Se({kind:"hot",currentFile:mt}),(!u||L==="file_asc"||L==="file_desc")&&Be()},onError:async()=>{Lt(Ne,We),Se(null)}})},[bn,Es,Xt,_i,ds,Ge,Lt,u,Kt,Be,L]),Ki=b.useCallback(Q=>{const ne=Es(Q),ce=bn(Q.output||"");if(!ne||!ce||te.has(ne)||$i.has(ne))return!1;Zi(ne,!0),qi(ne);const fe=`delete:${ne}`,Ne=k.enqueue(fe,async()=>{await Fi(Q,{alreadyRemoved:!0})});return Ne||Li(ne),Ne},[k,Es,bn,te,$i,Zi,Fi]),Ts=b.useCallback(Q=>{const ne=Es(Q),ce=bn(Q.output||"");if(!ne||!ce||$i.has(ne)||te.has(ne))return!1;Di(ne,!0),qi(ne);const fe=`keep:${ne}`,Ne=k.enqueue(fe,async()=>{await Hi(Q,{alreadyRemoved:!0})});return Ne||Li(ne),Ne},[k,Es,bn,$i,te,Di,Hi]),In=b.useCallback(Q=>{const ne=Es(Q);if(!ne||Xt.has(ne))return!1;const ce=`hot:${ne}`;return k.enqueue(ce,async()=>{await ei(Q)})},[k,Es,ei,Xt]),Wi=b.useCallback(Q=>{const ne=yb(Q.output||""),ce=bn(ne),fe=Ee[ce];if(!fe)return Q;const Ne=ne.lastIndexOf("/"),We=Ne>=0?ne.slice(0,Ne+1):"";return{...Q,output:We+fe}},[Ee]),Nn=yt??e,On=pt??y,pn=b.useMemo(()=>{const Q=new Map;for(const ce of Nn){const fe=Wi(ce);Q.set(Es(fe),fe)}for(const ce of s){const fe=Wi(ce),Ne=Es(fe);Q.has(Ne)&&Q.set(Ne,{...Q.get(Ne),...fe})}return Array.from(Q.values()).filter(ce=>q.has(Es(ce))||M3(ce.output)?!1:ce.status==="finished"||ce.status==="failed"||ce.status==="stopped")},[s,Nn,q,Wi]),ln=b.useRef(new Map);b.useEffect(()=>{const Q=new Map;for(const ne of pn){const ce=bn(ne.output||"");ce&&Q.set(ce,Es(ne))}ln.current=Q},[pn]),b.useEffect(()=>{const Q=ne=>{const ce=ne.detail;if(!ce?.file)return;const fe=ln.current.get(ce.file)||ce.file;if(ce.phase==="start"){Zi(fe,!0),qi(fe);return}if(ce.phase==="error"){Li(fe),kt.current.get(fe)?.reset();return}if(ce.phase==="success"){Zi(fe,!1);return}};return window.addEventListener("finished-downloads:delete",Q),()=>window.removeEventListener("finished-downloads:delete",Q)},[qi,Zi,Be,Li]),b.useEffect(()=>{const Q=()=>{if(ge.current){Ie.current||(Ie.current=!0);return}Xe.current==null&&Be()};return window.addEventListener("finished-downloads:reload",Q),()=>window.removeEventListener("finished-downloads:reload",Q)},[Be]),b.useEffect(()=>{const Q=ne=>{const ce=ne.detail,fe=String(ce?.oldFile??"").trim(),Ne=String(ce?.newFile??"").trim();!fe||!Ne||fe===Ne||Ge(fe,Ne)};return window.addEventListener("finished-downloads:rename",Q),()=>window.removeEventListener("finished-downloads:rename",Q)},[Ge]);const Is=b.useMemo(()=>{const Q=pn.filter(ce=>!q.has(Es(ce))),ne=Pi.length?Q.filter(ce=>{const fe=bn(ce.output||""),Ne=Zd(ce.output),We=Nr(Ne),xt=Zt.tagsByModelKey[We]??[],it=Nr([fe,vr(fe),Ne,ce.id,xt.join(" ")].join(" "));for(const mt of Pi)if(!it.includes(mt))return!1;return!0}):Q;return Qt.size===0?ne:ne.filter(ce=>{const fe=Nr(Zd(ce.output)),Ne=Zt.tagSetByModelKey[fe];if(!Ne||Ne.size===0)return!1;for(const We of Qt)if(!Ne.has(We))return!1;return!0})},[pn,q,Qt,Zt,Pi]),un=$?Is.length:On,Mn=b.useMemo(()=>{if(!$)return Is;const Q=(v-1)*T,ne=Q+T;return Is.slice(Math.max(0,Q),Math.max(0,ne))},[$,Is,v,T]),Js=!$&&un===0,en=V&&Is.length===0,zi=P&&Is.length===0,Pn=F&&(Js||zi||en);b.useEffect(()=>{if(!V)return;const Q=Math.max(1,Math.ceil(Is.length/T));v>Q&&S(Q)},[V,Is.length,v,T,S]),b.useEffect(()=>{if(!(G==="hover"&&!N&&(ke==="cards"||ke==="gallery"||ke==="table"))){z(null),J.current?.disconnect(),J.current=null;return}if(ke==="cards"&&qt?.key){z(qt.key);return}J.current?.disconnect();const ne=new IntersectionObserver(ce=>{let fe=null,Ne=0;for(const We of ce){if(!We.isIntersecting)continue;const xt=W.current.get(We.target);xt&&We.intersectionRatio>Ne&&(Ne=We.intersectionRatio,fe=xt)}fe&&z(We=>We===fe?We:fe)},{threshold:[0,.15,.3,.5,.7,.9],rootMargin:"0px"});J.current=ne;for(const[ce,fe]of R.current)W.current.set(fe,ce),ne.observe(fe);return()=>{ne.disconnect(),J.current===ne&&(J.current=null)}},[ke,G,N,qt?.key]);const _n=Q=>{const ne=Es(Q),ce=ht[ne]??Q?.durationSeconds;if(typeof ce=="number"&&Number.isFinite(ce)&&ce>0)return g2(ce*1e3);const fe=Date.parse(String(Q.startedAt||"")),Ne=Date.parse(String(Q.endedAt||""));return Number.isFinite(fe)&&Number.isFinite(Ne)&&Ne>fe?g2(Ne-fe):"—"},me=b.useCallback(Q=>ne=>{const ce=R.current.get(Q);ce&&J.current&&J.current.unobserve(ce),ne?(R.current.set(Q,ne),W.current.set(ne,Q),J.current?.observe(ne)):R.current.delete(Q)},[]),we=b.useCallback((Q,ne)=>{if(!Number.isFinite(ne)||ne<=0)return;const ce=Es(Q),fe=Yt.current[ce];typeof fe=="number"&&Math.abs(fe-ne)<.5||(Yt.current={...Yt.current,[ce]:ne},di())},[di]),ue=b.useCallback((Q,ne,ce)=>{if(!Number.isFinite(ne)||!Number.isFinite(ce)||ne<=0||ce<=0)return;const fe=Es(Q),Ne=Bi.current[fe];Ne&&Ne.w===ne&&Ne.h===ce||(Bi.current={...Bi.current,[fe]:{w:ne,h:ce}},ai())},[ai]),pe=y2("(max-width: 639px)"),xe="mt-10",Oe="mb-2";return b.useEffect(()=>{if(!pe||ke!=="cards")return;const Q=Mn[0];if(!Q){z(null);return}const ne=Es(Q);z(fe=>fe===ne?fe:null);const ce=window.setTimeout(()=>{z(fe=>fe===ne?fe:ne)},140);return()=>window.clearTimeout(ce)},[pe,ke,Mn,Es]),b.useEffect(()=>{pe||(kt.current=new Map)},[pe]),b.useEffect(()=>{Js&&v!==1&&S(1)},[Js,v,S]),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"sticky top-[56px] z-20",children:m.jsxs("div",{className:`\r
rounded-xl border border-gray-200/70 bg-white/80 shadow-sm\r
backdrop-blur supports-[backdrop-filter]:bg-white/60\r
dark:border-white/10 dark:bg-gray-950/60 dark:supports-[backdrop-filter]:bg-gray-950/40\r
`,children:[m.jsxs("div",{className:"flex items-center gap-3 p-3",children:[m.jsxs("div",{className:"hidden sm:flex items-center gap-2 min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),m.jsx("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-gray-200",children:un})]}),m.jsxs("div",{className:"sm:hidden flex items-center gap-2 min-w-0 flex-1",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),m.jsx("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-gray-200",children:un})]}),m.jsxs("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:[F?m.jsx(p2,{size:"lg",className:"text-indigo-500",srLabel:"Lade Downloads…"}):null,m.jsxs("div",{className:"hidden sm:flex items-center gap-2 min-w-0 flex-1",children:[m.jsx("input",{value:Et,onChange:Q=>Dt(Q.target.value),placeholder:"Suchen…",className:`\r
h-9 w-full max-w-[420px] rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900 shadow-sm\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:[color-scheme:dark]\r
`}),(Et||"").trim()!==""?m.jsx(ri,{size:"sm",variant:"soft",onClick:Jt,children:"Leeren"}):null]}),m.jsx("div",{className:"hidden sm:block",children:m.jsx(To,{label:"Behaltene Downloads anzeigen",checked:Ue,onChange:Q=>{v!==1&&S(1),at(Q)}})}),ke!=="table"&&m.jsxs("div",{className:"hidden sm:block",children:[m.jsx("label",{className:"sr-only",htmlFor:"finished-sort",children:"Sortierung"}),m.jsxs("select",{id:"finished-sort",value:L,onChange:Q=>{const ne=Q.target.value;O(ne),v!==1&&S(1)},className:`\r
h-9 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-900 shadow-sm\r
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:[color-scheme:dark]\r
`,children:[m.jsx("option",{value:"completed_desc",children:"Fertiggestellt am ↓"}),m.jsx("option",{value:"completed_asc",children:"Fertiggestellt am ↑"}),m.jsx("option",{value:"file_asc",children:"Modelname A→Z"}),m.jsx("option",{value:"file_desc",children:"Modelname Z→A"}),m.jsx("option",{value:"duration_desc",children:"Dauer ↓"}),m.jsx("option",{value:"duration_asc",children:"Dauer ↑"}),m.jsx("option",{value:"size_desc",children:"Größe ↓"}),m.jsx("option",{value:"size_asc",children:"Größe ↑"})]})]}),m.jsx(ri,{size:"md",variant:"soft",disabled:!Je||Re,onClick:Ct,title:Je?`Letzte Aktion rückgängig machen (${Je.kind})`:"Keine Aktion zum Rückgängig machen",children:"Undo"}),m.jsx(hx,{value:ke,onChange:Q=>De(Q),size:pe?"sm":"md",ariaLabel:"Ansicht",items:[{id:"table",icon:m.jsx(LM,{className:pe?"size-4":"size-5"}),label:pe?void 0:"Tabelle",srLabel:"Tabelle"},{id:"cards",icon:m.jsx(EM,{className:pe?"size-4":"size-5"}),label:pe?void 0:"Cards",srLabel:"Cards"},{id:"gallery",icon:m.jsx(kM,{className:pe?"size-4":"size-5"}),label:pe?void 0:"Galerie",srLabel:"Galerie"}]}),m.jsxs("button",{type:"button",className:`sm:hidden relative inline-flex items-center justify-center rounded-md border border-gray-200 bg-white p-2 shadow-sm\r
hover:bg-gray-50 dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:hover:bg-white/10`,onClick:()=>wt(Q=>!Q),"aria-expanded":dt,"aria-controls":"finished-mobile-options","aria-label":"Filter & Optionen",children:[m.jsx(HO,{className:"size-5"}),V||Ue?m.jsx("span",{className:"absolute -top-1 -right-1 h-2.5 w-2.5 rounded-full bg-indigo-500 ring-2 ring-white dark:ring-gray-950"}):null]})]})]}),Tt.length>0?m.jsxs("div",{className:"hidden sm:flex items-center gap-2 border-t border-gray-200/60 dark:border-white/10 px-3 py-2",children:[m.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Tag-Filter"}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Tt.map(Q=>m.jsx(Zr,{tag:Q,active:!0,onClick:ki},Q)),m.jsx(ri,{className:`\r
ml-1 inline-flex items-center rounded-md px-2 py-1 text-xs font-medium\r
text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-white/10\r
`,size:"sm",variant:"soft",onClick:Te,children:"Zurücksetzen"})]})]}):null,m.jsxs("div",{id:"finished-mobile-options",className:["sm:hidden overflow-hidden transition-[max-height,opacity] duration-200 ease-in-out",dt?"max-h-[720px] opacity-100":"max-h-0 opacity-0"].join(" "),children:[m.jsx("div",{className:"border-t border-gray-200/60 dark:border-white/10 p-3",children:m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-2 shadow-sm dark:border-white/10 dark:bg-gray-900/60",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{value:Et,onChange:Q=>Dt(Q.target.value),placeholder:"Suchen…",className:`\r
h-10 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:border-white/10 dark:bg-gray-950/60 dark:text-gray-100 dark:[color-scheme:dark]\r
`}),(Et||"").trim()!==""?m.jsx(ri,{size:"sm",variant:"soft",onClick:Jt,children:"Clear"}):null]})}),m.jsx("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 px-3 py-2 shadow-sm dark:border-white/10 dark:bg-gray-900/60",children:m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Keep anzeigen"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Behaltene Downloads in der Liste"})]}),m.jsx(dx,{checked:Ue,onChange:Q=>{v!==1&&S(1),at(Q)},ariaLabel:"Behaltene Downloads anzeigen",size:"default"})]})}),ke!=="table"?m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 px-3 py-2 shadow-sm dark:border-white/10 dark:bg-gray-900/60",children:[m.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 mb-1",children:"Sortierung"}),m.jsxs("select",{id:"finished-sort-mobile",value:L,onChange:Q=>{const ne=Q.target.value;O(ne),v!==1&&S(1)},className:`\r
w-full h-10 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-900 shadow-sm\r
dark:border-white/10 dark:bg-gray-950/60 dark:text-gray-100 dark:[color-scheme:dark]\r
`,children:[m.jsx("option",{value:"completed_desc",children:"Fertiggestellt am ↓"}),m.jsx("option",{value:"completed_asc",children:"Fertiggestellt am ↑"}),m.jsx("option",{value:"file_asc",children:"Modelname A→Z"}),m.jsx("option",{value:"file_desc",children:"Modelname Z→A"}),m.jsx("option",{value:"duration_desc",children:"Dauer ↓"}),m.jsx("option",{value:"duration_asc",children:"Dauer ↑"}),m.jsx("option",{value:"size_desc",children:"Größe ↓"}),m.jsx("option",{value:"size_asc",children:"Größe ↑"})]})]}):null]})}),Tt.length>0?m.jsx("div",{className:"border-t border-gray-200/60 dark:border-white/10 px-3 py-2",children:m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Tag-Filter"}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Tt.map(Q=>m.jsx(Zr,{tag:Q,active:!0,onClick:ki},Q)),m.jsx(ri,{className:`\r
ml-1 inline-flex items-center rounded-md px-2 py-1 text-xs font-medium\r
text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-white/10\r
`,size:"sm",variant:"soft",onClick:Te,children:"Zurücksetzen"})]})]})}):null]})]})}),Pn?m.jsx(pa,{grayBody:!0,children:m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Lade Downloads…"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Bitte warte einen Moment."})]}),m.jsx(p2,{size:"lg",className:"text-indigo-500",srLabel:"Lade Downloads…"})]})}):Js||zi?m.jsx(pa,{grayBody:!0,children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-white/70 ring-1 ring-gray-200 dark:bg-white/5 dark:ring-white/10",children:m.jsx("span",{className:"text-lg",children:"📁"})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Keine abgeschlossenen Downloads"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Im Zielordner ist aktuell nichts vorhanden."})]})]})}):en?m.jsxs(pa,{grayBody:!0,children:[m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine Treffer für die aktuellen Filter."}),Tt.length>0||(Et||"").trim()!==""?m.jsxs("div",{className:"mt-2 flex flex-wrap gap-3",children:[Tt.length>0?m.jsx("button",{type:"button",className:"text-sm font-medium text-gray-700 hover:underline dark:text-gray-200",onClick:Te,children:"Tag-Filter zurücksetzen"}):null,(Et||"").trim()!==""?m.jsx("button",{type:"button",className:"text-sm font-medium text-gray-700 hover:underline dark:text-gray-200",onClick:Jt,children:"Suche zurücksetzen"}):null]}):null]}):m.jsxs(m.Fragment,{children:[ke==="cards"&&m.jsx("div",{className:pe?`${xe} ${Oe}`:"",children:m.jsx(d3,{rows:Mn,isSmall:pe,isLoading:F,blurPreviews:t,durations:ht,teaserKey:Y,teaserPlayback:G,teaserAudio:n,hoverTeaserKey:X,inlinePlay:qt,deletingKeys:te,keepingKeys:$i,removingKeys:$s,swipeRefs:kt,keyFor:Es,baseName:bn,modelNameFromOutput:Zd,runtimeOf:_n,sizeBytesOf:Hy,formatBytes:$y,lower:Nr,onOpenPlayer:r,openPlayer:xs,onOpenPlayerAt:Gi,handleScrubberClickIndex:fi,startInlineAt:vs,startInline:ss,tryAutoplayInline:Ci,registerTeaserHost:me,handleDuration:we,deleteVideo:Fi,keepVideo:Hi,releasePlayingFile:bs,modelsByKey:I,onToggleHot:ei,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,activeTagSet:Qt,onToggleTagFilter:ki,onHoverPreviewKeyChange:re,assetNonce:w??0,enqueueDeleteVideo:Ki,enqueueKeepVideo:Ts,enqueueToggleHot:In})}),ke==="table"&&m.jsx(b3,{rows:Mn,isLoading:F,keyFor:Es,baseName:bn,lower:Nr,modelNameFromOutput:Zd,runtimeOf:_n,sizeBytesOf:Hy,formatBytes:$y,resolutions:oi,durations:ht,canHover:N,teaserAudio:n,hoverTeaserKey:X,setHoverTeaserKey:re,teaserPlayback:G,teaserKey:Y,registerTeaserHost:me,handleDuration:we,handleResolution:ue,blurPreviews:t,assetNonce:w,deletingKeys:te,keepingKeys:$i,removingKeys:$s,modelsByKey:I,activeTagSet:Qt,onToggleTagFilter:ki,onOpenPlayer:r,handleScrubberClickIndex:fi,onSortModeChange:O,page:v,onPageChange:S,onToggleHot:ei,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,deleteVideo:Fi,keepVideo:Hi,enqueueDeleteVideo:Ki,enqueueKeepVideo:Ts,enqueueToggleHot:In}),ke==="gallery"&&m.jsx(E3,{rows:Mn,isLoading:F,blurPreviews:t,durations:ht,handleDuration:we,teaserKey:Y,teaserPlayback:G,teaserAudio:n,hoverTeaserKey:X,keyFor:Es,baseName:bn,modelNameFromOutput:Zd,runtimeOf:_n,sizeBytesOf:Hy,formatBytes:$y,deletingKeys:te,keepingKeys:$i,removingKeys:$s,deletedKeys:q,registerTeaserHost:me,onOpenPlayer:r,handleScrubberClickIndex:fi,deleteVideo:Fi,keepVideo:Hi,onToggleHot:ei,lower:Nr,modelsByKey:I,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,activeTagSet:Qt,onToggleTagFilter:ki,onHoverPreviewKeyChange:re,enqueueDeleteVideo:Ki,enqueueKeepVideo:Ts,enqueueToggleHot:In}),m.jsx(mx,{page:v,pageSize:T,totalItems:un,onPageChange:Q=>{Nc.flushSync(()=>{Mt(null),z(null),re(null)});for(const ne of Mn){const ce=bn(ne.output||"");ce&&(window.dispatchEvent(new CustomEvent("player:release",{detail:{file:ce}})),window.dispatchEvent(new CustomEvent("player:close",{detail:{file:ce}})))}window.scrollTo({top:0,behavior:"auto"}),S(Q)},showSummary:!1,prevLabel:"Zurück",nextLabel:"Weiter",className:"mt-4"})]})]})}var Vy,b2;function cp(){if(b2)return Vy;b2=1;var s;return typeof window<"u"?s=window:typeof h0<"u"?s=h0:typeof self<"u"?s=self:s={},Vy=s,Vy}var j3=cp();const ye=Kc(j3),$3={},H3=Object.freeze(Object.defineProperty({__proto__:null,default:$3},Symbol.toStringTag,{value:"Module"})),z3=lN(H3);var Gy,T2;function gk(){if(T2)return Gy;T2=1;var s=typeof h0<"u"?h0:typeof window<"u"?window:{},e=z3,t;return typeof document<"u"?t=document:(t=s["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=s["__GLOBAL_DOCUMENT_CACHE@4"]=e)),Gy=t,Gy}var V3=gk();const bt=Kc(V3);var wm={exports:{}},qy={exports:{}},S2;function G3(){return S2||(S2=1,(function(s){function e(){return s.exports=e=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s.exports.__esModule=!0,s.exports.default=s.exports,e.apply(null,arguments)}s.exports=e,s.exports.__esModule=!0,s.exports.default=s.exports})(qy)),qy.exports}var Ky,_2;function q3(){if(_2)return Ky;_2=1,Ky=e;var s=Object.prototype.toString;function e(t){if(!t)return!1;var i=s.call(t);return i==="[object Function]"||typeof t=="function"&&i!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}return Ky}var Wy,E2;function K3(){if(E2)return Wy;E2=1;function s(n,r){var a=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a)return(a=a.call(n)).next.bind(a);if(Array.isArray(n)||(a=e(n))||r){a&&(n=a);var u=0;return function(){return u>=n.length?{done:!0}:{done:!1,value:n[u++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function e(n,r){if(n){if(typeof n=="string")return t(n,r);var a=Object.prototype.toString.call(n).slice(8,-1);if(a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set")return Array.from(n);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return t(n,r)}}function t(n,r){(r==null||r>n.length)&&(r=n.length);for(var a=0,u=new Array(r);a<r;a++)u[a]=n[a];return u}var i=(function(){function n(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var r=n.prototype;return r.getIsEnabled=function(){return this.enabled_},r.enable=function(){this.enabled_=!0},r.disable=function(){this.enabled_=!1},r.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},r.addInterceptor=function(u,c){this.typeToInterceptorsMap_.has(u)||this.typeToInterceptorsMap_.set(u,new Set);var d=this.typeToInterceptorsMap_.get(u);return d.has(c)?!1:(d.add(c),!0)},r.removeInterceptor=function(u,c){var d=this.typeToInterceptorsMap_.get(u);return d&&d.has(c)?(d.delete(c),!0):!1},r.clearInterceptorsByType=function(u){var c=this.typeToInterceptorsMap_.get(u);return c?(this.typeToInterceptorsMap_.delete(u),this.typeToInterceptorsMap_.set(u,new Set),!0):!1},r.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},r.getForType=function(u){return this.typeToInterceptorsMap_.get(u)||new Set},r.execute=function(u,c){for(var d=this.getForType(u),f=s(d),g;!(g=f()).done;){var y=g.value;try{c=y(c)}catch{}}return c},n})();return Wy=i,Wy}var Yy,w2;function W3(){if(w2)return Yy;w2=1;var s=(function(){function t(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var i=t.prototype;return i.getIsEnabled=function(){return this.enabled_},i.enable=function(){this.enabled_=!0},i.disable=function(){this.enabled_=!1},i.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},i.getMaxAttempts=function(){return this.maxAttempts_},i.setMaxAttempts=function(r){this.maxAttempts_=r},i.getDelayFactor=function(){return this.delayFactor_},i.setDelayFactor=function(r){this.delayFactor_=r},i.getFuzzFactor=function(){return this.fuzzFactor_},i.setFuzzFactor=function(r){this.fuzzFactor_=r},i.getInitialDelay=function(){return this.initialDelay_},i.setInitialDelay=function(r){this.initialDelay_=r},i.createRetry=function(r){var a=r===void 0?{}:r,u=a.maxAttempts,c=a.delayFactor,d=a.fuzzFactor,f=a.initialDelay;return new e({maxAttempts:u||this.maxAttempts_,delayFactor:c||this.delayFactor_,fuzzFactor:d||this.fuzzFactor_,initialDelay:f||this.initialDelay_})},t})(),e=(function(){function t(n){this.maxAttempts_=n.maxAttempts,this.delayFactor_=n.delayFactor,this.fuzzFactor_=n.fuzzFactor,this.currentDelay_=n.initialDelay,this.currentAttempt_=1}var i=t.prototype;return i.moveToNextAttempt=function(){this.currentAttempt_++;var r=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+r},i.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},i.getCurrentDelay=function(){return this.currentDelay_},i.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},i.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},i.getCurrentFuzzedDelay=function(){var r=this.getCurrentMinPossibleDelay(),a=this.getCurrentMaxPossibleDelay();return r+Math.random()*(a-r)},t})();return Yy=s,Yy}var Xy,A2;function Y3(){if(A2)return Xy;A2=1;var s=cp(),e=function(n,r){return r===void 0&&(r=!1),function(a,u,c){if(a){n(a);return}if(u.statusCode>=400&&u.statusCode<=599){var d=c;if(r)if(s.TextDecoder){var f=t(u.headers&&u.headers["content-type"]);try{d=new TextDecoder(f).decode(c)}catch{}}else d=String.fromCharCode.apply(null,new Uint8Array(c));n({cause:d});return}n(null,c)}};function t(i){return i===void 0&&(i=""),i.toLowerCase().split(";").reduce(function(n,r){var a=r.split("="),u=a[0],c=a[1];return u.trim()==="charset"?c.trim():n},"utf-8")}return Xy=e,Xy}var k2;function X3(){if(k2)return wm.exports;k2=1;var s=cp(),e=G3(),t=q3(),i=K3(),n=W3();d.httpHandler=Y3(),d.requestInterceptorsStorage=new i,d.responseInterceptorsStorage=new i,d.retryManager=new n;var r=function(T){var S={};return T&&T.trim().split(`
`).forEach(function(w){var L=w.indexOf(":"),O=w.slice(0,L).trim().toLowerCase(),I=w.slice(L+1).trim();typeof S[O]>"u"?S[O]=I:Array.isArray(S[O])?S[O].push(I):S[O]=[S[O],I]}),S};wm.exports=d,wm.exports.default=d,d.XMLHttpRequest=s.XMLHttpRequest||y,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:s.XDomainRequest,a(["get","put","post","patch","head","delete"],function(v){d[v==="delete"?"del":v]=function(T,S,w){return S=c(T,S,w),S.method=v.toUpperCase(),f(S)}});function a(v,T){for(var S=0;S<v.length;S++)T(v[S])}function u(v){for(var T in v)if(v.hasOwnProperty(T))return!1;return!0}function c(v,T,S){var w=v;return t(T)?(S=T,typeof v=="string"&&(w={uri:v})):w=e({},T,{uri:v}),w.callback=S,w}function d(v,T,S){return T=c(v,T,S),f(T)}function f(v){if(typeof v.callback>"u")throw new Error("callback argument missing");if(v.requestType&&d.requestInterceptorsStorage.getIsEnabled()){var T={uri:v.uri||v.url,headers:v.headers||{},body:v.body,metadata:v.metadata||{},retry:v.retry,timeout:v.timeout},S=d.requestInterceptorsStorage.execute(v.requestType,T);v.uri=S.uri,v.headers=S.headers,v.body=S.body,v.metadata=S.metadata,v.retry=S.retry,v.timeout=S.timeout}var w=!1,L=function(Z,te,oe){w||(w=!0,v.callback(Z,te,oe))};function O(){G.readyState===4&&!d.responseInterceptorsStorage.getIsEnabled()&&setTimeout(P,0)}function I(){var q=void 0;if(G.response?q=G.response:q=G.responseText||g(G),re)try{q=JSON.parse(q)}catch{}return q}function j(q){if(clearTimeout(J),clearTimeout(v.retryTimeout),q instanceof Error||(q=new Error(""+(q||"Unknown XMLHttpRequest Error"))),q.statusCode=0,!K&&d.retryManager.getIsEnabled()&&v.retry&&v.retry.shouldRetry()){v.retryTimeout=setTimeout(function(){v.retry.moveToNextAttempt(),v.xhr=G,f(v)},v.retry.getCurrentFuzzedDelay());return}if(v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var Z={headers:W.headers||{},body:W.body,responseUrl:G.responseURL,responseType:G.responseType},te=d.responseInterceptorsStorage.execute(v.requestType,Z);W.body=te.body,W.headers=te.headers}return L(q,W)}function P(){if(!K){var q;clearTimeout(J),clearTimeout(v.retryTimeout),v.useXDR&&G.status===void 0?q=200:q=G.status===1223?204:G.status;var Z=W,te=null;if(q!==0?(Z={body:I(),statusCode:q,method:R,headers:{},url:k,rawRequest:G},G.getAllResponseHeaders&&(Z.headers=r(G.getAllResponseHeaders()))):te=new Error("Internal XMLHttpRequest Error"),v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var oe={headers:Z.headers||{},body:Z.body,responseUrl:G.responseURL,responseType:G.responseType},F=d.responseInterceptorsStorage.execute(v.requestType,oe);Z.body=F.body,Z.headers=F.headers}return L(te,Z,Z.body)}}var G=v.xhr||null;G||(v.cors||v.useXDR?G=new d.XDomainRequest:G=new d.XMLHttpRequest);var N,K,k=G.url=v.uri||v.url,R=G.method=v.method||"GET",Y=v.body||v.data,z=G.headers=v.headers||{},X=!!v.sync,re=!1,J,W={body:void 0,headers:{},statusCode:0,method:R,url:k,rawRequest:G};if("json"in v&&v.json!==!1&&(re=!0,z.accept||z.Accept||(z.Accept="application/json"),R!=="GET"&&R!=="HEAD"&&(z["content-type"]||z["Content-Type"]||(z["Content-Type"]="application/json"),Y=JSON.stringify(v.json===!0?Y:v.json))),G.onreadystatechange=O,G.onload=P,G.onerror=j,G.onprogress=function(){},G.onabort=function(){K=!0,clearTimeout(v.retryTimeout)},G.ontimeout=j,G.open(R,k,!X,v.username,v.password),X||(G.withCredentials=!!v.withCredentials),!X&&v.timeout>0&&(J=setTimeout(function(){if(!K){K=!0,G.abort("timeout");var q=new Error("XMLHttpRequest timeout");q.code="ETIMEDOUT",j(q)}},v.timeout)),G.setRequestHeader)for(N in z)z.hasOwnProperty(N)&&G.setRequestHeader(N,z[N]);else if(v.headers&&!u(v.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in v&&(G.responseType=v.responseType),"beforeSend"in v&&typeof v.beforeSend=="function"&&v.beforeSend(G),G.send(Y||null),G}function g(v){try{if(v.responseType==="document")return v.responseXML;var T=v.responseXML&&v.responseXML.documentElement.nodeName==="parsererror";if(v.responseType===""&&!T)return v.responseXML}catch{}return null}function y(){}return wm.exports}var Q3=X3();const yk=Kc(Q3);var Qy={exports:{}},Zy,C2;function Z3(){if(C2)return Zy;C2=1;var s=gk(),e=Object.create||(function(){function k(){}return function(R){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return k.prototype=R,new k}})();function t(k,R){this.name="ParsingError",this.code=k.code,this.message=R||k.message}t.prototype=e(Error.prototype),t.prototype.constructor=t,t.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function i(k){function R(z,X,re,J){return(z|0)*3600+(X|0)*60+(re|0)+(J|0)/1e3}var Y=k.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return Y?Y[3]?R(Y[1],Y[2],Y[3].replace(":",""),Y[4]):Y[1]>59?R(Y[1],Y[2],0,Y[4]):R(0,Y[1],Y[2],Y[4]):null}function n(){this.values=e(null)}n.prototype={set:function(k,R){!this.get(k)&&R!==""&&(this.values[k]=R)},get:function(k,R,Y){return Y?this.has(k)?this.values[k]:R[Y]:this.has(k)?this.values[k]:R},has:function(k){return k in this.values},alt:function(k,R,Y){for(var z=0;z<Y.length;++z)if(R===Y[z]){this.set(k,R);break}},integer:function(k,R){/^-?\d+$/.test(R)&&this.set(k,parseInt(R,10))},percent:function(k,R){return R.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(R=parseFloat(R),R>=0&&R<=100)?(this.set(k,R),!0):!1}};function r(k,R,Y,z){var X=z?k.split(z):[k];for(var re in X)if(typeof X[re]=="string"){var J=X[re].split(Y);if(J.length===2){var W=J[0].trim(),q=J[1].trim();R(W,q)}}}function a(k,R,Y){var z=k;function X(){var W=i(k);if(W===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+z);return k=k.replace(/^[^\sa-zA-Z-]+/,""),W}function re(W,q){var Z=new n;r(W,function(te,oe){switch(te){case"region":for(var F=Y.length-1;F>=0;F--)if(Y[F].id===oe){Z.set(te,Y[F].region);break}break;case"vertical":Z.alt(te,oe,["rl","lr"]);break;case"line":var le=oe.split(","),ge=le[0];Z.integer(te,ge),Z.percent(te,ge)&&Z.set("snapToLines",!1),Z.alt(te,ge,["auto"]),le.length===2&&Z.alt("lineAlign",le[1],["start","center","end"]);break;case"position":le=oe.split(","),Z.percent(te,le[0]),le.length===2&&Z.alt("positionAlign",le[1],["start","center","end"]);break;case"size":Z.percent(te,oe);break;case"align":Z.alt(te,oe,["start","center","end","left","right"]);break}},/:/,/\s/),q.region=Z.get("region",null),q.vertical=Z.get("vertical","");try{q.line=Z.get("line","auto")}catch{}q.lineAlign=Z.get("lineAlign","start"),q.snapToLines=Z.get("snapToLines",!0),q.size=Z.get("size",100);try{q.align=Z.get("align","center")}catch{q.align=Z.get("align","middle")}try{q.position=Z.get("position","auto")}catch{q.position=Z.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},q.align)}q.positionAlign=Z.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},q.align)}function J(){k=k.replace(/^\s+/,"")}if(J(),R.startTime=X(),J(),k.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+z);k=k.substr(3),J(),R.endTime=X(),J(),re(k,R)}var u=s.createElement&&s.createElement("textarea"),c={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},d={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},f={v:"title",lang:"lang"},g={rt:"ruby"};function y(k,R){function Y(){if(!R)return null;function ge(Le){return R=R.substr(Le.length),Le}var Ie=R.match(/^([^<]*)(<[^>]*>?)?/);return ge(Ie[1]?Ie[1]:Ie[2])}function z(ge){return u.innerHTML=ge,ge=u.textContent,u.textContent="",ge}function X(ge,Ie){return!g[Ie.localName]||g[Ie.localName]===ge.localName}function re(ge,Ie){var Le=c[ge];if(!Le)return null;var Pe=k.document.createElement(Le),Je=f[ge];return Je&&Ie&&(Pe[Je]=Ie.trim()),Pe}for(var J=k.document.createElement("div"),W=J,q,Z=[];(q=Y())!==null;){if(q[0]==="<"){if(q[1]==="/"){Z.length&&Z[Z.length-1]===q.substr(2).replace(">","")&&(Z.pop(),W=W.parentNode);continue}var te=i(q.substr(1,q.length-2)),oe;if(te){oe=k.document.createProcessingInstruction("timestamp",te),W.appendChild(oe);continue}var F=q.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!F||(oe=re(F[1],F[3]),!oe)||!X(W,oe))continue;if(F[2]){var le=F[2].split(".");le.forEach(function(ge){var Ie=/^bg_/.test(ge),Le=Ie?ge.slice(3):ge;if(d.hasOwnProperty(Le)){var Pe=Ie?"background-color":"color",Je=d[Le];oe.style[Pe]=Je}}),oe.className=le.join(" ")}Z.push(F[1]),W.appendChild(oe),W=oe;continue}W.appendChild(k.document.createTextNode(z(q)))}return J}var v=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function T(k){for(var R=0;R<v.length;R++){var Y=v[R];if(k>=Y[0]&&k<=Y[1])return!0}return!1}function S(k){var R=[],Y="",z;if(!k||!k.childNodes)return"ltr";function X(W,q){for(var Z=q.childNodes.length-1;Z>=0;Z--)W.push(q.childNodes[Z])}function re(W){if(!W||!W.length)return null;var q=W.pop(),Z=q.textContent||q.innerText;if(Z){var te=Z.match(/^.*(\n|\r)/);return te?(W.length=0,te[0]):Z}if(q.tagName==="ruby")return re(W);if(q.childNodes)return X(W,q),re(W)}for(X(R,k);Y=re(R);)for(var J=0;J<Y.length;J++)if(z=Y.charCodeAt(J),T(z))return"rtl";return"ltr"}function w(k){if(typeof k.line=="number"&&(k.snapToLines||k.line>=0&&k.line<=100))return k.line;if(!k.track||!k.track.textTrackList||!k.track.textTrackList.mediaElement)return-1;for(var R=k.track,Y=R.textTrackList,z=0,X=0;X<Y.length&&Y[X]!==R;X++)Y[X].mode==="showing"&&z++;return++z*-1}function L(){}L.prototype.applyStyles=function(k,R){R=R||this.div;for(var Y in k)k.hasOwnProperty(Y)&&(R.style[Y]=k[Y])},L.prototype.formatStyle=function(k,R){return k===0?0:k+R};function O(k,R,Y){L.call(this),this.cue=R,this.cueDiv=y(k,R.text);var z={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:R.vertical===""?"horizontal-tb":R.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(z,this.cueDiv),this.div=k.document.createElement("div"),z={direction:S(this.cueDiv),writingMode:R.vertical===""?"horizontal-tb":R.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:R.align==="middle"?"center":R.align,font:Y.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(z),this.div.appendChild(this.cueDiv);var X=0;switch(R.positionAlign){case"start":case"line-left":X=R.position;break;case"center":X=R.position-R.size/2;break;case"end":case"line-right":X=R.position-R.size;break}R.vertical===""?this.applyStyles({left:this.formatStyle(X,"%"),width:this.formatStyle(R.size,"%")}):this.applyStyles({top:this.formatStyle(X,"%"),height:this.formatStyle(R.size,"%")}),this.move=function(re){this.applyStyles({top:this.formatStyle(re.top,"px"),bottom:this.formatStyle(re.bottom,"px"),left:this.formatStyle(re.left,"px"),right:this.formatStyle(re.right,"px"),height:this.formatStyle(re.height,"px"),width:this.formatStyle(re.width,"px")})}}O.prototype=e(L.prototype),O.prototype.constructor=O;function I(k){var R,Y,z,X;if(k.div){Y=k.div.offsetHeight,z=k.div.offsetWidth,X=k.div.offsetTop;var re=(re=k.div.childNodes)&&(re=re[0])&&re.getClientRects&&re.getClientRects();k=k.div.getBoundingClientRect(),R=re?Math.max(re[0]&&re[0].height||0,k.height/re.length):0}this.left=k.left,this.right=k.right,this.top=k.top||X,this.height=k.height||Y,this.bottom=k.bottom||X+(k.height||Y),this.width=k.width||z,this.lineHeight=R!==void 0?R:k.lineHeight}I.prototype.move=function(k,R){switch(R=R!==void 0?R:this.lineHeight,k){case"+x":this.left+=R,this.right+=R;break;case"-x":this.left-=R,this.right-=R;break;case"+y":this.top+=R,this.bottom+=R;break;case"-y":this.top-=R,this.bottom-=R;break}},I.prototype.overlaps=function(k){return this.left<k.right&&this.right>k.left&&this.top<k.bottom&&this.bottom>k.top},I.prototype.overlapsAny=function(k){for(var R=0;R<k.length;R++)if(this.overlaps(k[R]))return!0;return!1},I.prototype.within=function(k){return this.top>=k.top&&this.bottom<=k.bottom&&this.left>=k.left&&this.right<=k.right},I.prototype.overlapsOppositeAxis=function(k,R){switch(R){case"+x":return this.left<k.left;case"-x":return this.right>k.right;case"+y":return this.top<k.top;case"-y":return this.bottom>k.bottom}},I.prototype.intersectPercentage=function(k){var R=Math.max(0,Math.min(this.right,k.right)-Math.max(this.left,k.left)),Y=Math.max(0,Math.min(this.bottom,k.bottom)-Math.max(this.top,k.top)),z=R*Y;return z/(this.height*this.width)},I.prototype.toCSSCompatValues=function(k){return{top:this.top-k.top,bottom:k.bottom-this.bottom,left:this.left-k.left,right:k.right-this.right,height:this.height,width:this.width}},I.getSimpleBoxPosition=function(k){var R=k.div?k.div.offsetHeight:k.tagName?k.offsetHeight:0,Y=k.div?k.div.offsetWidth:k.tagName?k.offsetWidth:0,z=k.div?k.div.offsetTop:k.tagName?k.offsetTop:0;k=k.div?k.div.getBoundingClientRect():k.tagName?k.getBoundingClientRect():k;var X={left:k.left,right:k.right,top:k.top||z,height:k.height||R,bottom:k.bottom||z+(k.height||R),width:k.width||Y};return X};function j(k,R,Y,z){function X(Le,Pe){for(var Je,Se=new I(Le),Re=1,Ve=0;Ve<Pe.length;Ve++){for(;Le.overlapsOppositeAxis(Y,Pe[Ve])||Le.within(Y)&&Le.overlapsAny(z);)Le.move(Pe[Ve]);if(Le.within(Y))return Le;var Ee=Le.intersectPercentage(Y);Re>Ee&&(Je=new I(Le),Re=Ee),Le=new I(Se)}return Je||Se}var re=new I(R),J=R.cue,W=w(J),q=[];if(J.snapToLines){var Z;switch(J.vertical){case"":q=["+y","-y"],Z="height";break;case"rl":q=["+x","-x"],Z="width";break;case"lr":q=["-x","+x"],Z="width";break}var te=re.lineHeight,oe=te*Math.round(W),F=Y[Z]+te,le=q[0];Math.abs(oe)>F&&(oe=oe<0?-1:1,oe*=Math.ceil(F/te)*te),W<0&&(oe+=J.vertical===""?Y.height:Y.width,q=q.reverse()),re.move(le,oe)}else{var ge=re.lineHeight/Y.height*100;switch(J.lineAlign){case"center":W-=ge/2;break;case"end":W-=ge;break}switch(J.vertical){case"":R.applyStyles({top:R.formatStyle(W,"%")});break;case"rl":R.applyStyles({left:R.formatStyle(W,"%")});break;case"lr":R.applyStyles({right:R.formatStyle(W,"%")});break}q=["+y","-x","+x","-y"],re=new I(R)}var Ie=X(re,q);R.move(Ie.toCSSCompatValues(Y))}function P(){}P.StringDecoder=function(){return{decode:function(k){if(!k)return"";if(typeof k!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(k))}}},P.convertCueToDOMTree=function(k,R){return!k||!R?null:y(k,R)};var G=.05,N="sans-serif",K="1.5%";return P.processCues=function(k,R,Y){if(!k||!R||!Y)return null;for(;Y.firstChild;)Y.removeChild(Y.firstChild);var z=k.document.createElement("div");z.style.position="absolute",z.style.left="0",z.style.right="0",z.style.top="0",z.style.bottom="0",z.style.margin=K,Y.appendChild(z);function X(te){for(var oe=0;oe<te.length;oe++)if(te[oe].hasBeenReset||!te[oe].displayState)return!0;return!1}if(!X(R)){for(var re=0;re<R.length;re++)z.appendChild(R[re].displayState);return}var J=[],W=I.getSimpleBoxPosition(z),q=Math.round(W.height*G*100)/100,Z={font:q+"px "+N};(function(){for(var te,oe,F=0;F<R.length;F++)oe=R[F],te=new O(k,oe,Z),z.appendChild(te.div),j(k,te,W,J),oe.displayState=te.div,J.push(I.getSimpleBoxPosition(te))})()},P.Parser=function(k,R,Y){Y||(Y=R,R={}),R||(R={}),this.window=k,this.vttjs=R,this.state="INITIAL",this.buffer="",this.decoder=Y||new TextDecoder("utf8"),this.regionList=[]},P.Parser.prototype={reportOrThrowError:function(k){if(k instanceof t)this.onparsingerror&&this.onparsingerror(k);else throw k},parse:function(k){var R=this;k&&(R.buffer+=R.decoder.decode(k,{stream:!0}));function Y(){for(var te=R.buffer,oe=0;oe<te.length&&te[oe]!=="\r"&&te[oe]!==`
`;)++oe;var F=te.substr(0,oe);return te[oe]==="\r"&&++oe,te[oe]===`
`&&++oe,R.buffer=te.substr(oe),F}function z(te){var oe=new n;if(r(te,function(le,ge){switch(le){case"id":oe.set(le,ge);break;case"width":oe.percent(le,ge);break;case"lines":oe.integer(le,ge);break;case"regionanchor":case"viewportanchor":var Ie=ge.split(",");if(Ie.length!==2)break;var Le=new n;if(Le.percent("x",Ie[0]),Le.percent("y",Ie[1]),!Le.has("x")||!Le.has("y"))break;oe.set(le+"X",Le.get("x")),oe.set(le+"Y",Le.get("y"));break;case"scroll":oe.alt(le,ge,["up"]);break}},/=/,/\s/),oe.has("id")){var F=new(R.vttjs.VTTRegion||R.window.VTTRegion);F.width=oe.get("width",100),F.lines=oe.get("lines",3),F.regionAnchorX=oe.get("regionanchorX",0),F.regionAnchorY=oe.get("regionanchorY",100),F.viewportAnchorX=oe.get("viewportanchorX",0),F.viewportAnchorY=oe.get("viewportanchorY",100),F.scroll=oe.get("scroll",""),R.onregion&&R.onregion(F),R.regionList.push({id:oe.get("id"),region:F})}}function X(te){var oe=new n;r(te,function(F,le){switch(F){case"MPEGT":oe.integer(F+"S",le);break;case"LOCA":oe.set(F+"L",i(le));break}},/[^\d]:/,/,/),R.ontimestampmap&&R.ontimestampmap({MPEGTS:oe.get("MPEGTS"),LOCAL:oe.get("LOCAL")})}function re(te){te.match(/X-TIMESTAMP-MAP/)?r(te,function(oe,F){oe==="X-TIMESTAMP-MAP"&&X(F)},/=/):r(te,function(oe,F){oe==="Region"&&z(F)},/:/)}try{var J;if(R.state==="INITIAL"){if(!/\r\n|\n/.test(R.buffer))return this;J=Y();var W=J.match(/^WEBVTT([ \t].*)?$/);if(!W||!W[0])throw new t(t.Errors.BadSignature);R.state="HEADER"}for(var q=!1;R.buffer;){if(!/\r\n|\n/.test(R.buffer))return this;switch(q?q=!1:J=Y(),R.state){case"HEADER":/:/.test(J)?re(J):J||(R.state="ID");continue;case"NOTE":J||(R.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(J)){R.state="NOTE";break}if(!J)continue;R.cue=new(R.vttjs.VTTCue||R.window.VTTCue)(0,0,"");try{R.cue.align="center"}catch{R.cue.align="middle"}if(R.state="CUE",J.indexOf("-->")===-1){R.cue.id=J;continue}case"CUE":try{a(J,R.cue,R.regionList)}catch(te){R.reportOrThrowError(te),R.cue=null,R.state="BADCUE";continue}R.state="CUETEXT";continue;case"CUETEXT":var Z=J.indexOf("-->")!==-1;if(!J||Z&&(q=!0)){R.oncue&&R.oncue(R.cue),R.cue=null,R.state="ID";continue}R.cue.text&&(R.cue.text+=`
`),R.cue.text+=J.replace(/\u2028/g,`
`).replace(/u2029/g,`
`);continue;case"BADCUE":J||(R.state="ID");continue}}}catch(te){R.reportOrThrowError(te),R.state==="CUETEXT"&&R.cue&&R.oncue&&R.oncue(R.cue),R.cue=null,R.state=R.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var k=this;try{if(k.buffer+=k.decoder.decode(),(k.cue||k.state==="HEADER")&&(k.buffer+=`
`,k.parse()),k.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(R){k.reportOrThrowError(R)}return k.onflush&&k.onflush(),this}},Zy=P,Zy}var Jy,D2;function J3(){if(D2)return Jy;D2=1;var s="auto",e={"":1,lr:1,rl:1},t={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function i(a){if(typeof a!="string")return!1;var u=e[a.toLowerCase()];return u?a.toLowerCase():!1}function n(a){if(typeof a!="string")return!1;var u=t[a.toLowerCase()];return u?a.toLowerCase():!1}function r(a,u,c){this.hasBeenReset=!1;var d="",f=!1,g=a,y=u,v=c,T=null,S="",w=!0,L="auto",O="start",I="auto",j="auto",P=100,G="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return d},set:function(N){d=""+N}},pauseOnExit:{enumerable:!0,get:function(){return f},set:function(N){f=!!N}},startTime:{enumerable:!0,get:function(){return g},set:function(N){if(typeof N!="number")throw new TypeError("Start time must be set to a number.");g=N,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return y},set:function(N){if(typeof N!="number")throw new TypeError("End time must be set to a number.");y=N,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return v},set:function(N){v=""+N,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return T},set:function(N){T=N,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return S},set:function(N){var K=i(N);if(K===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");S=K,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return w},set:function(N){w=!!N,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return L},set:function(N){if(typeof N!="number"&&N!==s)throw new SyntaxError("Line: an invalid number or illegal string was specified.");L=N,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return O},set:function(N){var K=n(N);K?(O=K,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return I},set:function(N){if(N<0||N>100)throw new Error("Position must be between 0 and 100.");I=N,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return j},set:function(N){var K=n(N);K?(j=K,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return P},set:function(N){if(N<0||N>100)throw new Error("Size must be between 0 and 100.");P=N,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return G},set:function(N){var K=n(N);if(!K)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");G=K,this.hasBeenReset=!0}}}),this.displayState=void 0}return r.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},Jy=r,Jy}var ev,L2;function eP(){if(L2)return ev;L2=1;var s={"":!0,up:!0};function e(n){if(typeof n!="string")return!1;var r=s[n.toLowerCase()];return r?n.toLowerCase():!1}function t(n){return typeof n=="number"&&n>=0&&n<=100}function i(){var n=100,r=3,a=0,u=100,c=0,d=100,f="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return n},set:function(g){if(!t(g))throw new Error("Width must be between 0 and 100.");n=g}},lines:{enumerable:!0,get:function(){return r},set:function(g){if(typeof g!="number")throw new TypeError("Lines must be set to a number.");r=g}},regionAnchorY:{enumerable:!0,get:function(){return u},set:function(g){if(!t(g))throw new Error("RegionAnchorX must be between 0 and 100.");u=g}},regionAnchorX:{enumerable:!0,get:function(){return a},set:function(g){if(!t(g))throw new Error("RegionAnchorY must be between 0 and 100.");a=g}},viewportAnchorY:{enumerable:!0,get:function(){return d},set:function(g){if(!t(g))throw new Error("ViewportAnchorY must be between 0 and 100.");d=g}},viewportAnchorX:{enumerable:!0,get:function(){return c},set:function(g){if(!t(g))throw new Error("ViewportAnchorX must be between 0 and 100.");c=g}},scroll:{enumerable:!0,get:function(){return f},set:function(g){var y=e(g);y===!1?console.warn("Scroll: an invalid or illegal string was specified."):f=y}}})}return ev=i,ev}var R2;function tP(){if(R2)return Qy.exports;R2=1;var s=cp(),e=Qy.exports={WebVTT:Z3(),VTTCue:J3(),VTTRegion:eP()};s.vttjs=e,s.WebVTT=e.WebVTT;var t=e.VTTCue,i=e.VTTRegion,n=s.VTTCue,r=s.VTTRegion;return e.shim=function(){s.VTTCue=t,s.VTTRegion=i},e.restore=function(){s.VTTCue=n,s.VTTRegion=r},s.VTTCue||e.shim(),Qy.exports}var iP=tP();const I2=Kc(iP);function on(){return on=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},on.apply(null,arguments)}var N2="https://example.com",dp=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=ye.location&&ye.location.href||"");var i=/^\/\//.test(e),n=!ye.location&&!/\/\//i.test(e);e=new ye.URL(e,ye.location||N2);var r=new URL(t,e);return n?r.href.slice(N2.length):i?r.href.slice(r.protocol.length):r.href},vb=(function(){function s(){this.listeners={}}var e=s.prototype;return e.on=function(i,n){this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push(n)},e.off=function(i,n){if(!this.listeners[i])return!1;var r=this.listeners[i].indexOf(n);return this.listeners[i]=this.listeners[i].slice(0),this.listeners[i].splice(r,1),r>-1},e.trigger=function(i){var n=this.listeners[i];if(n)if(arguments.length===2)for(var r=n.length,a=0;a<r;++a)n[a].call(this,arguments[1]);else for(var u=Array.prototype.slice.call(arguments,1),c=n.length,d=0;d<c;++d)n[d].apply(this,u)},e.dispose=function(){this.listeners={}},e.pipe=function(i){this.on("data",function(n){i.push(n)})},s})(),sP=function(e){return ye.atob?ye.atob(e):Buffer.from(e,"base64").toString("binary")};function vk(s){for(var e=sP(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}class nP extends vb{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
`);t>-1;t=this.buffer.indexOf(`
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const rP=" ",tv=function(s){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(s||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},aP=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},Jn=function(s){const e={};if(!s)return e;const t=s.split(aP());let i=t.length,n;for(;i--;)t[i]!==""&&(n=/([^=]*)=(.*)/.exec(t[i]).slice(1),n[0]=n[0].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^['"](.*)['"]$/g,"$1"),e[n[0]]=n[1]);return e},O2=s=>{const e=s.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class oP extends vb{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,i;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((r,a)=>{const u=a(e);return u===e?r:r.concat([u])},[e]).forEach(r=>{for(let a=0;a<this.customParsers.length;a++)if(this.customParsers[a].call(this,r))return;if(r.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:r.slice(1)});return}if(r=r.replace("\r",""),t=/^#EXTM3U/.exec(r),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(r),t){i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),this.trigger("data",i);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(r),t){i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(r),t){i=on(tv(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",i);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(r),t){i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(r),t){if(i={type:"tag",tagType:"map"},t[1]){const a=Jn(t[1]);a.URI&&(i.uri=a.URI),a.BYTERANGE&&(i.byterange=tv(a.BYTERANGE))}this.trigger("data",i);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"stream-inf"},t[1]&&(i.attributes=Jn(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=O2(i.attributes.RESOLUTION)),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(r),t){i={type:"tag",tagType:"media"},t[1]&&(i.attributes=Jn(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-ENDLIST/.exec(r),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(r),t){i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(r),t){i={type:"tag",tagType:"key"},t[1]&&(i.attributes=Jn(t[1]),i.attributes.IV&&(i.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),this.trigger("data",i);return}if(t=/^#EXT-X-START:(.*)$/.exec(r),t){i={type:"tag",tagType:"start"},t[1]&&(i.attributes=Jn(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"skip"},i.attributes=Jn(t[1]),i.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(i.attributes["SKIPPED-SEGMENTS"]=parseInt(i.attributes["SKIPPED-SEGMENTS"],10)),i.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(i.attributes["RECENTLY-REMOVED-DATERANGES"]=i.attributes["RECENTLY-REMOVED-DATERANGES"].split(rP)),this.trigger("data",i);return}if(t=/^#EXT-X-PART:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part"},i.attributes=Jn(t[1]),["DURATION"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["INDEPENDENT","GAP"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=tv(i.attributes.BYTERANGE)),this.trigger("data",i);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"server-control"},i.attributes=Jn(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part-inf"},i.attributes=Jn(t[1]),["PART-TARGET"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"preload-hint"},i.attributes=Jn(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(a){if(i.attributes.hasOwnProperty(a)){i.attributes[a]=parseInt(i.attributes[a],10);const u=a==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[u]=i.attributes[a],delete i.attributes[a]}}),this.trigger("data",i);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"rendition-report"},i.attributes=Jn(t[1]),["LAST-MSN","LAST-PART"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseInt(i.attributes[a],10))}),this.trigger("data",i);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=Jn(t[1]),["ID","CLASS"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=String(i.attributes[u]))}),["START-DATE","END-DATE"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=new Date(i.attributes[u]))}),["DURATION","PLANNED-DURATION"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=parseFloat(i.attributes[u]))}),["END-ON-NEXT"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=/YES/i.test(i.attributes[u]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=i.attributes[u].toString(16))});const a=/^X-([A-Z]+-)+[A-Z]+$/;for(const u in i.attributes){if(!a.test(u))continue;const c=/[0-9A-Fa-f]{6}/g.test(i.attributes[u]),d=/^\d+(\.\d+)?$/.test(i.attributes[u]);i.attributes[u]=c?i.attributes[u].toString(16):d?parseFloat(i.attributes[u]):String(i.attributes[u])}this.trigger("data",i);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(r),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(r),t){i={type:"tag",tagType:"content-steering"},i.attributes=Jn(t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"i-frame-playlist"},i.attributes=Jn(t[1]),i.attributes.URI&&(i.uri=i.attributes.URI),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=O2(i.attributes.RESOLUTION)),i.attributes["AVERAGE-BANDWIDTH"]&&(i.attributes["AVERAGE-BANDWIDTH"]=parseInt(i.attributes["AVERAGE-BANDWIDTH"],10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),this.trigger("data",i);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(r),t){i={type:"tag",tagType:"define"},i.attributes=Jn(t[1]),this.trigger("data",i);return}this.trigger("data",{type:"tag",data:r.slice(4)})})}addParser({expression:e,customType:t,dataParser:i,segment:n}){typeof i!="function"&&(i=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:i(r),customType:t,segment:n}),!0})}addTagMapper({expression:e,map:t}){const i=n=>e.test(n)?t(n):n;this.tagMappers.push(i)}}const lP=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),hl=function(s){const e={};return Object.keys(s).forEach(function(t){e[lP(t)]=s[t]}),e},iv=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const n="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",u=t&&t*3,c=i&&i*2;t&&!e.hasOwnProperty(r)&&(e[r]=u,this.trigger("info",{message:`${n} defaulting HOLD-BACK to targetDuration * 3 (${u}).`})),u&&e[r]<u&&(this.trigger("warn",{message:`${n} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${u})`}),e[r]=u),i&&!e.hasOwnProperty(a)&&(e[a]=i*3,this.trigger("info",{message:`${n} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),i&&e[a]<c&&(this.trigger("warn",{message:`${n} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${c}).`}),e[a]=c)};class uP extends vb{constructor(e={}){super(),this.lineStream=new nP,this.parseStream=new oP,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,i=[];let n={},r,a,u=!1;const c=function(){},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let g=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let y=0,v=0;const T={};this.on("end",()=>{n.uri||!n.parts&&!n.preloadHints||(!n.map&&r&&(n.map=r),!n.key&&a&&(n.key=a),!n.timeline&&typeof g=="number"&&(n.timeline=g),this.manifest.preloadSegment=n)}),this.parseStream.on("data",function(S){let w,L;if(t.manifest.definitions){for(const O in t.manifest.definitions)if(S.uri&&(S.uri=S.uri.replace(`{$${O}}`,t.manifest.definitions[O])),S.attributes)for(const I in S.attributes)typeof S.attributes[I]=="string"&&(S.attributes[I]=S.attributes[I].replace(`{$${O}}`,t.manifest.definitions[O]))}({tag(){({version(){S.version&&(this.manifest.version=S.version)},"allow-cache"(){this.manifest.allowCache=S.allowed,"allowed"in S||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const O={};"length"in S&&(n.byterange=O,O.length=S.length,"offset"in S||(S.offset=y)),"offset"in S&&(n.byterange=O,O.offset=S.offset),y=O.offset+O.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),S.title&&(n.title=S.title),S.duration>0&&(n.duration=S.duration),S.duration===0&&(n.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!S.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(S.attributes.METHOD==="NONE"){a=null;return}if(!S.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(S.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:S.attributes};return}if(S.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:S.attributes.URI};return}if(S.attributes.KEYFORMAT===f){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(S.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(S.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),S.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(S.attributes.KEYID&&S.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:S.attributes.KEYFORMAT,keyId:S.attributes.KEYID.substring(2)},pssh:vk(S.attributes.URI.split(",")[1])};return}S.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:S.attributes.METHOD||"AES-128",uri:S.attributes.URI},typeof S.attributes.IV<"u"&&(a.iv=S.attributes.IV)},"media-sequence"(){if(!isFinite(S.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+S.number});return}this.manifest.mediaSequence=S.number},"discontinuity-sequence"(){if(!isFinite(S.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+S.number});return}this.manifest.discontinuitySequence=S.number,g=S.number},"playlist-type"(){if(!/VOD|EVENT/.test(S.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+S.playlist});return}this.manifest.playlistType=S.playlistType},map(){r={},S.uri&&(r.uri=S.uri),S.byterange&&(r.byterange=S.byterange),a&&(r.key=a)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||d,!S.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}n.attributes||(n.attributes={}),on(n.attributes,S.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,!(S.attributes&&S.attributes.TYPE&&S.attributes["GROUP-ID"]&&S.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const O=this.manifest.mediaGroups[S.attributes.TYPE];O[S.attributes["GROUP-ID"]]=O[S.attributes["GROUP-ID"]]||{},w=O[S.attributes["GROUP-ID"]],L={default:/yes/i.test(S.attributes.DEFAULT)},L.default?L.autoselect=!0:L.autoselect=/yes/i.test(S.attributes.AUTOSELECT),S.attributes.LANGUAGE&&(L.language=S.attributes.LANGUAGE),S.attributes.URI&&(L.uri=S.attributes.URI),S.attributes["INSTREAM-ID"]&&(L.instreamId=S.attributes["INSTREAM-ID"]),S.attributes.CHARACTERISTICS&&(L.characteristics=S.attributes.CHARACTERISTICS),S.attributes.FORCED&&(L.forced=/yes/i.test(S.attributes.FORCED)),w[S.attributes.NAME]=L},discontinuity(){g+=1,n.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=S.dateTimeString,this.manifest.dateTimeObject=S.dateTimeObject),n.dateTimeString=S.dateTimeString,n.dateTimeObject=S.dateTimeObject;const{lastProgramDateTime:O}=this;this.lastProgramDateTime=new Date(S.dateTimeString).getTime(),O===null&&this.manifest.segments.reduceRight((I,j)=>(j.programDateTime=I-j.duration*1e3,j.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(S.duration)||S.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+S.duration});return}this.manifest.targetDuration=S.duration,iv.call(this,this.manifest)},start(){if(!S.attributes||isNaN(S.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:S.attributes["TIME-OFFSET"],precise:S.attributes.PRECISE}},"cue-out"(){n.cueOut=S.data},"cue-out-cont"(){n.cueOutCont=S.data},"cue-in"(){n.cueIn=S.data},skip(){this.manifest.skip=hl(S.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",S.attributes,["SKIPPED-SEGMENTS"])},part(){u=!0;const O=this.manifest.segments.length,I=hl(S.attributes);n.parts=n.parts||[],n.parts.push(I),I.byterange&&(I.byterange.hasOwnProperty("offset")||(I.byterange.offset=v),v=I.byterange.offset+I.byterange.length);const j=n.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${j} for segment #${O}`,S.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((P,G)=>{P.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${G} lacks required attribute(s): LAST-PART`})})},"server-control"(){const O=this.manifest.serverControl=hl(S.attributes);O.hasOwnProperty("canBlockReload")||(O.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),iv.call(this,this.manifest),O.canSkipDateranges&&!O.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const O=this.manifest.segments.length,I=hl(S.attributes),j=I.type&&I.type==="PART";n.preloadHints=n.preloadHints||[],n.preloadHints.push(I),I.byterange&&(I.byterange.hasOwnProperty("offset")||(I.byterange.offset=j?v:0,j&&(v=I.byterange.offset+I.byterange.length)));const P=n.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${P} for segment #${O}`,S.attributes,["TYPE","URI"]),!!I.type)for(let G=0;G<n.preloadHints.length-1;G++){const N=n.preloadHints[G];N.type&&N.type===I.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${P} for segment #${O} has the same TYPE ${I.type} as preload hint #${G}`})}},"rendition-report"(){const O=hl(S.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(O);const I=this.manifest.renditionReports.length-1,j=["LAST-MSN","URI"];u&&j.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${I}`,S.attributes,j)},"part-inf"(){this.manifest.partInf=hl(S.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",S.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),iv.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(hl(S.attributes));const O=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${O}`,S.attributes,["ID","START-DATE"]);const I=this.manifest.dateRanges[O];I.endDate&&I.startDate&&new Date(I.endDate)<new Date(I.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),I.duration&&I.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),I.plannedDuration&&I.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const j=!!I.endOnNext;if(j&&!I.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),j&&(I.duration||I.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),I.duration&&I.endDate){const G=I.startDate.getTime()+I.duration*1e3;this.manifest.dateRanges[O].endDate=new Date(G)}if(!T[I.id])T[I.id]=I;else{for(const G in T[I.id])if(I[G]&&JSON.stringify(T[I.id][G])!==JSON.stringify(I[G])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const P=this.manifest.dateRanges.findIndex(G=>G.id===I.id);this.manifest.dateRanges[P]=on(this.manifest.dateRanges[P],I),T[I.id]=on(T[I.id],I),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=hl(S.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",S.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const O=(I,j)=>{if(I in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${I}`});return}this.manifest.definitions[I]=j};if("QUERYPARAM"in S.attributes){if("NAME"in S.attributes||"IMPORT"in S.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const I=this.params.get(S.attributes.QUERYPARAM);if(!I){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${S.attributes.QUERYPARAM}`});return}O(S.attributes.QUERYPARAM,decodeURIComponent(I));return}if("NAME"in S.attributes){if("IMPORT"in S.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in S.attributes)||typeof S.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${S.attributes.NAME}`});return}O(S.attributes.NAME,S.attributes.VALUE);return}if("IMPORT"in S.attributes){if(!this.mainDefinitions[S.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${S.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}O(S.attributes.IMPORT,this.mainDefinitions[S.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:S.attributes,uri:S.uri,timeline:g}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",S.attributes,["BANDWIDTH","URI"])}}[S.tagType]||c).call(t)},uri(){n.uri=S.uri,i.push(n),this.manifest.targetDuration&&!("duration"in n)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),n.duration=this.manifest.targetDuration),a&&(n.key=a),n.timeline=g,r&&(n.map=r),v=0,this.lastProgramDateTime!==null&&(n.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=n.duration*1e3),n={}},comment(){},custom(){S.segment?(n.custom=n.custom||{},n.custom[S.customType]=S.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[S.customType]=S.data)}})[S.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,i){const n=[];i.forEach(function(r){t.hasOwnProperty(r)||n.push(r)}),n.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${n.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var pu={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},cP=["video","audio","text"],M2=["Video","Audio","Text"],xk=function(e){return e&&e.replace(/avc1\.(\d+)\.(\d+)/i,function(t,i,n){var r=("00"+Number(i).toString(16)).slice(-2),a=("00"+Number(n).toString(16)).slice(-2);return"avc1."+r+"00"+a})},Fa=function(e){e===void 0&&(e="");var t=e.split(","),i=[];return t.forEach(function(n){n=n.trim();var r;cP.forEach(function(a){var u=pu[a].exec(n.toLowerCase());if(!(!u||u.length<=1)){r=a;var c=n.substring(0,u[1].length),d=n.replace(c,"");i.push({type:c,details:d,mediaType:a})}}),r||i.push({type:n,details:"",mediaType:"unknown"})}),i},dP=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return Fa(r.playlists[0].attributes.CODECS)}return null},bk=function(e){return e===void 0&&(e=""),pu.audio.test(e.trim().toLowerCase())},hP=function(e){return e===void 0&&(e=""),pu.text.test(e.trim().toLowerCase())},Pc=function(e){if(!(!e||typeof e!="string")){var t=e.toLowerCase().split(",").map(function(r){return xk(r.trim())}),i="video";t.length===1&&bk(t[0])?i="audio":t.length===1&&hP(t[0])&&(i="application");var n="mp4";return t.every(function(r){return pu.mp4.test(r)})?n="mp4":t.every(function(r){return pu.webm.test(r)})?n="webm":t.every(function(r){return pu.ogg.test(r)})&&(n="ogg"),i+"/"+n+';codecs="'+e+'"'}},_h=function(e,t){return e===void 0&&(e=""),t===void 0&&(t=!1),ye.MediaSource&&ye.MediaSource.isTypeSupported&&ye.MediaSource.isTypeSupported(Pc(e))||t&&ye.ManagedMediaSource&&ye.ManagedMediaSource.isTypeSupported&&ye.ManagedMediaSource.isTypeSupported(Pc(e))||!1},sv=function(e){return e===void 0&&(e=""),e.toLowerCase().split(",").every(function(t){t=t.trim();for(var i=0;i<M2.length;i++){var n=M2[i];if(pu["muxer"+n].test(t))return!0}return!1})},P2="mp4a.40.2",fP="avc1.4d400d",mP=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,pP=/^application\/dash\+xml/i,Tk=function(e){return mP.test(e)?"hls":pP.test(e)?"dash":e==="application/vnd.videojs.vhs+json"?"vhs-json":null},gP=function(e){return e.toString(2).length},yP=function(e){return Math.ceil(gP(e)/8)},Sk=function(e){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},vP=function(e){return Sk(e)},si=function(e){return e instanceof Uint8Array?e:(!Array.isArray(e)&&!vP(e)&&!(e instanceof ArrayBuffer)&&(typeof e!="number"||typeof e=="number"&&e!==e?e=0:e=[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0))},Hn=ye.BigInt||Number,px=[Hn("0x1"),Hn("0x100"),Hn("0x10000"),Hn("0x1000000"),Hn("0x100000000"),Hn("0x10000000000"),Hn("0x1000000000000"),Hn("0x100000000000000"),Hn("0x10000000000000000")];(function(){var s=new Uint16Array([65484]),e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var xP=function(e,t){var i=t===void 0?{}:t,n=i.signed,r=n===void 0?!1:n,a=i.le,u=a===void 0?!1:a;e=si(e);var c=u?"reduce":"reduceRight",d=e[c]?e[c]:Array.prototype[c],f=d.call(e,function(y,v,T){var S=u?T:Math.abs(T+1-e.length);return y+Hn(v)*px[S]},Hn(0));if(r){var g=px[e.length]/Hn(2)-Hn(1);f=Hn(f),f>g&&(f-=g,f-=g,f-=Hn(2))}return Number(f)},bP=function(e,t){var i={},n=i.le,r=n===void 0?!1:n;(typeof e!="bigint"&&typeof e!="number"||typeof e=="number"&&e!==e)&&(e=0),e=Hn(e);for(var a=yP(e),u=new Uint8Array(new ArrayBuffer(a)),c=0;c<a;c++){var d=r?c:Math.abs(c+1-u.length);u[d]=Number(e/px[c]&Hn(255)),e<0&&(u[d]=Math.abs(~u[d]),u[d]-=c===0?1:2)}return u},_k=function(e,t){if(typeof e!="string"&&e&&typeof e.toString=="function"&&(e=e.toString()),typeof e!="string")return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),n=0;n<e.length;n++)i[n]=e.charCodeAt(n);return i},TP=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(t=t.filter(function(u){return u&&(u.byteLength||u.length)&&typeof u!="string"}),t.length<=1)return si(t[0]);var n=t.reduce(function(u,c,d){return u+(c.byteLength||c.length)},0),r=new Uint8Array(n),a=0;return t.forEach(function(u){u=si(u),r.set(u,a),a+=u.byteLength}),r},Fs=function(e,t,i){var n=i===void 0?{}:i,r=n.offset,a=r===void 0?0:r,u=n.mask,c=u===void 0?[]:u;e=si(e),t=si(t);var d=t.every?t.every:Array.prototype.every;return t.length&&e.length-a>=t.length&&d.call(t,function(f,g){var y=c[g]?c[g]&e[a+g]:e[a+g];return f===y})},SP=function(e,t,i){t.forEach(function(n){for(var r in e.mediaGroups[n])for(var a in e.mediaGroups[n][r]){var u=e.mediaGroups[n][r][a];i(u,n,r,a)}})},Jd={},yo={},eu={},B2;function hp(){if(B2)return eu;B2=1;function s(r,a,u){if(u===void 0&&(u=Array.prototype),r&&typeof u.find=="function")return u.find.call(r,a);for(var c=0;c<r.length;c++)if(Object.prototype.hasOwnProperty.call(r,c)){var d=r[c];if(a.call(void 0,d,c,r))return d}}function e(r,a){return a===void 0&&(a=Object),a&&typeof a.freeze=="function"?a.freeze(r):r}function t(r,a){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(r[u]=a[u]);return r}var i=e({HTML:"text/html",isHTML:function(r){return r===i.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),n=e({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(r){return r===n.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});return eu.assign=t,eu.find=s,eu.freeze=e,eu.MIME_TYPE=i,eu.NAMESPACE=n,eu}var F2;function Ek(){if(F2)return yo;F2=1;var s=hp(),e=s.find,t=s.NAMESPACE;function i(V){return V!==""}function n(V){return V?V.split(/[\t\n\f\r ]+/).filter(i):[]}function r(V,$){return V.hasOwnProperty($)||(V[$]=!0),V}function a(V){if(!V)return[];var $=n(V);return Object.keys($.reduce(r,{}))}function u(V){return function($){return V&&V.indexOf($)!==-1}}function c(V,$){for(var ie in V)Object.prototype.hasOwnProperty.call(V,ie)&&($[ie]=V[ie])}function d(V,$){var ie=V.prototype;if(!(ie instanceof $)){let Be=function(){};var Te=Be;Be.prototype=$.prototype,Be=new Be,c(ie,Be),V.prototype=ie=Be}ie.constructor!=V&&(typeof V!="function"&&console.error("unknown Class:"+V),ie.constructor=V)}var f={},g=f.ELEMENT_NODE=1,y=f.ATTRIBUTE_NODE=2,v=f.TEXT_NODE=3,T=f.CDATA_SECTION_NODE=4,S=f.ENTITY_REFERENCE_NODE=5,w=f.ENTITY_NODE=6,L=f.PROCESSING_INSTRUCTION_NODE=7,O=f.COMMENT_NODE=8,I=f.DOCUMENT_NODE=9,j=f.DOCUMENT_TYPE_NODE=10,P=f.DOCUMENT_FRAGMENT_NODE=11,G=f.NOTATION_NODE=12,N={},K={};N.INDEX_SIZE_ERR=(K[1]="Index size error",1),N.DOMSTRING_SIZE_ERR=(K[2]="DOMString size error",2);var k=N.HIERARCHY_REQUEST_ERR=(K[3]="Hierarchy request error",3);N.WRONG_DOCUMENT_ERR=(K[4]="Wrong document",4),N.INVALID_CHARACTER_ERR=(K[5]="Invalid character",5),N.NO_DATA_ALLOWED_ERR=(K[6]="No data allowed",6),N.NO_MODIFICATION_ALLOWED_ERR=(K[7]="No modification allowed",7);var R=N.NOT_FOUND_ERR=(K[8]="Not found",8);N.NOT_SUPPORTED_ERR=(K[9]="Not supported",9);var Y=N.INUSE_ATTRIBUTE_ERR=(K[10]="Attribute in use",10);N.INVALID_STATE_ERR=(K[11]="Invalid state",11),N.SYNTAX_ERR=(K[12]="Syntax error",12),N.INVALID_MODIFICATION_ERR=(K[13]="Invalid modification",13),N.NAMESPACE_ERR=(K[14]="Invalid namespace",14),N.INVALID_ACCESS_ERR=(K[15]="Invalid access",15);function z(V,$){if($ instanceof Error)var ie=$;else ie=this,Error.call(this,K[V]),this.message=K[V],Error.captureStackTrace&&Error.captureStackTrace(this,z);return ie.code=V,$&&(this.message=this.message+": "+$),ie}z.prototype=Error.prototype,c(N,z);function X(){}X.prototype={length:0,item:function(V){return V>=0&&V<this.length?this[V]:null},toString:function(V,$){for(var ie=[],Te=0;Te<this.length;Te++)yi(this[Te],ie,V,$);return ie.join("")},filter:function(V){return Array.prototype.filter.call(this,V)},indexOf:function(V){return Array.prototype.indexOf.call(this,V)}};function re(V,$){this._node=V,this._refresh=$,J(this)}function J(V){var $=V._node._inc||V._node.ownerDocument._inc;if(V._inc!==$){var ie=V._refresh(V._node);if(ki(V,"length",ie.length),!V.$$length||ie.length<V.$$length)for(var Te=ie.length;Te in V;Te++)Object.prototype.hasOwnProperty.call(V,Te)&&delete V[Te];c(ie,V),V._inc=$}}re.prototype.item=function(V){return J(this),this[V]||null},d(re,X);function W(){}function q(V,$){for(var ie=V.length;ie--;)if(V[ie]===$)return ie}function Z(V,$,ie,Te){if(Te?$[q($,Te)]=ie:$[$.length++]=ie,V){ie.ownerElement=V;var Be=V.ownerDocument;Be&&(Te&&Pe(Be,V,Te),Le(Be,V,ie))}}function te(V,$,ie){var Te=q($,ie);if(Te>=0){for(var Be=$.length-1;Te<Be;)$[Te]=$[++Te];if($.length=Be,V){var ht=V.ownerDocument;ht&&(Pe(ht,V,ie),ie.ownerElement=null)}}else throw new z(R,new Error(V.tagName+"@"+ie))}W.prototype={length:0,item:X.prototype.item,getNamedItem:function(V){for(var $=this.length;$--;){var ie=this[$];if(ie.nodeName==V)return ie}},setNamedItem:function(V){var $=V.ownerElement;if($&&$!=this._ownerElement)throw new z(Y);var ie=this.getNamedItem(V.nodeName);return Z(this._ownerElement,this,V,ie),ie},setNamedItemNS:function(V){var $=V.ownerElement,ie;if($&&$!=this._ownerElement)throw new z(Y);return ie=this.getNamedItemNS(V.namespaceURI,V.localName),Z(this._ownerElement,this,V,ie),ie},removeNamedItem:function(V){var $=this.getNamedItem(V);return te(this._ownerElement,this,$),$},removeNamedItemNS:function(V,$){var ie=this.getNamedItemNS(V,$);return te(this._ownerElement,this,ie),ie},getNamedItemNS:function(V,$){for(var ie=this.length;ie--;){var Te=this[ie];if(Te.localName==$&&Te.namespaceURI==V)return Te}return null}};function oe(){}oe.prototype={hasFeature:function(V,$){return!0},createDocument:function(V,$,ie){var Te=new Ie;if(Te.implementation=this,Te.childNodes=new X,Te.doctype=ie||null,ie&&Te.appendChild(ie),$){var Be=Te.createElementNS(V,$);Te.appendChild(Be)}return Te},createDocumentType:function(V,$,ie){var Te=new at;return Te.name=V,Te.nodeName=V,Te.publicId=$||"",Te.systemId=ie||"",Te}};function F(){}F.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(V,$){return Xe(this,V,$)},replaceChild:function(V,$){Xe(this,V,$,Qe),$&&this.removeChild($)},removeChild:function(V){return Se(this,V)},appendChild:function(V){return this.insertBefore(V,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(V){return Jt(this.ownerDocument||this,this,V)},normalize:function(){for(var V=this.firstChild;V;){var $=V.nextSibling;$&&$.nodeType==v&&V.nodeType==v?(this.removeChild($),V.appendData($.data)):(V.normalize(),V=$)}},isSupported:function(V,$){return this.ownerDocument.implementation.hasFeature(V,$)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(V){for(var $=this;$;){var ie=$._nsMap;if(ie){for(var Te in ie)if(Object.prototype.hasOwnProperty.call(ie,Te)&&ie[Te]===V)return Te}$=$.nodeType==y?$.ownerDocument:$.parentNode}return null},lookupNamespaceURI:function(V){for(var $=this;$;){var ie=$._nsMap;if(ie&&Object.prototype.hasOwnProperty.call(ie,V))return ie[V];$=$.nodeType==y?$.ownerDocument:$.parentNode}return null},isDefaultNamespace:function(V){var $=this.lookupPrefix(V);return $==null}};function le(V){return V=="<"&&"&lt;"||V==">"&&"&gt;"||V=="&"&&"&amp;"||V=='"'&&"&quot;"||"&#"+V.charCodeAt()+";"}c(f,F),c(f,F.prototype);function ge(V,$){if($(V))return!0;if(V=V.firstChild)do if(ge(V,$))return!0;while(V=V.nextSibling)}function Ie(){this.ownerDocument=this}function Le(V,$,ie){V&&V._inc++;var Te=ie.namespaceURI;Te===t.XMLNS&&($._nsMap[ie.prefix?ie.localName:""]=ie.value)}function Pe(V,$,ie,Te){V&&V._inc++;var Be=ie.namespaceURI;Be===t.XMLNS&&delete $._nsMap[ie.prefix?ie.localName:""]}function Je(V,$,ie){if(V&&V._inc){V._inc++;var Te=$.childNodes;if(ie)Te[Te.length++]=ie;else{for(var Be=$.firstChild,ht=0;Be;)Te[ht++]=Be,Be=Be.nextSibling;Te.length=ht,delete Te[Te.length]}}}function Se(V,$){var ie=$.previousSibling,Te=$.nextSibling;return ie?ie.nextSibling=Te:V.firstChild=Te,Te?Te.previousSibling=ie:V.lastChild=ie,$.parentNode=null,$.previousSibling=null,$.nextSibling=null,Je(V.ownerDocument,V),$}function Re(V){return V&&(V.nodeType===F.DOCUMENT_NODE||V.nodeType===F.DOCUMENT_FRAGMENT_NODE||V.nodeType===F.ELEMENT_NODE)}function Ve(V){return V&&(_e(V)||yt(V)||Ee(V)||V.nodeType===F.DOCUMENT_FRAGMENT_NODE||V.nodeType===F.COMMENT_NODE||V.nodeType===F.PROCESSING_INSTRUCTION_NODE)}function Ee(V){return V&&V.nodeType===F.DOCUMENT_TYPE_NODE}function _e(V){return V&&V.nodeType===F.ELEMENT_NODE}function yt(V){return V&&V.nodeType===F.TEXT_NODE}function ut(V,$){var ie=V.childNodes||[];if(e(ie,_e)||Ee($))return!1;var Te=e(ie,Ee);return!($&&Te&&ie.indexOf(Te)>ie.indexOf($))}function pt(V,$){var ie=V.childNodes||[];function Te(ht){return _e(ht)&&ht!==$}if(e(ie,Te))return!1;var Be=e(ie,Ee);return!($&&Be&&ie.indexOf(Be)>ie.indexOf($))}function Fe(V,$,ie){if(!Re(V))throw new z(k,"Unexpected parent node type "+V.nodeType);if(ie&&ie.parentNode!==V)throw new z(R,"child not in parent");if(!Ve($)||Ee($)&&V.nodeType!==F.DOCUMENT_NODE)throw new z(k,"Unexpected node type "+$.nodeType+" for parent node type "+V.nodeType)}function _t(V,$,ie){var Te=V.childNodes||[],Be=$.childNodes||[];if($.nodeType===F.DOCUMENT_FRAGMENT_NODE){var ht=Be.filter(_e);if(ht.length>1||e(Be,yt))throw new z(k,"More than one element or text in fragment");if(ht.length===1&&!ut(V,ie))throw new z(k,"Element in fragment can not be inserted before doctype")}if(_e($)&&!ut(V,ie))throw new z(k,"Only one element can be added and only after doctype");if(Ee($)){if(e(Te,Ee))throw new z(k,"Only one doctype is allowed");var It=e(Te,_e);if(ie&&Te.indexOf(It)<Te.indexOf(ie))throw new z(k,"Doctype can only be inserted before an element");if(!ie&&It)throw new z(k,"Doctype can not be appended since element is present")}}function Qe(V,$,ie){var Te=V.childNodes||[],Be=$.childNodes||[];if($.nodeType===F.DOCUMENT_FRAGMENT_NODE){var ht=Be.filter(_e);if(ht.length>1||e(Be,yt))throw new z(k,"More than one element or text in fragment");if(ht.length===1&&!pt(V,ie))throw new z(k,"Element in fragment can not be inserted before doctype")}if(_e($)&&!pt(V,ie))throw new z(k,"Only one element can be added and only after doctype");if(Ee($)){let pi=function(oi){return Ee(oi)&&oi!==ie};var Yt=pi;if(e(Te,pi))throw new z(k,"Only one doctype is allowed");var It=e(Te,_e);if(ie&&Te.indexOf(It)<Te.indexOf(ie))throw new z(k,"Doctype can only be inserted before an element")}}function Xe(V,$,ie,Te){Fe(V,$,ie),V.nodeType===F.DOCUMENT_NODE&&(Te||_t)(V,$,ie);var Be=$.parentNode;if(Be&&Be.removeChild($),$.nodeType===P){var ht=$.firstChild;if(ht==null)return $;var It=$.lastChild}else ht=It=$;var Yt=ie?ie.previousSibling:V.lastChild;ht.previousSibling=Yt,It.nextSibling=ie,Yt?Yt.nextSibling=ht:V.firstChild=ht,ie==null?V.lastChild=It:ie.previousSibling=It;do{ht.parentNode=V;var pi=V.ownerDocument||V;ze(ht,pi)}while(ht!==It&&(ht=ht.nextSibling));return Je(V.ownerDocument||V,V),$.nodeType==P&&($.firstChild=$.lastChild=null),$}function ze(V,$){if(V.ownerDocument!==$){if(V.ownerDocument=$,V.nodeType===g&&V.attributes)for(var ie=0;ie<V.attributes.length;ie++){var Te=V.attributes.item(ie);Te&&(Te.ownerDocument=$)}for(var Be=V.firstChild;Be;)ze(Be,$),Be=Be.nextSibling}}function Ze(V,$){$.parentNode&&$.parentNode.removeChild($),$.parentNode=V,$.previousSibling=V.lastChild,$.nextSibling=null,$.previousSibling?$.previousSibling.nextSibling=$:V.firstChild=$,V.lastChild=$,Je(V.ownerDocument,V,$);var ie=V.ownerDocument||V;return ze($,ie),$}Ie.prototype={nodeName:"#document",nodeType:I,doctype:null,documentElement:null,_inc:1,insertBefore:function(V,$){if(V.nodeType==P){for(var ie=V.firstChild;ie;){var Te=ie.nextSibling;this.insertBefore(ie,$),ie=Te}return V}return Xe(this,V,$),ze(V,this),this.documentElement===null&&V.nodeType===g&&(this.documentElement=V),V},removeChild:function(V){return this.documentElement==V&&(this.documentElement=null),Se(this,V)},replaceChild:function(V,$){Xe(this,V,$,Qe),ze(V,this),$&&this.removeChild($),_e(V)&&(this.documentElement=V)},importNode:function(V,$){return Pi(this,V,$)},getElementById:function(V){var $=null;return ge(this.documentElement,function(ie){if(ie.nodeType==g&&ie.getAttribute("id")==V)return $=ie,!0}),$},getElementsByClassName:function(V){var $=a(V);return new re(this,function(ie){var Te=[];return $.length>0&&ge(ie.documentElement,function(Be){if(Be!==ie&&Be.nodeType===g){var ht=Be.getAttribute("class");if(ht){var It=V===ht;if(!It){var Yt=a(ht);It=$.every(u(Yt))}It&&Te.push(Be)}}}),Te})},createElement:function(V){var $=new ct;$.ownerDocument=this,$.nodeName=V,$.tagName=V,$.localName=V,$.childNodes=new X;var ie=$.attributes=new W;return ie._ownerElement=$,$},createDocumentFragment:function(){var V=new Tt;return V.ownerDocument=this,V.childNodes=new X,V},createTextNode:function(V){var $=new ke;return $.ownerDocument=this,$.appendData(V),$},createComment:function(V){var $=new De;return $.ownerDocument=this,$.appendData(V),$},createCDATASection:function(V){var $=new Ue;return $.ownerDocument=this,$.appendData(V),$},createProcessingInstruction:function(V,$){var ie=new Ft;return ie.ownerDocument=this,ie.tagName=ie.nodeName=ie.target=V,ie.nodeValue=ie.data=$,ie},createAttribute:function(V){var $=new St;return $.ownerDocument=this,$.name=V,$.nodeName=V,$.localName=V,$.specified=!0,$},createEntityReference:function(V){var $=new kt;return $.ownerDocument=this,$.nodeName=V,$},createElementNS:function(V,$){var ie=new ct,Te=$.split(":"),Be=ie.attributes=new W;return ie.childNodes=new X,ie.ownerDocument=this,ie.nodeName=$,ie.tagName=$,ie.namespaceURI=V,Te.length==2?(ie.prefix=Te[0],ie.localName=Te[1]):ie.localName=$,Be._ownerElement=ie,ie},createAttributeNS:function(V,$){var ie=new St,Te=$.split(":");return ie.ownerDocument=this,ie.nodeName=$,ie.name=$,ie.namespaceURI=V,ie.specified=!0,Te.length==2?(ie.prefix=Te[0],ie.localName=Te[1]):ie.localName=$,ie}},d(Ie,F);function ct(){this._nsMap={}}ct.prototype={nodeType:g,hasAttribute:function(V){return this.getAttributeNode(V)!=null},getAttribute:function(V){var $=this.getAttributeNode(V);return $&&$.value||""},getAttributeNode:function(V){return this.attributes.getNamedItem(V)},setAttribute:function(V,$){var ie=this.ownerDocument.createAttribute(V);ie.value=ie.nodeValue=""+$,this.setAttributeNode(ie)},removeAttribute:function(V){var $=this.getAttributeNode(V);$&&this.removeAttributeNode($)},appendChild:function(V){return V.nodeType===P?this.insertBefore(V,null):Ze(this,V)},setAttributeNode:function(V){return this.attributes.setNamedItem(V)},setAttributeNodeNS:function(V){return this.attributes.setNamedItemNS(V)},removeAttributeNode:function(V){return this.attributes.removeNamedItem(V.nodeName)},removeAttributeNS:function(V,$){var ie=this.getAttributeNodeNS(V,$);ie&&this.removeAttributeNode(ie)},hasAttributeNS:function(V,$){return this.getAttributeNodeNS(V,$)!=null},getAttributeNS:function(V,$){var ie=this.getAttributeNodeNS(V,$);return ie&&ie.value||""},setAttributeNS:function(V,$,ie){var Te=this.ownerDocument.createAttributeNS(V,$);Te.value=Te.nodeValue=""+ie,this.setAttributeNode(Te)},getAttributeNodeNS:function(V,$){return this.attributes.getNamedItemNS(V,$)},getElementsByTagName:function(V){return new re(this,function($){var ie=[];return ge($,function(Te){Te!==$&&Te.nodeType==g&&(V==="*"||Te.tagName==V)&&ie.push(Te)}),ie})},getElementsByTagNameNS:function(V,$){return new re(this,function(ie){var Te=[];return ge(ie,function(Be){Be!==ie&&Be.nodeType===g&&(V==="*"||Be.namespaceURI===V)&&($==="*"||Be.localName==$)&&Te.push(Be)}),Te})}},Ie.prototype.getElementsByTagName=ct.prototype.getElementsByTagName,Ie.prototype.getElementsByTagNameNS=ct.prototype.getElementsByTagNameNS,d(ct,F);function St(){}St.prototype.nodeType=y,d(St,F);function se(){}se.prototype={data:"",substringData:function(V,$){return this.data.substring(V,V+$)},appendData:function(V){V=this.data+V,this.nodeValue=this.data=V,this.length=V.length},insertData:function(V,$){this.replaceData(V,0,$)},appendChild:function(V){throw new Error(K[k])},deleteData:function(V,$){this.replaceData(V,$,"")},replaceData:function(V,$,ie){var Te=this.data.substring(0,V),Be=this.data.substring(V+$);ie=Te+ie+Be,this.nodeValue=this.data=ie,this.length=ie.length}},d(se,F);function ke(){}ke.prototype={nodeName:"#text",nodeType:v,splitText:function(V){var $=this.data,ie=$.substring(V);$=$.substring(0,V),this.data=this.nodeValue=$,this.length=$.length;var Te=this.ownerDocument.createTextNode(ie);return this.parentNode&&this.parentNode.insertBefore(Te,this.nextSibling),Te}},d(ke,se);function De(){}De.prototype={nodeName:"#comment",nodeType:O},d(De,se);function Ue(){}Ue.prototype={nodeName:"#cdata-section",nodeType:T},d(Ue,se);function at(){}at.prototype.nodeType=j,d(at,F);function dt(){}dt.prototype.nodeType=G,d(dt,F);function wt(){}wt.prototype.nodeType=w,d(wt,F);function kt(){}kt.prototype.nodeType=S,d(kt,F);function Tt(){}Tt.prototype.nodeName="#document-fragment",Tt.prototype.nodeType=P,d(Tt,F);function Ft(){}Ft.prototype.nodeType=L,d(Ft,F);function Qt(){}Qt.prototype.serializeToString=function(V,$,ie){return Zt.call(V,$,ie)},F.prototype.toString=Zt;function Zt(V,$){var ie=[],Te=this.nodeType==9&&this.documentElement||this,Be=Te.prefix,ht=Te.namespaceURI;if(ht&&Be==null){var Be=Te.lookupPrefix(ht);if(Be==null)var It=[{namespace:ht,prefix:null}]}return yi(this,ie,V,$,It),ie.join("")}function Et(V,$,ie){var Te=V.prefix||"",Be=V.namespaceURI;if(!Be||Te==="xml"&&Be===t.XML||Be===t.XMLNS)return!1;for(var ht=ie.length;ht--;){var It=ie[ht];if(It.prefix===Te)return It.namespace!==Be}return!0}function Dt(V,$,ie){V.push(" ",$,'="',ie.replace(/[<>&"\t\n\r]/g,le),'"')}function yi(V,$,ie,Te,Be){if(Be||(Be=[]),Te)if(V=Te(V),V){if(typeof V=="string"){$.push(V);return}}else return;switch(V.nodeType){case g:var ht=V.attributes,It=ht.length,Mt=V.firstChild,Yt=V.tagName;ie=t.isHTML(V.namespaceURI)||ie;var pi=Yt;if(!ie&&!V.prefix&&V.namespaceURI){for(var oi,ci=0;ci<ht.length;ci++)if(ht.item(ci).name==="xmlns"){oi=ht.item(ci).value;break}if(!oi)for(var Bi=Be.length-1;Bi>=0;Bi--){var Gt=Be[Bi];if(Gt.prefix===""&&Gt.namespace===V.namespaceURI){oi=Gt.namespace;break}}if(oi!==V.namespaceURI)for(var Bi=Be.length-1;Bi>=0;Bi--){var Gt=Be[Bi];if(Gt.namespace===V.namespaceURI){Gt.prefix&&(pi=Gt.prefix+":"+Yt);break}}}$.push("<",pi);for(var xi=0;xi<It;xi++){var ai=ht.item(xi);ai.prefix=="xmlns"?Be.push({prefix:ai.localName,namespace:ai.value}):ai.nodeName=="xmlns"&&Be.push({prefix:"",namespace:ai.value})}for(var xi=0;xi<It;xi++){var ai=ht.item(xi);if(Et(ai,ie,Be)){var di=ai.prefix||"",qt=ai.namespaceURI;Dt($,di?"xmlns:"+di:"xmlns",qt),Be.push({prefix:di,namespace:qt})}yi(ai,$,ie,Te,Be)}if(Yt===pi&&Et(V,ie,Be)){var di=V.prefix||"",qt=V.namespaceURI;Dt($,di?"xmlns:"+di:"xmlns",qt),Be.push({prefix:di,namespace:qt})}if(Mt||ie&&!/^(?:meta|link|img|br|hr|input)$/i.test(Yt)){if($.push(">"),ie&&/^script$/i.test(Yt))for(;Mt;)Mt.data?$.push(Mt.data):yi(Mt,$,ie,Te,Be.slice()),Mt=Mt.nextSibling;else for(;Mt;)yi(Mt,$,ie,Te,Be.slice()),Mt=Mt.nextSibling;$.push("</",pi,">")}else $.push("/>");return;case I:case P:for(var Mt=V.firstChild;Mt;)yi(Mt,$,ie,Te,Be.slice()),Mt=Mt.nextSibling;return;case y:return Dt($,V.name,V.value);case v:return $.push(V.data.replace(/[<&>]/g,le));case T:return $.push("<![CDATA[",V.data,"]]>");case O:return $.push("<!--",V.data,"-->");case j:var vt=V.publicId,Ci=V.systemId;if($.push("<!DOCTYPE ",V.name),vt)$.push(" PUBLIC ",vt),Ci&&Ci!="."&&$.push(" ",Ci),$.push(">");else if(Ci&&Ci!=".")$.push(" SYSTEM ",Ci,">");else{var ss=V.internalSubset;ss&&$.push(" [",ss,"]"),$.push(">")}return;case L:return $.push("<?",V.target," ",V.data,"?>");case S:return $.push("&",V.nodeName,";");default:$.push("??",V.nodeName)}}function Pi(V,$,ie){var Te;switch($.nodeType){case g:Te=$.cloneNode(!1),Te.ownerDocument=V;case P:break;case y:ie=!0;break}if(Te||(Te=$.cloneNode(!1)),Te.ownerDocument=V,Te.parentNode=null,ie)for(var Be=$.firstChild;Be;)Te.appendChild(Pi(V,Be,ie)),Be=Be.nextSibling;return Te}function Jt(V,$,ie){var Te=new $.constructor;for(var Be in $)if(Object.prototype.hasOwnProperty.call($,Be)){var ht=$[Be];typeof ht!="object"&&ht!=Te[Be]&&(Te[Be]=ht)}switch($.childNodes&&(Te.childNodes=new X),Te.ownerDocument=V,Te.nodeType){case g:var It=$.attributes,Yt=Te.attributes=new W,pi=It.length;Yt._ownerElement=Te;for(var oi=0;oi<pi;oi++)Te.setAttributeNode(Jt(V,It.item(oi),!0));break;case y:ie=!0}if(ie)for(var ci=$.firstChild;ci;)Te.appendChild(Jt(V,ci,ie)),ci=ci.nextSibling;return Te}function ki(V,$,ie){V[$]=ie}try{if(Object.defineProperty){let V=function($){switch($.nodeType){case g:case P:var ie=[];for($=$.firstChild;$;)$.nodeType!==7&&$.nodeType!==8&&ie.push(V($)),$=$.nextSibling;return ie.join("");default:return $.nodeValue}};var gt=V;Object.defineProperty(re.prototype,"length",{get:function(){return J(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){return V(this)},set:function($){switch(this.nodeType){case g:case P:for(;this.firstChild;)this.removeChild(this.firstChild);($||String($))&&this.appendChild(this.ownerDocument.createTextNode($));break;default:this.data=$,this.value=$,this.nodeValue=$}}}),ki=function($,ie,Te){$["$$"+ie]=Te}}}catch{}return yo.DocumentType=at,yo.DOMException=z,yo.DOMImplementation=oe,yo.Element=ct,yo.Node=F,yo.NodeList=X,yo.XMLSerializer=Qt,yo}var eh={},nv={},U2;function _P(){return U2||(U2=1,(function(s){var e=hp().freeze;s.XML_ENTITIES=e({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),s.HTML_ENTITIES=e({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"",backsim:"∽",backsimeq:"⋍",Backslash:"",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"",Bernoullis:"",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"",caps:"∩︀",caret:"",caron:"ˇ",Cayleys:"",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"",dd:"",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:"",emsp13:"",emsp14:"",ENG:"Ŋ",eng:"ŋ",ensp:"",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"",escr:"",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"",ExponentialE:"",exponentiale:"",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"",frown:"⌢",Fscr:"",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:"",half:"½",hamilt:"",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"",hfr:"𝔥",HilbertSpace:"",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"",hyphen:"",Iacute:"Í",iacute:"í",ic:"",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"",Imacr:"Ī",imacr:"ī",image:"",ImaginaryI:"",imagline:"",imagpart:"",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"",InvisibleTimes:"",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"",Lscr:"",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"",lsquor:"",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:"",Mellintrf:"",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"",midast:"*",midcir:"⫰",middot:"·",minus:"",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:`
`,nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"",NonBreakingSpace:" ",Nopf:"",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:"",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"",operp:"⦹",oplus:"⊕",Or:"⩔",or:"",orarr:"↻",ord:"⩝",order:"",orderof:"",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"",pointint:"⨕",Popf:"",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"",primes:"",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:"",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"",rationals:"",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"",real:"",realine:"",realpart:"",reals:"",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"",Rscr:"",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"",rsquor:"",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"",setmn:"",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"",smashp:"⨳",smeparsl:"⧤",smid:"",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:" ",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"",ThickSpace:"",thinsp:"",ThinSpace:"",thkap:"≈",thksim:"",THORN:"Þ",thorn:"þ",Tilde:"",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"",vee:"",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:"",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",Zfr:"",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}),s.entityMap=s.HTML_ENTITIES})(nv)),nv}var Am={},j2;function EP(){if(j2)return Am;j2=1;var s=hp().NAMESPACE,e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),i=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$"),n=0,r=1,a=2,u=3,c=4,d=5,f=6,g=7;function y(k,R){this.message=k,this.locator=R,Error.captureStackTrace&&Error.captureStackTrace(this,y)}y.prototype=new Error,y.prototype.name=y.name;function v(){}v.prototype={parse:function(k,R,Y){var z=this.domBuilder;z.startDocument(),j(R,R={}),T(k,R,Y,z,this.errorHandler),z.endDocument()}};function T(k,R,Y,z,X){function re(Ze){if(Ze>65535){Ze-=65536;var ct=55296+(Ze>>10),St=56320+(Ze&1023);return String.fromCharCode(ct,St)}else return String.fromCharCode(Ze)}function J(Ze){var ct=Ze.slice(1,-1);return Object.hasOwnProperty.call(Y,ct)?Y[ct]:ct.charAt(0)==="#"?re(parseInt(ct.substr(1).replace("x","0x"))):(X.error("entity not found:"+Ze),Ze)}function W(Ze){if(Ze>Ie){var ct=k.substring(Ie,Ze).replace(/&#?\w+;/g,J);F&&q(Ie),z.characters(ct,0,Ze-Ie),Ie=Ze}}function q(Ze,ct){for(;Ze>=te&&(ct=oe.exec(k));)Z=ct.index,te=Z+ct[0].length,F.lineNumber++;F.columnNumber=Ze-Z+1}for(var Z=0,te=0,oe=/.*(?:\r\n?|\n)|.*$/g,F=z.locator,le=[{currentNSMap:R}],ge={},Ie=0;;){try{var Le=k.indexOf("<",Ie);if(Le<0){if(!k.substr(Ie).match(/^\s*$/)){var Pe=z.doc,Je=Pe.createTextNode(k.substr(Ie));Pe.appendChild(Je),z.currentElement=Je}return}switch(Le>Ie&&W(Le),k.charAt(Le+1)){case"/":var Fe=k.indexOf(">",Le+3),Se=k.substring(Le+2,Fe).replace(/[ \t\n\r]+$/g,""),Re=le.pop();Fe<0?(Se=k.substring(Le+2).replace(/[\s<].*/,""),X.error("end tag name: "+Se+" is not complete:"+Re.tagName),Fe=Le+1+Se.length):Se.match(/\s</)&&(Se=Se.replace(/[\s<].*/,""),X.error("end tag name: "+Se+" maybe not complete"),Fe=Le+1+Se.length);var Ve=Re.localNSMap,Ee=Re.tagName==Se,_e=Ee||Re.tagName&&Re.tagName.toLowerCase()==Se.toLowerCase();if(_e){if(z.endElement(Re.uri,Re.localName,Se),Ve)for(var yt in Ve)Object.prototype.hasOwnProperty.call(Ve,yt)&&z.endPrefixMapping(yt);Ee||X.fatalError("end tag name: "+Se+" is not match the current start tagName:"+Re.tagName)}else le.push(Re);Fe++;break;case"?":F&&q(Le),Fe=G(k,Le,z);break;case"!":F&&q(Le),Fe=P(k,Le,z,X);break;default:F&&q(Le);var ut=new N,pt=le[le.length-1].currentNSMap,Fe=w(k,Le,ut,pt,J,X),_t=ut.length;if(!ut.closed&&I(k,Fe,ut.tagName,ge)&&(ut.closed=!0,Y.nbsp||X.warning("unclosed xml attribute")),F&&_t){for(var Qe=S(F,{}),Xe=0;Xe<_t;Xe++){var ze=ut[Xe];q(ze.offset),ze.locator=S(F,{})}z.locator=Qe,L(ut,z,pt)&&le.push(ut),z.locator=F}else L(ut,z,pt)&&le.push(ut);s.isHTML(ut.uri)&&!ut.closed?Fe=O(k,Fe,ut.tagName,J,z):Fe++}}catch(Ze){if(Ze instanceof y)throw Ze;X.error("element parse error: "+Ze),Fe=-1}Fe>Ie?Ie=Fe:W(Math.max(Le,Ie)+1)}}function S(k,R){return R.lineNumber=k.lineNumber,R.columnNumber=k.columnNumber,R}function w(k,R,Y,z,X,re){function J(F,le,ge){Y.attributeNames.hasOwnProperty(F)&&re.fatalError("Attribute "+F+" redefined"),Y.addValue(F,le.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,X),ge)}for(var W,q,Z=++R,te=n;;){var oe=k.charAt(Z);switch(oe){case"=":if(te===r)W=k.slice(R,Z),te=u;else if(te===a)te=u;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(te===u||te===r)if(te===r&&(re.warning('attribute value must after "="'),W=k.slice(R,Z)),R=Z+1,Z=k.indexOf(oe,R),Z>0)q=k.slice(R,Z),J(W,q,R-1),te=d;else throw new Error("attribute value no end '"+oe+"' match");else if(te==c)q=k.slice(R,Z),J(W,q,R),re.warning('attribute "'+W+'" missed start quot('+oe+")!!"),R=Z+1,te=d;else throw new Error('attribute value must after "="');break;case"/":switch(te){case n:Y.setTagName(k.slice(R,Z));case d:case f:case g:te=g,Y.closed=!0;case c:case r:break;case a:Y.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return re.error("unexpected end of input"),te==n&&Y.setTagName(k.slice(R,Z)),Z;case">":switch(te){case n:Y.setTagName(k.slice(R,Z));case d:case f:case g:break;case c:case r:q=k.slice(R,Z),q.slice(-1)==="/"&&(Y.closed=!0,q=q.slice(0,-1));case a:te===a&&(q=W),te==c?(re.warning('attribute "'+q+'" missed quot(")!'),J(W,q,R)):((!s.isHTML(z[""])||!q.match(/^(?:disabled|checked|selected)$/i))&&re.warning('attribute "'+q+'" missed value!! "'+q+'" instead!!'),J(q,q,R));break;case u:throw new Error("attribute value missed!!")}return Z;case"€":oe=" ";default:if(oe<=" ")switch(te){case n:Y.setTagName(k.slice(R,Z)),te=f;break;case r:W=k.slice(R,Z),te=a;break;case c:var q=k.slice(R,Z);re.warning('attribute "'+q+'" missed quot(")!!'),J(W,q,R);case d:te=f;break}else switch(te){case a:Y.tagName,(!s.isHTML(z[""])||!W.match(/^(?:disabled|checked|selected)$/i))&&re.warning('attribute "'+W+'" missed value!! "'+W+'" instead2!!'),J(W,W,R),R=Z,te=r;break;case d:re.warning('attribute space is required"'+W+'"!!');case f:te=r,R=Z;break;case u:te=c,R=Z;break;case g:throw new Error("elements closed character '/' and '>' must be connected to")}}Z++}}function L(k,R,Y){for(var z=k.tagName,X=null,oe=k.length;oe--;){var re=k[oe],J=re.qName,W=re.value,F=J.indexOf(":");if(F>0)var q=re.prefix=J.slice(0,F),Z=J.slice(F+1),te=q==="xmlns"&&Z;else Z=J,q=null,te=J==="xmlns"&&"";re.localName=Z,te!==!1&&(X==null&&(X={},j(Y,Y={})),Y[te]=X[te]=W,re.uri=s.XMLNS,R.startPrefixMapping(te,W))}for(var oe=k.length;oe--;){re=k[oe];var q=re.prefix;q&&(q==="xml"&&(re.uri=s.XML),q!=="xmlns"&&(re.uri=Y[q||""]))}var F=z.indexOf(":");F>0?(q=k.prefix=z.slice(0,F),Z=k.localName=z.slice(F+1)):(q=null,Z=k.localName=z);var le=k.uri=Y[q||""];if(R.startElement(le,Z,z,k),k.closed){if(R.endElement(le,Z,z),X)for(q in X)Object.prototype.hasOwnProperty.call(X,q)&&R.endPrefixMapping(q)}else return k.currentNSMap=Y,k.localNSMap=X,!0}function O(k,R,Y,z,X){if(/^(?:script|textarea)$/i.test(Y)){var re=k.indexOf("</"+Y+">",R),J=k.substring(R+1,re);if(/[&<]/.test(J))return/^script$/i.test(Y)?(X.characters(J,0,J.length),re):(J=J.replace(/&#?\w+;/g,z),X.characters(J,0,J.length),re)}return R+1}function I(k,R,Y,z){var X=z[Y];return X==null&&(X=k.lastIndexOf("</"+Y+">"),X<R&&(X=k.lastIndexOf("</"+Y)),z[Y]=X),X<R}function j(k,R){for(var Y in k)Object.prototype.hasOwnProperty.call(k,Y)&&(R[Y]=k[Y])}function P(k,R,Y,z){var X=k.charAt(R+2);switch(X){case"-":if(k.charAt(R+3)==="-"){var re=k.indexOf("-->",R+4);return re>R?(Y.comment(k,R+4,re-R-4),re+3):(z.error("Unclosed comment"),-1)}else return-1;default:if(k.substr(R+3,6)=="CDATA["){var re=k.indexOf("]]>",R+9);return Y.startCDATA(),Y.characters(k,R+9,re-R-9),Y.endCDATA(),re+3}var J=K(k,R),W=J.length;if(W>1&&/!doctype/i.test(J[0][0])){var q=J[1][0],Z=!1,te=!1;W>3&&(/^public$/i.test(J[2][0])?(Z=J[3][0],te=W>4&&J[4][0]):/^system$/i.test(J[2][0])&&(te=J[3][0]));var oe=J[W-1];return Y.startDTD(q,Z,te),Y.endDTD(),oe.index+oe[0].length}}return-1}function G(k,R,Y){var z=k.indexOf("?>",R);if(z){var X=k.substring(R,z).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return X?(X[0].length,Y.processingInstruction(X[1],X[2]),z+2):-1}return-1}function N(){this.attributeNames={}}N.prototype={setTagName:function(k){if(!i.test(k))throw new Error("invalid tagName:"+k);this.tagName=k},addValue:function(k,R,Y){if(!i.test(k))throw new Error("invalid attribute:"+k);this.attributeNames[k]=this.length,this[this.length++]={qName:k,value:R,offset:Y}},length:0,getLocalName:function(k){return this[k].localName},getLocator:function(k){return this[k].locator},getQName:function(k){return this[k].qName},getURI:function(k){return this[k].uri},getValue:function(k){return this[k].value}};function K(k,R){var Y,z=[],X=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(X.lastIndex=R,X.exec(k);Y=X.exec(k);)if(z.push(Y),Y[1])return z}return Am.XMLReader=v,Am.ParseError=y,Am}var $2;function wP(){if($2)return eh;$2=1;var s=hp(),e=Ek(),t=_P(),i=EP(),n=e.DOMImplementation,r=s.NAMESPACE,a=i.ParseError,u=i.XMLReader;function c(w){return w.replace(/\r[\n\u0085]/g,`
`).replace(/[\r\u0085\u2028]/g,`
`)}function d(w){this.options=w||{locator:{}}}d.prototype.parseFromString=function(w,L){var O=this.options,I=new u,j=O.domBuilder||new g,P=O.errorHandler,G=O.locator,N=O.xmlns||{},K=/\/x?html?$/.test(L),k=K?t.HTML_ENTITIES:t.XML_ENTITIES;G&&j.setDocumentLocator(G),I.errorHandler=f(P,j,G),I.domBuilder=O.domBuilder||j,K&&(N[""]=r.HTML),N.xml=N.xml||r.XML;var R=O.normalizeLineEndings||c;return w&&typeof w=="string"?I.parse(R(w),N,k):I.errorHandler.error("invalid doc source"),j.doc};function f(w,L,O){if(!w){if(L instanceof g)return L;w=L}var I={},j=w instanceof Function;O=O||{};function P(G){var N=w[G];!N&&j&&(N=w.length==2?function(K){w(G,K)}:w),I[G]=N&&function(K){N("[xmldom "+G+"] "+K+v(O))}||function(){}}return P("warning"),P("error"),P("fatalError"),I}function g(){this.cdata=!1}function y(w,L){L.lineNumber=w.lineNumber,L.columnNumber=w.columnNumber}g.prototype={startDocument:function(){this.doc=new n().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(w,L,O,I){var j=this.doc,P=j.createElementNS(w,O||L),G=I.length;S(this,P),this.currentElement=P,this.locator&&y(this.locator,P);for(var N=0;N<G;N++){var w=I.getURI(N),K=I.getValue(N),O=I.getQName(N),k=j.createAttributeNS(w,O);this.locator&&y(I.getLocator(N),k),k.value=k.nodeValue=K,P.setAttributeNode(k)}},endElement:function(w,L,O){var I=this.currentElement;I.tagName,this.currentElement=I.parentNode},startPrefixMapping:function(w,L){},endPrefixMapping:function(w){},processingInstruction:function(w,L){var O=this.doc.createProcessingInstruction(w,L);this.locator&&y(this.locator,O),S(this,O)},ignorableWhitespace:function(w,L,O){},characters:function(w,L,O){if(w=T.apply(this,arguments),w){if(this.cdata)var I=this.doc.createCDATASection(w);else var I=this.doc.createTextNode(w);this.currentElement?this.currentElement.appendChild(I):/^\s*$/.test(w)&&this.doc.appendChild(I),this.locator&&y(this.locator,I)}},skippedEntity:function(w){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(w){(this.locator=w)&&(w.lineNumber=0)},comment:function(w,L,O){w=T.apply(this,arguments);var I=this.doc.createComment(w);this.locator&&y(this.locator,I),S(this,I)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(w,L,O){var I=this.doc.implementation;if(I&&I.createDocumentType){var j=I.createDocumentType(w,L,O);this.locator&&y(this.locator,j),S(this,j),this.doc.doctype=j}},warning:function(w){console.warn("[xmldom warning] "+w,v(this.locator))},error:function(w){console.error("[xmldom error] "+w,v(this.locator))},fatalError:function(w){throw new a(w,this.locator)}};function v(w){if(w)return`
@`+(w.systemId||"")+"#[line:"+w.lineNumber+",col:"+w.columnNumber+"]"}function T(w,L,O){return typeof w=="string"?w.substr(L,O):w.length>=L+O||L?new java.lang.String(w,L,O)+"":w}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(w){g.prototype[w]=function(){return null}});function S(w,L){w.currentElement?w.currentElement.appendChild(L):w.doc.appendChild(L)}return eh.__DOMHandler=g,eh.normalizeLineEndings=c,eh.DOMParser=d,eh}var H2;function AP(){if(H2)return Jd;H2=1;var s=Ek();return Jd.DOMImplementation=s.DOMImplementation,Jd.XMLSerializer=s.XMLSerializer,Jd.DOMParser=wP().DOMParser,Jd}var kP=AP();const z2=s=>!!s&&typeof s=="object",Ln=(...s)=>s.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(i=>{Array.isArray(e[i])&&Array.isArray(t[i])?e[i]=e[i].concat(t[i]):z2(e[i])&&z2(t[i])?e[i]=Ln(e[i],t[i]):e[i]=t[i]}),e),{}),wk=s=>Object.keys(s).map(e=>s[e]),CP=(s,e)=>{const t=[];for(let i=s;i<e;i++)t.push(i);return t},Bc=s=>s.reduce((e,t)=>e.concat(t),[]),Ak=s=>{if(!s.length)return[];const e=[];for(let t=0;t<s.length;t++)e.push(s[t]);return e},DP=(s,e)=>s.reduce((t,i,n)=>(i[e]&&t.push(n),t),[]),LP=(s,e)=>wk(s.reduce((t,i)=>(i.forEach(n=>{t[e(n)]=n}),t),{}));var Fc={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const Oh=({baseUrl:s="",source:e="",range:t="",indexRange:i=""})=>{const n={uri:e,resolvedUri:dp(s||"",e)};if(t||i){const a=(t||i).split("-");let u=ye.BigInt?ye.BigInt(a[0]):parseInt(a[0],10),c=ye.BigInt?ye.BigInt(a[1]):parseInt(a[1],10);u<Number.MAX_SAFE_INTEGER&&typeof u=="bigint"&&(u=Number(u)),c<Number.MAX_SAFE_INTEGER&&typeof c=="bigint"&&(c=Number(c));let d;typeof c=="bigint"||typeof u=="bigint"?d=ye.BigInt(c)-ye.BigInt(u)+ye.BigInt(1):d=c-u+1,typeof d=="bigint"&&d<Number.MAX_SAFE_INTEGER&&(d=Number(d)),n.byterange={length:d,offset:u}}return n},RP=s=>{let e;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=ye.BigInt(s.offset)+ye.BigInt(s.length)-ye.BigInt(1):e=s.offset+s.length-1,`${s.offset}-${e}`},V2=s=>(s&&typeof s!="number"&&(s=parseInt(s,10)),isNaN(s)?null:s),IP={static(s){const{duration:e,timescale:t=1,sourceDuration:i,periodDuration:n}=s,r=V2(s.endNumber),a=e/t;return typeof r=="number"?{start:0,end:r}:typeof n=="number"?{start:0,end:n/a}:{start:0,end:i/a}},dynamic(s){const{NOW:e,clientOffset:t,availabilityStartTime:i,timescale:n=1,duration:r,periodStart:a=0,minimumUpdatePeriod:u=0,timeShiftBufferDepth:c=1/0}=s,d=V2(s.endNumber),f=(e+t)/1e3,g=i+a,v=f+u-g,T=Math.ceil(v*n/r),S=Math.floor((f-g-c)*n/r),w=Math.floor((f-g)*n/r);return{start:Math.max(0,S),end:typeof d=="number"?d:Math.min(T,w)}}},NP=s=>e=>{const{duration:t,timescale:i=1,periodStart:n,startNumber:r=1}=s;return{number:r+e,duration:t/i,timeline:n,time:e*t}},xb=s=>{const{type:e,duration:t,timescale:i=1,periodDuration:n,sourceDuration:r}=s,{start:a,end:u}=IP[e](s),c=CP(a,u).map(NP(s));if(e==="static"){const d=c.length-1,f=typeof n=="number"?n:r;c[d].duration=f-t/i*d}return c},kk=s=>{const{baseUrl:e,initialization:t={},sourceDuration:i,indexRange:n="",periodStart:r,presentationTime:a,number:u=0,duration:c}=s;if(!e)throw new Error(Fc.NO_BASE_URL);const d=Oh({baseUrl:e,source:t.sourceURL,range:t.range}),f=Oh({baseUrl:e,source:e,indexRange:n});if(f.map=d,c){const g=xb(s);g.length&&(f.duration=g[0].duration,f.timeline=g[0].timeline)}else i&&(f.duration=i,f.timeline=r);return f.presentationTime=a||r,f.number=u,[f]},bb=(s,e,t)=>{const i=s.sidx.map?s.sidx.map:null,n=s.sidx.duration,r=s.timeline||0,a=s.sidx.byterange,u=a.offset+a.length,c=e.timescale,d=e.references.filter(w=>w.referenceType!==1),f=[],g=s.endList?"static":"dynamic",y=s.sidx.timeline;let v=y,T=s.mediaSequence||0,S;typeof e.firstOffset=="bigint"?S=ye.BigInt(u)+e.firstOffset:S=u+e.firstOffset;for(let w=0;w<d.length;w++){const L=e.references[w],O=L.referencedSize,I=L.subsegmentDuration;let j;typeof S=="bigint"?j=S+ye.BigInt(O)-ye.BigInt(1):j=S+O-1;const P=`${S}-${j}`,N=kk({baseUrl:t,timescale:c,timeline:r,periodStart:y,presentationTime:v,number:T,duration:I,sourceDuration:n,indexRange:P,type:g})[0];i&&(N.map=i),f.push(N),typeof S=="bigint"?S+=ye.BigInt(O):S+=O,v+=I/c,T++}return s.segments=f,s},OP=["AUDIO","SUBTITLES"],MP=1/60,Ck=s=>LP(s,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),PP=(s,e)=>{for(let t=0;t<s.length;t++)if(s[t].attributes.NAME===e)return s[t];return null},G2=s=>{let e=[];return SP(s,OP,(t,i,n,r)=>{e=e.concat(t.playlists||[])}),e},q2=({playlist:s,mediaSequence:e})=>{s.mediaSequence=e,s.segments.forEach((t,i)=>{t.number=s.mediaSequence+i})},BP=({oldPlaylists:s,newPlaylists:e,timelineStarts:t})=>{e.forEach(i=>{i.discontinuitySequence=t.findIndex(function({timeline:c}){return c===i.timeline});const n=PP(s,i.attributes.NAME);if(!n||i.sidx)return;const r=i.segments[0],a=n.segments.findIndex(function(c){return Math.abs(c.presentationTime-r.presentationTime)<MP});if(a===-1){q2({playlist:i,mediaSequence:n.mediaSequence+n.segments.length}),i.segments[0].discontinuity=!0,i.discontinuityStarts.unshift(0),(!n.segments.length&&i.timeline>n.timeline||n.segments.length&&i.timeline>n.segments[n.segments.length-1].timeline)&&i.discontinuitySequence--;return}n.segments[a].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),q2({playlist:i,mediaSequence:n.segments[a].number})})},FP=({oldManifest:s,newManifest:e})=>{const t=s.playlists.concat(G2(s)),i=e.playlists.concat(G2(e));return e.timelineStarts=Ck([s.timelineStarts,e.timelineStarts]),BP({oldPlaylists:t,newPlaylists:i,timelineStarts:e.timelineStarts}),e},fp=s=>s&&s.uri+"-"+RP(s.byterange),rv=s=>{const e=s.reduce(function(i,n){return i[n.attributes.baseUrl]||(i[n.attributes.baseUrl]=[]),i[n.attributes.baseUrl].push(n),i},{});let t=[];return Object.values(e).forEach(i=>{const n=wk(i.reduce((r,a)=>{const u=a.attributes.id+(a.attributes.lang||"");return r[u]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),r[u].segments.push(...a.segments)),a.attributes.contentProtection&&(r[u].attributes.contentProtection=a.attributes.contentProtection)):(r[u]=a,r[u].attributes.timelineStarts=[]),r[u].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),r},{}));t=t.concat(n)}),t.map(i=>(i.discontinuityStarts=DP(i.segments||[],"discontinuity"),i))},Tb=(s,e)=>{const t=fp(s.sidx),i=t&&e[t]&&e[t].sidx;return i&&bb(s,i,s.sidx.resolvedUri),s},UP=(s,e={})=>{if(!Object.keys(e).length)return s;for(const t in s)s[t]=Tb(s[t],e);return s},jP=({attributes:s,segments:e,sidx:t,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:r},a)=>{const u={attributes:{NAME:s.id,BANDWIDTH:s.bandwidth,CODECS:s.codecs,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuitySequence:n,discontinuityStarts:r,timelineStarts:s.timelineStarts,mediaSequence:i,segments:e};return s.contentProtection&&(u.contentProtection=s.contentProtection),s.serviceLocation&&(u.attributes.serviceLocation=s.serviceLocation),t&&(u.sidx=t),a&&(u.attributes.AUDIO="audio",u.attributes.SUBTITLES="subs"),u},$P=({attributes:s,segments:e,mediaSequence:t,discontinuityStarts:i,discontinuitySequence:n})=>{typeof e>"u"&&(e=[{uri:s.baseUrl,timeline:s.periodStart,resolvedUri:s.baseUrl||"",duration:s.sourceDuration,number:0}],s.duration=s.sourceDuration);const r={NAME:s.id,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1};s.codecs&&(r.CODECS=s.codecs);const a={attributes:r,uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,timelineStarts:s.timelineStarts,discontinuityStarts:i,discontinuitySequence:n,mediaSequence:t,segments:e};return s.serviceLocation&&(a.attributes.serviceLocation=s.serviceLocation),a},HP=(s,e={},t=!1)=>{let i;const n=s.reduce((r,a)=>{const u=a.attributes.role&&a.attributes.role.value||"",c=a.attributes.lang||"";let d=a.attributes.label||"main";if(c&&!a.attributes.label){const g=u?` (${u})`:"";d=`${a.attributes.lang}${g}`}r[d]||(r[d]={language:c,autoselect:!0,default:u==="main",playlists:[],uri:""});const f=Tb(jP(a,t),e);return r[d].playlists.push(f),typeof i>"u"&&u==="main"&&(i=a,i.default=!0),r},{});if(!i){const r=Object.keys(n)[0];n[r].default=!0}return n},zP=(s,e={})=>s.reduce((t,i)=>{const n=i.attributes.label||i.attributes.lang||"text",r=i.attributes.lang||"und";return t[n]||(t[n]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[n].playlists.push(Tb($P(i),e)),t},{}),VP=s=>s.reduce((e,t)=>(t&&t.forEach(i=>{const{channel:n,language:r}=i;e[r]={autoselect:!1,default:!1,instreamId:n,language:r},i.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=i.aspectRatio),i.hasOwnProperty("easyReader")&&(e[r].easyReader=i.easyReader),i.hasOwnProperty("3D")&&(e[r]["3D"]=i["3D"])}),e),{}),GP=({attributes:s,segments:e,sidx:t,discontinuityStarts:i})=>{const n={attributes:{NAME:s.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:s.width,height:s.height},CODECS:s.codecs,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuityStarts:i,timelineStarts:s.timelineStarts,segments:e};return s.frameRate&&(n.attributes["FRAME-RATE"]=s.frameRate),s.contentProtection&&(n.contentProtection=s.contentProtection),s.serviceLocation&&(n.attributes.serviceLocation=s.serviceLocation),t&&(n.sidx=t),n},qP=({attributes:s})=>s.mimeType==="video/mp4"||s.mimeType==="video/webm"||s.contentType==="video",KP=({attributes:s})=>s.mimeType==="audio/mp4"||s.mimeType==="audio/webm"||s.contentType==="audio",WP=({attributes:s})=>s.mimeType==="text/vtt"||s.contentType==="text",YP=(s,e)=>{s.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:i}){return i===t.timeline}),t.segments&&t.segments.forEach((i,n)=>{i.number=n})})},K2=s=>s?Object.keys(s).reduce((e,t)=>{const i=s[t];return e.concat(i.playlists)},[]):[],XP=({dashPlaylists:s,locations:e,contentSteering:t,sidxMapping:i={},previousManifest:n,eventStream:r})=>{if(!s.length)return{};const{sourceDuration:a,type:u,suggestedPresentationDelay:c,minimumUpdatePeriod:d}=s[0].attributes,f=rv(s.filter(qP)).map(GP),g=rv(s.filter(KP)),y=rv(s.filter(WP)),v=s.map(j=>j.attributes.captionServices).filter(Boolean),T={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:UP(f,i)};d>=0&&(T.minimumUpdatePeriod=d*1e3),e&&(T.locations=e),t&&(T.contentSteering=t),u==="dynamic"&&(T.suggestedPresentationDelay=c),r&&r.length>0&&(T.eventStream=r);const S=T.playlists.length===0,w=g.length?HP(g,i,S):null,L=y.length?zP(y,i):null,O=f.concat(K2(w),K2(L)),I=O.map(({timelineStarts:j})=>j);return T.timelineStarts=Ck(I),YP(O,T.timelineStarts),w&&(T.mediaGroups.AUDIO.audio=w),L&&(T.mediaGroups.SUBTITLES.subs=L),v.length&&(T.mediaGroups["CLOSED-CAPTIONS"].cc=VP(v)),n?FP({oldManifest:n,newManifest:T}):T},QP=(s,e,t)=>{const{NOW:i,clientOffset:n,availabilityStartTime:r,timescale:a=1,periodStart:u=0,minimumUpdatePeriod:c=0}=s,d=(i+n)/1e3,f=r+u,y=d+c-f;return Math.ceil((y*a-e)/t)},Dk=(s,e)=>{const{type:t,minimumUpdatePeriod:i=0,media:n="",sourceDuration:r,timescale:a=1,startNumber:u=1,periodStart:c}=s,d=[];let f=-1;for(let g=0;g<e.length;g++){const y=e[g],v=y.d,T=y.r||0,S=y.t||0;f<0&&(f=S),S&&S>f&&(f=S);let w;if(T<0){const I=g+1;I===e.length?t==="dynamic"&&i>0&&n.indexOf("$Number$")>0?w=QP(s,f,v):w=(r*a-f)/v:w=(e[I].t-f)/v}else w=T+1;const L=u+d.length+w;let O=u+d.length;for(;O<L;)d.push({number:O,duration:v/a,time:f,timeline:c}),f+=v,O++}return d},ZP=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,JP=s=>(e,t,i,n)=>{if(e==="$$")return"$";if(typeof s[t]>"u")return e;const r=""+s[t];return t==="RepresentationID"||(i?n=parseInt(n,10):n=1,r.length>=n)?r:`${new Array(n-r.length+1).join("0")}${r}`},W2=(s,e)=>s.replace(ZP,JP(e)),e4=(s,e)=>!s.duration&&!e?[{number:s.startNumber||1,duration:s.sourceDuration,time:0,timeline:s.periodStart}]:s.duration?xb(s):Dk(s,e),t4=(s,e)=>{const t={RepresentationID:s.id,Bandwidth:s.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=s,n=Oh({baseUrl:s.baseUrl,source:W2(i.sourceURL,t),range:i.range});return e4(s,e).map(a=>{t.Number=a.number,t.Time=a.time;const u=W2(s.media||"",t),c=s.timescale||1,d=s.presentationTimeOffset||0,f=s.periodStart+(a.time-d)/c;return{uri:u,timeline:a.timeline,duration:a.duration,resolvedUri:dp(s.baseUrl||"",u),map:n,number:a.number,presentationTime:f}})},i4=(s,e)=>{const{baseUrl:t,initialization:i={}}=s,n=Oh({baseUrl:t,source:i.sourceURL,range:i.range}),r=Oh({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=n,r},s4=(s,e)=>{const{duration:t,segmentUrls:i=[],periodStart:n}=s;if(!t&&!e||t&&e)throw new Error(Fc.SEGMENT_TIME_UNSPECIFIED);const r=i.map(c=>i4(s,c));let a;return t&&(a=xb(s)),e&&(a=Dk(s,e)),a.map((c,d)=>{if(r[d]){const f=r[d],g=s.timescale||1,y=s.presentationTimeOffset||0;return f.timeline=c.timeline,f.duration=c.duration,f.number=c.number,f.presentationTime=n+(c.time-y)/g,f}}).filter(c=>c)},n4=({attributes:s,segmentInfo:e})=>{let t,i;e.template?(i=t4,t=Ln(s,e.template)):e.base?(i=kk,t=Ln(s,e.base)):e.list&&(i=s4,t=Ln(s,e.list));const n={attributes:s};if(!i)return n;const r=i(t,e.segmentTimeline);if(t.duration){const{duration:a,timescale:u=1}=t;t.duration=a/u}else r.length?t.duration=r.reduce((a,u)=>Math.max(a,Math.ceil(u.duration)),0):t.duration=0;return n.attributes=t,n.segments=r,e.base&&t.indexRange&&(n.sidx=r[0],n.segments=[]),n},r4=s=>s.map(n4),Us=(s,e)=>Ak(s.childNodes).filter(({tagName:t})=>t===e),Xh=s=>s.textContent.trim(),a4=s=>parseFloat(s.split("/").reduce((e,t)=>e/t)),ic=s=>{const u=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(s);if(!u)return 0;const[c,d,f,g,y,v]=u.slice(1);return parseFloat(c||0)*31536e3+parseFloat(d||0)*2592e3+parseFloat(f||0)*86400+parseFloat(g||0)*3600+parseFloat(y||0)*60+parseFloat(v||0)},o4=s=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(s)&&(s+="Z"),Date.parse(s)),Y2={mediaPresentationDuration(s){return ic(s)},availabilityStartTime(s){return o4(s)/1e3},minimumUpdatePeriod(s){return ic(s)},suggestedPresentationDelay(s){return ic(s)},type(s){return s},timeShiftBufferDepth(s){return ic(s)},start(s){return ic(s)},width(s){return parseInt(s,10)},height(s){return parseInt(s,10)},bandwidth(s){return parseInt(s,10)},frameRate(s){return a4(s)},startNumber(s){return parseInt(s,10)},timescale(s){return parseInt(s,10)},presentationTimeOffset(s){return parseInt(s,10)},duration(s){const e=parseInt(s,10);return isNaN(e)?ic(s):e},d(s){return parseInt(s,10)},t(s){return parseInt(s,10)},r(s){return parseInt(s,10)},presentationTime(s){return parseInt(s,10)},DEFAULT(s){return s}},mn=s=>s&&s.attributes?Ak(s.attributes).reduce((e,t)=>{const i=Y2[t.name]||Y2.DEFAULT;return e[t.name]=i(t.value),e},{}):{},l4={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},mp=(s,e)=>e.length?Bc(s.map(function(t){return e.map(function(i){const n=Xh(i),r=dp(t.baseUrl,n),a=Ln(mn(i),{baseUrl:r});return r!==n&&!a.serviceLocation&&t.serviceLocation&&(a.serviceLocation=t.serviceLocation),a})})):s,Sb=s=>{const e=Us(s,"SegmentTemplate")[0],t=Us(s,"SegmentList")[0],i=t&&Us(t,"SegmentURL").map(g=>Ln({tag:"SegmentURL"},mn(g))),n=Us(s,"SegmentBase")[0],r=t||e,a=r&&Us(r,"SegmentTimeline")[0],u=t||n||e,c=u&&Us(u,"Initialization")[0],d=e&&mn(e);d&&c?d.initialization=c&&mn(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});const f={template:d,segmentTimeline:a&&Us(a,"S").map(g=>mn(g)),list:t&&Ln(mn(t),{segmentUrls:i,initialization:mn(c)}),base:n&&Ln(mn(n),{initialization:mn(c)})};return Object.keys(f).forEach(g=>{f[g]||delete f[g]}),f},u4=(s,e,t)=>i=>{const n=Us(i,"BaseURL"),r=mp(e,n),a=Ln(s,mn(i)),u=Sb(i);return r.map(c=>({segmentInfo:Ln(t,u),attributes:Ln(a,c)}))},c4=s=>s.reduce((e,t)=>{const i=mn(t);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());const n=l4[i.schemeIdUri];if(n){e[n]={attributes:i};const r=Us(t,"cenc:pssh")[0];if(r){const a=Xh(r);e[n].pssh=a&&vk(a)}}return e},{}),d4=s=>{if(s.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{let i,n;return n=t,/^CC\d=/.test(t)?[i,n]=t.split("="):/^CC\d$/.test(t)&&(i=t),{channel:i,language:n}});if(s.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{const i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(t)){const[n,r=""]=t.split("=");i.channel=n,i.language=t,r.split(",").forEach(a=>{const[u,c]=a.split(":");u==="lang"?i.language=c:u==="er"?i.easyReader=Number(c):u==="war"?i.aspectRatio=Number(c):u==="3D"&&(i["3D"]=Number(c))})}else i.language=t;return i.channel&&(i.channel="SERVICE"+i.channel),i})},h4=s=>Bc(Us(s.node,"EventStream").map(e=>{const t=mn(e),i=t.schemeIdUri;return Us(e,"Event").map(n=>{const r=mn(n),a=r.presentationTime||0,u=t.timescale||1,c=r.duration||0,d=a/u+s.attributes.start;return{schemeIdUri:i,value:t.value,id:r.id,start:d,end:d+c/u,messageData:Xh(n)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),f4=(s,e,t)=>i=>{const n=mn(i),r=mp(e,Us(i,"BaseURL")),a=Us(i,"Role")[0],u={role:mn(a)};let c=Ln(s,n,u);const d=Us(i,"Accessibility")[0],f=d4(mn(d));f&&(c=Ln(c,{captionServices:f}));const g=Us(i,"Label")[0];if(g&&g.childNodes.length){const w=g.childNodes[0].nodeValue.trim();c=Ln(c,{label:w})}const y=c4(Us(i,"ContentProtection"));Object.keys(y).length&&(c=Ln(c,{contentProtection:y}));const v=Sb(i),T=Us(i,"Representation"),S=Ln(t,v);return Bc(T.map(u4(c,r,S)))},m4=(s,e)=>(t,i)=>{const n=mp(e,Us(t.node,"BaseURL")),r=Ln(s,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const a=Us(t.node,"AdaptationSet"),u=Sb(t.node);return Bc(a.map(f4(r,n,u)))},p4=(s,e)=>{if(s.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!s.length)return null;const t=Ln({serverURL:Xh(s[0])},mn(s[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},g4=({attributes:s,priorPeriodAttributes:e,mpdType:t})=>typeof s.start=="number"?s.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,y4=(s,e={})=>{const{manifestUri:t="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:r=function(){}}=e,a=Us(s,"Period");if(!a.length)throw new Error(Fc.INVALID_NUMBER_OF_PERIOD);const u=Us(s,"Location"),c=mn(s),d=mp([{baseUrl:t}],Us(s,"BaseURL")),f=Us(s,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=i,c.clientOffset=n,u.length&&(c.locations=u.map(Xh));const g=[];return a.forEach((y,v)=>{const T=mn(y),S=g[v-1];T.start=g4({attributes:T,priorPeriodAttributes:S?S.attributes:null,mpdType:c.type}),g.push({node:y,attributes:T})}),{locations:c.locations,contentSteeringInfo:p4(f,r),representationInfo:Bc(g.map(m4(c,d))),eventStream:Bc(g.map(h4))}},Lk=s=>{if(s==="")throw new Error(Fc.DASH_EMPTY_MANIFEST);const e=new kP.DOMParser;let t,i;try{t=e.parseFromString(s,"application/xml"),i=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error(Fc.DASH_INVALID_XML);return i},v4=s=>{const e=Us(s,"UTCTiming")[0];if(!e)return null;const t=mn(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;default:throw new Error(Fc.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},x4=(s,e={})=>{const t=y4(Lk(s),e),i=r4(t.representationInfo);return XP({dashPlaylists:i,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},b4=s=>v4(Lk(s));var av,X2;function T4(){if(X2)return av;X2=1;var s=Math.pow(2,32),e=function(t){var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n;return i.getBigUint64?(n=i.getBigUint64(0),n<Number.MAX_SAFE_INTEGER?Number(n):n):i.getUint32(0)*s+i.getUint32(4)};return av={getUint64:e,MAX_UINT32:s},av}var ov,Q2;function S4(){if(Q2)return ov;Q2=1;var s=T4().getUint64,e=function(t){var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8)},r=12;n.version===0?(n.earliestPresentationTime=i.getUint32(r),n.firstOffset=i.getUint32(r+4),r+=8):(n.earliestPresentationTime=s(t.subarray(r)),n.firstOffset=s(t.subarray(r+8)),r+=16),r+=2;var a=i.getUint16(r);for(r+=2;a>0;r+=12,a--)n.references.push({referenceType:(t[r]&128)>>>7,referencedSize:i.getUint32(r)&2147483647,subsegmentDuration:i.getUint32(r+4),startsWithSap:!!(t[r+8]&128),sapType:(t[r+8]&112)>>>4,sapDeltaTime:i.getUint32(r+8)&268435455});return n};return ov=e,ov}var _4=S4();const E4=Kc(_4);var w4=si([73,68,51]),A4=function(e,t){t===void 0&&(t=0),e=si(e);var i=e[t+5],n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9],r=(i&16)>>4;return r?n+20:n+10},hh=function s(e,t){return t===void 0&&(t=0),e=si(e),e.length-t<10||!Fs(e,w4,{offset:t})?t:(t+=A4(e,t),s(e,t))},Z2=function(e){return typeof e=="string"?_k(e):e},k4=function(e){return Array.isArray(e)?e.map(function(t){return Z2(t)}):[Z2(e)]},C4=function s(e,t,i){i===void 0&&(i=!1),t=k4(t),e=si(e);var n=[];if(!t.length)return n;for(var r=0;r<e.length;){var a=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,u=e.subarray(r+4,r+8);if(a===0)break;var c=r+a;if(c>e.length){if(i)break;c=e.length}var d=e.subarray(r+8,c);Fs(u,t[0])&&(t.length===1?n.push(d):n.push.apply(n,s(d,t.slice(1),i))),r=c}return n},km={EBML:si([26,69,223,163]),DocType:si([66,130]),Segment:si([24,83,128,103]),SegmentInfo:si([21,73,169,102]),Tracks:si([22,84,174,107]),Track:si([174]),TrackNumber:si([215]),DefaultDuration:si([35,227,131]),TrackEntry:si([174]),TrackType:si([131]),FlagDefault:si([136]),CodecID:si([134]),CodecPrivate:si([99,162]),VideoTrack:si([224]),AudioTrack:si([225]),Cluster:si([31,67,182,117]),Timestamp:si([231]),TimestampScale:si([42,215,177]),BlockGroup:si([160]),BlockDuration:si([155]),Block:si([161]),SimpleBlock:si([163])},gx=[128,64,32,16,8,4,2,1],D4=function(e){for(var t=1,i=0;i<gx.length&&!(e&gx[i]);i++)t++;return t},T0=function(e,t,i,n){i===void 0&&(i=!0),n===void 0&&(n=!1);var r=D4(e[t]),a=e.subarray(t,t+r);return i&&(a=Array.prototype.slice.call(e,t,t+r),a[0]^=gx[r-1]),{length:r,value:xP(a,{signed:n}),bytes:a}},J2=function s(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return s(t)}):typeof e=="number"?bP(e):e},L4=function(e){return Array.isArray(e)?e.map(function(t){return J2(t)}):[J2(e)]},R4=function s(e,t,i){if(i>=t.length)return t.length;var n=T0(t,i,!1);if(Fs(e.bytes,n.bytes))return i;var r=T0(t,i+n.length);return s(e,t,i+r.length+r.value+n.length)},eE=function s(e,t){t=L4(t),e=si(e);var i=[];if(!t.length)return i;for(var n=0;n<e.length;){var r=T0(e,n,!1),a=T0(e,n+r.length),u=n+r.length+a.length;a.value===127&&(a.value=R4(r,e,u),a.value!==e.length&&(a.value-=u));var c=u+a.value>e.length?e.length:u+a.value,d=e.subarray(u,c);Fs(t[0],r.bytes)&&(t.length===1?i.push(d):i=i.concat(s(d,t.slice(1))));var f=r.length+a.length+d.length;n+=f}return i},I4=si([0,0,0,1]),N4=si([0,0,1]),O4=si([0,0,3]),M4=function(e){for(var t=[],i=1;i<e.length-2;)Fs(e.subarray(i,i+3),O4)&&(t.push(i+2),i++),i++;if(t.length===0)return e;var n=e.length-t.length,r=new Uint8Array(n),a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=e[a];return r},Rk=function(e,t,i,n){e=si(e),i=[].concat(i);for(var r=0,a,u=0;r<e.length&&(u<n||a);){var c=void 0;if(Fs(e.subarray(r),I4)?c=4:Fs(e.subarray(r),N4)&&(c=3),!c){r++;continue}if(u++,a)return M4(e.subarray(a,r));var d=void 0;t==="h264"?d=e[r+c]&31:t==="h265"&&(d=e[r+c]>>1&63),i.indexOf(d)!==-1&&(a=r+c),r+=c+(t==="h264"?1:2)}return e.subarray(0,0)},P4=function(e,t,i){return Rk(e,"h264",t,i)},B4=function(e,t,i){return Rk(e,"h265",t,i)},er={webm:si([119,101,98,109]),matroska:si([109,97,116,114,111,115,107,97]),flac:si([102,76,97,67]),ogg:si([79,103,103,83]),ac3:si([11,119]),riff:si([82,73,70,70]),avi:si([65,86,73]),wav:si([87,65,86,69]),"3gp":si([102,116,121,112,51,103]),mp4:si([102,116,121,112]),fmp4:si([115,116,121,112]),mov:si([102,116,121,112,113,116]),moov:si([109,111,111,118]),moof:si([109,111,111,102])},Uc={aac:function(e){var t=hh(e);return Fs(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=hh(e);return Fs(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=eE(e,[km.EBML,km.DocType])[0];return Fs(t,er.webm)},mkv:function(e){var t=eE(e,[km.EBML,km.DocType])[0];return Fs(t,er.matroska)},mp4:function(e){if(Uc["3gp"](e)||Uc.mov(e))return!1;if(Fs(e,er.mp4,{offset:4})||Fs(e,er.fmp4,{offset:4})||Fs(e,er.moof,{offset:4})||Fs(e,er.moov,{offset:4}))return!0},mov:function(e){return Fs(e,er.mov,{offset:4})},"3gp":function(e){return Fs(e,er["3gp"],{offset:4})},ac3:function(e){var t=hh(e);return Fs(e,er.ac3,{offset:t})},ts:function(e){if(e.length<189&&e.length>=1)return e[0]===71;for(var t=0;t+188<e.length&&t<188;){if(e[t]===71&&e[t+188]===71)return!0;t+=1}return!1},flac:function(e){var t=hh(e);return Fs(e,er.flac,{offset:t})},ogg:function(e){return Fs(e,er.ogg)},avi:function(e){return Fs(e,er.riff)&&Fs(e,er.avi,{offset:8})},wav:function(e){return Fs(e,er.riff)&&Fs(e,er.wav,{offset:8})},h264:function(e){return P4(e,7,3).length},h265:function(e){return B4(e,[32,33],3).length}},yx=Object.keys(Uc).filter(function(s){return s!=="ts"&&s!=="h264"&&s!=="h265"}).concat(["ts","h264","h265"]);yx.forEach(function(s){var e=Uc[s];Uc[s]=function(t){return e(si(t))}});var F4=Uc,_b=function(e){e=si(e);for(var t=0;t<yx.length;t++){var i=yx[t];if(F4[i](e))return i}return""},U4=function(e){return C4(e,["moof"]).length>0},lv,tE;function j4(){if(tE)return lv;tE=1;var s=9e4,e,t,i,n,r,a,u;return e=function(c){return c*s},t=function(c,d){return c*d},i=function(c){return c/s},n=function(c,d){return c/d},r=function(c,d){return e(n(c,d))},a=function(c,d){return t(i(c),d)},u=function(c,d,f){return i(f?c:c-d)},lv={ONE_SECOND_IN_TS:s,secondsToVideoTs:e,secondsToAudioTs:t,videoTsToSeconds:i,audioTsToSeconds:n,audioTsToVideoTs:r,videoTsToAudioTs:a,metadataTsToSeconds:u},lv}var fu=j4();var vx="8.23.4";const Ao={},Cl=function(s,e){return Ao[s]=Ao[s]||[],e&&(Ao[s]=Ao[s].concat(e)),Ao[s]},$4=function(s,e){Cl(s,e)},Ik=function(s,e){const t=Cl(s).indexOf(e);return t<=-1?!1:(Ao[s]=Ao[s].slice(),Ao[s].splice(t,1),!0)},H4=function(s,e){Cl(s,[].concat(e).map(t=>{const i=(...n)=>(Ik(s,i),t(...n));return i}))},S0={prefixed:!0},e0=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],iE=e0[0];let fh;for(let s=0;s<e0.length;s++)if(e0[s][1]in bt){fh=e0[s];break}if(fh){for(let s=0;s<fh.length;s++)S0[iE[s]]=fh[s];S0.prefixed=fh[0]!==iE[0]}let gr=[];const z4=(s,e,t)=>(i,n,r)=>{const a=e.levels[n],u=new RegExp(`^(${a})$`);let c=s;if(i!=="log"&&r.unshift(i.toUpperCase()+":"),t&&(c=`%c${s}`,r.unshift(t)),r.unshift(c+":"),gr){gr.push([].concat(r));const f=gr.length-1e3;gr.splice(0,f>0?f:0)}if(!ye.console)return;let d=ye.console[i];!d&&i==="debug"&&(d=ye.console.info||ye.console.log),!(!d||!a||!u.test(i))&&d[Array.isArray(r)?"apply":"call"](ye.console,r)};function xx(s,e=":",t=""){let i="info",n;function r(...a){n("log",i,a)}return n=z4(s,r,t),r.createLogger=(a,u,c)=>{const d=u!==void 0?u:e,f=c!==void 0?c:t,g=`${s} ${d} ${a}`;return xx(g,d,f)},r.createNewLogger=(a,u,c)=>xx(a,u,c),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:i},r.level=a=>{if(typeof a=="string"){if(!r.levels.hasOwnProperty(a))throw new Error(`"${a}" in not a valid log level`);i=a}return i},r.history=()=>gr?[].concat(gr):[],r.history.filter=a=>(gr||[]).filter(u=>new RegExp(`.*${a}.*`).test(u[0])),r.history.clear=()=>{gr&&(gr.length=0)},r.history.disable=()=>{gr!==null&&(gr.length=0,gr=null)},r.history.enable=()=>{gr===null&&(gr=[])},r.error=(...a)=>n("error",i,a),r.warn=(...a)=>n("warn",i,a),r.debug=(...a)=>n("debug",i,a),r}const wi=xx("VIDEOJS"),Nk=wi.createLogger,V4=Object.prototype.toString,Ok=function(s){return Wa(s)?Object.keys(s):[]};function bc(s,e){Ok(s).forEach(t=>e(s[t],t))}function Mk(s,e,t=0){return Ok(s).reduce((i,n)=>e(i,s[n],n),t)}function Wa(s){return!!s&&typeof s=="object"}function jc(s){return Wa(s)&&V4.call(s)==="[object Object]"&&s.constructor===Object}function gs(...s){const e={};return s.forEach(t=>{t&&bc(t,(i,n)=>{if(!jc(i)){e[n]=i;return}jc(e[n])||(e[n]={}),e[n]=gs(e[n],i)})}),e}function Pk(s={}){const e=[];for(const t in s)if(s.hasOwnProperty(t)){const i=s[t];e.push(i)}return e}function pp(s,e,t,i=!0){const n=a=>Object.defineProperty(s,e,{value:a,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const a=t();return n(a),a}};return i&&(r.set=n),Object.defineProperty(s,e,r)}var G4=Object.freeze({__proto__:null,each:bc,reduce:Mk,isObject:Wa,isPlain:jc,merge:gs,values:Pk,defineLazyProperty:pp});let Eb=!1,Bk=null,va=!1,Fk,Uk=!1,Tc=!1,Sc=!1,Ya=!1,wb=null,gp=null;const q4=!!(ye.cast&&ye.cast.framework&&ye.cast.framework.CastReceiverContext);let jk=null,_0=!1,yp=!1,E0=!1,vp=!1,w0=!1,A0=!1,k0=!1;const Mh=!!(Wc()&&("ontouchstart"in ye||ye.navigator.maxTouchPoints||ye.DocumentTouch&&ye.document instanceof ye.DocumentTouch)),fl=ye.navigator&&ye.navigator.userAgentData;fl&&fl.platform&&fl.brands&&(va=fl.platform==="Android",Tc=!!fl.brands.find(s=>s.brand==="Microsoft Edge"),Sc=!!fl.brands.find(s=>s.brand==="Chromium"),Ya=!Tc&&Sc,wb=gp=(fl.brands.find(s=>s.brand==="Chromium")||{}).version||null,yp=fl.platform==="Windows");if(!Sc){const s=ye.navigator&&ye.navigator.userAgent||"";Eb=/iPod/i.test(s),Bk=(function(){const e=s.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null})(),va=/Android/i.test(s),Fk=(function(){const e=s.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);return t&&i?parseFloat(e[1]+"."+e[2]):t||null})(),Uk=/Firefox/i.test(s),Tc=/Edg/i.test(s),Sc=/Chrome/i.test(s)||/CriOS/i.test(s),Ya=!Tc&&Sc,wb=gp=(function(){const e=s.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null})(),jk=(function(){const e=/MSIE\s(\d+)\.\d/.exec(s);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(s)&&/rv:11.0/.test(s)&&(t=11),t})(),w0=/Tizen/i.test(s),A0=/Web0S/i.test(s),k0=w0||A0,_0=/Safari/i.test(s)&&!Ya&&!va&&!Tc&&!k0,yp=/Windows/i.test(s),E0=/iPad/i.test(s)||_0&&Mh&&!/iPhone/i.test(s),vp=/iPhone/i.test(s)&&!E0}const Wn=vp||E0||Eb,xp=(_0||Wn)&&!Ya;var $k=Object.freeze({__proto__:null,get IS_IPOD(){return Eb},get IOS_VERSION(){return Bk},get IS_ANDROID(){return va},get ANDROID_VERSION(){return Fk},get IS_FIREFOX(){return Uk},get IS_EDGE(){return Tc},get IS_CHROMIUM(){return Sc},get IS_CHROME(){return Ya},get CHROMIUM_VERSION(){return wb},get CHROME_VERSION(){return gp},IS_CHROMECAST_RECEIVER:q4,get IE_VERSION(){return jk},get IS_SAFARI(){return _0},get IS_WINDOWS(){return yp},get IS_IPAD(){return E0},get IS_IPHONE(){return vp},get IS_TIZEN(){return w0},get IS_WEBOS(){return A0},get IS_SMART_TV(){return k0},TOUCH_ENABLED:Mh,IS_IOS:Wn,IS_ANY_SAFARI:xp});function sE(s){return typeof s=="string"&&!!s.trim()}function K4(s){if(s.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function Wc(){return bt===ye.document}function Yc(s){return Wa(s)&&s.nodeType===1}function Hk(){try{return ye.parent!==ye.self}catch{return!0}}function zk(s){return function(e,t){if(!sE(e))return bt[s](null);sE(t)&&(t=bt.querySelector(t));const i=Yc(t)?t:bt;return i[s]&&i[s](e)}}function ui(s="div",e={},t={},i){const n=bt.createElement(s);return Object.getOwnPropertyNames(e).forEach(function(r){const a=e[r];r==="textContent"?Il(n,a):(n[r]!==a||r==="tabIndex")&&(n[r]=a)}),Object.getOwnPropertyNames(t).forEach(function(r){n.setAttribute(r,t[r])}),i&&Ab(n,i),n}function Il(s,e){return typeof s.textContent>"u"?s.innerText=e:s.textContent=e,s}function bx(s,e){e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}function Eh(s,e){return K4(e),s.classList.contains(e)}function gu(s,...e){return s.classList.add(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s}function bp(s,...e){return s?(s.classList.remove(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s):(wi.warn("removeClass was called with an element that doesn't exist"),null)}function Vk(s,e,t){return typeof t=="function"&&(t=t(s,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(i=>s.classList.toggle(i,t)),s}function Gk(s,e){Object.getOwnPropertyNames(e).forEach(function(t){const i=e[t];i===null||typeof i>"u"||i===!1?s.removeAttribute(t):s.setAttribute(t,i===!0?"":i)})}function xl(s){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(s&&s.attributes&&s.attributes.length>0){const i=s.attributes;for(let n=i.length-1;n>=0;n--){const r=i[n].name;let a=i[n].value;t.includes(r)&&(a=a!==null),e[r]=a}}return e}function qk(s,e){return s.getAttribute(e)}function $c(s,e,t){s.setAttribute(e,t)}function Tp(s,e){s.removeAttribute(e)}function Kk(){bt.body.focus(),bt.onselectstart=function(){return!1}}function Wk(){bt.onselectstart=function(){return!0}}function Hc(s){if(s&&s.getBoundingClientRect&&s.parentNode){const e=s.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(i=>{e[i]!==void 0&&(t[i]=e[i])}),t.height||(t.height=parseFloat(zc(s,"height"))),t.width||(t.width=parseFloat(zc(s,"width"))),t}}function Ph(s){if(!s||s&&!s.offsetParent)return{left:0,top:0,width:0,height:0};const e=s.offsetWidth,t=s.offsetHeight;let i=0,n=0;for(;s.offsetParent&&s!==bt[S0.fullscreenElement];)i+=s.offsetLeft,n+=s.offsetTop,s=s.offsetParent;return{left:i,top:n,width:e,height:t}}function Sp(s,e){const t={x:0,y:0};if(Wn){let f=s;for(;f&&f.nodeName.toLowerCase()!=="html";){const g=zc(f,"transform");if(/^matrix/.test(g)){const y=g.slice(7,-1).split(/,\s/).map(Number);t.x+=y[4],t.y+=y[5]}else if(/^matrix3d/.test(g)){const y=g.slice(9,-1).split(/,\s/).map(Number);t.x+=y[12],t.y+=y[13]}if(f.assignedSlot&&f.assignedSlot.parentElement&&ye.WebKitCSSMatrix){const y=ye.getComputedStyle(f.assignedSlot.parentElement).transform,v=new ye.WebKitCSSMatrix(y);t.x+=v.m41,t.y+=v.m42}f=f.parentNode||f.host}}const i={},n=Ph(e.target),r=Ph(s),a=r.width,u=r.height;let c=e.offsetY-(r.top-n.top),d=e.offsetX-(r.left-n.left);return e.changedTouches&&(d=e.changedTouches[0].pageX-r.left,c=e.changedTouches[0].pageY+r.top,Wn&&(d-=t.x,c-=t.y)),i.y=1-Math.max(0,Math.min(1,c/u)),i.x=Math.max(0,Math.min(1,d/a)),i}function Yk(s){return Wa(s)&&s.nodeType===3}function _p(s){for(;s.firstChild;)s.removeChild(s.firstChild);return s}function Xk(s){return typeof s=="function"&&(s=s()),(Array.isArray(s)?s:[s]).map(e=>{if(typeof e=="function"&&(e=e()),Yc(e)||Yk(e))return e;if(typeof e=="string"&&/\S/.test(e))return bt.createTextNode(e)}).filter(e=>e)}function Ab(s,e){return Xk(e).forEach(t=>s.appendChild(t)),s}function Qk(s,e){return Ab(_p(s),e)}function Bh(s){return s.button===void 0&&s.buttons===void 0||s.button===0&&s.buttons===void 0||s.type==="mouseup"&&s.button===0&&s.buttons===0||s.type==="mousedown"&&s.button===0&&s.buttons===0?!0:!(s.button!==0||s.buttons!==1)}const Dl=zk("querySelector"),Zk=zk("querySelectorAll");function zc(s,e){if(!s||!e)return"";if(typeof ye.getComputedStyle=="function"){let t;try{t=ye.getComputedStyle(s)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function Jk(s){[...bt.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(n=>n.cssText).join(""),i=bt.createElement("style");i.textContent=t,s.document.head.appendChild(i)}catch{const i=bt.createElement("link");i.rel="stylesheet",i.type=e.type,i.media=e.media.mediaText,i.href=e.href,s.document.head.appendChild(i)}})}var eC=Object.freeze({__proto__:null,isReal:Wc,isEl:Yc,isInFrame:Hk,createEl:ui,textContent:Il,prependTo:bx,hasClass:Eh,addClass:gu,removeClass:bp,toggleClass:Vk,setAttributes:Gk,getAttributes:xl,getAttribute:qk,setAttribute:$c,removeAttribute:Tp,blockTextSelection:Kk,unblockTextSelection:Wk,getBoundingClientRect:Hc,findPosition:Ph,getPointerPosition:Sp,isTextNode:Yk,emptyEl:_p,normalizeContent:Xk,appendContent:Ab,insertContent:Qk,isSingleLeftClick:Bh,$:Dl,$$:Zk,computedStyle:zc,copyStyleSheetsToWindow:Jk});let tC=!1,Tx;const W4=function(){if(Tx.options.autoSetup===!1)return;const s=Array.prototype.slice.call(bt.getElementsByTagName("video")),e=Array.prototype.slice.call(bt.getElementsByTagName("audio")),t=Array.prototype.slice.call(bt.getElementsByTagName("video-js")),i=s.concat(e,t);if(i&&i.length>0)for(let n=0,r=i.length;n<r;n++){const a=i[n];if(a&&a.getAttribute)a.player===void 0&&a.getAttribute("data-setup")!==null&&Tx(a);else{Sx(1);break}}else tC||Sx(1)};function Sx(s,e){Wc()&&(e&&(Tx=e),ye.setTimeout(W4,s))}function _x(){tC=!0,ye.removeEventListener("load",_x)}Wc()&&(bt.readyState==="complete"?_x():ye.addEventListener("load",_x));const iC=function(s){const e=bt.createElement("style");return e.className=s,e},sC=function(s,e){s.styleSheet?s.styleSheet.cssText=e:s.textContent=e};var ir=new WeakMap;const Y4=3;let X4=Y4;function ea(){return X4++}function nE(s,e){if(!ir.has(s))return;const t=ir.get(s);t.handlers[e].length===0&&(delete t.handlers[e],s.removeEventListener?s.removeEventListener(e,t.dispatcher,!1):s.detachEvent&&s.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&&ir.delete(s)}function kb(s,e,t,i){t.forEach(function(n){s(e,n,i)})}function Ep(s){if(s.fixed_)return s;function e(){return!0}function t(){return!1}if(!s||!s.isPropagationStopped||!s.isImmediatePropagationStopped){const i=s||ye.event;s={};const n=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in i)n.includes(r)||r==="returnValue"&&i.preventDefault||(s[r]=i[r]);if(s.target||(s.target=s.srcElement||bt),s.relatedTarget||(s.relatedTarget=s.fromElement===s.target?s.toElement:s.fromElement),s.preventDefault=function(){i.preventDefault&&i.preventDefault(),s.returnValue=!1,i.returnValue=!1,s.defaultPrevented=!0},s.defaultPrevented=!1,s.stopPropagation=function(){i.stopPropagation&&i.stopPropagation(),s.cancelBubble=!0,i.cancelBubble=!0,s.isPropagationStopped=e},s.isPropagationStopped=t,s.stopImmediatePropagation=function(){i.stopImmediatePropagation&&i.stopImmediatePropagation(),s.isImmediatePropagationStopped=e,s.stopPropagation()},s.isImmediatePropagationStopped=t,s.clientX!==null&&s.clientX!==void 0){const r=bt.documentElement,a=bt.body;s.pageX=s.clientX+(r&&r.scrollLeft||a&&a.scrollLeft||0)-(r&&r.clientLeft||a&&a.clientLeft||0),s.pageY=s.clientY+(r&&r.scrollTop||a&&a.scrollTop||0)-(r&&r.clientTop||a&&a.clientTop||0)}s.which=s.charCode||s.keyCode,s.button!==null&&s.button!==void 0&&(s.button=s.button&1?0:s.button&4?1:s.button&2?2:0)}return s.fixed_=!0,s}let Cm;const Q4=function(){if(typeof Cm!="boolean"){Cm=!1;try{const s=Object.defineProperty({},"passive",{get(){Cm=!0}});ye.addEventListener("test",null,s),ye.removeEventListener("test",null,s)}catch{}}return Cm},Z4=["touchstart","touchmove"];function zr(s,e,t){if(Array.isArray(e))return kb(zr,s,e,t);ir.has(s)||ir.set(s,{});const i=ir.get(s);if(i.handlers||(i.handlers={}),i.handlers[e]||(i.handlers[e]=[]),t.guid||(t.guid=ea()),i.handlers[e].push(t),i.dispatcher||(i.disabled=!1,i.dispatcher=function(n,r){if(i.disabled)return;n=Ep(n);const a=i.handlers[n.type];if(a){const u=a.slice(0);for(let c=0,d=u.length;c<d&&!n.isImmediatePropagationStopped();c++)try{u[c].call(s,n,r)}catch(f){wi.error(f)}}}),i.handlers[e].length===1)if(s.addEventListener){let n=!1;Q4()&&Z4.indexOf(e)>-1&&(n={passive:!0}),s.addEventListener(e,i.dispatcher,n)}else s.attachEvent&&s.attachEvent("on"+e,i.dispatcher)}function Yn(s,e,t){if(!ir.has(s))return;const i=ir.get(s);if(!i.handlers)return;if(Array.isArray(e))return kb(Yn,s,e,t);const n=function(a,u){i.handlers[u]=[],nE(a,u)};if(e===void 0){for(const a in i.handlers)Object.prototype.hasOwnProperty.call(i.handlers||{},a)&&n(s,a);return}const r=i.handlers[e];if(r){if(!t){n(s,e);return}if(t.guid)for(let a=0;a<r.length;a++)r[a].guid===t.guid&&r.splice(a--,1);nE(s,e)}}function Xc(s,e,t){const i=ir.has(s)?ir.get(s):{},n=s.parentNode||s.ownerDocument;if(typeof e=="string"?e={type:e,target:s}:e.target||(e.target=s),e=Ep(e),i.dispatcher&&i.dispatcher.call(s,e,t),n&&!e.isPropagationStopped()&&e.bubbles===!0)Xc.call(null,n,e,t);else if(!n&&!e.defaultPrevented&&e.target&&e.target[e.type]){ir.has(e.target)||ir.set(e.target,{});const r=ir.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function wp(s,e,t){if(Array.isArray(e))return kb(wp,s,e,t);const i=function(){Yn(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||ea(),zr(s,e,i)}function Cb(s,e,t){const i=function(){Yn(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||ea(),zr(s,e,i)}var J4=Object.freeze({__proto__:null,fixEvent:Ep,on:zr,off:Yn,trigger:Xc,one:wp,any:Cb});const ta=30,Ls=function(s,e,t){e.guid||(e.guid=ea());const i=e.bind(s);return i.guid=t?t+"_"+e.guid:e.guid,i},Xa=function(s,e){let t=ye.performance.now();return function(...n){const r=ye.performance.now();r-t>=e&&(s(...n),t=r)}},nC=function(s,e,t,i=ye){let n;const r=()=>{i.clearTimeout(n),n=null},a=function(){const u=this,c=arguments;let d=function(){n=null,d=null,t||s.apply(u,c)};!n&&t&&s.apply(u,c),i.clearTimeout(n),n=i.setTimeout(d,e)};return a.cancel=r,a};var eB=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:ta,bind_:Ls,throttle:Xa,debounce:nC});let th;class Vr{on(e,t){const i=this.addEventListener;this.addEventListener=()=>{},zr(this,e,t),this.addEventListener=i}off(e,t){Yn(this,e,t)}one(e,t){const i=this.addEventListener;this.addEventListener=()=>{},wp(this,e,t),this.addEventListener=i}any(e,t){const i=this.addEventListener;this.addEventListener=()=>{},Cb(this,e,t),this.addEventListener=i}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Ep(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),Xc(this,e)}queueTrigger(e){th||(th=new Map);const t=e.type||e;let i=th.get(this);i||(i=new Map,th.set(this,i));const n=i.get(t);i.delete(t),ye.clearTimeout(n);const r=ye.setTimeout(()=>{i.delete(t),i.size===0&&(i=null,th.delete(this)),this.trigger(e)},0);i.set(t,r)}}Vr.prototype.allowedEvents_={};Vr.prototype.addEventListener=Vr.prototype.on;Vr.prototype.removeEventListener=Vr.prototype.off;Vr.prototype.dispatchEvent=Vr.prototype.trigger;const Ap=s=>typeof s.name=="function"?s.name():typeof s.name=="string"?s.name:s.name_?s.name_:s.constructor&&s.constructor.name?s.constructor.name:typeof s,Do=s=>s instanceof Vr||!!s.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof s[e]=="function"),tB=(s,e)=>{Do(s)?e():(s.eventedCallbacks||(s.eventedCallbacks=[]),s.eventedCallbacks.push(e))},Ex=s=>typeof s=="string"&&/\S/.test(s)||Array.isArray(s)&&!!s.length,C0=(s,e,t)=>{if(!s||!s.nodeName&&!Do(s))throw new Error(`Invalid target for ${Ap(e)}#${t}; must be a DOM node or evented object.`)},rC=(s,e,t)=>{if(!Ex(s))throw new Error(`Invalid event type for ${Ap(e)}#${t}; must be a non-empty string or array.`)},aC=(s,e,t)=>{if(typeof s!="function")throw new Error(`Invalid listener for ${Ap(e)}#${t}; must be a function.`)},uv=(s,e,t)=>{const i=e.length<3||e[0]===s||e[0]===s.eventBusEl_;let n,r,a;return i?(n=s.eventBusEl_,e.length>=3&&e.shift(),[r,a]=e):(n=e[0],r=e[1],a=e[2]),C0(n,s,t),rC(r,s,t),aC(a,s,t),a=Ls(s,a),{isTargetingSelf:i,target:n,type:r,listener:a}},tu=(s,e,t,i)=>{C0(s,s,e),s.nodeName?J4[e](s,t,i):s[e](t,i)},iB={on(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=uv(this,s,"on");if(tu(t,"on",i,n),!e){const r=()=>this.off(t,i,n);r.guid=n.guid;const a=()=>this.off("dispose",r);a.guid=n.guid,tu(this,"on","dispose",r),tu(t,"on","dispose",a)}},one(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=uv(this,s,"one");if(e)tu(t,"one",i,n);else{const r=(...a)=>{this.off(t,i,r),n.apply(null,a)};r.guid=n.guid,tu(t,"one",i,r)}},any(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=uv(this,s,"any");if(e)tu(t,"any",i,n);else{const r=(...a)=>{this.off(t,i,r),n.apply(null,a)};r.guid=n.guid,tu(t,"any",i,r)}},off(s,e,t){if(!s||Ex(s))Yn(this.eventBusEl_,s,e);else{const i=s,n=e;C0(i,this,"off"),rC(n,this,"off"),aC(t,this,"off"),t=Ls(this,t),this.off("dispose",t),i.nodeName?(Yn(i,n,t),Yn(i,"dispose",t)):Do(i)&&(i.off(n,t),i.off("dispose",t))}},trigger(s,e){C0(this.eventBusEl_,this,"trigger");const t=s&&typeof s!="string"?s.type:s;if(!Ex(t))throw new Error(`Invalid event type for ${Ap(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return Xc(this.eventBusEl_,s,e)}};function Db(s,e={}){const{eventBusKey:t}=e;if(t){if(!s[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);s.eventBusEl_=s[t]}else s.eventBusEl_=ui("span",{className:"vjs-event-bus"});return Object.assign(s,iB),s.eventedCallbacks&&s.eventedCallbacks.forEach(i=>{i()}),s.on("dispose",()=>{s.off(),[s,s.el_,s.eventBusEl_].forEach(function(i){i&&ir.has(i)&&ir.delete(i)}),ye.setTimeout(()=>{s.eventBusEl_=null},0)}),s}const sB={state:{},setState(s){typeof s=="function"&&(s=s());let e;return bc(s,(t,i)=>{this.state[i]!==t&&(e=e||{},e[i]={from:this.state[i],to:t}),this.state[i]=t}),e&&Do(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function oC(s,e){return Object.assign(s,sB),s.state=Object.assign({},s.state,e),typeof s.handleStateChanged=="function"&&Do(s)&&s.on("statechanged",s.handleStateChanged),s}const wh=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toLowerCase())},Qs=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},lC=function(s,e){return Qs(s)===Qs(e)};var nB=Object.freeze({__proto__:null,toLowerCase:wh,toTitleCase:Qs,titleCaseEquals:lC});class st{constructor(e,t,i){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=gs({},this.options_),t=this.options_=gs(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const n=e&&e.id&&e.id()||"no_player";this.id_=`${n}_component_${ea()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(n=>this.addClass(n)),["on","off","one","any","trigger"].forEach(n=>{this[n]=void 0}),t.evented!==!1&&(Db(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),oC(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(i),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=gs(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,i){return ui(e,t,i)}localize(e,t,i=e){const n=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),a=r&&r[n],u=n&&n.split("-")[0],c=r&&r[u];let d=i;return a&&a[e]?d=a[e]:c&&c[e]&&(d=c[e]),t&&(d=d.replace(/\{(\d+)\}/g,function(f,g){const y=t[g-1];let v=y;return typeof y>"u"&&(v=f),v})),d}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((i,n)=>i.concat(n),[]);let t=this;for(let i=0;i<e.length;i++)if(t=t.getChild(e[i]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const i="http://www.w3.org/2000/svg",n=ui("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=bt.createElementNS(i,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const a=bt.createElementNS(i,"use");return r.appendChild(a),a.setAttributeNS(null,"href",`#vjs-icon-${e}`),n.appendChild(r),this.iconIsSet_?t.replaceChild(n,t.querySelector(".vjs-icon-placeholder")):t.appendChild(n),this.iconIsSet_=!0,n}addChild(e,t={},i=this.children_.length){let n,r;if(typeof e=="string"){r=Qs(e);const a=t.componentClass||r;t.name=r;const u=st.getComponent(a);if(!u)throw new Error(`Component ${a} does not exist`);if(typeof u!="function")return null;n=new u(this.player_||this,t)}else n=e;if(n.parentComponent_&&n.parentComponent_.removeChild(n),this.children_.splice(i,0,n),n.parentComponent_=this,typeof n.id=="function"&&(this.childIndex_[n.id()]=n),r=r||n.name&&Qs(n.name()),r&&(this.childNameIndex_[r]=n,this.childNameIndex_[wh(r)]=n),typeof n.el=="function"&&n.el()){let a=null;this.children_[i+1]&&(this.children_[i+1].el_?a=this.children_[i+1].el_:Yc(this.children_[i+1])&&(a=this.children_[i+1])),this.contentEl().insertBefore(n.el(),a)}return n}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let n=this.children_.length-1;n>=0;n--)if(this.children_[n]===e){t=!0,this.children_.splice(n,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Qs(e.name())]=null,this.childNameIndex_[wh(e.name())]=null;const i=e.el();i&&i.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,i=a=>{const u=a.name;let c=a.opts;if(t[u]!==void 0&&(c=t[u]),c===!1)return;c===!0&&(c={}),c.playerOptions=this.options_.playerOptions;const d=this.addChild(u,c);d&&(this[u]=d)};let n;const r=st.getComponent("Tech");Array.isArray(e)?n=e:n=Object.keys(e),n.concat(Object.keys(this.options_).filter(function(a){return!n.some(function(u){return typeof u=="string"?a===u:a===u.name})})).map(a=>{let u,c;return typeof a=="string"?(u=a,c=e[u]||this.options_[u]||{}):(u=a.name,c=a),{name:u,opts:c}}).filter(a=>{const u=st.getComponent(a.opts.componentClass||Qs(a.name));return u&&!r.isTech(u)}).forEach(i)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return Dl(e,t||this.contentEl())}$$(e,t){return Zk(e,t||this.contentEl())}hasClass(e){return Eh(this.el_,e)}addClass(...e){gu(this.el_,...e)}removeClass(...e){bp(this.el_,...e)}toggleClass(e,t){Vk(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return qk(this.el_,e)}setAttribute(e,t){$c(this.el_,e,t)}removeAttribute(e){Tp(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,i){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",i||this.trigger("componentresize");return}if(!this.el_)return 0;const n=this.el_.style[e],r=n.indexOf("px");return parseInt(r!==-1?n.slice(0,r):this.el_["offset"+Qs(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=zc(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const i=`offset${Qs(e)}`;t=this.el_[i]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},i={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:i}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const i=10,n=200;let r;this.on("touchstart",function(u){u.touches.length===1&&(t={pageX:u.touches[0].pageX,pageY:u.touches[0].pageY},e=ye.performance.now(),r=!0)}),this.on("touchmove",function(u){if(u.touches.length>1)r=!1;else if(t){const c=u.touches[0].pageX-t.pageX,d=u.touches[0].pageY-t.pageY;Math.sqrt(c*c+d*d)>i&&(r=!1)}});const a=function(){r=!1};this.on("touchleave",a),this.on("touchcancel",a),this.on("touchend",function(u){t=null,r===!0&&ye.performance.now()-e<n&&(u.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=Ls(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const i=function(n){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",i),this.on("touchcancel",i)}setTimeout(e,t){var i;return e=Ls(this,e),this.clearTimersOnDispose_(),i=ye.setTimeout(()=>{this.setTimeoutIds_.has(i)&&this.setTimeoutIds_.delete(i),e()},t),this.setTimeoutIds_.add(i),i}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),ye.clearTimeout(e)),e}setInterval(e,t){e=Ls(this,e),this.clearTimersOnDispose_();const i=ye.setInterval(e,t);return this.setIntervalIds_.add(i),i}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),ye.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=Ls(this,e),t=ye.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=Ls(this,t);const i=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,i),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),ye.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((i,n)=>this[t](n))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const a=ye.getComputedStyle(r,null),u=a.getPropertyValue("visibility");return a.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(u)}function i(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||ye.getComputedStyle(r).height==="0px"||ye.getComputedStyle(r).width==="0px")}function n(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const a={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(a.x<0||a.x>(bt.documentElement.clientWidth||ye.innerWidth)||a.y<0||a.y>(bt.documentElement.clientHeight||ye.innerHeight))return!1;let u=bt.elementFromPoint(a.x,a.y);for(;u;){if(u===r)return!0;if(u.parentNode)u=u.parentNode;else return!1}}return e||(e=this.el()),!!(n(e)&&i(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const i=st.getComponent("Tech"),n=i&&i.isTech(t),r=st===t||st.prototype.isPrototypeOf(t.prototype);if(n||!r){let u;throw n?u="techs must be registered using Tech.registerTech()":u="must be a Component subclass",new Error(`Illegal component, "${e}"; ${u}.`)}e=Qs(e),st.components_||(st.components_={});const a=st.getComponent("Player");if(e==="Player"&&a&&a.players){const u=a.players,c=Object.keys(u);if(u&&c.length>0){for(let d=0;d<c.length;d++)if(u[c[d]]!==null)throw new Error("Can not register Player component after player has been created.")}}return st.components_[e]=t,st.components_[wh(e)]=t,t}static getComponent(e){if(!(!e||!st.components_))return st.components_[e]}}st.registerComponent("Component",st);function rB(s,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${s}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function rE(s,e,t,i){return rB(s,i,t.length-1),t[i][e]}function cv(s){let e;return s===void 0||s.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:s.length,start:rE.bind(null,"start",0,s),end:rE.bind(null,"end",1,s)},ye.Symbol&&ye.Symbol.iterator&&(e[ye.Symbol.iterator]=()=>(s||[]).values()),e}function ya(s,e){return Array.isArray(s)?cv(s):s===void 0||e===void 0?cv():cv([[s,e]])}const uC=function(s,e){s=s<0?0:s;let t=Math.floor(s%60),i=Math.floor(s/60%60),n=Math.floor(s/3600);const r=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(n=i=t="-"),n=n>0||a>0?n+":":"",i=((n||r>=10)&&i<10?"0"+i:i)+":",t=t<10?"0"+t:t,n+i+t};let Lb=uC;function cC(s){Lb=s}function dC(){Lb=uC}function Eu(s,e=s){return Lb(s,e)}var aB=Object.freeze({__proto__:null,createTimeRanges:ya,createTimeRange:ya,setFormatTime:cC,resetFormatTime:dC,formatTime:Eu});function hC(s,e){let t=0,i,n;if(!e)return 0;(!s||!s.length)&&(s=ya(0,0));for(let r=0;r<s.length;r++)i=s.start(r),n=s.end(r),n>e&&(n=e),t+=n-i;return t/e}function Gs(s){if(s instanceof Gs)return s;typeof s=="number"?this.code=s:typeof s=="string"?this.message=s:Wa(s)&&(typeof s.code=="number"&&(this.code=s.code),Object.assign(this,s)),this.message||(this.message=Gs.defaultMessages[this.code]||"")}Gs.prototype.code=0;Gs.prototype.message="";Gs.prototype.status=null;Gs.prototype.metadata=null;Gs.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Gs.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Gs.MEDIA_ERR_CUSTOM=0;Gs.prototype.MEDIA_ERR_CUSTOM=0;Gs.MEDIA_ERR_ABORTED=1;Gs.prototype.MEDIA_ERR_ABORTED=1;Gs.MEDIA_ERR_NETWORK=2;Gs.prototype.MEDIA_ERR_NETWORK=2;Gs.MEDIA_ERR_DECODE=3;Gs.prototype.MEDIA_ERR_DECODE=3;Gs.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Gs.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Gs.MEDIA_ERR_ENCRYPTED=5;Gs.prototype.MEDIA_ERR_ENCRYPTED=5;function Ah(s){return s!=null&&typeof s.then=="function"}function $a(s){Ah(s)&&s.then(null,e=>{})}const wx=function(s){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((t,i,n)=>(s[i]&&(t[i]=s[i]),t),{cues:s.cues&&Array.prototype.map.call(s.cues,function(t){return{startTime:t.startTime,endTime:t.endTime,text:t.text,id:t.id}})})},oB=function(s){const e=s.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const r=wx(n.track);return n.src&&(r.src=n.src),r}).concat(Array.prototype.filter.call(s.textTracks(),function(n){return t.indexOf(n)===-1}).map(wx))},lB=function(s,e){return s.forEach(function(t){const i=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(n=>i.addCue(n))}),e.textTracks()};var Ax={textTracksToJson:oB,jsonToTextTracks:lB,trackToJson:wx};const dv="vjs-modal-dialog";class Qc extends st{constructor(e,t){super(e,t),this.handleKeyDown_=i=>this.handleKeyDown(i),this.close_=i=>this.close(i),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=ui("div",{className:`${dv}-content`},{role:"document"}),this.descEl_=ui("p",{className:`${dv}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Il(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${dv} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let i=this.getChild("closeButton");if(t&&!i){const n=this.contentEl_;this.contentEl_=this.el_,i=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=n,this.on(i,"close",this.close_)}!t&&i&&(this.off(i,"close",this.close_),this.removeChild(i),i.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),i=t.parentNode,n=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,i.removeChild(t),this.empty(),Qk(t,e),this.trigger("modalfill"),n?i.insertBefore(t,n):i.appendChild(t);const r=this.getChild("closeButton");r&&i.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),_p(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=bt.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),i=this.el_.querySelector(":focus");let n;for(let r=0;r<t.length;r++)if(i===t[r]){n=r;break}bt.activeElement===this.el_&&(n=0),e.shiftKey&&n===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&n===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof ye.HTMLAnchorElement||t instanceof ye.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof ye.HTMLInputElement||t instanceof ye.HTMLSelectElement||t instanceof ye.HTMLTextAreaElement||t instanceof ye.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof ye.HTMLIFrameElement||t instanceof ye.HTMLObjectElement||t instanceof ye.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Qc.prototype.options_={pauseOnOpen:!0,temporary:!0};st.registerComponent("ModalDialog",Qc);class wu extends Vr{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},Do(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this[i],t.off&&t.off(),this.tracks_.splice(i,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}wu.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const s in wu.prototype.allowedEvents_)wu.prototype["on"+s]=null;const hv=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].enabled=!1)};class fC extends wu{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){hv(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&hv(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,hv(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const fv=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].selected=!1)};class mC extends wu{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){fv(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&fv(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,fv(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class Rb extends wu{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}toJSON(){return this.tracks_.map(e=>e.toJSON())}}class uB{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,i=e.length;t<i;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let i=0,n=this.trackElements_.length;i<n;i++)if(e===this.trackElements_[i].track){t=this.trackElements_[i];break}return t}removeTrackElement_(e){for(let t=0,i=this.trackElements_.length;t<i;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class D0{constructor(e){D0.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let i=0;const n=e.length;this.cues_=e,this.length_=e.length;const r=function(a){""+a in this||Object.defineProperty(this,""+a,{get(){return this.cues_[a]}})};if(t<n)for(i=t;i<n;i++)r.call(this,i)}getCueById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}const cB={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},dB={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},hB={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},aE={disabled:"disabled",hidden:"hidden",showing:"showing"};class Ib extends Vr{constructor(e={}){super();const t={id:e.id||"vjs_track_"+ea(),kind:e.kind||"",language:e.language||""};let i=e.label||"";for(const n in t)Object.defineProperty(this,n,{get(){return t[n]},set(){}});Object.defineProperty(this,"label",{get(){return i},set(n){n!==i&&(i=n,this.trigger("labelchange"))}})}}const Nb=function(s){return new URL(s,bt.baseURI)},pC=function(s){return new URL(s,bt.baseURI).href},Ob=function(s){if(typeof s=="string"){const t=s.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return t?t[1].toLowerCase():""}return""},kp=function(s,e=ye.location){return Nb(s).origin!==e.origin};var fB=Object.freeze({__proto__:null,parseUrl:Nb,getAbsoluteURL:pC,getFileExtension:Ob,isCrossOrigin:kp});const oE=function(s,e){const t=new ye.WebVTT.Parser(ye,ye.vttjs,ye.WebVTT.StringDecoder()),i=[];t.oncue=function(n){e.addCue(n)},t.onparsingerror=function(n){i.push(n)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(s),i.length>0&&(ye.console&&ye.console.groupCollapsed&&ye.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),i.forEach(n=>wi.error(n)),ye.console&&ye.console.groupEnd&&ye.console.groupEnd()),t.flush()},lE=function(s,e){const t={uri:s},i=kp(s);i&&(t.cors=i);const n=e.tech_.crossOrigin()==="use-credentials";n&&(t.withCredentials=n),yk(t,Ls(this,function(r,a,u){if(r)return wi.error(r,a);e.loaded_=!0,typeof ye.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){wi.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return oE(u,e)}):oE(u,e)}))};class Qh extends Ib{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=gs(e,{kind:hB[e.kind]||"subtitles",language:e.language||e.srclang||""});let i=aE[t.mode]||"disabled";const n=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(i="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new D0(this.cues_),a=new D0(this.activeCues_);let u=!1;this.timeupdateHandler=Ls(this,function(d={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){d.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,u&&(this.trigger("cuechange"),u=!1),d.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const c=()=>{this.stopTracking()};this.tech_.one("dispose",c),i!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return n},set(){}},mode:{get(){return i},set(d){aE[d]&&i!==d&&(i=d,!this.preload_&&i!=="disabled"&&this.cues.length===0&&lE(this.src,this),this.stopTracking(),i!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return a;const d=this.tech_.currentTime(),f=[];for(let g=0,y=this.cues.length;g<y;g++){const v=this.cues[g];v.startTime<=d&&v.endTime>=d&&f.push(v)}if(u=!1,f.length!==this.activeCues_.length)u=!0;else for(let g=0;g<f.length;g++)this.activeCues_.indexOf(f[g])===-1&&(u=!0);return this.activeCues_=f,a.setCues_(this.activeCues_),a},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&lE(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new ye.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const n in e)n in t||(t[n]=e[n]);t.id=e.id,t.originalCue_=e}const i=this.tech_.textTracks();for(let n=0;n<i.length;n++)i[n]!==this&&i[n].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}toJSON(){return Ax.trackToJson(this)}removeCue(e){let t=this.cues_.length;for(;t--;){const i=this.cues_[t];if(i===e||i.originalCue_&&i.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}Qh.prototype.allowedEvents_={cuechange:"cuechange"};class gC extends Ib{constructor(e={}){const t=gs(e,{kind:dB[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"enabled",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class yC extends Ib{constructor(e={}){const t=gs(e,{kind:cB[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"selected",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class Ro extends Vr{constructor(e={}){super();let t;const i=new Qh(e);this.kind=i.kind,this.src=i.src,this.srclang=i.language,this.label=i.label,this.default=i.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return i}}}),t=Ro.NONE,i.addEventListener("loadeddata",()=>{t=Ro.LOADED,this.trigger({type:"load",target:this})})}}Ro.prototype.allowedEvents_={load:"load"};Ro.NONE=0;Ro.LOADING=1;Ro.LOADED=2;Ro.ERROR=3;const Jr={audio:{ListClass:fC,TrackClass:gC,capitalName:"Audio"},video:{ListClass:mC,TrackClass:yC,capitalName:"Video"},text:{ListClass:Rb,TrackClass:Qh,capitalName:"Text"}};Object.keys(Jr).forEach(function(s){Jr[s].getterName=`${s}Tracks`,Jr[s].privateName=`${s}Tracks_`});const Vc={remoteText:{ListClass:Rb,TrackClass:Qh,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:uB,TrackClass:Ro,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},tr=Object.assign({},Jr,Vc);Vc.names=Object.keys(Vc);Jr.names=Object.keys(Jr);tr.names=[].concat(Vc.names).concat(Jr.names);function mB(s,e,t,i,n={}){const r=s.textTracks();n.kind=e,t&&(n.label=t),i&&(n.language=i),n.tech=s;const a=new tr.text.TrackClass(n);return r.addTrack(a),a}class bi extends st{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=i=>this.onDurationChange(i),this.trackProgress_=i=>this.trackProgress(i),this.trackCurrentTime_=i=>this.trackCurrentTime(i),this.stopTrackingCurrentTime_=i=>this.stopTrackingCurrentTime(i),this.disposeSourceHandler_=i=>this.disposeSourceHandler(i),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),tr.names.forEach(i=>{const n=tr[i];e&&e[n.getterName]&&(this[n.privateName]=e[n.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(i=>{e[`native${i}Tracks`]===!1&&(this[`featuresNative${i}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new tr.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(Ls(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return ya(0,0)}bufferedPercent(){return hC(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(Jr.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const i=this[`${t}Tracks`]()||[];let n=i.length;for(;n--;){const r=i[n];t==="text"&&this.removeRemoteTextTrack(r),i.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const i=e[t];this.removeRemoteTextTrack(i)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Gs(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?ya(0,0):ya()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){Jr.names.forEach(e=>{const t=Jr[e],i=()=>{this.trigger(`${e}trackchange`)},n=this[t.getterName]();n.addEventListener("removetrack",i),n.addEventListener("addtrack",i),this.on("dispose",()=>{n.removeEventListener("removetrack",i),n.removeEventListener("addtrack",i)})})}addWebVttScript_(){if(!ye.WebVTT)if(bt.body.contains(this.el())){if(!this.options_["vtt.js"]&&jc(I2)&&Object.keys(I2).length>0){this.trigger("vttjsloaded");return}const e=bt.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),ye.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),i=u=>e.addTrack(u.track),n=u=>e.removeTrack(u.track);t.on("addtrack",i),t.on("removetrack",n),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),a=()=>{r();for(let u=0;u<e.length;u++){const c=e[u];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};a(),e.addEventListener("change",a),e.addEventListener("addtrack",a),e.addEventListener("removetrack",a),this.on("dispose",function(){t.off("addtrack",i),t.off("removetrack",n),e.removeEventListener("change",a),e.removeEventListener("addtrack",a),e.removeEventListener("removetrack",a);for(let u=0;u<e.length;u++)e[u].removeEventListener("cuechange",r)})}addTextTrack(e,t,i){if(!e)throw new Error("TextTrack kind is required but was not provided");return mB(this,e,t,i)}createRemoteTextTrack(e){const t=gs(e,{tech:this});return new Vc.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const i=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(i.track)),i}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=ea();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return bi.canPlayType(e.type)}static isTech(e){return e.prototype instanceof bi||e instanceof bi||e===bi}static registerTech(e,t){if(bi.techs_||(bi.techs_={}),!bi.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!bi.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!bi.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=Qs(e),bi.techs_[e]=t,bi.techs_[wh(e)]=t,e!=="Tech"&&bi.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(bi.techs_&&bi.techs_[e])return bi.techs_[e];if(e=Qs(e),ye&&ye.videojs&&ye.videojs[e])return wi.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),ye.videojs[e]}}}tr.names.forEach(function(s){const e=tr[s];bi.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});bi.prototype.featuresVolumeControl=!0;bi.prototype.featuresMuteControl=!0;bi.prototype.featuresFullscreenResize=!1;bi.prototype.featuresPlaybackRate=!1;bi.prototype.featuresProgressEvents=!1;bi.prototype.featuresSourceset=!1;bi.prototype.featuresTimeupdateEvents=!1;bi.prototype.featuresNativeTextTracks=!1;bi.prototype.featuresVideoFrameCallback=!1;bi.withSourceHandlers=function(s){s.registerSourceHandler=function(t,i){let n=s.sourceHandlers;n||(n=s.sourceHandlers=[]),i===void 0&&(i=n.length),n.splice(i,0,t)},s.canPlayType=function(t){const i=s.sourceHandlers||[];let n;for(let r=0;r<i.length;r++)if(n=i[r].canPlayType(t),n)return n;return""},s.selectSourceHandler=function(t,i){const n=s.sourceHandlers||[];let r;for(let a=0;a<n.length;a++)if(r=n[a].canHandleSource(t,i),r)return n[a];return null},s.canPlaySource=function(t,i){const n=s.selectSourceHandler(t,i);return n?n.canHandleSource(t,i):""},["seekable","seeking","duration"].forEach(function(t){const i=this[t];typeof i=="function"&&(this[t]=function(){return this.sourceHandler_&&this.sourceHandler_[t]?this.sourceHandler_[t].apply(this.sourceHandler_,arguments):i.apply(this,arguments)})},s.prototype),s.prototype.setSource=function(t){let i=s.selectSourceHandler(t,this.options_);i||(s.nativeSourceHandler?i=s.nativeSourceHandler:wi.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),i!==s.nativeSourceHandler&&(this.currentSource_=t),this.sourceHandler_=i.handleSource(t,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},s.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};st.registerComponent("Tech",bi);bi.registerTech("Tech",bi);bi.defaultTechOrder_=[];const yu={},L0={},R0={};function pB(s,e){yu[s]=yu[s]||[],yu[s].push(e)}function gB(s,e,t){s.setTimeout(()=>ou(e,yu[e.type],t,s),1)}function yB(s,e){s.forEach(t=>t.setTech&&t.setTech(e))}function vB(s,e,t){return s.reduceRight(Mb(t),e[t]())}function xB(s,e,t,i){return e[t](s.reduce(Mb(t),i))}function uE(s,e,t,i=null){const n="call"+Qs(t),r=s.reduce(Mb(n),i),a=r===R0,u=a?null:e[t](r);return SB(s,t,u,a),u}const bB={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},TB={setCurrentTime:1,setMuted:1,setVolume:1},cE={play:1,pause:1};function Mb(s){return(e,t)=>e===R0?R0:t[s]?t[s](e):e}function SB(s,e,t,i){for(let n=s.length-1;n>=0;n--){const r=s[n];r[e]&&r[e](i,t)}}function _B(s){L0.hasOwnProperty(s.id())&&delete L0[s.id()]}function EB(s,e){const t=L0[s.id()];let i=null;if(t==null)return i=e(s),L0[s.id()]=[[e,i]],i;for(let n=0;n<t.length;n++){const[r,a]=t[n];r===e&&(i=a)}return i===null&&(i=e(s),t.push([e,i])),i}function ou(s={},e=[],t,i,n=[],r=!1){const[a,...u]=e;if(typeof a=="string")ou(s,yu[a],t,i,n,r);else if(a){const c=EB(i,a);if(!c.setSource)return n.push(c),ou(s,u,t,i,n,r);c.setSource(Object.assign({},s),function(d,f){if(d)return ou(s,u,t,i,n,r);n.push(c),ou(f,s.type===f.type?u:yu[f.type],t,i,n,r)})}else u.length?ou(s,u,t,i,n,r):r?t(s,n):ou(s,yu["*"],t,i,n,!0)}const wB={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},I0=function(s=""){const e=Ob(s);return wB[e.toLowerCase()]||""},AB=(s,e)=>{if(!e)return"";if(s.cache_.source.src===e&&s.cache_.source.type)return s.cache_.source.type;const t=s.cache_.sources.filter(n=>n.src===e);if(t.length)return t[0].type;const i=s.$$("source");for(let n=0;n<i.length;n++){const r=i[n];if(r.type&&r.src&&r.src===e)return r.type}return I0(e)},vC=function(s){if(Array.isArray(s)){let e=[];s.forEach(function(t){t=vC(t),Array.isArray(t)?e=e.concat(t):Wa(t)&&e.push(t)}),s=e}else typeof s=="string"&&s.trim()?s=[dE({src:s})]:Wa(s)&&typeof s.src=="string"&&s.src&&s.src.trim()?s=[dE(s)]:s=[];return s};function dE(s){if(!s.type){const e=I0(s.src);e&&(s.type=e)}return s}var kB=`<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol viewBox="0 0 48 48" id="vjs-icon-play">
<path d="M16 10v28l22-14z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-pause">
<path d="M12 38h8V10h-8v28zm16-28v28h8V10h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-audio">
<path d="M24 2C14.06 2 6 10.06 6 20v14c0 3.31 2.69 6 6 6h6V24h-8v-4c0-7.73 6.27-14 14-14s14 6.27 14 14v4h-8v16h6c3.31 0 6-2.69 6-6V20c0-9.94-8.06-18-18-18z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-captions">
<path d="M38 8H10c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM22 22h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2zm14 0h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-subtitles">
<path d="M40 8H8c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM8 24h8v4H8v-4zm20 12H8v-4h20v4zm12 0h-8v-4h8v4zm0-8H20v-4h20v4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-enter">
<path d="M14 28h-4v10h10v-4h-6v-6zm-4-8h4v-6h6v-4H10v10zm24 14h-6v4h10V28h-4v6zm-6-24v4h6v6h4V10H28z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-exit">
<path d="M10 32h6v6h4V28H10v4zm6-16h-6v4h10V10h-4v6zm12 22h4v-6h6v-4H28v10zm4-22v-6h-4v10h10v-4h-6z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-play-circle">
<path d="M20 33l12-9-12-9v18zm4-29C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-mute">
<path d="M33 24c0-3.53-2.04-6.58-5-8.05v4.42l4.91 4.91c.06-.42.09-.85.09-1.28zm5 0c0 1.88-.41 3.65-1.08 5.28l3.03 3.03C41.25 29.82 42 27 42 24c0-8.56-5.99-15.72-14-17.54v4.13c5.78 1.72 10 7.07 10 13.41zM8.55 6L6 8.55 15.45 18H6v12h8l10 10V26.55l8.51 8.51c-1.34 1.03-2.85 1.86-4.51 2.36v4.13a17.94 17.94 0 0 0 7.37-3.62L39.45 42 42 39.45l-18-18L8.55 6zM24 8l-4.18 4.18L24 16.36V8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-low">
<path d="M14 18v12h8l10 10V8L22 18h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-medium">
<path d="M37 24c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zm-27-6v12h8l10 10V8L18 18h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-high">
<path d="M6 18v12h8l10 10V8L14 18H6zm27 6c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zM28 6.46v4.13c5.78 1.72 10 7.07 10 13.41s-4.22 11.69-10 13.41v4.13c8.01-1.82 14-8.97 14-17.54S36.01 8.28 28 6.46z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-spinner">
<path d="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64 4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77 18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44 24c0-1.37-.14-2.71-.4-4zm-26.53 4l-7.8-13.5C6.01 14.06 4 18.79 4 24c0 1.37.14 2.71.4 4h14.98l-2.31-4zM4.92 30c1.84 5.85 6.3 10.52 11.99 12.68L24.23 30H4.92zm22.54 0l-7.8 13.51c1.4.31 2.85.49 4.34.49 4.8 0 9.19-1.69 12.64-4.51L29.31 26.8 27.46 30z"></path>
</symbol>
<symbol viewBox="0 0 24 24" id="vjs-icon-hd">
<path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm2-6h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1h-4V9zm1.5 4.5h2v-3h-2v3z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-chapters">
<path d="M6 26h4v-4H6v4zm0 8h4v-4H6v4zm0-16h4v-4H6v4zm8 8h28v-4H14v4zm0 8h28v-4H14v4zm0-20v4h28v-4H14z"></path>
</symbol>
<symbol viewBox="0 0 40 40" id="vjs-icon-downloading">
<path d="M18.208 36.875q-3.208-.292-5.979-1.729-2.771-1.438-4.812-3.729-2.042-2.292-3.188-5.229-1.146-2.938-1.146-6.23 0-6.583 4.334-11.416 4.333-4.834 10.833-5.5v3.166q-5.167.75-8.583 4.646Q6.25 14.75 6.25 19.958q0 5.209 3.396 9.104 3.396 3.896 8.562 4.646zM20 28.417L11.542 20l2.083-2.083 4.917 4.916v-11.25h2.916v11.25l4.875-4.916L28.417 20zm1.792 8.458v-3.167q1.833-.25 3.541-.958 1.709-.708 3.167-1.875l2.333 2.292q-1.958 1.583-4.25 2.541-2.291.959-4.791 1.167zm6.791-27.792q-1.541-1.125-3.25-1.854-1.708-.729-3.541-1.021V3.042q2.5.25 4.77 1.208 2.271.958 4.271 2.5zm4.584 21.584l-2.25-2.25q1.166-1.5 1.854-3.209.687-1.708.937-3.541h3.209q-.292 2.5-1.229 4.791-.938 2.292-2.521 4.209zm.541-12.417q-.291-1.833-.958-3.562-.667-1.73-1.833-3.188l2.375-2.208q1.541 1.916 2.458 4.208.917 2.292 1.167 4.75z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download">
<path d="M10.8 40.55q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h26.35v-7.7h3.4v7.7q0 1.4-1 2.4t-2.4 1zM24 32.1L13.9 22.05l2.45-2.45 5.95 5.95V7.15h3.4v18.4l5.95-5.95 2.45 2.45z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download-done">
<path d="M9.8 40.5v-3.45h28.4v3.45zm9.2-9.05L7.4 19.85l2.45-2.35L19 26.65l19.2-19.2 2.4 2.4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download-off">
<path d="M4.9 4.75L43.25 43.1 41 45.3l-4.75-4.75q-.05.05-.075.025-.025-.025-.075-.025H10.8q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h22.05l-7-7-1.85 1.8L13.9 21.9l1.85-1.85L2.7 7zm26.75 14.7l2.45 2.45-3.75 3.8-2.45-2.5zM25.7 7.15V21.1l-3.4-3.45V7.15z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-share">
<path d="M36 32.17c-1.52 0-2.89.59-3.93 1.54L17.82 25.4c.11-.45.18-.92.18-1.4s-.07-.95-.18-1.4l14.1-8.23c1.07 1 2.5 1.62 4.08 1.62 3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6c0 .48.07.95.18 1.4l-14.1 8.23c-1.07-1-2.5-1.62-4.08-1.62-3.31 0-6 2.69-6 6s2.69 6 6 6c1.58 0 3.01-.62 4.08-1.62l14.25 8.31c-.1.42-.16.86-.16 1.31A5.83 5.83 0 1 0 36 32.17z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cog">
<path d="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3a14.8 14.8 0 0 0-3.38 1.97L9.9 10.1a1 1 0 0 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3a14.8 14.8 0 0 0 3.38-1.97l4.98 2.01a1 1 0 0 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-square">
<path d="M36 8H12c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zm0 28H12V12h24v24z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle">
<circle cx="24" cy="24" r="20"></circle>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle-outline">
<path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle-inner-circle">
<path d="M24 4C12.97 4 4 12.97 4 24s8.97 20 20 20 20-8.97 20-20S35.03 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm6-16c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6 6 2.69 6 6z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cancel">
<path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm10 27.17L31.17 34 24 26.83 16.83 34 14 31.17 21.17 24 14 16.83 16.83 14 24 21.17 31.17 14 34 16.83 26.83 24 34 31.17z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-replay">
<path d="M24 10V2L14 12l10 10v-8c6.63 0 12 5.37 12 12s-5.37 12-12 12-12-5.37-12-12H8c0 8.84 7.16 16 16 16s16-7.16 16-16-7.16-16-16-16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-repeat">
<path d="M14 14h20v6l8-8-8-8v6H10v12h4v-8zm20 20H14v-6l-8 8 8 8v-6h24V26h-4v8z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-5">
<path d="M17.689 98l-8.697 8.696 8.697 8.697 2.486-2.485-4.32-4.319h1.302c4.93 0 9.071 1.722 12.424 5.165 3.352 3.443 5.029 7.638 5.029 12.584h3.55c0-2.958-.553-5.73-1.658-8.313-1.104-2.583-2.622-4.841-4.555-6.774-1.932-1.932-4.19-3.45-6.773-4.555-2.584-1.104-5.355-1.657-8.313-1.657H15.5l4.615-4.615zm-8.08 21.659v13.861h11.357v5.008H9.609V143h12.7c.834 0 1.55-.298 2.146-.894.596-.597.895-1.31.895-2.145v-7.781c0-.835-.299-1.55-.895-2.147a2.929 2.929 0 0 0-2.147-.894h-8.227v-5.096H25.35v-4.384z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-10">
<path d="M42.315 125.63c0-4.997-1.694-9.235-5.08-12.713-3.388-3.479-7.571-5.218-12.552-5.218h-1.315l4.363 4.363-2.51 2.51-8.787-8.786L25.221 97l2.45 2.45-4.662 4.663h1.375c2.988 0 5.788.557 8.397 1.673 2.61 1.116 4.892 2.65 6.844 4.602 1.953 1.953 3.487 4.234 4.602 6.844 1.116 2.61 1.674 5.41 1.674 8.398zM8.183 142v-19.657H3.176V117.8h9.643V142zm13.63 0c-1.156 0-2.127-.393-2.912-1.178-.778-.778-1.168-1.746-1.168-2.902v-16.04c0-1.156.393-2.127 1.178-2.912.779-.779 1.746-1.168 2.902-1.168h7.696c1.156 0 2.126.392 2.911 1.177.779.78 1.168 1.747 1.168 2.903v16.04c0 1.156-.392 2.127-1.177 2.912-.779.779-1.746 1.168-2.902 1.168zm.556-4.636h6.583v-15.02H22.37z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-30">
<path d="M26.047 97l-8.733 8.732 8.733 8.733 2.496-2.494-4.336-4.338h1.307c4.95 0 9.108 1.73 12.474 5.187 3.367 3.458 5.051 7.668 5.051 12.635h3.565c0-2.97-.556-5.751-1.665-8.346-1.109-2.594-2.633-4.862-4.574-6.802-1.94-1.941-4.208-3.466-6.803-4.575-2.594-1.109-5.375-1.664-8.345-1.664H23.85l4.634-4.634zM2.555 117.531v4.688h10.297v5.25H5.873v4.687h6.979v5.156H2.555V142H13.36c1.061 0 1.95-.395 2.668-1.186.718-.79 1.076-1.772 1.076-2.94v-16.218c0-1.168-.358-2.149-1.076-2.94-.717-.79-1.607-1.185-2.668-1.185zm22.482.14c-1.149 0-2.11.39-2.885 1.165-.78.78-1.172 1.744-1.172 2.893v15.943c0 1.149.388 2.11 1.163 2.885.78.78 1.745 1.172 2.894 1.172h7.649c1.148 0 2.11-.388 2.884-1.163.78-.78 1.17-1.745 1.17-2.894v-15.943c0-1.15-.386-2.111-1.16-2.885-.78-.78-1.746-1.172-2.894-1.172zm.553 4.518h6.545v14.93H25.59z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-5">
<path d="M29.508 97l-2.431 2.43 4.625 4.625h-1.364c-2.965 0-5.742.554-8.332 1.66-2.589 1.107-4.851 2.629-6.788 4.566-1.937 1.937-3.458 4.2-4.565 6.788-1.107 2.59-1.66 5.367-1.66 8.331h3.557c0-4.957 1.68-9.16 5.04-12.611 3.36-3.45 7.51-5.177 12.451-5.177h1.304l-4.326 4.33 2.49 2.49 8.715-8.716zm-9.783 21.61v13.89h11.382v5.018H19.725V142h12.727a2.93 2.93 0 0 0 2.15-.896 2.93 2.93 0 0 0 .896-2.15v-7.798c0-.837-.299-1.554-.896-2.152a2.93 2.93 0 0 0-2.15-.896h-8.245V123h11.29v-4.392z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-10">
<path d="M23.119 97l-2.386 2.383 4.538 4.538h-1.339c-2.908 0-5.633.543-8.173 1.63-2.54 1.085-4.76 2.577-6.66 4.478-1.9 1.9-3.392 4.12-4.478 6.66-1.085 2.54-1.629 5.264-1.629 8.172h3.49c0-4.863 1.648-8.986 4.944-12.372 3.297-3.385 7.368-5.078 12.216-5.078h1.279l-4.245 4.247 2.443 2.442 8.55-8.55zm-9.52 21.45v4.42h4.871V142h4.513v-23.55zm18.136 0c-1.125 0-2.066.377-2.824 1.135-.764.764-1.148 1.709-1.148 2.834v15.612c0 1.124.38 2.066 1.139 2.824.764.764 1.708 1.145 2.833 1.145h7.489c1.125 0 2.066-.378 2.824-1.136.764-.764 1.145-1.709 1.145-2.833v-15.612c0-1.125-.378-2.067-1.136-2.825-.764-.764-1.708-1.145-2.833-1.145zm.54 4.42h6.408v14.617h-6.407z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-30">
<path d="M25.549 97l-2.437 2.434 4.634 4.635H26.38c-2.97 0-5.753.555-8.347 1.664-2.594 1.109-4.861 2.633-6.802 4.574-1.94 1.94-3.465 4.207-4.574 6.802-1.109 2.594-1.664 5.377-1.664 8.347h3.565c0-4.967 1.683-9.178 5.05-12.636 3.366-3.458 7.525-5.187 12.475-5.187h1.307l-4.335 4.338 2.495 2.494 8.732-8.732zm-11.553 20.53v4.689h10.297v5.249h-6.978v4.688h6.978v5.156H13.996V142h10.808c1.06 0 1.948-.395 2.666-1.186.718-.79 1.077-1.771 1.077-2.94v-16.217c0-1.169-.36-2.15-1.077-2.94-.718-.79-1.605-1.186-2.666-1.186zm21.174.168c-1.149 0-2.11.389-2.884 1.163-.78.78-1.172 1.745-1.172 2.894v15.942c0 1.15.388 2.11 1.162 2.885.78.78 1.745 1.17 2.894 1.17h7.649c1.149 0 2.11-.386 2.885-1.16.78-.78 1.17-1.746 1.17-2.895v-15.942c0-1.15-.387-2.11-1.161-2.885-.78-.78-1.745-1.172-2.894-1.172zm.552 4.516h6.542v14.931h-6.542z"></path>
</symbol>
<symbol viewBox="0 0 512 512" id="vjs-icon-audio-description">
<g fill-rule="evenodd"><path d="M227.29 381.351V162.993c50.38-1.017 89.108-3.028 117.631 17.126 27.374 19.342 48.734 56.965 44.89 105.325-4.067 51.155-41.335 94.139-89.776 98.475-24.085 2.155-71.972 0-71.972 0s-.84-1.352-.773-2.568m48.755-54.804c31.43 1.26 53.208-16.633 56.495-45.386 4.403-38.51-21.188-63.552-58.041-60.796v103.612c-.036 1.466.575 2.22 1.546 2.57"></path><path d="M383.78 381.328c13.336 3.71 17.387-11.06 23.215-21.408 12.722-22.571 22.294-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.226 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M425.154 381.328c13.336 3.71 17.384-11.061 23.215-21.408 12.721-22.571 22.291-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.511c-.586 3.874 2.226 7.315 3.866 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M466.26 381.328c13.337 3.71 17.385-11.061 23.216-21.408 12.722-22.571 22.292-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.225 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894M4.477 383.005H72.58l18.573-28.484 64.169-.135s.065 19.413.065 28.62h48.756V160.307h-58.816c-5.653 9.537-140.85 222.697-140.85 222.697zm152.667-145.282v71.158l-40.453-.27 40.453-70.888z"></path></g>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-next-item">
<path d="M12 36l17-12-17-12v24zm20-24v24h4V12h-4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-previous-item">
<path d="M12 12h4v24h-4zm7 12l17 12V12z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-shuffle">
<path d="M21.17 18.34L10.83 8 8 10.83l10.34 10.34 2.83-2.83zM29 8l4.09 4.09L8 37.17 10.83 40l25.09-25.09L40 19V8H29zm.66 18.83l-2.83 2.83 6.26 6.26L29 40h11V29l-4.09 4.09-6.25-6.26z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cast">
<path d="M42 6H6c-2.21 0-4 1.79-4 4v6h4v-6h36v28H28v4h14c2.21 0 4-1.79 4-4V10c0-2.21-1.79-4-4-4zM2 36v6h6c0-3.31-2.69-6-6-6zm0-8v4c5.52 0 10 4.48 10 10h4c0-7.73-6.27-14-14-14zm0-8v4c9.94 0 18 8.06 18 18h4c0-12.15-9.85-22-22-22z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-picture-in-picture-enter">
<path d="M38 22H22v11.99h16V22zm8 16V9.96C46 7.76 44.2 6 42 6H6C3.8 6 2 7.76 2 9.96V38c0 2.2 1.8 4 4 4h36c2.2 0 4-1.8 4-4zm-4 .04H6V9.94h36v28.1z"></path>
</symbol>
<symbol viewBox="0 0 22 18" id="vjs-icon-picture-in-picture-exit">
<path d="M18 4H4v10h14V4zm4 12V1.98C22 .88 21.1 0 20 0H2C.9 0 0 .88 0 1.98V16c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H2V1.97h18v14.05z"></path>
<path fill="none" d="M-1-3h24v24H-1z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-facebook">
<path d="M1343 12v264h-157q-86 0-116 36t-30 108v189h293l-39 296h-254v759H734V905H479V609h255V391q0-186 104-288.5T1115 0q147 0 228 12z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-linkedin">
<path d="M477 625v991H147V625h330zm21-306q1 73-50.5 122T312 490h-2q-82 0-132-49t-50-122q0-74 51.5-122.5T314 148t133 48.5T498 319zm1166 729v568h-329v-530q0-105-40.5-164.5T1168 862q-63 0-105.5 34.5T999 982q-11 30-11 81v553H659q2-399 2-647t-1-296l-1-48h329v144h-2q20-32 41-56t56.5-52 87-43.5T1285 602q171 0 275 113.5t104 332.5z"></path>
</symbol>
<symbol viewBox="0 0 1200 1227" id="vjs-icon-twitter">
<path d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"/>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-tumblr">
<path d="M1328 1329l80 237q-23 35-111 66t-177 32q-104 2-190.5-26T787 1564t-95-106-55.5-120-16.5-118V676H452V461q72-26 129-69.5t91-90 58-102 34-99T779 12q1-5 4.5-8.5T791 0h244v424h333v252h-334v518q0 30 6.5 56t22.5 52.5 49.5 41.5 81.5 14q78-2 134-29z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-pinterest">
<path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
</symbol>
</defs>
</svg>`;const hE=w0?10009:A0?461:8,sc={codes:{play:415,pause:19,ff:417,rw:412,back:hE},names:{415:"play",19:"pause",417:"ff",412:"rw",[hE]:"back"},isEventKey(s,e){return e=e.toLowerCase(),!!(this.names[s.keyCode]&&this.names[s.keyCode]===e)},getEventName(s){if(this.names[s.keyCode])return this.names[s.keyCode];if(this.codes[s.code]){const e=this.codes[s.code];return this.names[e]}return null}},fE=5;class CB extends Vr{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const i=t.key.substring(5).toLowerCase();this.move(i)}else if(sc.isEventKey(t,"play")||sc.isEventKey(t,"pause")||sc.isEventKey(t,"ff")||sc.isEventKey(t,"rw")){t.preventDefault();const i=sc.getEventName(t);this.performMediaAction_(i)}else sc.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+fE);break;case"rw":this.userSeek_(this.player_.currentTime()-fE);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let i=null;const n=this.getCurrentComponent(e.target);t&&(i=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!i||!t)&&(n&&n.name()==="CloseButton"?this.refocusComponent():(this.pause(),n&&n.el()&&(this.lastFocusedComponent_=n)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function i(n){for(const r of n)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&i(r.children_)}return e.children_.forEach(n=>{if(n.hasOwnProperty("el_"))if(n.getIsFocusable&&n.getIsAvailableToBeFocused&&n.getIsFocusable()&&n.getIsAvailableToBeFocused(n.el())){t.push(n);return}else n.hasOwnProperty("children_")&&n.children_.length>0?i(n.children_):n.hasOwnProperty("items")&&n.items.length>0?i(n.items):this.findSuitableDOMChild(n)&&t.push(n);if(n.name_==="ErrorDisplay"&&n.opened_){const r=n.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((u,c)=>{t.push({name:()=>"ModalButton"+(c+1),el:()=>u,getPositions:()=>{const d=u.getBoundingClientRect(),f={x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left},g={x:d.left+d.width/2,y:d.top+d.height/2,width:0,height:0,top:d.top+d.height/2,right:d.left+d.width/2,bottom:d.top+d.height/2,left:d.left+d.width/2};return{boundingClientRect:f,center:g}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:d=>!0,focus:()=>u.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(i){if(e.getIsFocusable(i)&&e.getIsAvailableToBeFocused(i))return i;for(let n=0;n<i.children.length;n++){const r=i.children[n],a=t(r);if(a)return a}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const i of this.focusableComponents)if(i.el()===t)return i}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const i=t.getPositions(),n=this.focusableComponents.filter(a=>a!==t&&this.isInDirection_(i.boundingClientRect,a.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(i.center,n,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,i){let n=1/0,r=null;for(const a of t){const u=a.getPositions().center,c=this.calculateDistance_(e,u,i);c<n&&(n=c,r=a)}return r}isInDirection_(e,t,i){switch(i){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,i){const n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let a;switch(i){case"right":case"left":a=n+r*100;break;case"up":a=r*2+n*.5;break;case"down":a=r*5+n;break;default:a=n+r}return a}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class DB extends st{constructor(e,t,i){const n=gs({createEl:!1},t);if(super(e,n,i),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,a=t.playerOptions.techOrder;r<a.length;r++){const u=Qs(a[r]);let c=bi.getTech(u);if(u||(c=st.getComponent(u)),c&&c.isSupported()){e.loadTech_(u);break}}else e.src(t.playerOptions.sources)}}st.registerComponent("MediaLoader",DB);class Cp extends st{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=i=>this.handleMouseOver(i),this.handleMouseOut_=i=>this.handleMouseOut(i),this.handleClick_=i=>this.handleClick(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.emitTapEvents(),this.enable()}createEl(e="div",t={},i={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&wi.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),i=Object.assign({role:"button"},i),this.tabIndex_=t.tabIndex;const n=ui(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(ui("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=ui("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const i=this.localize(e);this.controlText_=e,Il(this.controlTextEl_,i),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",i)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}st.registerComponent("ClickableComponent",Cp);class kx extends Cp{constructor(e,t){super(e,t),this.update(),this.update_=i=>this.update(i),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return ui("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(ui("picture",{className:"vjs-poster",tabIndex:-1},{},ui("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?$a(this.player_.play()):this.player_.pause())}}kx.prototype.crossorigin=kx.prototype.crossOrigin;st.registerComponent("PosterImage",kx);const Xr="#222",mE="#ccc",LB={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function mv(s,e){let t;if(s.length===4)t=s[1]+s[1]+s[2]+s[2]+s[3]+s[3];else if(s.length===7)t=s.slice(1);else throw new Error("Invalid color code provided, "+s+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function Na(s,e,t){try{s.style[e]=t}catch{return}}function pE(s){return s?`${s}px`:""}class RB extends st{constructor(e,t,i){super(e,t,i);const n=a=>this.updateDisplay(a),r=a=>{this.updateDisplayOverlay(),this.updateDisplay(a)};e.on("loadstart",a=>this.toggleDisplay(a)),e.on("useractive",n),e.on("userinactive",n),e.on("texttrackchange",n),e.on("loadedmetadata",a=>{this.updateDisplayOverlay(),this.preselectTrack(a)}),e.ready(Ls(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const a=ye.screen.orientation||ye,u=ye.screen.orientation?"change":"orientationchange";a.addEventListener(u,r),e.on("dispose",()=>a.removeEventListener(u,r));const c=this.options_.playerOptions.tracks||[];for(let d=0;d<c.length;d++)this.player_.addRemoteTextTrack(c[d],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),i=this.player_.cache_.selectedLanguage;let n,r,a;for(let u=0;u<t.length;u++){const c=t[u];i&&i.enabled&&i.language&&i.language===c.language&&c.kind in e?c.kind===i.kind?a=c:a||(a=c):i&&!i.enabled?(a=null,n=null,r=null):c.default&&(c.kind==="descriptions"&&!n?n=c:c.kind in e&&!r&&(r=c))}a?a.mode="showing":r?r.mode="showing":n&&(n.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof ye.WebVTT=="function"&&ye.WebVTT.processCues(ye,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const a=[];for(let u=0;u<e.length;++u){const c=e[u];c.mode==="showing"&&a.push(c)}this.updateForTrack(a);return}let i=null,n=null,r=e.length;for(;r--;){const a=e[r];a.mode==="showing"&&(a.kind==="descriptions"?i=a:n=a)}if(n?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(n)):i&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(i)),!ye.CSS.supports("inset","10px")){const a=this.el_,u=a.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,d=this.player_.el_.getBoundingClientRect().height;a.style="",Na(a,"position","relative"),Na(a,"height",d-c+"px"),Na(a,"top","unset"),k0?Na(a,"bottom",d+"px"):Na(a,"bottom","0px"),u.length>0&&u.forEach(f=>{if(f.style.inset){const g=f.style.inset.split(" ");g.length===3&&Object.assign(f.style,{top:g[0],right:g[1],bottom:g[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!ye.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),i=e/t,n=this.player_.videoWidth()/this.player_.videoHeight();let r=0,a=0;Math.abs(i-n)>.1&&(i>n?r=Math.round((e-t*n)/2):a=Math.round((t-e/n)/2)),Na(this.el_,"insetInline",pE(r)),Na(this.el_,"insetBlock",pE(a))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),i=e.activeCues;let n=i.length;for(;n--;){const r=i[n];if(!r)continue;const a=r.displayState;if(t.color&&(a.firstChild.style.color=t.color),t.textOpacity&&Na(a.firstChild,"color",mv(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(a.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Na(a.firstChild,"backgroundColor",mv(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Na(a,"backgroundColor",mv(t.windowColor,t.windowOpacity)):a.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?a.firstChild.style.textShadow=`2px 2px 3px ${Xr}, 2px 2px 4px ${Xr}, 2px 2px 5px ${Xr}`:t.edgeStyle==="raised"?a.firstChild.style.textShadow=`1px 1px ${Xr}, 2px 2px ${Xr}, 3px 3px ${Xr}`:t.edgeStyle==="depressed"?a.firstChild.style.textShadow=`1px 1px ${mE}, 0 1px ${mE}, -1px -1px ${Xr}, 0 -1px ${Xr}`:t.edgeStyle==="uniform"&&(a.firstChild.style.textShadow=`0 0 4px ${Xr}, 0 0 4px ${Xr}, 0 0 4px ${Xr}, 0 0 4px ${Xr}`)),t.fontPercent&&t.fontPercent!==1){const u=ye.parseFloat(a.style.fontSize);a.style.fontSize=u*t.fontPercent+"px",a.style.height="auto",a.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?a.firstChild.style.fontVariant="small-caps":a.firstChild.style.fontFamily=LB[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof ye.WebVTT!="function"||e.every(i=>!i.activeCues))return;const t=[];for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r)t.push(n.activeCues[r])}ye.WebVTT.processCues(ye,t,this.el_);for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r){const a=n.activeCues[r].displayState;gu(a,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:i)),n.language&&$c(a,"lang",n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}st.registerComponent("TextTrackDisplay",RB);class IB extends st{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),i=ui("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),n=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return n.appendChild(i),n}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}st.registerComponent("LoadingSpinner",IB);class Xn extends Cp{createEl(e,t={},i={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i);const n=ui(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(ui("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}addChild(e,t={}){const i=this.constructor.name;return wi.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),st.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}st.registerComponent("Button",Xn);class xC extends Xn{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",i=>this.handleMouseDown(i))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(e.type==="tap"||this.mouseused_&&"clientX"in e&&"clientY"in e){$a(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const i=this.player_.getChild("controlBar"),n=i&&i.getChild("playToggle");if(!n){this.player_.tech(!0).focus();return}const r=()=>n.focus();Ah(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}xC.prototype.controlText_="Play Video";st.registerComponent("BigPlayButton",xC);class NB extends Xn{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}st.registerComponent("CloseButton",NB);class bC extends Xn{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",i=>this.handlePlay(i)),this.on(e,"pause",i=>this.handlePause(i)),t.replay&&this.on(e,"ended",i=>this.handleEnded(i))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?$a(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}bC.prototype.controlText_="Play";st.registerComponent("PlayToggle",bC);class Zc extends st{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],i=>this.update(i)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),i=ui("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(i),this.contentEl_=ui("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=Eu(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,wi.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=bt.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}Zc.prototype.labelText_="Time";Zc.prototype.controlText_="Time";st.registerComponent("TimeDisplay",Zc);class Pb extends Zc{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():e&&e.target&&typeof e.target.pendingSeekTime=="function"?t=e.target.pendingSeekTime():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Pb.prototype.labelText_="Current Time";Pb.prototype.controlText_="Current Time";st.registerComponent("CurrentTimeDisplay",Pb);class Bb extends Zc{constructor(e,t){super(e,t);const i=n=>this.updateContent(n);this.on(e,"durationchange",i),this.on(e,"loadstart",i),this.on(e,"loadedmetadata",i)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}}Bb.prototype.labelText_="Duration";Bb.prototype.controlText_="Duration";st.registerComponent("DurationDisplay",Bb);class OB extends st{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),i=super.createEl("span",{textContent:"/"});return t.appendChild(i),e.appendChild(t),e}}st.registerComponent("TimeDivider",OB);class Fb extends Zc{constructor(e,t){super(e,t),this.on(e,"durationchange",i=>this.updateContent(i))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(ui("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}Fb.prototype.labelText_="Remaining Time";Fb.prototype.controlText_="Remaining Time";st.registerComponent("RemainingTimeDisplay",Fb);class MB extends st{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",i=>this.updateShowing(i))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=ui("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(ui("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(bt.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}st.registerComponent("LiveDisplay",MB);class TC extends Xn{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=i=>this.updateLiveEdgeStatus(i),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=ui("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}TC.prototype.controlText_="Seek to live, currently playing live";st.registerComponent("SeekToLive",TC);function Zh(s,e,t){return s=Number(s),Math.min(t,Math.max(e,isNaN(s)?e:s))}var PB=Object.freeze({__proto__:null,clamp:Zh});class Ub extends st{constructor(e,t){super(e,t),this.handleMouseDown_=i=>this.handleMouseDown(i),this.handleMouseUp_=i=>this.handleMouseUp(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.handleClick_=i=>this.handleClick(i),this.handleMouseMove_=i=>this.handleMouseMove(i),this.update_=i=>this.update(i),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},i={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),i=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},i),super.createEl(e,t,i)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!Ya&&e.preventDefault(),Kk(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;Wk(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(Zh(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Sp(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,i=t&&t.enabled,n=t&&t.horizontalSeek;i?n&&e.key==="ArrowLeft"||!n&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):n&&e.key==="ArrowRight"||!n&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(this.pendingSeekTime()&&(this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime())),super.handleKeyDown(e)):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}st.registerComponent("Slider",Ub);const pv=(s,e)=>Zh(s/e*100,0,100).toFixed(2)+"%";class BB extends st{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",i=>this.update(i))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=ui("span",{className:"vjs-control-text"}),i=ui("span",{textContent:this.localize("Loaded")}),n=bt.createTextNode(": ");return this.percentageEl_=ui("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(i),t.appendChild(n),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,i=this.player_.buffered(),n=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),a=this.partEls_,u=pv(r,n);this.percent_!==u&&(this.el_.style.width=u,Il(this.percentageEl_,u),this.percent_=u);for(let c=0;c<i.length;c++){const d=i.start(c),f=i.end(c);let g=a[c];g||(g=this.el_.appendChild(ui()),a[c]=g),!(g.dataset.start===d&&g.dataset.end===f)&&(g.dataset.start=d,g.dataset.end=f,g.style.left=pv(d,r),g.style.width=pv(f-d,r))}for(let c=a.length;c>i.length;c--)this.el_.removeChild(a[c-1]);a.length=i.length})}}st.registerComponent("LoadProgressBar",BB);class FB extends st{constructor(e,t){super(e,t),this.update=Xa(Ls(this,this.update),ta)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,i){const n=Ph(this.el_),r=Hc(this.player_.el()),a=e.width*t;if(!r||!n)return;let u=e.left-r.left+a,c=e.width-a+(r.right-e.right);c||(c=e.width-a,u=a);let d=n.width/2;u<d?d+=d-u:c<d&&(d=c),d<0?d=0:d>n.width&&(d=n.width),d=Math.round(d),this.el_.style.right=`-${d}px`,this.write(i)}write(e){Il(this.el_,e)}updateTime(e,t,i,n){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const u=this.player_.liveTracker.liveWindow(),c=u-t*u;r=(c<1?"":"-")+Eu(c,u)}else r=Eu(i,a);this.update(e,t,r),n&&n()})}}st.registerComponent("TimeTooltip",FB);class jb extends st{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=Xa(Ls(this,this.update),ta)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t,i){const n=this.getChild("timeTooltip");if(!n)return;const r=i&&i.target&&typeof i.target.pendingSeekTime=="function"?i.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,r)}}jb.prototype.options_={children:[]};!Wn&&!va&&jb.prototype.options_.children.push("timeTooltip");st.registerComponent("PlayProgressBar",jb);class SC extends st{constructor(e,t){super(e,t),this.update=Xa(Ls(this,this.update),ta)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const i=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,i,()=>{this.el_.style.left=`${e.width*t}px`})}}SC.prototype.options_={children:["timeTooltip"]};st.registerComponent("MouseTimeDisplay",SC);class Dp extends Ub{constructor(e,t){t=gs(Dp.prototype.options_,t),t.children=[...t.children];const i=e.options_.disableSeekWhileScrubbingOnMobile&&(Wn||va)||e.options_.disableSeekWhileScrubbingOnSTV;(!Wn&&!va||i)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbing_=i,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=Ls(this,this.update),this.update=Xa(this.update_,ta),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in bt&&"visibilityState"in bt&&this.on(bt,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){bt.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,ta))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(bt.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const i=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),n=this.player_.liveTracker;let r=this.player_.duration();n&&n.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==i||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[Eu(i,r),Eu(r,r)],"{1} of {2}")),this.currentTime_=i,this.duration_=r),this.bar&&this.bar.update(Hc(this.el()),this.getProgress(),e)}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(e){if(e!==void 0)if(e!==null){const t=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(e,t))}else this.pendingSeekTime_=null;return this.pendingSeekTime_}getPercent(){if(this.pendingSeekTime()!==null)return this.pendingSeekTime()/this.player_.duration();const e=this.getCurrentTime_();let t;const i=this.player_.liveTracker;return i&&i.isLive()?(t=(e-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){Bh(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!Bh(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let i;const n=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())i=n*this.player_.duration(),i===this.player_.duration()&&(i=i-.1);else{if(n>=.99){r.seekToLiveEdge();return}const a=r.seekableStart(),u=r.liveCurrentTime();if(i=a+n*r.liveWindow(),i>=u&&(i=u),i<=a&&(i=a+.1),i===1/0)return}this.shouldDisableSeekWhileScrubbing_?this.pendingSeekTime(i):this.userSeek_(i),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?$a(this.player_.play()):this.update_()}handlePendingSeek_(e){this.player_.paused()||this.player_.pause();const t=this.pendingSeekTime()!==null?this.pendingSeekTime():this.player_.currentTime();this.pendingSeekTime(t+e),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}stepForward(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(this.options().stepSeconds):this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(-this.options().stepSeconds):this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(e){this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const i=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*i):this.userSeek_(this.player_.duration()*i)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in bt&&"visibilityState"in bt&&this.off(bt,"visibilitychange",this.toggleVisibility_),super.dispose()}}Dp.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12};st.registerComponent("SeekBar",Dp);class _C extends st{constructor(e,t){super(e,t),this.handleMouseMove=Xa(Ls(this,this.handleMouseMove),ta),this.throttledHandleMouseSeek=Xa(Ls(this,this.handleMouseSeek),ta),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.handleMouseDownHandler_=i=>this.handleMouseDown(i),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const i=t.getChild("playProgressBar"),n=t.getChild("mouseTimeDisplay");if(!i&&!n)return;const r=t.el(),a=Ph(r);let u=Sp(r,e).x;u=Zh(u,0,1),n&&n.update(a,u),i&&i.update(a,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&$a(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,i=this.getChild("seekBar");i&&i.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}_C.prototype.options_={children:["seekBar"]};st.registerComponent("ProgressControl",_C);class EC extends Xn{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],i=>this.handlePictureInPictureChange(i)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],i=>this.handlePictureInPictureEnabledChange(i)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){bt.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in ye?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof bt.exitPictureInPicture=="function"&&super.show()}}EC.prototype.controlText_="Picture-in-Picture";st.registerComponent("PictureInPictureToggle",EC);class wC extends Xn{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",i=>this.handleFullscreenChange(i)),bt[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}wC.prototype.controlText_="Fullscreen";st.registerComponent("FullscreenToggle",wC);const UB=function(s,e){e.tech_&&!e.tech_.featuresVolumeControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class jB extends st{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}st.registerComponent("VolumeLevel",jB);class $B extends st{constructor(e,t){super(e,t),this.update=Xa(Ls(this,this.update),ta)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,i,n){if(!i){const r=Hc(this.el_),a=Hc(this.player_.el()),u=e.width*t;if(!a||!r)return;const c=e.left-a.left+u,d=e.width-u+(a.right-e.right);let f=r.width/2;c<f?f+=f-c:d<f&&(f=d),f<0?f=0:f>r.width&&(f=r.width),this.el_.style.right=`-${f}px`}this.write(`${n}%`)}write(e){Il(this.el_,e)}updateVolume(e,t,i,n,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,i,n.toFixed(0)),r&&r()})}}st.registerComponent("VolumeLevelTooltip",$B);class AC extends st{constructor(e,t){super(e,t),this.update=Xa(Ls(this,this.update),ta)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,i){const n=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,i,n,()=>{i?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}AC.prototype.options_={children:["volumeLevelTooltip"]};st.registerComponent("MouseVolumeLevelDisplay",AC);class Lp extends Ub{constructor(e,t){super(e,t),this.on("slideractive",i=>this.updateLastVolume_(i)),this.on(e,"volumechange",i=>this.updateARIAAttributes(i)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){Bh(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const i=this.el(),n=Hc(i),r=this.vertical();let a=Sp(i,e);a=r?a.y:a.x,a=Zh(a,0,1),t.update(n,a,r)}Bh(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}Lp.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Wn&&!va&&Lp.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");Lp.prototype.playerEvent="volumechange";st.registerComponent("VolumeBar",Lp);class kC extends st{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||jc(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),UB(this,e),this.throttledHandleMouseMove=Xa(Ls(this,this.handleMouseMove),ta),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.on("mousedown",i=>this.handleMouseDown(i)),this.on("touchstart",i=>this.handleMouseDown(i)),this.on("mousemove",i=>this.handleMouseMove(i)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}kC.prototype.options_={children:["volumeBar"]};st.registerComponent("VolumeControl",kC);const HB=function(s,e){e.tech_&&!e.tech_.featuresMuteControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresMuteControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class CC extends Xn{constructor(e,t){super(e,t),HB(this,e),this.on(e,["loadstart","volumechange"],i=>this.update(i))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),i=this.player_.lastVolume_();if(t===0){const n=i<.1?.1:i;this.player_.volume(n),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),Wn&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),bp(this.el_,[0,1,2,3].reduce((i,n)=>i+`${n?" ":""}vjs-vol-${n}`,"")),gu(this.el_,`vjs-vol-${t}`)}updateControlText_(){const t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==t&&this.controlText(t)}}CC.prototype.controlText_="Mute";st.registerComponent("MuteToggle",CC);class DC extends st{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||jc(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=i=>this.handleKeyPress(i),this.on(e,["loadstart"],i=>this.volumePanelState_(i)),this.on(this.muteToggle,"keyup",i=>this.handleKeyPress(i)),this.on(this.volumeControl,"keyup",i=>this.handleVolumeControlKeyUp(i)),this.on("keydown",i=>this.handleKeyPress(i)),this.on("mouseover",i=>this.handleMouseOver(i)),this.on("mouseout",i=>this.handleMouseOut(i)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),zr(bt,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Yn(bt,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}DC.prototype.options_={children:["muteToggle","volumeControl"]};st.registerComponent("VolumePanel",DC);class LC extends Xn{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()?i.seekableEnd():this.player_.duration();let r;t+this.skipTime<=n?r=t+this.skipTime:r=n,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}LC.prototype.controlText_="Skip Forward";st.registerComponent("SkipForward",LC);class RC extends Xn{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()&&i.seekableStart();let r;n&&t-this.skipTime<=n?r=n:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}RC.prototype.controlText_="Skip Backward";st.registerComponent("SkipBackward",RC);class IC extends st{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",i=>this.handleKeyDown(i)),this.boundHandleBlur_=i=>this.handleBlur(i),this.boundHandleTapClick_=i=>this.handleTapClick(i)}addEventListenerForItem(e){e instanceof st&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof st&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=ui(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),zr(t,"click",function(i){i.preventDefault(),i.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||bt.activeElement;if(!this.children().some(i=>i.el()===t)){const i=this.menuButton_;i&&i.buttonPressed_&&t!==i.el().firstChild&&i.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const i=t.filter(n=>n.el()===e.target)[0];if(!i)return;i.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}st.registerComponent("Menu",IC);class $b extends st{constructor(e,t={}){super(e,t),this.menuButton_=new Xn(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const i=Xn.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+i,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const n=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",n),this.on(this.menuButton_,"click",n),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),zr(bt,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new IC(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=ui("li",{className:"vjs-menu-title",textContent:Qs(this.options_.title),tabIndex:-1}),i=new st(this.player_,{el:t});e.addItem(i)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=Xn.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Yn(bt,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Wn&&Hk())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}st.registerComponent("MenuButton",$b);class Hb extends $b{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!i)return;const n=Ls(this,this.update);i.addEventListener("removetrack",n),i.addEventListener("addtrack",n),i.addEventListener("labelchange",n),this.player_.on("ready",n),this.player_.on("dispose",function(){i.removeEventListener("removetrack",n),i.removeEventListener("addtrack",n),i.removeEventListener("labelchange",n)})}}st.registerComponent("TrackButton",Hb);class Jh extends Cp{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,i){this.nonIconControl=!0;const n=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),i),r=ui("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?n.appendChild(r):n.replaceChild(r,n.querySelector(".vjs-icon-placeholder")),n}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}st.registerComponent("MenuItem",Jh);class ef extends Jh{constructor(e,t){const i=t.track,n=e.textTracks();t.label=i.label||i.language||"Unknown",t.selected=i.mode==="showing",super(e,t),this.track=i,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...u)=>{this.handleTracksChange.apply(this,u)},a=(...u)=>{this.handleSelectedLanguageChange.apply(this,u)};if(e.on(["loadstart","texttrackchange"],r),n.addEventListener("change",r),n.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),n.removeEventListener("change",r),n.removeEventListener("selectedlanguagechange",a)}),n.onchange===void 0){let u;this.on(["tap","click"],function(){if(typeof ye.Event!="object")try{u=new ye.Event("change")}catch{}u||(u=bt.createEvent("Event"),u.initEvent("change",!0,!0)),n.dispatchEvent(u)})}this.handleTracksChange()}handleClick(e){const t=this.track,i=this.player_.textTracks();if(super.handleClick(e),!!i)for(let n=0;n<i.length;n++){const r=i[n];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}st.registerComponent("TextTrackMenuItem",ef);class NC extends ef{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(this.options_.kinds.indexOf(a.kind)>-1&&a.mode==="showing"){i=!1;break}}i!==this.isSelected_&&this.selected(i)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(["captions","descriptions","subtitles"].indexOf(a.kind)>-1&&a.mode==="showing"){i=!1;break}}i&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}st.registerComponent("OffTextTrackMenuItem",NC);class Jc extends Hb{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=ef){let i;this.label_&&(i=`${this.label_} off`),e.push(new NC(this.player_,{kinds:this.kinds_,kind:this.kind_,label:i})),this.hideThreshold_+=1;const n=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<n.length;r++){const a=n[r];if(this.kinds_.indexOf(a.kind)>-1){const u=new t(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});u.addClass(`vjs-${a.kind}-menu-item`),e.push(u)}}return e}}st.registerComponent("TextTrackButton",Jc);class OC extends Jh{constructor(e,t){const i=t.track,n=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=n.text,t.selected=n.startTime<=r&&r<n.endTime,super(e,t),this.track=i,this.cue=n}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}st.registerComponent("ChaptersTrackMenuItem",OC);class zb extends Jc{constructor(e,t,i){super(e,t,i),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(n=>{n.selected(this.track_.activeCues[0]===n.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const i=e[t];if(i.kind===this.kind_)return i}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Qs(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let i=0,n=t.length;i<n;i++){const r=t[i],a=new OC(this.player_,{track:this.track_,cue:r});e.push(a)}return e}}zb.prototype.kind_="chapters";zb.prototype.controlText_="Chapters";st.registerComponent("ChaptersButton",zb);class Vb extends Jc{constructor(e,t,i){super(e,t,i),this.setIcon("audio-description");const n=e.textTracks(),r=Ls(this,this.handleTracksChange);n.addEventListener("change",r),this.on("dispose",function(){n.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let i=!1;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(a.kind!==this.kind_&&a.mode==="showing"){i=!0;break}}i?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}Vb.prototype.kind_="descriptions";Vb.prototype.controlText_="Descriptions";st.registerComponent("DescriptionsButton",Vb);class Gb extends Jc{constructor(e,t,i){super(e,t,i),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}Gb.prototype.kind_="subtitles";Gb.prototype.controlText_="Subtitles";st.registerComponent("SubtitlesButton",Gb);class qb extends ef{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}st.registerComponent("CaptionSettingsMenuItem",qb);class Kb extends Jc{constructor(e,t,i){super(e,t,i),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new qb(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}Kb.prototype.kind_="captions";Kb.prototype.controlText_="Captions";st.registerComponent("CaptionsButton",Kb);class MC extends ef{createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",n):r.appendChild(ui("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ui("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),n}}st.registerComponent("SubsCapsMenuItem",MC);class Wb extends Jc{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Qs(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new qb(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,MC),e}}Wb.prototype.kinds_=["captions","subtitles"];Wb.prototype.controlText_="Subtitles";st.registerComponent("SubsCapsButton",Wb);class PC extends Jh{constructor(e,t){const i=t.track,n=e.audioTracks();t.label=i.label||i.language||"Unknown",t.selected=i.enabled,super(e,t),this.track=i,this.addClass(`vjs-${i.kind}-menu-item`);const r=(...a)=>{this.handleTracksChange.apply(this,a)};n.addEventListener("change",r),this.on("dispose",()=>{n.removeEventListener("change",r)})}createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(ui("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ui("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),n}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];n!==this.track&&(n.enabled=n===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}st.registerComponent("AudioTrackMenuItem",PC);class BC extends Hb{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];e.push(new PC(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}BC.prototype.controlText_="Audio Track";st.registerComponent("AudioTrackButton",BC);class Yb extends Jh{constructor(e,t){const i=t.rate,n=parseFloat(i,10);t.label=i,t.selected=n===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=i,this.rate=n,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}Yb.prototype.contentElType="button";st.registerComponent("PlaybackRateMenuItem",Yb);class FC extends $b{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",i=>this.updateVisibility(i)),this.on(e,"ratechange",i=>this.updateLabel(i)),this.on(e,"playbackrateschange",i=>this.handlePlaybackRateschange(i))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=ui("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let i=e.length-1;i>=0;i--)t.push(new Yb(this.player(),{rate:e[i]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}FC.prototype.controlText_="Playback Rate";st.registerComponent("PlaybackRateMenuButton",FC);class UC extends st{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}st.registerComponent("Spacer",UC);class zB extends UC{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}st.registerComponent("CustomControlSpacer",zB);class jC extends st{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}jC.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};st.registerComponent("ControlBar",jC);class $C extends Qc{constructor(e,t){super(e,t),this.on(e,"error",i=>{this.open(i)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}$C.prototype.options_=Object.assign({},Qc.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});st.registerComponent("ErrorDisplay",$C);class HC extends st{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),ui("select",{id:this.options_.id},{},this.options_.SelectOptions.map(t=>{const i=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${ea()}`)+"-"+t[1].replace(/\W+/g,""),n=ui("option",{id:i,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${i}`),n}))}}st.registerComponent("TextTrackSelect",HC);class vu extends st{constructor(e,t={}){super(e,t);const i=ui("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(i);const n=this.options_.selects;for(const r of n){const a=this.options_.selectConfigs[r],u=a.className,c=a.id.replace("%s",this.options_.id_);let d=null;const f=`vjs_select_${ea()}`;if(this.options_.type==="colors"){d=ui("span",{className:u});const y=ui("label",{id:c,className:"vjs-label",textContent:this.localize(a.label)});y.setAttribute("for",f),d.appendChild(y)}const g=new HC(e,{SelectOptions:a.options,legendId:this.options_.legendId,id:f,labelId:c});this.addChild(g),this.options_.type==="colors"&&(d.appendChild(g.el()),this.el().appendChild(d))}}createEl(){return ui("fieldset",{className:this.options_.className})}}st.registerComponent("TextTrackFieldset",vu);class zC extends st{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new vu(e,{id_:i,legendId:`captions-text-legend-${i}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(n);const r=new vu(e,{id_:i,legendId:`captions-background-${i}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const a=new vu(e,{id_:i,legendId:`captions-window-${i}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(a)}createEl(){return ui("div",{className:"vjs-track-settings-colors"})}}st.registerComponent("TextTrackSettingsColors",zC);class VC extends st{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new vu(e,{id_:i,legendId:`captions-font-size-${i}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(n);const r=new vu(e,{id_:i,legendId:`captions-edge-style-${i}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const a=new vu(e,{id_:i,legendId:`captions-font-family-${i}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(a)}createEl(){return ui("div",{className:"vjs-track-settings-font"})}}st.registerComponent("TextTrackSettingsFont",VC);class GC extends st{constructor(e,t={}){super(e,t);const i=new Xn(e,{controlText:this.localize("restore all settings to the default values"),className:"vjs-default-button"});i.el().classList.remove("vjs-control","vjs-button"),i.el().textContent=this.localize("Reset"),this.addChild(i);const n=this.localize("Done"),r=new Xn(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=n,this.addChild(r)}createEl(){return ui("div",{className:"vjs-track-settings-controls"})}}st.registerComponent("TrackSettingsControls",GC);const gv="vjs-text-track-settings",gE=["#000","Black"],yE=["#00F","Blue"],vE=["#0FF","Cyan"],xE=["#0F0","Green"],bE=["#F0F","Magenta"],TE=["#F00","Red"],SE=["#FFF","White"],_E=["#FF0","Yellow"],yv=["1","Opaque"],vv=["0.5","Semi-Transparent"],EE=["0","Transparent"],bl={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[gE,SE,TE,xE,yE,_E,bE,vE],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[yv,vv,EE],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[SE,gE,TE,xE,yE,_E,bE,vE],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:s=>s==="1.00"?null:Number(s)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[yv,vv],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[EE,vv,yv],className:"vjs-window-opacity vjs-opacity"}};bl.windowColor.options=bl.backgroundColor.options;function qC(s,e){if(e&&(s=e(s)),s&&s!=="none")return s}function VB(s,e){const t=s.options[s.options.selectedIndex].value;return qC(t,e)}function GB(s,e,t){if(e){for(let i=0;i<s.options.length;i++)if(qC(s.options[i].value,t)===e){s.selectedIndex=i;break}}}class qB extends Qc{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=ui("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new zC(e,{textTrackComponentid:this.id_,selectConfigs:bl,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const i=new VC(e,{textTrackComponentid:this.id_,selectConfigs:bl,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(i);const n=new GC(e);this.addChild(n)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),bc(bl,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return Mk(bl,(e,t,i)=>{const n=VB(this.$(t.selector),t.parser);return n!==void 0&&(e[i]=n),e},{})}setValues(e){bc(bl,(t,i)=>{GB(this.$(t.selector),e[i],t.parser)})}setDefaults(){bc(bl,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(ye.localStorage.getItem(gv))}catch(t){wi.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?ye.localStorage.setItem(gv,JSON.stringify(e)):ye.localStorage.removeItem(gv)}catch(t){wi.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}st.registerComponent("TextTrackSettings",qB);class KB extends st{constructor(e,t){let i=t.ResizeObserver||ye.ResizeObserver;t.ResizeObserver===null&&(i=!1);const n=gs({createEl:!i,reportTouchActivity:!1},t);super(e,n),this.ResizeObserver=t.ResizeObserver||ye.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=nC(()=>{this.resizeHandler()},100,!1,this),i?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let a=this.unloadListener_=function(){Yn(this,"resize",r),Yn(this,"unload",a),a=null};zr(this.el_.contentWindow,"unload",a),zr(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}st.registerComponent("ResizeManager",KB);const WB={trackingThreshold:20,liveTolerance:15};class YB extends st{constructor(e,t){const i=gs(WB,t,{createEl:!1});super(e,i),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=n=>this.handlePlay(n),this.handleFirstTimeupdate_=n=>this.handleFirstTimeupdate(n),this.handleSeeked_=n=>this.handleSeeked(n),this.seekToLiveEdge_=n=>this.seekToLiveEdge(n),this.reset_(),this.on(this.player_,"durationchange",n=>this.handleDurationchange(n)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(ye.performance.now().toFixed(4)),i=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+i;const n=this.liveCurrentTime(),r=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(n-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||n===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,ta),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.end(i));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.start(i));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}st.registerComponent("LiveTracker",YB);class XB extends st{constructor(e,t){super(e,t),this.on("statechanged",i=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:ui("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${ea()}`}),description:ui("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${ea()}`})},ui("div",{className:"vjs-title-bar"},{},Pk(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,i={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(n=>{const r=this.state[n],a=this.els[n],u=i[n];_p(a),r&&Il(a,r),t&&(t.removeAttribute(u),r&&t.setAttribute(u,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}st.registerComponent("TitleBar",XB);const QB={initialDisplay:4e3,position:[],takeFocus:!1};class ZB extends Xn{constructor(e,t){t=gs(QB,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],i=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=ui("button",{},{type:"button",class:this.buildCSSClass()},ui("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}st.registerComponent("TransientButton",ZB);const Cx=s=>{const e=s.el();if(e.hasAttribute("src"))return s.triggerSourceset(e.src),!0;const t=s.$$("source"),i=[];let n="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const a=t[r].src;a&&i.indexOf(a)===-1&&i.push(a)}return i.length?(i.length===1&&(n=i[0]),s.triggerSourceset(n),!0):!1},JB=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(s){const e=bt.createElement(this.nodeName.toLowerCase());e.innerHTML=s;const t=bt.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",ye.Element.prototype.appendChild.call(this,t),this.innerHTML}}),KC=(s,e)=>{let t={};for(let i=0;i<s.length&&(t=Object.getOwnPropertyDescriptor(s[i],e),!(t&&t.set&&t.get));i++);return t.enumerable=!0,t.configurable=!0,t},eF=s=>KC([s.el(),ye.HTMLMediaElement.prototype,ye.Element.prototype,JB],"innerHTML"),wE=function(s){const e=s.el();if(e.resetSourceWatch_)return;const t={},i=eF(s),n=r=>(...a)=>{const u=r.apply(e,a);return Cx(s),u};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=n(t[r]))}),Object.defineProperty(e,"innerHTML",gs(i,{set:n(i.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",i)},s.one("sourceset",e.resetSourceWatch_)},tF=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?pC(ye.Element.prototype.getAttribute.call(this,"src")):""},set(s){return ye.Element.prototype.setAttribute.call(this,"src",s),s}}),iF=s=>KC([s.el(),ye.HTMLMediaElement.prototype,tF],"src"),sF=function(s){if(!s.featuresSourceset)return;const e=s.el();if(e.resetSourceset_)return;const t=iF(s),i=e.setAttribute,n=e.load;Object.defineProperty(e,"src",gs(t,{set:r=>{const a=t.set.call(e,r);return s.triggerSourceset(e.src),a}})),e.setAttribute=(r,a)=>{const u=i.call(e,r,a);return/src/i.test(r)&&s.triggerSourceset(e.src),u},e.load=()=>{const r=n.call(e);return Cx(s)||(s.triggerSourceset(""),wE(s)),r},e.currentSrc?s.triggerSourceset(e.currentSrc):Cx(s)||wE(s),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=n,e.setAttribute=i,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class Ut extends bi{constructor(e,t){super(e,t);const i=e.source;let n=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",i&&(this.el_.currentSrc!==i.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(i):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let a=r.length;const u=[];for(;a--;){const c=r[a];c.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(c),this.remoteTextTracks().addTrack(c.track),this.textTracks().addTrack(c.track),!n&&!this.el_.hasAttribute("crossorigin")&&kp(c.src)&&(n=!0)):u.push(c))}for(let c=0;c<u.length;c++)this.el_.removeChild(u[c])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&n&&wi.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(Mh||vp)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),Ut.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){sF(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const i=()=>{t=[];for(let r=0;r<e.length;r++){const a=e[r];a.kind==="metadata"&&t.push({track:a,storedMode:a.mode})}};i(),e.addEventListener("change",i),this.on("dispose",()=>e.removeEventListener("change",i));const n=()=>{for(let r=0;r<t.length;r++){const a=t[r];a.track.mode==="disabled"&&a.track.mode!==a.storedMode&&(a.track.mode=a.storedMode)}e.removeEventListener("change",n)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",i),e.removeEventListener("change",n),e.addEventListener("change",n)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",i),e.addEventListener("change",i),e.removeEventListener("change",n)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const i=e.toLowerCase();this[`${i}TracksListeners_`]&&Object.keys(this[`${i}TracksListeners_`]).forEach(n=>{this.el()[`${i}Tracks`].removeEventListener(n,this[`${i}TracksListeners_`][n])}),this[`featuresNative${e}Tracks`]=!t,this[`${i}TracksListeners_`]=null,this.proxyNativeTracksForType_(i)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=Jr[e],i=this.el()[t.getterName],n=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!i||!i.addEventListener)return;const r={change:u=>{const c={type:"change",target:n,currentTarget:n,srcElement:n};n.trigger(c),e==="text"&&this[Vc.remoteText.getterName]().trigger(c)},addtrack(u){n.addTrack(u.track)},removetrack(u){n.removeTrack(u.track)}},a=function(){const u=[];for(let c=0;c<n.length;c++){let d=!1;for(let f=0;f<i.length;f++)if(i[f]===n[c]){d=!0;break}d||u.push(n[c])}for(;u.length;)n.removeTrack(u.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(u=>{const c=r[u];i.addEventListener(u,c),this.on("dispose",d=>i.removeEventListener(u,c))}),this.on("loadstart",a),this.on("dispose",u=>this.off("loadstart",a))}proxyNativeTracks_(){Jr.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const i=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(i,e),Ut.disposeMediaElement(e),e=i}else{e=bt.createElement("video");const i=this.options_.tag&&xl(this.options_.tag),n=gs({},i);(!Mh||this.options_.nativeControlsForTouch!==!0)&&delete n.controls,Gk(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&$c(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let i=0;i<t.length;i++){const n=t[i],r=this.options_[n];typeof r<"u"&&(r?$c(e,n,n):Tp(e,n),e[n]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let i=!1;const n=function(){i=!0};this.on("loadstart",n);const r=function(){i||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",n),this.off("loadedmetadata",r),i||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(i){this.trigger(i)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&xp?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){wi(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&va&&Ya&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)$a(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return wi.error("Invalid source URL."),!1;const i={src:e};t&&(i.type=t);const n=ui("source",{},i);return this.el_.appendChild(n),!0}removeSourceElement(e){if(!e)return wi.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const i of t)if(i.src===e)return this.el_.removeChild(i),!0;return wi.warn(`No matching source element found with src: ${e}`),!1}reset(){Ut.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,i){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,i):super.addTextTrack(e,t,i)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=bt.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const i=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(i),i}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let i=t.length;for(;i--;)(e===t[i]||e===t[i].track)&&this.el().removeChild(t[i])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),ye.performance&&(e.creationTime=ye.performance.now()),e}}pp(Ut,"TEST_VID",function(){if(!Wc())return;const s=bt.createElement("video"),e=bt.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",s.appendChild(e),s});Ut.isSupported=function(){try{Ut.TEST_VID.volume=.5}catch{return!1}return!!(Ut.TEST_VID&&Ut.TEST_VID.canPlayType)};Ut.canPlayType=function(s){return Ut.TEST_VID.canPlayType(s)};Ut.canPlaySource=function(s,e){return Ut.canPlayType(s.type)};Ut.canControlVolume=function(){try{const s=Ut.TEST_VID.volume;Ut.TEST_VID.volume=s/2+.1;const e=s!==Ut.TEST_VID.volume;return e&&Wn?(ye.setTimeout(()=>{Ut&&Ut.prototype&&(Ut.prototype.featuresVolumeControl=s!==Ut.TEST_VID.volume)}),!1):e}catch{return!1}};Ut.canMuteVolume=function(){try{const s=Ut.TEST_VID.muted;return Ut.TEST_VID.muted=!s,Ut.TEST_VID.muted?$c(Ut.TEST_VID,"muted","muted"):Tp(Ut.TEST_VID,"muted","muted"),s!==Ut.TEST_VID.muted}catch{return!1}};Ut.canControlPlaybackRate=function(){if(va&&Ya&&gp<58)return!1;try{const s=Ut.TEST_VID.playbackRate;return Ut.TEST_VID.playbackRate=s/2+.1,s!==Ut.TEST_VID.playbackRate}catch{return!1}};Ut.canOverrideAttributes=function(){try{const s=()=>{};Object.defineProperty(bt.createElement("video"),"src",{get:s,set:s}),Object.defineProperty(bt.createElement("audio"),"src",{get:s,set:s}),Object.defineProperty(bt.createElement("video"),"innerHTML",{get:s,set:s}),Object.defineProperty(bt.createElement("audio"),"innerHTML",{get:s,set:s})}catch{return!1}return!0};Ut.supportsNativeTextTracks=function(){return xp||Wn&&Ya};Ut.supportsNativeVideoTracks=function(){return!!(Ut.TEST_VID&&Ut.TEST_VID.videoTracks)};Ut.supportsNativeAudioTracks=function(){return!!(Ut.TEST_VID&&Ut.TEST_VID.audioTracks)};Ut.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([s,e]){pp(Ut.prototype,s,()=>Ut[e](),!0)});Ut.prototype.featuresVolumeControl=Ut.canControlVolume();Ut.prototype.movingMediaElementInDOM=!Wn;Ut.prototype.featuresFullscreenResize=!0;Ut.prototype.featuresProgressEvents=!0;Ut.prototype.featuresTimeupdateEvents=!0;Ut.prototype.featuresVideoFrameCallback=!!(Ut.TEST_VID&&Ut.TEST_VID.requestVideoFrameCallback);Ut.disposeMediaElement=function(s){if(s){for(s.parentNode&&s.parentNode.removeChild(s);s.hasChildNodes();)s.removeChild(s.firstChild);s.removeAttribute("src"),typeof s.load=="function"&&(function(){try{s.load()}catch{}})()}};Ut.resetMediaElement=function(s){if(!s)return;const e=s.querySelectorAll("source");let t=e.length;for(;t--;)s.removeChild(e[t]);s.removeAttribute("src"),typeof s.load=="function"&&(function(){try{s.load()}catch{}})()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(s){Ut.prototype[s]=function(){return this.el_[s]||this.el_.hasAttribute(s)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(s){Ut.prototype["set"+Qs(s)]=function(e){this.el_[s]=e,e?this.el_.setAttribute(s,s):this.el_.removeAttribute(s)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(s){Ut.prototype[s]=function(){return this.el_[s]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(s){Ut.prototype["set"+Qs(s)]=function(e){this.el_[s]=e}});["pause","load","play"].forEach(function(s){Ut.prototype[s]=function(){return this.el_[s]()}});bi.withSourceHandlers(Ut);Ut.nativeSourceHandler={};Ut.nativeSourceHandler.canPlayType=function(s){try{return Ut.TEST_VID.canPlayType(s)}catch{return""}};Ut.nativeSourceHandler.canHandleSource=function(s,e){if(s.type)return Ut.nativeSourceHandler.canPlayType(s.type);if(s.src){const t=Ob(s.src);return Ut.nativeSourceHandler.canPlayType(`video/${t}`)}return""};Ut.nativeSourceHandler.handleSource=function(s,e,t){e.setSrc(s.src)};Ut.nativeSourceHandler.dispose=function(){};Ut.registerSourceHandler(Ut.nativeSourceHandler);bi.registerTech("Html5",Ut);const WC=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],xv={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},Dx=["tiny","xsmall","small","medium","large","xlarge","huge"],t0={};Dx.forEach(s=>{const e=s.charAt(0)==="x"?`x-${s.substring(1)}`:s;t0[s]=`vjs-layout-${e}`});const nF={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};let js=class hc extends st{constructor(e,t,i){if(e.id=e.id||t.id||`vjs_video_${ea()}`,t=Object.assign(hc.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const a=e.closest("[lang]");a&&(t.language=a.getAttribute("lang"))}if(super(null,t,i),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.boundUpdatePlayerHeightOnAudioOnlyMode_=a=>this.updatePlayerHeightOnAudioOnlyMode_(a),this.isFullscreen_=!1,this.log=Nk(this.id_),this.fsApi_=S0,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&xl(e),this.language(this.options_.language),t.languages){const a={};Object.getOwnPropertyNames(t.languages).forEach(function(u){a[u.toLowerCase()]=t.languages[u]}),this.languages_=a}else this.languages_=hc.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Db(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(zr(bt,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const n=gs(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(a=>{this[a](t.plugins[a])}),t.debug&&this.debug(!0),this.options_.playerOptions=n,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const u=new ye.DOMParser().parseFromString(kB,"image/svg+xml");if(u.querySelector("parsererror"))wi.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const d=u.documentElement;d.style.display="none",this.el_.appendChild(d),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new CB(this),this.addClass("vjs-spatial-navigation-enabled")),Mh&&this.addClass("vjs-touch-enabled"),Wn||this.addClass("vjs-workinghover"),hc.players[this.id_]=this;const r=vx.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),Yn(bt,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Yn(bt,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),hc.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),_B(this),tr.names.forEach(e=>{const t=tr[e],i=this[t.getterName]();i&&i.off&&i.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,i=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const n=this.tag.tagName.toLowerCase()==="video-js";i?t=this.el_=e.parentNode:n||(t=this.el_=super.createEl("div"));const r=xl(e);if(n){for(t=this.el_=e,e=this.tag=bt.createElement("video");t.children.length;)e.appendChild(t.firstChild);Eh(t,"video-js")||gu(t,"video-js"),t.appendChild(e),i=this.playerElIngest_=t,Object.keys(t).forEach(c=>{try{e[c]=t[c]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",Ya&&yp&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(c){n&&c==="class"||t.setAttribute(c,r[c]),n&&e.setAttribute(c,r[c])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const a=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>$k[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...a),ye.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=iC("vjs-styles-dimensions");const c=Dl(".vjs-styles-defaults"),d=Dl("head");d.insertBefore(this.styleEl_,c?c.nextSibling:d.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const u=e.getElementsByTagName("a");for(let c=0;c<u.length;c++){const d=u.item(c);gu(d,"vjs-hidden"),d.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!i&&e.parentNode.insertBefore(t,e),bx(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){wi.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const i=e+"_";if(t===void 0)return this[i]||0;if(t===""||t==="auto"){this[i]=void 0,this.updateStyleEl_();return}const n=parseFloat(t);if(isNaN(n)){wi.error(`Improper value "${t}" supplied for for ${e}`);return}this[i]=n,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,Do(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),tB(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(ye.VIDEOJS_NO_DYNAMIC_STYLE===!0){const u=typeof this.width_=="number"?this.width_:this.options_.width,c=typeof this.height_=="number"?this.height_:this.options_.height,d=this.tech_&&this.tech_.el();d&&(u>=0&&(d.width=u),c>=0&&(d.height=c));return}let e,t,i,n;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?i=this.aspectRatio_:this.videoWidth()>0?i=this.videoWidth()+":"+this.videoHeight():i="16:9";const r=i.split(":"),a=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*a,/^[^a-zA-Z]/.test(this.id())?n="dimensions-"+this.id():n=this.id()+"-dimensions",this.addClass(n),sC(this.styleEl_,`
.${n} {
width: ${e}px;
height: ${t}px;
}
.${n}.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: ${a*100}%;
}
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const i=Qs(e),n=e.charAt(0).toLowerCase()+e.slice(1);i!=="Html5"&&this.tag&&(bi.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=i,this.isReady_=!1;let r=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(r=!1);const a={source:t,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${n}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};tr.names.forEach(c=>{const d=tr[c];a[d.getterName]=this[d.privateName]}),Object.assign(a,this.options_[i]),Object.assign(a,this.options_[n]),Object.assign(a,this.options_[e.toLowerCase()]),this.tag&&(a.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(a.startTime=this.cache_.currentTime);const u=bi.getTech(e);if(!u)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new u(a),this.tech_.ready(Ls(this,this.handleTechReady_),!0),Ax.jsonToTextTracks(this.textTracksJson_||[],this.tech_),WC.forEach(c=>{this.on(this.tech_,c,d=>this[`handleTech${Qs(c)}_`](d))}),Object.keys(xv).forEach(c=>{this.on(this.tech_,c,d=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${xv[c]}_`].bind(this),event:d});return}this[`handleTech${xv[c]}_`](d)})}),this.on(this.tech_,"loadstart",c=>this.handleTechLoadStart_(c)),this.on(this.tech_,"sourceset",c=>this.handleTechSourceset_(c)),this.on(this.tech_,"waiting",c=>this.handleTechWaiting_(c)),this.on(this.tech_,"ended",c=>this.handleTechEnded_(c)),this.on(this.tech_,"seeking",c=>this.handleTechSeeking_(c)),this.on(this.tech_,"play",c=>this.handleTechPlay_(c)),this.on(this.tech_,"pause",c=>this.handleTechPause_(c)),this.on(this.tech_,"durationchange",c=>this.handleTechDurationChange_(c)),this.on(this.tech_,"fullscreenchange",(c,d)=>this.handleTechFullscreenChange_(c,d)),this.on(this.tech_,"fullscreenerror",(c,d)=>this.handleTechFullscreenError_(c,d)),this.on(this.tech_,"enterpictureinpicture",c=>this.handleTechEnterPictureInPicture_(c)),this.on(this.tech_,"leavepictureinpicture",c=>this.handleTechLeavePictureInPicture_(c)),this.on(this.tech_,"error",c=>this.handleTechError_(c)),this.on(this.tech_,"posterchange",c=>this.handleTechPosterChange_(c)),this.on(this.tech_,"textdata",c=>this.handleTechTextData_(c)),this.on(this.tech_,"ratechange",c=>this.handleTechRateChange_(c)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode!==this.el()&&(i!=="Html5"||!this.tag)&&bx(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){tr.names.forEach(e=>{const t=tr[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=Ax.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return e===void 0&&wi.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
See https://github.com/videojs/video.js/issues/2617 for more info.
`),this.tech_}version(){return{"video.js":vx}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const n=this.muted();this.muted(!0);const r=()=>{this.muted(n)};this.playTerminatedQueue_.push(r);const a=this.play();if(Ah(a))return a.catch(u=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${u||""}`)})};let i;if(e==="any"&&!this.muted()?(i=this.play(),Ah(i)&&(i=i.catch(t))):e==="muted"&&!this.muted()?i=t():i=this.play(),!!Ah(i))return i.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,i="";typeof t!="string"&&(t=e.src,i=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!i&&(i=AB(this,t)),this.cache_.source=gs({},e,{src:t,type:i});const n=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],a=this.$$("source"),u=[];for(let c=0;c<a.length;c++){const d=xl(a[c]);r.push(d),d.src&&d.src===t&&u.push(d.src)}u.length&&!n.length?this.cache_.sources=r:n.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const i=this.currentSource().src,n=e.src;i&&!/^blob:/.test(i)&&/^blob:/.test(n)&&(!this.lastSource_||this.lastSource_.tech!==n&&this.lastSource_.player!==i)&&(t=()=>{}),t(n),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?$a(this.play()):this.pause())}handleTechDoubleClick_(e){if(!this.controls_)return;Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),i=>i.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!bt.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen())}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const i=this.el();let n=bt[this.fsApi_.fullscreenElement]===i;!n&&i.matches&&(n=i.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(n)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in TB)return xB(this.middleware_,this.tech_,e,t);if(e in cE)return uE(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(i){throw wi(i),i}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in bB)return vB(this.middleware_,this.tech_,e);if(e in cE)return uE(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(wi(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(wi(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(wi(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=$a){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),i=!!(xp||Wn);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=a=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&i&&this.load();return}const n=this.techGet_("play");i&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),n===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(n)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(i){i(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||ya(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=ya(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=ya(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return hC(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let i=e.end(e.length-1);return i>t&&(i=t),i}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((i,n)=>{function r(){t.off("fullscreenerror",u),t.off("fullscreenchange",a)}function a(){r(),i()}function u(d,f){r(),n(f)}t.one("fullscreenchange",a),t.one("fullscreenerror",u);const c=t.requestFullscreenHelper_(e);c&&(c.then(r,r),c.then(i,n))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const i=this.el_[this.fsApi_.requestFullscreen](t);return i&&i.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),i}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,i)=>{function n(){e.off("fullscreenerror",a),e.off("fullscreenchange",r)}function r(){n(),t()}function a(c,d){n(),i(d)}e.one("fullscreenchange",r),e.one("fullscreenerror",a);const u=e.exitFullscreenHelper_();u&&(u.then(n,n),u.then(t,i))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=bt[this.fsApi_.exitFullscreen]();return e&&$a(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=bt.documentElement.style.overflow,zr(bt,"keydown",this.boundFullWindowOnEscKey_),bt.documentElement.style.overflow="hidden",gu(bt.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Yn(bt,"keydown",this.boundFullWindowOnEscKey_),bt.documentElement.style.overflow=this.docOrigOverflow,bp(bt.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&ye.documentPictureInPicture){const e=bt.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(ui("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),ye.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(Jk(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",i=>{const n=i.target.querySelector(".video-js");e.parentNode.replaceChild(n,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in bt&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(ye.documentPictureInPicture&&ye.documentPictureInPicture.window)return ye.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in bt)return bt.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const r=n.tagName.toLowerCase();if(n.isContentEditable)return!0;const a=["button","checkbox","hidden","radio","reset","submit"];return r==="input"?a.indexOf(n.type)===-1:["textarea"].indexOf(r)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:i=a=>e.key.toLowerCase()==="f",muteKey:n=a=>e.key.toLowerCase()==="m",playPauseKey:r=a=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(i.call(this,e)){e.preventDefault(),e.stopPropagation();const a=st.getComponent("FullscreenToggle");bt[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else n.call(this,e)?(e.preventDefault(),e.stopPropagation(),st.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),st.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let i=0,n=this.options_.techOrder;i<n.length;i++){const r=n[i];let a=bi.getTech(r);if(a||(a=st.getComponent(r)),!a){wi.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(a.isSupported()&&(t=a.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(u=>[u,bi.getTech(u)]).filter(([u,c])=>c?c.isSupported():(wi.error(`The "${u}" tech is undefined. Skipped browser support check for that tech.`),!1)),i=function(u,c,d){let f;return u.some(g=>c.some(y=>{if(f=d(g,y),f)return!0})),f};let n;const r=u=>(c,d)=>u(d,c),a=([u,c],d)=>{if(c.canPlaySource(d,this.options_[u.toLowerCase()]))return{source:d,tech:u}};return this.options_.sourceOrder?n=i(e,t,r(a)):n=i(t,e,a),n||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const i=vC(e);if(!i.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=i),this.updateSourceCaches_(i[0]),gB(this,i[0],(n,r)=>{if(this.middleware_=r,t||(this.cache_.sources=i),this.updateSourceCaches_(n),this.src_(n)){if(i.length>1)return this.handleSrc_(i.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}yB(r,this.tech_)}),i.length>1){const n=()=>{this.error(null),this.handleSrc_(i.slice(1),!0)},r=()=>{this.off("error",n)};this.one("error",n),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",n),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?lC(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();$a(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),Do(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:i,remainingTimeDisplay:n}=this.controlBar||{},{seekBar:r}=i||{};e&&e.updateContent(),t&&t.updateContent(),n&&n.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Cl("beforeerror").forEach(t=>{const i=t(this,e);if(!(Wa(i)&&!Array.isArray(i)||typeof i=="string"||typeof i=="number"||i===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=i}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Gs(e),this.addClass("vjs-error"),wi.error(`(CODE:${this.error_.code} ${Gs.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Cl("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,i;const n=Ls(this,this.reportUserActivity),r=function(g){(g.screenX!==t||g.screenY!==i)&&(t=g.screenX,i=g.screenY,n())},a=function(){n(),this.clearInterval(e),e=this.setInterval(n,250)},u=function(g){n(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",r),this.on("mouseup",u),this.on("mouseleave",u);const c=this.getChild("controlBar");c&&!Wn&&!va&&(c.on("mouseenter",function(g){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(g){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",n),this.on("keyup",n);let d;const f=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(d);const g=this.options_.inactivityTimeout;g<=0||(d=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},g))};this.setInterval(f,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),i=t&&t.currentHeight();e.forEach(n=>{n!==t&&n.el_&&!n.hasClass("vjs-hidden")&&(n.hide(),this.audioOnlyCache_.hiddenChildren.push(n))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=i,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(i),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,i){if(this.tech_)return this.tech_.addTextTrack(e,t,i)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),Do(this)&&this.trigger("languagechange"))}languages(){return gs(hc.prototype.options_.languages,this.languages_)}toJSON(){const e=gs(this.options_),t=e.tracks;e.tracks=[];for(let i=0;i<t.length;i++){let n=t[i];n=gs(n),n.player=void 0,e.tracks[i]=n}return e}createModal(e,t){t=t||{},t.content=e||"";const i=new Qc(this,t);return this.addChild(i),i.on("dispose",()=>{this.removeChild(i)}),i.open(),i}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let i=0;i<Dx.length;i++){const n=Dx[i],r=this.breakpoints_[n];if(t<=r){if(e===n)return;e&&this.removeClass(t0[e]),this.addClass(t0[n]),this.breakpoint_=n;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},nF,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return t0[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const i=this.crossOrigin();this.reset(),this.cache_.media=gs(e);const{artist:n,artwork:r,description:a,poster:u,src:c,textTracks:d,title:f}=this.cache_.media;!r&&u&&(this.cache_.media.artwork=[{src:u,type:I0(u)}]),i&&this.crossOrigin(i),c&&this.src(c),u&&this.poster(u),Array.isArray(d)&&d.forEach(g=>this.addRemoteTextTrack(g,!1)),this.titleBar&&this.titleBar.update({title:f,description:a||n||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),i=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),n={src:t,textTracks:i};return e&&(n.poster=e,n.artwork=[{src:n.poster,type:I0(n.poster)}]),n}return gs(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},i=xl(e),n=i["data-setup"];if(Eh(e,"vjs-fill")&&(i.fill=!0),Eh(e,"vjs-fluid")&&(i.fluid=!0),n!==null)try{Object.assign(i,JSON.parse(n||"{}"))}catch(r){wi.error("data-setup",r)}if(Object.assign(t,i),e.hasChildNodes()){const r=e.childNodes;for(let a=0,u=r.length;a<u;a++){const c=r[a],d=c.nodeName.toLowerCase();d==="source"?t.sources.push(xl(c)):d==="track"&&t.tracks.push(xl(c))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}};js.prototype.videoTracks=()=>{};js.prototype.audioTracks=()=>{};js.prototype.textTracks=()=>{};js.prototype.remoteTextTracks=()=>{};js.prototype.remoteTextTrackEls=()=>{};tr.names.forEach(function(s){const e=tr[s];js.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});js.prototype.crossorigin=js.prototype.crossOrigin;js.players={};const ih=ye.navigator;js.prototype.options_={techOrder:bi.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:ih&&(ih.languages&&ih.languages[0]||ih.userLanguage||ih.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1,disableSeekWhileScrubbingOnSTV:!1};WC.forEach(function(s){js.prototype[`handleTech${Qs(s)}_`]=function(){return this.trigger(s)}});st.registerComponent("Player",js);const N0="plugin",_c="activePlugins_",mc={},O0=s=>mc.hasOwnProperty(s),i0=s=>O0(s)?mc[s]:void 0,YC=(s,e)=>{s[_c]=s[_c]||{},s[_c][e]=!0},M0=(s,e,t)=>{const i=(t?"before":"")+"pluginsetup";s.trigger(i,e),s.trigger(i+":"+e.name,e)},rF=function(s,e){const t=function(){M0(this,{name:s,plugin:e,instance:null},!0);const i=e.apply(this,arguments);return YC(this,s),M0(this,{name:s,plugin:e,instance:i}),i};return Object.keys(e).forEach(function(i){t[i]=e[i]}),t},AE=(s,e)=>(e.prototype.name=s,function(...t){M0(this,{name:s,plugin:e,instance:null},!0);const i=new e(this,...t);return this[s]=()=>i,M0(this,i.getEventHash()),i});class Sr{constructor(e){if(this.constructor===Sr)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),Db(this),delete this.trigger,oC(this,this.constructor.defaultState),YC(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return Xc(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[_c][e]=!1,this.player=this.state=null,t[e]=AE(e,mc[e])}static isBasic(e){const t=typeof e=="string"?i0(e):e;return typeof t=="function"&&!Sr.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(O0(e))wi.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(js.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return mc[e]=t,e!==N0&&(Sr.isBasic(t)?js.prototype[e]=rF(e,t):js.prototype[e]=AE(e,t)),t}static deregisterPlugin(e){if(e===N0)throw new Error("Cannot de-register base plugin.");O0(e)&&(delete mc[e],delete js.prototype[e])}static getPlugins(e=Object.keys(mc)){let t;return e.forEach(i=>{const n=i0(i);n&&(t=t||{},t[i]=n)}),t}static getPluginVersion(e){const t=i0(e);return t&&t.VERSION||""}}Sr.getPlugin=i0;Sr.BASE_PLUGIN_NAME=N0;Sr.registerPlugin(N0,Sr);js.prototype.usingPlugin=function(s){return!!this[_c]&&this[_c][s]===!0};js.prototype.hasPlugin=function(s){return!!O0(s)};function aF(s,e){let t=!1;return function(...i){return t||wi.warn(s),t=!0,e.apply(this,i)}}function xa(s,e,t,i){return aF(`${e} is deprecated and will be removed in ${s}.0; please use ${t} instead.`,i)}var oF={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const XC=s=>s.indexOf("#")===0?s.slice(1):s;function He(s,e,t){let i=He.getPlayer(s);if(i)return e&&wi.warn(`Player "${s}" is already initialised. Options will not be applied.`),t&&i.ready(t),i;const n=typeof s=="string"?Dl("#"+XC(s)):s;if(!Yc(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");const a=("getRootNode"in n?n.getRootNode()instanceof ye.ShadowRoot:!1)?n.getRootNode():n.ownerDocument.body;(!n.ownerDocument.defaultView||!a.contains(n))&&wi.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(n.parentNode&&n.parentNode.hasAttribute&&n.parentNode.hasAttribute("data-vjs-player")?n.parentNode:n).cloneNode(!0)),Cl("beforesetup").forEach(c=>{const d=c(n,gs(e));if(!Wa(d)||Array.isArray(d)){wi.error("please return an object in beforesetup hooks");return}e=gs(e,d)});const u=st.getComponent("Player");return i=new u(n,e,t),Cl("setup").forEach(c=>c(i)),i}He.hooks_=Ao;He.hooks=Cl;He.hook=$4;He.hookOnce=H4;He.removeHook=Ik;if(ye.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&Wc()){let s=Dl(".vjs-styles-defaults");if(!s){s=iC("vjs-styles-defaults");const e=Dl("head");e&&e.insertBefore(s,e.firstChild),sC(s,`
.video-js {
width: 300px;
height: 150px;
}
.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: 56.25%
}
`)}}Sx(1,He);He.VERSION=vx;He.options=js.prototype.options_;He.getPlayers=()=>js.players;He.getPlayer=s=>{const e=js.players;let t;if(typeof s=="string"){const i=XC(s),n=e[i];if(n)return n;t=Dl("#"+i)}else t=s;if(Yc(t)){const{player:i,playerId:n}=t;if(i||e[n])return i||e[n]}};He.getAllPlayers=()=>Object.keys(js.players).map(s=>js.players[s]).filter(Boolean);He.players=js.players;He.getComponent=st.getComponent;He.registerComponent=(s,e)=>(bi.isTech(e)&&wi.warn(`The ${s} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),st.registerComponent.call(st,s,e));He.getTech=bi.getTech;He.registerTech=bi.registerTech;He.use=pB;Object.defineProperty(He,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(He.middleware,"TERMINATOR",{value:R0,writeable:!1,enumerable:!0});He.browser=$k;He.obj=G4;He.mergeOptions=xa(9,"videojs.mergeOptions","videojs.obj.merge",gs);He.defineLazyProperty=xa(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",pp);He.bind=xa(9,"videojs.bind","native Function.prototype.bind",Ls);He.registerPlugin=Sr.registerPlugin;He.deregisterPlugin=Sr.deregisterPlugin;He.plugin=(s,e)=>(wi.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),Sr.registerPlugin(s,e));He.getPlugins=Sr.getPlugins;He.getPlugin=Sr.getPlugin;He.getPluginVersion=Sr.getPluginVersion;He.addLanguage=function(s,e){return s=(""+s).toLowerCase(),He.options.languages=gs(He.options.languages,{[s]:e}),He.options.languages[s]};He.log=wi;He.createLogger=Nk;He.time=aB;He.createTimeRange=xa(9,"videojs.createTimeRange","videojs.time.createTimeRanges",ya);He.createTimeRanges=xa(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",ya);He.formatTime=xa(9,"videojs.formatTime","videojs.time.formatTime",Eu);He.setFormatTime=xa(9,"videojs.setFormatTime","videojs.time.setFormatTime",cC);He.resetFormatTime=xa(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",dC);He.parseUrl=xa(9,"videojs.parseUrl","videojs.url.parseUrl",Nb);He.isCrossOrigin=xa(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",kp);He.EventTarget=Vr;He.any=Cb;He.on=zr;He.one=wp;He.off=Yn;He.trigger=Xc;He.xhr=yk;He.TrackList=wu;He.TextTrack=Qh;He.TextTrackList=Rb;He.AudioTrack=gC;He.AudioTrackList=fC;He.VideoTrack=yC;He.VideoTrackList=mC;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(s=>{He[s]=function(){return wi.warn(`videojs.${s}() is deprecated; use videojs.dom.${s}() instead`),eC[s].apply(null,arguments)}});He.computedStyle=xa(9,"videojs.computedStyle","videojs.dom.computedStyle",zc);He.dom=eC;He.fn=eB;He.num=PB;He.str=nB;He.url=fB;He.Error=oF;class lF{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(i){t.enabled_(i)}}),t}}class P0 extends He.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const i=this.levels_.length;return t=new lF(e),""+i in this||Object.defineProperty(this,i,{get(){return this.levels_[i]}}),this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this.levels_.splice(i,1)[0],this.selectedIndex_===i?this.selectedIndex_=-1:this.selectedIndex_>i&&this.selectedIndex_--;break}return t&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),t}getQualityLevelById(e){for(let t=0,i=this.length;t<i;t++){const n=this[t];if(n.id===e)return n}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}P0.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const s in P0.prototype.allowedEvents_)P0.prototype["on"+s]=null;var QC="4.1.0";const uF=function(s,e){const t=s.qualityLevels,i=new P0,n=function(){i.dispose(),s.qualityLevels=t,s.off("dispose",n)};return s.on("dispose",n),s.qualityLevels=()=>i,s.qualityLevels.VERSION=QC,i},ZC=function(s){return uF(this,He.obj.merge({},s))};He.registerPlugin("qualityLevels",ZC);ZC.VERSION=QC;const yr=dp,B0=(s,e)=>e&&e.responseURL&&s!==e.responseURL?e.responseURL:s,na=s=>He.log.debug?He.log.debug.bind(He,"VHS:",`${s} >`):function(){};function is(...s){const e=He.obj||He;return(e.merge||e.mergeOptions).apply(e,s)}function Rn(...s){const e=He.time||He;return(e.createTimeRanges||e.createTimeRanges).apply(e,s)}function cF(s){if(s.length===0)return"Buffered Ranges are empty";let e=`Buffered Ranges:
`;for(let t=0;t<s.length;t++){const i=s.start(t),n=s.end(t);e+=`${i} --> ${n}. Duration (${n-i})
`}return e}const Ha=1/30,za=Ha*3,JC=function(s,e){const t=[];let i;if(s&&s.length)for(i=0;i<s.length;i++)e(s.start(i),s.end(i))&&t.push([s.start(i),s.end(i)]);return Rn(t)},pc=function(s,e){return JC(s,function(t,i){return t-za<=e&&i+za>=e})},Dm=function(s,e){return JC(s,function(t){return t-Ha>=e})},dF=function(s){if(s.length<2)return Rn();const e=[];for(let t=1;t<s.length;t++){const i=s.end(t-1),n=s.start(t);e.push([i,n])}return Rn(e)},hF=function(s,e){let t=null,i=null,n=0;const r=[],a=[];if(!s||!s.length||!e||!e.length)return Rn();let u=s.length;for(;u--;)r.push({time:s.start(u),type:"start"}),r.push({time:s.end(u),type:"end"});for(u=e.length;u--;)r.push({time:e.start(u),type:"start"}),r.push({time:e.end(u),type:"end"});for(r.sort(function(c,d){return c.time-d.time}),u=0;u<r.length;u++)r[u].type==="start"?(n++,n===2&&(t=r[u].time)):r[u].type==="end"&&(n--,n===1&&(i=r[u].time)),t!==null&&i!==null&&(a.push([t,i]),t=null,i=null);return Rn(a)},eD=s=>{const e=[];if(!s||!s.length)return"";for(let t=0;t<s.length;t++)e.push(s.start(t)+" => "+s.end(t));return e.join(", ")},fF=function(s,e,t=1){return((s.length?s.end(s.length-1):0)-e)/t},mu=s=>{const e=[];for(let t=0;t<s.length;t++)e.push({start:s.start(t),end:s.end(t)});return e},mF=function(s,e){if(s===e)return!1;if(!s&&e||!e&&s||s.length!==e.length)return!0;for(let t=0;t<s.length;t++)if(s.start(t)!==e.start(t)||s.end(t)!==e.end(t))return!0;return!1},bv=function(s){if(!(!s||!s.length||!s.end))return s.end(s.length-1)},Xb=function(s,e){let t=0;if(!s||!s.length)return t;for(let i=0;i<s.length;i++){const n=s.start(i),r=s.end(i);if(!(e>r)){if(e>n&&e<=r){t+=r-e;continue}t+=r-n}}return t},Qb=(s,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(i){t+=i.duration}),(e.preloadHints||[]).forEach(function(i){i.type==="PART"&&(t+=s.partTargetDuration)}),t},Lx=s=>(s.segments||[]).reduce((e,t,i)=>(t.parts?t.parts.forEach(function(n,r){e.push({duration:n.duration,segmentIndex:i,partIndex:r,part:n,segment:t})}):e.push({duration:t.duration,segmentIndex:i,partIndex:null,segment:t,part:null}),e),[]),tD=s=>{const e=s.segments&&s.segments.length&&s.segments[s.segments.length-1];return e&&e.parts||[]},iD=({preloadSegment:s})=>{if(!s)return;const{parts:e,preloadHints:t}=s;let i=(t||[]).reduce((n,r)=>n+(r.type==="PART"?1:0),0);return i+=e&&e.length?e.length:0,i},sD=(s,e)=>{if(e.endList)return 0;if(s&&s.suggestedPresentationDelay)return s.suggestedPresentationDelay;const t=tD(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},pF=function(s,e){let t=0,i=e-s.mediaSequence,n=s.segments[i];if(n){if(typeof n.start<"u")return{result:n.start,precise:!0};if(typeof n.end<"u")return{result:n.end-n.duration,precise:!0}}for(;i--;){if(n=s.segments[i],typeof n.end<"u")return{result:t+n.end,precise:!0};if(t+=Qb(s,n),typeof n.start<"u")return{result:t+n.start,precise:!0}}return{result:t,precise:!1}},gF=function(s,e){let t=0,i,n=e-s.mediaSequence;for(;n<s.segments.length;n++){if(i=s.segments[n],typeof i.start<"u")return{result:i.start-t,precise:!0};if(t+=Qb(s,i),typeof i.end<"u")return{result:i.end-t,precise:!0}}return{result:-1,precise:!1}},nD=function(s,e,t){if(typeof e>"u"&&(e=s.mediaSequence+s.segments.length),e<s.mediaSequence)return 0;const i=pF(s,e);if(i.precise)return i.result;const n=gF(s,e);return n.precise?n.result:i.result+t},rD=function(s,e,t){if(!s)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(s.totalDuration)return s.totalDuration;if(!s.endList)return ye.Infinity}return nD(s,e,t)},kh=function({defaultDuration:s,durationList:e,startIndex:t,endIndex:i}){let n=0;if(t>i&&([t,i]=[i,t]),t<0){for(let r=t;r<Math.min(0,i);r++)n+=s;t=0}for(let r=t;r<i;r++)n+=e[r].duration;return n},aD=function(s,e,t,i){if(!s||!s.segments)return null;if(s.endList)return rD(s);if(e===null)return null;e=e||0;let n=nD(s,s.mediaSequence+s.segments.length,e);return t&&(i=typeof i=="number"?i:sD(null,s),n-=i),Math.max(0,n)},yF=function(s,e,t){const n=e||0;let r=aD(s,e,!0,t);return r===null?Rn():(r<n&&(r=n),Rn(n,r))},vF=function({playlist:s,currentTime:e,startingSegmentIndex:t,startingPartIndex:i,startTime:n,exactManifestTimings:r}){let a=e-n;const u=Lx(s);let c=0;for(let d=0;d<u.length;d++){const f=u[d];if(t===f.segmentIndex&&!(typeof i=="number"&&typeof f.partIndex=="number"&&i!==f.partIndex)){c=d;break}}if(a<0){if(c>0)for(let d=c-1;d>=0;d--){const f=u[d];if(a+=f.duration,r){if(a<0)continue}else if(a+Ha<=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n-kh({defaultDuration:s.targetDuration,durationList:u,startIndex:c,endIndex:d})}}return{partIndex:u[0]&&u[0].partIndex||null,segmentIndex:u[0]&&u[0].segmentIndex||0,startTime:e}}if(c<0){for(let d=c;d<0;d++)if(a-=s.targetDuration,a<0)return{partIndex:u[0]&&u[0].partIndex||null,segmentIndex:u[0]&&u[0].segmentIndex||0,startTime:e};c=0}for(let d=c;d<u.length;d++){const f=u[d];a-=f.duration;const g=f.duration>Ha,y=a===0,v=g&&a+Ha>=0;if(!((y||v)&&d!==u.length-1)){if(r){if(a>0)continue}else if(a-Ha>=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n+kh({defaultDuration:s.targetDuration,durationList:u,startIndex:c,endIndex:d})}}}return{segmentIndex:u[u.length-1].segmentIndex,partIndex:u[u.length-1].partIndex,startTime:e}},oD=function(s){return s.excludeUntil&&s.excludeUntil>Date.now()},Zb=function(s){return s.excludeUntil&&s.excludeUntil===1/0},Rp=function(s){const e=oD(s);return!s.disabled&&!e},xF=function(s){return s.disabled},bF=function(s){for(let e=0;e<s.segments.length;e++)if(s.segments[e].key)return!0;return!1},lD=function(s,e){return e.attributes&&e.attributes[s]},TF=function(s,e,t,i=0){return lD("BANDWIDTH",t)?(s*t.attributes.BANDWIDTH-i*8)/e:NaN},Rx=(s,e)=>{if(s.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return s.playlists.filter(i=>Rp(i)?(i.attributes.BANDWIDTH||0)<t:!1).length===0},Jb=(s,e)=>!s&&!e||!s&&e||s&&!e?!1:!!(s===e||s.id&&e.id&&s.id===e.id||s.resolvedUri&&e.resolvedUri&&s.resolvedUri===e.resolvedUri||s.uri&&e.uri&&s.uri===e.uri),kE=function(s,e){const t=s&&s.mediaGroups&&s.mediaGroups.AUDIO||{};let i=!1;for(const n in t){for(const r in t[n])if(i=e(t[n][r]),i)break;if(i)break}return!!i},tf=s=>{if(!s||!s.playlists||!s.playlists.length)return kE(s,t=>t.playlists&&t.playlists.length||t.uri);for(let e=0;e<s.playlists.length;e++){const t=s.playlists[e],i=t.attributes&&t.attributes.CODECS;if(!(i&&i.split(",").every(r=>bk(r))||kE(s,r=>Jb(t,r))))return!1}return!0};var xr={liveEdgeDelay:sD,duration:rD,seekable:yF,getMediaInfoForTime:vF,isEnabled:Rp,isDisabled:xF,isExcluded:oD,isIncompatible:Zb,playlistEnd:aD,isAes:bF,hasAttribute:lD,estimateSegmentRequestTime:TF,isLowestEnabledRendition:Rx,isAudioOnly:tf,playlistMatch:Jb,segmentDurationWithParts:Qb};const{log:uD}=He,Ec=(s,e)=>`${s}-${e}`,cD=(s,e,t)=>`placeholder-uri-${s}-${e}-${t}`,SF=({onwarn:s,oninfo:e,manifestString:t,customTagParsers:i=[],customTagMappers:n=[],llhls:r})=>{const a=new uP;s&&a.on("warn",s),e&&a.on("info",e),i.forEach(d=>a.addParser(d)),n.forEach(d=>a.addTagMapper(d)),a.push(t),a.end();const u=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(d){u.hasOwnProperty(d)&&delete u[d]}),u.segments&&u.segments.forEach(function(d){["parts","preloadHints"].forEach(function(f){d.hasOwnProperty(f)&&delete d[f]})})),!u.targetDuration){let d=10;u.segments&&u.segments.length&&(d=u.segments.reduce((f,g)=>Math.max(f,g.duration),0)),s&&s({message:`manifest has no targetDuration defaulting to ${d}`}),u.targetDuration=d}const c=tD(u);if(c.length&&!u.partTargetDuration){const d=c.reduce((f,g)=>Math.max(f,g.duration),0);s&&(s({message:`manifest has no partTargetDuration defaulting to ${d}`}),uD.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),u.partTargetDuration=d}return u},ed=(s,e)=>{s.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(s.mediaGroups[t])for(const i in s.mediaGroups[t])for(const n in s.mediaGroups[t][i]){const r=s.mediaGroups[t][i][n];e(r,t,i,n)}})},dD=({playlist:s,uri:e,id:t})=>{s.id=t,s.playlistErrors_=0,e&&(s.uri=e),s.attributes=s.attributes||{}},_F=s=>{let e=s.playlists.length;for(;e--;){const t=s.playlists[e];dD({playlist:t,id:Ec(e,t.uri)}),t.resolvedUri=yr(s.uri,t.uri),s.playlists[t.id]=t,s.playlists[t.uri]=t,t.attributes.BANDWIDTH||uD.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},EF=s=>{ed(s,e=>{e.uri&&(e.resolvedUri=yr(s.uri,e.uri))})},wF=(s,e)=>{const t=Ec(0,e),i={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:ye.location.href,resolvedUri:ye.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return i.playlists[t]=i.playlists[0],i.playlists[e]=i.playlists[0],i},hD=(s,e,t=cD)=>{s.uri=e;for(let n=0;n<s.playlists.length;n++)if(!s.playlists[n].uri){const r=`placeholder-uri-${n}`;s.playlists[n].uri=r}const i=tf(s);ed(s,(n,r,a,u)=>{if(!n.playlists||!n.playlists.length){if(i&&r==="AUDIO"&&!n.uri)for(let c=0;c<s.playlists.length;c++){const d=s.playlists[c];if(d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===a)return}n.playlists=[on({},n)]}n.playlists.forEach(function(c,d){const f=t(r,a,u,c),g=Ec(d,f);c.uri?c.resolvedUri=c.resolvedUri||yr(s.uri,c.uri):(c.uri=d===0?f:g,c.resolvedUri=c.uri),c.id=c.id||g,c.attributes=c.attributes||{},s.playlists[c.id]=c,s.playlists[c.uri]=c})}),_F(s),EF(s)};class CE{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,i=t.startDate.getTime();this.trimProcessedDateRanges_(i),this.pendingDateRanges_=e.reduce((n,r)=>(n.set(r.id,r),n),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((i,n)=>{if(!this.processedDateRanges_.has(n)&&(i.startTime=i.startDate.getTime()/1e3-this.offset_,i.processDateRange=()=>this.processDateRange(i),t.push(i),!!i.class))if(e[i.class]){const r=e[i.class].push(i);i.classListIndex=r-1}else e[i.class]=[i],i.classListIndex=0});for(const i of t){const n=e[i.class]||[];i.endDate?i.endTime=i.endDate.getTime()/1e3-this.offset_:i.endOnNext&&n[i.classListIndex+1]?i.endTime=n[i.classListIndex+1].startTime:i.duration?i.endTime=i.startTime+i.duration:i.plannedDuration?i.endTime=i.startTime+i.plannedDuration:i.endTime=i.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((i,n)=>{i.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const fD=22,xu=({requestType:s,request:e,error:t,parseFailure:i})=>{const n=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,a={uri:e.uri,requestType:s},u=n&&!r||i;if(t&&r)a.error=on({},t),a.errorType=He.Error.NetworkRequestFailed;else if(e.aborted)a.errorType=He.Error.NetworkRequestAborted;else if(e.timedout)a.errorType=He.Error.NetworkRequestTimeout;else if(u){const c=i?He.Error.NetworkBodyParserFailed:He.Error.NetworkBadStatus;a.errorType=c,a.status=e.status,a.headers=e.headers}return a},AF=na("CodecUtils"),mD=function(s){const e=s.attributes||{};if(e.CODECS)return Fa(e.CODECS)},pD=(s,e)=>{const t=e.attributes||{};return s&&s.mediaGroups&&s.mediaGroups.AUDIO&&t.AUDIO&&s.mediaGroups.AUDIO[t.AUDIO]},kF=(s,e)=>{if(!pD(s,e))return!0;const t=e.attributes||{},i=s.mediaGroups.AUDIO[t.AUDIO];for(const n in i)if(!i[n].uri&&!i[n].playlists)return!0;return!1},Fh=function(s){const e={};return s.forEach(({mediaType:t,type:i,details:n})=>{e[t]=e[t]||[],e[t].push(xk(`${i}${n}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){AF(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},DE=function(s){let e=0;return s.audio&&e++,s.video&&e++,e},Ch=function(s,e){const t=e.attributes||{},i=Fh(mD(e)||[]);if(pD(s,e)&&!i.audio&&!kF(s,e)){const n=Fh(dP(s,t.AUDIO)||[]);n.audio&&(i.audio=n.audio)}return i},{EventTarget:CF}=He,DF=(s,e)=>{if(e.endList||!e.serverControl)return s;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:i}=e;let n=e.mediaSequence+e.segments.length;if(i){const r=i.parts||[],a=iD(e)-1;a>-1&&a!==r.length-1&&(t._HLS_part=a),(a>-1||r.length)&&n--}t._HLS_msn=n}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const i=new ye.URL(s);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(n){t.hasOwnProperty(n)&&i.searchParams.set(n,t[n])}),s=i.toString()}return s},LF=(s,e)=>{if(!s)return e;const t=is(s,e);if(s.preloadHints&&!e.preloadHints&&delete t.preloadHints,s.parts&&!e.parts)delete t.parts;else if(s.parts&&e.parts)for(let i=0;i<e.parts.length;i++)s.parts&&s.parts[i]&&(t.parts[i]=is(s.parts[i],e.parts[i]));return!s.skipped&&e.skipped&&(t.skipped=!1),s.preload&&!e.preload&&(t.preload=!1),t},RF=(s,e,t)=>{const i=s.slice(),n=e.slice();t=t||0;const r=[];let a;for(let u=0;u<n.length;u++){const c=i[u+t],d=n[u];c?(a=c.map||a,r.push(LF(c,d))):(a&&!d.map&&(d.map=a),r.push(d))}return r},gD=(s,e)=>{!s.resolvedUri&&s.uri&&(s.resolvedUri=yr(e,s.uri)),s.key&&!s.key.resolvedUri&&(s.key.resolvedUri=yr(e,s.key.uri)),s.map&&!s.map.resolvedUri&&(s.map.resolvedUri=yr(e,s.map.uri)),s.map&&s.map.key&&!s.map.key.resolvedUri&&(s.map.key.resolvedUri=yr(e,s.map.key.uri)),s.parts&&s.parts.length&&s.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=yr(e,t.uri))}),s.preloadHints&&s.preloadHints.length&&s.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=yr(e,t.uri))})},yD=function(s){const e=s.segments||[],t=s.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let i=0;i<t.preloadHints.length;i++)if(t.preloadHints[i].type==="MAP")return e}t.duration=s.targetDuration,t.preload=!0,e.push(t)}return e},vD=(s,e)=>s===e||s.segments&&e.segments&&s.segments.length===e.segments.length&&s.endList===e.endList&&s.mediaSequence===e.mediaSequence&&s.preloadSegment===e.preloadSegment,Ix=(s,e,t=vD)=>{const i=is(s,{}),n=i.playlists[e.id];if(!n||t(n,e))return null;e.segments=yD(e);const r=is(n,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,n.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a<e.skip.skippedSegments;a++)e.segments.unshift({skipped:!0})}r.segments=RF(n.segments,e.segments,e.mediaSequence-n.mediaSequence)}r.segments.forEach(a=>{gD(a,r.resolvedUri)});for(let a=0;a<i.playlists.length;a++)i.playlists[a].id===e.id&&(i.playlists[a]=r);return i.playlists[e.id]=r,i.playlists[e.uri]=r,ed(s,(a,u,c,d)=>{if(a.playlists)for(let f=0;f<a.playlists.length;f++)e.id===a.playlists[f].id&&(a.playlists[f]=r)}),i},Nx=(s,e)=>{const t=s.segments||[],i=t[t.length-1],n=i&&i.parts&&i.parts[i.parts.length-1],r=n&&n.duration||i&&i.duration;return e&&r?r*1e3:(s.partTargetDuration||s.targetDuration||10)*500},LE=(s,e,t)=>{if(!s)return;const i=[];return s.forEach(n=>{if(!n.attributes)return;const{BANDWIDTH:r,RESOLUTION:a,CODECS:u}=n.attributes;i.push({id:n.id,bandwidth:r,resolution:a,codecs:u})}),{type:e,isLive:t,renditions:i}};let gc=class extends CF{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=na("PlaylistLoader");const{withCredentials:n=!1}=i;this.src=e,this.vhs_=t,this.withCredentials=n,this.addDateRangesToTextTrack_=i.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new CE,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=yr(this.main.uri,e.uri);this.llhls&&(t=DF(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(i,n)=>{if(this.request){if(i)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,i){const{uri:n,id:r}=t;this.request=null,i&&(this.state=i),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${n}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:xu({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{const i=SF({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls});return!i.playlists||!i.playlists.length||this.excludeAudioOnlyVariants(i.playlists),i}catch(i){this.error=i,this.error.metadata={errorType:He.Error.StreamingHlsPlaylistParserError,error:i}}}excludeAudioOnlyVariants(e){const t=i=>{const n=i.attributes||{},{width:r,height:a}=n.RESOLUTION||{};if(r&&a)return!0;const u=mD(i)||[];return!!Fh(u).video};e.some(t)&&e.forEach(i=>{t(i)||(i.excludeUntil=1/0)})}haveMetadata({playlistString:e,playlistObject:t,url:i,id:n}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:i}};this.trigger({type:"playlistparsestart",metadata:r});const a=t||this.parseManifest_({url:i,manifestString:e});a.lastRequest=Date.now(),dD({playlist:a,uri:i,id:n});const u=Ix(this.main,a);this.targetDuration=a.partTargetDuration||a.targetDuration,this.pendingMedia_=null,u?(this.main=u,this.media_=this.main.playlists[n]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(Nx(this.media(),!!u)),r.parsedPlaylist=LE(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),ye.clearTimeout(this.mediaUpdateTimeout),ye.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new CE,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(ye.clearTimeout(this.finalRenditionTimeout),t){const u=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=ye.setTimeout(this.media.bind(this,e,!1),u);return}const i=this.state,n=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(Nx(e,!0)),!n)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const a={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:a}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(u,c)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=B0(e.resolvedUri,c),u)return this.playlistRequestError(this.request,e,i);this.trigger({type:"playlistrequestcomplete",metadata:a}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const i=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=ye.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},i);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=ye.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=ye.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,i)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:i.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:i.responseText,code:2,metadata:xu({requestType:i.requestType,request:i,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=B0(this.src,i),this.trigger({type:"playlistparsestart",metadata:e});const n=this.parseManifest_({manifestString:i.responseText,url:this.src});e.parsedPlaylist=LE(n.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(n)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,hD(this.main,this.srcUri()),e.playlists.forEach(i=>{i.segments=yD(i),i.segments.forEach(n=>{gD(n,i.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||ye.location.href;this.main=wF(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const i=this.main,n=e.ID;let r=i.playlists.length;for(;r--;){const a=i.playlists[r];if(a.attributes["PATHWAY-ID"]===n){const u=a.resolvedUri,c=a.id;if(t){const d=this.createCloneURI_(a.resolvedUri,e),f=Ec(n,d),g=this.createCloneAttributes_(n,a.attributes),y=this.createClonePlaylist_(a,f,e,g);i.playlists[r]=y,i.playlists[f]=y,i.playlists[d]=y}else i.playlists.splice(r,1);delete i.playlists[c],delete i.playlists[u]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const i=this.main,n=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!i.mediaGroups[r]||!i.mediaGroups[r][n])){for(const a in i.mediaGroups[r])if(a===n){for(const u in i.mediaGroups[r][a])i.mediaGroups[r][a][u].playlists.forEach((d,f)=>{const g=i.playlists[d.id],y=g.id,v=g.resolvedUri;delete i.playlists[y],delete i.playlists[v]});delete i.mediaGroups[r][a]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const i=this.main,n=i.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),a=Ec(e.ID,r),u=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,a,e,u);i.playlists[n]=c,i.playlists[a]=c,i.playlists[r]=c,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,i=e["BASE-ID"],n=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||n.mediaGroups[r][t]))for(const a in n.mediaGroups[r]){if(a===i)n.mediaGroups[r][t]={};else continue;for(const u in n.mediaGroups[r][a]){const c=n.mediaGroups[r][a][u];n.mediaGroups[r][t][u]=on({},c);const d=n.mediaGroups[r][t][u],f=this.createCloneURI_(c.resolvedUri,e);d.resolvedUri=f,d.uri=f,d.playlists=[],c.playlists.forEach((g,y)=>{const v=n.playlists[g.id],T=cD(r,t,u),S=Ec(t,T);if(v&&!n.playlists[S]){const w=this.createClonePlaylist_(v,S,e),L=w.resolvedUri;n.playlists[S]=w,n.playlists[L]=w}d.playlists[y]=this.createClonePlaylist_(g,S,e)})}}})}createClonePlaylist_(e,t,i,n){const r=this.createCloneURI_(e.resolvedUri,i),a={resolvedUri:r,uri:r,id:t};return e.segments&&(a.segments=[]),n&&(a.attributes=n),is(e,a)}createCloneURI_(e,t){const i=new URL(e);i.hostname=t["URI-REPLACEMENT"].HOST;const n=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(n))i.searchParams.set(r,n[r]);return i.href}createCloneAttributes_(e,t){const i={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(n=>{t[n]&&(i[n]=e)}),i}getKeyIdSet(e){const t=new Set;if(!e||!e.contentProtection)return t;for(const i in e.contentProtection)if(e.contentProtection[i]&&e.contentProtection[i].attributes&&e.contentProtection[i].attributes.keyId){const n=e.contentProtection[i].attributes.keyId;t.add(n.toLowerCase())}return t}};const Ox=function(s,e,t,i){const n=s.responseType==="arraybuffer"?s.response:s.responseText;!e&&n&&(s.responseTime=Date.now(),s.roundTripTime=s.responseTime-s.requestTime,s.bytesReceived=n.byteLength||n.length,s.bandwidth||(s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3))),t.headers&&(s.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(s.timedout=!0),!e&&!s.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(s&&(n||s.responseText)))),i(e,s)},IF=(s,e)=>{if(!s||!s.size)return;let t=e;return s.forEach(i=>{t=i(t)}),t},NF=(s,e,t,i)=>{!s||!s.size||s.forEach(n=>{n(e,t,i)})},xD=function(){const s=function e(t,i){t=is({timeout:45e3},t);const n=e.beforeRequest||He.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||He.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||He.Vhs.xhr._responseCallbackSet;n&&typeof n=="function"&&(He.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(n));const u=He.Vhs.xhr.original===!0?He.xhr:He.Vhs.xhr,c=IF(r,t);r.delete(n);const d=u(c||t,function(g,y){return NF(a,d,g,y),Ox(d,g,y,i)}),f=d.abort;return d.abort=function(){return d.aborted=!0,f.apply(d,arguments)},d.uri=t.uri,d.requestType=t.requestType,d.requestTime=Date.now(),d};return s.original=!0,s},OF=function(s){let e;const t=s.offset;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=ye.BigInt(s.offset)+ye.BigInt(s.length)-ye.BigInt(1):e=s.offset+s.length-1,"bytes="+t+"-"+e},Mx=function(s){const e={};return s.byterange&&(e.Range=OF(s.byterange)),e},MF=function(s,e){return s.start(e)+"-"+s.end(e)},PF=function(s,e){const t=s.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},BF=function(s){return s>=32&&s<126?String.fromCharCode(s):"."},bD=function(s){const e={};return Object.keys(s).forEach(t=>{const i=s[t];Sk(i)?e[t]={bytes:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength}:e[t]=i}),e},F0=function(s){const e=s.byterange||{length:1/0,offset:0};return[e.length,e.offset,s.resolvedUri].join(",")},TD=function(s){return s.resolvedUri},SD=s=>{const e=Array.prototype.slice.call(s),t=16;let i="",n,r;for(let a=0;a<e.length/t;a++)n=e.slice(a*t,a*t+t).map(PF).join(""),r=e.slice(a*t,a*t+t).map(BF).join(""),i+=n+" "+r+`
`;return i},FF=({bytes:s})=>SD(s),UF=s=>{let e="",t;for(t=0;t<s.length;t++)e+=MF(s,t)+" ";return e};var jF=Object.freeze({__proto__:null,createTransferableMessage:bD,initSegmentId:F0,segmentKeyId:TD,hexDump:SD,tagDump:FF,textRanges:UF});const _D=.25,$F=(s,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,r=s-n;return new Date(e.dateTimeObject.getTime()+r*1e3)},HF=s=>s.transmuxedPresentationEnd-s.transmuxedPresentationStart-s.transmuxerPrependedSeconds,zF=(s,e)=>{let t;try{t=new Date(s)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let i=e.segments[0];if(t<new Date(i.dateTimeObject))return null;for(let c=0;c<e.segments.length-1;c++){i=e.segments[c];const d=new Date(e.segments[c+1].dateTimeObject);if(t<d)break}const n=e.segments[e.segments.length-1],r=n.dateTimeObject,a=n.videoTimingInfo?HF(n.videoTimingInfo):n.duration+n.duration*_D,u=new Date(r.getTime()+a*1e3);return t>u?null:(t>new Date(r)&&(i=n),{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:xr.duration(e,e.mediaSequence+e.segments.indexOf(i)),type:i.videoTimingInfo?"accurate":"estimate"})},VF=(s,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,i;for(let r=0;r<e.segments.length&&(i=e.segments[r],t=i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationEnd:t+i.duration,!(s<=t));r++);const n=e.segments[e.segments.length-1];if(n.videoTimingInfo&&n.videoTimingInfo.transmuxedPresentationEnd<s)return null;if(s>t){if(s>t+n.duration*_D)return null;i=n}return{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:t-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}},GF=(s,e)=>{let t,i;try{t=new Date(s),i=new Date(e)}catch{}const n=t.getTime();return(i.getTime()-n)/1e3},qF=s=>{if(!s.segments||s.segments.length===0)return!1;for(let e=0;e<s.segments.length;e++)if(!s.segments[e].dateTimeObject)return!1;return!0},KF=({playlist:s,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!s||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const i=VF(e,s);if(!i)return t({message:"valid programTime was not found"});if(i.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:i.estimatedStart});const n={mediaSeconds:e},r=$F(e,i.segment);return r&&(n.programDateTime=r.toISOString()),t(null,n)},ED=({programTime:s,playlist:e,retryCount:t=2,seekTo:i,pauseAfterSeek:n=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof s>"u"||!e||!i)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!qF(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const u=zF(s,e);if(!u)return a({message:`${s} was not found in the stream`});const c=u.segment,d=GF(c.dateTimeObject,s);if(u.type==="estimate"){if(t===0)return a({message:`${s} is not buffered yet. Try again`});i(u.estimatedStart+d),r.one("seeked",()=>{ED({programTime:s,playlist:e,retryCount:t-1,seekTo:i,pauseAfterSeek:n,tech:r,callback:a})});return}const f=c.start+d,g=()=>a(null,r.currentTime());r.one("seeked",g),n&&r.pause(),i(f)},Tv=(s,e)=>{if(s.readyState===4)return e()},WF=(s,e,t,i)=>{let n=[],r,a=!1;const u=function(g,y,v,T){return y.abort(),a=!0,t(g,y,v,T)},c=function(g,y){if(a)return;if(g)return g.metadata=xu({requestType:i,request:y,error:g}),u(g,y,"",n);const v=y.responseText.substring(n&&n.byteLength||0,y.responseText.length);if(n=TP(n,_k(v,!0)),r=r||hh(n),n.length<10||r&&n.length<r+2)return Tv(y,()=>u(g,y,"",n));const T=_b(n);return T==="ts"&&n.length<188?Tv(y,()=>u(g,y,"",n)):!T&&n.length<376?Tv(y,()=>u(g,y,"",n)):u(null,y,T,n)},f=e({uri:s,beforeSend(g){g.overrideMimeType("text/plain; charset=x-user-defined"),g.addEventListener("progress",function({total:y,loaded:v}){return Ox(g,null,{statusCode:g.status},c)})}},function(g,y){return Ox(f,g,y,c)});return f},{EventTarget:YF}=He,RE=function(s,e){if(!vD(s,e)||s.sidx&&e.sidx&&(s.sidx.offset!==e.sidx.offset||s.sidx.length!==e.sidx.length))return!1;if(!s.sidx&&e.sidx||s.sidx&&!e.sidx||s.segments&&!e.segments||!s.segments&&e.segments)return!1;if(!s.segments&&!e.segments)return!0;for(let t=0;t<s.segments.length;t++){const i=s.segments[t],n=e.segments[t];if(i.uri!==n.uri)return!1;if(!i.byterange&&!n.byterange)continue;const r=i.byterange,a=n.byterange;if(r&&!a||!r&&a||r.offset!==a.offset||r.length!==a.length)return!1}return!0},XF=(s,e,t,i)=>{const n=i.attributes.NAME||t;return`placeholder-uri-${s}-${e}-${n}`},QF=({mainXml:s,srcUrl:e,clientOffset:t,sidxMapping:i,previousManifest:n})=>{const r=x4(s,{manifestUri:e,clientOffset:t,sidxMapping:i,previousManifest:n});return hD(r,e,XF),r},ZF=(s,e)=>{ed(s,(t,i,n,r)=>{(!e.mediaGroups[i][n]||!(r in e.mediaGroups[i][n]))&&delete s.mediaGroups[i][n][r]})},JF=(s,e,t)=>{let i=!0,n=is(s,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const a=e.playlists[r];if(a.sidx){const c=fp(a.sidx);t&&t[c]&&t[c].sidx&&bb(a,t[c].sidx,a.sidx.resolvedUri)}const u=Ix(n,a,RE);u&&(n=u,i=!1)}return ed(e,(r,a,u,c)=>{if(r.playlists&&r.playlists.length){const d=r.playlists[0].id,f=Ix(n,r.playlists[0],RE);f&&(n=f,c in n.mediaGroups[a][u]||(n.mediaGroups[a][u][c]=r),n.mediaGroups[a][u][c].playlists[0]=n.playlists[d],i=!1)}}),ZF(n,e),e.minimumUpdatePeriod!==s.minimumUpdatePeriod&&(i=!1),i?null:n},e8=(s,e)=>(!s.map&&!e.map||!!(s.map&&e.map&&s.map.byterange.offset===e.map.byterange.offset&&s.map.byterange.length===e.map.byterange.length))&&s.uri===e.uri&&s.byterange.offset===e.byterange.offset&&s.byterange.length===e.byterange.length,IE=(s,e)=>{const t={};for(const i in s){const r=s[i].sidx;if(r){const a=fp(r);if(!e[a])break;const u=e[a].sidxInfo;e8(u,r)&&(t[a]=e[a])}}return t},t8=(s,e)=>{let i=IE(s.playlists,e);return ed(s,(n,r,a,u)=>{if(n.playlists&&n.playlists.length){const c=n.playlists;i=is(i,IE(c,e))}}),i};class Px extends YF{constructor(e,t,i={},n){super(),this.isPaused_=!0,this.mainPlaylistLoader_=n||this,n||(this.isMain_=!0);const{withCredentials:r=!1}=i;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=i.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=na("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,i){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},i&&(this.state=i),this.trigger("error"),!0}addSidxSegments_(e,t,i){const n=e.sidx&&fp(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){ye.clearTimeout(this.mediaRequest_),this.mediaRequest_=ye.setTimeout(()=>i(!1),0);return}const r=B0(e.sidx.resolvedUri),a=(c,d)=>{if(this.requestErrored_(c,d,t))return;const f=this.mainPlaylistLoader_.sidxMapping_,{requestType:g}=d;let y;try{y=E4(si(d.response).subarray(8))}catch(v){v.metadata=xu({requestType:g,request:d,parseFailure:!0}),this.requestErrored_(v,d,t);return}return f[n]={sidxInfo:e.sidx,sidx:y},bb(e,y,e.sidx.resolvedUri),i(!0)},u="dash-sidx";this.request=WF(r,this.vhs_.xhr,(c,d,f,g)=>{if(c)return a(c,d);if(!f||f!=="mp4"){const T=f||"unknown";return a({status:d.status,message:`Unsupported ${T} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},d)}const{offset:y,length:v}=e.sidx.byterange;if(g.length>=v+y)return a(c,{response:g.subarray(y,y+v),status:d.status,uri:d.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:Mx({byterange:e.sidx.byterange})},a)},u)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},ye.clearTimeout(this.minimumUpdatePeriodTimeout_),ye.clearTimeout(this.mediaRequest_),ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const i=!this.media_||e.id!==this.media_.id;if(i&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,i&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}i&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,n=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,ye.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(ye.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,ye.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const i=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ye.setTimeout(()=>this.load(),i);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){ye.clearTimeout(this.mediaRequest_),this.mediaRequest_=ye.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(i,n)=>{if(i){const{requestType:a}=n;i.metadata=xu({requestType:a,request:n,error:i})}if(this.requestErrored_(i,n)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=n.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?this.mainLoaded_=Date.parse(n.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=B0(this.mainPlaylistLoader_.srcUrl,n),r){this.handleMain_(),this.syncClientServerClock_(()=>e(n,r));return}return e(n,r)})}syncClientServerClock_(e){const t=b4(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:yr(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(i,n)=>{if(!this.request)return;if(i){const{requestType:a}=n;return this.error.metadata=xu({requestType:a,request:n,error:i}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!n.responseHeaders||!n.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(n.responseHeaders.date):r=Date.parse(n.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){ye.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let i;try{i=QF({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:He.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(i=JF(e,i,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=i||e;const n=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(n&&n!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=n),(!e||i&&i.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(i),i){const{duration:r,endList:a}=i,u=[];i.playlists.forEach(d=>{u.push({id:d.id,bandwidth:d.attributes.BANDWIDTH,resolution:d.attributes.RESOLUTION,codecs:d.attributes.CODECS})});const c={duration:r,isLive:!a,renditions:u};t.parsedManifest=c,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!i}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(ye.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=ye.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=t8(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,i=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,i=!this.media_||this.media_!==t[e];if(i?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const n=()=>{this.media().endList||(this.mediaUpdateTimeout=ye.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},Nx(this.media(),!!i)))};n()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(i=>({cueTime:i.start,frames:[{data:i.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const i in e.contentProtection){const n=e.contentProtection[i].attributes["cenc:default_KID"];n&&t.add(n.replace(/-/g,"").toLowerCase())}return t}}}var Dn={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const i8=s=>{const e=new Uint8Array(new ArrayBuffer(s.length));for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e.buffer},wD=function(s){return s.on=s.addEventListener,s.off=s.removeEventListener,s},s8=function(s){try{return URL.createObjectURL(new Blob([s],{type:"application/javascript"}))}catch{const t=new BlobBuilder;return t.append(s),URL.createObjectURL(t.getBlob())}},AD=function(s){return function(){const e=s8(s),t=wD(new Worker(e));t.objURL=e;const i=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),i.call(this)},t}},kD=function(s){return`var browserWorkerPolyFill = ${wD.toString()};
browserWorkerPolyFill(self);
`+s},CD=function(s){return s.toString().replace(/^function.+?{/,"").slice(0,-1)},n8=kD(CD(function(){var s=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=function(){this.init=function(){var x={};this.on=function(A,D){x[A]||(x[A]=[]),x[A]=x[A].concat(D)},this.off=function(A,D){var C;return x[A]?(C=x[A].indexOf(D),x[A]=x[A].slice(),x[A].splice(C,1),C>-1):!1},this.trigger=function(A){var D,C,M,B;if(D=x[A],!!D)if(arguments.length===2)for(M=D.length,C=0;C<M;++C)D[C].call(this,arguments[1]);else{for(B=[],C=arguments.length,C=1;C<arguments.length;++C)B.push(arguments[C]);for(M=D.length,C=0;C<M;++C)D[C].apply(this,B)}},this.dispose=function(){x={}}}};e.prototype.pipe=function(x){return this.on("data",function(A){x.push(A)}),this.on("done",function(A){x.flush(A)}),this.on("partialdone",function(A){x.partialFlush(A)}),this.on("endedtimeline",function(A){x.endTimeline(A)}),this.on("reset",function(A){x.reset(A)}),x},e.prototype.push=function(x){this.trigger("data",x)},e.prototype.flush=function(x){this.trigger("done",x)},e.prototype.partialFlush=function(x){this.trigger("partialdone",x)},e.prototype.endTimeline=function(x){this.trigger("endedtimeline",x)},e.prototype.reset=function(x){this.trigger("reset",x)};var t=e,i=Math.pow(2,32),n=function(x){var A=new DataView(x.buffer,x.byteOffset,x.byteLength),D;return A.getBigUint64?(D=A.getBigUint64(0),D<Number.MAX_SAFE_INTEGER?Number(D):D):A.getUint32(0)*i+A.getUint32(4)},r={getUint64:n,MAX_UINT32:i},a=r.MAX_UINT32,u,c,d,f,g,y,v,T,S,w,L,O,I,j,P,G,N,K,k,R,Y,z,X,re,J,W,q,Z,te,oe,F,le,ge,Ie,Le,Pe;(function(){var x;if(X={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(x in X)X.hasOwnProperty(x)&&(X[x]=[x.charCodeAt(0),x.charCodeAt(1),x.charCodeAt(2),x.charCodeAt(3)]);re=new Uint8Array([105,115,111,109]),W=new Uint8Array([97,118,99,49]),J=new Uint8Array([0,0,0,1]),q=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]),Z=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]),te={video:q,audio:Z},le=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),F=new Uint8Array([0,0,0,0,0,0,0,0]),ge=new Uint8Array([0,0,0,0,0,0,0,0]),Ie=ge,Le=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Pe=ge,oe=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),u=function(x){var A=[],D=0,C,M,B;for(C=1;C<arguments.length;C++)A.push(arguments[C]);for(C=A.length;C--;)D+=A[C].byteLength;for(M=new Uint8Array(D+8),B=new DataView(M.buffer,M.byteOffset,M.byteLength),B.setUint32(0,M.byteLength),M.set(x,4),C=0,D=8;C<A.length;C++)M.set(A[C],D),D+=A[C].byteLength;return M},c=function(){return u(X.dinf,u(X.dref,le))},d=function(x){return u(X.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,x.audioobjecttype<<3|x.samplingfrequencyindex>>>1,x.samplingfrequencyindex<<7|x.channelcount<<3,6,1,2]))},f=function(){return u(X.ftyp,re,J,re,W)},G=function(x){return u(X.hdlr,te[x])},g=function(x){return u(X.mdat,x)},P=function(x){var A=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,x.duration>>>24&255,x.duration>>>16&255,x.duration>>>8&255,x.duration&255,85,196,0,0]);return x.samplerate&&(A[12]=x.samplerate>>>24&255,A[13]=x.samplerate>>>16&255,A[14]=x.samplerate>>>8&255,A[15]=x.samplerate&255),u(X.mdhd,A)},j=function(x){return u(X.mdia,P(x),G(x.type),v(x))},y=function(x){return u(X.mfhd,new Uint8Array([0,0,0,0,(x&4278190080)>>24,(x&16711680)>>16,(x&65280)>>8,x&255]))},v=function(x){return u(X.minf,x.type==="video"?u(X.vmhd,oe):u(X.smhd,F),c(),K(x))},T=function(x,A){for(var D=[],C=A.length;C--;)D[C]=R(A[C]);return u.apply(null,[X.moof,y(x)].concat(D))},S=function(x){for(var A=x.length,D=[];A--;)D[A]=O(x[A]);return u.apply(null,[X.moov,L(4294967295)].concat(D).concat(w(x)))},w=function(x){for(var A=x.length,D=[];A--;)D[A]=Y(x[A]);return u.apply(null,[X.mvex].concat(D))},L=function(x){var A=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(x&4278190080)>>24,(x&16711680)>>16,(x&65280)>>8,x&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 u(X.mvhd,A)},N=function(x){var A=x.samples||[],D=new Uint8Array(4+A.length),C,M;for(M=0;M<A.length;M++)C=A[M].flags,D[M+4]=C.dependsOn<<4|C.isDependedOn<<2|C.hasRedundancy;return u(X.sdtp,D)},K=function(x){return u(X.stbl,k(x),u(X.stts,Pe),u(X.stsc,Ie),u(X.stsz,Le),u(X.stco,ge))},(function(){var x,A;k=function(D){return u(X.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),D.type==="video"?x(D):A(D))},x=function(D){var C=D.sps||[],M=D.pps||[],B=[],ae=[],de,he;for(de=0;de<C.length;de++)B.push((C[de].byteLength&65280)>>>8),B.push(C[de].byteLength&255),B=B.concat(Array.prototype.slice.call(C[de]));for(de=0;de<M.length;de++)ae.push((M[de].byteLength&65280)>>>8),ae.push(M[de].byteLength&255),ae=ae.concat(Array.prototype.slice.call(M[de]));if(he=[X.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,(D.width&65280)>>8,D.width&255,(D.height&65280)>>8,D.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u(X.avcC,new Uint8Array([1,D.profileIdc,D.profileCompatibility,D.levelIdc,255].concat([C.length],B,[M.length],ae))),u(X.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],D.sarRatio){var ve=D.sarRatio[0],Ce=D.sarRatio[1];he.push(u(X.pasp,new Uint8Array([(ve&4278190080)>>24,(ve&16711680)>>16,(ve&65280)>>8,ve&255,(Ce&4278190080)>>24,(Ce&16711680)>>16,(Ce&65280)>>8,Ce&255])))}return u.apply(null,he)},A=function(D){return u(X.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(D.channelcount&65280)>>8,D.channelcount&255,(D.samplesize&65280)>>8,D.samplesize&255,0,0,0,0,(D.samplerate&65280)>>8,D.samplerate&255,0,0]),d(D))}})(),I=function(x){var A=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(x.id&4278190080)>>24,(x.id&16711680)>>16,(x.id&65280)>>8,x.id&255,0,0,0,0,(x.duration&4278190080)>>24,(x.duration&16711680)>>16,(x.duration&65280)>>8,x.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(x.width&65280)>>8,x.width&255,0,0,(x.height&65280)>>8,x.height&255,0,0]);return u(X.tkhd,A)},R=function(x){var A,D,C,M,B,ae,de;return A=u(X.tfhd,new Uint8Array([0,0,0,58,(x.id&4278190080)>>24,(x.id&16711680)>>16,(x.id&65280)>>8,x.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),ae=Math.floor(x.baseMediaDecodeTime/a),de=Math.floor(x.baseMediaDecodeTime%a),D=u(X.tfdt,new Uint8Array([1,0,0,0,ae>>>24&255,ae>>>16&255,ae>>>8&255,ae&255,de>>>24&255,de>>>16&255,de>>>8&255,de&255])),B=92,x.type==="audio"?(C=z(x,B),u(X.traf,A,D,C)):(M=N(x),C=z(x,M.length+B),u(X.traf,A,D,C,M))},O=function(x){return x.duration=x.duration||4294967295,u(X.trak,I(x),j(x))},Y=function(x){var A=new Uint8Array([0,0,0,0,(x.id&4278190080)>>24,(x.id&16711680)>>16,(x.id&65280)>>8,x.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return x.type!=="video"&&(A[A.length-1]=0),u(X.trex,A)},(function(){var x,A,D;D=function(C,M){var B=0,ae=0,de=0,he=0;return C.length&&(C[0].duration!==void 0&&(B=1),C[0].size!==void 0&&(ae=2),C[0].flags!==void 0&&(de=4),C[0].compositionTimeOffset!==void 0&&(he=8)),[0,0,B|ae|de|he,1,(C.length&4278190080)>>>24,(C.length&16711680)>>>16,(C.length&65280)>>>8,C.length&255,(M&4278190080)>>>24,(M&16711680)>>>16,(M&65280)>>>8,M&255]},A=function(C,M){var B,ae,de,he,ve,Ce;for(he=C.samples||[],M+=20+16*he.length,de=D(he,M),ae=new Uint8Array(de.length+he.length*16),ae.set(de),B=de.length,Ce=0;Ce<he.length;Ce++)ve=he[Ce],ae[B++]=(ve.duration&4278190080)>>>24,ae[B++]=(ve.duration&16711680)>>>16,ae[B++]=(ve.duration&65280)>>>8,ae[B++]=ve.duration&255,ae[B++]=(ve.size&4278190080)>>>24,ae[B++]=(ve.size&16711680)>>>16,ae[B++]=(ve.size&65280)>>>8,ae[B++]=ve.size&255,ae[B++]=ve.flags.isLeading<<2|ve.flags.dependsOn,ae[B++]=ve.flags.isDependedOn<<6|ve.flags.hasRedundancy<<4|ve.flags.paddingValue<<1|ve.flags.isNonSyncSample,ae[B++]=ve.flags.degradationPriority&61440,ae[B++]=ve.flags.degradationPriority&15,ae[B++]=(ve.compositionTimeOffset&4278190080)>>>24,ae[B++]=(ve.compositionTimeOffset&16711680)>>>16,ae[B++]=(ve.compositionTimeOffset&65280)>>>8,ae[B++]=ve.compositionTimeOffset&255;return u(X.trun,ae)},x=function(C,M){var B,ae,de,he,ve,Ce;for(he=C.samples||[],M+=20+8*he.length,de=D(he,M),B=new Uint8Array(de.length+he.length*8),B.set(de),ae=de.length,Ce=0;Ce<he.length;Ce++)ve=he[Ce],B[ae++]=(ve.duration&4278190080)>>>24,B[ae++]=(ve.duration&16711680)>>>16,B[ae++]=(ve.duration&65280)>>>8,B[ae++]=ve.duration&255,B[ae++]=(ve.size&4278190080)>>>24,B[ae++]=(ve.size&16711680)>>>16,B[ae++]=(ve.size&65280)>>>8,B[ae++]=ve.size&255;return u(X.trun,B)},z=function(C,M){return C.type==="audio"?x(C,M):A(C,M)}})();var Je={ftyp:f,mdat:g,moof:T,moov:S,initSegment:function(x){var A=f(),D=S(x),C;return C=new Uint8Array(A.byteLength+D.byteLength),C.set(A),C.set(D,A.byteLength),C}},Se=function(x){var A,D,C=[],M=[];for(M.byteLength=0,M.nalCount=0,M.duration=0,C.byteLength=0,A=0;A<x.length;A++)D=x[A],D.nalUnitType==="access_unit_delimiter_rbsp"?(C.length&&(C.duration=D.dts-C.dts,M.byteLength+=C.byteLength,M.nalCount+=C.length,M.duration+=C.duration,M.push(C)),C=[D],C.byteLength=D.data.byteLength,C.pts=D.pts,C.dts=D.dts):(D.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(C.keyFrame=!0),C.duration=D.dts-C.dts,C.byteLength+=D.data.byteLength,C.push(D));return M.length&&(!C.duration||C.duration<=0)&&(C.duration=M[M.length-1].duration),M.byteLength+=C.byteLength,M.nalCount+=C.length,M.duration+=C.duration,M.push(C),M},Re=function(x){var A,D,C=[],M=[];for(C.byteLength=0,C.nalCount=0,C.duration=0,C.pts=x[0].pts,C.dts=x[0].dts,M.byteLength=0,M.nalCount=0,M.duration=0,M.pts=x[0].pts,M.dts=x[0].dts,A=0;A<x.length;A++)D=x[A],D.keyFrame?(C.length&&(M.push(C),M.byteLength+=C.byteLength,M.nalCount+=C.nalCount,M.duration+=C.duration),C=[D],C.nalCount=D.length,C.byteLength=D.byteLength,C.pts=D.pts,C.dts=D.dts,C.duration=D.duration):(C.duration+=D.duration,C.nalCount+=D.length,C.byteLength+=D.byteLength,C.push(D));return M.length&&C.duration<=0&&(C.duration=M[M.length-1].duration),M.byteLength+=C.byteLength,M.nalCount+=C.nalCount,M.duration+=C.duration,M.push(C),M},Ve=function(x){var A;return!x[0][0].keyFrame&&x.length>1&&(A=x.shift(),x.byteLength-=A.byteLength,x.nalCount-=A.nalCount,x[0][0].dts=A.dts,x[0][0].pts=A.pts,x[0][0].duration+=A.duration),x},Ee=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},_e=function(x,A){var D=Ee();return D.dataOffset=A,D.compositionTimeOffset=x.pts-x.dts,D.duration=x.duration,D.size=4*x.length,D.size+=x.byteLength,x.keyFrame&&(D.flags.dependsOn=2,D.flags.isNonSyncSample=0),D},yt=function(x,A){var D,C,M,B,ae,de=A||0,he=[];for(D=0;D<x.length;D++)for(B=x[D],C=0;C<B.length;C++)ae=B[C],M=_e(ae,de),de+=M.size,he.push(M);return he},ut=function(x){var A,D,C,M,B,ae,de=0,he=x.byteLength,ve=x.nalCount,Ce=he+4*ve,et=new Uint8Array(Ce),At=new DataView(et.buffer);for(A=0;A<x.length;A++)for(M=x[A],D=0;D<M.length;D++)for(B=M[D],C=0;C<B.length;C++)ae=B[C],At.setUint32(de,ae.data.byteLength),de+=4,et.set(ae.data,de),de+=ae.data.byteLength;return et},pt=function(x,A){var D,C=A||0,M=[];return D=_e(x,C),M.push(D),M},Fe=function(x){var A,D,C=0,M=x.byteLength,B=x.length,ae=M+4*B,de=new Uint8Array(ae),he=new DataView(de.buffer);for(A=0;A<x.length;A++)D=x[A],he.setUint32(C,D.data.byteLength),C+=4,de.set(D.data,C),C+=D.data.byteLength;return de},_t={groupNalsIntoFrames:Se,groupFramesIntoGops:Re,extendFirstKeyFrame:Ve,generateSampleTable:yt,concatenateNalData:ut,generateSampleTableForFrame:pt,concatenateNalDataForFrame:Fe},Qe=[33,16,5,32,164,27],Xe=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],ze=function(x){for(var A=[];x--;)A.push(0);return A},Ze=function(x){return Object.keys(x).reduce(function(A,D){return A[D]=new Uint8Array(x[D].reduce(function(C,M){return C.concat(M)},[])),A},{})},ct,St=function(){if(!ct){var x={96e3:[Qe,[227,64],ze(154),[56]],88200:[Qe,[231],ze(170),[56]],64e3:[Qe,[248,192],ze(240),[56]],48e3:[Qe,[255,192],ze(268),[55,148,128],ze(54),[112]],44100:[Qe,[255,192],ze(268),[55,163,128],ze(84),[112]],32e3:[Qe,[255,192],ze(268),[55,234],ze(226),[112]],24e3:[Qe,[255,192],ze(268),[55,255,128],ze(268),[111,112],ze(126),[224]],16e3:[Qe,[255,192],ze(268),[55,255,128],ze(268),[111,255],ze(269),[223,108],ze(195),[1,192]],12e3:[Xe,ze(268),[3,127,248],ze(268),[6,255,240],ze(268),[13,255,224],ze(268),[27,253,128],ze(259),[56]],11025:[Xe,ze(268),[3,127,248],ze(268),[6,255,240],ze(268),[13,255,224],ze(268),[27,255,192],ze(268),[55,175,128],ze(108),[112]],8e3:[Xe,ze(268),[3,121,16],ze(47),[7]]};ct=Ze(x)}return ct},se=9e4,ke,De,Ue,at,dt,wt,kt;ke=function(x){return x*se},De=function(x,A){return x*A},Ue=function(x){return x/se},at=function(x,A){return x/A},dt=function(x,A){return ke(at(x,A))},wt=function(x,A){return De(Ue(x),A)},kt=function(x,A,D){return Ue(D?x:x-A)};var Tt={ONE_SECOND_IN_TS:se,secondsToVideoTs:ke,secondsToAudioTs:De,videoTsToSeconds:Ue,audioTsToSeconds:at,audioTsToVideoTs:dt,videoTsToAudioTs:wt,metadataTsToSeconds:kt},Ft=St,Qt=Tt,Zt=function(x){var A,D,C=0;for(A=0;A<x.length;A++)D=x[A],C+=D.data.byteLength;return C},Et=function(x,A,D,C){var M,B=0,ae=0,de=0,he=0,ve,Ce,et;if(A.length&&(M=Qt.audioTsToVideoTs(x.baseMediaDecodeTime,x.samplerate),B=Math.ceil(Qt.ONE_SECOND_IN_TS/(x.samplerate/1024)),D&&C&&(ae=M-Math.max(D,C),de=Math.floor(ae/B),he=de*B),!(de<1||he>Qt.ONE_SECOND_IN_TS/2))){for(ve=Ft()[x.samplerate],ve||(ve=A[0].data),Ce=0;Ce<de;Ce++)et=A[0],A.splice(0,0,{data:ve,dts:et.dts-B,pts:et.pts-B});return x.baseMediaDecodeTime-=Math.floor(Qt.videoTsToAudioTs(he,x.samplerate)),he}},Dt=function(x,A,D){return A.minSegmentDts>=D?x:(A.minSegmentDts=1/0,x.filter(function(C){return C.dts>=D?(A.minSegmentDts=Math.min(A.minSegmentDts,C.dts),A.minSegmentPts=A.minSegmentDts,!0):!1}))},yi=function(x){var A,D,C=[];for(A=0;A<x.length;A++)D=x[A],C.push({size:D.data.byteLength,duration:1024});return C},Pi=function(x){var A,D,C=0,M=new Uint8Array(Zt(x));for(A=0;A<x.length;A++)D=x[A],M.set(D.data,C),C+=D.data.byteLength;return M},Jt={prefixWithSilence:Et,trimAdtsFramesByEarliestDts:Dt,generateSampleTable:yi,concatenateFrameData:Pi},ki=Tt.ONE_SECOND_IN_TS,gt=function(x,A){typeof A.pts=="number"&&(x.timelineStartInfo.pts===void 0&&(x.timelineStartInfo.pts=A.pts),x.minSegmentPts===void 0?x.minSegmentPts=A.pts:x.minSegmentPts=Math.min(x.minSegmentPts,A.pts),x.maxSegmentPts===void 0?x.maxSegmentPts=A.pts:x.maxSegmentPts=Math.max(x.maxSegmentPts,A.pts)),typeof A.dts=="number"&&(x.timelineStartInfo.dts===void 0&&(x.timelineStartInfo.dts=A.dts),x.minSegmentDts===void 0?x.minSegmentDts=A.dts:x.minSegmentDts=Math.min(x.minSegmentDts,A.dts),x.maxSegmentDts===void 0?x.maxSegmentDts=A.dts:x.maxSegmentDts=Math.max(x.maxSegmentDts,A.dts))},V=function(x){delete x.minSegmentDts,delete x.maxSegmentDts,delete x.minSegmentPts,delete x.maxSegmentPts},$=function(x,A){var D,C,M=x.minSegmentDts;return A||(M-=x.timelineStartInfo.dts),D=x.timelineStartInfo.baseMediaDecodeTime,D+=M,D=Math.max(0,D),x.type==="audio"&&(C=x.samplerate/ki,D*=C,D=Math.floor(D)),D},ie={clearDtsInfo:V,calculateTrackBaseMediaDecodeTime:$,collectDtsInfo:gt},Te=4,Be=128,ht=function(x){for(var A=0,D={payloadType:-1,payloadSize:0},C=0,M=0;A<x.byteLength&&x[A]!==Be;){for(;x[A]===255;)C+=255,A++;for(C+=x[A++];x[A]===255;)M+=255,A++;if(M+=x[A++],!D.payload&&C===Te){var B=String.fromCharCode(x[A+3],x[A+4],x[A+5],x[A+6]);if(B==="GA94"){D.payloadType=C,D.payloadSize=M,D.payload=x.subarray(A,A+M);break}else D.payload=void 0}A+=M,C=0,M=0}return D},It=function(x){return x.payload[0]!==181||(x.payload[1]<<8|x.payload[2])!==49||String.fromCharCode(x.payload[3],x.payload[4],x.payload[5],x.payload[6])!=="GA94"||x.payload[7]!==3?null:x.payload.subarray(8,x.payload.length-1)},Yt=function(x,A){var D=[],C,M,B,ae;if(!(A[0]&64))return D;for(M=A[0]&31,C=0;C<M;C++)B=C*3,ae={type:A[B+2]&3,pts:x},A[B+2]&4&&(ae.ccData=A[B+3]<<8|A[B+4],D.push(ae));return D},pi=function(x){for(var A=x.byteLength,D=[],C=1,M,B;C<A-2;)x[C]===0&&x[C+1]===0&&x[C+2]===3?(D.push(C+2),C+=2):C++;if(D.length===0)return x;M=A-D.length,B=new Uint8Array(M);var ae=0;for(C=0;C<M;ae++,C++)ae===D[0]&&(ae++,D.shift()),B[C]=x[ae];return B},oi={parseSei:ht,parseUserData:It,parseCaptionPackets:Yt,discardEmulationPreventionBytes:pi,USER_DATA_REGISTERED_ITU_T_T35:Te},ci=t,Bi=oi,Gt=function(x){x=x||{},Gt.prototype.init.call(this),this.parse708captions_=typeof x.parse708captions=="boolean"?x.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new fi(0,0),new fi(0,1),new fi(1,0),new fi(1,1)],this.parse708captions_&&(this.cc708Stream_=new vt({captionServices:x.captionServices})),this.reset(),this.ccStreams_.forEach(function(A){A.on("data",this.trigger.bind(this,"data")),A.on("partialdone",this.trigger.bind(this,"partialdone")),A.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};Gt.prototype=new ci,Gt.prototype.push=function(x){var A,D,C;if(x.nalUnitType==="sei_rbsp"&&(A=Bi.parseSei(x.escapedRBSP),!!A.payload&&A.payloadType===Bi.USER_DATA_REGISTERED_ITU_T_T35&&(D=Bi.parseUserData(A),!!D))){if(x.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(x.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}C=Bi.parseCaptionPackets(x.pts,D),this.captionPackets_=this.captionPackets_.concat(C),this.latestDts_!==x.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=x.dts}},Gt.prototype.flushCCStreams=function(x){this.ccStreams_.forEach(function(A){return x==="flush"?A.flush():A.partialFlush()},this)},Gt.prototype.flushStream=function(x){if(!this.captionPackets_.length){this.flushCCStreams(x);return}this.captionPackets_.forEach(function(A,D){A.presortIndex=D}),this.captionPackets_.sort(function(A,D){return A.pts===D.pts?A.presortIndex-D.presortIndex:A.pts-D.pts}),this.captionPackets_.forEach(function(A){A.type<2?this.dispatchCea608Packet(A):this.dispatchCea708Packet(A)},this),this.captionPackets_.length=0,this.flushCCStreams(x)},Gt.prototype.flush=function(){return this.flushStream("flush")},Gt.prototype.partialFlush=function(){return this.flushStream("partialFlush")},Gt.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(x){x.reset()})},Gt.prototype.dispatchCea608Packet=function(x){this.setsTextOrXDSActive(x)?this.activeCea608Channel_[x.type]=null:this.setsChannel1Active(x)?this.activeCea608Channel_[x.type]=0:this.setsChannel2Active(x)&&(this.activeCea608Channel_[x.type]=1),this.activeCea608Channel_[x.type]!==null&&this.ccStreams_[(x.type<<1)+this.activeCea608Channel_[x.type]].push(x)},Gt.prototype.setsChannel1Active=function(x){return(x.ccData&30720)===4096},Gt.prototype.setsChannel2Active=function(x){return(x.ccData&30720)===6144},Gt.prototype.setsTextOrXDSActive=function(x){return(x.ccData&28928)===256||(x.ccData&30974)===4138||(x.ccData&30974)===6186},Gt.prototype.dispatchCea708Packet=function(x){this.parse708captions_&&this.cc708Stream_.push(x)};var xi={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},ai=function(x){var A=xi[x]||x;return x&4096&&x===A?"":String.fromCharCode(A)},di=function(x){return 32<=x&&x<=127||160<=x&&x<=255},qt=function(x){this.windowNum=x,this.reset()};qt.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},qt.prototype.getText=function(){return this.rows.join(`
`)},qt.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},qt.prototype.newLine=function(x){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(x),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},qt.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},qt.prototype.addText=function(x){this.rows[this.rowIdx]+=x},qt.prototype.backspace=function(){if(!this.isEmpty()){var x=this.rows[this.rowIdx];this.rows[this.rowIdx]=x.substr(0,x.length-1)}};var Mt=function(x,A,D){this.serviceNum=x,this.text="",this.currentWindow=new qt(-1),this.windows=[],this.stream=D,typeof A=="string"&&this.createTextDecoder(A)};Mt.prototype.init=function(x,A){this.startPts=x;for(var D=0;D<8;D++)this.windows[D]=new qt(D),typeof A=="function"&&(this.windows[D].beforeRowOverflow=A)},Mt.prototype.setCurrentWindow=function(x){this.currentWindow=this.windows[x]},Mt.prototype.createTextDecoder=function(x){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(x)}catch(A){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+x+" encoding. "+A})}};var vt=function(x){x=x||{},vt.prototype.init.call(this);var A=this,D=x.captionServices||{},C={},M;Object.keys(D).forEach(B=>{M=D[B],/^SERVICE/.test(B)&&(C[B]=M.encoding)}),this.serviceEncodings=C,this.current708Packet=null,this.services={},this.push=function(B){B.type===3?(A.new708Packet(),A.add708Bytes(B)):(A.current708Packet===null&&A.new708Packet(),A.add708Bytes(B))}};vt.prototype=new ci,vt.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},vt.prototype.add708Bytes=function(x){var A=x.ccData,D=A>>>8,C=A&255;this.current708Packet.ptsVals.push(x.pts),this.current708Packet.data.push(D),this.current708Packet.data.push(C)},vt.prototype.push708Packet=function(){var x=this.current708Packet,A=x.data,D=null,C=null,M=0,B=A[M++];for(x.seq=B>>6,x.sizeCode=B&63;M<A.length;M++)B=A[M++],D=B>>5,C=B&31,D===7&&C>0&&(B=A[M++],D=B),this.pushServiceBlock(D,M,C),C>0&&(M+=C-1)},vt.prototype.pushServiceBlock=function(x,A,D){var C,M=A,B=this.current708Packet.data,ae=this.services[x];for(ae||(ae=this.initService(x,M));M<A+D&&M<B.length;M++)C=B[M],di(C)?M=this.handleText(M,ae):C===24?M=this.multiByteCharacter(M,ae):C===16?M=this.extendedCommands(M,ae):128<=C&&C<=135?M=this.setCurrentWindow(M,ae):152<=C&&C<=159?M=this.defineWindow(M,ae):C===136?M=this.clearWindows(M,ae):C===140?M=this.deleteWindows(M,ae):C===137?M=this.displayWindows(M,ae):C===138?M=this.hideWindows(M,ae):C===139?M=this.toggleWindows(M,ae):C===151?M=this.setWindowAttributes(M,ae):C===144?M=this.setPenAttributes(M,ae):C===145?M=this.setPenColor(M,ae):C===146?M=this.setPenLocation(M,ae):C===143?ae=this.reset(M,ae):C===8?ae.currentWindow.backspace():C===12?ae.currentWindow.clearText():C===13?ae.currentWindow.pendingNewLine=!0:C===14?ae.currentWindow.clearText():C===141&&M++},vt.prototype.extendedCommands=function(x,A){var D=this.current708Packet.data,C=D[++x];return di(C)&&(x=this.handleText(x,A,{isExtended:!0})),x},vt.prototype.getPts=function(x){return this.current708Packet.ptsVals[Math.floor(x/2)]},vt.prototype.initService=function(x,A){var C="SERVICE"+x,D=this,C,M;return C in this.serviceEncodings&&(M=this.serviceEncodings[C]),this.services[x]=new Mt(x,M,D),this.services[x].init(this.getPts(A),function(B){D.flushDisplayed(B,D.services[x])}),this.services[x]},vt.prototype.handleText=function(x,A,D){var C=D&&D.isExtended,M=D&&D.isMultiByte,B=this.current708Packet.data,ae=C?4096:0,de=B[x],he=B[x+1],ve=A.currentWindow,Ce,et;function At(nt){return nt.map(Bt=>("0"+(Bt&255).toString(16)).slice(-2)).join("")}if(M?(et=[de,he],x++):et=[de],A.textDecoder_&&!C)Ce=A.textDecoder_.decode(new Uint8Array(et));else if(M){const nt=At(et);Ce=String.fromCharCode(parseInt(nt,16))}else Ce=ai(ae|de);return ve.pendingNewLine&&!ve.isEmpty()&&ve.newLine(this.getPts(x)),ve.pendingNewLine=!1,ve.addText(Ce),x},vt.prototype.multiByteCharacter=function(x,A){var D=this.current708Packet.data,C=D[x+1],M=D[x+2];return di(C)&&di(M)&&(x=this.handleText(++x,A,{isMultiByte:!0})),x},vt.prototype.setCurrentWindow=function(x,A){var D=this.current708Packet.data,C=D[x],M=C&7;return A.setCurrentWindow(M),x},vt.prototype.defineWindow=function(x,A){var D=this.current708Packet.data,C=D[x],M=C&7;A.setCurrentWindow(M);var B=A.currentWindow;return C=D[++x],B.visible=(C&32)>>5,B.rowLock=(C&16)>>4,B.columnLock=(C&8)>>3,B.priority=C&7,C=D[++x],B.relativePositioning=(C&128)>>7,B.anchorVertical=C&127,C=D[++x],B.anchorHorizontal=C,C=D[++x],B.anchorPoint=(C&240)>>4,B.rowCount=C&15,C=D[++x],B.columnCount=C&63,C=D[++x],B.windowStyle=(C&56)>>3,B.penStyle=C&7,B.virtualRowCount=B.rowCount+1,x},vt.prototype.setWindowAttributes=function(x,A){var D=this.current708Packet.data,C=D[x],M=A.currentWindow.winAttr;return C=D[++x],M.fillOpacity=(C&192)>>6,M.fillRed=(C&48)>>4,M.fillGreen=(C&12)>>2,M.fillBlue=C&3,C=D[++x],M.borderType=(C&192)>>6,M.borderRed=(C&48)>>4,M.borderGreen=(C&12)>>2,M.borderBlue=C&3,C=D[++x],M.borderType+=(C&128)>>5,M.wordWrap=(C&64)>>6,M.printDirection=(C&48)>>4,M.scrollDirection=(C&12)>>2,M.justify=C&3,C=D[++x],M.effectSpeed=(C&240)>>4,M.effectDirection=(C&12)>>2,M.displayEffect=C&3,x},vt.prototype.flushDisplayed=function(x,A){for(var D=[],C=0;C<8;C++)A.windows[C].visible&&!A.windows[C].isEmpty()&&D.push(A.windows[C].getText());A.endPts=x,A.text=D.join(`
`),this.pushCaption(A),A.startPts=x},vt.prototype.pushCaption=function(x){x.text!==""&&(this.trigger("data",{startPts:x.startPts,endPts:x.endPts,text:x.text,stream:"cc708_"+x.serviceNum}),x.text="",x.startPts=x.endPts)},vt.prototype.displayWindows=function(x,A){var D=this.current708Packet.data,C=D[++x],M=this.getPts(x);this.flushDisplayed(M,A);for(var B=0;B<8;B++)C&1<<B&&(A.windows[B].visible=1);return x},vt.prototype.hideWindows=function(x,A){var D=this.current708Packet.data,C=D[++x],M=this.getPts(x);this.flushDisplayed(M,A);for(var B=0;B<8;B++)C&1<<B&&(A.windows[B].visible=0);return x},vt.prototype.toggleWindows=function(x,A){var D=this.current708Packet.data,C=D[++x],M=this.getPts(x);this.flushDisplayed(M,A);for(var B=0;B<8;B++)C&1<<B&&(A.windows[B].visible^=1);return x},vt.prototype.clearWindows=function(x,A){var D=this.current708Packet.data,C=D[++x],M=this.getPts(x);this.flushDisplayed(M,A);for(var B=0;B<8;B++)C&1<<B&&A.windows[B].clearText();return x},vt.prototype.deleteWindows=function(x,A){var D=this.current708Packet.data,C=D[++x],M=this.getPts(x);this.flushDisplayed(M,A);for(var B=0;B<8;B++)C&1<<B&&A.windows[B].reset();return x},vt.prototype.setPenAttributes=function(x,A){var D=this.current708Packet.data,C=D[x],M=A.currentWindow.penAttr;return C=D[++x],M.textTag=(C&240)>>4,M.offset=(C&12)>>2,M.penSize=C&3,C=D[++x],M.italics=(C&128)>>7,M.underline=(C&64)>>6,M.edgeType=(C&56)>>3,M.fontStyle=C&7,x},vt.prototype.setPenColor=function(x,A){var D=this.current708Packet.data,C=D[x],M=A.currentWindow.penColor;return C=D[++x],M.fgOpacity=(C&192)>>6,M.fgRed=(C&48)>>4,M.fgGreen=(C&12)>>2,M.fgBlue=C&3,C=D[++x],M.bgOpacity=(C&192)>>6,M.bgRed=(C&48)>>4,M.bgGreen=(C&12)>>2,M.bgBlue=C&3,C=D[++x],M.edgeRed=(C&48)>>4,M.edgeGreen=(C&12)>>2,M.edgeBlue=C&3,x},vt.prototype.setPenLocation=function(x,A){var D=this.current708Packet.data,C=D[x],M=A.currentWindow.penLoc;return A.currentWindow.pendingNewLine=!0,C=D[++x],M.row=C&15,C=D[++x],M.column=C&63,x},vt.prototype.reset=function(x,A){var D=this.getPts(x);return this.flushDisplayed(D,A),this.initService(A.serviceNum,x)};var Ci={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},ss=function(x){return x===null?"":(x=Ci[x]||x,String.fromCharCode(x))},vs=14,xs=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Gi=function(){for(var x=[],A=vs+1;A--;)x.push({text:"",indent:0,offset:0});return x},fi=function(x,A){fi.prototype.init.call(this),this.field_=x||0,this.dataChannel_=A||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(D){var C,M,B,ae,de;if(C=D.ccData&32639,C===this.lastControlCode_){this.lastControlCode_=null;return}if((C&61440)===4096?this.lastControlCode_=C:C!==this.PADDING_&&(this.lastControlCode_=null),B=C>>>8,ae=C&255,C!==this.PADDING_)if(C===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(C===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(D.pts),this.flushDisplayed(D.pts),M=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=M,this.startPts_=D.pts;else if(C===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(D.pts);else if(C===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(D.pts);else if(C===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(D.pts);else if(C===this.CARRIAGE_RETURN_)this.clearFormatting(D.pts),this.flushDisplayed(D.pts),this.shiftRowsUp_(),this.startPts_=D.pts;else if(C===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(C===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(D.pts),this.displayed_=Gi();else if(C===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Gi();else if(C===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(D.pts),this.displayed_=Gi()),this.mode_="paintOn",this.startPts_=D.pts;else if(this.isSpecialCharacter(B,ae))B=(B&3)<<8,de=ss(B|ae),this[this.mode_](D.pts,de),this.column_++;else if(this.isExtCharacter(B,ae))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),B=(B&3)<<8,de=ss(B|ae),this[this.mode_](D.pts,de),this.column_++;else if(this.isMidRowCode(B,ae))this.clearFormatting(D.pts),this[this.mode_](D.pts," "),this.column_++,(ae&14)===14&&this.addFormatting(D.pts,["i"]),(ae&1)===1&&this.addFormatting(D.pts,["u"]);else if(this.isOffsetControlCode(B,ae)){const ve=ae&3;this.nonDisplayed_[this.row_].offset=ve,this.column_+=ve}else if(this.isPAC(B,ae)){var he=xs.indexOf(C&7968);if(this.mode_==="rollUp"&&(he-this.rollUpRows_+1<0&&(he=this.rollUpRows_-1),this.setRollUp(D.pts,he)),he!==this.row_&&he>=0&&he<=14&&(this.clearFormatting(D.pts),this.row_=he),ae&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(D.pts,["u"]),(C&16)===16){const ve=(C&14)>>1;this.column_=ve*4,this.nonDisplayed_[this.row_].indent+=ve}this.isColorPAC(ae)&&(ae&14)===14&&this.addFormatting(D.pts,["i"])}else this.isNormalChar(B)&&(ae===0&&(ae=null),de=ss(B),de+=ss(ae),this[this.mode_](D.pts,de),this.column_+=de.length)}};fi.prototype=new ci,fi.prototype.flushDisplayed=function(x){const A=C=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+C+"."})},D=[];this.displayed_.forEach((C,M)=>{if(C&&C.text&&C.text.length){try{C.text=C.text.trim()}catch{A(M)}C.text.length&&D.push({text:C.text,line:M+1,position:10+Math.min(70,C.indent*10)+C.offset*2.5})}else C==null&&A(M)}),D.length&&this.trigger("data",{startPts:this.startPts_,endPts:x,content:D,stream:this.name_})},fi.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Gi(),this.nonDisplayed_=Gi(),this.lastControlCode_=null,this.column_=0,this.row_=vs,this.rollUpRows_=2,this.formatting_=[]},fi.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},fi.prototype.isSpecialCharacter=function(x,A){return x===this.EXT_&&A>=48&&A<=63},fi.prototype.isExtCharacter=function(x,A){return(x===this.EXT_+1||x===this.EXT_+2)&&A>=32&&A<=63},fi.prototype.isMidRowCode=function(x,A){return x===this.EXT_&&A>=32&&A<=47},fi.prototype.isOffsetControlCode=function(x,A){return x===this.OFFSET_&&A>=33&&A<=35},fi.prototype.isPAC=function(x,A){return x>=this.BASE_&&x<this.BASE_+8&&A>=64&&A<=127},fi.prototype.isColorPAC=function(x){return x>=64&&x<=79||x>=96&&x<=127},fi.prototype.isNormalChar=function(x){return x>=32&&x<=127},fi.prototype.setRollUp=function(x,A){if(this.mode_!=="rollUp"&&(this.row_=vs,this.mode_="rollUp",this.flushDisplayed(x),this.nonDisplayed_=Gi(),this.displayed_=Gi()),A!==void 0&&A!==this.row_)for(var D=0;D<this.rollUpRows_;D++)this.displayed_[A-D]=this.displayed_[this.row_-D],this.displayed_[this.row_-D]={text:"",indent:0,offset:0};A===void 0&&(A=this.row_),this.topRow_=A-this.rollUpRows_+1},fi.prototype.addFormatting=function(x,A){this.formatting_=this.formatting_.concat(A);var D=A.reduce(function(C,M){return C+"<"+M+">"},"");this[this.mode_](x,D)},fi.prototype.clearFormatting=function(x){if(this.formatting_.length){var A=this.formatting_.reverse().reduce(function(D,C){return D+"</"+C+">"},"");this.formatting_=[],this[this.mode_](x,A)}},fi.prototype.popOn=function(x,A){var D=this.nonDisplayed_[this.row_].text;D+=A,this.nonDisplayed_[this.row_].text=D},fi.prototype.rollUp=function(x,A){var D=this.displayed_[this.row_].text;D+=A,this.displayed_[this.row_].text=D},fi.prototype.shiftRowsUp_=function(){var x;for(x=0;x<this.topRow_;x++)this.displayed_[x]={text:"",indent:0,offset:0};for(x=this.row_+1;x<vs+1;x++)this.displayed_[x]={text:"",indent:0,offset:0};for(x=this.topRow_;x<this.row_;x++)this.displayed_[x]=this.displayed_[x+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},fi.prototype.paintOn=function(x,A){var D=this.displayed_[this.row_].text;D+=A,this.displayed_[this.row_].text=D};var Zi={CaptionStream:Gt,Cea608Stream:fi,Cea708Stream:vt},ts={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},$i=t,Ji=8589934592,Di=4294967296,$s="shared",Cs=function(x,A){var D=1;for(x>A&&(D=-1);Math.abs(A-x)>Di;)x+=D*Ji;return x},ns=function(x){var A,D;ns.prototype.init.call(this),this.type_=x||$s,this.push=function(C){if(C.type==="metadata"){this.trigger("data",C);return}this.type_!==$s&&C.type!==this.type_||(D===void 0&&(D=C.dts),C.dts=Cs(C.dts,D),C.pts=Cs(C.pts,D),A=C.dts,this.trigger("data",C))},this.flush=function(){D=A,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){D=void 0,A=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};ns.prototype=new $i;var rs={TimestampRolloverStream:ns,handleRollover:Cs},Rs=(x,A,D)=>{if(!x)return-1;for(var C=D;C<x.length;C++)if(x[C]===A)return C;return-1},Li={typedArrayIndexOf:Rs},qi=Li.typedArrayIndexOf,bs={Utf8:3},Kt=function(x,A,D){var C,M="";for(C=A;C<D;C++)M+="%"+("00"+x[C].toString(16)).slice(-2);return M},ds=function(x,A,D){return decodeURIComponent(Kt(x,A,D))},Fi=function(x,A,D){return unescape(Kt(x,A,D))},Hi=function(x){return x[0]<<21|x[1]<<14|x[2]<<7|x[3]},Ge={APIC:function(x){var A=1,D,C,M="-->";x.data[0]===bs.Utf8&&(D=qi(x.data,0,A),!(D<0)&&(x.mimeType=Fi(x.data,A,D),A=D+1,x.pictureType=x.data[A],A++,C=qi(x.data,0,A),!(C<0)&&(x.description=ds(x.data,A,C),A=C+1,x.mimeType===M?x.url=Fi(x.data,A,x.data.length):x.pictureData=x.data.subarray(A,x.data.length))))},"T*":function(x){x.data[0]===bs.Utf8&&(x.value=ds(x.data,1,x.data.length).replace(/\0*$/,""),x.values=x.value.split("\0"))},TXXX:function(x){var A;x.data[0]===bs.Utf8&&(A=qi(x.data,0,1),A!==-1&&(x.description=ds(x.data,1,A),x.value=ds(x.data,A+1,x.data.length).replace(/\0*$/,""),x.data=x.value))},"W*":function(x){x.url=Fi(x.data,0,x.data.length).replace(/\0.*$/,"")},WXXX:function(x){var A;x.data[0]===bs.Utf8&&(A=qi(x.data,0,1),A!==-1&&(x.description=ds(x.data,1,A),x.url=Fi(x.data,A+1,x.data.length).replace(/\0.*$/,"")))},PRIV:function(x){var A;for(A=0;A<x.data.length;A++)if(x.data[A]===0){x.owner=Fi(x.data,0,A);break}x.privateData=x.data.subarray(A+1),x.data=x.privateData}},Lt=function(x){var A,D,C=10,M=0,B=[];if(!(x.length<10||x[0]!==73||x[1]!==68||x[2]!==51)){M=Hi(x.subarray(6,10)),M+=10;var ae=x[5]&64;ae&&(C+=4,C+=Hi(x.subarray(10,14)),M-=Hi(x.subarray(16,20)));do{if(A=Hi(x.subarray(C+4,C+8)),A<1)break;D=String.fromCharCode(x[C],x[C+1],x[C+2],x[C+3]);var de={id:D,data:x.subarray(C+10,C+A+10)};de.key=de.id,Ge[de.id]?Ge[de.id](de):de.id[0]==="T"?Ge["T*"](de):de.id[0]==="W"&&Ge["W*"](de),B.push(de),C+=10,C+=A}while(C<M);return B}},Ct={parseId3Frames:Lt,parseSyncSafeInteger:Hi,frameParsers:Ge},Xt=t,Wt=ts,_i=Ct,ei;ei=function(x){var A={descriptor:x&&x.descriptor},D=0,C=[],M=0,B;if(ei.prototype.init.call(this),this.dispatchType=Wt.METADATA_STREAM_TYPE.toString(16),A.descriptor)for(B=0;B<A.descriptor.length;B++)this.dispatchType+=("00"+A.descriptor[B].toString(16)).slice(-2);this.push=function(ae){var de,he,ve,Ce,et,At;if(ae.type==="timed-metadata"){if(ae.dataAlignmentIndicator&&(M=0,C.length=0),C.length===0&&(ae.data.length<10||ae.data[0]!==73||ae.data[1]!==68||ae.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(C.push(ae),M+=ae.data.byteLength,C.length===1&&(D=_i.parseSyncSafeInteger(ae.data.subarray(6,10)),D+=10),!(M<D)){for(de={data:new Uint8Array(D),frames:[],pts:C[0].pts,dts:C[0].dts},et=0;et<D;)de.data.set(C[0].data.subarray(0,D-et),et),et+=C[0].data.byteLength,M-=C[0].data.byteLength,C.shift();he=10,de.data[5]&64&&(he+=4,he+=_i.parseSyncSafeInteger(de.data.subarray(10,14)),D-=_i.parseSyncSafeInteger(de.data.subarray(16,20)));do{if(ve=_i.parseSyncSafeInteger(de.data.subarray(he+4,he+8)),ve<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(At=String.fromCharCode(de.data[he],de.data[he+1],de.data[he+2],de.data[he+3]),Ce={id:At,data:de.data.subarray(he+10,he+ve+10)},Ce.key=Ce.id,_i.frameParsers[Ce.id]?_i.frameParsers[Ce.id](Ce):Ce.id[0]==="T"?_i.frameParsers["T*"](Ce):Ce.id[0]==="W"&&_i.frameParsers["W*"](Ce),Ce.owner==="com.apple.streaming.transportStreamTimestamp"){var nt=Ce.data,Bt=(nt[3]&1)<<30|nt[4]<<22|nt[5]<<14|nt[6]<<6|nt[7]>>>2;Bt*=4,Bt+=nt[7]&3,Ce.timeStamp=Bt,de.pts===void 0&&de.dts===void 0&&(de.pts=Ce.timeStamp,de.dts=Ce.timeStamp),this.trigger("timestamp",Ce)}de.frames.push(Ce),he+=10,he+=ve}while(he<D);this.trigger("data",de)}}}},ei.prototype=new Xt;var Ki=ei,Ts=t,In=Zi,Wi=ts,Nn=rs.TimestampRolloverStream,On,Zs,pn,ln=188,Is=71;On=function(){var x=new Uint8Array(ln),A=0;On.prototype.init.call(this),this.push=function(D){var C=0,M=ln,B;for(A?(B=new Uint8Array(D.byteLength+A),B.set(x.subarray(0,A)),B.set(D,A),A=0):B=D;M<B.byteLength;){if(B[C]===Is&&B[M]===Is){this.trigger("data",B.subarray(C,M)),C+=ln,M+=ln;continue}C++,M++}C<B.byteLength&&(x.set(B.subarray(C),0),A=B.byteLength-C)},this.flush=function(){A===ln&&x[0]===Is&&(this.trigger("data",x),A=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){A=0,this.trigger("reset")}},On.prototype=new Ts,Zs=function(){var x,A,D,C;Zs.prototype.init.call(this),C=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,x=function(M,B){var ae=0;B.payloadUnitStartIndicator&&(ae+=M[ae]+1),B.type==="pat"?A(M.subarray(ae),B):D(M.subarray(ae),B)},A=function(M,B){B.section_number=M[7],B.last_section_number=M[8],C.pmtPid=(M[10]&31)<<8|M[11],B.pmtPid=C.pmtPid},D=function(M,B){var ae,de,he,ve;if(M[5]&1){for(C.programMapTable={video:null,audio:null,"timed-metadata":{}},ae=(M[1]&15)<<8|M[2],de=3+ae-4,he=(M[10]&15)<<8|M[11],ve=12+he;ve<de;){var Ce=M[ve],et=(M[ve+1]&31)<<8|M[ve+2];Ce===Wi.H264_STREAM_TYPE&&C.programMapTable.video===null?C.programMapTable.video=et:Ce===Wi.ADTS_STREAM_TYPE&&C.programMapTable.audio===null?C.programMapTable.audio=et:Ce===Wi.METADATA_STREAM_TYPE&&(C.programMapTable["timed-metadata"][et]=Ce),ve+=((M[ve+3]&15)<<8|M[ve+4])+5}B.programMapTable=C.programMapTable}},this.push=function(M){var B={},ae=4;if(B.payloadUnitStartIndicator=!!(M[1]&64),B.pid=M[1]&31,B.pid<<=8,B.pid|=M[2],(M[3]&48)>>>4>1&&(ae+=M[ae]+1),B.pid===0)B.type="pat",x(M.subarray(ae),B),this.trigger("data",B);else if(B.pid===this.pmtPid)for(B.type="pmt",x(M.subarray(ae),B),this.trigger("data",B);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([M,ae,B]):this.processPes_(M,ae,B)},this.processPes_=function(M,B,ae){ae.pid===this.programMapTable.video?ae.streamType=Wi.H264_STREAM_TYPE:ae.pid===this.programMapTable.audio?ae.streamType=Wi.ADTS_STREAM_TYPE:ae.streamType=this.programMapTable["timed-metadata"][ae.pid],ae.type="pes",ae.data=M.subarray(B),this.trigger("data",ae)}},Zs.prototype=new Ts,Zs.STREAM_TYPES={h264:27,adts:15},pn=function(){var x=this,A=!1,D={data:[],size:0},C={data:[],size:0},M={data:[],size:0},B,ae=function(he,ve){var Ce;const et=he[0]<<16|he[1]<<8|he[2];ve.data=new Uint8Array,et===1&&(ve.packetLength=6+(he[4]<<8|he[5]),ve.dataAlignmentIndicator=(he[6]&4)!==0,Ce=he[7],Ce&192&&(ve.pts=(he[9]&14)<<27|(he[10]&255)<<20|(he[11]&254)<<12|(he[12]&255)<<5|(he[13]&254)>>>3,ve.pts*=4,ve.pts+=(he[13]&6)>>>1,ve.dts=ve.pts,Ce&64&&(ve.dts=(he[14]&14)<<27|(he[15]&255)<<20|(he[16]&254)<<12|(he[17]&255)<<5|(he[18]&254)>>>3,ve.dts*=4,ve.dts+=(he[18]&6)>>>1)),ve.data=he.subarray(9+he[8]))},de=function(he,ve,Ce){var et=new Uint8Array(he.size),At={type:ve},nt=0,Bt=0,mi=!1,tn;if(!(!he.data.length||he.size<9)){for(At.trackId=he.data[0].pid,nt=0;nt<he.data.length;nt++)tn=he.data[nt],et.set(tn.data,Bt),Bt+=tn.data.byteLength;ae(et,At),mi=ve==="video"||At.packetLength<=he.size,(Ce||mi)&&(he.size=0,he.data.length=0),mi&&x.trigger("data",At)}};pn.prototype.init.call(this),this.push=function(he){({pat:function(){},pes:function(){var ve,Ce;switch(he.streamType){case Wi.H264_STREAM_TYPE:ve=D,Ce="video";break;case Wi.ADTS_STREAM_TYPE:ve=C,Ce="audio";break;case Wi.METADATA_STREAM_TYPE:ve=M,Ce="timed-metadata";break;default:return}he.payloadUnitStartIndicator&&de(ve,Ce,!0),ve.data.push(he),ve.size+=he.data.byteLength},pmt:function(){var ve={type:"metadata",tracks:[]};B=he.programMapTable,B.video!==null&&ve.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"}),B.audio!==null&&ve.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"}),A=!0,x.trigger("data",ve)}})[he.type]()},this.reset=function(){D.size=0,D.data.length=0,C.size=0,C.data.length=0,this.trigger("reset")},this.flushStreams_=function(){de(D,"video"),de(C,"audio"),de(M,"timed-metadata")},this.flush=function(){if(!A&&B){var he={type:"metadata",tracks:[]};B.video!==null&&he.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"}),B.audio!==null&&he.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"}),x.trigger("data",he)}A=!1,this.flushStreams_(),this.trigger("done")}},pn.prototype=new Ts;var un={PAT_PID:0,MP2T_PACKET_LENGTH:ln,TransportPacketStream:On,TransportParseStream:Zs,ElementaryStream:pn,TimestampRolloverStream:Nn,CaptionStream:In.CaptionStream,Cea608Stream:In.Cea608Stream,Cea708Stream:In.Cea708Stream,MetadataStream:Ki};for(var Mn in Wi)Wi.hasOwnProperty(Mn)&&(un[Mn]=Wi[Mn]);var Js=un,en=t,zi=Tt.ONE_SECOND_IN_TS,Pn,_n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Pn=function(x){var A,D=0;Pn.prototype.init.call(this),this.skipWarn_=function(C,M){this.trigger("log",{level:"warn",message:`adts skiping bytes ${C} to ${M} in frame ${D} outside syncword`})},this.push=function(C){var M=0,B,ae,de,he,ve;if(x||(D=0),C.type==="audio"){A&&A.length?(de=A,A=new Uint8Array(de.byteLength+C.data.byteLength),A.set(de),A.set(C.data,de.byteLength)):A=C.data;for(var Ce;M+7<A.length;){if(A[M]!==255||(A[M+1]&246)!==240){typeof Ce!="number"&&(Ce=M),M++;continue}if(typeof Ce=="number"&&(this.skipWarn_(Ce,M),Ce=null),ae=(~A[M+1]&1)*2,B=(A[M+3]&3)<<11|A[M+4]<<3|(A[M+5]&224)>>5,he=((A[M+6]&3)+1)*1024,ve=he*zi/_n[(A[M+2]&60)>>>2],A.byteLength-M<B)break;this.trigger("data",{pts:C.pts+D*ve,dts:C.dts+D*ve,sampleCount:he,audioobjecttype:(A[M+2]>>>6&3)+1,channelcount:(A[M+2]&1)<<2|(A[M+3]&192)>>>6,samplerate:_n[(A[M+2]&60)>>>2],samplingfrequencyindex:(A[M+2]&60)>>>2,samplesize:16,data:A.subarray(M+7+ae,M+B)}),D++,M+=B}typeof Ce=="number"&&(this.skipWarn_(Ce,M),Ce=null),A=A.subarray(M)}},this.flush=function(){D=0,this.trigger("done")},this.reset=function(){A=void 0,this.trigger("reset")},this.endTimeline=function(){A=void 0,this.trigger("endedtimeline")}},Pn.prototype=new en;var me=Pn,we;we=function(x){var A=x.byteLength,D=0,C=0;this.length=function(){return 8*A},this.bitsAvailable=function(){return 8*A+C},this.loadWord=function(){var M=x.byteLength-A,B=new Uint8Array(4),ae=Math.min(4,A);if(ae===0)throw new Error("no bytes available");B.set(x.subarray(M,M+ae)),D=new DataView(B.buffer).getUint32(0),C=ae*8,A-=ae},this.skipBits=function(M){var B;C>M?(D<<=M,C-=M):(M-=C,B=Math.floor(M/8),M-=B*8,A-=B,this.loadWord(),D<<=M,C-=M)},this.readBits=function(M){var B=Math.min(C,M),ae=D>>>32-B;return C-=B,C>0?D<<=B:A>0&&this.loadWord(),B=M-B,B>0?ae<<B|this.readBits(B):ae},this.skipLeadingZeros=function(){var M;for(M=0;M<C;++M)if((D&2147483648>>>M)!==0)return D<<=M,C-=M,M;return this.loadWord(),M+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var M=this.skipLeadingZeros();return this.readBits(M+1)-1},this.readExpGolomb=function(){var M=this.readUnsignedExpGolomb();return 1&M?1+M>>>1:-1*(M>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var ue=we,pe=t,xe=ue,Oe,Q,ne;Q=function(){var x=0,A,D;Q.prototype.init.call(this),this.push=function(C){var M;D?(M=new Uint8Array(D.byteLength+C.data.byteLength),M.set(D),M.set(C.data,D.byteLength),D=M):D=C.data;for(var B=D.byteLength;x<B-3;x++)if(D[x+2]===1){A=x+5;break}for(;A<B;)switch(D[A]){case 0:if(D[A-1]!==0){A+=2;break}else if(D[A-2]!==0){A++;break}x+3!==A-2&&this.trigger("data",D.subarray(x+3,A-2));do A++;while(D[A]!==1&&A<B);x=A-2,A+=3;break;case 1:if(D[A-1]!==0||D[A-2]!==0){A+=3;break}this.trigger("data",D.subarray(x+3,A-2)),x=A-2,A+=3;break;default:A+=3;break}D=D.subarray(x),A-=x,x=0},this.reset=function(){D=null,x=0,this.trigger("reset")},this.flush=function(){D&&D.byteLength>3&&this.trigger("data",D.subarray(x+3)),D=null,x=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Q.prototype=new pe,ne={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Oe=function(){var x=new Q,A,D,C,M,B,ae,de;Oe.prototype.init.call(this),A=this,this.push=function(he){he.type==="video"&&(D=he.trackId,C=he.pts,M=he.dts,x.push(he))},x.on("data",function(he){var ve={trackId:D,pts:C,dts:M,data:he,nalUnitTypeCode:he[0]&31};switch(ve.nalUnitTypeCode){case 5:ve.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:ve.nalUnitType="sei_rbsp",ve.escapedRBSP=B(he.subarray(1));break;case 7:ve.nalUnitType="seq_parameter_set_rbsp",ve.escapedRBSP=B(he.subarray(1)),ve.config=ae(ve.escapedRBSP);break;case 8:ve.nalUnitType="pic_parameter_set_rbsp";break;case 9:ve.nalUnitType="access_unit_delimiter_rbsp";break}A.trigger("data",ve)}),x.on("done",function(){A.trigger("done")}),x.on("partialdone",function(){A.trigger("partialdone")}),x.on("reset",function(){A.trigger("reset")}),x.on("endedtimeline",function(){A.trigger("endedtimeline")}),this.flush=function(){x.flush()},this.partialFlush=function(){x.partialFlush()},this.reset=function(){x.reset()},this.endTimeline=function(){x.endTimeline()},de=function(he,ve){var Ce=8,et=8,At,nt;for(At=0;At<he;At++)et!==0&&(nt=ve.readExpGolomb(),et=(Ce+nt+256)%256),Ce=et===0?Ce:et},B=function(he){for(var ve=he.byteLength,Ce=[],et=1,At,nt;et<ve-2;)he[et]===0&&he[et+1]===0&&he[et+2]===3?(Ce.push(et+2),et+=2):et++;if(Ce.length===0)return he;At=ve-Ce.length,nt=new Uint8Array(At);var Bt=0;for(et=0;et<At;Bt++,et++)Bt===Ce[0]&&(Bt++,Ce.shift()),nt[et]=he[Bt];return nt},ae=function(he){var ve=0,Ce=0,et=0,At=0,nt,Bt,mi,tn,Qn,Da,Gl,Ds,no,ua,La,as=[1,1],Gr,wn;if(nt=new xe(he),Bt=nt.readUnsignedByte(),tn=nt.readUnsignedByte(),mi=nt.readUnsignedByte(),nt.skipUnsignedExpGolomb(),ne[Bt]&&(Qn=nt.readUnsignedExpGolomb(),Qn===3&&nt.skipBits(1),nt.skipUnsignedExpGolomb(),nt.skipUnsignedExpGolomb(),nt.skipBits(1),nt.readBoolean()))for(La=Qn!==3?8:12,wn=0;wn<La;wn++)nt.readBoolean()&&(wn<6?de(16,nt):de(64,nt));if(nt.skipUnsignedExpGolomb(),Da=nt.readUnsignedExpGolomb(),Da===0)nt.readUnsignedExpGolomb();else if(Da===1)for(nt.skipBits(1),nt.skipExpGolomb(),nt.skipExpGolomb(),Gl=nt.readUnsignedExpGolomb(),wn=0;wn<Gl;wn++)nt.skipExpGolomb();if(nt.skipUnsignedExpGolomb(),nt.skipBits(1),Ds=nt.readUnsignedExpGolomb(),no=nt.readUnsignedExpGolomb(),ua=nt.readBits(1),ua===0&&nt.skipBits(1),nt.skipBits(1),nt.readBoolean()&&(ve=nt.readUnsignedExpGolomb(),Ce=nt.readUnsignedExpGolomb(),et=nt.readUnsignedExpGolomb(),At=nt.readUnsignedExpGolomb()),nt.readBoolean()&&nt.readBoolean()){switch(Gr=nt.readUnsignedByte(),Gr){case 1:as=[1,1];break;case 2:as=[12,11];break;case 3:as=[10,11];break;case 4:as=[16,11];break;case 5:as=[40,33];break;case 6:as=[24,11];break;case 7:as=[20,11];break;case 8:as=[32,11];break;case 9:as=[80,33];break;case 10:as=[18,11];break;case 11:as=[15,11];break;case 12:as=[64,33];break;case 13:as=[160,99];break;case 14:as=[4,3];break;case 15:as=[3,2];break;case 16:as=[2,1];break;case 255:{as=[nt.readUnsignedByte()<<8|nt.readUnsignedByte(),nt.readUnsignedByte()<<8|nt.readUnsignedByte()];break}}as&&as[0]/as[1]}return{profileIdc:Bt,levelIdc:mi,profileCompatibility:tn,width:(Ds+1)*16-ve*2-Ce*2,height:(2-ua)*(no+1)*16-et*2-At*2,sarRatio:as}}},Oe.prototype=new pe;var ce={H264Stream:Oe},fe=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Ne=function(x,A){var D=x[A+6]<<21|x[A+7]<<14|x[A+8]<<7|x[A+9],C=x[A+5],M=(C&16)>>4;return D=D>=0?D:0,M?D+20:D+10},We=function(x,A){return x.length-A<10||x[A]!==73||x[A+1]!==68||x[A+2]!==51?A:(A+=Ne(x,A),We(x,A))},xt=function(x){var A=We(x,0);return x.length>=A+2&&(x[A]&255)===255&&(x[A+1]&240)===240&&(x[A+1]&22)===16},it=function(x){return x[0]<<21|x[1]<<14|x[2]<<7|x[3]},mt=function(x,A,D){var C,M="";for(C=A;C<D;C++)M+="%"+("00"+x[C].toString(16)).slice(-2);return M},Rt=function(x,A,D){return unescape(mt(x,A,D))},Pt=function(x,A){var D=(x[A+5]&224)>>5,C=x[A+4]<<3,M=x[A+3]&6144;return M|C|D},Nt=function(x,A){return x[A]===73&&x[A+1]===68&&x[A+2]===51?"timed-metadata":x[A]&!0&&(x[A+1]&240)===240?"audio":null},Ht=function(x){for(var A=0;A+5<x.length;){if(x[A]!==255||(x[A+1]&246)!==240){A++;continue}return fe[(x[A+2]&60)>>>2]}return null},Vi=function(x){var A,D,C,M;A=10,x[5]&64&&(A+=4,A+=it(x.subarray(10,14)));do{if(D=it(x.subarray(A+4,A+8)),D<1)return null;if(M=String.fromCharCode(x[A],x[A+1],x[A+2],x[A+3]),M==="PRIV"){C=x.subarray(A+10,A+D+10);for(var B=0;B<C.byteLength;B++)if(C[B]===0){var ae=Rt(C,0,B);if(ae==="com.apple.streaming.transportStreamTimestamp"){var de=C.subarray(B+1),he=(de[3]&1)<<30|de[4]<<22|de[5]<<14|de[6]<<6|de[7]>>>2;return he*=4,he+=de[7]&3,he}break}}A+=10,A+=D}while(A<x.byteLength);return null},gn={isLikelyAacData:xt,parseId3TagSize:Ne,parseAdtsSize:Pt,parseType:Nt,parseSampleRate:Ht,parseAacTimestamp:Vi},yn=t,No=gn,Er;Er=function(){var x=new Uint8Array,A=0;Er.prototype.init.call(this),this.setTimestamp=function(D){A=D},this.push=function(D){var C=0,M=0,B,ae,de,he;for(x.length?(he=x.length,x=new Uint8Array(D.byteLength+he),x.set(x.subarray(0,he)),x.set(D,he)):x=D;x.length-M>=3;){if(x[M]===73&&x[M+1]===68&&x[M+2]===51){if(x.length-M<10||(C=No.parseId3TagSize(x,M),M+C>x.length))break;ae={type:"timed-metadata",data:x.subarray(M,M+C)},this.trigger("data",ae),M+=C;continue}else if((x[M]&255)===255&&(x[M+1]&240)===240){if(x.length-M<7||(C=No.parseAdtsSize(x,M),M+C>x.length))break;de={type:"audio",data:x.subarray(M,M+C),pts:A,dts:A},this.trigger("data",de),M+=C;continue}M++}B=x.length-M,B>0?x=x.subarray(M):x=new Uint8Array},this.reset=function(){x=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){x=new Uint8Array,this.trigger("endedtimeline")}},Er.prototype=new yn;var hs=Er,Ms=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],En=Ms,ba=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],sf=ba,Ta=t,Nl=Je,Ol=_t,Cu=Jt,wr=ie,aa=Js,Ml=Tt,nf=me,Mp=ce.H264Stream,Pp=hs,Bp=gn.isLikelyAacData,td=Tt.ONE_SECOND_IN_TS,rf=En,af=sf,Du,Oo,Lu,eo,Fp=function(x,A){A.stream=x,this.trigger("log",A)},of=function(x,A){for(var D=Object.keys(A),C=0;C<D.length;C++){var M=D[C];M==="headOfPipeline"||!A[M].on||A[M].on("log",Fp.bind(x,M))}},lf=function(x,A){var D;if(x.length!==A.length)return!1;for(D=0;D<x.length;D++)if(x[D]!==A[D])return!1;return!0},uf=function(x,A,D,C,M,B){var ae=D-A,de=C-A,he=M-D;return{start:{dts:x,pts:x+ae},end:{dts:x+de,pts:x+he},prependedContentDuration:B,baseMediaDecodeTime:x}};Oo=function(x,A){var D=[],C,M=0,B=0,ae=1/0;A=A||{},C=A.firstSequenceNumber||0,Oo.prototype.init.call(this),this.push=function(de){wr.collectDtsInfo(x,de),x&&rf.forEach(function(he){x[he]=de[he]}),D.push(de)},this.setEarliestDts=function(de){M=de},this.setVideoBaseMediaDecodeTime=function(de){ae=de},this.setAudioAppendStart=function(de){B=de},this.flush=function(){var de,he,ve,Ce,et,At,nt;if(D.length===0){this.trigger("done","AudioSegmentStream");return}de=Cu.trimAdtsFramesByEarliestDts(D,x,M),x.baseMediaDecodeTime=wr.calculateTrackBaseMediaDecodeTime(x,A.keepOriginalTimestamps),nt=Cu.prefixWithSilence(x,de,B,ae),x.samples=Cu.generateSampleTable(de),ve=Nl.mdat(Cu.concatenateFrameData(de)),D=[],he=Nl.moof(C,[x]),Ce=new Uint8Array(he.byteLength+ve.byteLength),C++,Ce.set(he),Ce.set(ve,he.byteLength),wr.clearDtsInfo(x),et=Math.ceil(td*1024/x.samplerate),de.length&&(At=de.length*et,this.trigger("segmentTimingInfo",uf(Ml.audioTsToVideoTs(x.baseMediaDecodeTime,x.samplerate),de[0].dts,de[0].pts,de[0].dts+At,de[0].pts+At,nt||0)),this.trigger("timingInfo",{start:de[0].pts,end:de[0].pts+At})),this.trigger("data",{track:x,boxes:Ce}),this.trigger("done","AudioSegmentStream")},this.reset=function(){wr.clearDtsInfo(x),D=[],this.trigger("reset")}},Oo.prototype=new Ta,Du=function(x,A){var D,C=[],M=[],B,ae;A=A||{},D=A.firstSequenceNumber||0,Du.prototype.init.call(this),delete x.minPTS,this.gopCache_=[],this.push=function(de){wr.collectDtsInfo(x,de),de.nalUnitType==="seq_parameter_set_rbsp"&&!B&&(B=de.config,x.sps=[de.data],af.forEach(function(he){x[he]=B[he]},this)),de.nalUnitType==="pic_parameter_set_rbsp"&&!ae&&(ae=de.data,x.pps=[de.data]),C.push(de)},this.flush=function(){for(var de,he,ve,Ce,et,At,nt=0,Bt,mi;C.length&&C[0].nalUnitType!=="access_unit_delimiter_rbsp";)C.shift();if(C.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(de=Ol.groupNalsIntoFrames(C),ve=Ol.groupFramesIntoGops(de),ve[0][0].keyFrame||(he=this.getGopForFusion_(C[0],x),he?(nt=he.duration,ve.unshift(he),ve.byteLength+=he.byteLength,ve.nalCount+=he.nalCount,ve.pts=he.pts,ve.dts=he.dts,ve.duration+=he.duration):ve=Ol.extendFirstKeyFrame(ve)),M.length){var tn;if(A.alignGopsAtEnd?tn=this.alignGopsAtEnd_(ve):tn=this.alignGopsAtStart_(ve),!tn){this.gopCache_.unshift({gop:ve.pop(),pps:x.pps,sps:x.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),C=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}wr.clearDtsInfo(x),ve=tn}wr.collectDtsInfo(x,ve),x.samples=Ol.generateSampleTable(ve),et=Nl.mdat(Ol.concatenateNalData(ve)),x.baseMediaDecodeTime=wr.calculateTrackBaseMediaDecodeTime(x,A.keepOriginalTimestamps),this.trigger("processedGopsInfo",ve.map(function(Qn){return{pts:Qn.pts,dts:Qn.dts,byteLength:Qn.byteLength}})),Bt=ve[0],mi=ve[ve.length-1],this.trigger("segmentTimingInfo",uf(x.baseMediaDecodeTime,Bt.dts,Bt.pts,mi.dts+mi.duration,mi.pts+mi.duration,nt)),this.trigger("timingInfo",{start:ve[0].pts,end:ve[ve.length-1].pts+ve[ve.length-1].duration}),this.gopCache_.unshift({gop:ve.pop(),pps:x.pps,sps:x.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),C=[],this.trigger("baseMediaDecodeTime",x.baseMediaDecodeTime),this.trigger("timelineStartInfo",x.timelineStartInfo),Ce=Nl.moof(D,[x]),At=new Uint8Array(Ce.byteLength+et.byteLength),D++,At.set(Ce),At.set(et,Ce.byteLength),this.trigger("data",{track:x,boxes:At}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),C=[],this.gopCache_.length=0,M.length=0,this.trigger("reset")},this.resetStream_=function(){wr.clearDtsInfo(x),B=void 0,ae=void 0},this.getGopForFusion_=function(de){var he=45e3,ve=1/0,Ce,et,At,nt,Bt;for(Bt=0;Bt<this.gopCache_.length;Bt++)nt=this.gopCache_[Bt],At=nt.gop,!(!(x.pps&&lf(x.pps[0],nt.pps[0]))||!(x.sps&&lf(x.sps[0],nt.sps[0])))&&(At.dts<x.timelineStartInfo.dts||(Ce=de.dts-At.dts-At.duration,Ce>=-1e4&&Ce<=he&&(!et||ve>Ce)&&(et=nt,ve=Ce)));return et?et.gop:null},this.alignGopsAtStart_=function(de){var he,ve,Ce,et,At,nt,Bt,mi;for(At=de.byteLength,nt=de.nalCount,Bt=de.duration,he=ve=0;he<M.length&&ve<de.length&&(Ce=M[he],et=de[ve],Ce.pts!==et.pts);){if(et.pts>Ce.pts){he++;continue}ve++,At-=et.byteLength,nt-=et.nalCount,Bt-=et.duration}return ve===0?de:ve===de.length?null:(mi=de.slice(ve),mi.byteLength=At,mi.duration=Bt,mi.nalCount=nt,mi.pts=mi[0].pts,mi.dts=mi[0].dts,mi)},this.alignGopsAtEnd_=function(de){var he,ve,Ce,et,At,nt;for(he=M.length-1,ve=de.length-1,At=null,nt=!1;he>=0&&ve>=0;){if(Ce=M[he],et=de[ve],Ce.pts===et.pts){nt=!0;break}if(Ce.pts>et.pts){he--;continue}he===M.length-1&&(At=ve),ve--}if(!nt&&At===null)return null;var Bt;if(nt?Bt=ve:Bt=At,Bt===0)return de;var mi=de.slice(Bt),tn=mi.reduce(function(Qn,Da){return Qn.byteLength+=Da.byteLength,Qn.duration+=Da.duration,Qn.nalCount+=Da.nalCount,Qn},{byteLength:0,duration:0,nalCount:0});return mi.byteLength=tn.byteLength,mi.duration=tn.duration,mi.nalCount=tn.nalCount,mi.pts=mi[0].pts,mi.dts=mi[0].dts,mi},this.alignGopsWith=function(de){M=de}},Du.prototype=new Ta,eo=function(x,A){this.numberOfTracks=0,this.metadataStream=A,x=x||{},typeof x.remux<"u"?this.remuxTracks=!!x.remux:this.remuxTracks=!0,typeof x.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=x.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,eo.prototype.init.call(this),this.push=function(D){if(D.content||D.text)return this.pendingCaptions.push(D);if(D.frames)return this.pendingMetadata.push(D);this.pendingTracks.push(D.track),this.pendingBytes+=D.boxes.byteLength,D.track.type==="video"&&(this.videoTrack=D.track,this.pendingBoxes.push(D.boxes)),D.track.type==="audio"&&(this.audioTrack=D.track,this.pendingBoxes.unshift(D.boxes))}},eo.prototype=new Ta,eo.prototype.flush=function(x){var A=0,D={captions:[],captionStreams:{},metadata:[],info:{}},C,M,B,ae=0,de;if(this.pendingTracks.length<this.numberOfTracks){if(x!=="VideoSegmentStream"&&x!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(ae=this.videoTrack.timelineStartInfo.pts,af.forEach(function(he){D.info[he]=this.videoTrack[he]},this)):this.audioTrack&&(ae=this.audioTrack.timelineStartInfo.pts,rf.forEach(function(he){D.info[he]=this.audioTrack[he]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?D.type=this.pendingTracks[0].type:D.type="combined",this.emittedTracks+=this.pendingTracks.length,B=Nl.initSegment(this.pendingTracks),D.initSegment=new Uint8Array(B.byteLength),D.initSegment.set(B),D.data=new Uint8Array(this.pendingBytes),de=0;de<this.pendingBoxes.length;de++)D.data.set(this.pendingBoxes[de],A),A+=this.pendingBoxes[de].byteLength;for(de=0;de<this.pendingCaptions.length;de++)C=this.pendingCaptions[de],C.startTime=Ml.metadataTsToSeconds(C.startPts,ae,this.keepOriginalTimestamps),C.endTime=Ml.metadataTsToSeconds(C.endPts,ae,this.keepOriginalTimestamps),D.captionStreams[C.stream]=!0,D.captions.push(C);for(de=0;de<this.pendingMetadata.length;de++)M=this.pendingMetadata[de],M.cueTime=Ml.metadataTsToSeconds(M.pts,ae,this.keepOriginalTimestamps),D.metadata.push(M);for(D.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",D),de=0;de<D.captions.length;de++)C=D.captions[de],this.trigger("caption",C);for(de=0;de<D.metadata.length;de++)M=D.metadata[de],this.trigger("id3Frame",M)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},eo.prototype.setRemux=function(x){this.remuxTracks=x},Lu=function(x){var A=this,D=!0,C,M;Lu.prototype.init.call(this),x=x||{},this.baseMediaDecodeTime=x.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="aac",B.metadataStream=new aa.MetadataStream,B.aacStream=new Pp,B.audioTimestampRolloverStream=new aa.TimestampRolloverStream("audio"),B.timedMetadataTimestampRolloverStream=new aa.TimestampRolloverStream("timed-metadata"),B.adtsStream=new nf,B.coalesceStream=new eo(x,B.metadataStream),B.headOfPipeline=B.aacStream,B.aacStream.pipe(B.audioTimestampRolloverStream).pipe(B.adtsStream),B.aacStream.pipe(B.timedMetadataTimestampRolloverStream).pipe(B.metadataStream).pipe(B.coalesceStream),B.metadataStream.on("timestamp",function(ae){B.aacStream.setTimestamp(ae.timeStamp)}),B.aacStream.on("data",function(ae){ae.type!=="timed-metadata"&&ae.type!=="audio"||B.audioSegmentStream||(M=M||{timelineStartInfo:{baseMediaDecodeTime:A.baseMediaDecodeTime},codec:"adts",type:"audio"},B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new Oo(M,x),B.audioSegmentStream.on("log",A.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",A.trigger.bind(A,"audioTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream),A.trigger("trackinfo",{hasAudio:!!M,hasVideo:!!C}))}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),of(this,B)},this.setupTsPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="ts",B.metadataStream=new aa.MetadataStream,B.packetStream=new aa.TransportPacketStream,B.parseStream=new aa.TransportParseStream,B.elementaryStream=new aa.ElementaryStream,B.timestampRolloverStream=new aa.TimestampRolloverStream,B.adtsStream=new nf,B.h264Stream=new Mp,B.captionStream=new aa.CaptionStream(x),B.coalesceStream=new eo(x,B.metadataStream),B.headOfPipeline=B.packetStream,B.packetStream.pipe(B.parseStream).pipe(B.elementaryStream).pipe(B.timestampRolloverStream),B.timestampRolloverStream.pipe(B.h264Stream),B.timestampRolloverStream.pipe(B.adtsStream),B.timestampRolloverStream.pipe(B.metadataStream).pipe(B.coalesceStream),B.h264Stream.pipe(B.captionStream).pipe(B.coalesceStream),B.elementaryStream.on("data",function(ae){var de;if(ae.type==="metadata"){for(de=ae.tracks.length;de--;)!C&&ae.tracks[de].type==="video"?(C=ae.tracks[de],C.timelineStartInfo.baseMediaDecodeTime=A.baseMediaDecodeTime):!M&&ae.tracks[de].type==="audio"&&(M=ae.tracks[de],M.timelineStartInfo.baseMediaDecodeTime=A.baseMediaDecodeTime);C&&!B.videoSegmentStream&&(B.coalesceStream.numberOfTracks++,B.videoSegmentStream=new Du(C,x),B.videoSegmentStream.on("log",A.getLogTrigger_("videoSegmentStream")),B.videoSegmentStream.on("timelineStartInfo",function(he){M&&!x.keepOriginalTimestamps&&(M.timelineStartInfo=he,B.audioSegmentStream.setEarliestDts(he.dts-A.baseMediaDecodeTime))}),B.videoSegmentStream.on("processedGopsInfo",A.trigger.bind(A,"gopInfo")),B.videoSegmentStream.on("segmentTimingInfo",A.trigger.bind(A,"videoSegmentTimingInfo")),B.videoSegmentStream.on("baseMediaDecodeTime",function(he){M&&B.audioSegmentStream.setVideoBaseMediaDecodeTime(he)}),B.videoSegmentStream.on("timingInfo",A.trigger.bind(A,"videoTimingInfo")),B.h264Stream.pipe(B.videoSegmentStream).pipe(B.coalesceStream)),M&&!B.audioSegmentStream&&(B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new Oo(M,x),B.audioSegmentStream.on("log",A.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",A.trigger.bind(A,"audioTimingInfo")),B.audioSegmentStream.on("segmentTimingInfo",A.trigger.bind(A,"audioSegmentTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream)),A.trigger("trackinfo",{hasAudio:!!M,hasVideo:!!C})}}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("id3Frame",function(ae){ae.dispatchType=B.metadataStream.dispatchType,A.trigger("id3Frame",ae)}),B.coalesceStream.on("caption",this.trigger.bind(this,"caption")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),of(this,B)},this.setBaseMediaDecodeTime=function(B){var ae=this.transmuxPipeline_;x.keepOriginalTimestamps||(this.baseMediaDecodeTime=B),M&&(M.timelineStartInfo.dts=void 0,M.timelineStartInfo.pts=void 0,wr.clearDtsInfo(M),ae.audioTimestampRolloverStream&&ae.audioTimestampRolloverStream.discontinuity()),C&&(ae.videoSegmentStream&&(ae.videoSegmentStream.gopCache_=[]),C.timelineStartInfo.dts=void 0,C.timelineStartInfo.pts=void 0,wr.clearDtsInfo(C),ae.captionStream.reset()),ae.timestampRolloverStream&&ae.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(B){M&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(B)},this.setRemux=function(B){var ae=this.transmuxPipeline_;x.remux=B,ae&&ae.coalesceStream&&ae.coalesceStream.setRemux(B)},this.alignGopsWith=function(B){C&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(B)},this.getLogTrigger_=function(B){var ae=this;return function(de){de.stream=B,ae.trigger("log",de)}},this.push=function(B){if(D){var ae=Bp(B);ae&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!ae&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),D=!1}this.transmuxPipeline_.headOfPipeline.push(B)},this.flush=function(){D=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},Lu.prototype=new Ta;var Up={Transmuxer:Lu},jp=function(x){return x>>>0},$p=function(x){return("00"+x.toString(16)).slice(-2)},Mo={toUnsigned:jp,toHexString:$p},Pl=function(x){var A="";return A+=String.fromCharCode(x[0]),A+=String.fromCharCode(x[1]),A+=String.fromCharCode(x[2]),A+=String.fromCharCode(x[3]),A},cf=Pl,df=Mo.toUnsigned,hf=cf,id=function(x,A){var D=[],C,M,B,ae,de;if(!A.length)return null;for(C=0;C<x.byteLength;)M=df(x[C]<<24|x[C+1]<<16|x[C+2]<<8|x[C+3]),B=hf(x.subarray(C+4,C+8)),ae=M>1?C+M:x.byteLength,B===A[0]&&(A.length===1?D.push(x.subarray(C+8,ae)):(de=id(x.subarray(C+8,ae),A.slice(1)),de.length&&(D=D.concat(de)))),C=ae;return D},Ru=id,ff=Mo.toUnsigned,Po=r.getUint64,Hp=function(x){var A={version:x[0],flags:new Uint8Array(x.subarray(1,4))};return A.version===1?A.baseMediaDecodeTime=Po(x.subarray(4)):A.baseMediaDecodeTime=ff(x[4]<<24|x[5]<<16|x[6]<<8|x[7]),A},sd=Hp,zp=function(x){var A=new DataView(x.buffer,x.byteOffset,x.byteLength),D={version:x[0],flags:new Uint8Array(x.subarray(1,4)),trackId:A.getUint32(4)},C=D.flags[2]&1,M=D.flags[2]&2,B=D.flags[2]&8,ae=D.flags[2]&16,de=D.flags[2]&32,he=D.flags[0]&65536,ve=D.flags[0]&131072,Ce;return Ce=8,C&&(Ce+=4,D.baseDataOffset=A.getUint32(12),Ce+=4),M&&(D.sampleDescriptionIndex=A.getUint32(Ce),Ce+=4),B&&(D.defaultSampleDuration=A.getUint32(Ce),Ce+=4),ae&&(D.defaultSampleSize=A.getUint32(Ce),Ce+=4),de&&(D.defaultSampleFlags=A.getUint32(Ce)),he&&(D.durationIsEmpty=!0),!C&&ve&&(D.baseDataOffsetIsMoof=!0),D},nd=zp,mf=function(x){return{isLeading:(x[0]&12)>>>2,dependsOn:x[0]&3,isDependedOn:(x[1]&192)>>>6,hasRedundancy:(x[1]&48)>>>4,paddingValue:(x[1]&14)>>>1,isNonSyncSample:x[1]&1,degradationPriority:x[2]<<8|x[3]}},Bl=mf,Bo=Bl,Vp=function(x){var A={version:x[0],flags:new Uint8Array(x.subarray(1,4)),samples:[]},D=new DataView(x.buffer,x.byteOffset,x.byteLength),C=A.flags[2]&1,M=A.flags[2]&4,B=A.flags[1]&1,ae=A.flags[1]&2,de=A.flags[1]&4,he=A.flags[1]&8,ve=D.getUint32(4),Ce=8,et;for(C&&(A.dataOffset=D.getInt32(Ce),Ce+=4),M&&ve&&(et={flags:Bo(x.subarray(Ce,Ce+4))},Ce+=4,B&&(et.duration=D.getUint32(Ce),Ce+=4),ae&&(et.size=D.getUint32(Ce),Ce+=4),he&&(A.version===1?et.compositionTimeOffset=D.getInt32(Ce):et.compositionTimeOffset=D.getUint32(Ce),Ce+=4),A.samples.push(et),ve--);ve--;)et={},B&&(et.duration=D.getUint32(Ce),Ce+=4),ae&&(et.size=D.getUint32(Ce),Ce+=4),de&&(et.flags=Bo(x.subarray(Ce,Ce+4)),Ce+=4),he&&(A.version===1?et.compositionTimeOffset=D.getInt32(Ce):et.compositionTimeOffset=D.getUint32(Ce),Ce+=4),A.samples.push(et);return A},Fl=Vp,rd={tfdt:sd,trun:Fl},ad={parseTfdt:rd.tfdt,parseTrun:rd.trun},od=function(x){for(var A=0,D=String.fromCharCode(x[A]),C="";D!=="\0";)C+=D,A++,D=String.fromCharCode(x[A]);return C+=D,C},ld={uint8ToCString:od},Ul=ld.uint8ToCString,pf=r.getUint64,gf=function(x){var A=4,D=x[0],C,M,B,ae,de,he,ve,Ce;if(D===0){C=Ul(x.subarray(A)),A+=C.length,M=Ul(x.subarray(A)),A+=M.length;var et=new DataView(x.buffer);B=et.getUint32(A),A+=4,de=et.getUint32(A),A+=4,he=et.getUint32(A),A+=4,ve=et.getUint32(A),A+=4}else if(D===1){var et=new DataView(x.buffer);B=et.getUint32(A),A+=4,ae=pf(x.subarray(A)),A+=8,he=et.getUint32(A),A+=4,ve=et.getUint32(A),A+=4,C=Ul(x.subarray(A)),A+=C.length,M=Ul(x.subarray(A)),A+=M.length}Ce=new Uint8Array(x.subarray(A,x.byteLength));var At={scheme_id_uri:C,value:M,timescale:B||1,presentation_time:ae,presentation_time_delta:de,event_duration:he,id:ve,message_data:Ce};return qp(D,At)?At:void 0},Gp=function(x,A,D,C){return x||x===0?x/A:C+D/A},qp=function(x,A){var D=A.scheme_id_uri!=="\0",C=x===0&&yf(A.presentation_time_delta)&&D,M=x===1&&yf(A.presentation_time)&&D;return!(x>1)&&C||M},yf=function(x){return x!==void 0||x!==null},Kp={parseEmsgBox:gf,scaleTime:Gp},jl;typeof window<"u"?jl=window:typeof s<"u"?jl=s:typeof self<"u"?jl=self:jl={};var Gn=jl,Sa=Mo.toUnsigned,Fo=Mo.toHexString,Ps=Ru,to=cf,Iu=Kp,ud=nd,Wp=Fl,Uo=sd,cd=r.getUint64,jo,Nu,dd,_a,io,$l,hd,oa=Gn,vf=Ct.parseId3Frames;jo=function(x){var A={},D=Ps(x,["moov","trak"]);return D.reduce(function(C,M){var B,ae,de,he,ve;return B=Ps(M,["tkhd"])[0],!B||(ae=B[0],de=ae===0?12:20,he=Sa(B[de]<<24|B[de+1]<<16|B[de+2]<<8|B[de+3]),ve=Ps(M,["mdia","mdhd"])[0],!ve)?null:(ae=ve[0],de=ae===0?12:20,C[he]=Sa(ve[de]<<24|ve[de+1]<<16|ve[de+2]<<8|ve[de+3]),C)},A)},Nu=function(x,A){var D;D=Ps(A,["moof","traf"]);var C=D.reduce(function(M,B){var ae=Ps(B,["tfhd"])[0],de=Sa(ae[4]<<24|ae[5]<<16|ae[6]<<8|ae[7]),he=x[de]||9e4,ve=Ps(B,["tfdt"])[0],Ce=new DataView(ve.buffer,ve.byteOffset,ve.byteLength),et;ve[0]===1?et=cd(ve.subarray(4,12)):et=Ce.getUint32(4);let At;return typeof et=="bigint"?At=et/oa.BigInt(he):typeof et=="number"&&!isNaN(et)&&(At=et/he),At<Number.MAX_SAFE_INTEGER&&(At=Number(At)),At<M&&(M=At),M},1/0);return typeof C=="bigint"||isFinite(C)?C:0},dd=function(x,A){var D=Ps(A,["moof","traf"]),C=0,M=0,B;if(D&&D.length){var ae=Ps(D[0],["tfhd"])[0],de=Ps(D[0],["trun"])[0],he=Ps(D[0],["tfdt"])[0];if(ae){var ve=ud(ae);B=ve.trackId}if(he){var Ce=Uo(he);C=Ce.baseMediaDecodeTime}if(de){var et=Wp(de);et.samples&&et.samples.length&&(M=et.samples[0].compositionTimeOffset||0)}}var At=x[B]||9e4;typeof C=="bigint"&&(M=oa.BigInt(M),At=oa.BigInt(At));var nt=(C+M)/At;return typeof nt=="bigint"&&nt<Number.MAX_SAFE_INTEGER&&(nt=Number(nt)),nt},_a=function(x){var A=Ps(x,["moov","trak"]),D=[];return A.forEach(function(C){var M=Ps(C,["mdia","hdlr"]),B=Ps(C,["tkhd"]);M.forEach(function(ae,de){var he=to(ae.subarray(8,12)),ve=B[de],Ce,et,At;he==="vide"&&(Ce=new DataView(ve.buffer,ve.byteOffset,ve.byteLength),et=Ce.getUint8(0),At=et===0?Ce.getUint32(12):Ce.getUint32(20),D.push(At))})}),D},$l=function(x){var A=x[0],D=A===0?12:20;return Sa(x[D]<<24|x[D+1]<<16|x[D+2]<<8|x[D+3])},io=function(x){var A=Ps(x,["moov","trak"]),D=[];return A.forEach(function(C){var M={},B=Ps(C,["tkhd"])[0],ae,de;B&&(ae=new DataView(B.buffer,B.byteOffset,B.byteLength),de=ae.getUint8(0),M.id=de===0?ae.getUint32(12):ae.getUint32(20));var he=Ps(C,["mdia","hdlr"])[0];if(he){var ve=to(he.subarray(8,12));ve==="vide"?M.type="video":ve==="soun"?M.type="audio":M.type=ve}var Ce=Ps(C,["mdia","minf","stbl","stsd"])[0];if(Ce){var et=Ce.subarray(8);M.codec=to(et.subarray(4,8));var At=Ps(et,[M.codec])[0],nt,Bt;At&&(/^[asm]vc[1-9]$/i.test(M.codec)?(nt=At.subarray(78),Bt=to(nt.subarray(4,8)),Bt==="avcC"&&nt.length>11?(M.codec+=".",M.codec+=Fo(nt[9]),M.codec+=Fo(nt[10]),M.codec+=Fo(nt[11])):M.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(M.codec)?(nt=At.subarray(28),Bt=to(nt.subarray(4,8)),Bt==="esds"&&nt.length>20&&nt[19]!==0?(M.codec+="."+Fo(nt[19]),M.codec+="."+Fo(nt[20]>>>2&63).replace(/^0/,"")):M.codec="mp4a.40.2"):M.codec=M.codec.toLowerCase())}var mi=Ps(C,["mdia","mdhd"])[0];mi&&(M.timescale=$l(mi)),D.push(M)}),D},hd=function(x,A=0){var D=Ps(x,["emsg"]);return D.map(C=>{var M=Iu.parseEmsgBox(new Uint8Array(C)),B=vf(M.message_data);return{cueTime:Iu.scaleTime(M.presentation_time,M.timescale,M.presentation_time_delta,A),duration:Iu.scaleTime(M.event_duration,M.timescale),frames:B}})};var $o={findBox:Ps,parseType:to,timescale:jo,startTime:Nu,compositionStartTime:dd,videoTrackIds:_a,tracks:io,getTimescaleFromMediaHeader:$l,getEmsgID3:hd};const{parseTrun:xf}=ad,{findBox:bf}=$o;var Tf=Gn,Yp=function(x){var A=bf(x,["moof","traf"]),D=bf(x,["mdat"]),C=[];return D.forEach(function(M,B){var ae=A[B];C.push({mdat:M,traf:ae})}),C},Sf=function(x,A,D){var C=A,M=D.defaultSampleDuration||0,B=D.defaultSampleSize||0,ae=D.trackId,de=[];return x.forEach(function(he){var ve=xf(he),Ce=ve.samples;Ce.forEach(function(et){et.duration===void 0&&(et.duration=M),et.size===void 0&&(et.size=B),et.trackId=ae,et.dts=C,et.compositionTimeOffset===void 0&&(et.compositionTimeOffset=0),typeof C=="bigint"?(et.pts=C+Tf.BigInt(et.compositionTimeOffset),C+=Tf.BigInt(et.duration)):(et.pts=C+et.compositionTimeOffset,C+=et.duration)}),de=de.concat(Ce)}),de},fd={getMdatTrafPairs:Yp,parseSamples:Sf},md=oi.discardEmulationPreventionBytes,Ar=Zi.CaptionStream,Ho=Ru,nr=sd,zo=nd,{getMdatTrafPairs:pd,parseSamples:Ou}=fd,Mu=function(x,A){for(var D=x,C=0;C<A.length;C++){var M=A[C];if(D<M.size)return M;D-=M.size}return null},gd=function(x,A,D){var C=new DataView(x.buffer,x.byteOffset,x.byteLength),M={logs:[],seiNals:[]},B,ae,de,he;for(ae=0;ae+4<x.length;ae+=de)if(de=C.getUint32(ae),ae+=4,!(de<=0))switch(x[ae]&31){case 6:var ve=x.subarray(ae+1,ae+1+de),Ce=Mu(ae,A);if(B={nalUnitType:"sei_rbsp",size:de,data:ve,escapedRBSP:md(ve),trackId:D},Ce)B.pts=Ce.pts,B.dts=Ce.dts,he=Ce;else if(he)B.pts=he.pts,B.dts=he.dts;else{M.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+ae+" for trackId "+D+". See mux.js#223."});break}M.seiNals.push(B);break}return M},so=function(x,A){var D={},C=pd(x);return C.forEach(function(M){var B=M.mdat,ae=M.traf,de=Ho(ae,["tfhd"]),he=zo(de[0]),ve=he.trackId,Ce=Ho(ae,["tfdt"]),et=Ce.length>0?nr(Ce[0]).baseMediaDecodeTime:0,At=Ho(ae,["trun"]),nt,Bt;A===ve&&At.length>0&&(nt=Ou(At,et,he),Bt=gd(B,nt,ve),D[ve]||(D[ve]={seiNals:[],logs:[]}),D[ve].seiNals=D[ve].seiNals.concat(Bt.seiNals),D[ve].logs=D[ve].logs.concat(Bt.logs))}),D},_f=function(x,A,D){var C;if(A===null)return null;C=so(x,A);var M=C[A]||{};return{seiNals:M.seiNals,logs:M.logs,timescale:D}},Pu=function(){var x=!1,A,D,C,M,B,ae;this.isInitialized=function(){return x},this.init=function(de){A=new Ar,x=!0,ae=de?de.isPartial:!1,A.on("data",function(he){he.startTime=he.startPts/M,he.endTime=he.endPts/M,B.captions.push(he),B.captionStreams[he.stream]=!0}),A.on("log",function(he){B.logs.push(he)})},this.isNewInit=function(de,he){return de&&de.length===0||he&&typeof he=="object"&&Object.keys(he).length===0?!1:C!==de[0]||M!==he[C]},this.parse=function(de,he,ve){var Ce;if(this.isInitialized()){if(!he||!ve)return null;if(this.isNewInit(he,ve))C=he[0],M=ve[C];else if(C===null||!M)return D.push(de),null}else return null;for(;D.length>0;){var et=D.shift();this.parse(et,he,ve)}return Ce=_f(de,C,M),Ce&&Ce.logs&&(B.logs=B.logs.concat(Ce.logs)),Ce===null||!Ce.seiNals?B.logs.length?{logs:B.logs,captions:[],captionStreams:[]}:null:(this.pushNals(Ce.seiNals),this.flushStream(),B)},this.pushNals=function(de){if(!this.isInitialized()||!de||de.length===0)return null;de.forEach(function(he){A.push(he)})},this.flushStream=function(){if(!this.isInitialized())return null;ae?A.partialFlush():A.flush()},this.clearParsedCaptions=function(){B.captions=[],B.captionStreams={},B.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;A.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){D=[],C=null,M=null,B?this.clearParsedCaptions():B={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Vo=Pu;const{parseTfdt:Xp}=ad,qs=Ru,{getTimescaleFromMediaHeader:yd}=$o,{parseSamples:la,getMdatTrafPairs:Ef}=fd;var Ea=function(){let x=9e4;this.init=function(A){const D=qs(A,["moov","trak","mdia","mdhd"])[0];D&&(x=yd(D))},this.parseSegment=function(A){const D=[],C=Ef(A);let M=0;return C.forEach(function(B){const ae=B.mdat,de=B.traf,he=qs(de,["tfdt"])[0],ve=qs(de,["tfhd"])[0],Ce=qs(de,["trun"]);if(he&&(M=Xp(he).baseMediaDecodeTime),Ce.length&&ve){const et=la(Ce,M,ve);let At=0;et.forEach(function(nt){const Bt="utf-8",mi=new TextDecoder(Bt),tn=ae.slice(At,At+nt.size);if(qs(tn,["vtte"])[0]){At+=nt.size;return}qs(tn,["vttc"]).forEach(function(Gl){const Ds=qs(Gl,["payl"])[0],no=qs(Gl,["sttg"])[0],ua=nt.pts/x,La=(nt.pts+nt.duration)/x;let as,Gr;if(Ds)try{as=mi.decode(Ds)}catch(wn){console.error(wn)}if(no)try{Gr=mi.decode(no)}catch(wn){console.error(wn)}nt.duration&&as&&D.push({cueText:as,start:ua,end:La,settings:Gr})}),At+=nt.size})}}),D}},Hl=ts,xd=function(x){var A=x[1]&31;return A<<=8,A|=x[2],A},Go=function(x){return!!(x[1]&64)},zl=function(x){var A=0;return(x[3]&48)>>>4>1&&(A+=x[4]+1),A},rr=function(x,A){var D=xd(x);return D===0?"pat":D===A?"pmt":A?"pes":null},qo=function(x){var A=Go(x),D=4+zl(x);return A&&(D+=x[D]+1),(x[D+10]&31)<<8|x[D+11]},Ko=function(x){var A={},D=Go(x),C=4+zl(x);if(D&&(C+=x[C]+1),!!(x[C+5]&1)){var M,B,ae;M=(x[C+1]&15)<<8|x[C+2],B=3+M-4,ae=(x[C+10]&15)<<8|x[C+11];for(var de=12+ae;de<B;){var he=C+de;A[(x[he+1]&31)<<8|x[he+2]]=x[he],de+=((x[he+3]&15)<<8|x[he+4])+5}return A}},Bu=function(x,A){var D=xd(x),C=A[D];switch(C){case Hl.H264_STREAM_TYPE:return"video";case Hl.ADTS_STREAM_TYPE:return"audio";case Hl.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},Vl=function(x){var A=Go(x);if(!A)return null;var D=4+zl(x);if(D>=x.byteLength)return null;var C=null,M;return M=x[D+7],M&192&&(C={},C.pts=(x[D+9]&14)<<27|(x[D+10]&255)<<20|(x[D+11]&254)<<12|(x[D+12]&255)<<5|(x[D+13]&254)>>>3,C.pts*=4,C.pts+=(x[D+13]&6)>>>1,C.dts=C.pts,M&64&&(C.dts=(x[D+14]&14)<<27|(x[D+15]&255)<<20|(x[D+16]&254)<<12|(x[D+17]&255)<<5|(x[D+18]&254)>>>3,C.dts*=4,C.dts+=(x[D+18]&6)>>>1)),C},qn=function(x){switch(x){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},ar=function(x){for(var A=4+zl(x),D=x.subarray(A),C=0,M=0,B=!1,ae;M<D.byteLength-3;M++)if(D[M+2]===1){C=M+5;break}for(;C<D.byteLength;)switch(D[C]){case 0:if(D[C-1]!==0){C+=2;break}else if(D[C-2]!==0){C++;break}M+3!==C-2&&(ae=qn(D[M+3]&31),ae==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0));do C++;while(D[C]!==1&&C<D.length);M=C-2,C+=3;break;case 1:if(D[C-1]!==0||D[C-2]!==0){C+=3;break}ae=qn(D[M+3]&31),ae==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0),M=C-2,C+=3;break;default:C+=3;break}return D=D.subarray(M),C-=M,M=0,D&&D.byteLength>3&&(ae=qn(D[M+3]&31),ae==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0)),B},wa={parseType:rr,parsePat:qo,parsePmt:Ko,parsePayloadUnitStartIndicator:Go,parsePesType:Bu,parsePesTime:Vl,videoPacketContainsKeyFrame:ar},kr=ts,Bn=rs.handleRollover,Ei={};Ei.ts=wa,Ei.aac=gn;var Aa=Tt.ONE_SECOND_IN_TS,vn=188,or=71,wf=function(x,A){for(var D=0,C=vn,M,B;C<x.byteLength;){if(x[D]===or&&x[C]===or){switch(M=x.subarray(D,C),B=Ei.ts.parseType(M,A.pid),B){case"pat":A.pid=Ei.ts.parsePat(M);break;case"pmt":var ae=Ei.ts.parsePmt(M);A.table=A.table||{},Object.keys(ae).forEach(function(de){A.table[de]=ae[de]});break}D+=vn,C+=vn;continue}D++,C++}},cn=function(x,A,D){for(var C=0,M=vn,B,ae,de,he,ve,Ce=!1;M<=x.byteLength;){if(x[C]===or&&(x[M]===or||M===x.byteLength)){if(B=x.subarray(C,M),ae=Ei.ts.parseType(B,A.pid),ae==="pes"&&(de=Ei.ts.parsePesType(B,A.table),he=Ei.ts.parsePayloadUnitStartIndicator(B),de==="audio"&&he&&(ve=Ei.ts.parsePesTime(B),ve&&(ve.type="audio",D.audio.push(ve),Ce=!0))),Ce)break;C+=vn,M+=vn;continue}C++,M++}for(M=x.byteLength,C=M-vn,Ce=!1;C>=0;){if(x[C]===or&&(x[M]===or||M===x.byteLength)){if(B=x.subarray(C,M),ae=Ei.ts.parseType(B,A.pid),ae==="pes"&&(de=Ei.ts.parsePesType(B,A.table),he=Ei.ts.parsePayloadUnitStartIndicator(B),de==="audio"&&he&&(ve=Ei.ts.parsePesTime(B),ve&&(ve.type="audio",D.audio.push(ve),Ce=!0))),Ce)break;C-=vn,M-=vn;continue}C--,M--}},Ss=function(x,A,D){for(var C=0,M=vn,B,ae,de,he,ve,Ce,et,At,nt=!1,Bt={data:[],size:0};M<x.byteLength;){if(x[C]===or&&x[M]===or){switch(B=x.subarray(C,M),ae=Ei.ts.parseType(B,A.pid),ae){case"pes":if(de=Ei.ts.parsePesType(B,A.table),he=Ei.ts.parsePayloadUnitStartIndicator(B),de==="video"&&(he&&!nt&&(ve=Ei.ts.parsePesTime(B),ve&&(ve.type="video",D.video.push(ve),nt=!0)),!D.firstKeyFrame)){if(he&&Bt.size!==0){for(Ce=new Uint8Array(Bt.size),et=0;Bt.data.length;)At=Bt.data.shift(),Ce.set(At,et),et+=At.byteLength;if(Ei.ts.videoPacketContainsKeyFrame(Ce)){var mi=Ei.ts.parsePesTime(Ce);mi?(D.firstKeyFrame=mi,D.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}Bt.size=0}Bt.data.push(B),Bt.size+=B.byteLength}break}if(nt&&D.firstKeyFrame)break;C+=vn,M+=vn;continue}C++,M++}for(M=x.byteLength,C=M-vn,nt=!1;C>=0;){if(x[C]===or&&x[M]===or){if(B=x.subarray(C,M),ae=Ei.ts.parseType(B,A.pid),ae==="pes"&&(de=Ei.ts.parsePesType(B,A.table),he=Ei.ts.parsePayloadUnitStartIndicator(B),de==="video"&&he&&(ve=Ei.ts.parsePesTime(B),ve&&(ve.type="video",D.video.push(ve),nt=!0))),nt)break;C-=vn,M-=vn;continue}C--,M--}},Ni=function(x,A){if(x.audio&&x.audio.length){var D=A;(typeof D>"u"||isNaN(D))&&(D=x.audio[0].dts),x.audio.forEach(function(B){B.dts=Bn(B.dts,D),B.pts=Bn(B.pts,D),B.dtsTime=B.dts/Aa,B.ptsTime=B.pts/Aa})}if(x.video&&x.video.length){var C=A;if((typeof C>"u"||isNaN(C))&&(C=x.video[0].dts),x.video.forEach(function(B){B.dts=Bn(B.dts,C),B.pts=Bn(B.pts,C),B.dtsTime=B.dts/Aa,B.ptsTime=B.pts/Aa}),x.firstKeyFrame){var M=x.firstKeyFrame;M.dts=Bn(M.dts,C),M.pts=Bn(M.pts,C),M.dtsTime=M.dts/Aa,M.ptsTime=M.pts/Aa}}},ka=function(x){for(var A=!1,D=0,C=null,M=null,B=0,ae=0,de;x.length-ae>=3;){var he=Ei.aac.parseType(x,ae);switch(he){case"timed-metadata":if(x.length-ae<10){A=!0;break}if(B=Ei.aac.parseId3TagSize(x,ae),B>x.length){A=!0;break}M===null&&(de=x.subarray(ae,ae+B),M=Ei.aac.parseAacTimestamp(de)),ae+=B;break;case"audio":if(x.length-ae<7){A=!0;break}if(B=Ei.aac.parseAdtsSize(x,ae),B>x.length){A=!0;break}C===null&&(de=x.subarray(ae,ae+B),C=Ei.aac.parseSampleRate(de)),D++,ae+=B;break;default:ae++;break}if(A)return null}if(C===null||M===null)return null;var ve=Aa/C,Ce={audio:[{type:"audio",dts:M,pts:M},{type:"audio",dts:M+D*1024*ve,pts:M+D*1024*ve}]};return Ce},lr=function(x){var A={pid:null,table:null},D={};wf(x,A);for(var C in A.table)if(A.table.hasOwnProperty(C)){var M=A.table[C];switch(M){case kr.H264_STREAM_TYPE:D.video=[],Ss(x,A,D),D.video.length===0&&delete D.video;break;case kr.ADTS_STREAM_TYPE:D.audio=[],cn(x,A,D),D.audio.length===0&&delete D.audio;break}}return D},bd=function(x,A){var D=Ei.aac.isLikelyAacData(x),C;return D?C=ka(x):C=lr(x),!C||!C.audio&&!C.video?null:(Ni(C,A),C)},Ca={inspect:bd,parseAudioPes_:cn};const Af=function(x,A){A.on("data",function(D){const C=D.initSegment;D.initSegment={data:C.buffer,byteOffset:C.byteOffset,byteLength:C.byteLength};const M=D.data;D.data=M.buffer,x.postMessage({action:"data",segment:D,byteOffset:M.byteOffset,byteLength:M.byteLength},[D.data])}),A.on("done",function(D){x.postMessage({action:"done"})}),A.on("gopInfo",function(D){x.postMessage({action:"gopInfo",gopInfo:D})}),A.on("videoSegmentTimingInfo",function(D){const C={start:{decode:Tt.videoTsToSeconds(D.start.dts),presentation:Tt.videoTsToSeconds(D.start.pts)},end:{decode:Tt.videoTsToSeconds(D.end.dts),presentation:Tt.videoTsToSeconds(D.end.pts)},baseMediaDecodeTime:Tt.videoTsToSeconds(D.baseMediaDecodeTime)};D.prependedContentDuration&&(C.prependedContentDuration=Tt.videoTsToSeconds(D.prependedContentDuration)),x.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:C})}),A.on("audioSegmentTimingInfo",function(D){const C={start:{decode:Tt.videoTsToSeconds(D.start.dts),presentation:Tt.videoTsToSeconds(D.start.pts)},end:{decode:Tt.videoTsToSeconds(D.end.dts),presentation:Tt.videoTsToSeconds(D.end.pts)},baseMediaDecodeTime:Tt.videoTsToSeconds(D.baseMediaDecodeTime)};D.prependedContentDuration&&(C.prependedContentDuration=Tt.videoTsToSeconds(D.prependedContentDuration)),x.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:C})}),A.on("id3Frame",function(D){x.postMessage({action:"id3Frame",id3Frame:D})}),A.on("caption",function(D){x.postMessage({action:"caption",caption:D})}),A.on("trackinfo",function(D){x.postMessage({action:"trackinfo",trackInfo:D})}),A.on("audioTimingInfo",function(D){x.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:Tt.videoTsToSeconds(D.start),end:Tt.videoTsToSeconds(D.end)}})}),A.on("videoTimingInfo",function(D){x.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:Tt.videoTsToSeconds(D.start),end:Tt.videoTsToSeconds(D.end)}})}),A.on("log",function(D){x.postMessage({action:"log",log:D})})};class Td{constructor(A,D){this.options=D||{},this.self=A,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Up.Transmuxer(this.options),Af(this.self,this.transmuxer)}pushMp4Captions(A){this.captionParser||(this.captionParser=new Vo,this.captionParser.init());const D=new Uint8Array(A.data,A.byteOffset,A.byteLength),C=this.captionParser.parse(D,A.trackIds,A.timescales);this.self.postMessage({action:"mp4Captions",captions:C&&C.captions||[],logs:C&&C.logs||[],data:D.buffer},[D.buffer])}initMp4WebVttParser(A){this.webVttParser||(this.webVttParser=new Ea);const D=new Uint8Array(A.data,A.byteOffset,A.byteLength);this.webVttParser.init(D)}getMp4WebVttText(A){this.webVttParser||(this.webVttParser=new Ea);const D=new Uint8Array(A.data,A.byteOffset,A.byteLength),C=this.webVttParser.parseSegment(D);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:C||[],data:D.buffer},[D.buffer])}probeMp4StartTime({timescales:A,data:D}){const C=$o.startTime(A,D);this.self.postMessage({action:"probeMp4StartTime",startTime:C,data:D},[D.buffer])}probeMp4Tracks({data:A}){const D=$o.tracks(A);this.self.postMessage({action:"probeMp4Tracks",tracks:D,data:A},[A.buffer])}probeEmsgID3({data:A,offset:D}){const C=$o.getEmsgID3(A,D);this.self.postMessage({action:"probeEmsgID3",id3Frames:C,emsgData:A},[A.buffer])}probeTs({data:A,baseStartTime:D}){const C=typeof D=="number"&&!isNaN(D)?D*Tt.ONE_SECOND_IN_TS:void 0,M=Ca.inspect(A,C);let B=null;M&&(B={hasVideo:M.video&&M.video.length===2||!1,hasAudio:M.audio&&M.audio.length===2||!1},B.hasVideo&&(B.videoStart=M.video[0].ptsTime),B.hasAudio&&(B.audioStart=M.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:B,data:A},[A.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(A){const D=new Uint8Array(A.data,A.byteOffset,A.byteLength);this.transmuxer.push(D)}reset(){this.transmuxer.reset()}setTimestampOffset(A){const D=A.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(Tt.secondsToVideoTs(D)))}setAudioAppendStart(A){this.transmuxer.setAudioAppendStart(Math.ceil(Tt.secondsToVideoTs(A.appendStart)))}setRemux(A){this.transmuxer.setRemux(A.remux)}flush(A){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(A){this.transmuxer.alignGopsWith(A.gopsToAlignWith.slice())}}self.onmessage=function(x){if(x.data.action==="init"&&x.data.options){this.messageHandlers=new Td(self,x.data.options);return}this.messageHandlers||(this.messageHandlers=new Td(self)),x.data&&x.data.action&&x.data.action!=="init"&&this.messageHandlers[x.data.action]&&this.messageHandlers[x.data.action](x.data)}}));var r8=AD(n8);const a8=(s,e,t)=>{const{type:i,initSegment:n,captions:r,captionStreams:a,metadata:u,videoFrameDtsTime:c,videoFramePtsTime:d}=s.data.segment;e.buffer.push({captions:r,captionStreams:a,metadata:u});const f=s.data.segment.boxes||{data:s.data.segment.data},g={type:i,data:new Uint8Array(f.data,f.data.byteOffset,f.data.byteLength),initSegment:new Uint8Array(n.data,n.byteOffset,n.byteLength)};typeof c<"u"&&(g.videoFrameDtsTime=c),typeof d<"u"&&(g.videoFramePtsTime=d),t(g)},o8=({transmuxedData:s,callback:e})=>{s.buffer=[],e(s)},l8=(s,e)=>{e.gopInfo=s.data.gopInfo},DD=s=>{const{transmuxer:e,bytes:t,audioAppendStart:i,gopsToAlignWith:n,remux:r,onData:a,onTrackInfo:u,onAudioTimingInfo:c,onVideoTimingInfo:d,onVideoSegmentTimingInfo:f,onAudioSegmentTimingInfo:g,onId3:y,onCaptions:v,onDone:T,onEndedTimeline:S,onTransmuxerLog:w,isEndOfTimeline:L,segment:O,triggerSegmentEventFn:I}=s,j={buffer:[]};let P=L;const G=K=>{e.currentTransmux===s&&(K.data.action==="data"&&a8(K,j,a),K.data.action==="trackinfo"&&u(K.data.trackInfo),K.data.action==="gopInfo"&&l8(K,j),K.data.action==="audioTimingInfo"&&c(K.data.audioTimingInfo),K.data.action==="videoTimingInfo"&&d(K.data.videoTimingInfo),K.data.action==="videoSegmentTimingInfo"&&f(K.data.videoSegmentTimingInfo),K.data.action==="audioSegmentTimingInfo"&&g(K.data.audioSegmentTimingInfo),K.data.action==="id3Frame"&&y([K.data.id3Frame],K.data.id3Frame.dispatchType),K.data.action==="caption"&&v(K.data.caption),K.data.action==="endedtimeline"&&(P=!1,S()),K.data.action==="log"&&w(K.data.log),K.data.type==="transmuxed"&&(P||(e.onmessage=null,o8({transmuxedData:j,callback:T}),LD(e))))},N=()=>{const K={message:"Received an error message from the transmuxer worker",metadata:{errorType:He.Error.StreamingFailedToTransmuxSegment,segmentInfo:du({segment:O})}};T(null,K)};if(e.onmessage=G,e.onerror=N,i&&e.postMessage({action:"setAudioAppendStart",appendStart:i}),Array.isArray(n)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:n}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const K=t instanceof ArrayBuffer?t:t.buffer,k=t instanceof ArrayBuffer?0:t.byteOffset;I({type:"segmenttransmuxingstart",segment:O}),e.postMessage({action:"push",data:K,byteOffset:k,byteLength:t.byteLength},[K])}L&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},LD=s=>{s.currentTransmux=null,s.transmuxQueue.length&&(s.currentTransmux=s.transmuxQueue.shift(),typeof s.currentTransmux=="function"?s.currentTransmux():DD(s.currentTransmux))},NE=(s,e)=>{s.postMessage({action:e}),LD(s)},RD=(s,e)=>{if(!e.currentTransmux){e.currentTransmux=s,NE(e,s);return}e.transmuxQueue.push(NE.bind(null,e,s))},u8=s=>{RD("reset",s)},c8=s=>{RD("endTimeline",s)},ID=s=>{if(!s.transmuxer.currentTransmux){s.transmuxer.currentTransmux=s,DD(s);return}s.transmuxer.transmuxQueue.push(s)},d8=s=>{const e=new r8;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:s}),e};var Sv={reset:u8,endTimeline:c8,transmux:ID,createTransmuxer:d8};const wc=function(s){const e=s.transmuxer,t=s.endAction||s.action,i=s.callback,n=on({},s,{endAction:null,transmuxer:null,callback:null}),r=a=>{a.data.action===t&&(e.removeEventListener("message",r),a.data.data&&(a.data.data=new Uint8Array(a.data.data,s.byteOffset||0,s.byteLength||a.data.data.byteLength),s.data&&(s.data=a.data.data)),i(a.data))};if(e.addEventListener("message",r),s.data){const a=s.data instanceof ArrayBuffer;n.byteOffset=a?0:s.data.byteOffset,n.byteLength=s.data.byteLength;const u=[a?s.data:s.data.buffer];e.postMessage(n,u)}else e.postMessage(n)},Va={FAILURE:2,TIMEOUT:-101,ABORTED:-102},ND="wvtt",Bx=s=>{s.forEach(e=>{e.abort()})},h8=s=>({bandwidth:s.bandwidth,bytesReceived:s.bytesReceived||0,roundTripTime:s.roundTripTime||0}),f8=s=>{const e=s.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return i.bytesReceived=s.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i},e1=(s,e)=>{const{requestType:t}=e,i=xu({requestType:t,request:e,error:s});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Va.TIMEOUT,xhr:e,metadata:i}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Va.ABORTED,xhr:e,metadata:i}:s?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Va.FAILURE,xhr:e,metadata:i}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Va.FAILURE,xhr:e,metadata:i}:null},OE=(s,e,t,i)=>(n,r)=>{const a=r.response,u=e1(n,r);if(u)return t(u,s);if(a.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Va.FAILURE,xhr:r},s);const c=new DataView(a),d=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let g=0;g<e.length;g++)e[g].bytes=d;const f={uri:r.uri};return i({type:"segmentkeyloadcomplete",segment:s,keyInfo:f}),t(null,s)},m8=(s,e)=>{e===ND&&s.transmuxer.postMessage({action:"initMp4WebVttParser",data:s.map.bytes})},p8=(s,e,t)=>{e===ND&&wc({action:"getMp4WebVttText",data:s.bytes,transmuxer:s.transmuxer,callback:({data:i,mp4VttCues:n})=>{s.bytes=i,t(null,s,{mp4VttCues:n})}})},OD=(s,e)=>{const t=_b(s.map.bytes);if(t!=="mp4"){const i=s.map.resolvedUri||s.map.uri,n=t||"unknown";return e({internal:!0,message:`Found unsupported ${n} container for initialization segment at URL: ${i}`,code:Va.FAILURE,metadata:{mediaType:n}})}wc({action:"probeMp4Tracks",data:s.map.bytes,transmuxer:s.transmuxer,callback:({tracks:i,data:n})=>(s.map.bytes=n,i.forEach(function(r){s.map.tracks=s.map.tracks||{},!s.map.tracks[r.type]&&(s.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(s.map.timescales=s.map.timescales||{},s.map.timescales[r.id]=r.timescale),r.type==="text"&&m8(s,r.codec))}),e(null))})},g8=({segment:s,finishProcessingFn:e,triggerSegmentEventFn:t})=>(i,n)=>{const r=e1(i,n);if(r)return e(r,s);const a=new Uint8Array(n.response);if(t({type:"segmentloaded",segment:s}),s.map.key)return s.map.encryptedBytes=a,e(null,s);s.map.bytes=a,OD(s,function(u){if(u)return u.xhr=n,u.status=n.status,e(u,s);e(null,s)})},y8=({segment:s,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:i})=>(n,r)=>{const a=e1(n,r);if(a)return e(a,s);i({type:"segmentloaded",segment:s});const u=t==="arraybuffer"||!r.responseText?r.response:i8(r.responseText.substring(s.lastReachedChar||0));return s.stats=h8(r),s.key?s.encryptedBytes=new Uint8Array(u):s.bytes=new Uint8Array(u),e(null,s)},v8=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})=>{const T=s.map&&s.map.tracks||{},S=!!(T.audio&&T.video);let w=i.bind(null,s,"audio","start");const L=i.bind(null,s,"audio","end");let O=i.bind(null,s,"video","start");const I=i.bind(null,s,"video","end"),j=()=>ID({bytes:e,transmuxer:s.transmuxer,audioAppendStart:s.audioAppendStart,gopsToAlignWith:s.gopsToAlignWith,remux:S,onData:P=>{P.type=P.type==="combined"?"video":P.type,f(s,P)},onTrackInfo:P=>{t&&(S&&(P.isMuxed=!0),t(s,P))},onAudioTimingInfo:P=>{w&&typeof P.start<"u"&&(w(P.start),w=null),L&&typeof P.end<"u"&&L(P.end)},onVideoTimingInfo:P=>{O&&typeof P.start<"u"&&(O(P.start),O=null),I&&typeof P.end<"u"&&I(P.end)},onVideoSegmentTimingInfo:P=>{const G={pts:{start:P.start.presentation,end:P.end.presentation},dts:{start:P.start.decode,end:P.end.decode}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:G}),n(P)},onAudioSegmentTimingInfo:P=>{const G={pts:{start:P.start.pts,end:P.end.pts},dts:{start:P.start.dts,end:P.end.dts}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:G}),r(P)},onId3:(P,G)=>{a(s,P,G)},onCaptions:P=>{u(s,[P])},isEndOfTimeline:c,onEndedTimeline:()=>{d()},onTransmuxerLog:y,onDone:(P,G)=>{g&&(P.type=P.type==="combined"?"video":P.type,v({type:"segmenttransmuxingcomplete",segment:s}),g(G,s,P))},segment:s,triggerSegmentEventFn:v});wc({action:"probeTs",transmuxer:s.transmuxer,data:e,baseStartTime:s.baseStartTime,callback:P=>{s.bytes=e=P.data;const G=P.result;G&&(t(s,{hasAudio:G.hasAudio,hasVideo:G.hasVideo,isMuxed:S}),t=null),j()}})},MD=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})=>{let T=new Uint8Array(e);if(U4(T)){s.isFmp4=!0;const{tracks:S}=s.map;if(S.text&&(!S.audio||!S.video)){f(s,{data:T,type:"text"}),p8(s,S.text.codec,g);return}const L={isFmp4:!0,hasVideo:!!S.video,hasAudio:!!S.audio};S.audio&&S.audio.codec&&S.audio.codec!=="enca"&&(L.audioCodec=S.audio.codec),S.video&&S.video.codec&&S.video.codec!=="encv"&&(L.videoCodec=S.video.codec),S.video&&S.audio&&(L.isMuxed=!0),t(s,L);const O=(I,j)=>{f(s,{data:T,type:L.hasAudio&&!L.isMuxed?"audio":"video"}),j&&j.length&&a(s,j),I&&I.length&&u(s,I),g(null,s,{})};wc({action:"probeMp4StartTime",timescales:s.map.timescales,data:T,transmuxer:s.transmuxer,callback:({data:I,startTime:j})=>{e=I.buffer,s.bytes=T=I,L.hasAudio&&!L.isMuxed&&i(s,"audio","start",j),L.hasVideo&&i(s,"video","start",j),wc({action:"probeEmsgID3",data:T,transmuxer:s.transmuxer,offset:j,callback:({emsgData:P,id3Frames:G})=>{if(e=P.buffer,s.bytes=T=P,!S.video||!P.byteLength||!s.transmuxer){O(void 0,G);return}wc({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:s.transmuxer,data:T,timescales:s.map.timescales,trackIds:[S.video.id],callback:N=>{e=N.data.buffer,s.bytes=T=N.data,N.logs.forEach(function(K){y(is(K,{stream:"mp4CaptionParser"}))}),O(N.captions,G)}})}})}});return}if(!s.transmuxer){g(null,s,{});return}if(typeof s.container>"u"&&(s.container=_b(T)),s.container!=="ts"&&s.container!=="aac"){t(s,{hasAudio:!1,hasVideo:!1}),g(null,s,{});return}v8({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})},PD=function({id:s,key:e,encryptedBytes:t,decryptionWorker:i,segment:n,doneFn:r},a){const u=d=>{if(d.data.source===s){i.removeEventListener("message",u);const f=d.data.decrypted;a(new Uint8Array(f.bytes,f.byteOffset,f.byteLength))}};i.onerror=()=>{const d="An error occurred in the decryption worker",f=du({segment:n}),g={message:d,metadata:{error:new Error(d),errorType:He.Error.StreamingFailedToDecryptSegment,segmentInfo:f,keyInfo:{uri:n.key.resolvedUri||n.map.key.resolvedUri}}};r(g,n)},i.addEventListener("message",u);let c;e.bytes.slice?c=e.bytes.slice():c=new Uint32Array(Array.prototype.slice.call(e.bytes)),i.postMessage(bD({source:s,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},x8=({decryptionWorker:s,segment:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})=>{v({type:"segmentdecryptionstart"}),PD({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:s,segment:e,doneFn:g},T=>{e.bytes=T,v({type:"segmentdecryptioncomplete",segment:e}),MD({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})})},b8=({activeXhrs:s,decryptionWorker:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})=>{let T=0,S=!1;return(w,L)=>{if(!S){if(w)return S=!0,Bx(s),g(w,L);if(T+=1,T===s.length){const O=function(){if(L.encryptedBytes)return x8({decryptionWorker:e,segment:L,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v});MD({segment:L,bytes:L.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:g,onTransmuxerLog:y,triggerSegmentEventFn:v})};if(L.endOfAllRequests=Date.now(),L.map&&L.map.encryptedBytes&&!L.map.bytes)return v({type:"segmentdecryptionstart",segment:L}),PD({decryptionWorker:e,id:L.requestId+"-init",encryptedBytes:L.map.encryptedBytes,key:L.map.key,segment:L,doneFn:g},I=>{L.map.bytes=I,v({type:"segmentdecryptioncomplete",segment:L}),OD(L,j=>{if(j)return Bx(s),g(j,L);O()})});O()}}}},T8=({loadendState:s,abortFn:e})=>t=>{t.target.aborted&&e&&!s.calledAbortFn&&(e(),s.calledAbortFn=!0)},S8=({segment:s,progressFn:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f})=>g=>{if(!g.target.aborted)return s.stats=is(s.stats,f8(g)),!s.stats.firstBytesReceivedAt&&s.stats.bytesReceived&&(s.stats.firstBytesReceivedAt=Date.now()),e(g,s)},_8=({xhr:s,xhrOptions:e,decryptionWorker:t,segment:i,abortFn:n,progressFn:r,trackInfoFn:a,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:g,isEndOfTimeline:y,endedTimelineFn:v,dataFn:T,doneFn:S,onTransmuxerLog:w,triggerSegmentEventFn:L})=>{const O=[],I=b8({activeXhrs:O,decryptionWorker:t,trackInfoFn:a,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:g,isEndOfTimeline:y,endedTimelineFn:v,dataFn:T,doneFn:S,onTransmuxerLog:w,triggerSegmentEventFn:L});if(i.key&&!i.key.bytes){const K=[i.key];i.map&&!i.map.bytes&&i.map.key&&i.map.key.resolvedUri===i.key.resolvedUri&&K.push(i.map.key);const k=is(e,{uri:i.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),R=OE(i,K,I,L),Y={uri:i.key.resolvedUri};L({type:"segmentkeyloadstart",segment:i,keyInfo:Y});const z=s(k,R);O.push(z)}if(i.map&&!i.map.bytes){if(i.map.key&&(!i.key||i.key.resolvedUri!==i.map.key.resolvedUri)){const z=is(e,{uri:i.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),X=OE(i,[i.map.key],I,L),re={uri:i.map.key.resolvedUri};L({type:"segmentkeyloadstart",segment:i,keyInfo:re});const J=s(z,X);O.push(J)}const k=is(e,{uri:i.map.resolvedUri,responseType:"arraybuffer",headers:Mx(i.map),requestType:"segment-media-initialization"}),R=g8({segment:i,finishProcessingFn:I,triggerSegmentEventFn:L});L({type:"segmentloadstart",segment:i});const Y=s(k,R);O.push(Y)}const j=is(e,{uri:i.part&&i.part.resolvedUri||i.resolvedUri,responseType:"arraybuffer",headers:Mx(i),requestType:"segment"}),P=y8({segment:i,finishProcessingFn:I,responseType:j.responseType,triggerSegmentEventFn:L});L({type:"segmentloadstart",segment:i});const G=s(j,P);G.addEventListener("progress",S8({segment:i,progressFn:r,trackInfoFn:a,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:g,isEndOfTimeline:y,endedTimelineFn:v,dataFn:T})),O.push(G);const N={};return O.forEach(K=>{K.addEventListener("loadend",T8({loadendState:N,abortFn:n}))}),()=>Bx(O)},Lm=na("PlaylistSelector"),ME=function(s){if(!s||!s.playlist)return;const e=s.playlist;return JSON.stringify({id:e.id,bandwidth:s.bandwidth,width:s.width,height:s.height,codecs:e.attributes&&e.attributes.CODECS||""})},Ac=function(s,e){if(!s)return"";const t=ye.getComputedStyle(s);return t?t[e]:""},kc=function(s,e){const t=s.slice();s.sort(function(i,n){const r=e(i,n);return r===0?t.indexOf(i)-t.indexOf(n):r})},t1=function(s,e){let t,i;return s.attributes.BANDWIDTH&&(t=s.attributes.BANDWIDTH),t=t||ye.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||ye.Number.MAX_VALUE,t-i},E8=function(s,e){let t,i;return s.attributes.RESOLUTION&&s.attributes.RESOLUTION.width&&(t=s.attributes.RESOLUTION.width),t=t||ye.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||ye.Number.MAX_VALUE,t===i&&s.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?s.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-i};let BD=function(s){const{main:e,bandwidth:t,playerWidth:i,playerHeight:n,playerObjectFit:r,limitRenditionByPlayerDimensions:a,playlistController:u}=s;if(!e)return;const c={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:a};let d=e.playlists;xr.isAudioOnly(e)&&(d=u.getAudioTrackPlaylists_(),c.audioOnly=!0);let f=d.map(N=>{let K;const k=N.attributes&&N.attributes.RESOLUTION&&N.attributes.RESOLUTION.width,R=N.attributes&&N.attributes.RESOLUTION&&N.attributes.RESOLUTION.height;return K=N.attributes&&N.attributes.BANDWIDTH,K=K||ye.Number.MAX_VALUE,{bandwidth:K,width:k,height:R,playlist:N}});kc(f,(N,K)=>N.bandwidth-K.bandwidth),f=f.filter(N=>!xr.isIncompatible(N.playlist));let g=f.filter(N=>xr.isEnabled(N.playlist));g.length||(g=f.filter(N=>!xr.isDisabled(N.playlist)));const y=g.filter(N=>N.bandwidth*Dn.BANDWIDTH_VARIANCE<t);let v=y[y.length-1];const T=y.filter(N=>N.bandwidth===v.bandwidth)[0];if(a===!1){const N=T||g[0]||f[0];if(N&&N.playlist){let K="sortedPlaylistReps";return T&&(K="bandwidthBestRep"),g[0]&&(K="enabledPlaylistReps"),Lm(`choosing ${ME(N)} using ${K} with options`,c),N.playlist}return Lm("could not choose a playlist with options",c),null}const S=y.filter(N=>N.width&&N.height);kc(S,(N,K)=>N.width-K.width);const w=S.filter(N=>N.width===i&&N.height===n);v=w[w.length-1];const L=w.filter(N=>N.bandwidth===v.bandwidth)[0];let O,I,j;L||(O=S.filter(N=>r==="cover"?N.width>i&&N.height>n:N.width>i||N.height>n),I=O.filter(N=>N.width===O[0].width&&N.height===O[0].height),v=I[I.length-1],j=I.filter(N=>N.bandwidth===v.bandwidth)[0]);let P;if(u.leastPixelDiffSelector){const N=S.map(K=>(K.pixelDiff=Math.abs(K.width-i)+Math.abs(K.height-n),K));kc(N,(K,k)=>K.pixelDiff===k.pixelDiff?k.bandwidth-K.bandwidth:K.pixelDiff-k.pixelDiff),P=N[0]}const G=P||j||L||T||g[0]||f[0];if(G&&G.playlist){let N="sortedPlaylistReps";return P?N="leastPixelDiffRep":j?N="resolutionPlusOneRep":L?N="resolutionBestRep":T?N="bandwidthBestRep":g[0]&&(N="enabledPlaylistReps"),Lm(`choosing ${ME(G)} using ${N} with options`,c),G.playlist}return Lm("could not choose a playlist with options",c),null};const PE=function(){let s=this.useDevicePixelRatio&&ye.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(s=this.customPixelRatio),BD({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(Ac(this.tech_.el(),"width"),10)*s,playerHeight:parseInt(Ac(this.tech_.el(),"height"),10)*s,playerObjectFit:this.usePlayerObjectFit?Ac(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},w8=function(s){let e=-1,t=-1;if(s<0||s>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let i=this.useDevicePixelRatio&&ye.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=s*this.systemBandwidth+(1-s)*e,t=this.systemBandwidth),BD({main:this.playlists.main,bandwidth:e,playerWidth:parseInt(Ac(this.tech_.el(),"width"),10)*i,playerHeight:parseInt(Ac(this.tech_.el(),"height"),10)*i,playerObjectFit:this.usePlayerObjectFit?Ac(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},A8=function(s){const{main:e,currentTime:t,bandwidth:i,duration:n,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:u,syncController:c}=s,d=e.playlists.filter(T=>!xr.isIncompatible(T));let f=d.filter(xr.isEnabled);f.length||(f=d.filter(T=>!xr.isDisabled(T)));const y=f.filter(xr.hasAttribute.bind(null,"BANDWIDTH")).map(T=>{const w=c.getSyncPoint(T,n,u,t)?1:2,O=xr.estimateSegmentRequestTime(r,i,T)*w-a;return{playlist:T,rebufferingImpact:O}}),v=y.filter(T=>T.rebufferingImpact<=0);return kc(v,(T,S)=>t1(S.playlist,T.playlist)),v.length?v[0]:(kc(y,(T,S)=>T.rebufferingImpact-S.rebufferingImpact),y[0]||null)},k8=function(){const s=this.playlists.main.playlists.filter(xr.isEnabled);return kc(s,(t,i)=>t1(t,i)),s.filter(t=>!!Ch(this.playlists.main,t).video)[0]||null},C8=s=>{let e=0,t;return s.bytes&&(t=new Uint8Array(s.bytes),s.segments.forEach(i=>{t.set(i,e),e+=i.byteLength})),t};function FD(s){try{return new URL(s).pathname.split("/").slice(-2).join("/")}catch{return""}}const D8=function(s,e,t){if(!s[t]){e.trigger({type:"usage",name:"vhs-608"});let i=t;/^cc708_/.test(t)&&(i="SERVICE"+t.split("_")[1]);const n=e.textTracks().getTrackById(i);if(n)s[t]=n;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=t,u=t,c=!1;const d=r[i];d&&(a=d.label,u=d.language,c=d.default),s[t]=e.addRemoteTextTrack({kind:"captions",id:i,default:c,label:a,language:u},!1).track}}},L8=function({inbandTextTracks:s,captionArray:e,timestampOffset:t}){if(!e)return;const i=ye.WebKitDataCue||ye.VTTCue;e.forEach(n=>{const r=n.stream;n.content?n.content.forEach(a=>{const u=new i(n.startTime+t,n.endTime+t,a.text);u.line=a.line,u.align="left",u.position=a.position,u.positionAlign="line-left",s[r].addCue(u)}):s[r].addCue(new i(n.startTime+t,n.endTime+t,n.text))})},R8=function(s){Object.defineProperties(s.frame,{id:{get(){return He.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),s.value.key}},value:{get(){return He.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),s.value.data}},privateData:{get(){return He.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),s.value.data}}})},I8=({inbandTextTracks:s,metadataArray:e,timestampOffset:t,videoDuration:i})=>{if(!e)return;const n=ye.WebKitDataCue||ye.VTTCue,r=s.metadataTrack_;if(!r||(e.forEach(f=>{const g=f.cueTime+t;typeof g!="number"||ye.isNaN(g)||g<0||!(g<1/0)||!f.frames||!f.frames.length||f.frames.forEach(y=>{const v=new n(g,g,y.value||y.url||y.data||"");v.frame=y,v.value=y,R8(v),r.addCue(v)})}),!r.cues||!r.cues.length))return;const a=r.cues,u=[];for(let f=0;f<a.length;f++)a[f]&&u.push(a[f]);const c=u.reduce((f,g)=>{const y=f[g.startTime]||[];return y.push(g),f[g.startTime]=y,f},{}),d=Object.keys(c).sort((f,g)=>Number(f)-Number(g));d.forEach((f,g)=>{const y=c[f],v=isFinite(i)?i:f,T=Number(d[g+1])||v;y.forEach(S=>{S.endTime=T})})},N8={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},O8=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),M8=({inbandTextTracks:s,dateRanges:e})=>{const t=s.metadataTrack_;if(!t)return;const i=ye.WebKitDataCue||ye.VTTCue;e.forEach(n=>{for(const r of Object.keys(n)){if(O8.has(r))continue;const a=new i(n.startTime,n.endTime,"");a.id=n.id,a.type="com.apple.quicktime.HLS",a.value={key:N8[r],data:n[r]},(r==="scte35Out"||r==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(a)}n.processDateRange()})},BE=(s,e,t)=>{s.metadataTrack_||(s.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,He.browser.IS_ANY_SAFARI||(s.metadataTrack_.inBandMetadataTrackDispatchType=e))},mh=function(s,e,t){let i,n;if(t&&t.cues)for(i=t.cues.length;i--;)n=t.cues[i],n.startTime>=s&&n.endTime<=e&&t.removeCue(n)},P8=function(s){const e=s.cues;if(!e)return;const t={};for(let i=e.length-1;i>=0;i--){const n=e[i],r=`${n.startTime}-${n.endTime}-${n.text}`;t[r]?s.removeCue(n):t[r]=n}},B8=(s,e,t)=>{if(typeof e>"u"||e===null||!s.length)return[];const i=Math.ceil((e-t+3)*fu.ONE_SECOND_IN_TS);let n;for(n=0;n<s.length&&!(s[n].pts>i);n++);return s.slice(n)},F8=(s,e,t)=>{if(!e.length)return s;if(t)return e.slice();const i=e[0].pts;let n=0;for(n;n<s.length&&!(s[n].pts>=i);n++);return s.slice(0,n).concat(e)},U8=(s,e,t,i)=>{const n=Math.ceil((e-i)*fu.ONE_SECOND_IN_TS),r=Math.ceil((t-i)*fu.ONE_SECOND_IN_TS),a=s.slice();let u=s.length;for(;u--&&!(s[u].pts<=r););if(u===-1)return a;let c=u+1;for(;c--&&!(s[c].pts<=n););return c=Math.max(c,0),a.splice(c,u-c+1),a},j8=function(s,e){if(!s&&!e||!s&&e||s&&!e)return!1;if(s===e)return!0;const t=Object.keys(s).sort(),i=Object.keys(e).sort();if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++){const r=t[n];if(r!==i[n]||s[r]!==e[r])return!1}return!0},$8=function(s,e,t){e=e||[];const i=[];let n=0;for(let r=0;r<e.length;r++){const a=e[r];if(s===a.timeline&&(i.push(r),n+=a.duration,n>t))return r}return i.length===0?0:i[i.length-1]},sh=1,H8=500,FE=s=>typeof s=="number"&&isFinite(s),Rm=1/60,z8=(s,e,t)=>s!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,V8=(s,e,t)=>{let i=e-Dn.BACK_BUFFER_LENGTH;s.length&&(i=Math.max(i,s.start(0)));const n=e-t;return Math.min(n,i)},nc=s=>{const{startOfSegment:e,duration:t,segment:i,part:n,playlist:{mediaSequence:r,id:a,segments:u=[]},mediaIndex:c,partIndex:d,timeline:f}=s,g=u.length-1;let y="mediaIndex/partIndex increment";s.getMediaInfoForTime?y=`getMediaInfoForTime (${s.getMediaInfoForTime})`:s.isSyncRequest&&(y="getSyncSegmentCandidate (isSyncRequest)"),s.independent&&(y+=` with independent ${s.independent}`);const v=typeof d=="number",T=s.segment.uri?"segment":"pre-segment",S=v?iD({preloadSegment:i})-1:0;return`${T} [${r+c}/${r+g}]`+(v?` part [${d}/${S}]`:"")+` segment start/end [${i.start} => ${i.end}]`+(v?` part start/end [${n.start} => ${n.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${f}] selected by [${y}] playlist [${a}]`},UE=s=>`${s}TimingInfo`,G8=({segmentTimeline:s,currentTimeline:e,startOfSegment:t,buffered:i,overrideCheck:n})=>!n&&s===e?null:s<e?t:i.length?i.end(i.length-1):t,Fx=({timelineChangeController:s,currentTimeline:e,segmentTimeline:t,loaderType:i,audioDisabled:n})=>{if(e===t)return!1;if(i==="audio"){const r=s.lastTimelineChange({type:"main"});return!r||r.to!==t}if(i==="main"&&n){const r=s.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},q8=s=>{if(!s)return!1;const e=s.pendingTimelineChange({type:"audio"}),t=s.pendingTimelineChange({type:"main"}),i=e&&t,n=i&&e.to!==t.to;return!!(i&&e.from!==-1&&t.from!==-1&&n)},K8=s=>{const e=s.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=s.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},ml=s=>{const e=s.pendingSegment_;if(!e)return;if(Fx({timelineChangeController:s.timelineChangeController_,currentTimeline:s.currentTimeline_,segmentTimeline:e.timeline,loaderType:s.loaderType_,audioDisabled:s.audioDisabled_})&&q8(s.timelineChangeController_)){if(K8(s)){s.timelineChangeController_.trigger("audioTimelineBehind");return}s.timelineChangeController_.trigger("fixBadTimelineChange")}},W8=s=>{let e=0;return["video","audio"].forEach(function(t){const i=s[`${t}TimingInfo`];if(!i)return;const{start:n,end:r}=i;let a;typeof n=="bigint"||typeof r=="bigint"?a=ye.BigInt(r)-ye.BigInt(n):typeof n=="number"&&typeof r=="number"&&(a=r-n),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},jE=({segmentDuration:s,maxDuration:e})=>s?Math.round(s)>e+Ha:!1,Y8=(s,e)=>{if(e!=="hls")return null;const t=W8({audioTimingInfo:s.audioTimingInfo,videoTimingInfo:s.videoTimingInfo});if(!t)return null;const i=s.playlist.targetDuration,n=jE({segmentDuration:t,maxDuration:i*2}),r=jE({segmentDuration:t,maxDuration:i}),a=`Segment with index ${s.mediaIndex} from playlist ${s.playlist.id} has a duration of ${t} when the reported duration is ${s.duration} and the target duration is ${i}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return n||r?{severity:n?"warn":"info",message:a}:null},du=({type:s,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),i=!!(e.map&&!e.map.bytes),n=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:s||e.type,uri:e.resolvedUri||e.uri,start:n,duration:e.duration,isEncrypted:t,isMediaInitialization:i}};class Ux extends He.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=na(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(i){i!==this.state_&&(this.logger_(`${this.state_} -> ${i}`),this.state_=i,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():ml(this)}),this.sourceUpdater_.on("codecschange",i=>{this.trigger(on({type:"codecschange"},i))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():ml(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",i=>{this.trigger(on({type:"timelinechange"},i)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():ml(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():ml(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Sv.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&ye.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,ye.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Sv.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return Rn();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:i,isMuxed:n}=e;if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const i=F0(e);let n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),n||e}segmentKey(e,t=!1){if(!e)return null;const i=TD(e);let n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
currentTime: ${this.currentTime_()}
bufferedEnd: ${bv(this.buffered_())}
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const a=e.mediaSequence-i.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null)if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const u=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!u.parts||!u.parts.length||!u.parts[this.partIndex])){const c=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=c}}n&&(n.mediaIndex-=a,n.mediaIndex<0?(n.mediaIndex=null,n.partIndex=null):(n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex]),n.partIndex>=0&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex]))),this.syncController_.saveExpiredSegmentInfo(i,e)}pause(){this.checkBufferTimeout_&&(ye.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&Sv.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;const e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;this.sourceType_==="hls"&&!e&&(this.shouldForceTimestampOffsetAfterResync_=!0),this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,i=()=>{},n=!1){if(t===1/0&&(t=this.duration_()),t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let r=1;const a=()=>{r--,r===0&&i()};(n||!this.audioDisabled_)&&(r++,this.sourceUpdater_.removeAudio(e,t,a)),(n||this.loaderType_==="main")&&(this.gopBuffer_=U8(this.gopBuffer_,e,t,this.timeMapping_),r++,this.sourceUpdater_.removeVideo(e,t,a));for(const u in this.inbandTextTracks_)mh(e,t,this.inbandTextTracks_[u]);mh(e,t,this.segmentMetadataTrack_),a()}monitorBuffer_(){this.checkBufferTimeout_&&ye.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ye.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&ye.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ye.setTimeout(this.monitorBufferTick_.bind(this),H8)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();if(!e)return;const t={segmentInfo:du({type:this.loaderType_,segment:e})};this.trigger({type:"segmentselected",metadata:t}),typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,i=this.partIndex){if(!t||!this.mediaSource_)return!1;const n=typeof e=="number"&&t.segments[e],r=e+1===t.segments.length,a=!n||!n.parts||i+1===n.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&r&&a}chooseNextRequest_(){const e=this.buffered_(),t=bv(e)||0,i=Xb(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),a=this.playlist_.segments;if(!a.length||n||r)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);const u={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(u.isSyncRequest)u.mediaIndex=$8(this.currentTimeline_,a,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${u.mediaIndex}`);else if(this.mediaIndex!==null){const y=a[this.mediaIndex],v=typeof this.partIndex=="number"?this.partIndex:-1;u.startOfSegment=y.end?y.end:t,y.parts&&y.parts[v+1]?(u.mediaIndex=this.mediaIndex,u.partIndex=v+1):u.mediaIndex=this.mediaIndex+1}else{let y,v,T;const S=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
For TargetTime: ${S}.
CurrentTime: ${this.currentTime_()}
BufferedEnd: ${t}
Fetch At Buffer: ${this.fetchAtBuffer_}
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const w=this.getSyncInfoFromMediaSequenceSync_(S);if(!w){const L="No sync info found while using media sequence sync";return this.error({message:L,metadata:{errorType:He.Error.StreamingFailedToSelectNextSegment,error:new Error(L)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${w.start} --> ${w.end})`),y=w.segmentIndex,v=w.partIndex,T=w.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const w=xr.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:S,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});y=w.segmentIndex,v=w.partIndex,T=w.startTime}u.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${S}`:`currentTime ${S}`,u.mediaIndex=y,u.startOfSegment=T,u.partIndex=v,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${u.mediaIndex} `)}const c=a[u.mediaIndex];let d=c&&typeof u.partIndex=="number"&&c.parts&&c.parts[u.partIndex];if(!c||typeof u.partIndex=="number"&&!d)return null;typeof u.partIndex!="number"&&c.parts&&(u.partIndex=0,d=c.parts[0]);const f=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!i&&d&&!f&&!d.independent)if(u.partIndex===0){const y=a[u.mediaIndex-1],v=y.parts&&y.parts.length&&y.parts[y.parts.length-1];v&&v.independent&&(u.mediaIndex-=1,u.partIndex=y.parts.length-1,u.independent="previous segment")}else c.parts[u.partIndex-1].independent&&(u.partIndex-=1,u.independent="previous part");const g=this.mediaSource_&&this.mediaSource_.readyState==="ended";return u.mediaIndex>=a.length-1&&g&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,u.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(u))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const i=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!i)return null;if(!i.isAppended)return i;const n=this.mediaSequenceSync_.getSyncInfoForTime(i.end);return n?(n.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),n):null}generateSegmentInfo_(e){const{independent:t,playlist:i,mediaIndex:n,startOfSegment:r,isSyncRequest:a,partIndex:u,forceTimestampOffset:c,getMediaInfoForTime:d}=e,f=i.segments[n],g=typeof u=="number"&&f.parts[u],y={requestId:"segment-loader-"+Math.random(),uri:g&&g.resolvedUri||f.resolvedUri,mediaIndex:n,partIndex:g?u:null,isSyncRequest:a,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:f.timeline,duration:g&&g.duration||f.duration,segment:f,part:g,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:d,independent:t},v=typeof c<"u"?c:this.isPendingTimestampOffset_;y.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:f.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:v});const T=bv(this.sourceUpdater_.audioBuffered());return typeof T=="number"&&(y.audioAppendStart=T-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(y.gopsToAlignWith=B8(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),y}timestampOffsetForSegment_(e){return G8(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=xr.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),a=fF(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=a)return;const u=A8({main:this.vhs_.playlists.main,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!u)return;const d=r-a-u.rebufferingImpact;let f=.5;a<=Ha&&(f=1),!(!u.playlist||u.playlist.uri===this.playlist_.uri||d<f)&&(this.bandwidth=u.playlist.attributes.BANDWIDTH*Dn.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${nc(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:i,hasVideo:n}=t,r={segmentInfo:du({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:i,hasVideo:n}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},j8(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():ml(this))))}handleTimingInfo_(e,t,i,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,a=UE(t);r[a]=r[a]||{},r[a][i]=n,this.logger_(`timinginfo: ${t} - ${i} - ${n}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():ml(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={};t.forEach(a=>{r[a.stream]=r[a.stream]||{startTime:1/0,captions:[],endTime:0};const u=r[a.stream];u.startTime=Math.min(u.startTime,a.startTime+n),u.endTime=Math.max(u.endTime,a.endTime+n),u.captions.push(a)}),Object.keys(r).forEach(a=>{const{startTime:u,endTime:c,captions:d}=r[a],f=this.inbandTextTracks_;this.logger_(`adding cues from ${u} -> ${c} for ${a}`),D8(f,this.vhs_.tech_,a),mh(u,c,f[a]),L8({captionArray:d,inbandTextTracks:f,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i));return}this.addMetadataToTextTrack(i,t,this.duration_())}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!Fx({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:i,hasVideo:n,isMuxed:r}=t;return!(n&&!e.videoTimingInfo||i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||Fx({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){ml(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.part||i.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),i.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),i.isFmp4=e.isFmp4,i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[UE(t.type)].start;else{const n=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&n&&n.hasVideo;let a;r&&(a=i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:a,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(i,t.type),this.updateSourceBufferTimestampOffset_(i),i.isSyncRequest){this.updateTimingInfoEnd_(i),this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:this.loaderType_==="main"});const n=this.chooseNextRequest_();if(n.mediaIndex!==i.mediaIndex||n.partIndex!==i.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:i,playlist:n}){if(i){const r=F0(i);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(i,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=n,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i},n){const r=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+mu(r).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+mu(a).join(", "));const u=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,d=a.length?a.start(0):0,f=a.length?a.end(a.length-1):0;if(c-u<=sh&&f-d<=sh){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${i.byteLength}, audio buffer: ${mu(r).join(", ")}, video buffer: ${mu(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:i}));const y=this.currentTime_()-sh;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${y}`),this.remove(0,y,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${sh}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=ye.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},sh*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:i},n){if(n){if(n.code===fD){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",n),this.error({message:`${t} append of ${i.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:He.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:i,data:n,bytes:r}){if(!r){const u=[n];let c=n.byteLength;i&&(u.unshift(i),c+=i.byteLength),r=C8({bytes:c,segments:u})}const a={segmentInfo:du({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,i){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const n=this.pendingSegment_.segment,r=`${e}TimingInfo`;n[r]||(n[r]={}),n[r].transmuxerPrependedSeconds=i.prependedContentDuration||0,n[r].transmuxedPresentationStart=i.start.presentation,n[r].transmuxedDecodeStart=i.start.decode,n[r].transmuxedPresentationEnd=i.end.presentation,n[r].transmuxedDecodeEnd=i.end.decode,n[r].baseMediaDecodeTime=i.baseMediaDecodeTime}appendData_(e,t){const{type:i,data:n}=t;if(!n||!n.byteLength||i==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){ml(this),this.loadQueue_.push(()=>{const t=on({},e,{forceTimestampOffset:!0});on(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),i=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),n=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,a=i||n&&r;this.logger_(`Requesting
${FD(e.uri)}
${nc(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=_8({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:u,level:c,stream:d})=>{this.logger_(`${nc(e)} logged from transmuxer stream ${d} as a ${c}: ${u}`)},triggerSegmentEventFn:({type:u,segment:c,keyInfo:d,trackInfo:f,timingInfo:g})=>{const v={segmentInfo:du({segment:c})};d&&(v.keyInfo=d),f&&(v.trackInfo=f),g&&(v.timingInfo=g),this.trigger({type:u,metadata:v})}})}trimBackBuffer_(e){const t=V8(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,i=e.part,n=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:n,isMediaInitialization:r},u=e.playlist.segments[e.mediaIndex-1];if(u&&u.timeline===t.timeline&&(u.videoTimingInfo?a.baseStartTime=u.videoTimingInfo.transmuxedDecodeEnd:u.audioTimingInfo&&(a.baseStartTime=u.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=c}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<Rm){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${Rm}`);return}const i={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:i}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,i){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===Va.ABORTED)return;if(this.pause(),e.code===Va.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const n=this.pendingSegment_;this.saveBandwidthRelatedStats_(n.duration,t.stats),n.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=F8(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(n)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:i,firstVideoFrameTimeForData:n,currentVideoTimestampOffset:r,useVideoTimingInfo:a,videoTimingInfo:u,audioTimingInfo:c}){if(typeof e<"u")return e;if(!a)return c.start;const d=t.segments[i-1];return i===0||!d||typeof d.start>"u"||d.end!==n+r?n:u.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:i,hasVideo:n,isMuxed:r}=t,a=this.loaderType_==="main"&&n,u=!this.audioDisabled_&&i&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,u&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),u&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=z8(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:i}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:i.start:i.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const c={segmentInfo:du({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:c})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=Y8(e,this.sourceType_);if(t&&(t.severity==="warn"?He.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${nc(e)}`);return}this.logger_(`Appended ${nc(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const i=e.segment,n=e.part,r=i.end&&this.currentTime_()-i.end>e.playlist.targetDuration*3,a=n&&n.end&&this.currentTime_()-n.end>e.playlist.partTargetDuration*3;if(r||a){this.logger_(`bad ${r?"segment":"part"} ${nc(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<Rm){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${Rm}`);return}const t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,i=t.start,n=t.end;if(!FE(i)||!FE(n))return;mh(i,n,this.segmentMetadataTrack_);const r=ye.WebKitDataCue||ye.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},u=JSON.stringify(a),c=new r(i,n,u);c.value=a,this.segmentMetadataTrack_.addCue(c)}}function ko(){}const UD=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},X8=["video","audio"],jx=(s,e)=>{const t=e[`${s}Buffer`];return t&&t.updating||e.queuePending[s]},Q8=(s,e)=>{for(let t=0;t<e.length;t++){const i=e[t];if(i.type==="mediaSource")return null;if(i.type===s)return t}return null},Cc=(s,e)=>{if(e.queue.length===0)return;let t=0,i=e.queue[t];if(i.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),i.action(e),i.doneFn&&i.doneFn(),Cc("audio",e),Cc("video",e));return}if(s!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||jx(s,e))){if(i.type!==s){if(t=Q8(s,e.queue),t===null)return;i=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[s]=i,i.action(s,e),!i.doneFn){e.queuePending[s]=null,Cc(s,e);return}}},jD=(s,e)=>{const t=e[`${s}Buffer`],i=UD(s);t&&(t.removeEventListener("updateend",e[`on${i}UpdateEnd_`]),t.removeEventListener("error",e[`on${i}Error_`]),e.codecs[s]=null,e[`${s}Buffer`]=null)},Ua=(s,e)=>s&&e&&Array.prototype.indexOf.call(s.sourceBuffers,e)!==-1,Or={appendBuffer:(s,e,t)=>(i,n)=>{const r=n[`${i}Buffer`];if(Ua(n.mediaSource,r)){n.logger_(`Appending segment ${e.mediaIndex}'s ${s.length} bytes to ${i}Buffer`);try{r.appendBuffer(s)}catch(a){n.logger_(`Error with code ${a.code} `+(a.code===fD?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${i}Buffer`),n.queuePending[i]=null,t(a)}}},remove:(s,e)=>(t,i)=>{const n=i[`${t}Buffer`];if(Ua(i.mediaSource,n)){i.logger_(`Removing ${s} to ${e} from ${t}Buffer`);try{n.remove(s,e)}catch{i.logger_(`Remove ${s} to ${e} from ${t}Buffer failed`)}}},timestampOffset:s=>(e,t)=>{const i=t[`${e}Buffer`];Ua(t.mediaSource,i)&&(t.logger_(`Setting ${e}timestampOffset to ${s}`),i.timestampOffset=s)},callback:s=>(e,t)=>{s()},endOfStream:s=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${s||""})`);try{e.mediaSource.endOfStream(s)}catch(t){He.log.warn("Failed to call media source endOfStream",t)}}},duration:s=>e=>{e.logger_(`Setting mediaSource duration to ${s}`);try{e.mediaSource.duration=s}catch(t){He.log.warn("Failed to set media source duration",t)}},abort:()=>(s,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${s}Buffer`];if(Ua(e.mediaSource,t)){e.logger_(`calling abort on ${s}Buffer`);try{t.abort()}catch(i){He.log.warn(`Failed to abort on ${s}Buffer`,i)}}},addSourceBuffer:(s,e)=>t=>{const i=UD(s),n=Pc(e);t.logger_(`Adding ${s}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(n);r.addEventListener("updateend",t[`on${i}UpdateEnd_`]),r.addEventListener("error",t[`on${i}Error_`]),t.codecs[s]=e,t[`${s}Buffer`]=r},removeSourceBuffer:s=>e=>{const t=e[`${s}Buffer`];if(jD(s,e),!!Ua(e.mediaSource,t)){e.logger_(`Removing ${s}Buffer with codec ${e.codecs[s]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(i){He.log.warn(`Failed to removeSourceBuffer ${s}Buffer`,i)}}},changeType:s=>(e,t)=>{const i=t[`${e}Buffer`],n=Pc(s);if(!Ua(t.mediaSource,i))return;const r=s.substring(0,s.indexOf(".")),a=t.codecs[e];if(a.substring(0,a.indexOf("."))===r)return;const c={codecsChangeInfo:{from:a,to:s}};t.trigger({type:"codecschange",metadata:c}),t.logger_(`changing ${e}Buffer codec from ${a} to ${s}`);try{i.changeType(n),t.codecs[e]=s}catch(d){c.errorType=He.Error.StreamingCodecsChangeError,c.error=d,d.metadata=c,t.error_=d,t.trigger("error"),He.log.warn(`Failed to changeType on ${e}Buffer`,d)}}},Mr=({type:s,sourceUpdater:e,action:t,doneFn:i,name:n})=>{e.queue.push({type:s,action:t,doneFn:i,name:n}),Cc(s,e)},$E=(s,e)=>t=>{const i=e[`${s}Buffered`](),n=cF(i);if(e.logger_(`received "updateend" event for ${s} Source Buffer: `,n),e.queuePending[s]){const r=e.queuePending[s].doneFn;e.queuePending[s]=null,r&&r(e[`${s}Error_`])}Cc(s,e)};class $D extends He.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>Cc("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=na("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=$E("video",this),this.onAudioUpdateEnd_=$E("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){Mr({type:"mediaSource",sourceUpdater:this,action:Or.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){Mr({type:e,sourceUpdater:this,action:Or.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){He.log.error("removeSourceBuffer is not supported!");return}Mr({type:"mediaSource",sourceUpdater:this,action:Or.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!He.browser.IS_FIREFOX&&ye.MediaSource&&ye.MediaSource.prototype&&typeof ye.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return ye.SourceBuffer&&ye.SourceBuffer.prototype&&typeof ye.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){He.log.error("changeType is not supported!");return}Mr({type:e,sourceUpdater:this,action:Or.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const i=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,i);this.canChangeType()&&this.changeType(t,i)})}appendBuffer(e,t){const{segmentInfo:i,type:n,bytes:r}=e;if(this.processedAppend_=!0,n==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const a=t;if(Mr({type:n,sourceUpdater:this,action:Or.appendBuffer(r,i||{mediaIndex:-1},a),doneFn:t,name:"appendBuffer"}),n==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const u=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${u.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,u.forEach(c=>{this.appendBuffer.apply(this,c)})}}audioBuffered(){return Ua(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:Rn()}videoBuffered(){return Ua(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:Rn()}buffered(){const e=Ua(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=Ua(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():hF(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ko){Mr({type:"mediaSource",sourceUpdater:this,action:Or.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ko){typeof e!="string"&&(e=void 0),Mr({type:"mediaSource",sourceUpdater:this,action:Or.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=ko){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){i();return}Mr({type:"audio",sourceUpdater:this,action:Or.remove(e,t),doneFn:i,name:"remove"})}removeVideo(e,t,i=ko){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){i();return}Mr({type:"video",sourceUpdater:this,action:Or.remove(e,t),doneFn:i,name:"remove"})}updating(){return!!(jx("audio",this)||jx("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(Mr({type:"audio",sourceUpdater:this,action:Or.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(Mr({type:"video",sourceUpdater:this,action:Or.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&Mr({type:"audio",sourceUpdater:this,action:Or.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&Mr({type:"video",sourceUpdater:this,action:Or.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),X8.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>jD(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const HE=s=>decodeURIComponent(escape(String.fromCharCode.apply(null,s))),Z8=s=>{const e=new Uint8Array(s);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},zE=new Uint8Array(`
`.split("").map(s=>s.charCodeAt(0)));class J8 extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class e6 extends Ux{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return Rn();const e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return Rn([[t,i]])}initSegmentForMap(e,t=!1){if(!e)return null;const i=F0(e);let n=this.initSegments_[i];if(t&&!n&&e.bytes){const r=zE.byteLength+e.bytes.byteLength,a=new Uint8Array(r);a.set(e.bytes),a.set(zE,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return n||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,t){mh(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const t=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,i){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===Va.TIMEOUT&&this.handleTimeout_(),e.code===Va.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const n=this.pendingSegment_,r=i.mp4VttCues&&i.mp4VttCues.length;r&&(n.mp4VttCues=i.mp4VttCues),this.saveBandwidthRelatedStats_(n.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const a=n.segment;if(a.map&&(a.map.bytes=t.map.bytes),n.bytes=t.bytes,typeof ye.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,i),()=>this.stopForError({message:"Error loading vtt.js"}));return}a.requested=!0;try{this.parseVTTCues_(n)}catch(u){this.stopForError({message:u.message,metadata:{errorType:He.Error.StreamingVttParserError,error:u}});return}if(r||this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.cues.length?n.timingInfo={start:n.cues[0].startTime,end:n.cues[n.cues.length-1].endTime}:n.timingInfo={start:n.startOfSegment,end:n.startOfSegment+n.duration},n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.forEach(u=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new ye.VTTCue(u.startTime,u.endTime,u.text):u)}),P8(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const i=e&&e.type==="vtt",n=t&&t.type==="text";i&&n&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(i=>{const n=i.start+t,r=i.end+t,a=new ye.VTTCue(n,r,i.cueText);i.settings&&i.settings.split(" ").forEach(u=>{const c=u.split(":"),d=c[0],f=c[1];a[d]=isNaN(f)?f:Number(f)}),e.cues.push(a)})}parseVTTCues_(e){let t,i=!1;if(typeof ye.WebVTT!="function")throw new J8;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof ye.TextDecoder=="function"?t=new ye.TextDecoder("utf8"):(t=ye.WebVTT.StringDecoder(),i=!0);const n=new ye.WebVTT.Parser(ye,ye.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=a=>{e.timestampmap=a},n.onparsingerror=a=>{He.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;i&&(a=HE(a)),n.parse(a)}let r=e.bytes;i&&(r=HE(r)),n.parse(r),n.flush()}updateTimeMapping_(e,t,i){const n=e.segment;if(!t)return;if(!e.cues.length){n.empty=!0;return}const{MPEGTS:r,LOCAL:a}=e.timestampmap,c=r/fu.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(d=>{const f=d.endTime-d.startTime,g=this.handleRollover_(d.startTime+c,t.time);d.startTime=Math.max(g,0),d.endTime=Math.max(g+f,0)}),!i.syncInfo){const d=e.cues[0].startTime,f=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(d,f-n.duration)}}}handleRollover_(e,t){if(t===null)return e;let i=e*fu.ONE_SECOND_IN_TS;const n=t*fu.ONE_SECOND_IN_TS;let r;for(n<i?r=-8589934592:r=8589934592;Math.abs(i-n)>4294967296;)i+=r;return i/fu.ONE_SECOND_IN_TS}}const t6=function(s,e){const t=s.cues;for(let i=0;i<t.length;i++){const n=t[i];if(e>=n.adStartTime&&e<=n.adEndTime)return n}return null},i6=function(s,e,t=0){if(!s.segments)return;let i=t,n;for(let r=0;r<s.segments.length;r++){const a=s.segments[r];if(n||(n=t6(e,i+a.duration/2)),n){if("cueIn"in a){n.endTime=i,n.adEndTime=i,i+=a.duration,n=null;continue}if(i<n.endTime){i+=a.duration;continue}n.endTime+=a.duration}else if("cueOut"in a&&(n=new ye.VTTCue(i,i+a.duration,a.cueOut),n.adStartTime=i,n.adEndTime=i+parseFloat(a.cueOut),e.addCue(n)),"cueOutCont"in a){const[u,c]=a.cueOutCont.split("/").map(parseFloat);n=new ye.VTTCue(i,i+a.duration,""),n.adStartTime=i-u,n.adEndTime=n.adStartTime+c,e.addCue(n)}i+=a.duration}};class VE{constructor({start:e,end:t,segmentIndex:i,partIndex:n=null,appended:r=!1}){this.start_=e,this.end_=t,this.segmentIndex_=i,this.partIndex_=n,this.appended_=r}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class s6{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class HD{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){const{mediaSequence:i,segments:n}=e;if(this.isReliable_=this.isReliablePlaylist_(i,n),!!this.isReliable_)return this.updateStorage_(n,i,this.calculateBaseTime_(i,n,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:i}of this.storage_.values())if(i.length){for(const n of i)if(n.isInRange(e))return n}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,i){const n=new Map;let r=`
`,a=i,u=t;this.start_=a,e.forEach((c,d)=>{const f=this.storage_.get(u),g=a,y=g+c.duration,v=!!(f&&f.segmentSyncInfo&&f.segmentSyncInfo.isAppended),T=new VE({start:g,end:y,appended:v,segmentIndex:d});c.syncInfo=T;let S=a;const w=(c.parts||[]).map((L,O)=>{const I=S,j=S+L.duration,P=!!(f&&f.partsSyncInfo&&f.partsSyncInfo[O]&&f.partsSyncInfo[O].isAppended),G=new VE({start:I,end:j,appended:P,segmentIndex:d,partIndex:O});return S=j,r+=`Media Sequence: ${u}.${O} | Range: ${I} --> ${j} | Appended: ${P}
`,L.syncInfo=G,G});n.set(u,new s6(T,w)),r+=`${FD(c.resolvedUri)} | Media Sequence: ${u} | Range: ${g} --> ${y} | Appended: ${v}
`,u++,a=y}),this.end_=a,this.storage_=n,this.diagnostics_=r}calculateBaseTime_(e,t,i){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const n=Math.min(...this.storage_.keys());if(e<n){const r=n-e;let a=this.storage_.get(n).segmentSyncInfo.start;for(let u=0;u<r;u++){const c=t[u];a-=c.duration}return a}return i}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class GE extends HD{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,i){if(!this.storage_.size){const n=this.parent_.getSyncInfoForMediaSequence(e);return n?n.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,i)}}const n6=86400,_v=[{name:"VOD",run:(s,e,t,i,n)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(s,e,t,i,n,r)=>{const a=s.getMediaSequenceSync(r);if(!a||!a.isReliable)return null;const u=a.getSyncInfoForTime(n);return u?{time:u.start,partIndex:u.partIndex,segmentIndex:u.segmentIndex}:null}},{name:"ProgramDateTime",run:(s,e,t,i,n)=>{if(!Object.keys(s.timelineToDatetimeMappings).length)return null;let r=null,a=null;const u=Lx(e);n=n||0;for(let c=0;c<u.length;c++){const d=e.endList||n===0?c:u.length-(c+1),f=u[d],g=f.segment,y=s.timelineToDatetimeMappings[g.timeline];if(!y||!g.dateTimeObject)continue;let T=g.dateTimeObject.getTime()/1e3+y;if(g.parts&&typeof f.partIndex=="number")for(let w=0;w<f.partIndex;w++)T+=g.parts[w].duration;const S=Math.abs(n-T);if(a!==null&&(S===0||a<S))break;a=S,r={time:T,segmentIndex:f.segmentIndex,partIndex:f.partIndex}}return r}},{name:"Segment",run:(s,e,t,i,n)=>{let r=null,a=null;n=n||0;const u=Lx(e);for(let c=0;c<u.length;c++){const d=e.endList||n===0?c:u.length-(c+1),f=u[d],g=f.segment,y=f.part&&f.part.start||g&&g.start;if(g.timeline===i&&typeof y<"u"){const v=Math.abs(n-y);if(a!==null&&a<v)break;(!r||a===null||a>=v)&&(a=v,r={time:y,segmentIndex:f.segmentIndex,partIndex:f.partIndex})}}return r}},{name:"Discontinuity",run:(s,e,t,i,n)=>{let r=null;if(n=n||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let u=0;u<e.discontinuityStarts.length;u++){const c=e.discontinuityStarts[u],d=e.discontinuitySequence+u+1,f=s.discontinuities[d];if(f){const g=Math.abs(n-f.time);if(a!==null&&a<g)break;(!r||a===null||a>=g)&&(a=g,r={time:f.time,segmentIndex:c,partIndex:null})}}}return r}},{name:"Playlist",run:(s,e,t,i,n)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class r6 extends He.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new HD,i=new GE(t),n=new GE(t);this.mediaSequenceStorage_={main:t,audio:i,vtt:n},this.logger_=na("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,i,n,r){if(t!==1/0)return _v.find(({name:c})=>c==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,i,n,r);if(!a.length)return null;for(const u of a){const{syncPoint:c,strategy:d}=u,{segmentIndex:f,time:g}=c;if(f<0)continue;const y=e.segments[f],v=g,T=v+y.duration;if(this.logger_(`Strategy: ${d}. Current time: ${n}. selected segment: ${f}. Time: [${v} -> ${T}]}`),n>=v&&n<T)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;const i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;const n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+kh({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,i,n,r){const a=[];for(let u=0;u<_v.length;u++){const c=_v[u],d=c.run(this,e,t,i,n,r);d&&(d.strategy=c.name,a.push({strategy:c.name,syncPoint:d}))}return a}selectSyncPoint_(e,t){let i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let a=1;a<e.length;a++){const u=Math.abs(e[a].syncPoint[t.key]-t.value);u<n&&(n=u,i=e[a].syncPoint,r=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${i.time}, segmentIndex:${i.segmentIndex}`+(typeof i.partIndex=="number"?`,partIndex:${i.partIndex}`:"")+"]"),i}saveExpiredSegmentInfo(e,t){const i=t.mediaSequence-e.mediaSequence;if(i>n6){He.log.warn(`Not saving expired segment info. Media sequence gap ${i} is too large.`);return}for(let n=i-1;n>=0;n--){const r=e.segments[n];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],i=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-i}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const i=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;i&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}));const r=n.dateTimeObject;n.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[n.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,i){const n=e.segment,r=e.part;let a=this.timelines[e.timeline],u,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),u=e.startOfSegment,c=t.end+a.mapping;else if(a)u=t.start+a.mapping,c=t.end+a.mapping;else return!1;return r&&(r.start=u,r.end=c),(!n.start||u<n.start)&&(n.start=u),n.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){const r=t.discontinuityStarts[n],a=t.discontinuitySequence+n+1,u=r-e.mediaIndex,c=Math.abs(u);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let d;u<0?d=i.start-kh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):d=i.end+kh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[a]={time:d,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class a6 extends He.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:i}){return typeof t=="number"&&typeof i=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:i},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:i}){if(typeof t=="number"&&typeof i=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:i},delete this.pendingTimelineChanges_[e];const n={timelineChangeInfo:{from:t,to:i}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const o6=kD(CD(function(){var s=(function(){function S(){this.listeners={}}var w=S.prototype;return w.on=function(O,I){this.listeners[O]||(this.listeners[O]=[]),this.listeners[O].push(I)},w.off=function(O,I){if(!this.listeners[O])return!1;var j=this.listeners[O].indexOf(I);return this.listeners[O]=this.listeners[O].slice(0),this.listeners[O].splice(j,1),j>-1},w.trigger=function(O){var I=this.listeners[O];if(I)if(arguments.length===2)for(var j=I.length,P=0;P<j;++P)I[P].call(this,arguments[1]);else for(var G=Array.prototype.slice.call(arguments,1),N=I.length,K=0;K<N;++K)I[K].apply(this,G)},w.dispose=function(){this.listeners={}},w.pipe=function(O){this.on("data",function(I){O.push(I)})},S})();function e(S){return S.subarray(0,S.byteLength-S[S.byteLength-1])}const t=function(){const S=[[[],[],[],[],[]],[[],[],[],[],[]]],w=S[0],L=S[1],O=w[4],I=L[4];let j,P,G;const N=[],K=[];let k,R,Y,z,X,re;for(j=0;j<256;j++)K[(N[j]=j<<1^(j>>7)*283)^j]=j;for(P=G=0;!O[P];P^=k||1,G=K[G]||1)for(z=G^G<<1^G<<2^G<<3^G<<4,z=z>>8^z&255^99,O[P]=z,I[z]=P,Y=N[R=N[k=N[P]]],re=Y*16843009^R*65537^k*257^P*16843008,X=N[z]*257^z*16843008,j=0;j<4;j++)w[j][P]=X=X<<24^X>>>8,L[j][z]=re=re<<24^re>>>8;for(j=0;j<5;j++)w[j]=w[j].slice(0),L[j]=L[j].slice(0);return S};let i=null;class n{constructor(w){i||(i=t()),this._tables=[[i[0][0].slice(),i[0][1].slice(),i[0][2].slice(),i[0][3].slice(),i[0][4].slice()],[i[1][0].slice(),i[1][1].slice(),i[1][2].slice(),i[1][3].slice(),i[1][4].slice()]];let L,O,I;const j=this._tables[0][4],P=this._tables[1],G=w.length;let N=1;if(G!==4&&G!==6&&G!==8)throw new Error("Invalid aes key size");const K=w.slice(0),k=[];for(this._key=[K,k],L=G;L<4*G+28;L++)I=K[L-1],(L%G===0||G===8&&L%G===4)&&(I=j[I>>>24]<<24^j[I>>16&255]<<16^j[I>>8&255]<<8^j[I&255],L%G===0&&(I=I<<8^I>>>24^N<<24,N=N<<1^(N>>7)*283)),K[L]=K[L-G]^I;for(O=0;L;O++,L--)I=K[O&3?L:L-4],L<=4||O<4?k[O]=I:k[O]=P[0][j[I>>>24]]^P[1][j[I>>16&255]]^P[2][j[I>>8&255]]^P[3][j[I&255]]}decrypt(w,L,O,I,j,P){const G=this._key[1];let N=w^G[0],K=I^G[1],k=O^G[2],R=L^G[3],Y,z,X;const re=G.length/4-2;let J,W=4;const q=this._tables[1],Z=q[0],te=q[1],oe=q[2],F=q[3],le=q[4];for(J=0;J<re;J++)Y=Z[N>>>24]^te[K>>16&255]^oe[k>>8&255]^F[R&255]^G[W],z=Z[K>>>24]^te[k>>16&255]^oe[R>>8&255]^F[N&255]^G[W+1],X=Z[k>>>24]^te[R>>16&255]^oe[N>>8&255]^F[K&255]^G[W+2],R=Z[R>>>24]^te[N>>16&255]^oe[K>>8&255]^F[k&255]^G[W+3],W+=4,N=Y,K=z,k=X;for(J=0;J<4;J++)j[(3&-J)+P]=le[N>>>24]<<24^le[K>>16&255]<<16^le[k>>8&255]<<8^le[R&255]^G[W++],Y=N,N=K,K=k,k=R,R=Y}}class r extends s{constructor(){super(s),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(w){this.jobs.push(w),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},u=function(S,w,L){const O=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),I=new n(Array.prototype.slice.call(w)),j=new Uint8Array(S.byteLength),P=new Int32Array(j.buffer);let G,N,K,k,R,Y,z,X,re;for(G=L[0],N=L[1],K=L[2],k=L[3],re=0;re<O.length;re+=4)R=a(O[re]),Y=a(O[re+1]),z=a(O[re+2]),X=a(O[re+3]),I.decrypt(R,Y,z,X,P,re),P[re]=a(P[re]^G),P[re+1]=a(P[re+1]^N),P[re+2]=a(P[re+2]^K),P[re+3]=a(P[re+3]^k),G=R,N=Y,K=z,k=X;return j};class c{constructor(w,L,O,I){const j=c.STEP,P=new Int32Array(w.buffer),G=new Uint8Array(w.byteLength);let N=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(P.subarray(N,N+j),L,O,G)),N=j;N<P.length;N+=j)O=new Uint32Array([a(P[N-4]),a(P[N-3]),a(P[N-2]),a(P[N-1])]),this.asyncStream_.push(this.decryptChunk_(P.subarray(N,N+j),L,O,G));this.asyncStream_.push(function(){I(null,e(G))})}static get STEP(){return 32e3}decryptChunk_(w,L,O,I){return function(){const j=u(w,L,O);I.set(j,w.byteOffset)}}}var d=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},f;typeof window<"u"?f=window:typeof d<"u"?f=d:typeof self<"u"?f=self:f={};var g=f,y=function(w){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(w):w&&w.buffer instanceof ArrayBuffer},v=g.BigInt||Number;v("0x1"),v("0x100"),v("0x10000"),v("0x1000000"),v("0x100000000"),v("0x10000000000"),v("0x1000000000000"),v("0x100000000000000"),v("0x10000000000000000"),(function(){var S=new Uint16Array([65484]),w=new Uint8Array(S.buffer,S.byteOffset,S.byteLength);return w[0]===255?"big":w[0]===204?"little":"unknown"})();const T=function(S){const w={};return Object.keys(S).forEach(L=>{const O=S[L];y(O)?w[L]={bytes:O.buffer,byteOffset:O.byteOffset,byteLength:O.byteLength}:w[L]=O}),w};self.onmessage=function(S){const w=S.data,L=new Uint8Array(w.encrypted.bytes,w.encrypted.byteOffset,w.encrypted.byteLength),O=new Uint32Array(w.key.bytes,w.key.byteOffset,w.key.byteLength/4),I=new Uint32Array(w.iv.bytes,w.iv.byteOffset,w.iv.byteLength/4);new c(L,O,I,function(j,P){self.postMessage(T({source:w.source,decrypted:P}),[P.buffer])})}}));var l6=AD(o6);const u6=s=>{let e=s.default?"main":"alternative";return s.characteristics&&s.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},zD=(s,e)=>{s.abort(),s.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},$x=(s,e)=>{e.activePlaylistLoader=s,s.load()},c6=(s,e)=>()=>{const{segmentLoaders:{[s]:t,main:i},mediaTypes:{[s]:n}}=e,r=n.activeTrack(),a=n.getActiveGroup(),u=n.activePlaylistLoader,c=n.lastGroup_;if(!(a&&c&&a.id===c.id)&&(n.lastGroup_=a,n.lastTrack_=r,zD(t,n),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){u&&i.resetEverything();return}t.resyncLoader(),$x(a.playlistLoader,n)}},d6=(s,e)=>()=>{const{segmentLoaders:{[s]:t},mediaTypes:{[s]:i}}=e;i.lastGroup_=null,t.abort(),t.pause()},h6=(s,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[s]:i,main:n},mediaTypes:{[s]:r}}=e,a=r.activeTrack(),u=r.getActiveGroup(),c=r.activePlaylistLoader,d=r.lastTrack_;if(!(d&&a&&d.id===a.id)&&(r.lastGroup_=u,r.lastTrack_=a,zD(i,r),!!u)){if(u.isMainPlaylist){if(!a||!d||a.id===d.id)return;const f=e.vhs.playlistController_,g=f.selectPlaylist();if(f.media()===g)return;r.logger_(`track change. Switching main audio from ${d.id} to ${a.id}`),t.pause(),n.resetEverything(),f.fastQualityChange_(g);return}if(s==="AUDIO"){if(!u.playlistLoader){n.setAudio(!0),n.resetEverything();return}i.setAudio(!0),n.setAudio(!1)}if(c===u.playlistLoader){$x(u.playlistLoader,r);return}i.track&&i.track(a),i.resetEverything(),$x(u.playlistLoader,r)}},U0={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:t},excludePlaylist:i}=e,n=t.activeTrack(),r=t.activeGroup(),a=(r.filter(c=>c.default)[0]||r[0]).id,u=t.tracks[a];if(n===u){i({error:{message:"Problem encountered loading the default audio track."}});return}He.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===u;t.onTrackChanged()},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:t}}=e;He.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const i=t.activeTrack();i&&(i.mode="disabled"),t.onTrackChanged()}},qE={AUDIO:(s,e,t)=>{if(!e)return;const{tech:i,requestOptions:n,segmentLoaders:{[s]:r}}=t;e.on("loadedmetadata",()=>{const a=e.media();r.playlist(a,n),(!i.paused()||a.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",U0[s](s,t))},SUBTITLES:(s,e,t)=>{const{tech:i,requestOptions:n,segmentLoaders:{[s]:r},mediaTypes:{[s]:a}}=t;e.on("loadedmetadata",()=>{const u=e.media();r.playlist(u,n),r.track(a.activeTrack()),(!i.paused()||u.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",U0[s](s,t))}},f6={AUDIO:(s,e)=>{const{vhs:t,sourceType:i,segmentLoaders:{[s]:n},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[s]:{groups:u,tracks:c,logger_:d}},mainPlaylistLoader:f}=e,g=tf(f.main);(!a[s]||Object.keys(a[s]).length===0)&&(a[s]={main:{default:{default:!0}}},g&&(a[s].main.default.playlists=f.main.playlists));for(const y in a[s]){u[y]||(u[y]=[]);for(const v in a[s][y]){let T=a[s][y][v],S;if(g?(d(`AUDIO group '${y}' label '${v}' is a main playlist`),T.isMainPlaylist=!0,S=null):i==="vhs-json"&&T.playlists?S=new gc(T.playlists[0],t,r):T.resolvedUri?S=new gc(T.resolvedUri,t,r):T.playlists&&i==="dash"?S=new Px(T.playlists[0],t,r,f):S=null,T=is({id:v,playlistLoader:S},T),qE[s](s,T.playlistLoader,e),u[y].push(T),typeof c[v]>"u"){const w=new He.AudioTrack({id:v,kind:u6(T),enabled:!1,language:T.language,default:T.default,label:v});c[v]=w}}}n.on("error",U0[s](s,e))},SUBTITLES:(s,e)=>{const{tech:t,vhs:i,sourceType:n,segmentLoaders:{[s]:r},requestOptions:a,main:{mediaGroups:u},mediaTypes:{[s]:{groups:c,tracks:d}},mainPlaylistLoader:f}=e;for(const g in u[s]){c[g]||(c[g]=[]);for(const y in u[s][g]){if(!i.options_.useForcedSubtitles&&u[s][g][y].forced)continue;let v=u[s][g][y],T;if(n==="hls")T=new gc(v.resolvedUri,i,a);else if(n==="dash"){if(!v.playlists.filter(w=>w.excludeUntil!==1/0).length)return;T=new Px(v.playlists[0],i,a,f)}else n==="vhs-json"&&(T=new gc(v.playlists?v.playlists[0]:v.resolvedUri,i,a));if(v=is({id:y,playlistLoader:T},v),qE[s](s,v.playlistLoader,e),c[g].push(v),typeof d[y]>"u"){const S=t.addRemoteTextTrack({id:y,kind:"subtitles",default:v.default&&v.autoselect,language:v.language,label:y},!1).track;d[y]=S}}}r.on("error",U0[s](s,e))},"CLOSED-CAPTIONS":(s,e)=>{const{tech:t,main:{mediaGroups:i},mediaTypes:{[s]:{groups:n,tracks:r}}}=e;for(const a in i[s]){n[a]||(n[a]=[]);for(const u in i[s][a]){const c=i[s][a][u];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const d=t.options_.vhs&&t.options_.vhs.captionServices||{};let f={label:u,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(d[f.instreamId]&&(f=is(f,d[f.instreamId])),f.default===void 0&&delete f.default,n[a].push(is({id:u},c)),typeof r[u]>"u"){const g=t.addRemoteTextTrack({id:f.instreamId,kind:"captions",default:f.default,language:f.language,label:f.label},!1).track;r[u]=g}}}}},VD=(s,e)=>{for(let t=0;t<s.length;t++)if(Jb(e,s[t])||s[t].playlists&&VD(s[t].playlists,e))return!0;return!1},m6=(s,e)=>t=>{const{mainPlaylistLoader:i,mediaTypes:{[s]:{groups:n}}}=e,r=i.media();if(!r)return null;let a=null;r.attributes[s]&&(a=n[r.attributes[s]]);const u=Object.keys(n);if(!a)if(s==="AUDIO"&&u.length>1&&tf(e.main))for(let c=0;c<u.length;c++){const d=n[u[c]];if(VD(d,r)){a=d;break}}else n.main?a=n.main:u.length===1&&(a=n[u[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},p6={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].enabled)return t[i];return null},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].mode==="showing"||t[i].mode==="hidden")return t[i];return null}},g6=(s,{mediaTypes:e})=>()=>{const t=e[s].activeTrack();return t?e[s].activeGroup(t):null},y6=s=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(d=>{f6[d](d,s)});const{mediaTypes:e,mainPlaylistLoader:t,tech:i,vhs:n,segmentLoaders:{["AUDIO"]:r,main:a}}=s;["AUDIO","SUBTITLES"].forEach(d=>{e[d].activeGroup=m6(d,s),e[d].activeTrack=p6[d](d,s),e[d].onGroupChanged=c6(d,s),e[d].onGroupChanging=d6(d,s),e[d].onTrackChanged=h6(d,s),e[d].getActiveGroup=g6(d,s)});const u=e.AUDIO.activeGroup();if(u){const d=(u.filter(g=>g.default)[0]||u[0]).id;e.AUDIO.tracks[d].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(d=>e[d].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(d=>e[d].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),i.trigger({type:"usage",name:"vhs-audio-change"})};i.audioTracks().addEventListener("change",c),i.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),n.on("dispose",()=>{i.audioTracks().removeEventListener("change",c),i.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),i.clearTracks("audio");for(const d in e.AUDIO.tracks)i.audioTracks().addTrack(e.AUDIO.tracks[d])},v6=()=>{const s={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{s[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ko,activeTrack:ko,getActiveGroup:ko,onGroupChanged:ko,onTrackChanged:ko,lastTrack_:null,logger_:na(`MediaGroups[${e}]`)}}),s};class KE{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=yr(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}let x6=class extends He.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new KE,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=na("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const i=t.serverUri||t.serverURL;if(!i){this.logger_(`steering manifest URL is ${i}, cannot request steering manifest.`),this.trigger("error");return}if(i.startsWith("data:")){this.decodeDataUriManifest_(i.substring(i.indexOf(",")+1));return}this.steeringManifest.reloadUri=yr(e,i),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const i=e?t:this.getRequestURI(t);if(!i){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const n={contentSteeringInfo:{uri:i}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:i,requestType:"content-steering-manifest"},(r,a)=>{if(r){if(a.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${i} this session.`),this.excludedSteeringManifestURLs.add(i);return}if(a.status===429){const d=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${d} seconds.`),this.startTTLTimeout_(parseInt(d,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let u;try{u=JSON.parse(this.request_.responseText)}catch(d){const f={errorType:He.Error.StreamingContentSteeringParserError,error:d};this.trigger({type:"error",metadata:f})}this.assignSteeringProperties_(u);const c={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new ye.URL(e),i=new ye.URL(this.proxyServerUrl_);return i.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(i.toString())}decodeDataUriManifest_(e){const t=JSON.parse(ye.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new ye.URL(e),i=this.getPathway(),n=this.getBandwidth_();if(i){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,i)}if(n){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const i=(n=>{for(const r of n)if(this.availablePathways_.has(r))return r;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==i&&(this.currentPathway=i,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=n=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){const n=this.setProxyServerUrl_(e);if(!t(n))return n}const i=this.setSteeringParams_(e);return t(i)?null:i}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=ye.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){ye.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new KE}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(yr(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}};const b6=(s,e)=>{let t=null;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{s.apply(null,i)},e)}},T6=10;let pl;const S6=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],_6=function(s){return this.audioSegmentLoader_[s]+this.mainSegmentLoader_[s]},E6=function({currentPlaylist:s,buffered:e,currentTime:t,nextPlaylist:i,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:a,bufferBasedABR:u,log:c}){if(!i)return He.log.warn("We received no playlist to switch to. Please check your stream."),!1;const d=`allowing switch ${s&&s.id||"null"} -> ${i.id}`;if(!s)return c(`${d} as current playlist is not set`),!0;if(i.id===s.id)return!1;const f=!!pc(e,t).length;if(!s.endList)return!f&&typeof s.partTargetDuration=="number"?(c(`not ${d} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${d} as current playlist is live`),!0);const g=Xb(e,t),y=u?Dn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Dn.MAX_BUFFER_LOW_WATER_LINE;if(a<y)return c(`${d} as duration < max low water line (${a} < ${y})`),!0;const v=i.attributes.BANDWIDTH,T=s.attributes.BANDWIDTH;if(v<T&&(!u||g<r)){let S=`${d} as next bandwidth < current bandwidth (${v} < ${T})`;return u&&(S+=` and forwardBuffer < bufferHighWaterLine (${g} < ${r})`),c(S),!0}if((!u||v>T)&&g>=n){let S=`${d} as forwardBuffer >= bufferLowWaterLine (${g} >= ${n})`;return u&&(S+=` and next bandwidth > current bandwidth (${v} > ${T})`),c(S),!0}return c(`not ${d} as no switching criteria met`),!1};class w6 extends He.EventTarget{constructor(e){super(),this.fastQualityChange_=b6(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:i,tech:n,bandwidth:r,externVhs:a,useCueTags:u,playlistExclusionDuration:c,enableLowInitialPlaylist:d,sourceType:f,cacheEncryptionKeys:g,bufferBasedABR:y,leastPixelDiffSelector:v,captionServices:T,experimentalUseMMS:S}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:w}=e;(w===null||typeof w>"u")&&(w=1/0),pl=a,this.bufferBasedABR=!!y,this.leastPixelDiffSelector=!!v,this.withCredentials=i,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=f,this.useCueTags_=u,this.playlistExclusionDuration=c,this.maxPlaylistRetries=w,this.enableLowInitialPlaylist=d,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:w,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=v6(),S&&ye.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new ye.ManagedMediaSource,this.usingManagedMediaSource_=!0,He.log("Using ManagedMediaSource")):ye.MediaSource&&(this.mediaSource=new ye.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=Rn(),this.hasPlayed_=!1,this.syncController_=new r6(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new l6,this.sourceUpdater_=new $D(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new a6,this.keyStatusMap_=new Map;const L={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:T,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:g,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new Px(t,this.vhs_,is(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new gc(t,this.vhs_,is(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Ux(is(L,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Ux(is(L,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new e6(is(L,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((j,P)=>{function G(){n.off("vttjserror",N),j()}function N(){n.off("vttjsloaded",G),P()}n.one("vttjsloaded",G),n.one("vttjserror",N),n.addWebVttScript_()})}),e);const O=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new x6(this.vhs_.xhr,O),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),S6.forEach(j=>{this[j+"_"]=_6.bind(this,j)}),this.logger_=na("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const I=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(I,()=>{const j=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-j,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,i){const n=this.media(),r=n&&(n.id||n.uri),a=e&&(e.id||e.uri);if(r&&r!==a){this.logger_(`switch media ${r} -> ${a} from ${t}`);const u={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:u}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,i)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],i=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(i&&n){const a=(i.length?i[0].playlists:i.playlists).filter(u=>u.attributes.serviceLocation===n);a.length&&this.mediaTypes_[e].activePlaylistLoader.media(a[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=ye.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(ye.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const i=e.mediaGroups.AUDIO,n=Object.keys(i);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const u=i.main||n.length&&i[n[0]];for(const c in u)if(u[c].default){r={label:c};break}}if(!r)return t;const a=[];for(const u in i)if(i[u][r.label]){const c=i[u][r.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let d=0;d<e.playlists.length;d++){const f=e.playlists[d];f.attributes&&f.attributes.AUDIO&&f.attributes.AUDIO===u&&a.push(f)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;Rx(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,t.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load()),y6({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),t),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let i;if(this.enableLowInitialPlaylist&&(i=this.selectInitialPlaylist()),i||(i=this.selectPlaylist()),!i||!this.shouldSwitchToMedia_(i)||(this.initialMedia_=i,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{const t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;Rx(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(t)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(t=>{this.mainPlaylistLoader_.on(t,i=>{this.player_.trigger(on({},i))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const i=e.mediaGroups||{};let n=!0;const r=Object.keys(i.AUDIO);for(const a in i.AUDIO)for(const u in i.AUDIO[a])i.AUDIO[a][u].uri||(n=!1);n&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),pl.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),n=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),a=this.tech_.buffered();return E6({buffered:a,currentTime:i,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const i=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:i.playlist,error:i})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const i=this.audioSegmentLoader_.pendingSegment_;if(!i||!i.segment||!i.segment.syncInfo)return;const n=i.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",i=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:T6}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const i=this.getCodecsOrExclude_();i&&this.sourceUpdater_.addOrChangeSourceBuffers(i)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(i=>{this.mainSegmentLoader_.on(i,n=>{this.player_.trigger(on({},n))}),this.audioSegmentLoader_.on(i,n=>{this.player_.trigger(on({},n))}),this.subtitleSegmentLoader_.on(i,n=>{this.player_.trigger(on({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const i=t.end(0);let n=i;if(e.start){const r=e.start.timeOffset;r<0?n=Math.max(i+r,t.start(0)):n=Math.min(i,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const i=this.syncController_.getExpiredTime(e,this.duration());if(i===null)return!1;const n=pl.Playlist.playlistEnd(e,i),r=this.tech_.currentTime(),a=this.tech_.buffered();if(!a.length)return n-r<=za;const u=a.end(a.length-1);return u-r<=za&&n-u<=za}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:i}){if(e=e||this.mainPlaylistLoader_.media(),i=i||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const n=this.mainPlaylistLoader_.main.playlists,r=n.filter(Rp),a=r.length===1&&r[0]===e;if(n.length===1&&i!==1/0)return He.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const T=this.pathwayAttribute_(e),S=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(T),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(T)},S);return}let v=!1;n.forEach(T=>{if(T===e)return;const S=T.excludeUntil;typeof S<"u"&&S!==1/0&&(v=!0,delete T.excludeUntil)}),v&&(He.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let u;e.playlistErrors_>this.maxPlaylistRetries?u=1/0:u=Date.now()+i*1e3,e.excludeUntil=u,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const d=t.internal?this.logger_:He.log.warn,f=t.message?" "+t.message:"";d(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${f} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const g=c.targetDuration/2*1e3||5*1e3,y=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=g;return this.switchMedia_(c,"exclude",a||y)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const i=[],n=e==="all";(n||e==="main")&&i.push(this.mainPlaylistLoader_);const r=[];(n||e==="audio")&&r.push("AUDIO"),(n||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(a=>{const u=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;u&&i.push(u)}),["main","audio","subtitle"].forEach(a=>{const u=this[`${a}SegmentLoader_`];u&&(e===a||e==="all")&&i.push(u)}),i.forEach(a=>t.forEach(u=>{typeof a[u]=="function"&&a[u]()}))}setCurrentTime(e){const t=pc(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:pl.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const i=e.media();if(!i)return null;const n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){const u=n.start,c=n.end;if(!isFinite(u)||!isFinite(c))return null;const d=pl.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i),f=Math.max(u,c-d);return Rn([[u,f]])}const r=this.syncController_.getExpiredTime(i,this.duration());if(r===null)return null;const a=pl.Playlist.seekable(i,r,pl.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const i=e.start(0),n=e.end(0),r=t.start(0),a=t.end(0);return r>n||i>a?e:Rn([[Math.max(i,r),Math.min(n,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const i=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||i&&i.length&&this.seekable_.length&&i.start(0)===this.seekable_.start(0)&&i.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${eD(this.seekable_)}]`);const n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const n=this.seekable();if(!n.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))&&this.sourceUpdater_.setDuration(n.end(n.length-1));return}const t=this.tech_.buffered();let i=pl.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(i=Math.max(i,t.end(t.length-1))),this.mediaSource.duration!==i&&this.sourceUpdater_.setDuration(i)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const i in t)t[i].forEach(n=>{n.playlistLoader&&n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),i=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!i)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const i=Ch(this.main(),t),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(n.video=i.video||e.main.videoCodec||fP),e.main.isMuxed&&(n.video+=`,${i.audio||e.main.audioCodec||P2}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(n.audio=i.audio||e.main.audioCodec||e.audio.audioCodec||P2,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(d,f)=>d?_h(f,this.usingManagedMediaSource_):sv(f),u={};let c;if(["video","audio"].forEach(function(d){if(n.hasOwnProperty(d)&&!a(e[d].isFmp4,n[d])){const f=e[d].isFmp4?"browser":"muxer";u[f]=u[f]||[],u[f].push(n[d]),d==="audio"&&(c=f)}}),r&&c&&t.attributes.AUDIO){const d=t.attributes.AUDIO;this.main().playlists.forEach(f=>{(f.attributes&&f.attributes.AUDIO)===d&&f!==t&&(f.excludeUntil=1/0)}),this.logger_(`excluding audio group ${d} as ${c} does not support codec(s): "${n.audio}"`)}if(Object.keys(u).length){const d=Object.keys(u).reduce((f,g)=>(f&&(f+=", "),f+=`${g} does not support codec(s): "${u[g].join(",")}"`,f),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:d},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const d=[];if(["video","audio"].forEach(f=>{const g=(Fa(this.sourceUpdater_.codecs[f]||"")[0]||{}).type,y=(Fa(n[f]||"")[0]||{}).type;g&&y&&g.toLowerCase()!==y.toLowerCase()&&d.push(`"${this.sourceUpdater_.codecs[f]}" -> "${n[f]}"`)}),d.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${d.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(i=>{const n=e[i];if(t.indexOf(n.id)!==-1)return;t.push(n.id);const r=Ch(this.main,n),a=[];r.audio&&!sv(r.audio)&&!_h(r.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${r.audio}`),r.video&&!sv(r.video)&&!_h(r.video,this.usingManagedMediaSource_)&&a.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&a.push(`text codec ${r.text}`),a.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],i=this.main().playlists,n=Fh(Fa(e)),r=DE(n),a=n.video&&Fa(n.video)[0]||null,u=n.audio&&Fa(n.audio)[0]||null;Object.keys(i).forEach(c=>{const d=i[c];if(t.indexOf(d.id)!==-1||d.excludeUntil===1/0)return;t.push(d.id);const f=[],g=Ch(this.mainPlaylistLoader_.main,d),y=DE(g);if(!(!g.audio&&!g.video)){if(y!==r&&f.push(`codec count "${y}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const v=g.video&&Fa(g.video)[0]||null,T=g.audio&&Fa(g.audio)[0]||null;v&&a&&v.type.toLowerCase()!==a.type.toLowerCase()&&f.push(`video codec "${v.type}" !== "${a.type}"`),T&&u&&T.type.toLowerCase()!==u.type.toLowerCase()&&f.push(`audio codec "${T.type}" !== "${u.type}"`)}f.length&&(d.excludeUntil=1/0,this.logger_(`excluding ${d.id}: ${f.join(" && ")}`))}})}updateAdCues_(e){let t=0;const i=this.seekable();i.length&&(t=i.start(0)),i6(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Dn.GOAL_BUFFER_LENGTH,i=Dn.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,Dn.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Dn.BUFFER_LOW_WATER_LINE,i=Dn.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,Dn.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,Dn.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?r:n)}bufferHighWaterLine(){return Dn.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){BE(this.inbandTextTracks_,"com.apple.streaming",this.tech_),M8({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,i){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();BE(this.inbandTextTracks_,e,this.tech_),I8({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:i})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(t=>{this.contentSteeringController_.on(t,i=>{this.trigger(on({},i))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const r=this.contentSteeringController_.getAvailablePathways(),a=[];for(const u of t.playlists){const c=u.attributes.serviceLocation;if(c&&(a.push(c),!r.has(c)))return!0}return!!(!a.length&&r.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const i=this.main().playlists,n=new Set;let r=!1;Object.keys(i).forEach(a=>{const u=i[a],c=this.pathwayAttribute_(u),d=c&&e!==c;u.excludeUntil===1/0&&u.lastExcludeReason_==="content-steering"&&!d&&(delete u.excludeUntil,delete u.lastExcludeReason_,r=!0);const g=!u.excludeUntil&&u.excludeUntil!==1/0;!n.has(u.id)&&d&&g&&(n.add(u.id),u.excludeUntil=1/0,u.lastExcludeReason_="content-steering",this.logger_(`excluding ${u.id} for ${u.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(a=>{const u=this.mediaTypes_[a];if(u.activePlaylistLoader){const c=u.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(r=!0)}}),r&&this.changeSegmentPathway_()}handlePathwayClones_(){const t=this.main().playlists,i=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(i&&i.size||n&&n.size){for(const[a,u]of i.entries())n.get(a)||(this.mainPlaylistLoader_.updateOrDeleteClone(u),this.contentSteeringController_.excludePathway(a));for(const[a,u]of n.entries()){const c=i.get(a);if(!c){t.filter(f=>f.attributes["PATHWAY-ID"]===u["BASE-ID"]).forEach(f=>{this.mainPlaylistLoader_.addClonePathway(u,f)}),this.contentSteeringController_.addAvailablePathway(a);continue}this.equalPathwayClones_(c,u)||(this.mainPlaylistLoader_.updateOrDeleteClone(u,!0),this.contentSteeringController_.addAvailablePathway(a))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const i=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(const r in i)if(i[r]!==n[r])return!1;for(const r in n)if(i[r]!==n[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=this.mainPlaylistLoader_.getKeyIdSet(i);!n||!n.size||n.forEach(r=>{const a="usable",u=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===a,c=i.lastExcludeReason_===t&&i.excludeUntil===1/0;u?u&&c&&(delete i.excludeUntil,delete i.lastExcludeReason_,this.logger_(`enabling playlist ${i.id} because key ID ${r} is ${a}`)):(i.excludeUntil!==1/0&&i.lastExcludeReason_!==t&&(i.excludeUntil=1/0,i.lastExcludeReason_=t,this.logger_(`excluding playlist ${i.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=i&&i.attributes&&i.attributes.RESOLUTION&&i.attributes.RESOLUTION.height<720,r=i.excludeUntil===1/0&&i.lastExcludeReason_===t;n&&r&&(delete i.excludeUntil,He.log.warn(`enabling non-HD playlist ${i.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const r=(typeof e=="string"?e:Z8(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${r} added to the keyStatusMap`),this.keyStatusMap_.set(r,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const A6=(s,e,t)=>i=>{const n=s.main.playlists[e],r=Zb(n),a=Rp(n);if(typeof i>"u")return a;i?delete n.disabled:n.disabled=!0;const u={renditionInfo:{id:e,bandwidth:n.attributes.BANDWIDTH,resolution:n.attributes.RESOLUTION,codecs:n.attributes.CODECS},cause:"fast-quality"};return i!==a&&!r&&(i?(t(n),s.trigger({type:"renditionenabled",metadata:u})):s.trigger({type:"renditiondisabled",metadata:u})),i};class k6{constructor(e,t,i){const{playlistController_:n}=e,r=n.fastQualityChange_.bind(n);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=Ch(n.main(),t),this.playlist=t,this.id=i,this.enabled=A6(e.playlists,t.id,r)}}const C6=function(s){s.representations=()=>{const e=s.playlistController_.main(),t=tf(e)?s.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(i=>!Zb(i)).map((i,n)=>new k6(s,i,i.id)):[]}},WE=["seeking","seeked","pause","playing","error"];class D6 extends He.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=na("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),a=this.playlistController_,u=["main","subtitle","audio"],c={};u.forEach(f=>{c[f]={reset:()=>this.resetSegmentDownloads_(f),updateend:()=>this.checkSegmentDownloads_(f)},a[`${f}SegmentLoader_`].on("appendsdone",c[f].updateend),a[`${f}SegmentLoader_`].on("playlistupdate",c[f].reset),this.tech_.on(["seeked","seeking"],c[f].reset)});const d=f=>{["main","audio"].forEach(g=>{a[`${g}SegmentLoader_`][f]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),d("off"))},this.clearSeekingAppendCheck_=()=>d("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),d("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(WE,r),this.tech_.on("canplay",i),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(WE,r),this.tech_.off("canplay",i),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),u.forEach(f=>{a[`${f}SegmentLoader_`].off("appendsdone",c[f].updateend),a[`${f}SegmentLoader_`].off("playlistupdate",c[f].reset),this.tech_.off(["seeked","seeking"],c[f].reset)}),this.checkCurrentTimeTimeout_&&ye.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&ye.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=ye.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,i=t[`${e}SegmentLoader_`],n=i.buffered_(),r=mF(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,r){const a={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:i.playlist_&&i.playlist_.id,buffered:mu(n)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+za>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Rn([this.lastRecordedTime,e]));const i={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:i}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const t=this.seekable(),i=this.tech_.currentTime(),n=this.afterSeekableWindow_(t,i,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let r;if(n&&(r=t.end(t.length-1)),this.beforeSeekableWindow_(t,i)){const T=t.start(0);r=T+(T===t.end(0)?0:za)}if(typeof r<"u")return this.logger_(`Trying to seek outside of seekable at time ${i} with seekable range ${eD(t)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;const a=this.playlistController_.sourceUpdater_,u=this.tech_.buffered(),c=a.audioBuffer?a.audioBuffered():null,d=a.videoBuffer?a.videoBuffered():null,f=this.media(),g=f.partTargetDuration?f.partTargetDuration:(f.targetDuration-Ha)*2,y=[c,d];for(let T=0;T<y.length;T++){if(!y[T])continue;if(Xb(y[T],i)<g)return!1}const v=Dm(u,i);return v.length===0?!1:(r=v.start(0)+za,this.logger_(`Buffered region starts (${v.start(0)}) just beyond seek point (${i}). Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),i=pc(t,e);if(i.length&&e+3<=i.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${i.start(0)} -> ${i.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const u=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${u}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(u),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const i=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:i.audioBuffered(),videoBuffered:i.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const a=Dm(n,t);return a.length>0?(this.logger_(`Stopped at ${t} and seeking to ${a.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,i,n=!1){if(!e.length)return!1;let r=e.end(e.length-1)+za;const a=!i.endList,u=typeof i.partTargetDuration=="number";return a&&(u||n)&&(r=e.end(e.length-1)+i.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:i}){if(!e)return;let n;if(e.length&&t.length){const r=pc(e,i-3),a=pc(e,i),u=pc(t,i);u.length&&!a.length&&r.length&&(n={start:r.end(0),end:u.end(0)})}else Dm(e,i).length||(n=this.gapFromVideoUnderflow_(e,i));return n?(this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${i}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),i=this.tech_.currentTime(),n=Dm(t,i);if(this.resetTimeUpdate_(),n.length===0||i!==e)return;this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+Ha);const r={gapInfo:{from:i,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const i=dF(e);for(let n=0;n<i.length;n++){const r=i.start(n),a=i.end(n);if(t-r<4&&t-r>2)return{start:r,end:a}}return null}}const L6={errorInterval:30,getSource(s){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return s(t)}},GD=function(s,e){let t=0,i=0;const n=is(L6,e);s.ready(()=>{s.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){i&&s.currentTime(i)},a=function(f){f!=null&&(i=s.duration()!==1/0&&s.currentTime()||0,s.one("loadedmetadata",r),s.src(f),s.trigger({type:"usage",name:"vhs-error-reload"}),s.play())},u=function(){if(Date.now()-t<n.errorInterval*1e3){s.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!n.getSource||typeof n.getSource!="function"){He.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(s,a)},c=function(){s.off("loadedmetadata",r),s.off("error",u),s.off("dispose",c)},d=function(f){c(),GD(s,f)};s.on("error",u),s.on("dispose",c),s.reloadSourceOnError=d},R6=function(s){GD(this,s)};var qD="3.17.2",I6="7.1.0",N6="1.3.1",O6="7.2.0",M6="4.0.2";const Vs={PlaylistLoader:gc,Playlist:xr,utils:jF,STANDARD_PLAYLIST_SELECTOR:PE,INITIAL_PLAYLIST_SELECTOR:k8,lastBandwidthSelector:PE,movingAverageBandwidthSelector:w8,comparePlaylistBandwidth:t1,comparePlaylistResolution:E8,xhr:xD()};Object.keys(Dn).forEach(s=>{Object.defineProperty(Vs,s,{get(){return He.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),Dn[s]},set(e){if(He.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){He.log.warn(`value of Vhs.${s} must be greater than or equal to 0`);return}Dn[s]=e}})});const KD="videojs-vhs",WD=function(s,e){const t=e.media();let i=-1;for(let n=0;n<s.length;n++)if(s[n].id===t.id){i=n;break}s.selectedIndex_=i,s.trigger({selectedIndex:i,type:"change"})},P6=function(s,e){e.representations().forEach(t=>{s.addQualityLevel(t)}),WD(s,e.playlists)};Vs.canPlaySource=function(){return He.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const B6=(s,e,t)=>{if(!s)return s;let i={};e&&e.attributes&&e.attributes.CODECS&&(i=Fh(Fa(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(i.audio=t.attributes.CODECS);const n=Pc(i.video),r=Pc(i.audio),a={};for(const u in s)a[u]={},r&&(a[u].audioContentType=r),n&&(a[u].videoContentType=n),e.contentProtection&&e.contentProtection[u]&&e.contentProtection[u].pssh&&(a[u].pssh=e.contentProtection[u].pssh),typeof s[u]=="string"&&(a[u].url=s[u]);return is(s,a)},F6=(s,e)=>s.reduce((t,i)=>{if(!i.contentProtection)return t;const n=e.reduce((r,a)=>{const u=i.contentProtection[a];return u&&u.pssh&&(r[a]={pssh:u.pssh}),r},{});return Object.keys(n).length&&t.push(n),t},[]),U6=({player:s,sourceKeySystems:e,audioMedia:t,mainPlaylists:i})=>{if(!s.eme.initializeMediaKeys)return Promise.resolve();const n=t?i.concat([t]):i,r=F6(n,Object.keys(e)),a=[],u=[];return r.forEach(c=>{u.push(new Promise((d,f)=>{s.tech_.one("keysessioncreated",d)})),a.push(new Promise((d,f)=>{s.eme.initializeMediaKeys({keySystems:c},g=>{if(g){f(g);return}d()})}))}),Promise.race([Promise.all(a),Promise.race(u)])},j6=({player:s,sourceKeySystems:e,media:t,audioMedia:i})=>{const n=B6(e,t,i);return n?(s.currentSource().keySystems=n,n&&!s.eme?(He.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},YD=()=>{if(!ye.localStorage)return null;const s=ye.localStorage.getItem(KD);if(!s)return null;try{return JSON.parse(s)}catch{return null}},$6=s=>{if(!ye.localStorage)return!1;let e=YD();e=e?is(e,s):s;try{ye.localStorage.setItem(KD,JSON.stringify(e))}catch{return!1}return e},H6=s=>s.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(s.substring(s.indexOf(",")+1)):s,XD=(s,e)=>{s._requestCallbackSet||(s._requestCallbackSet=new Set),s._requestCallbackSet.add(e)},QD=(s,e)=>{s._responseCallbackSet||(s._responseCallbackSet=new Set),s._responseCallbackSet.add(e)},ZD=(s,e)=>{s._requestCallbackSet&&(s._requestCallbackSet.delete(e),s._requestCallbackSet.size||delete s._requestCallbackSet)},JD=(s,e)=>{s._responseCallbackSet&&(s._responseCallbackSet.delete(e),s._responseCallbackSet.size||delete s._responseCallbackSet)};Vs.supportsNativeHls=(function(){if(!bt||!bt.createElement)return!1;const s=bt.createElement("video");return He.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(t){return/maybe|probably/i.test(s.canPlayType(t))}):!1})();Vs.supportsNativeDash=(function(){return!bt||!bt.createElement||!He.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(bt.createElement("video").canPlayType("application/dash+xml"))})();Vs.supportsTypeNatively=s=>s==="hls"?Vs.supportsNativeHls:s==="dash"?Vs.supportsNativeDash:!1;Vs.isSupported=function(){return He.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Vs.xhr.onRequest=function(s){XD(Vs.xhr,s)};Vs.xhr.onResponse=function(s){QD(Vs.xhr,s)};Vs.xhr.offRequest=function(s){ZD(Vs.xhr,s)};Vs.xhr.offResponse=function(s){JD(Vs.xhr,s)};const z6=He.getComponent("Component");class eL extends z6{constructor(e,t,i){if(super(t,i.vhs),typeof i.initialBandwidth=="number"&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=na("VhsHandler"),t.options_&&t.options_.playerId){const n=He.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(bt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const r=bt.fullscreenElement||bt.webkitFullscreenElement||bt.mozFullScreenElement||bt.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=is(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=typeof this.options_.useNetworkInformationApi<"u"?this.options_.useNetworkInformationApi:!0,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const i=YD();i&&i.bandwidth&&(this.options_.bandwidth=i.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),i&&i.throughput&&(this.options_.throughput=i.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Dn.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Dn.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","usePlayerObjectFit","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(i=>{typeof this.source_[i]<"u"&&(this.options_[i]=this.source_[i])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=H6(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Vs,this.options_.sourceType=Tk(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new w6(this.options_);const i=is({liveRangeSafeTimeDelta:za},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new D6(i),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=He.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),r.error(a)});const n=this.options_.bufferBasedABR?Vs.movingAverageBandwidthSelector(.55):Vs.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Vs.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const a=ye.navigator.connection||ye.navigator.mozConnection||ye.navigator.webkitConnection,u=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=u&&r>=u?r=Math.max(r,c):r=c}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(r+a))},set(){He.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>mu(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>mu(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&$6({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{C6(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=ye.URL.createObjectURL(this.playlistController_.mediaSource),(He.browser.IS_ANY_SAFARI||He.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),U6({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=j6({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",i=>{this.playlistController_.updatePlaylistByKeyStatus(i.keyId,i.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=He.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{P6(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{WD(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":qD,"mux.js":I6,"mpd-parser":N6,"m3u8-parser":O6,"aes-decrypter":M6}}version(){return this.constructor.version()}canChangeType(){return $D.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&ye.URL.revokeObjectURL&&(ye.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return KF({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,n=2){return ED({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{XD(this.xhr,e)},this.xhr.onResponse=e=>{QD(this.xhr,e)},this.xhr.offRequest=e=>{ZD(this.xhr,e)},this.xhr.offResponse=e=>{JD(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(i=>{this.playlistController_.on(i,n=>{this.player_.trigger(on({},n))})}),t.forEach(i=>{this.playbackWatcher_.on(i,n=>{this.player_.trigger(on({},n))})})}}const j0={name:"videojs-http-streaming",VERSION:qD,canHandleSource(s,e={}){const t=is(He.options,e);return!t.vhs.experimentalUseMMS&&!_h("avc1.4d400d,mp4a.40.2",!1)?!1:j0.canPlayType(s.type,t)},handleSource(s,e,t={}){const i=is(He.options,t);return e.vhs=new eL(s,e,i),e.vhs.xhr=xD(),e.vhs.setupXhrHooks_(),e.vhs.src(s.src,s.type),e.vhs},canPlayType(s,e){const t=Tk(s);if(!t)return"";const i=j0.getOverrideNative(e);return!Vs.supportsTypeNatively(t)||i?"maybe":""},getOverrideNative(s={}){const{vhs:e={}}=s,t=!(He.browser.IS_ANY_SAFARI||He.browser.IS_IOS),{overrideNative:i=t}=e;return i}},V6=()=>_h("avc1.4d400d,mp4a.40.2",!0);V6()&&He.getTech("Html5").registerSourceHandler(j0,0);He.VhsHandler=eL;He.VhsSourceHandler=j0;He.Vhs=Vs;He.use||He.registerComponent("Vhs",Vs);He.options.vhs=He.options.vhs||{};(!He.getPlugin||!He.getPlugin("reloadSourceOnError"))&&He.registerPlugin("reloadSourceOnError",R6);const G6="",lu=s=>{const e=s.startsWith("/")?s:`/${s}`;return`${G6}${e}`};async function Ev(s,e){const t=await fetch(lu(s),{...e,credentials:"include",headers:{...e?.headers??{},"Content-Type":e?.headers?.["Content-Type"]??"application/json"}});return t.status===401&&(location.pathname.startsWith("/login")||(location.href="/login")),t}const Ot=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},q6=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=K6},K6=Number.MAX_SAFE_INTEGER||9007199254740991;let Vt=(function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s})({}),$e=(function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s})({}),H=(function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s})({});var Ii={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class rc{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class W6{constructor(e,t,i,n=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new rc(e),this.fast_=new rc(t),this.defaultTTFB_=n,this.ttfb_=new rc(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new rc(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new rc(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new rc(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,r=i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Y6(s,e,t){return(e=Q6(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function ys(){return ys=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},ys.apply(null,arguments)}function YE(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),t.push.apply(t,i)}return t}function us(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?YE(Object(t),!0).forEach(function(i){Y6(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):YE(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function X6(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function Q6(s){var e=X6(s,"string");return typeof e=="symbol"?e:e+""}class ra{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=Tl,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const Tl=function(){},Z6={trace:Tl,debug:Tl,log:Tl,warn:Tl,info:Tl,error:Tl};function Hx(){return ys({},Z6)}function J6(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Tl}function XE(s,e,t){return e[s]?e[s].bind(e):J6(s,t)}const zx=Hx();function eU(s,e,t){const i=Hx();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=XE(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`)}catch{return Hx()}n.forEach(r=>{zx[r]=XE(r,s)})}else ys(zx,i);return i}const cs=zx;function Ll(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function tU(s){return typeof self<"u"&&s===self.ManagedMediaSource}function tL(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(a=>i.indexOf(a)===-1)}function Hr(s,e=!1){if(typeof TextDecoder<"u"){const d=new TextDecoder("utf-8").decode(s);if(e){const f=d.indexOf("\0");return f!==-1?d.substring(0,f):d}return d.replace(/\0/g,"")}const t=s.length;let i,n,r,a="",u=0;for(;u<t;){if(i=s[u++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=s[u++],a+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[u++],r=s[u++],a+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return a}function zn(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function iL(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function iU(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var wv={exports:{}},QE;function sU(){return QE||(QE=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(c,d,f){if(f=f||{},c=c.trim(),d=d.trim(),!d){if(!f.alwaysNormalize)return c;var g=u.parseURL(c);if(!g)throw new Error("Error trying to parse base URL.");return g.path=u.normalizePath(g.path),u.buildURLFromParts(g)}var y=u.parseURL(d);if(!y)throw new Error("Error trying to parse relative URL.");if(y.scheme)return f.alwaysNormalize?(y.path=u.normalizePath(y.path),u.buildURLFromParts(y)):d;var v=u.parseURL(c);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var T=n.exec(v.path);v.netLoc=T[1],v.path=T[2]}v.netLoc&&!v.path&&(v.path="/");var S={scheme:v.scheme,netLoc:y.netLoc,path:null,params:y.params,query:y.query,fragment:y.fragment};if(!y.netLoc&&(S.netLoc=v.netLoc,y.path[0]!=="/"))if(!y.path)S.path=v.path,y.params||(S.params=v.params,y.query||(S.query=v.query));else{var w=v.path,L=w.substring(0,w.lastIndexOf("/")+1)+y.path;S.path=u.normalizePath(L)}return S.path===null&&(S.path=f.alwaysNormalize?u.normalizePath(y.path):y.path),u.buildURLFromParts(S)},parseURL:function(c){var d=i.exec(c);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(r,"");c.length!==(c=c.replace(a,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};s.exports=u})()})(wv)),wv.exports}var i1=sU();class s1{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 ws={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class sL{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,rU(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let n;i.length===1?n=t?.byteRangeEndOffset||0:n=parseInt(i[1]),this._byteRange=[n,parseInt(i[0])+n]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[ws.AUDIO]:null,[ws.VIDEO]:null,[ws.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new s1),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=i1.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ws.AUDIO]=null,e[ws.VIDEO]=null,e[ws.AUDIOVIDEO]=null}}function an(s){return s.sn!=="initSegment"}class Av extends sL{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(Ot(e)&&Ot(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=Ot(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){var t;const i=Object.keys(this.levelkeys),n=i.length;if(n>1||n===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!Ot(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return an(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const n=t[e];n&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=n.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,r,a=!1){const{elementaryStreams:u}=this,c=u[e];if(!c){u[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:a};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,i),c.startDTS=Math.min(c.startDTS,n),c.endDTS=Math.max(c.endDTS,r)}}class nU extends sL{constructor(e,t,i,n,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.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)}}function nL(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||nL(t,e)}}function rU(s,e){const t=nL(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const ZE=Math.pow(2,32)-1,aU=[].push,rL={video:1,audio:2,id3:3,text:4};function Tn(s){return String.fromCharCode.apply(null,s)}function aL(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function hi(s,e){const t=oL(s,e);return t<0?4294967296+t:t}function JE(s,e){let t=hi(s,e);return t*=Math.pow(2,32),t+=hi(s,e+4),t}function oL(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function oU(s){const e=s.byteLength;for(let t=0;t<e;){const i=hi(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return!0;t=i>1?t+i:e}return!1}function Ai(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=hi(s,n),a=Tn(s.subarray(n+4,n+8)),u=r>1?n+r:i;if(a===e[0])if(e.length===1)t.push(s.subarray(n+8,u));else{const c=Ai(s.subarray(n+8,u),e.slice(1));c.length&&aU.apply(t,c)}n=u}return t}function lU(s){const e=[],t=s[0];let i=8;const n=hi(s,i);i+=4;let r=0,a=0;t===0?(r=hi(s,i),a=hi(s,i+4),i+=8):(r=JE(s,i),a=JE(s,i+8),i+=16),i+=2;let u=s.length+a;const c=aL(s,i);i+=2;for(let d=0;d<c;d++){let f=i;const g=hi(s,f);f+=4;const y=g&2147483647;if((g&2147483648)>>>31===1)return cs.warn("SIDX has hierarchical references (not supported)"),null;const T=hi(s,f);f+=4,e.push({referenceSize:y,subsegmentDuration:T,info:{duration:T/n,start:u,end:u+y-1}}),u+=y,f+=4,i=f}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:c,references:e}}function lL(s){const e=[],t=Ai(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],a=Ai(r,["tkhd"])[0];if(a){let u=a[0];const c=hi(a,u===0?12:20),d=Ai(r,["mdia","mdhd"])[0];if(d){u=d[0];const f=hi(d,u===0?12:20),g=Ai(r,["mdia","hdlr"])[0];if(g){const y=Tn(g.subarray(8,12)),v={soun:ws.AUDIO,vide:ws.VIDEO}[y],T=Ai(r,["mdia","minf","stbl","stsd"])[0],S=uU(T);v?(e[c]={timescale:f,type:v,stsd:S},e[v]=us({timescale:f,id:c},S)):e[c]={timescale:f,type:y,stsd:S}}}}}return Ai(s,["moov","mvex","trex"]).forEach(n=>{const r=hi(n,4),a=e[r];a&&(a.default={duration:hi(n,12),flags:hi(n,20)})}),e}function uU(s){const e=s.subarray(8),t=e.subarray(86),i=Tn(e.subarray(4,8));let n=i,r;const a=i==="enca"||i==="encv";if(a){const d=Ai(e,[i])[0].subarray(i==="enca"?28:78);Ai(d,["sinf"]).forEach(g=>{const y=Ai(g,["schm"])[0];if(y){const v=Tn(y.subarray(4,8));if(v==="cbcs"||v==="cenc"){const T=Ai(g,["frma"])[0];T&&(n=Tn(T))}}})}const u=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const c=Ai(t,["avcC"])[0];c&&c.length>3&&(n+="."+Nm(c[1])+Nm(c[2])+Nm(c[3]),r=Im(u==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=Ai(e,[i])[0],d=Ai(c.subarray(28),["esds"])[0];if(d&&d.length>7){let f=4;if(d[f++]!==3)break;f=kv(d,f),f+=2;const g=d[f++];if(g&128&&(f+=2),g&64&&(f+=d[f++]),d[f++]!==4)break;f=kv(d,f);const y=d[f++];if(y===64)n+="."+Nm(y);else break;if(f+=12,d[f++]!==5)break;f=kv(d,f);const v=d[f++];let T=(v&248)>>3;T===31&&(T+=1+((v&7)<<3)+((d[f]&224)>>5)),n+="."+T}break}case"hvc1":case"hev1":{const c=Ai(t,["hvcC"])[0];if(c&&c.length>12){const d=c[1],f=["","A","B","C"][d>>6],g=d&31,y=hi(c,2),v=(d&32)>>5?"H":"L",T=c[12],S=c.subarray(6,12);n+="."+f+g,n+="."+cU(y).toString(16).toUpperCase(),n+="."+v+T;let w="";for(let L=S.length;L--;){const O=S[L];(O||w)&&(w="."+O.toString(16).toUpperCase()+w)}n+=w}r=Im(u=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=Im(n,t)||n;break}case"vp09":{const c=Ai(t,["vpcC"])[0];if(c&&c.length>6){const d=c[4],f=c[5],g=c[6]>>4&15;n+="."+Ba(d)+"."+Ba(f)+"."+Ba(g)}break}case"av01":{const c=Ai(t,["av1C"])[0];if(c&&c.length>2){const d=c[1]>>>5,f=c[1]&31,g=c[2]>>>7?"H":"M",y=(c[2]&64)>>6,v=(c[2]&32)>>5,T=d===2&&y?v?12:10:y?10:8,S=(c[2]&16)>>4,w=(c[2]&8)>>3,L=(c[2]&4)>>2,O=c[2]&3;n+="."+d+"."+Ba(f)+g+"."+Ba(T)+"."+S+"."+w+L+O+"."+Ba(1)+"."+Ba(1)+"."+Ba(1)+"."+0,r=Im("dav1",t)}break}}return{codec:n,encrypted:a,supplemental:r}}function Im(s,e){const t=Ai(e,["dvvC"]),i=t.length?t[0]:Ai(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+Ba(n)+"."+Ba(r)}}function cU(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function kv(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function Nm(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Ba(s){return(s<10?"0":"")+s}function dU(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&uL(s,(i,n)=>{const r=i.subarray(8,24);r.some(a=>a!==0)||(cs.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${zn(r)} -> ${zn(t)}`),i.set(t,8))})}function hU(s){const e=[];return uL(s,t=>e.push(t.subarray(8,24))),e}function uL(s,e){Ai(s,["moov","trak"]).forEach(i=>{const n=Ai(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let a=Ai(r,["enca"]);const u=a.length>0;u||(a=Ai(r,["encv"])),a.forEach(c=>{const d=u?c.subarray(28):c.subarray(78);Ai(d,["sinf"]).forEach(g=>{const y=cL(g);y&&e(y,u)})})})}function cL(s){const e=Ai(s,["schm"])[0];if(e){const t=Tn(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=Ai(s,["schi","tenc"])[0];if(i)return i}}}function fU(s,e,t){const i={},n=Ai(s,["moof","traf"]);for(let r=0;r<n.length;r++){const a=n[r],u=Ai(a,["tfhd"])[0],c=hi(u,4),d=e[c];if(!d)continue;i[c]||(i[c]={start:NaN,duration:0,sampleCount:0,timescale:d.timescale,type:d.type});const f=i[c],g=Ai(a,["tfdt"])[0];if(g){const I=g[0];let j=hi(g,4);I===1&&(j===ZE?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(j*=ZE+1,j+=hi(g,8))),Ot(j)&&(!Ot(f.start)||j<f.start)&&(f.start=j)}const y=d.default,v=hi(u,0)|y?.flags;let T=y?.duration||0;v&8&&(v&2?T=hi(u,12):T=hi(u,8));const S=Ai(a,["trun"]);let w=f.start||0,L=0,O=T;for(let I=0;I<S.length;I++){const j=S[I],P=hi(j,4),G=f.sampleCount;f.sampleCount+=P;const N=j[3]&1,K=j[3]&4,k=j[2]&1,R=j[2]&2,Y=j[2]&4,z=j[2]&8;let X=8,re=P;for(N&&(X+=4),K&&P&&(!(j[X+1]&1)&&f.keyFrameIndex===void 0&&(f.keyFrameIndex=G),X+=4,k?(O=hi(j,X),X+=4):O=T,R&&(X+=4),z&&(X+=4),w+=O,L+=O,re--);re--;)k?(O=hi(j,X),X+=4):O=T,R&&(X+=4),Y&&(j[X+1]&1||f.keyFrameIndex===void 0&&(f.keyFrameIndex=f.sampleCount-(re+1),f.keyFrameStart=w),X+=4),z&&(X+=4),w+=O,L+=O;!L&&T&&(L+=T*P)}f.duration+=L}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,a=0;const u=Ai(s,["sidx"]);for(let c=0;c<u.length;c++){const d=lU(u[c]);if(d!=null&&d.references){r=Math.min(r,d.earliestPresentationTime/d.timescale);const f=d.references.reduce((g,y)=>g+y.info.duration||0,0);a=Math.max(a,f+d.earliestPresentationTime/d.timescale)}}a&&Ot(a)&&Object.keys(i).forEach(c=>{i[c].duration||(i[c].duration=a*i[c].timescale-i[c].start)})}return i}function mU(s){const e={valid:null,remainder:null},t=Ai(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function ia(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function ew(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let a=!1;return Ai(i,["moof"]).map(c=>{const d=c.byteOffset-8;Ai(c,["traf"]).map(g=>{const y=Ai(g,["tfdt"]).map(v=>{const T=v[0];let S=hi(v,4);return T===1&&(S*=Math.pow(2,32),S+=hi(v,8)),S/n})[0];return y!==void 0&&(s=y),Ai(g,["tfhd"]).map(v=>{const T=hi(v,4),S=hi(v,0)&16777215,w=(S&1)!==0,L=(S&2)!==0,O=(S&8)!==0;let I=0;const j=(S&16)!==0;let P=0;const G=(S&32)!==0;let N=8;T===r&&(w&&(N+=8),L&&(N+=4),O&&(I=hi(v,N),N+=4),j&&(P=hi(v,N),N+=4),G&&(N+=4),e.type==="video"&&(a=Ip(e.codec)),Ai(g,["trun"]).map(K=>{const k=K[0],R=hi(K,0)&16777215,Y=(R&1)!==0;let z=0;const X=(R&4)!==0,re=(R&256)!==0;let J=0;const W=(R&512)!==0;let q=0;const Z=(R&1024)!==0,te=(R&2048)!==0;let oe=0;const F=hi(K,4);let le=8;Y&&(z=hi(K,le),le+=4),X&&(le+=4);let ge=z+d;for(let Ie=0;Ie<F;Ie++){if(re?(J=hi(K,le),le+=4):J=I,W?(q=hi(K,le),le+=4):q=P,Z&&(le+=4),te&&(k===0?oe=hi(K,le):oe=oL(K,le),le+=4),e.type===ws.VIDEO){let Le=0;for(;Le<q;){const Pe=hi(i,ge);if(ge+=4,pU(a,i[ge])){const Je=i.subarray(ge,ge+Pe);n1(Je,a?2:1,s+oe/n,t)}ge+=Pe,Le+=Pe+4}}s+=J/n}}))})})}),t}function Ip(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function pU(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function n1(s,e,t,i){const n=dL(s);let r=0;r+=e;let a=0,u=0,c=0;for(;r<n.length;){a=0;do{if(r>=n.length)break;c=n[r++],a+=c}while(c===255);u=0;do{if(r>=n.length)break;c=n[r++],u+=c}while(c===255);const d=n.length-r;let f=r;if(u<d)r+=u;else if(u>d){cs.error(`Malformed SEI payload. ${u} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(n[f++]===181){const y=aL(n,f);if(f+=2,y===49){const v=hi(n,f);if(f+=4,v===1195456820){const T=n[f++];if(T===3){const S=n[f++],w=31&S,L=64&S,O=L?2+w*3:0,I=new Uint8Array(O);if(L){I[0]=S;for(let j=1;j<O;j++)I[j]=n[f++]}i.push({type:T,payloadType:a,pts:t,bytes:I})}}}}}else if(a===5&&u>16){const g=[];for(let T=0;T<16;T++){const S=n[f++].toString(16);g.push(S.length==1?"0"+S:S),(T===3||T===5||T===7||T===9)&&g.push("-")}const y=u-16,v=new Uint8Array(y);for(let T=0;T<y;T++)v[T]=n[f++];i.push({payloadType:a,pts:t,uuid:g.join(""),userData:Hr(v),userDataBytes:v})}}}function dL(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const n=e-t.length,r=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=s[a];return r}function gU(s){const e=s[0];let t="",i="",n=0,r=0,a=0,u=0,c=0,d=0;if(e===0){for(;Tn(s.subarray(d,d+1))!=="\0";)t+=Tn(s.subarray(d,d+1)),d+=1;for(t+=Tn(s.subarray(d,d+1)),d+=1;Tn(s.subarray(d,d+1))!=="\0";)i+=Tn(s.subarray(d,d+1)),d+=1;i+=Tn(s.subarray(d,d+1)),d+=1,n=hi(s,12),r=hi(s,16),u=hi(s,20),c=hi(s,24),d=28}else if(e===1){d+=4,n=hi(s,d),d+=4;const g=hi(s,d);d+=4;const y=hi(s,d);for(d+=4,a=2**32*g+y,q6(a)||(a=Number.MAX_SAFE_INTEGER,cs.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=hi(s,d),d+=4,c=hi(s,d),d+=4;Tn(s.subarray(d,d+1))!=="\0";)t+=Tn(s.subarray(d,d+1)),d+=1;for(t+=Tn(s.subarray(d,d+1)),d+=1;Tn(s.subarray(d,d+1))!=="\0";)i+=Tn(s.subarray(d,d+1)),d+=1;i+=Tn(s.subarray(d,d+1)),d+=1}const f=s.subarray(d,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:r,eventDuration:u,id:c,payload:f}}function yU(s,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(s,4),n=0,i=8;n<t;n++)r.set(e[n],i),i+=e[n].byteLength;return r}function vU(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;i=0,n=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),yU([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,a,t)}function xU(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const n=new DataView(s,i),r=bU(n);e.push(r),i+=r.size}}return e}function bU(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const r=s.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const a=s.buffer,u=zn(new Uint8Array(a,t+12,16));let c=null,d=null,f=0;if(r===0)f=28;else{const y=s.getUint32(28);if(!y||i<32+y*16)return{offset:t,size:e};c=[];for(let v=0;v<y;v++)c.push(new Uint8Array(a,t+32+v*16,16));f=32+y*16}if(!f)return{offset:t,size:e};const g=s.getUint32(f);return e-32<g?{offset:t,size:e}:(d=new Uint8Array(a,t+f+4,g),{version:r,systemId:u,kids:c,data:d,offset:t,size:e})}const hL=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Gc={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function r1(s,e){const t=Gc[e];return!!t&&!!t[s.slice(0,4)]}function Uh(s,e,t=!0){return!s.split(",").some(i=>!a1(i,e,t))}function a1(s,e,t=!0){var i;const n=Ll(t);return(i=n?.isTypeSupported(jh(s,e)))!=null?i:!1}function jh(s,e){return`${e}/mp4;codecs=${s}`}function tw(s){if(s){const e=s.substring(0,4);return Gc.video[e]}return 2}function $0(s){const e=hL();return s.split(",").reduce((t,i)=>{const r=e&&Ip(i)?9:Gc.video[i];return r?(r*2+t)/(t?3:2):(Gc.audio[i]+t)/(t?2:1)},0)}const Cv={};function TU(s,e=!0){if(Cv[s])return Cv[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let n=0;n<t.length;n++){var i;if(a1(t[n],"audio",e))return Cv[s]=t[n],t[n];if(t[n]==="mp3"&&(i=Ll(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const SU=/flac|opus|mp4a\.40\.34/i;function H0(s,e=!0){return s.replace(SU,t=>TU(t.toLowerCase(),e))}function _U(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)r1(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function s0(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(iw(s,"audio")||iw(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function iw(s,e){return r1(s,e)&&a1(s,e)}function EU(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function wU(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function sw(s){const e=Ll(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Vx(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const AU={supported:!0,powerEfficient:!0,smooth:!0},kU={supported:!1,smooth:!1,powerEfficient:!1},fL={supported:!0,configurations:[],decodingInfoResults:[AU]};function mL(s,e){return{supported:!1,configurations:e,decodingInfoResults:[kU],error:s}}function CU(s,e,t,i,n,r){const a=s.videoCodec,u=s.audioCodec?s.audioGroups:null,c=r?.audioCodec,d=r?.channels,f=d?parseInt(d):c?1/0:2;let g=null;if(u!=null&&u.length)try{u.length===1&&u[0]?g=e.groups[u[0]].channels:g=u.reduce((y,v)=>{if(v){const T=e.groups[v];if(!T)throw new Error(`Audio track group ${v} not found`);Object.keys(T.channels).forEach(S=>{y[S]=(y[S]||0)+T.channels[S]})}return y},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(y=>Ip(y))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(n,8e6))||!!g&&Ot(f)&&Object.keys(g).some(y=>parseInt(y)>f)}function pL(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(fL);const r=[],a=DU(s),u=a.length,c=LU(s,e,u>0),d=c.length;for(let f=u||1*d||1;f--;){const g={type:"media-source"};if(u&&(g.video=a[f%u]),d){g.audio=c[f%d];const y=g.audio.bitrate;g.video&&y&&(g.video.bitrate-=y)}r.push(g)}if(n){const f=navigator.userAgent;if(n.split(",").some(g=>Ip(g))&&hL())return Promise.resolve(mL(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${f})`),r))}return Promise.all(r.map(f=>{const g=IU(f);return i[g]||(i[g]=t.decodingInfo(f))})).then(f=>({supported:!f.some(g=>!g.supported),configurations:r,decodingInfoResults:f})).catch(f=>({supported:!1,configurations:r,decodingInfoResults:[],error:f}))}function DU(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=gL(s),n=s.width||640,r=s.height||480,a=s.frameRate||30,u=s.videoRange.toLowerCase();return t?t.map(c=>{const d={contentType:jh(wU(c),"video"),width:n,height:r,bitrate:i,framerate:a};return u!=="sdr"&&(d.transferFunction=u),d}):[]}function LU(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=gL(s);return n&&s.audioGroups?s.audioGroups.reduce((a,u)=>{var c;const d=u?(c=e.groups[u])==null?void 0:c.tracks:null;return d?d.reduce((f,g)=>{if(g.groupId===u){const y=parseFloat(g.channels||"");n.forEach(v=>{const T={contentType:jh(v,"audio"),bitrate:t?RU(v,r):r};y&&(T.channels=""+y),f.push(T)})}return f},a):a},[]):[]}function RU(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function gL(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function IU(s){let e="";const{audio:t,video:i}=s;if(i){const n=Vx(i.contentType);e+=`${n}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const n=Vx(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const Gx=["NONE","TYPE-0","TYPE-1",null];function NU(s){return Gx.indexOf(s)>-1}const z0=["SDR","PQ","HLG"];function OU(s){return!!s&&z0.indexOf(s)>-1}var n0={No:"",Yes:"YES",v2:"v2"};function nw(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?n0.v2:n0.Yes:n0.No}class rw{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class $h{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return aw(this._audioGroups,e)}hasSubtitleGroup(e){return aw(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function aw(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function MU(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function PU(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||z0.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&MU(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const BU=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},ks=(s,e)=>JSON.stringify(s,BU(e));function FU(s,e,t,i,n){const r=Object.keys(s),a=i?.channels,u=i?.audioCodec,c=n?.videoCodec,d=a&&parseInt(a)===2;let f=!1,g=!1,y=1/0,v=1/0,T=1/0,S=1/0,w=0,L=[];const{preferHDR:O,allowedVideoRanges:I}=PU(e,n);for(let K=r.length;K--;){const k=s[r[K]];f||(f=k.channels[2]>0),y=Math.min(y,k.minHeight),v=Math.min(v,k.minFramerate),T=Math.min(T,k.minBitrate),I.filter(Y=>k.videoRanges[Y]>0).length>0&&(g=!0)}y=Ot(y)?y:0,v=Ot(v)?v:0;const j=Math.max(1080,y),P=Math.max(30,v);T=Ot(T)?T:t,t=Math.max(T,t),g||(e=void 0);const G=r.length>1;return{codecSet:r.reduce((K,k)=>{const R=s[k];if(k===K)return K;if(L=g?I.filter(Y=>R.videoRanges[Y]>0):[],G){if(R.minBitrate>t)return Oa(k,`min bitrate of ${R.minBitrate} > current estimate of ${t}`),K;if(!R.hasDefaultAudio)return Oa(k,"no renditions with default or auto-select sound found"),K;if(u&&k.indexOf(u.substring(0,4))%5!==0)return Oa(k,`audio codec preference "${u}" not found`),K;if(a&&!d){if(!R.channels[a])return Oa(k,`no renditions with ${a} channel sound found (channels options: ${Object.keys(R.channels)})`),K}else if((!u||d)&&f&&R.channels[2]===0)return Oa(k,"no renditions with stereo sound found"),K;if(R.minHeight>j)return Oa(k,`min resolution of ${R.minHeight} > maximum of ${j}`),K;if(R.minFramerate>P)return Oa(k,`min framerate of ${R.minFramerate} > maximum of ${P}`),K;if(!L.some(Y=>R.videoRanges[Y]>0))return Oa(k,`no variants with VIDEO-RANGE of ${ks(L)} found`),K;if(c&&k.indexOf(c.substring(0,4))%5!==0)return Oa(k,`video codec preference "${c}" not found`),K;if(R.maxScore<w)return Oa(k,`max score of ${R.maxScore} < selected max of ${w}`),K}return K&&($0(k)>=$0(K)||R.fragmentError>s[K].fragmentError)?K:(S=R.minIndex,w=R.maxScore,k)},void 0),videoRanges:L,preferHDR:O,minFramerate:v,minBitrate:T,minIndex:S}}function Oa(s,e){cs.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function yL(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function UU(s,e,t,i){return s.slice(t,i+1).reduce((n,r,a)=>{if(!r.codecSet)return n;const u=r.audioGroups;let c=n[r.codecSet];c||(n[r.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!u,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,r.bitrate);const d=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,d),c.minFramerate=Math.min(c.minFramerate,r.frameRate),c.minIndex=Math.min(c.minIndex,a),c.maxScore=Math.max(c.maxScore,r.score),c.fragmentError+=r.fragmentError,c.videoRanges[r.videoRange]=(c.videoRanges[r.videoRange]||0)+1,u&&u.forEach(f=>{if(!f)return;const g=e.groups[f];g&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?g.hasDefault:g.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(g.channels).forEach(y=>{c.channels[y]=(c.channels[y]||0)+g.channels[y]}))}),n},{})}function ow(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}=s;return{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}}function Ga(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const n=e[i];if(bu(s,n,t))return i}return-1}function bu(s,e,t){const{groupId:i,name:n,lang:r,assocLang:a,default:u}=s,c=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||jU(r,e.lang))&&(r===void 0||e.assocLang===a)&&(u===void 0||e.default===u)&&(c===void 0||e.forced===c)&&(!("characteristics"in s)||$U(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function jU(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function $U(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function uu(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function HU(s,e,t,i,n){const r=e[i],u=e.reduce((y,v,T)=>{const S=v.uri;return(y[S]||(y[S]=[])).push(T),y},{})[r.uri];u.length>1&&(i=Math.max.apply(Math,u));const c=r.videoRange,d=r.frameRate,f=r.codecSet.substring(0,4),g=lw(e,i,y=>{if(y.videoRange!==c||y.frameRate!==d||y.codecSet.substring(0,4)!==f)return!1;const v=y.audioGroups,T=t.filter(S=>!v||v.indexOf(S.groupId)!==-1);return Ga(s,T,n)>-1});return g>-1?g:lw(e,i,y=>{const v=y.audioGroups,T=t.filter(S=>!v||v.indexOf(S.groupId)!==-1);return Ga(s,T,n)>-1})}function lw(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function V0(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class zU extends ra{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:n,partCurrent:r,hls:a}=this,{autoLevelEnabled:u,media:c}=a;if(!n||!c)return;const d=performance.now(),f=r?r.stats:n.stats,g=r?r.duration:n.duration,y=d-f.loading.start,v=a.minAutoLevel,T=n.level,S=this._nextAutoLevel;if(f.aborted||f.loaded&&f.loaded===f.total||T<=v){this.clearTimer(),this._nextAutoLevel=-1;return}if(!u)return;const w=S>-1&&S!==T,L=!!t||w;if(!L&&(c.paused||!c.playbackRate||!c.readyState))return;const O=a.mainForwardBufferInfo;if(!L&&O===null)return;const I=this.bwEstimator.getEstimateTTFB(),j=Math.abs(c.playbackRate);if(y<=Math.max(I,1e3*(g/(j*2))))return;const P=O?O.len/j:0,G=f.loading.first?f.loading.first-f.loading.start:-1,N=f.loaded&&G>-1,K=this.getBwEstimate(),k=a.levels,R=k[T],Y=Math.max(f.loaded,Math.round(g*(n.bitrate||R.averageBitrate)/8));let z=N?y-G:y;z<1&&N&&(z=Math.min(y,f.loaded*8/K));const X=N?f.loaded*1e3/z:0,re=I/1e3,J=X?(Y-f.loaded)/X:Y*8/K+re;if(J<=P)return;const W=X?X*8:K,q=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,Z=this.hls.config.abrBandWidthUpFactor;let te=Number.POSITIVE_INFINITY,oe;for(oe=T-1;oe>v;oe--){const Ie=k[oe].maxBitrate,Le=!k[oe].details||q;if(te=this.getTimeToLoadFrag(re,W,g*Ie,Le),te<Math.min(P,g+re))break}if(te>=J||te>g*10)return;N?this.bwEstimator.sample(y-Math.min(I,G),f.loaded):this.bwEstimator.sampleTTFB(y);const F=k[oe].maxBitrate;this.getBwEstimate()*Z>F&&this.resetEstimator(F);const le=this.findBestLevel(F,v,oe,0,P,1,1);le>-1&&(oe=le),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${T} is loading too slowly;
Fragment duration: ${n.duration.toFixed(3)}
Time to underbuffer: ${P.toFixed(3)} s
Estimated load time for current fragment: ${J.toFixed(3)} s
Estimated load time for down switch fragment: ${te.toFixed(3)} s
TTFB estimate: ${G|0} ms
Current BW estimate: ${Ot(K)?K|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${oe} @ ${F|0} bps`),a.nextLoadLevel=a.nextAutoLevel=oe,this.clearTimer();const ge=()=>{if(this.clearTimer(),this.fragCurrent===n&&this.hls.loadLevel===oe&&oe>0){const Ie=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${oe>0?"and switching down":""}
Fragment duration: ${n.duration.toFixed(3)} s
Time to underbuffer: ${Ie.toFixed(3)} s`),n.abortRequests(),this.fragCurrent=this.partCurrent=null,oe>v){let Le=this.findBestLevel(this.hls.levels[v].bitrate,v,oe,0,Ie,1,1);Le===-1&&(Le=v),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Le,this.resetEstimator(this.hls.levels[Le].bitrate)}}};w||J>te*2?ge():this.timer=self.setInterval(ge,te*1e3),a.trigger(H.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:r,stats:f})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new W6(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.FRAG_LOADING,this.onFragLoading,this),e.on(H.FRAG_LOADED,this.onFragLoaded,this),e.on(H.FRAG_BUFFERED,this.onFragBuffered,this),e.on(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(H.LEVEL_LOADED,this.onLevelLoaded,this),e.on(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(H.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.FRAG_LOADING,this.onFragLoading,this),e.off(H.FRAG_LOADED,this.onFragLoaded,this),e.off(H.FRAG_BUFFERED,this.onFragBuffered,this),e.off(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(H.LEVEL_LOADED,this.onLevelLoaded,this),e.off(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(H.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(H.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var n;this.fragCurrent=i,this.partCurrent=(n=t.part)!=null?n:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case $e.BUFFER_ADD_CODEC_ERROR:case $e.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case $e.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:n,partCurrent:r}=this;if(i&&n&&i.sn===n.sn&&i.level===n.level){const a=performance.now(),u=r?r.stats:i.stats,c=a-u.loading.start,d=u.loading.first?u.loading.first-u.loading.start:-1;if(u.loaded&&d>-1){const g=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(g,d),u.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,i,n){const r=e+i/t,a=n?e+this.lastLevelLoadSec:0;return r+a}onLevelLoaded(e,t){const i=this.hls.config,{loading:n}=t.stats,r=n.end-n.first;Ot(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const n=i?i.stats:t.stats;if(t.type===jt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:t.duration,a=this.hls.levels[t.level],u=(a.loaded?a.loaded.bytes:0)+n.loaded,c=(a.loaded?a.loaded.duration:0)+r;a.loaded={bytes:u,duration:c},a.realBitrate=Math.round(8*u/c)}if(t.bitrateTest){const r={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(H.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:n}=t,r=n!=null&&n.stats.loaded?n.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;const a=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==jt.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,n,1,1);if(r>-1)return r;const a=this.hls.firstLevel,u=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${u}`),u}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),n=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!n||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=i&&n?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,r)&&a[e].loadError<=a[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:n,config:r,minAutoLevel:a}=i,u=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),d=this.getStarvationDelay();let f=r.abrBandWidthFactor,g=r.abrBandWidthUpFactor;if(d){const w=this.findBestLevel(c,a,n,d,0,f,g);if(w>=0)return this.rebufferNotice=-1,w}let y=u?Math.min(u,r.maxStarvationDelay):r.maxStarvationDelay;if(!d){const w=this.bitrateTestDelay;w&&(y=(u?Math.min(u,r.maxLoadingDelay):r.maxLoadingDelay)-w,this.info(`bitrate test took ${Math.round(1e3*w)}ms, set first fragment max fetchDuration to ${Math.round(1e3*y)} ms`),f=g=1)}const v=this.findBestLevel(c,a,n,d,y,f,g);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${v}`)),v>-1)return v;const T=i.levels[a],S=i.loadLevelObj;return S&&T?.bitrate<S.bitrate?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,n,r,a,u){var c;const d=n+r,f=this.lastLoadedFragLevel,g=f===-1?this.hls.firstLevel:f,{fragCurrent:y,partCurrent:v}=this,{levels:T,allAudioTracks:S,loadLevel:w,config:L}=this.hls;if(T.length===1)return 0;const O=T[g],I=!!((c=this.hls.latestLevelDetails)!=null&&c.live),j=w===-1||f===-1;let P,G="SDR",N=O?.frameRate||0;const{audioPreference:K,videoPreference:k}=L,R=this.audioTracksByGroup||(this.audioTracksByGroup=yL(S));let Y=-1;if(j){if(this.firstSelection!==-1)return this.firstSelection;const W=this.codecTiers||(this.codecTiers=UU(T,R,t,i)),q=FU(W,G,e,K,k),{codecSet:Z,videoRanges:te,minFramerate:oe,minBitrate:F,minIndex:le,preferHDR:ge}=q;Y=le,P=Z,G=ge?te[te.length-1]:te[0],N=oe,e=Math.max(e,F),this.log(`picked start tier ${ks(q)}`)}else P=O?.codecSet,G=O?.videoRange;const z=v?v.duration:y?y.duration:0,X=this.bwEstimator.getEstimateTTFB()/1e3,re=[];for(let W=i;W>=t;W--){var J;const q=T[W],Z=W>g;if(!q)continue;if(L.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){const Le=navigator.mediaCapabilities;typeof Le?.decodingInfo=="function"&&CU(q,R,G,N,e,K)?(q.supportedPromise=pL(q,R,Le,this.supportedCache),q.supportedPromise.then(Pe=>{if(!this.hls)return;q.supportedResult=Pe;const Je=this.hls.levels,Se=Je.indexOf(q);Pe.error?this.warn(`MediaCapabilities decodingInfo error: "${Pe.error}" for level ${Se} ${ks(Pe)}`):Pe.supported?Pe.decodingInfoResults.some(Re=>Re.smooth===!1||Re.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${Se} not smooth or powerEfficient: ${ks(Pe)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Se} ${ks(Pe)}`),Se>-1&&Je.length>1&&(this.log(`Removing unsupported level ${Se}`),this.hls.removeLevel(Se),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Pe=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Pe}`)})):q.supportedResult=fL}if((P&&q.codecSet!==P||G&&q.videoRange!==G||Z&&N>q.frameRate||!Z&&N>0&&N<q.frameRate||(J=q.supportedResult)!=null&&(J=J.decodingInfoResults)!=null&&J.some(Le=>Le.smooth===!1))&&(!j||W!==Y)){re.push(W);continue}const te=q.details,oe=(v?te?.partTarget:te?.averagetargetduration)||z;let F;Z?F=u*e:F=a*e;const le=z&&n>=z*2&&r===0?q.averageBitrate:q.maxBitrate,ge=this.getTimeToLoadFrag(X,F,le*oe,te===void 0);if(F>=le&&(W===f||q.loadError===0&&q.fragmentError===0)&&(ge<=X||!Ot(ge)||I&&!this.bitrateTestDelay||ge<d)){const Le=this.forcedAutoLevel;return W!==w&&(Le===-1||Le!==w)&&(re.length&&this.trace(`Skipped level(s) ${re.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${T[re[0]].codecs}" ${T[re[0]].videoRange}; not compatible with "${P}" ${G}`),this.info(`switch candidate:${g}->${W} adjustedbw(${Math.round(F)})-bitrate=${Math.round(F-le)} ttfb:${X.toFixed(1)} avgDuration:${oe.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${ge.toFixed(1)} firstSelection:${j} codecSet:${q.codecSet} videoRange:${q.videoRange} hls.loadLevel:${w}`)),j&&(this.firstSelection=W),W}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const vL={search:function(s,e){let t=0,i=s.length-1,n=null,r=null;for(;t<=i;){n=(t+i)/2|0,r=s[n];const a=e(r);if(a>0)t=n+1;else if(a<0)i=n-1;else return r}return null}};function VU(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!Ot(e))return null;const i=s[0].programDateTime;if(e<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(e>=(n||0))return null;for(let r=0;r<s.length;++r){const a=s[r];if(qU(e,t,a))return a}return null}function Au(s,e,t=0,i=0,n=.005){let r=null;if(s){r=e[1+s.sn-e[0].sn]||null;const u=s.endDTS-t;u>0&&u<15e-7&&(t+=15e-7),r&&s.level!==r.level&&r.end<=s.end&&(r=e[2+s.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(r=e[0]);if(r&&((!s||s.level===r.level)&&uw(t,i,r)===0||GU(r,s,Math.min(n,i))))return r;const a=vL.search(e,uw.bind(null,t,i));return a&&(a!==s||!r)?a:r}function GU(s,e,t){if(e&&e.start===0&&e.level<s.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((n,r)=>(r[0]==="INF"&&(n+=parseFloat(r[1])),n),t);return s.start<=i}return!1}function uw(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function qU(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function xL(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments;const{fragmentHint:n}=s;n&&(i=i.concat(n));let r;return vL.search(i,a=>a.cc<e?1:a.cc>e?-1:(r=a,a.end<=t?1:a.start>t?-1:0)),r||null}return null}function G0(s){switch(s.details){case $e.FRAG_LOAD_TIMEOUT:case $e.KEY_LOAD_TIMEOUT:case $e.LEVEL_LOAD_TIMEOUT:case $e.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function bL(s){return s.details.startsWith("key")}function TL(s){return bL(s)&&!!s.frag&&!s.frag.decryptdata}function cw(s,e){const t=G0(e);return s.default[`${t?"timeout":"error"}Retry`]}function o1(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function dw(s){return us(us({},s),{errorRetry:null,timeoutRetry:null})}function q0(s,e,t,i){if(!s)return!1;const n=i?.code,r=e<s.maxNumRetry&&(KU(n)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,r):r}function KU(s){return qx(s)||!!s&&(s<400||s>499)}function qx(s){return s===0&&navigator.onLine===!1}var $n={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Fr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class WU extends ra{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(H.ERROR,this.onError,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(H.ERROR,this.onError,this),e.off(H.ERROR,this.onErrorOut,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===jt.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(a=>n.indexOf(a.groupId)>=0).some(a=>{var u;return(u=a.details)==null?void 0:u.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const n=this.hls,r=t.context;switch(t.details){case $e.FRAG_LOAD_ERROR:case $e.FRAG_LOAD_TIMEOUT:case $e.KEY_LOAD_ERROR:case $e.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case $e.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=Dc();return}case $e.FRAG_GAP:case $e.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=$n.SendAlternateToPenaltyBox;return}case $e.LEVEL_EMPTY_ERROR:case $e.LEVEL_PARSING_ERROR:{var a;const c=t.parent===jt.MAIN?t.level:n.loadLevel;t.details===$e.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case $e.LEVEL_LOAD_ERROR:case $e.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case $e.AUDIO_TRACK_LOAD_ERROR:case $e.AUDIO_TRACK_LOAD_TIMEOUT:case $e.SUBTITLE_LOAD_ERROR:case $e.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const c=n.loadLevelObj;if(c&&(r.type===Ii.AUDIO_TRACK&&c.hasAudioGroup(r.groupId)||r.type===Ii.SUBTITLE_TRACK&&c.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=$n.SendAlternateToPenaltyBox,t.errorAction.flags=Fr.MoveAllAlternatesMatchingHost;return}}return;case $e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:$n.SendAlternateToPenaltyBox,flags:Fr.MoveAllAlternatesMatchingHDCP};return;case $e.KEY_SYSTEM_SESSION_UPDATE_FAILED:case $e.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case $e.KEY_SYSTEM_NO_SESSION:t.errorAction={action:$n.SendAlternateToPenaltyBox,flags:Fr.MoveAllAlternatesMatchingKey};return;case $e.BUFFER_ADD_CODEC_ERROR:case $e.REMUX_ALLOC_ERROR:case $e.BUFFER_APPEND_ERROR:if(!t.errorAction){var u;t.errorAction=this.getLevelSwitchAction(t,(u=t.level)!=null?u:n.loadLevel)}return;case $e.INTERNAL_EXCEPTION:case $e.BUFFER_APPENDING_ERROR:case $e.BUFFER_FULL_ERROR:case $e.LEVEL_SWITCH_ERROR:case $e.BUFFER_STALLED_ERROR:case $e.BUFFER_SEEK_OVER_HOLE:case $e.BUFFER_NUDGE_ON_STALL:t.errorAction=Dc();return}t.type===Vt.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Dc())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,n=cw(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(q0(n,r,G0(e),e.response))return{action:$n.RetryRequest,flags:Fr.None,retryConfig:n,retryCount:r};const u=this.getLevelSwitchAction(e,t);return n&&(u.retryConfig=n,u.retryCount=r),u}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,u=cw(bL(e)?a:r,e),c=t.levels.reduce((f,g)=>f+g.fragmentError,0);if(n&&(e.details!==$e.FRAG_GAP&&n.fragmentError++,!TL(e)&&q0(u,c,G0(e),e.response)))return{action:$n.RetryRequest,flags:Fr.None,retryConfig:u,retryCount:c};const d=this.getLevelSwitchAction(e,i);return u&&(d.retryConfig=u,d.retryCount=c),d}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const n=this.hls.levels[t];if(n){var r,a;const d=e.details;n.loadError++,d===$e.BUFFER_APPEND_ERROR&&n.fragmentError++;let f=-1;const{levels:g,loadLevel:y,minAutoLevel:v,maxAutoLevel:T}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const S=(r=e.frag)==null?void 0:r.type,L=(S===jt.AUDIO&&d===$e.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===$e.BUFFER_ADD_CODEC_ERROR||d===$e.BUFFER_APPEND_ERROR))&&g.some(({audioCodec:G})=>n.audioCodec!==G),I=e.sourceBufferName==="video"&&(d===$e.BUFFER_ADD_CODEC_ERROR||d===$e.BUFFER_APPEND_ERROR)&&g.some(({codecSet:G,audioCodec:N})=>n.codecSet!==G&&n.audioCodec===N),{type:j,groupId:P}=(a=e.context)!=null?a:{};for(let G=g.length;G--;){const N=(G+y)%g.length;if(N!==y&&N>=v&&N<=T&&g[N].loadError===0){var u,c;const K=g[N];if(d===$e.FRAG_GAP&&S===jt.MAIN&&e.frag){const k=g[N].details;if(k){const R=Au(e.frag,k.fragments,e.frag.start);if(R!=null&&R.gap)continue}}else{if(j===Ii.AUDIO_TRACK&&K.hasAudioGroup(P)||j===Ii.SUBTITLE_TRACK&&K.hasSubtitleGroup(P))continue;if(S===jt.AUDIO&&(u=n.audioGroups)!=null&&u.some(k=>K.hasAudioGroup(k))||S===jt.SUBTITLE&&(c=n.subtitleGroups)!=null&&c.some(k=>K.hasSubtitleGroup(k))||L&&n.audioCodec===K.audioCodec||I&&n.codecSet===K.codecSet||!L&&n.codecSet!==K.codecSet)continue}f=N;break}}if(f>-1&&i.loadLevel!==f)return e.levelRetry=!0,this.playlistError=0,{action:$n.SendAlternateToPenaltyBox,flags:Fr.None,nextAutoLevel:f}}return{action:$n.SendAlternateToPenaltyBox,flags:Fr.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case $n.DoNothing:break;case $n.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==$e.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:n}=i,r=i.nextAutoLevel;switch(n){case Fr.None:this.switchLevel(e,r);break;case Fr.MoveAllAlternatesMatchingHDCP:{const c=this.getVariantLevelIndex(e.frag),d=t.levels[c],f=d?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=f,f==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(f){t.maxHdcpLevel=Gx[Gx.indexOf(f)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Fr.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const d=this.hls.levels,f=d.length;for(let y=f;y--;)if(this.variantHasKey(d[y],c)){var a,u;this.log(`Banned key found in level ${y} (${d[y].bitrate}bps) or audio group "${(a=d[y].audioGroups)==null?void 0:a.join(",")}" (${(u=e.frag)==null?void 0:u.type} fragment) ${zn(c.keyId||[])}`),d[y].fragmentError++,d[y].loadError++,this.log(`Removing level ${y} with key error (${e.error})`),this.hls.removeLevel(y)}const g=e.frag;if(this.hls.levels.length<f)i.resolved=!0;else if(g&&g.type!==jt.MAIN){const y=g.decryptdata;y&&!c.matches(y)&&(i.resolved=!0)}}break}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(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,e.details===$e.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Vx(e.mimeType),n=this.hls.levels;for(let r=n.length;r--;)n[r][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${r} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(r))}}}function Dc(s){const e={action:$n.DoNothing,flags:Fr.None};return s&&(e.resolved=!0),e}var Sn={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class YU{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&&(e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.BUFFER_APPENDED,this.onBufferAppended,this),e.on(H.FRAG_BUFFERED,this.onFragBuffered,this),e.on(H.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.BUFFER_APPENDED,this.onBufferAppended,this),e.off(H.FRAG_BUFFERED,this.onFragBuffered,this),e.off(H.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let n=i.length;n--;){const r=i[n];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:n}=this,r=Object.keys(n);for(let a=r.length;a--;){const u=n[r[a]];if(u?.body.type===t&&(!i||u.buffered)){const c=u.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,t,i,n,r){this.timeRanges&&(this.timeRanges[e]=t);const a=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(u=>{const c=this.fragments[u];if(!c||a>=c.body.sn)return;if(!c.buffered&&(!c.loaded||r)){c.body.type===i&&this.removeFragment(c.body);return}const d=c.range[e];if(d){if(d.time.length===0){this.removeFragment(c.body);return}d.time.some(f=>{const g=!this.isTimeBuffered(f.startPTS,f.endPTS,t);return g&&this.removeFragment(c.body),g})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,n=ac(i),r=this.fragments[n];if(!r||r.buffered&&i.gap)return;const a=!i.relurl;Object.keys(t).forEach(u=>{const c=i.elementaryStreams[u];if(!c)return;const d=t[u],f=a||c.partial===!0;r.range[u]=this.getBufferedTimes(i,e.part,f,d)}),r.loaded=null,Object.keys(r.range).length?(this.bufferedEnd(r,i),Om(r)||this.removeParts(i.sn-1,i.type)):this.removeFragment(r.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=hw(i,n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=ac(e);let n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}getBufferedTimes(e,t,i,n){const r={time:[],partial:i},a=e.start,u=e.end,c=e.minEndPTS||u,d=e.maxStartPTS||a;for(let f=0;f<n.length;f++){const g=n.start(f)-this.bufferPadding,y=n.end(f)+this.bufferPadding;if(d>=g&&c<=y){r.time.push({startPTS:Math.max(a,n.start(f)),endPTS:Math.min(u,n.end(f))});break}else if(a<y&&u>g){const v=Math.max(a,n.start(f)),T=Math.min(u,n.end(f));T>v&&(r.partial=!0,r.time.push({startPTS:v,endPTS:T}))}else if(u<=g)break}return r}getPartialFragment(e){let t=null,i,n,r,a=0;const{bufferPadding:u,fragments:c}=this;return Object.keys(c).forEach(d=>{const f=c[d];f&&Om(f)&&(n=f.body.start-u,r=f.body.end+u,e>=n&&e<=r&&(i=Math.min(e-n,r-e),a<=i&&(t=f.body,a=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Om(t))}getState(e){const t=ac(e),i=this.fragments[t];return i?i.buffered?Om(i)?Sn.PARTIAL:Sn.OK:Sn.APPENDING:Sn.NOT_LOADED}isTimeBuffered(e,t,i){let n,r;for(let a=0;a<i.length;a++){if(n=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,e>=n&&t<=r)return!0;if(t<=n)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,n=t.part?null:t,r=ac(i);this.fragments[r]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:n,timeRanges:r,type:a}=t;if(i.sn==="initSegment")return;const u=i.type;if(n){let d=this.activePartLists[u];d||(this.activePartLists[u]=d=[]),d.push(n)}this.timeRanges=r;const c=r[a];this.detectEvictedFragments(a,c,u,n)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ac(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let n=i.length;n--;){const r=t[i[n]];if(r?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,n,r){n&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const u=this.fragments[a];if(!u)return;const c=u.body;c.type!==i||n&&!c.gap||c.start<t&&c.end>e&&(u.buffered||r)&&this.removeFragment(c)})}removeFragment(e){const t=ac(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=hw(i,r=>r.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function Om(s){var e,t,i;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial)}function ac(s){return`${s.type}_${s.level}_${s.sn}`}function hw(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Rl={cbc:0,ctr:1};class XU{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Rl.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Rl.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function QU(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class ZU{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let n=0;n<4;n++)i[n]=t.getUint32(n*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],r=i[1],a=i[2],u=i[3],c=this.invSubMix,d=c[0],f=c[1],g=c[2],y=c[3],v=new Uint32Array(256);let T=0,S=0,w=0;for(w=0;w<256;w++)w<128?v[w]=w<<1:v[w]=w<<1^283;for(w=0;w<256;w++){let L=S^S<<1^S<<2^S<<3^S<<4;L=L>>>8^L&255^99,e[T]=L,t[L]=T;const O=v[T],I=v[O],j=v[I];let P=v[L]*257^L*16843008;n[T]=P<<24|P>>>8,r[T]=P<<16|P>>>16,a[T]=P<<8|P>>>24,u[T]=P,P=j*16843009^I*65537^O*257^T*16843008,d[L]=P<<24|P>>>8,f[L]=P<<16|P>>>16,g[L]=P<<8|P>>>24,y[L]=P,T?(T=O^v[v[v[j^O]]],S^=v[v[S]]):T=S=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,n=0;for(;n<t.length&&i;)i=t[n]===this.key[n],n++;if(i)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const a=this.ksRows=(r+6+1)*4;let u,c;const d=this.keySchedule=new Uint32Array(a),f=this.invKeySchedule=new Uint32Array(a),g=this.sBox,y=this.rcon,v=this.invSubMix,T=v[0],S=v[1],w=v[2],L=v[3];let O,I;for(u=0;u<a;u++){if(u<r){O=d[u]=t[u];continue}I=O,u%r===0?(I=I<<8|I>>>24,I=g[I>>>24]<<24|g[I>>>16&255]<<16|g[I>>>8&255]<<8|g[I&255],I^=y[u/r|0]<<24):r>6&&u%r===4&&(I=g[I>>>24]<<24|g[I>>>16&255]<<16|g[I>>>8&255]<<8|g[I&255]),d[u]=O=(d[u-r]^I)>>>0}for(c=0;c<a;c++)u=a-c,c&3?I=d[u]:I=d[u-4],c<4||u<=4?f[c]=I:f[c]=T[g[I>>>24]]^S[g[I>>>16&255]]^w[g[I>>>8&255]]^L[g[I&255]],f[c]=f[c]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const n=this.keySize+6,r=this.invKeySchedule,a=this.invSBox,u=this.invSubMix,c=u[0],d=u[1],f=u[2],g=u[3],y=this.uint8ArrayToUint32Array_(i);let v=y[0],T=y[1],S=y[2],w=y[3];const L=new Int32Array(e),O=new Int32Array(L.length);let I,j,P,G,N,K,k,R,Y,z,X,re,J,W;const q=this.networkToHostOrderSwap;for(;t<L.length;){for(Y=q(L[t]),z=q(L[t+1]),X=q(L[t+2]),re=q(L[t+3]),N=Y^r[0],K=re^r[1],k=X^r[2],R=z^r[3],J=4,W=1;W<n;W++)I=c[N>>>24]^d[K>>16&255]^f[k>>8&255]^g[R&255]^r[J],j=c[K>>>24]^d[k>>16&255]^f[R>>8&255]^g[N&255]^r[J+1],P=c[k>>>24]^d[R>>16&255]^f[N>>8&255]^g[K&255]^r[J+2],G=c[R>>>24]^d[N>>16&255]^f[K>>8&255]^g[k&255]^r[J+3],N=I,K=j,k=P,R=G,J=J+4;I=a[N>>>24]<<24^a[K>>16&255]<<16^a[k>>8&255]<<8^a[R&255]^r[J],j=a[K>>>24]<<24^a[k>>16&255]<<16^a[R>>8&255]<<8^a[N&255]^r[J+1],P=a[k>>>24]<<24^a[R>>16&255]<<16^a[N>>8&255]<<8^a[K&255]^r[J+2],G=a[R>>>24]<<24^a[N>>16&255]<<16^a[K>>8&255]<<8^a[k&255]^r[J+3],O[t]=q(I^v),O[t+1]=q(G^T),O[t+2]=q(P^S),O[t+3]=q(j^w),v=Y,T=z,S=X,w=re,t=t+4}return O.buffer}}class JU{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=ej(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function ej(s){switch(s){case Rl.cbc:return"AES-CBC";case Rl.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const tj=16;class l1{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.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?QU(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,n){return this.useSoftware?new Promise((r,a)=>{const u=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(u,t,i,n);const c=this.flush();c?r(c.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}softwareDecrypt(e,t,i,n){const{currentIV:r,currentResult:a,remainderData:u}=this;if(n!==Rl.cbc||t.byteLength!==16)return cs.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),u&&(e=ia(u,e),this.remainderData=null);const c=this.getValidChunk(e);if(!c.length)return null;r&&(i=r);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new ZU),d.expandKey(t);const f=a;return this.currentResult=d.decrypt(c.buffer,0,i),this.currentIV=c.slice(-16).buffer,f||null}webCryptoDecrypt(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new JU(this.subtle,t,n)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new XU(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(cs.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i,n)))}onWebCryptoError(e,t,i,n){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%tj;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(cs.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const fw=Math.pow(2,17);class ij{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new _o({type:Vt.NETWORK_ERROR,details:$e.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,r=n.fLoader,a=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(T=>T[0]==="GAP")){c(pw(e));return}else e.gap=!1;const d=this.loader=r?new r(n):new a(n),f=mw(e);e.loader=d;const g=dw(n.fragLoadPolicy.default),y={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:fw};e.stats=d.stats;const v={onSuccess:(T,S,w,L)=>{this.resetLoader(e,d);let O=T.data;w.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(O.slice(0,16)),O=O.slice(16)),u({frag:e,part:null,payload:O,networkDetails:L})},onError:(T,S,w,L)=>{this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:us({url:i,data:void 0},T),error:new Error(`HTTP Error ${T.code} ${T.text}`),networkDetails:w,stats:L}))},onAbort:(T,S,w)=>{this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:w,stats:T}))},onTimeout:(T,S,w)=>{this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${y.timeout}ms`),networkDetails:w,stats:T}))}};t&&(v.onProgress=(T,S,w,L)=>t({frag:e,part:null,payload:w,networkDetails:L})),d.load(f,y,v)})}loadPart(e,t,i){this.abort();const n=this.config,r=n.fLoader,a=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(pw(e,t));return}const d=this.loader=r?new r(n):new a(n),f=mw(e,t);e.loader=d;const g=dw(n.fragLoadPolicy.default),y={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:fw};t.stats=d.stats,d.load(f,y,{onSuccess:(v,T,S,w)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const L={frag:e,part:t,payload:v.data,networkDetails:w};i(L),u(L)},onError:(v,T,S,w)=>{this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:us({url:f.url,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:S,stats:w}))},onAbort:(v,T,S)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:S,stats:v}))},onTimeout:(v,T,S)=>{this.resetLoader(e,d),c(new _o({type:Vt.NETWORK_ERROR,details:$e.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${y.timeout}ms`),networkDetails:S,stats:v}))}})})}updateStatsFromPart(e,t){const i=e.stats,n=t.stats,r=n.total;if(i.loaded+=n.loaded,r){const c=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/r),c),g=(c-d)*Math.round(i.loaded/d);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const a=i.loading,u=n.loading;a.start?a.first+=u.first-u.start:(a.start=u.start,a.first=u.first),a.end=u.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function mw(s,e=null){const t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},n=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(Ot(n)&&Ot(r)){var a;let u=n,c=r;if(s.sn==="initSegment"&&sj((a=s.decryptdata)==null?void 0:a.method)){const d=r-n;d%16&&(c=r+(16-d%16)),n!==0&&(i.resetIV=!0,u=n-16)}i.rangeStart=u,i.rangeEnd=c}return i}function pw(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:Vt.MEDIA_ERROR,details:$e.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new _o(i)}function sj(s){return s==="AES-128"||s==="AES-256"}class _o extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class SL extends ra{constructor(e,t){super(e,t),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(){}}class u1{constructor(e,t,i,n=0,r=-1,a=!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=Mm(),this.buffering={audio:Mm(),video:Mm(),audiovideo:Mm()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=r,this.partial=a}}function Mm(){return{start:0,executeStart:0,executeEnd:0,end:0}}const gw={length:0,start:()=>0,end:()=>0};class gi{static isBuffered(e,t){if(e){const i=gi.getBuffered(e);for(let n=i.length;n--;)if(t>=i.start(n)&&t<=i.end(n))return!0}return!1}static bufferedRanges(e){if(e){const t=gi.getBuffered(e);return gi.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const n=gi.bufferedRanges(e);if(n.length)return gi.bufferedInfo(n,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((f,g)=>f.start-g.start||g.end-f.end);let n=-1,r=[];if(i)for(let f=0;f<e.length;f++){t>=e[f].start&&t<=e[f].end&&(n=f);const g=r.length;if(g){const y=r[g-1].end;e[f].start-y<i?e[f].end>y&&(r[g-1].end=e[f].end):r.push(e[f])}else r.push(e[f])}else r=e;let a=0,u,c=t,d=t;for(let f=0;f<r.length;f++){const g=r[f].start,y=r[f].end;if(n===-1&&t>=g&&t<=y&&(n=f),t+i>=g&&t<y)c=g,d=y,a=d-t;else if(t+i<g){u=g;break}}return{len:a,start:c||0,end:d||0,nextStart:u,buffered:e,bufferedIndex:n}}static getBuffered(e){try{return e.buffered||gw}catch(t){return cs.log("failed to get media.buffered",t),gw}}}const _L=/\{\$([a-zA-Z0-9-_]+)\}/g;function yw(s){return _L.test(s)}function Kx(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(_L,i=>{const n=i.substring(2,i.length-1),r=t?.[n];return r===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):r})}return e}function vw(s,e,t){let i=s.variableList;i||(s.variableList=i={});let n,r;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(n))r=a.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else n=e.NAME,r=e.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=r||""}function nj(s,e,t){const i=e.IMPORT;if(t&&i in t){let n=s.variableList;n||(s.variableList=n={}),n[i]=t[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const rj=/^(\d+)x(\d+)$/,xw=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Hs{constructor(e,t){typeof e=="string"&&(e=Hs.parseAttrList(e,t)),ys(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(n*2,n*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((n,r)=>(n[r.toLowerCase()]=!0,n),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=rj.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const n={};for(xw.lastIndex=0;(i=xw.exec(e))!==null;){const a=i[1].trim();let u=i[2];const c=u.indexOf('"')===0&&u.lastIndexOf('"')===u.length-1;let d=!1;if(c)u=u.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(t&&(c||d))u=Kx(t,u);else if(!d&&!c)switch(a){case"CLOSED-CAPTIONS":if(u==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":cs.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=u}return n}}const aj="com.apple.hls.interstitial";function oj(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function lj(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class EL{constructor(e,t,i=0){var n;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(n=t?.tagOrder)!=null?n:i,t){const r=t.attr;for(const a in r)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==r[a]){cs.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=ys(new Hs({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=t?.endDate||new Date(this.attr["END-DATE"]);Ot(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(cs.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Ot(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 isInterstitial(){return this.class===aj}get isValid(){return!!this.id&&!this._badValueForSameId&&Ot(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const uj=10;class cj{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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?Ot(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||uj}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(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start: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 maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function K0(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function bw(s,e){return!s&&!e?!0:!s||!e?!1:K0(s,e)}function Lc(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function c1(s){switch(s){case"AES-128":case"AES-256":return Rl.cbc;case"AES-256-CTR":return Rl.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function d1(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Wx(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function dj(s){const e=Wx(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function wL(s){const e=function(i,n,r){const a=i[n];i[n]=i[r],i[r]=a};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function AL(s){const e=s.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const r=n[0]==="base64",a=n[1];r?(i.splice(-1,1),t=d1(a)):t=dj(a)}}return t}const W0=typeof self<"u"?self:void 0;var zs={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Vn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function r0(s){switch(s){case Vn.FAIRPLAY:return zs.FAIRPLAY;case Vn.PLAYREADY:return zs.PLAYREADY;case Vn.WIDEVINE:return zs.WIDEVINE;case Vn.CLEARKEY:return zs.CLEARKEY}}function Dv(s){switch(s){case zs.FAIRPLAY:return Vn.FAIRPLAY;case zs.PLAYREADY:return Vn.PLAYREADY;case zs.WIDEVINE:return Vn.WIDEVINE;case zs.CLEARKEY:return Vn.CLEARKEY}}function ph(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[zs.FAIRPLAY,zs.WIDEVINE,zs.PLAYREADY,zs.CLEARKEY].filter(n=>!!e[n]):[];return!i[zs.WIDEVINE]&&t&&i.push(zs.WIDEVINE),i}const kL=(function(s){return W0!=null&&(s=W0.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function hj(s,e,t,i){let n;switch(s){case zs.FAIRPLAY:n=["cenc","sinf"];break;case zs.WIDEVINE:case zs.PLAYREADY:n=["cenc"];break;case zs.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return fj(n,e,t,i)}function fj(s,e,t,i){return[{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:`audio/mp4; codecs=${r}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:`video/mp4; codecs=${r}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function mj(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function CL(s){const e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const u=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(u){const c=d1(u).subarray(0,16);return wL(c),c}}return null}let oc={};class kl{static clearKeyUriToKeyIdMap(){oc={}}static setKeyIdForUri(e,t){oc[e]=t}static addKeyIdForUri(e){const t=Object.keys(oc).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),oc[e]=i,i}constructor(e,t,i,n=[1],r=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Lc(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(iL(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&K0(e.keyFormatVersions,this.keyFormatVersions)&&bw(e.iv,this.iv)&&bw(e.keyId,this.keyId)}isSupported(){if(this.method){if(Lc(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Vn.FAIRPLAY:case Vn.WIDEVINE:case Vn.PLAYREADY:case Vn.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Lc(this.method)){let r=this.iv;return r||(typeof e!="number"&&(cs.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),r=gj(e)),new kl(this.method,this.uri,"identity",this.keyFormatVersions,r)}if(this.keyId){const r=oc[this.uri];if(r&&!K0(this.keyId,r)&&kl.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=AL(this.uri);if(i)switch(this.keyFormat){case Vn.WIDEVINE:if(this.pssh=i,!this.keyId){const r=xU(i.buffer);if(r.length){var n;const a=r[0];this.keyId=(n=a.kids)!=null&&n.length?a.kids[0]:null}}this.keyId||(this.keyId=Tw(t));break;case Vn.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=vU(r,null,i),this.keyId=CL(i);break}default:{let r=i.subarray(0,16);if(r.length!==16){const a=new Uint8Array(16);a.set(r,16-r.length),r=a}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r;r=pj(t),r||(r=Tw(t),r||(r=oc[this.uri])),r&&(this.keyId=r,kl.setKeyIdForUri(this.uri,r))}return this}}function pj(s){const e=s?.[Vn.WIDEVINE];return e?e.keyId:null}function Tw(s){const e=s?.[Vn.PLAYREADY];if(e){const t=AL(e.uri);if(t)return CL(t)}return null}function gj(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const Sw=/#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,_w=/#EXT-X-MEDIA:(.*)/g,yj=/^#EXT(?:INF|-X-TARGETDURATION):/m,Lv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),vj=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class qa{static findGroup(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(n.id===t)return n}}static resolve(e,t){return i1.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return yj.test(e)}static parseMasterPlaylist(e,t){const i=yw(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];if(Sw.lastIndex=0,!e.startsWith("#EXTM3U"))return n.playlistParsingError=new Error("no EXTM3U delimiter"),n;let a;for(;(a=Sw.exec(e))!=null;)if(a[1]){var u;const d=new Hs(a[1],n),f=Kx(n,a[2]),g={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:qa.resolve(f,t)},y=d.decimalResolution("RESOLUTION");y&&(g.width=y.width,g.height=y.height),Aw(d.CODECS,g);const v=d["SUPPLEMENTAL-CODECS"];v&&(g.supplemental={},Aw(v,g.supplemental)),(u=g.unknownCodecs)!=null&&u.length||r.push(g),n.levels.push(g)}else if(a[3]){const d=a[3],f=a[4];switch(d){case"SESSION-DATA":{const g=new Hs(f,n),y=g["DATA-ID"];y&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[y]=g);break}case"SESSION-KEY":{const g=Ew(f,t,n);g.encrypted&&g.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(g)):cs.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${f}"`);break}case"DEFINE":{{const g=new Hs(f,n);vw(n,g,t)}break}case"CONTENT-STEERING":{const g=new Hs(f,n);n.contentSteering={uri:qa.resolve(g["SERVER-URI"],t),pathwayId:g["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=ww(f);break}}}const c=r.length>0&&r.length<n.levels.length;return n.levels=c?r:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,i){let n;const r={},a=i.levels,u={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(_w.lastIndex=0;(n=_w.exec(e))!==null;){const d=new Hs(n[1],i),f=d.TYPE;if(f){const g=u[f],y=r[f]||[];r[f]=y;const v=d.LANGUAGE,T=d["ASSOC-LANGUAGE"],S=d.CHANNELS,w=d.CHARACTERISTICS,L=d["INSTREAM-ID"],O={attrs:d,bitrate:0,id:c++,groupId:d["GROUP-ID"]||"",name:d.NAME||v||"",type:f,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:v,url:d.URI?qa.resolve(d.URI,t):""};if(T&&(O.assocLang=T),S&&(O.channels=S),w&&(O.characteristics=w),L&&(O.instreamId=L),g!=null&&g.length){const I=qa.findGroup(g,O.groupId)||g[0];kw(O,I,"audioCodec"),kw(O,I,"textCodec")}y.push(O)}}return r}static parseLevelPlaylist(e,t,i,n,r,a){var u;const c={url:t},d=new cj(t),f=d.fragments,g=[];let y=null,v=0,T=0,S=0,w=0,L=0,O=null,I=new Av(n,c),j,P,G,N=-1,K=!1,k=null,R;if(Lv.lastIndex=0,d.m3u8=e,d.hasVariableRefs=yw(e),((u=Lv.exec(e))==null?void 0:u[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(j=Lv.exec(e))!==null;){K&&(K=!1,I=new Av(n,c),I.playlistOffset=S,I.setStart(S),I.sn=v,I.cc=w,L&&(I.bitrate=L),I.level=i,y&&(I.initSegment=y,y.rawProgramDateTime&&(I.rawProgramDateTime=y.rawProgramDateTime,y.rawProgramDateTime=null),k&&(I.setByteRange(k),k=null)));const re=j[1];if(re){I.duration=parseFloat(re);const J=(" "+j[2]).slice(1);I.title=J||null,I.tagList.push(J?["INF",re,J]:["INF",re])}else if(j[3]){if(Ot(I.duration)){I.playlistOffset=S,I.setStart(S),G&&Dw(I,G,d),I.sn=v,I.level=i,I.cc=w,f.push(I);const J=(" "+j[3]).slice(1);I.relurl=Kx(d,J),Yx(I,O,g),O=I,S+=I.duration,v++,T=0,K=!0}}else{if(j=j[0].match(vj),!j){cs.warn("No matches on slow regex match for level playlist!");continue}for(P=1;P<j.length&&j[P]===void 0;P++);const J=(" "+j[P]).slice(1),W=(" "+j[P+1]).slice(1),q=j[P+2]?(" "+j[P+2]).slice(1):null;switch(J){case"BYTERANGE":O?I.setByteRange(W,O):I.setByteRange(W);break;case"PROGRAM-DATE-TIME":I.rawProgramDateTime=W,I.tagList.push(["PROGRAM-DATE-TIME",W]),N===-1&&(N=f.length);break;case"PLAYLIST-TYPE":d.type&&vo(d,J,j),d.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":d.startSN!==0?vo(d,J,j):f.length>0&&Lw(d,J,j),v=d.startSN=parseInt(W);break;case"SKIP":{d.skippedSegments&&vo(d,J,j);const Z=new Hs(W,d),te=Z.decimalInteger("SKIPPED-SEGMENTS");if(Ot(te)){d.skippedSegments+=te;for(let F=te;F--;)f.push(null);v+=te}const oe=Z.enumeratedString("RECENTLY-REMOVED-DATERANGES");oe&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(oe.split(" ")));break}case"TARGETDURATION":d.targetduration!==0&&vo(d,J,j),d.targetduration=Math.max(parseInt(W),1);break;case"VERSION":d.version!==null&&vo(d,J,j),d.version=parseInt(W);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":d.live||vo(d,J,j),d.live=!1;break;case"#":(W||q)&&I.tagList.push(q?[W,q]:[W]);break;case"DISCONTINUITY":w++,I.tagList.push(["DIS"]);break;case"GAP":I.gap=!0,I.tagList.push([J]);break;case"BITRATE":I.tagList.push([J,W]),L=parseInt(W)*1e3,Ot(L)?I.bitrate=L:L=0;break;case"DATERANGE":{const Z=new Hs(W,d),te=new EL(Z,d.dateRanges[Z.ID],d.dateRangeTagCount);d.dateRangeTagCount++,te.isValid||d.skippedSegments?d.dateRanges[te.id]=te:cs.warn(`Ignoring invalid DATERANGE tag: "${W}"`),I.tagList.push(["EXT-X-DATERANGE",W]);break}case"DEFINE":{{const Z=new Hs(W,d);"IMPORT"in Z?nj(d,Z,a):vw(d,Z,t)}break}case"DISCONTINUITY-SEQUENCE":d.startCC!==0?vo(d,J,j):f.length>0&&Lw(d,J,j),d.startCC=w=parseInt(W);break;case"KEY":{const Z=Ew(W,t,d);if(Z.isSupported()){if(Z.method==="NONE"){G=void 0;break}G||(G={});const te=G[Z.keyFormat];te!=null&&te.matches(Z)||(te&&(G=ys({},G)),G[Z.keyFormat]=Z)}else cs.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${W}"`);break}case"START":d.startTimeOffset=ww(W);break;case"MAP":{const Z=new Hs(W,d);if(I.duration){const te=new Av(n,c);Cw(te,Z,i,G),y=te,I.initSegment=y,y.rawProgramDateTime&&!I.rawProgramDateTime&&(I.rawProgramDateTime=y.rawProgramDateTime)}else{const te=I.byteRangeEndOffset;if(te){const oe=I.byteRangeStartOffset;k=`${te-oe}@${oe}`}else k=null;Cw(I,Z,i,G),y=I,K=!0}y.cc=w;break}case"SERVER-CONTROL":{R&&vo(d,J,j),R=new Hs(W),d.canBlockReload=R.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=R.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&R.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=R.optionalFloat("PART-HOLD-BACK",0),d.holdBack=R.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{d.partTarget&&vo(d,J,j);const Z=new Hs(W);d.partTarget=Z.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Z=d.partList;Z||(Z=d.partList=[]);const te=T>0?Z[Z.length-1]:void 0,oe=T++,F=new Hs(W,d),le=new nU(F,I,c,oe,te);Z.push(le),I.duration+=le.duration;break}case"PRELOAD-HINT":{const Z=new Hs(W,d);d.preloadHint=Z;break}case"RENDITION-REPORT":{const Z=new Hs(W,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push(Z);break}default:cs.warn(`line parsed but not handled: ${j}`);break}}}O&&!O.relurl?(f.pop(),S-=O.duration,d.partList&&(d.fragmentHint=O)):d.partList&&(Yx(I,O,g),I.cc=w,d.fragmentHint=I,G&&Dw(I,G,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));const Y=f.length,z=f[0],X=f[Y-1];if(S+=d.skippedSegments*d.targetduration,S>0&&Y&&X){d.averagetargetduration=S/Y;const re=X.sn;d.endSN=re!=="initSegment"?re:0,d.live||(X.endList=!0),N>0&&(bj(f,N),z&&g.unshift(z))}return d.fragmentHint&&(S+=d.fragmentHint.duration),d.totalduration=S,g.length&&d.dateRangeTagCount&&z&&DL(g,d),d.endCC=w,d}}function DL(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){const u=e.fragments[e.fragments.length-1];s.push(u),t++}else return;const i=s[t-1],n=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let u=r.length;u--;){const c=e.dateRanges[r[u]],d=c.startDate.getTime();c.tagAnchor=i.ref;for(let f=t;f--;){var a;if(((a=s[f])==null?void 0:a.sn)<e.startSN)break;const g=xj(e,d,s,f,n);if(g!==-1){c.tagAnchor=e.fragments[g].ref;break}}}}function xj(s,e,t,i,n){const r=t[i];if(r){const u=r.programDateTime;if(e>=u||i===0){var a;const c=(((a=t[i+1])==null?void 0:a.start)||n)-r.start;if(e<=u+c*1e3){const d=t[i].sn-s.startSN;if(d<0)return-1;const f=s.fragments;if(f.length>t.length){const y=(t[i+1]||f[f.length-1]).sn-s.startSN;for(let v=y;v>d;v--){const T=f[v].programDateTime;if(e>=T&&e<T+f[v].duration*1e3)return v}}return d}}}return-1}function Ew(s,e,t){var i,n;const r=new Hs(s,t),a=(i=r.METHOD)!=null?i:"",u=r.URI,c=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,f=(n=r.KEYFORMAT)!=null?n:"identity";u&&r.IV&&!c&&cs.error(`Invalid IV: ${r.IV}`);const g=u?qa.resolve(u,e):"",y=(d||"1").split("/").map(Number).filter(Number.isFinite);return new kl(a,g,f,y,c,r.KEYID)}function ww(s){const t=new Hs(s).decimalFloatingPoint("TIME-OFFSET");return Ot(t)?t:null}function Aw(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const n=t.filter(r=>r1(r,i));n.length&&(e[`${i}Codec`]=n.map(r=>r.split("/")[0]).join(","),t=t.filter(r=>n.indexOf(r)===-1))}),e.unknownCodecs=t}function kw(s,e,t){const i=e[t];i&&(s[t]=i)}function bj(s,e){let t=s[e];for(let i=e;i--;){const n=s[i];if(!n)return;n.programDateTime=t.programDateTime-n.duration*1e3,t=n}}function Yx(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function Cw(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function Dw(s,e,t){s.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(n=>e[n].isCommonEncryption)&&i.push(s)}function vo(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Lw(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Rv(s,e){const t=e.startPTS;if(Ot(t)){let i=0,n;e.sn>s.sn?(i=t-s.start,n=s):(i=s.start-t,n=e),n.duration!==i&&n.setDuration(i)}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0))}function LL(s,e,t,i,n,r,a){i-t<=0&&(a.warn("Fragment should have a positive duration",e),i=t+e.duration,r=n+e.duration);let c=t,d=i;const f=e.startPTS,g=e.endPTS;if(Ot(f)){const L=Math.abs(f-t);s&&L>s.totalduration?a.warn(`media timestamps and playlist times differ by ${L}s for level ${e.level} ${s.url}`):Ot(e.deltaPTS)?e.deltaPTS=Math.max(L,e.deltaPTS):e.deltaPTS=L,c=Math.max(t,f),t=Math.min(t,f),n=e.startDTS!==void 0?Math.min(n,e.startDTS):n,d=Math.min(i,g),i=Math.max(i,g),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const y=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=c,e.startDTS=n,e.endPTS=i,e.minEndPTS=d,e.endDTS=r;const v=e.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let T;const S=v-s.startSN,w=s.fragments;for(w[S]=e,T=S;T>0;T--)Rv(w[T],w[T-1]);for(T=S;T<w.length-1;T++)Rv(w[T],w[T+1]);return s.fragmentHint&&Rv(w[w.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,y}function Tj(s,e,t){if(s===e)return;let i=null;const n=s.fragments;for(let f=n.length-1;f>=0;f--){const g=n[f].initSegment;if(g){i=g;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r;Ej(s,e,(f,g,y,v)=>{if((!e.startCC||e.skippedSegments)&&g.cc!==f.cc){const T=f.cc-g.cc;for(let S=y;S<v.length;S++)v[S].cc+=T;e.endCC=v[v.length-1].cc}Ot(f.startPTS)&&Ot(f.endPTS)&&(g.setStart(g.startPTS=f.startPTS),g.startDTS=f.startDTS,g.maxStartPTS=f.maxStartPTS,g.endPTS=f.endPTS,g.endDTS=f.endDTS,g.minEndPTS=f.minEndPTS,g.setDuration(f.endPTS-f.startPTS),g.duration&&(r=g),e.PTSKnown=e.alignedSliding=!0),f.hasStreams&&(g.elementaryStreams=f.elementaryStreams),g.loader=f.loader,f.hasStats&&(g.stats=f.stats),f.initSegment&&(g.initSegment=f.initSegment,i=f.initSegment)});const a=e.fragments,u=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&u.forEach(f=>{var g;f&&(!f.initSegment||f.initSegment.relurl===((g=i)==null?void 0:g.relurl))&&(f.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(f=>!f),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=e.skippedSegments;f--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=Sj(s.dateRanges,e,t));const f=s.fragments.filter(g=>g.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let g=1;g<u.length;g++)u[g].programDateTime===null&&Yx(u[g],u[g-1],f);DL(f,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var c;const f=NL(s,e.startSN-1);e.startCC=(c=f?.cc)!=null?c:a[0].cc}_j(s.partList,e.partList,(f,g)=>{g.elementaryStreams=f.elementaryStreams,g.stats=f.stats}),r?LL(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):RL(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const d=e.advancedDateTime;if(e.advanced&&d){const f=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=f),e.driftEndTime=d,e.driftEnd=f}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled)}function Sj(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:n}=e,r=ys({},s);n&&n.forEach(c=>{delete r[c]});const u=Object.keys(r).length;return u?(Object.keys(i).forEach(c=>{const d=r[c],f=new EL(i[c].attr,d);f.isValid?(r[c]=f,d||(f.tagOrder+=u)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${ks(i[c].attr)}"`)}),r):i}function _j(s,e,t){if(s&&e){let i=0;for(let n=0,r=s.length;n<=r;n++){const a=s[n],u=e[n+i];a&&u&&a.index===u.index&&a.fragment.sn===u.fragment.sn?t(a,u):i--}}}function Ej(s,e,t){const i=e.skippedSegments,n=Math.max(s.startSN,e.startSN)-e.startSN,r=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,c=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let d=n;d<=r;d++){const f=c[a+d];let g=u[d];if(i&&!g&&f&&(g=e.fragments[d]=f),f&&g){t(f,g,d,u);const y=f.relurl,v=g.relurl;if(y&&wj(y,v)){e.playlistParsingError=Rw(`media sequence mismatch ${g.sn}:`,s,e,f,g);return}else if(f.cc!==g.cc){e.playlistParsingError=Rw(`discontinuity sequence mismatch (${f.cc}!=${g.cc})`,s,e,f,g);return}}}}function Rw(s,e,t,i,n){return new Error(`${s} ${n.url}
Playlist starting @${e.startSN}
${e.m3u8}
Playlist starting @${t.startSN}
${t.m3u8}`)}function RL(s,e,t=!0){const i=e.startSN+e.skippedSegments-s.startSN,n=s.fragments,r=i>=0;let a=0;if(r&&i<n.length)a=n[i].start;else if(r&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(r&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;Xx(e,a)}function Xx(s,e){if(e){const t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e)}}function IL(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){const i=s.fragments;if(i.length&&t*4>e){const r=i[i.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function NL(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function Iw(s,e,t){return s?OL(s.partList,e,t):null}function OL(s,e,t){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===t&&n.fragment.sn===e)return n}return null}function ML(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(n=>{n.level=t,n.initSegment&&(n.initSegment.level=t)})})}function wj(s,e){return s!==e&&e?Nw(s)!==Nw(e):!1}function Nw(s){return s.replace(/\?[^?]*$/,"")}function Dh(s,e){for(let i=0,n=s.length;i<n;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function Aj(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function Ow(s,e){const t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration}function PL(s,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)Ow(t[i],s);e.fragmentHint&&Ow(e.fragmentHint,s),e.alignedSliding=!0}function kj(s,e){s&&(BL(e,s),e.alignedSliding||Y0(e,s),!e.alignedSliding&&!e.skippedSegments&&RL(s,e,!1))}function BL(s,e){if(!Aj(e,s))return;const t=Math.min(e.endCC,s.endCC),i=Dh(e.fragments,t),n=Dh(s.fragments,t);if(!i||!n)return;cs.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-n.start;PL(r,s)}function Y0(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;const t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;let n,r;const a=Math.min(e.endCC,s.endCC);e.startCC<a&&s.startCC<a&&(n=Dh(i,a),r=Dh(t,a)),(!n||!r)&&(n=i[Math.floor(i.length/2)],r=Dh(t,n.cc)||t[Math.floor(t.length/2)]);const u=n.programDateTime,c=r.programDateTime;if(!u||!c)return;const d=(c-u)/1e3-(r.start-n.start);PL(d,s)}function sr(s,e,t){br(s,e,t),s.addEventListener(e,t)}function br(s,e,t){s.removeEventListener(e,t)}const Cj={toString:function(s){let e="";const t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},ot={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 h1 extends SL{constructor(e,t,i,n,r){super(n,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=ot.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.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.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:a,fragCurrent:u,media:c,mediaBuffer:d,state:f}=this,g=c?c.currentTime:0,y=gi.bufferInfo(d||c,g,a.maxBufferHole),v=!y.len;if(this.log(`Media seeking to ${Ot(g)?g.toFixed(3):g}, state: ${f}, ${v?"out of":"in"} buffer`),this.state===ot.ENDED)this.resetLoadingState();else if(u){const T=a.maxFragLookUpTolerance,S=u.start-T,w=u.start+u.duration+T;if(v||w<y.start||S>y.end){const L=g>w;(g<S||L)&&(L&&u.loader&&(this.log(`Cancelling fragment load for seek (sn: ${u.sn})`),u.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(g,1/0,this.playlistType,!0);const T=this.lastCurrentTime;if(g>T&&(this.lastCurrentTime=g),!this.loadingParts){const S=Math.max(y.end,g),w=this.shouldLoadParts(this.getLevelDetails(),S);w&&(this.log(`LL-Part loading ON after seeking to ${g.toFixed(2)} with buffer @${S.toFixed(2)}`),this.loadingParts=w)}}this.hls.hasEnoughToStart||(this.log(`Setting ${v?"startPosition":"nextLoadPosition"} to ${g} for seek without enough to start`),this.nextLoadPosition=g,v&&(this.startPosition=g)),v&&this.state===ot.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new ij(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new l1(e.config)}registerListeners(){const{hls:e}=this;e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(H.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===ot.STOPPED)return;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=ot.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=gi.bufferedInfo(r,e.start,0));const a=e.nextStart;if(a&&a>n&&a<t.edge||this.media.currentTime<e.start)return!1;const c=t.partList;if(c!=null&&c.length){const f=c[c.length-1];return gi.isBuffered(this.media,f.start+f.duration/2)}const d=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;sr(i,"seeking",this.onMediaSeeking),sr(i,"ended",this.onMediaEnded);const n=this.config;this.levels&&n.autoStartLoad&&this.state===ot.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,n=this.media;if(n!==null){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),br(n,"seeking",this.onMediaSeeking),br(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=ot.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const n=r=>{const a=r.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(a,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,n).then(r=>{if(!r)return;const a=this.state,u=r.frag;if(this.fragContextChanged(u)){(a===ot.FRAG_LOADING||!this.fragCurrent&&a===ot.PARSING)&&(this.fragmentTracker.removeFragment(u),this.state=ot.IDLE);return}"payload"in r&&(this.log(`Loaded ${u.type} sn: ${u.sn} of ${this.playlistLabel()} ${u.level}`),this.hls.trigger(H.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===ot.STOPPED||this.state===ot.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Sn.APPENDING){const r=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,r),u=Math.max(e.duration,a?a.len:this.config.maxBufferLength),c=this.backtrackFragment;((c?e.sn-c.sn:0)===1||this.reduceMaxBufferLength(u,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Sn.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const n={startOffset:e,endOffset:t,type:i};this.hls.trigger(H.BUFFER_FLUSHING,n)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const n=i?.frag;if(!n||this.fragContextChanged(n)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:n}=this,{frag:r,payload:a}=i,u=r.decryptdata;if(a&&a.byteLength>0&&u!=null&&u.key&&u.iv&&Lc(u.method)){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),u.key.buffer,u.iv.buffer,c1(u.method)).catch(d=>{throw n.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:r}),d}).then(d=>{const f=self.performance.now();return n.trigger(H.FRAG_DECRYPTED,{frag:r,payload:d,stats:{tstart:c,tdecrypt:f}}),i.payload=d,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===ot.STOPPED||this.state===ot.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==ot.STOPPED&&(this.state=ot.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,n;const r=e.tracks;if(r&&!t.encrypted&&((i=r.audio)!=null&&i.encrypted||(n=r.video)!=null&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,u=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(u.message),!a||a.mediaKeys?!1:(this.hls.trigger(H.ERROR,{type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_NO_KEYS,fatal:!1,error:u,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?Cj.toString(gi.getBuffered(i)):"(detached)"})`),an(e)){var n;if(e.type!==jt.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(u=>!!a[u])){this.state=ot.IDLE;return}}const r=(n=this.levels)==null?void 0:n[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=ot.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:r}=e,a=!r||r.length===0||r.some(c=>!c),u=new u1(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!a);t.flush(u)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var r;this.fragCurrent=e;const a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let u=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=ot.KEY_LOADING,this.fragCurrent=e,u=this.keyLoader.load(e).then(y=>{if(!this.fragContextChanged(y.frag))return this.hls.trigger(H.KEY_LOADED,y),this.state===ot.KEY_LOADING&&(this.state=ot.IDLE),y}),this.hls.trigger(H.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(u=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),u&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(an(e)&&(!c||e.sn!==c.sn)){const y=this.shouldLoadParts(t.details,e.end);y!==this.loadingParts&&(this.log(`LL-Part loading ${y?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=y)}if(i=Math.max(e.start,i||0),this.loadingParts&&an(e)){const y=a.partList;if(y&&n){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);const v=this.getNextPart(y,e,i);if(v>-1){const T=y[v];e=this.fragCurrent=T.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${T.index} (${v}/${y.length-1}) of ${this.fragInfo(e,!1,T)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=T.start+T.duration,this.state=ot.FRAG_LOADING;let S;return u?S=u.then(w=>!w||this.fragContextChanged(w.frag)?null:this.doFragPartsLoad(e,T,t,n)).catch(w=>this.handleFragLoadError(w)):S=this.doFragPartsLoad(e,T,t,n).catch(w=>this.handleFragLoadError(w)),this.hls.trigger(H.FRAG_LOADING,{frag:e,part:T,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):S}else if(!e.url||this.loadedEndOfParts(y,i))return Promise.resolve(null)}}if(an(e)&&this.loadingParts){var d;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(d=a.partList)==null?void 0:d.filter(y=>y.loaded).map(y=>`[${y.start}-${y.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),Ot(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ot.FRAG_LOADING;const f=this.config.progressive&&e.type!==jt.SUBTITLE;let g;return f&&u?g=u.then(y=>!y||this.fragContextChanged(y.frag)?null:this.fragmentLoader.load(e,n)).catch(y=>this.handleFragLoadError(y)):g=Promise.all([this.fragmentLoader.load(e,f?n:void 0),u]).then(([y])=>(!f&&n&&n(y),y)).catch(y=>this.handleFragLoadError(y)),this.hls.trigger(H.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g}doFragPartsLoad(e,t,i,n){return new Promise((r,a)=>{var u;const c=[],d=(u=i.details)==null?void 0:u.partList,f=g=>{this.fragmentLoader.loadPart(e,g,n).then(y=>{c[g.index]=y;const v=y.part;this.hls.trigger(H.FRAG_LOADED,y);const T=Iw(i.details,e.sn,g.index+1)||OL(d,e.sn,g.index+1);if(T)f(T);else return r({frag:e,part:v,partsLoaded:c})}).catch(a)};f(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===$e.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Vt.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(H.ERROR,t)}else this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==ot.PARSING){!this.fragCurrent&&this.state!==ot.STOPPED&&this.state!==ot.ERROR&&(this.state=ot.IDLE);return}const{frag:i,part:n,level:r}=t,a=self.performance.now();i.stats.parsing.end=a,n&&(n.stats.parsing.end=a);const u=this.getLevelDetails(),d=u&&i.sn>u.endSN||this.shouldLoadParts(u,i.end);d!==this.loadingParts&&(this.log(`LL-Part loading ${d?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=d),this.updateLevelTiming(i,n,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const r=e.partList[0];if(r.fragment.type===jt.SUBTITLE)return!1;const a=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var n;if((this.hls.hasEnoughToStart?((n=this.media)==null?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:n,sn:r,part:a}=e;if(!(t!=null&&t[n]))return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;const u=t[n],c=u.details,d=a>-1?Iw(c,r,a):null,f=d?d.fragment:NL(c,r,i);return f?(i&&i!==f&&(f.stats=i.stats),{frag:f,part:d,level:u}):null}bufferFragmentData(e,t,i,n,r){if(this.state!==ot.PARSING)return;const{data1:a,data2:u}=e;let c=a;if(u&&(c=ia(a,u)),!c.length)return;const d=this.initPTS[t.cc],f=d?-d.baseTime/d.timescale:void 0,g={type:e.type,frag:t,part:i,chunkMeta:n,offset:f,parent:t.type,data:c};if(this.hls.trigger(H.BUFFER_APPENDING,g),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!gi.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=gi.bufferInfo(t,i,0),r=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),u=Math.max(Math.min(e.start-a,n.end-a),i+a);e.start-u>a&&this.flushMainBuffer(u,e.start)}getFwdBufferInfo(e,t){var i;const n=this.getLoadPosition();if(!Ot(n))return null;const a=this.lastCurrentTime>n||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}getFwdBufferInfoAtPos(e,t,i,n){const r=gi.bufferInfo(e,t,n);if(r.len===0&&r.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(r.nextStart<=a.end||a.gap)){const u=Math.max(Math.min(r.nextStart,a.end)-t,n);return gi.bufferInfo(e,t,u)}}return r}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),r=Math.max(e-t*3,i.maxMaxBufferLength/2,n);return r>=n?(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=jt.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,n=i.length;if(!n)return null;const{config:r}=this,a=i[0].start,u=r.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const g=r.initialLiveManifestSize;if(n<g)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${g})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var d;u&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const y=this.hls.startPosition,v=this.hls.liveSyncPosition,T=c?(y!==-1&&y>=a?y:v)||c.start:e;this.log(`Setting startPosition to ${T} to match start frag at live edge. mainStart: ${y} liveSyncPosition: ${v} frag.start: ${(d=c)==null?void 0:d.start}`),this.startPosition=this.nextLoadPosition=T}}else e<=a&&(c=i[0]);if(!c){const g=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,g,t)}let f=this.filterReplacedPrimary(c,t);if(!f&&c){const g=c.sn-t.startSN;f=this.filterReplacedPrimary(i[g+1]||null,t)}return this.mapToInitFragWhenRequired(f)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Sn.OK||i===Sn.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,r){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){const u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(u!==null&&i.len+u.len>=r){const c=a.sn;return this.loopSn!==c&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${c}`),this.loopSn=c),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(Mw(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(Mw(this.config)&&e.type!==jt.SUBTITLE){const i=this.hls.interstitialsManager,n=i?.bufferingItem;if(n){const a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||n.start===0)return null}else if(e.end<=n.start&&t?.live===!1||e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}const r=i?.playerQueue;if(r)for(let a=r.length;a--;){const u=r[a].interstitial;if(u.appendInPlace&&e.start>=u.startTime&&e.end<=u.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let n=-1,r=!1,a=!0;for(let u=0,c=e.length;u<c;u++){const d=e[u];if(a=a&&!d.independent,n>-1&&i<d.start)break;const f=d.loaded;f?n=-1:(r||(d.independent||a)&&d.fragment===t)&&(d.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${d.start}`),n=u),r=f}return n}loadedEndOfParts(e,t){let i;for(let n=e.length;n--;){if(i=e[n],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let n=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=VU(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const a=t[r-e.startSN];i.cc===a.cc&&(n=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=xL(e,i.cc,i.end),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(n=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}getFragmentAtPosition(e,t,i){const{config:n}=this;let{fragPrevious:r}=this,{fragments:a,endSN:u}=i;const{fragmentHint:c}=i,{maxFragLookUpTolerance:d}=n,f=i.partList,g=!!(this.loadingParts&&f!=null&&f.length&&c);g&&!this.bitrateTest&&f[f.length-1].fragment.sn===c.sn&&(a=a.concat(c),u=c.sn);let y;if(e<t){var v;const S=e<this.lastCurrentTime||e>t-d||(v=this.media)!=null&&v.paused||!this.startFragRequested?0:d;y=Au(r,a,e,S)}else y=a[a.length-1];if(y){const T=y.sn-i.startSN,S=this.fragmentTracker.getState(y);if((S===Sn.OK||S===Sn.PARTIAL&&y.gap)&&(r=y),r&&y.sn===r.sn&&(!g||f[0].fragment.sn>y.sn||!i.live)&&y.level===r.level){const L=a[T+1];y.sn<u&&this.fragmentTracker.getState(L)!==Sn.OK?y=L:y=null}}return y}alignPlaylists(e,t,i){const n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,a=!t,u=e.alignedSliding&&Ot(r);if(a||!u&&!r){kj(i,e);const c=e.fragmentStart;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),c}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const n=this.timelineOffset;if(i===-1){const r=this.startTimeOffset!==null,a=r?this.startTimeOffset:e.startTimeOffset;a!==null&&Ot(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${r?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&an(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==ot.FRAG_LOADING_WAITING_RETRY)&&(this.state=ot.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const L=this.getCurrentContext(t.chunkMeta);L&&(t.frag=L.frag)}const n=t.frag;if(!n||n.type!==e||!this.levels)return;if(this.fragContextChanged(n)){var r;this.warn(`Frag load error must match current frag to retry ${n.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const a=t.details===$e.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(n,!0);const u=t.errorAction;if(!u){this.state=ot.ERROR;return}const{action:c,flags:d,retryCount:f=0,retryConfig:g}=u,y=!!g,v=y&&c===$n.RetryRequest,T=y&&!u.resolved&&d===Fr.MoveAllAlternatesMatchingHost,S=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!v&&T&&an(n)&&!n.endList&&S&&!TL(t))this.resetFragmentErrors(e),this.treatAsGap(n),u.resolved=!0;else if((v||T)&&f<g.maxNumRetry){var w;const L=qx((w=t.response)==null?void 0:w.code),O=o1(g,f);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+O,this.state=ot.FRAG_LOADING_WAITING_RETRY,u.resolved=!0,L){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${n.sn} of ${e} ${n.level} errored with ${t.details}, retrying loading ${f+1}/${g.maxNumRetry} in ${O}ms`)}else if(g)if(this.resetFragmentErrors(e),f<g.maxNumRetry)!a&&c!==$n.RemoveAlternatePermanently&&(u.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${f})`);return}else c===$n.SendAlternateToPenaltyBox?this.state=ot.WAITING_LEVEL:this.state=ot.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!qx(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=ot.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===ot.PARSING||this.state===ot.PARSED){const t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),r=n&&n.len>.5;r&&this.reduceMaxBufferLength(n.len,t?.duration||10);const a=!r;return a&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===jt.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==ot.STOPPED&&(this.state=ot.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=gi.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===ot.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==ot.STOPPED&&(this.state=ot.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,n){const r=i.details;if(!r){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((c,d)=>{const f=e.elementaryStreams[d];if(f){const g=f.endPTS-f.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${g})`),c||!1;const y=n?0:LL(r,e,f.startPTS,f.endPTS,f.startDTS,f.endDTS,this);return this.hls.trigger(H.LEVEL_PTS_UPDATED,{details:r,level:i,drift:y,type:d,frag:e,start:f.startPTS,end:f.endPTS}),!0}return c},!1)){var u;const c=((u=this.transmuxer)==null?void 0:u.error)===null;if((i.fragmentError===0||c&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),c){const d=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(d.message),this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=ot.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(H.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===jt.MAIN?"level":"track"}fragInfo(e,t=!0,i){var n,r;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((n=t&&!i?e.startPTS:(i||e).start)!=null?n:NaN).toFixed(3)}-${((r=t&&!i?e.endPTS:(i||e).end)!=null?r:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Mw(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class FL{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=Dj(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Dj(s,e){const t=new Uint8Array(e);let i=0;for(let n=0;n<s.length;n++){const r=s[n];t.set(r,i),i+=r.length}return t}var Iv={exports:{}},Pw;function Lj(){return Pw||(Pw=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(c,d,f){this.fn=c,this.context=d,this.once=f||!1}function r(c,d,f,g,y){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new n(f,g||c,y),T=t?t+d:d;return c._events[T]?c._events[T].fn?c._events[T]=[c._events[T],v]:c._events[T].push(v):(c._events[T]=v,c._eventsCount++),c}function a(c,d){--c._eventsCount===0?c._events=new i:delete c._events[d]}function u(){this._events=new i,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],f,g;if(this._eventsCount===0)return d;for(g in f=this._events)e.call(f,g)&&d.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(f)):d},u.prototype.listeners=function(d){var f=t?t+d:d,g=this._events[f];if(!g)return[];if(g.fn)return[g.fn];for(var y=0,v=g.length,T=new Array(v);y<v;y++)T[y]=g[y].fn;return T},u.prototype.listenerCount=function(d){var f=t?t+d:d,g=this._events[f];return g?g.fn?1:g.length:0},u.prototype.emit=function(d,f,g,y,v,T){var S=t?t+d:d;if(!this._events[S])return!1;var w=this._events[S],L=arguments.length,O,I;if(w.fn){switch(w.once&&this.removeListener(d,w.fn,void 0,!0),L){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,f),!0;case 3:return w.fn.call(w.context,f,g),!0;case 4:return w.fn.call(w.context,f,g,y),!0;case 5:return w.fn.call(w.context,f,g,y,v),!0;case 6:return w.fn.call(w.context,f,g,y,v,T),!0}for(I=1,O=new Array(L-1);I<L;I++)O[I-1]=arguments[I];w.fn.apply(w.context,O)}else{var j=w.length,P;for(I=0;I<j;I++)switch(w[I].once&&this.removeListener(d,w[I].fn,void 0,!0),L){case 1:w[I].fn.call(w[I].context);break;case 2:w[I].fn.call(w[I].context,f);break;case 3:w[I].fn.call(w[I].context,f,g);break;case 4:w[I].fn.call(w[I].context,f,g,y);break;default:if(!O)for(P=1,O=new Array(L-1);P<L;P++)O[P-1]=arguments[P];w[I].fn.apply(w[I].context,O)}}return!0},u.prototype.on=function(d,f,g){return r(this,d,f,g,!1)},u.prototype.once=function(d,f,g){return r(this,d,f,g,!0)},u.prototype.removeListener=function(d,f,g,y){var v=t?t+d:d;if(!this._events[v])return this;if(!f)return a(this,v),this;var T=this._events[v];if(T.fn)T.fn===f&&(!y||T.once)&&(!g||T.context===g)&&a(this,v);else{for(var S=0,w=[],L=T.length;S<L;S++)(T[S].fn!==f||y&&!T[S].once||g&&T[S].context!==g)&&w.push(T[S]);w.length?this._events[v]=w.length===1?w[0]:w:a(this,v)}return this},u.prototype.removeAllListeners=function(d){var f;return d?(f=t?t+d:d,this._events[f]&&a(this,f)):(this._events=new i,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=t,u.EventEmitter=u,s.exports=u})(Iv)),Iv.exports}var Rj=Lj(),f1=iU(Rj);const Hh="1.6.15",qc={};function Ij(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Nj(){const s=qc[Hh];if(s)return s.clientCount++,s;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),n={worker:new self.Worker(t),objectURL:t,clientCount:1};return qc[Hh]=n,n}function Oj(s){const e=qc[s];if(e)return e.clientCount++,e;const t=new self.URL(s,self.location.href).href,n={worker:new self.Worker(t),scriptURL:t,clientCount:1};return qc[s]=n,n}function Mj(s){const e=qc[s||Hh];if(e&&e.clientCount--===1){const{worker:i,objectURL:n}=e;delete qc[s||Hh],n&&self.URL.revokeObjectURL(n),i.terminate()}}function UL(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function m1(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function Np(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function zh(s,e){const t=e;let i=0;for(;m1(s,e);){i+=10;const n=Np(s,e+6);i+=n,UL(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function Pj(s,e,t,i){const n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],a=r>>2&15;if(a>12){const v=new Error(`invalid ADTS sampling index:${a}`);s.emit(H.ERROR,H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message});return}const u=(r>>6&3)+1,c=e[t+3]>>6&3|(r&1)<<2,d="mp4a.40."+u,f=n[a];let g=a;(u===5||u===29)&&(g-=3);const y=[u<<3|(g&14)>>1,(g&1)<<7|c<<3];return cs.log(`manifest codec:${i}, parsed codec:${d}, channels:${c}, rate:${f} (ADTS object type:${u} sampling index:${a})`),{config:y,samplerate:f,channelCount:c,codec:d,parsedCodec:d,manifestCodec:i}}function jL(s,e){return s[e]===255&&(s[e+1]&246)===240}function $L(s,e){return s[e+1]&1?7:9}function p1(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function Bj(s,e){return e+5<s.length}function X0(s,e){return e+1<s.length&&jL(s,e)}function Fj(s,e){return Bj(s,e)&&jL(s,e)&&p1(s,e)<=s.length-e}function Uj(s,e){if(X0(s,e)){const t=$L(s,e);if(e+t>=s.length)return!1;const i=p1(s,e);if(i<=t)return!1;const n=e+i;return n===s.length||X0(s,n)}return!1}function HL(s,e,t,i,n){if(!s.samplerate){const r=Pj(e,t,i,n);if(!r)return;ys(s,r)}}function zL(s){return 1024*9e4/s}function jj(s,e){const t=$L(s,e);if(e+t<=s.length){const i=p1(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function VL(s,e,t,i,n){const r=zL(s.samplerate),a=i+n*r,u=jj(e,t);let c;if(u){const{frameLength:g,headerLength:y}=u,v=y+g,T=Math.max(0,t+v-e.length);T?(c=new Uint8Array(v-y),c.set(e.subarray(t+y,e.length),0)):c=e.subarray(t+y,t+v);const S={unit:c,pts:a};return T||s.samples.push(S),{sample:S,length:v,missing:T}}const d=e.length-t;return c=new Uint8Array(d),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:a},length:d,missing:-1}}function $j(s,e){return m1(s,e)&&Np(s,e+6)+10<=s.length-e}function Hj(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function Nv(s,e=0,t=1/0){return zj(s,e,t,Uint8Array)}function zj(s,e,t,i){const n=Vj(s);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const a=Gj(s)?s.byteOffset:0,u=(a+s.byteLength)/r,c=(a+e)/r,d=Math.floor(Math.max(0,Math.min(c,u))),f=Math.floor(Math.min(d+Math.max(t,0),u));return new i(n,d,f-d)}function Vj(s){return s instanceof ArrayBuffer?s:s.buffer}function Gj(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function qj(s){const e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=s.data.subarray(1).indexOf(0);if(i===-1)return;const n=Hr(Nv(s.data,1,i)),r=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;const u=Hr(Nv(s.data,3+i,a));let c;return n==="-->"?c=Hr(Nv(s.data,4+i+a)):c=Hj(s.data.subarray(4+i+a)),e.mimeType=n,e.pictureType=r,e.description=u,e.data=c,e}function Kj(s){if(s.size<2)return;const e=Hr(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function Wj(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=Hr(s.data.subarray(t),!0);t+=i.length+1;const n=Hr(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=Hr(s.data.subarray(1));return{key:s.type,info:"",data:e}}function Yj(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=Hr(s.data.subarray(t),!0);t+=i.length+1;const n=Hr(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=Hr(s.data);return{key:s.type,info:"",data:e}}function Xj(s){return s.type==="PRIV"?Kj(s):s.type[0]==="W"?Yj(s):s.type==="APIC"?qj(s):Wj(s)}function Qj(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=Np(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const Pm=10,Zj=10;function GL(s){let e=0;const t=[];for(;m1(s,e);){const i=Np(s,e+6);s[e+5]>>6&1&&(e+=Pm),e+=Pm;const n=e+i;for(;e+Zj<n;){const r=Qj(s.subarray(e)),a=Xj(r);a&&t.push(a),e+=r.size+Pm}UL(s,e)&&(e+=Pm)}return t}function qL(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function Jj(s){if(s.data.byteLength===8){const e=new Uint8Array(s.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function g1(s){const e=GL(s);for(let t=0;t<e.length;t++){const i=e[t];if(qL(i))return Jj(i)}}let jr=(function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s})({});function ja(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class y1{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=ia(this.cachedData,e),this.cachedData=null);let i=zh(e,0),n=i?i.length:0,r;const a=this._audioTrack,u=this._id3Track,c=i?g1(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&Ot(c))&&(this.basePTS=e7(c,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:jr.audioId3,duration:Number.POSITIVE_INFINITY});n<d;){if(this.canParse(e,n)){const f=this.appendFrame(a,e,n);f?(this.frameIndex++,this.lastPTS=f.sample.pts,n+=f.length,r=n):n=d}else $j(e,n)?(i=zh(e,n),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:jr.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===d&&r!==d){const f=e.slice(r);this.cachedData?this.cachedData=ia(this.cachedData,f):this.cachedData=f}}return{audioTrack:a,videoTrack:ja(),id3Track:u,textTrack:ja()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ja(),id3Track:this._id3Track,textTrack:ja()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const e7=(s,e,t)=>{if(Ot(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Bm=null;const t7=[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],i7=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s7=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],n7=[0,1,1,4];function KL(s,e,t,i,n){if(t+24>e.length)return;const r=WL(e,t);if(r&&t+r.frameLength<=e.length){const a=r.samplesPerFrame*9e4/r.sampleRate,u=i+n*a,c={unit:e.subarray(t,t+r.frameLength),pts:u,dts:u};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(c),{sample:c,length:r.frameLength,missing:0}}}function WL(s,e){const t=s[e+1]>>3&3,i=s[e+1]>>1&3,n=s[e+2]>>4&15,r=s[e+2]>>2&3;if(t!==1&&n!==0&&n!==15&&r!==3){const a=s[e+2]>>1&1,u=s[e+3]>>6,c=t===3?3-i:i===3?3:4,d=t7[c*14+n-1]*1e3,g=i7[(t===3?0:t===2?1:2)*3+r],y=u===3?1:2,v=s7[t][i],T=n7[i],S=v*8*T,w=Math.floor(v*d/g+a)*T;if(Bm===null){const I=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bm=I?parseInt(I[1]):0}return Bm&&Bm<=87&&i===2&&d>=224e3&&u===0&&(s[e+3]=s[e+3]|128),{sampleRate:g,channelCount:y,frameLength:w,samplesPerFrame:S}}}function v1(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function YL(s,e){return e+1<s.length&&v1(s,e)}function r7(s,e){return v1(s,e)&&4<=s.length-e}function XL(s,e){if(e+1<s.length&&v1(s,e)){const i=WL(s,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const r=e+n;return r===s.length||YL(s,r)}return!1}class a7 extends y1{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=zh(e,0);let n=i?.length||0;if(XL(e,n))return!1;for(let r=e.length;n<r;n++)if(Uj(e,n))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Fj(e,t)}appendFrame(e,t,i){HL(e,this.observer,t,i,e.manifestCodec);const n=VL(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const QL=(s,e)=>{let t=0,i=5;e+=i;const n=new Uint32Array(1),r=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];const u=Math.min(i,8),c=8-u;r[0]=4278190080>>>24+c<<c,n[0]=(a[0]&r[0])>>c,t=t?t<<u|n[0]:n[0],e+=1,i-=u}return t};class o7 extends y1{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const n=ZL(e,t,i,this.basePTS,this.frameIndex);if(n!==-1)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}static probe(e){if(!e)return!1;const t=zh(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&g1(t)!==void 0&&QL(e,i)<16}}function ZL(s,e,t,i,n){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const r=e[t+4]>>6;if(r>=3)return-1;const u=[48e3,44100,32e3][r],c=e[t+4]&63,f=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][c*3+r]*2;if(t+f>e.length)return-1;const g=e[t+6]>>5;let y=0;g===2?y+=2:(g&1&&g!==1&&(y+=2),g&4&&(y+=2));const v=(e[t+6]<<8|e[t+7])>>12-y&1,S=[2,1,2,3,3,4,4,5][g]+v,w=e[t+5]>>3,L=e[t+5]&7,O=new Uint8Array([r<<6|w<<1|L>>2,(L&3)<<6|g<<3|v<<2|c>>4,c<<4&224]),I=1536/u*9e4,j=i+n*I,P=e.subarray(t,t+f);return s.config=O,s.channelCount=S,s.samplerate=u,s.samples.push({unit:P,pts:j}),f}class l7 extends y1{resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=zh(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&g1(t)!==void 0&&QL(e,i)<=16)return!1;for(let n=e.length;i<n;i++)if(XL(e,i))return cs.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return r7(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return KL(e,t,i,this.basePTS,this.frameIndex)}}const u7=/\/emsg[-/]ID3/i;class c7{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,n){const r=this.videoTrack=ja("video",1),a=this.audioTrack=ja("audio",1),u=this.txtTrack=ja("text",1);if(this.id3Track=ja("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=lL(e);if(c.video){const{id:d,timescale:f,codec:g,supplemental:y}=c.video;r.id=d,r.timescale=u.timescale=f,r.codec=g,r.supplemental=y}if(c.audio){const{id:d,timescale:f,codec:g}=c.audio;a.id=d,a.timescale=f,a.codec=g}u.id=rL.text,r.sampleDuration=0,r.duration=a.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return oU(e)}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ia(this.remainderData,e));const u=mU(i);this.remainderData=u.remainder,n.samples=u.valid||new Uint8Array}else n.samples=i;const a=this.extractID3Track(n,t);return r.samples=ew(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(t,this.timeOffset);return i.samples=ew(e,t),{videoTrack:t,audioTrack:ja(),id3Track:n,textTrack:ja()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=Ai(e.samples,["emsg"]);n&&n.forEach(r=>{const a=gU(r);if(u7.test(a.schemeIdUri)){const u=Bw(a,t);let c=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const d=a.payload;i.samples.push({data:d,len:d.byteLength,dts:u,pts:u,type:jr.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const u=Bw(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:jr.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function Bw(s,e){return Ot(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}class d7{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new l1(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Rl.cbc)}decryptAacSample(e,t,i){const n=e[t].unit;if(n.length<=16)return;const r=n.subarray(16,n.length-n.length%16),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(a).then(u=>{const c=new Uint8Array(u);n.set(c,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)i.set(e.subarray(r,r+16),n);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)e.set(i.subarray(n,n+16),r);return e}decryptAvcSample(e,t,i,n,r){const a=dL(r.data),u=this.getAvcEncryptedData(a);this.decryptBuffer(u.buffer).then(c=>{r.data=this.getAvcDecryptedUnit(a,c),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}decryptAvcSamples(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){n();return}const r=e[t].units;for(;!(i>=r.length);i++){const a=r[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,n,a),!this.decrypter.isSync()))return}}}}class JL{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,n;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const r=i.units;n=r[r.length-1]}return n}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,n=i.length;if(n){const r=i[n-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const n=t.byteLength;let r=e.naluState||0;const a=r,u=[];let c=0,d,f,g,y=-1,v=0;for(r===-1&&(y=0,v=this.getNALuType(t,0),r=0,c=1);c<n;){if(d=t[c++],!r){r=d?0:1;continue}if(r===1){r=d?0:2;continue}if(!d)r=3;else if(d===1){if(f=c-r-1,y>=0){const T={data:t.subarray(y,f),type:v};u.push(T)}else{const T=this.getLastNalUnit(e.samples);T&&(a&&c<=4-a&&T.state&&(T.data=T.data.subarray(0,T.data.byteLength-a)),f>0&&(T.data=ia(T.data,t.subarray(0,f)),T.state=0))}c<n?(g=this.getNALuType(t,c),y=c,v=g,r=0):r=-1}else r=0}if(y>=0&&r>=0){const T={data:t.subarray(y,n),type:v,state:r};u.push(T)}if(u.length===0){const T=this.getLastNalUnit(e.samples);T&&(T.data=ia(T.data,t))}return e.naluState=r,u}}class Lh{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");n.set(e.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&cs.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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)}}class h7 extends JL{parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let a=this.VideoSample,u,c=!1;i.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,g;switch(d.type){case 1:{let S=!1;u=!0;const w=d.data;if(c&&w.length>4){const L=this.readSliceType(w);(L===2||L===4||L===7||L===9)&&(S=!0)}if(S){var y;(y=a)!=null&&y.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.frame=!0,a.key=S;break}case 5:u=!0,(f=a)!=null&&f.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 6:{u=!0,n1(d.data,1,i.pts,t.samples);break}case 7:{var v,T;u=!0,c=!0;const S=d.data,w=this.readSPS(S);if(!e.sps||e.width!==w.width||e.height!==w.height||((v=e.pixelRatio)==null?void 0:v[0])!==w.pixelRatio[0]||((T=e.pixelRatio)==null?void 0:T[1])!==w.pixelRatio[1]){e.width=w.width,e.height=w.height,e.pixelRatio=w.pixelRatio,e.sps=[S];const L=S.subarray(1,4);let O="avc1.";for(let I=0;I<3;I++){let j=L[I].toString(16);j.length<2&&(j="0"+j),O+=j}e.codec=O}break}case 8:u=!0,e.pps=[d.data];break;case 9:u=!0,e.audFound=!0,(g=a)!=null&&g.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:u=!0;break;default:u=!1;break}a&&u&&a.units.push(d)}),n&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new Lh(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,n=8,r;for(let a=0;a<e;a++)n!==0&&(r=t.readEG(),n=(i+r+256)%256),i=n===0?i:n}readSPS(e){const t=new Lh(e);let i=0,n=0,r=0,a=0,u,c,d;const f=t.readUByte.bind(t),g=t.readBits.bind(t),y=t.readUEG.bind(t),v=t.readBoolean.bind(t),T=t.skipBits.bind(t),S=t.skipEG.bind(t),w=t.skipUEG.bind(t),L=this.skipScalingList.bind(this);f();const O=f();if(g(5),T(3),f(),w(),O===100||O===110||O===122||O===244||O===44||O===83||O===86||O===118||O===128){const K=y();if(K===3&&T(1),w(),w(),T(1),v())for(c=K!==3?8:12,d=0;d<c;d++)v()&&(d<6?L(16,t):L(64,t))}w();const I=y();if(I===0)y();else if(I===1)for(T(1),S(),S(),u=y(),d=0;d<u;d++)S();w(),T(1);const j=y(),P=y(),G=g(1);G===0&&T(1),T(1),v()&&(i=y(),n=y(),r=y(),a=y());let N=[1,1];if(v()&&v())switch(f()){case 1:N=[1,1];break;case 2:N=[12,11];break;case 3:N=[10,11];break;case 4:N=[16,11];break;case 5:N=[40,33];break;case 6:N=[24,11];break;case 7:N=[20,11];break;case 8:N=[32,11];break;case 9:N=[80,33];break;case 10:N=[18,11];break;case 11:N=[15,11];break;case 12:N=[64,33];break;case 13:N=[160,99];break;case 14:N=[4,3];break;case 15:N=[3,2];break;case 16:N=[2,1];break;case 255:{N=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((j+1)*16-i*2-n*2),height:(2-G)*(P+1)*16-(G?2:4)*(r+a),pixelRatio:N}}}class f7 extends JL{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let a=this.VideoSample,u,c=!1;i.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,g;switch(d.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.frame=!0,u=!0;break;case 16:case 17:case 18:case 21:if(u=!0,c){var y;(y=a)!=null&&y.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:u=!0,(f=a)!=null&&f.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 39:u=!0,n1(d.data,2,i.pts,t.samples);break;case 32:u=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=ys(e.params,this.readVPS(d.data)),this.initVPS=d.data),e.vps=[d.data];break;case 33:if(u=!0,c=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],d.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const v=this.readSPS(d.data);e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.codec=v.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const T in v.params)e.params[T]=v.params[T]}this.pushParameterSet(e.sps,d.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0;break;case 34:if(u=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const v=this.readPPS(d.data);for(const T in v)e.params[T]=v[T]}this.pushParameterSet(e.pps,d.data,e.vps)}break;case 35:u=!0,e.audFound=!0,(g=a)!=null&&g.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:u=!1;break}a&&u&&a.units.push(d)}),n&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let n=0;n<e.byteLength;n++)n>=2&&e[n]===3&&e[n-1]===0&&e[n-2]===0||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new Lh(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),n=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:n}}readSPS(e){const t=new Lh(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const n=t.readBits(2),r=t.readBoolean(),a=t.readBits(5),u=t.readUByte(),c=t.readUByte(),d=t.readUByte(),f=t.readUByte(),g=t.readUByte(),y=t.readUByte(),v=t.readUByte(),T=t.readUByte(),S=t.readUByte(),w=t.readUByte(),L=t.readUByte(),O=[],I=[];for(let Fe=0;Fe<i;Fe++)O.push(t.readBoolean()),I.push(t.readBoolean());if(i>0)for(let Fe=i;Fe<8;Fe++)t.readBits(2);for(let Fe=0;Fe<i;Fe++)O[Fe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),I[Fe]&&t.readUByte();t.readUEG();const j=t.readUEG();j==3&&t.skipBits(1);const P=t.readUEG(),G=t.readUEG(),N=t.readBoolean();let K=0,k=0,R=0,Y=0;N&&(K+=t.readUEG(),k+=t.readUEG(),R+=t.readUEG(),Y+=t.readUEG());const z=t.readUEG(),X=t.readUEG(),re=t.readUEG(),J=t.readBoolean();for(let Fe=J?0:i;Fe<=i;Fe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let _t=0;_t<4;_t++)for(let Qe=0;Qe<(_t===3?2:6);Qe++)if(!t.readBoolean())t.readUEG();else{const ze=Math.min(64,1<<4+(_t<<1));_t>1&&t.readEG();for(let Ze=0;Ze<ze;Ze++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const Z=t.readUEG();let te=0;for(let Fe=0;Fe<Z;Fe++){let _t=!1;if(Fe!==0&&(_t=t.readBoolean()),_t){Fe===Z&&t.readUEG(),t.readBoolean(),t.readUEG();let Qe=0;for(let Xe=0;Xe<=te;Xe++){const ze=t.readBoolean();let Ze=!1;ze||(Ze=t.readBoolean()),(ze||Ze)&&Qe++}te=Qe}else{const Qe=t.readUEG(),Xe=t.readUEG();te=Qe+Xe;for(let ze=0;ze<Qe;ze++)t.readUEG(),t.readBoolean();for(let ze=0;ze<Xe;ze++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Fe=t.readUEG();for(let _t=0;_t<Fe;_t++){for(let Qe=0;Qe<re+4;Qe++)t.readBits(1);t.readBits(1)}}let F=0,le=1,ge=1,Ie=!0,Le=1,Pe=0;t.readBoolean(),t.readBoolean();let Je=!1;if(t.readBoolean()){if(t.readBoolean()){const ct=t.readUByte(),St=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],se=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];ct>0&&ct<16?(le=St[ct-1],ge=se[ct-1]):ct===255&&(le=t.readBits(16),ge=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Je=t.readBoolean(),Je&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Le=t.readBits(32),Pe=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const se=t.readBoolean(),ke=t.readBoolean();let De=!1;(se||ke)&&(De=t.readBoolean(),De&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),De&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Ue=0;Ue<=i;Ue++){Ie=t.readBoolean();const at=Ie||t.readBoolean();let dt=!1;at?t.readEG():dt=t.readBoolean();const wt=dt?1:t.readUEG()+1;if(se)for(let kt=0;kt<wt;kt++)t.readUEG(),t.readUEG(),De&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(ke)for(let kt=0;kt<wt;kt++)t.readUEG(),t.readUEG(),De&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),F=t.readUEG())}let Re=P,Ve=G;if(N){let Fe=1,_t=1;j===1?Fe=_t=2:j==2&&(Fe=2),Re=P-Fe*k-Fe*K,Ve=G-_t*Y-_t*R}const Ee=n?["A","B","C"][n]:"",_e=u<<24|c<<16|d<<8|f;let yt=0;for(let Fe=0;Fe<32;Fe++)yt=(yt|(_e>>Fe&1)<<31-Fe)>>>0;let ut=yt.toString(16);return a===1&&ut==="2"&&(ut="6"),{codecString:`hvc1.${Ee}${a}.${ut}.${r?"H":"L"}${L}.B0`,params:{general_tier_flag:r,general_profile_idc:a,general_profile_space:n,general_profile_compatibility_flags:[u,c,d,f],general_constraint_indicator_flags:[g,y,v,T,S,w],general_level_idc:L,bit_depth:z+8,bit_depth_luma_minus8:z,bit_depth_chroma_minus8:X,min_spatial_segmentation_idc:F,chroma_format_idc:j,frame_rate:{fixed:Ie,fps:Pe/Le}},width:Re,height:Ve,pixelRatio:[le,ge]}}readPPS(e){const t=new Lh(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const n=t.readBoolean(),r=t.readBoolean();let a=1;return r&&n?a=0:r?a=3:n&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const kn=188;class Sl{constructor(e,t,i,n){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=n,this.videoParser=null}static probe(e,t){const i=Sl.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(kn*5,t-kn)+1,n=0;for(;n<i;){let r=!1,a=-1,u=0;for(let c=n;c<t;c+=kn)if(e[c]===71&&(t-c===kn||e[c+kn]===71)){if(u++,a===-1&&(a=c,a!==0&&(i=Math.min(a+kn*99,e.length-kn)+1)),r||(r=Qx(e,c)===0),r&&u>1&&(a===0&&u>2||c+kn>i))return a}else{if(u)return-1;break}n++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:rL[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Sl.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=Sl.createTrack("audio",n),this._id3Track=Sl.createTrack("id3"),this._txtTrack=Sl.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,n=!1){i||(this.sampleAes=null);let r;const a=this._videoTrack,u=this._audioTrack,c=this._id3Track,d=this._txtTrack;let f=a.pid,g=a.pesData,y=u.pid,v=c.pid,T=u.pesData,S=c.pesData,w=null,L=this.pmtParsed,O=this._pmtId,I=e.length;if(this.remainderData&&(e=ia(this.remainderData,e),I=e.length,this.remainderData=null),I<kn&&!n)return this.remainderData=e,{audioTrack:u,videoTrack:a,id3Track:c,textTrack:d};const j=Math.max(0,Sl.syncOffset(e));I-=(I-j)%kn,I<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,I,e.buffer.byteLength-I));let P=0;for(let N=j;N<I;N+=kn)if(e[N]===71){const K=!!(e[N+1]&64),k=Qx(e,N),R=(e[N+3]&48)>>4;let Y;if(R>1){if(Y=N+5+e[N+4],Y===N+kn)continue}else Y=N+4;switch(k){case f:K&&(g&&(r=lc(g,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,d,r,!1)),g={data:[],size:0}),g&&(g.data.push(e.subarray(Y,N+kn)),g.size+=N+kn-Y);break;case y:if(K){if(T&&(r=lc(T,this.logger)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,r);break;case"mp3":this.parseMPEGPES(u,r);break;case"ac3":this.parseAC3PES(u,r);break}T={data:[],size:0}}T&&(T.data.push(e.subarray(Y,N+kn)),T.size+=N+kn-Y);break;case v:K&&(S&&(r=lc(S,this.logger))&&this.parseID3PES(c,r),S={data:[],size:0}),S&&(S.data.push(e.subarray(Y,N+kn)),S.size+=N+kn-Y);break;case 0:K&&(Y+=e[Y]+1),O=this._pmtId=m7(e,Y);break;case O:{K&&(Y+=e[Y]+1);const z=p7(e,Y,this.typeSupported,i,this.observer,this.logger);f=z.videoPid,f>0&&(a.pid=f,a.segmentCodec=z.segmentVideoCodec),y=z.audioPid,y>0&&(u.pid=y,u.segmentCodec=z.segmentAudioCodec),v=z.id3Pid,v>0&&(c.pid=v),w!==null&&!L&&(this.logger.warn(`MPEG-TS PMT found at ${N} after unknown PID '${w}'. Backtracking to sync byte @${j} to parse all TS packets.`),w=null,N=j-188),L=this.pmtParsed=!0;break}case 17:case 8191:break;default:w=k;break}}else P++;P>0&&Zx(this.observer,new Error(`Found ${P} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=g,u.pesData=T,c.pesData=S;const G={audioTrack:u,videoTrack:a,id3Track:c,textTrack:d};return n&&this.extractRemainingSamples(G),G}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:n,textTrack:r}=e,a=i.pesData,u=t.pesData,c=n.pesData;let d;if(a&&(d=lc(a,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,d,!0),i.pesData=null)):i.pesData=a,u&&(d=lc(u,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else u!=null&&u.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=u;c&&(d=lc(c,this.logger))?(this.parseID3PES(n,d),n.pesData=null):n.pesData=c}demuxSampleAes(e,t,i){const n=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new d7(this.observer,this.config,t);return this.decrypt(n,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new h7:e==="hevc"&&(this.videoParser=new f7))}decrypt(e,t){return new Promise(i=>{const{audioTrack:n,videoTrack:r}=e;n.samples&&n.segmentCodec==="aac"?t.decryptAacSamples(n.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let i=0;const n=this.aacOverFlow;let r=t.data;if(n){this.aacOverFlow=null;const g=n.missing,y=n.sample.unit.byteLength;if(g===-1)r=ia(n.sample.unit,r);else{const v=y-g;n.sample.unit.set(r.subarray(0,g),v),e.samples.push(n.sample),i=n.missing}}let a,u;for(a=i,u=r.length;a<u-1&&!X0(r,a);a++);if(a!==i){let g;const y=a<u-1;if(y?g=`AAC PES did not start with ADTS header,offset:${a}`:g="No ADTS header found in AAC PES",Zx(this.observer,new Error(g),y,this.logger),!y)return}HL(e,this.observer,r,a,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(n){const g=zL(e.samplerate);c=n.sample.pts+g}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,f;for(;a<u;)if(f=VL(e,r,a,c,d),a+=f.length,f.missing){this.aacOverFlow=f;break}else for(d++;a<u-1&&!X0(r,a);a++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let r=0,a=0;const u=t.pts;if(u===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(YL(i,a)){const c=KL(e,i,a,u,r);if(c)a+=c.length,r++;else break}else a++}parseAC3PES(e,t){{const i=t.data,n=t.pts;if(n===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const r=i.length;let a=0,u=0,c;for(;u<r&&(c=ZL(e,i,u,n,a++))>0;)u+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ys({},t,{type:this._videoTrack?jr.emsg:jr.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Qx(s,e){return((s[e+1]&31)<<8)+s[e+2]}function m7(s,e){return(s[e+10]&31)<<8|s[e+11]}function p7(s,e,t,i,n,r){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=(s[e+1]&15)<<8|s[e+2],c=e+3+u-4,d=(s[e+10]&15)<<8|s[e+11];for(e+=12+d;e<c;){const f=Qx(s,e),g=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){Ov("ADTS AAC",r);break}case 15:a.audioPid===-1&&(a.audioPid=f);break;case 21:a.id3Pid===-1&&(a.id3Pid=f);break;case 219:if(!i){Ov("H.264",r);break}case 27:a.videoPid===-1&&(a.videoPid=f);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=f,a.segmentAudioCodec="mp3");break;case 193:if(!i){Ov("AC-3",r);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=f,a.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&g>0){let y=e+5,v=g;for(;v>2;){s[y]===106&&(t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=f,a.segmentAudioCodec="ac3"));const S=s[y+1]+2;y+=S,v-=S}}break;case 194:case 135:return Zx(n,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:a.videoPid===-1&&(a.videoPid=f,a.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=g+5}return a}function Zx(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(H.ERROR,H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Ov(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function lc(s,e){let t=0,i,n,r,a,u;const c=s.data;if(!s||s.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=ia(c[0],c[1]),c.splice(1,1);if(i=c[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(n=(i[4]<<8)+i[5],n&&n>s.size-6)return null;const f=i[7];f&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,f&64?(u=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-u>60*9e4&&(e.warn(`${Math.round((a-u)/9e4)}s delta between PTS and DTS, align them`),a=u)):u=a),r=i[8];let g=r+9;if(s.size<=g)return null;s.size-=g;const y=new Uint8Array(s.size);for(let v=0,T=c.length;v<T;v++){i=c[v];let S=i.byteLength;if(g)if(g>S){g-=S;continue}else i=i.subarray(g),S-=g,g=0;y.set(i,t),t+=S}return n&&(n-=r+3),{data:y,pts:a,dts:u,len:n}}return null}class g7{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 gl=Math.pow(2,32)-1;class je{static init(){je.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in je.types)je.types.hasOwnProperty(e)&&(je.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);je.HDLR_TYPES={video:t,audio:i};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);je.STTS=je.STSC=je.STCO=r,je.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),je.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),je.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),je.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),u=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);je.FTYP=je.box(je.types.ftyp,a,c,a,u),je.DINF=je.box(je.types.dinf,je.box(je.types.dref,n))}static box(e,...t){let i=8,n=t.length;const r=n;for(;n--;)i+=t[n].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),n=0,i=8;n<r;n++)a.set(t[n],i),i+=t[n].byteLength;return a}static hdlr(e){return je.box(je.types.hdlr,je.HDLR_TYPES[e])}static mdat(e){return je.box(je.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(gl+1)),n=Math.floor(t%(gl+1));return je.box(je.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(e){return je.box(je.types.mdia,je.mdhd(e.timescale||0,e.duration||0),je.hdlr(e.type),je.minf(e))}static mfhd(e){return je.box(je.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"?je.box(je.types.minf,je.box(je.types.smhd,je.SMHD),je.DINF,je.stbl(e)):je.box(je.types.minf,je.box(je.types.vmhd,je.VMHD),je.DINF,je.stbl(e))}static moof(e,t,i){return je.box(je.types.moof,je.mfhd(e),je.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=je.trak(e[t]);return je.box.apply(null,[je.types.moov,je.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(je.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=je.trex(e[t]);return je.box.apply(null,[je.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(gl+1)),n=Math.floor(t%(gl+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return je.box(je.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let n,r;for(n=0;n<t.length;n++)r=t[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return je.box(je.types.sdtp,i)}static stbl(e){return je.box(je.types.stbl,je.stsd(e),je.box(je.types.stts,je.STTS),je.box(je.types.stsc,je.STSC),je.box(je.types.stsz,je.STSZ),je.box(je.types.stco,je.STCO))}static avc1(e){let t=[],i=[],n,r,a;for(n=0;n<e.sps.length;n++)r=e.sps[n],a=r.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(r));for(n=0;n<e.pps.length;n++)r=e.pps[n],a=r.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(r));const u=je.box(je.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),c=e.width,d=e.height,f=e.pixelRatio[0],g=e.pixelRatio[1];return je.box(je.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,c>>8&255,c&255,d>>8&255,d&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]),u,je.box(je.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),je.box(je.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,g>>24,g>>16&255,g>>8&255,g&255])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return je.box(je.types.mp4a,je.audioStsd(e),je.box(je.types.esds,je.esds(e)))}static mp3(e){return je.box(je.types[".mp3"],je.audioStsd(e))}static ac3(e){return je.box(je.types["ac-3"],je.audioStsd(e),je.box(je.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return je.box(je.types.stsd,je.STSD,je.mp4a(e));if(t==="ac3"&&e.config)return je.box(je.types.stsd,je.STSD,je.ac3(e));if(t==="mp3"&&e.codec==="mp3")return je.box(je.types.stsd,je.STSD,je.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return je.box(je.types.stsd,je.STSD,je.avc1(e));if(t==="hevc"&&e.vps)return je.box(je.types.stsd,je.STSD,je.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),n=e.width||0,r=e.height||0,a=Math.floor(i/(gl+1)),u=Math.floor(i%(gl+1));return je.box(je.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,a>>24,a>>16&255,a>>8&255,a&255,u>>24,u>>16&255,u>>8&255,u&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,n&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const i=je.sdtp(e),n=e.id,r=Math.floor(t/(gl+1)),a=Math.floor(t%(gl+1));return je.box(je.types.traf,je.box(je.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),je.box(je.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,a>>24,a>>16&255,a>>8&255,a&255])),je.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,je.box(je.types.trak,je.tkhd(e),je.mdia(e))}static trex(e){const t=e.id;return je.box(je.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],n=i.length,r=12+16*n,a=new Uint8Array(r);let u,c,d,f,g,y;for(t+=8+r,a.set([e.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),u=0;u<n;u++)c=i[u],d=c.duration,f=c.size,g=c.flags,y=c.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,g.isLeading<<2|g.dependsOn,g.isDependedOn<<6|g.hasRedundancy<<4|g.paddingValue<<1|g.isNonSync,g.degradPrio&61440,g.degradPrio&15,y>>>24&255,y>>>16&255,y>>>8&255,y&255],12+16*u);return je.box(je.types.trun,a)}static initSegment(e){je.types||je.init();const t=je.moov(e);return ia(je.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],n=4,r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),n-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let a=r.length;for(let T=0;T<i.length;T+=1){a+=3;for(let S=0;S<i[T].length;S+=1)a+=2+i[T][S].length}const u=new Uint8Array(a);u.set(r,0),a=r.length;const c=i.length-1;for(let T=0;T<i.length;T+=1){u.set(new Uint8Array([32+T|(T===c?128:0),0,i[T].length]),a),a+=3;for(let S=0;S<i[T].length;S+=1)u.set(new Uint8Array([i[T][S].length>>8,i[T][S].length&255]),a),a+=2,u.set(i[T][S],a),a+=i[T][S].length}const d=je.box(je.types.hvcC,u),f=e.width,g=e.height,y=e.pixelRatio[0],v=e.pixelRatio[1];return je.box(je.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,g>>8&255,g&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,je.box(je.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),je.box(je.types.pasp,new Uint8Array([y>>24,y>>16&255,y>>8&255,y&255,v>>24,v>>16&255,v>>8&255,v&255])))}}je.types=void 0;je.HDLR_TYPES=void 0;je.STTS=void 0;je.STSC=void 0;je.STCO=void 0;je.STSZ=void 0;je.VMHD=void 0;je.SMHD=void 0;je.STSD=void 0;je.FTYP=void 0;je.DINF=void 0;const eR=9e4;function x1(s,e,t=1,i=!1){const n=s*e*t;return i?Math.round(n):n}function y7(s,e,t=1,i=!1){return x1(s,e,1/t,i)}function nh(s,e=!1){return x1(s,1e3,1/eR,e)}function v7(s,e=1){return x1(s,eR,1/e)}function Fw(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const x7=10*1e3,b7=1024,T7=1152,S7=1536;let uc=null,Mv=null;function Uw(s,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}class a0 extends ra{constructor(e,t,i,n){if(super("mp4-remuxer",n),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,uc===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);uc=a?parseInt(a[1]):0}if(Mv===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Mv=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&Fw(t)} > ${e&&Fw(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,n=e.reduce((r,a)=>{let u=a.pts,c=u-r;return c<-4294967296&&(t=!0,u=Ur(u,i),c=u-r),c>0?r:u},i);return t&&this.debug("PTS rollover detected"),n}remux(e,t,i,n,r,a,u,c){let d,f,g,y,v,T,S=r,w=r;const L=e.pid>-1,O=t.pid>-1,I=t.samples.length,j=e.samples.length>0,P=u&&I>0||I>1;if((!L||j)&&(!O||P)||this.ISGenerated||u){if(this.ISGenerated){var N,K,k,R;const re=this.videoTrackConfig;(re&&(t.width!==re.width||t.height!==re.height||((N=t.pixelRatio)==null?void 0:N[0])!==((K=re.pixelRatio)==null?void 0:K[0])||((k=t.pixelRatio)==null?void 0:k[1])!==((R=re.pixelRatio)==null?void 0:R[1]))||!re&&P||this.nextAudioTs===null&&j)&&this.resetInitSegment()}this.ISGenerated||(g=this.generateIS(e,t,r,a));const Y=this.isVideoContiguous;let z=-1,X;if(P&&(z=_7(t.samples),!Y&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,z>0){this.warn(`Dropped ${z} out of ${I} video samples due to a missing keyframe`);const re=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(z),t.dropped+=z,w+=(t.samples[0].pts-re)/t.inputTimeScale,X=w}else z===-1&&(this.warn(`No keyframe found out of ${I} video samples`),T=!1);if(this.ISGenerated){if(j&&P){const re=this.getVideoStartPts(t.samples),W=(Ur(e.samples[0].pts,re)-re)/t.inputTimeScale;S+=Math.max(0,W),w+=Math.max(0,-W)}if(j){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),g=this.generateIS(e,t,r,a)),f=this.remuxAudio(e,S,this.isAudioContiguous,a,O||P||c===jt.AUDIO?w:void 0),P){const re=f?f.endPTS-f.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),g=this.generateIS(e,t,r,a)),d=this.remuxVideo(t,w,Y,re)}}else P&&(d=this.remuxVideo(t,w,Y,0));d&&(d.firstKeyFrame=z,d.independent=z!==-1,d.firstKeyFramePTS=X)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(v=tR(i,r,this._initPTS,this._initDTS)),n.samples.length&&(y=iR(n,r,this._initPTS))),{audio:f,video:d,initSegment:g,independent:T,text:y,id3:v}}computeInitPts(e,t,i,n){const r=Math.round(i*t);let a=Ur(e,r);if(a<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-a)/t} ${n}`);a<r+t;)a+=8589934592;return a-r}generateIS(e,t,i,n){const r=e.samples,a=t.samples,u=this.typeSupported,c={},d=this._initPTS;let f=!d||n,g="audio/mp4",y,v,T,S=-1;if(f&&(y=v=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(g="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:g,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):je.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(S=e.id,T=e.inputTimeScale,!d||T!==d.timescale?y=v=this.computeInitPts(r[0].pts,T,i,"audio"):f=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:je.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(S=t.id,T=t.inputTimeScale,!d||T!==d.timescale){const w=this.getVideoStartPts(a),L=Ur(a[0].dts,w),O=this.computeInitPts(L,T,i,"video"),I=this.computeInitPts(w,T,i,"video");v=Math.min(v,O),y=Math.min(y,I)}else f=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,f?(d&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${y/T} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${y/T} (${y}/${T}) trackId: ${S}`),this._initPTS={baseTime:y,timescale:T,trackId:S},this._initDTS={baseTime:v,timescale:T,trackId:S}):y=T=void 0,{tracks:c,initPTS:y,timescale:T,trackId:S}}remuxVideo(e,t,i,n){const r=e.inputTimeScale,a=e.samples,u=[],c=a.length,d=this._initPTS,f=d.baseTime*r/d.timescale;let g=this.nextVideoTs,y=8,v=this.videoSampleDuration,T,S,w=Number.POSITIVE_INFINITY,L=Number.NEGATIVE_INFINITY,O=!1;if(!i||g===null){const F=f+t*r,le=a[0].pts-Ur(a[0].dts,a[0].pts);uc&&g!==null&&Math.abs(F-le-(g+f))<15e3?i=!0:g=F-le-f}const I=g+f;for(let F=0;F<c;F++){const le=a[F];le.pts=Ur(le.pts,I),le.dts=Ur(le.dts,I),le.dts<a[F>0?F-1:F].dts&&(O=!0)}O&&a.sort(function(F,le){const ge=F.dts-le.dts,Ie=F.pts-le.pts;return ge||Ie}),T=a[0].dts,S=a[a.length-1].dts;const j=S-T,P=j?Math.round(j/(c-1)):v||e.inputTimeScale/30;if(i){const F=T-I,le=F>P,ge=F<-1;if((le||ge)&&(le?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${nh(F,!0)} ms (${F}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${nh(-F,!0)} ms (${F}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ge||I>=a[0].pts||uc)){T=I;const Ie=a[0].pts-F;if(le)a[0].dts=T,a[0].pts=Ie;else{let Le=!0;for(let Pe=0;Pe<a.length&&!(a[Pe].dts>Ie&&Le);Pe++){const Je=a[Pe].pts;if(a[Pe].dts-=F,a[Pe].pts-=F,Pe<a.length-1){const Se=a[Pe+1].pts,Re=a[Pe].pts,Ve=Se<=Re,Ee=Se<=Je;Le=Ve==Ee}}}this.log(`Video: Initial PTS/DTS adjusted: ${nh(Ie,!0)}/${nh(T,!0)}, delta: ${nh(F,!0)} ms`)}}T=Math.max(0,T);let G=0,N=0,K=T;for(let F=0;F<c;F++){const le=a[F],ge=le.units,Ie=ge.length;let Le=0;for(let Pe=0;Pe<Ie;Pe++)Le+=ge[Pe].data.length;N+=Le,G+=Ie,le.length=Le,le.dts<K?(le.dts=K,K+=P/4|0||1):K=le.dts,w=Math.min(le.pts,w),L=Math.max(le.pts,L)}S=a[c-1].dts;const k=N+4*G+8;let R;try{R=new Uint8Array(k)}catch(F){this.observer.emit(H.ERROR,H.ERROR,{type:Vt.MUX_ERROR,details:$e.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:k,reason:`fail allocating video mdat ${k}`});return}const Y=new DataView(R.buffer);Y.setUint32(0,k),R.set(je.types.mdat,4);let z=!1,X=Number.POSITIVE_INFINITY,re=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(let F=0;F<c;F++){const le=a[F],ge=le.units;let Ie=0;for(let Je=0,Se=ge.length;Je<Se;Je++){const Re=ge[Je],Ve=Re.data,Ee=Re.data.byteLength;Y.setUint32(y,Ee),y+=4,R.set(Ve,y),y+=Ee,Ie+=4+Ee}let Le;if(F<c-1)v=a[F+1].dts-le.dts,Le=a[F+1].pts-le.pts;else{const Je=this.config,Se=F>0?le.dts-a[F-1].dts:P;if(Le=F>0?le.pts-a[F-1].pts:P,Je.stretchShortVideoTrack&&this.nextAudioTs!==null){const Re=Math.floor(Je.maxBufferHole*r),Ve=(n?w+n*r:this.nextAudioTs+f)-le.pts;Ve>Re?(v=Ve-Se,v<0?v=Se:z=!0,this.log(`It is approximately ${Ve/90} ms to the next segment; using duration ${v/90} ms for the last video frame.`)):v=Se}else v=Se}const Pe=Math.round(le.pts-le.dts);X=Math.min(X,v),J=Math.max(J,v),re=Math.min(re,Le),W=Math.max(W,Le),u.push(Uw(le.key,v,Ie,Pe))}if(u.length){if(uc){if(uc<70){const F=u[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(Mv&&W-re<J-X&&P/J<.025&&u[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let F=T;for(let le=0,ge=u.length;le<ge;le++){const Ie=F+u[le].duration,Le=F+u[le].cts;if(le<ge-1){const Pe=Ie+u[le+1].cts;u[le].duration=Pe-Le}else u[le].duration=le?u[le-1].duration:P;u[le].cts=0,F=Ie}}}v=z||!v?P:v;const q=S+v;this.nextVideoTs=g=q-f,this.videoSampleDuration=v,this.isVideoContiguous=!0;const oe={data1:je.moof(e.sequenceNumber++,T,ys(e,{samples:u})),data2:R,startPTS:(w-f)/r,endPTS:(L+v-f)/r,startDTS:(T-f)/r,endDTS:g/r,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,oe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return T7;case"ac3":return S7;default:return b7}}remuxAudio(e,t,i,n,r){const a=e.inputTimeScale,u=e.samplerate?e.samplerate:a,c=a/u,d=this.getSamplesPerFrame(e),f=d*c,g=this._initPTS,y=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],T=r!==void 0;let S=e.samples,w=y?0:8,L=this.nextAudioTs||-1;const O=g.baseTime*a/g.timescale,I=O+t*a;if(this.isAudioContiguous=i=i||S.length&&L>0&&(n&&Math.abs(I-(L+O))<9e3||Math.abs(Ur(S[0].pts,I)-(L+O))<20*f),S.forEach(function(W){W.pts=Ur(W.pts,I)}),!i||L<0){const W=S.length;if(S=S.filter(q=>q.pts>=0),W!==S.length&&this.warn(`Removed ${S.length-W} of ${W} samples (initPTS ${O} / ${a})`),!S.length)return;r===0?L=0:n&&!T?L=Math.max(0,I-O):L=S[0].pts-O}if(e.segmentCodec==="aac"){const W=this.config.maxAudioFramesDrift;for(let q=0,Z=L+O;q<S.length;q++){const te=S[q],oe=te.pts,F=oe-Z,le=Math.abs(1e3*F/a);if(F<=-W*f&&T)q===0&&(this.warn(`Audio frame @ ${(oe/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*F/a)} ms.`),this.nextAudioTs=L=oe-O,Z=oe);else if(F>=W*f&&le<x7&&T){let ge=Math.round(F/f);for(Z=oe-ge*f;Z<0&&ge&&f;)ge--,Z+=f;q===0&&(this.nextAudioTs=L=Z-O),this.warn(`Injecting ${ge} audio frames @ ${((Z-O)/a).toFixed(3)}s due to ${Math.round(1e3*F/a)} ms gap.`);for(let Ie=0;Ie<ge;Ie++){let Le=g7.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Le||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Le=te.unit.subarray()),S.splice(q,0,{unit:Le,pts:Z}),Z+=f,q++}}te.pts=Z,Z+=f}}let j=null,P=null,G,N=0,K=S.length;for(;K--;)N+=S[K].unit.byteLength;for(let W=0,q=S.length;W<q;W++){const Z=S[W],te=Z.unit;let oe=Z.pts;if(P!==null){const le=v[W-1];le.duration=Math.round((oe-P)/c)}else if(i&&e.segmentCodec==="aac"&&(oe=L+O),j=oe,N>0){N+=w;try{G=new Uint8Array(N)}catch(le){this.observer.emit(H.ERROR,H.ERROR,{type:Vt.MUX_ERROR,details:$e.REMUX_ALLOC_ERROR,fatal:!1,error:le,bytes:N,reason:`fail allocating audio mdat ${N}`});return}y||(new DataView(G.buffer).setUint32(0,N),G.set(je.types.mdat,4))}else return;G.set(te,w);const F=te.byteLength;w+=F,v.push(Uw(!0,d,F,0)),P=oe}const k=v.length;if(!k)return;const R=v[v.length-1];L=P-O,this.nextAudioTs=L+c*R.duration;const Y=y?new Uint8Array(0):je.moof(e.sequenceNumber++,j/c,ys({},e,{samples:v}));e.samples=[];const z=(j-O)/a,X=this.nextAudioTs/a,J={data1:Y,data2:G,startPTS:z,endPTS:X,startDTS:z,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,J}}function Ur(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function _7(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function tR(s,e,t,i){const n=s.samples.length;if(!n)return;const r=s.inputTimeScale;for(let u=0;u<n;u++){const c=s.samples[u];c.pts=Ur(c.pts-t.baseTime*r/t.timescale,e*r)/r,c.dts=Ur(c.dts-i.baseTime*r/i.timescale,e*r)/r}const a=s.samples;return s.samples=[],{samples:a}}function iR(s,e,t){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let a=0;a<i;a++){const u=s.samples[a];u.pts=Ur(u.pts-t.baseTime*n/t.timescale,e*n)/n}s.samples.sort((a,u)=>a.pts-u.pts);const r=s.samples;return s.samples=[],{samples:r}}class E7 extends ra{constructor(e,t,i,n){super("passthrough-remuxer",n),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,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:n}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:r,video:a}=this.initData=lL(e);if(t)dU(e,t);else{const c=r||a;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}r&&(i=jw(r,ws.AUDIO,this)),a&&(n=jw(a,ws.VIDEO,this));const u={};r&&a?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:a?u.video={container:"video/mp4",codec:n,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}remux(e,t,i,n,r,a){var u,c;let{initPTS:d,lastEndTime:f}=this;const g={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};Ot(f)||(f=this.lastEndTime=r||0);const y=t.samples;if(!y.length)return g;const v={initPTS:void 0,timescale:void 0,trackId:void 0};let T=this.initData;if((u=T)!=null&&u.length||(this.generateInitSegment(y),T=this.initData),!((c=T)!=null&&c.length))return this.warn("Failed to generate initSegment."),g;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);const S=fU(y,T,this),w=T.audio?S[T.audio.id]:null,L=T.video?S[T.video.id]:null,O=Fm(L,1/0),I=Fm(w,1/0),j=Fm(L,0,!0),P=Fm(w,0,!0);let G=r,N=0;const K=w&&(!L||!d&&I<O||d&&d.trackId===T.audio.id),k=K?w:L;if(k){const Z=k.timescale,te=k.start-r*Z,oe=K?T.audio.id:T.video.id;G=k.start/Z,N=K?P-I:j-O,(a||!d)&&(w7(d,G,r,N)||Z!==d.timescale)&&(d&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${r} ${te/Z} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${G-r} (${te}/${Z}) trackId: ${oe}`),d=null,v.initPTS=te,v.timescale=Z,v.trackId=oe)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);d?(v.initPTS=d.baseTime,v.timescale=d.timescale,v.trackId=d.trackId):((!v.timescale||v.trackId===void 0||v.initPTS===void 0)&&(this.warn("Could not set initPTS"),v.initPTS=G,v.timescale=1,v.trackId=-1),this.initPTS=d={baseTime:v.initPTS,timescale:v.timescale,trackId:v.trackId});const R=G-d.baseTime/d.timescale,Y=R+N;N>0?this.lastEndTime=Y:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const z=!!T.audio,X=!!T.video;let re="";z&&(re+="audio"),X&&(re+="video");const J=(T.audio?T.audio.encrypted:!1)||(T.video?T.video.encrypted:!1),W={data1:y,startPTS:R,startDTS:R,endPTS:Y,endDTS:Y,type:re,hasAudio:z,hasVideo:X,nb:1,dropped:0,encrypted:J};g.audio=z&&!X?W:void 0,g.video=X?W:void 0;const q=L?.sampleCount;if(q){const Z=L.keyFrameIndex,te=Z!==-1;W.nb=q,W.dropped=Z===0||this.isVideoContiguous?0:te?Z:q,W.independent=te,W.firstKeyFrame=Z,te&&L.keyFrameStart&&(W.firstKeyFramePTS=(L.keyFrameStart-d.baseTime)/d.timescale),this.isVideoContiguous||(g.independent=te),this.isVideoContiguous||(this.isVideoContiguous=te),W.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${Z}/${q} dropped: ${W.dropped} start: ${W.firstKeyFramePTS||"NA"}`)}return g.initSegment=v,g.id3=tR(i,r,d,d),n.samples.length&&(g.text=iR(n,r,d)),g}}function Fm(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function w7(s,e,t,i){if(s===null)return!0;const n=Math.max(i,1),r=e-s.baseTime/s.timescale;return Math.abs(r-t)>n}function jw(s,e,t){const i=s.codec;return i&&i.length>4?i:e===ws.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?H0(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let Eo;try{Eo=self.performance.now.bind(self.performance)}catch{Eo=Date.now}const o0=[{demux:c7,remux:E7},{demux:Sl,remux:a0},{demux:a7,remux:a0},{demux:l7,remux:a0}];o0.splice(2,0,{demux:o7,remux:a0});class $w{constructor(e,t,i,n,r,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=r,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const r=i.transmuxing;r.executeStart=Eo();let a=new Uint8Array(e);const{currentTransmuxState:u,transmuxConfig:c}=this;n&&(this.currentTransmuxState=n);const{contiguous:d,discontinuity:f,trackSwitch:g,accurateTimeOffset:y,timeOffset:v,initSegmentChange:T}=n||u,{audioCodec:S,videoCodec:w,defaultInitPts:L,duration:O,initSegmentData:I}=c,j=A7(a,t);if(j&&Lc(j.method)){const K=this.getDecrypter(),k=c1(j.method);if(K.isSync()){let R=K.softwareDecrypt(a,j.key.buffer,j.iv.buffer,k);if(i.part>-1){const z=K.flush();R=z&&z.buffer}if(!R)return r.executeEnd=Eo(),Pv(i);a=new Uint8Array(R)}else return this.asyncResult=!0,this.decryptionPromise=K.webCryptoDecrypt(a,j.key.buffer,j.iv.buffer,k).then(R=>{const Y=this.push(R,null,i);return this.decryptionPromise=null,Y}),this.decryptionPromise}const P=this.needsProbing(f,g);if(P){const K=this.configureTransmuxer(a);if(K)return this.logger.warn(`[transmuxer] ${K.message}`),this.observer.emit(H.ERROR,H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_PARSING_ERROR,fatal:!1,error:K,reason:K.message}),r.executeEnd=Eo(),Pv(i)}(f||g||T||P)&&this.resetInitSegment(I,S,w,O,t),(f||T||P)&&this.resetInitialTimestamp(L),d||this.resetContiguity();const G=this.transmux(a,j,v,y,i);this.asyncResult=Vh(G);const N=this.currentTransmuxState;return N.contiguous=!0,N.discontinuity=!1,N.trackSwitch=!1,r.executeEnd=Eo(),G}flush(e){const t=e.transmuxing;t.executeStart=Eo();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const a=[],{timeOffset:u}=n;if(i){const g=i.flush();g&&a.push(this.push(g.buffer,null,e))}const{demuxer:c,remuxer:d}=this;if(!c||!d){t.executeEnd=Eo();const g=[Pv(e)];return this.asyncResult?Promise.resolve(g):g}const f=c.flush(u);return Vh(f)?(this.asyncResult=!0,f.then(g=>(this.flushRemux(a,g,e),a))):(this.flushRemux(a,f,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:r,id3Track:a,textTrack:u}=t,{accurateTimeOffset:c,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===jt.MAIN?"level":"track"} ${i.level}`);const f=this.remuxer.remux(n,r,a,u,d,c,!0,this.id);e.push({remuxResult:f,chunkMeta:i}),i.transmuxing.executeEnd=Eo()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,n,r){const{demuxer:a,remuxer:u}=this;!a||!u||(a.resetInitSegment(e,t,i,n),u.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,n,r){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,n,r):a=this.transmuxUnencrypted(e,i,n,r),a}transmuxUnencrypted(e,t,i,n){const{audioTrack:r,videoTrack:a,id3Track:u,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,a,u,c,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,r){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,n,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:n}=this;let r;for(let g=0,y=o0.length;g<y;g++){var a;if((a=o0[g].demux)!=null&&a.probe(e,this.logger)){r=o0[g];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const u=this.demuxer,c=this.remuxer,d=r.remux,f=r.demux;(!c||!(c instanceof d))&&(this.remuxer=new d(i,t,n,this.logger)),(!u||!(u instanceof f))&&(this.demuxer=new f(i,t,n,this.logger),this.probe=f.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new l1(this.config)),e}}function A7(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Pv=s=>({remuxResult:{},chunkMeta:s});function Vh(s){return"then"in s&&s.then instanceof Function}class k7{constructor(e,t,i,n,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=n,this.defaultInitPts=r||null}}class C7{constructor(e,t,i,n,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=a}}let Hw=0;class sR{constructor(e,t,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Hw++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=c=>{const d=c.data,f=this.hls;if(!(!f||!(d!=null&&d.event)||d.instanceNo!==this.instanceNo))switch(d.event){case"init":{var g;const y=(g=this.workerContext)==null?void 0:g.objectURL;y&&self.URL.revokeObjectURL(y);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":{f.logger[d.data.logType]&&f.logger[d.data.logType](d.data.message);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.part=this.part,d.data.id=this.id,f.trigger(d.event,d.data);break}}},this.onWorkerError=c=>{if(!this.hls)return;const d=new Error(`${c.message} (${c.filename}:${c.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:d})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const a=(c,d)=>{d=d||{},d.frag=this.frag||void 0,c===H.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(c,d)};this.observer=new f1,this.observer.on(H.FRAG_DECRYPTED,a),this.observer.on(H.ERROR,a);const u=sw(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(r.workerPath||Ij()){try{r.workerPath?(c.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=Oj(r.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=Nj());const{worker:f}=this.workerContext;f.addEventListener("message",this.onWorkerMessage),f.addEventListener("error",this.onWorkerError),f.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:t,config:ks(r)})}catch(f){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,f),this.terminateWorker(),this.error=null,this.transmuxer=new $w(this.observer,u,r,"",t,e.logger)}return}}this.transmuxer=new $w(this.observer,u,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Hw++;const t=this.hls.config,i=sw(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:ks(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),Mj(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,n,r,a,u,c,d,f){var g,y;d.transmuxing.start=self.performance.now();const{instanceNo:v,transmuxer:T}=this,S=a?a.start:r.start,w=r.decryptdata,L=this.frag,O=!(L&&r.cc===L.cc),I=!(L&&d.level===L.level),j=L?d.sn-L.sn:-1,P=this.part?d.part-this.part.index:-1,G=j===0&&d.id>1&&d.id===L?.stats.chunkCount,N=!I&&(j===1||j===0&&(P===1||G&&P<=0)),K=self.performance.now();(I||j||r.stats.parsing.start===0)&&(r.stats.parsing.start=K),a&&(P||!N)&&(a.stats.parsing.start=K);const k=!(L&&((g=r.initSegment)==null?void 0:g.url)===((y=L.initSegment)==null?void 0:y.url)),R=new C7(O,N,c,I,S,k);if(!N||O||k){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id===jt.MAIN?"level":"track"}: ${d.level} id: ${d.id}
discontinuity: ${O}
trackSwitch: ${I}
contiguous: ${N}
accurateTimeOffset: ${c}
timeOffset: ${S}
initSegmentChange: ${k}`);const Y=new k7(i,n,t,u,f);this.configureTransmuxer(Y)}if(this.frag=r,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:v,cmd:"demux",data:e,decryptdata:w,chunkMeta:d,state:R},e instanceof ArrayBuffer?[e]:[]);else if(T){const Y=T.push(e,w,d,R);Vh(Y)?Y.then(z=>{this.handleTransmuxComplete(z)}).catch(z=>{this.transmuxerError(z,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(Y)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const n=i.flush(e);Vh(n)?n.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const zw=100;class D7 extends h1{constructor(e,t,i){super(e,t,i,"audio-stream-controller",jt.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(H.LEVEL_LOADED,this.onLevelLoaded,this),e.on(H.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(H.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(H.BUFFER_RESET,this.onBufferReset,this),e.on(H.BUFFER_CREATED,this.onBufferCreated,this),e.on(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(H.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(H.FRAG_LOADING,this.onFragLoading,this),e.on(H.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(H.LEVEL_LOADED,this.onLevelLoaded,this),e.off(H.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(H.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(H.BUFFER_RESET,this.onBufferReset,this),e.off(H.BUFFER_CREATED,this.onBufferCreated,this),e.off(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(H.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(H.FRAG_LOADING,this.onFragLoading,this),e.off(H.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:a}){if(i===jt.MAIN){const u=t.cc,c=this.fragCurrent;if(this.initPTS[u]={baseTime:n,timescale:r,trackId:a},this.log(`InitPTS for cc: ${u} found from main: ${n/r} (${n}/${r}) trackId: ${a}`),this.mainAnchor=t,this.state===ot.WAITING_INIT_PTS){const d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==u)&&this.syncWithAnchor(t,d?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==u?(c.abortRequests(),this.syncWithAnchor(t,c)):this.state===ot.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const n=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&n?.cc===t.cc)return;const r=(n||e).cc,a=this.getLevelDetails(),u=this.getLoadPosition(),c=xL(a,r,u);c&&(this.log(`Syncing with main frag at ${c.start} cc ${c.cc}`),this.startFragRequested=!1,this.nextLoadPosition=c.start,this.resetLoadingState(),this.state===ot.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=ot.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(zw),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=ot.IDLE):this.state=ot.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case ot.IDLE:this.doTickIdle();break;case ot.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],n=i?.details;if(n&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(n))break;this.state=ot.WAITING_INIT_PTS}break}case ot.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case ot.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:n,complete:r}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=ot.FRAG_LOADING;const u=n.flush().buffer,c={frag:t,part:i,payload:u,networkDetails:null};this._handleFragmentLoadProgress(c),r&&super._handleFragmentLoadComplete(c)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=ot.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:n,trackId:r}=this,a=t.config;if(!this.buffering||!n&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[r]))return;const u=i[r],c=u.details;if(!c||this.waitForLive(u)||this.waitForCdnTuneIn(c)){this.state=ot.WAITING_TRACK,this.startFragRequested=!1;return}const d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,ws.AUDIO,jt.AUDIO));const f=this.getFwdBufferInfo(d,jt.AUDIO);if(f===null)return;if(!this.switchingTrack&&this._streamEnded(f,c)){t.trigger(H.BUFFER_EOS,{type:"audio"}),this.state=ot.ENDED;return}const g=f.len,y=t.maxBufferLength,v=c.fragments,T=v[0].start,S=this.getLoadPosition(),w=this.flushing?S:f.end;if(this.switchingTrack&&n){const I=S;c.PTSKnown&&I<T&&(f.end>T||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=T+.05)}if(g>=y&&!this.switchingTrack&&w<v[v.length-1].start)return;let L=this.getNextFragment(w,c);if(L&&this.isLoopLoading(L,w)&&(L=this.getNextFragmentLoopLoading(L,c,f,jt.MAIN,y)),!L){this.bufferFlushed=!0;return}let O=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&O&&an(L)&&!L.endList&&(!c.live||!this.loadingParts&&w<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(O)===Sn.OK&&(this.mainFragLoading=O=null),O&&an(O))){if(L.start>O.end){const j=this.fragmentTracker.getFragAtPos(w,jt.MAIN);j&&j.end>O.end&&(O=j,this.mainFragLoading={frag:j,targetBufferTime:null})}if(L.start>O.end)return}this.loadFragment(L,u,w)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new $h(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==ot.STOPPED&&(this.setInterval(zw),this.state=ot.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(H.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:n}=this,{details:r,id:a,groupId:u,track:c}=t;if(!n){this.warn(`Audio tracks reset while loading track ${a} "${c.name}" of "${u}"`);return}const d=this.mainDetails;if(!d||r.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==ot.STOPPED&&(this.state=ot.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${c.name}" of "${u}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const f=n[a];let g=0;if(r.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(f.details){var y;g=this.alignPlaylists(r,f.details,(y=this.levelLastLoaded)==null?void 0:y.details)}r.alignedSliding||(BL(r,d),r.alignedSliding||Y0(r,d),g=r.fragmentStart)}f.details=r,this.levelLastLoaded=f,this.startFragRequested||this.setStartPosition(d,g),this.hls.trigger(H.AUDIO_TRACK_UPDATED,{details:r,id:a,groupId:t.groupId}),this.state===ot.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=ot.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{config:a,trackId:u,levels:c}=this;if(!c){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const d=c[u];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const f=d.details;if(!f){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const g=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let y=this.transmuxer;y||(y=this.transmuxer=new sR(this.hls,jt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const v=this.initPTS[i.cc],T=(t=i.initSegment)==null?void 0:t.data;if(v!==void 0){const w=n?n.index:-1,L=w!==-1,O=new u1(i.level,i.sn,i.stats.chunkCount,r.byteLength,w,L);y.push(r,T,g,"",i,n,f.totalduration,!1,O,v)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${f.startSN} ,${f.endSN}],track ${u}`);const{cache:S}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new FL,complete:!1};S.push(new Uint8Array(r)),this.state!==ot.STOPPED&&(this.state=ot.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===jt.MAIN&&an(t.frag)&&(this.mainFragLoading=t,this.state===ot.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==jt.AUDIO){!this.audioOnly&&i.type===jt.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(an(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(H.AUDIO_TRACK_SWITCHED,us({},r)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=ot.ERROR;return}switch(t.details){case $e.FRAG_GAP:case $e.FRAG_PARSING_ERROR:case $e.FRAG_DECRYPT_ERROR:case $e.FRAG_LOAD_ERROR:case $e.FRAG_LOAD_TIMEOUT:case $e.KEY_LOAD_ERROR:case $e.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(jt.AUDIO,t);break;case $e.AUDIO_TRACK_LOAD_ERROR:case $e.AUDIO_TRACK_LOAD_TIMEOUT:case $e.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===ot.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Ii.AUDIO_TRACK&&(this.state=ot.IDLE);break;case $e.BUFFER_ADD_CODEC_ERROR:case $e.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case $e.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case $e.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ws.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ws.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===ot.ENDED&&(this.state=ot.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,jt.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:a}=e,u=this.getCurrentContext(a);if(!u){this.resetWhenMissingContext(a);return}const{frag:c,part:d,level:f}=u,{details:g}=f,{audio:y,text:v,id3:T,initSegment:S}=r;if(this.fragContextChanged(c)||!g){this.fragmentTracker.removeFragment(c);return}if(this.state=ot.PARSING,this.switchingTrack&&y&&this.completeAudioSwitch(this.switchingTrack),S!=null&&S.tracks){const w=c.initSegment||c;if(this.unhandledEncryptionError(S,c))return;this._bufferInitSegment(f,S.tracks,w,a),n.trigger(H.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:i,tracks:S.tracks})}if(y){const{startPTS:w,endPTS:L,startDTS:O,endDTS:I}=y;d&&(d.elementaryStreams[ws.AUDIO]={startPTS:w,endPTS:L,startDTS:O,endDTS:I}),c.setElementaryStreamInfo(ws.AUDIO,w,L,O,I),this.bufferFragmentData(y,c,d,a)}if(T!=null&&(t=T.samples)!=null&&t.length){const w=ys({id:i,frag:c,details:g},T);n.trigger(H.FRAG_PARSING_METADATA,w)}if(v){const w=ys({id:i,frag:c,details:g},v);n.trigger(H.FRAG_PARSING_USERDATA,w)}}_bufferInitSegment(e,t,i,n){if(this.state!==ot.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=jt.AUDIO;const a=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${a}/${r.codec}]`),a&&a.split(",").length===1&&(r.levelCodec=a),this.hls.trigger(H.BUFFER_CODECS,t);const u=r.initSegment;if(u!=null&&u.byteLength){const c={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:u};this.hls.trigger(H.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.switchingTrack||n===Sn.NOT_LOADED||n===Sn.PARTIAL){var r;if(!an(e))this._loadInitSegment(e,t);else if((r=t.details)!=null&&r.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=ot.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&Y0(t.details,a)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:n,characteristics:r,audioCodec:a,channels:u}=this.bufferedTrack;bu({name:t,lang:i,assocLang:n,characteristics:r,audioCodec:a,channels:u},e,uu)||(V0(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(H.AUDIO_TRACK_SWITCHED,us({},e))}}class b1 extends ra{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const n=t?.renditionReports;if(n){let r=-1;for(let a=0;a<n.length;a++){const u=n[a];let c;try{c=new self.URL(u.URI,t.url).href}catch(d){this.warn(`Could not construct new URL for Rendition Report: ${d}`),c=u.URI||""}if(c===e){r=a;break}else c===e.substring(0,c.length)&&(r=a)}if(r!==-1){const a=n[r],u=parseInt(a["LAST-MSN"])||t.lastPartSn;let c=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const f=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&f>t.partTarget&&(c+=1)}const d=i&&nw(i);return new rw(u,c>=0?c:void 0,d)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:n,stats:r}=t,a=self.performance.now(),u=r.loading.first?Math.max(0,a-r.loading.first):0;n.advancedDateTime=Date.now()-u;const c=this.hls.config.timelineOffset;if(c!==n.appliedTimelineOffset){const f=Math.max(c||0,0);n.appliedTimelineOffset=f,n.fragments.forEach(g=>{g.setStart(g.playlistOffset+f)})}if(n.live||i!=null&&i.live){const f="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){Tj(i,n,this);const O=n.playlistParsingError;if(O){this.warn(O);const I=this.hls;if(!I.config.ignorePlaylistParsingErrors){var d;const{networkDetails:j}=t;I.trigger(H.ERROR,{type:Vt.NETWORK_ERROR,details:$e.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:O,reason:O.message,level:t.level||void 0,parent:(d=n.fragments[0])==null?void 0:d.type,networkDetails:j,stats:r});return}n.playlistParsingError=null}}n.requestScheduled===-1&&(n.requestScheduled=r.loading.start);const g=this.hls.mainForwardBufferInfo,y=g?g.end-g.len:0,v=(n.edge-y)*1e3,T=IL(n,v);if(n.requestScheduled+T<a?n.requestScheduled=a:n.requestScheduled+=T,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;let S,w,L;if(n.canBlockReload&&n.endSN&&n.advanced){const O=this.hls.config.lowLatencyMode,I=n.lastPartSn,j=n.endSN,P=n.lastPartIndex,G=P!==-1,N=I===j;G?N?(w=j+1,L=O?0:P):(w=I,L=O?P+1:n.maxPartIndex):w=j+1;const K=n.age,k=K+n.ageHeader;let R=Math.min(k-n.partTarget,n.targetduration*1.5);if(R>0){if(k>n.targetduration*3)this.log(`Playlist last advanced ${K.toFixed(2)}s ago. Omitting segment and part directives.`),w=void 0,L=void 0;else if(i!=null&&i.tuneInGoal&&k-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${R} with playlist age: ${n.age}`),R=0;else{const Y=Math.floor(R/n.targetduration);if(w+=Y,L!==void 0){const z=Math.round(R%n.targetduration/n.partTarget);L+=z}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${K.toFixed(2)}s goal: ${R} skip sn ${Y} to part ${L}`)}n.tuneInGoal=R}if(S=this.getDeliveryDirectives(n,t.deliveryDirectives,w,L),O||!N){n.requestScheduled=a,this.loadingPlaylist(f,S);return}}else(n.canBlockReload||n.canSkipUntil)&&(S=this.getDeliveryDirectives(n,t.deliveryDirectives,w,L));S&&w!==void 0&&n.canBlockReload&&(n.requestScheduled=r.loading.first+Math.max(T-u*2,T/2)),this.scheduleLoading(f,S,n)}else this.clearTimer()}scheduleLoading(e,t,i){const n=i||e.details;if(!n){this.loadingPlaylist(e,t);return}const r=self.performance.now(),a=n.requestScheduled;if(r>=a){this.loadingPlaylist(e,t);return}const u=a-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(u)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),u)}getDeliveryDirectives(e,t,i,n){let r=nw(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,r=n0.No),new rw(i,n,r)}checkRetry(e){const t=e.details,i=G0(e),n=e.errorAction,{action:r,retryCount:a=0,retryConfig:u}=n||{},c=!!n&&!!u&&(r===$n.RetryRequest||!n.resolved&&r===$n.SendAlternateToPenaltyBox);if(c){var d;if(a>=u.maxNumRetry)return!1;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const f=o1(u,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),f),this.warn(`Retrying playlist loading ${a+1}/${u.maxNumRetry} after "${t}" in ${f}ms`)}e.levelRetry=!0,n.resolved=!0}return c}}function nR(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Gh(s[t].attrs,e[t].attrs))return!1;return!0}function Gh(s,e,t){const i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(n=>s[n]!==e[n])}function Jx(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}class L7 extends b1{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.LEVEL_LOADING,this.onLevelLoading,this),e.on(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(H.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.LEVEL_LOADING,this.onLevelLoading,this),e.off(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(H.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(H.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:n,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==n){this.warn(`Audio track with id:${i} and group:${n} not found in active group ${a?.groupId}`);return}const u=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,u)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||n?.length!==i?.length||i!=null&&i.some(u=>n?.indexOf(u)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const u=this.tracks.filter(y=>!i||i.indexOf(y.groupId)!==-1);if(u.length)this.selectDefaultTrack&&!u.some(y=>y.default)&&(this.selectDefaultTrack=!1),u.forEach((y,v)=>{y.id=v});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=u;const c=this.hls.config.audioPreference;if(!r&&c){const y=Ga(c,u,uu);if(y>-1)r=u[y];else{const v=Ga(c,this.tracks);r=this.tracks[v]}}let d=this.findTrackId(r);d===-1&&r&&(d=this.findTrackId(null));const f={audioTracks:u};this.log(`Updating audio tracks, ${u.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(H.AUDIO_TRACKS_UPDATED,f);const g=this.trackId;if(d!==-1&&g===-1)this.setAudioTrack(d);else if(u.length&&g===-1){var a;const y=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${u.length}`);this.warn(y.message),this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:y})}}}onError(e,t){t.fatal||!t.context||t.context.type===Ii.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const n=this.currentTrack;if(n&&bu(e,n,uu))return n;const r=Ga(e,this.tracksInGroup,uu);if(r>-1){const a=this.tracksInGroup[r];return this.setAudioTrack(r),a}else if(n){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const u=HU(e,t.levels,i,a,uu);if(u===-1)return null;t.nextLoadLevel=u}if(e.channels||e.audioCodec){const a=Ga(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,n=t[e],r=n.details&&!n.details.live;if(e===this.trackId&&n===i&&r||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(H.AUDIO_TRACK_SWITCHING,us({},n)),r))return;const a=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(!(this.selectDefaultTrack&&!n.default)&&(!e||bu(e,n,uu)))return i}if(e){const{name:i,lang:n,assocLang:r,characteristics:a,audioCodec:u,channels:c}=e;for(let d=0;d<t.length;d++){const f=t[d];if(bu({name:i,lang:n,assocLang:r,characteristics:a,audioCodec:u,channels:c},f,uu))return d}for(let d=0;d<t.length;d++){const f=t[d];if(Gh(e.attrs,f.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const f=t[d];if(Gh(e.attrs,f.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&V0(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,n=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,u=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${u&&a.live?" age "+u.toFixed(1)+(a.type&&" "+a.type||""):""} ${r}`),this.hls.trigger(H.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}}class R7{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const n=this.queues[t];n.push(e),n.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const n=t[0];try{n.execute()}catch(r){var i;if(n.onError(r),this.queues===null||this.tracks===null)return;const a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
${this.list("video")}
${this.list("audio")}
${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],n=i?.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const Vw=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,rR="HlsJsTrackRemovedError";class I7 extends Error{constructor(e){super(e),this.name=rR}}class N7 extends ra{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var n;this.hls&&((n=this.mediaSource)==null?void 0:n.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:n,mediaSource:r}=this;i&&this.log("Media source opened"),!(!n||!r)&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(H.MEDIA_ATTACHED,{media:n,mediaSource:r}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:n}=this;i!==n&&this.error(`Media element src was set while attaching MediaSource (${n} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=tU(Ll(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.BUFFER_RESET,this.onBufferReset,this),e.on(H.BUFFER_APPENDING,this.onBufferAppending,this),e.on(H.BUFFER_CODECS,this.onBufferCodecs,this),e.on(H.BUFFER_EOS,this.onBufferEos,this),e.on(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(H.FRAG_PARSED,this.onFragParsed,this),e.on(H.FRAG_CHANGED,this.onFragChanged,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.BUFFER_RESET,this.onBufferReset,this),e.off(H.BUFFER_APPENDING,this.onBufferAppending,this),e.off(H.BUFFER_CODECS,this.onBufferCodecs,this),e.off(H.BUFFER_EOS,this.onBufferEos,this),e.off(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(H.FRAG_PARSED,this.onFragParsed,this),e.off(H.FRAG_CHANGED,this.onFragChanged,this),e.off(H.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const r=this.isUpdating();r||this.operationQueue.removeBlockers();const a=this.isQueued();(r||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const n=this.transferData;return!this.sourceBufferCount&&n&&n.mediaSource===t?ys(i,n.tracks):this.sourceBuffers.forEach(r=>{const[a]=r;a&&(i[a]=ys({},this.tracks[a]),this.removeBuffer(a)),r[0]=r[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const n=Ll(this.appendSource);if(n){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(a),r)this._objectUrl=i.src,this.attachTransferred();else{const u=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");const c=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||c&&a instanceof c,Gw(i),O7(i,u),i.load()}catch{i.src=u}else i.src=u}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,n=t.tracks,r=n?Object.keys(n):null,a=r?r.length:0,u=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&r&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
required tracks: ${ks(i,(c,d)=>c==="initSegment"?void 0:d)};
transfer tracks: ${ks(n,(c,d)=>c==="initSegment"?void 0:d)}}`),!tL(n,i)){t.mediaSource=null,t.tracks=void 0;const c=e.currentTime,d=this.details,f=Math.max(c,d?.fragments[0].start||0);if(f-c>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${f}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${f} currentTime: ${c}`),this.onMediaDetaching(H.MEDIA_DETACHING,{}),this.onMediaAttaching(H.MEDIA_ATTACHING,t),e.currentTime=f;return}this.transferData=void 0,r.forEach(c=>{const d=c,f=n[d];if(f){const g=f.buffer;if(g){const y=this.fragmentTracker,v=f.id;if(y.hasFragments(v)||y.hasParts(v)){const w=gi.getBuffered(g);y.detectEvictedFragments(d,w,v,null,!0)}const T=Bv(d),S=[d,g];this.sourceBuffers[T]=S,g.updating&&this.operationQueue&&this.operationQueue.prependBlocker(d),this.trackSourceBuffer(d,f)}}}),u(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),u()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:n,mediaSource:r,_objectUrl:a}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([u])=>{u&&this.removeBuffer(u)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const u=r.readyState==="open";try{const c=r.sourceBuffers;for(let d=c.length;d--;)u&&c[d].abort(),r.removeSourceBuffer(c[d]);u&&r.endOfStream()}catch(c){this.warn(`onMediaDetaching: ${c.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(n.removeAttribute("src"),this.appendSource&&Gw(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(H.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;(n=this.mediaSource)!=null&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(r){this.warn(`onBufferReset ${e}`,r)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Bv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new R7(this.tracks)}onBufferCodecs(e,t){var i;const n=this.tracks,r=Object.keys(t);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),u=!a&&this.sourceBufferCount&&this.media&&r.some(c=>!n[c]);if(a||u){this.warn(`Unsupported transition between "${Object.keys(n)}" and "${r}" SourceBuffers`);return}r.forEach(c=>{var d,f;const g=t[c],{id:y,codec:v,levelCodec:T,container:S,metadata:w,supplemental:L}=g;let O=n[c];const I=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[c],j=I!=null&&I.buffer?I:O,P=j?.pendingCodec||j?.codec,G=j?.levelCodec;O||(O=n[c]={buffer:void 0,listeners:[],codec:v,supplemental:L,container:S,levelCodec:T,metadata:w,id:y});const N=s0(P,G),K=N?.replace(Vw,"$1");let k=s0(v,T);const R=(f=k)==null?void 0:f.replace(Vw,"$1");k&&N&&K!==R&&(c.slice(0,5)==="audio"&&(k=H0(k,this.appendSource)),this.log(`switching codec ${P} to ${k}`),k!==(O.pendingCodec||O.codec)&&(O.pendingCodec=k),O.container=S,this.appendChangeType(c,S,k))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const n=`${t};codecs=${i}`,r={label:`change-type=${n}`,execute:()=>{const a=this.tracks[e];if(a){const u=a.buffer;u!=null&&u.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),u.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,n=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,jt.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var u;const c=this.tracks.video;(this.lastVideoAppendEnd>n||c!=null&&c.buffer&&gi.isBuffered(c.buffer,n)||((u=this.fragmentTracker.getAppendedFrag(n,jt.MAIN))==null?void 0:u.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:u=>{this.warn("Error executing block-audio operation",u)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:n,type:r,parent:a,frag:u,part:c,chunkMeta:d,offset:f}=t,g=d.buffering[r],{sn:y,cc:v}=u,T=self.performance.now();g.start=T;const S=u.stats.buffering,w=c?c.stats.buffering:null;S.start===0&&(S.start=T),w&&w.start===0&&(w.start=T);const L=i.audio;let O=!1;r==="audio"&&L?.container==="audio/mpeg"&&(O=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const I=i.video,j=I?.buffer;if(j&&y!=="initSegment"){const N=c||u,K=this.blockedAudioAppend;if(r==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(I.ending||I.ended)){const R=N.start+N.duration*.05,Y=j.buffered,z=this.currentOp("video");!Y.length&&!z?this.blockAudio(N):!z&&!gi.isBuffered(j,R)&&this.lastVideoAppendEnd<R&&this.blockAudio(N)}else if(r==="video"){const k=N.end;if(K){const R=K.frag.start;(k>R||k<this.lastVideoAppendEnd||gi.isBuffered(j,R))&&this.unblockAudio()}this.lastVideoAppendEnd=k}}const P=(c||u).start,G={label:`append-${r}`,execute:()=>{var N;g.executeStart=self.performance.now();const K=(N=this.tracks[r])==null?void 0:N.buffer;K&&(O?this.updateTimestampOffset(K,P,.1,r,y,v):f!==void 0&&Ot(f)&&this.updateTimestampOffset(K,f,1e-6,r,y,v)),this.appendExecutor(n,r)},onStart:()=>{},onComplete:()=>{const N=self.performance.now();g.executeEnd=g.end=N,S.first===0&&(S.first=N),w&&w.first===0&&(w.first=N);const K={};this.sourceBuffers.forEach(([k,R])=>{k&&(K[k]=gi.getBuffered(R))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(H.BUFFER_APPENDED,{type:r,frag:u,part:c,chunkMeta:d,parent:u.type,timeRanges:K})},onError:N=>{var K;const k={type:Vt.MEDIA_ERROR,parent:u.type,details:$e.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:u,part:c,chunkMeta:d,error:N,err:N,fatal:!1},R=(K=this.media)==null?void 0:K.error;if(N.code===DOMException.QUOTA_EXCEEDED_ERR||N.name=="QuotaExceededError"||"quota"in N)k.details=$e.BUFFER_FULL_ERROR;else if(N.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!R)k.errorAction=Dc(!0);else if(N.name===rR&&this.sourceBufferCount===0)k.errorAction=Dc(!0);else{const Y=++this.appendErrors[r];this.warn(`Failed ${Y}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${R||"no media error"})`),(Y>=this.hls.config.appendErrorMaxRetry||R)&&(k.fatal=!0)}this.hls.trigger(H.ERROR,k)}};this.log(`queuing "${r}" append sn: ${y}${c?" p: "+c.index:""} of ${u.type===jt.MAIN?"level":"track"} ${u.level} cc: ${v}`),this.append(G,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(H.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}onBufferFlushing(e,t){const{type:i,startOffset:n,endOffset:r}=t;i?this.append(this.getFlushOp(i,n,r),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,n,r),a)})}onFragParsed(e,t){const{frag:i,part:n}=t,r=[],a=n?n.elementaryStreams:i.elementaryStreams;a[ws.AUDIOVIDEO]?r.push("audiovideo"):(a[ws.AUDIO]&&r.push("audio"),a[ws.VIDEO]&&r.push("video"));const u=()=>{const c=self.performance.now();i.stats.buffering.end=c,n&&(n.stats.buffering.end=c);const d=n?n.stats:i.stats;this.hls.trigger(H.FRAG_BUFFERED,{frag:i,part:n,stats:d,id:i.type})};r.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(u,r).catch(c=>{this.warn(`Fragment buffered callback ${c}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){const u=this.tracks[a];(!t.type||t.type===a)&&(u.ending=!0,u.ended||(u.ended=!0,this.log(`${a} buffer reached EOS`)))}});const n=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var u;return a&&!((u=this.tracks[a])!=null&&u.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(H.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(H.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===$e.BUFFER_APPEND_ERROR&&t.frag){var i;const n=(i=t.errorAction)==null?void 0:i.nextAutoLevel;Ot(n)&&n!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const n=e.config,r=i.currentTime,a=t.levelTargetDuration,u=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(Ot(u)&&u>=0){const d=Math.max(u,a),f=Math.floor(r/a)*a-d;this.flushBackBuffer(r,a,f)}const c=n.frontBufferFlushThreshold;if(Ot(c)&&c>0){const d=Math.max(n.maxBufferLength,c),f=Math.max(d,a),g=Math.floor(r/a)*a+f;this.flushFrontBuffer(r,a,g)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const u=gi.getBuffered(r);if(u.length>0&&i>u.start(0)){var a;this.hls.trigger(H.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[n];if((a=this.details)!=null&&a.live)this.hls.trigger(H.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended){this.log(`Cannot flush ${n} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(H.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const a=gi.getBuffered(r),u=a.length;if(u<2)return;const c=a.start(u-1),d=a.end(u-1);if(i>c||e>=c&&e<=d)return;this.hls.trigger(H.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:n})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const d=Math.max(0,t.fragmentStart),f=Math.max(d,n);return{duration:1/0,start:d,end:f}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return Ot(r)?{duration:r}:null;const a=this.media.duration,u=Ot(i.duration)?i.duration:0;return n>u&&n>a||!Ot(a)?{duration:n}:null}updateMediaSource({duration:e,start:t,end:i}){const n=this.mediaSource;!this.media||!n||n.readyState!=="open"||(n.duration!==e&&(Ot(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${ks(i)}`),this.tracksReady){var n;const r=(n=this.transferData)==null?void 0:n.tracks;r&&Object.keys(r).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(H.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const a=r,u=e[a];if(this.isPending(u)){const c=this.getTrackCodec(u,a),d=`${u.container};codecs=${c}`;u.codec=c,this.log(`creating sourceBuffer(${d})${this.currentOp(a)?" Queued":""} ${ks(u)}`);try{const f=i.addSourceBuffer(d),g=Bv(a),y=[a,f];t[g]=y,u.buffer=f}catch(f){var n;this.error(`error while trying to add sourceBuffer: ${f.message}`),this.shiftAndExecuteNext(a),(n=this.operationQueue)==null||n.removeBlockers(),delete this.tracks[a],this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,sourceBufferName:a,mimeType:d,parent:u.id});return}this.trackSourceBuffer(a,u)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let n=e.codec;i&&(t==="video"||t==="audiovideo")&&Uh(i,"video")&&(n=_U(n,i));const r=s0(n,e.levelCodec);return r?t.slice(0,5)==="audio"?H0(r,this.appendSource):r:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(r,a)=>{const u=a.removedRanges;u!=null&&u.length&&this.hls.trigger(H.BUFFER_FLUSHED,{type:r})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const r=this.currentOp(e);r&&r.onError(n)}updateTimestampOffset(e,t,i,n,r,a){const u=t-e.timestampOffset;Math.abs(u)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:n,mediaSource:r}=this,a=this.tracks[e],u=a?.buffer;if(!n||!r||!u){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const c=Ot(n.duration)?n.duration:1/0,d=Ot(r.duration)?r.duration:1/0,f=Math.max(0,t),g=Math.min(i,c,d);g>f&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${f},${g}] from the ${e} SourceBuffer`),u.remove(f,g)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],n=i?.buffer;if(!n)throw new I7(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,n=t.map(a=>this.appendBlocker(a));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const n=(i=this.tracks[t])==null?void 0:i.buffer;!n||n.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const n=this.tracks[e];if(!n)return;const r=n.buffer;if(!r)return;const a=i.bind(this,e);n.listeners.push({event:t,listener:a}),r.addEventListener(t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(n=>{i.removeEventListener(n.event,n.listener)}),t.listeners.length=0)}}function Gw(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function O7(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function Bv(s){return s==="audio"?1:0}class T1{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.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(H.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(H.BUFFER_CODECS,this.onBufferCodecs,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(H.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(H.BUFFER_CODECS,this.onBufferCodecs,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Ot(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((n,r)=>this.isLevelAllowed(n)&&r<=e);return this.clientRect=null,T1.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const n=(u,c)=>c?u.width!==c.width||u.height!==c.height:!0;let r=e.length-1;const a=Math.max(t,i);for(let u=0;u<e.length;u+=1){const c=e[u];if((c.width>=a||c.height>=a)&&n(c,e[u+1])){r=u;break}}return r}}const M7={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},pr=M7,P7={HLS:"h"},B7=P7;class Qa{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Qa?i:new Qa(i))),this.value=e,this.params=t}}const F7="Dict";function U7(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function j7(s,e,t,i){return new Error(`failed to ${s} "${U7(e)}" as ${t}`,{cause:i})}function Za(s,e,t){return j7("serialize",s,e,t)}class aR{constructor(e){this.description=e}}const qw="Bare Item",$7="Boolean";function H7(s){if(typeof s!="boolean")throw Za(s,$7);return s?"?1":"?0"}function z7(s){return btoa(String.fromCharCode(...s))}const V7="Byte Sequence";function G7(s){if(ArrayBuffer.isView(s)===!1)throw Za(s,V7);return`:${z7(s)}:`}const q7="Integer";function K7(s){return s<-999999999999999||999999999999999<s}function oR(s){if(K7(s))throw Za(s,q7);return s.toString()}function W7(s){return`@${oR(s.getTime()/1e3)}`}function lR(s,e){if(s<0)return-lR(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const n=Math.floor(s*t);return(n%2===0?n:n+1)/t}else return Math.round(s*t)/t}const Y7="Decimal";function X7(s){const e=lR(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Za(s,Y7);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Q7="String",Z7=/[\x00-\x1f\x7f]+/;function J7(s){if(Z7.test(s))throw Za(s,Q7);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function e9(s){return s.description||s.toString().slice(7,-1)}const t9="Token";function Kw(s){const e=e9(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Za(e,t9);return e}function eb(s){switch(typeof s){case"number":if(!Ot(s))throw Za(s,qw);return Number.isInteger(s)?oR(s):X7(s);case"string":return J7(s);case"symbol":return Kw(s);case"boolean":return H7(s);case"object":if(s instanceof Date)return W7(s);if(s instanceof Uint8Array)return G7(s);if(s instanceof aR)return Kw(s);default:throw Za(s,qw)}}const i9="Key";function tb(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw Za(s,i9);return s}function S1(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${tb(e)}`:`;${tb(e)}=${eb(t)}`).join("")}function uR(s){return s instanceof Qa?`${eb(s.value)}${S1(s.params)}`:eb(s)}function s9(s){return`(${s.value.map(uR).join(" ")})${S1(s.params)}`}function n9(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw Za(s,F7);const t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([n,r])=>{r instanceof Qa||(r=new Qa(r));let a=tb(n);return r.value===!0?a+=S1(r.params):(a+="=",Array.isArray(r.value)?a+=s9(r):a+=uR(r)),a}).join(`,${i}`)}function cR(s,e){return n9(s,e)}const Ma="CMCD-Object",Ys="CMCD-Request",iu="CMCD-Session",yl="CMCD-Status",r9={br:Ma,ab:Ma,d:Ma,ot:Ma,tb:Ma,tpb:Ma,lb:Ma,tab:Ma,lab:Ma,url:Ma,pb:Ys,bl:Ys,tbl:Ys,dl:Ys,ltc:Ys,mtp:Ys,nor:Ys,nrr:Ys,rc:Ys,sn:Ys,sta:Ys,su:Ys,ttfb:Ys,ttfbb:Ys,ttlb:Ys,cmsdd:Ys,cmsds:Ys,smrt:Ys,df:Ys,cs:Ys,ts:Ys,cid:iu,pr:iu,sf:iu,sid:iu,st:iu,v:iu,msd:iu,bs:yl,bsd:yl,cdn:yl,rtp:yl,bg:yl,pt:yl,ec:yl,e:yl},a9={REQUEST:Ys};function o9(s){return Object.keys(s).reduce((e,t)=>{var i;return(i=s[t])===null||i===void 0||i.forEach(n=>e[n]=t),e},{})}function l9(s,e){const t={};if(!s)return t;const i=Object.keys(s),n=e?o9(e):{};return i.reduce((r,a)=>{var u;const c=r9[a]||n[a]||a9.REQUEST,d=(u=r[c])!==null&&u!==void 0?u:r[c]={};return d[a]=s[a],r},t)}function u9(s){return["ot","sf","st","e","sta"].includes(s)}function c9(s){return typeof s=="number"?Ot(s):s!=null&&s!==""&&s!==!1}const dR="event";function d9(s,e){const t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;const n=t.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);for(;n[0]===r[0];)n.shift(),r.shift();for(;r.length;)r.shift(),n.unshift("..");return n.join("/")+t.search+t.hash}const l0=s=>Math.round(s),ib=(s,e)=>Array.isArray(s)?s.map(t=>ib(t,e)):s instanceof Qa&&typeof s.value=="string"?new Qa(ib(s.value,e),s.params):(e.baseUrl&&(s=d9(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),Um=s=>l0(s/100)*100,h9=(s,e)=>{let t=s;return e.version>=2&&(s instanceof Qa&&typeof s.value=="string"?t=new Qa([s]):typeof s=="string"&&(t=[s])),ib(t,e)},f9={br:l0,d:l0,bl:Um,dl:Um,mtp:Um,nor:h9,rtp:Um,tb:l0},hR="request",fR="response",_1=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],m9=["e"],p9=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Op(s){return p9.test(s)}function g9(s){return _1.includes(s)||m9.includes(s)||Op(s)}const mR=["d","dl","nor","ot","rtp","su"];function y9(s){return _1.includes(s)||mR.includes(s)||Op(s)}const v9=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function x9(s){return _1.includes(s)||mR.includes(s)||v9.includes(s)||Op(s)}const b9=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function T9(s){return b9.includes(s)||Op(s)}const S9={[fR]:x9,[dR]:g9,[hR]:y9};function pR(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||1,n=e.reportingMode||hR,r=i===1?T9:S9[n];let a=Object.keys(s).filter(r);const u=e.filter;typeof u=="function"&&(a=a.filter(u));const c=n===fR||n===dR;c&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const d=ys({},f9,e.formatters),f={version:i,reportingMode:n,baseUrl:e.baseUrl};return a.sort().forEach(g=>{let y=s[g];const v=d[g];if(typeof v=="function"&&(y=v(y,f)),g==="v"){if(i===1)return;y=i}g=="pr"&&y===1||(c&&g==="ts"&&!Ot(y)&&(y=Date.now()),c9(y)&&(u9(g)&&typeof y=="string"&&(y=new aR(y)),t[g]=y))}),t}function _9(s,e={}){const t={};if(!s)return t;const i=pR(s,e),n=l9(i,e?.customHeaderMap);return Object.entries(n).reduce((r,[a,u])=>{const c=cR(u,{whitespace:!1});return c&&(r[a]=c),r},t)}function E9(s,e,t){return ys(s,_9(e,t))}const w9="CMCD";function A9(s,e={}){return s?cR(pR(s,e),{whitespace:!1}):""}function k9(s,e={}){if(!s)return"";const t=A9(s,e);return encodeURIComponent(t)}function C9(s,e={}){if(!s)return"";const t=k9(s,e);return`${w9}=${t}`}const Ww=/CMCD=[^&#]+/;function D9(s,e,t){const i=C9(e,t);if(!i)return s;if(Ww.test(s))return s.replace(Ww,i);const n=s.includes("?")?"&":"?";return`${s}${n}${i}`}class L9{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.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=n=>{try{this.apply(n,{ot:pr.MANIFEST,su:!this.initialized})}catch(r){this.hls.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=n=>{try{const{frag:r,part:a}=n,u=this.hls.levels[r.level],c=this.getObjectType(r),d={d:(a||r).duration*1e3,ot:c};(c===pr.VIDEO||c===pr.AUDIO||c==pr.MUXED)&&(d.br=u.bitrate/1e3,d.tb=this.getTopBandwidth(c)/1e3,d.bl=this.getBufferLength(c));const f=a?this.getNextPart(a):this.getNextFrag(r);f!=null&&f.url&&f.url!==r.url&&(d.nor=f.url),this.apply(n,d)}catch(r){this.hls.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHED,this.onMediaDetached,this),e.on(H.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHED,this.onMediaDetached,this),e.off(H.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)==null?void 0:n.buffer}createData(){var e;return{v:1,sf:B7.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ys(t,this.createData());const i=t.ot===pr.INIT||t.ot===pr.VIDEO||t.ot===pr.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:n}=this;n&&(t=Object.keys(t).reduce((a,u)=>(n.includes(u)&&(a[u]=t[u]),a),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),E9(e.headers,t,r)):e.url=D9(e.url,t,r)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const n=e.sn-i.startSN;return i.fragments[n+1]}}getNextPart(e){var t;const{index:i,fragment:n}=e,r=(t=this.hls.levels[n.level])==null||(t=t.details)==null?void 0:t.partList;if(r){const{sn:a}=n;for(let u=r.length-1;u>=0;u--){const c=r[u];if(c.index===i&&c.fragment.sn===a)return r[u+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return pr.TIMED_TEXT;if(e.sn==="initSegment")return pr.INIT;if(t==="audio")return pr.AUDIO;if(t==="main")return this.hls.audioTracks.length?pr.VIDEO:pr.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===pr.AUDIO)i=n.audioTracks;else{const r=n.maxAutoLevel,a=r>-1?r+1:n.levels.length;i=n.levels.slice(0,a)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===pr.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:gi.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,a,u){t(r),this.loader.load(r,a,u)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,a,u){t(r),this.loader.load(r,a,u)}}}}const R9=3e5;class I9 extends ra{constructor(e){super("content-steering",e.logger),this.hls=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.registerListeners()}registerListeners(){const e=this.hls;e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===$n.SendAlternateToPenaltyBox&&i.flags===Fr.MoveAllAlternatesMatchingHost){const n=this.levels;let r=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:u,pathwayId:c,type:d}=t.context;u&&n?a=this.getPathwayForGroupId(u,d,a):c&&(a=c)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!r&&n&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==a),t.details===$e.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${n&&n.length} priorities: ${ks(r)} penalized: ${ks(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(r=>{n-i[r]>R9&&delete i[r]});for(let r=0;r<e.length;r++){const a=e[r];if(a in i)continue;if(a===this.pathwayId)return;const u=this.hls.nextLoadLevel,c=this.hls.levels[u];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,ML(t),this.hls.trigger(H.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[u];c&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==c.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==c.bitrate&&this.log(`Unstable Pathways change from bitrate ${c.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=u);break}}}getPathwayForGroupId(e,t,i){const n=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<n.length;r++)if(t===Ii.AUDIO_TRACK&&n[r].hasAudioGroup(e)||t===Ii.SUBTITLE_TRACK&&n[r].hasSubtitleGroup(e))return n[r].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},n={};e.forEach(r=>{const{ID:a,"BASE-ID":u,"URI-REPLACEMENT":c}=r;if(t.some(f=>f.pathwayId===a))return;const d=this.getLevelsForPathway(u).map(f=>{const g=new Hs(f.attrs);g["PATHWAY-ID"]=a;const y=g.AUDIO&&`${g.AUDIO}_clone_${a}`,v=g.SUBTITLES&&`${g.SUBTITLES}_clone_${a}`;y&&(i[g.AUDIO]=y,g.AUDIO=y),v&&(n[g.SUBTITLES]=v,g.SUBTITLES=v);const T=gR(f.uri,g["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),S=new $h({attrs:g,audioCodec:f.audioCodec,bitrate:f.bitrate,height:f.height,name:f.name,url:T,videoCodec:f.videoCodec,width:f.width});if(f.audioGroups)for(let w=1;w<f.audioGroups.length;w++)S.addGroupId("audio",`${f.audioGroups[w]}_clone_${a}`);if(f.subtitleGroups)for(let w=1;w<f.subtitleGroups.length;w++)S.addGroupId("text",`${f.subtitleGroups[w]}_clone_${a}`);return S});t.push(...d),Yw(this.audioTracks,i,c,a),Yw(this.subtitleTracks,n,c,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let n;try{n=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(n.protocol!=="data:"){const f=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+f)}const r={responseType:"json",url:n.href},a=t.steeringManifestLoadPolicy.default,u=a.errorRetry||a.timeoutRetry||{},c={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:(f,g,y,v)=>{this.log(`Loaded steering manifest: "${n}"`);const T=f.data;if(T?.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":S,"PATHWAY-CLONES":w,"PATHWAY-PRIORITY":L}=T;if(S)try{this.uri=new self.URL(S,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${S}`);return}this.scheduleRefresh(this.uri||y.url),w&&this.clonePathways(w);const O={steeringManifest:T,url:n.toString()};this.hls.trigger(H.STEERING_MANIFEST_LOADED,O),L&&this.updatePathwayPriority(L)},onError:(f,g,y,v)=>{if(this.log(`Error loading steering manifest: ${f.code} ${f.text} (${g.url})`),this.stopLoad(),f.code===410){this.enabled=!1,this.log(`Steering manifest ${g.url} no longer available`);return}let T=this.timeToLoad*1e3;if(f.code===429){const S=this.loader;if(typeof S?.getResponseHeader=="function"){const w=S.getResponseHeader("Retry-After");w&&(T=parseFloat(w)*1e3)}this.log(`Steering manifest ${g.url} rate limited`);return}this.scheduleRefresh(this.uri||g.url,T)},onTimeout:(f,g,y)=>{this.log(`Timeout loading steering manifest (${g.url})`),this.scheduleRefresh(this.uri||g.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,c,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const n=(i=this.hls)==null?void 0:i.media;if(n&&!n.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Yw(s,e,t,i){s&&Object.keys(e).forEach(n=>{const r=s.filter(a=>a.groupId===n).map(a=>{const u=ys({},a);return u.details=void 0,u.attrs=new Hs(u.attrs),u.url=u.attrs.URI=gR(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),u.groupId=u.attrs["GROUP-ID"]=e[n],u.attrs["PATHWAY-ID"]=i,u});s.push(...r)})}function gR(s,e,t,i){const{HOST:n,PARAMS:r,[t]:a}=i;let u;e&&(u=a?.[e],u&&(s=u));const c=new self.URL(s);return n&&!u&&(c.host=n),r&&Object.keys(r).sort().forEach(d=>{d&&c.searchParams.set(d,r[d])}),c.href}class Rc extends ra{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Rc.CDMCleanupPromise?[Rc.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:n}=t,r=`"${t.type}" event: init data type: "${i}"`;if(this.debug(r),n!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=ph(this.config));const u=a.map(Dv).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(u)}this.keyFormatPromise.then(a=>{const u=r0(a);if(i!=="sinf"||u!==zs.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${u}`);return}let c;try{const v=Tn(new Uint8Array(n)),T=d1(JSON.parse(v).sinf),S=cL(T);if(!S)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(S.subarray(8,24))}catch(v){this.warn(`${r} Failed to parse sinf: ${v}`);return}const d=zn(c),{keyIdToKeySessionPromise:f,mediaKeySessions:g}=this;let y=f[d];for(let v=0;v<g.length;v++){const T=g[v],S=T.decryptdata;if(!S.keyId)continue;const w=zn(S.keyId);if(K0(c,S.keyId)||S.uri.replace(/-/g,"").indexOf(d)!==-1){if(y=f[w],!y)continue;if(S.pssh)break;delete f[w],S.pssh=new Uint8Array(n),S.keyId=c,y=f[d]=y.then(()=>this.generateRequestWithPreferredKeySession(T,i,n,"encrypted-event-key-match")),y.catch(L=>this.handleError(L));break}}y||this.handleError(new Error(`Key ID ${d} not encountered in playlist. Key-system sessions ${g.length}.`))}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(H.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(H.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(H.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(H.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(H.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(H.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(H.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(H.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t?.[e];if(n)return n.licenseUrl;if(e===zs.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(a,u,c)=>!!a&&c.indexOf(a)===u,n=t.map(a=>a.audioCodec).filter(i),r=t.map(a=>a.videoCodec).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise((a,u)=>{const c=d=>{const f=d.shift();this.getMediaKeysPromise(f,n,r).then(g=>a({keySystem:f,mediaKeys:g})).catch(g=>{d.length?c(d):g instanceof Br?u(g):u(new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_NO_ACCESS,error:g,fatal:!0},g.message))})};c(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return kL===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}getMediaKeysPromise(e,t,i){var n;const r=hj(e,t,i,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],u=(n=a)==null?void 0:n.keySystemAccess;if(!u){this.log(`Requesting encrypted media "${e}" key-system access with config: ${ks(r)}`),u=this.requestMediaKeySystemAccess(e,r);const c=a=this.keySystemAccessPromises[e]={keySystemAccess:u};return u.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`)}),u.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);const f=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const g=c.mediaKeys=d.createMediaKeys().then(y=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,f.then(v=>v?this.setMediaKeysServerCertificate(y,e,v):y)));return g.catch(y=>{this.error(`Failed to create media-keys for "${e}"}: ${y}`)}),g})}return u.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${zn(e.keyId||[])} keyUri: ${e.uri}`);const n=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),n=jm(t),r="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,r,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${zn(e.decryptdata.keyId||[])}
} (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Dv(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:n})=>{const r=Dv(n);r?t(r):i(new Error(`Unable to find format for key-system "${n}"`))}).catch(i)})}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){const t=ph(this.config),i=e.map(r0).filter(n=>!!n&&t.indexOf(n)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const n=N9(e,t[i]);if(n)return n}}loadKey(e){const t=e.keyInfo.decryptdata,i=jm(t),n=this.bannedKeyIds[i];if(n||this.getKeyStatus(t)==="internal-error"){const u=Xw(n||"internal-error",t);return this.handleError(u,e.frag),Promise.reject(u)}const r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const a=this.keyIdToKeySessionPromise[i];if(!a){const u=this.getKeySystemForKeyPromise(t).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(c,d).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:t}))))).then(c=>{const d="cenc",f=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(c,d,f,"playlist-key")});return u.catch(c=>this.handleError(c,e.frag)),this.keyIdToKeySessionPromise[i]=u,u}return a.catch(u=>{if(u instanceof Br){const c=us({},u.data);this.getKeyStatus(t)==="internal-error"&&(c.decryptdata=t);const d=new Br(c,u.message);this.handleError(d,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Br){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${zn(i.keyId||[])})`:""}`),this.hls.trigger(H.ERROR,e.data)}else this.error(e.message),this.hls.trigger(H.ERROR,{type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=jm(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=r0(e.keyFormat),r=n?[n]:ph(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=ph(this.config)),e.length===0)throw new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${ks({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((r,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(r).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>i.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,t,i,n){var r;const a=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(a)try{const T=a.call(this.hls,t,i,e);if(!T)throw new Error("Invalid response from configured generateRequest filter");t=T.initDataType,i=T.initData?T.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(T){if(this.warn(T.message),this.hls&&this.hls.config.debug)throw T}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const u=jm(e.decryptdata),c=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${u} URI: ${c} (init data type: ${t} length: ${i.byteLength})`);const d=new f1,f=e._onmessage=T=>{const S=e.mediaKeysSession;if(!S){d.emit("error",new Error("invalid state"));return}const{messageType:w,message:L}=T;this.log(`"${w}" message event for session "${S.sessionId}" message size: ${L.byteLength}`),w==="license-request"||w==="license-renewal"?this.renewLicense(e,L).catch(O=>{d.eventNames().length?d.emit("error",O):this.handleError(O)}):w==="license-release"?e.keySystem===zs.FAIRPLAY&&this.updateKeySession(e,Wx("acknowledged")).then(()=>this.removeSession(e)).catch(O=>this.handleError(O)):this.warn(`unhandled media key message type "${w}"`)},g=(T,S)=>{S.keyStatus=T;let w;T.startsWith("usable")?d.emit("resolved"):T==="internal-error"||T==="output-restricted"||T==="output-downscaled"?w=Xw(T,S.decryptdata):T==="expired"?w=new Error(`key expired (keyId: ${u})`):T==="released"?w=new Error("key released"):T==="status-pending"||this.warn(`unhandled key status change "${T}" (keyId: ${u})`),w&&(d.eventNames().length?d.emit("error",w):this.handleError(w))},y=e._onkeystatuseschange=T=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}const w=this.getKeyStatuses(e);if(!Object.keys(w).some(j=>w[j]!=="status-pending"))return;if(w[u]==="expired"){this.log(`Expired key ${ks(w)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let O=w[u];if(O)g(O,e);else{var I;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(I=e.keyStatusTimeouts)[u]||(I[u]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const P=this.getKeyStatus(e.decryptdata);if(P&&P!=="status-pending")return this.log(`No status for keyId ${u} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${P} from other session.`),g(P,e);this.log(`key status for ${u} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),O="internal-error",g(O,e)},1e3)),this.log(`No status for keyId ${u} (${ks(w)}).`)}};sr(e.mediaKeysSession,"message",f),sr(e.mediaKeysSession,"keystatuseschange",y);const v=new Promise((T,S)=>{d.on("error",S),d.on("resolved",T)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${u} URI: ${c}`)}).catch(T=>{throw new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_NO_SESSION,error:T,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${T}`)}).then(()=>v).catch(T=>(d.removeAllListeners(),this.removeSession(e).then(()=>{throw T}))).then(()=>(d.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if(typeof n=="string"&&typeof i=="object"){const u=n;n=i,i=u}const r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===zs.PLAYREADY&&r.length===16){const u=zn(r);t[u]=i,wL(r)}const a=zn(r);i==="internal-error"&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,n=new i(t),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,u)=>{const c={responseType:"arraybuffer",url:r},d=t.certLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(y,v,T,S)=>{a(y.data)},onError:(y,v,T,S)=>{u(new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:us({url:c.url,data:void 0},y)},`"${e}" certificate request failed (${r}). Status: ${y.code} (${y.text})`))},onTimeout:(y,v,T)=>{u(new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(y,v,T)=>{u(new Error("aborted"))}};n.load(c,f,g)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,r)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(a=>{r(new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:n,fatal:!1},n.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const n=new DOMParser().parseFromString(i,"application/xml"),r=n.querySelectorAll("HttpHeader");if(r.length>0){let f;for(let g=0,y=r.length;g<y;g++){var a,u;f=r[g];const v=(a=f.querySelector("name"))==null?void 0:a.textContent,T=(u=f.querySelector("value"))==null?void 0:u.textContent;v&&T&&e.setRequestHeader(v,T)}}const c=n.querySelector("Challenge"),d=c?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Wx(atob(d))}setupLicenseXHR(e,t,i,n){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,n)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),r.call(this.hls,e,t,i,n)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((n,r)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(u.readyState===4)if(u.status===200){this._requestLicenseFailureCount=0;let c=u.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const d=this.config.licenseResponseCallback;if(d)try{c=d.call(this.hls,u,a,e)}catch(f){this.error(f)}n(c)}else{const c=i.errorRetry,d=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||u.status>=400&&u.status<500)r(new Br({type:Vt.KEY_SYSTEM_ERROR,details:$e.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:u,response:{url:a,data:void 0,code:u.status,text:u.statusText}},`License Request XHR failed (${a}). Status: ${u.status} (${u.statusText})`));else{const f=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${f} attempts left`),this.requestLicense(e,t).then(n,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=u,this.setupLicenseXHR(u,a,e,t).then(({xhr:c,licenseChallenge:d})=>{e.keySystem==zs.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(c,d)),c.send(d)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,sr(i,"encrypted",this.onMediaEncrypted),sr(i,"waitingforkey",this.onWaitingForKey);const n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(br(e,"encrypted",this.onMediaEncrypted),br(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,n=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,kl.clearKeyUriToKeyIdMap();const r=n.length;Rc.CDMCleanupPromise=Promise.all(n.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((n,r)=>(n.indexOf(r.keyFormat)===-1&&n.push(r.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:n}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${zn(n?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(d=>self.clearTimeout(a[d]));const{drmSystemOptions:u}=this.config;return(mj(u)?new Promise((d,f)=>{self.setTimeout(()=>f(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(d).catch(f)}):Promise.resolve()).catch(d=>{this.log(`Could not remove session: ${d}`),this.hls&&this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${d}`)})}).then(()=>t.close()).catch(d=>{this.log(`Could not close session: ${d}`),this.hls&&this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${d}`)})})}return Promise.resolve()}}Rc.CDMCleanupPromise=void 0;function jm(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return zn(s.keyId)}function N9(s,e){if(s.keyId&&e.mediaKeysSession.keyStatuses.has(s.keyId))return e.mediaKeysSession.keyStatuses.get(s.keyId);if(s.matches(e.decryptdata))return e.keyStatus}class Br 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}}function Xw(s,e){const t=s==="output-restricted",i=t?$e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:$e.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Br({type:Vt.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}class O9{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(H.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(H.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(H.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const n=performance.now();if(t){if(this.lastTime){const r=n-this.lastTime,a=i-this.lastDroppedFrames,u=t-this.lastDecodedFrames,c=1e3*a/r,d=this.hls;if(d.trigger(H.FPS_DROP,{currentDropped:a,currentDecoded:u,totalDroppedFrames:i}),c>0&&a>d.config.fpsDroppedMonitoringThreshold*u){let f=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+f),f>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=f)&&(f=f-1,d.trigger(H.FPS_DROP_LEVEL_CAPPING,{level:f,droppedLevel:d.currentLevel}),d.autoLevelCapping=f,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function yR(s,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=s,e.dispatchEvent(t)}function vR(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){cs.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,s.addCue(n)}catch(n){cs.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(s.mode=t)}function yc(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t)}function sb(s,e,t,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const r=P9(s.cues,e,t);for(let a=0;a<r.length;a++)(!i||i(r[a]))&&s.removeCue(r[a])}n==="disabled"&&(s.mode=n)}function M9(s,e){if(e<=s[0].startTime)return 0;const t=s.length-1;if(e>s[t].endTime)return-1;let i=0,n=t,r;for(;i<=n;)if(r=Math.floor((n+i)/2),e<s[r].startTime)n=r-1;else if(e>s[r].startTime&&i<t)i=r+1;else return r;return s[i].startTime-e<e-s[n].startTime?i:n}function P9(s,e,t){const i=[],n=M9(s,e);if(n>-1)for(let r=n,a=s.length;r<a;r++){const u=s[r];if(u.startTime>=e&&u.endTime<=t)i.push(u);else if(u.startTime>t)return i}return i}function u0(s){const e=[];for(let t=0;t<s.length;t++){const i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t])}return e}class B9 extends b1{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=u0(this.media.textTracks);for(let r=0;r<i.length;r++)if(i[r].mode==="hidden")t=i[r];else if(i[r].mode==="showing"){t=i[r];break}const n=this.findTrackForTextTrack(t);this.subtitleTrack!==n&&this.setSubtitleTrack(n)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.LEVEL_LOADING,this.onLevelLoading,this),e.on(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(H.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(H.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.LEVEL_LOADING,this.onLevelLoading,this),e.off(H.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(H.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(H.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.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,n)return;u0(i.textTracks).forEach(a=>{yc(a)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:n,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==n){this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${a?.groupId}`);return}const u=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,u)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||n?.length!==i?.length||i!=null&&i.some(a=>n?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(f=>!i||i.indexOf(f.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(f=>f.default)&&(this.selectDefaultTrack=!1),a.forEach((f,g)=>{f.id=g});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const u=this.hls.config.subtitlePreference;if(!r&&u){this.selectDefaultTrack=!1;const f=Ga(u,a);if(f>-1)r=a[f];else{const g=Ga(u,this.tracks);r=this.tracks[g]}}let c=this.findTrackId(r);c===-1&&r&&(c=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(H.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.trackId===-1&&this.setSubtitleTrack(c)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let n=0;n<t.length;n++){const r=t[n];if(!(i&&!r.default||!i&&!e)&&(!e||bu(r,e)))return n}if(e){for(let n=0;n<t.length;n++){const r=t[n];if(Gh(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const r=t[n];if(Gh(e.attrs,r.attrs,["LANGUAGE"]))return n}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(Jx(n,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ii.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&bu(e,i))return i;const n=Ga(e,this.tracksInGroup);if(n>-1){const r=this.tracksInGroup[n];return this.setSubtitleTrack(n),r}else{if(i)return null;{const r=Ga(e,t);if(r>-1)return t[r]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,n=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,u=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${u&&a.live?" age "+u.toFixed(1)+(a.type&&" "+a.type||""):""} ${r}`),this.hls.trigger(H.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=u0(e.textTracks),i=this.currentTrack;let n;if(i&&(n=t.filter(r=>Jx(i,r))[0],n||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(r=>{r.mode!=="disabled"&&r!==n&&(r.mode="disabled")}),n){const r=this.subtitleDisplay?"showing":"hidden";n.mode!==r&&(n.mode=r)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!Ot(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),!n){this.hls.trigger(H.SUBTITLE_TRACK_SWITCH,{id:e});return}const r=!!n.details&&!n.details.live;if(e===this.trackId&&n===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:a,groupId:u="",name:c,type:d,url:f}=n;this.hls.trigger(H.SUBTITLE_TRACK_SWITCH,{id:a,groupId:u,name:c,type:d,url:f});const g=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(g)}}function F9(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n=="x"?r:r&3|8).toString(16)})}}}function Rh(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const Ic=.025;let Q0=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function U9(s,e,t){return`${s.identifier}-${t+1}-${Rh(e)}`}class j9{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Fv(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=Fv(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=Ot(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Fv(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Ic))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Q0.Range:Q0.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return $9(this)}}function Fv(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<Ic)?e.start:e.start+e.duration}function xR(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Uv(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function $9(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function fc(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class H9{constructor(e,t,i,n){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(H.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=n;const a=()=>{this.hasDetails=!0};r.once(H.LEVEL_LOADED,a),r.once(H.AUDIO_TRACK_LOADED,a),r.once(H.SUBTITLE_TRACK_LOADED,a),r.on(H.MEDIA_ATTACHING,(u,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(H.BUFFER_APPENDED,()=>{const f=this.bufferedEnd;this.reachedPlayout(f)&&(this._bufferedEosTime=f,r.trigger(H.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=xR(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,r=gi.bufferInfo(e,n,0);return this.getAssetTime(r.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=gi.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var n;(n=this.hls)==null||n.on(e,t)}once(e,t,i){var n;(n=this.hls)==null||n.once(e,t)}off(e,t,i){var n;(n=this.hls)==null||n.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${fc(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const Qw=.033;class z9 extends ra{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const n=this.items;if(n)for(n[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(r=n[i])!=null&&r.event;){var r;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let n=0;n<i.length;n++){let r=i[n];if(t&&t!=="primary"&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return n}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let n=e;n<=t&&i[n];n++){const r=i[n].event;if(r!=null&&r.restrictions.jump&&!r.appendInPlace)return n}return-1}findEventIndex(e){const t=this.items;if(t)for(let n=t.length;n--;){var i;if(((i=t[n].event)==null?void 0:i.identifier)===e)return n}return-1}findAssetIndex(e,t){const i=e.assetList,n=i.length;if(n>1)for(let r=0;r<n;r++){const a=i[r];if(!a.error){const u=a.timelineStart;if(t===u||t>u&&(t<u+(a.duration||0)||r===n-1))return r}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:n}=i,r=this.events,a=this.parseDateRanges(n,{url:i.url},t),u=Object.keys(n),c=r?r.filter(d=>!u.includes(d.identifier)):[];a.length&&a.sort((d,f)=>{const g=d.cue.pre,y=d.cue.post,v=f.cue.pre,T=f.cue.post;if(g&&!v)return-1;if(v&&!g||y&&!T)return 1;if(T&&!y)return-1;if(!g&&!v&&!y&&!T){const S=d.startTime,w=f.startTime;if(S!==w)return S-w}return d.dateRange.tagOrder-f.dateRange.tagOrder}),this.events=a,c.forEach(d=>{this.removeEvent(d)}),this.updateSchedule(e,c)}updateSchedule(e,t=[],i=!1){const n=this.events||[];if(n.length||t.length||this.length<2){const r=this.items,a=this.parseSchedule(n,e);(i||t.length||r?.length!==a.length||a.some((c,d)=>Math.abs(c.playout.start-r[d].playout.start)>.005||Math.abs(c.playout.end-r[d].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const n=[],r=Object.keys(e);for(let a=0;a<r.length;a++){const u=r[a],c=e[u];if(c.isInterstitial){let d=this.eventMap[u];d?d.setDateRange(c):(d=new j9(c,t),this.eventMap[u]=d,i===!1&&(d.appendInPlace=i)),n.push(d)}}return n}parseSchedule(e,t){const i=[],n=t.main.details,r=n.live?1/0:n.edge;let a=0;if(e=e.filter(c=>!c.error&&!(c.cue.once&&c.hasPlayed)),e.length){this.resolveOffsets(e,t);let c=0,d=0;if(e.forEach((f,g)=>{const y=f.cue.pre,v=f.cue.post,T=e[g-1]||null,S=f.appendInPlace,w=v?r:f.startOffset,L=f.duration,O=f.timelineOccupancy===Q0.Range?L:0,I=f.resumptionOffset,j=T?.startTime===w,P=w+f.cumulativeDuration;let G=S?P+L:w+I;if(y||!v&&w<=0){const K=d;d+=O,f.timelineStart=P;const k=a;a+=L,i.push({event:f,start:P,end:G,playout:{start:k,end:a},integrated:{start:K,end:d}})}else if(w<=r){if(!j){const R=w-c;if(R>Qw){const Y=c,z=d;d+=R;const X=a;a+=R;const re={previousEvent:e[g-1]||null,nextEvent:f,start:Y,end:Y+R,playout:{start:X,end:a},integrated:{start:z,end:d}};i.push(re)}else R>0&&T&&(T.cumulativeDuration+=R,i[i.length-1].end=w)}v&&(G=P),f.timelineStart=P;const K=d;d+=O;const k=a;a+=L,i.push({event:f,start:P,end:G,playout:{start:k,end:a},integrated:{start:K,end:d}})}else return;const N=f.resumeTime;v||N>r?c=r:c=N}),c<r){var u;const f=c,g=d,y=r-c;d+=y;const v=a;a+=y,i.push({previousEvent:((u=i[i.length-1])==null?void 0:u.event)||null,nextEvent:null,start:c,end:f+y,playout:{start:v,end:a},integrated:{start:g,end:d}})}this.setDurations(r,a,d)}else i.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,n=i.live?1/0:i.edge;let r=0,a=-1;e.forEach((u,c)=>{const d=u.cue.pre,f=u.cue.post,g=d?0:f?n:u.startTime;this.updateAssetDurations(u),a===g?u.cumulativeDuration=r:(r=0,a=g),!f&&u.snapOptions.in&&(u.resumeAnchor=Au(null,i.fragments,u.startOffset+u.resumptionOffset,0,0)||void 0),u.appendInPlace&&!u.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(u,t)||(u.appendInPlace=!1)),!u.appendInPlace&&c+1<e.length&&e[c+1].startTime-e[c].resumeTime<Qw&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${u}`));const v=Ot(u.resumeOffset)?u.resumeOffset:u.duration;r+=v})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>Ic?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(a=>{const u=t[a].details,c=u.edge;if(i>=c)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${c}`),!1;const d=Au(null,u.fragments,i);if(!d)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${u.fragStart}-${u.fragmentEnd})`),!0;const f=a==="audio"?.175:0;return Math.abs(d.start-i)<Ic+f||Math.abs(d.end-i)<Ic+f?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${d.start}-${d.end} sn: ${d.sn} cc: ${d.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,n=!1,r=!1;for(let a=0;a<e.assetList.length;a++){const u=e.assetList[a],c=t+i;u.startOffset=i,u.timelineStart=c,n||(n=u.duration===null),r||(r=!!u.error);const d=u.error?0:u.duration||0;i+=d}n&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function ha(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class V9{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let n;try{n=xR(i,this.hls.sessionId,e.baseUrl)}catch(y){const v=this.assignAssetListError(e,$e.ASSET_LIST_LOAD_ERROR,y,i);this.hls.trigger(H.ERROR,v);return}t&&n.protocol!=="data:"&&n.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,a=r.loader,u=new a(r),c={responseType:"json",url:n.href},d=r.interstitialAssetListLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(y,v,T,S)=>{const w=y.data,L=w?.ASSETS;if(!Array.isArray(L)){const O=this.assignAssetListError(e,$e.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),T.url,v,S);this.hls.trigger(H.ERROR,O);return}e.assetListResponse=w,this.hls.trigger(H.ASSET_LIST_LOADED,{event:e,assetListResponse:w,networkDetails:S})},onError:(y,v,T,S)=>{const w=this.assignAssetListError(e,$e.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${y.code} ${y.text} (${v.url})`),v.url,S,T);this.hls.trigger(H.ERROR,w)},onTimeout:(y,v,T)=>{const S=this.assignAssetListError(e,$e.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${v.url})`),v.url,y,T);this.hls.trigger(H.ERROR,S)}};return u.load(c,f,g),this.hls.trigger(H.ASSET_LIST_LOADING,{event:e}),u}assignAssetListError(e,t,i,n,r,a){return e.error=i,{type:Vt.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:a,stats:r}}}function Zw(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function $m(s,e){return`[${s}] Advancing timeline position to ${e}`}class G9 extends ra{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const n=i-this.timelinePos;if(Math.abs(n)<1/7056e5)return;const a=n<=-.01;this.timelinePos=i,this.bufferedPos=i;const u=this.playingItem;if(!u){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-n)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<u.start||i>=u.end){var c;const v=this.findItemIndex(u);let T=this.schedule.findItemIndexAtTime(i);if(T===-1&&(T=v+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${v} to ${T})`)),!this.isInterstitial(u)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!a&&T>v){const S=this.schedule.findJumpRestrictedIndex(v+1,T);if(S>v){this.setSchedulePosition(S);return}}this.setSchedulePosition(T);return}const d=this.playingAsset;if(!d){if(this.playingLastItem&&this.isInterstitial(u)){const v=u.event.assetList[0];v&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,v))}return}const f=d.timelineStart,g=d.duration||0;if(a&&i<f||i>=f+g){var y;(y=u.event)!=null&&y.appendInPlace&&(this.clearAssetPlayers(u.event,u),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,d)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const n=this.playingItem;if(!n||this.playingLastItem)return;if(i>=n.end){this.timelinePos=n.end;const u=this.findItemIndex(n);this.setSchedulePosition(u+1)}const r=this.playingAsset;if(!r)return;const a=r.timelineStart+(r.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,n)=>{const r=this.schedule;if(!r)return;const a=this.playingItem,u=r.events||[],c=r.items||[],d=r.durations,f=i.map(S=>S.identifier),g=!!(u.length||f.length);(g||n)&&this.log(`INTERSTITIALS_UPDATED (${u.length}): ${u}
Schedule: ${c.map(S=>ha(S))} pos: ${this.timelinePos}`),f.length&&this.log(`Removed events ${f}`);let y=null,v=null;a&&(y=this.updateItem(a,this.timelinePos),this.itemsMatch(a,y)?this.playingItem=y:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const T=this.bufferingItem;if(T&&(v=this.updateItem(T,this.bufferedPos),this.itemsMatch(T,v)?this.bufferingItem=v:T.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(T.event,null))),i.forEach(S=>{S.assetList.forEach(w=>{this.clearAssetPlayer(w.identifier,null)})}),this.playerQueue.forEach(S=>{if(S.interstitial.appendInPlace){const w=S.assetItem.timelineStart,L=S.timelineOffset-w;if(L)try{S.timelineOffset=w}catch(O){Math.abs(L)>Ic&&this.warn(`${O} ("${S.assetId}" ${S.timelineOffset}->${w})`)}}}),g||n){if(this.hls.trigger(H.INTERSTITIALS_UPDATED,{events:u.slice(0),schedule:c.slice(0),durations:d,removedIds:f}),this.isInterstitial(a)&&f.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(y,a),T&&v!==y&&this.trimInPlace(v,T),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new V9(e),this.schedule=new z9(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(H.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(H.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(H.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(H.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(H.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(H.BUFFER_APPENDED,this.onBufferAppended,this),e.on(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(H.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(H.MEDIA_ENDED,this.onMediaEnded,this),e.on(H.ERROR,this.onError,this),e.on(H.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(H.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(H.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(H.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(H.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(H.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(H.BUFFER_CODECS,this.onBufferCodecs,this),e.off(H.BUFFER_APPENDED,this.onBufferAppended,this),e.off(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(H.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(H.MEDIA_ENDED,this.onMediaEnded,this),e.off(H.ERROR,this.onError,this),e.off(H.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){br(e,"play",this.onPlay),br(e,"pause",this.onPause),br(e,"seeking",this.onSeeking),br(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;sr(i,"seeking",this.onSeeking),sr(i,"timeupdate",this.onTimeupdate),sr(i,"play",this.onPlay),sr(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!n){this.clearScheduleState();const r=this.findItemIndex(i);this.setSchedulePosition(r)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){const r=this.getBufferingPlayer();r&&(this.log(`Removing schedule state for detachedData and ${r}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,r.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=g=>g&&e.getAssetPlayer(g.identifier),n=(g,y,v,T,S)=>{if(g){let w=g[y].start;const L=g.event;if(L){if(y==="playout"||L.timelineOccupancy!==Q0.Point){const O=i(v);O?.interstitial===L&&(w+=O.assetItem.startOffset+O[S])}}else{const O=T==="bufferedPos"?a():e[T];w+=O-g.start}return w}return 0},r=(g,y)=>{var v;if(g!==0&&y!=="primary"&&(v=e.schedule)!=null&&v.length){var T;const S=e.schedule.findItemIndexAtTime(g),w=(T=e.schedule.items)==null?void 0:T[S];if(w){const L=w[y].start-w.start;return g+L}}return g},a=()=>{const g=e.bufferedPos;return g===Number.MAX_VALUE?u("primary"):Math.max(g,0)},u=g=>{var y,v;return(y=e.primaryDetails)!=null&&y.live?e.primaryDetails.edge:((v=e.schedule)==null?void 0:v.durations[g])||0},c=(g,y)=>{var v,T;const S=e.effectivePlayingItem;if(S!=null&&(v=S.event)!=null&&v.restrictions.skip||!e.schedule)return;e.log(`seek to ${g} "${y}"`);const w=e.effectivePlayingItem,L=e.schedule.findItemIndexAtTime(g,y),O=(T=e.schedule.items)==null?void 0:T[L],I=e.getBufferingPlayer(),j=I?.interstitial,P=j?.appendInPlace,G=w&&e.itemsMatch(w,O);if(w&&(P||G)){const N=i(e.playingAsset),K=N?.media||e.primaryMedia;if(K){const k=y==="primary"?K.currentTime:n(w,y,e.playingAsset,"timelinePos","currentTime"),R=g-k,Y=(P?k:K.currentTime)+R;if(Y>=0&&(!N||P||Y<=N.duration)){K.currentTime=Y;return}}}if(O){let N=g;if(y!=="primary"){const k=O[y].start,R=g-k;N=O.start+R}const K=!e.isInterstitial(O);if((!e.isInterstitial(w)||w.event.appendInPlace)&&(K||O.event.appendInPlace)){const k=e.media||(P?I?.media:null);k&&(k.currentTime=N)}else if(w){const k=e.findItemIndex(w);if(L>k){const Y=e.schedule.findJumpRestrictedIndex(k+1,L);if(Y>k){e.setSchedulePosition(Y);return}}let R=0;if(K)e.timelinePos=N,e.checkBuffer();else{const Y=O.event.assetList,z=g-(O[y]||O).start;for(let X=Y.length;X--;){const re=Y[X];if(re.duration&&z>=re.startOffset&&z<re.startOffset+re.duration){R=X;break}}}e.setSchedulePosition(L,R)}}},d=()=>{const g=e.effectivePlayingItem;if(e.isInterstitial(g))return g;const y=t();return e.isInterstitial(y)?y:null},f={get bufferedEnd(){const g=t(),y=e.bufferingItem;if(y&&y===g){var v;return n(y,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-y.playout.start||((v=e.bufferingAsset)==null?void 0:v.startOffset)||0}return 0},get currentTime(){const g=d(),y=e.effectivePlayingItem;return y&&y===g?n(y,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-y.playout.start:0},set currentTime(g){const y=d(),v=e.effectivePlayingItem;v&&v===y&&c(g+v.playout.start,"playout")},get duration(){const g=d();return g?g.playout.end-g.playout.start:0},get assetPlayers(){var g;const y=(g=d())==null?void 0:g.event.assetList;return y?y.map(v=>e.getAssetPlayer(v.identifier)):[]},get playingIndex(){var g;const y=(g=d())==null?void 0:g.event;return y&&e.effectivePlayingAsset?y.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var g;return((g=e.schedule)==null||(g=g.events)==null?void 0:g.slice(0))||[]},get schedule(){var g;return((g=e.schedule)==null||(g=g.items)==null?void 0:g.slice(0))||[]},get interstitialPlayer(){return d()?f:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const g=t();return e.findItemIndex(g)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const g=e.effectivePlayingItem;return e.findItemIndex(g)},primary:{get bufferedEnd(){return a()},get currentTime(){const g=e.timelinePos;return g>0?g:0},set currentTime(g){c(g,"primary")},get duration(){return u("primary")},get seekableStart(){var g;return((g=e.primaryDetails)==null?void 0:g.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(g){c(g,"integrated")},get duration(){return u("integrated")},get seekableStart(){var g;return r(((g=e.primaryDetails)==null?void 0:g.fragmentStart)||0,"integrated")}},skip:()=>{const g=e.effectivePlayingItem,y=g?.event;if(y&&!y.restrictions.skip){const v=e.findItemIndex(g);if(y.appendInPlace){const T=g.playout.start+g.event.duration;c(T+.001,"playout")}else e.advanceAfterAssetEnded(y,v,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let n=this.media;!n&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(n=this.primaryMedia);const r=(t=n)==null?void 0:t.currentTime;if(!(r===void 0||!Ot(r)))return r}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n){this.detachedData={media:n};return}const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${ks(r)}`),this.detachedData=r}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}transferMediaTo(e,t){var i,n;if(e.media===t)return;let r=null;const a=this.hls,u=e!==a,c=u&&e.interstitial.appendInPlace,d=(i=this.detachedData)==null?void 0:i.mediaSource;let f;if(a.media)c&&(r=a.transferMedia(),this.detachedData=r),f="Primary";else if(d){const T=this.getBufferingPlayer();T?(r=T.transferMedia(),f=`${T}`):f="detached MediaSource"}else f="detached media";if(!r){if(d)r=this.detachedData,this.log(`using detachedData: MediaSource ${ks(r)}`);else if(!this.detachedData||a.media===t){const T=this.playerQueue;T.length>1&&T.forEach(S=>{if(u&&S.interstitial.appendInPlace!==c){const w=S.interstitial;this.clearInterstitial(S.interstitial,null),w.appendInPlace=!1,w.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${w}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const g=r&&"mediaSource"in r&&((n=r.mediaSource)==null?void 0:n.readyState)!=="closed",y=g&&r?r:t;this.log(`${g?"transfering MediaSource":"attaching media"} to ${u?e:"Primary"} from ${f} (media.currentTime: ${t.currentTime})`);const v=this.schedule;if(y===r&&v){const T=u&&e.assetId===v.assetIdAtEnd;y.overrides={duration:v.duration,endOfStream:!u||T,cueRemoval:!u}}e.attachMedia(y)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,n=this.effectivePlayingItem;if(i===-1){const r=this.hls.startPosition;if(this.log($m("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(r>=0||!this.primaryLive){const a=this.timelinePos=r>0?r:0,u=e.findItemIndexAtTime(a);this.setSchedulePosition(u)}}else if(n&&!this.playingItem){const r=e.findItemIndex(n);this.setSchedulePosition(r)}}advanceAssetBuffering(e,t){const i=e.event,n=i.findAssetIndex(t),r=Uv(i,n);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var a;const u=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];u&&this.bufferedToItem(u)}}advanceAfterAssetEnded(e,t,i){const n=Uv(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){const r=this.schedule.items;if(r){const a=t+1,u=r.length;if(a>=u){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log($m("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(a)}}}else{if(e.appendInPlace){const r=e.assetList[n];r&&this.advanceInPlace(r.timelineStart)}this.setSchedulePosition(t,n)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const n=t.parentIdentifier,r=i.getEvent(n);if(r){const a=i.findEventIndex(n),u=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,a,u-1)}}setSchedulePosition(e,t){var i;const n=(i=this.schedule)==null?void 0:i.items;if(!n||this.playbackDisabled)return;const r=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${r&&ha(r)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,u=this.playingLastItem;if(this.isInterstitial(a)){const f=a.event,g=this.playingAsset,y=g?.identifier,v=y?this.getAssetPlayer(y):null;if(v&&y&&(!this.eventItemsMatch(a,r)||t!==void 0&&y!==f.assetList[t].identifier)){var c;const T=f.findAssetIndex(g);if(this.log(`INTERSTITIAL_ASSET_ENDED ${T+1}/${f.assetList.length} ${fc(g)}`),this.endedAsset=g,this.playingAsset=null,this.hls.trigger(H.INTERSTITIAL_ASSET_ENDED,{asset:g,assetListIndex:T,event:f,schedule:n.slice(0),scheduleIndex:e,player:v}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(f,this.findItemIndex(this.playingItem),T);return}this.retreiveMediaSource(y,r),v.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&v.detachMedia()}if(!this.eventItemsMatch(a,r)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${f} ${ha(a)}`),f.hasPlayed=!0,this.hls.trigger(H.INTERSTITIAL_ENDED,{event:f,schedule:n.slice(0),scheduleIndex:e}),f.cue.once)){var d;this.updateSchedule();const T=(d=this.schedule)==null?void 0:d.items;if(r&&T){const S=this.findItemIndex(r);this.advanceSchedule(S,T,t,a,u)}return}}this.advanceSchedule(e,n,t,a,u)}advanceSchedule(e,t,i,n,r){const a=this.schedule;if(!a)return;const u=t[e]||null,c=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(f=>{const g=f.interstitial,y=a.findEventIndex(g.identifier);(y<e||y>e+1)&&this.clearInterstitial(g,u)}),this.isInterstitial(u)){this.timelinePos=Math.min(Math.max(this.timelinePos,u.start),u.end);const f=u.event;if(i===void 0){i=a.findAssetIndex(f,this.timelinePos);const T=Uv(f,i-1);if(f.isAssetPastPlayoutLimit(T)||f.appendInPlace&&this.timelinePos===u.end){this.advanceAfterAssetEnded(f,e,i);return}i=T}const g=this.waitingItem;this.assetsBuffered(u,c)||this.setBufferingItem(u);let y=this.preloadAssets(f,i);if(this.eventItemsMatch(u,g||n)||(this.waitingItem=u,this.log(`INTERSTITIAL_STARTED ${ha(u)} ${f.appendInPlace?"append in place":""}`),this.hls.trigger(H.INTERSTITIAL_STARTED,{event:f,schedule:t.slice(0),scheduleIndex:e})),!f.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${f}`);return}if(f.assetListLoader&&(f.assetListLoader.destroy(),f.assetListLoader=void 0),!c){this.log(`Waiting for attachMedia to start Interstitial ${f}`);return}this.waitingItem=this.endedItem=null,this.playingItem=u;const v=f.assetList[i];if(!v){this.advanceAfterAssetEnded(f,e,i||0);return}if(y||(y=this.getAssetPlayer(v.identifier)),y===null||y.destroyed){const T=f.assetList.length;this.warn(`asset ${i+1}/${T} player destroyed ${f}`),y=this.createAssetPlayer(f,v,i),y.loadSource()}if(!this.eventItemsMatch(u,this.bufferingItem)&&f.appendInPlace&&this.isAssetBuffered(v))return;this.startAssetPlayer(y,i,t,e,c),this.shouldPlay&&Zw(y.media)}else u?(this.resumePrimary(u,e,n),this.shouldPlay&&Zw(this.hls.media)):r&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var n,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${ha(e)}`),!((n=this.detachedData)!=null&&n.mediaSource)){let u=this.timelinePos;(u<e.start||u>=e.end)&&(u=this.getPrimaryResumption(e,t),this.log($m("resumePrimary",u)),this.timelinePos=u),this.attachPrimary(u,e)}if(!i)return;const a=(r=this.schedule)==null?void 0:r.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${ha(e)}`),this.hls.trigger(H.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const n=this.primaryDetails;if(t===0)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:gi.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const n=this.primaryMedia;if(!n)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log($m("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const n=this.hls;!n.loadingEnabled||!n.media||Math.abs((((i=n.mainForwardBufferInfo)==null?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(H.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(H.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const n=us(us({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=us(us({},this.altSelection),{},{audio:i});return}const r=us(us({},n),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=us(us({},this.altSelection),{},{subtitles:i});return}const r=us(us({},n),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=ow(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setAudioOption(t)||n.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=ow(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setSubtitleOption(t)||t.id!==-1&&n.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let n=0;n<t.length;n++){const r=t[n];if(r.cue.post){var i;const a=this.schedule.findEventIndex(r.identifier),u=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(u)&&this.eventItemsMatch(u,this.bufferingItem)&&this.bufferedToItem(u,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const n=(i=this.schedule)==null?void 0:i.items;if(e&&n){const r=this.findItemIndex(e,t);return n[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((r,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,n=gi.bufferInfo(this.primaryMedia,i,0);(n.end>i||(n.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${ha(e)} (was ${ha(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const n=gi.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}updateBufferedPos(e,t,i){const n=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!n)return;if(t.length===1&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}const a=this.playingItem,u=this.findItemIndex(a);let c=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var d;const f=this.findItemIndex(r),g=Math.min(f+1,t.length-1),y=t[g];if((c===-1&&r&&e>=r.end||(d=y.event)!=null&&d.appendInPlace&&e+.01>=y.start)&&(c=g),this.isInterstitial(r)){const v=r.event;if(g-u>1&&v.appendInPlace===!1||v.assetList.length===0&&v.assetListLoader)return}if(this.bufferedPos=e,c>f&&c>u)this.bufferedToItem(y);else{const v=this.primaryDetails;this.primaryLive&&v&&e>v.edge-v.targetduration&&y.start<v.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(y)&&this.preloadAssets(y.event,0)}}else i&&a&&!this.itemsMatch(a,r)&&(c===u?this.bufferedToItem(a):c===u+1&&this.bufferedToItem(t[c]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(n=>{const r=this.getAssetPlayer(n.identifier);return!(r!=null&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:n,events:r}=i;if(!n||!r)return t;const a=this.isInterstitial(e),u=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const c=u?u.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${ha(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const d=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((f,g)=>{const y=this.getAssetPlayer(f.identifier);y&&(g===d&&y.loadSource(),y.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger(H.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const n=this.detachedData;n?n.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,n=i.assetList.length===0&&!i.assetListLoader,r=i.cue.once;if(n||!r){const a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){const u=this.primaryMedia;u&&this.bufferAssetPlayer(a,u)}}}preloadAssets(e,t){const i=e.assetUrl,n=e.assetList.length,r=n===0&&!e.assetListLoader,a=e.cue.once;if(r){const c=e.timelineStart;if(e.appendInPlace){var u;const y=this.playingItem;!this.isInterstitial(y)&&(y==null||(u=y.nextEvent)==null?void 0:u.identifier)===e.identifier&&this.flushFrontBuffer(c+.25)}let d,f=0;if(!this.playingItem&&this.primaryLive&&(f=this.hls.startPosition,f===-1&&(f=this.hls.liveSyncPosition||0)),f&&!(e.cue.pre||e.cue.post)){const y=f-c;y>0&&(d=Math.round(y*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${d?` live-start: ${f} start-offset: ${d}`:""}`),i)return this.createAsset(e,0,0,c,e.duration,i);const g=this.assetListLoader.loadAssetList(e,d);g&&(e.assetListLoader=g)}else if(!a&&n){for(let d=t;d<n;d++){const f=e.assetList[d],g=this.getAssetPlayerQueueIndex(f.identifier);(g===-1||this.playerQueue[g].destroyed)&&!f.error&&this.createAssetPlayer(e,f,d)}const c=e.assetList[t];if(c){const d=this.getAssetPlayer(c.identifier);return d&&d.loadSource(),d}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(n=>{this.hls.trigger(H.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:n})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,n,r,a){const u={parentIdentifier:e.identifier,identifier:U9(e,a,t),duration:r,startOffset:i,timelineStart:n,uri:a};return this.createAssetPlayer(e,u,t)}createAssetPlayer(e,t,i){const n=this.hls,r=n.userConfig;let a=r.videoPreference;const u=n.loadLevelObj||n.levels[n.currentLevel];(a||u)&&(a=ys({},a),u.videoCodec&&(a.videoCodec=u.videoCodec),u.videoRange&&(a.allowedVideoRanges=[u.videoRange]));const c=n.audioTracks[n.audioTrack],d=n.subtitleTracks[n.subtitleTrack];let f=0;if(this.primaryLive||e.appendInPlace){const j=this.timelinePos-t.timelineStart;if(j>1){const P=t.duration;P&&j<P&&(f=j)}}const g=t.identifier,y=us(us({},r),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:g,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:f,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:c||r.audioPreference,subtitlePreference:d||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(y.timelineOffset=t.timelineStart));const v=y.cmcd;v!=null&&v.sessionId&&v.contentId&&(y.cmcd=ys({},v,{contentId:Rh(t.uri)})),this.getAssetPlayer(g)&&this.warn(`Duplicate date range identifier ${e} and asset ${g}`);const T=new H9(this.HlsPlayerClass,y,e,t);this.playerQueue.push(T),e.assetList[i]=t;let S=!0;const w=j=>{if(j.live){var P;const K=new Error(`Interstitials MUST be VOD assets ${e}`),k={fatal:!0,type:Vt.OTHER_ERROR,details:$e.INTERSTITIAL_ASSET_ITEM_ERROR,error:K},R=((P=this.schedule)==null?void 0:P.findEventIndex(e.identifier))||-1;this.handleAssetItemError(k,e,R,i,K.message);return}const G=j.edge-j.fragmentStart,N=t.duration;(S||N===null||G>N)&&(S=!1,this.log(`Interstitial asset "${g}" duration change ${N} > ${G}`),t.duration=G,this.updateSchedule())};T.on(H.LEVEL_UPDATED,(j,{details:P})=>w(P)),T.on(H.LEVEL_PTS_UPDATED,(j,{details:P})=>w(P)),T.on(H.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const L=(j,P)=>{const G=this.getAssetPlayer(g);if(G&&P.tracks){G.off(H.BUFFER_CODECS,L),G.tracks=P.tracks;const N=this.primaryMedia;this.bufferingAsset===G.assetItem&&N&&!G.media&&this.bufferAssetPlayer(G,N)}};T.on(H.BUFFER_CODECS,L);const O=()=>{var j;const P=this.getAssetPlayer(g);if(this.log(`buffered to end of asset ${P}`),!P||!this.schedule)return;const G=this.schedule.findEventIndex(e.identifier),N=(j=this.schedule.items)==null?void 0:j[G];this.isInterstitial(N)&&this.advanceAssetBuffering(N,t)};T.on(H.BUFFERED_TO_END,O);const I=j=>()=>{if(!this.getAssetPlayer(g)||!this.schedule)return;this.shouldPlay=!0;const G=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,G,j)};return T.once(H.MEDIA_ENDED,I(i)),T.once(H.PLAYOUT_LIMIT_REACHED,I(1/0)),T.on(H.ERROR,(j,P)=>{if(!this.schedule)return;const G=this.getAssetPlayer(g);if(P.details===$e.BUFFER_STALLED_ERROR){if(G!=null&&G.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(P,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${P.error} ${e}`)}),T.on(H.DESTROYING,()=>{if(!this.getAssetPlayer(g)||!this.schedule)return;const P=new Error(`Asset player destroyed unexpectedly ${g}`),G={fatal:!0,type:Vt.OTHER_ERROR,details:$e.INTERSTITIAL_ASSET_ITEM_ERROR,error:P};this.handleAssetItemError(G,e,this.schedule.findEventIndex(e.identifier),i,P.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${fc(t)}`),this.hls.trigger(H.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:T}),T}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t&&ha(t)}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,n,r){const{interstitial:a,assetItem:u,assetId:c}=e,d=a.assetList.length,f=this.playingAsset;this.endedAsset=null,this.playingAsset=u,(!f||f.identifier!==c)&&(f&&(this.clearAssetPlayer(f.identifier,i[n]),delete f.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${d} ${fc(u)}`),this.hls.trigger(H.INTERSTITIAL_ASSET_STARTED,{asset:u,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var i,n;if(!this.schedule)return;const{interstitial:r,assetItem:a}=e,u=this.schedule.findEventIndex(r.identifier),c=(i=this.schedule.items)==null?void 0:i[u];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=a;const d=this.getBufferingPlayer();if(d===e)return;const f=r.appendInPlace;if(f&&d?.interstitial.appendInPlace===!1)return;const g=d?.tracks||((n=this.detachedData)==null?void 0:n.tracks)||this.requiredTracks;if(f&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(g&&!tL(g,e.tracks)){const y=new Error(`Asset ${fc(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(g)}')`),v={fatal:!0,type:Vt.OTHER_ERROR,details:$e.INTERSTITIAL_ASSET_ITEM_ERROR,error:y},T=r.findAssetIndex(a);this.handleAssetItemError(v,r,u,T,y.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const n=i.currentTime,r=t.findAssetIndex(e,n),a=e.assetList[r];if(a){const u=this.getAssetPlayer(a.identifier);if(u){const c=u.currentTime||n-a.timelineStart,d=u.duration-c;if(this.warn(`Stalled at ${c} of ${c+d} in ${u} ${e} (media.currentTime: ${n})`),c&&(d/i.playbackRate<.5||u.bufferedInPlaceToEnd(i))&&u.hls){const f=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,f,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,n,r){if(e.details===$e.BUFFER_STALLED_ERROR)return;const a=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&fc(a)} ${e.error}`),!this.schedule)return;const u=a?.identifier||"",c=this.getAssetPlayerQueueIndex(u),d=this.playerQueue[c]||null,f=this.schedule.items,g=ys({},e,{fatal:!1,errorAction:Dc(!0),asset:a,assetListIndex:n,event:t,schedule:f,scheduleIndex:i,player:d});if(this.hls.trigger(H.INTERSTITIAL_ASSET_ERROR,g),!e.fatal)return;const y=this.playingAsset,v=this.bufferingAsset,T=new Error(r);if(a&&(this.clearAssetPlayer(u,null),a.error=T),!t.assetList.some(S=>!S.error))t.error=T;else for(let S=n;S<t.assetList.length;S++)this.resetAssetPlayer(t.assetList[S].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):y&&y.identifier===u?this.advanceAfterAssetEnded(t,i,n):v&&v.identifier===u&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,v)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;let n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${ha(i)} error: ${e.error}`),n===-1&&(n=this.hls.startPosition);const a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(n===-1){this.checkStart();return}if(!this.schedule)return;const r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}onAssetListLoaded(e,t){var i,n;const r=t.event,a=r.identifier,u=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;const c=r.timelineStart,d=r.duration;let f=0;u.forEach((S,w)=>{const L=parseFloat(S.DURATION);this.createAsset(r,w,f,c+f,L,S.URI),f+=L}),r.duration=f,this.log(`Loaded asset-list with duration: ${f} (was: ${d}) ${r}`);const g=this.waitingItem,y=g?.event.identifier===a;this.updateSchedule();const v=(n=this.bufferingItem)==null?void 0:n.event;if(y){var T;const S=this.schedule.findEventIndex(a),w=(T=this.schedule.items)==null?void 0:T[S];if(w){if(!this.playingItem&&this.timelinePos>w.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==S){r.error=new Error(`Interstitial ${u.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${r}`),this.log(r.error.message),this.updateSchedule(!0),this.primaryFallback(r);return}this.setBufferingItem(w)}this.setSchedulePosition(S)}else if(v?.identifier===a){const S=r.assetList[0];if(S){const w=this.getAssetPlayer(S.identifier);if(v.appendInPlace){const L=this.primaryMedia;w&&L&&this.bufferAssetPlayer(w,L)}else w&&w.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case $e.ASSET_LIST_PARSING_ERROR:case $e.ASSET_LIST_LOAD_ERROR:case $e.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case $e.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const Jw=500;class q9 extends h1{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",jt.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(H.LEVEL_LOADED,this.onLevelLoaded,this),e.on(H.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(H.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(H.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(H.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(H.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(H.LEVEL_LOADED,this.onLevelLoaded,this),e.off(H.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(H.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(H.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(H.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(H.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=ot.IDLE,this.setInterval(Jw),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:n}=t;if(this.fragContextChanged(i)||(an(i)&&(this.fragPrevious=i),this.state=ot.IDLE),!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let a;const u=i.start;for(let d=0;d<r.length;d++)if(u>=r[d].start&&u<=r[d].end){a=r[d];break}const c=i.start+i.duration;a?a.end=c:(a={start:u,end:c},r.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:n}=t;if(i===0&&n!==Number.POSITIVE_INFINITY){const r=n-1;if(r<=0)return;t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(a=>{for(let u=0;u<a.length;){if(a[u].end<=r){a.shift();continue}else if(a[u].start<r)a[u].start=r;else break;u++}}),this.fragmentTracker.removeFragmentsInRange(i,r,jt.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===jt.SUBTITLE&&(t.details===$e.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ot.STOPPED&&(this.state=ot.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&nR(this.levels,t)){this.levels=t.map(i=>new $h(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const n=new $h(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,jt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const n=this.levels[this.currentTrackId];n!=null&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==ot.STOPPED&&this.setInterval(Jw)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:n,levels:r}=this,{details:a,id:u}=t;if(!r){this.warn(`Subtitle tracks were reset while loading level ${u}`);return}const c=r[u];if(u>=r.length||!c)return;this.log(`Subtitle track ${u} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(i=c.details)!=null&&i.live){if(a.deltaUpdateFailed)return;const g=this.mainDetails;if(!g){this.startFragRequested=!1;return}const y=g.fragments[0];if(!c.details)a.hasProgramDateTime&&g.hasProgramDateTime?(Y0(a,g),d=a.fragmentStart):y&&(d=y.start,Xx(a,d));else{var f;d=this.alignPlaylists(a,c.details,(f=this.levelLastLoaded)==null?void 0:f.details),d===0&&y&&(d=y.start,Xx(a,d))}g&&!this.startFragRequested&&this.setStartPosition(g,d)}c.details=a,this.levelLastLoaded=c,u===n&&(this.hls.trigger(H.SUBTITLE_TRACK_UPDATED,{details:a,id:u,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===ot.IDLE&&(Au(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,n=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&n!=null&&n.key&&n.iv&&Lc(n.method)){const a=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,c1(n.method)).catch(u=>{throw r.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:t}),u}).then(u=>{const c=performance.now();r.trigger(H.FRAG_DECRYPTED,{frag:t,payload:u,stats:{tstart:a,tdecrypt:c}})}).catch(u=>{this.warn(`${u.name}: ${u.message}`),this.state=ot.IDLE})}}doTick(){if(!this.media){this.state=ot.IDLE;return}if(this.state===ot.IDLE){const{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:n}=this,r=this.getLoadPosition(),a=gi.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:u,len:c}=a,d=i.details,f=this.hls.maxBufferLength+d.levelTargetDuration;if(c>f)return;const g=d.fragments,y=g.length,v=d.edge;let T=null;const S=this.fragPrevious;if(u<v){const O=n.maxFragLookUpTolerance,I=u>v-O?0:O;T=Au(S,g,Math.max(g[0].start,u),I),!T&&S&&S.start<g[0].start&&(T=g[0])}else T=g[y-1];if(T=this.filterReplacedPrimary(T,i.details),!T)return;const w=T.sn-d.startSN,L=g[w-1];if(L&&L.cc===T.cc&&this.fragmentTracker.getState(L)===Sn.NOT_LOADED&&(T=L),this.fragmentTracker.getState(T)===Sn.NOT_LOADED){const O=this.mapToInitFragWhenRequired(T);O&&this.loadFragment(O,i,u)}}}loadFragment(e,t,i){an(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new K9(this.tracksBuffered[this.currentTrackId]||[])}}class K9{constructor(e){this.buffered=void 0;const t=(i,n,r)=>{if(n=n>>>0,n>r-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${r})`);return e[n][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const W9={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},bR=s=>String.fromCharCode(W9[s]||s),fa=15,xo=100,Y9={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},X9={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Q9={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Z9={25:2,26:4,29:6,30:8,31:10,27:13,28:15},J9=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class e${constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;cs.log(`${this.time} [${e}] ${i}`)}}}const su=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class TR{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class t${constructor(){this.uchar=" ",this.penState=new TR}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 i${constructor(e){this.chars=[],this.pos=0,this.currPenState=new TR,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<xo;t++)this.chars.push(new t$);this.logger=e}equals(e){for(let t=0;t<xo;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<xo;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<xo;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>xo&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=xo)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=bR(e);if(this.pos>=xo){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<xo;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<xo;i++){const n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class jv{constructor(e){this.rows=[],this.currRow=fa-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<fa;t++)this.rows.push(new i$(e));this.logger=e}reset(){for(let e=0;e<fa;e++)this.rows[e].clear();this.currRow=fa-1}equals(e){let t=!0;for(let i=0;i<fa;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<fa;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<fa;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 = "+ks(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let u=0;u<fa;u++)this.rows[u].clear();const r=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const u=a.rows[r].cueStartTime,c=this.logger.time;if(u!==null&&c!==null&&u<c)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[r+d])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,a=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground}const n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+ks(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",n=-1;for(let r=0;r<fa;r++){const a=this.rows[r].getTextString();a&&(n=r+1,e?t.push("Row "+n+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
`)),i}getTextAndFormat(){return this.rows}}class eA{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new jv(i),this.nonDisplayedMemory=new jv(i),this.lastOutputScreen=new jv(i),this.currRollUpRow=this.displayedMemory.rows[fa-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[fa-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=n[i]}this.logger.log(2,"MIDROW: "+ks(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 tA{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=n$(),this.logger=void 0;const n=this.logger=new e$;this.channels=[null,new eA(e,t,n),new eA(e+1,i,n)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const n=t[i]&127,r=t[i+1]&127;let a=!1,u=null;if(n===0&&r===0)continue;this.logger.log(3,()=>"["+su([t[i],t[i+1]])+"] -> ("+su([n,r])+")");const c=this.cmdHistory;if(n>=16&&n<=31){if(s$(n,r,c)){Hm(null,null,c),this.logger.log(3,()=>"Repeated command ("+su([n,r])+") is dropped");continue}Hm(n,r,this.cmdHistory),a=this.parseCmd(n,r),a||(a=this.parseMidrow(n,r)),a||(a=this.parsePAC(n,r)),a||(a=this.parseBackgroundAttributes(n,r))}else Hm(null,null,c);if(!a&&(u=this.parseChars(n,r),u)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(u):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!u&&this.logger.log(2,()=>"Couldn't parse cleaned data "+su([n,r])+" orig: "+su([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(i||n))return!1;const r=e===20||e===21||e===23?1:2,a=this.channels[r];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),this.currentChannel=r,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return n?(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+su([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(e===16||e===24)&&t>=64&&t<=95;if(!(n||r))return!1;const a=e<=23?1:2;t>=64&&t<=95?i=a===1?Y9[e]:Q9[e]:i=a===1?X9[e]:Z9[e];const u=this.channels[a];return u?(u.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(e,t){let i,n=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let a;r===17?a=t+80:r===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+bR(a)+"' in channel "+i),n=[a]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);return n&&this.logger.log(3,()=>"Char codes = "+su(n).join(",")),n}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=45&&t<=47;if(!(i||n))return!1;let r;const a={};e===16||e===24?(r=Math.floor((t-32)/2),a.background=J9[r],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const u=e<=23?1:2;return this.channels[u].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Hm(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Hm(s,e,t){t.a=s,t.b=e}function s$(s,e,t){return t.a===s&&t.b===e}function n$(){return{a:null,b:null}}var E1=(function(){if(W0!=null&&W0.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(u,c){if(typeof c!="string"||!Array.isArray(u))return!1;const d=c.toLowerCase();return~u.indexOf(d)?d:!1}function i(u){return t(s,u)}function n(u){return t(e,u)}function r(u,...c){let d=1;for(;d<arguments.length;d++){const f=arguments[d];for(const g in f)u[g]=f[g]}return u}function a(u,c,d){const f=this,g={enumerable:!0};f.hasBeenReset=!1;let y="",v=!1,T=u,S=c,w=d,L=null,O="",I=!0,j="auto",P="start",G=50,N="middle",K=50,k="middle";Object.defineProperty(f,"id",r({},g,{get:function(){return y},set:function(R){y=""+R}})),Object.defineProperty(f,"pauseOnExit",r({},g,{get:function(){return v},set:function(R){v=!!R}})),Object.defineProperty(f,"startTime",r({},g,{get:function(){return T},set:function(R){if(typeof R!="number")throw new TypeError("Start time must be set to a number.");T=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",r({},g,{get:function(){return S},set:function(R){if(typeof R!="number")throw new TypeError("End time must be set to a number.");S=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",r({},g,{get:function(){return w},set:function(R){w=""+R,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",r({},g,{get:function(){return L},set:function(R){L=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",r({},g,{get:function(){return O},set:function(R){const Y=i(R);if(Y===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=Y,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",r({},g,{get:function(){return I},set:function(R){I=!!R,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",r({},g,{get:function(){return j},set:function(R){if(typeof R!="number"&&R!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");j=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",r({},g,{get:function(){return P},set:function(R){const Y=n(R);if(!Y)throw new SyntaxError("An invalid or illegal string was specified.");P=Y,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",r({},g,{get:function(){return G},set:function(R){if(R<0||R>100)throw new Error("Position must be between 0 and 100.");G=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",r({},g,{get:function(){return N},set:function(R){const Y=n(R);if(!Y)throw new SyntaxError("An invalid or illegal string was specified.");N=Y,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",r({},g,{get:function(){return K},set:function(R){if(R<0||R>100)throw new Error("Size must be between 0 and 100.");K=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",r({},g,{get:function(){return k},set:function(R){const Y=n(R);if(!Y)throw new SyntaxError("An invalid or illegal string was specified.");k=Y,this.hasBeenReset=!0}})),f.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})();class r${decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function SR(s){function e(i,n,r,a){return(i|0)*3600+(n|0)*60+(r|0)+parseFloat(a||0)}const t=s.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 a${constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function _R(s,e,t,i){const n=i?s.split(i):[s];for(const r in n){if(typeof n[r]!="string")continue;const a=n[r].split(t);if(a.length!==2)continue;const u=a[0],c=a[1];e(u,c)}}const nb=new E1(0,0,""),zm=nb.align==="middle"?"middle":"center";function o$(s,e,t){const i=s;function n(){const u=SR(s);if(u===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),u}function r(u,c){const d=new a$;_R(u,function(y,v){let T;switch(y){case"region":for(let S=t.length-1;S>=0;S--)if(t[S].id===v){d.set(y,t[S].region);break}break;case"vertical":d.alt(y,v,["rl","lr"]);break;case"line":T=v.split(","),d.integer(y,T[0]),d.percent(y,T[0])&&d.set("snapToLines",!1),d.alt(y,T[0],["auto"]),T.length===2&&d.alt("lineAlign",T[1],["start",zm,"end"]);break;case"position":T=v.split(","),d.percent(y,T[0]),T.length===2&&d.alt("positionAlign",T[1],["start",zm,"end","line-left","line-right","auto"]);break;case"size":d.percent(y,v);break;case"align":d.alt(y,v,["start",zm,"end","left","right"]);break}},/:/,/\s/),c.region=d.get("region",null),c.vertical=d.get("vertical","");let f=d.get("line","auto");f==="auto"&&nb.line===-1&&(f=-1),c.line=f,c.lineAlign=d.get("lineAlign","start"),c.snapToLines=d.get("snapToLines",!0),c.size=d.get("size",100),c.align=d.get("align",zm);let g=d.get("position","auto");g==="auto"&&nb.position===50&&(g=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=g}function a(){s=s.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=n(),a(),r(s,e)}function ER(s){return s.replace(/<br(?: \/)?>/gi,`
`)}class l${constructor(){this.state="INITIAL",this.buffer="",this.decoder=new r$,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let r=t.buffer,a=0;for(r=ER(r);a<r.length&&r[a]!=="\r"&&r[a]!==`
`;)++a;const u=r.slice(0,a);return r[a]==="\r"&&++a,r[a]===`
`&&++a,t.buffer=r.slice(a),u}function n(r){_R(r,function(a,u){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=i();const u=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(u!=null&&u[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:r=i(),t.state){case"HEADER":/:/.test(r)?n(r):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new E1(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{o$(r,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const u=r.indexOf("-->")!==-1;if(!r||u&&(a=!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+=r}continue;case"BADCUE":r||(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 u$=/\r\n|\n\r|\n|\r/g,$v=function(e,t,i=0){return e.slice(i,i+t.length)===t},c$=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!Ot(t)||!Ot(i)||!Ot(n)||!Ot(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=3600*1e3*r,t};function w1(s,e,t){return Rh(s.toString())+Rh(e.toString())+Rh(t)}const d$=function(e,t,i){let n=e[t],r=e[n.prevCC];if(!r||!r.new&&n.new){e.ccOffset=e.presentationOffset=n.start,n.new=!1;return}for(;(a=r)!=null&&a.new;){var a;e.ccOffset+=n.start-r.start,n.new=!1,n=r,r=e[n.prevCC]}e.presentationOffset=i};function h$(s,e,t,i,n,r,a){const u=new l$,c=Hr(new Uint8Array(s)).trim().replace(u$,`
`).split(`
`),d=[],f=e?v7(e.baseTime,e.timescale):0;let g="00:00.000",y=0,v=0,T,S=!0;u.oncue=function(w){const L=t[i];let O=t.ccOffset;const I=(y-f)/9e4;if(L!=null&&L.new&&(v!==void 0?O=t.ccOffset=L.start:d$(t,i,I)),I){if(!e){T=new Error("Missing initPTS for VTT MPEGTS");return}O=I-t.presentationOffset}const j=w.endTime-w.startTime,P=Ur((w.startTime+O-v)*9e4,n*9e4)/9e4;w.startTime=Math.max(P,0),w.endTime=Math.max(P+j,0);const G=w.text.trim();w.text=decodeURIComponent(encodeURIComponent(G)),w.id||(w.id=w1(w.startTime,w.endTime,G)),w.endTime>0&&d.push(w)},u.onparsingerror=function(w){T=w},u.onflush=function(){if(T){a(T);return}r(d)},c.forEach(w=>{if(S)if($v(w,"X-TIMESTAMP-MAP=")){S=!1,w.slice(16).split(",").forEach(L=>{$v(L,"LOCAL:")?g=L.slice(6):$v(L,"MPEGTS:")&&(y=parseInt(L.slice(7)))});try{v=c$(g)/1e3}catch(L){T=L}return}else w===""&&(S=!1);u.parse(w+`
`)}),u.flush()}const Hv="stpp.ttml.im1t",wR=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,AR=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f$={left:"start",center:"center",right:"end",start:"start",end:"end"};function iA(s,e,t,i){const n=Ai(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=n.map(u=>Hr(u)),a=y7(e.baseTime,1,e.timescale);try{r.forEach(u=>t(m$(u,a)))}catch(u){i(u)}}function m$(s,e){const n=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(r).reduce((g,y)=>(g[y]=n.getAttribute(`ttp:${y}`)||r[y],g),{}),u=n.getAttribute("xml:space")!=="preserve",c=sA(zv(n,"styling","style")),d=sA(zv(n,"layout","region")),f=zv(n,"body","[begin]");return[].map.call(f,g=>{const y=kR(g,u);if(!y||!g.hasAttribute("begin"))return null;const v=Gv(g.getAttribute("begin"),a),T=Gv(g.getAttribute("dur"),a);let S=Gv(g.getAttribute("end"),a);if(v===null)throw nA(g);if(S===null){if(T===null)throw nA(g);S=v+T}const w=new E1(v-e,S-e,y);w.id=w1(w.startTime,w.endTime,w.text);const L=d[g.getAttribute("region")],O=c[g.getAttribute("style")],I=p$(L,O,c),{textAlign:j}=I;if(j){const P=f$[j];P&&(w.lineAlign=P),w.align=j}return ys(w,I),w}).filter(g=>g!==null)}function zv(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function sA(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function kR(s,e){return[].slice.call(s.childNodes).reduce((t,i,n)=>{var r;return i.nodeName==="br"&&n?t+`
`:(r=i.childNodes)!=null&&r.length?kR(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function p$(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let n=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(n=t[a]),r.reduce((u,c)=>{const d=Vv(e,i,c)||Vv(s,i,c)||Vv(n,i,c);return d&&(u[c]=d),u},{})}function Vv(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function nA(s){return new Error(`Could not parse ttml timestamp ${s}`)}function Gv(s,e){if(!s)return null;let t=SR(s);return t===null&&(wR.test(s)?t=g$(s,e):AR.test(s)&&(t=y$(s,e))),t}function g$(s,e){const t=wR.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function y$(s,e){const t=AR.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Vm{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class v${constructor(e){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.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=aA(),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}},e.on(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(H.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(H.FRAG_LOADING,this.onFragLoading,this),e.on(H.FRAG_LOADED,this.onFragLoaded,this),e.on(H.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(H.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(H.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(H.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(H.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(H.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(H.FRAG_LOADING,this.onFragLoading,this),e.off(H.FRAG_LOADED,this.onFragLoaded,this),e.off(H.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(H.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(H.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(H.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(H.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Vm(this,"textTrack1"),t=new Vm(this,"textTrack2"),i=new Vm(this,"textTrack3"),n=new Vm(this,"textTrack4");this.cea608Parser1=new tA(1,e,t),this.cea608Parser2=new tA(3,i,n)}addCues(e,t,i,n,r){let a=!1;for(let u=r.length;u--;){const c=r[u],d=x$(c[0],c[1],t,i);if(d>=0&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],i),a=!0,d/(i-t)>.5))return}if(a||r.push([t,i]),this.config.renderTextTracksNatively){const u=this.captionsTracks[e];this.Cues.newCue(u,t,i,n)}else{const u=this.Cues.newCue(null,t,i,n);this.hls.trigger(H.CUES_PARSED,{type:"captions",cues:u,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:a}){const{unparsedVttFrags:u}=this;i===jt.MAIN&&(this.initPTS[t.cc]={baseTime:n,timescale:r,trackId:a}),u.length&&(this.unparsedVttFrags=[],u.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(H.FRAG_LOADED,c):this.hls.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let n=0;n<i.textTracks.length;n++){const r=i.textTracks[n];if(rA(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))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:i,media:n}=this,{label:r,languageCode:a}=t[e],u=this.getExistingTrack(r,a);if(u)i[e]=u,yc(i[e]),yR(i[e],n);else{const c=this.createTextTrack("captions",r,a);c&&(c[e]=!0,i[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,n={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(H.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,i){const n=this.media;if(n)return n.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:n}=this;Object.keys(n).forEach(r=>{yc(n[r]),delete n[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=aA(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)yc(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(r=>r.textCodec===Hv);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(nR(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const a=this.media,u=a?u0(a.textTracks):null;if(this.tracks.forEach((c,d)=>{let f;if(u){let g=null;for(let y=0;y<u.length;y++)if(u[y]&&rA(u[y],c)){g=u[y],u[y]=null;break}g&&(f=g)}if(f)yc(f);else{const g=CR(c);f=this.createTextTrack(g,c.name,c.lang),f&&(f.mode="disabled")}f&&this.textTracks.push(f)}),u!=null&&u.length){const c=u.filter(d=>d!==null).map(d=>d.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(u=>({label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}));this.hls.trigger(H.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const r=`textTrack${n[1]}`,a=this.captionsProperties[r];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===jt.MAIN){var i,n;const{cea608Parser1:r,cea608Parser2:a,lastSn:u}=this,{cc:c,sn:d}=t.frag,f=(i=(n=t.part)==null?void 0:n.index)!=null?i:-1;r&&a&&(d!==u+1||d===u&&f!==this.lastPartIndex+1||c!==this.lastCc)&&(r.reset(),a.reset()),this.lastCc=c,this.lastSn=d,this.lastPartIndex=f}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===jt.SUBTITLE)if(n.byteLength){const r=i.decryptdata,a="stats"in t;if(r==null||!r.encrypted||a){const u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===Hv?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;iA(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{i.logger.log(`Failed to parse IMSC1: ${n}`),i.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:r,unparsedVttFrags:a}=this,u=r.length-1;if(!r[i.cc]&&u===-1){a.push(e);return}const c=this.hls,d=(t=i.initSegment)!=null&&t.data?ia(i.initSegment.data,new Uint8Array(n)).buffer:n;h$(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,f=>{this._appendCues(f,i.level),c.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},f=>{const g=f.message==="Missing initPTS for VTT MPEGTS";g?a.push(e):this._fallbackToIMSC1(i,n),c.logger.log(`Failed to parse VTT cue: ${f}`),!(g&&u>i.cc)&&c.trigger(H.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:f})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||iA(t,this.initPTS[e.cc],()=>{i.textCodec=Hv,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(r=>vR(n,r))}else{const n=this.tracks[t];if(!n)return;const r=n.default?"default":"subtitles"+t;i.trigger(H.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===jt.SUBTITLE&&this.onFragLoaded(H.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:n}=t;if(!(i.type===jt.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<n.length;r++){const a=n[r].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const u=this.extractCea608Data(a);this.cea608Parser1.addData(n[r].pts,u[0]),this.cea608Parser2.addData(n[r].pts,u[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!r||r==="video"){const{captionsTracks:u}=this;Object.keys(u).forEach(c=>sb(u[c],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:u}=this;Object.keys(u).forEach(c=>sb(u[c],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let r=0;r<i;r++){const a=e[n++],u=127&e[n++],c=127&e[n++];if(u===0&&c===0)continue;if((4&a)!==0){const f=3&a;(f===0||f===1)&&(t[f].push(u),t[f].push(c))}}return t}}function CR(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function rA(s,e){return!!s&&s.kind===CR(e)&&Jx(e,s)}function x$(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function aA(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const b$=/\s/,T$={newCue(s,e,t,i){const n=[];let r,a,u,c,d;const f=self.VTTCue||self.TextTrackCue;for(let y=0;y<i.rows.length;y++)if(r=i.rows[y],u=!0,c=0,d="",!r.isEmpty()){var g;for(let S=0;S<r.chars.length;S++)b$.test(r.chars[S].uchar)&&u?c++:(d+=r.chars[S].uchar,u=!1);r.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const v=ER(d.trim()),T=w1(e,t,v);s!=null&&(g=s.cues)!=null&&g.getCueById(T)||(a=new f(e,t,v),a.id=T,a.line=y+1,a.align="left",a.position=10+Math.min(80,Math.floor(c*8/32)*10),n.push(a))}return s&&n.length&&(n.sort((y,v)=>y.line==="auto"||v.line==="auto"?0:y.line>8&&v.line>8?v.line-y.line:y.line-v.line),n.forEach(y=>vR(s,y))),n}};function S$(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const _$=/(\d+)-(\d+)\/(\d+)/;class oA{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||k$,this.controller=new self.AbortController,this.stats=new s1}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const r=E$(e,this.controller.signal),a=e.responseType==="arraybuffer",u=a?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=c&&Ot(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(Vh(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(g=>{var y;this.response=this.loader=g;const v=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},d-(v-n.loading.start)),!g.ok){const{status:S,statusText:w}=g;throw new C$(w||"fetch, bad network response",S,g)}n.loading.first=v,n.total=A$(g.headers)||n.total;const T=(y=this.callbacks)==null?void 0:y.onProgress;return T&&Ot(t.highWaterMark)?this.loadProgressively(g,n,e,t.highWaterMark,T):a?g.arrayBuffer():e.responseType==="json"?g.json():g.text()}).then(g=>{var y,v;const T=this.response;if(!T)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const S=g[u];S&&(n.loaded=n.total=S);const w={url:T.url,data:g,code:T.status},L=(y=this.callbacks)==null?void 0:y.onProgress;L&&!Ot(t.highWaterMark)&&L(n,e,g,T),(v=this.callbacks)==null||v.onSuccess(w,n,e,T)}).catch(g=>{var y;if(self.clearTimeout(this.requestTimeout),n.aborted)return;const v=g&&g.code||0,T=g?g.message:null;(y=this.callbacks)==null||y.onError({code:v,text:T},e,g?g.details:null,n)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,n=0,r){const a=new FL,u=e.body.getReader(),c=()=>u.read().then(d=>{if(d.done)return a.dataLength&&r(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const f=d.value,g=f.length;return t.loaded+=g,g<n||a.dataLength?(a.push(f),a.dataLength>=n&&r(t,i,a.flush().buffer,e)):r(t,i,f.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function E$(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ys({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function w$(s){const e=_$.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function A$(s){const e=s.get("Content-Range");if(e){const i=w$(e);if(Ot(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function k$(s,e){return new self.Request(s.url,e)}class C$ extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const D$=/^age:\s*[\d.]+\s*$/im;class DR{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=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new s1,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return r(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),r(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{var u;(u=this.callbacks)==null||u.onError({code:i.status,text:a.message},t,i,n)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const n=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(n)for(const u in n)e.setRequestHeader(u,n[u]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&Ot(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const n=t.readyState,r=this.config;if(!i.aborted&&n>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const d=t.status,f=t.responseType==="text"?t.responseText:null;if(d>=200&&d<300){const T=f??t.response;if(T!=null){var a,u;i.loading.end=Math.max(self.performance.now(),i.loading.first);const S=t.responseType==="arraybuffer"?T.byteLength:T.length;i.loaded=i.total=S,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const w=(a=this.callbacks)==null?void 0:a.onProgress;w&&w(i,e,T,t);const L={url:t.responseURL,data:T,code:d};(u=this.callbacks)==null||u.onSuccess(L,i,e,t);return}}const g=r.loadPolicy.errorRetry,y=i.retry,v={url:e.url,data:void 0,code:d};if(q0(g,y,!1,v))this.retry(g);else{var c;cs.error(`${d} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:d,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(q0(e,t,!0))this.retry(e);else{var i;cs.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=o1(e,i.retry),i.retry++,cs.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&D$.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}}const L$={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},R$=us(us({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:DR,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:zU,bufferController:N7,capLevelController:T1,errorController:WU,fpsController:O9,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:kL,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:L$},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},I$()),{},{subtitleStreamController:q9,subtitleTrackController:B9,timelineController:v$,audioStreamController:D7,audioTrackController:L7,emeController:Rc,cmcdController:L9,contentSteeringController:I9,interstitialsController:G9});function I$(){return{cueHandler:T$,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 N$(s,e,t){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 i=rb(s),n=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return n.forEach(a=>{const u=`${a==="level"?"playlist":a}LoadPolicy`,c=e[u]===void 0,d=[];r.forEach(f=>{const g=`${a}Loading${f}`,y=e[g];if(y!==void 0&&c){d.push(g);const v=i[u].default;switch(e[u]={default:v},f){case"TimeOut":v.maxLoadTimeMs=y,v.maxTimeToFirstByteMs=y;break;case"MaxRetry":v.errorRetry.maxNumRetry=y,v.timeoutRetry.maxNumRetry=y;break;case"RetryDelay":v.errorRetry.retryDelayMs=y,v.timeoutRetry.retryDelayMs=y;break;case"MaxRetryTimeout":v.errorRetry.maxRetryDelayMs=y,v.timeoutRetry.maxRetryDelayMs=y;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${u}": ${ks(e[u])}`)}),us(us({},i),e)}function rb(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(rb):Object.keys(s).reduce((e,t)=>(e[t]=rb(s[t]),e),{}):s}function O$(s,e){const t=s.loader;t!==oA&&t!==DR?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):S$()&&(s.loader=oA,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const c0=2,M$=.1,P$=.05,B$=100;class F$ extends SL{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(H.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(B$),this.mediaSource=t.mediaSource;const i=this.media=t.media;sr(i,"playing",this.onMediaPlaying),sr(i,"waiting",this.onMediaWaiting),sr(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(br(i,"playing",this.onMediaPlaying),br(i,"waiting",this.onMediaWaiting),br(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,n;const r=(i=this.hls)==null?void 0:i.config;if(!r)return;const a=this.media;if(!a)return;const{seeking:u}=a,c=this.seeking&&!u,d=!this.seeking&&u,f=a.paused&&!u||a.ended||a.playbackRate===0;if(this.seeking=u,e!==t){t&&(this.ended=0),this.moved=!0,u||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!f&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||c){c&&this.stallResolved(e);return}if(f){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(H.MEDIA_ENDED,{stalled:!1}));return}if(!gi.getBuffered(a).length){this.nudgeRetry=0;return}const g=gi.bufferInfo(a,e,0),y=g.nextStart||0,v=this.fragmentTracker;if(u&&v&&this.hls){const G=lA(this.hls.inFlightFragments,e),N=g.len>c0,K=!y||G||y-e>c0&&!v.getPartialFragment(e);if(N||K)return;this.moved=!1}const T=(n=this.hls)==null?void 0:n.latestLevelDetails;if(!this.moved&&this.stalled!==null&&v){if(!(g.len>0)&&!y)return;const N=Math.max(y,g.start||0)-e,k=!!(T!=null&&T.live)?T.targetduration*2:c0,R=Gm(e,v);if(N>0&&(N<=k||R)){a.paused||this._trySkipBufferHole(R);return}}const S=r.detectStallWithCurrentTimeMs,w=self.performance.now(),L=this.waiting;let O=this.stalled;if(O===null)if(L>0&&w-L<S)O=this.stalled=L;else{this.stalled=w;return}const I=w-O;if(!u&&(I>=S||L)&&this.hls){var j;if(((j=this.mediaSource)==null?void 0:j.readyState)==="ended"&&!(T!=null&&T.live)&&Math.abs(e-(T?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(H.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(g),!this.media||!this.hls)return}const P=gi.bufferInfo(a,e,r.maxBufferHole);this._tryFixBufferStall(P,I,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(H.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&n&&n.length>1&&e>n.end(0)){const r=gi.bufferedInfo(gi.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const a=gi.timeRangesToArray(n),u=gi.bufferedInfo(a,t,0).bufferedIndex;if(u>-1&&u<a.length-1){const c=gi.bufferedInfo(a,e,0).bufferedIndex,d=a[u].end,f=a[u+1].start;if((c===-1||c>u)&&f-d<1&&e-d<2){const g=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${f} buffered index: ${c}`);this.warn(g.message),this.media.currentTime+=1e-6;let y=Gm(e,this.fragmentTracker);y&&"fragment"in y?y=y.fragment:y||(y=void 0);const v=gi.bufferInfo(this.media,e,0);this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:g,reason:g.message,frag:y,buffer:v.len,bufferInfo:v})}}}}}_tryFixBufferStall(e,t,i){var n,r;const{fragmentTracker:a,media:u}=this,c=(n=this.hls)==null?void 0:n.config;if(!u||!a||!c)return;const d=(r=this.hls)==null?void 0:r.latestLevelDetails,f=Gm(i,a);if((f||d!=null&&d.live&&i<d.fragmentStart)&&(this._trySkipBufferHole(f)||!this.media))return;const g=e.buffered,y=this.adjacentTraversal(e,i);(g&&g.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-i<c.maxBufferHole||y))&&(t>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,n=e.nextStart;if(i&&n){const r=i.getFragAtPos(t,jt.MAIN),a=i.getFragAtPos(n,jt.MAIN);if(r&&a)return a.sn-r.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:n,stalled:r}=this;if(!n&&r!==null&&i&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${ks(e)})`);this.warn(a.message),t.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:n}=this,r=(t=this.hls)==null?void 0:t.config;if(!n||!i||!r)return 0;const a=n.currentTime,u=gi.bufferInfo(n,a,0),c=a<u.start?u.start:u.nextStart;if(c&&this.hls){const f=u.len<=r.maxBufferHole,g=u.len>0&&u.len<1&&n.readyState<3,y=c-a;if(y>0&&(f||g)){if(y>r.maxBufferHole){let T=!1;if(a===0){const S=i.getAppendedFrag(0,jt.MAIN);S&&c<S.end&&(T=!0)}if(!T&&e){var d;if(!((d=this.hls.loadLevelObj)!=null&&d.details)||lA(this.hls.inFlightFragments,c))return 0;let w=!1,L=e.end;for(;L<c;){const O=Gm(L,i);if(O)L+=O.duration;else{w=!0;break}}if(w)return 0}}const v=Math.max(c+P$,a+M$);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${v}`),this.moved=!0,n.currentTime=v,!(e!=null&&e.gap)){const T=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${v}`),S={type:Vt.MEDIA_ERROR,details:$e.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:T,reason:T.message,buffer:u.len,bufferInfo:u};e&&("fragment"in e?S.part=e:S.frag=e),this.hls.trigger(H.ERROR,S)}return v}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:n}=this,r=t?.config;if(!i||!r)return 0;const a=i.currentTime;if(this.nudgeRetry++,n<r.nudgeMaxRetry){const u=a+(n+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${a} to ${u}`);this.warn(c.message),i.currentTime=u,t.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const u=new Error(`Playhead still not moving while enough data buffered @${a} after ${r.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}function lA(s,e){const t=uA(s.main);if(t&&t.start<=e)return t;const i=uA(s.audio);return i&&i.start<=e?i:null}function uA(s){if(!s)return null;switch(s.state){case ot.IDLE:case ot.STOPPED:case ot.ENDED:case ot.ERROR:return null}return s.frag}function Gm(s,e){return e.getAppendedFrag(s,jt.MAIN)||e.getPartialFragment(s)}const U$=.25;function ab(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function qv(s,e,t,i,n){let r=new s(e,t,"");try{r.value=i,n&&(r.type=n)}catch{r=new s(e,t,ks(n?us({type:n},i):i))}return r}const qm=(()=>{const s=ab();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class j${constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(H.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(H.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(H.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(H.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(H.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&yc(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return yR(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:n}=this.hls.config;if(!i&&!n)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=ab();if(a)for(let u=0;u<r.length;u++){const c=r[u].type;if(c===jr.emsg&&!i||!n)continue;const d=GL(r[u].data),f=r[u].pts;let g=f+r[u].duration;g>qm&&(g=qm),g-f<=0&&(g=f+U$);for(let v=0;v<d.length;v++){const T=d[v];if(!qL(T)){this.updateId3CueEnds(f,c);const S=qv(a,f,g,T,c);S&&this.id3Track.addCue(S)}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let r=n.length;r--;){const a=n[r];a.type===t&&a.startTime<e&&a.endTime===qm&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:r,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:u,enableID3MetadataCues:c}}=a;if(r&&(u||c)){let d;n==="audio"?d=f=>f.type===jr.audioId3&&c:n==="video"?d=f=>f.type===jr.emsg&&u:d=f=>f.type===jr.audioId3&&c||f.type===jr.emsg&&u,sb(r,t,i,d)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:n,enableDateRangeMetadataCues:r,interstitialsController:a}=this.hls.config;if(!r)return;const u=ab();if(i&&n&&!a){const{fragmentStart:S,fragmentEnd:w}=e;let L=this.assetCue;L?(L.startTime=S,L.endTime=w):u&&(L=this.assetCue=qv(u,S,w,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),L&&(L.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(L),L.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:d}=e,f=Object.keys(d);let g=this.dateRangeCuesAppended;if(c&&t){var y;if((y=c.cues)!=null&&y.length){const S=Object.keys(g).filter(w=>!f.includes(w));for(let w=S.length;w--;){var v;const L=S[w],O=(v=g[L])==null?void 0:v.cues;delete g[L],O&&Object.keys(O).forEach(I=>{const j=O[I];if(j){j.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(j)}catch{}}})}}else g=this.dateRangeCuesAppended={}}const T=e.fragments[e.fragments.length-1];if(!(f.length===0||!Ot(T?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let S=0;S<f.length;S++){const w=f[S],L=d[w],O=L.startTime,I=g[w],j=I?.cues||{};let P=I?.durationKnown||!1,G=qm;const{duration:N,endDate:K}=L;if(K&&N!==null)G=O+N,P=!0;else if(L.endOnNext&&!P){const R=f.reduce((Y,z)=>{if(z!==L.id){const X=d[z];if(X.class===L.class&&X.startDate>L.startDate&&(!Y||L.startDate<Y.startDate))return X}return Y},null);R&&(G=R.startTime,P=!0)}const k=Object.keys(L.attr);for(let R=0;R<k.length;R++){const Y=k[R];if(!oj(Y))continue;const z=j[Y];if(z)P&&!(I!=null&&I.durationKnown)?z.endTime=G:Math.abs(z.startTime-O)>.01&&(z.startTime=O,z.endTime=G);else if(u){let X=L.attr[Y];lj(Y)&&(X=iL(X));const J=qv(u,O,G,{key:Y,data:X},jr.dateRange);J&&(J.id=w,this.id3Track.addCue(J),j[Y]=J,a&&(Y==="X-ASSET-LIST"||Y==="X-ASSET-URL")&&J.addEventListener("enter",this.onEventCueEnter))}}g[w]={cues:j,dateRange:L,durationKnown:P}}}}}class $${constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const n=this.computeLatency();if(n===null)return;this._latency=n;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:a}=this.config;if(!r||a===1||!i.live)return;const u=this.targetLatency;if(u===null)return;const c=n-u,d=Math.min(this.maxLatency,u+i.targetduration);if(c<d&&c>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,a)),y=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,v=Math.min(g,Math.max(1,y));this.changeMediaPlaybackRate(t,v)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:n}=e,{liveSyncDuration:r,liveSyncDurationCount:a,lowLatencyMode:u}=this.config,c=this.hls.userConfig;let d=u&&i||t;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||d===0)&&(d=r!==void 0?r:a*n);const f=n;return d+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,f)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const n=i.edge,r=e-t-this.edgeStalled,a=n-i.totalduration,u=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,r),u)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;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}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(H.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(H.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(H.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(H.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===$e.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,n;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(n=this.targetLatency)==null?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class H$ extends b1{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-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(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(H.LEVEL_LOADED,this.onLevelLoaded,this),e.on(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(H.FRAG_BUFFERED,this.onFragBuffered,this),e.on(H.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(H.LEVEL_LOADED,this.onLevelLoaded,this),e.off(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(H.FRAG_BUFFERED,this.onFragBuffered,this),e.off(H.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,n=[],r={},a={};let u=!1,c=!1,d=!1;t.levels.forEach(f=>{const g=f.attrs;let{audioCodec:y,videoCodec:v}=f;y&&(f.audioCodec=y=H0(y,i)||void 0),v&&(v=f.videoCodec=EU(v));const{width:T,height:S,unknownCodecs:w}=f,L=w?.length||0;if(u||(u=!!(T&&S)),c||(c=!!v),d||(d=!!y),L||y&&!this.isAudioSupported(y)||v&&!this.isVideoSupported(v)){this.log(`Some or all CODECS not supported "${g.CODECS}"`);return}const{CODECS:O,"FRAME-RATE":I,"HDCP-LEVEL":j,"PATHWAY-ID":P,RESOLUTION:G,"VIDEO-RANGE":N}=g,k=`${`${P||"."}-`}${f.bitrate}-${G}-${I}-${O}-${N}-${j}`;if(r[k])if(r[k].uri!==f.url&&!f.attrs["PATHWAY-ID"]){const R=a[k]+=1;f.attrs["PATHWAY-ID"]=new Array(R+1).join(".");const Y=this.createLevel(f);r[k]=Y,n.push(Y)}else r[k].addGroupId("audio",g.AUDIO),r[k].addGroupId("text",g.SUBTITLES);else{const R=this.createLevel(f);r[k]=R,a[k]=1,n.push(R)}}),this.filterAndSortMediaOptions(n,t,u,c,d)}createLevel(e){const t=new $h(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=mL(n,[])}return t}isAudioSupported(e){return Uh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Uh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,n,r){var a;let u=[],c=[],d=e;const f=((a=t.stats)==null?void 0:a.parsing)||{};if((i||n)&&r&&(d=d.filter(({videoCodec:O,videoRange:I,width:j,height:P})=>(!!O||!!(j&&P))&&OU(I))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let O="no level with compatible codecs found in manifest",I=O;t.levels.length&&(I=`one or more CODECS in variant not supported: ${ks(t.levels.map(P=>P.attrs.CODECS).filter((P,G,N)=>N.indexOf(P)===G))}`,this.warn(I),O+=` (${I})`);const j=new Error(O);this.hls.trigger(H.ERROR,{type:Vt.MEDIA_ERROR,details:$e.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:j,reason:I})}}),f.end=performance.now();return}t.audioTracks&&(u=t.audioTracks.filter(O=>!O.audioCodec||this.isAudioSupported(O.audioCodec)),cA(u)),t.subtitles&&(c=t.subtitles,cA(c));const g=d.slice(0);d.sort((O,I)=>{if(O.attrs["HDCP-LEVEL"]!==I.attrs["HDCP-LEVEL"])return(O.attrs["HDCP-LEVEL"]||"")>(I.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&O.height!==I.height)return O.height-I.height;if(O.frameRate!==I.frameRate)return O.frameRate-I.frameRate;if(O.videoRange!==I.videoRange)return z0.indexOf(O.videoRange)-z0.indexOf(I.videoRange);if(O.videoCodec!==I.videoCodec){const j=tw(O.videoCodec),P=tw(I.videoCodec);if(j!==P)return P-j}if(O.uri===I.uri&&O.codecSet!==I.codecSet){const j=$0(O.codecSet),P=$0(I.codecSet);if(j!==P)return P-j}return O.averageBitrate!==I.averageBitrate?O.averageBitrate-I.averageBitrate:0});let y=g[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==g.length)){for(let O=0;O<g.length;O++)if(g[O].pathwayId===d[0].pathwayId){y=g[O];break}}this._levels=d;for(let O=0;O<d.length;O++)if(d[O]===y){var v;this._firstLevel=O;const I=y.bitrate,j=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${I}`),((v=this.hls.userConfig)==null?void 0:v.abrEwmaDefaultEstimate)===void 0){const P=Math.min(I,this.hls.config.abrEwmaDefaultEstimateMax);P>j&&j===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=P)}break}const T=r&&!n,S=this.hls.config,w=!!(S.audioStreamController&&S.audioTrackController),L={levels:d,audioTracks:u,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:n,altAudio:w&&!T&&u.some(O=>!!O.url)};f.end=performance.now(),this.hls.trigger(H.MANIFEST_PARSED,L)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const f=new Error("invalid level idx"),g=e<0;if(this.hls.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.LEVEL_SWITCH_ERROR,level:e,fatal:g,error:f,reason:f.message}),g)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,a=t[e],u=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&n&&r===u)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${u?" with Pathway "+u:""} from level ${i}${r?" with Pathway "+r:""}`);const c={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(H.LEVEL_SWITCHING,c);const d=a.details;if(!d||d.live){const f=this.switchParams(a.uri,n?.details,d);this.loadPlaylist(f)}}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.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(n=>t.indexOf(n)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===Ii.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===jt.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(r=>!!i[r]))return;const n=this._levels[t.level];n!=null&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}onLevelLoaded(e,t){var i;const{level:n,details:r}=t,a=t.levelInfo;if(!a){var u;this.warn(`Invalid level index ${n}`),(u=t.deliveryDirectives)!=null&&u.skip&&(r.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let c=a.details;c===t.details&&c.advanced&&(c=void 0),this.playlistLoaded(n,t,c)}else(i=t.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),n=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],a=e.details,u=a?.age;this.log(`Loading level index ${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${u&&a.live?" age "+u.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(H.LEVEL_LOADING,{url:i,level:n,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||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){var t;if(this._levels.length===1)return;const i=this._levels.filter((r,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(u=>u.level=-1)),!1));ML(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(H.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(H.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function cA(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function LR(){return self.SourceBuffer||self.WebKitSourceBuffer}function RR(){if(!Ll())return!1;const e=LR();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function z$(){if(!RR())return!1;const s=Ll();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(jh(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(jh(e,"audio"))))}function V$(){var s;const e=LR();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const G$=100;class q$ extends h1{constructor(e,t,i){super(e,t,i,"stream-controller",jt.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const n=this.media,r=n?n.currentTime:null;if(r===null||!Ot(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const a=this.getFwdBufferInfoAtPos(n,r,jt.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${a?a.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(H.MANIFEST_PARSED,this.onManifestParsed,this),e.on(H.LEVEL_LOADING,this.onLevelLoading,this),e.on(H.LEVEL_LOADED,this.onLevelLoaded,this),e.on(H.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(H.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(H.BUFFER_CREATED,this.onBufferCreated,this),e.on(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(H.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(H.MANIFEST_PARSED,this.onManifestParsed,this),e.off(H.LEVEL_LOADED,this.onLevelLoaded,this),e.off(H.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(H.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(H.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(H.BUFFER_CREATED,this.onBufferCreated,this),e.off(H.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(H.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(H.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:n}=this;if(this.stopLoad(),this.setInterval(G$),this.level=-1,!this.startFragRequested){let r=n.startLevel;r===-1&&(n.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=n.firstAutoLevel),n.nextLoadLevel=r,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=ot.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=ot.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case ot.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],n=i?.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=ot.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=ot.IDLE;break}break}case ot.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===ot.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:n}=this;if(t===null||!n&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[r]))return;const a=i[r],u=this.getMainFwdBufferInfo();if(u===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){const S={};this.altAudio===2&&(S.type="video"),this.hls.trigger(H.BUFFER_EOS,S),this.state=ot.ENDED;return}if(!this.buffering)return;e.loadLevel!==r&&e.manualLevel===-1&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const d=a.details;if(!d||this.state===ot.WAITING_LEVEL||this.waitForLive(a)){this.level=r,this.state=ot.WAITING_LEVEL,this.startFragRequested=!1;return}const f=u.len,g=this.getMaxBufferLength(a.maxBitrate);if(f>=g)return;this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);const y=this.backtrackFragment?this.backtrackFragment.start:u.end;let v=this.getNextFragment(y,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&an(v)&&this.fragmentTracker.getState(v)!==Sn.OK){var T;const w=((T=this.backtrackFragment)!=null?T:v).sn-d.startSN,L=d.fragments[w-1];L&&v.cc===L.cc&&(v=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,y)){if(!v.gap){const w=this.audioOnly&&!this.altAudio?ws.AUDIO:ws.VIDEO,L=(w===ws.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;L&&this.afterBufferFlushed(L,w,jt.MAIN)}v=this.getNextFragmentLoopLoading(v,d,u,jt.MAIN,g)}v&&(v.initSegment&&!v.initSegment.data&&!this.bitrateTest&&(v=v.initSegment),this.loadFragment(v,a,y))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);n===Sn.NOT_LOADED||n===Sn.PARTIAL?an(e)?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)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,jt.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const u=this.getMainFwdBufferInfo();if(!u||u.len<r.targetduration*2)return}if(!t.paused&&e){const u=this.hls.nextLoadLevel,c=e[u],d=this.fragLastKbps;d&&this.fragCurrent?i=this.fragCurrent.duration*c.maxBitrate/(1e3*d)+1:i=0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const u=this.followingBufferedFrag(a);if(u){this.abortCurrentFrag();const c=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,f=Math.max(a.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,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 ot.KEY_LOADING:case ot.FRAG_LOADING:case ot.FRAG_LOADING_WAITING_RETRY:case ot.PARSING:case ot.PARSED:this.state=ot.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;sr(i,"playing",this.onMediaPlaying),sr(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(br(i,"playing",this.onMediaPlaying),br(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(H.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,n=!1;for(let r=0;r<t.levels.length;r++){const a=t.levels[r].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,n=n||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&n&&!V$(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==ot.IDLE)return;const n=t.levelInfo;(!n.details||n.details.live&&(this.levelLastLoaded!==n||n.details.expired)||this.waitForCdnTuneIn(n.details))&&(this.state=ot.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n,startFragRequested:r}=this,a=t.level,u=t.details,c=u.totalduration;if(!n){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${u.startSN},${u.endSN}]${u.lastPartSn?`[part-${u.lastPartSn}-${u.lastPartIndex}]`:""}, cc [${u.startCC}, ${u.endCC}] duration:${c}`);const d=t.levelInfo,f=this.fragCurrent;f&&(this.state===ot.FRAG_LOADING||this.state===ot.FRAG_LOADING_WAITING_RETRY)&&f.level!==t.level&&f.loader&&this.abortCurrentFrag();let g=0;if(u.live||(i=d.details)!=null&&i.live){var y;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;g=this.alignPlaylists(u,d.details,(y=this.levelLastLoaded)==null?void 0:y.details)}if(d.details=u,this.levelLastLoaded=d,r||this.setStartPosition(u,g),this.hls.trigger(H.LEVEL_UPDATED,{details:u,level:a}),this.state===ot.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=ot.IDLE}r&&u.live&&this.synchronizeToLiveEdge(u),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=this.getLoadPosition(),a=e.fragmentStart,u=e.edge,c=r>=a-t.maxFragLookUpTolerance&&r<=u;if(n!==null&&i.duration>n&&(r<n||!c)){const f=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!c&&i.readyState<4||r<u-f)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${u}, reset currentTime to : ${n.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var d;const g=gi.bufferInfo(i,n,0);if(!((d=g.buffered)!=null&&d.length)){i.currentTime=n;return}if(g.start<=r){i.currentTime=n;return}const{nextStart:v}=gi.bufferedInfo(g.buffered,r,0);v&&(i.currentTime=v)}else i.currentTime=n}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const u=a[i.level];if(!u){this.warn(`Level ${i.level} not found on progress`);return}const c=u.details;if(!c){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const d=u.videoCodec,f=c.PTSKnown||!c.live,g=(t=i.initSegment)==null?void 0:t.data,y=this._getAudioCodec(u),v=this.transmuxer=this.transmuxer||new sR(this.hls,jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,S=T!==-1,w=new u1(i.level,i.sn,i.stats.chunkCount,r.byteLength,T,S),L=this.initPTS[i.cc];v.push(r,g,y,d,i,n,c.totalduration,f,w,L)}onAudioTrackSwitching(e,t){const i=this.hls,n=this.altAudio!==0;if(V0(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(H.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(H.AUDIO_TRACK_SWITCHED,t)}),i.trigger(H.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(H.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=V0(t.url,this.hls);if(i){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=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let n,r,a=!1;for(const u in i){const c=i[u];if(c.id==="main"){if(r=u,n=c,u==="video"){const d=i[u];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:n}=t,r=i.type===jt.MAIN;if(r){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===ot.PARSED&&(this.state=ot.IDLE);return}const u=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*u.total/(u.buffering.end-u.loading.first)),an(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}const a=this.media;a&&(!this._hasEnoughToStart&&gi.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=ot.ERROR;return}switch(t.details){case $e.FRAG_GAP:case $e.FRAG_PARSING_ERROR:case $e.FRAG_DECRYPT_ERROR:case $e.FRAG_LOAD_ERROR:case $e.FRAG_LOAD_TIMEOUT:case $e.KEY_LOAD_ERROR:case $e.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(jt.MAIN,t);break;case $e.LEVEL_LOAD_ERROR:case $e.LEVEL_LOAD_TIMEOUT:case $e.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===ot.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Ii.LEVEL&&(this.state=ot.IDLE);break;case $e.BUFFER_ADD_CODEC_ERROR:case $e.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case $e.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case $e.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=ot.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ws.AUDIO||!this.altAudio){const i=(t===ws.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,jt.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const n=this.timelineOffset;n&&i&&(i+=n);const r=this.getLevelDetails(),a=gi.getBuffered(e),u=a.length?a.start(0):0,c=u-i,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<d||this.loadingParts&&c<2*(r?.partTarget||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),i+=c,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${u}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:n}=this,r=i?.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=ot.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=r.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(H.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===ot.STOPPED||this.state===ot.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:n,chunkMeta:r}=e,a=this.getCurrentContext(r);if(!a){this.resetWhenMissingContext(r);return}const{frag:u,part:c,level:d}=a,{video:f,text:g,id3:y,initSegment:v}=n,{details:T}=d,S=this.altAudio?void 0:n.audio;if(this.fragContextChanged(u)){this.fragmentTracker.removeFragment(u);return}if(this.state=ot.PARSING,v){const w=v.tracks;if(w){const j=u.initSegment||u;if(this.unhandledEncryptionError(v,u))return;this._bufferInitSegment(d,w,j,r),i.trigger(H.FRAG_PARSING_INIT_SEGMENT,{frag:j,id:t,tracks:w})}const L=v.initPTS,O=v.timescale,I=this.initPTS[u.cc];if(Ot(L)&&(!I||I.baseTime!==L||I.timescale!==O)){const j=v.trackId;this.initPTS[u.cc]={baseTime:L,timescale:O,trackId:j},i.trigger(H.INIT_PTS_FOUND,{frag:u,id:t,initPTS:L,timescale:O,trackId:j})}}if(f&&T){S&&f.type==="audiovideo"&&this.logMuxedErr(u);const w=T.fragments[u.sn-1-T.startSN],L=u.sn===T.startSN,O=!w||u.cc>w.cc;if(n.independent!==!1){const{startPTS:I,endPTS:j,startDTS:P,endDTS:G}=f;if(c)c.elementaryStreams[f.type]={startPTS:I,endPTS:j,startDTS:P,endDTS:G};else if(f.firstKeyFrame&&f.independent&&r.id===1&&!O&&(this.couldBacktrack=!0),f.dropped&&f.independent){const N=this.getMainFwdBufferInfo(),K=(N?N.end:this.getLoadPosition())+this.config.maxBufferHole,k=f.firstKeyFramePTS?f.firstKeyFramePTS:I;if(!L&&K<k-this.config.maxBufferHole&&!O){this.backtrack(u);return}else O&&(u.gap=!0);u.setElementaryStreamInfo(f.type,u.start,j,u.start,G,!0)}else L&&I-(T.appliedTimelineOffset||0)>c0&&(u.gap=!0);u.setElementaryStreamInfo(f.type,I,j,P,G),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(f,u,c,r,L||O)}else if(L||O)u.gap=!0;else{this.backtrack(u);return}}if(S){const{startPTS:w,endPTS:L,startDTS:O,endDTS:I}=S;c&&(c.elementaryStreams[ws.AUDIO]={startPTS:w,endPTS:L,startDTS:O,endDTS:I}),u.setElementaryStreamInfo(ws.AUDIO,w,L,O,I),this.bufferFragmentData(S,u,c,r)}if(T&&y!=null&&y.samples.length){const w={id:t,frag:u,details:T,samples:y.samples};i.trigger(H.FRAG_PARSING_METADATA,w)}if(T&&g){const w={id:t,frag:u,details:T,samples:g.samples};i.trigger(H.FRAG_PARSING_USERDATA,w)}}logMuxedErr(e){this.warn(`${an(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,n){if(this.state!==ot.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:a,audiovideo:u}=t;if(r){const d=e.audioCodec;let f=s0(r.codec,d);f==="mp4a"&&(f="mp4a.40.5");const g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5");const y=r.metadata;y&&"channelCount"in y&&(y.channelCount||1)!==1&&g.indexOf("firefox")===-1&&(f="mp4a.40.5")}f&&f.indexOf("mp4a.40.5")!==-1&&g.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),d&&d!==f&&this.log(`Swapping manifest audio codec "${d}" for "${f}"`),r.levelCodec=f,r.id=jt.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${f||""}/${d||""}/${r.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=jt.MAIN;const d=a.codec;if(d?.length===4)switch(d){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${a.codec!==d?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}u&&(this.log(`Init audiovideo buffer, container:${u.container}, codecs[level/parsed]=[${e.codecs}/${u.codec}]`),delete t.video,delete t.audio);const c=Object.keys(t);if(c.length){if(this.hls.trigger(H.BUFFER_CODECS,t),!this.hls)return;c.forEach(d=>{const g=t[d].initSegment;g!=null&&g.byteLength&&this.hls.trigger(H.BUFFER_APPENDING,{type:d,data:g,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,jt.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}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=ot.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(gi.isBuffered(e,i)?t=this.getAppendedFrag(i):gi.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const n=this.fragPlaying,r=t.level;(!n||t.sn!==n.sn||n.level!==r)&&(this.fragPlaying=t,this.hls.trigger(H.FRAG_CHANGED,{frag:t}),(!n||n.level!==r)&&this.hls.trigger(H.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return Ot(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(Ot(t)){const i=this.getLevelDetails(),n=this.currentFrag||(i?Au(null,i.fragments,t):null);if(n){const r=n.programDateTime;if(r!==null){const a=r+(t-n.start)*1e3;return new Date(a)}}}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 K$ extends ra{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[i].loader;if(n){var t;if(e&&e!==((t=n.context)==null?void 0:t.frag.type))return;n.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=$e.KEY_LOAD_ERROR,i,n,r){return new _o({type:Vt.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:n})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let n=0,r=t.length;n<r;n++){const a=t[n];if(e.cc<=a.cc&&(!an(e)||!an(a)||e.sn<a.sn)||!i&&n==r-1)return this.emeController.selectKeySystemFormat(a).then(u=>{if(!this.emeController)return;a.setKeyFormat(u);const c=r0(u);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const n=ph(this.config);if(n.length)return this.emeController.getKeySystemAccess(n)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,n;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,$e.KEY_LOAD_ERROR,d))}const a=r.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,$e.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));const u=Kv(r);let c=this.keyIdToKeyInfo[u];if((i=c)!=null&&i.decryptdata.key)return r.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if(this.emeController&&(n=c)!=null&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(c.decryptdata)){case"usable":case"usable-in-future":return c.keyLoadPromise.then(f=>{const{keyInfo:g}=f;return r.key=g.decryptdata.key,{frag:e,keyInfo:g}})}switch(this.log(`${this.keyIdToKeyInfo[u]?"Rel":"L"}oading${r.keyId?" keyId: "+zn(r.keyId):""} URI: ${r.uri} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[u]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,$e.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&(n=t.initSegment)!=null&&n.data){const a=hU(t.initSegment.data);if(a.length){let u=a[0];u.some(c=>c!==0)?(this.log(`Using keyId found in init segment ${zn(u)}`),kl.setKeyIdForUri(e.decryptdata.uri,u)):(u=kl.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${zn(u)}`)),e.decryptdata.keyId=u}}if(!e.decryptdata.keyId&&!an(t))return Promise.resolve(i);const r=this.emeController.loadKey(i);return(e.keyLoadPromise=r.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,n=i.loader,r=new n(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((a,u)=>{const c={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=i.keyLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(y,v,T,S)=>{const{frag:w,keyInfo:L}=T,O=Kv(L.decryptdata);if(!w.decryptdata||L!==this.keyIdToKeyInfo[O])return u(this.createKeyLoadError(w,$e.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),S));L.decryptdata.key=w.decryptdata.key=new Uint8Array(y.data),w.keyLoader=null,L.loader=null,a({frag:w,keyInfo:L})},onError:(y,v,T,S)=>{this.resetLoader(v),u(this.createKeyLoadError(t,$e.KEY_LOAD_ERROR,new Error(`HTTP Error ${y.code} loading key ${y.text}`),T,us({url:c.url,data:void 0},y)))},onTimeout:(y,v,T)=>{this.resetLoader(v),u(this.createKeyLoadError(t,$e.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(y,v,T)=>{this.resetLoader(v),u(this.createKeyLoadError(t,$e.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};r.load(c,f,g)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const a=Kv(i.decryptdata)||n;delete this.keyIdToKeyInfo[a],r&&r.destroy()}}function Kv(s){if(s.keyFormat!==Vn.FAIRPLAY){const e=s.keyId;if(e)return zn(e)}return s.uri}function dA(s){const{type:e}=s;switch(e){case Ii.AUDIO_TRACK:return jt.AUDIO;case Ii.SUBTITLE_TRACK:return jt.SUBTITLE;default:return jt.MAIN}}function Wv(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class W${constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(H.MANIFEST_LOADING,this.onManifestLoading,this),e.on(H.LEVEL_LOADING,this.onLevelLoading,this),e.on(H.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(H.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(H.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(H.MANIFEST_LOADING,this.onManifestLoading,this),e.off(H.LEVEL_LOADING,this.onLevelLoading,this),e.off(H.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(H.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(H.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,r=i||n,a=new r(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ii.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:n,pathwayId:r,url:a,deliveryDirectives:u,levelInfo:c}=t;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:Ii.LEVEL,url:a,deliveryDirectives:u,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:a,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Ii.AUDIO_TRACK,url:r,deliveryDirectives:a,levelOrTrack:u})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:a,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Ii.SUBTITLE_TRACK,url:r,deliveryDirectives:a,levelOrTrack:u})}onLevelsUpdated(e,t){const i=this.loaders[Ii.LEVEL];if(i){const n=i.context;n&&!t.levels.some(r=>r===n.levelOrTrack)&&(i.abort(),delete this.loaders[Ii.LEVEL])}}load(e){var t;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const d=this.hls.logger,f=n.context;if(f&&f.levelOrTrack===e.levelOrTrack&&(f.url===e.url||f.deliveryDirectives&&!e.deliveryDirectives)){f.url===e.url?d.log(`[playlist-loader]: ignore ${e.url} ongoing request`):d.log(`[playlist-loader]: ignore ${e.url} in favor of ${f.url}`);return}d.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let r;if(e.type===Ii.MANIFEST?r=i.manifestLoadPolicy.default:r=ys({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),Ot((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Ii.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Ii.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Ii.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const f=d.partTarget,g=d.targetduration;if(f&&g){const y=Math.max(f*3,g*.8)*1e3;r=ys({},r,{maxTimeToFirstByteMs:Math.min(y,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(y,r.maxTimeToFirstByteMs)})}}}const a=r.errorRetry||r.timeoutRetry||{},u={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(d,f,g,y)=>{const v=this.getInternalLoader(g);this.resetInternalLoader(g.type);const T=d.data;f.parsing.start=performance.now(),qa.isMediaPlaylist(T)||g.type!==Ii.MANIFEST?this.handleTrackOrLevelPlaylist(d,f,g,y||null,v):this.handleMasterPlaylist(d,f,g,y)},onError:(d,f,g,y)=>{this.handleNetworkError(f,g,!1,d,y)},onTimeout:(d,f,g)=>{this.handleNetworkError(f,g,!0,void 0,d)}};n.load(e,u,c)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,n){const r=this.hls,a=e.data,u=Wv(e,i),c=qa.parseMasterPlaylist(a,u);if(c.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,c.playlistParsingError,n,t);return}const{contentSteering:d,levels:f,sessionData:g,sessionKeys:y,startTimeOffset:v,variableList:T}=c;this.variableList=T,f.forEach(O=>{const{unknownCodecs:I}=O;if(I){const{preferManagedMediaSource:j}=this.hls.config;let{audioCodec:P,videoCodec:G}=O;for(let N=I.length;N--;){const K=I[N];Uh(K,"audio",j)?(O.audioCodec=P=P?`${P},${K}`:K,Gc.audio[P.substring(0,4)]=2,I.splice(N,1)):Uh(K,"video",j)&&(O.videoCodec=G=G?`${G},${K}`:K,Gc.video[G.substring(0,4)]=2,I.splice(N,1))}}});const{AUDIO:S=[],SUBTITLES:w,"CLOSED-CAPTIONS":L}=qa.parseMasterPlaylistMedia(a,u,c);S.length&&!S.some(I=>!I.url)&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Hs({}),bitrate:0,url:""})),r.trigger(H.MANIFEST_LOADED,{levels:f,audioTracks:S,subtitles:w,captions:L,contentSteering:d,url:u,stats:t,networkDetails:n,sessionData:g,sessionKeys:y,startTimeOffset:v,variableList:T})}handleTrackOrLevelPlaylist(e,t,i,n,r){const a=this.hls,{id:u,level:c,type:d}=i,f=Wv(e,i),g=Ot(c)?c:Ot(u)?u:0,y=dA(i),v=qa.parseLevelPlaylist(e.data,f,g,y,0,this.variableList);if(d===Ii.MANIFEST){const T={attrs:new Hs({}),bitrate:0,details:v,name:"",url:f};v.requestScheduled=t.loading.start+IL(v,0),a.trigger(H.MANIFEST_LOADED,{levels:[T],audioTracks:[],url:f,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=v,this.handlePlaylistLoaded(v,e,t,i,n,r)}handleManifestParsingError(e,t,i,n,r){this.hls.trigger(H.ERROR,{type:Vt.NETWORK_ERROR,details:$e.MANIFEST_PARSING_ERROR,fatal:t.type===Ii.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:r})}handleNetworkError(e,t,i=!1,n,r){let a=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===Ii.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Ii.AUDIO_TRACK||e.type===Ii.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const u=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let c=$e.UNKNOWN,d=!1;const f=this.getInternalLoader(e);switch(e.type){case Ii.MANIFEST:c=i?$e.MANIFEST_LOAD_TIMEOUT:$e.MANIFEST_LOAD_ERROR,d=!0;break;case Ii.LEVEL:c=i?$e.LEVEL_LOAD_TIMEOUT:$e.LEVEL_LOAD_ERROR,d=!1;break;case Ii.AUDIO_TRACK:c=i?$e.AUDIO_TRACK_LOAD_TIMEOUT:$e.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ii.SUBTITLE_TRACK:c=i?$e.SUBTITLE_TRACK_LOAD_TIMEOUT:$e.SUBTITLE_LOAD_ERROR,d=!1;break}f&&this.resetInternalLoader(e.type);const g={type:Vt.NETWORK_ERROR,details:c,fatal:d,url:e.url,loader:f,context:e,error:u,networkDetails:t,stats:r};if(n){const y=t?.url||e.url;g.response=us({url:y,data:void 0},n)}this.hls.trigger(H.ERROR,g)}handlePlaylistLoaded(e,t,i,n,r,a){const u=this.hls,{type:c,level:d,levelOrTrack:f,id:g,groupId:y,deliveryDirectives:v}=n,T=Wv(t,n),S=dA(n);let w=typeof n.level=="number"&&S===jt.MAIN?d:void 0;const L=e.playlistParsingError;if(L){if(this.hls.logger.warn(`${L} ${e.url}`),!u.config.ignorePlaylistParsingErrors){u.trigger(H.ERROR,{type:Vt.NETWORK_ERROR,details:$e.LEVEL_PARSING_ERROR,fatal:!1,url:T,error:L,reason:L.message,response:t,context:n,level:w,parent:S,networkDetails:r,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const O=e.playlistParsingError=new Error("No Segments found in Playlist");u.trigger(H.ERROR,{type:Vt.NETWORK_ERROR,details:$e.LEVEL_EMPTY_ERROR,fatal:!1,url:T,error:O,reason:O.message,response:t,context:n,level:w,parent:S,networkDetails:r,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case Ii.MANIFEST:case Ii.LEVEL:if(w){if(!f)w=0;else if(f!==u.levels[w]){const O=u.levels.indexOf(f);O>-1&&(w=O)}}u.trigger(H.LEVEL_LOADED,{details:e,levelInfo:f||u.levels[0],level:w||0,id:g||0,stats:i,networkDetails:r,deliveryDirectives:v,withoutMultiVariant:c===Ii.MANIFEST});break;case Ii.AUDIO_TRACK:u.trigger(H.AUDIO_TRACK_LOADED,{details:e,track:f,id:g||0,groupId:y||"",stats:i,networkDetails:r,deliveryDirectives:v});break;case Ii.SUBTITLE_TRACK:u.trigger(H.SUBTITLE_TRACK_LOADED,{details:e,track:f,id:g||0,groupId:y||"",stats:i,networkDetails:r,deliveryDirectives:v});break}}}class $r{static get version(){return Hh}static isMSESupported(){return RR()}static isSupported(){return z$()}static getMediaSource(){return Ll()}static get Events(){return H}static get MetadataSchema(){return jr}static get ErrorTypes(){return Vt}static get ErrorDetails(){return $e}static get DefaultConfig(){return $r.defaultConfig?$r.defaultConfig:R$}static set DefaultConfig(e){$r.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new f1,this._autoLevelCapping=-1,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=eU(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=N$($r.DefaultConfig,e,t);this.userConfig=e,i.progressive&&O$(i,t);const{abrController:n,bufferController:r,capLevelController:a,errorController:u,fpsController:c}=i,d=new u(this),f=this.abrController=new n(this),g=new YU(this),y=i.interstitialsController,v=y?this.interstitialsController=new y(this,$r):null,T=this.bufferController=new r(this,g),S=this.capLevelController=new a(this),w=new c(this),L=new W$(this),O=i.contentSteeringController,I=O?new O(this):null,j=this.levelController=new H$(this,I),P=new j$(this),G=new K$(this.config,this.logger),N=this.streamController=new q$(this,g,G),K=this.gapController=new F$(this,g);S.setStreamController(N),w.setStreamController(N);const k=[L,j,N];v&&k.splice(1,0,v),I&&k.splice(1,0,I),this.networkControllers=k;const R=[f,T,K,S,w,P,g];this.audioTrackController=this.createController(i.audioTrackController,k);const Y=i.audioStreamController;Y&&k.push(this.audioStreamController=new Y(this,g,G)),this.subtitleTrackController=this.createController(i.subtitleTrackController,k);const z=i.subtitleStreamController;z&&k.push(this.subtititleStreamController=new z(this,g,G)),this.createController(i.timelineController,R),G.emeController=this.emeController=this.createController(i.emeController,R),this.cmcdController=this.createController(i.cmcdController,R),this.latencyController=this.createController($$,R),this.coreComponents=R,k.push(d);const X=d.onErrorOut;typeof X=="function"&&this.on(H.ERROR,X,d),this.on(H.MANIFEST_LOADED,L.onManifestLoaded,L)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,n){this._emitter.off(e,t,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const n=e===H.ERROR;this.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.INTERNAL_EXCEPTION,fatal:n,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(H.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){if(!e||"media"in e&&!e.media){const r=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(H.ERROR,{type:Vt.OTHER_ERROR,details:$e.ATTACH_MEDIA_ERROR,fatal:!0,error:r});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,n=t?e:{media:i};this._media=i,this.trigger(H.MEDIA_ATTACHING,n)}detachMedia(){this.logger.log("detachMedia"),this.trigger(H.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(H.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,n=this._url=i1.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(H.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[jt.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[jt.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[jt.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=F9()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.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){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.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}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){NU(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let n;if(t===-1&&e!=null&&e.length?n=e.length-1:n=t,i)for(let r=n;r--;){const a=e[r].attrs["HDCP-LEVEL"];if(a&&a<=i)return r}return n}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}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 allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}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}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=yL(t);return pL(e,i,navigator.mediaCapabilities)}}$r.defaultConfig=void 0;function hA(s,e){const t=s.includes("?")?"&":"?";return`${s}${t}v=${e}`}function IR({src:s,muted:e=x0,className:t}){const i=b.useRef(null),[n,r]=b.useState(!1),[a,u]=b.useState(null),[c,d]=b.useState(1),f=b.useMemo(()=>hA(s,c),[s,c]);return b.useEffect(()=>{let g=!1,y=null,v=null,T=null;const S=i.current;if(!S)return;const w=S;r(!1),u(null),Nh(w,{muted:e});const L=()=>{v&&window.clearTimeout(v),T&&window.clearInterval(T),v=null,T=null},O=()=>{g||(L(),d(G=>G+1))};async function I(){const G=Date.now();for(;!g&&Date.now()-G<9e4;){try{const N=hA(s,Date.now()),K=await fetch(N,{cache:"no-store"});if(K.status===403)return{ok:!1,reason:"private"};if(K.status===404)return{ok:!1,reason:"offline"};if(K.ok&&(await K.text()).includes("#EXTINF"))return{ok:!0}}catch{}await new Promise(N=>setTimeout(N,500))}return{ok:!1}}async function j(){const G=await I();if(!g){if(!G.ok){if(G.reason==="private"||G.reason==="offline"){u(G.reason),r(!0);return}window.setTimeout(()=>{g||O()},800);return}if(w.canPlayType("application/vnd.apple.mpegurl")){w.pause(),w.removeAttribute("src"),w.load(),w.src=f,w.load(),w.play().catch(()=>{});let N=Date.now(),K=-1;const k=()=>{w.currentTime>K+.01&&(K=w.currentTime,N=Date.now())},R=()=>{v||(v=window.setTimeout(()=>{v=null,!g&&Date.now()-N>3500&&O()},800))};return w.addEventListener("timeupdate",k),w.addEventListener("waiting",R),w.addEventListener("stalled",R),w.addEventListener("error",R),T=window.setInterval(()=>{g||!w.paused&&Date.now()-N>6e3&&O()},2e3),()=>{w.removeEventListener("timeupdate",k),w.removeEventListener("waiting",R),w.removeEventListener("stalled",R),w.removeEventListener("error",R)}}if(!$r.isSupported()){r(!0);return}y=new $r({lowLatencyMode:!0,liveSyncDurationCount:2,maxBufferLength:8}),y.on($r.Events.ERROR,(N,K)=>{if(y&&K.fatal){if(K.type===$r.ErrorTypes.NETWORK_ERROR){y.startLoad();return}if(K.type===$r.ErrorTypes.MEDIA_ERROR){y.recoverMediaError();return}O()}}),y.loadSource(f),y.attachMedia(w),y.on($r.Events.MANIFEST_PARSED,()=>{w.play().catch(()=>{})})}}let P;return(async()=>{const G=await j();typeof G=="function"&&(P=G)})(),()=>{g=!0,L();try{P?.()}catch{}try{y?.destroy()}catch{}}},[s,e,f]),n?m.jsx("div",{className:"text-xs text-gray-400 italic",children:a==="private"?"Private":a==="offline"?"Offline":""}):m.jsx("video",{ref:i,className:t,playsInline:!0,autoPlay:!0,muted:e,preload:"auto",crossOrigin:"anonymous",onClick:()=>{const g=i.current;g&&(g.muted=!1,g.play().catch(()=>{}))}})}const Qr=s=>(s||"").replaceAll("\\","/").split("/").pop()||"",A1=s=>s.startsWith("HOT ")?s.slice(4):s,Y$=s=>(s||"").trim().toLowerCase(),X$=s=>{const e=String(s??"").trim();if(!e)return[];const t=e.split(/[\n,;|]+/g).map(r=>r.trim()).filter(Boolean),i=new Set,n=[];for(const r of t){const a=r.toLowerCase();i.has(a)||(i.add(a),n.push(r))}return n.sort((r,a)=>r.localeCompare(a,void 0,{sensitivity:"base"})),n};function Q$(s){if(!Number.isFinite(s)||s<=0)return"—";const e=Math.floor(s/1e3),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}function Z$(s){if(typeof s!="number"||!Number.isFinite(s)||s<=0)return"—";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0||t>=100?0:t>=10?1:2;return`${t.toFixed(n)} ${e[i]}`}function fA(s){if(!s)return"—";const e=s instanceof Date?s:new Date(s),t=e.getTime();return Number.isFinite(t)?e.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—"}const Km=(...s)=>{for(const e of s){const t=typeof e=="string"?Number(e):e;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}return null};function J$(s){if(!s||!Number.isFinite(s))return"—";const e=s>=10?0:2;return`${s.toFixed(e)} fps`}function eH(s){return!s||!Number.isFinite(s)?"—":`${Math.round(s)}p`}function tH(s){const e=Qr(s||""),t=A1(e);if(!t)return null;const n=t.replace(/\.[^.]+$/,"").match(/_(\d{1,2})_(\d{1,2})_(\d{4})__(\d{1,2})-(\d{2})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),a=Number(n[2]),u=Number(n[3]),c=Number(n[4]),d=Number(n[5]),f=Number(n[6]);return[r,a,u,c,d,f].every(g=>Number.isFinite(g))?new Date(u,r-1,a,c,d,f):null}const iH=s=>{const e=Qr(s||""),t=A1(e);if(!t)return"—";const i=t.replace(/\.[^.]+$/,""),n=i.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(n?.[1])return n[1];const r=i.lastIndexOf("_");return r>0?i.slice(0,r):i},sH=s=>{const e=s,t=e.sizeBytes??e.fileSizeBytes??e.bytes??e.size??null;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:null};function bo(...s){return s.filter(Boolean).join(" ")}function nH(s){const[e,t]=b.useState(!1);return b.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia(s),n=()=>t(i.matches);return n(),i.addEventListener?i.addEventListener("change",n):i.addListener(n),()=>{i.removeEventListener?i.removeEventListener("change",n):i.removeListener(n)}},[s]),e}function rH(s){!s||s.__absTimelineShimInstalled||(s.__absTimelineShimInstalled=!0,s.__origCurrentTime=s.currentTime.bind(s),s.__origDuration=s.duration.bind(s),s.__setRelativeTime=e=>{try{s.__origCurrentTime(Math.max(0,e||0))}catch{}},s.currentTime=function(e){const t=Number(this.__timeOffsetSec??0)||0;if(typeof e=="number"&&Number.isFinite(e)){const n=Math.max(0,e);return typeof this.__serverSeekAbs=="function"?(this.__serverSeekAbs(n),n):this.__origCurrentTime(Math.max(0,n-t))}const i=Number(this.__origCurrentTime()??0)||0;return Math.max(0,t+i)},s.duration=function(){const e=Number(this.__fullDurationSec??0)||0;if(e>0)return e;const t=Number(this.__timeOffsetSec??0)||0,i=Number(this.__origDuration()??0)||0;return Math.max(0,t+i)})}function aH({job:s,expanded:e,onClose:t,onToggleExpand:i,modelKey:n,modelsByKey:r,isHot:a=!1,isFavorite:u=!1,isLiked:c=!1,isWatching:d=!1,onKeep:f,onDelete:g,onToggleHot:y,onToggleFavorite:v,onToggleLike:T,onToggleWatch:S,onStopJob:w,startMuted:L=JM,startAtSec:O=0}){const I=b.useMemo(()=>Qr(s.output?.trim()||"")||s.id,[s.output,s.id]),j=b.useMemo(()=>Qr(s.output?.trim()||""),[s.output]),P=b.useMemo(()=>Qr(s.output?.trim()||""),[s.output]),G=b.useMemo(()=>Z$(sH(s)),[s]),N=s,[K,k]=b.useState(()=>Number(s?.meta?.durationSeconds)||Number(s?.durationSeconds)||0),[R,Y]=b.useState(()=>s.status==="running"),[z,X]=b.useState(()=>({h:0,fps:null})),re=s.status==="running",[J,W]=b.useState(!1),q=re&&J,Z=b.useMemo(()=>(P||"").replace(/\.[^.]+$/,""),[P]),te=b.useMemo(()=>re?s.id:Z||s.id,[re,s.id,Z]);b.useEffect(()=>{if(re||K>0)return;const me=Qr(s.output?.trim()||"");if(!me)return;let we=!0;const ue=new AbortController;return(async()=>{try{const pe=lu(`/api/record/done/meta?file=${encodeURIComponent(me)}`),xe=await Ev(pe,{signal:ue.signal,cache:"no-store"});if(!xe.ok)return;const Oe=await xe.json(),Q=Number(Oe?.durationSeconds||Oe?.meta?.durationSeconds||0)||0;if(!we||Q<=0)return;k(Q);const ne=Ze.current;if(ne&&!ne.isDisposed?.())try{ne.__fullDurationSec=Q,ne.trigger?.("durationchange"),ne.trigger?.("timeupdate")}catch{}}catch{}})(),()=>{we=!1,ue.abort()}},[re,K,s.output]);const oe=j.startsWith("HOT "),F=b.useMemo(()=>{const me=(n||"").trim();return me||iH(s.output)},[n,s.output]),le=b.useMemo(()=>A1(j),[j]),ge=b.useMemo(()=>{const me=Number(K||0)||0;return me>0?Q$(me*1e3):"—"},[K]),Ie=b.useMemo(()=>{const me=tH(s.output);if(me)return fA(me);const we=N.startedAt??N.endedAt??N.createdAt??N.fileCreatedAt??N.ctime??null,ue=we?new Date(we):null;return fA(ue&&Number.isFinite(ue.getTime())?ue:null)},[s.output,N.startedAt,N.endedAt,N.createdAt,N.fileCreatedAt,N.ctime]),Le=b.useMemo(()=>Y$((n||F||"").trim()),[n,F]),Pe=b.useMemo(()=>{const me=r?.[Le];return X$(me?.tags)},[r,Le]),Je=b.useMemo(()=>lu(`/api/preview?id=${encodeURIComponent(te)}&file=thumbs.webp`),[te]),Se=b.useMemo(()=>lu(`/api/preview?id=${encodeURIComponent(te)}&play=1&file=index_hq.m3u8`),[te]),[Re,Ve]=b.useState(Je);b.useEffect(()=>{Ve(Je)},[Je]);const Ee=b.useMemo(()=>Km(z.h,N.videoHeight,N.height,N.meta?.height),[z.h,N.videoHeight,N.height,N.meta?.height]),_e=b.useMemo(()=>Km(z.fps,N.fps,N.frameRate,N.meta?.fps,N.meta?.frameRate),[z.fps,N.fps,N.frameRate,N.meta?.fps,N.meta?.frameRate]),[yt,ut]=b.useState(null),pt=b.useMemo(()=>eH(yt??Ee),[yt,Ee]),Fe=b.useMemo(()=>J$(_e),[_e]);b.useEffect(()=>{const me=we=>we.key==="Escape"&&t();return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[t]);const _t=b.useMemo(()=>{const me=`/api/preview?id=${encodeURIComponent(te)}&file=index_hq.m3u8&play=1`;return lu(re?`${me}&t=${Date.now()}`:me)},[te,re]);b.useEffect(()=>{if(!re){W(!1);return}let me=!0;const we=new AbortController;return W(!1),(async()=>{for(let pe=0;pe<120&&me&&!we.signal.aborted;pe++){try{const xe=await Ev(_t,{method:"GET",cache:"no-store",signal:we.signal,headers:{"cache-control":"no-cache"}});if(xe.ok){const Oe=await xe.text(),Q=Oe.includes("#EXTM3U"),ne=/#EXTINF:/i.test(Oe)||/\.ts(\?|$)/i.test(Oe)||/\.m4s(\?|$)/i.test(Oe);if(Q&&ne){me&&W(!0);return}}}catch{}await new Promise(xe=>setTimeout(xe,500))}})(),()=>{me=!1,we.abort()}},[re,_t]);const Qe=b.useCallback(me=>{const we=new URLSearchParams;return me.file&&we.set("file",me.file),me.id&&we.set("id",me.id),lu(`/api/record/video?${we.toString()}`)},[]),Xe=b.useMemo(()=>{if(re)return{src:"",type:""};if(!R)return{src:"",type:""};const me=Qr(s.output?.trim()||"");if(me){const we=me.toLowerCase().split(".").pop(),ue=we==="mp4"?"video/mp4":we==="ts"?"video/mp2t":"application/octet-stream";return{src:Qe({file:me}),type:ue}}return{src:Qe({id:s.id}),type:"video/mp4"}},[re,R,s.output,s.id,Qe]),ze=b.useRef(null),Ze=b.useRef(null),ct=b.useRef(null),[St,se]=b.useState(!1),ke=b.useCallback(()=>{const me=Ze.current;if(!me||me.isDisposed?.())return;const we=typeof me.videoHeight=="function"?me.videoHeight():0;typeof we=="number"&&we>0&&Number.isFinite(we)&&ut(we)},[]),De=b.useCallback(()=>{try{const me=Ze.current?.tech?.(!0)?.el?.()||Ze.current?.el?.()?.querySelector?.("video.vjs-tech")||ct.current;if(!me||!(me instanceof HTMLVideoElement))return null;const we=Number(me.videoWidth||0),ue=Number(me.videoHeight||0);if(!Number.isFinite(we)||!Number.isFinite(ue)||we<=0||ue<=0)return null;let pe=Gi.current;pe||(pe=document.createElement("canvas"),Gi.current=pe);const Oe=Math.min(1,640/we),Q=Math.max(1,Math.round(we*Oe)),ne=Math.max(1,Math.round(ue*Oe));pe.width!==Q&&(pe.width=Q),pe.height!==ne&&(pe.height=ne);const ce=pe.getContext("2d",{alpha:!1});return ce?(ce.drawImage(me,0,0,Q,ne),pe.toDataURL("image/jpeg",.78)):null}catch{return null}},[]),Ue=b.useMemo(()=>Qr(s.output?.trim()||"")||s.id,[s.output,s.id]),at=b.useMemo(()=>{const me=Number(O);return Number.isFinite(me)&&me>=0?me:0},[O]),dt=b.useRef("");b.useEffect(()=>{if(re){Y(!0);return}const me=Qr(s.output?.trim()||"");if(!me){Y(!0);return}let we=!0;const ue=new AbortController;return Y(!1),(async()=>{for(let pe=0;pe<80&&we&&!ue.signal.aborted;pe++){try{const xe=lu(`/api/record/done/meta?file=${encodeURIComponent(me)}`),Oe=await Ev(xe,{signal:ue.signal,cache:"no-store"});if(Oe.ok){const Q=await Oe.json(),ne=!!Q?.metaExists,ce=Number(Q?.durationSeconds||0)||0,fe=Number(Q?.height||0)||0,Ne=Number(Q?.fps||0)||0;if(ce>0){k(ce);const We=Ze.current;if(We&&!We.isDisposed?.())try{We.__fullDurationSec=ce,We.trigger?.("durationchange"),We.trigger?.("timeupdate")}catch{}}if(fe>0&&X({h:fe,fps:Ne>0?Ne:null}),ne){Y(!0);return}}}catch{}await new Promise(xe=>setTimeout(xe,250))}we&&Y(!0)})(),()=>{we=!1,ue.abort()}},[re,Ue,s.output]);const[,wt]=b.useState(0);b.useEffect(()=>{if(typeof window>"u")return;const me=window.visualViewport;if(!me)return;const we=()=>wt(ue=>ue+1);return we(),me.addEventListener("resize",we),me.addEventListener("scroll",we),window.addEventListener("resize",we),window.addEventListener("orientationchange",we),()=>{me.removeEventListener("resize",we),me.removeEventListener("scroll",we),window.removeEventListener("resize",we),window.removeEventListener("orientationchange",we)}},[]);const[kt,Tt]=b.useState(30),[Ft,Qt]=b.useState(null),Zt=!e,Et=nH("(min-width: 640px)"),Dt=Zt&&Et,yi=e||Dt,Pi="player_window_v1",Jt=420,ki=280,gt=12,V=320,$=200;b.useEffect(()=>{if(!St)return;const me=Ze.current;if(!me||me.isDisposed?.())return;const we=me.el();if(!we)return;const ue=we.querySelector(".vjs-control-bar");if(!ue)return;const pe=()=>{const Oe=Math.round(ue.getBoundingClientRect().height||0);Oe>0&&Tt(Oe)};pe();let xe=null;return typeof ResizeObserver<"u"&&(xe=new ResizeObserver(pe),xe.observe(ue)),window.addEventListener("resize",pe),()=>{window.removeEventListener("resize",pe),xe?.disconnect()}},[St,e]),b.useEffect(()=>se(!0),[]),b.useEffect(()=>{if(!yi){Qt(null);return}let me=document.getElementById("player-root");me||(me=document.createElement("div"),me.id="player-root");let we=null;if(Et){const ue=Array.from(document.querySelectorAll("dialog[open]"));we=ue.length?ue[ue.length-1]:null}we=we??document.body,we.appendChild(me),me.style.position="relative",me.style.zIndex="2147483647",Qt(me)},[Et,yi]),b.useEffect(()=>{const me=Ze.current;if(!me||me.isDisposed?.()||re||(rH(me),!Qr(s.output?.trim()||"")))return;const ue=Number(K||0)||0;return ue>0&&(me.__fullDurationSec=ue),me.__serverSeekAbs=pe=>{const xe=Math.max(0,Number(pe)||0);try{me.__origCurrentTime?.(xe);try{me.trigger?.("timeupdate")}catch{}}catch{try{me.currentTime?.(xe)}catch{}}},()=>{try{delete me.__serverSeekAbs}catch{}}},[s.output,re]),b.useLayoutEffect(()=>{if(!St||!ze.current||Ze.current||re||!R)return;const me=document.createElement("video");me.className="video-js vjs-big-play-centered w-full h-full",me.setAttribute("playsinline","true"),ze.current.appendChild(me),ct.current=me;const we=He(me,{autoplay:!0,muted:L,controls:!0,preload:"metadata",playsinline:!0,responsive:!0,fluid:!1,fill:!0,liveui:!1,html5:{vhs:{lowLatencyMode:!0}},inactivityTimeout:0,controlBar:{skipButtons:{backward:10,forward:10},volumePanel:{inline:!1},children:["skipBackward","playToggle","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","spacer","playbackRateMenuButton","fullscreenToggle"]},playbackRates:[.5,1,1.25,1.5,2]});return Ze.current=we,we.one("loadedmetadata",()=>{ke()}),we.userActive(!0),we.on("userinactive",()=>we.userActive(!0)),()=>{try{Ze.current&&(Ze.current.dispose(),Ze.current=null)}finally{ct.current&&(ct.current.remove(),ct.current=null)}}},[St,L,re,R,Ee,ke]),b.useEffect(()=>{const me=Ze.current;if(!me||me.isDisposed?.())return;const we=me.el();we&&we.classList.toggle("is-live-download",!!q)},[q]);const ie=b.useCallback(()=>{const me=Ze.current;if(!(!me||me.isDisposed?.())){try{me.pause(),me.reset?.()}catch{}try{me.src({src:"",type:"video/mp4"}),me.load?.()}catch{}}},[]),Te=b.useCallback(me=>{const we=Ze.current;if(!we||we.isDisposed?.())return;const ue=Math.max(0,Number(me)||0);try{const pe=Number(we.duration?.()??0),xe=Number.isFinite(pe)&&pe>0?Math.max(0,pe-.05):ue;we.currentTime(Math.min(ue,xe)),we.trigger?.("timeupdate")}catch{try{we.currentTime(ue)}catch{}}},[]);b.useEffect(()=>{if(!St)return;if(!re&&!R){ie();return}const me=Ze.current;if(!me||me.isDisposed?.())return;const we=me.currentTime()||0;if(me.muted(L),!Xe.src){try{me.pause(),me.reset?.(),me.error(null)}catch{}return}me.__timeOffsetSec=0;const ue=Number(K||0)||0;me.__fullDurationSec=ue;const pe=String(me.currentSrc?.()||"");if(dt.current="",pe&&pe===Xe.src){const Oe=me.play?.();Oe&&typeof Oe.catch=="function"&&Oe.catch(()=>{});return}me.src({src:Xe.src,type:Xe.type});const xe=()=>{const Oe=me.play?.();Oe&&typeof Oe.catch=="function"&&Oe.catch(()=>{})};me.one("loadedmetadata",()=>{if(me.isDisposed?.())return;ke();try{const Q=Number(K||0)||0;Q>0&&(me.__fullDurationSec=Q)}catch{}try{me.playbackRate(1)}catch{}const Oe=/mpegurl/i.test(Xe.type);if(we>0&&!Oe)try{const Q=Number(me.__timeOffsetSec??0)||0,ne=Math.max(0,we-Q);me.__setRelativeTime?.(ne)}catch{}try{me.trigger?.("timeupdate")}catch{}xe()}),xe()},[St,re,R,Xe.src,Xe.type,L,ke,K,ie]),b.useEffect(()=>{if(!St||re||!R||!Xe.src)return;const me=Ze.current;if(!me||me.isDisposed?.())return;if(!(at>0)){dt.current="";return}const we=`${Ue}|${Xe.src}|${at.toFixed(3)}`;if(dt.current===we)return;let ue=!1;const pe=()=>{if(ue)return;const ne=Ze.current;if(!ne||ne.isDisposed?.())return;const ce=String(ne.currentSrc?.()||"");if(!ce||ce!==Xe.src)return;const fe=ne.tech?.(!0)?.el?.()||ne.el?.()?.querySelector?.("video.vjs-tech");if(!((fe instanceof HTMLVideoElement?Number(fe.readyState||0):0)<1)){Te(at),dt.current=we;try{const We=ne.play?.();We&&typeof We.catch=="function"&&We.catch(()=>{})}catch{}}};if(pe(),dt.current===we)return;const xe=()=>pe();me.one?.("loadedmetadata",xe),me.one?.("canplay",xe),me.one?.("durationchange",xe);const Oe=window.setTimeout(pe,0),Q=window.setTimeout(pe,120);return()=>{ue=!0,window.clearTimeout(Oe),window.clearTimeout(Q);try{me.off?.("loadedmetadata",xe)}catch{}try{me.off?.("canplay",xe)}catch{}try{me.off?.("durationchange",xe)}catch{}}},[St,re,R,Xe.src,Ue,at,Te]),b.useEffect(()=>{if(!St)return;const me=Ze.current;if(!me||me.isDisposed?.())return;const we=()=>{s.status==="running"&&W(!1)};return me.on("error",we),()=>{try{me.off("error",we)}catch{}}},[St,s.status]),b.useEffect(()=>{const me=Ze.current;!me||me.isDisposed?.()||queueMicrotask(()=>me.trigger("resize"))},[e]),b.useEffect(()=>{const me=we=>{const pe=(we.detail?.file??"").trim();if(!pe)return;const xe=Qr(s.output?.trim()||"");xe&&xe===pe&&ie()};return window.addEventListener("player:release",me),()=>window.removeEventListener("player:release",me)},[s.output,ie]),b.useEffect(()=>{const me=we=>{const pe=(we.detail?.file??"").trim();if(!pe)return;const xe=Qr(s.output?.trim()||"");xe&&xe===pe&&(ie(),t())};return window.addEventListener("player:close",me),()=>window.removeEventListener("player:close",me)},[s.output,ie,t]);const Be=()=>{if(typeof window>"u")return{w:0,h:0,ox:0,oy:0,bottomInset:0};const me=window.visualViewport;if(me&&Number.isFinite(me.width)&&Number.isFinite(me.height)){const xe=Math.floor(me.width),Oe=Math.floor(me.height),Q=Math.floor(me.offsetLeft||0),ne=Math.floor(me.offsetTop||0),ce=Math.max(0,Math.floor(window.innerHeight-(me.height+me.offsetTop)));return{w:xe,h:Oe,ox:Q,oy:ne,bottomInset:ce}}const we=document.documentElement,ue=we?.clientWidth||window.innerWidth,pe=we?.clientHeight||window.innerHeight;return{w:ue,h:pe,ox:0,oy:0,bottomInset:0}},ht=b.useRef(null);b.useEffect(()=>{if(typeof window>"u")return;const{w:me,h:we}=Be();ht.current={w:me,h:we}},[]);const It=b.useCallback(()=>{const me=s,we=Km(Ze.current?.videoWidth?.(),me.videoWidth,me.width,me.meta?.width)??0,ue=Km(yt,Ze.current?.videoHeight?.(),me.videoHeight,me.height,me.meta?.height)??0;return we>0&&ue>0?we/ue:16/9},[s,yt]),Yt=b.useCallback(me=>{if(typeof window>"u")return me;const we=It(),ue=30,{w:pe,h:xe}=Be(),Oe=pe-gt*2,Q=Math.max(1,xe-gt*2-ue),ne=Math.max(1,$-ue);let ce=Math.max(V,Math.min(me.w,Oe)),fe=ce/we;fe<ne&&(fe=ne,ce=fe*we),fe>Q&&(fe=Q,ce=fe*we),ce>Oe&&(ce=Oe,fe=ce/we);const Ne=Math.round(fe+ue),We=Math.max(gt,Math.min(me.x,pe-ce-gt)),xt=Math.max(gt,Math.min(me.y,xe-Ne-gt));return{x:We,y:xt,w:Math.round(ce),h:Ne}},[It]),pi=b.useCallback(()=>{if(typeof window>"u")return{x:gt,y:gt,w:Jt,h:ki};try{const Q=window.localStorage.getItem(Pi);if(Q){const ne=JSON.parse(Q);if(typeof ne.x=="number"&&typeof ne.y=="number"&&typeof ne.w=="number"&&typeof ne.h=="number")return Yt({x:ne.x,y:ne.y,w:ne.w,h:ne.h})}}catch{}const{w:me,h:we}=Be(),ue=Jt,pe=ki,xe=Math.max(gt,me-ue-gt),Oe=Math.max(gt,we-pe-gt);return Yt({x:xe,y:Oe,w:ue,h:pe})},[Yt]),[oi,ci]=b.useState(()=>pi()),Bi=Dt&&oi.w<380,Gt=b.useCallback(me=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Pi,JSON.stringify(me))}catch{}},[]),xi=b.useRef(oi);b.useEffect(()=>{xi.current=oi},[oi]),b.useEffect(()=>{Dt&&ci(pi())},[Dt,pi]),b.useEffect(()=>{if(!Dt)return;const me=()=>{const we=ht.current,{w:ue,h:pe}=Be();ci(xe=>{if(!we)return Yt(xe);const Oe=24,Q=xe.x-gt,ne=we.w-gt-(xe.x+xe.w),ce=we.h-gt-(xe.y+xe.h),fe=Math.abs(Q)<=Oe,Ne=Math.abs(ne)<=Oe,We=Math.abs(ce)<=Oe;let xt=Yt(xe);return We&&(xt={...xt,y:Math.max(gt,pe-xt.h-gt)}),Ne?xt={...xt,x:Math.max(gt,ue-xt.w-gt)}:fe&&(xt={...xt,x:gt}),Yt(xt)}),ht.current={w:ue,h:pe}};return ht.current=(()=>{const{w:we,h:ue}=Be();return{w:we,h:ue}})(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)},[Dt,Yt]);const ai=b.useRef(null);b.useEffect(()=>{const me=Ze.current;if(!(!me||me.isDisposed?.()))return ai.current!=null&&cancelAnimationFrame(ai.current),ai.current=requestAnimationFrame(()=>{ai.current=null;try{me.trigger("resize")}catch{}}),()=>{ai.current!=null&&(cancelAnimationFrame(ai.current),ai.current=null)}},[Dt,oi.w,oi.h]);const[di,qt]=b.useState(!1),[Mt,vt]=b.useState(!1),[Ci,ss]=b.useState(null),[vs,xs]=b.useState(null),Gi=b.useRef(null),fi=b.useRef(null),Zi=b.useRef(null),ts=b.useRef(null),$i=b.useCallback(me=>{const{w:we,h:ue}=Be(),pe=gt,xe=we-me.w-gt,Oe=ue-me.h-gt,ne=me.x+me.w/2<we/2;return{...me,x:ne?pe:xe,y:Oe}},[]),Ji=b.useCallback(me=>{const we=ts.current;if(!we)return;const ue=me.clientX-we.sx,pe=me.clientY-we.sy,xe=we.start,Oe=Yt({x:xe.x+ue,y:xe.y+pe,w:xe.w,h:xe.h});Zi.current={x:Oe.x,y:Oe.y},ss($i(Oe)),fi.current==null&&(fi.current=requestAnimationFrame(()=>{fi.current=null;const Q=Zi.current;Q&&ci(ne=>({...ne,x:Q.x,y:Q.y}))}))},[Yt,$i]),Di=b.useCallback(()=>{ts.current&&(vt(!1),ss(null),fi.current!=null&&(cancelAnimationFrame(fi.current),fi.current=null),ts.current=null,window.removeEventListener("pointermove",Ji),window.removeEventListener("pointerup",Di),ci(me=>{const we=$i(Yt(me));return queueMicrotask(()=>Gt(we)),we}))},[Ji,$i,Yt,Gt]),$s=b.useCallback(me=>{if(!Dt||di||me.button!==0)return;me.preventDefault(),me.stopPropagation();const we=xi.current;ts.current={sx:me.clientX,sy:me.clientY,start:we},vt(!0);const ue=De();xs(ue),ss($i(we)),window.addEventListener("pointermove",Ji),window.addEventListener("pointerup",Di)},[Dt,di,Ji,Di,$i,De]),Cs=b.useRef(null),ns=b.useRef(null),rs=b.useRef(null),Rs=b.useCallback(me=>{const we=rs.current;if(!we)return;const ue=me.clientX-we.sx,pe=me.clientY-we.sy,xe=we.ratio,Oe=we.dir.includes("w"),Q=we.dir.includes("e"),ne=we.dir.includes("n"),ce=we.dir.includes("s");let fe=we.start.w,Ne=we.start.h,We=we.start.x,xt=we.start.y;const{w:it,h:mt}=Be(),Rt=24,Pt=we.start.x+we.start.w,Nt=we.start.y+we.start.h,Ht=Math.abs(it-gt-Pt)<=Rt,Vi=Math.abs(mt-gt-Nt)<=Rt,gn=hs=>{hs=Math.max(V,hs);let Ms=hs/xe;return Ms<$&&(Ms=$,hs=Ms*xe),{newW:hs,newH:Ms}},yn=hs=>{hs=Math.max($,hs);let Ms=hs*xe;return Ms<V&&(Ms=V,hs=Ms/xe),{newW:Ms,newH:hs}};if((Q||Oe)&&(ne||ce)){if(Math.abs(ue)>=Math.abs(pe)){const Ms=Q?we.start.w+ue:we.start.w-ue,{newW:En,newH:ba}=gn(Ms);fe=En,Ne=ba}else{const Ms=ce?we.start.h+pe:we.start.h-pe,{newW:En,newH:ba}=yn(Ms);fe=En,Ne=ba}Oe&&(We=we.start.x+(we.start.w-fe)),ne&&(xt=we.start.y+(we.start.h-Ne))}else if(Q||Oe){const hs=Q?we.start.w+ue:we.start.w-ue,{newW:Ms,newH:En}=gn(hs);fe=Ms,Ne=En,Oe&&(We=we.start.x+(we.start.w-fe)),xt=Vi?we.start.y+(we.start.h-Ne):we.start.y}else if(ne||ce){const hs=ce?we.start.h+pe:we.start.h-pe,{newW:Ms,newH:En}=yn(hs);fe=Ms,Ne=En,ne&&(xt=we.start.y+(we.start.h-Ne)),Ht?We=we.start.x+(we.start.w-fe):We=we.start.x}const Er=Yt({x:We,y:xt,w:fe,h:Ne});ns.current=Er,Cs.current==null&&(Cs.current=requestAnimationFrame(()=>{Cs.current=null;const hs=ns.current;hs&&ci(hs)}))},[Yt]),Li=b.useCallback(()=>{rs.current&&(qt(!1),ss(null),xs(null),Cs.current!=null&&(cancelAnimationFrame(Cs.current),Cs.current=null),rs.current=null,window.removeEventListener("pointermove",Rs),window.removeEventListener("pointerup",Li),Gt(xi.current))},[Rs,Gt]),qi=b.useCallback(me=>we=>{if(!Dt||we.button!==0)return;we.preventDefault(),we.stopPropagation();const ue=xi.current;rs.current={dir:me,sx:we.clientX,sy:we.clientY,start:ue,ratio:ue.w/ue.h},qt(!0),window.addEventListener("pointermove",Rs),window.addEventListener("pointerup",Li)},[Dt,Rs,Li]),[bs,Kt]=b.useState(!1),[ds,Fi]=b.useState(!1);b.useEffect(()=>{const me=window.matchMedia?.("(hover: hover) and (pointer: fine)"),we=()=>Kt(!!me?.matches);return we(),me?.addEventListener?.("change",we),()=>me?.removeEventListener?.("change",we)},[]);const Hi=Dt&&(ds||Mt||di),[Ge,Lt]=b.useState(!1);if(b.useEffect(()=>{s.status!=="running"&&Lt(!1)},[s.id,s.status]),!St||yi&&!Ft)return null;const Ct="inline-flex items-center justify-center rounded-md p-2 transition bg-white/75 text-gray-900 ring-1 ring-black/10 hover:bg-white/90 active:scale-[0.98] dark:bg-black/45 dark:text-white dark:ring-white/10 dark:hover:bg-black/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500",Wt=String(s.phase??"").toLowerCase(),_i=Wt==="stopping"||Wt==="remuxing"||Wt==="moving",ei=!w||!re||_i||Ge,Ki=m.jsx("div",{className:"flex items-center gap-1 min-w-0",children:re?m.jsxs(m.Fragment,{children:[m.jsx(ri,{variant:"primary",color:"red",size:"sm",rounded:"md",disabled:ei,title:_i||Ge?"Stoppe…":"Stop","aria-label":_i||Ge?"Stoppe…":"Stop",onClick:async me=>{if(me.preventDefault(),me.stopPropagation(),!ei)try{Lt(!0),await w?.(s.id)}finally{Lt(!1)}},className:bo("shadow-none shrink-0",Dt&&Bi&&"px-2"),children:m.jsx("span",{className:"whitespace-nowrap",children:_i||Ge?"Stoppe…":Dt&&Bi?"Stop":"Stoppen"})}),m.jsx(ga,{job:s,variant:"overlay",collapseToMenu:!0,busy:_i||Ge,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:S?me=>S(me):void 0,onToggleFavorite:v?me=>v(me):void 0,onToggleLike:T?me=>T(me):void 0,order:["watch","favorite","like","details"],className:"gap-1 min-w-0 flex-1"})]}):m.jsx(ga,{job:s,variant:"overlay",collapseToMenu:!0,isHot:a||oe,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:S?me=>S(me):void 0,onToggleFavorite:v?me=>v(me):void 0,onToggleLike:T?me=>T(me):void 0,onToggleHot:y?async me=>{ie(),await new Promise(ue=>setTimeout(ue,150)),await y(me),await new Promise(ue=>setTimeout(ue,0));const we=Ze.current;if(we&&!we.isDisposed?.()){const ue=we.play?.();ue&&typeof ue.catch=="function"&&ue.catch(()=>{})}}:void 0,onKeep:f?async me=>{ie(),t(),await new Promise(we=>setTimeout(we,150)),await f(me)}:void 0,onDelete:g?async me=>{ie(),t(),await new Promise(we=>setTimeout(we,150)),await g(me)}:void 0,order:["watch","favorite","like","hot","keep","delete","details"],className:"gap-1 min-w-0 flex-1"})}),Ts=e||Dt,In=re?"calc(4px + env(safe-area-inset-bottom))":`calc(${kt+2}px + env(safe-area-inset-bottom))`,Wi="top-2",Nn=e&&Et,On=m.jsx("div",{className:bo("relative overflow-visible",e||Dt?"flex-1 min-h-0":"aspect-video"),onMouseEnter:()=>{!Dt||!bs||Fi(!0)},onMouseLeave:()=>{!Dt||!bs||Fi(!1)},children:m.jsxs("div",{className:bo("relative w-full h-full",Dt&&"vjs-mini"),style:{"--vjs-controlbar-h":`${kt}px`},children:[re?m.jsxs("div",{className:"absolute inset-0 bg-black",children:[m.jsx(IR,{src:Se,muted:L,className:"w-full h-full object-contain object-bottom"}),m.jsxs("div",{className:"absolute right-2 bottom-2 z-[60] pointer-events-none inline-flex items-center gap-1.5 rounded-full bg-red-600/90 px-2 py-1 text-[11px] font-semibold text-white shadow-sm",children:[m.jsx("span",{className:"inline-block size-1.5 rounded-full bg-white animate-pulse"}),"Live"]})]}):m.jsx("div",{ref:ze,className:"absolute inset-0"}),m.jsxs("div",{className:bo("absolute inset-x-0 z-30 pointer-events-none","top-0"),children:[m.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-16 bg-gradient-to-b from-black/35 to-transparent"}),m.jsx("div",{className:bo("absolute inset-x-2",Wi),children:m.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-2",children:[m.jsx("div",{className:"min-w-0 pointer-events-auto overflow-visible",children:Nn?null:Ki}),Dt?m.jsxs("button",{type:"button","aria-label":"Player-Fenster verschieben",title:"Ziehen zum Verschieben",onPointerDown:$s,onClick:me=>{me.preventDefault(),me.stopPropagation()},className:bo(Ct,"px-3 gap-1 cursor-grab active:cursor-grabbing select-none",Hi?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none -translate-y-1",Mt&&"scale-[0.98] opacity-90"),children:[m.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"}),m.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"}),m.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"})]}):null,m.jsxs("div",{className:"shrink-0 flex items-center gap-1 pointer-events-auto",children:[m.jsx("button",{type:"button",className:Ct,onClick:i,"aria-label":e?"Minimieren":"Maximieren",title:e?"Minimieren":"Maximieren",children:e?m.jsx(WO,{className:"h-5 w-5"}):m.jsx(XO,{className:"h-5 w-5"})}),m.jsx("button",{type:"button",className:Ct,onClick:t,"aria-label":"Schließen",title:"Schließen",children:m.jsx(v0,{className:"h-5 w-5"})})]})]})})]}),m.jsxs("div",{className:bo("player-ui pointer-events-none absolute inset-x-2 z-50","flex items-end justify-between gap-2","transition-all duration-200 ease-out"),style:{bottom:In},children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-white",children:F}),m.jsx("div",{className:"truncate text-[11px] text-white/80",children:m.jsxs("span",{className:"inline-flex items-center gap-1 min-w-0 align-middle",children:[m.jsx("span",{className:"truncate",children:le||I}),a||oe?m.jsx("span",{className:"shrink-0 rounded bg-amber-500/25 px-1.5 py-0.5 font-semibold text-white",children:"HOT"}):null]})})]}),m.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 text-[11px] text-white",children:[pt!=="—"?m.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:pt}):null,re?null:m.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:ge}),G!=="—"?m.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:G}):null]})]})]})}),Zs=m.jsx("div",{className:"w-[360px] shrink-0 border-r border-white/10 bg-black/40 text-white",children:m.jsxs("div",{className:"h-full p-4 flex flex-col gap-3 overflow-y-auto",children:[m.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-white/10 bg-black/30",children:m.jsx("div",{className:"relative aspect-video",children:m.jsx("img",{src:Re,alt:"",className:"absolute inset-0 h-full w-full object-contain opacity-80",draggable:!1,onError:()=>{}})})}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("div",{className:"text-lg font-semibold truncate",children:F}),m.jsx("div",{className:"text-xs text-white/70 break-all",children:le||I})]}),m.jsx("div",{className:"pointer-events-auto",children:m.jsxs("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[re?m.jsx(ri,{variant:"primary",color:"red",size:"sm",rounded:"md",disabled:ei,title:_i||Ge?"Stoppe…":"Stop","aria-label":_i||Ge?"Stoppe…":"Stop",onClick:async me=>{if(me.preventDefault(),me.stopPropagation(),!ei)try{Lt(!0),await w?.(s.id)}finally{Lt(!1)}},className:"shadow-none",children:_i||Ge?"Stoppe…":"Stoppen"}):null,m.jsx(ga,{job:s,variant:"table",collapseToMenu:!1,busy:_i||Ge,isHot:a||oe,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:S?me=>S(me):void 0,onToggleFavorite:v?me=>v(me):void 0,onToggleLike:T?me=>T(me):void 0,onToggleHot:y?async me=>{ie(),await new Promise(ue=>setTimeout(ue,150)),await y(me),await new Promise(ue=>setTimeout(ue,0));const we=Ze.current;if(we&&!we.isDisposed?.()){const ue=we.play?.();ue&&typeof ue.catch=="function"&&ue.catch(()=>{})}}:void 0,onKeep:f?async me=>{ie(),t(),await new Promise(we=>setTimeout(we,150)),await f(me)}:void 0,onDelete:g?async me=>{ie(),t(),await new Promise(we=>setTimeout(we,150)),await g(me)}:void 0,order:re?["watch","favorite","like","details"]:["watch","favorite","like","hot","details","keep","delete"],className:"flex items-center justify-start gap-1"})]})}),m.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-2 text-sm",children:[m.jsx("div",{className:"text-white/60",children:"Status"}),m.jsx("div",{className:"font-medium",children:s.status}),m.jsx("div",{className:"text-white/60",children:"Auflösung"}),m.jsx("div",{className:"font-medium",children:pt}),m.jsx("div",{className:"text-white/60",children:"FPS"}),m.jsx("div",{className:"font-medium",children:Fe}),m.jsx("div",{className:"text-white/60",children:"Laufzeit"}),m.jsx("div",{className:"font-medium",children:ge}),m.jsx("div",{className:"text-white/60",children:"Größe"}),m.jsx("div",{className:"font-medium",children:G}),m.jsx("div",{className:"text-white/60",children:"Datum"}),m.jsx("div",{className:"font-medium",children:Ie}),m.jsx("div",{className:"col-span-2",children:Pe.length?m.jsx("div",{className:"flex flex-wrap gap-1.5",children:Pe.map(me=>m.jsx("span",{className:"rounded bg-white/10 px-2 py-0.5 text-xs text-white/90",children:me},me))}):m.jsx("span",{className:"text-white/50",children:"—"})})]})]})}),pn=Dt&&Mt&&Ci?m.jsx("div",{className:"pointer-events-none absolute z-0 player-snap-ghost overflow-hidden rounded-lg border-2 border-dashed border-white/70 bg-black/55 shadow-2xl dark:border-white/60",style:{left:Ci.x-oi.x,top:Ci.y-oi.y,width:Ci.w,height:Ci.h},"aria-hidden":"true",children:m.jsxs("div",{className:"absolute inset-0 bg-black",children:[m.jsx("img",{src:vs||Re,alt:"",className:"absolute inset-0 h-full w-full object-contain opacity-80",draggable:!1,onError:()=>{}}),m.jsx("div",{className:"absolute inset-x-0 top-0 h-14 bg-gradient-to-b from-black/55 to-transparent"}),m.jsxs("div",{className:"absolute top-2 right-2 flex items-center gap-1.5 opacity-80",children:[m.jsx("div",{className:"h-8 w-8 rounded-md bg-white/15 ring-1 ring-white/20"}),m.jsx("div",{className:"h-8 w-8 rounded-md bg-white/15 ring-1 ring-white/20"})]}),m.jsxs("div",{className:"absolute top-2 left-2 h-8 rounded-md bg-white/12 px-2 flex items-center gap-1 ring-1 ring-white/15",children:[m.jsx("span",{className:"h-1 w-1 rounded-full bg-white/50"}),m.jsx("span",{className:"h-1 w-1 rounded-full bg-white/50"}),m.jsx("span",{className:"h-1 w-1 rounded-full bg-white/50"})]}),m.jsxs("div",{className:"absolute inset-x-2 bottom-2 flex items-end justify-between gap-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-white/95",children:F}),m.jsxs("div",{className:"truncate text-[11px] text-white/75",children:[le||I,a||oe?m.jsx("span",{className:"ml-1.5 rounded bg-amber-500/30 px-1.5 py-0.5 text-white",children:"HOT"}):null]})]}),m.jsxs("div",{className:"shrink-0 flex items-center gap-1 text-[10px] text-white/90",children:[pt!=="—"?m.jsx("span",{className:"rounded bg-black/45 px-1.5 py-0.5",children:pt}):null,!re&&ge!=="—"?m.jsx("span",{className:"rounded bg-black/45 px-1.5 py-0.5",children:ge}):null]})]}),m.jsx("div",{className:"absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-white/8 to-transparent"})]})}):null,ln=m.jsx(pa,{edgeToEdgeMobile:!0,noBodyPadding:!0,className:bo("relative z-10 flex flex-col shadow-2xl ring-1 ring-black/10 dark:ring-white/10","w-full",Ts?"h-full":"h-[220px] max-h-[40vh]",e?"rounded-2xl":Dt?"rounded-lg":"rounded-none"),bodyClassName:"flex flex-col flex-1 min-h-0 p-0",children:m.jsxs("div",{className:"flex flex-1 min-h-0",children:[Nn?Zs:null,On]})}),{w:Is,h:un,ox:Mn,oy:Js,bottomInset:en}=Be(),zi={left:Mn+16,top:Js+16,width:Math.max(0,Is-32),height:Math.max(0,un-32)},Pn=e?zi:Dt?{left:oi.x,top:oi.y,width:oi.w,height:oi.h}:void 0,_n=m.jsxs(m.Fragment,{children:[m.jsx("style",{children:`
/* Live-Download: Progress/Seek-Bar ausblenden */
.is-live-download .vjs-progress-control {
display: none !important;
}
/* ---------- Video.js Layout-Fix (Finished Player) ----------
Ziel:
- Video endet immer direkt über der Controlbar
- Aspect Ratio bleibt erhalten
- Resize stabil (kein "Wandern")
*/
/* Container schwarz, falls Letterboxing sichtbar wird */
.vjs-mini .video-js,
.vjs-mini .video-js .vjs-tech,
.vjs-mini .video-js .vjs-poster {
background-color: transparent !important;
}
/* ECHTES Video (<video class="vjs-tech">) */
.vjs-mini .video-js .vjs-tech {
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
width: 100% !important;
height: 100% !important;
/* Seitenverhältnis beibehalten + unten an die Controlbar "anlehnen" */
object-fit: contain !important;
object-position: center top !important;
}
/* Poster genauso behandeln (falls sichtbar) */
.vjs-mini .video-js .vjs-poster {
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
width: 100% !important;
height: 100% !important;
background-position: center bottom !important;
background-size: contain !important;
background-repeat: no-repeat !important;
}
/* Untertitel-/Texttrack-Layer darf ebenfalls nicht in die Controlbar laufen */
.vjs-mini .video-js .vjs-text-track-display {
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: var(--vjs-controlbar-h, 30px) !important;
inset: 0 0 var(--vjs-controlbar-h, 30px) 0 !important;
}
/* Sicherheitsnetz: Controlbar immer wirklich unten */
.vjs-mini .video-js .vjs-control-bar {
bottom: 0 !important;
}
.player-snap-ghost {
backdrop-filter: blur(2px);
-webkit-backdrop-filter: blur(2px);
}
.player-snap-ghost::after {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
pointer-events: none;
}
`}),e||Dt?m.jsxs("div",{className:bo("fixed z-[2147483647]",!di&&!Mt&&"transition-[left,top,width,height] duration-300 ease-[cubic-bezier(.2,.9,.2,1)]"),style:{...Pn,willChange:di?"left, top, width, height":void 0},children:[pn,ln,Dt?m.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[m.jsx("div",{className:"pointer-events-auto absolute -left-1 bottom-2 top-2 w-3 cursor-ew-resize",onPointerDown:qi("w")}),m.jsx("div",{className:"pointer-events-auto absolute -right-1 bottom-2 top-2 w-3 cursor-ew-resize",onPointerDown:qi("e")}),m.jsx("div",{className:"pointer-events-auto absolute left-2 right-2 -top-1 h-3 cursor-ns-resize",onPointerDown:qi("n")}),m.jsx("div",{className:"pointer-events-auto absolute left-2 right-2 -bottom-1 h-3 cursor-ns-resize",onPointerDown:qi("s")}),m.jsx("div",{className:"pointer-events-auto absolute -left-1 -top-1 h-4 w-4 cursor-nwse-resize",onPointerDown:qi("nw")}),m.jsx("div",{className:"pointer-events-auto absolute -right-1 -top-1 h-4 w-4 cursor-nesw-resize",onPointerDown:qi("ne")}),m.jsx("div",{className:"pointer-events-auto absolute -left-1 -bottom-1 h-4 w-4 cursor-nesw-resize",onPointerDown:qi("sw")}),m.jsx("div",{className:"pointer-events-auto absolute -right-1 -bottom-1 h-4 w-4 cursor-nwse-resize",onPointerDown:qi("se")})]}):null]}):m.jsx("div",{className:`\r
fixed z-[2147483647] inset-x-0 w-full\r
shadow-2xl\r
md:bottom-4 md:left-1/2 md:right-auto md:inset-x-auto md:w-[min(760px,calc(100vw-32px))] md:-translate-x-1/2\r
`,style:{bottom:`calc(${en}px + env(safe-area-inset-bottom))`},children:ln})]});return yi?Nc.createPortal(_n,Ft):_n}function NR({jobId:s,thumbTick:e,autoTickMs:t=1e4,blur:i=!1,className:n,alignStartAt:r,alignEndAt:a=null,alignEveryMs:u,fastRetryMs:c,fastRetryMax:d,fastRetryWindowMs:f,thumbsWebpUrl:g,thumbsCandidates:y}){const v=i?"blur-md":"",T=30,S=b.useRef(null),w=b.useRef(!0),[L,O]=b.useState(!1),I=b.useRef(!1),[j,P]=b.useState(0),[G,N]=b.useState(!1),[K,k]=b.useState(!1),R=b.useRef(null),Y=b.useRef(0),z=b.useRef(!1),X=b.useRef(!1),[re,J]=b.useState(!0),W=Re=>{if(typeof Re=="number"&&Number.isFinite(Re))return Re;if(Re instanceof Date)return Re.getTime();const Ve=Date.parse(String(Re??""));return Number.isFinite(Ve)?Ve:NaN},q=Re=>{const Ve=String(Re??"").trim();return Ve?/^https?:\/\//i.test(Ve)||Ve.startsWith("/")?Ve:`/${Ve}`:""},Z=b.useMemo(()=>{const Re=[g,...Array.isArray(y)?y:[]].map(q).filter(Boolean);return Array.from(new Set(Re)).join("|")},[g,y]);b.useEffect(()=>{const Re=()=>{const Ee=!document.hidden;w.current=Ee,J(Ee)},Ve=!document.hidden;return w.current=Ve,J(Ve),document.addEventListener("visibilitychange",Re),()=>document.removeEventListener("visibilitychange",Re)},[]),b.useEffect(()=>()=>{R.current&&window.clearTimeout(R.current)},[]),b.useEffect(()=>{const Re=S.current;if(!Re)return;const Ve=new IntersectionObserver(Ee=>{const _e=Ee[0],yt=!!(_e&&(_e.isIntersecting||_e.intersectionRatio>0));yt!==I.current&&(I.current=yt,O(yt))},{root:null,threshold:0,rootMargin:"300px 0px"});return Ve.observe(Re),()=>Ve.disconnect()},[]),b.useEffect(()=>{typeof e!="number"&&L&&w.current&&(X.current||(X.current=!0,P(Re=>Re+1)))},[L,e]),b.useEffect(()=>{if(typeof e=="number"||!L||!w.current)return;const Re=Number(u??t??1e4);if(!Number.isFinite(Re)||Re<=0)return;const Ve=r?W(r):NaN,Ee=a?W(a):NaN;if(Number.isFinite(Ve)){let yt;const ut=()=>{if(!w.current)return;const pt=Date.now();if(Number.isFinite(Ee)&&pt>=Ee)return;const _t=Math.max(0,pt-Ve)%Re,Qe=_t===0?Re:Re-_t;yt=window.setTimeout(()=>{I.current&&w.current&&(P(Xe=>Xe+1),ut())},Qe)};return ut(),()=>{yt&&window.clearTimeout(yt)}}const _e=window.setInterval(()=>{I.current&&w.current&&P(yt=>yt+1)},Re);return()=>window.clearInterval(_e)},[e,t,L,re,r,a,u]);const te=typeof e=="number"?e:j,oe=b.useRef(0),[F,le]=b.useState(0);b.useEffect(()=>{L&&w.current&&(oe.current=te,le(te))},[te,L]),b.useEffect(()=>{N(!1),k(!1)},[F]),b.useEffect(()=>{z.current=!1,Y.current=0,X.current=!1,N(!1),k(!1),I.current&&w.current&&P(Re=>Re+1)},[s,Z]);const ge=b.useMemo(()=>`/api/preview?id=${encodeURIComponent(s)}&v=${F}`,[s,F]),Ie=b.useMemo(()=>`/api/preview?id=${encodeURIComponent(s)}&hover=1&file=index_hq.m3u8`,[s]),Pe=b.useMemo(()=>Z?Z.split("|"):[],[Z])[0]||"",Je=!!Pe&&!G,Se=b.useMemo(()=>{if(Je){const Re=Pe.includes("?")?"&":"?";return`${Pe}${Re}v=${encodeURIComponent(String(F))}`}return ge},[Je,Pe,F,ge]);return m.jsx(ck,{content:(Re,{close:Ve})=>Re&&m.jsx("div",{className:"w-[420px] max-w-[calc(100vw-1.5rem)]",children:m.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{paddingBottom:`calc(56.25% + ${T}px)`},children:m.jsxs("div",{className:"absolute inset-0",children:[m.jsx(IR,{src:Ie,muted:!1,className:"w-full h-full object-contain object-bottom relative z-0"}),m.jsxs("div",{className:"absolute left-2 top-2 inline-flex items-center gap-1.5 rounded-full bg-red-600/90 px-2 py-1 text-[11px] font-semibold text-white shadow-sm",children:[m.jsx("span",{className:"inline-block size-1.5 rounded-full bg-white animate-pulse"}),"Live"]}),m.jsx("button",{type:"button",className:"absolute right-2 top-2 z-20 inline-flex items-center justify-center rounded-md p-1.5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/70 bg-white/75 text-gray-900 ring-1 ring-black/10 hover:bg-white/90 dark:bg-black/40 dark:text-white dark:ring-white/10 dark:hover:bg-black/55","aria-label":"Live-Vorschau schließen",title:"Vorschau schließen",onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),Ve()},children:m.jsx(v0,{className:"h-4 w-4"})})]})})}),children:m.jsx("div",{ref:S,className:["block relative rounded bg-gray-100 dark:bg-white/5 overflow-hidden",n||"w-full h-full"].join(" "),children:K?m.jsx("div",{className:"absolute inset-0 grid place-items-center px-1 text-center text-[10px] text-gray-500 dark:text-gray-400",children:"keine Vorschau"}):m.jsx("img",{src:Se,loading:L?"eager":"lazy",fetchPriority:L?"high":"auto",decoding:"async",alt:"",className:["block w-full h-full object-cover object-center",v].filter(Boolean).join(" "),onLoad:()=>{z.current=!0,Y.current=0,R.current&&window.clearTimeout(R.current),Je?N(!1):k(!1)},onError:()=>{if(Je){N(!0);return}if(k(!0),!c||!I.current||!w.current||z.current)return;const Re=r?W(r):NaN,Ve=Number(f??6e4);if(!(!Number.isFinite(Re)||Date.now()-Re<Ve))return;const _e=Number(d??25);Y.current>=_e||(R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{Y.current+=1,k(!1),P(yt=>yt+1)},c))}})})})}function qh({label:s,value:e=0,indeterminate:t=!1,showPercent:i=!1,rightLabel:n,steps:r,currentStep:a,size:u="md",className:c}){const d=Math.max(0,Math.min(100,Number(e)||0)),f=u==="sm"?"h-1.5":"h-2",g=Array.isArray(r)&&r.length>0,y=g?r.length:0,v=w=>w===0?"text-left":w===y-1?"text-right":"text-center",T=w=>typeof a!="number"||!Number.isFinite(a)?!1:w<=a,S=i&&!t;return m.jsxs("div",{className:c,children:[s||S?m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s?m.jsx("p",{className:"flex-1 min-w-0 truncate text-xs font-medium text-gray-900 dark:text-white",children:s}):m.jsx("span",{className:"flex-1"}),S?m.jsxs("span",{className:"shrink-0 text-xs font-medium text-gray-700 dark:text-gray-300",children:[Math.round(d),"%"]}):null]}):null,m.jsxs("div",{"aria-hidden":"true",className:s||S?"mt-2":"",children:[m.jsx("div",{className:"overflow-hidden rounded-full bg-gray-200 dark:bg-white/10",children:t?m.jsx("div",{className:`${f} w-full rounded-full bg-indigo-600/70 dark:bg-indigo-500/70 animate-pulse`}):m.jsx("div",{className:`${f} rounded-full bg-indigo-600 dark:bg-indigo-500 transition-[width] duration-200`,style:{width:`${d}%`}})}),n?m.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:n}):null,g?m.jsx("div",{className:"mt-3 hidden text-sm font-medium text-gray-600 sm:grid dark:text-gray-400",style:{gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`},children:r.map((w,L)=>m.jsx("div",{className:[v(L),T(L)?"text-indigo-600 dark:text-indigo-400":""].join(" "),children:w},`${L}-${w}`))}):null]})]})}function oH(s){const[e,t]=b.useState(s),i=b.useRef(s.length);return b.useEffect(()=>{const n=up("/api/record/stream","jobs",r=>{Array.isArray(r)&&(r.length,i.current,i.current=r.length,t(r))});return()=>n()},[]),e}function lH(s,e=!1){const[t,i]=b.useState(e);return b.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(s),r=()=>{i(n.matches)};return r(),typeof n.addEventListener=="function"?(n.addEventListener("change",r),()=>n.removeEventListener("change",r)):(n.addListener(r),()=>n.removeListener(r))},[s]),t}const Z0=s=>{const e=s;return e.modelName??e.model??e.modelKey??e.username??e.name??"—"},OR=s=>{const e=s;return e.sourceUrl??e.url??e.roomUrl??""},MR=s=>{const e=s;return String(e.imageUrl??e.image_url??"").trim()},cc=s=>{const e=s;return String(e.key??e.id??Z0(s))},Xs=s=>{if(typeof s=="number"&&Number.isFinite(s))return s<1e12?s*1e3:s;if(typeof s=="string"){const e=Date.parse(s);return Number.isFinite(e)?e:0}return s instanceof Date?s.getTime():0},uH=s=>{const e=String(s??"").trim();return e?/^https?:\/\//i.test(e)||e.startsWith("/")?e:`/${e}`:""},PR=s=>{const e=s,t=[e.thumbsWebpUrl,e.thumbsUrl,e.previewThumbsUrl,e.thumbnailSheetUrl],i=[e.previewBaseUrl?`${String(e.previewBaseUrl).replace(/\/+$/,"")}/thumbs.webp`:"",e.assetBaseUrl?`${String(e.assetBaseUrl).replace(/\/+$/,"")}/thumbs.webp`:"",e.thumbsBaseUrl?`${String(e.thumbsBaseUrl).replace(/\/+$/,"")}/thumbs.webp`:""];return[...t,...i].map(n=>uH(String(n??""))).filter(Boolean)},dc=s=>{if(s.kind==="job"){const t=s.job;return Xs(t.addedAt)||Xs(t.createdAt)||Xs(t.enqueuedAt)||Xs(t.queuedAt)||Xs(t.requestedAt)||Xs(t.startedAt)||0}const e=s.pending;return Xs(e.addedAt)||Xs(e.createdAt)||Xs(e.enqueuedAt)||Xs(e.queuedAt)||Xs(e.requestedAt)||0},BR=s=>{switch((s??"").toLowerCase()){case"stopping":return"Stop wird angefordert…";case"probe":return"Analysiere Datei (Dauer/Streams)…";case"remuxing":return"Konvertiere Container zu MP4…";case"moving":return"Verschiebe nach Done…";case"assets":return"Erstelle Vorschau/Thumbnails…";case"postwork":return"Nacharbeiten laufen…";default:return""}};async function cH(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}function FR(s,e){const t=s.postWork;if(!t)return"Warte auf Nacharbeiten…";if(t.state==="running"){const i=typeof t.running=="number"?t.running:0,n=typeof t.maxParallel=="number"?t.maxParallel:0;return n>0?`Nacharbeiten laufen… (${i}/${n} parallel)`:"Nacharbeiten laufen…"}if(t.state==="queued"){const i=typeof t.position=="number"?t.position:0,n=typeof t.waiting=="number"?t.waiting:0,r=typeof t.running=="number"?t.running:0,a=Math.max(n+r,i),u=typeof e?.pos=="number"&&Number.isFinite(e.pos)&&e.pos>0?e.pos:i,c=typeof e?.total=="number"&&Number.isFinite(e.total)&&e.total>0?e.total:a;return u>0&&c>0?`Warte auf Nacharbeiten… ${u} / ${c}`:"Warte auf Nacharbeiten…"}return"Warte auf Nacharbeiten…"}function dH({job:s,postworkInfo:e}){const t=String(s?.phase??"").trim(),i=Number(s?.progress??0),n=t.toLowerCase(),r=n==="recording";let a=t?BR(t)||t:"";n==="postwork"&&(a=FR(s,e)),r&&(a="Recording läuft…");const u=a||String(s?.status??"").trim().toLowerCase(),c=!r&&Number.isFinite(i)&&i>0&&i<100,d=!r&&!c&&!!t&&(!Number.isFinite(i)||i<=0||i>=100);return m.jsx("div",{className:"min-w-0",children:c?m.jsx(qh,{label:u,value:Math.max(0,Math.min(100,i)),showPercent:!0,size:"sm",className:"w-full min-w-0 sm:min-w-[220px]"}):d?m.jsx(qh,{label:u,indeterminate:!0,size:"sm",className:"w-full min-w-0 sm:min-w-[220px]"}):m.jsx("div",{className:"truncate",children:m.jsx("span",{className:"font-medium",children:u})})})}function Yv({r:s,nowMs:e,blurPreviews:t,modelsByKey:i,stopRequestedIds:n,postworkInfoOf:r,markStopRequested:a,onOpenPlayer:u,onStopJob:c,onToggleFavorite:d,onToggleLike:f,onToggleWatch:g}){if(s.kind==="pending"){const q=s.pending,Z=Z0(q),te=OR(q),oe=(q.currentShow||"unknown").toLowerCase();return m.jsxs("div",{className:`
relative overflow-hidden rounded-2xl border border-white/40 bg-white/35 shadow-sm
backdrop-blur-xl supports-[backdrop-filter]:bg-white/25
ring-1 ring-black/5
transition-all hover:-translate-y-0.5 hover:shadow-md active:translate-y-0
dark:border-white/10 dark:bg-gray-950/35 dark:supports-[backdrop-filter]:bg-gray-950/25
`,children:[m.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-br from-white/70 via-white/20 to-white/60 dark:from-white/10 dark:via-transparent dark:to-white/5"}),m.jsxs("div",{className:"relative p-3",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",title:Z,children:Z}),m.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-gray-600 dark:text-gray-300",children:[m.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-900/5 px-2 py-0.5 font-medium dark:bg-white/10",children:"Wartend"}),m.jsx("span",{className:"inline-flex items-center rounded-full bg-gray-900/5 px-2 py-0.5 text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:bg-white/10 dark:text-gray-200",children:oe})]})]}),m.jsx("span",{className:"shrink-0 rounded-full bg-gray-900/5 px-2.5 py-1 text-xs font-medium text-gray-800 dark:bg-white/10 dark:text-gray-200",children:"⏳"})]}),m.jsx("div",{className:"mt-3",children:(()=>{const F=MR(q);return m.jsx("div",{className:"relative aspect-[16/9] w-full overflow-hidden rounded-xl bg-gray-100 ring-1 ring-black/5 dark:bg-white/10 dark:ring-white/10",children:F?m.jsx("img",{src:F,alt:Z,className:["h-full w-full object-cover",t?"blur-md":""].join(" "),loading:"lazy",referrerPolicy:"no-referrer",onError:le=>{le.currentTarget.style.display="none"}}):m.jsx("div",{className:"grid h-full w-full place-items-center",children:m.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-300",children:"Waiting…"})})})})()}),te?m.jsx("a",{href:te,target:"_blank",rel:"noreferrer",className:"mt-3 block truncate text-xs text-indigo-600 hover:underline dark:text-indigo-400",onClick:F=>F.stopPropagation(),title:te,children:te}):null]})]})}const y=s.job,v=ob(y.output),T=k1(y.output||""),S=String(y.phase??"").trim(),w=S.toLowerCase(),L=w==="recording",O=!!n[y.id],I=String(y.status??"").toLowerCase(),P=w!==""&&w!=="recording"||I!=="running"||O;let G=S?BR(S)||S:"";w==="recording"?G="Recording läuft…":w==="postwork"&&(G=FR(y,r(y)));const N=I||"unknown",K=G||N,k=Number(y.progress??0),R=!L&&Number.isFinite(k)&&k>0&&k<100,Y=!L&&!R&&!!S&&(!Number.isFinite(k)||k<=0||k>=100),z=v&&v!=="—"?v.toLowerCase():"",X=z?i[z]:void 0,re=!!X?.favorite,J=X?.liked===!0,W=!!X?.watching;return m.jsxs("div",{className:`
group relative overflow-hidden rounded-2xl border border-white/40 bg-white/35 shadow-sm
backdrop-blur-xl supports-[backdrop-filter]:bg-white/25
ring-1 ring-black/5
transition-all hover:-translate-y-0.5 hover:shadow-md active:translate-y-0
dark:border-white/10 dark:bg-gray-950/35 dark:supports-[backdrop-filter]:bg-gray-950/25
`,onClick:()=>u(y),role:"button",tabIndex:0,onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&u(y)},children:[m.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-br from-white/70 via-white/20 to-white/60 dark:from-white/10 dark:via-transparent dark:to-white/5"}),m.jsx("div",{className:"pointer-events-none absolute -inset-10 opacity-0 blur-2xl transition-opacity duration-300 group-hover:opacity-100 bg-white/40 dark:bg-white/10"}),m.jsxs("div",{className:"relative p-3",children:[m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx("div",{className:`
relative
shrink-0 overflow-hidden rounded-lg
w-[112px] h-[64px]
bg-gray-100 ring-1 ring-black/5
dark:bg-white/10 dark:ring-white/10
`,children:m.jsx(NR,{jobId:y.id,blur:t,alignStartAt:y.startedAt,alignEndAt:y.endedAt??null,alignEveryMs:1e4,fastRetryMs:1e3,fastRetryMax:25,fastRetryWindowMs:6e4,thumbsCandidates:PR(y),className:"w-full h-full"})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("div",{className:"truncate text-base font-semibold text-gray-900 dark:text-white",title:v,children:v}),m.jsx("span",{className:["shrink-0 inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold","bg-gray-900/5 text-gray-800 dark:bg-white/10 dark:text-gray-200",P?"ring-1 ring-amber-500/30":"ring-1 ring-emerald-500/25"].join(" "),title:N,children:N})]}),m.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-600 dark:text-gray-300",title:y.output,children:T||"—"})]}),m.jsxs("div",{className:"shrink-0 flex flex-col items-end gap-1",children:[m.jsx("span",{className:"rounded-full bg-gray-900/5 px-2 py-0.5 text-[11px] font-medium text-gray-900 dark:bg-white/10 dark:text-gray-200",children:UR(y,e)}),m.jsx("span",{className:"rounded-full bg-gray-900/5 px-2 py-0.5 text-[11px] font-medium text-gray-900 dark:bg-white/10 dark:text-gray-200",children:$R(jR(y))})]})]}),y.sourceUrl?m.jsx("a",{href:y.sourceUrl,target:"_blank",rel:"noreferrer",className:"mt-1 block truncate text-xs text-indigo-600 hover:underline dark:text-indigo-400",onClick:q=>q.stopPropagation(),title:y.sourceUrl,children:y.sourceUrl}):null]})]}),R||Y?m.jsx("div",{className:"mt-3",children:R?m.jsx(qh,{label:K,value:Math.max(0,Math.min(100,k)),showPercent:!0,size:"sm",className:"w-full"}):m.jsx(qh,{label:K,indeterminate:!0,size:"sm",className:"w-full"})}):null,m.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/30 pt-3 dark:border-white/10",children:[m.jsx("div",{className:"flex items-center gap-1",onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:m.jsx(ga,{job:y,variant:"table",busy:P,isFavorite:re,isLiked:J,isWatching:W,onToggleFavorite:d,onToggleLike:f,onToggleWatch:g,order:["watch","favorite","like","details"],className:"flex items-center gap-1"})}),m.jsx(ri,{size:"sm",variant:"primary",disabled:P,className:"shrink-0",onClick:q=>{q.stopPropagation(),!P&&(a(y.id),c(y.id))},children:P?"Stoppe…":"Stop"})]})]})]})}const k1=s=>(s||"").replaceAll("\\","/").trim().split("/").pop()||"",ob=s=>{const e=k1(s||"");if(!e)return"—";const t=e.replace(/\.[^.]+$/,""),i=t.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(i?.[1])return i[1];const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t},hH=s=>{if(!Number.isFinite(s)||s<=0)return"—";const e=Math.floor(s/1e3),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`},UR=(s,e)=>{const t=s,i=Xs(t.startedAtMs)||Xs(s.startedAt);if(!Number.isFinite(i)||i<=0)return"—";const n=s.endedAt?Xs(t.endedAtMs)||Xs(s.endedAt):e;return!Number.isFinite(n)||n<=0?"—":hH(n-i)},jR=s=>{const e=s,t=e.sizeBytes??e.fileSizeBytes??e.bytes??e.size??null;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:null},$R=s=>{if(!s||!Number.isFinite(s)||s<=0)return"—";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0?0:t>=10?1:2;return`${t.toFixed(n).replace(/\.0+$/,"")} ${e[i]}`},Xv=s=>{const e=s,t=String(e.phase??"").trim(),i=e.postWork;return!!(String(e.postWorkKey??"").trim()||i&&(i.state==="queued"||i.state==="running")||s.endedAt&&t||t==="postwork")},mA=s=>{const e=String(s??"").trim().toLowerCase();return e==="stopped"||e==="finished"||e==="failed"||e==="done"||e==="completed"||e==="canceled"||e==="cancelled"};function pA(){return m.jsx("span",{className:`
inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold
bg-red-100 text-red-800 ring-1 ring-red-200
dark:bg-red-500/15 dark:text-red-200 dark:ring-red-400/25
`,title:"Speicherplatz-Notbremse aktiv: Autostart gesperrt und Downloads wurden gestoppt",children:"Speicherplatz-Notbremse aktiv"})}function fH({jobs:s,pending:e=[],onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:a,onAddToDownloads:u,modelsByKey:c={},blurPreviews:d}){const f=oH(s),g=lH("(min-width: 640px)",!0),[y,v]=b.useState(!1),[T,S]=b.useState(!1),[,w]=b.useState(!1),[L,O]=b.useState(!1),I=b.useRef(null),j=b.useRef(null),P=b.useRef(null),[G,N]=b.useState(!1),K=b.useCallback(async()=>{try{const Se=await cH("/api/autostart/state",{cache:"no-store"}),Re=!!Se?.paused,Ve=!!Se?.pausedByUser,Ee=!!Se?.pausedByDisk;I.current=Re,j.current=Ve,P.current=Ee,S(Re),w(Ve),O(Ee)}catch{}},[]);b.useEffect(()=>{K();const Se=up("/api/autostart/state/stream","autostart",Re=>{const Ve=!!Re?.paused,Ee=!!Re?.pausedByUser,_e=!!Re?.pausedByDisk;I.current===Ve&&j.current===Ee&&P.current===_e||(I.current=Ve,j.current=Ee,P.current=_e,S(Ve),w(Ee),O(_e))});return()=>{Se()}},[K]);const k=b.useCallback(async()=>{if(!(G||T)){N(!0);try{const Se=await fetch("/api/autostart/pause",{method:"POST"});if(!Se.ok)throw new Error(`HTTP ${Se.status}`);await K()}catch{}finally{N(!1)}}},[G,T,K]),R=b.useCallback(async()=>{if(!(G||!T||L)){N(!0);try{const Se=await fetch("/api/autostart/resume",{method:"POST"});if(!Se.ok)throw new Error(`HTTP ${Se.status}`);await K()}catch{}finally{N(!1)}}},[G,T,L,K]),[Y,z]=b.useState({}),[X,re]=b.useState({}),J=b.useCallback(Se=>{const Re=Array.isArray(Se)?Se:[Se];z(Ve=>{const Ee={...Ve};for(const _e of Re)_e&&(Ee[_e]=!0);return Ee}),re(Ve=>{const Ee={...Ve};for(const _e of Re)_e&&(Ee[_e]=!0);return Ee})},[]);b.useEffect(()=>{z(Se=>{const Re=Object.keys(Se);if(Re.length===0)return Se;const Ve={};for(const Ee of Re){const _e=f.find(Fe=>Fe.id===Ee);if(!_e)continue;const yt=String(_e.phase??"").trim().toLowerCase();yt!==""&&yt!=="recording"||_e.status!=="running"||(Ve[Ee]=!0)}return Ve})},[f]);const[W,q]=b.useState(()=>Date.now()),Z=b.useMemo(()=>f.some(Se=>!Se.endedAt&&Se.status==="running"),[f]),te=b.useMemo(()=>{const Se=new Map,Re=ut=>{const pt=ut,Fe=pt.postWork;return Xs(Fe?.enqueuedAt)||Xs(pt.enqueuedAt)||Xs(pt.queuedAt)||Xs(pt.createdAt)||Xs(pt.addedAt)||Xs(ut.endedAt)||Xs(ut.startedAt)||0},Ve=[],Ee=[];for(const ut of f){const pt=ut?.postWork;if(!pt)continue;const Fe=String(pt.state??"").toLowerCase();Fe==="running"?Ve.push(ut):Fe==="queued"&&Ee.push(ut)}Ve.sort((ut,pt)=>Re(ut)-Re(pt)),Ee.sort((ut,pt)=>Re(ut)-Re(pt));const _e=Ve.length,yt=_e+Ee.length;for(let ut=0;ut<Ee.length;ut++){const pt=String(Ee[ut]?.id??"");pt&&Se.set(pt,{pos:_e+ut+1,total:yt})}return Se},[f]),oe=b.useCallback(Se=>{const Re=String(Se?.id??"");return Re?te.get(Re):void 0},[te]);b.useEffect(()=>{if(!Z)return;const Se=window.setInterval(()=>q(Date.now()),1e3);return()=>window.clearInterval(Se)},[Z]);const F=b.useMemo(()=>f.filter(Se=>{if(Xv(Se)||Se.endedAt)return!1;const Re=String(Se.phase??"").trim(),Ve=!!Y[Se.id],Ee=Re.trim().toLowerCase();return!(Ee!==""&&Ee!=="recording"||Se.status!=="running"||Ve)}).map(Se=>Se.id),[f,Y]),le=b.useMemo(()=>[{key:"preview",header:"Vorschau",widthClassName:"w-[96px]",cell:Se=>{if(Se.kind==="job"){const _e=Se.job;return m.jsx("div",{className:"grid w-[96px] h-[60px] overflow-hidden rounded-md",children:m.jsx(NR,{jobId:_e.id,blur:d,alignStartAt:_e.startedAt,alignEndAt:_e.endedAt??null,alignEveryMs:1e4,fastRetryMs:1e3,fastRetryMax:25,fastRetryWindowMs:6e4,thumbsCandidates:PR(_e),className:"w-full h-full"})})}const Re=Se.pending,Ve=Z0(Re),Ee=MR(Re);return Ee?m.jsx("div",{className:"grid w-[96px] h-[60px] overflow-hidden rounded-md bg-gray-100 ring-1 ring-black/5 dark:bg-white/10 dark:ring-white/10",children:m.jsx("img",{src:Ee,alt:Ve,className:["h-full w-full object-cover",d?"blur-md":""].join(" "),loading:"lazy",referrerPolicy:"no-referrer",onError:_e=>{_e.currentTarget.style.display="none"}})}):m.jsx("div",{className:"h-[60px] w-[96px] rounded-md bg-gray-100 dark:bg-white/10 grid place-items-center text-sm text-gray-500",children:"⏳"})}},{key:"model",header:"Modelname",widthClassName:"w-[170px]",cell:Se=>{if(Se.kind==="job"){const _e=Se.job,yt=k1(_e.output||""),ut=ob(_e.output),pt=String(_e.status??"").toLowerCase(),Fe=!!Y[_e.id],_t=!!X[_e.id],Qe=pt==="stopped"||_t&&!!_e.endedAt,Xe=Qe?"stopped":pt||"unknown",ze=!Qe&&Fe,Ze=ze?"stopping":Xe;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:"min-w-0 block max-w-[170px] truncate font-medium",title:ut,children:ut}),m.jsx("span",{className:["shrink-0 inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold ring-1",pt==="running"?"bg-emerald-500/15 text-emerald-900 ring-emerald-500/30 dark:bg-emerald-400/10 dark:text-emerald-200 dark:ring-emerald-400/25":Qe?"bg-slate-500/15 text-slate-900 ring-slate-500/30 dark:bg-slate-400/10 dark:text-slate-200 dark:ring-slate-400/25":pt==="failed"?"bg-red-500/15 text-red-900 ring-red-500/30 dark:bg-red-400/10 dark:text-red-200 dark:ring-red-400/25":pt==="finished"?"bg-emerald-500/15 text-emerald-900 ring-emerald-500/30 dark:bg-emerald-400/10 dark:text-emerald-200 dark:ring-emerald-400/25":ze?"bg-amber-500/15 text-amber-900 ring-amber-500/30 dark:bg-amber-400/10 dark:text-amber-200 dark:ring-amber-400/25":"bg-gray-900/5 text-gray-800 ring-gray-900/10 dark:bg-white/10 dark:text-gray-200 dark:ring-white/10"].join(" "),title:Ze,children:Ze})]}),m.jsx("span",{className:"block max-w-[220px] truncate",title:_e.output,children:yt}),_e.sourceUrl?m.jsx("a",{href:_e.sourceUrl,target:"_blank",rel:"noreferrer",title:_e.sourceUrl,className:"block max-w-[260px] truncate text-indigo-600 dark:text-indigo-400 hover:underline",onClick:ct=>ct.stopPropagation(),children:_e.sourceUrl}):m.jsx("span",{className:"block max-w-[260px] truncate text-gray-500 dark:text-gray-400",children:"—"})]})}const Re=Se.pending,Ve=Z0(Re),Ee=OR(Re);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"block max-w-[170px] truncate font-medium",title:Ve,children:Ve}),Ee?m.jsx("a",{href:Ee,target:"_blank",rel:"noreferrer",title:Ee,className:"block max-w-[260px] truncate text-indigo-600 dark:text-indigo-400 hover:underline",onClick:_e=>_e.stopPropagation(),children:Ee}):m.jsx("span",{className:"block max-w-[260px] truncate text-gray-500 dark:text-gray-400",children:"—"})]})}},{key:"status",header:"Status",widthClassName:"w-[260px] min-w-[240px]",cell:Se=>{if(Se.kind==="job"){const Ee=Se.job;return m.jsx(dH,{job:Ee,postworkInfo:oe(Ee)})}const Ve=(Se.pending.currentShow||"unknown").toLowerCase();return m.jsx("div",{className:"min-w-0",children:m.jsx("div",{className:"truncate",children:m.jsx("span",{className:"font-medium",children:Ve})})})}},{key:"runtime",header:"Dauer",widthClassName:"w-[90px]",cell:Se=>Se.kind==="job"?UR(Se.job,W):"—"},{key:"size",header:"Größe",align:"right",widthClassName:"w-[110px]",cell:Se=>Se.kind==="job"?m.jsx("span",{className:"tabular-nums text-sm text-gray-900 dark:text-white",children:$R(jR(Se.job))}):m.jsx("span",{className:"tabular-nums text-sm text-gray-500 dark:text-gray-400",children:"—"})},{key:"actions",header:"Aktion",srOnlyHeader:!0,align:"right",widthClassName:"w-[320px] min-w-[300px]",cell:Se=>{if(Se.kind!=="job")return m.jsx("div",{className:"pr-2 text-right text-sm text-gray-500 dark:text-gray-400",children:"—"});const Re=Se.job,Ve=String(Re.phase??"").trim(),Ee=!!Y[Re.id],_e=Ve.trim().toLowerCase(),ut=_e!==""&&_e!=="recording"||Re.status!=="running"||Ee,pt=ob(Re.output||""),Fe=pt&&pt!=="—"?c[pt.toLowerCase()]:void 0,_t=!!Fe?.favorite,Qe=Fe?.liked===!0,Xe=!!Fe?.watching;return m.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 pr-2",children:[m.jsx(ga,{job:Re,variant:"table",busy:ut,isFavorite:_t,isLiked:Qe,isWatching:Xe,onToggleFavorite:n,onToggleLike:r,onToggleWatch:a,onAddToDownloads:u,order:["watch","favorite","like","details"],className:"flex items-center gap-1"}),(()=>{const ze=String(Re.phase??"").trim(),Ze=!!Y[Re.id],ct=ze.trim().toLowerCase(),se=ct!==""&&ct!=="recording"||Re.status!=="running"||Ze;return m.jsx(ri,{size:"sm",variant:"primary",disabled:se,className:"shrink-0",onClick:ke=>{ke.stopPropagation(),!se&&(J(Re.id),i(Re.id))},children:se?"Stoppe…":"Stop"})})()]})}}],[d,J,c,W,i,n,r,a,Y,X,oe]),ge=b.useMemo(()=>{const Se=f.filter(Re=>!(Xv(Re)||mA(Re?.status)||Re?.endedAt)).map(Re=>({kind:"job",job:Re}));return Se.sort((Re,Ve)=>dc(Ve)-dc(Re)),Se},[f]),Ie=b.useMemo(()=>{const Se=f.filter(Ee=>!(!Xv(Ee)||mA(Ee?.status))).map(Ee=>({kind:"job",job:Ee})),Re=Ee=>{const _e=Ee?.postWork,yt=String(_e?.state??"").toLowerCase();return yt==="running"?0:yt==="queued"?1:2},Ve=Ee=>{const _e=String(Ee?.id??""),yt=_e?te.get(_e):void 0;return typeof yt?.pos=="number"&&Number.isFinite(yt.pos)?yt.pos:Number.MAX_SAFE_INTEGER};return Se.sort((Ee,_e)=>{const yt=Ee.job,ut=_e.job,pt=Re(yt)-Re(ut);if(pt!==0)return pt;const Fe=Ve(yt),_t=Ve(ut);return Fe!==_t?Fe-_t:dc(Ee)-dc(_e)}),Se},[f,te]),Le=b.useMemo(()=>{const Se=e.map(Re=>({kind:"pending",pending:Re}));return Se.sort((Re,Ve)=>dc(Ve)-dc(Re)),Se},[e]),Pe=ge.length+Ie.length+Le.length,Je=b.useCallback(async()=>{if(!y&&F.length!==0){v(!0);try{J(F),await Promise.allSettled(F.map(Se=>Promise.resolve(i(Se))))}finally{v(!1)}}},[y,F,J,i]);return m.jsxs("div",{className:"grid gap-3",children:[m.jsx("div",{className:"sticky top-[56px] z-20",children:m.jsx("div",{className:`
rounded-xl border border-gray-200/70 bg-white/80 shadow-sm
backdrop-blur supports-[backdrop-filter]:bg-white/60
dark:border-white/10 dark:bg-gray-950/60 dark:supports-[backdrop-filter]:bg-gray-950/40
`,children:m.jsxs("div",{className:"flex items-center justify-between gap-2 p-3",children:[m.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Downloads"}),m.jsx("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-gray-200",children:Pe})]}),m.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[m.jsx(ri,{size:"sm",variant:T?"secondary":"primary",disabled:G||L,onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),!L&&(T?R():k())},className:"hidden sm:inline-flex",title:L?"Autostart durch Speicherplatz-Notbremse gesperrt":T?"Autostart fortsetzen":"Autostart pausieren",leadingIcon:T?m.jsx(VM,{className:"size-4 shrink-0"}):m.jsx(qM,{className:"size-4 shrink-0"}),children:"Autostart"}),m.jsx(ri,{size:"sm",variant:"primary",disabled:y||F.length===0,onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),Je()},className:"hidden sm:inline-flex",title:F.length===0?"Nichts zu stoppen":"Alle laufenden stoppen",children:y?"Stoppe alle…":`Alle stoppen (${F.length})`})]})]})})}),ge.length>0||Ie.length>0||Le.length>0?m.jsx(m.Fragment,{children:g?m.jsxs("div",{className:"mt-3 space-y-4",children:[ge.length>0?m.jsxs("div",{className:"overflow-x-auto",children:[m.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white",children:[m.jsxs("span",{children:["Downloads (",ge.length,")"]}),L?m.jsx(pA,{}):null]}),m.jsx(Sh,{rows:ge,columns:le,getRowKey:Se=>Se.kind==="job"?`dl:job:${Se.job.id}`:`dl:pending:${cc(Se.pending)}`,striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0,onRowClick:Se=>{Se.kind==="job"&&t(Se.job)}})]}):null,Ie.length>0?m.jsxs("div",{className:"overflow-x-auto",children:[m.jsxs("div",{className:"mb-2 text-sm font-semibold text-gray-900 dark:text-white",children:["Nacharbeiten (",Ie.length,")"]}),m.jsx(Sh,{rows:Ie,columns:le,getRowKey:Se=>Se.kind==="job"?`pw:job:${Se.job.id}`:`pw:pending:${cc(Se.pending)}`,striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0,onRowClick:Se=>{Se.kind==="job"&&t(Se.job)}})]}):null,Le.length>0?m.jsxs("div",{className:"overflow-x-auto",children:[m.jsxs("div",{className:"mb-2 text-sm font-semibold text-gray-900 dark:text-white",children:["Wartend (",Le.length,")"]}),m.jsx(Sh,{rows:Le,columns:le,getRowKey:Se=>Se.kind==="job"?`wa:job:${Se.job.id}`:`wa:pending:${cc(Se.pending)}`,striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0})]}):null]}):m.jsxs("div",{className:"mt-3 grid gap-4",children:[ge.length>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-gray-700 dark:text-gray-200",children:[m.jsxs("span",{children:["Downloads (",ge.length,")"]}),L?m.jsx(pA,{}):null]}),ge.map(Se=>m.jsx(Yv,{r:Se,nowMs:W,blurPreviews:d,modelsByKey:c,postworkInfoOf:oe,stopRequestedIds:Y,markStopRequested:J,onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:a},`dl:${Se.kind==="job"?Se.job.id:cc(Se.pending)}`))]}):null,Ie.length>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"mt-2 text-xs font-semibold text-gray-700 dark:text-gray-200",children:["Nacharbeiten (",Ie.length,")"]}),Ie.map(Se=>m.jsx(Yv,{r:Se,nowMs:W,blurPreviews:d,modelsByKey:c,postworkInfoOf:oe,stopRequestedIds:Y,markStopRequested:J,onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:a},`pw:${Se.kind==="job"?Se.job.id:cc(Se.pending)}`))]}):null,Le.length>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"mt-2 text-xs font-semibold text-gray-700 dark:text-gray-200",children:["Wartend (",Le.length,")"]}),Le.map(Se=>m.jsx(Yv,{r:Se,nowMs:W,blurPreviews:d,modelsByKey:c,postworkInfoOf:oe,stopRequestedIds:Y,markStopRequested:J,onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:a},`wa:${Se.kind==="job"?Se.job.id:cc(Se.pending)}`))]}):null]})}):m.jsx(pa,{grayBody:!0,children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-white/70 ring-1 ring-gray-200 dark:bg-white/5 dark:ring-white/10",children:m.jsx("span",{className:"text-lg",children:"⏸️"})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Keine laufenden Downloads"}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Starte oben eine URL hier siehst du Live-Status und kannst Jobs stoppen."})]})]})})]})}function jn(...s){return s.filter(Boolean).join(" ")}function lb({open:s,onClose:e,title:t,children:i,footer:n,icon:r,width:a="max-w-lg",layout:u="single",left:c,leftWidthClass:d="lg:w-80",scroll:f,bodyClassName:g,leftClassName:y,rightClassName:v,rightHeader:T,rightBodyClassName:S,mobileCollapsedImageSrc:w,mobileCollapsedImageAlt:L}){const O=f??(u==="split"?"right":"body"),I=b.useRef(null),[j,P]=b.useState(!1);return b.useEffect(()=>{if(!s)return;const G=document.documentElement,N=document.body,K=G.style.overflow,k=N.style.overflow,R=N.style.paddingRight,Y=window.innerWidth-G.clientWidth;return G.style.overflow="hidden",N.style.overflow="hidden",Y>0&&(N.style.paddingRight=`${Y}px`),()=>{G.style.overflow=K,N.style.overflow=k,N.style.paddingRight=R}},[s]),b.useEffect(()=>{s&&P(!1)},[s]),b.useEffect(()=>{if(!s)return;const G=I.current;if(!G)return;const N=72,K=()=>{const k=G.scrollTop||0;P(R=>{const Y=k>N;return R===Y?R:Y})};return K(),G.addEventListener("scroll",K,{passive:!0}),()=>G.removeEventListener("scroll",K)},[s]),m.jsx(bh,{show:s,as:b.Fragment,children:m.jsxs(vc,{open:s,as:"div",className:"relative z-50",onClose:e,children:[m.jsx(bh.Child,{as:b.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:m.jsx("div",{className:"fixed inset-0 bg-gray-500/75 dark:bg-gray-900/50"})}),m.jsx("div",{className:"fixed inset-0 z-50 overflow-hidden px-4 py-6 sm:px-6",children:m.jsx("div",{className:"min-h-full flex items-start justify-center sm:items-center",children:m.jsx(bh.Child,{as:b.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:m.jsxs(vc.Panel,{className:jn("relative w-full rounded-lg bg-white text-left shadow-xl transition-all","max-h-[calc(100vh-3rem)] sm:max-h-[calc(100vh-4rem)]","flex flex-col min-h-0","dark:bg-gray-800 dark:outline dark:-outline-offset-1 dark:outline-white/10",a),children:[r?m.jsx("div",{className:"mx-auto mb-4 mt-6 flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-500/10",children:r}):null,m.jsxs("div",{className:jn("shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 items-start justify-between gap-3",u==="split"?"hidden lg:flex":"flex"),children:[m.jsx("div",{className:"min-w-0",children:t?m.jsx(vc.Title,{className:"hidden sm:block text-base font-semibold text-gray-900 dark:text-white truncate",children:t}):null}),m.jsx("button",{type:"button",onClick:e,className:jn("inline-flex shrink-0 items-center justify-center rounded-lg p-1.5","text-gray-500 hover:text-gray-900 hover:bg-black/5","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600","dark:text-gray-400 dark:hover:text-white dark:hover:bg-white/10 dark:focus-visible:outline-indigo-500"),"aria-label":"Schließen",title:"Schließen",children:m.jsx(v0,{className:"size-5"})})]}),u==="single"?m.jsx("div",{className:jn("flex-1 min-h-0 h-full",O==="body"?"overflow-y-auto overscroll-contain":"overflow-hidden",v),children:i}):m.jsxs("div",{className:jn("px-2 pb-4 pt-3 sm:px-4 sm:pb-6 sm:pt-4","flex-1 min-h-0","overflow-hidden","flex flex-col",g),children:[m.jsxs("div",{ref:I,className:jn("lg:hidden flex-1 min-h-0 relative",O==="right"||O==="body"?"overflow-y-auto overscroll-contain":"overflow-hidden"),children:[m.jsxs("div",{className:jn("sticky top-0 z-50","bg-white/95 backdrop-blur dark:bg-gray-800/95","border-b border-gray-200/70 dark:border-white/10"),children:[m.jsxs("div",{className:jn("flex items-center justify-between gap-3 px-3",j?"py-2":"py-3"),children:[m.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[w?m.jsx("img",{src:w,alt:L||t||"",className:jn("shrink-0 rounded-lg object-cover ring-1 ring-black/5 dark:ring-white/10",j?"size-8":"size-10"),loading:"lazy",decoding:"async"}):null,m.jsx("div",{className:"min-w-0",children:t?m.jsx("div",{className:jn("truncate font-semibold text-gray-900 dark:text-white",j?"text-sm":"text-base"),children:t}):null})]}),m.jsx("button",{type:"button",onClick:e,className:jn("inline-flex shrink-0 items-center justify-center rounded-lg p-1.5","text-gray-500 hover:text-gray-900 hover:bg-black/5","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600","dark:text-gray-400 dark:hover:text-white dark:hover:bg-white/10 dark:focus-visible:outline-indigo-500"),"aria-label":"Schließen",title:"Schließen",children:m.jsx(v0,{className:"size-5"})})]}),T?m.jsx("div",{children:T}):null]}),c?m.jsx("div",{className:jn("lg:hidden px-2 pb-2",y),children:c}):null,m.jsx("div",{className:jn("px-2 pt-0 min-h-0",v),children:m.jsx("div",{className:jn("min-h-0",S),children:i})})]}),m.jsxs("div",{className:"hidden lg:flex flex-1 min-h-0 gap-3",children:[m.jsx("div",{className:jn("min-h-0",d,"shrink-0","overflow-hidden",y),children:c}),m.jsxs("div",{className:jn("flex-1 min-h-0 flex flex-col",v),children:[T?m.jsx("div",{className:"shrink-0",children:T}):null,m.jsx("div",{className:jn("flex-1 min-h-0",O==="right"?"overflow-y-auto overscroll-contain":"overflow-hidden",S),children:i})]})]})]}),n?m.jsx("div",{className:"shrink-0 px-6 py-4 border-t border-gray-200/70 dark:border-white/10 flex justify-end gap-3",children:n}):null]})})})})]})})}async function Qv(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}const gA=(s,e)=>m.jsx("span",{className:ni("inline-flex items-center rounded-md px-2 py-0.5 text-xs","bg-indigo-50 text-indigo-700 dark:bg-indigo-500/10 dark:text-indigo-200"),children:e});function mH(s){let e=(s??"").trim();if(!e)return null;/^https?:\/\//i.test(e)||(e=`https://${e}`);try{const t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function Wm(s){if(!s)return[];const e=s.split(/[\n,;|]+/g).map(i=>i.trim()).filter(Boolean),t=Array.from(new Set(e));return t.sort((i,n)=>i.localeCompare(n,void 0,{sensitivity:"base"})),t}function pH(s){return String(s??"").trim().toLowerCase().replace(/^www\./,"")}function gH(s){const t=String(s||"").replaceAll("\\","/").split("/");return t[t.length-1]||""}function yH(s){const e=String(s||"");return e.toUpperCase().startsWith("HOT ")?e.slice(4).trim():e}function vH(s){const e=gH(s||""),t=yH(e);if(!t)return"—";const i=t.replace(/\.[^.]+$/,""),n=i.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(n?.[1])return n[1];const r=i.lastIndexOf("_");return r>0?i.slice(0,r):i}function Ym(s){if(s.isUrl&&/^https?:\/\//i.test(String(s.input??"")))return String(s.input);const e=pH(s.host),t=String(s.modelKey??"").trim();return!e||!t?null:e.includes("chaturbate.com")||e.includes("chaturbate")?`https://chaturbate.com/${encodeURIComponent(t)}/`:e.includes("myfreecams.com")||e.includes("myfreecams")?`https://www.myfreecams.com/#${encodeURIComponent(t)}`:null}function yA(s){const e=String(s.profileImageCached??"").trim();if(e)return e;const t=String(s.profileImageUrl??"").trim();return/^https?:\/\//i.test(t)?t:null}function vA({title:s,active:e,hiddenUntilHover:t,onClick:i,icon:n}){return m.jsx("span",{className:ni(t&&!e?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:m.jsx(ri,{variant:e?"soft":"secondary",size:"xs",className:ni("px-2 py-1 leading-none",e?"":"bg-transparent shadow-none hover:bg-gray-50 dark:hover:bg-white/10"),title:s,onClick:i,children:m.jsx("span",{className:"text-base leading-none",children:n})})})}function xA(s){return s==null?{isNull:!0,kind:"string",value:""}:s instanceof Date?{isNull:!1,kind:"number",value:s.getTime()}:typeof s=="number"?{isNull:!1,kind:"number",value:s}:typeof s=="boolean"?{isNull:!1,kind:"number",value:s?1:0}:typeof s=="bigint"?{isNull:!1,kind:"number",value:Number(s)}:{isNull:!1,kind:"string",value:String(s).toLocaleLowerCase()}}function bA(s){return s?s.key==="createdAt"?s.direction==="asc"?"created_asc":"created_desc":s.key==="model"?s.direction==="asc"?"model_asc":"model_desc":s.key==="videos"?s.direction==="asc"?"videos_asc":"videos_desc":s.key==="tags"?s.direction==="asc"?"tags_asc":"tags_desc":"created_desc":"created_desc"}function TA(s){switch(s){case"created_asc":return{key:"createdAt",direction:"asc"};case"created_desc":return{key:"createdAt",direction:"desc"};case"model_asc":return{key:"model",direction:"asc"};case"model_desc":return{key:"model",direction:"desc"};case"videos_asc":return{key:"videos",direction:"asc"};case"videos_desc":return{key:"videos",direction:"desc"};case"tags_asc":return{key:"tags",direction:"asc"};case"tags_desc":return{key:"tags",direction:"desc"};default:return{key:"createdAt",direction:"desc"}}}function SA(){return m.jsxs("svg",{viewBox:"0 0 24 24",className:"size-4",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1.5"}),m.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1.5"}),m.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1.5"}),m.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1.5"})]})}function _A(){return m.jsxs("svg",{viewBox:"0 0 24 24",className:"size-4",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),m.jsx("path",{d:"M3 10h18"}),m.jsx("path",{d:"M9 10v10"}),m.jsx("path",{d:"M15 10v10"})]})}function xH(){const[s,e]=b.useState([]),t=b.useRef({}),[i,n]=b.useState(!1),[r,a]=b.useState(null),[u,c]=b.useState(""),[d,f]=b.useState(1),g=10,[y,v]=b.useState("gallery"),[T,S]=b.useState([]),[w,L]=b.useState({}),[O,I]=b.useState(!1),[j,P]=b.useState({key:"createdAt",direction:"desc"}),G=b.useCallback(async()=>{I(!0);try{const se=await fetch("/api/record/done?all=1&includeKeep=1",{cache:"no-store"});if(!se.ok)return;const ke=await se.json().catch(()=>null),De=Array.isArray(ke?.items)?ke.items:Array.isArray(ke)?ke:[],Ue={};for(const at of De){const dt=vH(at.output);if(!dt||dt==="—")continue;const wt=dt.trim().toLowerCase();wt&&(Ue[wt]=(Ue[wt]??0)+1)}L(Ue)}finally{I(!1)}},[]),N=b.useMemo(()=>new Set(T.map(se=>se.toLowerCase())),[T]),K=b.useCallback(se=>{const ke=se.toLowerCase();S(De=>De.some(at=>at.toLowerCase()===ke)?De.filter(at=>at.toLowerCase()!==ke):[...De,se])},[]),k=b.useCallback(()=>S([]),[]);b.useEffect(()=>{const se=ke=>{const De=ke,Ue=Array.isArray(De.detail?.tags)?De.detail.tags:[];S(Ue)};return window.addEventListener("models:set-tag-filter",se),()=>window.removeEventListener("models:set-tag-filter",se)},[]),b.useEffect(()=>{try{const se=localStorage.getItem("models_pendingTags");if(!se)return;const ke=JSON.parse(se);Array.isArray(ke)&&S(ke),localStorage.removeItem("models_pendingTags")}catch{}},[]),b.useEffect(()=>{try{const se=localStorage.getItem("models_viewMode");(se==="table"||se==="gallery")&&v(se)}catch{}},[]),b.useEffect(()=>{try{localStorage.setItem("models_viewMode",y)}catch{}},[y]);const[R,Y]=b.useState(""),[z,X]=b.useState(null),[re,J]=b.useState(null),[W,q]=b.useState(!1),[Z,te]=b.useState(!1),[oe,F]=b.useState(null),[le,ge]=b.useState(null),[Ie,Le]=b.useState("favorite"),[Pe,Je]=b.useState(!1),[Se,Re]=b.useState(null);async function Ve(){if(oe){Je(!0),ge(null),a(null);try{const se=new FormData;se.append("file",oe),se.append("kind",Ie);const ke=await fetch("/api/models/import",{method:"POST",body:se});if(!ke.ok)throw new Error(await ke.text());const De=await ke.json();ge(`✅ Import: ${De.inserted} neu, ${De.updated} aktualisiert, ${De.skipped} übersprungen`),te(!1),F(null),await yt(),window.dispatchEvent(new Event("models-changed"))}catch(se){Re(se?.message??String(se))}finally{Je(!1)}}}function Ee(se){const ke=Ym(se)??void 0;return{output:`${se.modelKey}_01_01_2000__00-00-00.mp4`,sourceUrl:ke}}const _e=()=>{Re(null),ge(null),F(null),Le("favorite"),te(!0)},yt=b.useCallback(async()=>{n(!0),a(null);try{const se=await Qv("/api/models",{cache:"no-store"});e(Array.isArray(se)?se:[]),G()}catch(se){a(se?.message??String(se))}finally{n(!1)}},[G]);b.useEffect(()=>{G()},[G]),b.useEffect(()=>{yt()},[yt]),b.useEffect(()=>{const se=ke=>{const Ue=ke?.detail??{};if(Ue?.model){const at=Ue.model;e(dt=>{const wt=dt.findIndex(Tt=>Tt.id===at.id);if(wt===-1)return[at,...dt];const kt=dt.slice();return kt[wt]=at,kt});return}if(Ue?.removed&&Ue?.id){const at=String(Ue.id);e(dt=>dt.filter(wt=>wt.id!==at));return}yt()};return window.addEventListener("models-changed",se),()=>window.removeEventListener("models-changed",se)},[yt]),b.useEffect(()=>{const se=R.trim();if(!se){X(null),J(null);return}const ke=mH(se);if(!ke){X(null),J("Bitte nur gültige http(s) URLs einfügen (keine Modelnamen).");return}const De=window.setTimeout(async()=>{try{const Ue=await Qv("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:ke})});if(!Ue?.isUrl){X(null),J("Bitte nur URLs einfügen (keine Modelnamen).");return}X(Ue),J(null)}catch(Ue){X(null),J(Ue?.message??String(Ue))}},300);return()=>window.clearTimeout(De)},[R]);const ut=b.useMemo(()=>s.map(se=>({m:se,hay:`${se.modelKey} ${se.host??""} ${se.input??""} ${se.tags??""}`.toLowerCase()})),[s]),pt=b.useDeferredValue(u);async function Fe(se,ke){if(a(null),t.current[se])return;t.current[se]=!0;const De=s.find(Ue=>Ue.id===se)??null;if(De){const Ue={...De,...ke};typeof ke?.watched=="boolean"&&(Ue.watching=ke.watched),ke?.favorite===!0&&(Ue.liked=!1),ke?.liked===!0&&(Ue.favorite=!1),e(at=>at.map(dt=>dt.id===se?Ue:dt)),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Ue}}))}try{const Ue=await fetch("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:se,...ke})});if(Ue.status===204){e(dt=>dt.filter(wt=>wt.id!==se)),De?window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:De.id,modelKey:De.modelKey}})):window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:se}}));return}if(!Ue.ok){const dt=await Ue.text().catch(()=>"");throw new Error(dt||`HTTP ${Ue.status}`)}const at=await Ue.json();e(dt=>{const wt=dt.findIndex(Tt=>Tt.id===at.id);if(wt===-1)return dt;const kt=dt.slice();return kt[wt]=at,kt}),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:at}}))}catch(Ue){De&&(e(at=>at.map(dt=>dt.id===se?De:dt)),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:De}}))),a(Ue?.message??String(Ue))}finally{delete t.current[se]}}const _t=b.useMemo(()=>[{key:"statusAll",header:"Status",align:"center",cell:se=>{const ke=se.liked===!0,De=se.favorite===!0,Ue=se.watching===!0,at=!Ue&&!De&&!ke;return m.jsxs("div",{className:"group flex items-center justify-center gap-1 w-[110px]",children:[m.jsx("span",{className:ni(at&&!Ue?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:m.jsx(ri,{variant:Ue?"soft":"secondary",size:"xs",className:ni("px-2 py-1 leading-none",!Ue&&"bg-transparent shadow-none hover:bg-gray-50 dark:hover:bg-white/10"),title:Ue?"Nicht mehr beobachten":"Beobachten",onClick:dt=>{dt.stopPropagation(),Fe(se.id,{watched:!Ue})},children:m.jsx("span",{className:ni("text-base leading-none",Ue?"text-indigo-600 dark:text-indigo-400":"text-gray-400 dark:text-gray-500"),children:"👁"})})}),m.jsx(vA,{title:De?"Favorit entfernen":"Als Favorit markieren",active:De,hiddenUntilHover:at,onClick:dt=>{dt.stopPropagation(),De?Fe(se.id,{favorite:!1}):Fe(se.id,{favorite:!0,liked:!1})},icon:m.jsx("span",{className:De?"text-amber-500":"text-gray-400 dark:text-gray-500",children:"★"})}),m.jsx(vA,{title:ke?"Gefällt mir entfernen":"Gefällt mir",active:ke,hiddenUntilHover:at,onClick:dt=>{dt.stopPropagation(),ke?Fe(se.id,{liked:!1}):Fe(se.id,{liked:!0,favorite:!1})},icon:m.jsx("span",{className:ke?"text-rose-500":"text-gray-400 dark:text-gray-500",children:"♥"})})]})}},{key:"model",header:"Model",sortable:!0,sortValue:se=>(se.modelKey||"").toLowerCase(),cell:se=>{const ke=Ym(se),De=yA(se);return m.jsx("div",{className:"min-w-0",children:m.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:De?m.jsx("img",{src:De,alt:se.modelKey,loading:"lazy",className:"w-10 h-10 rounded-full object-cover bg-gray-100 dark:bg-white/10 ring-1 ring-gray-200 dark:ring-white/10",onClick:Ue=>{Ue.stopPropagation(),ke&&window.open(ke,"_blank","noreferrer")},onError:Ue=>{Ue.currentTarget.style.display="none"}}):m.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-100 dark:bg-white/10 ring-1 ring-gray-200 dark:ring-white/10 flex items-center justify-center text-xs text-gray-500 dark:text-gray-400",children:String(se.modelKey||"?").slice(0,1).toUpperCase()})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("div",{className:"font-medium truncate",children:se.modelKey}),ke?m.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",title:ke,onClick:Ue=>{Ue.stopPropagation(),window.open(ke,"_blank","noreferrer")},children:"↗"}):null]}),m.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:se.host??"—"}),ke?m.jsx("div",{className:"text-xs text-indigo-600 dark:text-indigo-400 truncate max-w-[520px]",children:ke}):null]})]})})}},{key:"videos",header:"Videos",sortable:!0,sortValue:se=>{const ke=String(se.modelKey||"").trim().toLowerCase(),De=w[ke];return typeof De=="number"?De:0},align:"right",cell:se=>{const ke=String(se.modelKey||"").trim().toLowerCase(),De=w[ke];return m.jsx("span",{className:"tabular-nums text-sm text-gray-900 dark:text-white w-[64px] inline-block text-right",children:typeof De=="number"?De:O?"…":0})}},{key:"tags",header:"Tags",sortable:!0,sortValue:se=>Wm(se.tags).length,cell:se=>{const ke=Wm(se.tags),De=ke.slice(0,6),Ue=ke.length-De.length,at=ke.join(", ");return m.jsxs("div",{className:"flex flex-wrap gap-2 max-w-[520px]",title:at||void 0,children:[se.hot?gA(!0,"🔥 HOT"):null,se.keep?gA(!0,"📌 Behalten"):null,De.map(dt=>m.jsx(Zr,{tag:dt,title:dt,active:N.has(dt.toLowerCase()),onClick:K},dt)),Ue>0?m.jsxs(Zr,{title:at,children:["+",Ue]}):null,!se.hot&&!se.keep&&ke.length===0?m.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"}):null]})}},{key:"createdAt",header:"Hinzugefügt",sortable:!0,sortValue:se=>{const ke=Date.parse(String(se.createdAt??""));return Number.isFinite(ke)?ke:0},widthClassName:"w-[160px]",cell:se=>{const ke=Date.parse(String(se.createdAt??""));if(!Number.isFinite(ke)||ke<=0)return m.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"});const De=new Date(ke);return m.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300 leading-tight",children:[m.jsx("div",{className:"tabular-nums",children:De.toLocaleDateString("de-DE")}),m.jsx("div",{className:"tabular-nums text-gray-500 dark:text-gray-400",children:De.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})})]})}},{key:"actions",header:"",align:"right",cell:se=>m.jsx("div",{className:"flex justify-end w-[92px]",children:m.jsx(ga,{job:Ee(se),variant:"table",order:["add","details"],className:"flex items-center gap-2"})})}],[N,K,w,O]),Qe=b.useMemo(()=>{const se=pt.trim().toLowerCase(),ke=se?ut.filter(De=>De.hay.includes(se)).map(De=>De.m):s;return N.size===0?ke:ke.filter(De=>{const Ue=Wm(De.tags);if(Ue.length===0)return!1;const at=new Set(Ue.map(dt=>dt.toLowerCase()));for(const dt of N)if(!at.has(dt))return!1;return!0})},[s,ut,pt,N]),Xe=b.useMemo(()=>{if(!j)return Qe;const se=_t.find(Ue=>Ue.key===j.key);if(!se)return Qe;const ke=j.direction==="asc"?1:-1,De=Qe.map((Ue,at)=>({r:Ue,i:at}));return De.sort((Ue,at)=>{let dt=0;if(se.sortFn)dt=se.sortFn(Ue.r,at.r);else{const wt=se.sortValue?se.sortValue(Ue.r):Ue.r?.[se.key],kt=se.sortValue?se.sortValue(at.r):at.r?.[se.key],Tt=xA(wt),Ft=xA(kt);Tt.isNull&&!Ft.isNull?dt=1:!Tt.isNull&&Ft.isNull?dt=-1:Tt.kind==="number"&&Ft.kind==="number"?dt=Tt.value<Ft.value?-1:Tt.value>Ft.value?1:0:dt=String(Tt.value).localeCompare(String(Ft.value),void 0,{numeric:!0})}return dt===0?Ue.i-at.i:dt*ke}),De.map(Ue=>Ue.r)},[Qe,j,_t]);b.useEffect(()=>{f(1)},[u,T,y,j]);const ze=Xe.length,Ze=b.useMemo(()=>Math.max(1,Math.ceil(ze/g)),[ze,g]);b.useEffect(()=>{d>Ze&&f(Ze)},[d,Ze]);const ct=b.useMemo(()=>{const se=(d-1)*g;return Xe.slice(se,se+g)},[Xe,d,g]),St=async()=>{if(z){if(!z.isUrl){J("Bitte nur URLs einfügen (keine Modelnamen).");return}q(!0),a(null);try{const se=await Qv("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});e(ke=>{const De=ke.filter(Ue=>Ue.id!==se.id);return[se,...De]}),Y(""),X(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:se}}))}catch(se){a(se?.message??String(se))}finally{q(!1)}}};return m.jsxs("div",{className:"space-y-4",children:[m.jsx(pa,{header:m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Model hinzufügen"}),grayBody:!0,children:m.jsxs("div",{className:"grid gap-2",children:[m.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[m.jsx("input",{value:R,onChange:se=>Y(se.target.value),placeholder:"https://…",className:"flex-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"}),m.jsx(ri,{className:"px-3 py-2 text-sm",onClick:St,disabled:!z||W,title:z?"In Models speichern":"Bitte gültige URL einfügen",children:"Hinzufügen"}),m.jsx(ri,{className:"px-3 py-2 text-sm",onClick:yt,disabled:i,children:"Aktualisieren"})]}),re?m.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:re}):z?m.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Gefunden: ",m.jsx("span",{className:"font-medium",children:z.modelKey}),z.host?m.jsxs("span",{className:"opacity-70",children:[" • ",z.host]}):null]}):null,r?m.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:r}):null]})}),m.jsx(pa,{header:m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"grid gap-2 sm:flex sm:items-center sm:justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white whitespace-nowrap",children:["Models ",m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",Qe.length,")"]})]}),m.jsx("div",{className:"sm:hidden shrink-0",children:m.jsx(ri,{variant:"secondary",size:"md",onClick:_e,children:"Import"})}),m.jsx("div",{className:"hidden sm:block shrink-0",children:m.jsx(ri,{variant:"secondary",size:"md",onClick:_e,children:"Importieren"})})]}),m.jsxs("div",{className:"w-full sm:w-auto min-w-0",children:[m.jsxs("div",{className:"sm:hidden grid gap-2",children:[m.jsxs("div",{className:"grid grid-cols-[auto,minmax(0,1fr)] gap-2 items-center min-w-0",children:[m.jsx("div",{className:"shrink-0",children:m.jsx(hx,{ariaLabel:"Ansicht umschalten",size:"lg",className:"flex w-full [&>button]:flex-1 [&>button]:min-w-0",value:y,onChange:se=>{(se==="table"||se==="gallery")&&v(se)},items:[{id:"gallery",label:"Gallery",icon:m.jsx(SA,{})},{id:"table",label:"Tabelle",icon:m.jsx(_A,{})}]})}),m.jsx("div",{className:"min-w-0",children:y==="gallery"?m.jsxs(m.Fragment,{children:[m.jsx("label",{className:"sr-only",htmlFor:"models-gallery-sort-mobile",children:"Sortierung"}),m.jsxs("select",{id:"models-gallery-sort-mobile",value:bA(j),onChange:se=>{const ke=TA(se.target.value);P(ke)},className:`\r
h-9 w-full min-w-0\r
rounded-md px-2 text-sm\r
bg-white text-gray-900 shadow-sm ring-1 ring-gray-200\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:bg-white/10 dark:text-white dark:ring-white/10 dark:[color-scheme:dark]\r
`,children:[m.jsx("option",{value:"created_desc",children:"Hinzugefügt ↓"}),m.jsx("option",{value:"created_asc",children:"Hinzugefügt ↑"}),m.jsx("option",{value:"model_asc",children:"Model A→Z"}),m.jsx("option",{value:"model_desc",children:"Model Z→A"}),m.jsx("option",{value:"videos_desc",children:"Videos ↓"}),m.jsx("option",{value:"videos_asc",children:"Videos ↑"}),m.jsx("option",{value:"tags_desc",children:"Tags ↓"}),m.jsx("option",{value:"tags_asc",children:"Tags ↑"})]})]}):m.jsx("div",{"aria-hidden":"true",className:`\r
h-9 w-full min-w-0\r
rounded-md px-3 text-sm\r
inline-flex items-center\r
bg-gray-50 text-gray-400 ring-1 ring-gray-200\r
dark:bg-white/5 dark:text-white/30 dark:ring-white/10\r
select-none\r
`,title:"Sortierung in der Tabellenansicht über Spaltenkopf",children:"Sortierung"})})]}),m.jsx("input",{value:u,onChange:se=>c(se.target.value),placeholder:"Suchen…",className:`\r
w-full min-w-0\r
rounded-md px-3 py-2 text-sm\r
bg-white text-gray-900 shadow-sm ring-1 ring-gray-200\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:bg-white/10 dark:text-white dark:ring-white/10\r
`})]}),m.jsxs("div",{className:"hidden sm:flex items-center gap-2 min-w-0 sm:justify-end",children:[y==="gallery"?m.jsxs("div",{className:"shrink-0",children:[m.jsx("label",{className:"sr-only",htmlFor:"models-gallery-sort",children:"Sortierung"}),m.jsxs("select",{id:"models-gallery-sort",value:bA(j),onChange:se=>{const ke=TA(se.target.value);P(ke)},className:`\r
h-9 w-auto\r
rounded-md px-3 text-sm\r
bg-white text-gray-900 shadow-sm ring-1 ring-gray-200\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:bg-white/10 dark:text-white dark:ring-white/10 dark:[color-scheme:dark]\r
`,children:[m.jsx("option",{value:"created_desc",children:"Hinzugefügt ↓"}),m.jsx("option",{value:"created_asc",children:"Hinzugefügt ↑"}),m.jsx("option",{value:"model_asc",children:"Model A→Z"}),m.jsx("option",{value:"model_desc",children:"Model Z→A"}),m.jsx("option",{value:"videos_desc",children:"Videos ↓"}),m.jsx("option",{value:"videos_asc",children:"Videos ↑"}),m.jsx("option",{value:"tags_desc",children:"Tags ↓"}),m.jsx("option",{value:"tags_asc",children:"Tags ↑"})]})]}):null,m.jsx("div",{className:"shrink-0",children:m.jsx(hx,{ariaLabel:"Ansicht umschalten",size:"lg",value:y,onChange:se=>{(se==="table"||se==="gallery")&&v(se)},items:[{id:"gallery",label:"Gallery",icon:m.jsx(SA,{})},{id:"table",label:"Tabelle",icon:m.jsx(_A,{})}]})}),m.jsx("input",{value:u,onChange:se=>c(se.target.value),placeholder:"Suchen…",className:`\r
w-full sm:w-[260px]\r
rounded-md px-3 py-2 text-sm\r
bg-white text-gray-900 shadow-sm ring-1 ring-gray-200\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:bg-white/10 dark:text-white dark:ring-white/10\r
`})]})]})]}),T.length>0?m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Tag-Filter:"}),m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[T.map(se=>m.jsx(Zr,{tag:se,active:!0,onClick:K,title:se},se)),m.jsx(ri,{size:"sm",variant:"soft",className:"text-xs font-medium text-gray-600 hover:underline dark:text-gray-300",onClick:k,children:"Zurücksetzen"})]})]}):null]}),noBodyPadding:!0,children:y==="table"?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"overflow-x-auto",children:m.jsx("div",{className:"min-w-[980px]",children:m.jsx(Sh,{rows:ct,columns:_t,getRowKey:se=>se.id,striped:!0,compact:!0,fullWidth:!0,stickyHeader:!0,sort:j,onSortChange:se=>P(se),onRowClick:se=>{const ke=Ym(se);ke&&window.open(ke,"_blank","noreferrer")}})})}),m.jsx(mx,{page:d,pageSize:g,totalItems:ze,onPageChange:f})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"p-2 sm:p-3",children:ct.length===0?m.jsx("div",{className:"rounded-lg border border-dashed border-gray-200 p-8 text-center text-sm text-gray-500 dark:border-white/10 dark:text-gray-400",children:"Keine Models gefunden."}):m.jsx("div",{className:"grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-5",children:ct.map(se=>{const ke=Ym(se),De=yA(se),Ue=Wm(se.tags),at=Ue.slice(0,3),dt=se.liked===!0,wt=se.favorite===!0,kt=se.watching===!0,Tt=!kt&&!wt&&!dt,Ft=w[String(se.modelKey||"").trim().toLowerCase()]??0,Qt=String(se.modelKey||"?"),Zt=Qt.length;return m.jsxs("div",{className:"group h-full overflow-hidden rounded-md border border-gray-200 bg-slate-900/80 shadow-sm transition hover:shadow-md dark:border-white/10 flex flex-col",children:[m.jsx("div",{className:"relative cursor-pointer bg-slate-950",onClick:()=>{ke&&window.open(ke,"_blank","noreferrer")},children:m.jsxs("div",{className:"relative aspect-[3/4] w-full overflow-hidden bg-[#12202c]",children:[De?m.jsx("img",{src:De,alt:se.modelKey,loading:"lazy",className:"absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.02]",onError:Et=>{Et.currentTarget.style.display="none";const Dt=Et.currentTarget.nextElementSibling;Dt&&(Dt.style.display="flex")}}):null,m.jsx("div",{className:ni("absolute inset-0 items-center justify-center px-3 text-center font-semibold text-slate-500 leading-tight",De?"hidden":"flex"),style:{display:De?"none":"flex",fontSize:Zt<=10?"clamp(1rem, 1.4vw + 0.4rem, 2.1rem)":Zt<=18?"clamp(0.95rem, 1.15vw + 0.3rem, 1.7rem)":"clamp(0.8rem, 0.9vw + 0.25rem, 1.25rem)",lineHeight:1.1,overflowWrap:"anywhere",wordBreak:"break-word"},title:Qt,children:Qt}),m.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),m.jsxs("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 p-2.5 pr-18 sm:pr-2.5",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",title:se.modelKey,children:se.modelKey}),se.host?m.jsx("div",{className:"truncate text-[11px] text-white/70 drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:se.host}):null]}),m.jsxs("div",{className:"pointer-events-none absolute bottom-2 right-2 z-10 flex flex-col items-end gap-1",children:[m.jsxs("span",{className:"inline-flex items-center gap-1 px-0.5 py-0 text-[10px] font-semibold text-white/95 tabular-nums",title:"Videos","aria-hidden":"true",children:[m.jsx("span",{className:"text-[11px] leading-none drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:"🎬"}),m.jsx("span",{className:"drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:O?"…":Ft})]}),m.jsxs("span",{className:"inline-flex items-center gap-1 px-0.5 py-0 text-[10px] font-semibold text-white/95 tabular-nums",title:"Tags","aria-hidden":"true",children:[m.jsx("span",{className:"text-[11px] leading-none drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:"🏷️"}),m.jsx("span",{className:"drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:Ue.length})]})]}),m.jsx("div",{className:ni("absolute left-2 z-10 flex items-center gap-1",se.hot||se.keep?"top-12":"top-2"),onClick:Et=>Et.stopPropagation(),children:m.jsx(ga,{job:Ee(se),variant:"table",order:["add","details"],className:`\r
flex items-center gap-1\r
[&_button]:h-7 [&_button]:w-7 [&_button]:min-w-0 [&_button]:p-0\r
[&_button]:bg-transparent [&_button]:shadow-none\r
[&_button:hover]:bg-white/10\r
[&_button]:border-0\r
[&_button_svg]:drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]\r
`})}),m.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5 pointer-events-none select-none",children:[kt?m.jsx("span",{className:"inline-flex items-center justify-center text-xl leading-none text-indigo-300 drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",title:"Beobachtet","aria-hidden":"true",children:"👁"}):null,wt?m.jsx("span",{className:"inline-flex items-center justify-center text-xl leading-none text-amber-300 drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",title:"Favorit","aria-hidden":"true",children:"★"}):null,dt?m.jsx("span",{className:"inline-flex items-center justify-center text-xl leading-none text-rose-300 drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",title:"Gefällt mir","aria-hidden":"true",children:"♥"}):null]}),(se.hot||se.keep)&&m.jsxs("div",{className:"absolute left-2 top-2 flex flex-col gap-1",children:[se.hot?m.jsx("span",{className:"rounded bg-amber-500/90 px-1.5 py-0.5 text-[10px] font-semibold text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:"HOT"}):null,se.keep?m.jsx("span",{className:"rounded bg-indigo-500/90 px-1.5 py-0.5 text-[10px] font-semibold text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]",children:"KEEP"}):null]})]})}),m.jsxs("div",{className:"border-t border-white/5 bg-slate-800/70 px-2.5 py-2 rounded-b-md flex-1",children:[m.jsxs("div",{className:"sm:hidden",children:[m.jsxs("div",{className:"grid grid-cols-3 gap-1.5",onClick:Et=>Et.stopPropagation(),children:[m.jsx(ri,{variant:kt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",kt?"bg-indigo-500/20 text-indigo-200 hover:bg-indigo-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:kt?"Nicht mehr beobachten":"Beobachten",onClick:Et=>{Et.stopPropagation(),Fe(se.id,{watched:!kt})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",kt?"text-indigo-300":"text-slate-300"),children:"👁"})})}),m.jsx(ri,{variant:wt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",wt?"bg-amber-500/20 text-amber-200 hover:bg-amber-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:wt?"Favorit entfernen":"Als Favorit markieren",onClick:Et=>{Et.stopPropagation(),wt?Fe(se.id,{favorite:!1}):Fe(se.id,{favorite:!0,liked:!1})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",wt?"text-amber-300":"text-slate-300"),children:"★"})})}),m.jsx(ri,{variant:dt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",dt?"bg-rose-500/20 text-rose-200 hover:bg-rose-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:dt?"Gefällt mir entfernen":"Gefällt mir",onClick:Et=>{Et.stopPropagation(),dt?Fe(se.id,{liked:!1}):Fe(se.id,{liked:!0,favorite:!1})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",dt?"text-rose-300":"text-slate-300"),children:"♥"})})})]}),m.jsx("div",{className:"mt-2 min-h-[24px] flex flex-wrap items-start gap-1.5",children:at.length>0?at.map(Et=>m.jsx(Zr,{tag:Et,title:Et,active:N.has(Et.toLowerCase()),onClick:K},`${se.id}:${Et}`)):m.jsx("span",{className:"opacity-0 select-none pointer-events-none text-[11px]",children:"placeholder"})})]}),m.jsxs("div",{className:"hidden sm:block",children:[m.jsx("div",{onClick:Et=>Et.stopPropagation(),children:m.jsxs("div",{className:"grid grid-cols-3 gap-1.5 w-full",children:[m.jsx(ri,{variant:kt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",Tt&&!kt?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100",kt?"bg-indigo-500/20 text-indigo-200 hover:bg-indigo-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:kt?"Nicht mehr beobachten":"Beobachten",onClick:Et=>{Et.stopPropagation(),Fe(se.id,{watched:!kt})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",kt?"text-indigo-300":"text-slate-300"),children:"👁"})})}),m.jsx(ri,{variant:wt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",Tt&&!wt?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100",wt?"bg-amber-500/20 text-amber-200 hover:bg-amber-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:wt?"Favorit entfernen":"Als Favorit markieren",onClick:Et=>{Et.stopPropagation(),wt?Fe(se.id,{favorite:!1}):Fe(se.id,{favorite:!0,liked:!1})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",wt?"text-amber-300":"text-slate-300"),children:"★"})})}),m.jsx(ri,{variant:dt?"soft":"secondary",size:"xs",className:ni("h-8 min-w-0 px-0 shadow-none",Tt&&!dt?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100",dt?"bg-rose-500/20 text-rose-200 hover:bg-rose-500/30":"bg-white/5 text-slate-200 hover:bg-white/10"),title:dt?"Gefällt mir entfernen":"Gefällt mir",onClick:Et=>{Et.stopPropagation(),dt?Fe(se.id,{liked:!1}):Fe(se.id,{liked:!0,favorite:!1})},children:m.jsx("span",{className:"inline-flex items-center justify-center gap-1",children:m.jsx("span",{className:ni("text-xl leading-none",dt?"text-rose-300":"text-slate-300"),children:"♥"})})})]})}),m.jsx("div",{className:"mt-2 min-h-[24px] flex flex-wrap items-start gap-1.5",children:at.length>0?at.map(Et=>m.jsx(Zr,{tag:Et,title:Et,active:N.has(Et.toLowerCase()),onClick:K},`${se.id}:${Et}`)):m.jsx("span",{className:"opacity-0 select-none pointer-events-none text-[11px]",children:"placeholder"})})]})]})]},se.id)})})}),m.jsx(mx,{page:d,pageSize:g,totalItems:ze,onPageChange:f})]})}),m.jsx(lb,{open:Z,onClose:()=>!Pe&&te(!1),title:"Models importieren",footer:m.jsxs(m.Fragment,{children:[m.jsx(ri,{variant:"secondary",onClick:()=>te(!1),disabled:Pe,children:"Abbrechen"}),m.jsx(ri,{variant:"primary",onClick:Ve,isLoading:Pe,disabled:!oe||Pe,children:"Import starten"})]}),children:m.jsxs("div",{className:"space-y-3",children:[m.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Wähle eine CSV-Datei zum Import aus."}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Import-Typ"}),m.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[m.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[m.jsx("input",{type:"radio",name:"import-kind",value:"favorite",checked:Ie==="favorite",onChange:()=>Le("favorite"),disabled:Pe}),"Favoriten (★)"]}),m.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[m.jsx("input",{type:"radio",name:"import-kind",value:"liked",checked:Ie==="liked",onChange:()=>Le("liked"),disabled:Pe}),"Gefällt mir (♥)"]})]})]}),m.jsx("input",{type:"file",accept:".csv,text/csv",onChange:se=>{const ke=se.target.files?.[0]??null;Re(null),F(ke)},className:"block w-full text-sm text-gray-700 file:mr-4 file:rounded-md file:border-0 file:bg-gray-100 file:px-3 file:py-2 file:text-sm file:font-semibold file:text-gray-900 hover:file:bg-gray-200 dark:text-gray-200 dark:file:bg-white/10 dark:file:text-white dark:hover:file:bg-white/20"}),oe?m.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Ausgewählt: ",m.jsx("span",{className:"font-medium",children:oe.name})]}):null,Se?m.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:Se}):null,le?m.jsx("div",{className:"rounded-md bg-green-50 px-3 py-2 text-xs text-green-700 dark:bg-green-500/10 dark:text-green-200",children:le}):null]})})]})}function Qi(...s){return s.filter(Boolean).join(" ")}const bH=new Intl.NumberFormat("de-DE");function nu(s){return s==null||!Number.isFinite(s)?"—":bH.format(s)}function TH(s){if(s==null||!Number.isFinite(s))return"—";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0||i===1?0:1;return`${t.toFixed(n)} ${e[i]}`}function Zv(s){if(s==null||!Number.isFinite(s)||s<0)return"—";const e=Math.floor(s),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}:${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}`:`${i}:${String(n).padStart(2,"0")}`}function rh(s){if(!s)return"—";const e=typeof s=="string"?new Date(s):s;return Number.isNaN(e.getTime())?String(s):e.toLocaleString("de-DE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function SH(s){return s?s.split(",").map(e=>e.trim()).filter(Boolean):[]}function gh(s){return(s||"").split(/[\\/]/).pop()||""}function HR(s){if(!s)return"—";const e=typeof s=="string"?new Date(s):s;return Number.isNaN(e.getTime())?String(s):e.toLocaleDateString("de-DE",{year:"2-digit",month:"2-digit",day:"2-digit"})}function C1(s){return s.startsWith("HOT ")?s.slice(4):s}function zR(s){return String(s||"").startsWith("HOT ")}function _H(s,e){const t=String(s||"");return t&&t.replace(/([\\/])[^\\/]*$/,`$1${e}`)}function EH(s){return zR(s)?C1(s):`HOT ${s}`}function wH(s){const e=gh(s||""),t=C1(e);if(!t)return"—";const i=t.replace(/\.[^.]+$/,""),n=i.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(n?.[1])return n[1];const r=i.lastIndexOf("_");return r>0?i.slice(0,r):i}function d0(s){return s?String(s).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi,"").replace(/<\/?[^>]+>/g," ").replace(/\s+/g," ").trim():""}function EA(s){const e=String(s??"").trim();if(!e)return"";const t=e.match(/HTTP\s+(\d{3})/i);if(t?.[1])return`HTTP ${t[1]}`;const i=e.toLowerCase();if(i.includes("<!doctype")||i.includes("<html")||i.includes("text/html"))return"HTTP Error (HTML response)";const n=e.replace(/\s+/g," ");return n.length>80?n.slice(0,77)+"…":n}function wA(s){const e=String(s??"").trim();if(!e)return"";const t=d0(e);return t.length>2e3?t.slice(0,2e3)+"…":t}function AH(s){if(!s)return"";const e=String(s).trim();return e?e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/")?`https://chaturbate.com${e}`:`https://chaturbate.com/${e}`:""}function Pr(s){return Qi("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ring-1 ring-inset",s)}const ah=s=>s?"blur-md scale-[1.03] brightness-90":"";function kH(s){return C1(s||"").trim()||"—"}function CH(s){const e=s.endedAt??s.completedAt??s.endedAt;return e?HR(e):"—"}function DH(s){let e=String(s??"").trim();if(!e)return"";if(e=e.replace(/^https?:\/\//i,""),e.includes("/")){const t=e.split("/").filter(Boolean);e=t[t.length-1]||e}return e.includes(":")&&(e=e.split(":").pop()||e),e.trim().toLowerCase()}function LH(s){const e=s??{},t=e.cf_clearance||e["cf-clearance"]||e.cfclearance||"",i=e.sessionId||e.sessionid||e.session_id||e["session-id"]||"",n=[];return t&&n.push(`cf_clearance=${t}`),i&&n.push(`sessionid=${i}`),n.join("; ")}function RH({open:s,modelKey:e,onClose:t,onOpenPlayer:i,cookies:n,runningJobs:r,blurPreviews:a,onToggleWatch:u,onToggleFavorite:c,onToggleLike:d,onToggleHot:f,onDelete:g}){const[y,v]=b.useState([]),[,T]=b.useState(!1),[S,w]=b.useState(null),[L,O]=b.useState(null),[I,j]=b.useState(null),[P,G]=b.useState(null),[N,K]=b.useState(!1),[k,R]=b.useState([]),[Y,z]=b.useState(!1),[X,re]=b.useState([]),[J,W]=b.useState(!1),[q,Z]=b.useState(0),[te,oe]=b.useState(null),[F,le]=b.useState(0),[ge,Ie]=b.useState(1),Le=25,Pe=DH(e),Je=b.useCallback(async()=>{try{const ie=await(await fetch("/api/models",{cache:"no-store"})).json().catch(()=>null);v(Array.isArray(ie)?ie:[])}catch{}},[]),Se=b.useCallback(async()=>{if(Pe){z(!0);try{const $=`/api/record/done?model=${encodeURIComponent(Pe)}&page=${ge}&pageSize=${Le}&sort=completed_desc&includeKeep=1&withCount=1`,Te=await(await fetch($,{cache:"no-store"})).json().catch(()=>null),Be=Array.isArray(Te?.items)?Te.items:[],ht=Number(Te?.count??Be.length);R(Be),le(Number.isFinite(ht)?ht:Be.length)}catch{}finally{z(!1)}}},[Pe,ge]);function Re($){return{id:`model:${$}`,output:`${$}_01_01_2000__00-00-00.mp4`,status:"finished"}}const Ve=b.useCallback(($,ie)=>{const Te=String($??"").trim();Te&&oe({src:Te,alt:ie})},[]);b.useEffect(()=>{s||Z(0)},[s]);const Ee=b.useMemo(()=>Array.isArray(r)?r:X,[r,X]);b.useEffect(()=>{s&&Ie(1)},[s,e]),b.useEffect(()=>{if(!s)return;let $=!0;return T(!0),fetch("/api/models",{cache:"no-store"}).then(ie=>ie.json()).then(ie=>{$&&v(Array.isArray(ie)?ie:[])}).catch(()=>{$&&v([])}).finally(()=>{$&&T(!1)}),()=>{$=!1}},[s]),b.useEffect(()=>{if(!s||!Pe)return;let $=!0,ie=null,Te=null;const Be=async()=>{try{Te?.abort(),Te=new AbortController;const It=await(await fetch("/api/chaturbate/online",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",signal:Te.signal,body:JSON.stringify({q:[Pe],show:[],refresh:!1})})).json().catch(()=>null);if(!$)return;O({enabled:It?.enabled,fetchedAt:It?.fetchedAt,lastError:It?.lastError});const Yt=Array.isArray(It?.rooms)?It.rooms:[];w(Yt[0]??null)}catch(ht){if(ht?.name==="AbortError"||!$)return;O({enabled:void 0,fetchedAt:void 0,lastError:"Fetch fehlgeschlagen"}),w(null)}};return Be(),ie=window.setInterval(Be,8e3),()=>{$=!1,ie&&window.clearInterval(ie),Te?.abort()}},[s,Pe]),b.useEffect(()=>{if(!s||!Pe)return;let $=!0;K(!0),j(null),G(null);const ie=LH(n),Te=`/api/chaturbate/biocontext?model=${encodeURIComponent(Pe)}${q>0?"&refresh=1":""}`;return fetch(Te,{cache:"no-store",headers:ie?{"X-Chaturbate-Cookie":ie}:void 0}).then(async Be=>{if(!Be.ok){const ht=await Be.text().catch(()=>"");throw new Error(ht||`HTTP ${Be.status}`)}return Be.json()}).then(Be=>{$&&(G({enabled:Be?.enabled,fetchedAt:Be?.fetchedAt,lastError:Be?.lastError}),j(Be?.bio??null))}).catch(Be=>{$&&(G({enabled:void 0,fetchedAt:void 0,lastError:Be?.message||"Fetch fehlgeschlagen"}),j(null))}).finally(()=>{$&&K(!1)}),()=>{$=!1}},[s,Pe,q,n]),b.useEffect(()=>{!s||!Pe||Se()},[s,Pe,Se]),b.useEffect(()=>{if(!s||Array.isArray(r))return;let $=!0;return W(!0),fetch("/api/record/jobs",{cache:"no-store"}).then(ie=>ie.json()).then(ie=>{$&&re(Array.isArray(ie)?ie:[])}).catch(()=>{$&&re([])}).finally(()=>{$&&W(!1)}),()=>{$=!1}},[s,r]);const _e=b.useMemo(()=>Pe?y.find($=>($.modelKey||"").toLowerCase()===Pe)??null:null,[y,Pe]),yt=k,ut=b.useMemo(()=>Math.max(1,Math.ceil(F/Le)),[F]),pt=b.useMemo(()=>Pe?Ee.filter($=>{const ie=wH($.output);return ie!=="—"&&ie.trim().toLowerCase()===Pe}):[],[Ee,Pe]),Fe=b.useMemo(()=>{const $=SH(_e?.tags),ie=Array.isArray(S?.tags)?S.tags:[],Te=new Map;for(const Be of[...$,...ie]){const ht=String(Be).trim().toLowerCase();ht&&(Te.has(ht)||Te.set(ht,String(Be).trim()))}return Array.from(Te.values()).sort((Be,ht)=>Be.localeCompare(ht,"de"))},[_e?.tags,S?.tags]),_t=S?.display_name||_e?.modelKey||Pe||"Model",Qe=S?.image_url_360x270||S?.image_url||"",Xe=S?.image_url||Qe,ze=S?.chat_room_url_revshare||S?.chat_room_url||"",Ze=(S?.current_show||"").trim().toLowerCase(),ct=Ze?Ze==="public"?"Public":Ze==="private"?"Private":Ze:"",St=(I?.location||"").trim(),se=I?.follower_count,ke=I?.display_age,De=(I?.room_status||"").trim(),Ue=I?.last_broadcast?rh(I.last_broadcast):"—",at=d0(I?.about_me),dt=d0(I?.wish_list),wt=_e?.lastSeenOnline==null?"":_e.lastSeenOnline?"online":"offline",kt=(De||Ze||wt||"").trim(),Tt=Array.isArray(I?.social_medias)?I.social_medias:[],Ft=Array.isArray(I?.photo_sets)?I.photo_sets:[],Qt=Array.isArray(I?.interested_in)?I.interested_in:[],Zt=({icon:$,label:ie,value:Te})=>m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 px-2.5 py-2 sm:px-3 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] sm:text-xs text-gray-600 dark:text-gray-300",children:[$,ie]}),m.jsx("div",{className:"mt-0.5 text-sm font-semibold text-gray-900 dark:text-white",children:Te})]}),Et=b.useCallback(async $=>{const ie=$.output||"",Te=gh(ie);if(!Te){await f?.($);return}const Be=EH(Te);R(ht=>ht.map(It=>It.id&&$.id&&It.id===$.id||It.output&&$.output&&It.output===$.output?{...It,output:_H(It.output||"",Be)}:It)),await f?.($),Se()},[f,Se]),Dt=b.useCallback(async $=>{const ie=$.output||"";gh(ie)&&R(Be=>Be.filter(ht=>!(ht.id&&$.id&&ht.id===$.id||ht.output&&$.output&&ht.output===$.output))),await g?.($),Se()},[g,Se]),yi=b.useCallback(async()=>{Pe&&(v($=>$.map(ie=>(ie.modelKey||"").toLowerCase()===Pe?{...ie,favorite:!ie.favorite}:ie)),await c?.(Re(Pe)),Je())},[Pe,c,Je]),Pi=b.useCallback(async()=>{Pe&&(v($=>$.map(ie=>(ie.modelKey||"").toLowerCase()===Pe?{...ie,liked:ie.liked!==!0}:ie)),await d?.(Re(Pe)),Je())},[Pe,d,Je]),Jt=b.useCallback(async()=>{Pe&&(v($=>$.map(ie=>(ie.modelKey||"").toLowerCase()===Pe?{...ie,watching:!ie.watching}:ie)),await u?.(Re(Pe)),Je())},[Pe,u,Je]),[ki,gt]=b.useState("info");b.useEffect(()=>{s&&gt("info")},[s,Pe]);const V=[{id:"info",label:"Info"},{id:"downloads",label:"Downloads",count:F?nu(F):void 0,disabled:Y},{id:"running",label:"Running",count:pt.length?nu(pt.length):void 0,disabled:J}];return m.jsxs(lb,{open:s,onClose:t,title:_t,width:"max-w-6xl",layout:"split",scroll:"right",leftWidthClass:"lg:w-[320px]",mobileCollapsedImageSrc:Qe||void 0,mobileCollapsedImageAlt:_t,rightBodyClassName:"pt-0 sm:pt-2",left:m.jsx("div",{className:"space-y-3 sm:space-y-4",children:m.jsxs("div",{className:"hidden sm:block space-y-2",children:[m.jsxs("div",{className:"overflow-hidden rounded-lg border border-gray-200/70 bg-white/70 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"relative",children:[Qe?m.jsx("button",{type:"button",className:"block w-full cursor-zoom-in",onClick:()=>Ve(Xe,_t),"aria-label":"Bild vergrößern",children:m.jsx("img",{src:Qe,alt:_t,className:Qi("h-24 sm:h-52 w-full object-cover transition",ah(a))})}):m.jsx("div",{className:"h-24 sm:h-52 w-full bg-gradient-to-br from-indigo-500/10 via-transparent to-sky-500/10"}),m.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-black/40 via-black/0 to-black/0"}),m.jsxs("div",{className:"absolute left-3 top-3 flex flex-wrap items-center gap-2",children:[ct?m.jsx("span",{className:Pr("bg-emerald-500/10 text-emerald-900 ring-emerald-200 backdrop-blur dark:text-emerald-200 dark:ring-emerald-400/20"),children:ct}):null,kt?m.jsx("span",{className:Pr(kt.toLowerCase()==="online"?"bg-emerald-500/10 text-emerald-900 ring-emerald-200 backdrop-blur dark:text-emerald-200 dark:ring-emerald-400/20":"bg-gray-500/10 text-gray-900 ring-gray-200 backdrop-blur dark:text-gray-200 dark:ring-white/15"),children:kt}):null,S?.is_hd?m.jsx("span",{className:Pr("bg-indigo-500/10 text-indigo-900 ring-indigo-200 backdrop-blur dark:text-indigo-200 dark:ring-indigo-400/20"),children:"HD"}):null,S?.is_new?m.jsx("span",{className:Pr("bg-amber-500/10 text-amber-900 ring-amber-200 backdrop-blur dark:text-amber-200 dark:ring-amber-400/20"),children:"NEW"}):null]}),m.jsxs("div",{className:"absolute bottom-3 left-3 right-3",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-white drop-shadow",children:S?.display_name||S?.username||_e?.modelKey||Pe||"—"}),m.jsx("div",{className:"truncate text-xs text-white/85 drop-shadow",children:S?.username?`@${S.username}`:_e?.modelKey?`@${_e.modelKey}`:""})]}),m.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-2",children:[m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),Jt()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",_e?.watching?"bg-sky-500/25 ring-sky-200/30":"bg-black/20 ring-white/15"),title:_e?.watching?"Watch entfernen":"Auf Watch setzen","aria-pressed":!!_e?.watching,"aria-label":_e?.watching?"Watch entfernen":"Auf Watch setzen",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(g0,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.watching?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),m.jsx(Su,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.watching?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-sky-200")})]})}),m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),yi()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",_e?.favorite?"bg-amber-500/25 ring-amber-200/30":"bg-black/20 ring-white/15"),title:_e?.favorite?"Favorit entfernen":"Als Favorit markieren","aria-pressed":!!_e?.favorite,"aria-label":_e?.favorite?"Favorit entfernen":"Als Favorit markieren",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(y0,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.favorite?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),m.jsx(Mc,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.favorite?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-amber-200")})]})}),m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),Pi()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",_e?.liked?"bg-rose-500/25 ring-rose-200/30":"bg-black/20 ring-white/15"),title:_e?.liked?"Like entfernen":"Liken","aria-pressed":_e?.liked===!0,"aria-label":_e?.liked?"Like entfernen":"Liken",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(Th,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.liked?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),m.jsx(_u,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.liked?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-rose-200")})]})})]})]}),m.jsxs("div",{className:"p-3 sm:p-4",children:[m.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[m.jsx(Zt,{icon:m.jsx(n2,{className:"size-4"}),label:"Viewer",value:nu(S?.num_users)}),m.jsx(Zt,{icon:m.jsx(Py,{className:"size-4"}),label:"Follower",value:nu(S?.num_followers??se)})]}),m.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-xs",children:[m.jsxs("div",{className:"rounded-lg border border-gray-200/60 bg-white/50 px-2.5 py-2 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[m.jsx(TM,{className:"size-4"}),"Location"]}),m.jsx("dd",{className:"mt-1 text-[13px] font-semibold leading-snug text-gray-900 dark:text-white break-words",children:S?.location||St||"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/60 bg-white/50 px-2.5 py-2 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[m.jsx(gM,{className:"size-4"}),"Sprache"]}),m.jsx("dd",{className:"mt-1 text-[13px] font-semibold leading-snug text-gray-900 dark:text-white break-words",children:S?.spoken_languages||"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/60 bg-white/50 px-2.5 py-2 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[m.jsx(Em,{className:"size-4"}),"Online"]}),m.jsx("dd",{className:"mt-1 text-[13px] font-semibold leading-snug text-gray-900 dark:text-white break-words",children:Zv(S?.seconds_online)})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/60 bg-white/50 px-2.5 py-2 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[m.jsx(Th,{className:"size-4"}),"Alter"]}),m.jsx("dd",{className:"mt-1 text-[13px] font-semibold leading-snug text-gray-900 dark:text-white break-words",children:ke!=null?String(ke):S?.age!=null?String(S.age):"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/60 bg-white/50 px-2.5 py-2 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[m.jsx(Em,{className:"size-4"}),"Last broadcast"]}),m.jsx("dd",{className:"mt-1 text-[13px] font-semibold leading-snug text-gray-900 dark:text-white break-words",children:Ue})]})]}),L?.enabled===!1?m.jsx("div",{className:"mt-2 rounded-lg border border-amber-200/60 bg-amber-50/70 px-3 py-2 text-xs text-amber-900 dark:border-amber-400/20 dark:bg-amber-400/10 dark:text-amber-200",children:"Chaturbate-Online ist aktuell deaktiviert."}):L?.lastError?m.jsxs("div",{className:"mt-2 rounded-lg border border-rose-200/60 bg-rose-50/70 px-3 py-2 text-xs text-rose-900 dark:border-rose-400/20 dark:bg-rose-400/10 dark:text-rose-200",children:[m.jsxs("div",{className:"font-medium",children:["Online-Info: ",EA(L.lastError)]}),m.jsxs("details",{className:"mt-1",children:[m.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-rose-900/80 underline underline-offset-2 dark:text-rose-200/80",children:"Details"}),m.jsx("pre",{className:"mt-1 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded-md bg-black/5 p-2 text-[11px] leading-snug dark:bg-white/10",children:wA(L.lastError)})]})]}):null,P?.enabled===!1?m.jsx("div",{className:"mt-2 rounded-lg border border-amber-200/60 bg-amber-50/70 px-3 py-2 text-xs text-amber-900 dark:border-amber-400/20 dark:bg-amber-400/10 dark:text-amber-200",children:"BioContext ist aktuell deaktiviert."}):P?.lastError?m.jsxs("div",{className:"mt-2 rounded-lg border border-rose-200/60 bg-rose-50/70 px-3 py-2 text-xs text-rose-900 dark:border-rose-400/20 dark:bg-rose-400/10 dark:text-rose-200",children:["BioContext: ",P.lastError]}):null]})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Tags"}),Fe.length?m.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Fe.map($=>m.jsx(Zr,{tag:$},$))}):m.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Tags vorhanden."})]})]})}),rightHeader:m.jsxs("div",{className:Qi("border-b border-gray-200/70 dark:border-white/10","bg-white/95 backdrop-blur dark:bg-gray-800/95"),children:[m.jsxs("div",{className:"sm:hidden px-2 pb-2 space-y-1.5",children:[m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-2.5 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsxs("button",{type:"button",className:"relative shrink-0 overflow-hidden rounded-lg ring-1 ring-black/5 dark:ring-white/10",onClick:()=>Xe&&Ve(Xe,_t),"aria-label":"Bild vergrößern",children:[Qe?m.jsx("img",{src:Qe,alt:_t,className:Qi("size-10 object-cover",ah(a))}):m.jsx("div",{className:"size-10 bg-gradient-to-br from-indigo-500/10 via-transparent to-sky-500/10"}),m.jsx("span",{"aria-hidden":!0,className:Qi("absolute bottom-1.5 right-1.5 size-2.5 rounded-full ring-2 ring-white/80 dark:ring-gray-900/60",(kt||"").toLowerCase()==="online"?"bg-emerald-400":"bg-gray-400")})]}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:S?.display_name||S?.username||_e?.modelKey||Pe||"—"}),m.jsx("div",{className:"truncate text-xs text-gray-600 dark:text-gray-300",children:S?.username?`@${S.username}`:_e?.modelKey?`@${_e.modelKey}`:""})]}),m.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),Jt()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","transition active:scale-[0.98]",_e?.watching?"bg-sky-500/15 ring-sky-200/30":"bg-black/5 ring-black/10 dark:bg-white/5 dark:ring-white/10"),title:_e?.watching?"Watch entfernen":"Auf Watch setzen","aria-pressed":!!_e?.watching,"aria-label":_e?.watching?"Watch entfernen":"Auf Watch setzen",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(g0,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.watching?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-gray-700 dark:text-white/70")}),m.jsx(Su,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.watching?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-sky-500")})]})}),m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),yi()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","transition active:scale-[0.98]",_e?.favorite?"bg-amber-500/15 ring-amber-200/30":"bg-black/5 ring-black/10 dark:bg-white/5 dark:ring-white/10"),title:_e?.favorite?"Favorit entfernen":"Als Favorit markieren","aria-pressed":!!_e?.favorite,"aria-label":_e?.favorite?"Favorit entfernen":"Als Favorit markieren",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(y0,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.favorite?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-gray-700 dark:text-white/70")}),m.jsx(Mc,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.favorite?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-amber-500")})]})}),m.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),$.stopPropagation(),Pi()},className:Qi("inline-flex items-center justify-center rounded-full p-1.5 ring-1 ring-inset backdrop-blur","transition active:scale-[0.98]",_e?.liked?"bg-rose-500/15 ring-rose-200/30":"bg-black/5 ring-black/10 dark:bg-white/5 dark:ring-white/10"),title:_e?.liked?"Like entfernen":"Liken","aria-pressed":_e?.liked===!0,"aria-label":_e?.liked?"Like entfernen":"Liken",children:m.jsxs("span",{className:"relative inline-block size-4",children:[m.jsx(Th,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.liked?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-gray-700 dark:text-white/70")}),m.jsx(_u,{className:Qi("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",_e?.liked?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-rose-500")})]})})]})]}),m.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[ct?m.jsx("span",{className:Pr("bg-emerald-500/10 text-emerald-900 ring-emerald-200 dark:text-emerald-200 dark:ring-emerald-400/20"),children:ct}):null,De?m.jsx("span",{className:Pr(De.toLowerCase()==="online"?"bg-emerald-500/10 text-emerald-900 ring-emerald-200 dark:text-emerald-200 dark:ring-emerald-400/20":"bg-gray-500/10 text-gray-900 ring-gray-200 dark:text-gray-200 dark:ring-white/15"),children:De}):null,S?.is_hd?m.jsx("span",{className:Pr("bg-indigo-500/10 text-indigo-900 ring-indigo-200 dark:text-indigo-200 dark:ring-indigo-400/20"),children:"HD"}):null,S?.is_new?m.jsx("span",{className:Pr("bg-amber-500/10 text-amber-900 ring-amber-200 dark:text-amber-200 dark:ring-amber-400/20"),children:"NEW"}):null]}),ze?m.jsx("div",{className:"mt-1.5 flex justify-end",children:m.jsxs("a",{href:ze,target:"_blank",rel:"noreferrer",className:Qi("inline-flex h-8 items-center justify-center gap-1 rounded-lg px-3 text-sm font-medium","border border-gray-200/70 bg-white/70 text-gray-900 shadow-sm backdrop-blur hover:bg-white","dark:border-white/10 dark:bg-white/5 dark:text-white"),title:"Room öffnen",children:[m.jsx(_m,{className:"size-4"}),m.jsx("span",{children:"Room"})]})}):null]})]}),m.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-[12px] text-gray-700 dark:text-gray-200",children:[m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(n2,{className:"size-3.5 text-gray-400"}),m.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:nu(S?.num_users)})]}),m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(Py,{className:"size-3.5 text-gray-400"}),m.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:nu(S?.num_followers??se)})]}),m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(J_,{className:"size-3.5 text-gray-400"}),m.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:Zv(S?.seconds_online)})]}),m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(Em,{className:"size-3.5 text-gray-400"}),m.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:I?.last_broadcast?HR(I.last_broadcast):"—"})]})]}),L?.enabled===!1?m.jsx("div",{className:"mt-2 rounded-lg border border-amber-200/60 bg-amber-50/70 px-3 py-2 text-xs text-amber-900 dark:border-amber-400/20 dark:bg-amber-400/10 dark:text-amber-200",children:"Chaturbate-Online ist aktuell deaktiviert."}):L?.lastError?m.jsxs("div",{className:"mt-2 rounded-lg border border-rose-200/60 bg-rose-50/70 px-3 py-2 text-xs text-rose-900 dark:border-rose-400/20 dark:bg-rose-400/10 dark:text-rose-200",children:["Online-Info: ",L.lastError]}):null,P?.enabled===!1?m.jsx("div",{className:"mt-2 rounded-lg border border-amber-200/60 bg-amber-50/70 px-3 py-2 text-xs text-amber-900 dark:border-amber-400/20 dark:bg-amber-400/10 dark:text-amber-200",children:"BioContext ist aktuell deaktiviert."}):P?.lastError?m.jsxs("div",{className:"mt-2 rounded-lg border border-rose-200/60 bg-rose-50/70 px-3 py-2 text-xs text-rose-900 dark:border-rose-400/20 dark:bg-rose-400/10 dark:text-rose-200",children:[m.jsx("div",{className:"flex items-start justify-between gap-2",children:m.jsxs("div",{className:"font-medium",children:["BioContext: ",EA(P.lastError)]})}),m.jsxs("details",{className:"mt-1",children:[m.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-rose-900/80 underline underline-offset-2 dark:text-rose-200/80",children:"Details"}),m.jsx("pre",{className:"mt-1 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded-md bg-black/5 p-2 text-[11px] leading-snug dark:bg-white/10",children:wA(P.lastError)})]})]}):null]}),Fe.length?m.jsx("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 px-2 py-1.5 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 text-xs font-semibold text-gray-900 dark:text-white",children:["Tags ",m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",Fe.length,")"]})]}),m.jsx("div",{className:"-mx-1 flex-1 overflow-x-auto px-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:m.jsxs("div",{className:"flex min-w-max items-center gap-1.5",children:[Fe.slice(0,20).map($=>m.jsx(Zr,{tag:$},$)),Fe.length>20?m.jsxs("span",{className:Pr("bg-gray-500/10 text-gray-900 ring-gray-200 dark:text-gray-200 dark:ring-white/15"),children:["+",Fe.length-20]}):null]})})]})}):null]}),m.jsxs("div",{className:"flex items-start justify-between gap-2 px-2 py-2 sm:px-4",children:[m.jsx("div",{className:"min-w-0",children:m.jsx("div",{className:"text-[11px] leading-snug text-gray-600 dark:text-gray-300",children:Pe?m.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[L?.fetchedAt?m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Online-Stand: ",rh(L.fetchedAt)]}):null,P?.fetchedAt?m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["· Bio-Stand: ",rh(P.fetchedAt)]}):null,_e?.lastSeenOnlineAt?m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["· Zuletzt gesehen:"," ",m.jsx("span",{className:"font-medium",children:_e.lastSeenOnline==null?"—":_e.lastSeenOnline?"online":"offline"})," ","(",rh(_e.lastSeenOnlineAt),")"]}):null]}):"—"})}),m.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[ki==="info"?m.jsx(ri,{variant:"secondary",className:Qi("h-9 px-3 text-sm","whitespace-nowrap"),disabled:N||!e,onClick:()=>Z($=>$+1),title:"BioContext neu abrufen",children:m.jsxs("span",{className:"inline-flex items-center gap-2",children:[m.jsx(GO,{className:Qi("size-4",N?"animate-spin":"")}),m.jsx("span",{className:"hidden sm:inline",children:"Bio aktualisieren"})]})}):null,ze?m.jsxs("a",{href:ze,target:"_blank",rel:"noreferrer",className:Qi("inline-flex h-8 items-center justify-center gap-1 rounded-lg","border border-gray-200/70 bg-white/70 px-3 text-sm font-medium text-gray-900 shadow-sm backdrop-blur hover:bg-white","dark:border-white/10 dark:bg-white/5 dark:text-white","whitespace-nowrap"),title:"Room öffnen",children:[m.jsx(_m,{className:"size-4"}),m.jsx("span",{className:"hidden sm:inline",children:"Room öffnen"})]}):null]})]}),m.jsx("div",{className:"px-2 pb-2",children:m.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:m.jsx("div",{className:"min-w-max",children:m.jsx(cx,{tabs:V,value:ki,onChange:$=>gt($),variant:"pillsBrand",ariaLabel:"Bereich auswählen"})})})})]}),footer:m.jsx("div",{className:"w-full",children:m.jsx(ri,{variant:"secondary",className:"w-full sm:w-auto",onClick:t,children:"Schließen"})}),children:[m.jsxs("div",{className:"min-h-0",children:[ki==="info"?m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-3 sm:p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsx("div",{className:"flex items-center justify-between gap-3",children:m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Room Subject"})}),m.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:S?.room_subject?m.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words",children:S.room_subject}):m.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Keine Subject-Info vorhanden."})})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Bio"}),N?m.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Lade…"}):null]}),m.jsxs("div",{className:"mt-2 grid gap-3 sm:grid-cols-2",children:[m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 p-3 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:[m.jsx(hM,{className:"size-4"}),"Über mich"]}),m.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:at?m.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap",children:at}):m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"—"})})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 p-3 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:[m.jsx(Py,{className:"size-4"}),"Wishlist"]}),m.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:dt?m.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap",children:dt}):m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"—"})})]})]}),m.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Real name:"})," ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:I?.real_name?d0(I.real_name):"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Body type:"})," ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:I?.body_type||"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Smoke/Drink:"})," ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:I?.smoke_drink||"—"})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[m.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Sex:"})," ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:I?.sex||"—"})]})]}),Qt.length?m.jsxs("div",{className:"mt-2",children:[m.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"Interested in"}),m.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Qt.map($=>m.jsx("span",{className:Pr("bg-sky-500/10 text-sky-900 ring-sky-200 dark:text-sky-200 dark:ring-sky-400/20"),children:$},$))})]}):null]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Socials"}),Tt.length?m.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:[Tt.length," Links"]}):null]}),Tt.length?m.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:Tt.map($=>{const ie=AH($.link);return m.jsxs("a",{href:ie,target:"_blank",rel:"noreferrer",className:Qi("group flex min-w-0 w-full items-center gap-3 overflow-hidden rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-gray-900","transition hover:border-indigo-200 hover:bg-gray-50/80 hover:text-gray-900 dark:border-white/10 dark:bg-white/5 dark:text-white dark:hover:border-indigo-400/30 dark:hover:bg-white/10 dark:hover:text-white"),title:$.title_name,children:[m.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-black/5 dark:bg-white/5",children:$.image_url?m.jsx("img",{src:$.image_url,alt:"",className:"size-5"}):m.jsx(vM,{className:"size-5"})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:$.title_name}),m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:$.label_text?$.label_text:$.tokens!=null?`${$.tokens} token(s)`:"Link"})]}),m.jsx(_m,{className:"ml-auto size-4 text-gray-400 transition group-hover:text-indigo-500 dark:text-gray-500 dark:group-hover:text-indigo-400"})]},$.id)})}):m.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Social-Medias vorhanden."})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Photo sets"}),Ft.length?m.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:[Ft.length," Sets"]}):null]}),Ft.length?m.jsx("div",{className:"mt-2 grid gap-3 sm:grid-cols-2",children:Ft.slice(0,6).map($=>m.jsxs("div",{className:"overflow-hidden rounded-lg border border-gray-200/70 bg-white/60 dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"relative",children:[$.cover_url?m.jsx("button",{type:"button",className:"block w-full cursor-zoom-in",onClick:()=>Ve($.cover_url,$.name),"aria-label":"Bild vergrößern",children:m.jsx("img",{src:$.cover_url,alt:$.name,className:Qi("h-28 w-full object-cover transition",ah(a))})}):m.jsx("div",{className:"flex h-28 w-full items-center justify-center bg-black/5 dark:bg-white/5",children:m.jsx(i2,{className:"size-6 text-gray-500"})}),m.jsxs("div",{className:"absolute left-2 top-2 flex flex-wrap gap-2",children:[$.is_video?m.jsx("span",{className:Pr("bg-indigo-500/10 text-indigo-900 ring-indigo-200 dark:text-indigo-200 dark:ring-indigo-400/20"),children:"Video"}):m.jsx("span",{className:Pr("bg-gray-500/10 text-gray-900 ring-gray-200 dark:text-gray-200 dark:ring-white/15"),children:"Photos"}),$.fan_club_only?m.jsx("span",{className:Pr("bg-amber-500/10 text-amber-900 ring-amber-200 dark:text-amber-200 dark:ring-amber-400/20"),children:"FanClub"}):null]})]}),m.jsxs("div",{className:"p-3",children:[m.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:$.name}),m.jsxs("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:["Tokens: ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:nu($.tokens)}),$.user_can_access===!0?m.jsx("span",{className:"ml-2",children:"· Zugriff: ✅"}):null]})]})]},$.id))}):m.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Photo-Sets vorhanden."})]})]}):null,ki==="downloads"?m.jsx("div",{className:"min-h-0",children:m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),m.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Inkl. Dateien aus ",m.jsx("span",{className:"font-medium",children:"/done/keep/"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ri,{size:"sm",variant:"secondary",disabled:Y||ge<=1,onClick:()=>Ie($=>Math.max(1,$-1)),children:"Zurück"}),m.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Seite ",ge," / ",ut]}),m.jsx(ri,{size:"sm",variant:"secondary",disabled:Y||ge>=ut,onClick:()=>Ie($=>Math.min(ut,$+1)),children:"Weiter"})]})]}),m.jsx("div",{className:"mt-2",children:Y?m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Lade Downloads…"}):yt.length===0?m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine abgeschlossenen Downloads für dieses Model gefunden."}):m.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:yt.map($=>{const ie=gh($.output||""),Te=zR(ie),Be=kH(ie),ht=Zv($.durationSeconds),It=TH($.sizeBytes),Yt=CH($);return m.jsxs("div",{role:i?"button":void 0,tabIndex:i?0:void 0,className:Qi("group relative overflow-hidden rounded-lg outline-1 outline-black/5 dark:-outline-offset-1 dark:outline-white/10","bg-white dark:bg-gray-900/40","transition-all duration-200","hover:-translate-y-0.5 hover:shadow-lg dark:hover:shadow-none","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500",i?"cursor-pointer":""),onClick:()=>i?.($),onKeyDown:pi=>{i&&(pi.key==="Enter"||pi.key===" ")&&i($)},children:[m.jsxs("div",{className:"relative aspect-video bg-black/5 dark:bg-white/5",children:[m.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-500/10 via-transparent to-sky-500/10"}),m.jsx("div",{className:Qi("absolute inset-0",ah(a))}),m.jsx("div",{className:"absolute inset-x-3 top-3 z-10 flex justify-end",onClick:pi=>pi.stopPropagation(),onMouseDown:pi=>pi.stopPropagation(),children:m.jsx(ga,{job:$,variant:"overlay",collapseToMenu:!0,isHot:Te,isFavorite:!!_e?.favorite,isLiked:_e?.liked===!0,isWatching:!!_e?.watching,onToggleHot:Et,onDelete:Dt,order:["hot","delete"],className:"w-full justify-end gap-2"})}),m.jsx("div",{className:"absolute inset-0 grid place-items-center",children:m.jsxs("div",{className:"rounded-lg bg-black/10 px-4 py-3 text-gray-700 dark:bg-white/10 dark:text-gray-200",children:[m.jsx(lM,{className:"mx-auto size-8 opacity-80"}),m.jsx("div",{className:"mt-1 text-sm font-medium opacity-80",children:"Preview"})]})})]}),m.jsxs("div",{className:"border-t border-gray-200/60 bg-white px-5 py-4 dark:border-white/10 dark:bg-gray-900",children:[m.jsx("div",{className:"flex items-center justify-between gap-2",children:m.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[Te?m.jsx("span",{className:"shrink-0 rounded-md bg-amber-500/15 px-2 py-0.5 text-xs font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null,m.jsx("div",{className:"min-w-0 truncate text-base font-semibold text-gray-900 dark:text-white",children:Be})]})}),m.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-gray-600 dark:text-gray-300",children:[m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(Em,{className:"size-5 text-gray-400"}),Yt]}),m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(J_,{className:"size-5 text-gray-400"}),ht]}),m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx(i2,{className:"size-5 text-gray-400"}),It]})]})]})]},`${$.id}-${ie}`)})})})]})}):null,ki==="running"?m.jsx("div",{className:"min-h-0",children:m.jsxs("div",{className:"rounded-lg border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Laufende Jobs"}),J?m.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Lade…"}):null]}),m.jsx("div",{className:"mt-2",children:J?m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Lade…"}):pt.length===0?m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine laufenden Jobs."}):m.jsx("div",{className:"grid gap-2",children:pt.map($=>m.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200/70 bg-white/60 px-3 py-2 text-sm dark:border-white/10 dark:bg-white/5",children:m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"break-words line-clamp-2 font-medium text-gray-900 dark:text-white",children:gh($.output||"")}),m.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:["Start:"," ",m.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:rh($.startedAt)})]})]}),i?m.jsx(ri,{size:"sm",variant:"secondary",className:"shrink-0",onClick:()=>i($),children:"Öffnen"}):null]})},$.id))})})]})}):null]}),m.jsx(lb,{open:!!te,onClose:()=>oe(null),title:te?.alt||"Bild",width:"max-w-4xl",layout:"single",scroll:"body",footer:m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[te?.src?m.jsxs("a",{href:te.src,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-lg border border-gray-200/70 bg-white/70 px-3 py-1.5 text-xs font-medium text-gray-900 shadow-sm backdrop-blur hover:bg-white dark:border-white/10 dark:bg-white/5 dark:text-white",children:[m.jsx(_m,{className:"size-4"}),"In neuem Tab"]}):null,m.jsx(ri,{variant:"secondary",onClick:()=>oe(null),children:"Schließen"})]}),children:m.jsx("div",{className:"grid place-items-center",children:te?.src?m.jsx("img",{src:te.src,alt:te.alt||"",className:Qi("max-h-[80vh] w-auto max-w-full rounded-lg object-contain",ah(a))}):null})})]})}const Xm=s=>Math.max(0,Math.min(1,s));function Qm(s){return s==="good"?"bg-emerald-500":s==="warn"?"bg-amber-500":"bg-red-500"}function IH(s){return s==null?"":`${Math.round(s)}ms`}function AA(s){return s==null?"":`${Math.round(s)}%`}function Jv(s){if(s==null||!Number.isFinite(s)||s<=0)return"";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0?0:t>=10?1:2;return`${t.toFixed(n)} ${e[i]}`}function NH(s=1e3){const[e,t]=ii.useState(null);return ii.useEffect(()=>{let i=0,n=performance.now(),r=0,a=!0,u=!1;const c=y=>{if(!a||!u)return;r+=1;const v=y-n;if(v>=s){const T=Math.round(r*1e3/v);t(T),r=0,n=y}i=requestAnimationFrame(c)},d=()=>{a&&(document.hidden||u||(u=!0,n=performance.now(),r=0,i=requestAnimationFrame(c)))},f=()=>{u=!1,cancelAnimationFrame(i)},g=()=>{document.hidden?f():d()};return d(),document.addEventListener("visibilitychange",g),()=>{a=!1,document.removeEventListener("visibilitychange",g),f()}},[s]),e}function kA({mode:s="inline",className:e,pollMs:t=3e3}){const i=NH(1e3),[n,r]=ii.useState(null),[a,u]=ii.useState(null),[c,d]=ii.useState(null),[f,g]=ii.useState(null),[y,v]=ii.useState(null),T=5*1024*1024*1024,S=8*1024*1024*1024,w=ii.useRef(!1);ii.useEffect(()=>{const X=`/api/perf/stream?ms=${encodeURIComponent(String(t))}`,re=up(X,"perf",J=>{const W=typeof J?.cpuPercent=="number"?J.cpuPercent:null,q=typeof J?.diskFreeBytes=="number"?J.diskFreeBytes:null,Z=typeof J?.diskTotalBytes=="number"?J.diskTotalBytes:null,te=typeof J?.diskUsedPercent=="number"?J.diskUsedPercent:null;u(W),d(q),g(Z),v(te);const oe=typeof J?.serverMs=="number"?J.serverMs:null;r(oe!=null?Math.max(0,Date.now()-oe):null)});return()=>re()},[t]);const L=n==null?"bad":n<=120?"good":n<=300?"warn":"bad",O=i==null?"bad":i>=55?"good":i>=30?"warn":"bad",I=a==null?"bad":a<=60?"good":a<=85?"warn":"bad",j=Xm((n??999)/500),P=Xm((i??0)/60),G=Xm((a??0)/100),N=c!=null&&f!=null&&f>0?c/f:null,K=y??(N!=null?(1-N)*100:null),k=Xm((K??0)/100);c==null?w.current=!1:w.current?c>=S&&(w.current=!1):c<=T&&(w.current=!0);const R=c==null||w.current||N==null?"bad":N>=.15?"good":N>=.07?"warn":"bad",Y=c==null?"Disk: ":`Free: ${Jv(c)} / Total: ${Jv(f)} · Used: ${AA(K)}`,z=s==="floating"?"fixed bottom-4 right-4 z-[80]":"flex items-center";return m.jsx("div",{className:`${z} ${e??""}`,children:m.jsxs("div",{className:`\r
rounded-lg border border-gray-200/70 bg-white/70 px-2.5 py-1.5 shadow-sm backdrop-blur\r
dark:border-white/10 dark:bg-white/5\r
grid grid-cols-2 gap-x-3 gap-y-2\r
sm:flex sm:items-center sm:gap-3\r
`,children:[m.jsxs("div",{className:"flex items-center gap-2",title:Y,children:[m.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"Disk"}),m.jsx("div",{className:"hidden sm:block h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:m.jsx("div",{className:`h-full ${Qm(R)}`,style:{width:`${Math.round(k*100)}%`}})}),m.jsx("span",{className:"text-[11px] w-11 tabular-nums text-gray-900 dark:text-gray-100",children:Jv(c)})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"Ping"}),m.jsx("div",{className:"hidden sm:block h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:m.jsx("div",{className:`h-full ${Qm(L)}`,style:{width:`${Math.round(j*100)}%`}})}),m.jsx("span",{className:"text-[11px] w-10 tabular-nums text-gray-900 dark:text-gray-100",children:IH(n)})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"FPS"}),m.jsx("div",{className:"hidden sm:block h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:m.jsx("div",{className:`h-full ${Qm(O)}`,style:{width:`${Math.round(P*100)}%`}})}),m.jsx("span",{className:"text-[11px] w-8 tabular-nums text-gray-900 dark:text-gray-100",children:i??""})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"CPU"}),m.jsx("div",{className:"hidden sm:block h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:m.jsx("div",{className:`h-full ${Qm(I)}`,style:{width:`${Math.round(G*100)}%`}})}),m.jsx("span",{className:"text-[11px] w-10 tabular-nums text-gray-900 dark:text-gray-100",children:AA(a)})]})]})})}function OH(s,e){const t=[];for(let i=0;i<s.length;i+=e)t.push(s.slice(i,i+e));return t}function MH(s){const e=new Set,t=[];for(const i of s){const n=String(i?.username??"").trim().toLowerCase();!n||e.has(n)||(e.add(n),t.push(i))}return t}function CA(s){const e=s.intervalMs??5e3;let t=null,i=null,n="",r=null,a=!1;const u=()=>{t!=null&&(window.clearTimeout(t),t=null)},c=()=>{if(i){try{i.abort()}catch{}i=null}},d=g=>{a||(u(),t=window.setTimeout(()=>{f()},g))},f=async()=>{if(!a)try{const g=(s.getModels?.()??[]).map(Y=>String(Y||"").trim()).filter(Boolean),v=(s.getShow?.()??[]).map(Y=>String(Y||"").trim()).filter(Boolean).slice().sort(),T=g.slice().sort(),S=T.length===0&&!!s.fetchAllWhenNoModels;if(T.length===0&&!S){c();const Y={enabled:r?.enabled??!1,rooms:[]};r=Y,s.onData(Y);const z=document.hidden?Math.max(15e3,e):e;d(z);return}const w=S?[]:T,L=`${v.join(",")}|${S?"__ALL__":w.join(",")}`,O=L;n=L,c();const I=new AbortController;i=I;const P=S?[[]]:OH(w,350);let G=[],N=!1,K=0,k=!1;for(const Y of P){if(I.signal.aborted||O!==n||a)return;const z=await fetch("/api/chaturbate/online",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:Y,show:v,refresh:!1}),signal:I.signal,cache:"no-store"});if(!z.ok)continue;k=!0;const X=await z.json();N=N||!!X?.enabled,G.push(...Array.isArray(X?.rooms)?X.rooms:[]);const re=Number(X?.total??0);Number.isFinite(re)&&re>K&&(K=re)}if(!k){const Y=document.hidden?Math.max(15e3,e):e;d(Y);return}const R={enabled:N,rooms:MH(G),total:K};if(I.signal.aborted||O!==n||a)return;r=R,s.onData(R)}catch(g){if(g?.name==="AbortError")return;s.onError?.(g)}finally{const g=document.hidden?Math.max(15e3,e):e;d(g)}};return f(),()=>{a=!0,u(),c()}}async function ex(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}function PH(s,e,t,i){const n=`/api/generated/cover?category=${encodeURIComponent(s)}`,r=e?`&v=${e}`:"",a="",u=i&&i.trim()?`&model=${encodeURIComponent(i.trim())}`:"";return`${n}${r}${a}${u}`}function DA(s){if(!s)return[];const e=s.split(/[\n,;|]+/g).map(t=>t.trim()).filter(Boolean);return Array.from(new Set(e))}function VR(s){return String(s||"").replaceAll("\\","/").split("/").pop()||""}function GR(s){return s.toUpperCase().startsWith("HOT ")?s.slice(4).trim():s}function BH(s){const e=GR(VR(s||""));return e?e.replace(/\.[^.]+$/,""):""}const FH=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function tx(s){const t=GR(VR(s)).replace(/\.[^.]+$/,""),i=t.match(FH);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n).trim():t?t.trim():null}function UH(s){const e=BH(s);return e?`/generated/meta/${encodeURIComponent(e)}/thumbs.webp`:null}async function jH(s,e,t,i){const n=(t||"").trim(),r=`/api/generated/cover?category=${encodeURIComponent(s)}&src=${encodeURIComponent(e)}`+(n?`&model=${encodeURIComponent(n)}`:"")+"&refresh=1",a=await fetch(r,{method:"GET",cache:"no-store"});if(!a.ok){const u=await a.text().catch(()=>"");throw new Error(u||`ensureCover failed: HTTP ${a.status}`)}}function $H(){const[s,e]=b.useState([]),[t,i]=b.useState(!1),[n,r]=b.useState(null),[a,u]=b.useState(()=>Date.now()),[c,d]=b.useState({}),[f,g]=b.useState({}),[y,v]=b.useState(!1),[T,S]=b.useState(null),[w,L]=b.useState({}),O=b.useRef(null),I=b.useRef({}),j=b.useCallback((k,R)=>{const Y={};for(const X of Array.isArray(k)?k:[]){const re=String(X?.modelKey??"").trim().toLowerCase();if(!re)continue;const J=DA(X?.tags).map(W=>W.toLowerCase());J.length&&(Y[re]=J)}const z={};for(const X of Array.isArray(R)?R:[]){const re=String(X?.output??"");if(!re)continue;const J=(tx(re)||"").trim().toLowerCase();if(!J)continue;const W=Y[J];if(!(!W||W.length===0))for(const q of W)q&&(z[q]||(z[q]=[]),z[q].push(re))}for(const[X,re]of Object.entries(z))z[X]=Array.from(new Set(re));I.current=z},[]),P=b.useCallback(k=>{const R=String(k||"").trim();if(R){try{localStorage.setItem("finishedDownloads_pendingTags",JSON.stringify([R]))}catch{}window.dispatchEvent(new CustomEvent("app:navigate-tab",{detail:{tab:"finished"}})),window.dispatchEvent(new CustomEvent("finished-downloads:tag-filter",{detail:{tags:[R],mode:"replace"}}))}},[]),G=b.useCallback(k=>{const R=String(k||"").trim();if(R){try{localStorage.setItem("models_pendingTags",JSON.stringify([R]))}catch{}window.dispatchEvent(new CustomEvent("app:navigate-tab",{detail:{tab:"models"}})),window.dispatchEvent(new CustomEvent("models:set-tag-filter",{detail:{tags:[R]}}))}},[]),N=b.useCallback(async()=>{O.current?.abort();const k=new AbortController;O.current=k,i(!0),r(null);try{const[R,Y]=await Promise.all([ex("/api/models",{cache:"no-store",signal:k.signal}),ex("/api/record/done?page=1&pageSize=2000&sort=completed_desc",{cache:"no-store",signal:k.signal})]),z=Array.isArray(Y?.items)?Y.items:Array.isArray(Y)?Y:[];j(Array.isArray(R)?R:[],z);const X=new Map;for(const te of Array.isArray(R)?R:[])for(const oe of DA(te?.tags)){const F=oe.toLowerCase();X.set(F,(X.get(F)??0)+1)}const re=I.current||{},J=Array.from(X.entries()).map(([te,oe])=>({tag:te,modelsCount:oe,downloadsCount:(re[te]||[]).length})).sort((te,oe)=>te.tag.localeCompare(oe.tag,void 0,{sensitivity:"base"})),W=new Map;try{const te=await ex("/api/generated/coverinfo/list",{cache:"no-store",signal:k.signal});for(const oe of Array.isArray(te)?te:[]){const F=String(oe?.category??"").trim().toLowerCase();F&&W.set(F,oe)}}catch{}const q={};for(const te of J){const oe=W.get(te.tag);q[te.tag]=!!oe?.hasCover}g(q);const Z={};for(const te of J){const F=(re[te.tag]||[])[0]||"";let le=F?tx(F):null;if(!le){const ge=W.get(te.tag);ge?.hasCover&&ge.model?.trim()&&(le=ge.model.trim())}le&&(Z[te.tag]=le)}L(Z),d(te=>{const oe={};for(const F of J){const le=te[F.tag];le&&q[F.tag]===!0&&(oe[F.tag]=le)}return oe}),e(J)}catch(R){if(R?.name==="AbortError")return;r(R?.message??String(R)),e([]),I.current={},L({}),g({}),d({})}finally{O.current===k&&(O.current=null,i(!1))}},[j]);b.useEffect(()=>(N(),()=>{O.current?.abort()}),[N]);const K=b.useCallback(async()=>{if(!y){v(!0),r(null),S({done:0,total:s.length});try{const k=I.current||{},R=await Promise.all(s.map(async z=>{try{const X=k[z.tag]||[];if(X.length===0)return{tag:z.tag,ok:!0,status:0,text:"skipped (no candidates)"};const re=X[Math.floor(Math.random()*X.length)],J=UH(re);if(!J)return{tag:z.tag,ok:!0,status:0,text:"skipped (no thumb url)"};const W=tx(re);return await jH(z.tag,J,W,!0),g(q=>({...q,[z.tag]:!0})),L(q=>{const Z={...q};return W?.trim()?Z[z.tag]=W.trim():delete Z[z.tag],Z}),d(q=>{const Z={...q};return delete Z[z.tag],Z}),{tag:z.tag,ok:!0,status:200,text:""}}catch(X){return{tag:z.tag,ok:!1,status:0,text:X?.message??String(X)}}finally{S(X=>X&&{...X,done:Math.min(X.total,X.done+1)})}})),Y=R.filter(z=>!z.ok);if(Y.length){console.warn("Cover renew failed:",Y.slice(0,20));const z=Y.slice(0,8).map(X=>`${X.tag} (ERR)`).join(", ");r(`Covers fehlgeschlagen: ${Y.length}/${R.length} — z.B.: ${z}`)}else r(null)}finally{u(Date.now()),v(!1),setTimeout(()=>S(null),400)}}},[s,y]);return m.jsxs(pa,{header:m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Kategorien ",m.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",s.length,")"]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[T?m.jsxs("div",{className:"hidden sm:flex items-center gap-2 mr-2",children:[m.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300 tabular-nums",children:["Covers: ",T.done,"/",T.total]}),m.jsx("div",{className:"h-2 w-28 rounded-full bg-gray-200 dark:bg-white/10 overflow-hidden",children:m.jsx("div",{className:"h-full bg-indigo-500",style:{width:T.total>0?`${Math.round(T.done/T.total*100)}%`:"0%"}})})]}):null,m.jsx(ri,{variant:"secondary",size:"md",onClick:K,disabled:t||y,children:"Cover erneuern"}),m.jsx(ri,{variant:"secondary",size:"md",onClick:N,disabled:t||y,children:"Aktualisieren"})]})]}),grayBody:!0,children:[n?m.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:n}):null,s.length===0&&!t?m.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine Kategorien/Tags gefunden."}):null,m.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(k=>{const R=w[k.tag]??null,Y=f[k.tag]===!0,z=Object.prototype.hasOwnProperty.call(f,k.tag),X=Y?PH(k.tag,a,!1,R):"",re=c[k.tag]==="ok",J=c[k.tag]==="error";return m.jsxs("button",{type:"button",onClick:()=>P(k.tag),className:ni("group text-left rounded-2xl overflow-hidden transition","bg-white/70 dark:bg-white/[0.06]","border border-gray-200/70 dark:border-white/10","shadow-sm hover:shadow-md","hover:-translate-y-[1px]","hover:bg-white dark:hover:bg-white/[0.09]","focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500/70 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-950"),title:"In FinishedDownloads öffnen (Tag-Filter setzen)",children:[m.jsx("div",{className:"relative w-full overflow-hidden aspect-[16/9] bg-gray-100/70 dark:bg-white/5",children:z?Y?J?m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",children:[m.jsx("div",{className:"absolute inset-0 opacity-70",style:{background:"radial-gradient(circle at 30% 20%, rgba(99,102,241,0.25), transparent 55%),radial-gradient(circle at 70% 80%, rgba(14,165,233,0.18), transparent 55%)"}}),m.jsxs("div",{className:"relative z-10 rounded-xl bg-white/80 dark:bg-black/30 px-3 py-2.5 shadow-sm ring-1 ring-black/5 dark:ring-white/10 backdrop-blur-md",children:[m.jsx("div",{className:"text-xs font-semibold text-gray-900 dark:text-white",children:"Cover konnte nicht geladen werden"}),m.jsx("div",{className:"mt-1 flex justify-center",children:m.jsx("span",{className:`text-[11px] inline-flex items-center rounded-full bg-indigo-50 px-2 py-1 font-semibold text-indigo-700 ring-1 ring-indigo-100 hover:bg-indigo-100\r
dark:bg-indigo-500/10 dark:text-indigo-200 dark:ring-indigo-500/20 dark:hover:bg-indigo-500/20`,onClick:W=>{W.preventDefault(),W.stopPropagation(),d(q=>{const Z={...q};return delete Z[k.tag],Z}),u(Date.now())},children:"Retry"})})]})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{"aria-hidden":"true",className:"absolute inset-0 z-[1] pointer-events-none",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.10), rgba(255,255,255,0) 35%),linear-gradient(to top, rgba(0,0,0,0.35), rgba(0,0,0,0) 45%)"}}),m.jsx("img",{src:X,alt:"","aria-hidden":"true",className:"absolute inset-0 z-0 h-full w-full object-cover blur-xl scale-110 opacity-60",loading:"lazy"}),m.jsx("img",{src:X,alt:k.tag,className:"absolute inset-0 z-0 h-full w-full object-contain",loading:"lazy",onLoad:()=>d(W=>({...W,[k.tag]:"ok"})),onError:()=>{d(W=>({...W,[k.tag]:"error"})),g(W=>({...W,[k.tag]:!1}))}}),re&&R?m.jsx("div",{className:"absolute left-3 bottom-3 z-10 max-w-[calc(100%-24px)]",children:m.jsx("div",{className:ni("truncate rounded-full px-2.5 py-1 text-[11px] font-semibold","bg-black/40 text-white backdrop-blur-md","ring-1 ring-white/15"),children:R})}):null]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",children:[m.jsx("div",{className:"absolute inset-0 opacity-70",style:{background:"radial-gradient(circle at 30% 20%, rgba(99,102,241,0.25), transparent 55%),radial-gradient(circle at 70% 80%, rgba(14,165,233,0.18), transparent 55%)"}}),m.jsxs("div",{className:"relative z-10 rounded-xl bg-white/80 dark:bg-black/30 px-3 py-2.5 shadow-sm ring-1 ring-black/5 dark:ring-white/10 backdrop-blur-md",children:[m.jsx("div",{className:"text-xs font-semibold text-gray-900 dark:text-white",children:"Kein Cover vorhanden"}),R?m.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-700 dark:text-gray-300",children:["Model: ",m.jsx("span",{className:"font-semibold",children:R})]}):null,m.jsx("div",{className:"mt-1 text-[11px] text-gray-600 dark:text-gray-400 text-center",children:"(Kein Request / keine 404)"})]})]}):m.jsxs("div",{className:"absolute inset-0",children:[m.jsx("div",{className:"absolute inset-0 opacity-70",style:{background:"radial-gradient(circle at 30% 20%, rgba(99,102,241,0.20), transparent 55%),radial-gradient(circle at 70% 80%, rgba(14,165,233,0.14), transparent 55%)"}}),m.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 to-transparent"}),m.jsx("div",{className:"absolute left-3 bottom-3 text-[11px] font-semibold text-white/80 bg-black/30 px-2.5 py-1 rounded-full ring-1 ring-white/10",children:"Cover wird geprüft…"})]})}),m.jsx("div",{className:"px-4 py-3.5",children:m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"font-semibold text-gray-900 dark:text-white truncate tracking-tight",children:k.tag}),m.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[m.jsxs("span",{role:"button",tabIndex:0,className:ni("inline-flex max-w-full items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold","tabular-nums whitespace-nowrap","overflow-hidden","bg-indigo-50 text-indigo-700 ring-1 ring-indigo-100","dark:bg-indigo-500/10 dark:text-indigo-200 dark:ring-indigo-500/20","cursor-pointer"),title:"FinishedDownloads nach diesem Tag filtern",onClick:W=>{W.preventDefault(),W.stopPropagation(),P(k.tag)},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),W.stopPropagation(),P(k.tag))},children:[m.jsx("span",{className:"shrink-0",children:k.downloadsCount}),m.jsx("span",{className:"min-w-0 truncate font-medium",children:"Downloads"})]}),m.jsxs("span",{role:"button",tabIndex:0,className:ni("inline-flex max-w-full items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold","tabular-nums whitespace-nowrap overflow-hidden","bg-gray-50 text-gray-700 ring-1 ring-gray-200","dark:bg-white/5 dark:text-gray-200 dark:ring-white/10","cursor-pointer"),title:"Models nach diesem Tag filtern",onClick:W=>{W.preventDefault(),W.stopPropagation(),G(k.tag)},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),W.stopPropagation(),G(k.tag))},children:[m.jsx("span",{className:"shrink-0",children:k.modelsCount}),m.jsx("span",{className:"min-w-0 truncate font-medium",children:"Models"})]})]})]}),m.jsx("span",{"aria-hidden":"true",className:ni("shrink-0 mt-0.5 text-gray-400 dark:text-gray-500","transition-transform group-hover:translate-x-[1px]"),children:"→"})]})})]},k.tag)})})]})}async function oh(s,e){const t=await fetch(s,{credentials:"include",...e});if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}function HH(){try{const e=new URL(window.location.href).searchParams.get("next")||"/";return!e.startsWith("/")||e.startsWith("/login")?"/":e}catch{return"/"}}const D1="recorder_login_state_v1";function zH(){try{const s=sessionStorage.getItem(D1);if(!s)return null;const e=JSON.parse(s);return!e?.ts||Date.now()-e.ts>900*1e3?null:e}catch{return null}}function VH(s){try{sessionStorage.setItem(D1,JSON.stringify(s))}catch{}}function Zm(){try{sessionStorage.removeItem(D1)}catch{}}function GH(s){const t=(s??"").replace(/\D/g,"").slice(0,6).split("");for(;t.length<6;)t.push("");return t}function qH(s){return(s??[]).join("")}function KH({onLoggedIn:s}){const e=b.useMemo(()=>HH(),[]),[t,i]=b.useState(""),[n,r]=b.useState(""),[a,u]=b.useState(["","","","","",""]),c=b.useRef([]),[d,f]=b.useState(!1),[g,y]=b.useState(null),[v,T]=b.useState("login"),[S,w]=b.useState(null),[L,O]=b.useState(null),[I,j]=b.useState(null),P=b.useRef(!1),G=b.useMemo(()=>qH(a),[a]);function N(q){const Z=c.current[q];Z&&Z.focus()}function K(){u(["","","","","",""]),P.current=!1,window.setTimeout(()=>N(0),0)}function k(q,Z){const te=(Z??"").replace(/\D/g,"").slice(-1);u(oe=>{const F=[...oe];return F[q]=te,F})}function R(q,Z){const te=(Z??"").replace(/\D/g,"");if(!te){k(q,""),P.current=!1;return}if(te.length>1){u(oe=>{const F=[...oe];let le=q;for(const ge of te){if(le>5)break;F[le]=ge,le++}return F}),P.current=!1,window.setTimeout(()=>N(Math.min(5,q+te.length)),0);return}k(q,te),P.current=!1,q<5&&window.setTimeout(()=>N(q+1),0)}function Y(q,Z){if(Z.key==="Backspace"){if(a[q]){Z.preventDefault(),k(q,""),P.current=!1;return}q>0&&(Z.preventDefault(),N(q-1),k(q-1,""),P.current=!1);return}if(Z.key==="ArrowLeft"){Z.preventDefault(),q>0&&N(q-1);return}if(Z.key==="ArrowRight"){Z.preventDefault(),q<5&&N(q+1);return}}function z(q,Z){const oe=(Z.clipboardData.getData("text")||"").replace(/\D/g,"").slice(0,6);oe&&(Z.preventDefault(),u(F=>{const le=[...F];let ge=q;for(const Ie of oe){if(ge>5)break;le[ge]=Ie,ge++}return le}),P.current=!1,window.setTimeout(()=>N(Math.min(5,q+oe.length)),0))}b.useEffect(()=>{const q=zH();q&&(T(q.stage??"login"),i(q.username??""),u(GH(q.code??"")),w(q.setupAuthUrl??null),O(q.setupSecret??null),j(q.setupInfo??null))},[]),b.useEffect(()=>{VH({stage:v,username:t,code:G,setupAuthUrl:S,setupSecret:L,setupInfo:I,ts:Date.now()})},[v,t,G,S,L,I]),b.useEffect(()=>{P.current=!1,(v==="verify"||v==="setup")&&window.setTimeout(()=>N(0),0)},[v]),b.useEffect(()=>{let q=!1;return(async()=>{try{const te=await oh("/api/auth/me",{cache:"no-store"});if(q)return;if(te?.authenticated){te?.totpConfigured?(Zm(),window.location.assign(e||"/")):(T("setup"),J());return}if(te?.pending2fa){T("verify");return}T("login")}catch{}})(),()=>{q=!0}},[e]);const X=async()=>{f(!0),y(null);try{if((await oh("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:n})}))?.totpRequired){T("verify"),K();return}const Z=await oh("/api/auth/me",{cache:"no-store"});if(Z?.authenticated&&!Z?.totpConfigured){T("setup"),K(),await J();return}s&&await s(),Zm(),window.location.assign(e||"/")}catch(q){y(q?.message??String(q))}finally{f(!1)}},re=async()=>{const q=G.trim();if(/^\d{6}$/.test(q)){f(!0),y(null);try{await oh("/api/auth/2fa/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:q})}),s&&await s(),Zm(),window.location.assign(e||"/")}catch(Z){P.current=!1,y(Z?.message??String(Z))}finally{f(!1)}}},J=async()=>{y(null),j(null);try{const q=await oh("/api/auth/2fa/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Z=(q?.otpauth??"").trim();if(!Z)throw new Error("2FA Setup fehlgeschlagen (keine otpauth URL).");w(Z),O((q?.secret??"").trim()||null),j("Scan den QR-Code in deiner Authenticator-App und bestätige danach mit dem 6-stelligen Code.")}catch(q){y(q?.message??String(q))}};b.useEffect(()=>{d||v!=="verify"&&v!=="setup"||/^\d{6}$/.test(G)&&(P.current||(P.current=!0,re()))},[G,v,d]);const W=m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"2FA Code"}),m.jsx("div",{className:"flex items-center justify-between gap-2",children:a.map((q,Z)=>m.jsx("input",{ref:te=>{c.current[Z]=te},value:q,onChange:te=>R(Z,te.target.value),onKeyDown:te=>Y(Z,te),onPaste:te=>z(Z,te),inputMode:"numeric",pattern:"[0-9]*",maxLength:1,autoComplete:Z===0?"one-time-code":"off",enterKeyHint:Z===5?"done":"next",autoCapitalize:"none",autoCorrect:"off",disabled:d,className:`h-12 w-12 rounded-lg text-center text-lg tabular-nums bg-white text-gray-900 shadow-sm ring-1 ring-gray-200\r
focus:outline-none focus:ring-2 focus:ring-indigo-500\r
dark:bg-white/10 dark:text-white dark:ring-white/10`,"aria-label":`2FA Ziffer ${Z+1}`},Z))})]});return m.jsxs("div",{className:"min-h-[100dvh] bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100",children:[m.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 overflow-hidden",children:[m.jsx("div",{className:"absolute -top-28 left-1/2 h-80 w-[52rem] -translate-x-1/2 rounded-full bg-indigo-500/10 blur-3xl dark:bg-indigo-400/10"}),m.jsx("div",{className:"absolute -bottom-28 right-[-6rem] h-80 w-[46rem] rounded-full bg-sky-500/10 blur-3xl dark:bg-sky-400/10"})]}),m.jsx("div",{className:"relative grid min-h-[100dvh] place-items-center px-4",children:m.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-gray-200/70 bg-white/80 p-6 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Recorder Login"}),m.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Bitte melde dich an, um fortzufahren."})]}),m.jsxs("div",{className:"mt-5 space-y-3",children:[v==="login"?m.jsxs("form",{onSubmit:q=>{q.preventDefault(),!d&&X()},className:"space-y-3",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"Username"}),m.jsx("input",{value:t,onChange:q=>i(q.target.value),autoComplete:"username",className:"block w-full rounded-lg px-3 py-2.5 text-sm bg-white text-gray-900 shadow-sm ring-1 ring-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:bg-white/10 dark:text-white dark:ring-white/10",placeholder:"admin",disabled:d})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"Passwort"}),m.jsx("input",{type:"password",value:n,onChange:q=>r(q.target.value),autoComplete:"current-password",className:"block w-full rounded-lg px-3 py-2.5 text-sm bg-white text-gray-900 shadow-sm ring-1 ring-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:bg-white/10 dark:text-white dark:ring-white/10",placeholder:"••••••••••",disabled:d})]}),m.jsx(ri,{type:"submit",variant:"primary",className:"w-full rounded-lg",disabled:d||!t.trim()||!n,children:d?"Login…":"Login"})]}):v==="verify"?m.jsxs("form",{onSubmit:q=>{q.preventDefault(),!d&&re()},className:"space-y-3",children:[m.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:"2FA ist aktiv bitte gib den Code aus deiner Authenticator-App ein."}),W,m.jsxs("div",{className:"flex gap-2",children:[m.jsx(ri,{type:"button",variant:"secondary",className:"flex-1 rounded-lg",disabled:d,onClick:()=>{T("login"),K()},children:"Zurück"}),m.jsx(ri,{type:"submit",variant:"primary",className:"flex-1 rounded-lg",disabled:d||!/^\d{6}$/.test(G),children:d?"Prüfe…":"Bestätigen"})]})]}):m.jsxs("form",{onSubmit:q=>{q.preventDefault(),!d&&re()},className:"space-y-3",children:[m.jsx("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50 px-3 py-2 text-sm text-indigo-900 dark:border-indigo-500/30 dark:bg-indigo-500/10 dark:text-indigo-200",children:"2FA ist noch nicht eingerichtet bitte richte es jetzt ein (empfohlen)."}),m.jsxs("div",{className:"space-y-2 text-sm text-gray-700 dark:text-gray-200",children:[m.jsx("div",{children:"1) Öffne deine Authenticator-App und füge einen neuen Account hinzu."}),m.jsx("div",{children:"2) Scanne den QR-Code oder verwende den Secret-Key."})]}),m.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white/70 p-3 dark:border-white/10 dark:bg-white/5",children:[m.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"QR / Setup"}),S?m.jsx("div",{className:"mt-2 flex items-center justify-center",children:m.jsx("img",{alt:"2FA QR Code",className:"h-44 w-44 rounded bg-white p-2",src:`https://api.qrserver.com/v1/create-qr-code/?size=220x220&data=${encodeURIComponent(S)}`})}):m.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-300",children:"QR wird geladen…"}),L?m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Secret (manuell):"}),m.jsx("div",{className:"mt-1 select-all break-all rounded bg-gray-100 px-2 py-1 text-xs font-mono text-gray-900 dark:bg-white/10 dark:text-gray-100",children:L})]}):null,I?m.jsx("div",{className:"mt-3 text-xs text-gray-600 dark:text-gray-300",children:I}):null,m.jsx("div",{className:"mt-3",children:m.jsx(ri,{type:"button",variant:"secondary",className:"w-full rounded-lg",disabled:d,onClick:()=>{J()},title:"Setup-Infos neu laden",children:S?"QR/Setup erneut laden":"QR/Setup laden"})})]}),W,m.jsxs("div",{className:"flex gap-2",children:[m.jsx(ri,{type:"button",variant:"secondary",className:"flex-1 rounded-lg",disabled:d,onClick:()=>{s&&s(),Zm(),window.location.assign(e||"/")},title:"Ohne 2FA fortfahren (nicht empfohlen)",children:"Später"}),m.jsx(ri,{type:"submit",variant:"primary",className:"flex-1 rounded-lg",disabled:d||!/^\d{6}$/.test(G),children:d?"Aktiviere…":"2FA aktivieren"})]})]}),g?m.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",children:m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsx("div",{className:"min-w-0 break-words",children:g}),m.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-red-700 hover:bg-red-100 dark:text-red-200 dark:hover:bg-white/10",onClick:()=>y(null),"aria-label":"Fehlermeldung schließen",title:"Schließen",children:"✕"})]})}):null]})]})})]})}const ix="record_cookies";function Jm(s){return Object.fromEntries(Object.entries(s??{}).map(([t,i])=>[t.trim().toLowerCase(),String(i??"").trim()]).filter(([t,i])=>t.length>0&&i.length>0))}async function Cn(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}const LA={recordDir:"records",doneDir:"records/done",ffmpegPath:"",autoAddToDownloadList:!1,autoStartAddedDownloads:!1,useChaturbateApi:!1,useMyFreeCamsWatcher:!1,autoDeleteSmallDownloads:!1,autoDeleteSmallDownloadsBelowMB:200,blurPreviews:!1,teaserPlayback:"hover",teaserAudio:!1,lowDiskPauseBelowGB:3e3};function So(s){let e=(s??"").trim();if(!e)return null;e=e.replace(/^[("'[{<]+/,"").replace(/[)"'\]}>.,;:]+$/,""),/^https?:\/\//i.test(e)||(e=`https://${e}`);try{const t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function ru(s){const e=(s??"").trim();if(!e)return null;for(const t of e.split(/\s+/g)){const i=So(t);if(i)return i}return null}function Ih(s){try{const e=new URL(s).hostname.replace(/^www\./i,"").toLowerCase();return e==="chaturbate.com"||e.endsWith(".chaturbate.com")?"chaturbate":e==="myfreecams.com"||e.endsWith(".myfreecams.com")?"mfc":null}catch{return null}}function qR(s){try{const e=new URL(s),t=e.hostname.replace(/^www\./i,"").toLowerCase();if(t!=="chaturbate.com"&&!t.endsWith(".chaturbate.com"))return"";const i=e.pathname.split("/").filter(Boolean);return i[0]?decodeURIComponent(i[0]).trim():""}catch{return""}}function vl(s){const e=Ih(s);if(!e)return s;if(e==="chaturbate"){const i=qR(s);return i?`https://chaturbate.com/${encodeURIComponent(i)}/`:s}const t=KR(s);return t?`https://www.myfreecams.com/#${encodeURIComponent(t)}`:s}function WH(s){const e=Ih(s);return e?((e==="chaturbate"?qR(s):KR(s))||"").trim().toLowerCase():""}function KR(s){try{const e=new URL(s),t=e.hostname.replace(/^www\./i,"").toLowerCase();if(t!=="myfreecams.com"&&!t.endsWith(".myfreecams.com"))return"";const i=(e.hash||"").replace(/^#\/?/,"");if(i){const a=i.split("/").filter(Boolean),u=a[a.length-1]||"";if(u)return decodeURIComponent(u).trim()}const n=e.pathname.split("/").filter(Boolean),r=n[n.length-1]||"";return r?decodeURIComponent(r).trim():""}catch{return""}}const Os=s=>(s||"").replaceAll("\\","/").split("/").pop()||"";function YH(s,e){const i=(s||"").replaceAll("\\","/").split("/");return i[i.length-1]=e,i.join("/")}function XH(s){return s.startsWith("HOT ")?s.slice(4):s}const QH=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function lh(s){const t=XH(Os(s)).replace(/\.[^.]+$/,""),i=t.match(QH);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t||null}function ZH(){const[s,e]=b.useState(!1),[t,i]=b.useState(!1),n=b.useCallback(async()=>{try{const ue=await Cn("/api/auth/me",{cache:"no-store"});i(!!ue?.authenticated)}catch{i(!1)}finally{e(!0)}},[]),r=b.useCallback(async()=>{try{await fetch("/api/auth/logout",{method:"POST",cache:"no-store"})}catch{}finally{i(!1),e(!0),De(null),at(!1),Et("running"),yi(null),Jt(!1),St(null),q([]),te([]),ge(0),F(1),Fe({}),Le(0),Di({}),$s.current={},di.current={},qt.current=!1,oi([]),Bi({}),Je(0),J("")}},[]);b.useEffect(()=>{n()},[n]);const a=pk(),u=b.useRef(a),c=b.useRef(0),d=ue=>{const pe=(ue||"").toLowerCase();return pe.includes("altersverifikationsseite erhalten")||pe.includes("verify your age")||pe.includes("schutzseite von cloudflare erhalten")||pe.includes("just a moment")||pe.includes("kein room-html")},f=ue=>{const pe=!!ue?.silent,xe="Cookies fehlen oder sind abgelaufen",Oe="Der Recorder hat statt des Room-HTML eine Schutz-/Altersverifikationsseite erhalten. Bitte Cookies aktualisieren (bei Chaturbate z.B. cf_clearance + sessionId) und erneut starten.";if(!pe){De(`⚠️ ${xe}. ${Oe}`),wt(!0);return}const Q=Date.now();Q-c.current>15e3&&(c.current=Q,u.current?.error(xe,Oe))};b.useEffect(()=>{u.current=a},[a]);const[g,y]=b.useState(!1);b.useEffect(()=>{const ue=window,pe=typeof ue.requestIdleCallback=="function"?ue.requestIdleCallback(()=>y(!0),{timeout:1500}):window.setTimeout(()=>y(!0),800);return()=>{typeof ue.cancelIdleCallback=="function"?ue.cancelIdleCallback(pe):window.clearTimeout(pe)}},[]);const v=8,T="finishedDownloads_sort",[S,w]=b.useState(()=>{try{return window.localStorage.getItem(T)||"completed_desc"}catch{return"completed_desc"}}),L=b.useRef(null),O=b.useRef(!1),I=(ue,pe)=>`${pe}::${ue}`,j=b.useCallback(async ue=>{if(ue<1||O.current)return;const pe=I(ue,S),xe=L.current;if(!(xe?.key===pe&&Date.now()-xe.ts<15e3)){O.current=!0;try{const Oe=await fetch(`/api/record/done?page=${ue}&pageSize=${v}&sort=${encodeURIComponent(S)}`,{cache:"no-store"});if(!Oe.ok)return;const Q=await Oe.json().catch(()=>null),ne=Array.isArray(Q?.items)?Q.items:Array.isArray(Q)?Q:[];L.current={key:pe,items:ne,ts:Date.now()}}finally{O.current=!1}}},[S]),P=b.useCallback(async()=>{const ue=Date.now();if(!G.current&&!(ue-N.current<500)){G.current=!0,N.current=ue;try{const pe=await fetch("/api/record/done/meta",{cache:"no-store"});if(!pe.ok)return;const xe=await pe.json().catch(()=>null),Oe=Number(xe?.count??0),Q=Number.isFinite(Oe)&&Oe>=0?Oe:0;ge(Q),Re(Date.now())}catch{}finally{G.current=!1}}},[]),G=b.useRef(!1),N=b.useRef(0),K=b.useRef(null),k=b.useRef(0),R=b.useCallback((ue="unknown")=>{const pe=Date.now(),xe=700;if(Fi.current!=="finished"||K.current!=null)return;const Oe=pe-k.current;if(Oe<xe){K.current=window.setTimeout(()=>{K.current=null,k.current=Date.now(),window.dispatchEvent(new CustomEvent("finished-downloads:reload",{detail:{source:"App.requestFinishedReload(cooldown-tail)",reason:ue}}))},xe-Oe);return}K.current=window.setTimeout(()=>{K.current=null,k.current=Date.now(),window.dispatchEvent(new CustomEvent("finished-downloads:reload",{detail:{source:"App.requestFinishedReload",reason:ue}}))},150)},[]);b.useEffect(()=>()=>{K.current!=null&&(window.clearTimeout(K.current),K.current=null)},[]);const Y=b.useCallback(async()=>{try{const ue=await fetch("/api/record/list",{cache:"no-store"});if(!ue.ok)return;const pe=await ue.json().catch(()=>null),xe=Array.isArray(pe)?pe:Array.isArray(pe?.items)?pe.items:[];q(xe),ai.current=xe,Re(Date.now())}catch{}},[]);b.useEffect(()=>{try{window.localStorage.setItem(T,S)}catch{}},[S]),b.useEffect(()=>{t&&P()},[t,P]);const[z,X]=b.useState(null),[re,J]=b.useState(""),[W,q]=b.useState([]),[Z,te]=b.useState([]),[oe,F]=b.useState(1),[le,ge]=b.useState(0),[Ie,Le]=b.useState(0),[Pe,Je]=b.useState(0),[Se,Re]=b.useState(()=>Date.now()),[Ve,Ee]=b.useState(()=>Date.now());b.useEffect(()=>{const ue=window.setInterval(()=>Ee(Date.now()),1e3);return()=>window.clearInterval(ue)},[]);const _e=ue=>(ue||"").toLowerCase().trim(),yt=ue=>{const pe=Math.max(0,Math.floor(ue/1e3));if(pe<2)return"gerade eben";if(pe<60)return`vor ${pe} Sekunden`;const xe=Math.floor(pe/60);if(xe===1)return"vor 1 Minute";if(xe<60)return`vor ${xe} Minuten`;const Oe=Math.floor(xe/60);return Oe===1?"vor 1 Stunde":`vor ${Oe} Stunden`},ut=b.useMemo(()=>{const ue=Ve-Se;return`(zuletzt aktualisiert: ${yt(ue)})`},[Ve,Se]),[pt,Fe]=b.useState({}),_t=b.useCallback(ue=>{const pe={};for(const xe of Array.isArray(ue)?ue:[]){const Oe=(xe?.modelKey||"").trim().toLowerCase();if(!Oe)continue;const Q=ce=>(ce.favorite?4:0)+(ce.liked===!0?2:0)+(ce.watching?1:0),ne=pe[Oe];(!ne||Q(xe)>=Q(ne))&&(pe[Oe]=xe)}return pe},[]),Qe=b.useCallback(async()=>{try{const ue=await Cn("/api/models",{cache:"no-store"});Fe(_t(Array.isArray(ue)?ue:[])),Re(Date.now())}catch{}},[_t]),[Xe,ze]=b.useState(null),Ze=b.useRef(null),[ct,St]=b.useState(null);b.useEffect(()=>{const ue=pe=>{const Oe=(pe.detail?.modelKey??"").trim();if(!Oe)return;if(!Oe.includes(" ")&&!Oe.includes("/")&&!Oe.includes("\\")){const Ne=Oe.replace(/^@/,"").trim().toLowerCase();Ne&&St(Ne);return}const ne=So(Oe);if(!ne){let Ne=Oe.replace(/^https?:\/\//i,"");Ne.includes("/")&&(Ne=Ne.split("/").filter(Boolean).pop()||Ne),Ne.includes(":")&&(Ne=Ne.split(":").pop()||Ne),Ne=Ne.trim().toLowerCase(),Ne&&St(Ne);return}const ce=vl(ne),fe=WH(ce);fe&&St(fe)};return window.addEventListener("open-model-details",ue),()=>window.removeEventListener("open-model-details",ue)},[]);const se=b.useCallback(ue=>{const pe=Date.now(),xe=Ze.current;if(!xe){Ze.current={ts:pe,list:[ue]};return}xe.ts=pe;const Oe=xe.list.findIndex(Q=>Q.id===ue.id);Oe>=0?xe.list[Oe]=ue:xe.list.unshift(ue)},[]);b.useEffect(()=>{Qe();const ue=pe=>{const Oe=pe?.detail??{},Q=Oe?.model;if(Q&&typeof Q=="object"){const ne=String(Q.modelKey??"").toLowerCase().trim();ne&&Fe(ce=>({...ce,[ne]:Q}));try{se(Q)}catch{}ze(ce=>ce?.id===Q.id?Q:ce),Re(Date.now());return}if(Oe?.removed){const ne=String(Oe?.id??"").trim(),ce=String(Oe?.modelKey??"").toLowerCase().trim();ce&&Fe(fe=>{const{[ce]:Ne,...We}=fe;return We}),ne&&ze(fe=>fe?.id===ne?null:fe),Re(Date.now());return}Qe()};return window.addEventListener("models-changed",ue),()=>window.removeEventListener("models-changed",ue)},[Qe,se]);const[ke,De]=b.useState(null),[Ue,at]=b.useState(!1),[dt,wt]=b.useState(!1),[kt,Tt]=b.useState({}),[Ft,Qt]=b.useState(!1),[Zt,Et]=b.useState("running"),[Dt,yi]=b.useState(null),[Pi,Jt]=b.useState(!1),[ki,gt]=b.useState(null),[V,$]=b.useState(0),ie=b.useCallback(()=>$(ue=>ue+1),[]),[Te,Be]=b.useState(LA),ht=b.useRef(Te);b.useEffect(()=>{ht.current=Te},[Te]);const It=!!Te.autoAddToDownloadList,Yt=!!Te.autoStartAddedDownloads,[pi,oi]=b.useState([]),[ci,Bi]=b.useState({}),Gt=b.useRef(!1),xi=b.useRef({}),ai=b.useRef([]),di=b.useRef({}),qt=b.useRef(!1);b.useEffect(()=>{Gt.current=Ue},[Ue]),b.useEffect(()=>{xi.current=kt},[kt]),b.useEffect(()=>{ai.current=W},[W]);const Mt=b.useRef(null),vt=b.useRef(""),Ci=4,ss=b.useRef([]),vs=b.useRef(0),xs=b.useRef(new Set),Gi=b.useRef(!1),fi=b.useCallback(()=>{const ue=vs.current>0;at(ue),Gt.current=ue},[]),Zi=b.useCallback(ue=>{const pe=So(ue.url);if(!pe)return!1;const xe=vl(pe);return xs.current.has(xe)||(xs.current.add(xe),ss.current.push({...ue,url:xe}),Gi.current||(Gi.current=!0,queueMicrotask(()=>{Gi.current=!1,$i()}))),!0},[]);async function ts(ue,pe){if(ue=vl(ue),ai.current.some(Oe=>{if(String(Oe.status||"").toLowerCase()!=="running"||Oe.endedAt)return!1;const Q=So(String(Oe.sourceUrl||""));return(Q?vl(Q):"")===ue}))return!0;try{const Oe=xi.current,Q=Ih(ue);if(!Q)return pe||De("Nur chaturbate.com oder myfreecams.com werden unterstützt."),!1;if(Q==="chaturbate"&&!Wi(Oe))return pe||De('Für Chaturbate müssen die Cookies "cf_clearance" und "sessionId" gesetzt sein.'),!1;const ne=Object.entries(Oe).map(([fe,Ne])=>`${fe}=${Ne}`).join("; "),ce=await Cn("/api/record",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:ue,cookie:ne})});return ce?.id&&(di.current[String(ce.id)]=!0),q(fe=>[ce,...fe]),ai.current=[ce,...ai.current],!0}catch(Oe){const Q=Oe?.message??String(Oe);return d(Q)?(f({silent:pe}),!1):(pe||De(Q),!1)}}async function $i(){for(;vs.current<Ci&&ss.current.length>0;){const ue=ss.current.shift();vs.current++,fi(),(async()=>{try{if(await ts(ue.url,ue.silent)&&ue.pendingKeyLower){const xe=ue.pendingKeyLower;Bi(Oe=>{const Q={...Oe||{}};return delete Q[xe],Kt.current=Q,Q})}}finally{xs.current.delete(ue.url),vs.current=Math.max(0,vs.current-1),fi(),ss.current.length>0&&$i()}})()}}const[Ji,Di]=b.useState({}),$s=b.useRef({}),Cs=b.useRef({}),ns=b.useRef({}),rs=b.useRef(!1),Rs=b.useRef({});b.useEffect(()=>{$s.current=Ji},[Ji]);const Li=b.useCallback(ue=>{const pe=String(ue?.host??"").toLowerCase(),xe=String(ue?.input??"").toLowerCase();return pe.includes("chaturbate")||xe.includes("chaturbate.com")},[]),qi=b.useMemo(()=>{const ue=new Set;for(const pe of Object.values(pt)){if(!Li(pe))continue;const xe=_e(String(pe?.modelKey??""));xe&&ue.add(xe)}return Array.from(ue)},[pt,Li]),bs=b.useRef(pt);b.useEffect(()=>{bs.current=pt},[pt]);const Kt=b.useRef(ci);b.useEffect(()=>{Kt.current=ci},[ci]);const ds=b.useRef(qi);b.useEffect(()=>{ds.current=qi},[qi]);const Fi=b.useRef(Zt);b.useEffect(()=>{Fi.current=Zt},[Zt]);const Hi=b.useCallback(async(ue,pe)=>{const xe=So(ue);if(!xe)return!1;const Oe=vl(xe),Q=!!pe?.silent;Q||De(null);const ne=Ih(Oe);if(!ne)return Q||De("Nur chaturbate.com oder myfreecams.com werden unterstützt."),!1;const ce=xi.current;if(ne==="chaturbate"&&!Wi(ce))return Q||De('Für Chaturbate müssen die Cookies "cf_clearance" und "sessionId" gesetzt sein.'),!1;if(ai.current.some(Ne=>{if(String(Ne.status||"").toLowerCase()!=="running"||Ne.endedAt)return!1;const We=So(String(Ne.sourceUrl||""));return(We?vl(We):"")===Oe}))return!0;if(ne==="chaturbate"&&ht.current.useChaturbateApi)try{const Ne=await Cn("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:Oe})}),We=String(Ne?.modelKey??"").trim().toLowerCase();if(We){if(Gt.current)return Bi(mt=>({...mt||{},[We]:Oe})),!0;const xt=$s.current[We],it=String(xt?.current_show??"");if(xt&&it&&it!=="public")return Bi(mt=>({...mt||{},[We]:Oe})),!0}}catch{}else if(Gt.current)return Mt.current=Oe,!0;if(Gt.current)return!1;at(!0),Gt.current=!0;try{const Ne=Object.entries(ce).map(([xt,it])=>`${xt}=${it}`).join("; "),We=await Cn("/api/record",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Oe,cookie:Ne})});return We?.id&&(di.current[String(We.id)]=!0),q(xt=>[We,...xt]),ai.current=[We,...ai.current],!0}catch(Ne){const We=Ne?.message??String(Ne);return d(We)?(f({silent:Q}),!1):(Q||De(We),!1)}finally{at(!1),Gt.current=!1}},[]);b.useEffect(()=>{let ue=!1;const pe=async()=>{try{const Q=await Cn("/api/settings",{cache:"no-store"});!ue&&Q&&Be({...LA,...Q})}catch{}},xe=()=>{pe()},Oe=()=>{pe()};return window.addEventListener("recorder-settings-updated",xe),window.addEventListener("focus",Oe),document.addEventListener("visibilitychange",Oe),pe(),()=>{ue=!0,window.removeEventListener("recorder-settings-updated",xe),window.removeEventListener("focus",Oe),document.removeEventListener("visibilitychange",Oe)}},[]),b.useEffect(()=>{let ue=!1;const pe=async()=>{try{const Oe=await Cn("/api/models/meta",{cache:"no-store"}),Q=Number(Oe?.count??0);!ue&&Number.isFinite(Q)&&(Le(Q),Re(Date.now()))}catch{}};pe();const xe=window.setInterval(pe,document.hidden?6e4:3e4);return()=>{ue=!0,window.clearInterval(xe)}},[]);const Ge=b.useMemo(()=>Object.entries(kt).map(([ue,pe])=>({name:ue,value:pe})),[kt]),Lt=b.useCallback((ue,pe)=>{Ze.current=null,ze(null),yi(ue),Jt(!1),gt(typeof pe=="number"&&Number.isFinite(pe)&&pe>=0?pe:null)},[]),Ct=W.filter(ue=>{const pe=String(ue?.status??"").toLowerCase();return pe==="running"||pe==="postwork"}),Xt=b.useMemo(()=>{let ue=0;for(const pe of Object.values(pt)){if(!pe?.watching||!Li(pe))continue;const xe=_e(String(pe?.modelKey??""));xe&&Ji[xe]&&ue++}return ue},[pt,Ji,Li]),{onlineFavCount:Wt,onlineLikedCount:_i}=b.useMemo(()=>{let ue=0,pe=0;for(const xe of Object.values(pt)){const Oe=_e(String(xe?.modelKey??""));Oe&&Ji[Oe]&&(xe?.favorite&&ue++,xe?.liked===!0&&pe++)}return{onlineFavCount:ue,onlineLikedCount:pe}},[pt,Ji]),ei=[{id:"running",label:"Laufende Downloads",count:Ct.length},{id:"finished",label:"Abgeschlossene Downloads",count:le},{id:"models",label:"Models",count:Ie},{id:"categories",label:"Kategorien"},{id:"settings",label:"Einstellungen"}],Ki=b.useMemo(()=>re.trim().length>0&&!Ue,[re,Ue]);b.useEffect(()=>{let ue=!1;return(async()=>{try{const xe=await Cn("/api/cookies",{cache:"no-store"}),Oe=Jm(xe?.cookies);if(ue||Tt(Oe),Object.keys(Oe).length===0){const Q=localStorage.getItem(ix);if(Q)try{const ne=JSON.parse(Q),ce=Jm(ne);Object.keys(ce).length>0&&(ue||Tt(ce),await Cn("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:ce})}))}catch{}}}catch{const xe=localStorage.getItem(ix);if(xe)try{const Oe=JSON.parse(xe);ue||Tt(Jm(Oe))}catch{}}finally{ue||Qt(!0)}})(),()=>{ue=!0}},[]),b.useEffect(()=>{Ft&&localStorage.setItem(ix,JSON.stringify(kt))},[kt,Ft]),b.useEffect(()=>{P();const ue=()=>{document.hidden||P()};return document.addEventListener("visibilitychange",ue),()=>{document.removeEventListener("visibilitychange",ue)}},[P]),b.useEffect(()=>{if(Zt!=="finished")return;P(),R("selectedTab effect");const ue=()=>{document.hidden||(P(),R("selectedTab visibilitychange"))};return document.addEventListener("visibilitychange",ue),()=>{document.removeEventListener("visibilitychange",ue)}},[Zt,P,R]),b.useEffect(()=>{const ue=Math.max(1,Math.ceil(le/v));oe>ue&&F(ue)},[le,oe]),b.useEffect(()=>{if(!t)return;let ue=null,pe=null;const xe=()=>{pe!=null&&(window.clearInterval(pe),pe=null)},Oe=()=>{pe==null&&(pe=window.setInterval(()=>{document.hidden||(Fi.current==="finished"?(P(),R("done-stream poll tick")):P())},document.hidden?6e4:15e3))},Q={t:0};let ne=null;const ce=()=>{const We=Date.now();if(We-Q.t<800){if(ne!=null)return;ne=window.setTimeout(()=>{ne=null,Q.t=Date.now(),Fi.current==="finished"?(P(),R("done-stream coalesced requestRefresh")):P()},900);return}Q.t=We,Fi.current==="finished"?(P(),R("done-stream requestRefresh")):P()};P(),ue=new EventSource("/api/record/done/stream"),ue.onopen=()=>{xe()},ue.onerror=()=>{Oe()};const fe=()=>ce();ue.addEventListener("doneChanged",fe);const Ne=()=>{document.hidden||ce()};return document.addEventListener("visibilitychange",Ne),()=>{document.removeEventListener("visibilitychange",Ne),ne!=null&&window.clearTimeout(ne),xe(),ue?.removeEventListener("doneChanged",fe),ue?.close(),ue=null}},[t,P,R]),b.useEffect(()=>{if(!t)return;Y();const ue=window.setInterval(()=>{if(document.hidden)return;const xe=ai.current.some(Oe=>{const Q=String(Oe?.status??"").toLowerCase();return Q==="running"||Q==="postwork"});(Fi.current==="running"||xe)&&Y()},document.hidden?6e4:3e3),pe=()=>{document.hidden||Y()};return document.addEventListener("visibilitychange",pe),()=>{window.clearInterval(ue),document.removeEventListener("visibilitychange",pe)}},[t,Y]);function Ts(ue){const pe=So(ue);if(!pe)return!1;try{return new URL(pe).hostname.includes("chaturbate.com")}catch{return!1}}function In(ue,pe){const xe=Object.fromEntries(Object.entries(ue).map(([Oe,Q])=>[Oe.trim().toLowerCase(),Q]));for(const Oe of pe){const Q=xe[Oe.toLowerCase()];if(Q)return Q}}function Wi(ue){const pe=In(ue,["cf_clearance"]),xe=In(ue,["sessionid","session_id","sessionId"]);return!!(pe&&xe)}async function Nn(ue){try{await Cn(`/api/record/stop?id=${encodeURIComponent(ue)}`,{method:"POST"})}catch(pe){a.error("Stop fehlgeschlagen",pe?.message??String(pe))}}b.useEffect(()=>{const ue=pe=>{const Oe=Number(pe.detail?.delta??0);Number.isFinite(Oe)&&Oe!==0&&ge(Q=>Math.max(0,Q+Oe)),P()};return window.addEventListener("finished-downloads:count-hint",ue),()=>window.removeEventListener("finished-downloads:count-hint",ue)},[P]),b.useEffect(()=>{const ue=pe=>{const xe=pe.detail||{};xe.tab==="finished"&&Et("finished"),xe.tab==="categories"&&Et("categories"),xe.tab==="models"&&Et("models"),xe.tab==="running"&&Et("running"),xe.tab==="settings"&&Et("settings")};return window.addEventListener("app:navigate-tab",ue),()=>window.removeEventListener("app:navigate-tab",ue)},[]),b.useEffect(()=>{if(!Dt){ze(null),X(null);return}const ue=(lh(Dt.output||"")||"").trim().toLowerCase();X(ue||null);const pe=ue?pt[ue]:void 0;ze(pe??null)},[Dt,pt]);async function On(){return Hi(re)}const Zs=b.useCallback(async ue=>{const pe=String(ue?.sourceUrl??""),xe=ru(pe);if(!xe)return!1;const Oe=So(xe);if(!Oe)return!1;const Q=vl(Oe),ne=await Hi(Q,{silent:!0});return ne||a.error("Konnte URL nicht hinzufügen","Start fehlgeschlagen oder URL ungültig."),ne},[Hi,a]);async function pn(ue){const{kind:pe,file:xe,run:Oe,onSuccess:Q,onError:ne}=ue;(pe==="delete"||pe==="keep")&&window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:xe,phase:"start"}}));try{const ce=await Oe();return(pe==="delete"||pe==="keep")&&window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:xe,phase:"success"}})),await Q?.(ce),ce}catch(ce){throw(pe==="delete"||pe==="keep")&&window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:xe,phase:"error"}})),await ne?.(ce),ce}}const ln=b.useCallback(async ue=>{const pe=Os(ue.output||"");if(pe)try{const xe=await pn({kind:"delete",file:pe,run:()=>Cn(`/api/record/delete?file=${encodeURIComponent(pe)}`,{method:"POST"}),onSuccess:async()=>{window.setTimeout(()=>{te(Q=>{const ne=Q.filter(it=>Os(it.output||"")!==pe);if(v-ne.length<=0)return ne;const fe=I(oe+1,S),Ne=L.current;if(!Ne||Ne.key!==fe||!Array.isArray(Ne.items)||Ne.items.length===0)return ne;const We=[...ne],xt=new Set(We.map(it=>String(it.id||Os(it.output||"")).trim()));for(;We.length<v&&Ne.items.length>0;){const it=Ne.items.shift(),mt=String(it.id||Os(it.output||"")).trim();!mt||xt.has(mt)||(xt.add(mt),We.push(it))}return L.current={...Ne,items:Ne.items,ts:Ne.ts},We}),ge(Q=>Math.max(0,Q-1)),q(Q=>Q.filter(ne=>Os(ne.output||"")!==pe)),yi(Q=>Q&&Os(Q.output||"")===pe?null:Q),j(oe+1)},320)},onError:async()=>{a.error("Löschen fehlgeschlagen",pe)}}),Oe=typeof xe?.undoToken=="string"?xe.undoToken:"";return Oe?{undoToken:Oe}:{}}catch{return}},[pn,a,oe,S,j]),Is=b.useCallback(async ue=>{const pe=Os(ue.output||"");if(pe)try{await pn({kind:"keep",file:pe,run:()=>Cn(`/api/record/keep?file=${encodeURIComponent(pe)}`,{method:"POST"}),onSuccess:async()=>{window.setTimeout(()=>{te(xe=>xe.filter(Oe=>Os(Oe.output||"")!==pe)),q(xe=>xe.filter(Oe=>Os(Oe.output||"")!==pe)),yi(xe=>xe&&Os(xe.output||"")===pe?null:xe),ge(xe=>Math.max(0,xe-1)),j(oe+1)},320)},onError:async()=>{a.error("Keep fehlgeschlagen",pe)}})}catch{return}},[pn,a,oe,j]),un=b.useCallback(async ue=>{const pe=Os(ue.output||"");if(pe)try{window.dispatchEvent(new CustomEvent("player:release",{detail:{file:pe}})),await new Promise(ce=>window.setTimeout(ce,60));const xe=await Cn(`/api/record/toggle-hot?file=${encodeURIComponent(pe)}`,{method:"POST"}),Oe=Os(xe.oldFile||pe)||pe,Q=Os(xe.newFile||"")||"";if(!Q)throw new Error("Backend lieferte keinen neuen Dateinamen zurück");window.dispatchEvent(new CustomEvent("finished-downloads:rename",{detail:{oldFile:Oe,newFile:Q}}));const ne=ce=>YH(ce||"",Q);return yi(ce=>ce&&(ce.id===ue.id||Os(ce.output||"")===Oe?{...ce,output:ne(ce.output||"")}:ce)),te(ce=>ce.map(fe=>fe.id===ue.id||Os(fe.output||"")===Oe?{...fe,output:ne(fe.output||"")}:fe)),q(ce=>ce.map(fe=>fe.id===ue.id||Os(fe.output||"")===Oe?{...fe,output:ne(fe.output||"")}:fe)),xe}catch(xe){a.error("Umbenennen fehlgeschlagen",xe?.message??String(xe));return}},[a]),Mn=b.useCallback(async ue=>{await ln(ue)},[ln]);async function Js(ue){const pe=await fetch("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)});if(pe.status===204)return null;if(!pe.ok){const xe=await pe.text().catch(()=>"");throw new Error(xe||`HTTP ${pe.status}`)}return pe.json()}const en=b.useCallback(ue=>{const pe=Ze.current;!pe||!ue||(pe.ts=Date.now(),pe.list=pe.list.filter(xe=>xe.id!==ue))},[]),zi=b.useRef({}),Pn=b.useCallback(async ue=>{const pe=Os(ue.output||""),xe=!!(Dt&&Os(Dt.output||"")===pe),Oe=it=>{try{const mt=String(it.sourceUrl??it.SourceURL??""),Rt=ru(mt);return Rt?new URL(Rt).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Q=(lh(ue.output||"")||"").trim().toLowerCase();if(Q){const it=Q;if(zi.current[it])return;zi.current[it]=!0;const mt=pt[Q]??{id:"",input:"",host:Oe(ue)||void 0,modelKey:Q,watching:!1,favorite:!1,liked:null,isUrl:!1},Rt=!mt.favorite,Pt={...mt,modelKey:mt.modelKey||Q,favorite:Rt,liked:Rt?!1:mt.liked};Fe(Nt=>({...Nt,[Q]:Pt})),se(Pt),xe&&ze(Pt);try{const Nt=await Js({...Pt.id?{id:Pt.id}:{},host:Pt.host||Oe(ue)||"",modelKey:Q,favorite:Rt,...Rt?{liked:!1}:{}});if(!Nt){Fe(Vi=>{const{[Q]:gn,...yn}=Vi;return yn}),mt.id&&en(mt.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:mt.id,modelKey:Q}}));return}const Ht=_e(Nt.modelKey||Q);Ht&&Fe(Vi=>({...Vi,[Ht]:Nt})),se(Nt),xe&&ze(Nt),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Nt}}))}catch(Nt){Fe(Ht=>({...Ht,[Q]:mt})),se(mt),xe&&ze(mt),a.error("Favorit umschalten fehlgeschlagen",Nt?.message??String(Nt))}finally{delete zi.current[it]}return}let ne=xe?Xe:null;if(ne||(ne=await we(ue,{ensure:!0})),!ne)return;const ce=_e(ne.modelKey||ne.id||"");if(!ce||zi.current[ce])return;zi.current[ce]=!0;const fe=ne,Ne=!fe.favorite,We={...fe,favorite:Ne,liked:Ne?!1:fe.liked},xt=_e(fe.modelKey||"");xt&&Fe(it=>({...it,[xt]:We})),se(We),xe&&ze(We);try{const it=await Js({id:fe.id,favorite:Ne,...Ne?{liked:!1}:{}});if(!it){Fe(Rt=>{const Pt=_e(fe.modelKey||"");if(!Pt)return Rt;const{[Pt]:Nt,...Ht}=Rt;return Ht}),en(fe.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:fe.id,modelKey:fe.modelKey}}));return}const mt=_e(it.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:it})),se(it),xe&&ze(it),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:it}}))}catch(it){const mt=_e(fe.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:fe})),se(fe),xe&&ze(fe),a.error("Favorit umschalten fehlgeschlagen",it?.message??String(it))}finally{delete zi.current[ce]}},[a,Dt,Xe,we,Js,se,en,pt]),_n=b.useCallback(async ue=>{const pe=Os(ue.output||""),xe=!!(Dt&&Os(Dt.output||"")===pe),Oe=it=>{try{const mt=String(it.sourceUrl??it.SourceURL??""),Rt=ru(mt);return Rt?new URL(Rt).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Q=(lh(ue.output||"")||"").trim().toLowerCase();if(Q){const it=Q;if(zi.current[it])return;zi.current[it]=!0;const mt=pt[Q]??{id:"",input:"",host:Oe(ue)||void 0,modelKey:Q,watching:!1,favorite:!1,liked:null,isUrl:!1},Rt=mt.liked!==!0,Pt={...mt,modelKey:mt.modelKey||Q,liked:Rt,favorite:Rt?!1:mt.favorite};Fe(Nt=>({...Nt,[Q]:Pt})),se(Pt),xe&&ze(Pt);try{const Nt=await Js({...Pt.id?{id:Pt.id}:{},host:Pt.host||Oe(ue)||"",modelKey:Q,liked:Rt,...Rt?{favorite:!1}:{}});if(!Nt){Fe(Vi=>{const{[Q]:gn,...yn}=Vi;return yn}),mt.id&&en(mt.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:mt.id,modelKey:Q}}));return}const Ht=_e(Nt.modelKey||Q);Ht&&Fe(Vi=>({...Vi,[Ht]:Nt})),se(Nt),xe&&ze(Nt),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Nt}}))}catch(Nt){Fe(Ht=>({...Ht,[Q]:mt})),se(mt),xe&&ze(mt),a.error("Like umschalten fehlgeschlagen",Nt?.message??String(Nt))}finally{delete zi.current[it]}return}let ne=xe?Xe:null;if(ne||(ne=await we(ue,{ensure:!0})),!ne)return;const ce=_e(ne.modelKey||ne.id||"");if(!ce||zi.current[ce])return;zi.current[ce]=!0;const fe=ne,Ne=fe.liked!==!0,We={...fe,liked:Ne,favorite:Ne?!1:fe.favorite},xt=_e(fe.modelKey||"");xt&&Fe(it=>({...it,[xt]:We})),se(We),xe&&ze(We);try{const it=Ne?await Js({id:fe.id,liked:!0,favorite:!1}):await Js({id:fe.id,liked:!1});if(!it){Fe(Rt=>{const Pt=_e(fe.modelKey||"");if(!Pt)return Rt;const{[Pt]:Nt,...Ht}=Rt;return Ht}),en(fe.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:fe.id,modelKey:fe.modelKey}}));return}const mt=_e(it.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:it})),se(it),xe&&ze(it),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:it}}))}catch(it){const mt=_e(fe.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:fe})),se(fe),xe&&ze(fe),a.error("Like umschalten fehlgeschlagen",it?.message??String(it))}finally{delete zi.current[ce]}},[a,Dt,Xe,we,Js,se,en,pt]),me=b.useCallback(async ue=>{const pe=Os(ue.output||""),xe=!!(Dt&&Os(Dt.output||"")===pe),Oe=it=>{try{const mt=String(it.sourceUrl??it.SourceURL??""),Rt=ru(mt);return Rt?new URL(Rt).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Q=(lh(ue.output||"")||"").trim().toLowerCase();if(Q){const it=Q;if(zi.current[it])return;zi.current[it]=!0;const mt=pt[Q]??{id:"",input:"",host:Oe(ue)||void 0,modelKey:Q,watching:!1,favorite:!1,liked:null,isUrl:!1},Rt=!mt.watching,Pt={...mt,modelKey:mt.modelKey||Q,watching:Rt};Fe(Nt=>({...Nt,[Q]:Pt})),se(Pt),xe&&ze(Pt);try{const Nt=await Js({...Pt.id?{id:Pt.id}:{},host:Pt.host||Oe(ue)||"",modelKey:Q,watched:Rt});if(!Nt){Fe(Vi=>{const{[Q]:gn,...yn}=Vi;return yn}),mt.id&&en(mt.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:mt.id,modelKey:Q}}));return}const Ht=_e(Nt.modelKey||Q);Ht&&Fe(Vi=>({...Vi,[Ht]:Nt})),se(Nt),xe&&ze(Nt),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Nt}}))}catch(Nt){Fe(Ht=>({...Ht,[Q]:mt})),se(mt),xe&&ze(mt),a.error("Watched umschalten fehlgeschlagen",Nt?.message??String(Nt))}finally{delete zi.current[it]}return}let ne=xe?Xe:null;if(ne||(ne=await we(ue,{ensure:!0})),!ne)return;const ce=_e(ne.modelKey||ne.id||"");if(!ce||zi.current[ce])return;zi.current[ce]=!0;const fe=ne,Ne=!fe.watching,We={...fe,watching:Ne},xt=_e(fe.modelKey||"");xt&&Fe(it=>({...it,[xt]:We})),se(We),xe&&ze(We);try{const it=await Js({id:fe.id,watched:Ne});if(!it){Fe(Rt=>{const Pt=_e(fe.modelKey||"");if(!Pt)return Rt;const{[Pt]:Nt,...Ht}=Rt;return Ht}),en(fe.id),xe&&ze(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:fe.id,modelKey:fe.modelKey}}));return}const mt=_e(it.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:it})),se(it),xe&&ze(it),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:it}}))}catch(it){const mt=_e(fe.modelKey||"");mt&&Fe(Rt=>({...Rt,[mt]:fe})),se(fe),xe&&ze(fe),a.error("Watched umschalten fehlgeschlagen",it?.message??String(it))}finally{delete zi.current[ce]}},[a,Dt,Xe,we,Js,se,en,pt]);async function we(ue,pe){const xe=!!pe?.ensure,Oe=We=>{const xt=Date.now(),it=Ze.current;if(!it){Ze.current={ts:xt,list:[We]};return}it.ts=xt;const mt=it.list.findIndex(Rt=>Rt.id===We.id);mt>=0?it.list[mt]=We:it.list.unshift(We)},Q=async We=>{if(!We)return null;const xt=We.trim().toLowerCase();if(!xt)return null;const it=pt[xt];if(it)return Oe(it),it;if(xe){let Ht;try{const gn=ue.sourceUrl??ue.SourceURL??"",yn=ru(gn);yn&&(Ht=new URL(yn).hostname.replace(/^www\./i,"").toLowerCase())}catch{}const Vi=await Cn("/api/models/ensure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelKey:We,...Ht?{host:Ht}:{}})});return se(Vi),Vi}const mt=Date.now(),Rt=Ze.current;if(!Rt||mt-Rt.ts>3e4){const Ht=Object.values(pt);if(Ht.length)Ze.current={ts:mt,list:Ht};else{const Vi=await Cn("/api/models",{cache:"no-store"});Ze.current={ts:mt,list:Array.isArray(Vi)?Vi:[]}}}const Nt=(Ze.current?.list??[]).find(Ht=>(Ht.modelKey||"").trim().toLowerCase()===xt);return Nt||null},ne=lh(ue.output||"");if(ne)return Q(ne);const ce=ue.status==="running",fe=ue.sourceUrl??ue.SourceURL??"",Ne=ru(fe);if(ce&&Ne){const We=await Cn("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:Ne})}),xt=await Cn("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(We)});return se(xt),xt}return null}return b.useEffect(()=>{if(!It&&!Yt||!navigator.clipboard?.readText)return;let ue=!1,pe=!1,xe=null;const Oe=async()=>{if(!(ue||pe)){pe=!0;try{const ce=await navigator.clipboard.readText(),fe=ru(ce);if(!fe)return;const Ne=So(fe);if(!Ne||!Ih(Ne))return;const xt=vl(Ne);if(xt===vt.current)return;vt.current=xt,It&&J(xt),Yt&&Zi({url:xt,silent:!1})}catch{}finally{pe=!1}}},Q=ce=>{ue||(xe=window.setTimeout(async()=>{await Oe(),Q(document.hidden?5e3:1500)},ce))},ne=()=>{Oe()};return window.addEventListener("hover",ne),document.addEventListener("visibilitychange",ne),Q(0),()=>{ue=!0,xe&&window.clearTimeout(xe),window.removeEventListener("hover",ne),document.removeEventListener("visibilitychange",ne)}},[It,Yt,Zi]),b.useEffect(()=>{const ue=CA({getModels:()=>{if(!ht.current.useChaturbateApi)return[];const pe=bs.current,xe=Kt.current,Oe=Object.values(pe).filter(ne=>!!ne?.watching&&String(ne?.host??"").toLowerCase().includes("chaturbate")).map(ne=>String(ne?.modelKey??"").trim().toLowerCase()).filter(Boolean),Q=Object.keys(xe||{}).map(ne=>String(ne||"").trim().toLowerCase()).filter(Boolean);return Array.from(new Set([...Oe,...Q]))},getShow:()=>["public","private","hidden","away"],intervalMs:8e3,onData:pe=>{(async()=>{if(!pe?.enabled){Di({}),$s.current={},Cs.current={},oi([]),Rs.current={},rs.current=!1,ns.current={},Re(Date.now());return}const xe={};for(const ce of Array.isArray(pe.rooms)?pe.rooms:[]){const fe=String(ce?.username??"").trim().toLowerCase();fe&&(xe[fe]=ce)}Di(xe),$s.current=xe;try{const ce=!!(ht.current.enableNotifications??!0),fe=new Set(["private","away","hidden"]),Ne=new Set(Object.values(bs.current||{}).filter(Ht=>!!Ht?.watching&&String(Ht?.host??"").toLowerCase().includes("chaturbate")).map(Ht=>String(Ht?.modelKey??"").trim().toLowerCase()).filter(Boolean)),We=Cs.current||{},xt={...We},it=ns.current||{},mt=!rs.current,Rt=Rs.current||{},Pt={...Rt};for(const[Ht,Vi]of Object.entries(xe)){const gn=String(Vi?.current_show??"").toLowerCase().trim(),yn=String(We[Ht]??"").toLowerCase().trim(),hs=!0&&!!!it[Ht],Ms=!!Rt[Ht],En=String(Vi?.username??Ht).trim()||Ht,ba=String(Vi?.image_url??"").trim();if(Pt[Ht]=!0,gn==="public"&&fe.has(yn)){ce&&a.info(En,"ist wieder online.",{imageUrl:ba,imageAlt:`${En} Vorschau`,durationMs:5500,onClick:()=>{window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:En}}))}}),gn&&(xt[Ht]=gn);continue}if(Ne.has(Ht)&&hs){const Ta=Ms;ce&&!mt&&a.info(En,Ta?"ist wieder online.":"ist online.",{imageUrl:ba,imageAlt:`${En} Vorschau`,durationMs:5500,onClick:()=>{window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:En}}))}})}gn&&(xt[Ht]=gn)}const Nt={};for(const Ht of Object.keys(xe))Nt[Ht]=!0;ns.current=Nt,Rs.current=Pt,rs.current=!0,Cs.current=xt}catch{}const Oe=ds.current;for(const ce of Oe||[]){const fe=String(ce||"").trim().toLowerCase();fe&&xe[fe]}if(!ht.current.useChaturbateApi)oi([]);else if(Fi.current==="running"){const ce=bs.current,fe=Kt.current,Ne=Array.from(new Set(Object.values(ce).filter(mt=>!!mt?.watching&&String(mt?.host??"").toLowerCase().includes("chaturbate")).map(mt=>String(mt?.modelKey??"").trim().toLowerCase()).filter(Boolean))),We=Object.keys(fe||{}).map(mt=>String(mt||"").trim().toLowerCase()).filter(Boolean),xt=new Set(We),it=Array.from(new Set([...Ne,...We]));if(it.length===0)oi([]);else{const mt=[];for(const Rt of it){const Pt=xe[Rt];if(!Pt)continue;const Nt=String(Pt?.username??"").trim(),Ht=String(Pt?.current_show??"unknown");if(Ht==="public"&&!xt.has(Rt))continue;const Vi=`https://chaturbate.com/${(Nt||Rt).trim()}/`;mt.push({id:Rt,modelKey:Nt||Rt,url:Vi,currentShow:Ht,imageUrl:String(Pt?.image_url??"")})}mt.sort((Rt,Pt)=>Rt.modelKey.localeCompare(Pt.modelKey,void 0,{sensitivity:"base"})),oi(mt)}}if(!ht.current.useChaturbateApi||Gt.current)return;const Q=Kt.current,ne=Object.keys(Q||{}).map(ce=>String(ce||"").toLowerCase()).filter(Boolean);for(const ce of ne){const fe=xe[ce];if(!fe||String(fe.current_show??"")!=="public")continue;const Ne=Q[ce];Ne&&Zi({url:Ne,silent:!0,pendingKeyLower:ce})}Re(Date.now())})()}});return()=>ue()},[]),b.useEffect(()=>{if(!Te.useChaturbateApi){Je(0);return}const ue=CA({getModels:()=>[],getShow:()=>["public","private","hidden","away"],intervalMs:3e4,fetchAllWhenNoModels:!0,onData:pe=>{if(!pe?.enabled){Je(0);return}const xe=Number(pe?.total??0);Je(Number.isFinite(xe)?xe:0),Re(Date.now())},onError:pe=>{console.error("[ALL-online poller] error",pe)}});return()=>ue()},[Te.useChaturbateApi]),s?t?m.jsxs("div",{className:"min-h-[100dvh] bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100",children:[m.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 overflow-hidden",children:[m.jsx("div",{className:"absolute -top-28 left-1/2 h-80 w-[52rem] -translate-x-1/2 rounded-full bg-indigo-500/10 blur-3xl dark:bg-indigo-400/10"}),m.jsx("div",{className:"absolute -bottom-28 right-[-6rem] h-80 w-[46rem] rounded-full bg-sky-500/10 blur-3xl dark:bg-sky-400/10"})]}),m.jsxs("div",{className:"relative",children:[m.jsx("header",{className:"z-30 bg-white/70 backdrop-blur dark:bg-gray-950/60 sm:sticky sm:top-0 sm:border-b sm:border-gray-200/70 sm:dark:border-white/10",children:m.jsxs("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 pt-3 sm:py-4 space-y-2 sm:space-y-3",children:[m.jsxs("div",{className:"flex items-center sm:items-start justify-between gap-3 sm:gap-4",children:[m.jsx("div",{className:"min-w-0",children:m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m.jsx("h1",{className:"text-lg font-semibold tracking-tight text-gray-900 dark:text-white",children:"Recorder"}),m.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[m.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-100/80 px-2 py-1 text-[11px] font-semibold text-gray-900 ring-1 ring-gray-200/60 dark:bg-white/10 dark:text-gray-100 dark:ring-white/10",title:"online",children:[m.jsx(WM,{className:"size-4 opacity-80"}),m.jsx("span",{className:"tabular-nums",children:Pe})]}),m.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-100/80 px-2 py-1 text-[11px] font-semibold text-gray-900 ring-1 ring-gray-200/60 dark:bg-white/10 dark:text-gray-100 dark:ring-white/10",title:"Watched online",children:[m.jsx(Su,{className:"size-4 opacity-80"}),m.jsx("span",{className:"tabular-nums",children:Xt})]}),m.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-100/80 px-2 py-1 text-[11px] font-semibold text-gray-900 ring-1 ring-gray-200/60 dark:bg-white/10 dark:text-gray-100 dark:ring-white/10",title:"Fav online",children:[m.jsx(_u,{className:"size-4 opacity-80"}),m.jsx("span",{className:"tabular-nums",children:Wt})]}),m.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gray-100/80 px-2 py-1 text-[11px] font-semibold text-gray-900 ring-1 ring-gray-200/60 dark:bg-white/10 dark:text-gray-100 dark:ring-white/10",title:"Like online",children:[m.jsx($M,{className:"size-4 opacity-80"}),m.jsx("span",{className:"tabular-nums",children:_i})]})]}),m.jsx("div",{className:"hidden sm:block text-[11px] text-gray-500 dark:text-gray-400",children:ut})]}),m.jsxs("div",{className:"sm:hidden mt-1 w-full",children:[m.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:ut}),m.jsxs("div",{className:"mt-2 flex items-stretch gap-2",children:[g?m.jsx(kA,{mode:"inline",className:"flex-1"}):m.jsx("div",{className:"flex-1"}),m.jsx(ri,{variant:"secondary",onClick:()=>wt(!0),className:"px-3 shrink-0",children:"Cookies"}),m.jsx(ri,{variant:"secondary",onClick:r,className:"px-3 shrink-0",children:"Abmelden"})]})]})]})}),m.jsxs("div",{className:"hidden sm:flex items-center gap-2 h-full",children:[g?m.jsx(kA,{mode:"inline"}):null,m.jsx(ri,{variant:"secondary",onClick:()=>wt(!0),className:"h-9 px-3",children:"Cookies"}),m.jsx(ri,{variant:"secondary",onClick:r,className:"h-9 px-3",children:"Abmelden"})]})]}),m.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto] sm:items-stretch",children:[m.jsxs("div",{className:"relative",children:[m.jsx("label",{className:"sr-only",children:"Source URL"}),m.jsx("input",{value:re,onChange:ue=>J(ue.target.value),placeholder:"https://…",className:"block w-full rounded-lg px-3 py-2.5 text-sm bg-white text-gray-900 shadow-sm ring-1 ring-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:bg-white/10 dark:text-white dark:ring-white/10"})]}),m.jsx(ri,{variant:"primary",onClick:On,disabled:!Ki,className:"w-full sm:w-auto rounded-lg",children:"Start"})]}),ke?m.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",children:m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsx("div",{className:"min-w-0 break-words",children:ke}),m.jsx("button",{type:"button",className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-red-700 hover:bg-red-100 dark:text-red-200 dark:hover:bg-white/10",onClick:()=>De(null),"aria-label":"Fehlermeldung schließen",title:"Schließen",children:"✕"})]})}):null,Ts(re)&&!Wi(kt)?m.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["⚠️ Für Chaturbate werden die Cookies ",m.jsx("code",{children:"cf_clearance"})," und ",m.jsx("code",{children:"sessionId"})," benötigt."]}):null,Ue?m.jsx("div",{className:"pt-1",children:m.jsx(qh,{label:"Starte Download…",indeterminate:!0})}):null,m.jsx("div",{className:"hidden sm:block pt-2",children:m.jsx(cx,{tabs:ei,value:Zt,onChange:Et,ariaLabel:"Tabs",variant:"barUnderline"})})]})}),m.jsx("div",{className:"sm:hidden sticky top-0 z-20 border-b border-gray-200/70 bg-white/70 backdrop-blur dark:border-white/10 dark:bg-gray-950/60",children:m.jsx("div",{className:"mx-auto max-w-7xl px-4 pt-0 pb-2",children:m.jsx(cx,{tabs:ei,value:Zt,onChange:Et,ariaLabel:"Tabs",variant:"barUnderline"})})}),m.jsxs("main",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-2 space-y-2",children:[Zt==="running"?m.jsx(fH,{jobs:Ct,modelsByKey:pt,pending:pi,onOpenPlayer:Lt,onStopJob:Nn,onToggleFavorite:Pn,onToggleLike:_n,onToggleWatch:me,onAddToDownloads:Zs,blurPreviews:!!Te.blurPreviews}):null,Zt==="finished"?m.jsx(U3,{jobs:W,modelsByKey:pt,doneJobs:Z,doneTotal:le,page:oe,pageSize:v,onPageChange:F,onOpenPlayer:Lt,onDeleteJob:ln,onToggleHot:un,onToggleFavorite:Pn,onToggleLike:_n,onToggleWatch:me,onKeepJob:Is,blurPreviews:!!Te.blurPreviews,teaserPlayback:Te.teaserPlayback??"hover",teaserAudio:!!Te.teaserAudio,assetNonce:V,sortMode:S,onSortModeChange:ue=>{w(ue),F(1)},loadMode:"paged"}):null,Zt==="models"?m.jsx(xH,{}):null,Zt==="categories"?m.jsx($H,{}):null,Zt==="settings"?m.jsx(UO,{onAssetsGenerated:ie}):null]}),m.jsx(DO,{open:dt,onClose:()=>wt(!1),initialCookies:Ge,onApply:ue=>{const pe=Jm(Object.fromEntries(ue.map(xe=>[xe.name,xe.value])));Tt(pe),Cn("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:pe})}).catch(()=>{})}}),m.jsx(RH,{open:!!ct,modelKey:ct,onClose:()=>St(null),onOpenPlayer:Lt,runningJobs:Ct,cookies:kt,blurPreviews:Te.blurPreviews,onToggleHot:un,onDelete:Mn,onToggleFavorite:Pn,onToggleLike:_n,onToggleWatch:me}),Dt?m.jsx(aH,{job:Dt,modelKey:z??void 0,modelsByKey:pt,expanded:Pi,onToggleExpand:()=>Jt(ue=>!ue),onClose:()=>{yi(null),gt(null)},startAtSec:ki??void 0,isHot:Os(Dt.output||"").startsWith("HOT "),isFavorite:!!Xe?.favorite,isLiked:Xe?.liked===!0,isWatching:!!Xe?.watching,onKeep:Is,onDelete:Mn,onToggleHot:un,onToggleFavorite:Pn,onToggleLike:_n,onStopJob:Nn,onToggleWatch:me},[String(Dt?.id??""),Os(Dt.output||""),String(V)].join("::")):null]})]}):m.jsx(KH,{onLoggedIn:n}):m.jsx("div",{className:"min-h-[100dvh] grid place-items-center",children:"Lade…"})}IA.createRoot(document.getElementById("root")).render(m.jsx(b.StrictMode,{children:m.jsx(I3,{position:"top-right",maxToasts:3,defaultDurationMs:3500,children:m.jsx(ZH,{})})}));