nsfwapp/backend/web/dist/assets/index-DSZfASIn.js
2026-01-20 13:48:05 +01:00

337 lines
1.7 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 _I(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 o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).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 qm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function SI(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 sy={exports:{}},Fd={};var Z_;function EI(){if(Z_)return Fd;Z_=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,n,r){var o=null;if(r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+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:o,ref:n!==void 0?n:null,props:r}}return Fd.Fragment=e,Fd.jsx=t,Fd.jsxs=t,Fd}var J_;function wI(){return J_||(J_=1,sy.exports=EI()),sy.exports}var y=wI(),ny={exports:{}},Qt={};var eS;function AI(){if(eS)return Qt;eS=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"),o=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"),p=Symbol.for("react.activity"),g=Symbol.iterator;function v(F){return F===null||typeof F!="object"?null:(F=g&&F[g]||F["@@iterator"],typeof F=="function"?F:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,S={};function D(F,ee,pe){this.props=F,this.context=ee,this.refs=S,this.updater=pe||b}D.prototype.isReactComponent={},D.prototype.setState=function(F,ee){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,ee,"setState")},D.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function R(){}R.prototype=D.prototype;function L(F,ee,pe){this.props=F,this.context=ee,this.refs=S,this.updater=pe||b}var M=L.prototype=new R;M.constructor=L,_(M,D.prototype),M.isPureReactComponent=!0;var j=Array.isArray;function V(){}var P={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function I(F,ee,pe){var _e=pe.ref;return{$$typeof:s,type:F,key:ee,ref:_e!==void 0?_e:null,props:pe}}function O(F,ee){return I(F.type,ee,F.props)}function W(F){return typeof F=="object"&&F!==null&&F.$$typeof===s}function X(F){var ee={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(pe){return ee[pe]})}var q=/\/+/g;function ue(F,ee){return typeof F=="object"&&F!==null&&F.key!=null?X(""+F.key):ee.toString(36)}function ie(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(V,V):(F.status="pending",F.then(function(ee){F.status==="pending"&&(F.status="fulfilled",F.value=ee)},function(ee){F.status==="pending"&&(F.status="rejected",F.reason=ee)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function Y(F,ee,pe,_e,ve){var Ce=typeof F;(Ce==="undefined"||Ce==="boolean")&&(F=null);var Be=!1;if(F===null)Be=!0;else switch(Ce){case"bigint":case"string":case"number":Be=!0;break;case"object":switch(F.$$typeof){case s:case e:Be=!0;break;case f:return Be=F._init,Y(Be(F._payload),ee,pe,_e,ve)}}if(Be)return ve=ve(F),Be=_e===""?"."+ue(F,0):_e,j(ve)?(pe="",Be!=null&&(pe=Be.replace(q,"$&/")+"/"),Y(ve,ee,pe,"",function(Ct){return Ct})):ve!=null&&(W(ve)&&(ve=O(ve,pe+(ve.key==null||F&&F.key===ve.key?"":(""+ve.key).replace(q,"$&/")+"/")+Be)),ee.push(ve)),1;Be=0;var tt=_e===""?".":_e+":";if(j(F))for(var Je=0;Je<F.length;Je++)_e=F[Je],Ce=tt+ue(_e,Je),Be+=Y(_e,ee,pe,Ce,ve);else if(Je=v(F),typeof Je=="function")for(F=Je.call(F),Je=0;!(_e=F.next()).done;)_e=_e.value,Ce=tt+ue(_e,Je++),Be+=Y(_e,ee,pe,Ce,ve);else if(Ce==="object"){if(typeof F.then=="function")return Y(ie(F),ee,pe,_e,ve);throw ee=String(F),Error("Objects are not valid as a React child (found: "+(ee==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":ee)+"). If you meant to render a collection of children, use an array instead.")}return Be}function G(F,ee,pe){if(F==null)return F;var _e=[],ve=0;return Y(F,_e,"","",function(Ce){return ee.call(pe,Ce,ve++)}),_e}function J(F){if(F._status===-1){var ee=F._result;ee=ee(),ee.then(function(pe){(F._status===0||F._status===-1)&&(F._status=1,F._result=pe)},function(pe){(F._status===0||F._status===-1)&&(F._status=2,F._result=pe)}),F._status===-1&&(F._status=0,F._result=ee)}if(F._status===1)return F._result.default;throw F._result}var oe=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ee=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(ee))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},ce={map:G,forEach:function(F,ee,pe){G(F,function(){ee.apply(this,arguments)},pe)},count:function(F){var ee=0;return G(F,function(){ee++}),ee},toArray:function(F){return G(F,function(ee){return ee})||[]},only:function(F){if(!W(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Qt.Activity=p,Qt.Children=ce,Qt.Component=D,Qt.Fragment=t,Qt.Profiler=n,Qt.PureComponent=L,Qt.StrictMode=i,Qt.Suspense=c,Qt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=P,Qt.__COMPILER_RUNTIME={__proto__:null,c:function(F){return P.H.useMemoCache(F)}},Qt.cache=function(F){return function(){return F.apply(null,arguments)}},Qt.cacheSignal=function(){return null},Qt.cloneElement=function(F,ee,pe){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var _e=_({},F.props),ve=F.key;if(ee!=null)for(Ce in ee.key!==void 0&&(ve=""+ee.key),ee)!z.call(ee,Ce)||Ce==="key"||Ce==="__self"||Ce==="__source"||Ce==="ref"&&ee.ref===void 0||(_e[Ce]=ee[Ce]);var Ce=arguments.length-2;if(Ce===1)_e.children=pe;else if(1<Ce){for(var Be=Array(Ce),tt=0;tt<Ce;tt++)Be[tt]=arguments[tt+2];_e.children=Be}return I(F.type,ve,_e)},Qt.createContext=function(F){return F={$$typeof:o,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:r,_context:F},F},Qt.createElement=function(F,ee,pe){var _e,ve={},Ce=null;if(ee!=null)for(_e in ee.key!==void 0&&(Ce=""+ee.key),ee)z.call(ee,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(ve[_e]=ee[_e]);var Be=arguments.length-2;if(Be===1)ve.children=pe;else if(1<Be){for(var tt=Array(Be),Je=0;Je<Be;Je++)tt[Je]=arguments[Je+2];ve.children=tt}if(F&&F.defaultProps)for(_e in Be=F.defaultProps,Be)ve[_e]===void 0&&(ve[_e]=Be[_e]);return I(F,Ce,ve)},Qt.createRef=function(){return{current:null}},Qt.forwardRef=function(F){return{$$typeof:u,render:F}},Qt.isValidElement=W,Qt.lazy=function(F){return{$$typeof:f,_payload:{_status:-1,_result:F},_init:J}},Qt.memo=function(F,ee){return{$$typeof:d,type:F,compare:ee===void 0?null:ee}},Qt.startTransition=function(F){var ee=P.T,pe={};P.T=pe;try{var _e=F(),ve=P.S;ve!==null&&ve(pe,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(V,oe)}catch(Ce){oe(Ce)}finally{ee!==null&&pe.types!==null&&(ee.types=pe.types),P.T=ee}},Qt.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},Qt.use=function(F){return P.H.use(F)},Qt.useActionState=function(F,ee,pe){return P.H.useActionState(F,ee,pe)},Qt.useCallback=function(F,ee){return P.H.useCallback(F,ee)},Qt.useContext=function(F){return P.H.useContext(F)},Qt.useDebugValue=function(){},Qt.useDeferredValue=function(F,ee){return P.H.useDeferredValue(F,ee)},Qt.useEffect=function(F,ee){return P.H.useEffect(F,ee)},Qt.useEffectEvent=function(F){return P.H.useEffectEvent(F)},Qt.useId=function(){return P.H.useId()},Qt.useImperativeHandle=function(F,ee,pe){return P.H.useImperativeHandle(F,ee,pe)},Qt.useInsertionEffect=function(F,ee){return P.H.useInsertionEffect(F,ee)},Qt.useLayoutEffect=function(F,ee){return P.H.useLayoutEffect(F,ee)},Qt.useMemo=function(F,ee){return P.H.useMemo(F,ee)},Qt.useOptimistic=function(F,ee){return P.H.useOptimistic(F,ee)},Qt.useReducer=function(F,ee,pe){return P.H.useReducer(F,ee,pe)},Qt.useRef=function(F){return P.H.useRef(F)},Qt.useState=function(F){return P.H.useState(F)},Qt.useSyncExternalStore=function(F,ee,pe){return P.H.useSyncExternalStore(F,ee,pe)},Qt.useTransition=function(){return P.H.useTransition()},Qt.version="19.2.3",Qt}var tS;function Rp(){return tS||(tS=1,ny.exports=AI()),ny.exports}var A=Rp();const Mt=Nc(A),iS=_I({__proto__:null,default:Mt},[A]);var ry={exports:{}},Ud={},ay={exports:{}},oy={};var sS;function CI(){return sS||(sS=1,(function(s){function e(Y,G){var J=Y.length;Y.push(G);e:for(;0<J;){var oe=J-1>>>1,ce=Y[oe];if(0<n(ce,G))Y[oe]=G,Y[J]=ce,J=oe;else break e}}function t(Y){return Y.length===0?null:Y[0]}function i(Y){if(Y.length===0)return null;var G=Y[0],J=Y.pop();if(J!==G){Y[0]=J;e:for(var oe=0,ce=Y.length,F=ce>>>1;oe<F;){var ee=2*(oe+1)-1,pe=Y[ee],_e=ee+1,ve=Y[_e];if(0>n(pe,J))_e<ce&&0>n(ve,pe)?(Y[oe]=ve,Y[_e]=J,oe=_e):(Y[oe]=pe,Y[ee]=J,oe=ee);else if(_e<ce&&0>n(ve,J))Y[oe]=ve,Y[_e]=J,oe=_e;else break e}}return G}function n(Y,G){var J=Y.sortIndex-G.sortIndex;return J!==0?J:Y.id-G.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 o=Date,u=o.now();s.unstable_now=function(){return o.now()-u}}var c=[],d=[],f=1,p=null,g=3,v=!1,b=!1,_=!1,S=!1,D=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function M(Y){for(var G=t(d);G!==null;){if(G.callback===null)i(d);else if(G.startTime<=Y)i(d),G.sortIndex=G.expirationTime,e(c,G);else break;G=t(d)}}function j(Y){if(_=!1,M(Y),!b)if(t(c)!==null)b=!0,V||(V=!0,X());else{var G=t(d);G!==null&&ie(j,G.startTime-Y)}}var V=!1,P=-1,z=5,I=-1;function O(){return S?!0:!(s.unstable_now()-I<z)}function W(){if(S=!1,V){var Y=s.unstable_now();I=Y;var G=!0;try{e:{b=!1,_&&(_=!1,R(P),P=-1),v=!0;var J=g;try{t:{for(M(Y),p=t(c);p!==null&&!(p.expirationTime>Y&&O());){var oe=p.callback;if(typeof oe=="function"){p.callback=null,g=p.priorityLevel;var ce=oe(p.expirationTime<=Y);if(Y=s.unstable_now(),typeof ce=="function"){p.callback=ce,M(Y),G=!0;break t}p===t(c)&&i(c),M(Y)}else i(c);p=t(c)}if(p!==null)G=!0;else{var F=t(d);F!==null&&ie(j,F.startTime-Y),G=!1}}break e}finally{p=null,g=J,v=!1}G=void 0}}finally{G?X():V=!1}}}var X;if(typeof L=="function")X=function(){L(W)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,ue=q.port2;q.port1.onmessage=W,X=function(){ue.postMessage(null)}}else X=function(){D(W,0)};function ie(Y,G){P=D(function(){Y(s.unstable_now())},G)}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(Y){Y.callback=null},s.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<Y?Math.floor(1e3/Y):5},s.unstable_getCurrentPriorityLevel=function(){return g},s.unstable_next=function(Y){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var J=g;g=G;try{return Y()}finally{g=J}},s.unstable_requestPaint=function(){S=!0},s.unstable_runWithPriority=function(Y,G){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var J=g;g=Y;try{return G()}finally{g=J}},s.unstable_scheduleCallback=function(Y,G,J){var oe=s.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?oe+J:oe):J=oe,Y){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=J+ce,Y={id:f++,callback:G,priorityLevel:Y,startTime:J,expirationTime:ce,sortIndex:-1},J>oe?(Y.sortIndex=J,e(d,Y),t(c)===null&&Y===t(d)&&(_?(R(P),P=-1):_=!0,ie(j,J-oe))):(Y.sortIndex=ce,e(c,Y),b||v||(b=!0,V||(V=!0,X()))),Y},s.unstable_shouldYield=O,s.unstable_wrapCallback=function(Y){var G=g;return function(){var J=g;g=G;try{return Y.apply(this,arguments)}finally{g=J}}}})(oy)),oy}var nS;function kI(){return nS||(nS=1,ay.exports=CI()),ay.exports}var ly={exports:{}},nn={};var rS;function DI(){if(rS)return nn;rS=1;var s=Rp();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 p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:n,key:p==null?null:""+p,children:c,containerInfo:d,implementation:f}}var o=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 nn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,nn.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)},nn.flushSync=function(c){var d=o.T,f=i.p;try{if(o.T=null,i.p=2,c)return c()}finally{o.T=d,i.p=f,i.d.f()}},nn.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))},nn.prefetchDNS=function(c){typeof c=="string"&&i.d.D(c)},nn.preinit=function(c,d){if(typeof c=="string"&&d&&typeof d.as=="string"){var f=d.as,p=u(f,d.crossOrigin),g=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:p,integrity:g,fetchPriority:v}):f==="script"&&i.d.X(c,{crossOrigin:p,integrity:g,fetchPriority:v,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},nn.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)},nn.preload=function(c,d){if(typeof c=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var f=d.as,p=u(f,d.crossOrigin);i.d.L(c,f,{crossOrigin:p,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})}},nn.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)},nn.requestFormReset=function(c){i.d.r(c)},nn.unstable_batchedUpdates=function(c,d){return c(d)},nn.useFormState=function(c,d,f){return o.H.useFormState(c,d,f)},nn.useFormStatus=function(){return o.H.useHostTransitionStatus()},nn.version="19.2.3",nn}var aS;function Zw(){if(aS)return ly.exports;aS=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(),ly.exports=DI(),ly.exports}var oS;function LI(){if(oS)return Ud;oS=1;var s=kI(),e=Rp(),t=Zw();function i(a){var l="https://react.dev/errors/"+a;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 #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function r(a){var l=a,h=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(h=l.return),a=l.return;while(a)}return l.tag===3?h:null}function o(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function u(a){if(a.tag===31){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function c(a){if(r(a)!==a)throw Error(i(188))}function d(a){var l=a.alternate;if(!l){if(l=r(a),l===null)throw Error(i(188));return l!==a?null:a}for(var h=a,m=l;;){var T=h.return;if(T===null)break;var E=T.alternate;if(E===null){if(m=T.return,m!==null){h=m;continue}break}if(T.child===E.child){for(E=T.child;E;){if(E===h)return c(T),a;if(E===m)return c(T),l;E=E.sibling}throw Error(i(188))}if(h.return!==m.return)h=T,m=E;else{for(var U=!1,Z=T.child;Z;){if(Z===h){U=!0,h=T,m=E;break}if(Z===m){U=!0,m=T,h=E;break}Z=Z.sibling}if(!U){for(Z=E.child;Z;){if(Z===h){U=!0,h=E,m=T;break}if(Z===m){U=!0,m=E,h=T;break}Z=Z.sibling}if(!U)throw Error(i(189))}}if(h.alternate!==m)throw Error(i(190))}if(h.tag!==3)throw Error(i(188));return h.stateNode.current===h?a:l}function f(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a;for(a=a.child;a!==null;){if(l=f(a),l!==null)return l;a=a.sibling}return null}var p=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),L=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),W=Symbol.iterator;function X(a){return a===null||typeof a!="object"?null:(a=W&&a[W]||a["@@iterator"],typeof a=="function"?a:null)}var q=Symbol.for("react.client.reference");function ue(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===q?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case _:return"Fragment";case D:return"Profiler";case S:return"StrictMode";case j:return"Suspense";case V:return"SuspenseList";case I:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case b:return"Portal";case L:return a.displayName||"Context";case R:return(a._context.displayName||"Context")+".Consumer";case M:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case P:return l=a.displayName||null,l!==null?l:ue(a.type)||"Memo";case z:l=a._payload,a=a._init;try{return ue(a(l))}catch{}}return null}var ie=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},oe=[],ce=-1;function F(a){return{current:a}}function ee(a){0>ce||(a.current=oe[ce],oe[ce]=null,ce--)}function pe(a,l){ce++,oe[ce]=a.current,a.current=l}var _e=F(null),ve=F(null),Ce=F(null),Be=F(null);function tt(a,l){switch(pe(Ce,l),pe(ve,a),pe(_e,null),l.nodeType){case 9:case 11:a=(a=l.documentElement)&&(a=a.namespaceURI)?T_(a):0;break;default:if(a=l.tagName,l=l.namespaceURI)l=T_(l),a=__(l,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}ee(_e),pe(_e,a)}function Je(){ee(_e),ee(ve),ee(Ce)}function Ct(a){a.memoizedState!==null&&pe(Be,a);var l=_e.current,h=__(l,a.type);l!==h&&(pe(ve,a),pe(_e,h))}function st(a){ve.current===a&&(ee(_e),ee(ve)),Be.current===a&&(ee(Be),Od._currentValue=J)}var mt,pt;function ut(a){if(mt===void 0)try{throw Error()}catch(h){var l=h.stack.trim().match(/\n( *(at )?)/);mt=l&&l[1]||"",pt=-1<h.stack.indexOf(`
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
`+mt+a+pt}var Ht=!1;function at(a,l){if(!a||Ht)return"";Ht=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(l){var qe=function(){throw Error()};if(Object.defineProperty(qe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(qe,[])}catch(Me){var Ne=Me}Reflect.construct(a,[],qe)}else{try{qe.call()}catch(Me){Ne=Me}a.call(qe.prototype)}}else{try{throw Error()}catch(Me){Ne=Me}(qe=a())&&typeof qe.catch=="function"&&qe.catch(function(){})}}catch(Me){if(Me&&Ne&&typeof Me.stack=="string")return[Me.stack,Ne.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var E=m.DetermineComponentFrameRoot(),U=E[0],Z=E[1];if(U&&Z){var ge=U.split(`
`),Re=Z.split(`
`);for(T=m=0;m<ge.length&&!ge[m].includes("DetermineComponentFrameRoot");)m++;for(;T<Re.length&&!Re[T].includes("DetermineComponentFrameRoot");)T++;if(m===ge.length||T===Re.length)for(m=ge.length-1,T=Re.length-1;1<=m&&0<=T&&ge[m]!==Re[T];)T--;for(;1<=m&&0<=T;m--,T--)if(ge[m]!==Re[T]){if(m!==1||T!==1)do if(m--,T--,0>T||ge[m]!==Re[T]){var $e=`
`+ge[m].replace(" at new "," at ");return a.displayName&&$e.includes("<anonymous>")&&($e=$e.replace("<anonymous>",a.displayName)),$e}while(1<=m&&0<=T);break}}}finally{Ht=!1,Error.prepareStackTrace=h}return(h=a?a.displayName||a.name:"")?ut(h):""}function gt(a,l){switch(a.tag){case 26:case 27:case 5:return ut(a.type);case 16:return ut("Lazy");case 13:return a.child!==l&&l!==null?ut("Suspense Fallback"):ut("Suspense");case 19:return ut("SuspenseList");case 0:case 15:return at(a.type,!1);case 11:return at(a.type.render,!1);case 1:return at(a.type,!0);case 31:return ut("Activity");default:return""}}function Dt(a){try{var l="",h=null;do l+=gt(a,h),h=a,a=a.return;while(a);return l}catch(m){return`
Error generating stack: `+m.message+`
`+m.stack}}var Nt=Object.prototype.hasOwnProperty,dt=s.unstable_scheduleCallback,lt=s.unstable_cancelCallback,ye=s.unstable_shouldYield,ze=s.unstable_requestPaint,We=s.unstable_now,et=s.unstable_getCurrentPriorityLevel,ot=s.unstable_ImmediatePriority,nt=s.unstable_UserBlockingPriority,vt=s.unstable_NormalPriority,Xe=s.unstable_LowPriority,Ft=s.unstable_IdlePriority,Gt=s.log,wt=s.unstable_setDisableYieldValue,hi=null,Qe=null;function Lt(a){if(typeof Gt=="function"&&wt(a),Qe&&typeof Qe.setStrictMode=="function")try{Qe.setStrictMode(hi,a)}catch{}}var Ut=Math.clz32?Math.clz32:kt,vi=Math.log,gi=Math.LN2;function kt(a){return a>>>=0,a===0?32:31-(vi(a)/gi|0)|0}var ht=256,ri=262144,Ie=4194304;function H(a){var l=a&42;if(l!==0)return l;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function K(a,l,h){var m=a.pendingLanes;if(m===0)return 0;var T=0,E=a.suspendedLanes,U=a.pingedLanes;a=a.warmLanes;var Z=m&134217727;return Z!==0?(m=Z&~E,m!==0?T=H(m):(U&=Z,U!==0?T=H(U):h||(h=Z&~a,h!==0&&(T=H(h))))):(Z=m&~E,Z!==0?T=H(Z):U!==0?T=H(U):h||(h=m&~a,h!==0&&(T=H(h)))),T===0?0:l!==0&&l!==T&&(l&E)===0&&(E=T&-T,h=l&-l,E>=h||E===32&&(h&4194048)!==0)?l:T}function re(a,l){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&l)===0}function Ee(a,l){switch(a){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 Ye(){var a=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),a}function Tt(a){for(var l=[],h=0;31>h;h++)l.push(a);return l}function zt(a,l){a.pendingLanes|=l,l!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function xi(a,l,h,m,T,E){var U=a.pendingLanes;a.pendingLanes=h,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=h,a.entangledLanes&=h,a.errorRecoveryDisabledLanes&=h,a.shellSuspendCounter=0;var Z=a.entanglements,ge=a.expirationTimes,Re=a.hiddenUpdates;for(h=U&~h;0<h;){var $e=31-Ut(h),qe=1<<$e;Z[$e]=0,ge[$e]=-1;var Ne=Re[$e];if(Ne!==null)for(Re[$e]=null,$e=0;$e<Ne.length;$e++){var Me=Ne[$e];Me!==null&&(Me.lane&=-536870913)}h&=~qe}m!==0&&Wi(a,m,0),E!==0&&T===0&&a.tag!==0&&(a.suspendedLanes|=E&~(U&~l))}function Wi(a,l,h){a.pendingLanes|=l,a.suspendedLanes&=~l;var m=31-Ut(l);a.entangledLanes|=l,a.entanglements[m]=a.entanglements[m]|1073741824|h&261930}function Xi(a,l){var h=a.entangledLanes|=l;for(a=a.entanglements;h;){var m=31-Ut(h),T=1<<m;T&l|a[m]&l&&(a[m]|=l),h&=~T}}function rs(a,l){var h=l&-l;return h=(h&42)!==0?1:Qi(h),(h&(a.suspendedLanes|l))!==0?0:h}function Qi(a){switch(a){case 2:a=1;break;case 8:a=4;break;case 32:a=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:a=128;break;case 268435456:a=134217728;break;default:a=0}return a}function ai(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function Fi(){var a=G.p;return a!==0?a:(a=window.event,a===void 0?32:z_(a.type))}function Ui(a,l){var h=G.p;try{return G.p=a,l()}finally{G.p=h}}var Ei=Math.random().toString(36).slice(2),Wt="__reactFiber$"+Ei,Kt="__reactProps$"+Ei,jt="__reactContainer$"+Ei,Ii="__reactEvents$"+Ei,ds="__reactListeners$"+Ei,as="__reactHandles$"+Ei,Fs="__reactResources$"+Ei,fi="__reactMarker$"+Ei;function li(a){delete a[Wt],delete a[Kt],delete a[Ii],delete a[ds],delete a[as]}function ji(a){var l=a[Wt];if(l)return l;for(var h=a.parentNode;h;){if(l=h[jt]||h[Wt]){if(h=l.alternate,l.child!==null||h!==null&&h.child!==null)for(a=D_(a);a!==null;){if(h=a[Wt])return h;a=D_(a)}return l}a=h,h=a.parentNode}return null}function hs(a){if(a=a[Wt]||a[jt]){var l=a.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return a}return null}function Us(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a.stateNode;throw Error(i(33))}function Q(a){var l=a[Fs];return l||(l=a[Fs]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function se(a){a[fi]=!0}var ae=new Set,xe={};function Te(a,l){je(a,l),je(a+"Capture",l)}function je(a,l){for(xe[a]=l,a=0;a<l.length;a++)ae.add(l[a])}var de=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]*$"),me={},Pe={};function it(a){return Nt.call(Pe,a)?!0:Nt.call(me,a)?!1:de.test(a)?Pe[a]=!0:(me[a]=!0,!1)}function ft(a,l,h){if(it(l))if(h===null)a.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":a.removeAttribute(l);return;case"boolean":var m=l.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){a.removeAttribute(l);return}}a.setAttribute(l,""+h)}}function Ke(a,l,h){if(h===null)a.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(l);return}a.setAttribute(l,""+h)}}function Ve(a,l,h,m){if(m===null)a.removeAttribute(h);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(h);return}a.setAttributeNS(l,h,""+m)}}function Ze(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function _t(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function St(a,l,h){var m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l);if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var T=m.get,E=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return T.call(this)},set:function(U){h=""+U,E.call(this,U)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return h},setValue:function(U){h=""+U},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function Bt(a){if(!a._valueTracker){var l=_t(a)?"checked":"value";a._valueTracker=St(a,l,""+a[l])}}function Ti(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var h=l.getValue(),m="";return a&&(m=_t(a)?a.checked?"true":"false":a.value),a=m,a!==h?(l.setValue(a),!0):!1}function Js(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var vs=/[\n"\\]/g;function Ls(a){return a.replace(vs,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function Ja(a,l,h,m,T,E,U,Z){a.name="",U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"?a.type=U:a.removeAttribute("type"),l!=null?U==="number"?(l===0&&a.value===""||a.value!=l)&&(a.value=""+Ze(l)):a.value!==""+Ze(l)&&(a.value=""+Ze(l)):U!=="submit"&&U!=="reset"||a.removeAttribute("value"),l!=null?xa(a,U,Ze(l)):h!=null?xa(a,U,Ze(h)):m!=null&&a.removeAttribute("value"),T==null&&E!=null&&(a.defaultChecked=!!E),T!=null&&(a.checked=T&&typeof T!="function"&&typeof T!="symbol"),Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"?a.name=""+Ze(Z):a.removeAttribute("name")}function eo(a,l,h,m,T,E,U,Z){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(a.type=E),l!=null||h!=null){if(!(E!=="submit"&&E!=="reset"||l!=null)){Bt(a);return}h=h!=null?""+Ze(h):"",l=l!=null?""+Ze(l):h,Z||l===a.value||(a.value=l),a.defaultValue=l}m=m??T,m=typeof m!="function"&&typeof m!="symbol"&&!!m,a.checked=Z?a.checked:!!m,a.defaultChecked=!!m,U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"&&(a.name=U),Bt(a)}function xa(a,l,h){l==="number"&&Js(a.ownerDocument)===a||a.defaultValue===""+h||(a.defaultValue=""+h)}function Es(a,l,h,m){if(a=a.options,l){l={};for(var T=0;T<h.length;T++)l["$"+h[T]]=!0;for(h=0;h<a.length;h++)T=l.hasOwnProperty("$"+a[h].value),a[h].selected!==T&&(a[h].selected=T),T&&m&&(a[h].defaultSelected=!0)}else{for(h=""+Ze(h),l=null,T=0;T<a.length;T++){if(a[T].value===h){a[T].selected=!0,m&&(a[T].defaultSelected=!0);return}l!==null||a[T].disabled||(l=a[T])}l!==null&&(l.selected=!0)}}function su(a,l,h){if(l!=null&&(l=""+Ze(l),l!==a.value&&(a.value=l),h==null)){a.defaultValue!==l&&(a.defaultValue=l);return}a.defaultValue=h!=null?""+Ze(h):""}function Or(a,l,h,m){if(l==null){if(m!=null){if(h!=null)throw Error(i(92));if(ie(m)){if(1<m.length)throw Error(i(93));m=m[0]}h=m}h==null&&(h=""),l=h}h=Ze(l),a.defaultValue=h,m=a.textContent,m===h&&m!==""&&m!==null&&(a.value=m),Bt(a)}function un(a,l){if(l){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=l;return}}a.textContent=l}var rl=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 vr(a,l,h){var m=l.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?m?a.setProperty(l,""):l==="float"?a.cssFloat="":a[l]="":m?a.setProperty(l,h):typeof h!="number"||h===0||rl.has(l)?l==="float"?a.cssFloat=h:a[l]=(""+h).trim():a[l]=h+"px"}function qi(a,l,h){if(l!=null&&typeof l!="object")throw Error(i(62));if(a=a.style,h!=null){for(var m in h)!h.hasOwnProperty(m)||l!=null&&l.hasOwnProperty(m)||(m.indexOf("--")===0?a.setProperty(m,""):m==="float"?a.cssFloat="":a[m]="");for(var T in l)m=l[T],l.hasOwnProperty(T)&&h[T]!==m&&vr(a,T,m)}else for(var E in l)l.hasOwnProperty(E)&&vr(a,E,l[E])}function Ji(a){if(a.indexOf("-")===-1)return!1;switch(a){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 jn=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"]]),al=/^[\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 nu(a){return al.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function xr(){}var to=null;function ru(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var io=null,ba=null;function Ph(a){var l=hs(a);if(l&&(a=l.stateNode)){var h=a[Kt]||null;e:switch(a=l.stateNode,l.type){case"input":if(Ja(a,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),l=h.name,h.type==="radio"&&l!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+Ls(""+l)+'"][type="radio"]'),l=0;l<h.length;l++){var m=h[l];if(m!==a&&m.form===a.form){var T=m[Kt]||null;if(!T)throw Error(i(90));Ja(m,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(l=0;l<h.length;l++)m=h[l],m.form===a.form&&Ti(m)}break e;case"textarea":su(a,h.value,h.defaultValue);break e;case"select":l=h.value,l!=null&&Es(a,!!h.multiple,l,!1)}}}var au=!1;function Bh(a,l,h){if(au)return a(l,h);au=!0;try{var m=a(l);return m}finally{if(au=!1,(io!==null||ba!==null)&&(Bf(),io&&(l=io,a=ba,ba=io=null,Ph(l),a)))for(l=0;l<a.length;l++)Ph(a[l])}}function Mr(a,l){var h=a.stateNode;if(h===null)return null;var m=h[Kt]||null;if(m===null)return null;h=m[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":(m=!m.disabled)||(a=a.type,m=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!m;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(i(231,l,typeof h));return h}var xn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ou=!1;if(xn)try{var ol={};Object.defineProperty(ol,"passive",{get:function(){ou=!0}}),window.addEventListener("test",ol,ol),window.removeEventListener("test",ol,ol)}catch{ou=!1}var Pr=null,lu=null,ll=null;function Fh(){if(ll)return ll;var a,l=lu,h=l.length,m,T="value"in Pr?Pr.value:Pr.textContent,E=T.length;for(a=0;a<h&&l[a]===T[a];a++);var U=h-a;for(m=1;m<=U&&l[h-m]===T[E-m];m++);return ll=T.slice(a,1<m?1-m:void 0)}function ul(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function uu(){return!0}function Uh(){return!1}function en(a){function l(h,m,T,E,U){this._reactName=h,this._targetInst=T,this.type=m,this.nativeEvent=E,this.target=U,this.currentTarget=null;for(var Z in a)a.hasOwnProperty(Z)&&(h=a[Z],this[Z]=h?h(E):E[Z]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?uu:Uh,this.isPropagationStopped=Uh,this}return p(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=uu)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=uu)},persist:function(){},isPersistent:uu}),l}var Ta={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cu=en(Ta),cl=p({},Ta,{view:0,detail:0}),$c=en(cl),Hc,du,Br,hu=p({},cl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vc,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Br&&(Br&&a.type==="mousemove"?(Hc=a.screenX-Br.screenX,du=a.screenY-Br.screenY):du=Hc=0,Br=a),Hc)},movementY:function(a){return"movementY"in a?a.movementY:du}}),jh=en(hu),hg=p({},hu,{dataTransfer:0}),fg=en(hg),mg=p({},cl,{relatedTarget:0}),so=en(mg),dl=p({},Ta,{animationName:0,elapsedTime:0,pseudoElement:0}),hl=en(dl),fu=p({},Ta,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),$n=en(fu),br=p({},Ta,{data:0}),fl=en(br),$h={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pg={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"},gg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yg(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=gg[a])?!!l[a]:!1}function Vc(){return yg}var Hh=p({},cl,{key:function(a){if(a.key){var l=$h[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=ul(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?pg[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vc,charCode:function(a){return a.type==="keypress"?ul(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?ul(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),Vh=en(Hh),mu=p({},hu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),no=en(mu),pu=p({},cl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vc}),_a=en(pu),vg=p({},Ta,{propertyName:0,elapsedTime:0,pseudoElement:0}),Gh=en(vg),zh=p({},hu,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),qh=en(zh),xg=p({},Ta,{newState:0,oldState:0}),bg=en(xg),Tg=[9,13,27,32],ro=xn&&"CompositionEvent"in window,ml=null;xn&&"documentMode"in document&&(ml=document.documentMode);var Kh=xn&&"TextEvent"in window&&!ml,Yh=xn&&(!ro||ml&&8<ml&&11>=ml),Wh=" ",Gc=!1;function gu(a,l){switch(a){case"keyup":return Tg.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xh(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ao=!1;function _g(a,l){switch(a){case"compositionend":return Xh(l);case"keypress":return l.which!==32?null:(Gc=!0,Wh);case"textInput":return a=l.data,a===Wh&&Gc?null:a;default:return null}}function zc(a,l){if(ao)return a==="compositionend"||!ro&&gu(a,l)?(a=Fh(),ll=lu=Pr=null,ao=!1,a):null;switch(a){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 Yh&&l.locale!=="ko"?null:l.data;default:return null}}var Sg={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 qc(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!Sg[a.type]:l==="textarea"}function Qh(a,l,h,m){io?ba?ba.push(m):ba=[m]:io=m,l=Gf(l,"onChange"),0<l.length&&(h=new cu("onChange","change",null,h,m),a.push({event:h,listeners:l}))}var pl=null,oo=null;function Eg(a){p_(a,0)}function gl(a){var l=Us(a);if(Ti(l))return a}function Kc(a,l){if(a==="change")return l}var Yc=!1;if(xn){var Wc;if(xn){var Xc="oninput"in document;if(!Xc){var yl=document.createElement("div");yl.setAttribute("oninput","return;"),Xc=typeof yl.oninput=="function"}Wc=Xc}else Wc=!1;Yc=Wc&&(!document.documentMode||9<document.documentMode)}function Zh(){pl&&(pl.detachEvent("onpropertychange",Jh),oo=pl=null)}function Jh(a){if(a.propertyName==="value"&&gl(oo)){var l=[];Qh(l,oo,a,ru(a)),Bh(Eg,l)}}function wg(a,l,h){a==="focusin"?(Zh(),pl=l,oo=h,pl.attachEvent("onpropertychange",Jh)):a==="focusout"&&Zh()}function Ag(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return gl(oo)}function ef(a,l){if(a==="click")return gl(l)}function Cg(a,l){if(a==="input"||a==="change")return gl(l)}function vl(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var tn=typeof Object.is=="function"?Object.is:vl;function Fr(a,l){if(tn(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var h=Object.keys(a),m=Object.keys(l);if(h.length!==m.length)return!1;for(m=0;m<h.length;m++){var T=h[m];if(!Nt.call(l,T)||!tn(a[T],l[T]))return!1}return!0}function lo(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function es(a,l){var h=lo(a);a=0;for(var m;h;){if(h.nodeType===3){if(m=a+h.textContent.length,a<=l&&m>=l)return{node:h,offset:l-a};a=m}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=lo(h)}}function Sa(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Sa(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function yu(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var l=Js(a.document);l instanceof a.HTMLIFrameElement;){try{var h=typeof l.contentWindow.location.href=="string"}catch{h=!1}if(h)a=l.contentWindow;else break;l=Js(a.document)}return l}function Qc(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}var kg=xn&&"documentMode"in document&&11>=document.documentMode,uo=null,Zc=null,co=null,vu=!1;function Jc(a,l,h){var m=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;vu||uo==null||uo!==Js(m)||(m=uo,"selectionStart"in m&&Qc(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),co&&Fr(co,m)||(co=m,m=Gf(Zc,"onSelect"),0<m.length&&(l=new cu("onSelect","select",null,l,h),a.push({event:l,listeners:m}),l.target=uo)))}function Ur(a,l){var h={};return h[a.toLowerCase()]=l.toLowerCase(),h["Webkit"+a]="webkit"+l,h["Moz"+a]="moz"+l,h}var Ea={animationend:Ur("Animation","AnimationEnd"),animationiteration:Ur("Animation","AnimationIteration"),animationstart:Ur("Animation","AnimationStart"),transitionrun:Ur("Transition","TransitionRun"),transitionstart:Ur("Transition","TransitionStart"),transitioncancel:Ur("Transition","TransitionCancel"),transitionend:Ur("Transition","TransitionEnd")},xl={},ed={};xn&&(ed=document.createElement("div").style,"AnimationEvent"in window||(delete Ea.animationend.animation,delete Ea.animationiteration.animation,delete Ea.animationstart.animation),"TransitionEvent"in window||delete Ea.transitionend.transition);function Tr(a){if(xl[a])return xl[a];if(!Ea[a])return a;var l=Ea[a],h;for(h in l)if(l.hasOwnProperty(h)&&h in ed)return xl[a]=l[h];return a}var tf=Tr("animationend"),ho=Tr("animationiteration"),sf=Tr("animationstart"),nf=Tr("transitionrun"),rf=Tr("transitionstart"),Dg=Tr("transitioncancel"),af=Tr("transitionend"),td=new Map,id="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(" ");id.push("scrollEnd");function Hn(a,l){td.set(a,l),Te(l,[a])}var fo=typeof reportError=="function"?reportError:function(a){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof a=="object"&&a!==null&&typeof a.message=="string"?String(a.message):String(a),error:a});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",a);return}console.error(a)},bn=[],mo=0,sd=0;function xu(){for(var a=mo,l=sd=mo=0;l<a;){var h=bn[l];bn[l++]=null;var m=bn[l];bn[l++]=null;var T=bn[l];bn[l++]=null;var E=bn[l];if(bn[l++]=null,m!==null&&T!==null){var U=m.pending;U===null?T.next=T:(T.next=U.next,U.next=T),m.pending=T}E!==0&&of(h,T,E)}}function bu(a,l,h,m){bn[mo++]=a,bn[mo++]=l,bn[mo++]=h,bn[mo++]=m,sd|=m,a.lanes|=m,a=a.alternate,a!==null&&(a.lanes|=m)}function nd(a,l,h,m){return bu(a,l,h,m),Tu(a)}function wa(a,l){return bu(a,null,null,l),Tu(a)}function of(a,l,h){a.lanes|=h;var m=a.alternate;m!==null&&(m.lanes|=h);for(var T=!1,E=a.return;E!==null;)E.childLanes|=h,m=E.alternate,m!==null&&(m.childLanes|=h),E.tag===22&&(a=E.stateNode,a===null||a._visibility&1||(T=!0)),a=E,E=E.return;return a.tag===3?(E=a.stateNode,T&&l!==null&&(T=31-Ut(h),a=E.hiddenUpdates,m=a[T],m===null?a[T]=[l]:m.push(l),l.lane=h|536870912),E):null}function Tu(a){if(50<Cd)throw Cd=0,C0=null,Error(i(185));for(var l=a.return;l!==null;)a=l,l=a.return;return a.tag===3?a.stateNode:null}var po={};function Lg(a,l,h,m){this.tag=a,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=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fs(a,l,h,m){return new Lg(a,l,h,m)}function rd(a){return a=a.prototype,!(!a||!a.isReactComponent)}function _r(a,l){var h=a.alternate;return h===null?(h=fs(a.tag,l,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=l,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&65011712,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,l=a.dependencies,h.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h.refCleanup=a.refCleanup,h}function lf(a,l){a.flags&=65011714;var h=a.alternate;return h===null?(a.childLanes=0,a.lanes=l,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=h.childLanes,a.lanes=h.lanes,a.child=h.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=h.memoizedProps,a.memoizedState=h.memoizedState,a.updateQueue=h.updateQueue,a.type=h.type,l=h.dependencies,a.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),a}function ad(a,l,h,m,T,E){var U=0;if(m=a,typeof a=="function")rd(a)&&(U=1);else if(typeof a=="string")U=cI(a,h,_e.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case I:return a=fs(31,h,l,T),a.elementType=I,a.lanes=E,a;case _:return jr(h.children,T,E,l);case S:U=8,T|=24;break;case D:return a=fs(12,h,l,T|2),a.elementType=D,a.lanes=E,a;case j:return a=fs(13,h,l,T),a.elementType=j,a.lanes=E,a;case V:return a=fs(19,h,l,T),a.elementType=V,a.lanes=E,a;default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case L:U=10;break e;case R:U=9;break e;case M:U=11;break e;case P:U=14;break e;case z:U=16,m=null;break e}U=29,h=Error(i(130,a===null?"null":typeof a,"")),m=null}return l=fs(U,h,l,T),l.elementType=a,l.type=m,l.lanes=E,l}function jr(a,l,h,m){return a=fs(7,a,m,l),a.lanes=h,a}function bl(a,l,h){return a=fs(6,a,null,l),a.lanes=h,a}function od(a){var l=fs(18,null,null,0);return l.stateNode=a,l}function go(a,l,h){return l=fs(4,a.children!==null?a.children:[],a.key,l),l.lanes=h,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}var Tl=new WeakMap;function Tn(a,l){if(typeof a=="object"&&a!==null){var h=Tl.get(a);return h!==void 0?h:(l={value:a,source:l,stack:Dt(l)},Tl.set(a,l),l)}return{value:a,source:l,stack:Dt(l)}}var yo=[],vo=0,_u=null,_l=0,sn=[],_n=0,$r=null,Vn=1,qs="";function ii(a,l){yo[vo++]=_l,yo[vo++]=_u,_u=a,_l=l}function Hr(a,l,h){sn[_n++]=Vn,sn[_n++]=qs,sn[_n++]=$r,$r=a;var m=Vn;a=qs;var T=32-Ut(m)-1;m&=~(1<<T),h+=1;var E=32-Ut(l)+T;if(30<E){var U=T-T%5;E=(m&(1<<U)-1).toString(32),m>>=U,T-=U,Vn=1<<32-Ut(l)+T|h<<T|m,qs=E+a}else Vn=1<<E|h<<T|m,qs=a}function Rs(a){a.return!==null&&(ii(a,1),Hr(a,1,0))}function Sn(a){for(;a===_u;)_u=yo[--vo],yo[vo]=null,_l=yo[--vo],yo[vo]=null;for(;a===$r;)$r=sn[--_n],sn[_n]=null,qs=sn[--_n],sn[_n]=null,Vn=sn[--_n],sn[_n]=null}function uf(a,l){sn[_n++]=Vn,sn[_n++]=qs,sn[_n++]=$r,Vn=l.id,qs=l.overflow,$r=a}var ws=null,$i=null,ui=!1,Vr=null,En=!1,ld=Error(i(519));function Gr(a){var l=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw C(Tn(l,a)),ld}function cf(a){var l=a.stateNode,h=a.type,m=a.memoizedProps;switch(l[Wt]=a,l[Kt]=m,h){case"dialog":di("cancel",l),di("close",l);break;case"iframe":case"object":case"embed":di("load",l);break;case"video":case"audio":for(h=0;h<Dd.length;h++)di(Dd[h],l);break;case"source":di("error",l);break;case"img":case"image":case"link":di("error",l),di("load",l);break;case"details":di("toggle",l);break;case"input":di("invalid",l),eo(l,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":di("invalid",l);break;case"textarea":di("invalid",l),Or(l,m.value,m.defaultValue,m.children)}h=m.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||l.textContent===""+h||m.suppressHydrationWarning===!0||x_(l.textContent,h)?(m.popover!=null&&(di("beforetoggle",l),di("toggle",l)),m.onScroll!=null&&di("scroll",l),m.onScrollEnd!=null&&di("scrollend",l),m.onClick!=null&&(l.onclick=xr),l=!0):l=!1,l||Gr(a,!0)}function ud(a){for(ws=a.return;ws;)switch(ws.tag){case 5:case 31:case 13:En=!1;return;case 27:case 3:En=!0;return;default:ws=ws.return}}function x(a){if(a!==ws)return!1;if(!ui)return ud(a),ui=!0,!1;var l=a.tag,h;if((h=l!==3&&l!==27)&&((h=l===5)&&(h=a.type,h=!(h!=="form"&&h!=="button")||H0(a.type,a.memoizedProps)),h=!h),h&&$i&&Gr(a),ud(a),l===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(317));$i=k_(a)}else if(l===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(317));$i=k_(a)}else l===27?(l=$i,Ro(a.type)?(a=K0,K0=null,$i=a):$i=l):$i=ws?or(a.stateNode.nextSibling):null;return!0}function w(){$i=ws=null,ui=!1}function k(){var a=Vr;return a!==null&&(kn===null?kn=a:kn.push.apply(kn,a),Vr=null),a}function C(a){Vr===null?Vr=[a]:Vr.push(a)}var N=F(null),B=null,te=null;function ne(a,l,h){pe(N,l._currentValue),l._currentValue=h}function le(a){a._currentValue=N.current,ee(N)}function fe(a,l,h){for(;a!==null;){var m=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,m!==null&&(m.childLanes|=l)):m!==null&&(m.childLanes&l)!==l&&(m.childLanes|=l),a===h)break;a=a.return}}function Se(a,l,h,m){var T=a.child;for(T!==null&&(T.return=a);T!==null;){var E=T.dependencies;if(E!==null){var U=T.child;E=E.firstContext;e:for(;E!==null;){var Z=E;E=T;for(var ge=0;ge<l.length;ge++)if(Z.context===l[ge]){E.lanes|=h,Z=E.alternate,Z!==null&&(Z.lanes|=h),fe(E.return,h,a),m||(U=null);break e}E=Z.next}}else if(T.tag===18){if(U=T.return,U===null)throw Error(i(341));U.lanes|=h,E=U.alternate,E!==null&&(E.lanes|=h),fe(U,h,a),U=null}else U=T.child;if(U!==null)U.return=T;else for(U=T;U!==null;){if(U===a){U=null;break}if(T=U.sibling,T!==null){T.return=U.return,U=T;break}U=U.return}T=U}}function Oe(a,l,h,m){a=null;for(var T=l,E=!1;T!==null;){if(!E){if((T.flags&524288)!==0)E=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var U=T.alternate;if(U===null)throw Error(i(387));if(U=U.memoizedProps,U!==null){var Z=T.type;tn(T.pendingProps.value,U.value)||(a!==null?a.push(Z):a=[Z])}}else if(T===Be.current){if(U=T.alternate,U===null)throw Error(i(387));U.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(a!==null?a.push(Od):a=[Od])}T=T.return}a!==null&&Se(l,a,h,m),l.flags|=262144}function ct(a){for(a=a.firstContext;a!==null;){if(!tn(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function Ue(a){B=a,te=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function xt(a){return xs(B,a)}function Yt(a,l){return B===null&&Ue(a),xs(a,l)}function xs(a,l){var h=l._currentValue;if(l={context:l,memoizedValue:h,next:null},te===null){if(a===null)throw Error(i(308));te=l,a.dependencies={lanes:0,firstContext:l},a.flags|=524288}else te=te.next=l;return h}var cn=typeof AbortController<"u"?AbortController:function(){var a=[],l=this.signal={aborted:!1,addEventListener:function(h,m){a.push(m)}};this.abort=function(){l.aborted=!0,a.forEach(function(h){return h()})}},zr=s.unstable_scheduleCallback,Sl=s.unstable_NormalPriority,Ki={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Aa(){return{controller:new cn,data:new Map,refCount:0}}function Sr(a){a.refCount--,a.refCount===0&&zr(Sl,function(){a.controller.abort()})}var qr=null,Ci=0,rr=0,js=null;function uR(a,l){if(qr===null){var h=qr=[];Ci=0,rr=N0(),js={status:"pending",value:void 0,then:function(m){h.push(m)}}}return Ci++,l.then(rT,rT),l}function rT(){if(--Ci===0&&qr!==null){js!==null&&(js.status="fulfilled");var a=qr;qr=null,rr=0,js=null;for(var l=0;l<a.length;l++)(0,a[l])()}}function cR(a,l){var h=[],m={status:"pending",value:null,reason:null,then:function(T){h.push(T)}};return a.then(function(){m.status="fulfilled",m.value=l;for(var T=0;T<h.length;T++)(0,h[T])(l)},function(T){for(m.status="rejected",m.reason=T,T=0;T<h.length;T++)(0,h[T])(void 0)}),m}var aT=Y.S;Y.S=function(a,l){V1=We(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&uR(a,l),aT!==null&&aT(a,l)};var El=F(null);function Rg(){var a=El.current;return a!==null?a:Hi.pooledCache}function df(a,l){l===null?pe(El,El.current):pe(El,l.pool)}function oT(){var a=Rg();return a===null?null:{parent:Ki._currentValue,pool:a}}var Su=Error(i(460)),Ig=Error(i(474)),hf=Error(i(542)),ff={then:function(){}};function lT(a){return a=a.status,a==="fulfilled"||a==="rejected"}function uT(a,l,h){switch(h=a[h],h===void 0?a.push(l):h!==l&&(l.then(xr,xr),l=h),l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,dT(a),a;default:if(typeof l.status=="string")l.then(xr,xr);else{if(a=Hi,a!==null&&100<a.shellSuspendCounter)throw Error(i(482));a=l,a.status="pending",a.then(function(m){if(l.status==="pending"){var T=l;T.status="fulfilled",T.value=m}},function(m){if(l.status==="pending"){var T=l;T.status="rejected",T.reason=m}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,dT(a),a}throw Al=l,Su}}function wl(a){try{var l=a._init;return l(a._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(Al=h,Su):h}}var Al=null;function cT(){if(Al===null)throw Error(i(459));var a=Al;return Al=null,a}function dT(a){if(a===Su||a===hf)throw Error(i(483))}var Eu=null,cd=0;function mf(a){var l=cd;return cd+=1,Eu===null&&(Eu=[]),uT(Eu,a,l)}function dd(a,l){l=l.props.ref,a.ref=l!==void 0?l:null}function pf(a,l){throw l.$$typeof===g?Error(i(525)):(a=Object.prototype.toString.call(l),Error(i(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a)))}function hT(a){function l(we,be){if(a){var Le=we.deletions;Le===null?(we.deletions=[be],we.flags|=16):Le.push(be)}}function h(we,be){if(!a)return null;for(;be!==null;)l(we,be),be=be.sibling;return null}function m(we){for(var be=new Map;we!==null;)we.key!==null?be.set(we.key,we):be.set(we.index,we),we=we.sibling;return be}function T(we,be){return we=_r(we,be),we.index=0,we.sibling=null,we}function E(we,be,Le){return we.index=Le,a?(Le=we.alternate,Le!==null?(Le=Le.index,Le<be?(we.flags|=67108866,be):Le):(we.flags|=67108866,be)):(we.flags|=1048576,be)}function U(we){return a&&we.alternate===null&&(we.flags|=67108866),we}function Z(we,be,Le,Ge){return be===null||be.tag!==6?(be=bl(Le,we.mode,Ge),be.return=we,be):(be=T(be,Le),be.return=we,be)}function ge(we,be,Le,Ge){var Ot=Le.type;return Ot===_?$e(we,be,Le.props.children,Ge,Le.key):be!==null&&(be.elementType===Ot||typeof Ot=="object"&&Ot!==null&&Ot.$$typeof===z&&wl(Ot)===be.type)?(be=T(be,Le.props),dd(be,Le),be.return=we,be):(be=ad(Le.type,Le.key,Le.props,null,we.mode,Ge),dd(be,Le),be.return=we,be)}function Re(we,be,Le,Ge){return be===null||be.tag!==4||be.stateNode.containerInfo!==Le.containerInfo||be.stateNode.implementation!==Le.implementation?(be=go(Le,we.mode,Ge),be.return=we,be):(be=T(be,Le.children||[]),be.return=we,be)}function $e(we,be,Le,Ge,Ot){return be===null||be.tag!==7?(be=jr(Le,we.mode,Ge,Ot),be.return=we,be):(be=T(be,Le),be.return=we,be)}function qe(we,be,Le){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return be=bl(""+be,we.mode,Le),be.return=we,be;if(typeof be=="object"&&be!==null){switch(be.$$typeof){case v:return Le=ad(be.type,be.key,be.props,null,we.mode,Le),dd(Le,be),Le.return=we,Le;case b:return be=go(be,we.mode,Le),be.return=we,be;case z:return be=wl(be),qe(we,be,Le)}if(ie(be)||X(be))return be=jr(be,we.mode,Le,null),be.return=we,be;if(typeof be.then=="function")return qe(we,mf(be),Le);if(be.$$typeof===L)return qe(we,Yt(we,be),Le);pf(we,be)}return null}function Ne(we,be,Le,Ge){var Ot=be!==null?be.key:null;if(typeof Le=="string"&&Le!==""||typeof Le=="number"||typeof Le=="bigint")return Ot!==null?null:Z(we,be,""+Le,Ge);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case v:return Le.key===Ot?ge(we,be,Le,Ge):null;case b:return Le.key===Ot?Re(we,be,Le,Ge):null;case z:return Le=wl(Le),Ne(we,be,Le,Ge)}if(ie(Le)||X(Le))return Ot!==null?null:$e(we,be,Le,Ge,null);if(typeof Le.then=="function")return Ne(we,be,mf(Le),Ge);if(Le.$$typeof===L)return Ne(we,be,Yt(we,Le),Ge);pf(we,Le)}return null}function Me(we,be,Le,Ge,Ot){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return we=we.get(Le)||null,Z(be,we,""+Ge,Ot);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case v:return we=we.get(Ge.key===null?Le:Ge.key)||null,ge(be,we,Ge,Ot);case b:return we=we.get(Ge.key===null?Le:Ge.key)||null,Re(be,we,Ge,Ot);case z:return Ge=wl(Ge),Me(we,be,Le,Ge,Ot)}if(ie(Ge)||X(Ge))return we=we.get(Le)||null,$e(be,we,Ge,Ot,null);if(typeof Ge.then=="function")return Me(we,be,Le,mf(Ge),Ot);if(Ge.$$typeof===L)return Me(we,be,Le,Yt(be,Ge),Ot);pf(be,Ge)}return null}function At(we,be,Le,Ge){for(var Ot=null,_i=null,Rt=be,ei=be=0,pi=null;Rt!==null&&ei<Le.length;ei++){Rt.index>ei?(pi=Rt,Rt=null):pi=Rt.sibling;var Si=Ne(we,Rt,Le[ei],Ge);if(Si===null){Rt===null&&(Rt=pi);break}a&&Rt&&Si.alternate===null&&l(we,Rt),be=E(Si,be,ei),_i===null?Ot=Si:_i.sibling=Si,_i=Si,Rt=pi}if(ei===Le.length)return h(we,Rt),ui&&ii(we,ei),Ot;if(Rt===null){for(;ei<Le.length;ei++)Rt=qe(we,Le[ei],Ge),Rt!==null&&(be=E(Rt,be,ei),_i===null?Ot=Rt:_i.sibling=Rt,_i=Rt);return ui&&ii(we,ei),Ot}for(Rt=m(Rt);ei<Le.length;ei++)pi=Me(Rt,we,ei,Le[ei],Ge),pi!==null&&(a&&pi.alternate!==null&&Rt.delete(pi.key===null?ei:pi.key),be=E(pi,be,ei),_i===null?Ot=pi:_i.sibling=pi,_i=pi);return a&&Rt.forEach(function(Po){return l(we,Po)}),ui&&ii(we,ei),Ot}function $t(we,be,Le,Ge){if(Le==null)throw Error(i(151));for(var Ot=null,_i=null,Rt=be,ei=be=0,pi=null,Si=Le.next();Rt!==null&&!Si.done;ei++,Si=Le.next()){Rt.index>ei?(pi=Rt,Rt=null):pi=Rt.sibling;var Po=Ne(we,Rt,Si.value,Ge);if(Po===null){Rt===null&&(Rt=pi);break}a&&Rt&&Po.alternate===null&&l(we,Rt),be=E(Po,be,ei),_i===null?Ot=Po:_i.sibling=Po,_i=Po,Rt=pi}if(Si.done)return h(we,Rt),ui&&ii(we,ei),Ot;if(Rt===null){for(;!Si.done;ei++,Si=Le.next())Si=qe(we,Si.value,Ge),Si!==null&&(be=E(Si,be,ei),_i===null?Ot=Si:_i.sibling=Si,_i=Si);return ui&&ii(we,ei),Ot}for(Rt=m(Rt);!Si.done;ei++,Si=Le.next())Si=Me(Rt,we,ei,Si.value,Ge),Si!==null&&(a&&Si.alternate!==null&&Rt.delete(Si.key===null?ei:Si.key),be=E(Si,be,ei),_i===null?Ot=Si:_i.sibling=Si,_i=Si);return a&&Rt.forEach(function(TI){return l(we,TI)}),ui&&ii(we,ei),Ot}function Mi(we,be,Le,Ge){if(typeof Le=="object"&&Le!==null&&Le.type===_&&Le.key===null&&(Le=Le.props.children),typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case v:e:{for(var Ot=Le.key;be!==null;){if(be.key===Ot){if(Ot=Le.type,Ot===_){if(be.tag===7){h(we,be.sibling),Ge=T(be,Le.props.children),Ge.return=we,we=Ge;break e}}else if(be.elementType===Ot||typeof Ot=="object"&&Ot!==null&&Ot.$$typeof===z&&wl(Ot)===be.type){h(we,be.sibling),Ge=T(be,Le.props),dd(Ge,Le),Ge.return=we,we=Ge;break e}h(we,be);break}else l(we,be);be=be.sibling}Le.type===_?(Ge=jr(Le.props.children,we.mode,Ge,Le.key),Ge.return=we,we=Ge):(Ge=ad(Le.type,Le.key,Le.props,null,we.mode,Ge),dd(Ge,Le),Ge.return=we,we=Ge)}return U(we);case b:e:{for(Ot=Le.key;be!==null;){if(be.key===Ot)if(be.tag===4&&be.stateNode.containerInfo===Le.containerInfo&&be.stateNode.implementation===Le.implementation){h(we,be.sibling),Ge=T(be,Le.children||[]),Ge.return=we,we=Ge;break e}else{h(we,be);break}else l(we,be);be=be.sibling}Ge=go(Le,we.mode,Ge),Ge.return=we,we=Ge}return U(we);case z:return Le=wl(Le),Mi(we,be,Le,Ge)}if(ie(Le))return At(we,be,Le,Ge);if(X(Le)){if(Ot=X(Le),typeof Ot!="function")throw Error(i(150));return Le=Ot.call(Le),$t(we,be,Le,Ge)}if(typeof Le.then=="function")return Mi(we,be,mf(Le),Ge);if(Le.$$typeof===L)return Mi(we,be,Yt(we,Le),Ge);pf(we,Le)}return typeof Le=="string"&&Le!==""||typeof Le=="number"||typeof Le=="bigint"?(Le=""+Le,be!==null&&be.tag===6?(h(we,be.sibling),Ge=T(be,Le),Ge.return=we,we=Ge):(h(we,be),Ge=bl(Le,we.mode,Ge),Ge.return=we,we=Ge),U(we)):h(we,be)}return function(we,be,Le,Ge){try{cd=0;var Ot=Mi(we,be,Le,Ge);return Eu=null,Ot}catch(Rt){if(Rt===Su||Rt===hf)throw Rt;var _i=fs(29,Rt,null,we.mode);return _i.lanes=Ge,_i.return=we,_i}}}var Cl=hT(!0),fT=hT(!1),xo=!1;function Ng(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Og(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function bo(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function To(a,l,h){var m=a.updateQueue;if(m===null)return null;if(m=m.shared,(wi&2)!==0){var T=m.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),m.pending=l,l=Tu(a),of(a,null,h),l}return bu(a,m,l,h),Tu(a)}function hd(a,l,h){if(l=l.updateQueue,l!==null&&(l=l.shared,(h&4194048)!==0)){var m=l.lanes;m&=a.pendingLanes,h|=m,l.lanes=h,Xi(a,h)}}function Mg(a,l){var h=a.updateQueue,m=a.alternate;if(m!==null&&(m=m.updateQueue,h===m)){var T=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?T=E=U:E=E.next=U,h=h.next}while(h!==null);E===null?T=E=l:E=E.next=l}else T=E=l;h={baseState:m.baseState,firstBaseUpdate:T,lastBaseUpdate:E,shared:m.shared,callbacks:m.callbacks},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=l:a.next=l,h.lastBaseUpdate=l}var Pg=!1;function fd(){if(Pg){var a=js;if(a!==null)throw a}}function md(a,l,h,m){Pg=!1;var T=a.updateQueue;xo=!1;var E=T.firstBaseUpdate,U=T.lastBaseUpdate,Z=T.shared.pending;if(Z!==null){T.shared.pending=null;var ge=Z,Re=ge.next;ge.next=null,U===null?E=Re:U.next=Re,U=ge;var $e=a.alternate;$e!==null&&($e=$e.updateQueue,Z=$e.lastBaseUpdate,Z!==U&&(Z===null?$e.firstBaseUpdate=Re:Z.next=Re,$e.lastBaseUpdate=ge))}if(E!==null){var qe=T.baseState;U=0,$e=Re=ge=null,Z=E;do{var Ne=Z.lane&-536870913,Me=Ne!==Z.lane;if(Me?(mi&Ne)===Ne:(m&Ne)===Ne){Ne!==0&&Ne===rr&&(Pg=!0),$e!==null&&($e=$e.next={lane:0,tag:Z.tag,payload:Z.payload,callback:null,next:null});e:{var At=a,$t=Z;Ne=l;var Mi=h;switch($t.tag){case 1:if(At=$t.payload,typeof At=="function"){qe=At.call(Mi,qe,Ne);break e}qe=At;break e;case 3:At.flags=At.flags&-65537|128;case 0:if(At=$t.payload,Ne=typeof At=="function"?At.call(Mi,qe,Ne):At,Ne==null)break e;qe=p({},qe,Ne);break e;case 2:xo=!0}}Ne=Z.callback,Ne!==null&&(a.flags|=64,Me&&(a.flags|=8192),Me=T.callbacks,Me===null?T.callbacks=[Ne]:Me.push(Ne))}else Me={lane:Ne,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},$e===null?(Re=$e=Me,ge=qe):$e=$e.next=Me,U|=Ne;if(Z=Z.next,Z===null){if(Z=T.shared.pending,Z===null)break;Me=Z,Z=Me.next,Me.next=null,T.lastBaseUpdate=Me,T.shared.pending=null}}while(!0);$e===null&&(ge=qe),T.baseState=ge,T.firstBaseUpdate=Re,T.lastBaseUpdate=$e,E===null&&(T.shared.lanes=0),Ao|=U,a.lanes=U,a.memoizedState=qe}}function mT(a,l){if(typeof a!="function")throw Error(i(191,a));a.call(l)}function pT(a,l){var h=a.callbacks;if(h!==null)for(a.callbacks=null,a=0;a<h.length;a++)mT(h[a],l)}var wu=F(null),gf=F(0);function gT(a,l){a=Ma,pe(gf,a),pe(wu,l),Ma=a|l.baseLanes}function Bg(){pe(gf,Ma),pe(wu,wu.current)}function Fg(){Ma=gf.current,ee(wu),ee(gf)}var Gn=F(null),ar=null;function _o(a){var l=a.alternate;pe(bs,bs.current&1),pe(Gn,a),ar===null&&(l===null||wu.current!==null||l.memoizedState!==null)&&(ar=a)}function Ug(a){pe(bs,bs.current),pe(Gn,a),ar===null&&(ar=a)}function yT(a){a.tag===22?(pe(bs,bs.current),pe(Gn,a),ar===null&&(ar=a)):So()}function So(){pe(bs,bs.current),pe(Gn,Gn.current)}function zn(a){ee(Gn),ar===a&&(ar=null),ee(bs)}var bs=F(0);function yf(a){for(var l=a;l!==null;){if(l.tag===13){var h=l.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||z0(h)||q0(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===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Ca=0,Jt=null,Ni=null,As=null,vf=!1,Au=!1,kl=!1,xf=0,pd=0,Cu=null,dR=0;function ms(){throw Error(i(321))}function jg(a,l){if(l===null)return!1;for(var h=0;h<l.length&&h<a.length;h++)if(!tn(a[h],l[h]))return!1;return!0}function $g(a,l,h,m,T,E){return Ca=E,Jt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Y.H=a===null||a.memoizedState===null?e1:i0,kl=!1,E=h(m,T),kl=!1,Au&&(E=xT(l,h,m,T)),vT(a),E}function vT(a){Y.H=vd;var l=Ni!==null&&Ni.next!==null;if(Ca=0,As=Ni=Jt=null,vf=!1,pd=0,Cu=null,l)throw Error(i(300));a===null||Cs||(a=a.dependencies,a!==null&&ct(a)&&(Cs=!0))}function xT(a,l,h,m){Jt=a;var T=0;do{if(Au&&(Cu=null),pd=0,Au=!1,25<=T)throw Error(i(301));if(T+=1,As=Ni=null,a.updateQueue!=null){var E=a.updateQueue;E.lastEffect=null,E.events=null,E.stores=null,E.memoCache!=null&&(E.memoCache.index=0)}Y.H=t1,E=l(h,m)}while(Au);return E}function hR(){var a=Y.H,l=a.useState()[0];return l=typeof l.then=="function"?gd(l):l,a=a.useState()[0],(Ni!==null?Ni.memoizedState:null)!==a&&(Jt.flags|=1024),l}function Hg(){var a=xf!==0;return xf=0,a}function Vg(a,l,h){l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~h}function Gg(a){if(vf){for(a=a.memoizedState;a!==null;){var l=a.queue;l!==null&&(l.pending=null),a=a.next}vf=!1}Ca=0,As=Ni=Jt=null,Au=!1,pd=xf=0,Cu=null}function dn(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return As===null?Jt.memoizedState=As=a:As=As.next=a,As}function Ts(){if(Ni===null){var a=Jt.alternate;a=a!==null?a.memoizedState:null}else a=Ni.next;var l=As===null?Jt.memoizedState:As.next;if(l!==null)As=l,Ni=a;else{if(a===null)throw Jt.alternate===null?Error(i(467)):Error(i(310));Ni=a,a={memoizedState:Ni.memoizedState,baseState:Ni.baseState,baseQueue:Ni.baseQueue,queue:Ni.queue,next:null},As===null?Jt.memoizedState=As=a:As=As.next=a}return As}function bf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function gd(a){var l=pd;return pd+=1,Cu===null&&(Cu=[]),a=uT(Cu,a,l),l=Jt,(As===null?l.memoizedState:As.next)===null&&(l=l.alternate,Y.H=l===null||l.memoizedState===null?e1:i0),a}function Tf(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return gd(a);if(a.$$typeof===L)return xt(a)}throw Error(i(438,String(a)))}function zg(a){var l=null,h=Jt.updateQueue;if(h!==null&&(l=h.memoCache),l==null){var m=Jt.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(l={data:m.data.map(function(T){return T.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),h===null&&(h=bf(),Jt.updateQueue=h),h.memoCache=l,h=l.data[l.index],h===void 0)for(h=l.data[l.index]=Array(a),m=0;m<a;m++)h[m]=O;return l.index++,h}function ka(a,l){return typeof l=="function"?l(a):l}function _f(a){var l=Ts();return qg(l,Ni,a)}function qg(a,l,h){var m=a.queue;if(m===null)throw Error(i(311));m.lastRenderedReducer=h;var T=a.baseQueue,E=m.pending;if(E!==null){if(T!==null){var U=T.next;T.next=E.next,E.next=U}l.baseQueue=T=E,m.pending=null}if(E=a.baseState,T===null)a.memoizedState=E;else{l=T.next;var Z=U=null,ge=null,Re=l,$e=!1;do{var qe=Re.lane&-536870913;if(qe!==Re.lane?(mi&qe)===qe:(Ca&qe)===qe){var Ne=Re.revertLane;if(Ne===0)ge!==null&&(ge=ge.next={lane:0,revertLane:0,gesture:null,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null}),qe===rr&&($e=!0);else if((Ca&Ne)===Ne){Re=Re.next,Ne===rr&&($e=!0);continue}else qe={lane:0,revertLane:Re.revertLane,gesture:null,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null},ge===null?(Z=ge=qe,U=E):ge=ge.next=qe,Jt.lanes|=Ne,Ao|=Ne;qe=Re.action,kl&&h(E,qe),E=Re.hasEagerState?Re.eagerState:h(E,qe)}else Ne={lane:qe,revertLane:Re.revertLane,gesture:Re.gesture,action:Re.action,hasEagerState:Re.hasEagerState,eagerState:Re.eagerState,next:null},ge===null?(Z=ge=Ne,U=E):ge=ge.next=Ne,Jt.lanes|=qe,Ao|=qe;Re=Re.next}while(Re!==null&&Re!==l);if(ge===null?U=E:ge.next=Z,!tn(E,a.memoizedState)&&(Cs=!0,$e&&(h=js,h!==null)))throw h;a.memoizedState=E,a.baseState=U,a.baseQueue=ge,m.lastRenderedState=E}return T===null&&(m.lanes=0),[a.memoizedState,m.dispatch]}function Kg(a){var l=Ts(),h=l.queue;if(h===null)throw Error(i(311));h.lastRenderedReducer=a;var m=h.dispatch,T=h.pending,E=l.memoizedState;if(T!==null){h.pending=null;var U=T=T.next;do E=a(E,U.action),U=U.next;while(U!==T);tn(E,l.memoizedState)||(Cs=!0),l.memoizedState=E,l.baseQueue===null&&(l.baseState=E),h.lastRenderedState=E}return[E,m]}function bT(a,l,h){var m=Jt,T=Ts(),E=ui;if(E){if(h===void 0)throw Error(i(407));h=h()}else h=l();var U=!tn((Ni||T).memoizedState,h);if(U&&(T.memoizedState=h,Cs=!0),T=T.queue,Xg(ST.bind(null,m,T,a),[a]),T.getSnapshot!==l||U||As!==null&&As.memoizedState.tag&1){if(m.flags|=2048,ku(9,{destroy:void 0},_T.bind(null,m,T,h,l),null),Hi===null)throw Error(i(349));E||(Ca&127)!==0||TT(m,l,h)}return h}function TT(a,l,h){a.flags|=16384,a={getSnapshot:l,value:h},l=Jt.updateQueue,l===null?(l=bf(),Jt.updateQueue=l,l.stores=[a]):(h=l.stores,h===null?l.stores=[a]:h.push(a))}function _T(a,l,h,m){l.value=h,l.getSnapshot=m,ET(l)&&wT(a)}function ST(a,l,h){return h(function(){ET(l)&&wT(a)})}function ET(a){var l=a.getSnapshot;a=a.value;try{var h=l();return!tn(a,h)}catch{return!0}}function wT(a){var l=wa(a,2);l!==null&&Dn(l,a,2)}function Yg(a){var l=dn();if(typeof a=="function"){var h=a;if(a=h(),kl){Lt(!0);try{h()}finally{Lt(!1)}}}return l.memoizedState=l.baseState=a,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:a},l}function AT(a,l,h,m){return a.baseState=h,qg(a,Ni,typeof m=="function"?m:ka)}function fR(a,l,h,m,T){if(wf(a))throw Error(i(485));if(a=l.action,a!==null){var E={payload:T,action:a,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(U){E.listeners.push(U)}};Y.T!==null?h(!0):E.isTransition=!1,m(E),h=l.pending,h===null?(E.next=l.pending=E,CT(l,E)):(E.next=h.next,l.pending=h.next=E)}}function CT(a,l){var h=l.action,m=l.payload,T=a.state;if(l.isTransition){var E=Y.T,U={};Y.T=U;try{var Z=h(T,m),ge=Y.S;ge!==null&&ge(U,Z),kT(a,l,Z)}catch(Re){Wg(a,l,Re)}finally{E!==null&&U.types!==null&&(E.types=U.types),Y.T=E}}else try{E=h(T,m),kT(a,l,E)}catch(Re){Wg(a,l,Re)}}function kT(a,l,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(m){DT(a,l,m)},function(m){return Wg(a,l,m)}):DT(a,l,h)}function DT(a,l,h){l.status="fulfilled",l.value=h,LT(l),a.state=h,l=a.pending,l!==null&&(h=l.next,h===l?a.pending=null:(h=h.next,l.next=h,CT(a,h)))}function Wg(a,l,h){var m=a.pending;if(a.pending=null,m!==null){m=m.next;do l.status="rejected",l.reason=h,LT(l),l=l.next;while(l!==m)}a.action=null}function LT(a){a=a.listeners;for(var l=0;l<a.length;l++)(0,a[l])()}function RT(a,l){return l}function IT(a,l){if(ui){var h=Hi.formState;if(h!==null){e:{var m=Jt;if(ui){if($i){t:{for(var T=$i,E=En;T.nodeType!==8;){if(!E){T=null;break t}if(T=or(T.nextSibling),T===null){T=null;break t}}E=T.data,T=E==="F!"||E==="F"?T:null}if(T){$i=or(T.nextSibling),m=T.data==="F!";break e}}Gr(m)}m=!1}m&&(l=h[0])}}return h=dn(),h.memoizedState=h.baseState=l,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:RT,lastRenderedState:l},h.queue=m,h=QT.bind(null,Jt,m),m.dispatch=h,m=Yg(!1),E=t0.bind(null,Jt,!1,m.queue),m=dn(),T={state:l,dispatch:null,action:a,pending:null},m.queue=T,h=fR.bind(null,Jt,T,E,h),T.dispatch=h,m.memoizedState=a,[l,h,!1]}function NT(a){var l=Ts();return OT(l,Ni,a)}function OT(a,l,h){if(l=qg(a,l,RT)[0],a=_f(ka)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var m=gd(l)}catch(U){throw U===Su?hf:U}else m=l;l=Ts();var T=l.queue,E=T.dispatch;return h!==l.memoizedState&&(Jt.flags|=2048,ku(9,{destroy:void 0},mR.bind(null,T,h),null)),[m,E,a]}function mR(a,l){a.action=l}function MT(a){var l=Ts(),h=Ni;if(h!==null)return OT(l,h,a);Ts(),l=l.memoizedState,h=Ts();var m=h.queue.dispatch;return h.memoizedState=a,[l,m,!1]}function ku(a,l,h,m){return a={tag:a,create:h,deps:m,inst:l,next:null},l=Jt.updateQueue,l===null&&(l=bf(),Jt.updateQueue=l),h=l.lastEffect,h===null?l.lastEffect=a.next=a:(m=h.next,h.next=a,a.next=m,l.lastEffect=a),a}function PT(){return Ts().memoizedState}function Sf(a,l,h,m){var T=dn();Jt.flags|=a,T.memoizedState=ku(1|l,{destroy:void 0},h,m===void 0?null:m)}function Ef(a,l,h,m){var T=Ts();m=m===void 0?null:m;var E=T.memoizedState.inst;Ni!==null&&m!==null&&jg(m,Ni.memoizedState.deps)?T.memoizedState=ku(l,E,h,m):(Jt.flags|=a,T.memoizedState=ku(1|l,E,h,m))}function BT(a,l){Sf(8390656,8,a,l)}function Xg(a,l){Ef(2048,8,a,l)}function pR(a){Jt.flags|=4;var l=Jt.updateQueue;if(l===null)l=bf(),Jt.updateQueue=l,l.events=[a];else{var h=l.events;h===null?l.events=[a]:h.push(a)}}function FT(a){var l=Ts().memoizedState;return pR({ref:l,nextImpl:a}),function(){if((wi&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}function UT(a,l){return Ef(4,2,a,l)}function jT(a,l){return Ef(4,4,a,l)}function $T(a,l){if(typeof l=="function"){a=a();var h=l(a);return function(){typeof h=="function"?h():l(null)}}if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function HT(a,l,h){h=h!=null?h.concat([a]):null,Ef(4,4,$T.bind(null,l,a),h)}function Qg(){}function VT(a,l){var h=Ts();l=l===void 0?null:l;var m=h.memoizedState;return l!==null&&jg(l,m[1])?m[0]:(h.memoizedState=[a,l],a)}function GT(a,l){var h=Ts();l=l===void 0?null:l;var m=h.memoizedState;if(l!==null&&jg(l,m[1]))return m[0];if(m=a(),kl){Lt(!0);try{a()}finally{Lt(!1)}}return h.memoizedState=[m,l],m}function Zg(a,l,h){return h===void 0||(Ca&1073741824)!==0&&(mi&261930)===0?a.memoizedState=l:(a.memoizedState=h,a=z1(),Jt.lanes|=a,Ao|=a,h)}function zT(a,l,h,m){return tn(h,l)?h:wu.current!==null?(a=Zg(a,h,m),tn(a,l)||(Cs=!0),a):(Ca&42)===0||(Ca&1073741824)!==0&&(mi&261930)===0?(Cs=!0,a.memoizedState=h):(a=z1(),Jt.lanes|=a,Ao|=a,l)}function qT(a,l,h,m,T){var E=G.p;G.p=E!==0&&8>E?E:8;var U=Y.T,Z={};Y.T=Z,t0(a,!1,l,h);try{var ge=T(),Re=Y.S;if(Re!==null&&Re(Z,ge),ge!==null&&typeof ge=="object"&&typeof ge.then=="function"){var $e=cR(ge,m);yd(a,l,$e,Yn(a))}else yd(a,l,m,Yn(a))}catch(qe){yd(a,l,{then:function(){},status:"rejected",reason:qe},Yn())}finally{G.p=E,U!==null&&Z.types!==null&&(U.types=Z.types),Y.T=U}}function gR(){}function Jg(a,l,h,m){if(a.tag!==5)throw Error(i(476));var T=KT(a).queue;qT(a,T,l,J,h===null?gR:function(){return YT(a),h(m)})}function KT(a){var l=a.memoizedState;if(l!==null)return l;l={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:J},next:null};var h={};return l.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:h},next:null},a.memoizedState=l,a=a.alternate,a!==null&&(a.memoizedState=l),l}function YT(a){var l=KT(a);l.next===null&&(l=a.alternate.memoizedState),yd(a,l.next.queue,{},Yn())}function e0(){return xt(Od)}function WT(){return Ts().memoizedState}function XT(){return Ts().memoizedState}function yR(a){for(var l=a.return;l!==null;){switch(l.tag){case 24:case 3:var h=Yn();a=bo(h);var m=To(l,a,h);m!==null&&(Dn(m,l,h),hd(m,l,h)),l={cache:Aa()},a.payload=l;return}l=l.return}}function vR(a,l,h){var m=Yn();h={lane:m,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},wf(a)?ZT(l,h):(h=nd(a,l,h,m),h!==null&&(Dn(h,a,m),JT(h,l,m)))}function QT(a,l,h){var m=Yn();yd(a,l,h,m)}function yd(a,l,h,m){var T={lane:m,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(wf(a))ZT(l,T);else{var E=a.alternate;if(a.lanes===0&&(E===null||E.lanes===0)&&(E=l.lastRenderedReducer,E!==null))try{var U=l.lastRenderedState,Z=E(U,h);if(T.hasEagerState=!0,T.eagerState=Z,tn(Z,U))return bu(a,l,T,0),Hi===null&&xu(),!1}catch{}if(h=nd(a,l,T,m),h!==null)return Dn(h,a,m),JT(h,l,m),!0}return!1}function t0(a,l,h,m){if(m={lane:2,revertLane:N0(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},wf(a)){if(l)throw Error(i(479))}else l=nd(a,h,m,2),l!==null&&Dn(l,a,2)}function wf(a){var l=a.alternate;return a===Jt||l!==null&&l===Jt}function ZT(a,l){Au=vf=!0;var h=a.pending;h===null?l.next=l:(l.next=h.next,h.next=l),a.pending=l}function JT(a,l,h){if((h&4194048)!==0){var m=l.lanes;m&=a.pendingLanes,h|=m,l.lanes=h,Xi(a,h)}}var vd={readContext:xt,use:Tf,useCallback:ms,useContext:ms,useEffect:ms,useImperativeHandle:ms,useLayoutEffect:ms,useInsertionEffect:ms,useMemo:ms,useReducer:ms,useRef:ms,useState:ms,useDebugValue:ms,useDeferredValue:ms,useTransition:ms,useSyncExternalStore:ms,useId:ms,useHostTransitionStatus:ms,useFormState:ms,useActionState:ms,useOptimistic:ms,useMemoCache:ms,useCacheRefresh:ms};vd.useEffectEvent=ms;var e1={readContext:xt,use:Tf,useCallback:function(a,l){return dn().memoizedState=[a,l===void 0?null:l],a},useContext:xt,useEffect:BT,useImperativeHandle:function(a,l,h){h=h!=null?h.concat([a]):null,Sf(4194308,4,$T.bind(null,l,a),h)},useLayoutEffect:function(a,l){return Sf(4194308,4,a,l)},useInsertionEffect:function(a,l){Sf(4,2,a,l)},useMemo:function(a,l){var h=dn();l=l===void 0?null:l;var m=a();if(kl){Lt(!0);try{a()}finally{Lt(!1)}}return h.memoizedState=[m,l],m},useReducer:function(a,l,h){var m=dn();if(h!==void 0){var T=h(l);if(kl){Lt(!0);try{h(l)}finally{Lt(!1)}}}else T=l;return m.memoizedState=m.baseState=T,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:T},m.queue=a,a=a.dispatch=vR.bind(null,Jt,a),[m.memoizedState,a]},useRef:function(a){var l=dn();return a={current:a},l.memoizedState=a},useState:function(a){a=Yg(a);var l=a.queue,h=QT.bind(null,Jt,l);return l.dispatch=h,[a.memoizedState,h]},useDebugValue:Qg,useDeferredValue:function(a,l){var h=dn();return Zg(h,a,l)},useTransition:function(){var a=Yg(!1);return a=qT.bind(null,Jt,a.queue,!0,!1),dn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,l,h){var m=Jt,T=dn();if(ui){if(h===void 0)throw Error(i(407));h=h()}else{if(h=l(),Hi===null)throw Error(i(349));(mi&127)!==0||TT(m,l,h)}T.memoizedState=h;var E={value:h,getSnapshot:l};return T.queue=E,BT(ST.bind(null,m,E,a),[a]),m.flags|=2048,ku(9,{destroy:void 0},_T.bind(null,m,E,h,l),null),h},useId:function(){var a=dn(),l=Hi.identifierPrefix;if(ui){var h=qs,m=Vn;h=(m&~(1<<32-Ut(m)-1)).toString(32)+h,l="_"+l+"R_"+h,h=xf++,0<h&&(l+="H"+h.toString(32)),l+="_"}else h=dR++,l="_"+l+"r_"+h.toString(32)+"_";return a.memoizedState=l},useHostTransitionStatus:e0,useFormState:IT,useActionState:IT,useOptimistic:function(a){var l=dn();l.memoizedState=l.baseState=a;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=h,l=t0.bind(null,Jt,!0,h),h.dispatch=l,[a,l]},useMemoCache:zg,useCacheRefresh:function(){return dn().memoizedState=yR.bind(null,Jt)},useEffectEvent:function(a){var l=dn(),h={impl:a};return l.memoizedState=h,function(){if((wi&2)!==0)throw Error(i(440));return h.impl.apply(void 0,arguments)}}},i0={readContext:xt,use:Tf,useCallback:VT,useContext:xt,useEffect:Xg,useImperativeHandle:HT,useInsertionEffect:UT,useLayoutEffect:jT,useMemo:GT,useReducer:_f,useRef:PT,useState:function(){return _f(ka)},useDebugValue:Qg,useDeferredValue:function(a,l){var h=Ts();return zT(h,Ni.memoizedState,a,l)},useTransition:function(){var a=_f(ka)[0],l=Ts().memoizedState;return[typeof a=="boolean"?a:gd(a),l]},useSyncExternalStore:bT,useId:WT,useHostTransitionStatus:e0,useFormState:NT,useActionState:NT,useOptimistic:function(a,l){var h=Ts();return AT(h,Ni,a,l)},useMemoCache:zg,useCacheRefresh:XT};i0.useEffectEvent=FT;var t1={readContext:xt,use:Tf,useCallback:VT,useContext:xt,useEffect:Xg,useImperativeHandle:HT,useInsertionEffect:UT,useLayoutEffect:jT,useMemo:GT,useReducer:Kg,useRef:PT,useState:function(){return Kg(ka)},useDebugValue:Qg,useDeferredValue:function(a,l){var h=Ts();return Ni===null?Zg(h,a,l):zT(h,Ni.memoizedState,a,l)},useTransition:function(){var a=Kg(ka)[0],l=Ts().memoizedState;return[typeof a=="boolean"?a:gd(a),l]},useSyncExternalStore:bT,useId:WT,useHostTransitionStatus:e0,useFormState:MT,useActionState:MT,useOptimistic:function(a,l){var h=Ts();return Ni!==null?AT(h,Ni,a,l):(h.baseState=a,[a,h.queue.dispatch])},useMemoCache:zg,useCacheRefresh:XT};t1.useEffectEvent=FT;function s0(a,l,h,m){l=a.memoizedState,h=h(m,l),h=h==null?l:p({},l,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var n0={enqueueSetState:function(a,l,h){a=a._reactInternals;var m=Yn(),T=bo(m);T.payload=l,h!=null&&(T.callback=h),l=To(a,T,m),l!==null&&(Dn(l,a,m),hd(l,a,m))},enqueueReplaceState:function(a,l,h){a=a._reactInternals;var m=Yn(),T=bo(m);T.tag=1,T.payload=l,h!=null&&(T.callback=h),l=To(a,T,m),l!==null&&(Dn(l,a,m),hd(l,a,m))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var h=Yn(),m=bo(h);m.tag=2,l!=null&&(m.callback=l),l=To(a,m,h),l!==null&&(Dn(l,a,h),hd(l,a,h))}};function i1(a,l,h,m,T,E,U){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(m,E,U):l.prototype&&l.prototype.isPureReactComponent?!Fr(h,m)||!Fr(T,E):!0}function s1(a,l,h,m){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(h,m),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(h,m),l.state!==a&&n0.enqueueReplaceState(l,l.state,null)}function Dl(a,l){var h=l;if("ref"in l){h={};for(var m in l)m!=="ref"&&(h[m]=l[m])}if(a=a.defaultProps){h===l&&(h=p({},h));for(var T in a)h[T]===void 0&&(h[T]=a[T])}return h}function n1(a){fo(a)}function r1(a){console.error(a)}function a1(a){fo(a)}function Af(a,l){try{var h=a.onUncaughtError;h(l.value,{componentStack:l.stack})}catch(m){setTimeout(function(){throw m})}}function o1(a,l,h){try{var m=a.onCaughtError;m(h.value,{componentStack:h.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function r0(a,l,h){return h=bo(h),h.tag=3,h.payload={element:null},h.callback=function(){Af(a,l)},h}function l1(a){return a=bo(a),a.tag=3,a}function u1(a,l,h,m){var T=h.type.getDerivedStateFromError;if(typeof T=="function"){var E=m.value;a.payload=function(){return T(E)},a.callback=function(){o1(l,h,m)}}var U=h.stateNode;U!==null&&typeof U.componentDidCatch=="function"&&(a.callback=function(){o1(l,h,m),typeof T!="function"&&(Co===null?Co=new Set([this]):Co.add(this));var Z=m.stack;this.componentDidCatch(m.value,{componentStack:Z!==null?Z:""})})}function xR(a,l,h,m,T){if(h.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(l=h.alternate,l!==null&&Oe(l,h,T,!0),h=Gn.current,h!==null){switch(h.tag){case 31:case 13:return ar===null?Ff():h.alternate===null&&ps===0&&(ps=3),h.flags&=-257,h.flags|=65536,h.lanes=T,m===ff?h.flags|=16384:(l=h.updateQueue,l===null?h.updateQueue=new Set([m]):l.add(m),L0(a,m,T)),!1;case 22:return h.flags|=65536,m===ff?h.flags|=16384:(l=h.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([m])},h.updateQueue=l):(h=l.retryQueue,h===null?l.retryQueue=new Set([m]):h.add(m)),L0(a,m,T)),!1}throw Error(i(435,h.tag))}return L0(a,m,T),Ff(),!1}if(ui)return l=Gn.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,m!==ld&&(a=Error(i(422),{cause:m}),C(Tn(a,h)))):(m!==ld&&(l=Error(i(423),{cause:m}),C(Tn(l,h))),a=a.current.alternate,a.flags|=65536,T&=-T,a.lanes|=T,m=Tn(m,h),T=r0(a.stateNode,m,T),Mg(a,T),ps!==4&&(ps=2)),!1;var E=Error(i(520),{cause:m});if(E=Tn(E,h),Ad===null?Ad=[E]:Ad.push(E),ps!==4&&(ps=2),l===null)return!0;m=Tn(m,h),h=l;do{switch(h.tag){case 3:return h.flags|=65536,a=T&-T,h.lanes|=a,a=r0(h.stateNode,m,a),Mg(h,a),!1;case 1:if(l=h.type,E=h.stateNode,(h.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||E!==null&&typeof E.componentDidCatch=="function"&&(Co===null||!Co.has(E))))return h.flags|=65536,T&=-T,h.lanes|=T,T=l1(T),u1(T,a,h,m),Mg(h,T),!1}h=h.return}while(h!==null);return!1}var a0=Error(i(461)),Cs=!1;function Ks(a,l,h,m){l.child=a===null?fT(l,null,h,m):Cl(l,a.child,h,m)}function c1(a,l,h,m,T){h=h.render;var E=l.ref;if("ref"in m){var U={};for(var Z in m)Z!=="ref"&&(U[Z]=m[Z])}else U=m;return Ue(l),m=$g(a,l,h,U,E,T),Z=Hg(),a!==null&&!Cs?(Vg(a,l,T),Da(a,l,T)):(ui&&Z&&Rs(l),l.flags|=1,Ks(a,l,m,T),l.child)}function d1(a,l,h,m,T){if(a===null){var E=h.type;return typeof E=="function"&&!rd(E)&&E.defaultProps===void 0&&h.compare===null?(l.tag=15,l.type=E,h1(a,l,E,m,T)):(a=ad(h.type,null,m,l,l.mode,T),a.ref=l.ref,a.return=l,l.child=a)}if(E=a.child,!m0(a,T)){var U=E.memoizedProps;if(h=h.compare,h=h!==null?h:Fr,h(U,m)&&a.ref===l.ref)return Da(a,l,T)}return l.flags|=1,a=_r(E,m),a.ref=l.ref,a.return=l,l.child=a}function h1(a,l,h,m,T){if(a!==null){var E=a.memoizedProps;if(Fr(E,m)&&a.ref===l.ref)if(Cs=!1,l.pendingProps=m=E,m0(a,T))(a.flags&131072)!==0&&(Cs=!0);else return l.lanes=a.lanes,Da(a,l,T)}return o0(a,l,h,m,T)}function f1(a,l,h,m){var T=m.children,E=a!==null?a.memoizedState:null;if(a===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((l.flags&128)!==0){if(E=E!==null?E.baseLanes|h:h,a!==null){for(m=l.child=a.child,T=0;m!==null;)T=T|m.lanes|m.childLanes,m=m.sibling;m=T&~E}else m=0,l.child=null;return m1(a,l,E,h,m)}if((h&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},a!==null&&df(l,E!==null?E.cachePool:null),E!==null?gT(l,E):Bg(),yT(l);else return m=l.lanes=536870912,m1(a,l,E!==null?E.baseLanes|h:h,h,m)}else E!==null?(df(l,E.cachePool),gT(l,E),So(),l.memoizedState=null):(a!==null&&df(l,null),Bg(),So());return Ks(a,l,T,h),l.child}function xd(a,l){return a!==null&&a.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function m1(a,l,h,m,T){var E=Rg();return E=E===null?null:{parent:Ki._currentValue,pool:E},l.memoizedState={baseLanes:h,cachePool:E},a!==null&&df(l,null),Bg(),yT(l),a!==null&&Oe(a,l,m,!0),l.childLanes=T,null}function Cf(a,l){return l=Df({mode:l.mode,children:l.children},a.mode),l.ref=a.ref,a.child=l,l.return=a,l}function p1(a,l,h){return Cl(l,a.child,null,h),a=Cf(l,l.pendingProps),a.flags|=2,zn(l),l.memoizedState=null,a}function bR(a,l,h){var m=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,a===null){if(ui){if(m.mode==="hidden")return a=Cf(l,m),l.lanes=536870912,xd(null,a);if(Ug(l),(a=$i)?(a=C_(a,En),a=a!==null&&a.data==="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:$r!==null?{id:Vn,overflow:qs}:null,retryLane:536870912,hydrationErrors:null},h=od(a),h.return=l,l.child=h,ws=l,$i=null)):a=null,a===null)throw Gr(l);return l.lanes=536870912,null}return Cf(l,m)}var E=a.memoizedState;if(E!==null){var U=E.dehydrated;if(Ug(l),T)if(l.flags&256)l.flags&=-257,l=p1(a,l,h);else if(l.memoizedState!==null)l.child=a.child,l.flags|=128,l=null;else throw Error(i(558));else if(Cs||Oe(a,l,h,!1),T=(h&a.childLanes)!==0,Cs||T){if(m=Hi,m!==null&&(U=rs(m,h),U!==0&&U!==E.retryLane))throw E.retryLane=U,wa(a,U),Dn(m,a,U),a0;Ff(),l=p1(a,l,h)}else a=E.treeContext,$i=or(U.nextSibling),ws=l,ui=!0,Vr=null,En=!1,a!==null&&uf(l,a),l=Cf(l,m),l.flags|=4096;return l}return a=_r(a.child,{mode:m.mode,children:m.children}),a.ref=l.ref,l.child=a,a.return=l,a}function kf(a,l){var h=l.ref;if(h===null)a!==null&&a.ref!==null&&(l.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(i(284));(a===null||a.ref!==h)&&(l.flags|=4194816)}}function o0(a,l,h,m,T){return Ue(l),h=$g(a,l,h,m,void 0,T),m=Hg(),a!==null&&!Cs?(Vg(a,l,T),Da(a,l,T)):(ui&&m&&Rs(l),l.flags|=1,Ks(a,l,h,T),l.child)}function g1(a,l,h,m,T,E){return Ue(l),l.updateQueue=null,h=xT(l,m,h,T),vT(a),m=Hg(),a!==null&&!Cs?(Vg(a,l,E),Da(a,l,E)):(ui&&m&&Rs(l),l.flags|=1,Ks(a,l,h,E),l.child)}function y1(a,l,h,m,T){if(Ue(l),l.stateNode===null){var E=po,U=h.contextType;typeof U=="object"&&U!==null&&(E=xt(U)),E=new h(m,E),l.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,E.updater=n0,l.stateNode=E,E._reactInternals=l,E=l.stateNode,E.props=m,E.state=l.memoizedState,E.refs={},Ng(l),U=h.contextType,E.context=typeof U=="object"&&U!==null?xt(U):po,E.state=l.memoizedState,U=h.getDerivedStateFromProps,typeof U=="function"&&(s0(l,h,U,m),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&&n0.enqueueReplaceState(E,E.state,null),md(l,m,E,T),fd(),E.state=l.memoizedState),typeof E.componentDidMount=="function"&&(l.flags|=4194308),m=!0}else if(a===null){E=l.stateNode;var Z=l.memoizedProps,ge=Dl(h,Z);E.props=ge;var Re=E.context,$e=h.contextType;U=po,typeof $e=="object"&&$e!==null&&(U=xt($e));var qe=h.getDerivedStateFromProps;$e=typeof qe=="function"||typeof E.getSnapshotBeforeUpdate=="function",Z=l.pendingProps!==Z,$e||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(Z||Re!==U)&&s1(l,E,m,U),xo=!1;var Ne=l.memoizedState;E.state=Ne,md(l,m,E,T),fd(),Re=l.memoizedState,Z||Ne!==Re||xo?(typeof qe=="function"&&(s0(l,h,qe,m),Re=l.memoizedState),(ge=xo||i1(l,h,ge,m,Ne,Re,U))?($e||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=m,l.memoizedState=Re),E.props=m,E.state=Re,E.context=U,m=ge):(typeof E.componentDidMount=="function"&&(l.flags|=4194308),m=!1)}else{E=l.stateNode,Og(a,l),U=l.memoizedProps,$e=Dl(h,U),E.props=$e,qe=l.pendingProps,Ne=E.context,Re=h.contextType,ge=po,typeof Re=="object"&&Re!==null&&(ge=xt(Re)),Z=h.getDerivedStateFromProps,(Re=typeof Z=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(U!==qe||Ne!==ge)&&s1(l,E,m,ge),xo=!1,Ne=l.memoizedState,E.state=Ne,md(l,m,E,T),fd();var Me=l.memoizedState;U!==qe||Ne!==Me||xo||a!==null&&a.dependencies!==null&&ct(a.dependencies)?(typeof Z=="function"&&(s0(l,h,Z,m),Me=l.memoizedState),($e=xo||i1(l,h,$e,m,Ne,Me,ge)||a!==null&&a.dependencies!==null&&ct(a.dependencies))?(Re||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(m,Me,ge),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(m,Me,ge)),typeof E.componentDidUpdate=="function"&&(l.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof E.componentDidUpdate!="function"||U===a.memoizedProps&&Ne===a.memoizedState||(l.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||U===a.memoizedProps&&Ne===a.memoizedState||(l.flags|=1024),l.memoizedProps=m,l.memoizedState=Me),E.props=m,E.state=Me,E.context=ge,m=$e):(typeof E.componentDidUpdate!="function"||U===a.memoizedProps&&Ne===a.memoizedState||(l.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||U===a.memoizedProps&&Ne===a.memoizedState||(l.flags|=1024),m=!1)}return E=m,kf(a,l),m=(l.flags&128)!==0,E||m?(E=l.stateNode,h=m&&typeof h.getDerivedStateFromError!="function"?null:E.render(),l.flags|=1,a!==null&&m?(l.child=Cl(l,a.child,null,T),l.child=Cl(l,null,h,T)):Ks(a,l,h,T),l.memoizedState=E.state,a=l.child):a=Da(a,l,T),a}function v1(a,l,h,m){return w(),l.flags|=256,Ks(a,l,h,m),l.child}var l0={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function u0(a){return{baseLanes:a,cachePool:oT()}}function c0(a,l,h){return a=a!==null?a.childLanes&~h:0,l&&(a|=Kn),a}function x1(a,l,h){var m=l.pendingProps,T=!1,E=(l.flags&128)!==0,U;if((U=E)||(U=a!==null&&a.memoizedState===null?!1:(bs.current&2)!==0),U&&(T=!0,l.flags&=-129),U=(l.flags&32)!==0,l.flags&=-33,a===null){if(ui){if(T?_o(l):So(),(a=$i)?(a=C_(a,En),a=a!==null&&a.data!=="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:$r!==null?{id:Vn,overflow:qs}:null,retryLane:536870912,hydrationErrors:null},h=od(a),h.return=l,l.child=h,ws=l,$i=null)):a=null,a===null)throw Gr(l);return q0(a)?l.lanes=32:l.lanes=536870912,null}var Z=m.children;return m=m.fallback,T?(So(),T=l.mode,Z=Df({mode:"hidden",children:Z},T),m=jr(m,T,h,null),Z.return=l,m.return=l,Z.sibling=m,l.child=Z,m=l.child,m.memoizedState=u0(h),m.childLanes=c0(a,U,h),l.memoizedState=l0,xd(null,m)):(_o(l),d0(l,Z))}var ge=a.memoizedState;if(ge!==null&&(Z=ge.dehydrated,Z!==null)){if(E)l.flags&256?(_o(l),l.flags&=-257,l=h0(a,l,h)):l.memoizedState!==null?(So(),l.child=a.child,l.flags|=128,l=null):(So(),Z=m.fallback,T=l.mode,m=Df({mode:"visible",children:m.children},T),Z=jr(Z,T,h,null),Z.flags|=2,m.return=l,Z.return=l,m.sibling=Z,l.child=m,Cl(l,a.child,null,h),m=l.child,m.memoizedState=u0(h),m.childLanes=c0(a,U,h),l.memoizedState=l0,l=xd(null,m));else if(_o(l),q0(Z)){if(U=Z.nextSibling&&Z.nextSibling.dataset,U)var Re=U.dgst;U=Re,m=Error(i(419)),m.stack="",m.digest=U,C({value:m,source:null,stack:null}),l=h0(a,l,h)}else if(Cs||Oe(a,l,h,!1),U=(h&a.childLanes)!==0,Cs||U){if(U=Hi,U!==null&&(m=rs(U,h),m!==0&&m!==ge.retryLane))throw ge.retryLane=m,wa(a,m),Dn(U,a,m),a0;z0(Z)||Ff(),l=h0(a,l,h)}else z0(Z)?(l.flags|=192,l.child=a.child,l=null):(a=ge.treeContext,$i=or(Z.nextSibling),ws=l,ui=!0,Vr=null,En=!1,a!==null&&uf(l,a),l=d0(l,m.children),l.flags|=4096);return l}return T?(So(),Z=m.fallback,T=l.mode,ge=a.child,Re=ge.sibling,m=_r(ge,{mode:"hidden",children:m.children}),m.subtreeFlags=ge.subtreeFlags&65011712,Re!==null?Z=_r(Re,Z):(Z=jr(Z,T,h,null),Z.flags|=2),Z.return=l,m.return=l,m.sibling=Z,l.child=m,xd(null,m),m=l.child,Z=a.child.memoizedState,Z===null?Z=u0(h):(T=Z.cachePool,T!==null?(ge=Ki._currentValue,T=T.parent!==ge?{parent:ge,pool:ge}:T):T=oT(),Z={baseLanes:Z.baseLanes|h,cachePool:T}),m.memoizedState=Z,m.childLanes=c0(a,U,h),l.memoizedState=l0,xd(a.child,m)):(_o(l),h=a.child,a=h.sibling,h=_r(h,{mode:"visible",children:m.children}),h.return=l,h.sibling=null,a!==null&&(U=l.deletions,U===null?(l.deletions=[a],l.flags|=16):U.push(a)),l.child=h,l.memoizedState=null,h)}function d0(a,l){return l=Df({mode:"visible",children:l},a.mode),l.return=a,a.child=l}function Df(a,l){return a=fs(22,a,null,l),a.lanes=0,a}function h0(a,l,h){return Cl(l,a.child,null,h),a=d0(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function b1(a,l,h){a.lanes|=l;var m=a.alternate;m!==null&&(m.lanes|=l),fe(a.return,l,h)}function f0(a,l,h,m,T,E){var U=a.memoizedState;U===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:m,tail:h,tailMode:T,treeForkCount:E}:(U.isBackwards=l,U.rendering=null,U.renderingStartTime=0,U.last=m,U.tail=h,U.tailMode=T,U.treeForkCount=E)}function T1(a,l,h){var m=l.pendingProps,T=m.revealOrder,E=m.tail;m=m.children;var U=bs.current,Z=(U&2)!==0;if(Z?(U=U&1|2,l.flags|=128):U&=1,pe(bs,U),Ks(a,l,m,h),m=ui?_l:0,!Z&&a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&b1(a,h,l);else if(a.tag===19)b1(a,h,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}switch(T){case"forwards":for(h=l.child,T=null;h!==null;)a=h.alternate,a!==null&&yf(a)===null&&(T=h),h=h.sibling;h=T,h===null?(T=l.child,l.child=null):(T=h.sibling,h.sibling=null),f0(l,!1,T,h,E,m);break;case"backwards":case"unstable_legacy-backwards":for(h=null,T=l.child,l.child=null;T!==null;){if(a=T.alternate,a!==null&&yf(a)===null){l.child=T;break}a=T.sibling,T.sibling=h,h=T,T=a}f0(l,!0,h,null,E,m);break;case"together":f0(l,!1,null,null,void 0,m);break;default:l.memoizedState=null}return l.child}function Da(a,l,h){if(a!==null&&(l.dependencies=a.dependencies),Ao|=l.lanes,(h&l.childLanes)===0)if(a!==null){if(Oe(a,l,h,!1),(h&l.childLanes)===0)return null}else return null;if(a!==null&&l.child!==a.child)throw Error(i(153));if(l.child!==null){for(a=l.child,h=_r(a,a.pendingProps),l.child=h,h.return=l;a.sibling!==null;)a=a.sibling,h=h.sibling=_r(a,a.pendingProps),h.return=l;h.sibling=null}return l.child}function m0(a,l){return(a.lanes&l)!==0?!0:(a=a.dependencies,!!(a!==null&&ct(a)))}function TR(a,l,h){switch(l.tag){case 3:tt(l,l.stateNode.containerInfo),ne(l,Ki,a.memoizedState.cache),w();break;case 27:case 5:Ct(l);break;case 4:tt(l,l.stateNode.containerInfo);break;case 10:ne(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Ug(l),null;break;case 13:var m=l.memoizedState;if(m!==null)return m.dehydrated!==null?(_o(l),l.flags|=128,null):(h&l.child.childLanes)!==0?x1(a,l,h):(_o(l),a=Da(a,l,h),a!==null?a.sibling:null);_o(l);break;case 19:var T=(a.flags&128)!==0;if(m=(h&l.childLanes)!==0,m||(Oe(a,l,h,!1),m=(h&l.childLanes)!==0),T){if(m)return T1(a,l,h);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),pe(bs,bs.current),m)break;return null;case 22:return l.lanes=0,f1(a,l,h,l.pendingProps);case 24:ne(l,Ki,a.memoizedState.cache)}return Da(a,l,h)}function _1(a,l,h){if(a!==null)if(a.memoizedProps!==l.pendingProps)Cs=!0;else{if(!m0(a,h)&&(l.flags&128)===0)return Cs=!1,TR(a,l,h);Cs=(a.flags&131072)!==0}else Cs=!1,ui&&(l.flags&1048576)!==0&&Hr(l,_l,l.index);switch(l.lanes=0,l.tag){case 16:e:{var m=l.pendingProps;if(a=wl(l.elementType),l.type=a,typeof a=="function")rd(a)?(m=Dl(a,m),l.tag=1,l=y1(null,l,a,m,h)):(l.tag=0,l=o0(null,l,a,m,h));else{if(a!=null){var T=a.$$typeof;if(T===M){l.tag=11,l=c1(null,l,a,m,h);break e}else if(T===P){l.tag=14,l=d1(null,l,a,m,h);break e}}throw l=ue(a)||a,Error(i(306,l,""))}}return l;case 0:return o0(a,l,l.type,l.pendingProps,h);case 1:return m=l.type,T=Dl(m,l.pendingProps),y1(a,l,m,T,h);case 3:e:{if(tt(l,l.stateNode.containerInfo),a===null)throw Error(i(387));m=l.pendingProps;var E=l.memoizedState;T=E.element,Og(a,l),md(l,m,null,h);var U=l.memoizedState;if(m=U.cache,ne(l,Ki,m),m!==E.cache&&Se(l,[Ki],h,!0),fd(),m=U.element,E.isDehydrated)if(E={element:m,isDehydrated:!1,cache:U.cache},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){l=v1(a,l,m,h);break e}else if(m!==T){T=Tn(Error(i(424)),l),C(T),l=v1(a,l,m,h);break e}else for(a=l.stateNode.containerInfo,a.nodeType===9?a=a.body:a=a.nodeName==="HTML"?a.ownerDocument.body:a,$i=or(a.firstChild),ws=l,ui=!0,Vr=null,En=!0,h=fT(l,null,m,h),l.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(w(),m===T){l=Da(a,l,h);break e}Ks(a,l,m,h)}l=l.child}return l;case 26:return kf(a,l),a===null?(h=N_(l.type,null,l.pendingProps,null))?l.memoizedState=h:ui||(h=l.type,a=l.pendingProps,m=zf(Ce.current).createElement(h),m[Wt]=l,m[Kt]=a,Ys(m,h,a),se(m),l.stateNode=m):l.memoizedState=N_(l.type,a.memoizedProps,l.pendingProps,a.memoizedState),null;case 27:return Ct(l),a===null&&ui&&(m=l.stateNode=L_(l.type,l.pendingProps,Ce.current),ws=l,En=!0,T=$i,Ro(l.type)?(K0=T,$i=or(m.firstChild)):$i=T),Ks(a,l,l.pendingProps.children,h),kf(a,l),a===null&&(l.flags|=4194304),l.child;case 5:return a===null&&ui&&((T=m=$i)&&(m=QR(m,l.type,l.pendingProps,En),m!==null?(l.stateNode=m,ws=l,$i=or(m.firstChild),En=!1,T=!0):T=!1),T||Gr(l)),Ct(l),T=l.type,E=l.pendingProps,U=a!==null?a.memoizedProps:null,m=E.children,H0(T,E)?m=null:U!==null&&H0(T,U)&&(l.flags|=32),l.memoizedState!==null&&(T=$g(a,l,hR,null,null,h),Od._currentValue=T),kf(a,l),Ks(a,l,m,h),l.child;case 6:return a===null&&ui&&((a=h=$i)&&(h=ZR(h,l.pendingProps,En),h!==null?(l.stateNode=h,ws=l,$i=null,a=!0):a=!1),a||Gr(l)),null;case 13:return x1(a,l,h);case 4:return tt(l,l.stateNode.containerInfo),m=l.pendingProps,a===null?l.child=Cl(l,null,m,h):Ks(a,l,m,h),l.child;case 11:return c1(a,l,l.type,l.pendingProps,h);case 7:return Ks(a,l,l.pendingProps,h),l.child;case 8:return Ks(a,l,l.pendingProps.children,h),l.child;case 12:return Ks(a,l,l.pendingProps.children,h),l.child;case 10:return m=l.pendingProps,ne(l,l.type,m.value),Ks(a,l,m.children,h),l.child;case 9:return T=l.type._context,m=l.pendingProps.children,Ue(l),T=xt(T),m=m(T),l.flags|=1,Ks(a,l,m,h),l.child;case 14:return d1(a,l,l.type,l.pendingProps,h);case 15:return h1(a,l,l.type,l.pendingProps,h);case 19:return T1(a,l,h);case 31:return bR(a,l,h);case 22:return f1(a,l,h,l.pendingProps);case 24:return Ue(l),m=xt(Ki),a===null?(T=Rg(),T===null&&(T=Hi,E=Aa(),T.pooledCache=E,E.refCount++,E!==null&&(T.pooledCacheLanes|=h),T=E),l.memoizedState={parent:m,cache:T},Ng(l),ne(l,Ki,T)):((a.lanes&h)!==0&&(Og(a,l),md(l,null,null,h),fd()),T=a.memoizedState,E=l.memoizedState,T.parent!==m?(T={parent:m,cache:m},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),ne(l,Ki,m)):(m=E.cache,ne(l,Ki,m),m!==T.cache&&Se(l,[Ki],h,!0))),Ks(a,l,l.pendingProps.children,h),l.child;case 29:throw l.pendingProps}throw Error(i(156,l.tag))}function La(a){a.flags|=4}function p0(a,l,h,m,T){if((l=(a.mode&32)!==0)&&(l=!1),l){if(a.flags|=16777216,(T&335544128)===T)if(a.stateNode.complete)a.flags|=8192;else if(W1())a.flags|=8192;else throw Al=ff,Ig}else a.flags&=-16777217}function S1(a,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!F_(l))if(W1())a.flags|=8192;else throw Al=ff,Ig}function Lf(a,l){l!==null&&(a.flags|=4),a.flags&16384&&(l=a.tag!==22?Ye():536870912,a.lanes|=l,Iu|=l)}function bd(a,l){if(!ui)switch(a.tailMode){case"hidden":l=a.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var m=null;h!==null;)h.alternate!==null&&(m=h),h=h.sibling;m===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:m.sibling=null}}function Zi(a){var l=a.alternate!==null&&a.alternate.child===a.child,h=0,m=0;if(l)for(var T=a.child;T!==null;)h|=T.lanes|T.childLanes,m|=T.subtreeFlags&65011712,m|=T.flags&65011712,T.return=a,T=T.sibling;else for(T=a.child;T!==null;)h|=T.lanes|T.childLanes,m|=T.subtreeFlags,m|=T.flags,T.return=a,T=T.sibling;return a.subtreeFlags|=m,a.childLanes=h,l}function _R(a,l,h){var m=l.pendingProps;switch(Sn(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zi(l),null;case 1:return Zi(l),null;case 3:return h=l.stateNode,m=null,a!==null&&(m=a.memoizedState.cache),l.memoizedState.cache!==m&&(l.flags|=2048),le(Ki),Je(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(a===null||a.child===null)&&(x(l)?La(l):a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,k())),Zi(l),null;case 26:var T=l.type,E=l.memoizedState;return a===null?(La(l),E!==null?(Zi(l),S1(l,E)):(Zi(l),p0(l,T,null,m,h))):E?E!==a.memoizedState?(La(l),Zi(l),S1(l,E)):(Zi(l),l.flags&=-16777217):(a=a.memoizedProps,a!==m&&La(l),Zi(l),p0(l,T,a,m,h)),null;case 27:if(st(l),h=Ce.current,T=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==m&&La(l);else{if(!m){if(l.stateNode===null)throw Error(i(166));return Zi(l),null}a=_e.current,x(l)?cf(l):(a=L_(T,m,h),l.stateNode=a,La(l))}return Zi(l),null;case 5:if(st(l),T=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==m&&La(l);else{if(!m){if(l.stateNode===null)throw Error(i(166));return Zi(l),null}if(E=_e.current,x(l))cf(l);else{var U=zf(Ce.current);switch(E){case 1:E=U.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:E=U.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":E=U.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":E=U.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":E=U.createElement("div"),E.innerHTML="<script><\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof m.is=="string"?U.createElement("select",{is:m.is}):U.createElement("select"),m.multiple?E.multiple=!0:m.size&&(E.size=m.size);break;default:E=typeof m.is=="string"?U.createElement(T,{is:m.is}):U.createElement(T)}}E[Wt]=l,E[Kt]=m;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(Ys(E,T,m),T){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&La(l)}}return Zi(l),p0(l,l.type,a===null?null:a.memoizedProps,l.pendingProps,h),null;case 6:if(a&&l.stateNode!=null)a.memoizedProps!==m&&La(l);else{if(typeof m!="string"&&l.stateNode===null)throw Error(i(166));if(a=Ce.current,x(l)){if(a=l.stateNode,h=l.memoizedProps,m=null,T=ws,T!==null)switch(T.tag){case 27:case 5:m=T.memoizedProps}a[Wt]=l,a=!!(a.nodeValue===h||m!==null&&m.suppressHydrationWarning===!0||x_(a.nodeValue,h)),a||Gr(l,!0)}else a=zf(a).createTextNode(m),a[Wt]=l,l.stateNode=a}return Zi(l),null;case 31:if(h=l.memoizedState,a===null||a.memoizedState!==null){if(m=x(l),h!==null){if(a===null){if(!m)throw Error(i(318));if(a=l.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(557));a[Wt]=l}else w(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Zi(l),a=!1}else h=k(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=h),a=!0;if(!a)return l.flags&256?(zn(l),l):(zn(l),null);if((l.flags&128)!==0)throw Error(i(558))}return Zi(l),null;case 13:if(m=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(T=x(l),m!==null&&m.dehydrated!==null){if(a===null){if(!T)throw Error(i(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(i(317));T[Wt]=l}else w(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Zi(l),T=!1}else T=k(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(zn(l),l):(zn(l),null)}return zn(l),(l.flags&128)!==0?(l.lanes=h,l):(h=m!==null,a=a!==null&&a.memoizedState!==null,h&&(m=l.child,T=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(T=m.alternate.memoizedState.cachePool.pool),E=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(E=m.memoizedState.cachePool.pool),E!==T&&(m.flags|=2048)),h!==a&&h&&(l.child.flags|=8192),Lf(l,l.updateQueue),Zi(l),null);case 4:return Je(),a===null&&B0(l.stateNode.containerInfo),Zi(l),null;case 10:return le(l.type),Zi(l),null;case 19:if(ee(bs),m=l.memoizedState,m===null)return Zi(l),null;if(T=(l.flags&128)!==0,E=m.rendering,E===null)if(T)bd(m,!1);else{if(ps!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(E=yf(a),E!==null){for(l.flags|=128,bd(m,!1),a=E.updateQueue,l.updateQueue=a,Lf(l,a),l.subtreeFlags=0,a=h,h=l.child;h!==null;)lf(h,a),h=h.sibling;return pe(bs,bs.current&1|2),ui&&ii(l,m.treeForkCount),l.child}a=a.sibling}m.tail!==null&&We()>Mf&&(l.flags|=128,T=!0,bd(m,!1),l.lanes=4194304)}else{if(!T)if(a=yf(E),a!==null){if(l.flags|=128,T=!0,a=a.updateQueue,l.updateQueue=a,Lf(l,a),bd(m,!0),m.tail===null&&m.tailMode==="hidden"&&!E.alternate&&!ui)return Zi(l),null}else 2*We()-m.renderingStartTime>Mf&&h!==536870912&&(l.flags|=128,T=!0,bd(m,!1),l.lanes=4194304);m.isBackwards?(E.sibling=l.child,l.child=E):(a=m.last,a!==null?a.sibling=E:l.child=E,m.last=E)}return m.tail!==null?(a=m.tail,m.rendering=a,m.tail=a.sibling,m.renderingStartTime=We(),a.sibling=null,h=bs.current,pe(bs,T?h&1|2:h&1),ui&&ii(l,m.treeForkCount),a):(Zi(l),null);case 22:case 23:return zn(l),Fg(),m=l.memoizedState!==null,a!==null?a.memoizedState!==null!==m&&(l.flags|=8192):m&&(l.flags|=8192),m?(h&536870912)!==0&&(l.flags&128)===0&&(Zi(l),l.subtreeFlags&6&&(l.flags|=8192)):Zi(l),h=l.updateQueue,h!==null&&Lf(l,h.retryQueue),h=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(h=a.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==h&&(l.flags|=2048),a!==null&&ee(El),null;case 24:return h=null,a!==null&&(h=a.memoizedState.cache),l.memoizedState.cache!==h&&(l.flags|=2048),le(Ki),Zi(l),null;case 25:return null;case 30:return null}throw Error(i(156,l.tag))}function SR(a,l){switch(Sn(l),l.tag){case 1:return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return le(Ki),Je(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 26:case 27:case 5:return st(l),null;case 31:if(l.memoizedState!==null){if(zn(l),l.alternate===null)throw Error(i(340));w()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 13:if(zn(l),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(i(340));w()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return ee(bs),null;case 4:return Je(),null;case 10:return le(l.type),null;case 22:case 23:return zn(l),Fg(),a!==null&&ee(El),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 24:return le(Ki),null;case 25:return null;default:return null}}function E1(a,l){switch(Sn(l),l.tag){case 3:le(Ki),Je();break;case 26:case 27:case 5:st(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&zn(l);break;case 13:zn(l);break;case 19:ee(bs);break;case 10:le(l.type);break;case 22:case 23:zn(l),Fg(),a!==null&&ee(El);break;case 24:le(Ki)}}function Td(a,l){try{var h=l.updateQueue,m=h!==null?h.lastEffect:null;if(m!==null){var T=m.next;h=T;do{if((h.tag&a)===a){m=void 0;var E=h.create,U=h.inst;m=E(),U.destroy=m}h=h.next}while(h!==T)}}catch(Z){Di(l,l.return,Z)}}function Eo(a,l,h){try{var m=l.updateQueue,T=m!==null?m.lastEffect:null;if(T!==null){var E=T.next;m=E;do{if((m.tag&a)===a){var U=m.inst,Z=U.destroy;if(Z!==void 0){U.destroy=void 0,T=l;var ge=h,Re=Z;try{Re()}catch($e){Di(T,ge,$e)}}}m=m.next}while(m!==E)}}catch($e){Di(l,l.return,$e)}}function w1(a){var l=a.updateQueue;if(l!==null){var h=a.stateNode;try{pT(l,h)}catch(m){Di(a,a.return,m)}}}function A1(a,l,h){h.props=Dl(a.type,a.memoizedProps),h.state=a.memoizedState;try{h.componentWillUnmount()}catch(m){Di(a,l,m)}}function _d(a,l){try{var h=a.ref;if(h!==null){switch(a.tag){case 26:case 27:case 5:var m=a.stateNode;break;case 30:m=a.stateNode;break;default:m=a.stateNode}typeof h=="function"?a.refCleanup=h(m):h.current=m}}catch(T){Di(a,l,T)}}function Kr(a,l){var h=a.ref,m=a.refCleanup;if(h!==null)if(typeof m=="function")try{m()}catch(T){Di(a,l,T)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(T){Di(a,l,T)}else h.current=null}function C1(a){var l=a.type,h=a.memoizedProps,m=a.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":h.autoFocus&&m.focus();break e;case"img":h.src?m.src=h.src:h.srcSet&&(m.srcset=h.srcSet)}}catch(T){Di(a,a.return,T)}}function g0(a,l,h){try{var m=a.stateNode;zR(m,a.type,h,l),m[Kt]=l}catch(T){Di(a,a.return,T)}}function k1(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Ro(a.type)||a.tag===4}function y0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||k1(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Ro(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function v0(a,l,h){var m=a.tag;if(m===5||m===6)a=a.stateNode,l?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(a,l):(l=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,l.appendChild(a),h=h._reactRootContainer,h!=null||l.onclick!==null||(l.onclick=xr));else if(m!==4&&(m===27&&Ro(a.type)&&(h=a.stateNode,l=null),a=a.child,a!==null))for(v0(a,l,h),a=a.sibling;a!==null;)v0(a,l,h),a=a.sibling}function Rf(a,l,h){var m=a.tag;if(m===5||m===6)a=a.stateNode,l?h.insertBefore(a,l):h.appendChild(a);else if(m!==4&&(m===27&&Ro(a.type)&&(h=a.stateNode),a=a.child,a!==null))for(Rf(a,l,h),a=a.sibling;a!==null;)Rf(a,l,h),a=a.sibling}function D1(a){var l=a.stateNode,h=a.memoizedProps;try{for(var m=a.type,T=l.attributes;T.length;)l.removeAttributeNode(T[0]);Ys(l,m,h),l[Wt]=a,l[Kt]=h}catch(E){Di(a,a.return,E)}}var Ra=!1,ks=!1,x0=!1,L1=typeof WeakSet=="function"?WeakSet:Set,$s=null;function ER(a,l){if(a=a.containerInfo,j0=Zf,a=yu(a),Qc(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var m=h.getSelection&&h.getSelection();if(m&&m.rangeCount!==0){h=m.anchorNode;var T=m.anchorOffset,E=m.focusNode;m=m.focusOffset;try{h.nodeType,E.nodeType}catch{h=null;break e}var U=0,Z=-1,ge=-1,Re=0,$e=0,qe=a,Ne=null;t:for(;;){for(var Me;qe!==h||T!==0&&qe.nodeType!==3||(Z=U+T),qe!==E||m!==0&&qe.nodeType!==3||(ge=U+m),qe.nodeType===3&&(U+=qe.nodeValue.length),(Me=qe.firstChild)!==null;)Ne=qe,qe=Me;for(;;){if(qe===a)break t;if(Ne===h&&++Re===T&&(Z=U),Ne===E&&++$e===m&&(ge=U),(Me=qe.nextSibling)!==null)break;qe=Ne,Ne=qe.parentNode}qe=Me}h=Z===-1||ge===-1?null:{start:Z,end:ge}}else h=null}h=h||{start:0,end:0}}else h=null;for($0={focusedElem:a,selectionRange:h},Zf=!1,$s=l;$s!==null;)if(l=$s,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,$s=a;else for(;$s!==null;){switch(l=$s,E=l.alternate,a=l.flags,l.tag){case 0:if((a&4)!==0&&(a=l.updateQueue,a=a!==null?a.events:null,a!==null))for(h=0;h<a.length;h++)T=a[h],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&E!==null){a=void 0,h=l,T=E.memoizedProps,E=E.memoizedState,m=h.stateNode;try{var At=Dl(h.type,T);a=m.getSnapshotBeforeUpdate(At,E),m.__reactInternalSnapshotBeforeUpdate=a}catch($t){Di(h,h.return,$t)}}break;case 3:if((a&1024)!==0){if(a=l.stateNode.containerInfo,h=a.nodeType,h===9)G0(a);else if(h===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":G0(a);break;default:a.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((a&1024)!==0)throw Error(i(163))}if(a=l.sibling,a!==null){a.return=l.return,$s=a;break}$s=l.return}}function R1(a,l,h){var m=h.flags;switch(h.tag){case 0:case 11:case 15:Na(a,h),m&4&&Td(5,h);break;case 1:if(Na(a,h),m&4)if(a=h.stateNode,l===null)try{a.componentDidMount()}catch(U){Di(h,h.return,U)}else{var T=Dl(h.type,l.memoizedProps);l=l.memoizedState;try{a.componentDidUpdate(T,l,a.__reactInternalSnapshotBeforeUpdate)}catch(U){Di(h,h.return,U)}}m&64&&w1(h),m&512&&_d(h,h.return);break;case 3:if(Na(a,h),m&64&&(a=h.updateQueue,a!==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{pT(a,l)}catch(U){Di(h,h.return,U)}}break;case 27:l===null&&m&4&&D1(h);case 26:case 5:Na(a,h),l===null&&m&4&&C1(h),m&512&&_d(h,h.return);break;case 12:Na(a,h);break;case 31:Na(a,h),m&4&&O1(a,h);break;case 13:Na(a,h),m&4&&M1(a,h),m&64&&(a=h.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(h=NR.bind(null,h),JR(a,h))));break;case 22:if(m=h.memoizedState!==null||Ra,!m){l=l!==null&&l.memoizedState!==null||ks,T=Ra;var E=ks;Ra=m,(ks=l)&&!E?Oa(a,h,(h.subtreeFlags&8772)!==0):Na(a,h),Ra=T,ks=E}break;case 30:break;default:Na(a,h)}}function I1(a){var l=a.alternate;l!==null&&(a.alternate=null,I1(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&li(l)),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}var ts=null,wn=!1;function Ia(a,l,h){for(h=h.child;h!==null;)N1(a,l,h),h=h.sibling}function N1(a,l,h){if(Qe&&typeof Qe.onCommitFiberUnmount=="function")try{Qe.onCommitFiberUnmount(hi,h)}catch{}switch(h.tag){case 26:ks||Kr(h,l),Ia(a,l,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:ks||Kr(h,l);var m=ts,T=wn;Ro(h.type)&&(ts=h.stateNode,wn=!1),Ia(a,l,h),Rd(h.stateNode),ts=m,wn=T;break;case 5:ks||Kr(h,l);case 6:if(m=ts,T=wn,ts=null,Ia(a,l,h),ts=m,wn=T,ts!==null)if(wn)try{(ts.nodeType===9?ts.body:ts.nodeName==="HTML"?ts.ownerDocument.body:ts).removeChild(h.stateNode)}catch(E){Di(h,l,E)}else try{ts.removeChild(h.stateNode)}catch(E){Di(h,l,E)}break;case 18:ts!==null&&(wn?(a=ts,w_(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,h.stateNode),ju(a)):w_(ts,h.stateNode));break;case 4:m=ts,T=wn,ts=h.stateNode.containerInfo,wn=!0,Ia(a,l,h),ts=m,wn=T;break;case 0:case 11:case 14:case 15:Eo(2,h,l),ks||Eo(4,h,l),Ia(a,l,h);break;case 1:ks||(Kr(h,l),m=h.stateNode,typeof m.componentWillUnmount=="function"&&A1(h,l,m)),Ia(a,l,h);break;case 21:Ia(a,l,h);break;case 22:ks=(m=ks)||h.memoizedState!==null,Ia(a,l,h),ks=m;break;default:Ia(a,l,h)}}function O1(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{ju(a)}catch(h){Di(l,l.return,h)}}}function M1(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{ju(a)}catch(h){Di(l,l.return,h)}}function wR(a){switch(a.tag){case 31:case 13:case 19:var l=a.stateNode;return l===null&&(l=a.stateNode=new L1),l;case 22:return a=a.stateNode,l=a._retryCache,l===null&&(l=a._retryCache=new L1),l;default:throw Error(i(435,a.tag))}}function If(a,l){var h=wR(a);l.forEach(function(m){if(!h.has(m)){h.add(m);var T=OR.bind(null,a,m);m.then(T,T)}})}function An(a,l){var h=l.deletions;if(h!==null)for(var m=0;m<h.length;m++){var T=h[m],E=a,U=l,Z=U;e:for(;Z!==null;){switch(Z.tag){case 27:if(Ro(Z.type)){ts=Z.stateNode,wn=!1;break e}break;case 5:ts=Z.stateNode,wn=!1;break e;case 3:case 4:ts=Z.stateNode.containerInfo,wn=!0;break e}Z=Z.return}if(ts===null)throw Error(i(160));N1(E,U,T),ts=null,wn=!1,E=T.alternate,E!==null&&(E.return=null),T.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)P1(l,a),l=l.sibling}var Er=null;function P1(a,l){var h=a.alternate,m=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:An(l,a),Cn(a),m&4&&(Eo(3,a,a.return),Td(3,a),Eo(5,a,a.return));break;case 1:An(l,a),Cn(a),m&512&&(ks||h===null||Kr(h,h.return)),m&64&&Ra&&(a=a.updateQueue,a!==null&&(m=a.callbacks,m!==null&&(h=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=h===null?m:h.concat(m))));break;case 26:var T=Er;if(An(l,a),Cn(a),m&512&&(ks||h===null||Kr(h,h.return)),m&4){var E=h!==null?h.memoizedState:null;if(m=a.memoizedState,h===null)if(m===null)if(a.stateNode===null){e:{m=a.type,h=a.memoizedProps,T=T.ownerDocument||T;t:switch(m){case"title":E=T.getElementsByTagName("title")[0],(!E||E[fi]||E[Wt]||E.namespaceURI==="http://www.w3.org/2000/svg"||E.hasAttribute("itemprop"))&&(E=T.createElement(m),T.head.insertBefore(E,T.querySelector("head > title"))),Ys(E,m,h),E[Wt]=a,se(E),m=E;break e;case"link":var U=P_("link","href",T).get(m+(h.href||""));if(U){for(var Z=0;Z<U.length;Z++)if(E=U[Z],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(Z,1);break t}}E=T.createElement(m),Ys(E,m,h),T.head.appendChild(E);break;case"meta":if(U=P_("meta","content",T).get(m+(h.content||""))){for(Z=0;Z<U.length;Z++)if(E=U[Z],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(Z,1);break t}}E=T.createElement(m),Ys(E,m,h),T.head.appendChild(E);break;default:throw Error(i(468,m))}E[Wt]=a,se(E),m=E}a.stateNode=m}else B_(T,a.type,a.stateNode);else a.stateNode=M_(T,m,a.memoizedProps);else E!==m?(E===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):E.count--,m===null?B_(T,a.type,a.stateNode):M_(T,m,a.memoizedProps)):m===null&&a.stateNode!==null&&g0(a,a.memoizedProps,h.memoizedProps)}break;case 27:An(l,a),Cn(a),m&512&&(ks||h===null||Kr(h,h.return)),h!==null&&m&4&&g0(a,a.memoizedProps,h.memoizedProps);break;case 5:if(An(l,a),Cn(a),m&512&&(ks||h===null||Kr(h,h.return)),a.flags&32){T=a.stateNode;try{un(T,"")}catch(At){Di(a,a.return,At)}}m&4&&a.stateNode!=null&&(T=a.memoizedProps,g0(a,T,h!==null?h.memoizedProps:T)),m&1024&&(x0=!0);break;case 6:if(An(l,a),Cn(a),m&4){if(a.stateNode===null)throw Error(i(162));m=a.memoizedProps,h=a.stateNode;try{h.nodeValue=m}catch(At){Di(a,a.return,At)}}break;case 3:if(Yf=null,T=Er,Er=qf(l.containerInfo),An(l,a),Er=T,Cn(a),m&4&&h!==null&&h.memoizedState.isDehydrated)try{ju(l.containerInfo)}catch(At){Di(a,a.return,At)}x0&&(x0=!1,B1(a));break;case 4:m=Er,Er=qf(a.stateNode.containerInfo),An(l,a),Cn(a),Er=m;break;case 12:An(l,a),Cn(a);break;case 31:An(l,a),Cn(a),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,If(a,m)));break;case 13:An(l,a),Cn(a),a.child.flags&8192&&a.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(Of=We()),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,If(a,m)));break;case 22:T=a.memoizedState!==null;var ge=h!==null&&h.memoizedState!==null,Re=Ra,$e=ks;if(Ra=Re||T,ks=$e||ge,An(l,a),ks=$e,Ra=Re,Cn(a),m&8192)e:for(l=a.stateNode,l._visibility=T?l._visibility&-2:l._visibility|1,T&&(h===null||ge||Ra||ks||Ll(a)),h=null,l=a;;){if(l.tag===5||l.tag===26){if(h===null){ge=h=l;try{if(E=ge.stateNode,T)U=E.style,typeof U.setProperty=="function"?U.setProperty("display","none","important"):U.display="none";else{Z=ge.stateNode;var qe=ge.memoizedProps.style,Ne=qe!=null&&qe.hasOwnProperty("display")?qe.display:null;Z.style.display=Ne==null||typeof Ne=="boolean"?"":(""+Ne).trim()}}catch(At){Di(ge,ge.return,At)}}}else if(l.tag===6){if(h===null){ge=l;try{ge.stateNode.nodeValue=T?"":ge.memoizedProps}catch(At){Di(ge,ge.return,At)}}}else if(l.tag===18){if(h===null){ge=l;try{var Me=ge.stateNode;T?A_(Me,!0):A_(ge.stateNode,!1)}catch(At){Di(ge,ge.return,At)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===a)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break e;for(;l.sibling===null;){if(l.return===null||l.return===a)break e;h===l&&(h=null),l=l.return}h===l&&(h=null),l.sibling.return=l.return,l=l.sibling}m&4&&(m=a.updateQueue,m!==null&&(h=m.retryQueue,h!==null&&(m.retryQueue=null,If(a,h))));break;case 19:An(l,a),Cn(a),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,If(a,m)));break;case 30:break;case 21:break;default:An(l,a),Cn(a)}}function Cn(a){var l=a.flags;if(l&2){try{for(var h,m=a.return;m!==null;){if(k1(m)){h=m;break}m=m.return}if(h==null)throw Error(i(160));switch(h.tag){case 27:var T=h.stateNode,E=y0(a);Rf(a,E,T);break;case 5:var U=h.stateNode;h.flags&32&&(un(U,""),h.flags&=-33);var Z=y0(a);Rf(a,Z,U);break;case 3:case 4:var ge=h.stateNode.containerInfo,Re=y0(a);v0(a,Re,ge);break;default:throw Error(i(161))}}catch($e){Di(a,a.return,$e)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function B1(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var l=a;B1(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),a=a.sibling}}function Na(a,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)R1(a,l.alternate,l),l=l.sibling}function Ll(a){for(a=a.child;a!==null;){var l=a;switch(l.tag){case 0:case 11:case 14:case 15:Eo(4,l,l.return),Ll(l);break;case 1:Kr(l,l.return);var h=l.stateNode;typeof h.componentWillUnmount=="function"&&A1(l,l.return,h),Ll(l);break;case 27:Rd(l.stateNode);case 26:case 5:Kr(l,l.return),Ll(l);break;case 22:l.memoizedState===null&&Ll(l);break;case 30:Ll(l);break;default:Ll(l)}a=a.sibling}}function Oa(a,l,h){for(h=h&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var m=l.alternate,T=a,E=l,U=E.flags;switch(E.tag){case 0:case 11:case 15:Oa(T,E,h),Td(4,E);break;case 1:if(Oa(T,E,h),m=E,T=m.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(Re){Di(m,m.return,Re)}if(m=E,T=m.updateQueue,T!==null){var Z=m.stateNode;try{var ge=T.shared.hiddenCallbacks;if(ge!==null)for(T.shared.hiddenCallbacks=null,T=0;T<ge.length;T++)mT(ge[T],Z)}catch(Re){Di(m,m.return,Re)}}h&&U&64&&w1(E),_d(E,E.return);break;case 27:D1(E);case 26:case 5:Oa(T,E,h),h&&m===null&&U&4&&C1(E),_d(E,E.return);break;case 12:Oa(T,E,h);break;case 31:Oa(T,E,h),h&&U&4&&O1(T,E);break;case 13:Oa(T,E,h),h&&U&4&&M1(T,E);break;case 22:E.memoizedState===null&&Oa(T,E,h),_d(E,E.return);break;case 30:break;default:Oa(T,E,h)}l=l.sibling}}function b0(a,l){var h=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(h=a.memoizedState.cachePool.pool),a=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(a=l.memoizedState.cachePool.pool),a!==h&&(a!=null&&a.refCount++,h!=null&&Sr(h))}function T0(a,l){a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Sr(a))}function wr(a,l,h,m){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)F1(a,l,h,m),l=l.sibling}function F1(a,l,h,m){var T=l.flags;switch(l.tag){case 0:case 11:case 15:wr(a,l,h,m),T&2048&&Td(9,l);break;case 1:wr(a,l,h,m);break;case 3:wr(a,l,h,m),T&2048&&(a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Sr(a)));break;case 12:if(T&2048){wr(a,l,h,m),a=l.stateNode;try{var E=l.memoizedProps,U=E.id,Z=E.onPostCommit;typeof Z=="function"&&Z(U,l.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(ge){Di(l,l.return,ge)}}else wr(a,l,h,m);break;case 31:wr(a,l,h,m);break;case 13:wr(a,l,h,m);break;case 23:break;case 22:E=l.stateNode,U=l.alternate,l.memoizedState!==null?E._visibility&2?wr(a,l,h,m):Sd(a,l):E._visibility&2?wr(a,l,h,m):(E._visibility|=2,Du(a,l,h,m,(l.subtreeFlags&10256)!==0||!1)),T&2048&&b0(U,l);break;case 24:wr(a,l,h,m),T&2048&&T0(l.alternate,l);break;default:wr(a,l,h,m)}}function Du(a,l,h,m,T){for(T=T&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var E=a,U=l,Z=h,ge=m,Re=U.flags;switch(U.tag){case 0:case 11:case 15:Du(E,U,Z,ge,T),Td(8,U);break;case 23:break;case 22:var $e=U.stateNode;U.memoizedState!==null?$e._visibility&2?Du(E,U,Z,ge,T):Sd(E,U):($e._visibility|=2,Du(E,U,Z,ge,T)),T&&Re&2048&&b0(U.alternate,U);break;case 24:Du(E,U,Z,ge,T),T&&Re&2048&&T0(U.alternate,U);break;default:Du(E,U,Z,ge,T)}l=l.sibling}}function Sd(a,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var h=a,m=l,T=m.flags;switch(m.tag){case 22:Sd(h,m),T&2048&&b0(m.alternate,m);break;case 24:Sd(h,m),T&2048&&T0(m.alternate,m);break;default:Sd(h,m)}l=l.sibling}}var Ed=8192;function Lu(a,l,h){if(a.subtreeFlags&Ed)for(a=a.child;a!==null;)U1(a,l,h),a=a.sibling}function U1(a,l,h){switch(a.tag){case 26:Lu(a,l,h),a.flags&Ed&&a.memoizedState!==null&&dI(h,Er,a.memoizedState,a.memoizedProps);break;case 5:Lu(a,l,h);break;case 3:case 4:var m=Er;Er=qf(a.stateNode.containerInfo),Lu(a,l,h),Er=m;break;case 22:a.memoizedState===null&&(m=a.alternate,m!==null&&m.memoizedState!==null?(m=Ed,Ed=16777216,Lu(a,l,h),Ed=m):Lu(a,l,h));break;default:Lu(a,l,h)}}function j1(a){var l=a.alternate;if(l!==null&&(a=l.child,a!==null)){l.child=null;do l=a.sibling,a.sibling=null,a=l;while(a!==null)}}function wd(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var m=l[h];$s=m,H1(m,a)}j1(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)$1(a),a=a.sibling}function $1(a){switch(a.tag){case 0:case 11:case 15:wd(a),a.flags&2048&&Eo(9,a,a.return);break;case 3:wd(a);break;case 12:wd(a);break;case 22:var l=a.stateNode;a.memoizedState!==null&&l._visibility&2&&(a.return===null||a.return.tag!==13)?(l._visibility&=-3,Nf(a)):wd(a);break;default:wd(a)}}function Nf(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var m=l[h];$s=m,H1(m,a)}j1(a)}for(a=a.child;a!==null;){switch(l=a,l.tag){case 0:case 11:case 15:Eo(8,l,l.return),Nf(l);break;case 22:h=l.stateNode,h._visibility&2&&(h._visibility&=-3,Nf(l));break;default:Nf(l)}a=a.sibling}}function H1(a,l){for(;$s!==null;){var h=$s;switch(h.tag){case 0:case 11:case 15:Eo(8,h,l);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var m=h.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:Sr(h.memoizedState.cache)}if(m=h.child,m!==null)m.return=h,$s=m;else e:for(h=a;$s!==null;){m=$s;var T=m.sibling,E=m.return;if(I1(m),m===h){$s=null;break e}if(T!==null){T.return=E,$s=T;break e}$s=E}}}var AR={getCacheForType:function(a){var l=xt(Ki),h=l.data.get(a);return h===void 0&&(h=a(),l.data.set(a,h)),h},cacheSignal:function(){return xt(Ki).controller.signal}},CR=typeof WeakMap=="function"?WeakMap:Map,wi=0,Hi=null,ci=null,mi=0,ki=0,qn=null,wo=!1,Ru=!1,_0=!1,Ma=0,ps=0,Ao=0,Rl=0,S0=0,Kn=0,Iu=0,Ad=null,kn=null,E0=!1,Of=0,V1=0,Mf=1/0,Pf=null,Co=null,Is=0,ko=null,Nu=null,Pa=0,w0=0,A0=null,G1=null,Cd=0,C0=null;function Yn(){return(wi&2)!==0&&mi!==0?mi&-mi:Y.T!==null?N0():Fi()}function z1(){if(Kn===0)if((mi&536870912)===0||ui){var a=ri;ri<<=1,(ri&3932160)===0&&(ri=262144),Kn=a}else Kn=536870912;return a=Gn.current,a!==null&&(a.flags|=32),Kn}function Dn(a,l,h){(a===Hi&&(ki===2||ki===9)||a.cancelPendingCommit!==null)&&(Ou(a,0),Do(a,mi,Kn,!1)),zt(a,h),((wi&2)===0||a!==Hi)&&(a===Hi&&((wi&2)===0&&(Rl|=h),ps===4&&Do(a,mi,Kn,!1)),Yr(a))}function q1(a,l,h){if((wi&6)!==0)throw Error(i(327));var m=!h&&(l&127)===0&&(l&a.expiredLanes)===0||re(a,l),T=m?LR(a,l):D0(a,l,!0),E=m;do{if(T===0){Ru&&!m&&Do(a,l,0,!1);break}else{if(h=a.current.alternate,E&&!kR(h)){T=D0(a,l,!1),E=!1;continue}if(T===2){if(E=l,a.errorRecoveryDisabledLanes&E)var U=0;else U=a.pendingLanes&-536870913,U=U!==0?U:U&536870912?536870912:0;if(U!==0){l=U;e:{var Z=a;T=Ad;var ge=Z.current.memoizedState.isDehydrated;if(ge&&(Ou(Z,U).flags|=256),U=D0(Z,U,!1),U!==2){if(_0&&!ge){Z.errorRecoveryDisabledLanes|=E,Rl|=E,T=4;break e}E=kn,kn=T,E!==null&&(kn===null?kn=E:kn.push.apply(kn,E))}T=U}if(E=!1,T!==2)continue}}if(T===1){Ou(a,0),Do(a,l,0,!0);break}e:{switch(m=a,E=T,E){case 0:case 1:throw Error(i(345));case 4:if((l&4194048)!==l)break;case 6:Do(m,l,Kn,!wo);break e;case 2:kn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((l&62914560)===l&&(T=Of+300-We(),10<T)){if(Do(m,l,Kn,!wo),K(m,0,!0)!==0)break e;Pa=l,m.timeoutHandle=S_(K1.bind(null,m,h,kn,Pf,E0,l,Kn,Rl,Iu,wo,E,"Throttled",-0,0),T);break e}K1(m,h,kn,Pf,E0,l,Kn,Rl,Iu,wo,E,null,-0,0)}}break}while(!0);Yr(a)}function K1(a,l,h,m,T,E,U,Z,ge,Re,$e,qe,Ne,Me){if(a.timeoutHandle=-1,qe=l.subtreeFlags,qe&8192||(qe&16785408)===16785408){qe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:xr},U1(l,E,qe);var At=(E&62914560)===E?Of-We():(E&4194048)===E?V1-We():0;if(At=hI(qe,At),At!==null){Pa=E,a.cancelPendingCommit=At(t_.bind(null,a,l,E,h,m,T,U,Z,ge,$e,qe,null,Ne,Me)),Do(a,E,U,!Re);return}}t_(a,l,E,h,m,T,U,Z,ge)}function kR(a){for(var l=a;;){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 m=0;m<h.length;m++){var T=h[m],E=T.getSnapshot;T=T.value;try{if(!tn(E(),T))return!1}catch{return!1}}if(h=l.child,l.subtreeFlags&16384&&h!==null)h.return=l,l=h;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Do(a,l,h,m){l&=~S0,l&=~Rl,a.suspendedLanes|=l,a.pingedLanes&=~l,m&&(a.warmLanes|=l),m=a.expirationTimes;for(var T=l;0<T;){var E=31-Ut(T),U=1<<E;m[E]=-1,T&=~U}h!==0&&Wi(a,h,l)}function Bf(){return(wi&6)===0?(kd(0),!1):!0}function k0(){if(ci!==null){if(ki===0)var a=ci.return;else a=ci,te=B=null,Gg(a),Eu=null,cd=0,a=ci;for(;a!==null;)E1(a.alternate,a),a=a.return;ci=null}}function Ou(a,l){var h=a.timeoutHandle;h!==-1&&(a.timeoutHandle=-1,YR(h)),h=a.cancelPendingCommit,h!==null&&(a.cancelPendingCommit=null,h()),Pa=0,k0(),Hi=a,ci=h=_r(a.current,null),mi=l,ki=0,qn=null,wo=!1,Ru=re(a,l),_0=!1,Iu=Kn=S0=Rl=Ao=ps=0,kn=Ad=null,E0=!1,(l&8)!==0&&(l|=l&32);var m=a.entangledLanes;if(m!==0)for(a=a.entanglements,m&=l;0<m;){var T=31-Ut(m),E=1<<T;l|=a[T],m&=~E}return Ma=l,xu(),h}function Y1(a,l){Jt=null,Y.H=vd,l===Su||l===hf?(l=cT(),ki=3):l===Ig?(l=cT(),ki=4):ki=l===a0?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,qn=l,ci===null&&(ps=1,Af(a,Tn(l,a.current)))}function W1(){var a=Gn.current;return a===null?!0:(mi&4194048)===mi?ar===null:(mi&62914560)===mi||(mi&536870912)!==0?a===ar:!1}function X1(){var a=Y.H;return Y.H=vd,a===null?vd:a}function Q1(){var a=Y.A;return Y.A=AR,a}function Ff(){ps=4,wo||(mi&4194048)!==mi&&Gn.current!==null||(Ru=!0),(Ao&134217727)===0&&(Rl&134217727)===0||Hi===null||Do(Hi,mi,Kn,!1)}function D0(a,l,h){var m=wi;wi|=2;var T=X1(),E=Q1();(Hi!==a||mi!==l)&&(Pf=null,Ou(a,l)),l=!1;var U=ps;e:do try{if(ki!==0&&ci!==null){var Z=ci,ge=qn;switch(ki){case 8:k0(),U=6;break e;case 3:case 2:case 9:case 6:Gn.current===null&&(l=!0);var Re=ki;if(ki=0,qn=null,Mu(a,Z,ge,Re),h&&Ru){U=0;break e}break;default:Re=ki,ki=0,qn=null,Mu(a,Z,ge,Re)}}DR(),U=ps;break}catch($e){Y1(a,$e)}while(!0);return l&&a.shellSuspendCounter++,te=B=null,wi=m,Y.H=T,Y.A=E,ci===null&&(Hi=null,mi=0,xu()),U}function DR(){for(;ci!==null;)Z1(ci)}function LR(a,l){var h=wi;wi|=2;var m=X1(),T=Q1();Hi!==a||mi!==l?(Pf=null,Mf=We()+500,Ou(a,l)):Ru=re(a,l);e:do try{if(ki!==0&&ci!==null){l=ci;var E=qn;t:switch(ki){case 1:ki=0,qn=null,Mu(a,l,E,1);break;case 2:case 9:if(lT(E)){ki=0,qn=null,J1(l);break}l=function(){ki!==2&&ki!==9||Hi!==a||(ki=7),Yr(a)},E.then(l,l);break e;case 3:ki=7;break e;case 4:ki=5;break e;case 7:lT(E)?(ki=0,qn=null,J1(l)):(ki=0,qn=null,Mu(a,l,E,7));break;case 5:var U=null;switch(ci.tag){case 26:U=ci.memoizedState;case 5:case 27:var Z=ci;if(U?F_(U):Z.stateNode.complete){ki=0,qn=null;var ge=Z.sibling;if(ge!==null)ci=ge;else{var Re=Z.return;Re!==null?(ci=Re,Uf(Re)):ci=null}break t}}ki=0,qn=null,Mu(a,l,E,5);break;case 6:ki=0,qn=null,Mu(a,l,E,6);break;case 8:k0(),ps=6;break e;default:throw Error(i(462))}}RR();break}catch($e){Y1(a,$e)}while(!0);return te=B=null,Y.H=m,Y.A=T,wi=h,ci!==null?0:(Hi=null,mi=0,xu(),ps)}function RR(){for(;ci!==null&&!ye();)Z1(ci)}function Z1(a){var l=_1(a.alternate,a,Ma);a.memoizedProps=a.pendingProps,l===null?Uf(a):ci=l}function J1(a){var l=a,h=l.alternate;switch(l.tag){case 15:case 0:l=g1(h,l,l.pendingProps,l.type,void 0,mi);break;case 11:l=g1(h,l,l.pendingProps,l.type.render,l.ref,mi);break;case 5:Gg(l);default:E1(h,l),l=ci=lf(l,Ma),l=_1(h,l,Ma)}a.memoizedProps=a.pendingProps,l===null?Uf(a):ci=l}function Mu(a,l,h,m){te=B=null,Gg(l),Eu=null,cd=0;var T=l.return;try{if(xR(a,T,l,h,mi)){ps=1,Af(a,Tn(h,a.current)),ci=null;return}}catch(E){if(T!==null)throw ci=T,E;ps=1,Af(a,Tn(h,a.current)),ci=null;return}l.flags&32768?(ui||m===1?a=!0:Ru||(mi&536870912)!==0?a=!1:(wo=a=!0,(m===2||m===9||m===3||m===6)&&(m=Gn.current,m!==null&&m.tag===13&&(m.flags|=16384))),e_(l,a)):Uf(l)}function Uf(a){var l=a;do{if((l.flags&32768)!==0){e_(l,wo);return}a=l.return;var h=_R(l.alternate,l,Ma);if(h!==null){ci=h;return}if(l=l.sibling,l!==null){ci=l;return}ci=l=a}while(l!==null);ps===0&&(ps=5)}function e_(a,l){do{var h=SR(a.alternate,a);if(h!==null){h.flags&=32767,ci=h;return}if(h=a.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!l&&(a=a.sibling,a!==null)){ci=a;return}ci=a=h}while(a!==null);ps=6,ci=null}function t_(a,l,h,m,T,E,U,Z,ge){a.cancelPendingCommit=null;do jf();while(Is!==0);if((wi&6)!==0)throw Error(i(327));if(l!==null){if(l===a.current)throw Error(i(177));if(E=l.lanes|l.childLanes,E|=sd,xi(a,h,E,U,Z,ge),a===Hi&&(ci=Hi=null,mi=0),Nu=l,ko=a,Pa=h,w0=E,A0=T,G1=m,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,MR(vt,function(){return a_(),null})):(a.callbackNode=null,a.callbackPriority=0),m=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||m){m=Y.T,Y.T=null,T=G.p,G.p=2,U=wi,wi|=4;try{ER(a,l,h)}finally{wi=U,G.p=T,Y.T=m}}Is=1,i_(),s_(),n_()}}function i_(){if(Is===1){Is=0;var a=ko,l=Nu,h=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||h){h=Y.T,Y.T=null;var m=G.p;G.p=2;var T=wi;wi|=4;try{P1(l,a);var E=$0,U=yu(a.containerInfo),Z=E.focusedElem,ge=E.selectionRange;if(U!==Z&&Z&&Z.ownerDocument&&Sa(Z.ownerDocument.documentElement,Z)){if(ge!==null&&Qc(Z)){var Re=ge.start,$e=ge.end;if($e===void 0&&($e=Re),"selectionStart"in Z)Z.selectionStart=Re,Z.selectionEnd=Math.min($e,Z.value.length);else{var qe=Z.ownerDocument||document,Ne=qe&&qe.defaultView||window;if(Ne.getSelection){var Me=Ne.getSelection(),At=Z.textContent.length,$t=Math.min(ge.start,At),Mi=ge.end===void 0?$t:Math.min(ge.end,At);!Me.extend&&$t>Mi&&(U=Mi,Mi=$t,$t=U);var we=es(Z,$t),be=es(Z,Mi);if(we&&be&&(Me.rangeCount!==1||Me.anchorNode!==we.node||Me.anchorOffset!==we.offset||Me.focusNode!==be.node||Me.focusOffset!==be.offset)){var Le=qe.createRange();Le.setStart(we.node,we.offset),Me.removeAllRanges(),$t>Mi?(Me.addRange(Le),Me.extend(be.node,be.offset)):(Le.setEnd(be.node,be.offset),Me.addRange(Le))}}}}for(qe=[],Me=Z;Me=Me.parentNode;)Me.nodeType===1&&qe.push({element:Me,left:Me.scrollLeft,top:Me.scrollTop});for(typeof Z.focus=="function"&&Z.focus(),Z=0;Z<qe.length;Z++){var Ge=qe[Z];Ge.element.scrollLeft=Ge.left,Ge.element.scrollTop=Ge.top}}Zf=!!j0,$0=j0=null}finally{wi=T,G.p=m,Y.T=h}}a.current=l,Is=2}}function s_(){if(Is===2){Is=0;var a=ko,l=Nu,h=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||h){h=Y.T,Y.T=null;var m=G.p;G.p=2;var T=wi;wi|=4;try{R1(a,l.alternate,l)}finally{wi=T,G.p=m,Y.T=h}}Is=3}}function n_(){if(Is===4||Is===3){Is=0,ze();var a=ko,l=Nu,h=Pa,m=G1;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Is=5:(Is=0,Nu=ko=null,r_(a,a.pendingLanes));var T=a.pendingLanes;if(T===0&&(Co=null),ai(h),l=l.stateNode,Qe&&typeof Qe.onCommitFiberRoot=="function")try{Qe.onCommitFiberRoot(hi,l,void 0,(l.current.flags&128)===128)}catch{}if(m!==null){l=Y.T,T=G.p,G.p=2,Y.T=null;try{for(var E=a.onRecoverableError,U=0;U<m.length;U++){var Z=m[U];E(Z.value,{componentStack:Z.stack})}}finally{Y.T=l,G.p=T}}(Pa&3)!==0&&jf(),Yr(a),T=a.pendingLanes,(h&261930)!==0&&(T&42)!==0?a===C0?Cd++:(Cd=0,C0=a):Cd=0,kd(0)}}function r_(a,l){(a.pooledCacheLanes&=l)===0&&(l=a.pooledCache,l!=null&&(a.pooledCache=null,Sr(l)))}function jf(){return i_(),s_(),n_(),a_()}function a_(){if(Is!==5)return!1;var a=ko,l=w0;w0=0;var h=ai(Pa),m=Y.T,T=G.p;try{G.p=32>h?32:h,Y.T=null,h=A0,A0=null;var E=ko,U=Pa;if(Is=0,Nu=ko=null,Pa=0,(wi&6)!==0)throw Error(i(331));var Z=wi;if(wi|=4,$1(E.current),F1(E,E.current,U,h),wi=Z,kd(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot=="function")try{Qe.onPostCommitFiberRoot(hi,E)}catch{}return!0}finally{G.p=T,Y.T=m,r_(a,l)}}function o_(a,l,h){l=Tn(h,l),l=r0(a.stateNode,l,2),a=To(a,l,2),a!==null&&(zt(a,2),Yr(a))}function Di(a,l,h){if(a.tag===3)o_(a,a,h);else for(;l!==null;){if(l.tag===3){o_(l,a,h);break}else if(l.tag===1){var m=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Co===null||!Co.has(m))){a=Tn(h,a),h=l1(2),m=To(l,h,2),m!==null&&(u1(h,m,l,a),zt(m,2),Yr(m));break}}l=l.return}}function L0(a,l,h){var m=a.pingCache;if(m===null){m=a.pingCache=new CR;var T=new Set;m.set(l,T)}else T=m.get(l),T===void 0&&(T=new Set,m.set(l,T));T.has(h)||(_0=!0,T.add(h),a=IR.bind(null,a,l,h),l.then(a,a))}function IR(a,l,h){var m=a.pingCache;m!==null&&m.delete(l),a.pingedLanes|=a.suspendedLanes&h,a.warmLanes&=~h,Hi===a&&(mi&h)===h&&(ps===4||ps===3&&(mi&62914560)===mi&&300>We()-Of?(wi&2)===0&&Ou(a,0):S0|=h,Iu===mi&&(Iu=0)),Yr(a)}function l_(a,l){l===0&&(l=Ye()),a=wa(a,l),a!==null&&(zt(a,l),Yr(a))}function NR(a){var l=a.memoizedState,h=0;l!==null&&(h=l.retryLane),l_(a,h)}function OR(a,l){var h=0;switch(a.tag){case 31:case 13:var m=a.stateNode,T=a.memoizedState;T!==null&&(h=T.retryLane);break;case 19:m=a.stateNode;break;case 22:m=a.stateNode._retryCache;break;default:throw Error(i(314))}m!==null&&m.delete(l),l_(a,h)}function MR(a,l){return dt(a,l)}var $f=null,Pu=null,R0=!1,Hf=!1,I0=!1,Lo=0;function Yr(a){a!==Pu&&a.next===null&&(Pu===null?$f=Pu=a:Pu=Pu.next=a),Hf=!0,R0||(R0=!0,BR())}function kd(a,l){if(!I0&&Hf){I0=!0;do for(var h=!1,m=$f;m!==null;){if(a!==0){var T=m.pendingLanes;if(T===0)var E=0;else{var U=m.suspendedLanes,Z=m.pingedLanes;E=(1<<31-Ut(42|a)+1)-1,E&=T&~(U&~Z),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(h=!0,h_(m,E))}else E=mi,E=K(m,m===Hi?E:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(E&3)===0||re(m,E)||(h=!0,h_(m,E));m=m.next}while(h);I0=!1}}function PR(){u_()}function u_(){Hf=R0=!1;var a=0;Lo!==0&&KR()&&(a=Lo);for(var l=We(),h=null,m=$f;m!==null;){var T=m.next,E=c_(m,l);E===0?(m.next=null,h===null?$f=T:h.next=T,T===null&&(Pu=h)):(h=m,(a!==0||(E&3)!==0)&&(Hf=!0)),m=T}Is!==0&&Is!==5||kd(a),Lo!==0&&(Lo=0)}function c_(a,l){for(var h=a.suspendedLanes,m=a.pingedLanes,T=a.expirationTimes,E=a.pendingLanes&-62914561;0<E;){var U=31-Ut(E),Z=1<<U,ge=T[U];ge===-1?((Z&h)===0||(Z&m)!==0)&&(T[U]=Ee(Z,l)):ge<=l&&(a.expiredLanes|=Z),E&=~Z}if(l=Hi,h=mi,h=K(a,a===l?h:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),m=a.callbackNode,h===0||a===l&&(ki===2||ki===9)||a.cancelPendingCommit!==null)return m!==null&&m!==null&&lt(m),a.callbackNode=null,a.callbackPriority=0;if((h&3)===0||re(a,h)){if(l=h&-h,l===a.callbackPriority)return l;switch(m!==null&&lt(m),ai(h)){case 2:case 8:h=nt;break;case 32:h=vt;break;case 268435456:h=Ft;break;default:h=vt}return m=d_.bind(null,a),h=dt(h,m),a.callbackPriority=l,a.callbackNode=h,l}return m!==null&&m!==null&&lt(m),a.callbackPriority=2,a.callbackNode=null,2}function d_(a,l){if(Is!==0&&Is!==5)return a.callbackNode=null,a.callbackPriority=0,null;var h=a.callbackNode;if(jf()&&a.callbackNode!==h)return null;var m=mi;return m=K(a,a===Hi?m:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),m===0?null:(q1(a,m,l),c_(a,We()),a.callbackNode!=null&&a.callbackNode===h?d_.bind(null,a):null)}function h_(a,l){if(jf())return null;q1(a,l,!0)}function BR(){WR(function(){(wi&6)!==0?dt(ot,PR):u_()})}function N0(){if(Lo===0){var a=rr;a===0&&(a=ht,ht<<=1,(ht&261888)===0&&(ht=256)),Lo=a}return Lo}function f_(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:nu(""+a)}function m_(a,l){var h=l.ownerDocument.createElement("input");return h.name=l.name,h.value=l.value,a.id&&h.setAttribute("form",a.id),l.parentNode.insertBefore(h,l),a=new FormData(a),h.parentNode.removeChild(h),a}function FR(a,l,h,m,T){if(l==="submit"&&h&&h.stateNode===T){var E=f_((T[Kt]||null).action),U=m.submitter;U&&(l=(l=U[Kt]||null)?f_(l.formAction):U.getAttribute("formAction"),l!==null&&(E=l,U=null));var Z=new cu("action","action",null,m,T);a.push({event:Z,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(Lo!==0){var ge=U?m_(T,U):new FormData(T);Jg(h,{pending:!0,data:ge,method:T.method,action:E},null,ge)}}else typeof E=="function"&&(Z.preventDefault(),ge=U?m_(T,U):new FormData(T),Jg(h,{pending:!0,data:ge,method:T.method,action:E},E,ge))},currentTarget:T}]})}}for(var O0=0;O0<id.length;O0++){var M0=id[O0],UR=M0.toLowerCase(),jR=M0[0].toUpperCase()+M0.slice(1);Hn(UR,"on"+jR)}Hn(tf,"onAnimationEnd"),Hn(ho,"onAnimationIteration"),Hn(sf,"onAnimationStart"),Hn("dblclick","onDoubleClick"),Hn("focusin","onFocus"),Hn("focusout","onBlur"),Hn(nf,"onTransitionRun"),Hn(rf,"onTransitionStart"),Hn(Dg,"onTransitionCancel"),Hn(af,"onTransitionEnd"),je("onMouseEnter",["mouseout","mouseover"]),je("onMouseLeave",["mouseout","mouseover"]),je("onPointerEnter",["pointerout","pointerover"]),je("onPointerLeave",["pointerout","pointerover"]),Te("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Te("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Te("onBeforeInput",["compositionend","keypress","textInput","paste"]),Te("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Te("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Te("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dd="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(" "),$R=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Dd));function p_(a,l){l=(l&4)!==0;for(var h=0;h<a.length;h++){var m=a[h],T=m.event;m=m.listeners;e:{var E=void 0;if(l)for(var U=m.length-1;0<=U;U--){var Z=m[U],ge=Z.instance,Re=Z.currentTarget;if(Z=Z.listener,ge!==E&&T.isPropagationStopped())break e;E=Z,T.currentTarget=Re;try{E(T)}catch($e){fo($e)}T.currentTarget=null,E=ge}else for(U=0;U<m.length;U++){if(Z=m[U],ge=Z.instance,Re=Z.currentTarget,Z=Z.listener,ge!==E&&T.isPropagationStopped())break e;E=Z,T.currentTarget=Re;try{E(T)}catch($e){fo($e)}T.currentTarget=null,E=ge}}}}function di(a,l){var h=l[Ii];h===void 0&&(h=l[Ii]=new Set);var m=a+"__bubble";h.has(m)||(g_(l,a,2,!1),h.add(m))}function P0(a,l,h){var m=0;l&&(m|=4),g_(h,a,m,l)}var Vf="_reactListening"+Math.random().toString(36).slice(2);function B0(a){if(!a[Vf]){a[Vf]=!0,ae.forEach(function(h){h!=="selectionchange"&&($R.has(h)||P0(h,!1,a),P0(h,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Vf]||(l[Vf]=!0,P0("selectionchange",!1,l))}}function g_(a,l,h,m){switch(z_(l)){case 2:var T=pI;break;case 8:T=gI;break;default:T=Z0}h=T.bind(null,l,h,a),T=void 0,!ou||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),m?T!==void 0?a.addEventListener(l,h,{capture:!0,passive:T}):a.addEventListener(l,h,!0):T!==void 0?a.addEventListener(l,h,{passive:T}):a.addEventListener(l,h,!1)}function F0(a,l,h,m,T){var E=m;if((l&1)===0&&(l&2)===0&&m!==null)e:for(;;){if(m===null)return;var U=m.tag;if(U===3||U===4){var Z=m.stateNode.containerInfo;if(Z===T)break;if(U===4)for(U=m.return;U!==null;){var ge=U.tag;if((ge===3||ge===4)&&U.stateNode.containerInfo===T)return;U=U.return}for(;Z!==null;){if(U=ji(Z),U===null)return;if(ge=U.tag,ge===5||ge===6||ge===26||ge===27){m=E=U;continue e}Z=Z.parentNode}}m=m.return}Bh(function(){var Re=E,$e=ru(h),qe=[];e:{var Ne=td.get(a);if(Ne!==void 0){var Me=cu,At=a;switch(a){case"keypress":if(ul(h)===0)break e;case"keydown":case"keyup":Me=Vh;break;case"focusin":At="focus",Me=so;break;case"focusout":At="blur",Me=so;break;case"beforeblur":case"afterblur":Me=so;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":Me=jh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Me=fg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Me=_a;break;case tf:case ho:case sf:Me=hl;break;case af:Me=Gh;break;case"scroll":case"scrollend":Me=$c;break;case"wheel":Me=qh;break;case"copy":case"cut":case"paste":Me=$n;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Me=no;break;case"toggle":case"beforetoggle":Me=bg}var $t=(l&4)!==0,Mi=!$t&&(a==="scroll"||a==="scrollend"),we=$t?Ne!==null?Ne+"Capture":null:Ne;$t=[];for(var be=Re,Le;be!==null;){var Ge=be;if(Le=Ge.stateNode,Ge=Ge.tag,Ge!==5&&Ge!==26&&Ge!==27||Le===null||we===null||(Ge=Mr(be,we),Ge!=null&&$t.push(Ld(be,Ge,Le))),Mi)break;be=be.return}0<$t.length&&(Ne=new Me(Ne,At,null,h,$e),qe.push({event:Ne,listeners:$t}))}}if((l&7)===0){e:{if(Ne=a==="mouseover"||a==="pointerover",Me=a==="mouseout"||a==="pointerout",Ne&&h!==to&&(At=h.relatedTarget||h.fromElement)&&(ji(At)||At[jt]))break e;if((Me||Ne)&&(Ne=$e.window===$e?$e:(Ne=$e.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,Me?(At=h.relatedTarget||h.toElement,Me=Re,At=At?ji(At):null,At!==null&&(Mi=r(At),$t=At.tag,At!==Mi||$t!==5&&$t!==27&&$t!==6)&&(At=null)):(Me=null,At=Re),Me!==At)){if($t=jh,Ge="onMouseLeave",we="onMouseEnter",be="mouse",(a==="pointerout"||a==="pointerover")&&($t=no,Ge="onPointerLeave",we="onPointerEnter",be="pointer"),Mi=Me==null?Ne:Us(Me),Le=At==null?Ne:Us(At),Ne=new $t(Ge,be+"leave",Me,h,$e),Ne.target=Mi,Ne.relatedTarget=Le,Ge=null,ji($e)===Re&&($t=new $t(we,be+"enter",At,h,$e),$t.target=Le,$t.relatedTarget=Mi,Ge=$t),Mi=Ge,Me&&At)t:{for($t=HR,we=Me,be=At,Le=0,Ge=we;Ge;Ge=$t(Ge))Le++;Ge=0;for(var Ot=be;Ot;Ot=$t(Ot))Ge++;for(;0<Le-Ge;)we=$t(we),Le--;for(;0<Ge-Le;)be=$t(be),Ge--;for(;Le--;){if(we===be||be!==null&&we===be.alternate){$t=we;break t}we=$t(we),be=$t(be)}$t=null}else $t=null;Me!==null&&y_(qe,Ne,Me,$t,!1),At!==null&&Mi!==null&&y_(qe,Mi,At,$t,!0)}}e:{if(Ne=Re?Us(Re):window,Me=Ne.nodeName&&Ne.nodeName.toLowerCase(),Me==="select"||Me==="input"&&Ne.type==="file")var _i=Kc;else if(qc(Ne))if(Yc)_i=Cg;else{_i=Ag;var Rt=wg}else Me=Ne.nodeName,!Me||Me.toLowerCase()!=="input"||Ne.type!=="checkbox"&&Ne.type!=="radio"?Re&&Ji(Re.elementType)&&(_i=Kc):_i=ef;if(_i&&(_i=_i(a,Re))){Qh(qe,_i,h,$e);break e}Rt&&Rt(a,Ne,Re),a==="focusout"&&Re&&Ne.type==="number"&&Re.memoizedProps.value!=null&&xa(Ne,"number",Ne.value)}switch(Rt=Re?Us(Re):window,a){case"focusin":(qc(Rt)||Rt.contentEditable==="true")&&(uo=Rt,Zc=Re,co=null);break;case"focusout":co=Zc=uo=null;break;case"mousedown":vu=!0;break;case"contextmenu":case"mouseup":case"dragend":vu=!1,Jc(qe,h,$e);break;case"selectionchange":if(kg)break;case"keydown":case"keyup":Jc(qe,h,$e)}var ei;if(ro)e:{switch(a){case"compositionstart":var pi="onCompositionStart";break e;case"compositionend":pi="onCompositionEnd";break e;case"compositionupdate":pi="onCompositionUpdate";break e}pi=void 0}else ao?gu(a,h)&&(pi="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(pi="onCompositionStart");pi&&(Yh&&h.locale!=="ko"&&(ao||pi!=="onCompositionStart"?pi==="onCompositionEnd"&&ao&&(ei=Fh()):(Pr=$e,lu="value"in Pr?Pr.value:Pr.textContent,ao=!0)),Rt=Gf(Re,pi),0<Rt.length&&(pi=new fl(pi,a,null,h,$e),qe.push({event:pi,listeners:Rt}),ei?pi.data=ei:(ei=Xh(h),ei!==null&&(pi.data=ei)))),(ei=Kh?_g(a,h):zc(a,h))&&(pi=Gf(Re,"onBeforeInput"),0<pi.length&&(Rt=new fl("onBeforeInput","beforeinput",null,h,$e),qe.push({event:Rt,listeners:pi}),Rt.data=ei)),FR(qe,a,Re,h,$e)}p_(qe,l)})}function Ld(a,l,h){return{instance:a,listener:l,currentTarget:h}}function Gf(a,l){for(var h=l+"Capture",m=[];a!==null;){var T=a,E=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||E===null||(T=Mr(a,h),T!=null&&m.unshift(Ld(a,T,E)),T=Mr(a,l),T!=null&&m.push(Ld(a,T,E))),a.tag===3)return m;a=a.return}return[]}function HR(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function y_(a,l,h,m,T){for(var E=l._reactName,U=[];h!==null&&h!==m;){var Z=h,ge=Z.alternate,Re=Z.stateNode;if(Z=Z.tag,ge!==null&&ge===m)break;Z!==5&&Z!==26&&Z!==27||Re===null||(ge=Re,T?(Re=Mr(h,E),Re!=null&&U.unshift(Ld(h,Re,ge))):T||(Re=Mr(h,E),Re!=null&&U.push(Ld(h,Re,ge)))),h=h.return}U.length!==0&&a.push({event:l,listeners:U})}var VR=/\r\n?/g,GR=/\u0000|\uFFFD/g;function v_(a){return(typeof a=="string"?a:""+a).replace(VR,`
`).replace(GR,"")}function x_(a,l){return l=v_(l),v_(a)===l}function Oi(a,l,h,m,T,E){switch(h){case"children":typeof m=="string"?l==="body"||l==="textarea"&&m===""||un(a,m):(typeof m=="number"||typeof m=="bigint")&&l!=="body"&&un(a,""+m);break;case"className":Ke(a,"class",m);break;case"tabIndex":Ke(a,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":Ke(a,h,m);break;case"style":qi(a,m,E);break;case"data":if(l!=="object"){Ke(a,"data",m);break}case"src":case"href":if(m===""&&(l!=="a"||h!=="href")){a.removeAttribute(h);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){a.removeAttribute(h);break}m=nu(""+m),a.setAttribute(h,m);break;case"action":case"formAction":if(typeof m=="function"){a.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"&&Oi(a,l,"name",T.name,T,null),Oi(a,l,"formEncType",T.formEncType,T,null),Oi(a,l,"formMethod",T.formMethod,T,null),Oi(a,l,"formTarget",T.formTarget,T,null)):(Oi(a,l,"encType",T.encType,T,null),Oi(a,l,"method",T.method,T,null),Oi(a,l,"target",T.target,T,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){a.removeAttribute(h);break}m=nu(""+m),a.setAttribute(h,m);break;case"onClick":m!=null&&(a.onclick=xr);break;case"onScroll":m!=null&&di("scroll",a);break;case"onScrollEnd":m!=null&&di("scrollend",a);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(i(61));if(h=m.__html,h!=null){if(T.children!=null)throw Error(i(60));a.innerHTML=h}}break;case"multiple":a.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":a.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){a.removeAttribute("xlink:href");break}h=nu(""+m),a.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":m!=null&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(h,""+m):a.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":m&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(h,""):a.removeAttribute(h);break;case"capture":case"download":m===!0?a.setAttribute(h,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(h,m):a.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?a.setAttribute(h,m):a.removeAttribute(h);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?a.removeAttribute(h):a.setAttribute(h,m);break;case"popover":di("beforetoggle",a),di("toggle",a),ft(a,"popover",m);break;case"xlinkActuate":Ve(a,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":Ve(a,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":Ve(a,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":Ve(a,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":Ve(a,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":Ve(a,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":Ve(a,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":Ve(a,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":Ve(a,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":ft(a,"is",m);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=jn.get(h)||h,ft(a,h,m))}}function U0(a,l,h,m,T,E){switch(h){case"style":qi(a,m,E);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(i(61));if(h=m.__html,h!=null){if(T.children!=null)throw Error(i(60));a.innerHTML=h}}break;case"children":typeof m=="string"?un(a,m):(typeof m=="number"||typeof m=="bigint")&&un(a,""+m);break;case"onScroll":m!=null&&di("scroll",a);break;case"onScrollEnd":m!=null&&di("scrollend",a);break;case"onClick":m!=null&&(a.onclick=xr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!xe.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(T=h.endsWith("Capture"),l=h.slice(2,T?h.length-7:void 0),E=a[Kt]||null,E=E!=null?E[h]:null,typeof E=="function"&&a.removeEventListener(l,E,T),typeof m=="function")){typeof E!="function"&&E!==null&&(h in a?a[h]=null:a.hasAttribute(h)&&a.removeAttribute(h)),a.addEventListener(l,m,T);break e}h in a?a[h]=m:m===!0?a.setAttribute(h,""):ft(a,h,m)}}}function Ys(a,l,h){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":di("error",a),di("load",a);var m=!1,T=!1,E;for(E in h)if(h.hasOwnProperty(E)){var U=h[E];if(U!=null)switch(E){case"src":m=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:Oi(a,l,E,U,h,null)}}T&&Oi(a,l,"srcSet",h.srcSet,h,null),m&&Oi(a,l,"src",h.src,h,null);return;case"input":di("invalid",a);var Z=E=U=T=null,ge=null,Re=null;for(m in h)if(h.hasOwnProperty(m)){var $e=h[m];if($e!=null)switch(m){case"name":T=$e;break;case"type":U=$e;break;case"checked":ge=$e;break;case"defaultChecked":Re=$e;break;case"value":E=$e;break;case"defaultValue":Z=$e;break;case"children":case"dangerouslySetInnerHTML":if($e!=null)throw Error(i(137,l));break;default:Oi(a,l,m,$e,h,null)}}eo(a,E,Z,ge,Re,U,T,!1);return;case"select":di("invalid",a),m=U=E=null;for(T in h)if(h.hasOwnProperty(T)&&(Z=h[T],Z!=null))switch(T){case"value":E=Z;break;case"defaultValue":U=Z;break;case"multiple":m=Z;default:Oi(a,l,T,Z,h,null)}l=E,h=U,a.multiple=!!m,l!=null?Es(a,!!m,l,!1):h!=null&&Es(a,!!m,h,!0);return;case"textarea":di("invalid",a),E=T=m=null;for(U in h)if(h.hasOwnProperty(U)&&(Z=h[U],Z!=null))switch(U){case"value":m=Z;break;case"defaultValue":T=Z;break;case"children":E=Z;break;case"dangerouslySetInnerHTML":if(Z!=null)throw Error(i(91));break;default:Oi(a,l,U,Z,h,null)}Or(a,m,T,E);return;case"option":for(ge in h)h.hasOwnProperty(ge)&&(m=h[ge],m!=null)&&(ge==="selected"?a.selected=m&&typeof m!="function"&&typeof m!="symbol":Oi(a,l,ge,m,h,null));return;case"dialog":di("beforetoggle",a),di("toggle",a),di("cancel",a),di("close",a);break;case"iframe":case"object":di("load",a);break;case"video":case"audio":for(m=0;m<Dd.length;m++)di(Dd[m],a);break;case"image":di("error",a),di("load",a);break;case"details":di("toggle",a);break;case"embed":case"source":case"link":di("error",a),di("load",a);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Re in h)if(h.hasOwnProperty(Re)&&(m=h[Re],m!=null))switch(Re){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:Oi(a,l,Re,m,h,null)}return;default:if(Ji(l)){for($e in h)h.hasOwnProperty($e)&&(m=h[$e],m!==void 0&&U0(a,l,$e,m,h,void 0));return}}for(Z in h)h.hasOwnProperty(Z)&&(m=h[Z],m!=null&&Oi(a,l,Z,m,h,null))}function zR(a,l,h,m){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,E=null,U=null,Z=null,ge=null,Re=null,$e=null;for(Me in h){var qe=h[Me];if(h.hasOwnProperty(Me)&&qe!=null)switch(Me){case"checked":break;case"value":break;case"defaultValue":ge=qe;default:m.hasOwnProperty(Me)||Oi(a,l,Me,null,m,qe)}}for(var Ne in m){var Me=m[Ne];if(qe=h[Ne],m.hasOwnProperty(Ne)&&(Me!=null||qe!=null))switch(Ne){case"type":E=Me;break;case"name":T=Me;break;case"checked":Re=Me;break;case"defaultChecked":$e=Me;break;case"value":U=Me;break;case"defaultValue":Z=Me;break;case"children":case"dangerouslySetInnerHTML":if(Me!=null)throw Error(i(137,l));break;default:Me!==qe&&Oi(a,l,Ne,Me,m,qe)}}Ja(a,U,Z,ge,Re,$e,E,T);return;case"select":Me=U=Z=Ne=null;for(E in h)if(ge=h[E],h.hasOwnProperty(E)&&ge!=null)switch(E){case"value":break;case"multiple":Me=ge;default:m.hasOwnProperty(E)||Oi(a,l,E,null,m,ge)}for(T in m)if(E=m[T],ge=h[T],m.hasOwnProperty(T)&&(E!=null||ge!=null))switch(T){case"value":Ne=E;break;case"defaultValue":Z=E;break;case"multiple":U=E;default:E!==ge&&Oi(a,l,T,E,m,ge)}l=Z,h=U,m=Me,Ne!=null?Es(a,!!h,Ne,!1):!!m!=!!h&&(l!=null?Es(a,!!h,l,!0):Es(a,!!h,h?[]:"",!1));return;case"textarea":Me=Ne=null;for(Z in h)if(T=h[Z],h.hasOwnProperty(Z)&&T!=null&&!m.hasOwnProperty(Z))switch(Z){case"value":break;case"children":break;default:Oi(a,l,Z,null,m,T)}for(U in m)if(T=m[U],E=h[U],m.hasOwnProperty(U)&&(T!=null||E!=null))switch(U){case"value":Ne=T;break;case"defaultValue":Me=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(i(91));break;default:T!==E&&Oi(a,l,U,T,m,E)}su(a,Ne,Me);return;case"option":for(var At in h)Ne=h[At],h.hasOwnProperty(At)&&Ne!=null&&!m.hasOwnProperty(At)&&(At==="selected"?a.selected=!1:Oi(a,l,At,null,m,Ne));for(ge in m)Ne=m[ge],Me=h[ge],m.hasOwnProperty(ge)&&Ne!==Me&&(Ne!=null||Me!=null)&&(ge==="selected"?a.selected=Ne&&typeof Ne!="function"&&typeof Ne!="symbol":Oi(a,l,ge,Ne,m,Me));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 $t in h)Ne=h[$t],h.hasOwnProperty($t)&&Ne!=null&&!m.hasOwnProperty($t)&&Oi(a,l,$t,null,m,Ne);for(Re in m)if(Ne=m[Re],Me=h[Re],m.hasOwnProperty(Re)&&Ne!==Me&&(Ne!=null||Me!=null))switch(Re){case"children":case"dangerouslySetInnerHTML":if(Ne!=null)throw Error(i(137,l));break;default:Oi(a,l,Re,Ne,m,Me)}return;default:if(Ji(l)){for(var Mi in h)Ne=h[Mi],h.hasOwnProperty(Mi)&&Ne!==void 0&&!m.hasOwnProperty(Mi)&&U0(a,l,Mi,void 0,m,Ne);for($e in m)Ne=m[$e],Me=h[$e],!m.hasOwnProperty($e)||Ne===Me||Ne===void 0&&Me===void 0||U0(a,l,$e,Ne,m,Me);return}}for(var we in h)Ne=h[we],h.hasOwnProperty(we)&&Ne!=null&&!m.hasOwnProperty(we)&&Oi(a,l,we,null,m,Ne);for(qe in m)Ne=m[qe],Me=h[qe],!m.hasOwnProperty(qe)||Ne===Me||Ne==null&&Me==null||Oi(a,l,qe,Ne,m,Me)}function b_(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function qR(){if(typeof performance.getEntriesByType=="function"){for(var a=0,l=0,h=performance.getEntriesByType("resource"),m=0;m<h.length;m++){var T=h[m],E=T.transferSize,U=T.initiatorType,Z=T.duration;if(E&&Z&&b_(U)){for(U=0,Z=T.responseEnd,m+=1;m<h.length;m++){var ge=h[m],Re=ge.startTime;if(Re>Z)break;var $e=ge.transferSize,qe=ge.initiatorType;$e&&b_(qe)&&(ge=ge.responseEnd,U+=$e*(ge<Z?1:(Z-Re)/(ge-Re)))}if(--m,l+=8*(E+U)/(T.duration/1e3),a++,10<a)break}}if(0<a)return l/a/1e6}return navigator.connection&&(a=navigator.connection.downlink,typeof a=="number")?a:5}var j0=null,$0=null;function zf(a){return a.nodeType===9?a:a.ownerDocument}function T_(a){switch(a){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function __(a,l){if(a===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return a===1&&l==="foreignObject"?0:a}function H0(a,l){return a==="textarea"||a==="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 V0=null;function KR(){var a=window.event;return a&&a.type==="popstate"?a===V0?!1:(V0=a,!0):(V0=null,!1)}var S_=typeof setTimeout=="function"?setTimeout:void 0,YR=typeof clearTimeout=="function"?clearTimeout:void 0,E_=typeof Promise=="function"?Promise:void 0,WR=typeof queueMicrotask=="function"?queueMicrotask:typeof E_<"u"?function(a){return E_.resolve(null).then(a).catch(XR)}:S_;function XR(a){setTimeout(function(){throw a})}function Ro(a){return a==="head"}function w_(a,l){var h=l,m=0;do{var T=h.nextSibling;if(a.removeChild(h),T&&T.nodeType===8)if(h=T.data,h==="/$"||h==="/&"){if(m===0){a.removeChild(T),ju(l);return}m--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")m++;else if(h==="html")Rd(a.ownerDocument.documentElement);else if(h==="head"){h=a.ownerDocument.head,Rd(h);for(var E=h.firstChild;E;){var U=E.nextSibling,Z=E.nodeName;E[fi]||Z==="SCRIPT"||Z==="STYLE"||Z==="LINK"&&E.rel.toLowerCase()==="stylesheet"||h.removeChild(E),E=U}}else h==="body"&&Rd(a.ownerDocument.body);h=T}while(h);ju(l)}function A_(a,l){var h=a;a=0;do{var m=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||""),m&&m.nodeType===8)if(h=m.data,h==="/$"){if(a===0)break;a--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||a++;h=m}while(h)}function G0(a){var l=a.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":G0(h),li(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}a.removeChild(h)}}function QR(a,l,h,m){for(;a.nodeType===1;){var T=h;if(a.nodeName.toLowerCase()!==l.toLowerCase()){if(!m&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(m){if(!a[fi])switch(l){case"meta":if(!a.hasAttribute("itemprop"))break;return a;case"link":if(E=a.getAttribute("rel"),E==="stylesheet"&&a.hasAttribute("data-precedence"))break;if(E!==T.rel||a.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||a.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||a.getAttribute("title")!==(T.title==null?null:T.title))break;return a;case"style":if(a.hasAttribute("data-precedence"))break;return a;case"script":if(E=a.getAttribute("src"),(E!==(T.src==null?null:T.src)||a.getAttribute("type")!==(T.type==null?null:T.type)||a.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&E&&a.hasAttribute("async")&&!a.hasAttribute("itemprop"))break;return a;default:return a}}else if(l==="input"&&a.type==="hidden"){var E=T.name==null?null:""+T.name;if(T.type==="hidden"&&a.getAttribute("name")===E)return a}else return a;if(a=or(a.nextSibling),a===null)break}return null}function ZR(a,l,h){if(l==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!h||(a=or(a.nextSibling),a===null))return null;return a}function C_(a,l){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!l||(a=or(a.nextSibling),a===null))return null;return a}function z0(a){return a.data==="$?"||a.data==="$~"}function q0(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function JR(a,l){var h=a.ownerDocument;if(a.data==="$~")a._reactRetry=l;else if(a.data!=="$?"||h.readyState!=="loading")l();else{var m=function(){l(),h.removeEventListener("DOMContentLoaded",m)};h.addEventListener("DOMContentLoaded",m),a._reactRetry=m}}function or(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return a}var K0=null;function k_(a){a=a.nextSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"||h==="/&"){if(l===0)return or(a.nextSibling);l--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||l++}a=a.nextSibling}return null}function D_(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(l===0)return a;l--}else h!=="/$"&&h!=="/&"||l++}a=a.previousSibling}return null}function L_(a,l,h){switch(l=zf(h),a){case"html":if(a=l.documentElement,!a)throw Error(i(452));return a;case"head":if(a=l.head,!a)throw Error(i(453));return a;case"body":if(a=l.body,!a)throw Error(i(454));return a;default:throw Error(i(451))}}function Rd(a){for(var l=a.attributes;l.length;)a.removeAttributeNode(l[0]);li(a)}var lr=new Map,R_=new Set;function qf(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var Ba=G.d;G.d={f:eI,r:tI,D:iI,C:sI,L:nI,m:rI,X:oI,S:aI,M:lI};function eI(){var a=Ba.f(),l=Bf();return a||l}function tI(a){var l=hs(a);l!==null&&l.tag===5&&l.type==="form"?YT(l):Ba.r(a)}var Bu=typeof document>"u"?null:document;function I_(a,l,h){var m=Bu;if(m&&typeof l=="string"&&l){var T=Ls(l);T='link[rel="'+a+'"][href="'+T+'"]',typeof h=="string"&&(T+='[crossorigin="'+h+'"]'),R_.has(T)||(R_.add(T),a={rel:a,crossOrigin:h,href:l},m.querySelector(T)===null&&(l=m.createElement("link"),Ys(l,"link",a),se(l),m.head.appendChild(l)))}}function iI(a){Ba.D(a),I_("dns-prefetch",a,null)}function sI(a,l){Ba.C(a,l),I_("preconnect",a,l)}function nI(a,l,h){Ba.L(a,l,h);var m=Bu;if(m&&a&&l){var T='link[rel="preload"][as="'+Ls(l)+'"]';l==="image"&&h&&h.imageSrcSet?(T+='[imagesrcset="'+Ls(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(T+='[imagesizes="'+Ls(h.imageSizes)+'"]')):T+='[href="'+Ls(a)+'"]';var E=T;switch(l){case"style":E=Fu(a);break;case"script":E=Uu(a)}lr.has(E)||(a=p({rel:"preload",href:l==="image"&&h&&h.imageSrcSet?void 0:a,as:l},h),lr.set(E,a),m.querySelector(T)!==null||l==="style"&&m.querySelector(Id(E))||l==="script"&&m.querySelector(Nd(E))||(l=m.createElement("link"),Ys(l,"link",a),se(l),m.head.appendChild(l)))}}function rI(a,l){Ba.m(a,l);var h=Bu;if(h&&a){var m=l&&typeof l.as=="string"?l.as:"script",T='link[rel="modulepreload"][as="'+Ls(m)+'"][href="'+Ls(a)+'"]',E=T;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":E=Uu(a)}if(!lr.has(E)&&(a=p({rel:"modulepreload",href:a},l),lr.set(E,a),h.querySelector(T)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(Nd(E)))return}m=h.createElement("link"),Ys(m,"link",a),se(m),h.head.appendChild(m)}}}function aI(a,l,h){Ba.S(a,l,h);var m=Bu;if(m&&a){var T=Q(m).hoistableStyles,E=Fu(a);l=l||"default";var U=T.get(E);if(!U){var Z={loading:0,preload:null};if(U=m.querySelector(Id(E)))Z.loading=5;else{a=p({rel:"stylesheet",href:a,"data-precedence":l},h),(h=lr.get(E))&&Y0(a,h);var ge=U=m.createElement("link");se(ge),Ys(ge,"link",a),ge._p=new Promise(function(Re,$e){ge.onload=Re,ge.onerror=$e}),ge.addEventListener("load",function(){Z.loading|=1}),ge.addEventListener("error",function(){Z.loading|=2}),Z.loading|=4,Kf(U,l,m)}U={type:"stylesheet",instance:U,count:1,state:Z},T.set(E,U)}}}function oI(a,l){Ba.X(a,l);var h=Bu;if(h&&a){var m=Q(h).hoistableScripts,T=Uu(a),E=m.get(T);E||(E=h.querySelector(Nd(T)),E||(a=p({src:a,async:!0},l),(l=lr.get(T))&&W0(a,l),E=h.createElement("script"),se(E),Ys(E,"link",a),h.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},m.set(T,E))}}function lI(a,l){Ba.M(a,l);var h=Bu;if(h&&a){var m=Q(h).hoistableScripts,T=Uu(a),E=m.get(T);E||(E=h.querySelector(Nd(T)),E||(a=p({src:a,async:!0,type:"module"},l),(l=lr.get(T))&&W0(a,l),E=h.createElement("script"),se(E),Ys(E,"link",a),h.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},m.set(T,E))}}function N_(a,l,h,m){var T=(T=Ce.current)?qf(T):null;if(!T)throw Error(i(446));switch(a){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(l=Fu(h.href),h=Q(T).hoistableStyles,m=h.get(l),m||(m={type:"style",instance:null,count:0,state:null},h.set(l,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){a=Fu(h.href);var E=Q(T).hoistableStyles,U=E.get(a);if(U||(T=T.ownerDocument||T,U={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},E.set(a,U),(E=T.querySelector(Id(a)))&&!E._p&&(U.instance=E,U.state.loading=5),lr.has(a)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},lr.set(a,h),E||uI(T,a,h,U.state))),l&&m===null)throw Error(i(528,""));return U}if(l&&m!==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=Uu(h),h=Q(T).hoistableScripts,m=h.get(l),m||(m={type:"script",instance:null,count:0,state:null},h.set(l,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,a))}}function Fu(a){return'href="'+Ls(a)+'"'}function Id(a){return'link[rel="stylesheet"]['+a+"]"}function O_(a){return p({},a,{"data-precedence":a.precedence,precedence:null})}function uI(a,l,h,m){a.querySelector('link[rel="preload"][as="style"]['+l+"]")?m.loading=1:(l=a.createElement("link"),m.preload=l,l.addEventListener("load",function(){return m.loading|=1}),l.addEventListener("error",function(){return m.loading|=2}),Ys(l,"link",h),se(l),a.head.appendChild(l))}function Uu(a){return'[src="'+Ls(a)+'"]'}function Nd(a){return"script[async]"+a}function M_(a,l,h){if(l.count++,l.instance===null)switch(l.type){case"style":var m=a.querySelector('style[data-href~="'+Ls(h.href)+'"]');if(m)return l.instance=m,se(m),m;var T=p({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return m=(a.ownerDocument||a).createElement("style"),se(m),Ys(m,"style",T),Kf(m,h.precedence,a),l.instance=m;case"stylesheet":T=Fu(h.href);var E=a.querySelector(Id(T));if(E)return l.state.loading|=4,l.instance=E,se(E),E;m=O_(h),(T=lr.get(T))&&Y0(m,T),E=(a.ownerDocument||a).createElement("link"),se(E);var U=E;return U._p=new Promise(function(Z,ge){U.onload=Z,U.onerror=ge}),Ys(E,"link",m),l.state.loading|=4,Kf(E,h.precedence,a),l.instance=E;case"script":return E=Uu(h.src),(T=a.querySelector(Nd(E)))?(l.instance=T,se(T),T):(m=h,(T=lr.get(E))&&(m=p({},h),W0(m,T)),a=a.ownerDocument||a,T=a.createElement("script"),se(T),Ys(T,"link",m),a.head.appendChild(T),l.instance=T);case"void":return null;default:throw Error(i(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(m=l.instance,l.state.loading|=4,Kf(m,h.precedence,a));return l.instance}function Kf(a,l,h){for(var m=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=m.length?m[m.length-1]:null,E=T,U=0;U<m.length;U++){var Z=m[U];if(Z.dataset.precedence===l)E=Z;else if(E!==T)break}E?E.parentNode.insertBefore(a,E.nextSibling):(l=h.nodeType===9?h.head:h,l.insertBefore(a,l.firstChild))}function Y0(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.title==null&&(a.title=l.title)}function W0(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.integrity==null&&(a.integrity=l.integrity)}var Yf=null;function P_(a,l,h){if(Yf===null){var m=new Map,T=Yf=new Map;T.set(h,m)}else T=Yf,m=T.get(h),m||(m=new Map,T.set(h,m));if(m.has(a))return m;for(m.set(a,null),h=h.getElementsByTagName(a),T=0;T<h.length;T++){var E=h[T];if(!(E[fi]||E[Wt]||a==="link"&&E.getAttribute("rel")==="stylesheet")&&E.namespaceURI!=="http://www.w3.org/2000/svg"){var U=E.getAttribute(l)||"";U=a+U;var Z=m.get(U);Z?Z.push(E):m.set(U,[E])}}return m}function B_(a,l,h){a=a.ownerDocument||a,a.head.insertBefore(h,l==="title"?a.querySelector("head > title"):null)}function cI(a,l,h){if(h===1||l.itemProp!=null)return!1;switch(a){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"?(a=l.disabled,typeof l.precedence=="string"&&a==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 F_(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function dI(a,l,h,m){if(h.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var T=Fu(m.href),E=l.querySelector(Id(T));if(E){l=E._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(a.count++,a=Wf.bind(a),l.then(a,a)),h.state.loading|=4,h.instance=E,se(E);return}E=l.ownerDocument||l,m=O_(m),(T=lr.get(T))&&Y0(m,T),E=E.createElement("link"),se(E);var U=E;U._p=new Promise(function(Z,ge){U.onload=Z,U.onerror=ge}),Ys(E,"link",m),h.instance=E}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(h,l),(l=h.state.preload)&&(h.state.loading&3)===0&&(a.count++,h=Wf.bind(a),l.addEventListener("load",h),l.addEventListener("error",h))}}var X0=0;function hI(a,l){return a.stylesheets&&a.count===0&&Qf(a,a.stylesheets),0<a.count||0<a.imgCount?function(h){var m=setTimeout(function(){if(a.stylesheets&&Qf(a,a.stylesheets),a.unsuspend){var E=a.unsuspend;a.unsuspend=null,E()}},6e4+l);0<a.imgBytes&&X0===0&&(X0=62500*qR());var T=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&Qf(a,a.stylesheets),a.unsuspend)){var E=a.unsuspend;a.unsuspend=null,E()}},(a.imgBytes>X0?50:800)+l);return a.unsuspend=h,function(){a.unsuspend=null,clearTimeout(m),clearTimeout(T)}}:null}function Wf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qf(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Xf=null;function Qf(a,l){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Xf=new Map,l.forEach(fI,a),Xf=null,Wf.call(a))}function fI(a,l){if(!(l.state.loading&4)){var h=Xf.get(a);if(h)var m=h.get(null);else{h=new Map,Xf.set(a,h);for(var T=a.querySelectorAll("link[data-precedence],style[data-precedence]"),E=0;E<T.length;E++){var U=T[E];(U.nodeName==="LINK"||U.getAttribute("media")!=="not all")&&(h.set(U.dataset.precedence,U),m=U)}m&&h.set(null,m)}T=l.instance,U=T.getAttribute("data-precedence"),E=h.get(U)||m,E===m&&h.set(null,T),h.set(U,T),this.count++,m=Wf.bind(this),T.addEventListener("load",m),T.addEventListener("error",m),E?E.parentNode.insertBefore(T,E.nextSibling):(a=a.nodeType===9?a.head:a,a.insertBefore(T,a.firstChild)),l.state.loading|=4}}var Od={$$typeof:L,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function mI(a,l,h,m,T,E,U,Z,ge){this.tag=1,this.containerInfo=a,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=Tt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Tt(0),this.hiddenUpdates=Tt(null),this.identifierPrefix=m,this.onUncaughtError=T,this.onCaughtError=E,this.onRecoverableError=U,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ge,this.incompleteTransitions=new Map}function U_(a,l,h,m,T,E,U,Z,ge,Re,$e,qe){return a=new mI(a,l,h,U,ge,Re,$e,qe,Z),l=1,E===!0&&(l|=24),E=fs(3,null,null,l),a.current=E,E.stateNode=a,l=Aa(),l.refCount++,a.pooledCache=l,l.refCount++,E.memoizedState={element:m,isDehydrated:h,cache:l},Ng(E),a}function j_(a){return a?(a=po,a):po}function $_(a,l,h,m,T,E){T=j_(T),m.context===null?m.context=T:m.pendingContext=T,m=bo(l),m.payload={element:h},E=E===void 0?null:E,E!==null&&(m.callback=E),h=To(a,m,l),h!==null&&(Dn(h,a,l),hd(h,a,l))}function H_(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<l?h:l}}function Q0(a,l){H_(a,l),(a=a.alternate)&&H_(a,l)}function V_(a){if(a.tag===13||a.tag===31){var l=wa(a,67108864);l!==null&&Dn(l,a,67108864),Q0(a,67108864)}}function G_(a){if(a.tag===13||a.tag===31){var l=Yn();l=Qi(l);var h=wa(a,l);h!==null&&Dn(h,a,l),Q0(a,l)}}var Zf=!0;function pI(a,l,h,m){var T=Y.T;Y.T=null;var E=G.p;try{G.p=2,Z0(a,l,h,m)}finally{G.p=E,Y.T=T}}function gI(a,l,h,m){var T=Y.T;Y.T=null;var E=G.p;try{G.p=8,Z0(a,l,h,m)}finally{G.p=E,Y.T=T}}function Z0(a,l,h,m){if(Zf){var T=J0(m);if(T===null)F0(a,l,m,Jf,h),q_(a,m);else if(vI(T,a,l,h,m))m.stopPropagation();else if(q_(a,m),l&4&&-1<yI.indexOf(a)){for(;T!==null;){var E=hs(T);if(E!==null)switch(E.tag){case 3:if(E=E.stateNode,E.current.memoizedState.isDehydrated){var U=H(E.pendingLanes);if(U!==0){var Z=E;for(Z.pendingLanes|=2,Z.entangledLanes|=2;U;){var ge=1<<31-Ut(U);Z.entanglements[1]|=ge,U&=~ge}Yr(E),(wi&6)===0&&(Mf=We()+500,kd(0))}}break;case 31:case 13:Z=wa(E,2),Z!==null&&Dn(Z,E,2),Bf(),Q0(E,2)}if(E=J0(m),E===null&&F0(a,l,m,Jf,h),E===T)break;T=E}T!==null&&m.stopPropagation()}else F0(a,l,m,null,h)}}function J0(a){return a=ru(a),ey(a)}var Jf=null;function ey(a){if(Jf=null,a=ji(a),a!==null){var l=r(a);if(l===null)a=null;else{var h=l.tag;if(h===13){if(a=o(l),a!==null)return a;a=null}else if(h===31){if(a=u(l),a!==null)return a;a=null}else if(h===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null)}}return Jf=a,null}function z_(a){switch(a){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(et()){case ot:return 2;case nt:return 8;case vt:case Xe:return 32;case Ft:return 268435456;default:return 32}default:return 32}}var ty=!1,Io=null,No=null,Oo=null,Md=new Map,Pd=new Map,Mo=[],yI="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 q_(a,l){switch(a){case"focusin":case"focusout":Io=null;break;case"dragenter":case"dragleave":No=null;break;case"mouseover":case"mouseout":Oo=null;break;case"pointerover":case"pointerout":Md.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Pd.delete(l.pointerId)}}function Bd(a,l,h,m,T,E){return a===null||a.nativeEvent!==E?(a={blockedOn:l,domEventName:h,eventSystemFlags:m,nativeEvent:E,targetContainers:[T]},l!==null&&(l=hs(l),l!==null&&V_(l)),a):(a.eventSystemFlags|=m,l=a.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),a)}function vI(a,l,h,m,T){switch(l){case"focusin":return Io=Bd(Io,a,l,h,m,T),!0;case"dragenter":return No=Bd(No,a,l,h,m,T),!0;case"mouseover":return Oo=Bd(Oo,a,l,h,m,T),!0;case"pointerover":var E=T.pointerId;return Md.set(E,Bd(Md.get(E)||null,a,l,h,m,T)),!0;case"gotpointercapture":return E=T.pointerId,Pd.set(E,Bd(Pd.get(E)||null,a,l,h,m,T)),!0}return!1}function K_(a){var l=ji(a.target);if(l!==null){var h=r(l);if(h!==null){if(l=h.tag,l===13){if(l=o(h),l!==null){a.blockedOn=l,Ui(a.priority,function(){G_(h)});return}}else if(l===31){if(l=u(h),l!==null){a.blockedOn=l,Ui(a.priority,function(){G_(h)});return}}else if(l===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function em(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var h=J0(a.nativeEvent);if(h===null){h=a.nativeEvent;var m=new h.constructor(h.type,h);to=m,h.target.dispatchEvent(m),to=null}else return l=hs(h),l!==null&&V_(l),a.blockedOn=h,!1;l.shift()}return!0}function Y_(a,l,h){em(a)&&h.delete(l)}function xI(){ty=!1,Io!==null&&em(Io)&&(Io=null),No!==null&&em(No)&&(No=null),Oo!==null&&em(Oo)&&(Oo=null),Md.forEach(Y_),Pd.forEach(Y_)}function tm(a,l){a.blockedOn===l&&(a.blockedOn=null,ty||(ty=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xI)))}var im=null;function W_(a){im!==a&&(im=a,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){im===a&&(im=null);for(var l=0;l<a.length;l+=3){var h=a[l],m=a[l+1],T=a[l+2];if(typeof m!="function"){if(ey(m||h)===null)continue;break}var E=hs(h);E!==null&&(a.splice(l,3),l-=3,Jg(E,{pending:!0,data:T,method:h.method,action:m},m,T))}}))}function ju(a){function l(ge){return tm(ge,a)}Io!==null&&tm(Io,a),No!==null&&tm(No,a),Oo!==null&&tm(Oo,a),Md.forEach(l),Pd.forEach(l);for(var h=0;h<Mo.length;h++){var m=Mo[h];m.blockedOn===a&&(m.blockedOn=null)}for(;0<Mo.length&&(h=Mo[0],h.blockedOn===null);)K_(h),h.blockedOn===null&&Mo.shift();if(h=(a.ownerDocument||a).$$reactFormReplay,h!=null)for(m=0;m<h.length;m+=3){var T=h[m],E=h[m+1],U=T[Kt]||null;if(typeof E=="function")U||W_(h);else if(U){var Z=null;if(E&&E.hasAttribute("formAction")){if(T=E,U=E[Kt]||null)Z=U.formAction;else if(ey(T)!==null)continue}else Z=U.action;typeof Z=="function"?h[m+1]=Z:(h.splice(m,3),m-=3),W_(h)}}}function X_(){function a(E){E.canIntercept&&E.info==="react-transition"&&E.intercept({handler:function(){return new Promise(function(U){return T=U})},focusReset:"manual",scroll:"manual"})}function l(){T!==null&&(T(),T=null),m||setTimeout(h,20)}function h(){if(!m&&!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 m=!1,T=null;return navigation.addEventListener("navigate",a),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(h,100),function(){m=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),T!==null&&(T(),T=null)}}}function iy(a){this._internalRoot=a}sm.prototype.render=iy.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(i(409));var h=l.current,m=Yn();$_(h,m,a,l,null,null)},sm.prototype.unmount=iy.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;$_(a.current,2,null,a,null,null),Bf(),l[jt]=null}};function sm(a){this._internalRoot=a}sm.prototype.unstable_scheduleHydration=function(a){if(a){var l=Fi();a={blockedOn:null,target:a,priority:l};for(var h=0;h<Mo.length&&l!==0&&l<Mo[h].priority;h++);Mo.splice(h,0,a),h===0&&K_(a)}};var Q_=e.version;if(Q_!=="19.2.3")throw Error(i(527,Q_,"19.2.3"));G.findDOMNode=function(a){var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(i(188)):(a=Object.keys(a).join(","),Error(i(268,a)));return a=d(l),a=a!==null?f(a):null,a=a===null?null:a.stateNode,a};var bI={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{hi=nm.inject(bI),Qe=nm}catch{}}return Ud.createRoot=function(a,l){if(!n(a))throw Error(i(299));var h=!1,m="",T=n1,E=r1,U=a1;return l!=null&&(l.unstable_strictMode===!0&&(h=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(T=l.onUncaughtError),l.onCaughtError!==void 0&&(E=l.onCaughtError),l.onRecoverableError!==void 0&&(U=l.onRecoverableError)),l=U_(a,1,!1,null,null,h,m,null,T,E,U,X_),a[jt]=l.current,B0(a),new iy(l)},Ud.hydrateRoot=function(a,l,h){if(!n(a))throw Error(i(299));var m=!1,T="",E=n1,U=r1,Z=a1,ge=null;return h!=null&&(h.unstable_strictMode===!0&&(m=!0),h.identifierPrefix!==void 0&&(T=h.identifierPrefix),h.onUncaughtError!==void 0&&(E=h.onUncaughtError),h.onCaughtError!==void 0&&(U=h.onCaughtError),h.onRecoverableError!==void 0&&(Z=h.onRecoverableError),h.formState!==void 0&&(ge=h.formState)),l=U_(a,1,!0,l,h??null,m,T,ge,E,U,Z,X_),l.context=j_(null),h=l.current,m=Yn(),m=Qi(m),T=bo(m),T.callback=null,To(h,T,m),h=m,l.current.lanes=h,zt(l,h),Yr(l),a[jt]=l.current,B0(a),new sm(l)},Ud.version="19.2.3",Ud}var lS;function RI(){if(lS)return ry.exports;lS=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(),ry.exports=LI(),ry.exports}var II=RI();function NI(...s){return s.filter(Boolean).join(" ")}const OI="inline-flex items-center justify-center font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",MI={sm:"rounded-sm",md:"rounded-md",full:"rounded-full"},PI={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"},BI={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 FI(){return y.jsxs("svg",{viewBox:"0 0 24 24",className:"size-4 animate-spin","aria-hidden":"true",children:[y.jsx("circle",{cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.25"}),y.jsx("path",{d:"M22 12a10 10 0 0 1-10 10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.9"})]})}function ti({children:s,variant:e="primary",color:t="indigo",size:i="md",rounded:n="md",leadingIcon:r,trailingIcon:o,isLoading:u=!1,disabled:c,className:d,type:f="button",...p}){const g=r||o||u?"gap-x-1.5":"";return y.jsxs("button",{type:f,disabled:c||u,className:NI(OI,MI[n],PI[i],BI[t][e],g,d),...p,children:[u?y.jsx("span",{className:"-ml-0.5",children:y.jsx(FI,{})}):r&&y.jsx("span",{className:"-ml-0.5",children:r}),y.jsx("span",{children:s}),o&&!u&&y.jsx("span",{className:"-mr-0.5",children:o})]})}function Jw(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=Jw(s[e]))&&(i&&(i+=" "),i+=t)}else for(t in s)s[t]&&(i&&(i+=" "),i+=t);return i}function yi(){for(var s,e,t=0,i="",n=arguments.length;t<n;t++)(s=arguments[t])&&(e=Jw(s))&&(i&&(i+=" "),i+=e);return i}var yc=Zw(),UI=Object.defineProperty,jI=(s,e,t)=>e in s?UI(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,uy=(s,e,t)=>(jI(s,typeof e!="symbol"?e+"":e,t),t);let $I=class{constructor(){uy(this,"current",this.detect()),uy(this,"handoffState","pending"),uy(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"}},ca=new $I;function Ch(s){var e;return ca.isServer?null:s==null?document:(e=s?.ownerDocument)!=null?e:document}function Iv(s){var e,t;return ca.isServer?null:s==null?document:(t=(e=s?.getRootNode)==null?void 0:e.call(s))!=null?t:document}function eA(s){var e,t;return(t=(e=Iv(s))==null?void 0:e.activeElement)!=null?t:null}function HI(s){return eA(s)===s}function Ip(s){typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s).catch(e=>setTimeout(()=>{throw e}))}function Za(){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 Ip(()=>{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=Za();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 Np(){let[s]=A.useState(Za);return A.useEffect(()=>()=>s.dispose(),[s]),s}let Bn=(s,e)=>{ca.isServer?A.useEffect(s,e):A.useLayoutEffect(s,e)};function iu(s){let e=A.useRef(s);return Bn(()=>{e.current=s},[s]),e}let Gi=function(s){let e=iu(s);return Mt.useCallback((...t)=>e.current(...t),[e])};function kh(s){return A.useMemo(()=>s,Object.values(s))}let VI=A.createContext(void 0);function GI(){return A.useContext(VI)}function Nv(...s){return Array.from(new Set(s.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function Xa(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,Xa),i}var Km=(s=>(s[s.None=0]="None",s[s.RenderStrategy=1]="RenderStrategy",s[s.Static=2]="Static",s))(Km||{}),Xo=(s=>(s[s.Unmount=0]="Unmount",s[s.Hidden=1]="Hidden",s))(Xo||{});function pr(){let s=qI();return A.useCallback(e=>zI({mergeRefs:s,...e}),[s])}function zI({ourProps:s,theirProps:e,slot:t,defaultTag:i,features:n,visible:r=!0,name:o,mergeRefs:u}){u=u??KI;let c=tA(e,s);if(r)return rm(c,t,i,o,u);let d=n??0;if(d&2){let{static:f=!1,...p}=c;if(f)return rm(p,t,i,o,u)}if(d&1){let{unmount:f=!0,...p}=c;return Xa(f?0:1,{0(){return null},1(){return rm({...p,hidden:!0,style:{display:"none"}},t,i,o,u)}})}return rm(c,t,i,o,u)}function rm(s,e={},t,i,n){let{as:r=t,children:o,refName:u="ref",...c}=cy(s,["unmount","static"]),d=s.ref!==void 0?{[u]:s.ref}:{},f=typeof o=="function"?o(e):o;"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 p={};if(e){let g=!1,v=[];for(let[b,_]of Object.entries(e))typeof _=="boolean"&&(g=!0),_===!0&&v.push(b.replace(/([A-Z])/g,S=>`-${S.toLowerCase()}`));if(g){p["data-headlessui-state"]=v.join(" ");for(let b of v)p[`data-${b}`]=""}}if(th(r)&&(Object.keys(Pl(c)).length>0||Object.keys(Pl(p)).length>0))if(!A.isValidElement(f)||Array.isArray(f)&&f.length>1||WI(f)){if(Object.keys(Pl(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(Pl(c)).concat(Object.keys(Pl(p))).map(g=>` - ${g}`).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(g=>` - ${g}`).join(`
`)].join(`
`))}else{let g=f.props,v=g?.className,b=typeof v=="function"?(...D)=>Nv(v(...D),c.className):Nv(v,c.className),_=b?{className:b}:{},S=tA(f.props,Pl(cy(c,["ref"])));for(let D in p)D in S&&delete p[D];return A.cloneElement(f,Object.assign({},S,p,d,{ref:n(YI(f),d.ref)},_))}return A.createElement(r,Object.assign({},cy(c,["ref"]),!th(r)&&d,!th(r)&&p),f)}function qI(){let s=A.useRef([]),e=A.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 KI(...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 tA(...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 o=t[i];for(let u of o){if((n instanceof Event||n?.nativeEvent instanceof Event)&&n.defaultPrevented)return;u(n,...r)}}});return e}function Un(s){var e;return Object.assign(A.forwardRef(s),{displayName:(e=s.displayName)!=null?e:s.name})}function Pl(s){let e=Object.assign({},s);for(let t in e)e[t]===void 0&&delete e[t];return e}function cy(s,e=[]){let t=Object.assign({},s);for(let i of e)i in t&&delete t[i];return t}function YI(s){return Mt.version.split(".")[0]>="19"?s.props.ref:s.ref}function th(s){return s===A.Fragment||s===Symbol.for("react.fragment")}function WI(s){return th(s.type)}let XI="span";var Ym=(s=>(s[s.None=1]="None",s[s.Focusable=2]="Focusable",s[s.Hidden=4]="Hidden",s))(Ym||{});function QI(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 pr()({ourProps:r,theirProps:n,slot:{},defaultTag:XI,name:"Hidden"})}let Ov=Un(QI);function ZI(s){return typeof s!="object"||s===null?!1:"nodeType"in s}function Zo(s){return ZI(s)&&"tagName"in s}function Zl(s){return Zo(s)&&"accessKey"in s}function Qo(s){return Zo(s)&&"tabIndex"in s}function JI(s){return Zo(s)&&"style"in s}function eN(s){return Zl(s)&&s.nodeName==="IFRAME"}function tN(s){return Zl(s)&&s.nodeName==="INPUT"}let iA=Symbol();function iN(s,e=!0){return Object.assign(s,{[iA]:e})}function va(...s){let e=A.useRef(s);A.useEffect(()=>{e.current=s},[s]);let t=Gi(i=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(i):n.current=i)});return s.every(i=>i==null||i?.[iA])?void 0:t}let Fx=A.createContext(null);Fx.displayName="DescriptionContext";function sA(){let s=A.useContext(Fx);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,sA),e}return s}function sN(){let[s,e]=A.useState([]);return[s.length>0?s.join(" "):void 0,A.useMemo(()=>function(t){let i=Gi(r=>(e(o=>[...o,r]),()=>e(o=>{let u=o.slice(),c=u.indexOf(r);return c!==-1&&u.splice(c,1),u}))),n=A.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 Mt.createElement(Fx.Provider,{value:n},t.children)},[e])]}let nN="p";function rN(s,e){let t=A.useId(),i=GI(),{id:n=`headlessui-description-${t}`,...r}=s,o=sA(),u=va(e);Bn(()=>o.register(n),[n,o.register]);let c=kh({...o.slot,disabled:i||!1}),d={ref:u,...o.props,id:n};return pr()({ourProps:d,theirProps:r,slot:c,defaultTag:nN,name:o.name||"Description"})}let aN=Un(rN),oN=Object.assign(aN,{});var nA=(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))(nA||{});let lN=A.createContext(()=>{});function uN({value:s,children:e}){return Mt.createElement(lN.Provider,{value:s},e)}let rA=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 cN=Object.defineProperty,dN=(s,e,t)=>e in s?cN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,hN=(s,e,t)=>(dN(s,e+"",t),t),aA=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ur=(s,e,t)=>(aA(s,e,"read from private field"),t?t.call(s):e.get(s)),dy=(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)},uS=(s,e,t,i)=>(aA(s,e,"write to private field"),e.set(s,t),t),Zr,Yd,Wd;let fN=class{constructor(e){dy(this,Zr,{}),dy(this,Yd,new rA(()=>new Set)),dy(this,Wd,new Set),hN(this,"disposables",Za()),uS(this,Zr,e),ca.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return ur(this,Zr)}subscribe(e,t){if(ca.isServer)return()=>{};let i={selector:e,callback:t,current:e(ur(this,Zr))};return ur(this,Wd).add(i),this.disposables.add(()=>{ur(this,Wd).delete(i)})}on(e,t){return ca.isServer?()=>{}:(ur(this,Yd).get(e).add(t),this.disposables.add(()=>{ur(this,Yd).get(e).delete(t)}))}send(e){let t=this.reduce(ur(this,Zr),e);if(t!==ur(this,Zr)){uS(this,Zr,t);for(let i of ur(this,Wd)){let n=i.selector(ur(this,Zr));oA(i.current,n)||(i.current=n,i.callback(n))}for(let i of ur(this,Yd).get(e.type))i(ur(this,Zr),e)}}};Zr=new WeakMap,Yd=new WeakMap,Wd=new WeakMap;function oA(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:hy(s[Symbol.iterator](),e[Symbol.iterator]()):s instanceof Map&&e instanceof Map||s instanceof Set&&e instanceof Set?s.size!==e.size?!1:hy(s.entries(),e.entries()):cS(s)&&cS(e)?hy(Object.entries(s)[Symbol.iterator](),Object.entries(e)[Symbol.iterator]()):!1}function hy(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 cS(s){if(Object.prototype.toString.call(s)!=="[object Object]")return!1;let e=Object.getPrototypeOf(s);return e===null||Object.getPrototypeOf(e)===null}var mN=Object.defineProperty,pN=(s,e,t)=>e in s?mN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,dS=(s,e,t)=>(pN(s,typeof e!="symbol"?e+"":e,t),t),gN=(s=>(s[s.Push=0]="Push",s[s.Pop=1]="Pop",s))(gN||{});let yN={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}}},vN=class lA extends fN{constructor(){super(...arguments),dS(this,"actions",{push:e=>this.send({type:0,id:e}),pop:e=>this.send({type:1,id:e})}),dS(this,"selectors",{isTop:(e,t)=>e.stack[e.stack.length-1]===t,inStack:(e,t)=>e.stack.includes(t)})}static new(){return new lA({stack:[]})}reduce(e,t){return Xa(t.type,yN,e,t)}};const uA=new rA(()=>vN.new());var fy={exports:{}},my={};var hS;function xN(){if(hS)return my;hS=1;var s=Rp();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,o=s.useMemo,u=s.useDebugValue;return my.useSyncExternalStoreWithSelector=function(c,d,f,p,g){var v=n(null);if(v.current===null){var b={hasValue:!1,value:null};v.current=b}else b=v.current;v=o(function(){function S(j){if(!D){if(D=!0,R=j,j=p(j),g!==void 0&&b.hasValue){var V=b.value;if(g(V,j))return L=V}return L=j}if(V=L,t(R,j))return V;var P=p(j);return g!==void 0&&g(V,P)?(R=j,V):(R=j,L=P)}var D=!1,R,L,M=f===void 0?null:f;return[function(){return S(d())},M===null?void 0:function(){return S(M())}]},[d,f,p,g]);var _=i(c,v[0],v[1]);return r(function(){b.hasValue=!0,b.value=_},[_]),u(_),_},my}var fS;function bN(){return fS||(fS=1,fy.exports=xN()),fy.exports}var TN=bN();function cA(s,e,t=oA){return TN.useSyncExternalStoreWithSelector(Gi(i=>s.subscribe(_N,i)),Gi(()=>s.state),Gi(()=>s.state),Gi(e),t)}function _N(s){return s}function Dh(s,e){let t=A.useId(),i=uA.get(e),[n,r]=cA(i,A.useCallback(o=>[i.selectors.isTop(o,t),i.selectors.inStack(o,t)],[i,t]));return Bn(()=>{if(s)return i.actions.push(t),()=>i.actions.pop(t)},[i,s,t]),s?r?n:!0:!1}let Mv=new Map,ih=new Map;function mS(s){var e;let t=(e=ih.get(s))!=null?e:0;return ih.set(s,t+1),t!==0?()=>pS(s):(Mv.set(s,{"aria-hidden":s.getAttribute("aria-hidden"),inert:s.inert}),s.setAttribute("aria-hidden","true"),s.inert=!0,()=>pS(s))}function pS(s){var e;let t=(e=ih.get(s))!=null?e:1;if(t===1?ih.delete(s):ih.set(s,t-1),t!==1)return;let i=Mv.get(s);i&&(i["aria-hidden"]===null?s.removeAttribute("aria-hidden"):s.setAttribute("aria-hidden",i["aria-hidden"]),s.inert=i.inert,Mv.delete(s))}function SN(s,{allowed:e,disallowed:t}={}){let i=Dh(s,"inert-others");Bn(()=>{var n,r;if(!i)return;let o=Za();for(let c of(n=t?.())!=null?n:[])c&&o.add(mS(c));let u=(r=e?.())!=null?r:[];for(let c of u){if(!c)continue;let d=Ch(c);if(!d)continue;let f=c.parentElement;for(;f&&f!==d.body;){for(let p of f.children)u.some(g=>p.contains(g))||o.add(mS(p));f=f.parentElement}}return o.dispose},[i,e,t])}function EN(s,e,t){let i=iu(n=>{let r=n.getBoundingClientRect();r.x===0&&r.y===0&&r.width===0&&r.height===0&&t()});A.useEffect(()=>{if(!s)return;let n=e===null?null:Zl(e)?e:e.current;if(!n)return;let r=Za();if(typeof ResizeObserver<"u"){let o=new ResizeObserver(()=>i.current(n));o.observe(n),r.add(()=>o.disconnect())}if(typeof IntersectionObserver<"u"){let o=new IntersectionObserver(()=>i.current(n));o.observe(n),r.add(()=>o.disconnect())}return()=>r.dispose()},[e,i,s])}let Wm=["[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(","),wN=["[data-autofocus]"].map(s=>`${s}:not([tabindex='-1'])`).join(",");var za=(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))(za||{}),Pv=(s=>(s[s.Error=0]="Error",s[s.Overflow=1]="Overflow",s[s.Success=2]="Success",s[s.Underflow=3]="Underflow",s))(Pv||{}),AN=(s=>(s[s.Previous=-1]="Previous",s[s.Next=1]="Next",s))(AN||{});function CN(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(Wm)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}function kN(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(wN)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var dA=(s=>(s[s.Strict=0]="Strict",s[s.Loose=1]="Loose",s))(dA||{});function DN(s,e=0){var t;return s===((t=Ch(s))==null?void 0:t.body)?!1:Xa(e,{0(){return s.matches(Wm)},1(){let i=s;for(;i!==null;){if(i.matches(Wm))return!0;i=i.parentElement}return!1}})}var LN=(s=>(s[s.Keyboard=0]="Keyboard",s[s.Mouse=1]="Mouse",s))(LN||{});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 Ya(s){s?.focus({preventScroll:!0})}let RN=["textarea","input"].join(",");function IN(s){var e,t;return(t=(e=s?.matches)==null?void 0:e.call(s,RN))!=null?t:!1}function NN(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 o=n.compareDocumentPosition(r);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function sh(s,e,{sorted:t=!0,relativeTo:i=null,skipElements:n=[]}={}){let r=Array.isArray(s)?s.length>0?Iv(s[0]):document:Iv(s),o=Array.isArray(s)?t?NN(s):s:e&64?kN(s):CN(s);n.length>0&&o.length>1&&(o=o.filter(v=>!n.some(b=>b!=null&&"current"in b?b?.current===v:b===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,o.indexOf(i))-1;if(e&4)return Math.max(0,o.indexOf(i))+1;if(e&8)return o.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=e&32?{preventScroll:!0}:{},f=0,p=o.length,g;do{if(f>=p||f+p<=0)return 0;let v=c+f;if(e&16)v=(v+p)%p;else{if(v<0)return 3;if(v>=p)return 1}g=o[v],g?.focus(d),f+=u}while(g!==eA(g));return e&6&&IN(g)&&g.select(),2}function hA(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function ON(){return/Android/gi.test(window.navigator.userAgent)}function gS(){return hA()||ON()}function am(s,e,t,i){let n=iu(t);A.useEffect(()=>{if(!s)return;function r(o){n.current(o)}return document.addEventListener(e,r,i),()=>document.removeEventListener(e,r,i)},[s,e,i])}function fA(s,e,t,i){let n=iu(t);A.useEffect(()=>{if(!s)return;function r(o){n.current(o)}return window.addEventListener(e,r,i),()=>window.removeEventListener(e,r,i)},[s,e,i])}const yS=30;function MN(s,e,t){let i=iu(t),n=A.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 p(g){return typeof g=="function"?p(g()):Array.isArray(g)||g instanceof Set?g:[g]})(e);for(let p of f)if(p!==null&&(p.contains(d)||u.composed&&u.composedPath().includes(p)))return;return!DN(d,dA.Loose)&&d.tabIndex!==-1&&u.preventDefault(),i.current(u,d)},[i,e]),r=A.useRef(null);am(s,"pointerdown",u=>{var c,d;gS()||(r.current=((d=(c=u.composedPath)==null?void 0:c.call(u))==null?void 0:d[0])||u.target)},!0),am(s,"pointerup",u=>{if(gS()||!r.current)return;let c=r.current;return r.current=null,n(u,()=>c)},!0);let o=A.useRef({x:0,y:0});am(s,"touchstart",u=>{o.current.x=u.touches[0].clientX,o.current.y=u.touches[0].clientY},!0),am(s,"touchend",u=>{let c={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(c.x-o.current.x)>=yS||Math.abs(c.y-o.current.y)>=yS))return n(u,()=>Qo(u.target)?u.target:null)},!0),fA(s,"blur",u=>n(u,()=>eN(window.document.activeElement)?window.document.activeElement:null),!0)}function Ux(...s){return A.useMemo(()=>Ch(...s),[...s])}function mA(s,e,t,i){let n=iu(t);A.useEffect(()=>{s=s??window;function r(o){n.current(o)}return s.addEventListener(e,r,i),()=>s.removeEventListener(e,r,i)},[s,e,i])}function PN(s){return A.useSyncExternalStore(s.subscribe,s.getSnapshot,s.getSnapshot)}function BN(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 o=e[n].call(t,...r);o&&(t=o,i.forEach(u=>u()))}}}function FN(){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 UN(){return hA()?{before({doc:s,d:e,meta:t}){function i(n){for(let r of t().containers)for(let o of r())if(o.contains(n))return!0;return!1}e.microTask(()=>{var n;if(window.getComputedStyle(s.documentElement).scrollBehavior!=="auto"){let u=Za();u.style(s.documentElement,"scrollBehavior","auto"),e.add(()=>e.microTask(()=>u.dispose()))}let r=(n=window.scrollY)!=null?n:window.pageYOffset,o=null;e.addEventListener(s,"click",u=>{if(Qo(u.target))try{let c=u.target.closest("a");if(!c)return;let{hash:d}=new URL(c.href),f=s.querySelector(d);Qo(f)&&!i(f)&&(o=f)}catch{}},!0),e.group(u=>{e.addEventListener(s,"touchstart",c=>{if(u.dispose(),Qo(c.target)&&JI(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(Qo(u.target)){if(tN(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),o&&o.isConnected&&(o.scrollIntoView({block:"nearest"}),o=null)})})}}:{}}function jN(){return{before({doc:s,d:e}){e.style(s.documentElement,"overflow","hidden")}}}function vS(s){let e={};for(let t of s)Object.assign(e,t(e));return e}let Vl=BN(()=>new Map,{PUSH(s,e){var t;let i=(t=this.get(s))!=null?t:{doc:s,count:0,d:Za(),meta:new Set,computedMeta:{}};return i.count++,i.meta.add(e),i.computedMeta=vS(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=vS(t.meta)),this},SCROLL_PREVENT(s){let e={doc:s.doc,d:s.d,meta(){return s.computedMeta}},t=[UN(),FN(),jN()];t.forEach(({before:i})=>i?.(e)),t.forEach(({after:i})=>i?.(e))},SCROLL_ALLOW({d:s}){s.dispose()},TEARDOWN({doc:s}){this.delete(s)}});Vl.subscribe(()=>{let s=Vl.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)&&Vl.dispatch(t.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",t),t.count===0&&Vl.dispatch("TEARDOWN",t)}});function $N(s,e,t=()=>({containers:[]})){let i=PN(Vl),n=e?i.get(e):void 0,r=n?n.count>0:!1;return Bn(()=>{if(!(!e||!s))return Vl.dispatch("PUSH",e,t),()=>Vl.dispatch("POP",e,t)},[s,e]),r}function HN(s,e,t=()=>[document.body]){let i=Dh(s,"scroll-lock");$N(i,e,n=>{var r;return{containers:[...(r=n.containers)!=null?r:[],t]}})}function VN(s=0){let[e,t]=A.useState(s),i=A.useCallback(c=>t(c),[]),n=A.useCallback(c=>t(d=>d|c),[]),r=A.useCallback(c=>(e&c)===c,[e]),o=A.useCallback(c=>t(d=>d&~c),[]),u=A.useCallback(c=>t(d=>d^c),[]);return{flags:e,setFlag:i,addFlag:n,hasFlag:r,removeFlag:o,toggleFlag:u}}var GN={},xS,bS;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((xS=process==null?void 0:GN)==null?void 0:xS.NODE_ENV)==="test"&&typeof((bS=Element?.prototype)==null?void 0:bS.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 zN=(s=>(s[s.None=0]="None",s[s.Closed=1]="Closed",s[s.Enter=2]="Enter",s[s.Leave=4]="Leave",s))(zN||{});function qN(s){let e={};for(let t in s)s[t]===!0&&(e[`data-${t}`]="");return e}function KN(s,e,t,i){let[n,r]=A.useState(t),{hasFlag:o,addFlag:u,removeFlag:c}=VN(s&&n?3:0),d=A.useRef(!1),f=A.useRef(!1),p=Np();return Bn(()=>{var g;if(s){if(t&&r(!0),!e){t&&u(3);return}return(g=i?.start)==null||g.call(i,t),YN(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&&QN(e)||(d.current=!1,c(7),t||r(!1),(v=i?.end)==null||v.call(i,t))}})}},[s,t,e,p]),s?[n,{closed:o(1),enter:o(2),leave:o(4),transition:o(2)||o(4)}]:[t,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function YN(s,{prepare:e,run:t,done:i,inFlight:n}){let r=Za();return XN(s,{prepare:e,inFlight:n}),r.nextFrame(()=>{t(),r.requestAnimationFrame(()=>{r.add(WN(s,i))})}),r.dispose}function WN(s,e){var t,i;let n=Za();if(!s)return n.dispose;let r=!1;n.add(()=>{r=!0});let o=(i=(t=s.getAnimations)==null?void 0:t.call(s).filter(u=>u instanceof CSSTransition))!=null?i:[];return o.length===0?(e(),n.dispose):(Promise.allSettled(o.map(u=>u.finished)).then(()=>{r||e()}),n.dispose)}function XN(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 QN(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 jx(s,e){let t=A.useRef([]),i=Gi(s);A.useEffect(()=>{let n=[...t.current];for(let[r,o]of e.entries())if(t.current[r]!==o){let u=i(e,n);return t.current=e,u}},[i,...e])}let Op=A.createContext(null);Op.displayName="OpenClosedContext";var Dr=(s=>(s[s.Open=1]="Open",s[s.Closed=2]="Closed",s[s.Closing=4]="Closing",s[s.Opening=8]="Opening",s))(Dr||{});function Mp(){return A.useContext(Op)}function ZN({value:s,children:e}){return Mt.createElement(Op.Provider,{value:s},e)}function JN({children:s}){return Mt.createElement(Op.Provider,{value:null},s)}function e5(s){function e(){document.readyState!=="loading"&&(s(),document.removeEventListener("DOMContentLoaded",e))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",e),e())}let Wo=[];e5(()=>{function s(e){if(!Qo(e.target)||e.target===document.body||Wo[0]===e.target)return;let t=e.target;t=t.closest(Wm),Wo.unshift(t??e.target),Wo=Wo.filter(i=>i!=null&&i.isConnected),Wo.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 pA(s){let e=Gi(s),t=A.useRef(!1);A.useEffect(()=>(t.current=!1,()=>{t.current=!0,Ip(()=>{t.current&&e()})}),[e])}let gA=A.createContext(!1);function t5(){return A.useContext(gA)}function TS(s){return Mt.createElement(gA.Provider,{value:s.force},s.children)}function i5(s){let e=t5(),t=A.useContext(vA),[i,n]=A.useState(()=>{var r;if(!e&&t!==null)return(r=t.current)!=null?r:null;if(ca.isServer)return null;let o=s?.getElementById("headlessui-portal-root");if(o)return o;if(s===null)return null;let u=s.createElement("div");return u.setAttribute("id","headlessui-portal-root"),s.body.appendChild(u)});return A.useEffect(()=>{i!==null&&(s!=null&&s.body.contains(i)||s==null||s.body.appendChild(i))},[i,s]),A.useEffect(()=>{e||t!==null&&n(t.current)},[t,n,e]),i}let yA=A.Fragment,s5=Un(function(s,e){let{ownerDocument:t=null,...i}=s,n=A.useRef(null),r=va(iN(g=>{n.current=g}),e),o=Ux(n.current),u=t??o,c=i5(u),d=A.useContext(Bv),f=Np(),p=pr();return pA(()=>{var g;c&&c.childNodes.length<=0&&((g=c.parentElement)==null||g.removeChild(c))}),c?yc.createPortal(Mt.createElement("div",{"data-headlessui-portal":"",ref:g=>{f.dispose(),d&&g&&f.add(d.register(g))}},p({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:yA,name:"Portal"})),c):null});function n5(s,e){let t=va(e),{enabled:i=!0,ownerDocument:n,...r}=s,o=pr();return i?Mt.createElement(s5,{...r,ownerDocument:n,ref:t}):o({ourProps:{ref:t},theirProps:r,slot:{},defaultTag:yA,name:"Portal"})}let r5=A.Fragment,vA=A.createContext(null);function a5(s,e){let{target:t,...i}=s,n={ref:va(e)},r=pr();return Mt.createElement(vA.Provider,{value:t},r({ourProps:n,theirProps:i,defaultTag:r5,name:"Popover.Group"}))}let Bv=A.createContext(null);function o5(){let s=A.useContext(Bv),e=A.useRef([]),t=Gi(r=>(e.current.push(r),s&&s.register(r),()=>i(r))),i=Gi(r=>{let o=e.current.indexOf(r);o!==-1&&e.current.splice(o,1),s&&s.unregister(r)}),n=A.useMemo(()=>({register:t,unregister:i,portals:e}),[t,i,e]);return[e,A.useMemo(()=>function({children:r}){return Mt.createElement(Bv.Provider,{value:n},r)},[n])]}let l5=Un(n5),xA=Un(a5),u5=Object.assign(l5,{Group:xA});function c5(s,e=typeof document<"u"?document.defaultView:null,t){let i=Dh(s,"escape");mA(e,"keydown",n=>{i&&(n.defaultPrevented||n.key===nA.Escape&&t(n))})}function d5(){var s;let[e]=A.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[t,i]=A.useState((s=e?.matches)!=null?s:!1);return Bn(()=>{if(!e)return;function n(r){i(r.matches)}return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[e]),t}function h5({defaultContainers:s=[],portals:e,mainTreeNode:t}={}){let i=Gi(()=>{var n,r;let o=Ch(t),u=[];for(let c of s)c!==null&&(Zo(c)?u.push(c):"current"in c&&Zo(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=o?.querySelectorAll("html > *, body > *"))!=null?n:[])c!==document.body&&c!==document.head&&Zo(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:Gi(n=>i().some(r=>r.contains(n)))}}let bA=A.createContext(null);function _S({children:s,node:e}){let[t,i]=A.useState(null),n=TA(e??t);return Mt.createElement(bA.Provider,{value:n},s,n===null&&Mt.createElement(Ov,{features:Ym.Hidden,ref:r=>{var o,u;if(r){for(let c of(u=(o=Ch(r))==null?void 0:o.querySelectorAll("html > *, body > *"))!=null?u:[])if(c!==document.body&&c!==document.head&&Zo(c)&&c!=null&&c.contains(r)){i(c);break}}}}))}function TA(s=null){var e;return(e=A.useContext(bA))!=null?e:s}function f5(){let s=typeof document>"u";return"useSyncExternalStore"in iS?(e=>e.useSyncExternalStore)(iS)(()=>()=>{},()=>!1,()=>!s):!1}function Pp(){let s=f5(),[e,t]=A.useState(ca.isHandoffComplete);return e&&ca.isHandoffComplete===!1&&t(!1),A.useEffect(()=>{e!==!0&&t(!0)},[e]),A.useEffect(()=>ca.handoff(),[]),s?!1:e}function $x(){let s=A.useRef(!1);return Bn(()=>(s.current=!0,()=>{s.current=!1}),[]),s}var Xd=(s=>(s[s.Forwards=0]="Forwards",s[s.Backwards=1]="Backwards",s))(Xd||{});function m5(){let s=A.useRef(0);return fA(!0,"keydown",e=>{e.key==="Tab"&&(s.current=e.shiftKey?1:0)},!0),s}function _A(s){if(!s)return new Set;if(typeof s=="function")return new Set(s());let e=new Set;for(let t of s.current)Zo(t.current)&&e.add(t.current);return e}let p5="div";var jl=(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))(jl||{});function g5(s,e){let t=A.useRef(null),i=va(t,e),{initialFocus:n,initialFocusFallback:r,containers:o,features:u=15,...c}=s;Pp()||(u=0);let d=Ux(t.current);b5(u,{ownerDocument:d});let f=T5(u,{ownerDocument:d,container:t,initialFocus:n,initialFocusFallback:r});_5(u,{ownerDocument:d,container:t,containers:o,previousActiveElement:f});let p=m5(),g=Gi(R=>{if(!Zl(t.current))return;let L=t.current;(M=>M())(()=>{Xa(p.current,{[Xd.Forwards]:()=>{sh(L,za.First,{skipElements:[R.relatedTarget,r]})},[Xd.Backwards]:()=>{sh(L,za.Last,{skipElements:[R.relatedTarget,r]})}})})}),v=Dh(!!(u&2),"focus-trap#tab-lock"),b=Np(),_=A.useRef(!1),S={ref:i,onKeyDown(R){R.key=="Tab"&&(_.current=!0,b.requestAnimationFrame(()=>{_.current=!1}))},onBlur(R){if(!(u&4))return;let L=_A(o);Zl(t.current)&&L.add(t.current);let M=R.relatedTarget;Qo(M)&&M.dataset.headlessuiFocusGuard!=="true"&&(SA(L,M)||(_.current?sh(t.current,Xa(p.current,{[Xd.Forwards]:()=>za.Next,[Xd.Backwards]:()=>za.Previous})|za.WrapAround,{relativeTo:R.target}):Qo(R.target)&&Ya(R.target)))}},D=pr();return Mt.createElement(Mt.Fragment,null,v&&Mt.createElement(Ov,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Ym.Focusable}),D({ourProps:S,theirProps:c,defaultTag:p5,name:"FocusTrap"}),v&&Mt.createElement(Ov,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Ym.Focusable}))}let y5=Un(g5),v5=Object.assign(y5,{features:jl});function x5(s=!0){let e=A.useRef(Wo.slice());return jx(([t],[i])=>{i===!0&&t===!1&&Ip(()=>{e.current.splice(0)}),i===!1&&t===!0&&(e.current=Wo.slice())},[s,Wo,e]),Gi(()=>{var t;return(t=e.current.find(i=>i!=null&&i.isConnected))!=null?t:null})}function b5(s,{ownerDocument:e}){let t=!!(s&8),i=x5(t);jx(()=>{t||HI(e?.body)&&Ya(i())},[t]),pA(()=>{t&&Ya(i())})}function T5(s,{ownerDocument:e,container:t,initialFocus:i,initialFocusFallback:n}){let r=A.useRef(null),o=Dh(!!(s&1),"focus-trap#initial-focus"),u=$x();return jx(()=>{if(s===0)return;if(!o){n!=null&&n.current&&Ya(n.current);return}let c=t.current;c&&Ip(()=>{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)Ya(i.current);else{if(s&16){if(sh(c,za.First|za.AutoFocus)!==Pv.Error)return}else if(sh(c,za.First)!==Pv.Error)return;if(n!=null&&n.current&&(Ya(n.current),e?.activeElement===n.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}r.current=e?.activeElement})},[n,o,s]),r}function _5(s,{ownerDocument:e,container:t,containers:i,previousActiveElement:n}){let r=$x(),o=!!(s&4);mA(e?.defaultView,"focus",u=>{if(!o||!r.current)return;let c=_A(i);Zl(t.current)&&c.add(t.current);let d=n.current;if(!d)return;let f=u.target;Zl(f)?SA(c,f)?(n.current=f,Ya(f)):(u.preventDefault(),u.stopPropagation(),Ya(d)):Ya(n.current)},!0)}function SA(s,e){for(let t of s)if(t.contains(e))return!0;return!1}function EA(s){var e;return!!(s.enter||s.enterFrom||s.enterTo||s.leave||s.leaveFrom||s.leaveTo)||!th((e=s.as)!=null?e:AA)||Mt.Children.count(s.children)===1}let Bp=A.createContext(null);Bp.displayName="TransitionContext";var S5=(s=>(s.Visible="visible",s.Hidden="hidden",s))(S5||{});function E5(){let s=A.useContext(Bp);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}function w5(){let s=A.useContext(Fp);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}let Fp=A.createContext(null);Fp.displayName="NestingContext";function Up(s){return"children"in s?Up(s.children):s.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function wA(s,e){let t=iu(s),i=A.useRef([]),n=$x(),r=Np(),o=Gi((v,b=Xo.Hidden)=>{let _=i.current.findIndex(({el:S})=>S===v);_!==-1&&(Xa(b,{[Xo.Unmount](){i.current.splice(_,1)},[Xo.Hidden](){i.current[_].state="hidden"}}),r.microTask(()=>{var S;!Up(i)&&n.current&&((S=t.current)==null||S.call(t))}))}),u=Gi(v=>{let b=i.current.find(({el:_})=>_===v);return b?b.state!=="visible"&&(b.state="visible"):i.current.push({el:v,state:"visible"}),()=>o(v,Xo.Unmount)}),c=A.useRef([]),d=A.useRef(Promise.resolve()),f=A.useRef({enter:[],leave:[]}),p=Gi((v,b,_)=>{c.current.splice(0),e&&(e.chains.current[b]=e.chains.current[b].filter(([S])=>S!==v)),e?.chains.current[b].push([v,new Promise(S=>{c.current.push(S)})]),e?.chains.current[b].push([v,new Promise(S=>{Promise.all(f.current[b].map(([D,R])=>R)).then(()=>S())})]),b==="enter"?d.current=d.current.then(()=>e?.wait.current).then(()=>_(b)):_(b)}),g=Gi((v,b,_)=>{Promise.all(f.current[b].splice(0).map(([S,D])=>D)).then(()=>{var S;(S=c.current.shift())==null||S()}).then(()=>_(b))});return A.useMemo(()=>({children:i,register:u,unregister:o,onStart:p,onStop:g,wait:d,chains:f}),[u,o,i,p,g,f,d])}let AA=A.Fragment,CA=Km.RenderStrategy;function A5(s,e){var t,i;let{transition:n=!0,beforeEnter:r,afterEnter:o,beforeLeave:u,afterLeave:c,enter:d,enterFrom:f,enterTo:p,entered:g,leave:v,leaveFrom:b,leaveTo:_,...S}=s,[D,R]=A.useState(null),L=A.useRef(null),M=EA(s),j=va(...M?[L,e,R]:e===null?[]:[e]),V=(t=S.unmount)==null||t?Xo.Unmount:Xo.Hidden,{show:P,appear:z,initial:I}=E5(),[O,W]=A.useState(P?"visible":"hidden"),X=w5(),{register:q,unregister:ue}=X;Bn(()=>q(L),[q,L]),Bn(()=>{if(V===Xo.Hidden&&L.current){if(P&&O!=="visible"){W("visible");return}return Xa(O,{hidden:()=>ue(L),visible:()=>q(L)})}},[O,L,q,ue,P,V]);let ie=Pp();Bn(()=>{if(M&&ie&&O==="visible"&&L.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[L,O,ie,M]);let Y=I&&!z,G=z&&P&&I,J=A.useRef(!1),oe=wA(()=>{J.current||(W("hidden"),ue(L))},X),ce=Gi(Be=>{J.current=!0;let tt=Be?"enter":"leave";oe.onStart(L,tt,Je=>{Je==="enter"?r?.():Je==="leave"&&u?.()})}),F=Gi(Be=>{let tt=Be?"enter":"leave";J.current=!1,oe.onStop(L,tt,Je=>{Je==="enter"?o?.():Je==="leave"&&c?.()}),tt==="leave"&&!Up(oe)&&(W("hidden"),ue(L))});A.useEffect(()=>{M&&n||(ce(P),F(P))},[P,M,n]);let ee=!(!n||!M||!ie||Y),[,pe]=KN(ee,D,P,{start:ce,end:F}),_e=Pl({ref:j,className:((i=Nv(S.className,G&&d,G&&f,pe.enter&&d,pe.enter&&pe.closed&&f,pe.enter&&!pe.closed&&p,pe.leave&&v,pe.leave&&!pe.closed&&b,pe.leave&&pe.closed&&_,!pe.transition&&P&&g))==null?void 0:i.trim())||void 0,...qN(pe)}),ve=0;O==="visible"&&(ve|=Dr.Open),O==="hidden"&&(ve|=Dr.Closed),P&&O==="hidden"&&(ve|=Dr.Opening),!P&&O==="visible"&&(ve|=Dr.Closing);let Ce=pr();return Mt.createElement(Fp.Provider,{value:oe},Mt.createElement(ZN,{value:ve},Ce({ourProps:_e,theirProps:S,defaultTag:AA,features:CA,visible:O==="visible",name:"Transition.Child"})))}function C5(s,e){let{show:t,appear:i=!1,unmount:n=!0,...r}=s,o=A.useRef(null),u=EA(s),c=va(...u?[o,e]:e===null?[]:[e]);Pp();let d=Mp();if(t===void 0&&d!==null&&(t=(d&Dr.Open)===Dr.Open),t===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[f,p]=A.useState(t?"visible":"hidden"),g=wA(()=>{t||p("hidden")}),[v,b]=A.useState(!0),_=A.useRef([t]);Bn(()=>{v!==!1&&_.current[_.current.length-1]!==t&&(_.current.push(t),b(!1))},[_,t]);let S=A.useMemo(()=>({show:t,appear:i,initial:v}),[t,i,v]);Bn(()=>{t?p("visible"):!Up(g)&&o.current!==null&&p("hidden")},[t,g]);let D={unmount:n},R=Gi(()=>{var j;v&&b(!1),(j=s.beforeEnter)==null||j.call(s)}),L=Gi(()=>{var j;v&&b(!1),(j=s.beforeLeave)==null||j.call(s)}),M=pr();return Mt.createElement(Fp.Provider,{value:g},Mt.createElement(Bp.Provider,{value:S},M({ourProps:{...D,as:A.Fragment,children:Mt.createElement(kA,{ref:c,...D,...r,beforeEnter:R,beforeLeave:L})},theirProps:{},defaultTag:A.Fragment,features:CA,visible:f==="visible",name:"Transition"})))}function k5(s,e){let t=A.useContext(Bp)!==null,i=Mp()!==null;return Mt.createElement(Mt.Fragment,null,!t&&i?Mt.createElement(Fv,{ref:e,...s}):Mt.createElement(kA,{ref:e,...s}))}let Fv=Un(C5),kA=Un(A5),Hx=Un(k5),nh=Object.assign(Fv,{Child:Hx,Root:Fv});var D5=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(D5||{}),L5=(s=>(s[s.SetTitleId=0]="SetTitleId",s))(L5||{});let R5={0(s,e){return s.titleId===e.id?s:{...s,titleId:e.id}}},Vx=A.createContext(null);Vx.displayName="DialogContext";function jp(s){let e=A.useContext(Vx);if(e===null){let t=new Error(`<${s} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,jp),t}return e}function I5(s,e){return Xa(e.type,R5,s,e)}let SS=Un(function(s,e){let t=A.useId(),{id:i=`headlessui-dialog-${t}`,open:n,onClose:r,initialFocus:o,role:u="dialog",autoFocus:c=!0,__demoMode:d=!1,unmount:f=!1,...p}=s,g=A.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(g.current||(g.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let v=Mp();n===void 0&&v!==null&&(n=(v&Dr.Open)===Dr.Open);let b=A.useRef(null),_=va(b,e),S=Ux(b.current),D=n?0:1,[R,L]=A.useReducer(I5,{titleId:null,descriptionId:null,panelRef:A.createRef()}),M=Gi(()=>r(!1)),j=Gi(pe=>L({type:0,id:pe})),V=Pp()?D===0:!1,[P,z]=o5(),I={get current(){var pe;return(pe=R.panelRef.current)!=null?pe:b.current}},O=TA(),{resolveContainers:W}=h5({mainTreeNode:O,portals:P,defaultContainers:[I]}),X=v!==null?(v&Dr.Closing)===Dr.Closing:!1;SN(d||X?!1:V,{allowed:Gi(()=>{var pe,_e;return[(_e=(pe=b.current)==null?void 0:pe.closest("[data-headlessui-portal]"))!=null?_e:null]}),disallowed:Gi(()=>{var pe;return[(pe=O?.closest("body > *:not(#headlessui-portal-root)"))!=null?pe:null]})});let q=uA.get(null);Bn(()=>{if(V)return q.actions.push(i),()=>q.actions.pop(i)},[q,i,V]);let ue=cA(q,A.useCallback(pe=>q.selectors.isTop(pe,i),[q,i]));MN(ue,W,pe=>{pe.preventDefault(),M()}),c5(ue,S?.defaultView,pe=>{pe.preventDefault(),pe.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),M()}),HN(d||X?!1:V,S,W),EN(V,b,M);let[ie,Y]=sN(),G=A.useMemo(()=>[{dialogState:D,close:M,setTitleId:j,unmount:f},R],[D,M,j,f,R]),J=kh({open:D===0}),oe={ref:_,id:i,role:u,tabIndex:-1,"aria-modal":d?void 0:D===0?!0:void 0,"aria-labelledby":R.titleId,"aria-describedby":ie,unmount:f},ce=!d5(),F=jl.None;V&&!d&&(F|=jl.RestoreFocus,F|=jl.TabLock,c&&(F|=jl.AutoFocus),ce&&(F|=jl.InitialFocus));let ee=pr();return Mt.createElement(JN,null,Mt.createElement(TS,{force:!0},Mt.createElement(u5,null,Mt.createElement(Vx.Provider,{value:G},Mt.createElement(xA,{target:b},Mt.createElement(TS,{force:!1},Mt.createElement(Y,{slot:J},Mt.createElement(z,null,Mt.createElement(v5,{initialFocus:o,initialFocusFallback:b,containers:W,features:F},Mt.createElement(uN,{value:M},ee({ourProps:oe,theirProps:p,slot:J,defaultTag:N5,features:O5,visible:D===0,name:"Dialog"})))))))))))}),N5="div",O5=Km.RenderStrategy|Km.Static;function M5(s,e){let{transition:t=!1,open:i,...n}=s,r=Mp(),o=s.hasOwnProperty("open")||r!==null,u=s.hasOwnProperty("onClose");if(!o&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!o)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?Mt.createElement(_S,null,Mt.createElement(nh,{show:i,transition:t,unmount:n.unmount},Mt.createElement(SS,{ref:e,...n}))):Mt.createElement(_S,null,Mt.createElement(SS,{ref:e,open:i,...n}))}let P5="div";function B5(s,e){let t=A.useId(),{id:i=`headlessui-dialog-panel-${t}`,transition:n=!1,...r}=s,[{dialogState:o,unmount:u},c]=jp("Dialog.Panel"),d=va(e,c.panelRef),f=kh({open:o===0}),p=Gi(S=>{S.stopPropagation()}),g={ref:d,id:i,onClick:p},v=n?Hx:A.Fragment,b=n?{unmount:u}:{},_=pr();return Mt.createElement(v,{...b},_({ourProps:g,theirProps:r,slot:f,defaultTag:P5,name:"Dialog.Panel"}))}let F5="div";function U5(s,e){let{transition:t=!1,...i}=s,[{dialogState:n,unmount:r}]=jp("Dialog.Backdrop"),o=kh({open:n===0}),u={ref:e,"aria-hidden":!0},c=t?Hx:A.Fragment,d=t?{unmount:r}:{},f=pr();return Mt.createElement(c,{...d},f({ourProps:u,theirProps:i,slot:o,defaultTag:F5,name:"Dialog.Backdrop"}))}let j5="h2";function $5(s,e){let t=A.useId(),{id:i=`headlessui-dialog-title-${t}`,...n}=s,[{dialogState:r,setTitleId:o}]=jp("Dialog.Title"),u=va(e);A.useEffect(()=>(o(i),()=>o(null)),[i,o]);let c=kh({open:r===0}),d={ref:u,id:i};return pr()({ourProps:d,theirProps:n,slot:c,defaultTag:j5,name:"Dialog.Title"})}let H5=Un(M5),V5=Un(B5);Un(U5);let G5=Un($5),sc=Object.assign(H5,{Panel:V5,Title:G5,Description:oN});function z5({open:s,onClose:e,onApply:t,initialCookies:i}){const[n,r]=A.useState(""),[o,u]=A.useState(""),[c,d]=A.useState([]),f=A.useRef(!1);A.useEffect(()=>{s&&!f.current&&(r(""),u(""),d(i??[])),f.current=s},[s,i]);function p(){const b=n.trim(),_=o.trim();!b||!_||(d(S=>[...S.filter(R=>R.name!==b),{name:b,value:_}]),r(""),u(""))}function g(b){d(_=>_.filter(S=>S.name!==b))}function v(){t(c),e()}return y.jsxs(sc,{open:s,onClose:e,className:"relative z-50",children:[y.jsx("div",{className:"fixed inset-0 bg-black/40","aria-hidden":"true"}),y.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",children:y.jsxs(sc.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:[y.jsx(sc.Title,{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Zusätzliche Cookies"}),y.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[y.jsx("input",{value:n,onChange:b=>r(b.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"}),y.jsx("input",{value:o,onChange:b=>u(b.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"})]}),y.jsx("div",{className:"mt-2",children:y.jsx(ti,{size:"sm",variant:"secondary",onClick:p,disabled:!n.trim()||!o.trim(),children:"Hinzufügen"})}),y.jsx("div",{className:"mt-4",children:c.length===0?y.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Noch keine Cookies hinzugefügt."}):y.jsxs("table",{className:"min-w-full text-sm border divide-y dark:divide-white/10",children:[y.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700/50",children:y.jsxs("tr",{children:[y.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Name"}),y.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Wert"}),y.jsx("th",{className:"px-3 py-2"})]})}),y.jsx("tbody",{className:"divide-y dark:divide-white/10",children:c.map(b=>y.jsxs("tr",{children:[y.jsx("td",{className:"px-3 py-2 font-mono",children:b.name}),y.jsx("td",{className:"px-3 py-2 truncate max-w-[240px]",children:b.value}),y.jsx("td",{className:"px-3 py-2 text-right",children:y.jsx("button",{onClick:()=>g(b.name),className:"text-xs text-red-600 hover:underline dark:text-red-400",children:"Entfernen"})})]},b.name))})]})}),y.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[y.jsx(ti,{variant:"secondary",onClick:e,children:"Abbrechen"}),y.jsx(ti,{variant:"primary",onClick:v,children:"Übernehmen"})]})]})})]})}function q5({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 K5=A.forwardRef(q5);function ES({tabs:s,value:e,onChange:t,className:i,ariaLabel:n="Ansicht auswählen",variant:r="underline",hideCountUntilMd:o=!1}){if(!s?.length)return null;const u=s.find(g=>g.id===e)??s[0],c=yi("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=g=>yi(g?"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",o?"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=(g,v)=>v.count===void 0?null:y.jsx("span",{className:d(g),children:v.count}),p=()=>{switch(r){case"underline":case"underlineIcons":return y.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:y.jsx("nav",{"aria-label":n,className:"-mb-px flex space-x-8",children:s.map(g=>{const v=g.id===u.id,b=!!g.disabled;return y.jsxs("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:yi(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",b&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[r==="underlineIcons"&&g.icon?y.jsx(g.icon,{"aria-hidden":"true",className:yi(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,y.jsx("span",{children:g.label}),f(v,g)]},g.id)})})});case"pills":case"pillsGray":case"pillsBrand":{const g=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 y.jsx("nav",{"aria-label":n,className:"flex space-x-4",children:s.map(b=>{const _=b.id===u.id,S=!!b.disabled;return y.jsxs("button",{type:"button",onClick:()=>!S&&t(b.id),disabled:S,"aria-current":_?"page":void 0,className:yi(_?g:v,"inline-flex items-center rounded-md px-3 py-2 text-sm font-medium",S&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:[y.jsx("span",{children:b.label}),b.count!==void 0?y.jsx("span",{className:yi(_?"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:b.count}):null]},b.id)})})}case"fullWidthUnderline":return y.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:y.jsx("nav",{"aria-label":n,className:"-mb-px flex",children:s.map(g=>{const v=g.id===u.id,b=!!g.disabled;return y.jsx("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:yi(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",b&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:g.label},g.id)})})});case"barUnderline":return y.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((g,v)=>{const b=g.id===u.id,_=!!g.disabled;return y.jsxs("button",{type:"button",onClick:()=>!_&&t(g.id),disabled:_,"aria-current":b?"page":void 0,className:yi(b?"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",_&&"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[y.jsxs("span",{className:"inline-flex items-center justify-center",children:[g.label,g.count!==void 0?y.jsx("span",{className:"ml-2 rounded-full bg-white/70 px-2 py-0.5 text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-white",children:g.count}):null]}),y.jsx("span",{"aria-hidden":"true",className:yi(b?"bg-indigo-500 dark:bg-indigo-400":"bg-transparent","absolute inset-x-0 bottom-0 h-0.5")})]},g.id)})});case"simple":return y.jsx("nav",{className:"flex border-b border-gray-200 py-4 dark:border-white/10","aria-label":n,children:y.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(g=>{const v=g.id===u.id,b=!!g.disabled;return y.jsx("li",{children:y.jsx("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:yi(v?"text-indigo-600 dark:text-indigo-400":"hover:text-gray-700 dark:hover:text-white",b&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:g.label})},g.id)})})});default:return null}};return y.jsxs("div",{className:i,children:[y.jsxs("div",{className:"grid grid-cols-1 sm:hidden",children:[y.jsx("select",{value:u.id,onChange:g=>t(g.target.value),"aria-label":n,className:c,children:s.map(g=>y.jsx("option",{value:g.id,children:g.label},g.id))}),y.jsx(K5,{"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"})]}),y.jsx("div",{className:"hidden sm:block",children:p()})]})}function ha({header:s,footer:e,grayBody:t=!1,grayFooter:i=!1,edgeToEdgeMobile:n=!1,well:r=!1,noBodyPadding:o=!1,className:u,bodyClassName:c,children:d}){const f=r;return y.jsxs("div",{className:yi("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&&y.jsx("div",{className:"shrink-0 px-4 py-5 sm:px-6 border-b border-gray-200 dark:border-white/10",children:s}),y.jsx("div",{className:yi("min-h-0",o?"p-0":"px-4 py-5 sm:p-6",t&&"bg-gray-50 dark:bg-gray-800",c),children:d}),e&&y.jsx("div",{className:yi("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 Uv({checked:s,onChange:e,id:t,name:i,disabled:n,required:r,ariaLabel:o,ariaLabelledby:u,ariaDescribedby:c,size:d="default",variant:f="simple",className:p}){const g=b=>{n||e(b.target.checked)},v=yi("absolute inset-0 size-full appearance-none focus:outline-hidden",n&&"cursor-not-allowed");return d==="short"?y.jsxs("div",{className:yi("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",p),children:[y.jsx("span",{className:yi("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")}),y.jsx("span",{className:yi("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")}),y.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:g,disabled:n,required:r,"aria-label":o,"aria-labelledby":u,"aria-describedby":c,className:v})]}):y.jsxs("div",{className:yi("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",p),children:[f==="icon"?y.jsxs("span",{className:yi("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:[y.jsx("span",{"aria-hidden":"true",className:yi("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-in",s?"opacity-0 duration-100":"opacity-100 duration-200"),children:y.jsx("svg",{fill:"none",viewBox:"0 0 12 12",className:"size-3 text-gray-400 dark:text-gray-600",children:y.jsx("path",{d:"M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}),y.jsx("span",{"aria-hidden":"true",className:yi("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-out",s?"opacity-100 duration-200":"opacity-0 duration-100"),children:y.jsx("svg",{fill:"currentColor",viewBox:"0 0 12 12",className:"size-3 text-indigo-600 dark:text-indigo-500",children:y.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"})})})]}):y.jsx("span",{className:yi("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")}),y.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:g,disabled:n,required:r,"aria-label":o,"aria-labelledby":u,"aria-describedby":c,className:v})]})}function Go({label:s,description:e,labelPosition:t="left",id:i,className:n,...r}){const o=A.useId(),u=i??`sw-${o}`,c=`${u}-label`,d=`${u}-desc`;return t==="right"?y.jsxs("div",{className:yi("flex items-center justify-between gap-3",n),children:[y.jsx(Uv,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0}),y.jsxs("div",{className:"text-sm",children:[y.jsx("label",{id:c,htmlFor:u,className:"font-medium text-gray-900 dark:text-white",children:s})," ",e?y.jsx("span",{id:d,className:"text-gray-500 dark:text-gray-400",children:e}):null]})]}):y.jsxs("div",{className:yi("flex items-center justify-between",n),children:[y.jsxs("span",{className:"flex grow flex-col",children:[y.jsx("label",{id:c,htmlFor:u,className:"text-sm/6 font-medium text-gray-900 dark:text-white",children:s}),e?y.jsx("span",{id:d,className:"text-sm text-gray-500 dark:text-gray-400",children:e}):null]}),y.jsx(Uv,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0})]})}function vc({label:s,value:e=0,indeterminate:t=!1,showPercent:i=!1,rightLabel:n,steps:r,currentStep:o,size:u="md",className:c}){const d=Math.max(0,Math.min(100,Number(e)||0)),f=u==="sm"?"h-1.5":"h-2",p=Array.isArray(r)&&r.length>0,g=p?r.length:0,v=S=>S===0?"text-left":S===g-1?"text-right":"text-center",b=S=>typeof o!="number"||!Number.isFinite(o)?!1:S<=o,_=i&&!t;return y.jsxs("div",{className:c,children:[s||_?y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s?y.jsx("p",{className:"flex-1 min-w-0 truncate text-xs font-medium text-gray-900 dark:text-white",children:s}):y.jsx("span",{className:"flex-1"}),_?y.jsxs("span",{className:"shrink-0 text-xs font-medium text-gray-700 dark:text-gray-300",children:[Math.round(d),"%"]}):null]}):null,y.jsxs("div",{"aria-hidden":"true",className:s||_?"mt-2":"",children:[y.jsx("div",{className:"overflow-hidden rounded-full bg-gray-200 dark:bg-white/10",children:t?y.jsx("div",{className:`${f} w-full rounded-full bg-indigo-600/70 dark:bg-indigo-500/70 animate-pulse`}):y.jsx("div",{className:`${f} rounded-full bg-indigo-600 dark:bg-indigo-500 transition-[width] duration-200`,style:{width:`${d}%`}})}),n?y.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:n}):null,p?y.jsx("div",{className:"mt-3 hidden text-sm font-medium text-gray-600 sm:grid dark:text-gray-400",style:{gridTemplateColumns:`repeat(${g}, minmax(0, 1fr))`},children:r.map((S,D)=>y.jsx("div",{className:[v(D),b(D)?"text-indigo-600 dark:text-indigo-400":""].join(" "),children:S},`${D}-${S}`))}):null]})]})}async function wS(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 Y5({onFinished:s}){const[e,t]=A.useState(null),[i,n]=A.useState(null),[r,o]=A.useState(!1),[u,c]=A.useState(!1),d=A.useCallback(async()=>{try{const M=await wS("/api/tasks/generate-assets");t(M)}catch(M){n(M?.message??String(M))}},[]),f=A.useRef(!1);A.useEffect(()=>{const M=f.current,j=!!e?.running;f.current=j,M&&!j&&s?.()},[e?.running,s]),A.useEffect(()=>{d()},[d]),A.useEffect(()=>{if(!e?.running)return;const M=window.setInterval(d,1200);return()=>window.clearInterval(M)},[e?.running,d]);async function p(){n(null),o(!0);try{const M=await wS("/api/tasks/generate-assets",{method:"POST"});t(M)}catch(M){n(M?.message??String(M))}finally{o(!1)}}async function g(){n(null),c(!0);try{await fetch("/api/tasks/generate-assets",{method:"DELETE",cache:"no-store"})}catch{}finally{await d(),c(!1)}}const v=!!e?.running,b=e?.total??0,_=e?.done??0,S=b>0?Math.min(100,Math.round(_/b*100)):0,D=M=>{const j=String(M??"").trim();if(!j)return null;const V=new Date(j);return Number.isFinite(V.getTime())?V.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):null},R=D(e?.startedAt),L=D(e?.finishedAt);return y.jsxs("div",{className:`\r
rounded-2xl border border-gray-200 bg-white/80 p-4 shadow-sm\r
backdrop-blur supports-[backdrop-filter]:bg-white/60\r
dark:border-white/10 dark:bg-gray-950/50 dark:supports-[backdrop-filter]:bg-gray-950/35\r
`,children:[y.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Assets-Generator"}),v?y.jsx("span",{className:"inline-flex items-center rounded-full bg-indigo-500/10 px-2 py-0.5 text-[11px] font-semibold text-indigo-700 ring-1 ring-inset ring-indigo-200 dark:text-indigo-200 dark:ring-indigo-400/30",children:"läuft"}):y.jsx("span",{className:"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/5 dark:text-gray-200 dark:ring-white/10",children:"bereit"})]}),y.jsxs("div",{className:"mt-1 text-xs text-gray-600 dark:text-white/70",children:["Erzeugt pro fertiger Datei unter ",y.jsx("span",{className:"font-mono",children:"/generated/<id>/"})," ",y.jsx("span",{className:"font-mono",children:"thumbs.jpg"}),", ",y.jsx("span",{className:"font-mono",children:"preview.mp4"})," ","und ",y.jsx("span",{className:"font-mono",children:"meta.json"})," für schnelle Listen & zuverlässige Duration."]})]}),y.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[v?y.jsx(ti,{variant:"secondary",color:"red",onClick:g,disabled:u,className:"w-full sm:w-auto",children:u?"Stoppe…":"Stop"}):null,y.jsx(ti,{variant:"primary",onClick:p,disabled:r||v,className:"w-full sm:w-auto",children:r?"Starte…":v?"Läuft…":"Generieren"})]})]}),i?y.jsx("div",{className:"mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",children:i}):null,e?.error?y.jsx("div",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:e.error}):null,e?y.jsxs("div",{className:"mt-4 space-y-3",children:[y.jsx(vc,{value:S,showPercent:!0,rightLabel:b?`${_}/${b} Dateien`:"—"}),y.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[y.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-[11px] font-medium text-gray-600 dark:text-white/70",children:"Thumbs"}),y.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums text-gray-900 dark:text-white",children:e.generatedThumbs??0})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-[11px] font-medium text-gray-600 dark:text-white/70",children:"Previews"}),y.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums text-gray-900 dark:text-white",children:e.generatedPreviews??0})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-[11px] font-medium text-gray-600 dark:text-white/70",children:"Übersprungen"}),y.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums text-gray-900 dark:text-white",children:e.skipped??0})]})]}),y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs text-gray-600 dark:text-white/70",children:[y.jsx("span",{children:R?y.jsxs(y.Fragment,{children:["Start: ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:R})]}):"Start: —"}),y.jsx("span",{children:L?y.jsxs(y.Fragment,{children:["Ende: ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L})]}):"Ende: —"})]})]}):y.jsx("div",{className:"mt-4 text-xs text-gray-600 dark:text-white/70",children:"Status wird geladen…"})]})}const Ns={recordDir:"records",doneDir:"records/done",ffmpegPath:"",autoAddToDownloadList:!0,autoStartAddedDownloads:!0,useChaturbateApi:!1,useMyFreeCamsWatcher:!1,autoDeleteSmallDownloads:!1,autoDeleteSmallDownloadsBelowMB:50,blurPreviews:!1,teaserPlayback:"hover",teaserAudio:!1,lowDiskPauseBelowGB:5};function W5({onAssetsGenerated:s}){const[e,t]=A.useState(Ns),[i,n]=A.useState(!1),[r,o]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(null),[p,g]=A.useState(null);A.useEffect(()=>{let S=!0;return fetch("/api/settings",{cache:"no-store"}).then(async D=>{if(!D.ok)throw new Error(await D.text());return D.json()}).then(D=>{S&&t({recordDir:(D.recordDir||Ns.recordDir).toString(),doneDir:(D.doneDir||Ns.doneDir).toString(),ffmpegPath:String(D.ffmpegPath??Ns.ffmpegPath??""),autoAddToDownloadList:D.autoAddToDownloadList??Ns.autoAddToDownloadList,autoStartAddedDownloads:D.autoStartAddedDownloads??Ns.autoStartAddedDownloads,useChaturbateApi:D.useChaturbateApi??Ns.useChaturbateApi,useMyFreeCamsWatcher:D.useMyFreeCamsWatcher??Ns.useMyFreeCamsWatcher,autoDeleteSmallDownloads:D.autoDeleteSmallDownloads??Ns.autoDeleteSmallDownloads,autoDeleteSmallDownloadsBelowMB:D.autoDeleteSmallDownloadsBelowMB??Ns.autoDeleteSmallDownloadsBelowMB,blurPreviews:D.blurPreviews??Ns.blurPreviews,teaserPlayback:D.teaserPlayback??Ns.teaserPlayback,teaserAudio:D.teaserAudio??Ns.teaserAudio,lowDiskPauseBelowGB:D.lowDiskPauseBelowGB??Ns.lowDiskPauseBelowGB})}).catch(()=>{}),()=>{S=!1}},[]);async function v(S){g(null),f(null),c(S);try{window.focus();const D=await fetch(`/api/settings/browse?target=${S}`,{cache:"no-store"});if(D.status===204)return;if(!D.ok){const M=await D.text().catch(()=>"");throw new Error(M||`HTTP ${D.status}`)}const L=((await D.json()).path??"").trim();if(!L)return;t(M=>S==="record"?{...M,recordDir:L}:S==="done"?{...M,doneDir:L}:{...M,ffmpegPath:L})}catch(D){g(D?.message??String(D))}finally{c(null)}}async function b(){g(null),f(null);const S=e.recordDir.trim(),D=e.doneDir.trim(),R=(e.ffmpegPath??"").trim();if(!S||!D){g("Bitte Aufnahme-Ordner und Ziel-Ordner angeben.");return}const L=!!e.autoAddToDownloadList,M=L?!!e.autoStartAddedDownloads:!1,j=!!e.useChaturbateApi,V=!!e.useMyFreeCamsWatcher,P=!!e.autoDeleteSmallDownloads,z=Math.max(0,Math.min(1e5,Math.floor(Number(e.autoDeleteSmallDownloadsBelowMB??Ns.autoDeleteSmallDownloadsBelowMB)))),I=!!e.blurPreviews,O=e.teaserPlayback==="still"||e.teaserPlayback==="all"||e.teaserPlayback==="hover"?e.teaserPlayback:Ns.teaserPlayback,W=!!e.teaserAudio,X=Math.max(1,Math.floor(Number(e.lowDiskPauseBelowGB??Ns.lowDiskPauseBelowGB)));n(!0);try{const q=await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({recordDir:S,doneDir:D,ffmpegPath:R,autoAddToDownloadList:L,autoStartAddedDownloads:M,useChaturbateApi:j,useMyFreeCamsWatcher:V,autoDeleteSmallDownloads:P,autoDeleteSmallDownloadsBelowMB:z,blurPreviews:I,teaserPlayback:O,teaserAudio:W,lowDiskPauseBelowGB:X})});if(!q.ok){const ue=await q.text().catch(()=>"");throw new Error(ue||`HTTP ${q.status}`)}f("✅ Gespeichert."),window.dispatchEvent(new CustomEvent("recorder-settings-updated"))}catch(q){g(q?.message??String(q))}finally{n(!1)}}async function _(){g(null),f(null);const S=Number(e.autoDeleteSmallDownloadsBelowMB??Ns.autoDeleteSmallDownloadsBelowMB??0),D=(e.doneDir||Ns.doneDir).trim();if(!D){g("doneDir ist leer.");return}if(!S||S<=0){g("Mindestgröße ist 0 es würde nichts gelöscht.");return}if(window.confirm(`Aufräumen: Alle Dateien in "${D}" löschen, die kleiner als ${S} MB sind? (Ordner "keep" wird übersprungen)`)){o(!0);try{const L=await fetch("/api/settings/cleanup-small-downloads",{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store"});if(!L.ok){const j=await L.text().catch(()=>"");throw new Error(j||`HTTP ${L.status}`)}const M=await L.json();f(`🧹 Aufräumen fertig: ${M.deletedFiles} Datei(en) gelöscht (${M.deletedBytesHuman}). Geprüft: ${M.scannedFiles}. Übersprungen: ${M.skippedFiles}.`)}catch(L){g(L?.message??String(L))}finally{o(!1)}}}return y.jsx(ha,{header:y.jsxs("div",{className:"flex items-center justify-between gap-4",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Einstellungen"}),y.jsx("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:"Recorder-Konfiguration, Automatisierung und Tasks."})]}),y.jsx(ti,{variant:"primary",onClick:b,disabled:i,children:"Speichern"})]}),grayBody:!0,children:y.jsxs("div",{className:"space-y-4",children:[p&&y.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:p}),d&&y.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}),y.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:[y.jsxs("div",{className:"flex items-start justify-between gap-4",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Tasks"}),y.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Generiere fehlende Vorschauen/Metadaten für schnelle Listenansichten."})]}),y.jsx("div",{className:"shrink-0",children:y.jsx("span",{className:"inline-flex items-center rounded-full bg-gray-100 px-2 py-1 text-[11px] font-medium text-gray-700 dark:bg-white/10 dark:text-gray-200",children:"Utilities"})})]}),y.jsx("div",{className:"mt-3",children:y.jsx(Y5,{onFinished:s})})]}),y.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:[y.jsxs("div",{className:"mb-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Pfad-Einstellungen"}),y.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Aufnahme- und Zielverzeichnisse sowie optionaler ffmpeg-Pfad."})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[y.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Aufnahme-Ordner"}),y.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[y.jsx("input",{value:e.recordDir,onChange:S=>t(D=>({...D,recordDir:S.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`}),y.jsx(ti,{variant:"secondary",onClick:()=>v("record"),disabled:i||u!==null,children:"Durchsuchen..."})]})]}),y.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[y.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Fertige Downloads nach"}),y.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[y.jsx("input",{value:e.doneDir,onChange:S=>t(D=>({...D,doneDir:S.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`}),y.jsx(ti,{variant:"secondary",onClick:()=>v("done"),disabled:i||u!==null,children:"Durchsuchen..."})]})]}),y.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[y.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"ffmpeg.exe"}),y.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[y.jsx("input",{value:e.ffmpegPath??"",onChange:S=>t(D=>({...D,ffmpegPath:S.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`}),y.jsx(ti,{variant:"secondary",onClick:()=>v("ffmpeg"),disabled:i||u!==null,children:"Durchsuchen..."})]})]})]})]}),y.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:[y.jsxs("div",{className:"mb-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Automatisierung & Anzeige"}),y.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Verhalten beim Hinzufügen/Starten sowie Anzeigeoptionen."})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsx(Go,{checked:!!e.autoAddToDownloadList,onChange:S=>t(D=>({...D,autoAddToDownloadList:S,autoStartAddedDownloads:S?D.autoStartAddedDownloads:!1})),label:"Automatisch zur Downloadliste hinzufügen",description:"Neue Links/Modelle werden automatisch in die Downloadliste übernommen."}),y.jsx(Go,{checked:!!e.autoStartAddedDownloads,onChange:S=>t(D=>({...D,autoStartAddedDownloads:S})),disabled:!e.autoAddToDownloadList,label:"Hinzugefügte Downloads automatisch starten",description:"Wenn ein Download hinzugefügt wurde, startet er direkt (sofern möglich)."}),y.jsx(Go,{checked:!!e.useChaturbateApi,onChange:S=>t(D=>({...D,useChaturbateApi:S})),label:"Chaturbate API",description:"Wenn aktiv, pollt das Backend alle paar Sekunden die Online-Rooms API und cached die aktuell online Models."}),y.jsx(Go,{checked:!!e.useMyFreeCamsWatcher,onChange:S=>t(D=>({...D,useMyFreeCamsWatcher:S})),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."}),y.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-white/10 dark:bg-white/5",children:[y.jsx(Go,{checked:!!e.autoDeleteSmallDownloads,onChange:S=>t(D=>({...D,autoDeleteSmallDownloads:S,autoDeleteSmallDownloadsBelowMB:D.autoDeleteSmallDownloadsBelowMB??50})),label:"Kleine Downloads automatisch löschen",description:"Löscht fertige Downloads automatisch, wenn die Datei kleiner als die eingestellte Mindestgröße ist."}),y.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:[y.jsxs("div",{className:"sm:col-span-4",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-200",children:"Mindestgröße"}),y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Alles darunter wird gelöscht."})]}),y.jsx("div",{className:"sm:col-span-8",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("input",{type:"number",min:0,step:1,value:e.autoDeleteSmallDownloadsBelowMB??50,onChange:S=>t(D=>({...D,autoDeleteSmallDownloadsBelowMB:Number(S.target.value||0)})),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`}),y.jsx("span",{className:"shrink-0 text-xs text-gray-600 dark:text-gray-300",children:"MB"}),y.jsx(ti,{variant:"secondary",onClick:_,disabled:i||r||!e.autoDeleteSmallDownloads,className:"h-9 shrink-0 px-3",title:"Löscht Dateien im doneDir kleiner als die Mindestgröße (keep wird übersprungen)",children:r?"…":"Aufräumen"})]})})]})]}),y.jsx(Go,{checked:!!e.blurPreviews,onChange:S=>t(D=>({...D,blurPreviews:S})),label:"Vorschaubilder blurren",description:"Weichzeichnet Vorschaubilder/Teaser (praktisch auf mobilen Geräten oder im öffentlichen Umfeld)."}),y.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[y.jsxs("div",{className:"sm:col-span-4",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-200",children:"Teaser abspielen"}),y.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."})]}),y.jsxs("div",{className:"sm:col-span-8",children:[y.jsx("label",{className:"sr-only",htmlFor:"teaserPlayback",children:"Teaser abspielen"}),y.jsxs("select",{id:"teaserPlayback",value:e.teaserPlayback??"hover",onChange:S=>t(D=>({...D,teaserPlayback:S.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:[y.jsx("option",{value:"still",children:"Standbild"}),y.jsx("option",{value:"hover",children:"Bei Hover (Standard)"}),y.jsx("option",{value:"all",children:"Alle"})]})]})]}),y.jsx(Go,{checked:!!e.teaserAudio,onChange:S=>t(D=>({...D,teaserAudio:S})),label:"Teaser mit Ton",description:"Wenn aktiv, werden Vorschau/Teaser nicht stumm geschaltet."}),y.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Speicherplatz-Notbremse"}),y.jsx("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:"Wenn freier Platz darunter fällt: Autostart pausieren + laufende Downloads stoppen. Resume erfolgt automatisch bei +3 GB."}),y.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-12 sm:items-center",children:[y.jsxs("div",{className:"sm:col-span-4",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-200",children:"Pause unter"}),y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Freier Speicher in GB"})]}),y.jsxs("div",{className:"sm:col-span-8 flex items-center gap-3",children:[y.jsx("input",{type:"range",min:1,max:500,step:1,value:e.lowDiskPauseBelowGB??5,onChange:S=>t(D=>({...D,lowDiskPauseBelowGB:Number(S.target.value)})),className:"w-full"}),y.jsxs("span",{className:"w-16 text-right text-sm tabular-nums text-gray-900 dark:text-gray-100",children:[e.lowDiskPauseBelowGB??5," GB"]})]})]})]})]})]})]})})}function X5({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 Q5=A.forwardRef(X5);function Z5({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 J5=A.forwardRef(Z5);function eO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 tO=A.forwardRef(eO);function iO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 sO=A.forwardRef(iO);function Ln(...s){return s.filter(Boolean).join(" ")}function AS(s){return s==="center"?"text-center":s==="right"?"text-right":"text-left"}function nO(s){return s==="center"?"justify-center":s==="right"?"justify-end":"justify-start"}function CS(s,e){const t=s===0,i=s===e-1;return t||i?"pl-2 pr-2":"px-2"}function kS(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 Gx({columns:s,rows:e,getRowKey:t,title:i,description:n,actions:r,fullWidth:o=!1,card:u=!0,striped:c=!1,stickyHeader:d=!1,compact:f=!1,isLoading:p=!1,emptyLabel:g="Keine Daten vorhanden.",className:v,rowClassName:b,onRowClick:_,onRowContextMenu:S,sort:D,onSortChange:R,defaultSort:L=null}){const M=f?"py-2":"py-4",j=f?"py-3":"py-3.5",V=D!==void 0,[P,z]=A.useState(L),I=V?D:P,O=A.useCallback(X=>{V||z(X),R?.(X)},[V,R]),W=A.useMemo(()=>{if(!I)return e;const X=s.find(ie=>ie.key===I.key);if(!X)return e;const q=I.direction==="asc"?1:-1,ue=e.map((ie,Y)=>({r:ie,i:Y}));return ue.sort((ie,Y)=>{let G=0;if(X.sortFn)G=X.sortFn(ie.r,Y.r);else{const J=X.sortValue?X.sortValue(ie.r):ie.r?.[X.key],oe=X.sortValue?X.sortValue(Y.r):Y.r?.[X.key],ce=kS(J),F=kS(oe);ce.isNull&&!F.isNull?G=1:!ce.isNull&&F.isNull?G=-1:ce.kind==="number"&&F.kind==="number"?G=ce.value<F.value?-1:ce.value>F.value?1:0:G=String(ce.value).localeCompare(String(F.value),void 0,{numeric:!0})}return G===0?ie.i-Y.i:G*q}),ue.map(ie=>ie.r)},[e,s,I]);return y.jsxs("div",{className:Ln(o?"":"px-4 sm:px-6 lg:px-8",v),children:[(i||n||r)&&y.jsxs("div",{className:"sm:flex sm:items-center",children:[y.jsxs("div",{className:"sm:flex-auto",children:[i&&y.jsx("h1",{className:"text-base font-semibold text-gray-900 dark:text-white",children:i}),n&&y.jsx("p",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:n})]}),r&&y.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-16 sm:flex-none",children:r})]}),y.jsx("div",{className:Ln(i||n||r?"mt-8":""),children:y.jsx("div",{className:"flow-root",children:y.jsx("div",{className:"overflow-x-auto",children:y.jsx("div",{className:Ln("inline-block min-w-full align-middle",o?"":"sm:px-6 lg:px-8"),children:y.jsx("div",{className:Ln(u&&"overflow-hidden shadow-sm outline-1 outline-black/5 sm:rounded-lg dark:shadow-none dark:-outline-offset-1 dark:outline-white/10"),children:y.jsxs("table",{className:"relative min-w-full divide-y divide-gray-200 dark:divide-white/10",children:[y.jsx("thead",{className:Ln(u&&"bg-gray-50/90 dark:bg-gray-800/70",d&&"sticky top-0 z-10 backdrop-blur-sm shadow-sm"),children:y.jsx("tr",{children:s.map((X,q)=>{const ue=CS(q,s.length),ie=!!I&&I.key===X.key,Y=ie?I.direction:void 0,G=X.sortable&&!X.srOnlyHeader?ie?Y==="asc"?"ascending":"descending":"none":void 0,J=()=>{if(!(!X.sortable||X.srOnlyHeader))return O(ie?Y==="asc"?{key:X.key,direction:"desc"}:null:{key:X.key,direction:"asc"})};return y.jsx("th",{scope:"col","aria-sort":G,className:Ln(j,ue,"text-xs font-semibold tracking-wide text-gray-700 dark:text-gray-200 whitespace-nowrap",AS(X.align),X.widthClassName,X.headerClassName),children:X.srOnlyHeader?y.jsx("span",{className:"sr-only",children:X.header}):X.sortable?y.jsxs("button",{type:"button",onClick:J,className:Ln("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",nO(X.align)),children:[y.jsx("span",{children:X.header}),y.jsx("span",{className:Ln("flex-none rounded-sm text-gray-400 dark:text-gray-500",ie?"bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-white":"invisible group-hover:visible group-focus-visible:visible"),children:y.jsx(Q5,{"aria-hidden":"true",className:Ln("size-5 transition-transform",ie&&Y==="asc"&&"rotate-180")})})]}):X.header},X.key)})})}),y.jsx("tbody",{className:Ln("divide-y divide-gray-200 dark:divide-white/10",u?"bg-white dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),children:p?y.jsx("tr",{children:y.jsx("td",{colSpan:s.length,className:Ln(M,"px-2 text-sm text-gray-500 dark:text-gray-400"),children:"Lädt…"})}):W.length===0?y.jsx("tr",{children:y.jsx("td",{colSpan:s.length,className:Ln(M,"px-2 text-sm text-gray-500 dark:text-gray-400"),children:g})}):W.map((X,q)=>{const ue=t?t(X,q):String(q);return y.jsx("tr",{className:Ln(c&&"even:bg-gray-50 dark:even:bg-gray-800/50",_&&"cursor-pointer",_&&"hover:bg-gray-50 dark:hover:bg-white/5 transition-colors",b?.(X,q)),onClick:()=>_?.(X),onContextMenu:S?ie=>{ie.preventDefault(),S(X,ie)}:void 0,children:s.map((ie,Y)=>{const G=CS(Y,s.length),J=ie.cell?.(X,q)??ie.accessor?.(X)??X?.[ie.key];return y.jsx("td",{className:Ln(M,G,"text-sm whitespace-nowrap",AS(ie.align),ie.className,ie.key===s[0]?.key?"font-medium text-gray-900 dark:text-white":"text-gray-500 dark:text-gray-400"),children:J},ie.key)})},ue)})})]})})})})})})]})}function DA({children:s,content:e}){const t=A.useRef(null),i=A.useRef(null),[n,r]=A.useState(!1),[o,u]=A.useState(null),c=A.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)},p=()=>{d(),r(!0)},g=()=>{f()},v=()=>{d(),r(!1)},b=()=>{const S=t.current,D=i.current;if(!S||!D)return;const R=8,L=8,M=S.getBoundingClientRect(),j=D.getBoundingClientRect();let V=M.bottom+R;if(V+j.height>window.innerHeight-L){const I=M.top-j.height-R;I>=L?V=I:V=Math.max(L,window.innerHeight-j.height-L)}let z=M.left;z+j.width>window.innerWidth-L&&(z=window.innerWidth-j.width-L),z=Math.max(L,z),u({left:z,top:V})};A.useLayoutEffect(()=>{if(!n)return;const S=requestAnimationFrame(()=>b());return()=>cancelAnimationFrame(S)},[n]),A.useEffect(()=>{if(!n)return;const S=()=>requestAnimationFrame(()=>b());return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[n]),A.useEffect(()=>()=>d(),[]);const _=()=>typeof e=="function"?e(n,{close:v}):e;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:t,className:"inline-flex",onMouseEnter:p,onMouseLeave:g,children:s}),n&&yc.createPortal(y.jsx("div",{ref:i,className:"fixed z-50",style:{left:o?.left??-9999,top:o?.top??-9999,visibility:o?"visible":"hidden"},onMouseEnter:p,onMouseLeave:g,children:y.jsx(ha,{className:"shadow-lg ring-1 ring-black/10 dark:ring-white/10 max-w-[calc(100vw-16px)]",noBodyPadding:!0,children:_()})}),document.body)]})}const Xm=!0,rO=!1;function Qm(s,e){if(!s)return;const t=e?.muted??Xm;s.muted=t,s.defaultMuted=t,s.playsInline=!0,s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","")}function zx({job:s,getFileName:e,durationSeconds:t,onDuration:i,animated:n=!1,animatedMode:r="frames",animatedTrigger:o="always",autoTickMs:u=15e3,thumbStepSec:c,thumbSpread:d,thumbSamples:f,clipSeconds:p=1,variant:g="thumb",className:v,showPopover:b=!0,blur:_=!1,inlineVideo:S=!1,inlineNonce:D=0,inlineControls:R=!1,inlineLoop:L=!0,assetNonce:M=0,muted:j=Xm,popoverMuted:V=Xm,noGenerateTeaser:P}){const z=e(s.output||""),I=_?"blur-md":"",O={muted:j,playsInline:!0,preload:"metadata"},[W,X]=A.useState(!0),[q,ue]=A.useState(!0),[ie,Y]=A.useState(!1),[G,J]=A.useState(!1),[oe,ce]=A.useState(!0),F=A.useRef(null),[ee,pe]=A.useState(!1),[_e,ve]=A.useState(!1),[Ce,Be]=A.useState(0),[tt,Je]=A.useState(!1),Ct=S===!0||S==="always"?"always":S==="hover"?"hover":"never",st=Qe=>Qe.startsWith("HOT ")?Qe.slice(4):Qe,mt=A.useMemo(()=>{const Qe=e(s.output||"");if(!Qe)return"";const Lt=Qe.replace(/\.[^.]+$/,"");return st(Lt).trim()},[s.output,e]),pt=A.useMemo(()=>z?`/api/record/video?file=${encodeURIComponent(z)}`:"",[z]),ut=typeof t=="number"&&Number.isFinite(t)&&t>0,Ht=g==="fill"?"w-full h-full":"w-20 h-16",at=A.useRef(null),gt=A.useRef(null),Dt=A.useRef(null),Nt=Qe=>{if(Qe){try{Qe.pause()}catch{}try{Qe.removeAttribute("src"),Qe.src="",Qe.load()}catch{}}};A.useEffect(()=>{J(!1),ce(!0)},[mt,M,P]),A.useEffect(()=>{const Qe=Lt=>{const Ut=String(Lt?.detail?.file??"");!Ut||Ut!==z||(Nt(at.current),Nt(gt.current),Nt(Dt.current))};return window.addEventListener("player:release",Qe),window.addEventListener("player:close",Qe),()=>{window.removeEventListener("player:release",Qe),window.removeEventListener("player:close",Qe)}},[z]),A.useEffect(()=>{const Qe=F.current;if(!Qe)return;const Lt=new IntersectionObserver(Ut=>{const vi=!!Ut[0]?.isIntersecting;pe(vi),vi&&ve(!0)},{threshold:.01,rootMargin:"350px 0px"});return Lt.observe(Qe),()=>Lt.disconnect()},[]),A.useEffect(()=>{if(!n||r!=="frames"||!ee||document.hidden)return;const Qe=window.setInterval(()=>Be(Lt=>Lt+1),u);return()=>window.clearInterval(Qe)},[n,r,ee,u]);const dt=A.useMemo(()=>{if(!n||r!=="frames"||!ut)return null;const Qe=t,Lt=Math.max(.25,c??3);if(d){const gi=Math.max(4,Math.min(f??16,Math.floor(Qe))),kt=Ce%gi,ht=Math.max(.1,Qe-Lt),ri=Math.min(.25,ht*.02),Ie=kt/gi*ht+ri;return Math.min(Qe-.05,Math.max(.05,Ie))}const Ut=Math.max(Qe-.1,Lt),vi=Ce*Lt%Ut;return Math.min(Qe-.05,Math.max(.05,vi))},[n,r,ut,t,Ce,c,d,f]),lt=M??0,ye=A.useMemo(()=>mt?dt==null?`/api/record/preview?id=${encodeURIComponent(mt)}&v=${lt}`:`/api/record/preview?id=${encodeURIComponent(mt)}&t=${dt}&v=${lt}-${Ce}`:"",[mt,dt,Ce,lt]),ze=A.useMemo(()=>{if(!mt)return"";const Qe=P?"&noGenerate=1":"";return`/api/generated/teaser?id=${encodeURIComponent(mt)}${Qe}&v=${lt}`},[mt,lt,P]),We=Qe=>{if(Y(!0),!i)return;const Lt=Qe.currentTarget.duration;Number.isFinite(Lt)&&Lt>0&&i(s,Lt)};if(A.useEffect(()=>{X(!0),ue(!0)},[mt,M]),!pt)return y.jsx("div",{className:[Ht,"rounded bg-gray-100 dark:bg-white/5"].join(" ")});const et=Ct!=="never"&&ee&&q&&(Ct==="always"||Ct==="hover"&&tt),ot=n&&ee&&!document.hidden&&q&&!et&&(o==="always"||tt)&&(r==="teaser"&&oe&&!!ze||r==="clips"&&ut),nt=Ct==="hover"||n&&(r==="clips"||r==="teaser")&&o==="hover",vt=_e||nt&&tt,Xe=A.useMemo(()=>{if(!n)return[];if(r!=="clips")return[];if(!ut)return[];const Qe=t,Lt=Math.max(.25,p),Ut=Math.max(8,Math.min(f??18,Math.floor(Qe))),vi=Math.max(.1,Qe-Lt),gi=Math.min(.25,vi*.02),kt=[];for(let ht=0;ht<Ut;ht++){const ri=ht/Ut*vi+gi;kt.push(Math.min(Qe-.05,Math.max(.05,ri)))}return kt},[n,r,ut,t,f,p]),Ft=A.useMemo(()=>Xe.map(Qe=>Qe.toFixed(2)).join(","),[Xe]),Gt=A.useRef(0),wt=A.useRef(0);A.useEffect(()=>{const Qe=gt.current;if(!Qe)return;if(!(ot&&r==="teaser")){try{Qe.pause()}catch{}return}Qm(Qe,{muted:j});const Ut=Qe.play?.();Ut&&typeof Ut.catch=="function"&&Ut.catch(()=>{})},[ot,r,ze,j]),A.useEffect(()=>{et&&Qm(at.current,{muted:j})},[et,j]),A.useEffect(()=>{const Qe=Dt.current;if(!Qe)return;if(!(ot&&r==="clips")){ot||Qe.pause();return}if(!Xe.length)return;Gt.current=Gt.current%Xe.length,wt.current=Xe[Gt.current];const Lt=()=>{try{Qe.currentTime=wt.current}catch{}const gi=Qe.play();gi&&typeof gi.catch=="function"&&gi.catch(()=>{})},Ut=()=>Lt(),vi=()=>{if(Xe.length&&Qe.currentTime-wt.current>=p){Gt.current=(Gt.current+1)%Xe.length,wt.current=Xe[Gt.current];try{Qe.currentTime=wt.current+.01}catch{}}};return Qe.addEventListener("loadedmetadata",Ut),Qe.addEventListener("timeupdate",vi),Qe.readyState>=1&&Lt(),()=>{Qe.removeEventListener("loadedmetadata",Ut),Qe.removeEventListener("timeupdate",vi),Qe.pause()}},[ot,r,Ft,p,Xe]);const hi=y.jsxs("div",{ref:F,className:["rounded bg-gray-100 dark:bg-white/5 overflow-hidden relative",Ht,v??""].join(" "),onMouseEnter:nt?()=>Je(!0):void 0,onMouseLeave:nt?()=>Je(!1):void 0,onFocus:nt?()=>Je(!0):void 0,onBlur:nt?()=>Je(!1):void 0,children:[vt&&ye&&W?y.jsx("img",{src:ye,loading:"lazy",decoding:"async",alt:z,className:["absolute inset-0 w-full h-full object-cover",I].filter(Boolean).join(" "),onError:()=>X(!1)}):y.jsx("div",{className:"absolute inset-0 bg-black/10 dark:bg-white/10"}),et?A.createElement("video",{...O,ref:at,key:`inline-${mt}-${D}`,src:pt,className:["absolute inset-0 w-full h-full object-cover",I,R?"pointer-events-auto":"pointer-events-none"].filter(Boolean).join(" "),autoPlay:!0,muted:j,controls:R,loop:L,poster:vt&&ye||void 0,onLoadedMetadata:We,onError:()=>ue(!1)}):null,!et&&ot&&r==="teaser"?y.jsx("video",{ref:gt,src:ze,className:["absolute inset-0 w-full h-full object-cover pointer-events-none",I,G?"opacity-100":"opacity-0","transition-opacity duration-150"].filter(Boolean).join(" "),muted:j,playsInline:!0,autoPlay:!0,loop:!0,preload:"metadata",poster:vt&&ye||void 0,onLoadedData:()=>J(!0),onPlaying:()=>J(!0),onError:()=>{ce(!1),J(!1)}},`teaser-mp4-${mt}`):null,!et&&ot&&r==="clips"?y.jsx("video",{ref:Dt,src:pt,className:["absolute inset-0 w-full h-full object-cover pointer-events-none",I].filter(Boolean).join(" "),muted:j,playsInline:!0,preload:"metadata",poster:vt&&ye||void 0,onError:()=>ue(!1)},`clips-${mt}-${Ft}`):null,ee&&i&&!ut&&!ie&&!et&&y.jsx("video",{src:pt,preload:"metadata",muted:j,playsInline:!0,className:"hidden",onLoadedMetadata:We})]});return b?y.jsx(DA,{content:Qe=>Qe&&y.jsx("div",{className:"w-[420px]",children:y.jsx("div",{className:"aspect-video",children:y.jsx("video",{src:pt,className:["w-full h-full bg-black",I].filter(Boolean).join(" "),muted:V,playsInline:!0,preload:"metadata",controls:!0,autoPlay:!0,loop:!0,onClick:Lt=>Lt.stopPropagation(),onMouseDown:Lt=>Lt.stopPropagation()})})}),children:hi}):hi}function py(...s){return s.filter(Boolean).join(" ")}const aO={sm:{btn:"px-2.5 py-1.5 text-sm",icon:"size-5"},md:{btn:"px-3 py-2 text-sm",icon:"size-5"}};function oO({items:s,value:e,onChange:t,size:i="md",className:n,ariaLabel:r="Optionen"}){const o=aO[i];return y.jsx("span",{className:py("isolate inline-flex rounded-md shadow-xs dark:shadow-none",n),role:"group","aria-label":r,children:s.map((u,c)=>{const d=u.id===e,f=c===0,p=c===s.length-1,g=!u.label&&!!u.icon;return y.jsxs("button",{type:"button",disabled:u.disabled,onClick:()=>t(u.id),"aria-pressed":d,className:py("relative inline-flex items-center justify-center font-semibold focus:z-10 transition-colors",!f&&"-ml-px",f&&"rounded-l-md",p&&"rounded-r-md",d?"bg-indigo-100 text-indigo-800 inset-ring-1 inset-ring-indigo-300 hover:bg-indigo-200 dark:bg-indigo-500/40 dark:text-indigo-100 dark:inset-ring-indigo-400/50 dark:hover:bg-indigo-500/50":"bg-white text-gray-900 inset-ring-1 inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:inset-ring-gray-700 dark:hover:bg-white/20","disabled:opacity-50 disabled:cursor-not-allowed",g?"px-2 py-2":o.btn),title:typeof u.label=="string"?u.label:u.srLabel,children:[g&&u.srLabel?y.jsx("span",{className:"sr-only",children:u.srLabel}):null,u.icon?y.jsx("span",{className:py("shrink-0",g?"":"-ml-0.5",d?"text-indigo-600 dark:text-indigo-200":"text-gray-400 dark:text-gray-500"),children:u.icon}):null,u.label?y.jsx("span",{className:u.icon?"ml-1.5":"",children:u.label}):null]},u.id)})})}function lO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 uO=A.forwardRef(lO);function cO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 gy=A.forwardRef(cO);function dO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 hO=A.forwardRef(dO);function fO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 mO=A.forwardRef(fO);function pO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 jv=A.forwardRef(pO);function gO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 DS=A.forwardRef(gO);function yO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 vO=A.forwardRef(yO);function xO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 bO=A.forwardRef(xO);function TO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 _O=A.forwardRef(TO);function SO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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"}),A.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))}const $v=A.forwardRef(SO);function EO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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"}),A.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 LS=A.forwardRef(EO);function wO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 Zm=A.forwardRef(wO);function AO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 CO=A.forwardRef(AO);function kO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 DO=A.forwardRef(kO);function LO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 RO=A.forwardRef(LO);function IO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 NO=A.forwardRef(IO);function OO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 RS=A.forwardRef(OO);function MO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}),A.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 PO=A.forwardRef(MO);function BO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 FO=A.forwardRef(BO);function UO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 jO=A.forwardRef(UO);function $O({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 IS=A.forwardRef($O);function HO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 VO=A.forwardRef(HO);function GO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 Hv=A.forwardRef(GO);function zO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 qO=A.forwardRef(zO);function KO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 Vv=A.forwardRef(KO);function YO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 WO=A.forwardRef(YO);function XO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 QO=A.forwardRef(XO);function ZO({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"}))}const qx=A.forwardRef(ZO);function om(...s){return s.filter(Boolean).join(" ")}const JO=A.forwardRef(function({children:e,enabled:t=!0,disabled:i=!1,onTap:n,onSwipeLeft:r,onSwipeRight:o,className:u,leftAction:c={label:y.jsxs("span",{className:"inline-flex flex-col items-center gap-1 font-semibold leading-tight",children:[y.jsx(jv,{className:"h-6 w-6","aria-hidden":"true"}),y.jsx("span",{children:"Behalten"})]}),className:"bg-emerald-500/20 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300"},rightAction:d={label:y.jsxs("span",{className:"inline-flex flex-col items-center gap-1 font-semibold leading-tight",children:[y.jsx(Vv,{className:"h-6 w-6","aria-hidden":"true"}),y.jsx("span",{children:"Löschen"})]}),className:"bg-red-500/20 text-red-800 dark:bg-red-500/15 dark:text-red-300"},thresholdPx:f=180,thresholdRatio:p=.1,ignoreFromBottomPx:g=72,ignoreSelector:v="[data-swipe-ignore]",snapMs:b=180,commitMs:_=180,tapIgnoreSelector:S="button,a,input,textarea,select,video[controls],video[controls] *,[data-tap-ignore]"},D){const R=A.useRef(null),L=A.useRef(0),M=A.useRef(null),j=A.useRef(0),V=A.useRef({id:null,x:0,y:0,dragging:!1,captured:!1,tapIgnored:!1}),[P,z]=A.useState(0),[I,O]=A.useState(null),[W,X]=A.useState(0),q=A.useCallback(()=>{M.current!=null&&(cancelAnimationFrame(M.current),M.current=null),L.current=0,X(b),z(0),O(null),window.setTimeout(()=>X(0),b)},[b]),ue=A.useCallback(async(ie,Y)=>{M.current!=null&&(cancelAnimationFrame(M.current),M.current=null);const J=R.current?.offsetWidth||360;X(_),O(ie==="right"?"right":"left");const oe=ie==="right"?J+40:-(J+40);L.current=oe,z(oe);let ce=!0;if(Y)try{ce=ie==="right"?await o():await r()}catch{ce=!1}return ce===!1?(X(b),O(null),z(0),window.setTimeout(()=>X(0),b),!1):!0},[_,r,o,b]);return A.useImperativeHandle(D,()=>({swipeLeft:ie=>ue("left",ie?.runAction??!0),swipeRight:ie=>ue("right",ie?.runAction??!0),reset:()=>q()}),[ue,q]),y.jsxs("div",{className:om("relative overflow-hidden rounded-lg",u),children:[y.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden rounded-lg",children:[y.jsx("div",{className:om("absolute inset-0 transition-opacity duration-200 ease-out",P===0?"opacity-0":"opacity-100",P>0?c.className:d.className)}),y.jsx("div",{className:om("absolute inset-0 flex items-center transition-all duration-200 ease-out"),style:{transform:`translateX(${Math.max(-24,Math.min(24,P/8))}px)`,opacity:P===0?0:1,justifyContent:P>0?"flex-start":"flex-end",paddingLeft:P>0?16:0,paddingRight:P>0?0:16},children:P>0?c.label:d.label})]}),y.jsx("div",{ref:R,className:"relative",style:{transform:P!==0?`translate3d(${P}px,0,0)`:void 0,transition:W?`transform ${W}ms ease`:void 0,touchAction:"pan-y",willChange:P!==0?"transform":void 0},onPointerDown:ie=>{if(!t||i)return;const Y=ie.target,G=!!(S&&Y?.closest?.(S));if(v&&Y?.closest?.(v))return;const J=ie.currentTarget,ce=Array.from(J.querySelectorAll("video")).find(ve=>ve.controls);if(ce){const ve=ce.getBoundingClientRect();if(ie.clientX>=ve.left&&ie.clientX<=ve.right&&ie.clientY>=ve.top&&ie.clientY<=ve.bottom){if(ve.bottom-ie.clientY<=72)return;const Je=64,Ct=ie.clientX-ve.left,st=ve.right-ie.clientX;if(!(Ct<=Je||st<=Je))return}}const ee=ie.currentTarget.getBoundingClientRect().bottom-ie.clientY;if(g&&ee<=g)return;V.current={id:ie.pointerId,x:ie.clientX,y:ie.clientY,dragging:!1,captured:!1,tapIgnored:G};const _e=R.current?.offsetWidth||360;j.current=Math.min(f,_e*p),L.current=0},onPointerMove:ie=>{if(!t||i||V.current.id!==ie.pointerId)return;const Y=ie.clientX-V.current.x,G=ie.clientY-V.current.y;if(!V.current.dragging){if(Math.abs(G)>Math.abs(Y)&&Math.abs(G)>8){V.current.id=null;return}if(Math.abs(Y)<12)return;V.current.dragging=!0,X(0);try{ie.currentTarget.setPointerCapture(ie.pointerId),V.current.captured=!0}catch{V.current.captured=!1}}L.current=Y,M.current==null&&(M.current=requestAnimationFrame(()=>{M.current=null,z(L.current)}));const J=j.current,oe=Y>J?"right":Y<-J?"left":null;O(ce=>ce===oe?ce:oe)},onPointerUp:ie=>{if(!t||i||V.current.id!==ie.pointerId)return;const Y=j.current||Math.min(f,(R.current?.offsetWidth||360)*p),G=V.current.dragging,J=V.current.captured,oe=V.current.tapIgnored;if(V.current.id=null,V.current.dragging=!1,V.current.captured=!1,J)try{ie.currentTarget.releasePointerCapture(ie.pointerId)}catch{}if(!G){if(oe){X(0),z(0),O(null);return}q(),n?.();return}const ce=L.current;M.current!=null&&(cancelAnimationFrame(M.current),M.current=null),ce>Y?ue("right",!0):ce<-Y?ue("left",!0):q(),L.current=0},onPointerCancel:ie=>{if(!(!t||i)){if(V.current.captured&&V.current.id!=null)try{ie.currentTarget.releasePointerCapture(V.current.id)}catch{}V.current={id:null,x:0,y:0,dragging:!1,captured:!1,tapIgnored:!1},M.current!=null&&(cancelAnimationFrame(M.current),M.current=null),L.current=0,q()}},children:y.jsxs("div",{className:"relative",children:[y.jsx("div",{className:"relative z-10",children:e}),y.jsx("div",{className:om("absolute inset-0 z-20 pointer-events-none transition-opacity duration-150 rounded-lg",I==="right"&&"bg-emerald-500/20 opacity-100",I==="left"&&"bg-red-500/20 opacity-100",I===null&&"opacity-0")})]})})]})});function eM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),A.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 xc=A.forwardRef(eM);function tM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 NS=A.forwardRef(tM);function iM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 sM=A.forwardRef(iM);function nM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 bc=A.forwardRef(nM);function rM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 aM=A.forwardRef(rM);function oM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 lM=A.forwardRef(oM);function uM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 cM=A.forwardRef(uM);function dM({title:s,titleId:e,...t},i){return A.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?A.createElement("title",{id:e},s):null,A.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 mh=A.forwardRef(dM);function Lr({tag:s,children:e,title:t,active:i,onClick:n,maxWidthClassName:r="max-w-[11rem]",className:o,stopPropagation:u=!0}){const c=s??(typeof e=="string"||typeof e=="number"?String(e):""),d=yi("inline-flex 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"),g=yi(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":"",o),v=_=>_.stopPropagation(),b=u?{onPointerDown:v,onMouseDown:v}:{};return n?y.jsx("button",{type:"button",className:g,title:t??c,"aria-pressed":!!i,...b,onClick:_=>{u&&(_.preventDefault(),_.stopPropagation()),c&&n(c)},children:e??s}):y.jsx("span",{className:g,title:t??c,...b,onClick:u?v:void 0,children:e??s})}function bi(...s){return s.filter(Boolean).join(" ")}const hM=s=>(s||"").replaceAll("\\","/").trim().split("/").pop()||"",fM=s=>s.startsWith("HOT ")?s.slice(4):s,mM=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function pM(s){const t=fM(hM(s||"")).replace(/\.[^.]+$/,""),i=t.match(mM);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t||null}function da({job:s,variant:e="overlay",collapseToMenu:t=!1,inlineCount:i,busy:n=!1,compact:r=!1,isHot:o=!1,isFavorite:u=!1,isLiked:c=!1,isWatching:d=!1,showFavorite:f,showLike:p,showHot:g,showKeep:v,showDelete:b,showWatch:_,showDetails:S,onToggleFavorite:D,onToggleLike:R,onToggleHot:L,onKeep:M,onDelete:j,onToggleWatch:V,order:P,className:z}){const I=e==="overlay"?r?"p-1.5":"p-2":"p-1.5",O=r?"size-4":"size-5",W="h-full w-full",X=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`,q=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"},ue=f??!!D,ie=p??!!R,Y=g??!!L,G=v??!!M,J=b??!!j,oe=_??!!V,ce=S??!0,F=pM(s.output||""),ee=F?`Mehr zu ${F} anzeigen`:"Mehr anzeigen",[pe,_e]=A.useState(0),[ve,Ce]=A.useState(4),Be=kt=>ht=>{ht.preventDefault(),ht.stopPropagation(),!(n||!kt)&&Promise.resolve(kt(s)).catch(()=>{})},tt=ce&&F?y.jsxs("button",{type:"button",className:bi(X),title:ee,"aria-label":ee,disabled:n,onClick:kt=>{kt.preventDefault(),kt.stopPropagation(),!n&&window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:F}}))},children:[y.jsx("span",{className:bi("inline-flex items-center justify-center",O),children:y.jsx(RS,{className:bi(W,q.off)})}),y.jsx("span",{className:"sr-only",children:ee})]}):null,Je=ue?y.jsx("button",{type:"button",className:X,title:u?"Favorit entfernen":"Als Favorit markieren","aria-label":u?"Favorit entfernen":"Als Favorit markieren","aria-pressed":u,disabled:n||!D,onClick:Be(D),children:y.jsxs("span",{className:bi("relative inline-block",O),children:[y.jsx(Hv,{className:bi("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",W,q.off)}),y.jsx(mh,{className:bi("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",W,q.favOn)})]})}):null,Ct=ie?y.jsx("button",{type:"button",className:X,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||!R,onClick:Be(R),children:y.jsxs("span",{className:bi("relative inline-block",O),children:[y.jsx(Zm,{className:bi("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",W,q.off)}),y.jsx(bc,{className:bi("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",W,q.likeOn)})]})}):null,st=Y?y.jsx("button",{type:"button",className:X,title:o?"HOT entfernen":"Als HOT markieren","aria-label":o?"HOT entfernen":"Als HOT markieren","aria-pressed":o,disabled:n||!L,onClick:Be(L),children:y.jsxs("span",{className:bi("relative inline-block",O),children:[y.jsx(LS,{className:bi("absolute inset-0 transition-all duration-200 ease-out",o?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",W,q.off)}),y.jsx(NS,{className:bi("absolute inset-0 transition-all duration-200 ease-out",o?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",W,q.hotOn)})]})}):null,mt=oe?y.jsx("button",{type:"button",className:X,title:d?"Watched entfernen":"Als Watched markieren","aria-label":d?"Watched entfernen":"Als Watched markieren","aria-pressed":d,disabled:n||!V,onClick:Be(V),children:y.jsxs("span",{className:bi("relative inline-block",O),children:[y.jsx($v,{className:bi("absolute inset-0 transition-all duration-200 ease-out",d?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0",W,q.off)}),y.jsx(xc,{className:bi("absolute inset-0 transition-all duration-200 ease-out",d?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12",W,q.watchOn)})]})}):null,pt=G?y.jsx("button",{type:"button",className:X,title:"Behalten (nach keep verschieben)","aria-label":"Behalten",disabled:n||!M,onClick:Be(M),children:y.jsx("span",{className:bi("inline-flex items-center justify-center",O),children:y.jsx(jv,{className:bi(W,q.keep)})})}):null,ut=J?y.jsx("button",{type:"button",className:X,title:"Löschen","aria-label":"Löschen",disabled:n||!j,onClick:Be(j),children:y.jsx("span",{className:bi("inline-flex items-center justify-center",O),children:y.jsx(Vv,{className:bi(W,q.del)})})}):null,Ht=P??["watch","favorite","like","hot","keep","delete","details"],at={details:tt,favorite:Je,like:Ct,watch:mt,hot:st,keep:pt,delete:ut},gt=t&&e==="overlay",Dt=Ht.filter(kt=>!!at[kt]),Nt=gt&&typeof i!="number",ye=(r?16:20)+(e==="overlay"?r?6:8:6)*2,ze=r?2:3,We=A.useMemo(()=>{if(!Nt)return i??ze;const kt=pe||0;if(kt<=0)return Math.min(Dt.length,ze);for(let ht=Dt.length;ht>=0;ht--)if(ht*ye+ye+(ht>0?ht*ve:0)<=kt)return ht;return 0},[Nt,i,ze,pe,Dt.length,ye,ve]),et=gt?Dt.slice(0,We):Dt,ot=gt?Dt.slice(We):[],[nt,vt]=A.useState(!1),Xe=A.useRef(null);A.useLayoutEffect(()=>{const kt=Xe.current;if(!kt||typeof window>"u")return;const ht=()=>{const Ie=Xe.current;if(!Ie)return;const H=Math.floor(Ie.getBoundingClientRect().width||0);H>0&&_e(H);const K=window.getComputedStyle(Ie),re=K.columnGap||K.gap||"0",Ee=parseFloat(re);Number.isFinite(Ee)&&Ee>=0&&Ce(Ee)};ht();const ri=new ResizeObserver(()=>ht());return ri.observe(kt),window.addEventListener("resize",ht),()=>{window.removeEventListener("resize",ht),ri.disconnect()}},[]);const Ft=A.useRef(null),Gt=A.useRef(null),wt=208,hi=4,Qe=8,[Lt,Ut]=A.useState(null);A.useEffect(()=>{if(!nt)return;const kt=ri=>{ri.key==="Escape"&&vt(!1)},ht=ri=>{const Ie=Xe.current,H=Gt.current,K=ri.target;Ie&&Ie.contains(K)||H&&H.contains(K)||vt(!1)};return window.addEventListener("keydown",kt),window.addEventListener("mousedown",ht),()=>{window.removeEventListener("keydown",kt),window.removeEventListener("mousedown",ht)}},[nt]),A.useLayoutEffect(()=>{if(!nt){Ut(null);return}const kt=()=>{const ht=Ft.current;if(!ht)return;const ri=ht.getBoundingClientRect(),Ie=window.innerWidth,H=window.innerHeight;let K=ri.right-wt;K=Math.max(Qe,Math.min(K,Ie-wt-Qe));let re=ri.bottom+hi;re=Math.max(Qe,Math.min(re,H-Qe));const Ee=Math.max(120,H-re-Qe);Ut({top:re,left:K,maxH:Ee})};return kt(),window.addEventListener("resize",kt),window.addEventListener("scroll",kt,!0),()=>{window.removeEventListener("resize",kt),window.removeEventListener("scroll",kt,!0)}},[nt]);const vi=()=>{F&&window.dispatchEvent(new CustomEvent("open-model-details",{detail:{modelKey:F}}))},gi=kt=>kt==="details"?y.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:ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),vi()},children:[y.jsx(RS,{className:bi("size-4",q.off)}),y.jsx("span",{className:"truncate",children:"Details"})]},"details"):kt==="favorite"?y.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||!D,onClick:async ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await D?.(s)},children:[u?y.jsx(mh,{className:bi("size-4",q.favOn)}):y.jsx(Hv,{className:bi("size-4",q.off)}),y.jsx("span",{className:"truncate",children:u?"Favorit entfernen":"Als Favorit markieren"})]},"favorite"):kt==="like"?y.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||!R,onClick:async ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await R?.(s)},children:[c?y.jsx(bc,{className:bi("size-4",q.favOn)}):y.jsx(Zm,{className:bi("size-4",q.off)}),y.jsx("span",{className:"truncate",children:c?"Gefällt mir entfernen":"Gefällt mir"})]},"like"):kt==="watch"?y.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 ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await V?.(s)},children:[d?y.jsx(xc,{className:bi("size-4",q.favOn)}):y.jsx($v,{className:bi("size-4",q.off)}),y.jsx("span",{className:"truncate",children:d?"Watched entfernen":"Watched"})]},"watch"):kt==="hot"?y.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||!L,onClick:async ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await L?.(s)},children:[o?y.jsx(NS,{className:bi("size-4",q.favOn)}):y.jsx(LS,{className:bi("size-4",q.off)}),y.jsx("span",{className:"truncate",children:o?"HOT entfernen":"Als HOT markieren"})]},"hot"):kt==="keep"?y.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||!M,onClick:async ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await M?.(s)},children:[y.jsx(jv,{className:bi("size-4",q.keep)}),y.jsx("span",{className:"truncate",children:"Behalten"})]},"keep"):kt==="delete"?y.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||!j,onClick:async ht=>{ht.preventDefault(),ht.stopPropagation(),vt(!1),await j?.(s)},children:[y.jsx(Vv,{className:bi("size-4",q.del)}),y.jsx("span",{className:"truncate",children:"Löschen"})]},"delete"):null;return y.jsxs("div",{ref:Xe,className:bi("relative flex items-center flex-nowrap",z??"gap-2"),children:[et.map(kt=>{const ht=at[kt];return ht?y.jsx(A.Fragment,{children:ht},kt):null}),gt&&ot.length>0?y.jsxs("div",{className:"relative",children:[y.jsx("button",{ref:Ft,type:"button",className:X,"aria-label":"Mehr",title:"Mehr","aria-haspopup":"menu","aria-expanded":nt,disabled:n,onClick:kt=>{kt.preventDefault(),kt.stopPropagation(),!n&&vt(ht=>!ht)},children:y.jsx("span",{className:bi("inline-flex items-center justify-center",O),children:y.jsx(bO,{className:bi(W,q.off)})})}),nt&&Lt&&typeof document<"u"?yc.createPortal(y.jsx("div",{ref:Gt,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:Lt.top,left:Lt.left,width:wt,maxHeight:Lt.maxH},onClick:kt=>kt.stopPropagation(),children:ot.map(gi)}),document.body):null]}):null]})}function Kx({children:s,force:e=!1,rootMargin:t="300px",placeholder:i=null,className:n}){const r=A.useRef(null),[o,u]=A.useState(e);return A.useEffect(()=>{e&&!o&&u(!0)},[e,o]),A.useEffect(()=>{if(o||e)return;const c=r.current;if(!c)return;const d=new IntersectionObserver(f=>{f.some(p=>p.isIntersecting)&&(u(!0),d.disconnect())},{rootMargin:t});return d.observe(c),()=>d.disconnect()},[o,e,t]),y.jsx("div",{ref:r,className:n,children:o?s:i})}const LA=/^HOT[ \u00A0]+/i,RA=s=>String(s||"").replaceAll(" "," "),Zu=s=>LA.test(RA(s)),sa=s=>RA(s).replace(LA,"");function gM(...s){return s.filter(Boolean).join(" ")}const yM=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 o=r.toLowerCase();i.has(o)||(i.add(o),n.push(r))}return n};function vM({rows:s,isSmall:e,teaserPlayback:t,teaserAudio:i,hoverTeaserKey:n,blurPreviews:r,teaserKey:o,inlinePlay:u,setInlinePlay:c,deletingKeys:d,keepingKeys:f,removingKeys:p,swipeRefs:g,assetNonce:v,keyFor:b,baseName:_,modelNameFromOutput:S,runtimeOf:D,sizeBytesOf:R,formatBytes:L,lower:M,onHoverPreviewKeyChange:j,onOpenPlayer:V,openPlayer:P,startInline:z,tryAutoplayInline:I,registerTeaserHost:O,deleteVideo:W,keepVideo:X,releasePlayingFile:q,modelsByKey:ue,activeTagSet:ie,onToggleTagFilter:Y,onToggleHot:G,onToggleFavorite:J,onToggleLike:oe,onToggleWatch:ce}){const[F,ee]=A.useState(null),pe=A.useRef(null);A.useEffect(()=>{if(!F)return;const ve=Be=>{Be.key==="Escape"&&ee(null)},Ce=Be=>{const tt=pe.current;tt&&(tt.contains(Be.target)||ee(null))};return document.addEventListener("keydown",ve),document.addEventListener("pointerdown",Ce),()=>{document.removeEventListener("keydown",ve),document.removeEventListener("pointerdown",Ce)}},[F]),A.useEffect(()=>{if(!F)return;s.some(Ce=>b(Ce)===F)||ee(null)},[s,b,F]);const _e=e?"180px":"500px";return y.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:s.map(ve=>{const Ce=b(ve),Be=u?.key===Ce,Je=!(!!i&&(Be||n===Ce)),Ct=Be?u?.nonce??0:0,st=d.has(Ce)||f.has(Ce)||p.has(Ce),mt=S(ve.output),pt=_(ve.output||""),ut=Zu(pt),Ht=ue[M(mt)],at=!!Ht?.favorite,gt=Ht?.liked===!0,Dt=!!Ht?.watching,Nt=yM(Ht?.tags),dt=Nt.slice(0,6),lt=Nt.length-dt.length,ye=Nt.join(", "),ze=ve.status==="failed"?"bg-red-500/35":ve.status==="finished"?"bg-emerald-500/35":ve.status==="stopped"?"bg-amber-500/35":"bg-black/40",We=D(ve),et=L(R(ve)),ot=`inline-prev-${encodeURIComponent(Ce)}`,nt=e?"":"transition-all duration-300 ease-in-out hover:-translate-y-0.5 hover:shadow-md dark:hover:shadow-none",vt=y.jsx("div",{role:"button",tabIndex:0,className:["group",nt,"rounded-xl","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500",st&&"pointer-events-none",d.has(Ce)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30 animate-pulse",f.has(Ce)&&"ring-1 ring-emerald-300 bg-emerald-50/60 dark:bg-emerald-500/10 dark:ring-emerald-500/30 animate-pulse",p.has(Ce)&&"opacity-0 translate-y-2 scale-[0.98]"].filter(Boolean).join(" "),onClick:e?void 0:()=>P(ve),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&V(ve)},children:y.jsxs(ha,{noBodyPadding:!0,className:"overflow-hidden",children:[y.jsxs("div",{id:ot,ref:O(Ce),className:"relative aspect-video bg-black/5 dark:bg-white/5",onMouseEnter:e?void 0:()=>j?.(Ce),onMouseLeave:e?void 0:()=>j?.(null),onClick:Xe=>{Xe.preventDefault(),Xe.stopPropagation(),!e&&z(Ce)},children:[y.jsx(Kx,{force:Be,rootMargin:_e,placeholder:y.jsx("div",{className:"w-full h-full bg-black/5 dark:bg-white/5 animate-pulse"}),className:"absolute inset-0",children:y.jsx(zx,{job:ve,getFileName:Xe=>sa(_(Xe)),className:"w-full h-full",showPopover:!1,blur:e||Be?!1:r,animated:t==="all"?!0:t==="hover"?o===Ce:!1,animatedMode:"teaser",animatedTrigger:"always",inlineVideo:Be?"always":!1,inlineNonce:Ct,inlineControls:Be,inlineLoop:!1,muted:Je,popoverMuted:Je,assetNonce:v??0})}),y.jsx("div",{className:["pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-black/70 to-transparent","transition-opacity duration-150",Be?"opacity-0":"opacity-100"].join(" ")}),y.jsx("div",{className:["pointer-events-none absolute inset-x-0 bottom-0 p-2 text-white","transition-opacity duration-150",Be?"opacity-0":"opacity-100"].join(" "),children:y.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] opacity-90",children:[y.jsx("span",{className:gM("rounded px-1.5 py-0.5 font-semibold",ze),children:ve.status}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:We}),y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:et})]})]})}),!e&&u?.key===Ce&&y.jsx("button",{type:"button",className:"absolute left-2 top-2 z-10 rounded-md bg-black/40 px-2 py-1 text-xs font-semibold text-white backdrop-blur hover:bg-black/60",onClick:Xe=>{Xe.preventDefault(),Xe.stopPropagation(),c(Ft=>({key:Ce,nonce:Ft?.key===Ce?Ft.nonce+1:1}))},title:"Von vorne starten","aria-label":"Von vorne starten",children:"↻"}),y.jsx("div",{className:"absolute right-2 top-2 flex items-center gap-2",onClick:Xe=>Xe.stopPropagation(),onMouseDown:Xe=>Xe.stopPropagation(),children:y.jsx(da,{job:ve,variant:"overlay",busy:st,isHot:ut,isFavorite:at,isLiked:gt,isWatching:Dt,onToggleWatch:ce,onToggleFavorite:J,onToggleLike:oe,onToggleHot:G?async Xe=>{const Ft=_(Xe.output||"");Ft&&(await q(Ft,{close:!0}),await new Promise(Gt=>setTimeout(Gt,150))),await G(Xe)}:void 0,showKeep:!e,showDelete:!e,onKeep:X,onDelete:W,order:["watch","favorite","like","hot","details","keep","delete"],className:"flex items-center gap-2"})})]}),y.jsxs("div",{className:["px-4 py-3 rounded-b-lg border-t border-gray-200/60 dark:border-white/10",e?"bg-white/90 dark:bg-gray-950/80":"bg-white/60 backdrop-blur dark:bg-white/5"].join(" "),children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("div",{className:"min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-white",children:mt}),y.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[Dt?y.jsx(xc,{className:"size-4 text-sky-600 dark:text-sky-300"}):null,gt?y.jsx(bc,{className:"size-4 text-rose-600 dark:text-rose-300"}):null,at?y.jsx(mh,{className:"size-4 text-amber-600 dark:text-amber-300"}):null]})]}),y.jsxs("div",{className:"mt-0.5 flex items-center gap-2 min-w-0 text-xs text-gray-500 dark:text-gray-400",children:[y.jsx("span",{className:"truncate",children:sa(pt)||"—"}),ut?y.jsx("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null]}),y.jsxs("div",{className:"mt-2 h-6 relative flex items-center gap-1.5",onClick:Xe=>Xe.stopPropagation(),onMouseDown:Xe=>Xe.stopPropagation(),children:[y.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:y.jsx("div",{className:"flex flex-nowrap items-center gap-1.5",children:dt.length>0?dt.map(Xe=>y.jsx(Lr,{tag:Xe,active:ie.has(M(Xe)),onClick:Y},Xe)):y.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"})})}),lt>0?y.jsxs("button",{type:"button",className:"shrink-0 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 hover:bg-gray-200/70 dark:bg-white/5 dark:text-gray-200 dark:ring-white/10 dark:hover:bg-white/10",title:ye,"aria-haspopup":"dialog","aria-expanded":F===Ce,onPointerDown:Xe=>Xe.stopPropagation(),onClick:Xe=>{Xe.preventDefault(),Xe.stopPropagation(),ee(Ft=>Ft===Ce?null:Ce)},children:["+",lt]}):null,F===Ce?y.jsxs("div",{ref:pe,className:["absolute right-0 bottom-8 z-30 w-72 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-gray-200/70 bg-white/95 shadow-lg ring-1 ring-black/5",e?"":"backdrop-blur","dark:border-white/10 dark:bg-gray-950/90 dark:ring-white/10"].join(" "),onClick:Xe=>Xe.stopPropagation(),onMouseDown:Xe=>Xe.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-200/60 px-3 py-2 dark:border-white/10",children:[y.jsx("div",{className:"text-xs font-semibold text-gray-900 dark:text-white",children:"Tags"}),y.jsx("button",{type:"button",className:"rounded px-2 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/10",onClick:()=>ee(null),"aria-label":"Schließen",title:"Schließen",children:"✕"})]}),y.jsx("div",{className:"max-h-48 overflow-auto p-2",children:y.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nt.map(Xe=>y.jsx(Lr,{tag:Xe,active:ie.has(M(Xe)),onClick:Y},Xe))})})]}):null]})]})]})});return e?y.jsx(JO,{ref:Xe=>{Xe?g.current.set(Ce,Xe):g.current.delete(Ce)},enabled:!0,disabled:st,ignoreFromBottomPx:110,onTap:()=>{const Xe=`inline-prev-${encodeURIComponent(Ce)}`;z(Ce),requestAnimationFrame(()=>{I(Xe)||requestAnimationFrame(()=>I(Xe))})},onSwipeLeft:()=>W(ve),onSwipeRight:()=>X(ve),children:vt},Ce):y.jsx(A.Fragment,{children:vt},Ce)})})}function xM({rows:s,columns:e,getRowKey:t,sort:i,onSortChange:n,onRowClick:r,rowClassName:o}){return y.jsx(Gx,{rows:s,columns:e,getRowKey:t,striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0,sort:i,onSortChange:n,onRowClick:r,rowClassName:o})}function bM({rows:s,blurPreviews:e,durations:t,teaserPlayback:i,teaserAudio:n,hoverTeaserKey:r,teaserKey:o,handleDuration:u,keyFor:c,baseName:d,modelNameFromOutput:f,runtimeOf:p,sizeBytesOf:g,formatBytes:v,deletingKeys:b,keepingKeys:_,removingKeys:S,deletedKeys:D,registerTeaserHost:R,onHoverPreviewKeyChange:L,onOpenPlayer:M,deleteVideo:j,keepVideo:V,onToggleHot:P,lower:z,modelsByKey:I,activeTagSet:O,onToggleTagFilter:W,onToggleFavorite:X,onToggleLike:q,onToggleWatch:ue}){const[ie,Y]=A.useState(null),G=A.useRef(null),J=i==="hover"||i==="all",oe=A.useCallback(F=>ee=>{if(!J){R(F)(null);return}R(F)(ee)},[R,J]);A.useEffect(()=>{if(!ie)return;const F=pe=>{pe.key==="Escape"&&Y(null)},ee=pe=>{const _e=G.current;_e&&(_e.contains(pe.target)||Y(null))};return document.addEventListener("keydown",F),document.addEventListener("pointerdown",ee),()=>{document.removeEventListener("keydown",F),document.removeEventListener("pointerdown",ee)}},[ie]),A.useEffect(()=>{if(!ie)return;s.some(ee=>c(ee)===ie)||Y(null)},[s,c,ie]);const ce=F=>{const ee=String(F??"").trim();if(!ee)return[];const pe=ee.split(/[\n,;|]+/g).map(Ce=>Ce.trim()).filter(Boolean),_e=new Set,ve=[];for(const Ce of pe){const Be=Ce.toLowerCase();_e.has(Be)||(_e.add(Be),ve.push(Ce))}return ve};return y.jsx(y.Fragment,{children:y.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:s.map(F=>{const ee=c(F),_e=!(!!n&&r===ee),ve=f(F.output),Ce=z(ve),Be=I[Ce],tt=!!Be?.favorite,Je=Be?.liked===!0,Ct=!!Be?.watching,st=ce(Be?.tags),mt=st.slice(0,6),pt=st.length-mt.length,ut=st.join(", "),Ht=d(F.output||""),at=Zu(Ht),gt=sa(Ht),Dt=p(F),Nt=v(g(F)),dt=b.has(ee)||_.has(ee)||S.has(ee),lt=D.has(ee);return y.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",dt&&"pointer-events-none opacity-70",b.has(ee)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30",S.has(ee)&&"opacity-0 translate-y-2 scale-[0.98]",lt&&"hidden"].filter(Boolean).join(" "),onClick:()=>M(F),onKeyDown:ye=>{(ye.key==="Enter"||ye.key===" ")&&M(F)},children:[y.jsxs("div",{className:"group relative aspect-video rounded-t-lg bg-black/5 dark:bg-white/5",ref:oe(ee),onMouseEnter:()=>L?.(ee),onMouseLeave:()=>L?.(null),children:[y.jsxs("div",{className:"absolute inset-0 overflow-hidden rounded-t-lg",children:[y.jsx(Kx,{force:o===ee||r===ee,rootMargin:"500px",placeholder:y.jsx("div",{className:"absolute inset-0 bg-black/5 dark:bg-white/5 animate-pulse"}),className:"absolute inset-0",children:y.jsx(zx,{job:F,getFileName:ye=>sa(d(ye)),durationSeconds:t[ee]??F?.durationSeconds,onDuration:u,variant:"fill",showPopover:!1,blur:e,animated:i==="all"?!0:i==="hover"?o===ee:!1,animatedMode:"teaser",animatedTrigger:"always",clipSeconds:1,thumbSamples:18,muted:_e,popoverMuted:_e})}),y.jsx("div",{className:`
pointer-events-none absolute inset-x-0 bottom-0 h-16
bg-gradient-to-t from-black/65 to-transparent
transition-opacity duration-150
group-hover:opacity-0 group-focus-within:opacity-0
`}),y.jsx("div",{className:`
pointer-events-none absolute inset-x-0 bottom-0 p-2 text-white
`,children:y.jsxs("div",{className:"flex items-end justify-between gap-2",children:[y.jsx("div",{className:"min-w-0",children:y.jsx("div",{children:y.jsx("span",{className:["inline-block rounded px-1.5 py-0.5 text-[11px] font-semibold",F.status==="finished"?"bg-emerald-600/70":F.status==="stopped"?"bg-amber-600/70":F.status==="failed"?"bg-red-600/70":"bg-black/50"].join(" "),children:F.status})})}),y.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 text-xs font-medium",children:Dt}),y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 text-xs font-medium",children:Nt})]})]})})]}),y.jsx("div",{className:"absolute inset-x-2 top-2 z-10 flex justify-end",onClick:ye=>ye.stopPropagation(),children:y.jsx(da,{job:F,variant:"overlay",busy:dt,collapseToMenu:!0,isHot:at,isFavorite:tt,isLiked:Je,isWatching:Ct,onToggleWatch:ue,onToggleFavorite:X,onToggleLike:q,onToggleHot:P,onKeep:V,onDelete:j,order:["watch","favorite","like","hot","keep","delete","details"],className:"w-full justify-end gap-1"})})]}),y.jsxs("div",{className:"px-4 py-3 rounded-b-lg border-t border-gray-200/60 bg-white/60 backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("div",{className:"min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-white",children:ve}),y.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[Ct?y.jsx(xc,{className:"size-4 text-sky-600 dark:text-sky-300"}):null,Je?y.jsx(bc,{className:"size-4 text-rose-600 dark:text-rose-300"}):null,tt?y.jsx(mh,{className:"size-4 text-amber-600 dark:text-amber-300"}):null]})]}),y.jsxs("div",{className:"mt-0.5 flex items-center gap-2 min-w-0 text-xs text-gray-500 dark:text-gray-400",children:[y.jsx("span",{className:"truncate",children:sa(gt)||"—"}),at?y.jsx("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null]}),y.jsxs("div",{className:"mt-2 h-6 relative flex items-center gap-1.5",onClick:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),children:[y.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:y.jsx("div",{className:"flex flex-nowrap items-center gap-1.5",children:mt.length>0?mt.map(ye=>y.jsx(Lr,{tag:ye,active:O.has(z(ye)),onClick:W},ye)):y.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"})})}),pt>0?y.jsxs("button",{type:"button",className:"shrink-0 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 hover:bg-gray-200/70 dark:bg-white/5 dark:text-gray-200 dark:ring-white/10 dark:hover:bg-white/10",title:ut,"aria-haspopup":"dialog","aria-expanded":ie===ee,onPointerDown:ye=>ye.stopPropagation(),onClick:ye=>{ye.preventDefault(),ye.stopPropagation(),Y(ze=>ze===ee?null:ee)},children:["+",pt]}):null,ie===ee?y.jsxs("div",{ref:G,className:"absolute right-0 bottom-8 z-30 w-72 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-gray-200/70 bg-white/95 shadow-lg ring-1 ring-black/5 backdrop-blur dark:border-white/10 dark:bg-gray-950/90 dark:ring-white/10",onClick:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-200/60 px-3 py-2 dark:border-white/10",children:[y.jsx("div",{className:"text-xs font-semibold text-gray-900 dark:text-white",children:"Tags"}),y.jsx("button",{type:"button",className:"rounded px-2 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/10",onClick:()=>Y(null),"aria-label":"Schließen",title:"Schließen",children:"✕"})]}),y.jsx("div",{className:"max-h-48 overflow-auto p-2",children:y.jsx("div",{className:"flex flex-wrap gap-1.5",children:st.map(ye=>y.jsx(Lr,{tag:ye,active:O.has(z(ye)),onClick:W},ye))})})]}):null]})]})]},ee)})})})}function OS(s,e,t){return Math.max(e,Math.min(t,s))}function yy(s,e){const t=[];for(let i=s;i<=e;i++)t.push(i);return t}function TM(s,e,t,i){if(s<=1)return[1];const n=1,r=s,o=yy(n,Math.min(t,r)),u=yy(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(...o),c>t+1?f.push("ellipsis"):t+1<r-t&&f.push(t+1),f.push(...yy(c,d)),d<r-t?f.push("ellipsis"):r-t>t&&f.push(r-t),f.push(...u);const p=new Set;return f.filter(g=>{const v=String(g);return p.has(v)?!1:(p.add(v),!0)})}function _M({active:s,disabled:e,rounded:t,onClick:i,children:n,title:r}){const o=t==="l"?"rounded-l-md":t==="r"?"rounded-r-md":"";return y.jsx("button",{type:"button",disabled:e,onClick:e?void 0:i,title:r,className:yi("relative inline-flex items-center px-4 py-2 text-sm font-semibold focus:z-20 focus:outline-offset-0",o,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 IA({page:s,pageSize:e,totalItems:t,onPageChange:i,siblingCount:n=1,boundaryCount:r=1,showSummary:o=!0,className:u,ariaLabel:c="Pagination",prevLabel:d="Previous",nextLabel:f="Next"}){const p=Math.max(1,Math.ceil((t||0)/Math.max(1,e||1))),g=OS(s||1,1,p);if(p<=1)return null;const v=t===0?0:(g-1)*e+1,b=Math.min(g*e,t),_=TM(p,g,r,n),S=D=>i(OS(D,1,p));return y.jsxs("div",{className:yi("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:[y.jsxs("div",{className:"flex flex-1 justify-between sm:hidden",children:[y.jsx("button",{type:"button",onClick:()=>S(g-1),disabled:g<=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}),y.jsx("button",{type:"button",onClick:()=>S(g+1),disabled:g>=p,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})]}),y.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",children:[y.jsx("div",{children:o?y.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",y.jsx("span",{className:"font-medium",children:v})," to"," ",y.jsx("span",{className:"font-medium",children:b})," of"," ",y.jsx("span",{className:"font-medium",children:t})," results"]}):null}),y.jsx("div",{children:y.jsxs("nav",{"aria-label":c,className:"isolate inline-flex -space-x-px rounded-md shadow-xs dark:shadow-none",children:[y.jsxs("button",{type:"button",onClick:()=>S(g-1),disabled:g<=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:[y.jsx("span",{className:"sr-only",children:d}),y.jsx(J5,{"aria-hidden":"true",className:"size-5"})]}),_.map((D,R)=>D==="ellipsis"?y.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-${R}`):y.jsx(_M,{active:D===g,onClick:()=>S(D),rounded:"none",children:D},D)),y.jsxs("button",{type:"button",onClick:()=>S(g+1),disabled:g>=p,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:[y.jsx("span",{className:"sr-only",children:f}),y.jsx(tO,{"aria-hidden":"true",className:"size-5"})]})]})})]})]})}const NA=A.createContext(null);function SM(s){switch(s){case"success":return{Icon:vO,cls:"text-emerald-500"};case"error":return{Icon:QO,cls:"text-rose-500"};case"warning":return{Icon:_O,cls:"text-amber-500"};default:return{Icon:DO,cls:"text-sky-500"}}}function EM(s){switch(s){case"success":return"border-emerald-200/70 dark:border-emerald-400/20";case"error":return"border-rose-200/70 dark:border-rose-400/20";case"warning":return"border-amber-200/70 dark:border-amber-400/20";default:return"border-sky-200/70 dark:border-sky-400/20"}}function wM(s){switch(s){case"success":return"Erfolg";case"error":return"Fehler";case"warning":return"Hinweis";default:return"Info"}}function AM(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function CM({children:s,maxToasts:e=3,defaultDurationMs:t=3500,position:i="bottom-right"}){const[n,r]=A.useState([]),o=A.useCallback(v=>{r(b=>b.filter(_=>_.id!==v))},[]),u=A.useCallback(()=>r([]),[]),c=A.useCallback(v=>{const b=AM(),_=v.durationMs??t;return r(S=>[{...v,id:b,durationMs:_},...S].slice(0,Math.max(1,e))),_&&_>0&&window.setTimeout(()=>o(b),_),b},[t,e,o]),d=A.useMemo(()=>({push:c,remove:o,clear:u}),[c,o,u]),f=i==="top-right"||i==="top-left"?"items-start sm:items-start sm:justify-start":"items-end sm:items-end sm:justify-end",p=i.endsWith("left")?"sm:items-start":"sm:items-end",g=i.startsWith("top")?"top-0 bottom-auto":"bottom-0 top-auto";return y.jsxs(NA.Provider,{value:d,children:[s,y.jsx("div",{"aria-live":"assertive",className:["pointer-events-none fixed z-[80] inset-x-0",g].join(" "),children:y.jsx("div",{className:["flex w-full px-4 py-6 sm:p-6",f].join(" "),children:y.jsx("div",{className:["flex w-full flex-col space-y-3",p].join(" "),children:n.map(v=>{const{Icon:b,cls:_}=SM(v.type),S=(v.title||"").trim()||wM(v.type),D=(v.message||"").trim();return y.jsx(nh,{appear:!0,show:!0,children:y.jsx("div",{className:["pointer-events-auto w-full max-w-sm overflow-hidden rounded-xl","border bg-white/90 shadow-lg backdrop-blur","outline-1 outline-black/5","dark:bg-gray-950/70 dark:-outline-offset-1 dark:outline-white/10",EM(v.type),"transition data-closed:opacity-0 data-enter:transform data-enter:duration-200 data-enter:ease-out","data-closed:data-enter:translate-y-2 sm:data-closed:data-enter:translate-y-0",i.endsWith("right")?"sm:data-closed:data-enter:translate-x-2":"sm:data-closed:data-enter:-translate-x-2"].join(" "),children:y.jsx("div",{className:"p-4",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsx("div",{className:"shrink-0",children:y.jsx(b,{className:["size-6",_].join(" "),"aria-hidden":"true"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:S}),D?y.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-300 break-words",children:D}):null]}),y.jsxs("button",{type:"button",onClick:()=>o(v.id),className:"shrink-0 rounded-md text-gray-400 hover:text-gray-600 focus:outline-2 focus:outline-offset-2 focus:outline-indigo-600 dark:hover:text-white dark:focus:outline-indigo-500",children:[y.jsx("span",{className:"sr-only",children:"Close"}),y.jsx(sO,{"aria-hidden":"true",className:"size-5"})]})]})})})},v.id)})})})})]})}function kM(){const s=A.useContext(NA);if(!s)throw new Error("useToast must be used within <ToastProvider>");return s}function OA(){const{push:s,remove:e,clear:t}=kM(),i=n=>(r,o,u)=>s({type:n,title:r,message:o,...u});return{push:s,remove:e,clear:t,success:i("success"),error:i("error"),info:i("info"),warning:i("warning")}}const MA=s=>(s||"").replaceAll("\\","/"),rn=s=>{const t=MA(s).split("/");return t[t.length-1]||""},Rn=s=>rn(s.output||"")||s.id;function MS(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 vy(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 PS(s){const[e,t]=A.useState(!1);return A.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 DM=s=>{const e=(s??"").match(/\bHTTP\s+(\d{3})\b/i);return e?`HTTP ${e[1]}`:null},Bo=s=>{const e=rn(s||""),t=sa(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},hn=s=>(s||"").trim().toLowerCase(),BS=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 o=r.toLowerCase();i.has(o)||(i.add(o),n.push(r))}return n.sort((r,o)=>r.localeCompare(o,void 0,{sensitivity:"base"})),n},lm=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 LM({jobs:s,doneJobs:e,blurPreviews:t,teaserPlayback:i,teaserAudio:n,onOpenPlayer:r,onDeleteJob:o,onToggleHot:u,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,doneTotal:p,page:g,pageSize:v,onPageChange:b,assetNonce:_,sortMode:S,onSortModeChange:D,modelsByKey:R}){const L=i??"hover",M=PS("(hover: hover) and (pointer: fine)"),j=OA(),V=A.useRef(new Map),[P,z]=A.useState(null),[I,O]=A.useState(null),W=A.useRef(null),X=A.useRef(new WeakMap),[q,ue]=A.useState(()=>new Set),[ie,Y]=A.useState(()=>new Set),[G,J]=A.useState({}),[oe,ce]=A.useState(null),[F,ee]=A.useState(null),[pe,_e]=A.useState(0),ve=A.useRef(null),Ce=A.useCallback(()=>{ve.current&&window.clearTimeout(ve.current),ve.current=window.setTimeout(()=>_e(Q=>Q+1),80)},[]),[Be,tt]=A.useState(null),Je="finishedDownloads_view",Ct="finishedDownloads_includeKeep_v2",st="finishedDownloads_mobileOptionsOpen_v1",[mt,pt]=A.useState("table"),[ut,Ht]=A.useState(!1),[at,gt]=A.useState(!1),Dt=A.useRef(new Map),[Nt,dt]=A.useState([]),lt=A.useMemo(()=>new Set(Nt.map(hn)),[Nt]),ye=A.useMemo(()=>{const Q={},se={};for(const[ae,xe]of Object.entries(R??{})){const Te=hn(ae),je=BS(xe?.tags);Q[Te]=je,se[Te]=new Set(je.map(hn))}return{tagsByModelKey:Q,tagSetByModelKey:se}},[R]),[ze,We]=A.useState(""),et=A.useDeferredValue(ze),ot=A.useMemo(()=>hn(et).split(/\s+/g).map(Q=>Q.trim()).filter(Boolean),[et]),nt=A.useCallback(()=>We(""),[]),vt=A.useCallback(Q=>{const se=hn(Q);dt(ae=>ae.some(Te=>hn(Te)===se)?ae.filter(Te=>hn(Te)!==se):[...ae,Q])},[]),Xe=ot.length>0||lt.size>0,Ft=A.useCallback(async Q=>{const se=await fetch(`/api/record/done?all=1&sort=${encodeURIComponent(S)}&withCount=1${ut?"&includeKeep=1":""}`,{cache:"no-store",signal:Q});if(!se.ok)return;const ae=await se.json().catch(()=>null),xe=Array.isArray(ae?.items)?ae.items:[],Te=Number(ae?.count??ae?.totalCount??xe.length);ce(xe),ee(Number.isFinite(Te)?Te:xe.length)},[S,ut]),Gt=A.useCallback(()=>dt([]),[]);A.useEffect(()=>{try{const Q=localStorage.getItem("finishedDownloads_pendingTags");if(!Q)return;const se=JSON.parse(Q),ae=Array.isArray(se)?se.map(xe=>String(xe||"").trim()).filter(Boolean):[];if(ae.length===0)return;yc.flushSync(()=>dt(ae)),g!==1&&b(1)}catch{}finally{try{localStorage.removeItem("finishedDownloads_pendingTags")}catch{}}},[]),A.useEffect(()=>{if(!Xe)return;const Q=new AbortController,se=window.setTimeout(()=>{Ft(Q.signal).catch(()=>{})},250);return()=>{window.clearTimeout(se),Q.abort()}},[Xe,Ft]),A.useEffect(()=>{if(pe===0)return;if(Xe){const se=new AbortController;return(async()=>{try{await Ft(se.signal)}catch{}})(),()=>se.abort()}const Q=new AbortController;return(async()=>{try{const se=await fetch(`/api/record/done?page=${g}&pageSize=${v}&sort=${encodeURIComponent(S)}&withCount=1${ut?"&includeKeep=1":""}`,{cache:"no-store",signal:Q.signal});if(se.ok){const ae=await se.json().catch(()=>null),xe=Array.isArray(ae?.items)?ae.items:[],Te=Number(ae?.count??ae?.totalCount??xe.length);if(ce(xe),Number.isFinite(Te)&&Te>=0){ee(Te);const je=Math.max(1,Math.ceil(Te/v));if(g>je){b(je),ce(null);return}}}}catch{}})(),()=>Q.abort()},[pe,g,v,b,S,Xe,Ft,ut]),A.useEffect(()=>{Xe||(ce(null),ee(null))},[g,v,S,ut,Xe]),A.useEffect(()=>{if(!ut){Xe||(ce(null),ee(null));return}if(Xe)return;const Q=new AbortController;return(async()=>{try{const se=await fetch(`/api/record/done?page=${g}&pageSize=${v}&sort=${encodeURIComponent(S)}&withCount=1&includeKeep=1`,{cache:"no-store",signal:Q.signal});if(!se.ok)return;const ae=await se.json().catch(()=>null),xe=Array.isArray(ae?.items)?ae.items:[],Te=Number(ae?.count??ae?.totalCount??xe.length);ce(xe),ee(Number.isFinite(Te)?Te:xe.length)}catch{}})(),()=>Q.abort()},[ut,Xe,g,v,S]),A.useEffect(()=>{try{const Q=localStorage.getItem(Je);pt(Q==="table"||Q==="cards"||Q==="gallery"?Q:window.matchMedia("(max-width: 639px)").matches?"cards":"table")}catch{pt("table")}},[]),A.useEffect(()=>{try{localStorage.setItem(Je,mt)}catch{}},[mt]),A.useEffect(()=>{try{const Q=localStorage.getItem(Ct);Ht(Q==="1"||Q==="true"||Q==="yes")}catch{Ht(!1)}},[]),A.useEffect(()=>{try{localStorage.setItem(Ct,ut?"1":"0")}catch{}},[ut]),A.useEffect(()=>{try{const Q=localStorage.getItem(st);gt(Q==="1"||Q==="true"||Q==="yes")}catch{gt(!1)}},[]),A.useEffect(()=>{try{localStorage.setItem(st,at?"1":"0")}catch{}},[at]);const[wt,hi]=A.useState({}),[Qe,Lt]=A.useState(null),Ut=!n,vi=A.useCallback(Q=>{const ae=document.getElementById(Q)?.querySelector("video");if(!ae)return!1;Qm(ae,{muted:Ut});const xe=ae.play?.();return xe&&typeof xe.catch=="function"&&xe.catch(()=>{}),!0},[Ut]),gi=A.useCallback(Q=>{Lt(se=>se?.key===Q?{key:Q,nonce:se.nonce+1}:{key:Q,nonce:1})},[]),kt=A.useCallback(Q=>{Lt(null),r(Q)},[r]),ht=A.useCallback((Q,se)=>{Y(ae=>{const xe=new Set(ae);return se?xe.add(Q):xe.delete(Q),xe})},[]),ri=A.useCallback(Q=>{ue(se=>{const ae=new Set(se);return ae.add(Q),ae})},[]),[Ie,H]=A.useState(()=>new Set),K=A.useCallback((Q,se)=>{H(ae=>{const xe=new Set(ae);return se?xe.add(Q):xe.delete(Q),xe})},[]),[re,Ee]=A.useState(()=>new Set),Ye=A.useCallback((Q,se)=>{Ee(ae=>{const xe=new Set(ae);return se?xe.add(Q):xe.delete(Q),xe})},[]),Tt=A.useCallback(Q=>{Ye(Q,!0),window.setTimeout(()=>{ri(Q),Ye(Q,!1),Ce()},320)},[ri,Ye,Ce]),zt=A.useCallback(async(Q,se)=>{window.dispatchEvent(new CustomEvent("player:release",{detail:{file:Q}})),se?.close&&window.dispatchEvent(new CustomEvent("player:close",{detail:{file:Q}})),await new Promise(ae=>window.setTimeout(ae,250))},[]),xi=A.useCallback(async Q=>{const se=rn(Q.output||""),ae=Rn(Q);if(!se)return j.error("Löschen nicht möglich","Kein Dateiname gefunden kann nicht löschen."),!1;if(ie.has(ae))return!1;ht(ae,!0);try{if(await zt(se,{close:!0}),o)return await o(Q),!0;const xe=await fetch(`/api/record/delete?file=${encodeURIComponent(se)}`,{method:"POST"});if(!xe.ok){const Te=await xe.text().catch(()=>"");throw new Error(Te||`HTTP ${xe.status}`)}return Tt(ae),window.dispatchEvent(new CustomEvent("finished-downloads:count-hint",{detail:{delta:-1}})),!0}catch(xe){return j.error("Löschen fehlgeschlagen",String(xe?.message||xe)),!1}finally{ht(ae,!1)}},[ie,ht,zt,o,Tt,j]),Wi=A.useCallback(async Q=>{const se=rn(Q.output||""),ae=Rn(Q);if(!se)return j.error("Keep nicht möglich","Kein Dateiname gefunden kann nicht behalten."),!1;if(Ie.has(ae)||ie.has(ae))return!1;K(ae,!0);try{await zt(se,{close:!0});const xe=await fetch(`/api/record/keep?file=${encodeURIComponent(se)}`,{method:"POST"});if(!xe.ok){const Te=await xe.text().catch(()=>"");throw new Error(Te||`HTTP ${xe.status}`)}return Tt(ae),window.dispatchEvent(new CustomEvent("finished-downloads:count-hint",{detail:{delta:-1}})),!0}catch(xe){return j.error("Keep fehlgeschlagen",String(xe?.message||xe)),!1}finally{K(ae,!1)}},[Ie,ie,K,zt,Tt,j]),Xi=A.useCallback(async Q=>{const se=rn(Q.output||"");if(!se){j.error("HOT nicht möglich","Kein Dateiname gefunden kann nicht HOT togglen.");return}const ae=je=>Zu(je)?sa(je):`HOT ${je}`,xe=(je,de)=>{!de||de===je||(J(me=>({...me,[je]:de})),hi(me=>{const Pe=me[je];if(typeof Pe!="number")return me;const{[je]:it,...ft}=me;return{...ft,[de]:Pe}}))},Te=(je,de,me)=>{de&&(de===me&&je===se||(J(Pe=>({...Pe,[je]:de})),hi(Pe=>{const it=Pe[je]??Pe[me];if(typeof it!="number")return Pe;const{[je]:ft,[me]:Ke,...Ve}=Pe;return{...Ve,[de]:it}})))};try{await zt(se,{close:!0});const je=se,de=ae(je);if(xe(je,de),u){await u(Q),Ce();return}const me=await fetch(`/api/record/toggle-hot?file=${encodeURIComponent(se)}`,{method:"POST"});if(!me.ok){const Ke=await me.text().catch(()=>"");throw new Error(Ke||`HTTP ${me.status}`)}const Pe=await me.json().catch(()=>null),it=typeof Pe?.oldFile=="string"&&Pe.oldFile?Pe.oldFile:se,ft=typeof Pe?.newFile=="string"&&Pe.newFile?Pe.newFile:"";Te(it,ft,de),Ce()}catch(je){j.error("HOT umbenennen fehlgeschlagen",String(je?.message||je))}},[rn,zt,u,j,Ce]),rs=A.useCallback(Q=>{const se=Q?.durationSeconds;if(typeof se=="number"&&Number.isFinite(se)&&se>0)return se;const ae=Date.parse(String(Q?.startedAt||"")),xe=Date.parse(String(Q?.endedAt||""));if(Number.isFinite(ae)&&Number.isFinite(xe)&&xe>ae){const Te=(xe-ae)/1e3;if(Te>=1&&Te<=1440*60)return Te}return Number.POSITIVE_INFINITY},[]),Qi=A.useCallback(Q=>{const se=MA(Q.output||""),ae=rn(se),xe=G[ae];if(!xe)return Q;const Te=se.lastIndexOf("/"),je=Te>=0?se.slice(0,Te+1):"";return{...Q,output:je+xe}},[G,rn]),ai=oe??e,Fi=F??p,Ui=A.useMemo(()=>{const Q=new Map;for(const ae of ai){const xe=Qi(ae);Q.set(Rn(xe),xe)}for(const ae of s){const xe=Qi(ae),Te=Rn(xe);Q.has(Te)&&Q.set(Te,{...Q.get(Te),...xe})}return Array.from(Q.values()).filter(ae=>q.has(Rn(ae))?!1:ae.status==="finished"||ae.status==="failed"||ae.status==="stopped")},[s,ai,q,Qi]),Ei=Ui;A.useEffect(()=>{const Q=se=>{const ae=se.detail;if(!ae?.file)return;const xe=ae.file;ae.phase==="start"?(ht(xe,!0),mt==="cards"?window.setTimeout(()=>{ri(xe)},320):Tt(xe)):ae.phase==="error"?(ht(xe,!1),mt==="cards"&&Dt.current.get(xe)?.reset()):ae.phase==="success"&&(ht(xe,!1),Ce())};return window.addEventListener("finished-downloads:delete",Q),()=>window.removeEventListener("finished-downloads:delete",Q)},[Tt,ht,ri,mt,Ce]);const Wt=A.useMemo(()=>{const Q=Ei.filter(ae=>!q.has(Rn(ae))),se=ot.length?Q.filter(ae=>{const xe=rn(ae.output||""),Te=Bo(ae.output),je=hn(Te),de=ye.tagsByModelKey[je]??[],me=hn([xe,sa(xe),Te,ae.id,ae.status,de.join(" ")].join(" "));for(const Pe of ot)if(!me.includes(Pe))return!1;return!0}):Q;return lt.size===0?se:se.filter(ae=>{const xe=hn(Bo(ae.output)),Te=ye.tagSetByModelKey[xe];if(!Te||Te.size===0)return!1;for(const je of lt)if(!Te.has(je))return!1;return!0})},[Ei,q,lt,ye,ot]),Kt=Xe?Wt.length:Fi,jt=A.useMemo(()=>{if(!Xe)return Wt;const Q=(g-1)*v,se=Q+v;return Wt.slice(Math.max(0,Q),Math.max(0,se))},[Xe,Wt,g,v]);A.useEffect(()=>{if(!Xe)return;const Q=Math.max(1,Math.ceil(Wt.length/v));g>Q&&b(Q)},[Xe,Wt.length,g,v,b]),A.useEffect(()=>{if(!(L==="hover"&&!M&&(mt==="cards"||mt==="gallery"||mt==="table"))){z(null),W.current?.disconnect(),W.current=null;return}if(mt==="cards"&&Qe?.key){z(Qe.key);return}W.current?.disconnect();const se=new IntersectionObserver(ae=>{let xe=null,Te=0;for(const je of ae){if(!je.isIntersecting)continue;const de=X.current.get(je.target);de&&je.intersectionRatio>Te&&(Te=je.intersectionRatio,xe=de)}xe&&z(je=>je===xe?je:xe)},{threshold:[0,.15,.3,.5,.7,.9],rootMargin:"0px"});W.current=se;for(const[ae,xe]of V.current)X.current.set(xe,ae),se.observe(xe);return()=>{se.disconnect(),W.current===se&&(W.current=null)}},[mt,L,M,Qe?.key]);const Ii=Q=>{const se=Rn(Q),ae=wt[se]??Q?.durationSeconds;if(typeof ae=="number"&&Number.isFinite(ae)&&ae>0)return MS(ae*1e3);const xe=Date.parse(String(Q.startedAt||"")),Te=Date.parse(String(Q.endedAt||""));return Number.isFinite(xe)&&Number.isFinite(Te)&&Te>xe?MS(Te-xe):"—"},ds=A.useCallback(Q=>se=>{const ae=V.current.get(Q);ae&&W.current&&W.current.unobserve(ae),se?(V.current.set(Q,se),X.current.set(se,Q),W.current?.observe(se)):V.current.delete(Q)},[]),as=A.useCallback((Q,se)=>{if(!Number.isFinite(se)||se<=0)return;const ae=Rn(Q);hi(xe=>{const Te=xe[ae];return typeof Te=="number"&&Math.abs(Te-se)<.5?xe:{...xe,[ae]:se}})},[]),Fs=[{key:"preview",header:"Vorschau",widthClassName:"w-[140px]",cell:Q=>{const se=Rn(Q),xe=!(!!n&&I===se);return y.jsx("div",{ref:ds(se),className:"py-1",onClick:Te=>Te.stopPropagation(),onMouseDown:Te=>Te.stopPropagation(),onMouseEnter:()=>{M&&O(se)},onMouseLeave:()=>{M&&O(null)},children:y.jsx(Kx,{force:P===se||I===se,rootMargin:"400px",placeholder:y.jsx("div",{className:"w-28 h-16 rounded-md ring-1 ring-black/5 dark:ring-white/10 bg-black/5 dark:bg-white/5 animate-pulse"}),children:y.jsx(zx,{job:Q,getFileName:rn,durationSeconds:wt[se],muted:xe,popoverMuted:xe,onDuration:as,className:"w-28 h-16 rounded-md ring-1 ring-black/5 dark:ring-white/10",showPopover:!1,blur:t,animated:i==="all"?!0:i==="hover"?P===se:!1,animatedMode:"teaser",animatedTrigger:"always",assetNonce:_})})})}},{key:"Model",header:"Model",sortable:!0,sortValue:Q=>{const se=rn(Q.output||""),ae=Zu(se),xe=Bo(Q.output),Te=sa(se);return`${xe} ${ae?"HOT":""} ${Te}`.trim()},cell:Q=>{const se=rn(Q.output||""),ae=Zu(se),xe=sa(se),Te=Bo(Q.output),je=hn(Bo(Q.output)),de=BS(R[je]?.tags),me=de.slice(0,6),Pe=de.length-me.length,it=de.join(", ");return y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:Te}),y.jsxs("div",{className:"mt-0.5 min-w-0 text-xs text-gray-500 dark:text-gray-400",children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.jsx("span",{className:"truncate",title:xe,children:xe||"—"}),ae?y.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]}),me.length>0?y.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 min-w-0",children:[me.map(ft=>y.jsx(Lr,{tag:ft,active:lt.has(hn(ft)),onClick:vt},ft)),Pe>0?y.jsxs("span",{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 dark:bg-white/5 dark:text-gray-200 dark:ring-white/10",title:it,children:["+",Pe]}):null]}):null]})]})}},{key:"status",header:"Status",sortable:!0,sortValue:Q=>Q.status==="finished"?0:Q.status==="stopped"?1:Q.status==="failed"?2:9,cell:Q=>{const se="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold ring-1 ring-inset";if(Q.status==="failed"){const ae=DM(Q.error),xe=ae?`failed (${ae})`:"failed";return y.jsx("span",{className:`${se} bg-red-50 text-red-700 ring-red-200 dark:bg-red-500/10 dark:text-red-300 dark:ring-red-500/30`,title:Q.error||"",children:xe})}return Q.status==="finished"?y.jsx("span",{className:`${se} bg-emerald-50 text-emerald-800 ring-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-300 dark:ring-emerald-500/30`,children:"finished"}):Q.status==="stopped"?y.jsx("span",{className:`${se} bg-amber-50 text-amber-800 ring-amber-200 dark:bg-amber-500/10 dark:text-amber-300 dark:ring-amber-500/30`,children:"stopped"}):y.jsx("span",{className:`${se} bg-gray-50 text-gray-700 ring-gray-200 dark:bg-white/5 dark:text-gray-300 dark:ring-white/10`,children:Q.status})}},{key:"completedAt",header:"Fertiggestellt am",sortable:!0,widthClassName:"w-[150px]",sortValue:Q=>{const se=Date.parse(String(Q.endedAt||""));return Number.isFinite(se)?se:Number.NEGATIVE_INFINITY},cell:Q=>{const se=Date.parse(String(Q.endedAt||""));if(!Number.isFinite(se))return y.jsx("span",{className:"text-xs text-gray-400",children:"—"});const ae=new Date(se),xe=ae.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),Te=ae.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"});return y.jsxs("time",{dateTime:ae.toISOString(),title:`${xe} ${Te}`,className:"tabular-nums whitespace-nowrap text-sm text-gray-900 dark:text-white",children:[y.jsx("span",{className:"font-medium",children:xe}),y.jsx("span",{className:"mx-1 text-gray-400 dark:text-gray-600",children:"·"}),y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:Te})]})}},{key:"runtime",header:"Dauer",align:"right",sortable:!0,sortValue:Q=>rs(Q),cell:Q=>y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:Ii(Q)})},{key:"size",header:"Größe",align:"right",sortable:!0,sortValue:Q=>{const se=lm(Q);return typeof se=="number"?se:Number.NEGATIVE_INFINITY},cell:Q=>y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:vy(lm(Q))})},{key:"actions",header:"Aktionen",align:"right",srOnlyHeader:!0,cell:Q=>{const se=Rn(Q),ae=ie.has(se)||Ie.has(se)||re.has(se),xe=rn(Q.output||""),Te=Zu(xe),je=hn(Bo(Q.output)),de=R[je],me=!!de?.favorite,Pe=de?.liked===!0,it=!!de?.watching;return y.jsx(da,{job:Q,variant:"table",busy:ae,isHot:Te,isFavorite:me,isLiked:Pe,isWatching:it,onToggleWatch:f,onToggleFavorite:c,onToggleLike:d,onToggleHot:Xi,onKeep:Wi,onDelete:xi,order:["watch","favorite","like","hot","details","keep","delete"],className:"flex items-center justify-end gap-1"})}}],fi=Q=>{if(!Q)return"completed_desc";const se=Q,ae=String(se.key??se.columnKey??se.id??""),xe=String(se.dir??se.direction??se.order??"").toLowerCase(),Te=xe==="asc"||xe==="1"||xe==="true";return ae==="completedAt"?Te?"completed_asc":"completed_desc":ae==="runtime"?Te?"duration_asc":"duration_desc":ae==="size"?Te?"size_asc":"size_desc":ae==="video"?Te?"file_asc":"file_desc":Te?"completed_asc":"completed_desc"},li=Q=>{tt(Q);const se=fi(Q);D(se),g!==1&&b(1)},ji=PS("(max-width: 639px)");A.useEffect(()=>{ji||(Dt.current=new Map)},[ji]);const hs=Ui.length===0&&Fi===0,Us=!hs&&Wt.length===0;return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"sticky top-[56px] z-20",children:y.jsxs("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:[y.jsxs("div",{className:"flex items-center gap-3 p-3",children:[y.jsxs("div",{className:"hidden sm:flex items-center gap-2 min-w-0",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),y.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:Kt})]}),y.jsxs("div",{className:"sm:hidden flex items-center gap-2 min-w-0 flex-1",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),y.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:Kt})]}),y.jsxs("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:[y.jsxs("div",{className:"hidden sm:flex items-center gap-2 min-w-0 flex-1",children:[y.jsx("input",{value:ze,onChange:Q=>We(Q.target.value),placeholder:"Suchen…",className:`
h-9 w-full max-w-[420px] rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900 shadow-sm
focus:outline-none focus:ring-2 focus:ring-indigo-500
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:[color-scheme:dark]
`}),(ze||"").trim()!==""?y.jsx(ti,{size:"sm",variant:"soft",onClick:nt,children:"Leeren"}):null]}),y.jsx("div",{className:"hidden sm:block",children:y.jsx(Go,{label:"Behaltene Downloads anzeigen",checked:ut,onChange:Q=>{g!==1&&b(1),Ht(Q),Ce()}})}),mt!=="table"&&y.jsxs("div",{className:"hidden sm:block",children:[y.jsx("label",{className:"sr-only",htmlFor:"finished-sort",children:"Sortierung"}),y.jsxs("select",{id:"finished-sort",value:S,onChange:Q=>{const se=Q.target.value;D(se),g!==1&&b(1)},className:`
h-9 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-900 shadow-sm
dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:[color-scheme:dark]
`,children:[y.jsx("option",{value:"completed_desc",children:"Fertiggestellt am ↓"}),y.jsx("option",{value:"completed_asc",children:"Fertiggestellt am ↑"}),y.jsx("option",{value:"model_asc",children:"Modelname A→Z"}),y.jsx("option",{value:"model_desc",children:"Modelname Z→A"}),y.jsx("option",{value:"file_asc",children:"Dateiname A→Z"}),y.jsx("option",{value:"file_desc",children:"Dateiname Z→A"}),y.jsx("option",{value:"duration_desc",children:"Dauer ↓"}),y.jsx("option",{value:"duration_asc",children:"Dauer ↑"}),y.jsx("option",{value:"size_desc",children:"Größe ↓"}),y.jsx("option",{value:"size_asc",children:"Größe ↑"})]})]}),y.jsx(oO,{value:mt,onChange:Q=>pt(Q),size:ji?"sm":"md",ariaLabel:"Ansicht",items:[{id:"table",icon:y.jsx(qO,{className:ji?"size-4":"size-5"}),label:ji?void 0:"Tabelle",srLabel:"Tabelle"},{id:"cards",icon:y.jsx(jO,{className:ji?"size-4":"size-5"}),label:ji?void 0:"Cards",srLabel:"Cards"},{id:"gallery",icon:y.jsx(VO,{className:ji?"size-4":"size-5"}),label:ji?void 0:"Galerie",srLabel:"Galerie"}]}),y.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
hover:bg-gray-50 dark:border-white/10 dark:bg-gray-900 dark:text-gray-100 dark:hover:bg-white/10`,onClick:()=>gt(Q=>!Q),"aria-expanded":at,"aria-controls":"finished-mobile-options","aria-label":"Filter & Optionen",children:[y.jsx(uO,{className:"size-5"}),Xe||ut?y.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]})]})]}),Nt.length>0?y.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:[y.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Tag-Filter"}),y.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Nt.map(Q=>y.jsx(Lr,{tag:Q,active:!0,onClick:vt},Q)),y.jsx(ti,{className:`
ml-1 inline-flex items-center rounded-md px-2 py-1 text-xs font-medium
text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-white/10
`,size:"sm",variant:"soft",onClick:Gt,children:"Zurücksetzen"})]})]}):null,y.jsxs("div",{id:"finished-mobile-options",className:["sm:hidden overflow-hidden transition-[max-height,opacity] duration-200 ease-in-out",at?"max-h-[720px] opacity-100":"max-h-0 opacity-0"].join(" "),children:[y.jsx("div",{className:"border-t border-gray-200/60 dark:border-white/10 p-3",children:y.jsxs("div",{className:"space-y-2",children:[y.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:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("input",{value:ze,onChange:Q=>We(Q.target.value),placeholder:"Suchen…",className:`
h-10 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-900
focus:outline-none focus:ring-2 focus:ring-indigo-500
dark:border-white/10 dark:bg-gray-950/60 dark:text-gray-100 dark:[color-scheme:dark]
`}),(ze||"").trim()!==""?y.jsx(ti,{size:"sm",variant:"soft",onClick:nt,children:"Clear"}):null]})}),y.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:y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Keep anzeigen"}),y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Behaltene Downloads in der Liste"})]}),y.jsx(Uv,{checked:ut,onChange:Q=>{g!==1&&b(1),Ht(Q),Ce()},ariaLabel:"Behaltene Downloads anzeigen",size:"default"})]})}),mt!=="table"?y.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:[y.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 mb-1",children:"Sortierung"}),y.jsxs("select",{id:"finished-sort-mobile",value:S,onChange:Q=>{const se=Q.target.value;D(se),g!==1&&b(1)},className:`
w-full h-10 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-900 shadow-sm
dark:border-white/10 dark:bg-gray-950/60 dark:text-gray-100 dark:[color-scheme:dark]
`,children:[y.jsx("option",{value:"completed_desc",children:"Fertiggestellt am ↓"}),y.jsx("option",{value:"completed_asc",children:"Fertiggestellt am ↑"}),y.jsx("option",{value:"model_asc",children:"Modelname A→Z"}),y.jsx("option",{value:"model_desc",children:"Modelname Z→A"}),y.jsx("option",{value:"file_asc",children:"Dateiname A→Z"}),y.jsx("option",{value:"file_desc",children:"Dateiname Z→A"}),y.jsx("option",{value:"duration_desc",children:"Dauer ↓"}),y.jsx("option",{value:"duration_asc",children:"Dauer ↑"}),y.jsx("option",{value:"size_desc",children:"Größe ↓"}),y.jsx("option",{value:"size_asc",children:"Größe ↑"})]})]}):null]})}),Nt.length>0?y.jsx("div",{className:"border-t border-gray-200/60 dark:border-white/10 px-3 py-2",children:y.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Tag-Filter"}),y.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Nt.map(Q=>y.jsx(Lr,{tag:Q,active:!0,onClick:vt},Q)),y.jsx(ti,{className:`
ml-1 inline-flex items-center rounded-md px-2 py-1 text-xs font-medium
text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-white/10
`,size:"sm",variant:"soft",onClick:Gt,children:"Zurücksetzen"})]})]})}):null]})]})}),hs?y.jsx(ha,{grayBody:!0,children:y.jsxs("div",{className:"flex items-center gap-3",children:[y.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:y.jsx("span",{className:"text-lg",children:"📁"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Keine abgeschlossenen Downloads"}),y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:"Im Zielordner ist aktuell nichts vorhanden."})]})]})}):Us?y.jsxs(ha,{grayBody:!0,children:[y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine Treffer für die aktuellen Filter."}),Nt.length>0||(ze||"").trim()!==""?y.jsxs("div",{className:"mt-2 flex flex-wrap gap-3",children:[Nt.length>0?y.jsx("button",{type:"button",className:"text-sm font-medium text-gray-700 hover:underline dark:text-gray-200",onClick:Gt,children:"Tag-Filter zurücksetzen"}):null,(ze||"").trim()!==""?y.jsx("button",{type:"button",className:"text-sm font-medium text-gray-700 hover:underline dark:text-gray-200",onClick:nt,children:"Suche zurücksetzen"}):null]}):null]}):y.jsxs(y.Fragment,{children:[mt==="cards"&&y.jsx(vM,{rows:jt,isSmall:ji,blurPreviews:t,durations:wt,teaserKey:P,teaserPlayback:L,teaserAudio:n,hoverTeaserKey:I,inlinePlay:Qe,setInlinePlay:Lt,deletingKeys:ie,keepingKeys:Ie,removingKeys:re,swipeRefs:Dt,keyFor:Rn,baseName:rn,modelNameFromOutput:Bo,runtimeOf:Ii,sizeBytesOf:lm,formatBytes:vy,lower:hn,onOpenPlayer:r,openPlayer:kt,startInline:gi,tryAutoplayInline:vi,registerTeaserHost:ds,handleDuration:as,deleteVideo:xi,keepVideo:Wi,releasePlayingFile:zt,modelsByKey:R,onToggleHot:Xi,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,activeTagSet:lt,onToggleTagFilter:vt,onHoverPreviewKeyChange:O,assetNonce:_??0}),mt==="table"&&y.jsx(xM,{rows:jt,columns:Fs,getRowKey:Q=>Rn(Q),sort:Be,onSortChange:li,onRowClick:r,rowClassName:Q=>{const se=Rn(Q);return["transition-all duration-300",(ie.has(se)||re.has(se))&&"bg-red-50/60 dark:bg-red-500/10 pointer-events-none",ie.has(se)&&"animate-pulse",(Ie.has(se)||re.has(se))&&"pointer-events-none",Ie.has(se)&&"bg-emerald-50/60 dark:bg-emerald-500/10 animate-pulse",re.has(se)&&"opacity-0"].filter(Boolean).join(" ")}}),mt==="gallery"&&y.jsx(bM,{rows:jt,blurPreviews:t,durations:wt,handleDuration:as,teaserKey:P,teaserPlayback:L,teaserAudio:n,hoverTeaserKey:I,keyFor:Rn,baseName:rn,modelNameFromOutput:Bo,runtimeOf:Ii,sizeBytesOf:lm,formatBytes:vy,deletingKeys:ie,keepingKeys:Ie,removingKeys:re,deletedKeys:q,registerTeaserHost:ds,onOpenPlayer:r,deleteVideo:xi,keepVideo:Wi,onToggleHot:Xi,lower:hn,modelsByKey:R,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,activeTagSet:lt,onToggleTagFilter:vt,onHoverPreviewKeyChange:O}),y.jsx(IA,{page:g,pageSize:v,totalItems:Kt,onPageChange:Q=>{yc.flushSync(()=>{Lt(null),z(null),O(null)});for(const se of jt){const ae=rn(se.output||"");ae&&(window.dispatchEvent(new CustomEvent("player:release",{detail:{file:ae}})),window.dispatchEvent(new CustomEvent("player:close",{detail:{file:ae}})))}window.scrollTo({top:0,behavior:"auto"}),b(Q)},showSummary:!1,prevLabel:"Zurück",nextLabel:"Weiter",className:"mt-4"})]})]})}var xy,FS;function $p(){if(FS)return xy;FS=1;var s;return typeof window<"u"?s=window:typeof qm<"u"?s=qm:typeof self<"u"?s=self:s={},xy=s,xy}var RM=$p();const he=Nc(RM),IM={},NM=Object.freeze(Object.defineProperty({__proto__:null,default:IM},Symbol.toStringTag,{value:"Module"})),OM=SI(NM);var by,US;function PA(){if(US)return by;US=1;var s=typeof qm<"u"?qm:typeof window<"u"?window:{},e=OM,t;return typeof document<"u"?t=document:(t=s["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=s["__GLOBAL_DOCUMENT_CACHE@4"]=e)),by=t,by}var MM=PA();const rt=Nc(MM);var um={exports:{}},Ty={exports:{}},jS;function PM(){return jS||(jS=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})(Ty)),Ty.exports}var _y,$S;function BM(){if($S)return _y;$S=1,_y=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 _y}var Sy,HS;function FM(){if(HS)return Sy;HS=1;function s(n,r){var o=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(o)return(o=o.call(n)).next.bind(o);if(Array.isArray(n)||(o=e(n))||r){o&&(n=o);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 o=Object.prototype.toString.call(n).slice(8,-1);if(o==="Object"&&n.constructor&&(o=n.constructor.name),o==="Map"||o==="Set")return Array.from(n);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return t(n,r)}}function t(n,r){(r==null||r>n.length)&&(r=n.length);for(var o=0,u=new Array(r);o<r;o++)u[o]=n[o];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),p;!(p=f()).done;){var g=p.value;try{c=g(c)}catch{}}return c},n})();return Sy=i,Sy}var Ey,VS;function UM(){if(VS)return Ey;VS=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 o=r===void 0?{}:r,u=o.maxAttempts,c=o.delayFactor,d=o.fuzzFactor,f=o.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(),o=this.getCurrentMaxPossibleDelay();return r+Math.random()*(o-r)},t})();return Ey=s,Ey}var wy,GS;function jM(){if(GS)return wy;GS=1;var s=$p(),e=function(n,r){return r===void 0&&(r=!1),function(o,u,c){if(o){n(o);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 o=r.split("="),u=o[0],c=o[1];return u.trim()==="charset"?c.trim():n},"utf-8")}return wy=e,wy}var zS;function $M(){if(zS)return um.exports;zS=1;var s=$p(),e=PM(),t=BM(),i=FM(),n=UM();d.httpHandler=jM(),d.requestInterceptorsStorage=new i,d.responseInterceptorsStorage=new i,d.retryManager=new n;var r=function(b){var _={};return b&&b.trim().split(`
`).forEach(function(S){var D=S.indexOf(":"),R=S.slice(0,D).trim().toLowerCase(),L=S.slice(D+1).trim();typeof _[R]>"u"?_[R]=L:Array.isArray(_[R])?_[R].push(L):_[R]=[_[R],L]}),_};um.exports=d,um.exports.default=d,d.XMLHttpRequest=s.XMLHttpRequest||g,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:s.XDomainRequest,o(["get","put","post","patch","head","delete"],function(v){d[v==="delete"?"del":v]=function(b,_,S){return _=c(b,_,S),_.method=v.toUpperCase(),f(_)}});function o(v,b){for(var _=0;_<v.length;_++)b(v[_])}function u(v){for(var b in v)if(v.hasOwnProperty(b))return!1;return!0}function c(v,b,_){var S=v;return t(b)?(_=b,typeof v=="string"&&(S={uri:v})):S=e({},b,{uri:v}),S.callback=_,S}function d(v,b,_){return b=c(v,b,_),f(b)}function f(v){if(typeof v.callback>"u")throw new Error("callback argument missing");if(v.requestType&&d.requestInterceptorsStorage.getIsEnabled()){var b={uri:v.uri||v.url,headers:v.headers||{},body:v.body,metadata:v.metadata||{},retry:v.retry,timeout:v.timeout},_=d.requestInterceptorsStorage.execute(v.requestType,b);v.uri=_.uri,v.headers=_.headers,v.body=_.body,v.metadata=_.metadata,v.retry=_.retry,v.timeout=_.timeout}var S=!1,D=function(J,oe,ce){S||(S=!0,v.callback(J,oe,ce))};function R(){V.readyState===4&&!d.responseInterceptorsStorage.getIsEnabled()&&setTimeout(j,0)}function L(){var G=void 0;if(V.response?G=V.response:G=V.responseText||p(V),ue)try{G=JSON.parse(G)}catch{}return G}function M(G){if(clearTimeout(ie),clearTimeout(v.retryTimeout),G instanceof Error||(G=new Error(""+(G||"Unknown XMLHttpRequest Error"))),G.statusCode=0,!z&&d.retryManager.getIsEnabled()&&v.retry&&v.retry.shouldRetry()){v.retryTimeout=setTimeout(function(){v.retry.moveToNextAttempt(),v.xhr=V,f(v)},v.retry.getCurrentFuzzedDelay());return}if(v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var J={headers:Y.headers||{},body:Y.body,responseUrl:V.responseURL,responseType:V.responseType},oe=d.responseInterceptorsStorage.execute(v.requestType,J);Y.body=oe.body,Y.headers=oe.headers}return D(G,Y)}function j(){if(!z){var G;clearTimeout(ie),clearTimeout(v.retryTimeout),v.useXDR&&V.status===void 0?G=200:G=V.status===1223?204:V.status;var J=Y,oe=null;if(G!==0?(J={body:L(),statusCode:G,method:O,headers:{},url:I,rawRequest:V},V.getAllResponseHeaders&&(J.headers=r(V.getAllResponseHeaders()))):oe=new Error("Internal XMLHttpRequest Error"),v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var ce={headers:J.headers||{},body:J.body,responseUrl:V.responseURL,responseType:V.responseType},F=d.responseInterceptorsStorage.execute(v.requestType,ce);J.body=F.body,J.headers=F.headers}return D(oe,J,J.body)}}var V=v.xhr||null;V||(v.cors||v.useXDR?V=new d.XDomainRequest:V=new d.XMLHttpRequest);var P,z,I=V.url=v.uri||v.url,O=V.method=v.method||"GET",W=v.body||v.data,X=V.headers=v.headers||{},q=!!v.sync,ue=!1,ie,Y={body:void 0,headers:{},statusCode:0,method:O,url:I,rawRequest:V};if("json"in v&&v.json!==!1&&(ue=!0,X.accept||X.Accept||(X.Accept="application/json"),O!=="GET"&&O!=="HEAD"&&(X["content-type"]||X["Content-Type"]||(X["Content-Type"]="application/json"),W=JSON.stringify(v.json===!0?W:v.json))),V.onreadystatechange=R,V.onload=j,V.onerror=M,V.onprogress=function(){},V.onabort=function(){z=!0,clearTimeout(v.retryTimeout)},V.ontimeout=M,V.open(O,I,!q,v.username,v.password),q||(V.withCredentials=!!v.withCredentials),!q&&v.timeout>0&&(ie=setTimeout(function(){if(!z){z=!0,V.abort("timeout");var G=new Error("XMLHttpRequest timeout");G.code="ETIMEDOUT",M(G)}},v.timeout)),V.setRequestHeader)for(P in X)X.hasOwnProperty(P)&&V.setRequestHeader(P,X[P]);else if(v.headers&&!u(v.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in v&&(V.responseType=v.responseType),"beforeSend"in v&&typeof v.beforeSend=="function"&&v.beforeSend(V),V.send(W||null),V}function p(v){try{if(v.responseType==="document")return v.responseXML;var b=v.responseXML&&v.responseXML.documentElement.nodeName==="parsererror";if(v.responseType===""&&!b)return v.responseXML}catch{}return null}function g(){}return um.exports}var HM=$M();const BA=Nc(HM);var Ay={exports:{}},Cy,qS;function VM(){if(qS)return Cy;qS=1;var s=PA(),e=Object.create||(function(){function I(){}return function(O){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return I.prototype=O,new I}})();function t(I,O){this.name="ParsingError",this.code=I.code,this.message=O||I.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(I){function O(X,q,ue,ie){return(X|0)*3600+(q|0)*60+(ue|0)+(ie|0)/1e3}var W=I.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return W?W[3]?O(W[1],W[2],W[3].replace(":",""),W[4]):W[1]>59?O(W[1],W[2],0,W[4]):O(0,W[1],W[2],W[4]):null}function n(){this.values=e(null)}n.prototype={set:function(I,O){!this.get(I)&&O!==""&&(this.values[I]=O)},get:function(I,O,W){return W?this.has(I)?this.values[I]:O[W]:this.has(I)?this.values[I]:O},has:function(I){return I in this.values},alt:function(I,O,W){for(var X=0;X<W.length;++X)if(O===W[X]){this.set(I,O);break}},integer:function(I,O){/^-?\d+$/.test(O)&&this.set(I,parseInt(O,10))},percent:function(I,O){return O.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(O=parseFloat(O),O>=0&&O<=100)?(this.set(I,O),!0):!1}};function r(I,O,W,X){var q=X?I.split(X):[I];for(var ue in q)if(typeof q[ue]=="string"){var ie=q[ue].split(W);if(ie.length===2){var Y=ie[0].trim(),G=ie[1].trim();O(Y,G)}}}function o(I,O,W){var X=I;function q(){var Y=i(I);if(Y===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+X);return I=I.replace(/^[^\sa-zA-Z-]+/,""),Y}function ue(Y,G){var J=new n;r(Y,function(oe,ce){switch(oe){case"region":for(var F=W.length-1;F>=0;F--)if(W[F].id===ce){J.set(oe,W[F].region);break}break;case"vertical":J.alt(oe,ce,["rl","lr"]);break;case"line":var ee=ce.split(","),pe=ee[0];J.integer(oe,pe),J.percent(oe,pe)&&J.set("snapToLines",!1),J.alt(oe,pe,["auto"]),ee.length===2&&J.alt("lineAlign",ee[1],["start","center","end"]);break;case"position":ee=ce.split(","),J.percent(oe,ee[0]),ee.length===2&&J.alt("positionAlign",ee[1],["start","center","end"]);break;case"size":J.percent(oe,ce);break;case"align":J.alt(oe,ce,["start","center","end","left","right"]);break}},/:/,/\s/),G.region=J.get("region",null),G.vertical=J.get("vertical","");try{G.line=J.get("line","auto")}catch{}G.lineAlign=J.get("lineAlign","start"),G.snapToLines=J.get("snapToLines",!0),G.size=J.get("size",100);try{G.align=J.get("align","center")}catch{G.align=J.get("align","middle")}try{G.position=J.get("position","auto")}catch{G.position=J.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},G.align)}G.positionAlign=J.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},G.align)}function ie(){I=I.replace(/^\s+/,"")}if(ie(),O.startTime=q(),ie(),I.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+X);I=I.substr(3),ie(),O.endTime=q(),ie(),ue(I,O)}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"},p={rt:"ruby"};function g(I,O){function W(){if(!O)return null;function pe(ve){return O=O.substr(ve.length),ve}var _e=O.match(/^([^<]*)(<[^>]*>?)?/);return pe(_e[1]?_e[1]:_e[2])}function X(pe){return u.innerHTML=pe,pe=u.textContent,u.textContent="",pe}function q(pe,_e){return!p[_e.localName]||p[_e.localName]===pe.localName}function ue(pe,_e){var ve=c[pe];if(!ve)return null;var Ce=I.document.createElement(ve),Be=f[pe];return Be&&_e&&(Ce[Be]=_e.trim()),Ce}for(var ie=I.document.createElement("div"),Y=ie,G,J=[];(G=W())!==null;){if(G[0]==="<"){if(G[1]==="/"){J.length&&J[J.length-1]===G.substr(2).replace(">","")&&(J.pop(),Y=Y.parentNode);continue}var oe=i(G.substr(1,G.length-2)),ce;if(oe){ce=I.document.createProcessingInstruction("timestamp",oe),Y.appendChild(ce);continue}var F=G.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!F||(ce=ue(F[1],F[3]),!ce)||!q(Y,ce))continue;if(F[2]){var ee=F[2].split(".");ee.forEach(function(pe){var _e=/^bg_/.test(pe),ve=_e?pe.slice(3):pe;if(d.hasOwnProperty(ve)){var Ce=_e?"background-color":"color",Be=d[ve];ce.style[Ce]=Be}}),ce.className=ee.join(" ")}J.push(F[1]),Y.appendChild(ce),Y=ce;continue}Y.appendChild(I.document.createTextNode(X(G)))}return ie}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 b(I){for(var O=0;O<v.length;O++){var W=v[O];if(I>=W[0]&&I<=W[1])return!0}return!1}function _(I){var O=[],W="",X;if(!I||!I.childNodes)return"ltr";function q(Y,G){for(var J=G.childNodes.length-1;J>=0;J--)Y.push(G.childNodes[J])}function ue(Y){if(!Y||!Y.length)return null;var G=Y.pop(),J=G.textContent||G.innerText;if(J){var oe=J.match(/^.*(\n|\r)/);return oe?(Y.length=0,oe[0]):J}if(G.tagName==="ruby")return ue(Y);if(G.childNodes)return q(Y,G),ue(Y)}for(q(O,I);W=ue(O);)for(var ie=0;ie<W.length;ie++)if(X=W.charCodeAt(ie),b(X))return"rtl";return"ltr"}function S(I){if(typeof I.line=="number"&&(I.snapToLines||I.line>=0&&I.line<=100))return I.line;if(!I.track||!I.track.textTrackList||!I.track.textTrackList.mediaElement)return-1;for(var O=I.track,W=O.textTrackList,X=0,q=0;q<W.length&&W[q]!==O;q++)W[q].mode==="showing"&&X++;return++X*-1}function D(){}D.prototype.applyStyles=function(I,O){O=O||this.div;for(var W in I)I.hasOwnProperty(W)&&(O.style[W]=I[W])},D.prototype.formatStyle=function(I,O){return I===0?0:I+O};function R(I,O,W){D.call(this),this.cue=O,this.cueDiv=g(I,O.text);var X={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:O.vertical===""?"horizontal-tb":O.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(X,this.cueDiv),this.div=I.document.createElement("div"),X={direction:_(this.cueDiv),writingMode:O.vertical===""?"horizontal-tb":O.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:O.align==="middle"?"center":O.align,font:W.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(X),this.div.appendChild(this.cueDiv);var q=0;switch(O.positionAlign){case"start":case"line-left":q=O.position;break;case"center":q=O.position-O.size/2;break;case"end":case"line-right":q=O.position-O.size;break}O.vertical===""?this.applyStyles({left:this.formatStyle(q,"%"),width:this.formatStyle(O.size,"%")}):this.applyStyles({top:this.formatStyle(q,"%"),height:this.formatStyle(O.size,"%")}),this.move=function(ue){this.applyStyles({top:this.formatStyle(ue.top,"px"),bottom:this.formatStyle(ue.bottom,"px"),left:this.formatStyle(ue.left,"px"),right:this.formatStyle(ue.right,"px"),height:this.formatStyle(ue.height,"px"),width:this.formatStyle(ue.width,"px")})}}R.prototype=e(D.prototype),R.prototype.constructor=R;function L(I){var O,W,X,q;if(I.div){W=I.div.offsetHeight,X=I.div.offsetWidth,q=I.div.offsetTop;var ue=(ue=I.div.childNodes)&&(ue=ue[0])&&ue.getClientRects&&ue.getClientRects();I=I.div.getBoundingClientRect(),O=ue?Math.max(ue[0]&&ue[0].height||0,I.height/ue.length):0}this.left=I.left,this.right=I.right,this.top=I.top||q,this.height=I.height||W,this.bottom=I.bottom||q+(I.height||W),this.width=I.width||X,this.lineHeight=O!==void 0?O:I.lineHeight}L.prototype.move=function(I,O){switch(O=O!==void 0?O:this.lineHeight,I){case"+x":this.left+=O,this.right+=O;break;case"-x":this.left-=O,this.right-=O;break;case"+y":this.top+=O,this.bottom+=O;break;case"-y":this.top-=O,this.bottom-=O;break}},L.prototype.overlaps=function(I){return this.left<I.right&&this.right>I.left&&this.top<I.bottom&&this.bottom>I.top},L.prototype.overlapsAny=function(I){for(var O=0;O<I.length;O++)if(this.overlaps(I[O]))return!0;return!1},L.prototype.within=function(I){return this.top>=I.top&&this.bottom<=I.bottom&&this.left>=I.left&&this.right<=I.right},L.prototype.overlapsOppositeAxis=function(I,O){switch(O){case"+x":return this.left<I.left;case"-x":return this.right>I.right;case"+y":return this.top<I.top;case"-y":return this.bottom>I.bottom}},L.prototype.intersectPercentage=function(I){var O=Math.max(0,Math.min(this.right,I.right)-Math.max(this.left,I.left)),W=Math.max(0,Math.min(this.bottom,I.bottom)-Math.max(this.top,I.top)),X=O*W;return X/(this.height*this.width)},L.prototype.toCSSCompatValues=function(I){return{top:this.top-I.top,bottom:I.bottom-this.bottom,left:this.left-I.left,right:I.right-this.right,height:this.height,width:this.width}},L.getSimpleBoxPosition=function(I){var O=I.div?I.div.offsetHeight:I.tagName?I.offsetHeight:0,W=I.div?I.div.offsetWidth:I.tagName?I.offsetWidth:0,X=I.div?I.div.offsetTop:I.tagName?I.offsetTop:0;I=I.div?I.div.getBoundingClientRect():I.tagName?I.getBoundingClientRect():I;var q={left:I.left,right:I.right,top:I.top||X,height:I.height||O,bottom:I.bottom||X+(I.height||O),width:I.width||W};return q};function M(I,O,W,X){function q(ve,Ce){for(var Be,tt=new L(ve),Je=1,Ct=0;Ct<Ce.length;Ct++){for(;ve.overlapsOppositeAxis(W,Ce[Ct])||ve.within(W)&&ve.overlapsAny(X);)ve.move(Ce[Ct]);if(ve.within(W))return ve;var st=ve.intersectPercentage(W);Je>st&&(Be=new L(ve),Je=st),ve=new L(tt)}return Be||tt}var ue=new L(O),ie=O.cue,Y=S(ie),G=[];if(ie.snapToLines){var J;switch(ie.vertical){case"":G=["+y","-y"],J="height";break;case"rl":G=["+x","-x"],J="width";break;case"lr":G=["-x","+x"],J="width";break}var oe=ue.lineHeight,ce=oe*Math.round(Y),F=W[J]+oe,ee=G[0];Math.abs(ce)>F&&(ce=ce<0?-1:1,ce*=Math.ceil(F/oe)*oe),Y<0&&(ce+=ie.vertical===""?W.height:W.width,G=G.reverse()),ue.move(ee,ce)}else{var pe=ue.lineHeight/W.height*100;switch(ie.lineAlign){case"center":Y-=pe/2;break;case"end":Y-=pe;break}switch(ie.vertical){case"":O.applyStyles({top:O.formatStyle(Y,"%")});break;case"rl":O.applyStyles({left:O.formatStyle(Y,"%")});break;case"lr":O.applyStyles({right:O.formatStyle(Y,"%")});break}G=["+y","-x","+x","-y"],ue=new L(O)}var _e=q(ue,G);O.move(_e.toCSSCompatValues(W))}function j(){}j.StringDecoder=function(){return{decode:function(I){if(!I)return"";if(typeof I!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(I))}}},j.convertCueToDOMTree=function(I,O){return!I||!O?null:g(I,O)};var V=.05,P="sans-serif",z="1.5%";return j.processCues=function(I,O,W){if(!I||!O||!W)return null;for(;W.firstChild;)W.removeChild(W.firstChild);var X=I.document.createElement("div");X.style.position="absolute",X.style.left="0",X.style.right="0",X.style.top="0",X.style.bottom="0",X.style.margin=z,W.appendChild(X);function q(oe){for(var ce=0;ce<oe.length;ce++)if(oe[ce].hasBeenReset||!oe[ce].displayState)return!0;return!1}if(!q(O)){for(var ue=0;ue<O.length;ue++)X.appendChild(O[ue].displayState);return}var ie=[],Y=L.getSimpleBoxPosition(X),G=Math.round(Y.height*V*100)/100,J={font:G+"px "+P};(function(){for(var oe,ce,F=0;F<O.length;F++)ce=O[F],oe=new R(I,ce,J),X.appendChild(oe.div),M(I,oe,Y,ie),ce.displayState=oe.div,ie.push(L.getSimpleBoxPosition(oe))})()},j.Parser=function(I,O,W){W||(W=O,O={}),O||(O={}),this.window=I,this.vttjs=O,this.state="INITIAL",this.buffer="",this.decoder=W||new TextDecoder("utf8"),this.regionList=[]},j.Parser.prototype={reportOrThrowError:function(I){if(I instanceof t)this.onparsingerror&&this.onparsingerror(I);else throw I},parse:function(I){var O=this;I&&(O.buffer+=O.decoder.decode(I,{stream:!0}));function W(){for(var oe=O.buffer,ce=0;ce<oe.length&&oe[ce]!=="\r"&&oe[ce]!==`
`;)++ce;var F=oe.substr(0,ce);return oe[ce]==="\r"&&++ce,oe[ce]===`
`&&++ce,O.buffer=oe.substr(ce),F}function X(oe){var ce=new n;if(r(oe,function(ee,pe){switch(ee){case"id":ce.set(ee,pe);break;case"width":ce.percent(ee,pe);break;case"lines":ce.integer(ee,pe);break;case"regionanchor":case"viewportanchor":var _e=pe.split(",");if(_e.length!==2)break;var ve=new n;if(ve.percent("x",_e[0]),ve.percent("y",_e[1]),!ve.has("x")||!ve.has("y"))break;ce.set(ee+"X",ve.get("x")),ce.set(ee+"Y",ve.get("y"));break;case"scroll":ce.alt(ee,pe,["up"]);break}},/=/,/\s/),ce.has("id")){var F=new(O.vttjs.VTTRegion||O.window.VTTRegion);F.width=ce.get("width",100),F.lines=ce.get("lines",3),F.regionAnchorX=ce.get("regionanchorX",0),F.regionAnchorY=ce.get("regionanchorY",100),F.viewportAnchorX=ce.get("viewportanchorX",0),F.viewportAnchorY=ce.get("viewportanchorY",100),F.scroll=ce.get("scroll",""),O.onregion&&O.onregion(F),O.regionList.push({id:ce.get("id"),region:F})}}function q(oe){var ce=new n;r(oe,function(F,ee){switch(F){case"MPEGT":ce.integer(F+"S",ee);break;case"LOCA":ce.set(F+"L",i(ee));break}},/[^\d]:/,/,/),O.ontimestampmap&&O.ontimestampmap({MPEGTS:ce.get("MPEGTS"),LOCAL:ce.get("LOCAL")})}function ue(oe){oe.match(/X-TIMESTAMP-MAP/)?r(oe,function(ce,F){ce==="X-TIMESTAMP-MAP"&&q(F)},/=/):r(oe,function(ce,F){ce==="Region"&&X(F)},/:/)}try{var ie;if(O.state==="INITIAL"){if(!/\r\n|\n/.test(O.buffer))return this;ie=W();var Y=ie.match(/^WEBVTT([ \t].*)?$/);if(!Y||!Y[0])throw new t(t.Errors.BadSignature);O.state="HEADER"}for(var G=!1;O.buffer;){if(!/\r\n|\n/.test(O.buffer))return this;switch(G?G=!1:ie=W(),O.state){case"HEADER":/:/.test(ie)?ue(ie):ie||(O.state="ID");continue;case"NOTE":ie||(O.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(ie)){O.state="NOTE";break}if(!ie)continue;O.cue=new(O.vttjs.VTTCue||O.window.VTTCue)(0,0,"");try{O.cue.align="center"}catch{O.cue.align="middle"}if(O.state="CUE",ie.indexOf("-->")===-1){O.cue.id=ie;continue}case"CUE":try{o(ie,O.cue,O.regionList)}catch(oe){O.reportOrThrowError(oe),O.cue=null,O.state="BADCUE";continue}O.state="CUETEXT";continue;case"CUETEXT":var J=ie.indexOf("-->")!==-1;if(!ie||J&&(G=!0)){O.oncue&&O.oncue(O.cue),O.cue=null,O.state="ID";continue}O.cue.text&&(O.cue.text+=`
`),O.cue.text+=ie.replace(/\u2028/g,`
`).replace(/u2029/g,`
`);continue;case"BADCUE":ie||(O.state="ID");continue}}}catch(oe){O.reportOrThrowError(oe),O.state==="CUETEXT"&&O.cue&&O.oncue&&O.oncue(O.cue),O.cue=null,O.state=O.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var I=this;try{if(I.buffer+=I.decoder.decode(),(I.cue||I.state==="HEADER")&&(I.buffer+=`
`,I.parse()),I.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(O){I.reportOrThrowError(O)}return I.onflush&&I.onflush(),this}},Cy=j,Cy}var ky,KS;function GM(){if(KS)return ky;KS=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(o){if(typeof o!="string")return!1;var u=e[o.toLowerCase()];return u?o.toLowerCase():!1}function n(o){if(typeof o!="string")return!1;var u=t[o.toLowerCase()];return u?o.toLowerCase():!1}function r(o,u,c){this.hasBeenReset=!1;var d="",f=!1,p=o,g=u,v=c,b=null,_="",S=!0,D="auto",R="start",L="auto",M="auto",j=100,V="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return d},set:function(P){d=""+P}},pauseOnExit:{enumerable:!0,get:function(){return f},set:function(P){f=!!P}},startTime:{enumerable:!0,get:function(){return p},set:function(P){if(typeof P!="number")throw new TypeError("Start time must be set to a number.");p=P,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return g},set:function(P){if(typeof P!="number")throw new TypeError("End time must be set to a number.");g=P,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return v},set:function(P){v=""+P,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return b},set:function(P){b=P,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return _},set:function(P){var z=i(P);if(z===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");_=z,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return S},set:function(P){S=!!P,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return D},set:function(P){if(typeof P!="number"&&P!==s)throw new SyntaxError("Line: an invalid number or illegal string was specified.");D=P,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return R},set:function(P){var z=n(P);z?(R=z,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return L},set:function(P){if(P<0||P>100)throw new Error("Position must be between 0 and 100.");L=P,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return M},set:function(P){var z=n(P);z?(M=z,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return j},set:function(P){if(P<0||P>100)throw new Error("Size must be between 0 and 100.");j=P,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return V},set:function(P){var z=n(P);if(!z)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");V=z,this.hasBeenReset=!0}}}),this.displayState=void 0}return r.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},ky=r,ky}var Dy,YS;function zM(){if(YS)return Dy;YS=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,o=0,u=100,c=0,d=100,f="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return n},set:function(p){if(!t(p))throw new Error("Width must be between 0 and 100.");n=p}},lines:{enumerable:!0,get:function(){return r},set:function(p){if(typeof p!="number")throw new TypeError("Lines must be set to a number.");r=p}},regionAnchorY:{enumerable:!0,get:function(){return u},set:function(p){if(!t(p))throw new Error("RegionAnchorX must be between 0 and 100.");u=p}},regionAnchorX:{enumerable:!0,get:function(){return o},set:function(p){if(!t(p))throw new Error("RegionAnchorY must be between 0 and 100.");o=p}},viewportAnchorY:{enumerable:!0,get:function(){return d},set:function(p){if(!t(p))throw new Error("ViewportAnchorY must be between 0 and 100.");d=p}},viewportAnchorX:{enumerable:!0,get:function(){return c},set:function(p){if(!t(p))throw new Error("ViewportAnchorX must be between 0 and 100.");c=p}},scroll:{enumerable:!0,get:function(){return f},set:function(p){var g=e(p);g===!1?console.warn("Scroll: an invalid or illegal string was specified."):f=g}}})}return Dy=i,Dy}var WS;function qM(){if(WS)return Ay.exports;WS=1;var s=$p(),e=Ay.exports={WebVTT:VM(),VTTCue:GM(),VTTRegion:zM()};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(),Ay.exports}var KM=qM();const XS=Nc(KM);function Ss(){return Ss=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},Ss.apply(null,arguments)}var QS="https://example.com",Hp=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=he.location&&he.location.href||"");var i=/^\/\//.test(e),n=!he.location&&!/\/\//i.test(e);e=new he.URL(e,he.location||QS);var r=new URL(t,e);return n?r.href.slice(QS.length):i?r.href.slice(r.protocol.length):r.href},Yx=(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,o=0;o<r;++o)n[o].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})(),YM=function(e){return he.atob?he.atob(e):Buffer.from(e,"base64").toString("binary")};function FA(s){for(var e=YM(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}class WM extends Yx{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 XM=" ",Ly=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},QM=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},fn=function(s){const e={};if(!s)return e;const t=s.split(QM());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},ZS=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 ZM extends Yx{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,o)=>{const u=o(e);return u===e?r:r.concat([u])},[e]).forEach(r=>{for(let o=0;o<this.customParsers.length;o++)if(this.customParsers[o].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=Ss(Ly(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 o=fn(t[1]);o.URI&&(i.uri=o.URI),o.BYTERANGE&&(i.byterange=Ly(o.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=fn(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=ZS(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=fn(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=fn(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=fn(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=fn(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(XM)),this.trigger("data",i);return}if(t=/^#EXT-X-PART:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part"},i.attributes=fn(t[1]),["DURATION"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),["INDEPENDENT","GAP"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=/YES/.test(i.attributes[o]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=Ly(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=fn(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=/YES/.test(i.attributes[o]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part-inf"},i.attributes=fn(t[1]),["PART-TARGET"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"preload-hint"},i.attributes=fn(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(o){if(i.attributes.hasOwnProperty(o)){i.attributes[o]=parseInt(i.attributes[o],10);const u=o==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[u]=i.attributes[o],delete i.attributes[o]}}),this.trigger("data",i);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"rendition-report"},i.attributes=fn(t[1]),["LAST-MSN","LAST-PART"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseInt(i.attributes[o],10))}),this.trigger("data",i);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=fn(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 o=/^X-([A-Z]+-)+[A-Z]+$/;for(const u in i.attributes){if(!o.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=fn(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=fn(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=ZS(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=fn(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 JM=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),Fo=function(s){const e={};return Object.keys(s).forEach(function(t){e[JM(t)]=s[t]}),e},Ry=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const n="#EXT-X-SERVER-CONTROL",r="holdBack",o="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(o)&&(e[o]=i*3,this.trigger("info",{message:`${n} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[o]}).`})),i&&e[o]<c&&(this.trigger("warn",{message:`${n} clamping PART-HOLD-BACK (${e[o]}) to partTargetDuration * 2 (${c}).`}),e[o]=c)};class eP extends Yx{constructor(e={}){super(),this.lineStream=new WM,this.parseStream=new ZM,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,o,u=!1;const c=function(){},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let p=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let g=0,v=0;const b={};this.on("end",()=>{n.uri||!n.parts&&!n.preloadHints||(!n.map&&r&&(n.map=r),!n.key&&o&&(n.key=o),!n.timeline&&typeof p=="number"&&(n.timeline=p),this.manifest.preloadSegment=n)}),this.parseStream.on("data",function(_){let S,D;if(t.manifest.definitions){for(const R in t.manifest.definitions)if(_.uri&&(_.uri=_.uri.replace(`{$${R}}`,t.manifest.definitions[R])),_.attributes)for(const L in _.attributes)typeof _.attributes[L]=="string"&&(_.attributes[L]=_.attributes[L].replace(`{$${R}}`,t.manifest.definitions[R]))}({tag(){({version(){_.version&&(this.manifest.version=_.version)},"allow-cache"(){this.manifest.allowCache=_.allowed,"allowed"in _||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const R={};"length"in _&&(n.byterange=R,R.length=_.length,"offset"in _||(_.offset=g)),"offset"in _&&(n.byterange=R,R.offset=_.offset),g=R.offset+R.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"})),_.title&&(n.title=_.title),_.duration>0&&(n.duration=_.duration),_.duration===0&&(n.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!_.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(_.attributes.METHOD==="NONE"){o=null;return}if(!_.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(_.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:_.attributes};return}if(_.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:_.attributes.URI};return}if(_.attributes.KEYFORMAT===f){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(_.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(_.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),_.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(_.attributes.KEYID&&_.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:_.attributes.KEYFORMAT,keyId:_.attributes.KEYID.substring(2)},pssh:FA(_.attributes.URI.split(",")[1])};return}_.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),o={method:_.attributes.METHOD||"AES-128",uri:_.attributes.URI},typeof _.attributes.IV<"u"&&(o.iv=_.attributes.IV)},"media-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+_.number});return}this.manifest.mediaSequence=_.number},"discontinuity-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+_.number});return}this.manifest.discontinuitySequence=_.number,p=_.number},"playlist-type"(){if(!/VOD|EVENT/.test(_.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+_.playlist});return}this.manifest.playlistType=_.playlistType},map(){r={},_.uri&&(r.uri=_.uri),_.byterange&&(r.byterange=_.byterange),o&&(r.key=o)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||d,!_.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}n.attributes||(n.attributes={}),Ss(n.attributes,_.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,!(_.attributes&&_.attributes.TYPE&&_.attributes["GROUP-ID"]&&_.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const R=this.manifest.mediaGroups[_.attributes.TYPE];R[_.attributes["GROUP-ID"]]=R[_.attributes["GROUP-ID"]]||{},S=R[_.attributes["GROUP-ID"]],D={default:/yes/i.test(_.attributes.DEFAULT)},D.default?D.autoselect=!0:D.autoselect=/yes/i.test(_.attributes.AUTOSELECT),_.attributes.LANGUAGE&&(D.language=_.attributes.LANGUAGE),_.attributes.URI&&(D.uri=_.attributes.URI),_.attributes["INSTREAM-ID"]&&(D.instreamId=_.attributes["INSTREAM-ID"]),_.attributes.CHARACTERISTICS&&(D.characteristics=_.attributes.CHARACTERISTICS),_.attributes.FORCED&&(D.forced=/yes/i.test(_.attributes.FORCED)),S[_.attributes.NAME]=D},discontinuity(){p+=1,n.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=_.dateTimeString,this.manifest.dateTimeObject=_.dateTimeObject),n.dateTimeString=_.dateTimeString,n.dateTimeObject=_.dateTimeObject;const{lastProgramDateTime:R}=this;this.lastProgramDateTime=new Date(_.dateTimeString).getTime(),R===null&&this.manifest.segments.reduceRight((L,M)=>(M.programDateTime=L-M.duration*1e3,M.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(_.duration)||_.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+_.duration});return}this.manifest.targetDuration=_.duration,Ry.call(this,this.manifest)},start(){if(!_.attributes||isNaN(_.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:_.attributes["TIME-OFFSET"],precise:_.attributes.PRECISE}},"cue-out"(){n.cueOut=_.data},"cue-out-cont"(){n.cueOutCont=_.data},"cue-in"(){n.cueIn=_.data},skip(){this.manifest.skip=Fo(_.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",_.attributes,["SKIPPED-SEGMENTS"])},part(){u=!0;const R=this.manifest.segments.length,L=Fo(_.attributes);n.parts=n.parts||[],n.parts.push(L),L.byterange&&(L.byterange.hasOwnProperty("offset")||(L.byterange.offset=v),v=L.byterange.offset+L.byterange.length);const M=n.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${M} for segment #${R}`,_.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((j,V)=>{j.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${V} lacks required attribute(s): LAST-PART`})})},"server-control"(){const R=this.manifest.serverControl=Fo(_.attributes);R.hasOwnProperty("canBlockReload")||(R.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),Ry.call(this,this.manifest),R.canSkipDateranges&&!R.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 R=this.manifest.segments.length,L=Fo(_.attributes),M=L.type&&L.type==="PART";n.preloadHints=n.preloadHints||[],n.preloadHints.push(L),L.byterange&&(L.byterange.hasOwnProperty("offset")||(L.byterange.offset=M?v:0,M&&(v=L.byterange.offset+L.byterange.length)));const j=n.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${j} for segment #${R}`,_.attributes,["TYPE","URI"]),!!L.type)for(let V=0;V<n.preloadHints.length-1;V++){const P=n.preloadHints[V];P.type&&P.type===L.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${j} for segment #${R} has the same TYPE ${L.type} as preload hint #${V}`})}},"rendition-report"(){const R=Fo(_.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(R);const L=this.manifest.renditionReports.length-1,M=["LAST-MSN","URI"];u&&M.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${L}`,_.attributes,M)},"part-inf"(){this.manifest.partInf=Fo(_.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",_.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),Ry.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(Fo(_.attributes));const R=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${R}`,_.attributes,["ID","START-DATE"]);const L=this.manifest.dateRanges[R];L.endDate&&L.startDate&&new Date(L.endDate)<new Date(L.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),L.duration&&L.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),L.plannedDuration&&L.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const M=!!L.endOnNext;if(M&&!L.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),M&&(L.duration||L.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),L.duration&&L.endDate){const V=L.startDate.getTime()+L.duration*1e3;this.manifest.dateRanges[R].endDate=new Date(V)}if(!b[L.id])b[L.id]=L;else{for(const V in b[L.id])if(L[V]&&JSON.stringify(b[L.id][V])!==JSON.stringify(L[V])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const j=this.manifest.dateRanges.findIndex(V=>V.id===L.id);this.manifest.dateRanges[j]=Ss(this.manifest.dateRanges[j],L),b[L.id]=Ss(b[L.id],L),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=Fo(_.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",_.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const R=(L,M)=>{if(L in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${L}`});return}this.manifest.definitions[L]=M};if("QUERYPARAM"in _.attributes){if("NAME"in _.attributes||"IMPORT"in _.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const L=this.params.get(_.attributes.QUERYPARAM);if(!L){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${_.attributes.QUERYPARAM}`});return}R(_.attributes.QUERYPARAM,decodeURIComponent(L));return}if("NAME"in _.attributes){if("IMPORT"in _.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in _.attributes)||typeof _.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${_.attributes.NAME}`});return}R(_.attributes.NAME,_.attributes.VALUE);return}if("IMPORT"in _.attributes){if(!this.mainDefinitions[_.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${_.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}R(_.attributes.IMPORT,this.mainDefinitions[_.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:_.attributes,uri:_.uri,timeline:p}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",_.attributes,["BANDWIDTH","URI"])}}[_.tagType]||c).call(t)},uri(){n.uri=_.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),o&&(n.key=o),n.timeline=p,r&&(n.map=r),v=0,this.lastProgramDateTime!==null&&(n.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=n.duration*1e3),n={}},comment(){},custom(){_.segment?(n.custom=n.custom||{},n.custom[_.customType]=_.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[_.customType]=_.data)}})[_.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 ql={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^/},tP=["video","audio","text"],JS=["Video","Audio","Text"],UA=function(e){return e&&e.replace(/avc1\.(\d+)\.(\d+)/i,function(t,i,n){var r=("00"+Number(i).toString(16)).slice(-2),o=("00"+Number(n).toString(16)).slice(-2);return"avc1."+r+"00"+o})},ea=function(e){e===void 0&&(e="");var t=e.split(","),i=[];return t.forEach(function(n){n=n.trim();var r;tP.forEach(function(o){var u=ql[o].exec(n.toLowerCase());if(!(!u||u.length<=1)){r=o;var c=n.substring(0,u[1].length),d=n.replace(c,"");i.push({type:c,details:d,mediaType:o})}}),r||i.push({type:n,details:"",mediaType:"unknown"})}),i},iP=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 ea(r.playlists[0].attributes.CODECS)}return null},jA=function(e){return e===void 0&&(e=""),ql.audio.test(e.trim().toLowerCase())},sP=function(e){return e===void 0&&(e=""),ql.text.test(e.trim().toLowerCase())},Tc=function(e){if(!(!e||typeof e!="string")){var t=e.toLowerCase().split(",").map(function(r){return UA(r.trim())}),i="video";t.length===1&&jA(t[0])?i="audio":t.length===1&&sP(t[0])&&(i="application");var n="mp4";return t.every(function(r){return ql.mp4.test(r)})?n="mp4":t.every(function(r){return ql.webm.test(r)})?n="webm":t.every(function(r){return ql.ogg.test(r)})&&(n="ogg"),i+"/"+n+';codecs="'+e+'"'}},rh=function(e,t){return e===void 0&&(e=""),t===void 0&&(t=!1),he.MediaSource&&he.MediaSource.isTypeSupported&&he.MediaSource.isTypeSupported(Tc(e))||t&&he.ManagedMediaSource&&he.ManagedMediaSource.isTypeSupported&&he.ManagedMediaSource.isTypeSupported(Tc(e))||!1},Iy=function(e){return e===void 0&&(e=""),e.toLowerCase().split(",").every(function(t){t=t.trim();for(var i=0;i<JS.length;i++){var n=JS[i];if(ql["muxer"+n].test(t))return!0}return!1})},eE="mp4a.40.2",nP="avc1.4d400d",rP=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,aP=/^application\/dash\+xml/i,$A=function(e){return rP.test(e)?"hls":aP.test(e)?"dash":e==="application/vnd.videojs.vhs+json"?"vhs-json":null},oP=function(e){return e.toString(2).length},lP=function(e){return Math.ceil(oP(e)/8)},HA=function(e){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},uP=function(e){return HA(e)},Pt=function(e){return e instanceof Uint8Array?e:(!Array.isArray(e)&&!uP(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))},Xs=he.BigInt||Number,Gv=[Xs("0x1"),Xs("0x100"),Xs("0x10000"),Xs("0x1000000"),Xs("0x100000000"),Xs("0x10000000000"),Xs("0x1000000000000"),Xs("0x100000000000000"),Xs("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 cP=function(e,t){var i=t===void 0?{}:t,n=i.signed,r=n===void 0?!1:n,o=i.le,u=o===void 0?!1:o;e=Pt(e);var c=u?"reduce":"reduceRight",d=e[c]?e[c]:Array.prototype[c],f=d.call(e,function(g,v,b){var _=u?b:Math.abs(b+1-e.length);return g+Xs(v)*Gv[_]},Xs(0));if(r){var p=Gv[e.length]/Xs(2)-Xs(1);f=Xs(f),f>p&&(f-=p,f-=p,f-=Xs(2))}return Number(f)},dP=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=Xs(e);for(var o=lP(e),u=new Uint8Array(new ArrayBuffer(o)),c=0;c<o;c++){var d=r?c:Math.abs(c+1-u.length);u[d]=Number(e/Gv[c]&Xs(255)),e<0&&(u[d]=Math.abs(~u[d]),u[d]-=c===0?1:2)}return u},VA=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},hP=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 Pt(t[0]);var n=t.reduce(function(u,c,d){return u+(c.byteLength||c.length)},0),r=new Uint8Array(n),o=0;return t.forEach(function(u){u=Pt(u),r.set(u,o),o+=u.byteLength}),r},is=function(e,t,i){var n=i===void 0?{}:i,r=n.offset,o=r===void 0?0:r,u=n.mask,c=u===void 0?[]:u;e=Pt(e),t=Pt(t);var d=t.every?t.every:Array.prototype.every;return t.length&&e.length-o>=t.length&&d.call(t,function(f,p){var g=c[p]?c[p]&e[o+p]:e[o+p];return f===g})},fP=function(e,t,i){t.forEach(function(n){for(var r in e.mediaGroups[n])for(var o in e.mediaGroups[n][r]){var u=e.mediaGroups[n][r][o];i(u,n,r,o)}})},jd={},Fa={},Il={},tE;function Vp(){if(tE)return Il;tE=1;function s(r,o,u){if(u===void 0&&(u=Array.prototype),r&&typeof u.find=="function")return u.find.call(r,o);for(var c=0;c<r.length;c++)if(Object.prototype.hasOwnProperty.call(r,c)){var d=r[c];if(o.call(void 0,d,c,r))return d}}function e(r,o){return o===void 0&&(o=Object),o&&typeof o.freeze=="function"?o.freeze(r):r}function t(r,o){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&(r[u]=o[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 Il.assign=t,Il.find=s,Il.freeze=e,Il.MIME_TYPE=i,Il.NAMESPACE=n,Il}var iE;function GA(){if(iE)return Fa;iE=1;var s=Vp(),e=s.find,t=s.NAMESPACE;function i(H){return H!==""}function n(H){return H?H.split(/[\t\n\f\r ]+/).filter(i):[]}function r(H,K){return H.hasOwnProperty(K)||(H[K]=!0),H}function o(H){if(!H)return[];var K=n(H);return Object.keys(K.reduce(r,{}))}function u(H){return function(K){return H&&H.indexOf(K)!==-1}}function c(H,K){for(var re in H)Object.prototype.hasOwnProperty.call(H,re)&&(K[re]=H[re])}function d(H,K){var re=H.prototype;if(!(re instanceof K)){let Ye=function(){};var Ee=Ye;Ye.prototype=K.prototype,Ye=new Ye,c(re,Ye),H.prototype=re=Ye}re.constructor!=H&&(typeof H!="function"&&console.error("unknown Class:"+H),re.constructor=H)}var f={},p=f.ELEMENT_NODE=1,g=f.ATTRIBUTE_NODE=2,v=f.TEXT_NODE=3,b=f.CDATA_SECTION_NODE=4,_=f.ENTITY_REFERENCE_NODE=5,S=f.ENTITY_NODE=6,D=f.PROCESSING_INSTRUCTION_NODE=7,R=f.COMMENT_NODE=8,L=f.DOCUMENT_NODE=9,M=f.DOCUMENT_TYPE_NODE=10,j=f.DOCUMENT_FRAGMENT_NODE=11,V=f.NOTATION_NODE=12,P={},z={};P.INDEX_SIZE_ERR=(z[1]="Index size error",1),P.DOMSTRING_SIZE_ERR=(z[2]="DOMString size error",2);var I=P.HIERARCHY_REQUEST_ERR=(z[3]="Hierarchy request error",3);P.WRONG_DOCUMENT_ERR=(z[4]="Wrong document",4),P.INVALID_CHARACTER_ERR=(z[5]="Invalid character",5),P.NO_DATA_ALLOWED_ERR=(z[6]="No data allowed",6),P.NO_MODIFICATION_ALLOWED_ERR=(z[7]="No modification allowed",7);var O=P.NOT_FOUND_ERR=(z[8]="Not found",8);P.NOT_SUPPORTED_ERR=(z[9]="Not supported",9);var W=P.INUSE_ATTRIBUTE_ERR=(z[10]="Attribute in use",10);P.INVALID_STATE_ERR=(z[11]="Invalid state",11),P.SYNTAX_ERR=(z[12]="Syntax error",12),P.INVALID_MODIFICATION_ERR=(z[13]="Invalid modification",13),P.NAMESPACE_ERR=(z[14]="Invalid namespace",14),P.INVALID_ACCESS_ERR=(z[15]="Invalid access",15);function X(H,K){if(K instanceof Error)var re=K;else re=this,Error.call(this,z[H]),this.message=z[H],Error.captureStackTrace&&Error.captureStackTrace(this,X);return re.code=H,K&&(this.message=this.message+": "+K),re}X.prototype=Error.prototype,c(P,X);function q(){}q.prototype={length:0,item:function(H){return H>=0&&H<this.length?this[H]:null},toString:function(H,K){for(var re=[],Ee=0;Ee<this.length;Ee++)gi(this[Ee],re,H,K);return re.join("")},filter:function(H){return Array.prototype.filter.call(this,H)},indexOf:function(H){return Array.prototype.indexOf.call(this,H)}};function ue(H,K){this._node=H,this._refresh=K,ie(this)}function ie(H){var K=H._node._inc||H._node.ownerDocument._inc;if(H._inc!==K){var re=H._refresh(H._node);if(ri(H,"length",re.length),!H.$$length||re.length<H.$$length)for(var Ee=re.length;Ee in H;Ee++)Object.prototype.hasOwnProperty.call(H,Ee)&&delete H[Ee];c(re,H),H._inc=K}}ue.prototype.item=function(H){return ie(this),this[H]||null},d(ue,q);function Y(){}function G(H,K){for(var re=H.length;re--;)if(H[re]===K)return re}function J(H,K,re,Ee){if(Ee?K[G(K,Ee)]=re:K[K.length++]=re,H){re.ownerElement=H;var Ye=H.ownerDocument;Ye&&(Ee&&Ce(Ye,H,Ee),ve(Ye,H,re))}}function oe(H,K,re){var Ee=G(K,re);if(Ee>=0){for(var Ye=K.length-1;Ee<Ye;)K[Ee]=K[++Ee];if(K.length=Ye,H){var Tt=H.ownerDocument;Tt&&(Ce(Tt,H,re),re.ownerElement=null)}}else throw new X(O,new Error(H.tagName+"@"+re))}Y.prototype={length:0,item:q.prototype.item,getNamedItem:function(H){for(var K=this.length;K--;){var re=this[K];if(re.nodeName==H)return re}},setNamedItem:function(H){var K=H.ownerElement;if(K&&K!=this._ownerElement)throw new X(W);var re=this.getNamedItem(H.nodeName);return J(this._ownerElement,this,H,re),re},setNamedItemNS:function(H){var K=H.ownerElement,re;if(K&&K!=this._ownerElement)throw new X(W);return re=this.getNamedItemNS(H.namespaceURI,H.localName),J(this._ownerElement,this,H,re),re},removeNamedItem:function(H){var K=this.getNamedItem(H);return oe(this._ownerElement,this,K),K},removeNamedItemNS:function(H,K){var re=this.getNamedItemNS(H,K);return oe(this._ownerElement,this,re),re},getNamedItemNS:function(H,K){for(var re=this.length;re--;){var Ee=this[re];if(Ee.localName==K&&Ee.namespaceURI==H)return Ee}return null}};function ce(){}ce.prototype={hasFeature:function(H,K){return!0},createDocument:function(H,K,re){var Ee=new _e;if(Ee.implementation=this,Ee.childNodes=new q,Ee.doctype=re||null,re&&Ee.appendChild(re),K){var Ye=Ee.createElementNS(H,K);Ee.appendChild(Ye)}return Ee},createDocumentType:function(H,K,re){var Ee=new vt;return Ee.name=H,Ee.nodeName=H,Ee.publicId=K||"",Ee.systemId=re||"",Ee}};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(H,K){return Nt(this,H,K)},replaceChild:function(H,K){Nt(this,H,K,Dt),K&&this.removeChild(K)},removeChild:function(H){return tt(this,H)},appendChild:function(H){return this.insertBefore(H,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(H){return ht(this.ownerDocument||this,this,H)},normalize:function(){for(var H=this.firstChild;H;){var K=H.nextSibling;K&&K.nodeType==v&&H.nodeType==v?(this.removeChild(K),H.appendData(K.data)):(H.normalize(),H=K)}},isSupported:function(H,K){return this.ownerDocument.implementation.hasFeature(H,K)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(H){for(var K=this;K;){var re=K._nsMap;if(re){for(var Ee in re)if(Object.prototype.hasOwnProperty.call(re,Ee)&&re[Ee]===H)return Ee}K=K.nodeType==g?K.ownerDocument:K.parentNode}return null},lookupNamespaceURI:function(H){for(var K=this;K;){var re=K._nsMap;if(re&&Object.prototype.hasOwnProperty.call(re,H))return re[H];K=K.nodeType==g?K.ownerDocument:K.parentNode}return null},isDefaultNamespace:function(H){var K=this.lookupPrefix(H);return K==null}};function ee(H){return H=="<"&&"&lt;"||H==">"&&"&gt;"||H=="&"&&"&amp;"||H=='"'&&"&quot;"||"&#"+H.charCodeAt()+";"}c(f,F),c(f,F.prototype);function pe(H,K){if(K(H))return!0;if(H=H.firstChild)do if(pe(H,K))return!0;while(H=H.nextSibling)}function _e(){this.ownerDocument=this}function ve(H,K,re){H&&H._inc++;var Ee=re.namespaceURI;Ee===t.XMLNS&&(K._nsMap[re.prefix?re.localName:""]=re.value)}function Ce(H,K,re,Ee){H&&H._inc++;var Ye=re.namespaceURI;Ye===t.XMLNS&&delete K._nsMap[re.prefix?re.localName:""]}function Be(H,K,re){if(H&&H._inc){H._inc++;var Ee=K.childNodes;if(re)Ee[Ee.length++]=re;else{for(var Ye=K.firstChild,Tt=0;Ye;)Ee[Tt++]=Ye,Ye=Ye.nextSibling;Ee.length=Tt,delete Ee[Ee.length]}}}function tt(H,K){var re=K.previousSibling,Ee=K.nextSibling;return re?re.nextSibling=Ee:H.firstChild=Ee,Ee?Ee.previousSibling=re:H.lastChild=re,K.parentNode=null,K.previousSibling=null,K.nextSibling=null,Be(H.ownerDocument,H),K}function Je(H){return H&&(H.nodeType===F.DOCUMENT_NODE||H.nodeType===F.DOCUMENT_FRAGMENT_NODE||H.nodeType===F.ELEMENT_NODE)}function Ct(H){return H&&(mt(H)||pt(H)||st(H)||H.nodeType===F.DOCUMENT_FRAGMENT_NODE||H.nodeType===F.COMMENT_NODE||H.nodeType===F.PROCESSING_INSTRUCTION_NODE)}function st(H){return H&&H.nodeType===F.DOCUMENT_TYPE_NODE}function mt(H){return H&&H.nodeType===F.ELEMENT_NODE}function pt(H){return H&&H.nodeType===F.TEXT_NODE}function ut(H,K){var re=H.childNodes||[];if(e(re,mt)||st(K))return!1;var Ee=e(re,st);return!(K&&Ee&&re.indexOf(Ee)>re.indexOf(K))}function Ht(H,K){var re=H.childNodes||[];function Ee(Tt){return mt(Tt)&&Tt!==K}if(e(re,Ee))return!1;var Ye=e(re,st);return!(K&&Ye&&re.indexOf(Ye)>re.indexOf(K))}function at(H,K,re){if(!Je(H))throw new X(I,"Unexpected parent node type "+H.nodeType);if(re&&re.parentNode!==H)throw new X(O,"child not in parent");if(!Ct(K)||st(K)&&H.nodeType!==F.DOCUMENT_NODE)throw new X(I,"Unexpected node type "+K.nodeType+" for parent node type "+H.nodeType)}function gt(H,K,re){var Ee=H.childNodes||[],Ye=K.childNodes||[];if(K.nodeType===F.DOCUMENT_FRAGMENT_NODE){var Tt=Ye.filter(mt);if(Tt.length>1||e(Ye,pt))throw new X(I,"More than one element or text in fragment");if(Tt.length===1&&!ut(H,re))throw new X(I,"Element in fragment can not be inserted before doctype")}if(mt(K)&&!ut(H,re))throw new X(I,"Only one element can be added and only after doctype");if(st(K)){if(e(Ee,st))throw new X(I,"Only one doctype is allowed");var zt=e(Ee,mt);if(re&&Ee.indexOf(zt)<Ee.indexOf(re))throw new X(I,"Doctype can only be inserted before an element");if(!re&&zt)throw new X(I,"Doctype can not be appended since element is present")}}function Dt(H,K,re){var Ee=H.childNodes||[],Ye=K.childNodes||[];if(K.nodeType===F.DOCUMENT_FRAGMENT_NODE){var Tt=Ye.filter(mt);if(Tt.length>1||e(Ye,pt))throw new X(I,"More than one element or text in fragment");if(Tt.length===1&&!Ht(H,re))throw new X(I,"Element in fragment can not be inserted before doctype")}if(mt(K)&&!Ht(H,re))throw new X(I,"Only one element can be added and only after doctype");if(st(K)){let Wi=function(Xi){return st(Xi)&&Xi!==re};var xi=Wi;if(e(Ee,Wi))throw new X(I,"Only one doctype is allowed");var zt=e(Ee,mt);if(re&&Ee.indexOf(zt)<Ee.indexOf(re))throw new X(I,"Doctype can only be inserted before an element")}}function Nt(H,K,re,Ee){at(H,K,re),H.nodeType===F.DOCUMENT_NODE&&(Ee||gt)(H,K,re);var Ye=K.parentNode;if(Ye&&Ye.removeChild(K),K.nodeType===j){var Tt=K.firstChild;if(Tt==null)return K;var zt=K.lastChild}else Tt=zt=K;var xi=re?re.previousSibling:H.lastChild;Tt.previousSibling=xi,zt.nextSibling=re,xi?xi.nextSibling=Tt:H.firstChild=Tt,re==null?H.lastChild=zt:re.previousSibling=zt;do{Tt.parentNode=H;var Wi=H.ownerDocument||H;dt(Tt,Wi)}while(Tt!==zt&&(Tt=Tt.nextSibling));return Be(H.ownerDocument||H,H),K.nodeType==j&&(K.firstChild=K.lastChild=null),K}function dt(H,K){if(H.ownerDocument!==K){if(H.ownerDocument=K,H.nodeType===p&&H.attributes)for(var re=0;re<H.attributes.length;re++){var Ee=H.attributes.item(re);Ee&&(Ee.ownerDocument=K)}for(var Ye=H.firstChild;Ye;)dt(Ye,K),Ye=Ye.nextSibling}}function lt(H,K){K.parentNode&&K.parentNode.removeChild(K),K.parentNode=H,K.previousSibling=H.lastChild,K.nextSibling=null,K.previousSibling?K.previousSibling.nextSibling=K:H.firstChild=K,H.lastChild=K,Be(H.ownerDocument,H,K);var re=H.ownerDocument||H;return dt(K,re),K}_e.prototype={nodeName:"#document",nodeType:L,doctype:null,documentElement:null,_inc:1,insertBefore:function(H,K){if(H.nodeType==j){for(var re=H.firstChild;re;){var Ee=re.nextSibling;this.insertBefore(re,K),re=Ee}return H}return Nt(this,H,K),dt(H,this),this.documentElement===null&&H.nodeType===p&&(this.documentElement=H),H},removeChild:function(H){return this.documentElement==H&&(this.documentElement=null),tt(this,H)},replaceChild:function(H,K){Nt(this,H,K,Dt),dt(H,this),K&&this.removeChild(K),mt(H)&&(this.documentElement=H)},importNode:function(H,K){return kt(this,H,K)},getElementById:function(H){var K=null;return pe(this.documentElement,function(re){if(re.nodeType==p&&re.getAttribute("id")==H)return K=re,!0}),K},getElementsByClassName:function(H){var K=o(H);return new ue(this,function(re){var Ee=[];return K.length>0&&pe(re.documentElement,function(Ye){if(Ye!==re&&Ye.nodeType===p){var Tt=Ye.getAttribute("class");if(Tt){var zt=H===Tt;if(!zt){var xi=o(Tt);zt=K.every(u(xi))}zt&&Ee.push(Ye)}}}),Ee})},createElement:function(H){var K=new ye;K.ownerDocument=this,K.nodeName=H,K.tagName=H,K.localName=H,K.childNodes=new q;var re=K.attributes=new Y;return re._ownerElement=K,K},createDocumentFragment:function(){var H=new wt;return H.ownerDocument=this,H.childNodes=new q,H},createTextNode:function(H){var K=new et;return K.ownerDocument=this,K.appendData(H),K},createComment:function(H){var K=new ot;return K.ownerDocument=this,K.appendData(H),K},createCDATASection:function(H){var K=new nt;return K.ownerDocument=this,K.appendData(H),K},createProcessingInstruction:function(H,K){var re=new hi;return re.ownerDocument=this,re.tagName=re.nodeName=re.target=H,re.nodeValue=re.data=K,re},createAttribute:function(H){var K=new ze;return K.ownerDocument=this,K.name=H,K.nodeName=H,K.localName=H,K.specified=!0,K},createEntityReference:function(H){var K=new Gt;return K.ownerDocument=this,K.nodeName=H,K},createElementNS:function(H,K){var re=new ye,Ee=K.split(":"),Ye=re.attributes=new Y;return re.childNodes=new q,re.ownerDocument=this,re.nodeName=K,re.tagName=K,re.namespaceURI=H,Ee.length==2?(re.prefix=Ee[0],re.localName=Ee[1]):re.localName=K,Ye._ownerElement=re,re},createAttributeNS:function(H,K){var re=new ze,Ee=K.split(":");return re.ownerDocument=this,re.nodeName=K,re.name=K,re.namespaceURI=H,re.specified=!0,Ee.length==2?(re.prefix=Ee[0],re.localName=Ee[1]):re.localName=K,re}},d(_e,F);function ye(){this._nsMap={}}ye.prototype={nodeType:p,hasAttribute:function(H){return this.getAttributeNode(H)!=null},getAttribute:function(H){var K=this.getAttributeNode(H);return K&&K.value||""},getAttributeNode:function(H){return this.attributes.getNamedItem(H)},setAttribute:function(H,K){var re=this.ownerDocument.createAttribute(H);re.value=re.nodeValue=""+K,this.setAttributeNode(re)},removeAttribute:function(H){var K=this.getAttributeNode(H);K&&this.removeAttributeNode(K)},appendChild:function(H){return H.nodeType===j?this.insertBefore(H,null):lt(this,H)},setAttributeNode:function(H){return this.attributes.setNamedItem(H)},setAttributeNodeNS:function(H){return this.attributes.setNamedItemNS(H)},removeAttributeNode:function(H){return this.attributes.removeNamedItem(H.nodeName)},removeAttributeNS:function(H,K){var re=this.getAttributeNodeNS(H,K);re&&this.removeAttributeNode(re)},hasAttributeNS:function(H,K){return this.getAttributeNodeNS(H,K)!=null},getAttributeNS:function(H,K){var re=this.getAttributeNodeNS(H,K);return re&&re.value||""},setAttributeNS:function(H,K,re){var Ee=this.ownerDocument.createAttributeNS(H,K);Ee.value=Ee.nodeValue=""+re,this.setAttributeNode(Ee)},getAttributeNodeNS:function(H,K){return this.attributes.getNamedItemNS(H,K)},getElementsByTagName:function(H){return new ue(this,function(K){var re=[];return pe(K,function(Ee){Ee!==K&&Ee.nodeType==p&&(H==="*"||Ee.tagName==H)&&re.push(Ee)}),re})},getElementsByTagNameNS:function(H,K){return new ue(this,function(re){var Ee=[];return pe(re,function(Ye){Ye!==re&&Ye.nodeType===p&&(H==="*"||Ye.namespaceURI===H)&&(K==="*"||Ye.localName==K)&&Ee.push(Ye)}),Ee})}},_e.prototype.getElementsByTagName=ye.prototype.getElementsByTagName,_e.prototype.getElementsByTagNameNS=ye.prototype.getElementsByTagNameNS,d(ye,F);function ze(){}ze.prototype.nodeType=g,d(ze,F);function We(){}We.prototype={data:"",substringData:function(H,K){return this.data.substring(H,H+K)},appendData:function(H){H=this.data+H,this.nodeValue=this.data=H,this.length=H.length},insertData:function(H,K){this.replaceData(H,0,K)},appendChild:function(H){throw new Error(z[I])},deleteData:function(H,K){this.replaceData(H,K,"")},replaceData:function(H,K,re){var Ee=this.data.substring(0,H),Ye=this.data.substring(H+K);re=Ee+re+Ye,this.nodeValue=this.data=re,this.length=re.length}},d(We,F);function et(){}et.prototype={nodeName:"#text",nodeType:v,splitText:function(H){var K=this.data,re=K.substring(H);K=K.substring(0,H),this.data=this.nodeValue=K,this.length=K.length;var Ee=this.ownerDocument.createTextNode(re);return this.parentNode&&this.parentNode.insertBefore(Ee,this.nextSibling),Ee}},d(et,We);function ot(){}ot.prototype={nodeName:"#comment",nodeType:R},d(ot,We);function nt(){}nt.prototype={nodeName:"#cdata-section",nodeType:b},d(nt,We);function vt(){}vt.prototype.nodeType=M,d(vt,F);function Xe(){}Xe.prototype.nodeType=V,d(Xe,F);function Ft(){}Ft.prototype.nodeType=S,d(Ft,F);function Gt(){}Gt.prototype.nodeType=_,d(Gt,F);function wt(){}wt.prototype.nodeName="#document-fragment",wt.prototype.nodeType=j,d(wt,F);function hi(){}hi.prototype.nodeType=D,d(hi,F);function Qe(){}Qe.prototype.serializeToString=function(H,K,re){return Lt.call(H,K,re)},F.prototype.toString=Lt;function Lt(H,K){var re=[],Ee=this.nodeType==9&&this.documentElement||this,Ye=Ee.prefix,Tt=Ee.namespaceURI;if(Tt&&Ye==null){var Ye=Ee.lookupPrefix(Tt);if(Ye==null)var zt=[{namespace:Tt,prefix:null}]}return gi(this,re,H,K,zt),re.join("")}function Ut(H,K,re){var Ee=H.prefix||"",Ye=H.namespaceURI;if(!Ye||Ee==="xml"&&Ye===t.XML||Ye===t.XMLNS)return!1;for(var Tt=re.length;Tt--;){var zt=re[Tt];if(zt.prefix===Ee)return zt.namespace!==Ye}return!0}function vi(H,K,re){H.push(" ",K,'="',re.replace(/[<>&"\t\n\r]/g,ee),'"')}function gi(H,K,re,Ee,Ye){if(Ye||(Ye=[]),Ee)if(H=Ee(H),H){if(typeof H=="string"){K.push(H);return}}else return;switch(H.nodeType){case p:var Tt=H.attributes,zt=Tt.length,Kt=H.firstChild,xi=H.tagName;re=t.isHTML(H.namespaceURI)||re;var Wi=xi;if(!re&&!H.prefix&&H.namespaceURI){for(var Xi,rs=0;rs<Tt.length;rs++)if(Tt.item(rs).name==="xmlns"){Xi=Tt.item(rs).value;break}if(!Xi)for(var Qi=Ye.length-1;Qi>=0;Qi--){var ai=Ye[Qi];if(ai.prefix===""&&ai.namespace===H.namespaceURI){Xi=ai.namespace;break}}if(Xi!==H.namespaceURI)for(var Qi=Ye.length-1;Qi>=0;Qi--){var ai=Ye[Qi];if(ai.namespace===H.namespaceURI){ai.prefix&&(Wi=ai.prefix+":"+xi);break}}}K.push("<",Wi);for(var Fi=0;Fi<zt;Fi++){var Ui=Tt.item(Fi);Ui.prefix=="xmlns"?Ye.push({prefix:Ui.localName,namespace:Ui.value}):Ui.nodeName=="xmlns"&&Ye.push({prefix:"",namespace:Ui.value})}for(var Fi=0;Fi<zt;Fi++){var Ui=Tt.item(Fi);if(Ut(Ui,re,Ye)){var Ei=Ui.prefix||"",Wt=Ui.namespaceURI;vi(K,Ei?"xmlns:"+Ei:"xmlns",Wt),Ye.push({prefix:Ei,namespace:Wt})}gi(Ui,K,re,Ee,Ye)}if(xi===Wi&&Ut(H,re,Ye)){var Ei=H.prefix||"",Wt=H.namespaceURI;vi(K,Ei?"xmlns:"+Ei:"xmlns",Wt),Ye.push({prefix:Ei,namespace:Wt})}if(Kt||re&&!/^(?:meta|link|img|br|hr|input)$/i.test(xi)){if(K.push(">"),re&&/^script$/i.test(xi))for(;Kt;)Kt.data?K.push(Kt.data):gi(Kt,K,re,Ee,Ye.slice()),Kt=Kt.nextSibling;else for(;Kt;)gi(Kt,K,re,Ee,Ye.slice()),Kt=Kt.nextSibling;K.push("</",Wi,">")}else K.push("/>");return;case L:case j:for(var Kt=H.firstChild;Kt;)gi(Kt,K,re,Ee,Ye.slice()),Kt=Kt.nextSibling;return;case g:return vi(K,H.name,H.value);case v:return K.push(H.data.replace(/[<&>]/g,ee));case b:return K.push("<![CDATA[",H.data,"]]>");case R:return K.push("<!--",H.data,"-->");case M:var jt=H.publicId,Ii=H.systemId;if(K.push("<!DOCTYPE ",H.name),jt)K.push(" PUBLIC ",jt),Ii&&Ii!="."&&K.push(" ",Ii),K.push(">");else if(Ii&&Ii!=".")K.push(" SYSTEM ",Ii,">");else{var ds=H.internalSubset;ds&&K.push(" [",ds,"]"),K.push(">")}return;case D:return K.push("<?",H.target," ",H.data,"?>");case _:return K.push("&",H.nodeName,";");default:K.push("??",H.nodeName)}}function kt(H,K,re){var Ee;switch(K.nodeType){case p:Ee=K.cloneNode(!1),Ee.ownerDocument=H;case j:break;case g:re=!0;break}if(Ee||(Ee=K.cloneNode(!1)),Ee.ownerDocument=H,Ee.parentNode=null,re)for(var Ye=K.firstChild;Ye;)Ee.appendChild(kt(H,Ye,re)),Ye=Ye.nextSibling;return Ee}function ht(H,K,re){var Ee=new K.constructor;for(var Ye in K)if(Object.prototype.hasOwnProperty.call(K,Ye)){var Tt=K[Ye];typeof Tt!="object"&&Tt!=Ee[Ye]&&(Ee[Ye]=Tt)}switch(K.childNodes&&(Ee.childNodes=new q),Ee.ownerDocument=H,Ee.nodeType){case p:var zt=K.attributes,xi=Ee.attributes=new Y,Wi=zt.length;xi._ownerElement=Ee;for(var Xi=0;Xi<Wi;Xi++)Ee.setAttributeNode(ht(H,zt.item(Xi),!0));break;case g:re=!0}if(re)for(var rs=K.firstChild;rs;)Ee.appendChild(ht(H,rs,re)),rs=rs.nextSibling;return Ee}function ri(H,K,re){H[K]=re}try{if(Object.defineProperty){let H=function(K){switch(K.nodeType){case p:case j:var re=[];for(K=K.firstChild;K;)K.nodeType!==7&&K.nodeType!==8&&re.push(H(K)),K=K.nextSibling;return re.join("");default:return K.nodeValue}};var Ie=H;Object.defineProperty(ue.prototype,"length",{get:function(){return ie(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){return H(this)},set:function(K){switch(this.nodeType){case p:case j:for(;this.firstChild;)this.removeChild(this.firstChild);(K||String(K))&&this.appendChild(this.ownerDocument.createTextNode(K));break;default:this.data=K,this.value=K,this.nodeValue=K}}}),ri=function(K,re,Ee){K["$$"+re]=Ee}}}catch{}return Fa.DocumentType=vt,Fa.DOMException=X,Fa.DOMImplementation=ce,Fa.Element=ye,Fa.Node=F,Fa.NodeList=q,Fa.XMLSerializer=Qe,Fa}var $d={},Ny={},sE;function mP(){return sE||(sE=1,(function(s){var e=Vp().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})(Ny)),Ny}var cm={},nE;function pP(){if(nE)return cm;nE=1;var s=Vp().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,o=2,u=3,c=4,d=5,f=6,p=7;function g(I,O){this.message=I,this.locator=O,Error.captureStackTrace&&Error.captureStackTrace(this,g)}g.prototype=new Error,g.prototype.name=g.name;function v(){}v.prototype={parse:function(I,O,W){var X=this.domBuilder;X.startDocument(),M(O,O={}),b(I,O,W,X,this.errorHandler),X.endDocument()}};function b(I,O,W,X,q){function ue(lt){if(lt>65535){lt-=65536;var ye=55296+(lt>>10),ze=56320+(lt&1023);return String.fromCharCode(ye,ze)}else return String.fromCharCode(lt)}function ie(lt){var ye=lt.slice(1,-1);return Object.hasOwnProperty.call(W,ye)?W[ye]:ye.charAt(0)==="#"?ue(parseInt(ye.substr(1).replace("x","0x"))):(q.error("entity not found:"+lt),lt)}function Y(lt){if(lt>_e){var ye=I.substring(_e,lt).replace(/&#?\w+;/g,ie);F&&G(_e),X.characters(ye,0,lt-_e),_e=lt}}function G(lt,ye){for(;lt>=oe&&(ye=ce.exec(I));)J=ye.index,oe=J+ye[0].length,F.lineNumber++;F.columnNumber=lt-J+1}for(var J=0,oe=0,ce=/.*(?:\r\n?|\n)|.*$/g,F=X.locator,ee=[{currentNSMap:O}],pe={},_e=0;;){try{var ve=I.indexOf("<",_e);if(ve<0){if(!I.substr(_e).match(/^\s*$/)){var Ce=X.doc,Be=Ce.createTextNode(I.substr(_e));Ce.appendChild(Be),X.currentElement=Be}return}switch(ve>_e&&Y(ve),I.charAt(ve+1)){case"/":var at=I.indexOf(">",ve+3),tt=I.substring(ve+2,at).replace(/[ \t\n\r]+$/g,""),Je=ee.pop();at<0?(tt=I.substring(ve+2).replace(/[\s<].*/,""),q.error("end tag name: "+tt+" is not complete:"+Je.tagName),at=ve+1+tt.length):tt.match(/\s</)&&(tt=tt.replace(/[\s<].*/,""),q.error("end tag name: "+tt+" maybe not complete"),at=ve+1+tt.length);var Ct=Je.localNSMap,st=Je.tagName==tt,mt=st||Je.tagName&&Je.tagName.toLowerCase()==tt.toLowerCase();if(mt){if(X.endElement(Je.uri,Je.localName,tt),Ct)for(var pt in Ct)Object.prototype.hasOwnProperty.call(Ct,pt)&&X.endPrefixMapping(pt);st||q.fatalError("end tag name: "+tt+" is not match the current start tagName:"+Je.tagName)}else ee.push(Je);at++;break;case"?":F&&G(ve),at=V(I,ve,X);break;case"!":F&&G(ve),at=j(I,ve,X,q);break;default:F&&G(ve);var ut=new P,Ht=ee[ee.length-1].currentNSMap,at=S(I,ve,ut,Ht,ie,q),gt=ut.length;if(!ut.closed&&L(I,at,ut.tagName,pe)&&(ut.closed=!0,W.nbsp||q.warning("unclosed xml attribute")),F&&gt){for(var Dt=_(F,{}),Nt=0;Nt<gt;Nt++){var dt=ut[Nt];G(dt.offset),dt.locator=_(F,{})}X.locator=Dt,D(ut,X,Ht)&&ee.push(ut),X.locator=F}else D(ut,X,Ht)&&ee.push(ut);s.isHTML(ut.uri)&&!ut.closed?at=R(I,at,ut.tagName,ie,X):at++}}catch(lt){if(lt instanceof g)throw lt;q.error("element parse error: "+lt),at=-1}at>_e?_e=at:Y(Math.max(ve,_e)+1)}}function _(I,O){return O.lineNumber=I.lineNumber,O.columnNumber=I.columnNumber,O}function S(I,O,W,X,q,ue){function ie(F,ee,pe){W.attributeNames.hasOwnProperty(F)&&ue.fatalError("Attribute "+F+" redefined"),W.addValue(F,ee.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,q),pe)}for(var Y,G,J=++O,oe=n;;){var ce=I.charAt(J);switch(ce){case"=":if(oe===r)Y=I.slice(O,J),oe=u;else if(oe===o)oe=u;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(oe===u||oe===r)if(oe===r&&(ue.warning('attribute value must after "="'),Y=I.slice(O,J)),O=J+1,J=I.indexOf(ce,O),J>0)G=I.slice(O,J),ie(Y,G,O-1),oe=d;else throw new Error("attribute value no end '"+ce+"' match");else if(oe==c)G=I.slice(O,J),ie(Y,G,O),ue.warning('attribute "'+Y+'" missed start quot('+ce+")!!"),O=J+1,oe=d;else throw new Error('attribute value must after "="');break;case"/":switch(oe){case n:W.setTagName(I.slice(O,J));case d:case f:case p:oe=p,W.closed=!0;case c:case r:break;case o:W.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return ue.error("unexpected end of input"),oe==n&&W.setTagName(I.slice(O,J)),J;case">":switch(oe){case n:W.setTagName(I.slice(O,J));case d:case f:case p:break;case c:case r:G=I.slice(O,J),G.slice(-1)==="/"&&(W.closed=!0,G=G.slice(0,-1));case o:oe===o&&(G=Y),oe==c?(ue.warning('attribute "'+G+'" missed quot(")!'),ie(Y,G,O)):((!s.isHTML(X[""])||!G.match(/^(?:disabled|checked|selected)$/i))&&ue.warning('attribute "'+G+'" missed value!! "'+G+'" instead!!'),ie(G,G,O));break;case u:throw new Error("attribute value missed!!")}return J;case"€":ce=" ";default:if(ce<=" ")switch(oe){case n:W.setTagName(I.slice(O,J)),oe=f;break;case r:Y=I.slice(O,J),oe=o;break;case c:var G=I.slice(O,J);ue.warning('attribute "'+G+'" missed quot(")!!'),ie(Y,G,O);case d:oe=f;break}else switch(oe){case o:W.tagName,(!s.isHTML(X[""])||!Y.match(/^(?:disabled|checked|selected)$/i))&&ue.warning('attribute "'+Y+'" missed value!! "'+Y+'" instead2!!'),ie(Y,Y,O),O=J,oe=r;break;case d:ue.warning('attribute space is required"'+Y+'"!!');case f:oe=r,O=J;break;case u:oe=c,O=J;break;case p:throw new Error("elements closed character '/' and '>' must be connected to")}}J++}}function D(I,O,W){for(var X=I.tagName,q=null,ce=I.length;ce--;){var ue=I[ce],ie=ue.qName,Y=ue.value,F=ie.indexOf(":");if(F>0)var G=ue.prefix=ie.slice(0,F),J=ie.slice(F+1),oe=G==="xmlns"&&J;else J=ie,G=null,oe=ie==="xmlns"&&"";ue.localName=J,oe!==!1&&(q==null&&(q={},M(W,W={})),W[oe]=q[oe]=Y,ue.uri=s.XMLNS,O.startPrefixMapping(oe,Y))}for(var ce=I.length;ce--;){ue=I[ce];var G=ue.prefix;G&&(G==="xml"&&(ue.uri=s.XML),G!=="xmlns"&&(ue.uri=W[G||""]))}var F=X.indexOf(":");F>0?(G=I.prefix=X.slice(0,F),J=I.localName=X.slice(F+1)):(G=null,J=I.localName=X);var ee=I.uri=W[G||""];if(O.startElement(ee,J,X,I),I.closed){if(O.endElement(ee,J,X),q)for(G in q)Object.prototype.hasOwnProperty.call(q,G)&&O.endPrefixMapping(G)}else return I.currentNSMap=W,I.localNSMap=q,!0}function R(I,O,W,X,q){if(/^(?:script|textarea)$/i.test(W)){var ue=I.indexOf("</"+W+">",O),ie=I.substring(O+1,ue);if(/[&<]/.test(ie))return/^script$/i.test(W)?(q.characters(ie,0,ie.length),ue):(ie=ie.replace(/&#?\w+;/g,X),q.characters(ie,0,ie.length),ue)}return O+1}function L(I,O,W,X){var q=X[W];return q==null&&(q=I.lastIndexOf("</"+W+">"),q<O&&(q=I.lastIndexOf("</"+W)),X[W]=q),q<O}function M(I,O){for(var W in I)Object.prototype.hasOwnProperty.call(I,W)&&(O[W]=I[W])}function j(I,O,W,X){var q=I.charAt(O+2);switch(q){case"-":if(I.charAt(O+3)==="-"){var ue=I.indexOf("-->",O+4);return ue>O?(W.comment(I,O+4,ue-O-4),ue+3):(X.error("Unclosed comment"),-1)}else return-1;default:if(I.substr(O+3,6)=="CDATA["){var ue=I.indexOf("]]>",O+9);return W.startCDATA(),W.characters(I,O+9,ue-O-9),W.endCDATA(),ue+3}var ie=z(I,O),Y=ie.length;if(Y>1&&/!doctype/i.test(ie[0][0])){var G=ie[1][0],J=!1,oe=!1;Y>3&&(/^public$/i.test(ie[2][0])?(J=ie[3][0],oe=Y>4&&ie[4][0]):/^system$/i.test(ie[2][0])&&(oe=ie[3][0]));var ce=ie[Y-1];return W.startDTD(G,J,oe),W.endDTD(),ce.index+ce[0].length}}return-1}function V(I,O,W){var X=I.indexOf("?>",O);if(X){var q=I.substring(O,X).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return q?(q[0].length,W.processingInstruction(q[1],q[2]),X+2):-1}return-1}function P(){this.attributeNames={}}P.prototype={setTagName:function(I){if(!i.test(I))throw new Error("invalid tagName:"+I);this.tagName=I},addValue:function(I,O,W){if(!i.test(I))throw new Error("invalid attribute:"+I);this.attributeNames[I]=this.length,this[this.length++]={qName:I,value:O,offset:W}},length:0,getLocalName:function(I){return this[I].localName},getLocator:function(I){return this[I].locator},getQName:function(I){return this[I].qName},getURI:function(I){return this[I].uri},getValue:function(I){return this[I].value}};function z(I,O){var W,X=[],q=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(q.lastIndex=O,q.exec(I);W=q.exec(I);)if(X.push(W),W[1])return X}return cm.XMLReader=v,cm.ParseError=g,cm}var rE;function gP(){if(rE)return $d;rE=1;var s=Vp(),e=GA(),t=mP(),i=pP(),n=e.DOMImplementation,r=s.NAMESPACE,o=i.ParseError,u=i.XMLReader;function c(S){return S.replace(/\r[\n\u0085]/g,`
`).replace(/[\r\u0085\u2028]/g,`
`)}function d(S){this.options=S||{locator:{}}}d.prototype.parseFromString=function(S,D){var R=this.options,L=new u,M=R.domBuilder||new p,j=R.errorHandler,V=R.locator,P=R.xmlns||{},z=/\/x?html?$/.test(D),I=z?t.HTML_ENTITIES:t.XML_ENTITIES;V&&M.setDocumentLocator(V),L.errorHandler=f(j,M,V),L.domBuilder=R.domBuilder||M,z&&(P[""]=r.HTML),P.xml=P.xml||r.XML;var O=R.normalizeLineEndings||c;return S&&typeof S=="string"?L.parse(O(S),P,I):L.errorHandler.error("invalid doc source"),M.doc};function f(S,D,R){if(!S){if(D instanceof p)return D;S=D}var L={},M=S instanceof Function;R=R||{};function j(V){var P=S[V];!P&&M&&(P=S.length==2?function(z){S(V,z)}:S),L[V]=P&&function(z){P("[xmldom "+V+"] "+z+v(R))}||function(){}}return j("warning"),j("error"),j("fatalError"),L}function p(){this.cdata=!1}function g(S,D){D.lineNumber=S.lineNumber,D.columnNumber=S.columnNumber}p.prototype={startDocument:function(){this.doc=new n().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(S,D,R,L){var M=this.doc,j=M.createElementNS(S,R||D),V=L.length;_(this,j),this.currentElement=j,this.locator&&g(this.locator,j);for(var P=0;P<V;P++){var S=L.getURI(P),z=L.getValue(P),R=L.getQName(P),I=M.createAttributeNS(S,R);this.locator&&g(L.getLocator(P),I),I.value=I.nodeValue=z,j.setAttributeNode(I)}},endElement:function(S,D,R){var L=this.currentElement;L.tagName,this.currentElement=L.parentNode},startPrefixMapping:function(S,D){},endPrefixMapping:function(S){},processingInstruction:function(S,D){var R=this.doc.createProcessingInstruction(S,D);this.locator&&g(this.locator,R),_(this,R)},ignorableWhitespace:function(S,D,R){},characters:function(S,D,R){if(S=b.apply(this,arguments),S){if(this.cdata)var L=this.doc.createCDATASection(S);else var L=this.doc.createTextNode(S);this.currentElement?this.currentElement.appendChild(L):/^\s*$/.test(S)&&this.doc.appendChild(L),this.locator&&g(this.locator,L)}},skippedEntity:function(S){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(S){(this.locator=S)&&(S.lineNumber=0)},comment:function(S,D,R){S=b.apply(this,arguments);var L=this.doc.createComment(S);this.locator&&g(this.locator,L),_(this,L)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(S,D,R){var L=this.doc.implementation;if(L&&L.createDocumentType){var M=L.createDocumentType(S,D,R);this.locator&&g(this.locator,M),_(this,M),this.doc.doctype=M}},warning:function(S){console.warn("[xmldom warning] "+S,v(this.locator))},error:function(S){console.error("[xmldom error] "+S,v(this.locator))},fatalError:function(S){throw new o(S,this.locator)}};function v(S){if(S)return`
@`+(S.systemId||"")+"#[line:"+S.lineNumber+",col:"+S.columnNumber+"]"}function b(S,D,R){return typeof S=="string"?S.substr(D,R):S.length>=D+R||D?new java.lang.String(S,D,R)+"":S}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(S){p.prototype[S]=function(){return null}});function _(S,D){S.currentElement?S.currentElement.appendChild(D):S.doc.appendChild(D)}return $d.__DOMHandler=p,$d.normalizeLineEndings=c,$d.DOMParser=d,$d}var aE;function yP(){if(aE)return jd;aE=1;var s=GA();return jd.DOMImplementation=s.DOMImplementation,jd.XMLSerializer=s.XMLSerializer,jd.DOMParser=gP().DOMParser,jd}var vP=yP();const oE=s=>!!s&&typeof s=="object",Gs=(...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]):oE(e[i])&&oE(t[i])?e[i]=Gs(e[i],t[i]):e[i]=t[i]}),e),{}),zA=s=>Object.keys(s).map(e=>s[e]),xP=(s,e)=>{const t=[];for(let i=s;i<e;i++)t.push(i);return t},_c=s=>s.reduce((e,t)=>e.concat(t),[]),qA=s=>{if(!s.length)return[];const e=[];for(let t=0;t<s.length;t++)e.push(s[t]);return e},bP=(s,e)=>s.reduce((t,i,n)=>(i[e]&&t.push(n),t),[]),TP=(s,e)=>zA(s.reduce((t,i)=>(i.forEach(n=>{t[e(n)]=n}),t),{}));var Sc={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 ph=({baseUrl:s="",source:e="",range:t="",indexRange:i=""})=>{const n={uri:e,resolvedUri:Hp(s||"",e)};if(t||i){const o=(t||i).split("-");let u=he.BigInt?he.BigInt(o[0]):parseInt(o[0],10),c=he.BigInt?he.BigInt(o[1]):parseInt(o[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=he.BigInt(c)-he.BigInt(u)+he.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},_P=s=>{let e;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=he.BigInt(s.offset)+he.BigInt(s.length)-he.BigInt(1):e=s.offset+s.length-1,`${s.offset}-${e}`},lE=s=>(s&&typeof s!="number"&&(s=parseInt(s,10)),isNaN(s)?null:s),SP={static(s){const{duration:e,timescale:t=1,sourceDuration:i,periodDuration:n}=s,r=lE(s.endNumber),o=e/t;return typeof r=="number"?{start:0,end:r}:typeof n=="number"?{start:0,end:n/o}:{start:0,end:i/o}},dynamic(s){const{NOW:e,clientOffset:t,availabilityStartTime:i,timescale:n=1,duration:r,periodStart:o=0,minimumUpdatePeriod:u=0,timeShiftBufferDepth:c=1/0}=s,d=lE(s.endNumber),f=(e+t)/1e3,p=i+o,v=f+u-p,b=Math.ceil(v*n/r),_=Math.floor((f-p-c)*n/r),S=Math.floor((f-p)*n/r);return{start:Math.max(0,_),end:typeof d=="number"?d:Math.min(b,S)}}},EP=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}},Wx=s=>{const{type:e,duration:t,timescale:i=1,periodDuration:n,sourceDuration:r}=s,{start:o,end:u}=SP[e](s),c=xP(o,u).map(EP(s));if(e==="static"){const d=c.length-1,f=typeof n=="number"?n:r;c[d].duration=f-t/i*d}return c},KA=s=>{const{baseUrl:e,initialization:t={},sourceDuration:i,indexRange:n="",periodStart:r,presentationTime:o,number:u=0,duration:c}=s;if(!e)throw new Error(Sc.NO_BASE_URL);const d=ph({baseUrl:e,source:t.sourceURL,range:t.range}),f=ph({baseUrl:e,source:e,indexRange:n});if(f.map=d,c){const p=Wx(s);p.length&&(f.duration=p[0].duration,f.timeline=p[0].timeline)}else i&&(f.duration=i,f.timeline=r);return f.presentationTime=o||r,f.number=u,[f]},Xx=(s,e,t)=>{const i=s.sidx.map?s.sidx.map:null,n=s.sidx.duration,r=s.timeline||0,o=s.sidx.byterange,u=o.offset+o.length,c=e.timescale,d=e.references.filter(S=>S.referenceType!==1),f=[],p=s.endList?"static":"dynamic",g=s.sidx.timeline;let v=g,b=s.mediaSequence||0,_;typeof e.firstOffset=="bigint"?_=he.BigInt(u)+e.firstOffset:_=u+e.firstOffset;for(let S=0;S<d.length;S++){const D=e.references[S],R=D.referencedSize,L=D.subsegmentDuration;let M;typeof _=="bigint"?M=_+he.BigInt(R)-he.BigInt(1):M=_+R-1;const j=`${_}-${M}`,P=KA({baseUrl:t,timescale:c,timeline:r,periodStart:g,presentationTime:v,number:b,duration:L,sourceDuration:n,indexRange:j,type:p})[0];i&&(P.map=i),f.push(P),typeof _=="bigint"?_+=he.BigInt(R):_+=R,v+=L/c,b++}return s.segments=f,s},wP=["AUDIO","SUBTITLES"],AP=1/60,YA=s=>TP(s,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),CP=(s,e)=>{for(let t=0;t<s.length;t++)if(s[t].attributes.NAME===e)return s[t];return null},uE=s=>{let e=[];return fP(s,wP,(t,i,n,r)=>{e=e.concat(t.playlists||[])}),e},cE=({playlist:s,mediaSequence:e})=>{s.mediaSequence=e,s.segments.forEach((t,i)=>{t.number=s.mediaSequence+i})},kP=({oldPlaylists:s,newPlaylists:e,timelineStarts:t})=>{e.forEach(i=>{i.discontinuitySequence=t.findIndex(function({timeline:c}){return c===i.timeline});const n=CP(s,i.attributes.NAME);if(!n||i.sidx)return;const r=i.segments[0],o=n.segments.findIndex(function(c){return Math.abs(c.presentationTime-r.presentationTime)<AP});if(o===-1){cE({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[o].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),cE({playlist:i,mediaSequence:n.segments[o].number})})},DP=({oldManifest:s,newManifest:e})=>{const t=s.playlists.concat(uE(s)),i=e.playlists.concat(uE(e));return e.timelineStarts=YA([s.timelineStarts,e.timelineStarts]),kP({oldPlaylists:t,newPlaylists:i,timelineStarts:e.timelineStarts}),e},Gp=s=>s&&s.uri+"-"+_P(s.byterange),Oy=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=zA(i.reduce((r,o)=>{const u=o.attributes.id+(o.attributes.lang||"");return r[u]?(o.segments&&(o.segments[0]&&(o.segments[0].discontinuity=!0),r[u].segments.push(...o.segments)),o.attributes.contentProtection&&(r[u].attributes.contentProtection=o.attributes.contentProtection)):(r[u]=o,r[u].attributes.timelineStarts=[]),r[u].attributes.timelineStarts.push({start:o.attributes.periodStart,timeline:o.attributes.periodStart}),r},{}));t=t.concat(n)}),t.map(i=>(i.discontinuityStarts=bP(i.segments||[],"discontinuity"),i))},Qx=(s,e)=>{const t=Gp(s.sidx),i=t&&e[t]&&e[t].sidx;return i&&Xx(s,i,s.sidx.resolvedUri),s},LP=(s,e={})=>{if(!Object.keys(e).length)return s;for(const t in s)s[t]=Qx(s[t],e);return s},RP=({attributes:s,segments:e,sidx:t,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:r},o)=>{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),o&&(u.attributes.AUDIO="audio",u.attributes.SUBTITLES="subs"),u},IP=({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 o={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&&(o.attributes.serviceLocation=s.serviceLocation),o},NP=(s,e={},t=!1)=>{let i;const n=s.reduce((r,o)=>{const u=o.attributes.role&&o.attributes.role.value||"",c=o.attributes.lang||"";let d=o.attributes.label||"main";if(c&&!o.attributes.label){const p=u?` (${u})`:"";d=`${o.attributes.lang}${p}`}r[d]||(r[d]={language:c,autoselect:!0,default:u==="main",playlists:[],uri:""});const f=Qx(RP(o,t),e);return r[d].playlists.push(f),typeof i>"u"&&u==="main"&&(i=o,i.default=!0),r},{});if(!i){const r=Object.keys(n)[0];n[r].default=!0}return n},OP=(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(Qx(IP(i),e)),t},{}),MP=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),{}),PP=({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},BP=({attributes:s})=>s.mimeType==="video/mp4"||s.mimeType==="video/webm"||s.contentType==="video",FP=({attributes:s})=>s.mimeType==="audio/mp4"||s.mimeType==="audio/webm"||s.contentType==="audio",UP=({attributes:s})=>s.mimeType==="text/vtt"||s.contentType==="text",jP=(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})})},dE=s=>s?Object.keys(s).reduce((e,t)=>{const i=s[t];return e.concat(i.playlists)},[]):[],$P=({dashPlaylists:s,locations:e,contentSteering:t,sidxMapping:i={},previousManifest:n,eventStream:r})=>{if(!s.length)return{};const{sourceDuration:o,type:u,suggestedPresentationDelay:c,minimumUpdatePeriod:d}=s[0].attributes,f=Oy(s.filter(BP)).map(PP),p=Oy(s.filter(FP)),g=Oy(s.filter(UP)),v=s.map(M=>M.attributes.captionServices).filter(Boolean),b={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:o,playlists:LP(f,i)};d>=0&&(b.minimumUpdatePeriod=d*1e3),e&&(b.locations=e),t&&(b.contentSteering=t),u==="dynamic"&&(b.suggestedPresentationDelay=c),r&&r.length>0&&(b.eventStream=r);const _=b.playlists.length===0,S=p.length?NP(p,i,_):null,D=g.length?OP(g,i):null,R=f.concat(dE(S),dE(D)),L=R.map(({timelineStarts:M})=>M);return b.timelineStarts=YA(L),jP(R,b.timelineStarts),S&&(b.mediaGroups.AUDIO.audio=S),D&&(b.mediaGroups.SUBTITLES.subs=D),v.length&&(b.mediaGroups["CLOSED-CAPTIONS"].cc=MP(v)),n?DP({oldManifest:n,newManifest:b}):b},HP=(s,e,t)=>{const{NOW:i,clientOffset:n,availabilityStartTime:r,timescale:o=1,periodStart:u=0,minimumUpdatePeriod:c=0}=s,d=(i+n)/1e3,f=r+u,g=d+c-f;return Math.ceil((g*o-e)/t)},WA=(s,e)=>{const{type:t,minimumUpdatePeriod:i=0,media:n="",sourceDuration:r,timescale:o=1,startNumber:u=1,periodStart:c}=s,d=[];let f=-1;for(let p=0;p<e.length;p++){const g=e[p],v=g.d,b=g.r||0,_=g.t||0;f<0&&(f=_),_&&_>f&&(f=_);let S;if(b<0){const L=p+1;L===e.length?t==="dynamic"&&i>0&&n.indexOf("$Number$")>0?S=HP(s,f,v):S=(r*o-f)/v:S=(e[L].t-f)/v}else S=b+1;const D=u+d.length+S;let R=u+d.length;for(;R<D;)d.push({number:R,duration:v/o,time:f,timeline:c}),f+=v,R++}return d},VP=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,GP=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}`},hE=(s,e)=>s.replace(VP,GP(e)),zP=(s,e)=>!s.duration&&!e?[{number:s.startNumber||1,duration:s.sourceDuration,time:0,timeline:s.periodStart}]:s.duration?Wx(s):WA(s,e),qP=(s,e)=>{const t={RepresentationID:s.id,Bandwidth:s.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=s,n=ph({baseUrl:s.baseUrl,source:hE(i.sourceURL,t),range:i.range});return zP(s,e).map(o=>{t.Number=o.number,t.Time=o.time;const u=hE(s.media||"",t),c=s.timescale||1,d=s.presentationTimeOffset||0,f=s.periodStart+(o.time-d)/c;return{uri:u,timeline:o.timeline,duration:o.duration,resolvedUri:Hp(s.baseUrl||"",u),map:n,number:o.number,presentationTime:f}})},KP=(s,e)=>{const{baseUrl:t,initialization:i={}}=s,n=ph({baseUrl:t,source:i.sourceURL,range:i.range}),r=ph({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=n,r},YP=(s,e)=>{const{duration:t,segmentUrls:i=[],periodStart:n}=s;if(!t&&!e||t&&e)throw new Error(Sc.SEGMENT_TIME_UNSPECIFIED);const r=i.map(c=>KP(s,c));let o;return t&&(o=Wx(s)),e&&(o=WA(s,e)),o.map((c,d)=>{if(r[d]){const f=r[d],p=s.timescale||1,g=s.presentationTimeOffset||0;return f.timeline=c.timeline,f.duration=c.duration,f.number=c.number,f.presentationTime=n+(c.time-g)/p,f}}).filter(c=>c)},WP=({attributes:s,segmentInfo:e})=>{let t,i;e.template?(i=qP,t=Gs(s,e.template)):e.base?(i=KA,t=Gs(s,e.base)):e.list&&(i=YP,t=Gs(s,e.list));const n={attributes:s};if(!i)return n;const r=i(t,e.segmentTimeline);if(t.duration){const{duration:o,timescale:u=1}=t;t.duration=o/u}else r.length?t.duration=r.reduce((o,u)=>Math.max(o,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},XP=s=>s.map(WP),ss=(s,e)=>qA(s.childNodes).filter(({tagName:t})=>t===e),Lh=s=>s.textContent.trim(),QP=s=>parseFloat(s.split("/").reduce((e,t)=>e/t)),$u=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,p,g,v]=u.slice(1);return parseFloat(c||0)*31536e3+parseFloat(d||0)*2592e3+parseFloat(f||0)*86400+parseFloat(p||0)*3600+parseFloat(g||0)*60+parseFloat(v||0)},ZP=s=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(s)&&(s+="Z"),Date.parse(s)),fE={mediaPresentationDuration(s){return $u(s)},availabilityStartTime(s){return ZP(s)/1e3},minimumUpdatePeriod(s){return $u(s)},suggestedPresentationDelay(s){return $u(s)},type(s){return s},timeShiftBufferDepth(s){return $u(s)},start(s){return $u(s)},width(s){return parseInt(s,10)},height(s){return parseInt(s,10)},bandwidth(s){return parseInt(s,10)},frameRate(s){return QP(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)?$u(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}},Ds=s=>s&&s.attributes?qA(s.attributes).reduce((e,t)=>{const i=fE[t.name]||fE.DEFAULT;return e[t.name]=i(t.value),e},{}):{},JP={"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"},zp=(s,e)=>e.length?_c(s.map(function(t){return e.map(function(i){const n=Lh(i),r=Hp(t.baseUrl,n),o=Gs(Ds(i),{baseUrl:r});return r!==n&&!o.serviceLocation&&t.serviceLocation&&(o.serviceLocation=t.serviceLocation),o})})):s,Zx=s=>{const e=ss(s,"SegmentTemplate")[0],t=ss(s,"SegmentList")[0],i=t&&ss(t,"SegmentURL").map(p=>Gs({tag:"SegmentURL"},Ds(p))),n=ss(s,"SegmentBase")[0],r=t||e,o=r&&ss(r,"SegmentTimeline")[0],u=t||n||e,c=u&&ss(u,"Initialization")[0],d=e&&Ds(e);d&&c?d.initialization=c&&Ds(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});const f={template:d,segmentTimeline:o&&ss(o,"S").map(p=>Ds(p)),list:t&&Gs(Ds(t),{segmentUrls:i,initialization:Ds(c)}),base:n&&Gs(Ds(n),{initialization:Ds(c)})};return Object.keys(f).forEach(p=>{f[p]||delete f[p]}),f},e3=(s,e,t)=>i=>{const n=ss(i,"BaseURL"),r=zp(e,n),o=Gs(s,Ds(i)),u=Zx(i);return r.map(c=>({segmentInfo:Gs(t,u),attributes:Gs(o,c)}))},t3=s=>s.reduce((e,t)=>{const i=Ds(t);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());const n=JP[i.schemeIdUri];if(n){e[n]={attributes:i};const r=ss(t,"cenc:pssh")[0];if(r){const o=Lh(r);e[n].pssh=o&&FA(o)}}return e},{}),i3=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(o=>{const[u,c]=o.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})},s3=s=>_c(ss(s.node,"EventStream").map(e=>{const t=Ds(e),i=t.schemeIdUri;return ss(e,"Event").map(n=>{const r=Ds(n),o=r.presentationTime||0,u=t.timescale||1,c=r.duration||0,d=o/u+s.attributes.start;return{schemeIdUri:i,value:t.value,id:r.id,start:d,end:d+c/u,messageData:Lh(n)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),n3=(s,e,t)=>i=>{const n=Ds(i),r=zp(e,ss(i,"BaseURL")),o=ss(i,"Role")[0],u={role:Ds(o)};let c=Gs(s,n,u);const d=ss(i,"Accessibility")[0],f=i3(Ds(d));f&&(c=Gs(c,{captionServices:f}));const p=ss(i,"Label")[0];if(p&&p.childNodes.length){const S=p.childNodes[0].nodeValue.trim();c=Gs(c,{label:S})}const g=t3(ss(i,"ContentProtection"));Object.keys(g).length&&(c=Gs(c,{contentProtection:g}));const v=Zx(i),b=ss(i,"Representation"),_=Gs(t,v);return _c(b.map(e3(c,r,_)))},r3=(s,e)=>(t,i)=>{const n=zp(e,ss(t.node,"BaseURL")),r=Gs(s,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const o=ss(t.node,"AdaptationSet"),u=Zx(t.node);return _c(o.map(n3(r,n,u)))},a3=(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=Gs({serverURL:Lh(s[0])},Ds(s[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},o3=({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,l3=(s,e={})=>{const{manifestUri:t="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:r=function(){}}=e,o=ss(s,"Period");if(!o.length)throw new Error(Sc.INVALID_NUMBER_OF_PERIOD);const u=ss(s,"Location"),c=Ds(s),d=zp([{baseUrl:t}],ss(s,"BaseURL")),f=ss(s,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=i,c.clientOffset=n,u.length&&(c.locations=u.map(Lh));const p=[];return o.forEach((g,v)=>{const b=Ds(g),_=p[v-1];b.start=o3({attributes:b,priorPeriodAttributes:_?_.attributes:null,mpdType:c.type}),p.push({node:g,attributes:b})}),{locations:c.locations,contentSteeringInfo:a3(f,r),representationInfo:_c(p.map(r3(c,d))),eventStream:_c(p.map(s3))}},XA=s=>{if(s==="")throw new Error(Sc.DASH_EMPTY_MANIFEST);const e=new vP.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(Sc.DASH_INVALID_XML);return i},u3=s=>{const e=ss(s,"UTCTiming")[0];if(!e)return null;const t=Ds(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(Sc.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},c3=(s,e={})=>{const t=l3(XA(s),e),i=XP(t.representationInfo);return $P({dashPlaylists:i,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},d3=s=>u3(XA(s));var My,mE;function h3(){if(mE)return My;mE=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 My={getUint64:e,MAX_UINT32:s},My}var Py,pE;function f3(){if(pE)return Py;pE=1;var s=h3().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 o=i.getUint16(r);for(r+=2;o>0;r+=12,o--)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 Py=e,Py}var m3=f3();const p3=Nc(m3);var g3=Pt([73,68,51]),y3=function(e,t){t===void 0&&(t=0),e=Pt(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},Qd=function s(e,t){return t===void 0&&(t=0),e=Pt(e),e.length-t<10||!is(e,g3,{offset:t})?t:(t+=y3(e,t),s(e,t))},gE=function(e){return typeof e=="string"?VA(e):e},v3=function(e){return Array.isArray(e)?e.map(function(t){return gE(t)}):[gE(e)]},x3=function s(e,t,i){i===void 0&&(i=!1),t=v3(t),e=Pt(e);var n=[];if(!t.length)return n;for(var r=0;r<e.length;){var o=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,u=e.subarray(r+4,r+8);if(o===0)break;var c=r+o;if(c>e.length){if(i)break;c=e.length}var d=e.subarray(r+8,c);is(u,t[0])&&(t.length===1?n.push(d):n.push.apply(n,s(d,t.slice(1),i))),r=c}return n},dm={EBML:Pt([26,69,223,163]),DocType:Pt([66,130]),Segment:Pt([24,83,128,103]),SegmentInfo:Pt([21,73,169,102]),Tracks:Pt([22,84,174,107]),Track:Pt([174]),TrackNumber:Pt([215]),DefaultDuration:Pt([35,227,131]),TrackEntry:Pt([174]),TrackType:Pt([131]),FlagDefault:Pt([136]),CodecID:Pt([134]),CodecPrivate:Pt([99,162]),VideoTrack:Pt([224]),AudioTrack:Pt([225]),Cluster:Pt([31,67,182,117]),Timestamp:Pt([231]),TimestampScale:Pt([42,215,177]),BlockGroup:Pt([160]),BlockDuration:Pt([155]),Block:Pt([161]),SimpleBlock:Pt([163])},zv=[128,64,32,16,8,4,2,1],b3=function(e){for(var t=1,i=0;i<zv.length&&!(e&zv[i]);i++)t++;return t},Jm=function(e,t,i,n){i===void 0&&(i=!0),n===void 0&&(n=!1);var r=b3(e[t]),o=e.subarray(t,t+r);return i&&(o=Array.prototype.slice.call(e,t,t+r),o[0]^=zv[r-1]),{length:r,value:cP(o,{signed:n}),bytes:o}},yE=function s(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return s(t)}):typeof e=="number"?dP(e):e},T3=function(e){return Array.isArray(e)?e.map(function(t){return yE(t)}):[yE(e)]},_3=function s(e,t,i){if(i>=t.length)return t.length;var n=Jm(t,i,!1);if(is(e.bytes,n.bytes))return i;var r=Jm(t,i+n.length);return s(e,t,i+r.length+r.value+n.length)},vE=function s(e,t){t=T3(t),e=Pt(e);var i=[];if(!t.length)return i;for(var n=0;n<e.length;){var r=Jm(e,n,!1),o=Jm(e,n+r.length),u=n+r.length+o.length;o.value===127&&(o.value=_3(r,e,u),o.value!==e.length&&(o.value-=u));var c=u+o.value>e.length?e.length:u+o.value,d=e.subarray(u,c);is(t[0],r.bytes)&&(t.length===1?i.push(d):i=i.concat(s(d,t.slice(1))));var f=r.length+o.length+d.length;n+=f}return i},S3=Pt([0,0,0,1]),E3=Pt([0,0,1]),w3=Pt([0,0,3]),A3=function(e){for(var t=[],i=1;i<e.length-2;)is(e.subarray(i,i+3),w3)&&(t.push(i+2),i++),i++;if(t.length===0)return e;var n=e.length-t.length,r=new Uint8Array(n),o=0;for(i=0;i<n;o++,i++)o===t[0]&&(o++,t.shift()),r[i]=e[o];return r},QA=function(e,t,i,n){e=Pt(e),i=[].concat(i);for(var r=0,o,u=0;r<e.length&&(u<n||o);){var c=void 0;if(is(e.subarray(r),S3)?c=4:is(e.subarray(r),E3)&&(c=3),!c){r++;continue}if(u++,o)return A3(e.subarray(o,r));var d=void 0;t==="h264"?d=e[r+c]&31:t==="h265"&&(d=e[r+c]>>1&63),i.indexOf(d)!==-1&&(o=r+c),r+=c+(t==="h264"?1:2)}return e.subarray(0,0)},C3=function(e,t,i){return QA(e,"h264",t,i)},k3=function(e,t,i){return QA(e,"h265",t,i)},mn={webm:Pt([119,101,98,109]),matroska:Pt([109,97,116,114,111,115,107,97]),flac:Pt([102,76,97,67]),ogg:Pt([79,103,103,83]),ac3:Pt([11,119]),riff:Pt([82,73,70,70]),avi:Pt([65,86,73]),wav:Pt([87,65,86,69]),"3gp":Pt([102,116,121,112,51,103]),mp4:Pt([102,116,121,112]),fmp4:Pt([115,116,121,112]),mov:Pt([102,116,121,112,113,116]),moov:Pt([109,111,111,118]),moof:Pt([109,111,111,102])},Ec={aac:function(e){var t=Qd(e);return is(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=Qd(e);return is(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=vE(e,[dm.EBML,dm.DocType])[0];return is(t,mn.webm)},mkv:function(e){var t=vE(e,[dm.EBML,dm.DocType])[0];return is(t,mn.matroska)},mp4:function(e){if(Ec["3gp"](e)||Ec.mov(e))return!1;if(is(e,mn.mp4,{offset:4})||is(e,mn.fmp4,{offset:4})||is(e,mn.moof,{offset:4})||is(e,mn.moov,{offset:4}))return!0},mov:function(e){return is(e,mn.mov,{offset:4})},"3gp":function(e){return is(e,mn["3gp"],{offset:4})},ac3:function(e){var t=Qd(e);return is(e,mn.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=Qd(e);return is(e,mn.flac,{offset:t})},ogg:function(e){return is(e,mn.ogg)},avi:function(e){return is(e,mn.riff)&&is(e,mn.avi,{offset:8})},wav:function(e){return is(e,mn.riff)&&is(e,mn.wav,{offset:8})},h264:function(e){return C3(e,7,3).length},h265:function(e){return k3(e,[32,33],3).length}},qv=Object.keys(Ec).filter(function(s){return s!=="ts"&&s!=="h264"&&s!=="h265"}).concat(["ts","h264","h265"]);qv.forEach(function(s){var e=Ec[s];Ec[s]=function(t){return e(Pt(t))}});var D3=Ec,Jx=function(e){e=Pt(e);for(var t=0;t<qv.length;t++){var i=qv[t];if(D3[i](e))return i}return""},L3=function(e){return x3(e,["moof"]).length>0},By,xE;function R3(){if(xE)return By;xE=1;var s=9e4,e,t,i,n,r,o,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))},o=function(c,d){return t(i(c),d)},u=function(c,d,f){return i(f?c:c-d)},By={ONE_SECOND_IN_TS:s,secondsToVideoTs:e,secondsToAudioTs:t,videoTsToSeconds:i,audioTsToSeconds:n,audioTsToVideoTs:r,videoTsToAudioTs:o,metadataTsToSeconds:u},By}var Gl=R3();var Kv="8.23.4";const qa={},el=function(s,e){return qa[s]=qa[s]||[],e&&(qa[s]=qa[s].concat(e)),qa[s]},I3=function(s,e){el(s,e)},ZA=function(s,e){const t=el(s).indexOf(e);return t<=-1?!1:(qa[s]=qa[s].slice(),qa[s].splice(t,1),!0)},N3=function(s,e){el(s,[].concat(e).map(t=>{const i=(...n)=>(ZA(s,i),t(...n));return i}))},ep={prefixed:!0},Om=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],bE=Om[0];let Zd;for(let s=0;s<Om.length;s++)if(Om[s][1]in rt){Zd=Om[s];break}if(Zd){for(let s=0;s<Zd.length;s++)ep[bE[s]]=Zd[s];ep.prefixed=Zd[0]!==bE[0]}let Nn=[];const O3=(s,e,t)=>(i,n,r)=>{const o=e.levels[n],u=new RegExp(`^(${o})$`);let c=s;if(i!=="log"&&r.unshift(i.toUpperCase()+":"),t&&(c=`%c${s}`,r.unshift(t)),r.unshift(c+":"),Nn){Nn.push([].concat(r));const f=Nn.length-1e3;Nn.splice(0,f>0?f:0)}if(!he.console)return;let d=he.console[i];!d&&i==="debug"&&(d=he.console.info||he.console.log),!(!d||!o||!u.test(i))&&d[Array.isArray(r)?"apply":"call"](he.console,r)};function Yv(s,e=":",t=""){let i="info",n;function r(...o){n("log",i,o)}return n=O3(s,r,t),r.createLogger=(o,u,c)=>{const d=u!==void 0?u:e,f=c!==void 0?c:t,p=`${s} ${d} ${o}`;return Yv(p,d,f)},r.createNewLogger=(o,u,c)=>Yv(o,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=o=>{if(typeof o=="string"){if(!r.levels.hasOwnProperty(o))throw new Error(`"${o}" in not a valid log level`);i=o}return i},r.history=()=>Nn?[].concat(Nn):[],r.history.filter=o=>(Nn||[]).filter(u=>new RegExp(`.*${o}.*`).test(u[0])),r.history.clear=()=>{Nn&&(Nn.length=0)},r.history.disable=()=>{Nn!==null&&(Nn.length=0,Nn=null)},r.history.enable=()=>{Nn===null&&(Nn=[])},r.error=(...o)=>n("error",i,o),r.warn=(...o)=>n("warn",i,o),r.debug=(...o)=>n("debug",i,o),r}const si=Yv("VIDEOJS"),JA=si.createLogger,M3=Object.prototype.toString,eC=function(s){return fa(s)?Object.keys(s):[]};function nc(s,e){eC(s).forEach(t=>e(s[t],t))}function tC(s,e,t=0){return eC(s).reduce((i,n)=>e(i,s[n],n),t)}function fa(s){return!!s&&typeof s=="object"}function wc(s){return fa(s)&&M3.call(s)==="[object Object]"&&s.constructor===Object}function Pi(...s){const e={};return s.forEach(t=>{t&&nc(t,(i,n)=>{if(!wc(i)){e[n]=i;return}wc(e[n])||(e[n]={}),e[n]=Pi(e[n],i)})}),e}function iC(s={}){const e=[];for(const t in s)if(s.hasOwnProperty(t)){const i=s[t];e.push(i)}return e}function qp(s,e,t,i=!0){const n=o=>Object.defineProperty(s,e,{value:o,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const o=t();return n(o),o}};return i&&(r.set=n),Object.defineProperty(s,e,r)}var P3=Object.freeze({__proto__:null,each:nc,reduce:tC,isObject:fa,isPlain:wc,merge:Pi,values:iC,defineLazyProperty:qp});let eb=!1,sC=null,Ir=!1,nC,rC=!1,rc=!1,ac=!1,ma=!1,tb=null,Kp=null;const B3=!!(he.cast&&he.cast.framework&&he.cast.framework.CastReceiverContext);let aC=null,tp=!1,Yp=!1,ip=!1,Wp=!1,sp=!1,np=!1,rp=!1;const gh=!!(Oc()&&("ontouchstart"in he||he.navigator.maxTouchPoints||he.DocumentTouch&&he.document instanceof he.DocumentTouch)),Uo=he.navigator&&he.navigator.userAgentData;Uo&&Uo.platform&&Uo.brands&&(Ir=Uo.platform==="Android",rc=!!Uo.brands.find(s=>s.brand==="Microsoft Edge"),ac=!!Uo.brands.find(s=>s.brand==="Chromium"),ma=!rc&&ac,tb=Kp=(Uo.brands.find(s=>s.brand==="Chromium")||{}).version||null,Yp=Uo.platform==="Windows");if(!ac){const s=he.navigator&&he.navigator.userAgent||"";eb=/iPod/i.test(s),sC=(function(){const e=s.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null})(),Ir=/Android/i.test(s),nC=(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})(),rC=/Firefox/i.test(s),rc=/Edg/i.test(s),ac=/Chrome/i.test(s)||/CriOS/i.test(s),ma=!rc&&ac,tb=Kp=(function(){const e=s.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null})(),aC=(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})(),sp=/Tizen/i.test(s),np=/Web0S/i.test(s),rp=sp||np,tp=/Safari/i.test(s)&&!ma&&!Ir&&!rc&&!rp,Yp=/Windows/i.test(s),ip=/iPad/i.test(s)||tp&&gh&&!/iPhone/i.test(s),Wp=/iPhone/i.test(s)&&!ip}const an=Wp||ip||eb,Xp=(tp||an)&&!ma;var oC=Object.freeze({__proto__:null,get IS_IPOD(){return eb},get IOS_VERSION(){return sC},get IS_ANDROID(){return Ir},get ANDROID_VERSION(){return nC},get IS_FIREFOX(){return rC},get IS_EDGE(){return rc},get IS_CHROMIUM(){return ac},get IS_CHROME(){return ma},get CHROMIUM_VERSION(){return tb},get CHROME_VERSION(){return Kp},IS_CHROMECAST_RECEIVER:B3,get IE_VERSION(){return aC},get IS_SAFARI(){return tp},get IS_WINDOWS(){return Yp},get IS_IPAD(){return ip},get IS_IPHONE(){return Wp},get IS_TIZEN(){return sp},get IS_WEBOS(){return np},get IS_SMART_TV(){return rp},TOUCH_ENABLED:gh,IS_IOS:an,IS_ANY_SAFARI:Xp});function TE(s){return typeof s=="string"&&!!s.trim()}function F3(s){if(s.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function Oc(){return rt===he.document}function Mc(s){return fa(s)&&s.nodeType===1}function lC(){try{return he.parent!==he.self}catch{return!0}}function uC(s){return function(e,t){if(!TE(e))return rt[s](null);TE(t)&&(t=rt.querySelector(t));const i=Mc(t)?t:rt;return i[s]&&i[s](e)}}function Vt(s="div",e={},t={},i){const n=rt.createElement(s);return Object.getOwnPropertyNames(e).forEach(function(r){const o=e[r];r==="textContent"?nl(n,o):(n[r]!==o||r==="tabIndex")&&(n[r]=o)}),Object.getOwnPropertyNames(t).forEach(function(r){n.setAttribute(r,t[r])}),i&&ib(n,i),n}function nl(s,e){return typeof s.textContent>"u"?s.innerText=e:s.textContent=e,s}function Wv(s,e){e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}function ah(s,e){return F3(e),s.classList.contains(e)}function Kl(s,...e){return s.classList.add(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s}function Qp(s,...e){return s?(s.classList.remove(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s):(si.warn("removeClass was called with an element that doesn't exist"),null)}function cC(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 dC(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 zo(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 o=i[n].value;t.includes(r)&&(o=o!==null),e[r]=o}}return e}function hC(s,e){return s.getAttribute(e)}function Ac(s,e,t){s.setAttribute(e,t)}function Zp(s,e){s.removeAttribute(e)}function fC(){rt.body.focus(),rt.onselectstart=function(){return!1}}function mC(){rt.onselectstart=function(){return!0}}function Cc(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(kc(s,"height"))),t.width||(t.width=parseFloat(kc(s,"width"))),t}}function yh(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!==rt[ep.fullscreenElement];)i+=s.offsetLeft,n+=s.offsetTop,s=s.offsetParent;return{left:i,top:n,width:e,height:t}}function Jp(s,e){const t={x:0,y:0};if(an){let f=s;for(;f&&f.nodeName.toLowerCase()!=="html";){const p=kc(f,"transform");if(/^matrix/.test(p)){const g=p.slice(7,-1).split(/,\s/).map(Number);t.x+=g[4],t.y+=g[5]}else if(/^matrix3d/.test(p)){const g=p.slice(9,-1).split(/,\s/).map(Number);t.x+=g[12],t.y+=g[13]}if(f.assignedSlot&&f.assignedSlot.parentElement&&he.WebKitCSSMatrix){const g=he.getComputedStyle(f.assignedSlot.parentElement).transform,v=new he.WebKitCSSMatrix(g);t.x+=v.m41,t.y+=v.m42}f=f.parentNode||f.host}}const i={},n=yh(e.target),r=yh(s),o=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,an&&(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/o)),i}function pC(s){return fa(s)&&s.nodeType===3}function eg(s){for(;s.firstChild;)s.removeChild(s.firstChild);return s}function gC(s){return typeof s=="function"&&(s=s()),(Array.isArray(s)?s:[s]).map(e=>{if(typeof e=="function"&&(e=e()),Mc(e)||pC(e))return e;if(typeof e=="string"&&/\S/.test(e))return rt.createTextNode(e)}).filter(e=>e)}function ib(s,e){return gC(e).forEach(t=>s.appendChild(t)),s}function yC(s,e){return ib(eg(s),e)}function vh(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 tl=uC("querySelector"),vC=uC("querySelectorAll");function kc(s,e){if(!s||!e)return"";if(typeof he.getComputedStyle=="function"){let t;try{t=he.getComputedStyle(s)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function xC(s){[...rt.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(n=>n.cssText).join(""),i=rt.createElement("style");i.textContent=t,s.document.head.appendChild(i)}catch{const i=rt.createElement("link");i.rel="stylesheet",i.type=e.type,i.media=e.media.mediaText,i.href=e.href,s.document.head.appendChild(i)}})}var bC=Object.freeze({__proto__:null,isReal:Oc,isEl:Mc,isInFrame:lC,createEl:Vt,textContent:nl,prependTo:Wv,hasClass:ah,addClass:Kl,removeClass:Qp,toggleClass:cC,setAttributes:dC,getAttributes:zo,getAttribute:hC,setAttribute:Ac,removeAttribute:Zp,blockTextSelection:fC,unblockTextSelection:mC,getBoundingClientRect:Cc,findPosition:yh,getPointerPosition:Jp,isTextNode:pC,emptyEl:eg,normalizeContent:gC,appendContent:ib,insertContent:yC,isSingleLeftClick:vh,$:tl,$$:vC,computedStyle:kc,copyStyleSheetsToWindow:xC});let TC=!1,Xv;const U3=function(){if(Xv.options.autoSetup===!1)return;const s=Array.prototype.slice.call(rt.getElementsByTagName("video")),e=Array.prototype.slice.call(rt.getElementsByTagName("audio")),t=Array.prototype.slice.call(rt.getElementsByTagName("video-js")),i=s.concat(e,t);if(i&&i.length>0)for(let n=0,r=i.length;n<r;n++){const o=i[n];if(o&&o.getAttribute)o.player===void 0&&o.getAttribute("data-setup")!==null&&Xv(o);else{Qv(1);break}}else TC||Qv(1)};function Qv(s,e){Oc()&&(e&&(Xv=e),he.setTimeout(U3,s))}function Zv(){TC=!0,he.removeEventListener("load",Zv)}Oc()&&(rt.readyState==="complete"?Zv():he.addEventListener("load",Zv));const _C=function(s){const e=rt.createElement("style");return e.className=s,e},SC=function(s,e){s.styleSheet?s.styleSheet.cssText=e:s.textContent=e};var yn=new WeakMap;const j3=3;let $3=j3;function hr(){return $3++}function _E(s,e){if(!yn.has(s))return;const t=yn.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&&yn.delete(s)}function sb(s,e,t,i){t.forEach(function(n){s(e,n,i)})}function tg(s){if(s.fixed_)return s;function e(){return!0}function t(){return!1}if(!s||!s.isPropagationStopped||!s.isImmediatePropagationStopped){const i=s||he.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||rt),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=rt.documentElement,o=rt.body;s.pageX=s.clientX+(r&&r.scrollLeft||o&&o.scrollLeft||0)-(r&&r.clientLeft||o&&o.clientLeft||0),s.pageY=s.clientY+(r&&r.scrollTop||o&&o.scrollTop||0)-(r&&r.clientTop||o&&o.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 hm;const H3=function(){if(typeof hm!="boolean"){hm=!1;try{const s=Object.defineProperty({},"passive",{get(){hm=!0}});he.addEventListener("test",null,s),he.removeEventListener("test",null,s)}catch{}}return hm},V3=["touchstart","touchmove"];function sr(s,e,t){if(Array.isArray(e))return sb(sr,s,e,t);yn.has(s)||yn.set(s,{});const i=yn.get(s);if(i.handlers||(i.handlers={}),i.handlers[e]||(i.handlers[e]=[]),t.guid||(t.guid=hr()),i.handlers[e].push(t),i.dispatcher||(i.disabled=!1,i.dispatcher=function(n,r){if(i.disabled)return;n=tg(n);const o=i.handlers[n.type];if(o){const u=o.slice(0);for(let c=0,d=u.length;c<d&&!n.isImmediatePropagationStopped();c++)try{u[c].call(s,n,r)}catch(f){si.error(f)}}}),i.handlers[e].length===1)if(s.addEventListener){let n=!1;H3()&&V3.indexOf(e)>-1&&(n={passive:!0}),s.addEventListener(e,i.dispatcher,n)}else s.attachEvent&&s.attachEvent("on"+e,i.dispatcher)}function on(s,e,t){if(!yn.has(s))return;const i=yn.get(s);if(!i.handlers)return;if(Array.isArray(e))return sb(on,s,e,t);const n=function(o,u){i.handlers[u]=[],_E(o,u)};if(e===void 0){for(const o in i.handlers)Object.prototype.hasOwnProperty.call(i.handlers||{},o)&&n(s,o);return}const r=i.handlers[e];if(r){if(!t){n(s,e);return}if(t.guid)for(let o=0;o<r.length;o++)r[o].guid===t.guid&&r.splice(o--,1);_E(s,e)}}function Pc(s,e,t){const i=yn.has(s)?yn.get(s):{},n=s.parentNode||s.ownerDocument;if(typeof e=="string"?e={type:e,target:s}:e.target||(e.target=s),e=tg(e),i.dispatcher&&i.dispatcher.call(s,e,t),n&&!e.isPropagationStopped()&&e.bubbles===!0)Pc.call(null,n,e,t);else if(!n&&!e.defaultPrevented&&e.target&&e.target[e.type]){yn.has(e.target)||yn.set(e.target,{});const r=yn.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 ig(s,e,t){if(Array.isArray(e))return sb(ig,s,e,t);const i=function(){on(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||hr(),sr(s,e,i)}function nb(s,e,t){const i=function(){on(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||hr(),sr(s,e,i)}var G3=Object.freeze({__proto__:null,fixEvent:tg,on:sr,off:on,trigger:Pc,one:ig,any:nb});const fr=30,Yi=function(s,e,t){e.guid||(e.guid=hr());const i=e.bind(s);return i.guid=t?t+"_"+e.guid:e.guid,i},pa=function(s,e){let t=he.performance.now();return function(...n){const r=he.performance.now();r-t>=e&&(s(...n),t=r)}},EC=function(s,e,t,i=he){let n;const r=()=>{i.clearTimeout(n),n=null},o=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 o.cancel=r,o};var z3=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:fr,bind_:Yi,throttle:pa,debounce:EC});let Hd;class nr{on(e,t){const i=this.addEventListener;this.addEventListener=()=>{},sr(this,e,t),this.addEventListener=i}off(e,t){on(this,e,t)}one(e,t){const i=this.addEventListener;this.addEventListener=()=>{},ig(this,e,t),this.addEventListener=i}any(e,t){const i=this.addEventListener;this.addEventListener=()=>{},nb(this,e,t),this.addEventListener=i}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=tg(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),Pc(this,e)}queueTrigger(e){Hd||(Hd=new Map);const t=e.type||e;let i=Hd.get(this);i||(i=new Map,Hd.set(this,i));const n=i.get(t);i.delete(t),he.clearTimeout(n);const r=he.setTimeout(()=>{i.delete(t),i.size===0&&(i=null,Hd.delete(this)),this.trigger(e)},0);i.set(t,r)}}nr.prototype.allowedEvents_={};nr.prototype.addEventListener=nr.prototype.on;nr.prototype.removeEventListener=nr.prototype.off;nr.prototype.dispatchEvent=nr.prototype.trigger;const sg=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,Wa=s=>s instanceof nr||!!s.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof s[e]=="function"),q3=(s,e)=>{Wa(s)?e():(s.eventedCallbacks||(s.eventedCallbacks=[]),s.eventedCallbacks.push(e))},Jv=s=>typeof s=="string"&&/\S/.test(s)||Array.isArray(s)&&!!s.length,ap=(s,e,t)=>{if(!s||!s.nodeName&&!Wa(s))throw new Error(`Invalid target for ${sg(e)}#${t}; must be a DOM node or evented object.`)},wC=(s,e,t)=>{if(!Jv(s))throw new Error(`Invalid event type for ${sg(e)}#${t}; must be a non-empty string or array.`)},AC=(s,e,t)=>{if(typeof s!="function")throw new Error(`Invalid listener for ${sg(e)}#${t}; must be a function.`)},Fy=(s,e,t)=>{const i=e.length<3||e[0]===s||e[0]===s.eventBusEl_;let n,r,o;return i?(n=s.eventBusEl_,e.length>=3&&e.shift(),[r,o]=e):(n=e[0],r=e[1],o=e[2]),ap(n,s,t),wC(r,s,t),AC(o,s,t),o=Yi(s,o),{isTargetingSelf:i,target:n,type:r,listener:o}},Nl=(s,e,t,i)=>{ap(s,s,e),s.nodeName?G3[e](s,t,i):s[e](t,i)},K3={on(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Fy(this,s,"on");if(Nl(t,"on",i,n),!e){const r=()=>this.off(t,i,n);r.guid=n.guid;const o=()=>this.off("dispose",r);o.guid=n.guid,Nl(this,"on","dispose",r),Nl(t,"on","dispose",o)}},one(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Fy(this,s,"one");if(e)Nl(t,"one",i,n);else{const r=(...o)=>{this.off(t,i,r),n.apply(null,o)};r.guid=n.guid,Nl(t,"one",i,r)}},any(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Fy(this,s,"any");if(e)Nl(t,"any",i,n);else{const r=(...o)=>{this.off(t,i,r),n.apply(null,o)};r.guid=n.guid,Nl(t,"any",i,r)}},off(s,e,t){if(!s||Jv(s))on(this.eventBusEl_,s,e);else{const i=s,n=e;ap(i,this,"off"),wC(n,this,"off"),AC(t,this,"off"),t=Yi(this,t),this.off("dispose",t),i.nodeName?(on(i,n,t),on(i,"dispose",t)):Wa(i)&&(i.off(n,t),i.off("dispose",t))}},trigger(s,e){ap(this.eventBusEl_,this,"trigger");const t=s&&typeof s!="string"?s.type:s;if(!Jv(t))throw new Error(`Invalid event type for ${sg(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return Pc(this.eventBusEl_,s,e)}};function rb(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_=Vt("span",{className:"vjs-event-bus"});return Object.assign(s,K3),s.eventedCallbacks&&s.eventedCallbacks.forEach(i=>{i()}),s.on("dispose",()=>{s.off(),[s,s.el_,s.eventBusEl_].forEach(function(i){i&&yn.has(i)&&yn.delete(i)}),he.setTimeout(()=>{s.eventBusEl_=null},0)}),s}const Y3={state:{},setState(s){typeof s=="function"&&(s=s());let e;return nc(s,(t,i)=>{this.state[i]!==t&&(e=e||{},e[i]={from:this.state[i],to:t}),this.state[i]=t}),e&&Wa(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function CC(s,e){return Object.assign(s,Y3),s.state=Object.assign({},s.state,e),typeof s.handleStateChanged=="function"&&Wa(s)&&s.on("statechanged",s.handleStateChanged),s}const oh=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toLowerCase())},ys=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},kC=function(s,e){return ys(s)===ys(e)};var W3=Object.freeze({__proto__:null,toLowerCase:oh,toTitleCase:ys,titleCaseEquals:kC});class Fe{constructor(e,t,i){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=Pi({},this.options_),t=this.options_=Pi(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_${hr()}`}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&&(rb(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),CC(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_=Pi(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,i){return Vt(e,t,i)}localize(e,t,i=e){const n=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),o=r&&r[n],u=n&&n.split("-")[0],c=r&&r[u];let d=i;return o&&o[e]?d=o[e]:c&&c[e]&&(d=c[e]),t&&(d=d.replace(/\{(\d+)\}/g,function(f,p){const g=t[p-1];let v=g;return typeof g>"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=Vt("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=rt.createElementNS(i,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const o=rt.createElementNS(i,"use");return r.appendChild(o),o.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=ys(e);const o=t.componentClass||r;t.name=r;const u=Fe.getComponent(o);if(!u)throw new Error(`Component ${o} 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&&ys(n.name()),r&&(this.childNameIndex_[r]=n,this.childNameIndex_[oh(r)]=n),typeof n.el=="function"&&n.el()){let o=null;this.children_[i+1]&&(this.children_[i+1].el_?o=this.children_[i+1].el_:Mc(this.children_[i+1])&&(o=this.children_[i+1])),this.contentEl().insertBefore(n.el(),o)}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_[ys(e.name())]=null,this.childNameIndex_[oh(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=o=>{const u=o.name;let c=o.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=Fe.getComponent("Tech");Array.isArray(e)?n=e:n=Object.keys(e),n.concat(Object.keys(this.options_).filter(function(o){return!n.some(function(u){return typeof u=="string"?o===u:o===u.name})})).map(o=>{let u,c;return typeof o=="string"?(u=o,c=e[u]||this.options_[u]||{}):(u=o.name,c=o),{name:u,opts:c}}).filter(o=>{const u=Fe.getComponent(o.opts.componentClass||ys(o.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 tl(e,t||this.contentEl())}$$(e,t){return vC(e,t||this.contentEl())}hasClass(e){return ah(this.el_,e)}addClass(...e){Kl(this.el_,...e)}removeClass(...e){Qp(this.el_,...e)}toggleClass(e,t){cC(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 hC(this.el_,e)}setAttribute(e,t){Ac(this.el_,e,t)}removeAttribute(e){Zp(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"+ys(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=kc(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const i=`offset${ys(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=he.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 o=function(){r=!1};this.on("touchleave",o),this.on("touchcancel",o),this.on("touchend",function(u){t=null,r===!0&&he.performance.now()-e<n&&(u.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=Yi(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=Yi(this,e),this.clearTimersOnDispose_(),i=he.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),he.clearTimeout(e)),e}setInterval(e,t){e=Yi(this,e),this.clearTimersOnDispose_();const i=he.setInterval(e,t);return this.setIntervalIds_.add(i),i}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),he.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=Yi(this,e),t=he.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=Yi(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),he.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 o=he.getComputedStyle(r,null),u=o.getPropertyValue("visibility");return o.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(u)}function i(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||he.getComputedStyle(r).height==="0px"||he.getComputedStyle(r).width==="0px")}function n(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const o={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(o.x<0||o.x>(rt.documentElement.clientWidth||he.innerWidth)||o.y<0||o.y>(rt.documentElement.clientHeight||he.innerHeight))return!1;let u=rt.elementFromPoint(o.x,o.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=Fe.getComponent("Tech"),n=i&&i.isTech(t),r=Fe===t||Fe.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=ys(e),Fe.components_||(Fe.components_={});const o=Fe.getComponent("Player");if(e==="Player"&&o&&o.players){const u=o.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 Fe.components_[e]=t,Fe.components_[oh(e)]=t,t}static getComponent(e){if(!(!e||!Fe.components_))return Fe.components_[e]}}Fe.registerComponent("Component",Fe);function X3(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 SE(s,e,t,i){return X3(s,i,t.length-1),t[i][e]}function Uy(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:SE.bind(null,"start",0,s),end:SE.bind(null,"end",1,s)},he.Symbol&&he.Symbol.iterator&&(e[he.Symbol.iterator]=()=>(s||[]).values()),e}function Rr(s,e){return Array.isArray(s)?Uy(s):s===void 0||e===void 0?Uy():Uy([[s,e]])}const DC=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),o=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(n=i=t="-"),n=n>0||o>0?n+":":"",i=((n||r>=10)&&i<10?"0"+i:i)+":",t=t<10?"0"+t:t,n+i+t};let ab=DC;function LC(s){ab=s}function RC(){ab=DC}function Jl(s,e=s){return ab(s,e)}var Q3=Object.freeze({__proto__:null,createTimeRanges:Rr,createTimeRange:Rr,setFormatTime:LC,resetFormatTime:RC,formatTime:Jl});function IC(s,e){let t=0,i,n;if(!e)return 0;(!s||!s.length)&&(s=Rr(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 cs(s){if(s instanceof cs)return s;typeof s=="number"?this.code=s:typeof s=="string"?this.message=s:fa(s)&&(typeof s.code=="number"&&(this.code=s.code),Object.assign(this,s)),this.message||(this.message=cs.defaultMessages[this.code]||"")}cs.prototype.code=0;cs.prototype.message="";cs.prototype.status=null;cs.prototype.metadata=null;cs.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];cs.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."};cs.MEDIA_ERR_CUSTOM=0;cs.prototype.MEDIA_ERR_CUSTOM=0;cs.MEDIA_ERR_ABORTED=1;cs.prototype.MEDIA_ERR_ABORTED=1;cs.MEDIA_ERR_NETWORK=2;cs.prototype.MEDIA_ERR_NETWORK=2;cs.MEDIA_ERR_DECODE=3;cs.prototype.MEDIA_ERR_DECODE=3;cs.MEDIA_ERR_SRC_NOT_SUPPORTED=4;cs.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;cs.MEDIA_ERR_ENCRYPTED=5;cs.prototype.MEDIA_ERR_ENCRYPTED=5;function lh(s){return s!=null&&typeof s.then=="function"}function na(s){lh(s)&&s.then(null,e=>{})}const ex=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}})})},Z3=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=ex(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(ex))},J3=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 tx={textTracksToJson:Z3,jsonToTextTracks:J3,trackToJson:ex};const jy="vjs-modal-dialog";class Bc extends Fe{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_=Vt("div",{className:`${jy}-content`},{role:"document"}),this.descEl_=Vt("p",{className:`${jy}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),nl(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`${jy} 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(),yC(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"),eg(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=rt.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}rt.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 he.HTMLAnchorElement||t instanceof he.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof he.HTMLInputElement||t instanceof he.HTMLSelectElement||t instanceof he.HTMLTextAreaElement||t instanceof he.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof he.HTMLIFrameElement||t instanceof he.HTMLObjectElement||t instanceof he.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Bc.prototype.options_={pauseOnOpen:!0,temporary:!0};Fe.registerComponent("ModalDialog",Bc);class eu extends nr{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})},Wa(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}}eu.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const s in eu.prototype.allowedEvents_)eu.prototype["on"+s]=null;const $y=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 NC extends eu{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){$y(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&$y(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,$y(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 Hy=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 OC extends eu{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Hy(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&&Hy(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Hy(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 ob extends eu{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 e4{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 op{constructor(e){op.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(o){""+o in this||Object.defineProperty(this,""+o,{get(){return this.cues_[o]}})};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 t4={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},i4={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},s4={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},EE={disabled:"disabled",hidden:"hidden",showing:"showing"};class lb extends nr{constructor(e={}){super();const t={id:e.id||"vjs_track_"+hr(),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 ub=function(s){return new URL(s,rt.baseURI)},MC=function(s){return new URL(s,rt.baseURI).href},cb=function(s){if(typeof s=="string"){const t=s.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return t?t[1].toLowerCase():""}return""},ng=function(s,e=he.location){return ub(s).origin!==e.origin};var n4=Object.freeze({__proto__:null,parseUrl:ub,getAbsoluteURL:MC,getFileExtension:cb,isCrossOrigin:ng});const wE=function(s,e){const t=new he.WebVTT.Parser(he,he.vttjs,he.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&&(he.console&&he.console.groupCollapsed&&he.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),i.forEach(n=>si.error(n)),he.console&&he.console.groupEnd&&he.console.groupEnd()),t.flush()},AE=function(s,e){const t={uri:s},i=ng(s);i&&(t.cors=i);const n=e.tech_.crossOrigin()==="use-credentials";n&&(t.withCredentials=n),BA(t,Yi(this,function(r,o,u){if(r)return si.error(r,o);e.loaded_=!0,typeof he.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){si.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return wE(u,e)}):wE(u,e)}))};class Rh extends lb{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=Pi(e,{kind:s4[e.kind]||"subtitles",language:e.language||e.srclang||""});let i=EE[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 op(this.cues_),o=new op(this.activeCues_);let u=!1;this.timeupdateHandler=Yi(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){EE[d]&&i!==d&&(i=d,!this.preload_&&i!=="disabled"&&this.cues.length===0&&AE(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 o;const d=this.tech_.currentTime(),f=[];for(let p=0,g=this.cues.length;p<g;p++){const v=this.cues[p];v.startTime<=d&&v.endTime>=d&&f.push(v)}if(u=!1,f.length!==this.activeCues_.length)u=!0;else for(let p=0;p<f.length;p++)this.activeCues_.indexOf(f[p])===-1&&(u=!0);return this.activeCues_=f,o.setCues_(this.activeCues_),o},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&AE(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 he.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 tx.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}}}}Rh.prototype.allowedEvents_={cuechange:"cuechange"};class PC extends lb{constructor(e={}){const t=Pi(e,{kind:i4[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 BC extends lb{constructor(e={}){const t=Pi(e,{kind:t4[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 Qa extends nr{constructor(e={}){super();let t;const i=new Rh(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=Qa.NONE,i.addEventListener("loadeddata",()=>{t=Qa.LOADED,this.trigger({type:"load",target:this})})}}Qa.prototype.allowedEvents_={load:"load"};Qa.NONE=0;Qa.LOADING=1;Qa.LOADED=2;Qa.ERROR=3;const dr={audio:{ListClass:NC,TrackClass:PC,capitalName:"Audio"},video:{ListClass:OC,TrackClass:BC,capitalName:"Video"},text:{ListClass:ob,TrackClass:Rh,capitalName:"Text"}};Object.keys(dr).forEach(function(s){dr[s].getterName=`${s}Tracks`,dr[s].privateName=`${s}Tracks_`});const Dc={remoteText:{ListClass:ob,TrackClass:Rh,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:e4,TrackClass:Qa,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},gn=Object.assign({},dr,Dc);Dc.names=Object.keys(Dc);dr.names=Object.keys(dr);gn.names=[].concat(Dc.names).concat(dr.names);function r4(s,e,t,i,n={}){const r=s.textTracks();n.kind=e,t&&(n.label=t),i&&(n.language=i),n.tech=s;const o=new gn.text.TrackClass(n);return r.addTrack(o),o}class Zt extends Fe{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}),gn.names.forEach(i=>{const n=gn[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 gn.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(Yi(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 Rr(0,0)}bufferedPercent(){return IC(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(dr.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 cs(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Rr(0,0):Rr()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){dr.names.forEach(e=>{const t=dr[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(!he.WebVTT)if(rt.body.contains(this.el())){if(!this.options_["vtt.js"]&&wc(XS)&&Object.keys(XS).length>0){this.trigger("vttjsloaded");return}const e=rt.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}),he.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"),o=()=>{r();for(let u=0;u<e.length;u++){const c=e[u];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};o(),e.addEventListener("change",o),e.addEventListener("addtrack",o),e.addEventListener("removetrack",o),this.on("dispose",function(){t.off("addtrack",i),t.off("removetrack",n),e.removeEventListener("change",o),e.removeEventListener("addtrack",o),e.removeEventListener("removetrack",o);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 r4(this,e,t,i)}createRemoteTextTrack(e){const t=Pi(e,{tech:this});return new Dc.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=hr();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 Zt.canPlayType(e.type)}static isTech(e){return e.prototype instanceof Zt||e instanceof Zt||e===Zt}static registerTech(e,t){if(Zt.techs_||(Zt.techs_={}),!Zt.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!Zt.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!Zt.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=ys(e),Zt.techs_[e]=t,Zt.techs_[oh(e)]=t,e!=="Tech"&&Zt.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(Zt.techs_&&Zt.techs_[e])return Zt.techs_[e];if(e=ys(e),he&&he.videojs&&he.videojs[e])return si.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),he.videojs[e]}}}gn.names.forEach(function(s){const e=gn[s];Zt.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});Zt.prototype.featuresVolumeControl=!0;Zt.prototype.featuresMuteControl=!0;Zt.prototype.featuresFullscreenResize=!1;Zt.prototype.featuresPlaybackRate=!1;Zt.prototype.featuresProgressEvents=!1;Zt.prototype.featuresSourceset=!1;Zt.prototype.featuresTimeupdateEvents=!1;Zt.prototype.featuresNativeTextTracks=!1;Zt.prototype.featuresVideoFrameCallback=!1;Zt.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 o=0;o<n.length;o++)if(r=n[o].canHandleSource(t,i),r)return n[o];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:si.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)}};Fe.registerComponent("Tech",Zt);Zt.registerTech("Tech",Zt);Zt.defaultTechOrder_=[];const Yl={},lp={},up={};function a4(s,e){Yl[s]=Yl[s]||[],Yl[s].push(e)}function o4(s,e,t){s.setTimeout(()=>Bl(e,Yl[e.type],t,s),1)}function l4(s,e){s.forEach(t=>t.setTech&&t.setTech(e))}function u4(s,e,t){return s.reduceRight(db(t),e[t]())}function c4(s,e,t,i){return e[t](s.reduce(db(t),i))}function CE(s,e,t,i=null){const n="call"+ys(t),r=s.reduce(db(n),i),o=r===up,u=o?null:e[t](r);return f4(s,t,u,o),u}const d4={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},h4={setCurrentTime:1,setMuted:1,setVolume:1},kE={play:1,pause:1};function db(s){return(e,t)=>e===up?up:t[s]?t[s](e):e}function f4(s,e,t,i){for(let n=s.length-1;n>=0;n--){const r=s[n];r[e]&&r[e](i,t)}}function m4(s){lp.hasOwnProperty(s.id())&&delete lp[s.id()]}function p4(s,e){const t=lp[s.id()];let i=null;if(t==null)return i=e(s),lp[s.id()]=[[e,i]],i;for(let n=0;n<t.length;n++){const[r,o]=t[n];r===e&&(i=o)}return i===null&&(i=e(s),t.push([e,i])),i}function Bl(s={},e=[],t,i,n=[],r=!1){const[o,...u]=e;if(typeof o=="string")Bl(s,Yl[o],t,i,n,r);else if(o){const c=p4(i,o);if(!c.setSource)return n.push(c),Bl(s,u,t,i,n,r);c.setSource(Object.assign({},s),function(d,f){if(d)return Bl(s,u,t,i,n,r);n.push(c),Bl(f,s.type===f.type?u:Yl[f.type],t,i,n,r)})}else u.length?Bl(s,u,t,i,n,r):r?t(s,n):Bl(s,Yl["*"],t,i,n,!0)}const g4={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"},cp=function(s=""){const e=cb(s);return g4[e.toLowerCase()]||""},y4=(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 cp(e)},FC=function(s){if(Array.isArray(s)){let e=[];s.forEach(function(t){t=FC(t),Array.isArray(t)?e=e.concat(t):fa(t)&&e.push(t)}),s=e}else typeof s=="string"&&s.trim()?s=[DE({src:s})]:fa(s)&&typeof s.src=="string"&&s.src&&s.src.trim()?s=[DE(s)]:s=[];return s};function DE(s){if(!s.type){const e=cp(s.src);e&&(s.type=e)}return s}var v4=`<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 LE=sp?10009:np?461:8,Hu={codes:{play:415,pause:19,ff:417,rw:412,back:LE},names:{415:"play",19:"pause",417:"ff",412:"rw",[LE]:"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}},RE=5;class x4 extends nr{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(Hu.isEventKey(t,"play")||Hu.isEventKey(t,"pause")||Hu.isEventKey(t,"ff")||Hu.isEventKey(t,"rw")){t.preventDefault();const i=Hu.getEventName(t);this.performMediaAction_(i)}else Hu.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()+RE);break;case"rw":this.userSeek_(this.player_.currentTime()-RE);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},p={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:p}},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],o=t(r);if(o)return o}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(o=>o!==t&&this.isInDirection_(i.boundingClientRect,o.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 o of t){const u=o.getPositions().center,c=this.calculateDistance_(e,u,i);c<n&&(n=c,r=o)}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 o;switch(i){case"right":case"left":o=n+r*100;break;case"up":o=r*2+n*.5;break;case"down":o=r*5+n;break;default:o=n+r}return o}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class b4 extends Fe{constructor(e,t,i){const n=Pi({createEl:!1},t);if(super(e,n,i),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,o=t.playerOptions.techOrder;r<o.length;r++){const u=ys(o[r]);let c=Zt.getTech(u);if(u||(c=Fe.getComponent(u)),c&&c.isSupported()){e.loadTech_(u);break}}else e.src(t.playerOptions.sources)}}Fe.registerComponent("MediaLoader",b4);class rg extends Fe{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"&&si.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=Vt(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(Vt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=Vt("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,nl(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)}}Fe.registerComponent("ClickableComponent",rg);class ix extends rg{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 Vt("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(Vt("picture",{className:"vjs-poster",tabIndex:-1},{},Vt("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()?na(this.player_.play()):this.player_.pause())}}ix.prototype.crossorigin=ix.prototype.crossOrigin;Fe.registerComponent("PosterImage",ix);const cr="#222",IE="#ccc",T4={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 Vy(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 Wr(s,e,t){try{s.style[e]=t}catch{return}}function NE(s){return s?`${s}px`:""}class _4 extends Fe{constructor(e,t,i){super(e,t,i);const n=o=>this.updateDisplay(o),r=o=>{this.updateDisplayOverlay(),this.updateDisplay(o)};e.on("loadstart",o=>this.toggleDisplay(o)),e.on("useractive",n),e.on("userinactive",n),e.on("texttrackchange",n),e.on("loadedmetadata",o=>{this.updateDisplayOverlay(),this.preselectTrack(o)}),e.ready(Yi(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const o=he.screen.orientation||he,u=he.screen.orientation?"change":"orientationchange";o.addEventListener(u,r),e.on("dispose",()=>o.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,o;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?o=c:o||(o=c):i&&!i.enabled?(o=null,n=null,r=null):c.default&&(c.kind==="descriptions"&&!n?n=c:c.kind in e&&!r&&(r=c))}o?o.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 he.WebVTT=="function"&&he.WebVTT.processCues(he,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const o=[];for(let u=0;u<e.length;++u){const c=e[u];c.mode==="showing"&&o.push(c)}this.updateForTrack(o);return}let i=null,n=null,r=e.length;for(;r--;){const o=e[r];o.mode==="showing"&&(o.kind==="descriptions"?i=o:n=o)}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)),!he.CSS.supports("inset","10px")){const o=this.el_,u=o.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,d=this.player_.el_.getBoundingClientRect().height;o.style="",Wr(o,"position","relative"),Wr(o,"height",d-c+"px"),Wr(o,"top","unset"),rp?Wr(o,"bottom",d+"px"):Wr(o,"bottom","0px"),u.length>0&&u.forEach(f=>{if(f.style.inset){const p=f.style.inset.split(" ");p.length===3&&Object.assign(f.style,{top:p[0],right:p[1],bottom:p[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!he.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,o=0;Math.abs(i-n)>.1&&(i>n?r=Math.round((e-t*n)/2):o=Math.round((t-e/n)/2)),Wr(this.el_,"insetInline",NE(r)),Wr(this.el_,"insetBlock",NE(o))}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 o=r.displayState;if(t.color&&(o.firstChild.style.color=t.color),t.textOpacity&&Wr(o.firstChild,"color",Vy(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(o.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Wr(o.firstChild,"backgroundColor",Vy(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Wr(o,"backgroundColor",Vy(t.windowColor,t.windowOpacity)):o.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?o.firstChild.style.textShadow=`2px 2px 3px ${cr}, 2px 2px 4px ${cr}, 2px 2px 5px ${cr}`:t.edgeStyle==="raised"?o.firstChild.style.textShadow=`1px 1px ${cr}, 2px 2px ${cr}, 3px 3px ${cr}`:t.edgeStyle==="depressed"?o.firstChild.style.textShadow=`1px 1px ${IE}, 0 1px ${IE}, -1px -1px ${cr}, 0 -1px ${cr}`:t.edgeStyle==="uniform"&&(o.firstChild.style.textShadow=`0 0 4px ${cr}, 0 0 4px ${cr}, 0 0 4px ${cr}, 0 0 4px ${cr}`)),t.fontPercent&&t.fontPercent!==1){const u=he.parseFloat(o.style.fontSize);o.style.fontSize=u*t.fontPercent+"px",o.style.height="auto",o.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?o.firstChild.style.fontVariant="small-caps":o.firstChild.style.fontFamily=T4[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof he.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])}he.WebVTT.processCues(he,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 o=n.activeCues[r].displayState;Kl(o,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:i)),n.language&&Ac(o,"lang",n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}Fe.registerComponent("TextTrackDisplay",_4);class S4 extends Fe{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),i=Vt("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"])}}Fe.registerComponent("LoadingSpinner",S4);class ln extends rg{createEl(e,t={},i={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i);const n=Vt(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(Vt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}addChild(e,t={}){const i=this.constructor.name;return si.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),Fe.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)}}Fe.registerComponent("Button",ln);class UC extends ln{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){na(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();lh(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}UC.prototype.controlText_="Play Video";Fe.registerComponent("BigPlayButton",UC);class E4 extends ln{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)}}Fe.registerComponent("CloseButton",E4);class jC extends ln{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()?na(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))}}jC.prototype.controlText_="Play";Fe.registerComponent("PlayToggle",jC);class Fc extends Fe{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=Vt("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(i),this.contentEl_=Vt("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=Jl(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,si.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_=rt.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}Fc.prototype.labelText_="Time";Fc.prototype.controlText_="Time";Fe.registerComponent("TimeDisplay",Fc);class hb extends Fc{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)}}hb.prototype.labelText_="Current Time";hb.prototype.controlText_="Current Time";Fe.registerComponent("CurrentTimeDisplay",hb);class fb extends Fc{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)}}fb.prototype.labelText_="Duration";fb.prototype.controlText_="Duration";Fe.registerComponent("DurationDisplay",fb);class w4 extends Fe{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}}Fe.registerComponent("TimeDivider",w4);class mb extends Fc{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(Vt("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)}}mb.prototype.labelText_="Remaining Time";mb.prototype.controlText_="Remaining Time";Fe.registerComponent("RemainingTimeDisplay",mb);class A4 extends Fe{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_=Vt("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(Vt("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(rt.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()}}Fe.registerComponent("LiveDisplay",A4);class $C extends ln{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_=Vt("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()}}$C.prototype.controlText_="Seek to live, currently playing live";Fe.registerComponent("SeekToLive",$C);function Ih(s,e,t){return s=Number(s),Math.min(t,Math.max(e,isNaN(s)?e:s))}var C4=Object.freeze({__proto__:null,clamp:Ih});class pb extends Fe{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"&&!ma&&e.preventDefault(),fC(),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;mC(),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(Ih(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Jp(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")}}Fe.registerComponent("Slider",pb);const Gy=(s,e)=>Ih(s/e*100,0,100).toFixed(2)+"%";class k4 extends Fe{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=Vt("span",{className:"vjs-control-text"}),i=Vt("span",{textContent:this.localize("Loaded")}),n=rt.createTextNode(": ");return this.percentageEl_=Vt("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(),o=this.partEls_,u=Gy(r,n);this.percent_!==u&&(this.el_.style.width=u,nl(this.percentageEl_,u),this.percent_=u);for(let c=0;c<i.length;c++){const d=i.start(c),f=i.end(c);let p=o[c];p||(p=this.el_.appendChild(Vt()),o[c]=p),!(p.dataset.start===d&&p.dataset.end===f)&&(p.dataset.start=d,p.dataset.end=f,p.style.left=Gy(d,r),p.style.width=Gy(f-d,r))}for(let c=o.length;c>i.length;c--)this.el_.removeChild(o[c-1]);o.length=i.length})}}Fe.registerComponent("LoadProgressBar",k4);class D4 extends Fe{constructor(e,t){super(e,t),this.update=pa(Yi(this,this.update),fr)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,i){const n=yh(this.el_),r=Cc(this.player_.el()),o=e.width*t;if(!r||!n)return;let u=e.left-r.left+o,c=e.width-o+(r.right-e.right);c||(c=e.width-o,u=o);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){nl(this.el_,e)}updateTime(e,t,i,n){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const o=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const u=this.player_.liveTracker.liveWindow(),c=u-t*u;r=(c<1?"":"-")+Jl(c,u)}else r=Jl(i,o);this.update(e,t,r),n&&n()})}}Fe.registerComponent("TimeTooltip",D4);class gb extends Fe{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=pa(Yi(this,this.update),fr)}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)}}gb.prototype.options_={children:[]};!an&&!Ir&&gb.prototype.options_.children.push("timeTooltip");Fe.registerComponent("PlayProgressBar",gb);class HC extends Fe{constructor(e,t){super(e,t),this.update=pa(Yi(this,this.update),fr)}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`})}}HC.prototype.options_={children:["timeTooltip"]};Fe.registerComponent("MouseTimeDisplay",HC);class ag extends pb{constructor(e,t){t=Pi(ag.prototype.options_,t),t.children=[...t.children];const i=e.options_.disableSeekWhileScrubbingOnMobile&&(an||Ir)||e.options_.disableSeekWhileScrubbingOnSTV;(!an&&!Ir||i)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbing_=i,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=Yi(this,this.update),this.update=pa(this.update_,fr),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 rt&&"visibilityState"in rt&&this.on(rt,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){rt.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,fr))}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(rt.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}",[Jl(i,r),Jl(r,r)],"{1} of {2}")),this.currentTime_=i,this.duration_=r),this.bar&&this.bar.update(Cc(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){vh(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!vh(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 o=r.seekableStart(),u=r.liveCurrentTime();if(i=o+n*r.liveWindow(),i>=u&&(i=u),i<=o&&(i=o+.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?na(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 rt&&"visibilityState"in rt&&this.off(rt,"visibilitychange",this.toggleVisibility_),super.dispose()}}ag.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12};Fe.registerComponent("SeekBar",ag);class VC extends Fe{constructor(e,t){super(e,t),this.handleMouseMove=pa(Yi(this,this.handleMouseMove),fr),this.throttledHandleMouseSeek=pa(Yi(this,this.handleMouseSeek),fr),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(),o=yh(r);let u=Jp(r,e).x;u=Ih(u,0,1),n&&n.update(o,u),i&&i.update(o,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&&na(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()}}VC.prototype.options_={children:["seekBar"]};Fe.registerComponent("ProgressControl",VC);class GC extends ln{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(){rt.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in he?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 rt.exitPictureInPicture=="function"&&super.show()}}GC.prototype.controlText_="Picture-in-Picture";Fe.registerComponent("PictureInPictureToggle",GC);class zC extends ln{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",i=>this.handleFullscreenChange(i)),rt[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()}}zC.prototype.controlText_="Fullscreen";Fe.registerComponent("FullscreenToggle",zC);const L4=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 R4 extends Fe{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}}Fe.registerComponent("VolumeLevel",R4);class I4 extends Fe{constructor(e,t){super(e,t),this.update=pa(Yi(this,this.update),fr)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,i,n){if(!i){const r=Cc(this.el_),o=Cc(this.player_.el()),u=e.width*t;if(!o||!r)return;const c=e.left-o.left+u,d=e.width-u+(o.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){nl(this.el_,e)}updateVolume(e,t,i,n,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,i,n.toFixed(0)),r&&r()})}}Fe.registerComponent("VolumeLevelTooltip",I4);class qC extends Fe{constructor(e,t){super(e,t),this.update=pa(Yi(this,this.update),fr)}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`})}}qC.prototype.options_={children:["volumeLevelTooltip"]};Fe.registerComponent("MouseVolumeLevelDisplay",qC);class og extends pb{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){vh(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const i=this.el(),n=Cc(i),r=this.vertical();let o=Jp(i,e);o=r?o.y:o.x,o=Ih(o,0,1),t.update(n,o,r)}vh(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)})}}og.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!an&&!Ir&&og.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");og.prototype.playerEvent="volumechange";Fe.registerComponent("VolumeBar",og);class KC extends Fe{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||wc(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),L4(this,e),this.throttledHandleMouseMove=pa(Yi(this,this.handleMouseMove),fr),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"]};Fe.registerComponent("VolumeControl",KC);const N4=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 YC extends ln{constructor(e,t){super(e,t),N4(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"),an&&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),Qp(this.el_,[0,1,2,3].reduce((i,n)=>i+`${n?" ":""}vjs-vol-${n}`,"")),Kl(this.el_,`vjs-vol-${t}`)}updateControlText_(){const t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==t&&this.controlText(t)}}YC.prototype.controlText_="Mute";Fe.registerComponent("MuteToggle",YC);class WC extends Fe{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||wc(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"),sr(rt,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),on(rt,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}WC.prototype.options_={children:["muteToggle","volumeControl"]};Fe.registerComponent("VolumePanel",WC);class XC extends ln{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]))}}XC.prototype.controlText_="Skip Forward";Fe.registerComponent("SkipForward",XC);class QC extends ln{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]))}}QC.prototype.controlText_="Skip Backward";Fe.registerComponent("SkipBackward",QC);class ZC extends Fe{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 Fe&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof Fe&&(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_=Vt(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_),sr(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||rt.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())}}Fe.registerComponent("Menu",ZC);class yb extends Fe{constructor(e,t={}){super(e,t),this.menuButton_=new ln(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const i=ln.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(),sr(rt,"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 ZC(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=Vt("li",{className:"vjs-menu-title",textContent:ys(this.options_.title),tabIndex:-1}),i=new Fe(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=ln.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"),on(rt,"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"),an&&lC())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()}}Fe.registerComponent("MenuButton",yb);class vb extends yb{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!i)return;const n=Yi(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)})}}Fe.registerComponent("TrackButton",vb);class Nh extends rg{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=Vt("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))}}Fe.registerComponent("MenuItem",Nh);class Oh extends Nh{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)},o=(...u)=>{this.handleSelectedLanguageChange.apply(this,u)};if(e.on(["loadstart","texttrackchange"],r),n.addEventListener("change",r),n.addEventListener("selectedlanguagechange",o),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),n.removeEventListener("change",r),n.removeEventListener("selectedlanguagechange",o)}),n.onchange===void 0){let u;this.on(["tap","click"],function(){if(typeof he.Event!="object")try{u=new he.Event("change")}catch{}u||(u=rt.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()}}Fe.registerComponent("TextTrackMenuItem",Oh);class JC extends Oh{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 o=t[n];if(this.options_.kinds.indexOf(o.kind)>-1&&o.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 o=t[n];if(["captions","descriptions","subtitles"].indexOf(o.kind)>-1&&o.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()}}Fe.registerComponent("OffTextTrackMenuItem",JC);class Uc extends vb{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=Oh){let i;this.label_&&(i=`${this.label_} off`),e.push(new JC(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 o=n[r];if(this.kinds_.indexOf(o.kind)>-1){const u=new t(this.player_,{track:o,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});u.addClass(`vjs-${o.kind}-menu-item`),e.push(u)}}return e}}Fe.registerComponent("TextTrackButton",Uc);class ek extends Nh{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)}}Fe.registerComponent("ChaptersTrackMenuItem",ek);class xb extends Uc{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(ys(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],o=new ek(this.player_,{track:this.track_,cue:r});e.push(o)}return e}}xb.prototype.kind_="chapters";xb.prototype.controlText_="Chapters";Fe.registerComponent("ChaptersButton",xb);class bb extends Uc{constructor(e,t,i){super(e,t,i),this.setIcon("audio-description");const n=e.textTracks(),r=Yi(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 o=t[n];if(o.kind!==this.kind_&&o.mode==="showing"){i=!0;break}}i?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}bb.prototype.kind_="descriptions";bb.prototype.controlText_="Descriptions";Fe.registerComponent("DescriptionsButton",bb);class Tb extends Uc{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()}`}}Tb.prototype.kind_="subtitles";Tb.prototype.controlText_="Subtitles";Fe.registerComponent("SubtitlesButton",Tb);class _b extends Oh{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()}}Fe.registerComponent("CaptionSettingsMenuItem",_b);class Sb extends Uc{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 _b(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}Sb.prototype.kind_="captions";Sb.prototype.controlText_="Captions";Fe.registerComponent("CaptionsButton",Sb);class tk extends Oh{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(Vt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(Vt("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),n}}Fe.registerComponent("SubsCapsMenuItem",tk);class Eb extends Uc{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(ys(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 _b(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,tk),e}}Eb.prototype.kinds_=["captions","subtitles"];Eb.prototype.controlText_="Subtitles";Fe.registerComponent("SubsCapsButton",Eb);class ik extends Nh{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=(...o)=>{this.handleTracksChange.apply(this,o)};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(Vt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(Vt("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)}}Fe.registerComponent("AudioTrackMenuItem",ik);class sk extends vb{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 ik(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}sk.prototype.controlText_="Audio Track";Fe.registerComponent("AudioTrackButton",sk);class wb extends Nh{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)}}wb.prototype.contentElType="button";Fe.registerComponent("PlaybackRateMenuItem",wb);class nk extends yb{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_=Vt("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 wb(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")}}nk.prototype.controlText_="Playback Rate";Fe.registerComponent("PlaybackRateMenuButton",nk);class rk extends Fe{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}Fe.registerComponent("Spacer",rk);class O4 extends rk{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}Fe.registerComponent("CustomControlSpacer",O4);class ak extends Fe{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}ak.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};Fe.registerComponent("ControlBar",ak);class ok extends Bc{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):""}}ok.prototype.options_=Object.assign({},Bc.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});Fe.registerComponent("ErrorDisplay",ok);class lk extends Fe{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(),Vt("select",{id:this.options_.id},{},this.options_.SelectOptions.map(t=>{const i=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${hr()}`)+"-"+t[1].replace(/\W+/g,""),n=Vt("option",{id:i,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${i}`),n}))}}Fe.registerComponent("TextTrackSelect",lk);class Wl extends Fe{constructor(e,t={}){super(e,t);const i=Vt("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 o=this.options_.selectConfigs[r],u=o.className,c=o.id.replace("%s",this.options_.id_);let d=null;const f=`vjs_select_${hr()}`;if(this.options_.type==="colors"){d=Vt("span",{className:u});const g=Vt("label",{id:c,className:"vjs-label",textContent:this.localize(o.label)});g.setAttribute("for",f),d.appendChild(g)}const p=new lk(e,{SelectOptions:o.options,legendId:this.options_.legendId,id:f,labelId:c});this.addChild(p),this.options_.type==="colors"&&(d.appendChild(p.el()),this.el().appendChild(d))}}createEl(){return Vt("fieldset",{className:this.options_.className})}}Fe.registerComponent("TextTrackFieldset",Wl);class uk extends Fe{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new Wl(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 Wl(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 o=new Wl(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(o)}createEl(){return Vt("div",{className:"vjs-track-settings-colors"})}}Fe.registerComponent("TextTrackSettingsColors",uk);class ck extends Fe{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new Wl(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 Wl(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 o=new Wl(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(o)}createEl(){return Vt("div",{className:"vjs-track-settings-font"})}}Fe.registerComponent("TextTrackSettingsFont",ck);class dk extends Fe{constructor(e,t={}){super(e,t);const i=new ln(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 ln(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=n,this.addChild(r)}createEl(){return Vt("div",{className:"vjs-track-settings-controls"})}}Fe.registerComponent("TrackSettingsControls",dk);const zy="vjs-text-track-settings",OE=["#000","Black"],ME=["#00F","Blue"],PE=["#0FF","Cyan"],BE=["#0F0","Green"],FE=["#F0F","Magenta"],UE=["#F00","Red"],jE=["#FFF","White"],$E=["#FF0","Yellow"],qy=["1","Opaque"],Ky=["0.5","Semi-Transparent"],HE=["0","Transparent"],qo={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[OE,jE,UE,BE,ME,$E,FE,PE],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[qy,Ky,HE],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[jE,OE,UE,BE,ME,$E,FE,PE],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:[qy,Ky],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:[HE,Ky,qy],className:"vjs-window-opacity vjs-opacity"}};qo.windowColor.options=qo.backgroundColor.options;function hk(s,e){if(e&&(s=e(s)),s&&s!=="none")return s}function M4(s,e){const t=s.options[s.options.selectedIndex].value;return hk(t,e)}function P4(s,e,t){if(e){for(let i=0;i<s.options.length;i++)if(hk(s.options[i].value,t)===e){s.selectedIndex=i;break}}}class B4 extends Bc{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=Vt("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 uk(e,{textTrackComponentid:this.id_,selectConfigs:qo,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const i=new ck(e,{textTrackComponentid:this.id_,selectConfigs:qo,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(i);const n=new dk(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()}),nc(qo,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 tC(qo,(e,t,i)=>{const n=M4(this.$(t.selector),t.parser);return n!==void 0&&(e[i]=n),e},{})}setValues(e){nc(qo,(t,i)=>{P4(this.$(t.selector),e[i],t.parser)})}setDefaults(){nc(qo,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(he.localStorage.getItem(zy))}catch(t){si.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?he.localStorage.setItem(zy,JSON.stringify(e)):he.localStorage.removeItem(zy)}catch(t){si.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}Fe.registerComponent("TextTrackSettings",B4);class F4 extends Fe{constructor(e,t){let i=t.ResizeObserver||he.ResizeObserver;t.ResizeObserver===null&&(i=!1);const n=Pi({createEl:!i,reportTouchActivity:!1},t);super(e,n),this.ResizeObserver=t.ResizeObserver||he.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=EC(()=>{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 o=this.unloadListener_=function(){on(this,"resize",r),on(this,"unload",o),o=null};sr(this.el_.contentWindow,"unload",o),sr(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()}}Fe.registerComponent("ResizeManager",F4);const U4={trackingThreshold:20,liveTolerance:15};class j4 extends Fe{constructor(e,t){const i=Pi(U4,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(he.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 o=this.player_.paused()||this.seekedBehindLive_||Math.abs(n-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||n===1/0)&&(o=!1),o!==this.behindLiveEdge_&&(this.behindLiveEdge_=o,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_,fr),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()}}Fe.registerComponent("LiveTracker",j4);class $4 extends Fe{constructor(e,t){super(e,t),this.on("statechanged",i=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:Vt("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${hr()}`}),description:Vt("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${hr()}`})},Vt("div",{className:"vjs-title-bar"},{},iC(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],o=this.els[n],u=i[n];eg(o),r&&nl(o,r),t&&(t.removeAttribute(u),r&&t.setAttribute(u,o.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}}Fe.registerComponent("TitleBar",$4);const H4={initialDisplay:4e3,position:[],takeFocus:!1};class V4 extends ln{constructor(e,t){t=Pi(H4,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=Vt("button",{},{type:"button",class:this.buildCSSClass()},Vt("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()}}Fe.registerComponent("TransientButton",V4);const sx=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 o=t[r].src;o&&i.indexOf(o)===-1&&i.push(o)}return i.length?(i.length===1&&(n=i[0]),s.triggerSourceset(n),!0):!1},G4=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(s){const e=rt.createElement(this.nodeName.toLowerCase());e.innerHTML=s;const t=rt.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",he.Element.prototype.appendChild.call(this,t),this.innerHTML}}),fk=(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},z4=s=>fk([s.el(),he.HTMLMediaElement.prototype,he.Element.prototype,G4],"innerHTML"),VE=function(s){const e=s.el();if(e.resetSourceWatch_)return;const t={},i=z4(s),n=r=>(...o)=>{const u=r.apply(e,o);return sx(s),u};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=n(t[r]))}),Object.defineProperty(e,"innerHTML",Pi(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_)},q4=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?MC(he.Element.prototype.getAttribute.call(this,"src")):""},set(s){return he.Element.prototype.setAttribute.call(this,"src",s),s}}),K4=s=>fk([s.el(),he.HTMLMediaElement.prototype,q4],"src"),Y4=function(s){if(!s.featuresSourceset)return;const e=s.el();if(e.resetSourceset_)return;const t=K4(s),i=e.setAttribute,n=e.load;Object.defineProperty(e,"src",Pi(t,{set:r=>{const o=t.set.call(e,r);return s.triggerSourceset(e.src),o}})),e.setAttribute=(r,o)=>{const u=i.call(e,r,o);return/src/i.test(r)&&s.triggerSourceset(e.src),u},e.load=()=>{const r=n.call(e);return sx(s)||(s.triggerSourceset(""),VE(s)),r},e.currentSrc?s.triggerSourceset(e.currentSrc):sx(s)||VE(s),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=n,e.setAttribute=i,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class bt extends Zt{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 o=r.length;const u=[];for(;o--;){const c=r[o];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")&&ng(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&&si.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_(),(gh||Wp)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),bt.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Y4(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const i=()=>{t=[];for(let r=0;r<e.length;r++){const o=e[r];o.kind==="metadata"&&t.push({track:o,storedMode:o.mode})}};i(),e.addEventListener("change",i),this.on("dispose",()=>e.removeEventListener("change",i));const n=()=>{for(let r=0;r<t.length;r++){const o=t[r];o.track.mode==="disabled"&&o.track.mode!==o.storedMode&&(o.track.mode=o.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=dr[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[Dc.remoteText.getterName]().trigger(c)},addtrack(u){n.addTrack(u.track)},removetrack(u){n.removeTrack(u.track)}},o=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",o),this.on("dispose",u=>this.off("loadstart",o))}proxyNativeTracks_(){dr.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),bt.disposeMediaElement(e),e=i}else{e=rt.createElement("video");const i=this.options_.tag&&zo(this.options_.tag),n=Pi({},i);(!gh||this.options_.nativeControlsForTouch!==!0)&&delete n.controls,dC(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&Ac(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?Ac(e,n,n):Zp(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){si(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Ir&&ma&&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)na(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 si.error("Invalid source URL."),!1;const i={src:e};t&&(i.type=t);const n=Vt("source",{},i);return this.el_.appendChild(n),!0}removeSourceElement(e){if(!e)return si.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 si.warn(`No matching source element found with src: ${e}`),!1}reset(){bt.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=rt.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),he.performance&&(e.creationTime=he.performance.now()),e}}qp(bt,"TEST_VID",function(){if(!Oc())return;const s=rt.createElement("video"),e=rt.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",s.appendChild(e),s});bt.isSupported=function(){try{bt.TEST_VID.volume=.5}catch{return!1}return!!(bt.TEST_VID&&bt.TEST_VID.canPlayType)};bt.canPlayType=function(s){return bt.TEST_VID.canPlayType(s)};bt.canPlaySource=function(s,e){return bt.canPlayType(s.type)};bt.canControlVolume=function(){try{const s=bt.TEST_VID.volume;bt.TEST_VID.volume=s/2+.1;const e=s!==bt.TEST_VID.volume;return e&&an?(he.setTimeout(()=>{bt&&bt.prototype&&(bt.prototype.featuresVolumeControl=s!==bt.TEST_VID.volume)}),!1):e}catch{return!1}};bt.canMuteVolume=function(){try{const s=bt.TEST_VID.muted;return bt.TEST_VID.muted=!s,bt.TEST_VID.muted?Ac(bt.TEST_VID,"muted","muted"):Zp(bt.TEST_VID,"muted","muted"),s!==bt.TEST_VID.muted}catch{return!1}};bt.canControlPlaybackRate=function(){if(Ir&&ma&&Kp<58)return!1;try{const s=bt.TEST_VID.playbackRate;return bt.TEST_VID.playbackRate=s/2+.1,s!==bt.TEST_VID.playbackRate}catch{return!1}};bt.canOverrideAttributes=function(){try{const s=()=>{};Object.defineProperty(rt.createElement("video"),"src",{get:s,set:s}),Object.defineProperty(rt.createElement("audio"),"src",{get:s,set:s}),Object.defineProperty(rt.createElement("video"),"innerHTML",{get:s,set:s}),Object.defineProperty(rt.createElement("audio"),"innerHTML",{get:s,set:s})}catch{return!1}return!0};bt.supportsNativeTextTracks=function(){return Xp||an&&ma};bt.supportsNativeVideoTracks=function(){return!!(bt.TEST_VID&&bt.TEST_VID.videoTracks)};bt.supportsNativeAudioTracks=function(){return!!(bt.TEST_VID&&bt.TEST_VID.audioTracks)};bt.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]){qp(bt.prototype,s,()=>bt[e](),!0)});bt.prototype.featuresVolumeControl=bt.canControlVolume();bt.prototype.movingMediaElementInDOM=!an;bt.prototype.featuresFullscreenResize=!0;bt.prototype.featuresProgressEvents=!0;bt.prototype.featuresTimeupdateEvents=!0;bt.prototype.featuresVideoFrameCallback=!!(bt.TEST_VID&&bt.TEST_VID.requestVideoFrameCallback);bt.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{}})()}};bt.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){bt.prototype[s]=function(){return this.el_[s]||this.el_.hasAttribute(s)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(s){bt.prototype["set"+ys(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){bt.prototype[s]=function(){return this.el_[s]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(s){bt.prototype["set"+ys(s)]=function(e){this.el_[s]=e}});["pause","load","play"].forEach(function(s){bt.prototype[s]=function(){return this.el_[s]()}});Zt.withSourceHandlers(bt);bt.nativeSourceHandler={};bt.nativeSourceHandler.canPlayType=function(s){try{return bt.TEST_VID.canPlayType(s)}catch{return""}};bt.nativeSourceHandler.canHandleSource=function(s,e){if(s.type)return bt.nativeSourceHandler.canPlayType(s.type);if(s.src){const t=cb(s.src);return bt.nativeSourceHandler.canPlayType(`video/${t}`)}return""};bt.nativeSourceHandler.handleSource=function(s,e,t){e.setSrc(s.src)};bt.nativeSourceHandler.dispose=function(){};bt.registerSourceHandler(bt.nativeSourceHandler);Zt.registerTech("Html5",bt);const mk=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],Yy={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},nx=["tiny","xsmall","small","medium","large","xlarge","huge"],Mm={};nx.forEach(s=>{const e=s.charAt(0)==="x"?`x-${s.substring(1)}`:s;Mm[s]=`vjs-layout-${e}`});const W4={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};let ns=class Xu extends Fe{constructor(e,t,i){if(e.id=e.id||t.id||`vjs_video_${hr()}`,t=Object.assign(Xu.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const o=e.closest("[lang]");o&&(t.language=o.getAttribute("lang"))}if(super(null,t,i),this.boundDocumentFullscreenChange_=o=>this.documentFullscreenChange_(o),this.boundFullWindowOnEscKey_=o=>this.fullWindowOnEscKey(o),this.boundUpdateStyleEl_=o=>this.updateStyleEl_(o),this.boundApplyInitTime_=o=>this.applyInitTime_(o),this.boundUpdateCurrentBreakpoint_=o=>this.updateCurrentBreakpoint_(o),this.boundHandleTechClick_=o=>this.handleTechClick_(o),this.boundHandleTechDoubleClick_=o=>this.handleTechDoubleClick_(o),this.boundHandleTechTouchStart_=o=>this.handleTechTouchStart_(o),this.boundHandleTechTouchMove_=o=>this.handleTechTouchMove_(o),this.boundHandleTechTouchEnd_=o=>this.handleTechTouchEnd_(o),this.boundHandleTechTap_=o=>this.handleTechTap_(o),this.boundUpdatePlayerHeightOnAudioOnlyMode_=o=>this.updatePlayerHeightOnAudioOnlyMode_(o),this.isFullscreen_=!1,this.log=JA(this.id_),this.fsApi_=ep,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&&zo(e),this.language(this.options_.language),t.languages){const o={};Object.getOwnPropertyNames(t.languages).forEach(function(u){o[u.toLowerCase()]=t.languages[u]}),this.languages_=o}else this.languages_=Xu.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(o=>{if(typeof this[o]!="function")throw new Error(`plugin "${o}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),rb(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(sr(rt,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const n=Pi(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(o=>{this[o](t.plugins[o])}),t.debug&&this.debug(!0),this.options_.playerOptions=n,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const u=new he.DOMParser().parseFromString(v4,"image/svg+xml");if(u.querySelector("parsererror"))si.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 x4(this),this.addClass("vjs-spatial-navigation-enabled")),gh&&this.addClass("vjs-touch-enabled"),an||this.addClass("vjs-workinghover"),Xu.players[this.id_]=this;const r=Kv.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",o=>this.listenForUserActivity_(o)),this.on("keydown",o=>this.handleKeyDown(o)),this.on("languagechange",o=>this.handleLanguagechange(o)),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"),on(rt,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),on(rt,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Xu.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),m4(this),gn.names.forEach(e=>{const t=gn[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=zo(e);if(n){for(t=this.el_=e,e=this.tag=rt.createElement("video");t.children.length;)e.appendChild(t.firstChild);ah(t,"video-js")||Kl(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",ma&&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 o=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>oC[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...o),he.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=_C("vjs-styles-dimensions");const c=tl(".vjs-styles-defaults"),d=tl("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);Kl(d,"vjs-hidden"),d.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!i&&e.parentNode.insertBefore(t,e),Wv(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"){si.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)){si.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,Wa(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),q3(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(he.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(":"),o=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/o:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*o,/^[^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: ${o*100}%;
}
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const i=ys(e),n=e.charAt(0).toLowerCase()+e.slice(1);i!=="Html5"&&this.tag&&(Zt.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 o={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};gn.names.forEach(c=>{const d=gn[c];o[d.getterName]=this[d.privateName]}),Object.assign(o,this.options_[i]),Object.assign(o,this.options_[n]),Object.assign(o,this.options_[e.toLowerCase()]),this.tag&&(o.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(o.startTime=this.cache_.currentTime);const u=Zt.getTech(e);if(!u)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new u(o),this.tech_.ready(Yi(this,this.handleTechReady_),!0),tx.jsonToTextTracks(this.textTracksJson_||[],this.tech_),mk.forEach(c=>{this.on(this.tech_,c,d=>this[`handleTech${ys(c)}_`](d))}),Object.keys(Yy).forEach(c=>{this.on(this.tech_,c,d=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${Yy[c]}_`].bind(this),event:d});return}this[`handleTech${Yy[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)&&Wv(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){gn.names.forEach(e=>{const t=gn[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=tx.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&&si.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":Kv}}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 o=this.play();if(lh(o))return o.catch(u=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${u||""}`)})};let i;if(e==="any"&&!this.muted()?(i=this.play(),lh(i)&&(i=i.catch(t))):e==="muted"&&!this.muted()?i=t():i=this.play(),!!lh(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=y4(this,t)),this.cache_.source=Pi({},e,{src:t,type:i});const n=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],o=this.$$("source"),u=[];for(let c=0;c<o.length;c++){const d=zo(o[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 o=this.techGet_("currentSrc");this.lastSource_.tech=o,this.updateSourceCaches_(o)})}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()?na(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()&&!rt.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=rt[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 h4)return c4(this.middleware_,this.tech_,e,t);if(e in kE)return CE(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(i){throw si(i),i}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in d4)return u4(this.middleware_,this.tech_,e);if(e in kE)return CE(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(si(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(si(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(si(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=na){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),i=!!(Xp||an);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=o=>{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")||Rr(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=Rr(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=Rr(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 IC(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",o)}function o(){r(),i()}function u(d,f){r(),n(f)}t.one("fullscreenchange",o),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",o),e.off("fullscreenchange",r)}function r(){n(),t()}function o(c,d){n(),i(d)}e.one("fullscreenchange",r),e.one("fullscreenerror",o);const u=e.exitFullscreenHelper_();u&&(u.then(n,n),u.then(t,i))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=rt[this.fsApi_.exitFullscreen]();return e&&na(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=rt.documentElement.style.overflow,sr(rt,"keydown",this.boundFullWindowOnEscKey_),rt.documentElement.style.overflow="hidden",Kl(rt.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,on(rt,"keydown",this.boundFullWindowOnEscKey_),rt.documentElement.style.overflow=this.docOrigOverflow,Qp(rt.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&&he.documentPictureInPicture){const e=rt.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(Vt("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),he.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(xC(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 rt&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(he.documentPictureInPicture&&he.documentPictureInPicture.window)return he.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in rt)return rt.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const r=n.tagName.toLowerCase();if(n.isContentEditable)return!0;const o=["button","checkbox","hidden","radio","reset","submit"];return r==="input"?o.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=o=>e.key.toLowerCase()==="f",muteKey:n=o=>e.key.toLowerCase()==="m",playPauseKey:r=o=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(i.call(this,e)){e.preventDefault(),e.stopPropagation();const o=Fe.getComponent("FullscreenToggle");rt[this.fsApi_.fullscreenEnabled]!==!1&&o.prototype.handleClick.call(this,e)}else n.call(this,e)?(e.preventDefault(),e.stopPropagation(),Fe.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),Fe.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 o=Zt.getTech(r);if(o||(o=Fe.getComponent(r)),!o){si.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(o.isSupported()&&(t=o.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(u=>[u,Zt.getTech(u)]).filter(([u,c])=>c?c.isSupported():(si.error(`The "${u}" tech is undefined. Skipped browser support check for that tech.`),!1)),i=function(u,c,d){let f;return u.some(p=>c.some(g=>{if(f=d(p,g),f)return!0})),f};let n;const r=u=>(c,d)=>u(d,c),o=([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(o)):n=i(t,e,o),n||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const i=FC(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]),o4(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}l4(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?kC(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();na(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}),Wa(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(el("beforeerror").forEach(t=>{const i=t(this,e);if(!(fa(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 cs(e),this.addClass("vjs-error"),si.error(`(CODE:${this.error_.code} ${cs.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),el("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=Yi(this,this.reportUserActivity),r=function(p){(p.screenX!==t||p.screenY!==i)&&(t=p.screenX,i=p.screenY,n())},o=function(){n(),this.clearInterval(e),e=this.setInterval(n,250)},u=function(p){n(),this.clearInterval(e)};this.on("mousedown",o),this.on("mousemove",r),this.on("mouseup",u),this.on("mouseleave",u);const c=this.getChild("controlBar");c&&!an&&!Ir&&(c.on("mouseenter",function(p){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(p){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 p=this.options_.inactivityTimeout;p<=0||(d=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},p))};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(),Wa(this)&&this.trigger("languagechange"))}languages(){return Pi(Xu.prototype.options_.languages,this.languages_)}toJSON(){const e=Pi(this.options_),t=e.tracks;e.tracks=[];for(let i=0;i<t.length;i++){let n=t[i];n=Pi(n),n.player=void 0,e.tracks[i]=n}return e}createModal(e,t){t=t||{},t.content=e||"";const i=new Bc(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<nx.length;i++){const n=nx[i],r=this.breakpoints_[n];if(t<=r){if(e===n)return;e&&this.removeClass(Mm[e]),this.addClass(Mm[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({},W4,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 Mm[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const i=this.crossOrigin();this.reset(),this.cache_.media=Pi(e);const{artist:n,artwork:r,description:o,poster:u,src:c,textTracks:d,title:f}=this.cache_.media;!r&&u&&(this.cache_.media.artwork=[{src:u,type:cp(u)}]),i&&this.crossOrigin(i),c&&this.src(c),u&&this.poster(u),Array.isArray(d)&&d.forEach(p=>this.addRemoteTextTrack(p,!1)),this.titleBar&&this.titleBar.update({title:f,description:o||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:cp(n.poster)}]),n}return Pi(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},i=zo(e),n=i["data-setup"];if(ah(e,"vjs-fill")&&(i.fill=!0),ah(e,"vjs-fluid")&&(i.fluid=!0),n!==null)try{Object.assign(i,JSON.parse(n||"{}"))}catch(r){si.error("data-setup",r)}if(Object.assign(t,i),e.hasChildNodes()){const r=e.childNodes;for(let o=0,u=r.length;o<u;o++){const c=r[o],d=c.nodeName.toLowerCase();d==="source"?t.sources.push(zo(c)):d==="track"&&t.tracks.push(zo(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"))}};ns.prototype.videoTracks=()=>{};ns.prototype.audioTracks=()=>{};ns.prototype.textTracks=()=>{};ns.prototype.remoteTextTracks=()=>{};ns.prototype.remoteTextTrackEls=()=>{};gn.names.forEach(function(s){const e=gn[s];ns.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});ns.prototype.crossorigin=ns.prototype.crossOrigin;ns.players={};const Vd=he.navigator;ns.prototype.options_={techOrder:Zt.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:Vd&&(Vd.languages&&Vd.languages[0]||Vd.userLanguage||Vd.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};mk.forEach(function(s){ns.prototype[`handleTech${ys(s)}_`]=function(){return this.trigger(s)}});Fe.registerComponent("Player",ns);const dp="plugin",oc="activePlugins_",Ju={},hp=s=>Ju.hasOwnProperty(s),Pm=s=>hp(s)?Ju[s]:void 0,pk=(s,e)=>{s[oc]=s[oc]||{},s[oc][e]=!0},fp=(s,e,t)=>{const i=(t?"before":"")+"pluginsetup";s.trigger(i,e),s.trigger(i+":"+e.name,e)},X4=function(s,e){const t=function(){fp(this,{name:s,plugin:e,instance:null},!0);const i=e.apply(this,arguments);return pk(this,s),fp(this,{name:s,plugin:e,instance:i}),i};return Object.keys(e).forEach(function(i){t[i]=e[i]}),t},GE=(s,e)=>(e.prototype.name=s,function(...t){fp(this,{name:s,plugin:e,instance:null},!0);const i=new e(this,...t);return this[s]=()=>i,fp(this,i.getEventHash()),i});class Fn{constructor(e){if(this.constructor===Fn)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),rb(this),delete this.trigger,CC(this,this.constructor.defaultState),pk(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 Pc(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[oc][e]=!1,this.player=this.state=null,t[e]=GE(e,Ju[e])}static isBasic(e){const t=typeof e=="string"?Pm(e):e;return typeof t=="function"&&!Fn.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(hp(e))si.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(ns.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 Ju[e]=t,e!==dp&&(Fn.isBasic(t)?ns.prototype[e]=X4(e,t):ns.prototype[e]=GE(e,t)),t}static deregisterPlugin(e){if(e===dp)throw new Error("Cannot de-register base plugin.");hp(e)&&(delete Ju[e],delete ns.prototype[e])}static getPlugins(e=Object.keys(Ju)){let t;return e.forEach(i=>{const n=Pm(i);n&&(t=t||{},t[i]=n)}),t}static getPluginVersion(e){const t=Pm(e);return t&&t.VERSION||""}}Fn.getPlugin=Pm;Fn.BASE_PLUGIN_NAME=dp;Fn.registerPlugin(dp,Fn);ns.prototype.usingPlugin=function(s){return!!this[oc]&&this[oc][s]===!0};ns.prototype.hasPlugin=function(s){return!!hp(s)};function Q4(s,e){let t=!1;return function(...i){return t||si.warn(s),t=!0,e.apply(this,i)}}function Nr(s,e,t,i){return Q4(`${e} is deprecated and will be removed in ${s}.0; please use ${t} instead.`,i)}var Z4={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 gk=s=>s.indexOf("#")===0?s.slice(1):s;function De(s,e,t){let i=De.getPlayer(s);if(i)return e&&si.warn(`Player "${s}" is already initialised. Options will not be applied.`),t&&i.ready(t),i;const n=typeof s=="string"?tl("#"+gk(s)):s;if(!Mc(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");const o=("getRootNode"in n?n.getRootNode()instanceof he.ShadowRoot:!1)?n.getRootNode():n.ownerDocument.body;(!n.ownerDocument.defaultView||!o.contains(n))&&si.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)),el("beforesetup").forEach(c=>{const d=c(n,Pi(e));if(!fa(d)||Array.isArray(d)){si.error("please return an object in beforesetup hooks");return}e=Pi(e,d)});const u=Fe.getComponent("Player");return i=new u(n,e,t),el("setup").forEach(c=>c(i)),i}De.hooks_=qa;De.hooks=el;De.hook=I3;De.hookOnce=N3;De.removeHook=ZA;if(he.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&Oc()){let s=tl(".vjs-styles-defaults");if(!s){s=_C("vjs-styles-defaults");const e=tl("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%
}
`)}}Qv(1,De);De.VERSION=Kv;De.options=ns.prototype.options_;De.getPlayers=()=>ns.players;De.getPlayer=s=>{const e=ns.players;let t;if(typeof s=="string"){const i=gk(s),n=e[i];if(n)return n;t=tl("#"+i)}else t=s;if(Mc(t)){const{player:i,playerId:n}=t;if(i||e[n])return i||e[n]}};De.getAllPlayers=()=>Object.keys(ns.players).map(s=>ns.players[s]).filter(Boolean);De.players=ns.players;De.getComponent=Fe.getComponent;De.registerComponent=(s,e)=>(Zt.isTech(e)&&si.warn(`The ${s} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),Fe.registerComponent.call(Fe,s,e));De.getTech=Zt.getTech;De.registerTech=Zt.registerTech;De.use=a4;Object.defineProperty(De,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(De.middleware,"TERMINATOR",{value:up,writeable:!1,enumerable:!0});De.browser=oC;De.obj=P3;De.mergeOptions=Nr(9,"videojs.mergeOptions","videojs.obj.merge",Pi);De.defineLazyProperty=Nr(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",qp);De.bind=Nr(9,"videojs.bind","native Function.prototype.bind",Yi);De.registerPlugin=Fn.registerPlugin;De.deregisterPlugin=Fn.deregisterPlugin;De.plugin=(s,e)=>(si.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),Fn.registerPlugin(s,e));De.getPlugins=Fn.getPlugins;De.getPlugin=Fn.getPlugin;De.getPluginVersion=Fn.getPluginVersion;De.addLanguage=function(s,e){return s=(""+s).toLowerCase(),De.options.languages=Pi(De.options.languages,{[s]:e}),De.options.languages[s]};De.log=si;De.createLogger=JA;De.time=Q3;De.createTimeRange=Nr(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Rr);De.createTimeRanges=Nr(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Rr);De.formatTime=Nr(9,"videojs.formatTime","videojs.time.formatTime",Jl);De.setFormatTime=Nr(9,"videojs.setFormatTime","videojs.time.setFormatTime",LC);De.resetFormatTime=Nr(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",RC);De.parseUrl=Nr(9,"videojs.parseUrl","videojs.url.parseUrl",ub);De.isCrossOrigin=Nr(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",ng);De.EventTarget=nr;De.any=nb;De.on=sr;De.one=ig;De.off=on;De.trigger=Pc;De.xhr=BA;De.TrackList=eu;De.TextTrack=Rh;De.TextTrackList=ob;De.AudioTrack=PC;De.AudioTrackList=NC;De.VideoTrack=BC;De.VideoTrackList=OC;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(s=>{De[s]=function(){return si.warn(`videojs.${s}() is deprecated; use videojs.dom.${s}() instead`),bC[s].apply(null,arguments)}});De.computedStyle=Nr(9,"videojs.computedStyle","videojs.dom.computedStyle",kc);De.dom=bC;De.fn=z3;De.num=C4;De.str=W3;De.url=n4;De.Error=Z4;class J4{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 mp extends De.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 J4(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}}mp.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const s in mp.prototype.allowedEvents_)mp.prototype["on"+s]=null;var yk="4.1.0";const eB=function(s,e){const t=s.qualityLevels,i=new mp,n=function(){i.dispose(),s.qualityLevels=t,s.off("dispose",n)};return s.on("dispose",n),s.qualityLevels=()=>i,s.qualityLevels.VERSION=yk,i},vk=function(s){return eB(this,De.obj.merge({},s))};De.registerPlugin("qualityLevels",vk);vk.VERSION=yk;const On=Hp,pp=(s,e)=>e&&e.responseURL&&s!==e.responseURL?e.responseURL:s,gr=s=>De.log.debug?De.log.debug.bind(De,"VHS:",`${s} >`):function(){};function Ai(...s){const e=De.obj||De;return(e.merge||e.mergeOptions).apply(e,s)}function zs(...s){const e=De.time||De;return(e.createTimeRanges||e.createTimeRanges).apply(e,s)}function tB(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 ra=1/30,aa=ra*3,xk=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 zs(t)},ec=function(s,e){return xk(s,function(t,i){return t-aa<=e&&i+aa>=e})},fm=function(s,e){return xk(s,function(t){return t-ra>=e})},iB=function(s){if(s.length<2)return zs();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 zs(e)},sB=function(s,e){let t=null,i=null,n=0;const r=[],o=[];if(!s||!s.length||!e||!e.length)return zs();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&&(o.push([t,i]),t=null,i=null);return zs(o)},bk=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(", ")},nB=function(s,e,t=1){return((s.length?s.end(s.length-1):0)-e)/t},zl=s=>{const e=[];for(let t=0;t<s.length;t++)e.push({start:s.start(t),end:s.end(t)});return e},rB=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},Wy=function(s){if(!(!s||!s.length||!s.end))return s.end(s.length-1)},Ab=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},Cb=(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},rx=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),[]),Tk=s=>{const e=s.segments&&s.segments.length&&s.segments[s.segments.length-1];return e&&e.parts||[]},_k=({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},Sk=(s,e)=>{if(e.endList)return 0;if(s&&s.suggestedPresentationDelay)return s.suggestedPresentationDelay;const t=Tk(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},aB=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+=Cb(s,n),typeof n.start<"u")return{result:t+n.start,precise:!0}}return{result:t,precise:!1}},oB=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+=Cb(s,i),typeof i.end<"u")return{result:i.end-t,precise:!0}}return{result:-1,precise:!1}},Ek=function(s,e,t){if(typeof e>"u"&&(e=s.mediaSequence+s.segments.length),e<s.mediaSequence)return 0;const i=aB(s,e);if(i.precise)return i.result;const n=oB(s,e);return n.precise?n.result:i.result+t},wk=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 he.Infinity}return Ek(s,e,t)},uh=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},Ak=function(s,e,t,i){if(!s||!s.segments)return null;if(s.endList)return wk(s);if(e===null)return null;e=e||0;let n=Ek(s,s.mediaSequence+s.segments.length,e);return t&&(i=typeof i=="number"?i:Sk(null,s),n-=i),Math.max(0,n)},lB=function(s,e,t){const n=e||0;let r=Ak(s,e,!0,t);return r===null?zs():(r<n&&(r=n),zs(n,r))},uB=function({playlist:s,currentTime:e,startingSegmentIndex:t,startingPartIndex:i,startTime:n,exactManifestTimings:r}){let o=e-n;const u=rx(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(o<0){if(c>0)for(let d=c-1;d>=0;d--){const f=u[d];if(o+=f.duration,r){if(o<0)continue}else if(o+ra<=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n-uh({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(o-=s.targetDuration,o<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];o-=f.duration;const p=f.duration>ra,g=o===0,v=p&&o+ra>=0;if(!((g||v)&&d!==u.length-1)){if(r){if(o>0)continue}else if(o-ra>=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n+uh({defaultDuration:s.targetDuration,durationList:u,startIndex:c,endIndex:d})}}}return{segmentIndex:u[u.length-1].segmentIndex,partIndex:u[u.length-1].partIndex,startTime:e}},Ck=function(s){return s.excludeUntil&&s.excludeUntil>Date.now()},kb=function(s){return s.excludeUntil&&s.excludeUntil===1/0},lg=function(s){const e=Ck(s);return!s.disabled&&!e},cB=function(s){return s.disabled},dB=function(s){for(let e=0;e<s.segments.length;e++)if(s.segments[e].key)return!0;return!1},kk=function(s,e){return e.attributes&&e.attributes[s]},hB=function(s,e,t,i=0){return kk("BANDWIDTH",t)?(s*t.attributes.BANDWIDTH-i*8)/e:NaN},ax=(s,e)=>{if(s.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return s.playlists.filter(i=>lg(i)?(i.attributes.BANDWIDTH||0)<t:!1).length===0},Db=(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),zE=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},Mh=s=>{if(!s||!s.playlists||!s.playlists.length)return zE(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=>jA(r))||zE(s,r=>Db(t,r))))return!1}return!0};var Mn={liveEdgeDelay:Sk,duration:wk,seekable:lB,getMediaInfoForTime:uB,isEnabled:lg,isDisabled:cB,isExcluded:Ck,isIncompatible:kb,playlistEnd:Ak,isAes:dB,hasAttribute:kk,estimateSegmentRequestTime:hB,isLowestEnabledRendition:ax,isAudioOnly:Mh,playlistMatch:Db,segmentDurationWithParts:Cb};const{log:Dk}=De,lc=(s,e)=>`${s}-${e}`,Lk=(s,e,t)=>`placeholder-uri-${s}-${e}-${t}`,fB=({onwarn:s,oninfo:e,manifestString:t,customTagParsers:i=[],customTagMappers:n=[],llhls:r})=>{const o=new eP;s&&o.on("warn",s),e&&o.on("info",e),i.forEach(d=>o.addParser(d)),n.forEach(d=>o.addTagMapper(d)),o.push(t),o.end();const u=o.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,p)=>Math.max(f,p.duration),0)),s&&s({message:`manifest has no targetDuration defaulting to ${d}`}),u.targetDuration=d}const c=Tk(u);if(c.length&&!u.partTargetDuration){const d=c.reduce((f,p)=>Math.max(f,p.duration),0);s&&(s({message:`manifest has no partTargetDuration defaulting to ${d}`}),Dk.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},jc=(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)}})},Rk=({playlist:s,uri:e,id:t})=>{s.id=t,s.playlistErrors_=0,e&&(s.uri=e),s.attributes=s.attributes||{}},mB=s=>{let e=s.playlists.length;for(;e--;){const t=s.playlists[e];Rk({playlist:t,id:lc(e,t.uri)}),t.resolvedUri=On(s.uri,t.uri),s.playlists[t.id]=t,s.playlists[t.uri]=t,t.attributes.BANDWIDTH||Dk.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},pB=s=>{jc(s,e=>{e.uri&&(e.resolvedUri=On(s.uri,e.uri))})},gB=(s,e)=>{const t=lc(0,e),i={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:he.location.href,resolvedUri:he.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return i.playlists[t]=i.playlists[0],i.playlists[e]=i.playlists[0],i},Ik=(s,e,t=Lk)=>{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=Mh(s);jc(s,(n,r,o,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===o)return}n.playlists=[Ss({},n)]}n.playlists.forEach(function(c,d){const f=t(r,o,u,c),p=lc(d,f);c.uri?c.resolvedUri=c.resolvedUri||On(s.uri,c.uri):(c.uri=d===0?f:p,c.resolvedUri=c.uri),c.id=c.id||p,c.attributes=c.attributes||{},s.playlists[c.id]=c,s.playlists[c.uri]=c})}),mB(s),pB(s)};class qE{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 Nk=22,Xl=({requestType:s,request:e,error:t,parseFailure:i})=>{const n=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,o={uri:e.uri,requestType:s},u=n&&!r||i;if(t&&r)o.error=Ss({},t),o.errorType=De.Error.NetworkRequestFailed;else if(e.aborted)o.errorType=De.Error.NetworkRequestAborted;else if(e.timedout)o.errorType=De.Error.NetworkRequestTimeout;else if(u){const c=i?De.Error.NetworkBodyParserFailed:De.Error.NetworkBadStatus;o.errorType=c,o.status=e.status,o.headers=e.headers}return o},yB=gr("CodecUtils"),Ok=function(s){const e=s.attributes||{};if(e.CODECS)return ea(e.CODECS)},Mk=(s,e)=>{const t=e.attributes||{};return s&&s.mediaGroups&&s.mediaGroups.AUDIO&&t.AUDIO&&s.mediaGroups.AUDIO[t.AUDIO]},vB=(s,e)=>{if(!Mk(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},xh=function(s){const e={};return s.forEach(({mediaType:t,type:i,details:n})=>{e[t]=e[t]||[],e[t].push(UA(`${i}${n}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){yB(`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},KE=function(s){let e=0;return s.audio&&e++,s.video&&e++,e},ch=function(s,e){const t=e.attributes||{},i=xh(Ok(e)||[]);if(Mk(s,e)&&!i.audio&&!vB(s,e)){const n=xh(iP(s,t.AUDIO)||[]);n.audio&&(i.audio=n.audio)}return i},{EventTarget:xB}=De,bB=(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||[],o=_k(e)-1;o>-1&&o!==r.length-1&&(t._HLS_part=o),(o>-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 he.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},TB=(s,e)=>{if(!s)return e;const t=Ai(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]=Ai(s.parts[i],e.parts[i]));return!s.skipped&&e.skipped&&(t.skipped=!1),s.preload&&!e.preload&&(t.preload=!1),t},_B=(s,e,t)=>{const i=s.slice(),n=e.slice();t=t||0;const r=[];let o;for(let u=0;u<n.length;u++){const c=i[u+t],d=n[u];c?(o=c.map||o,r.push(TB(c,d))):(o&&!d.map&&(d.map=o),r.push(d))}return r},Pk=(s,e)=>{!s.resolvedUri&&s.uri&&(s.resolvedUri=On(e,s.uri)),s.key&&!s.key.resolvedUri&&(s.key.resolvedUri=On(e,s.key.uri)),s.map&&!s.map.resolvedUri&&(s.map.resolvedUri=On(e,s.map.uri)),s.map&&s.map.key&&!s.map.key.resolvedUri&&(s.map.key.resolvedUri=On(e,s.map.key.uri)),s.parts&&s.parts.length&&s.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=On(e,t.uri))}),s.preloadHints&&s.preloadHints.length&&s.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=On(e,t.uri))})},Bk=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},Fk=(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,ox=(s,e,t=Fk)=>{const i=Ai(s,{}),n=i.playlists[e.id];if(!n||t(n,e))return null;e.segments=Bk(e);const r=Ai(n,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,n.segments){if(e.skip){e.segments=e.segments||[];for(let o=0;o<e.skip.skippedSegments;o++)e.segments.unshift({skipped:!0})}r.segments=_B(n.segments,e.segments,e.mediaSequence-n.mediaSequence)}r.segments.forEach(o=>{Pk(o,r.resolvedUri)});for(let o=0;o<i.playlists.length;o++)i.playlists[o].id===e.id&&(i.playlists[o]=r);return i.playlists[e.id]=r,i.playlists[e.uri]=r,jc(s,(o,u,c,d)=>{if(o.playlists)for(let f=0;f<o.playlists.length;f++)e.id===o.playlists[f].id&&(o.playlists[f]=r)}),i},lx=(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},YE=(s,e,t)=>{if(!s)return;const i=[];return s.forEach(n=>{if(!n.attributes)return;const{BANDWIDTH:r,RESOLUTION:o,CODECS:u}=n.attributes;i.push({id:n.id,bandwidth:r,resolution:o,codecs:u})}),{type:e,isLive:t,renditions:i}};let tc=class extends xB{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=gr("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 qE,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=On(this.main.uri,e.uri);this.llhls&&(t=bB(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:Xl({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{const i=fB({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:De.Error.StreamingHlsPlaylistParserError,error:i}}}excludeAudioOnlyVariants(e){const t=i=>{const n=i.attributes||{},{width:r,height:o}=n.RESOLUTION||{};if(r&&o)return!0;const u=Ok(i)||[];return!!xh(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 o=t||this.parseManifest_({url:i,manifestString:e});o.lastRequest=Date.now(),Rk({playlist:o,uri:i,id:n});const u=ox(this.main,o);this.targetDuration=o.partTargetDuration||o.targetDuration,this.pendingMedia_=null,u?(this.main=u,this.media_=this.main.playlists[n]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(lx(this.media(),!!u)),r.parsedPlaylist=YE(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),he.clearTimeout(this.mediaUpdateTimeout),he.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new qE,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(he.clearTimeout(this.finalRenditionTimeout),t){const u=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=he.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_(lx(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 o={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:o}),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=pp(e.resolvedUri,c),u)return this.playlistRequestError(this.request,e,i);this.trigger({type:"playlistrequestcomplete",metadata:o}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(he.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&&(he.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const i=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=he.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&&(he.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=he.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=he.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:Xl({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=pp(this.src,i),this.trigger({type:"playlistparsestart",metadata:e});const n=this.parseManifest_({manifestString:i.responseText,url:this.src});e.parsedPlaylist=YE(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,Ik(this.main,this.srcUri()),e.playlists.forEach(i=>{i.segments=Bk(i),i.segments.forEach(n=>{Pk(n,i.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||he.location.href;this.main=gB(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 o=i.playlists[r];if(o.attributes["PATHWAY-ID"]===n){const u=o.resolvedUri,c=o.id;if(t){const d=this.createCloneURI_(o.resolvedUri,e),f=lc(n,d),p=this.createCloneAttributes_(n,o.attributes),g=this.createClonePlaylist_(o,f,e,p);i.playlists[r]=g,i.playlists[f]=g,i.playlists[d]=g}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 o in i.mediaGroups[r])if(o===n){for(const u in i.mediaGroups[r][o])i.mediaGroups[r][o][u].playlists.forEach((d,f)=>{const p=i.playlists[d.id],g=p.id,v=p.resolvedUri;delete i.playlists[g],delete i.playlists[v]});delete i.mediaGroups[r][o]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const i=this.main,n=i.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),o=lc(e.ID,r),u=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,o,e,u);i.playlists[n]=c,i.playlists[o]=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 o in n.mediaGroups[r]){if(o===i)n.mediaGroups[r][t]={};else continue;for(const u in n.mediaGroups[r][o]){const c=n.mediaGroups[r][o][u];n.mediaGroups[r][t][u]=Ss({},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((p,g)=>{const v=n.playlists[p.id],b=Lk(r,t,u),_=lc(t,b);if(v&&!n.playlists[_]){const S=this.createClonePlaylist_(v,_,e),D=S.resolvedUri;n.playlists[_]=S,n.playlists[D]=S}d.playlists[g]=this.createClonePlaylist_(p,_,e)})}}})}createClonePlaylist_(e,t,i,n){const r=this.createCloneURI_(e.resolvedUri,i),o={resolvedUri:r,uri:r,id:t};return e.segments&&(o.segments=[]),n&&(o.attributes=n),Ai(e,o)}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 ux=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)},SB=(s,e)=>{if(!s||!s.size)return;let t=e;return s.forEach(i=>{t=i(t)}),t},EB=(s,e,t,i)=>{!s||!s.size||s.forEach(n=>{n(e,t,i)})},Uk=function(){const s=function e(t,i){t=Ai({timeout:45e3},t);const n=e.beforeRequest||De.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||De.Vhs.xhr._requestCallbackSet||new Set,o=e._responseCallbackSet||De.Vhs.xhr._responseCallbackSet;n&&typeof n=="function"&&(De.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(n));const u=De.Vhs.xhr.original===!0?De.xhr:De.Vhs.xhr,c=SB(r,t);r.delete(n);const d=u(c||t,function(p,g){return EB(o,d,p,g),ux(d,p,g,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},wB=function(s){let e;const t=s.offset;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=he.BigInt(s.offset)+he.BigInt(s.length)-he.BigInt(1):e=s.offset+s.length-1,"bytes="+t+"-"+e},cx=function(s){const e={};return s.byterange&&(e.Range=wB(s.byterange)),e},AB=function(s,e){return s.start(e)+"-"+s.end(e)},CB=function(s,e){const t=s.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},kB=function(s){return s>=32&&s<126?String.fromCharCode(s):"."},jk=function(s){const e={};return Object.keys(s).forEach(t=>{const i=s[t];HA(i)?e[t]={bytes:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength}:e[t]=i}),e},gp=function(s){const e=s.byterange||{length:1/0,offset:0};return[e.length,e.offset,s.resolvedUri].join(",")},$k=function(s){return s.resolvedUri},Hk=s=>{const e=Array.prototype.slice.call(s),t=16;let i="",n,r;for(let o=0;o<e.length/t;o++)n=e.slice(o*t,o*t+t).map(CB).join(""),r=e.slice(o*t,o*t+t).map(kB).join(""),i+=n+" "+r+`
`;return i},DB=({bytes:s})=>Hk(s),LB=s=>{let e="",t;for(t=0;t<s.length;t++)e+=AB(s,t)+" ";return e};var RB=Object.freeze({__proto__:null,createTransferableMessage:jk,initSegmentId:gp,segmentKeyId:$k,hexDump:Hk,tagDump:DB,textRanges:LB});const Vk=.25,IB=(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)},NB=s=>s.transmuxedPresentationEnd-s.transmuxedPresentationStart-s.transmuxerPrependedSeconds,OB=(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,o=n.videoTimingInfo?NB(n.videoTimingInfo):n.duration+n.duration*Vk,u=new Date(r.getTime()+o*1e3);return t>u?null:(t>new Date(r)&&(i=n),{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:Mn.duration(e,e.mediaSequence+e.segments.indexOf(i)),type:i.videoTimingInfo?"accurate":"estimate"})},MB=(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*Vk)return null;i=n}return{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:t-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}},PB=(s,e)=>{let t,i;try{t=new Date(s),i=new Date(e)}catch{}const n=t.getTime();return(i.getTime()-n)/1e3},BB=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},FB=({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=MB(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=IB(e,i.segment);return r&&(n.programDateTime=r.toISOString()),t(null,n)},Gk=({programTime:s,playlist:e,retryCount:t=2,seekTo:i,pauseAfterSeek:n=!0,tech:r,callback:o})=>{if(!o)throw new Error("seekToProgramTime: callback must be provided");if(typeof s>"u"||!e||!i)return o({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return o({message:"player must be playing a live stream to start buffering"});if(!BB(e))return o({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const u=OB(s,e);if(!u)return o({message:`${s} was not found in the stream`});const c=u.segment,d=PB(c.dateTimeObject,s);if(u.type==="estimate"){if(t===0)return o({message:`${s} is not buffered yet. Try again`});i(u.estimatedStart+d),r.one("seeked",()=>{Gk({programTime:s,playlist:e,retryCount:t-1,seekTo:i,pauseAfterSeek:n,tech:r,callback:o})});return}const f=c.start+d,p=()=>o(null,r.currentTime());r.one("seeked",p),n&&r.pause(),i(f)},Xy=(s,e)=>{if(s.readyState===4)return e()},UB=(s,e,t,i)=>{let n=[],r,o=!1;const u=function(p,g,v,b){return g.abort(),o=!0,t(p,g,v,b)},c=function(p,g){if(o)return;if(p)return p.metadata=Xl({requestType:i,request:g,error:p}),u(p,g,"",n);const v=g.responseText.substring(n&&n.byteLength||0,g.responseText.length);if(n=hP(n,VA(v,!0)),r=r||Qd(n),n.length<10||r&&n.length<r+2)return Xy(g,()=>u(p,g,"",n));const b=Jx(n);return b==="ts"&&n.length<188?Xy(g,()=>u(p,g,"",n)):!b&&n.length<376?Xy(g,()=>u(p,g,"",n)):u(null,g,b,n)},f=e({uri:s,beforeSend(p){p.overrideMimeType("text/plain; charset=x-user-defined"),p.addEventListener("progress",function({total:g,loaded:v}){return ux(p,null,{statusCode:p.status},c)})}},function(p,g){return ux(f,p,g,c)});return f},{EventTarget:jB}=De,WE=function(s,e){if(!Fk(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,o=n.byterange;if(r&&!o||!r&&o||r.offset!==o.offset||r.length!==o.length)return!1}return!0},$B=(s,e,t,i)=>{const n=i.attributes.NAME||t;return`placeholder-uri-${s}-${e}-${n}`},HB=({mainXml:s,srcUrl:e,clientOffset:t,sidxMapping:i,previousManifest:n})=>{const r=c3(s,{manifestUri:e,clientOffset:t,sidxMapping:i,previousManifest:n});return Ik(r,e,$B),r},VB=(s,e)=>{jc(s,(t,i,n,r)=>{(!e.mediaGroups[i][n]||!(r in e.mediaGroups[i][n]))&&delete s.mediaGroups[i][n][r]})},GB=(s,e,t)=>{let i=!0,n=Ai(s,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const o=e.playlists[r];if(o.sidx){const c=Gp(o.sidx);t&&t[c]&&t[c].sidx&&Xx(o,t[c].sidx,o.sidx.resolvedUri)}const u=ox(n,o,WE);u&&(n=u,i=!1)}return jc(e,(r,o,u,c)=>{if(r.playlists&&r.playlists.length){const d=r.playlists[0].id,f=ox(n,r.playlists[0],WE);f&&(n=f,c in n.mediaGroups[o][u]||(n.mediaGroups[o][u][c]=r),n.mediaGroups[o][u][c].playlists[0]=n.playlists[d],i=!1)}}),VB(n,e),e.minimumUpdatePeriod!==s.minimumUpdatePeriod&&(i=!1),i?null:n},zB=(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,XE=(s,e)=>{const t={};for(const i in s){const r=s[i].sidx;if(r){const o=Gp(r);if(!e[o])break;const u=e[o].sidxInfo;zB(u,r)&&(t[o]=e[o])}}return t},qB=(s,e)=>{let i=XE(s.playlists,e);return jc(s,(n,r,o,u)=>{if(n.playlists&&n.playlists.length){const c=n.playlists;i=Ai(i,XE(c,e))}}),i};class dx extends jB{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_=gr("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&&Gp(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){he.clearTimeout(this.mediaRequest_),this.mediaRequest_=he.setTimeout(()=>i(!1),0);return}const r=pp(e.sidx.resolvedUri),o=(c,d)=>{if(this.requestErrored_(c,d,t))return;const f=this.mainPlaylistLoader_.sidxMapping_,{requestType:p}=d;let g;try{g=p3(Pt(d.response).subarray(8))}catch(v){v.metadata=Xl({requestType:p,request:d,parseFailure:!0}),this.requestErrored_(v,d,t);return}return f[n]={sidxInfo:e.sidx,sidx:g},Xx(e,g,e.sidx.resolvedUri),i(!0)},u="dash-sidx";this.request=UB(r,this.vhs_.xhr,(c,d,f,p)=>{if(c)return o(c,d);if(!f||f!=="mp4"){const b=f||"unknown";return o({status:d.status,message:`Unsupported ${b} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},d)}const{offset:g,length:v}=e.sidx.byterange;if(p.length>=v+g)return o(c,{response:p.subarray(g,g+v),status:d.status,uri:d.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:cx({byterange:e.sidx.byterange})},o)},u)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},he.clearTimeout(this.minimumUpdatePeriodTimeout_),he.clearTimeout(this.mediaRequest_),he.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,he.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(),he.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(he.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,he.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const i=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=he.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_){he.clearTimeout(this.mediaRequest_),this.mediaRequest_=he.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:o}=n;i.metadata=Xl({requestType:o,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=pp(this.mainPlaylistLoader_.srcUrl,n),r){this.handleMain_(),this.syncClientServerClock_(()=>e(n,r));return}return e(n,r)})}syncClientServerClock_(e){const t=d3(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:On(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:o}=n;return this.error.metadata=Xl({requestType:o,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_(){he.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=HB({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:De.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(i=GB(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:o}=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:!o,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_&&(he.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_=he.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_=qB(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=he.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},lx(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 Vs={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 KB=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},zk=function(s){return s.on=s.addEventListener,s.off=s.removeEventListener,s},YB=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())}},qk=function(s){return function(){const e=YB(s),t=zk(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}},Kk=function(s){return`var browserWorkerPolyFill = ${zk.toString()};
browserWorkerPolyFill(self);
`+s},Yk=function(s){return s.toString().replace(/^function.+?{/,"").slice(0,-1)},WB=Kk(Yk(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(w,k){x[w]||(x[w]=[]),x[w]=x[w].concat(k)},this.off=function(w,k){var C;return x[w]?(C=x[w].indexOf(k),x[w]=x[w].slice(),x[w].splice(C,1),C>-1):!1},this.trigger=function(w){var k,C,N,B;if(k=x[w],!!k)if(arguments.length===2)for(N=k.length,C=0;C<N;++C)k[C].call(this,arguments[1]);else{for(B=[],C=arguments.length,C=1;C<arguments.length;++C)B.push(arguments[C]);for(N=k.length,C=0;C<N;++C)k[C].apply(this,B)}},this.dispose=function(){x={}}}};e.prototype.pipe=function(x){return this.on("data",function(w){x.push(w)}),this.on("done",function(w){x.flush(w)}),this.on("partialdone",function(w){x.partialFlush(w)}),this.on("endedtimeline",function(w){x.endTimeline(w)}),this.on("reset",function(w){x.reset(w)}),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 w=new DataView(x.buffer,x.byteOffset,x.byteLength),k;return w.getBigUint64?(k=w.getBigUint64(0),k<Number.MAX_SAFE_INTEGER?Number(k):k):w.getUint32(0)*i+w.getUint32(4)},r={getUint64:n,MAX_UINT32:i},o=r.MAX_UINT32,u,c,d,f,p,g,v,b,_,S,D,R,L,M,j,V,P,z,I,O,W,X,q,ue,ie,Y,G,J,oe,ce,F,ee,pe,_e,ve,Ce;(function(){var x;if(q={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 q)q.hasOwnProperty(x)&&(q[x]=[x.charCodeAt(0),x.charCodeAt(1),x.charCodeAt(2),x.charCodeAt(3)]);ue=new Uint8Array([105,115,111,109]),Y=new Uint8Array([97,118,99,49]),ie=new Uint8Array([0,0,0,1]),G=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]),J=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]),oe={video:G,audio:J},ee=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]),pe=new Uint8Array([0,0,0,0,0,0,0,0]),_e=pe,ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ce=pe,ce=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),u=function(x){var w=[],k=0,C,N,B;for(C=1;C<arguments.length;C++)w.push(arguments[C]);for(C=w.length;C--;)k+=w[C].byteLength;for(N=new Uint8Array(k+8),B=new DataView(N.buffer,N.byteOffset,N.byteLength),B.setUint32(0,N.byteLength),N.set(x,4),C=0,k=8;C<w.length;C++)N.set(w[C],k),k+=w[C].byteLength;return N},c=function(){return u(q.dinf,u(q.dref,ee))},d=function(x){return u(q.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(q.ftyp,ue,ie,ue,Y)},V=function(x){return u(q.hdlr,oe[x])},p=function(x){return u(q.mdat,x)},j=function(x){var w=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&&(w[12]=x.samplerate>>>24&255,w[13]=x.samplerate>>>16&255,w[14]=x.samplerate>>>8&255,w[15]=x.samplerate&255),u(q.mdhd,w)},M=function(x){return u(q.mdia,j(x),V(x.type),v(x))},g=function(x){return u(q.mfhd,new Uint8Array([0,0,0,0,(x&4278190080)>>24,(x&16711680)>>16,(x&65280)>>8,x&255]))},v=function(x){return u(q.minf,x.type==="video"?u(q.vmhd,ce):u(q.smhd,F),c(),z(x))},b=function(x,w){for(var k=[],C=w.length;C--;)k[C]=O(w[C]);return u.apply(null,[q.moof,g(x)].concat(k))},_=function(x){for(var w=x.length,k=[];w--;)k[w]=R(x[w]);return u.apply(null,[q.moov,D(4294967295)].concat(k).concat(S(x)))},S=function(x){for(var w=x.length,k=[];w--;)k[w]=W(x[w]);return u.apply(null,[q.mvex].concat(k))},D=function(x){var w=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(q.mvhd,w)},P=function(x){var w=x.samples||[],k=new Uint8Array(4+w.length),C,N;for(N=0;N<w.length;N++)C=w[N].flags,k[N+4]=C.dependsOn<<4|C.isDependedOn<<2|C.hasRedundancy;return u(q.sdtp,k)},z=function(x){return u(q.stbl,I(x),u(q.stts,Ce),u(q.stsc,_e),u(q.stsz,ve),u(q.stco,pe))},(function(){var x,w;I=function(k){return u(q.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),k.type==="video"?x(k):w(k))},x=function(k){var C=k.sps||[],N=k.pps||[],B=[],te=[],ne,le;for(ne=0;ne<C.length;ne++)B.push((C[ne].byteLength&65280)>>>8),B.push(C[ne].byteLength&255),B=B.concat(Array.prototype.slice.call(C[ne]));for(ne=0;ne<N.length;ne++)te.push((N[ne].byteLength&65280)>>>8),te.push(N[ne].byteLength&255),te=te.concat(Array.prototype.slice.call(N[ne]));if(le=[q.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,(k.width&65280)>>8,k.width&255,(k.height&65280)>>8,k.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(q.avcC,new Uint8Array([1,k.profileIdc,k.profileCompatibility,k.levelIdc,255].concat([C.length],B,[N.length],te))),u(q.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],k.sarRatio){var fe=k.sarRatio[0],Se=k.sarRatio[1];le.push(u(q.pasp,new Uint8Array([(fe&4278190080)>>24,(fe&16711680)>>16,(fe&65280)>>8,fe&255,(Se&4278190080)>>24,(Se&16711680)>>16,(Se&65280)>>8,Se&255])))}return u.apply(null,le)},w=function(k){return u(q.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(k.channelcount&65280)>>8,k.channelcount&255,(k.samplesize&65280)>>8,k.samplesize&255,0,0,0,0,(k.samplerate&65280)>>8,k.samplerate&255,0,0]),d(k))}})(),L=function(x){var w=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(q.tkhd,w)},O=function(x){var w,k,C,N,B,te,ne;return w=u(q.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])),te=Math.floor(x.baseMediaDecodeTime/o),ne=Math.floor(x.baseMediaDecodeTime%o),k=u(q.tfdt,new Uint8Array([1,0,0,0,te>>>24&255,te>>>16&255,te>>>8&255,te&255,ne>>>24&255,ne>>>16&255,ne>>>8&255,ne&255])),B=92,x.type==="audio"?(C=X(x,B),u(q.traf,w,k,C)):(N=P(x),C=X(x,N.length+B),u(q.traf,w,k,C,N))},R=function(x){return x.duration=x.duration||4294967295,u(q.trak,L(x),M(x))},W=function(x){var w=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"&&(w[w.length-1]=0),u(q.trex,w)},(function(){var x,w,k;k=function(C,N){var B=0,te=0,ne=0,le=0;return C.length&&(C[0].duration!==void 0&&(B=1),C[0].size!==void 0&&(te=2),C[0].flags!==void 0&&(ne=4),C[0].compositionTimeOffset!==void 0&&(le=8)),[0,0,B|te|ne|le,1,(C.length&4278190080)>>>24,(C.length&16711680)>>>16,(C.length&65280)>>>8,C.length&255,(N&4278190080)>>>24,(N&16711680)>>>16,(N&65280)>>>8,N&255]},w=function(C,N){var B,te,ne,le,fe,Se;for(le=C.samples||[],N+=20+16*le.length,ne=k(le,N),te=new Uint8Array(ne.length+le.length*16),te.set(ne),B=ne.length,Se=0;Se<le.length;Se++)fe=le[Se],te[B++]=(fe.duration&4278190080)>>>24,te[B++]=(fe.duration&16711680)>>>16,te[B++]=(fe.duration&65280)>>>8,te[B++]=fe.duration&255,te[B++]=(fe.size&4278190080)>>>24,te[B++]=(fe.size&16711680)>>>16,te[B++]=(fe.size&65280)>>>8,te[B++]=fe.size&255,te[B++]=fe.flags.isLeading<<2|fe.flags.dependsOn,te[B++]=fe.flags.isDependedOn<<6|fe.flags.hasRedundancy<<4|fe.flags.paddingValue<<1|fe.flags.isNonSyncSample,te[B++]=fe.flags.degradationPriority&61440,te[B++]=fe.flags.degradationPriority&15,te[B++]=(fe.compositionTimeOffset&4278190080)>>>24,te[B++]=(fe.compositionTimeOffset&16711680)>>>16,te[B++]=(fe.compositionTimeOffset&65280)>>>8,te[B++]=fe.compositionTimeOffset&255;return u(q.trun,te)},x=function(C,N){var B,te,ne,le,fe,Se;for(le=C.samples||[],N+=20+8*le.length,ne=k(le,N),B=new Uint8Array(ne.length+le.length*8),B.set(ne),te=ne.length,Se=0;Se<le.length;Se++)fe=le[Se],B[te++]=(fe.duration&4278190080)>>>24,B[te++]=(fe.duration&16711680)>>>16,B[te++]=(fe.duration&65280)>>>8,B[te++]=fe.duration&255,B[te++]=(fe.size&4278190080)>>>24,B[te++]=(fe.size&16711680)>>>16,B[te++]=(fe.size&65280)>>>8,B[te++]=fe.size&255;return u(q.trun,B)},X=function(C,N){return C.type==="audio"?x(C,N):w(C,N)}})();var Be={ftyp:f,mdat:p,moof:b,moov:_,initSegment:function(x){var w=f(),k=_(x),C;return C=new Uint8Array(w.byteLength+k.byteLength),C.set(w),C.set(k,w.byteLength),C}},tt=function(x){var w,k,C=[],N=[];for(N.byteLength=0,N.nalCount=0,N.duration=0,C.byteLength=0,w=0;w<x.length;w++)k=x[w],k.nalUnitType==="access_unit_delimiter_rbsp"?(C.length&&(C.duration=k.dts-C.dts,N.byteLength+=C.byteLength,N.nalCount+=C.length,N.duration+=C.duration,N.push(C)),C=[k],C.byteLength=k.data.byteLength,C.pts=k.pts,C.dts=k.dts):(k.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(C.keyFrame=!0),C.duration=k.dts-C.dts,C.byteLength+=k.data.byteLength,C.push(k));return N.length&&(!C.duration||C.duration<=0)&&(C.duration=N[N.length-1].duration),N.byteLength+=C.byteLength,N.nalCount+=C.length,N.duration+=C.duration,N.push(C),N},Je=function(x){var w,k,C=[],N=[];for(C.byteLength=0,C.nalCount=0,C.duration=0,C.pts=x[0].pts,C.dts=x[0].dts,N.byteLength=0,N.nalCount=0,N.duration=0,N.pts=x[0].pts,N.dts=x[0].dts,w=0;w<x.length;w++)k=x[w],k.keyFrame?(C.length&&(N.push(C),N.byteLength+=C.byteLength,N.nalCount+=C.nalCount,N.duration+=C.duration),C=[k],C.nalCount=k.length,C.byteLength=k.byteLength,C.pts=k.pts,C.dts=k.dts,C.duration=k.duration):(C.duration+=k.duration,C.nalCount+=k.length,C.byteLength+=k.byteLength,C.push(k));return N.length&&C.duration<=0&&(C.duration=N[N.length-1].duration),N.byteLength+=C.byteLength,N.nalCount+=C.nalCount,N.duration+=C.duration,N.push(C),N},Ct=function(x){var w;return!x[0][0].keyFrame&&x.length>1&&(w=x.shift(),x.byteLength-=w.byteLength,x.nalCount-=w.nalCount,x[0][0].dts=w.dts,x[0][0].pts=w.pts,x[0][0].duration+=w.duration),x},st=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},mt=function(x,w){var k=st();return k.dataOffset=w,k.compositionTimeOffset=x.pts-x.dts,k.duration=x.duration,k.size=4*x.length,k.size+=x.byteLength,x.keyFrame&&(k.flags.dependsOn=2,k.flags.isNonSyncSample=0),k},pt=function(x,w){var k,C,N,B,te,ne=w||0,le=[];for(k=0;k<x.length;k++)for(B=x[k],C=0;C<B.length;C++)te=B[C],N=mt(te,ne),ne+=N.size,le.push(N);return le},ut=function(x){var w,k,C,N,B,te,ne=0,le=x.byteLength,fe=x.nalCount,Se=le+4*fe,Oe=new Uint8Array(Se),ct=new DataView(Oe.buffer);for(w=0;w<x.length;w++)for(N=x[w],k=0;k<N.length;k++)for(B=N[k],C=0;C<B.length;C++)te=B[C],ct.setUint32(ne,te.data.byteLength),ne+=4,Oe.set(te.data,ne),ne+=te.data.byteLength;return Oe},Ht=function(x,w){var k,C=w||0,N=[];return k=mt(x,C),N.push(k),N},at=function(x){var w,k,C=0,N=x.byteLength,B=x.length,te=N+4*B,ne=new Uint8Array(te),le=new DataView(ne.buffer);for(w=0;w<x.length;w++)k=x[w],le.setUint32(C,k.data.byteLength),C+=4,ne.set(k.data,C),C+=k.data.byteLength;return ne},gt={groupNalsIntoFrames:tt,groupFramesIntoGops:Je,extendFirstKeyFrame:Ct,generateSampleTable:pt,concatenateNalData:ut,generateSampleTableForFrame:Ht,concatenateNalDataForFrame:at},Dt=[33,16,5,32,164,27],Nt=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],dt=function(x){for(var w=[];x--;)w.push(0);return w},lt=function(x){return Object.keys(x).reduce(function(w,k){return w[k]=new Uint8Array(x[k].reduce(function(C,N){return C.concat(N)},[])),w},{})},ye,ze=function(){if(!ye){var x={96e3:[Dt,[227,64],dt(154),[56]],88200:[Dt,[231],dt(170),[56]],64e3:[Dt,[248,192],dt(240),[56]],48e3:[Dt,[255,192],dt(268),[55,148,128],dt(54),[112]],44100:[Dt,[255,192],dt(268),[55,163,128],dt(84),[112]],32e3:[Dt,[255,192],dt(268),[55,234],dt(226),[112]],24e3:[Dt,[255,192],dt(268),[55,255,128],dt(268),[111,112],dt(126),[224]],16e3:[Dt,[255,192],dt(268),[55,255,128],dt(268),[111,255],dt(269),[223,108],dt(195),[1,192]],12e3:[Nt,dt(268),[3,127,248],dt(268),[6,255,240],dt(268),[13,255,224],dt(268),[27,253,128],dt(259),[56]],11025:[Nt,dt(268),[3,127,248],dt(268),[6,255,240],dt(268),[13,255,224],dt(268),[27,255,192],dt(268),[55,175,128],dt(108),[112]],8e3:[Nt,dt(268),[3,121,16],dt(47),[7]]};ye=lt(x)}return ye},We=9e4,et,ot,nt,vt,Xe,Ft,Gt;et=function(x){return x*We},ot=function(x,w){return x*w},nt=function(x){return x/We},vt=function(x,w){return x/w},Xe=function(x,w){return et(vt(x,w))},Ft=function(x,w){return ot(nt(x),w)},Gt=function(x,w,k){return nt(k?x:x-w)};var wt={ONE_SECOND_IN_TS:We,secondsToVideoTs:et,secondsToAudioTs:ot,videoTsToSeconds:nt,audioTsToSeconds:vt,audioTsToVideoTs:Xe,videoTsToAudioTs:Ft,metadataTsToSeconds:Gt},hi=ze,Qe=wt,Lt=function(x){var w,k,C=0;for(w=0;w<x.length;w++)k=x[w],C+=k.data.byteLength;return C},Ut=function(x,w,k,C){var N,B=0,te=0,ne=0,le=0,fe,Se,Oe;if(w.length&&(N=Qe.audioTsToVideoTs(x.baseMediaDecodeTime,x.samplerate),B=Math.ceil(Qe.ONE_SECOND_IN_TS/(x.samplerate/1024)),k&&C&&(te=N-Math.max(k,C),ne=Math.floor(te/B),le=ne*B),!(ne<1||le>Qe.ONE_SECOND_IN_TS/2))){for(fe=hi()[x.samplerate],fe||(fe=w[0].data),Se=0;Se<ne;Se++)Oe=w[0],w.splice(0,0,{data:fe,dts:Oe.dts-B,pts:Oe.pts-B});return x.baseMediaDecodeTime-=Math.floor(Qe.videoTsToAudioTs(le,x.samplerate)),le}},vi=function(x,w,k){return w.minSegmentDts>=k?x:(w.minSegmentDts=1/0,x.filter(function(C){return C.dts>=k?(w.minSegmentDts=Math.min(w.minSegmentDts,C.dts),w.minSegmentPts=w.minSegmentDts,!0):!1}))},gi=function(x){var w,k,C=[];for(w=0;w<x.length;w++)k=x[w],C.push({size:k.data.byteLength,duration:1024});return C},kt=function(x){var w,k,C=0,N=new Uint8Array(Lt(x));for(w=0;w<x.length;w++)k=x[w],N.set(k.data,C),C+=k.data.byteLength;return N},ht={prefixWithSilence:Ut,trimAdtsFramesByEarliestDts:vi,generateSampleTable:gi,concatenateFrameData:kt},ri=wt.ONE_SECOND_IN_TS,Ie=function(x,w){typeof w.pts=="number"&&(x.timelineStartInfo.pts===void 0&&(x.timelineStartInfo.pts=w.pts),x.minSegmentPts===void 0?x.minSegmentPts=w.pts:x.minSegmentPts=Math.min(x.minSegmentPts,w.pts),x.maxSegmentPts===void 0?x.maxSegmentPts=w.pts:x.maxSegmentPts=Math.max(x.maxSegmentPts,w.pts)),typeof w.dts=="number"&&(x.timelineStartInfo.dts===void 0&&(x.timelineStartInfo.dts=w.dts),x.minSegmentDts===void 0?x.minSegmentDts=w.dts:x.minSegmentDts=Math.min(x.minSegmentDts,w.dts),x.maxSegmentDts===void 0?x.maxSegmentDts=w.dts:x.maxSegmentDts=Math.max(x.maxSegmentDts,w.dts))},H=function(x){delete x.minSegmentDts,delete x.maxSegmentDts,delete x.minSegmentPts,delete x.maxSegmentPts},K=function(x,w){var k,C,N=x.minSegmentDts;return w||(N-=x.timelineStartInfo.dts),k=x.timelineStartInfo.baseMediaDecodeTime,k+=N,k=Math.max(0,k),x.type==="audio"&&(C=x.samplerate/ri,k*=C,k=Math.floor(k)),k},re={clearDtsInfo:H,calculateTrackBaseMediaDecodeTime:K,collectDtsInfo:Ie},Ee=4,Ye=128,Tt=function(x){for(var w=0,k={payloadType:-1,payloadSize:0},C=0,N=0;w<x.byteLength&&x[w]!==Ye;){for(;x[w]===255;)C+=255,w++;for(C+=x[w++];x[w]===255;)N+=255,w++;if(N+=x[w++],!k.payload&&C===Ee){var B=String.fromCharCode(x[w+3],x[w+4],x[w+5],x[w+6]);if(B==="GA94"){k.payloadType=C,k.payloadSize=N,k.payload=x.subarray(w,w+N);break}else k.payload=void 0}w+=N,C=0,N=0}return k},zt=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)},xi=function(x,w){var k=[],C,N,B,te;if(!(w[0]&64))return k;for(N=w[0]&31,C=0;C<N;C++)B=C*3,te={type:w[B+2]&3,pts:x},w[B+2]&4&&(te.ccData=w[B+3]<<8|w[B+4],k.push(te));return k},Wi=function(x){for(var w=x.byteLength,k=[],C=1,N,B;C<w-2;)x[C]===0&&x[C+1]===0&&x[C+2]===3?(k.push(C+2),C+=2):C++;if(k.length===0)return x;N=w-k.length,B=new Uint8Array(N);var te=0;for(C=0;C<N;te++,C++)te===k[0]&&(te++,k.shift()),B[C]=x[te];return B},Xi={parseSei:Tt,parseUserData:zt,parseCaptionPackets:xi,discardEmulationPreventionBytes:Wi,USER_DATA_REGISTERED_ITU_T_T35:Ee},rs=t,Qi=Xi,ai=function(x){x=x||{},ai.prototype.init.call(this),this.parse708captions_=typeof x.parse708captions=="boolean"?x.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new li(0,0),new li(0,1),new li(1,0),new li(1,1)],this.parse708captions_&&(this.cc708Stream_=new jt({captionServices:x.captionServices})),this.reset(),this.ccStreams_.forEach(function(w){w.on("data",this.trigger.bind(this,"data")),w.on("partialdone",this.trigger.bind(this,"partialdone")),w.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")))};ai.prototype=new rs,ai.prototype.push=function(x){var w,k,C;if(x.nalUnitType==="sei_rbsp"&&(w=Qi.parseSei(x.escapedRBSP),!!w.payload&&w.payloadType===Qi.USER_DATA_REGISTERED_ITU_T_T35&&(k=Qi.parseUserData(w),!!k))){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=Qi.parseCaptionPackets(x.pts,k),this.captionPackets_=this.captionPackets_.concat(C),this.latestDts_!==x.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=x.dts}},ai.prototype.flushCCStreams=function(x){this.ccStreams_.forEach(function(w){return x==="flush"?w.flush():w.partialFlush()},this)},ai.prototype.flushStream=function(x){if(!this.captionPackets_.length){this.flushCCStreams(x);return}this.captionPackets_.forEach(function(w,k){w.presortIndex=k}),this.captionPackets_.sort(function(w,k){return w.pts===k.pts?w.presortIndex-k.presortIndex:w.pts-k.pts}),this.captionPackets_.forEach(function(w){w.type<2?this.dispatchCea608Packet(w):this.dispatchCea708Packet(w)},this),this.captionPackets_.length=0,this.flushCCStreams(x)},ai.prototype.flush=function(){return this.flushStream("flush")},ai.prototype.partialFlush=function(){return this.flushStream("partialFlush")},ai.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(x){x.reset()})},ai.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)},ai.prototype.setsChannel1Active=function(x){return(x.ccData&30720)===4096},ai.prototype.setsChannel2Active=function(x){return(x.ccData&30720)===6144},ai.prototype.setsTextOrXDSActive=function(x){return(x.ccData&28928)===256||(x.ccData&30974)===4138||(x.ccData&30974)===6186},ai.prototype.dispatchCea708Packet=function(x){this.parse708captions_&&this.cc708Stream_.push(x)};var Fi={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},Ui=function(x){var w=Fi[x]||x;return x&4096&&x===w?"":String.fromCharCode(w)},Ei=function(x){return 32<=x&&x<=127||160<=x&&x<=255},Wt=function(x){this.windowNum=x,this.reset()};Wt.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},Wt.prototype.getText=function(){return this.rows.join(`
`)},Wt.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},Wt.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--},Wt.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},Wt.prototype.addText=function(x){this.rows[this.rowIdx]+=x},Wt.prototype.backspace=function(){if(!this.isEmpty()){var x=this.rows[this.rowIdx];this.rows[this.rowIdx]=x.substr(0,x.length-1)}};var Kt=function(x,w,k){this.serviceNum=x,this.text="",this.currentWindow=new Wt(-1),this.windows=[],this.stream=k,typeof w=="string"&&this.createTextDecoder(w)};Kt.prototype.init=function(x,w){this.startPts=x;for(var k=0;k<8;k++)this.windows[k]=new Wt(k),typeof w=="function"&&(this.windows[k].beforeRowOverflow=w)},Kt.prototype.setCurrentWindow=function(x){this.currentWindow=this.windows[x]},Kt.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(w){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+x+" encoding. "+w})}};var jt=function(x){x=x||{},jt.prototype.init.call(this);var w=this,k=x.captionServices||{},C={},N;Object.keys(k).forEach(B=>{N=k[B],/^SERVICE/.test(B)&&(C[B]=N.encoding)}),this.serviceEncodings=C,this.current708Packet=null,this.services={},this.push=function(B){B.type===3?(w.new708Packet(),w.add708Bytes(B)):(w.current708Packet===null&&w.new708Packet(),w.add708Bytes(B))}};jt.prototype=new rs,jt.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},jt.prototype.add708Bytes=function(x){var w=x.ccData,k=w>>>8,C=w&255;this.current708Packet.ptsVals.push(x.pts),this.current708Packet.data.push(k),this.current708Packet.data.push(C)},jt.prototype.push708Packet=function(){var x=this.current708Packet,w=x.data,k=null,C=null,N=0,B=w[N++];for(x.seq=B>>6,x.sizeCode=B&63;N<w.length;N++)B=w[N++],k=B>>5,C=B&31,k===7&&C>0&&(B=w[N++],k=B),this.pushServiceBlock(k,N,C),C>0&&(N+=C-1)},jt.prototype.pushServiceBlock=function(x,w,k){var C,N=w,B=this.current708Packet.data,te=this.services[x];for(te||(te=this.initService(x,N));N<w+k&&N<B.length;N++)C=B[N],Ei(C)?N=this.handleText(N,te):C===24?N=this.multiByteCharacter(N,te):C===16?N=this.extendedCommands(N,te):128<=C&&C<=135?N=this.setCurrentWindow(N,te):152<=C&&C<=159?N=this.defineWindow(N,te):C===136?N=this.clearWindows(N,te):C===140?N=this.deleteWindows(N,te):C===137?N=this.displayWindows(N,te):C===138?N=this.hideWindows(N,te):C===139?N=this.toggleWindows(N,te):C===151?N=this.setWindowAttributes(N,te):C===144?N=this.setPenAttributes(N,te):C===145?N=this.setPenColor(N,te):C===146?N=this.setPenLocation(N,te):C===143?te=this.reset(N,te):C===8?te.currentWindow.backspace():C===12?te.currentWindow.clearText():C===13?te.currentWindow.pendingNewLine=!0:C===14?te.currentWindow.clearText():C===141&&N++},jt.prototype.extendedCommands=function(x,w){var k=this.current708Packet.data,C=k[++x];return Ei(C)&&(x=this.handleText(x,w,{isExtended:!0})),x},jt.prototype.getPts=function(x){return this.current708Packet.ptsVals[Math.floor(x/2)]},jt.prototype.initService=function(x,w){var C="SERVICE"+x,k=this,C,N;return C in this.serviceEncodings&&(N=this.serviceEncodings[C]),this.services[x]=new Kt(x,N,k),this.services[x].init(this.getPts(w),function(B){k.flushDisplayed(B,k.services[x])}),this.services[x]},jt.prototype.handleText=function(x,w,k){var C=k&&k.isExtended,N=k&&k.isMultiByte,B=this.current708Packet.data,te=C?4096:0,ne=B[x],le=B[x+1],fe=w.currentWindow,Se,Oe;function ct(Ue){return Ue.map(xt=>("0"+(xt&255).toString(16)).slice(-2)).join("")}if(N?(Oe=[ne,le],x++):Oe=[ne],w.textDecoder_&&!C)Se=w.textDecoder_.decode(new Uint8Array(Oe));else if(N){const Ue=ct(Oe);Se=String.fromCharCode(parseInt(Ue,16))}else Se=Ui(te|ne);return fe.pendingNewLine&&!fe.isEmpty()&&fe.newLine(this.getPts(x)),fe.pendingNewLine=!1,fe.addText(Se),x},jt.prototype.multiByteCharacter=function(x,w){var k=this.current708Packet.data,C=k[x+1],N=k[x+2];return Ei(C)&&Ei(N)&&(x=this.handleText(++x,w,{isMultiByte:!0})),x},jt.prototype.setCurrentWindow=function(x,w){var k=this.current708Packet.data,C=k[x],N=C&7;return w.setCurrentWindow(N),x},jt.prototype.defineWindow=function(x,w){var k=this.current708Packet.data,C=k[x],N=C&7;w.setCurrentWindow(N);var B=w.currentWindow;return C=k[++x],B.visible=(C&32)>>5,B.rowLock=(C&16)>>4,B.columnLock=(C&8)>>3,B.priority=C&7,C=k[++x],B.relativePositioning=(C&128)>>7,B.anchorVertical=C&127,C=k[++x],B.anchorHorizontal=C,C=k[++x],B.anchorPoint=(C&240)>>4,B.rowCount=C&15,C=k[++x],B.columnCount=C&63,C=k[++x],B.windowStyle=(C&56)>>3,B.penStyle=C&7,B.virtualRowCount=B.rowCount+1,x},jt.prototype.setWindowAttributes=function(x,w){var k=this.current708Packet.data,C=k[x],N=w.currentWindow.winAttr;return C=k[++x],N.fillOpacity=(C&192)>>6,N.fillRed=(C&48)>>4,N.fillGreen=(C&12)>>2,N.fillBlue=C&3,C=k[++x],N.borderType=(C&192)>>6,N.borderRed=(C&48)>>4,N.borderGreen=(C&12)>>2,N.borderBlue=C&3,C=k[++x],N.borderType+=(C&128)>>5,N.wordWrap=(C&64)>>6,N.printDirection=(C&48)>>4,N.scrollDirection=(C&12)>>2,N.justify=C&3,C=k[++x],N.effectSpeed=(C&240)>>4,N.effectDirection=(C&12)>>2,N.displayEffect=C&3,x},jt.prototype.flushDisplayed=function(x,w){for(var k=[],C=0;C<8;C++)w.windows[C].visible&&!w.windows[C].isEmpty()&&k.push(w.windows[C].getText());w.endPts=x,w.text=k.join(`
`),this.pushCaption(w),w.startPts=x},jt.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)},jt.prototype.displayWindows=function(x,w){var k=this.current708Packet.data,C=k[++x],N=this.getPts(x);this.flushDisplayed(N,w);for(var B=0;B<8;B++)C&1<<B&&(w.windows[B].visible=1);return x},jt.prototype.hideWindows=function(x,w){var k=this.current708Packet.data,C=k[++x],N=this.getPts(x);this.flushDisplayed(N,w);for(var B=0;B<8;B++)C&1<<B&&(w.windows[B].visible=0);return x},jt.prototype.toggleWindows=function(x,w){var k=this.current708Packet.data,C=k[++x],N=this.getPts(x);this.flushDisplayed(N,w);for(var B=0;B<8;B++)C&1<<B&&(w.windows[B].visible^=1);return x},jt.prototype.clearWindows=function(x,w){var k=this.current708Packet.data,C=k[++x],N=this.getPts(x);this.flushDisplayed(N,w);for(var B=0;B<8;B++)C&1<<B&&w.windows[B].clearText();return x},jt.prototype.deleteWindows=function(x,w){var k=this.current708Packet.data,C=k[++x],N=this.getPts(x);this.flushDisplayed(N,w);for(var B=0;B<8;B++)C&1<<B&&w.windows[B].reset();return x},jt.prototype.setPenAttributes=function(x,w){var k=this.current708Packet.data,C=k[x],N=w.currentWindow.penAttr;return C=k[++x],N.textTag=(C&240)>>4,N.offset=(C&12)>>2,N.penSize=C&3,C=k[++x],N.italics=(C&128)>>7,N.underline=(C&64)>>6,N.edgeType=(C&56)>>3,N.fontStyle=C&7,x},jt.prototype.setPenColor=function(x,w){var k=this.current708Packet.data,C=k[x],N=w.currentWindow.penColor;return C=k[++x],N.fgOpacity=(C&192)>>6,N.fgRed=(C&48)>>4,N.fgGreen=(C&12)>>2,N.fgBlue=C&3,C=k[++x],N.bgOpacity=(C&192)>>6,N.bgRed=(C&48)>>4,N.bgGreen=(C&12)>>2,N.bgBlue=C&3,C=k[++x],N.edgeRed=(C&48)>>4,N.edgeGreen=(C&12)>>2,N.edgeBlue=C&3,x},jt.prototype.setPenLocation=function(x,w){var k=this.current708Packet.data,C=k[x],N=w.currentWindow.penLoc;return w.currentWindow.pendingNewLine=!0,C=k[++x],N.row=C&15,C=k[++x],N.column=C&63,x},jt.prototype.reset=function(x,w){var k=this.getPts(x);return this.flushDisplayed(k,w),this.initService(w.serviceNum,x)};var Ii={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},ds=function(x){return x===null?"":(x=Ii[x]||x,String.fromCharCode(x))},as=14,Fs=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],fi=function(){for(var x=[],w=as+1;w--;)x.push({text:"",indent:0,offset:0});return x},li=function(x,w){li.prototype.init.call(this),this.field_=x||0,this.dataChannel_=w||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(k){var C,N,B,te,ne;if(C=k.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,te=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(k.pts),this.flushDisplayed(k.pts),N=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=N,this.startPts_=k.pts;else if(C===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(k.pts);else if(C===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(k.pts);else if(C===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(k.pts);else if(C===this.CARRIAGE_RETURN_)this.clearFormatting(k.pts),this.flushDisplayed(k.pts),this.shiftRowsUp_(),this.startPts_=k.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(k.pts),this.displayed_=fi();else if(C===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=fi();else if(C===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(k.pts),this.displayed_=fi()),this.mode_="paintOn",this.startPts_=k.pts;else if(this.isSpecialCharacter(B,te))B=(B&3)<<8,ne=ds(B|te),this[this.mode_](k.pts,ne),this.column_++;else if(this.isExtCharacter(B,te))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,ne=ds(B|te),this[this.mode_](k.pts,ne),this.column_++;else if(this.isMidRowCode(B,te))this.clearFormatting(k.pts),this[this.mode_](k.pts," "),this.column_++,(te&14)===14&&this.addFormatting(k.pts,["i"]),(te&1)===1&&this.addFormatting(k.pts,["u"]);else if(this.isOffsetControlCode(B,te)){const fe=te&3;this.nonDisplayed_[this.row_].offset=fe,this.column_+=fe}else if(this.isPAC(B,te)){var le=Fs.indexOf(C&7968);if(this.mode_==="rollUp"&&(le-this.rollUpRows_+1<0&&(le=this.rollUpRows_-1),this.setRollUp(k.pts,le)),le!==this.row_&&le>=0&&le<=14&&(this.clearFormatting(k.pts),this.row_=le),te&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(k.pts,["u"]),(C&16)===16){const fe=(C&14)>>1;this.column_=fe*4,this.nonDisplayed_[this.row_].indent+=fe}this.isColorPAC(te)&&(te&14)===14&&this.addFormatting(k.pts,["i"])}else this.isNormalChar(B)&&(te===0&&(te=null),ne=ds(B),ne+=ds(te),this[this.mode_](k.pts,ne),this.column_+=ne.length)}};li.prototype=new rs,li.prototype.flushDisplayed=function(x){const w=C=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+C+"."})},k=[];this.displayed_.forEach((C,N)=>{if(C&&C.text&&C.text.length){try{C.text=C.text.trim()}catch{w(N)}C.text.length&&k.push({text:C.text,line:N+1,position:10+Math.min(70,C.indent*10)+C.offset*2.5})}else C==null&&w(N)}),k.length&&this.trigger("data",{startPts:this.startPts_,endPts:x,content:k,stream:this.name_})},li.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=fi(),this.nonDisplayed_=fi(),this.lastControlCode_=null,this.column_=0,this.row_=as,this.rollUpRows_=2,this.formatting_=[]},li.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},li.prototype.isSpecialCharacter=function(x,w){return x===this.EXT_&&w>=48&&w<=63},li.prototype.isExtCharacter=function(x,w){return(x===this.EXT_+1||x===this.EXT_+2)&&w>=32&&w<=63},li.prototype.isMidRowCode=function(x,w){return x===this.EXT_&&w>=32&&w<=47},li.prototype.isOffsetControlCode=function(x,w){return x===this.OFFSET_&&w>=33&&w<=35},li.prototype.isPAC=function(x,w){return x>=this.BASE_&&x<this.BASE_+8&&w>=64&&w<=127},li.prototype.isColorPAC=function(x){return x>=64&&x<=79||x>=96&&x<=127},li.prototype.isNormalChar=function(x){return x>=32&&x<=127},li.prototype.setRollUp=function(x,w){if(this.mode_!=="rollUp"&&(this.row_=as,this.mode_="rollUp",this.flushDisplayed(x),this.nonDisplayed_=fi(),this.displayed_=fi()),w!==void 0&&w!==this.row_)for(var k=0;k<this.rollUpRows_;k++)this.displayed_[w-k]=this.displayed_[this.row_-k],this.displayed_[this.row_-k]={text:"",indent:0,offset:0};w===void 0&&(w=this.row_),this.topRow_=w-this.rollUpRows_+1},li.prototype.addFormatting=function(x,w){this.formatting_=this.formatting_.concat(w);var k=w.reduce(function(C,N){return C+"<"+N+">"},"");this[this.mode_](x,k)},li.prototype.clearFormatting=function(x){if(this.formatting_.length){var w=this.formatting_.reverse().reduce(function(k,C){return k+"</"+C+">"},"");this.formatting_=[],this[this.mode_](x,w)}},li.prototype.popOn=function(x,w){var k=this.nonDisplayed_[this.row_].text;k+=w,this.nonDisplayed_[this.row_].text=k},li.prototype.rollUp=function(x,w){var k=this.displayed_[this.row_].text;k+=w,this.displayed_[this.row_].text=k},li.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<as+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}},li.prototype.paintOn=function(x,w){var k=this.displayed_[this.row_].text;k+=w,this.displayed_[this.row_].text=k};var ji={CaptionStream:ai,Cea608Stream:li,Cea708Stream:jt},hs={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Us=t,Q=8589934592,se=4294967296,ae="shared",xe=function(x,w){var k=1;for(x>w&&(k=-1);Math.abs(w-x)>se;)x+=k*Q;return x},Te=function(x){var w,k;Te.prototype.init.call(this),this.type_=x||ae,this.push=function(C){if(C.type==="metadata"){this.trigger("data",C);return}this.type_!==ae&&C.type!==this.type_||(k===void 0&&(k=C.dts),C.dts=xe(C.dts,k),C.pts=xe(C.pts,k),w=C.dts,this.trigger("data",C))},this.flush=function(){k=w,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){k=void 0,w=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Te.prototype=new Us;var je={TimestampRolloverStream:Te,handleRollover:xe},de=(x,w,k)=>{if(!x)return-1;for(var C=k;C<x.length;C++)if(x[C]===w)return C;return-1},me={typedArrayIndexOf:de},Pe=me.typedArrayIndexOf,it={Utf8:3},ft=function(x,w,k){var C,N="";for(C=w;C<k;C++)N+="%"+("00"+x[C].toString(16)).slice(-2);return N},Ke=function(x,w,k){return decodeURIComponent(ft(x,w,k))},Ve=function(x,w,k){return unescape(ft(x,w,k))},Ze=function(x){return x[0]<<21|x[1]<<14|x[2]<<7|x[3]},_t={APIC:function(x){var w=1,k,C,N="-->";x.data[0]===it.Utf8&&(k=Pe(x.data,0,w),!(k<0)&&(x.mimeType=Ve(x.data,w,k),w=k+1,x.pictureType=x.data[w],w++,C=Pe(x.data,0,w),!(C<0)&&(x.description=Ke(x.data,w,C),w=C+1,x.mimeType===N?x.url=Ve(x.data,w,x.data.length):x.pictureData=x.data.subarray(w,x.data.length))))},"T*":function(x){x.data[0]===it.Utf8&&(x.value=Ke(x.data,1,x.data.length).replace(/\0*$/,""),x.values=x.value.split("\0"))},TXXX:function(x){var w;x.data[0]===it.Utf8&&(w=Pe(x.data,0,1),w!==-1&&(x.description=Ke(x.data,1,w),x.value=Ke(x.data,w+1,x.data.length).replace(/\0*$/,""),x.data=x.value))},"W*":function(x){x.url=Ve(x.data,0,x.data.length).replace(/\0.*$/,"")},WXXX:function(x){var w;x.data[0]===it.Utf8&&(w=Pe(x.data,0,1),w!==-1&&(x.description=Ke(x.data,1,w),x.url=Ve(x.data,w+1,x.data.length).replace(/\0.*$/,"")))},PRIV:function(x){var w;for(w=0;w<x.data.length;w++)if(x.data[w]===0){x.owner=Ve(x.data,0,w);break}x.privateData=x.data.subarray(w+1),x.data=x.privateData}},St=function(x){var w,k,C=10,N=0,B=[];if(!(x.length<10||x[0]!==73||x[1]!==68||x[2]!==51)){N=Ze(x.subarray(6,10)),N+=10;var te=x[5]&64;te&&(C+=4,C+=Ze(x.subarray(10,14)),N-=Ze(x.subarray(16,20)));do{if(w=Ze(x.subarray(C+4,C+8)),w<1)break;k=String.fromCharCode(x[C],x[C+1],x[C+2],x[C+3]);var ne={id:k,data:x.subarray(C+10,C+w+10)};ne.key=ne.id,_t[ne.id]?_t[ne.id](ne):ne.id[0]==="T"?_t["T*"](ne):ne.id[0]==="W"&&_t["W*"](ne),B.push(ne),C+=10,C+=w}while(C<N);return B}},Bt={parseId3Frames:St,parseSyncSafeInteger:Ze,frameParsers:_t},Ti=t,Js=hs,vs=Bt,Ls;Ls=function(x){var w={descriptor:x&&x.descriptor},k=0,C=[],N=0,B;if(Ls.prototype.init.call(this),this.dispatchType=Js.METADATA_STREAM_TYPE.toString(16),w.descriptor)for(B=0;B<w.descriptor.length;B++)this.dispatchType+=("00"+w.descriptor[B].toString(16)).slice(-2);this.push=function(te){var ne,le,fe,Se,Oe,ct;if(te.type==="timed-metadata"){if(te.dataAlignmentIndicator&&(N=0,C.length=0),C.length===0&&(te.data.length<10||te.data[0]!==73||te.data[1]!==68||te.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(C.push(te),N+=te.data.byteLength,C.length===1&&(k=vs.parseSyncSafeInteger(te.data.subarray(6,10)),k+=10),!(N<k)){for(ne={data:new Uint8Array(k),frames:[],pts:C[0].pts,dts:C[0].dts},Oe=0;Oe<k;)ne.data.set(C[0].data.subarray(0,k-Oe),Oe),Oe+=C[0].data.byteLength,N-=C[0].data.byteLength,C.shift();le=10,ne.data[5]&64&&(le+=4,le+=vs.parseSyncSafeInteger(ne.data.subarray(10,14)),k-=vs.parseSyncSafeInteger(ne.data.subarray(16,20)));do{if(fe=vs.parseSyncSafeInteger(ne.data.subarray(le+4,le+8)),fe<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(ct=String.fromCharCode(ne.data[le],ne.data[le+1],ne.data[le+2],ne.data[le+3]),Se={id:ct,data:ne.data.subarray(le+10,le+fe+10)},Se.key=Se.id,vs.frameParsers[Se.id]?vs.frameParsers[Se.id](Se):Se.id[0]==="T"?vs.frameParsers["T*"](Se):Se.id[0]==="W"&&vs.frameParsers["W*"](Se),Se.owner==="com.apple.streaming.transportStreamTimestamp"){var Ue=Se.data,xt=(Ue[3]&1)<<30|Ue[4]<<22|Ue[5]<<14|Ue[6]<<6|Ue[7]>>>2;xt*=4,xt+=Ue[7]&3,Se.timeStamp=xt,ne.pts===void 0&&ne.dts===void 0&&(ne.pts=Se.timeStamp,ne.dts=Se.timeStamp),this.trigger("timestamp",Se)}ne.frames.push(Se),le+=10,le+=fe}while(le<k);this.trigger("data",ne)}}}},Ls.prototype=new Ti;var Ja=Ls,eo=t,xa=ji,Es=hs,su=je.TimestampRolloverStream,Or,un,rl,vr=188,qi=71;Or=function(){var x=new Uint8Array(vr),w=0;Or.prototype.init.call(this),this.push=function(k){var C=0,N=vr,B;for(w?(B=new Uint8Array(k.byteLength+w),B.set(x.subarray(0,w)),B.set(k,w),w=0):B=k;N<B.byteLength;){if(B[C]===qi&&B[N]===qi){this.trigger("data",B.subarray(C,N)),C+=vr,N+=vr;continue}C++,N++}C<B.byteLength&&(x.set(B.subarray(C),0),w=B.byteLength-C)},this.flush=function(){w===vr&&x[0]===qi&&(this.trigger("data",x),w=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){w=0,this.trigger("reset")}},Or.prototype=new eo,un=function(){var x,w,k,C;un.prototype.init.call(this),C=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,x=function(N,B){var te=0;B.payloadUnitStartIndicator&&(te+=N[te]+1),B.type==="pat"?w(N.subarray(te),B):k(N.subarray(te),B)},w=function(N,B){B.section_number=N[7],B.last_section_number=N[8],C.pmtPid=(N[10]&31)<<8|N[11],B.pmtPid=C.pmtPid},k=function(N,B){var te,ne,le,fe;if(N[5]&1){for(C.programMapTable={video:null,audio:null,"timed-metadata":{}},te=(N[1]&15)<<8|N[2],ne=3+te-4,le=(N[10]&15)<<8|N[11],fe=12+le;fe<ne;){var Se=N[fe],Oe=(N[fe+1]&31)<<8|N[fe+2];Se===Es.H264_STREAM_TYPE&&C.programMapTable.video===null?C.programMapTable.video=Oe:Se===Es.ADTS_STREAM_TYPE&&C.programMapTable.audio===null?C.programMapTable.audio=Oe:Se===Es.METADATA_STREAM_TYPE&&(C.programMapTable["timed-metadata"][Oe]=Se),fe+=((N[fe+3]&15)<<8|N[fe+4])+5}B.programMapTable=C.programMapTable}},this.push=function(N){var B={},te=4;if(B.payloadUnitStartIndicator=!!(N[1]&64),B.pid=N[1]&31,B.pid<<=8,B.pid|=N[2],(N[3]&48)>>>4>1&&(te+=N[te]+1),B.pid===0)B.type="pat",x(N.subarray(te),B),this.trigger("data",B);else if(B.pid===this.pmtPid)for(B.type="pmt",x(N.subarray(te),B),this.trigger("data",B);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([N,te,B]):this.processPes_(N,te,B)},this.processPes_=function(N,B,te){te.pid===this.programMapTable.video?te.streamType=Es.H264_STREAM_TYPE:te.pid===this.programMapTable.audio?te.streamType=Es.ADTS_STREAM_TYPE:te.streamType=this.programMapTable["timed-metadata"][te.pid],te.type="pes",te.data=N.subarray(B),this.trigger("data",te)}},un.prototype=new eo,un.STREAM_TYPES={h264:27,adts:15},rl=function(){var x=this,w=!1,k={data:[],size:0},C={data:[],size:0},N={data:[],size:0},B,te=function(le,fe){var Se;const Oe=le[0]<<16|le[1]<<8|le[2];fe.data=new Uint8Array,Oe===1&&(fe.packetLength=6+(le[4]<<8|le[5]),fe.dataAlignmentIndicator=(le[6]&4)!==0,Se=le[7],Se&192&&(fe.pts=(le[9]&14)<<27|(le[10]&255)<<20|(le[11]&254)<<12|(le[12]&255)<<5|(le[13]&254)>>>3,fe.pts*=4,fe.pts+=(le[13]&6)>>>1,fe.dts=fe.pts,Se&64&&(fe.dts=(le[14]&14)<<27|(le[15]&255)<<20|(le[16]&254)<<12|(le[17]&255)<<5|(le[18]&254)>>>3,fe.dts*=4,fe.dts+=(le[18]&6)>>>1)),fe.data=le.subarray(9+le[8]))},ne=function(le,fe,Se){var Oe=new Uint8Array(le.size),ct={type:fe},Ue=0,xt=0,Yt=!1,xs;if(!(!le.data.length||le.size<9)){for(ct.trackId=le.data[0].pid,Ue=0;Ue<le.data.length;Ue++)xs=le.data[Ue],Oe.set(xs.data,xt),xt+=xs.data.byteLength;te(Oe,ct),Yt=fe==="video"||ct.packetLength<=le.size,(Se||Yt)&&(le.size=0,le.data.length=0),Yt&&x.trigger("data",ct)}};rl.prototype.init.call(this),this.push=function(le){({pat:function(){},pes:function(){var fe,Se;switch(le.streamType){case Es.H264_STREAM_TYPE:fe=k,Se="video";break;case Es.ADTS_STREAM_TYPE:fe=C,Se="audio";break;case Es.METADATA_STREAM_TYPE:fe=N,Se="timed-metadata";break;default:return}le.payloadUnitStartIndicator&&ne(fe,Se,!0),fe.data.push(le),fe.size+=le.data.byteLength},pmt:function(){var fe={type:"metadata",tracks:[]};B=le.programMapTable,B.video!==null&&fe.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"}),B.audio!==null&&fe.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"}),w=!0,x.trigger("data",fe)}})[le.type]()},this.reset=function(){k.size=0,k.data.length=0,C.size=0,C.data.length=0,this.trigger("reset")},this.flushStreams_=function(){ne(k,"video"),ne(C,"audio"),ne(N,"timed-metadata")},this.flush=function(){if(!w&&B){var le={type:"metadata",tracks:[]};B.video!==null&&le.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.video,codec:"avc",type:"video"}),B.audio!==null&&le.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+B.audio,codec:"adts",type:"audio"}),x.trigger("data",le)}w=!1,this.flushStreams_(),this.trigger("done")}},rl.prototype=new eo;var Ji={PAT_PID:0,MP2T_PACKET_LENGTH:vr,TransportPacketStream:Or,TransportParseStream:un,ElementaryStream:rl,TimestampRolloverStream:su,CaptionStream:xa.CaptionStream,Cea608Stream:xa.Cea608Stream,Cea708Stream:xa.Cea708Stream,MetadataStream:Ja};for(var jn in Es)Es.hasOwnProperty(jn)&&(Ji[jn]=Es[jn]);var al=Ji,nu=t,xr=wt.ONE_SECOND_IN_TS,to,ru=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];to=function(x){var w,k=0;to.prototype.init.call(this),this.skipWarn_=function(C,N){this.trigger("log",{level:"warn",message:`adts skiping bytes ${C} to ${N} in frame ${k} outside syncword`})},this.push=function(C){var N=0,B,te,ne,le,fe;if(x||(k=0),C.type==="audio"){w&&w.length?(ne=w,w=new Uint8Array(ne.byteLength+C.data.byteLength),w.set(ne),w.set(C.data,ne.byteLength)):w=C.data;for(var Se;N+7<w.length;){if(w[N]!==255||(w[N+1]&246)!==240){typeof Se!="number"&&(Se=N),N++;continue}if(typeof Se=="number"&&(this.skipWarn_(Se,N),Se=null),te=(~w[N+1]&1)*2,B=(w[N+3]&3)<<11|w[N+4]<<3|(w[N+5]&224)>>5,le=((w[N+6]&3)+1)*1024,fe=le*xr/ru[(w[N+2]&60)>>>2],w.byteLength-N<B)break;this.trigger("data",{pts:C.pts+k*fe,dts:C.dts+k*fe,sampleCount:le,audioobjecttype:(w[N+2]>>>6&3)+1,channelcount:(w[N+2]&1)<<2|(w[N+3]&192)>>>6,samplerate:ru[(w[N+2]&60)>>>2],samplingfrequencyindex:(w[N+2]&60)>>>2,samplesize:16,data:w.subarray(N+7+te,N+B)}),k++,N+=B}typeof Se=="number"&&(this.skipWarn_(Se,N),Se=null),w=w.subarray(N)}},this.flush=function(){k=0,this.trigger("done")},this.reset=function(){w=void 0,this.trigger("reset")},this.endTimeline=function(){w=void 0,this.trigger("endedtimeline")}},to.prototype=new nu;var io=to,ba;ba=function(x){var w=x.byteLength,k=0,C=0;this.length=function(){return 8*w},this.bitsAvailable=function(){return 8*w+C},this.loadWord=function(){var N=x.byteLength-w,B=new Uint8Array(4),te=Math.min(4,w);if(te===0)throw new Error("no bytes available");B.set(x.subarray(N,N+te)),k=new DataView(B.buffer).getUint32(0),C=te*8,w-=te},this.skipBits=function(N){var B;C>N?(k<<=N,C-=N):(N-=C,B=Math.floor(N/8),N-=B*8,w-=B,this.loadWord(),k<<=N,C-=N)},this.readBits=function(N){var B=Math.min(C,N),te=k>>>32-B;return C-=B,C>0?k<<=B:w>0&&this.loadWord(),B=N-B,B>0?te<<B|this.readBits(B):te},this.skipLeadingZeros=function(){var N;for(N=0;N<C;++N)if((k&2147483648>>>N)!==0)return k<<=N,C-=N,N;return this.loadWord(),N+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var N=this.skipLeadingZeros();return this.readBits(N+1)-1},this.readExpGolomb=function(){var N=this.readUnsignedExpGolomb();return 1&N?1+N>>>1:-1*(N>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var Ph=ba,au=t,Bh=Ph,Mr,xn,ou;xn=function(){var x=0,w,k;xn.prototype.init.call(this),this.push=function(C){var N;k?(N=new Uint8Array(k.byteLength+C.data.byteLength),N.set(k),N.set(C.data,k.byteLength),k=N):k=C.data;for(var B=k.byteLength;x<B-3;x++)if(k[x+2]===1){w=x+5;break}for(;w<B;)switch(k[w]){case 0:if(k[w-1]!==0){w+=2;break}else if(k[w-2]!==0){w++;break}x+3!==w-2&&this.trigger("data",k.subarray(x+3,w-2));do w++;while(k[w]!==1&&w<B);x=w-2,w+=3;break;case 1:if(k[w-1]!==0||k[w-2]!==0){w+=3;break}this.trigger("data",k.subarray(x+3,w-2)),x=w-2,w+=3;break;default:w+=3;break}k=k.subarray(x),w-=x,x=0},this.reset=function(){k=null,x=0,this.trigger("reset")},this.flush=function(){k&&k.byteLength>3&&this.trigger("data",k.subarray(x+3)),k=null,x=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},xn.prototype=new au,ou={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Mr=function(){var x=new xn,w,k,C,N,B,te,ne;Mr.prototype.init.call(this),w=this,this.push=function(le){le.type==="video"&&(k=le.trackId,C=le.pts,N=le.dts,x.push(le))},x.on("data",function(le){var fe={trackId:k,pts:C,dts:N,data:le,nalUnitTypeCode:le[0]&31};switch(fe.nalUnitTypeCode){case 5:fe.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:fe.nalUnitType="sei_rbsp",fe.escapedRBSP=B(le.subarray(1));break;case 7:fe.nalUnitType="seq_parameter_set_rbsp",fe.escapedRBSP=B(le.subarray(1)),fe.config=te(fe.escapedRBSP);break;case 8:fe.nalUnitType="pic_parameter_set_rbsp";break;case 9:fe.nalUnitType="access_unit_delimiter_rbsp";break}w.trigger("data",fe)}),x.on("done",function(){w.trigger("done")}),x.on("partialdone",function(){w.trigger("partialdone")}),x.on("reset",function(){w.trigger("reset")}),x.on("endedtimeline",function(){w.trigger("endedtimeline")}),this.flush=function(){x.flush()},this.partialFlush=function(){x.partialFlush()},this.reset=function(){x.reset()},this.endTimeline=function(){x.endTimeline()},ne=function(le,fe){var Se=8,Oe=8,ct,Ue;for(ct=0;ct<le;ct++)Oe!==0&&(Ue=fe.readExpGolomb(),Oe=(Se+Ue+256)%256),Se=Oe===0?Se:Oe},B=function(le){for(var fe=le.byteLength,Se=[],Oe=1,ct,Ue;Oe<fe-2;)le[Oe]===0&&le[Oe+1]===0&&le[Oe+2]===3?(Se.push(Oe+2),Oe+=2):Oe++;if(Se.length===0)return le;ct=fe-Se.length,Ue=new Uint8Array(ct);var xt=0;for(Oe=0;Oe<ct;xt++,Oe++)xt===Se[0]&&(xt++,Se.shift()),Ue[Oe]=le[xt];return Ue},te=function(le){var fe=0,Se=0,Oe=0,ct=0,Ue,xt,Yt,xs,cn,zr,Sl,Ki,Aa,Sr,qr,Ci=[1,1],rr,js;if(Ue=new Bh(le),xt=Ue.readUnsignedByte(),xs=Ue.readUnsignedByte(),Yt=Ue.readUnsignedByte(),Ue.skipUnsignedExpGolomb(),ou[xt]&&(cn=Ue.readUnsignedExpGolomb(),cn===3&&Ue.skipBits(1),Ue.skipUnsignedExpGolomb(),Ue.skipUnsignedExpGolomb(),Ue.skipBits(1),Ue.readBoolean()))for(qr=cn!==3?8:12,js=0;js<qr;js++)Ue.readBoolean()&&(js<6?ne(16,Ue):ne(64,Ue));if(Ue.skipUnsignedExpGolomb(),zr=Ue.readUnsignedExpGolomb(),zr===0)Ue.readUnsignedExpGolomb();else if(zr===1)for(Ue.skipBits(1),Ue.skipExpGolomb(),Ue.skipExpGolomb(),Sl=Ue.readUnsignedExpGolomb(),js=0;js<Sl;js++)Ue.skipExpGolomb();if(Ue.skipUnsignedExpGolomb(),Ue.skipBits(1),Ki=Ue.readUnsignedExpGolomb(),Aa=Ue.readUnsignedExpGolomb(),Sr=Ue.readBits(1),Sr===0&&Ue.skipBits(1),Ue.skipBits(1),Ue.readBoolean()&&(fe=Ue.readUnsignedExpGolomb(),Se=Ue.readUnsignedExpGolomb(),Oe=Ue.readUnsignedExpGolomb(),ct=Ue.readUnsignedExpGolomb()),Ue.readBoolean()&&Ue.readBoolean()){switch(rr=Ue.readUnsignedByte(),rr){case 1:Ci=[1,1];break;case 2:Ci=[12,11];break;case 3:Ci=[10,11];break;case 4:Ci=[16,11];break;case 5:Ci=[40,33];break;case 6:Ci=[24,11];break;case 7:Ci=[20,11];break;case 8:Ci=[32,11];break;case 9:Ci=[80,33];break;case 10:Ci=[18,11];break;case 11:Ci=[15,11];break;case 12:Ci=[64,33];break;case 13:Ci=[160,99];break;case 14:Ci=[4,3];break;case 15:Ci=[3,2];break;case 16:Ci=[2,1];break;case 255:{Ci=[Ue.readUnsignedByte()<<8|Ue.readUnsignedByte(),Ue.readUnsignedByte()<<8|Ue.readUnsignedByte()];break}}Ci&&Ci[0]/Ci[1]}return{profileIdc:xt,levelIdc:Yt,profileCompatibility:xs,width:(Ki+1)*16-fe*2-Se*2,height:(2-Sr)*(Aa+1)*16-Oe*2-ct*2,sarRatio:Ci}}},Mr.prototype=new au;var ol={H264Stream:Mr},Pr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],lu=function(x,w){var k=x[w+6]<<21|x[w+7]<<14|x[w+8]<<7|x[w+9],C=x[w+5],N=(C&16)>>4;return k=k>=0?k:0,N?k+20:k+10},ll=function(x,w){return x.length-w<10||x[w]!==73||x[w+1]!==68||x[w+2]!==51?w:(w+=lu(x,w),ll(x,w))},Fh=function(x){var w=ll(x,0);return x.length>=w+2&&(x[w]&255)===255&&(x[w+1]&240)===240&&(x[w+1]&22)===16},ul=function(x){return x[0]<<21|x[1]<<14|x[2]<<7|x[3]},uu=function(x,w,k){var C,N="";for(C=w;C<k;C++)N+="%"+("00"+x[C].toString(16)).slice(-2);return N},Uh=function(x,w,k){return unescape(uu(x,w,k))},en=function(x,w){var k=(x[w+5]&224)>>5,C=x[w+4]<<3,N=x[w+3]&6144;return N|C|k},Ta=function(x,w){return x[w]===73&&x[w+1]===68&&x[w+2]===51?"timed-metadata":x[w]&!0&&(x[w+1]&240)===240?"audio":null},cu=function(x){for(var w=0;w+5<x.length;){if(x[w]!==255||(x[w+1]&246)!==240){w++;continue}return Pr[(x[w+2]&60)>>>2]}return null},cl=function(x){var w,k,C,N;w=10,x[5]&64&&(w+=4,w+=ul(x.subarray(10,14)));do{if(k=ul(x.subarray(w+4,w+8)),k<1)return null;if(N=String.fromCharCode(x[w],x[w+1],x[w+2],x[w+3]),N==="PRIV"){C=x.subarray(w+10,w+k+10);for(var B=0;B<C.byteLength;B++)if(C[B]===0){var te=Uh(C,0,B);if(te==="com.apple.streaming.transportStreamTimestamp"){var ne=C.subarray(B+1),le=(ne[3]&1)<<30|ne[4]<<22|ne[5]<<14|ne[6]<<6|ne[7]>>>2;return le*=4,le+=ne[7]&3,le}break}}w+=10,w+=k}while(w<x.byteLength);return null},$c={isLikelyAacData:Fh,parseId3TagSize:lu,parseAdtsSize:en,parseType:Ta,parseSampleRate:cu,parseAacTimestamp:cl},Hc=t,du=$c,Br;Br=function(){var x=new Uint8Array,w=0;Br.prototype.init.call(this),this.setTimestamp=function(k){w=k},this.push=function(k){var C=0,N=0,B,te,ne,le;for(x.length?(le=x.length,x=new Uint8Array(k.byteLength+le),x.set(x.subarray(0,le)),x.set(k,le)):x=k;x.length-N>=3;){if(x[N]===73&&x[N+1]===68&&x[N+2]===51){if(x.length-N<10||(C=du.parseId3TagSize(x,N),N+C>x.length))break;te={type:"timed-metadata",data:x.subarray(N,N+C)},this.trigger("data",te),N+=C;continue}else if((x[N]&255)===255&&(x[N+1]&240)===240){if(x.length-N<7||(C=du.parseAdtsSize(x,N),N+C>x.length))break;ne={type:"audio",data:x.subarray(N,N+C),pts:w,dts:w},this.trigger("data",ne),N+=C;continue}N++}B=x.length-N,B>0?x=x.subarray(N):x=new Uint8Array},this.reset=function(){x=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){x=new Uint8Array,this.trigger("endedtimeline")}},Br.prototype=new Hc;var hu=Br,jh=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],hg=jh,fg=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],mg=fg,so=t,dl=Be,hl=gt,fu=ht,$n=re,br=al,fl=wt,$h=io,pg=ol.H264Stream,gg=hu,yg=$c.isLikelyAacData,Vc=wt.ONE_SECOND_IN_TS,Hh=hg,Vh=mg,mu,no,pu,_a,vg=function(x,w){w.stream=x,this.trigger("log",w)},Gh=function(x,w){for(var k=Object.keys(w),C=0;C<k.length;C++){var N=k[C];N==="headOfPipeline"||!w[N].on||w[N].on("log",vg.bind(x,N))}},zh=function(x,w){var k;if(x.length!==w.length)return!1;for(k=0;k<x.length;k++)if(x[k]!==w[k])return!1;return!0},qh=function(x,w,k,C,N,B){var te=k-w,ne=C-w,le=N-k;return{start:{dts:x,pts:x+te},end:{dts:x+ne,pts:x+le},prependedContentDuration:B,baseMediaDecodeTime:x}};no=function(x,w){var k=[],C,N=0,B=0,te=1/0;w=w||{},C=w.firstSequenceNumber||0,no.prototype.init.call(this),this.push=function(ne){$n.collectDtsInfo(x,ne),x&&Hh.forEach(function(le){x[le]=ne[le]}),k.push(ne)},this.setEarliestDts=function(ne){N=ne},this.setVideoBaseMediaDecodeTime=function(ne){te=ne},this.setAudioAppendStart=function(ne){B=ne},this.flush=function(){var ne,le,fe,Se,Oe,ct,Ue;if(k.length===0){this.trigger("done","AudioSegmentStream");return}ne=fu.trimAdtsFramesByEarliestDts(k,x,N),x.baseMediaDecodeTime=$n.calculateTrackBaseMediaDecodeTime(x,w.keepOriginalTimestamps),Ue=fu.prefixWithSilence(x,ne,B,te),x.samples=fu.generateSampleTable(ne),fe=dl.mdat(fu.concatenateFrameData(ne)),k=[],le=dl.moof(C,[x]),Se=new Uint8Array(le.byteLength+fe.byteLength),C++,Se.set(le),Se.set(fe,le.byteLength),$n.clearDtsInfo(x),Oe=Math.ceil(Vc*1024/x.samplerate),ne.length&&(ct=ne.length*Oe,this.trigger("segmentTimingInfo",qh(fl.audioTsToVideoTs(x.baseMediaDecodeTime,x.samplerate),ne[0].dts,ne[0].pts,ne[0].dts+ct,ne[0].pts+ct,Ue||0)),this.trigger("timingInfo",{start:ne[0].pts,end:ne[0].pts+ct})),this.trigger("data",{track:x,boxes:Se}),this.trigger("done","AudioSegmentStream")},this.reset=function(){$n.clearDtsInfo(x),k=[],this.trigger("reset")}},no.prototype=new so,mu=function(x,w){var k,C=[],N=[],B,te;w=w||{},k=w.firstSequenceNumber||0,mu.prototype.init.call(this),delete x.minPTS,this.gopCache_=[],this.push=function(ne){$n.collectDtsInfo(x,ne),ne.nalUnitType==="seq_parameter_set_rbsp"&&!B&&(B=ne.config,x.sps=[ne.data],Vh.forEach(function(le){x[le]=B[le]},this)),ne.nalUnitType==="pic_parameter_set_rbsp"&&!te&&(te=ne.data,x.pps=[ne.data]),C.push(ne)},this.flush=function(){for(var ne,le,fe,Se,Oe,ct,Ue=0,xt,Yt;C.length&&C[0].nalUnitType!=="access_unit_delimiter_rbsp";)C.shift();if(C.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(ne=hl.groupNalsIntoFrames(C),fe=hl.groupFramesIntoGops(ne),fe[0][0].keyFrame||(le=this.getGopForFusion_(C[0],x),le?(Ue=le.duration,fe.unshift(le),fe.byteLength+=le.byteLength,fe.nalCount+=le.nalCount,fe.pts=le.pts,fe.dts=le.dts,fe.duration+=le.duration):fe=hl.extendFirstKeyFrame(fe)),N.length){var xs;if(w.alignGopsAtEnd?xs=this.alignGopsAtEnd_(fe):xs=this.alignGopsAtStart_(fe),!xs){this.gopCache_.unshift({gop:fe.pop(),pps:x.pps,sps:x.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),C=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}$n.clearDtsInfo(x),fe=xs}$n.collectDtsInfo(x,fe),x.samples=hl.generateSampleTable(fe),Oe=dl.mdat(hl.concatenateNalData(fe)),x.baseMediaDecodeTime=$n.calculateTrackBaseMediaDecodeTime(x,w.keepOriginalTimestamps),this.trigger("processedGopsInfo",fe.map(function(cn){return{pts:cn.pts,dts:cn.dts,byteLength:cn.byteLength}})),xt=fe[0],Yt=fe[fe.length-1],this.trigger("segmentTimingInfo",qh(x.baseMediaDecodeTime,xt.dts,xt.pts,Yt.dts+Yt.duration,Yt.pts+Yt.duration,Ue)),this.trigger("timingInfo",{start:fe[0].pts,end:fe[fe.length-1].pts+fe[fe.length-1].duration}),this.gopCache_.unshift({gop:fe.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),Se=dl.moof(k,[x]),ct=new Uint8Array(Se.byteLength+Oe.byteLength),k++,ct.set(Se),ct.set(Oe,Se.byteLength),this.trigger("data",{track:x,boxes:ct}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),C=[],this.gopCache_.length=0,N.length=0,this.trigger("reset")},this.resetStream_=function(){$n.clearDtsInfo(x),B=void 0,te=void 0},this.getGopForFusion_=function(ne){var le=45e3,fe=1/0,Se,Oe,ct,Ue,xt;for(xt=0;xt<this.gopCache_.length;xt++)Ue=this.gopCache_[xt],ct=Ue.gop,!(!(x.pps&&zh(x.pps[0],Ue.pps[0]))||!(x.sps&&zh(x.sps[0],Ue.sps[0])))&&(ct.dts<x.timelineStartInfo.dts||(Se=ne.dts-ct.dts-ct.duration,Se>=-1e4&&Se<=le&&(!Oe||fe>Se)&&(Oe=Ue,fe=Se)));return Oe?Oe.gop:null},this.alignGopsAtStart_=function(ne){var le,fe,Se,Oe,ct,Ue,xt,Yt;for(ct=ne.byteLength,Ue=ne.nalCount,xt=ne.duration,le=fe=0;le<N.length&&fe<ne.length&&(Se=N[le],Oe=ne[fe],Se.pts!==Oe.pts);){if(Oe.pts>Se.pts){le++;continue}fe++,ct-=Oe.byteLength,Ue-=Oe.nalCount,xt-=Oe.duration}return fe===0?ne:fe===ne.length?null:(Yt=ne.slice(fe),Yt.byteLength=ct,Yt.duration=xt,Yt.nalCount=Ue,Yt.pts=Yt[0].pts,Yt.dts=Yt[0].dts,Yt)},this.alignGopsAtEnd_=function(ne){var le,fe,Se,Oe,ct,Ue;for(le=N.length-1,fe=ne.length-1,ct=null,Ue=!1;le>=0&&fe>=0;){if(Se=N[le],Oe=ne[fe],Se.pts===Oe.pts){Ue=!0;break}if(Se.pts>Oe.pts){le--;continue}le===N.length-1&&(ct=fe),fe--}if(!Ue&&ct===null)return null;var xt;if(Ue?xt=fe:xt=ct,xt===0)return ne;var Yt=ne.slice(xt),xs=Yt.reduce(function(cn,zr){return cn.byteLength+=zr.byteLength,cn.duration+=zr.duration,cn.nalCount+=zr.nalCount,cn},{byteLength:0,duration:0,nalCount:0});return Yt.byteLength=xs.byteLength,Yt.duration=xs.duration,Yt.nalCount=xs.nalCount,Yt.pts=Yt[0].pts,Yt.dts=Yt[0].dts,Yt},this.alignGopsWith=function(ne){N=ne}},mu.prototype=new so,_a=function(x,w){this.numberOfTracks=0,this.metadataStream=w,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,_a.prototype.init.call(this),this.push=function(k){if(k.content||k.text)return this.pendingCaptions.push(k);if(k.frames)return this.pendingMetadata.push(k);this.pendingTracks.push(k.track),this.pendingBytes+=k.boxes.byteLength,k.track.type==="video"&&(this.videoTrack=k.track,this.pendingBoxes.push(k.boxes)),k.track.type==="audio"&&(this.audioTrack=k.track,this.pendingBoxes.unshift(k.boxes))}},_a.prototype=new so,_a.prototype.flush=function(x){var w=0,k={captions:[],captionStreams:{},metadata:[],info:{}},C,N,B,te=0,ne;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?(te=this.videoTrack.timelineStartInfo.pts,Vh.forEach(function(le){k.info[le]=this.videoTrack[le]},this)):this.audioTrack&&(te=this.audioTrack.timelineStartInfo.pts,Hh.forEach(function(le){k.info[le]=this.audioTrack[le]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?k.type=this.pendingTracks[0].type:k.type="combined",this.emittedTracks+=this.pendingTracks.length,B=dl.initSegment(this.pendingTracks),k.initSegment=new Uint8Array(B.byteLength),k.initSegment.set(B),k.data=new Uint8Array(this.pendingBytes),ne=0;ne<this.pendingBoxes.length;ne++)k.data.set(this.pendingBoxes[ne],w),w+=this.pendingBoxes[ne].byteLength;for(ne=0;ne<this.pendingCaptions.length;ne++)C=this.pendingCaptions[ne],C.startTime=fl.metadataTsToSeconds(C.startPts,te,this.keepOriginalTimestamps),C.endTime=fl.metadataTsToSeconds(C.endPts,te,this.keepOriginalTimestamps),k.captionStreams[C.stream]=!0,k.captions.push(C);for(ne=0;ne<this.pendingMetadata.length;ne++)N=this.pendingMetadata[ne],N.cueTime=fl.metadataTsToSeconds(N.pts,te,this.keepOriginalTimestamps),k.metadata.push(N);for(k.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",k),ne=0;ne<k.captions.length;ne++)C=k.captions[ne],this.trigger("caption",C);for(ne=0;ne<k.metadata.length;ne++)N=k.metadata[ne],this.trigger("id3Frame",N)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},_a.prototype.setRemux=function(x){this.remuxTracks=x},pu=function(x){var w=this,k=!0,C,N;pu.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 br.MetadataStream,B.aacStream=new gg,B.audioTimestampRolloverStream=new br.TimestampRolloverStream("audio"),B.timedMetadataTimestampRolloverStream=new br.TimestampRolloverStream("timed-metadata"),B.adtsStream=new $h,B.coalesceStream=new _a(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(te){B.aacStream.setTimestamp(te.timeStamp)}),B.aacStream.on("data",function(te){te.type!=="timed-metadata"&&te.type!=="audio"||B.audioSegmentStream||(N=N||{timelineStartInfo:{baseMediaDecodeTime:w.baseMediaDecodeTime},codec:"adts",type:"audio"},B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new no(N,x),B.audioSegmentStream.on("log",w.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",w.trigger.bind(w,"audioTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream),w.trigger("trackinfo",{hasAudio:!!N,hasVideo:!!C}))}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),Gh(this,B)},this.setupTsPipeline=function(){var B={};this.transmuxPipeline_=B,B.type="ts",B.metadataStream=new br.MetadataStream,B.packetStream=new br.TransportPacketStream,B.parseStream=new br.TransportParseStream,B.elementaryStream=new br.ElementaryStream,B.timestampRolloverStream=new br.TimestampRolloverStream,B.adtsStream=new $h,B.h264Stream=new pg,B.captionStream=new br.CaptionStream(x),B.coalesceStream=new _a(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(te){var ne;if(te.type==="metadata"){for(ne=te.tracks.length;ne--;)!C&&te.tracks[ne].type==="video"?(C=te.tracks[ne],C.timelineStartInfo.baseMediaDecodeTime=w.baseMediaDecodeTime):!N&&te.tracks[ne].type==="audio"&&(N=te.tracks[ne],N.timelineStartInfo.baseMediaDecodeTime=w.baseMediaDecodeTime);C&&!B.videoSegmentStream&&(B.coalesceStream.numberOfTracks++,B.videoSegmentStream=new mu(C,x),B.videoSegmentStream.on("log",w.getLogTrigger_("videoSegmentStream")),B.videoSegmentStream.on("timelineStartInfo",function(le){N&&!x.keepOriginalTimestamps&&(N.timelineStartInfo=le,B.audioSegmentStream.setEarliestDts(le.dts-w.baseMediaDecodeTime))}),B.videoSegmentStream.on("processedGopsInfo",w.trigger.bind(w,"gopInfo")),B.videoSegmentStream.on("segmentTimingInfo",w.trigger.bind(w,"videoSegmentTimingInfo")),B.videoSegmentStream.on("baseMediaDecodeTime",function(le){N&&B.audioSegmentStream.setVideoBaseMediaDecodeTime(le)}),B.videoSegmentStream.on("timingInfo",w.trigger.bind(w,"videoTimingInfo")),B.h264Stream.pipe(B.videoSegmentStream).pipe(B.coalesceStream)),N&&!B.audioSegmentStream&&(B.coalesceStream.numberOfTracks++,B.audioSegmentStream=new no(N,x),B.audioSegmentStream.on("log",w.getLogTrigger_("audioSegmentStream")),B.audioSegmentStream.on("timingInfo",w.trigger.bind(w,"audioTimingInfo")),B.audioSegmentStream.on("segmentTimingInfo",w.trigger.bind(w,"audioSegmentTimingInfo")),B.adtsStream.pipe(B.audioSegmentStream).pipe(B.coalesceStream)),w.trigger("trackinfo",{hasAudio:!!N,hasVideo:!!C})}}),B.coalesceStream.on("data",this.trigger.bind(this,"data")),B.coalesceStream.on("id3Frame",function(te){te.dispatchType=B.metadataStream.dispatchType,w.trigger("id3Frame",te)}),B.coalesceStream.on("caption",this.trigger.bind(this,"caption")),B.coalesceStream.on("done",this.trigger.bind(this,"done")),Gh(this,B)},this.setBaseMediaDecodeTime=function(B){var te=this.transmuxPipeline_;x.keepOriginalTimestamps||(this.baseMediaDecodeTime=B),N&&(N.timelineStartInfo.dts=void 0,N.timelineStartInfo.pts=void 0,$n.clearDtsInfo(N),te.audioTimestampRolloverStream&&te.audioTimestampRolloverStream.discontinuity()),C&&(te.videoSegmentStream&&(te.videoSegmentStream.gopCache_=[]),C.timelineStartInfo.dts=void 0,C.timelineStartInfo.pts=void 0,$n.clearDtsInfo(C),te.captionStream.reset()),te.timestampRolloverStream&&te.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(B){N&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(B)},this.setRemux=function(B){var te=this.transmuxPipeline_;x.remux=B,te&&te.coalesceStream&&te.coalesceStream.setRemux(B)},this.alignGopsWith=function(B){C&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(B)},this.getLogTrigger_=function(B){var te=this;return function(ne){ne.stream=B,te.trigger("log",ne)}},this.push=function(B){if(k){var te=yg(B);te&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!te&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),k=!1}this.transmuxPipeline_.headOfPipeline.push(B)},this.flush=function(){k=!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()}},pu.prototype=new so;var xg={Transmuxer:pu},bg=function(x){return x>>>0},Tg=function(x){return("00"+x.toString(16)).slice(-2)},ro={toUnsigned:bg,toHexString:Tg},ml=function(x){var w="";return w+=String.fromCharCode(x[0]),w+=String.fromCharCode(x[1]),w+=String.fromCharCode(x[2]),w+=String.fromCharCode(x[3]),w},Kh=ml,Yh=ro.toUnsigned,Wh=Kh,Gc=function(x,w){var k=[],C,N,B,te,ne;if(!w.length)return null;for(C=0;C<x.byteLength;)N=Yh(x[C]<<24|x[C+1]<<16|x[C+2]<<8|x[C+3]),B=Wh(x.subarray(C+4,C+8)),te=N>1?C+N:x.byteLength,B===w[0]&&(w.length===1?k.push(x.subarray(C+8,te)):(ne=Gc(x.subarray(C+8,te),w.slice(1)),ne.length&&(k=k.concat(ne)))),C=te;return k},gu=Gc,Xh=ro.toUnsigned,ao=r.getUint64,_g=function(x){var w={version:x[0],flags:new Uint8Array(x.subarray(1,4))};return w.version===1?w.baseMediaDecodeTime=ao(x.subarray(4)):w.baseMediaDecodeTime=Xh(x[4]<<24|x[5]<<16|x[6]<<8|x[7]),w},zc=_g,Sg=function(x){var w=new DataView(x.buffer,x.byteOffset,x.byteLength),k={version:x[0],flags:new Uint8Array(x.subarray(1,4)),trackId:w.getUint32(4)},C=k.flags[2]&1,N=k.flags[2]&2,B=k.flags[2]&8,te=k.flags[2]&16,ne=k.flags[2]&32,le=k.flags[0]&65536,fe=k.flags[0]&131072,Se;return Se=8,C&&(Se+=4,k.baseDataOffset=w.getUint32(12),Se+=4),N&&(k.sampleDescriptionIndex=w.getUint32(Se),Se+=4),B&&(k.defaultSampleDuration=w.getUint32(Se),Se+=4),te&&(k.defaultSampleSize=w.getUint32(Se),Se+=4),ne&&(k.defaultSampleFlags=w.getUint32(Se)),le&&(k.durationIsEmpty=!0),!C&&fe&&(k.baseDataOffsetIsMoof=!0),k},qc=Sg,Qh=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]}},pl=Qh,oo=pl,Eg=function(x){var w={version:x[0],flags:new Uint8Array(x.subarray(1,4)),samples:[]},k=new DataView(x.buffer,x.byteOffset,x.byteLength),C=w.flags[2]&1,N=w.flags[2]&4,B=w.flags[1]&1,te=w.flags[1]&2,ne=w.flags[1]&4,le=w.flags[1]&8,fe=k.getUint32(4),Se=8,Oe;for(C&&(w.dataOffset=k.getInt32(Se),Se+=4),N&&fe&&(Oe={flags:oo(x.subarray(Se,Se+4))},Se+=4,B&&(Oe.duration=k.getUint32(Se),Se+=4),te&&(Oe.size=k.getUint32(Se),Se+=4),le&&(w.version===1?Oe.compositionTimeOffset=k.getInt32(Se):Oe.compositionTimeOffset=k.getUint32(Se),Se+=4),w.samples.push(Oe),fe--);fe--;)Oe={},B&&(Oe.duration=k.getUint32(Se),Se+=4),te&&(Oe.size=k.getUint32(Se),Se+=4),ne&&(Oe.flags=oo(x.subarray(Se,Se+4)),Se+=4),le&&(w.version===1?Oe.compositionTimeOffset=k.getInt32(Se):Oe.compositionTimeOffset=k.getUint32(Se),Se+=4),w.samples.push(Oe);return w},gl=Eg,Kc={tfdt:zc,trun:gl},Yc={parseTfdt:Kc.tfdt,parseTrun:Kc.trun},Wc=function(x){for(var w=0,k=String.fromCharCode(x[w]),C="";k!=="\0";)C+=k,w++,k=String.fromCharCode(x[w]);return C+=k,C},Xc={uint8ToCString:Wc},yl=Xc.uint8ToCString,Zh=r.getUint64,Jh=function(x){var w=4,k=x[0],C,N,B,te,ne,le,fe,Se;if(k===0){C=yl(x.subarray(w)),w+=C.length,N=yl(x.subarray(w)),w+=N.length;var Oe=new DataView(x.buffer);B=Oe.getUint32(w),w+=4,ne=Oe.getUint32(w),w+=4,le=Oe.getUint32(w),w+=4,fe=Oe.getUint32(w),w+=4}else if(k===1){var Oe=new DataView(x.buffer);B=Oe.getUint32(w),w+=4,te=Zh(x.subarray(w)),w+=8,le=Oe.getUint32(w),w+=4,fe=Oe.getUint32(w),w+=4,C=yl(x.subarray(w)),w+=C.length,N=yl(x.subarray(w)),w+=N.length}Se=new Uint8Array(x.subarray(w,x.byteLength));var ct={scheme_id_uri:C,value:N,timescale:B||1,presentation_time:te,presentation_time_delta:ne,event_duration:le,id:fe,message_data:Se};return Ag(k,ct)?ct:void 0},wg=function(x,w,k,C){return x||x===0?x/w:C+k/w},Ag=function(x,w){var k=w.scheme_id_uri!=="\0",C=x===0&&ef(w.presentation_time_delta)&&k,N=x===1&&ef(w.presentation_time)&&k;return!(x>1)&&C||N},ef=function(x){return x!==void 0||x!==null},Cg={parseEmsgBox:Jh,scaleTime:wg},vl;typeof window<"u"?vl=window:typeof s<"u"?vl=s:typeof self<"u"?vl=self:vl={};var tn=vl,Fr=ro.toUnsigned,lo=ro.toHexString,es=gu,Sa=Kh,yu=Cg,Qc=qc,kg=gl,uo=zc,Zc=r.getUint64,co,vu,Jc,Ur,Ea,xl,ed,Tr=tn,tf=Bt.parseId3Frames;co=function(x){var w={},k=es(x,["moov","trak"]);return k.reduce(function(C,N){var B,te,ne,le,fe;return B=es(N,["tkhd"])[0],!B||(te=B[0],ne=te===0?12:20,le=Fr(B[ne]<<24|B[ne+1]<<16|B[ne+2]<<8|B[ne+3]),fe=es(N,["mdia","mdhd"])[0],!fe)?null:(te=fe[0],ne=te===0?12:20,C[le]=Fr(fe[ne]<<24|fe[ne+1]<<16|fe[ne+2]<<8|fe[ne+3]),C)},w)},vu=function(x,w){var k;k=es(w,["moof","traf"]);var C=k.reduce(function(N,B){var te=es(B,["tfhd"])[0],ne=Fr(te[4]<<24|te[5]<<16|te[6]<<8|te[7]),le=x[ne]||9e4,fe=es(B,["tfdt"])[0],Se=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),Oe;fe[0]===1?Oe=Zc(fe.subarray(4,12)):Oe=Se.getUint32(4);let ct;return typeof Oe=="bigint"?ct=Oe/Tr.BigInt(le):typeof Oe=="number"&&!isNaN(Oe)&&(ct=Oe/le),ct<Number.MAX_SAFE_INTEGER&&(ct=Number(ct)),ct<N&&(N=ct),N},1/0);return typeof C=="bigint"||isFinite(C)?C:0},Jc=function(x,w){var k=es(w,["moof","traf"]),C=0,N=0,B;if(k&&k.length){var te=es(k[0],["tfhd"])[0],ne=es(k[0],["trun"])[0],le=es(k[0],["tfdt"])[0];if(te){var fe=Qc(te);B=fe.trackId}if(le){var Se=uo(le);C=Se.baseMediaDecodeTime}if(ne){var Oe=kg(ne);Oe.samples&&Oe.samples.length&&(N=Oe.samples[0].compositionTimeOffset||0)}}var ct=x[B]||9e4;typeof C=="bigint"&&(N=Tr.BigInt(N),ct=Tr.BigInt(ct));var Ue=(C+N)/ct;return typeof Ue=="bigint"&&Ue<Number.MAX_SAFE_INTEGER&&(Ue=Number(Ue)),Ue},Ur=function(x){var w=es(x,["moov","trak"]),k=[];return w.forEach(function(C){var N=es(C,["mdia","hdlr"]),B=es(C,["tkhd"]);N.forEach(function(te,ne){var le=Sa(te.subarray(8,12)),fe=B[ne],Se,Oe,ct;le==="vide"&&(Se=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),Oe=Se.getUint8(0),ct=Oe===0?Se.getUint32(12):Se.getUint32(20),k.push(ct))})}),k},xl=function(x){var w=x[0],k=w===0?12:20;return Fr(x[k]<<24|x[k+1]<<16|x[k+2]<<8|x[k+3])},Ea=function(x){var w=es(x,["moov","trak"]),k=[];return w.forEach(function(C){var N={},B=es(C,["tkhd"])[0],te,ne;B&&(te=new DataView(B.buffer,B.byteOffset,B.byteLength),ne=te.getUint8(0),N.id=ne===0?te.getUint32(12):te.getUint32(20));var le=es(C,["mdia","hdlr"])[0];if(le){var fe=Sa(le.subarray(8,12));fe==="vide"?N.type="video":fe==="soun"?N.type="audio":N.type=fe}var Se=es(C,["mdia","minf","stbl","stsd"])[0];if(Se){var Oe=Se.subarray(8);N.codec=Sa(Oe.subarray(4,8));var ct=es(Oe,[N.codec])[0],Ue,xt;ct&&(/^[asm]vc[1-9]$/i.test(N.codec)?(Ue=ct.subarray(78),xt=Sa(Ue.subarray(4,8)),xt==="avcC"&&Ue.length>11?(N.codec+=".",N.codec+=lo(Ue[9]),N.codec+=lo(Ue[10]),N.codec+=lo(Ue[11])):N.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(N.codec)?(Ue=ct.subarray(28),xt=Sa(Ue.subarray(4,8)),xt==="esds"&&Ue.length>20&&Ue[19]!==0?(N.codec+="."+lo(Ue[19]),N.codec+="."+lo(Ue[20]>>>2&63).replace(/^0/,"")):N.codec="mp4a.40.2"):N.codec=N.codec.toLowerCase())}var Yt=es(C,["mdia","mdhd"])[0];Yt&&(N.timescale=xl(Yt)),k.push(N)}),k},ed=function(x,w=0){var k=es(x,["emsg"]);return k.map(C=>{var N=yu.parseEmsgBox(new Uint8Array(C)),B=tf(N.message_data);return{cueTime:yu.scaleTime(N.presentation_time,N.timescale,N.presentation_time_delta,w),duration:yu.scaleTime(N.event_duration,N.timescale),frames:B}})};var ho={findBox:es,parseType:Sa,timescale:co,startTime:vu,compositionStartTime:Jc,videoTrackIds:Ur,tracks:Ea,getTimescaleFromMediaHeader:xl,getEmsgID3:ed};const{parseTrun:sf}=Yc,{findBox:nf}=ho;var rf=tn,Dg=function(x){var w=nf(x,["moof","traf"]),k=nf(x,["mdat"]),C=[];return k.forEach(function(N,B){var te=w[B];C.push({mdat:N,traf:te})}),C},af=function(x,w,k){var C=w,N=k.defaultSampleDuration||0,B=k.defaultSampleSize||0,te=k.trackId,ne=[];return x.forEach(function(le){var fe=sf(le),Se=fe.samples;Se.forEach(function(Oe){Oe.duration===void 0&&(Oe.duration=N),Oe.size===void 0&&(Oe.size=B),Oe.trackId=te,Oe.dts=C,Oe.compositionTimeOffset===void 0&&(Oe.compositionTimeOffset=0),typeof C=="bigint"?(Oe.pts=C+rf.BigInt(Oe.compositionTimeOffset),C+=rf.BigInt(Oe.duration)):(Oe.pts=C+Oe.compositionTimeOffset,C+=Oe.duration)}),ne=ne.concat(Se)}),ne},td={getMdatTrafPairs:Dg,parseSamples:af},id=Xi.discardEmulationPreventionBytes,Hn=ji.CaptionStream,fo=gu,bn=zc,mo=qc,{getMdatTrafPairs:sd,parseSamples:xu}=td,bu=function(x,w){for(var k=x,C=0;C<w.length;C++){var N=w[C];if(k<N.size)return N;k-=N.size}return null},nd=function(x,w,k){var C=new DataView(x.buffer,x.byteOffset,x.byteLength),N={logs:[],seiNals:[]},B,te,ne,le;for(te=0;te+4<x.length;te+=ne)if(ne=C.getUint32(te),te+=4,!(ne<=0))switch(x[te]&31){case 6:var fe=x.subarray(te+1,te+1+ne),Se=bu(te,w);if(B={nalUnitType:"sei_rbsp",size:ne,data:fe,escapedRBSP:id(fe),trackId:k},Se)B.pts=Se.pts,B.dts=Se.dts,le=Se;else if(le)B.pts=le.pts,B.dts=le.dts;else{N.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+te+" for trackId "+k+". See mux.js#223."});break}N.seiNals.push(B);break}return N},wa=function(x,w){var k={},C=sd(x);return C.forEach(function(N){var B=N.mdat,te=N.traf,ne=fo(te,["tfhd"]),le=mo(ne[0]),fe=le.trackId,Se=fo(te,["tfdt"]),Oe=Se.length>0?bn(Se[0]).baseMediaDecodeTime:0,ct=fo(te,["trun"]),Ue,xt;w===fe&&ct.length>0&&(Ue=xu(ct,Oe,le),xt=nd(B,Ue,fe),k[fe]||(k[fe]={seiNals:[],logs:[]}),k[fe].seiNals=k[fe].seiNals.concat(xt.seiNals),k[fe].logs=k[fe].logs.concat(xt.logs))}),k},of=function(x,w,k){var C;if(w===null)return null;C=wa(x,w);var N=C[w]||{};return{seiNals:N.seiNals,logs:N.logs,timescale:k}},Tu=function(){var x=!1,w,k,C,N,B,te;this.isInitialized=function(){return x},this.init=function(ne){w=new Hn,x=!0,te=ne?ne.isPartial:!1,w.on("data",function(le){le.startTime=le.startPts/N,le.endTime=le.endPts/N,B.captions.push(le),B.captionStreams[le.stream]=!0}),w.on("log",function(le){B.logs.push(le)})},this.isNewInit=function(ne,le){return ne&&ne.length===0||le&&typeof le=="object"&&Object.keys(le).length===0?!1:C!==ne[0]||N!==le[C]},this.parse=function(ne,le,fe){var Se;if(this.isInitialized()){if(!le||!fe)return null;if(this.isNewInit(le,fe))C=le[0],N=fe[C];else if(C===null||!N)return k.push(ne),null}else return null;for(;k.length>0;){var Oe=k.shift();this.parse(Oe,le,fe)}return Se=of(ne,C,N),Se&&Se.logs&&(B.logs=B.logs.concat(Se.logs)),Se===null||!Se.seiNals?B.logs.length?{logs:B.logs,captions:[],captionStreams:[]}:null:(this.pushNals(Se.seiNals),this.flushStream(),B)},this.pushNals=function(ne){if(!this.isInitialized()||!ne||ne.length===0)return null;ne.forEach(function(le){w.push(le)})},this.flushStream=function(){if(!this.isInitialized())return null;te?w.partialFlush():w.flush()},this.clearParsedCaptions=function(){B.captions=[],B.captionStreams={},B.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;w.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){k=[],C=null,N=null,B?this.clearParsedCaptions():B={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},po=Tu;const{parseTfdt:Lg}=Yc,fs=gu,{getTimescaleFromMediaHeader:rd}=ho,{parseSamples:_r,getMdatTrafPairs:lf}=td;var jr=function(){let x=9e4;this.init=function(w){const k=fs(w,["moov","trak","mdia","mdhd"])[0];k&&(x=rd(k))},this.parseSegment=function(w){const k=[],C=lf(w);let N=0;return C.forEach(function(B){const te=B.mdat,ne=B.traf,le=fs(ne,["tfdt"])[0],fe=fs(ne,["tfhd"])[0],Se=fs(ne,["trun"]);if(le&&(N=Lg(le).baseMediaDecodeTime),Se.length&&fe){const Oe=_r(Se,N,fe);let ct=0;Oe.forEach(function(Ue){const xt="utf-8",Yt=new TextDecoder(xt),xs=te.slice(ct,ct+Ue.size);if(fs(xs,["vtte"])[0]){ct+=Ue.size;return}fs(xs,["vttc"]).forEach(function(Sl){const Ki=fs(Sl,["payl"])[0],Aa=fs(Sl,["sttg"])[0],Sr=Ue.pts/x,qr=(Ue.pts+Ue.duration)/x;let Ci,rr;if(Ki)try{Ci=Yt.decode(Ki)}catch(js){console.error(js)}if(Aa)try{rr=Yt.decode(Aa)}catch(js){console.error(js)}Ue.duration&&Ci&&k.push({cueText:Ci,start:Sr,end:qr,settings:rr})}),ct+=Ue.size})}}),k}},bl=hs,od=function(x){var w=x[1]&31;return w<<=8,w|=x[2],w},go=function(x){return!!(x[1]&64)},Tl=function(x){var w=0;return(x[3]&48)>>>4>1&&(w+=x[4]+1),w},Tn=function(x,w){var k=od(x);return k===0?"pat":k===w?"pmt":w?"pes":null},yo=function(x){var w=go(x),k=4+Tl(x);return w&&(k+=x[k]+1),(x[k+10]&31)<<8|x[k+11]},vo=function(x){var w={},k=go(x),C=4+Tl(x);if(k&&(C+=x[C]+1),!!(x[C+5]&1)){var N,B,te;N=(x[C+1]&15)<<8|x[C+2],B=3+N-4,te=(x[C+10]&15)<<8|x[C+11];for(var ne=12+te;ne<B;){var le=C+ne;w[(x[le+1]&31)<<8|x[le+2]]=x[le],ne+=((x[le+3]&15)<<8|x[le+4])+5}return w}},_u=function(x,w){var k=od(x),C=w[k];switch(C){case bl.H264_STREAM_TYPE:return"video";case bl.ADTS_STREAM_TYPE:return"audio";case bl.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},_l=function(x){var w=go(x);if(!w)return null;var k=4+Tl(x);if(k>=x.byteLength)return null;var C=null,N;return N=x[k+7],N&192&&(C={},C.pts=(x[k+9]&14)<<27|(x[k+10]&255)<<20|(x[k+11]&254)<<12|(x[k+12]&255)<<5|(x[k+13]&254)>>>3,C.pts*=4,C.pts+=(x[k+13]&6)>>>1,C.dts=C.pts,N&64&&(C.dts=(x[k+14]&14)<<27|(x[k+15]&255)<<20|(x[k+16]&254)<<12|(x[k+17]&255)<<5|(x[k+18]&254)>>>3,C.dts*=4,C.dts+=(x[k+18]&6)>>>1)),C},sn=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}},_n=function(x){for(var w=4+Tl(x),k=x.subarray(w),C=0,N=0,B=!1,te;N<k.byteLength-3;N++)if(k[N+2]===1){C=N+5;break}for(;C<k.byteLength;)switch(k[C]){case 0:if(k[C-1]!==0){C+=2;break}else if(k[C-2]!==0){C++;break}N+3!==C-2&&(te=sn(k[N+3]&31),te==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0));do C++;while(k[C]!==1&&C<k.length);N=C-2,C+=3;break;case 1:if(k[C-1]!==0||k[C-2]!==0){C+=3;break}te=sn(k[N+3]&31),te==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0),N=C-2,C+=3;break;default:C+=3;break}return k=k.subarray(N),C-=N,N=0,k&&k.byteLength>3&&(te=sn(k[N+3]&31),te==="slice_layer_without_partitioning_rbsp_idr"&&(B=!0)),B},$r={parseType:Tn,parsePat:yo,parsePmt:vo,parsePayloadUnitStartIndicator:go,parsePesType:_u,parsePesTime:_l,videoPacketContainsKeyFrame:_n},Vn=hs,qs=je.handleRollover,ii={};ii.ts=$r,ii.aac=$c;var Hr=wt.ONE_SECOND_IN_TS,Rs=188,Sn=71,uf=function(x,w){for(var k=0,C=Rs,N,B;C<x.byteLength;){if(x[k]===Sn&&x[C]===Sn){switch(N=x.subarray(k,C),B=ii.ts.parseType(N,w.pid),B){case"pat":w.pid=ii.ts.parsePat(N);break;case"pmt":var te=ii.ts.parsePmt(N);w.table=w.table||{},Object.keys(te).forEach(function(ne){w.table[ne]=te[ne]});break}k+=Rs,C+=Rs;continue}k++,C++}},ws=function(x,w,k){for(var C=0,N=Rs,B,te,ne,le,fe,Se=!1;N<=x.byteLength;){if(x[C]===Sn&&(x[N]===Sn||N===x.byteLength)){if(B=x.subarray(C,N),te=ii.ts.parseType(B,w.pid),te==="pes"&&(ne=ii.ts.parsePesType(B,w.table),le=ii.ts.parsePayloadUnitStartIndicator(B),ne==="audio"&&le&&(fe=ii.ts.parsePesTime(B),fe&&(fe.type="audio",k.audio.push(fe),Se=!0))),Se)break;C+=Rs,N+=Rs;continue}C++,N++}for(N=x.byteLength,C=N-Rs,Se=!1;C>=0;){if(x[C]===Sn&&(x[N]===Sn||N===x.byteLength)){if(B=x.subarray(C,N),te=ii.ts.parseType(B,w.pid),te==="pes"&&(ne=ii.ts.parsePesType(B,w.table),le=ii.ts.parsePayloadUnitStartIndicator(B),ne==="audio"&&le&&(fe=ii.ts.parsePesTime(B),fe&&(fe.type="audio",k.audio.push(fe),Se=!0))),Se)break;C-=Rs,N-=Rs;continue}C--,N--}},$i=function(x,w,k){for(var C=0,N=Rs,B,te,ne,le,fe,Se,Oe,ct,Ue=!1,xt={data:[],size:0};N<x.byteLength;){if(x[C]===Sn&&x[N]===Sn){switch(B=x.subarray(C,N),te=ii.ts.parseType(B,w.pid),te){case"pes":if(ne=ii.ts.parsePesType(B,w.table),le=ii.ts.parsePayloadUnitStartIndicator(B),ne==="video"&&(le&&!Ue&&(fe=ii.ts.parsePesTime(B),fe&&(fe.type="video",k.video.push(fe),Ue=!0)),!k.firstKeyFrame)){if(le&&xt.size!==0){for(Se=new Uint8Array(xt.size),Oe=0;xt.data.length;)ct=xt.data.shift(),Se.set(ct,Oe),Oe+=ct.byteLength;if(ii.ts.videoPacketContainsKeyFrame(Se)){var Yt=ii.ts.parsePesTime(Se);Yt?(k.firstKeyFrame=Yt,k.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.")}xt.size=0}xt.data.push(B),xt.size+=B.byteLength}break}if(Ue&&k.firstKeyFrame)break;C+=Rs,N+=Rs;continue}C++,N++}for(N=x.byteLength,C=N-Rs,Ue=!1;C>=0;){if(x[C]===Sn&&x[N]===Sn){if(B=x.subarray(C,N),te=ii.ts.parseType(B,w.pid),te==="pes"&&(ne=ii.ts.parsePesType(B,w.table),le=ii.ts.parsePayloadUnitStartIndicator(B),ne==="video"&&le&&(fe=ii.ts.parsePesTime(B),fe&&(fe.type="video",k.video.push(fe),Ue=!0))),Ue)break;C-=Rs,N-=Rs;continue}C--,N--}},ui=function(x,w){if(x.audio&&x.audio.length){var k=w;(typeof k>"u"||isNaN(k))&&(k=x.audio[0].dts),x.audio.forEach(function(B){B.dts=qs(B.dts,k),B.pts=qs(B.pts,k),B.dtsTime=B.dts/Hr,B.ptsTime=B.pts/Hr})}if(x.video&&x.video.length){var C=w;if((typeof C>"u"||isNaN(C))&&(C=x.video[0].dts),x.video.forEach(function(B){B.dts=qs(B.dts,C),B.pts=qs(B.pts,C),B.dtsTime=B.dts/Hr,B.ptsTime=B.pts/Hr}),x.firstKeyFrame){var N=x.firstKeyFrame;N.dts=qs(N.dts,C),N.pts=qs(N.pts,C),N.dtsTime=N.dts/Hr,N.ptsTime=N.pts/Hr}}},Vr=function(x){for(var w=!1,k=0,C=null,N=null,B=0,te=0,ne;x.length-te>=3;){var le=ii.aac.parseType(x,te);switch(le){case"timed-metadata":if(x.length-te<10){w=!0;break}if(B=ii.aac.parseId3TagSize(x,te),B>x.length){w=!0;break}N===null&&(ne=x.subarray(te,te+B),N=ii.aac.parseAacTimestamp(ne)),te+=B;break;case"audio":if(x.length-te<7){w=!0;break}if(B=ii.aac.parseAdtsSize(x,te),B>x.length){w=!0;break}C===null&&(ne=x.subarray(te,te+B),C=ii.aac.parseSampleRate(ne)),k++,te+=B;break;default:te++;break}if(w)return null}if(C===null||N===null)return null;var fe=Hr/C,Se={audio:[{type:"audio",dts:N,pts:N},{type:"audio",dts:N+k*1024*fe,pts:N+k*1024*fe}]};return Se},En=function(x){var w={pid:null,table:null},k={};uf(x,w);for(var C in w.table)if(w.table.hasOwnProperty(C)){var N=w.table[C];switch(N){case Vn.H264_STREAM_TYPE:k.video=[],$i(x,w,k),k.video.length===0&&delete k.video;break;case Vn.ADTS_STREAM_TYPE:k.audio=[],ws(x,w,k),k.audio.length===0&&delete k.audio;break}}return k},ld=function(x,w){var k=ii.aac.isLikelyAacData(x),C;return k?C=Vr(x):C=En(x),!C||!C.audio&&!C.video?null:(ui(C,w),C)},Gr={inspect:ld,parseAudioPes_:ws};const cf=function(x,w){w.on("data",function(k){const C=k.initSegment;k.initSegment={data:C.buffer,byteOffset:C.byteOffset,byteLength:C.byteLength};const N=k.data;k.data=N.buffer,x.postMessage({action:"data",segment:k,byteOffset:N.byteOffset,byteLength:N.byteLength},[k.data])}),w.on("done",function(k){x.postMessage({action:"done"})}),w.on("gopInfo",function(k){x.postMessage({action:"gopInfo",gopInfo:k})}),w.on("videoSegmentTimingInfo",function(k){const C={start:{decode:wt.videoTsToSeconds(k.start.dts),presentation:wt.videoTsToSeconds(k.start.pts)},end:{decode:wt.videoTsToSeconds(k.end.dts),presentation:wt.videoTsToSeconds(k.end.pts)},baseMediaDecodeTime:wt.videoTsToSeconds(k.baseMediaDecodeTime)};k.prependedContentDuration&&(C.prependedContentDuration=wt.videoTsToSeconds(k.prependedContentDuration)),x.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:C})}),w.on("audioSegmentTimingInfo",function(k){const C={start:{decode:wt.videoTsToSeconds(k.start.dts),presentation:wt.videoTsToSeconds(k.start.pts)},end:{decode:wt.videoTsToSeconds(k.end.dts),presentation:wt.videoTsToSeconds(k.end.pts)},baseMediaDecodeTime:wt.videoTsToSeconds(k.baseMediaDecodeTime)};k.prependedContentDuration&&(C.prependedContentDuration=wt.videoTsToSeconds(k.prependedContentDuration)),x.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:C})}),w.on("id3Frame",function(k){x.postMessage({action:"id3Frame",id3Frame:k})}),w.on("caption",function(k){x.postMessage({action:"caption",caption:k})}),w.on("trackinfo",function(k){x.postMessage({action:"trackinfo",trackInfo:k})}),w.on("audioTimingInfo",function(k){x.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:wt.videoTsToSeconds(k.start),end:wt.videoTsToSeconds(k.end)}})}),w.on("videoTimingInfo",function(k){x.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:wt.videoTsToSeconds(k.start),end:wt.videoTsToSeconds(k.end)}})}),w.on("log",function(k){x.postMessage({action:"log",log:k})})};class ud{constructor(w,k){this.options=k||{},this.self=w,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new xg.Transmuxer(this.options),cf(this.self,this.transmuxer)}pushMp4Captions(w){this.captionParser||(this.captionParser=new po,this.captionParser.init());const k=new Uint8Array(w.data,w.byteOffset,w.byteLength),C=this.captionParser.parse(k,w.trackIds,w.timescales);this.self.postMessage({action:"mp4Captions",captions:C&&C.captions||[],logs:C&&C.logs||[],data:k.buffer},[k.buffer])}initMp4WebVttParser(w){this.webVttParser||(this.webVttParser=new jr);const k=new Uint8Array(w.data,w.byteOffset,w.byteLength);this.webVttParser.init(k)}getMp4WebVttText(w){this.webVttParser||(this.webVttParser=new jr);const k=new Uint8Array(w.data,w.byteOffset,w.byteLength),C=this.webVttParser.parseSegment(k);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:C||[],data:k.buffer},[k.buffer])}probeMp4StartTime({timescales:w,data:k}){const C=ho.startTime(w,k);this.self.postMessage({action:"probeMp4StartTime",startTime:C,data:k},[k.buffer])}probeMp4Tracks({data:w}){const k=ho.tracks(w);this.self.postMessage({action:"probeMp4Tracks",tracks:k,data:w},[w.buffer])}probeEmsgID3({data:w,offset:k}){const C=ho.getEmsgID3(w,k);this.self.postMessage({action:"probeEmsgID3",id3Frames:C,emsgData:w},[w.buffer])}probeTs({data:w,baseStartTime:k}){const C=typeof k=="number"&&!isNaN(k)?k*wt.ONE_SECOND_IN_TS:void 0,N=Gr.inspect(w,C);let B=null;N&&(B={hasVideo:N.video&&N.video.length===2||!1,hasAudio:N.audio&&N.audio.length===2||!1},B.hasVideo&&(B.videoStart=N.video[0].ptsTime),B.hasAudio&&(B.audioStart=N.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:B,data:w},[w.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(w){const k=new Uint8Array(w.data,w.byteOffset,w.byteLength);this.transmuxer.push(k)}reset(){this.transmuxer.reset()}setTimestampOffset(w){const k=w.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(wt.secondsToVideoTs(k)))}setAudioAppendStart(w){this.transmuxer.setAudioAppendStart(Math.ceil(wt.secondsToVideoTs(w.appendStart)))}setRemux(w){this.transmuxer.setRemux(w.remux)}flush(w){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(w){this.transmuxer.alignGopsWith(w.gopsToAlignWith.slice())}}self.onmessage=function(x){if(x.data.action==="init"&&x.data.options){this.messageHandlers=new ud(self,x.data.options);return}this.messageHandlers||(this.messageHandlers=new ud(self)),x.data&&x.data.action&&x.data.action!=="init"&&this.messageHandlers[x.data.action]&&this.messageHandlers[x.data.action](x.data)}}));var XB=qk(WB);const QB=(s,e,t)=>{const{type:i,initSegment:n,captions:r,captionStreams:o,metadata:u,videoFrameDtsTime:c,videoFramePtsTime:d}=s.data.segment;e.buffer.push({captions:r,captionStreams:o,metadata:u});const f=s.data.segment.boxes||{data:s.data.segment.data},p={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"&&(p.videoFrameDtsTime=c),typeof d<"u"&&(p.videoFramePtsTime=d),t(p)},ZB=({transmuxedData:s,callback:e})=>{s.buffer=[],e(s)},JB=(s,e)=>{e.gopInfo=s.data.gopInfo},Wk=s=>{const{transmuxer:e,bytes:t,audioAppendStart:i,gopsToAlignWith:n,remux:r,onData:o,onTrackInfo:u,onAudioTimingInfo:c,onVideoTimingInfo:d,onVideoSegmentTimingInfo:f,onAudioSegmentTimingInfo:p,onId3:g,onCaptions:v,onDone:b,onEndedTimeline:_,onTransmuxerLog:S,isEndOfTimeline:D,segment:R,triggerSegmentEventFn:L}=s,M={buffer:[]};let j=D;const V=z=>{e.currentTransmux===s&&(z.data.action==="data"&&QB(z,M,o),z.data.action==="trackinfo"&&u(z.data.trackInfo),z.data.action==="gopInfo"&&JB(z,M),z.data.action==="audioTimingInfo"&&c(z.data.audioTimingInfo),z.data.action==="videoTimingInfo"&&d(z.data.videoTimingInfo),z.data.action==="videoSegmentTimingInfo"&&f(z.data.videoSegmentTimingInfo),z.data.action==="audioSegmentTimingInfo"&&p(z.data.audioSegmentTimingInfo),z.data.action==="id3Frame"&&g([z.data.id3Frame],z.data.id3Frame.dispatchType),z.data.action==="caption"&&v(z.data.caption),z.data.action==="endedtimeline"&&(j=!1,_()),z.data.action==="log"&&S(z.data.log),z.data.type==="transmuxed"&&(j||(e.onmessage=null,ZB({transmuxedData:M,callback:b}),Xk(e))))},P=()=>{const z={message:"Received an error message from the transmuxer worker",metadata:{errorType:De.Error.StreamingFailedToTransmuxSegment,segmentInfo:$l({segment:R})}};b(null,z)};if(e.onmessage=V,e.onerror=P,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 z=t instanceof ArrayBuffer?t:t.buffer,I=t instanceof ArrayBuffer?0:t.byteOffset;L({type:"segmenttransmuxingstart",segment:R}),e.postMessage({action:"push",data:z,byteOffset:I,byteLength:t.byteLength},[z])}D&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},Xk=s=>{s.currentTransmux=null,s.transmuxQueue.length&&(s.currentTransmux=s.transmuxQueue.shift(),typeof s.currentTransmux=="function"?s.currentTransmux():Wk(s.currentTransmux))},QE=(s,e)=>{s.postMessage({action:e}),Xk(s)},Qk=(s,e)=>{if(!e.currentTransmux){e.currentTransmux=s,QE(e,s);return}e.transmuxQueue.push(QE.bind(null,e,s))},eF=s=>{Qk("reset",s)},tF=s=>{Qk("endTimeline",s)},Zk=s=>{if(!s.transmuxer.currentTransmux){s.transmuxer.currentTransmux=s,Wk(s);return}s.transmuxer.transmuxQueue.push(s)},iF=s=>{const e=new XB;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 Qy={reset:eF,endTimeline:tF,transmux:Zk,createTransmuxer:iF};const uc=function(s){const e=s.transmuxer,t=s.endAction||s.action,i=s.callback,n=Ss({},s,{endAction:null,transmuxer:null,callback:null}),r=o=>{o.data.action===t&&(e.removeEventListener("message",r),o.data.data&&(o.data.data=new Uint8Array(o.data.data,s.byteOffset||0,s.byteLength||o.data.data.byteLength),s.data&&(s.data=o.data.data)),i(o.data))};if(e.addEventListener("message",r),s.data){const o=s.data instanceof ArrayBuffer;n.byteOffset=o?0:s.data.byteOffset,n.byteLength=s.data.byteLength;const u=[o?s.data:s.data.buffer];e.postMessage(n,u)}else e.postMessage(n)},oa={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Jk="wvtt",hx=s=>{s.forEach(e=>{e.abort()})},sF=s=>({bandwidth:s.bandwidth,bytesReceived:s.bytesReceived||0,roundTripTime:s.roundTripTime||0}),nF=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},Lb=(s,e)=>{const{requestType:t}=e,i=Xl({requestType:t,request:e,error:s});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:oa.TIMEOUT,xhr:e,metadata:i}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:oa.ABORTED,xhr:e,metadata:i}:s?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:oa.FAILURE,xhr:e,metadata:i}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:oa.FAILURE,xhr:e,metadata:i}:null},ZE=(s,e,t,i)=>(n,r)=>{const o=r.response,u=Lb(n,r);if(u)return t(u,s);if(o.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:oa.FAILURE,xhr:r},s);const c=new DataView(o),d=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let p=0;p<e.length;p++)e[p].bytes=d;const f={uri:r.uri};return i({type:"segmentkeyloadcomplete",segment:s,keyInfo:f}),t(null,s)},rF=(s,e)=>{e===Jk&&s.transmuxer.postMessage({action:"initMp4WebVttParser",data:s.map.bytes})},aF=(s,e,t)=>{e===Jk&&uc({action:"getMp4WebVttText",data:s.bytes,transmuxer:s.transmuxer,callback:({data:i,mp4VttCues:n})=>{s.bytes=i,t(null,s,{mp4VttCues:n})}})},eD=(s,e)=>{const t=Jx(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:oa.FAILURE,metadata:{mediaType:n}})}uc({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"&&rF(s,r.codec))}),e(null))})},oF=({segment:s,finishProcessingFn:e,triggerSegmentEventFn:t})=>(i,n)=>{const r=Lb(i,n);if(r)return e(r,s);const o=new Uint8Array(n.response);if(t({type:"segmentloaded",segment:s}),s.map.key)return s.map.encryptedBytes=o,e(null,s);s.map.bytes=o,eD(s,function(u){if(u)return u.xhr=n,u.status=n.status,e(u,s);e(null,s)})},lF=({segment:s,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:i})=>(n,r)=>{const o=Lb(n,r);if(o)return e(o,s);i({type:"segmentloaded",segment:s});const u=t==="arraybuffer"||!r.responseText?r.response:KB(r.responseText.substring(s.lastReachedChar||0));return s.stats=sF(r),s.key?s.encryptedBytes=new Uint8Array(u):s.bytes=new Uint8Array(u),e(null,s)},uF=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{const b=s.map&&s.map.tracks||{},_=!!(b.audio&&b.video);let S=i.bind(null,s,"audio","start");const D=i.bind(null,s,"audio","end");let R=i.bind(null,s,"video","start");const L=i.bind(null,s,"video","end"),M=()=>Zk({bytes:e,transmuxer:s.transmuxer,audioAppendStart:s.audioAppendStart,gopsToAlignWith:s.gopsToAlignWith,remux:_,onData:j=>{j.type=j.type==="combined"?"video":j.type,f(s,j)},onTrackInfo:j=>{t&&(_&&(j.isMuxed=!0),t(s,j))},onAudioTimingInfo:j=>{S&&typeof j.start<"u"&&(S(j.start),S=null),D&&typeof j.end<"u"&&D(j.end)},onVideoTimingInfo:j=>{R&&typeof j.start<"u"&&(R(j.start),R=null),L&&typeof j.end<"u"&&L(j.end)},onVideoSegmentTimingInfo:j=>{const V={pts:{start:j.start.presentation,end:j.end.presentation},dts:{start:j.start.decode,end:j.end.decode}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:V}),n(j)},onAudioSegmentTimingInfo:j=>{const V={pts:{start:j.start.pts,end:j.end.pts},dts:{start:j.start.dts,end:j.end.dts}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:V}),r(j)},onId3:(j,V)=>{o(s,j,V)},onCaptions:j=>{u(s,[j])},isEndOfTimeline:c,onEndedTimeline:()=>{d()},onTransmuxerLog:g,onDone:(j,V)=>{p&&(j.type=j.type==="combined"?"video":j.type,v({type:"segmenttransmuxingcomplete",segment:s}),p(V,s,j))},segment:s,triggerSegmentEventFn:v});uc({action:"probeTs",transmuxer:s.transmuxer,data:e,baseStartTime:s.baseStartTime,callback:j=>{s.bytes=e=j.data;const V=j.result;V&&(t(s,{hasAudio:V.hasAudio,hasVideo:V.hasVideo,isMuxed:_}),t=null),M()}})},tD=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{let b=new Uint8Array(e);if(L3(b)){s.isFmp4=!0;const{tracks:_}=s.map;if(_.text&&(!_.audio||!_.video)){f(s,{data:b,type:"text"}),aF(s,_.text.codec,p);return}const D={isFmp4:!0,hasVideo:!!_.video,hasAudio:!!_.audio};_.audio&&_.audio.codec&&_.audio.codec!=="enca"&&(D.audioCodec=_.audio.codec),_.video&&_.video.codec&&_.video.codec!=="encv"&&(D.videoCodec=_.video.codec),_.video&&_.audio&&(D.isMuxed=!0),t(s,D);const R=(L,M)=>{f(s,{data:b,type:D.hasAudio&&!D.isMuxed?"audio":"video"}),M&&M.length&&o(s,M),L&&L.length&&u(s,L),p(null,s,{})};uc({action:"probeMp4StartTime",timescales:s.map.timescales,data:b,transmuxer:s.transmuxer,callback:({data:L,startTime:M})=>{e=L.buffer,s.bytes=b=L,D.hasAudio&&!D.isMuxed&&i(s,"audio","start",M),D.hasVideo&&i(s,"video","start",M),uc({action:"probeEmsgID3",data:b,transmuxer:s.transmuxer,offset:M,callback:({emsgData:j,id3Frames:V})=>{if(e=j.buffer,s.bytes=b=j,!_.video||!j.byteLength||!s.transmuxer){R(void 0,V);return}uc({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:s.transmuxer,data:b,timescales:s.map.timescales,trackIds:[_.video.id],callback:P=>{e=P.data.buffer,s.bytes=b=P.data,P.logs.forEach(function(z){g(Ai(z,{stream:"mp4CaptionParser"}))}),R(P.captions,V)}})}})}});return}if(!s.transmuxer){p(null,s,{});return}if(typeof s.container>"u"&&(s.container=Jx(b)),s.container!=="ts"&&s.container!=="aac"){t(s,{hasAudio:!1,hasVideo:!1}),p(null,s,{});return}uF({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})},iD=function({id:s,key:e,encryptedBytes:t,decryptionWorker:i,segment:n,doneFn:r},o){const u=d=>{if(d.data.source===s){i.removeEventListener("message",u);const f=d.data.decrypted;o(new Uint8Array(f.bytes,f.byteOffset,f.byteLength))}};i.onerror=()=>{const d="An error occurred in the decryption worker",f=$l({segment:n}),p={message:d,metadata:{error:new Error(d),errorType:De.Error.StreamingFailedToDecryptSegment,segmentInfo:f,keyInfo:{uri:n.key.resolvedUri||n.map.key.resolvedUri}}};r(p,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(jk({source:s,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},cF=({decryptionWorker:s,segment:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{v({type:"segmentdecryptionstart"}),iD({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:s,segment:e,doneFn:p},b=>{e.bytes=b,v({type:"segmentdecryptioncomplete",segment:e}),tD({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})})},dF=({activeXhrs:s,decryptionWorker:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{let b=0,_=!1;return(S,D)=>{if(!_){if(S)return _=!0,hx(s),p(S,D);if(b+=1,b===s.length){const R=function(){if(D.encryptedBytes)return cF({decryptionWorker:e,segment:D,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v});tD({segment:D,bytes:D.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:p,onTransmuxerLog:g,triggerSegmentEventFn:v})};if(D.endOfAllRequests=Date.now(),D.map&&D.map.encryptedBytes&&!D.map.bytes)return v({type:"segmentdecryptionstart",segment:D}),iD({decryptionWorker:e,id:D.requestId+"-init",encryptedBytes:D.map.encryptedBytes,key:D.map.key,segment:D,doneFn:p},L=>{D.map.bytes=L,v({type:"segmentdecryptioncomplete",segment:D}),eD(D,M=>{if(M)return hx(s),p(M,D);R()})});R()}}}},hF=({loadendState:s,abortFn:e})=>t=>{t.target.aborted&&e&&!s.calledAbortFn&&(e(),s.calledAbortFn=!0)},fF=({segment:s,progressFn:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f})=>p=>{if(!p.target.aborted)return s.stats=Ai(s.stats,nF(p)),!s.stats.firstBytesReceivedAt&&s.stats.bytesReceived&&(s.stats.firstBytesReceivedAt=Date.now()),e(p,s)},mF=({xhr:s,xhrOptions:e,decryptionWorker:t,segment:i,abortFn:n,progressFn:r,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:p,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b,doneFn:_,onTransmuxerLog:S,triggerSegmentEventFn:D})=>{const R=[],L=dF({activeXhrs:R,decryptionWorker:t,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:p,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b,doneFn:_,onTransmuxerLog:S,triggerSegmentEventFn:D});if(i.key&&!i.key.bytes){const z=[i.key];i.map&&!i.map.bytes&&i.map.key&&i.map.key.resolvedUri===i.key.resolvedUri&&z.push(i.map.key);const I=Ai(e,{uri:i.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),O=ZE(i,z,L,D),W={uri:i.key.resolvedUri};D({type:"segmentkeyloadstart",segment:i,keyInfo:W});const X=s(I,O);R.push(X)}if(i.map&&!i.map.bytes){if(i.map.key&&(!i.key||i.key.resolvedUri!==i.map.key.resolvedUri)){const X=Ai(e,{uri:i.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),q=ZE(i,[i.map.key],L,D),ue={uri:i.map.key.resolvedUri};D({type:"segmentkeyloadstart",segment:i,keyInfo:ue});const ie=s(X,q);R.push(ie)}const I=Ai(e,{uri:i.map.resolvedUri,responseType:"arraybuffer",headers:cx(i.map),requestType:"segment-media-initialization"}),O=oF({segment:i,finishProcessingFn:L,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:i});const W=s(I,O);R.push(W)}const M=Ai(e,{uri:i.part&&i.part.resolvedUri||i.resolvedUri,responseType:"arraybuffer",headers:cx(i),requestType:"segment"}),j=lF({segment:i,finishProcessingFn:L,responseType:M.responseType,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:i});const V=s(M,j);V.addEventListener("progress",fF({segment:i,progressFn:r,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:p,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b})),R.push(V);const P={};return R.forEach(z=>{z.addEventListener("loadend",hF({loadendState:P,abortFn:n}))}),()=>hx(R)},mm=gr("PlaylistSelector"),JE=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||""})},cc=function(s,e){if(!s)return"";const t=he.getComputedStyle(s);return t?t[e]:""},dc=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})},Rb=function(s,e){let t,i;return s.attributes.BANDWIDTH&&(t=s.attributes.BANDWIDTH),t=t||he.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||he.Number.MAX_VALUE,t-i},pF=function(s,e){let t,i;return s.attributes.RESOLUTION&&s.attributes.RESOLUTION.width&&(t=s.attributes.RESOLUTION.width),t=t||he.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||he.Number.MAX_VALUE,t===i&&s.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?s.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-i};let sD=function(s){const{main:e,bandwidth:t,playerWidth:i,playerHeight:n,playerObjectFit:r,limitRenditionByPlayerDimensions:o,playlistController:u}=s;if(!e)return;const c={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:o};let d=e.playlists;Mn.isAudioOnly(e)&&(d=u.getAudioTrackPlaylists_(),c.audioOnly=!0);let f=d.map(P=>{let z;const I=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.width,O=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.height;return z=P.attributes&&P.attributes.BANDWIDTH,z=z||he.Number.MAX_VALUE,{bandwidth:z,width:I,height:O,playlist:P}});dc(f,(P,z)=>P.bandwidth-z.bandwidth),f=f.filter(P=>!Mn.isIncompatible(P.playlist));let p=f.filter(P=>Mn.isEnabled(P.playlist));p.length||(p=f.filter(P=>!Mn.isDisabled(P.playlist)));const g=p.filter(P=>P.bandwidth*Vs.BANDWIDTH_VARIANCE<t);let v=g[g.length-1];const b=g.filter(P=>P.bandwidth===v.bandwidth)[0];if(o===!1){const P=b||p[0]||f[0];if(P&&P.playlist){let z="sortedPlaylistReps";return b&&(z="bandwidthBestRep"),p[0]&&(z="enabledPlaylistReps"),mm(`choosing ${JE(P)} using ${z} with options`,c),P.playlist}return mm("could not choose a playlist with options",c),null}const _=g.filter(P=>P.width&&P.height);dc(_,(P,z)=>P.width-z.width);const S=_.filter(P=>P.width===i&&P.height===n);v=S[S.length-1];const D=S.filter(P=>P.bandwidth===v.bandwidth)[0];let R,L,M;D||(R=_.filter(P=>r==="cover"?P.width>i&&P.height>n:P.width>i||P.height>n),L=R.filter(P=>P.width===R[0].width&&P.height===R[0].height),v=L[L.length-1],M=L.filter(P=>P.bandwidth===v.bandwidth)[0]);let j;if(u.leastPixelDiffSelector){const P=_.map(z=>(z.pixelDiff=Math.abs(z.width-i)+Math.abs(z.height-n),z));dc(P,(z,I)=>z.pixelDiff===I.pixelDiff?I.bandwidth-z.bandwidth:z.pixelDiff-I.pixelDiff),j=P[0]}const V=j||M||D||b||p[0]||f[0];if(V&&V.playlist){let P="sortedPlaylistReps";return j?P="leastPixelDiffRep":M?P="resolutionPlusOneRep":D?P="resolutionBestRep":b?P="bandwidthBestRep":p[0]&&(P="enabledPlaylistReps"),mm(`choosing ${JE(V)} using ${P} with options`,c),V.playlist}return mm("could not choose a playlist with options",c),null};const e2=function(){let s=this.useDevicePixelRatio&&he.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(s=this.customPixelRatio),sD({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(cc(this.tech_.el(),"width"),10)*s,playerHeight:parseInt(cc(this.tech_.el(),"height"),10)*s,playerObjectFit:this.usePlayerObjectFit?cc(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},gF=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&&he.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),sD({main:this.playlists.main,bandwidth:e,playerWidth:parseInt(cc(this.tech_.el(),"width"),10)*i,playerHeight:parseInt(cc(this.tech_.el(),"height"),10)*i,playerObjectFit:this.usePlayerObjectFit?cc(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},yF=function(s){const{main:e,currentTime:t,bandwidth:i,duration:n,segmentDuration:r,timeUntilRebuffer:o,currentTimeline:u,syncController:c}=s,d=e.playlists.filter(b=>!Mn.isIncompatible(b));let f=d.filter(Mn.isEnabled);f.length||(f=d.filter(b=>!Mn.isDisabled(b)));const g=f.filter(Mn.hasAttribute.bind(null,"BANDWIDTH")).map(b=>{const S=c.getSyncPoint(b,n,u,t)?1:2,R=Mn.estimateSegmentRequestTime(r,i,b)*S-o;return{playlist:b,rebufferingImpact:R}}),v=g.filter(b=>b.rebufferingImpact<=0);return dc(v,(b,_)=>Rb(_.playlist,b.playlist)),v.length?v[0]:(dc(g,(b,_)=>b.rebufferingImpact-_.rebufferingImpact),g[0]||null)},vF=function(){const s=this.playlists.main.playlists.filter(Mn.isEnabled);return dc(s,(t,i)=>Rb(t,i)),s.filter(t=>!!ch(this.playlists.main,t).video)[0]||null},xF=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 nD(s){try{return new URL(s).pathname.split("/").slice(-2).join("/")}catch{return""}}const bF=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 o=t,u=t,c=!1;const d=r[i];d&&(o=d.label,u=d.language,c=d.default),s[t]=e.addRemoteTextTrack({kind:"captions",id:i,default:c,label:o,language:u},!1).track}}},TF=function({inbandTextTracks:s,captionArray:e,timestampOffset:t}){if(!e)return;const i=he.WebKitDataCue||he.VTTCue;e.forEach(n=>{const r=n.stream;n.content?n.content.forEach(o=>{const u=new i(n.startTime+t,n.endTime+t,o.text);u.line=o.line,u.align="left",u.position=o.position,u.positionAlign="line-left",s[r].addCue(u)}):s[r].addCue(new i(n.startTime+t,n.endTime+t,n.text))})},_F=function(s){Object.defineProperties(s.frame,{id:{get(){return De.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),s.value.key}},value:{get(){return De.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),s.value.data}},privateData:{get(){return De.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),s.value.data}}})},SF=({inbandTextTracks:s,metadataArray:e,timestampOffset:t,videoDuration:i})=>{if(!e)return;const n=he.WebKitDataCue||he.VTTCue,r=s.metadataTrack_;if(!r||(e.forEach(f=>{const p=f.cueTime+t;typeof p!="number"||he.isNaN(p)||p<0||!(p<1/0)||!f.frames||!f.frames.length||f.frames.forEach(g=>{const v=new n(p,p,g.value||g.url||g.data||"");v.frame=g,v.value=g,_F(v),r.addCue(v)})}),!r.cues||!r.cues.length))return;const o=r.cues,u=[];for(let f=0;f<o.length;f++)o[f]&&u.push(o[f]);const c=u.reduce((f,p)=>{const g=f[p.startTime]||[];return g.push(p),f[p.startTime]=g,f},{}),d=Object.keys(c).sort((f,p)=>Number(f)-Number(p));d.forEach((f,p)=>{const g=c[f],v=isFinite(i)?i:f,b=Number(d[p+1])||v;g.forEach(_=>{_.endTime=b})})},EF={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"},wF=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),AF=({inbandTextTracks:s,dateRanges:e})=>{const t=s.metadataTrack_;if(!t)return;const i=he.WebKitDataCue||he.VTTCue;e.forEach(n=>{for(const r of Object.keys(n)){if(wF.has(r))continue;const o=new i(n.startTime,n.endTime,"");o.id=n.id,o.type="com.apple.quicktime.HLS",o.value={key:EF[r],data:n[r]},(r==="scte35Out"||r==="scte35In")&&(o.value.data=new Uint8Array(o.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(o)}n.processDateRange()})},t2=(s,e,t)=>{s.metadataTrack_||(s.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,De.browser.IS_ANY_SAFARI||(s.metadataTrack_.inBandMetadataTrackDispatchType=e))},Jd=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)},CF=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}},kF=(s,e,t)=>{if(typeof e>"u"||e===null||!s.length)return[];const i=Math.ceil((e-t+3)*Gl.ONE_SECOND_IN_TS);let n;for(n=0;n<s.length&&!(s[n].pts>i);n++);return s.slice(n)},DF=(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)},LF=(s,e,t,i)=>{const n=Math.ceil((e-i)*Gl.ONE_SECOND_IN_TS),r=Math.ceil((t-i)*Gl.ONE_SECOND_IN_TS),o=s.slice();let u=s.length;for(;u--&&!(s[u].pts<=r););if(u===-1)return o;let c=u+1;for(;c--&&!(s[c].pts<=n););return c=Math.max(c,0),o.splice(c,u-c+1),o},RF=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},IF=function(s,e,t){e=e||[];const i=[];let n=0;for(let r=0;r<e.length;r++){const o=e[r];if(s===o.timeline&&(i.push(r),n+=o.duration,n>t))return r}return i.length===0?0:i[i.length-1]},Gd=1,NF=500,i2=s=>typeof s=="number"&&isFinite(s),pm=1/60,OF=(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,MF=(s,e,t)=>{let i=e-Vs.BACK_BUFFER_LENGTH;s.length&&(i=Math.max(i,s.start(0)));const n=e-t;return Math.min(n,i)},Vu=s=>{const{startOfSegment:e,duration:t,segment:i,part:n,playlist:{mediaSequence:r,id:o,segments:u=[]},mediaIndex:c,partIndex:d,timeline:f}=s,p=u.length-1;let g="mediaIndex/partIndex increment";s.getMediaInfoForTime?g=`getMediaInfoForTime (${s.getMediaInfoForTime})`:s.isSyncRequest&&(g="getSyncSegmentCandidate (isSyncRequest)"),s.independent&&(g+=` with independent ${s.independent}`);const v=typeof d=="number",b=s.segment.uri?"segment":"pre-segment",_=v?_k({preloadSegment:i})-1:0;return`${b} [${r+c}/${r+p}]`+(v?` part [${d}/${_}]`:"")+` segment start/end [${i.start} => ${i.end}]`+(v?` part start/end [${n.start} => ${n.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${f}] selected by [${g}] playlist [${o}]`},s2=s=>`${s}TimingInfo`,PF=({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},BF=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)},FF=s=>{const e=s.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=s.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},jo=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_})&&BF(s.timelineChangeController_)){if(FF(s)){s.timelineChangeController_.trigger("audioTimelineBehind");return}s.timelineChangeController_.trigger("fixBadTimelineChange")}},UF=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 o;typeof n=="bigint"||typeof r=="bigint"?o=he.BigInt(r)-he.BigInt(n):typeof n=="number"&&typeof r=="number"&&(o=r-n),typeof o<"u"&&o>e&&(e=o)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},n2=({segmentDuration:s,maxDuration:e})=>s?Math.round(s)>e+ra:!1,jF=(s,e)=>{if(e!=="hls")return null;const t=UF({audioTimingInfo:s.audioTimingInfo,videoTimingInfo:s.videoTimingInfo});if(!t)return null;const i=s.playlist.targetDuration,n=n2({segmentDuration:t,maxDuration:i*2}),r=n2({segmentDuration:t,maxDuration:i}),o=`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:o}:null},$l=({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 mx extends De.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_=gr(`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_():jo(this)}),this.sourceUpdater_.on("codecschange",i=>{this.trigger(Ss({type:"codecschange"},i))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():jo(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",i=>{this.trigger(Ss({type:"timelinechange"},i)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():jo(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():jo(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Qy.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_&&he.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,he.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_&&Qy.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return zs();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=gp(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=$k(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: ${Wy(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 o=e.mediaSequence-i.mediaSequence;if(this.logger_(`live window shift [${o}]`),this.mediaIndex!==null)if(this.mediaIndex-=o,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-=o,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_&&(he.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_&&Qy.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 o=()=>{r--,r===0&&i()};(n||!this.audioDisabled_)&&(r++,this.sourceUpdater_.removeAudio(e,t,o)),(n||this.loaderType_==="main")&&(this.gopBuffer_=LF(this.gopBuffer_,e,t,this.timeMapping_),r++,this.sourceUpdater_.removeVideo(e,t,o));for(const u in this.inbandTextTracks_)Jd(e,t,this.inbandTextTracks_[u]);Jd(e,t,this.segmentMetadataTrack_),o()}monitorBuffer_(){this.checkBufferTimeout_&&he.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=he.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&he.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=he.setTimeout(this.monitorBufferTick_.bind(this),NF)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();if(!e)return;const t={segmentInfo:$l({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,o=!n||!n.parts||i+1===n.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&r&&o}chooseNextRequest_(){const e=this.buffered_(),t=Wy(e)||0,i=Ab(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),o=this.playlist_.segments;if(!o.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=IF(this.currentTimeline_,o,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${u.mediaIndex}`);else if(this.mediaIndex!==null){const g=o[this.mediaIndex],v=typeof this.partIndex=="number"?this.partIndex:-1;u.startOfSegment=g.end?g.end:t,g.parts&&g.parts[v+1]?(u.mediaIndex=this.mediaIndex,u.partIndex=v+1):u.mediaIndex=this.mediaIndex+1}else{let g,v,b;const _=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
For TargetTime: ${_}.
CurrentTime: ${this.currentTime_()}
BufferedEnd: ${t}
Fetch At Buffer: ${this.fetchAtBuffer_}
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const S=this.getSyncInfoFromMediaSequenceSync_(_);if(!S){const D="No sync info found while using media sequence sync";return this.error({message:D,metadata:{errorType:De.Error.StreamingFailedToSelectNextSegment,error:new Error(D)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${S.start} --> ${S.end})`),g=S.segmentIndex,v=S.partIndex,b=S.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const S=Mn.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:_,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});g=S.segmentIndex,v=S.partIndex,b=S.startTime}u.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${_}`:`currentTime ${_}`,u.mediaIndex=g,u.startOfSegment=b,u.partIndex=v,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${u.mediaIndex} `)}const c=o[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 g=o[u.mediaIndex-1],v=g.parts&&g.parts.length&&g.parts[g.parts.length-1];v&&v.independent&&(u.mediaIndex-=1,u.partIndex=g.parts.length-1,u.independent="previous segment")}else c.parts[u.partIndex-1].independent&&(u.partIndex-=1,u.independent="previous part");const p=this.mediaSource_&&this.mediaSource_.readyState==="ended";return u.mediaIndex>=o.length-1&&p&&!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:o,partIndex:u,forceTimestampOffset:c,getMediaInfoForTime:d}=e,f=i.segments[n],p=typeof u=="number"&&f.parts[u],g={requestId:"segment-loader-"+Math.random(),uri:p&&p.resolvedUri||f.resolvedUri,mediaIndex:n,partIndex:p?u:null,isSyncRequest:o,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:f.timeline,duration:p&&p.duration||f.duration,segment:f,part:p,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:d,independent:t},v=typeof c<"u"?c:this.isPendingTimestampOffset_;g.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:f.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:v});const b=Wy(this.sourceUpdater_.audioBuffered());return typeof b=="number"&&(g.audioAppendStart=b-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(g.gopsToAlignWith=kF(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),g}timestampOffsetForSegment_(e){return PF(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=Mn.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),o=nB(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=o)return;const u=yF({main:this.vhs_.playlists.main,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:o,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!u)return;const d=r-o-u.rebufferingImpact;let f=.5;o<=ra&&(f=1),!(!u.playlist||u.playlist.uri===this.playlist_.uri||d<f)&&(this.bandwidth=u.playlist.attributes.BANDWIDTH*Vs.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${Vu(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:$l({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||{},RF(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_():jo(this))))}handleTimingInfo_(e,t,i,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,o=s2(t);r[o]=r[o]||{},r[o][i]=n,this.logger_(`timinginfo: ${t} - ${i} - ${n}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():jo(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(o=>{r[o.stream]=r[o.stream]||{startTime:1/0,captions:[],endTime:0};const u=r[o.stream];u.startTime=Math.min(u.startTime,o.startTime+n),u.endTime=Math.max(u.endTime,o.endTime+n),u.captions.push(o)}),Object.keys(r).forEach(o=>{const{startTime:u,endTime:c,captions:d}=r[o],f=this.inbandTextTracks_;this.logger_(`adding cues from ${u} -> ${c} for ${o}`),bF(f,this.vhs_.tech_,o),Jd(u,c,f[o]),TF({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_()){jo(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[s2(t.type)].start;else{const n=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&n&&n.hasVideo;let o;r&&(o=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:o,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=gp(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(),o=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+zl(r).join(", ")),o.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+zl(o).join(", "));const u=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,d=o.length?o.start(0):0,f=o.length?o.end(o.length-1):0;if(c-u<=Gd&&f-d<=Gd){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${i.byteLength}, audio buffer: ${zl(r).join(", ")}, video buffer: ${zl(o).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 g=this.currentTime_()-Gd;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${g}`),this.remove(0,g,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${Gd}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=he.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},Gd*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:i},n){if(n){if(n.code===Nk){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:De.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=xF({bytes:c,segments:u})}const o={segmentInfo:$l({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:o}),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_()){jo(this),this.loadQueue_.push(()=>{const t=Ss({},e,{forceTimestampOffset:!0});Ss(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,o=i||n&&r;this.logger_(`Requesting
${nD(e.uri)}
${Vu(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=mF({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:o,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_(`${Vu(e)} logged from transmuxer stream ${d} as a ${c}: ${u}`)},triggerSegmentEventFn:({type:u,segment:c,keyInfo:d,trackInfo:f,timingInfo:p})=>{const v={segmentInfo:$l({segment:c})};d&&(v.keyInfo=d),f&&(v.trackInfo=f),p&&(v.timingInfo=p),this.trigger({type:u,metadata:v})}})}trimBackBuffer_(e){const t=MF(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,o={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?o.baseStartTime=u.videoTimingInfo.transmuxedDecodeEnd:u.audioTimingInfo&&(o.baseStartTime=u.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);o.key=this.segmentKey(t.key),o.key.iv=c}return t.map&&(o.map=this.initSegmentForMap(t.map)),o}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<pm){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${pm}`);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===oa.ABORTED)return;if(this.pause(),e.code===oa.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_=DF(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:o,videoTimingInfo:u,audioTimingInfo:c}){if(typeof e<"u")return e;if(!o)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,o=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}o&&e.waitingOnAppends++,u&&e.waitingOnAppends++,o&&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=OF(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:$l({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=jF(e,this.sourceType_);if(t&&(t.severity==="warn"?De.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 ${Vu(e)}`);return}this.logger_(`Appended ${Vu(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,o=n&&n.end&&this.currentTime_()-n.end>e.playlist.partTargetDuration*3;if(r||o){this.logger_(`bad ${r?"segment":"part"} ${Vu(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<pm){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${pm}`);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(!i2(i)||!i2(n))return;Jd(i,n,this.segmentMetadataTrack_);const r=he.WebKitDataCue||he.VTTCue,o={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(o),c=new r(i,n,u);c.value=o,this.segmentMetadataTrack_.addCue(c)}}function Ka(){}const rD=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},$F=["video","audio"],px=(s,e)=>{const t=e[`${s}Buffer`];return t&&t.updating||e.queuePending[s]},HF=(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},hc=(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(),hc("audio",e),hc("video",e));return}if(s!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||px(s,e))){if(i.type!==s){if(t=HF(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,hc(s,e);return}}},aD=(s,e)=>{const t=e[`${s}Buffer`],i=rD(s);t&&(t.removeEventListener("updateend",e[`on${i}UpdateEnd_`]),t.removeEventListener("error",e[`on${i}Error_`]),e.codecs[s]=null,e[`${s}Buffer`]=null)},ta=(s,e)=>s&&e&&Array.prototype.indexOf.call(s.sourceBuffers,e)!==-1,Wn={appendBuffer:(s,e,t)=>(i,n)=>{const r=n[`${i}Buffer`];if(ta(n.mediaSource,r)){n.logger_(`Appending segment ${e.mediaIndex}'s ${s.length} bytes to ${i}Buffer`);try{r.appendBuffer(s)}catch(o){n.logger_(`Error with code ${o.code} `+(o.code===Nk?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${i}Buffer`),n.queuePending[i]=null,t(o)}}},remove:(s,e)=>(t,i)=>{const n=i[`${t}Buffer`];if(ta(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`];ta(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){De.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){De.log.warn("Failed to set media source duration",t)}},abort:()=>(s,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${s}Buffer`];if(ta(e.mediaSource,t)){e.logger_(`calling abort on ${s}Buffer`);try{t.abort()}catch(i){De.log.warn(`Failed to abort on ${s}Buffer`,i)}}},addSourceBuffer:(s,e)=>t=>{const i=rD(s),n=Tc(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(aD(s,e),!!ta(e.mediaSource,t)){e.logger_(`Removing ${s}Buffer with codec ${e.codecs[s]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(i){De.log.warn(`Failed to removeSourceBuffer ${s}Buffer`,i)}}},changeType:s=>(e,t)=>{const i=t[`${e}Buffer`],n=Tc(s);if(!ta(t.mediaSource,i))return;const r=s.substring(0,s.indexOf(".")),o=t.codecs[e];if(o.substring(0,o.indexOf("."))===r)return;const c={codecsChangeInfo:{from:o,to:s}};t.trigger({type:"codecschange",metadata:c}),t.logger_(`changing ${e}Buffer codec from ${o} to ${s}`);try{i.changeType(n),t.codecs[e]=s}catch(d){c.errorType=De.Error.StreamingCodecsChangeError,c.error=d,d.metadata=c,t.error_=d,t.trigger("error"),De.log.warn(`Failed to changeType on ${e}Buffer`,d)}}},Xn=({type:s,sourceUpdater:e,action:t,doneFn:i,name:n})=>{e.queue.push({type:s,action:t,doneFn:i,name:n}),hc(s,e)},r2=(s,e)=>t=>{const i=e[`${s}Buffered`](),n=tB(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_`])}hc(s,e)};class oD extends De.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>hc("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=gr("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=r2("video",this),this.onAudioUpdateEnd_=r2("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){Xn({type:"mediaSource",sourceUpdater:this,action:Wn.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){Xn({type:e,sourceUpdater:this,action:Wn.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){De.log.error("removeSourceBuffer is not supported!");return}Xn({type:"mediaSource",sourceUpdater:this,action:Wn.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!De.browser.IS_FIREFOX&&he.MediaSource&&he.MediaSource.prototype&&typeof he.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return he.SourceBuffer&&he.SourceBuffer.prototype&&typeof he.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){De.log.error("changeType is not supported!");return}Xn({type:e,sourceUpdater:this,action:Wn.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 o=t;if(Xn({type:n,sourceUpdater:this,action:Wn.appendBuffer(r,i||{mediaIndex:-1},o),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 ta(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:zs()}videoBuffered(){return ta(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:zs()}buffered(){const e=ta(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=ta(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():sB(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=Ka){Xn({type:"mediaSource",sourceUpdater:this,action:Wn.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=Ka){typeof e!="string"&&(e=void 0),Xn({type:"mediaSource",sourceUpdater:this,action:Wn.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=Ka){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){i();return}Xn({type:"audio",sourceUpdater:this,action:Wn.remove(e,t),doneFn:i,name:"remove"})}removeVideo(e,t,i=Ka){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){i();return}Xn({type:"video",sourceUpdater:this,action:Wn.remove(e,t),doneFn:i,name:"remove"})}updating(){return!!(px("audio",this)||px("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(Xn({type:"audio",sourceUpdater:this,action:Wn.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(Xn({type:"video",sourceUpdater:this,action:Wn.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&Xn({type:"audio",sourceUpdater:this,action:Wn.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&Xn({type:"video",sourceUpdater:this,action:Wn.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),$F.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>aD(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const a2=s=>decodeURIComponent(escape(String.fromCharCode.apply(null,s))),VF=s=>{const e=new Uint8Array(s);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},o2=new Uint8Array(`
`.split("").map(s=>s.charCodeAt(0)));class GF extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class zF extends mx{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 zs();const e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return zs([[t,i]])}initSegmentForMap(e,t=!1){if(!e)return null;const i=gp(e);let n=this.initSegments_[i];if(t&&!n&&e.bytes){const r=o2.byteLength+e.bytes.byteLength,o=new Uint8Array(r);o.set(e.bytes),o.set(o2,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:o}}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){Jd(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===oa.TIMEOUT&&this.handleTimeout_(),e.code===oa.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 o=n.segment;if(o.map&&(o.map.bytes=t.map.bytes),n.bytes=t.bytes,typeof he.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}o.requested=!0;try{this.parseVTTCues_(n)}catch(u){this.stopForError({message:u.message,metadata:{errorType:De.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+=o.duration,n.cues.forEach(u=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new he.VTTCue(u.startTime,u.endTime,u.text):u)}),CF(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,o=new he.VTTCue(n,r,i.cueText);i.settings&&i.settings.split(" ").forEach(u=>{const c=u.split(":"),d=c[0],f=c[1];o[d]=isNaN(f)?f:Number(f)}),e.cues.push(o)})}parseVTTCues_(e){let t,i=!1;if(typeof he.WebVTT!="function")throw new GF;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof he.TextDecoder=="function"?t=new he.TextDecoder("utf8"):(t=he.WebVTT.StringDecoder(),i=!0);const n=new he.WebVTT.Parser(he,he.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=o=>{e.timestampmap=o},n.onparsingerror=o=>{De.log.warn("Error encountered when parsing cues: "+o.message)},e.segment.map){let o=e.segment.map.bytes;i&&(o=a2(o)),n.parse(o)}let r=e.bytes;i&&(r=a2(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:o}=e.timestampmap,c=r/Gl.ONE_SECOND_IN_TS-o+t.mapping;if(e.cues.forEach(d=>{const f=d.endTime-d.startTime,p=this.handleRollover_(d.startTime+c,t.time);d.startTime=Math.max(p,0),d.endTime=Math.max(p+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*Gl.ONE_SECOND_IN_TS;const n=t*Gl.ONE_SECOND_IN_TS;let r;for(n<i?r=-8589934592:r=8589934592;Math.abs(i-n)>4294967296;)i+=r;return i/Gl.ONE_SECOND_IN_TS}}const qF=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},KF=function(s,e,t=0){if(!s.segments)return;let i=t,n;for(let r=0;r<s.segments.length;r++){const o=s.segments[r];if(n||(n=qF(e,i+o.duration/2)),n){if("cueIn"in o){n.endTime=i,n.adEndTime=i,i+=o.duration,n=null;continue}if(i<n.endTime){i+=o.duration;continue}n.endTime+=o.duration}else if("cueOut"in o&&(n=new he.VTTCue(i,i+o.duration,o.cueOut),n.adStartTime=i,n.adEndTime=i+parseFloat(o.cueOut),e.addCue(n)),"cueOutCont"in o){const[u,c]=o.cueOutCont.split("/").map(parseFloat);n=new he.VTTCue(i,i+o.duration,""),n.adStartTime=i-u,n.adEndTime=n.adStartTime+c,e.addCue(n)}i+=o.duration}};class l2{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 YF{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 lD{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=`
`,o=i,u=t;this.start_=o,e.forEach((c,d)=>{const f=this.storage_.get(u),p=o,g=p+c.duration,v=!!(f&&f.segmentSyncInfo&&f.segmentSyncInfo.isAppended),b=new l2({start:p,end:g,appended:v,segmentIndex:d});c.syncInfo=b;let _=o;const S=(c.parts||[]).map((D,R)=>{const L=_,M=_+D.duration,j=!!(f&&f.partsSyncInfo&&f.partsSyncInfo[R]&&f.partsSyncInfo[R].isAppended),V=new l2({start:L,end:M,appended:j,segmentIndex:d,partIndex:R});return _=M,r+=`Media Sequence: ${u}.${R} | Range: ${L} --> ${M} | Appended: ${j}
`,D.syncInfo=V,V});n.set(u,new YF(b,S)),r+=`${nD(c.resolvedUri)} | Media Sequence: ${u} | Range: ${p} --> ${g} | Appended: ${v}
`,u++,o=g}),this.end_=o,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 o=this.storage_.get(n).segmentSyncInfo.start;for(let u=0;u<r;u++){const c=t[u];o-=c.duration}return o}return i}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class u2 extends lD{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 WF=86400,Zy=[{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 o=s.getMediaSequenceSync(r);if(!o||!o.isReliable)return null;const u=o.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,o=null;const u=rx(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],p=f.segment,g=s.timelineToDatetimeMappings[p.timeline];if(!g||!p.dateTimeObject)continue;let b=p.dateTimeObject.getTime()/1e3+g;if(p.parts&&typeof f.partIndex=="number")for(let S=0;S<f.partIndex;S++)b+=p.parts[S].duration;const _=Math.abs(n-b);if(o!==null&&(_===0||o<_))break;o=_,r={time:b,segmentIndex:f.segmentIndex,partIndex:f.partIndex}}return r}},{name:"Segment",run:(s,e,t,i,n)=>{let r=null,o=null;n=n||0;const u=rx(e);for(let c=0;c<u.length;c++){const d=e.endList||n===0?c:u.length-(c+1),f=u[d],p=f.segment,g=f.part&&f.part.start||p&&p.start;if(p.timeline===i&&typeof g<"u"){const v=Math.abs(n-g);if(o!==null&&o<v)break;(!r||o===null||o>=v)&&(o=v,r={time:g,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 o=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 p=Math.abs(n-f.time);if(o!==null&&o<p)break;(!r||o===null||o>=p)&&(o=p,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 XF extends De.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new lD,i=new u2(t),n=new u2(t);this.mediaSequenceStorage_={main:t,audio:i,vtt:n},this.logger_=gr("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,i,n,r){if(t!==1/0)return Zy.find(({name:c})=>c==="VOD").run(this,e,t);const o=this.runStrategies_(e,t,i,n,r);if(!o.length)return null;for(const u of o){const{syncPoint:c,strategy:d}=u,{segmentIndex:f,time:p}=c;if(f<0)continue;const g=e.segments[f],v=p,b=v+g.duration;if(this.logger_(`Strategy: ${d}. Current time: ${n}. selected segment: ${f}. Time: [${v} -> ${b}]}`),n>=v&&n<b)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(o,{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+uh({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,i,n,r){const o=[];for(let u=0;u<Zy.length;u++){const c=Zy[u],d=c.run(this,e,t,i,n,r);d&&(d.strategy=c.name,o.push({strategy:c.name,syncPoint:d}))}return o}selectSyncPoint_(e,t){let i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let o=1;o<e.length;o++){const u=Math.abs(e[o].syncPoint[t.key]-t.value);u<n&&(n=u,i=e[o].syncPoint,r=e[o].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>WF){De.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 o=this.timelines[e.timeline],u,c;if(typeof e.timestampOffset=="number")o={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=o,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${o.time}] [mapping: ${o.mapping}]`)),u=e.startOfSegment,c=t.end+o.mapping;else if(o)u=t.start+o.mapping,c=t.end+o.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],o=t.discontinuitySequence+n+1,u=r-e.mediaIndex,c=Math.abs(u);if(!this.discontinuities[o]||this.discontinuities[o].accuracy>c){let d;u<0?d=i.start-uh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):d=i.end+uh({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[o]={time:d,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class QF extends De.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 ZF=Kk(Yk(function(){var s=(function(){function _(){this.listeners={}}var S=_.prototype;return S.on=function(R,L){this.listeners[R]||(this.listeners[R]=[]),this.listeners[R].push(L)},S.off=function(R,L){if(!this.listeners[R])return!1;var M=this.listeners[R].indexOf(L);return this.listeners[R]=this.listeners[R].slice(0),this.listeners[R].splice(M,1),M>-1},S.trigger=function(R){var L=this.listeners[R];if(L)if(arguments.length===2)for(var M=L.length,j=0;j<M;++j)L[j].call(this,arguments[1]);else for(var V=Array.prototype.slice.call(arguments,1),P=L.length,z=0;z<P;++z)L[z].apply(this,V)},S.dispose=function(){this.listeners={}},S.pipe=function(R){this.on("data",function(L){R.push(L)})},_})();function e(_){return _.subarray(0,_.byteLength-_[_.byteLength-1])}const t=function(){const _=[[[],[],[],[],[]],[[],[],[],[],[]]],S=_[0],D=_[1],R=S[4],L=D[4];let M,j,V;const P=[],z=[];let I,O,W,X,q,ue;for(M=0;M<256;M++)z[(P[M]=M<<1^(M>>7)*283)^M]=M;for(j=V=0;!R[j];j^=I||1,V=z[V]||1)for(X=V^V<<1^V<<2^V<<3^V<<4,X=X>>8^X&255^99,R[j]=X,L[X]=j,W=P[O=P[I=P[j]]],ue=W*16843009^O*65537^I*257^j*16843008,q=P[X]*257^X*16843008,M=0;M<4;M++)S[M][j]=q=q<<24^q>>>8,D[M][X]=ue=ue<<24^ue>>>8;for(M=0;M<5;M++)S[M]=S[M].slice(0),D[M]=D[M].slice(0);return _};let i=null;class n{constructor(S){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 D,R,L;const M=this._tables[0][4],j=this._tables[1],V=S.length;let P=1;if(V!==4&&V!==6&&V!==8)throw new Error("Invalid aes key size");const z=S.slice(0),I=[];for(this._key=[z,I],D=V;D<4*V+28;D++)L=z[D-1],(D%V===0||V===8&&D%V===4)&&(L=M[L>>>24]<<24^M[L>>16&255]<<16^M[L>>8&255]<<8^M[L&255],D%V===0&&(L=L<<8^L>>>24^P<<24,P=P<<1^(P>>7)*283)),z[D]=z[D-V]^L;for(R=0;D;R++,D--)L=z[R&3?D:D-4],D<=4||R<4?I[R]=L:I[R]=j[0][M[L>>>24]]^j[1][M[L>>16&255]]^j[2][M[L>>8&255]]^j[3][M[L&255]]}decrypt(S,D,R,L,M,j){const V=this._key[1];let P=S^V[0],z=L^V[1],I=R^V[2],O=D^V[3],W,X,q;const ue=V.length/4-2;let ie,Y=4;const G=this._tables[1],J=G[0],oe=G[1],ce=G[2],F=G[3],ee=G[4];for(ie=0;ie<ue;ie++)W=J[P>>>24]^oe[z>>16&255]^ce[I>>8&255]^F[O&255]^V[Y],X=J[z>>>24]^oe[I>>16&255]^ce[O>>8&255]^F[P&255]^V[Y+1],q=J[I>>>24]^oe[O>>16&255]^ce[P>>8&255]^F[z&255]^V[Y+2],O=J[O>>>24]^oe[P>>16&255]^ce[z>>8&255]^F[I&255]^V[Y+3],Y+=4,P=W,z=X,I=q;for(ie=0;ie<4;ie++)M[(3&-ie)+j]=ee[P>>>24]<<24^ee[z>>16&255]<<16^ee[I>>8&255]<<8^ee[O&255]^V[Y++],W=P,P=z,z=I,I=O,O=W}}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(S){this.jobs.push(S),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const o=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},u=function(_,S,D){const R=new Int32Array(_.buffer,_.byteOffset,_.byteLength>>2),L=new n(Array.prototype.slice.call(S)),M=new Uint8Array(_.byteLength),j=new Int32Array(M.buffer);let V,P,z,I,O,W,X,q,ue;for(V=D[0],P=D[1],z=D[2],I=D[3],ue=0;ue<R.length;ue+=4)O=o(R[ue]),W=o(R[ue+1]),X=o(R[ue+2]),q=o(R[ue+3]),L.decrypt(O,W,X,q,j,ue),j[ue]=o(j[ue]^V),j[ue+1]=o(j[ue+1]^P),j[ue+2]=o(j[ue+2]^z),j[ue+3]=o(j[ue+3]^I),V=O,P=W,z=X,I=q;return M};class c{constructor(S,D,R,L){const M=c.STEP,j=new Int32Array(S.buffer),V=new Uint8Array(S.byteLength);let P=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(j.subarray(P,P+M),D,R,V)),P=M;P<j.length;P+=M)R=new Uint32Array([o(j[P-4]),o(j[P-3]),o(j[P-2]),o(j[P-1])]),this.asyncStream_.push(this.decryptChunk_(j.subarray(P,P+M),D,R,V));this.asyncStream_.push(function(){L(null,e(V))})}static get STEP(){return 32e3}decryptChunk_(S,D,R,L){return function(){const M=u(S,D,R);L.set(M,S.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 p=f,g=function(S){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(S):S&&S.buffer instanceof ArrayBuffer},v=p.BigInt||Number;v("0x1"),v("0x100"),v("0x10000"),v("0x1000000"),v("0x100000000"),v("0x10000000000"),v("0x1000000000000"),v("0x100000000000000"),v("0x10000000000000000"),(function(){var _=new Uint16Array([65484]),S=new Uint8Array(_.buffer,_.byteOffset,_.byteLength);return S[0]===255?"big":S[0]===204?"little":"unknown"})();const b=function(_){const S={};return Object.keys(_).forEach(D=>{const R=_[D];g(R)?S[D]={bytes:R.buffer,byteOffset:R.byteOffset,byteLength:R.byteLength}:S[D]=R}),S};self.onmessage=function(_){const S=_.data,D=new Uint8Array(S.encrypted.bytes,S.encrypted.byteOffset,S.encrypted.byteLength),R=new Uint32Array(S.key.bytes,S.key.byteOffset,S.key.byteLength/4),L=new Uint32Array(S.iv.bytes,S.iv.byteOffset,S.iv.byteLength/4);new c(D,R,L,function(M,j){self.postMessage(b({source:S.source,decrypted:j}),[j.buffer])})}}));var JF=qk(ZF);const e8=s=>{let e=s.default?"main":"alternative";return s.characteristics&&s.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},uD=(s,e)=>{s.abort(),s.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},gx=(s,e)=>{e.activePlaylistLoader=s,s.load()},t8=(s,e)=>()=>{const{segmentLoaders:{[s]:t,main:i},mediaTypes:{[s]:n}}=e,r=n.activeTrack(),o=n.getActiveGroup(),u=n.activePlaylistLoader,c=n.lastGroup_;if(!(o&&c&&o.id===c.id)&&(n.lastGroup_=o,n.lastTrack_=r,uD(t,n),!(!o||o.isMainPlaylist))){if(!o.playlistLoader){u&&i.resetEverything();return}t.resyncLoader(),gx(o.playlistLoader,n)}},i8=(s,e)=>()=>{const{segmentLoaders:{[s]:t},mediaTypes:{[s]:i}}=e;i.lastGroup_=null,t.abort(),t.pause()},s8=(s,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[s]:i,main:n},mediaTypes:{[s]:r}}=e,o=r.activeTrack(),u=r.getActiveGroup(),c=r.activePlaylistLoader,d=r.lastTrack_;if(!(d&&o&&d.id===o.id)&&(r.lastGroup_=u,r.lastTrack_=o,uD(i,r),!!u)){if(u.isMainPlaylist){if(!o||!d||o.id===d.id)return;const f=e.vhs.playlistController_,p=f.selectPlaylist();if(f.media()===p)return;r.logger_(`track change. Switching main audio from ${d.id} to ${o.id}`),t.pause(),n.resetEverything(),f.fastQualityChange_(p);return}if(s==="AUDIO"){if(!u.playlistLoader){n.setAudio(!0),n.resetEverything();return}i.setAudio(!0),n.setAudio(!1)}if(c===u.playlistLoader){gx(u.playlistLoader,r);return}i.track&&i.track(o),i.resetEverything(),gx(u.playlistLoader,r)}},yp={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:t},excludePlaylist:i}=e,n=t.activeTrack(),r=t.activeGroup(),o=(r.filter(c=>c.default)[0]||r[0]).id,u=t.tracks[o];if(n===u){i({error:{message:"Problem encountered loading the default audio track."}});return}De.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;De.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const i=t.activeTrack();i&&(i.mode="disabled"),t.onTrackChanged()}},c2={AUDIO:(s,e,t)=>{if(!e)return;const{tech:i,requestOptions:n,segmentLoaders:{[s]:r}}=t;e.on("loadedmetadata",()=>{const o=e.media();r.playlist(o,n),(!i.paused()||o.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",yp[s](s,t))},SUBTITLES:(s,e,t)=>{const{tech:i,requestOptions:n,segmentLoaders:{[s]:r},mediaTypes:{[s]:o}}=t;e.on("loadedmetadata",()=>{const u=e.media();r.playlist(u,n),r.track(o.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",yp[s](s,t))}},n8={AUDIO:(s,e)=>{const{vhs:t,sourceType:i,segmentLoaders:{[s]:n},requestOptions:r,main:{mediaGroups:o},mediaTypes:{[s]:{groups:u,tracks:c,logger_:d}},mainPlaylistLoader:f}=e,p=Mh(f.main);(!o[s]||Object.keys(o[s]).length===0)&&(o[s]={main:{default:{default:!0}}},p&&(o[s].main.default.playlists=f.main.playlists));for(const g in o[s]){u[g]||(u[g]=[]);for(const v in o[s][g]){let b=o[s][g][v],_;if(p?(d(`AUDIO group '${g}' label '${v}' is a main playlist`),b.isMainPlaylist=!0,_=null):i==="vhs-json"&&b.playlists?_=new tc(b.playlists[0],t,r):b.resolvedUri?_=new tc(b.resolvedUri,t,r):b.playlists&&i==="dash"?_=new dx(b.playlists[0],t,r,f):_=null,b=Ai({id:v,playlistLoader:_},b),c2[s](s,b.playlistLoader,e),u[g].push(b),typeof c[v]>"u"){const S=new De.AudioTrack({id:v,kind:e8(b),enabled:!1,language:b.language,default:b.default,label:v});c[v]=S}}}n.on("error",yp[s](s,e))},SUBTITLES:(s,e)=>{const{tech:t,vhs:i,sourceType:n,segmentLoaders:{[s]:r},requestOptions:o,main:{mediaGroups:u},mediaTypes:{[s]:{groups:c,tracks:d}},mainPlaylistLoader:f}=e;for(const p in u[s]){c[p]||(c[p]=[]);for(const g in u[s][p]){if(!i.options_.useForcedSubtitles&&u[s][p][g].forced)continue;let v=u[s][p][g],b;if(n==="hls")b=new tc(v.resolvedUri,i,o);else if(n==="dash"){if(!v.playlists.filter(S=>S.excludeUntil!==1/0).length)return;b=new dx(v.playlists[0],i,o,f)}else n==="vhs-json"&&(b=new tc(v.playlists?v.playlists[0]:v.resolvedUri,i,o));if(v=Ai({id:g,playlistLoader:b},v),c2[s](s,v.playlistLoader,e),c[p].push(v),typeof d[g]>"u"){const _=t.addRemoteTextTrack({id:g,kind:"subtitles",default:v.default&&v.autoselect,language:v.language,label:g},!1).track;d[g]=_}}}r.on("error",yp[s](s,e))},"CLOSED-CAPTIONS":(s,e)=>{const{tech:t,main:{mediaGroups:i},mediaTypes:{[s]:{groups:n,tracks:r}}}=e;for(const o in i[s]){n[o]||(n[o]=[]);for(const u in i[s][o]){const c=i[s][o][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=Ai(f,d[f.instreamId])),f.default===void 0&&delete f.default,n[o].push(Ai({id:u},c)),typeof r[u]>"u"){const p=t.addRemoteTextTrack({id:f.instreamId,kind:"captions",default:f.default,language:f.language,label:f.label},!1).track;r[u]=p}}}}},cD=(s,e)=>{for(let t=0;t<s.length;t++)if(Db(e,s[t])||s[t].playlists&&cD(s[t].playlists,e))return!0;return!1},r8=(s,e)=>t=>{const{mainPlaylistLoader:i,mediaTypes:{[s]:{groups:n}}}=e,r=i.media();if(!r)return null;let o=null;r.attributes[s]&&(o=n[r.attributes[s]]);const u=Object.keys(n);if(!o)if(s==="AUDIO"&&u.length>1&&Mh(e.main))for(let c=0;c<u.length;c++){const d=n[u[c]];if(cD(d,r)){o=d;break}}else n.main?o=n.main:u.length===1&&(o=n[u[0]]);return typeof t>"u"?o:t===null||!o?null:o.filter(c=>c.id===t.id)[0]||null},a8={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}},o8=(s,{mediaTypes:e})=>()=>{const t=e[s].activeTrack();return t?e[s].activeGroup(t):null},l8=s=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(d=>{n8[d](d,s)});const{mediaTypes:e,mainPlaylistLoader:t,tech:i,vhs:n,segmentLoaders:{["AUDIO"]:r,main:o}}=s;["AUDIO","SUBTITLES"].forEach(d=>{e[d].activeGroup=r8(d,s),e[d].activeTrack=a8[d](d,s),e[d].onGroupChanged=t8(d,s),e[d].onGroupChanging=i8(d,s),e[d].onTrackChanged=s8(d,s),e[d].getActiveGroup=o8(d,s)});const u=e.AUDIO.activeGroup();if(u){const d=(u.filter(p=>p.default)[0]||u[0]).id;e.AUDIO.tracks[d].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(o.setAudio(!1),r.setAudio(!0)):o.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])},u8=()=>{const s={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{s[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Ka,activeTrack:Ka,getActiveGroup:Ka,onGroupChanged:Ka,onTrackChanged:Ka,lastTrack_:null,logger_:gr(`MediaGroups[${e}]`)}}),s};class d2{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_=On(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 c8=class extends De.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new d2,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_=gr("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=On(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,o)=>{if(r){if(o.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(o.status===429){const d=o.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:De.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 he.URL(e),i=new he.URL(this.proxyServerUrl_);return i.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(i.toString())}decodeDataUriManifest_(e){const t=JSON.parse(he.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new he.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_=he.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){he.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 d2}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&&(On(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}};const d8=(s,e)=>{let t=null;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{s.apply(null,i)},e)}},h8=10;let $o;const f8=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],m8=function(s){return this.audioSegmentLoader_[s]+this.mainSegmentLoader_[s]},p8=function({currentPlaylist:s,buffered:e,currentTime:t,nextPlaylist:i,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:o,bufferBasedABR:u,log:c}){if(!i)return De.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=!!ec(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 p=Ab(e,t),g=u?Vs.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Vs.MAX_BUFFER_LOW_WATER_LINE;if(o<g)return c(`${d} as duration < max low water line (${o} < ${g})`),!0;const v=i.attributes.BANDWIDTH,b=s.attributes.BANDWIDTH;if(v<b&&(!u||p<r)){let _=`${d} as next bandwidth < current bandwidth (${v} < ${b})`;return u&&(_+=` and forwardBuffer < bufferHighWaterLine (${p} < ${r})`),c(_),!0}if((!u||v>b)&&p>=n){let _=`${d} as forwardBuffer >= bufferLowWaterLine (${p} >= ${n})`;return u&&(_+=` and next bandwidth > current bandwidth (${v} > ${b})`),c(_),!0}return c(`not ${d} as no switching criteria met`),!1};class g8 extends De.EventTarget{constructor(e){super(),this.fastQualityChange_=d8(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:i,tech:n,bandwidth:r,externVhs:o,useCueTags:u,playlistExclusionDuration:c,enableLowInitialPlaylist:d,sourceType:f,cacheEncryptionKeys:p,bufferBasedABR:g,leastPixelDiffSelector:v,captionServices:b,experimentalUseMMS:_}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:S}=e;(S===null||typeof S>"u")&&(S=1/0),$o=o,this.bufferBasedABR=!!g,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=S,this.enableLowInitialPlaylist=d,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:S,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=u8(),_&&he.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new he.ManagedMediaSource,this.usingManagedMediaSource_=!0,De.log("Using ManagedMediaSource")):he.MediaSource&&(this.mediaSource=new he.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_=zs(),this.hasPlayed_=!1,this.syncController_=new XF(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new JF,this.sourceUpdater_=new oD(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new QF,this.keyStatusMap_=new Map;const D={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:b,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:p,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new dx(t,this.vhs_,Ai(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new tc(t,this.vhs_,Ai(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new mx(Ai(D,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new mx(Ai(D,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new zF(Ai(D,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((M,j)=>{function V(){n.off("vttjserror",P),M()}function P(){n.off("vttjsloaded",V),j()}n.one("vttjsloaded",V),n.one("vttjserror",P),n.addWebVttScript_()})}),e);const R=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new c8(this.vhs_.xhr,R),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),f8.forEach(M=>{this[M+"_"]=m8.bind(this,M)}),this.logger_=gr("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 L=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(L,()=>{const M=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-M,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),o=e&&(e.id||e.uri);if(r&&r!==o){this.logger_(`switch media ${r} -> ${o} from ${t}`);const u={renditionInfo:{id:o,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 o=(i.length?i[0].playlists:i.playlists).filter(u=>u.attributes.serviceLocation===n);o.length&&this.mediaTypes_[e].activePlaylistLoader.media(o[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=he.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(he.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 o=[];for(const u in i)if(i[u][r.label]){const c=i[u][r.label];if(c.playlists&&c.playlists.length)o.push.apply(o,c.playlists);else if(c.uri)o.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&&o.push(f)}}return o.length?o:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;ax(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()),l8({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;ax(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(Ss({},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 o in i.AUDIO)for(const u in i.AUDIO[o])i.AUDIO[o][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"}),$o.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(),o=this.tech_.buffered();return p8({buffered:o,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:h8}))});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(Ss({},n))}),this.audioSegmentLoader_.on(i,n=>{this.player_.trigger(Ss({},n))}),this.subtitleSegmentLoader_.on(i,n=>{this.player_.trigger(Ss({},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=$o.Playlist.playlistEnd(e,i),r=this.tech_.currentTime(),o=this.tech_.buffered();if(!o.length)return n-r<=aa;const u=o.end(o.length-1);return u-r<=aa&&n-u<=aa}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(lg),o=r.length===1&&r[0]===e;if(n.length===1&&i!==1/0)return De.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(o);if(o){if(this.main().contentSteering){const b=this.pathwayAttribute_(e),_=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(b),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(b)},_);return}let v=!1;n.forEach(b=>{if(b===e)return;const _=b.excludeUntil;typeof _<"u"&&_!==1/0&&(v=!0,delete b.excludeUntil)}),v&&(De.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_:De.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 p=c.targetDuration/2*1e3||5*1e3,g=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=p;return this.switchMedia_(c,"exclude",o||g)}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(o=>{const u=this.mediaTypes_[o]&&this.mediaTypes_[o].activePlaylistLoader;u&&i.push(u)}),["main","audio","subtitle"].forEach(o=>{const u=this[`${o}SegmentLoader_`];u&&(e===o||e==="all")&&i.push(u)}),i.forEach(o=>t.forEach(u=>{typeof o[u]=="function"&&o[u]()}))}setCurrentTime(e){const t=ec(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:$o.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=$o.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i),f=Math.max(u,c-d);return zs([[u,f]])}const r=this.syncController_.getExpiredTime(i,this.duration());if(r===null)return null;const o=$o.Playlist.seekable(i,r,$o.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i));return o.length?o:null}computeFinalSeekable_(e,t){if(!t)return e;const i=e.start(0),n=e.end(0),r=t.start(0),o=t.end(0);return r>n||i>o?e:zs([[Math.max(i,r),Math.min(n,o)]])}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 [${bk(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=$o.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||nP),e.main.isMuxed&&(n.video+=`,${i.audio||e.main.audioCodec||eE}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(n.audio=i.audio||e.main.audioCodec||e.audio.audioCodec||eE,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 o=(d,f)=>d?rh(f,this.usingManagedMediaSource_):Iy(f),u={};let c;if(["video","audio"].forEach(function(d){if(n.hasOwnProperty(d)&&!o(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,p)=>(f&&(f+=", "),f+=`${p} does not support codec(s): "${u[p].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 p=(ea(this.sourceUpdater_.codecs[f]||"")[0]||{}).type,g=(ea(n[f]||"")[0]||{}).type;p&&g&&p.toLowerCase()!==g.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),o=[];r.audio&&!Iy(r.audio)&&!rh(r.audio,this.usingManagedMediaSource_)&&o.push(`audio codec ${r.audio}`),r.video&&!Iy(r.video)&&!rh(r.video,this.usingManagedMediaSource_)&&o.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&o.push(`text codec ${r.text}`),o.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${o.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],i=this.main().playlists,n=xh(ea(e)),r=KE(n),o=n.video&&ea(n.video)[0]||null,u=n.audio&&ea(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=[],p=ch(this.mainPlaylistLoader_.main,d),g=KE(p);if(!(!p.audio&&!p.video)){if(g!==r&&f.push(`codec count "${g}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const v=p.video&&ea(p.video)[0]||null,b=p.audio&&ea(p.audio)[0]||null;v&&o&&v.type.toLowerCase()!==o.type.toLowerCase()&&f.push(`video codec "${v.type}" !== "${o.type}"`),b&&u&&b.type.toLowerCase()!==u.type.toLowerCase()&&f.push(`audio codec "${b.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)),KF(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=Vs.GOAL_BUFFER_LENGTH,i=Vs.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,Vs.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=Vs.BUFFER_LOW_WATER_LINE,i=Vs.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,Vs.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,Vs.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?r:n)}bufferHighWaterLine(){return Vs.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){t2(this.inbandTextTracks_,"com.apple.streaming",this.tech_),AF({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,i){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();t2(this.inbandTextTracks_,e,this.tech_),SF({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(Ss({},i))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const r=this.contentSteeringController_.getAvailablePathways(),o=[];for(const u of t.playlists){const c=u.attributes.serviceLocation;if(c&&(o.push(c),!r.has(c)))return!0}return!!(!o.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(o=>{const u=i[o],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 p=!u.excludeUntil&&u.excludeUntil!==1/0;!n.has(u.id)&&d&&p&&(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(o=>{const u=this.mediaTypes_[o];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[o,u]of i.entries())n.get(o)||(this.mainPlaylistLoader_.updateOrDeleteClone(u),this.contentSteeringController_.excludePathway(o));for(const[o,u]of n.entries()){const c=i.get(o);if(!c){t.filter(f=>f.attributes["PATHWAY-ID"]===u["BASE-ID"]).forEach(f=>{this.mainPlaylistLoader_.addClonePathway(u,f)}),this.contentSteeringController_.addAvailablePathway(o);continue}this.equalPathwayClones_(c,u)||(this.mainPlaylistLoader_.updateOrDeleteClone(u,!0),this.contentSteeringController_.addAvailablePathway(o))}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 o="usable",u=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===o,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 ${o}`)):(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 ${o}`)),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,De.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:VF(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 y8=(s,e,t)=>i=>{const n=s.main.playlists[e],r=kb(n),o=lg(n);if(typeof i>"u")return o;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!==o&&!r&&(i?(t(n),s.trigger({type:"renditionenabled",metadata:u})):s.trigger({type:"renditiondisabled",metadata:u})),i};class v8{constructor(e,t,i){const{playlistController_:n}=e,r=n.fastQualityChange_.bind(n);if(t.attributes){const o=t.attributes.RESOLUTION;this.width=o&&o.width,this.height=o&&o.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=y8(e.playlists,t.id,r)}}const x8=function(s){s.representations=()=>{const e=s.playlistController_.main(),t=Mh(e)?s.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(i=>!kb(i)).map((i,n)=>new v8(s,i,i.id)):[]}},h2=["seeking","seeked","pause","playing","error"];class b8 extends De.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_=gr("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),o=this.playlistController_,u=["main","subtitle","audio"],c={};u.forEach(f=>{c[f]={reset:()=>this.resetSegmentDownloads_(f),updateend:()=>this.checkSegmentDownloads_(f)},o[`${f}SegmentLoader_`].on("appendsdone",c[f].updateend),o[`${f}SegmentLoader_`].on("playlistupdate",c[f].reset),this.tech_.on(["seeked","seeking"],c[f].reset)});const d=f=>{["main","audio"].forEach(p=>{o[`${p}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(h2,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(h2,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=>{o[`${f}SegmentLoader_`].off("appendsdone",c[f].updateend),o[`${f}SegmentLoader_`].off("playlistupdate",c[f].reset),this.tech_.off(["seeked","seeking"],c[f].reset)}),this.checkCurrentTimeTimeout_&&he.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&he.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=he.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=rB(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,r){const o={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:o}),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:zl(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+aa>=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(zs([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 b=t.start(0);r=b+(b===t.end(0)?0:aa)}if(typeof r<"u")return this.logger_(`Trying to seek outside of seekable at time ${i} with seekable range ${bk(t)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;const o=this.playlistController_.sourceUpdater_,u=this.tech_.buffered(),c=o.audioBuffer?o.audioBuffered():null,d=o.videoBuffer?o.videoBuffered():null,f=this.media(),p=f.partTargetDuration?f.partTargetDuration:(f.targetDuration-ra)*2,g=[c,d];for(let b=0;b<g.length;b++){if(!g[b])continue;if(Ab(g[b],i)<p)return!1}const v=fm(u,i);return v.length===0?!1:(r=v.start(0)+aa,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=ec(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 o=fm(n,t);return o.length>0?(this.logger_(`Stopped at ${t} and seeking to ${o.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)+aa;const o=!i.endList,u=typeof i.partTargetDuration=="number";return o&&(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=ec(e,i-3),o=ec(e,i),u=ec(t,i);u.length&&!o.length&&r.length&&(n={start:r.end(0),end:u.end(0)})}else fm(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=fm(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)+ra);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=iB(e);for(let n=0;n<i.length;n++){const r=i.start(n),o=i.end(n);if(t-r<4&&t-r>2)return{start:r,end:o}}return null}}const T8={errorInterval:30,getSource(s){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return s(t)}},dD=function(s,e){let t=0,i=0;const n=Ai(T8,e);s.ready(()=>{s.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){i&&s.currentTime(i)},o=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"){De.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(s,o)},c=function(){s.off("loadedmetadata",r),s.off("error",u),s.off("dispose",c)},d=function(f){c(),dD(s,f)};s.on("error",u),s.on("dispose",c),s.reloadSourceOnError=d},_8=function(s){dD(this,s)};var hD="3.17.2",S8="7.1.0",E8="1.3.1",w8="7.2.0",A8="4.0.2";const us={PlaylistLoader:tc,Playlist:Mn,utils:RB,STANDARD_PLAYLIST_SELECTOR:e2,INITIAL_PLAYLIST_SELECTOR:vF,lastBandwidthSelector:e2,movingAverageBandwidthSelector:gF,comparePlaylistBandwidth:Rb,comparePlaylistResolution:pF,xhr:Uk()};Object.keys(Vs).forEach(s=>{Object.defineProperty(us,s,{get(){return De.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),Vs[s]},set(e){if(De.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){De.log.warn(`value of Vhs.${s} must be greater than or equal to 0`);return}Vs[s]=e}})});const fD="videojs-vhs",mD=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"})},C8=function(s,e){e.representations().forEach(t=>{s.addQualityLevel(t)}),mD(s,e.playlists)};us.canPlaySource=function(){return De.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const k8=(s,e,t)=>{if(!s)return s;let i={};e&&e.attributes&&e.attributes.CODECS&&(i=xh(ea(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(i.audio=t.attributes.CODECS);const n=Tc(i.video),r=Tc(i.audio),o={};for(const u in s)o[u]={},r&&(o[u].audioContentType=r),n&&(o[u].videoContentType=n),e.contentProtection&&e.contentProtection[u]&&e.contentProtection[u].pssh&&(o[u].pssh=e.contentProtection[u].pssh),typeof s[u]=="string"&&(o[u].url=s[u]);return Ai(s,o)},D8=(s,e)=>s.reduce((t,i)=>{if(!i.contentProtection)return t;const n=e.reduce((r,o)=>{const u=i.contentProtection[o];return u&&u.pssh&&(r[o]={pssh:u.pssh}),r},{});return Object.keys(n).length&&t.push(n),t},[]),L8=({player:s,sourceKeySystems:e,audioMedia:t,mainPlaylists:i})=>{if(!s.eme.initializeMediaKeys)return Promise.resolve();const n=t?i.concat([t]):i,r=D8(n,Object.keys(e)),o=[],u=[];return r.forEach(c=>{u.push(new Promise((d,f)=>{s.tech_.one("keysessioncreated",d)})),o.push(new Promise((d,f)=>{s.eme.initializeMediaKeys({keySystems:c},p=>{if(p){f(p);return}d()})}))}),Promise.race([Promise.all(o),Promise.race(u)])},R8=({player:s,sourceKeySystems:e,media:t,audioMedia:i})=>{const n=k8(e,t,i);return n?(s.currentSource().keySystems=n,n&&!s.eme?(De.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},pD=()=>{if(!he.localStorage)return null;const s=he.localStorage.getItem(fD);if(!s)return null;try{return JSON.parse(s)}catch{return null}},I8=s=>{if(!he.localStorage)return!1;let e=pD();e=e?Ai(e,s):s;try{he.localStorage.setItem(fD,JSON.stringify(e))}catch{return!1}return e},N8=s=>s.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(s.substring(s.indexOf(",")+1)):s,gD=(s,e)=>{s._requestCallbackSet||(s._requestCallbackSet=new Set),s._requestCallbackSet.add(e)},yD=(s,e)=>{s._responseCallbackSet||(s._responseCallbackSet=new Set),s._responseCallbackSet.add(e)},vD=(s,e)=>{s._requestCallbackSet&&(s._requestCallbackSet.delete(e),s._requestCallbackSet.size||delete s._requestCallbackSet)},xD=(s,e)=>{s._responseCallbackSet&&(s._responseCallbackSet.delete(e),s._responseCallbackSet.size||delete s._responseCallbackSet)};us.supportsNativeHls=(function(){if(!rt||!rt.createElement)return!1;const s=rt.createElement("video");return De.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})();us.supportsNativeDash=(function(){return!rt||!rt.createElement||!De.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(rt.createElement("video").canPlayType("application/dash+xml"))})();us.supportsTypeNatively=s=>s==="hls"?us.supportsNativeHls:s==="dash"?us.supportsNativeDash:!1;us.isSupported=function(){return De.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};us.xhr.onRequest=function(s){gD(us.xhr,s)};us.xhr.onResponse=function(s){yD(us.xhr,s)};us.xhr.offRequest=function(s){vD(us.xhr,s)};us.xhr.offResponse=function(s){xD(us.xhr,s)};const O8=De.getComponent("Component");class bD extends O8{constructor(e,t,i){if(super(t,i.vhs),typeof i.initialBandwidth=="number"&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=gr("VhsHandler"),t.options_&&t.options_.playerId){const n=De.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(rt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const r=rt.fullscreenElement||rt.webkitFullscreenElement||rt.mozFullScreenElement||rt.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_=Ai(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=pD();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=Vs.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Vs.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=N8(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=us,this.options_.sourceType=$A(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new g8(this.options_);const i=Ai({liveRangeSafeTimeDelta:aa},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new b8(i),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=De.players[this.tech_.options_.playerId];let o=this.playlistController_.error;typeof o=="object"&&!o.code?o.code=3:typeof o=="string"&&(o={message:o,code:3}),r.error(o)});const n=this.options_.bufferBasedABR?us.movingAverageBandwidthSelector(.55):us.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=us.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 o=he.navigator.connection||he.navigator.mozConnection||he.navigator.webkitConnection,u=1e7;if(this.options_.useNetworkInformationApi&&o){const c=o.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 o;return this.throughput>0?o=1/this.throughput:o=0,Math.floor(1/(r+o))},set(){De.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:()=>zl(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:()=>zl(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&&I8({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{x8(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_=he.URL.createObjectURL(this.playlistController_.mediaSource),(De.browser.IS_ANY_SAFARI||De.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"),L8({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=R8({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=De.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{C8(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{mD(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":hD,"mux.js":S8,"mpd-parser":E8,"m3u8-parser":w8,"aes-decrypter":A8}}version(){return this.constructor.version()}canChangeType(){return oD.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_&&he.URL.revokeObjectURL&&(he.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return FB({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,n=2){return Gk({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=>{gD(this.xhr,e)},this.xhr.onResponse=e=>{yD(this.xhr,e)},this.xhr.offRequest=e=>{vD(this.xhr,e)},this.xhr.offResponse=e=>{xD(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(Ss({},n))})}),t.forEach(i=>{this.playbackWatcher_.on(i,n=>{this.player_.trigger(Ss({},n))})})}}const vp={name:"videojs-http-streaming",VERSION:hD,canHandleSource(s,e={}){const t=Ai(De.options,e);return!t.vhs.experimentalUseMMS&&!rh("avc1.4d400d,mp4a.40.2",!1)?!1:vp.canPlayType(s.type,t)},handleSource(s,e,t={}){const i=Ai(De.options,t);return e.vhs=new bD(s,e,i),e.vhs.xhr=Uk(),e.vhs.setupXhrHooks_(),e.vhs.src(s.src,s.type),e.vhs},canPlayType(s,e){const t=$A(s);if(!t)return"";const i=vp.getOverrideNative(e);return!us.supportsTypeNatively(t)||i?"maybe":""},getOverrideNative(s={}){const{vhs:e={}}=s,t=!(De.browser.IS_ANY_SAFARI||De.browser.IS_IOS),{overrideNative:i=t}=e;return i}},M8=()=>rh("avc1.4d400d,mp4a.40.2",!0);M8()&&De.getTech("Html5").registerSourceHandler(vp,0);De.VhsHandler=bD;De.VhsSourceHandler=vp;De.Vhs=us;De.use||De.registerComponent("Vhs",us);De.options.vhs=De.options.vhs||{};(!De.getPlugin||!De.getPlugin("reloadSourceOnError"))&&De.registerPlugin("reloadSourceOnError",_8);const Hl=s=>(s||"").replaceAll("\\","/").split("/").pop()||"",Ib=s=>s.startsWith("HOT ")?s.slice(4):s,P8=s=>(s||"").trim().toLowerCase(),B8=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 o=r.toLowerCase();i.has(o)||(i.add(o),n.push(r))}return n.sort((r,o)=>r.localeCompare(o,void 0,{sensitivity:"base"})),n};function f2(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 F8(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 m2(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 Jy=(...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 U8(s){if(!s||!Number.isFinite(s))return"—";const e=s>=10?0:2;return`${s.toFixed(e)} fps`}function j8(s,e){if(!s||!e)return"—";const t=Math.round(e);return`${s}×${e} (${t}p)`}function $8(s){const e=Hl(s||""),t=Ib(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]),o=Number(n[2]),u=Number(n[3]),c=Number(n[4]),d=Number(n[5]),f=Number(n[6]);return[r,o,u,c,d,f].every(p=>Number.isFinite(p))?new Date(u,r-1,o,c,d,f):null}const H8=s=>{const e=Hl(s||""),t=Ib(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},V8=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 Ua(...s){return s.filter(Boolean).join(" ")}function G8(s){const[e,t]=A.useState(!1);return A.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 z8({job:s,expanded:e,onClose:t,onToggleExpand:i,modelKey:n,modelsByKey:r,isHot:o=!1,isFavorite:u=!1,isLiked:c=!1,isWatching:d=!1,onKeep:f,onDelete:p,onToggleHot:g,onToggleFavorite:v,onToggleLike:b,onToggleWatch:_,onStopJob:S,startMuted:D=rO}){const R=A.useMemo(()=>Hl(s.output?.trim()||"")||s.id,[s.output,s.id]),L=A.useMemo(()=>Hl(s.output?.trim()||""),[s.output]),M=L.startsWith("HOT "),j=A.useMemo(()=>{const de=(n||"").trim();return de||H8(s.output)},[n,s.output]),V=A.useMemo(()=>Ib(L),[L]),P=A.useMemo(()=>{const de=Date.parse(String(s.startedAt||"")),me=Date.parse(String(s.endedAt||""));if(Number.isFinite(de)&&Number.isFinite(me)&&me>de)return f2(me-de);const Pe=s.durationSeconds;return typeof Pe=="number"&&Number.isFinite(Pe)&&Pe>0?f2(Pe*1e3):"—"},[s]),z=A.useMemo(()=>F8(V8(s)),[s]),I=s,O=A.useMemo(()=>{const de=$8(s.output);if(de)return m2(de);const me=I.startedAt??I.endedAt??I.createdAt??I.fileCreatedAt??I.ctime??null,Pe=me?new Date(me):null;return m2(Pe&&Number.isFinite(Pe.getTime())?Pe:null)},[s.output,I.startedAt,I.endedAt,I.createdAt,I.fileCreatedAt,I.ctime]),W=A.useMemo(()=>P8((n||j||"").trim()),[n,j]),X=A.useMemo(()=>{const de=r?.[W];return B8(de?.tags)},[r,W]),q=A.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s.id)}&file=preview.jpg`,[s.id]),ue=A.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s.id)}&file=thumbs.jpg`,[s.id]),[ie,Y]=A.useState(q);A.useEffect(()=>{Y(q)},[q]);const G=A.useMemo(()=>Jy(I.videoWidth,I.width,I.meta?.width),[I.videoWidth,I.width,I.meta?.width]),J=A.useMemo(()=>Jy(I.videoHeight,I.height,I.meta?.height),[I.videoHeight,I.height,I.meta?.height]),oe=A.useMemo(()=>Jy(I.fps,I.frameRate,I.meta?.fps,I.meta?.frameRate),[I.fps,I.frameRate,I.meta?.fps,I.meta?.frameRate]),ce=A.useMemo(()=>j8(G,J),[G,J]),F=A.useMemo(()=>U8(oe),[oe]);A.useEffect(()=>{const de=me=>me.key==="Escape"&&t();return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[t]);const ee=A.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s.id)}&file=index_hq.m3u8`,[s.id]),[pe,_e]=A.useState(s.status!=="running");A.useEffect(()=>{if(s.status!=="running"){_e(!0);return}let de=!0;const me=new AbortController;return _e(!1),(async()=>{for(let it=0;it<100&&de&&!me.signal.aborted;it++){try{if((await fetch(ee,{method:"HEAD",cache:"no-store",signal:me.signal})).status===200){de&&_e(!0);return}}catch{}await new Promise(ft=>setTimeout(ft,600))}})(),()=>{de=!1,me.abort()}},[s.status,ee]);const ve=A.useMemo(()=>{if(s.status==="running")return pe?{src:ee,type:"application/x-mpegURL"}:{src:"",type:"application/x-mpegURL"};const de=Hl(s.output?.trim()||"");return de?{src:`/api/record/video?file=${encodeURIComponent(de)}`,type:"video/mp4"}:{src:`/api/record/video?id=${encodeURIComponent(s.id)}`,type:"video/mp4"}},[s.status,s.output,s.id,pe,ee]),Ce=A.useRef(null),Be=A.useRef(null),tt=A.useRef(null),[Je,Ct]=A.useState(!1),[st,mt]=A.useState(56),[pt,ut]=A.useState(null),Ht=!e,at=G8("(min-width: 640px)"),gt=Ht&&at,Dt="player_window_v1",Nt=420,dt=280,lt=12,ye=320,ze=200;A.useEffect(()=>{if(!Je)return;const de=Be.current;if(!de||de.isDisposed?.())return;const me=de.el();if(!me)return;const Pe=me.querySelector(".vjs-control-bar");if(!Pe)return;const it=()=>{const Ke=Math.round(Pe.getBoundingClientRect().height||0);Ke>0&&mt(Ke)};it();let ft=null;return typeof ResizeObserver<"u"&&(ft=new ResizeObserver(it),ft.observe(Pe)),window.addEventListener("resize",it),()=>{window.removeEventListener("resize",it),ft?.disconnect()}},[Je,e]),A.useEffect(()=>Ct(!0),[]),A.useEffect(()=>{let de=document.getElementById("player-root");de||(de=document.createElement("div"),de.id="player-root");let me=null;if(at){const Pe=Array.from(document.querySelectorAll("dialog[open]"));me=Pe.length?Pe[Pe.length-1]:null}me=me??document.body,me.appendChild(de),de.style.position="relative",de.style.zIndex="2147483647",ut(de)},[at]),A.useLayoutEffect(()=>{if(!Je||!Ce.current||Be.current)return;const de=document.createElement("video");de.className="video-js vjs-big-play-centered w-full h-full",de.setAttribute("playsinline","true"),Ce.current.appendChild(de),tt.current=de;const me=De(de,{autoplay:!0,muted:D,controls:!0,preload:"metadata",playsinline:!0,responsive:!0,fluid:!1,fill:!0,inactivityTimeout:0,controlBar:{skipButtons:{backward:10,forward:10},volumePanel:{inline:!1},children:["skipBackward","playToggle","skipForward","volumePanel","currentTimeDisplay","durationDisplay","timeDivider","progressControl","spacer","playbackRateMenuButton","fullscreenToggle"]},playbackRates:[.5,1,1.25,1.5,2]});return Be.current=me,me.userActive(!0),me.on("userinactive",()=>me.userActive(!0)),()=>{try{Be.current&&(Be.current.dispose(),Be.current=null)}finally{tt.current&&(tt.current.remove(),tt.current=null)}}},[Je,D]),A.useEffect(()=>{if(!Je)return;const de=Be.current;if(!de||de.isDisposed?.())return;const me=de.currentTime()||0;if(de.muted(D),!ve.src)return;de.src({src:ve.src,type:ve.type});const Pe=()=>{const it=de.play?.();it&&typeof it.catch=="function"&&it.catch(()=>{})};de.one("loadedmetadata",()=>{if(!de.isDisposed?.()){try{de.playbackRate(1)}catch{}me>0&&ve.type!=="application/x-mpegURL"&&de.currentTime(me),Pe()}}),Pe()},[Je,ve.src,ve.type,D]),A.useEffect(()=>{if(!Je)return;const de=Be.current;if(!de||de.isDisposed?.())return;const me=()=>{s.status==="running"&&_e(!1)};return de.on("error",me),()=>{try{de.off("error",me)}catch{}}},[Je,s.status]),A.useEffect(()=>{const de=Be.current;!de||de.isDisposed?.()||queueMicrotask(()=>de.trigger("resize"))},[e]);const We=A.useCallback(()=>{const de=Be.current;if(!(!de||de.isDisposed?.())){try{de.pause(),de.reset?.()}catch{}try{de.src({src:"",type:"video/mp4"}),de.load?.()}catch{}}},[]);A.useEffect(()=>{const de=me=>{const it=(me.detail?.file??"").trim();if(!it)return;const ft=Hl(s.output?.trim()||"");ft&&ft===it&&We()};return window.addEventListener("player:release",de),()=>window.removeEventListener("player:release",de)},[s.output,We]),A.useEffect(()=>{const de=me=>{const it=(me.detail?.file??"").trim();if(!it)return;const ft=Hl(s.output?.trim()||"");ft&&ft===it&&(We(),t())};return window.addEventListener("player:close",de),()=>window.removeEventListener("player:close",de)},[s.output,We,t]);const et=()=>{if(typeof window>"u")return{w:0,h:0};const de=window.visualViewport;if(de&&Number.isFinite(de.width)&&Number.isFinite(de.height))return{w:Math.floor(de.width),h:Math.floor(de.height)};const me=document.documentElement;return{w:me?.clientWidth||window.innerWidth,h:me?.clientHeight||window.innerHeight}},ot=A.useCallback((de,me)=>{if(typeof window>"u")return de;const{w:Pe,h:it}=et(),ft=Pe-lt*2,Ke=it-lt*2;let Ve=de.w,Ze=de.h;me&&Number.isFinite(me)&&me>.1?(Ve=Math.max(ye,Ve),Ze=Ve/me,Ze<ze&&(Ze=ze,Ve=Ze*me),Ve>ft&&(Ve=ft,Ze=Ve/me),Ze>Ke&&(Ze=Ke,Ve=Ze*me)):(Ve=Math.max(ye,Math.min(Ve,ft)),Ze=Math.max(ze,Math.min(Ze,Ke)));const _t=Math.max(lt,Math.min(de.x,Pe-Ve-lt)),St=Math.max(lt,Math.min(de.y,it-Ze-lt));return{x:_t,y:St,w:Ve,h:Ze}},[]),nt=A.useCallback(()=>{if(typeof window>"u")return{x:lt,y:lt,w:Nt,h:dt};try{const Ve=window.localStorage.getItem(Dt);if(Ve){const Ze=JSON.parse(Ve);if(typeof Ze.x=="number"&&typeof Ze.y=="number"&&typeof Ze.w=="number"&&typeof Ze.h=="number"){const _t=Ze.w,St=Ze.h,Bt=Ze.x,Ti=Ze.y;return ot({x:Bt,y:Ti,w:_t,h:St},_t/St)}}}catch{}const{w:de,h:me}=et(),Pe=Nt,it=dt,ft=Math.max(lt,de-Pe-lt),Ke=Math.max(lt,me-it-lt);return ot({x:ft,y:Ke,w:Pe,h:it},Pe/it)},[ot]),[vt,Xe]=A.useState(()=>nt()),Ft=gt&&vt.w<380,Gt=A.useCallback(de=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Dt,JSON.stringify(de))}catch{}},[]),wt=A.useRef(vt);A.useEffect(()=>{wt.current=vt},[vt]),A.useEffect(()=>{gt&&Xe(nt())},[gt,nt]),A.useEffect(()=>{if(!gt)return;const de=()=>Xe(me=>ot(me,me.w/me.h));return window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[gt,ot]);const hi=A.useRef(null);A.useEffect(()=>{const de=Be.current;if(!(!de||de.isDisposed?.()))return hi.current!=null&&cancelAnimationFrame(hi.current),hi.current=requestAnimationFrame(()=>{hi.current=null;try{de.trigger("resize")}catch{}}),()=>{hi.current!=null&&(cancelAnimationFrame(hi.current),hi.current=null)}},[gt,vt.w,vt.h]);const[Qe,Lt]=A.useState(!1),[Ut,vi]=A.useState(!1),gi=A.useRef(null),kt=A.useRef(null),ht=A.useRef(null),ri=A.useCallback(de=>{const{w:me,h:Pe}=et(),it=lt,ft=me-de.w-lt,Ke=Pe-de.h-lt,Ze=de.x+de.w/2<me/2;return{...de,x:Ze?it:ft,y:Ke}},[]),Ie=A.useCallback(de=>{const me=ht.current;if(!me)return;const Pe=de.clientX-me.sx,it=de.clientY-me.sy,ft=me.start,Ke=ot({x:ft.x+Pe,y:ft.y+it,w:ft.w,h:ft.h});kt.current={x:Ke.x,y:Ke.y},gi.current==null&&(gi.current=requestAnimationFrame(()=>{gi.current=null;const Ve=kt.current;Ve&&Xe(Ze=>({...Ze,x:Ve.x,y:Ve.y}))}))},[ot]),H=A.useCallback(()=>{ht.current&&(vi(!1),gi.current!=null&&(cancelAnimationFrame(gi.current),gi.current=null),ht.current=null,window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",H),Xe(de=>{const me=ri(ot(de));return queueMicrotask(()=>Gt(me)),me}))},[Ie,ri,ot,Gt]),K=A.useCallback(de=>{if(!gt||Qe||de.button!==0)return;de.preventDefault(),de.stopPropagation();const me=wt.current;ht.current={sx:de.clientX,sy:de.clientY,start:me},vi(!0),window.addEventListener("pointermove",Ie),window.addEventListener("pointerup",H)},[gt,Qe,Ie,H]),re=A.useRef(null),Ee=A.useRef(null),Ye=A.useRef(null),Tt=A.useCallback(de=>{const me=Ye.current;if(!me)return;const Pe=de.clientX-me.sx,it=de.clientY-me.sy,ft=me.ratio,Ke=me.dir.includes("w"),Ve=me.dir.includes("e"),Ze=me.dir.includes("n"),_t=me.dir.includes("s");let St=me.start.w,Bt=me.start.h,Ti=me.start.x,Js=me.start.y;const{w:vs,h:Ls}=et(),Ja=24,eo=me.start.x+me.start.w,xa=me.start.y+me.start.h,Es=Math.abs(vs-lt-eo)<=Ja,su=Math.abs(Ls-lt-xa)<=Ja,Or=qi=>{qi=Math.max(ye,qi);let Ji=qi/ft;return Ji<ze&&(Ji=ze,qi=Ji*ft),{newW:qi,newH:Ji}},un=qi=>{qi=Math.max(ze,qi);let Ji=qi*ft;return Ji<ye&&(Ji=ye,qi=Ji/ft),{newW:Ji,newH:qi}};if((Ve||Ke)&&(Ze||_t)){if(Math.abs(Pe)>=Math.abs(it)){const Ji=Ve?me.start.w+Pe:me.start.w-Pe,{newW:jn,newH:al}=Or(Ji);St=jn,Bt=al}else{const Ji=_t?me.start.h+it:me.start.h-it,{newW:jn,newH:al}=un(Ji);St=jn,Bt=al}Ke&&(Ti=me.start.x+(me.start.w-St)),Ze&&(Js=me.start.y+(me.start.h-Bt))}else if(Ve||Ke){const qi=Ve?me.start.w+Pe:me.start.w-Pe,{newW:Ji,newH:jn}=Or(qi);St=Ji,Bt=jn,Ke&&(Ti=me.start.x+(me.start.w-St)),Js=su?me.start.y+(me.start.h-Bt):me.start.y}else if(Ze||_t){const qi=_t?me.start.h+it:me.start.h-it,{newW:Ji,newH:jn}=un(qi);St=Ji,Bt=jn,Ze&&(Js=me.start.y+(me.start.h-Bt)),Es?Ti=me.start.x+(me.start.w-St):Ti=me.start.x}const vr=ot({x:Ti,y:Js,w:St,h:Bt},ft);Ee.current=vr,re.current==null&&(re.current=requestAnimationFrame(()=>{re.current=null;const qi=Ee.current;qi&&Xe(qi)}))},[ot]),zt=A.useCallback(()=>{Ye.current&&(Lt(!1),re.current!=null&&(cancelAnimationFrame(re.current),re.current=null),Ye.current=null,window.removeEventListener("pointermove",Tt),window.removeEventListener("pointerup",zt),Gt(wt.current))},[Tt,Gt]),xi=A.useCallback(de=>me=>{if(!gt||me.button!==0)return;me.preventDefault(),me.stopPropagation();const Pe=wt.current;Ye.current={dir:de,sx:me.clientX,sy:me.clientY,start:Pe,ratio:Pe.w/Pe.h},Lt(!0),window.addEventListener("pointermove",Tt),window.addEventListener("pointerup",zt)},[gt,Tt,zt]),[Wi,Xi]=A.useState(!1),[rs,Qi]=A.useState(!1);A.useEffect(()=>{const de=window.matchMedia?.("(hover: hover) and (pointer: fine)"),me=()=>Xi(!!de?.matches);return me(),de?.addEventListener?.("change",me),()=>de?.removeEventListener?.("change",me)},[]);const ai=gt&&(rs||Ut||Qe),[Fi,Ui]=A.useState(!1);if(A.useEffect(()=>{s.status!=="running"&&Ui(!1)},[s.id,s.status]),!Je||!pt)return null;const Ei="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",Kt=String(s.phase??"").toLowerCase(),jt=s.status==="running",Ii=Kt==="stopping"||Kt==="remuxing"||Kt==="moving",ds=!S||!jt||Ii||Fi,as=y.jsx("div",{className:"flex items-center gap-1 min-w-0",children:jt?y.jsxs(y.Fragment,{children:[y.jsx(ti,{variant:"primary",color:"red",size:"sm",rounded:"md",disabled:ds,title:Ii||Fi?"Stoppe…":"Stop","aria-label":Ii||Fi?"Stoppe…":"Stop",onClick:async de=>{if(de.preventDefault(),de.stopPropagation(),!ds)try{Ui(!0),await S?.(s.id)}finally{Ui(!1)}},className:Ua("shadow-none shrink-0",Ft&&"px-2"),children:y.jsx("span",{className:"whitespace-nowrap",children:Ii||Fi?"Stoppe…":Ft?"Stop":"Stoppen"})}),y.jsx(da,{job:s,variant:"overlay",collapseToMenu:!0,busy:Ii||Fi,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:_?de=>_(de):void 0,showHot:!1,showKeep:!1,showDelete:!1,onToggleFavorite:v?de=>v(de):void 0,onToggleLike:b?de=>b(de):void 0,order:["watch","favorite","like","details"],className:"gap-1 min-w-0 flex-1"})]}):y.jsx(da,{job:s,variant:"overlay",collapseToMenu:!0,isHot:o||M,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:_?de=>_(de):void 0,onToggleFavorite:v?de=>v(de):void 0,onToggleLike:b?de=>b(de):void 0,onToggleHot:g?async de=>{We(),await new Promise(Pe=>setTimeout(Pe,150)),await g(de),await new Promise(Pe=>setTimeout(Pe,0));const me=Be.current;if(me&&!me.isDisposed?.()){const Pe=me.play?.();Pe&&typeof Pe.catch=="function"&&Pe.catch(()=>{})}}:void 0,onKeep:f?async de=>{We(),t(),await new Promise(me=>setTimeout(me,150)),await f(de)}:void 0,onDelete:p?async de=>{We(),t(),await new Promise(me=>setTimeout(me,150)),await p(de)}:void 0,order:["watch","favorite","like","hot","keep","delete","details"],className:"gap-1 min-w-0 flex-1"})}),Fs=e||gt,fi=`calc(${st}px + env(safe-area-inset-bottom))`,li=`calc(${st+8}px + env(safe-area-inset-bottom))`,ji=gt?"top-4":"top-2",hs=e&&at,Us=y.jsx("div",{className:Ua("relative overflow-visible",e||gt?"flex-1 min-h-0":"aspect-video"),onMouseEnter:()=>{!gt||!Wi||Qi(!0)},onMouseLeave:()=>{!gt||!Wi||Qi(!1)},children:y.jsxs("div",{className:Ua("relative w-full h-full",gt&&"vjs-mini"),children:[y.jsx("div",{ref:Ce,className:"absolute inset-0"}),y.jsx("div",{className:Ua("absolute inset-x-2 z-30",ji),children:y.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-2",children:[y.jsx("div",{className:"min-w-0 pointer-events-auto overflow-visible",children:hs?null:as}),gt?y.jsxs("button",{type:"button","aria-label":"Player-Fenster verschieben",title:"Ziehen zum Verschieben",onPointerDown:K,onClick:de=>{de.preventDefault(),de.stopPropagation()},className:Ua(Ei,"px-3 gap-1 cursor-grab active:cursor-grabbing select-none",ai?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none -translate-y-1",Ut&&"scale-[0.98] opacity-90"),children:[y.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"}),y.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"}),y.jsx("span",{className:"h-1 w-1 rounded-full bg-black/35 dark:bg-white/35"})]}):null,y.jsxs("div",{className:"shrink-0 flex items-center gap-1 pointer-events-auto",children:[y.jsx("button",{type:"button",className:Ei,onClick:i,"aria-label":e?"Minimieren":"Maximieren",title:e?"Minimieren":"Maximieren",children:e?y.jsx(hO,{className:"h-5 w-5"}):y.jsx(mO,{className:"h-5 w-5"})}),y.jsx("button",{type:"button",className:Ei,onClick:t,"aria-label":"Schließen",title:"Schließen",children:y.jsx(qx,{className:"h-5 w-5"})})]})]})}),y.jsx("div",{className:Ua("player-ui pointer-events-none absolute inset-x-0 z-40","bg-gradient-to-t from-black/70 to-transparent","transition-all duration-200 ease-out",e?"h-28":"h-24"),style:{bottom:fi}}),y.jsxs("div",{className:Ua("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:li},children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-white",children:j}),y.jsx("div",{className:"truncate text-[11px] text-white/80",children:V||R})]}),y.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 text-[11px] text-white",children:[y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-semibold",children:s.status}),o||M?y.jsx("span",{className:"rounded bg-amber-500/25 px-1.5 py-0.5 font-semibold text-white",children:"HOT"}):null,y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:P}),z!=="—"?y.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:z}):null]})]})]})}),Q=y.jsx("div",{className:"w-[360px] shrink-0 border-r border-white/10 bg-black/40 text-white",children:y.jsxs("div",{className:"h-full p-4 flex flex-col gap-3 overflow-y-auto",children:[y.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-white/10 bg-black/30",children:y.jsx("div",{className:"relative aspect-video",children:y.jsx("img",{src:ie,alt:"Vorschau",className:"absolute inset-0 h-full w-full object-cover",loading:"lazy",onError:()=>{ie!==ue&&Y(ue)}})})}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("div",{className:"text-lg font-semibold truncate",children:j}),y.jsx("div",{className:"text-xs text-white/70 break-all",children:V||R})]}),y.jsx("div",{className:"pointer-events-auto",children:y.jsxs("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[jt?y.jsx(ti,{variant:"primary",color:"red",size:"sm",rounded:"md",disabled:ds,title:Ii||Fi?"Stoppe…":"Stop","aria-label":Ii||Fi?"Stoppe…":"Stop",onClick:async de=>{if(de.preventDefault(),de.stopPropagation(),!ds)try{Ui(!0),await S?.(s.id)}finally{Ui(!1)}},className:"shadow-none",children:Ii||Fi?"Stoppe…":"Stoppen"}):null,y.jsx(da,{job:s,variant:"table",collapseToMenu:!1,busy:Ii||Fi,isHot:o||M,isFavorite:u,isLiked:c,isWatching:d,onToggleWatch:_?de=>_(de):void 0,onToggleFavorite:v?de=>v(de):void 0,onToggleLike:b?de=>b(de):void 0,onToggleHot:g?async de=>{We(),await new Promise(Pe=>setTimeout(Pe,150)),await g(de),await new Promise(Pe=>setTimeout(Pe,0));const me=Be.current;if(me&&!me.isDisposed?.()){const Pe=me.play?.();Pe&&typeof Pe.catch=="function"&&Pe.catch(()=>{})}}:void 0,onKeep:f?async de=>{We(),t(),await new Promise(me=>setTimeout(me,150)),await f(de)}:void 0,onDelete:p?async de=>{We(),t(),await new Promise(me=>setTimeout(me,150)),await p(de)}:void 0,order:jt?["watch","favorite","like","details"]:["watch","favorite","like","hot","details","keep","delete"],className:"flex items-center justify-start gap-1"})]})}),y.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-2 text-sm",children:[y.jsx("div",{className:"text-white/60",children:"Status"}),y.jsx("div",{className:"font-medium",children:s.status}),y.jsx("div",{className:"text-white/60",children:"Auflösung"}),y.jsx("div",{className:"font-medium",children:ce}),y.jsx("div",{className:"text-white/60",children:"FPS"}),y.jsx("div",{className:"font-medium",children:F}),y.jsx("div",{className:"text-white/60",children:"Laufzeit"}),y.jsx("div",{className:"font-medium",children:P}),y.jsx("div",{className:"text-white/60",children:"Größe"}),y.jsx("div",{className:"font-medium",children:z}),y.jsx("div",{className:"text-white/60",children:"Datum"}),y.jsx("div",{className:"font-medium",children:O}),y.jsx("div",{className:"col-span-2",children:X.length?y.jsx("div",{className:"flex flex-wrap gap-1.5",children:X.map(de=>y.jsx("span",{className:"rounded bg-white/10 px-2 py-0.5 text-xs text-white/90",children:de},de))}):y.jsx("span",{className:"text-white/50",children:"—"})})]})]})}),se=y.jsx(ha,{edgeToEdgeMobile:!0,noBodyPadding:!0,className:Ua("relative flex flex-col shadow-2xl ring-1 ring-black/10 dark:ring-white/10","w-full",Fs?"h-full":"h-[220px] max-h-[40vh]",e?"rounded-2xl":gt?"rounded-lg":"rounded-none"),bodyClassName:"flex flex-col flex-1 min-h-0 p-0",children:y.jsxs("div",{className:"flex flex-1 min-h-0",children:[hs?Q:null,Us]})}),{w:ae,h:xe}=et(),Te={left:16,top:16,width:Math.max(0,ae-32),height:Math.max(0,xe-32)},je=e?Te:gt?{left:vt.x,top:vt.y,width:vt.w,height:vt.h}:void 0;return yc.createPortal(y.jsx(y.Fragment,{children:e||gt?y.jsxs("div",{className:Ua("fixed z-[2147483647]",!Qe&&!Ut&&"transition-[left,top,width,height] duration-300 ease-[cubic-bezier(.2,.9,.2,1)]"),style:{...je,willChange:Qe?"left, top, width, height":void 0},children:[se,gt?y.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[y.jsx("div",{className:"pointer-events-auto absolute -left-1 bottom-2 top-2 w-3 cursor-ew-resize",onPointerDown:xi("w")}),y.jsx("div",{className:"pointer-events-auto absolute -right-1 bottom-2 top-2 w-3 cursor-ew-resize",onPointerDown:xi("e")}),y.jsx("div",{className:"pointer-events-auto absolute left-2 right-2 -top-1 h-3 cursor-ns-resize",onPointerDown:xi("n")}),y.jsx("div",{className:"pointer-events-auto absolute left-2 right-2 -bottom-1 h-3 cursor-ns-resize",onPointerDown:xi("s")}),y.jsx("div",{className:"pointer-events-auto absolute -left-1 -top-1 h-4 w-4 cursor-nwse-resize",onPointerDown:xi("nw")}),y.jsx("div",{className:"pointer-events-auto absolute -right-1 -top-1 h-4 w-4 cursor-nesw-resize",onPointerDown:xi("ne")}),y.jsx("div",{className:"pointer-events-auto absolute -left-1 -bottom-1 h-4 w-4 cursor-nesw-resize",onPointerDown:xi("sw")}),y.jsx("div",{className:"pointer-events-auto absolute -right-1 -bottom-1 h-4 w-4 cursor-nwse-resize",onPointerDown:xi("se")})]}):null]}):y.jsx("div",{className:"fixed z-[2147483647] w-full left-0 right-0 bottom-0 md:left-1/2 md:-translate-x-1/2 pb-[env(safe-area-inset-bottom)] shadow-2xl",children:se})}),pt)}const yt=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},q8=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=K8},K8=Number.MAX_SAFE_INTEGER||9007199254740991;let It=(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})({}),ke=(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})({}),$=(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 oi={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Et={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Gu{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 Y8{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 Gu(e),this.fast_=new Gu(t),this.defaultTTFB_=n,this.ttfb_=new Gu(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Gu(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new Gu(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Gu(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 W8(s,e,t){return(e=Q8(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function Bi(){return Bi=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},Bi.apply(null,arguments)}function p2(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 Li(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?p2(Object(t),!0).forEach(function(i){W8(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):p2(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function X8(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 Q8(s){var e=X8(s,"string");return typeof e=="symbol"?e:e+""}class yr{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=Ko,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 Ko=function(){},Z8={trace:Ko,debug:Ko,log:Ko,warn:Ko,info:Ko,error:Ko};function yx(){return Bi({},Z8)}function J8(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Ko}function g2(s,e,t){return e[s]?e[s].bind(e):J8(s,t)}const vx=yx();function e6(s,e,t){const i=yx();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=g2(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`)}catch{return yx()}n.forEach(r=>{vx[r]=g2(r,s)})}else Bi(vx,i);return i}const Ri=vx;function il(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function t6(s){return typeof self<"u"&&s===self.ManagedMediaSource}function TD(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(o=>i.indexOf(o)===-1)}function ir(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,o="",u=0;for(;u<t;){if(i=s[u++],i===0&&e)return o;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:o+=String.fromCharCode(i);break;case 12:case 13:n=s[u++],o+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[u++],r=s[u++],o+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return o}function Qs(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 _D(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function i6(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ev={exports:{}},y2;function s6(){return y2||(y2=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(c,d,f){if(f=f||{},c=c.trim(),d=d.trim(),!d){if(!f.alwaysNormalize)return c;var p=u.parseURL(c);if(!p)throw new Error("Error trying to parse base URL.");return p.path=u.normalizePath(p.path),u.buildURLFromParts(p)}var g=u.parseURL(d);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return f.alwaysNormalize?(g.path=u.normalizePath(g.path),u.buildURLFromParts(g)):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 b=n.exec(v.path);v.netLoc=b[1],v.path=b[2]}v.netLoc&&!v.path&&(v.path="/");var _={scheme:v.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(_.netLoc=v.netLoc,g.path[0]!=="/"))if(!g.path)_.path=v.path,g.params||(_.params=v.params,g.query||(_.query=v.query));else{var S=v.path,D=S.substring(0,S.lastIndexOf("/")+1)+g.path;_.path=u.normalizePath(D)}return _.path===null&&(_.path=f.alwaysNormalize?u.normalizePath(g.path):g.path),u.buildURLFromParts(_)},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(o,"")).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})()})(ev)),ev.exports}var Nb=s6();class Ob{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 Vi={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class SD{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,r6(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={[Vi.AUDIO]:null,[Vi.VIDEO]:null,[Vi.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 Ob),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Nb.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Vi.AUDIO]=null,e[Vi.VIDEO]=null,e[Vi.AUDIOVIDEO]=null}}function _s(s){return s.sn!=="initSegment"}class tv extends SD{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(yt(e)&&yt(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=yt(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(!yt(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return _s(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,o=!1){const{elementaryStreams:u}=this,c=u[e];if(!c){u[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:o};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 n6 extends SD{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 o=e.enumeratedString("BYTERANGE");o&&this.setByteRange(o,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 ED(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||ED(t,e)}}function r6(s,e){const t=ED(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const v2=Math.pow(2,32)-1,a6=[].push,wD={video:1,audio:2,id3:3,text:4};function Ps(s){return String.fromCharCode.apply(null,s)}function AD(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function qt(s,e){const t=CD(s,e);return t<0?4294967296+t:t}function x2(s,e){let t=qt(s,e);return t*=Math.pow(2,32),t+=qt(s,e+4),t}function CD(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function o6(s){const e=s.byteLength;for(let t=0;t<e;){const i=qt(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 ni(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=qt(s,n),o=Ps(s.subarray(n+4,n+8)),u=r>1?n+r:i;if(o===e[0])if(e.length===1)t.push(s.subarray(n+8,u));else{const c=ni(s.subarray(n+8,u),e.slice(1));c.length&&a6.apply(t,c)}n=u}return t}function l6(s){const e=[],t=s[0];let i=8;const n=qt(s,i);i+=4;let r=0,o=0;t===0?(r=qt(s,i),o=qt(s,i+4),i+=8):(r=x2(s,i),o=x2(s,i+8),i+=16),i+=2;let u=s.length+o;const c=AD(s,i);i+=2;for(let d=0;d<c;d++){let f=i;const p=qt(s,f);f+=4;const g=p&2147483647;if((p&2147483648)>>>31===1)return Ri.warn("SIDX has hierarchical references (not supported)"),null;const b=qt(s,f);f+=4,e.push({referenceSize:g,subsegmentDuration:b,info:{duration:b/n,start:u,end:u+g-1}}),u+=g,f+=4,i=f}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:c,references:e}}function kD(s){const e=[],t=ni(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],o=ni(r,["tkhd"])[0];if(o){let u=o[0];const c=qt(o,u===0?12:20),d=ni(r,["mdia","mdhd"])[0];if(d){u=d[0];const f=qt(d,u===0?12:20),p=ni(r,["mdia","hdlr"])[0];if(p){const g=Ps(p.subarray(8,12)),v={soun:Vi.AUDIO,vide:Vi.VIDEO}[g],b=ni(r,["mdia","minf","stbl","stsd"])[0],_=u6(b);v?(e[c]={timescale:f,type:v,stsd:_},e[v]=Li({timescale:f,id:c},_)):e[c]={timescale:f,type:g,stsd:_}}}}}return ni(s,["moov","mvex","trex"]).forEach(n=>{const r=qt(n,4),o=e[r];o&&(o.default={duration:qt(n,12),flags:qt(n,20)})}),e}function u6(s){const e=s.subarray(8),t=e.subarray(86),i=Ps(e.subarray(4,8));let n=i,r;const o=i==="enca"||i==="encv";if(o){const d=ni(e,[i])[0].subarray(i==="enca"?28:78);ni(d,["sinf"]).forEach(p=>{const g=ni(p,["schm"])[0];if(g){const v=Ps(g.subarray(4,8));if(v==="cbcs"||v==="cenc"){const b=ni(p,["frma"])[0];b&&(n=Ps(b))}}})}const u=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const c=ni(t,["avcC"])[0];c&&c.length>3&&(n+="."+ym(c[1])+ym(c[2])+ym(c[3]),r=gm(u==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=ni(e,[i])[0],d=ni(c.subarray(28),["esds"])[0];if(d&&d.length>7){let f=4;if(d[f++]!==3)break;f=iv(d,f),f+=2;const p=d[f++];if(p&128&&(f+=2),p&64&&(f+=d[f++]),d[f++]!==4)break;f=iv(d,f);const g=d[f++];if(g===64)n+="."+ym(g);else break;if(f+=12,d[f++]!==5)break;f=iv(d,f);const v=d[f++];let b=(v&248)>>3;b===31&&(b+=1+((v&7)<<3)+((d[f]&224)>>5)),n+="."+b}break}case"hvc1":case"hev1":{const c=ni(t,["hvcC"])[0];if(c&&c.length>12){const d=c[1],f=["","A","B","C"][d>>6],p=d&31,g=qt(c,2),v=(d&32)>>5?"H":"L",b=c[12],_=c.subarray(6,12);n+="."+f+p,n+="."+c6(g).toString(16).toUpperCase(),n+="."+v+b;let S="";for(let D=_.length;D--;){const R=_[D];(R||S)&&(S="."+R.toString(16).toUpperCase()+S)}n+=S}r=gm(u=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=gm(n,t)||n;break}case"vp09":{const c=ni(t,["vpcC"])[0];if(c&&c.length>6){const d=c[4],f=c[5],p=c[6]>>4&15;n+="."+Jr(d)+"."+Jr(f)+"."+Jr(p)}break}case"av01":{const c=ni(t,["av1C"])[0];if(c&&c.length>2){const d=c[1]>>>5,f=c[1]&31,p=c[2]>>>7?"H":"M",g=(c[2]&64)>>6,v=(c[2]&32)>>5,b=d===2&&g?v?12:10:g?10:8,_=(c[2]&16)>>4,S=(c[2]&8)>>3,D=(c[2]&4)>>2,R=c[2]&3;n+="."+d+"."+Jr(f)+p+"."+Jr(b)+"."+_+"."+S+D+R+"."+Jr(1)+"."+Jr(1)+"."+Jr(1)+"."+0,r=gm("dav1",t)}break}}return{codec:n,encrypted:o,supplemental:r}}function gm(s,e){const t=ni(e,["dvvC"]),i=t.length?t[0]:ni(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+Jr(n)+"."+Jr(r)}}function c6(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function iv(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function ym(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Jr(s){return(s<10?"0":"")+s}function d6(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&DD(s,(i,n)=>{const r=i.subarray(8,24);r.some(o=>o!==0)||(Ri.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${Qs(r)} -> ${Qs(t)}`),i.set(t,8))})}function h6(s){const e=[];return DD(s,t=>e.push(t.subarray(8,24))),e}function DD(s,e){ni(s,["moov","trak"]).forEach(i=>{const n=ni(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let o=ni(r,["enca"]);const u=o.length>0;u||(o=ni(r,["encv"])),o.forEach(c=>{const d=u?c.subarray(28):c.subarray(78);ni(d,["sinf"]).forEach(p=>{const g=LD(p);g&&e(g,u)})})})}function LD(s){const e=ni(s,["schm"])[0];if(e){const t=Ps(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=ni(s,["schi","tenc"])[0];if(i)return i}}}function f6(s,e,t){const i={},n=ni(s,["moof","traf"]);for(let r=0;r<n.length;r++){const o=n[r],u=ni(o,["tfhd"])[0],c=qt(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],p=ni(o,["tfdt"])[0];if(p){const L=p[0];let M=qt(p,4);L===1&&(M===v2?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(M*=v2+1,M+=qt(p,8))),yt(M)&&(!yt(f.start)||M<f.start)&&(f.start=M)}const g=d.default,v=qt(u,0)|g?.flags;let b=g?.duration||0;v&8&&(v&2?b=qt(u,12):b=qt(u,8));const _=ni(o,["trun"]);let S=f.start||0,D=0,R=b;for(let L=0;L<_.length;L++){const M=_[L],j=qt(M,4),V=f.sampleCount;f.sampleCount+=j;const P=M[3]&1,z=M[3]&4,I=M[2]&1,O=M[2]&2,W=M[2]&4,X=M[2]&8;let q=8,ue=j;for(P&&(q+=4),z&&j&&(!(M[q+1]&1)&&f.keyFrameIndex===void 0&&(f.keyFrameIndex=V),q+=4,I?(R=qt(M,q),q+=4):R=b,O&&(q+=4),X&&(q+=4),S+=R,D+=R,ue--);ue--;)I?(R=qt(M,q),q+=4):R=b,O&&(q+=4),W&&(M[q+1]&1||f.keyFrameIndex===void 0&&(f.keyFrameIndex=f.sampleCount-(ue+1),f.keyFrameStart=S),q+=4),X&&(q+=4),S+=R,D+=R;!D&&b&&(D+=b*j)}f.duration+=D}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,o=0;const u=ni(s,["sidx"]);for(let c=0;c<u.length;c++){const d=l6(u[c]);if(d!=null&&d.references){r=Math.min(r,d.earliestPresentationTime/d.timescale);const f=d.references.reduce((p,g)=>p+g.info.duration||0,0);o=Math.max(o,f+d.earliestPresentationTime/d.timescale)}}o&&yt(o)&&Object.keys(i).forEach(c=>{i[c].duration||(i[c].duration=o*i[c].timescale-i[c].start)})}return i}function m6(s){const e={valid:null,remainder:null},t=ni(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 mr(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function b2(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let o=!1;return ni(i,["moof"]).map(c=>{const d=c.byteOffset-8;ni(c,["traf"]).map(p=>{const g=ni(p,["tfdt"]).map(v=>{const b=v[0];let _=qt(v,4);return b===1&&(_*=Math.pow(2,32),_+=qt(v,8)),_/n})[0];return g!==void 0&&(s=g),ni(p,["tfhd"]).map(v=>{const b=qt(v,4),_=qt(v,0)&16777215,S=(_&1)!==0,D=(_&2)!==0,R=(_&8)!==0;let L=0;const M=(_&16)!==0;let j=0;const V=(_&32)!==0;let P=8;b===r&&(S&&(P+=8),D&&(P+=4),R&&(L=qt(v,P),P+=4),M&&(j=qt(v,P),P+=4),V&&(P+=4),e.type==="video"&&(o=ug(e.codec)),ni(p,["trun"]).map(z=>{const I=z[0],O=qt(z,0)&16777215,W=(O&1)!==0;let X=0;const q=(O&4)!==0,ue=(O&256)!==0;let ie=0;const Y=(O&512)!==0;let G=0;const J=(O&1024)!==0,oe=(O&2048)!==0;let ce=0;const F=qt(z,4);let ee=8;W&&(X=qt(z,ee),ee+=4),q&&(ee+=4);let pe=X+d;for(let _e=0;_e<F;_e++){if(ue?(ie=qt(z,ee),ee+=4):ie=L,Y?(G=qt(z,ee),ee+=4):G=j,J&&(ee+=4),oe&&(I===0?ce=qt(z,ee):ce=CD(z,ee),ee+=4),e.type===Vi.VIDEO){let ve=0;for(;ve<G;){const Ce=qt(i,pe);if(pe+=4,p6(o,i[pe])){const Be=i.subarray(pe,pe+Ce);Mb(Be,o?2:1,s+ce/n,t)}pe+=Ce,ve+=Ce+4}}s+=ie/n}}))})})}),t}function ug(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function p6(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Mb(s,e,t,i){const n=RD(s);let r=0;r+=e;let o=0,u=0,c=0;for(;r<n.length;){o=0;do{if(r>=n.length)break;c=n[r++],o+=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){Ri.error(`Malformed SEI payload. ${u} is too small, only ${d} bytes left to parse.`);break}if(o===4){if(n[f++]===181){const g=AD(n,f);if(f+=2,g===49){const v=qt(n,f);if(f+=4,v===1195456820){const b=n[f++];if(b===3){const _=n[f++],S=31&_,D=64&_,R=D?2+S*3:0,L=new Uint8Array(R);if(D){L[0]=_;for(let M=1;M<R;M++)L[M]=n[f++]}i.push({type:b,payloadType:o,pts:t,bytes:L})}}}}}else if(o===5&&u>16){const p=[];for(let b=0;b<16;b++){const _=n[f++].toString(16);p.push(_.length==1?"0"+_:_),(b===3||b===5||b===7||b===9)&&p.push("-")}const g=u-16,v=new Uint8Array(g);for(let b=0;b<g;b++)v[b]=n[f++];i.push({payloadType:o,pts:t,uuid:p.join(""),userData:ir(v),userDataBytes:v})}}}function RD(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 o=0;for(i=0;i<n;o++,i++)o===t[0]&&(o++,t.shift()),r[i]=s[o];return r}function g6(s){const e=s[0];let t="",i="",n=0,r=0,o=0,u=0,c=0,d=0;if(e===0){for(;Ps(s.subarray(d,d+1))!=="\0";)t+=Ps(s.subarray(d,d+1)),d+=1;for(t+=Ps(s.subarray(d,d+1)),d+=1;Ps(s.subarray(d,d+1))!=="\0";)i+=Ps(s.subarray(d,d+1)),d+=1;i+=Ps(s.subarray(d,d+1)),d+=1,n=qt(s,12),r=qt(s,16),u=qt(s,20),c=qt(s,24),d=28}else if(e===1){d+=4,n=qt(s,d),d+=4;const p=qt(s,d);d+=4;const g=qt(s,d);for(d+=4,o=2**32*p+g,q8(o)||(o=Number.MAX_SAFE_INTEGER,Ri.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=qt(s,d),d+=4,c=qt(s,d),d+=4;Ps(s.subarray(d,d+1))!=="\0";)t+=Ps(s.subarray(d,d+1)),d+=1;for(t+=Ps(s.subarray(d,d+1)),d+=1;Ps(s.subarray(d,d+1))!=="\0";)i+=Ps(s.subarray(d,d+1)),d+=1;i+=Ps(s.subarray(d,d+1)),d+=1}const f=s.subarray(d,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:o,presentationTimeDelta:r,eventDuration:u,id:c,payload:f}}function y6(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 v6(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 o=new Uint8Array(4);return t.byteLength>0&&new DataView(o.buffer).setUint32(0,t.byteLength,!1),y6([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,o,t)}function x6(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=b6(n);e.push(r),i+=r.size}}return e}function b6(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 o=s.buffer,u=Qs(new Uint8Array(o,t+12,16));let c=null,d=null,f=0;if(r===0)f=28;else{const g=s.getUint32(28);if(!g||i<32+g*16)return{offset:t,size:e};c=[];for(let v=0;v<g;v++)c.push(new Uint8Array(o,t+32+v*16,16));f=32+g*16}if(!f)return{offset:t,size:e};const p=s.getUint32(f);return e-32<p?{offset:t,size:e}:(d=new Uint8Array(o,t+f+4,p),{version:r,systemId:u,kids:c,data:d,offset:t,size:e})}const ID=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Lc={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 Pb(s,e){const t=Lc[e];return!!t&&!!t[s.slice(0,4)]}function bh(s,e,t=!0){return!s.split(",").some(i=>!Bb(i,e,t))}function Bb(s,e,t=!0){var i;const n=il(t);return(i=n?.isTypeSupported(Th(s,e)))!=null?i:!1}function Th(s,e){return`${e}/mp4;codecs=${s}`}function T2(s){if(s){const e=s.substring(0,4);return Lc.video[e]}return 2}function xp(s){const e=ID();return s.split(",").reduce((t,i)=>{const r=e&&ug(i)?9:Lc.video[i];return r?(r*2+t)/(t?3:2):(Lc.audio[i]+t)/(t?2:1)},0)}const sv={};function T6(s,e=!0){if(sv[s])return sv[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(Bb(t[n],"audio",e))return sv[s]=t[n],t[n];if(t[n]==="mp3"&&(i=il(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const _6=/flac|opus|mp4a\.40\.34/i;function bp(s,e=!0){return s.replace(_6,t=>T6(t.toLowerCase(),e))}function S6(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)Pb(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function Bm(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(_2(s,"audio")||_2(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 _2(s,e){return Pb(s,e)&&Bb(s,e)}function E6(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 w6(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 S2(s){const e=il(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 xx(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const A6={supported:!0,powerEfficient:!0,smooth:!0},C6={supported:!1,smooth:!1,powerEfficient:!1},ND={supported:!0,configurations:[],decodingInfoResults:[A6]};function OD(s,e){return{supported:!1,configurations:e,decodingInfoResults:[C6],error:s}}function k6(s,e,t,i,n,r){const o=s.videoCodec,u=s.audioCodec?s.audioGroups:null,c=r?.audioCodec,d=r?.channels,f=d?parseInt(d):c?1/0:2;let p=null;if(u!=null&&u.length)try{u.length===1&&u[0]?p=e.groups[u[0]].channels:p=u.reduce((g,v)=>{if(v){const b=e.groups[v];if(!b)throw new Error(`Audio track group ${v} not found`);Object.keys(b.channels).forEach(_=>{g[_]=(g[_]||0)+b.channels[_]})}return g},{2:0})}catch{return!0}return o!==void 0&&(o.split(",").some(g=>ug(g))||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))||!!p&&yt(f)&&Object.keys(p).some(g=>parseInt(g)>f)}function MD(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(ND);const r=[],o=D6(s),u=o.length,c=L6(s,e,u>0),d=c.length;for(let f=u||1*d||1;f--;){const p={type:"media-source"};if(u&&(p.video=o[f%u]),d){p.audio=c[f%d];const g=p.audio.bitrate;p.video&&g&&(p.video.bitrate-=g)}r.push(p)}if(n){const f=navigator.userAgent;if(n.split(",").some(p=>ug(p))&&ID())return Promise.resolve(OD(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${f})`),r))}return Promise.all(r.map(f=>{const p=I6(f);return i[p]||(i[p]=t.decodingInfo(f))})).then(f=>({supported:!f.some(p=>!p.supported),configurations:r,decodingInfoResults:f})).catch(f=>({supported:!1,configurations:r,decodingInfoResults:[],error:f}))}function D6(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=PD(s),n=s.width||640,r=s.height||480,o=s.frameRate||30,u=s.videoRange.toLowerCase();return t?t.map(c=>{const d={contentType:Th(w6(c),"video"),width:n,height:r,bitrate:i,framerate:o};return u!=="sdr"&&(d.transferFunction=u),d}):[]}function L6(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=PD(s);return n&&s.audioGroups?s.audioGroups.reduce((o,u)=>{var c;const d=u?(c=e.groups[u])==null?void 0:c.tracks:null;return d?d.reduce((f,p)=>{if(p.groupId===u){const g=parseFloat(p.channels||"");n.forEach(v=>{const b={contentType:Th(v,"audio"),bitrate:t?R6(v,r):r};g&&(b.channels=""+g),f.push(b)})}return f},o):o},[]):[]}function R6(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 PD(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function I6(s){let e="";const{audio:t,video:i}=s;if(i){const n=xx(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=xx(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const bx=["NONE","TYPE-0","TYPE-1",null];function N6(s){return bx.indexOf(s)>-1}const Tp=["SDR","PQ","HLG"];function O6(s){return!!s&&Tp.indexOf(s)>-1}var Fm={No:"",Yes:"YES",v2:"v2"};function E2(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?Fm.v2:Fm.Yes:Fm.No}class w2{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 A2(this._audioGroups,e)}hasSubtitleGroup(e){return A2(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 A2(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function M6(){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 P6(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||Tp.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&M6(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const B6=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}},zi=(s,e)=>JSON.stringify(s,B6(e));function F6(s,e,t,i,n){const r=Object.keys(s),o=i?.channels,u=i?.audioCodec,c=n?.videoCodec,d=o&&parseInt(o)===2;let f=!1,p=!1,g=1/0,v=1/0,b=1/0,_=1/0,S=0,D=[];const{preferHDR:R,allowedVideoRanges:L}=P6(e,n);for(let z=r.length;z--;){const I=s[r[z]];f||(f=I.channels[2]>0),g=Math.min(g,I.minHeight),v=Math.min(v,I.minFramerate),b=Math.min(b,I.minBitrate),L.filter(W=>I.videoRanges[W]>0).length>0&&(p=!0)}g=yt(g)?g:0,v=yt(v)?v:0;const M=Math.max(1080,g),j=Math.max(30,v);b=yt(b)?b:t,t=Math.max(b,t),p||(e=void 0);const V=r.length>1;return{codecSet:r.reduce((z,I)=>{const O=s[I];if(I===z)return z;if(D=p?L.filter(W=>O.videoRanges[W]>0):[],V){if(O.minBitrate>t)return Xr(I,`min bitrate of ${O.minBitrate} > current estimate of ${t}`),z;if(!O.hasDefaultAudio)return Xr(I,"no renditions with default or auto-select sound found"),z;if(u&&I.indexOf(u.substring(0,4))%5!==0)return Xr(I,`audio codec preference "${u}" not found`),z;if(o&&!d){if(!O.channels[o])return Xr(I,`no renditions with ${o} channel sound found (channels options: ${Object.keys(O.channels)})`),z}else if((!u||d)&&f&&O.channels[2]===0)return Xr(I,"no renditions with stereo sound found"),z;if(O.minHeight>M)return Xr(I,`min resolution of ${O.minHeight} > maximum of ${M}`),z;if(O.minFramerate>j)return Xr(I,`min framerate of ${O.minFramerate} > maximum of ${j}`),z;if(!D.some(W=>O.videoRanges[W]>0))return Xr(I,`no variants with VIDEO-RANGE of ${zi(D)} found`),z;if(c&&I.indexOf(c.substring(0,4))%5!==0)return Xr(I,`video codec preference "${c}" not found`),z;if(O.maxScore<S)return Xr(I,`max score of ${O.maxScore} < selected max of ${S}`),z}return z&&(xp(I)>=xp(z)||O.fragmentError>s[z].fragmentError)?z:(_=O.minIndex,S=O.maxScore,I)},void 0),videoRanges:D,preferHDR:R,minFramerate:v,minBitrate:b,minIndex:_}}function Xr(s,e){Ri.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function BD(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 U6(s,e,t,i){return s.slice(t,i+1).reduce((n,r,o)=>{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:o,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,o),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 p=e.groups[f];p&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?p.hasDefault:p.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(p.channels).forEach(g=>{c.channels[g]=(c.channels[g]||0)+p.channels[g]}))}),n},{})}function C2(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 la(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(Ql(s,n,t))return i}return-1}function Ql(s,e,t){const{groupId:i,name:n,lang:r,assocLang:o,default:u}=s,c=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||j6(r,e.lang))&&(r===void 0||e.assocLang===o)&&(u===void 0||e.default===u)&&(c===void 0||e.forced===c)&&(!("characteristics"in s)||$6(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function j6(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function $6(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function Fl(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 H6(s,e,t,i,n){const r=e[i],u=e.reduce((g,v,b)=>{const _=v.uri;return(g[_]||(g[_]=[])).push(b),g},{})[r.uri];u.length>1&&(i=Math.max.apply(Math,u));const c=r.videoRange,d=r.frameRate,f=r.codecSet.substring(0,4),p=k2(e,i,g=>{if(g.videoRange!==c||g.frameRate!==d||g.codecSet.substring(0,4)!==f)return!1;const v=g.audioGroups,b=t.filter(_=>!v||v.indexOf(_.groupId)!==-1);return la(s,b,n)>-1});return p>-1?p:k2(e,i,g=>{const v=g.audioGroups,b=t.filter(_=>!v||v.indexOf(_.groupId)!==-1);return la(s,b,n)>-1})}function k2(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 _p(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class V6 extends yr{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:o}=this,{autoLevelEnabled:u,media:c}=o;if(!n||!c)return;const d=performance.now(),f=r?r.stats:n.stats,p=r?r.duration:n.duration,g=d-f.loading.start,v=o.minAutoLevel,b=n.level,_=this._nextAutoLevel;if(f.aborted||f.loaded&&f.loaded===f.total||b<=v){this.clearTimer(),this._nextAutoLevel=-1;return}if(!u)return;const S=_>-1&&_!==b,D=!!t||S;if(!D&&(c.paused||!c.playbackRate||!c.readyState))return;const R=o.mainForwardBufferInfo;if(!D&&R===null)return;const L=this.bwEstimator.getEstimateTTFB(),M=Math.abs(c.playbackRate);if(g<=Math.max(L,1e3*(p/(M*2))))return;const j=R?R.len/M:0,V=f.loading.first?f.loading.first-f.loading.start:-1,P=f.loaded&&V>-1,z=this.getBwEstimate(),I=o.levels,O=I[b],W=Math.max(f.loaded,Math.round(p*(n.bitrate||O.averageBitrate)/8));let X=P?g-V:g;X<1&&P&&(X=Math.min(g,f.loaded*8/z));const q=P?f.loaded*1e3/X:0,ue=L/1e3,ie=q?(W-f.loaded)/q:W*8/z+ue;if(ie<=j)return;const Y=q?q*8:z,G=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,J=this.hls.config.abrBandWidthUpFactor;let oe=Number.POSITIVE_INFINITY,ce;for(ce=b-1;ce>v;ce--){const _e=I[ce].maxBitrate,ve=!I[ce].details||G;if(oe=this.getTimeToLoadFrag(ue,Y,p*_e,ve),oe<Math.min(j,p+ue))break}if(oe>=ie||oe>p*10)return;P?this.bwEstimator.sample(g-Math.min(L,V),f.loaded):this.bwEstimator.sampleTTFB(g);const F=I[ce].maxBitrate;this.getBwEstimate()*J>F&&this.resetEstimator(F);const ee=this.findBestLevel(F,v,ce,0,j,1,1);ee>-1&&(ce=ee),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${b} is loading too slowly;
Fragment duration: ${n.duration.toFixed(3)}
Time to underbuffer: ${j.toFixed(3)} s
Estimated load time for current fragment: ${ie.toFixed(3)} s
Estimated load time for down switch fragment: ${oe.toFixed(3)} s
TTFB estimate: ${V|0} ms
Current BW estimate: ${yt(z)?z|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${ce} @ ${F|0} bps`),o.nextLoadLevel=o.nextAutoLevel=ce,this.clearTimer();const pe=()=>{if(this.clearTimer(),this.fragCurrent===n&&this.hls.loadLevel===ce&&ce>0){const _e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${ce>0?"and switching down":""}
Fragment duration: ${n.duration.toFixed(3)} s
Time to underbuffer: ${_e.toFixed(3)} s`),n.abortRequests(),this.fragCurrent=this.partCurrent=null,ce>v){let ve=this.findBestLevel(this.hls.levels[v].bitrate,v,ce,0,_e,1,1);ve===-1&&(ve=v),this.hls.nextLoadLevel=this.hls.nextAutoLevel=ve,this.resetEstimator(this.hls.levels[ve].bitrate)}}};S||ie>oe*2?pe():this.timer=self.setInterval(pe,oe*1e3),o.trigger($.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 Y8(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.FRAG_LOADING,this.onFragLoading,this),e.on($.FRAG_LOADED,this.onFragLoaded,this),e.on($.FRAG_BUFFERED,this.onFragBuffered,this),e.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($.LEVEL_LOADED,this.onLevelLoaded,this),e.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.FRAG_LOADING,this.onFragLoading,this),e.off($.FRAG_LOADED,this.onFragLoaded,this),e.off($.FRAG_BUFFERED,this.onFragBuffered,this),e.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($.LEVEL_LOADED,this.onLevelLoaded,this),e.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off($.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 ke.BUFFER_ADD_CODEC_ERROR:case ke.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case ke.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:n,partCurrent:r}=this;if(i&&n&&i.sn===n.sn&&i.level===n.level){const o=performance.now(),u=r?r.stats:i.stats,c=o-u.loading.start,d=u.loading.first?u.loading.first-u.loading.start:-1;if(u.loaded&&d>-1){const p=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(p,d),u.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,i,n){const r=e+i/t,o=n?e+this.lastLevelLoadSec:0;return r+o}onLevelLoaded(e,t){const i=this.hls.config,{loading:n}=t.stats,r=n.end-n.first;yt(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===Et.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,o=this.hls.levels[t.level],u=(o.loaded?o.loaded.bytes:0)+n.loaded,c=(o.loaded?o.loaded.duration:0)+r;o.loaded={bytes:u,duration:c},o.realBitrate=Math.round(8*u/c)}if(t.bitrateTest){const r={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered($.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 o=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Et.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 o=this.hls.firstLevel,u=Math.min(Math.max(o,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} 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 o=this.hls.levels;if(o.length>Math.max(e,r)&&o[e].loadError<=o[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:o}=i,u=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),d=this.getStarvationDelay();let f=r.abrBandWidthFactor,p=r.abrBandWidthUpFactor;if(d){const S=this.findBestLevel(c,o,n,d,0,f,p);if(S>=0)return this.rebufferNotice=-1,S}let g=u?Math.min(u,r.maxStarvationDelay):r.maxStarvationDelay;if(!d){const S=this.bitrateTestDelay;S&&(g=(u?Math.min(u,r.maxLoadingDelay):r.maxLoadingDelay)-S,this.info(`bitrate test took ${Math.round(1e3*S)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),f=p=1)}const v=this.findBestLevel(c,o,n,d,g,f,p);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${v}`)),v>-1)return v;const b=i.levels[o],_=i.loadLevelObj;return _&&b?.bitrate<_.bitrate?o: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,o,u){var c;const d=n+r,f=this.lastLoadedFragLevel,p=f===-1?this.hls.firstLevel:f,{fragCurrent:g,partCurrent:v}=this,{levels:b,allAudioTracks:_,loadLevel:S,config:D}=this.hls;if(b.length===1)return 0;const R=b[p],L=!!((c=this.hls.latestLevelDetails)!=null&&c.live),M=S===-1||f===-1;let j,V="SDR",P=R?.frameRate||0;const{audioPreference:z,videoPreference:I}=D,O=this.audioTracksByGroup||(this.audioTracksByGroup=BD(_));let W=-1;if(M){if(this.firstSelection!==-1)return this.firstSelection;const Y=this.codecTiers||(this.codecTiers=U6(b,O,t,i)),G=F6(Y,V,e,z,I),{codecSet:J,videoRanges:oe,minFramerate:ce,minBitrate:F,minIndex:ee,preferHDR:pe}=G;W=ee,j=J,V=pe?oe[oe.length-1]:oe[0],P=ce,e=Math.max(e,F),this.log(`picked start tier ${zi(G)}`)}else j=R?.codecSet,V=R?.videoRange;const X=v?v.duration:g?g.duration:0,q=this.bwEstimator.getEstimateTTFB()/1e3,ue=[];for(let Y=i;Y>=t;Y--){var ie;const G=b[Y],J=Y>p;if(!G)continue;if(D.useMediaCapabilities&&!G.supportedResult&&!G.supportedPromise){const ve=navigator.mediaCapabilities;typeof ve?.decodingInfo=="function"&&k6(G,O,V,P,e,z)?(G.supportedPromise=MD(G,O,ve,this.supportedCache),G.supportedPromise.then(Ce=>{if(!this.hls)return;G.supportedResult=Ce;const Be=this.hls.levels,tt=Be.indexOf(G);Ce.error?this.warn(`MediaCapabilities decodingInfo error: "${Ce.error}" for level ${tt} ${zi(Ce)}`):Ce.supported?Ce.decodingInfoResults.some(Je=>Je.smooth===!1||Je.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${tt} not smooth or powerEfficient: ${zi(Ce)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${tt} ${zi(Ce)}`),tt>-1&&Be.length>1&&(this.log(`Removing unsupported level ${tt}`),this.hls.removeLevel(tt),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Ce=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Ce}`)})):G.supportedResult=ND}if((j&&G.codecSet!==j||V&&G.videoRange!==V||J&&P>G.frameRate||!J&&P>0&&P<G.frameRate||(ie=G.supportedResult)!=null&&(ie=ie.decodingInfoResults)!=null&&ie.some(ve=>ve.smooth===!1))&&(!M||Y!==W)){ue.push(Y);continue}const oe=G.details,ce=(v?oe?.partTarget:oe?.averagetargetduration)||X;let F;J?F=u*e:F=o*e;const ee=X&&n>=X*2&&r===0?G.averageBitrate:G.maxBitrate,pe=this.getTimeToLoadFrag(q,F,ee*ce,oe===void 0);if(F>=ee&&(Y===f||G.loadError===0&&G.fragmentError===0)&&(pe<=q||!yt(pe)||L&&!this.bitrateTestDelay||pe<d)){const ve=this.forcedAutoLevel;return Y!==S&&(ve===-1||ve!==S)&&(ue.length&&this.trace(`Skipped level(s) ${ue.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${b[ue[0]].codecs}" ${b[ue[0]].videoRange}; not compatible with "${j}" ${V}`),this.info(`switch candidate:${p}->${Y} adjustedbw(${Math.round(F)})-bitrate=${Math.round(F-ee)} ttfb:${q.toFixed(1)} avgDuration:${ce.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${pe.toFixed(1)} firstSelection:${M} codecSet:${G.codecSet} videoRange:${G.videoRange} hls.loadLevel:${S}`)),M&&(this.firstSelection=Y),Y}}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 FD={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 o=e(r);if(o>0)t=n+1;else if(o<0)i=n-1;else return r}return null}};function G6(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!yt(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 o=s[r];if(q6(e,t,o))return o}return null}function tu(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)&&D2(t,i,r)===0||z6(r,s,Math.min(n,i))))return r;const o=FD.search(e,D2.bind(null,t,i));return o&&(o!==s||!r)?o:r}function z6(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 D2(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 q6(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function UD(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 FD.search(i,o=>o.cc<e?1:o.cc>e?-1:(r=o,o.end<=t?1:o.start>t?-1:0)),r||null}return null}function Sp(s){switch(s.details){case ke.FRAG_LOAD_TIMEOUT:case ke.KEY_LOAD_TIMEOUT:case ke.LEVEL_LOAD_TIMEOUT:case ke.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function jD(s){return s.details.startsWith("key")}function $D(s){return jD(s)&&!!s.frag&&!s.frag.decryptdata}function L2(s,e){const t=Sp(e);return s.default[`${t?"timeout":"error"}Retry`]}function Fb(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function R2(s){return Li(Li({},s),{errorRetry:null,timeoutRetry:null})}function Ep(s,e,t,i){if(!s)return!1;const n=i?.code,r=e<s.maxNumRetry&&(K6(n)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,r):r}function K6(s){return Tx(s)||!!s&&(s<400||s>499)}function Tx(s){return s===0&&navigator.onLine===!1}var Ws={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Zn={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class Y6 extends yr{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($.ERROR,this.onError,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off($.ERROR,this.onError,this),e.off($.ERROR,this.onErrorOut,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===Et.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(o=>n.indexOf(o.groupId)>=0).some(o=>{var u;return(u=o.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 ke.FRAG_LOAD_ERROR:case ke.FRAG_LOAD_TIMEOUT:case ke.KEY_LOAD_ERROR:case ke.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case ke.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=fc();return}case ke.FRAG_GAP:case ke.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ws.SendAlternateToPenaltyBox;return}case ke.LEVEL_EMPTY_ERROR:case ke.LEVEL_PARSING_ERROR:{var o;const c=t.parent===Et.MAIN?t.level:n.loadLevel;t.details===ke.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(o=o.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case ke.LEVEL_LOAD_ERROR:case ke.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case ke.AUDIO_TRACK_LOAD_ERROR:case ke.AUDIO_TRACK_LOAD_TIMEOUT:case ke.SUBTITLE_LOAD_ERROR:case ke.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const c=n.loadLevelObj;if(c&&(r.type===oi.AUDIO_TRACK&&c.hasAudioGroup(r.groupId)||r.type===oi.SUBTITLE_TRACK&&c.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Ws.SendAlternateToPenaltyBox,t.errorAction.flags=Zn.MoveAllAlternatesMatchingHost;return}}return;case ke.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Ws.SendAlternateToPenaltyBox,flags:Zn.MoveAllAlternatesMatchingHDCP};return;case ke.KEY_SYSTEM_SESSION_UPDATE_FAILED:case ke.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case ke.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Ws.SendAlternateToPenaltyBox,flags:Zn.MoveAllAlternatesMatchingKey};return;case ke.BUFFER_ADD_CODEC_ERROR:case ke.REMUX_ALLOC_ERROR:case ke.BUFFER_APPEND_ERROR:if(!t.errorAction){var u;t.errorAction=this.getLevelSwitchAction(t,(u=t.level)!=null?u:n.loadLevel)}return;case ke.INTERNAL_EXCEPTION:case ke.BUFFER_APPENDING_ERROR:case ke.BUFFER_FULL_ERROR:case ke.LEVEL_SWITCH_ERROR:case ke.BUFFER_STALLED_ERROR:case ke.BUFFER_SEEK_OVER_HOLE:case ke.BUFFER_NUDGE_ON_STALL:t.errorAction=fc();return}t.type===It.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=fc())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,n=L2(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(Ep(n,r,Sp(e),e.response))return{action:Ws.RetryRequest,flags:Zn.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:o}=t.config,u=L2(jD(e)?o:r,e),c=t.levels.reduce((f,p)=>f+p.fragmentError,0);if(n&&(e.details!==ke.FRAG_GAP&&n.fragmentError++,!$D(e)&&Ep(u,c,Sp(e),e.response)))return{action:Ws.RetryRequest,flags:Zn.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,o;const d=e.details;n.loadError++,d===ke.BUFFER_APPEND_ERROR&&n.fragmentError++;let f=-1;const{levels:p,loadLevel:g,minAutoLevel:v,maxAutoLevel:b}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const _=(r=e.frag)==null?void 0:r.type,D=(_===Et.AUDIO&&d===ke.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===ke.BUFFER_ADD_CODEC_ERROR||d===ke.BUFFER_APPEND_ERROR))&&p.some(({audioCodec:V})=>n.audioCodec!==V),L=e.sourceBufferName==="video"&&(d===ke.BUFFER_ADD_CODEC_ERROR||d===ke.BUFFER_APPEND_ERROR)&&p.some(({codecSet:V,audioCodec:P})=>n.codecSet!==V&&n.audioCodec===P),{type:M,groupId:j}=(o=e.context)!=null?o:{};for(let V=p.length;V--;){const P=(V+g)%p.length;if(P!==g&&P>=v&&P<=b&&p[P].loadError===0){var u,c;const z=p[P];if(d===ke.FRAG_GAP&&_===Et.MAIN&&e.frag){const I=p[P].details;if(I){const O=tu(e.frag,I.fragments,e.frag.start);if(O!=null&&O.gap)continue}}else{if(M===oi.AUDIO_TRACK&&z.hasAudioGroup(j)||M===oi.SUBTITLE_TRACK&&z.hasSubtitleGroup(j))continue;if(_===Et.AUDIO&&(u=n.audioGroups)!=null&&u.some(I=>z.hasAudioGroup(I))||_===Et.SUBTITLE&&(c=n.subtitleGroups)!=null&&c.some(I=>z.hasSubtitleGroup(I))||D&&n.audioCodec===z.audioCodec||L&&n.codecSet===z.codecSet||!D&&n.codecSet!==z.codecSet)continue}f=P;break}}if(f>-1&&i.loadLevel!==f)return e.levelRetry=!0,this.playlistError=0,{action:Ws.SendAlternateToPenaltyBox,flags:Zn.None,nextAutoLevel:f}}return{action:Ws.SendAlternateToPenaltyBox,flags:Zn.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ws.DoNothing:break;case Ws.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==ke.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 Zn.None:this.switchLevel(e,r);break;case Zn.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=bx[bx.indexOf(f)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Zn.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const d=this.hls.levels,f=d.length;for(let g=f;g--;)if(this.variantHasKey(d[g],c)){var o,u;this.log(`Banned key found in level ${g} (${d[g].bitrate}bps) or audio group "${(o=d[g].audioGroups)==null?void 0:o.join(",")}" (${(u=e.frag)==null?void 0:u.type} fragment) ${Qs(c.keyId||[])}`),d[g].fragmentError++,d[g].loadError++,this.log(`Removing level ${g} with key error (${e.error})`),this.hls.removeLevel(g)}const p=e.frag;if(this.hls.levels.length<f)i.resolved=!0;else if(p&&p.type!==Et.MAIN){const g=p.decryptdata;g&&!c.matches(g)&&(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===ke.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=xx(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 fc(s){const e={action:Ws.DoNothing,flags:Zn.None};return s&&(e.resolved=!0),e}var Bs={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class W6{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($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.BUFFER_APPENDED,this.onBufferAppended,this),e.on($.FRAG_BUFFERED,this.onFragBuffered,this),e.on($.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.BUFFER_APPENDED,this.onBufferAppended,this),e.off($.FRAG_BUFFERED,this.onFragBuffered,this),e.off($.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.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 o=r.length;o--;){const u=n[r[o]];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 o=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(u=>{const c=this.fragments[u];if(!c||o>=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 p=!this.isTimeBuffered(f.startPTS,f.endPTS,t);return p&&this.removeFragment(c.body),p})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,n=zu(i),r=this.fragments[n];if(!r||r.buffered&&i.gap)return;const o=!i.relurl;Object.keys(t).forEach(u=>{const c=i.elementaryStreams[u];if(!c)return;const d=t[u],f=o||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),vm(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]=I2(i,n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=zu(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},o=e.start,u=e.end,c=e.minEndPTS||u,d=e.maxStartPTS||o;for(let f=0;f<n.length;f++){const p=n.start(f)-this.bufferPadding,g=n.end(f)+this.bufferPadding;if(d>=p&&c<=g){r.time.push({startPTS:Math.max(o,n.start(f)),endPTS:Math.min(u,n.end(f))});break}else if(o<g&&u>p){const v=Math.max(o,n.start(f)),b=Math.min(u,n.end(f));b>v&&(r.partial=!0,r.time.push({startPTS:v,endPTS:b}))}else if(u<=p)break}return r}getPartialFragment(e){let t=null,i,n,r,o=0;const{bufferPadding:u,fragments:c}=this;return Object.keys(c).forEach(d=>{const f=c[d];f&&vm(f)&&(n=f.body.start-u,r=f.body.end+u,e>=n&&e<=r&&(i=Math.min(e-n,r-e),o<=i&&(t=f.body,o=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||vm(t))}getState(e){const t=zu(e),i=this.fragments[t];return i?i.buffered?vm(i)?Bs.PARTIAL:Bs.OK:Bs.APPENDING:Bs.NOT_LOADED}isTimeBuffered(e,t,i){let n,r;for(let o=0;o<i.length;o++){if(n=i.start(o)-this.bufferPadding,r=i.end(o)+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=zu(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:o}=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[o];this.detectEvictedFragments(o,c,u,n)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=zu(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(o=>{const u=this.fragments[o];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=zu(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=I2(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 vm(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 zu(s){return`${s.type}_${s.level}_${s.sn}`}function I2(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var sl={cbc:0,ctr:1};class X6{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 sl.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case sl.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 Q6(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class Z6{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],o=i[2],u=i[3],c=this.invSubMix,d=c[0],f=c[1],p=c[2],g=c[3],v=new Uint32Array(256);let b=0,_=0,S=0;for(S=0;S<256;S++)S<128?v[S]=S<<1:v[S]=S<<1^283;for(S=0;S<256;S++){let D=_^_<<1^_<<2^_<<3^_<<4;D=D>>>8^D&255^99,e[b]=D,t[D]=b;const R=v[b],L=v[R],M=v[L];let j=v[D]*257^D*16843008;n[b]=j<<24|j>>>8,r[b]=j<<16|j>>>16,o[b]=j<<8|j>>>24,u[b]=j,j=M*16843009^L*65537^R*257^b*16843008,d[D]=j<<24|j>>>8,f[D]=j<<16|j>>>16,p[D]=j<<8|j>>>24,g[D]=j,b?(b=R^v[v[v[M^R]]],_^=v[v[_]]):b=_=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 o=this.ksRows=(r+6+1)*4;let u,c;const d=this.keySchedule=new Uint32Array(o),f=this.invKeySchedule=new Uint32Array(o),p=this.sBox,g=this.rcon,v=this.invSubMix,b=v[0],_=v[1],S=v[2],D=v[3];let R,L;for(u=0;u<o;u++){if(u<r){R=d[u]=t[u];continue}L=R,u%r===0?(L=L<<8|L>>>24,L=p[L>>>24]<<24|p[L>>>16&255]<<16|p[L>>>8&255]<<8|p[L&255],L^=g[u/r|0]<<24):r>6&&u%r===4&&(L=p[L>>>24]<<24|p[L>>>16&255]<<16|p[L>>>8&255]<<8|p[L&255]),d[u]=R=(d[u-r]^L)>>>0}for(c=0;c<o;c++)u=o-c,c&3?L=d[u]:L=d[u-4],c<4||u<=4?f[c]=L:f[c]=b[p[L>>>24]]^_[p[L>>>16&255]]^S[p[L>>>8&255]]^D[p[L&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,o=this.invSBox,u=this.invSubMix,c=u[0],d=u[1],f=u[2],p=u[3],g=this.uint8ArrayToUint32Array_(i);let v=g[0],b=g[1],_=g[2],S=g[3];const D=new Int32Array(e),R=new Int32Array(D.length);let L,M,j,V,P,z,I,O,W,X,q,ue,ie,Y;const G=this.networkToHostOrderSwap;for(;t<D.length;){for(W=G(D[t]),X=G(D[t+1]),q=G(D[t+2]),ue=G(D[t+3]),P=W^r[0],z=ue^r[1],I=q^r[2],O=X^r[3],ie=4,Y=1;Y<n;Y++)L=c[P>>>24]^d[z>>16&255]^f[I>>8&255]^p[O&255]^r[ie],M=c[z>>>24]^d[I>>16&255]^f[O>>8&255]^p[P&255]^r[ie+1],j=c[I>>>24]^d[O>>16&255]^f[P>>8&255]^p[z&255]^r[ie+2],V=c[O>>>24]^d[P>>16&255]^f[z>>8&255]^p[I&255]^r[ie+3],P=L,z=M,I=j,O=V,ie=ie+4;L=o[P>>>24]<<24^o[z>>16&255]<<16^o[I>>8&255]<<8^o[O&255]^r[ie],M=o[z>>>24]<<24^o[I>>16&255]<<16^o[O>>8&255]<<8^o[P&255]^r[ie+1],j=o[I>>>24]<<24^o[O>>16&255]<<16^o[P>>8&255]<<8^o[z&255]^r[ie+2],V=o[O>>>24]<<24^o[P>>16&255]<<16^o[z>>8&255]<<8^o[I&255]^r[ie+3],R[t]=G(L^v),R[t+1]=G(V^b),R[t+2]=G(j^_),R[t+3]=G(M^S),v=W,b=X,_=q,S=ue,t=t+4}return R.buffer}}class J6{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=eU(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function eU(s){switch(s){case sl.cbc:return"AES-CBC";case sl.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const tU=16;class Ub{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?Q6(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,o)=>{const u=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(u,t,i,n);const c=this.flush();c?r(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}softwareDecrypt(e,t,i,n){const{currentIV:r,currentResult:o,remainderData:u}=this;if(n!==sl.cbc||t.byteLength!==16)return Ri.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),u&&(e=mr(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 Z6),d.expandKey(t);const f=o;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 J6(this.subtle,t,n)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new X6(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(Ri.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 o=this.flush();if(o)return o.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%tU;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Ri.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const N2=Math.pow(2,17);class iU{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 Va({type:It.NETWORK_ERROR,details:ke.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,o=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(b=>b[0]==="GAP")){c(M2(e));return}else e.gap=!1;const d=this.loader=r?new r(n):new o(n),f=O2(e);e.loader=d;const p=R2(n.fragLoadPolicy.default),g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:N2};e.stats=d.stats;const v={onSuccess:(b,_,S,D)=>{this.resetLoader(e,d);let R=b.data;S.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),u({frag:e,part:null,payload:R,networkDetails:D})},onError:(b,_,S,D)=>{this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Li({url:i,data:void 0},b),error:new Error(`HTTP Error ${b.code} ${b.text}`),networkDetails:S,stats:D}))},onAbort:(b,_,S)=>{this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:S,stats:b}))},onTimeout:(b,_,S)=>{this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:S,stats:b}))}};t&&(v.onProgress=(b,_,S,D)=>t({frag:e,part:null,payload:S,networkDetails:D})),d.load(f,g,v)})}loadPart(e,t,i){this.abort();const n=this.config,r=n.fLoader,o=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(M2(e,t));return}const d=this.loader=r?new r(n):new o(n),f=O2(e,t);e.loader=d;const p=R2(n.fragLoadPolicy.default),g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:N2};t.stats=d.stats,d.load(f,g,{onSuccess:(v,b,_,S)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const D={frag:e,part:t,payload:v.data,networkDetails:S};i(D),u(D)},onError:(v,b,_,S)=>{this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Li({url:f.url,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:_,stats:S}))},onAbort:(v,b,_)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:_,stats:v}))},onTimeout:(v,b,_)=>{this.resetLoader(e,d),c(new Va({type:It.NETWORK_ERROR,details:ke.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:_,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),p=(c-d)*Math.round(i.loaded/d);i.total=i.loaded+p}else i.total=Math.max(i.loaded,i.total);const o=i.loading,u=n.loading;o.start?o.first+=u.first-u.start:(o.start=u.start,o.first=u.first),o.end=u.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function O2(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(yt(n)&&yt(r)){var o;let u=n,c=r;if(s.sn==="initSegment"&&sU((o=s.decryptdata)==null?void 0:o.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 M2(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:It.MEDIA_ERROR,details:ke.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new Va(i)}function sU(s){return s==="AES-128"||s==="AES-256"}class Va extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class HD extends yr{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 jb{constructor(e,t,i,n=0,r=-1,o=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=xm(),this.buffering={audio:xm(),video:xm(),audiovideo:xm()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=r,this.partial=o}}function xm(){return{start:0,executeStart:0,executeEnd:0,end:0}}const P2={length:0,start:()=>0,end:()=>0};class Xt{static isBuffered(e,t){if(e){const i=Xt.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=Xt.getBuffered(e);return Xt.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=Xt.bufferedRanges(e);if(n.length)return Xt.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,p)=>f.start-p.start||p.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 p=r.length;if(p){const g=r[p-1].end;e[f].start-g<i?e[f].end>g&&(r[p-1].end=e[f].end):r.push(e[f])}else r.push(e[f])}else r=e;let o=0,u,c=t,d=t;for(let f=0;f<r.length;f++){const p=r[f].start,g=r[f].end;if(n===-1&&t>=p&&t<=g&&(n=f),t+i>=p&&t<g)c=p,d=g,o=d-t;else if(t+i<p){u=p;break}}return{len:o,start:c||0,end:d||0,nextStart:u,buffered:e,bufferedIndex:n}}static getBuffered(e){try{return e.buffered||P2}catch(t){return Ri.log("failed to get media.buffered",t),P2}}}const VD=/\{\$([a-zA-Z0-9-_]+)\}/g;function B2(s){return VD.test(s)}function _x(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(VD,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 F2(s,e,t){let i=s.variableList;i||(s.variableList=i={});let n,r;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const o=new self.URL(t).searchParams;if(o.has(n))r=o.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(o){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${o.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 nU(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 rU=/^(\d+)x(\d+)$/,U2=/(.+?)=(".*?"|.*?)(?:,|$)/g;class os{constructor(e,t){typeof e=="string"&&(e=os.parseAttrList(e,t)),Bi(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=rU.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(U2.lastIndex=0;(i=U2.exec(e))!==null;){const o=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(o){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(t&&(c||d))u=_x(t,u);else if(!d&&!c)switch(o){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":Ri.warn(`${e}: attribute ${o} is missing quotes`)}n[o]=u}return n}}const aU="com.apple.hls.interstitial";function oU(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function lU(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class GD{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 o in r)if(Object.prototype.hasOwnProperty.call(e,o)&&e[o]!==r[o]){Ri.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=o;break}e=Bi(new os({}),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"]);yt(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?(Ri.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(yt(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===aU}get isValid(){return!!this.id&&!this._badValueForSameId&&yt(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 uU=10;class cU{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?yt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||uU}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 wp(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function j2(s,e){return!s&&!e?!0:!s||!e?!1:wp(s,e)}function mc(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function $b(s){switch(s){case"AES-128":case"AES-256":return sl.cbc;case"AES-256-CTR":return sl.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Hb(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Sx(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function dU(s){const e=Sx(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function zD(s){const e=function(i,n,r){const o=i[n];i[n]=i[r],i[r]=o};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function qD(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",o=n[1];r?(i.splice(-1,1),t=Hb(o)):t=dU(o)}}return t}const Ap=typeof self<"u"?self:void 0;var ls={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zs={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Um(s){switch(s){case Zs.FAIRPLAY:return ls.FAIRPLAY;case Zs.PLAYREADY:return ls.PLAYREADY;case Zs.WIDEVINE:return ls.WIDEVINE;case Zs.CLEARKEY:return ls.CLEARKEY}}function nv(s){switch(s){case ls.FAIRPLAY:return Zs.FAIRPLAY;case ls.PLAYREADY:return Zs.PLAYREADY;case ls.WIDEVINE:return Zs.WIDEVINE;case ls.CLEARKEY:return Zs.CLEARKEY}}function eh(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[ls.FAIRPLAY,ls.WIDEVINE,ls.PLAYREADY,ls.CLEARKEY].filter(n=>!!e[n]):[];return!i[ls.WIDEVINE]&&t&&i.push(ls.WIDEVINE),i}const KD=(function(s){return Ap!=null&&(s=Ap.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function hU(s,e,t,i){let n;switch(s){case ls.FAIRPLAY:n=["cenc","sinf"];break;case ls.WIDEVINE:case ls.PLAYREADY:n=["cenc"];break;case ls.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return fU(n,e,t,i)}function fU(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 mU(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function YD(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),o=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(o){const u=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(u){const c=Hb(u).subarray(0,16);return zD(c),c}}return null}let qu={};class Jo{static clearKeyUriToKeyIdMap(){qu={}}static setKeyIdForUri(e,t){qu[e]=t}static addKeyIdForUri(e){const t=Object.keys(qu).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),qu[e]=i,i}constructor(e,t,i,n=[1],r=null,o){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&&!mc(e),o!=null&&o.startsWith("0x")&&(this.keyId=new Uint8Array(_D(o)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&wp(e.keyFormatVersions,this.keyFormatVersions)&&j2(e.iv,this.iv)&&j2(e.keyId,this.keyId)}isSupported(){if(this.method){if(mc(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Zs.FAIRPLAY:case Zs.WIDEVINE:case Zs.PLAYREADY:case Zs.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(mc(this.method)){let r=this.iv;return r||(typeof e!="number"&&(Ri.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),r=gU(e)),new Jo(this.method,this.uri,"identity",this.keyFormatVersions,r)}if(this.keyId){const r=qu[this.uri];if(r&&!wp(this.keyId,r)&&Jo.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=qD(this.uri);if(i)switch(this.keyFormat){case Zs.WIDEVINE:if(this.pssh=i,!this.keyId){const r=x6(i.buffer);if(r.length){var n;const o=r[0];this.keyId=(n=o.kids)!=null&&n.length?o.kids[0]:null}}this.keyId||(this.keyId=$2(t));break;case Zs.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=v6(r,null,i),this.keyId=YD(i);break}default:{let r=i.subarray(0,16);if(r.length!==16){const o=new Uint8Array(16);o.set(r,16-r.length),r=o}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r;r=pU(t),r||(r=$2(t),r||(r=qu[this.uri])),r&&(this.keyId=r,Jo.setKeyIdForUri(this.uri,r))}return this}}function pU(s){const e=s?.[Zs.WIDEVINE];return e?e.keyId:null}function $2(s){const e=s?.[Zs.PLAYREADY];if(e){const t=qD(e.uri);if(t)return YD(t)}return null}function gU(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const H2=/#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,V2=/#EXT-X-MEDIA:(.*)/g,yU=/^#EXT(?:INF|-X-TARGETDURATION):/m,rv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),vU=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 ua{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 Nb.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return yU.test(e)}static parseMasterPlaylist(e,t){const i=B2(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];if(H2.lastIndex=0,!e.startsWith("#EXTM3U"))return n.playlistParsingError=new Error("no EXTM3U delimiter"),n;let o;for(;(o=H2.exec(e))!=null;)if(o[1]){var u;const d=new os(o[1],n),f=_x(n,o[2]),p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:ua.resolve(f,t)},g=d.decimalResolution("RESOLUTION");g&&(p.width=g.width,p.height=g.height),q2(d.CODECS,p);const v=d["SUPPLEMENTAL-CODECS"];v&&(p.supplemental={},q2(v,p.supplemental)),(u=p.unknownCodecs)!=null&&u.length||r.push(p),n.levels.push(p)}else if(o[3]){const d=o[3],f=o[4];switch(d){case"SESSION-DATA":{const p=new os(f,n),g=p["DATA-ID"];g&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[g]=p);break}case"SESSION-KEY":{const p=G2(f,t,n);p.encrypted&&p.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(p)):Ri.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${f}"`);break}case"DEFINE":{{const p=new os(f,n);F2(n,p,t)}break}case"CONTENT-STEERING":{const p=new os(f,n);n.contentSteering={uri:ua.resolve(p["SERVER-URI"],t),pathwayId:p["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=z2(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={},o=i.levels,u={AUDIO:o.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:o.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(V2.lastIndex=0;(n=V2.exec(e))!==null;){const d=new os(n[1],i),f=d.TYPE;if(f){const p=u[f],g=r[f]||[];r[f]=g;const v=d.LANGUAGE,b=d["ASSOC-LANGUAGE"],_=d.CHANNELS,S=d.CHARACTERISTICS,D=d["INSTREAM-ID"],R={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?ua.resolve(d.URI,t):""};if(b&&(R.assocLang=b),_&&(R.channels=_),S&&(R.characteristics=S),D&&(R.instreamId=D),p!=null&&p.length){const L=ua.findGroup(p,R.groupId)||p[0];K2(R,L,"audioCodec"),K2(R,L,"textCodec")}g.push(R)}}return r}static parseLevelPlaylist(e,t,i,n,r,o){var u;const c={url:t},d=new cU(t),f=d.fragments,p=[];let g=null,v=0,b=0,_=0,S=0,D=0,R=null,L=new tv(n,c),M,j,V,P=-1,z=!1,I=null,O;if(rv.lastIndex=0,d.m3u8=e,d.hasVariableRefs=B2(e),((u=rv.exec(e))==null?void 0:u[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(M=rv.exec(e))!==null;){z&&(z=!1,L=new tv(n,c),L.playlistOffset=_,L.setStart(_),L.sn=v,L.cc=S,D&&(L.bitrate=D),L.level=i,g&&(L.initSegment=g,g.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),I&&(L.setByteRange(I),I=null)));const ue=M[1];if(ue){L.duration=parseFloat(ue);const ie=(" "+M[2]).slice(1);L.title=ie||null,L.tagList.push(ie?["INF",ue,ie]:["INF",ue])}else if(M[3]){if(yt(L.duration)){L.playlistOffset=_,L.setStart(_),V&&W2(L,V,d),L.sn=v,L.level=i,L.cc=S,f.push(L);const ie=(" "+M[3]).slice(1);L.relurl=_x(d,ie),Ex(L,R,p),R=L,_+=L.duration,v++,b=0,z=!0}}else{if(M=M[0].match(vU),!M){Ri.warn("No matches on slow regex match for level playlist!");continue}for(j=1;j<M.length&&M[j]===void 0;j++);const ie=(" "+M[j]).slice(1),Y=(" "+M[j+1]).slice(1),G=M[j+2]?(" "+M[j+2]).slice(1):null;switch(ie){case"BYTERANGE":R?L.setByteRange(Y,R):L.setByteRange(Y);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=Y,L.tagList.push(["PROGRAM-DATE-TIME",Y]),P===-1&&(P=f.length);break;case"PLAYLIST-TYPE":d.type&&ja(d,ie,M),d.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":d.startSN!==0?ja(d,ie,M):f.length>0&&X2(d,ie,M),v=d.startSN=parseInt(Y);break;case"SKIP":{d.skippedSegments&&ja(d,ie,M);const J=new os(Y,d),oe=J.decimalInteger("SKIPPED-SEGMENTS");if(yt(oe)){d.skippedSegments+=oe;for(let F=oe;F--;)f.push(null);v+=oe}const ce=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");ce&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(ce.split(" ")));break}case"TARGETDURATION":d.targetduration!==0&&ja(d,ie,M),d.targetduration=Math.max(parseInt(Y),1);break;case"VERSION":d.version!==null&&ja(d,ie,M),d.version=parseInt(Y);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":d.live||ja(d,ie,M),d.live=!1;break;case"#":(Y||G)&&L.tagList.push(G?[Y,G]:[Y]);break;case"DISCONTINUITY":S++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([ie]);break;case"BITRATE":L.tagList.push([ie,Y]),D=parseInt(Y)*1e3,yt(D)?L.bitrate=D:D=0;break;case"DATERANGE":{const J=new os(Y,d),oe=new GD(J,d.dateRanges[J.ID],d.dateRangeTagCount);d.dateRangeTagCount++,oe.isValid||d.skippedSegments?d.dateRanges[oe.id]=oe:Ri.warn(`Ignoring invalid DATERANGE tag: "${Y}"`),L.tagList.push(["EXT-X-DATERANGE",Y]);break}case"DEFINE":{{const J=new os(Y,d);"IMPORT"in J?nU(d,J,o):F2(d,J,t)}break}case"DISCONTINUITY-SEQUENCE":d.startCC!==0?ja(d,ie,M):f.length>0&&X2(d,ie,M),d.startCC=S=parseInt(Y);break;case"KEY":{const J=G2(Y,t,d);if(J.isSupported()){if(J.method==="NONE"){V=void 0;break}V||(V={});const oe=V[J.keyFormat];oe!=null&&oe.matches(J)||(oe&&(V=Bi({},V)),V[J.keyFormat]=J)}else Ri.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${Y}"`);break}case"START":d.startTimeOffset=z2(Y);break;case"MAP":{const J=new os(Y,d);if(L.duration){const oe=new tv(n,c);Y2(oe,J,i,V),g=oe,L.initSegment=g,g.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime)}else{const oe=L.byteRangeEndOffset;if(oe){const ce=L.byteRangeStartOffset;I=`${oe-ce}@${ce}`}else I=null;Y2(L,J,i,V),g=L,z=!0}g.cc=S;break}case"SERVER-CONTROL":{O&&ja(d,ie,M),O=new os(Y),d.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),d.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{d.partTarget&&ja(d,ie,M);const J=new os(Y);d.partTarget=J.decimalFloatingPoint("PART-TARGET");break}case"PART":{let J=d.partList;J||(J=d.partList=[]);const oe=b>0?J[J.length-1]:void 0,ce=b++,F=new os(Y,d),ee=new n6(F,L,c,ce,oe);J.push(ee),L.duration+=ee.duration;break}case"PRELOAD-HINT":{const J=new os(Y,d);d.preloadHint=J;break}case"RENDITION-REPORT":{const J=new os(Y,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push(J);break}default:Ri.warn(`line parsed but not handled: ${M}`);break}}}R&&!R.relurl?(f.pop(),_-=R.duration,d.partList&&(d.fragmentHint=R)):d.partList&&(Ex(L,R,p),L.cc=S,d.fragmentHint=L,V&&W2(L,V,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));const W=f.length,X=f[0],q=f[W-1];if(_+=d.skippedSegments*d.targetduration,_>0&&W&&q){d.averagetargetduration=_/W;const ue=q.sn;d.endSN=ue!=="initSegment"?ue:0,d.live||(q.endList=!0),P>0&&(bU(f,P),X&&p.unshift(X))}return d.fragmentHint&&(_+=d.fragmentHint.duration),d.totalduration=_,p.length&&d.dateRangeTagCount&&X&&WD(p,d),d.endCC=S,d}}function WD(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 o;if(((o=s[f])==null?void 0:o.sn)<e.startSN)break;const p=xU(e,d,s,f,n);if(p!==-1){c.tagAnchor=e.fragments[p].ref;break}}}}function xU(s,e,t,i,n){const r=t[i];if(r){const u=r.programDateTime;if(e>=u||i===0){var o;const c=(((o=t[i+1])==null?void 0:o.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 g=(t[i+1]||f[f.length-1]).sn-s.startSN;for(let v=g;v>d;v--){const b=f[v].programDateTime;if(e>=b&&e<b+f[v].duration*1e3)return v}}return d}}}return-1}function G2(s,e,t){var i,n;const r=new os(s,t),o=(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&&Ri.error(`Invalid IV: ${r.IV}`);const p=u?ua.resolve(u,e):"",g=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Jo(o,p,f,g,c,r.KEYID)}function z2(s){const t=new os(s).decimalFloatingPoint("TIME-OFFSET");return yt(t)?t:null}function q2(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const n=t.filter(r=>Pb(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 K2(s,e,t){const i=e[t];i&&(s[t]=i)}function bU(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 Ex(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function Y2(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 W2(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 ja(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function X2(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function av(s,e){const t=e.startPTS;if(yt(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 XD(s,e,t,i,n,r,o){i-t<=0&&(o.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,p=e.endPTS;if(yt(f)){const D=Math.abs(f-t);s&&D>s.totalduration?o.warn(`media timestamps and playlist times differ by ${D}s for level ${e.level} ${s.url}`):yt(e.deltaPTS)?e.deltaPTS=Math.max(D,e.deltaPTS):e.deltaPTS=D,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,p),i=Math.max(i,p),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const g=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 b;const _=v-s.startSN,S=s.fragments;for(S[_]=e,b=_;b>0;b--)av(S[b],S[b-1]);for(b=_;b<S.length-1;b++)av(S[b],S[b+1]);return s.fragmentHint&&av(S[S.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function TU(s,e,t){if(s===e)return;let i=null;const n=s.fragments;for(let f=n.length-1;f>=0;f--){const p=n[f].initSegment;if(p){i=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r;EU(s,e,(f,p,g,v)=>{if((!e.startCC||e.skippedSegments)&&p.cc!==f.cc){const b=f.cc-p.cc;for(let _=g;_<v.length;_++)v[_].cc+=b;e.endCC=v[v.length-1].cc}yt(f.startPTS)&&yt(f.endPTS)&&(p.setStart(p.startPTS=f.startPTS),p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.setDuration(f.endPTS-f.startPTS),p.duration&&(r=p),e.PTSKnown=e.alignedSliding=!0),f.hasStreams&&(p.elementaryStreams=f.elementaryStreams),p.loader=f.loader,f.hasStats&&(p.stats=f.stats),f.initSegment&&(p.initSegment=f.initSegment,i=f.initSegment)});const o=e.fragments,u=e.fragmentHint?o.concat(e.fragmentHint):o;if(i&&u.forEach(f=>{var p;f&&(!f.initSegment||f.initSegment.relurl===((p=i)==null?void 0:p.relurl))&&(f.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=o.some(f=>!f),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=e.skippedSegments;f--;)o.shift();e.startSN=o[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=_U(s.dateRanges,e,t));const f=s.fragments.filter(p=>p.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let p=1;p<u.length;p++)u[p].programDateTime===null&&Ex(u[p],u[p-1],f);WD(f,e)}e.endCC=o[o.length-1].cc}if(!e.startCC){var c;const f=JD(s,e.startSN-1);e.startCC=(c=f?.cc)!=null?c:o[0].cc}SU(s.partList,e.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),r?XD(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):QD(s,e),o.length&&(e.totalduration=e.edge-o[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 _U(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:n}=e,r=Bi({},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 GD(i[c].attr,d);f.isValid?(r[c]=f,d||(f.tagOrder+=u)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${zi(i[c].attr)}"`)}),r):i}function SU(s,e,t){if(s&&e){let i=0;for(let n=0,r=s.length;n<=r;n++){const o=s[n],u=e[n+i];o&&u&&o.index===u.index&&o.fragment.sn===u.fragment.sn?t(o,u):i--}}}function EU(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,o=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[o+d];let p=u[d];if(i&&!p&&f&&(p=e.fragments[d]=f),f&&p){t(f,p,d,u);const g=f.relurl,v=p.relurl;if(g&&wU(g,v)){e.playlistParsingError=Q2(`media sequence mismatch ${p.sn}:`,s,e,f,p);return}else if(f.cc!==p.cc){e.playlistParsingError=Q2(`discontinuity sequence mismatch (${f.cc}!=${p.cc})`,s,e,f,p);return}}}}function Q2(s,e,t,i,n){return new Error(`${s} ${n.url}
Playlist starting @${e.startSN}
${e.m3u8}
Playlist starting @${t.startSN}
${t.m3u8}`)}function QD(s,e,t=!0){const i=e.startSN+e.skippedSegments-s.startSN,n=s.fragments,r=i>=0;let o=0;if(r&&i<n.length)o=n[i].start;else if(r&&e.startSN===s.endSN+1)o=s.fragmentEnd;else if(r&&t)o=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)o=s.fragmentStart;else return;wx(e,o)}function wx(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 ZD(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 JD(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 Z2(s,e,t){return s?eL(s.partList,e,t):null}function eL(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 tL(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 wU(s,e){return s!==e&&e?J2(s)!==J2(e):!1}function J2(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 AU(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function ew(s,e){const t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration}function iL(s,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)ew(t[i],s);e.fragmentHint&&ew(e.fragmentHint,s),e.alignedSliding=!0}function CU(s,e){s&&(sL(e,s),e.alignedSliding||Cp(e,s),!e.alignedSliding&&!e.skippedSegments&&QD(s,e,!1))}function sL(s,e){if(!AU(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;Ri.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-n.start;iL(r,s)}function Cp(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 o=Math.min(e.endCC,s.endCC);e.startCC<o&&s.startCC<o&&(n=dh(i,o),r=dh(t,o)),(!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);iL(d,s)}function vn(s,e,t){Pn(s,e,t),s.addEventListener(e,t)}function Pn(s,e,t){s.removeEventListener(e,t)}const kU={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}},He={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 Vb extends HD{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=He.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:o,fragCurrent:u,media:c,mediaBuffer:d,state:f}=this,p=c?c.currentTime:0,g=Xt.bufferInfo(d||c,p,o.maxBufferHole),v=!g.len;if(this.log(`Media seeking to ${yt(p)?p.toFixed(3):p}, state: ${f}, ${v?"out of":"in"} buffer`),this.state===He.ENDED)this.resetLoadingState();else if(u){const b=o.maxFragLookUpTolerance,_=u.start-b,S=u.start+u.duration+b;if(v||S<g.start||_>g.end){const D=p>S;(p<_||D)&&(D&&u.loader&&(this.log(`Cancelling fragment load for seek (sn: ${u.sn})`),u.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(p,1/0,this.playlistType,!0);const b=this.lastCurrentTime;if(p>b&&(this.lastCurrentTime=p),!this.loadingParts){const _=Math.max(g.end,p),S=this.shouldLoadParts(this.getLevelDetails(),_);S&&(this.log(`LL-Part loading ON after seeking to ${p.toFixed(2)} with buffer @${_.toFixed(2)}`),this.loadingParts=S)}}this.hls.hasEnoughToStart||(this.log(`Setting ${v?"startPosition":"nextLoadPosition"} to ${p} for seek without enough to start`),this.nextLoadPosition=p,v&&(this.startPosition=p)),v&&this.state===He.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 iU(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ub(e.config)}registerListeners(){const{hls:e}=this;e.on($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===He.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=He.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=Xt.bufferedInfo(r,e.start,0));const o=e.nextStart;if(o&&o>n&&o<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 Xt.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;vn(i,"seeking",this.onMediaSeeking),vn(i,"ended",this.onMediaEnded);const n=this.config;this.levels&&n.autoStartLoad&&this.state===He.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),Pn(n,"seeking",this.onMediaSeeking),Pn(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=He.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 o=r.frag;if(this.fragContextChanged(o)){this.warn(`${o.type} sn: ${o.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(o,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(o);return}o.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,n).then(r=>{if(!r)return;const o=this.state,u=r.frag;if(this.fragContextChanged(u)){(o===He.FRAG_LOADING||!this.fragCurrent&&o===He.PARSING)&&(this.fragmentTracker.removeFragment(u),this.state=He.IDLE);return}"payload"in r&&(this.log(`Loaded ${u.type} sn: ${u.sn} of ${this.playlistLabel()} ${u.level}`),this.hls.trigger($.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===He.STOPPED||this.state===He.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Bs.APPENDING){const r=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,r),u=Math.max(e.duration,o?o.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)===Bs.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($.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:o}=i,u=r.decryptdata;if(o&&o.byteLength>0&&u!=null&&u.key&&u.iv&&mc(u.method)){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),u.key.buffer,u.iv.buffer,$b(u.method)).catch(d=>{throw n.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:r}),d}).then(d=>{const f=self.performance.now();return n.trigger($.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===He.STOPPED||this.state===He.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!==He.STOPPED&&(this.state=He.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 o=this.media,u=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${o?"attached mediaKeys: "+o.mediaKeys:"detached"})`);return this.warn(u.message),!o||o.mediaKeys?!1:(this.hls.trigger($.ERROR,{type:It.KEY_SYSTEM_ERROR,details:ke.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?kU.toString(Xt.getBuffered(i)):"(detached)"})`),_s(e)){var n;if(e.type!==Et.SUBTITLE){const o=e.elementaryStreams;if(!Object.keys(o).some(u=>!!o[u])){this.state=He.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=He.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:r}=e,o=!r||r.length===0||r.some(c=>!c),u=new jb(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!o);t.flush(u)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var r;this.fragCurrent=e;const o=t.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let u=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${o.startSN}-${o.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=He.KEY_LOADING,this.fragCurrent=e,u=this.keyLoader.load(e).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger($.KEY_LOADED,g),this.state===He.KEY_LOADING&&(this.state=He.IDLE),g}),this.hls.trigger($.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,o.encryptedFragments,this.startFragRequested),u&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(_s(e)&&(!c||e.sn!==c.sn)){const g=this.shouldLoadParts(t.details,e.end);g!==this.loadingParts&&(this.log(`LL-Part loading ${g?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=g)}if(i=Math.max(e.start,i||0),this.loadingParts&&_s(e)){const g=o.partList;if(g&&n){i>o.fragmentEnd&&o.fragmentHint&&(e=o.fragmentHint);const v=this.getNextPart(g,e,i);if(v>-1){const b=g[v];e=this.fragCurrent=b.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${b.index} (${v}/${g.length-1}) of ${this.fragInfo(e,!1,b)}) cc: ${e.cc} [${o.startSN}-${o.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=He.FRAG_LOADING;let _;return u?_=u.then(S=>!S||this.fragContextChanged(S.frag)?null:this.doFragPartsLoad(e,b,t,n)).catch(S=>this.handleFragLoadError(S)):_=this.doFragPartsLoad(e,b,t,n).catch(S=>this.handleFragLoadError(S)),this.hls.trigger($.FRAG_LOADING,{frag:e,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):_}else if(!e.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}if(_s(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=o.partList)==null?void 0:d.filter(g=>g.loaded).map(g=>`[${g.start}-${g.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} ${"["+o.startSN+"-"+o.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),yt(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=He.FRAG_LOADING;const f=this.config.progressive&&e.type!==Et.SUBTITLE;let p;return f&&u?p=u.then(g=>!g||this.fragContextChanged(g.frag)?null:this.fragmentLoader.load(e,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(e,f?n:void 0),u]).then(([g])=>(!f&&n&&n(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger($.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(e,t,i,n){return new Promise((r,o)=>{var u;const c=[],d=(u=i.details)==null?void 0:u.partList,f=p=>{this.fragmentLoader.loadPart(e,p,n).then(g=>{c[p.index]=g;const v=g.part;this.hls.trigger($.FRAG_LOADED,g);const b=Z2(i.details,e.sn,p.index+1)||eL(d,e.sn,p.index+1);if(b)f(b);else return r({frag:e,part:v,partsLoaded:c})}).catch(o)};f(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===ke.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===It.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger($.ERROR,t)}else this.hls.trigger($.ERROR,{type:It.OTHER_ERROR,details:ke.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==He.PARSING){!this.fragCurrent&&this.state!==He.STOPPED&&this.state!==He.ERROR&&(this.state=He.IDLE);return}const{frag:i,part:n,level:r}=t,o=self.performance.now();i.stats.parsing.end=o,n&&(n.stats.parsing.end=o);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===Et.SUBTITLE)return!1;const o=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=o){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:o}=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=o>-1?Z2(c,r,o):null,f=d?d.fragment:JD(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!==He.PARSING)return;const{data1:o,data2:u}=e;let c=o;if(u&&(c=mr(o,u)),!c.length)return;const d=this.initPTS[t.cc],f=d?-d.baseTime/d.timescale:void 0,p={type:e.type,frag:t,part:i,chunkMeta:n,offset:f,parent:t.type,data:c};if(this.hls.trigger($.BUFFER_APPENDING,p),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Xt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=Xt.bufferInfo(t,i,0),r=e.duration,o=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),u=Math.max(Math.min(e.start-o,n.end-o),i+o);e.start-u>o&&this.flushMainBuffer(u,e.start)}getFwdBufferInfo(e,t){var i;const n=this.getLoadPosition();if(!yt(n))return null;const o=this.lastCurrentTime>n||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,o)}getFwdBufferInfoAtPos(e,t,i,n){const r=Xt.bufferInfo(e,t,n);if(r.len===0&&r.nextStart!==void 0){const o=this.fragmentTracker.getBufferedFrag(t,i);if(o&&(r.nextStart<=o.end||o.gap)){const u=Math.max(Math.min(r.nextStart,o.end)-t,n);return Xt.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=Et.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,o=i[0].start,u=r.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const p=r.initialLiveManifestSize;if(n<p)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${p})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<o){var d;u&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const g=this.hls.startPosition,v=this.hls.liveSyncPosition,b=c?(g!==-1&&g>=o?g:v)||c.start:e;this.log(`Setting startPosition to ${b} to match start frag at live edge. mainStart: ${g} liveSyncPosition: ${v} frag.start: ${(d=c)==null?void 0:d.start}`),this.startPosition=this.nextLoadPosition=b}}else e<=o&&(c=i[0]);if(!c){const p=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,p,t)}let f=this.filterReplacedPrimary(c,t);if(!f&&c){const p=c.sn-t.startSN;f=this.filterReplacedPrimary(i[p+1]||null,t)}return this.mapToInitFragWhenRequired(f)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Bs.OK||i===Bs.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,r){let o=null;if(e.gap&&(o=this.getNextFragment(this.nextLoadPosition,t),o&&!o.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=o.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,o}get primaryPrefetch(){if(tw(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(tw(this.config)&&e.type!==Et.SUBTITLE){const i=this.hls.interstitialsManager,n=i?.bufferingItem;if(n){const o=n.event;if(o){if(o.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 o=r.length;o--;){const u=r[o].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,o=!0;for(let u=0,c=e.length;u<c;u++){const d=e[u];if(o=o&&!d.independent,n>-1&&i<d.start)break;const f=d.loaded;f?n=-1:(r||(d.independent||o)&&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=G6(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const o=t[r-e.startSN];i.cc===o.cc&&(n=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=UD(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:o,endSN:u}=i;const{fragmentHint:c}=i,{maxFragLookUpTolerance:d}=n,f=i.partList,p=!!(this.loadingParts&&f!=null&&f.length&&c);p&&!this.bitrateTest&&f[f.length-1].fragment.sn===c.sn&&(o=o.concat(c),u=c.sn);let g;if(e<t){var v;const _=e<this.lastCurrentTime||e>t-d||(v=this.media)!=null&&v.paused||!this.startFragRequested?0:d;g=tu(r,o,e,_)}else g=o[o.length-1];if(g){const b=g.sn-i.startSN,_=this.fragmentTracker.getState(g);if((_===Bs.OK||_===Bs.PARTIAL&&g.gap)&&(r=g),r&&g.sn===r.sn&&(!p||f[0].fragment.sn>g.sn||!i.live)&&g.level===r.level){const D=o[b+1];g.sn<u&&this.fragmentTracker.getState(D)!==Bs.OK?g=D:g=null}}return g}alignPlaylists(e,t,i){const n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,o=!t,u=e.alignedSliding&&yt(r);if(o||!u&&!r){CU(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,o=r?this.startTimeOffset:e.startTimeOffset;o!==null&&yt(o)?(i=t+o,o<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${o} 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&&_s(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!==He.FRAG_LOADING_WAITING_RETRY)&&(this.state=He.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const D=this.getCurrentContext(t.chunkMeta);D&&(t.frag=D.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 o=t.details===ke.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(n,!0);const u=t.errorAction;if(!u){this.state=He.ERROR;return}const{action:c,flags:d,retryCount:f=0,retryConfig:p}=u,g=!!p,v=g&&c===Ws.RetryRequest,b=g&&!u.resolved&&d===Zn.MoveAllAlternatesMatchingHost,_=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!v&&b&&_s(n)&&!n.endList&&_&&!$D(t))this.resetFragmentErrors(e),this.treatAsGap(n),u.resolved=!0;else if((v||b)&&f<p.maxNumRetry){var S;const D=Tx((S=t.response)==null?void 0:S.code),R=Fb(p,f);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+R,this.state=He.FRAG_LOADING_WAITING_RETRY,u.resolved=!0,D){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}/${p.maxNumRetry} in ${R}ms`)}else if(p)if(this.resetFragmentErrors(e),f<p.maxNumRetry)!o&&c!==Ws.RemoveAlternatePermanently&&(u.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${f})`);return}else c===Ws.SendAlternateToPenaltyBox?this.state=He.WAITING_LEVEL:this.state=He.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Tx(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=He.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===He.PARSING||this.state===He.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 o=!r;return o&&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(),o}return!1}resetFragmentErrors(e){e===Et.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==He.STOPPED&&(this.state=He.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=Xt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===He.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==He.STOPPED&&(this.state=He.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 p=f.endPTS-f.startPTS;if(p<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${p})`),c||!1;const g=n?0:XD(r,e,f.startPTS,f.endPTS,f.startDTS,f.endDTS,this);return this.hls.trigger($.LEVEL_PTS_UPDATED,{details:r,level:i,drift:g,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($.ERROR,{type:It.MEDIA_ERROR,details:ke.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=He.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger($.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Et.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 tw(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class nL{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=DU(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function DU(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 ov={exports:{}},iw;function LU(){return iw||(iw=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,p,g){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new n(f,p||c,g),b=t?t+d:d;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],v]:c._events[b].push(v):(c._events[b]=v,c._eventsCount++),c}function o(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,p;if(this._eventsCount===0)return d;for(p in f=this._events)e.call(f,p)&&d.push(t?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(f)):d},u.prototype.listeners=function(d){var f=t?t+d:d,p=this._events[f];if(!p)return[];if(p.fn)return[p.fn];for(var g=0,v=p.length,b=new Array(v);g<v;g++)b[g]=p[g].fn;return b},u.prototype.listenerCount=function(d){var f=t?t+d:d,p=this._events[f];return p?p.fn?1:p.length:0},u.prototype.emit=function(d,f,p,g,v,b){var _=t?t+d:d;if(!this._events[_])return!1;var S=this._events[_],D=arguments.length,R,L;if(S.fn){switch(S.once&&this.removeListener(d,S.fn,void 0,!0),D){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,f),!0;case 3:return S.fn.call(S.context,f,p),!0;case 4:return S.fn.call(S.context,f,p,g),!0;case 5:return S.fn.call(S.context,f,p,g,v),!0;case 6:return S.fn.call(S.context,f,p,g,v,b),!0}for(L=1,R=new Array(D-1);L<D;L++)R[L-1]=arguments[L];S.fn.apply(S.context,R)}else{var M=S.length,j;for(L=0;L<M;L++)switch(S[L].once&&this.removeListener(d,S[L].fn,void 0,!0),D){case 1:S[L].fn.call(S[L].context);break;case 2:S[L].fn.call(S[L].context,f);break;case 3:S[L].fn.call(S[L].context,f,p);break;case 4:S[L].fn.call(S[L].context,f,p,g);break;default:if(!R)for(j=1,R=new Array(D-1);j<D;j++)R[j-1]=arguments[j];S[L].fn.apply(S[L].context,R)}}return!0},u.prototype.on=function(d,f,p){return r(this,d,f,p,!1)},u.prototype.once=function(d,f,p){return r(this,d,f,p,!0)},u.prototype.removeListener=function(d,f,p,g){var v=t?t+d:d;if(!this._events[v])return this;if(!f)return o(this,v),this;var b=this._events[v];if(b.fn)b.fn===f&&(!g||b.once)&&(!p||b.context===p)&&o(this,v);else{for(var _=0,S=[],D=b.length;_<D;_++)(b[_].fn!==f||g&&!b[_].once||p&&b[_].context!==p)&&S.push(b[_]);S.length?this._events[v]=S.length===1?S[0]:S:o(this,v)}return this},u.prototype.removeAllListeners=function(d){var f;return d?(f=t?t+d:d,this._events[f]&&o(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})(ov)),ov.exports}var RU=LU(),Gb=i6(RU);const Sh="1.6.15",Rc={};function IU(){return typeof __HLS_WORKER_BUNDLE__=="function"}function NU(){const s=Rc[Sh];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 Rc[Sh]=n,n}function OU(s){const e=Rc[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 Rc[s]=n,n}function MU(s){const e=Rc[s||Sh];if(e&&e.clientCount--===1){const{worker:i,objectURL:n}=e;delete Rc[s||Sh],n&&self.URL.revokeObjectURL(n),i.terminate()}}function rL(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 zb(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 cg(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 Eh(s,e){const t=e;let i=0;for(;zb(s,e);){i+=10;const n=cg(s,e+6);i+=n,rL(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function PU(s,e,t,i){const n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],o=r>>2&15;if(o>12){const v=new Error(`invalid ADTS sampling index:${o}`);s.emit($.ERROR,$.ERROR,{type:It.MEDIA_ERROR,details:ke.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[o];let p=o;(u===5||u===29)&&(p-=3);const g=[u<<3|(p&14)>>1,(p&1)<<7|c<<3];return Ri.log(`manifest codec:${i}, parsed codec:${d}, channels:${c}, rate:${f} (ADTS object type:${u} sampling index:${o})`),{config:g,samplerate:f,channelCount:c,codec:d,parsedCodec:d,manifestCodec:i}}function aL(s,e){return s[e]===255&&(s[e+1]&246)===240}function oL(s,e){return s[e+1]&1?7:9}function qb(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function BU(s,e){return e+5<s.length}function kp(s,e){return e+1<s.length&&aL(s,e)}function FU(s,e){return BU(s,e)&&aL(s,e)&&qb(s,e)<=s.length-e}function UU(s,e){if(kp(s,e)){const t=oL(s,e);if(e+t>=s.length)return!1;const i=qb(s,e);if(i<=t)return!1;const n=e+i;return n===s.length||kp(s,n)}return!1}function lL(s,e,t,i,n){if(!s.samplerate){const r=PU(e,t,i,n);if(!r)return;Bi(s,r)}}function uL(s){return 1024*9e4/s}function jU(s,e){const t=oL(s,e);if(e+t<=s.length){const i=qb(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function cL(s,e,t,i,n){const r=uL(s.samplerate),o=i+n*r,u=jU(e,t);let c;if(u){const{frameLength:p,headerLength:g}=u,v=g+p,b=Math.max(0,t+v-e.length);b?(c=new Uint8Array(v-g),c.set(e.subarray(t+g,e.length),0)):c=e.subarray(t+g,t+v);const _={unit:c,pts:o};return b||s.samples.push(_),{sample:_,length:v,missing:b}}const d=e.length-t;return c=new Uint8Array(d),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:o},length:d,missing:-1}}function $U(s,e){return zb(s,e)&&cg(s,e+6)+10<=s.length-e}function HU(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function lv(s,e=0,t=1/0){return VU(s,e,t,Uint8Array)}function VU(s,e,t,i){const n=GU(s);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const o=zU(s)?s.byteOffset:0,u=(o+s.byteLength)/r,c=(o+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 GU(s){return s instanceof ArrayBuffer?s:s.buffer}function zU(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function qU(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=ir(lv(s.data,1,i)),r=s.data[2+i],o=s.data.subarray(3+i).indexOf(0);if(o===-1)return;const u=ir(lv(s.data,3+i,o));let c;return n==="-->"?c=ir(lv(s.data,4+i+o)):c=HU(s.data.subarray(4+i+o)),e.mimeType=n,e.pictureType=r,e.description=u,e.data=c,e}function KU(s){if(s.size<2)return;const e=ir(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function YU(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=ir(s.data.subarray(t),!0);t+=i.length+1;const n=ir(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=ir(s.data.subarray(1));return{key:s.type,info:"",data:e}}function WU(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=ir(s.data.subarray(t),!0);t+=i.length+1;const n=ir(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=ir(s.data);return{key:s.type,info:"",data:e}}function XU(s){return s.type==="PRIV"?KU(s):s.type[0]==="W"?WU(s):s.type==="APIC"?qU(s):YU(s)}function QU(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=cg(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const bm=10,ZU=10;function dL(s){let e=0;const t=[];for(;zb(s,e);){const i=cg(s,e+6);s[e+5]>>6&1&&(e+=bm),e+=bm;const n=e+i;for(;e+ZU<n;){const r=QU(s.subarray(e)),o=XU(r);o&&t.push(o),e+=r.size+bm}rL(s,e)&&(e+=bm)}return t}function hL(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function JU(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 Kb(s){const e=dL(s);for(let t=0;t<e.length;t++){const i=e[t];if(hL(i))return JU(i)}}let er=(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 ia(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Yb{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=mr(this.cachedData,e),this.cachedData=null);let i=Eh(e,0),n=i?i.length:0,r;const o=this._audioTrack,u=this._id3Track,c=i?Kb(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&yt(c))&&(this.basePTS=ej(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:er.audioId3,duration:Number.POSITIVE_INFINITY});n<d;){if(this.canParse(e,n)){const f=this.appendFrame(o,e,n);f?(this.frameIndex++,this.lastPTS=f.sample.pts,n+=f.length,r=n):n=d}else $U(e,n)?(i=Eh(e,n),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:er.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=mr(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:ia(),id3Track:u,textTrack:ia()}}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:ia(),id3Track:this._id3Track,textTrack:ia()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const ej=(s,e,t)=>{if(yt(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Tm=null;const tj=[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],ij=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],sj=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],nj=[0,1,1,4];function fL(s,e,t,i,n){if(t+24>e.length)return;const r=mL(e,t);if(r&&t+r.frameLength<=e.length){const o=r.samplesPerFrame*9e4/r.sampleRate,u=i+n*o,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 mL(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 o=s[e+2]>>1&1,u=s[e+3]>>6,c=t===3?3-i:i===3?3:4,d=tj[c*14+n-1]*1e3,p=ij[(t===3?0:t===2?1:2)*3+r],g=u===3?1:2,v=sj[t][i],b=nj[i],_=v*8*b,S=Math.floor(v*d/p+o)*b;if(Tm===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Tm=L?parseInt(L[1]):0}return Tm&&Tm<=87&&i===2&&d>=224e3&&u===0&&(s[e+3]=s[e+3]|128),{sampleRate:p,channelCount:g,frameLength:S,samplesPerFrame:_}}}function Wb(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function pL(s,e){return e+1<s.length&&Wb(s,e)}function rj(s,e){return Wb(s,e)&&4<=s.length-e}function gL(s,e){if(e+1<s.length&&Wb(s,e)){const i=mL(s,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const r=e+n;return r===s.length||pL(s,r)}return!1}class aj extends Yb{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=Eh(e,0);let n=i?.length||0;if(gL(e,n))return!1;for(let r=e.length;n<r;n++)if(UU(e,n))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return FU(e,t)}appendFrame(e,t,i){lL(e,this.observer,t,i,e.manifestCodec);const n=cL(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const yL=(s,e)=>{let t=0,i=5;e+=i;const n=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);for(;i>0;){o[0]=s[e];const u=Math.min(i,8),c=8-u;r[0]=4278190080>>>24+c<<c,n[0]=(o[0]&r[0])>>c,t=t?t<<u|n[0]:n[0],e+=1,i-=u}return t};class oj extends Yb{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=vL(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=Eh(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&Kb(t)!==void 0&&yL(e,i)<16}}function vL(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 p=e[t+6]>>5;let g=0;p===2?g+=2:(p&1&&p!==1&&(g+=2),p&4&&(g+=2));const v=(e[t+6]<<8|e[t+7])>>12-g&1,_=[2,1,2,3,3,4,4,5][p]+v,S=e[t+5]>>3,D=e[t+5]&7,R=new Uint8Array([r<<6|S<<1|D>>2,(D&3)<<6|p<<3|v<<2|c>>4,c<<4&224]),L=1536/u*9e4,M=i+n*L,j=e.subarray(t,t+f);return s.config=R,s.channelCount=_,s.samplerate=u,s.samples.push({unit:j,pts:M}),f}class lj extends Yb{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=Eh(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Kb(t)!==void 0&&yL(e,i)<=16)return!1;for(let n=e.length;i<n;i++)if(gL(e,i))return Ri.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return rj(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return fL(e,t,i,this.basePTS,this.frameIndex)}}const uj=/\/emsg[-/]ID3/i;class cj{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=ia("video",1),o=this.audioTrack=ia("audio",1),u=this.txtTrack=ia("text",1);if(this.id3Track=ia("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=kD(e);if(c.video){const{id:d,timescale:f,codec:p,supplemental:g}=c.video;r.id=d,r.timescale=u.timescale=f,r.codec=p,r.supplemental=g}if(c.audio){const{id:d,timescale:f,codec:p}=c.audio;o.id=d,o.timescale=f,o.codec=p}u.id=wD.text,r.sampleDuration=0,r.duration=o.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return o6(e)}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=mr(this.remainderData,e));const u=m6(i);this.remainderData=u.remainder,n.samples=u.valid||new Uint8Array}else n.samples=i;const o=this.extractID3Track(n,t);return r.samples=b2(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,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=b2(e,t),{videoTrack:t,audioTrack:ia(),id3Track:n,textTrack:ia()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=ni(e.samples,["emsg"]);n&&n.forEach(r=>{const o=g6(r);if(uj.test(o.schemeIdUri)){const u=sw(o,t);let c=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const d=o.payload;i.samples.push({data:d,len:d.byteLength,dts:u,pts:u,type:er.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&o.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const u=sw(o,t);i.samples.push({data:o.payload,len:o.payload.byteLength,dts:u,pts:u,type:er.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 sw(s,e){return yt(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}class dj{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ub(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,sl.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),o=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(o).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 o=RD(r.data),u=this.getAvcEncryptedData(o);this.decryptBuffer(u.buffer).then(c=>{r.data=this.getAvcDecryptedUnit(o,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 o=r[i];if(!(o.data.length<=48||o.type!==1&&o.type!==5)&&(this.decryptAvcSample(e,t,i,n,o),!this.decrypter.isSync()))return}}}}class xL{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 o=r,u=[];let c=0,d,f,p,g=-1,v=0;for(r===-1&&(g=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,g>=0){const b={data:t.subarray(g,f),type:v};u.push(b)}else{const b=this.getLastNalUnit(e.samples);b&&(o&&c<=4-o&&b.state&&(b.data=b.data.subarray(0,b.data.byteLength-o)),f>0&&(b.data=mr(b.data,t.subarray(0,f)),b.state=0))}c<n?(p=this.getNALuType(t,c),g=c,v=p,r=0):r=-1}else r=0}if(g>=0&&r>=0){const b={data:t.subarray(g,n),type:v,state:r};u.push(b)}if(u.length===0){const b=this.getLastNalUnit(e.samples);b&&(b.data=mr(b.data,t))}return e.naluState=r,u}}class hh{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&&Ri.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 hj extends xL{parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let o=this.VideoSample,u,c=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,p;switch(d.type){case 1:{let _=!1;u=!0;const S=d.data;if(c&&S.length>4){const D=this.readSliceType(S);(D===2||D===4||D===7||D===9)&&(_=!0)}if(_){var g;(g=o)!=null&&g.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=_;break}case 5:u=!0,(f=o)!=null&&f.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:{u=!0,Mb(d.data,1,i.pts,t.samples);break}case 7:{var v,b;u=!0,c=!0;const _=d.data,S=this.readSPS(_);if(!e.sps||e.width!==S.width||e.height!==S.height||((v=e.pixelRatio)==null?void 0:v[0])!==S.pixelRatio[0]||((b=e.pixelRatio)==null?void 0:b[1])!==S.pixelRatio[1]){e.width=S.width,e.height=S.height,e.pixelRatio=S.pixelRatio,e.sps=[_];const D=_.subarray(1,4);let R="avc1.";for(let L=0;L<3;L++){let M=D[L].toString(16);M.length<2&&(M="0"+M),R+=M}e.codec=R}break}case 8:u=!0,e.pps=[d.data];break;case 9:u=!0,e.audFound=!0,(p=o)!=null&&p.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:u=!0;break;default:u=!1;break}o&&u&&o.units.push(d)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new hh(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,n=8,r;for(let o=0;o<e;o++)n!==0&&(r=t.readEG(),n=(i+r+256)%256),i=n===0?i:n}readSPS(e){const t=new hh(e);let i=0,n=0,r=0,o=0,u,c,d;const f=t.readUByte.bind(t),p=t.readBits.bind(t),g=t.readUEG.bind(t),v=t.readBoolean.bind(t),b=t.skipBits.bind(t),_=t.skipEG.bind(t),S=t.skipUEG.bind(t),D=this.skipScalingList.bind(this);f();const R=f();if(p(5),b(3),f(),S(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){const z=g();if(z===3&&b(1),S(),S(),b(1),v())for(c=z!==3?8:12,d=0;d<c;d++)v()&&(d<6?D(16,t):D(64,t))}S();const L=g();if(L===0)g();else if(L===1)for(b(1),_(),_(),u=g(),d=0;d<u;d++)_();S(),b(1);const M=g(),j=g(),V=p(1);V===0&&b(1),b(1),v()&&(i=g(),n=g(),r=g(),o=g());let P=[1,1];if(v()&&v())switch(f()){case 1:P=[1,1];break;case 2:P=[12,11];break;case 3:P=[10,11];break;case 4:P=[16,11];break;case 5:P=[40,33];break;case 6:P=[24,11];break;case 7:P=[20,11];break;case 8:P=[32,11];break;case 9:P=[80,33];break;case 10:P=[18,11];break;case 11:P=[15,11];break;case 12:P=[64,33];break;case 13:P=[160,99];break;case 14:P=[4,3];break;case 15:P=[3,2];break;case 16:P=[2,1];break;case 255:{P=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-i*2-n*2),height:(2-V)*(j+1)*16-(V?2:4)*(r+o),pixelRatio:P}}}class fj extends xL{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let o=this.VideoSample,u,c=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,p;switch(d.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,u=!0;break;case 16:case 17:case 18:case 21:if(u=!0,c){var g;(g=o)!=null&&g.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:u=!0,(f=o)!=null&&f.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:u=!0,Mb(d.data,2,i.pts,t.samples);break;case 32:u=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Bi(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 b in v.params)e.params[b]=v.params[b]}this.pushParameterSet(e.sps,d.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.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 b in v)e.params[b]=v[b]}this.pushParameterSet(e.pps,d.data,e.vps)}break;case 35:u=!0,e.audFound=!0,(p=o)!=null&&p.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:u=!1;break}o&&u&&o.units.push(d)}),n&&o&&(this.pushAccessUnit(o,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 hh(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 hh(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(),o=t.readBits(5),u=t.readUByte(),c=t.readUByte(),d=t.readUByte(),f=t.readUByte(),p=t.readUByte(),g=t.readUByte(),v=t.readUByte(),b=t.readUByte(),_=t.readUByte(),S=t.readUByte(),D=t.readUByte(),R=[],L=[];for(let at=0;at<i;at++)R.push(t.readBoolean()),L.push(t.readBoolean());if(i>0)for(let at=i;at<8;at++)t.readBits(2);for(let at=0;at<i;at++)R[at]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),L[at]&&t.readUByte();t.readUEG();const M=t.readUEG();M==3&&t.skipBits(1);const j=t.readUEG(),V=t.readUEG(),P=t.readBoolean();let z=0,I=0,O=0,W=0;P&&(z+=t.readUEG(),I+=t.readUEG(),O+=t.readUEG(),W+=t.readUEG());const X=t.readUEG(),q=t.readUEG(),ue=t.readUEG(),ie=t.readBoolean();for(let at=ie?0:i;at<=i;at++)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 gt=0;gt<4;gt++)for(let Dt=0;Dt<(gt===3?2:6);Dt++)if(!t.readBoolean())t.readUEG();else{const dt=Math.min(64,1<<4+(gt<<1));gt>1&&t.readEG();for(let lt=0;lt<dt;lt++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const J=t.readUEG();let oe=0;for(let at=0;at<J;at++){let gt=!1;if(at!==0&&(gt=t.readBoolean()),gt){at===J&&t.readUEG(),t.readBoolean(),t.readUEG();let Dt=0;for(let Nt=0;Nt<=oe;Nt++){const dt=t.readBoolean();let lt=!1;dt||(lt=t.readBoolean()),(dt||lt)&&Dt++}oe=Dt}else{const Dt=t.readUEG(),Nt=t.readUEG();oe=Dt+Nt;for(let dt=0;dt<Dt;dt++)t.readUEG(),t.readBoolean();for(let dt=0;dt<Nt;dt++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const at=t.readUEG();for(let gt=0;gt<at;gt++){for(let Dt=0;Dt<ue+4;Dt++)t.readBits(1);t.readBits(1)}}let F=0,ee=1,pe=1,_e=!0,ve=1,Ce=0;t.readBoolean(),t.readBoolean();let Be=!1;if(t.readBoolean()){if(t.readBoolean()){const ye=t.readUByte(),ze=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],We=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];ye>0&&ye<16?(ee=ze[ye-1],pe=We[ye-1]):ye===255&&(ee=t.readBits(16),pe=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(),Be=t.readBoolean(),Be&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(ve=t.readBits(32),Ce=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const We=t.readBoolean(),et=t.readBoolean();let ot=!1;(We||et)&&(ot=t.readBoolean(),ot&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ot&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let nt=0;nt<=i;nt++){_e=t.readBoolean();const vt=_e||t.readBoolean();let Xe=!1;vt?t.readEG():Xe=t.readBoolean();const Ft=Xe?1:t.readUEG()+1;if(We)for(let Gt=0;Gt<Ft;Gt++)t.readUEG(),t.readUEG(),ot&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(et)for(let Gt=0;Gt<Ft;Gt++)t.readUEG(),t.readUEG(),ot&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),F=t.readUEG())}let Je=j,Ct=V;if(P){let at=1,gt=1;M===1?at=gt=2:M==2&&(at=2),Je=j-at*I-at*z,Ct=V-gt*W-gt*O}const st=n?["A","B","C"][n]:"",mt=u<<24|c<<16|d<<8|f;let pt=0;for(let at=0;at<32;at++)pt=(pt|(mt>>at&1)<<31-at)>>>0;let ut=pt.toString(16);return o===1&&ut==="2"&&(ut="6"),{codecString:`hvc1.${st}${o}.${ut}.${r?"H":"L"}${D}.B0`,params:{general_tier_flag:r,general_profile_idc:o,general_profile_space:n,general_profile_compatibility_flags:[u,c,d,f],general_constraint_indicator_flags:[p,g,v,b,_,S],general_level_idc:D,bit_depth:X+8,bit_depth_luma_minus8:X,bit_depth_chroma_minus8:q,min_spatial_segmentation_idc:F,chroma_format_idc:M,frame_rate:{fixed:_e,fps:Ce/ve}},width:Je,height:Ct,pixelRatio:[ee,pe]}}readPPS(e){const t=new hh(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 o=1;return r&&n?o=0:r?o=3:n&&(o=2),{parallelismType:o}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Hs=188;class Yo{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=Yo.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(Hs*5,t-Hs)+1,n=0;for(;n<i;){let r=!1,o=-1,u=0;for(let c=n;c<t;c+=Hs)if(e[c]===71&&(t-c===Hs||e[c+Hs]===71)){if(u++,o===-1&&(o=c,o!==0&&(i=Math.min(o+Hs*99,e.length-Hs)+1)),r||(r=Ax(e,c)===0),r&&u>1&&(o===0&&u>2||c+Hs>i))return o}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:wD[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=Yo.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=Yo.createTrack("audio",n),this._id3Track=Yo.createTrack("id3"),this._txtTrack=Yo.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 o=this._videoTrack,u=this._audioTrack,c=this._id3Track,d=this._txtTrack;let f=o.pid,p=o.pesData,g=u.pid,v=c.pid,b=u.pesData,_=c.pesData,S=null,D=this.pmtParsed,R=this._pmtId,L=e.length;if(this.remainderData&&(e=mr(this.remainderData,e),L=e.length,this.remainderData=null),L<Hs&&!n)return this.remainderData=e,{audioTrack:u,videoTrack:o,id3Track:c,textTrack:d};const M=Math.max(0,Yo.syncOffset(e));L-=(L-M)%Hs,L<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let j=0;for(let P=M;P<L;P+=Hs)if(e[P]===71){const z=!!(e[P+1]&64),I=Ax(e,P),O=(e[P+3]&48)>>4;let W;if(O>1){if(W=P+5+e[P+4],W===P+Hs)continue}else W=P+4;switch(I){case f:z&&(p&&(r=Ku(p,this.logger))&&(this.readyVideoParser(o.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(o,d,r,!1)),p={data:[],size:0}),p&&(p.data.push(e.subarray(W,P+Hs)),p.size+=P+Hs-W);break;case g:if(z){if(b&&(r=Ku(b,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}b={data:[],size:0}}b&&(b.data.push(e.subarray(W,P+Hs)),b.size+=P+Hs-W);break;case v:z&&(_&&(r=Ku(_,this.logger))&&this.parseID3PES(c,r),_={data:[],size:0}),_&&(_.data.push(e.subarray(W,P+Hs)),_.size+=P+Hs-W);break;case 0:z&&(W+=e[W]+1),R=this._pmtId=mj(e,W);break;case R:{z&&(W+=e[W]+1);const X=pj(e,W,this.typeSupported,i,this.observer,this.logger);f=X.videoPid,f>0&&(o.pid=f,o.segmentCodec=X.segmentVideoCodec),g=X.audioPid,g>0&&(u.pid=g,u.segmentCodec=X.segmentAudioCodec),v=X.id3Pid,v>0&&(c.pid=v),S!==null&&!D&&(this.logger.warn(`MPEG-TS PMT found at ${P} after unknown PID '${S}'. Backtracking to sync byte @${M} to parse all TS packets.`),S=null,P=M-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:S=I;break}}else j++;j>0&&Cx(this.observer,new Error(`Found ${j} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=p,u.pesData=b,c.pesData=_;const V={audioTrack:u,videoTrack:o,id3Track:c,textTrack:d};return n&&this.extractRemainingSamples(V),V}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,o=i.pesData,u=t.pesData,c=n.pesData;let d;if(o&&(d=Ku(o,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,d,!0),i.pesData=null)):i.pesData=o,u&&(d=Ku(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=Ku(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 dj(this.observer,this.config,t);return this.decrypt(n,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new hj:e==="hevc"&&(this.videoParser=new fj))}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 p=n.missing,g=n.sample.unit.byteLength;if(p===-1)r=mr(n.sample.unit,r);else{const v=g-p;n.sample.unit.set(r.subarray(0,p),v),e.samples.push(n.sample),i=n.missing}}let o,u;for(o=i,u=r.length;o<u-1&&!kp(r,o);o++);if(o!==i){let p;const g=o<u-1;if(g?p=`AAC PES did not start with ADTS header,offset:${o}`:p="No ADTS header found in AAC PES",Cx(this.observer,new Error(p),g,this.logger),!g)return}lL(e,this.observer,r,o,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(n){const p=uL(e.samplerate);c=n.sample.pts+p}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,f;for(;o<u;)if(f=cL(e,r,o,c,d),o+=f.length,f.missing){this.aacOverFlow=f;break}else for(d++;o<u-1&&!kp(r,o);o++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let r=0,o=0;const u=t.pts;if(u===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<n;)if(pL(i,o)){const c=fL(e,i,o,u,r);if(c)o+=c.length,r++;else break}else o++}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 o=0,u=0,c;for(;u<r&&(c=vL(e,i,u,n,o++))>0;)u+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Bi({},t,{type:this._videoTrack?er.emsg:er.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Ax(s,e){return((s[e+1]&31)<<8)+s[e+2]}function mj(s,e){return(s[e+10]&31)<<8|s[e+11]}function pj(s,e,t,i,n,r){const o={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=Ax(s,e),p=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){uv("ADTS AAC",r);break}case 15:o.audioPid===-1&&(o.audioPid=f);break;case 21:o.id3Pid===-1&&(o.id3Pid=f);break;case 219:if(!i){uv("H.264",r);break}case 27:o.videoPid===-1&&(o.videoPid=f);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):o.audioPid===-1&&(o.audioPid=f,o.segmentAudioCodec="mp3");break;case 193:if(!i){uv("AC-3",r);break}case 129:t.ac3?o.audioPid===-1&&(o.audioPid=f,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(o.audioPid===-1&&p>0){let g=e+5,v=p;for(;v>2;){s[g]===106&&(t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=f,o.segmentAudioCodec="ac3"));const _=s[g+1]+2;g+=_,v-=_}}break;case 194:case 135:return Cx(n,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:o.videoPid===-1&&(o.videoPid=f,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=p+5}return o}function Cx(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit($.ERROR,$.ERROR,{type:It.MEDIA_ERROR,details:ke.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function uv(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function Ku(s,e){let t=0,i,n,r,o,u;const c=s.data;if(!s||s.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=mr(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&&(o=(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,o-u>60*9e4&&(e.warn(`${Math.round((o-u)/9e4)}s delta between PTS and DTS, align them`),o=u)):u=o),r=i[8];let p=r+9;if(s.size<=p)return null;s.size-=p;const g=new Uint8Array(s.size);for(let v=0,b=c.length;v<b;v++){i=c[v];let _=i.byteLength;if(p)if(p>_){p-=_;continue}else i=i.subarray(p),_-=p,p=0;g.set(i,t),t+=_}return n&&(n-=r+3),{data:g,pts:o,dts:u,len:n}}return null}class gj{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 Ho=Math.pow(2,32)-1;class Ae{static init(){Ae.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 Ae.types)Ae.types.hasOwnProperty(e)&&(Ae.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]);Ae.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]);Ae.STTS=Ae.STSC=Ae.STCO=r,Ae.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ae.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Ae.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Ae.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),u=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);Ae.FTYP=Ae.box(Ae.types.ftyp,o,c,o,u),Ae.DINF=Ae.box(Ae.types.dinf,Ae.box(Ae.types.dref,n))}static box(e,...t){let i=8,n=t.length;const r=n;for(;n--;)i+=t[n].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(e,4),n=0,i=8;n<r;n++)o.set(t[n],i),i+=t[n].byteLength;return o}static hdlr(e){return Ae.box(Ae.types.hdlr,Ae.HDLR_TYPES[e])}static mdat(e){return Ae.box(Ae.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Ho+1)),n=Math.floor(t%(Ho+1));return Ae.box(Ae.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 Ae.box(Ae.types.mdia,Ae.mdhd(e.timescale||0,e.duration||0),Ae.hdlr(e.type),Ae.minf(e))}static mfhd(e){return Ae.box(Ae.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"?Ae.box(Ae.types.minf,Ae.box(Ae.types.smhd,Ae.SMHD),Ae.DINF,Ae.stbl(e)):Ae.box(Ae.types.minf,Ae.box(Ae.types.vmhd,Ae.VMHD),Ae.DINF,Ae.stbl(e))}static moof(e,t,i){return Ae.box(Ae.types.moof,Ae.mfhd(e),Ae.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=Ae.trak(e[t]);return Ae.box.apply(null,[Ae.types.moov,Ae.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(Ae.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=Ae.trex(e[t]);return Ae.box.apply(null,[Ae.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Ho+1)),n=Math.floor(t%(Ho+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 Ae.box(Ae.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 Ae.box(Ae.types.sdtp,i)}static stbl(e){return Ae.box(Ae.types.stbl,Ae.stsd(e),Ae.box(Ae.types.stts,Ae.STTS),Ae.box(Ae.types.stsc,Ae.STSC),Ae.box(Ae.types.stsz,Ae.STSZ),Ae.box(Ae.types.stco,Ae.STCO))}static avc1(e){let t=[],i=[],n,r,o;for(n=0;n<e.sps.length;n++)r=e.sps[n],o=r.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(r));for(n=0;n<e.pps.length;n++)r=e.pps[n],o=r.byteLength,i.push(o>>>8&255),i.push(o&255),i=i.concat(Array.prototype.slice.call(r));const u=Ae.box(Ae.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],p=e.pixelRatio[1];return Ae.box(Ae.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,Ae.box(Ae.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Ae.box(Ae.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,p>>24,p>>16&255,p>>8&255,p&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 Ae.box(Ae.types.mp4a,Ae.audioStsd(e),Ae.box(Ae.types.esds,Ae.esds(e)))}static mp3(e){return Ae.box(Ae.types[".mp3"],Ae.audioStsd(e))}static ac3(e){return Ae.box(Ae.types["ac-3"],Ae.audioStsd(e),Ae.box(Ae.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return Ae.box(Ae.types.stsd,Ae.STSD,Ae.mp4a(e));if(t==="ac3"&&e.config)return Ae.box(Ae.types.stsd,Ae.STSD,Ae.ac3(e));if(t==="mp3"&&e.codec==="mp3")return Ae.box(Ae.types.stsd,Ae.STSD,Ae.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return Ae.box(Ae.types.stsd,Ae.STSD,Ae.avc1(e));if(t==="hevc"&&e.vps)return Ae.box(Ae.types.stsd,Ae.STSD,Ae.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,o=Math.floor(i/(Ho+1)),u=Math.floor(i%(Ho+1));return Ae.box(Ae.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,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=Ae.sdtp(e),n=e.id,r=Math.floor(t/(Ho+1)),o=Math.floor(t%(Ho+1));return Ae.box(Ae.types.traf,Ae.box(Ae.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),Ae.box(Ae.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,o>>24,o>>16&255,o>>8&255,o&255])),Ae.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,Ae.box(Ae.types.trak,Ae.tkhd(e),Ae.mdia(e))}static trex(e){const t=e.id;return Ae.box(Ae.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,o=new Uint8Array(r);let u,c,d,f,p,g;for(t+=8+r,o.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,p=c.flags,g=c.cts,o.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,p.isLeading<<2|p.dependsOn,p.isDependedOn<<6|p.hasRedundancy<<4|p.paddingValue<<1|p.isNonSync,p.degradPrio&61440,p.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*u);return Ae.box(Ae.types.trun,o)}static initSegment(e){Ae.types||Ae.init();const t=Ae.moov(e);return mr(Ae.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 o=r.length;for(let b=0;b<i.length;b+=1){o+=3;for(let _=0;_<i[b].length;_+=1)o+=2+i[b][_].length}const u=new Uint8Array(o);u.set(r,0),o=r.length;const c=i.length-1;for(let b=0;b<i.length;b+=1){u.set(new Uint8Array([32+b|(b===c?128:0),0,i[b].length]),o),o+=3;for(let _=0;_<i[b].length;_+=1)u.set(new Uint8Array([i[b][_].length>>8,i[b][_].length&255]),o),o+=2,u.set(i[b][_],o),o+=i[b][_].length}const d=Ae.box(Ae.types.hvcC,u),f=e.width,p=e.height,g=e.pixelRatio[0],v=e.pixelRatio[1];return Ae.box(Ae.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,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,Ae.box(Ae.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Ae.box(Ae.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}}Ae.types=void 0;Ae.HDLR_TYPES=void 0;Ae.STTS=void 0;Ae.STSC=void 0;Ae.STCO=void 0;Ae.STSZ=void 0;Ae.VMHD=void 0;Ae.SMHD=void 0;Ae.STSD=void 0;Ae.FTYP=void 0;Ae.DINF=void 0;const bL=9e4;function Xb(s,e,t=1,i=!1){const n=s*e*t;return i?Math.round(n):n}function yj(s,e,t=1,i=!1){return Xb(s,e,1/t,i)}function zd(s,e=!1){return Xb(s,1e3,1/bL,e)}function vj(s,e=1){return Xb(s,bL,1/e)}function nw(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const xj=10*1e3,bj=1024,Tj=1152,_j=1536;let Yu=null,cv=null;function rw(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 jm extends yr{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,Yu===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Yu=o?parseInt(o[1]):0}if(cv===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);cv=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&&nw(t)} > ${e&&nw(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,o)=>{let u=o.pts,c=u-r;return c<-4294967296&&(t=!0,u=Jn(u,i),c=u-r),c>0?r:u},i);return t&&this.debug("PTS rollover detected"),n}remux(e,t,i,n,r,o,u,c){let d,f,p,g,v,b,_=r,S=r;const D=e.pid>-1,R=t.pid>-1,L=t.samples.length,M=e.samples.length>0,j=u&&L>0||L>1;if((!D||M)&&(!R||j)||this.ISGenerated||u){if(this.ISGenerated){var P,z,I,O;const ue=this.videoTrackConfig;(ue&&(t.width!==ue.width||t.height!==ue.height||((P=t.pixelRatio)==null?void 0:P[0])!==((z=ue.pixelRatio)==null?void 0:z[0])||((I=t.pixelRatio)==null?void 0:I[1])!==((O=ue.pixelRatio)==null?void 0:O[1]))||!ue&&j||this.nextAudioTs===null&&M)&&this.resetInitSegment()}this.ISGenerated||(p=this.generateIS(e,t,r,o));const W=this.isVideoContiguous;let X=-1,q;if(j&&(X=Sj(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(b=!0,X>0){this.warn(`Dropped ${X} out of ${L} video samples due to a missing keyframe`);const ue=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(X),t.dropped+=X,S+=(t.samples[0].pts-ue)/t.inputTimeScale,q=S}else X===-1&&(this.warn(`No keyframe found out of ${L} video samples`),b=!1);if(this.ISGenerated){if(M&&j){const ue=this.getVideoStartPts(t.samples),Y=(Jn(e.samples[0].pts,ue)-ue)/t.inputTimeScale;_+=Math.max(0,Y),S+=Math.max(0,-Y)}if(M){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),p=this.generateIS(e,t,r,o)),f=this.remuxAudio(e,_,this.isAudioContiguous,o,R||j||c===Et.AUDIO?S:void 0),j){const ue=f?f.endPTS-f.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),p=this.generateIS(e,t,r,o)),d=this.remuxVideo(t,S,W,ue)}}else j&&(d=this.remuxVideo(t,S,W,0));d&&(d.firstKeyFrame=X,d.independent=X!==-1,d.firstKeyFramePTS=q)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(v=TL(i,r,this._initPTS,this._initDTS)),n.samples.length&&(g=_L(n,r,this._initPTS))),{audio:f,video:d,initSegment:p,independent:b,text:g,id3:v}}computeInitPts(e,t,i,n){const r=Math.round(i*t);let o=Jn(e,r);if(o<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-o)/t} ${n}`);o<r+t;)o+=8589934592;return o-r}generateIS(e,t,i,n){const r=e.samples,o=t.samples,u=this.typeSupported,c={},d=this._initPTS;let f=!d||n,p="audio/mp4",g,v,b,_=-1;if(f&&(g=v=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(p="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:p,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):Ae.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(_=e.id,b=e.inputTimeScale,!d||b!==d.timescale?g=v=this.computeInitPts(r[0].pts,b,i,"audio"):f=!1)}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Ae.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(_=t.id,b=t.inputTimeScale,!d||b!==d.timescale){const S=this.getVideoStartPts(o),D=Jn(o[0].dts,S),R=this.computeInitPts(D,b,i,"video"),L=this.computeInitPts(S,b,i,"video");v=Math.min(v,R),g=Math.min(g,L)}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} ${g/b} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${g/b} (${g}/${b}) trackId: ${_}`),this._initPTS={baseTime:g,timescale:b,trackId:_},this._initDTS={baseTime:v,timescale:b,trackId:_}):g=b=void 0,{tracks:c,initPTS:g,timescale:b,trackId:_}}remuxVideo(e,t,i,n){const r=e.inputTimeScale,o=e.samples,u=[],c=o.length,d=this._initPTS,f=d.baseTime*r/d.timescale;let p=this.nextVideoTs,g=8,v=this.videoSampleDuration,b,_,S=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,R=!1;if(!i||p===null){const F=f+t*r,ee=o[0].pts-Jn(o[0].dts,o[0].pts);Yu&&p!==null&&Math.abs(F-ee-(p+f))<15e3?i=!0:p=F-ee-f}const L=p+f;for(let F=0;F<c;F++){const ee=o[F];ee.pts=Jn(ee.pts,L),ee.dts=Jn(ee.dts,L),ee.dts<o[F>0?F-1:F].dts&&(R=!0)}R&&o.sort(function(F,ee){const pe=F.dts-ee.dts,_e=F.pts-ee.pts;return pe||_e}),b=o[0].dts,_=o[o.length-1].dts;const M=_-b,j=M?Math.round(M/(c-1)):v||e.inputTimeScale/30;if(i){const F=b-L,ee=F>j,pe=F<-1;if((ee||pe)&&(ee?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${zd(F,!0)} ms (${F}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${zd(-F,!0)} ms (${F}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!pe||L>=o[0].pts||Yu)){b=L;const _e=o[0].pts-F;if(ee)o[0].dts=b,o[0].pts=_e;else{let ve=!0;for(let Ce=0;Ce<o.length&&!(o[Ce].dts>_e&&ve);Ce++){const Be=o[Ce].pts;if(o[Ce].dts-=F,o[Ce].pts-=F,Ce<o.length-1){const tt=o[Ce+1].pts,Je=o[Ce].pts,Ct=tt<=Je,st=tt<=Be;ve=Ct==st}}}this.log(`Video: Initial PTS/DTS adjusted: ${zd(_e,!0)}/${zd(b,!0)}, delta: ${zd(F,!0)} ms`)}}b=Math.max(0,b);let V=0,P=0,z=b;for(let F=0;F<c;F++){const ee=o[F],pe=ee.units,_e=pe.length;let ve=0;for(let Ce=0;Ce<_e;Ce++)ve+=pe[Ce].data.length;P+=ve,V+=_e,ee.length=ve,ee.dts<z?(ee.dts=z,z+=j/4|0||1):z=ee.dts,S=Math.min(ee.pts,S),D=Math.max(ee.pts,D)}_=o[c-1].dts;const I=P+4*V+8;let O;try{O=new Uint8Array(I)}catch(F){this.observer.emit($.ERROR,$.ERROR,{type:It.MUX_ERROR,details:ke.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:I,reason:`fail allocating video mdat ${I}`});return}const W=new DataView(O.buffer);W.setUint32(0,I),O.set(Ae.types.mdat,4);let X=!1,q=Number.POSITIVE_INFINITY,ue=Number.POSITIVE_INFINITY,ie=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY;for(let F=0;F<c;F++){const ee=o[F],pe=ee.units;let _e=0;for(let Be=0,tt=pe.length;Be<tt;Be++){const Je=pe[Be],Ct=Je.data,st=Je.data.byteLength;W.setUint32(g,st),g+=4,O.set(Ct,g),g+=st,_e+=4+st}let ve;if(F<c-1)v=o[F+1].dts-ee.dts,ve=o[F+1].pts-ee.pts;else{const Be=this.config,tt=F>0?ee.dts-o[F-1].dts:j;if(ve=F>0?ee.pts-o[F-1].pts:j,Be.stretchShortVideoTrack&&this.nextAudioTs!==null){const Je=Math.floor(Be.maxBufferHole*r),Ct=(n?S+n*r:this.nextAudioTs+f)-ee.pts;Ct>Je?(v=Ct-tt,v<0?v=tt:X=!0,this.log(`It is approximately ${Ct/90} ms to the next segment; using duration ${v/90} ms for the last video frame.`)):v=tt}else v=tt}const Ce=Math.round(ee.pts-ee.dts);q=Math.min(q,v),ie=Math.max(ie,v),ue=Math.min(ue,ve),Y=Math.max(Y,ve),u.push(rw(ee.key,v,_e,Ce))}if(u.length){if(Yu){if(Yu<70){const F=u[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(cv&&Y-ue<ie-q&&j/ie<.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=b;for(let ee=0,pe=u.length;ee<pe;ee++){const _e=F+u[ee].duration,ve=F+u[ee].cts;if(ee<pe-1){const Ce=_e+u[ee+1].cts;u[ee].duration=Ce-ve}else u[ee].duration=ee?u[ee-1].duration:j;u[ee].cts=0,F=_e}}}v=X||!v?j:v;const G=_+v;this.nextVideoTs=p=G-f,this.videoSampleDuration=v,this.isVideoContiguous=!0;const ce={data1:Ae.moof(e.sequenceNumber++,b,Bi(e,{samples:u})),data2:O,startPTS:(S-f)/r,endPTS:(D+v-f)/r,startDTS:(b-f)/r,endDTS:p/r,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ce}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Tj;case"ac3":return _j;default:return bj}}remuxAudio(e,t,i,n,r){const o=e.inputTimeScale,u=e.samplerate?e.samplerate:o,c=o/u,d=this.getSamplesPerFrame(e),f=d*c,p=this._initPTS,g=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],b=r!==void 0;let _=e.samples,S=g?0:8,D=this.nextAudioTs||-1;const R=p.baseTime*o/p.timescale,L=R+t*o;if(this.isAudioContiguous=i=i||_.length&&D>0&&(n&&Math.abs(L-(D+R))<9e3||Math.abs(Jn(_[0].pts,L)-(D+R))<20*f),_.forEach(function(Y){Y.pts=Jn(Y.pts,L)}),!i||D<0){const Y=_.length;if(_=_.filter(G=>G.pts>=0),Y!==_.length&&this.warn(`Removed ${_.length-Y} of ${Y} samples (initPTS ${R} / ${o})`),!_.length)return;r===0?D=0:n&&!b?D=Math.max(0,L-R):D=_[0].pts-R}if(e.segmentCodec==="aac"){const Y=this.config.maxAudioFramesDrift;for(let G=0,J=D+R;G<_.length;G++){const oe=_[G],ce=oe.pts,F=ce-J,ee=Math.abs(1e3*F/o);if(F<=-Y*f&&b)G===0&&(this.warn(`Audio frame @ ${(ce/o).toFixed(3)}s overlaps marker by ${Math.round(1e3*F/o)} ms.`),this.nextAudioTs=D=ce-R,J=ce);else if(F>=Y*f&&ee<xj&&b){let pe=Math.round(F/f);for(J=ce-pe*f;J<0&&pe&&f;)pe--,J+=f;G===0&&(this.nextAudioTs=D=J-R),this.warn(`Injecting ${pe} audio frames @ ${((J-R)/o).toFixed(3)}s due to ${Math.round(1e3*F/o)} ms gap.`);for(let _e=0;_e<pe;_e++){let ve=gj.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);ve||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),ve=oe.unit.subarray()),_.splice(G,0,{unit:ve,pts:J}),J+=f,G++}}oe.pts=J,J+=f}}let M=null,j=null,V,P=0,z=_.length;for(;z--;)P+=_[z].unit.byteLength;for(let Y=0,G=_.length;Y<G;Y++){const J=_[Y],oe=J.unit;let ce=J.pts;if(j!==null){const ee=v[Y-1];ee.duration=Math.round((ce-j)/c)}else if(i&&e.segmentCodec==="aac"&&(ce=D+R),M=ce,P>0){P+=S;try{V=new Uint8Array(P)}catch(ee){this.observer.emit($.ERROR,$.ERROR,{type:It.MUX_ERROR,details:ke.REMUX_ALLOC_ERROR,fatal:!1,error:ee,bytes:P,reason:`fail allocating audio mdat ${P}`});return}g||(new DataView(V.buffer).setUint32(0,P),V.set(Ae.types.mdat,4))}else return;V.set(oe,S);const F=oe.byteLength;S+=F,v.push(rw(!0,d,F,0)),j=ce}const I=v.length;if(!I)return;const O=v[v.length-1];D=j-R,this.nextAudioTs=D+c*O.duration;const W=g?new Uint8Array(0):Ae.moof(e.sequenceNumber++,M/c,Bi({},e,{samples:v}));e.samples=[];const X=(M-R)/o,q=this.nextAudioTs/o,ie={data1:W,data2:V,startPTS:X,endPTS:q,startDTS:X,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:I};return this.isAudioContiguous=!0,ie}}function Jn(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 Sj(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function TL(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=Jn(c.pts-t.baseTime*r/t.timescale,e*r)/r,c.dts=Jn(c.dts-i.baseTime*r/i.timescale,e*r)/r}const o=s.samples;return s.samples=[],{samples:o}}function _L(s,e,t){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let o=0;o<i;o++){const u=s.samples[o];u.pts=Jn(u.pts-t.baseTime*n/t.timescale,e*n)/n}s.samples.sort((o,u)=>o.pts-u.pts);const r=s.samples;return s.samples=[],{samples:r}}class Ej extends yr{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:o}=this.initData=kD(e);if(t)d6(e,t);else{const c=r||o;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}r&&(i=aw(r,Vi.AUDIO,this)),o&&(n=aw(o,Vi.VIDEO,this));const u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}remux(e,t,i,n,r,o){var u,c;let{initPTS:d,lastEndTime:f}=this;const p={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};yt(f)||(f=this.lastEndTime=r||0);const g=t.samples;if(!g.length)return p;const v={initPTS:void 0,timescale:void 0,trackId:void 0};let b=this.initData;if((u=b)!=null&&u.length||(this.generateInitSegment(g),b=this.initData),!((c=b)!=null&&c.length))return this.warn("Failed to generate initSegment."),p;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);const _=f6(g,b,this),S=b.audio?_[b.audio.id]:null,D=b.video?_[b.video.id]:null,R=_m(D,1/0),L=_m(S,1/0),M=_m(D,0,!0),j=_m(S,0,!0);let V=r,P=0;const z=S&&(!D||!d&&L<R||d&&d.trackId===b.audio.id),I=z?S:D;if(I){const J=I.timescale,oe=I.start-r*J,ce=z?b.audio.id:b.video.id;V=I.start/J,P=z?j-L:M-R,(o||!d)&&(wj(d,V,r,P)||J!==d.timescale)&&(d&&this.warn(`Timestamps at playlist time: ${o?"":"~"}${r} ${oe/J} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${V-r} (${oe}/${J}) trackId: ${ce}`),d=null,v.initPTS=oe,v.timescale=J,v.trackId=ce)}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=V,v.timescale=1,v.trackId=-1),this.initPTS=d={baseTime:v.initPTS,timescale:v.timescale,trackId:v.trackId});const O=V-d.baseTime/d.timescale,W=O+P;P>0?this.lastEndTime=W:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const X=!!b.audio,q=!!b.video;let ue="";X&&(ue+="audio"),q&&(ue+="video");const ie=(b.audio?b.audio.encrypted:!1)||(b.video?b.video.encrypted:!1),Y={data1:g,startPTS:O,startDTS:O,endPTS:W,endDTS:W,type:ue,hasAudio:X,hasVideo:q,nb:1,dropped:0,encrypted:ie};p.audio=X&&!q?Y:void 0,p.video=q?Y:void 0;const G=D?.sampleCount;if(G){const J=D.keyFrameIndex,oe=J!==-1;Y.nb=G,Y.dropped=J===0||this.isVideoContiguous?0:oe?J:G,Y.independent=oe,Y.firstKeyFrame=J,oe&&D.keyFrameStart&&(Y.firstKeyFramePTS=(D.keyFrameStart-d.baseTime)/d.timescale),this.isVideoContiguous||(p.independent=oe),this.isVideoContiguous||(this.isVideoContiguous=oe),Y.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${J}/${G} dropped: ${Y.dropped} start: ${Y.firstKeyFramePTS||"NA"}`)}return p.initSegment=v,p.id3=TL(i,r,d,d),n.samples.length&&(p.text=_L(n,r,d)),p}}function _m(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function wj(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 aw(s,e,t){const i=s.codec;return i&&i.length>4?i:e===Vi.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?bp(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 Ga;try{Ga=self.performance.now.bind(self.performance)}catch{Ga=Date.now}const $m=[{demux:cj,remux:Ej},{demux:Yo,remux:jm},{demux:aj,remux:jm},{demux:lj,remux:jm}];$m.splice(2,0,{demux:oj,remux:jm});class ow{constructor(e,t,i,n,r,o){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=o}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const r=i.transmuxing;r.executeStart=Ga();let o=new Uint8Array(e);const{currentTransmuxState:u,transmuxConfig:c}=this;n&&(this.currentTransmuxState=n);const{contiguous:d,discontinuity:f,trackSwitch:p,accurateTimeOffset:g,timeOffset:v,initSegmentChange:b}=n||u,{audioCodec:_,videoCodec:S,defaultInitPts:D,duration:R,initSegmentData:L}=c,M=Aj(o,t);if(M&&mc(M.method)){const z=this.getDecrypter(),I=$b(M.method);if(z.isSync()){let O=z.softwareDecrypt(o,M.key.buffer,M.iv.buffer,I);if(i.part>-1){const X=z.flush();O=X&&X.buffer}if(!O)return r.executeEnd=Ga(),dv(i);o=new Uint8Array(O)}else return this.asyncResult=!0,this.decryptionPromise=z.webCryptoDecrypt(o,M.key.buffer,M.iv.buffer,I).then(O=>{const W=this.push(O,null,i);return this.decryptionPromise=null,W}),this.decryptionPromise}const j=this.needsProbing(f,p);if(j){const z=this.configureTransmuxer(o);if(z)return this.logger.warn(`[transmuxer] ${z.message}`),this.observer.emit($.ERROR,$.ERROR,{type:It.MEDIA_ERROR,details:ke.FRAG_PARSING_ERROR,fatal:!1,error:z,reason:z.message}),r.executeEnd=Ga(),dv(i)}(f||p||b||j)&&this.resetInitSegment(L,_,S,R,t),(f||b||j)&&this.resetInitialTimestamp(D),d||this.resetContiguity();const V=this.transmux(o,M,v,g,i);this.asyncResult=wh(V);const P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,r.executeEnd=Ga(),V}flush(e){const t=e.transmuxing;t.executeStart=Ga();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const o=[],{timeOffset:u}=n;if(i){const p=i.flush();p&&o.push(this.push(p.buffer,null,e))}const{demuxer:c,remuxer:d}=this;if(!c||!d){t.executeEnd=Ga();const p=[dv(e)];return this.asyncResult?Promise.resolve(p):p}const f=c.flush(u);return wh(f)?(this.asyncResult=!0,f.then(p=>(this.flushRemux(o,p,e),o))):(this.flushRemux(o,f,e),this.asyncResult?Promise.resolve(o):o)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:r,id3Track:o,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===Et.MAIN?"level":"track"} ${i.level}`);const f=this.remuxer.remux(n,r,o,u,d,c,!0,this.id);e.push({remuxResult:f,chunkMeta:i}),i.transmuxing.executeEnd=Ga()}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:o,remuxer:u}=this;!o||!u||(o.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 o;return t&&t.method==="SAMPLE-AES"?o=this.transmuxSampleAes(e,t,i,n,r):o=this.transmuxUnencrypted(e,i,n,r),o}transmuxUnencrypted(e,t,i,n){const{audioTrack:r,videoTrack:o,id3Track:u,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,o,u,c,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,r){return this.demuxer.demuxSampleAes(e,t,i).then(o=>({remuxResult:this.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,i,n,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:n}=this;let r;for(let p=0,g=$m.length;p<g;p++){var o;if((o=$m[p].demux)!=null&&o.probe(e,this.logger)){r=$m[p];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 Ub(this.config)),e}}function Aj(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const dv=s=>({remuxResult:{},chunkMeta:s});function wh(s){return"then"in s&&s.then instanceof Function}class Cj{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 kj{constructor(e,t,i,n,r,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=o}}let lw=0;class SL{constructor(e,t,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=lw++,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 p;const g=(p=this.workerContext)==null?void 0:p.objectURL;g&&self.URL.revokeObjectURL(g);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($.ERROR,{type:It.OTHER_ERROR,details:ke.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 o=(c,d)=>{d=d||{},d.frag=this.frag||void 0,c===$.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(c,d)};this.observer=new Gb,this.observer.on($.FRAG_DECRYPTED,o),this.observer.on($.ERROR,o);const u=S2(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(r.workerPath||IU()){try{r.workerPath?(c.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=OU(r.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=NU());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:zi(r)})}catch(f){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,f),this.terminateWorker(),this.error=null,this.transmuxer=new ow(this.observer,u,r,"",t,e.logger)}return}}this.transmuxer=new ow(this.observer,u,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=lw++;const t=this.hls.config,i=S2(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:zi(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),MU(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,o,u,c,d,f){var p,g;d.transmuxing.start=self.performance.now();const{instanceNo:v,transmuxer:b}=this,_=o?o.start:r.start,S=r.decryptdata,D=this.frag,R=!(D&&r.cc===D.cc),L=!(D&&d.level===D.level),M=D?d.sn-D.sn:-1,j=this.part?d.part-this.part.index:-1,V=M===0&&d.id>1&&d.id===D?.stats.chunkCount,P=!L&&(M===1||M===0&&(j===1||V&&j<=0)),z=self.performance.now();(L||M||r.stats.parsing.start===0)&&(r.stats.parsing.start=z),o&&(j||!P)&&(o.stats.parsing.start=z);const I=!(D&&((p=r.initSegment)==null?void 0:p.url)===((g=D.initSegment)==null?void 0:g.url)),O=new kj(R,P,c,L,_,I);if(!P||R||I){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id===Et.MAIN?"level":"track"}: ${d.level} id: ${d.id}
discontinuity: ${R}
trackSwitch: ${L}
contiguous: ${P}
accurateTimeOffset: ${c}
timeOffset: ${_}
initSegmentChange: ${I}`);const W=new Cj(i,n,t,u,f);this.configureTransmuxer(W)}if(this.frag=r,this.part=o,this.workerContext)this.workerContext.worker.postMessage({instanceNo:v,cmd:"demux",data:e,decryptdata:S,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(b){const W=b.push(e,S,d,O);wh(W)?W.then(X=>{this.handleTransmuxComplete(X)}).catch(X=>{this.transmuxerError(X,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(W)}}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);wh(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($.ERROR,{type:It.MEDIA_ERROR,details:ke.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 uw=100;class Dj extends Vb{constructor(e,t,i){super(e,t,i,"audio-stream-controller",Et.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($.LEVEL_LOADED,this.onLevelLoaded,this),e.on($.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($.BUFFER_RESET,this.onBufferReset,this),e.on($.BUFFER_CREATED,this.onBufferCreated,this),e.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($.FRAG_LOADING,this.onFragLoading,this),e.on($.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off($.LEVEL_LOADED,this.onLevelLoaded,this),e.off($.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($.BUFFER_RESET,this.onBufferReset,this),e.off($.BUFFER_CREATED,this.onBufferCreated,this),e.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($.FRAG_LOADING,this.onFragLoading,this),e.off($.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:o}){if(i===Et.MAIN){const u=t.cc,c=this.fragCurrent;if(this.initPTS[u]={baseTime:n,timescale:r,trackId:o},this.log(`InitPTS for cc: ${u} found from main: ${n/r} (${n}/${r}) trackId: ${o}`),this.mainAnchor=t,this.state===He.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===He.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,o=this.getLevelDetails(),u=this.getLoadPosition(),c=UD(o,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===He.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=He.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(uw),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=He.IDLE):this.state=He.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case He.IDLE:this.doTickIdle();break;case He.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=He.WAITING_INIT_PTS}break}case He.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case He.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:n,complete:r}=e,o=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=He.FRAG_LOADING;const u=n.flush().buffer,c={frag:t,part:i,payload:u,networkDetails:null};this._handleFragmentLoadProgress(c),r&&super._handleFragmentLoadComplete(c)}else o&&o.cc!==e.frag.cc&&this.syncWithAnchor(o,e.frag)}else this.state=He.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,o=t.config;if(!this.buffering||!n&&!this.primaryPrefetch&&(this.startFragRequested||!o.startFragPrefetch)||!(i!=null&&i[r]))return;const u=i[r],c=u.details;if(!c||this.waitForLive(u)||this.waitForCdnTuneIn(c)){this.state=He.WAITING_TRACK,this.startFragRequested=!1;return}const d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,Vi.AUDIO,Et.AUDIO));const f=this.getFwdBufferInfo(d,Et.AUDIO);if(f===null)return;if(!this.switchingTrack&&this._streamEnded(f,c)){t.trigger($.BUFFER_EOS,{type:"audio"}),this.state=He.ENDED;return}const p=f.len,g=t.maxBufferLength,v=c.fragments,b=v[0].start,_=this.getLoadPosition(),S=this.flushing?_:f.end;if(this.switchingTrack&&n){const L=_;c.PTSKnown&&L<b&&(f.end>b||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=b+.05)}if(p>=g&&!this.switchingTrack&&S<v[v.length-1].start)return;let D=this.getNextFragment(S,c);if(D&&this.isLoopLoading(D,S)&&(D=this.getNextFragmentLoopLoading(D,c,f,Et.MAIN,g)),!D){this.bufferFlushed=!0;return}let R=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&R&&_s(D)&&!D.endList&&(!c.live||!this.loadingParts&&S<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(R)===Bs.OK&&(this.mainFragLoading=R=null),R&&_s(R))){if(D.start>R.end){const M=this.fragmentTracker.getFragAtPos(S,Et.MAIN);M&&M.end>R.end&&(R=M,this.mainFragLoading={frag:M,targetBufferTime:null})}if(D.start>R.end)return}this.loadFragment(D,u,S)}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!==He.STOPPED&&(this.setInterval(uw),this.state=He.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($.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:n}=this,{details:r,id:o,groupId:u,track:c}=t;if(!n){this.warn(`Audio tracks reset while loading track ${o} "${c.name}" of "${u}"`);return}const d=this.mainDetails;if(!d||r.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==He.STOPPED&&(this.state=He.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${o} "${c.name}" of "${u}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const f=n[o];let p=0;if(r.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(f.details){var g;p=this.alignPlaylists(r,f.details,(g=this.levelLastLoaded)==null?void 0:g.details)}r.alignedSliding||(sL(r,d),r.alignedSliding||Cp(r,d),p=r.fragmentStart)}f.details=r,this.levelLastLoaded=f,this.startFragRequested||this.setStartPosition(d,p),this.hls.trigger($.AUDIO_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.state===He.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=He.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{config:o,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 p=o.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let g=this.transmuxer;g||(g=this.transmuxer=new SL(this.hls,Et.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const v=this.initPTS[i.cc],b=(t=i.initSegment)==null?void 0:t.data;if(v!==void 0){const S=n?n.index:-1,D=S!==-1,R=new jb(i.level,i.sn,i.stats.chunkCount,r.byteLength,S,D);g.push(r,b,p,"",i,n,f.totalduration,!1,R,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:_}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new nL,complete:!1};_.push(new Uint8Array(r)),this.state!==He.STOPPED&&(this.state=He.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===Et.MAIN&&_s(t.frag)&&(this.mainFragLoading=t,this.state===He.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==Et.AUDIO){!this.audioOnly&&i.type===Et.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(_s(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger($.AUDIO_TRACK_SWITCHED,Li({},r)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=He.ERROR;return}switch(t.details){case ke.FRAG_GAP:case ke.FRAG_PARSING_ERROR:case ke.FRAG_DECRYPT_ERROR:case ke.FRAG_LOAD_ERROR:case ke.FRAG_LOAD_TIMEOUT:case ke.KEY_LOAD_ERROR:case ke.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Et.AUDIO,t);break;case ke.AUDIO_TRACK_LOAD_ERROR:case ke.AUDIO_TRACK_LOAD_TIMEOUT:case ke.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===He.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===oi.AUDIO_TRACK&&(this.state=He.IDLE);break;case ke.BUFFER_ADD_CODEC_ERROR:case ke.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case ke.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ke.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Vi.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Vi.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===He.ENDED&&(this.state=He.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,Et.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:o}=e,u=this.getCurrentContext(o);if(!u){this.resetWhenMissingContext(o);return}const{frag:c,part:d,level:f}=u,{details:p}=f,{audio:g,text:v,id3:b,initSegment:_}=r;if(this.fragContextChanged(c)||!p){this.fragmentTracker.removeFragment(c);return}if(this.state=He.PARSING,this.switchingTrack&&g&&this.completeAudioSwitch(this.switchingTrack),_!=null&&_.tracks){const S=c.initSegment||c;if(this.unhandledEncryptionError(_,c))return;this._bufferInitSegment(f,_.tracks,S,o),n.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:i,tracks:_.tracks})}if(g){const{startPTS:S,endPTS:D,startDTS:R,endDTS:L}=g;d&&(d.elementaryStreams[Vi.AUDIO]={startPTS:S,endPTS:D,startDTS:R,endDTS:L}),c.setElementaryStreamInfo(Vi.AUDIO,S,D,R,L),this.bufferFragmentData(g,c,d,o)}if(b!=null&&(t=b.samples)!=null&&t.length){const S=Bi({id:i,frag:c,details:p},b);n.trigger($.FRAG_PARSING_METADATA,S)}if(v){const S=Bi({id:i,frag:c,details:p},v);n.trigger($.FRAG_PARSING_USERDATA,S)}}_bufferInitSegment(e,t,i,n){if(this.state!==He.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=Et.AUDIO;const o=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${o}/${r.codec}]`),o&&o.split(",").length===1&&(r.levelCodec=o),this.hls.trigger($.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($.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.switchingTrack||n===Bs.NOT_LOADED||n===Bs.PARTIAL){var r;if(!_s(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=He.WAITING_INIT_PTS;const o=this.mainDetails;o&&o.fragmentStart!==t.details.fragmentStart&&Cp(t.details,o)}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:o,channels:u}=this.bufferedTrack;Ql({name:t,lang:i,assocLang:n,characteristics:r,audioCodec:o,channels:u},e,Fl)||(_p(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($.AUDIO_TRACK_SWITCHED,Li({},e))}}class Qb extends yr{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 o=0;o<n.length;o++){const u=n[o];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=o;break}else c===e.substring(0,c.length)&&(r=o)}if(r!==-1){const o=n[r],u=parseInt(o["LAST-MSN"])||t.lastPartSn;let c=parseInt(o["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&&E2(i);return new w2(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,o=self.performance.now(),u=r.loading.first?Math.max(0,o-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(p=>{p.setStart(p.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){TU(i,n,this);const R=n.playlistParsingError;if(R){this.warn(R);const L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var d;const{networkDetails:M}=t;L.trigger($.ERROR,{type:It.NETWORK_ERROR,details:ke.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:R,reason:R.message,level:t.level||void 0,parent:(d=n.fragments[0])==null?void 0:d.type,networkDetails:M,stats:r});return}n.playlistParsingError=null}}n.requestScheduled===-1&&(n.requestScheduled=r.loading.start);const p=this.hls.mainForwardBufferInfo,g=p?p.end-p.len:0,v=(n.edge-g)*1e3,b=ZD(n,v);if(n.requestScheduled+b<o?n.requestScheduled=o:n.requestScheduled+=b,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;let _,S,D;if(n.canBlockReload&&n.endSN&&n.advanced){const R=this.hls.config.lowLatencyMode,L=n.lastPartSn,M=n.endSN,j=n.lastPartIndex,V=j!==-1,P=L===M;V?P?(S=M+1,D=R?0:j):(S=L,D=R?j+1:n.maxPartIndex):S=M+1;const z=n.age,I=z+n.ageHeader;let O=Math.min(I-n.partTarget,n.targetduration*1.5);if(O>0){if(I>n.targetduration*3)this.log(`Playlist last advanced ${z.toFixed(2)}s ago. Omitting segment and part directives.`),S=void 0,D=void 0;else if(i!=null&&i.tuneInGoal&&I-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${O} with playlist age: ${n.age}`),O=0;else{const W=Math.floor(O/n.targetduration);if(S+=W,D!==void 0){const X=Math.round(O%n.targetduration/n.partTarget);D+=X}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${z.toFixed(2)}s goal: ${O} skip sn ${W} to part ${D}`)}n.tuneInGoal=O}if(_=this.getDeliveryDirectives(n,t.deliveryDirectives,S,D),R||!P){n.requestScheduled=o,this.loadingPlaylist(f,_);return}}else(n.canBlockReload||n.canSkipUntil)&&(_=this.getDeliveryDirectives(n,t.deliveryDirectives,S,D));_&&S!==void 0&&n.canBlockReload&&(n.requestScheduled=r.loading.first+Math.max(b-u*2,b/2)),this.scheduleLoading(f,_,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(),o=n.requestScheduled;if(r>=o){this.loadingPlaylist(e,t);return}const u=o-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=E2(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,r=Fm.No),new w2(i,n,r)}checkRetry(e){const t=e.details,i=Sp(e),n=e.errorAction,{action:r,retryCount:o=0,retryConfig:u}=n||{},c=!!n&&!!u&&(r===Ws.RetryRequest||!n.resolved&&r===Ws.SendAlternateToPenaltyBox);if(c){var d;if(o>=u.maxNumRetry)return!1;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const f=Fb(u,o);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),f),this.warn(`Retrying playlist loading ${o+1}/${u.maxNumRetry} after "${t}" in ${f}ms`)}e.levelRetry=!0,n.resolved=!0}return c}}function EL(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Ah(s[t].attrs,e[t].attrs))return!1;return!0}function Ah(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 kx(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}class Lj extends Qb{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($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.LEVEL_LOADING,this.onLevelLoading,this),e.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.LEVEL_LOADING,this.onLevelLoading,this),e.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.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,o=this.tracksInGroup[i];if(!o||o.groupId!==n){this.warn(`Audio track with id:${i} and group:${n} not found in active group ${o?.groupId}`);return}const u=o.details;o.details=t.details,this.log(`Audio track ${i} "${o.name}" lang:${o.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(g=>!i||i.indexOf(g.groupId)!==-1);if(u.length)this.selectDefaultTrack&&!u.some(g=>g.default)&&(this.selectDefaultTrack=!1),u.forEach((g,v)=>{g.id=v});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=u;const c=this.hls.config.audioPreference;if(!r&&c){const g=la(c,u,Fl);if(g>-1)r=u[g];else{const v=la(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($.AUDIO_TRACKS_UPDATED,f);const p=this.trackId;if(d!==-1&&p===-1)this.setAudioTrack(d);else if(u.length&&p===-1){var o;const g=new Error(`No audio track selected for current audio group-ID(s): ${(o=this.groupIds)==null?void 0:o.join(",")} track count: ${u.length}`);this.warn(g.message),this.hls.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===oi.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&&Ql(e,n,Fl))return n;const r=la(e,this.tracksInGroup,Fl);if(r>-1){const o=this.tracksInGroup[r];return this.setAudioTrack(r),o}else if(n){let o=t.loadLevel;o===-1&&(o=t.firstAutoLevel);const u=H6(e,t.levels,i,o,Fl);if(u===-1)return null;t.nextLoadLevel=u}if(e.channels||e.audioCodec){const o=la(e,i);if(o>-1)return i[o]}}}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($.AUDIO_TRACK_SWITCHING,Li({},n)),r))return;const o=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(o)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(!(this.selectDefaultTrack&&!n.default)&&(!e||Ql(e,n,Fl)))return i}if(e){const{name:i,lang:n,assocLang:r,characteristics:o,audioCodec:u,channels:c}=e;for(let d=0;d<t.length;d++){const f=t[d];if(Ql({name:i,lang:n,assocLang:r,characteristics:o,audioCodec:u,channels:c},f,Fl))return d}for(let d=0;d<t.length;d++){const f=t[d];if(Ah(e.attrs,f.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const f=t[d];if(Ah(e.attrs,f.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&_p(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),o=e.details,u=o?.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&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger($.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}}class Rj{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 o=(i=this.tracks[e])==null?void 0:i.buffer;o!=null&&o.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 cw=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,wL="HlsJsTrackRemovedError";class Ij extends Error{constructor(e){super(e),this.name=wL}}class Nj extends yr{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($.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=t6(il(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($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.BUFFER_RESET,this.onBufferReset,this),e.on($.BUFFER_APPENDING,this.onBufferAppending,this),e.on($.BUFFER_CODECS,this.onBufferCodecs,this),e.on($.BUFFER_EOS,this.onBufferEos,this),e.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($.FRAG_PARSED,this.onFragParsed,this),e.on($.FRAG_CHANGED,this.onFragChanged,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.BUFFER_RESET,this.onBufferReset,this),e.off($.BUFFER_APPENDING,this.onBufferAppending,this),e.off($.BUFFER_CODECS,this.onBufferCodecs,this),e.off($.BUFFER_EOS,this.onBufferEos,this),e.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($.FRAG_PARSED,this.onFragParsed,this),e.off($.FRAG_CHANGED,this.onFragChanged,this),e.off($.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 o=this.isQueued();(r||o)&&this.warn(`Transfering MediaSource with${o?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const n=this.transferData;return!this.sourceBufferCount&&n&&n.mediaSource===t?Bi(i,n.tracks):this.sourceBuffers.forEach(r=>{const[o]=r;o&&(i[o]=Bi({},this.tracks[o]),this.removeBuffer(o)),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=il(this.appendSource);if(n){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const o=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(o),r)this._objectUrl=i.src,this.attachTransferred();else{const u=this._objectUrl=self.URL.createObjectURL(o);if(this.appendSource)try{i.removeAttribute("src");const c=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||c&&o instanceof c,dw(i),Oj(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,o=r?r.length:0,u=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&r&&o){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: ${zi(i,(c,d)=>c==="initSegment"?void 0:d)};
transfer tracks: ${zi(n,(c,d)=>c==="initSegment"?void 0:d)}}`),!TD(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($.MEDIA_DETACHING,{}),this.onMediaAttaching($.MEDIA_ATTACHING,t),e.currentTime=f;return}this.transferData=void 0,r.forEach(c=>{const d=c,f=n[d];if(f){const p=f.buffer;if(p){const g=this.fragmentTracker,v=f.id;if(g.hasFragments(v)||g.hasParts(v)){const S=Xt.getBuffered(p);g.detectEvictedFragments(d,S,v,null,!0)}const b=hv(d),_=[d,p];this.sourceBuffers[b]=_,p.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:o}=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||(o&&self.URL.revokeObjectURL(o),this.mediaSrc===o?(n.removeAttribute("src"),this.appendSource&&dw(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger($.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[hv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Rj(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 o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),u=!o&&this.sourceBufferCount&&this.media&&r.some(c=>!n[c]);if(o||u){this.warn(`Unsupported transition between "${Object.keys(n)}" and "${r}" SourceBuffers`);return}r.forEach(c=>{var d,f;const p=t[c],{id:g,codec:v,levelCodec:b,container:_,metadata:S,supplemental:D}=p;let R=n[c];const L=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[c],M=L!=null&&L.buffer?L:R,j=M?.pendingCodec||M?.codec,V=M?.levelCodec;R||(R=n[c]={buffer:void 0,listeners:[],codec:v,supplemental:D,container:_,levelCodec:b,metadata:S,id:g});const P=Bm(j,V),z=P?.replace(cw,"$1");let I=Bm(v,b);const O=(f=I)==null?void 0:f.replace(cw,"$1");I&&P&&z!==O&&(c.slice(0,5)==="audio"&&(I=bp(I,this.appendSource)),this.log(`switching codec ${j} to ${I}`),I!==(R.pendingCodec||R.codec)&&(R.pendingCodec=I),R.container=_,this.appendChangeType(c,_,I))}),(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 o=this.tracks[e];if(o){const u=o.buffer;u!=null&&u.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),u.changeType(n),o.codec=i,o.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn(`Failed to change ${e} SourceBuffer type`,o)}};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,Et.MAIN))==null?void 0:t.gap)===!0)return;const o={label:"block-audio",execute:()=>{var u;const c=this.tracks.video;(this.lastVideoAppendEnd>n||c!=null&&c.buffer&&Xt.isBuffered(c.buffer,n)||((u=this.fragmentTracker.getAppendedFrag(n,Et.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:o,frag:e},this.append(o,"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:o,frag:u,part:c,chunkMeta:d,offset:f}=t,p=d.buffering[r],{sn:g,cc:v}=u,b=self.performance.now();p.start=b;const _=u.stats.buffering,S=c?c.stats.buffering:null;_.start===0&&(_.start=b),S&&S.start===0&&(S.start=b);const D=i.audio;let R=!1;r==="audio"&&D?.container==="audio/mpeg"&&(R=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const L=i.video,M=L?.buffer;if(M&&g!=="initSegment"){const P=c||u,z=this.blockedAudioAppend;if(r==="audio"&&o!=="main"&&!this.blockedAudioAppend&&!(L.ending||L.ended)){const O=P.start+P.duration*.05,W=M.buffered,X=this.currentOp("video");!W.length&&!X?this.blockAudio(P):!X&&!Xt.isBuffered(M,O)&&this.lastVideoAppendEnd<O&&this.blockAudio(P)}else if(r==="video"){const I=P.end;if(z){const O=z.frag.start;(I>O||I<this.lastVideoAppendEnd||Xt.isBuffered(M,O))&&this.unblockAudio()}this.lastVideoAppendEnd=I}}const j=(c||u).start,V={label:`append-${r}`,execute:()=>{var P;p.executeStart=self.performance.now();const z=(P=this.tracks[r])==null?void 0:P.buffer;z&&(R?this.updateTimestampOffset(z,j,.1,r,g,v):f!==void 0&&yt(f)&&this.updateTimestampOffset(z,f,1e-6,r,g,v)),this.appendExecutor(n,r)},onStart:()=>{},onComplete:()=>{const P=self.performance.now();p.executeEnd=p.end=P,_.first===0&&(_.first=P),S&&S.first===0&&(S.first=P);const z={};this.sourceBuffers.forEach(([I,O])=>{I&&(z[I]=Xt.getBuffered(O))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger($.BUFFER_APPENDED,{type:r,frag:u,part:c,chunkMeta:d,parent:u.type,timeRanges:z})},onError:P=>{var z;const I={type:It.MEDIA_ERROR,parent:u.type,details:ke.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:u,part:c,chunkMeta:d,error:P,err:P,fatal:!1},O=(z=this.media)==null?void 0:z.error;if(P.code===DOMException.QUOTA_EXCEEDED_ERR||P.name=="QuotaExceededError"||"quota"in P)I.details=ke.BUFFER_FULL_ERROR;else if(P.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!O)I.errorAction=fc(!0);else if(P.name===wL&&this.sourceBufferCount===0)I.errorAction=fc(!0);else{const W=++this.appendErrors[r];this.warn(`Failed ${W}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${O||"no media error"})`),(W>=this.hls.config.appendErrorMaxRetry||O)&&(I.fatal=!0)}this.hls.trigger($.ERROR,I)}};this.log(`queuing "${r}" append sn: ${g}${c?" p: "+c.index:""} of ${u.type===Et.MAIN?"level":"track"} ${u.level} cc: ${v}`),this.append(V,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($.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(([o])=>{o&&this.append(this.getFlushOp(o,n,r),o)})}onFragParsed(e,t){const{frag:i,part:n}=t,r=[],o=n?n.elementaryStreams:i.elementaryStreams;o[Vi.AUDIOVIDEO]?r.push("audiovideo"):(o[Vi.AUDIO]&&r.push("audio"),o[Vi.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($.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(([o])=>{if(o){const u=this.tracks[o];(!t.type||t.type===o)&&(u.ending=!0,u.ended||(u.ended=!0,this.log(`${o} buffer reached EOS`)))}});const n=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([o])=>{var u;return o&&!((u=this.tracks[o])!=null&&u.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:o}=this;if(!o||o.readyState!=="open"){o&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${o.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),o.endOfStream(),this.hls.trigger($.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger($.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===ke.BUFFER_APPEND_ERROR&&t.frag){var i;const n=(i=t.errorAction)==null?void 0:i.nextAutoLevel;yt(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,o=t.levelTargetDuration,u=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(yt(u)&&u>=0){const d=Math.max(u,o),f=Math.floor(r/o)*o-d;this.flushBackBuffer(r,o,f)}const c=n.frontBufferFlushThreshold;if(yt(c)&&c>0){const d=Math.max(n.maxBufferLength,c),f=Math.max(d,o),p=Math.floor(r/o)*o+f;this.flushFrontBuffer(r,o,p)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const u=Xt.getBuffered(r);if(u.length>0&&i>u.start(0)){var o;this.hls.trigger($.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[n];if((o=this.details)!=null&&o.live)this.hls.trigger($.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($.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const o=Xt.getBuffered(r),u=o.length;if(u<2)return;const c=o.start(u-1),d=o.end(u-1);if(i>c||e>=c&&e<=d)return;this.hls.trigger($.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 yt(r)?{duration:r}:null;const o=this.media.duration,u=yt(i.duration)?i.duration:0;return n>u&&n>o||!yt(o)?{duration:n}:null}updateMediaSource({duration:e,start:t,end:i}){const n=this.mediaSource;!this.media||!n||n.readyState!=="open"||(n.duration!==e&&(yt(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}) ${zi(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($.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($.ERROR,{type:It.MEDIA_ERROR,details:ke.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 o=r,u=e[o];if(this.isPending(u)){const c=this.getTrackCodec(u,o),d=`${u.container};codecs=${c}`;u.codec=c,this.log(`creating sourceBuffer(${d})${this.currentOp(o)?" Queued":""} ${zi(u)}`);try{const f=i.addSourceBuffer(d),p=hv(o),g=[o,f];t[p]=g,u.buffer=f}catch(f){var n;this.error(`error while trying to add sourceBuffer: ${f.message}`),this.shiftAndExecuteNext(o),(n=this.operationQueue)==null||n.removeBlockers(),delete this.tracks[o],this.hls.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,sourceBufferName:o,mimeType:d,parent:u.id});return}this.trackSourceBuffer(o,u)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let n=e.codec;i&&(t==="video"||t==="audiovideo")&&bh(i,"video")&&(n=S6(n,i));const r=Bm(n,e.levelCodec);return r?t.slice(0,5)==="audio"?bp(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,o)=>{const u=o.removedRanges;u!=null&&u.length&&this.hls.trigger($.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($.ERROR,{type:It.MEDIA_ERROR,details:ke.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const r=this.currentOp(e);r&&r.onError(n)}updateTimestampOffset(e,t,i,n,r,o){const u=t-e.timestampOffset;Math.abs(u)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${o})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:n,mediaSource:r}=this,o=this.tracks[e],u=o?.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=yt(n.duration)?n.duration:1/0,d=yt(r.duration)?r.duration:1/0,f=Math.max(0,t),p=Math.min(i,c,d);p>f&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${f},${p}] from the ${e} SourceBuffer`),u.remove(f,p)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],n=i?.buffer;if(!n)throw new Ij(`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(o=>this.appendBlocker(o));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(o=>{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 o=i.bind(this,e);n.listeners.push({event:t,listener:o}),r.addEventListener(t,o)}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 dw(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function Oj(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function hv(s){return s==="audio"?1:0}class Zb{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($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($.BUFFER_CODECS,this.onBufferCodecs,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($.BUFFER_CODECS,this.onBufferCodecs,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,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&&yt(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,Zb.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 o=Math.max(t,i);for(let u=0;u<e.length;u+=1){const c=e[u];if((c.width>=o||c.height>=o)&&n(c,e[u+1])){r=u;break}}return r}}const Mj={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},In=Mj,Pj={HLS:"h"},Bj=Pj;class ga{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof ga?i:new ga(i))),this.value=e,this.params=t}}const Fj="Dict";function Uj(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 jj(s,e,t,i){return new Error(`failed to ${s} "${Uj(e)}" as ${t}`,{cause:i})}function ya(s,e,t){return jj("serialize",s,e,t)}class AL{constructor(e){this.description=e}}const hw="Bare Item",$j="Boolean";function Hj(s){if(typeof s!="boolean")throw ya(s,$j);return s?"?1":"?0"}function Vj(s){return btoa(String.fromCharCode(...s))}const Gj="Byte Sequence";function zj(s){if(ArrayBuffer.isView(s)===!1)throw ya(s,Gj);return`:${Vj(s)}:`}const qj="Integer";function Kj(s){return s<-999999999999999||999999999999999<s}function CL(s){if(Kj(s))throw ya(s,qj);return s.toString()}function Yj(s){return`@${CL(s.getTime()/1e3)}`}function kL(s,e){if(s<0)return-kL(-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 Wj="Decimal";function Xj(s){const e=kL(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ya(s,Wj);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Qj="String",Zj=/[\x00-\x1f\x7f]+/;function Jj(s){if(Zj.test(s))throw ya(s,Qj);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function e7(s){return s.description||s.toString().slice(7,-1)}const t7="Token";function fw(s){const e=e7(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw ya(e,t7);return e}function Dx(s){switch(typeof s){case"number":if(!yt(s))throw ya(s,hw);return Number.isInteger(s)?CL(s):Xj(s);case"string":return Jj(s);case"symbol":return fw(s);case"boolean":return Hj(s);case"object":if(s instanceof Date)return Yj(s);if(s instanceof Uint8Array)return zj(s);if(s instanceof AL)return fw(s);default:throw ya(s,hw)}}const i7="Key";function Lx(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw ya(s,i7);return s}function Jb(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${Lx(e)}`:`;${Lx(e)}=${Dx(t)}`).join("")}function DL(s){return s instanceof ga?`${Dx(s.value)}${Jb(s.params)}`:Dx(s)}function s7(s){return`(${s.value.map(DL).join(" ")})${Jb(s.params)}`}function n7(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw ya(s,Fj);const t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([n,r])=>{r instanceof ga||(r=new ga(r));let o=Lx(n);return r.value===!0?o+=Jb(r.params):(o+="=",Array.isArray(r.value)?o+=s7(r):o+=DL(r)),o}).join(`,${i}`)}function LL(s,e){return n7(s,e)}const Qr="CMCD-Object",gs="CMCD-Request",Ol="CMCD-Session",Vo="CMCD-Status",r7={br:Qr,ab:Qr,d:Qr,ot:Qr,tb:Qr,tpb:Qr,lb:Qr,tab:Qr,lab:Qr,url:Qr,pb:gs,bl:gs,tbl:gs,dl:gs,ltc:gs,mtp:gs,nor:gs,nrr:gs,rc:gs,sn:gs,sta:gs,su:gs,ttfb:gs,ttfbb:gs,ttlb:gs,cmsdd:gs,cmsds:gs,smrt:gs,df:gs,cs:gs,ts:gs,cid:Ol,pr:Ol,sf:Ol,sid:Ol,st:Ol,v:Ol,msd:Ol,bs:Vo,bsd:Vo,cdn:Vo,rtp:Vo,bg:Vo,pt:Vo,ec:Vo,e:Vo},a7={REQUEST:gs};function o7(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 l7(s,e){const t={};if(!s)return t;const i=Object.keys(s),n=e?o7(e):{};return i.reduce((r,o)=>{var u;const c=r7[o]||n[o]||a7.REQUEST,d=(u=r[c])!==null&&u!==void 0?u:r[c]={};return d[o]=s[o],r},t)}function u7(s){return["ot","sf","st","e","sta"].includes(s)}function c7(s){return typeof s=="number"?yt(s):s!=null&&s!==""&&s!==!1}const RL="event";function d7(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 Hm=s=>Math.round(s),Rx=(s,e)=>Array.isArray(s)?s.map(t=>Rx(t,e)):s instanceof ga&&typeof s.value=="string"?new ga(Rx(s.value,e),s.params):(e.baseUrl&&(s=d7(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),Sm=s=>Hm(s/100)*100,h7=(s,e)=>{let t=s;return e.version>=2&&(s instanceof ga&&typeof s.value=="string"?t=new ga([s]):typeof s=="string"&&(t=[s])),Rx(t,e)},f7={br:Hm,d:Hm,bl:Sm,dl:Sm,mtp:Sm,nor:h7,rtp:Sm,tb:Hm},IL="request",NL="response",eT=["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"],m7=["e"],p7=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function dg(s){return p7.test(s)}function g7(s){return eT.includes(s)||m7.includes(s)||dg(s)}const OL=["d","dl","nor","ot","rtp","su"];function y7(s){return eT.includes(s)||OL.includes(s)||dg(s)}const v7=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function x7(s){return eT.includes(s)||OL.includes(s)||v7.includes(s)||dg(s)}const b7=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function T7(s){return b7.includes(s)||dg(s)}const _7={[NL]:x7,[RL]:g7,[IL]:y7};function ML(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||1,n=e.reportingMode||IL,r=i===1?T7:_7[n];let o=Object.keys(s).filter(r);const u=e.filter;typeof u=="function"&&(o=o.filter(u));const c=n===NL||n===RL;c&&!o.includes("ts")&&o.push("ts"),i>1&&!o.includes("v")&&o.push("v");const d=Bi({},f7,e.formatters),f={version:i,reportingMode:n,baseUrl:e.baseUrl};return o.sort().forEach(p=>{let g=s[p];const v=d[p];if(typeof v=="function"&&(g=v(g,f)),p==="v"){if(i===1)return;g=i}p=="pr"&&g===1||(c&&p==="ts"&&!yt(g)&&(g=Date.now()),c7(g)&&(u7(p)&&typeof g=="string"&&(g=new AL(g)),t[p]=g))}),t}function S7(s,e={}){const t={};if(!s)return t;const i=ML(s,e),n=l7(i,e?.customHeaderMap);return Object.entries(n).reduce((r,[o,u])=>{const c=LL(u,{whitespace:!1});return c&&(r[o]=c),r},t)}function E7(s,e,t){return Bi(s,S7(e,t))}const w7="CMCD";function A7(s,e={}){return s?LL(ML(s,e),{whitespace:!1}):""}function C7(s,e={}){if(!s)return"";const t=A7(s,e);return encodeURIComponent(t)}function k7(s,e={}){if(!s)return"";const t=C7(s,e);return`${w7}=${t}`}const mw=/CMCD=[^&#]+/;function D7(s,e,t){const i=k7(e,t);if(!i)return s;if(mw.test(s))return s.replace(mw,i);const n=s.includes("?")?"&":"?";return`${s}${n}${i}`}class L7{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:In.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:o}=n,u=this.hls.levels[r.level],c=this.getObjectType(r),d={d:(o||r).duration*1e3,ot:c};(c===In.VIDEO||c===In.AUDIO||c==In.MUXED)&&(d.br=u.bitrate/1e3,d.tb=this.getTopBandwidth(c)/1e3,d.bl=this.getBufferLength(c));const f=o?this.getNextPart(o):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($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHED,this.onMediaDetached,this),e.on($.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHED,this.onMediaDetached,this),e.off($.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,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:Bj.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Bi(t,this.createData());const i=t.ot===In.INIT||t.ot===In.VIDEO||t.ot===In.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((o,u)=>(n.includes(u)&&(o[u]=t[u]),o),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),E7(e.headers,t,r)):e.url=D7(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:o}=n;for(let u=r.length-1;u>=0;u--){const c=r[u];if(c.index===i&&c.fragment.sn===o)return r[u+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return In.TIMED_TEXT;if(e.sn==="initSegment")return In.INIT;if(t==="audio")return In.AUDIO;if(t==="main")return this.hls.audioTracks.length?In.VIDEO:In.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===In.AUDIO)i=n.audioTracks;else{const r=n.maxAutoLevel,o=r>-1?r+1:n.levels.length;i=n.levels.slice(0,o)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===In.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Xt.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,o,u){t(r),this.loader.load(r,o,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,o,u){t(r),this.loader.load(r,o,u)}}}}const R7=3e5;class I7 extends yr{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($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.ERROR,this.onError,this))}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===Ws.SendAlternateToPenaltyBox&&i.flags===Zn.MoveAllAlternatesMatchingHost){const n=this.levels;let r=this._pathwayPriority,o=this.pathwayId;if(t.context){const{groupId:u,pathwayId:c,type:d}=t.context;u&&n?o=this.getPathwayForGroupId(u,d,o):c&&(o=c)}o in this.penalizedPathways||(this.penalizedPathways[o]=performance.now()),!r&&n&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==o),t.details===ke.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: ${o} levels: ${n&&n.length} priorities: ${zi(r)} penalized: ${zi(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]>R7&&delete i[r]});for(let r=0;r<e.length;r++){const o=e[r];if(o in i)continue;if(o===this.pathwayId)return;const u=this.hls.nextLoadLevel,c=this.hls.levels[u];if(t=this.getLevelsForPathway(o),t.length>0){this.log(`Setting Pathway to "${o}"`),this.pathwayId=o,tL(t),this.hls.trigger($.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===oi.AUDIO_TRACK&&n[r].hasAudioGroup(e)||t===oi.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:o,"BASE-ID":u,"URI-REPLACEMENT":c}=r;if(t.some(f=>f.pathwayId===o))return;const d=this.getLevelsForPathway(u).map(f=>{const p=new os(f.attrs);p["PATHWAY-ID"]=o;const g=p.AUDIO&&`${p.AUDIO}_clone_${o}`,v=p.SUBTITLES&&`${p.SUBTITLES}_clone_${o}`;g&&(i[p.AUDIO]=g,p.AUDIO=g),v&&(n[p.SUBTITLES]=v,p.SUBTITLES=v);const b=PL(f.uri,p["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),_=new _h({attrs:p,audioCodec:f.audioCodec,bitrate:f.bitrate,height:f.height,name:f.name,url:b,videoCodec:f.videoCodec,width:f.width});if(f.audioGroups)for(let S=1;S<f.audioGroups.length;S++)_.addGroupId("audio",`${f.audioGroups[S]}_clone_${o}`);if(f.subtitleGroups)for(let S=1;S<f.subtitleGroups.length;S++)_.addGroupId("text",`${f.subtitleGroups[S]}_clone_${o}`);return _});t.push(...d),pw(this.audioTracks,i,c,o),pw(this.subtitleTracks,n,c,o)})}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},o=t.steeringManifestLoadPolicy.default,u=o.errorRetry||o.timeoutRetry||{},c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:(f,p,g,v)=>{this.log(`Loaded steering manifest: "${n}"`);const b=f.data;if(b?.VERSION!==1){this.log(`Steering VERSION ${b.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=b.TTL;const{"RELOAD-URI":_,"PATHWAY-CLONES":S,"PATHWAY-PRIORITY":D}=b;if(_)try{this.uri=new self.URL(_,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${_}`);return}this.scheduleRefresh(this.uri||g.url),S&&this.clonePathways(S);const R={steeringManifest:b,url:n.toString()};this.hls.trigger($.STEERING_MANIFEST_LOADED,R),D&&this.updatePathwayPriority(D)},onError:(f,p,g,v)=>{if(this.log(`Error loading steering manifest: ${f.code} ${f.text} (${p.url})`),this.stopLoad(),f.code===410){this.enabled=!1,this.log(`Steering manifest ${p.url} no longer available`);return}let b=this.timeToLoad*1e3;if(f.code===429){const _=this.loader;if(typeof _?.getResponseHeader=="function"){const S=_.getResponseHeader("Retry-After");S&&(b=parseFloat(S)*1e3)}this.log(`Steering manifest ${p.url} rate limited`);return}this.scheduleRefresh(this.uri||p.url,b)},onTimeout:(f,p,g)=>{this.log(`Timeout loading steering manifest (${p.url})`),this.scheduleRefresh(this.uri||p.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 pw(s,e,t,i){s&&Object.keys(e).forEach(n=>{const r=s.filter(o=>o.groupId===n).map(o=>{const u=Bi({},o);return u.details=void 0,u.attrs=new os(u.attrs),u.url=u.attrs.URI=PL(o.url,o.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 PL(s,e,t,i){const{HOST:n,PARAMS:r,[t]:o}=i;let u;e&&(u=o?.[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 pc extends yr{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=pc.CDMCleanupPromise?[pc.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 o=Object.keys(this.keySystemAccessPromises);o.length||(o=eh(this.config));const u=o.map(nv).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(u)}this.keyFormatPromise.then(o=>{const u=Um(o);if(i!=="sinf"||u!==ls.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${u}`);return}let c;try{const v=Ps(new Uint8Array(n)),b=Hb(JSON.parse(v).sinf),_=LD(b);if(!_)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(_.subarray(8,24))}catch(v){this.warn(`${r} Failed to parse sinf: ${v}`);return}const d=Qs(c),{keyIdToKeySessionPromise:f,mediaKeySessions:p}=this;let g=f[d];for(let v=0;v<p.length;v++){const b=p[v],_=b.decryptdata;if(!_.keyId)continue;const S=Qs(_.keyId);if(wp(c,_.keyId)||_.uri.replace(/-/g,"").indexOf(d)!==-1){if(g=f[S],!g)continue;if(_.pssh)break;delete f[S],_.pssh=new Uint8Array(n),_.keyId=c,g=f[d]=g.then(()=>this.generateRequestWithPreferredKeySession(b,i,n,"encrypted-event-key-match")),g.catch(D=>this.handleError(D));break}}g||this.handleError(new Error(`Key ID ${d} not encountered in playlist. Key-system sessions ${p.length}.`))}).catch(o=>this.handleError(o))}},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($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on($.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on($.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off($.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off($.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t?.[e];if(n)return n.licenseUrl;if(e===ls.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=(o,u,c)=>!!o&&c.indexOf(o)===u,n=t.map(o=>o.audioCodec).filter(i),r=t.map(o=>o.videoCodec).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise((o,u)=>{const c=d=>{const f=d.shift();this.getMediaKeysPromise(f,n,r).then(p=>o({keySystem:f,mediaKeys:p})).catch(p=>{d.length?c(d):p instanceof Qn?u(p):u(new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_NO_ACCESS,error:p,fatal:!0},p.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 KD===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=hU(e,t,i,this.config.drmSystemOptions||{});let o=this.keySystemAccessPromises[e],u=(n=o)==null?void 0:n.keySystemAccess;if(!u){this.log(`Requesting encrypted media "${e}" key-system access with config: ${zi(r)}`),u=this.requestMediaKeySystemAccess(e,r);const c=o=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 p=c.mediaKeys=d.createMediaKeys().then(g=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,f.then(v=>v?this.setMediaKeysServerCertificate(g,e,v):g)));return p.catch(g=>{this.error(`Failed to create media-keys for "${e}"}: ${g}`)}),p})}return u.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Qs(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=Em(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 ${Qs(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})=>nv(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=nv(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=eh(this.config),i=e.map(Um).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=N7(e,t[i]);if(n)return n}}loadKey(e){const t=e.keyInfo.decryptdata,i=Em(t),n=this.bannedKeyIds[i];if(n||this.getKeyStatus(t)==="internal-error"){const u=gw(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 o=this.keyIdToKeySessionPromise[i];if(!o){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 o.catch(u=>{if(u instanceof Qn){const c=Li({},u.data);this.getKeyStatus(t)==="internal-error"&&(c.decryptdata=t);const d=new Qn(c,u.message);this.handleError(d,e.frag)}}),o}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Qn){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${Qs(i.keyId||[])})`:""}`),this.hls.trigger($.ERROR,e.data)}else this.error(e.message),this.hls.trigger($.ERROR,{type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Em(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=Um(e.keyFormat),r=n?[n]:eh(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=eh(this.config)),e.length===0)throw new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${zi({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,o)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return o(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(r).catch(o)}}));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 o=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(o)try{const b=o.call(this.hls,t,i,e);if(!b)throw new Error("Invalid response from configured generateRequest filter");t=b.initDataType,i=b.initData?b.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(b){if(this.warn(b.message),this.hls&&this.hls.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const u=Em(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 Gb,f=e._onmessage=b=>{const _=e.mediaKeysSession;if(!_){d.emit("error",new Error("invalid state"));return}const{messageType:S,message:D}=b;this.log(`"${S}" message event for session "${_.sessionId}" message size: ${D.byteLength}`),S==="license-request"||S==="license-renewal"?this.renewLicense(e,D).catch(R=>{d.eventNames().length?d.emit("error",R):this.handleError(R)}):S==="license-release"?e.keySystem===ls.FAIRPLAY&&this.updateKeySession(e,Sx("acknowledged")).then(()=>this.removeSession(e)).catch(R=>this.handleError(R)):this.warn(`unhandled media key message type "${S}"`)},p=(b,_)=>{_.keyStatus=b;let S;b.startsWith("usable")?d.emit("resolved"):b==="internal-error"||b==="output-restricted"||b==="output-downscaled"?S=gw(b,_.decryptdata):b==="expired"?S=new Error(`key expired (keyId: ${u})`):b==="released"?S=new Error("key released"):b==="status-pending"||this.warn(`unhandled key status change "${b}" (keyId: ${u})`),S&&(d.eventNames().length?d.emit("error",S):this.handleError(S))},g=e._onkeystatuseschange=b=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}const S=this.getKeyStatuses(e);if(!Object.keys(S).some(M=>S[M]!=="status-pending"))return;if(S[u]==="expired"){this.log(`Expired key ${zi(S)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let R=S[u];if(R)p(R,e);else{var L;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(L=e.keyStatusTimeouts)[u]||(L[u]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const j=this.getKeyStatus(e.decryptdata);if(j&&j!=="status-pending")return this.log(`No status for keyId ${u} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${j} from other session.`),p(j,e);this.log(`key status for ${u} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),R="internal-error",p(R,e)},1e3)),this.log(`No status for keyId ${u} (${zi(S)}).`)}};vn(e.mediaKeysSession,"message",f),vn(e.mediaKeysSession,"keystatuseschange",g);const v=new Promise((b,_)=>{d.on("error",_),d.on("resolved",b)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${u} URI: ${c}`)}).catch(b=>{throw new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_NO_SESSION,error:b,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>(d.removeAllListeners(),this.removeSession(e).then(()=>{throw b}))).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===ls.PLAYREADY&&r.length===16){const u=Qs(r);t[u]=i,zD(r)}const o=Qs(r);i==="internal-error"&&(this.bannedKeyIds[o]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${o} key-session "${e.mediaKeysSession.sessionId}"`),t[o]=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((o,u)=>{const c={responseType:"arraybuffer",url:r},d=t.certLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:(g,v,b,_)=>{o(g.data)},onError:(g,v,b,_)=>{u(new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:Li({url:c.url,data:void 0},g)},`"${e}" certificate request failed (${r}). Status: ${g.code} (${g.text})`))},onTimeout:(g,v,b)=>{u(new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(g,v,b)=>{u(new Error("aborted"))}};n.load(c,f,p)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,r)=>{e.setServerCertificate(i).then(o=>{this.log(`setServerCertificate ${o?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(o=>{r(new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:o,fatal:!0},o.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new Qn({type:It.KEY_SYSTEM_ERROR,details:ke.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 p=0,g=r.length;p<g;p++){var o,u;f=r[p];const v=(o=f.querySelector("name"))==null?void 0:o.textContent,b=(u=f.querySelector("value"))==null?void 0:u.textContent;v&&b&&e.setRequestHeader(v,b)}}const c=n.querySelector("Challenge"),d=c?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Sx(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(o=>{if(!i.decryptdata)throw o;return e.open("POST",t,!0),r.call(this.hls,e,t,i,n)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||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 o=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${o}`);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,o,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 Qn({type:It.KEY_SYSTEM_ERROR,details:ke.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:u,response:{url:o,data:void 0,code:u.status,text:u.statusText}},`License Request XHR failed (${o}). 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,o,e,t).then(({xhr:c,licenseChallenge:d})=>{e.keySystem==ls.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,vn(i,"encrypted",this.onMediaEncrypted),vn(i,"waitingforkey",this.onWaitingForKey);const n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(Pn(e,"encrypted",this.onMediaEncrypted),Pn(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,Jo.clearKeyUriToKeyIdMap();const r=n.length;pc.CDMCleanupPromise=Promise.all(n.map(o=>this.removeSession(o)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(o=>{this.log(`Could not clear media keys: ${o}`),this.hls&&this.hls.trigger($.ERROR,{type:It.OTHER_ERROR,details:ke.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${o}`)})}))||Promise.resolve())).catch(o=>{this.log(`Could not close sessions and clear media keys: ${o}`),this.hls&&this.hls.trigger($.ERROR,{type:It.OTHER_ERROR,details:ke.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${o}`)})}).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: ${Qs(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:o}=e;o&&Object.keys(o).forEach(d=>self.clearTimeout(o[d]));const{drmSystemOptions:u}=this.config;return(mU(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($.ERROR,{type:It.OTHER_ERROR,details:ke.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($.ERROR,{type:It.OTHER_ERROR,details:ke.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${d}`)})})}return Promise.resolve()}}pc.CDMCleanupPromise=void 0;function Em(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return Qs(s.keyId)}function N7(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 Qn 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 gw(s,e){const t=s==="output-restricted",i=t?ke.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:ke.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Qn({type:It.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}class O7{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on($.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off($.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,o=i-this.lastDroppedFrames,u=t-this.lastDecodedFrames,c=1e3*o/r,d=this.hls;if(d.trigger($.FPS_DROP,{currentDropped:o,currentDecoded:u,totalDroppedFrames:i}),c>0&&o>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($.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 BL(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 FL(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){Ri.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){Ri.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(s.mode=t)}function ic(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 Ix(s,e,t,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const r=P7(s.cues,e,t);for(let o=0;o<r.length;o++)(!i||i(r[o]))&&s.removeCue(r[o])}n==="disabled"&&(s.mode=n)}function M7(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 P7(s,e,t){const i=[],n=M7(s,e);if(n>-1)for(let r=n,o=s.length;r<o;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 Vm(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 B7 extends Qb{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=Vm(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($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.LEVEL_LOADING,this.onLevelLoading,this),e.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.LEVEL_LOADING,this.onLevelLoading,this),e.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.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;Vm(i.textTracks).forEach(o=>{ic(o)})}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,o=this.tracksInGroup[i];if(!o||o.groupId!==n){this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${o?.groupId}`);return}const u=o.details;o.details=t.details,this.log(`Subtitle track ${i} "${o.name}" lang:${o.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(o=>n?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(f=>!i||i.indexOf(f.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(f=>f.default)&&(this.selectDefaultTrack=!1),o.forEach((f,p)=>{f.id=p});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const u=this.hls.config.subtitlePreference;if(!r&&u){this.selectDefaultTrack=!1;const f=la(u,o);if(f>-1)r=o[f];else{const p=la(u,this.tracks);r=this.tracks[p]}}let c=this.findTrackId(r);c===-1&&r&&(c=this.findTrackId(null));const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger($.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||Ql(r,e)))return n}if(e){for(let n=0;n<t.length;n++){const r=t[n];if(Ah(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const r=t[n];if(Ah(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(kx(n,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===oi.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&&Ql(e,i))return i;const n=la(e,this.tracksInGroup);if(n>-1){const r=this.tracksInGroup[n];return this.setSubtitleTrack(n),r}else{if(i)return null;{const r=la(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),o=e.details,u=o?.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&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger($.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Vm(e.textTracks),i=this.currentTrack;let n;if(i&&(n=t.filter(r=>kx(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||!yt(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($.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:o,groupId:u="",name:c,type:d,url:f}=n;this.hls.trigger($.SUBTITLE_TRACK_SWITCH,{id:o,groupId:u,name:c,type:d,url:f});const p=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(p)}}function F7(){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 fh(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const gc=.025;let Dp=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function U7(s,e,t){return`${s.identifier}-${t+1}-${fh(e)}`}class j7{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=yt(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)<gc))}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"?Dp.Range:Dp.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 $7(this)}}function fv(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<gc)?e.start:e.start+e.duration}function UL(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function mv(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function $7(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function Qu(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class H7{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($.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=n;const o=()=>{this.hasDetails=!0};r.once($.LEVEL_LOADED,o),r.once($.AUDIO_TRACK_LOADED,o),r.once($.SUBTITLE_TRACK_LOADED,o),r.on($.MEDIA_ATTACHING,(u,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on($.BUFFER_APPENDED,()=>{const f=this.bufferedEnd;this.reachedPlayout(f)&&(this._bufferedEosTime=f,r.trigger($.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=UL(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=Xt.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=Xt.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: ${Qu(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const yw=.033;class V7 extends yr{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 o=i[r];if(!o.error){const u=o.timelineStart;if(t===u||t>u&&(t<u+(o.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,o=this.parseDateRanges(n,{url:i.url},t),u=Object.keys(n),c=r?r.filter(d=>!u.includes(d.identifier)):[];o.length&&o.sort((d,f)=>{const p=d.cue.pre,g=d.cue.post,v=f.cue.pre,b=f.cue.post;if(p&&!v)return-1;if(v&&!p||g&&!b)return 1;if(b&&!g)return-1;if(!p&&!v&&!g&&!b){const _=d.startTime,S=f.startTime;if(_!==S)return _-S}return d.dateRange.tagOrder-f.dateRange.tagOrder}),this.events=o,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,o=this.parseSchedule(n,e);(i||t.length||r?.length!==o.length||o.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=o,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const n=[],r=Object.keys(e);for(let o=0;o<r.length;o++){const u=r[o],c=e[u];if(c.isInterstitial){let d=this.eventMap[u];d?d.setDateRange(c):(d=new j7(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 o=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,p)=>{const g=f.cue.pre,v=f.cue.post,b=e[p-1]||null,_=f.appendInPlace,S=v?r:f.startOffset,D=f.duration,R=f.timelineOccupancy===Dp.Range?D:0,L=f.resumptionOffset,M=b?.startTime===S,j=S+f.cumulativeDuration;let V=_?j+D:S+L;if(g||!v&&S<=0){const z=d;d+=R,f.timelineStart=j;const I=o;o+=D,i.push({event:f,start:j,end:V,playout:{start:I,end:o},integrated:{start:z,end:d}})}else if(S<=r){if(!M){const O=S-c;if(O>yw){const W=c,X=d;d+=O;const q=o;o+=O;const ue={previousEvent:e[p-1]||null,nextEvent:f,start:W,end:W+O,playout:{start:q,end:o},integrated:{start:X,end:d}};i.push(ue)}else O>0&&b&&(b.cumulativeDuration+=O,i[i.length-1].end=S)}v&&(V=j),f.timelineStart=j;const z=d;d+=R;const I=o;o+=D,i.push({event:f,start:j,end:V,playout:{start:I,end:o},integrated:{start:z,end:d}})}else return;const P=f.resumeTime;v||P>r?c=r:c=P}),c<r){var u;const f=c,p=d,g=r-c;d+=g;const v=o;o+=g,i.push({previousEvent:((u=i[i.length-1])==null?void 0:u.event)||null,nextEvent:null,start:c,end:f+g,playout:{start:v,end:o},integrated:{start:p,end:d}})}this.setDurations(r,o,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,o=-1;e.forEach((u,c)=>{const d=u.cue.pre,f=u.cue.post,p=d?0:f?n:u.startTime;this.updateAssetDurations(u),o===p?u.cumulativeDuration=r:(r=0,o=p),!f&&u.snapOptions.in&&(u.resumeAnchor=tu(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<yw&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${u}`));const v=yt(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)>gc?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(o=>{const u=t[o].details,c=u.edge;if(i>=c)return this.log(`"${e.identifier}" resumption ${i} past ${o} playlist end ${c}`),!1;const d=tu(null,u.fragments,i);if(!d)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${o} playlist (${u.fragStart}-${u.fragmentEnd})`),!0;const f=o==="audio"?.175:0;return Math.abs(d.start-i)<gc+f||Math.abs(d.end-i)<gc+f?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${o} 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 o=0;o<e.assetList.length;o++){const u=e.assetList[o],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 Ar(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class G7{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let n;try{n=UL(i,this.hls.sessionId,e.baseUrl)}catch(g){const v=this.assignAssetListError(e,ke.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger($.ERROR,v);return}t&&n.protocol!=="data:"&&n.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,o=r.loader,u=new o(r),c={responseType:"json",url:n.href},d=r.interstitialAssetListLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:(g,v,b,_)=>{const S=g.data,D=S?.ASSETS;if(!Array.isArray(D)){const R=this.assignAssetListError(e,ke.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),b.url,v,_);this.hls.trigger($.ERROR,R);return}e.assetListResponse=S,this.hls.trigger($.ASSET_LIST_LOADED,{event:e,assetListResponse:S,networkDetails:_})},onError:(g,v,b,_)=>{const S=this.assignAssetListError(e,ke.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${v.url})`),v.url,_,b);this.hls.trigger($.ERROR,S)},onTimeout:(g,v,b)=>{const _=this.assignAssetListError(e,ke.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${v.url})`),v.url,g,b);this.hls.trigger($.ERROR,_)}};return u.load(c,f,p),this.hls.trigger($.ASSET_LIST_LOADING,{event:e}),u}assignAssetListError(e,t,i,n,r,o){return e.error=i,{type:It.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:o,stats:r}}}function vw(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function wm(s,e){return`[${s}] Advancing timeline position to ${e}`}class z7 extends yr{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 o=n<=-.01;this.timelinePos=i,this.bufferedPos=i;const u=this.playingItem;if(!u){this.checkBuffer();return}if(o&&this.schedule.resetErrorsInRange(i,i-n)&&this.updateSchedule(!0),this.checkBuffer(),o&&i<u.start||i>=u.end){var c;const v=this.findItemIndex(u);let b=this.schedule.findItemIndexAtTime(i);if(b===-1&&(b=v+(o?-1:1),this.log(`seeked ${o?"back ":""}to position not covered by schedule ${i} (resolving from ${v} to ${b})`)),!this.isInterstitial(u)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!o&&b>v){const _=this.schedule.findJumpRestrictedIndex(v+1,b);if(_>v){this.setSchedulePosition(_);return}}this.setSchedulePosition(b);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,p=d.duration||0;if(o&&i<f||i>=f+p){var g;(g=u.event)!=null&&g.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 o=r.timelineStart+(r.duration||0);i>=o&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,n)=>{const r=this.schedule;if(!r)return;const o=this.playingItem,u=r.events||[],c=r.items||[],d=r.durations,f=i.map(_=>_.identifier),p=!!(u.length||f.length);(p||n)&&this.log(`INTERSTITIALS_UPDATED (${u.length}): ${u}
Schedule: ${c.map(_=>Ar(_))} pos: ${this.timelinePos}`),f.length&&this.log(`Removed events ${f}`);let g=null,v=null;o&&(g=this.updateItem(o,this.timelinePos),this.itemsMatch(o,g)?this.playingItem=g:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const b=this.bufferingItem;if(b&&(v=this.updateItem(b,this.bufferedPos),this.itemsMatch(b,v)?this.bufferingItem=v:b.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(b.event,null))),i.forEach(_=>{_.assetList.forEach(S=>{this.clearAssetPlayer(S.identifier,null)})}),this.playerQueue.forEach(_=>{if(_.interstitial.appendInPlace){const S=_.assetItem.timelineStart,D=_.timelineOffset-S;if(D)try{_.timelineOffset=S}catch(R){Math.abs(D)>gc&&this.warn(`${R} ("${_.assetId}" ${_.timelineOffset}->${S})`)}}}),p||n){if(this.hls.trigger($.INTERSTITIALS_UPDATED,{events:u.slice(0),schedule:c.slice(0),durations:d,removedIds:f}),this.isInterstitial(o)&&f.includes(o.event.identifier)){this.warn(`Interstitial "${o.event.identifier}" removed while playing`),this.primaryFallback(o.event);return}o&&this.trimInPlace(g,o),b&&v!==g&&this.trimInPlace(v,b),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new G7(e),this.schedule=new V7(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on($.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on($.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on($.BUFFER_APPENDED,this.onBufferAppended,this),e.on($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on($.MEDIA_ENDED,this.onMediaEnded,this),e.on($.ERROR,this.onError,this),e.on($.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off($.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off($.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off($.BUFFER_CODECS,this.onBufferCodecs,this),e.off($.BUFFER_APPENDED,this.onBufferAppended,this),e.off($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off($.MEDIA_ENDED,this.onMediaEnded,this),e.off($.ERROR,this.onError,this),e.off($.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){Pn(e,"play",this.onPlay),Pn(e,"pause",this.onPause),Pn(e,"seeking",this.onSeeking),Pn(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;vn(i,"seeking",this.onSeeking),vn(i,"timeupdate",this.onTimeupdate),vn(i,"play",this.onPlay),vn(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=p=>p&&e.getAssetPlayer(p.identifier),n=(p,g,v,b,_)=>{if(p){let S=p[g].start;const D=p.event;if(D){if(g==="playout"||D.timelineOccupancy!==Dp.Point){const R=i(v);R?.interstitial===D&&(S+=R.assetItem.startOffset+R[_])}}else{const R=b==="bufferedPos"?o():e[b];S+=R-p.start}return S}return 0},r=(p,g)=>{var v;if(p!==0&&g!=="primary"&&(v=e.schedule)!=null&&v.length){var b;const _=e.schedule.findItemIndexAtTime(p),S=(b=e.schedule.items)==null?void 0:b[_];if(S){const D=S[g].start-S.start;return p+D}}return p},o=()=>{const p=e.bufferedPos;return p===Number.MAX_VALUE?u("primary"):Math.max(p,0)},u=p=>{var g,v;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:((v=e.schedule)==null?void 0:v.durations[p])||0},c=(p,g)=>{var v,b;const _=e.effectivePlayingItem;if(_!=null&&(v=_.event)!=null&&v.restrictions.skip||!e.schedule)return;e.log(`seek to ${p} "${g}"`);const S=e.effectivePlayingItem,D=e.schedule.findItemIndexAtTime(p,g),R=(b=e.schedule.items)==null?void 0:b[D],L=e.getBufferingPlayer(),M=L?.interstitial,j=M?.appendInPlace,V=S&&e.itemsMatch(S,R);if(S&&(j||V)){const P=i(e.playingAsset),z=P?.media||e.primaryMedia;if(z){const I=g==="primary"?z.currentTime:n(S,g,e.playingAsset,"timelinePos","currentTime"),O=p-I,W=(j?I:z.currentTime)+O;if(W>=0&&(!P||j||W<=P.duration)){z.currentTime=W;return}}}if(R){let P=p;if(g!=="primary"){const I=R[g].start,O=p-I;P=R.start+O}const z=!e.isInterstitial(R);if((!e.isInterstitial(S)||S.event.appendInPlace)&&(z||R.event.appendInPlace)){const I=e.media||(j?L?.media:null);I&&(I.currentTime=P)}else if(S){const I=e.findItemIndex(S);if(D>I){const W=e.schedule.findJumpRestrictedIndex(I+1,D);if(W>I){e.setSchedulePosition(W);return}}let O=0;if(z)e.timelinePos=P,e.checkBuffer();else{const W=R.event.assetList,X=p-(R[g]||R).start;for(let q=W.length;q--;){const ue=W[q];if(ue.duration&&X>=ue.startOffset&&X<ue.startOffset+ue.duration){O=q;break}}}e.setSchedulePosition(D,O)}}},d=()=>{const p=e.effectivePlayingItem;if(e.isInterstitial(p))return p;const g=t();return e.isInterstitial(g)?g:null},f={get bufferedEnd(){const p=t(),g=e.bufferingItem;if(g&&g===p){var v;return n(g,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-g.playout.start||((v=e.bufferingAsset)==null?void 0:v.startOffset)||0}return 0},get currentTime(){const p=d(),g=e.effectivePlayingItem;return g&&g===p?n(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(p){const g=d(),v=e.effectivePlayingItem;v&&v===g&&c(p+v.playout.start,"playout")},get duration(){const p=d();return p?p.playout.end-p.playout.start:0},get assetPlayers(){var p;const g=(p=d())==null?void 0:p.event.assetList;return g?g.map(v=>e.getAssetPlayer(v.identifier)):[]},get playingIndex(){var p;const g=(p=d())==null?void 0:p.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var p;return((p=e.schedule)==null||(p=p.events)==null?void 0:p.slice(0))||[]},get schedule(){var p;return((p=e.schedule)==null||(p=p.items)==null?void 0:p.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 p=t();return e.findItemIndex(p)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const p=e.effectivePlayingItem;return e.findItemIndex(p)},primary:{get bufferedEnd(){return o()},get currentTime(){const p=e.timelinePos;return p>0?p:0},set currentTime(p){c(p,"primary")},get duration(){return u("primary")},get seekableStart(){var p;return((p=e.primaryDetails)==null?void 0:p.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(p){c(p,"integrated")},get duration(){return u("integrated")},get seekableStart(){var p;return r(((p=e.primaryDetails)==null?void 0:p.fragmentStart)||0,"integrated")}},skip:()=>{const p=e.effectivePlayingItem,g=p?.event;if(g&&!g.restrictions.skip){const v=e.findItemIndex(p);if(g.appendInPlace){const b=p.playout.start+p.event.duration;c(b+.001,"playout")}else e.advanceAfterAssetEnded(g,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||!yt(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} ${zi(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 o=this.hls,u=e!==o,c=u&&e.interstitial.appendInPlace,d=(i=this.detachedData)==null?void 0:i.mediaSource;let f;if(o.media)c&&(r=o.transferMedia(),this.detachedData=r),f="Primary";else if(d){const b=this.getBufferingPlayer();b?(r=b.transferMedia(),f=`${b}`):f="detached MediaSource"}else f="detached media";if(!r){if(d)r=this.detachedData,this.log(`using detachedData: MediaSource ${zi(r)}`);else if(!this.detachedData||o.media===t){const b=this.playerQueue;b.length>1&&b.forEach(_=>{if(u&&_.interstitial.appendInPlace!==c){const S=_.interstitial;this.clearInterstitial(_.interstitial,null),S.appendInPlace=!1,S.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${S}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const p=r&&"mediaSource"in r&&((n=r.mediaSource)==null?void 0:n.readyState)!=="closed",g=p&&r?r:t;this.log(`${p?"transfering MediaSource":"attaching media"} to ${u?e:"Primary"} from ${f} (media.currentTime: ${t.currentTime})`);const v=this.schedule;if(g===r&&v){const b=u&&e.assetId===v.assetIdAtEnd;g.overrides={duration:v.duration,endOfStream:!u||b,cueRemoval:!u}}e.attachMedia(g)}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(wm("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const o=e.findEventIndex(t[0].identifier);this.setSchedulePosition(o)}else if(r>=0||!this.primaryLive){const o=this.timelinePos=r>0?r:0,u=e.findItemIndexAtTime(o);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=mv(i,n);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var o;const u=(o=this.schedule.items)==null?void 0:o[this.findItemIndex(e)+1];u&&this.bufferedToItem(u)}}advanceAfterAssetEnded(e,t,i){const n=mv(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){const r=this.schedule.items;if(r){const o=t+1,u=r.length;if(o>=u){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log(wm("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(o)}}}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 o=i.findEventIndex(n),u=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,o,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&&Ar(r)}) pos: ${this.timelinePos}`);const o=this.waitingItem||this.playingItem,u=this.playingLastItem;if(this.isInterstitial(o)){const f=o.event,p=this.playingAsset,g=p?.identifier,v=g?this.getAssetPlayer(g):null;if(v&&g&&(!this.eventItemsMatch(o,r)||t!==void 0&&g!==f.assetList[t].identifier)){var c;const b=f.findAssetIndex(p);if(this.log(`INTERSTITIAL_ASSET_ENDED ${b+1}/${f.assetList.length} ${Qu(p)}`),this.endedAsset=p,this.playingAsset=null,this.hls.trigger($.INTERSTITIAL_ASSET_ENDED,{asset:p,assetListIndex:b,event:f,schedule:n.slice(0),scheduleIndex:e,player:v}),o!==this.playingItem){this.itemsMatch(o,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(f,this.findItemIndex(this.playingItem),b);return}this.retreiveMediaSource(g,r),v.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&v.detachMedia()}if(!this.eventItemsMatch(o,r)&&(this.endedItem=o,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${f} ${Ar(o)}`),f.hasPlayed=!0,this.hls.trigger($.INTERSTITIAL_ENDED,{event:f,schedule:n.slice(0),scheduleIndex:e}),f.cue.once)){var d;this.updateSchedule();const b=(d=this.schedule)==null?void 0:d.items;if(r&&b){const _=this.findItemIndex(r);this.advanceSchedule(_,b,t,o,u)}return}}this.advanceSchedule(e,n,t,o,u)}advanceSchedule(e,t,i,n,r){const o=this.schedule;if(!o)return;const u=t[e]||null,c=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(f=>{const p=f.interstitial,g=o.findEventIndex(p.identifier);(g<e||g>e+1)&&this.clearInterstitial(p,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=o.findAssetIndex(f,this.timelinePos);const b=mv(f,i-1);if(f.isAssetPastPlayoutLimit(b)||f.appendInPlace&&this.timelinePos===u.end){this.advanceAfterAssetEnded(f,e,i);return}i=b}const p=this.waitingItem;this.assetsBuffered(u,c)||this.setBufferingItem(u);let g=this.preloadAssets(f,i);if(this.eventItemsMatch(u,p||n)||(this.waitingItem=u,this.log(`INTERSTITIAL_STARTED ${Ar(u)} ${f.appendInPlace?"append in place":""}`),this.hls.trigger($.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(g||(g=this.getAssetPlayer(v.identifier)),g===null||g.destroyed){const b=f.assetList.length;this.warn(`asset ${i+1}/${b} player destroyed ${f}`),g=this.createAssetPlayer(f,v,i),g.loadSource()}if(!this.eventItemsMatch(u,this.bufferingItem)&&f.appendInPlace&&this.isAssetBuffered(v))return;this.startAssetPlayer(g,i,t,e,c),this.shouldPlay&&vw(g.media)}else u?(this.resumePrimary(u,e,n),this.shouldPlay&&vw(this.hls.media)):r&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(o.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 ${Ar(e)}`),!((n=this.detachedData)!=null&&n.mediaSource)){let u=this.timelinePos;(u<e.start||u>=e.end)&&(u=this.getPrimaryResumption(e,t),this.log(wm("resumePrimary",u)),this.timelinePos=u),this.attachPrimary(u,e)}if(!i)return;const o=(r=this.schedule)==null?void 0:r.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Ar(e)}`),this.hls.trigger($.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.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:Xt.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(wm("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($.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on($.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=Li(Li({},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=Li(Li({},this.altSelection),{},{audio:i});return}const r=Li(Li({},n),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=Li(Li({},this.altSelection),{},{subtitles:i});return}const r=Li(Li({},n),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=C2(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setAudioOption(t)||n.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=C2(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 o=this.schedule.findEventIndex(r.identifier),u=(i=this.schedule.items)==null?void 0:i[o];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,o)=>{e.event.isAssetPastPlayoutLimit(o)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,n=Xt.bufferInfo(this.primaryMedia,i,0);(n.end>i||(n.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Ar(e)} (was ${Ar(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=Xt.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 o=this.playingItem,u=this.findItemIndex(o);let c=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var d;const f=this.findItemIndex(r),p=Math.min(f+1,t.length-1),g=t[p];if((c===-1&&r&&e>=r.end||(d=g.event)!=null&&d.appendInPlace&&e+.01>=g.start)&&(c=p),this.isInterstitial(r)){const v=r.event;if(p-u>1&&v.appendInPlace===!1||v.assetList.length===0&&v.assetListLoader)return}if(this.bufferedPos=e,c>f&&c>u)this.bufferedToItem(g);else{const v=this.primaryDetails;this.primaryLive&&v&&e>v.edge-v.targetduration&&g.start<v.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(g)&&this.preloadAssets(g.event,0)}}else i&&o&&!this.itemsMatch(o,r)&&(c===u?this.bufferedToItem(o):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 o=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 ${Ar(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(o){const d=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((f,p)=>{const g=this.getAssetPlayer(f.identifier);g&&(p===d&&g.loadSource(),g.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger($.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 o=this.preloadAssets(i,t);if(o!=null&&o.interstitial.appendInPlace){const u=this.primaryMedia;u&&this.bufferAssetPlayer(o,u)}}}preloadAssets(e,t){const i=e.assetUrl,n=e.assetList.length,r=n===0&&!e.assetListLoader,o=e.cue.once;if(r){const c=e.timelineStart;if(e.appendInPlace){var u;const g=this.playingItem;!this.isInterstitial(g)&&(g==null||(u=g.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 g=f-c;g>0&&(d=Math.round(g*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 p=this.assetListLoader.loadAssetList(e,d);p&&(e.assetListLoader=p)}else if(!o&&n){for(let d=t;d<n;d++){const f=e.assetList[d],p=this.getAssetPlayerQueueIndex(f.identifier);(p===-1||this.playerQueue[p].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($.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,o){const u={parentIdentifier:e.identifier,identifier:U7(e,o,t),duration:r,startOffset:i,timelineStart:n,uri:o};return this.createAssetPlayer(e,u,t)}createAssetPlayer(e,t,i){const n=this.hls,r=n.userConfig;let o=r.videoPreference;const u=n.loadLevelObj||n.levels[n.currentLevel];(o||u)&&(o=Bi({},o),u.videoCodec&&(o.videoCodec=u.videoCodec),u.videoRange&&(o.allowedVideoRanges=[u.videoRange]));const c=n.audioTracks[n.audioTrack],d=n.subtitleTracks[n.subtitleTrack];let f=0;if(this.primaryLive||e.appendInPlace){const M=this.timelinePos-t.timelineStart;if(M>1){const j=t.duration;j&&M<j&&(f=M)}}const p=t.identifier,g=Li(Li({},r),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:p,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:f,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:o,audioPreference:c||r.audioPreference,subtitlePreference:d||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const v=g.cmcd;v!=null&&v.sessionId&&v.contentId&&(g.cmcd=Bi({},v,{contentId:fh(t.uri)})),this.getAssetPlayer(p)&&this.warn(`Duplicate date range identifier ${e} and asset ${p}`);const b=new H7(this.HlsPlayerClass,g,e,t);this.playerQueue.push(b),e.assetList[i]=t;let _=!0;const S=M=>{if(M.live){var j;const z=new Error(`Interstitials MUST be VOD assets ${e}`),I={fatal:!0,type:It.OTHER_ERROR,details:ke.INTERSTITIAL_ASSET_ITEM_ERROR,error:z},O=((j=this.schedule)==null?void 0:j.findEventIndex(e.identifier))||-1;this.handleAssetItemError(I,e,O,i,z.message);return}const V=M.edge-M.fragmentStart,P=t.duration;(_||P===null||V>P)&&(_=!1,this.log(`Interstitial asset "${p}" duration change ${P} > ${V}`),t.duration=V,this.updateSchedule())};b.on($.LEVEL_UPDATED,(M,{details:j})=>S(j)),b.on($.LEVEL_PTS_UPDATED,(M,{details:j})=>S(j)),b.on($.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const D=(M,j)=>{const V=this.getAssetPlayer(p);if(V&&j.tracks){V.off($.BUFFER_CODECS,D),V.tracks=j.tracks;const P=this.primaryMedia;this.bufferingAsset===V.assetItem&&P&&!V.media&&this.bufferAssetPlayer(V,P)}};b.on($.BUFFER_CODECS,D);const R=()=>{var M;const j=this.getAssetPlayer(p);if(this.log(`buffered to end of asset ${j}`),!j||!this.schedule)return;const V=this.schedule.findEventIndex(e.identifier),P=(M=this.schedule.items)==null?void 0:M[V];this.isInterstitial(P)&&this.advanceAssetBuffering(P,t)};b.on($.BUFFERED_TO_END,R);const L=M=>()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;this.shouldPlay=!0;const V=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,V,M)};return b.once($.MEDIA_ENDED,L(i)),b.once($.PLAYOUT_LIMIT_REACHED,L(1/0)),b.on($.ERROR,(M,j)=>{if(!this.schedule)return;const V=this.getAssetPlayer(p);if(j.details===ke.BUFFER_STALLED_ERROR){if(V!=null&&V.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(j,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${j.error} ${e}`)}),b.on($.DESTROYING,()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;const j=new Error(`Asset player destroyed unexpectedly ${p}`),V={fatal:!0,type:It.OTHER_ERROR,details:ke.INTERSTITIAL_ASSET_ITEM_ERROR,error:j};this.handleAssetItemError(V,e,this.schedule.findEventIndex(e.identifier),i,j.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Qu(t)}`),this.hls.trigger($.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:b}),b}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&&Ar(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:o,assetItem:u,assetId:c}=e,d=o.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} ${Qu(u)}`),this.hls.trigger($.INTERSTITIAL_ASSET_STARTED,{asset:u,assetListIndex:t,event:o,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:o}=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=o;const d=this.getBufferingPlayer();if(d===e)return;const f=r.appendInPlace;if(f&&d?.interstitial.appendInPlace===!1)return;const p=d?.tracks||((n=this.detachedData)==null?void 0:n.tracks)||this.requiredTracks;if(f&&o!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(p&&!TD(p,e.tracks)){const g=new Error(`Asset ${Qu(o)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(p)}')`),v={fatal:!0,type:It.OTHER_ERROR,details:ke.INTERSTITIAL_ASSET_ITEM_ERROR,error:g},b=r.findAssetIndex(o);this.handleAssetItemError(v,r,u,b,g.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),o=e.assetList[r];if(o){const u=this.getAssetPlayer(o.identifier);if(u){const c=u.currentTime||n-o.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===ke.BUFFER_STALLED_ERROR)return;const o=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${o&&Qu(o)} ${e.error}`),!this.schedule)return;const u=o?.identifier||"",c=this.getAssetPlayerQueueIndex(u),d=this.playerQueue[c]||null,f=this.schedule.items,p=Bi({},e,{fatal:!1,errorAction:fc(!0),asset:o,assetListIndex:n,event:t,schedule:f,scheduleIndex:i,player:d});if(this.hls.trigger($.INTERSTITIAL_ASSET_ERROR,p),!e.fatal)return;const g=this.playingAsset,v=this.bufferingAsset,b=new Error(r);if(o&&(this.clearAssetPlayer(u,null),o.error=b),!t.assetList.some(_=>!_.error))t.error=b;else for(let _=n;_<t.assetList.length;_++)this.resetAssetPlayer(t.assetList[_].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):g&&g.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: ${Ar(i)} error: ${e.error}`),n===-1&&(n=this.hls.startPosition);const o=this.updateItem(i,n);this.itemsMatch(i,o)&&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,o=r.identifier,u=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(o)))return;const c=r.timelineStart,d=r.duration;let f=0;u.forEach((_,S)=>{const D=parseFloat(_.DURATION);this.createAsset(r,S,f,c+f,D,_.URI),f+=D}),r.duration=f,this.log(`Loaded asset-list with duration: ${f} (was: ${d}) ${r}`);const p=this.waitingItem,g=p?.event.identifier===o;this.updateSchedule();const v=(n=this.bufferingItem)==null?void 0:n.event;if(g){var b;const _=this.schedule.findEventIndex(o),S=(b=this.schedule.items)==null?void 0:b[_];if(S){if(!this.playingItem&&this.timelinePos>S.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==_){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(S)}this.setSchedulePosition(_)}else if(v?.identifier===o){const _=r.assetList[0];if(_){const S=this.getAssetPlayer(_.identifier);if(v.appendInPlace){const D=this.primaryMedia;S&&D&&this.bufferAssetPlayer(S,D)}else S&&S.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case ke.ASSET_LIST_PARSING_ERROR:case ke.ASSET_LIST_LOAD_ERROR:case ke.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case ke.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 xw=500;class q7 extends Vb{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",Et.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($.LEVEL_LOADED,this.onLevelLoaded,this),e.on($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on($.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($.LEVEL_LOADED,this.onLevelLoaded,this),e.off($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off($.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=He.IDLE,this.setInterval(xw),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)||(_s(i)&&(this.fragPrevious=i),this.state=He.IDLE),!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let o;const u=i.start;for(let d=0;d<r.length;d++)if(u>=r[d].start&&u<=r[d].end){o=r[d];break}const c=i.start+i.duration;o?o.end=c:(o={start:u,end:c},r.push(o)),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(o=>{for(let u=0;u<o.length;){if(o[u].end<=r){o.shift();continue}else if(o[u].start<r)o[u].start=r;else break;u++}}),this.fragmentTracker.removeFragmentsInRange(i,r,Et.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===Et.SUBTITLE&&(t.details===ke.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==He.STOPPED&&(this.state=He.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&EL(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,Et.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!==He.STOPPED&&this.setInterval(xw)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:n,levels:r}=this,{details:o,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 [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(o.live||(i=c.details)!=null&&i.live){if(o.deltaUpdateFailed)return;const p=this.mainDetails;if(!p){this.startFragRequested=!1;return}const g=p.fragments[0];if(!c.details)o.hasProgramDateTime&&p.hasProgramDateTime?(Cp(o,p),d=o.fragmentStart):g&&(d=g.start,wx(o,d));else{var f;d=this.alignPlaylists(o,c.details,(f=this.levelLastLoaded)==null?void 0:f.details),d===0&&g&&(d=g.start,wx(o,d))}p&&!this.startFragRequested&&this.setStartPosition(p,d)}c.details=o,this.levelLastLoaded=c,u===n&&(this.hls.trigger($.SUBTITLE_TRACK_UPDATED,{details:o,id:u,groupId:t.groupId}),this.tick(),o.live&&!this.fragCurrent&&this.media&&this.state===He.IDLE&&(tu(null,o.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&&mc(n.method)){const o=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,$b(n.method)).catch(u=>{throw r.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:t}),u}).then(u=>{const c=performance.now();r.trigger($.FRAG_DECRYPTED,{frag:t,payload:u,stats:{tstart:o,tdecrypt:c}})}).catch(u=>{this.warn(`${u.name}: ${u.message}`),this.state=He.IDLE})}}doTick(){if(!this.media){this.state=He.IDLE;return}if(this.state===He.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(),o=Xt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:u,len:c}=o,d=i.details,f=this.hls.maxBufferLength+d.levelTargetDuration;if(c>f)return;const p=d.fragments,g=p.length,v=d.edge;let b=null;const _=this.fragPrevious;if(u<v){const R=n.maxFragLookUpTolerance,L=u>v-R?0:R;b=tu(_,p,Math.max(p[0].start,u),L),!b&&_&&_.start<p[0].start&&(b=p[0])}else b=p[g-1];if(b=this.filterReplacedPrimary(b,i.details),!b)return;const S=b.sn-d.startSN,D=p[S-1];if(D&&D.cc===b.cc&&this.fragmentTracker.getState(D)===Bs.NOT_LOADED&&(b=D),this.fragmentTracker.getState(b)===Bs.NOT_LOADED){const R=this.mapToInitFragWhenRequired(b);R&&this.loadFragment(R,i,u)}}}loadFragment(e,t,i){_s(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new K7(this.tracksBuffered[this.currentTrackId]||[])}}class K7{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 Y7={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},jL=s=>String.fromCharCode(Y7[s]||s),kr=15,$a=100,W7={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},X7={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Q7={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Z7={25:2,26:4,29:6,30:8,31:10,27:13,28:15},J7=["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;Ri.log(`${this.time} [${e}] ${i}`)}}}const Ml=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class $L{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 $L}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class i${constructor(e){this.chars=[],this.pos=0,this.currPenState=new $L,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<$a;t++)this.chars.push(new t$);this.logger=e}equals(e){for(let t=0;t<$a;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<$a;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<$a;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>$a&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=$a)}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=jL(e);if(this.pos>=$a){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<$a;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<$a;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 pv{constructor(e){this.rows=[],this.currRow=kr-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<kr;t++)this.rows.push(new i$(e));this.logger=e}reset(){for(let e=0;e<kr;e++)this.rows[e].clear();this.currRow=kr-1}equals(e){let t=!0;for(let i=0;i<kr;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<kr;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<kr;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 = "+zi(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<kr;u++)this.rows[u].clear();const r=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){const u=o.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(o.rows[r+d])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,o=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[o].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 = "+zi(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<kr;r++){const o=this.rows[r].getTextString();o&&(n=r+1,e?t.push("Row "+n+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
`)),i}getTextAndFormat(){return this.rows}}class bw{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 pv(i),this.nonDisplayedMemory=new pv(i),this.lastOutputScreen=new pv(i),this.currRollUpRow=this.displayedMemory.rows[kr-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[kr-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: "+zi(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 Tw{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 bw(e,t,n),new bw(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 o=!1,u=null;if(n===0&&r===0)continue;this.logger.log(3,()=>"["+Ml([t[i],t[i+1]])+"] -> ("+Ml([n,r])+")");const c=this.cmdHistory;if(n>=16&&n<=31){if(s$(n,r,c)){Am(null,null,c),this.logger.log(3,()=>"Repeated command ("+Ml([n,r])+") is dropped");continue}Am(n,r,this.cmdHistory),o=this.parseCmd(n,r),o||(o=this.parseMidrow(n,r)),o||(o=this.parsePAC(n,r)),o||(o=this.parseBackgroundAttributes(n,r))}else Am(null,null,c);if(!o&&(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?")}!o&&!u&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Ml([n,r])+" orig: "+Ml([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,o=this.channels[r];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.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 ("+Ml([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 o=e<=23?1:2;t>=64&&t<=95?i=o===1?W7[e]:Q7[e]:i=o===1?X7[e]:Z7[e];const u=this.channels[o];return u?(u.setPAC(this.interpretPAC(i,t)),this.currentChannel=o,!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 o;r===17?o=t+80:r===18?o=t+112:o=t+144,this.logger.log(2,()=>"Special char '"+jL(o)+"' in channel "+i),n=[o]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);return n&&this.logger.log(3,()=>"Char codes = "+Ml(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 o={};e===16||e===24?(r=Math.floor((t-32)/2),o.background=J7[r],t%2===1&&(o.background=o.background+"_semi")):t===45?o.background="transparent":(o.foreground="black",t===47&&(o.underline=!0));const u=e<=23?1:2;return this.channels[u].setBkgData(o),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Am(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 Am(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 tT=(function(){if(Ap!=null&&Ap.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 p in f)u[p]=f[p]}return u}function o(u,c,d){const f=this,p={enumerable:!0};f.hasBeenReset=!1;let g="",v=!1,b=u,_=c,S=d,D=null,R="",L=!0,M="auto",j="start",V=50,P="middle",z=50,I="middle";Object.defineProperty(f,"id",r({},p,{get:function(){return g},set:function(O){g=""+O}})),Object.defineProperty(f,"pauseOnExit",r({},p,{get:function(){return v},set:function(O){v=!!O}})),Object.defineProperty(f,"startTime",r({},p,{get:function(){return b},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");b=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",r({},p,{get:function(){return _},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");_=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",r({},p,{get:function(){return S},set:function(O){S=""+O,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",r({},p,{get:function(){return D},set:function(O){D=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",r({},p,{get:function(){return R},set:function(O){const W=i(O);if(W===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=W,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",r({},p,{get:function(){return L},set:function(O){L=!!O,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",r({},p,{get:function(){return M},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");M=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",r({},p,{get:function(){return j},set:function(O){const W=n(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");j=W,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",r({},p,{get:function(){return V},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");V=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",r({},p,{get:function(){return P},set:function(O){const W=n(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");P=W,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",r({},p,{get:function(){return z},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");z=O,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",r({},p,{get:function(){return I},set:function(O){const W=n(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");I=W,this.hasBeenReset=!0}})),f.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o})();class r${decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function HL(s){function e(i,n,r,o){return(i|0)*3600+(n|0)*60+(r|0)+parseFloat(o||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 VL(s,e,t,i){const n=i?s.split(i):[s];for(const r in n){if(typeof n[r]!="string")continue;const o=n[r].split(t);if(o.length!==2)continue;const u=o[0],c=o[1];e(u,c)}}const Nx=new tT(0,0,""),Cm=Nx.align==="middle"?"middle":"center";function o$(s,e,t){const i=s;function n(){const u=HL(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$;VL(u,function(g,v){let b;switch(g){case"region":for(let _=t.length-1;_>=0;_--)if(t[_].id===v){d.set(g,t[_].region);break}break;case"vertical":d.alt(g,v,["rl","lr"]);break;case"line":b=v.split(","),d.integer(g,b[0]),d.percent(g,b[0])&&d.set("snapToLines",!1),d.alt(g,b[0],["auto"]),b.length===2&&d.alt("lineAlign",b[1],["start",Cm,"end"]);break;case"position":b=v.split(","),d.percent(g,b[0]),b.length===2&&d.alt("positionAlign",b[1],["start",Cm,"end","line-left","line-right","auto"]);break;case"size":d.percent(g,v);break;case"align":d.alt(g,v,["start",Cm,"end","left","right"]);break}},/:/,/\s/),c.region=d.get("region",null),c.vertical=d.get("vertical","");let f=d.get("line","auto");f==="auto"&&Nx.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",Cm);let p=d.get("position","auto");p==="auto"&&Nx.position===50&&(p=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=p}function o(){s=s.replace(/^\s+/,"")}if(o(),e.startTime=n(),o(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),o(),e.endTime=n(),o(),r(s,e)}function GL(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,o=0;for(r=GL(r);o<r.length&&r[o]!=="\r"&&r[o]!==`
`;)++o;const u=r.slice(0,o);return r[o]==="\r"&&++o,r[o]===`
`&&++o,t.buffer=r.slice(o),u}function n(r){VL(r,function(o,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 o=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!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 tT(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&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
`),t.cue.text+=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,gv=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(!yt(t)||!yt(i)||!yt(n)||!yt(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=3600*1e3*r,t};function iT(s,e,t){return fh(s.toString())+fh(e.toString())+fh(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(;(o=r)!=null&&o.new;){var o;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,o){const u=new l$,c=ir(new Uint8Array(s)).trim().replace(u$,`
`).split(`
`),d=[],f=e?vj(e.baseTime,e.timescale):0;let p="00:00.000",g=0,v=0,b,_=!0;u.oncue=function(S){const D=t[i];let R=t.ccOffset;const L=(g-f)/9e4;if(D!=null&&D.new&&(v!==void 0?R=t.ccOffset=D.start:d$(t,i,L)),L){if(!e){b=new Error("Missing initPTS for VTT MPEGTS");return}R=L-t.presentationOffset}const M=S.endTime-S.startTime,j=Jn((S.startTime+R-v)*9e4,n*9e4)/9e4;S.startTime=Math.max(j,0),S.endTime=Math.max(j+M,0);const V=S.text.trim();S.text=decodeURIComponent(encodeURIComponent(V)),S.id||(S.id=iT(S.startTime,S.endTime,V)),S.endTime>0&&d.push(S)},u.onparsingerror=function(S){b=S},u.onflush=function(){if(b){o(b);return}r(d)},c.forEach(S=>{if(_)if(gv(S,"X-TIMESTAMP-MAP=")){_=!1,S.slice(16).split(",").forEach(D=>{gv(D,"LOCAL:")?p=D.slice(6):gv(D,"MPEGTS:")&&(g=parseInt(D.slice(7)))});try{v=c$(p)/1e3}catch(D){b=D}return}else S===""&&(_=!1);u.parse(S+`
`)}),u.flush()}const yv="stpp.ttml.im1t",zL=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,qL=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f$={left:"start",center:"center",right:"end",start:"start",end:"end"};function _w(s,e,t,i){const n=ni(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=n.map(u=>ir(u)),o=yj(e.baseTime,1,e.timescale);try{r.forEach(u=>t(m$(u,o)))}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},o=Object.keys(r).reduce((p,g)=>(p[g]=n.getAttribute(`ttp:${g}`)||r[g],p),{}),u=n.getAttribute("xml:space")!=="preserve",c=Sw(vv(n,"styling","style")),d=Sw(vv(n,"layout","region")),f=vv(n,"body","[begin]");return[].map.call(f,p=>{const g=KL(p,u);if(!g||!p.hasAttribute("begin"))return null;const v=bv(p.getAttribute("begin"),o),b=bv(p.getAttribute("dur"),o);let _=bv(p.getAttribute("end"),o);if(v===null)throw Ew(p);if(_===null){if(b===null)throw Ew(p);_=v+b}const S=new tT(v-e,_-e,g);S.id=iT(S.startTime,S.endTime,S.text);const D=d[p.getAttribute("region")],R=c[p.getAttribute("style")],L=p$(D,R,c),{textAlign:M}=L;if(M){const j=f$[M];j&&(S.lineAlign=j),S.align=M}return Bi(S,L),S}).filter(p=>p!==null)}function vv(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Sw(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function KL(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?KL(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"],o=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return o&&t.hasOwnProperty(o)&&(n=t[o]),r.reduce((u,c)=>{const d=xv(e,i,c)||xv(s,i,c)||xv(n,i,c);return d&&(u[c]=d),u},{})}function xv(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Ew(s){return new Error(`Could not parse ttml timestamp ${s}`)}function bv(s,e){if(!s)return null;let t=HL(s);return t===null&&(zL.test(s)?t=g$(s,e):qL.test(s)&&(t=y$(s,e))),t}function g$(s,e){const t=zL.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=qL.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 km{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=Aw(),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($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($.FRAG_LOADING,this.onFragLoading,this),e.on($.FRAG_LOADED,this.onFragLoaded,this),e.on($.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on($.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on($.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on($.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($.FRAG_LOADING,this.onFragLoading,this),e.off($.FRAG_LOADED,this.onFragLoaded,this),e.off($.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off($.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off($.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new km(this,"textTrack1"),t=new km(this,"textTrack2"),i=new km(this,"textTrack3"),n=new km(this,"textTrack4");this.cea608Parser1=new Tw(1,e,t),this.cea608Parser2=new Tw(3,i,n)}addCues(e,t,i,n,r){let o=!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),o=!0,d/(i-t)>.5))return}if(o||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($.CUES_PARSED,{type:"captions",cues:u,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:o}){const{unparsedVttFrags:u}=this;i===Et.MAIN&&(this.initPTS[t.cc]={baseTime:n,timescale:r,trackId:o}),u.length&&(this.unparsedVttFrags=[],u.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded($.FRAG_LOADED,c):this.hls.trigger($.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(ww(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:o}=t[e],u=this.getExistingTrack(r,o);if(u)i[e]=u,ic(i[e]),BL(i[e],n);else{const c=this.createTextTrack("captions",r,o);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($.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=>{ic(n[r]),delete n[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Aw(),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++)ic(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(r=>r.textCodec===yv);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(EL(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media,u=o?Vm(o.textTracks):null;if(this.tracks.forEach((c,d)=>{let f;if(u){let p=null;for(let g=0;g<u.length;g++)if(u[g]&&ww(u[g],c)){p=u[g],u[g]=null;break}p&&(f=p)}if(f)ic(f);else{const p=YL(c);f=this.createTextTrack(p,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 o=this.tracks.map(u=>({label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}));this.hls.trigger($.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}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]}`,o=this.captionsProperties[r];o&&(o.label=i.name,i.lang&&(o.languageCode=i.lang),o.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===Et.MAIN){var i,n;const{cea608Parser1:r,cea608Parser2:o,lastSn:u}=this,{cc:c,sn:d}=t.frag,f=(i=(n=t.part)==null?void 0:n.index)!=null?i:-1;r&&o&&(d!==u+1||d===u&&f!==this.lastPartIndex+1||c!==this.lastCc)&&(r.reset(),o.reset()),this.lastCc=c,this.lastSn=d,this.lastPartIndex=f}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===Et.SUBTITLE)if(n.byteLength){const r=i.decryptdata,o="stats"in t;if(r==null||!r.encrypted||o){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===yv?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;_w(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{i.logger.log(`Failed to parse IMSC1: ${n}`),i.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:r,unparsedVttFrags:o}=this,u=r.length-1;if(!r[i.cc]&&u===-1){o.push(e);return}const c=this.hls,d=(t=i.initSegment)!=null&&t.data?mr(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($.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},f=>{const p=f.message==="Missing initPTS for VTT MPEGTS";p?o.push(e):this._fallbackToIMSC1(i,n),c.logger.log(`Failed to parse VTT cue: ${f}`),!(p&&u>i.cc)&&c.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:f})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||_w(t,this.initPTS[e.cc],()=>{i.textCodec=yv,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=>FL(n,r))}else{const n=this.tracks[t];if(!n)return;const r=n.default?"default":"subtitles"+t;i.trigger($.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===Et.SUBTITLE&&this.onFragLoaded($.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===Et.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<n.length;r++){const o=n[r].bytes;if(o){this.cea608Parser1||this.initCea608Parsers();const u=this.extractCea608Data(o);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:o}=this;if(!(!o||o.currentTime<i)){if(!r||r==="video"){const{captionsTracks:u}=this;Object.keys(u).forEach(c=>Ix(u[c],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:u}=this;Object.keys(u).forEach(c=>Ix(u[c],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let r=0;r<i;r++){const o=e[n++],u=127&e[n++],c=127&e[n++];if(u===0&&c===0)continue;if((4&o)!==0){const f=3&o;(f===0||f===1)&&(t[f].push(u),t[f].push(c))}}return t}}function YL(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function ww(s,e){return!!s&&s.kind===YL(e)&&kx(e,s)}function x$(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Aw(){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,o,u,c,d;const f=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(r=i.rows[g],u=!0,c=0,d="",!r.isEmpty()){var p;for(let _=0;_<r.chars.length;_++)b$.test(r.chars[_].uchar)&&u?c++:(d+=r.chars[_].uchar,u=!1);r.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const v=GL(d.trim()),b=iT(e,t,v);s!=null&&(p=s.cues)!=null&&p.getCueById(b)||(o=new f(e,t,v),o.id=b,o.line=g+1,o.align="left",o.position=10+Math.min(80,Math.floor(c*8/32)*10),n.push(o))}return s&&n.length&&(n.sort((g,v)=>g.line==="auto"||v.line==="auto"?0:g.line>8&&v.line>8?v.line-g.line:g.line-v.line),n.forEach(g=>FL(s,g))),n}};function _$(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const S$=/(\d+)-(\d+)\/(\d+)/;class Cw{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||C$,this.controller=new self.AbortController,this.stats=new Ob}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),o=e.responseType==="arraybuffer",u=o?"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&&yt(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(wh(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(p=>{var g;this.response=this.loader=p;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)),!p.ok){const{status:_,statusText:S}=p;throw new k$(S||"fetch, bad network response",_,p)}n.loading.first=v,n.total=A$(p.headers)||n.total;const b=(g=this.callbacks)==null?void 0:g.onProgress;return b&&yt(t.highWaterMark)?this.loadProgressively(p,n,e,t.highWaterMark,b):o?p.arrayBuffer():e.responseType==="json"?p.json():p.text()}).then(p=>{var g,v;const b=this.response;if(!b)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const _=p[u];_&&(n.loaded=n.total=_);const S={url:b.url,data:p,code:b.status},D=(g=this.callbacks)==null?void 0:g.onProgress;D&&!yt(t.highWaterMark)&&D(n,e,p,b),(v=this.callbacks)==null||v.onSuccess(S,n,e,b)}).catch(p=>{var g;if(self.clearTimeout(this.requestTimeout),n.aborted)return;const v=p&&p.code||0,b=p?p.message:null;(g=this.callbacks)==null||g.onError({code:v,text:b},e,p?p.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 o=new nL,u=e.body.getReader(),c=()=>u.read().then(d=>{if(d.done)return o.dataLength&&r(t,i,o.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const f=d.value,p=f.length;return t.loaded+=p,p<n||o.dataLength?(o.push(f),o.dataLength>=n&&r(t,i,o.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(Bi({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function w$(s){const e=S$.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(yt(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function C$(s,e){return new self.Request(s.url,e)}class k$ 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 WL{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 Ob,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(o=>{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(o=>{var u;(u=this.callbacks)==null||u.onError({code:i.status,text:o.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:o}=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&&yt(r)?r:o,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 b=f??t.response;if(b!=null){var o,u;i.loading.end=Math.max(self.performance.now(),i.loading.first);const _=t.responseType==="arraybuffer"?b.byteLength:b.length;i.loaded=i.total=_,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const S=(o=this.callbacks)==null?void 0:o.onProgress;S&&S(i,e,b,t);const D={url:t.responseURL,data:b,code:d};(u=this.callbacks)==null||u.onSuccess(D,i,e,t);return}}const p=r.loadPolicy.errorRetry,g=i.retry,v={url:e.url,data:void 0,code:d};if(Ep(p,g,!1,v))this.retry(p);else{var c;Ri.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(Ep(e,t,!0))this.retry(e);else{var i;Ri.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=Fb(e,i.retry),i.retry++,Ri.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$=Li(Li({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:WL,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V6,bufferController:Nj,capLevelController:Zb,errorController:Y6,fpsController:O7,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:KD,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:q7,subtitleTrackController:B7,timelineController:v$,audioStreamController:Dj,audioTrackController:Lj,emeController:pc,cmcdController:L7,contentSteeringController:I7,interstitialsController:z7});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=Ox(s),n=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return n.forEach(o=>{const u=`${o==="level"?"playlist":o}LoadPolicy`,c=e[u]===void 0,d=[];r.forEach(f=>{const p=`${o}Loading${f}`,g=e[p];if(g!==void 0&&c){d.push(p);const v=i[u].default;switch(e[u]={default:v},f){case"TimeOut":v.maxLoadTimeMs=g,v.maxTimeToFirstByteMs=g;break;case"MaxRetry":v.errorRetry.maxNumRetry=g,v.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":v.errorRetry.retryDelayMs=g,v.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":v.errorRetry.maxRetryDelayMs=g,v.timeoutRetry.maxRetryDelayMs=g;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${u}": ${zi(e[u])}`)}),Li(Li({},i),e)}function Ox(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ox):Object.keys(s).reduce((e,t)=>(e[t]=Ox(s[t]),e),{}):s}function O$(s,e){const t=s.loader;t!==Cw&&t!==WL?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):_$()&&(s.loader=Cw,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Gm=2,M$=.1,P$=.05,B$=100;class F$ extends HD{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($.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.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;vn(i,"playing",this.onMediaPlaying),vn(i,"waiting",this.onMediaWaiting),vn(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(Pn(i,"playing",this.onMediaPlaying),Pn(i,"waiting",this.onMediaWaiting),Pn(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 o=this.media;if(!o)return;const{seeking:u}=o,c=this.seeking&&!u,d=!this.seeking&&u,f=o.paused&&!u||o.ended||o.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&&o.ended&&this.hls&&(this.ended=e||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!1}));return}if(!Xt.getBuffered(o).length){this.nudgeRetry=0;return}const p=Xt.bufferInfo(o,e,0),g=p.nextStart||0,v=this.fragmentTracker;if(u&&v&&this.hls){const V=kw(this.hls.inFlightFragments,e),P=p.len>Gm,z=!g||V||g-e>Gm&&!v.getPartialFragment(e);if(P||z)return;this.moved=!1}const b=(n=this.hls)==null?void 0:n.latestLevelDetails;if(!this.moved&&this.stalled!==null&&v){if(!(p.len>0)&&!g)return;const P=Math.max(g,p.start||0)-e,I=!!(b!=null&&b.live)?b.targetduration*2:Gm,O=Dm(e,v);if(P>0&&(P<=I||O)){o.paused||this._trySkipBufferHole(O);return}}const _=r.detectStallWithCurrentTimeMs,S=self.performance.now(),D=this.waiting;let R=this.stalled;if(R===null)if(D>0&&S-D<_)R=this.stalled=D;else{this.stalled=S;return}const L=S-R;if(!u&&(L>=_||D)&&this.hls){var M;if(((M=this.mediaSource)==null?void 0:M.readyState)==="ended"&&!(b!=null&&b.live)&&Math.abs(e-(b?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger($.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(p),!this.media||!this.hls)return}const j=Xt.bufferInfo(o,e,r.maxBufferHole);this._tryFixBufferStall(j,L,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($.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=Xt.bufferedInfo(Xt.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const o=Xt.timeRangesToArray(n),u=Xt.bufferedInfo(o,t,0).bufferedIndex;if(u>-1&&u<o.length-1){const c=Xt.bufferedInfo(o,e,0).bufferedIndex,d=o[u].end,f=o[u+1].start;if((c===-1||c>u)&&f-d<1&&e-d<2){const p=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${f} buffered index: ${c}`);this.warn(p.message),this.media.currentTime+=1e-6;let g=Dm(e,this.fragmentTracker);g&&"fragment"in g?g=g.fragment:g||(g=void 0);const v=Xt.bufferInfo(this.media,e,0);this.hls.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:p,reason:p.message,frag:g,buffer:v.len,bufferInfo:v})}}}}}_tryFixBufferStall(e,t,i){var n,r;const{fragmentTracker:o,media:u}=this,c=(n=this.hls)==null?void 0:n.config;if(!u||!o||!c)return;const d=(r=this.hls)==null?void 0:r.latestLevelDetails,f=Dm(i,o);if((f||d!=null&&d.live&&i<d.fragmentStart)&&(this._trySkipBufferHole(f)||!this.media))return;const p=e.buffered,g=this.adjacentTraversal(e,i);(p&&p.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-i<c.maxBufferHole||g))&&(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,Et.MAIN),o=i.getFragAtPos(n,Et.MAIN);if(r&&o)return o.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 o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${zi(e)})`);this.warn(o.message),t.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.BUFFER_STALLED_ERROR,fatal:!1,error:o,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 o=n.currentTime,u=Xt.bufferInfo(n,o,0),c=o<u.start?u.start:u.nextStart;if(c&&this.hls){const f=u.len<=r.maxBufferHole,p=u.len>0&&u.len<1&&n.readyState<3,g=c-o;if(g>0&&(f||p)){if(g>r.maxBufferHole){let b=!1;if(o===0){const _=i.getAppendedFrag(0,Et.MAIN);_&&c<_.end&&(b=!0)}if(!b&&e){var d;if(!((d=this.hls.loadLevelObj)!=null&&d.details)||kw(this.hls.inFlightFragments,c))return 0;let S=!1,D=e.end;for(;D<c;){const R=Dm(D,i);if(R)D+=R.duration;else{S=!0;break}}if(S)return 0}}const v=Math.max(c+P$,o+M$);if(this.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,n.currentTime=v,!(e!=null&&e.gap)){const b=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`),_={type:It.MEDIA_ERROR,details:ke.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:b,reason:b.message,buffer:u.len,bufferInfo:u};e&&("fragment"in e?_.part=e:_.frag=e),this.hls.trigger($.ERROR,_)}return v}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:n}=this,r=t?.config;if(!i||!r)return 0;const o=i.currentTime;if(this.nudgeRetry++,n<r.nudgeMaxRetry){const u=o+(n+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${o} to ${u}`);this.warn(c.message),i.currentTime=u,t.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.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 @${o} after ${r.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}function kw(s,e){const t=Dw(s.main);if(t&&t.start<=e)return t;const i=Dw(s.audio);return i&&i.start<=e?i:null}function Dw(s){if(!s)return null;switch(s.state){case He.IDLE:case He.STOPPED:case He.ENDED:case He.ERROR:return null}return s.frag}function Dm(s,e){return e.getAppendedFrag(s,Et.MAIN)||e.getPartialFragment(s)}const U$=.25;function Mx(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Tv(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,zi(n?Li({type:n},i):i))}return r}const Lm=(()=>{const s=Mx();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($.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($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($.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&&ic(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 BL(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 o=Mx();if(o)for(let u=0;u<r.length;u++){const c=r[u].type;if(c===er.emsg&&!i||!n)continue;const d=dL(r[u].data),f=r[u].pts;let p=f+r[u].duration;p>Lm&&(p=Lm),p-f<=0&&(p=f+U$);for(let v=0;v<d.length;v++){const b=d[v];if(!hL(b)){this.updateId3CueEnds(f,c);const _=Tv(o,f,p,b,c);_&&this.id3Track.addCue(_)}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let r=n.length;r--;){const o=n[r];o.type===t&&o.startTime<e&&o.endTime===Lm&&(o.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:r,hls:o}=this;if(!o)return;const{config:{enableEmsgMetadataCues:u,enableID3MetadataCues:c}}=o;if(r&&(u||c)){let d;n==="audio"?d=f=>f.type===er.audioId3&&c:n==="video"?d=f=>f.type===er.emsg&&u:d=f=>f.type===er.audioId3&&c||f.type===er.emsg&&u,Ix(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:o}=this.hls.config;if(!r)return;const u=Mx();if(i&&n&&!o){const{fragmentStart:_,fragmentEnd:S}=e;let D=this.assetCue;D?(D.startTime=_,D.endTime=S):u&&(D=this.assetCue=Tv(u,_,S,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),D&&(D.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(D),D.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:d}=e,f=Object.keys(d);let p=this.dateRangeCuesAppended;if(c&&t){var g;if((g=c.cues)!=null&&g.length){const _=Object.keys(p).filter(S=>!f.includes(S));for(let S=_.length;S--;){var v;const D=_[S],R=(v=p[D])==null?void 0:v.cues;delete p[D],R&&Object.keys(R).forEach(L=>{const M=R[L];if(M){M.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(M)}catch{}}})}}else p=this.dateRangeCuesAppended={}}const b=e.fragments[e.fragments.length-1];if(!(f.length===0||!yt(b?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let _=0;_<f.length;_++){const S=f[_],D=d[S],R=D.startTime,L=p[S],M=L?.cues||{};let j=L?.durationKnown||!1,V=Lm;const{duration:P,endDate:z}=D;if(z&&P!==null)V=R+P,j=!0;else if(D.endOnNext&&!j){const O=f.reduce((W,X)=>{if(X!==D.id){const q=d[X];if(q.class===D.class&&q.startDate>D.startDate&&(!W||D.startDate<W.startDate))return q}return W},null);O&&(V=O.startTime,j=!0)}const I=Object.keys(D.attr);for(let O=0;O<I.length;O++){const W=I[O];if(!oU(W))continue;const X=M[W];if(X)j&&!(L!=null&&L.durationKnown)?X.endTime=V:Math.abs(X.startTime-R)>.01&&(X.startTime=R,X.endTime=V);else if(u){let q=D.attr[W];lU(W)&&(q=_D(q));const ie=Tv(u,R,V,{key:W,data:q},er.dateRange);ie&&(ie.id=S,this.id3Track.addCue(ie),M[W]=ie,o&&(W==="X-ASSET-LIST"||W==="X-ASSET-URL")&&ie.addEventListener("enter",this.onEventCueEnter))}}p[S]={cues:M,dateRange:D,durationKnown:j}}}}}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:o}=this.config;if(!r||o===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 p=Math.min(2,Math.max(1,o)),g=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,v=Math.min(p,Math.max(1,g));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:o,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:o*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,o=n-i.totalduration,u=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(o,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($.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($.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===ke.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 Qb{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($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($.LEVEL_LOADED,this.onLevelLoaded,this),e.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($.FRAG_BUFFERED,this.onFragBuffered,this),e.on($.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($.LEVEL_LOADED,this.onLevelLoaded,this),e.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($.FRAG_BUFFERED,this.onFragBuffered,this),e.off($.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={},o={};let u=!1,c=!1,d=!1;t.levels.forEach(f=>{const p=f.attrs;let{audioCodec:g,videoCodec:v}=f;g&&(f.audioCodec=g=bp(g,i)||void 0),v&&(v=f.videoCodec=E6(v));const{width:b,height:_,unknownCodecs:S}=f,D=S?.length||0;if(u||(u=!!(b&&_)),c||(c=!!v),d||(d=!!g),D||g&&!this.isAudioSupported(g)||v&&!this.isVideoSupported(v)){this.log(`Some or all CODECS not supported "${p.CODECS}"`);return}const{CODECS:R,"FRAME-RATE":L,"HDCP-LEVEL":M,"PATHWAY-ID":j,RESOLUTION:V,"VIDEO-RANGE":P}=p,I=`${`${j||"."}-`}${f.bitrate}-${V}-${L}-${R}-${P}-${M}`;if(r[I])if(r[I].uri!==f.url&&!f.attrs["PATHWAY-ID"]){const O=o[I]+=1;f.attrs["PATHWAY-ID"]=new Array(O+1).join(".");const W=this.createLevel(f);r[I]=W,n.push(W)}else r[I].addGroupId("audio",p.AUDIO),r[I].addGroupId("text",p.SUBTITLES);else{const O=this.createLevel(f);r[I]=O,o[I]=1,n.push(O)}}),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=OD(n,[])}return t}isAudioSupported(e){return bh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return bh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,n,r){var o;let u=[],c=[],d=e;const f=((o=t.stats)==null?void 0:o.parsing)||{};if((i||n)&&r&&(d=d.filter(({videoCodec:R,videoRange:L,width:M,height:j})=>(!!R||!!(M&&j))&&O6(L))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let R="no level with compatible codecs found in manifest",L=R;t.levels.length&&(L=`one or more CODECS in variant not supported: ${zi(t.levels.map(j=>j.attrs.CODECS).filter((j,V,P)=>P.indexOf(j)===V))}`,this.warn(L),R+=` (${L})`);const M=new Error(R);this.hls.trigger($.ERROR,{type:It.MEDIA_ERROR,details:ke.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:M,reason:L})}}),f.end=performance.now();return}t.audioTracks&&(u=t.audioTracks.filter(R=>!R.audioCodec||this.isAudioSupported(R.audioCodec)),Lw(u)),t.subtitles&&(c=t.subtitles,Lw(c));const p=d.slice(0);d.sort((R,L)=>{if(R.attrs["HDCP-LEVEL"]!==L.attrs["HDCP-LEVEL"])return(R.attrs["HDCP-LEVEL"]||"")>(L.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&R.height!==L.height)return R.height-L.height;if(R.frameRate!==L.frameRate)return R.frameRate-L.frameRate;if(R.videoRange!==L.videoRange)return Tp.indexOf(R.videoRange)-Tp.indexOf(L.videoRange);if(R.videoCodec!==L.videoCodec){const M=T2(R.videoCodec),j=T2(L.videoCodec);if(M!==j)return j-M}if(R.uri===L.uri&&R.codecSet!==L.codecSet){const M=xp(R.codecSet),j=xp(L.codecSet);if(M!==j)return j-M}return R.averageBitrate!==L.averageBitrate?R.averageBitrate-L.averageBitrate:0});let g=p[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==p.length)){for(let R=0;R<p.length;R++)if(p[R].pathwayId===d[0].pathwayId){g=p[R];break}}this._levels=d;for(let R=0;R<d.length;R++)if(d[R]===g){var v;this._firstLevel=R;const L=g.bitrate,M=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${L}`),((v=this.hls.userConfig)==null?void 0:v.abrEwmaDefaultEstimate)===void 0){const j=Math.min(L,this.hls.config.abrEwmaDefaultEstimateMax);j>M&&M===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=j)}break}const b=r&&!n,_=this.hls.config,S=!!(_.audioStreamController&&_.audioTrackController),D={levels:d,audioTracks:u,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:n,altAudio:S&&!b&&u.some(R=>!!R.url)};f.end=performance.now(),this.hls.trigger($.MANIFEST_PARSED,D)}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"),p=e<0;if(this.hls.trigger($.ERROR,{type:It.OTHER_ERROR,details:ke.LEVEL_SWITCH_ERROR,level:e,fatal:p,error:f,reason:f.message}),p)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],u=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,i===e&&n&&r===u)return;this.log(`Switching to level ${e} (${o.height?o.height+"p ":""}${o.videoRange?o.videoRange+" ":""}${o.codecSet?o.codecSet+" ":""}@${o.bitrate})${u?" with Pathway "+u:""} from level ${i}${r?" with Pathway "+r:""}`);const c={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger($.LEVEL_SWITCHING,c);const d=o.details;if(!d||d.live){const f=this.switchParams(o.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===oi.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===Et.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,o=t.levelInfo;if(!o){var u;this.warn(`Invalid level index ${n}`),(u=t.deliveryDirectives)!=null&&u.skip&&(r.deltaUpdateFailed=!0);return}if(o===this.currentLevel||t.withoutMultiVariant){o.fragmentError===0&&(o.loadError=0);let c=o.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"],o=e.details,u=o?.age;this.log(`Loading level index ${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${u&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${i}`),this.hls.trigger($.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,o)=>o!==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));tL(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($.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($.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Lw(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function XL(){return self.SourceBuffer||self.WebKitSourceBuffer}function QL(){if(!il())return!1;const e=XL();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function V$(){if(!QL())return!1;const s=il();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Th(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Th(e,"audio"))))}function G$(){var s;const e=XL();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const z$=100;class q$ extends Vb{constructor(e,t,i){super(e,t,i,"stream-controller",Et.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||!yt(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const o=this.getFwdBufferInfoAtPos(n,r,Et.MAIN,0);if(o===null||o.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${o?o.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on($.MANIFEST_PARSED,this.onManifestParsed,this),e.on($.LEVEL_LOADING,this.onLevelLoading,this),e.on($.LEVEL_LOADED,this.onLevelLoaded,this),e.on($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on($.BUFFER_CREATED,this.onBufferCreated,this),e.on($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($.MANIFEST_PARSED,this.onManifestParsed,this),e.off($.LEVEL_LOADED,this.onLevelLoaded,this),e.off($.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off($.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off($.BUFFER_CREATED,this.onBufferCreated,this),e.off($.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.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(z$),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=He.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=He.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case He.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=He.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=He.IDLE;break}break}case He.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===He.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 o=i[r],u=this.getMainFwdBufferInfo();if(u===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){const _={};this.altAudio===2&&(_.type="video"),this.hls.trigger($.BUFFER_EOS,_),this.state=He.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=o.details;if(!d||this.state===He.WAITING_LEVEL||this.waitForLive(o)){this.level=r,this.state=He.WAITING_LEVEL,this.startFragRequested=!1;return}const f=u.len,p=this.getMaxBufferLength(o.maxBitrate);if(f>=p)return;this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);const g=this.backtrackFragment?this.backtrackFragment.start:u.end;let v=this.getNextFragment(g,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&_s(v)&&this.fragmentTracker.getState(v)!==Bs.OK){var b;const S=((b=this.backtrackFragment)!=null?b:v).sn-d.startSN,D=d.fragments[S-1];D&&v.cc===D.cc&&(v=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,g)){if(!v.gap){const S=this.audioOnly&&!this.altAudio?Vi.AUDIO:Vi.VIDEO,D=(S===Vi.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,S,Et.MAIN)}v=this.getNextFragmentLoopLoading(v,d,u,Et.MAIN,p)}v&&(v.initSegment&&!v.initSegment.data&&!this.bitrateTest&&(v=v.initSegment),this.loadFragment(v,o,g))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);n===Bs.NOT_LOADED||n===Bs.PARTIAL?_s(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,Et.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 o=this.getBufferedFrag(t.currentTime+i);if(o){const u=this.followingBufferedFrag(o);if(u){this.abortCurrentFrag();const c=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,f=Math.max(o.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 He.KEY_LOADING:case He.FRAG_LOADING:case He.FRAG_LOADING_WAITING_RETRY:case He.PARSING:case He.PARSED:this.state=He.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;vn(i,"playing",this.onMediaPlaying),vn(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(Pn(i,"playing",this.onMediaPlaying),Pn(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($.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 o=t.levels[r].audioCodec;o&&(i=i||o.indexOf("mp4a.40.2")!==-1,n=n||o.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&n&&!G$(),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!==He.IDLE)return;const n=t.levelInfo;(!n.details||n.details.live&&(this.levelLastLoaded!==n||n.details.expired)||this.waitForCdnTuneIn(n.details))&&(this.state=He.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n,startFragRequested:r}=this,o=t.level,u=t.details,c=u.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} 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===He.FRAG_LOADING||this.state===He.FRAG_LOADING_WAITING_RETRY)&&f.level!==t.level&&f.loader&&this.abortCurrentFrag();let p=0;if(u.live||(i=d.details)!=null&&i.live){var g;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;p=this.alignPlaylists(u,d.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(d.details=u,this.levelLastLoaded=d,r||this.setStartPosition(u,p),this.hls.trigger($.LEVEL_UPDATED,{details:u,level:o}),this.state===He.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=He.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(),o=e.fragmentStart,u=e.edge,c=r>=o-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 p=Xt.bufferInfo(i,n,0);if(!((d=p.buffered)!=null&&d.length)){i.currentTime=n;return}if(p.start<=r){i.currentTime=n;return}const{nextStart:v}=Xt.bufferedInfo(p.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:o}=this;if(!o){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=o[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,p=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(u),v=this.transmuxer=this.transmuxer||new SL(this.hls,Et.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),b=n?n.index:-1,_=b!==-1,S=new jb(i.level,i.sn,i.stats.chunkCount,r.byteLength,b,_),D=this.initPTS[i.cc];v.push(r,p,g,d,i,n,c.totalduration,f,S,D)}onAudioTrackSwitching(e,t){const i=this.hls,n=this.altAudio!==0;if(_p(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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once($.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger($.AUDIO_TRACK_SWITCHED,t)}),i.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger($.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=_p(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,o=!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 o=!0}o&&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===Et.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===He.PARSED&&(this.state=He.IDLE);return}const u=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*u.total/(u.buffering.end-u.loading.first)),_s(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}const o=this.media;o&&(!this._hasEnoughToStart&&Xt.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=He.ERROR;return}switch(t.details){case ke.FRAG_GAP:case ke.FRAG_PARSING_ERROR:case ke.FRAG_DECRYPT_ERROR:case ke.FRAG_LOAD_ERROR:case ke.FRAG_LOAD_TIMEOUT:case ke.KEY_LOAD_ERROR:case ke.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Et.MAIN,t);break;case ke.LEVEL_LOAD_ERROR:case ke.LEVEL_LOAD_TIMEOUT:case ke.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===He.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===oi.LEVEL&&(this.state=He.IDLE);break;case ke.BUFFER_ADD_CODEC_ERROR:case ke.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case ke.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 ke.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=He.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Vi.AUDIO||!this.altAudio){const i=(t===Vi.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,Et.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(),o=Xt.getBuffered(e),u=o.length?o.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=He.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=r.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),n.trigger($.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===He.STOPPED||this.state===He.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:n,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o){this.resetWhenMissingContext(r);return}const{frag:u,part:c,level:d}=o,{video:f,text:p,id3:g,initSegment:v}=n,{details:b}=d,_=this.altAudio?void 0:n.audio;if(this.fragContextChanged(u)){this.fragmentTracker.removeFragment(u);return}if(this.state=He.PARSING,v){const S=v.tracks;if(S){const M=u.initSegment||u;if(this.unhandledEncryptionError(v,u))return;this._bufferInitSegment(d,S,M,r),i.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:t,tracks:S})}const D=v.initPTS,R=v.timescale,L=this.initPTS[u.cc];if(yt(D)&&(!L||L.baseTime!==D||L.timescale!==R)){const M=v.trackId;this.initPTS[u.cc]={baseTime:D,timescale:R,trackId:M},i.trigger($.INIT_PTS_FOUND,{frag:u,id:t,initPTS:D,timescale:R,trackId:M})}}if(f&&b){_&&f.type==="audiovideo"&&this.logMuxedErr(u);const S=b.fragments[u.sn-1-b.startSN],D=u.sn===b.startSN,R=!S||u.cc>S.cc;if(n.independent!==!1){const{startPTS:L,endPTS:M,startDTS:j,endDTS:V}=f;if(c)c.elementaryStreams[f.type]={startPTS:L,endPTS:M,startDTS:j,endDTS:V};else if(f.firstKeyFrame&&f.independent&&r.id===1&&!R&&(this.couldBacktrack=!0),f.dropped&&f.independent){const P=this.getMainFwdBufferInfo(),z=(P?P.end:this.getLoadPosition())+this.config.maxBufferHole,I=f.firstKeyFramePTS?f.firstKeyFramePTS:L;if(!D&&z<I-this.config.maxBufferHole&&!R){this.backtrack(u);return}else R&&(u.gap=!0);u.setElementaryStreamInfo(f.type,u.start,M,u.start,V,!0)}else D&&L-(b.appliedTimelineOffset||0)>Gm&&(u.gap=!0);u.setElementaryStreamInfo(f.type,L,M,j,V),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(f,u,c,r,D||R)}else if(D||R)u.gap=!0;else{this.backtrack(u);return}}if(_){const{startPTS:S,endPTS:D,startDTS:R,endDTS:L}=_;c&&(c.elementaryStreams[Vi.AUDIO]={startPTS:S,endPTS:D,startDTS:R,endDTS:L}),u.setElementaryStreamInfo(Vi.AUDIO,S,D,R,L),this.bufferFragmentData(_,u,c,r)}if(b&&g!=null&&g.samples.length){const S={id:t,frag:u,details:b,samples:g.samples};i.trigger($.FRAG_PARSING_METADATA,S)}if(b&&p){const S={id:t,frag:u,details:b,samples:p.samples};i.trigger($.FRAG_PARSING_USERDATA,S)}}logMuxedErr(e){this.warn(`${_s(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,n){if(this.state!==He.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:o,audiovideo:u}=t;if(r){const d=e.audioCodec;let f=Bm(r.codec,d);f==="mp4a"&&(f="mp4a.40.5");const p=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5");const g=r.metadata;g&&"channelCount"in g&&(g.channelCount||1)!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")}f&&f.indexOf("mp4a.40.5")!==-1&&p.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=Et.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${f||""}/${d||""}/${r.codec}]`),delete t.audiovideo}if(o){o.levelCodec=e.videoCodec,o.id=Et.MAIN;const d=o.codec;if(d?.length===4)switch(d){case"hvc1":case"hev1":o.codec="hvc1.1.6.L120.90";break;case"av01":o.codec="av01.0.04M.08";break;case"avc1":o.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${o.codec!==d?" parsed-corrected="+o.codec:""}${o.supplemental?" supplemental="+o.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($.BUFFER_CODECS,t),!this.hls)return;c.forEach(d=>{const p=t[d].initSegment;p!=null&&p.byteLength&&this.hls.trigger($.BUFFER_APPENDING,{type:d,data:p,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,Et.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=He.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Xt.isBuffered(e,i)?t=this.getAppendedFrag(i):Xt.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($.FRAG_CHANGED,{frag:t}),(!n||n.level!==r)&&this.hls.trigger($.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 yt(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(yt(t)){const i=this.getLevelDetails(),n=this.currentFrag||(i?tu(null,i.fragments,t):null);if(n){const r=n.programDateTime;if(r!==null){const o=r+(t-n.start)*1e3;return new Date(o)}}}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 yr{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=ke.KEY_LOAD_ERROR,i,n,r){return new Va({type:It.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 o=t[n];if(e.cc<=o.cc&&(!_s(e)||!_s(o)||e.sn<o.sn)||!i&&n==r-1)return this.emeController.selectKeySystemFormat(o).then(u=>{if(!this.emeController)return;o.setKeyFormat(u);const c=Um(u);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const n=eh(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,ke.KEY_LOAD_ERROR,d))}const o=r.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,ke.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));const u=_v(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:p}=f;return r.key=p.decryptdata.key,{frag:e,keyInfo:p}})}switch(this.log(`${this.keyIdToKeyInfo[u]?"Rel":"L"}oading${r.keyId?" keyId: "+Qs(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,ke.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 o=h6(t.initSegment.data);if(o.length){let u=o[0];u.some(c=>c!==0)?(this.log(`Using keyId found in init segment ${Qs(u)}`),Jo.setKeyIdForUri(e.decryptdata.uri,u)):(u=Jo.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Qs(u)}`)),e.decryptdata.keyId=u}}if(!e.decryptdata.keyId&&!_s(t))return Promise.resolve(i);const r=this.emeController.loadKey(i);return(e.keyLoadPromise=r.then(o=>(e.mediaKeySessionContext=o,i))).catch(o=>{throw e.keyLoadPromise=null,"data"in o&&(o.data.frag=t),o})}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((o,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},p={onSuccess:(g,v,b,_)=>{const{frag:S,keyInfo:D}=b,R=_v(D.decryptdata);if(!S.decryptdata||D!==this.keyIdToKeyInfo[R])return u(this.createKeyLoadError(S,ke.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),_));D.decryptdata.key=S.decryptdata.key=new Uint8Array(g.data),S.keyLoader=null,D.loader=null,o({frag:S,keyInfo:D})},onError:(g,v,b,_)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ke.KEY_LOAD_ERROR,new Error(`HTTP Error ${g.code} loading key ${g.text}`),b,Li({url:c.url,data:void 0},g)))},onTimeout:(g,v,b)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ke.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),b))},onAbort:(g,v,b)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ke.INTERNAL_ABORTED,new Error("key loading aborted"),b))}};r.load(c,f,p)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const o=_v(i.decryptdata)||n;delete this.keyIdToKeyInfo[o],r&&r.destroy()}}function _v(s){if(s.keyFormat!==Zs.FAIRPLAY){const e=s.keyId;if(e)return Qs(e)}return s.uri}function Rw(s){const{type:e}=s;switch(e){case oi.AUDIO_TRACK:return Et.AUDIO;case oi.SUBTITLE_TRACK:return Et.SUBTITLE;default:return Et.MAIN}}function Sv(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Y${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($.MANIFEST_LOADING,this.onManifestLoading,this),e.on($.LEVEL_LOADING,this.onLevelLoading,this),e.on($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on($.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off($.MANIFEST_LOADING,this.onManifestLoading,this),e.off($.LEVEL_LOADING,this.onLevelLoading,this),e.off($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off($.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,r=i||n,o=new r(t);return this.loaders[e.type]=o,o}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:oi.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:n,pathwayId:r,url:o,deliveryDirectives:u,levelInfo:c}=t;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:oi.LEVEL,url:o,deliveryDirectives:u,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:o,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:oi.AUDIO_TRACK,url:r,deliveryDirectives:o,levelOrTrack:u})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:o,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:oi.SUBTITLE_TRACK,url:r,deliveryDirectives:o,levelOrTrack:u})}onLevelsUpdated(e,t){const i=this.loaders[oi.LEVEL];if(i){const n=i.context;n&&!t.levels.some(r=>r===n.levelOrTrack)&&(i.abort(),delete this.loaders[oi.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===oi.MANIFEST?r=i.manifestLoadPolicy.default:r=Bi({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),yt((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===oi.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===oi.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===oi.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const f=d.partTarget,p=d.targetduration;if(f&&p){const g=Math.max(f*3,p*.8)*1e3;r=Bi({},r,{maxTimeToFirstByteMs:Math.min(g,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,r.maxTimeToFirstByteMs)})}}}const o=r.errorRetry||r.timeoutRetry||{},u={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(d,f,p,g)=>{const v=this.getInternalLoader(p);this.resetInternalLoader(p.type);const b=d.data;f.parsing.start=performance.now(),ua.isMediaPlaylist(b)||p.type!==oi.MANIFEST?this.handleTrackOrLevelPlaylist(d,f,p,g||null,v):this.handleMasterPlaylist(d,f,p,g)},onError:(d,f,p,g)=>{this.handleNetworkError(f,p,!1,d,g)},onTimeout:(d,f,p)=>{this.handleNetworkError(f,p,!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,o=e.data,u=Sv(e,i),c=ua.parseMasterPlaylist(o,u);if(c.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,c.playlistParsingError,n,t);return}const{contentSteering:d,levels:f,sessionData:p,sessionKeys:g,startTimeOffset:v,variableList:b}=c;this.variableList=b,f.forEach(R=>{const{unknownCodecs:L}=R;if(L){const{preferManagedMediaSource:M}=this.hls.config;let{audioCodec:j,videoCodec:V}=R;for(let P=L.length;P--;){const z=L[P];bh(z,"audio",M)?(R.audioCodec=j=j?`${j},${z}`:z,Lc.audio[j.substring(0,4)]=2,L.splice(P,1)):bh(z,"video",M)&&(R.videoCodec=V=V?`${V},${z}`:z,Lc.video[V.substring(0,4)]=2,L.splice(P,1))}}});const{AUDIO:_=[],SUBTITLES:S,"CLOSED-CAPTIONS":D}=ua.parseMasterPlaylistMedia(o,u,c);_.length&&!_.some(L=>!L.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"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new os({}),bitrate:0,url:""})),r.trigger($.MANIFEST_LOADED,{levels:f,audioTracks:_,subtitles:S,captions:D,contentSteering:d,url:u,stats:t,networkDetails:n,sessionData:p,sessionKeys:g,startTimeOffset:v,variableList:b})}handleTrackOrLevelPlaylist(e,t,i,n,r){const o=this.hls,{id:u,level:c,type:d}=i,f=Sv(e,i),p=yt(c)?c:yt(u)?u:0,g=Rw(i),v=ua.parseLevelPlaylist(e.data,f,p,g,0,this.variableList);if(d===oi.MANIFEST){const b={attrs:new os({}),bitrate:0,details:v,name:"",url:f};v.requestScheduled=t.loading.start+ZD(v,0),o.trigger($.MANIFEST_LOADED,{levels:[b],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($.ERROR,{type:It.NETWORK_ERROR,details:ke.MANIFEST_PARSING_ERROR,fatal:t.type===oi.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 o=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===oi.LEVEL?o+=`: ${e.level} id: ${e.id}`:(e.type===oi.AUDIO_TRACK||e.type===oi.SUBTITLE_TRACK)&&(o+=` id: ${e.id} group-id: "${e.groupId}"`);const u=new Error(o);this.hls.logger.warn(`[playlist-loader]: ${o}`);let c=ke.UNKNOWN,d=!1;const f=this.getInternalLoader(e);switch(e.type){case oi.MANIFEST:c=i?ke.MANIFEST_LOAD_TIMEOUT:ke.MANIFEST_LOAD_ERROR,d=!0;break;case oi.LEVEL:c=i?ke.LEVEL_LOAD_TIMEOUT:ke.LEVEL_LOAD_ERROR,d=!1;break;case oi.AUDIO_TRACK:c=i?ke.AUDIO_TRACK_LOAD_TIMEOUT:ke.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case oi.SUBTITLE_TRACK:c=i?ke.SUBTITLE_TRACK_LOAD_TIMEOUT:ke.SUBTITLE_LOAD_ERROR,d=!1;break}f&&this.resetInternalLoader(e.type);const p={type:It.NETWORK_ERROR,details:c,fatal:d,url:e.url,loader:f,context:e,error:u,networkDetails:t,stats:r};if(n){const g=t?.url||e.url;p.response=Li({url:g,data:void 0},n)}this.hls.trigger($.ERROR,p)}handlePlaylistLoaded(e,t,i,n,r,o){const u=this.hls,{type:c,level:d,levelOrTrack:f,id:p,groupId:g,deliveryDirectives:v}=n,b=Sv(t,n),_=Rw(n);let S=typeof n.level=="number"&&_===Et.MAIN?d:void 0;const D=e.playlistParsingError;if(D){if(this.hls.logger.warn(`${D} ${e.url}`),!u.config.ignorePlaylistParsingErrors){u.trigger($.ERROR,{type:It.NETWORK_ERROR,details:ke.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:D,reason:D.message,response:t,context:n,level:S,parent:_,networkDetails:r,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const R=e.playlistParsingError=new Error("No Segments found in Playlist");u.trigger($.ERROR,{type:It.NETWORK_ERROR,details:ke.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:R,reason:R.message,response:t,context:n,level:S,parent:_,networkDetails:r,stats:i});return}switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),(!o.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case oi.MANIFEST:case oi.LEVEL:if(S){if(!f)S=0;else if(f!==u.levels[S]){const R=u.levels.indexOf(f);R>-1&&(S=R)}}u.trigger($.LEVEL_LOADED,{details:e,levelInfo:f||u.levels[0],level:S||0,id:p||0,stats:i,networkDetails:r,deliveryDirectives:v,withoutMultiVariant:c===oi.MANIFEST});break;case oi.AUDIO_TRACK:u.trigger($.AUDIO_TRACK_LOADED,{details:e,track:f,id:p||0,groupId:g||"",stats:i,networkDetails:r,deliveryDirectives:v});break;case oi.SUBTITLE_TRACK:u.trigger($.SUBTITLE_TRACK_LOADED,{details:e,track:f,id:p||0,groupId:g||"",stats:i,networkDetails:r,deliveryDirectives:v});break}}}class tr{static get version(){return Sh}static isMSESupported(){return QL()}static isSupported(){return V$()}static getMediaSource(){return il()}static get Events(){return $}static get MetadataSchema(){return er}static get ErrorTypes(){return It}static get ErrorDetails(){return ke}static get DefaultConfig(){return tr.defaultConfig?tr.defaultConfig:R$}static set DefaultConfig(e){tr.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 Gb,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=e6(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=N$(tr.DefaultConfig,e,t);this.userConfig=e,i.progressive&&O$(i,t);const{abrController:n,bufferController:r,capLevelController:o,errorController:u,fpsController:c}=i,d=new u(this),f=this.abrController=new n(this),p=new W6(this),g=i.interstitialsController,v=g?this.interstitialsController=new g(this,tr):null,b=this.bufferController=new r(this,p),_=this.capLevelController=new o(this),S=new c(this),D=new Y$(this),R=i.contentSteeringController,L=R?new R(this):null,M=this.levelController=new H$(this,L),j=new j$(this),V=new K$(this.config,this.logger),P=this.streamController=new q$(this,p,V),z=this.gapController=new F$(this,p);_.setStreamController(P),S.setStreamController(P);const I=[D,M,P];v&&I.splice(1,0,v),L&&I.splice(1,0,L),this.networkControllers=I;const O=[f,b,z,_,S,j,p];this.audioTrackController=this.createController(i.audioTrackController,I);const W=i.audioStreamController;W&&I.push(this.audioStreamController=new W(this,p,V)),this.subtitleTrackController=this.createController(i.subtitleTrackController,I);const X=i.subtitleStreamController;X&&I.push(this.subtititleStreamController=new X(this,p,V)),this.createController(i.timelineController,O),V.emeController=this.emeController=this.createController(i.emeController,O),this.cmcdController=this.createController(i.cmcdController,O),this.latencyController=this.createController($$,O),this.coreComponents=O,I.push(d);const q=d.onErrorOut;typeof q=="function"&&this.on($.ERROR,q,d),this.on($.MANIFEST_LOADED,D.onManifestLoaded,D)}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===$.ERROR;this.trigger($.ERROR,{type:It.OTHER_ERROR,details:ke.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($.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($.ERROR,{type:It.OTHER_ERROR,details:ke.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($.MEDIA_ATTACHING,n)}detachMedia(){this.logger.log("detachMedia"),this.trigger($.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger($.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,n=this._url=Nb.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($.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={[Et.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Et.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Et.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=F7()),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){N6(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 o=e[r].attrs["HDCP-LEVEL"];if(o&&o<=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=BD(t);return MD(e,i,navigator.mediaCapabilities)}}tr.defaultConfig=void 0;function Iw(s,e){const t=s.includes("?")?"&":"?";return`${s}${t}v=${e}`}function W$({src:s,muted:e=Xm,className:t}){const i=A.useRef(null),[n,r]=A.useState(!1),[o,u]=A.useState(null),c=A.useMemo(()=>Iw(s,Date.now()),[s]);return A.useEffect(()=>{let d=!1,f=null,p=null,g=null;const v=i.current;if(!v)return;const b=v;r(!1),u(null),Qm(b,{muted:e});const _=()=>{p&&window.clearTimeout(p),g&&window.clearInterval(g),p=null,g=null},S=()=>{if(d)return;_();try{b.pause()}catch{}b.removeAttribute("src"),b.load();const M=Iw(s,Date.now());b.src=M,b.load(),b.play().catch(()=>{})};async function D(){const M=Date.now();for(;!d&&Date.now()-M<2e4;){try{const j=await fetch(c,{cache:"no-store"});if(j.status===403)return{ok:!1,reason:"private"};if(j.status===404)return{ok:!1,reason:"offline"};if(j.status!==204){if(j.ok&&(await j.text()).includes("#EXTINF"))return{ok:!0}}}catch{}await new Promise(j=>setTimeout(j,400))}return{ok:!1}}async function R(){const M=await D();if(!M.ok||d){d||(u(M.reason??null),r(!0));return}if(b.canPlayType("application/vnd.apple.mpegurl")){b.src=c,b.load(),b.play().catch(()=>{});let j=Date.now(),V=-1;const P=()=>{b.currentTime>V+.01&&(V=b.currentTime,j=Date.now())},z=()=>{p||(p=window.setTimeout(()=>{p=null,!d&&Date.now()-j>3500&&S()},800))};return b.addEventListener("timeupdate",P),b.addEventListener("waiting",z),b.addEventListener("stalled",z),b.addEventListener("error",z),g=window.setInterval(()=>{d||!b.paused&&Date.now()-j>6e3&&S()},2e3),()=>{b.removeEventListener("timeupdate",P),b.removeEventListener("waiting",z),b.removeEventListener("stalled",z),b.removeEventListener("error",z)}}if(!tr.isSupported()){r(!0);return}f=new tr({lowLatencyMode:!0,liveSyncDurationCount:2,maxBufferLength:8}),f.on(tr.Events.ERROR,(j,V)=>{if(f&&V.fatal){if(V.type===tr.ErrorTypes.NETWORK_ERROR){f.startLoad();return}if(V.type===tr.ErrorTypes.MEDIA_ERROR){f.recoverMediaError();return}r(!0)}}),f.loadSource(c),f.attachMedia(b),f.on(tr.Events.MANIFEST_PARSED,()=>{b.play().catch(()=>{})})}let L;return(async()=>{const M=await R();typeof M=="function"&&(L=M)})(),()=>{d=!0,_();try{L?.()}catch{}f?.destroy()}},[s,c,e]),n?y.jsx("div",{className:"text-xs text-gray-400 italic",children:o==="private"?"Private":o==="offline"?"Offline":""}):y.jsx("video",{ref:i,className:t,playsInline:!0,autoPlay:!0,muted:e,onClick:()=>{const d=i.current;d&&(d.muted=!1,d.play().catch(()=>{}))}})}function ZL({jobId:s,thumbTick:e,autoTickMs:t=1e4,blur:i=!1,alignStartAt:n,alignEndAt:r=null,alignEveryMs:o,fastRetryMs:u,fastRetryMax:c,fastRetryWindowMs:d,className:f}){const[p,g]=A.useState(()=>typeof document>"u"?!0:!document.hidden),v=i?"blur-md":"",[b,_]=A.useState(0),[S,D]=A.useState(!1),R=A.useRef(null),[L,M]=A.useState(!1),j=A.useRef(null),V=A.useRef(0),P=A.useRef(!1),z=A.useRef(!1),I=q=>{if(typeof q=="number"&&Number.isFinite(q))return q;if(q instanceof Date)return q.getTime();const ue=Date.parse(String(q??""));return Number.isFinite(ue)?ue:NaN};A.useEffect(()=>{const q=()=>g(!document.hidden);return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[]),A.useEffect(()=>()=>{j.current&&window.clearTimeout(j.current)},[]),A.useEffect(()=>{typeof e!="number"&&(!L||!p||z.current||(z.current=!0,_(q=>q+1)))},[L,e,p]),A.useEffect(()=>{if(typeof e=="number"||!L||!p)return;const q=Number(o??t??1e4);if(!Number.isFinite(q)||q<=0)return;const ue=n?I(n):NaN,ie=r?I(r):NaN;if(Number.isFinite(ue)){let G;const J=()=>{const oe=Date.now();if(Number.isFinite(ie)&&oe>=ie)return;const F=Math.max(0,oe-ue)%q,ee=F===0?q:q-F;G=window.setTimeout(()=>{_(pe=>pe+1),J()},ee)};return J(),()=>{G&&window.clearTimeout(G)}}const Y=window.setInterval(()=>{_(G=>G+1)},q);return()=>window.clearInterval(Y)},[e,t,L,p,n,r,o]),A.useEffect(()=>{const q=R.current;if(!q)return;const ue=new IntersectionObserver(ie=>{const Y=ie[0];M(!!(Y&&(Y.isIntersecting||Y.intersectionRatio>0)))},{root:null,threshold:0,rootMargin:"300px 0px"});return ue.observe(q),()=>ue.disconnect()},[]);const O=typeof e=="number"?e:b;A.useEffect(()=>{D(!1)},[O]),A.useEffect(()=>{P.current=!1,V.current=0,z.current=!1,D(!1),_(q=>q+1)},[s]);const W=A.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s)}&v=${O}`,[s,O]),X=A.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s)}&hover=1&file=index_hq.m3u8`,[s]);return y.jsx(DA,{content:(q,{close:ue})=>q&&y.jsx("div",{className:"w-[420px] max-w-[calc(100vw-1.5rem)]",children:y.jsxs("div",{className:"relative aspect-video overflow-hidden rounded-lg bg-black",children:[y.jsx(W$,{src:X,muted:!1,className:["w-full h-full relative z-0"].filter(Boolean).join(" ")}),y.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:[y.jsx("span",{className:"inline-block size-1.5 rounded-full bg-white animate-pulse"}),"Live"]}),y.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:ie=>{ie.preventDefault(),ie.stopPropagation(),ue()},children:y.jsx(qx,{className:"h-4 w-4"})})]})}),children:y.jsx("div",{ref:R,className:["block relative rounded bg-gray-100 dark:bg-white/5 overflow-hidden",f||"w-full h-full"].join(" "),children:S?y.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"}):y.jsx("img",{src:W,loading:L?"eager":"lazy",fetchPriority:L?"high":"auto",alt:"",className:["block w-full h-full object-cover object-center",v].filter(Boolean).join(" "),onLoad:()=>{P.current=!0,V.current=0,j.current&&window.clearTimeout(j.current),D(!1)},onError:()=>{if(D(!0),!u||!L||!p||P.current)return;const q=n?I(n):NaN,ue=Number(d??6e4);if(!(!Number.isFinite(q)||Date.now()-q<ue))return;const Y=Number(c??25);V.current>=Y||(j.current&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{V.current+=1,_(G=>G+1)},u))}})})})}const Ic=new Map;let Nw=!1;function X$(){Nw||(Nw=!0,document.addEventListener("visibilitychange",()=>{if(document.hidden)for(const s of Ic.values())s.es&&(s.es.close(),s.es=null,s.dispatchers.clear());else for(const s of Ic.values())s.refs>0&&!s.es&&JL(s)}))}function JL(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 o of t)o(r)};s.dispatchers.set(e,i),s.es.addEventListener(e,i)}s.es.onerror=()=>{}}}function Q$(s){s.es&&(s.es.close(),s.es=null,s.dispatchers.clear())}function Z$(s){let e=Ic.get(s);return e||(e={url:s,es:null,refs:0,listeners:new Map,dispatchers:new Map},Ic.set(s,e)),e}function eR(s,e,t){X$();const i=Z$(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=o=>{let u=null;try{u=JSON.parse(String(o.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 JL(i);return()=>{const r=Ic.get(s);if(!r)return;const o=r.listeners.get(e);o&&(o.delete(t),o.size===0&&r.listeners.delete(e)),r.refs=Math.max(0,r.refs-1),r.refs===0&&(Q$(r),Ic.delete(s))}}const Lp=s=>{const e=s;return e.modelName??e.model??e.modelKey??e.username??e.name??"—"},tR=s=>{const e=s;return e.sourceUrl??e.url??e.roomUrl??""},iR=s=>{const e=s;return String(e.imageUrl??e.image_url??"").trim()},Ow=s=>{const e=s;return String(e.key??e.id??Lp(s))},Cr=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},Mw=s=>{if(s.kind==="job"){const t=s.job;return Cr(t.addedAt)||Cr(t.createdAt)||Cr(t.enqueuedAt)||Cr(t.queuedAt)||Cr(t.requestedAt)||Cr(t.startedAt)||0}const e=s.pending;return Cr(e.addedAt)||Cr(e.createdAt)||Cr(e.enqueuedAt)||Cr(e.queuedAt)||Cr(e.requestedAt)||0},sR=s=>{switch(s){case"stopping":return"Stop wird angefordert…";case"remuxing":return"Remux zu MP4…";case"moving":return"Verschiebe nach Done…";case"assets":return"Erstelle Vorschau…";default:return""}};async function J$(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 e9({job:s}){const e=String(s?.phase??"").trim(),t=Number(s?.progress??0),n=(e?sR(e)||e:"")||String(s?.status??"").trim().toLowerCase(),r=Number.isFinite(t)&&t>0&&t<100,o=!r&&!!e&&(!Number.isFinite(t)||t<=0||t>=100);return y.jsx("div",{className:"min-w-0",children:r?y.jsx(vc,{label:n,value:Math.max(0,Math.min(100,t)),showPercent:!0,size:"sm",className:"w-full min-w-0 sm:min-w-[220px]"}):o?y.jsx(vc,{label:n,indeterminate:!0,size:"sm",className:"w-full min-w-0 sm:min-w-[220px]"}):y.jsx("div",{className:"truncate",children:y.jsx("span",{className:"font-medium",children:n})})})}function t9({r:s,nowMs:e,blurPreviews:t,modelsByKey:i,stopRequestedIds:n,markStopRequested:r,onOpenPlayer:o,onStopJob:u,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f}){if(s.kind==="pending"){const q=s.pending,ue=Lp(q),ie=tR(q),Y=(q.currentShow||"unknown").toLowerCase();return y.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:[y.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"}),y.jsxs("div",{className:"relative p-3",children:[y.jsxs("div",{className:"flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",title:ue,children:ue}),y.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-gray-600 dark:text-gray-300",children:[y.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"}),y.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:Y})]})]}),y.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:"⏳"})]}),y.jsx("div",{className:"mt-3",children:(()=>{const G=iR(q);return y.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:G?y.jsx("img",{src:G,alt:ue,className:["h-full w-full object-cover",t?"blur-md":""].join(" "),loading:"lazy",referrerPolicy:"no-referrer",onError:J=>{J.currentTarget.style.display="none"}}):y.jsx("div",{className:"grid h-full w-full place-items-center",children:y.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-300",children:"Waiting…"})})})})()}),ie?y.jsx("a",{href:ie,target:"_blank",rel:"noreferrer",className:"mt-3 block truncate text-xs text-indigo-600 hover:underline dark:text-indigo-400",onClick:G=>G.stopPropagation(),title:ie,children:ie}):null]})]})}const p=s.job,g=Px(p.output),v=sT(p.output||""),b=String(p.phase??"").trim(),_=b?sR(b)||b:"",S=!!n[p.id],D=String(p.status??"").toLowerCase(),R=!!b||D!=="running"||S,L=D||"unknown",M=_||L,j=Number(p.progress??0),V=Number.isFinite(j)&&j>0&&j<100,P=!V&&!!b&&(!Number.isFinite(j)||j<=0||j>=100),z=g&&g!=="—"?g.toLowerCase():"",I=z?i[z]:void 0,O=!!I?.favorite,W=I?.liked===!0,X=!!I?.watching;return y.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:()=>o(p),role:"button",tabIndex:0,onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&o(p)},children:[y.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"}),y.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"}),y.jsxs("div",{className:"relative p-3",children:[y.jsxs("div",{className:"flex items-start gap-3",children:[y.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:y.jsx(ZL,{jobId:p.id,blur:t,alignStartAt:p.startedAt,alignEndAt:p.endedAt??null,alignEveryMs:1e4,fastRetryMs:1e3,fastRetryMax:25,fastRetryWindowMs:6e4,className:"w-full h-full"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.jsx("div",{className:"truncate text-base font-semibold text-gray-900 dark:text-white",title:g,children:g}),y.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",R?"ring-1 ring-amber-500/30":"ring-1 ring-emerald-500/25"].join(" "),title:L,children:L})]}),y.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-600 dark:text-gray-300",title:p.output,children:v||"—"})]}),y.jsxs("div",{className:"shrink-0 flex flex-col items-end gap-1",children:[y.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:nR(p,e)}),y.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:aR(rR(p))})]})]}),p.sourceUrl?y.jsx("a",{href:p.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:p.sourceUrl,children:p.sourceUrl}):null]})]}),V||P?y.jsx("div",{className:"mt-3",children:V?y.jsx(vc,{label:M,value:Math.max(0,Math.min(100,j)),showPercent:!0,size:"sm",className:"w-full"}):y.jsx(vc,{label:M,indeterminate:!0,size:"sm",className:"w-full"})}):null,y.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/30 pt-3 dark:border-white/10",children:[y.jsx("div",{className:"flex items-center gap-1",onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:y.jsx(da,{job:p,variant:"table",busy:R,isFavorite:O,isLiked:W,isWatching:X,showHot:!1,showKeep:!1,showDelete:!1,showFavorite:!0,showLike:!0,onToggleFavorite:c,onToggleLike:d,onToggleWatch:f,order:["watch","favorite","like","details"],className:"flex items-center gap-1"})}),y.jsx(ti,{size:"sm",variant:"primary",disabled:R,className:"shrink-0",onClick:q=>{q.stopPropagation(),!R&&(r(p.id),u(p.id))},children:R?"Stoppe…":"Stop"})]})]})]})}const sT=s=>(s||"").replaceAll("\\","/").trim().split("/").pop()||"",Px=s=>{const e=sT(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},i9=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`},nR=(s,e)=>{const t=Date.parse(String(s.startedAt||""));if(!Number.isFinite(t))return"—";const i=s.endedAt?Date.parse(String(s.endedAt)):e;return Number.isFinite(i)?i9(i-t):"—"},rR=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},aR=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]}`};function s9({jobs:s,pending:e=[],onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:o,modelsByKey:u={},blurPreviews:c}){const[d,f]=A.useState(!1),[p,g]=A.useState(!1),v=A.useRef(null),[b,_]=A.useState(!1),S=A.useCallback(async()=>{try{const J=!!(await J$("/api/autostart/state",{cache:"no-store"}))?.paused;v.current=J,g(J)}catch{}},[]);A.useEffect(()=>{S();const G=eR("/api/autostart/state/stream","autostart",J=>{const oe=!!J?.paused;v.current!==oe&&(v.current=oe,g(oe))});return()=>{G()}},[S]);const D=A.useCallback(async()=>{if(!(b||p)){_(!0);try{await fetch("/api/autostart/pause",{method:"POST"}),g(!0)}catch{}finally{_(!1)}}},[b,p]),R=A.useCallback(async()=>{if(!(b||!p)){_(!0);try{await fetch("/api/autostart/resume",{method:"POST"}),g(!1)}catch{}finally{_(!1)}}},[b,p]),[L,M]=A.useState({}),[j,V]=A.useState({}),P=A.useCallback(G=>{const J=Array.isArray(G)?G:[G];M(oe=>{const ce={...oe};for(const F of J)F&&(ce[F]=!0);return ce}),V(oe=>{const ce={...oe};for(const F of J)F&&(ce[F]=!0);return ce})},[]);A.useEffect(()=>{M(G=>{const J=Object.keys(G);if(J.length===0)return G;const oe={};for(const ce of J){const F=s.find(_e=>_e.id===ce);if(!F)continue;String(F.phase??"").trim()||F.status!=="running"||(oe[ce]=!0)}return oe})},[s]);const[z,I]=A.useState(()=>Date.now()),O=A.useMemo(()=>s.some(G=>!G.endedAt&&G.status==="running"),[s]);A.useEffect(()=>{if(!O)return;const G=window.setInterval(()=>I(Date.now()),15e3);return()=>window.clearInterval(G)},[O]);const W=A.useMemo(()=>s.filter(G=>{const J=String(G.phase??"").trim(),oe=!!L[G.id];return!(!!J||G.status!=="running"||oe)}).map(G=>G.id),[s,L]),X=A.useMemo(()=>[{key:"preview",header:"Vorschau",widthClassName:"w-[96px]",cell:G=>{if(G.kind==="job"){const F=G.job;return y.jsx("div",{className:"grid w-[96px] h-[60px] overflow-hidden rounded-md",children:y.jsx(ZL,{jobId:F.id,blur:c,alignStartAt:F.startedAt,alignEndAt:F.endedAt??null,alignEveryMs:1e4,fastRetryMs:1e3,fastRetryMax:25,fastRetryWindowMs:6e4,className:"w-full h-full"})})}const J=G.pending,oe=Lp(J),ce=iR(J);return ce?y.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:y.jsx("img",{src:ce,alt:oe,className:["h-full w-full object-cover",c?"blur-md":""].join(" "),loading:"lazy",referrerPolicy:"no-referrer",onError:F=>{F.currentTarget.style.display="none"}})}):y.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:G=>{if(G.kind==="job"){const F=G.job,ee=sT(F.output||""),pe=Px(F.output),_e=String(F.status??"").toLowerCase(),ve=!!L[F.id],Ce=!!j[F.id],Be=_e==="stopped"||Ce&&!!F.endedAt,tt=Be?"stopped":_e||"unknown",Je=!Be&&ve,Ct=Je?"stopping":tt;return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.jsx("span",{className:"min-w-0 block max-w-[170px] truncate font-medium",title:pe,children:pe}),y.jsx("span",{className:["shrink-0 inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold ring-1",_e==="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":Be?"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":_e==="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":_e==="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":Je?"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:Ct,children:Ct})]}),y.jsx("span",{className:"block max-w-[220px] truncate",title:F.output,children:ee}),F.sourceUrl?y.jsx("a",{href:F.sourceUrl,target:"_blank",rel:"noreferrer",title:F.sourceUrl,className:"block max-w-[260px] truncate text-indigo-600 dark:text-indigo-400 hover:underline",onClick:st=>st.stopPropagation(),children:F.sourceUrl}):y.jsx("span",{className:"block max-w-[260px] truncate text-gray-500 dark:text-gray-400",children:"—"})]})}const J=G.pending,oe=Lp(J),ce=tR(J);return y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"block max-w-[170px] truncate font-medium",title:oe,children:oe}),ce?y.jsx("a",{href:ce,target:"_blank",rel:"noreferrer",title:ce,className:"block max-w-[260px] truncate text-indigo-600 dark:text-indigo-400 hover:underline",onClick:F=>F.stopPropagation(),children:ce}):y.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:G=>{if(G.kind==="job"){const ce=G.job;return y.jsx(e9,{job:ce})}const oe=(G.pending.currentShow||"unknown").toLowerCase();return y.jsx("div",{className:"min-w-0",children:y.jsx("div",{className:"truncate",children:y.jsx("span",{className:"font-medium",children:oe})})})}},{key:"runtime",header:"Dauer",widthClassName:"w-[90px]",cell:G=>G.kind==="job"?nR(G.job,z):"—"},{key:"size",header:"Größe",align:"right",widthClassName:"w-[110px]",cell:G=>G.kind==="job"?y.jsx("span",{className:"tabular-nums text-sm text-gray-900 dark:text-white",children:aR(rR(G.job))}):y.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:G=>{if(G.kind!=="job")return y.jsx("div",{className:"pr-2 text-right text-sm text-gray-500 dark:text-gray-400",children:"—"});const J=G.job,oe=String(J.phase??"").trim(),ce=!!L[J.id],F=!!oe||J.status!=="running"||ce,ee=Px(J.output||""),pe=ee&&ee!=="—"?u[ee.toLowerCase()]:void 0,_e=!!pe?.favorite,ve=pe?.liked===!0,Ce=!!pe?.watching;return y.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 pr-2",children:[y.jsx(da,{job:J,variant:"table",busy:F,isFavorite:_e,isLiked:ve,isWatching:Ce,showHot:!1,showKeep:!1,showDelete:!1,showFavorite:!0,showLike:!0,onToggleFavorite:n,onToggleLike:r,onToggleWatch:o,order:["watch","favorite","like","details"],className:"flex items-center gap-1"}),(()=>{const Be=String(J.phase??"").trim(),tt=!!L[J.id],Je=!!Be||J.status!=="running"||tt;return y.jsx(ti,{size:"sm",variant:"primary",disabled:Je,className:"shrink-0",onClick:Ct=>{Ct.stopPropagation(),!Je&&(P(J.id),i(J.id))},children:Je?"Stoppe…":"Stop"})})()]})}}],[c,P,u,z,i,n,r,o,L,j]),q=e.length>0,ue=s.length>0,ie=A.useMemo(()=>{const G=[...s.map(J=>({kind:"job",job:J})),...e.map(J=>({kind:"pending",pending:J}))];return G.sort((J,oe)=>Mw(oe)-Mw(J)),G},[s,e]),Y=A.useCallback(async()=>{if(!d&&W.length!==0){f(!0);try{P(W),await Promise.allSettled(W.map(G=>Promise.resolve(i(G))))}finally{f(!1)}}},[d,W,P,i]);return y.jsxs("div",{className:"grid gap-3",children:[y.jsx("div",{className:"sticky top-[56px] z-20",children:y.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:y.jsxs("div",{className:"flex items-center justify-between gap-2 p-3",children:[y.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:"Downloads"}),y.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:ie.length})]}),y.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[y.jsx(ti,{size:"sm",variant:p?"secondary":"primary",disabled:b,onClick:G=>{G.preventDefault(),G.stopPropagation(),p?R():D()},className:"hidden sm:inline-flex",title:p?"Autostart fortsetzen":"Autostart pausieren",leadingIcon:p?y.jsx(aM,{className:"size-4 shrink-0"}):y.jsx(lM,{className:"size-4 shrink-0"}),children:"Autostart"}),y.jsx(ti,{size:"sm",variant:"primary",disabled:d||W.length===0,onClick:G=>{G.preventDefault(),G.stopPropagation(),Y()},className:"hidden sm:inline-flex",title:W.length===0?"Nichts zu stoppen":"Alle laufenden stoppen",children:d?"Stoppe alle…":`Alle stoppen (${W.length})`})]})]})})}),q||ue?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"mt-3 grid gap-4 sm:hidden",children:ie.map(G=>y.jsx(t9,{r:G,nowMs:z,blurPreviews:c,modelsByKey:u,stopRequestedIds:L,markStopRequested:P,onOpenPlayer:t,onStopJob:i,onToggleFavorite:n,onToggleLike:r,onToggleWatch:o},G.kind==="job"?`job:${G.job.id}`:`pending:${Ow(G.pending)}`))}),y.jsx("div",{className:"mt-3 hidden sm:block overflow-x-auto",children:y.jsx(Gx,{rows:ie,columns:X,getRowKey:G=>G.kind==="job"?`job:${G.job.id}`:`pending:${Ow(G.pending)}`,striped:!0,fullWidth:!0,stickyHeader:!0,compact:!1,card:!0,onRowClick:G=>{G.kind==="job"&&t(G.job)}})})]}):y.jsx(ha,{grayBody:!0,children:y.jsxs("div",{className:"flex items-center gap-3",children:[y.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:y.jsx("span",{className:"text-lg",children:"⏸️"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Keine laufenden Downloads"}),y.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 Bx({open:s,onClose:e,title:t,children:i,footer:n,icon:r,width:o="max-w-lg"}){return y.jsx(nh,{show:s,as:A.Fragment,children:y.jsxs(sc,{as:"div",className:"relative z-50",onClose:e,children:[y.jsx(nh.Child,{as:A.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:y.jsx("div",{className:"fixed inset-0 bg-gray-500/75 dark:bg-gray-900/50"})}),y.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto px-4 py-6 sm:px-6",children:y.jsx("div",{className:"min-h-full flex items-start justify-center sm:items-center",children:y.jsx(nh.Child,{as:A.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:y.jsxs(sc.Panel,{className:["relative w-full transform rounded-lg bg-white text-left shadow-xl transition-all","max-h-[calc(100vh-3rem)] sm:max-h-[calc(100vh-4rem)]","flex flex-col","dark:bg-gray-800 dark:outline dark:-outline-offset-1 dark:outline-white/10",o].join(" "),children:[r&&y.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-500/10",children:r}),y.jsxs("div",{className:"px-6 pt-6 flex items-start justify-between gap-3",children:[y.jsx("div",{className:"min-w-0",children:t?y.jsx(sc.Title,{className:"text-base font-semibold text-gray-900 dark:text-white truncate",children:t}):null}),y.jsx("button",{type:"button",onClick:e,className:`\r
inline-flex shrink-0 items-center justify-center rounded-lg p-1.5\r
text-gray-500 hover:text-gray-900 hover:bg-black/5\r
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600\r
dark:text-gray-400 dark:hover:text-white dark:hover:bg-white/10 dark:focus-visible:outline-indigo-500\r
`,"aria-label":"Schließen",title:"Schließen",children:y.jsx(qx,{className:"size-5"})})]}),y.jsx("div",{className:"px-6 pb-6 pt-4 text-sm text-gray-700 dark:text-gray-300 overflow-y-auto",children:i}),n?y.jsx("div",{className:"px-6 py-4 border-t border-gray-200/70 dark:border-white/10 flex justify-end gap-3",children:n}):null]})})})})]})})}async function Ev(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 Pw=(s,e)=>y.jsx("span",{className:yi("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 n9(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 wv(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 r9(s){return String(s??"").trim().toLowerCase().replace(/^www\./,"")}function a9(s){const t=String(s||"").replaceAll("\\","/").split("/");return t[t.length-1]||""}function o9(s){const e=String(s||"");return e.toUpperCase().startsWith("HOT ")?e.slice(4).trim():e}function l9(s){const e=a9(s||""),t=o9(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 Bw(s){if(s.isUrl&&/^https?:\/\//i.test(String(s.input??"")))return String(s.input);const e=r9(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 Fw({title:s,active:e,hiddenUntilHover:t,onClick:i,icon:n}){return y.jsx("span",{className:yi(t&&!e?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:y.jsx(ti,{variant:e?"soft":"secondary",size:"xs",className:yi("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:y.jsx("span",{className:"text-base leading-none",children:n})})})}function Uw(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 u9(){const[s,e]=A.useState([]),t=A.useRef({}),[i,n]=A.useState(!1),[r,o]=A.useState(null),[u,c]=A.useState(""),[d,f]=A.useState(1),p=10,[g,v]=A.useState([]),[b,_]=A.useState({}),[S,D]=A.useState(!1),[R,L]=A.useState({key:"videos",direction:"desc"}),M=A.useCallback(async()=>{D(!0);try{const ye=await fetch("/api/record/done?all=1&includeKeep=1",{cache:"no-store"});if(!ye.ok)return;const ze=await ye.json().catch(()=>null),We=Array.isArray(ze?.items)?ze.items:Array.isArray(ze)?ze:[],et={};for(const ot of We){const nt=l9(ot.output);if(!nt||nt==="—")continue;const vt=nt.trim().toLowerCase();vt&&(et[vt]=(et[vt]??0)+1)}_(et)}finally{D(!1)}},[]),j=A.useMemo(()=>new Set(g.map(ye=>ye.toLowerCase())),[g]),V=A.useCallback(ye=>{const ze=ye.toLowerCase();v(We=>We.some(ot=>ot.toLowerCase()===ze)?We.filter(ot=>ot.toLowerCase()!==ze):[...We,ye])},[]),P=A.useCallback(()=>v([]),[]);A.useEffect(()=>{const ye=ze=>{const We=ze,et=Array.isArray(We.detail?.tags)?We.detail.tags:[];v(et)};return window.addEventListener("models:set-tag-filter",ye),()=>window.removeEventListener("models:set-tag-filter",ye)},[]);const[z,I]=A.useState(""),[O,W]=A.useState(null),[X,q]=A.useState(null),[ue,ie]=A.useState(!1),[Y,G]=A.useState(!1),[J,oe]=A.useState(null),[ce,F]=A.useState(null),[ee,pe]=A.useState("favorite"),[_e,ve]=A.useState(!1),[Ce,Be]=A.useState(null);async function tt(){if(J){ve(!0),F(null),o(null);try{const ye=new FormData;ye.append("file",J),ye.append("kind",ee);const ze=await fetch("/api/models/import",{method:"POST",body:ye});if(!ze.ok)throw new Error(await ze.text());const We=await ze.json();F(`✅ Import: ${We.inserted} neu, ${We.updated} aktualisiert, ${We.skipped} übersprungen`),G(!1),oe(null),await st(),window.dispatchEvent(new Event("models-changed"))}catch(ye){Be(ye?.message??String(ye))}finally{ve(!1)}}}function Je(ye){return{output:`${ye}_01_01_2000__00-00-00.mp4`}}const Ct=()=>{Be(null),F(null),oe(null),pe("favorite"),G(!0)},st=A.useCallback(async()=>{n(!0),o(null);try{const ye=await Ev("/api/models/list",{cache:"no-store"});e(Array.isArray(ye)?ye:[]),M()}catch(ye){o(ye?.message??String(ye))}finally{n(!1)}},[M]);A.useEffect(()=>{M()},[M]),A.useEffect(()=>{st()},[st]),A.useEffect(()=>{const ye=ze=>{const et=ze?.detail??{};if(et?.model){const ot=et.model;e(nt=>{const vt=nt.findIndex(Ft=>Ft.id===ot.id);if(vt===-1)return nt;const Xe=nt.slice();return Xe[vt]=ot,Xe});return}if(et?.removed&&et?.id){const ot=String(et.id);e(nt=>nt.filter(vt=>vt.id!==ot));return}st()};return window.addEventListener("models-changed",ye),()=>window.removeEventListener("models-changed",ye)},[st]),A.useEffect(()=>{const ye=z.trim();if(!ye){W(null),q(null);return}const ze=n9(ye);if(!ze){W(null),q("Bitte nur gültige http(s) URLs einfügen (keine Modelnamen).");return}const We=window.setTimeout(async()=>{try{const et=await Ev("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:ze})});if(!et?.isUrl){W(null),q("Bitte nur URLs einfügen (keine Modelnamen).");return}W(et),q(null)}catch(et){W(null),q(et?.message??String(et))}},300);return()=>window.clearTimeout(We)},[z]);const mt=A.useMemo(()=>s.map(ye=>({m:ye,hay:`${ye.modelKey} ${ye.host??""} ${ye.input??""} ${ye.tags??""}`.toLowerCase()})),[s]),pt=A.useDeferredValue(u),ut=A.useMemo(()=>[{key:"statusAll",header:"Status",align:"center",cell:ye=>{const ze=ye.liked===!0,We=ye.favorite===!0,et=ye.watching===!0,ot=!et&&!We&&!ze;return y.jsxs("div",{className:"group flex items-center justify-center gap-1 w-[110px]",children:[y.jsx("span",{className:yi(ot&&!et?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:y.jsx(ti,{variant:et?"soft":"secondary",size:"xs",className:yi("px-2 py-1 leading-none",!et&&"bg-transparent shadow-none hover:bg-gray-50 dark:hover:bg-white/10"),title:et?"Nicht mehr beobachten":"Beobachten",onClick:nt=>{nt.stopPropagation(),lt(ye.id,{watched:!et})},children:y.jsx("span",{className:yi("text-base leading-none",et?"text-indigo-600 dark:text-indigo-400":"text-gray-400 dark:text-gray-500"),children:"👁"})})}),y.jsx(Fw,{title:We?"Favorit entfernen":"Als Favorit markieren",active:We,hiddenUntilHover:ot,onClick:nt=>{nt.stopPropagation(),We?lt(ye.id,{favorite:!1}):lt(ye.id,{favorite:!0,liked:!1})},icon:y.jsx("span",{className:We?"text-amber-500":"text-gray-400 dark:text-gray-500",children:"★"})}),y.jsx(Fw,{title:ze?"Gefällt mir entfernen":"Gefällt mir",active:ze,hiddenUntilHover:ot,onClick:nt=>{nt.stopPropagation(),ze?lt(ye.id,{liked:!1}):lt(ye.id,{liked:!0,favorite:!1})},icon:y.jsx("span",{className:ze?"text-rose-500":"text-gray-400 dark:text-gray-500",children:"♥"})})]})}},{key:"model",header:"Model",sortable:!0,sortValue:ye=>(ye.modelKey||"").toLowerCase(),cell:ye=>{const ze=Bw(ye);return y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.jsx("div",{className:"font-medium truncate",children:ye.modelKey}),ze?y.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",title:ze,onClick:We=>{We.stopPropagation(),window.open(ze,"_blank","noreferrer")},children:"↗"}):null]}),y.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:ye.host??"—"}),ze?y.jsx("div",{className:"text-xs text-indigo-600 dark:text-indigo-400 truncate max-w-[520px]",children:ze}):null]})}},{key:"videos",header:"Videos",sortable:!0,sortValue:ye=>{const ze=String(ye.modelKey||"").trim().toLowerCase(),We=b[ze];return typeof We=="number"?We:0},align:"right",cell:ye=>{const ze=String(ye.modelKey||"").trim().toLowerCase(),We=b[ze];return y.jsx("span",{className:"tabular-nums text-sm text-gray-900 dark:text-white w-[64px] inline-block text-right",children:typeof We=="number"?We:S?"…":0})}},{key:"tags",header:"Tags",sortable:!0,sortValue:ye=>wv(ye.tags).length,cell:ye=>{const ze=wv(ye.tags),We=ze.slice(0,6),et=ze.length-We.length,ot=ze.join(", ");return y.jsxs("div",{className:"flex flex-wrap gap-2 max-w-[520px]",title:ot||void 0,children:[ye.hot?Pw(!0,"🔥 HOT"):null,ye.keep?Pw(!0,"📌 Behalten"):null,We.map(nt=>y.jsx(Lr,{tag:nt,title:nt,active:j.has(nt.toLowerCase()),onClick:V},nt)),et>0?y.jsxs(Lr,{title:ot,children:["+",et]}):null,!ye.hot&&!ye.keep&&ze.length===0?y.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"}):null]})}},{key:"actions",header:"",align:"right",cell:ye=>y.jsx("div",{className:"flex justify-end w-[56px]",children:y.jsx(da,{job:Je(ye.modelKey),variant:"table",order:["details"],className:"flex items-center"})})}],[j,V,b,S]),Ht=A.useMemo(()=>{const ye=pt.trim().toLowerCase(),ze=ye?mt.filter(We=>We.hay.includes(ye)).map(We=>We.m):s;return j.size===0?ze:ze.filter(We=>{const et=wv(We.tags);if(et.length===0)return!1;const ot=new Set(et.map(nt=>nt.toLowerCase()));for(const nt of j)if(!ot.has(nt))return!1;return!0})},[s,mt,pt,j]),at=A.useMemo(()=>{if(!R)return Ht;const ye=ut.find(et=>et.key===R.key);if(!ye)return Ht;const ze=R.direction==="asc"?1:-1,We=Ht.map((et,ot)=>({r:et,i:ot}));return We.sort((et,ot)=>{let nt=0;if(ye.sortFn)nt=ye.sortFn(et.r,ot.r);else{const vt=ye.sortValue?ye.sortValue(et.r):et.r?.[ye.key],Xe=ye.sortValue?ye.sortValue(ot.r):ot.r?.[ye.key],Ft=Uw(vt),Gt=Uw(Xe);Ft.isNull&&!Gt.isNull?nt=1:!Ft.isNull&&Gt.isNull?nt=-1:Ft.kind==="number"&&Gt.kind==="number"?nt=Ft.value<Gt.value?-1:Ft.value>Gt.value?1:0:nt=String(Ft.value).localeCompare(String(Gt.value),void 0,{numeric:!0})}return nt===0?et.i-ot.i:nt*ze}),We.map(et=>et.r)},[Ht,R,ut]);A.useEffect(()=>{f(1)},[u,g]);const gt=at.length,Dt=A.useMemo(()=>Math.max(1,Math.ceil(gt/p)),[gt,p]);A.useEffect(()=>{d>Dt&&f(Dt)},[d,Dt]);const Nt=A.useMemo(()=>{const ye=(d-1)*p;return at.slice(ye,ye+p)},[at,d,p]),dt=async()=>{if(O){if(!O.isUrl){q("Bitte nur URLs einfügen (keine Modelnamen).");return}ie(!0),o(null);try{const ye=await Ev("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});e(ze=>{const We=ze.filter(et=>et.id!==ye.id);return[ye,...We]}),I(""),W(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:ye}}))}catch(ye){o(ye?.message??String(ye))}finally{ie(!1)}}};async function lt(ye,ze){if(o(null),t.current[ye])return;t.current[ye]=!0;const We=s.find(et=>et.id===ye)??null;if(We){const et={...We,...ze};typeof ze?.watched=="boolean"&&(et.watching=ze.watched),ze?.favorite===!0&&(et.liked=!1),ze?.liked===!0&&(et.favorite=!1),e(ot=>ot.map(nt=>nt.id===ye?et:nt)),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:et}}))}try{const et=await fetch("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:ye,...ze})});if(et.status===204){e(nt=>nt.filter(vt=>vt.id!==ye)),We?window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:We.id,modelKey:We.modelKey}})):window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:ye}}));return}if(!et.ok){const nt=await et.text().catch(()=>"");throw new Error(nt||`HTTP ${et.status}`)}const ot=await et.json();e(nt=>{const vt=nt.findIndex(Ft=>Ft.id===ot.id);if(vt===-1)return nt;const Xe=nt.slice();return Xe[vt]=ot,Xe}),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:ot}}))}catch(et){We&&(e(ot=>ot.map(nt=>nt.id===ye?We:nt)),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:We}}))),o(et?.message??String(et))}finally{delete t.current[ye]}}return y.jsxs("div",{className:"space-y-4",children:[y.jsx(ha,{header:y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Model hinzufügen"}),grayBody:!0,children:y.jsxs("div",{className:"grid gap-2",children:[y.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[y.jsx("input",{value:z,onChange:ye=>I(ye.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"}),y.jsx(ti,{className:"px-3 py-2 text-sm",onClick:dt,disabled:!O||ue,title:O?"In Models speichern":"Bitte gültige URL einfügen",children:"Hinzufügen"}),y.jsx(ti,{className:"px-3 py-2 text-sm",onClick:st,disabled:i,children:"Aktualisieren"})]}),X?y.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:X}):O?y.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Gefunden: ",y.jsx("span",{className:"font-medium",children:O.modelKey}),O.host?y.jsxs("span",{className:"opacity-70",children:[" • ",O.host]}):null]}):null,r?y.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:r}):null]})}),y.jsxs(ha,{header:y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"grid gap-2 sm:flex sm:items-center sm:justify-between",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Models ",y.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",Ht.length,")"]})]}),y.jsx("div",{className:"sm:hidden",children:y.jsx(ti,{variant:"secondary",size:"md",onClick:Ct,children:"Import"})})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"hidden sm:block",children:y.jsx(ti,{variant:"secondary",size:"md",onClick:Ct,children:"Importieren"})}),y.jsx("input",{value:u,onChange:ye=>c(ye.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
`})]})]}),g.length>0?y.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[y.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Tag-Filter:"}),y.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.map(ye=>y.jsx(Lr,{tag:ye,active:!0,onClick:V,title:ye},ye)),y.jsx(ti,{size:"sm",variant:"soft",className:"text-xs font-medium text-gray-600 hover:underline dark:text-gray-300",onClick:P,children:"Zurücksetzen"})]})]}):null]}),noBodyPadding:!0,children:[y.jsx("div",{className:"overflow-x-auto",children:y.jsx("div",{className:"min-w-[980px]",children:y.jsx(Gx,{rows:Nt,columns:ut,getRowKey:ye=>ye.id,striped:!0,compact:!0,fullWidth:!0,stickyHeader:!0,sort:R,onSortChange:ye=>L(ye),onRowClick:ye=>{const ze=Bw(ye);ze&&window.open(ze,"_blank","noreferrer")}})})}),y.jsx(IA,{page:d,pageSize:p,totalItems:gt,onPageChange:f})]}),y.jsx(Bx,{open:Y,onClose:()=>!_e&&G(!1),title:"Models importieren",footer:y.jsxs(y.Fragment,{children:[y.jsx(ti,{variant:"secondary",onClick:()=>G(!1),disabled:_e,children:"Abbrechen"}),y.jsx(ti,{variant:"primary",onClick:tt,isLoading:_e,disabled:!J||_e,children:"Import starten"})]}),children:y.jsxs("div",{className:"space-y-3",children:[y.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Wähle eine CSV-Datei zum Import aus."}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Import-Typ"}),y.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[y.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[y.jsx("input",{type:"radio",name:"import-kind",value:"favorite",checked:ee==="favorite",onChange:()=>pe("favorite"),disabled:_e}),"Favoriten (★)"]}),y.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[y.jsx("input",{type:"radio",name:"import-kind",value:"liked",checked:ee==="liked",onChange:()=>pe("liked"),disabled:_e}),"Gefällt mir (♥)"]})]})]}),y.jsx("input",{type:"file",accept:".csv,text/csv",onChange:ye=>{const ze=ye.target.files?.[0]??null;Be(null),oe(ze)},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"}),J?y.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Ausgewählt: ",y.jsx("span",{className:"font-medium",children:J.name})]}):null,Ce?y.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:Ce}):null,ce?y.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:ce}):null]})})]})}function pn(...s){return s.filter(Boolean).join(" ")}const c9=new Intl.NumberFormat("de-DE");function Av(s){return s==null||!Number.isFinite(s)?"—":c9.format(s)}function d9(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 jw(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 qd(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 h9(s){return s?s.split(",").map(e=>e.trim()).filter(Boolean):[]}function Ul(s){return(s||"").split(/[\\/]/).pop()||""}function f9(s){return String(s||"").replaceAll("\\","/")}function m9(s){return(f9(s||"").toLowerCase().match(/\/keep\/([^/]+)\//)?.[1]||"").trim().toLowerCase()}function nT(s){return s.startsWith("HOT ")?s.slice(4):s}function p9(s){return String(s||"").startsWith("HOT ")}function g9(s,e){const t=String(s||"");return t&&t.replace(/([\\/])[^\\/]*$/,`$1${e}`)}function y9(s){return p9(s)?nT(s):`HOT ${s}`}function $w(s){const e=Ul(s||""),t=nT(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 Cv(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 v9(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 Ha(s){return pn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ring-1 ring-inset",s)}const kv=s=>s?"blur-md scale-[1.03] brightness-90":"";function x9(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 b9(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 T9({open:s,modelKey:e,onClose:t,onOpenPlayer:i,cookies:n,runningJobs:r,blurPreviews:o,onToggleWatch:u,onToggleFavorite:c,onToggleLike:d,onToggleHot:f,onDelete:p}){const[g,v]=A.useState([]),[b,_]=A.useState(!1),[S,D]=A.useState(null),[R,L]=A.useState(null),[M,j]=A.useState(!1),[V,P]=A.useState(null),[z,I]=A.useState(null),[O,W]=A.useState(!1),[X,q]=A.useState([]),[ue,ie]=A.useState(!1),[Y,G]=A.useState([]),[J,oe]=A.useState(!1),[ce,F]=A.useState(0),[ee,pe]=A.useState(null),_e=A.useCallback(async()=>{try{const H=await(await fetch("/api/models/list",{cache:"no-store"})).json().catch(()=>null);v(Array.isArray(H)?H:[])}catch{}},[]),ve=A.useCallback(async()=>{try{const K=await(await fetch("/api/record/done?all=1&sort=completed_desc&includeKeep=1",{cache:"no-store"})).json().catch(()=>null),re=Array.isArray(K)?K:Array.isArray(K?.items)?K.items:[];q(re)}catch{}},[]);function Ce(Ie){return{id:`model:${Ie}`,output:`${Ie}_01_01_2000__00-00-00.mp4`,status:"finished"}}const Be=A.useCallback((Ie,H)=>{const K=String(Ie??"").trim();K&&pe({src:K,alt:H})},[]);A.useEffect(()=>{s||F(0)},[s]);const[tt,Je]=A.useState(1),Ct=25,st=x9(e),mt=A.useMemo(()=>Array.isArray(r)?r:Y,[r,Y]);A.useEffect(()=>{s&&Je(1)},[s,e]),A.useEffect(()=>{if(!s)return;let Ie=!0;return _(!0),fetch("/api/models/list",{cache:"no-store"}).then(H=>H.json()).then(H=>{Ie&&v(Array.isArray(H)?H:[])}).catch(()=>{Ie&&v([])}).finally(()=>{Ie&&_(!1)}),()=>{Ie=!1}},[s]),A.useEffect(()=>{if(!s||!st)return;let Ie=!0;return j(!0),D(null),L(null),fetch("/api/chaturbate/online",{cache:"no-store"}).then(H=>H.json()).then(H=>{if(!Ie)return;L({enabled:H?.enabled,fetchedAt:H?.fetchedAt,lastError:H?.lastError});const re=(Array.isArray(H?.rooms)?H.rooms:[]).find(Ee=>String(Ee?.username??"").trim().toLowerCase()===st)??null;D(re)}).catch(()=>{Ie&&(L({enabled:void 0,fetchedAt:void 0,lastError:"Fetch fehlgeschlagen"}),D(null))}).finally(()=>{Ie&&j(!1)}),()=>{Ie=!1}},[s,st]),A.useEffect(()=>{if(!s||!st)return;let Ie=!0;W(!0),P(null),I(null);const H=b9(n),K=`/api/chaturbate/biocontext?model=${encodeURIComponent(st)}${ce>0?"&refresh=1":""}`;return fetch(K,{cache:"no-store",headers:H?{"X-Chaturbate-Cookie":H}:void 0}).then(async re=>{if(!re.ok){const Ee=await re.text().catch(()=>"");throw new Error(Ee||`HTTP ${re.status}`)}return re.json()}).then(re=>{Ie&&(I({enabled:re?.enabled,fetchedAt:re?.fetchedAt,lastError:re?.lastError}),P(re?.bio??null))}).catch(re=>{Ie&&(I({enabled:void 0,fetchedAt:void 0,lastError:re?.message||"Fetch fehlgeschlagen"}),P(null))}).finally(()=>{Ie&&W(!1)}),()=>{Ie=!1}},[s,st,ce,n]),A.useEffect(()=>{if(!s)return;let Ie=!0;return ie(!0),fetch("/api/record/done?all=1&sort=completed_desc&includeKeep=1",{cache:"no-store"}).then(K=>K.json()).then(K=>{if(!Ie)return;const re=Array.isArray(K)?K:Array.isArray(K?.items)?K.items:[];q(re)}).catch(()=>{Ie&&q([])}).finally(()=>{Ie&&ie(!1)}),()=>{Ie=!1}},[s]),A.useEffect(()=>{if(!s||Array.isArray(r))return;let Ie=!0;return oe(!0),fetch("/api/record/jobs",{cache:"no-store"}).then(H=>H.json()).then(H=>{Ie&&G(Array.isArray(H)?H:[])}).catch(()=>{Ie&&G([])}).finally(()=>{Ie&&oe(!1)}),()=>{Ie=!1}},[s,r]);const pt=A.useMemo(()=>st?g.find(Ie=>(Ie.modelKey||"").toLowerCase()===st)??null:null,[g,st]),ut=A.useMemo(()=>st?X.filter(Ie=>{const H=Ie.output||"",K=m9(H);if(K)return K===st;const re=$w(H);return re!=="—"&&re.trim().toLowerCase()===st}):[],[X,st]),Ht=A.useMemo(()=>Math.max(1,Math.ceil(ut.length/Ct)),[ut.length]),at=A.useMemo(()=>{const Ie=(tt-1)*Ct;return ut.slice(Ie,Ie+Ct)},[ut,tt]),gt=A.useMemo(()=>st?mt.filter(Ie=>{const H=$w(Ie.output);return H!=="—"&&H.trim().toLowerCase()===st}):[],[mt,st]),Dt=A.useMemo(()=>{const Ie=h9(pt?.tags),H=Array.isArray(S?.tags)?S.tags:[],K=new Map;for(const re of[...Ie,...H]){const Ee=String(re).trim().toLowerCase();Ee&&(K.has(Ee)||K.set(Ee,String(re).trim()))}return Array.from(K.values()).sort((re,Ee)=>re.localeCompare(Ee,"de"))},[pt?.tags,S?.tags]),Nt=S?.display_name||pt?.modelKey||st||"Model",dt=S?.image_url_360x270||S?.image_url||"",lt=S?.image_url||dt,ye=S?.chat_room_url_revshare||S?.chat_room_url||"",ze=(S?.current_show||"").trim().toLowerCase(),We=ze?ze==="public"?"Public":ze==="private"?"Private":ze:"",et=(V?.location||"").trim(),ot=V?.follower_count,nt=V?.display_age,vt=(V?.room_status||"").trim(),Xe=V?.last_broadcast?qd(V.last_broadcast):"—",Ft=Cv(V?.about_me),Gt=Cv(V?.wish_list),wt=Array.isArray(V?.social_medias)?V.social_medias:[],hi=Array.isArray(V?.photo_sets)?V.photo_sets:[],Qe=Array.isArray(V?.interested_in)?V.interested_in:[],Lt=b||ue||J||M||O,Ut=({icon:Ie,label:H,value:K})=>y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-300",children:[Ie,H]}),y.jsx("div",{className:"mt-0.5 text-sm font-semibold text-gray-900 dark:text-white",children:K})]}),vi=A.useCallback(async Ie=>{const H=Ie.output||"",K=Ul(H);if(!K){await f?.(Ie);return}const re=y9(K);q(Ee=>Ee.map(Ye=>Ul(Ye.output||"")!==K?Ye:{...Ye,output:g9(Ye.output||"",re)})),await f?.(Ie),ve()},[f,ve]),gi=A.useCallback(async Ie=>{const H=Ie.output||"",K=Ul(H);K&&q(re=>re.filter(Ee=>Ul(Ee.output||"")!==K)),await p?.(Ie),ve()},[p,ve]),kt=A.useCallback(async()=>{st&&(v(Ie=>Ie.map(H=>(H.modelKey||"").toLowerCase()===st?{...H,favorite:!H.favorite}:H)),await c?.(Ce(st)),_e())},[st,c,_e]),ht=A.useCallback(async()=>{st&&(v(Ie=>Ie.map(H=>(H.modelKey||"").toLowerCase()===st?{...H,liked:H.liked!==!0}:H)),await d?.(Ce(st)),_e())},[st,d,_e]),ri=A.useCallback(async()=>{st&&(v(Ie=>Ie.map(H=>(H.modelKey||"").toLowerCase()===st?{...H,watching:!H.watching}:H)),await u?.(Ce(st)),_e())},[st,u,_e]);return y.jsxs(Bx,{open:s,onClose:t,title:Nt,width:"max-w-6xl",footer:y.jsx(ti,{variant:"secondary",onClick:t,children:"Schließen"}),children:[y.jsxs("div",{className:"space-y-6",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:st?y.jsxs("span",{children:["Key: ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:st}),R?.fetchedAt?y.jsxs("span",{className:"ml-2 text-gray-500 dark:text-gray-400",children:["· Online-Stand: ",qd(R.fetchedAt)]}):null,z?.fetchedAt?y.jsxs("span",{className:"ml-2 text-gray-500 dark:text-gray-400",children:["· Bio-Stand: ",qd(z.fetchedAt)]}):null]}):"—"}),y.jsx("div",{className:"flex items-center gap-2",children:ye?y.jsxs("a",{href:ye,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-lg border border-gray-200/70 bg-white/70 px-2.5 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:[y.jsx(gy,{className:"size-4"}),"Room öffnen"]}):null})]}),y.jsxs("div",{className:"grid gap-5 lg:grid-cols-[320px_1fr]",children:[y.jsx("div",{className:"space-y-4",children:y.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200/70 bg-white/70 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"relative",children:[dt?y.jsx("button",{type:"button",className:"block w-full cursor-zoom-in",onClick:()=>Be(lt,Nt),"aria-label":"Bild vergrößern",children:y.jsx("img",{src:dt,alt:Nt,className:pn("h-52 w-full object-cover transition",kv(o))})}):y.jsx("div",{className:"h-52 w-full bg-gradient-to-br from-indigo-500/10 via-transparent to-sky-500/10"}),y.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"}),y.jsxs("div",{className:"absolute left-3 top-3 flex flex-wrap items-center gap-2",children:[We?y.jsx("span",{className:Ha("bg-emerald-500/10 text-emerald-900 ring-emerald-200 backdrop-blur dark:text-emerald-200 dark:ring-emerald-400/20"),children:We}):null,vt?y.jsx("span",{className:Ha(vt.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:vt}):null,S?.is_hd?y.jsx("span",{className:Ha("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?y.jsx("span",{className:Ha("bg-amber-500/10 text-amber-900 ring-amber-200 backdrop-blur dark:text-amber-200 dark:ring-amber-400/20"),children:"NEW"}):null]}),y.jsxs("div",{className:"absolute bottom-3 left-3 right-3",children:[y.jsx("div",{className:"truncate text-sm font-semibold text-white drop-shadow",children:S?.display_name||S?.username||pt?.modelKey||st||"—"}),y.jsx("div",{className:"truncate text-xs text-white/85 drop-shadow",children:S?.username?`@${S.username}`:pt?.modelKey?`@${pt.modelKey}`:""})]}),y.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),kt()},className:pn("inline-flex items-center justify-center rounded-full p-2 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",pt?.favorite?"bg-amber-500/25 ring-amber-200/30":"bg-black/20 ring-white/15"),title:pt?.favorite?"Favorit entfernen":"Als Favorit markieren","aria-pressed":!!pt?.favorite,"aria-label":pt?.favorite?"Favorit entfernen":"Als Favorit markieren",children:y.jsxs("span",{className:"relative inline-block size-4",children:[y.jsx(Hv,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.favorite?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),y.jsx(mh,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.favorite?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-amber-200")})]})}),y.jsx("button",{type:"button",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ht()},className:pn("inline-flex items-center justify-center rounded-full p-2 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",pt?.liked?"bg-rose-500/25 ring-rose-200/30":"bg-black/20 ring-white/15"),title:pt?.liked?"Like entfernen":"Liken","aria-pressed":pt?.liked===!0,"aria-label":pt?.liked?"Like entfernen":"Liken",children:y.jsxs("span",{className:"relative inline-block size-4",children:[y.jsx(Zm,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.liked?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),y.jsx(bc,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.liked?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-rose-200")})]})}),y.jsx("button",{type:"button",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ri()},className:pn("inline-flex items-center justify-center rounded-full p-2 ring-1 ring-inset backdrop-blur","cursor-pointer hover:scale-[1.03] active:scale-[0.98] transition",pt?.watching?"bg-sky-500/25 ring-sky-200/30":"bg-black/20 ring-white/15"),title:pt?.watching?"Watch entfernen":"Auf Watch setzen","aria-pressed":!!pt?.watching,"aria-label":pt?.watching?"Watch entfernen":"Auf Watch setzen",children:y.jsxs("span",{className:"relative inline-block size-4",children:[y.jsx($v,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.watching?"opacity-0 scale-75 rotate-12":"opacity-100 scale-100 rotate-0","text-white/70")}),y.jsx(xc,{className:pn("absolute inset-0 size-4 transition-all duration-200 ease-out motion-reduce:transition-none",pt?.watching?"opacity-100 scale-110 rotate-0":"opacity-0 scale-75 -rotate-12","text-sky-200")})]})})]})]}),y.jsxs("div",{className:"p-4",children:[y.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[y.jsx(Ut,{icon:y.jsx(WO,{className:"size-4"}),label:"Viewer",value:Av(S?.num_users)}),y.jsx(Ut,{icon:y.jsx(IS,{className:"size-4"}),label:"Follower",value:Av(S?.num_followers??ot)})]}),y.jsxs("dl",{className:"mt-4 grid gap-2 text-xs",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[y.jsx(PO,{className:"size-4"}),"Location"]}),y.jsx("dd",{className:"truncate font-medium text-gray-900 dark:text-white",children:S?.location||et||"—"})]}),y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[y.jsx(RO,{className:"size-4"}),"Sprache"]}),y.jsx("dd",{className:"truncate font-medium text-gray-900 dark:text-white",children:S?.spoken_languages||"—"})]}),y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[y.jsx(DS,{className:"size-4"}),"Online"]}),y.jsx("dd",{className:"truncate font-medium text-gray-900 dark:text-white",children:jw(S?.seconds_online)})]}),y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[y.jsx(Zm,{className:"size-4"}),"Alter"]}),y.jsx("dd",{className:"truncate font-medium text-gray-900 dark:text-white",children:nt!=null?String(nt):S?.age!=null?String(S.age):"—"})]}),y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("dt",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-300",children:[y.jsx(DS,{className:"size-4"}),"Last broadcast"]}),y.jsx("dd",{className:"truncate font-medium text-gray-900 dark:text-white",children:Xe})]})]}),R?.enabled===!1?y.jsx("div",{className:"mt-3 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."}):R?.lastError?y.jsxs("div",{className:"mt-3 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: ",R.lastError]}):null,z?.enabled===!1?y.jsx("div",{className:"mt-3 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."}):z?.lastError?y.jsxs("div",{className:"mt-3 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: ",z.lastError]}):null]})]})}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Room Subject"}),Lt?y.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Lade…"}):null]}),y.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:S?.room_subject?y.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words",children:S.room_subject}):y.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Keine Subject-Info vorhanden."})})]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Bio"}),y.jsxs("div",{className:"flex items-center gap-2",children:[O?y.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Lade…"}):null,y.jsx(ti,{variant:"secondary",className:"h-7 px-2 text-xs",disabled:O||!e,onClick:()=>F(Ie=>Ie+1),title:"BioContext neu abrufen",children:"Aktualisieren"})]})]}),y.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 p-3 dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:[y.jsx(CO,{className:"size-4"}),"Über mich"]}),y.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:Ft?y.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap",children:Ft}):y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"—"})})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 p-3 dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:[y.jsx(IS,{className:"size-4"}),"Wishlist"]}),y.jsx("div",{className:"mt-2 text-sm text-gray-800 dark:text-gray-100",children:Gt?y.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap",children:Gt}):y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"—"})})]})]}),y.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Real name:"})," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:V?.real_name?Cv(V.real_name):"—"})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Body type:"})," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:V?.body_type||"—"})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Smoke/Drink:"})," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:V?.smoke_drink||"—"})]}),y.jsxs("div",{className:"rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 text-xs dark:border-white/10 dark:bg-white/5",children:[y.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Sex:"})," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:V?.sex||"—"})]})]}),Qe.length?y.jsxs("div",{className:"mt-3",children:[y.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:"Interested in"}),y.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Qe.map(Ie=>y.jsx("span",{className:Ha("bg-sky-500/10 text-sky-900 ring-sky-200 dark:text-sky-200 dark:ring-sky-400/20"),children:Ie},Ie))})]}):null]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Tags"}),Dt.length?y.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Dt.map(Ie=>y.jsx(Lr,{tag:Ie},Ie))}):y.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Tags vorhanden."})]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Socials"}),wt.length?y.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:[wt.length," Links"]}):null]}),wt.length?y.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:wt.map(Ie=>{const H=v9(Ie.link);return y.jsxs("a",{href:H,target:"_blank",rel:"noreferrer",className:pn("group flex items-center gap-3 rounded-xl 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:Ie.title_name,children:[y.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-black/5 dark:bg-white/5",children:Ie.image_url?y.jsx("img",{src:Ie.image_url,alt:"",className:"size-5"}):y.jsx(NO,{className:"size-5"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:Ie.title_name}),y.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:Ie.label_text?Ie.label_text:Ie.tokens!=null?`${Ie.tokens} token(s)`:"Link"})]}),y.jsx(gy,{className:"ml-auto size-4 text-gray-400 transition group-hover:text-indigo-500 dark:text-gray-500 dark:group-hover:text-indigo-400"})]},Ie.id)})}):y.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Social-Medias vorhanden."})]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Photo sets"}),hi.length?y.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:[hi.length," Sets"]}):null]}),hi.length?y.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:hi.slice(0,6).map(Ie=>y.jsxs("div",{className:"overflow-hidden rounded-xl border border-gray-200/70 bg-white/60 dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"relative",children:[Ie.cover_url?y.jsx("button",{type:"button",className:"block w-full cursor-zoom-in",onClick:()=>Be(Ie.cover_url,Ie.name),"aria-label":"Bild vergrößern",children:y.jsx("img",{src:Ie.cover_url,alt:Ie.name,className:pn("h-28 w-full object-cover transition",kv(o))})}):y.jsx("div",{className:"flex h-28 w-full items-center justify-center bg-black/5 dark:bg-white/5",children:y.jsx(FO,{className:"size-6 text-gray-500"})}),y.jsxs("div",{className:"absolute left-2 top-2 flex flex-wrap gap-2",children:[Ie.is_video?y.jsx("span",{className:Ha("bg-indigo-500/10 text-indigo-900 ring-indigo-200 dark:text-indigo-200 dark:ring-indigo-400/20"),children:"Video"}):y.jsx("span",{className:Ha("bg-gray-500/10 text-gray-900 ring-gray-200 dark:text-gray-200 dark:ring-white/15"),children:"Photos"}),Ie.fan_club_only?y.jsx("span",{className:Ha("bg-amber-500/10 text-amber-900 ring-amber-200 dark:text-amber-200 dark:ring-amber-400/20"),children:"FanClub"}):null]})]}),y.jsxs("div",{className:"p-3",children:[y.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:Ie.name}),y.jsxs("div",{className:"mt-1 text-xs text-gray-600 dark:text-gray-300",children:["Tokens: ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:Av(Ie.tokens)}),Ie.user_can_access===!0?y.jsx("span",{className:"ml-2",children:"· Zugriff: ✅"}):null]})]})]},Ie.id))}):y.jsx("div",{className:"mt-2 text-sm text-gray-600 dark:text-gray-300",children:"Keine Photo-Sets vorhanden."})]})]})]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Abgeschlossene Downloads"}),y.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Inkl. Dateien aus ",y.jsx("span",{className:"font-medium",children:"/done/keep/"})]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(ti,{size:"sm",variant:"secondary",disabled:ue||tt<=1,onClick:()=>Je(Ie=>Math.max(1,Ie-1)),children:"Zurück"}),y.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Seite ",tt," / ",Ht]}),y.jsx(ti,{size:"sm",variant:"secondary",disabled:ue||tt>=Ht,onClick:()=>Je(Ie=>Math.min(Ht,Ie+1)),children:"Weiter"})]})]}),y.jsx("div",{className:"mt-3",children:ue?y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Lade Downloads…"}):ut.length===0?y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine abgeschlossenen Downloads für dieses Model gefunden."}):y.jsx("div",{className:"grid gap-2",children:at.map(Ie=>{const H=Ul(Ie.output||""),K=H.startsWith("HOT "),re=Ie.endedAt?qd(Ie.endedAt):"—";return y.jsxs("div",{role:i?"button":void 0,tabIndex:i?0:void 0,className:pn("group flex w-full items-center justify-between gap-3 overflow-hidden rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2","transition hover:border-indigo-200 hover:bg-gray-50/80 dark:border-white/10 dark:bg-white/5 dark:hover:border-indigo-400/30 dark:hover:bg-white/10",i?"cursor-pointer":""),onClick:()=>i?.(Ie),onKeyDown:Ee=>{i&&(Ee.key==="Enter"||Ee.key===" ")&&i(Ie)},children:[y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[y.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-900 dark:text-white",children:nT(H)||"—"}),K?y.jsx("span",{className:Ha("shrink-0 bg-orange-500/10 text-orange-900 ring-orange-200 dark:text-orange-200 dark:ring-orange-400/20"),children:"HOT"}):null]}),y.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-600 dark:text-gray-300",children:[y.jsxs("span",{children:["Datum: ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:re})]}),y.jsxs("span",{children:["Dauer:"," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:jw(Ie.durationSeconds)})]}),y.jsxs("span",{children:["Größe:"," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:d9(Ie.sizeBytes)})]})]})]}),y.jsx("div",{className:"shrink-0 flex items-center gap-2",children:y.jsx("span",{onClick:Ee=>Ee.stopPropagation(),onMouseDown:Ee=>Ee.stopPropagation(),onKeyDown:Ee=>Ee.stopPropagation(),children:y.jsx(da,{job:Ie,variant:"table",isHot:K,isFavorite:!!pt?.favorite,isLiked:pt?.liked===!0,isWatching:!!pt?.watching,onToggleHot:vi,onDelete:gi,order:["hot","delete"],className:"flex items-center"})})})]},`${Ie.id}-${H}`)})})})]}),y.jsxs("div",{className:"rounded-2xl border border-gray-200/70 bg-white/70 p-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5",children:[y.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Laufende Jobs"}),y.jsx("div",{className:"mt-2",children:J?y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Lade…"}):gt.length===0?y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine laufenden Jobs."}):y.jsx("div",{className:"grid gap-2",children:gt.map(Ie=>y.jsx("div",{className:"overflow-hidden rounded-xl border border-gray-200/70 bg-white/60 px-3 py-2 text-sm dark:border-white/10 dark:bg-white/5",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("div",{className:"break-words line-clamp-2 font-medium text-gray-900 dark:text-white",children:Ul(Ie.output||"")}),y.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:["Start:"," ",y.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:qd(Ie.startedAt)})]})]}),i?y.jsx(ti,{size:"sm",variant:"secondary",className:"shrink-0",onClick:()=>i(Ie),children:"Öffnen"}):null]})},Ie.id))})})]})]}),y.jsx(Bx,{open:!!ee,onClose:()=>pe(null),title:ee?.alt||"Bild",width:"max-w-4xl",footer:y.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ee?.src?y.jsxs("a",{href:ee.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:[y.jsx(gy,{className:"size-4"}),"In neuem Tab"]}):null,y.jsx(ti,{variant:"secondary",onClick:()=>pe(null),children:"Schließen"})]}),children:y.jsx("div",{className:"grid place-items-center",children:ee?.src?y.jsx("img",{src:ee.src,alt:ee.alt||"",className:pn("max-h-[80vh] w-auto max-w-full rounded-xl object-contain",kv(o))}):null})})]})}const Rm=s=>Math.max(0,Math.min(1,s));function Im(s){return s==="good"?"bg-emerald-500":s==="warn"?"bg-amber-500":"bg-red-500"}function _9(s){return s==null?"":`${Math.round(s)}ms`}function Hw(s){return s==null?"":`${Math.round(s)}%`}function Dv(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 S9(s=1e3){const[e,t]=Mt.useState(null);return Mt.useEffect(()=>{let i=0,n=performance.now(),r=0,o=!0,u=!1;const c=g=>{if(!o||!u)return;r+=1;const v=g-n;if(v>=s){const b=Math.round(r*1e3/v);t(b),r=0,n=g}i=requestAnimationFrame(c)},d=()=>{o&&(document.hidden||u||(u=!0,n=performance.now(),r=0,i=requestAnimationFrame(c)))},f=()=>{u=!1,cancelAnimationFrame(i)},p=()=>{document.hidden?f():d()};return d(),document.addEventListener("visibilitychange",p),()=>{o=!1,document.removeEventListener("visibilitychange",p),f()}},[s]),e}function Vw({mode:s="inline",className:e,pollMs:t=3e3}){const i=S9(1e3),[n,r]=Mt.useState(null),[o,u]=Mt.useState(null),[c,d]=Mt.useState(null),[f,p]=Mt.useState(null),[g,v]=Mt.useState(null),b=5*1024*1024*1024,_=8*1024*1024*1024,S=Mt.useRef(!1);Mt.useEffect(()=>{const q=`/api/perf/stream?ms=${encodeURIComponent(String(t))}`,ue=eR(q,"perf",ie=>{const Y=typeof ie?.cpuPercent=="number"?ie.cpuPercent:null,G=typeof ie?.diskFreeBytes=="number"?ie.diskFreeBytes:null,J=typeof ie?.diskTotalBytes=="number"?ie.diskTotalBytes:null,oe=typeof ie?.diskUsedPercent=="number"?ie.diskUsedPercent:null;u(Y),d(G),p(J),v(oe);const ce=typeof ie?.serverMs=="number"?ie.serverMs:null;r(ce!=null?Math.max(0,Date.now()-ce):null)});return()=>ue()},[t]);const D=n==null?"bad":n<=120?"good":n<=300?"warn":"bad",R=i==null?"bad":i>=55?"good":i>=30?"warn":"bad",L=o==null?"bad":o<=60?"good":o<=85?"warn":"bad",M=Rm((n??999)/500),j=Rm((i??0)/60),V=Rm((o??0)/100),P=c!=null&&f!=null&&f>0?c/f:null,z=g??(P!=null?(1-P)*100:null),I=Rm((z??0)/100);c==null?S.current=!1:S.current?c>=_&&(S.current=!1):c<=b&&(S.current=!0);const O=c==null||S.current||P==null?"bad":P>=.15?"good":P>=.07?"warn":"bad",W=c==null?"Disk: ":`Free: ${Dv(c)} / Total: ${Dv(f)} · Used: ${Hw(z)}`,X=s==="floating"?"fixed bottom-4 right-4 z-[80]":"flex items-center";return y.jsx("div",{className:`${X} ${e??""}`,children:y.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:[y.jsxs("div",{className:"flex items-center gap-2",title:W,children:[y.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"Disk"}),y.jsx("div",{className:"h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:y.jsx("div",{className:`h-full ${Im(O)}`,style:{width:`${Math.round(I*100)}%`}})}),y.jsx("span",{className:"text-[11px] w-11 tabular-nums text-gray-900 dark:text-gray-100",children:Dv(c)})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"Ping"}),y.jsx("div",{className:"h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:y.jsx("div",{className:`h-full ${Im(D)}`,style:{width:`${Math.round(M*100)}%`}})}),y.jsx("span",{className:"text-[11px] w-10 tabular-nums text-gray-900 dark:text-gray-100",children:_9(n)})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"FPS"}),y.jsx("div",{className:"h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:y.jsx("div",{className:`h-full ${Im(R)}`,style:{width:`${Math.round(j*100)}%`}})}),y.jsx("span",{className:"text-[11px] w-8 tabular-nums text-gray-900 dark:text-gray-100",children:i??""})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"CPU"}),y.jsx("div",{className:"h-2 w-14 sm:w-16 rounded-full bg-gray-200/70 dark:bg-white/10 overflow-hidden",children:y.jsx("div",{className:`h-full ${Im(L)}`,style:{width:`${Math.round(V*100)}%`}})}),y.jsx("span",{className:"text-[11px] w-10 tabular-nums text-gray-900 dark:text-gray-100",children:Hw(o)})]})]})})}function E9(s,e){const t=[];for(let i=0;i<s.length;i+=e)t.push(s.slice(i,i+e));return t}function w9(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 Gw(s){const e=s.intervalMs??5e3;let t=null,i=null,n="",r=null,o=!1;const u=()=>{t!=null&&(window.clearTimeout(t),t=null)},c=()=>{if(i){try{i.abort()}catch{}i=null}},d=p=>{o||(u(),t=window.setTimeout(()=>{f()},p))},f=async()=>{if(!o)try{const p=(s.getModels?.()??[]).map(W=>String(W||"").trim()).filter(Boolean),v=(s.getShow?.()??[]).map(W=>String(W||"").trim()).filter(Boolean).slice().sort(),b=p.slice().sort(),_=b.length===0&&!!s.fetchAllWhenNoModels;if(b.length===0&&!_){c();const W={enabled:r?.enabled??!1,rooms:[]};r=W,s.onData(W);const X=document.hidden?Math.max(15e3,e):e;d(X);return}const S=_?[]:b,D=`${v.join(",")}|${_?"__ALL__":S.join(",")}`,R=D;n=D,c();const L=new AbortController;i=L;const j=_?[[]]:E9(S,350);let V=[],P=!1,z=0,I=!1;for(const W of j){if(L.signal.aborted||R!==n||o)return;const X=await fetch("/api/chaturbate/online",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:W,show:v,refresh:!1}),signal:L.signal,cache:"no-store"});if(!X.ok)continue;I=!0;const q=await X.json();P=P||!!q?.enabled,V.push(...Array.isArray(q?.rooms)?q.rooms:[]);const ue=Number(q?.total??0);Number.isFinite(ue)&&ue>z&&(z=ue)}if(!I){const W=document.hidden?Math.max(15e3,e):e;d(W);return}const O={enabled:P,rooms:w9(V),total:z};if(L.signal.aborted||R!==n||o)return;r=O,s.onData(O)}catch(p){if(p?.name==="AbortError")return;s.onError?.(p)}finally{const p=document.hidden?Math.max(15e3,e):e;d(p)}};return f(),()=>{o=!0,u(),c()}}async function zw(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 qw(s,e,t){const i=`/api/generated/cover?category=${encodeURIComponent(s)}`,n=e?`&v=${e}`:"";return`${i}${n}${t?"&refresh=1":""}`}function Kw(s){if(!s)return[];const e=s.split(/[\n,;|]+/g).map(t=>t.trim()).filter(Boolean);return Array.from(new Set(e))}function oR(s){return String(s||"").replaceAll("\\","/").split("/").pop()||""}function lR(s){return s.toUpperCase().startsWith("HOT ")?s.slice(4).trim():s}function A9(s){const e=lR(oR(s||""));return e?e.replace(/\.[^.]+$/,""):""}const C9=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function k9(s){const t=lR(oR(s)).replace(/\.[^.]+$/,""),i=t.match(C9);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 Yw(s){const e=A9(s);return e?`/generated/meta/${encodeURIComponent(e)}/thumbs.jpg`:null}async function Ww(s,e,t){const i=`/api/generated/cover?category=${encodeURIComponent(s)}&src=${encodeURIComponent(e)}`+(t?"&refresh=1":"");await fetch(i,{method:"GET",cache:"no-store"})}function D9(){const[s,e]=A.useState([]),[t,i]=A.useState(!1),[n,r]=A.useState(null),[o,u]=A.useState(()=>Date.now()),c=A.useRef({}),d=A.useCallback((v,b)=>{const _={};for(const D of Array.isArray(v)?v:[]){const R=String(D?.modelKey??"").trim().toLowerCase();if(!R)continue;const L=Kw(D?.tags).map(M=>M.toLowerCase());L.length&&(_[R]=L)}const S={};for(const D of Array.isArray(b)?b:[]){const R=String(D?.output??"");if(!R)continue;const L=(k9(R)||"").trim().toLowerCase();if(!L)continue;const M=_[L];if(!(!M||M.length===0))for(const j of M)j&&(S[j]||(S[j]=[]),S[j].push(R))}for(const[D,R]of Object.entries(S))S[D]=Array.from(new Set(R));c.current=S},[]),f=A.useCallback(v=>{const b=String(v||"").trim();if(b){try{localStorage.setItem("finishedDownloads_pendingTags",JSON.stringify([b]))}catch{}window.dispatchEvent(new CustomEvent("app:navigate-tab",{detail:{tab:"finished"}})),window.dispatchEvent(new CustomEvent("finished-downloads:tag-filter",{detail:{tags:[b],mode:"replace"}}))}},[]),p=A.useCallback(async()=>{i(!0),r(null);try{const v=await zw("/api/models/list",{cache:"no-store"}),b=await zw("/api/record/done?page=1&pageSize=2000&sort=completed_desc",{cache:"no-store"}),_=Array.isArray(b?.items)?b.items:Array.isArray(b)?b:[];d(Array.isArray(v)?v:[],_);const S=new Map;for(const j of Array.isArray(v)?v:[])for(const V of Kw(j?.tags)){const P=V.toLowerCase();S.set(P,(S.get(P)??0)+1)}const D=c.current||{},R=Array.from(S.entries()).map(([j,V])=>({tag:j,modelsCount:V,downloadsCount:(D[j]||[]).length})).sort((j,V)=>j.tag.localeCompare(V.tag,void 0,{sensitivity:"base"}));e(R);const L=60;let M=0;for(const j of R){if(M>=L)break;const V=D[j.tag]||[];if(V.length===0)continue;const P=V[Math.floor(Math.random()*V.length)],z=P?Yw(P):null;z&&(M++,Ww(j.tag,z,!1).catch(()=>{}))}u(Date.now())}catch(v){r(v?.message??String(v)),e([]),c.current={}}finally{i(!1)}},[d]);A.useEffect(()=>{p()},[p]);const g=A.useCallback(async()=>{try{const v=c.current||{},b=await Promise.all(s.map(async S=>{const D=v[S.tag]||[],R=D.length?D[Math.floor(Math.random()*D.length)]:"",L=R?Yw(R):null;try{if(L)return await Ww(S.tag,L,!0),{tag:S.tag,ok:!0,status:200,text:""};const M=await fetch(qw(S.tag,Date.now(),!0),{method:"GET",cache:"no-store"}),j=M.ok?"":await M.text().catch(()=>""),V=M.ok||M.status===404;return{tag:S.tag,ok:V,status:M.status,text:j}}catch(M){return{tag:S.tag,ok:!1,status:0,text:M?.message??String(M)}}})),_=b.filter(S=>!S.ok&&S.status!==404);if(_.length){console.warn("Cover renew failed:",_.slice(0,20));const S=_.slice(0,8).map(D=>`${D.tag} (${D.status||"ERR"})`).join(", ");r(`Covers fehlgeschlagen: ${_.length}/${b.length} — z.B.: ${S}`)}else r(null)}finally{u(Date.now())}},[s]);return y.jsxs(ha,{header:y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Kategorien ",y.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",s.length,")"]})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(ti,{variant:"secondary",size:"md",onClick:g,disabled:t,children:"Cover erneuern"}),y.jsx(ti,{variant:"secondary",size:"md",onClick:p,disabled:t,children:"Aktualisieren"})]})]}),grayBody:!0,children:[n?y.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:n}):null,s.length===0&&!t?y.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine Kategorien/Tags gefunden."}):null,y.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:s.map(v=>{const b=qw(v.tag,o);return y.jsxs("button",{type:"button",onClick:()=>f(v.tag),className:yi("group text-left rounded-xl ring-1 ring-gray-200/70 dark:ring-white/10","bg-white/70 hover:bg-white dark:bg-white/5 dark:hover:bg-white/10","overflow-hidden transition","focus:outline-none focus:ring-2 focus:ring-indigo-500"),title:"In FinishedDownloads öffnen (Tag-Filter setzen)",children:[y.jsx("div",{className:"relative h-24",children:y.jsx("img",{src:b,alt:v.tag,className:"absolute inset-0 h-full w-full object-cover",loading:"lazy"})}),y.jsx("div",{className:"px-3 py-3",children:y.jsxs("div",{className:"flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"font-semibold text-gray-900 dark:text-white truncate",children:v.tag}),y.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:[v.downloadsCount," Downloads • ",v.modelsCount," Models"]})]}),y.jsx("span",{className:"shrink-0 rounded-md bg-gray-100 px-2 py-1 text-xs font-semibold text-gray-900 dark:bg-white/10 dark:text-white tabular-nums",children:v.downloadsCount})]})})]},v.tag)})})]})}const Lv="record_cookies";function Nm(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 Os(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 Xw={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 zm(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 Wu(s){const e=(s??"").trim();if(!e)return null;for(const t of e.split(/\s+/g)){const i=zm(t);if(i)return i}return null}function Qw(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}}const Ms=s=>(s||"").replaceAll("\\","/").split("/").pop()||"";function Rv(s,e){const i=(s||"").replaceAll("\\","/").split("/");return i[i.length-1]=e,i.join("/")}function L9(s){return s.startsWith("HOT ")?s.slice(4):s}const R9=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function Kd(s){const t=L9(Ms(s)).replace(/\.[^.]+$/,""),i=t.match(R9);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t||null}function I9(){const s=OA(),e=8,t="finishedDownloads_sort",[i,n]=A.useState(()=>{try{return window.localStorage.getItem(t)||"completed_desc"}catch{return"completed_desc"}});A.useEffect(()=>{try{window.localStorage.setItem(t,i)}catch{}},[i]);const[r,o]=A.useState(null),[u,c]=A.useState(""),[d,f]=A.useState([]),[p,g]=A.useState([]),[v,b]=A.useState(1),[_,S]=A.useState(0),[D,R]=A.useState(0),[L,M]=A.useState(0),[j,V]=A.useState(()=>Date.now()),[P,z]=A.useState(()=>Date.now());A.useEffect(()=>{const Q=window.setInterval(()=>z(Date.now()),1e3);return()=>window.clearInterval(Q)},[]);const I=Q=>(Q||"").toLowerCase().trim(),O=Q=>{const se=Math.max(0,Math.floor(Q/1e3));if(se<2)return"gerade eben";if(se<60)return`vor ${se} Sekunden`;const ae=Math.floor(se/60);if(ae===1)return"vor 1 Minute";if(ae<60)return`vor ${ae} Minuten`;const xe=Math.floor(ae/60);return xe===1?"vor 1 Stunde":`vor ${xe} Stunden`},W=A.useMemo(()=>{const Q=P-j;return`(zuletzt aktualisiert: ${O(Q)})`},[P,j]),[X,q]=A.useState({}),ue=A.useCallback(Q=>{const se={};for(const ae of Array.isArray(Q)?Q:[]){const xe=(ae?.modelKey||"").trim().toLowerCase();if(!xe)continue;const Te=de=>(de.favorite?4:0)+(de.liked===!0?2:0)+(de.watching?1:0),je=se[xe];(!je||Te(ae)>=Te(je))&&(se[xe]=ae)}return se},[]),ie=A.useCallback(async()=>{try{const Q=await Os("/api/models/list",{cache:"no-store"});q(ue(Array.isArray(Q)?Q:[])),V(Date.now())}catch{}},[ue]),[Y,G]=A.useState(null),J=A.useRef(null),[oe,ce]=A.useState(null);A.useEffect(()=>{const Q=se=>{let Te=(se.detail?.modelKey??"").trim().replace(/^https?:\/\//i,"");Te.includes("/")&&(Te=Te.split("/").filter(Boolean).pop()||Te),Te.includes(":")&&(Te=Te.split(":").pop()||Te),Te=Te.trim().toLowerCase(),Te&&ce(Te)};return window.addEventListener("open-model-details",Q),()=>window.removeEventListener("open-model-details",Q)},[]);const F=A.useCallback(Q=>{const se=Date.now(),ae=J.current;if(!ae){J.current={ts:se,list:[Q]};return}ae.ts=se;const xe=ae.list.findIndex(Te=>Te.id===Q.id);xe>=0?ae.list[xe]=Q:ae.list.unshift(Q)},[]);A.useEffect(()=>{ie();const Q=se=>{const xe=se?.detail??{},Te=xe?.model;if(Te&&typeof Te=="object"){const je=String(Te.modelKey??"").toLowerCase().trim();je&&q(de=>({...de,[je]:Te}));try{F(Te)}catch{}G(de=>de?.id===Te.id?Te:de),V(Date.now());return}if(xe?.removed){const je=String(xe?.id??"").trim(),de=String(xe?.modelKey??"").toLowerCase().trim();de&&q(me=>{const{[de]:Pe,...it}=me;return it}),je&&G(me=>me?.id===je?null:me),V(Date.now());return}ie()};return window.addEventListener("models-changed",Q),()=>window.removeEventListener("models-changed",Q)},[ie,F]);const[ee,pe]=A.useState(null),[_e,ve]=A.useState(!1),[Ce,Be]=A.useState(!1),[tt,Je]=A.useState({}),[Ct,st]=A.useState(!1),[mt,pt]=A.useState("running"),[ut,Ht]=A.useState(null),[at,gt]=A.useState(!1),[Dt,Nt]=A.useState(0),dt=A.useCallback(()=>Nt(Q=>Q+1),[]),lt=A.useRef(null),ye=A.useCallback(()=>{dt(),lt.current&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>dt(),3500)},[dt]),[ze,We]=A.useState(Xw),et=A.useRef(ze);A.useEffect(()=>{et.current=ze},[ze]);const ot=!!ze.autoAddToDownloadList,nt=!!ze.autoStartAddedDownloads,[vt,Xe]=A.useState([]),[Ft,Gt]=A.useState({}),wt=A.useRef(!1),hi=A.useRef({}),Qe=A.useRef([]);A.useEffect(()=>{wt.current=_e},[_e]),A.useEffect(()=>{hi.current=tt},[tt]),A.useEffect(()=>{Qe.current=d},[d]);const Lt=A.useRef(null),Ut=A.useRef(""),[vi,gi]=A.useState({}),kt=A.useRef({});A.useEffect(()=>{kt.current=vi},[vi]);const ht=A.useCallback(Q=>{const se=String(Q?.host??"").toLowerCase(),ae=String(Q?.input??"").toLowerCase();return se.includes("chaturbate")||ae.includes("chaturbate.com")},[]),ri=A.useMemo(()=>{const Q=new Set;for(const se of Object.values(X)){if(!ht(se))continue;const ae=I(String(se?.modelKey??""));ae&&Q.add(ae)}return Array.from(Q)},[X,ht]),Ie=A.useRef(X);A.useEffect(()=>{Ie.current=X},[X]);const H=A.useRef(Ft);A.useEffect(()=>{H.current=Ft},[Ft]);const K=A.useRef(ri);A.useEffect(()=>{K.current=ri},[ri]);const re=A.useRef(mt);A.useEffect(()=>{re.current=mt},[mt]);const Ee=A.useCallback(async(Q,se)=>{const ae=zm(Q);if(!ae)return!1;const xe=!!se?.silent;xe||pe(null);const Te=Qw(ae);if(!Te)return xe||pe("Nur chaturbate.com oder myfreecams.com werden unterstützt."),!1;const je=hi.current;if(Te==="chaturbate"&&!Ei(je))return xe||pe('Für Chaturbate müssen die Cookies "cf_clearance" und "sessionId" gesetzt sein.'),!1;if(Qe.current.some(me=>me.status!=="running"?!1:zm(String(me.sourceUrl||""))===ae))return!0;if(Te==="chaturbate"&&et.current.useChaturbateApi)try{const me=await Os("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:ae})}),Pe=String(me?.modelKey??"").trim().toLowerCase();if(Pe){if(wt.current)return Gt(Ke=>({...Ke||{},[Pe]:ae})),!0;const it=kt.current[Pe],ft=String(it?.current_show??"");if(it&&ft&&ft!=="public")return Gt(Ke=>({...Ke||{},[Pe]:ae})),!0}}catch{}else if(wt.current)return Lt.current=ae,!0;if(wt.current)return!1;ve(!0),wt.current=!0;try{const me=Object.entries(je).map(([it,ft])=>`${it}=${ft}`).join("; "),Pe=await Os("/api/record",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:ae,cookie:me})});return f(it=>[Pe,...it]),Qe.current=[Pe,...Qe.current],!0}catch(me){return xe||pe(me?.message??String(me)),!1}finally{ve(!1),wt.current=!1}},[]);A.useEffect(()=>{let Q=!1;const se=async()=>{try{const Te=await Os("/api/settings",{cache:"no-store"});!Q&&Te&&We({...Xw,...Te})}catch{}},ae=()=>{se()},xe=()=>{se()};return window.addEventListener("recorder-settings-updated",ae),window.addEventListener("focus",xe),document.addEventListener("visibilitychange",xe),se(),()=>{Q=!0,window.removeEventListener("recorder-settings-updated",ae),window.removeEventListener("focus",xe),document.removeEventListener("visibilitychange",xe)}},[]),A.useEffect(()=>{let Q=!1;const se=async()=>{try{const xe=await Os("/api/models/meta",{cache:"no-store"}),Te=Number(xe?.count??0);!Q&&Number.isFinite(Te)&&(R(Te),V(Date.now()))}catch{}};se();const ae=window.setInterval(se,document.hidden?6e4:3e4);return()=>{Q=!0,window.clearInterval(ae)}},[]);const Ye=A.useMemo(()=>Object.entries(tt).map(([Q,se])=>({name:Q,value:se})),[tt]),Tt=A.useCallback(Q=>{J.current=null,G(null),Ht(Q),gt(!1)},[]),zt=d.filter(Q=>Q.status==="running"),xi=A.useMemo(()=>{let Q=0;for(const se of Object.values(X)){if(!se?.watching||!ht(se))continue;const ae=I(String(se?.modelKey??""));ae&&vi[ae]&&Q++}return Q},[X,vi,ht]),{onlineFavCount:Wi,onlineLikedCount:Xi}=A.useMemo(()=>{let Q=0,se=0;for(const ae of Object.values(X)){const xe=I(String(ae?.modelKey??""));xe&&vi[xe]&&(ae?.favorite&&Q++,ae?.liked===!0&&se++)}return{onlineFavCount:Q,onlineLikedCount:se}},[X,vi]),rs=[{id:"running",label:"Laufende Downloads",count:zt.length},{id:"finished",label:"Abgeschlossene Downloads",count:_},{id:"models",label:"Models",count:D},{id:"categories",label:"Kategorien"},{id:"settings",label:"Einstellungen"}],Qi=A.useMemo(()=>u.trim().length>0&&!_e,[u,_e]);A.useEffect(()=>{let Q=!1;return(async()=>{try{const ae=await Os("/api/cookies",{cache:"no-store"}),xe=Nm(ae?.cookies);if(Q||Je(xe),Object.keys(xe).length===0){const Te=localStorage.getItem(Lv);if(Te)try{const je=JSON.parse(Te),de=Nm(je);Object.keys(de).length>0&&(Q||Je(de),await Os("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:de})}))}catch{}}}catch{const ae=localStorage.getItem(Lv);if(ae)try{const xe=JSON.parse(ae);Q||Je(Nm(xe))}catch{}}finally{Q||st(!0)}})(),()=>{Q=!0}},[]),A.useEffect(()=>{Ct&&localStorage.setItem(Lv,JSON.stringify(tt))},[tt,Ct]),A.useEffect(()=>{let Q=!1,se;const ae=async()=>{try{const Te=await fetch(`/api/record/done?page=1&pageSize=1&withCount=1&sort=${encodeURIComponent(i)}`,{cache:"no-store"});if(!Te.ok)return;const je=await Te.json().catch(()=>null),de=Number(je?.count??je?.totalCount??0),me=Number.isFinite(de)&&de>=0?de:0;Q||(S(me),V(Date.now()))}catch{}finally{if(!Q){const Te=document.hidden?6e4:3e4;se=window.setTimeout(ae,Te)}}},xe=()=>{document.hidden||ae()};return document.addEventListener("visibilitychange",xe),ae(),()=>{Q=!0,se&&window.clearTimeout(se),document.removeEventListener("visibilitychange",xe)}},[i]),A.useEffect(()=>{const Q=Math.max(1,Math.ceil(_/e));v>Q&&b(Q)},[_,v]),A.useEffect(()=>{let Q=!1,se=null,ae=null,xe=!1;const Te=it=>{const ft=Array.isArray(it)?it:[];if(Q)return;const Ke=Qe.current,Ve=new Map(Ke.map(_t=>[_t.id,_t.status])),Ze=ft.some(_t=>{const St=Ve.get(_t.id);return St&&St!==_t.status&&(_t.status==="finished"||_t.status==="stopped")});f(ft),Qe.current=ft,V(Date.now()),Ze&&ye(),Ht(_t=>{if(!_t)return _t;const St=ft.find(Bt=>Bt.id===_t.id);return St||(_t.status==="running"?null:_t)})},je=async()=>{if(!(Q||xe)){xe=!0;try{const it=await Os("/api/record/list");Te(it)}catch{}finally{xe=!1}}},de=()=>{ae||(ae=window.setInterval(je,document.hidden?15e3:5e3))};je(),se=new EventSource("/api/record/stream");const me=it=>{try{Te(JSON.parse(it.data))}catch{}};se.addEventListener("jobs",me),se.onerror=()=>de();const Pe=()=>{document.hidden||je()};return document.addEventListener("visibilitychange",Pe),window.addEventListener("hover",Pe),()=>{Q=!0,ae&&window.clearInterval(ae),document.removeEventListener("visibilitychange",Pe),window.removeEventListener("hover",Pe),se?.removeEventListener("jobs",me),se?.close(),se=null}},[ye]),A.useEffect(()=>{if(mt!=="finished")return;let Q=!1;const se={current:!1},ae=new AbortController,xe=async()=>{if(!(Q||se.current)){se.current=!0;try{const me=await fetch(`/api/record/done?page=${v}&pageSize=${e}&sort=${encodeURIComponent(i)}&withCount=1`,{cache:"no-store",signal:ae.signal});if(!me.ok)throw new Error(`HTTP ${me.status}`);const Pe=await me.json().catch(()=>null),it=Array.isArray(Pe?.items)?Pe.items:Array.isArray(Pe)?Pe:[],ft=typeof Pe?.count=="number"?Pe.count:typeof Pe?.totalCount=="number"?Pe.totalCount:it.length;Q||(g(it),S(Number.isFinite(ft)?ft:it.length))}catch{Q||(g([]),S(0))}finally{se.current=!1}}};xe();const je=window.setInterval(()=>{document.hidden||xe()},2e4),de=()=>{document.hidden||xe()};return document.addEventListener("visibilitychange",de),()=>{Q=!0,ae.abort(),window.clearInterval(je),document.removeEventListener("visibilitychange",de)}},[mt,v,i]);const ai=A.useCallback(async Q=>{try{const se=typeof Q=="number"?Q:v,ae=await Os(`/api/record/done?page=${se}&pageSize=${e}&sort=${encodeURIComponent(i)}&withCount=1`,{cache:"no-store"}),xe=Array.isArray(ae?.items)?ae.items:[],Te=Number(ae?.count??ae?.totalCount??xe.length),je=Number.isFinite(Te)&&Te>=0?Te:xe.length;S(je);const de=Math.max(1,Math.ceil(je/e)),me=Math.min(Math.max(1,se),de);if(me!==v&&b(me),me===se)g(xe);else{const Pe=await Os(`/api/record/done?page=${me}&pageSize=${e}&sort=${encodeURIComponent(i)}&withCount=1`,{cache:"no-store"}),it=Array.isArray(Pe?.items)?Pe.items:[];g(it)}}catch{}},[v,i]);function Fi(Q){const se=zm(Q);if(!se)return!1;try{return new URL(se).hostname.includes("chaturbate.com")}catch{return!1}}function Ui(Q,se){const ae=Object.fromEntries(Object.entries(Q).map(([xe,Te])=>[xe.trim().toLowerCase(),Te]));for(const xe of se){const Te=ae[xe.toLowerCase()];if(Te)return Te}}function Ei(Q){const se=Ui(Q,["cf_clearance"]),ae=Ui(Q,["sessionid","session_id","sessionId"]);return!!(se&&ae)}async function Wt(Q){try{await Os(`/api/record/stop?id=${encodeURIComponent(Q)}`,{method:"POST"})}catch(se){s.error("Stop fehlgeschlagen",se?.message??String(se))}}A.useEffect(()=>{const Q=se=>{const xe=Number(se.detail?.delta??0);if(!Number.isFinite(xe)||xe===0){ai();return}S(Te=>Math.max(0,Te+xe)),ai()};return window.addEventListener("finished-downloads:count-hint",Q),()=>window.removeEventListener("finished-downloads:count-hint",Q)},[ai]),A.useEffect(()=>{const Q=se=>{const ae=se.detail||{};ae.tab==="finished"&&pt("finished"),ae.tab==="categories"&&pt("categories"),ae.tab==="models"&&pt("models"),ae.tab==="running"&&pt("running"),ae.tab==="settings"&&pt("settings")};return window.addEventListener("app:navigate-tab",Q),()=>window.removeEventListener("app:navigate-tab",Q)},[]),A.useEffect(()=>{if(!ut){G(null),o(null);return}const Q=(Kd(ut.output||"")||"").trim().toLowerCase();o(Q||null);const se=Q?X[Q]:void 0;G(se??null)},[ut,X]);async function Kt(){return Ee(u)}const jt=A.useCallback(async Q=>{const se=Ms(Q.output||"");if(se){window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"start"}}));try{await Os(`/api/record/delete?file=${encodeURIComponent(se)}`,{method:"POST"}),window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"success"}})),window.setTimeout(()=>{g(ae=>ae.filter(xe=>Ms(xe.output||"")!==se)),f(ae=>ae.filter(xe=>Ms(xe.output||"")!==se)),Ht(ae=>ae&&Ms(ae.output||"")===se?null:ae)},320),window.setTimeout(()=>{ai()},350)}catch(ae){window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"error"}})),s.error("Löschen fehlgeschlagen",ae?.message??String(ae));return}}},[s]),Ii=A.useCallback(async Q=>{const se=Ms(Q.output||"");if(se){window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"start"}}));try{await Os(`/api/record/keep?file=${encodeURIComponent(se)}`,{method:"POST"}),window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"success"}})),window.setTimeout(()=>{g(ae=>ae.filter(xe=>Ms(xe.output||"")!==se)),f(ae=>ae.filter(xe=>Ms(xe.output||"")!==se)),Ht(ae=>ae&&Ms(ae.output||"")===se?null:ae)},320),ai()}catch(ae){window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:se,phase:"error"}})),s.error("Keep fehlgeschlagen",ae?.message??String(ae));return}}},[mt,ai,s]),ds=A.useCallback(async Q=>{const se=Ms(Q.output||"");if(se)try{const ae=await Os(`/api/record/toggle-hot?file=${encodeURIComponent(se)}`,{method:"POST"}),xe=Rv(Q.output||"",ae.newFile);Ht(Te=>Te&&{...Te,output:xe}),g(Te=>Te.map(je=>Ms(je.output||"")===se?{...je,output:Rv(je.output||"",ae.newFile)}:je)),f(Te=>Te.map(je=>Ms(je.output||"")===se?{...je,output:Rv(je.output||"",ae.newFile)}:je))}catch(ae){s.error("Umbenennen fehlgeschlagen",ae?.message??String(ae));return}},[s]);async function as(Q){const se=await fetch("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)});if(se.status===204)return null;if(!se.ok){const ae=await se.text().catch(()=>"");throw new Error(ae||`HTTP ${se.status}`)}return se.json()}const Fs=A.useCallback(Q=>{const se=J.current;!se||!Q||(se.ts=Date.now(),se.list=se.list.filter(ae=>ae.id!==Q))},[]),fi=A.useRef({}),li=A.useCallback(async Q=>{const se=Ms(Q.output||""),ae=!!(ut&&Ms(ut.output||"")===se),xe=Ke=>{try{const Ve=String(Ke.sourceUrl??Ke.SourceURL??""),Ze=Wu(Ve);return Ze?new URL(Ze).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Te=(Kd(Q.output||"")||"").trim().toLowerCase();if(Te){const Ke=Te;if(fi.current[Ke])return;fi.current[Ke]=!0;const Ve=X[Te]??{id:"",input:"",host:xe(Q)||void 0,modelKey:Te,watching:!1,favorite:!1,liked:null,isUrl:!1},Ze=!Ve.favorite,_t={...Ve,modelKey:Ve.modelKey||Te,favorite:Ze,liked:Ze?!1:Ve.liked};q(St=>({...St,[Te]:_t})),F(_t),ae&&G(_t);try{const St=await as({..._t.id?{id:_t.id}:{},host:_t.host||xe(Q)||"",modelKey:Te,favorite:Ze,...Ze?{liked:!1}:{}});if(!St){q(Ti=>{const{[Te]:Js,...vs}=Ti;return vs}),Ve.id&&Fs(Ve.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:Ve.id,modelKey:Te}}));return}const Bt=I(St.modelKey||Te);Bt&&q(Ti=>({...Ti,[Bt]:St})),F(St),ae&&G(St),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:St}}))}catch(St){q(Bt=>({...Bt,[Te]:Ve})),F(Ve),ae&&G(Ve),s.error("Favorit umschalten fehlgeschlagen",St?.message??String(St))}finally{delete fi.current[Ke]}return}let je=ae?Y:null;if(je||(je=await Us(Q,{ensure:!0})),!je)return;const de=I(je.modelKey||je.id||"");if(!de||fi.current[de])return;fi.current[de]=!0;const me=je,Pe=!me.favorite,it={...me,favorite:Pe,liked:Pe?!1:me.liked},ft=I(me.modelKey||"");ft&&q(Ke=>({...Ke,[ft]:it})),F(it),ae&&G(it);try{const Ke=await as({id:me.id,favorite:Pe,...Pe?{liked:!1}:{}});if(!Ke){q(Ze=>{const _t=I(me.modelKey||"");if(!_t)return Ze;const{[_t]:St,...Bt}=Ze;return Bt}),Fs(me.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:me.id,modelKey:me.modelKey}}));return}const Ve=I(Ke.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:Ke})),F(Ke),ae&&G(Ke),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Ke}}))}catch(Ke){const Ve=I(me.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:me})),F(me),ae&&G(me),s.error("Favorit umschalten fehlgeschlagen",Ke?.message??String(Ke))}finally{delete fi.current[de]}},[s,ut,Y,Us,as,F,Fs,X]),ji=A.useCallback(async Q=>{const se=Ms(Q.output||""),ae=!!(ut&&Ms(ut.output||"")===se),xe=Ke=>{try{const Ve=String(Ke.sourceUrl??Ke.SourceURL??""),Ze=Wu(Ve);return Ze?new URL(Ze).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Te=(Kd(Q.output||"")||"").trim().toLowerCase();if(Te){const Ke=Te;if(fi.current[Ke])return;fi.current[Ke]=!0;const Ve=X[Te]??{id:"",input:"",host:xe(Q)||void 0,modelKey:Te,watching:!1,favorite:!1,liked:null,isUrl:!1},Ze=Ve.liked!==!0,_t={...Ve,modelKey:Ve.modelKey||Te,liked:Ze,favorite:Ze?!1:Ve.favorite};q(St=>({...St,[Te]:_t})),F(_t),ae&&G(_t);try{const St=await as({..._t.id?{id:_t.id}:{},host:_t.host||xe(Q)||"",modelKey:Te,liked:Ze,...Ze?{favorite:!1}:{}});if(!St){q(Ti=>{const{[Te]:Js,...vs}=Ti;return vs}),Ve.id&&Fs(Ve.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:Ve.id,modelKey:Te}}));return}const Bt=I(St.modelKey||Te);Bt&&q(Ti=>({...Ti,[Bt]:St})),F(St),ae&&G(St),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:St}}))}catch(St){q(Bt=>({...Bt,[Te]:Ve})),F(Ve),ae&&G(Ve),s.error("Like umschalten fehlgeschlagen",St?.message??String(St))}finally{delete fi.current[Ke]}return}let je=ae?Y:null;if(je||(je=await Us(Q,{ensure:!0})),!je)return;const de=I(je.modelKey||je.id||"");if(!de||fi.current[de])return;fi.current[de]=!0;const me=je,Pe=me.liked!==!0,it={...me,liked:Pe,favorite:Pe?!1:me.favorite},ft=I(me.modelKey||"");ft&&q(Ke=>({...Ke,[ft]:it})),F(it),ae&&G(it);try{const Ke=Pe?await as({id:me.id,liked:!0,favorite:!1}):await as({id:me.id,liked:!1});if(!Ke){q(Ze=>{const _t=I(me.modelKey||"");if(!_t)return Ze;const{[_t]:St,...Bt}=Ze;return Bt}),Fs(me.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:me.id,modelKey:me.modelKey}}));return}const Ve=I(Ke.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:Ke})),F(Ke),ae&&G(Ke),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Ke}}))}catch(Ke){const Ve=I(me.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:me})),F(me),ae&&G(me),s.error("Like umschalten fehlgeschlagen",Ke?.message??String(Ke))}finally{delete fi.current[de]}},[s,ut,Y,Us,as,F,Fs,X]),hs=A.useCallback(async Q=>{const se=Ms(Q.output||""),ae=!!(ut&&Ms(ut.output||"")===se),xe=Ke=>{try{const Ve=String(Ke.sourceUrl??Ke.SourceURL??""),Ze=Wu(Ve);return Ze?new URL(Ze).hostname.replace(/^www\./i,"").toLowerCase():""}catch{return""}},Te=(Kd(Q.output||"")||"").trim().toLowerCase();if(Te){const Ke=Te;if(fi.current[Ke])return;fi.current[Ke]=!0;const Ve=X[Te]??{id:"",input:"",host:xe(Q)||void 0,modelKey:Te,watching:!1,favorite:!1,liked:null,isUrl:!1},Ze=!Ve.watching,_t={...Ve,modelKey:Ve.modelKey||Te,watching:Ze};q(St=>({...St,[Te]:_t})),F(_t),ae&&G(_t);try{const St=await as({..._t.id?{id:_t.id}:{},host:_t.host||xe(Q)||"",modelKey:Te,watched:Ze});if(!St){q(Ti=>{const{[Te]:Js,...vs}=Ti;return vs}),Ve.id&&Fs(Ve.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:Ve.id,modelKey:Te}}));return}const Bt=I(St.modelKey||Te);Bt&&q(Ti=>({...Ti,[Bt]:St})),F(St),ae&&G(St),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:St}}))}catch(St){q(Bt=>({...Bt,[Te]:Ve})),F(Ve),ae&&G(Ve),s.error("Watched umschalten fehlgeschlagen",St?.message??String(St))}finally{delete fi.current[Ke]}return}let je=ae?Y:null;if(je||(je=await Us(Q,{ensure:!0})),!je)return;const de=I(je.modelKey||je.id||"");if(!de||fi.current[de])return;fi.current[de]=!0;const me=je,Pe=!me.watching,it={...me,watching:Pe},ft=I(me.modelKey||"");ft&&q(Ke=>({...Ke,[ft]:it})),F(it),ae&&G(it);try{const Ke=await as({id:me.id,watched:Pe});if(!Ke){q(Ze=>{const _t=I(me.modelKey||"");if(!_t)return Ze;const{[_t]:St,...Bt}=Ze;return Bt}),Fs(me.id),ae&&G(null),window.dispatchEvent(new CustomEvent("models-changed",{detail:{removed:!0,id:me.id,modelKey:me.modelKey}}));return}const Ve=I(Ke.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:Ke})),F(Ke),ae&&G(Ke),window.dispatchEvent(new CustomEvent("models-changed",{detail:{model:Ke}}))}catch(Ke){const Ve=I(me.modelKey||"");Ve&&q(Ze=>({...Ze,[Ve]:me})),F(me),ae&&G(me),s.error("Watched umschalten fehlgeschlagen",Ke?.message??String(Ke))}finally{delete fi.current[de]}},[s,ut,Y,Us,as,F,Fs,X]);async function Us(Q,se){const ae=!!se?.ensure,xe=it=>{const ft=Date.now(),Ke=J.current;if(!Ke){J.current={ts:ft,list:[it]};return}Ke.ts=ft;const Ve=Ke.list.findIndex(Ze=>Ze.id===it.id);Ve>=0?Ke.list[Ve]=it:Ke.list.unshift(it)},Te=async it=>{if(!it)return null;const ft=it.trim().toLowerCase();if(!ft)return null;const Ke=X[ft];if(Ke)return xe(Ke),Ke;if(ae){let Bt;try{const Js=Q.sourceUrl??Q.SourceURL??"",vs=Wu(Js);vs&&(Bt=new URL(vs).hostname.replace(/^www\./i,"").toLowerCase())}catch{}const Ti=await Os("/api/models/ensure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelKey:it,...Bt?{host:Bt}:{}})});return F(Ti),Ti}const Ve=Date.now(),Ze=J.current;if(!Ze||Ve-Ze.ts>3e4){const Bt=Object.values(X);if(Bt.length)J.current={ts:Ve,list:Bt};else{const Ti=await Os("/api/models/list",{cache:"no-store"});J.current={ts:Ve,list:Array.isArray(Ti)?Ti:[]}}}const St=(J.current?.list??[]).find(Bt=>(Bt.modelKey||"").trim().toLowerCase()===ft);return St||null},je=Kd(Q.output||"");if(je)return Te(je);const de=Q.status==="running",me=Q.sourceUrl??Q.SourceURL??"",Pe=Wu(me);if(de&&Pe){const it=await Os("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:Pe})}),ft=await Os("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(it)});return F(ft),ft}return null}return A.useEffect(()=>{if(!ot&&!nt||!navigator.clipboard?.readText)return;let Q=!1,se=!1,ae=null;const xe=async()=>{if(!(Q||se)){se=!0;try{const de=await navigator.clipboard.readText(),me=Wu(de);if(!me||!Qw(me)||me===Ut.current)return;Ut.current=me,ot&&c(me),nt&&(wt.current?Lt.current=me:(Lt.current=null,await Ee(me)))}catch{}finally{se=!1}}},Te=de=>{Q||(ae=window.setTimeout(async()=>{await xe(),Te(document.hidden?5e3:1500)},de))},je=()=>{xe()};return window.addEventListener("hover",je),document.addEventListener("visibilitychange",je),Te(0),()=>{Q=!0,ae&&window.clearTimeout(ae),window.removeEventListener("hover",je),document.removeEventListener("visibilitychange",je)}},[ot,nt,Ee]),A.useEffect(()=>{if(_e||!nt)return;const Q=Lt.current;Q&&(Lt.current=null,Ee(Q))},[_e,nt,Ee]),A.useEffect(()=>{const Q=Gw({getModels:()=>{if(!et.current.useChaturbateApi)return[];const se=Ie.current,ae=H.current,xe=Object.values(se).filter(je=>!!je?.watching&&String(je?.host??"").toLowerCase().includes("chaturbate")).map(je=>String(je?.modelKey??"").trim().toLowerCase()).filter(Boolean),Te=Object.keys(ae||{}).map(je=>String(je||"").trim().toLowerCase()).filter(Boolean);return Array.from(new Set([...xe,...Te]))},getShow:()=>["public","private","hidden","away"],intervalMs:12e3,onData:se=>{(async()=>{if(!se?.enabled){gi({}),kt.current={},Xe([]),V(Date.now());return}const ae={};for(const de of Array.isArray(se.rooms)?se.rooms:[]){const me=String(de?.username??"").trim().toLowerCase();me&&(ae[me]=de)}gi(ae),kt.current=ae;const xe=K.current;for(const de of xe||[]){const me=String(de||"").trim().toLowerCase();me&&ae[me]}if(!et.current.useChaturbateApi)Xe([]);else if(re.current==="running"){const de=Ie.current,me=H.current,Pe=Array.from(new Set(Object.values(de).filter(Ve=>!!Ve?.watching&&String(Ve?.host??"").toLowerCase().includes("chaturbate")).map(Ve=>String(Ve?.modelKey??"").trim().toLowerCase()).filter(Boolean))),it=Object.keys(me||{}).map(Ve=>String(Ve||"").trim().toLowerCase()).filter(Boolean),ft=new Set(it),Ke=Array.from(new Set([...Pe,...it]));if(Ke.length===0)Xe([]);else{const Ve=[];for(const Ze of Ke){const _t=ae[Ze];if(!_t)continue;const St=String(_t?.username??"").trim(),Bt=String(_t?.current_show??"unknown");if(Bt==="public"&&!ft.has(Ze))continue;const Ti=`https://chaturbate.com/${(St||Ze).trim()}/`;Ve.push({id:Ze,modelKey:St||Ze,url:Ti,currentShow:Bt,imageUrl:String(_t?.image_url??"")})}Ve.sort((Ze,_t)=>Ze.modelKey.localeCompare(_t.modelKey,void 0,{sensitivity:"base"})),Xe(Ve)}}if(!et.current.useChaturbateApi||wt.current)return;const Te=H.current,je=Object.keys(Te||{}).map(de=>String(de||"").toLowerCase()).filter(Boolean);for(const de of je){const me=ae[de];if(!me||String(me.current_show??"")!=="public")continue;const Pe=Te[de];if(!Pe)continue;await Ee(Pe,{silent:!0})&&Gt(ft=>{const Ke={...ft||{}};return delete Ke[de],H.current=Ke,Ke})}V(Date.now())})()}});return()=>Q()},[]),A.useEffect(()=>{if(!ze.useChaturbateApi){M(0);return}const Q=Gw({getModels:()=>[],getShow:()=>["public","private","hidden","away"],intervalMs:3e4,fetchAllWhenNoModels:!0,onData:se=>{if(!se?.enabled){M(0);return}const ae=Number(se?.total??0);M(Number.isFinite(ae)?ae:0),V(Date.now())},onError:se=>{console.error("[ALL-online poller] error",se)}});return()=>Q()},[ze.useChaturbateApi]),y.jsxs("div",{className:"min-h-screen bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100",children:[y.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 overflow-hidden",children:[y.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"}),y.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"})]}),y.jsxs("div",{className:"relative",children:[y.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:y.jsxs("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-3 sm:py-4 space-y-2 sm:space-y-3",children:[y.jsxs("div",{className:"flex items-center sm:items-start justify-between gap-3 sm:gap-4",children:[y.jsx("div",{className:"min-w-0",children:y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[y.jsx("h1",{className:"text-lg font-semibold tracking-tight text-gray-900 dark:text-white",children:"Recorder"}),y.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[y.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:[y.jsx(cM,{className:"size-4 opacity-80"}),y.jsx("span",{className:"tabular-nums",children:L})]}),y.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:[y.jsx(xc,{className:"size-4 opacity-80"}),y.jsx("span",{className:"tabular-nums",children:xi})]}),y.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:[y.jsx(bc,{className:"size-4 opacity-80"}),y.jsx("span",{className:"tabular-nums",children:Wi})]}),y.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:[y.jsx(sM,{className:"size-4 opacity-80"}),y.jsx("span",{className:"tabular-nums",children:Xi})]})]}),y.jsx("div",{className:"hidden sm:block text-[11px] text-gray-500 dark:text-gray-400",children:W})]}),y.jsxs("div",{className:"sm:hidden mt-1 w-full",children:[y.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:W}),y.jsxs("div",{className:"mt-2 flex items-stretch gap-2",children:[y.jsx(Vw,{mode:"inline",className:"flex-1"}),y.jsx(ti,{variant:"secondary",onClick:()=>Be(!0),className:"px-3 shrink-0",children:"Cookies"})]})]})]})}),y.jsxs("div",{className:"hidden sm:flex items-center gap-2 h-full",children:[y.jsx(Vw,{mode:"inline"}),y.jsx(ti,{variant:"secondary",onClick:()=>Be(!0),className:"h-9 px-3",children:"Cookies"})]})]}),y.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto] sm:items-stretch",children:[y.jsxs("div",{className:"relative",children:[y.jsx("label",{className:"sr-only",children:"Source URL"}),y.jsx("input",{value:u,onChange:Q=>c(Q.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"})]}),y.jsx(ti,{variant:"primary",onClick:Kt,disabled:!Qi,className:"w-full sm:w-auto rounded-lg",children:"Start"})]}),ee?y.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:y.jsxs("div",{className:"flex items-start justify-between gap-3",children:[y.jsx("div",{className:"min-w-0 break-words",children:ee}),y.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:()=>pe(null),"aria-label":"Fehlermeldung schließen",title:"Schließen",children:"✕"})]})}):null,Fi(u)&&!Ei(tt)?y.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["⚠️ Für Chaturbate werden die Cookies ",y.jsx("code",{children:"cf_clearance"})," und ",y.jsx("code",{children:"sessionId"})," benötigt."]}):null,_e?y.jsx("div",{className:"pt-1",children:y.jsx(vc,{label:"Starte Download…",indeterminate:!0})}):null,y.jsx("div",{className:"hidden sm:block pt-2",children:y.jsx(ES,{tabs:rs,value:mt,onChange:pt,ariaLabel:"Tabs",variant:"barUnderline"})})]})}),y.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:y.jsx("div",{className:"mx-auto max-w-7xl px-4 py-2",children:y.jsx(ES,{tabs:rs,value:mt,onChange:pt,ariaLabel:"Tabs",variant:"barUnderline"})})}),y.jsxs("main",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-6 space-y-6",children:[mt==="running"?y.jsx(s9,{jobs:zt,modelsByKey:X,pending:vt,onOpenPlayer:Tt,onStopJob:Wt,onToggleFavorite:li,onToggleLike:ji,onToggleWatch:hs,blurPreviews:!!ze.blurPreviews}):null,mt==="finished"?y.jsx(LM,{jobs:d,modelsByKey:X,doneJobs:p,doneTotal:_,page:v,pageSize:e,onPageChange:b,onOpenPlayer:Tt,onDeleteJob:jt,onToggleHot:ds,onToggleFavorite:li,onToggleLike:ji,onToggleWatch:hs,blurPreviews:!!ze.blurPreviews,teaserPlayback:ze.teaserPlayback??"hover",teaserAudio:!!ze.teaserAudio,assetNonce:Dt,sortMode:i,onSortModeChange:Q=>{n(Q),b(1)}}):null,mt==="models"?y.jsx(u9,{}):null,mt==="categories"?y.jsx(D9,{}):null,mt==="settings"?y.jsx(W5,{onAssetsGenerated:dt}):null]}),y.jsx(z5,{open:Ce,onClose:()=>Be(!1),initialCookies:Ye,onApply:Q=>{const se=Nm(Object.fromEntries(Q.map(ae=>[ae.name,ae.value])));Je(se),Os("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:se})}).catch(()=>{})}}),y.jsx(T9,{open:!!oe,modelKey:oe,onClose:()=>ce(null),onOpenPlayer:Tt,runningJobs:zt,cookies:tt,blurPreviews:ze.blurPreviews,onToggleHot:ds,onDelete:jt,onToggleFavorite:li,onToggleLike:ji,onToggleWatch:hs}),ut?y.jsx(z8,{job:ut,modelKey:r??void 0,modelsByKey:X,expanded:at,onToggleExpand:()=>gt(Q=>!Q),onClose:()=>Ht(null),isHot:Ms(ut.output||"").startsWith("HOT "),isFavorite:!!Y?.favorite,isLiked:Y?.liked===!0,isWatching:!!Y?.watching,onKeep:Ii,onDelete:jt,onToggleHot:ds,onToggleFavorite:li,onToggleLike:ji,onStopJob:Wt,onToggleWatch:hs}):null]})]})}II.createRoot(document.getElementById("root")).render(y.jsx(A.StrictMode,{children:y.jsx(CM,{position:"top-right",maxToasts:3,defaultDurationMs:3500,children:y.jsx(I9,{})})}));