mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
126 lines
514 KiB
JavaScript
126 lines
514 KiB
JavaScript
(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function Uy(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Mu={exports:{}},Qs={};var J0;function Hy(){if(J0)return Qs;J0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var p in f)p!=="key"&&(d[p]=f[p])}else d=f;return f=d.ref,{$$typeof:a,type:o,key:h,ref:f!==void 0?f:null,props:d}}return Qs.Fragment=l,Qs.jsx=i,Qs.jsxs=i,Qs}var I0;function Vy(){return I0||(I0=1,Mu.exports=Hy()),Mu.exports}var r=Vy(),Ru={exports:{}},Se={};var W0;function $y(){if(W0)return Se;W0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),N=Symbol.iterator;function M(q){return q===null||typeof q!="object"?null:(q=N&&q[N]||q["@@iterator"],typeof q=="function"?q:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,j={};function k(q,H,ne){this.props=q,this.context=H,this.refs=j,this.updater=ne||E}k.prototype.isReactComponent={},k.prototype.setState=function(q,H){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,H,"setState")},k.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function A(){}A.prototype=k.prototype;function C(q,H,ne){this.props=q,this.context=H,this.refs=j,this.updater=ne||E}var _=C.prototype=new A;_.constructor=C,w(_,k.prototype),_.isPureReactComponent=!0;var L=Array.isArray;function Y(){}var O={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function z(q,H,ne){var le=ne.ref;return{$$typeof:a,type:q,key:H,ref:le!==void 0?le:null,props:ne}}function Q(q,H){return z(q.type,H,q.props)}function K(q){return typeof q=="object"&&q!==null&&q.$$typeof===a}function ae(q){var H={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(ne){return H[ne]})}var ce=/\/+/g;function oe(q,H){return typeof q=="object"&&q!==null&&q.key!=null?ae(""+q.key):H.toString(36)}function $(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(Y,Y):(q.status="pending",q.then(function(H){q.status==="pending"&&(q.status="fulfilled",q.value=H)},function(H){q.status==="pending"&&(q.status="rejected",q.reason=H)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function R(q,H,ne,le,se){var ie=typeof q;(ie==="undefined"||ie==="boolean")&&(q=null);var ue=!1;if(q===null)ue=!0;else switch(ie){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(q.$$typeof){case a:case l:ue=!0;break;case y:return ue=q._init,R(ue(q._payload),H,ne,le,se)}}if(ue)return se=se(q),ue=le===""?"."+oe(q,0):le,L(se)?(ne="",ue!=null&&(ne=ue.replace(ce,"$&/")+"/"),R(se,H,ne,"",function(we){return we})):se!=null&&(K(se)&&(se=Q(se,ne+(se.key==null||q&&q.key===se.key?"":(""+se.key).replace(ce,"$&/")+"/")+ue)),H.push(se)),1;ue=0;var ve=le===""?".":le+":";if(L(q))for(var me=0;me<q.length;me++)le=q[me],ie=ve+oe(le,me),ue+=R(le,H,ne,ie,se);else if(me=M(q),typeof me=="function")for(q=me.call(q),me=0;!(le=q.next()).done;)le=le.value,ie=ve+oe(le,me++),ue+=R(le,H,ne,ie,se);else if(ie==="object"){if(typeof q.then=="function")return R($(q),H,ne,le,se);throw H=String(q),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return ue}function F(q,H,ne){if(q==null)return q;var le=[],se=0;return R(q,le,"","",function(ie){return H.call(ne,ie,se++)}),le}function P(q){if(q._status===-1){var H=q._result;H=H(),H.then(function(ne){(q._status===0||q._status===-1)&&(q._status=1,q._result=ne)},function(ne){(q._status===0||q._status===-1)&&(q._status=2,q._result=ne)}),q._status===-1&&(q._status=0,q._result=H)}if(q._status===1)return q._result.default;throw q._result}var re=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},fe={map:F,forEach:function(q,H,ne){F(q,function(){H.apply(this,arguments)},ne)},count:function(q){var H=0;return F(q,function(){H++}),H},toArray:function(q){return F(q,function(H){return H})||[]},only:function(q){if(!K(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Se.Activity=b,Se.Children=fe,Se.Component=k,Se.Fragment=i,Se.Profiler=f,Se.PureComponent=C,Se.StrictMode=o,Se.Suspense=x,Se.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Se.__COMPILER_RUNTIME={__proto__:null,c:function(q){return O.H.useMemoCache(q)}},Se.cache=function(q){return function(){return q.apply(null,arguments)}},Se.cacheSignal=function(){return null},Se.cloneElement=function(q,H,ne){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var le=w({},q.props),se=q.key;if(H!=null)for(ie in H.key!==void 0&&(se=""+H.key),H)!X.call(H,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&H.ref===void 0||(le[ie]=H[ie]);var ie=arguments.length-2;if(ie===1)le.children=ne;else if(1<ie){for(var ue=Array(ie),ve=0;ve<ie;ve++)ue[ve]=arguments[ve+2];le.children=ue}return z(q.type,se,le)},Se.createContext=function(q){return q={$$typeof:h,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:d,_context:q},q},Se.createElement=function(q,H,ne){var le,se={},ie=null;if(H!=null)for(le in H.key!==void 0&&(ie=""+H.key),H)X.call(H,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(se[le]=H[le]);var ue=arguments.length-2;if(ue===1)se.children=ne;else if(1<ue){for(var ve=Array(ue),me=0;me<ue;me++)ve[me]=arguments[me+2];se.children=ve}if(q&&q.defaultProps)for(le in ue=q.defaultProps,ue)se[le]===void 0&&(se[le]=ue[le]);return z(q,ie,se)},Se.createRef=function(){return{current:null}},Se.forwardRef=function(q){return{$$typeof:p,render:q}},Se.isValidElement=K,Se.lazy=function(q){return{$$typeof:y,_payload:{_status:-1,_result:q},_init:P}},Se.memo=function(q,H){return{$$typeof:g,type:q,compare:H===void 0?null:H}},Se.startTransition=function(q){var H=O.T,ne={};O.T=ne;try{var le=q(),se=O.S;se!==null&&se(ne,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(Y,re)}catch(ie){re(ie)}finally{H!==null&&ne.types!==null&&(H.types=ne.types),O.T=H}},Se.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Se.use=function(q){return O.H.use(q)},Se.useActionState=function(q,H,ne){return O.H.useActionState(q,H,ne)},Se.useCallback=function(q,H){return O.H.useCallback(q,H)},Se.useContext=function(q){return O.H.useContext(q)},Se.useDebugValue=function(){},Se.useDeferredValue=function(q,H){return O.H.useDeferredValue(q,H)},Se.useEffect=function(q,H){return O.H.useEffect(q,H)},Se.useEffectEvent=function(q){return O.H.useEffectEvent(q)},Se.useId=function(){return O.H.useId()},Se.useImperativeHandle=function(q,H,ne){return O.H.useImperativeHandle(q,H,ne)},Se.useInsertionEffect=function(q,H){return O.H.useInsertionEffect(q,H)},Se.useLayoutEffect=function(q,H){return O.H.useLayoutEffect(q,H)},Se.useMemo=function(q,H){return O.H.useMemo(q,H)},Se.useOptimistic=function(q,H){return O.H.useOptimistic(q,H)},Se.useReducer=function(q,H,ne){return O.H.useReducer(q,H,ne)},Se.useRef=function(q){return O.H.useRef(q)},Se.useState=function(q){return O.H.useState(q)},Se.useSyncExternalStore=function(q,H,ne){return O.H.useSyncExternalStore(q,H,ne)},Se.useTransition=function(){return O.H.useTransition()},Se.version="19.2.0",Se}var P0;function Cf(){return P0||(P0=1,Ru.exports=$y()),Ru.exports}var m=Cf();const Ia=Uy(m);var Tu={exports:{}},Ks={},Du={exports:{}},_u={};var ep;function Yy(){return ep||(ep=1,(function(a){function l(R,F){var P=R.length;R.push(F);e:for(;0<P;){var re=P-1>>>1,fe=R[re];if(0<f(fe,F))R[re]=F,R[P]=fe,P=re;else break e}}function i(R){return R.length===0?null:R[0]}function o(R){if(R.length===0)return null;var F=R[0],P=R.pop();if(P!==F){R[0]=P;e:for(var re=0,fe=R.length,q=fe>>>1;re<q;){var H=2*(re+1)-1,ne=R[H],le=H+1,se=R[le];if(0>f(ne,P))le<fe&&0>f(se,ne)?(R[re]=se,R[le]=P,re=le):(R[re]=ne,R[H]=P,re=H);else if(le<fe&&0>f(se,P))R[re]=se,R[le]=P,re=le;else break e}}return F}function f(R,F){var P=R.sortIndex-F.sortIndex;return P!==0?P:R.id-F.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;a.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var x=[],g=[],y=1,b=null,N=3,M=!1,E=!1,w=!1,j=!1,k=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function _(R){for(var F=i(g);F!==null;){if(F.callback===null)o(g);else if(F.startTime<=R)o(g),F.sortIndex=F.expirationTime,l(x,F);else break;F=i(g)}}function L(R){if(w=!1,_(R),!E)if(i(x)!==null)E=!0,Y||(Y=!0,ae());else{var F=i(g);F!==null&&$(L,F.startTime-R)}}var Y=!1,O=-1,X=5,z=-1;function Q(){return j?!0:!(a.unstable_now()-z<X)}function K(){if(j=!1,Y){var R=a.unstable_now();z=R;var F=!0;try{e:{E=!1,w&&(w=!1,A(O),O=-1),M=!0;var P=N;try{t:{for(_(R),b=i(x);b!==null&&!(b.expirationTime>R&&Q());){var re=b.callback;if(typeof re=="function"){b.callback=null,N=b.priorityLevel;var fe=re(b.expirationTime<=R);if(R=a.unstable_now(),typeof fe=="function"){b.callback=fe,_(R),F=!0;break t}b===i(x)&&o(x),_(R)}else o(x);b=i(x)}if(b!==null)F=!0;else{var q=i(g);q!==null&&$(L,q.startTime-R),F=!1}}break e}finally{b=null,N=P,M=!1}F=void 0}}finally{F?ae():Y=!1}}}var ae;if(typeof C=="function")ae=function(){C(K)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,oe=ce.port2;ce.port1.onmessage=K,ae=function(){oe.postMessage(null)}}else ae=function(){k(K,0)};function $(R,F){O=k(function(){R(a.unstable_now())},F)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(R){R.callback=null},a.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<R?Math.floor(1e3/R):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_next=function(R){switch(N){case 1:case 2:case 3:var F=3;break;default:F=N}var P=N;N=F;try{return R()}finally{N=P}},a.unstable_requestPaint=function(){j=!0},a.unstable_runWithPriority=function(R,F){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var P=N;N=R;try{return F()}finally{N=P}},a.unstable_scheduleCallback=function(R,F,P){var re=a.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?re+P:re):P=re,R){case 1:var fe=-1;break;case 2:fe=250;break;case 5:fe=1073741823;break;case 4:fe=1e4;break;default:fe=5e3}return fe=P+fe,R={id:y++,callback:F,priorityLevel:R,startTime:P,expirationTime:fe,sortIndex:-1},P>re?(R.sortIndex=P,l(g,R),i(x)===null&&R===i(g)&&(w?(A(O),O=-1):w=!0,$(L,P-re))):(R.sortIndex=fe,l(x,R),E||M||(E=!0,Y||(Y=!0,ae()))),R},a.unstable_shouldYield=Q,a.unstable_wrapCallback=function(R){var F=N;return function(){var P=N;N=F;try{return R.apply(this,arguments)}finally{N=P}}}})(_u)),_u}var tp;function Gy(){return tp||(tp=1,Du.exports=Yy()),Du.exports}var Ou={exports:{}},Nt={};var np;function Xy(){if(np)return Nt;np=1;var a=Cf();function l(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(l(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(x,g,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:x,containerInfo:g,implementation:y}}var h=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Nt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Nt.createPortal=function(x,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(l(299));return d(x,g,null,y)},Nt.flushSync=function(x){var g=h.T,y=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=y,o.d.f()}},Nt.preconnect=function(x,g){typeof x=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(x,g))},Nt.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},Nt.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin),N=typeof g.integrity=="string"?g.integrity:void 0,M=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:N,fetchPriority:M}):y==="script"&&o.d.X(x,{crossOrigin:b,integrity:N,fetchPriority:M,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Nt.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Nt.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin);o.d.L(x,y,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Nt.preloadModule=function(x,g){if(typeof x=="string")if(g){var y=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Nt.requestFormReset=function(x){o.d.r(x)},Nt.unstable_batchedUpdates=function(x,g){return x(g)},Nt.useFormState=function(x,g,y){return h.H.useFormState(x,g,y)},Nt.useFormStatus=function(){return h.H.useHostTransitionStatus()},Nt.version="19.2.0",Nt}var ap;function Fy(){if(ap)return Ou.exports;ap=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Ou.exports=Xy(),Ou.exports}var lp;function Qy(){if(lp)return Ks;lp=1;var a=Gy(),l=Cf(),i=Fy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var n=e,s=t;;){var c=n.return;if(c===null)break;var u=c.alternate;if(u===null){if(s=c.return,s!==null){n=s;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===n)return x(c),e;if(u===s)return x(c),t;u=u.sibling}throw Error(o(188))}if(n.return!==s.return)n=c,s=u;else{for(var v=!1,S=c.child;S;){if(S===n){v=!0,n=c,s=u;break}if(S===s){v=!0,s=c,n=u;break}S=S.sibling}if(!v){for(S=u.child;S;){if(S===n){v=!0,n=u,s=c;break}if(S===s){v=!0,s=u,n=c;break}S=S.sibling}if(!v)throw Error(o(189))}}if(n.alternate!==s)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function y(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=y(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,N=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),C=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),Q=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function ae(e){return e===null||typeof e!="object"?null:(e=K&&e[K]||e["@@iterator"],typeof e=="function"?e:null)}var ce=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case k:return"Profiler";case j:return"StrictMode";case L:return"Suspense";case Y:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case C:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case _:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case X:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var $=Array.isArray,R=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},re=[],fe=-1;function q(e){return{current:e}}function H(e){0>fe||(e.current=re[fe],re[fe]=null,fe--)}function ne(e,t){fe++,re[fe]=e.current,e.current=t}var le=q(null),se=q(null),ie=q(null),ue=q(null);function ve(e,t){switch(ne(ie,t),ne(se,e),ne(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?y0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=y0(t),e=b0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(le),ne(le,e)}function me(){H(le),H(se),H(ie)}function we(e){e.memoizedState!==null&&ne(ue,e);var t=le.current,n=b0(t,e.type);t!==n&&(ne(se,e),ne(le,n))}function te(e){se.current===e&&(H(le),H(se)),ue.current===e&&(H(ue),Ys._currentValue=P)}var J,pe;function be(e){if(J===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);J=t&&t[1]||"",pe=-1<n.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+J+e+pe}var Ne=!1;function ze(e,t){if(!e||Ne)return"";Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(Z){var G=Z}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(Z){G=Z}e.call(ee.prototype)}}else{try{throw Error()}catch(Z){G=Z}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(Z){if(Z&&G&&typeof Z.stack=="string")return[Z.stack,G.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=s.DetermineComponentFrameRoot(),v=u[0],S=u[1];if(v&&S){var T=v.split(`
|
||
`),V=S.split(`
|
||
`);for(c=s=0;s<T.length&&!T[s].includes("DetermineComponentFrameRoot");)s++;for(;c<V.length&&!V[c].includes("DetermineComponentFrameRoot");)c++;if(s===T.length||c===V.length)for(s=T.length-1,c=V.length-1;1<=s&&0<=c&&T[s]!==V[c];)c--;for(;1<=s&&0<=c;s--,c--)if(T[s]!==V[c]){if(s!==1||c!==1)do if(s--,c--,0>c||T[s]!==V[c]){var I=`
|
||
`+T[s].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=s&&0<=c);break}}}finally{Ne=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?be(n):""}function sn(e,t){switch(e.tag){case 26:case 27:case 5:return be(e.type);case 16:return be("Lazy");case 13:return e.child!==t&&t!==null?be("Suspense Fallback"):be("Suspense");case 19:return be("SuspenseList");case 0:case 15:return ze(e.type,!1);case 11:return ze(e.type.render,!1);case 1:return ze(e.type,!0);case 31:return be("Activity");default:return""}}function wa(e){try{var t="",n=null;do t+=sn(e,n),n=e,e=e.return;while(e);return t}catch(s){return`
|
||
Error generating stack: `+s.message+`
|
||
`+s.stack}}var Wn=Object.prototype.hasOwnProperty,it=a.unstable_scheduleCallback,rn=a.unstable_cancelCallback,xo=a.unstable_shouldYield,go=a.unstable_requestPaint,mt=a.unstable_now,Pa=a.unstable_getCurrentPriorityLevel,el=a.unstable_ImmediatePriority,on=a.unstable_UserBlockingPriority,Ca=a.unstable_NormalPriority,bi=a.unstable_LowPriority,tl=a.unstable_IdlePriority,vo=a.log,ns=a.unstable_setDisableYieldValue,cn=null,pt=null;function Gt(e){if(typeof vo=="function"&&ns(e),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(cn,e)}catch{}}var rt=Math.clz32?Math.clz32:bo,yo=Math.log,nl=Math.LN2;function bo(e){return e>>>=0,e===0?32:31-(yo(e)/nl|0)|0}var Ea=256,Ke=262144,al=4194304;function _t(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Pn(e,t,n){var s=e.pendingLanes;if(s===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var S=s&134217727;return S!==0?(s=S&~u,s!==0?c=_t(s):(v&=S,v!==0?c=_t(v):n||(n=S&~e,n!==0&&(c=_t(n))))):(S=s&~u,S!==0?c=_t(S):v!==0?c=_t(v):n||(n=s&~e,n!==0&&(c=_t(n)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,n=t&-t,u>=n||u===32&&(n&4194048)!==0)?t:c}function xn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Si(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 Ai(){var e=al;return al<<=1,(al&62914560)===0&&(al=4194304),e}function as(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ka(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ji(e,t,n,s,c,u){var v=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var S=e.entanglements,T=e.expirationTimes,V=e.hiddenUpdates;for(n=v&~n;0<n;){var I=31-rt(n),ee=1<<I;S[I]=0,T[I]=-1;var G=V[I];if(G!==null)for(V[I]=null,I=0;I<G.length;I++){var Z=G[I];Z!==null&&(Z.lane&=-536870913)}n&=~ee}s!==0&&Xt(e,s,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function Xt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-rt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|n&261930}function ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var s=31-rt(n),c=1<<s;c&t|e[s]&t&&(e[s]|=t),n&=~c}}function Xe(e,t){var n=t&-t;return n=(n&42)!==0?1:Fe(n),(n&(e.suspendedLanes|t))!==0?0:n}function Fe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ce(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ue(){var e=F.p;return e!==0?e:(e=window.event,e===void 0?32:Y0(e.type))}function vt(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var Ct=Math.random().toString(36).slice(2),et="__reactFiber$"+Ct,_e="__reactProps$"+Ct,Ft="__reactContainer$"+Ct,So="__reactEvents$"+Ct,kg="__reactListeners$"+Ct,qg="__reactHandles$"+Ct,id="__reactResources$"+Ct,ls="__reactMarker$"+Ct;function Ao(e){delete e[et],delete e[_e],delete e[So],delete e[kg],delete e[qg]}function ll(e){var t=e[et];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ft]||n[et]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=E0(e);e!==null;){if(n=e[et])return n;e=E0(e)}return t}e=n,n=e.parentNode}return null}function sl(e){if(e=e[et]||e[Ft]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ss(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function il(e){var t=e[id];return t||(t=e[id]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function xt(e){e[ls]=!0}var rd=new Set,od={};function qa(e,t){rl(e,t),rl(e+"Capture",t)}function rl(e,t){for(od[e]=t,e=0;e<t.length;e++)rd.add(t[e])}var Mg=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]*$"),cd={},ud={};function Rg(e){return Wn.call(ud,e)?!0:Wn.call(cd,e)?!1:Mg.test(e)?ud[e]=!0:(cd[e]=!0,!1)}function Ni(e,t,n){if(Rg(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var s=t.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function wi(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function En(e,t,n,s){if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+s)}}function Qt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Tg(e,t,n){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var c=s.get,u=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(v){n=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return n},setValue:function(v){n=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function jo(e){if(!e._valueTracker){var t=fd(e)?"checked":"value";e._valueTracker=Tg(e,t,""+e[t])}}function dd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),s="";return e&&(s=fd(e)?e.checked?"true":"false":e.value),e=s,e!==n?(t.setValue(e),!0):!1}function Ci(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Dg=/[\n"\\]/g;function Kt(e){return e.replace(Dg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function No(e,t,n,s,c,u,v,S){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Qt(t)):e.value!==""+Qt(t)&&(e.value=""+Qt(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?wo(e,v,Qt(t)):n!=null?wo(e,v,Qt(n)):s!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.name=""+Qt(S):e.removeAttribute("name")}function md(e,t,n,s,c,u,v,S){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||n!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){jo(e);return}n=n!=null?""+Qt(n):"",t=t!=null?""+Qt(t):n,S||t===e.value||(e.value=t),e.defaultValue=t}s=s??c,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=S?e.checked:!!s,e.defaultChecked=!!s,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),jo(e)}function wo(e,t,n){t==="number"&&Ci(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function ol(e,t,n,s){if(e=e.options,t){t={};for(var c=0;c<n.length;c++)t["$"+n[c]]=!0;for(n=0;n<e.length;n++)c=t.hasOwnProperty("$"+e[n].value),e[n].selected!==c&&(e[n].selected=c),c&&s&&(e[n].defaultSelected=!0)}else{for(n=""+Qt(n),t=null,c=0;c<e.length;c++){if(e[c].value===n){e[c].selected=!0,s&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function hd(e,t,n){if(t!=null&&(t=""+Qt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Qt(n):""}function pd(e,t,n,s){if(t==null){if(s!=null){if(n!=null)throw Error(o(92));if($(s)){if(1<s.length)throw Error(o(93));s=s[0]}n=s}n==null&&(n=""),t=n}n=Qt(t),e.defaultValue=n,s=e.textContent,s===n&&s!==""&&s!==null&&(e.value=s),jo(e)}function cl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var _g=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 xd(e,t,n){var s=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,n):typeof n!="number"||n===0||_g.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function gd(e,t,n){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,n!=null){for(var s in n)!n.hasOwnProperty(s)||t!=null&&t.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var c in t)s=t[c],t.hasOwnProperty(c)&&n[c]!==s&&xd(e,c,s)}else for(var u in t)t.hasOwnProperty(u)&&xd(e,u,t[u])}function Co(e){if(e.indexOf("-")===-1)return!1;switch(e){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 Og=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"]]),Bg=/^[\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 Ei(e){return Bg.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function kn(){}var Eo=null;function ko(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ul=null,fl=null;function vd(e){var t=sl(e);if(t&&(e=t.stateNode)){var n=e[_e]||null;e:switch(e=t.stateNode,t.type){case"input":if(No(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Kt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var s=n[t];if(s!==e&&s.form===e.form){var c=s[_e]||null;if(!c)throw Error(o(90));No(s,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<n.length;t++)s=n[t],s.form===e.form&&dd(s)}break e;case"textarea":hd(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&ol(e,!!n.multiple,t,!1)}}}var qo=!1;function yd(e,t,n){if(qo)return e(t,n);qo=!0;try{var s=e(t);return s}finally{if(qo=!1,(ul!==null||fl!==null)&&(hr(),ul&&(t=ul,e=fl,fl=ul=null,vd(t),e)))for(t=0;t<e.length;t++)vd(e[t])}}function is(e,t){var n=e.stateNode;if(n===null)return null;var s=n[_e]||null;if(s===null)return null;n=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(o(231,t,typeof n));return n}var qn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mo=!1;if(qn)try{var rs={};Object.defineProperty(rs,"passive",{get:function(){Mo=!0}}),window.addEventListener("test",rs,rs),window.removeEventListener("test",rs,rs)}catch{Mo=!1}var ea=null,Ro=null,ki=null;function bd(){if(ki)return ki;var e,t=Ro,n=t.length,s,c="value"in ea?ea.value:ea.textContent,u=c.length;for(e=0;e<n&&t[e]===c[e];e++);var v=n-e;for(s=1;s<=v&&t[n-s]===c[u-s];s++);return ki=c.slice(e,1<s?1-s:void 0)}function qi(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Mi(){return!0}function Sd(){return!1}function Et(e){function t(n,s,c,u,v){this._reactName=n,this._targetInst=c,this.type=s,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var S in e)e.hasOwnProperty(S)&&(n=e[S],this[S]=n?n(u):u[S]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Mi:Sd,this.isPropagationStopped=Sd,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Mi)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Mi)},persist:function(){},isPersistent:Mi}),t}var Ma={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ri=Et(Ma),os=b({},Ma,{view:0,detail:0}),Lg=Et(os),To,Do,cs,Ti=b({},os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Oo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==cs&&(cs&&e.type==="mousemove"?(To=e.screenX-cs.screenX,Do=e.screenY-cs.screenY):Do=To=0,cs=e),To)},movementY:function(e){return"movementY"in e?e.movementY:Do}}),Ad=Et(Ti),zg=b({},Ti,{dataTransfer:0}),Ug=Et(zg),Hg=b({},os,{relatedTarget:0}),_o=Et(Hg),Vg=b({},Ma,{animationName:0,elapsedTime:0,pseudoElement:0}),$g=Et(Vg),Yg=b({},Ma,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Gg=Et(Yg),Xg=b({},Ma,{data:0}),jd=Et(Xg),Fg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qg={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"},Kg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Zg(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Kg[e])?!!t[e]:!1}function Oo(){return Zg}var Jg=b({},os,{key:function(e){if(e.key){var t=Fg[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Qg[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Oo,charCode:function(e){return e.type==="keypress"?qi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ig=Et(Jg),Wg=b({},Ti,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Nd=Et(Wg),Pg=b({},os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Oo}),ev=Et(Pg),tv=b({},Ma,{propertyName:0,elapsedTime:0,pseudoElement:0}),nv=Et(tv),av=b({},Ti,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),lv=Et(av),sv=b({},Ma,{newState:0,oldState:0}),iv=Et(sv),rv=[9,13,27,32],Bo=qn&&"CompositionEvent"in window,us=null;qn&&"documentMode"in document&&(us=document.documentMode);var ov=qn&&"TextEvent"in window&&!us,wd=qn&&(!Bo||us&&8<us&&11>=us),Cd=" ",Ed=!1;function kd(e,t){switch(e){case"keyup":return rv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var dl=!1;function cv(e,t){switch(e){case"compositionend":return qd(t);case"keypress":return t.which!==32?null:(Ed=!0,Cd);case"textInput":return e=t.data,e===Cd&&Ed?null:e;default:return null}}function uv(e,t){if(dl)return e==="compositionend"||!Bo&&kd(e,t)?(e=bd(),ki=Ro=ea=null,dl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return wd&&t.locale!=="ko"?null:t.data;default:return null}}var fv={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 Md(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!fv[e.type]:t==="textarea"}function Rd(e,t,n,s){ul?fl?fl.push(s):fl=[s]:ul=s,t=Sr(t,"onChange"),0<t.length&&(n=new Ri("onChange","change",null,n,s),e.push({event:n,listeners:t}))}var fs=null,ds=null;function dv(e){m0(e,0)}function Di(e){var t=ss(e);if(dd(t))return e}function Td(e,t){if(e==="change")return t}var Dd=!1;if(qn){var Lo;if(qn){var zo="oninput"in document;if(!zo){var _d=document.createElement("div");_d.setAttribute("oninput","return;"),zo=typeof _d.oninput=="function"}Lo=zo}else Lo=!1;Dd=Lo&&(!document.documentMode||9<document.documentMode)}function Od(){fs&&(fs.detachEvent("onpropertychange",Bd),ds=fs=null)}function Bd(e){if(e.propertyName==="value"&&Di(ds)){var t=[];Rd(t,ds,e,ko(e)),yd(dv,t)}}function mv(e,t,n){e==="focusin"?(Od(),fs=t,ds=n,fs.attachEvent("onpropertychange",Bd)):e==="focusout"&&Od()}function hv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Di(ds)}function pv(e,t){if(e==="click")return Di(t)}function xv(e,t){if(e==="input"||e==="change")return Di(t)}function gv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ot=typeof Object.is=="function"?Object.is:gv;function ms(e,t){if(Ot(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(s=0;s<n.length;s++){var c=n[s];if(!Wn.call(t,c)||!Ot(e[c],t[c]))return!1}return!0}function Ld(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function zd(e,t){var n=Ld(e);e=0;for(var s;n;){if(n.nodeType===3){if(s=e+n.textContent.length,e<=t&&s>=t)return{node:n,offset:t-e};e=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ld(n)}}function Ud(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ud(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Hd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ci(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ci(e.document)}return t}function Uo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var vv=qn&&"documentMode"in document&&11>=document.documentMode,ml=null,Ho=null,hs=null,Vo=!1;function Vd(e,t,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vo||ml==null||ml!==Ci(s)||(s=ml,"selectionStart"in s&&Uo(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),hs&&ms(hs,s)||(hs=s,s=Sr(Ho,"onSelect"),0<s.length&&(t=new Ri("onSelect","select",null,t,n),e.push({event:t,listeners:s}),t.target=ml)))}function Ra(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hl={animationend:Ra("Animation","AnimationEnd"),animationiteration:Ra("Animation","AnimationIteration"),animationstart:Ra("Animation","AnimationStart"),transitionrun:Ra("Transition","TransitionRun"),transitionstart:Ra("Transition","TransitionStart"),transitioncancel:Ra("Transition","TransitionCancel"),transitionend:Ra("Transition","TransitionEnd")},$o={},$d={};qn&&($d=document.createElement("div").style,"AnimationEvent"in window||(delete hl.animationend.animation,delete hl.animationiteration.animation,delete hl.animationstart.animation),"TransitionEvent"in window||delete hl.transitionend.transition);function Ta(e){if($o[e])return $o[e];if(!hl[e])return e;var t=hl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in $d)return $o[e]=t[n];return e}var Yd=Ta("animationend"),Gd=Ta("animationiteration"),Xd=Ta("animationstart"),yv=Ta("transitionrun"),bv=Ta("transitionstart"),Sv=Ta("transitioncancel"),Fd=Ta("transitionend"),Qd=new Map,Yo="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(" ");Yo.push("scrollEnd");function un(e,t){Qd.set(e,t),qa(t,[e])}var _i=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Zt=[],pl=0,Go=0;function Oi(){for(var e=pl,t=Go=pl=0;t<e;){var n=Zt[t];Zt[t++]=null;var s=Zt[t];Zt[t++]=null;var c=Zt[t];Zt[t++]=null;var u=Zt[t];if(Zt[t++]=null,s!==null&&c!==null){var v=s.pending;v===null?c.next=c:(c.next=v.next,v.next=c),s.pending=c}u!==0&&Kd(n,c,u)}}function Bi(e,t,n,s){Zt[pl++]=e,Zt[pl++]=t,Zt[pl++]=n,Zt[pl++]=s,Go|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Xo(e,t,n,s){return Bi(e,t,n,s),Li(e)}function Da(e,t){return Bi(e,null,null,t),Li(e)}function Kd(e,t,n){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n);for(var c=!1,u=e.return;u!==null;)u.childLanes|=n,s=u.alternate,s!==null&&(s.childLanes|=n),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-rt(n),e=u.hiddenUpdates,s=e[c],s===null?e[c]=[t]:s.push(t),t.lane=n|536870912),u):null}function Li(e){if(50<Bs)throw Bs=0,eu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var xl={};function Av(e,t,n,s){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bt(e,t,n,s){return new Av(e,t,n,s)}function Fo(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Mn(e,t){var n=e.alternate;return n===null?(n=Bt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Zd(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function zi(e,t,n,s,c,u){var v=0;if(s=e,typeof e=="function")Fo(e)&&(v=1);else if(typeof e=="string")v=Ey(e,n,le.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=Bt(31,n,t,c),e.elementType=z,e.lanes=u,e;case w:return _a(n.children,c,u,t);case j:v=8,c|=24;break;case k:return e=Bt(12,n,t,c|2),e.elementType=k,e.lanes=u,e;case L:return e=Bt(13,n,t,c),e.elementType=L,e.lanes=u,e;case Y:return e=Bt(19,n,t,c),e.elementType=Y,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case C:v=10;break e;case A:v=9;break e;case _:v=11;break e;case O:v=14;break e;case X:v=16,s=null;break e}v=29,n=Error(o(130,e===null?"null":typeof e,"")),s=null}return t=Bt(v,n,t,c),t.elementType=e,t.type=s,t.lanes=u,t}function _a(e,t,n,s){return e=Bt(7,e,s,t),e.lanes=n,e}function Qo(e,t,n){return e=Bt(6,e,null,t),e.lanes=n,e}function Jd(e){var t=Bt(18,null,null,0);return t.stateNode=e,t}function Ko(e,t,n){return t=Bt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Id=new WeakMap;function Jt(e,t){if(typeof e=="object"&&e!==null){var n=Id.get(e);return n!==void 0?n:(t={value:e,source:t,stack:wa(t)},Id.set(e,t),t)}return{value:e,source:t,stack:wa(t)}}var gl=[],vl=0,Ui=null,ps=0,It=[],Wt=0,ta=null,gn=1,vn="";function Rn(e,t){gl[vl++]=ps,gl[vl++]=Ui,Ui=e,ps=t}function Wd(e,t,n){It[Wt++]=gn,It[Wt++]=vn,It[Wt++]=ta,ta=e;var s=gn;e=vn;var c=32-rt(s)-1;s&=~(1<<c),n+=1;var u=32-rt(t)+c;if(30<u){var v=c-c%5;u=(s&(1<<v)-1).toString(32),s>>=v,c-=v,gn=1<<32-rt(t)+c|n<<c|s,vn=u+e}else gn=1<<u|n<<c|s,vn=e}function Zo(e){e.return!==null&&(Rn(e,1),Wd(e,1,0))}function Jo(e){for(;e===Ui;)Ui=gl[--vl],gl[vl]=null,ps=gl[--vl],gl[vl]=null;for(;e===ta;)ta=It[--Wt],It[Wt]=null,vn=It[--Wt],It[Wt]=null,gn=It[--Wt],It[Wt]=null}function Pd(e,t){It[Wt++]=gn,It[Wt++]=vn,It[Wt++]=ta,gn=t.id,vn=t.overflow,ta=e}var yt=null,Ze=null,Re=!1,na=null,Pt=!1,Io=Error(o(519));function aa(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw xs(Jt(t,e)),Io}function em(e){var t=e.stateNode,n=e.type,s=e.memoizedProps;switch(t[et]=e,t[_e]=s,n){case"dialog":ke("cancel",t),ke("close",t);break;case"iframe":case"object":case"embed":ke("load",t);break;case"video":case"audio":for(n=0;n<zs.length;n++)ke(zs[n],t);break;case"source":ke("error",t);break;case"img":case"image":case"link":ke("error",t),ke("load",t);break;case"details":ke("toggle",t);break;case"input":ke("invalid",t),md(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":ke("invalid",t);break;case"textarea":ke("invalid",t),pd(t,s.value,s.defaultValue,s.children)}n=s.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||s.suppressHydrationWarning===!0||g0(t.textContent,n)?(s.popover!=null&&(ke("beforetoggle",t),ke("toggle",t)),s.onScroll!=null&&ke("scroll",t),s.onScrollEnd!=null&&ke("scrollend",t),s.onClick!=null&&(t.onclick=kn),t=!0):t=!1,t||aa(e,!0)}function tm(e){for(yt=e.return;yt;)switch(yt.tag){case 5:case 31:case 13:Pt=!1;return;case 27:case 3:Pt=!0;return;default:yt=yt.return}}function yl(e){if(e!==yt)return!1;if(!Re)return tm(e),Re=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||pu(e.type,e.memoizedProps)),n=!n),n&&Ze&&aa(e),tm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));Ze=C0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));Ze=C0(e)}else t===27?(t=Ze,ga(e.type)?(e=bu,bu=null,Ze=e):Ze=t):Ze=yt?tn(e.stateNode.nextSibling):null;return!0}function Oa(){Ze=yt=null,Re=!1}function Wo(){var e=na;return e!==null&&(Rt===null?Rt=e:Rt.push.apply(Rt,e),na=null),e}function xs(e){na===null?na=[e]:na.push(e)}var Po=q(null),Ba=null,Tn=null;function la(e,t,n){ne(Po,t._currentValue),t._currentValue=n}function Dn(e){e._currentValue=Po.current,H(Po)}function ec(e,t,n){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===n)break;e=e.return}}function tc(e,t,n,s){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var v=c.child;u=u.firstContext;e:for(;u!==null;){var S=u;u=c;for(var T=0;T<t.length;T++)if(S.context===t[T]){u.lanes|=n,S=u.alternate,S!==null&&(S.lanes|=n),ec(u.return,n,e),s||(v=null);break e}u=S.next}}else if(c.tag===18){if(v=c.return,v===null)throw Error(o(341));v.lanes|=n,u=v.alternate,u!==null&&(u.lanes|=n),ec(v,n,e),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===e){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function bl(e,t,n,s){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var S=c.type;Ot(c.pendingProps.value,v.value)||(e!==null?e.push(S):e=[S])}}else if(c===ue.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Ys):e=[Ys])}c=c.return}e!==null&&tc(t,e,n,s),t.flags|=262144}function Hi(e){for(e=e.firstContext;e!==null;){if(!Ot(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function La(e){Ba=e,Tn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function bt(e){return nm(Ba,e)}function Vi(e,t){return Ba===null&&La(e),nm(e,t)}function nm(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Tn===null){if(e===null)throw Error(o(308));Tn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Tn=Tn.next=t;return n}var jv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},Nv=a.unstable_scheduleCallback,wv=a.unstable_NormalPriority,ot={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function nc(){return{controller:new jv,data:new Map,refCount:0}}function gs(e){e.refCount--,e.refCount===0&&Nv(wv,function(){e.controller.abort()})}var vs=null,ac=0,Sl=0,Al=null;function Cv(e,t){if(vs===null){var n=vs=[];ac=0,Sl=iu(),Al={status:"pending",value:void 0,then:function(s){n.push(s)}}}return ac++,t.then(am,am),t}function am(){if(--ac===0&&vs!==null){Al!==null&&(Al.status="fulfilled");var e=vs;vs=null,Sl=0,Al=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ev(e,t){var n=[],s={status:"pending",value:null,reason:null,then:function(c){n.push(c)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var c=0;c<n.length;c++)(0,n[c])(t)},function(c){for(s.status="rejected",s.reason=c,c=0;c<n.length;c++)(0,n[c])(void 0)}),s}var lm=R.S;R.S=function(e,t){Vh=mt(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Cv(e,t),lm!==null&&lm(e,t)};var za=q(null);function lc(){var e=za.current;return e!==null?e:Qe.pooledCache}function $i(e,t){t===null?ne(za,za.current):ne(za,t.pool)}function sm(){var e=lc();return e===null?null:{parent:ot._currentValue,pool:e}}var jl=Error(o(460)),sc=Error(o(474)),Yi=Error(o(542)),Gi={then:function(){}};function im(e){return e=e.status,e==="fulfilled"||e==="rejected"}function rm(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(kn,kn),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,cm(e),e;default:if(typeof t.status=="string")t.then(kn,kn);else{if(e=Qe,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(s){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=s}},function(s){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=s}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,cm(e),e}throw Ha=t,jl}}function Ua(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Ha=n,jl):n}}var Ha=null;function om(){if(Ha===null)throw Error(o(459));var e=Ha;return Ha=null,e}function cm(e){if(e===jl||e===Yi)throw Error(o(483))}var Nl=null,ys=0;function Xi(e){var t=ys;return ys+=1,Nl===null&&(Nl=[]),rm(Nl,e,t)}function bs(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Fi(e,t){throw t.$$typeof===N?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function um(e){function t(B,D){if(e){var U=B.deletions;U===null?(B.deletions=[D],B.flags|=16):U.push(D)}}function n(B,D){if(!e)return null;for(;D!==null;)t(B,D),D=D.sibling;return null}function s(B){for(var D=new Map;B!==null;)B.key!==null?D.set(B.key,B):D.set(B.index,B),B=B.sibling;return D}function c(B,D){return B=Mn(B,D),B.index=0,B.sibling=null,B}function u(B,D,U){return B.index=U,e?(U=B.alternate,U!==null?(U=U.index,U<D?(B.flags|=67108866,D):U):(B.flags|=67108866,D)):(B.flags|=1048576,D)}function v(B){return e&&B.alternate===null&&(B.flags|=67108866),B}function S(B,D,U,W){return D===null||D.tag!==6?(D=Qo(U,B.mode,W),D.return=B,D):(D=c(D,U),D.return=B,D)}function T(B,D,U,W){var xe=U.type;return xe===w?I(B,D,U.props.children,W,U.key):D!==null&&(D.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===X&&Ua(xe)===D.type)?(D=c(D,U.props),bs(D,U),D.return=B,D):(D=zi(U.type,U.key,U.props,null,B.mode,W),bs(D,U),D.return=B,D)}function V(B,D,U,W){return D===null||D.tag!==4||D.stateNode.containerInfo!==U.containerInfo||D.stateNode.implementation!==U.implementation?(D=Ko(U,B.mode,W),D.return=B,D):(D=c(D,U.children||[]),D.return=B,D)}function I(B,D,U,W,xe){return D===null||D.tag!==7?(D=_a(U,B.mode,W,xe),D.return=B,D):(D=c(D,U),D.return=B,D)}function ee(B,D,U){if(typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint")return D=Qo(""+D,B.mode,U),D.return=B,D;if(typeof D=="object"&&D!==null){switch(D.$$typeof){case M:return U=zi(D.type,D.key,D.props,null,B.mode,U),bs(U,D),U.return=B,U;case E:return D=Ko(D,B.mode,U),D.return=B,D;case X:return D=Ua(D),ee(B,D,U)}if($(D)||ae(D))return D=_a(D,B.mode,U,null),D.return=B,D;if(typeof D.then=="function")return ee(B,Xi(D),U);if(D.$$typeof===C)return ee(B,Vi(B,D),U);Fi(B,D)}return null}function G(B,D,U,W){var xe=D!==null?D.key:null;if(typeof U=="string"&&U!==""||typeof U=="number"||typeof U=="bigint")return xe!==null?null:S(B,D,""+U,W);if(typeof U=="object"&&U!==null){switch(U.$$typeof){case M:return U.key===xe?T(B,D,U,W):null;case E:return U.key===xe?V(B,D,U,W):null;case X:return U=Ua(U),G(B,D,U,W)}if($(U)||ae(U))return xe!==null?null:I(B,D,U,W,null);if(typeof U.then=="function")return G(B,D,Xi(U),W);if(U.$$typeof===C)return G(B,D,Vi(B,U),W);Fi(B,U)}return null}function Z(B,D,U,W,xe){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return B=B.get(U)||null,S(D,B,""+W,xe);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case M:return B=B.get(W.key===null?U:W.key)||null,T(D,B,W,xe);case E:return B=B.get(W.key===null?U:W.key)||null,V(D,B,W,xe);case X:return W=Ua(W),Z(B,D,U,W,xe)}if($(W)||ae(W))return B=B.get(U)||null,I(D,B,W,xe,null);if(typeof W.then=="function")return Z(B,D,U,Xi(W),xe);if(W.$$typeof===C)return Z(B,D,U,Vi(D,W),xe);Fi(D,W)}return null}function de(B,D,U,W){for(var xe=null,Oe=null,he=D,je=D=0,Me=null;he!==null&&je<U.length;je++){he.index>je?(Me=he,he=null):Me=he.sibling;var Be=G(B,he,U[je],W);if(Be===null){he===null&&(he=Me);break}e&&he&&Be.alternate===null&&t(B,he),D=u(Be,D,je),Oe===null?xe=Be:Oe.sibling=Be,Oe=Be,he=Me}if(je===U.length)return n(B,he),Re&&Rn(B,je),xe;if(he===null){for(;je<U.length;je++)he=ee(B,U[je],W),he!==null&&(D=u(he,D,je),Oe===null?xe=he:Oe.sibling=he,Oe=he);return Re&&Rn(B,je),xe}for(he=s(he);je<U.length;je++)Me=Z(he,B,je,U[je],W),Me!==null&&(e&&Me.alternate!==null&&he.delete(Me.key===null?je:Me.key),D=u(Me,D,je),Oe===null?xe=Me:Oe.sibling=Me,Oe=Me);return e&&he.forEach(function(Aa){return t(B,Aa)}),Re&&Rn(B,je),xe}function ye(B,D,U,W){if(U==null)throw Error(o(151));for(var xe=null,Oe=null,he=D,je=D=0,Me=null,Be=U.next();he!==null&&!Be.done;je++,Be=U.next()){he.index>je?(Me=he,he=null):Me=he.sibling;var Aa=G(B,he,Be.value,W);if(Aa===null){he===null&&(he=Me);break}e&&he&&Aa.alternate===null&&t(B,he),D=u(Aa,D,je),Oe===null?xe=Aa:Oe.sibling=Aa,Oe=Aa,he=Me}if(Be.done)return n(B,he),Re&&Rn(B,je),xe;if(he===null){for(;!Be.done;je++,Be=U.next())Be=ee(B,Be.value,W),Be!==null&&(D=u(Be,D,je),Oe===null?xe=Be:Oe.sibling=Be,Oe=Be);return Re&&Rn(B,je),xe}for(he=s(he);!Be.done;je++,Be=U.next())Be=Z(he,B,je,Be.value,W),Be!==null&&(e&&Be.alternate!==null&&he.delete(Be.key===null?je:Be.key),D=u(Be,D,je),Oe===null?xe=Be:Oe.sibling=Be,Oe=Be);return e&&he.forEach(function(zy){return t(B,zy)}),Re&&Rn(B,je),xe}function Ge(B,D,U,W){if(typeof U=="object"&&U!==null&&U.type===w&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case M:e:{for(var xe=U.key;D!==null;){if(D.key===xe){if(xe=U.type,xe===w){if(D.tag===7){n(B,D.sibling),W=c(D,U.props.children),W.return=B,B=W;break e}}else if(D.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===X&&Ua(xe)===D.type){n(B,D.sibling),W=c(D,U.props),bs(W,U),W.return=B,B=W;break e}n(B,D);break}else t(B,D);D=D.sibling}U.type===w?(W=_a(U.props.children,B.mode,W,U.key),W.return=B,B=W):(W=zi(U.type,U.key,U.props,null,B.mode,W),bs(W,U),W.return=B,B=W)}return v(B);case E:e:{for(xe=U.key;D!==null;){if(D.key===xe)if(D.tag===4&&D.stateNode.containerInfo===U.containerInfo&&D.stateNode.implementation===U.implementation){n(B,D.sibling),W=c(D,U.children||[]),W.return=B,B=W;break e}else{n(B,D);break}else t(B,D);D=D.sibling}W=Ko(U,B.mode,W),W.return=B,B=W}return v(B);case X:return U=Ua(U),Ge(B,D,U,W)}if($(U))return de(B,D,U,W);if(ae(U)){if(xe=ae(U),typeof xe!="function")throw Error(o(150));return U=xe.call(U),ye(B,D,U,W)}if(typeof U.then=="function")return Ge(B,D,Xi(U),W);if(U.$$typeof===C)return Ge(B,D,Vi(B,U),W);Fi(B,U)}return typeof U=="string"&&U!==""||typeof U=="number"||typeof U=="bigint"?(U=""+U,D!==null&&D.tag===6?(n(B,D.sibling),W=c(D,U),W.return=B,B=W):(n(B,D),W=Qo(U,B.mode,W),W.return=B,B=W),v(B)):n(B,D)}return function(B,D,U,W){try{ys=0;var xe=Ge(B,D,U,W);return Nl=null,xe}catch(he){if(he===jl||he===Yi)throw he;var Oe=Bt(29,he,null,B.mode);return Oe.lanes=W,Oe.return=B,Oe}finally{}}}var Va=um(!0),fm=um(!1),sa=!1;function ic(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ia(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ra(e,t,n){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Le&2)!==0){var c=s.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),s.pending=t,t=Li(e),Kd(e,null,n),t}return Bi(e,s,t,n),Li(e)}function Ss(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,ge(e,n)}}function oc(e,t){var n=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var c=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var v={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,n=n.next}while(n!==null);u===null?c=u=t:u=u.next=t}else c=u=t;n={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:s.shared,callbacks:s.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var cc=!1;function As(){if(cc){var e=Al;if(e!==null)throw e}}function js(e,t,n,s){cc=!1;var c=e.updateQueue;sa=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,S=c.shared.pending;if(S!==null){c.shared.pending=null;var T=S,V=T.next;T.next=null,v===null?u=V:v.next=V,v=T;var I=e.alternate;I!==null&&(I=I.updateQueue,S=I.lastBaseUpdate,S!==v&&(S===null?I.firstBaseUpdate=V:S.next=V,I.lastBaseUpdate=T))}if(u!==null){var ee=c.baseState;v=0,I=V=T=null,S=u;do{var G=S.lane&-536870913,Z=G!==S.lane;if(Z?(qe&G)===G:(s&G)===G){G!==0&&G===Sl&&(cc=!0),I!==null&&(I=I.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var de=e,ye=S;G=t;var Ge=n;switch(ye.tag){case 1:if(de=ye.payload,typeof de=="function"){ee=de.call(Ge,ee,G);break e}ee=de;break e;case 3:de.flags=de.flags&-65537|128;case 0:if(de=ye.payload,G=typeof de=="function"?de.call(Ge,ee,G):de,G==null)break e;ee=b({},ee,G);break e;case 2:sa=!0}}G=S.callback,G!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[G]:Z.push(G))}else Z={lane:G,tag:S.tag,payload:S.payload,callback:S.callback,next:null},I===null?(V=I=Z,T=ee):I=I.next=Z,v|=G;if(S=S.next,S===null){if(S=c.shared.pending,S===null)break;Z=S,S=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);I===null&&(T=ee),c.baseState=T,c.firstBaseUpdate=V,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),da|=v,e.lanes=v,e.memoizedState=ee}}function dm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function mm(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)dm(n[e],t)}var wl=q(null),Qi=q(0);function hm(e,t){e=$n,ne(Qi,e),ne(wl,t),$n=e|t.baseLanes}function uc(){ne(Qi,$n),ne(wl,wl.current)}function fc(){$n=Qi.current,H(wl),H(Qi)}var Lt=q(null),en=null;function oa(e){var t=e.alternate;ne(at,at.current&1),ne(Lt,e),en===null&&(t===null||wl.current!==null||t.memoizedState!==null)&&(en=e)}function dc(e){ne(at,at.current),ne(Lt,e),en===null&&(en=e)}function pm(e){e.tag===22?(ne(at,at.current),ne(Lt,e),en===null&&(en=e)):ca()}function ca(){ne(at,at.current),ne(Lt,Lt.current)}function zt(e){H(Lt),en===e&&(en=null),H(at)}var at=q(0);function Ki(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||vu(n)||yu(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var _n=0,Ae=null,$e=null,ct=null,Zi=!1,Cl=!1,$a=!1,Ji=0,Ns=0,El=null,kv=0;function tt(){throw Error(o(321))}function mc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ot(e[n],t[n]))return!1;return!0}function hc(e,t,n,s,c,u){return _n=u,Ae=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=e===null||e.memoizedState===null?Wm:qc,$a=!1,u=n(s,c),$a=!1,Cl&&(u=gm(t,n,s,c)),xm(e),u}function xm(e){R.H=Es;var t=$e!==null&&$e.next!==null;if(_n=0,ct=$e=Ae=null,Zi=!1,Ns=0,El=null,t)throw Error(o(300));e===null||ut||(e=e.dependencies,e!==null&&Hi(e)&&(ut=!0))}function gm(e,t,n,s){Ae=e;var c=0;do{if(Cl&&(El=null),Ns=0,Cl=!1,25<=c)throw Error(o(301));if(c+=1,ct=$e=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}R.H=Pm,u=t(n,s)}while(Cl);return u}function qv(){var e=R.H,t=e.useState()[0];return t=typeof t.then=="function"?ws(t):t,e=e.useState()[0],($e!==null?$e.memoizedState:null)!==e&&(Ae.flags|=1024),t}function pc(){var e=Ji!==0;return Ji=0,e}function xc(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function gc(e){if(Zi){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Zi=!1}_n=0,ct=$e=Ae=null,Cl=!1,Ns=Ji=0,El=null}function wt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ct===null?Ae.memoizedState=ct=e:ct=ct.next=e,ct}function lt(){if($e===null){var e=Ae.alternate;e=e!==null?e.memoizedState:null}else e=$e.next;var t=ct===null?Ae.memoizedState:ct.next;if(t!==null)ct=t,$e=e;else{if(e===null)throw Ae.alternate===null?Error(o(467)):Error(o(310));$e=e,e={memoizedState:$e.memoizedState,baseState:$e.baseState,baseQueue:$e.baseQueue,queue:$e.queue,next:null},ct===null?Ae.memoizedState=ct=e:ct=ct.next=e}return ct}function Ii(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ws(e){var t=Ns;return Ns+=1,El===null&&(El=[]),e=rm(El,e,t),t=Ae,(ct===null?t.memoizedState:ct.next)===null&&(t=t.alternate,R.H=t===null||t.memoizedState===null?Wm:qc),e}function Wi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ws(e);if(e.$$typeof===C)return bt(e)}throw Error(o(438,String(e)))}function vc(e){var t=null,n=Ae.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var s=Ae.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(t={data:s.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Ii(),Ae.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),s=0;s<e;s++)n[s]=Q;return t.index++,n}function On(e,t){return typeof t=="function"?t(e):t}function Pi(e){var t=lt();return yc(t,$e,e)}function yc(e,t,n){var s=e.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=n;var c=e.baseQueue,u=s.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,s.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var S=v=null,T=null,V=t,I=!1;do{var ee=V.lane&-536870913;if(ee!==V.lane?(qe&ee)===ee:(_n&ee)===ee){var G=V.revertLane;if(G===0)T!==null&&(T=T.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ee===Sl&&(I=!0);else if((_n&G)===G){V=V.next,G===Sl&&(I=!0);continue}else ee={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},T===null?(S=T=ee,v=u):T=T.next=ee,Ae.lanes|=G,da|=G;ee=V.action,$a&&n(u,ee),u=V.hasEagerState?V.eagerState:n(u,ee)}else G={lane:ee,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},T===null?(S=T=G,v=u):T=T.next=G,Ae.lanes|=ee,da|=ee;V=V.next}while(V!==null&&V!==t);if(T===null?v=u:T.next=S,!Ot(u,e.memoizedState)&&(ut=!0,I&&(n=Al,n!==null)))throw n;e.memoizedState=u,e.baseState=v,e.baseQueue=T,s.lastRenderedState=u}return c===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function bc(e){var t=lt(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var s=n.dispatch,c=n.pending,u=t.memoizedState;if(c!==null){n.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Ot(u,t.memoizedState)||(ut=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),n.lastRenderedState=u}return[u,s]}function vm(e,t,n){var s=Ae,c=lt(),u=Re;if(u){if(n===void 0)throw Error(o(407));n=n()}else n=t();var v=!Ot(($e||c).memoizedState,n);if(v&&(c.memoizedState=n,ut=!0),c=c.queue,jc(Sm.bind(null,s,c,e),[e]),c.getSnapshot!==t||v||ct!==null&&ct.memoizedState.tag&1){if(s.flags|=2048,kl(9,{destroy:void 0},bm.bind(null,s,c,n,t),null),Qe===null)throw Error(o(349));u||(_n&127)!==0||ym(s,t,n)}return n}function ym(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ae.updateQueue,t===null?(t=Ii(),Ae.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function bm(e,t,n,s){t.value=n,t.getSnapshot=s,Am(t)&&jm(e)}function Sm(e,t,n){return n(function(){Am(t)&&jm(e)})}function Am(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ot(e,n)}catch{return!0}}function jm(e){var t=Da(e,2);t!==null&&Tt(t,e,2)}function Sc(e){var t=wt();if(typeof e=="function"){var n=e;if(e=n(),$a){Gt(!0);try{n()}finally{Gt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:On,lastRenderedState:e},t}function Nm(e,t,n,s){return e.baseState=n,yc(e,$e,typeof s=="function"?s:On)}function Mv(e,t,n,s,c){if(nr(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){u.listeners.push(v)}};R.T!==null?n(!0):u.isTransition=!1,s(u),n=t.pending,n===null?(u.next=t.pending=u,wm(t,u)):(u.next=n.next,t.pending=n.next=u)}}function wm(e,t){var n=t.action,s=t.payload,c=e.state;if(t.isTransition){var u=R.T,v={};R.T=v;try{var S=n(c,s),T=R.S;T!==null&&T(v,S),Cm(e,t,S)}catch(V){Ac(e,t,V)}finally{u!==null&&v.types!==null&&(u.types=v.types),R.T=u}}else try{u=n(c,s),Cm(e,t,u)}catch(V){Ac(e,t,V)}}function Cm(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(s){Em(e,t,s)},function(s){return Ac(e,t,s)}):Em(e,t,n)}function Em(e,t,n){t.status="fulfilled",t.value=n,km(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,wm(e,n)))}function Ac(e,t,n){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=n,km(t),t=t.next;while(t!==s)}e.action=null}function km(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function qm(e,t){return t}function Mm(e,t){if(Re){var n=Qe.formState;if(n!==null){e:{var s=Ae;if(Re){if(Ze){t:{for(var c=Ze,u=Pt;c.nodeType!==8;){if(!u){c=null;break t}if(c=tn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){Ze=tn(c.nextSibling),s=c.data==="F!";break e}}aa(s)}s=!1}s&&(t=n[0])}}return n=wt(),n.memoizedState=n.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qm,lastRenderedState:t},n.queue=s,n=Zm.bind(null,Ae,s),s.dispatch=n,s=Sc(!1),u=kc.bind(null,Ae,!1,s.queue),s=wt(),c={state:t,dispatch:null,action:e,pending:null},s.queue=c,n=Mv.bind(null,Ae,c,u,n),c.dispatch=n,s.memoizedState=e,[t,n,!1]}function Rm(e){var t=lt();return Tm(t,$e,e)}function Tm(e,t,n){if(t=yc(e,t,qm)[0],e=Pi(On)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=ws(t)}catch(v){throw v===jl?Yi:v}else s=t;t=lt();var c=t.queue,u=c.dispatch;return n!==t.memoizedState&&(Ae.flags|=2048,kl(9,{destroy:void 0},Rv.bind(null,c,n),null)),[s,u,e]}function Rv(e,t){e.action=t}function Dm(e){var t=lt(),n=$e;if(n!==null)return Tm(t,n,e);lt(),t=t.memoizedState,n=lt();var s=n.queue.dispatch;return n.memoizedState=e,[t,s,!1]}function kl(e,t,n,s){return e={tag:e,create:n,deps:s,inst:t,next:null},t=Ae.updateQueue,t===null&&(t=Ii(),Ae.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(s=n.next,n.next=e,e.next=s,t.lastEffect=e),e}function _m(){return lt().memoizedState}function er(e,t,n,s){var c=wt();Ae.flags|=e,c.memoizedState=kl(1|t,{destroy:void 0},n,s===void 0?null:s)}function tr(e,t,n,s){var c=lt();s=s===void 0?null:s;var u=c.memoizedState.inst;$e!==null&&s!==null&&mc(s,$e.memoizedState.deps)?c.memoizedState=kl(t,u,n,s):(Ae.flags|=e,c.memoizedState=kl(1|t,u,n,s))}function Om(e,t){er(8390656,8,e,t)}function jc(e,t){tr(2048,8,e,t)}function Tv(e){Ae.flags|=4;var t=Ae.updateQueue;if(t===null)t=Ii(),Ae.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Bm(e){var t=lt().memoizedState;return Tv({ref:t,nextImpl:e}),function(){if((Le&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Lm(e,t){return tr(4,2,e,t)}function zm(e,t){return tr(4,4,e,t)}function Um(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Hm(e,t,n){n=n!=null?n.concat([e]):null,tr(4,4,Um.bind(null,t,e),n)}function Nc(){}function Vm(e,t){var n=lt();t=t===void 0?null:t;var s=n.memoizedState;return t!==null&&mc(t,s[1])?s[0]:(n.memoizedState=[e,t],e)}function $m(e,t){var n=lt();t=t===void 0?null:t;var s=n.memoizedState;if(t!==null&&mc(t,s[1]))return s[0];if(s=e(),$a){Gt(!0);try{e()}finally{Gt(!1)}}return n.memoizedState=[s,t],s}function wc(e,t,n){return n===void 0||(_n&1073741824)!==0&&(qe&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Yh(),Ae.lanes|=e,da|=e,n)}function Ym(e,t,n,s){return Ot(n,t)?n:wl.current!==null?(e=wc(e,n,s),Ot(e,t)||(ut=!0),e):(_n&42)===0||(_n&1073741824)!==0&&(qe&261930)===0?(ut=!0,e.memoizedState=n):(e=Yh(),Ae.lanes|=e,da|=e,t)}function Gm(e,t,n,s,c){var u=F.p;F.p=u!==0&&8>u?u:8;var v=R.T,S={};R.T=S,kc(e,!1,t,n);try{var T=c(),V=R.S;if(V!==null&&V(S,T),T!==null&&typeof T=="object"&&typeof T.then=="function"){var I=Ev(T,s);Cs(e,t,I,Vt(e))}else Cs(e,t,s,Vt(e))}catch(ee){Cs(e,t,{then:function(){},status:"rejected",reason:ee},Vt())}finally{F.p=u,v!==null&&S.types!==null&&(v.types=S.types),R.T=v}}function Dv(){}function Cc(e,t,n,s){if(e.tag!==5)throw Error(o(476));var c=Xm(e).queue;Gm(e,c,t,P,n===null?Dv:function(){return Fm(e),n(s)})}function Xm(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:On,lastRenderedState:P},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:On,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Fm(e){var t=Xm(e);t.next===null&&(t=e.alternate.memoizedState),Cs(e,t.next.queue,{},Vt())}function Ec(){return bt(Ys)}function Qm(){return lt().memoizedState}function Km(){return lt().memoizedState}function _v(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Vt();e=ia(n);var s=ra(t,e,n);s!==null&&(Tt(s,t,n),Ss(s,t,n)),t={cache:nc()},e.payload=t;return}t=t.return}}function Ov(e,t,n){var s=Vt();n={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},nr(e)?Jm(t,n):(n=Xo(e,t,n,s),n!==null&&(Tt(n,e,s),Im(n,t,s)))}function Zm(e,t,n){var s=Vt();Cs(e,t,n,s)}function Cs(e,t,n,s){var c={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(nr(e))Jm(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var v=t.lastRenderedState,S=u(v,n);if(c.hasEagerState=!0,c.eagerState=S,Ot(S,v))return Bi(e,t,c,0),Qe===null&&Oi(),!1}catch{}finally{}if(n=Xo(e,t,c,s),n!==null)return Tt(n,e,s),Im(n,t,s),!0}return!1}function kc(e,t,n,s){if(s={lane:2,revertLane:iu(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},nr(e)){if(t)throw Error(o(479))}else t=Xo(e,n,s,2),t!==null&&Tt(t,e,2)}function nr(e){var t=e.alternate;return e===Ae||t!==null&&t===Ae}function Jm(e,t){Cl=Zi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Im(e,t,n){if((n&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,ge(e,n)}}var Es={readContext:bt,use:Wi,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useLayoutEffect:tt,useInsertionEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useSyncExternalStore:tt,useId:tt,useHostTransitionStatus:tt,useFormState:tt,useActionState:tt,useOptimistic:tt,useMemoCache:tt,useCacheRefresh:tt};Es.useEffectEvent=tt;var Wm={readContext:bt,use:Wi,useCallback:function(e,t){return wt().memoizedState=[e,t===void 0?null:t],e},useContext:bt,useEffect:Om,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,er(4194308,4,Um.bind(null,t,e),n)},useLayoutEffect:function(e,t){return er(4194308,4,e,t)},useInsertionEffect:function(e,t){er(4,2,e,t)},useMemo:function(e,t){var n=wt();t=t===void 0?null:t;var s=e();if($a){Gt(!0);try{e()}finally{Gt(!1)}}return n.memoizedState=[s,t],s},useReducer:function(e,t,n){var s=wt();if(n!==void 0){var c=n(t);if($a){Gt(!0);try{n(t)}finally{Gt(!1)}}}else c=t;return s.memoizedState=s.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},s.queue=e,e=e.dispatch=Ov.bind(null,Ae,e),[s.memoizedState,e]},useRef:function(e){var t=wt();return e={current:e},t.memoizedState=e},useState:function(e){e=Sc(e);var t=e.queue,n=Zm.bind(null,Ae,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Nc,useDeferredValue:function(e,t){var n=wt();return wc(n,e,t)},useTransition:function(){var e=Sc(!1);return e=Gm.bind(null,Ae,e.queue,!0,!1),wt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var s=Ae,c=wt();if(Re){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Qe===null)throw Error(o(349));(qe&127)!==0||ym(s,t,n)}c.memoizedState=n;var u={value:n,getSnapshot:t};return c.queue=u,Om(Sm.bind(null,s,u,e),[e]),s.flags|=2048,kl(9,{destroy:void 0},bm.bind(null,s,u,n,t),null),n},useId:function(){var e=wt(),t=Qe.identifierPrefix;if(Re){var n=vn,s=gn;n=(s&~(1<<32-rt(s)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Ji++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=kv++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Ec,useFormState:Mm,useActionState:Mm,useOptimistic:function(e){var t=wt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=kc.bind(null,Ae,!0,n),n.dispatch=t,[e,t]},useMemoCache:vc,useCacheRefresh:function(){return wt().memoizedState=_v.bind(null,Ae)},useEffectEvent:function(e){var t=wt(),n={impl:e};return t.memoizedState=n,function(){if((Le&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},qc={readContext:bt,use:Wi,useCallback:Vm,useContext:bt,useEffect:jc,useImperativeHandle:Hm,useInsertionEffect:Lm,useLayoutEffect:zm,useMemo:$m,useReducer:Pi,useRef:_m,useState:function(){return Pi(On)},useDebugValue:Nc,useDeferredValue:function(e,t){var n=lt();return Ym(n,$e.memoizedState,e,t)},useTransition:function(){var e=Pi(On)[0],t=lt().memoizedState;return[typeof e=="boolean"?e:ws(e),t]},useSyncExternalStore:vm,useId:Qm,useHostTransitionStatus:Ec,useFormState:Rm,useActionState:Rm,useOptimistic:function(e,t){var n=lt();return Nm(n,$e,e,t)},useMemoCache:vc,useCacheRefresh:Km};qc.useEffectEvent=Bm;var Pm={readContext:bt,use:Wi,useCallback:Vm,useContext:bt,useEffect:jc,useImperativeHandle:Hm,useInsertionEffect:Lm,useLayoutEffect:zm,useMemo:$m,useReducer:bc,useRef:_m,useState:function(){return bc(On)},useDebugValue:Nc,useDeferredValue:function(e,t){var n=lt();return $e===null?wc(n,e,t):Ym(n,$e.memoizedState,e,t)},useTransition:function(){var e=bc(On)[0],t=lt().memoizedState;return[typeof e=="boolean"?e:ws(e),t]},useSyncExternalStore:vm,useId:Qm,useHostTransitionStatus:Ec,useFormState:Dm,useActionState:Dm,useOptimistic:function(e,t){var n=lt();return $e!==null?Nm(n,$e,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:vc,useCacheRefresh:Km};Pm.useEffectEvent=Bm;function Mc(e,t,n,s){t=e.memoizedState,n=n(s,t),n=n==null?t:b({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Rc={enqueueSetState:function(e,t,n){e=e._reactInternals;var s=Vt(),c=ia(s);c.payload=t,n!=null&&(c.callback=n),t=ra(e,c,s),t!==null&&(Tt(t,e,s),Ss(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var s=Vt(),c=ia(s);c.tag=1,c.payload=t,n!=null&&(c.callback=n),t=ra(e,c,s),t!==null&&(Tt(t,e,s),Ss(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Vt(),s=ia(n);s.tag=2,t!=null&&(s.callback=t),t=ra(e,s,n),t!==null&&(Tt(t,e,n),Ss(t,e,n))}};function eh(e,t,n,s,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,u,v):t.prototype&&t.prototype.isPureReactComponent?!ms(n,s)||!ms(c,u):!0}function th(e,t,n,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,s),t.state!==e&&Rc.enqueueReplaceState(t,t.state,null)}function Ya(e,t){var n=t;if("ref"in t){n={};for(var s in t)s!=="ref"&&(n[s]=t[s])}if(e=e.defaultProps){n===t&&(n=b({},n));for(var c in e)n[c]===void 0&&(n[c]=e[c])}return n}function nh(e){_i(e)}function ah(e){console.error(e)}function lh(e){_i(e)}function ar(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function sh(e,t,n){try{var s=e.onCaughtError;s(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Tc(e,t,n){return n=ia(n),n.tag=3,n.payload={element:null},n.callback=function(){ar(e,t)},n}function ih(e){return e=ia(e),e.tag=3,e}function rh(e,t,n,s){var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var u=s.value;e.payload=function(){return c(u)},e.callback=function(){sh(t,n,s)}}var v=n.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){sh(t,n,s),typeof c!="function"&&(ma===null?ma=new Set([this]):ma.add(this));var S=s.stack;this.componentDidCatch(s.value,{componentStack:S!==null?S:""})})}function Bv(e,t,n,s,c){if(n.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=n.alternate,t!==null&&bl(t,n,c,!0),n=Lt.current,n!==null){switch(n.tag){case 31:case 13:return en===null?pr():n.alternate===null&&nt===0&&(nt=3),n.flags&=-257,n.flags|=65536,n.lanes=c,s===Gi?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([s]):t.add(s),au(e,s,c)),!1;case 22:return n.flags|=65536,s===Gi?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([s]):n.add(s)),au(e,s,c)),!1}throw Error(o(435,n.tag))}return au(e,s,c),pr(),!1}if(Re)return t=Lt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,s!==Io&&(e=Error(o(422),{cause:s}),xs(Jt(e,n)))):(s!==Io&&(t=Error(o(423),{cause:s}),xs(Jt(t,n))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,s=Jt(s,n),c=Tc(e.stateNode,s,c),oc(e,c),nt!==4&&(nt=2)),!1;var u=Error(o(520),{cause:s});if(u=Jt(u,n),Os===null?Os=[u]:Os.push(u),nt!==4&&(nt=2),t===null)return!0;s=Jt(s,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=c&-c,n.lanes|=e,e=Tc(n.stateNode,s,e),oc(n,e),!1;case 1:if(t=n.type,u=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(ma===null||!ma.has(u))))return n.flags|=65536,c&=-c,n.lanes|=c,c=ih(c),rh(c,e,n,s),oc(n,c),!1}n=n.return}while(n!==null);return!1}var Dc=Error(o(461)),ut=!1;function St(e,t,n,s){t.child=e===null?fm(t,null,n,s):Va(t,e.child,n,s)}function oh(e,t,n,s,c){n=n.render;var u=t.ref;if("ref"in s){var v={};for(var S in s)S!=="ref"&&(v[S]=s[S])}else v=s;return La(t),s=hc(e,t,n,v,u,c),S=pc(),e!==null&&!ut?(xc(e,t,c),Bn(e,t,c)):(Re&&S&&Zo(t),t.flags|=1,St(e,t,s,c),t.child)}function ch(e,t,n,s,c){if(e===null){var u=n.type;return typeof u=="function"&&!Fo(u)&&u.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=u,uh(e,t,u,s,c)):(e=zi(n.type,null,s,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!Vc(e,c)){var v=u.memoizedProps;if(n=n.compare,n=n!==null?n:ms,n(v,s)&&e.ref===t.ref)return Bn(e,t,c)}return t.flags|=1,e=Mn(u,s),e.ref=t.ref,e.return=t,t.child=e}function uh(e,t,n,s,c){if(e!==null){var u=e.memoizedProps;if(ms(u,s)&&e.ref===t.ref)if(ut=!1,t.pendingProps=s=u,Vc(e,c))(e.flags&131072)!==0&&(ut=!0);else return t.lanes=e.lanes,Bn(e,t,c)}return _c(e,t,n,s,c)}function fh(e,t,n,s){var c=s.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|n:n,e!==null){for(s=t.child=e.child,c=0;s!==null;)c=c|s.lanes|s.childLanes,s=s.sibling;s=c&~u}else s=0,t.child=null;return dh(e,t,u,n,s)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&$i(t,u!==null?u.cachePool:null),u!==null?hm(t,u):uc(),pm(t);else return s=t.lanes=536870912,dh(e,t,u!==null?u.baseLanes|n:n,n,s)}else u!==null?($i(t,u.cachePool),hm(t,u),ca(),t.memoizedState=null):(e!==null&&$i(t,null),uc(),ca());return St(e,t,c,n),t.child}function ks(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function dh(e,t,n,s,c){var u=lc();return u=u===null?null:{parent:ot._currentValue,pool:u},t.memoizedState={baseLanes:n,cachePool:u},e!==null&&$i(t,null),uc(),pm(t),e!==null&&bl(e,t,s,!0),t.childLanes=c,null}function lr(e,t){return t=ir({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function mh(e,t,n){return Va(t,e.child,null,n),e=lr(t,t.pendingProps),e.flags|=2,zt(t),t.memoizedState=null,e}function Lv(e,t,n){var s=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Re){if(s.mode==="hidden")return e=lr(t,s),t.lanes=536870912,ks(null,e);if(dc(t),(e=Ze)?(e=w0(e,Pt),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ta!==null?{id:gn,overflow:vn}:null,retryLane:536870912,hydrationErrors:null},n=Jd(e),n.return=t,t.child=n,yt=t,Ze=null)):e=null,e===null)throw aa(t);return t.lanes=536870912,null}return lr(t,s)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(dc(t),c)if(t.flags&256)t.flags&=-257,t=mh(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(ut||bl(e,t,n,!1),c=(n&e.childLanes)!==0,ut||c){if(s=Qe,s!==null&&(v=Xe(s,n),v!==0&&v!==u.retryLane))throw u.retryLane=v,Da(e,v),Tt(s,e,v),Dc;pr(),t=mh(e,t,n)}else e=u.treeContext,Ze=tn(v.nextSibling),yt=t,Re=!0,na=null,Pt=!1,e!==null&&Pd(t,e),t=lr(t,s),t.flags|=4096;return t}return e=Mn(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function sr(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function _c(e,t,n,s,c){return La(t),n=hc(e,t,n,s,void 0,c),s=pc(),e!==null&&!ut?(xc(e,t,c),Bn(e,t,c)):(Re&&s&&Zo(t),t.flags|=1,St(e,t,n,c),t.child)}function hh(e,t,n,s,c,u){return La(t),t.updateQueue=null,n=gm(t,s,n,c),xm(e),s=pc(),e!==null&&!ut?(xc(e,t,u),Bn(e,t,u)):(Re&&s&&Zo(t),t.flags|=1,St(e,t,n,u),t.child)}function ph(e,t,n,s,c){if(La(t),t.stateNode===null){var u=xl,v=n.contextType;typeof v=="object"&&v!==null&&(u=bt(v)),u=new n(s,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Rc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=s,u.state=t.memoizedState,u.refs={},ic(t),v=n.contextType,u.context=typeof v=="object"&&v!==null?bt(v):xl,u.state=t.memoizedState,v=n.getDerivedStateFromProps,typeof v=="function"&&(Mc(t,n,v,s),u.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(v=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),v!==u.state&&Rc.enqueueReplaceState(u,u.state,null),js(t,s,u,c),As(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!0}else if(e===null){u=t.stateNode;var S=t.memoizedProps,T=Ya(n,S);u.props=T;var V=u.context,I=n.contextType;v=xl,typeof I=="object"&&I!==null&&(v=bt(I));var ee=n.getDerivedStateFromProps;I=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",S=t.pendingProps!==S,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(S||V!==v)&&th(t,u,s,v),sa=!1;var G=t.memoizedState;u.state=G,js(t,s,u,c),As(),V=t.memoizedState,S||G!==V||sa?(typeof ee=="function"&&(Mc(t,n,ee,s),V=t.memoizedState),(T=sa||eh(t,n,T,s,G,V,v))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=V),u.props=s,u.state=V,u.context=v,s=T):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{u=t.stateNode,rc(e,t),v=t.memoizedProps,I=Ya(n,v),u.props=I,ee=t.pendingProps,G=u.context,V=n.contextType,T=xl,typeof V=="object"&&V!==null&&(T=bt(V)),S=n.getDerivedStateFromProps,(V=typeof S=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||G!==T)&&th(t,u,s,T),sa=!1,G=t.memoizedState,u.state=G,js(t,s,u,c),As();var Z=t.memoizedState;v!==ee||G!==Z||sa||e!==null&&e.dependencies!==null&&Hi(e.dependencies)?(typeof S=="function"&&(Mc(t,n,S,s),Z=t.memoizedState),(I=sa||eh(t,n,I,s,G,Z,T)||e!==null&&e.dependencies!==null&&Hi(e.dependencies))?(V||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(s,Z,T),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(s,Z,T)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&G===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&G===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=Z),u.props=s,u.state=Z,u.context=T,s=I):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&G===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&G===e.memoizedState||(t.flags|=1024),s=!1)}return u=s,sr(e,t),s=(t.flags&128)!==0,u||s?(u=t.stateNode,n=s&&typeof n.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&s?(t.child=Va(t,e.child,null,c),t.child=Va(t,null,n,c)):St(e,t,n,c),t.memoizedState=u.state,e=t.child):e=Bn(e,t,c),e}function xh(e,t,n,s){return Oa(),t.flags|=256,St(e,t,n,s),t.child}var Oc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bc(e){return{baseLanes:e,cachePool:sm()}}function Lc(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Ht),e}function gh(e,t,n){var s=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(at.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Re){if(c?oa(t):ca(),(e=Ze)?(e=w0(e,Pt),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ta!==null?{id:gn,overflow:vn}:null,retryLane:536870912,hydrationErrors:null},n=Jd(e),n.return=t,t.child=n,yt=t,Ze=null)):e=null,e===null)throw aa(t);return yu(e)?t.lanes=32:t.lanes=536870912,null}var S=s.children;return s=s.fallback,c?(ca(),c=t.mode,S=ir({mode:"hidden",children:S},c),s=_a(s,c,n,null),S.return=t,s.return=t,S.sibling=s,t.child=S,s=t.child,s.memoizedState=Bc(n),s.childLanes=Lc(e,v,n),t.memoizedState=Oc,ks(null,s)):(oa(t),zc(t,S))}var T=e.memoizedState;if(T!==null&&(S=T.dehydrated,S!==null)){if(u)t.flags&256?(oa(t),t.flags&=-257,t=Uc(e,t,n)):t.memoizedState!==null?(ca(),t.child=e.child,t.flags|=128,t=null):(ca(),S=s.fallback,c=t.mode,s=ir({mode:"visible",children:s.children},c),S=_a(S,c,n,null),S.flags|=2,s.return=t,S.return=t,s.sibling=S,t.child=s,Va(t,e.child,null,n),s=t.child,s.memoizedState=Bc(n),s.childLanes=Lc(e,v,n),t.memoizedState=Oc,t=ks(null,s));else if(oa(t),yu(S)){if(v=S.nextSibling&&S.nextSibling.dataset,v)var V=v.dgst;v=V,s=Error(o(419)),s.stack="",s.digest=v,xs({value:s,source:null,stack:null}),t=Uc(e,t,n)}else if(ut||bl(e,t,n,!1),v=(n&e.childLanes)!==0,ut||v){if(v=Qe,v!==null&&(s=Xe(v,n),s!==0&&s!==T.retryLane))throw T.retryLane=s,Da(e,s),Tt(v,e,s),Dc;vu(S)||pr(),t=Uc(e,t,n)}else vu(S)?(t.flags|=192,t.child=e.child,t=null):(e=T.treeContext,Ze=tn(S.nextSibling),yt=t,Re=!0,na=null,Pt=!1,e!==null&&Pd(t,e),t=zc(t,s.children),t.flags|=4096);return t}return c?(ca(),S=s.fallback,c=t.mode,T=e.child,V=T.sibling,s=Mn(T,{mode:"hidden",children:s.children}),s.subtreeFlags=T.subtreeFlags&65011712,V!==null?S=Mn(V,S):(S=_a(S,c,n,null),S.flags|=2),S.return=t,s.return=t,s.sibling=S,t.child=s,ks(null,s),s=t.child,S=e.child.memoizedState,S===null?S=Bc(n):(c=S.cachePool,c!==null?(T=ot._currentValue,c=c.parent!==T?{parent:T,pool:T}:c):c=sm(),S={baseLanes:S.baseLanes|n,cachePool:c}),s.memoizedState=S,s.childLanes=Lc(e,v,n),t.memoizedState=Oc,ks(e.child,s)):(oa(t),n=e.child,e=n.sibling,n=Mn(n,{mode:"visible",children:s.children}),n.return=t,n.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=n,t.memoizedState=null,n)}function zc(e,t){return t=ir({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function ir(e,t){return e=Bt(22,e,null,t),e.lanes=0,e}function Uc(e,t,n){return Va(t,e.child,null,n),e=zc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vh(e,t,n){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),ec(e.return,t,n)}function Hc(e,t,n,s,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:n,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=s,v.tail=n,v.tailMode=c,v.treeForkCount=u)}function yh(e,t,n){var s=t.pendingProps,c=s.revealOrder,u=s.tail;s=s.children;var v=at.current,S=(v&2)!==0;if(S?(v=v&1|2,t.flags|=128):v&=1,ne(at,v),St(e,t,s,n),s=Re?ps:0,!S&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vh(e,n,t);else if(e.tag===19)vh(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(n=t.child,c=null;n!==null;)e=n.alternate,e!==null&&Ki(e)===null&&(c=n),n=n.sibling;n=c,n===null?(c=t.child,t.child=null):(c=n.sibling,n.sibling=null),Hc(t,!1,c,n,u,s);break;case"backwards":case"unstable_legacy-backwards":for(n=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Ki(e)===null){t.child=c;break}e=c.sibling,c.sibling=n,n=c,c=e}Hc(t,!0,n,null,u,s);break;case"together":Hc(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function Bn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),da|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(bl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Mn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Mn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Vc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Hi(e)))}function zv(e,t,n){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),la(t,ot,e.memoizedState.cache),Oa();break;case 27:case 5:we(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:la(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,dc(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(oa(t),t.flags|=128,null):(n&t.child.childLanes)!==0?gh(e,t,n):(oa(t),e=Bn(e,t,n),e!==null?e.sibling:null);oa(t);break;case 19:var c=(e.flags&128)!==0;if(s=(n&t.childLanes)!==0,s||(bl(e,t,n,!1),s=(n&t.childLanes)!==0),c){if(s)return yh(e,t,n);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),ne(at,at.current),s)break;return null;case 22:return t.lanes=0,fh(e,t,n,t.pendingProps);case 24:la(t,ot,e.memoizedState.cache)}return Bn(e,t,n)}function bh(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ut=!0;else{if(!Vc(e,n)&&(t.flags&128)===0)return ut=!1,zv(e,t,n);ut=(e.flags&131072)!==0}else ut=!1,Re&&(t.flags&1048576)!==0&&Wd(t,ps,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=Ua(t.elementType),t.type=e,typeof e=="function")Fo(e)?(s=Ya(e,s),t.tag=1,t=ph(null,t,e,s,n)):(t.tag=0,t=_c(null,t,e,s,n));else{if(e!=null){var c=e.$$typeof;if(c===_){t.tag=11,t=oh(null,t,e,s,n);break e}else if(c===O){t.tag=14,t=ch(null,t,e,s,n);break e}}throw t=oe(e)||e,Error(o(306,t,""))}}return t;case 0:return _c(e,t,t.type,t.pendingProps,n);case 1:return s=t.type,c=Ya(s,t.pendingProps),ph(e,t,s,c,n);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));s=t.pendingProps;var u=t.memoizedState;c=u.element,rc(e,t),js(t,s,null,n);var v=t.memoizedState;if(s=v.cache,la(t,ot,s),s!==u.cache&&tc(t,[ot],n,!0),As(),s=v.element,u.isDehydrated)if(u={element:s,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=xh(e,t,s,n);break e}else if(s!==c){c=Jt(Error(o(424)),t),xs(c),t=xh(e,t,s,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Ze=tn(e.firstChild),yt=t,Re=!0,na=null,Pt=!0,n=fm(t,null,s,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Oa(),s===c){t=Bn(e,t,n);break e}St(e,t,s,n)}t=t.child}return t;case 26:return sr(e,t),e===null?(n=R0(t.type,null,t.pendingProps,null))?t.memoizedState=n:Re||(n=t.type,e=t.pendingProps,s=Ar(ie.current).createElement(n),s[et]=t,s[_e]=e,At(s,n,e),xt(s),t.stateNode=s):t.memoizedState=R0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return we(t),e===null&&Re&&(s=t.stateNode=k0(t.type,t.pendingProps,ie.current),yt=t,Pt=!0,c=Ze,ga(t.type)?(bu=c,Ze=tn(s.firstChild)):Ze=c),St(e,t,t.pendingProps.children,n),sr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Re&&((c=s=Ze)&&(s=hy(s,t.type,t.pendingProps,Pt),s!==null?(t.stateNode=s,yt=t,Ze=tn(s.firstChild),Pt=!1,c=!0):c=!1),c||aa(t)),we(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,s=u.children,pu(c,u)?s=null:v!==null&&pu(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=hc(e,t,qv,null,null,n),Ys._currentValue=c),sr(e,t),St(e,t,s,n),t.child;case 6:return e===null&&Re&&((e=n=Ze)&&(n=py(n,t.pendingProps,Pt),n!==null?(t.stateNode=n,yt=t,Ze=null,e=!0):e=!1),e||aa(t)),null;case 13:return gh(e,t,n);case 4:return ve(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Va(t,null,s,n):St(e,t,s,n),t.child;case 11:return oh(e,t,t.type,t.pendingProps,n);case 7:return St(e,t,t.pendingProps,n),t.child;case 8:return St(e,t,t.pendingProps.children,n),t.child;case 12:return St(e,t,t.pendingProps.children,n),t.child;case 10:return s=t.pendingProps,la(t,t.type,s.value),St(e,t,s.children,n),t.child;case 9:return c=t.type._context,s=t.pendingProps.children,La(t),c=bt(c),s=s(c),t.flags|=1,St(e,t,s,n),t.child;case 14:return ch(e,t,t.type,t.pendingProps,n);case 15:return uh(e,t,t.type,t.pendingProps,n);case 19:return yh(e,t,n);case 31:return Lv(e,t,n);case 22:return fh(e,t,n,t.pendingProps);case 24:return La(t),s=bt(ot),e===null?(c=lc(),c===null&&(c=Qe,u=nc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=n),c=u),t.memoizedState={parent:s,cache:c},ic(t),la(t,ot,c)):((e.lanes&n)!==0&&(rc(e,t),js(t,null,null,n),As()),c=e.memoizedState,u=t.memoizedState,c.parent!==s?(c={parent:s,cache:s},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),la(t,ot,s)):(s=u.cache,la(t,ot,s),s!==c.cache&&tc(t,[ot],n,!0))),St(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Ln(e){e.flags|=4}function $c(e,t,n,s,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(Qh())e.flags|=8192;else throw Ha=Gi,sc}else e.flags&=-16777217}function Sh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!B0(t))if(Qh())e.flags|=8192;else throw Ha=Gi,sc}function rr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Ai():536870912,e.lanes|=t,Tl|=t)}function qs(e,t){if(!Re)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function Je(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,s=0;if(t)for(var c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags&65011712,s|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=n,t}function Uv(e,t,n){var s=t.pendingProps;switch(Jo(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(t),null;case 1:return Je(t),null;case 3:return n=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Dn(ot),me(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(yl(t)?Ln(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Wo())),Je(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Ln(t),u!==null?(Je(t),Sh(t,u)):(Je(t),$c(t,c,null,s,n))):u?u!==e.memoizedState?(Ln(t),Je(t),Sh(t,u)):(Je(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&Ln(t),Je(t),$c(t,c,e,s,n)),null;case 27:if(te(t),n=ie.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Ln(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return Je(t),null}e=le.current,yl(t)?em(t):(e=k0(c,s,n),t.stateNode=e,Ln(t))}return Je(t),null;case 5:if(te(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Ln(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return Je(t),null}if(u=le.current,yl(t))em(t);else{var v=Ar(ie.current);switch(u){case 1:u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=v.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof s.is=="string"?v.createElement("select",{is:s.is}):v.createElement("select"),s.multiple?u.multiple=!0:s.size&&(u.size=s.size);break;default:u=typeof s.is=="string"?v.createElement(c,{is:s.is}):v.createElement(c)}}u[et]=t,u[_e]=s;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=u;e:switch(At(u,c,s),c){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&Ln(t)}}return Je(t),$c(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&Ln(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(o(166));if(e=ie.current,yl(t)){if(e=t.stateNode,n=t.memoizedProps,s=null,c=yt,c!==null)switch(c.tag){case 27:case 5:s=c.memoizedProps}e[et]=t,e=!!(e.nodeValue===n||s!==null&&s.suppressHydrationWarning===!0||g0(e.nodeValue,n)),e||aa(t,!0)}else e=Ar(e).createTextNode(s),e[et]=t,t.stateNode=e}return Je(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(s=yl(t),n!==null){if(e===null){if(!s)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[et]=t}else Oa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Je(t),e=!1}else n=Wo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(zt(t),t):(zt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return Je(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=yl(t),s!==null&&s.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[et]=t}else Oa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Je(t),c=!1}else c=Wo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(zt(t),t):(zt(t),null)}return zt(t),(t.flags&128)!==0?(t.lanes=n,t):(n=s!==null,e=e!==null&&e.memoizedState!==null,n&&(s=t.child,c=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(c=s.alternate.memoizedState.cachePool.pool),u=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),u!==c&&(s.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),rr(t,t.updateQueue),Je(t),null);case 4:return me(),e===null&&uu(t.stateNode.containerInfo),Je(t),null;case 10:return Dn(t.type),Je(t),null;case 19:if(H(at),s=t.memoizedState,s===null)return Je(t),null;if(c=(t.flags&128)!==0,u=s.rendering,u===null)if(c)qs(s,!1);else{if(nt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Ki(e),u!==null){for(t.flags|=128,qs(s,!1),e=u.updateQueue,t.updateQueue=e,rr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Zd(n,e),n=n.sibling;return ne(at,at.current&1|2),Re&&Rn(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&mt()>dr&&(t.flags|=128,c=!0,qs(s,!1),t.lanes=4194304)}else{if(!c)if(e=Ki(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,rr(t,e),qs(s,!0),s.tail===null&&s.tailMode==="hidden"&&!u.alternate&&!Re)return Je(t),null}else 2*mt()-s.renderingStartTime>dr&&n!==536870912&&(t.flags|=128,c=!0,qs(s,!1),t.lanes=4194304);s.isBackwards?(u.sibling=t.child,t.child=u):(e=s.last,e!==null?e.sibling=u:t.child=u,s.last=u)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=mt(),e.sibling=null,n=at.current,ne(at,c?n&1|2:n&1),Re&&Rn(t,s.treeForkCount),e):(Je(t),null);case 22:case 23:return zt(t),fc(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(n&536870912)!==0&&(t.flags&128)===0&&(Je(t),t.subtreeFlags&6&&(t.flags|=8192)):Je(t),n=t.updateQueue,n!==null&&rr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==n&&(t.flags|=2048),e!==null&&H(za),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Dn(ot),Je(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Hv(e,t){switch(Jo(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Dn(ot),me(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(t.memoizedState!==null){if(zt(t),t.alternate===null)throw Error(o(340));Oa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(zt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Oa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(at),null;case 4:return me(),null;case 10:return Dn(t.type),null;case 22:case 23:return zt(t),fc(),e!==null&&H(za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Dn(ot),null;case 25:return null;default:return null}}function Ah(e,t){switch(Jo(t),t.tag){case 3:Dn(ot),me();break;case 26:case 27:case 5:te(t);break;case 4:me();break;case 31:t.memoizedState!==null&&zt(t);break;case 13:zt(t);break;case 19:H(at);break;case 10:Dn(t.type);break;case 22:case 23:zt(t),fc(),e!==null&&H(za);break;case 24:Dn(ot)}}function Ms(e,t){try{var n=t.updateQueue,s=n!==null?n.lastEffect:null;if(s!==null){var c=s.next;n=c;do{if((n.tag&e)===e){s=void 0;var u=n.create,v=n.inst;s=u(),v.destroy=s}n=n.next}while(n!==c)}}catch(S){Ve(t,t.return,S)}}function ua(e,t,n){try{var s=t.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var u=c.next;s=u;do{if((s.tag&e)===e){var v=s.inst,S=v.destroy;if(S!==void 0){v.destroy=void 0,c=t;var T=n,V=S;try{V()}catch(I){Ve(c,T,I)}}}s=s.next}while(s!==u)}}catch(I){Ve(t,t.return,I)}}function jh(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{mm(t,n)}catch(s){Ve(e,e.return,s)}}}function Nh(e,t,n){n.props=Ya(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(s){Ve(e,t,s)}}function Rs(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof n=="function"?e.refCleanup=n(s):n.current=s}}catch(c){Ve(e,t,c)}}function yn(e,t){var n=e.ref,s=e.refCleanup;if(n!==null)if(typeof s=="function")try{s()}catch(c){Ve(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(c){Ve(e,t,c)}else n.current=null}function wh(e){var t=e.type,n=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&s.focus();break e;case"img":n.src?s.src=n.src:n.srcSet&&(s.srcset=n.srcSet)}}catch(c){Ve(e,e.return,c)}}function Yc(e,t,n){try{var s=e.stateNode;oy(s,e.type,n,t),s[_e]=t}catch(c){Ve(e,e.return,c)}}function Ch(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ga(e.type)||e.tag===4}function Gc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ch(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ga(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Xc(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=kn));else if(s!==4&&(s===27&&ga(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function or(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(s!==4&&(s===27&&ga(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(or(e,t,n),e=e.sibling;e!==null;)or(e,t,n),e=e.sibling}function Eh(e){var t=e.stateNode,n=e.memoizedProps;try{for(var s=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);At(t,s,n),t[et]=e,t[_e]=n}catch(u){Ve(e,e.return,u)}}var zn=!1,ft=!1,Fc=!1,kh=typeof WeakSet=="function"?WeakSet:Set,gt=null;function Vv(e,t){if(e=e.containerInfo,mu=qr,e=Hd(e),Uo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var c=s.anchorOffset,u=s.focusNode;s=s.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var v=0,S=-1,T=-1,V=0,I=0,ee=e,G=null;t:for(;;){for(var Z;ee!==n||c!==0&&ee.nodeType!==3||(S=v+c),ee!==u||s!==0&&ee.nodeType!==3||(T=v+s),ee.nodeType===3&&(v+=ee.nodeValue.length),(Z=ee.firstChild)!==null;)G=ee,ee=Z;for(;;){if(ee===e)break t;if(G===n&&++V===c&&(S=v),G===u&&++I===s&&(T=v),(Z=ee.nextSibling)!==null)break;ee=G,G=ee.parentNode}ee=Z}n=S===-1||T===-1?null:{start:S,end:T}}else n=null}n=n||{start:0,end:0}}else n=null;for(hu={focusedElem:e,selectionRange:n},qr=!1,gt=t;gt!==null;)if(t=gt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,gt=e;else for(;gt!==null;){switch(t=gt,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)c=e[n],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,n=t,c=u.memoizedProps,u=u.memoizedState,s=n.stateNode;try{var de=Ya(n.type,c);e=s.getSnapshotBeforeUpdate(de,u),s.__reactInternalSnapshotBeforeUpdate=e}catch(ye){Ve(n,n.return,ye)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)gu(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":gu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,gt=e;break}gt=t.return}}function qh(e,t,n){var s=n.flags;switch(n.tag){case 0:case 11:case 15:Hn(e,n),s&4&&Ms(5,n);break;case 1:if(Hn(e,n),s&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(v){Ve(n,n.return,v)}else{var c=Ya(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Ve(n,n.return,v)}}s&64&&jh(n),s&512&&Rs(n,n.return);break;case 3:if(Hn(e,n),s&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{mm(e,t)}catch(v){Ve(n,n.return,v)}}break;case 27:t===null&&s&4&&Eh(n);case 26:case 5:Hn(e,n),t===null&&s&4&&wh(n),s&512&&Rs(n,n.return);break;case 12:Hn(e,n);break;case 31:Hn(e,n),s&4&&Th(e,n);break;case 13:Hn(e,n),s&4&&Dh(e,n),s&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Jv.bind(null,n),xy(e,n))));break;case 22:if(s=n.memoizedState!==null||zn,!s){t=t!==null&&t.memoizedState!==null||ft,c=zn;var u=ft;zn=s,(ft=t)&&!u?Vn(e,n,(n.subtreeFlags&8772)!==0):Hn(e,n),zn=c,ft=u}break;case 30:break;default:Hn(e,n)}}function Mh(e){var t=e.alternate;t!==null&&(e.alternate=null,Mh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ao(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ie=null,kt=!1;function Un(e,t,n){for(n=n.child;n!==null;)Rh(e,t,n),n=n.sibling}function Rh(e,t,n){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(cn,n)}catch{}switch(n.tag){case 26:ft||yn(n,t),Un(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:ft||yn(n,t);var s=Ie,c=kt;ga(n.type)&&(Ie=n.stateNode,kt=!1),Un(e,t,n),Hs(n.stateNode),Ie=s,kt=c;break;case 5:ft||yn(n,t);case 6:if(s=Ie,c=kt,Ie=null,Un(e,t,n),Ie=s,kt=c,Ie!==null)if(kt)try{(Ie.nodeType===9?Ie.body:Ie.nodeName==="HTML"?Ie.ownerDocument.body:Ie).removeChild(n.stateNode)}catch(u){Ve(n,t,u)}else try{Ie.removeChild(n.stateNode)}catch(u){Ve(n,t,u)}break;case 18:Ie!==null&&(kt?(e=Ie,j0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Hl(e)):j0(Ie,n.stateNode));break;case 4:s=Ie,c=kt,Ie=n.stateNode.containerInfo,kt=!0,Un(e,t,n),Ie=s,kt=c;break;case 0:case 11:case 14:case 15:ua(2,n,t),ft||ua(4,n,t),Un(e,t,n);break;case 1:ft||(yn(n,t),s=n.stateNode,typeof s.componentWillUnmount=="function"&&Nh(n,t,s)),Un(e,t,n);break;case 21:Un(e,t,n);break;case 22:ft=(s=ft)||n.memoizedState!==null,Un(e,t,n),ft=s;break;default:Un(e,t,n)}}function Th(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hl(e)}catch(n){Ve(t,t.return,n)}}}function Dh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hl(e)}catch(n){Ve(t,t.return,n)}}function $v(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new kh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new kh),t;default:throw Error(o(435,e.tag))}}function cr(e,t){var n=$v(e);t.forEach(function(s){if(!n.has(s)){n.add(s);var c=Iv.bind(null,e,s);s.then(c,c)}})}function qt(e,t){var n=t.deletions;if(n!==null)for(var s=0;s<n.length;s++){var c=n[s],u=e,v=t,S=v;e:for(;S!==null;){switch(S.tag){case 27:if(ga(S.type)){Ie=S.stateNode,kt=!1;break e}break;case 5:Ie=S.stateNode,kt=!1;break e;case 3:case 4:Ie=S.stateNode.containerInfo,kt=!0;break e}S=S.return}if(Ie===null)throw Error(o(160));Rh(u,v,c),Ie=null,kt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)_h(t,e),t=t.sibling}var fn=null;function _h(e,t){var n=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:qt(t,e),Mt(e),s&4&&(ua(3,e,e.return),Ms(3,e),ua(5,e,e.return));break;case 1:qt(t,e),Mt(e),s&512&&(ft||n===null||yn(n,n.return)),s&64&&zn&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?s:n.concat(s))));break;case 26:var c=fn;if(qt(t,e),Mt(e),s&512&&(ft||n===null||yn(n,n.return)),s&4){var u=n!==null?n.memoizedState:null;if(s=e.memoizedState,n===null)if(s===null)if(e.stateNode===null){e:{s=e.type,n=e.memoizedProps,c=c.ownerDocument||c;t:switch(s){case"title":u=c.getElementsByTagName("title")[0],(!u||u[ls]||u[et]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(s),c.head.insertBefore(u,c.querySelector("head > title"))),At(u,s,n),u[et]=e,xt(u),s=u;break e;case"link":var v=_0("link","href",c).get(s+(n.href||""));if(v){for(var S=0;S<v.length;S++)if(u=v[S],u.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&u.getAttribute("rel")===(n.rel==null?null:n.rel)&&u.getAttribute("title")===(n.title==null?null:n.title)&&u.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){v.splice(S,1);break t}}u=c.createElement(s),At(u,s,n),c.head.appendChild(u);break;case"meta":if(v=_0("meta","content",c).get(s+(n.content||""))){for(S=0;S<v.length;S++)if(u=v[S],u.getAttribute("content")===(n.content==null?null:""+n.content)&&u.getAttribute("name")===(n.name==null?null:n.name)&&u.getAttribute("property")===(n.property==null?null:n.property)&&u.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&u.getAttribute("charset")===(n.charSet==null?null:n.charSet)){v.splice(S,1);break t}}u=c.createElement(s),At(u,s,n),c.head.appendChild(u);break;default:throw Error(o(468,s))}u[et]=e,xt(u),s=u}e.stateNode=s}else O0(c,e.type,e.stateNode);else e.stateNode=D0(c,s,e.memoizedProps);else u!==s?(u===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):u.count--,s===null?O0(c,e.type,e.stateNode):D0(c,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Yc(e,e.memoizedProps,n.memoizedProps)}break;case 27:qt(t,e),Mt(e),s&512&&(ft||n===null||yn(n,n.return)),n!==null&&s&4&&Yc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(qt(t,e),Mt(e),s&512&&(ft||n===null||yn(n,n.return)),e.flags&32){c=e.stateNode;try{cl(c,"")}catch(de){Ve(e,e.return,de)}}s&4&&e.stateNode!=null&&(c=e.memoizedProps,Yc(e,c,n!==null?n.memoizedProps:c)),s&1024&&(Fc=!0);break;case 6:if(qt(t,e),Mt(e),s&4){if(e.stateNode===null)throw Error(o(162));s=e.memoizedProps,n=e.stateNode;try{n.nodeValue=s}catch(de){Ve(e,e.return,de)}}break;case 3:if(wr=null,c=fn,fn=jr(t.containerInfo),qt(t,e),fn=c,Mt(e),s&4&&n!==null&&n.memoizedState.isDehydrated)try{Hl(t.containerInfo)}catch(de){Ve(e,e.return,de)}Fc&&(Fc=!1,Oh(e));break;case 4:s=fn,fn=jr(e.stateNode.containerInfo),qt(t,e),Mt(e),fn=s;break;case 12:qt(t,e),Mt(e);break;case 31:qt(t,e),Mt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,cr(e,s)));break;case 13:qt(t,e),Mt(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(fr=mt()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,cr(e,s)));break;case 22:c=e.memoizedState!==null;var T=n!==null&&n.memoizedState!==null,V=zn,I=ft;if(zn=V||c,ft=I||T,qt(t,e),ft=I,zn=V,Mt(e),s&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(n===null||T||zn||ft||Ga(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){T=n=t;try{if(u=T.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{S=T.stateNode;var ee=T.memoizedProps.style,G=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;S.style.display=G==null||typeof G=="boolean"?"":(""+G).trim()}}catch(de){Ve(T,T.return,de)}}}else if(t.tag===6){if(n===null){T=t;try{T.stateNode.nodeValue=c?"":T.memoizedProps}catch(de){Ve(T,T.return,de)}}}else if(t.tag===18){if(n===null){T=t;try{var Z=T.stateNode;c?N0(Z,!0):N0(T.stateNode,!1)}catch(de){Ve(T,T.return,de)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}s&4&&(s=e.updateQueue,s!==null&&(n=s.retryQueue,n!==null&&(s.retryQueue=null,cr(e,n))));break;case 19:qt(t,e),Mt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,cr(e,s)));break;case 30:break;case 21:break;default:qt(t,e),Mt(e)}}function Mt(e){var t=e.flags;if(t&2){try{for(var n,s=e.return;s!==null;){if(Ch(s)){n=s;break}s=s.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode,u=Gc(e);or(e,u,c);break;case 5:var v=n.stateNode;n.flags&32&&(cl(v,""),n.flags&=-33);var S=Gc(e);or(e,S,v);break;case 3:case 4:var T=n.stateNode.containerInfo,V=Gc(e);Xc(e,V,T);break;default:throw Error(o(161))}}catch(I){Ve(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Oh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Oh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Hn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)qh(e,t.alternate,t),t=t.sibling}function Ga(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ua(4,t,t.return),Ga(t);break;case 1:yn(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&Nh(t,t.return,n),Ga(t);break;case 27:Hs(t.stateNode);case 26:case 5:yn(t,t.return),Ga(t);break;case 22:t.memoizedState===null&&Ga(t);break;case 30:Ga(t);break;default:Ga(t)}e=e.sibling}}function Vn(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var s=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:Vn(c,u,n),Ms(4,u);break;case 1:if(Vn(c,u,n),s=u,c=s.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(V){Ve(s,s.return,V)}if(s=u,c=s.updateQueue,c!==null){var S=s.stateNode;try{var T=c.shared.hiddenCallbacks;if(T!==null)for(c.shared.hiddenCallbacks=null,c=0;c<T.length;c++)dm(T[c],S)}catch(V){Ve(s,s.return,V)}}n&&v&64&&jh(u),Rs(u,u.return);break;case 27:Eh(u);case 26:case 5:Vn(c,u,n),n&&s===null&&v&4&&wh(u),Rs(u,u.return);break;case 12:Vn(c,u,n);break;case 31:Vn(c,u,n),n&&v&4&&Th(c,u);break;case 13:Vn(c,u,n),n&&v&4&&Dh(c,u);break;case 22:u.memoizedState===null&&Vn(c,u,n),Rs(u,u.return);break;case 30:break;default:Vn(c,u,n)}t=t.sibling}}function Qc(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&gs(n))}function Kc(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&gs(e))}function dn(e,t,n,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Bh(e,t,n,s),t=t.sibling}function Bh(e,t,n,s){var c=t.flags;switch(t.tag){case 0:case 11:case 15:dn(e,t,n,s),c&2048&&Ms(9,t);break;case 1:dn(e,t,n,s);break;case 3:dn(e,t,n,s),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&gs(e)));break;case 12:if(c&2048){dn(e,t,n,s),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,S=u.onPostCommit;typeof S=="function"&&S(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(T){Ve(t,t.return,T)}}else dn(e,t,n,s);break;case 31:dn(e,t,n,s);break;case 13:dn(e,t,n,s);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?dn(e,t,n,s):Ts(e,t):u._visibility&2?dn(e,t,n,s):(u._visibility|=2,ql(e,t,n,s,(t.subtreeFlags&10256)!==0||!1)),c&2048&&Qc(v,t);break;case 24:dn(e,t,n,s),c&2048&&Kc(t.alternate,t);break;default:dn(e,t,n,s)}}function ql(e,t,n,s,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,S=n,T=s,V=v.flags;switch(v.tag){case 0:case 11:case 15:ql(u,v,S,T,c),Ms(8,v);break;case 23:break;case 22:var I=v.stateNode;v.memoizedState!==null?I._visibility&2?ql(u,v,S,T,c):Ts(u,v):(I._visibility|=2,ql(u,v,S,T,c)),c&&V&2048&&Qc(v.alternate,v);break;case 24:ql(u,v,S,T,c),c&&V&2048&&Kc(v.alternate,v);break;default:ql(u,v,S,T,c)}t=t.sibling}}function Ts(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,s=t,c=s.flags;switch(s.tag){case 22:Ts(n,s),c&2048&&Qc(s.alternate,s);break;case 24:Ts(n,s),c&2048&&Kc(s.alternate,s);break;default:Ts(n,s)}t=t.sibling}}var Ds=8192;function Ml(e,t,n){if(e.subtreeFlags&Ds)for(e=e.child;e!==null;)Lh(e,t,n),e=e.sibling}function Lh(e,t,n){switch(e.tag){case 26:Ml(e,t,n),e.flags&Ds&&e.memoizedState!==null&&ky(n,fn,e.memoizedState,e.memoizedProps);break;case 5:Ml(e,t,n);break;case 3:case 4:var s=fn;fn=jr(e.stateNode.containerInfo),Ml(e,t,n),fn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=Ds,Ds=16777216,Ml(e,t,n),Ds=s):Ml(e,t,n));break;default:Ml(e,t,n)}}function zh(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function _s(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];gt=s,Hh(s,e)}zh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uh(e),e=e.sibling}function Uh(e){switch(e.tag){case 0:case 11:case 15:_s(e),e.flags&2048&&ua(9,e,e.return);break;case 3:_s(e);break;case 12:_s(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ur(e)):_s(e);break;default:_s(e)}}function ur(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];gt=s,Hh(s,e)}zh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ua(8,t,t.return),ur(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,ur(t));break;default:ur(t)}e=e.sibling}}function Hh(e,t){for(;gt!==null;){var n=gt;switch(n.tag){case 0:case 11:case 15:ua(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var s=n.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:gs(n.memoizedState.cache)}if(s=n.child,s!==null)s.return=n,gt=s;else e:for(n=e;gt!==null;){s=gt;var c=s.sibling,u=s.return;if(Mh(s),s===n){gt=null;break e}if(c!==null){c.return=u,gt=c;break e}gt=u}}}var Yv={getCacheForType:function(e){var t=bt(ot),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return bt(ot).controller.signal}},Gv=typeof WeakMap=="function"?WeakMap:Map,Le=0,Qe=null,Ee=null,qe=0,He=0,Ut=null,fa=!1,Rl=!1,Zc=!1,$n=0,nt=0,da=0,Xa=0,Jc=0,Ht=0,Tl=0,Os=null,Rt=null,Ic=!1,fr=0,Vh=0,dr=1/0,mr=null,ma=null,ht=0,ha=null,Dl=null,Yn=0,Wc=0,Pc=null,$h=null,Bs=0,eu=null;function Vt(){return(Le&2)!==0&&qe!==0?qe&-qe:R.T!==null?iu():Ue()}function Yh(){if(Ht===0)if((qe&536870912)===0||Re){var e=Ke;Ke<<=1,(Ke&3932160)===0&&(Ke=262144),Ht=e}else Ht=536870912;return e=Lt.current,e!==null&&(e.flags|=32),Ht}function Tt(e,t,n){(e===Qe&&(He===2||He===9)||e.cancelPendingCommit!==null)&&(_l(e,0),pa(e,qe,Ht,!1)),ka(e,n),((Le&2)===0||e!==Qe)&&(e===Qe&&((Le&2)===0&&(Xa|=n),nt===4&&pa(e,qe,Ht,!1)),bn(e))}function Gh(e,t,n){if((Le&6)!==0)throw Error(o(327));var s=!n&&(t&127)===0&&(t&e.expiredLanes)===0||xn(e,t),c=s?Qv(e,t):nu(e,t,!0),u=s;do{if(c===0){Rl&&!s&&pa(e,t,0,!1);break}else{if(n=e.current.alternate,u&&!Xv(n)){c=nu(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var v=0;else v=e.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){t=v;e:{var S=e;c=Os;var T=S.current.memoizedState.isDehydrated;if(T&&(_l(S,v).flags|=256),v=nu(S,v,!1),v!==2){if(Zc&&!T){S.errorRecoveryDisabledLanes|=u,Xa|=u,c=4;break e}u=Rt,Rt=c,u!==null&&(Rt===null?Rt=u:Rt.push.apply(Rt,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){_l(e,0),pa(e,t,0,!0);break}e:{switch(s=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:pa(s,t,Ht,!fa);break e;case 2:Rt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=fr+300-mt(),10<c)){if(pa(s,t,Ht,!fa),Pn(s,0,!0)!==0)break e;Yn=t,s.timeoutHandle=S0(Xh.bind(null,s,n,Rt,mr,Ic,t,Ht,Xa,Tl,fa,u,"Throttled",-0,0),c);break e}Xh(s,n,Rt,mr,Ic,t,Ht,Xa,Tl,fa,u,null,-0,0)}}break}while(!0);bn(e)}function Xh(e,t,n,s,c,u,v,S,T,V,I,ee,G,Z){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:kn},Lh(t,u,ee);var de=(u&62914560)===u?fr-mt():(u&4194048)===u?Vh-mt():0;if(de=qy(ee,de),de!==null){Yn=u,e.cancelPendingCommit=de(Ph.bind(null,e,t,u,n,s,c,v,S,T,I,ee,null,G,Z)),pa(e,u,v,!V);return}}Ph(e,t,u,n,s,c,v,S,T)}function Xv(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var s=0;s<n.length;s++){var c=n[s],u=c.getSnapshot;c=c.value;try{if(!Ot(u(),c))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function pa(e,t,n,s){t&=~Jc,t&=~Xa,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var c=t;0<c;){var u=31-rt(c),v=1<<u;s[u]=-1,c&=~v}n!==0&&Xt(e,n,t)}function hr(){return(Le&6)===0?(Ls(0),!1):!0}function tu(){if(Ee!==null){if(He===0)var e=Ee.return;else e=Ee,Tn=Ba=null,gc(e),Nl=null,ys=0,e=Ee;for(;e!==null;)Ah(e.alternate,e),e=e.return;Ee=null}}function _l(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,fy(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Yn=0,tu(),Qe=e,Ee=n=Mn(e.current,null),qe=t,He=0,Ut=null,fa=!1,Rl=xn(e,t),Zc=!1,Tl=Ht=Jc=Xa=da=nt=0,Rt=Os=null,Ic=!1,(t&8)!==0&&(t|=t&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=t;0<s;){var c=31-rt(s),u=1<<c;t|=e[c],s&=~u}return $n=t,Oi(),n}function Fh(e,t){Ae=null,R.H=Es,t===jl||t===Yi?(t=om(),He=3):t===sc?(t=om(),He=4):He=t===Dc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ut=t,Ee===null&&(nt=1,ar(e,Jt(t,e.current)))}function Qh(){var e=Lt.current;return e===null?!0:(qe&4194048)===qe?en===null:(qe&62914560)===qe||(qe&536870912)!==0?e===en:!1}function Kh(){var e=R.H;return R.H=Es,e===null?Es:e}function Zh(){var e=R.A;return R.A=Yv,e}function pr(){nt=4,fa||(qe&4194048)!==qe&&Lt.current!==null||(Rl=!0),(da&134217727)===0&&(Xa&134217727)===0||Qe===null||pa(Qe,qe,Ht,!1)}function nu(e,t,n){var s=Le;Le|=2;var c=Kh(),u=Zh();(Qe!==e||qe!==t)&&(mr=null,_l(e,t)),t=!1;var v=nt;e:do try{if(He!==0&&Ee!==null){var S=Ee,T=Ut;switch(He){case 8:tu(),v=6;break e;case 3:case 2:case 9:case 6:Lt.current===null&&(t=!0);var V=He;if(He=0,Ut=null,Ol(e,S,T,V),n&&Rl){v=0;break e}break;default:V=He,He=0,Ut=null,Ol(e,S,T,V)}}Fv(),v=nt;break}catch(I){Fh(e,I)}while(!0);return t&&e.shellSuspendCounter++,Tn=Ba=null,Le=s,R.H=c,R.A=u,Ee===null&&(Qe=null,qe=0,Oi()),v}function Fv(){for(;Ee!==null;)Jh(Ee)}function Qv(e,t){var n=Le;Le|=2;var s=Kh(),c=Zh();Qe!==e||qe!==t?(mr=null,dr=mt()+500,_l(e,t)):Rl=xn(e,t);e:do try{if(He!==0&&Ee!==null){t=Ee;var u=Ut;t:switch(He){case 1:He=0,Ut=null,Ol(e,t,u,1);break;case 2:case 9:if(im(u)){He=0,Ut=null,Ih(t);break}t=function(){He!==2&&He!==9||Qe!==e||(He=7),bn(e)},u.then(t,t);break e;case 3:He=7;break e;case 4:He=5;break e;case 7:im(u)?(He=0,Ut=null,Ih(t)):(He=0,Ut=null,Ol(e,t,u,7));break;case 5:var v=null;switch(Ee.tag){case 26:v=Ee.memoizedState;case 5:case 27:var S=Ee;if(v?B0(v):S.stateNode.complete){He=0,Ut=null;var T=S.sibling;if(T!==null)Ee=T;else{var V=S.return;V!==null?(Ee=V,xr(V)):Ee=null}break t}}He=0,Ut=null,Ol(e,t,u,5);break;case 6:He=0,Ut=null,Ol(e,t,u,6);break;case 8:tu(),nt=6;break e;default:throw Error(o(462))}}Kv();break}catch(I){Fh(e,I)}while(!0);return Tn=Ba=null,R.H=s,R.A=c,Le=n,Ee!==null?0:(Qe=null,qe=0,Oi(),nt)}function Kv(){for(;Ee!==null&&!xo();)Jh(Ee)}function Jh(e){var t=bh(e.alternate,e,$n);e.memoizedProps=e.pendingProps,t===null?xr(e):Ee=t}function Ih(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=hh(n,t,t.pendingProps,t.type,void 0,qe);break;case 11:t=hh(n,t,t.pendingProps,t.type.render,t.ref,qe);break;case 5:gc(t);default:Ah(n,t),t=Ee=Zd(t,$n),t=bh(n,t,$n)}e.memoizedProps=e.pendingProps,t===null?xr(e):Ee=t}function Ol(e,t,n,s){Tn=Ba=null,gc(t),Nl=null,ys=0;var c=t.return;try{if(Bv(e,c,t,n,qe)){nt=1,ar(e,Jt(n,e.current)),Ee=null;return}}catch(u){if(c!==null)throw Ee=c,u;nt=1,ar(e,Jt(n,e.current)),Ee=null;return}t.flags&32768?(Re||s===1?e=!0:Rl||(qe&536870912)!==0?e=!1:(fa=e=!0,(s===2||s===9||s===3||s===6)&&(s=Lt.current,s!==null&&s.tag===13&&(s.flags|=16384))),Wh(t,e)):xr(t)}function xr(e){var t=e;do{if((t.flags&32768)!==0){Wh(t,fa);return}e=t.return;var n=Uv(t.alternate,t,$n);if(n!==null){Ee=n;return}if(t=t.sibling,t!==null){Ee=t;return}Ee=t=e}while(t!==null);nt===0&&(nt=5)}function Wh(e,t){do{var n=Hv(e.alternate,e);if(n!==null){n.flags&=32767,Ee=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ee=e;return}Ee=e=n}while(e!==null);nt=6,Ee=null}function Ph(e,t,n,s,c,u,v,S,T){e.cancelPendingCommit=null;do gr();while(ht!==0);if((Le&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Go,ji(e,n,u,v,S,T),e===Qe&&(Ee=Qe=null,qe=0),Dl=t,ha=e,Yn=n,Wc=u,Pc=c,$h=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Wv(Ca,function(){return l0(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=R.T,R.T=null,c=F.p,F.p=2,v=Le,Le|=4;try{Vv(e,t,n)}finally{Le=v,F.p=c,R.T=s}}ht=1,e0(),t0(),n0()}}function e0(){if(ht===1){ht=0;var e=ha,t=Dl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=R.T,R.T=null;var s=F.p;F.p=2;var c=Le;Le|=4;try{_h(t,e);var u=hu,v=Hd(e.containerInfo),S=u.focusedElem,T=u.selectionRange;if(v!==S&&S&&S.ownerDocument&&Ud(S.ownerDocument.documentElement,S)){if(T!==null&&Uo(S)){var V=T.start,I=T.end;if(I===void 0&&(I=V),"selectionStart"in S)S.selectionStart=V,S.selectionEnd=Math.min(I,S.value.length);else{var ee=S.ownerDocument||document,G=ee&&ee.defaultView||window;if(G.getSelection){var Z=G.getSelection(),de=S.textContent.length,ye=Math.min(T.start,de),Ge=T.end===void 0?ye:Math.min(T.end,de);!Z.extend&&ye>Ge&&(v=Ge,Ge=ye,ye=v);var B=zd(S,ye),D=zd(S,Ge);if(B&&D&&(Z.rangeCount!==1||Z.anchorNode!==B.node||Z.anchorOffset!==B.offset||Z.focusNode!==D.node||Z.focusOffset!==D.offset)){var U=ee.createRange();U.setStart(B.node,B.offset),Z.removeAllRanges(),ye>Ge?(Z.addRange(U),Z.extend(D.node,D.offset)):(U.setEnd(D.node,D.offset),Z.addRange(U))}}}}for(ee=[],Z=S;Z=Z.parentNode;)Z.nodeType===1&&ee.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<ee.length;S++){var W=ee[S];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}qr=!!mu,hu=mu=null}finally{Le=c,F.p=s,R.T=n}}e.current=t,ht=2}}function t0(){if(ht===2){ht=0;var e=ha,t=Dl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=R.T,R.T=null;var s=F.p;F.p=2;var c=Le;Le|=4;try{qh(e,t.alternate,t)}finally{Le=c,F.p=s,R.T=n}}ht=3}}function n0(){if(ht===4||ht===3){ht=0,go();var e=ha,t=Dl,n=Yn,s=$h;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ht=5:(ht=0,Dl=ha=null,a0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(ma=null),Ce(n),t=t.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(cn,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=R.T,c=F.p,F.p=2,R.T=null;try{for(var u=e.onRecoverableError,v=0;v<s.length;v++){var S=s[v];u(S.value,{componentStack:S.stack})}}finally{R.T=t,F.p=c}}(Yn&3)!==0&&gr(),bn(e),c=e.pendingLanes,(n&261930)!==0&&(c&42)!==0?e===eu?Bs++:(Bs=0,eu=e):Bs=0,Ls(0)}}function a0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,gs(t)))}function gr(){return e0(),t0(),n0(),l0()}function l0(){if(ht!==5)return!1;var e=ha,t=Wc;Wc=0;var n=Ce(Yn),s=R.T,c=F.p;try{F.p=32>n?32:n,R.T=null,n=Pc,Pc=null;var u=ha,v=Yn;if(ht=0,Dl=ha=null,Yn=0,(Le&6)!==0)throw Error(o(331));var S=Le;if(Le|=4,Uh(u.current),Bh(u,u.current,v,n),Le=S,Ls(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(cn,u)}catch{}return!0}finally{F.p=c,R.T=s,a0(e,t)}}function s0(e,t,n){t=Jt(n,t),t=Tc(e.stateNode,t,2),e=ra(e,t,2),e!==null&&(ka(e,2),bn(e))}function Ve(e,t,n){if(e.tag===3)s0(e,e,n);else for(;t!==null;){if(t.tag===3){s0(t,e,n);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(ma===null||!ma.has(s))){e=Jt(n,e),n=ih(2),s=ra(t,n,2),s!==null&&(rh(n,s,t,e),ka(s,2),bn(s));break}}t=t.return}}function au(e,t,n){var s=e.pingCache;if(s===null){s=e.pingCache=new Gv;var c=new Set;s.set(t,c)}else c=s.get(t),c===void 0&&(c=new Set,s.set(t,c));c.has(n)||(Zc=!0,c.add(n),e=Zv.bind(null,e,t,n),t.then(e,e))}function Zv(e,t,n){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Qe===e&&(qe&n)===n&&(nt===4||nt===3&&(qe&62914560)===qe&&300>mt()-fr?(Le&2)===0&&_l(e,0):Jc|=n,Tl===qe&&(Tl=0)),bn(e)}function i0(e,t){t===0&&(t=Ai()),e=Da(e,t),e!==null&&(ka(e,t),bn(e))}function Jv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),i0(e,n)}function Iv(e,t){var n=0;switch(e.tag){case 31:case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(n=c.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(o(314))}s!==null&&s.delete(t),i0(e,n)}function Wv(e,t){return it(e,t)}var vr=null,Bl=null,lu=!1,yr=!1,su=!1,xa=0;function bn(e){e!==Bl&&e.next===null&&(Bl===null?vr=Bl=e:Bl=Bl.next=e),yr=!0,lu||(lu=!0,ey())}function Ls(e,t){if(!su&&yr){su=!0;do for(var n=!1,s=vr;s!==null;){if(e!==0){var c=s.pendingLanes;if(c===0)var u=0;else{var v=s.suspendedLanes,S=s.pingedLanes;u=(1<<31-rt(42|e)+1)-1,u&=c&~(v&~S),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(n=!0,u0(s,u))}else u=qe,u=Pn(s,s===Qe?u:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(u&3)===0||xn(s,u)||(n=!0,u0(s,u));s=s.next}while(n);su=!1}}function Pv(){r0()}function r0(){yr=lu=!1;var e=0;xa!==0&&uy()&&(e=xa);for(var t=mt(),n=null,s=vr;s!==null;){var c=s.next,u=o0(s,t);u===0?(s.next=null,n===null?vr=c:n.next=c,c===null&&(Bl=n)):(n=s,(e!==0||(u&3)!==0)&&(yr=!0)),s=c}ht!==0&&ht!==5||Ls(e),xa!==0&&(xa=0)}function o0(e,t){for(var n=e.suspendedLanes,s=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-rt(u),S=1<<v,T=c[v];T===-1?((S&n)===0||(S&s)!==0)&&(c[v]=Si(S,t)):T<=t&&(e.expiredLanes|=S),u&=~S}if(t=Qe,n=qe,n=Pn(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,n===0||e===t&&(He===2||He===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&rn(s),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||xn(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(s!==null&&rn(s),Ce(n)){case 2:case 8:n=on;break;case 32:n=Ca;break;case 268435456:n=tl;break;default:n=Ca}return s=c0.bind(null,e),n=it(n,s),e.callbackPriority=t,e.callbackNode=n,t}return s!==null&&s!==null&&rn(s),e.callbackPriority=2,e.callbackNode=null,2}function c0(e,t){if(ht!==0&&ht!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(gr()&&e.callbackNode!==n)return null;var s=qe;return s=Pn(e,e===Qe?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Gh(e,s,t),o0(e,mt()),e.callbackNode!=null&&e.callbackNode===n?c0.bind(null,e):null)}function u0(e,t){if(gr())return null;Gh(e,t,!0)}function ey(){dy(function(){(Le&6)!==0?it(el,Pv):r0()})}function iu(){if(xa===0){var e=Sl;e===0&&(e=Ea,Ea<<=1,(Ea&261888)===0&&(Ea=256)),xa=e}return xa}function f0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ei(""+e)}function d0(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function ty(e,t,n,s,c){if(t==="submit"&&n&&n.stateNode===c){var u=f0((c[_e]||null).action),v=s.submitter;v&&(t=(t=v[_e]||null)?f0(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var S=new Ri("action","action",null,s,c);e.push({event:S,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(xa!==0){var T=v?d0(c,v):new FormData(c);Cc(n,{pending:!0,data:T,method:c.method,action:u},null,T)}}else typeof u=="function"&&(S.preventDefault(),T=v?d0(c,v):new FormData(c),Cc(n,{pending:!0,data:T,method:c.method,action:u},u,T))},currentTarget:c}]})}}for(var ru=0;ru<Yo.length;ru++){var ou=Yo[ru],ny=ou.toLowerCase(),ay=ou[0].toUpperCase()+ou.slice(1);un(ny,"on"+ay)}un(Yd,"onAnimationEnd"),un(Gd,"onAnimationIteration"),un(Xd,"onAnimationStart"),un("dblclick","onDoubleClick"),un("focusin","onFocus"),un("focusout","onBlur"),un(yv,"onTransitionRun"),un(bv,"onTransitionStart"),un(Sv,"onTransitionCancel"),un(Fd,"onTransitionEnd"),rl("onMouseEnter",["mouseout","mouseover"]),rl("onMouseLeave",["mouseout","mouseover"]),rl("onPointerEnter",["pointerout","pointerover"]),rl("onPointerLeave",["pointerout","pointerover"]),qa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qa("onBeforeInput",["compositionend","keypress","textInput","paste"]),qa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zs="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(" "),ly=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(zs));function m0(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var s=e[n],c=s.event;s=s.listeners;e:{var u=void 0;if(t)for(var v=s.length-1;0<=v;v--){var S=s[v],T=S.instance,V=S.currentTarget;if(S=S.listener,T!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=V;try{u(c)}catch(I){_i(I)}c.currentTarget=null,u=T}else for(v=0;v<s.length;v++){if(S=s[v],T=S.instance,V=S.currentTarget,S=S.listener,T!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=V;try{u(c)}catch(I){_i(I)}c.currentTarget=null,u=T}}}}function ke(e,t){var n=t[So];n===void 0&&(n=t[So]=new Set);var s=e+"__bubble";n.has(s)||(h0(t,e,2,!1),n.add(s))}function cu(e,t,n){var s=0;t&&(s|=4),h0(n,e,s,t)}var br="_reactListening"+Math.random().toString(36).slice(2);function uu(e){if(!e[br]){e[br]=!0,rd.forEach(function(n){n!=="selectionchange"&&(ly.has(n)||cu(n,!1,e),cu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[br]||(t[br]=!0,cu("selectionchange",!1,t))}}function h0(e,t,n,s){switch(Y0(t)){case 2:var c=Ty;break;case 8:c=Dy;break;default:c=wu}n=c.bind(null,t,n,e),c=void 0,!Mo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),s?c!==void 0?e.addEventListener(t,n,{capture:!0,passive:c}):e.addEventListener(t,n,!0):c!==void 0?e.addEventListener(t,n,{passive:c}):e.addEventListener(t,n,!1)}function fu(e,t,n,s,c){var u=s;if((t&1)===0&&(t&2)===0&&s!==null)e:for(;;){if(s===null)return;var v=s.tag;if(v===3||v===4){var S=s.stateNode.containerInfo;if(S===c)break;if(v===4)for(v=s.return;v!==null;){var T=v.tag;if((T===3||T===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;S!==null;){if(v=ll(S),v===null)return;if(T=v.tag,T===5||T===6||T===26||T===27){s=u=v;continue e}S=S.parentNode}}s=s.return}yd(function(){var V=u,I=ko(n),ee=[];e:{var G=Qd.get(e);if(G!==void 0){var Z=Ri,de=e;switch(e){case"keypress":if(qi(n)===0)break e;case"keydown":case"keyup":Z=Ig;break;case"focusin":de="focus",Z=_o;break;case"focusout":de="blur",Z=_o;break;case"beforeblur":case"afterblur":Z=_o;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Ad;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=Ug;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=ev;break;case Yd:case Gd:case Xd:Z=$g;break;case Fd:Z=nv;break;case"scroll":case"scrollend":Z=Lg;break;case"wheel":Z=lv;break;case"copy":case"cut":case"paste":Z=Gg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Nd;break;case"toggle":case"beforetoggle":Z=iv}var ye=(t&4)!==0,Ge=!ye&&(e==="scroll"||e==="scrollend"),B=ye?G!==null?G+"Capture":null:G;ye=[];for(var D=V,U;D!==null;){var W=D;if(U=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||U===null||B===null||(W=is(D,B),W!=null&&ye.push(Us(D,W,U))),Ge)break;D=D.return}0<ye.length&&(G=new Z(G,de,null,n,I),ee.push({event:G,listeners:ye}))}}if((t&7)===0){e:{if(G=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",G&&n!==Eo&&(de=n.relatedTarget||n.fromElement)&&(ll(de)||de[Ft]))break e;if((Z||G)&&(G=I.window===I?I:(G=I.ownerDocument)?G.defaultView||G.parentWindow:window,Z?(de=n.relatedTarget||n.toElement,Z=V,de=de?ll(de):null,de!==null&&(Ge=d(de),ye=de.tag,de!==Ge||ye!==5&&ye!==27&&ye!==6)&&(de=null)):(Z=null,de=V),Z!==de)){if(ye=Ad,W="onMouseLeave",B="onMouseEnter",D="mouse",(e==="pointerout"||e==="pointerover")&&(ye=Nd,W="onPointerLeave",B="onPointerEnter",D="pointer"),Ge=Z==null?G:ss(Z),U=de==null?G:ss(de),G=new ye(W,D+"leave",Z,n,I),G.target=Ge,G.relatedTarget=U,W=null,ll(I)===V&&(ye=new ye(B,D+"enter",de,n,I),ye.target=U,ye.relatedTarget=Ge,W=ye),Ge=W,Z&&de)t:{for(ye=sy,B=Z,D=de,U=0,W=B;W;W=ye(W))U++;W=0;for(var xe=D;xe;xe=ye(xe))W++;for(;0<U-W;)B=ye(B),U--;for(;0<W-U;)D=ye(D),W--;for(;U--;){if(B===D||D!==null&&B===D.alternate){ye=B;break t}B=ye(B),D=ye(D)}ye=null}else ye=null;Z!==null&&p0(ee,G,Z,ye,!1),de!==null&&Ge!==null&&p0(ee,Ge,de,ye,!0)}}e:{if(G=V?ss(V):window,Z=G.nodeName&&G.nodeName.toLowerCase(),Z==="select"||Z==="input"&&G.type==="file")var Oe=Td;else if(Md(G))if(Dd)Oe=xv;else{Oe=hv;var he=mv}else Z=G.nodeName,!Z||Z.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?V&&Co(V.elementType)&&(Oe=Td):Oe=pv;if(Oe&&(Oe=Oe(e,V))){Rd(ee,Oe,n,I);break e}he&&he(e,G,V),e==="focusout"&&V&&G.type==="number"&&V.memoizedProps.value!=null&&wo(G,"number",G.value)}switch(he=V?ss(V):window,e){case"focusin":(Md(he)||he.contentEditable==="true")&&(ml=he,Ho=V,hs=null);break;case"focusout":hs=Ho=ml=null;break;case"mousedown":Vo=!0;break;case"contextmenu":case"mouseup":case"dragend":Vo=!1,Vd(ee,n,I);break;case"selectionchange":if(vv)break;case"keydown":case"keyup":Vd(ee,n,I)}var je;if(Bo)e:{switch(e){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else dl?kd(e,n)&&(Me="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(Me="onCompositionStart");Me&&(wd&&n.locale!=="ko"&&(dl||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&dl&&(je=bd()):(ea=I,Ro="value"in ea?ea.value:ea.textContent,dl=!0)),he=Sr(V,Me),0<he.length&&(Me=new jd(Me,e,null,n,I),ee.push({event:Me,listeners:he}),je?Me.data=je:(je=qd(n),je!==null&&(Me.data=je)))),(je=ov?cv(e,n):uv(e,n))&&(Me=Sr(V,"onBeforeInput"),0<Me.length&&(he=new jd("onBeforeInput","beforeinput",null,n,I),ee.push({event:he,listeners:Me}),he.data=je)),ty(ee,e,V,n,I)}m0(ee,t)})}function Us(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Sr(e,t){for(var n=t+"Capture",s=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=is(e,n),c!=null&&s.unshift(Us(e,c,u)),c=is(e,t),c!=null&&s.push(Us(e,c,u))),e.tag===3)return s;e=e.return}return[]}function sy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function p0(e,t,n,s,c){for(var u=t._reactName,v=[];n!==null&&n!==s;){var S=n,T=S.alternate,V=S.stateNode;if(S=S.tag,T!==null&&T===s)break;S!==5&&S!==26&&S!==27||V===null||(T=V,c?(V=is(n,u),V!=null&&v.unshift(Us(n,V,T))):c||(V=is(n,u),V!=null&&v.push(Us(n,V,T)))),n=n.return}v.length!==0&&e.push({event:t,listeners:v})}var iy=/\r\n?/g,ry=/\u0000|\uFFFD/g;function x0(e){return(typeof e=="string"?e:""+e).replace(iy,`
|
||
`).replace(ry,"")}function g0(e,t){return t=x0(t),x0(e)===t}function Ye(e,t,n,s,c,u){switch(n){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||cl(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&cl(e,""+s);break;case"className":wi(e,"class",s);break;case"tabIndex":wi(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":wi(e,n,s);break;case"style":gd(e,s,u);break;case"data":if(t!=="object"){wi(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=Ei(""+s),e.setAttribute(n,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(n,"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 u=="function"&&(n==="formAction"?(t!=="input"&&Ye(e,t,"name",c.name,c,null),Ye(e,t,"formEncType",c.formEncType,c,null),Ye(e,t,"formMethod",c.formMethod,c,null),Ye(e,t,"formTarget",c.formTarget,c,null)):(Ye(e,t,"encType",c.encType,c,null),Ye(e,t,"method",c.method,c,null),Ye(e,t,"target",c.target,c,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=Ei(""+s),e.setAttribute(n,s);break;case"onClick":s!=null&&(e.onclick=kn);break;case"onScroll":s!=null&&ke("scroll",e);break;case"onScrollEnd":s!=null&&ke("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}n=Ei(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""+s):e.removeAttribute(n);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":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":s===!0?e.setAttribute(n,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,s):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(n,s):e.removeAttribute(n);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(n):e.setAttribute(n,s);break;case"popover":ke("beforetoggle",e),ke("toggle",e),Ni(e,"popover",s);break;case"xlinkActuate":En(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":En(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":En(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":En(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":En(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":En(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":En(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":En(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":En(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Ni(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=Og.get(n)||n,Ni(e,n,s))}}function du(e,t,n,s,c,u){switch(n){case"style":gd(e,s,u);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"children":typeof s=="string"?cl(e,s):(typeof s=="number"||typeof s=="bigint")&&cl(e,""+s);break;case"onScroll":s!=null&&ke("scroll",e);break;case"onScrollEnd":s!=null&&ke("scrollend",e);break;case"onClick":s!=null&&(e.onclick=kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!od.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(c=n.endsWith("Capture"),t=n.slice(2,c?n.length-7:void 0),u=e[_e]||null,u=u!=null?u[n]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof s=="function")){typeof u!="function"&&u!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,s,c);break e}n in e?e[n]=s:s===!0?e.setAttribute(n,""):Ni(e,n,s)}}}function At(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ke("error",e),ke("load",e);var s=!1,c=!1,u;for(u in n)if(n.hasOwnProperty(u)){var v=n[u];if(v!=null)switch(u){case"src":s=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ye(e,t,u,v,n,null)}}c&&Ye(e,t,"srcSet",n.srcSet,n,null),s&&Ye(e,t,"src",n.src,n,null);return;case"input":ke("invalid",e);var S=u=v=c=null,T=null,V=null;for(s in n)if(n.hasOwnProperty(s)){var I=n[s];if(I!=null)switch(s){case"name":c=I;break;case"type":v=I;break;case"checked":T=I;break;case"defaultChecked":V=I;break;case"value":u=I;break;case"defaultValue":S=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:Ye(e,t,s,I,n,null)}}md(e,u,S,T,V,v,c,!1);return;case"select":ke("invalid",e),s=v=u=null;for(c in n)if(n.hasOwnProperty(c)&&(S=n[c],S!=null))switch(c){case"value":u=S;break;case"defaultValue":v=S;break;case"multiple":s=S;default:Ye(e,t,c,S,n,null)}t=u,n=v,e.multiple=!!s,t!=null?ol(e,!!s,t,!1):n!=null&&ol(e,!!s,n,!0);return;case"textarea":ke("invalid",e),u=c=s=null;for(v in n)if(n.hasOwnProperty(v)&&(S=n[v],S!=null))switch(v){case"value":s=S;break;case"defaultValue":c=S;break;case"children":u=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(o(91));break;default:Ye(e,t,v,S,n,null)}pd(e,s,c,u);return;case"option":for(T in n)if(n.hasOwnProperty(T)&&(s=n[T],s!=null))switch(T){case"selected":e.selected=s&&typeof s!="function"&&typeof s!="symbol";break;default:Ye(e,t,T,s,n,null)}return;case"dialog":ke("beforetoggle",e),ke("toggle",e),ke("cancel",e),ke("close",e);break;case"iframe":case"object":ke("load",e);break;case"video":case"audio":for(s=0;s<zs.length;s++)ke(zs[s],e);break;case"image":ke("error",e),ke("load",e);break;case"details":ke("toggle",e);break;case"embed":case"source":case"link":ke("error",e),ke("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in n)if(n.hasOwnProperty(V)&&(s=n[V],s!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ye(e,t,V,s,n,null)}return;default:if(Co(t)){for(I in n)n.hasOwnProperty(I)&&(s=n[I],s!==void 0&&du(e,t,I,s,n,void 0));return}}for(S in n)n.hasOwnProperty(S)&&(s=n[S],s!=null&&Ye(e,t,S,s,n,null))}function oy(e,t,n,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,v=null,S=null,T=null,V=null,I=null;for(Z in n){var ee=n[Z];if(n.hasOwnProperty(Z)&&ee!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":T=ee;default:s.hasOwnProperty(Z)||Ye(e,t,Z,null,s,ee)}}for(var G in s){var Z=s[G];if(ee=n[G],s.hasOwnProperty(G)&&(Z!=null||ee!=null))switch(G){case"type":u=Z;break;case"name":c=Z;break;case"checked":V=Z;break;case"defaultChecked":I=Z;break;case"value":v=Z;break;case"defaultValue":S=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ee&&Ye(e,t,G,Z,s,ee)}}No(e,v,S,T,V,I,u,c);return;case"select":Z=v=S=G=null;for(u in n)if(T=n[u],n.hasOwnProperty(u)&&T!=null)switch(u){case"value":break;case"multiple":Z=T;default:s.hasOwnProperty(u)||Ye(e,t,u,null,s,T)}for(c in s)if(u=s[c],T=n[c],s.hasOwnProperty(c)&&(u!=null||T!=null))switch(c){case"value":G=u;break;case"defaultValue":S=u;break;case"multiple":v=u;default:u!==T&&Ye(e,t,c,u,s,T)}t=S,n=v,s=Z,G!=null?ol(e,!!n,G,!1):!!s!=!!n&&(t!=null?ol(e,!!n,t,!0):ol(e,!!n,n?[]:"",!1));return;case"textarea":Z=G=null;for(S in n)if(c=n[S],n.hasOwnProperty(S)&&c!=null&&!s.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:Ye(e,t,S,null,s,c)}for(v in s)if(c=s[v],u=n[v],s.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":G=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ye(e,t,v,c,s,u)}hd(e,G,Z);return;case"option":for(var de in n)if(G=n[de],n.hasOwnProperty(de)&&G!=null&&!s.hasOwnProperty(de))switch(de){case"selected":e.selected=!1;break;default:Ye(e,t,de,null,s,G)}for(T in s)if(G=s[T],Z=n[T],s.hasOwnProperty(T)&&G!==Z&&(G!=null||Z!=null))switch(T){case"selected":e.selected=G&&typeof G!="function"&&typeof G!="symbol";break;default:Ye(e,t,T,G,s,Z)}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 ye in n)G=n[ye],n.hasOwnProperty(ye)&&G!=null&&!s.hasOwnProperty(ye)&&Ye(e,t,ye,null,s,G);for(V in s)if(G=s[V],Z=n[V],s.hasOwnProperty(V)&&G!==Z&&(G!=null||Z!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(o(137,t));break;default:Ye(e,t,V,G,s,Z)}return;default:if(Co(t)){for(var Ge in n)G=n[Ge],n.hasOwnProperty(Ge)&&G!==void 0&&!s.hasOwnProperty(Ge)&&du(e,t,Ge,void 0,s,G);for(I in s)G=s[I],Z=n[I],!s.hasOwnProperty(I)||G===Z||G===void 0&&Z===void 0||du(e,t,I,G,s,Z);return}}for(var B in n)G=n[B],n.hasOwnProperty(B)&&G!=null&&!s.hasOwnProperty(B)&&Ye(e,t,B,null,s,G);for(ee in s)G=s[ee],Z=n[ee],!s.hasOwnProperty(ee)||G===Z||G==null&&Z==null||Ye(e,t,ee,G,s,Z)}function v0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function cy(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),s=0;s<n.length;s++){var c=n[s],u=c.transferSize,v=c.initiatorType,S=c.duration;if(u&&S&&v0(v)){for(v=0,S=c.responseEnd,s+=1;s<n.length;s++){var T=n[s],V=T.startTime;if(V>S)break;var I=T.transferSize,ee=T.initiatorType;I&&v0(ee)&&(T=T.responseEnd,v+=I*(T<S?1:(S-V)/(T-V)))}if(--s,t+=8*(u+v)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var mu=null,hu=null;function Ar(e){return e.nodeType===9?e:e.ownerDocument}function y0(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function b0(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function pu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var xu=null;function uy(){var e=window.event;return e&&e.type==="popstate"?e===xu?!1:(xu=e,!0):(xu=null,!1)}var S0=typeof setTimeout=="function"?setTimeout:void 0,fy=typeof clearTimeout=="function"?clearTimeout:void 0,A0=typeof Promise=="function"?Promise:void 0,dy=typeof queueMicrotask=="function"?queueMicrotask:typeof A0<"u"?function(e){return A0.resolve(null).then(e).catch(my)}:S0;function my(e){setTimeout(function(){throw e})}function ga(e){return e==="head"}function j0(e,t){var n=t,s=0;do{var c=n.nextSibling;if(e.removeChild(n),c&&c.nodeType===8)if(n=c.data,n==="/$"||n==="/&"){if(s===0){e.removeChild(c),Hl(t);return}s--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")s++;else if(n==="html")Hs(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Hs(n);for(var u=n.firstChild;u;){var v=u.nextSibling,S=u.nodeName;u[ls]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&u.rel.toLowerCase()==="stylesheet"||n.removeChild(u),u=v}}else n==="body"&&Hs(e.ownerDocument.body);n=c}while(n);Hl(t)}function N0(e,t){var n=e;e=0;do{var s=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=s}while(n)}function gu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":gu(n),Ao(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function hy(e,t,n,s){for(;e.nodeType===1;){var c=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[ls])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=tn(e.nextSibling),e===null)break}return null}function py(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=tn(e.nextSibling),e===null))return null;return e}function w0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=tn(e.nextSibling),e===null))return null;return e}function vu(e){return e.data==="$?"||e.data==="$~"}function yu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function xy(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var s=function(){t(),n.removeEventListener("DOMContentLoaded",s)};n.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function tn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var bu=null;function C0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return tn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function E0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function k0(e,t,n){switch(t=Ar(n),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Hs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ao(e)}var nn=new Map,q0=new Set;function jr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Gn=F.d;F.d={f:gy,r:vy,D:yy,C:by,L:Sy,m:Ay,X:Ny,S:jy,M:wy};function gy(){var e=Gn.f(),t=hr();return e||t}function vy(e){var t=sl(e);t!==null&&t.tag===5&&t.type==="form"?Fm(t):Gn.r(e)}var Ll=typeof document>"u"?null:document;function M0(e,t,n){var s=Ll;if(s&&typeof t=="string"&&t){var c=Kt(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof n=="string"&&(c+='[crossorigin="'+n+'"]'),q0.has(c)||(q0.add(c),e={rel:e,crossOrigin:n,href:t},s.querySelector(c)===null&&(t=s.createElement("link"),At(t,"link",e),xt(t),s.head.appendChild(t)))}}function yy(e){Gn.D(e),M0("dns-prefetch",e,null)}function by(e,t){Gn.C(e,t),M0("preconnect",e,t)}function Sy(e,t,n){Gn.L(e,t,n);var s=Ll;if(s&&e&&t){var c='link[rel="preload"][as="'+Kt(t)+'"]';t==="image"&&n&&n.imageSrcSet?(c+='[imagesrcset="'+Kt(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(c+='[imagesizes="'+Kt(n.imageSizes)+'"]')):c+='[href="'+Kt(e)+'"]';var u=c;switch(t){case"style":u=zl(e);break;case"script":u=Ul(e)}nn.has(u)||(e=b({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),nn.set(u,e),s.querySelector(c)!==null||t==="style"&&s.querySelector(Vs(u))||t==="script"&&s.querySelector($s(u))||(t=s.createElement("link"),At(t,"link",e),xt(t),s.head.appendChild(t)))}}function Ay(e,t){Gn.m(e,t);var n=Ll;if(n&&e){var s=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+Kt(s)+'"][href="'+Kt(e)+'"]',u=c;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Ul(e)}if(!nn.has(u)&&(e=b({rel:"modulepreload",href:e},t),nn.set(u,e),n.querySelector(c)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector($s(u)))return}s=n.createElement("link"),At(s,"link",e),xt(s),n.head.appendChild(s)}}}function jy(e,t,n){Gn.S(e,t,n);var s=Ll;if(s&&e){var c=il(s).hoistableStyles,u=zl(e);t=t||"default";var v=c.get(u);if(!v){var S={loading:0,preload:null};if(v=s.querySelector(Vs(u)))S.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},n),(n=nn.get(u))&&Su(e,n);var T=v=s.createElement("link");xt(T),At(T,"link",e),T._p=new Promise(function(V,I){T.onload=V,T.onerror=I}),T.addEventListener("load",function(){S.loading|=1}),T.addEventListener("error",function(){S.loading|=2}),S.loading|=4,Nr(v,t,s)}v={type:"stylesheet",instance:v,count:1,state:S},c.set(u,v)}}}function Ny(e,t){Gn.X(e,t);var n=Ll;if(n&&e){var s=il(n).hoistableScripts,c=Ul(e),u=s.get(c);u||(u=n.querySelector($s(c)),u||(e=b({src:e,async:!0},t),(t=nn.get(c))&&Au(e,t),u=n.createElement("script"),xt(u),At(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function wy(e,t){Gn.M(e,t);var n=Ll;if(n&&e){var s=il(n).hoistableScripts,c=Ul(e),u=s.get(c);u||(u=n.querySelector($s(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=nn.get(c))&&Au(e,t),u=n.createElement("script"),xt(u),At(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function R0(e,t,n,s){var c=(c=ie.current)?jr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=zl(n.href),n=il(c).hoistableStyles,s=n.get(t),s||(s={type:"style",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=zl(n.href);var u=il(c).hoistableStyles,v=u.get(e);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,v),(u=c.querySelector(Vs(e)))&&!u._p&&(v.instance=u,v.state.loading=5),nn.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},nn.set(e,n),u||Cy(c,e,n,v.state))),t&&s===null)throw Error(o(528,""));return v}if(t&&s!==null)throw Error(o(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ul(n),n=il(c).hoistableScripts,s=n.get(t),s||(s={type:"script",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function zl(e){return'href="'+Kt(e)+'"'}function Vs(e){return'link[rel="stylesheet"]['+e+"]"}function T0(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Cy(e,t,n,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),At(t,"link",n),xt(t),e.head.appendChild(t))}function Ul(e){return'[src="'+Kt(e)+'"]'}function $s(e){return"script[async]"+e}function D0(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+Kt(n.href)+'"]');if(s)return t.instance=s,xt(s),s;var c=b({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),xt(s),At(s,"style",c),Nr(s,n.precedence,e),t.instance=s;case"stylesheet":c=zl(n.href);var u=e.querySelector(Vs(c));if(u)return t.state.loading|=4,t.instance=u,xt(u),u;s=T0(n),(c=nn.get(c))&&Su(s,c),u=(e.ownerDocument||e).createElement("link"),xt(u);var v=u;return v._p=new Promise(function(S,T){v.onload=S,v.onerror=T}),At(u,"link",s),t.state.loading|=4,Nr(u,n.precedence,e),t.instance=u;case"script":return u=Ul(n.src),(c=e.querySelector($s(u)))?(t.instance=c,xt(c),c):(s=n,(c=nn.get(u))&&(s=b({},n),Au(s,c)),e=e.ownerDocument||e,c=e.createElement("script"),xt(c),At(c,"link",s),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,Nr(s,n.precedence,e));return t.instance}function Nr(e,t,n){for(var s=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=s.length?s[s.length-1]:null,u=c,v=0;v<s.length;v++){var S=s[v];if(S.dataset.precedence===t)u=S;else if(u!==c)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Su(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Au(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var wr=null;function _0(e,t,n){if(wr===null){var s=new Map,c=wr=new Map;c.set(n,s)}else c=wr,s=c.get(n),s||(s=new Map,c.set(n,s));if(s.has(e))return s;for(s.set(e,null),n=n.getElementsByTagName(e),c=0;c<n.length;c++){var u=n[c];if(!(u[ls]||u[et]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var S=s.get(v);S?S.push(u):s.set(v,[u])}}return s}function O0(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Ey(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function B0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ky(e,t,n,s){if(n.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var c=zl(s.href),u=t.querySelector(Vs(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Cr.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=u,xt(u);return}u=t.ownerDocument||t,s=T0(s),(c=nn.get(c))&&Su(s,c),u=u.createElement("link"),xt(u);var v=u;v._p=new Promise(function(S,T){v.onload=S,v.onerror=T}),At(u,"link",s),n.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=Cr.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var ju=0;function qy(e,t){return e.stylesheets&&e.count===0&&kr(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var s=setTimeout(function(){if(e.stylesheets&&kr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&ju===0&&(ju=62500*cy());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&kr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>ju?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(c)}}:null}function Cr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)kr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Er=null;function kr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Er=new Map,t.forEach(My,e),Er=null,Cr.call(e))}function My(e,t){if(!(t.state.loading&4)){var n=Er.get(e);if(n)var s=n.get(null);else{n=new Map,Er.set(e,n);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var v=c[u];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(n.set(v.dataset.precedence,v),s=v)}s&&n.set(null,s)}c=t.instance,v=c.getAttribute("data-precedence"),u=n.get(v)||s,u===s&&n.set(null,c),n.set(v,c),this.count++,s=Cr.bind(this),c.addEventListener("load",s),c.addEventListener("error",s),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Ys={$$typeof:C,Provider:null,Consumer:null,_currentValue:P,_currentValue2:P,_threadCount:0};function Ry(e,t,n,s,c,u,v,S,T){this.tag=1,this.containerInfo=e,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=as(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=as(0),this.hiddenUpdates=as(null),this.identifierPrefix=s,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=T,this.incompleteTransitions=new Map}function L0(e,t,n,s,c,u,v,S,T,V,I,ee){return e=new Ry(e,t,n,v,T,V,I,ee,S),t=1,u===!0&&(t|=24),u=Bt(3,null,null,t),e.current=u,u.stateNode=e,t=nc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:s,isDehydrated:n,cache:t},ic(u),e}function z0(e){return e?(e=xl,e):xl}function U0(e,t,n,s,c,u){c=z0(c),s.context===null?s.context=c:s.pendingContext=c,s=ia(t),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=ra(e,s,t),n!==null&&(Tt(n,e,t),Ss(n,e,t))}function H0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Nu(e,t){H0(e,t),(e=e.alternate)&&H0(e,t)}function V0(e){if(e.tag===13||e.tag===31){var t=Da(e,67108864);t!==null&&Tt(t,e,67108864),Nu(e,67108864)}}function $0(e){if(e.tag===13||e.tag===31){var t=Vt();t=Fe(t);var n=Da(e,t);n!==null&&Tt(n,e,t),Nu(e,t)}}var qr=!0;function Ty(e,t,n,s){var c=R.T;R.T=null;var u=F.p;try{F.p=2,wu(e,t,n,s)}finally{F.p=u,R.T=c}}function Dy(e,t,n,s){var c=R.T;R.T=null;var u=F.p;try{F.p=8,wu(e,t,n,s)}finally{F.p=u,R.T=c}}function wu(e,t,n,s){if(qr){var c=Cu(s);if(c===null)fu(e,t,s,Mr,n),G0(e,s);else if(Oy(c,e,t,n,s))s.stopPropagation();else if(G0(e,s),t&4&&-1<_y.indexOf(e)){for(;c!==null;){var u=sl(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=_t(u.pendingLanes);if(v!==0){var S=u;for(S.pendingLanes|=2,S.entangledLanes|=2;v;){var T=1<<31-rt(v);S.entanglements[1]|=T,v&=~T}bn(u),(Le&6)===0&&(dr=mt()+500,Ls(0))}}break;case 31:case 13:S=Da(u,2),S!==null&&Tt(S,u,2),hr(),Nu(u,2)}if(u=Cu(s),u===null&&fu(e,t,s,Mr,n),u===c)break;c=u}c!==null&&s.stopPropagation()}else fu(e,t,s,null,n)}}function Cu(e){return e=ko(e),Eu(e)}var Mr=null;function Eu(e){if(Mr=null,e=ll(e),e!==null){var t=d(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=h(t),e!==null)return e;e=null}else if(n===31){if(e=p(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Mr=e,null}function Y0(e){switch(e){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(Pa()){case el:return 2;case on:return 8;case Ca:case bi:return 32;case tl:return 268435456;default:return 32}default:return 32}}var ku=!1,va=null,ya=null,ba=null,Gs=new Map,Xs=new Map,Sa=[],_y="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 G0(e,t){switch(e){case"focusin":case"focusout":va=null;break;case"dragenter":case"dragleave":ya=null;break;case"mouseover":case"mouseout":ba=null;break;case"pointerover":case"pointerout":Gs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xs.delete(t.pointerId)}}function Fs(e,t,n,s,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:n,eventSystemFlags:s,nativeEvent:u,targetContainers:[c]},t!==null&&(t=sl(t),t!==null&&V0(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function Oy(e,t,n,s,c){switch(t){case"focusin":return va=Fs(va,e,t,n,s,c),!0;case"dragenter":return ya=Fs(ya,e,t,n,s,c),!0;case"mouseover":return ba=Fs(ba,e,t,n,s,c),!0;case"pointerover":var u=c.pointerId;return Gs.set(u,Fs(Gs.get(u)||null,e,t,n,s,c)),!0;case"gotpointercapture":return u=c.pointerId,Xs.set(u,Fs(Xs.get(u)||null,e,t,n,s,c)),!0}return!1}function X0(e){var t=ll(e.target);if(t!==null){var n=d(t);if(n!==null){if(t=n.tag,t===13){if(t=h(n),t!==null){e.blockedOn=t,vt(e.priority,function(){$0(n)});return}}else if(t===31){if(t=p(n),t!==null){e.blockedOn=t,vt(e.priority,function(){$0(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Cu(e.nativeEvent);if(n===null){n=e.nativeEvent;var s=new n.constructor(n.type,n);Eo=s,n.target.dispatchEvent(s),Eo=null}else return t=sl(n),t!==null&&V0(t),e.blockedOn=n,!1;t.shift()}return!0}function F0(e,t,n){Rr(e)&&n.delete(t)}function By(){ku=!1,va!==null&&Rr(va)&&(va=null),ya!==null&&Rr(ya)&&(ya=null),ba!==null&&Rr(ba)&&(ba=null),Gs.forEach(F0),Xs.forEach(F0)}function Tr(e,t){e.blockedOn===t&&(e.blockedOn=null,ku||(ku=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,By)))}var Dr=null;function Q0(e){Dr!==e&&(Dr=e,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){Dr===e&&(Dr=null);for(var t=0;t<e.length;t+=3){var n=e[t],s=e[t+1],c=e[t+2];if(typeof s!="function"){if(Eu(s||n)===null)continue;break}var u=sl(n);u!==null&&(e.splice(t,3),t-=3,Cc(u,{pending:!0,data:c,method:n.method,action:s},s,c))}}))}function Hl(e){function t(T){return Tr(T,e)}va!==null&&Tr(va,e),ya!==null&&Tr(ya,e),ba!==null&&Tr(ba,e),Gs.forEach(t),Xs.forEach(t);for(var n=0;n<Sa.length;n++){var s=Sa[n];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Sa.length&&(n=Sa[0],n.blockedOn===null);)X0(n),n.blockedOn===null&&Sa.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(s=0;s<n.length;s+=3){var c=n[s],u=n[s+1],v=c[_e]||null;if(typeof u=="function")v||Q0(n);else if(v){var S=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[_e]||null)S=v.formAction;else if(Eu(c)!==null)continue}else S=v.action;typeof S=="function"?n[s+1]=S:(n.splice(s,3),s-=3),Q0(n)}}}function K0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),s||setTimeout(n,20)}function n(){if(!s&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var s=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function qu(e){this._internalRoot=e}_r.prototype.render=qu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current,s=Vt();U0(n,s,e,t,null,null)},_r.prototype.unmount=qu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;U0(e.current,2,null,e,null,null),hr(),t[Ft]=null}};function _r(e){this._internalRoot=e}_r.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ue();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Sa.length&&t!==0&&t<Sa[n].priority;n++);Sa.splice(n,0,e),n===0&&X0(e)}};var Z0=l.version;if(Z0!=="19.2.0")throw Error(o(527,Z0,"19.2.0"));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Ly={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Or=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Or.isDisabled&&Or.supportsFiber)try{cn=Or.inject(Ly),pt=Or}catch{}}return Ks.createRoot=function(e,t){if(!f(e))throw Error(o(299));var n=!1,s="",c=nh,u=ah,v=lh;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=L0(e,1,!1,null,null,n,s,null,c,u,v,K0),e[Ft]=t.current,uu(e),new qu(t)},Ks.hydrateRoot=function(e,t,n){if(!f(e))throw Error(o(299));var s=!1,c="",u=nh,v=ah,S=lh,T=null;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(v=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError),n.formState!==void 0&&(T=n.formState)),t=L0(e,1,!0,t,n??null,s,c,T,u,v,S,K0),t.context=z0(null),n=t.current,s=Vt(),s=Fe(s),c=ia(s),c.callback=null,ra(n,c,s),n=s,t.current.lanes=n,ka(t,n),bn(t),e[Ft]=t.current,uu(e),new _r(t)},Ks.version="19.2.0",Ks}var sp;function Ky(){if(sp)return Tu.exports;sp=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Tu.exports=Qy(),Tu.exports}var Zy=Ky();var ip="popstate";function Jy(a={}){function l(o,f){let{pathname:d,search:h,hash:p}=o.location;return of("",{pathname:d,search:h,hash:p},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:ii(f)}return Wy(l,i,null,a)}function Pe(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function pn(a,l){if(!a){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function Iy(){return Math.random().toString(36).substring(2,10)}function rp(a,l){return{usr:a.state,key:a.key,idx:l}}function of(a,l,i=null,o){return{pathname:typeof a=="string"?a:a.pathname,search:"",hash:"",...typeof l=="string"?Wl(l):l,state:i,key:l&&l.key||o||Iy()}}function ii({pathname:a="/",search:l="",hash:i=""}){return l&&l!=="?"&&(a+=l.charAt(0)==="?"?l:"?"+l),i&&i!=="#"&&(a+=i.charAt(0)==="#"?i:"#"+i),a}function Wl(a){let l={};if(a){let i=a.indexOf("#");i>=0&&(l.hash=a.substring(i),a=a.substring(0,i));let o=a.indexOf("?");o>=0&&(l.search=a.substring(o),a=a.substring(0,o)),a&&(l.pathname=a)}return l}function Wy(a,l,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,p="POP",x=null,g=y();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function y(){return(h.state||{idx:null}).idx}function b(){p="POP";let j=y(),k=j==null?null:j-g;g=j,x&&x({action:p,location:w.location,delta:k})}function N(j,k){p="PUSH";let A=of(w.location,j,k);g=y()+1;let C=rp(A,g),_=w.createHref(A);try{h.pushState(C,"",_)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;f.location.assign(_)}d&&x&&x({action:p,location:w.location,delta:1})}function M(j,k){p="REPLACE";let A=of(w.location,j,k);g=y();let C=rp(A,g),_=w.createHref(A);h.replaceState(C,"",_),d&&x&&x({action:p,location:w.location,delta:0})}function E(j){return Py(j)}let w={get action(){return p},get location(){return a(f,h)},listen(j){if(x)throw new Error("A history only accepts one active listener");return f.addEventListener(ip,b),x=j,()=>{f.removeEventListener(ip,b),x=null}},createHref(j){return l(f,j)},createURL:E,encodeLocation(j){let k=E(j);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:N,replace:M,go(j){return h.go(j)}};return w}function Py(a,l=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),Pe(i,"No window.location.(origin|href) available to create URL");let o=typeof a=="string"?a:ii(a);return o=o.replace(/ $/,"%20"),!l&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function tx(a,l,i="/"){return eb(a,l,i,!1)}function eb(a,l,i,o){let f=typeof l=="string"?Wl(l):l,d=Jn(f.pathname||"/",i);if(d==null)return null;let h=nx(a);tb(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=db(d);p=ub(h[x],g,o)}return p}function nx(a,l=[],i=[],o="",f=!1){let d=(h,p,x=f,g)=>{let y={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&x)return;Pe(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let b=Zn([o,y.relativePath]),N=i.concat(y);h.children&&h.children.length>0&&(Pe(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),nx(h.children,l,N,b,x)),!(h.path==null&&!h.index)&&l.push({path:b,score:ob(b,h.index),routesMeta:N})};return a.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))d(h,p);else for(let x of ax(h.path))d(h,p,!0,x)}),l}function ax(a){let l=a.split("/");if(l.length===0)return[];let[i,...o]=l,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=ax(o.join("/")),p=[];return p.push(...h.map(x=>x===""?d:[d,x].join("/"))),f&&p.push(...h),p.map(x=>a.startsWith("/")&&x===""?"/":x)}function tb(a){a.sort((l,i)=>l.score!==i.score?i.score-l.score:cb(l.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var nb=/^:[\w-]+$/,ab=3,lb=2,sb=1,ib=10,rb=-2,op=a=>a==="*";function ob(a,l){let i=a.split("/"),o=i.length;return i.some(op)&&(o+=rb),l&&(o+=lb),i.filter(f=>!op(f)).reduce((f,d)=>f+(nb.test(d)?ab:d===""?sb:ib),o)}function cb(a,l){return a.length===l.length&&a.slice(0,-1).every((o,f)=>o===l[f])?a[a.length-1]-l[l.length-1]:0}function ub(a,l,i=!1){let{routesMeta:o}=a,f={},d="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,y=d==="/"?l:l.slice(d.length)||"/",b=Wr({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},y),N=x.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=Wr({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},y)),!b)return null;Object.assign(f,b.params),h.push({params:f,pathname:Zn([d,b.pathname]),pathnameBase:gb(Zn([d,b.pathnameBase])),route:N}),b.pathnameBase!=="/"&&(d=Zn([d,b.pathnameBase]))}return h}function Wr(a,l){typeof a=="string"&&(a={path:a,caseSensitive:!1,end:!0});let[i,o]=fb(a.path,a.caseSensitive,a.end),f=l.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),p=f.slice(1);return{params:o.reduce((g,{paramName:y,isOptional:b},N)=>{if(y==="*"){let E=p[N]||"";h=d.slice(0,d.length-E.length).replace(/(.)\/+$/,"$1")}const M=p[N];return b&&!M?g[y]=void 0:g[y]=(M||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:a}}function fb(a,l=!1,i=!0){pn(a==="*"||!a.endsWith("*")||a.endsWith("/*"),`Route path "${a}" will be treated as if it were "${a.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${a.replace(/\*$/,"/*")}".`);let o=[],f="^"+a.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return a.endsWith("*")?(o.push({paramName:"*"}),f+=a==="*"||a==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":a!==""&&a!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,l?void 0:"i"),o]}function db(a){try{return a.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return pn(!1,`The URL path "${a}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),a}}function Jn(a,l){if(l==="/")return a;if(!a.toLowerCase().startsWith(l.toLowerCase()))return null;let i=l.endsWith("/")?l.length-1:l.length,o=a.charAt(i);return o&&o!=="/"?null:a.slice(i)||"/"}var mb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,hb=a=>mb.test(a);function pb(a,l="/"){let{pathname:i,search:o="",hash:f=""}=typeof a=="string"?Wl(a):a,d;if(i)if(hb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),pn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=cp(i.substring(1),"/"):d=cp(i,l)}else d=l;return{pathname:d,search:vb(o),hash:yb(f)}}function cp(a,l){let i=l.replace(/\/+$/,"").split("/");return a.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Bu(a,l,i,o){return`Cannot include a '${a}' character in a manually specified \`to.${l}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function xb(a){return a.filter((l,i)=>i===0||l.route.path&&l.route.path.length>0)}function lx(a){let l=xb(a);return l.map((i,o)=>o===l.length-1?i.pathname:i.pathnameBase)}function sx(a,l,i,o=!1){let f;typeof a=="string"?f=Wl(a):(f={...a},Pe(!f.pathname||!f.pathname.includes("?"),Bu("?","pathname","search",f)),Pe(!f.pathname||!f.pathname.includes("#"),Bu("#","pathname","hash",f)),Pe(!f.search||!f.search.includes("#"),Bu("#","search","hash",f)));let d=a===""||f.pathname==="",h=d?"/":f.pathname,p;if(h==null)p=i;else{let b=l.length-1;if(!o&&h.startsWith("..")){let N=h.split("/");for(;N[0]==="..";)N.shift(),b-=1;f.pathname=N.join("/")}p=b>=0?l[b]:"/"}let x=pb(f,p),g=h&&h!=="/"&&h.endsWith("/"),y=(d||h===".")&&i.endsWith("/");return!x.pathname.endsWith("/")&&(g||y)&&(x.pathname+="/"),x}var Zn=a=>a.join("/").replace(/\/\/+/g,"/"),gb=a=>a.replace(/\/+$/,"").replace(/^\/*/,"/"),vb=a=>!a||a==="?"?"":a.startsWith("?")?a:"?"+a,yb=a=>!a||a==="#"?"":a.startsWith("#")?a:"#"+a;function bb(a){return a!=null&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.internal=="boolean"&&"data"in a}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ix=["POST","PUT","PATCH","DELETE"];new Set(ix);var Sb=["GET",...ix];new Set(Sb);var Pl=m.createContext(null);Pl.displayName="DataRouter";var so=m.createContext(null);so.displayName="DataRouterState";m.createContext(!1);var rx=m.createContext({isTransitioning:!1});rx.displayName="ViewTransition";var Ab=m.createContext(new Map);Ab.displayName="Fetchers";var jb=m.createContext(null);jb.displayName="Await";var wn=m.createContext(null);wn.displayName="Navigation";var pi=m.createContext(null);pi.displayName="Location";var In=m.createContext({outlet:null,matches:[],isDataRoute:!1});In.displayName="Route";var Ef=m.createContext(null);Ef.displayName="RouteError";function Nb(a,{relative:l}={}){Pe(xi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(wn),{hash:f,pathname:d,search:h}=gi(a,{relative:l}),p=d;return i!=="/"&&(p=d==="/"?i:Zn([i,d])),o.createHref({pathname:p,search:h,hash:f})}function xi(){return m.useContext(pi)!=null}function Wa(){return Pe(xi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(pi).location}var ox="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function cx(a){m.useContext(wn).static||m.useLayoutEffect(a)}function wb(){let{isDataRoute:a}=m.useContext(In);return a?zb():Cb()}function Cb(){Pe(xi(),"useNavigate() may be used only in the context of a <Router> component.");let a=m.useContext(Pl),{basename:l,navigator:i}=m.useContext(wn),{matches:o}=m.useContext(In),{pathname:f}=Wa(),d=JSON.stringify(lx(o)),h=m.useRef(!1);return cx(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(pn(h.current,ox),!h.current)return;if(typeof x=="number"){i.go(x);return}let y=sx(x,JSON.parse(d),f,g.relative==="path");a==null&&l!=="/"&&(y.pathname=y.pathname==="/"?l:Zn([l,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[l,i,d,f,a])}m.createContext(null);function gi(a,{relative:l}={}){let{matches:i}=m.useContext(In),{pathname:o}=Wa(),f=JSON.stringify(lx(i));return m.useMemo(()=>sx(a,JSON.parse(f),o,l==="path"),[a,f,o,l])}function Eb(a,l){return ux(a,l)}function ux(a,l,i,o,f){Pe(xi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(wn),{matches:h}=m.useContext(In),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",y=p?p.pathnameBase:"/",b=p&&p.route;{let A=b&&b.path||"";fx(g,!b||A.endsWith("*")||A.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${A}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let N=Wa(),M;if(l){let A=typeof l=="string"?Wl(l):l;Pe(y==="/"||A.pathname?.startsWith(y),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${y}" but pathname "${A.pathname}" was given in the \`location\` prop.`),M=A}else M=N;let E=M.pathname||"/",w=E;if(y!=="/"){let A=y.replace(/^\//,"").split("/");w="/"+E.replace(/^\//,"").split("/").slice(A.length).join("/")}let j=tx(a,{pathname:w});pn(b||j!=null,`No routes matched location "${M.pathname}${M.search}${M.hash}" `),pn(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${M.pathname}${M.search}${M.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let k=Tb(j&&j.map(A=>Object.assign({},A,{params:Object.assign({},x,A.params),pathname:Zn([y,d.encodeLocation?d.encodeLocation(A.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?y:Zn([y,d.encodeLocation?d.encodeLocation(A.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathnameBase])})),h,i,o,f);return l&&k?m.createElement(pi.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...M},navigationType:"POP"}},k):k}function kb(){let a=Lb(),l=bb(a)?`${a.status} ${a.statusText}`:a instanceof Error?a.message:JSON.stringify(a),i=a instanceof Error?a.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",a),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},l),i?m.createElement("pre",{style:f},i):null,h)}var qb=m.createElement(kb,null),Mb=class extends m.Component{constructor(a){super(a),this.state={location:a.location,revalidation:a.revalidation,error:a.error}}static getDerivedStateFromError(a){return{error:a}}static getDerivedStateFromProps(a,l){return l.location!==a.location||l.revalidation!=="idle"&&a.revalidation==="idle"?{error:a.error,location:a.location,revalidation:a.revalidation}:{error:a.error!==void 0?a.error:l.error,location:l.location,revalidation:a.revalidation||l.revalidation}}componentDidCatch(a,l){this.props.onError?this.props.onError(a,l):console.error("React Router caught the following error during render",a)}render(){return this.state.error!==void 0?m.createElement(In.Provider,{value:this.props.routeContext},m.createElement(Ef.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Rb({routeContext:a,match:l,children:i}){let o=m.useContext(Pl);return o&&o.static&&o.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=l.route.id),m.createElement(In.Provider,{value:a},i)}function Tb(a,l=[],i=null,o=null,f=null){if(a==null){if(!i)return null;if(i.errors)a=i.matches;else if(l.length===0&&!i.initialized&&i.matches.length>0)a=i.matches;else return null}let d=a,h=i?.errors;if(h!=null){let y=d.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);Pe(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,y+1))}let p=!1,x=-1;if(i)for(let y=0;y<d.length;y++){let b=d[y];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(x=y),b.route.id){let{loaderData:N,errors:M}=i,E=b.route.loader&&!N.hasOwnProperty(b.route.id)&&(!M||M[b.route.id]===void 0);if(b.route.lazy||E){p=!0,x>=0?d=d.slice(0,x+1):d=[d[0]];break}}}let g=i&&o?(y,b)=>{o(y,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:b})}:void 0;return d.reduceRight((y,b,N)=>{let M,E=!1,w=null,j=null;i&&(M=h&&b.route.id?h[b.route.id]:void 0,w=b.route.errorElement||qb,p&&(x<0&&N===0?(fx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,j=null):x===N&&(E=!0,j=b.route.hydrateFallbackElement||null)));let k=l.concat(d.slice(0,N+1)),A=()=>{let C;return M?C=w:E?C=j:b.route.Component?C=m.createElement(b.route.Component,null):b.route.element?C=b.route.element:C=y,m.createElement(Rb,{match:b,routeContext:{outlet:y,matches:k,isDataRoute:i!=null},children:C})};return i&&(b.route.ErrorBoundary||b.route.errorElement||N===0)?m.createElement(Mb,{location:i.location,revalidation:i.revalidation,component:w,error:M,children:A(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:g}):A()},null)}function kf(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Db(a){let l=m.useContext(Pl);return Pe(l,kf(a)),l}function _b(a){let l=m.useContext(so);return Pe(l,kf(a)),l}function Ob(a){let l=m.useContext(In);return Pe(l,kf(a)),l}function qf(a){let l=Ob(a),i=l.matches[l.matches.length-1];return Pe(i.route.id,`${a} can only be used on routes that contain a unique "id"`),i.route.id}function Bb(){return qf("useRouteId")}function Lb(){let a=m.useContext(Ef),l=_b("useRouteError"),i=qf("useRouteError");return a!==void 0?a:l.errors?.[i]}function zb(){let{router:a}=Db("useNavigate"),l=qf("useNavigate"),i=m.useRef(!1);return cx(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{pn(i.current,ox),i.current&&(typeof f=="number"?a.navigate(f):await a.navigate(f,{fromRouteId:l,...d}))},[a,l])}var up={};function fx(a,l,i){!l&&!up[a]&&(up[a]=!0,pn(!1,i))}m.memo(Ub);function Ub({routes:a,future:l,state:i,unstable_onError:o}){return ux(a,void 0,i,o,l)}function $r(a){Pe(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Hb({basename:a="/",children:l=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){Pe(!xi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=a.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=Wl(i));let{pathname:x="/",search:g="",hash:y="",state:b=null,key:N="default"}=i,M=m.useMemo(()=>{let E=Jn(x,h);return E==null?null:{location:{pathname:E,search:g,hash:y,state:b,key:N},navigationType:o}},[h,x,g,y,b,N,o]);return pn(M!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${y}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:m.createElement(wn.Provider,{value:p},m.createElement(pi.Provider,{children:l,value:M}))}function Vb({children:a,location:l}){return Eb(cf(a),l)}function cf(a,l=[]){let i=[];return m.Children.forEach(a,(o,f)=>{if(!m.isValidElement(o))return;let d=[...l,f];if(o.type===m.Fragment){i.push.apply(i,cf(o.props.children,d));return}Pe(o.type===$r,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Pe(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=cf(o.props.children,d)),i.push(h)}),i}var Yr="get",Gr="application/x-www-form-urlencoded";function io(a){return a!=null&&typeof a.tagName=="string"}function $b(a){return io(a)&&a.tagName.toLowerCase()==="button"}function Yb(a){return io(a)&&a.tagName.toLowerCase()==="form"}function Gb(a){return io(a)&&a.tagName.toLowerCase()==="input"}function Xb(a){return!!(a.metaKey||a.altKey||a.ctrlKey||a.shiftKey)}function Fb(a,l){return a.button===0&&(!l||l==="_self")&&!Xb(a)}var Br=null;function Qb(){if(Br===null)try{new FormData(document.createElement("form"),0),Br=!1}catch{Br=!0}return Br}var Kb=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Lu(a){return a!=null&&!Kb.has(a)?(pn(!1,`"${a}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Gr}"`),null):a}function Zb(a,l){let i,o,f,d,h;if(Yb(a)){let p=a.getAttribute("action");o=p?Jn(p,l):null,i=a.getAttribute("method")||Yr,f=Lu(a.getAttribute("enctype"))||Gr,d=new FormData(a)}else if($b(a)||Gb(a)&&(a.type==="submit"||a.type==="image")){let p=a.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=a.getAttribute("formaction")||p.getAttribute("action");if(o=x?Jn(x,l):null,i=a.getAttribute("formmethod")||p.getAttribute("method")||Yr,f=Lu(a.getAttribute("formenctype"))||Lu(p.getAttribute("enctype"))||Gr,d=new FormData(p,a),!Qb()){let{name:g,type:y,value:b}=a;if(y==="image"){let N=g?`${g}.`:"";d.append(`${N}x`,"0"),d.append(`${N}y`,"0")}else g&&d.append(g,b)}}else{if(io(a))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Yr,o=null,f=Gr,h=a}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Mf(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function Jb(a,l,i){let o=typeof a=="string"?new URL(a,typeof window>"u"?"server://singlefetch/":window.location.origin):a;return o.pathname==="/"?o.pathname=`_root.${i}`:l&&Jn(o.pathname,l)==="/"?o.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function Ib(a,l){if(a.id in l)return l[a.id];try{let i=await import(a.module);return l[a.id]=i,i}catch(i){return console.error(`Error loading route module \`${a.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Wb(a){return a==null?!1:a.href==null?a.rel==="preload"&&typeof a.imageSrcSet=="string"&&typeof a.imageSizes=="string":typeof a.rel=="string"&&typeof a.href=="string"}async function Pb(a,l,i){let o=await Promise.all(a.map(async f=>{let d=l.routes[f.route.id];if(d){let h=await Ib(d,i);return h.links?h.links():[]}return[]}));return a1(o.flat(1).filter(Wb).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function fp(a,l,i,o,f,d){let h=(x,g)=>i[g]?x.route.id!==i[g].route.id:!0,p=(x,g)=>i[g].pathname!==x.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==x.params["*"];return d==="assets"?l.filter((x,g)=>h(x,g)||p(x,g)):d==="data"?l.filter((x,g)=>{let y=o.routes[x.route.id];if(!y||!y.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(a,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function e1(a,l,{includeHydrateFallback:i}={}){return t1(a.map(o=>{let f=l.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function t1(a){return[...new Set(a)]}function n1(a){let l={},i=Object.keys(a).sort();for(let o of i)l[o]=a[o];return l}function a1(a,l){let i=new Set;return new Set(l),a.reduce((o,f)=>{let d=JSON.stringify(n1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function dx(){let a=m.useContext(Pl);return Mf(a,"You must render this element inside a <DataRouterContext.Provider> element"),a}function l1(){let a=m.useContext(so);return Mf(a,"You must render this element inside a <DataRouterStateContext.Provider> element"),a}var Rf=m.createContext(void 0);Rf.displayName="FrameworkContext";function mx(){let a=m.useContext(Rf);return Mf(a,"You must render this element inside a <HydratedRouter> element"),a}function s1(a,l){let i=m.useContext(Rf),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:y,onTouchStart:b}=l,N=m.useRef(null);m.useEffect(()=>{if(a==="render"&&h(!0),a==="viewport"){let w=k=>{k.forEach(A=>{h(A.isIntersecting)})},j=new IntersectionObserver(w,{threshold:.5});return N.current&&j.observe(N.current),()=>{j.disconnect()}}},[a]),m.useEffect(()=>{if(o){let w=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(w)}}},[o]);let M=()=>{f(!0)},E=()=>{f(!1),h(!1)};return i?a!=="intent"?[d,N,{}]:[d,N,{onFocus:Zs(p,M),onBlur:Zs(x,E),onMouseEnter:Zs(g,M),onMouseLeave:Zs(y,E),onTouchStart:Zs(b,M)}]:[!1,N,{}]}function Zs(a,l){return i=>{a&&a(i),i.defaultPrevented||l(i)}}function i1({page:a,...l}){let{router:i}=dx(),o=m.useMemo(()=>tx(i.routes,a,i.basename),[i.routes,a,i.basename]);return o?m.createElement(o1,{page:a,matches:o,...l}):null}function r1(a){let{manifest:l,routeModules:i}=mx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return Pb(a,l,i).then(h=>{d||f(h)}),()=>{d=!0}},[a,l,i]),o}function o1({page:a,matches:l,...i}){let o=Wa(),{manifest:f,routeModules:d}=mx(),{basename:h}=dx(),{loaderData:p,matches:x}=l1(),g=m.useMemo(()=>fp(a,l,x,f,o,"data"),[a,l,x,f,o]),y=m.useMemo(()=>fp(a,l,x,f,o,"assets"),[a,l,x,f,o]),b=m.useMemo(()=>{if(a===o.pathname+o.search+o.hash)return[];let E=new Set,w=!1;if(l.forEach(k=>{let A=f.routes[k.route.id];!A||!A.hasLoader||(!g.some(C=>C.route.id===k.route.id)&&k.route.id in p&&d[k.route.id]?.shouldRevalidate||A.hasClientLoader?w=!0:E.add(k.route.id))}),E.size===0)return[];let j=Jb(a,h,"data");return w&&E.size>0&&j.searchParams.set("_routes",l.filter(k=>E.has(k.route.id)).map(k=>k.route.id).join(",")),[j.pathname+j.search]},[h,p,o,f,g,l,a,d]),N=m.useMemo(()=>e1(y,f),[y,f]),M=r1(y);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...i})),N.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...i})),M.map(({key:E,link:w})=>m.createElement("link",{key:E,nonce:i.nonce,...w})))}function c1(...a){return l=>{a.forEach(i=>{typeof i=="function"?i(l):i!=null&&(i.current=l)})}}var hx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{hx&&(window.__reactRouterVersion="7.9.6")}catch{}function u1({basename:a,children:l,window:i}){let o=m.useRef();o.current==null&&(o.current=Jy({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>f.listen(p),[f,p]),m.createElement(Hb,{basename:a,children:l,location:d.location,navigationType:d.action,navigator:f})}var px=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xx=m.forwardRef(function({onClick:l,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:p,target:x,to:g,preventScrollReset:y,viewTransition:b,...N},M){let{basename:E}=m.useContext(wn),w=typeof g=="string"&&px.test(g),j,k=!1;if(typeof g=="string"&&w&&(j=g,hx))try{let z=new URL(window.location.href),Q=g.startsWith("//")?new URL(z.protocol+g):new URL(g),K=Jn(Q.pathname,E);Q.origin===z.origin&&K!=null?g=K+Q.search+Q.hash:k=!0}catch{pn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let A=Nb(g,{relative:f}),[C,_,L]=s1(o,N),Y=h1(g,{replace:h,state:p,target:x,preventScrollReset:y,relative:f,viewTransition:b});function O(z){l&&l(z),z.defaultPrevented||Y(z)}let X=m.createElement("a",{...N,...L,href:j||A,onClick:k||d?l:O,ref:c1(M,_),target:x,"data-discover":!w&&i==="render"?"true":void 0});return C&&!w?m.createElement(m.Fragment,null,X,m.createElement(i1,{page:A})):X});xx.displayName="Link";var f1=m.forwardRef(function({"aria-current":l="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:p,children:x,...g},y){let b=gi(h,{relative:g.relative}),N=Wa(),M=m.useContext(so),{navigator:E,basename:w}=m.useContext(wn),j=M!=null&&y1(b)&&p===!0,k=E.encodeLocation?E.encodeLocation(b).pathname:b.pathname,A=N.pathname,C=M&&M.navigation&&M.navigation.location?M.navigation.location.pathname:null;i||(A=A.toLowerCase(),C=C?C.toLowerCase():null,k=k.toLowerCase()),C&&w&&(C=Jn(C,w)||C);const _=k!=="/"&&k.endsWith("/")?k.length-1:k.length;let L=A===k||!f&&A.startsWith(k)&&A.charAt(_)==="/",Y=C!=null&&(C===k||!f&&C.startsWith(k)&&C.charAt(k.length)==="/"),O={isActive:L,isPending:Y,isTransitioning:j},X=L?l:void 0,z;typeof o=="function"?z=o(O):z=[o,L?"active":null,Y?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let Q=typeof d=="function"?d(O):d;return m.createElement(xx,{...g,"aria-current":X,className:z,ref:y,style:Q,to:h,viewTransition:p},typeof x=="function"?x(O):x)});f1.displayName="NavLink";var d1=m.forwardRef(({discover:a="render",fetcherKey:l,navigate:i,reloadDocument:o,replace:f,state:d,method:h=Yr,action:p,onSubmit:x,relative:g,preventScrollReset:y,viewTransition:b,...N},M)=>{let E=g1(),w=v1(p,{relative:g}),j=h.toLowerCase()==="get"?"get":"post",k=typeof p=="string"&&px.test(p),A=C=>{if(x&&x(C),C.defaultPrevented)return;C.preventDefault();let _=C.nativeEvent.submitter,L=_?.getAttribute("formmethod")||h;E(_||C.currentTarget,{fetcherKey:l,method:L,navigate:i,replace:f,state:d,relative:g,preventScrollReset:y,viewTransition:b})};return m.createElement("form",{ref:M,method:j,action:w,onSubmit:o?x:A,...N,"data-discover":!k&&a==="render"?"true":void 0})});d1.displayName="Form";function m1(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gx(a){let l=m.useContext(Pl);return Pe(l,m1(a)),l}function h1(a,{target:l,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let p=wb(),x=Wa(),g=gi(a,{relative:d});return m.useCallback(y=>{if(Fb(y,l)){y.preventDefault();let b=i!==void 0?i:ii(x)===ii(g);p(a,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[x,p,g,i,o,l,a,f,d,h])}var p1=0,x1=()=>`__${String(++p1)}__`;function g1(){let{router:a}=gx("useSubmit"),{basename:l}=m.useContext(wn),i=Bb();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:p,formData:x,body:g}=Zb(o,l);if(f.navigate===!1){let y=f.fetcherKey||x1();await a.fetch(y,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,flushSync:f.flushSync})}else await a.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[a,l,i])}function v1(a,{relative:l}={}){let{basename:i}=m.useContext(wn),o=m.useContext(In);Pe(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...gi(a||".",{relative:l})},h=Wa();if(a==null){d.search=h.search;let p=new URLSearchParams(d.search),x=p.getAll("index");if(x.some(y=>y==="")){p.delete("index"),x.filter(b=>b).forEach(b=>p.append("index",b));let y=p.toString();d.search=y?`?${y}`:""}}return(!a||a===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:Zn([i,d.pathname])),ii(d)}function y1(a,{relative:l}={}){let i=m.useContext(rx);Pe(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=gx("useViewTransitionState"),f=gi(a,{relative:l});if(!i.isTransitioning)return!1;let d=Jn(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=Jn(i.nextLocation.pathname,o)||i.nextLocation.pathname;return Wr(f.pathname,h)!=null||Wr(f.pathname,d)!=null}const Nn=Object.create(null);Nn.open="0";Nn.close="1";Nn.ping="2";Nn.pong="3";Nn.message="4";Nn.upgrade="5";Nn.noop="6";const Xr=Object.create(null);Object.keys(Nn).forEach(a=>{Xr[Nn[a]]=a});const uf={type:"error",data:"parser error"},vx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yx=typeof ArrayBuffer=="function",bx=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a&&a.buffer instanceof ArrayBuffer,Tf=({type:a,data:l},i,o)=>vx&&l instanceof Blob?i?o(l):dp(l,o):yx&&(l instanceof ArrayBuffer||bx(l))?i?o(l):dp(new Blob([l]),o):o(Nn[a]+(l||"")),dp=(a,l)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];l("b"+(o||""))},i.readAsDataURL(a)};function mp(a){return a instanceof Uint8Array?a:a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}let zu;function b1(a,l){if(vx&&a.data instanceof Blob)return a.data.arrayBuffer().then(mp).then(l);if(yx&&(a.data instanceof ArrayBuffer||bx(a.data)))return l(mp(a.data));Tf(a,!1,i=>{zu||(zu=new TextEncoder),l(zu.encode(i))})}const hp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ti=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let a=0;a<hp.length;a++)ti[hp.charCodeAt(a)]=a;const S1=a=>{let l=a.length*.75,i=a.length,o,f=0,d,h,p,x;a[a.length-1]==="="&&(l--,a[a.length-2]==="="&&l--);const g=new ArrayBuffer(l),y=new Uint8Array(g);for(o=0;o<i;o+=4)d=ti[a.charCodeAt(o)],h=ti[a.charCodeAt(o+1)],p=ti[a.charCodeAt(o+2)],x=ti[a.charCodeAt(o+3)],y[f++]=d<<2|h>>4,y[f++]=(h&15)<<4|p>>2,y[f++]=(p&3)<<6|x&63;return g},A1=typeof ArrayBuffer=="function",Df=(a,l)=>{if(typeof a!="string")return{type:"message",data:Sx(a,l)};const i=a.charAt(0);return i==="b"?{type:"message",data:j1(a.substring(1),l)}:Xr[i]?a.length>1?{type:Xr[i],data:a.substring(1)}:{type:Xr[i]}:uf},j1=(a,l)=>{if(A1){const i=S1(a);return Sx(i,l)}else return{base64:!0,data:a}},Sx=(a,l)=>{switch(l){case"blob":return a instanceof Blob?a:new Blob([a]);case"arraybuffer":default:return a instanceof ArrayBuffer?a:a.buffer}},Ax="",N1=(a,l)=>{const i=a.length,o=new Array(i);let f=0;a.forEach((d,h)=>{Tf(d,!1,p=>{o[h]=p,++f===i&&l(o.join(Ax))})})},w1=(a,l)=>{const i=a.split(Ax),o=[];for(let f=0;f<i.length;f++){const d=Df(i[f],l);if(o.push(d),d.type==="error")break}return o};function C1(){return new TransformStream({transform(a,l){b1(a,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}a.data&&typeof a.data!="string"&&(f[0]|=128),l.enqueue(f),l.enqueue(i)})}})}let Uu;function Lr(a){return a.reduce((l,i)=>l+i.length,0)}function zr(a,l){if(a[0].length===l)return a.shift();const i=new Uint8Array(l);let o=0;for(let f=0;f<l;f++)i[f]=a[0][o++],o===a[0].length&&(a.shift(),o=0);return a.length&&o<a[0].length&&(a[0]=a[0].slice(o)),i}function E1(a,l){Uu||(Uu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,p){for(i.push(h);;){if(o===0){if(Lr(i)<1)break;const x=zr(i,1);d=(x[0]&128)===128,f=x[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if(Lr(i)<2)break;const x=zr(i,2);f=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Lr(i)<8)break;const x=zr(i,8),g=new DataView(x.buffer,x.byteOffset,x.length),y=g.getUint32(0);if(y>Math.pow(2,21)-1){p.enqueue(uf);break}f=y*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Lr(i)<f)break;const x=zr(i,f);p.enqueue(Df(d?x:Uu.decode(x),l)),o=0}if(f===0||f>a){p.enqueue(uf);break}}}})}const jx=4;function dt(a){if(a)return k1(a)}function k1(a){for(var l in dt.prototype)a[l]=dt.prototype[l];return a}dt.prototype.on=dt.prototype.addEventListener=function(a,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(l),this};dt.prototype.once=function(a,l){function i(){this.off(a,i),l.apply(this,arguments)}return i.fn=l,this.on(a,i),this};dt.prototype.off=dt.prototype.removeListener=dt.prototype.removeAllListeners=dt.prototype.removeEventListener=function(a,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+a];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+a],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===l||o.fn===l){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+a],this};dt.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),i=this._callbacks["$"+a],o=1;o<arguments.length;o++)l[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,l)}return this};dt.prototype.emitReserved=dt.prototype.emit;dt.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]};dt.prototype.hasListeners=function(a){return!!this.listeners(a).length};const ro=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,i)=>i(l,0),ln=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),q1="arraybuffer";function Nx(a,...l){return l.reduce((i,o)=>(a.hasOwnProperty(o)&&(i[o]=a[o]),i),{})}const M1=ln.setTimeout,R1=ln.clearTimeout;function oo(a,l){l.useNativeTimers?(a.setTimeoutFn=M1.bind(ln),a.clearTimeoutFn=R1.bind(ln)):(a.setTimeoutFn=ln.setTimeout.bind(ln),a.clearTimeoutFn=ln.clearTimeout.bind(ln))}const T1=1.33;function D1(a){return typeof a=="string"?_1(a):Math.ceil((a.byteLength||a.size)*T1)}function _1(a){let l=0,i=0;for(let o=0,f=a.length;o<f;o++)l=a.charCodeAt(o),l<128?i+=1:l<2048?i+=2:l<55296||l>=57344?i+=3:(o++,i+=4);return i}function wx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function O1(a){let l="";for(let i in a)a.hasOwnProperty(i)&&(l.length&&(l+="&"),l+=encodeURIComponent(i)+"="+encodeURIComponent(a[i]));return l}function B1(a){let l={},i=a.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");l[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return l}class L1 extends Error{constructor(l,i,o){super(l),this.description=i,this.context=o,this.type="TransportError"}}class _f extends dt{constructor(l){super(),this.writable=!1,oo(this,l),this.opts=l,this.query=l.query,this.socket=l.socket,this.supportsBinary=!l.forceBase64}onError(l,i,o){return super.emitReserved("error",new L1(l,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(l){this.readyState==="open"&&this.write(l)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(l){const i=Df(l,this.socket.binaryType);this.onPacket(i)}onPacket(l){super.emitReserved("packet",l)}onClose(l){this.readyState="closed",super.emitReserved("close",l)}pause(l){}createUri(l,i={}){return l+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const l=this.opts.hostname;return l.indexOf(":")===-1?l:"["+l+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(l){const i=O1(l);return i.length?"?"+i:""}}class z1 extends _f{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(l){this.readyState="pausing";const i=()=>{this.readyState="paused",l()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(l){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};w1(l,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const l=()=>{this.write([{type:"close"}])};this.readyState==="open"?l():this.once("open",l)}write(l){this.writable=!1,N1(l,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const l=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=wx()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(l,i)}}let Cx=!1;try{Cx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const U1=Cx;function H1(){}class V1 extends z1{constructor(l){if(super(l),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||o!==l.port}}doWrite(l,i){const o=this.request({method:"POST",data:l});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=l}}class jn extends dt{constructor(l,i,o){super(),this.createRequest=l,oo(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var l;const i=Nx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(l=this._opts.cookieJar)===null||l===void 0||l.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=jn.requestsCount++,jn.requests[this._index]=this)}_onError(l){this.emitReserved("error",l,this._xhr),this._cleanup(!0)}_cleanup(l){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=H1,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete jn.requests[this._index],this._xhr=null}}_onLoad(){const l=this._xhr.responseText;l!==null&&(this.emitReserved("data",l),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}jn.requestsCount=0;jn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",pp);else if(typeof addEventListener=="function"){const a="onpagehide"in ln?"pagehide":"unload";addEventListener(a,pp,!1)}}function pp(){for(let a in jn.requests)jn.requests.hasOwnProperty(a)&&jn.requests[a].abort()}const $1=(function(){const a=Ex({xdomain:!1});return a&&a.responseType!==null})();class Y1 extends V1{constructor(l){super(l);const i=l&&l.forceBase64;this.supportsBinary=$1&&!i}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new jn(Ex,this.uri(),l)}}function Ex(a){const l=a.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||U1))return new XMLHttpRequest}catch{}if(!l)try{return new ln[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const kx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class G1 extends _f{get name(){return"websocket"}doOpen(){const l=this.uri(),i=this.opts.protocols,o=kx?{}:Nx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(l,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=l=>this.onClose({description:"websocket connection closed",context:l}),this.ws.onmessage=l=>this.onData(l.data),this.ws.onerror=l=>this.onError("websocket error",l)}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;Tf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&ro(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const l=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=wx()),this.supportsBinary||(i.b64=1),this.createUri(l,i)}}const Hu=ln.WebSocket||ln.MozWebSocket;class X1 extends G1{createSocket(l,i,o){return kx?new Hu(l,i,o):i?new Hu(l,i):new Hu(l)}doWrite(l,i){this.ws.send(i)}}class F1 extends _f{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(l){return this.emitReserved("error",l)}this._transport.closed.then(()=>{this.onClose()}).catch(l=>{this.onError("webtransport error",l)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(l=>{const i=E1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=l.readable.pipeThrough(i).getReader(),f=C1();f.readable.pipeTo(l.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),d())}).catch(p=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;this._writer.write(o).then(()=>{f&&ro(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const Q1={websocket:X1,webtransport:F1,polling:Y1},K1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Z1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ff(a){if(a.length>8e3)throw"URI too long";const l=a,i=a.indexOf("["),o=a.indexOf("]");i!=-1&&o!=-1&&(a=a.substring(0,i)+a.substring(i,o).replace(/:/g,";")+a.substring(o,a.length));let f=K1.exec(a||""),d={},h=14;for(;h--;)d[Z1[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=l,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=J1(d,d.path),d.queryKey=I1(d,d.query),d}function J1(a,l){const i=/\/{2,9}/g,o=l.replace(i,"/").split("/");return(l.slice(0,1)=="/"||l.length===0)&&o.splice(0,1),l.slice(-1)=="/"&&o.splice(o.length-1,1),o}function I1(a,l){const i={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const df=typeof addEventListener=="function"&&typeof removeEventListener=="function",Fr=[];df&&addEventListener("offline",()=>{Fr.forEach(a=>a())},!1);class Na extends dt{constructor(l,i){if(super(),this.binaryType=q1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,l&&typeof l=="object"&&(i=l,l=null),l){const o=ff(l);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=ff(i.host).host);oo(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=B1(this.opts.query)),df&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Fr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const i=Object.assign({},this.opts.query);i.EIO=jx,i.transport=l,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[l]);return new this._transportsByName[l](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const l=this.opts.rememberUpgrade&&Na.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(l);i.open(),this.setTransport(i)}setTransport(l){this.transport&&this.transport.removeAllListeners(),this.transport=l,l.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",Na.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(l){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",l),this.emitReserved("heartbeat"),l.type){case"open":this.onHandshake(JSON.parse(l.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=l.data,this._onError(i);break;case"message":this.emitReserved("data",l.data),this.emitReserved("message",l.data);break}}onHandshake(l){this.emitReserved("handshake",l),this.id=l.sid,this.transport.query.sid=l.sid,this._pingInterval=l.pingInterval,this._pingTimeout=l.pingTimeout,this._maxPayload=l.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const l=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+l,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},l),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const l=this._getWritablePackets();this.transport.send(l),this._prevBufferLen=l.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=D1(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const l=Date.now()>this._pingTimeoutTime;return l&&(this._pingTimeoutTime=0,ro(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),l}write(l,i,o){return this._sendPacket("message",l,i,o),this}send(l,i,o){return this._sendPacket("message",l,i,o),this}_sendPacket(l,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:l,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const l=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),l()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():l()}):this.upgrading?o():l()),this}_onError(l){if(Na.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",l),this._onClose("transport error",l)}_onClose(l,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),df&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Fr.indexOf(this._offlineEventListener);o!==-1&&Fr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,i),this.writeBuffer=[],this._prevBufferLen=0}}}Na.protocol=jx;class W1 extends Na{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let l=0;l<this._upgrades.length;l++)this._probe(this._upgrades[l])}_probe(l){let i=this.createTransport(l),o=!1;Na.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;Na.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const N=new Error("probe error");N.transport=i.name,this.emitReserved("upgradeError",N)}}))};function d(){o||(o=!0,y(),i.close(),i=null)}const h=b=>{const N=new Error("probe error: "+b);N.transport=i.name,d(),this.emitReserved("upgradeError",N)};function p(){h("transport closed")}function x(){h("socket closed")}function g(b){i&&b.name!==i.name&&d()}const y=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&l!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(l){this._upgrades=this._filterUpgrades(l.upgrades),super.onHandshake(l)}_filterUpgrades(l){const i=[];for(let o=0;o<l.length;o++)~this.transports.indexOf(l[o])&&i.push(l[o]);return i}}let P1=class extends W1{constructor(l,i={}){const o=typeof l=="object"?l:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>Q1[f]).filter(f=>!!f)),super(l,o)}};function eS(a,l="",i){let o=a;i=i||typeof location<"u"&&location,a==null&&(a=i.protocol+"//"+i.host),typeof a=="string"&&(a.charAt(0)==="/"&&(a.charAt(1)==="/"?a=i.protocol+a:a=i.host+a),/^(https?|wss?):\/\//.test(a)||(typeof i<"u"?a=i.protocol+"//"+a:a="https://"+a),o=ff(a)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+l,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const tS=typeof ArrayBuffer=="function",nS=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a.buffer instanceof ArrayBuffer,qx=Object.prototype.toString,aS=typeof Blob=="function"||typeof Blob<"u"&&qx.call(Blob)==="[object BlobConstructor]",lS=typeof File=="function"||typeof File<"u"&&qx.call(File)==="[object FileConstructor]";function Of(a){return tS&&(a instanceof ArrayBuffer||nS(a))||aS&&a instanceof Blob||lS&&a instanceof File}function Qr(a,l){if(!a||typeof a!="object")return!1;if(Array.isArray(a)){for(let i=0,o=a.length;i<o;i++)if(Qr(a[i]))return!0;return!1}if(Of(a))return!0;if(a.toJSON&&typeof a.toJSON=="function"&&arguments.length===1)return Qr(a.toJSON(),!0);for(const i in a)if(Object.prototype.hasOwnProperty.call(a,i)&&Qr(a[i]))return!0;return!1}function sS(a){const l=[],i=a.data,o=a;return o.data=mf(i,l),o.attachments=l.length,{packet:o,buffers:l}}function mf(a,l){if(!a)return a;if(Of(a)){const i={_placeholder:!0,num:l.length};return l.push(a),i}else if(Array.isArray(a)){const i=new Array(a.length);for(let o=0;o<a.length;o++)i[o]=mf(a[o],l);return i}else if(typeof a=="object"&&!(a instanceof Date)){const i={};for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=mf(a[o],l));return i}return a}function iS(a,l){return a.data=hf(a.data,l),delete a.attachments,a}function hf(a,l){if(!a)return a;if(a&&a._placeholder===!0){if(typeof a.num=="number"&&a.num>=0&&a.num<l.length)return l[a.num];throw new Error("illegal attachments")}else if(Array.isArray(a))for(let i=0;i<a.length;i++)a[i]=hf(a[i],l);else if(typeof a=="object")for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&(a[i]=hf(a[i],l));return a}const rS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],oS=5;var Te;(function(a){a[a.CONNECT=0]="CONNECT",a[a.DISCONNECT=1]="DISCONNECT",a[a.EVENT=2]="EVENT",a[a.ACK=3]="ACK",a[a.CONNECT_ERROR=4]="CONNECT_ERROR",a[a.BINARY_EVENT=5]="BINARY_EVENT",a[a.BINARY_ACK=6]="BINARY_ACK"})(Te||(Te={}));class cS{constructor(l){this.replacer=l}encode(l){return(l.type===Te.EVENT||l.type===Te.ACK)&&Qr(l)?this.encodeAsBinary({type:l.type===Te.EVENT?Te.BINARY_EVENT:Te.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let i=""+l.type;return(l.type===Te.BINARY_EVENT||l.type===Te.BINARY_ACK)&&(i+=l.attachments+"-"),l.nsp&&l.nsp!=="/"&&(i+=l.nsp+","),l.id!=null&&(i+=l.id),l.data!=null&&(i+=JSON.stringify(l.data,this.replacer)),i}encodeAsBinary(l){const i=sS(l),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function xp(a){return Object.prototype.toString.call(a)==="[object Object]"}class Bf extends dt{constructor(l){super(),this.reviver=l}add(l){let i;if(typeof l=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(l);const o=i.type===Te.BINARY_EVENT;o||i.type===Te.BINARY_ACK?(i.type=o?Te.EVENT:Te.ACK,this.reconstructor=new uS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Of(l)||l.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(l),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+l)}decodeString(l){let i=0;const o={type:Number(l.charAt(0))};if(Te[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Te.BINARY_EVENT||o.type===Te.BINARY_ACK){const d=i+1;for(;l.charAt(++i)!=="-"&&i!=l.length;);const h=l.substring(d,i);if(h!=Number(h)||l.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(l.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(l.charAt(i)===","||i===l.length););o.nsp=l.substring(d,i)}else o.nsp="/";const f=l.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=l.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===l.length)break}o.id=Number(l.substring(d,i+1))}if(l.charAt(++i)){const d=this.tryParse(l.substr(i));if(Bf.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(l){try{return JSON.parse(l,this.reviver)}catch{return!1}}static isPayloadValid(l,i){switch(l){case Te.CONNECT:return xp(i);case Te.DISCONNECT:return i===void 0;case Te.CONNECT_ERROR:return typeof i=="string"||xp(i);case Te.EVENT:case Te.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&rS.indexOf(i[0])===-1);case Te.ACK:case Te.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class uS{constructor(l){this.packet=l,this.buffers=[],this.reconPack=l}takeBinaryData(l){if(this.buffers.push(l),this.buffers.length===this.reconPack.attachments){const i=iS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const fS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Bf,Encoder:cS,get PacketType(){return Te},protocol:oS},Symbol.toStringTag,{value:"Module"}));function hn(a,l,i){return a.on(l,i),function(){a.off(l,i)}}const dS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Mx extends dt{constructor(l,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=l,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const l=this.io;this.subs=[hn(l,"open",this.onopen.bind(this)),hn(l,"packet",this.onpacket.bind(this)),hn(l,"error",this.onerror.bind(this)),hn(l,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...l){return l.unshift("message"),this.emit.apply(this,l),this}emit(l,...i){var o,f,d;if(dS.hasOwnProperty(l))throw new Error('"'+l.toString()+'" is a reserved event name');if(i.unshift(l),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:Te.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,b=i.pop();this._registerAckCallback(y,b),h.id=y}const p=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,x=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(l,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[l]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[l];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===l&&this.sendBuffer.splice(p,1);i.call(this,new Error("operation has timed out"))},f),h=(...p)=>{this.io.clearTimeoutFn(d),i.apply(this,p)};h.withError=!0,this.acks[l]=h}emitWithAck(l,...i){return new Promise((o,f)=>{const d=(h,p)=>h?f(h):o(p);d.withError=!0,i.push(d),this.emit(l,...i)})}_addToQueue(l){let i;typeof l[l.length-1]=="function"&&(i=l.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:l,flags:Object.assign({fromQueue:!0},this.flags)};l.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(l=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!l||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(l){l.nsp=this.nsp,this.io._packet(l)}onopen(){typeof this.auth=="function"?this.auth(l=>{this._sendConnectPacket(l)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(l){this.packet({type:Te.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},l):l})}onerror(l){this.connected||this.emitReserved("connect_error",l)}onclose(l,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",l,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(l=>{if(!this.sendBuffer.some(o=>String(o.id)===l)){const o=this.acks[l];delete this.acks[l],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(l){if(l.nsp===this.nsp)switch(l.type){case Te.CONNECT:l.data&&l.data.sid?this.onconnect(l.data.sid,l.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Te.EVENT:case Te.BINARY_EVENT:this.onevent(l);break;case Te.ACK:case Te.BINARY_ACK:this.onack(l);break;case Te.DISCONNECT:this.ondisconnect();break;case Te.CONNECT_ERROR:this.destroy();const o=new Error(l.data.message);o.data=l.data.data,this.emitReserved("connect_error",o);break}}onevent(l){const i=l.data||[];l.id!=null&&i.push(this.ack(l.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(l){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)o.apply(this,l)}super.emit.apply(this,l),this._pid&&l.length&&typeof l[l.length-1]=="string"&&(this._lastOffset=l[l.length-1])}ack(l){const i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:Te.ACK,id:l,data:f}))}}onack(l){const i=this.acks[l.id];typeof i=="function"&&(delete this.acks[l.id],i.withError&&l.data.unshift(null),i.apply(this,l.data))}onconnect(l,i){this.id=l,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(l=>this.emitEvent(l)),this.receiveBuffer=[],this.sendBuffer.forEach(l=>{this.notifyOutgoingListeners(l),this.packet(l)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(l=>l()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Te.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(l){return this.flags.compress=l,this}get volatile(){return this.flags.volatile=!0,this}timeout(l){return this.flags.timeout=l,this}onAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(l),this}prependAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(l),this}offAny(l){if(!this._anyListeners)return this;if(l){const i=this._anyListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(l),this}prependAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(l),this}offAnyOutgoing(l){if(!this._anyOutgoingListeners)return this;if(l){const i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(l){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,l.data)}}}function es(a){a=a||{},this.ms=a.min||100,this.max=a.max||1e4,this.factor=a.factor||2,this.jitter=a.jitter>0&&a.jitter<=1?a.jitter:0,this.attempts=0}es.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),i=Math.floor(l*this.jitter*a);a=(Math.floor(l*10)&1)==0?a-i:a+i}return Math.min(a,this.max)|0};es.prototype.reset=function(){this.attempts=0};es.prototype.setMin=function(a){this.ms=a};es.prototype.setMax=function(a){this.max=a};es.prototype.setJitter=function(a){this.jitter=a};class pf extends dt{constructor(l,i){var o;super(),this.nsps={},this.subs=[],l&&typeof l=="object"&&(i=l,l=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,oo(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new es({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=l;const f=i.parser||fS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(l){return arguments.length?(this._reconnection=!!l,l||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(l){return l===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=l,this)}reconnectionDelay(l){var i;return l===void 0?this._reconnectionDelay:(this._reconnectionDelay=l,(i=this.backoff)===null||i===void 0||i.setMin(l),this)}randomizationFactor(l){var i;return l===void 0?this._randomizationFactor:(this._randomizationFactor=l,(i=this.backoff)===null||i===void 0||i.setJitter(l),this)}reconnectionDelayMax(l){var i;return l===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=l,(i=this.backoff)===null||i===void 0||i.setMax(l),this)}timeout(l){return arguments.length?(this._timeout=l,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(l){if(~this._readyState.indexOf("open"))return this;this.engine=new P1(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=hn(i,"open",function(){o.onopen(),l&&l()}),d=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),l?l(p):this.maybeReconnectOnOpen()},h=hn(i,"error",d);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(f),this.subs.push(h),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(hn(l,"ping",this.onping.bind(this)),hn(l,"data",this.ondata.bind(this)),hn(l,"error",this.onerror.bind(this)),hn(l,"close",this.onclose.bind(this)),hn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(l){try{this.decoder.add(l)}catch(i){this.onclose("parse error",i)}}ondecoded(l){ro(()=>{this.emitReserved("packet",l)},this.setTimeoutFn)}onerror(l){this.emitReserved("error",l)}socket(l,i){let o=this.nsps[l];return o?this._autoConnect&&!o.active&&o.connect():(o=new Mx(this,l,i),this.nsps[l]=o),o}_destroy(l){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(l){const i=this.encoder.encode(l);for(let o=0;o<i.length;o++)this.engine.write(i[o],l.options)}cleanup(){this.subs.forEach(l=>l()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(l,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",l,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const l=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{l.skipReconnect||(this.emitReserved("reconnect_attempt",l.backoff.attempts),!l.skipReconnect&&l.open(f=>{f?(l._reconnecting=!1,l.reconnect(),this.emitReserved("reconnect_error",f)):l.onreconnect()}))},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const l=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",l)}}const Js={};function Kr(a,l){typeof a=="object"&&(l=a,a=void 0),l=l||{};const i=eS(a,l.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=Js[f]&&d in Js[f].nsps,p=l.forceNew||l["force new connection"]||l.multiplex===!1||h;let x;return p?x=new pf(o,l):(Js[f]||(Js[f]=new pf(o,l)),x=Js[f]),i.query&&!l.query&&(l.query=i.queryKey),x.socket(i.path,l)}Object.assign(Kr,{Manager:pf,Socket:Mx,io:Kr,connect:Kr});const Rx="roverSettings",mS=3600*24*365;function hS(a){try{const l=decodeURIComponent(a??"");return JSON.parse(l)}catch(l){return console.warn("Failed to parse settings cookie",l),null}}function xf(){if(typeof document>"u")return{};const a=`${Rx}=`,l=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(a));if(!l)return{};const i=l.substring(a.length);return hS(i)??{}}function gp(a){if(typeof document>"u")return!1;try{const l=encodeURIComponent(JSON.stringify(a??{})),i=`${Rx}=${l}; path=/; max-age=${mS}; samesite=strict`;return document.cookie=i,!0}catch(l){return console.warn("Failed to write settings cookie",l),!1}}const Tx=window.location.origin;console.info("[socket] connecting to",Tx);const pS=xf(),xS=pS?.page?.connectionTransport||"websocket",gS=xS==="polling"?["polling"]:["websocket","polling"],Lf=Kr(Tx,{transports:gS,timeout:15e3});Lf.on("connect_error",a=>console.error("connect_error",a.code,a.message,a.data));const Dx=m.createContext(Lf),vS=({children:a})=>r.jsx(Dx.Provider,{value:Lf,children:a}),Cn=()=>m.useContext(Dx),_x=m.createContext({connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,identifySession:async()=>{},login:async()=>{},setRole:async()=>{},requestControl:async()=>{},releaseControl:async()=>{},subscribeAll:async()=>{},homeAssistantToggle:async()=>{},homeAssistantSetState:async()=>{},homeAssistantSetLightColor:async()=>{},setNickname:async()=>{},requestVerification:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},setAudioLevels:async()=>{},llmControl:async()=>{}});function yS(a){return m.useCallback((l,i={})=>new Promise((o,f)=>{a.emit(l,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[a])}function bS({children:a}){const l=Cn(),i=yS(l),[o,f]=m.useState(null),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(null),[b,N]=m.useState(null),[M,E]=m.useState([]),[w,j]=m.useState(l.connected);m.useEffect(()=>{const C=()=>j(!0),_=()=>j(!1);return l.on("connect",C),l.on("disconnect",_),()=>{l.off("connect",C),l.off("disconnect",_)}},[l]),m.useEffect(()=>{function C(z){f(z)}function _(z=[]){h(z)}function L(z){h(Q=>[...Q.slice(-199),z])}function Y(z=[]){x(z)}function O(z){x(Q=>[...Q.slice(-199),z])}function X(z=null){const Q=z&&typeof z=="object"?z:null,K=Q?.debug?.status&&typeof Q.debug.status=="object"?Q.debug.status:null;y(Q),N(K)}return l.on("session:sync",C),l.on("log:init",_),l.on("log:entry",L),l.on("adminlog:init",Y),l.on("adminlog:entry",O),l.on("llm:state",X),l.on("alert:new",(z={})=>{E(Q=>[...Q.slice(-49),{...z,receivedAt:Date.now()}])}),()=>{l.off("session:sync",C),l.off("log:init",_),l.off("log:entry",L),l.off("adminlog:init",Y),l.off("adminlog:entry",O),l.off("llm:state",X),l.off("alert:new")}},[l]);const k=m.useMemo(()=>({login:(C,_)=>i("auth:login",{username:C,password:_}),identifySession:({cookieUserId:C,nickname:_}={})=>i("session:identify",{cookieUserId:C,nickname:_}),setRole:C=>i("session:setRole",{role:C}),requestControl:(C,_={})=>i("session:requestControl",{roverId:C,..._}),releaseControl:C=>i("session:releaseControl",{roverId:C}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(C,_)=>i("session:lockRover",{roverId:C,locked:_}),setMode:C=>i("setMode",{mode:C}),homeAssistantToggle:C=>i("homeAssistant:toggle",{entityId:C}),homeAssistantSetState:(C,_)=>i("homeAssistant:setState",{entityId:C,state:_}),homeAssistantSetLightColor:(C,_)=>i("homeAssistant:lightColor",{entityId:C,rgbColor:_}),setNickname:C=>i("nickname:set",{nickname:C}),requestVerification:()=>i("verification:request"),triggerReplay:(C=[])=>i("replay:trigger",{sources:C}),setCommunityGoal:C=>i("communityGoal:set",{text:C}),setAdminReason:C=>i("adminReason:set",{text:C}),rebootRover:C=>i("command",{roverId:C,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:C,name:_,mime:L,dataBase64:Y})=>i("audio:uploadPlay",{roverId:C,name:_,mime:L,dataBase64:Y}),stopUploadedAudio:C=>i("audio:uploadStop",{roverId:C}),setAudioLevels:(C={})=>i("audioLevels:set",C),llmControl:(C,_={})=>i("llm:control",{controls:{action:C,..._}}),pushAlert:C=>E(_=>[..._.slice(-49),{...C,receivedAt:Date.now(),id:C.id||Math.random().toString(36).slice(2)}])}),[i]),A=m.useMemo(()=>({connected:w,session:o,logs:d,adminLogs:p,llmCommentaryState:g,llmCommentaryStatus:b,alerts:M,...k}),[k,p,M,w,g,b,d,o]);return r.jsx(_x.Provider,{value:A,children:a})}function De(){return m.useContext(_x)}const Ox=m.createContext({frames:{}});function SS({children:a}){const l=Cn(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:p={},frame:x={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:p,raw:x?.data||null,receivedAt:Date.now()}}))}return l.on("sensorFrame",d),()=>{l.off("sensorFrame",d)}},[l]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(Ox.Provider,{value:f,children:a})}function zf(){return m.useContext(Ox).frames}function ts(a){const l=zf();return a?l[a]??null:null}const AS=650,jS={161:{red:!0},164:{green:!0},165:{force:!0},168:{red:!0,green:!0},169:{red:!0,force:!0},172:{green:!0,force:!0},173:{red:!0,green:!0,force:!0}};function Vu(a){if(typeof a!="number"||a<=0)return null;const l=jS[a];return l?{code:a,...l}:null}function NS(a,l={}){const i=l.holdMs||AS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(p)},[i]),m.useEffect(()=>{const p=Date.now(),x=Vu(a?.infraredCharacterLeft),g=Vu(a?.infraredCharacterRight),y=Vu(a?.infraredCharacterOmni);!x&&!g&&!y||f(b=>({left:x?{...x,ts:p}:b.left,right:g?{...g,ts:p}:b.right,omni:y?{...y,ts:p}:b.omni}))},[a?.infraredCharacterLeft,a?.infraredCharacterRight,a?.infraredCharacterOmni]),m.useEffect(()=>{const{left:p,right:x,omni:g}=o;if(!(p?.ts||x?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:p?.code??0,omni:g?.code??0,right:x?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const p=Date.now(),x=j=>{if(!j)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const k=p-j.ts,A=k<=i;return{active:A,age:k,code:j.code,red:!!(j.red&&A),green:!!(j.green&&A),force:!!(j.force&&A)}},g=x(o.left),y=x(o.right),b=x(o.omni),N=g.force||y.force||b.force,M=g.active||y.active||b.active,E=g.active&&!y.active?"right":y.active&&!g.active?"left":"center",w=(y.active?1:0)-(g.active?1:0);return{visible:M,forceDetected:N,left:g,right:y,omni:b,bias:E,balance:Math.max(-1,Math.min(1,w))}},[o.left,o.right,o.omni,i,d])}function wS(){const{connected:a,session:l}=De(),i=l?.assignment?.roverId,o=ts(i),f=o?.sensors||{},d=NS(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,p=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,g=f.batteryChargeMah,y=f.batteryCapacityMah;o?.receivedAt&&new Date(o.receivedAt).toLocaleTimeString();const b=o?.raw?o.raw:null,N=i?l?.activeDrivers?.[i]:null;return m.useMemo(()=>i?N?N===l?.socketId?"You":(l?.users||[]).find(E=>E.socketId===N)?.nickname||N.slice(0,6):"Available":"n/a",[N,i,l?.socketId,l?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[i?o?r.jsxs(r.Fragment,{children:[r.jsx(CS,{sensors:f,voltage:h,current:p,batteryTemp:x,charge:g,capacity:y}),r.jsx(ES,{sensors:f,dockState:d})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),b&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:b})]})}function CS({sensors:a,voltage:l,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",p=a?.oiMode?.label||"--",x=a?.chargingSources?.homeBase?"Yes":"No",g=a?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(Xn,{label:"Voltage",value:l??"--"}),r.jsx(Xn,{label:"Current",value:i??"--"}),r.jsx(Xn,{label:"Battery temp",value:o??"--"}),r.jsx(Xn,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(Xn,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(Xn,{label:"Charge",value:h}),r.jsx(Xn,{label:"OI mode",value:p}),r.jsx(Xn,{label:"Docked",value:x}),r.jsx(Xn,{label:"Charging state",value:g})]})}function Xn({label:a,value:l}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function ES({sensors:a,dockState:l}){const i=a?.bumpsAndWheelDrops||{},o=a?.wheelOvercurrents||{},f=[{label:"Left",value:a?.lightBumpLeftSignal},{label:"Front Left",value:a?.lightBumpFrontLeftSignal},{label:"Center Left",value:a?.lightBumpCenterLeftSignal},{label:"Center Right",value:a?.lightBumpCenterRightSignal},{label:"Front Right",value:a?.lightBumpFrontRightSignal},{label:"Right",value:a?.lightBumpRightSignal}],d=[{label:"Left",value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Front Left",value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Front Right",value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Right",value:a?.cliffRightSignal,active:a?.cliffRight}],h=[{label:"Wheel L",value:a?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:a?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:a?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:a?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Vl,{title:"Dock IR",children:[r.jsx(kS,{sensors:a}),r.jsx(qS,{state:l})]}),r.jsxs(Vl,{title:"Bumps & drops",children:[r.jsx(Fn,{label:"Bump L",value:r.jsx(Is,{active:i.bumpLeft})}),r.jsx(Fn,{label:"Bump R",value:r.jsx(Is,{active:i.bumpRight})}),r.jsx(Fn,{label:"Wheel drop L",value:r.jsx(Is,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(Fn,{label:"Wheel drop R",value:r.jsx(Is,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Vl,{title:"Light bumps (raw)",children:f.map(p=>r.jsx(Fn,{label:p.label,value:Ws(p.value)},p.label))}),r.jsx(Vl,{title:"Cliff sensors",children:d.map(p=>r.jsx(Fn,{label:p.label,value:`${Ws(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),r.jsx(Vl,{title:"Currents",children:h.map(p=>r.jsx(Fn,{label:p.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:Ws(p.value,"mA")}),p.over?r.jsx(Is,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),r.jsxs(Vl,{title:"Dirt detect",children:[r.jsx(Fn,{label:"Left",value:Ws(a?.dirtDetectLeft)}),r.jsx(Fn,{label:"Right",value:Ws(a?.dirtDetect)})]})]})}function Vl({title:a,children:l}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:a}),r.jsx("div",{className:"space-y-0.5",children:l})]})}function Fn({label:a,value:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function Is({active:a,tone:l="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=l==="red"?a?"bg-red-600 text-white":"bg-slate-700 text-slate-300":l==="amber"?a?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":a?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(a?"true":"false")})}function Ws(a,l){return a==null||Number.isNaN(a)?"--":l?`${a} ${l}`:a}function kS({sensors:a}){const l=a?.infraredCharacterLeft,i=a?.infraredCharacterRight,o=a?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(l)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function qS({state:a}){if(!a)return null;const l=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${a.left.code??"--"} (${l(a.left)}) · age ${i(a.left)}`}),r.jsx("div",{children:`Omni: ${a.omni.code??"--"} (${l(a.omni)}) · age ${i(a.omni)}`}),r.jsx("div",{children:`Right: ${a.right.code??"--"} (${l(a.right)}) · age ${i(a.right)}`})]})}const Bx=m.createContext(null);function MS({children:a}){const[l,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=xf();i({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=xf();i({status:"ready",data:p??{}})},[]),f=m.useCallback(p=>{const x=gp(p??{});return i(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),d=m.useCallback((p,x)=>{i(g=>{const y=g.data[p]||{},b=typeof x=="function"?x(y):{...y,...x??{}},N={...g.data,[p]:b};return gp(N)?{status:"ready",data:N}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:l.data,status:l.status,reload:o,saveAll:f,setNamespace:d}),[l,o,f,d]);return r.jsx(Bx.Provider,{value:h,children:a})}function RS(){const a=m.useContext(Bx);if(!a)throw new Error("useSettings must be used within SettingsProvider");return a}function We(a,l={}){const{data:i,status:o,setNamespace:f}=RS(),d=i[a]??l??{},h=m.useCallback(g=>{f(a,y=>{const b=y??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[a,f]),p=m.useCallback(g=>{f(a,()=>g??{})},[a,f]),x=m.useCallback(()=>{const g=typeof l=="object"?{...l}:l;f(a,()=>g??{})},[l,a,f]);return{value:d,status:o,save:h,replace:p,reset:x}}function TS(a=[]){return a.map(l=>!l?.type||!l?.id?null:{type:l.type,id:String(l.id),label:l.label||String(l.id),key:`${l.type}:${l.id}`}).filter(Boolean)}function Uf({panelId:a="replay-sources",fillHeight:l=!1}){const{session:i,triggerReplay:o}=De(),f=TS(i?.replaySources||[]),{value:d,save:h}=We("replaySources",{}),[p,x]=m.useState([]),[g,y]=m.useState(!1),[b,N]=m.useState(null),[M,E]=m.useState(null),w=i?.replay||null,[j,k]=m.useState(0),A=m.useMemo(()=>{const z=i?.assignment?.roverId;return z?[`rover:${z}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const z=d?.[a];if(Array.isArray(z)&&z.length){x(z);return}x(A)},[d?.[a],A,a]),m.useEffect(()=>{const z=new Set(f.map(Q=>Q.key));x(Q=>Q.filter(K=>z.has(K)))},[f]);const C=m.useMemo(()=>({rovers:f.filter(z=>z.type==="rover"),rooms:f.filter(z=>z.type==="room")}),[f]);m.useEffect(()=>{if(!w?.lastTriggeredAt||!w?.cooldownMs){k(0);return}const z=()=>{const K=w.lastTriggeredAt+w.cooldownMs-Date.now();k(Math.max(0,K))};z();const Q=setInterval(z,250);return()=>clearInterval(Q)},[w?.lastTriggeredAt,w?.cooldownMs,w?.remainingMs]);const _=g||i?.mode==="lockdown"||j>0||!p.length,L=z=>{x(Q=>{const K=Q.includes(z)?Q.filter(ae=>ae!==z):[...Q,z];return h(ae=>({...ae||{},[a]:K})),K}),E(null)},Y=async()=>{if(!_){y(!0),N(null),E(null);try{const z=p.map(Q=>{const[K,ae]=Q.split(":");return{type:K,id:ae}});await o(z),E("Replay sent. Check the Discord replay channel.")}catch(z){N(z.message)}finally{y(!1)}}},O=l?"h-full flex flex-col":"",X=l?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${O}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${X}`,children:[r.jsx(vp,{title:"Rovers",items:C.rovers,selected:p,onToggle:L}),r.jsx(vp,{title:"Room Cams",items:C.rooms,selected:p,onToggle:L})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:Y,disabled:_,children:j>0?`Replay (${Math.ceil(j/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,M?r.jsx("div",{className:"text-xs text-emerald-300",children:M}):null]})]})}function vp({title:a,items:l,selected:i,onToggle:o}){return l.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:a}),r.jsx("div",{className:"space-y-0.5",children:l.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:"truncate",children:f.label})]},f.key))})]}):null}var Lx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},yp=Ia.createContext&&Ia.createContext(Lx),DS=["attr","size","title"];function _S(a,l){if(a==null)return{};var i=OS(a,l),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);for(f=0;f<d.length;f++)o=d[f],!(l.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(i[o]=a[o])}return i}function OS(a,l){if(a==null)return{};var i={};for(var o in a)if(Object.prototype.hasOwnProperty.call(a,o)){if(l.indexOf(o)>=0)continue;i[o]=a[o]}return i}function Pr(){return Pr=Object.assign?Object.assign.bind():function(a){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=i[o])}return a},Pr.apply(this,arguments)}function bp(a,l){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);l&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(a,f).enumerable})),i.push.apply(i,o)}return i}function eo(a){for(var l=1;l<arguments.length;l++){var i=arguments[l]!=null?arguments[l]:{};l%2?bp(Object(i),!0).forEach(function(o){BS(a,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):bp(Object(i)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(i,o))})}return a}function BS(a,l,i){return l=LS(l),l in a?Object.defineProperty(a,l,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[l]=i,a}function LS(a){var l=zS(a,"string");return typeof l=="symbol"?l:l+""}function zS(a,l){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var o=i.call(a,l);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(a)}function zx(a){return a&&a.map((l,i)=>Ia.createElement(l.tag,eo({key:i},l.attr),zx(l.child)))}function vi(a){return l=>Ia.createElement(US,Pr({attr:eo({},a.attr)},l),zx(a.child))}function US(a){var l=i=>{var{attr:o,size:f,title:d}=a,h=_S(a,DS),p=f||i.size||"1em",x;return i.className&&(x=i.className),a.className&&(x=(x?x+" ":"")+a.className),Ia.createElement("svg",Pr({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:x,style:eo(eo({color:a.color||i.color},i.style),a.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),d&&Ia.createElement("title",null,d),a.children)};return yp!==void 0?Ia.createElement(yp.Consumer,null,i=>l(i)):l(Lx)}function Ux(a){return vi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(a)}function HS(a){return vi({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(a)}function Sp(a){return vi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(a)}function VS(a){return vi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(a)}function $S(a){return vi({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function YS(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Hf(a){return!!a?.system}function GS(a){const l=new Date(a);return`${l.getHours().toString().padStart(2,"0")}:${l.getMinutes().toString().padStart(2,"0")}`}function Ap(a){return a.nickname||a.socketId?.slice(0,6)||"unknown"}function XS({guildIconUrl:a,userAvatarUrl:l,label:i}){return!a&&!l?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${l?"bg-cover":""}`,style:l?{backgroundImage:`url(${l})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function Hx({message:a}){const l=a.fromDiscord?`${a.discordGuildName||"Discord"} · ${Ap(a)}`:null,i=Hf(a),o=i?"text-emerald-300":YS(a.role);return r.jsxs(r.Fragment,{children:[a.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(Ux,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(XS,{guildIconUrl:a.discordGuildIconUrl,userAvatarUrl:a.discordUserAvatarUrl,label:l})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:Ap(a)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,a.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",children:a.roverId})]})}function Vx(a){return Hf(a)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${a.role==="admin"||a.role==="lockdown"||a.role==="lockdown-admin"?"border border-amber-400/30":a.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function Vf({message:a}){const l=Hf(a);return r.jsxs("div",{className:Vx(a),children:[r.jsx(Hx,{message:a}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${l?"text-emerald-100":"text-slate-100"}`,children:a.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:GS(a.ts)})]})}function $x({message:a}){return r.jsxs("div",{className:`${Vx(a)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(Hx,{message:a}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}const FS=3e3,QS="#2196f3";function KS(a){return a.id?a.id:a.timestamp?`${a.timestamp}-${a.message}`:`${a.title||"alert"}-${a.message}`}function $f({scale:a=1}){const{alerts:l}=De(),[i,o]=m.useState(()=>Date.now()),f=m.useMemo(()=>l.slice(-3).map(x=>({alert:x,key:KS(x)})),[l]);m.useEffect(()=>{if(!f.length)return;const x=setInterval(()=>o(Date.now()),200);return()=>clearInterval(x)},[f.length]);const d=f.map(x=>({...x,age:i-(x.alert.receivedAt??x.alert.timestamp??0)})).filter(x=>x.age<=FS);if(!d.length)return null;const h=a===1?void 0:{transform:`translateX(-50%) scale(${a})`,transformOrigin:"top center"},p=a===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:p,style:h,children:d.map(x=>r.jsx(ZS,{alert:x.alert},x.key))})}function jp(a){const l=typeof a=="string"?a.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(l);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function ZS({alert:a}){if(a.kind==="chat"&&a.payload)return r.jsx(Vf,{message:a.payload});if(a.kind==="chat-typing"&&a.payload)return r.jsx($x,{message:a.payload});const l=jp(a.color)||jp(QS),i=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:a.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:a.message})]})})}const $l={main:[-127,127],side:[-127,127],vacuum:[0,127]},$u={maxSpeed:500,baseSpeed:250,boostSpeed:400},gf=100,Yf=[31,127],Zl=60,vf=8,JS=250,IS=4e3,Yu=.4,WS=.8,PS={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},ai={driveForward:["w"],driveBackward:["s"],driveLeft:["a"],driveRight:["d"],boostModifier:["\\"],slowModifier:["shift"],auxMainForward:["i"],auxMainReverse:["k"],auxSideForward:["o"],auxSideReverse:["l"],auxVacuumFast:["p"],auxVacuumSlow:[";"],auxAllForward:[","],cameraUp:["u"],cameraDown:["j"],nightVisionToggle:["e"],hornHonk:["h"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},Yx=[{id:"drive-sequence",label:"Drive",description:"Start, dock, and full command sequence used by the drive button.",steps:[{type:"servo",angle:0},{type:"oi",command:"start"},{type:"pause",duration:gf},{type:"oi",command:"dock"},{type:"pause",duration:gf},{type:"oi",command:"full"},{type:"pause",duration:300},{type:"drive",speeds:{left:-300,right:-300}},{type:"pause",duration:600},{type:"drive",speeds:{left:0,right:0}}]},{id:"seek-dock",label:"Dock",description:"Send the seek dock command.",steps:[{type:"oi",command:"dock"}]}];function yf(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function bf(){return{main:0,side:0,vacuum:0}}function eA(){return{enabled:!1,angle:null,config:null}}function Zr(){return{note:Zl}}function ni(){return{active:!1,heat:0,overheated:!1}}const Np={roverId:null,mode:"drive",drive:yf(),aux:bf(),camera:eA(),song:Zr(),horn:ni(),lastControlIntentAt:0,macros:Yx,keymap:ai,inputs:{}};function tA(a,l){switch(l.type){case"control/set-rover":return{...a,roverId:l.payload??null,drive:l.payload?a.drive:yf(),aux:l.payload?a.aux:bf(),song:l.payload?a.song:Zr(),horn:l.payload?a.horn:ni(),lastControlIntentAt:l.payload?a.lastControlIntentAt:0};case"control/set-mode":return a.mode===l.payload?a:{...a,mode:l.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=l.payload;return{...a,drive:{vector:i??a.drive.vector,speeds:o??a.drive.speeds,source:f??a.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...a,aux:{...a.aux,...l.payload}};case"control/set-camera-config":return{...a,camera:{...a.camera,enabled:!!l.payload?.config,config:l.payload?.config??null,angle:typeof l.payload?.angle=="number"?l.payload.angle:l.payload?.config?l.payload.config.homeAngle??a.camera.angle:null}};case"control/set-camera-angle":return{...a,camera:{...a.camera,angle:l.payload}};case"control/register-input-state":{const i=l.payload?.source||"unknown";return{...a,inputs:{...a.inputs,[i]:{...a.inputs[i]??{},...l.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...a,keymap:{...a.keymap,...l.payload??{}}};case"control/set-macros":return{...a,macros:Array.isArray(l.payload)?l.payload:a.macros};case"control/reset":return{...a,drive:yf(),aux:bf(),song:Zr(),horn:ni(),lastControlIntentAt:0};case"control/set-horn-active":return{...a,horn:{...a.horn||ni(),active:!!l.payload}};case"control/set-horn-heat":return{...a,horn:{...a.horn||ni(),heat:typeof l.payload?.heat=="number"?l.payload.heat:0,overheated:!!l.payload?.overheated}};case"control/record-intent":return{...a,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...a,song:{...a.song||Zr(),note:l.payload??Zl}};default:return a}}function Jl(a,l,i){return typeof a!="number"||Number.isNaN(a)?l:Math.max(l,Math.min(i,a))}function Il(a){return typeof a!="number"||Number.isNaN(a)?0:Math.max(-1,Math.min(1,a))}function an(a,l){return!Array.isArray(l)||l.length!==2?a:Jl(a,l[0],l[1])}function nA(a={}){const l=Il(a.x??0),i=Il(a.y??0);return{x:l,y:i,boost:!!a.boost}}function aA(a={},l={}){const i=nA(a),o=typeof l.maxSpeed=="number"?l.maxSpeed:$u.maxSpeed,f=typeof l.baseSpeed=="number"?l.baseSpeed:$u.baseSpeed,d=typeof l.boostSpeed=="number"?l.boostSpeed:$u.boostSpeed,h=i.boost?d:f,p=i.y*h,x=i.x*h;return{vector:i,speeds:{left:Jl(Math.round(p+x),-o,o),right:Jl(Math.round(p-x),-o,o)}}}function lA(a){const l=Array.isArray(a)?a:[],i=String.fromCharCode(...l);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(l).toString("base64");throw new Error("No base64 encoder available")}function wp(a){return new Promise(l=>setTimeout(l,a))}function sA(a={}){const{driveTransform:l,auxTransform:i}=a,o=Cn(),{session:f}=De(),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(L=>String(L.id)===String(d))||null,[d,f?.roster]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),y=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((L,Y)=>{d&&o.emit("command",{roverId:d,...L},Y)},[o,d]),N=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),M=m.useCallback(L=>{if(!d)return null;const Y={left:an(L?.left??0,[-500,500]),right:an(L?.right??0,[-500,500])},O=l?l(Y):Y,X={left:an(O?.left??0,[-500,500]),right:an(O?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:X}}),X},[l,b,d]),E=m.useCallback(({main:L=0,side:Y=0,vacuum:O=0}={})=>{if(!d)return null;const X={main:an(L,$l.main),side:an(Y,$l.side),vacuum:an(O,$l.vacuum)},z=i?i(X):X,Q={main:an(z?.main??0,$l.main),side:an(z?.side??0,$l.side),vacuum:an(z?.vacuum??0,$l.vacuum)};return b({type:"motors",data:{motorPwm:Q}}),Q},[i,b,d]),w=m.useCallback(L=>!d||!p?null:(b({type:"servo",data:{servo:{angle:L}}}),L),[b,d,p]),j=m.useCallback(L=>{if(!d)return!1;const Y=Array.isArray(L)?L:typeof L=="string"?PS[L]:null;return Y?(b({type:"raw",data:{raw:lA(Y)}}),N(),!0):!1},[b,N,d]),k=m.useCallback(async L=>{if(!(!L||!Array.isArray(L.steps)||!d))for(const Y of L.steps){if(!d)break;switch(Y.type){case"oi":j(Y.command);break;case"drive":M(Y.speeds??{left:0,right:0});break;case"motors":E(Y.values??{});break;case"servo":w(Y.angle);break;case"pause":await wp(Y.duration??gf);break}if(Y.delay||Y.delayMs){const O=Y.delayMs??Y.delay;typeof O=="number"&&O>0&&await wp(O)}}},[d,j,M,E,w]),A=m.useCallback((L="toggle")=>!d||!x?null:(b({type:"nightVision",data:{nightVision:{action:L}}}),L),[b,x,d]),C=m.useCallback(L=>d?(b({type:"horn",data:{horn:L}}),L):null,[b,d]),_=m.useCallback((L=[],Y={})=>{if(!d)return null;const X=(Array.isArray(L)&&L.length>0?L:[{note:Zl,duration:vf}]).slice(0,16).map(z=>({note:an(Math.round(z?.note??Zl),Yf),duration:an(Math.round(z?.duration??vf),[1,255])}));return b({type:"song",data:{song:{notes:X,slot:Y.slot,loop:Y.loop}}}),X},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:y,horn:g,emitCommand:b,enableSensorStream:N,sendDriveDirect:M,sendAuxMotors:E,sendServoAngle:w,sendOiCommand:j,sendNightVision:A,sendHorn:C,sendSong:_,runMacroSteps:k}),[d,h,p,x,y,g,b,N,M,E,w,j,A,C,k])}const iA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Cp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function yi(a){if(typeof a!="string")return"";const l=a.toLowerCase();return iA[l]??l}function rA(a){const l=yi(a);if(!l)return null;if(Cp[l])return Cp[l];if(l.length===1){if(/[a-z]/.test(l))return`Key${l.toUpperCase()}`;if(/[0-9]/.test(l))return`Digit${l}`}return null}function Gx(a){const l=yi(a);return l?`key:${l}`:null}function oA(a){const l=rA(a);return l?`code:${l}`:null}function Ep(a){const l=new Set,i=Gx(a?.key??"");i&&l.add(i);const o=a?.code?`code:${a.code}`:null;return o&&l.add(o),Array.from(l)}function cA(a={}){return Object.fromEntries(Object.entries(a).map(([l,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=Gx(String(d));h&&f.add(h);const p=oA(String(d));p&&f.add(p)}),[l,f]}))}function An(a){const l=yi(a);return l?l===" "?"Space":l==="\\"?"Backslash":l==="`"?"Backtick":l==="["?"[ or {":l==="]"?"] or }":l===";"?"; or :":l==="'"?`' or "`:l===","?", or <":l==="."?". or >":l==="/"?"/ or ?":l==="-"?"- or _":l==="="?"= or +":l==="arrowup"?"Arrow Up":l==="arrowdown"?"Arrow Down":l==="arrowleft"?"Arrow Left":l==="arrowright"?"Arrow Right":l.length===1?l.toUpperCase():l:"—"}const Sn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},Kn={label:"Default",calibration:{driveDeadzone:.18,cameraDeadzone:.08,auxDeadzone:.05,driveCurve:"linear",cameraCurve:"linear",auxCurve:"linear",cameraMode:"absolute",cameraSensitivity:60,auxSideScale:.55},bindings:{drive:{kind:"axisPair",sources:[{kind:"axisPair",x:0,y:1,invertX:!1,invertY:!0}]},cameraTilt:{kind:"axis",sources:[{kind:"axis",index:3,invert:!0},{kind:"axis",index:1,invert:!0}]},mainBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:6},{kind:"axis",index:2,invert:!1}]},sideBrush:{kind:"axis",sources:[{kind:"buttonAxis",index:7},{kind:"axis",index:5,invert:!1}]},vacuum:{kind:"button",sources:[{kind:"button",index:0}]},allAux:{kind:"button",sources:[{kind:"button",index:1}]},mainReverse:{kind:"button",sources:[{kind:"button",index:4}]},sideReverse:{kind:"button",sources:[{kind:"button",index:5}]},driveMacro:{kind:"button",sources:[{kind:"button",index:2}]},dockMacro:{kind:"button",sources:[{kind:"button",index:3}]},nightVisionToggle:{kind:"button",sources:[{kind:"button",index:9}]}}},ja={activeSignature:null,profiles:{},defaults:{profile:Kn}},Ja={waveform:"saw",freqs:[440,550,660,0]},jt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Fl=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],uA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function kp(){return Fl.reduce((a,l)=>(a[l.key]={cap:1,clearSec:0},a),{})}function qp(a){return Number.isFinite(a)?Math.max(0,Math.min(1,a)):0}function fA(a,l={}){const{session:i}=De(),d=(ts(a)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...uA,...l.config||{}}),[l.config]),[p,x]=m.useState(()=>kp()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),y=m.useRef(d);m.useEffect(()=>{y.current=d||{}},[d]),m.useEffect(()=>{x(kp())},[a]),m.useEffect(()=>{const E=setInterval(()=>{const w=typeof performance<"u"?performance.now():Date.now(),j=Math.max(0,w-g.current);g.current=w;const k=j/1e3;k<=0||x(A=>{let C=!1;const _={},L=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,Y=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,O=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return Fl.forEach(X=>{const z=A[X.key]||{cap:1,clearSec:0},Q=Number.isFinite(z.cap)?z.cap:1,K=Number.isFinite(z.clearSec)?z.clearSec:0,ae=X.motors.some(R=>!!y.current?.[R]),ce=ae?0:K+k,oe=!ae&&ce>=O,$=qp(ae?Q-L*k:oe?Q+Y*k:Q);(Math.abs($-Q)>1e-4||Math.abs(ce-K)>1e-4)&&(C=!0),_[X.key]={cap:$,clearSec:ce}}),C?_:A})},100);return()=>clearInterval(E)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec]);const b=m.useMemo(()=>{const E=Fl.reduce((w,j)=>{const k=p?.[j.key],A=Number.isFinite(k?.cap)?k.cap:1;return w[j.key]=qp(A),w},{});return{perGroup:E,drive:{left:E.drive??1,right:E.drive??1},aux:{main:E.aux??1,side:E.aux??1,vacuum:1}}},[p]),N=m.useMemo(()=>{const E={};Fl.forEach(j=>{j.motors.forEach(k=>{E[k]=!!d?.[k]})});const w=Fl.reduce((j,k)=>(j[k.key]=k.motors.some(A=>!!d?.[A]),j),{});return{motors:E,groups:w}},[d]),M=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:N,scales:b,isActive:(b?.drive?.left??1)<1||(b?.drive?.right??1)<1||(b?.aux?.main??1)<1||(b?.aux?.side??1)<1,config:h,adminImmune:M}),[p,N,b,h,M])}function dA(a={},l,i=!1){if(i||!l?.drive)return a;const o=typeof l.drive.left=="number"?l.drive.left:1,f=typeof l.drive.right=="number"?l.drive.right:1;return o>=.999&&f>=.999?a:{left:Math.round((a.left??0)*o),right:Math.round((a.right??0)*f)}}function mA(a={},l,i=!1){if(i||!l?.aux)return a;const o=typeof l.aux.main=="number"?l.aux.main:1,f=typeof l.aux.side=="number"?l.aux.side:1,d=typeof l.aux.vacuum=="number"?l.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?a:{main:Math.round((a.main??0)*o),side:Math.round((a.side??0)*f),vacuum:Math.round((a.vacuum??0)*d)}}const Xx=m.createContext(null);function Mp(a){return Object.fromEntries(Object.entries(a||{}).map(([l,i])=>[l,Array.isArray(i)?[...i]:[]]))}function hA(a,l){if(!a)return l;const i=typeof a.minAngle=="number"?a.minAngle:-45,o=typeof a.maxAngle=="number"?a.maxAngle:45;return Jl(l,i,o)}function pA({children:a}){const[l,i]=m.useReducer(tA,Np),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(Np.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:y}=We("controls",{keymap:ai,macros:Yx}),{value:b}=We("horn",Ja),{session:N,homeAssistantSetState:M}=De(),E=N?.assignment?.roverId??null,w=fA(E),j=m.useCallback(te=>dA(te,w.scales,w.adminImmune),[w.adminImmune,w.scales]),k=m.useCallback(te=>mA(te,w.scales,w.adminImmune),[w.adminImmune,w.scales]),A=sA({driveTransform:j,auxTransform:k}),C=m.useCallback(()=>{const J=(N?.homeAssistant?.entities||[]).filter(pe=>(pe.type==="light"||pe.type==="switch")&&pe.available!==!1&&pe.state!=="on");if(J.length===0){f.current=!1;return}f.current=!0,J.forEach(pe=>{M(pe.id,"on").catch(()=>{})}),f.current=!1},[N?.homeAssistant?.entities,M]);m.useEffect(()=>{i({type:"control/set-rover",payload:A.roverId})},[A.roverId]),m.useEffect(()=>{const te=o.current;o.current=l.mode,te!=="drive"&&l.mode==="drive"&&N?.homeAssistant?.entities?C():te!=="drive"&&l.mode==="drive"&&(f.current=!0)},[l.mode,N?.homeAssistant?.entities,C]),m.useEffect(()=>{f.current&&N?.homeAssistant?.entities&&C()},[N?.homeAssistant?.entities,C]),m.useEffect(()=>{const te={...ai,...g?.keymap||{}};i({type:"control/set-keymap",payload:te}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const te=A.servoConfig;if(!te){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const J=typeof te.minAngle=="number"?te.minAngle:-45,pe=typeof te.maxAngle=="number"?te.maxAngle:45,be=typeof te.homeAngle=="number"?te.homeAngle:(J+pe)/2,Ne=typeof d.current=="number"?Jl(d.current,J,pe):null,ze=Ne??Jl(be,J,pe);i({type:"control/set-camera-config",payload:{config:te,angle:ze}}),d.current=ze},[A.servoConfig]),m.useEffect(()=>{d.current=typeof l.camera.angle=="number"?l.camera.angle:d.current},[l.camera.angle]),m.useEffect(()=>{A.roverId&&A.enableSensorStream()},[A.roverId,A.enableSensorStream]);const _=m.useCallback(te=>{i({type:"control/set-mode",payload:te})},[]),L=m.useCallback(()=>{i({type:"control/record-intent"})},[]),Y=m.useRef(l.drive.speeds),O=m.useRef(l.aux),X=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),z=m.useRef(0),Q=m.useRef(0);m.useEffect(()=>{Y.current=l.drive.speeds},[l.drive.speeds]),m.useEffect(()=>{O.current=l.aux},[l.aux]),m.useEffect(()=>{if(!A.roverId||w.adminImmune||!w.isActive)return;const te=Math.max(0,Number(w?.config?.outputRateMs)||0),J=typeof performance<"u"?performance.now():Date.now(),pe=Y.current||{left:0,right:0},be=O.current||{main:0,side:0,vacuum:0},Ne=!!(pe.left||pe.right),ze=!!(be.main||be.side||be.vacuum);!Ne&&!ze||(Ne&&J-z.current>=te&&(z.current=J,A.sendDriveDirect(pe)),ze&&J-Q.current>=te&&(Q.current=J,A.sendAuxMotors(be)))},[X,w.adminImmune,w.config,w.isActive,A]);const K=m.useCallback((te,J={})=>{const pe=aA(te,J.speedOptions);i({type:"control/update-drive",payload:{...pe,source:J.source??null}}),L(),A.sendDriveDirect(pe.speeds)},[A,L]),ae=m.useCallback((te={})=>{const J=A.sendAuxMotors(te)??te;i({type:"control/set-aux-motors",payload:J}),L()},[A,L]),ce=m.useCallback((te,J)=>{if(!te)return!1;const pe=yi(J);if(!pe)return!1;const be=Mp(l.keymap);return be[te]=[pe],i({type:"control/set-keymap",payload:be}),y(Ne=>({...Ne??{},keymap:be})),!0},[l.keymap,y]),oe=m.useCallback(()=>{const te=Mp(ai);i({type:"control/set-keymap",payload:te}),y(J=>({...J??{},keymap:te}))},[y]),$=m.useCallback(te=>{if(!A.servoConfig)return;const J=hA(A.servoConfig,te);i({type:"control/set-camera-angle",payload:J}),A.sendServoAngle(J),d.current=J,L()},[A,L]),R=m.useCallback((te=0)=>{const J=A.servoConfig;if(!J)return;const pe=typeof te=="number"&&te!==0?te:J.nudgeDegrees||1,be=typeof d.current=="number"?d.current:typeof J.homeAngle=="number"?J.homeAngle:0;$(be+pe)},[A.servoConfig,$]),F=m.useCallback(()=>{const te=A.servoConfig;if(!te)return;const J=typeof te.homeAngle=="number"?te.homeAngle:typeof te.minAngle=="number"&&typeof te.maxAngle=="number"?(te.minAngle+te.maxAngle)/2:0;$(J)},[A.servoConfig,$]),P=m.useCallback(async te=>{const J=l.macros.find(pe=>pe.id===te)||null;J&&(te==="drive-sequence"?(C(),N?.homeAssistant?.entities||(f.current=!0),L()):te==="seek-dock"&&L(),await A.runMacroSteps(J))},[A,L,N?.homeAssistant?.entities,l.macros,C]),re=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),A.sendDriveDirect({left:0,right:0}),A.sendAuxMotors({main:0,side:0,vacuum:0})},[A]),fe=m.useCallback(te=>{A.sendOiCommand(te)},[A]),q=m.useCallback(te=>{A.roverId&&A.emitCommand({type:"sensorStream",data:{sensorStream:{enable:te}}})},[A]),H=m.useCallback(te=>{if(A.nightVision){if(typeof te=="boolean"){const J=te?"off":"on";A.sendNightVision(J)}else A.sendNightVision("toggle");L()}},[A,L]),ne=m.useCallback(()=>{H()},[H]),le=m.useCallback(te=>{const J=typeof te=="number"?te:Zl;return i({type:"control/set-song-note",payload:J}),J},[]),se=m.useCallback((te,J)=>A.sendSong(te,J),[A]),ie=m.useMemo(()=>{const te=b??Ja,J=te.waveform==="sine"?"sine":"saw",be=[...Array.isArray(te.freqs)?te.freqs:Ja.freqs,0,0,0,0].slice(0,4).map(Ne=>{const ze=Number(Ne);return Number.isFinite(ze)?ze<=0?0:Math.min(5e3,Math.round(ze)):0});return{waveform:J,freqs:be}},[b]),ue=m.useCallback(()=>{if(!A.horn)return;if(l.horn?.overheated||(l.horn?.heat??0)>=1||l.horn?.active)return!1;const te=Date.now();return A.sendHorn({action:"start",...ie}),i({type:"control/set-horn-active",payload:!0}),p.current=te,x.current=te,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{ve()},IS),L(),!0},[i,ie,A,L,l.horn?.active,l.horn?.heat,l.horn?.overheated]),ve=m.useCallback(()=>{if(!A.horn)return;A.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const te=Date.now(),J=p.current||te,pe=Math.max(0,te-J);if(p.current=0,pe>0){const be=l.horn?.heat??0,Ne=pe/1e3*Yu;let ze=Math.max(0,Math.min(1,be+Ne)),sn=l.horn?.overheated??!1;ze>=1&&(ze=1,sn=!0),i({type:"control/set-horn-heat",payload:{heat:ze,overheated:sn}})}},[i,A,l.horn?.heat,l.horn?.overheated,Yu]);m.useEffect(()=>{const J=setInterval(()=>{const pe=Date.now(),be=x.current||pe;x.current=pe;const Ne=Math.min(1e3,Math.max(0,pe-be))/1e3,ze=l.horn?.heat??0,sn=!!l.horn?.active,wa=!!l.horn?.overheated,Wn=Ne*(sn?Yu:-.2);let it=Math.max(0,Math.min(1,ze+Wn)),rn=wa;it>=1?(it=1,rn=!0,sn&&ve()):rn&&it<=WS&&(rn=!1),(it!==ze||rn!==wa)&&i({type:"control/set-horn-heat",payload:{heat:it,overheated:rn}})},100);return()=>clearInterval(J)},[i,l.horn?.active,l.horn?.heat,l.horn?.overheated,ve]);const me=m.useCallback((te,J)=>{i({type:"control/register-input-state",payload:{source:te,state:J}})},[]),we=m.useMemo(()=>({state:l,dispatch:i,pipeline:A,overcurrentLimiter:w,actions:{setMode:_,setDriveVector:K,setAuxMotors:ae,setServoAngle:$,nudgeServo:R,goServoHome:F,runMacro:P,stopAllMotion:re,sendOiCommand:fe,setSensorStream:q,setNightVision:H,toggleNightVision:ne,updateKeyBinding:ce,resetKeyBindings:oe,registerInputState:me,setSongNote:le,sendSong:se,startHorn:ue,stopHorn:ve}}),[l,A,w,_,K,ae,$,R,F,P,re,fe,q,H,ne,ce,oe,me,le,se,ue,ve]);return r.jsx(Xx.Provider,{value:we,children:a})}function Dt(){const a=m.useContext(Xx);if(!a)throw new Error("useControlSystem must be used within ControlSystemProvider");return a}const xA="data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAANAAAIpQBKSkpKSkpKXFxcXFxcXFxra2tra2tra3p6enp6enqJiYmJiYmJiZiYmJiYmJiYpqampqamprW1tbW1tbW1xMTExMTExMTT09PT09PT4uLi4uLi4uLx8fHx8fHx8f////////8AAABQTEFNRTMuMTAwBLkAAAAAAAAAABUgJAUYQQAB4AAACKVpqtMZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//ugxAAAwqQPR8CIwCh0BCj5jDwlIAAjW87wAACcOsAKPMk8ARj8w9OAWwNlV/gCgQMHEhAOVnFaNzWWAPI2zyjHjd8FAoKqyAa88AAAAABNjEd9CQOglIY9dtC+a51bGZrZgTewD3c+AAYx5hxIMheIcudKAyaykG1/h5EsPB0iTEFNRTMuMTAwqqqqqqrIBZqvAAAAAC9JXFIAHrCgAp0D0hUYOInIluqg1TNdKCzMeAAFQCKKsxUmVfireKILLBgSVgb4qBVtPWpMQU1FMy4xMDCqqqqqqqqqqqqqqqqpApm/AAAAAC7QYaHPHoCjkCysmc+QY9NNWRbKE+mqowNobwAAoSQQMLGChDlOrKMqVMC/6xy/CXbFaL7AZUxBTUUzLjEwMFVVVVVVVVVVVacDqZ8AAAAAMgzaYFBPNgIOnVCQfFfwmBBhLVNJQSdxdQRofwAGxF9xAAYs4AZDuE87li0YCASIBwaCiXUj+2BqTEFNRTMuMTAwqqqqqqqqlwOonwAAAAAtkABQSEZ1INNDgx8HeaaLCXiu5dqSciylQNXjv8GdmACQ5ogYKbnsmxkoChog+w9IhU6GsgzCIQBSxFpMQQAAMBiHjgAAAAv6FQQILmJmGLltnax9HszIVEAoEq1p8olpcPLlGpXFastuWosKNFlmlqADJbwAEFRI4iJJy0oDumUW//sgxOEAw5wfU8fnAGBvg6n5nDxUh7QuwcEzkK5Ztz7AZUxBTUUzLjEwMFVVVVVVVZUAhd8AAAAALZAAamQMWKtC7Avib0WLplt2IAp0SKV0pFFxCADLX6AIPFrWJIBQqPGW/x0QDTRLGaQYCRAZzKeoU6uqTEFN6AB3n/7wAAAxq//7EMT0AMPUHU/MawJgc4PpuYy8VQZjocBw2OgQQyQyECnbABEUC/ZoM0J56Jm0tqzNJaq8KospqUAQ5/QBghnCqQAhR4Mz1D1gJPstYsI1sYIg079I5cYjY6pMQU1FMy4xMDCqqqqq//sQxPUAw+AdT8zvAih6hCk5nWBFqqqWAFOf4AAAAEAIQZPkMcwUzFVE51cSBjIHpJRIEIjWgGar9VhgCUvwAFAUMk0RCpMkwXjPQDcoLBU+n5RuR4ZrPQLPckxBTUUzLjEwMKqqqqr/+xDE9oDEAB1NzG8CKIGEKPmd5EWqxgBWn9AAAAAKIiC5GcLJIczCEvNbWsF31jo4Bw0rXktvJF5YRyABlj+ABIQ2RGsHgdc0XsPntoEDUzaQOjTBqblFPUE1TEFNRckAt68AAAAALv/7EMT4AMQIHU3M7wIojwUo+Y2MZfAgKcwITAQIYN1TosJeLtDA0ubWNrFSADJoln4AC0hVaLiIIUChs+4HST4BgCpQHITPMBQkEnj73ORZfylh+sRLEGUiNIpMQU1FMy4xMDCqqqqq//sQxP6AxlgtK+13Yih3hCj5neBNqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrIkT7UNAZ7NS7yMqcihSKLMn8DlKYq8ZdPCVEoJBuWqkxBTUUzLjEwMKqqqqr/+xDE+ADEXCVHzGjDIIQEqLm9PIWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT+AMWoL0XNcwJoiASoeY3gVaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxPgAxHAnRcxvAmiBBKj5jehEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDE+IDEmCVDzPMCKH6EqLmNYE2qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT9gEPgI0vMZwQgvYWlPY5gFaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxOYDw+gpIIfgwWgAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",Fx=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function gA({children:a}){const l=Cn(),{session:i,pushAlert:o}=De(),{value:f}=We("audio",jt),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(!1),b=m.useRef(null),N=m.useRef(null),M=m.useRef(null),E=m.useRef(new Map),w=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),k=Number.isFinite(f?.masterVolume)?f.masterVolume:jt.masterVolume,A=Number.isFinite(f?.alertVolume)?f.alertVolume:jt.alertVolume,C=Math.max(0,Math.min(1,k*A)),_=m.useCallback(()=>{const $=Array.from(E.current.values()).sort((R,F)=>R.lastUpdate-F.lastUpdate).map(R=>R.payload);x($)},[]),L=m.useCallback($=>!$||typeof $!="object"?null:$.typingId?$.typingId:$.fromDiscord?`discord:${$.discordUserId||$.discordUserName||$.nickname||"unknown"}`:`socket:${$.socketId||$.nickname||"unknown"}`,[]);m.useEffect(()=>{M.current=new Audio(xA),M.current.volume=C,M.current.load()},[C]);const Y=m.useCallback(()=>{const $=M.current;$&&($.volume=C,$.currentTime=0,$.play().catch(()=>{}))},[C]);m.useEffect(()=>{function $(R={}){h(F=>[...F.slice(-99),R]),!(R?.socketId&&i?.socketId&&R.socketId===i.socketId)&&(Y(),o?.({kind:"chat",payload:R,id:`chat-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return l.on("chat:message",$),()=>{l.off("chat:message",$)}},[Y,i?.socketId,l]),m.useEffect(()=>{function $(R={}){const F=L(R);if(!F)return;const P=Date.now();if(R?.socketId&&i?.socketId&&R.socketId===i.socketId){R.isTyping||(E.current.delete(F),_());return}if(R.isTyping){E.current.set(F,{payload:R,expiresAt:P+6e3,lastUpdate:P});const re=w.current.get(F)||0;P-re>=2500&&(w.current.set(F,P),o?.({kind:"chat-typing",payload:R,id:`chat-typing-${F}-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:P}))}else E.current.delete(F);_()}return l.on("chat:typing",$),()=>{l.off("chat:typing",$)}},[o,_,L,i?.socketId,l]),m.useEffect(()=>{const $=setInterval(()=>{const R=Date.now();let F=!1;E.current.forEach((P,re)=>{P.expiresAt<=R&&(E.current.delete(re),F=!0)}),F&&_()},2e3);return()=>clearInterval($)},[_]),m.useEffect(()=>{function $(R=[]){Array.isArray(R)&&h(F=>{if(F.length===0)return R.slice(-100);const P=new Set(R.map(fe=>fe?.id));return[...R,...F.filter(fe=>fe?.id&&!P.has(fe.id))].slice(-100)})}return l.on("chat:init",$),()=>{l.off("chat:init",$)}},[l]);const O=m.useCallback($=>{const R=!!$,F=Date.now(),P=j.current,re=!R&&P.isTyping;!(R&&(!P.isTyping||F-P.lastSent>=3500))&&!re||(j.current={isTyping:R,lastSent:F},l.emit("chat:typing",{isTyping:R}))},[l]),X=m.useCallback(($,R=null)=>new Promise((F,P)=>{l.emit("chat:send",{text:$,tts:R},(re={})=>{re.error?P(new Error(re.error)):F(re)})}),[l]),z=m.useCallback(($,R={})=>{(R?.target==="hud"?"hud":"panel")==="hud"?N.current=$:b.current=$},[]),Q=m.useCallback(()=>{y(!0),(N.current||b.current)?.focus()},[]),K=m.useCallback(()=>{y(!1),N.current?.blur(),b.current?.blur()},[]),ae=m.useCallback(()=>y(!0),[]),ce=m.useCallback(()=>y(!1),[]),oe=m.useMemo(()=>({messages:d,sendMessage:X,focusChat:Q,blurChat:K,registerInputRef:z,onInputFocus:ae,onInputBlur:ce,setTypingActive:O,typing:p,isChatFocused:g,selfSocketId:i?.socketId||null}),[K,Q,g,d,ce,ae,z,X,i?.socketId,O,p]);return r.jsx(Fx.Provider,{value:oe,children:a})}function Gf(){const a=m.useContext(Fx);if(!a)throw new Error("useChat must be used inside ChatProvider");return a}let Qx=!1;function Gu(a){Qx=!!a}function Rp(){return Qx}const vA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function Kx(a){if(!a||a.nodeType!==1)return!1;const l=a.tagName;if(l==="TEXTAREA"||a.isContentEditable)return!0;if(l!=="INPUT")return!1;const i=a.type?a.type.toLowerCase():"";return vA.has(i)}function yA(){return typeof document>"u"?!1:Kx(document.activeElement)}const Xu="keyboard",Fu={x:0,y:0,boost:!1},Qu={main:0,side:0,vacuum:0},Tp=Yf[0],Dp=Yf[1],Xf=5,ri=500,oi=1,Ff=100;function Ku(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}function bA(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(Xf,Math.min(ri,i)):l}function Zx(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(oi,Math.min(Ff,i)):l}function SA(a){const i=(Zx(a,a)-oi)/(Ff-oi),o=ri-i*(ri-Xf);return Math.round(o)}function AA(a){const l=bA(a,a),i=(ri-l)/(ri-Xf),o=oi+i*(Ff-oi);return Math.round(o)}function jA(a){return Kx(a?.target)}function st(a,l){if(!a||a.size===0)return!1;for(const i of l)if(a.has(i))return!0;return!1}function NA(a,l){const i=st(l.driveForward,a),o=st(l.driveBackward,a),f=st(l.driveLeft,a),d=st(l.driveRight,a),h=st(l.boostModifier,a),p=st(l.slowModifier,a);let x=0;i&&!o?x=1:o&&!i&&(x=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const y=p?.4:1;return{x:g*y,y:x*y,boost:h&&!p}}function wA(a,l){if(st(l.auxAllForward,a))return{main:127,side:127,vacuum:127};const o=st(l.auxMainForward,a)?127:st(l.auxMainReverse,a)?-127:0,f=st(l.auxSideForward,a)?127:st(l.auxSideReverse,a)?-70:0,d=st(l.auxVacuumFast,a)?127:st(l.auxVacuumSlow,a)?50:0;return{main:o,side:f,vacuum:d}}function CA(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:y,setSongNote:b,sendSong:N}}=Dt(),{session:M,homeAssistantSetState:E}=De(),{focusChat:w,blurChat:j,isChatFocused:k}=Gf(),{value:A}=We("inputs",Sn),C=m.useMemo(()=>cA(a.keymap),[a.keymap]),_=m.useMemo(()=>{const se=new Set;return Object.values(C).forEach(ie=>{ie&&ie.forEach(ue=>se.add(ue))}),se},[C]),L=m.useMemo(()=>{const se=Sn.keyboard,ie=A?.keyboard??{};return{baseSpeed:Ku(ie.baseSpeed,se.baseSpeed),turboSpeed:Ku(ie.turboSpeed,se.turboSpeed),precisionSpeed:Ku(ie.precisionSpeed,se.precisionSpeed)}},[A?.keyboard]),Y=m.useMemo(()=>{const se=Sn.keyboard,ie=A?.keyboard??{},ue=Zx(typeof ie.tiltSpeed=="number"?ie.tiltSpeed:typeof ie.tiltIntervalMs=="number"?AA(ie.tiltIntervalMs):se.tiltSpeed,se.tiltSpeed);return SA(ue)},[A?.keyboard]),O=m.useMemo(()=>Math.abs(a.camera?.config?.nudgeDegrees||1),[a.camera?.config?.nudgeDegrees]),X=m.useRef(new Set),z=m.useRef(Fu),Q=m.useRef(Qu),K=m.useRef(null),ae=m.useRef(null),ce=m.useRef(!1),oe=m.useCallback(()=>{const se=new Set(X.current);st(C.boostModifier,se);const ue=st(C.slowModifier,se)?{baseSpeed:L.precisionSpeed,boostSpeed:L.precisionSpeed}:{baseSpeed:L.baseSpeed,boostSpeed:L.turboSpeed},ve=NA(se,C),me=wA(se,C);(ve.x!==z.current.x||ve.y!==z.current.y||ve.boost!==z.current.boost)&&(z.current=ve,i(ve,{source:Xu,speedOptions:ue})),(me.main!==Q.current.main||me.side!==Q.current.side||me.vacuum!==Q.current.vacuum)&&(Q.current=me,o(me)),p(Xu,{keys:Array.from(se),vector:ve,aux:me})},[C,L,p,o,i]),$=m.useCallback(()=>{K.current&&(clearTimeout(K.current),K.current=null)},[]),R=m.useCallback(()=>{const se=new Set(X.current),ie=st(C.cameraUp,se),ue=st(C.cameraDown,se);return(ie?1:0)-(ue?1:0)},[C]),F=m.useCallback(()=>{if(R()===0){$();return}if(K.current)return;const ie=()=>{const ue=R();if(ue===0){$();return}f(ue*O),K.current=setTimeout(ie,Y)};K.current=setTimeout(ie,0)},[R,f,Y,O,$]),P=m.useCallback(()=>{ae.current&&(clearTimeout(ae.current),ae.current=null)},[]),re=m.useCallback(()=>{const se=new Set(X.current),ie=st(C.songNoteUp,se),ue=st(C.songNoteDown,se);return(ie?1:0)-(ue?1:0)},[C]),fe=m.useCallback(se=>{if(se===0)return;let ue=(typeof a.song?.note=="number"?a.song.note:Zl)+se;ue>Dp?ue=Tp:ue<Tp&&(ue=Dp);const ve=b(ue);N([{note:ve,duration:vf}],{slot:0})},[N,b,a.song?.note]),q=m.useCallback(()=>{if(re()===0){P();return}if(ae.current)return;const ie=()=>{const ue=re();if(ue===0){P();return}fe(ue),ae.current=setTimeout(ie,JS)};ae.current=setTimeout(ie,0)},[re,P,fe]),H=m.useCallback(()=>{X.current.clear(),z.current=Fu,Q.current=Qu,$(),P(),ce.current&&(ce.current=!1,y()),h(),p(Xu,{keys:[],vector:Fu,aux:Qu})},[p,h,y,$,P]),ne=m.useCallback(se=>{const ie=M?.homeAssistant;if(!ie?.enabled||!ie?.connected)return;const ve=(ie.entities||[]).filter(me=>(me.type==="light"||me.type==="switch")&&me.available!==!1&&me.state!=="unavailable");if(ve.length!==0){if(se==="on"){const me=ve.find(we=>we.state!=="on");me&&E(me.id,"on").catch(()=>{});return}if(se==="off")for(let me=ve.length-1;me>=0;me-=1){const we=ve[me];if(we.state==="on"){E(we.id,"off").catch(()=>{});break}}}},[E,M?.homeAssistant]);m.useEffect(()=>{function se(ve){if(Rp()||jA(ve))return;const me=Ep(ve);if(me.length===0)return;const we=new Set(me);if(st(C.chatFocus,we)){ve.preventDefault(),H(),k||w();return}me.some(J=>_.has(J))&&ve.preventDefault();const te=me.filter(J=>!X.current.has(J));if(te.forEach(J=>X.current.add(J)),te.length>0)if(te.some(J=>C.driveMacro?.has(J)))l("drive"),d("drive-sequence");else if(te.some(J=>C.dockMacro?.has(J)))l("dock"),d("seek-dock");else if(te.some(J=>C.nightVisionToggle?.has(J)))x();else if(te.some(J=>C.hornHonk?.has(J))){if(!ce.current){const J=g();ce.current=!!J}}else te.some(J=>C.homeAssistantOn?.has(J))?ne("on"):te.some(J=>C.homeAssistantOff?.has(J))&&ne("off");F(),q(),oe()}function ie(ve){if(Rp())return;Ep(ve).forEach(we=>X.current.delete(we)),ce.current&&!st(C.hornHonk,X.current)&&(ce.current=!1,y()),F(),q(),oe()}function ue(){H()}return window.addEventListener("keydown",se,{capture:!0}),window.addEventListener("keyup",ie,{capture:!0}),window.addEventListener("blur",ue),()=>{window.removeEventListener("keydown",se,{capture:!0}),window.removeEventListener("keyup",ie,{capture:!0}),window.removeEventListener("blur",ue)}},[_,j,oe,F,q,w,k,C.chatFocus,C.dockMacro,C.driveMacro,C.hornHonk,H,d,l,h,P,g,y,ne]);const le=m.useRef(H);return m.useEffect(()=>{le.current=H},[H]),m.useEffect(()=>{le.current()},[a.roverId]),m.useEffect(()=>{ce.current=!!a.horn?.active},[a.horn?.active]),m.useEffect(()=>()=>{$(),P()},[$,P]),null}const EA=1.6;function Jx(a){if(!a)return"unknown::none::0::0";const l=a.id||"unknown",i=a.mapping||"none",o=Array.isArray(a.axes)?a.axes.length:0,f=Array.isArray(a.buttons)?a.buttons.length:0;return`${l}::${i}::${o}::${f}`}function kA(a){return JSON.parse(JSON.stringify(a??{}))}function Ix(a,l){const i=kA(l);return i.meta={id:a?.id??"Unknown",mapping:a?.mapping??"none",axes:a?.axes?.length??0,buttons:a?.buttons?.length??0},i}function Za(a){return Number.isFinite(a)?Math.max(-1,Math.min(1,a)):0}function Ps(a,l){if(!a)return 0;const i=Math.abs(a);return l==="expo"?Math.sign(a)*Math.pow(i,EA):a}function Zu(a,l){const i=Math.abs(a);if(i<=l)return 0;const o=(i-l)/(1-l);return Math.sign(a)*o}function qA(a,l,i){const o=Math.hypot(a,l);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:a*d,y:l*d}}function to(a,l){if(!a||!Array.isArray(a.axes))return null;const i=a.axes[l];return Number.isFinite(i)?Za(i):null}function Sf(a,l){if(!a||!Array.isArray(a.buttons))return null;const i=a.buttons[l];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function Ju(a,l=[]){for(const i of l)if(i){if(i.kind==="axis"){const o=to(a,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=Sf(a,i.index);if(!o)continue;return{value:Za(o.value),source:i}}}return{value:0,source:null}}function MA(a,l=[]){for(const i of l){if(!i||i.kind!=="axisPair")continue;const o=to(a,i.x),f=to(a,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function Fa(a,l=[]){for(const i of l)if(i){if(i.kind==="button"){const o=Sf(a,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=to(a,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=Sf(a,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function Wx(a,l){const i=l?.bindings??{},o=l?.calibration??{},f=i.drive??{},d=MA(a,f.sources);let h=Za(d.x),p=Za(d.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=qA(h,p,x);h=Ps(g.x,o.driveCurve),p=Ps(g.y,o.driveCurve);const y=i.cameraTilt??{},b=Ju(a,y.sources),N=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let M=Zu(Za(b.value),N);M=Ps(M,o.cameraCurve);const E=Math.min(Math.max(o.auxDeadzone??.05,0),.6),w=i.mainBrush??{},j=Ju(a,w.sources);let k=Zu(Za(j.value),E);k=Ps(k,o.auxCurve);const A=i.sideBrush??{},C=Ju(a,A.sources);let _=Zu(Za(C.value),E);_=Ps(_,o.auxCurve);const L=Fa(a,i.vacuum?.sources),Y=Fa(a,i.allAux?.sources),O=Fa(a,i.mainReverse?.sources),X=Fa(a,i.sideReverse?.sources),z=Fa(a,i.driveMacro?.sources),Q=Fa(a,i.dockMacro?.sources),K=Fa(a,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:M,auxAxis:{main:k,side:_},buttons:{vacuum:L.pressed,allAux:Y.pressed,mainReverse:O.pressed,sideReverse:X.pressed,driveMacro:z.pressed,dockMacro:Q.pressed,nightVisionToggle:K.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:j.source,sideBrush:C.source,vacuum:L.source,allAux:Y.source,mainReverse:O.source,sideReverse:X.source,driveMacro:z.source,dockMacro:Q.source,nightVisionToggle:K.source}}}const Jr=new Set;let Ql=null,no={pads:[],timestamp:0};function RA(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const a=navigator.getGamepads();return a?Array.from(a).filter(Boolean):[]}function TA(a){return{index:a.index,id:a.id,mapping:a.mapping,connected:a.connected!==!1,timestamp:a.timestamp,axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0})),signature:Jx(a)}}function DA(){no={pads:RA().map(TA),timestamp:typeof performance<"u"?performance.now():Date.now()},Jr.forEach(l=>l(no))}function Px(){DA(),Ql=requestAnimationFrame(Px)}function _A(){Ql||(Ql=requestAnimationFrame(Px))}function OA(){Ql&&(cancelAnimationFrame(Ql),Ql=null)}function eg(a){return Jr.add(a),_A(),a(no),()=>{Jr.delete(a),Jr.size===0&&OA()}}function BA(){const[a,l]=m.useState(no);return m.useEffect(()=>eg(l),[]),a}const Yl="gamepad",Qa={x:0,y:0,boost:!1},Ka={main:0,side:0,vacuum:0},LA=100,zA=100;function Iu(a,l){return a&&l&&a.x===l.x&&a.y===l.y&&a.boost===l.boost}function Wu(a,l){return a&&l&&a.main===l.main&&a.side===l.side&&a.vacuum===l.vacuum}function UA(a){return a?Math.hypot(a.x||0,a.y||0):0}function HA(a){return a?!a.main&&!a.side&&!a.vacuum:!0}function VA(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function $A(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:p}}=Dt(),{value:x,save:g}=We("gamepad",ja),y=m.useRef(new Set),b=m.useRef(Qa),N=m.useRef(Ka),M=m.useRef({main:!1,side:!1}),E=m.useRef(new Map),w=m.useRef(0),j=m.useRef(0),k=m.useRef(0),A=m.useRef(null),C=m.useCallback(O=>{const X=O.signature??Jx(O);x?.profiles?.[X]||y.current.has(X)||(y.current.add(X),g(z=>{const Q=z??ja;if(Q.profiles?.[X])return Q;const K=Q?.defaults?.profile??Kn,ae=Ix(O,K);return{...Q,profiles:{...Q.profiles??{},[X]:ae}}}))},[x?.profiles,g]),_=m.useCallback((O,X)=>{const z=E.current.get(O)||!1;return E.current.set(O,X),X&&!z},[]),L=m.useCallback((O,X)=>{const z=a.camera?.config;if(!z)return;const Q=typeof performance<"u"?performance.now():Date.now(),K=X?.cameraMode??"absolute",ae=Math.max(1,Math.min(180,X?.cameraSensitivity??60));if(K==="velocity"){const F=Math.min(50,Q-k.current||16),P=O*ae*(F/1e3);if(Math.abs(P)<.01)return;const fe=(typeof A.current=="number"?A.current:typeof a.camera?.angle=="number"?a.camera.angle:typeof z.homeAngle=="number"?z.homeAngle:0)+P;f(fe),A.current=fe,k.current=Q;return}const ce=typeof z.minAngle=="number"?z.minAngle:-45,oe=typeof z.maxAngle=="number"?z.maxAngle:45,$=typeof z.homeAngle=="number"?z.homeAngle:(ce+oe)/2,R=O<0?$+O*($-ce):$+O*(oe-$);typeof A.current=="number"&&Math.abs(A.current-R)<.35&&Q-k.current<80||(k.current=Q,A.current=R,f(R))},[f,a.camera?.angle,a.camera?.config]),Y=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>eg(O=>{const X=VA(O.pads,Y);if(!X){Iu(b.current,Qa)||(b.current=Qa,i(Qa,{source:Yl})),Wu(N.current,Ka)||(N.current=Ka,o(Ka)),E.current=new Map,M.current={main:!1,side:!1},w.current=0,j.current=0,p(Yl,{connected:!1});return}if(yA()){Iu(b.current,Qa)||(b.current=Qa,i(Qa,{source:Yl})),Wu(N.current,Ka)||(N.current=Ka,o(Ka)),E.current=new Map,M.current={main:!1,side:!1},p(Yl,{connected:!0,blocked:!0});return}C(X);const z=X.signature,Q=x?.profiles?.[z]??x?.defaults?.profile??Kn,K=Wx(X,Q);if(!Iu(K.driveVector,b.current)){const P=typeof performance<"u"?performance.now():Date.now();(UA(K.driveVector)<.02||P-w.current>=LA)&&(b.current=K.driveVector,w.current=P,i(K.driveVector,{source:Yl}))}const ae=Q.calibration?.auxSideScale??.55,ce=Math.round(Math.min(Math.abs(K.auxAxis.main),1)*127),oe=Math.round(Math.min(Math.abs(K.auxAxis.side),1)*127),$=M.current.main?-ce:ce,R=M.current.side?-Math.round(oe*ae):Math.round(oe*ae);let F={main:K.auxAxis.main!==0?$:0,side:K.auxAxis.side!==0?R:0,vacuum:K.buttons.vacuum?127:0};if(K.buttons.allAux&&(F={main:127,side:127,vacuum:127}),!Wu(F,N.current)){const P=typeof performance<"u"?performance.now():Date.now();(HA(F)||P-j.current>=zA)&&(N.current=F,j.current=P,o(F))}K.buttons.mainReverse&&_("mainReverse",!0)?M.current.main=!M.current.main:K.buttons.mainReverse||_("mainReverse",!1),K.buttons.sideReverse&&_("sideReverse",!0)?M.current.side=!M.current.side:K.buttons.sideReverse||_("sideReverse",!1),K.buttons.driveMacro&&_("driveMacro",!0)?(l("drive"),d("drive-sequence")):K.buttons.driveMacro||_("driveMacro",!1),K.buttons.dockMacro&&_("dockMacro",!0)?(l("dock"),d("seek-dock")):K.buttons.dockMacro||_("dockMacro",!1),K.buttons.nightVisionToggle&&_("nightVisionToggle",!0)?h():K.buttons.nightVisionToggle||_("nightVisionToggle",!1),Math.abs(K.cameraAxis)>.001&&L(K.cameraAxis,Q.calibration),p(Yl,{connected:!0,signature:z,id:X.id,index:X.index,axes:X.axes,buttons:X.buttons,drive:K.driveVector,aux:F,cameraAxis:K.cameraAxis,bindings:K.sources})}),[Y,C,x?.defaults?.profile,x?.profiles,_,L,p,d,o,i,l,h]),null}function tg(a){const l=a?.sensors||{},i=l.oiMode?.label||"Unknown",o=i.toLowerCase(),f=l.chargingState?.label||"",d=!!l.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function ng(a){const l=ts(a);return m.useMemo(()=>tg(l),[l])}function Gl({label:a,value:l,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:l})})}function _p({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function Pu({label:a,tone:l}){const i=l==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":l==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:a})}function YA({instructions:a,onConfirm:l,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:a.summary}),r.jsx(Af,{steps:a.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick:l,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function ag({layout:a="desktop",expand:l=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=a==="mobile",{state:{roverId:h,keymap:p},actions:x}=Dt(),g=ts(h),y=o??tg(g),{driving:b,docked:N,charging:M,dockingInProgress:E}=y,[w,j]=m.useState(null),[k,A]=m.useState(!1),[C,_]=m.useState(!1),L=!h||w!==null,Y=!h||w!==null,O=An(p?.driveMacro?.[0]),X=An(p?.dockMacro?.[0]),z={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},Q="Click this button to initate auto-dock.",K={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},ae=N?"Docked":"Undocked",ce=N?"good":"bad",oe=M?"Charging":N?"Charging in 5s":"—",$=M?"good":N?"warn":"bad",R=async()=>{if(!(!h||w)){j("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ne){alert(Ne.message)}finally{j(null)}}},F=async()=>{if(!(!h||w)){A(!1),_(!1),j("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ne){alert(Ne.message)}finally{j(null)}}},P=async()=>{if(!(!h||w)){j("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(Ne){alert(Ne.message)}finally{j(null),A(!1),_(!1)}}},re=()=>{Y||(_(!0),A(!0))},fe="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",q="text-center",H="items-center justify-between",ne="items-center justify-center",le=d?"text-sm font-semibold":"",se="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ie="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ue="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ve="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",we=l||E,te=we?"h-full flex-1":i?"flex-1":"",J=d&&!we?f:"",pe=d&&!we?ne:H,be=d&&!we&&b&&N;if(!b&&!E)return r.jsxs("button",{type:"button",onClick:F,onContextMenu:Ne=>Ne.preventDefault(),disabled:L,className:`${fe} ${te} ${J} ${q} ${pe} ${le} ${se}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&we?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[O?r.jsx(_p,{label:O}):null,r.jsx(Pu,{label:"Click to start",tone:"emerald"})]}):null]}),we?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:K.summary}),r.jsx(Af,{steps:K.steps,tone:"emerald"})]}):null]}),we?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Gl,{label:"Dock",value:ae,tone:ce}),r.jsx(Gl,{label:"Charge",value:oe,tone:$})]}):null]});if(E){const Ne={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:L,onClick:R,onContextMenu:ze=>ze.preventDefault(),className:`${fe} ${te} ${J} ${q} ${pe} ${le} ${ie}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),we?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(Pu,{label:"Return to driving mode",tone:"emerald"})}):null]}),we?r.jsx("p",{className:"text-sm text-amber-50/90",children:Ne.summary}):null]}),we?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Gl,{label:"Dock",value:ae,tone:ce}),r.jsx(Gl,{label:"Charge",value:oe,tone:$})]}),d?null:r.jsx(Af,{steps:Ne.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:Y,onClick:re,onContextMenu:Ne=>Ne.preventDefault(),className:d?`flex w-full ${fe} ${J} ${q} ${pe} ${le} ${be?ve:ue}`:`${fe} ${te} ${q} ${H} ${le} ${ue}`,children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:be?"Docked!":"Dock and Charge"}),!d&&we?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[X?r.jsx(_p,{label:X}):null,r.jsx(Pu,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&we&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:Q}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Gl,{label:"Dock",value:ae,tone:ce}),r.jsx(Gl,{label:"Charge",value:oe,tone:$})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),C||!d&&k?r.jsx(YA,{instructions:z,pending:w==="dock",onCancel:()=>{_(!1),A(!1)},onConfirm:P}):null]})}function Af({steps:a,tone:l="emerald"}){const i=l==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":l==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=l==="emerald"?"text-emerald-200":l==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:a.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<a.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function ef(a){return typeof a=="boolean"}function lg({nightVisionOn:a,disabled:l,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,p]=m.useState(ef(a)?a:null);m.useEffect(()=>{ef(a)&&p(a)},[a]);const x=ef(h),g=x?h:!1,y=x?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",N=()=>{if(l)return;const E=x?!g:!0;p(E),i?.(E)},M=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:N,onContextMenu:E=>E.preventDefault(),disabled:l,"aria-pressed":g,className:M,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:y})]})}function tf(a){const l=Number(a);return!Number.isFinite(l)||l<=0?0:Math.min(5e3,Math.round(l))}function sg({disabled:a,onStart:l,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[y,b]=m.useState(!1),[N,M]=m.useState(p),{value:E,save:w}=We("horn",Ja),[j,k]=m.useState(E?.waveform||Ja.waveform),[A,C]=m.useState(()=>[...Array.isArray(E?.freqs)?E.freqs:Ja.freqs,0,0,0,0].slice(0,4).map(R=>tf(R)));m.useEffect(()=>{k(E?.waveform||Ja.waveform),Array.isArray(E?.freqs)&&C([...E.freqs,0,0,0,0].slice(0,4).map($=>tf($)))},[E?.freqs,E?.waveform]);const _=!!f,L=Math.max(0,Math.min(1,Number(d)||0)),Y=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",_?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,_]),O=()=>{a||y||(b(!0),l?.())},X=()=>{y&&(b(!1),i?.())};m.useEffect(()=>{!_&&y&&b(!1)},[_,y]);const z=j==="sine"?"sine":"saw",Q=m.useCallback($=>{const R=$.target.value==="sine"?"sine":"saw";k(R),w(F=>({...F??{},waveform:R}))},[w]),K=m.useCallback(($,R)=>{C(F=>{const P=[...F];return P[$]=tf(R),w(re=>({...re??{},freqs:P})),P})},[w]),ae=$=>{if(a)return;const R=$.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||($.preventDefault(),O())},ce=$=>{const R=$.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||($.preventDefault(),X())},oe=x?r.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),M(R=>!R)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:N?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":y,onPointerDown:ae,onPointerUp:ce,onPointerLeave:X,onPointerCancel:X,onContextMenu:$=>$.preventDefault(),onBlur:X,className:Y,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${L*100}%, rgba(0,0,0,0) ${L*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${_?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),oe,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${_?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:_?"Honk":"Hold"})]}),N?g?r.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:Q,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:A.map(($,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:F=>K(R,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:Q,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),A.map(($,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:F=>K(R,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))]}):null]})}function Ur(a){return typeof a!="number"||Number.isNaN(a)?"—":`${a>0?"+":""}${a.toFixed(1)}°`}function Op({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function ig({value:a,min:l,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:y,keyUpLabel:b,className:N="",labelRowClass:M="",labelClass:E="",valueClass:w="",sliderClass:j="",endpointClass:k="",endpointLabelClass:A="",accentClass:C="",showValue:_=!0,showEndpoints:L}){const Y=d==="vertical",X=typeof L=="boolean"?L:!Y,[z,Q]=m.useState(a),K=m.useRef(!1),ae=m.useRef(null);m.useEffect(()=>{K.current||Q(a)},[a]),m.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);const ce=P=>{if(h){if(x>0){ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{h(P)},x);return}h(P)}},oe=P=>{const re=Number.parseFloat(P.target.value);Number.isNaN(re)||(K.current=!0,Q(re),ce(re))},$=()=>{K.current=!1,ae.current&&(clearTimeout(ae.current),ae.current=null),p?p(z):x>0&&h?.(z)};if(typeof l!="number"||typeof i!="number")return null;const R=[Y?"h-28 w-5":"w-full",C,j].filter(Boolean).join(" "),F=r.jsx("input",{type:"range",orient:Y?"vertical":void 0,min:l,max:i,step:o,value:Number.isFinite(z)?z:l,onChange:oe,onMouseUp:$,onTouchEnd:$,onPointerUp:$,disabled:g,className:R,style:Y?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return Y?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${N}`.trim(),children:[_?r.jsx("div",{className:`flex flex-col items-center ${M}`.trim(),children:r.jsx("span",{className:w,children:Ur(a)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:E,children:f}),F]})]}):r.jsxs("div",{className:`space-y-0.5 ${N}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${M}`.trim(),children:[r.jsx("span",{className:E,children:f}),_?r.jsx("span",{className:w,children:Ur(a)}):null]}),r.jsxs("div",{children:[F,X?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${k}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[y?r.jsx(Op,{label:y}):null,Ur(l)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[Ur(i),b?r.jsx(Op,{label:b}):null]})]}):null]})]})}const Hr="mobile-joystick",GA=80,XA=.15,FA={main:0,side:0,vacuum:0},QA={main:127,side:127,vacuum:127},KA={main:-127,side:-127,vacuum:-127};function ZA({disabled:a,layout:l,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),y=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(w=>{if(a||h.current!==null)return;w.preventDefault();const j=d.current;if(!j)return;const k=j.getBoundingClientRect(),A=w.clientX-k.left,C=w.clientY-k.top;p.current={x:A,y:C},h.current=w.pointerId,j.setPointerCapture?.(w.pointerId),g({active:!0,base:{x:A,y:C},knob:{x:0,y:0}})},[a]),N=m.useCallback(w=>{if(a||h.current!==w.pointerId)return;w.preventDefault();const j=d.current;if(!j)return;const k=j.getBoundingClientRect(),A=w.clientX-k.left,C=w.clientY-k.top,_=A-p.current.x,L=C-p.current.y,Y=Math.min(Math.hypot(_,L),i),O=Math.atan2(L,_),X=Math.cos(O)*Y,z=Math.sin(O)*Y,Q={x:Il(X/i),y:Il(-z/i),boost:!1};g(K=>({...K,knob:{x:X,y:z}})),o?.(Q)},[a,o]),M=m.useCallback(w=>{if(h.current!==w.pointerId)return;w.preventDefault(),d.current?.releasePointerCapture?.(w.pointerId),y()},[y]);return m.useEffect(()=>{a&&y()},[a,y]),r.jsxs("div",{ref:d,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:N,onPointerUp:M,onPointerLeave:M,onPointerCancel:M,onContextMenu:w=>w.preventDefault(),children:[!x.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:x.base.x,top:x.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function JA({layout:a}){const{state:{roverId:l},actions:{setDriveVector:i,registerInputState:o}}=Dt(),f=ng(l),d=f.docked&&!f.driving,h=d||f.dockingInProgress,p=!l,x=GA,g=XA,y=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(y.current={x:0,y:0,boost:!1})},[p]);const b=m.useCallback((w={})=>{if(p)return;const j={x:Il(w.x??0),y:Il(w.y??0),boost:!!w.boost},k={x:y.current.x+(j.x-y.current.x)*(1-g),y:y.current.y+(j.y-y.current.y)*(1-g),boost:j.boost};y.current=k,i(k,{source:Hr}),o(Hr,{vector:k,lastEvent:"move"})},[p,o,i,g]),N=m.useCallback(()=>{if(p)return;const w={x:0,y:0,boost:!1};y.current=w,i(w,{source:Hr}),o(Hr,{vector:w,lastEvent:"stop"})},[p,o,i]),E=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:E,children:[r.jsx(ag,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ZA,{disabled:p,layout:a,radius:x,onMove:b,onStop:N})})]})}function Bp({id:a,label:l,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:p=>{p.preventDefault(),d(a,i)},onPointerUp:()=>h(a),onPointerLeave:()=>h(a),onPointerCancel:()=>h(a),onContextMenu:p=>p.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:l})}function IA({layout:a}){const{state:{roverId:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=Dt(),y=!l,b=m.useRef(null),N=i?.config,M=!!(l&&i?.enabled&&N),E=!!(l&&f?.nightVision),w=f?.nightVisionState,j=!!(l&&f?.horn),k=o?.overheated,A=typeof N?.minAngle=="number"?N.minAngle:-45,C=typeof N?.maxAngle=="number"?N.maxAngle:45,_=typeof i?.angle=="number"?i.angle:typeof N?.homeAngle=="number"?N.homeAngle:(A+C)/2,L=m.useCallback(X=>{E&&h(X)},[E,h]),Y=m.useCallback((X,z)=>{y||(b.current=X,p(z))},[y,p]),O=m.useCallback(X=>{y||b.current===X&&(b.current=null,p(FA))},[y,p]);return r.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[r.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[r.jsx(Bp,{id:"aux-vac-forward",label:"Vacuum Forward",values:QA,color:"bg-fuchsia-600",disabled:y,onPress:Y,onRelease:O}),r.jsx(Bp,{id:"aux-vac-backward",label:"Vacuum Backward",values:KA,color:"bg-fuchsia-800",disabled:y,onPress:Y,onRelease:O})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[M?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(ig,{value:_,min:A,max:C,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,E?r.jsx(lg,{nightVisionOn:w?.nightVisionOn,disabled:y,onToggle:L,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:j?r.jsx(sg,{disabled:y||k,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function rg({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(IA,{layout:a})})}function og({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(JA,{layout:a==="landscape"?"landscape":"portrait"})})}function WA(){const a="h-[min(60svh,24rem)]";return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r.jsx(rg,{layout:"portrait",className:a}),r.jsx(og,{layout:"portrait",className:a})]})})}function PA(a=[],l={}){const i=Cn(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>a.map(E=>typeof E=="string"?E:E.id),[a]),g=m.useMemo(()=>{const E=x.join("|");return f?`${E}|v:${f}`:E},[x,f]),y=m.useRef([]),[b,N]=m.useState(0),M=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const E=()=>N(w=>w+1);return i.on("connect",E),()=>i.off("connect",E)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let E=!1;const w=y.current,j=(A={},C)=>{if(E||!A.id||!C)return;const _=C.byteLength??C.length??0,L=Date.now(),Y=M.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:Y.count+1,totalBytes:Y.totalBytes+_,lastLogAt:Y.lastLogAt};if(!O.lastLogAt||L-O.lastLogAt>=1e4){const K=O.count?O.totalBytes/O.count:0;console.log("[roomCamera]",A.id,`frame=${_}B`,`avg=${Math.round(K)}B`,`count=${O.count}`),O.lastLogAt=L}M.current.set(A.id,O);const X=new Blob([C],{type:"image/jpeg"}),z=URL.createObjectURL(X),Q=p.current.get(A.id);Q&&URL.revokeObjectURL(Q),p.current.set(A.id,z),h(K=>({...K,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:z}}))},k=(A={})=>{E||!A.id||h(C=>({...C,[A.id]:{...C[A.id]||{},status:A.error?"error":C[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||C[A.id]?.ts||null,objectUrl:C[A.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",j),i.on("roomCamera:status",k),i.emit("roomCamera:subscribe",{ids:w},(A={})=>{A.error}),()=>{E=!0,i.emit("roomCamera:unsubscribe",{ids:w}),i.off("roomCamera:frame",j),i.off("roomCamera:status",k),p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear()}},[i,g,o,b]),d}function ej({feed:a,label:l}){const[i,o]=m.useState(!1);m.useEffect(()=>{a&&(!a.ts&&!a.objectUrl||o(d=>!d))},[a?.ts,a?.objectUrl]);const f=m.useMemo(()=>a?a.error?`Error: ${a.error}`:a.status||"Connecting…":"Connecting…",[a]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[a?.objectUrl?r.jsx("img",{src:a.objectUrl,alt:l,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:l}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function tj(){return r.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),r.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const cg=["horizontal","vertical"];function nf(a,l){return cg.includes(a)?a:l}function Qf({defaultOrientation:a="horizontal",orientation:l,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=De(),h=d?.roomCameras||[],p=PA(h.map(j=>({id:j.id}))),{value:x,save:g}=We("roomCameraPanels",{}),[y,b]=m.useState(()=>nf(f?x?.[f]:a,"horizontal"));m.useEffect(()=>{if(!f)return;const j=x?.[f];j&&b(nf(j,"horizontal"))},[f,x?.[f]]);const N=l?nf(l,"horizontal"):y,M=N==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",E=!i&&!l&&h.length>0,w=j=>{b(j),f&&g(k=>({...k||{},[f]:j}))};return h.length===0?r.jsx(tj,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:E&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:cg.map(j=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${N===j?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>w(j),children:j==="vertical"?"Vertical":"Grid"},j))})]})})]}),r.jsx("div",{className:M,children:h.map(j=>{const k=p[j.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(ej,{feed:k,label:j.name||j.id})},j.id)})})]})}function Kf(){const{logs:a}=De();return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:a.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?r.jsx("p",{children:"No logs yet."}):a.slice().reverse().map(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",l.level,"]"]})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{children:l.message})]},l.id))})]})}function nj(a){if(!a)return null;if(typeof a=="string"){const l=String(a).trim();return l?{type:"rover",id:l,key:l}:null}if(typeof a=="object"){if(a.type&&a.id){const l=String(a.id);let i=a.key;return i||(i=a.type==="room"?`room:${l}`:l),{type:a.type,id:l,key:i}}if(a.roverId){const l=String(a.roverId);return{type:"rover",id:l,key:a.key||l}}if(a.roomCameraId){const l=String(a.roomCameraId);return{type:"room",id:l,key:a.key||`room:${l}`}}}return null}function aj(a=[]){const l=new Set,i=[];return a.forEach(o=>{!o?.key||l.has(o.key)||(l.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function ci(a=[],l={}){const i=Cn(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(a)?aj(a.map(nj).filter(Boolean)):[],[a]),x=m.useMemo(()=>{const M=p.map(E=>`${E.type}:${E.id}:${E.key}`).join("|");return f?`${M}|v:${f}`:M},[p,f]),g=m.useRef([]),[y,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const M=()=>b(E=>E+1);return i.on("connect",M),()=>{i.off("connect",M)}},[i]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const M=g.current;let E=!1;function w(j){const k=j.type==="room"?{roomCameraId:j.id}:{roverId:j.id};i.emit("video:request",k,(A={})=>{E||h(C=>({...C,[j.key]:A}))})}return M.forEach(j=>{w(j)}),()=>{E=!0}},[i,x,o,y]),m.useMemo(()=>{if(!x||!o)return{};const M={};return p.forEach(E=>{d[E.key]&&(M[E.key]=d[E.key])}),M},[x,d,p])}function Zf(a=[],l={}){const i=Cn(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>a.map(E=>typeof E=="string"?E:E.id).filter(Boolean),[a]),g=m.useMemo(()=>{const E=x.join("|");return f?`${E}|v:${f}`:E},[x,f]),y=m.useRef([]),[b,N]=m.useState(0),M=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const E=()=>N(w=>w+1);return i.on("connect",E),()=>i.off("connect",E)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let E=!1;const w=y.current,j=(A={},C)=>{if(E||!A.id||!C)return;const _=C.byteLength??C.length??0,L=Date.now(),Y=M.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:Y.count+1,totalBytes:Y.totalBytes+_,lastLogAt:Y.lastLogAt};if(!O.lastLogAt||L-O.lastLogAt>=1e4){const K=O.count?O.totalBytes/O.count:0;console.log("[roverSnapshot]",A.id,`frame=${_}B`,`avg=${Math.round(K)}B`,`count=${O.count}`),O.lastLogAt=L}M.current.set(A.id,O);const X=new Blob([C],{type:"image/jpeg"}),z=URL.createObjectURL(X),Q=p.current.get(A.id);Q&&URL.revokeObjectURL(Q),p.current.set(A.id,z),h(K=>({...K,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:z}}))},k=(A={})=>{E||!A.id||h(C=>({...C,[A.id]:{...C[A.id]||{},status:A.error?"error":C[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||C[A.id]?.ts||null,objectUrl:C[A.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",j),i.on("roverSnapshot:status",k),i.emit("roverSnapshot:subscribe",{ids:w},(A={})=>{A.error}),()=>{E=!0,i.emit("roverSnapshot:unsubscribe",{ids:w}),i.off("roverSnapshot:frame",j),i.off("roverSnapshot:status",k),p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear()}},[i,g,o,b]),d}const lj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function sj(a){if(typeof btoa=="function")return btoa(a);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function ij(a){if(!a)return{};const l=`${a}:${a}`;return{Authorization:`Basic ${sj(l)}`}}class Lp{constructor({url:l,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=l,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(l,i){typeof this.onStatus=="function"&&this.onStatus(l,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const l=new RTCPeerConnection(lj);this.pc=l;const i=new MediaStream;l.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?l.addTransceiver("audio",{direction:"recvonly"}):(l.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&l.addTransceiver("audio",{direction:"recvonly"})),l.onconnectionstatechange=()=>{this.notify(l.connectionState)},l.oniceconnectionstatechange=()=>{const o=l.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await l.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await l.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...ij(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await l.setRemoteDescription({type:"answer",sdp:d}),l.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(l=>l.track?.stop()),this.pc.getReceivers().forEach(l=>l.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function jf({sensors:a={},variant:l="full",size:i,overlay:o=!1}){const f=i||(l==="mini"?190:260),d=f/2,h=f*.07,p=d,x=d+h,g=d*.8,y=g-4,b=g+4,N=g-14,M=g-6,E=g*.65,w=a?.bumpsAndWheelDrops||{},j=a?.wheelOvercurrents||{},k=a?.wheelLeftCurrentMa??0,A=a?.wheelRightCurrentMa??0,C=a?.sideBrushCurrentMa??0,_=a?.mainBrushCurrentMa??0,L=6,Y=w.bumpLeft?L:0,O=w.bumpRight?L:0,X=mj({count:6,totalSpan:140,gap:6,startAngle:-70}),z=["L","FL","CL","CR","FR","R"],Q=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],K=X.map(($,R)=>({label:z[R],start:$.start,end:$.end,value:Q[R]})),ae=[{label:"Cliff L",start:-60,end:-46,value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:a?.cliffRightSignal,active:a?.cliffRight}],ce=Q.filter($=>$!=null),oe=ce.length?Math.max(...ce,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${f}px`,height:`${f}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),r.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",oe]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:p,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(zp,{cx:p-E,cy:x,current:k,drop:w.wheelDropLeft,overcurrent:j.leftWheel,label:"L"}),r.jsx(zp,{cx:p+E,cy:x,current:A,drop:w.wheelDropRight,overcurrent:j.rightWheel,label:"R"}),r.jsx(cj,{cx:p+g*.65,cy:x-g*.55,current:C,overcurrent:j.sideBrush}),r.jsx(uj,{cx:p,cy:x,current:_,overcurrent:j.mainBrush,variant:l,dirtLeft:a?.dirtDetectLeft,dirtRight:a?.dirtDetect}),K.map($=>{const R=fj($.value,oe),F=b+4,P=F+28;return r.jsx(rj,{cx:p,cy:x,rBase:P,rTip:F,startDeg:$.start,endDeg:$.end,color:R,value:$.value,max:oe},$.label)}),ae.map($=>{const R=dj($.value,$.active);return r.jsx(af,{cx:p,cy:x,rInner:N,rOuter:M,startDeg:$.start,endDeg:$.end,color:R,opacity:1,pulse:!!$.active},$.label)}),r.jsx(af,{cx:p,cy:x,rInner:y-Y,rOuter:b-Y,startDeg:-70,endDeg:-6,color:w.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpLeft}),r.jsx(af,{cx:p,cy:x,rInner:y-O,rOuter:b-O,startDeg:6,endDeg:70,color:w.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpRight})]})]})}function af({cx:a,cy:l,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:p=!1,opacity:x=1}){const g=(i+o)/2,y=o-i,b=oj(a,l,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:h,strokeWidth:y,strokeLinecap:"round",fill:"none",opacity:x}),p?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:y,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function rj({cx:a,cy:l,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:p,max:x}){const g=(f+d)/2,y=li(a,l,o,g),b=co(p!=null?p/(x||1):0),N=Math.pow(b,.35),M=i-(i-o)*N,E=li(a,l,M,f),w=li(a,l,M,d),j=`M ${y.x} ${y.y} L ${E.x} ${E.y} L ${w.x} ${w.y} Z`;return r.jsx("path",{d:j,fill:h,opacity:1,stroke:"none"})}function oj(a,l,i,o,f){let d=o,h=f;h<=d&&(h+=360);const p=li(a,l,i,d),x=li(a,l,i,h);return["M",p.x,p.y,"A",i,i,0,0,1,x.x,x.y].join(" ")}function li(a,l,i,o){const f=ug(o);return{x:a+i*Math.cos(f),y:l+i*Math.sin(f)}}function ug(a){return(a-90)*Math.PI/180}function Jf(a,l){if(l)return"#ef4444";const i=Math.abs(a);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function co(a){return Math.max(0,Math.min(1,a))}function zp({cx:a,cy:l,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),p=co(h/1200),x=Jf(i,f),g=56,y=14,b=9,N=3,M=g*p,E=d==="L"?-1:1,w=E*(-b/2-N/2),j=E*(y/2+N/2),k=y+b+N+2,A=g+4;return r.jsxs("g",{transform:`translate(${a},${l})`,children:[r.jsx("rect",{x:-k/2,y:-A/2,width:k,height:A,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:w-y/2,y:-g/2,width:y,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:w-y/2,y:g/2-M,width:y,height:M,fill:x,className:f?"animate-pulse":""}),r.jsx("rect",{x:j-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function cj({cx:a,cy:l,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=Jf(i*3,o),h=43,p=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${a}px ${l}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[r.jsx("circle",{cx:a,cy:l,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const y=ug(g),b=a+h*Math.cos(y),N=l+h*Math.sin(y);return r.jsx("line",{x1:a,y1:l,x2:b,y2:N,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:a,cy:l,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function uj({cx:a,cy:l,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const p=Math.abs(i),x=Jf(i,o),g=1,y=96,b=12,N=`main-brush-pattern-a-${f}`,M=`main-brush-pattern-b-${f}`,E=p>0?.6:null,w=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[N,M].map((j,k)=>r.jsxs("pattern",{id:j,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),E?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${w*(k===0?6:-6)}`,dur:`${E}s`,repeatCount:"indefinite"}):null]},j))}),r.jsx("rect",{x:a-y/2,y:l-14,width:y,height:b,rx:"3",fill:`url(#${N})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:a-y/2,y:l+4,width:y,height:b,rx:"3",fill:`url(#${M})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:a-y/4,cy:l-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:a+y/4,cy:l+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:a-y/2-4,y:l-16,width:y+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function fj(a,l){if(a==null||a<=0)return"hsl(200 60% 18%)";const o=co(a/(l||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function dj(a,l){if(l)return"#ef4444";const i=co(a==null?0:a/4095),o=[47,55,69],f=[245,158,11],[d,h,p]=o.map((x,g)=>Math.round(x+(f[g]-x)*i));return`rgb(${d}, ${h}, ${p})`}function mj({count:a,totalSpan:l,gap:i,startAngle:o}){const d=(l-i*(a-1))/a,h=[];let p=o;for(let x=0;x<a;x+=1){const g=p+d;h.push({start:p,end:g}),p=g+i}return h}function fg(){const{value:a,save:l}=We("page",{hudMapDesktop:!1});return[!!a?.hudMapDesktop,f=>{l({hudMapDesktop:!!f})}]}const hj={discord:Ux,kofi:Sp,"ko-fi":Sp,wiki:HS,throne:VS},pj={discord:{backgroundImage:"linear-gradient(270deg,#5865F2,#404EED,#5865F2)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"},kofi:{backgroundImage:"linear-gradient(270deg,#FF6433,#E04822,#FF6433)",backgroundSize:"600% 600%",animation:"socialGradient 170s ease infinite"},"ko-fi":{backgroundImage:"linear-gradient(270deg,#FF6433,#E04822,#FF6433)",backgroundSize:"600% 600%",animation:"socialGradient 170s ease infinite"},wiki:{backgroundImage:"linear-gradient(270deg,#EE8019,#C65C08,#EE8019)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"},throne:{backgroundImage:"linear-gradient(270deg,#7C3AED,#5B21B6,#7C3AED)",backgroundSize:"600% 600%",animation:"socialGradient 180s ease infinite"}};function xj(){m.useEffect(()=>{if(typeof document>"u")return;const a="social-button-keyframes";if(document.getElementById(a))return;const l=document.createElement("style");l.id=a,l.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(l)},[])}function gj(a,l){return typeof a=="string"&&a.trim()?a.trim().toLowerCase():typeof l=="string"&&l.trim()?l.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function If({id:a,label:l,url:i,className:o=""}){if(!i)return null;xj();const f=gj(a,l),d=hj[f]||$S,h=pj[f]||null,p=l||a||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),p]})}const ui=10;function dg({batteryState:a=null,charge:l=null,config:i=null}){const o=a?.percentDisplay!=null&&Number.isFinite(a.percentDisplay)?Math.round(a.percentDisplay):null,f=a?.warnActive??null,d=a?.urgentActive??null,h=i?.Full??null,p=i?.Warn??null,x=i?.Urgent??null,g=l??a?.charge??null;let y=o;if(y==null&&(y=vj({charge:g,full:h,warn:p,urgent:x})),y==null)return{available:!1};const b=Math.max(0,Math.min(1,y/100)),N=f??(p!=null&&g!=null&&g<=p),M=d??(x!=null&&g!=null&&g<=x);return{available:!0,percent:b,percentDisplay:y,warnActive:N,urgentActive:M,warnDisplayPercent:ui}}function vj({charge:a,full:l,warn:i,urgent:o}){if(a!=null&&l!=null&&i!=null&&o!=null&&l>i&&i>o){const f=ui/100,d=1-f;if(a<=o)return 0;if(a<=i){const p=(a-o)/(i-o);return Math.round(Math.max(0,Math.min(1,p))*ui)}if(a>=l)return 100;const h=(a-i)/(l-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const yj=1600,bj=800;function mn(...a){return a.filter(Boolean).join(" ")}function Nf({visual:a,orientation:l="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",p=l==="vertical",x=f??!h;if(!a?.available){if(h){const ae=ui,ce=mn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),oe=p?{bottom:`${ae}%`}:{left:`${ae}%`},$=mn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:$,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:ce,style:oe})]})}return p?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=a.percentDisplay??0,y=Math.max(0,Math.min(100,g)),b=a.warnDisplayPercent??ui,N=!!a.urgentActive,M=!!a.warnActive,E=N?`${bj}ms`:M?`${yj}ms`:void 0,j=h?N||M?"bg-red-500/45":"bg-emerald-500/45":N||M?"bg-red-500":"bg-emerald-500",k=N||M?"bg-red-900/35":"bg-slate-900/35",A=N||M?"bg-red-900/45":"bg-slate-900/35",C=mn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const ae=p?{height:`${y}%`}:{width:`${y}%`},ce=mn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",N&&"battery-urgent-flash"),oe=mn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),$=p?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:C,children:[r.jsx("div",{className:mn("absolute inset-0",k,N&&"battery-urgent-flash")}),r.jsx("div",{className:ce,style:{...ae,animationDuration:E}}),r.jsx("div",{className:oe,style:$})]})}const _=mn("relative overflow-hidden rounded-sm border border-slate-800",N||M?A:"bg-zinc-900/90",N&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),L=p?{height:`${y}%`}:{width:`${y}%`},Y=mn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",N&&"battery-urgent-flash"),O=mn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),X=p?{bottom:`${b}%`}:{left:`${b}%`},z=`Battery ${g}%`,Q=mn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",p?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),K=mn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:C,children:[r.jsxs("div",{className:_,children:[r.jsx("div",{className:Y,style:{...L,animationDuration:E}}),r.jsx("div",{className:O,style:X})]}),x&&!p?r.jsx("div",{className:Q,children:r.jsx("span",{className:K,children:z})}):null,x&&p?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:K,children:[g,"%"]})}):null]})}const Up=2e3,Sj=3e3,Aj=3e3,jj=40,Nj=1e3;function fi({sessionInfo:a,audioSessionInfo:l,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,forceMute:h=!1,telemetryFrame:p,batteryConfig:x,layoutFormat:g="desktop",hudVariant:y="default",driverLabel:b=null,hudForceMap:N=!1,hudMapPosition:M="top-center",hudLabelScale:E=1,fitParent:w=!1,overcurrentLimiter:j=null,showTurnCue:k=!1,turnTimerText:A=null,turnSeconds:C=null,isActiveDriver:_=!1,idleSkipSeconds:L=null}){const{session:Y}=De(),O=m.useRef(null),X=m.useRef(null),z=m.useRef(null),Q=m.useRef(null),K=m.useRef(null),ae=m.useRef(null),ce=m.useRef(null),oe=m.useRef(null),[$,R]=m.useState("idle"),[F,P]=m.useState(null),[re,fe]=m.useState("idle"),[q,H]=m.useState(null),[ne,le]=m.useState(0),[se,ie]=m.useState(0),[ue,ve]=m.useState(!0),me=!!l?.url,we=i==="snapshot",te=p?.sensors,{value:J}=We("audio",jt),pe=Number.isFinite(J?.masterVolume)?J.masterVolume:jt.masterVolume,be=Number.isFinite(J?.roverVolume)?J.roverVolume:jt.roverVolume,Ne=typeof J?.mainBrushDuckEnabled=="boolean"?J.mainBrushDuckEnabled:typeof J?.autoLevelEnabled=="boolean"?J.autoLevelEnabled:jt.mainBrushDuckEnabled,ze=Number.isFinite(J?.mainBrushDuckAmount)?Math.max(0,Math.min(1,J.mainBrushDuckAmount)):jt.mainBrushDuckAmount,sn=Math.max(0,Math.min(1,pe*be)),wa=te?.batteryChargeMah??null,Wn=g==="desktop",it=!Wn,rn=it?"top-right":M,[xo]=fg(),go=N||it?!0:xo,mt=dg({charge:wa,config:x}),Pa=te?.wheelOvercurrents||null,el=Pa==null?[]:Object.entries(Pa).filter(([,ge])=>!!ge).map(([ge])=>ge),on=j?.caps||null,Ca=j?.overcurrent?.groups||null,bi=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),tl=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),vo=m.useMemo(()=>{if(!on)return null;const ge=Number.isFinite(on?.drive?.cap)?on.drive.cap:1,Xe=Number.isFinite(on?.aux?.cap)?on.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(ge,Xe)))},[on]),ns=!!j?.isActive,cn=el.length?el:ns?["limiter"]:[],pt=vo??(el.length?1:0),Gt=!!cn.length,rt=!!((Number(te?.mainBrushCurrentMa)||0)>jj||te?.wheelOvercurrents?.mainBrush),yo=Ne&&rt?1-ze:1,nl=Math.max(0,Math.min(1,sn*yo)),bo=Ne&&rt&&ze>0?`Volume decreased ${Math.round(ze*1e3)/10}%`:null,Ea=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ea.current={hasDedicatedAudio:me,audioUrl:l?.url||null,mainBrushDuckEnabled:Ne,mainBrushDuckAmount:ze,mainBrushActive:rt,baseRoverGain:sn,effectiveRoverGain:nl}},[me,l?.url,Ne,ze,rt,sn,nl]);const Ke=m.useCallback((ge,Xe={})=>{if(!bi)return;const Fe=X.current,Ce=Ea.current,Ue={event:ge,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:Ce.hasDedicatedAudio,audioUrl:Ce.audioUrl,mainBrushDuckEnabled:Ce.mainBrushDuckEnabled,mainBrushDuckAmount:Ce.mainBrushDuckAmount,mainBrushActive:Ce.mainBrushActive,baseRoverGain:Ce.baseRoverGain,effectiveRoverGain:Ce.effectiveRoverGain,element:Fe?{muted:Fe.muted,volume:Fe.volume,paused:Fe.paused,ended:Fe.ended,readyState:Fe.readyState,networkState:Fe.networkState}:null,...Xe};try{console.log(`[AudioDebug] ${ge} ${JSON.stringify(Ue)}`)}catch{console.log("[AudioDebug]",ge,Ue)}},[bi,d]),al=Y?.socials?.find(ge=>String(ge?.id||ge?.label||"").toLowerCase()==="discord")?.url||Y?.discord?.invite||null;m.useEffect(()=>{tl&&console.log("[OvercurrentHUD]",{overlayVisible:Gt,overlayMotors:cn,overlayFill:pt,limiterActive:ns,limiterCaps:on,limiterGroups:Ca,wheelOvercurrents:Pa})},[tl,pt,cn,Gt,ns,on,Ca,Pa]),m.useEffect(()=>{Ke("settings/update")},[Ke]);const _t=m.useCallback(()=>{clearTimeout(z.current),z.current=setTimeout(()=>le(Date.now()),Up)},[]),Pn=m.useCallback(()=>{clearTimeout(Q.current),Q.current=setTimeout(()=>ie(Date.now()),Up)},[]),xn=m.useCallback(async()=>{const ge=O.current;if(ge)try{ge.muted=!0,await ge.play()}catch{}},[]),Si=m.useCallback((ge=0)=>{if(h||me)return;clearTimeout(ae.current);const Xe=()=>{clearTimeout(ae.current),ae.current=setTimeout(()=>{h||Fe()},Sj)},Fe=async()=>{const Ce=O.current;if(Ce)try{await xn(),Ce.muted=!1,await Ce.play(),ve(!1)}catch{Ce.muted=!0,ve(!0),Xe()}};ae.current=setTimeout(Fe,ge)},[xn,h,me]);m.useEffect(()=>()=>{clearTimeout(z.current),clearTimeout(Q.current),clearTimeout(ae.current),clearInterval(K.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{$==="playing"&&Si(0)},[$,Si]),m.useEffect(()=>{we&&(R("snapshot"),P(null))},[we]),m.useEffect(()=>{if(we||!a?.url||!O.current)return;let ge=!0,Xe;const Fe=setTimeout(()=>ve(!0),0),Ce=(Ue,vt)=>{ge&&(Ke("video/status",{nextStatus:Ue,info:vt||null}),R(Ue),P(vt||null),Ue==="playing"&&xn(),["error","failed","disconnected","closed"].includes(Ue)&&_t())};return Xe=new Lp({url:a.url,token:a.token,video:O.current,receiveAudio:!me,onStatus:Ce}),Xe.start().catch(Ue=>{ge&&(R("error"),P(Ue.message),_t())}),()=>{ge=!1,clearTimeout(Fe),Xe?.stop()}},[we,a?.url,a?.token,ne,_t,xn,me,Ke]),m.useEffect(()=>{$==="stopped"&&a?.url&&_t()},[$,a?.url,_t]),m.useEffect(()=>{const ge=X.current;if(!ge||!l?.url){Ke("route/no-audio-url"),oe.current=null;return}const Xe=Math.max(0,Math.min(1,nl)),Fe=oe.current==null?Math.max(0,Math.min(1,ge.volume)):oe.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),Xe>Fe){const Ce=performance.now(),Ue=Fe,vt=Xe-Ue,Ct=et=>{const _e=Math.min(1,(et-Ce)/Nj),Ft=Ue+vt*_e;ge.volume=Ft,oe.current=Ft,_e<1?ce.current=requestAnimationFrame(Ct):ce.current=null};ce.current=requestAnimationFrame(Ct)}else ge.volume=Xe,oe.current=Xe;Ke("route/direct",{elementVolume:Xe,duckEnabled:Ne,mainBrushActive:rt,duckAmount:ze})},[l?.url,nl,Ne,rt,ze,Ke]),m.useEffect(()=>{if(!l?.url||!X.current)return;let ge=!0,Xe;const Fe=(Ce,Ue)=>{ge&&(Ke("audio/status",{nextStatus:Ce,info:Ue||null}),H(Ue||(Ce==="connected"?"connected":null)),fe(vt=>Ce==="connected"&&(vt==="playing"||vt==="connecting")||Ce==="new"?vt:Ce),["error","failed"].includes(Ce)&&Pn())};return Xe=new Lp({url:l.url,token:l.token,video:X.current,audioOnly:!0,onStatus:Fe}),Xe.start().catch(Ce=>{ge&&(fe("error"),H(Ce.message),Pn())}),()=>{ge=!1,Xe?.stop()}},[l?.url,l?.token,se,Pn,Ke]),m.useEffect(()=>{const ge=X.current;if(!l?.url||!ge){clearInterval(K.current);return}if(!["connecting","connected","playing","paused"].includes(re)){clearInterval(K.current);return}const Fe=async()=>{const Ce=X.current;Ce&&(Ce.muted=!1,!(!Ce.paused&&!Ce.ended)&&(Ke("retry/play-attempt"),Ce.play().then(()=>{Ke("retry/play-ok"),fe(Ue=>Ue==="connected"?"playing":Ue),H(Ue=>Ue==="paused"?null:Ue)}).catch(Ue=>{Ke("retry/play-fail",{error:Ue?.message}),H(vt=>vt||Ue?.message||"autoplay blocked")})))};return Fe(),K.current=setInterval(Fe,Aj),()=>clearInterval(K.current)},[l?.url,re,Ke]),m.useEffect(()=>{const ge=X.current;if(!ge)return;const Xe=()=>{Ke("element/play"),fe(_e=>_e==="error"?_e:"playing"),H(null)},Fe=()=>{Ke("element/pause"),fe(_e=>["error","failed","disconnected","closed","stopped"].includes(_e)?_e:"paused"),H(_e=>_e||"paused")},Ce=()=>{Ke("element/ended"),fe(_e=>_e==="error"?_e:"stopped"),H(_e=>_e||"ended")},Ue=()=>{const{error:_e}=ge,Ft=_e?.message||"audio error";Ke("element/error",{error:Ft}),fe("error"),H(Ft)},vt=()=>Ke("element/waiting"),Ct=()=>Ke("element/canplay"),et=()=>Ke("element/stalled");return ge.addEventListener("play",Xe),ge.addEventListener("pause",Fe),ge.addEventListener("ended",Ce),ge.addEventListener("error",Ue),ge.addEventListener("waiting",vt),ge.addEventListener("canplay",Ct),ge.addEventListener("stalled",et),()=>{ge.removeEventListener("play",Xe),ge.removeEventListener("pause",Fe),ge.removeEventListener("ended",Ce),ge.removeEventListener("error",Ue),ge.removeEventListener("waiting",vt),ge.removeEventListener("canplay",Ct),ge.removeEventListener("stalled",et)}},[l?.url,Ke]);const Ai=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",as=we?Ai:a?.url?$==="error"?`Error: ${F||"unknown"}`:F?`${$} (${F})`:$:"waiting",ka=l?.error?`Error: ${l.error}`:l?.url?re==="error"?`Error: ${q||"unknown"}`:q?`${re} (${q})`:re:null,ji=y==="spectator",Xt=y==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[we?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:O,muted:h||ue||me,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:X,autoPlay:!0,hidden:!0}),!Xt&&k?r.jsx(Ej,{mobileHud:it,turnSeconds:C,isActiveDriver:_,idleSkipSeconds:L}):null,Xt?null:r.jsx(Cj,{frame:p,sensors:te,label:d,status:as,audioStatus:ka,levelStatus:bo,desktopLayout:Wn,layoutFormat:g,variant:y,driverLabel:b,battery:mt,showTopDown:go,mobileHud:it,mapPosition:rn,turnTimerText:A,labelScale:E}),Xt?null:r.jsx(Rj,{compact:it}),!Xt&&tl?r.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${Gt?1:0} motors:${cn.length} fill:${Math.round(pt*100)}%`}):null,Xt?null:r.jsx(qj,{motors:cn,fill:pt,compact:it}),Xt?null:r.jsx(Mj,{battery:mt,compact:it}),!Xt&&ji&&mt.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(Nf,{visual:mt,orientation:"vertical",variant:"inline",compact:it,className:"h-full w-4"})}):null,!Xt&&f?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:r.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${it?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:f}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(If,{id:"discord",label:"Join our Discord server while you wait!",url:al})})]})}):null]}),!Xt&&!ji&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(wj,{sensors:te}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Nf,{visual:mt,compact:it})})]})]})}function wj({sensors:a}){const l=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],i=l.filter(p=>p!=null).reduce((p,x)=>Math.max(p,x),1200),o=p=>Math.pow(Math.max(0,Math.min(1,(p??0)/i)),.35),f=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:l.map((p,x)=>{const g=o(p),y=x<d/2?-1:1,b=`${g*100}%`,N=f(p);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:b,background:N,float:y===-1?"right":"left"}})})},x)})})}function Cj({frame:a,sensors:l,label:i,status:o,audioStatus:f,levelStatus:d,desktopLayout:h=!0,layoutFormat:p="desktop",variant:x="default",driverLabel:g=null,battery:y,showTopDown:b=!1,mobileHud:N=!1,mapPosition:M="top-center",turnTimerText:E=null,labelScale:w=1}){l?.bumpsAndWheelDrops;const[j,k]=m.useState(()=>Date.now());m.useEffect(()=>{const P=setInterval(()=>k(Date.now()),150);return()=>clearInterval(P)},[]),a?.receivedAt&&j-a.receivedAt<200;const A=N,C=p==="mobile-portrait",_=A?"text-[0.45rem]":"text-[0.65rem]",L=A?"px-0.25 py-0.25":"px-1 py-0.5",Y=A?"px-0.25 py-0.25":"px-0.5 py-0.5",O=A?"text-[0.55rem]":"text-[0.8rem]",X=A?"left-0.5 top-0.5":"left-1 top-1",z=A?"text-[0.5rem]":"text-[0.7rem]",Q=A?"px-0.5 py-0.25":"px-1 py-0.5",K=A?"left-0.5 top-1/2":"left-1 top-1/2",ae="bottom-0.5",ce={transform:`translateX(-50%) scale(${w})`,transformOrigin:"center bottom"},oe="240px",$=C?.3:A?.33:.7,F={width:oe,height:oe,opacity:A?.6:.7,transform:M==="top-center"?`translateX(-50%) scale(${$})`:`scale(${$})`,transformOrigin:M==="bottom-left"?"bottom left":M==="top-center"?"top center":"top right",...M==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:M==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(x==="none")return null;if(x==="spectator"){const P=[["Voltage",l?.voltageMv!=null?`${(l.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",l?.currentMa!=null?`${l.currentMa} mA`:"--"],["Charge",l?.batteryChargeMah!=null?`${l.batteryChargeMah}`:"--"],["OI",l?.oiMode?.label||"--"]],re=!!l?.chargingSources?.homeBase,fe=l?.chargingState?.label||"",q=!!(fe&&fe.toLowerCase()!=="not charging"),H=l?.oiMode?.label||"Unknown",ne=H.toLowerCase(),le=ne==="full"?"bg-emerald-500/80 text-emerald-50":ne==="safe"?"bg-amber-400/80 text-amber-950":ne==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",se=re?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",ie=q?"bg-emerald-500/80 text-emerald-50":re?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${X} font-medium text-slate-100 ${_}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),r.jsx("div",{className:`absolute ${K} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${_} ${L}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${se}`,children:re?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ie}`,children:q?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${le}`,children:["OI: ",H]})]}),P.map(([ue,ve])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ue}),r.jsx("span",{className:"font-semibold text-white",children:ve})]},ue))]})}),r.jsx("div",{className:`absolute ${ae} left-1/2`,style:ce,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${Y} ${O}`,children:[r.jsx("span",{className:"font-semibold text-white",children:i||"Unnamed Rover"}),g?r.jsxs("span",{className:"text-slate-300",children:["• ",g]}):null]})})]}),b?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...F},children:r.jsx(jf,{sensors:l,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${X} font-medium text-slate-100 ${_}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),E?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${Q} ${z}`,children:E}):null,r.jsx("div",{className:`absolute ${ae} left-1/2`,style:ce,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${Y} ${O}`,children:r.jsxs("span",{children:['Rover: "',i||"Unnamed Rover",'"']})})}),b&&x!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...F},children:r.jsx(jf,{sensors:l,size:240,overlay:!0})}):null]})}function Ej({mobileHud:a=!1,turnSeconds:l=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=a?"text-3xl":"text-5xl",d=a?"text-xs":"text-sm",h=a?"text-[0.55rem]":"text-[0.75rem]",p=a?"px-4 py-3":"px-6 py-4",x=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${p}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),x?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const kj={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function qj({motors:a,fill:l=0,compact:i=!1}){if(!a?.length)return null;const o=a.map(y=>kj[y]||y),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",p=i?"text-xs":"text-xl",x=Math.max(0,Math.min(1,l)),g=`${Math.round(x*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}function Mj({battery:a,compact:l=!1}){if(!a?.available||!a.warnActive&&!a.urgentActive)return null;const i=a.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=l?"p-2 top-6":"p-4 top-10",f=l?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function Rj({compact:a=!1}){const{session:l}=De(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:p}=Gf(),{value:x}=We("tts",{engine:"flite",voice:"rms",pitch:50}),[g,y]=m.useState(""),[b,N]=m.useState(!1),M=l?.role!=="spectator",E=l?.role==="spectator",w=l?.assignment?.roverId||null,k=!!m.useMemo(()=>l?.roster?.find(O=>String(O.id)===String(w))||null,[w,l?.roster])?.audio?.ttsEnabled,A=m.useMemo(()=>{if(!k)return null;const O=x?.engine==="espeak"?"espeak":"flite";if(O==="espeak"){let z=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof z=="number"&&(z=Math.max(0,Math.min(99,z))),{speak:!0,engine:O,pitch:z}}const X=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:O,voice:X}},[x?.engine,x?.pitch,x?.voice,k]),C=a?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",_=a?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",L=a?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function Y(O){if(O.preventDefault(),!M)return;const X=g.trim();if(X){N(!0);try{await i(X,A),y(""),d(),p(!1)}catch(z){alert(z.message)}finally{N(!1)}}}return E?null:r.jsxs("form",{onSubmit:Y,className:C,children:[r.jsx("input",{className:_,value:g,onChange:O=>{const X=O.target.value;y(X),p(!!X.trim())},onFocus:O=>{o(O),p(!!g.trim())},onBlur:O=>{f(O),p(!1)},onKeyDown:O=>{O.key==="Enter"&&!g.trim()&&(O.preventDefault(),d(),p(!1))},ref:O=>h(O,{target:"hud"}),placeholder:M?"Chat (TTS)":"Spectator",disabled:!M}),r.jsx("button",{type:"submit",disabled:!M||b,className:L,children:"Speak"})]})}function Wf({layoutFormat:a="desktop"}){const{session:l}=De(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=Dt(),[d,h]=m.useState(()=>Date.now()),[p,x]=m.useState(!1),[g,y]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(l?.mode!=="turns")return;const le=setInterval(()=>h(Date.now()),250);return()=>clearInterval(le)},[l?.mode]);const N=l?.assignment?.roverId,E=!!(N&&l?.roster?l.roster.find(le=>String(le.id)===String(N)):null)?.media?.audioPublishUrl,w=N?l?.turnQueues?.[N]:null,j=l?.socketId||null,k=N?l?.activeDrivers?.[N]:null,A=!!(j&&k===j),C=m.useMemo(()=>{const le=w?.queue||[];if(!le.length||!w?.current||le.length<=1)return null;const se=le.findIndex(ie=>ie===w.current);return se===-1?le[0]||null:le[(se+1)%le.length]||null},[w?.queue,w?.current]),_=!!(j&&C===j),L=w?.deadline||null,Y=w?.idleDeadline||null,O=L?L-d:null,X=Y?Y-d:null,z=l?.mode==="turns"&&_&&O!=null&&O<=5e3&&O>0,Q=l?.mode!=="turns"||A||z,K=O!=null&&Number.isFinite(O)?Math.max(0,Math.ceil(O/1e3)):null,ae=X!=null&&Number.isFinite(X)?Math.max(0,Math.ceil(X/1e3)):null,ce=A?K!=null?`${K}s left`:null:_&&K!=null?`Your turn in ${K}s`:null,oe=N?[...Q?[{type:"rover",id:N,key:N}]:[],...E?[{type:"rover",id:`${N}-audio`,key:`${N}-audio`}]:[]]:[],$=ci(oe),R=N&&Q?$[N]:null,F=N&&E?$[`${N}-audio`]:null,P=Zf(N?[N]:[],{enabled:!!N,version:l?.mode}),re=N&&P[N]||null,fe=ts(N),q=N&&l?.roster?l.roster.find(le=>String(le.id)===String(N)):null,H=q?.battery??null,ne=q?.name||(N?`Rover ${N}`:"");return m.useEffect(()=>{if(l?.mode!=="turns"){x(!1),y(null),b.current={active:!1,roverId:null};return}const le=b.current,se=A&&!le.active,ie=A&&N&&N!==le.roverId;se||ie?(x(!0),y(Date.now())):!A&&le.active&&(x(!1),y(null)),b.current={active:A,roverId:N}},[A,N,l?.mode]),m.useEffect(()=>{!p||!g||o>g&&x(!1)},[o,g,p]),r.jsx("section",{className:"panel",children:N?r.jsx(fi,{sessionInfo:R,videoMode:Q?"whep":"snapshot",snapshotFeed:re,audioSessionInfo:F,label:ne,telemetryFrame:fe,batteryConfig:H,layoutFormat:a,overcurrentLimiter:f,songNote:i?.note,qualityNotice:Q?null:"Preview feed (low FPS) until your turn.",showTurnCue:p,turnTimerText:ce,turnSeconds:K,isActiveDriver:A,idleSkipSeconds:ae}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function wf({label:a,tone:l="muted"}){const i=l==="success"?"bg-emerald-900 text-emerald-100":l==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:a})}function uo(a){if(!Number.isFinite(a))return 0;const l=a%360;return l<0?l+360:l}function Tj(a){if(!Array.isArray(a)||a.length<3)return 0;const[l,i,o]=a,f=Math.max(0,Math.min(255,Number(l)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(f,d,h),x=Math.min(f,d,h),g=p-x;if(g===0)return 0;let y=0;return p===f?y=(d-h)/g%6:p===d?y=(h-f)/g+2:y=(f-d)/g+4,uo(Math.round(y*60))}function Hp(a){const l=uo(a),i=1,o=1-Math.abs(l/60%2-1);let f=0,d=0,h=0;return l<60?(f=i,d=o):l<120?(f=o,d=i):l<180?(d=i,h=o):l<240?(d=o,h=i):l<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function Vp(a){return a?Array.isArray(a.hsColor)?uo(Number(a.hsColor[0])):Array.isArray(a.rgbColor)?Tj(a.rgbColor):0:0}function Dj({entity:a,connected:l,onToggle:i,onSetColor:o}){const f=a.state==="unavailable"||!a.available,d=a.state==="on",h=a.type==="light"&&a.supportsColor,p=f?"warn":d?"success":"muted",x=f?"Unavailable":d?"On":"Off",g=!l||f,y=g||!h,[b,N]=m.useState(()=>Vp(a)),M=m.useRef(b),E=m.useRef(!1),w=f?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":d?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!h||E.current)return;const L=Vp(a);M.current=L,N(L)},[a.rgbColor,a.hsColor,h]);const j=L=>{const Y=uo(Number(L.target.value));M.current=Y,N(Y)},k=()=>{y||!o||o(a.id,Hp(M.current))},A=L=>{L.stopPropagation()},_=`rgb(${(h?Hp(M.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>i(a.id),disabled:g,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${w} disabled:opacity-60 disabled:hover:bg-inherit`,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[r.jsx("span",{className:"truncate font-semibold text-white",children:a.name||a.id}),h&&r.jsxs(r.Fragment,{children:[r.jsx(wf,{label:x,tone:p}),!l&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),h?r.jsx("div",{className:"-mt-0.5 w-full",onClick:A,onPointerDown:L=>{A(L),E.current=!0},onPointerUp:L=>{A(L),E.current=!1,k()},onPointerCancel:L=>{A(L),E.current=!1,k()},onKeyUp:L=>{A(L),k()},onBlur:k,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:b,onChange:j,disabled:y,"aria-label":`Set color for ${a.name||a.id}`,className:"ha-hue-slider w-full"})})}):r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsx(wf,{label:x,tone:p}),!l&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),h&&r.jsx("span",{className:"pointer-events-none absolute right-1 top-1 h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:_}}),!h&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:d?"Turn off":"Turn on"})]})}function mg(){const{state:{keymap:a}}=Dt(),{session:l,homeAssistantToggle:i,homeAssistantSetLightColor:o}=De(),f=l?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=An(a?.homeAssistantOn?.[0]),p=An(a?.homeAssistantOff?.[0]);if(!f?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(d.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const x=!!f?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:d.length}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"On"}),h?r.jsx($p,{label:h}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),p?r.jsx($p,{label:p}):null]})]})]}),r.jsx(wf,{label:x?"Connected":"Offline",tone:x?"success":"warn"})]}),r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(g=>r.jsx(Dj,{entity:g,connected:x,onToggle:i,onSetColor:o},g.id))})]})}function $p({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function hg(){const{login:a,setRole:l}=De(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await a(i,f),o(""),d("")}catch(y){alert(y.message)}finally{p(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function Yp(...a){return a.filter(Boolean).join(" ")}function _j(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function Oj(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Bj({title:a,roster:l=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),l.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:l.map(f=>r.jsxs("li",{className:Yp("surface flex flex-wrap items-center justify-between gap-0.5",f.locked&&"bg-red-900/40"),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:f.name}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:Yp("font-semibold",Oj(f)),children:["Battery ",_j(f)]})]})]}),o?o(f):null]},f.id))})]})}const Lj=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function zj(){const{session:a,lockRover:l,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:p,setAudioLevels:x,llmControl:g,adminLogs:y,llmCommentaryState:b}=De(),N=m.useMemo(()=>a?.roster??[],[a?.roster]),[M,E]=m.useState({}),[w,j]=m.useState({}),[k,A]=m.useState(!1),[C,_]=m.useState(!1),L=a?.health||null,Y=a?.communityGoal?.text||"",O=a?.communityGoal?.updatedAt||null,[X,z]=m.useState(Y),Q=a?.adminReason?.text||"",K=a?.adminReason?.updatedAt||null,[ae,ce]=m.useState(Q),oe=a?.audioLevels||{},[$,R]=m.useState({hornGain:Number.isFinite(oe.hornGain)?oe.hornGain:1,ttsGain:Number.isFinite(oe.ttsGain)?oe.ttsGain:1,forwardGain:Number.isFinite(oe.forwardGain)?oe.forwardGain:1}),F=a?.role==="admin"||a?.role==="lockdown"||a?.role==="lockdown-admin",P=a?.mode??"open",re=async(J,pe)=>{try{await l(J,pe),E(be=>({...be,[J]:pe}))}catch(be){alert(be.message)}},fe=async J=>{const pe=J.target.value;try{await i(pe)}catch(be){alert(be.message)}},q=async J=>{try{await o(J,{force:!0})}catch(pe){alert(pe.message)}},H=async J=>{if(!(!J?.id||!window.confirm(`Reboot rover "${J.name||J.id}" now?`))){j(be=>({...be,[J.id]:!0}));try{await h(J.id)}catch(be){alert(be.message)}finally{j(be=>({...be,[J.id]:!1}))}}},ne=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){A(!0);try{await p()}catch(pe){alert(pe.message),A(!1)}}},le=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){_(!0);try{await g("clearHistory")}catch(pe){alert(pe.message)}finally{_(!1)}}},se=async()=>{try{await f(X)}catch(J){alert(J.message)}},ie=async()=>{try{await f(null)}catch(J){alert(J.message)}},ue=async()=>{try{await d(ae)}catch(J){alert(J.message)}},ve=async()=>{try{await d(null)}catch(J){alert(J.message)}},me=J=>pe=>{const be=Number(pe.target.value);R(Ne=>({...Ne||{},[J]:Number.isFinite(be)?be:1}))},we=async()=>{try{await x($)}catch(J){alert(J.message)}};m.useEffect(()=>{z(Y)},[Y]),m.useEffect(()=>{ce(Q)},[Q]),m.useEffect(()=>{R({hornGain:Number.isFinite(oe.hornGain)?oe.hornGain:1,ttsGain:Number.isFinite(oe.ttsGain)?oe.ttsGain:1,forwardGain:Number.isFinite(oe.forwardGain)?oe.forwardGain:1})},[oe.forwardGain,oe.hornGain,oe.ttsGain]);const te=m.useMemo(()=>{const J={};return N.forEach(pe=>{J[pe.id]=M[pe.id]??pe.locked}),J},[N,M]);return F?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:P,onChange:fe,className:"field-input text-sm",children:Lj.map(J=>r.jsx("option",{value:J.key,children:J.label},J.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ne,disabled:k,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:k?"Server rebooting...":"Reboot Server"})}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),a?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(a.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[$.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:$.hornGain,onChange:me("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[$.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:$.ttsGain,onChange:me("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[$.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:$.forwardGain,onChange:me("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:we,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),O?r.jsxs("span",{children:["Updated ",new Date(O).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:X,onChange:J=>z(J.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:se,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:ie,className:"button-danger",children:"Clear"})]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Admin mode reason"}),K?r.jsxs("span",{children:["Updated ",new Date(K).toLocaleString()]}):null]}),r.jsx("textarea",{value:ae,onChange:J=>ce(J.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:ue,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:ve,className:"button-danger",children:"Clear"})]})]}),r.jsx(Bj,{roster:N,renderActions:J=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>re(J.id,!te[J.id]),className:"button-dark",children:te[J.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>q(J.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>H(J),disabled:!!w[J.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:w[J.id]?"Rebooting...":"Reboot"}),r.jsxs("span",{className:"surface-muted",children:["audio: ",a?.audioForward?.[J.id]?.state||"idle"]}),a?.audioForward?.[J.id]?.error?r.jsx("span",{className:"surface-muted text-rose-300",children:String(a.audioForward[J.id].error)}):null]})}),r.jsx($j,{health:L}),r.jsx(Uj,{state:b,onClearHistory:le,clearingHistory:C}),r.jsx(Yj,{entries:y})]}):null}function Uj({state:a,onClearHistory:l,clearingHistory:i}){const[o,f]=m.useState(null);if(!a)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=a.runtime||{},h=a.counters||{},p=a.timings||{},x=a.input||{},g=a.output||{},y=a.errors||{},b=Array.isArray(a.history)?a.history:[],N=b.find(j=>j.runId===o)||(b.length?b[b.length-1]:null),M=Hj(a),E=Vj(x.modelMessages,g.raw),w=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:l,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${M.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:M.label}),r.jsx("div",{className:"text-xs text-slate-200",children:M.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:w.map(j=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[j.label,": ",j.value]},j.label))}),y.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",y.message]}):null,y.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(y.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:E.length?E.map(j=>r.jsx(Vf,{message:j.message},j.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",y.failedAt?new Date(y.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(a,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(j=>r.jsxs("button",{type:"button",onClick:()=>f(j.runId),className:`w-full text-left surface ${N?.runId===j.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",j.runId]})," ",r.jsx("span",{className:"text-slate-200",children:j.outcome||j.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:j.durationMs!=null?`${j.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:j.reason||""})]},j.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),N?r.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[r.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",N.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(N,null,2)})]}):null]})}function Hj(a){const l=a?.runtime||{},i=a?.output||{},o=a?.errors||{};return l.inFlight?{label:"IN FLIGHT",detail:l.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:l.outcome==="posted"?{label:"POSTED",detail:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:l.outcome==="skipped"?{label:"SKIPPED",detail:l.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:l.outcome==="failed"?{label:"FAILED",detail:o.message||l.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:l.running?"IDLE":"STOPPED",detail:l.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Vj(a,l){const i=Date.now(),f=(Array.isArray(a)?a:[]).map((d,h)=>{const p=String(d?.role||"").toLowerCase(),x=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(l!=null){const d=String(l);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function $j({health:a}){if(!a)return null;const l=a.replay||{sources:[],readyCount:0,totalCount:0},i=a.snapshots||{rovers:[],rooms:[]},o=`${l.readyCount}/${l.totalCount} sources ready`,f=i.rovers.filter(h=>h.stale).length,d=i.rooms.filter(h=>h.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:o})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:f?"text-amber-300":"text-emerald-300",children:[i.rovers.length-f,"/",i.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:d?"text-amber-300":"text-emerald-300",children:[i.rooms.length-d,"/",i.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:l.sources.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.label}),r.jsxs("span",{className:h.ready?"text-emerald-300":"text-amber-300",children:[h.recentCount,"/",h.neededCount]})]},`${h.type}:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rovers.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.stale?"stale":"ok"})]},`rover:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rooms.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.error?"error":h.stale?"stale":"ok"})]},`room:${h.id}`))})]})}function Yj({entries:a}){const l=a||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:l.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No admin log entries yet."}):l.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const Gj=[{id:"driveForward",label:"Drive Forward",group:"Driving"},{id:"driveBackward",label:"Drive Backward",group:"Driving"},{id:"driveLeft",label:"Turn Left",group:"Driving"},{id:"driveRight",label:"Turn Right",group:"Driving"},{id:"boostModifier",label:"Boost Modifier",group:"Driving"},{id:"slowModifier",label:"Slow Modifier",group:"Driving"},{id:"auxMainForward",label:"Main Brush Forward",group:"Aux Motors"},{id:"auxMainReverse",label:"Main Brush Reverse",group:"Aux Motors"},{id:"auxSideForward",label:"Side Brush Forward",group:"Aux Motors"},{id:"auxSideReverse",label:"Side Brush Reverse",group:"Aux Motors"},{id:"auxVacuumFast",label:"Vacuum Max",group:"Aux Motors"},{id:"auxVacuumSlow",label:"Vacuum Low",group:"Aux Motors"},{id:"auxAllForward",label:"All Aux Forward",group:"Aux Motors"},{id:"cameraUp",label:"Camera Up",group:"Camera"},{id:"cameraDown",label:"Camera Down",group:"Camera"},{id:"nightVisionToggle",label:"Toggle Night Vision",group:"Camera"},{id:"hornHonk",label:"Horn (Hold)",group:"Audio"},{id:"driveMacro",label:"Drive Macro",group:"Macros"},{id:"dockMacro",label:"Dock Macro",group:"Macros"},{id:"chatFocus",label:"Toggle Chat",group:"Chat"},{id:"songNoteUp",label:"Song Note Up",group:"Audio"},{id:"songNoteDown",label:"Song Note Down",group:"Audio"},{id:"homeAssistantOn",label:"Room Controls On (Cycle)",group:"Room Controls"},{id:"homeAssistantOff",label:"Room Controls Off (Cycle)",group:"Room Controls"}];function Xj(a){return a.reduce((l,i)=>((l[i.group]||(l[i.group]=[])).push(i),l),{})}function Fj(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}const Pf=5,di=500,mi=1,ed=100;function Qj(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(Pf,Math.min(di,i)):l}function Ir(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(mi,Math.min(ed,i)):l}function Kj(a){const i=(Ir(a,a)-mi)/(ed-mi),o=di-i*(di-Pf);return Math.round(o)}function Zj(a){const l=Qj(a,a),i=(di-l)/(di-Pf),o=mi+i*(ed-mi);return Math.round(o)}function Jj(a){const[l,i]=m.useState(null),o=m.useCallback(h=>{Gu(!0),i(h)},[]),f=m.useCallback(()=>{Gu(!1),i(null)},[]),d=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){f();return}const x=yi(p.key??"");x&&(a(h,x,p),f())},[f,a]);return m.useEffect(()=>()=>Gu(!1),[]),{active:l,startCapture:o,cancel:f,captureFromEvent:d}}function Vr({label:a,description:l,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function Ij(){const{state:{keymap:a},actions:{updateKeyBinding:l,resetKeyBindings:i}}=Dt(),{value:o,save:f}=We("inputs",Sn),d={...Sn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?Ir(d.tiltSpeed,Sn.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?Ir(Zj(d.tiltIntervalMs),Sn.keyboard.tiltSpeed):Sn.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),p=m.useMemo(()=>Xj(Gj),[]),{active:x,startCapture:g,cancel:y,captureFromEvent:b}=Jj((w,j)=>{l(w,j)}),N=m.useCallback(w=>a?.[w]?.[0]||ai[w]?.[0]||"",[a]),M=m.useCallback((w,j)=>{const k=Sn.keyboard,A=Fj(j,k[w]);f(C=>({...C??{},keyboard:{...C?.keyboard??k,[w]:A}}))},[f]),E=m.useCallback(w=>{const j=Sn.keyboard,k=Ir(w,j.tiltSpeed),A=Kj(k);f(C=>({...C??{},keyboard:{...C?.keyboard??j,tiltSpeed:k,tiltIntervalMs:A}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Vr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:w=>M("baseSpeed",w)}),r.jsx(Vr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:w=>M("turboSpeed",w)}),r.jsx(Vr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:w=>M("precisionSpeed",w)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx(Vr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:E,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([w,j])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:w}),r.jsx("div",{className:"space-y-0.5",children:j.map(k=>{const A=N(k.id),C=x===k.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:k.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:An(A)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[C&&r.jsx("button",{type:"button",onClick:()=>y(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(k.id),onKeyDown:C?_=>b(k.id,_):void 0,autoFocus:C,className:`${C?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium transition-colors`,children:C?"Press a key…":"Change"})]})]},k.id)})})]},w))})]})}const Qn=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),Wj=[{id:"drive",label:"Drive stick",kind:"axisPair",section:"Driving",invertDefaults:{invertX:!1,invertY:!0}},{id:"cameraTilt",label:"Camera tilt",kind:"axis",section:"Camera",invertDefaults:{invert:!0}},{id:"mainBrush",label:"Main brush",kind:"axis",section:"Brushes",invertDefaults:{invert:!1}},{id:"sideBrush",label:"Side brush",kind:"axis",section:"Brushes",invertDefaults:{invert:!1}},{id:"vacuum",label:"Vacuum",kind:"button",section:"Aux buttons"},{id:"allAux",label:"All aux",kind:"button",section:"Aux buttons"},{id:"mainReverse",label:"Main reverse toggle",kind:"button",section:"Brush toggles"},{id:"sideReverse",label:"Side reverse toggle",kind:"button",section:"Brush toggles"},{id:"driveMacro",label:"Drive macro",kind:"button",section:"Mode macros"},{id:"dockMacro",label:"Dock macro",kind:"button",section:"Mode macros"},{id:"nightVisionToggle",label:"Night vision toggle",kind:"button",section:"Camera"}],Gp=.45,Pj=.6;function ei({label:a,description:l,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("span",{className:"font-mono text-slate-400",children:Qn.format(d)})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function eN(a){if(!a)return"Unassigned";if(a.kind==="axisPair"){const l=`${a.invertX?"X inv ":""}${a.invertY?"Y inv":""}`.trim();return`Axes ${a.x}/${a.y}${l?` (${l})`:""}`}if(a.kind==="axis")return`Axis ${a.index}${a.invert?" (inv)":""}`;if(a.kind==="button")return`Button ${a.index}`;if(a.kind==="buttonAxis")return`Button ${a.index} (analog)`;if(a.kind==="axisButton"){const l=a.direction<0?"<":">";return`Axis ${a.index} ${l} ${Qn.format(a.threshold??.6)}`}return"Unassigned"}function tN(a){return a.reduce((l,i)=>((l[i.section]||(l[i.section]=[])).push(i),l),{})}function nN(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function aN(a){return{axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0}))}}function lN(a,l,i){const o=(a.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(l.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>Gp).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>Gp);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function sN(a,l,i){const o=a.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>Pj)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=a.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,p=Math.abs(h-(l.axes?.[d]??0));if(Math.abs(h)>.7&&p>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function iN(a,l,i){if(!a)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=lN(a,l,i);if(o)return o}return sN(a,l,i)}function rN(){const a=BA(),{value:l,save:i}=We("gamepad",ja),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>tN(Wj),[]),p=m.useMemo(()=>nN(a.pads,l.activeSignature),[a.pads,l.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?l?.profiles?.[x]??l?.defaults?.profile??Kn:l?.defaults?.profile??Kn,[x,l?.defaults?.profile,l?.profiles]);m.useEffect(()=>{!p||!x||l?.profiles?.[x]||i(j=>{const k=j??ja;if(k.profiles?.[x])return k;const A=k?.defaults?.profile??Kn,C=Ix(p,A);return{...k,profiles:{...k.profiles??{},[x]:C}}})},[p,x,l?.profiles,i]),m.useEffect(()=>{d.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!d.current){d.current=aN(p);return}const j=iN(p,d.current,o);j&&(i(k=>{const A=k??ja,C=A.profiles?.[x]??A?.defaults?.profile??Kn,_={...C,bindings:{...C.bindings??{},[o.id]:{...C.bindings?.[o.id]??{},kind:o.kind,sources:[j]}}};return{...A,profiles:{...A.profiles??{},[x]:_}}}),f(null))},[p,x,o,i]);const y=m.useCallback(j=>{i(k=>({...k??ja,activeSignature:j||null}))},[i]),b=m.useCallback(j=>{i(k=>{const A=k??ja,C=(x&&A.profiles?.[x])??A?.defaults?.profile??Kn,_={...C,calibration:{...C.calibration??{},...j}};return x?{...A,profiles:{...A.profiles??{},[x]:_}}:{...A,defaults:{...A.defaults??{},profile:_}}})},[x,i]),N=m.useCallback((j,k)=>{i(A=>{const C=A??ja,_=(x&&C.profiles?.[x])??C?.defaults?.profile??Kn,L=k(_.bindings?.[j]??{}),Y={..._,bindings:{..._.bindings??{},[j]:L}};return x?{...C,profiles:{...C.profiles??{},[x]:Y}}:{...C,defaults:{...C.defaults??{},profile:Y}}})},[x,i]),M=m.useCallback(j=>{N(j.id,k=>({...k,sources:[]}))},[N]),E=m.useCallback((j,k)=>{N(j.id,A=>{const C=Array.isArray(A.sources)?[...A.sources]:[];if(!C[0])return A;const _={...C[0]};return k==="invertX"?_.invertX=!_.invertX:k==="invertY"?_.invertY=!_.invertY:_.invert=!_.invert,C[0]=_,{...A,sources:C}})},[N]),w=m.useMemo(()=>p?{outputs:Wx(p,g)}:null,[p,g]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),a.pads.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[r.jsx("select",{value:x??"",onChange:j=>y(j.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:a.pads.map(j=>r.jsx("option",{value:j.signature,children:j.id||"Unknown controller"},j.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ei,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:j=>b({driveDeadzone:j})}),r.jsx(ei,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:j=>b({cameraDeadzone:j})}),r.jsx(ei,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:j=>b({auxDeadzone:j})}),r.jsx(ei,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:j=>b({auxSideScale:j})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:j=>b({cameraMode:j.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(ei,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:j=>b({cameraSensitivity:j})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([j,k])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:j}),r.jsx("div",{className:"space-y-0.5",children:k.map(A=>{const _=g.bindings?.[A.id]?.sources?.[0]??null;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:A.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:eN(_)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[A.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!_,onClick:()=>E(A,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!_,onClick:()=>E(A,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),A.kind==="axis"&&r.jsx("button",{type:"button",disabled:!_,onClick:()=>E(A),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>M(A),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(A),className:`${o?.id===A.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===A.id?"Waiting…":"Capture"})]})]},A.id)})})]},j))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?r.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[r.jsx("p",{className:"text-slate-400",children:"Raw axes"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((j,k)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",k,": ",Qn.format(j)]},`axis-${k}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((j,k)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",k,": ",Qn.format(j.value)," ",j.pressed?"●":""]},`btn-${k}`))}),w?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",Qn.format(w.outputs.driveVector.x),","," ",Qn.format(w.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",Qn.format(w.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",Qn.format(w.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",Qn.format(w.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const oN={drive:"Drive wheels",aux:"Aux motors"};function Xp(a){return Number.isFinite(a)?`${Math.round(a*100)}%`:"--"}function cN({value:a,color:l="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,a))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${l}`,style:{width:i}})})}function uN(){const{state:{roverId:a},overcurrentLimiter:l}=Dt(),i=m.useMemo(()=>Fl.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:l?.adminImmune?"Admin immune":"Active"})]}),a?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=l?.caps?.[o]?.cap??0,d=l?.overcurrent?.groups?.[o]??!1,h=l?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:oN[o]||o}),r.jsx("span",{className:d?"text-red-300":"text-slate-400",children:d?"overcurrent":"ok"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Cap"}),r.jsx("span",{children:Xp(f)})]}),r.jsx(cN,{value:f,color:"bg-amber-500"}),r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Scale"}),r.jsx("span",{children:Xp(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${l?.config?.downRatePerSec}/s · Up rate ${l?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${l?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${l?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const pg=m.createContext(null);function xg(){const a=m.useContext(pg);if(!a)throw new Error("Tabs components must be used within a <Tabs> provider.");return a}const Fp={primary:{base:"flex-1 px-0.5 py-0.5 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-slate-500 rounded-md border border-slate-800",active:"bg-sky-600 text-white border-white",inactive:"bg-zinc-900 text-slate-300 hover:bg-sky-500 hover:text-white"}},gg="primary";function td(...a){return a.filter(Boolean).join(" ")}function nd({children:a,defaultTab:l,currentTab:i,onTabChange:o,variant:f=gg}){const[d,h]=m.useState(l??null),[p,x]=m.useState([]),g=m.useCallback(M=>M?(x(E=>E.includes(M)?E:[...E,M]),()=>x(E=>E.includes(M)?E.filter(w=>w!==M):E)):()=>{},[]),y=i??d??p[0]??null;m.useEffect(()=>{l&&i===void 0&&h(l)},[l,i]);const b=m.useCallback(M=>{M&&(i===void 0&&h(M),o&&o(M))},[i,o]),N=m.useMemo(()=>({activeTab:y,setActiveTab:b,registerTab:g,variant:f}),[y,b,g,f]);return r.jsx(pg.Provider,{value:N,children:a})}function ad({children:a,className:l=""}){return r.jsx("div",{className:td("flex gap-0.5",l),children:a})}function $t({id:a,children:l,className:i="",disabled:o=!1}){const{activeTab:f,setActiveTab:d,registerTab:h,variant:p}=xg();m.useEffect(()=>h(a),[a,h]);const x=Fp[p]??Fp[gg],g=f===a,y=td(x.base,g?x.active:x.inactive,o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:y,onClick:()=>!o&&d(a),"aria-pressed":g,"aria-disabled":o,children:l})}function ld({children:a,className:l=""}){return r.jsx("div",{className:td("mt-0 space-y-0.5",l),children:a})}function Yt({id:a,children:l,keepMounted:i=!1}){const{activeTab:o}=xg(),f=o===a;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:l}):r.jsx(r.Fragment,{children:l})}function fN(){const{session:a}=De(),l=m.useMemo(()=>JSON.stringify(a??{},null,2),[a]);return r.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),r.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:l})]})}const Qp=300,Kp=240;function dN(a,l){if(a===void 0)return"undefined";if(a===null)return"null";if(typeof a=="string")return a;if(typeof a=="number"||typeof a=="boolean")return String(a);if(typeof a=="function")return"[Function]";if(a instanceof Error)return`${a.name}: ${a.message}`;if(a instanceof Date)return a.toISOString();if(l||(l=new WeakSet),typeof a=="object"){if(l.has(a))return"[Circular]";l.add(a)}try{return JSON.stringify(a,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(a)}}function mN(a){const i=a.map(o=>dN(o)).join(" ");return i.length>Kp?`${i.slice(0,Kp)}…`:i}function hN(){const a=Cn(),[l,i]=m.useState([]),o=m.useMemo(()=>l.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[l]);return m.useEffect(()=>{const f=(x,g,y)=>{i(b=>{const N=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:mN(y),timestamp:new Date().toLocaleTimeString()}];return N.length>Qp?N.slice(-Qp):N})},d=(x,...g)=>f("in",x,g),h=(x,...g)=>f("out",x,g);a.onAny(d);let p=null;if(typeof a.onAnyOutgoing=="function")a.onAnyOutgoing(h),p=()=>a.offAnyOutgoing(h);else{const x=a.emit.bind(a);a.emit=(g,...y)=>(h(g,...y),x(g,...y)),p=()=>{a.emit=x}}return()=>{a.offAny(d),p&&p()}},[a]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No socket activity yet."}):l.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const pN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function vg(){const{state:{roverId:a},actions:{sendOiCommand:l,setSensorStream:i}}=Dt(),o=!!a,[f,d]=fg(),h=Cn(),{value:p,save:x}=We("page",{hudMapDesktop:!1,connectionTransport:"websocket"}),{value:g,save:y}=We("audio",jt),b=p?.connectionTransport||"websocket",N=Number.isFinite(g?.masterVolume)?g.masterVolume:jt.masterVolume,M=Number.isFinite(g?.alertVolume)?g.alertVolume:jt.alertVolume,E=Number.isFinite(g?.roverVolume)?g.roverVolume:jt.roverVolume,w=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:jt.mainBrushDuckEnabled,j=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):jt.mainBrushDuckAmount,k=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),A=Y=>{a&&i(Y)},C=Y=>{const O=Y.target.value;x(X=>({...X??{},connectionTransport:O})),h?.io?.opts&&(h.io.opts.transports=O==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},_=Y=>O=>{const X=Number(O.target.value),z=Number.isFinite(X)?Math.max(0,Math.min(1,X)):0;y(Q=>({...Q??{},[Y]:z}))},L=Y=>{const O=!!Y.target.checked;y(X=>({...X??{},mainBrushDuckEnabled:O}))};return r.jsxs(nd,{defaultTab:"keybindings",children:[r.jsxs(ad,{children:[r.jsx($t,{id:"keybindings",children:"Keybindings"}),r.jsx($t,{id:"controller",children:"Controller"}),r.jsx($t,{id:"page",children:"Page settings"}),r.jsx($t,{id:"admin",children:"Admin"})]}),r.jsxs(ld,{children:[r.jsx(Yt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(Ij,{})})}),r.jsx(Yt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(rN,{})})}),r.jsx(Yt,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:Y=>d(Y.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:_("masterVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Alert/page sounds"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(M*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:M,onChange:_("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:_("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:w,onChange:L})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:_("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!w})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:C,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(Yt,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:pN.map(Y=>r.jsx("button",{type:"button",onClick:()=>l(Y.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:Y.label},Y.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:k.map(Y=>r.jsx("button",{type:"button",onClick:()=>A(Y.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:Y.label},Y.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(hg,{}),r.jsx(uN,{}),r.jsx(zj,{}),r.jsx(fN,{}),r.jsx(hN,{})]})})]})]})}const Zp={desktop:{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel, on the bottom left of the page below the rover video.",{segments:["Toggle chat focus with ",{action:"chatFocus"},". Press ",{action:"chatFocus"}," again to send."]}]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen, or press ',{action:"driveMacro"}," on your keyboard to put the rover into driving mode."]},"Refer to the controls for the controls for the rover."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen, or press ',{action:"dockMacro"}," on your keyboard to start docking."]},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}],aside:[{type:"keyboard",title:"Keyboard controls",footnote:"Per-browser; adjust bindings and speeds in Settings → Keybindings.",groups:[{id:"movement",title:"Movement",items:[{action:"driveForward",label:"Forward"},{action:"driveBackward",label:"Backward"},{action:"driveLeft",label:"Turn left"},{action:"driveRight",label:"Turn right"},{action:"boostModifier",label:"Boost speed"},{action:"slowModifier",label:"Precision speed"}]},{id:"macros",title:"Rover modes & chat",items:[{action:"driveMacro",label:"Drive macro"},{action:"dockMacro",label:"Dock macro"},{action:"chatFocus",label:"Chat focus"}]},{id:"camera",title:"Camera",items:[{action:"cameraUp",label:"Tilt up"},{action:"cameraDown",label:"Tilt down"},{action:"nightVisionToggle",label:"Toggle night vision"}]},{id:"motors",title:"Rover Aux Motors",items:[{action:"auxMainForward",label:"Main brush forward"},{action:"auxMainReverse",label:"Main brush reverse"},{action:"auxSideForward",label:"Side brush forward"},{action:"auxSideReverse",label:"Side brush reverse"},{action:"auxVacuumFast",label:"Vacuum max"},{action:"auxVacuumSlow",label:"Vacuum low"},{action:"auxAllForward",label:"All motors forward"}]},{id:"audio",title:"Audio / Song",items:[{action:"songNoteUp",label:"Song note up"},{action:"songNoteDown",label:"Song note down"}]},{id:"room-controls",title:"Room Controls",items:[{action:"homeAssistantOn",label:"Next room control on"},{action:"homeAssistantOff",label:"Next room control off (reverse)"}]}]},{type:"gamepad",title:"Gamepad / joystick",items:["Gamepad controls are fully configurable to handle inconsistent browser mappings.","Use Settings → Controller to bind inputs, calibrate deadzones, and view diagnostics.","If inputs behave oddly, the diagnostics panel will show raw axis/button values."]}]},"mobile-portrait":{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen to put the rover into driving mode.']},"Look below the rover video. Use the joystick on the right to move the rover, and hold the buttons on the left to run the aux motors."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]},"mobile-landscape":{main:[{type:"list",title:"Chat and nicknames",items:["Scroll down to see more of the page.","Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button, or the "Drive" button to put the rover into driving mode.']},"Use the joystick to the right of the video feed to move the rover, and hold the buttons on the left to run the aux motors."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" or the "Dock" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]}};function xN(a){return Zp[a]||Zp.desktop}function yg({actionId:a,keymap:l}){const i=l?.[a]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:An(i)})}function Jp(a,l){return a.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(yg,{actionId:i.action,keymap:l},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function fo(a,l,i){if(typeof a=="string")return a;if(Array.isArray(a?.segments))return Jp(a.segments,l);if(a&&typeof a=="object"){if(typeof a.text=="string")return a.text;if(Array.isArray(a))return Jp(a,l)}return String(a??"")}function gN({hero:a,keymap:l}){return a?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:a.title}),a.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:a.subtitle})]}),a.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:a.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),a.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:a.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:fo(i,l)},f)})})]}):null}function vN({block:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:fo(i,l)},f)})})]})}function yN({block:a}){const l=a.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${l} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:a.title}),a.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:fo(i,{})},`callout-${o}`))})]})}function bN({group:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:a.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:a.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(yg,{actionId:i.action,keymap:l})]},i.action))})]})}function SN({block:a,keymap:l}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:a.title}),a.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:a.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:a.groups?.map(i=>r.jsx(bN,{group:i,keymap:l},i.id))})]}):null}function AN({block:a}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items?.map((l,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:fo(l,{})},`gamepad-${i}`))})]}):null}function Ip({block:a,keymap:l}){if(!a)return null;switch(a.type){case"list":return r.jsx(vN,{block:a,keymap:l});case"callout":return r.jsx(yN,{block:a});case"keyboard":return r.jsx(SN,{block:a,keymap:l});case"gamepad":return r.jsx(AN,{block:a});default:return null}}function bg({layout:a,keymap:l}){const i=m.useMemo(()=>xN(a),[a]),o=l||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(gN,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>r.jsx(Ip,{block:h,keymap:o},h.title||p))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,p)=>r.jsx(Ip,{block:h,keymap:o},h.title||p))})]})]})}function Sg({layout:a,onOpenOverlay:l}){const{state:i}=Dt();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:l,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(bg,{layout:a,keymap:i?.keymap||{}})]})}const jN=["kal","rms","slt","ksp","bdl"],NN=Array.from({length:10},(a,l)=>l*10);function mo({hideInput:a=!1,hideSpectatorNotice:l=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=De(),{messages:d,typing:h,sendMessage:p,registerInputRef:x,onInputFocus:g,onInputBlur:y,blurChat:b,setTypingActive:N}=Gf(),{value:M,save:E}=We("tts",{engine:"flite",voice:"rms",pitch:50}),[w,j]=m.useState(""),[k,A]=m.useState(!1),[C,_]=m.useState(!1),[L,Y]=m.useState(()=>M?.engine||"flite"),[O,X]=m.useState(()=>M?.voice||"rms"),[z,Q]=m.useState(()=>Number.isFinite(M?.pitch)?M.pitch:50),K=f?.role!=="spectator"||o,ae=m.useRef(null),ce=f?.assignment?.roverId||null,$=!!m.useMemo(()=>f?.roster?.find(q=>String(q.id)===String(ce))||null,[ce,f?.roster])?.audio?.ttsEnabled,R=m.useMemo(()=>d.slice(-200),[d]),F=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{ae.current&&(ae.current.scrollTop=ae.current.scrollHeight)},[R,F]),m.useEffect(()=>{const q=M?.engine||"flite",H=M?.voice||"rms",ne=Number.isFinite(M?.pitch)?M.pitch:50;L!==q&&Y(q),O!==H&&X(H),z!==ne&&Q(ne)},[L,z,M?.engine,M?.pitch,M?.voice,O]),m.useEffect(()=>{_(!!$)},[$]);const P=m.useMemo(()=>!$||!C?null:L==="espeak"?{speak:!0,engine:L,pitch:z}:{speak:!0,engine:L,voice:O},[L,z,C,$,O]);async function re(q){if(q.preventDefault(),!K||a)return;const ne=w.replace(/\\n/g,`
|
||
`).trim();if(ne){A(!0);try{await p(ne,P),j(""),b(),N(!1)}catch(le){alert(le.message)}finally{A(!1)}}}const fe=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${fe}`,ref:ae,children:[R.length===0&&F.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):R.map(q=>r.jsx(Vf,{message:q},q.id)),F.map(q=>r.jsx($x,{message:q},`typing-${q.typingId||q.id}`))]}),!a&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:re,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:w,onChange:q=>{const H=q.target.value;j(H),N(!!H.trim())},onFocus:q=>{g(q),N(!!w.trim())},onBlur:q=>{y(q),N(!1)},onKeyDown:q=>{q.key==="Enter"&&!w.trim()&&(q.preventDefault(),b(),N(!1))},ref:q=>x(q,{target:"panel"}),placeholder:K?"Type a message…":l?"":"Spectators cannot chat",disabled:!K}),$&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:C,onChange:q=>_(q.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:L,onChange:q=>{const H=q.target.value;Y(H),E(ne=>({...ne||{},engine:H}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),L==="flite"?r.jsx("select",{value:O,onChange:q=>{const H=q.target.value;X(H),E(ne=>({...ne||{},voice:H}))},className:"field-input text-xs",children:jN.map(q=>r.jsx("option",{value:q,children:q},q))}):r.jsx("select",{value:z,onChange:q=>{const H=Number(q.target.value);Q(H),E(ne=>({...ne||{},pitch:H}))},className:"field-input text-xs",children:NN.map(q=>r.jsxs("option",{value:q,children:["pitch ",q]},q))})]}),r.jsx("button",{type:"submit",disabled:!K||k,className:"button-dark h-full disabled:opacity-50 self-stretch",children:k?"...":"Send"})]})]})}function ho({compact:a=!1}){const{session:l,setNickname:i}=De(),{value:o,save:f}=We("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=l?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function y(b){if(b.preventDefault(),!g)return;const N=(d||"").trim().slice(0,32);if(N){x(!0);try{await i(N),f({nickname:N})}catch(M){alert(M.message)}finally{x(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:y,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":a?"Set":"Save"})]})}function wN(a){const l=Array.isArray(a?.socials)?a.socials:null;if(l&&l.length)return l;const i=[];return a?.discord?.invite&&i.push({id:"discord",label:"Discord",url:a.discord.invite}),a?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:a.kofi.link}),i}function CN(a){if(!a||typeof a!="object")return null;const l=a.id||a.service||a.key||a.name||null,i=a.label||a.title||a.name||l||"Link",o=a.url||a.link||a.href||null;return o?{id:l,label:i,url:o}:null}function Ag({className:a=""}){const{session:l}=De(),i=wN(l).map(CN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${a}`,children:i.map(o=>r.jsx(If,{...o},`${o.id||o.label}-${o.url}`))}):null}function EN({compact:a=!1}){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(ho,{compact:a})})})}function kN(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Ag,{className:"flex-1 min-h-0"})})}function lf(...a){return a.filter(Boolean).join(" ")}function qN(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function MN(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function RN(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function TN(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function po({title:a="Rovers"}){const{session:l,requestControl:i}=De(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),p=m.useMemo(()=>l?.role&&l.role!=="spectator",[l?.role]),x=l?.roster??[],g=l?.turnQueues??{},y=l?.users??[],b=l?.socketId||null,N=m.useMemo(()=>Object.values(g||{}).some(j=>j?.deadline||j?.idleDeadline),[g]);m.useEffect(()=>{if(!N)return;const j=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(j)},[N]);const M=m.useMemo(()=>{const j=new Set(x.map(A=>String(A.id))),k=Object.keys(g||{}).filter(A=>!j.has(String(A))).map(A=>({id:A,name:A,locked:!1,batteryState:null}));return[...x,...k]},[x,g]);async function E(j){if(j){f(k=>({...k,[j]:!0}));try{await i(j)}catch(k){alert(k.message)}finally{f(k=>({...k,[j]:!1}))}}}const w=j=>y.find(k=>k.socketId===j)||{socketId:j,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),M.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:M.map(j=>{const k=String(j.id),A=g?.[k]||null,C=A?.queue||[],_=A?.idleDeadline||A?.deadline||null,L=_&&_>d?Math.ceil((_-d)/1e3):_?0:null,Y=A?.current||null,O=Y?C.findIndex(R=>R===Y):-1,X=C.length>1?O>=0?C[(O+1)%C.length]:C[0]:null,z=!!(b&&Y&&Y===b),Q=!!(b&&X&&X===b),K=L!=null&&(z||Q),ae=!!j.locked,ce=j.lockReason?`locked: ${j.lockReason}`:"locked",oe=ae?ce:o[k]?"...":"request",$=p&&!ae&&!o[k];return r.jsxs("li",{className:lf("surface flex flex-wrap items-start justify-between gap-0.5",$&&"cursor-pointer",ae&&"bg-red-900/40"),onClick:()=>{$&&E(j.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:j.name}),K?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:z?`${L}s left`:`Your turn in ${L}s`}):null]}),r.jsx("span",{className:lf("text-[0.75rem] font-semibold",MN(j)),children:qN(j)})]}),C.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:C.map((R,F)=>{const P=w(R),re=R===Y,fe=!!(X&&R===X&&!re),q=re?"bg-sky-600 text-white ring-2 ring-amber-300":fe?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return r.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${q}`,children:[r.jsx("span",{className:`${RN(P.role)} font-semibold`,children:TN(P,b)}),re&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),fe&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${k}-${R}-${F}`)})})]}),p?r.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),E(j.id)},disabled:o[k]||ae,className:lf("button-dark disabled:opacity-40",ae&&"bg-red-600/70 text-white hover:bg-red-600"),children:oe}):null]},j.id)})})]})}function DN(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function _N(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function ao({hideNicknameForm:a=!1,hideHeader:l=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=De(),h=d?.role!=="spectator",p=d?.users??[],x=d?.socketId||null,g=m.useMemo(()=>[...p].sort((b,N)=>b.socketId===x?-1:N.socketId===x?1:(b.nickname||"").localeCompare(N.nickname||"")),[x,p]),y=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!a&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(ho,{compact:f})})}),r.jsx(Ag,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!l&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${y} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(b=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${DN(b.role)}`,children:_N(b,x)},b.socketId))})]})]})}const ON=/^cu_[a-f0-9]{32}$/,Wp=8*1024*1024,hi="field-input w-full max-w-sm text-left focus:ring-emerald-500",Kl="mx-auto w-full max-w-xl flex justify-center",si="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function BN(a){const l=String(a||"").trim();return l?l.length<=10?`${l.slice(0,2)}***${l.slice(-2)}`:`${l.slice(0,6)}...${l.slice(-6)}`:""}function LN(a){let l="";for(let o=0;o<a.length;o+=32768){const f=a.subarray(o,o+32768);l+=String.fromCharCode(...f)}return btoa(l)}function zN({roster:a=[],ownRoverId:l="",audioForwardByRover:i={},playUploadedAudio:o,stopUploadedAudio:f}){const[d,h]=m.useState(null),[p,x]=m.useState(!1),[g,y]=m.useState(""),b=a.length===1?a[0].id:"",N=String(b||l||"").trim(),M=m.useMemo(()=>N&&i?.[N]||null,[i,N]),E=async()=>{const j=N;if(!j){y("Take control of a rover first.");return}if(!d){y("Select an audio file first.");return}if(d.size>Wp){y(`File too large (max ${Wp} bytes).`);return}x(!0),y("");try{const k=await d.arrayBuffer(),A=LN(new Uint8Array(k));await o?.({roverId:j,name:d.name,mime:d.type||"",dataBase64:A}),y(`Playing upload on ${j}.`)}catch(k){y(k.message||"Failed to play upload.")}finally{x(!1)}},w=async()=>{const j=N;if(!j){y("Take control of a rover first.");return}x(!0),y("");try{await f?.(j),y(`Stopped upload on ${j}.`)}catch(k){y(k.message||"Failed to stop upload.")}finally{x(!1)}};return r.jsx("section",{className:`surface ${Kl}`,children:r.jsxs("div",{className:si,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"VIP Audio Forwarding"}),r.jsxs("label",{className:"grid w-full gap-0.5 text-xs text-slate-300",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:hi,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:p||!N,onChange:j=>h(j.target.files?.[0]||null)})]}),d?r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:[d.name," (",d.size," bytes)"]}):null,r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:p||!N,onClick:E,children:p?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:p||!N,onClick:w,children:"Stop"})]}),M?r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["state: ",M.state||"idle",M.error?` | error: ${M.error}`:""]}):null,g?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:g}):null]})})}function UN({pendingRequestId:a,currentStoredKey:l,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d}){const[h,p]=m.useState(0),[x,g]=m.useState(""),[y,b]=m.useState(!1),[N,M]=m.useState(!1),E=()=>{p(1),g(l),b(!1),d?.("")},w=()=>{p(0),b(!1)},j=async k=>{if(k.preventDefault(),!y){d?.("Please confirm your nickname agreement before sending.");return}if(h<3){d?.("Complete all request steps before sending.");return}M(!0),d?.("");try{const A=await f(x);await o?.(),g(A),p(0),b(!1),d?.("Verification request sent to lockdown admins.")}catch(A){d?.(A.message||"Failed to submit request.")}finally{M(!1)}};return a?r.jsx("section",{className:`surface text-sm text-slate-300 ${Kl}`,children:r.jsxs("div",{className:si,children:["Verification request pending: ",a]})}):h===0?r.jsx("section",{className:`surface ${Kl}`,children:r.jsxs("div",{className:si,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:E,disabled:N,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${Kl}`,onSubmit:j,children:r.jsxs("div",{className:si,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(ho,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:y,onChange:k=>b(k.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!y,onClick:()=>p(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,h===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:hi,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>g(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>navigator.clipboard?.writeText(x),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>p(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(1),children:"Back"})]})]}):null,h===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:hi,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>g(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:N||!x,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(2),children:"Back"})]})]}):null]})})}function HN({currentStoredKey:a,applyIdentityKey:l,onMessage:i}){const[o,f]=m.useState(0),[d,h]=m.useState(""),[p,x]=m.useState(!1),g=()=>{f(1),h(""),i?.("")},y=()=>{f(0),h("")},b=async N=>{if(N.preventDefault(),!(o<2)){x(!0),i?.("");try{await l(d),f(0),h(""),i?.("Identity key restored.")}catch(M){i?.(M.message||"Failed to restore key.")}finally{x(!1)}}};return r.jsx("section",{className:`surface ${Kl}`,children:r.jsxs("div",{className:si,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",BN(a)||"not set yet"]}),r.jsx("input",{className:hi,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:a,readOnly:!0,placeholder:"Identity key"}),o===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!a,onClick:()=>navigator.clipboard?.writeText(a),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:g,disabled:p,children:"Restore Key"})]}):null,o===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,children:"Cancel"})]})]}):null,o===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:b,children:[r.jsx("input",{className:hi,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:d,onChange:N=>h(N.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:p||!d,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function jg(){const{session:a,identifySession:l,requestVerification:i,playUploadedAudio:o,stopUploadedAudio:f}=De(),{value:d,save:h}=We("identity",{cookieUserId:""}),{value:p}=We("profile",{nickname:""}),x=m.useMemo(()=>(d?.cookieUserId||"").trim(),[d?.cookieUserId]),g=(p?.nickname||"").trim(),y=!!a?.isVerified,b=a?.verification?.pendingRequestId||null,N=m.useMemo(()=>a?.roster??[],[a?.roster]),M=String(a?.assignment?.roverId||"").trim(),E=m.useMemo(()=>M?N.filter(A=>A.id===M):[],[M,N]),[w,j]=m.useState(""),k=async A=>{const C=String(A||"").trim().toLowerCase();if(!C)throw new Error("Identity key required.");if(!ON.test(C))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return h(_=>({..._||{},cookieUserId:C})),await l({cookieUserId:C,nickname:g}),C};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[y?r.jsx(zN,{roster:E,ownRoverId:M,audioForwardByRover:a?.audioForward||{},playUploadedAudio:o,stopUploadedAudio:f}):r.jsx(UN,{pendingRequestId:b,currentStoredKey:x,nickname:g,requestVerification:i,applyIdentityKey:k,onMessage:j}),r.jsx(HN,{currentStoredKey:x,applyIdentityKey:k,onMessage:j}),w?r.jsx("div",{className:Kl,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:w})}):null]})}function VN(){const{state:{roverId:a}}=Dt(),i=ts(a)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(jf,{sensors:i})})})}function $N(){const{state:{roverId:a,keymap:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:p,stopHorn:x}}=Dt(),g=ng(a),y=g.docked&&!g.driving,b=i?.config,N=!!(a&&i?.enabled&&b),M=!!(a&&f?.nightVision),E=f?.nightVisionState,w=!!(a&&f?.horn),j=o?.overheated,k=typeof b?.minAngle=="number"?b.minAngle:-30,A=typeof b?.maxAngle=="number"?b.maxAngle:30,C=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(k+A)/2,_=An(l?.nightVisionToggle?.[0]),L=An(l?.hornHonk?.[0]),Y=An(l?.cameraUp?.[0]),O=An(l?.cameraDown?.[0]);return r.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[r.jsx(ag,{layout:"desktop",expand:!0,driveDockState:g}),y?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[M&&r.jsx(lg,{nightVisionOn:E?.nightVisionOn,disabled:!a,onToggle:h,keyLabel:_}),w&&r.jsx(sg,{disabled:!a||j,onStart:p,onStop:x,keyLabel:L,active:o?.active,heat:o?.heat}),N&&r.jsx(ig,{value:C,min:k,max:A,onChange:d,keyDownLabel:O,keyUpLabel:Y,className:"space-y-0.5 px-1 py-1",labelRowClass:"text-xs text-slate-300",labelClass:"",valueClass:"font-mono text-slate-100",sliderClass:"w-full",accentClass:"accent-emerald-400",endpointClass:"text-[0.7rem] text-slate-400"})]})]})}function YN({layout:a,onOpenHelpOverlay:l}){const{session:i}=De(),o=i?.isVerified?"bg-emerald-400":"bg-red-600";return r.jsx("section",{className:"panel text-base",children:r.jsxs(nd,{defaultTab:"telemetry",children:[r.jsxs(ad,{children:[r.jsx($t,{id:"telemetry",children:"Controls"}),r.jsx($t,{id:"vip",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${o}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx($t,{id:"help",children:"Help"}),r.jsx($t,{id:"settings",children:"Settings"})]}),r.jsxs(ld,{children:[r.jsx(Yt,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(VN,{}),r.jsx($N,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(po,{}),r.jsx(Uf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(kN,{})]}),r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[r.jsx(mo,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(ao,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(EN,{compact:!0})]})]}),r.jsx(mg,{}),r.jsx(Qf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Yt,{id:"vip",children:r.jsx(jg,{})}),r.jsx(Yt,{id:"help",children:r.jsx(Sg,{layout:a,onOpenOverlay:l})}),r.jsx(Yt,{id:"settings",children:r.jsx(vg,{})})]})]})})}const GN=new Set(["admin","lockdown","lockdown-admin"]),XN=new Set(["lockdown","lockdown-admin"]),FN=new Set(["admin","lockdown"]);function QN(a="admin"){return a==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function KN(){const{session:a}=De(),l=a?.mode,i=a?.role,o=a?.adminReason?.text||"";a?.adminReason?.updatedAt;const f=a?.timezone||"UTC",d=a?.socials?.find(N=>String(N?.id||N?.label||"").toLowerCase()==="discord")?.url||a?.discord?.invite||null,h=FN.has(l),p=l==="lockdown"?XN.has(i):GN.has(i),[x,g]=m.useState(()=>new Date),y=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,f]);if(m.useEffect(()=>{const N=setInterval(()=>g(new Date),1e3);return()=>clearInterval(N)},[]),!h||p)return null;const b=QN(l);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children:b.title}),r.jsx("p",{className:"text-sm text-slate-300",children:b.description})]}),r.jsxs("div",{className:"surface-muted space-y-0.5",children:[r.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),r.jsx("p",{className:"text-lg font-semibold text-slate-100",children:o||"No reason set."}),r.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",y]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(hg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(If,{id:"discord",label:"Join our Discord server for updates!",url:d})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(mo,{}),r.jsx(ho,{})]})]})})}const ZN="/assets/turn_alert-DVO8EZJa.mp3";function JN(a,l=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(a),i.current.volume=l,i.current.load()},[a,l]),()=>{i.current&&(i.current.volume=l,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function IN(){const{session:a,pushAlert:l}=De(),{value:i}=We("audio",jt),o=Number.isFinite(i?.masterVolume)?i.masterVolume:jt.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:jt.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=JN(ZN,d),p=m.useRef(new Set),x=m.useMemo(()=>a?.turnQueues||{},[a?.turnQueues]),g=a?.socketId||null;return m.useEffect(()=>{if(!g)return;const y=[];Object.entries(x).forEach(([b,N])=>{!N||!N.current||N.current!==g||p.current.has(b)||(y.push(b),p.current.add(b))}),Object.keys(x).forEach(b=>{(!x[b]||x[b].current!==g)&&p.current.delete(b)}),y.length!==0&&(y.forEach(b=>{const N=a?.roster?.find(M=>String(M.id)===String(b))?.name||b;l({title:"Your turn!",message:`You now control ${N}.`,color:"#ff5722"})}),h())},[x,h,l,a?.roster,g]),null}function WN({visible:a,mode:l,onEnterFullscreen:i,onDismiss:o}){if(!a)return null;const f=l==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}const Ng="fullscreenPromptDismissed",PN=new Set(["mobile-portrait","mobile-landscape"]),wg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},ew=()=>{const a=wg();if(!a)return!1;try{return a.getItem(Ng)==="1"}catch{return!1}},Pp=()=>{const a=wg();if(a)try{a.setItem(Ng,"1")}catch{}},tw=()=>{if(typeof navigator>"u")return!1;const a=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(a)},nw=()=>{if(typeof document>"u")return!1;const a=document;return!!(a.fullscreenEnabled||a.webkitFullscreenEnabled||a.mozFullScreenEnabled||a.msFullscreenEnabled)};function aw(a){const l=PN.has(a),[i,o]=m.useState(!1),[f,d]=m.useState("native"),h=m.useMemo(()=>tw(),[]),p=m.useCallback(()=>{if(!l){o(!1);return}if(ew()){o(!1);return}if(h){d("pwa-hint"),o(!0);return}if(!nw()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,l]);m.useEffect(()=>{p()},[p]),m.useEffect(()=>{if(typeof document>"u")return;const y=()=>{if(document.fullscreenElement){o(!1);return}p()};return document.addEventListener("fullscreenchange",y),document.addEventListener("webkitfullscreenchange",y),()=>{document.removeEventListener("fullscreenchange",y),document.removeEventListener("webkitfullscreenchange",y)}},[p]);const x=m.useCallback(()=>{Pp(),o(!1)},[]),g=m.useCallback(async()=>{if(!l||h||typeof document>"u")return!1;const y=document.documentElement;if(!y)return!1;const b=y.requestFullscreen||y.webkitRequestFullscreen||y.mozRequestFullScreen||y.msRequestFullscreen;if(!b)return!1;try{const N=b.call(y);return N&&typeof N.then=="function"&&await N,Pp(),o(!1),!0}catch(N){return console.warn("Failed to enter fullscreen",N),!1}},[h,l]);return m.useEffect(()=>{l||o(!1)},[l]),{visible:i,mode:f,enterFullscreen:g,dismiss:x}}function lw({visible:a,layout:l,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!a)return null;const{state:d}=Dt(),h=p=>{const x=!p.target.checked;f?.(x)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(bg,{layout:l,keymap:d?.keymap||{}})})]})})}const sw=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
`;function iw(a){return a?a.charAt(0).toUpperCase()+a.slice(1):""}function rw(){const a=String(sw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return a.length?(a[Math.floor(Math.random()*a.length)]||"").trim():""}function sd(){const{setNickname:a}=De(),{value:l,status:i,save:o}=We("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(l.nickname||"").trim())return;f.current=!0;const h=iw(rw()).slice(0,32);if(!h)return;(async()=>{try{await a(h)}catch{}finally{o({nickname:h})}})()},[o,a,i,l.nickname])}function ow(){const a=Cn(),{connected:l,identifySession:i}=De(),{value:o,status:f,save:d}=We("identity",{cookieUserId:""}),{value:h,status:p}=We("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),b=f==="ready"&&p==="ready",N=(o?.cookieUserId||"").trim(),M=(h?.nickname||"").trim(),E=m.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),w=m.useCallback(async()=>{if(!(!b||!l||!a?.id||x.current)){x.current=!0;try{const k=((await i({cookieUserId:N,nickname:M}))?.cookieUserId||"").trim();k&&k!==N&&d(A=>({...A||{},cookieUserId:k})),g.current=a.id,E()}catch{E(),y.current=setTimeout(()=>{w()},2e3)}finally{x.current=!1}}},[E,l,N,i,M,b,d,a?.id]);m.useEffect(()=>{!b||!l||!a?.id||g.current!==a.id&&w()},[l,b,w,a?.id]),m.useEffect(()=>{!b||!l||!a?.id||w()},[b,l,a?.id,N,M,w]),m.useEffect(()=>{const j=()=>{a?.connected&&w()},k=()=>{typeof document>"u"||document.visibilityState!=="visible"||a?.connected&&w()};return window.addEventListener("online",j),document.addEventListener("visibilitychange",k),()=>{window.removeEventListener("online",j),document.removeEventListener("visibilitychange",k)}},[w,a?.connected]),m.useEffect(()=>()=>E(),[E])}const sf=1e4,rf=28,cw=14;function lo({layout:a="desktop",className:l="",dismissable:i=!0}){const{session:o}=De(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=a==="mobile-portrait"||a==="mobile-landscape"||a==="mobile",[h,p]=m.useState(!1),[x,g]=m.useState(rf),[y,b]=m.useState(0),N=m.useRef(null),M=m.useRef(null),E=m.useRef(null);m.useEffect(()=>{if(!f){p(!1);return}if(p(!0),!d||!i)return;const A=Date.now();b(sf);const C=setTimeout(()=>p(!1),sf),_=setInterval(()=>{const L=Date.now()-A;b(Math.max(0,sf-L))},250);return()=>{clearTimeout(C),clearInterval(_)}},[f,d]),m.useEffect(()=>{if(!f)return;g(rf);let A=0;const C=()=>{const L=E.current,Y=M.current;if(!L||!Y)return;const O=L.clientWidth;if(!O)return;const X=Y.scrollWidth;if(!X)return;const z=Math.min(1,O/X),Q=Math.max(cw,Math.floor(rf*z));g(Q)};A=window.requestAnimationFrame(C);const _=new ResizeObserver(()=>{window.cancelAnimationFrame(A),A=window.requestAnimationFrame(C)});return N.current&&_.observe(N.current),()=>{window.cancelAnimationFrame(A),_.disconnect()}},[f]);const w=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",l].filter(Boolean).join(" "),[l,d]);if(!f||!h)return null;const j=d?Math.ceil(y/1e3):null,k=i?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:N,className:w,style:{fontSize:`${x}px`,lineHeight:1.1},...k,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:E,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:M,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[j,"s"]}):null]})})}function uw(){const[a,l]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?l("desktop"):o>f?l("mobile-landscape"):l("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),a}function fw({layout:a,onOpenHelpOverlay:l}){return r.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[r.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[r.jsx(Wf,{}),r.jsx(wS,{}),r.jsx(Kf,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(lo,{layout:a}),r.jsx(YN,{layout:a,onOpenHelpOverlay:l})]})]})}function Cg({layout:a,onOpenHelpOverlay:l,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=De(),d=f?.isVerified?"bg-emerald-400":"bg-amber-400";return r.jsx("section",{className:"panel text-base",children:r.jsxs(nd,{defaultTab:"chat",children:[r.jsxs(ad,{children:[r.jsx($t,{id:"chat",children:"Chat"}),r.jsx($t,{id:"vip",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${d}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx($t,{id:"roomcontrols",children:"Room Controls"}),r.jsx($t,{id:"help",children:"Help"}),r.jsx($t,{id:"settings",children:"Settings"})]}),r.jsxs(ld,{children:[r.jsx(Yt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(mo,{}),r.jsx(ao,{})]})}),r.jsx(Yt,{id:"vip",children:r.jsx(jg,{})}),r.jsx(Yt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(mg,{}),r.jsx(Qf,{panelId:i})]})}),r.jsx(Yt,{id:"help",children:r.jsx(Sg,{layout:a,onOpenOverlay:l})}),r.jsx(Yt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(vg,{}),r.jsx(Kf,{})]})})]})]})})}function dw({onOpenHelpOverlay:a}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(Wf,{layoutFormat:"mobile-portrait"}),r.jsx(WA,{}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Uf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(po,{})]}),r.jsx(Cg,{layout:"mobile-portrait",onOpenHelpOverlay:a,roomPanelId:"mobile-portrait-room"})]})}function mw({onOpenHelpOverlay:a}){const l="self-start h-[min(100svh,32rem)]";return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[r.jsx(rg,{layout:"landscape",className:l}),r.jsxs("div",{children:[r.jsx(Wf,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Uf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(po,{})]})]}),r.jsx(og,{layout:"landscape",className:l})]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Cg,{layout:"mobile-landscape",onOpenHelpOverlay:a,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function hw(){const a=uw(),l=a==="desktop",i=aw(a);return r.jsx("div",{className:`bg-black text-slate-100 ${l?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(pw,{layout:a,isDesktop:l,fullscreen:i})})}function pw({layout:a,isDesktop:l,fullscreen:i}){sd(),ow();const{visible:o,mode:f,enterFullscreen:d,dismiss:h}=i,{value:p,status:x,save:g}=We("help",{showOnLoad:!0}),[y,b]=m.useState(!1);m.useEffect(()=>{x==="ready"&&b(p?.showOnLoad!==!1)},[x,p?.showOnLoad]);const N=m.useCallback(()=>b(!0),[]),M=m.useCallback(()=>b(!1),[]),E=m.useCallback(j=>{const k=!!j;g(A=>({...A??{},showOnLoad:k})),k||b(!1)},[g]),w=m.useMemo(()=>l?r.jsx(fw,{layout:a,onOpenHelpOverlay:N}):a==="mobile-landscape"?r.jsx(mw,{onOpenHelpOverlay:N}):r.jsx(dw,{onOpenHelpOverlay:N}),[l,a,N]);return r.jsxs(pA,{children:[r.jsx(CA,{}),r.jsx($A,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${l?"h-full overflow-hidden":""}`,children:[l?null:r.jsx(lo,{layout:a}),w]}),r.jsx($f,{}),r.jsx(IN,{}),r.jsx(KN,{}),r.jsx(lw,{visible:y,layout:a,onClose:M,showOnLoad:p?.showOnLoad!==!1,onToggleShowOnLoad:E}),r.jsx(WN,{visible:o,mode:f,onEnterFullscreen:d,onDismiss:h})]})}function Eg(){const{session:a,setRole:l,subscribeAll:i,connected:o}=De(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(a?.mode==="lockdown"){d(!1);return}try{a?.role!=="spectator"&&await l("spectator"),await i(),h||d(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||d(!1)}}return p(),()=>{h=!0}},[o,a?.mode,a?.role,l,i]),f}function xw(){const[a,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>l(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),a}function gw({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f} (turns)`:f}function vw({rover:a,frame:l,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const p=gw({roverId:a.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(fi,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:a.name,telemetryFrame:l,batteryConfig:a.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function yw({roster:a,frames:l,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return a.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:a.map(p=>r.jsx(vw,{rover:p,frame:l[p.id],sessionInfo:h&&i[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:f[`${p.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function bw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(Qf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Sw({className:a=""}){return r.jsx("div",{className:`panel ${a}`,children:r.jsx(Kf,{})})}function Aw(){const{session:a}=De(),l=a?.mode==="lockdown",i=!!a?.isLocalNetwork;sd(),Eg();const o=xw(),f=zf(),d=a?.roster??[],h=Zf(d.map(j=>j.id),{enabled:!l&&!i,version:a?.mode}),p=i?d.map(j=>({type:"rover",id:j.id,key:j.id})):[],x=ci(p,{enabled:!l&&i,version:a?.mode}),g=d.flatMap(j=>j.media?.audioPublishUrl?[{type:"rover",id:`${j.id}-audio`,key:`${j.id}-audio`}]:[]),y=ci(g,{enabled:!l,version:a?.mode});if(l)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const b=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",N=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",M=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",E="",w=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:b,children:[r.jsxs("section",{className:M,children:[o?r.jsxs("div",{className:`${E} ${w} flex flex-col gap-0.5`,children:[r.jsx(lo,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ao,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsx("div",{className:E,children:r.jsx(lo,{layout:"desktop",dismissable:!1,className:"text-sm"})}),r.jsx("div",{className:`${E} ${o?`${w} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(po,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${E} flex-1 min-h-0`,children:r.jsx(ao,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${E} ${o?w:"flex-[1.1] min-h-0"}`,children:r.jsx(mo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${E} ${o?w:""}`,children:r.jsx(Sw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:N,children:[r.jsx(yw,{roster:d,frames:f,videoSources:x,snapshotFeeds:h,audioSources:y,session:a,canSpectateVideo:i}),r.jsx(bw,{})]})]}),r.jsx($f,{})]})}function jw(){return r.jsx(Aw,{})}const Nw=2e4,ww=3600*1e3;function Cw({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f}`:f}function Ew({rover:a,frame:l}){const i=l?.sensors?.batteryChargeMah??null,o=a?.battery??null;return dg({batteryState:a?.batteryState??null,charge:i,config:o})}function ex({rover:a,frame:l,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=Ew({rover:a,frame:l}),y=g?.available?g.percentDisplay:null,b=x==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(Nf,{visual:g,orientation:b?"vertical":"horizontal",variant:"background"}),b?r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:y==null?"--%":`${y}%`})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Xl,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:y==null?"--%":`${y}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(fi,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:a.name||a.id,telemetryFrame:l,batteryConfig:a.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function Xl({children:a,className:l="",maxSize:i=1e3,minSize:o=14}){const f=m.useRef(null),d=m.useRef(null),[h,p]=m.useState(i);return m.useLayoutEffect(()=>{const x=f.current,g=d.current;if(!x||!g)return;let y=null;const b=()=>{const E=x.clientWidth;if(!E){N();return}let w=o,j=i,k=o;for(;w<=j;){const A=Math.floor((w+j)/2);g.style.fontSize=`${A}px`,g.scrollWidth<=E?(k=A,w=A+1):j=A-1}p(k)},N=()=>{y&&cancelAnimationFrame(y),y=requestAnimationFrame(b)};N();const M=new ResizeObserver(N);return M.observe(x),()=>{y&&cancelAnimationFrame(y),M.disconnect()}},[a,i,o]),r.jsx("div",{ref:f,className:"w-full min-w-0",children:r.jsx("div",{ref:d,className:`whitespace-nowrap ${l}`,style:{fontSize:`${h}px`,lineHeight:1.1},children:a})})}function kw(){const{session:a}=De(),l=Eg();sd();const i=a?.mode==="lockdown",o=!!a?.isLocalNetwork,f=zf(),d=a?.roster??[],[h,p]=m.useState(0),x=a?.activeDrivers||{},g=m.useMemo(()=>d.filter(Q=>x[Q.id]),[d,x]),y=g.length?g:d,b=Zf(y.map(Q=>Q.id),{enabled:!i&&!o,version:a?.mode}),N=m.useMemo(()=>o?y.map(Q=>({type:"rover",id:Q.id,key:Q.id})):[],[o,y]),M=ci(N,{enabled:!i&&o,version:a?.mode}),E=m.useMemo(()=>g.flatMap(Q=>{if(!Q?.id||!Q.media?.audioPublishUrl)return[];const K=String(Q.id);return[{type:"rover",id:`${K}-audio`,key:`${K}-audio`}]}),[g]),w=ci(E,{enabled:!i,version:a?.mode}),j=m.useMemo(()=>{if(!g.length)return[];if(!o){const K=g.filter(ae=>b[ae.id]?.objectUrl);return K.length?K:g}const Q=g.filter(K=>{const ae=M[K.id];return ae?.url&&!ae?.error});return Q.length?Q:g},[g,b,M,o]),k=m.useMemo(()=>j.map(Q=>({type:"rover",rover:Q})),[j]),A=m.useMemo(()=>k.map(Q=>`r:${Q.rover.id}`).join("|"),[k]);m.useEffect(()=>{p(0)},[A]),m.useEffect(()=>{if(!k.length)return;const Q=setInterval(()=>{p(K=>(K+1)%k.length)},Nw);return()=>clearInterval(Q)},[k.length,A]);const C=k.length?k[h%k.length]:null,_=C?.type==="rover"?C.rover:null,L=!o&&_&&b[_.id]||null,Y=o&&_&&M[_.id]||null,O=_&&w[`${_.id}-audio`]||null,X=_&&f[_.id]||null,z=_?Cw({roverId:_.id,session:a}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:l?_?r.jsx(Mw,{children:o?r.jsx("div",{className:"relative h-full w-full",children:k.map(Q=>{const K=Q.rover,ae=_?.id===K.id;return r.jsx("div",{className:`absolute inset-0 ${ae?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(fi,{sessionInfo:M[K.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:ae?O:null,forceMute:!ae,label:K.name||K.id,telemetryFrame:f[K.id]||null,batteryConfig:K.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},K.id)})}):r.jsx(fi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:L,audioSessionInfo:O,label:_.name||_.id,telemetryFrame:X,batteryConfig:_.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:_?r.jsx(ex,{rover:_,frame:X,driverLabel:z,sessionInfo:o?Y:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[_.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((Q,K)=>r.jsx(ex,{rover:Q,frame:f[Q.id]||null,driverLabel:null,sessionInfo:o&&M[Q.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[Q.id]||null,showPreview:!0,withDivider:!1},Q.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function qw(){return m.useEffect(()=>{if(typeof window>"u")return;const a=setTimeout(()=>{const l=new URL(window.location.href);l.searchParams.set("refresh",Date.now().toString()),window.location.replace(l.toString())},ww);return()=>clearTimeout(a)},[]),r.jsxs(r.Fragment,{children:[r.jsx(kw,{}),r.jsx($f,{scale:3})]})}function Mw({children:a}){return r.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:r.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:r.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:a})})})}Zy.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(vS,{children:r.jsx(bS,{children:r.jsx(SS,{children:r.jsx(MS,{children:r.jsx(gA,{children:r.jsx(u1,{children:r.jsxs(Vb,{children:[r.jsx($r,{path:"/",element:r.jsx(hw,{})}),r.jsx($r,{path:"/spectate",element:r.jsx(jw,{})}),r.jsx($r,{path:"/mini",element:r.jsx(qw,{})})]})})})})})})})}));
|