mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
132 lines
571 KiB
JavaScript
132 lines
571 KiB
JavaScript
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))o(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&o(p)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();function py(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qu={exports:{}},nr={};var pp;function xy(){if(pp)return nr;pp=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function r(o,u,f){var p=null;if(f!==void 0&&(p=""+f),u.key!==void 0&&(p=""+u.key),"key"in u){f={};for(var h in u)h!=="key"&&(f[h]=u[h])}else f=u;return u=f.ref,{$$typeof:n,type:o,key:p,ref:u!==void 0?u:null,props:f}}return nr.Fragment=s,nr.jsx=r,nr.jsxs=r,nr}var xp;function gy(){return xp||(xp=1,Qu.exports=xy()),Qu.exports}var l=gy(),Ku={exports:{}},Ce={};var gp;function vy(){if(gp)return Ce;gp=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),p=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=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 C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,w={};function j(q,_,I){this.props=q,this.context=_,this.refs=w,this.updater=I||C}j.prototype.isReactComponent={},j.prototype.setState=function(q,_){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,_,"setState")},j.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function R(){}R.prototype=j.prototype;function k(q,_,I){this.props=q,this.context=_,this.refs=w,this.updater=I||C}var E=k.prototype=new R;E.constructor=k,S(E,j.prototype),E.isPureReactComponent=!0;var B=Array.isArray;function X(){}var L={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function K(q,_,I){var ne=I.ref;return{$$typeof:n,type:q,key:_,ref:ne!==void 0?ne:null,props:I}}function V(q,_){return K(q.type,_,q.props)}function F(q){return typeof q=="object"&&q!==null&&q.$$typeof===n}function W(q){var _={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(I){return _[I]})}var ie=/\/+/g;function oe(q,_){return typeof q=="object"&&q!==null&&q.key!=null?W(""+q.key):_.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(X,X):(q.status="pending",q.then(function(_){q.status==="pending"&&(q.status="fulfilled",q.value=_)},function(_){q.status==="pending"&&(q.status="rejected",q.reason=_)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function T(q,_,I,ne,me){var ce=typeof q;(ce==="undefined"||ce==="boolean")&&(q=null);var se=!1;if(q===null)se=!0;else switch(ce){case"bigint":case"string":case"number":se=!0;break;case"object":switch(q.$$typeof){case n:case s:se=!0;break;case v:return se=q._init,T(se(q._payload),_,I,ne,me)}}if(se)return me=me(q),se=ne===""?"."+oe(q,0):ne,B(me)?(I="",se!=null&&(I=se.replace(ie,"$&/")+"/"),T(me,_,I,"",function(be){return be})):me!=null&&(F(me)&&(me=V(me,I+(me.key==null||q&&q.key===me.key?"":(""+me.key).replace(ie,"$&/")+"/")+se)),_.push(me)),1;se=0;var ve=ne===""?".":ne+":";if(B(q))for(var he=0;he<q.length;he++)ne=q[he],ce=ve+oe(ne,he),se+=T(ne,_,I,ce,me);else if(he=M(q),typeof he=="function")for(q=he.call(q),he=0;!(ne=q.next()).done;)ne=ne.value,ce=ve+oe(ne,he++),se+=T(ne,_,I,ce,me);else if(ce==="object"){if(typeof q.then=="function")return T($(q),_,I,ne,me);throw _=String(q),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.")}return se}function H(q,_,I){if(q==null)return q;var ne=[],me=0;return T(q,ne,"","",function(ce){return _.call(I,ce,me++)}),ne}function J(q){if(q._status===-1){var _=q._result;_=_(),_.then(function(I){(q._status===0||q._status===-1)&&(q._status=1,q._result=I)},function(I){(q._status===0||q._status===-1)&&(q._status=2,q._result=I)}),q._status===-1&&(q._status=0,q._result=_)}if(q._status===1)return q._result.default;throw q._result}var te=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var _=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(_))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},ue={map:H,forEach:function(q,_,I){H(q,function(){_.apply(this,arguments)},I)},count:function(q){var _=0;return H(q,function(){_++}),_},toArray:function(q){return H(q,function(_){return _})||[]},only:function(q){if(!F(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Ce.Activity=y,Ce.Children=ue,Ce.Component=j,Ce.Fragment=r,Ce.Profiler=u,Ce.PureComponent=k,Ce.StrictMode=o,Ce.Suspense=x,Ce.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,Ce.__COMPILER_RUNTIME={__proto__:null,c:function(q){return L.H.useMemoCache(q)}},Ce.cache=function(q){return function(){return q.apply(null,arguments)}},Ce.cacheSignal=function(){return null},Ce.cloneElement=function(q,_,I){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var ne=S({},q.props),me=q.key;if(_!=null)for(ce in _.key!==void 0&&(me=""+_.key),_)!z.call(_,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&_.ref===void 0||(ne[ce]=_[ce]);var ce=arguments.length-2;if(ce===1)ne.children=I;else if(1<ce){for(var se=Array(ce),ve=0;ve<ce;ve++)se[ve]=arguments[ve+2];ne.children=se}return K(q.type,me,ne)},Ce.createContext=function(q){return q={$$typeof:p,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:f,_context:q},q},Ce.createElement=function(q,_,I){var ne,me={},ce=null;if(_!=null)for(ne in _.key!==void 0&&(ce=""+_.key),_)z.call(_,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(me[ne]=_[ne]);var se=arguments.length-2;if(se===1)me.children=I;else if(1<se){for(var ve=Array(se),he=0;he<se;he++)ve[he]=arguments[he+2];me.children=ve}if(q&&q.defaultProps)for(ne in se=q.defaultProps,se)me[ne]===void 0&&(me[ne]=se[ne]);return K(q,ce,me)},Ce.createRef=function(){return{current:null}},Ce.forwardRef=function(q){return{$$typeof:h,render:q}},Ce.isValidElement=F,Ce.lazy=function(q){return{$$typeof:v,_payload:{_status:-1,_result:q},_init:J}},Ce.memo=function(q,_){return{$$typeof:g,type:q,compare:_===void 0?null:_}},Ce.startTransition=function(q){var _=L.T,I={};L.T=I;try{var ne=q(),me=L.S;me!==null&&me(I,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(X,te)}catch(ce){te(ce)}finally{_!==null&&I.types!==null&&(_.types=I.types),L.T=_}},Ce.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},Ce.use=function(q){return L.H.use(q)},Ce.useActionState=function(q,_,I){return L.H.useActionState(q,_,I)},Ce.useCallback=function(q,_){return L.H.useCallback(q,_)},Ce.useContext=function(q){return L.H.useContext(q)},Ce.useDebugValue=function(){},Ce.useDeferredValue=function(q,_){return L.H.useDeferredValue(q,_)},Ce.useEffect=function(q,_){return L.H.useEffect(q,_)},Ce.useEffectEvent=function(q){return L.H.useEffectEvent(q)},Ce.useId=function(){return L.H.useId()},Ce.useImperativeHandle=function(q,_,I){return L.H.useImperativeHandle(q,_,I)},Ce.useInsertionEffect=function(q,_){return L.H.useInsertionEffect(q,_)},Ce.useLayoutEffect=function(q,_){return L.H.useLayoutEffect(q,_)},Ce.useMemo=function(q,_){return L.H.useMemo(q,_)},Ce.useOptimistic=function(q,_){return L.H.useOptimistic(q,_)},Ce.useReducer=function(q,_,I){return L.H.useReducer(q,_,I)},Ce.useRef=function(q){return L.H.useRef(q)},Ce.useState=function(q){return L.H.useState(q)},Ce.useSyncExternalStore=function(q,_,I){return L.H.useSyncExternalStore(q,_,I)},Ce.useTransition=function(){return L.H.useTransition()},Ce.version="19.2.0",Ce}var vp;function $d(){return vp||(vp=1,Ku.exports=vy()),Ku.exports}var m=$d();const an=py(m);var Zu={exports:{}},ar={},Iu={exports:{}},Ju={};var bp;function by(){return bp||(bp=1,(function(n){function s(T,H){var J=T.length;T.push(H);e:for(;0<J;){var te=J-1>>>1,ue=T[te];if(0<u(ue,H))T[te]=H,T[J]=ue,J=te;else break e}}function r(T){return T.length===0?null:T[0]}function o(T){if(T.length===0)return null;var H=T[0],J=T.pop();if(J!==H){T[0]=J;e:for(var te=0,ue=T.length,q=ue>>>1;te<q;){var _=2*(te+1)-1,I=T[_],ne=_+1,me=T[ne];if(0>u(I,J))ne<ue&&0>u(me,I)?(T[te]=me,T[ne]=J,te=ne):(T[te]=I,T[_]=J,te=_);else if(ne<ue&&0>u(me,J))T[te]=me,T[ne]=J,te=ne;else break e}}return H}function u(T,H){var J=T.sortIndex-H.sortIndex;return J!==0?J:T.id-H.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var p=Date,h=p.now();n.unstable_now=function(){return p.now()-h}}var x=[],g=[],v=1,y=null,N=3,M=!1,C=!1,S=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function E(T){for(var H=r(g);H!==null;){if(H.callback===null)o(g);else if(H.startTime<=T)o(g),H.sortIndex=H.expirationTime,s(x,H);else break;H=r(g)}}function B(T){if(S=!1,E(T),!C)if(r(x)!==null)C=!0,X||(X=!0,W());else{var H=r(g);H!==null&&$(B,H.startTime-T)}}var X=!1,L=-1,z=5,K=-1;function V(){return w?!0:!(n.unstable_now()-K<z)}function F(){if(w=!1,X){var T=n.unstable_now();K=T;var H=!0;try{e:{C=!1,S&&(S=!1,R(L),L=-1),M=!0;var J=N;try{t:{for(E(T),y=r(x);y!==null&&!(y.expirationTime>T&&V());){var te=y.callback;if(typeof te=="function"){y.callback=null,N=y.priorityLevel;var ue=te(y.expirationTime<=T);if(T=n.unstable_now(),typeof ue=="function"){y.callback=ue,E(T),H=!0;break t}y===r(x)&&o(x),E(T)}else o(x);y=r(x)}if(y!==null)H=!0;else{var q=r(g);q!==null&&$(B,q.startTime-T),H=!1}}break e}finally{y=null,N=J,M=!1}H=void 0}}finally{H?W():X=!1}}}var W;if(typeof k=="function")W=function(){k(F)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,oe=ie.port2;ie.port1.onmessage=F,W=function(){oe.postMessage(null)}}else W=function(){j(F,0)};function $(T,H){L=j(function(){T(n.unstable_now())},H)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return N},n.unstable_next=function(T){switch(N){case 1:case 2:case 3:var H=3;break;default:H=N}var J=N;N=H;try{return T()}finally{N=J}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(T,H){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=N;N=T;try{return H()}finally{N=J}},n.unstable_scheduleCallback=function(T,H,J){var te=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?te+J:te):J=te,T){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=J+ue,T={id:v++,callback:H,priorityLevel:T,startTime:J,expirationTime:ue,sortIndex:-1},J>te?(T.sortIndex=J,s(g,T),r(x)===null&&T===r(g)&&(S?(R(L),L=-1):S=!0,$(B,J-te))):(T.sortIndex=ue,s(x,T),C||M||(C=!0,X||(X=!0,W()))),T},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(T){var H=N;return function(){var J=N;N=H;try{return T.apply(this,arguments)}finally{N=J}}}})(Ju)),Ju}var yp;function yy(){return yp||(yp=1,Iu.exports=by()),Iu.exports}var Pu={exports:{}},_t={};var Sp;function Sy(){if(Sp)return _t;Sp=1;var n=$d();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)g+="&args[]="+encodeURIComponent(arguments[v])}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 r(){}var o={d:{f:r,r:function(){throw Error(s(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function f(x,g,v){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:y==null?null:""+y,children:x,containerInfo:g,implementation:v}}var p=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return _t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,_t.createPortal=function(x,g){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return f(x,g,null,v)},_t.flushSync=function(x){var g=p.T,v=o.p;try{if(p.T=null,o.p=2,x)return x()}finally{p.T=g,o.p=v,o.d.f()}},_t.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))},_t.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},_t.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var v=g.as,y=h(v,g.crossOrigin),N=typeof g.integrity=="string"?g.integrity:void 0,M=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;v==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:y,integrity:N,fetchPriority:M}):v==="script"&&o.d.X(x,{crossOrigin:y,integrity:N,fetchPriority:M,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},_t.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var v=h(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:v,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)},_t.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var v=g.as,y=h(v,g.crossOrigin);o.d.L(x,v,{crossOrigin:y,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})}},_t.preloadModule=function(x,g){if(typeof x=="string")if(g){var v=h(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},_t.requestFormReset=function(x){o.d.r(x)},_t.unstable_batchedUpdates=function(x,g){return x(g)},_t.useFormState=function(x,g,v){return p.H.useFormState(x,g,v)},_t.useFormStatus=function(){return p.H.useHostTransitionStatus()},_t.version="19.2.0",_t}var jp;function jy(){if(jp)return Pu.exports;jp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Pu.exports=Sy(),Pu.exports}var Np;function Ny(){if(Np)return ar;Np=1;var n=yy(),s=$d(),r=jy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}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 u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function p(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 h(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(f(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,i=t;;){var c=a.return;if(c===null)break;var d=c.alternate;if(d===null){if(i=c.return,i!==null){a=i;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===a)return x(c),e;if(d===i)return x(c),t;d=d.sibling}throw Error(o(188))}if(a.return!==i.return)a=c,i=d;else{for(var b=!1,A=c.child;A;){if(A===a){b=!0,a=c,i=d;break}if(A===i){b=!0,i=c,a=d;break}A=A.sibling}if(!b){for(A=d.child;A;){if(A===a){b=!0,a=d,i=c;break}if(A===i){b=!0,i=d,a=c;break}A=A.sibling}if(!b)throw Error(o(189))}}if(a.alternate!==i)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,N=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),k=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function W(e){return e===null||typeof e!="object"?null:(e=F&&e[F]||e["@@iterator"],typeof e=="function"?e:null)}var ie=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case j:return"Profiler";case w:return"StrictMode";case B:return"Suspense";case X:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case k:return e.displayName||"Context";case R:return(e._context.displayName||"Context")+".Consumer";case E:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case z:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var $=Array.isArray,T=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},te=[],ue=-1;function q(e){return{current:e}}function _(e){0>ue||(e.current=te[ue],te[ue]=null,ue--)}function I(e,t){ue++,te[ue]=e.current,e.current=t}var ne=q(null),me=q(null),ce=q(null),se=q(null);function ve(e,t){switch(I(ce,t),I(me,e),I(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?z0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=z0(t),e=U0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_(ne),I(ne,e)}function he(){_(ne),_(me),_(ce)}function be(e){e.memoizedState!==null&&I(se,e);var t=ne.current,a=U0(t,e.type);t!==a&&(I(me,e),I(ne,a))}function Ve(e){me.current===e&&(_(ne),_(me)),se.current===e&&(_(se),Pl._currentValue=J)}var De,Te;function ze(e){if(De===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);De=t&&t[1]||"",Te=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+De+e+Te}var $e=!1;function vt(e,t){if(!e||$e)return"";$e=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(Z){var Q=Z}Reflect.construct(e,[],ae)}else{try{ae.call()}catch(Z){Q=Z}e.call(ae.prototype)}}else{try{throw Error()}catch(Z){Q=Z}(ae=e())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(Z){if(Z&&Q&&typeof Z.stack=="string")return[Z.stack,Q.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=i.DetermineComponentFrameRoot(),b=d[0],A=d[1];if(b&&A){var D=b.split(`
|
||
`),Y=A.split(`
|
||
`);for(c=i=0;i<D.length&&!D[i].includes("DetermineComponentFrameRoot");)i++;for(;c<Y.length&&!Y[c].includes("DetermineComponentFrameRoot");)c++;if(i===D.length||c===Y.length)for(i=D.length-1,c=Y.length-1;1<=i&&0<=c&&D[i]!==Y[c];)c--;for(;1<=i&&0<=c;i--,c--)if(D[i]!==Y[c]){if(i!==1||c!==1)do if(i--,c--,0>c||D[i]!==Y[c]){var P=`
|
||
`+D[i].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),P}while(1<=i&&0<=c);break}}}finally{$e=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?ze(a):""}function re(e,t){switch(e.tag){case 26:case 27:case 5:return ze(e.type);case 16:return ze("Lazy");case 13:return e.child!==t&&t!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return vt(e.type,!1);case 11:return vt(e.type.render,!1);case 1:return vt(e.type,!0);case 31:return ze("Activity");default:return""}}function xe(e){try{var t="",a=null;do t+=re(e,a),a=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var Ee=Object.prototype.hasOwnProperty,fe=n.unstable_scheduleCallback,we=n.unstable_cancelCallback,Ae=n.unstable_shouldYield,it=n.unstable_requestPaint,le=n.unstable_now,de=n.unstable_getCurrentPriorityLevel,Me=n.unstable_ImmediatePriority,ft=n.unstable_UserBlockingPriority,kt=n.unstable_NormalPriority,ds=n.unstable_LowPriority,Qt=n.unstable_IdlePriority,Ba=n.log,qr=n.unstable_setDisableYieldValue,En=null,ot=null;function Ot(e){if(typeof Ba=="function"&&qr(e),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(En,e)}catch{}}var Bt=Math.clz32?Math.clz32:Tr,fs=Math.log,Bo=Math.LN2;function Tr(e){return e>>>=0,e===0?32:31-(fs(e)/Bo|0)|0}var nt=256,kn=262144,ca=4194304;function ln(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 La(e,t,a){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,b=e.pingedLanes;e=e.warmLanes;var A=i&134217727;return A!==0?(i=A&~d,i!==0?c=ln(i):(b&=A,b!==0?c=ln(b):a||(a=A&~e,a!==0&&(c=ln(a))))):(A=i&~d,A!==0?c=ln(A):b!==0?c=ln(b):a||(a=i&~e,a!==0&&(c=ln(a)))),c===0?0:t!==0&&t!==c&&(t&d)===0&&(d=c&-c,a=t&-t,d>=a||d===32&&(a&4194048)!==0)?t:c}function za(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Lo(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 Dr(){var e=ca;return ca<<=1,(ca&62914560)===0&&(ca=4194304),e}function ms(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function Lt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Se(e,t,a,i,c,d){var b=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var A=e.entanglements,D=e.expirationTimes,Y=e.hiddenUpdates;for(a=b&~a;0<a;){var P=31-Bt(a),ae=1<<P;A[P]=0,D[P]=-1;var Q=Y[P];if(Q!==null)for(Y[P]=null,P=0;P<Q.length;P++){var Z=Q[P];Z!==null&&(Z.lane&=-536870913)}a&=~ae}i!==0&&Ke(e,i,0),d!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=d&~(b&~t))}function Ke(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-Bt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|a&261930}function et(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var i=31-Bt(a),c=1<<i;c&t|e[i]&t&&(e[i]|=t),a&=~c}}function qe(e,t){var a=t&-t;return a=(a&42)!==0?1:Ge(a),(a&(e.suspendedLanes|t))!==0?0:a}function Ge(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 At(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ua(){var e=H.p;return e!==0?e:(e=window.event,e===void 0?32:op(e.type))}function Ua(e,t){var a=H.p;try{return H.p=e,t()}finally{H.p=a}}var at=Math.random().toString(36).slice(2),ct="__reactFiber$"+at,Ut="__reactProps$"+at,hs="__reactContainer$"+at,zo="__reactEvents$"+at,sv="__reactListeners$"+at,lv="__reactHandles$"+at,Af="__reactResources$"+at,ml="__reactMarker$"+at;function Uo(e){delete e[ct],delete e[Ut],delete e[zo],delete e[sv],delete e[lv]}function ps(e){var t=e[ct];if(t)return t;for(var a=e.parentNode;a;){if(t=a[hs]||a[ct]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=X0(e);e!==null;){if(a=e[ct])return a;e=X0(e)}return t}e=a,a=e.parentNode}return null}function xs(e){if(e=e[ct]||e[hs]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function hl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function gs(e){var t=e[Af];return t||(t=e[Af]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ct(e){e[ml]=!0}var Cf=new Set,Ef={};function Ha(e,t){vs(e,t),vs(e+"Capture",t)}function vs(e,t){for(Ef[e]=t,e=0;e<t.length;e++)Cf.add(t[e])}var rv=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]*$"),kf={},Mf={};function iv(e){return Ee.call(Mf,e)?!0:Ee.call(kf,e)?!1:rv.test(e)?Mf[e]=!0:(kf[e]=!0,!1)}function _r(e,t,a){if(iv(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function Or(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Ln(e,t,a,i){if(i===null)e.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+i)}}function rn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Rf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ov(e,t,a){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,d=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(b){a=""+b,d.call(this,b)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return a},setValue:function(b){a=""+b},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ho(e){if(!e._valueTracker){var t=Rf(e)?"checked":"value";e._valueTracker=ov(e,t,""+e[t])}}function qf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),i="";return e&&(i=Rf(e)?e.checked?"true":"false":e.value),e=i,e!==a?(t.setValue(e),!0):!1}function Br(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 cv=/[\n"\\]/g;function on(e){return e.replace(cv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Vo(e,t,a,i,c,d,b,A){e.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.type=b:e.removeAttribute("type"),t!=null?b==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+rn(t)):e.value!==""+rn(t)&&(e.value=""+rn(t)):b!=="submit"&&b!=="reset"||e.removeAttribute("value"),t!=null?$o(e,b,rn(t)):a!=null?$o(e,b,rn(a)):i!=null&&e.removeAttribute("value"),c==null&&d!=null&&(e.defaultChecked=!!d),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+rn(A):e.removeAttribute("name")}function Tf(e,t,a,i,c,d,b,A){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.type=d),t!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){Ho(e);return}a=a!=null?""+rn(a):"",t=t!=null?""+rn(t):a,A||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=A?e.checked:!!i,e.defaultChecked=!!i,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(e.name=b),Ho(e)}function $o(e,t,a){t==="number"&&Br(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function bs(e,t,a,i){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&i&&(e[a].defaultSelected=!0)}else{for(a=""+rn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Df(e,t,a){if(t!=null&&(t=""+rn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+rn(a):""}function _f(e,t,a,i){if(t==null){if(i!=null){if(a!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}a=i}a==null&&(a=""),t=a}a=rn(t),e.defaultValue=a,i=e.textContent,i===a&&i!==""&&i!==null&&(e.value=i),Ho(e)}function ys(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var uv=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 Of(e,t,a){var i=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,a):typeof a!="number"||a===0||uv.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Bf(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var i in a)!a.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&a[c]!==i&&Of(e,c,i)}else for(var d in t)t.hasOwnProperty(d)&&Of(e,d,t[d])}function Go(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 dv=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"]]),fv=/^[\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 Lr(e){return fv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function zn(){}var Yo=null;function Fo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ss=null,js=null;function Lf(e){var t=xs(e);if(t&&(e=t.stateNode)){var a=e[Ut]||null;e:switch(e=t.stateNode,t.type){case"input":if(Vo(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+on(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var i=a[t];if(i!==e&&i.form===e.form){var c=i[Ut]||null;if(!c)throw Error(o(90));Vo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)i=a[t],i.form===e.form&&qf(i)}break e;case"textarea":Df(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&bs(e,!!a.multiple,t,!1)}}}var Xo=!1;function zf(e,t,a){if(Xo)return e(t,a);Xo=!0;try{var i=e(t);return i}finally{if(Xo=!1,(Ss!==null||js!==null)&&(wi(),Ss&&(t=Ss,e=js,js=Ss=null,Lf(t),e)))for(t=0;t<e.length;t++)Lf(e[t])}}function pl(e,t){var a=e.stateNode;if(a===null)return null;var i=a[Ut]||null;if(i===null)return null;a=i[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":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Un=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qo=!1;if(Un)try{var xl={};Object.defineProperty(xl,"passive",{get:function(){Qo=!0}}),window.addEventListener("test",xl,xl),window.removeEventListener("test",xl,xl)}catch{Qo=!1}var da=null,Ko=null,zr=null;function Uf(){if(zr)return zr;var e,t=Ko,a=t.length,i,c="value"in da?da.value:da.textContent,d=c.length;for(e=0;e<a&&t[e]===c[e];e++);var b=a-e;for(i=1;i<=b&&t[a-i]===c[d-i];i++);return zr=c.slice(e,1<i?1-i:void 0)}function Ur(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 Hr(){return!0}function Hf(){return!1}function Ht(e){function t(a,i,c,d,b){this._reactName=a,this._targetInst=c,this.type=i,this.nativeEvent=d,this.target=b,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(a=e[A],this[A]=a?a(d):d[A]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Hr:Hf,this.isPropagationStopped=Hf,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Hr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Hr)},persist:function(){},isPersistent:Hr}),t}var Va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vr=Ht(Va),gl=y({},Va,{view:0,detail:0}),mv=Ht(gl),Zo,Io,vl,$r=y({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Po,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!==vl&&(vl&&e.type==="mousemove"?(Zo=e.screenX-vl.screenX,Io=e.screenY-vl.screenY):Io=Zo=0,vl=e),Zo)},movementY:function(e){return"movementY"in e?e.movementY:Io}}),Vf=Ht($r),hv=y({},$r,{dataTransfer:0}),pv=Ht(hv),xv=y({},gl,{relatedTarget:0}),Jo=Ht(xv),gv=y({},Va,{animationName:0,elapsedTime:0,pseudoElement:0}),vv=Ht(gv),bv=y({},Va,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),yv=Ht(bv),Sv=y({},Va,{data:0}),$f=Ht(Sv),jv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nv={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"},wv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Av(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wv[e])?!!t[e]:!1}function Po(){return Av}var Cv=y({},gl,{key:function(e){if(e.key){var t=jv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ur(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Nv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Po,charCode:function(e){return e.type==="keypress"?Ur(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ur(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ev=Ht(Cv),kv=y({},$r,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gf=Ht(kv),Mv=y({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Po}),Rv=Ht(Mv),qv=y({},Va,{propertyName:0,elapsedTime:0,pseudoElement:0}),Tv=Ht(qv),Dv=y({},$r,{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}),_v=Ht(Dv),Ov=y({},Va,{newState:0,oldState:0}),Bv=Ht(Ov),Lv=[9,13,27,32],Wo=Un&&"CompositionEvent"in window,bl=null;Un&&"documentMode"in document&&(bl=document.documentMode);var zv=Un&&"TextEvent"in window&&!bl,Yf=Un&&(!Wo||bl&&8<bl&&11>=bl),Ff=" ",Xf=!1;function Qf(e,t){switch(e){case"keyup":return Lv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ns=!1;function Uv(e,t){switch(e){case"compositionend":return Kf(t);case"keypress":return t.which!==32?null:(Xf=!0,Ff);case"textInput":return e=t.data,e===Ff&&Xf?null:e;default:return null}}function Hv(e,t){if(Ns)return e==="compositionend"||!Wo&&Qf(e,t)?(e=Uf(),zr=Ko=da=null,Ns=!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 Yf&&t.locale!=="ko"?null:t.data;default:return null}}var Vv={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 Zf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Vv[e.type]:t==="textarea"}function If(e,t,a,i){Ss?js?js.push(i):js=[i]:Ss=i,t=qi(t,"onChange"),0<t.length&&(a=new Vr("onChange","change",null,a,i),e.push({event:a,listeners:t}))}var yl=null,Sl=null;function $v(e){T0(e,0)}function Gr(e){var t=hl(e);if(qf(t))return e}function Jf(e,t){if(e==="change")return t}var Pf=!1;if(Un){var ec;if(Un){var tc="oninput"in document;if(!tc){var Wf=document.createElement("div");Wf.setAttribute("oninput","return;"),tc=typeof Wf.oninput=="function"}ec=tc}else ec=!1;Pf=ec&&(!document.documentMode||9<document.documentMode)}function em(){yl&&(yl.detachEvent("onpropertychange",tm),Sl=yl=null)}function tm(e){if(e.propertyName==="value"&&Gr(Sl)){var t=[];If(t,Sl,e,Fo(e)),zf($v,t)}}function Gv(e,t,a){e==="focusin"?(em(),yl=t,Sl=a,yl.attachEvent("onpropertychange",tm)):e==="focusout"&&em()}function Yv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Gr(Sl)}function Fv(e,t){if(e==="click")return Gr(t)}function Xv(e,t){if(e==="input"||e==="change")return Gr(t)}function Qv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Kt=typeof Object.is=="function"?Object.is:Qv;function jl(e,t){if(Kt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;for(i=0;i<a.length;i++){var c=a[i];if(!Ee.call(t,c)||!Kt(e[c],t[c]))return!1}return!0}function nm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function am(e,t){var a=nm(e);e=0;for(var i;a;){if(a.nodeType===3){if(i=e+a.textContent.length,e<=t&&i>=t)return{node:a,offset:t-e};e=i}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=nm(a)}}function sm(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?sm(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function lm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Br(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Br(e.document)}return t}function nc(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 Kv=Un&&"documentMode"in document&&11>=document.documentMode,ws=null,ac=null,Nl=null,sc=!1;function rm(e,t,a){var i=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;sc||ws==null||ws!==Br(i)||(i=ws,"selectionStart"in i&&nc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Nl&&jl(Nl,i)||(Nl=i,i=qi(ac,"onSelect"),0<i.length&&(t=new Vr("onSelect","select",null,t,a),e.push({event:t,listeners:i}),t.target=ws)))}function $a(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var As={animationend:$a("Animation","AnimationEnd"),animationiteration:$a("Animation","AnimationIteration"),animationstart:$a("Animation","AnimationStart"),transitionrun:$a("Transition","TransitionRun"),transitionstart:$a("Transition","TransitionStart"),transitioncancel:$a("Transition","TransitionCancel"),transitionend:$a("Transition","TransitionEnd")},lc={},im={};Un&&(im=document.createElement("div").style,"AnimationEvent"in window||(delete As.animationend.animation,delete As.animationiteration.animation,delete As.animationstart.animation),"TransitionEvent"in window||delete As.transitionend.transition);function Ga(e){if(lc[e])return lc[e];if(!As[e])return e;var t=As[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in im)return lc[e]=t[a];return e}var om=Ga("animationend"),cm=Ga("animationiteration"),um=Ga("animationstart"),Zv=Ga("transitionrun"),Iv=Ga("transitionstart"),Jv=Ga("transitioncancel"),dm=Ga("transitionend"),fm=new Map,rc="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(" ");rc.push("scrollEnd");function yn(e,t){fm.set(e,t),Ha(t,[e])}var Yr=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)},cn=[],Cs=0,ic=0;function Fr(){for(var e=Cs,t=ic=Cs=0;t<e;){var a=cn[t];cn[t++]=null;var i=cn[t];cn[t++]=null;var c=cn[t];cn[t++]=null;var d=cn[t];if(cn[t++]=null,i!==null&&c!==null){var b=i.pending;b===null?c.next=c:(c.next=b.next,b.next=c),i.pending=c}d!==0&&mm(a,c,d)}}function Xr(e,t,a,i){cn[Cs++]=e,cn[Cs++]=t,cn[Cs++]=a,cn[Cs++]=i,ic|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function oc(e,t,a,i){return Xr(e,t,a,i),Qr(e)}function Ya(e,t){return Xr(e,null,null,t),Qr(e)}function mm(e,t,a){e.lanes|=a;var i=e.alternate;i!==null&&(i.lanes|=a);for(var c=!1,d=e.return;d!==null;)d.childLanes|=a,i=d.alternate,i!==null&&(i.childLanes|=a),d.tag===22&&(e=d.stateNode,e===null||e._visibility&1||(c=!0)),e=d,d=d.return;return e.tag===3?(d=e.stateNode,c&&t!==null&&(c=31-Bt(a),e=d.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=a|536870912),d):null}function Qr(e){if(50<Fl)throw Fl=0,gu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Es={};function Pv(e,t,a,i){this.tag=e,this.key=a,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=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zt(e,t,a,i){return new Pv(e,t,a,i)}function cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hn(e,t){var a=e.alternate;return a===null?(a=Zt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function hm(e,t){e.flags&=65011714;var a=e.alternate;return a===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=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Kr(e,t,a,i,c,d){var b=0;if(i=e,typeof e=="function")cc(e)&&(b=1);else if(typeof e=="string")b=ay(e,a,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case K:return e=Zt(31,a,t,c),e.elementType=K,e.lanes=d,e;case S:return Fa(a.children,c,d,t);case w:b=8,c|=24;break;case j:return e=Zt(12,a,t,c|2),e.elementType=j,e.lanes=d,e;case B:return e=Zt(13,a,t,c),e.elementType=B,e.lanes=d,e;case X:return e=Zt(19,a,t,c),e.elementType=X,e.lanes=d,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case k:b=10;break e;case R:b=9;break e;case E:b=11;break e;case L:b=14;break e;case z:b=16,i=null;break e}b=29,a=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Zt(b,a,t,c),t.elementType=e,t.type=i,t.lanes=d,t}function Fa(e,t,a,i){return e=Zt(7,e,i,t),e.lanes=a,e}function uc(e,t,a){return e=Zt(6,e,null,t),e.lanes=a,e}function pm(e){var t=Zt(18,null,null,0);return t.stateNode=e,t}function dc(e,t,a){return t=Zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var xm=new WeakMap;function un(e,t){if(typeof e=="object"&&e!==null){var a=xm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:xe(t)},xm.set(e,t),t)}return{value:e,source:t,stack:xe(t)}}var ks=[],Ms=0,Zr=null,wl=0,dn=[],fn=0,fa=null,Mn=1,Rn="";function Vn(e,t){ks[Ms++]=wl,ks[Ms++]=Zr,Zr=e,wl=t}function gm(e,t,a){dn[fn++]=Mn,dn[fn++]=Rn,dn[fn++]=fa,fa=e;var i=Mn;e=Rn;var c=32-Bt(i)-1;i&=~(1<<c),a+=1;var d=32-Bt(t)+c;if(30<d){var b=c-c%5;d=(i&(1<<b)-1).toString(32),i>>=b,c-=b,Mn=1<<32-Bt(t)+c|a<<c|i,Rn=d+e}else Mn=1<<d|a<<c|i,Rn=e}function fc(e){e.return!==null&&(Vn(e,1),gm(e,1,0))}function mc(e){for(;e===Zr;)Zr=ks[--Ms],ks[Ms]=null,wl=ks[--Ms],ks[Ms]=null;for(;e===fa;)fa=dn[--fn],dn[fn]=null,Rn=dn[--fn],dn[fn]=null,Mn=dn[--fn],dn[fn]=null}function vm(e,t){dn[fn++]=Mn,dn[fn++]=Rn,dn[fn++]=fa,Mn=t.id,Rn=t.overflow,fa=e}var Mt=null,st=null,Ue=!1,ma=null,mn=!1,hc=Error(o(519));function ha(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Al(un(t,e)),hc}function bm(e){var t=e.stateNode,a=e.type,i=e.memoizedProps;switch(t[ct]=e,t[Ut]=i,a){case"dialog":Oe("cancel",t),Oe("close",t);break;case"iframe":case"object":case"embed":Oe("load",t);break;case"video":case"audio":for(a=0;a<Ql.length;a++)Oe(Ql[a],t);break;case"source":Oe("error",t);break;case"img":case"image":case"link":Oe("error",t),Oe("load",t);break;case"details":Oe("toggle",t);break;case"input":Oe("invalid",t),Tf(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Oe("invalid",t);break;case"textarea":Oe("invalid",t),_f(t,i.value,i.defaultValue,i.children)}a=i.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||i.suppressHydrationWarning===!0||B0(t.textContent,a)?(i.popover!=null&&(Oe("beforetoggle",t),Oe("toggle",t)),i.onScroll!=null&&Oe("scroll",t),i.onScrollEnd!=null&&Oe("scrollend",t),i.onClick!=null&&(t.onclick=zn),t=!0):t=!1,t||ha(e,!0)}function ym(e){for(Mt=e.return;Mt;)switch(Mt.tag){case 5:case 31:case 13:mn=!1;return;case 27:case 3:mn=!0;return;default:Mt=Mt.return}}function Rs(e){if(e!==Mt)return!1;if(!Ue)return ym(e),Ue=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Tu(e.type,e.memoizedProps)),a=!a),a&&st&&ha(e),ym(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));st=F0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));st=F0(e)}else t===27?(t=st,ka(e.type)?(e=Lu,Lu=null,st=e):st=t):st=Mt?pn(e.stateNode.nextSibling):null;return!0}function Xa(){st=Mt=null,Ue=!1}function pc(){var e=ma;return e!==null&&(Yt===null?Yt=e:Yt.push.apply(Yt,e),ma=null),e}function Al(e){ma===null?ma=[e]:ma.push(e)}var xc=q(null),Qa=null,$n=null;function pa(e,t,a){I(xc,t._currentValue),t._currentValue=a}function Gn(e){e._currentValue=xc.current,_(xc)}function gc(e,t,a){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===a)break;e=e.return}}function vc(e,t,a,i){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var d=c.dependencies;if(d!==null){var b=c.child;d=d.firstContext;e:for(;d!==null;){var A=d;d=c;for(var D=0;D<t.length;D++)if(A.context===t[D]){d.lanes|=a,A=d.alternate,A!==null&&(A.lanes|=a),gc(d.return,a,e),i||(b=null);break e}d=A.next}}else if(c.tag===18){if(b=c.return,b===null)throw Error(o(341));b.lanes|=a,d=b.alternate,d!==null&&(d.lanes|=a),gc(b,a,e),b=null}else b=c.child;if(b!==null)b.return=c;else for(b=c;b!==null;){if(b===e){b=null;break}if(c=b.sibling,c!==null){c.return=b.return,b=c;break}b=b.return}c=b}}function qs(e,t,a,i){e=null;for(var c=t,d=!1;c!==null;){if(!d){if((c.flags&524288)!==0)d=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var b=c.alternate;if(b===null)throw Error(o(387));if(b=b.memoizedProps,b!==null){var A=c.type;Kt(c.pendingProps.value,b.value)||(e!==null?e.push(A):e=[A])}}else if(c===se.current){if(b=c.alternate,b===null)throw Error(o(387));b.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Pl):e=[Pl])}c=c.return}e!==null&&vc(t,e,a,i),t.flags|=262144}function Ir(e){for(e=e.firstContext;e!==null;){if(!Kt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ka(e){Qa=e,$n=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Rt(e){return Sm(Qa,e)}function Jr(e,t){return Qa===null&&Ka(e),Sm(e,t)}function Sm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},$n===null){if(e===null)throw Error(o(308));$n=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $n=$n.next=t;return a}var Wv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},eb=n.unstable_scheduleCallback,tb=n.unstable_NormalPriority,bt={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bc(){return{controller:new Wv,data:new Map,refCount:0}}function Cl(e){e.refCount--,e.refCount===0&&eb(tb,function(){e.controller.abort()})}var El=null,yc=0,Ts=0,Ds=null;function nb(e,t){if(El===null){var a=El=[];yc=0,Ts=Nu(),Ds={status:"pending",value:void 0,then:function(i){a.push(i)}}}return yc++,t.then(jm,jm),t}function jm(){if(--yc===0&&El!==null){Ds!==null&&(Ds.status="fulfilled");var e=El;El=null,Ts=0,Ds=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ab(e,t){var a=[],i={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),i}var Nm=T.S;T.S=function(e,t){r0=le(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&nb(e,t),Nm!==null&&Nm(e,t)};var Za=q(null);function Sc(){var e=Za.current;return e!==null?e:tt.pooledCache}function Pr(e,t){t===null?I(Za,Za.current):I(Za,t.pool)}function wm(){var e=Sc();return e===null?null:{parent:bt._currentValue,pool:e}}var _s=Error(o(460)),jc=Error(o(474)),Wr=Error(o(542)),ei={then:function(){}};function Am(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Cm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(zn,zn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,km(e),e;default:if(typeof t.status=="string")t.then(zn,zn);else{if(e=tt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,km(e),e}throw Ja=t,_s}}function Ia(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Ja=a,_s):a}}var Ja=null;function Em(){if(Ja===null)throw Error(o(459));var e=Ja;return Ja=null,e}function km(e){if(e===_s||e===Wr)throw Error(o(483))}var Os=null,kl=0;function ti(e){var t=kl;return kl+=1,Os===null&&(Os=[]),Cm(Os,e,t)}function Ml(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function ni(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 Mm(e){function t(U,O){if(e){var G=U.deletions;G===null?(U.deletions=[O],U.flags|=16):G.push(O)}}function a(U,O){if(!e)return null;for(;O!==null;)t(U,O),O=O.sibling;return null}function i(U){for(var O=new Map;U!==null;)U.key!==null?O.set(U.key,U):O.set(U.index,U),U=U.sibling;return O}function c(U,O){return U=Hn(U,O),U.index=0,U.sibling=null,U}function d(U,O,G){return U.index=G,e?(G=U.alternate,G!==null?(G=G.index,G<O?(U.flags|=67108866,O):G):(U.flags|=67108866,O)):(U.flags|=1048576,O)}function b(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function A(U,O,G,ee){return O===null||O.tag!==6?(O=uc(G,U.mode,ee),O.return=U,O):(O=c(O,G),O.return=U,O)}function D(U,O,G,ee){var je=G.type;return je===S?P(U,O,G.props.children,ee,G.key):O!==null&&(O.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===z&&Ia(je)===O.type)?(O=c(O,G.props),Ml(O,G),O.return=U,O):(O=Kr(G.type,G.key,G.props,null,U.mode,ee),Ml(O,G),O.return=U,O)}function Y(U,O,G,ee){return O===null||O.tag!==4||O.stateNode.containerInfo!==G.containerInfo||O.stateNode.implementation!==G.implementation?(O=dc(G,U.mode,ee),O.return=U,O):(O=c(O,G.children||[]),O.return=U,O)}function P(U,O,G,ee,je){return O===null||O.tag!==7?(O=Fa(G,U.mode,ee,je),O.return=U,O):(O=c(O,G),O.return=U,O)}function ae(U,O,G){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=uc(""+O,U.mode,G),O.return=U,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case M:return G=Kr(O.type,O.key,O.props,null,U.mode,G),Ml(G,O),G.return=U,G;case C:return O=dc(O,U.mode,G),O.return=U,O;case z:return O=Ia(O),ae(U,O,G)}if($(O)||W(O))return O=Fa(O,U.mode,G,null),O.return=U,O;if(typeof O.then=="function")return ae(U,ti(O),G);if(O.$$typeof===k)return ae(U,Jr(U,O),G);ni(U,O)}return null}function Q(U,O,G,ee){var je=O!==null?O.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return je!==null?null:A(U,O,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case M:return G.key===je?D(U,O,G,ee):null;case C:return G.key===je?Y(U,O,G,ee):null;case z:return G=Ia(G),Q(U,O,G,ee)}if($(G)||W(G))return je!==null?null:P(U,O,G,ee,null);if(typeof G.then=="function")return Q(U,O,ti(G),ee);if(G.$$typeof===k)return Q(U,O,Jr(U,G),ee);ni(U,G)}return null}function Z(U,O,G,ee,je){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return U=U.get(G)||null,A(O,U,""+ee,je);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case M:return U=U.get(ee.key===null?G:ee.key)||null,D(O,U,ee,je);case C:return U=U.get(ee.key===null?G:ee.key)||null,Y(O,U,ee,je);case z:return ee=Ia(ee),Z(U,O,G,ee,je)}if($(ee)||W(ee))return U=U.get(G)||null,P(O,U,ee,je,null);if(typeof ee.then=="function")return Z(U,O,G,ti(ee),je);if(ee.$$typeof===k)return Z(U,O,G,Jr(O,ee),je);ni(O,ee)}return null}function ge(U,O,G,ee){for(var je=null,Ye=null,ye=O,Re=O=0,Le=null;ye!==null&&Re<G.length;Re++){ye.index>Re?(Le=ye,ye=null):Le=ye.sibling;var Fe=Q(U,ye,G[Re],ee);if(Fe===null){ye===null&&(ye=Le);break}e&&ye&&Fe.alternate===null&&t(U,ye),O=d(Fe,O,Re),Ye===null?je=Fe:Ye.sibling=Fe,Ye=Fe,ye=Le}if(Re===G.length)return a(U,ye),Ue&&Vn(U,Re),je;if(ye===null){for(;Re<G.length;Re++)ye=ae(U,G[Re],ee),ye!==null&&(O=d(ye,O,Re),Ye===null?je=ye:Ye.sibling=ye,Ye=ye);return Ue&&Vn(U,Re),je}for(ye=i(ye);Re<G.length;Re++)Le=Z(ye,U,Re,G[Re],ee),Le!==null&&(e&&Le.alternate!==null&&ye.delete(Le.key===null?Re:Le.key),O=d(Le,O,Re),Ye===null?je=Le:Ye.sibling=Le,Ye=Le);return e&&ye.forEach(function(Da){return t(U,Da)}),Ue&&Vn(U,Re),je}function Ne(U,O,G,ee){if(G==null)throw Error(o(151));for(var je=null,Ye=null,ye=O,Re=O=0,Le=null,Fe=G.next();ye!==null&&!Fe.done;Re++,Fe=G.next()){ye.index>Re?(Le=ye,ye=null):Le=ye.sibling;var Da=Q(U,ye,Fe.value,ee);if(Da===null){ye===null&&(ye=Le);break}e&&ye&&Da.alternate===null&&t(U,ye),O=d(Da,O,Re),Ye===null?je=Da:Ye.sibling=Da,Ye=Da,ye=Le}if(Fe.done)return a(U,ye),Ue&&Vn(U,Re),je;if(ye===null){for(;!Fe.done;Re++,Fe=G.next())Fe=ae(U,Fe.value,ee),Fe!==null&&(O=d(Fe,O,Re),Ye===null?je=Fe:Ye.sibling=Fe,Ye=Fe);return Ue&&Vn(U,Re),je}for(ye=i(ye);!Fe.done;Re++,Fe=G.next())Fe=Z(ye,U,Re,Fe.value,ee),Fe!==null&&(e&&Fe.alternate!==null&&ye.delete(Fe.key===null?Re:Fe.key),O=d(Fe,O,Re),Ye===null?je=Fe:Ye.sibling=Fe,Ye=Fe);return e&&ye.forEach(function(hy){return t(U,hy)}),Ue&&Vn(U,Re),je}function We(U,O,G,ee){if(typeof G=="object"&&G!==null&&G.type===S&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case M:e:{for(var je=G.key;O!==null;){if(O.key===je){if(je=G.type,je===S){if(O.tag===7){a(U,O.sibling),ee=c(O,G.props.children),ee.return=U,U=ee;break e}}else if(O.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===z&&Ia(je)===O.type){a(U,O.sibling),ee=c(O,G.props),Ml(ee,G),ee.return=U,U=ee;break e}a(U,O);break}else t(U,O);O=O.sibling}G.type===S?(ee=Fa(G.props.children,U.mode,ee,G.key),ee.return=U,U=ee):(ee=Kr(G.type,G.key,G.props,null,U.mode,ee),Ml(ee,G),ee.return=U,U=ee)}return b(U);case C:e:{for(je=G.key;O!==null;){if(O.key===je)if(O.tag===4&&O.stateNode.containerInfo===G.containerInfo&&O.stateNode.implementation===G.implementation){a(U,O.sibling),ee=c(O,G.children||[]),ee.return=U,U=ee;break e}else{a(U,O);break}else t(U,O);O=O.sibling}ee=dc(G,U.mode,ee),ee.return=U,U=ee}return b(U);case z:return G=Ia(G),We(U,O,G,ee)}if($(G))return ge(U,O,G,ee);if(W(G)){if(je=W(G),typeof je!="function")throw Error(o(150));return G=je.call(G),Ne(U,O,G,ee)}if(typeof G.then=="function")return We(U,O,ti(G),ee);if(G.$$typeof===k)return We(U,O,Jr(U,G),ee);ni(U,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,O!==null&&O.tag===6?(a(U,O.sibling),ee=c(O,G),ee.return=U,U=ee):(a(U,O),ee=uc(G,U.mode,ee),ee.return=U,U=ee),b(U)):a(U,O)}return function(U,O,G,ee){try{kl=0;var je=We(U,O,G,ee);return Os=null,je}catch(ye){if(ye===_s||ye===Wr)throw ye;var Ye=Zt(29,ye,null,U.mode);return Ye.lanes=ee,Ye.return=U,Ye}finally{}}}var Pa=Mm(!0),Rm=Mm(!1),xa=!1;function Nc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wc(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 ga(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function va(e,t,a){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(Xe&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Qr(e),mm(e,null,a),t}return Xr(e,i,t,a),Qr(e)}function Rl(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,et(e,a)}}function Ac(e,t){var a=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,a===i)){var c=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var b={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?c=d=b:d=d.next=b,a=a.next}while(a!==null);d===null?c=d=t:d=d.next=t}else c=d=t;a={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:d,shared:i.shared,callbacks:i.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Cc=!1;function ql(){if(Cc){var e=Ds;if(e!==null)throw e}}function Tl(e,t,a,i){Cc=!1;var c=e.updateQueue;xa=!1;var d=c.firstBaseUpdate,b=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var D=A,Y=D.next;D.next=null,b===null?d=Y:b.next=Y,b=D;var P=e.alternate;P!==null&&(P=P.updateQueue,A=P.lastBaseUpdate,A!==b&&(A===null?P.firstBaseUpdate=Y:A.next=Y,P.lastBaseUpdate=D))}if(d!==null){var ae=c.baseState;b=0,P=Y=D=null,A=d;do{var Q=A.lane&-536870913,Z=Q!==A.lane;if(Z?(Be&Q)===Q:(i&Q)===Q){Q!==0&&Q===Ts&&(Cc=!0),P!==null&&(P=P.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var ge=e,Ne=A;Q=t;var We=a;switch(Ne.tag){case 1:if(ge=Ne.payload,typeof ge=="function"){ae=ge.call(We,ae,Q);break e}ae=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=Ne.payload,Q=typeof ge=="function"?ge.call(We,ae,Q):ge,Q==null)break e;ae=y({},ae,Q);break e;case 2:xa=!0}}Q=A.callback,Q!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[Q]:Z.push(Q))}else Z={lane:Q,tag:A.tag,payload:A.payload,callback:A.callback,next:null},P===null?(Y=P=Z,D=ae):P=P.next=Z,b|=Q;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;Z=A,A=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);P===null&&(D=ae),c.baseState=D,c.firstBaseUpdate=Y,c.lastBaseUpdate=P,d===null&&(c.shared.lanes=0),Na|=b,e.lanes=b,e.memoizedState=ae}}function qm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Tm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)qm(a[e],t)}var Bs=q(null),ai=q(0);function Dm(e,t){e=Pn,I(ai,e),I(Bs,t),Pn=e|t.baseLanes}function Ec(){I(ai,Pn),I(Bs,Bs.current)}function kc(){Pn=ai.current,_(Bs),_(ai)}var It=q(null),hn=null;function ba(e){var t=e.alternate;I(xt,xt.current&1),I(It,e),hn===null&&(t===null||Bs.current!==null||t.memoizedState!==null)&&(hn=e)}function Mc(e){I(xt,xt.current),I(It,e),hn===null&&(hn=e)}function _m(e){e.tag===22?(I(xt,xt.current),I(It,e),hn===null&&(hn=e)):ya()}function ya(){I(xt,xt.current),I(It,It.current)}function Jt(e){_(It),hn===e&&(hn=null),_(xt)}var xt=q(0);function si(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Ou(a)||Bu(a)))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 Yn=0,ke=null,Je=null,yt=null,li=!1,Ls=!1,Wa=!1,ri=0,Dl=0,zs=null,sb=0;function mt(){throw Error(o(321))}function Rc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Kt(e[a],t[a]))return!1;return!0}function qc(e,t,a,i,c,d){return Yn=d,ke=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?gh:Xc,Wa=!1,d=a(i,c),Wa=!1,Ls&&(d=Bm(t,a,i,c)),Om(e),d}function Om(e){T.H=Bl;var t=Je!==null&&Je.next!==null;if(Yn=0,yt=Je=ke=null,li=!1,Dl=0,zs=null,t)throw Error(o(300));e===null||St||(e=e.dependencies,e!==null&&Ir(e)&&(St=!0))}function Bm(e,t,a,i){ke=e;var c=0;do{if(Ls&&(zs=null),Dl=0,Ls=!1,25<=c)throw Error(o(301));if(c+=1,yt=Je=null,e.updateQueue!=null){var d=e.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}T.H=vh,d=t(a,i)}while(Ls);return d}function lb(){var e=T.H,t=e.useState()[0];return t=typeof t.then=="function"?_l(t):t,e=e.useState()[0],(Je!==null?Je.memoizedState:null)!==e&&(ke.flags|=1024),t}function Tc(){var e=ri!==0;return ri=0,e}function Dc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function _c(e){if(li){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}li=!1}Yn=0,yt=Je=ke=null,Ls=!1,Dl=ri=0,zs=null}function zt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yt===null?ke.memoizedState=yt=e:yt=yt.next=e,yt}function gt(){if(Je===null){var e=ke.alternate;e=e!==null?e.memoizedState:null}else e=Je.next;var t=yt===null?ke.memoizedState:yt.next;if(t!==null)yt=t,Je=e;else{if(e===null)throw ke.alternate===null?Error(o(467)):Error(o(310));Je=e,e={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},yt===null?ke.memoizedState=yt=e:yt=yt.next=e}return yt}function ii(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function _l(e){var t=Dl;return Dl+=1,zs===null&&(zs=[]),e=Cm(zs,e,t),t=ke,(yt===null?t.memoizedState:yt.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?gh:Xc),e}function oi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return _l(e);if(e.$$typeof===k)return Rt(e)}throw Error(o(438,String(e)))}function Oc(e){var t=null,a=ke.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var i=ke.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=ii(),ke.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),i=0;i<e;i++)a[i]=V;return t.index++,a}function Fn(e,t){return typeof t=="function"?t(e):t}function ci(e){var t=gt();return Bc(t,Je,e)}function Bc(e,t,a){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=a;var c=e.baseQueue,d=i.pending;if(d!==null){if(c!==null){var b=c.next;c.next=d.next,d.next=b}t.baseQueue=c=d,i.pending=null}if(d=e.baseState,c===null)e.memoizedState=d;else{t=c.next;var A=b=null,D=null,Y=t,P=!1;do{var ae=Y.lane&-536870913;if(ae!==Y.lane?(Be&ae)===ae:(Yn&ae)===ae){var Q=Y.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),ae===Ts&&(P=!0);else if((Yn&Q)===Q){Y=Y.next,Q===Ts&&(P=!0);continue}else ae={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(A=D=ae,b=d):D=D.next=ae,ke.lanes|=Q,Na|=Q;ae=Y.action,Wa&&a(d,ae),d=Y.hasEagerState?Y.eagerState:a(d,ae)}else Q={lane:ae,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(A=D=Q,b=d):D=D.next=Q,ke.lanes|=ae,Na|=ae;Y=Y.next}while(Y!==null&&Y!==t);if(D===null?b=d:D.next=A,!Kt(d,e.memoizedState)&&(St=!0,P&&(a=Ds,a!==null)))throw a;e.memoizedState=d,e.baseState=b,e.baseQueue=D,i.lastRenderedState=d}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Lc(e){var t=gt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var i=a.dispatch,c=a.pending,d=t.memoizedState;if(c!==null){a.pending=null;var b=c=c.next;do d=e(d,b.action),b=b.next;while(b!==c);Kt(d,t.memoizedState)||(St=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),a.lastRenderedState=d}return[d,i]}function Lm(e,t,a){var i=ke,c=gt(),d=Ue;if(d){if(a===void 0)throw Error(o(407));a=a()}else a=t();var b=!Kt((Je||c).memoizedState,a);if(b&&(c.memoizedState=a,St=!0),c=c.queue,Hc(Hm.bind(null,i,c,e),[e]),c.getSnapshot!==t||b||yt!==null&&yt.memoizedState.tag&1){if(i.flags|=2048,Us(9,{destroy:void 0},Um.bind(null,i,c,a,t),null),tt===null)throw Error(o(349));d||(Yn&127)!==0||zm(i,t,a)}return a}function zm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=ke.updateQueue,t===null?(t=ii(),ke.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Um(e,t,a,i){t.value=a,t.getSnapshot=i,Vm(t)&&$m(e)}function Hm(e,t,a){return a(function(){Vm(t)&&$m(e)})}function Vm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Kt(e,a)}catch{return!0}}function $m(e){var t=Ya(e,2);t!==null&&Ft(t,e,2)}function zc(e){var t=zt();if(typeof e=="function"){var a=e;if(e=a(),Wa){Ot(!0);try{a()}finally{Ot(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:e},t}function Gm(e,t,a,i){return e.baseState=a,Bc(e,Je,typeof i=="function"?i:Fn)}function rb(e,t,a,i,c){if(fi(e))throw Error(o(485));if(e=t.action,e!==null){var d={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){d.listeners.push(b)}};T.T!==null?a(!0):d.isTransition=!1,i(d),a=t.pending,a===null?(d.next=t.pending=d,Ym(t,d)):(d.next=a.next,t.pending=a.next=d)}}function Ym(e,t){var a=t.action,i=t.payload,c=e.state;if(t.isTransition){var d=T.T,b={};T.T=b;try{var A=a(c,i),D=T.S;D!==null&&D(b,A),Fm(e,t,A)}catch(Y){Uc(e,t,Y)}finally{d!==null&&b.types!==null&&(d.types=b.types),T.T=d}}else try{d=a(c,i),Fm(e,t,d)}catch(Y){Uc(e,t,Y)}}function Fm(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(i){Xm(e,t,i)},function(i){return Uc(e,t,i)}):Xm(e,t,a)}function Xm(e,t,a){t.status="fulfilled",t.value=a,Qm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Ym(e,a)))}function Uc(e,t,a){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=a,Qm(t),t=t.next;while(t!==i)}e.action=null}function Qm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Km(e,t){return t}function Zm(e,t){if(Ue){var a=tt.formState;if(a!==null){e:{var i=ke;if(Ue){if(st){t:{for(var c=st,d=mn;c.nodeType!==8;){if(!d){c=null;break t}if(c=pn(c.nextSibling),c===null){c=null;break t}}d=c.data,c=d==="F!"||d==="F"?c:null}if(c){st=pn(c.nextSibling),i=c.data==="F!";break e}}ha(i)}i=!1}i&&(t=a[0])}}return a=zt(),a.memoizedState=a.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Km,lastRenderedState:t},a.queue=i,a=hh.bind(null,ke,i),i.dispatch=a,i=zc(!1),d=Fc.bind(null,ke,!1,i.queue),i=zt(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,a=rb.bind(null,ke,c,d,a),c.dispatch=a,i.memoizedState=e,[t,a,!1]}function Im(e){var t=gt();return Jm(t,Je,e)}function Jm(e,t,a){if(t=Bc(e,t,Km)[0],e=ci(Fn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=_l(t)}catch(b){throw b===_s?Wr:b}else i=t;t=gt();var c=t.queue,d=c.dispatch;return a!==t.memoizedState&&(ke.flags|=2048,Us(9,{destroy:void 0},ib.bind(null,c,a),null)),[i,d,e]}function ib(e,t){e.action=t}function Pm(e){var t=gt(),a=Je;if(a!==null)return Jm(t,a,e);gt(),t=t.memoizedState,a=gt();var i=a.queue.dispatch;return a.memoizedState=e,[t,i,!1]}function Us(e,t,a,i){return e={tag:e,create:a,deps:i,inst:t,next:null},t=ke.updateQueue,t===null&&(t=ii(),ke.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(i=a.next,a.next=e,e.next=i,t.lastEffect=e),e}function Wm(){return gt().memoizedState}function ui(e,t,a,i){var c=zt();ke.flags|=e,c.memoizedState=Us(1|t,{destroy:void 0},a,i===void 0?null:i)}function di(e,t,a,i){var c=gt();i=i===void 0?null:i;var d=c.memoizedState.inst;Je!==null&&i!==null&&Rc(i,Je.memoizedState.deps)?c.memoizedState=Us(t,d,a,i):(ke.flags|=e,c.memoizedState=Us(1|t,d,a,i))}function eh(e,t){ui(8390656,8,e,t)}function Hc(e,t){di(2048,8,e,t)}function ob(e){ke.flags|=4;var t=ke.updateQueue;if(t===null)t=ii(),ke.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function th(e){var t=gt().memoizedState;return ob({ref:t,nextImpl:e}),function(){if((Xe&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function nh(e,t){return di(4,2,e,t)}function ah(e,t){return di(4,4,e,t)}function sh(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function lh(e,t,a){a=a!=null?a.concat([e]):null,di(4,4,sh.bind(null,t,e),a)}function Vc(){}function rh(e,t){var a=gt();t=t===void 0?null:t;var i=a.memoizedState;return t!==null&&Rc(t,i[1])?i[0]:(a.memoizedState=[e,t],e)}function ih(e,t){var a=gt();t=t===void 0?null:t;var i=a.memoizedState;if(t!==null&&Rc(t,i[1]))return i[0];if(i=e(),Wa){Ot(!0);try{e()}finally{Ot(!1)}}return a.memoizedState=[i,t],i}function $c(e,t,a){return a===void 0||(Yn&1073741824)!==0&&(Be&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=o0(),ke.lanes|=e,Na|=e,a)}function oh(e,t,a,i){return Kt(a,t)?a:Bs.current!==null?(e=$c(e,a,i),Kt(e,t)||(St=!0),e):(Yn&42)===0||(Yn&1073741824)!==0&&(Be&261930)===0?(St=!0,e.memoizedState=a):(e=o0(),ke.lanes|=e,Na|=e,t)}function ch(e,t,a,i,c){var d=H.p;H.p=d!==0&&8>d?d:8;var b=T.T,A={};T.T=A,Fc(e,!1,t,a);try{var D=c(),Y=T.S;if(Y!==null&&Y(A,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var P=ab(D,i);Ol(e,t,P,en(e))}else Ol(e,t,i,en(e))}catch(ae){Ol(e,t,{then:function(){},status:"rejected",reason:ae},en())}finally{H.p=d,b!==null&&A.types!==null&&(b.types=A.types),T.T=b}}function cb(){}function Gc(e,t,a,i){if(e.tag!==5)throw Error(o(476));var c=uh(e).queue;ch(e,c,t,J,a===null?cb:function(){return dh(e),a(i)})}function uh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function dh(e){var t=uh(e);t.next===null&&(t=e.alternate.memoizedState),Ol(e,t.next.queue,{},en())}function Yc(){return Rt(Pl)}function fh(){return gt().memoizedState}function mh(){return gt().memoizedState}function ub(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=en();e=ga(a);var i=va(t,e,a);i!==null&&(Ft(i,t,a),Rl(i,t,a)),t={cache:bc()},e.payload=t;return}t=t.return}}function db(e,t,a){var i=en();a={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fi(e)?ph(t,a):(a=oc(e,t,a,i),a!==null&&(Ft(a,e,i),xh(a,t,i)))}function hh(e,t,a){var i=en();Ol(e,t,a,i)}function Ol(e,t,a,i){var c={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(fi(e))ph(t,c);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=t.lastRenderedReducer,d!==null))try{var b=t.lastRenderedState,A=d(b,a);if(c.hasEagerState=!0,c.eagerState=A,Kt(A,b))return Xr(e,t,c,0),tt===null&&Fr(),!1}catch{}finally{}if(a=oc(e,t,c,i),a!==null)return Ft(a,e,i),xh(a,t,i),!0}return!1}function Fc(e,t,a,i){if(i={lane:2,revertLane:Nu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},fi(e)){if(t)throw Error(o(479))}else t=oc(e,a,i,2),t!==null&&Ft(t,e,2)}function fi(e){var t=e.alternate;return e===ke||t!==null&&t===ke}function ph(e,t){Ls=li=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function xh(e,t,a){if((a&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,et(e,a)}}var Bl={readContext:Rt,use:oi,useCallback:mt,useContext:mt,useEffect:mt,useImperativeHandle:mt,useLayoutEffect:mt,useInsertionEffect:mt,useMemo:mt,useReducer:mt,useRef:mt,useState:mt,useDebugValue:mt,useDeferredValue:mt,useTransition:mt,useSyncExternalStore:mt,useId:mt,useHostTransitionStatus:mt,useFormState:mt,useActionState:mt,useOptimistic:mt,useMemoCache:mt,useCacheRefresh:mt};Bl.useEffectEvent=mt;var gh={readContext:Rt,use:oi,useCallback:function(e,t){return zt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:eh,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,ui(4194308,4,sh.bind(null,t,e),a)},useLayoutEffect:function(e,t){return ui(4194308,4,e,t)},useInsertionEffect:function(e,t){ui(4,2,e,t)},useMemo:function(e,t){var a=zt();t=t===void 0?null:t;var i=e();if(Wa){Ot(!0);try{e()}finally{Ot(!1)}}return a.memoizedState=[i,t],i},useReducer:function(e,t,a){var i=zt();if(a!==void 0){var c=a(t);if(Wa){Ot(!0);try{a(t)}finally{Ot(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=db.bind(null,ke,e),[i.memoizedState,e]},useRef:function(e){var t=zt();return e={current:e},t.memoizedState=e},useState:function(e){e=zc(e);var t=e.queue,a=hh.bind(null,ke,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Vc,useDeferredValue:function(e,t){var a=zt();return $c(a,e,t)},useTransition:function(){var e=zc(!1);return e=ch.bind(null,ke,e.queue,!0,!1),zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var i=ke,c=zt();if(Ue){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),tt===null)throw Error(o(349));(Be&127)!==0||zm(i,t,a)}c.memoizedState=a;var d={value:a,getSnapshot:t};return c.queue=d,eh(Hm.bind(null,i,d,e),[e]),i.flags|=2048,Us(9,{destroy:void 0},Um.bind(null,i,d,a,t),null),a},useId:function(){var e=zt(),t=tt.identifierPrefix;if(Ue){var a=Rn,i=Mn;a=(i&~(1<<32-Bt(i)-1)).toString(32)+a,t="_"+t+"R_"+a,a=ri++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=sb++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Yc,useFormState:Zm,useActionState:Zm,useOptimistic:function(e){var t=zt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Fc.bind(null,ke,!0,a),a.dispatch=t,[e,t]},useMemoCache:Oc,useCacheRefresh:function(){return zt().memoizedState=ub.bind(null,ke)},useEffectEvent:function(e){var t=zt(),a={impl:e};return t.memoizedState=a,function(){if((Xe&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Xc={readContext:Rt,use:oi,useCallback:rh,useContext:Rt,useEffect:Hc,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:ah,useMemo:ih,useReducer:ci,useRef:Wm,useState:function(){return ci(Fn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=gt();return oh(a,Je.memoizedState,e,t)},useTransition:function(){var e=ci(Fn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:Yc,useFormState:Im,useActionState:Im,useOptimistic:function(e,t){var a=gt();return Gm(a,Je,e,t)},useMemoCache:Oc,useCacheRefresh:mh};Xc.useEffectEvent=th;var vh={readContext:Rt,use:oi,useCallback:rh,useContext:Rt,useEffect:Hc,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:ah,useMemo:ih,useReducer:Lc,useRef:Wm,useState:function(){return Lc(Fn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=gt();return Je===null?$c(a,e,t):oh(a,Je.memoizedState,e,t)},useTransition:function(){var e=Lc(Fn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:_l(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:Yc,useFormState:Pm,useActionState:Pm,useOptimistic:function(e,t){var a=gt();return Je!==null?Gm(a,Je,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Oc,useCacheRefresh:mh};vh.useEffectEvent=th;function Qc(e,t,a,i){t=e.memoizedState,a=a(i,t),a=a==null?t:y({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Kc={enqueueSetState:function(e,t,a){e=e._reactInternals;var i=en(),c=ga(i);c.payload=t,a!=null&&(c.callback=a),t=va(e,c,i),t!==null&&(Ft(t,e,i),Rl(t,e,i))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var i=en(),c=ga(i);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=va(e,c,i),t!==null&&(Ft(t,e,i),Rl(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=en(),i=ga(a);i.tag=2,t!=null&&(i.callback=t),t=va(e,i,a),t!==null&&(Ft(t,e,a),Rl(t,e,a))}};function bh(e,t,a,i,c,d,b){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,d,b):t.prototype&&t.prototype.isPureReactComponent?!jl(a,i)||!jl(c,d):!0}function yh(e,t,a,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,i),t.state!==e&&Kc.enqueueReplaceState(t,t.state,null)}function es(e,t){var a=t;if("ref"in t){a={};for(var i in t)i!=="ref"&&(a[i]=t[i])}if(e=e.defaultProps){a===t&&(a=y({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function Sh(e){Yr(e)}function jh(e){console.error(e)}function Nh(e){Yr(e)}function mi(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function wh(e,t,a){try{var i=e.onCaughtError;i(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Zc(e,t,a){return a=ga(a),a.tag=3,a.payload={element:null},a.callback=function(){mi(e,t)},a}function Ah(e){return e=ga(e),e.tag=3,e}function Ch(e,t,a,i){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;e.payload=function(){return c(d)},e.callback=function(){wh(t,a,i)}}var b=a.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(e.callback=function(){wh(t,a,i),typeof c!="function"&&(wa===null?wa=new Set([this]):wa.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})})}function fb(e,t,a,i,c){if(a.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=a.alternate,t!==null&&qs(t,a,c,!0),a=It.current,a!==null){switch(a.tag){case 31:case 13:return hn===null?Ai():a.alternate===null&&ht===0&&(ht=3),a.flags&=-257,a.flags|=65536,a.lanes=c,i===ei?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([i]):t.add(i),yu(e,i,c)),!1;case 22:return a.flags|=65536,i===ei?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([i]):a.add(i)),yu(e,i,c)),!1}throw Error(o(435,a.tag))}return yu(e,i,c),Ai(),!1}if(Ue)return t=It.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==hc&&(e=Error(o(422),{cause:i}),Al(un(e,a)))):(i!==hc&&(t=Error(o(423),{cause:i}),Al(un(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=un(i,a),c=Zc(e.stateNode,i,c),Ac(e,c),ht!==4&&(ht=2)),!1;var d=Error(o(520),{cause:i});if(d=un(d,a),Yl===null?Yl=[d]:Yl.push(d),ht!==4&&(ht=2),t===null)return!0;i=un(i,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Zc(a.stateNode,i,e),Ac(a,e),!1;case 1:if(t=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(wa===null||!wa.has(d))))return a.flags|=65536,c&=-c,a.lanes|=c,c=Ah(c),Ch(c,e,a,i),Ac(a,c),!1}a=a.return}while(a!==null);return!1}var Ic=Error(o(461)),St=!1;function qt(e,t,a,i){t.child=e===null?Rm(t,null,a,i):Pa(t,e.child,a,i)}function Eh(e,t,a,i,c){a=a.render;var d=t.ref;if("ref"in i){var b={};for(var A in i)A!=="ref"&&(b[A]=i[A])}else b=i;return Ka(t),i=qc(e,t,a,b,d,c),A=Tc(),e!==null&&!St?(Dc(e,t,c),Xn(e,t,c)):(Ue&&A&&fc(t),t.flags|=1,qt(e,t,i,c),t.child)}function kh(e,t,a,i,c){if(e===null){var d=a.type;return typeof d=="function"&&!cc(d)&&d.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=d,Mh(e,t,d,i,c)):(e=Kr(a.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(d=e.child,!su(e,c)){var b=d.memoizedProps;if(a=a.compare,a=a!==null?a:jl,a(b,i)&&e.ref===t.ref)return Xn(e,t,c)}return t.flags|=1,e=Hn(d,i),e.ref=t.ref,e.return=t,t.child=e}function Mh(e,t,a,i,c){if(e!==null){var d=e.memoizedProps;if(jl(d,i)&&e.ref===t.ref)if(St=!1,t.pendingProps=i=d,su(e,c))(e.flags&131072)!==0&&(St=!0);else return t.lanes=e.lanes,Xn(e,t,c)}return Jc(e,t,a,i,c)}function Rh(e,t,a,i){var c=i.children,d=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~d}else i=0,t.child=null;return qh(e,t,d,a,i)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Pr(t,d!==null?d.cachePool:null),d!==null?Dm(t,d):Ec(),_m(t);else return i=t.lanes=536870912,qh(e,t,d!==null?d.baseLanes|a:a,a,i)}else d!==null?(Pr(t,d.cachePool),Dm(t,d),ya(),t.memoizedState=null):(e!==null&&Pr(t,null),Ec(),ya());return qt(e,t,c,a),t.child}function Ll(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function qh(e,t,a,i,c){var d=Sc();return d=d===null?null:{parent:bt._currentValue,pool:d},t.memoizedState={baseLanes:a,cachePool:d},e!==null&&Pr(t,null),Ec(),_m(t),e!==null&&qs(e,t,i,!0),t.childLanes=c,null}function hi(e,t){return t=xi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Th(e,t,a){return Pa(t,e.child,null,a),e=hi(t,t.pendingProps),e.flags|=2,Jt(t),t.memoizedState=null,e}function mb(e,t,a){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ue){if(i.mode==="hidden")return e=hi(t,i),t.lanes=536870912,Ll(null,e);if(Mc(t),(e=st)?(e=Y0(e,mn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:Mn,overflow:Rn}:null,retryLane:536870912,hydrationErrors:null},a=pm(e),a.return=t,t.child=a,Mt=t,st=null)):e=null,e===null)throw ha(t);return t.lanes=536870912,null}return hi(t,i)}var d=e.memoizedState;if(d!==null){var b=d.dehydrated;if(Mc(t),c)if(t.flags&256)t.flags&=-257,t=Th(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(St||qs(e,t,a,!1),c=(a&e.childLanes)!==0,St||c){if(i=tt,i!==null&&(b=qe(i,a),b!==0&&b!==d.retryLane))throw d.retryLane=b,Ya(e,b),Ft(i,e,b),Ic;Ai(),t=Th(e,t,a)}else e=d.treeContext,st=pn(b.nextSibling),Mt=t,Ue=!0,ma=null,mn=!1,e!==null&&vm(t,e),t=hi(t,i),t.flags|=4096;return t}return e=Hn(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pi(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Jc(e,t,a,i,c){return Ka(t),a=qc(e,t,a,i,void 0,c),i=Tc(),e!==null&&!St?(Dc(e,t,c),Xn(e,t,c)):(Ue&&i&&fc(t),t.flags|=1,qt(e,t,a,c),t.child)}function Dh(e,t,a,i,c,d){return Ka(t),t.updateQueue=null,a=Bm(t,i,a,c),Om(e),i=Tc(),e!==null&&!St?(Dc(e,t,d),Xn(e,t,d)):(Ue&&i&&fc(t),t.flags|=1,qt(e,t,a,d),t.child)}function _h(e,t,a,i,c){if(Ka(t),t.stateNode===null){var d=Es,b=a.contextType;typeof b=="object"&&b!==null&&(d=Rt(b)),d=new a(i,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Kc,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=i,d.state=t.memoizedState,d.refs={},Nc(t),b=a.contextType,d.context=typeof b=="object"&&b!==null?Rt(b):Es,d.state=t.memoizedState,b=a.getDerivedStateFromProps,typeof b=="function"&&(Qc(t,a,b,i),d.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(b=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),b!==d.state&&Kc.enqueueReplaceState(d,d.state,null),Tl(t,i,d,c),ql(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){d=t.stateNode;var A=t.memoizedProps,D=es(a,A);d.props=D;var Y=d.context,P=a.contextType;b=Es,typeof P=="object"&&P!==null&&(b=Rt(P));var ae=a.getDerivedStateFromProps;P=typeof ae=="function"||typeof d.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,P||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(A||Y!==b)&&yh(t,d,i,b),xa=!1;var Q=t.memoizedState;d.state=Q,Tl(t,i,d,c),ql(),Y=t.memoizedState,A||Q!==Y||xa?(typeof ae=="function"&&(Qc(t,a,ae,i),Y=t.memoizedState),(D=xa||bh(t,a,D,i,Q,Y,b))?(P||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(t.flags|=4194308)):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=Y),d.props=i,d.state=Y,d.context=b,i=D):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{d=t.stateNode,wc(e,t),b=t.memoizedProps,P=es(a,b),d.props=P,ae=t.pendingProps,Q=d.context,Y=a.contextType,D=Es,typeof Y=="object"&&Y!==null&&(D=Rt(Y)),A=a.getDerivedStateFromProps,(Y=typeof A=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(b!==ae||Q!==D)&&yh(t,d,i,D),xa=!1,Q=t.memoizedState,d.state=Q,Tl(t,i,d,c),ql();var Z=t.memoizedState;b!==ae||Q!==Z||xa||e!==null&&e.dependencies!==null&&Ir(e.dependencies)?(typeof A=="function"&&(Qc(t,a,A,i),Z=t.memoizedState),(P=xa||bh(t,a,P,i,Q,Z,D)||e!==null&&e.dependencies!==null&&Ir(e.dependencies))?(Y||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(i,Z,D),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(i,Z,D)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||b===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=Z),d.props=i,d.state=Z,d.context=D,i=P):(typeof d.componentDidUpdate!="function"||b===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),i=!1)}return d=i,pi(e,t),i=(t.flags&128)!==0,d||i?(d=t.stateNode,a=i&&typeof a.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,e!==null&&i?(t.child=Pa(t,e.child,null,c),t.child=Pa(t,null,a,c)):qt(e,t,a,c),t.memoizedState=d.state,e=t.child):e=Xn(e,t,c),e}function Oh(e,t,a,i){return Xa(),t.flags|=256,qt(e,t,a,i),t.child}var Pc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wc(e){return{baseLanes:e,cachePool:wm()}}function eu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Wt),e}function Bh(e,t,a){var i=t.pendingProps,c=!1,d=(t.flags&128)!==0,b;if((b=d)||(b=e!==null&&e.memoizedState===null?!1:(xt.current&2)!==0),b&&(c=!0,t.flags&=-129),b=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ue){if(c?ba(t):ya(),(e=st)?(e=Y0(e,mn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:Mn,overflow:Rn}:null,retryLane:536870912,hydrationErrors:null},a=pm(e),a.return=t,t.child=a,Mt=t,st=null)):e=null,e===null)throw ha(t);return Bu(e)?t.lanes=32:t.lanes=536870912,null}var A=i.children;return i=i.fallback,c?(ya(),c=t.mode,A=xi({mode:"hidden",children:A},c),i=Fa(i,c,a,null),A.return=t,i.return=t,A.sibling=i,t.child=A,i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,b,a),t.memoizedState=Pc,Ll(null,i)):(ba(t),tu(t,A))}var D=e.memoizedState;if(D!==null&&(A=D.dehydrated,A!==null)){if(d)t.flags&256?(ba(t),t.flags&=-257,t=nu(e,t,a)):t.memoizedState!==null?(ya(),t.child=e.child,t.flags|=128,t=null):(ya(),A=i.fallback,c=t.mode,i=xi({mode:"visible",children:i.children},c),A=Fa(A,c,a,null),A.flags|=2,i.return=t,A.return=t,i.sibling=A,t.child=i,Pa(t,e.child,null,a),i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,b,a),t.memoizedState=Pc,t=Ll(null,i));else if(ba(t),Bu(A)){if(b=A.nextSibling&&A.nextSibling.dataset,b)var Y=b.dgst;b=Y,i=Error(o(419)),i.stack="",i.digest=b,Al({value:i,source:null,stack:null}),t=nu(e,t,a)}else if(St||qs(e,t,a,!1),b=(a&e.childLanes)!==0,St||b){if(b=tt,b!==null&&(i=qe(b,a),i!==0&&i!==D.retryLane))throw D.retryLane=i,Ya(e,i),Ft(b,e,i),Ic;Ou(A)||Ai(),t=nu(e,t,a)}else Ou(A)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,st=pn(A.nextSibling),Mt=t,Ue=!0,ma=null,mn=!1,e!==null&&vm(t,e),t=tu(t,i.children),t.flags|=4096);return t}return c?(ya(),A=i.fallback,c=t.mode,D=e.child,Y=D.sibling,i=Hn(D,{mode:"hidden",children:i.children}),i.subtreeFlags=D.subtreeFlags&65011712,Y!==null?A=Hn(Y,A):(A=Fa(A,c,a,null),A.flags|=2),A.return=t,i.return=t,i.sibling=A,t.child=i,Ll(null,i),i=t.child,A=e.child.memoizedState,A===null?A=Wc(a):(c=A.cachePool,c!==null?(D=bt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=wm(),A={baseLanes:A.baseLanes|a,cachePool:c}),i.memoizedState=A,i.childLanes=eu(e,b,a),t.memoizedState=Pc,Ll(e.child,i)):(ba(t),a=e.child,e=a.sibling,a=Hn(a,{mode:"visible",children:i.children}),a.return=t,a.sibling=null,e!==null&&(b=t.deletions,b===null?(t.deletions=[e],t.flags|=16):b.push(e)),t.child=a,t.memoizedState=null,a)}function tu(e,t){return t=xi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function xi(e,t){return e=Zt(22,e,null,t),e.lanes=0,e}function nu(e,t,a){return Pa(t,e.child,null,a),e=tu(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Lh(e,t,a){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),gc(e.return,t,a)}function au(e,t,a,i,c,d){var b=e.memoizedState;b===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:a,tailMode:c,treeForkCount:d}:(b.isBackwards=t,b.rendering=null,b.renderingStartTime=0,b.last=i,b.tail=a,b.tailMode=c,b.treeForkCount=d)}function zh(e,t,a){var i=t.pendingProps,c=i.revealOrder,d=i.tail;i=i.children;var b=xt.current,A=(b&2)!==0;if(A?(b=b&1|2,t.flags|=128):b&=1,I(xt,b),qt(e,t,i,a),i=Ue?wl:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Lh(e,a,t);else if(e.tag===19)Lh(e,a,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(a=t.child,c=null;a!==null;)e=a.alternate,e!==null&&si(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),au(t,!1,c,a,d,i);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&si(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}au(t,!0,a,null,d,i);break;case"together":au(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Xn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Na|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(qs(e,t,a,!1),(a&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,a=Hn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Hn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function su(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Ir(e)))}function hb(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),pa(t,bt,e.memoizedState.cache),Xa();break;case 27:case 5:be(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:pa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Mc(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(ba(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Bh(e,t,a):(ba(t),e=Xn(e,t,a),e!==null?e.sibling:null);ba(t);break;case 19:var c=(e.flags&128)!==0;if(i=(a&t.childLanes)!==0,i||(qs(e,t,a,!1),i=(a&t.childLanes)!==0),c){if(i)return zh(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),I(xt,xt.current),i)break;return null;case 22:return t.lanes=0,Rh(e,t,a,t.pendingProps);case 24:pa(t,bt,e.memoizedState.cache)}return Xn(e,t,a)}function Uh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)St=!0;else{if(!su(e,a)&&(t.flags&128)===0)return St=!1,hb(e,t,a);St=(e.flags&131072)!==0}else St=!1,Ue&&(t.flags&1048576)!==0&&gm(t,wl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Ia(t.elementType),t.type=e,typeof e=="function")cc(e)?(i=es(e,i),t.tag=1,t=_h(null,t,e,i,a)):(t.tag=0,t=Jc(null,t,e,i,a));else{if(e!=null){var c=e.$$typeof;if(c===E){t.tag=11,t=Eh(null,t,e,i,a);break e}else if(c===L){t.tag=14,t=kh(null,t,e,i,a);break e}}throw t=oe(e)||e,Error(o(306,t,""))}}return t;case 0:return Jc(e,t,t.type,t.pendingProps,a);case 1:return i=t.type,c=es(i,t.pendingProps),_h(e,t,i,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var d=t.memoizedState;c=d.element,wc(e,t),Tl(t,i,null,a);var b=t.memoizedState;if(i=b.cache,pa(t,bt,i),i!==d.cache&&vc(t,[bt],a,!0),ql(),i=b.element,d.isDehydrated)if(d={element:i,isDehydrated:!1,cache:b.cache},t.updateQueue.baseState=d,t.memoizedState=d,t.flags&256){t=Oh(e,t,i,a);break e}else if(i!==c){c=un(Error(o(424)),t),Al(c),t=Oh(e,t,i,a);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(st=pn(e.firstChild),Mt=t,Ue=!0,ma=null,mn=!0,a=Rm(t,null,i,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Xa(),i===c){t=Xn(e,t,a);break e}qt(e,t,i,a)}t=t.child}return t;case 26:return pi(e,t),e===null?(a=I0(t.type,null,t.pendingProps,null))?t.memoizedState=a:Ue||(a=t.type,e=t.pendingProps,i=Ti(ce.current).createElement(a),i[ct]=t,i[Ut]=e,Tt(i,a,e),Ct(i),t.stateNode=i):t.memoizedState=I0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return be(t),e===null&&Ue&&(i=t.stateNode=Q0(t.type,t.pendingProps,ce.current),Mt=t,mn=!0,c=st,ka(t.type)?(Lu=c,st=pn(i.firstChild)):st=c),qt(e,t,t.pendingProps.children,a),pi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ue&&((c=i=st)&&(i=Yb(i,t.type,t.pendingProps,mn),i!==null?(t.stateNode=i,Mt=t,st=pn(i.firstChild),mn=!1,c=!0):c=!1),c||ha(t)),be(t),c=t.type,d=t.pendingProps,b=e!==null?e.memoizedProps:null,i=d.children,Tu(c,d)?i=null:b!==null&&Tu(c,b)&&(t.flags|=32),t.memoizedState!==null&&(c=qc(e,t,lb,null,null,a),Pl._currentValue=c),pi(e,t),qt(e,t,i,a),t.child;case 6:return e===null&&Ue&&((e=a=st)&&(a=Fb(a,t.pendingProps,mn),a!==null?(t.stateNode=a,Mt=t,st=null,e=!0):e=!1),e||ha(t)),null;case 13:return Bh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Pa(t,null,i,a):qt(e,t,i,a),t.child;case 11:return Eh(e,t,t.type,t.pendingProps,a);case 7:return qt(e,t,t.pendingProps,a),t.child;case 8:return qt(e,t,t.pendingProps.children,a),t.child;case 12:return qt(e,t,t.pendingProps.children,a),t.child;case 10:return i=t.pendingProps,pa(t,t.type,i.value),qt(e,t,i.children,a),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Ka(t),c=Rt(c),i=i(c),t.flags|=1,qt(e,t,i,a),t.child;case 14:return kh(e,t,t.type,t.pendingProps,a);case 15:return Mh(e,t,t.type,t.pendingProps,a);case 19:return zh(e,t,a);case 31:return mb(e,t,a);case 22:return Rh(e,t,a,t.pendingProps);case 24:return Ka(t),i=Rt(bt),e===null?(c=Sc(),c===null&&(c=tt,d=bc(),c.pooledCache=d,d.refCount++,d!==null&&(c.pooledCacheLanes|=a),c=d),t.memoizedState={parent:i,cache:c},Nc(t),pa(t,bt,c)):((e.lanes&a)!==0&&(wc(e,t),Tl(t,null,null,a),ql()),c=e.memoizedState,d=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),pa(t,bt,i)):(i=d.cache,pa(t,bt,i),i!==c.cache&&vc(t,[bt],a,!0))),qt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Qn(e){e.flags|=4}function lu(e,t,a,i,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(f0())e.flags|=8192;else throw Ja=ei,jc}else e.flags&=-16777217}function Hh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!tp(t))if(f0())e.flags|=8192;else throw Ja=ei,jc}function gi(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Dr():536870912,e.lanes|=t,Gs|=t)}function zl(e,t){if(!Ue)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function lt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,i=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=a,t}function pb(e,t,a){var i=t.pendingProps;switch(mc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return lt(t),null;case 1:return lt(t),null;case 3:return a=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Gn(bt),he(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Rs(t)?Qn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,pc())),lt(t),null;case 26:var c=t.type,d=t.memoizedState;return e===null?(Qn(t),d!==null?(lt(t),Hh(t,d)):(lt(t),lu(t,c,null,i,a))):d?d!==e.memoizedState?(Qn(t),lt(t),Hh(t,d)):(lt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&Qn(t),lt(t),lu(t,c,e,i,a)),null;case 27:if(Ve(t),a=ce.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Qn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return lt(t),null}e=ne.current,Rs(t)?bm(t):(e=Q0(c,i,a),t.stateNode=e,Qn(t))}return lt(t),null;case 5:if(Ve(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Qn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return lt(t),null}if(d=ne.current,Rs(t))bm(t);else{var b=Ti(ce.current);switch(d){case 1:d=b.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:d=b.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":d=b.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":d=b.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":d=b.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof i.is=="string"?b.createElement("select",{is:i.is}):b.createElement("select"),i.multiple?d.multiple=!0:i.size&&(d.size=i.size);break;default:d=typeof i.is=="string"?b.createElement(c,{is:i.is}):b.createElement(c)}}d[ct]=t,d[Ut]=i;e:for(b=t.child;b!==null;){if(b.tag===5||b.tag===6)d.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===t)break e;for(;b.sibling===null;){if(b.return===null||b.return===t)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}t.stateNode=d;e:switch(Tt(d,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Qn(t)}}return lt(t),lu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Qn(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=ce.current,Rs(t)){if(e=t.stateNode,a=t.memoizedProps,i=null,c=Mt,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[ct]=t,e=!!(e.nodeValue===a||i!==null&&i.suppressHydrationWarning===!0||B0(e.nodeValue,a)),e||ha(t,!0)}else e=Ti(e).createTextNode(i),e[ct]=t,t.stateNode=e}return lt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(i=Rs(t),a!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[ct]=t}else Xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;lt(t),e=!1}else a=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Jt(t),t):(Jt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return lt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Rs(t),i!==null&&i.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[ct]=t}else Xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;lt(t),c=!1}else c=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Jt(t),t):(Jt(t),null)}return Jt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=i!==null,e=e!==null&&e.memoizedState!==null,a&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==c&&(i.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),gi(t,t.updateQueue),lt(t),null);case 4:return he(),e===null&&Eu(t.stateNode.containerInfo),lt(t),null;case 10:return Gn(t.type),lt(t),null;case 19:if(_(xt),i=t.memoizedState,i===null)return lt(t),null;if(c=(t.flags&128)!==0,d=i.rendering,d===null)if(c)zl(i,!1);else{if(ht!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(d=si(e),d!==null){for(t.flags|=128,zl(i,!1),e=d.updateQueue,t.updateQueue=e,gi(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)hm(a,e),a=a.sibling;return I(xt,xt.current&1|2),Ue&&Vn(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&le()>ji&&(t.flags|=128,c=!0,zl(i,!1),t.lanes=4194304)}else{if(!c)if(e=si(d),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,gi(t,e),zl(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!Ue)return lt(t),null}else 2*le()-i.renderingStartTime>ji&&a!==536870912&&(t.flags|=128,c=!0,zl(i,!1),t.lanes=4194304);i.isBackwards?(d.sibling=t.child,t.child=d):(e=i.last,e!==null?e.sibling=d:t.child=d,i.last=d)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=le(),e.sibling=null,a=xt.current,I(xt,c?a&1|2:a&1),Ue&&Vn(t,i.treeForkCount),e):(lt(t),null);case 22:case 23:return Jt(t),kc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(a&536870912)!==0&&(t.flags&128)===0&&(lt(t),t.subtreeFlags&6&&(t.flags|=8192)):lt(t),a=t.updateQueue,a!==null&&gi(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==a&&(t.flags|=2048),e!==null&&_(Za),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Gn(bt),lt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function xb(e,t){switch(mc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gn(bt),he(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ve(t),null;case 31:if(t.memoizedState!==null){if(Jt(t),t.alternate===null)throw Error(o(340));Xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Jt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _(xt),null;case 4:return he(),null;case 10:return Gn(t.type),null;case 22:case 23:return Jt(t),kc(),e!==null&&_(Za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gn(bt),null;case 25:return null;default:return null}}function Vh(e,t){switch(mc(t),t.tag){case 3:Gn(bt),he();break;case 26:case 27:case 5:Ve(t);break;case 4:he();break;case 31:t.memoizedState!==null&&Jt(t);break;case 13:Jt(t);break;case 19:_(xt);break;case 10:Gn(t.type);break;case 22:case 23:Jt(t),kc(),e!==null&&_(Za);break;case 24:Gn(bt)}}function Ul(e,t){try{var a=t.updateQueue,i=a!==null?a.lastEffect:null;if(i!==null){var c=i.next;a=c;do{if((a.tag&e)===e){i=void 0;var d=a.create,b=a.inst;i=d(),b.destroy=i}a=a.next}while(a!==c)}}catch(A){Ie(t,t.return,A)}}function Sa(e,t,a){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var d=c.next;i=d;do{if((i.tag&e)===e){var b=i.inst,A=b.destroy;if(A!==void 0){b.destroy=void 0,c=t;var D=a,Y=A;try{Y()}catch(P){Ie(c,D,P)}}}i=i.next}while(i!==d)}}catch(P){Ie(t,t.return,P)}}function $h(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Tm(t,a)}catch(i){Ie(e,e.return,i)}}}function Gh(e,t,a){a.props=es(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(i){Ie(e,t,i)}}function Hl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof a=="function"?e.refCleanup=a(i):a.current=i}}catch(c){Ie(e,t,c)}}function qn(e,t){var a=e.ref,i=e.refCleanup;if(a!==null)if(typeof i=="function")try{i()}catch(c){Ie(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(c){Ie(e,t,c)}else a.current=null}function Yh(e){var t=e.type,a=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&i.focus();break e;case"img":a.src?i.src=a.src:a.srcSet&&(i.srcset=a.srcSet)}}catch(c){Ie(e,e.return,c)}}function ru(e,t,a){try{var i=e.stateNode;zb(i,e.type,a,t),i[Ut]=t}catch(c){Ie(e,e.return,c)}}function Fh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ka(e.type)||e.tag===4}function iu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Fh(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&&ka(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 ou(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=zn));else if(i!==4&&(i===27&&ka(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(ou(e,t,a),e=e.sibling;e!==null;)ou(e,t,a),e=e.sibling}function vi(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(i!==4&&(i===27&&ka(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(vi(e,t,a),e=e.sibling;e!==null;)vi(e,t,a),e=e.sibling}function Xh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Tt(t,i,a),t[ct]=e,t[Ut]=a}catch(d){Ie(e,e.return,d)}}var Kn=!1,jt=!1,cu=!1,Qh=typeof WeakSet=="function"?WeakSet:Set,Et=null;function gb(e,t){if(e=e.containerInfo,Ru=Ui,e=lm(e),nc(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var i=a.getSelection&&a.getSelection();if(i&&i.rangeCount!==0){a=i.anchorNode;var c=i.anchorOffset,d=i.focusNode;i=i.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var b=0,A=-1,D=-1,Y=0,P=0,ae=e,Q=null;t:for(;;){for(var Z;ae!==a||c!==0&&ae.nodeType!==3||(A=b+c),ae!==d||i!==0&&ae.nodeType!==3||(D=b+i),ae.nodeType===3&&(b+=ae.nodeValue.length),(Z=ae.firstChild)!==null;)Q=ae,ae=Z;for(;;){if(ae===e)break t;if(Q===a&&++Y===c&&(A=b),Q===d&&++P===i&&(D=b),(Z=ae.nextSibling)!==null)break;ae=Q,Q=ae.parentNode}ae=Z}a=A===-1||D===-1?null:{start:A,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(qu={focusedElem:e,selectionRange:a},Ui=!1,Et=t;Et!==null;)if(t=Et,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Et=e;else for(;Et!==null;){switch(t=Et,d=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(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&d!==null){e=void 0,a=t,c=d.memoizedProps,d=d.memoizedState,i=a.stateNode;try{var ge=es(a.type,c);e=i.getSnapshotBeforeUpdate(ge,d),i.__reactInternalSnapshotBeforeUpdate=e}catch(Ne){Ie(a,a.return,Ne)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)_u(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":_u(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,Et=e;break}Et=t.return}}function Kh(e,t,a){var i=a.flags;switch(a.tag){case 0:case 11:case 15:In(e,a),i&4&&Ul(5,a);break;case 1:if(In(e,a),i&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(b){Ie(a,a.return,b)}else{var c=es(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(b){Ie(a,a.return,b)}}i&64&&$h(a),i&512&&Hl(a,a.return);break;case 3:if(In(e,a),i&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Tm(e,t)}catch(b){Ie(a,a.return,b)}}break;case 27:t===null&&i&4&&Xh(a);case 26:case 5:In(e,a),t===null&&i&4&&Yh(a),i&512&&Hl(a,a.return);break;case 12:In(e,a);break;case 31:In(e,a),i&4&&Jh(e,a);break;case 13:In(e,a),i&4&&Ph(e,a),i&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=Cb.bind(null,a),Xb(e,a))));break;case 22:if(i=a.memoizedState!==null||Kn,!i){t=t!==null&&t.memoizedState!==null||jt,c=Kn;var d=jt;Kn=i,(jt=t)&&!d?Jn(e,a,(a.subtreeFlags&8772)!==0):In(e,a),Kn=c,jt=d}break;case 30:break;default:In(e,a)}}function Zh(e){var t=e.alternate;t!==null&&(e.alternate=null,Zh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Uo(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 rt=null,Vt=!1;function Zn(e,t,a){for(a=a.child;a!==null;)Ih(e,t,a),a=a.sibling}function Ih(e,t,a){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(En,a)}catch{}switch(a.tag){case 26:jt||qn(a,t),Zn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:jt||qn(a,t);var i=rt,c=Vt;ka(a.type)&&(rt=a.stateNode,Vt=!1),Zn(e,t,a),Zl(a.stateNode),rt=i,Vt=c;break;case 5:jt||qn(a,t);case 6:if(i=rt,c=Vt,rt=null,Zn(e,t,a),rt=i,Vt=c,rt!==null)if(Vt)try{(rt.nodeType===9?rt.body:rt.nodeName==="HTML"?rt.ownerDocument.body:rt).removeChild(a.stateNode)}catch(d){Ie(a,t,d)}else try{rt.removeChild(a.stateNode)}catch(d){Ie(a,t,d)}break;case 18:rt!==null&&(Vt?(e=rt,$0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Js(e)):$0(rt,a.stateNode));break;case 4:i=rt,c=Vt,rt=a.stateNode.containerInfo,Vt=!0,Zn(e,t,a),rt=i,Vt=c;break;case 0:case 11:case 14:case 15:Sa(2,a,t),jt||Sa(4,a,t),Zn(e,t,a);break;case 1:jt||(qn(a,t),i=a.stateNode,typeof i.componentWillUnmount=="function"&&Gh(a,t,i)),Zn(e,t,a);break;case 21:Zn(e,t,a);break;case 22:jt=(i=jt)||a.memoizedState!==null,Zn(e,t,a),jt=i;break;default:Zn(e,t,a)}}function Jh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Js(e)}catch(a){Ie(t,t.return,a)}}}function Ph(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Js(e)}catch(a){Ie(t,t.return,a)}}function vb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Qh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Qh),t;default:throw Error(o(435,e.tag))}}function bi(e,t){var a=vb(e);t.forEach(function(i){if(!a.has(i)){a.add(i);var c=Eb.bind(null,e,i);i.then(c,c)}})}function $t(e,t){var a=t.deletions;if(a!==null)for(var i=0;i<a.length;i++){var c=a[i],d=e,b=t,A=b;e:for(;A!==null;){switch(A.tag){case 27:if(ka(A.type)){rt=A.stateNode,Vt=!1;break e}break;case 5:rt=A.stateNode,Vt=!1;break e;case 3:case 4:rt=A.stateNode.containerInfo,Vt=!0;break e}A=A.return}if(rt===null)throw Error(o(160));Ih(d,b,c),rt=null,Vt=!1,d=c.alternate,d!==null&&(d.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Wh(t,e),t=t.sibling}var Sn=null;function Wh(e,t){var a=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:$t(t,e),Gt(e),i&4&&(Sa(3,e,e.return),Ul(3,e),Sa(5,e,e.return));break;case 1:$t(t,e),Gt(e),i&512&&(jt||a===null||qn(a,a.return)),i&64&&Kn&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?i:a.concat(i))));break;case 26:var c=Sn;if($t(t,e),Gt(e),i&512&&(jt||a===null||qn(a,a.return)),i&4){var d=a!==null?a.memoizedState:null;if(i=e.memoizedState,a===null)if(i===null)if(e.stateNode===null){e:{i=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":d=c.getElementsByTagName("title")[0],(!d||d[ml]||d[ct]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=c.createElement(i),c.head.insertBefore(d,c.querySelector("head > title"))),Tt(d,i,a),d[ct]=e,Ct(d),i=d;break e;case"link":var b=W0("link","href",c).get(i+(a.href||""));if(b){for(var A=0;A<b.length;A++)if(d=b[A],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){b.splice(A,1);break t}}d=c.createElement(i),Tt(d,i,a),c.head.appendChild(d);break;case"meta":if(b=W0("meta","content",c).get(i+(a.content||""))){for(A=0;A<b.length;A++)if(d=b[A],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){b.splice(A,1);break t}}d=c.createElement(i),Tt(d,i,a),c.head.appendChild(d);break;default:throw Error(o(468,i))}d[ct]=e,Ct(d),i=d}e.stateNode=i}else ep(c,e.type,e.stateNode);else e.stateNode=P0(c,i,e.memoizedProps);else d!==i?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,i===null?ep(c,e.type,e.stateNode):P0(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&ru(e,e.memoizedProps,a.memoizedProps)}break;case 27:$t(t,e),Gt(e),i&512&&(jt||a===null||qn(a,a.return)),a!==null&&i&4&&ru(e,e.memoizedProps,a.memoizedProps);break;case 5:if($t(t,e),Gt(e),i&512&&(jt||a===null||qn(a,a.return)),e.flags&32){c=e.stateNode;try{ys(c,"")}catch(ge){Ie(e,e.return,ge)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,ru(e,c,a!==null?a.memoizedProps:c)),i&1024&&(cu=!0);break;case 6:if($t(t,e),Gt(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,a=e.stateNode;try{a.nodeValue=i}catch(ge){Ie(e,e.return,ge)}}break;case 3:if(Oi=null,c=Sn,Sn=Di(t.containerInfo),$t(t,e),Sn=c,Gt(e),i&4&&a!==null&&a.memoizedState.isDehydrated)try{Js(t.containerInfo)}catch(ge){Ie(e,e.return,ge)}cu&&(cu=!1,e0(e));break;case 4:i=Sn,Sn=Di(e.stateNode.containerInfo),$t(t,e),Gt(e),Sn=i;break;case 12:$t(t,e),Gt(e);break;case 31:$t(t,e),Gt(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,bi(e,i)));break;case 13:$t(t,e),Gt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Si=le()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,bi(e,i)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,Y=Kn,P=jt;if(Kn=Y||c,jt=P||D,$t(t,e),jt=P,Kn=Y,Gt(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||Kn||jt||ts(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=t;try{if(d=D.stateNode,c)b=d.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{A=D.stateNode;var ae=D.memoizedProps.style,Q=ae!=null&&ae.hasOwnProperty("display")?ae.display:null;A.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(ge){Ie(D,D.return,ge)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(ge){Ie(D,D.return,ge)}}}else if(t.tag===18){if(a===null){D=t;try{var Z=D.stateNode;c?G0(Z,!0):G0(D.stateNode,!1)}catch(ge){Ie(D,D.return,ge)}}}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;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(a=i.retryQueue,a!==null&&(i.retryQueue=null,bi(e,a))));break;case 19:$t(t,e),Gt(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,bi(e,i)));break;case 30:break;case 21:break;default:$t(t,e),Gt(e)}}function Gt(e){var t=e.flags;if(t&2){try{for(var a,i=e.return;i!==null;){if(Fh(i)){a=i;break}i=i.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,d=iu(e);vi(e,d,c);break;case 5:var b=a.stateNode;a.flags&32&&(ys(b,""),a.flags&=-33);var A=iu(e);vi(e,A,b);break;case 3:case 4:var D=a.stateNode.containerInfo,Y=iu(e);ou(e,Y,D);break;default:throw Error(o(161))}}catch(P){Ie(e,e.return,P)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function e0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;e0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function In(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Kh(e,t.alternate,t),t=t.sibling}function ts(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Sa(4,t,t.return),ts(t);break;case 1:qn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Gh(t,t.return,a),ts(t);break;case 27:Zl(t.stateNode);case 26:case 5:qn(t,t.return),ts(t);break;case 22:t.memoizedState===null&&ts(t);break;case 30:ts(t);break;default:ts(t)}e=e.sibling}}function Jn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,d=t,b=d.flags;switch(d.tag){case 0:case 11:case 15:Jn(c,d,a),Ul(4,d);break;case 1:if(Jn(c,d,a),i=d,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(Y){Ie(i,i.return,Y)}if(i=d,c=i.updateQueue,c!==null){var A=i.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)qm(D[c],A)}catch(Y){Ie(i,i.return,Y)}}a&&b&64&&$h(d),Hl(d,d.return);break;case 27:Xh(d);case 26:case 5:Jn(c,d,a),a&&i===null&&b&4&&Yh(d),Hl(d,d.return);break;case 12:Jn(c,d,a);break;case 31:Jn(c,d,a),a&&b&4&&Jh(c,d);break;case 13:Jn(c,d,a),a&&b&4&&Ph(c,d);break;case 22:d.memoizedState===null&&Jn(c,d,a),Hl(d,d.return);break;case 30:break;default:Jn(c,d,a)}t=t.sibling}}function uu(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cl(a))}function du(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e))}function jn(e,t,a,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)t0(e,t,a,i),t=t.sibling}function t0(e,t,a,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:jn(e,t,a,i),c&2048&&Ul(9,t);break;case 1:jn(e,t,a,i);break;case 3:jn(e,t,a,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cl(e)));break;case 12:if(c&2048){jn(e,t,a,i),e=t.stateNode;try{var d=t.memoizedProps,b=d.id,A=d.onPostCommit;typeof A=="function"&&A(b,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Ie(t,t.return,D)}}else jn(e,t,a,i);break;case 31:jn(e,t,a,i);break;case 13:jn(e,t,a,i);break;case 23:break;case 22:d=t.stateNode,b=t.alternate,t.memoizedState!==null?d._visibility&2?jn(e,t,a,i):Vl(e,t):d._visibility&2?jn(e,t,a,i):(d._visibility|=2,Hs(e,t,a,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&uu(b,t);break;case 24:jn(e,t,a,i),c&2048&&du(t.alternate,t);break;default:jn(e,t,a,i)}}function Hs(e,t,a,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=e,b=t,A=a,D=i,Y=b.flags;switch(b.tag){case 0:case 11:case 15:Hs(d,b,A,D,c),Ul(8,b);break;case 23:break;case 22:var P=b.stateNode;b.memoizedState!==null?P._visibility&2?Hs(d,b,A,D,c):Vl(d,b):(P._visibility|=2,Hs(d,b,A,D,c)),c&&Y&2048&&uu(b.alternate,b);break;case 24:Hs(d,b,A,D,c),c&&Y&2048&&du(b.alternate,b);break;default:Hs(d,b,A,D,c)}t=t.sibling}}function Vl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,i=t,c=i.flags;switch(i.tag){case 22:Vl(a,i),c&2048&&uu(i.alternate,i);break;case 24:Vl(a,i),c&2048&&du(i.alternate,i);break;default:Vl(a,i)}t=t.sibling}}var $l=8192;function Vs(e,t,a){if(e.subtreeFlags&$l)for(e=e.child;e!==null;)n0(e,t,a),e=e.sibling}function n0(e,t,a){switch(e.tag){case 26:Vs(e,t,a),e.flags&$l&&e.memoizedState!==null&&sy(a,Sn,e.memoizedState,e.memoizedProps);break;case 5:Vs(e,t,a);break;case 3:case 4:var i=Sn;Sn=Di(e.stateNode.containerInfo),Vs(e,t,a),Sn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=$l,$l=16777216,Vs(e,t,a),$l=i):Vs(e,t,a));break;default:Vs(e,t,a)}}function a0(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 Gl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];Et=i,l0(i,e)}a0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)s0(e),e=e.sibling}function s0(e){switch(e.tag){case 0:case 11:case 15:Gl(e),e.flags&2048&&Sa(9,e,e.return);break;case 3:Gl(e);break;case 12:Gl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,yi(e)):Gl(e);break;default:Gl(e)}}function yi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];Et=i,l0(i,e)}a0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Sa(8,t,t.return),yi(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,yi(t));break;default:yi(t)}e=e.sibling}}function l0(e,t){for(;Et!==null;){var a=Et;switch(a.tag){case 0:case 11:case 15:Sa(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var i=a.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Cl(a.memoizedState.cache)}if(i=a.child,i!==null)i.return=a,Et=i;else e:for(a=e;Et!==null;){i=Et;var c=i.sibling,d=i.return;if(Zh(i),i===a){Et=null;break e}if(c!==null){c.return=d,Et=c;break e}Et=d}}}var bb={getCacheForType:function(e){var t=Rt(bt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Rt(bt).controller.signal}},yb=typeof WeakMap=="function"?WeakMap:Map,Xe=0,tt=null,_e=null,Be=0,Ze=0,Pt=null,ja=!1,$s=!1,fu=!1,Pn=0,ht=0,Na=0,ns=0,mu=0,Wt=0,Gs=0,Yl=null,Yt=null,hu=!1,Si=0,r0=0,ji=1/0,Ni=null,wa=null,wt=0,Aa=null,Ys=null,Wn=0,pu=0,xu=null,i0=null,Fl=0,gu=null;function en(){return(Xe&2)!==0&&Be!==0?Be&-Be:T.T!==null?Nu():ua()}function o0(){if(Wt===0)if((Be&536870912)===0||Ue){var e=kn;kn<<=1,(kn&3932160)===0&&(kn=262144),Wt=e}else Wt=536870912;return e=It.current,e!==null&&(e.flags|=32),Wt}function Ft(e,t,a){(e===tt&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)&&(Fs(e,0),Ca(e,Be,Wt,!1)),Lt(e,a),((Xe&2)===0||e!==tt)&&(e===tt&&((Xe&2)===0&&(ns|=a),ht===4&&Ca(e,Be,Wt,!1)),Tn(e))}function c0(e,t,a){if((Xe&6)!==0)throw Error(o(327));var i=!a&&(t&127)===0&&(t&e.expiredLanes)===0||za(e,t),c=i?Nb(e,t):bu(e,t,!0),d=i;do{if(c===0){$s&&!i&&Ca(e,t,0,!1);break}else{if(a=e.current.alternate,d&&!Sb(a)){c=bu(e,t,!1),d=!1;continue}if(c===2){if(d=t,e.errorRecoveryDisabledLanes&d)var b=0;else b=e.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){t=b;e:{var A=e;c=Yl;var D=A.current.memoizedState.isDehydrated;if(D&&(Fs(A,b).flags|=256),b=bu(A,b,!1),b!==2){if(fu&&!D){A.errorRecoveryDisabledLanes|=d,ns|=d,c=4;break e}d=Yt,Yt=c,d!==null&&(Yt===null?Yt=d:Yt.push.apply(Yt,d))}c=b}if(d=!1,c!==2)continue}}if(c===1){Fs(e,0),Ca(e,t,0,!0);break}e:{switch(i=e,d=c,d){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:Ca(i,t,Wt,!ja);break e;case 2:Yt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=Si+300-le(),10<c)){if(Ca(i,t,Wt,!ja),La(i,0,!0)!==0)break e;Wn=t,i.timeoutHandle=H0(u0.bind(null,i,a,Yt,Ni,hu,t,Wt,ns,Gs,ja,d,"Throttled",-0,0),c);break e}u0(i,a,Yt,Ni,hu,t,Wt,ns,Gs,ja,d,null,-0,0)}}break}while(!0);Tn(e)}function u0(e,t,a,i,c,d,b,A,D,Y,P,ae,Q,Z){if(e.timeoutHandle=-1,ae=t.subtreeFlags,ae&8192||(ae&16785408)===16785408){ae={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zn},n0(t,d,ae);var ge=(d&62914560)===d?Si-le():(d&4194048)===d?r0-le():0;if(ge=ly(ae,ge),ge!==null){Wn=d,e.cancelPendingCommit=ge(v0.bind(null,e,t,d,a,i,c,b,A,D,P,ae,null,Q,Z)),Ca(e,d,b,!Y);return}}v0(e,t,d,a,i,c,b,A,D)}function Sb(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var i=0;i<a.length;i++){var c=a[i],d=c.getSnapshot;c=c.value;try{if(!Kt(d(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;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 Ca(e,t,a,i){t&=~mu,t&=~ns,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var d=31-Bt(c),b=1<<d;i[d]=-1,c&=~b}a!==0&&Ke(e,a,t)}function wi(){return(Xe&6)===0?(Xl(0),!1):!0}function vu(){if(_e!==null){if(Ze===0)var e=_e.return;else e=_e,$n=Qa=null,_c(e),Os=null,kl=0,e=_e;for(;e!==null;)Vh(e.alternate,e),e=e.return;_e=null}}function Fs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Vb(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Wn=0,vu(),tt=e,_e=a=Hn(e.current,null),Be=t,Ze=0,Pt=null,ja=!1,$s=za(e,t),fu=!1,Gs=Wt=mu=ns=Na=ht=0,Yt=Yl=null,hu=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-Bt(i),d=1<<c;t|=e[c],i&=~d}return Pn=t,Fr(),a}function d0(e,t){ke=null,T.H=Bl,t===_s||t===Wr?(t=Em(),Ze=3):t===jc?(t=Em(),Ze=4):Ze=t===Ic?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Pt=t,_e===null&&(ht=1,mi(e,un(t,e.current)))}function f0(){var e=It.current;return e===null?!0:(Be&4194048)===Be?hn===null:(Be&62914560)===Be||(Be&536870912)!==0?e===hn:!1}function m0(){var e=T.H;return T.H=Bl,e===null?Bl:e}function h0(){var e=T.A;return T.A=bb,e}function Ai(){ht=4,ja||(Be&4194048)!==Be&&It.current!==null||($s=!0),(Na&134217727)===0&&(ns&134217727)===0||tt===null||Ca(tt,Be,Wt,!1)}function bu(e,t,a){var i=Xe;Xe|=2;var c=m0(),d=h0();(tt!==e||Be!==t)&&(Ni=null,Fs(e,t)),t=!1;var b=ht;e:do try{if(Ze!==0&&_e!==null){var A=_e,D=Pt;switch(Ze){case 8:vu(),b=6;break e;case 3:case 2:case 9:case 6:It.current===null&&(t=!0);var Y=Ze;if(Ze=0,Pt=null,Xs(e,A,D,Y),a&&$s){b=0;break e}break;default:Y=Ze,Ze=0,Pt=null,Xs(e,A,D,Y)}}jb(),b=ht;break}catch(P){d0(e,P)}while(!0);return t&&e.shellSuspendCounter++,$n=Qa=null,Xe=i,T.H=c,T.A=d,_e===null&&(tt=null,Be=0,Fr()),b}function jb(){for(;_e!==null;)p0(_e)}function Nb(e,t){var a=Xe;Xe|=2;var i=m0(),c=h0();tt!==e||Be!==t?(Ni=null,ji=le()+500,Fs(e,t)):$s=za(e,t);e:do try{if(Ze!==0&&_e!==null){t=_e;var d=Pt;t:switch(Ze){case 1:Ze=0,Pt=null,Xs(e,t,d,1);break;case 2:case 9:if(Am(d)){Ze=0,Pt=null,x0(t);break}t=function(){Ze!==2&&Ze!==9||tt!==e||(Ze=7),Tn(e)},d.then(t,t);break e;case 3:Ze=7;break e;case 4:Ze=5;break e;case 7:Am(d)?(Ze=0,Pt=null,x0(t)):(Ze=0,Pt=null,Xs(e,t,d,7));break;case 5:var b=null;switch(_e.tag){case 26:b=_e.memoizedState;case 5:case 27:var A=_e;if(b?tp(b):A.stateNode.complete){Ze=0,Pt=null;var D=A.sibling;if(D!==null)_e=D;else{var Y=A.return;Y!==null?(_e=Y,Ci(Y)):_e=null}break t}}Ze=0,Pt=null,Xs(e,t,d,5);break;case 6:Ze=0,Pt=null,Xs(e,t,d,6);break;case 8:vu(),ht=6;break e;default:throw Error(o(462))}}wb();break}catch(P){d0(e,P)}while(!0);return $n=Qa=null,T.H=i,T.A=c,Xe=a,_e!==null?0:(tt=null,Be=0,Fr(),ht)}function wb(){for(;_e!==null&&!Ae();)p0(_e)}function p0(e){var t=Uh(e.alternate,e,Pn);e.memoizedProps=e.pendingProps,t===null?Ci(e):_e=t}function x0(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Dh(a,t,t.pendingProps,t.type,void 0,Be);break;case 11:t=Dh(a,t,t.pendingProps,t.type.render,t.ref,Be);break;case 5:_c(t);default:Vh(a,t),t=_e=hm(t,Pn),t=Uh(a,t,Pn)}e.memoizedProps=e.pendingProps,t===null?Ci(e):_e=t}function Xs(e,t,a,i){$n=Qa=null,_c(t),Os=null,kl=0;var c=t.return;try{if(fb(e,c,t,a,Be)){ht=1,mi(e,un(a,e.current)),_e=null;return}}catch(d){if(c!==null)throw _e=c,d;ht=1,mi(e,un(a,e.current)),_e=null;return}t.flags&32768?(Ue||i===1?e=!0:$s||(Be&536870912)!==0?e=!1:(ja=e=!0,(i===2||i===9||i===3||i===6)&&(i=It.current,i!==null&&i.tag===13&&(i.flags|=16384))),g0(t,e)):Ci(t)}function Ci(e){var t=e;do{if((t.flags&32768)!==0){g0(t,ja);return}e=t.return;var a=pb(t.alternate,t,Pn);if(a!==null){_e=a;return}if(t=t.sibling,t!==null){_e=t;return}_e=t=e}while(t!==null);ht===0&&(ht=5)}function g0(e,t){do{var a=xb(e.alternate,e);if(a!==null){a.flags&=32767,_e=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){_e=e;return}_e=e=a}while(e!==null);ht=6,_e=null}function v0(e,t,a,i,c,d,b,A,D){e.cancelPendingCommit=null;do Ei();while(wt!==0);if((Xe&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(d=t.lanes|t.childLanes,d|=ic,Se(e,a,d,b,A,D),e===tt&&(_e=tt=null,Be=0),Ys=t,Aa=e,Wn=a,pu=d,xu=c,i0=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,kb(kt,function(){return N0(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=T.T,T.T=null,c=H.p,H.p=2,b=Xe,Xe|=4;try{gb(e,t,a)}finally{Xe=b,H.p=c,T.T=i}}wt=1,b0(),y0(),S0()}}function b0(){if(wt===1){wt=0;var e=Aa,t=Ys,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=T.T,T.T=null;var i=H.p;H.p=2;var c=Xe;Xe|=4;try{Wh(t,e);var d=qu,b=lm(e.containerInfo),A=d.focusedElem,D=d.selectionRange;if(b!==A&&A&&A.ownerDocument&&sm(A.ownerDocument.documentElement,A)){if(D!==null&&nc(A)){var Y=D.start,P=D.end;if(P===void 0&&(P=Y),"selectionStart"in A)A.selectionStart=Y,A.selectionEnd=Math.min(P,A.value.length);else{var ae=A.ownerDocument||document,Q=ae&&ae.defaultView||window;if(Q.getSelection){var Z=Q.getSelection(),ge=A.textContent.length,Ne=Math.min(D.start,ge),We=D.end===void 0?Ne:Math.min(D.end,ge);!Z.extend&&Ne>We&&(b=We,We=Ne,Ne=b);var U=am(A,Ne),O=am(A,We);if(U&&O&&(Z.rangeCount!==1||Z.anchorNode!==U.node||Z.anchorOffset!==U.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var G=ae.createRange();G.setStart(U.node,U.offset),Z.removeAllRanges(),Ne>We?(Z.addRange(G),Z.extend(O.node,O.offset)):(G.setEnd(O.node,O.offset),Z.addRange(G))}}}}for(ae=[],Z=A;Z=Z.parentNode;)Z.nodeType===1&&ae.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ae.length;A++){var ee=ae[A];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Ui=!!Ru,qu=Ru=null}finally{Xe=c,H.p=i,T.T=a}}e.current=t,wt=2}}function y0(){if(wt===2){wt=0;var e=Aa,t=Ys,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=T.T,T.T=null;var i=H.p;H.p=2;var c=Xe;Xe|=4;try{Kh(e,t.alternate,t)}finally{Xe=c,H.p=i,T.T=a}}wt=3}}function S0(){if(wt===4||wt===3){wt=0,it();var e=Aa,t=Ys,a=Wn,i=i0;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?wt=5:(wt=0,Ys=Aa=null,j0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(wa=null),At(a),t=t.stateNode,ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(En,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=T.T,c=H.p,H.p=2,T.T=null;try{for(var d=e.onRecoverableError,b=0;b<i.length;b++){var A=i[b];d(A.value,{componentStack:A.stack})}}finally{T.T=t,H.p=c}}(Wn&3)!==0&&Ei(),Tn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===gu?Fl++:(Fl=0,gu=e):Fl=0,Xl(0)}}function j0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cl(t)))}function Ei(){return b0(),y0(),S0(),N0()}function N0(){if(wt!==5)return!1;var e=Aa,t=pu;pu=0;var a=At(Wn),i=T.T,c=H.p;try{H.p=32>a?32:a,T.T=null,a=xu,xu=null;var d=Aa,b=Wn;if(wt=0,Ys=Aa=null,Wn=0,(Xe&6)!==0)throw Error(o(331));var A=Xe;if(Xe|=4,s0(d.current),t0(d,d.current,b,a),Xe=A,Xl(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(En,d)}catch{}return!0}finally{H.p=c,T.T=i,j0(e,t)}}function w0(e,t,a){t=un(a,t),t=Zc(e.stateNode,t,2),e=va(e,t,2),e!==null&&(Lt(e,2),Tn(e))}function Ie(e,t,a){if(e.tag===3)w0(e,e,a);else for(;t!==null;){if(t.tag===3){w0(t,e,a);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(wa===null||!wa.has(i))){e=un(a,e),a=Ah(2),i=va(t,a,2),i!==null&&(Ch(a,i,t,e),Lt(i,2),Tn(i));break}}t=t.return}}function yu(e,t,a){var i=e.pingCache;if(i===null){i=e.pingCache=new yb;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(a)||(fu=!0,c.add(a),e=Ab.bind(null,e,t,a),t.then(e,e))}function Ab(e,t,a){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,tt===e&&(Be&a)===a&&(ht===4||ht===3&&(Be&62914560)===Be&&300>le()-Si?(Xe&2)===0&&Fs(e,0):mu|=a,Gs===Be&&(Gs=0)),Tn(e)}function A0(e,t){t===0&&(t=Dr()),e=Ya(e,t),e!==null&&(Lt(e,t),Tn(e))}function Cb(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),A0(e,a)}function Eb(e,t){var a=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),A0(e,a)}function kb(e,t){return fe(e,t)}var ki=null,Qs=null,Su=!1,Mi=!1,ju=!1,Ea=0;function Tn(e){e!==Qs&&e.next===null&&(Qs===null?ki=Qs=e:Qs=Qs.next=e),Mi=!0,Su||(Su=!0,Rb())}function Xl(e,t){if(!ju&&Mi){ju=!0;do for(var a=!1,i=ki;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var d=0;else{var b=i.suspendedLanes,A=i.pingedLanes;d=(1<<31-Bt(42|e)+1)-1,d&=c&~(b&~A),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,M0(i,d))}else d=Be,d=La(i,i===tt?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(d&3)===0||za(i,d)||(a=!0,M0(i,d));i=i.next}while(a);ju=!1}}function Mb(){C0()}function C0(){Mi=Su=!1;var e=0;Ea!==0&&Hb()&&(e=Ea);for(var t=le(),a=null,i=ki;i!==null;){var c=i.next,d=E0(i,t);d===0?(i.next=null,a===null?ki=c:a.next=c,c===null&&(Qs=a)):(a=i,(e!==0||(d&3)!==0)&&(Mi=!0)),i=c}wt!==0&&wt!==5||Xl(e),Ea!==0&&(Ea=0)}function E0(e,t){for(var a=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,d=e.pendingLanes&-62914561;0<d;){var b=31-Bt(d),A=1<<b,D=c[b];D===-1?((A&a)===0||(A&i)!==0)&&(c[b]=Lo(A,t)):D<=t&&(e.expiredLanes|=A),d&=~A}if(t=tt,a=Be,a=La(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,a===0||e===t&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&we(i),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||za(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(i!==null&&we(i),At(a)){case 2:case 8:a=ft;break;case 32:a=kt;break;case 268435456:a=Qt;break;default:a=kt}return i=k0.bind(null,e),a=fe(a,i),e.callbackPriority=t,e.callbackNode=a,t}return i!==null&&i!==null&&we(i),e.callbackPriority=2,e.callbackNode=null,2}function k0(e,t){if(wt!==0&&wt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Ei()&&e.callbackNode!==a)return null;var i=Be;return i=La(e,e===tt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(c0(e,i,t),E0(e,le()),e.callbackNode!=null&&e.callbackNode===a?k0.bind(null,e):null)}function M0(e,t){if(Ei())return null;c0(e,t,!0)}function Rb(){$b(function(){(Xe&6)!==0?fe(Me,Mb):C0()})}function Nu(){if(Ea===0){var e=Ts;e===0&&(e=nt,nt<<=1,(nt&261888)===0&&(nt=256)),Ea=e}return Ea}function R0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Lr(""+e)}function q0(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function qb(e,t,a,i,c){if(t==="submit"&&a&&a.stateNode===c){var d=R0((c[Ut]||null).action),b=i.submitter;b&&(t=(t=b[Ut]||null)?R0(t.formAction):b.getAttribute("formAction"),t!==null&&(d=t,b=null));var A=new Vr("action","action",null,i,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ea!==0){var D=b?q0(c,b):new FormData(c);Gc(a,{pending:!0,data:D,method:c.method,action:d},null,D)}}else typeof d=="function"&&(A.preventDefault(),D=b?q0(c,b):new FormData(c),Gc(a,{pending:!0,data:D,method:c.method,action:d},d,D))},currentTarget:c}]})}}for(var wu=0;wu<rc.length;wu++){var Au=rc[wu],Tb=Au.toLowerCase(),Db=Au[0].toUpperCase()+Au.slice(1);yn(Tb,"on"+Db)}yn(om,"onAnimationEnd"),yn(cm,"onAnimationIteration"),yn(um,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Zv,"onTransitionRun"),yn(Iv,"onTransitionStart"),yn(Jv,"onTransitionCancel"),yn(dm,"onTransitionEnd"),vs("onMouseEnter",["mouseout","mouseover"]),vs("onMouseLeave",["mouseout","mouseover"]),vs("onPointerEnter",["pointerout","pointerover"]),vs("onPointerLeave",["pointerout","pointerover"]),Ha("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ha("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ha("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ha("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ha("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ha("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="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(" "),_b=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function T0(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var i=e[a],c=i.event;i=i.listeners;e:{var d=void 0;if(t)for(var b=i.length-1;0<=b;b--){var A=i[b],D=A.instance,Y=A.currentTarget;if(A=A.listener,D!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(P){Yr(P)}c.currentTarget=null,d=D}else for(b=0;b<i.length;b++){if(A=i[b],D=A.instance,Y=A.currentTarget,A=A.listener,D!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(P){Yr(P)}c.currentTarget=null,d=D}}}}function Oe(e,t){var a=t[zo];a===void 0&&(a=t[zo]=new Set);var i=e+"__bubble";a.has(i)||(D0(t,e,2,!1),a.add(i))}function Cu(e,t,a){var i=0;t&&(i|=4),D0(a,e,i,t)}var Ri="_reactListening"+Math.random().toString(36).slice(2);function Eu(e){if(!e[Ri]){e[Ri]=!0,Cf.forEach(function(a){a!=="selectionchange"&&(_b.has(a)||Cu(a,!1,e),Cu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ri]||(t[Ri]=!0,Cu("selectionchange",!1,t))}}function D0(e,t,a,i){switch(op(t)){case 2:var c=oy;break;case 8:c=cy;break;default:c=$u}a=c.bind(null,t,a,e),c=void 0,!Qo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function ku(e,t,a,i,c){var d=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var b=i.tag;if(b===3||b===4){var A=i.stateNode.containerInfo;if(A===c)break;if(b===4)for(b=i.return;b!==null;){var D=b.tag;if((D===3||D===4)&&b.stateNode.containerInfo===c)return;b=b.return}for(;A!==null;){if(b=ps(A),b===null)return;if(D=b.tag,D===5||D===6||D===26||D===27){i=d=b;continue e}A=A.parentNode}}i=i.return}zf(function(){var Y=d,P=Fo(a),ae=[];e:{var Q=fm.get(e);if(Q!==void 0){var Z=Vr,ge=e;switch(e){case"keypress":if(Ur(a)===0)break e;case"keydown":case"keyup":Z=Ev;break;case"focusin":ge="focus",Z=Jo;break;case"focusout":ge="blur",Z=Jo;break;case"beforeblur":case"afterblur":Z=Jo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Vf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=pv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=Rv;break;case om:case cm:case um:Z=vv;break;case dm:Z=Tv;break;case"scroll":case"scrollend":Z=mv;break;case"wheel":Z=_v;break;case"copy":case"cut":case"paste":Z=yv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Gf;break;case"toggle":case"beforetoggle":Z=Bv}var Ne=(t&4)!==0,We=!Ne&&(e==="scroll"||e==="scrollend"),U=Ne?Q!==null?Q+"Capture":null:Q;Ne=[];for(var O=Y,G;O!==null;){var ee=O;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||U===null||(ee=pl(O,U),ee!=null&&Ne.push(Kl(O,ee,G))),We)break;O=O.return}0<Ne.length&&(Q=new Z(Q,ge,null,a,P),ae.push({event:Q,listeners:Ne}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",Q&&a!==Yo&&(ge=a.relatedTarget||a.fromElement)&&(ps(ge)||ge[hs]))break e;if((Z||Q)&&(Q=P.window===P?P:(Q=P.ownerDocument)?Q.defaultView||Q.parentWindow:window,Z?(ge=a.relatedTarget||a.toElement,Z=Y,ge=ge?ps(ge):null,ge!==null&&(We=f(ge),Ne=ge.tag,ge!==We||Ne!==5&&Ne!==27&&Ne!==6)&&(ge=null)):(Z=null,ge=Y),Z!==ge)){if(Ne=Vf,ee="onMouseLeave",U="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(Ne=Gf,ee="onPointerLeave",U="onPointerEnter",O="pointer"),We=Z==null?Q:hl(Z),G=ge==null?Q:hl(ge),Q=new Ne(ee,O+"leave",Z,a,P),Q.target=We,Q.relatedTarget=G,ee=null,ps(P)===Y&&(Ne=new Ne(U,O+"enter",ge,a,P),Ne.target=G,Ne.relatedTarget=We,ee=Ne),We=ee,Z&&ge)t:{for(Ne=Ob,U=Z,O=ge,G=0,ee=U;ee;ee=Ne(ee))G++;ee=0;for(var je=O;je;je=Ne(je))ee++;for(;0<G-ee;)U=Ne(U),G--;for(;0<ee-G;)O=Ne(O),ee--;for(;G--;){if(U===O||O!==null&&U===O.alternate){Ne=U;break t}U=Ne(U),O=Ne(O)}Ne=null}else Ne=null;Z!==null&&_0(ae,Q,Z,Ne,!1),ge!==null&&We!==null&&_0(ae,We,ge,Ne,!0)}}e:{if(Q=Y?hl(Y):window,Z=Q.nodeName&&Q.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Q.type==="file")var Ye=Jf;else if(Zf(Q))if(Pf)Ye=Xv;else{Ye=Yv;var ye=Gv}else Z=Q.nodeName,!Z||Z.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?Y&&Go(Y.elementType)&&(Ye=Jf):Ye=Fv;if(Ye&&(Ye=Ye(e,Y))){If(ae,Ye,a,P);break e}ye&&ye(e,Q,Y),e==="focusout"&&Y&&Q.type==="number"&&Y.memoizedProps.value!=null&&$o(Q,"number",Q.value)}switch(ye=Y?hl(Y):window,e){case"focusin":(Zf(ye)||ye.contentEditable==="true")&&(ws=ye,ac=Y,Nl=null);break;case"focusout":Nl=ac=ws=null;break;case"mousedown":sc=!0;break;case"contextmenu":case"mouseup":case"dragend":sc=!1,rm(ae,a,P);break;case"selectionchange":if(Kv)break;case"keydown":case"keyup":rm(ae,a,P)}var Re;if(Wo)e:{switch(e){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Ns?Qf(e,a)&&(Le="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Le="onCompositionStart");Le&&(Yf&&a.locale!=="ko"&&(Ns||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Ns&&(Re=Uf()):(da=P,Ko="value"in da?da.value:da.textContent,Ns=!0)),ye=qi(Y,Le),0<ye.length&&(Le=new $f(Le,e,null,a,P),ae.push({event:Le,listeners:ye}),Re?Le.data=Re:(Re=Kf(a),Re!==null&&(Le.data=Re)))),(Re=zv?Uv(e,a):Hv(e,a))&&(Le=qi(Y,"onBeforeInput"),0<Le.length&&(ye=new $f("onBeforeInput","beforeinput",null,a,P),ae.push({event:ye,listeners:Le}),ye.data=Re)),qb(ae,e,Y,a,P)}T0(ae,t)})}function Kl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function qi(e,t){for(var a=t+"Capture",i=[];e!==null;){var c=e,d=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||d===null||(c=pl(e,a),c!=null&&i.unshift(Kl(e,c,d)),c=pl(e,t),c!=null&&i.push(Kl(e,c,d))),e.tag===3)return i;e=e.return}return[]}function Ob(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function _0(e,t,a,i,c){for(var d=t._reactName,b=[];a!==null&&a!==i;){var A=a,D=A.alternate,Y=A.stateNode;if(A=A.tag,D!==null&&D===i)break;A!==5&&A!==26&&A!==27||Y===null||(D=Y,c?(Y=pl(a,d),Y!=null&&b.unshift(Kl(a,Y,D))):c||(Y=pl(a,d),Y!=null&&b.push(Kl(a,Y,D)))),a=a.return}b.length!==0&&e.push({event:t,listeners:b})}var Bb=/\r\n?/g,Lb=/\u0000|\uFFFD/g;function O0(e){return(typeof e=="string"?e:""+e).replace(Bb,`
|
||
`).replace(Lb,"")}function B0(e,t){return t=O0(t),O0(e)===t}function Pe(e,t,a,i,c,d){switch(a){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||ys(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&ys(e,""+i);break;case"className":Or(e,"class",i);break;case"tabIndex":Or(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Or(e,a,i);break;case"style":Bf(e,i,d);break;case"data":if(t!=="object"){Or(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Lr(""+i),e.setAttribute(a,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(a,"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 d=="function"&&(a==="formAction"?(t!=="input"&&Pe(e,t,"name",c.name,c,null),Pe(e,t,"formEncType",c.formEncType,c,null),Pe(e,t,"formMethod",c.formMethod,c,null),Pe(e,t,"formTarget",c.formTarget,c,null)):(Pe(e,t,"encType",c.encType,c,null),Pe(e,t,"method",c.method,c,null),Pe(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Lr(""+i),e.setAttribute(a,i);break;case"onClick":i!=null&&(e.onclick=zn);break;case"onScroll":i!=null&&Oe("scroll",e);break;case"onScrollEnd":i!=null&&Oe("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}a=Lr(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""+i):e.removeAttribute(a);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":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":i===!0?e.setAttribute(a,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,i):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(a,i):e.removeAttribute(a);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(a):e.setAttribute(a,i);break;case"popover":Oe("beforetoggle",e),Oe("toggle",e),_r(e,"popover",i);break;case"xlinkActuate":Ln(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":Ln(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":Ln(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":Ln(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":Ln(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":Ln(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":_r(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=dv.get(a)||a,_r(e,a,i))}}function Mu(e,t,a,i,c,d){switch(a){case"style":Bf(e,i,d);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof i=="string"?ys(e,i):(typeof i=="number"||typeof i=="bigint")&&ys(e,""+i);break;case"onScroll":i!=null&&Oe("scroll",e);break;case"onScrollEnd":i!=null&&Oe("scrollend",e);break;case"onClick":i!=null&&(e.onclick=zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ef.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),d=e[Ut]||null,d=d!=null?d[a]:null,typeof d=="function"&&e.removeEventListener(t,d,c),typeof i=="function")){typeof d!="function"&&d!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,i,c);break e}a in e?e[a]=i:i===!0?e.setAttribute(a,""):_r(e,a,i)}}}function Tt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Oe("error",e),Oe("load",e);var i=!1,c=!1,d;for(d in a)if(a.hasOwnProperty(d)){var b=a[d];if(b!=null)switch(d){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,d,b,a,null)}}c&&Pe(e,t,"srcSet",a.srcSet,a,null),i&&Pe(e,t,"src",a.src,a,null);return;case"input":Oe("invalid",e);var A=d=b=c=null,D=null,Y=null;for(i in a)if(a.hasOwnProperty(i)){var P=a[i];if(P!=null)switch(i){case"name":c=P;break;case"type":b=P;break;case"checked":D=P;break;case"defaultChecked":Y=P;break;case"value":d=P;break;case"defaultValue":A=P;break;case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(o(137,t));break;default:Pe(e,t,i,P,a,null)}}Tf(e,d,A,D,Y,b,c,!1);return;case"select":Oe("invalid",e),i=b=d=null;for(c in a)if(a.hasOwnProperty(c)&&(A=a[c],A!=null))switch(c){case"value":d=A;break;case"defaultValue":b=A;break;case"multiple":i=A;default:Pe(e,t,c,A,a,null)}t=d,a=b,e.multiple=!!i,t!=null?bs(e,!!i,t,!1):a!=null&&bs(e,!!i,a,!0);return;case"textarea":Oe("invalid",e),d=c=i=null;for(b in a)if(a.hasOwnProperty(b)&&(A=a[b],A!=null))switch(b){case"value":i=A;break;case"defaultValue":c=A;break;case"children":d=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:Pe(e,t,b,A,a,null)}_f(e,i,c,d);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(i=a[D],i!=null))switch(D){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Pe(e,t,D,i,a,null)}return;case"dialog":Oe("beforetoggle",e),Oe("toggle",e),Oe("cancel",e),Oe("close",e);break;case"iframe":case"object":Oe("load",e);break;case"video":case"audio":for(i=0;i<Ql.length;i++)Oe(Ql[i],e);break;case"image":Oe("error",e),Oe("load",e);break;case"details":Oe("toggle",e);break;case"embed":case"source":case"link":Oe("error",e),Oe("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(Y in a)if(a.hasOwnProperty(Y)&&(i=a[Y],i!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,Y,i,a,null)}return;default:if(Go(t)){for(P in a)a.hasOwnProperty(P)&&(i=a[P],i!==void 0&&Mu(e,t,P,i,a,void 0));return}}for(A in a)a.hasOwnProperty(A)&&(i=a[A],i!=null&&Pe(e,t,A,i,a,null))}function zb(e,t,a,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,d=null,b=null,A=null,D=null,Y=null,P=null;for(Z in a){var ae=a[Z];if(a.hasOwnProperty(Z)&&ae!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ae;default:i.hasOwnProperty(Z)||Pe(e,t,Z,null,i,ae)}}for(var Q in i){var Z=i[Q];if(ae=a[Q],i.hasOwnProperty(Q)&&(Z!=null||ae!=null))switch(Q){case"type":d=Z;break;case"name":c=Z;break;case"checked":Y=Z;break;case"defaultChecked":P=Z;break;case"value":b=Z;break;case"defaultValue":A=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ae&&Pe(e,t,Q,Z,i,ae)}}Vo(e,b,A,D,Y,P,d,c);return;case"select":Z=b=A=Q=null;for(d in a)if(D=a[d],a.hasOwnProperty(d)&&D!=null)switch(d){case"value":break;case"multiple":Z=D;default:i.hasOwnProperty(d)||Pe(e,t,d,null,i,D)}for(c in i)if(d=i[c],D=a[c],i.hasOwnProperty(c)&&(d!=null||D!=null))switch(c){case"value":Q=d;break;case"defaultValue":A=d;break;case"multiple":b=d;default:d!==D&&Pe(e,t,c,d,i,D)}t=A,a=b,i=Z,Q!=null?bs(e,!!a,Q,!1):!!i!=!!a&&(t!=null?bs(e,!!a,t,!0):bs(e,!!a,a?[]:"",!1));return;case"textarea":Z=Q=null;for(A in a)if(c=a[A],a.hasOwnProperty(A)&&c!=null&&!i.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:Pe(e,t,A,null,i,c)}for(b in i)if(c=i[b],d=a[b],i.hasOwnProperty(b)&&(c!=null||d!=null))switch(b){case"value":Q=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==d&&Pe(e,t,b,c,i,d)}Df(e,Q,Z);return;case"option":for(var ge in a)if(Q=a[ge],a.hasOwnProperty(ge)&&Q!=null&&!i.hasOwnProperty(ge))switch(ge){case"selected":e.selected=!1;break;default:Pe(e,t,ge,null,i,Q)}for(D in i)if(Q=i[D],Z=a[D],i.hasOwnProperty(D)&&Q!==Z&&(Q!=null||Z!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Pe(e,t,D,Q,i,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 Ne in a)Q=a[Ne],a.hasOwnProperty(Ne)&&Q!=null&&!i.hasOwnProperty(Ne)&&Pe(e,t,Ne,null,i,Q);for(Y in i)if(Q=i[Y],Z=a[Y],i.hasOwnProperty(Y)&&Q!==Z&&(Q!=null||Z!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Pe(e,t,Y,Q,i,Z)}return;default:if(Go(t)){for(var We in a)Q=a[We],a.hasOwnProperty(We)&&Q!==void 0&&!i.hasOwnProperty(We)&&Mu(e,t,We,void 0,i,Q);for(P in i)Q=i[P],Z=a[P],!i.hasOwnProperty(P)||Q===Z||Q===void 0&&Z===void 0||Mu(e,t,P,Q,i,Z);return}}for(var U in a)Q=a[U],a.hasOwnProperty(U)&&Q!=null&&!i.hasOwnProperty(U)&&Pe(e,t,U,null,i,Q);for(ae in i)Q=i[ae],Z=a[ae],!i.hasOwnProperty(ae)||Q===Z||Q==null&&Z==null||Pe(e,t,ae,Q,i,Z)}function L0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ub(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),i=0;i<a.length;i++){var c=a[i],d=c.transferSize,b=c.initiatorType,A=c.duration;if(d&&A&&L0(b)){for(b=0,A=c.responseEnd,i+=1;i<a.length;i++){var D=a[i],Y=D.startTime;if(Y>A)break;var P=D.transferSize,ae=D.initiatorType;P&&L0(ae)&&(D=D.responseEnd,b+=P*(D<A?1:(A-Y)/(D-Y)))}if(--i,t+=8*(d+b)/(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 Ru=null,qu=null;function Ti(e){return e.nodeType===9?e:e.ownerDocument}function z0(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 U0(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 Tu(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 Du=null;function Hb(){var e=window.event;return e&&e.type==="popstate"?e===Du?!1:(Du=e,!0):(Du=null,!1)}var H0=typeof setTimeout=="function"?setTimeout:void 0,Vb=typeof clearTimeout=="function"?clearTimeout:void 0,V0=typeof Promise=="function"?Promise:void 0,$b=typeof queueMicrotask=="function"?queueMicrotask:typeof V0<"u"?function(e){return V0.resolve(null).then(e).catch(Gb)}:H0;function Gb(e){setTimeout(function(){throw e})}function ka(e){return e==="head"}function $0(e,t){var a=t,i=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(i===0){e.removeChild(c),Js(t);return}i--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")i++;else if(a==="html")Zl(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zl(a);for(var d=a.firstChild;d;){var b=d.nextSibling,A=d.nodeName;d[ml]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=b}}else a==="body"&&Zl(e.ownerDocument.body);a=c}while(a);Js(t)}function G0(e,t){var a=e;e=0;do{var i=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),i&&i.nodeType===8)if(a=i.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=i}while(a)}function _u(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":_u(a),Uo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Yb(e,t,a,i){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[ml])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(d=e.getAttribute("rel"),d==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(d!==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(d=e.getAttribute("src"),(d!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&d&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var d=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===d)return e}else return e;if(e=pn(e.nextSibling),e===null)break}return null}function Fb(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=pn(e.nextSibling),e===null))return null;return e}function Y0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=pn(e.nextSibling),e===null))return null;return e}function Ou(e){return e.data==="$?"||e.data==="$~"}function Bu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Xb(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var i=function(){t(),a.removeEventListener("DOMContentLoaded",i)};a.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function pn(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 Lu=null;function F0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return pn(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function X0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function Q0(e,t,a){switch(t=Ti(a),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 Zl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Uo(e)}var xn=new Map,K0=new Set;function Di(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ea=H.d;H.d={f:Qb,r:Kb,D:Zb,C:Ib,L:Jb,m:Pb,X:ey,S:Wb,M:ty};function Qb(){var e=ea.f(),t=wi();return e||t}function Kb(e){var t=xs(e);t!==null&&t.tag===5&&t.type==="form"?dh(t):ea.r(e)}var Ks=typeof document>"u"?null:document;function Z0(e,t,a){var i=Ks;if(i&&typeof t=="string"&&t){var c=on(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),K0.has(c)||(K0.add(c),e={rel:e,crossOrigin:a,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Tt(t,"link",e),Ct(t),i.head.appendChild(t)))}}function Zb(e){ea.D(e),Z0("dns-prefetch",e,null)}function Ib(e,t){ea.C(e,t),Z0("preconnect",e,t)}function Jb(e,t,a){ea.L(e,t,a);var i=Ks;if(i&&e&&t){var c='link[rel="preload"][as="'+on(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+on(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+on(a.imageSizes)+'"]')):c+='[href="'+on(e)+'"]';var d=c;switch(t){case"style":d=Zs(e);break;case"script":d=Is(e)}xn.has(d)||(e=y({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),xn.set(d,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(Il(d))||t==="script"&&i.querySelector(Jl(d))||(t=i.createElement("link"),Tt(t,"link",e),Ct(t),i.head.appendChild(t)))}}function Pb(e,t){ea.m(e,t);var a=Ks;if(a&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+on(i)+'"][href="'+on(e)+'"]',d=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Is(e)}if(!xn.has(d)&&(e=y({rel:"modulepreload",href:e},t),xn.set(d,e),a.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Jl(d)))return}i=a.createElement("link"),Tt(i,"link",e),Ct(i),a.head.appendChild(i)}}}function Wb(e,t,a){ea.S(e,t,a);var i=Ks;if(i&&e){var c=gs(i).hoistableStyles,d=Zs(e);t=t||"default";var b=c.get(d);if(!b){var A={loading:0,preload:null};if(b=i.querySelector(Il(d)))A.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},a),(a=xn.get(d))&&zu(e,a);var D=b=i.createElement("link");Ct(D),Tt(D,"link",e),D._p=new Promise(function(Y,P){D.onload=Y,D.onerror=P}),D.addEventListener("load",function(){A.loading|=1}),D.addEventListener("error",function(){A.loading|=2}),A.loading|=4,_i(b,t,i)}b={type:"stylesheet",instance:b,count:1,state:A},c.set(d,b)}}}function ey(e,t){ea.X(e,t);var a=Ks;if(a&&e){var i=gs(a).hoistableScripts,c=Is(e),d=i.get(c);d||(d=a.querySelector(Jl(c)),d||(e=y({src:e,async:!0},t),(t=xn.get(c))&&Uu(e,t),d=a.createElement("script"),Ct(d),Tt(d,"link",e),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function ty(e,t){ea.M(e,t);var a=Ks;if(a&&e){var i=gs(a).hoistableScripts,c=Is(e),d=i.get(c);d||(d=a.querySelector(Jl(c)),d||(e=y({src:e,async:!0,type:"module"},t),(t=xn.get(c))&&Uu(e,t),d=a.createElement("script"),Ct(d),Tt(d,"link",e),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function I0(e,t,a,i){var c=(c=ce.current)?Di(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Zs(a.href),a=gs(c).hoistableStyles,i=a.get(t),i||(i={type:"style",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Zs(a.href);var d=gs(c).hoistableStyles,b=d.get(e);if(b||(c=c.ownerDocument||c,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(e,b),(d=c.querySelector(Il(e)))&&!d._p&&(b.instance=d,b.state.loading=5),xn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},xn.set(e,a),d||ny(c,e,a,b.state))),t&&i===null)throw Error(o(528,""));return b}if(t&&i!==null)throw Error(o(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Is(a),a=gs(c).hoistableScripts,i=a.get(t),i||(i={type:"script",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Zs(e){return'href="'+on(e)+'"'}function Il(e){return'link[rel="stylesheet"]['+e+"]"}function J0(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function ny(e,t,a,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Tt(t,"link",a),Ct(t),e.head.appendChild(t))}function Is(e){return'[src="'+on(e)+'"]'}function Jl(e){return"script[async]"+e}function P0(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+on(a.href)+'"]');if(i)return t.instance=i,Ct(i),i;var c=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Ct(i),Tt(i,"style",c),_i(i,a.precedence,e),t.instance=i;case"stylesheet":c=Zs(a.href);var d=e.querySelector(Il(c));if(d)return t.state.loading|=4,t.instance=d,Ct(d),d;i=J0(a),(c=xn.get(c))&&zu(i,c),d=(e.ownerDocument||e).createElement("link"),Ct(d);var b=d;return b._p=new Promise(function(A,D){b.onload=A,b.onerror=D}),Tt(d,"link",i),t.state.loading|=4,_i(d,a.precedence,e),t.instance=d;case"script":return d=Is(a.src),(c=e.querySelector(Jl(d)))?(t.instance=c,Ct(c),c):(i=a,(c=xn.get(d))&&(i=y({},a),Uu(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),Ct(c),Tt(c,"link",i),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&&(i=t.instance,t.state.loading|=4,_i(i,a.precedence,e));return t.instance}function _i(e,t,a){for(var i=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,d=c,b=0;b<i.length;b++){var A=i[b];if(A.dataset.precedence===t)d=A;else if(d!==c)break}d?d.parentNode.insertBefore(e,d.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function zu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Uu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Oi=null;function W0(e,t,a){if(Oi===null){var i=new Map,c=Oi=new Map;c.set(a,i)}else c=Oi,i=c.get(a),i||(i=new Map,c.set(a,i));if(i.has(e))return i;for(i.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var d=a[c];if(!(d[ml]||d[ct]||e==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var b=d.getAttribute(t)||"";b=e+b;var A=i.get(b);A?A.push(d):i.set(b,[d])}}return i}function ep(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ay(e,t,a){if(a===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 tp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function sy(e,t,a,i){if(a.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Zs(i.href),d=t.querySelector(Il(c));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Bi.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=d,Ct(d);return}d=t.ownerDocument||t,i=J0(i),(c=xn.get(c))&&zu(i,c),d=d.createElement("link"),Ct(d);var b=d;b._p=new Promise(function(A,D){b.onload=A,b.onerror=D}),Tt(d,"link",i),a.instance=d}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Bi.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Hu=0;function ly(e,t){return e.stylesheets&&e.count===0&&zi(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var i=setTimeout(function(){if(e.stylesheets&&zi(e,e.stylesheets),e.unsuspend){var d=e.unsuspend;e.unsuspend=null,d()}},6e4+t);0<e.imgBytes&&Hu===0&&(Hu=62500*Ub());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&zi(e,e.stylesheets),e.unsuspend)){var d=e.unsuspend;e.unsuspend=null,d()}},(e.imgBytes>Hu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Bi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zi(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Li=null;function zi(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Li=new Map,t.forEach(ry,e),Li=null,Bi.call(e))}function ry(e,t){if(!(t.state.loading&4)){var a=Li.get(e);if(a)var i=a.get(null);else{a=new Map,Li.set(e,a);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<c.length;d++){var b=c[d];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(a.set(b.dataset.precedence,b),i=b)}i&&a.set(null,i)}c=t.instance,b=c.getAttribute("data-precedence"),d=a.get(b)||i,d===i&&a.set(null,c),a.set(b,c),this.count++,i=Bi.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),d?d.parentNode.insertBefore(c,d.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Pl={$$typeof:k,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function iy(e,t,a,i,c,d,b,A,D){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=ms(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ms(0),this.hiddenUpdates=ms(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=d,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function np(e,t,a,i,c,d,b,A,D,Y,P,ae){return e=new iy(e,t,a,b,D,Y,P,ae,A),t=1,d===!0&&(t|=24),d=Zt(3,null,null,t),e.current=d,d.stateNode=e,t=bc(),t.refCount++,e.pooledCache=t,t.refCount++,d.memoizedState={element:i,isDehydrated:a,cache:t},Nc(d),e}function ap(e){return e?(e=Es,e):Es}function sp(e,t,a,i,c,d){c=ap(c),i.context===null?i.context=c:i.pendingContext=c,i=ga(t),i.payload={element:a},d=d===void 0?null:d,d!==null&&(i.callback=d),a=va(e,i,t),a!==null&&(Ft(a,e,t),Rl(a,e,t))}function lp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Vu(e,t){lp(e,t),(e=e.alternate)&&lp(e,t)}function rp(e){if(e.tag===13||e.tag===31){var t=Ya(e,67108864);t!==null&&Ft(t,e,67108864),Vu(e,67108864)}}function ip(e){if(e.tag===13||e.tag===31){var t=en();t=Ge(t);var a=Ya(e,t);a!==null&&Ft(a,e,t),Vu(e,t)}}var Ui=!0;function oy(e,t,a,i){var c=T.T;T.T=null;var d=H.p;try{H.p=2,$u(e,t,a,i)}finally{H.p=d,T.T=c}}function cy(e,t,a,i){var c=T.T;T.T=null;var d=H.p;try{H.p=8,$u(e,t,a,i)}finally{H.p=d,T.T=c}}function $u(e,t,a,i){if(Ui){var c=Gu(i);if(c===null)ku(e,t,i,Hi,a),cp(e,i);else if(dy(c,e,t,a,i))i.stopPropagation();else if(cp(e,i),t&4&&-1<uy.indexOf(e)){for(;c!==null;){var d=xs(c);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var b=ln(d.pendingLanes);if(b!==0){var A=d;for(A.pendingLanes|=2,A.entangledLanes|=2;b;){var D=1<<31-Bt(b);A.entanglements[1]|=D,b&=~D}Tn(d),(Xe&6)===0&&(ji=le()+500,Xl(0))}}break;case 31:case 13:A=Ya(d,2),A!==null&&Ft(A,d,2),wi(),Vu(d,2)}if(d=Gu(i),d===null&&ku(e,t,i,Hi,a),d===c)break;c=d}c!==null&&i.stopPropagation()}else ku(e,t,i,null,a)}}function Gu(e){return e=Fo(e),Yu(e)}var Hi=null;function Yu(e){if(Hi=null,e=ps(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=p(t),e!==null)return e;e=null}else if(a===31){if(e=h(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Hi=e,null}function op(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(de()){case Me:return 2;case ft:return 8;case kt:case ds:return 32;case Qt:return 268435456;default:return 32}default:return 32}}var Fu=!1,Ma=null,Ra=null,qa=null,Wl=new Map,er=new Map,Ta=[],uy="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 cp(e,t){switch(e){case"focusin":case"focusout":Ma=null;break;case"dragenter":case"dragleave":Ra=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":Wl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":er.delete(t.pointerId)}}function tr(e,t,a,i,c,d){return e===null||e.nativeEvent!==d?(e={blockedOn:t,domEventName:a,eventSystemFlags:i,nativeEvent:d,targetContainers:[c]},t!==null&&(t=xs(t),t!==null&&rp(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function dy(e,t,a,i,c){switch(t){case"focusin":return Ma=tr(Ma,e,t,a,i,c),!0;case"dragenter":return Ra=tr(Ra,e,t,a,i,c),!0;case"mouseover":return qa=tr(qa,e,t,a,i,c),!0;case"pointerover":var d=c.pointerId;return Wl.set(d,tr(Wl.get(d)||null,e,t,a,i,c)),!0;case"gotpointercapture":return d=c.pointerId,er.set(d,tr(er.get(d)||null,e,t,a,i,c)),!0}return!1}function up(e){var t=ps(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=p(a),t!==null){e.blockedOn=t,Ua(e.priority,function(){ip(a)});return}}else if(t===31){if(t=h(a),t!==null){e.blockedOn=t,Ua(e.priority,function(){ip(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Vi(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Gu(e.nativeEvent);if(a===null){a=e.nativeEvent;var i=new a.constructor(a.type,a);Yo=i,a.target.dispatchEvent(i),Yo=null}else return t=xs(a),t!==null&&rp(t),e.blockedOn=a,!1;t.shift()}return!0}function dp(e,t,a){Vi(e)&&a.delete(t)}function fy(){Fu=!1,Ma!==null&&Vi(Ma)&&(Ma=null),Ra!==null&&Vi(Ra)&&(Ra=null),qa!==null&&Vi(qa)&&(qa=null),Wl.forEach(dp),er.forEach(dp)}function $i(e,t){e.blockedOn===t&&(e.blockedOn=null,Fu||(Fu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,fy)))}var Gi=null;function fp(e){Gi!==e&&(Gi=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Gi===e&&(Gi=null);for(var t=0;t<e.length;t+=3){var a=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Yu(i||a)===null)continue;break}var d=xs(a);d!==null&&(e.splice(t,3),t-=3,Gc(d,{pending:!0,data:c,method:a.method,action:i},i,c))}}))}function Js(e){function t(D){return $i(D,e)}Ma!==null&&$i(Ma,e),Ra!==null&&$i(Ra,e),qa!==null&&$i(qa,e),Wl.forEach(t),er.forEach(t);for(var a=0;a<Ta.length;a++){var i=Ta[a];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Ta.length&&(a=Ta[0],a.blockedOn===null);)up(a),a.blockedOn===null&&Ta.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(i=0;i<a.length;i+=3){var c=a[i],d=a[i+1],b=c[Ut]||null;if(typeof d=="function")b||fp(a);else if(b){var A=null;if(d&&d.hasAttribute("formAction")){if(c=d,b=d[Ut]||null)A=b.formAction;else if(Yu(c)!==null)continue}else A=b.action;typeof A=="function"?a[i+1]=A:(a.splice(i,3),i-=3),fp(a)}}}function mp(){function e(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(b){return c=b})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),i||setTimeout(a,20)}function a(){if(!i&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Xu(e){this._internalRoot=e}Yi.prototype.render=Xu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,i=en();sp(a,i,e,t,null,null)},Yi.prototype.unmount=Xu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;sp(e.current,2,null,e,null,null),wi(),t[hs]=null}};function Yi(e){this._internalRoot=e}Yi.prototype.unstable_scheduleHydration=function(e){if(e){var t=ua();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Ta.length&&t!==0&&t<Ta[a].priority;a++);Ta.splice(a,0,e),a===0&&up(e)}};var hp=s.version;if(hp!=="19.2.0")throw Error(o(527,hp,"19.2.0"));H.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?v(e):null,e=e===null?null:e.stateNode,e};var my={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Fi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fi.isDisabled&&Fi.supportsFiber)try{En=Fi.inject(my),ot=Fi}catch{}}return ar.createRoot=function(e,t){if(!u(e))throw Error(o(299));var a=!1,i="",c=Sh,d=jh,b=Nh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(b=t.onRecoverableError)),t=np(e,1,!1,null,null,a,i,null,c,d,b,mp),e[hs]=t.current,Eu(e),new Xu(t)},ar.hydrateRoot=function(e,t,a){if(!u(e))throw Error(o(299));var i=!1,c="",d=Sh,b=jh,A=Nh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(b=a.onCaughtError),a.onRecoverableError!==void 0&&(A=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=np(e,1,!0,t,a??null,i,c,D,d,b,A,mp),t.context=ap(null),a=t.current,i=en(),i=Ge(i),c=ga(i),c.callback=null,va(a,c,i),a=i,t.current.lanes=a,Lt(t,a),Tn(t),e[hs]=t.current,Eu(e),new Yi(t)},ar.version="19.2.0",ar}var wp;function wy(){if(wp)return Zu.exports;wp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Zu.exports=Ny(),Zu.exports}var Ay=wy();var Ap="popstate";function Cy(n={}){function s(o,u){let{pathname:f,search:p,hash:h}=o.location;return Nd("",{pathname:f,search:p,hash:h},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function r(o,u){return typeof u=="string"?u:xr(u)}return ky(s,r,null,n)}function dt(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Cn(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Ey(){return Math.random().toString(36).substring(2,10)}function Cp(n,s){return{usr:n.state,key:n.key,idx:s}}function Nd(n,s,r=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?cl(s):s,state:r,key:s&&s.key||o||Ey()}}function xr({pathname:n="/",search:s="",hash:r=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),r&&r!=="#"&&(n+=r.charAt(0)==="#"?r:"#"+r),n}function cl(n){let s={};if(n){let r=n.indexOf("#");r>=0&&(s.hash=n.substring(r),n=n.substring(0,r));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function ky(n,s,r,o={}){let{window:u=document.defaultView,v5Compat:f=!1}=o,p=u.history,h="POP",x=null,g=v();g==null&&(g=0,p.replaceState({...p.state,idx:g},""));function v(){return(p.state||{idx:null}).idx}function y(){h="POP";let w=v(),j=w==null?null:w-g;g=w,x&&x({action:h,location:S.location,delta:j})}function N(w,j){h="PUSH";let R=Nd(S.location,w,j);g=v()+1;let k=Cp(R,g),E=S.createHref(R);try{p.pushState(k,"",E)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;u.location.assign(E)}f&&x&&x({action:h,location:S.location,delta:1})}function M(w,j){h="REPLACE";let R=Nd(S.location,w,j);g=v();let k=Cp(R,g),E=S.createHref(R);p.replaceState(k,"",E),f&&x&&x({action:h,location:S.location,delta:0})}function C(w){return My(w)}let S={get action(){return h},get location(){return n(u,p)},listen(w){if(x)throw new Error("A history only accepts one active listener");return u.addEventListener(Ap,y),x=w,()=>{u.removeEventListener(Ap,y),x=null}},createHref(w){return s(u,w)},createURL:C,encodeLocation(w){let j=C(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:N,replace:M,go(w){return p.go(w)}};return S}function My(n,s=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),dt(r,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:xr(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=r+o),new URL(o,r)}function Mx(n,s,r="/"){return Ry(n,s,r,!1)}function Ry(n,s,r,o){let u=typeof s=="string"?cl(s):s,f=ra(u.pathname||"/",r);if(f==null)return null;let p=Rx(n);qy(p);let h=null;for(let x=0;h==null&&x<p.length;++x){let g=$y(f);h=Hy(p[x],g,o)}return h}function Rx(n,s=[],r=[],o="",u=!1){let f=(p,h,x=u,g)=>{let v={relativePath:g===void 0?p.path||"":g,caseSensitive:p.caseSensitive===!0,childrenIndex:h,route:p};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&x)return;dt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let y=la([o,v.relativePath]),N=r.concat(v);p.children&&p.children.length>0&&(dt(p.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Rx(p.children,s,N,y,x)),!(p.path==null&&!p.index)&&s.push({path:y,score:zy(y,p.index),routesMeta:N})};return n.forEach((p,h)=>{if(p.path===""||!p.path?.includes("?"))f(p,h);else for(let x of qx(p.path))f(p,h,!0,x)}),s}function qx(n){let s=n.split("/");if(s.length===0)return[];let[r,...o]=s,u=r.endsWith("?"),f=r.replace(/\?$/,"");if(o.length===0)return u?[f,""]:[f];let p=qx(o.join("/")),h=[];return h.push(...p.map(x=>x===""?f:[f,x].join("/"))),u&&h.push(...p),h.map(x=>n.startsWith("/")&&x===""?"/":x)}function qy(n){n.sort((s,r)=>s.score!==r.score?r.score-s.score:Uy(s.routesMeta.map(o=>o.childrenIndex),r.routesMeta.map(o=>o.childrenIndex)))}var Ty=/^:[\w-]+$/,Dy=3,_y=2,Oy=1,By=10,Ly=-2,Ep=n=>n==="*";function zy(n,s){let r=n.split("/"),o=r.length;return r.some(Ep)&&(o+=Ly),s&&(o+=_y),r.filter(u=>!Ep(u)).reduce((u,f)=>u+(Ty.test(f)?Dy:f===""?Oy:By),o)}function Uy(n,s){return n.length===s.length&&n.slice(0,-1).every((o,u)=>o===s[u])?n[n.length-1]-s[s.length-1]:0}function Hy(n,s,r=!1){let{routesMeta:o}=n,u={},f="/",p=[];for(let h=0;h<o.length;++h){let x=o[h],g=h===o.length-1,v=f==="/"?s:s.slice(f.length)||"/",y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},v),N=x.route;if(!y&&g&&r&&!o[o.length-1].route.index&&(y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!y)return null;Object.assign(u,y.params),p.push({params:u,pathname:la([f,y.pathname]),pathnameBase:Qy(la([f,y.pathnameBase])),route:N}),y.pathnameBase!=="/"&&(f=la([f,y.pathnameBase]))}return p}function ho(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[r,o]=Vy(n.path,n.caseSensitive,n.end),u=s.match(r);if(!u)return null;let f=u[0],p=f.replace(/(.)\/+$/,"$1"),h=u.slice(1);return{params:o.reduce((g,{paramName:v,isOptional:y},N)=>{if(v==="*"){let C=h[N]||"";p=f.slice(0,f.length-C.length).replace(/(.)\/+$/,"$1")}const M=h[N];return y&&!M?g[v]=void 0:g[v]=(M||"").replace(/%2F/g,"/"),g},{}),pathname:f,pathnameBase:p,pattern:n}}function Vy(n,s=!1,r=!0){Cn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(p,h,x)=>(o.push({paramName:h,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,s?void 0:"i"),o]}function $y(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Cn(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function ra(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,o=n.charAt(r);return o&&o!=="/"?null:n.slice(r)||"/"}var Gy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yy=n=>Gy.test(n);function Fy(n,s="/"){let{pathname:r,search:o="",hash:u=""}=typeof n=="string"?cl(n):n,f;if(r)if(Yy(r))f=r;else{if(r.includes("//")){let p=r;r=r.replace(/\/\/+/g,"/"),Cn(!1,`Pathnames cannot have embedded double slashes - normalizing ${p} -> ${r}`)}r.startsWith("/")?f=kp(r.substring(1),"/"):f=kp(r,s)}else f=s;return{pathname:f,search:Ky(o),hash:Zy(u)}}function kp(n,s){let r=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?r.length>1&&r.pop():u!=="."&&r.push(u)}),r.length>1?r.join("/"):"/"}function Wu(n,s,r,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Xy(n){return n.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function Tx(n){let s=Xy(n);return s.map((r,o)=>o===s.length-1?r.pathname:r.pathnameBase)}function Dx(n,s,r,o=!1){let u;typeof n=="string"?u=cl(n):(u={...n},dt(!u.pathname||!u.pathname.includes("?"),Wu("?","pathname","search",u)),dt(!u.pathname||!u.pathname.includes("#"),Wu("#","pathname","hash",u)),dt(!u.search||!u.search.includes("#"),Wu("#","search","hash",u)));let f=n===""||u.pathname==="",p=f?"/":u.pathname,h;if(p==null)h=r;else{let y=s.length-1;if(!o&&p.startsWith("..")){let N=p.split("/");for(;N[0]==="..";)N.shift(),y-=1;u.pathname=N.join("/")}h=y>=0?s[y]:"/"}let x=Fy(u,h),g=p&&p!=="/"&&p.endsWith("/"),v=(f||p===".")&&r.endsWith("/");return!x.pathname.endsWith("/")&&(g||v)&&(x.pathname+="/"),x}var la=n=>n.join("/").replace(/\/\/+/g,"/"),Qy=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Ky=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Zy=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Iy(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _x=["POST","PUT","PATCH","DELETE"];new Set(_x);var Jy=["GET",..._x];new Set(Jy);var ul=m.createContext(null);ul.displayName="DataRouter";var Ao=m.createContext(null);Ao.displayName="DataRouterState";m.createContext(!1);var Ox=m.createContext({isTransitioning:!1});Ox.displayName="ViewTransition";var Py=m.createContext(new Map);Py.displayName="Fetchers";var Wy=m.createContext(null);Wy.displayName="Await";var Bn=m.createContext(null);Bn.displayName="Navigation";var Ar=m.createContext(null);Ar.displayName="Location";var oa=m.createContext({outlet:null,matches:[],isDataRoute:!1});oa.displayName="Route";var Gd=m.createContext(null);Gd.displayName="RouteError";function e1(n,{relative:s}={}){dt(Cr(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=m.useContext(Bn),{hash:u,pathname:f,search:p}=Er(n,{relative:s}),h=f;return r!=="/"&&(h=f==="/"?r:la([r,f])),o.createHref({pathname:h,search:p,hash:u})}function Cr(){return m.useContext(Ar)!=null}function us(){return dt(Cr(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ar).location}var Bx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lx(n){m.useContext(Bn).static||m.useLayoutEffect(n)}function t1(){let{isDataRoute:n}=m.useContext(oa);return n?h1():n1()}function n1(){dt(Cr(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(ul),{basename:s,navigator:r}=m.useContext(Bn),{matches:o}=m.useContext(oa),{pathname:u}=us(),f=JSON.stringify(Tx(o)),p=m.useRef(!1);return Lx(()=>{p.current=!0}),m.useCallback((x,g={})=>{if(Cn(p.current,Bx),!p.current)return;if(typeof x=="number"){r.go(x);return}let v=Dx(x,JSON.parse(f),u,g.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:la([s,v.pathname])),(g.replace?r.replace:r.push)(v,g.state,g)},[s,r,f,u,n])}m.createContext(null);function Er(n,{relative:s}={}){let{matches:r}=m.useContext(oa),{pathname:o}=us(),u=JSON.stringify(Tx(r));return m.useMemo(()=>Dx(n,JSON.parse(u),o,s==="path"),[n,u,o,s])}function a1(n,s){return zx(n,s)}function zx(n,s,r,o,u){dt(Cr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(Bn),{matches:p}=m.useContext(oa),h=p[p.length-1],x=h?h.params:{},g=h?h.pathname:"/",v=h?h.pathnameBase:"/",y=h&&h.route;{let R=y&&y.path||"";Ux(g,!y||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${R}">) 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="${R}"> to <Route path="${R==="/"?"*":`${R}/*`}">.`)}let N=us(),M;if(s){let R=typeof s=="string"?cl(s):s;dt(v==="/"||R.pathname?.startsWith(v),`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 "${v}" but pathname "${R.pathname}" was given in the \`location\` prop.`),M=R}else M=N;let C=M.pathname||"/",S=C;if(v!=="/"){let R=v.replace(/^\//,"").split("/");S="/"+C.replace(/^\//,"").split("/").slice(R.length).join("/")}let w=Mx(n,{pathname:S});Cn(y||w!=null,`No routes matched location "${M.pathname}${M.search}${M.hash}" `),Cn(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.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 j=o1(w&&w.map(R=>Object.assign({},R,{params:Object.assign({},x,R.params),pathname:la([v,f.encodeLocation?f.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?v:la([v,f.encodeLocation?f.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),p,r,o,u);return s&&j?m.createElement(Ar.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...M},navigationType:"POP"}},j):j}function s1(){let n=m1(),s=Iy(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),r=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:o},f={padding:"2px 4px",backgroundColor:o},p=null;return console.error("Error handled by React Router default ErrorBoundary:",n),p=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:f},"ErrorBoundary")," or"," ",m.createElement("code",{style:f},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),r?m.createElement("pre",{style:u},r):null,p)}var l1=m.createElement(s1,null),r1=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(oa.Provider,{value:this.props.routeContext},m.createElement(Gd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function i1({routeContext:n,match:s,children:r}){let o=m.useContext(ul);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(oa.Provider,{value:n},r)}function o1(n,s=[],r=null,o=null,u=null){if(n==null){if(!r)return null;if(r.errors)n=r.matches;else if(s.length===0&&!r.initialized&&r.matches.length>0)n=r.matches;else return null}let f=n,p=r?.errors;if(p!=null){let v=f.findIndex(y=>y.route.id&&p?.[y.route.id]!==void 0);dt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(p).join(",")}`),f=f.slice(0,Math.min(f.length,v+1))}let h=!1,x=-1;if(r)for(let v=0;v<f.length;v++){let y=f[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(x=v),y.route.id){let{loaderData:N,errors:M}=r,C=y.route.loader&&!N.hasOwnProperty(y.route.id)&&(!M||M[y.route.id]===void 0);if(y.route.lazy||C){h=!0,x>=0?f=f.slice(0,x+1):f=[f[0]];break}}}let g=r&&o?(v,y)=>{o(v,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:y})}:void 0;return f.reduceRight((v,y,N)=>{let M,C=!1,S=null,w=null;r&&(M=p&&y.route.id?p[y.route.id]:void 0,S=y.route.errorElement||l1,h&&(x<0&&N===0?(Ux("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,w=null):x===N&&(C=!0,w=y.route.hydrateFallbackElement||null)));let j=s.concat(f.slice(0,N+1)),R=()=>{let k;return M?k=S:C?k=w:y.route.Component?k=m.createElement(y.route.Component,null):y.route.element?k=y.route.element:k=v,m.createElement(i1,{match:y,routeContext:{outlet:v,matches:j,isDataRoute:r!=null},children:k})};return r&&(y.route.ErrorBoundary||y.route.errorElement||N===0)?m.createElement(r1,{location:r.location,revalidation:r.revalidation,component:S,error:M,children:R(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:g}):R()},null)}function Yd(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function c1(n){let s=m.useContext(ul);return dt(s,Yd(n)),s}function u1(n){let s=m.useContext(Ao);return dt(s,Yd(n)),s}function d1(n){let s=m.useContext(oa);return dt(s,Yd(n)),s}function Fd(n){let s=d1(n),r=s.matches[s.matches.length-1];return dt(r.route.id,`${n} can only be used on routes that contain a unique "id"`),r.route.id}function f1(){return Fd("useRouteId")}function m1(){let n=m.useContext(Gd),s=u1("useRouteError"),r=Fd("useRouteError");return n!==void 0?n:s.errors?.[r]}function h1(){let{router:n}=c1("useNavigate"),s=Fd("useNavigate"),r=m.useRef(!1);return Lx(()=>{r.current=!0}),m.useCallback(async(u,f={})=>{Cn(r.current,Bx),r.current&&(typeof u=="number"?n.navigate(u):await n.navigate(u,{fromRouteId:s,...f}))},[n,s])}var Mp={};function Ux(n,s,r){!s&&!Mp[n]&&(Mp[n]=!0,Cn(!1,r))}m.memo(p1);function p1({routes:n,future:s,state:r,unstable_onError:o}){return zx(n,void 0,r,o,s)}function ao(n){dt(!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 x1({basename:n="/",children:s=null,location:r,navigationType:o="POP",navigator:u,static:f=!1}){dt(!Cr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:p,navigator:u,static:f,future:{}}),[p,u,f]);typeof r=="string"&&(r=cl(r));let{pathname:x="/",search:g="",hash:v="",state:y=null,key:N="default"}=r,M=m.useMemo(()=>{let C=ra(x,p);return C==null?null:{location:{pathname:C,search:g,hash:v,state:y,key:N},navigationType:o}},[p,x,g,v,y,N,o]);return Cn(M!=null,`<Router basename="${p}"> is not able to match the URL "${x}${g}${v}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:m.createElement(Bn.Provider,{value:h},m.createElement(Ar.Provider,{children:s,value:M}))}function g1({children:n,location:s}){return a1(wd(n),s)}function wd(n,s=[]){let r=[];return m.Children.forEach(n,(o,u)=>{if(!m.isValidElement(o))return;let f=[...s,u];if(o.type===m.Fragment){r.push.apply(r,wd(o.props.children,f));return}dt(o.type===ao,`[${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>`),dt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let p={id:o.props.id||f.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&&(p.children=wd(o.props.children,f)),r.push(p)}),r}var so="get",lo="application/x-www-form-urlencoded";function Co(n){return n!=null&&typeof n.tagName=="string"}function v1(n){return Co(n)&&n.tagName.toLowerCase()==="button"}function b1(n){return Co(n)&&n.tagName.toLowerCase()==="form"}function y1(n){return Co(n)&&n.tagName.toLowerCase()==="input"}function S1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function j1(n,s){return n.button===0&&(!s||s==="_self")&&!S1(n)}var Xi=null;function N1(){if(Xi===null)try{new FormData(document.createElement("form"),0),Xi=!1}catch{Xi=!0}return Xi}var w1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ed(n){return n!=null&&!w1.has(n)?(Cn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${lo}"`),null):n}function A1(n,s){let r,o,u,f,p;if(b1(n)){let h=n.getAttribute("action");o=h?ra(h,s):null,r=n.getAttribute("method")||so,u=ed(n.getAttribute("enctype"))||lo,f=new FormData(n)}else if(v1(n)||y1(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=n.getAttribute("formaction")||h.getAttribute("action");if(o=x?ra(x,s):null,r=n.getAttribute("formmethod")||h.getAttribute("method")||so,u=ed(n.getAttribute("formenctype"))||ed(h.getAttribute("enctype"))||lo,f=new FormData(h,n),!N1()){let{name:g,type:v,value:y}=n;if(v==="image"){let N=g?`${g}.`:"";f.append(`${N}x`,"0"),f.append(`${N}y`,"0")}else g&&f.append(g,y)}}else{if(Co(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=so,o=null,u=lo,p=n}return f&&u==="text/plain"&&(p=f,f=void 0),{action:o,method:r.toLowerCase(),encType:u,formData:f,body:p}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xd(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function C1(n,s,r){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${r}`:s&&ra(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function E1(n,s){if(n.id in s)return s[n.id];try{let r=await import(n.module);return s[n.id]=r,r}catch(r){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function k1(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function M1(n,s,r){let o=await Promise.all(n.map(async u=>{let f=s.routes[u.route.id];if(f){let p=await E1(f,r);return p.links?p.links():[]}return[]}));return D1(o.flat(1).filter(k1).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function Rp(n,s,r,o,u,f){let p=(x,g)=>r[g]?x.route.id!==r[g].route.id:!0,h=(x,g)=>r[g].pathname!==x.pathname||r[g].route.path?.endsWith("*")&&r[g].params["*"]!==x.params["*"];return f==="assets"?s.filter((x,g)=>p(x,g)||h(x,g)):f==="data"?s.filter((x,g)=>{let v=o.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(p(x,g)||h(x,g))return!0;if(x.route.shouldRevalidate){let y=x.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function R1(n,s,{includeHydrateFallback:r}={}){return q1(n.map(o=>{let u=s.routes[o.route.id];if(!u)return[];let f=[u.module];return u.clientActionModule&&(f=f.concat(u.clientActionModule)),u.clientLoaderModule&&(f=f.concat(u.clientLoaderModule)),r&&u.hydrateFallbackModule&&(f=f.concat(u.hydrateFallbackModule)),u.imports&&(f=f.concat(u.imports)),f}).flat(1))}function q1(n){return[...new Set(n)]}function T1(n){let s={},r=Object.keys(n).sort();for(let o of r)s[o]=n[o];return s}function D1(n,s){let r=new Set;return new Set(s),n.reduce((o,u)=>{let f=JSON.stringify(T1(u));return r.has(f)||(r.add(f),o.push({key:f,link:u})),o},[])}function Hx(){let n=m.useContext(ul);return Xd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function _1(){let n=m.useContext(Ao);return Xd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Qd=m.createContext(void 0);Qd.displayName="FrameworkContext";function Vx(){let n=m.useContext(Qd);return Xd(n,"You must render this element inside a <HydratedRouter> element"),n}function O1(n,s){let r=m.useContext(Qd),[o,u]=m.useState(!1),[f,p]=m.useState(!1),{onFocus:h,onBlur:x,onMouseEnter:g,onMouseLeave:v,onTouchStart:y}=s,N=m.useRef(null);m.useEffect(()=>{if(n==="render"&&p(!0),n==="viewport"){let S=j=>{j.forEach(R=>{p(R.isIntersecting)})},w=new IntersectionObserver(S,{threshold:.5});return N.current&&w.observe(N.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let S=setTimeout(()=>{p(!0)},100);return()=>{clearTimeout(S)}}},[o]);let M=()=>{u(!0)},C=()=>{u(!1),p(!1)};return r?n!=="intent"?[f,N,{}]:[f,N,{onFocus:sr(h,M),onBlur:sr(x,C),onMouseEnter:sr(g,M),onMouseLeave:sr(v,C),onTouchStart:sr(y,M)}]:[!1,N,{}]}function sr(n,s){return r=>{n&&n(r),r.defaultPrevented||s(r)}}function B1({page:n,...s}){let{router:r}=Hx(),o=m.useMemo(()=>Mx(r.routes,n,r.basename),[r.routes,n,r.basename]);return o?m.createElement(z1,{page:n,matches:o,...s}):null}function L1(n){let{manifest:s,routeModules:r}=Vx(),[o,u]=m.useState([]);return m.useEffect(()=>{let f=!1;return M1(n,s,r).then(p=>{f||u(p)}),()=>{f=!0}},[n,s,r]),o}function z1({page:n,matches:s,...r}){let o=us(),{manifest:u,routeModules:f}=Vx(),{basename:p}=Hx(),{loaderData:h,matches:x}=_1(),g=m.useMemo(()=>Rp(n,s,x,u,o,"data"),[n,s,x,u,o]),v=m.useMemo(()=>Rp(n,s,x,u,o,"assets"),[n,s,x,u,o]),y=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let C=new Set,S=!1;if(s.forEach(j=>{let R=u.routes[j.route.id];!R||!R.hasLoader||(!g.some(k=>k.route.id===j.route.id)&&j.route.id in h&&f[j.route.id]?.shouldRevalidate||R.hasClientLoader?S=!0:C.add(j.route.id))}),C.size===0)return[];let w=C1(n,p,"data");return S&&C.size>0&&w.searchParams.set("_routes",s.filter(j=>C.has(j.route.id)).map(j=>j.route.id).join(",")),[w.pathname+w.search]},[p,h,o,u,g,s,n,f]),N=m.useMemo(()=>R1(v,u),[v,u]),M=L1(v);return m.createElement(m.Fragment,null,y.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...r})),N.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...r})),M.map(({key:C,link:S})=>m.createElement("link",{key:C,nonce:r.nonce,...S})))}function U1(...n){return s=>{n.forEach(r=>{typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var $x=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{$x&&(window.__reactRouterVersion="7.9.6")}catch{}function H1({basename:n,children:s,window:r}){let o=m.useRef();o.current==null&&(o.current=Cy({window:r,v5Compat:!0}));let u=o.current,[f,p]=m.useState({action:u.action,location:u.location}),h=m.useCallback(x=>{m.startTransition(()=>p(x))},[p]);return m.useLayoutEffect(()=>u.listen(h),[u,h]),m.createElement(x1,{basename:n,children:s,location:f.location,navigationType:f.action,navigator:u})}var Gx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yx=m.forwardRef(function({onClick:s,discover:r="render",prefetch:o="none",relative:u,reloadDocument:f,replace:p,state:h,target:x,to:g,preventScrollReset:v,viewTransition:y,...N},M){let{basename:C}=m.useContext(Bn),S=typeof g=="string"&&Gx.test(g),w,j=!1;if(typeof g=="string"&&S&&(w=g,$x))try{let K=new URL(window.location.href),V=g.startsWith("//")?new URL(K.protocol+g):new URL(g),F=ra(V.pathname,C);V.origin===K.origin&&F!=null?g=F+V.search+V.hash:j=!0}catch{Cn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let R=e1(g,{relative:u}),[k,E,B]=O1(o,N),X=Y1(g,{replace:p,state:h,target:x,preventScrollReset:v,relative:u,viewTransition:y});function L(K){s&&s(K),K.defaultPrevented||X(K)}let z=m.createElement("a",{...N,...B,href:w||R,onClick:j||f?s:L,ref:U1(M,E),target:x,"data-discover":!S&&r==="render"?"true":void 0});return k&&!S?m.createElement(m.Fragment,null,z,m.createElement(B1,{page:R})):z});Yx.displayName="Link";var V1=m.forwardRef(function({"aria-current":s="page",caseSensitive:r=!1,className:o="",end:u=!1,style:f,to:p,viewTransition:h,children:x,...g},v){let y=Er(p,{relative:g.relative}),N=us(),M=m.useContext(Ao),{navigator:C,basename:S}=m.useContext(Bn),w=M!=null&&Z1(y)&&h===!0,j=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,R=N.pathname,k=M&&M.navigation&&M.navigation.location?M.navigation.location.pathname:null;r||(R=R.toLowerCase(),k=k?k.toLowerCase():null,j=j.toLowerCase()),k&&S&&(k=ra(k,S)||k);const E=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let B=R===j||!u&&R.startsWith(j)&&R.charAt(E)==="/",X=k!=null&&(k===j||!u&&k.startsWith(j)&&k.charAt(j.length)==="/"),L={isActive:B,isPending:X,isTransitioning:w},z=B?s:void 0,K;typeof o=="function"?K=o(L):K=[o,B?"active":null,X?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let V=typeof f=="function"?f(L):f;return m.createElement(Yx,{...g,"aria-current":z,className:K,ref:v,style:V,to:p,viewTransition:h},typeof x=="function"?x(L):x)});V1.displayName="NavLink";var $1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:r,reloadDocument:o,replace:u,state:f,method:p=so,action:h,onSubmit:x,relative:g,preventScrollReset:v,viewTransition:y,...N},M)=>{let C=Q1(),S=K1(h,{relative:g}),w=p.toLowerCase()==="get"?"get":"post",j=typeof h=="string"&&Gx.test(h),R=k=>{if(x&&x(k),k.defaultPrevented)return;k.preventDefault();let E=k.nativeEvent.submitter,B=E?.getAttribute("formmethod")||p;C(E||k.currentTarget,{fetcherKey:s,method:B,navigate:r,replace:u,state:f,relative:g,preventScrollReset:v,viewTransition:y})};return m.createElement("form",{ref:M,method:w,action:S,onSubmit:o?x:R,...N,"data-discover":!j&&n==="render"?"true":void 0})});$1.displayName="Form";function G1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Fx(n){let s=m.useContext(ul);return dt(s,G1(n)),s}function Y1(n,{target:s,replace:r,state:o,preventScrollReset:u,relative:f,viewTransition:p}={}){let h=t1(),x=us(),g=Er(n,{relative:f});return m.useCallback(v=>{if(j1(v,s)){v.preventDefault();let y=r!==void 0?r:xr(x)===xr(g);h(n,{replace:y,state:o,preventScrollReset:u,relative:f,viewTransition:p})}},[x,h,g,r,o,s,n,u,f,p])}var F1=0,X1=()=>`__${String(++F1)}__`;function Q1(){let{router:n}=Fx("useSubmit"),{basename:s}=m.useContext(Bn),r=f1();return m.useCallback(async(o,u={})=>{let{action:f,method:p,encType:h,formData:x,body:g}=A1(o,s);if(u.navigate===!1){let v=u.fetcherKey||X1();await n.fetch(v,r,u.action||f,{preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync})}else await n.navigate(u.action||f,{preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:r,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,s,r])}function K1(n,{relative:s}={}){let{basename:r}=m.useContext(Bn),o=m.useContext(oa);dt(o,"useFormAction must be used inside a RouteContext");let[u]=o.matches.slice(-1),f={...Er(n||".",{relative:s})},p=us();if(n==null){f.search=p.search;let h=new URLSearchParams(f.search),x=h.getAll("index");if(x.some(v=>v==="")){h.delete("index"),x.filter(y=>y).forEach(y=>h.append("index",y));let v=h.toString();f.search=v?`?${v}`:""}}return(!n||n===".")&&u.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(f.pathname=f.pathname==="/"?r:la([r,f.pathname])),xr(f)}function Z1(n,{relative:s}={}){let r=m.useContext(Ox);dt(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Fx("useViewTransitionState"),u=Er(n,{relative:s});if(!r.isTransitioning)return!1;let f=ra(r.currentLocation.pathname,o)||r.currentLocation.pathname,p=ra(r.nextLocation.pathname,o)||r.nextLocation.pathname;return ho(u.pathname,p)!=null||ho(u.pathname,f)!=null}const On=Object.create(null);On.open="0";On.close="1";On.ping="2";On.pong="3";On.message="4";On.upgrade="5";On.noop="6";const ro=Object.create(null);Object.keys(On).forEach(n=>{ro[On[n]]=n});const Ad={type:"error",data:"parser error"},Xx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Qx=typeof ArrayBuffer=="function",Kx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Kd=({type:n,data:s},r,o)=>Xx&&s instanceof Blob?r?o(s):qp(s,o):Qx&&(s instanceof ArrayBuffer||Kx(s))?r?o(s):qp(new Blob([s]),o):o(On[n]+(s||"")),qp=(n,s)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];s("b"+(o||""))},r.readAsDataURL(n)};function Tp(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let td;function I1(n,s){if(Xx&&n.data instanceof Blob)return n.data.arrayBuffer().then(Tp).then(s);if(Qx&&(n.data instanceof ArrayBuffer||Kx(n.data)))return s(Tp(n.data));Kd(n,!1,r=>{td||(td=new TextEncoder),s(td.encode(r))})}const Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ur=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Dp.length;n++)ur[Dp.charCodeAt(n)]=n;const J1=n=>{let s=n.length*.75,r=n.length,o,u=0,f,p,h,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),v=new Uint8Array(g);for(o=0;o<r;o+=4)f=ur[n.charCodeAt(o)],p=ur[n.charCodeAt(o+1)],h=ur[n.charCodeAt(o+2)],x=ur[n.charCodeAt(o+3)],v[u++]=f<<2|p>>4,v[u++]=(p&15)<<4|h>>2,v[u++]=(h&3)<<6|x&63;return g},P1=typeof ArrayBuffer=="function",Zd=(n,s)=>{if(typeof n!="string")return{type:"message",data:Zx(n,s)};const r=n.charAt(0);return r==="b"?{type:"message",data:W1(n.substring(1),s)}:ro[r]?n.length>1?{type:ro[r],data:n.substring(1)}:{type:ro[r]}:Ad},W1=(n,s)=>{if(P1){const r=J1(n);return Zx(r,s)}else return{base64:!0,data:n}},Zx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Ix="",eS=(n,s)=>{const r=n.length,o=new Array(r);let u=0;n.forEach((f,p)=>{Kd(f,!1,h=>{o[p]=h,++u===r&&s(o.join(Ix))})})},tS=(n,s)=>{const r=n.split(Ix),o=[];for(let u=0;u<r.length;u++){const f=Zd(r[u],s);if(o.push(f),f.type==="error")break}return o};function nS(){return new TransformStream({transform(n,s){I1(n,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const f=new DataView(u.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{u=new Uint8Array(9);const f=new DataView(u.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(u[0]|=128),s.enqueue(u),s.enqueue(r)})}})}let nd;function Qi(n){return n.reduce((s,r)=>s+r.length,0)}function Ki(n,s){if(n[0].length===s)return n.shift();const r=new Uint8Array(s);let o=0;for(let u=0;u<s;u++)r[u]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function aS(n,s){nd||(nd=new TextDecoder);const r=[];let o=0,u=-1,f=!1;return new TransformStream({transform(p,h){for(r.push(p);;){if(o===0){if(Qi(r)<1)break;const x=Ki(r,1);f=(x[0]&128)===128,u=x[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Qi(r)<2)break;const x=Ki(r,2);u=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Qi(r)<8)break;const x=Ki(r,8),g=new DataView(x.buffer,x.byteOffset,x.length),v=g.getUint32(0);if(v>Math.pow(2,21)-1){h.enqueue(Ad);break}u=v*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Qi(r)<u)break;const x=Ki(r,u);h.enqueue(Zd(f?x:nd.decode(x),s)),o=0}if(u===0||u>n){h.enqueue(Ad);break}}}})}const Jx=4;function Nt(n){if(n)return sS(n)}function sS(n){for(var s in Nt.prototype)n[s]=Nt.prototype[s];return n}Nt.prototype.on=Nt.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};Nt.prototype.once=function(n,s){function r(){this.off(n,r),s.apply(this,arguments)}return r.fn=s,this.on(n,r),this};Nt.prototype.off=Nt.prototype.removeListener=Nt.prototype.removeAllListeners=Nt.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,u=0;u<r.length;u++)if(o=r[u],o===s||o.fn===s){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+n],this};Nt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].apply(this,s)}return this};Nt.prototype.emitReserved=Nt.prototype.emit;Nt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Nt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Eo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,r)=>r(s,0),bn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),lS="arraybuffer";function Px(n,...s){return s.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const rS=bn.setTimeout,iS=bn.clearTimeout;function ko(n,s){s.useNativeTimers?(n.setTimeoutFn=rS.bind(bn),n.clearTimeoutFn=iS.bind(bn)):(n.setTimeoutFn=bn.setTimeout.bind(bn),n.clearTimeoutFn=bn.clearTimeout.bind(bn))}const oS=1.33;function cS(n){return typeof n=="string"?uS(n):Math.ceil((n.byteLength||n.size)*oS)}function uS(n){let s=0,r=0;for(let o=0,u=n.length;o<u;o++)s=n.charCodeAt(o),s<128?r+=1:s<2048?r+=2:s<55296||s>=57344?r+=3:(o++,r+=4);return r}function Wx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dS(n){let s="";for(let r in n)n.hasOwnProperty(r)&&(s.length&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return s}function fS(n){let s={},r=n.split("&");for(let o=0,u=r.length;o<u;o++){let f=r[o].split("=");s[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return s}class mS extends Error{constructor(s,r,o){super(s),this.description=r,this.context=o,this.type="TransportError"}}class Id extends Nt{constructor(s){super(),this.writable=!1,ko(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,r,o){return super.emitReserved("error",new mS(s,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const r=Zd(s,this.socket.binaryType);this.onPacket(r)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,r={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const r=dS(s);return r.length?"?"+r:""}}class hS extends Id{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const r=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const r=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)};tS(s,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,eS(s,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=Wx()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(s,r)}}let eg=!1;try{eg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const pS=eg;function xS(){}class gS extends hS{constructor(s){if(super(s),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,r){const o=this.request({method:"POST",data:s});o.on("success",r),o.on("error",(u,f)=>{this.onError("xhr post error",u,f)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=s}}class _n extends Nt{constructor(s,r,o){super(),this.createRequest=s,ko(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const r=Px(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.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(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=_n.requestsCount++,_n.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=xS,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _n.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}_n.requestsCount=0;_n.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",_p);else if(typeof addEventListener=="function"){const n="onpagehide"in bn?"pagehide":"unload";addEventListener(n,_p,!1)}}function _p(){for(let n in _n.requests)_n.requests.hasOwnProperty(n)&&_n.requests[n].abort()}const vS=(function(){const n=tg({xdomain:!1});return n&&n.responseType!==null})();class bS extends gS{constructor(s){super(s);const r=s&&s.forceBase64;this.supportsBinary=vS&&!r}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new _n(tg,this.uri(),s)}}function tg(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||pS))return new XMLHttpRequest}catch{}if(!s)try{return new bn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ng=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class yS extends Id{get name(){return"websocket"}doOpen(){const s=this.uri(),r=this.opts.protocols,o=ng?{}:Px(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(s,r,o)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let r=0;r<s.length;r++){const o=s[r],u=r===s.length-1;Kd(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}u&&Eo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=Wx()),this.supportsBinary||(r.b64=1),this.createUri(s,r)}}const ad=bn.WebSocket||bn.MozWebSocket;class SS extends yS{createSocket(s,r,o){return ng?new ad(s,r,o):r?new ad(s,r):new ad(s)}doWrite(s,r){this.ws.send(r)}}class jS extends Id{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const r=aS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(r).getReader(),u=nS();u.readable.pipeTo(s.writable),this._writer=u.writable.getWriter();const f=()=>{o.read().then(({done:h,value:x})=>{h||(this.onPacket(x),f())}).catch(h=>{})};f();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let r=0;r<s.length;r++){const o=s[r],u=r===s.length-1;this._writer.write(o).then(()=>{u&&Eo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const NS={websocket:SS,webtransport:jS,polling:bS},wS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,AS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Cd(n){if(n.length>8e3)throw"URI too long";const s=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let u=wS.exec(n||""),f={},p=14;for(;p--;)f[AS[p]]=u[p]||"";return r!=-1&&o!=-1&&(f.source=s,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=CS(f,f.path),f.queryKey=ES(f,f.query),f}function CS(n,s){const r=/\/{2,9}/g,o=s.replace(r,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function ES(n,s){const r={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,f){u&&(r[u]=f)}),r}const Ed=typeof addEventListener=="function"&&typeof removeEventListener=="function",io=[];Ed&&addEventListener("offline",()=>{io.forEach(n=>n())},!1);class Oa extends Nt{constructor(s,r){if(super(),this.binaryType=lS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(r=s,s=null),s){const o=Cd(s);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Cd(r.host).host);ko(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{const u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=fS(this.opts.query)),Ed&&(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"})},io.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const r=Object.assign({},this.opts.query);r.EIO=Jx,r.transport=s,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&Oa.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(s);r.open(),this.setTransport(r)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Oa.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=s.data,this._onError(r);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),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 s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=cS(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,Eo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,r,o){return this._sendPacket("message",s,r,o),this}send(s,r,o){return this._sendPacket("message",s,r,o),this}_sendPacket(s,r,o,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:s,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),u&&this.once("flush",u),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),s()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():s()}):this.upgrading?o():s()),this}_onError(s){if(Oa.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,r){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(),Ed&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=io.indexOf(this._offlineEventListener);o!==-1&&io.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,r),this.writeBuffer=[],this._prevBufferLen=0}}}Oa.protocol=Jx;class kS extends Oa{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let r=this.createTransport(s),o=!1;Oa.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",y=>{if(!o)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Oa.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const N=new Error("probe error");N.transport=r.name,this.emitReserved("upgradeError",N)}}))};function f(){o||(o=!0,v(),r.close(),r=null)}const p=y=>{const N=new Error("probe error: "+y);N.transport=r.name,f(),this.emitReserved("upgradeError",N)};function h(){p("transport closed")}function x(){p("socket closed")}function g(y){r&&y.name!==r.name&&f()}const v=()=>{r.removeListener("open",u),r.removeListener("error",p),r.removeListener("close",h),this.off("close",x),this.off("upgrading",g)};r.once("open",u),r.once("error",p),r.once("close",h),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const r=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&r.push(s[o]);return r}}let MS=class extends kS{constructor(s,r={}){const o=typeof s=="object"?s:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>NS[u]).filter(u=>!!u)),super(s,o)}};function RS(n,s="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=Cd(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+s,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const qS=typeof ArrayBuffer=="function",TS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ag=Object.prototype.toString,DS=typeof Blob=="function"||typeof Blob<"u"&&ag.call(Blob)==="[object BlobConstructor]",_S=typeof File=="function"||typeof File<"u"&&ag.call(File)==="[object FileConstructor]";function Jd(n){return qS&&(n instanceof ArrayBuffer||TS(n))||DS&&n instanceof Blob||_S&&n instanceof File}function oo(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(oo(n[r]))return!0;return!1}if(Jd(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return oo(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&oo(n[r]))return!0;return!1}function OS(n){const s=[],r=n.data,o=n;return o.data=kd(r,s),o.attachments=s.length,{packet:o,buffers:s}}function kd(n,s){if(!n)return n;if(Jd(n)){const r={_placeholder:!0,num:s.length};return s.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=kd(n[o],s);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=kd(n[o],s));return r}return n}function BS(n,s){return n.data=Md(n.data,s),delete n.attachments,n}function Md(n,s){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<s.length)return s[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Md(n[r],s);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Md(n[r],s));return n}const LS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],zS=5;var He;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(He||(He={}));class US{constructor(s){this.replacer=s}encode(s){return(s.type===He.EVENT||s.type===He.ACK)&&oo(s)?this.encodeAsBinary({type:s.type===He.EVENT?He.BINARY_EVENT:He.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let r=""+s.type;return(s.type===He.BINARY_EVENT||s.type===He.BINARY_ACK)&&(r+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(r+=s.nsp+","),s.id!=null&&(r+=s.id),s.data!=null&&(r+=JSON.stringify(s.data,this.replacer)),r}encodeAsBinary(s){const r=OS(s),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function Op(n){return Object.prototype.toString.call(n)==="[object Object]"}class Pd extends Nt{constructor(s){super(),this.reviver=s}add(s){let r;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(s);const o=r.type===He.BINARY_EVENT;o||r.type===He.BINARY_ACK?(r.type=o?He.EVENT:He.ACK,this.reconstructor=new HS(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Jd(s)||s.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(s),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let r=0;const o={type:Number(s.charAt(0))};if(He[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===He.BINARY_EVENT||o.type===He.BINARY_ACK){const f=r+1;for(;s.charAt(++r)!=="-"&&r!=s.length;);const p=s.substring(f,r);if(p!=Number(p)||s.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(p)}if(s.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(s.charAt(r)===","||r===s.length););o.nsp=s.substring(f,r)}else o.nsp="/";const u=s.charAt(r+1);if(u!==""&&Number(u)==u){const f=r+1;for(;++r;){const p=s.charAt(r);if(p==null||Number(p)!=p){--r;break}if(r===s.length)break}o.id=Number(s.substring(f,r+1))}if(s.charAt(++r)){const f=this.tryParse(s.substr(r));if(Pd.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,r){switch(s){case He.CONNECT:return Op(r);case He.DISCONNECT:return r===void 0;case He.CONNECT_ERROR:return typeof r=="string"||Op(r);case He.EVENT:case He.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&LS.indexOf(r[0])===-1);case He.ACK:case He.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class HS{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const r=BS(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const VS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Pd,Encoder:US,get PacketType(){return He},protocol:zS},Symbol.toStringTag,{value:"Module"}));function wn(n,s,r){return n.on(s,r),function(){n.off(s,r)}}const $S=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sg extends Nt{constructor(s,r,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=s,this.nsp=r,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 s=this.io;this.subs=[wn(s,"open",this.onopen.bind(this)),wn(s,"packet",this.onpacket.bind(this)),wn(s,"error",this.onerror.bind(this)),wn(s,"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(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...r){var o,u,f;if($S.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(r.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const p={type:He.EVENT,data:r};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const v=this.ids++,y=r.pop();this._registerAckCallback(v,y),p.id=v}const h=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,x=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!h||(x?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(s,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[s]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===s&&this.sendBuffer.splice(h,1);r.call(this,new Error("operation has timed out"))},u),p=(...h)=>{this.io.clearTimeoutFn(f),r.apply(this,h)};p.withError=!0,this.acks[s]=p}emitWithAck(s,...r){return new Promise((o,u)=>{const f=(p,h)=>p?u(p):o(h);f.withError=!0,r.push(f),this.emit(s,...r)})}_addToQueue(s){let r;typeof s[s.length-1]=="function"&&(r=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((u,...f)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!s||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:He.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(o=>String(o.id)===s)){const o=this.acks[s];delete this.acks[s],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case He.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.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 He.EVENT:case He.BINARY_EVENT:this.onevent(s);break;case He.ACK:case He.BINARY_ACK:this.onack(s);break;case He.DISCONNECT:this.ondisconnect();break;case He.CONNECT_ERROR:this.destroy();const o=new Error(s.data.message);o.data=s.data.data,this.emitReserved("connect_error",o);break}}onevent(s){const r=s.data||[];s.id!=null&&r.push(this.ack(s.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const r=this;let o=!1;return function(...u){o||(o=!0,r.packet({type:He.ACK,id:s,data:u}))}}onack(s){const r=this.acks[s.id];typeof r=="function"&&(delete this.acks[s.id],r.withError&&s.data.unshift(null),r.apply(this,s.data))}onconnect(s,r){this.id=s,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:He.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(s===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(s===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,s.data)}}}function dl(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}dl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),r=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};dl.prototype.reset=function(){this.attempts=0};dl.prototype.setMin=function(n){this.ms=n};dl.prototype.setMax=function(n){this.max=n};dl.prototype.setJitter=function(n){this.jitter=n};class Rd extends Nt{constructor(s,r){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(r=s,s=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,ko(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new dl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=s;const u=r.parser||VS;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var r;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(r=this.backoff)===null||r===void 0||r.setMin(s),this)}randomizationFactor(s){var r;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(r=this.backoff)===null||r===void 0||r.setJitter(s),this)}reconnectionDelayMax(s){var r;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(r=this.backoff)===null||r===void 0||r.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new MS(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=wn(r,"open",function(){o.onopen(),s&&s()}),f=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),s?s(h):this.maybeReconnectOnOpen()},p=wn(r,"error",f);if(this._timeout!==!1){const h=this._timeout,x=this.setTimeoutFn(()=>{u(),f(new Error("timeout")),r.close()},h);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(u),this.subs.push(p),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(wn(s,"ping",this.onping.bind(this)),wn(s,"data",this.ondata.bind(this)),wn(s,"error",this.onerror.bind(this)),wn(s,"close",this.onclose.bind(this)),wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(r){this.onclose("parse error",r)}}ondecoded(s){Eo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,r){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new sg(this,s,r),this.nsps[s]=o),o}_destroy(s){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(s){const r=this.encoder.encode(s);for(let o=0;o<r.length;o++)this.engine.write(r[o],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(u=>{u?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",u)):s.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const lr={};function co(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const r=RS(n,s.path||"/socket.io"),o=r.source,u=r.id,f=r.path,p=lr[u]&&f in lr[u].nsps,h=s.forceNew||s["force new connection"]||s.multiplex===!1||p;let x;return h?x=new Rd(o,s):(lr[u]||(lr[u]=new Rd(o,s)),x=lr[u]),r.query&&!s.query&&(s.query=r.queryKey),x.socket(r.path,s)}Object.assign(co,{Manager:Rd,Socket:sg,io:co,connect:co});const lg="roverSettings",GS=3600*24*365;function YS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function qd(){if(typeof document>"u")return{};const n=`${lg}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const r=s.substring(n.length);return YS(r)??{}}function Bp(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),r=`${lg}=${s}; path=/; max-age=${GS}; samesite=strict`;return document.cookie=r,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const rg=window.location.origin;console.info("[socket] connecting to",rg);const FS=qd(),XS=FS?.page?.connectionTransport||"websocket",QS=XS==="polling"?["polling"]:["websocket","polling"],Wd=co(rg,{transports:QS,timeout:15e3});Wd.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const ig=m.createContext(Wd),KS=({children:n})=>l.jsx(ig.Provider,{value:Wd,children:n}),sn=()=>m.useContext(ig),ZS={connected:!1,session:null,neatoLidar:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,overseerControlState:null,alerts:[]},ef=m.createContext(null);function IS(n){return m.useCallback((s,r={})=>new Promise((o,u)=>{n.emit(s,r,(f={})=>{f.error?u(new Error(f.error)):o(f)})}),[n])}function JS(n){return typeof n=="function"?n:s=>s}function PS({children:n}){const s=sn(),r=IS(s),o=m.useRef({...ZS,connected:s.connected}),u=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),p=m.useCallback(v=>{const y=o.current,N=typeof v=="function"?v(y):{...y,...v||{}};N!==y&&(o.current=N,u.current.forEach(M=>{const C=M.selector(N);M.equalityFn(M.current,C)||(M.current=C,M.listener(C))}))},[]),h=m.useCallback((v,y,N=Object.is)=>{const M=JS(v),C={selector:M,equalityFn:N,listener:y,current:M(o.current)};return u.current.add(C),()=>{u.current.delete(C)}},[]);m.useEffect(()=>{const v=()=>{p(N=>N.connected?N:{...N,connected:!0})},y=()=>{p(N=>N.connected?{...N,connected:!1}:N)};return s.on("connect",v),s.on("disconnect",y),()=>{s.off("connect",v),s.off("disconnect",y)}},[p,s]),m.useEffect(()=>{function v(k){p(E=>({...E,session:k}))}function y(k=[]){p(E=>({...E,logs:k}))}function N(k){p(E=>({...E,logs:[...E.logs.slice(-199),k]}))}function M(k=[]){p(E=>({...E,adminLogs:k}))}function C(k){p(E=>({...E,adminLogs:[...E.adminLogs.slice(-199),k]}))}function S(k=null){const E=k&&typeof k=="object"?k:null,B=E?.debug?.status&&typeof E.debug.status=="object"?E.debug.status:null;p(X=>({...X,llmCommentaryState:E,llmCommentaryStatus:B}))}function w(k={}){p(E=>({...E,alerts:[...E.alerts.slice(-49),{...k,receivedAt:Date.now()}]}))}function j(k=null){const E=k&&typeof k=="object"?k:null;p(B=>({...B,overseerControlState:E}))}function R(k=null){const E=k&&typeof k=="object"?k:null;p(B=>({...B,neatoLidar:E}))}return s.on("session:sync",v),s.on("neato:lidar",R),s.on("log:init",y),s.on("log:entry",N),s.on("adminlog:init",M),s.on("adminlog:entry",C),s.on("llm:state",S),s.on("overseer:state",j),s.on("alert:new",w),()=>{s.off("session:sync",v),s.off("neato:lidar",R),s.off("log:init",y),s.off("log:entry",N),s.off("adminlog:init",M),s.off("adminlog:entry",C),s.off("llm:state",S),s.off("overseer:state",j),s.off("alert:new",w)}},[p,s]);const x=m.useMemo(()=>({login:(v,y)=>r("auth:login",{username:v,password:y}),identifySession:({cookieUserId:v,nickname:y}={})=>r("session:identify",{cookieUserId:v,nickname:y}),setRole:v=>r("session:setRole",{role:v}),requestControl:(v,y={})=>r("session:requestControl",{roverId:v,...y}),releaseControl:v=>r("session:releaseControl",{roverId:v}),subscribeAll:()=>r("session:subscribeAll"),lockRover:(v,y)=>r("session:lockRover",{roverId:v,locked:y}),setMode:v=>r("setMode",{mode:v}),homeAssistantToggle:v=>r("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,y)=>r("homeAssistant:setState",{entityId:v,state:y}),homeAssistantSetLightColor:(v,y)=>r("homeAssistant:lightColor",{entityId:v,rgbColor:y}),homeAssistantSetLightWhite:v=>r("homeAssistant:lightWhite",{entityId:v}),neatoStart:()=>r("neato:start"),neatoSendHome:()=>r("neato:sendHome"),neatoLocate:()=>r("neato:locate"),neatoClearErrors:()=>r("neato:clearErrors"),neatoPowerCycle:()=>r("neato:powerCycle"),liftUp:()=>r("lift:up"),liftDown:()=>r("lift:down"),setNickname:v=>r("nickname:set",{nickname:v}),requestVerification:()=>r("verification:request"),requestPrivateRoverAccess:v=>r("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[],y="")=>v&&typeof v=="object"&&!Array.isArray(v)?r("replay:trigger",v):r("replay:trigger",{sources:v,title:y}),setGlobalObjective:v=>r("globalObjective:set",{text:v}),setAdminReason:v=>r("adminReason:set",{text:v}),rebootRover:v=>r("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>r("server:reboot"),playUploadedAudio:({roverId:v,name:y,mime:N,dataBase64:M})=>r("audio:uploadPlay",{roverId:v,name:y,mime:N,dataBase64:M}),stopUploadedAudio:v=>r("audio:uploadStop",{roverId:v}),startMicWhip:v=>r("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>r("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>r("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>r("audioLevels:set",v),setPrivateSafety:(v,y={})=>r("session:privateSafety:set",{roverId:v,safety:y}),llmControl:(v,y={})=>r("llm:control",{controls:{action:v,...y}}),overseerControl:(v,y={})=>r("overseer:control",{controls:{action:v,...y}}),pushAlert:v=>p(y=>({...y,alerts:[...y.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[r,p]),g=m.useMemo(()=>({getState:f,subscribe:h,actions:x}),[x,f,h]);return l.jsx(ef.Provider,{value:g,children:n})}function pe(n,s=Object.is){const r=m.useContext(ef);if(!r)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const u=m.useRef(s);u.current=s;const[f,p]=m.useState(()=>n(r.getState()));return m.useEffect(()=>(p(h=>{const x=o.current(r.getState());return u.current(h,x)?h:x}),r.subscribe(h=>o.current(h),h=>{p(x=>u.current(x,h)?x:h)},(h,x)=>u.current(h,x))),[r]),f}function Xt(){const n=m.useContext(ef);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function kr(){const n=pe(r=>r),s=Xt();return m.useMemo(()=>({...n,...s}),[s,n])}const WS=Object.freeze({}),Td=null,tf=m.createContext(null);function ej({children:n}){const s=sn(),r=m.useRef({}),o=m.useRef(new Map),u=m.useRef(new Set),f=h=>{const x=o.current.get(h);x&&x.forEach(g=>g()),u.current.forEach(g=>g())},p=m.useMemo(()=>({getFrames:()=>r.current,getFrame:h=>h?r.current[h]??Td:Td,subscribeAll:h=>(u.current.add(h),()=>{u.current.delete(h)}),subscribeRover:(h,x)=>{if(!h)return()=>{};let g=o.current.get(h);return g||(g=new Set,o.current.set(h,g)),g.add(x),()=>{const v=o.current.get(h);v&&(v.delete(x),v.size||o.current.delete(h))}}}),[]);return m.useEffect(()=>{function h({roverId:x,sensors:g={},frame:v={}}){x&&(r.current={...r.current,[x]:{roverId:x,sensors:g,raw:v?.data||null,receivedAt:Date.now()}},f(x))}return s.on("sensorFrame",h),()=>{s.off("sensorFrame",h)}},[s]),l.jsx(tf.Provider,{value:p,children:n})}function og(){const n=m.useContext(tf);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>WS)}function fl(n){const s=m.useContext(tf);if(!s)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(r=>s.subscribeRover(n,r),()=>s.getFrame(n),()=>Td)}const tj=650,nj={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 sd(n){if(typeof n!="number"||n<=0)return null;const s=nj[n];return s?{code:n,...s}:null}function aj(n,s={}){const r=s.holdMs||tj,[o,u]=m.useState({left:null,right:null,omni:null}),[f,p]=m.useState(0);return m.useEffect(()=>{const h=setInterval(()=>p(Date.now()),Math.max(r/2,100));return()=>clearInterval(h)},[r]),m.useEffect(()=>{const h=Date.now(),x=sd(n?.infraredCharacterLeft),g=sd(n?.infraredCharacterRight),v=sd(n?.infraredCharacterOmni);!x&&!g&&!v||u(y=>({left:x?{...x,ts:h}:y.left,right:g?{...g,ts:h}:y.right,omni:v?{...v,ts:h}:y.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const h=Date.now(),x=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const j=h-w.ts,R=j<=r;return{active:R,age:j,code:w.code,red:!!(w.red&&R),green:!!(w.green&&R),force:!!(w.force&&R)}},g=x(o.left),v=x(o.right),y=x(o.omni),N=g.force||v.force||y.force,M=g.active||v.active||y.active,C=g.active&&!v.active?"right":v.active&&!g.active?"left":"center",S=(v.active?1:0)-(g.active?1:0);return{visible:M,forceDetected:N,left:g,right:v,omni:y,bias:C,balance:Math.max(-1,Math.min(1,S))}},[o.left,o.right,o.omni,r,f])}function sj(){pe(M=>M.connected);const n=pe(M=>M.session?.assignment?.roverId??null),s=pe(M=>{const C=M.session?.assignment?.roverId;return C&&M.session?.activeDrivers?.[C]||null}),r=pe(M=>M.session?.socketId||null),o=pe(M=>M.session?.users??[]),u=fl(n),f=u?.sensors||{},p=aj(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,x=f.currentMa!=null?`${f.currentMa} mA`:null,g=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,v=f.batteryChargeMah,y=f.batteryCapacityMah;u?.receivedAt&&new Date(u.receivedAt).toLocaleTimeString();const N=u?.raw?u.raw:null;return m.useMemo(()=>n?s?s===r?"You":o.find(C=>C.socketId===s)?.nickname||s.slice(0,6):"Available":"n/a",[s,n,r,o]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[n?u?l.jsxs(l.Fragment,{children:[l.jsx(lj,{sensors:f,voltage:h,current:x,batteryTemp:g,charge:v,capacity:y}),l.jsx(rj,{sensors:f,dockState:p})]}):l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):l.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),N&&l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:N})]})}function lj({sensors:n,voltage:s,current:r,batteryTemp:o,charge:u,capacity:f}){const p=u!=null&&f?`${Math.round(u/f*100)}`:"--",h=n?.oiMode?.label||"--",x=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[l.jsx(ta,{label:"Voltage",value:s??"--"}),l.jsx(ta,{label:"Current",value:r??"--"}),l.jsx(ta,{label:"Battery temp",value:o??"--"}),l.jsx(ta,{label:"Charge",value:u!=null?`${u} mAh`:"--"}),l.jsx(ta,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),l.jsx(ta,{label:"Charge",value:p}),l.jsx(ta,{label:"OI mode",value:h}),l.jsx(ta,{label:"Docked",value:x}),l.jsx(ta,{label:"Charging state",value:g})]})}function ta({label:n,value:s}){return l.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[l.jsx("span",{className:"text-slate-400",children:n}),l.jsx("span",{className:"text-slate-100",children:s})]})}function rj({sensors:n,dockState:s}){const r=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},u=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],f=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],p=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs(Ps,{title:"Dock IR",children:[l.jsx(ij,{sensors:n}),l.jsx(oj,{state:s})]}),l.jsxs(Ps,{title:"Bumps & drops",children:[l.jsx(na,{label:"Bump L",value:l.jsx(rr,{active:r.bumpLeft})}),l.jsx(na,{label:"Bump R",value:l.jsx(rr,{active:r.bumpRight})}),l.jsx(na,{label:"Wheel drop L",value:l.jsx(rr,{active:r.wheelDropLeft,tone:"amber"})}),l.jsx(na,{label:"Wheel drop R",value:l.jsx(rr,{active:r.wheelDropRight,tone:"amber"})})]}),l.jsx(Ps,{title:"Light bumps (raw)",children:u.map(h=>l.jsx(na,{label:h.label,value:ir(h.value)},h.label))}),l.jsx(Ps,{title:"Cliff sensors",children:f.map(h=>l.jsx(na,{label:h.label,value:`${ir(h.value)} · ${h.active?"bool: true":"bool: false"}`},h.label))}),l.jsx(Ps,{title:"Currents",children:p.map(h=>l.jsx(na,{label:h.label,value:l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:ir(h.value,"mA")}),h.over?l.jsx(rr,{active:!0,tone:"red",label:"over"}):null]})},h.label))}),l.jsxs(Ps,{title:"Dirt detect",children:[l.jsx(na,{label:"Left",value:ir(n?.dirtDetectLeft)}),l.jsx(na,{label:"Right",value:ir(n?.dirtDetect)})]})]})}function Ps({title:n,children:s}){return l.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[l.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),l.jsx("div",{className:"space-y-0.5",children:s})]})}function na({label:n,value:s}){return l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-300",children:n}),l.jsx("span",{className:"text-slate-100",children:s})]})}function rr({active:n,tone:s="green",label:r}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",u=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return l.jsx("span",{className:`${o} ${u}`,children:r||(n?"true":"false")})}function ir(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function ij({sensors:n}){const s=n?.infraredCharacterLeft,r=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,u=f=>l.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${f?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:f||"--"});return l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"L"}),u(s)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"O"}),u(o)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"R"}),u(r)]})]})}function oj({state:n}){if(!n)return null;const s=o=>{const u=[];return o?.red&&u.push("R"),o?.green&&u.push("G"),o?.force&&u.push("F"),u.length?u.join(""):"none"},r=o=>o?.age!=null?`${o.age}ms`:"--";return l.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Left: ${n.left.code??"--"} (${s(n.left)}) · age ${r(n.left)}`}),l.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${r(n.omni)}`}),l.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${r(n.right)}`})]})}const cg=m.createContext(null);function cj({children:n}){const[s,r]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const h=qd();r({status:"ready",data:h??{}})},[]);const o=m.useCallback(()=>{const h=qd();r({status:"ready",data:h??{}})},[]),u=m.useCallback(h=>{const x=Bp(h??{});return r(x?{status:"ready",data:h??{}}:g=>({...g,status:"error"})),x},[]),f=m.useCallback((h,x)=>{r(g=>{const v=g.data[h]||{},y=typeof x=="function"?x(v):{...v,...x??{}},N={...g.data,[h]:y};return Bp(N)?{status:"ready",data:N}:{...g,status:"error"}})},[]),p=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:u,setNamespace:f}),[s,o,u,f]);return l.jsx(cg.Provider,{value:p,children:n})}function uj(){const n=m.useContext(cg);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Qe(n,s={}){const{data:r,status:o,setNamespace:u}=uj(),f=r[n]??s??{},p=m.useCallback(g=>{u(n,v=>{const y=v??{};return typeof g=="function"?g(y):{...y,...g??{}}})},[n,u]),h=m.useCallback(g=>{u(n,()=>g??{})},[n,u]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;u(n,()=>g??{})},[s,n,u]);return{value:f,status:o,save:p,replace:h,reset:x}}const dj=/^#[0-9A-Fa-f]{6}$/;function nf(n){const s=typeof n=="string"?n.trim():"";return!s||!dj.test(s)?null:s.toUpperCase()}function ia(n,s=.2){const r=nf(n);if(!r)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,u=ug(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.65)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function fj(n,s=.2){const r=nf(n);if(!r)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,u=ug(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.55)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function ug(n){const s=nf(n);return s?{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16)}:null}function mj(n=[]){return n.map(s=>!s?.type||!s?.id?null:{type:s.type,id:String(s.id),label:s.label||String(s.id),color:s.color||null,key:`${s.type}:${s.id}`}).filter(Boolean)}function af({panelId:n="replay-sources",fillHeight:s=!1}){const r=pe(q=>q.session?.replaySources??[]),o=pe(q=>q.session?.mode||null),u=pe(q=>q.session?.assignment?.roverId??null),f=pe(q=>q.session?.users??[]),p=pe(q=>q.session?.socketId||null),h=pe(q=>q.session?.roster??[]),x=pe(q=>q.session?.replay||null),{triggerReplay:g}=Xt(),v=mj(r||[]),{value:y,save:N}=Qe("replaySources",{}),[M,C]=m.useState([]),[S,w]=m.useState(!1),[j,R]=m.useState(null),[k,E]=m.useState(null),[B,X]=m.useState(""),[L,z]=m.useState(!1),[K,V]=m.useState(!0),[F,W]=m.useState(0),ie=m.useMemo(()=>{const q=u;return q?[`rover:${q}`]:[]},[u]),oe=m.useMemo(()=>{const _=((Array.isArray(f)?f.find(me=>me?.socketId===p):null)?.nickname||"Someone").trim()||"Someone",I=u||null,ne=I&&Array.isArray(h)?h.find(me=>String(me?.id)===String(I))?.name||I:"a rover";return`${_} driving ${ne}`},[f,p,u,h]);m.useEffect(()=>{const q=y?.[n];if(Array.isArray(q)&&q.length){C(q);return}C(ie)},[y?.[n],ie,n]),m.useEffect(()=>{const q=y?.[`${n}:includeSidebar`];if(typeof q=="boolean"){V(q);return}V(!0)},[y?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{L||X(oe)},[oe,L]),m.useEffect(()=>{const q=new Set(v.map(_=>_.key));C(_=>_.filter(I=>q.has(I)))},[v]);const $=m.useMemo(()=>({rovers:v.filter(q=>q.type==="rover"),rooms:v.filter(q=>q.type==="room")}),[v]);m.useEffect(()=>{if(!x?.lastTriggeredAt||!x?.cooldownMs){W(0);return}const q=()=>{const I=x.lastTriggeredAt+x.cooldownMs-Date.now();W(Math.max(0,I))};q();const _=setInterval(q,250);return()=>clearInterval(_)},[x?.lastTriggeredAt,x?.cooldownMs,x?.remainingMs]);const T=S||o==="lockdown"||F>0||!M.length,H=q=>{C(_=>{const I=_.includes(q)?_.filter(ne=>ne!==q):[..._,q];return N(ne=>({...ne||{},[n]:I})),I}),E(null)},J=async()=>{if(!T){w(!0),R(null),E(null);try{const q=M.map(I=>{const[ne,me]=I.split(":");return{type:ne,id:me}}),_=String(B||"").trim()||oe;await g({sources:q,title:_,includeSidebar:K}),E("Replay sent. Check the Discord replay channel.")}catch(q){R(q.message)}finally{w(!1)}}},te=s?"h-full flex flex-col":"",ue=s?"flex-1 min-h-0 overflow-y-auto":"";return l.jsxs("section",{className:`panel-section p-0.75 text-sm ${te}`,children:[l.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[l.jsx("span",{children:"Replay Sources"}),l.jsx("span",{children:v.length})]}),l.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${ue}`,children:[l.jsx(Lp,{title:"Rovers",items:$.rovers,selected:M,onToggle:H}),l.jsx(Lp,{title:"Room Cams",items:$.rooms,selected:M,onToggle:H})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),l.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:B,onChange:q=>{X(q.target.value),z(!0)},placeholder:oe,maxLength:120}),l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:K,onChange:q=>{const _=!!q.target.checked;V(_),N(I=>({...I||{},[`${n}:includeSidebar`]:_}))},className:"accent-emerald-400"}),l.jsx("span",{children:"Include replay sidebar"})]}),l.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:J,disabled:T,children:F>0?`Replay (${Math.ceil(F/1e3)}s)`:S?"Replay…":"Replay"}),j?l.jsx("div",{className:"text-xs text-amber-400",children:j}):null,k?l.jsx("div",{className:"text-xs text-emerald-300",children:k}):null]})]})}function Lp({title:n,items:s,selected:r,onToggle:o}){return s.length?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs",children:n}),l.jsx("div",{className:"space-y-0.5",children:s.map(u=>l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:r.includes(u.key),onChange:()=>o(u.key),className:"accent-emerald-400"}),l.jsx("span",{className:`truncate ${u.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:u.type==="rover"?ia(u.color,.16):void 0,children:u.label})]},u.key))})]}):null}var dg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},zp=an.createContext&&an.createContext(dg),hj=["attr","size","title"];function pj(n,s){if(n==null)return{};var r=xj(n,s),o,u;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(u=0;u<f.length;u++)o=f[u],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(r[o]=n[o])}return r}function xj(n,s){if(n==null)return{};var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;r[o]=n[o]}return r}function po(){return po=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}return n},po.apply(this,arguments)}function Up(n,s){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(n,u).enumerable})),r.push.apply(r,o)}return r}function xo(n){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Up(Object(r),!0).forEach(function(o){gj(n,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Up(Object(r)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(r,o))})}return n}function gj(n,s,r){return s=vj(s),s in n?Object.defineProperty(n,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[s]=r,n}function vj(n){var s=bj(n,"string");return typeof s=="symbol"?s:s+""}function bj(n,s){if(typeof n!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var o=r.call(n,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function fg(n){return n&&n.map((s,r)=>an.createElement(s.tag,xo({key:r},s.attr),fg(s.child)))}function Mr(n){return s=>an.createElement(yj,po({attr:xo({},n.attr)},s),fg(n.child))}function yj(n){var s=r=>{var{attr:o,size:u,title:f}=n,p=pj(n,hj),h=u||r.size||"1em",x;return r.className&&(x=r.className),n.className&&(x=(x?x+" ":"")+n.className),an.createElement("svg",po({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,o,p,{className:x,style:xo(xo({color:n.color||r.color},r.style),n.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),f&&an.createElement("title",null,f),n.children)};return zp!==void 0?an.createElement(zp.Consumer,null,r=>s(r)):s(dg)}function mg(n){return Mr({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:[]}]})(n)}function Sj(n){return Mr({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:[]}]})(n)}function Hp(n){return Mr({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:[]}]})(n)}function jj(n){return Mr({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:[]}]})(n)}function Nj(n){return Mr({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:[]}]})(n)}function wj(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function sf(n){return!!n?.system}function Aj(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function Vp(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Cj({guildIconUrl:n,userAvatarUrl:s,label:r}){return!n&&!s?null:l.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:r,children:[l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function hg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${Vp(n)}`:null,r=sf(n),o=r?"text-emerald-300":wj(n.role);return l.jsxs(l.Fragment,{children:[n.fromDiscord?l.jsxs(l.Fragment,{children:[l.jsx(mg,{className:"h-3.5 w-3.5 text-indigo-200"}),l.jsx(Cj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,l.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:Vp(n)}),r?l.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:fj(n.roverColor,.14),children:n.roverId})]})}function pg(n){return sf(n)?"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 ${n.role==="admin"||n.role==="lockdown"||n.role==="lockdown-admin"?"border border-amber-400/30":n.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function lf({message:n}){const s=sf(n);return l.jsxs("div",{className:pg(n),children:[l.jsx(hg,{message:n}),l.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${s?"text-emerald-100":"text-slate-100"}`,children:n.text}),l.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:Aj(n.ts)})]})}function xg({message:n}){return l.jsxs("div",{className:`${pg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[l.jsx(hg,{message:n}),l.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function gg({buttonId:n,count:s,goal:r,rewardNumber:o,rewardName:u,className:f=""}){return l.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",f].filter(Boolean).join(" "),children:[l.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),l.jsxs("p",{className:"text-sm font-semibold text-white",children:[s," / ",r]}),l.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",u]})]})}const Ej=3e3,kj=3500,Mj="#2196f3";function Rj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function rf({scale:n=1}){const s=pe(N=>N.alerts),r=pe(N=>N.session?.buttonBox?.buttons??[]),{pushAlert:o}=Xt(),u=sn(),[f,p]=m.useState(()=>Date.now());m.useEffect(()=>{function N(M={}){const C=Number(M.buttonId);if(!Number.isFinite(C)||C<1||C>4)return;const w=(Array.isArray(r)?r:[]).find(B=>Number(B?.id)===C)||{},j=Number.isFinite(M.count)?M.count:Number(w.count)||0,R=Number.isFinite(w.goal)?w.goal:0,k=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",E=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${C}`,kind:"buttonbox-active",lifetimeMs:kj,payload:{buttonId:C,count:j,goal:R,rewardNumber:k,rewardName:E}})}return u.on("buttonBox:increment",N),()=>{u.off("buttonBox:increment",N)}},[o,r,u]);const h=m.useMemo(()=>s.slice(-12).map(N=>({alert:N,key:Rj(N)})),[s]);m.useEffect(()=>{if(!h.length)return;const N=setInterval(()=>p(Date.now()),200);return()=>clearInterval(N)},[h.length]);const x=new Map;h.forEach(N=>{const M=f-(N.alert.receivedAt??N.alert.timestamp??0),C=Number.isFinite(N.alert.lifetimeMs)?N.alert.lifetimeMs:Ej;M<=C&&x.set(N.key,{...N,age:M})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},y=n===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 l.jsx("div",{className:y,style:v,children:g.map(N=>l.jsx(qj,{alert:N.alert},N.key))})}function $p(n){const s=typeof n=="string"?n.trim():"",r=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!r)return null;const o=r[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function qj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const u=n.payload;return l.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:l.jsx(gg,{buttonId:u.buttonId,count:u.count,goal:u.goal,rewardNumber:u.rewardNumber,rewardName:u.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return l.jsx(lf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return l.jsx(xg,{message:n.payload});const s=$p(n.color)||$p(Mj),r=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return l.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:r,border:`1px solid ${o}`},children:l.jsxs("p",{className:"truncate text-slate-100",children:[l.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),l.jsx("span",{className:"text-slate-500",children:" · "}),l.jsx("span",{className:"text-white",children:n.message})]})})}const Ws={main:[-127,127],side:[-127,127],vacuum:[0,127]},ld={maxSpeed:500,baseSpeed:250,boostSpeed:400},Dd=100,of=[31,127],ll=60,_d=8,Tj=250,Dj=4e3,Zi=.4,Gp=.2,Yp=.8,_j={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},mr={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"],micPtt:["m"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},vg=[{id:"drive-sequence",label:"Drive",description:"Start, undock, and full command sequence used by the drive button.",steps:[{type:"servo",angle:0},{type:"oi",command:"start"},{type:"pause",duration:Dd},{type:"oi",command:"dock"},{type:"pause",duration:Dd},{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 Od(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Bd(){return{main:0,side:0,vacuum:0}}function Oj(){return{enabled:!1,angle:null,config:null}}function uo(){return{note:ll}}function dr(){return{active:!1,heat:0,overheated:!1}}function fo(){return{pttActive:!1}}const Fp={roverId:null,mode:"drive",drive:Od(),aux:Bd(),camera:Oj(),song:uo(),horn:dr(),mic:fo(),lastControlIntentAt:0,macros:vg,keymap:mr,inputs:{}};function Bj(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Od(),aux:s.payload?n.aux:Bd(),song:s.payload?n.song:uo(),horn:s.payload?n.horn:dr(),mic:s.payload?n.mic:fo(),lastControlIntentAt:s.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===s.payload?n:{...n,mode:s.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:r,speeds:o,source:u}=s.payload;return{...n,drive:{vector:r??n.drive.vector,speeds:o??n.drive.speeds,source:u??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...s.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!s.payload?.config,config:s.payload?.config??null,angle:typeof s.payload?.angle=="number"?s.payload.angle:s.payload?.config?s.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:s.payload}};case"control/register-input-state":{const r=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[r]:{...n.inputs[r]??{},...s.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...s.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(s.payload)?s.payload:n.macros};case"control/reset":return{...n,drive:Od(),aux:Bd(),song:uo(),horn:dr(),mic:fo(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||dr(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||dr(),heat:typeof s.payload?.heat=="number"?s.payload.heat:0,overheated:!!s.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||uo(),note:s.payload??ll}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||fo(),pttActive:!!s.payload}};default:return n}}function rl(n,s,r){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(r,n))}function il(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function gn(n,s){return!Array.isArray(s)||s.length!==2?n:rl(n,s[0],s[1])}function Lj(n={}){const s=il(n.x??0),r=il(n.y??0);return{x:s,y:r,boost:!!n.boost}}function zj(n={},s={}){const r=Lj(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:ld.maxSpeed,u=typeof s.baseSpeed=="number"?s.baseSpeed:ld.baseSpeed,f=typeof s.boostSpeed=="number"?s.boostSpeed:ld.boostSpeed,p=r.boost?f:u,h=r.y*p,x=r.x*p;return{vector:r,speeds:{left:rl(Math.round(h+x),-o,o),right:rl(Math.round(h-x),-o,o)}}}function Uj(n){const s=Array.isArray(n)?n:[],r=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(r);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function Xp(n){return new Promise(s=>setTimeout(s,n))}function Hj(n={}){const{driveTransform:s,auxTransform:r}=n,o=sn(),u=pe(B=>B.session?.assignment?.roverId??null),f=pe(B=>B.session?.roster??[]),p=m.useMemo(()=>!u||!Array.isArray(f)?null:f.find(B=>String(B.id)===String(u))||null,[u,f]),h=m.useMemo(()=>!p?.cameraServo||!p.cameraServo.enabled?null:p.cameraServo,[p]),x=m.useMemo(()=>!p?.nightVision||!p.nightVision.enabled?null:p.nightVision,[p]),g=m.useMemo(()=>!p?.horn||!p.horn.enabled?null:p.horn,[p]),v=m.useMemo(()=>p?.nightVision?.state??null,[p]),y=m.useCallback((B,X)=>{u&&o.emit("command",{roverId:u,...B},X)},[o,u]),N=m.useCallback(()=>{u&&y({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[y,u]),M=m.useCallback(B=>{if(!u)return null;const X={left:gn(B?.left??0,[-500,500]),right:gn(B?.right??0,[-500,500])},L=s?s(X):X,z={left:gn(L?.left??0,[-500,500]),right:gn(L?.right??0,[-500,500])};return y({type:"drive",data:{driveDirect:z}}),z},[s,y,u]),C=m.useCallback(({main:B=0,side:X=0,vacuum:L=0}={})=>{if(!u)return null;const z={main:gn(B,Ws.main),side:gn(X,Ws.side),vacuum:gn(L,Ws.vacuum)},K=r?r(z):z,V={main:gn(K?.main??0,Ws.main),side:gn(K?.side??0,Ws.side),vacuum:gn(K?.vacuum??0,Ws.vacuum)};return y({type:"motors",data:{motorPwm:V}}),V},[r,y,u]),S=m.useCallback(B=>!u||!h?null:(y({type:"servo",data:{servo:{angle:B}}}),B),[y,u,h]),w=m.useCallback(B=>{if(!u)return!1;const X=Array.isArray(B)?B:typeof B=="string"?_j[B]:null;return X?(y({type:"raw",data:{raw:Uj(X)}}),N(),!0):!1},[y,N,u]),j=m.useCallback(async B=>{if(!(!B||!Array.isArray(B.steps)||!u))for(const X of B.steps){if(!u)break;switch(X.type){case"oi":w(X.command);break;case"drive":M(X.speeds??{left:0,right:0});break;case"motors":C(X.values??{});break;case"servo":S(X.angle);break;case"pause":await Xp(X.duration??Dd);break}if(X.delay||X.delayMs){const L=X.delayMs??X.delay;typeof L=="number"&&L>0&&await Xp(L)}}},[u,w,M,C,S]),R=m.useCallback((B="toggle")=>!u||!x?null:(y({type:"nightVision",data:{nightVision:{action:B}}}),B),[y,x,u]),k=m.useCallback(B=>u?(y({type:"horn",data:{horn:B}}),B):null,[y,u]),E=m.useCallback((B=[],X={})=>{if(!u)return null;const z=(Array.isArray(B)&&B.length>0?B:[{note:ll,duration:_d}]).slice(0,16).map(K=>({note:gn(Math.round(K?.note??ll),of),duration:gn(Math.round(K?.duration??_d),[1,255])}));return y({type:"song",data:{song:{notes:z,slot:X.slot,loop:X.loop}}}),z},[y,u]);return m.useMemo(()=>({roverId:u,rosterEntry:p,servoConfig:h,nightVision:x,nightVisionState:v,horn:g,emitCommand:y,enableSensorStream:N,sendDriveDirect:M,sendAuxMotors:C,sendServoAngle:S,sendOiCommand:w,sendNightVision:R,sendHorn:k,sendSong:E,runMacroSteps:j}),[u,p,h,x,v,g,y,N,M,C,S,w,R,k,j])}const Vj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Qp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Rr(n){if(typeof n!="string")return"";const s=n.toLowerCase();return Vj[s]??s}function $j(n){const s=Rr(n);if(!s)return null;if(Qp[s])return Qp[s];if(s.length===1){if(/[a-z]/.test(s))return`Key${s.toUpperCase()}`;if(/[0-9]/.test(s))return`Digit${s}`}return null}function bg(n){const s=Rr(n);return s?`key:${s}`:null}function Gj(n){const s=$j(n);return s?`code:${s}`:null}function Kp(n){const s=new Set,r=bg(n?.key??"");r&&s.add(r);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function Yj(n={}){return Object.fromEntries(Object.entries(n).map(([s,r])=>{const o=Array.isArray(r)?r:[r],u=new Set;return o.forEach(f=>{const p=bg(String(f));p&&u.add(p);const h=Gj(String(f));h&&u.add(h)}),[s,u]}))}function An(n){const s=Rr(n);return s?s===" "?"Space":s==="\\"?"Backslash":s==="`"?"Backtick":s==="["?"[ or {":s==="]"?"] or }":s===";"?"; or :":s==="'"?`' or "`:s===","?", or <":s==="."?". or >":s==="/"?"/ or ?":s==="-"?"- or _":s==="="?"= or +":s==="arrowup"?"Arrow Up":s==="arrowdown"?"Arrow Down":s==="arrowleft"?"Arrow Left":s==="arrowright"?"Arrow Right":s.length===1?s.toUpperCase():s:"—"}const Dn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:100,tiltIntervalMs:110}},sa={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}]}}},_a={activeSignature:null,profiles:{},defaults:{profile:sa}},cs={waveform:"saw",freqs:[440,550,660,0]},ut={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},is=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Fj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Zp(){return is.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function Ip(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Xj(n,s={}){const r=pe(j=>j.session?.role||null),f=(fl(n)?.sensors||{})?.wheelOvercurrents||{},p=m.useMemo(()=>({...Fj,...s.config||{}}),[s.config]),[h,x]=m.useState(()=>Zp()),g=m.useRef(0),v=m.useRef(f);m.useEffect(()=>{v.current=f||{}},[f]),m.useEffect(()=>{x(Zp()),g.current=0},[n]);const y=m.useMemo(()=>is.some(j=>j.motors.some(R=>!!f?.[R])),[f]),N=m.useMemo(()=>Object.values(h||{}).some(j=>(Number.isFinite(j?.cap)?j.cap:1)<.999),[h]),M=!!n&&(y||N);m.useEffect(()=>{if(!M)return;g.current=typeof performance<"u"?performance.now():Date.now();const j=setInterval(()=>{const R=typeof performance<"u"?performance.now():Date.now(),k=Math.max(0,R-g.current);g.current=R;const E=Math.min(.25,k/1e3);E<=0||x(B=>{let X=!1;const L={},z=Number.isFinite(p.downRatePerSec)?Math.max(0,p.downRatePerSec):0,K=Number.isFinite(p.upRatePerSec)?Math.max(0,p.upRatePerSec):0,V=Number.isFinite(p.releaseDelaySec)?Math.max(0,p.releaseDelaySec):0;return is.forEach(F=>{const W=B[F.key]||{cap:1,clearSec:0},ie=Number.isFinite(W.cap)?W.cap:1,oe=Number.isFinite(W.clearSec)?W.clearSec:0,$=F.motors.some(te=>!!v.current?.[te]),T=$?0:oe+E,H=!$&&T>=V,J=Ip($?ie-z*E:H?ie+K*E:ie);(Math.abs(J-ie)>1e-4||Math.abs(T-oe)>1e-4)&&(X=!0),L[F.key]={cap:J,clearSec:T}}),X?L:B})},100);return()=>clearInterval(j)},[p.downRatePerSec,p.releaseDelaySec,p.upRatePerSec,n,M]);const C=m.useMemo(()=>{const j=is.reduce((R,k)=>{const E=h?.[k.key],B=Number.isFinite(E?.cap)?E.cap:1;return R[k.key]=Ip(B),R},{});return{perGroup:j,drive:{left:j.drive??1,right:j.drive??1},aux:{main:j.aux??1,side:j.aux??1,vacuum:1}}},[h]),S=m.useMemo(()=>{const j={};is.forEach(k=>{k.motors.forEach(E=>{j[E]=!!f?.[E]})});const R=is.reduce((k,E)=>(k[E.key]=E.motors.some(B=>!!f?.[B]),k),{});return{motors:j,groups:R}},[f]),w=r==="admin"||r==="lockdown"||r==="lockdown-admin";return m.useMemo(()=>({caps:h,overcurrent:S,scales:C,isActive:(C?.drive?.left??1)<1||(C?.drive?.right??1)<1||(C?.aux?.main??1)<1||(C?.aux?.side??1)<1,config:p,adminImmune:w}),[h,S,C,p,w])}function Qj(n={},s,r=!1){if(r||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,u=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&u>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*u)}}function Kj(n={},s,r=!1){if(r||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,u=typeof s.aux.side=="number"?s.aux.side:1,f=typeof s.aux.vacuum=="number"?s.aux.vacuum:1;return o>=.999&&u>=.999&&f>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*u),vacuum:Math.round((n.vacuum??0)*f)}}const yg=m.createContext(null);function Jp(n){return Object.fromEntries(Object.entries(n||{}).map(([s,r])=>[s,Array.isArray(r)?[...r]:[]]))}function Zj(n,s){if(!n)return s;const r=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return rl(s,r,o)}function Ij(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[r,o,u]=s,f=r?.type==="drive"&&Number(r?.speeds?.left)===-300&&Number(r?.speeds?.right)===-300,p=o?.type==="pause"&&Number(o?.duration)===600,h=u?.type==="drive"&&Number(u?.speeds?.left)===0&&Number(u?.speeds?.right)===0;return!f||!p||!h?n:n.slice(0,-3)}function Jj({children:n}){const[s,r]=m.useReducer(Bj,Fp),o=m.useRef(null),u=m.useRef(!1),f=m.useRef(Fp.camera.angle),p=m.useRef(null),h=m.useRef(0),x=m.useRef(0),{value:g,save:v}=Qe("controls",{keymap:mr,macros:vg}),{value:y}=Qe("page",{driveMacroBackoffEnabled:!0}),{value:N}=Qe("horn",cs),M=typeof y?.driveMacroBackoffEnabled=="boolean"?y.driveMacroBackoffEnabled:!0,C=pe(re=>re.session?.assignment?.roverId??null),S=pe(re=>re.session?.homeAssistant?.entities??[]),{homeAssistantSetState:w}=Xt(),j=Xj(C),R=m.useCallback(re=>Qj(re,j.scales,j.adminImmune),[j.adminImmune,j.scales]),k=m.useCallback(re=>Kj(re,j.scales,j.adminImmune),[j.adminImmune,j.scales]),E=Hj({driveTransform:R,auxTransform:k}),B=m.useCallback(()=>{const xe=(S||[]).filter(Ee=>(Ee.type==="light"||Ee.type==="switch")&&Ee.available!==!1&&Ee.state!=="on");if(xe.length===0){u.current=!1;return}u.current=!0,xe.forEach(Ee=>{w(Ee.id,"on").catch(()=>{})}),u.current=!1},[S,w]);m.useEffect(()=>{r({type:"control/set-rover",payload:E.roverId})},[E.roverId]),m.useEffect(()=>{const re=o.current;o.current=s.mode,re!=="drive"&&s.mode==="drive"&&S?.length?B():re!=="drive"&&s.mode==="drive"&&(u.current=!0)},[s.mode,S,B]),m.useEffect(()=>{u.current&&S?.length&&B()},[S,B]),m.useEffect(()=>{const re={...mr,...g?.keymap||{}};r({type:"control/set-keymap",payload:re}),g?.macros&&r({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const re=E.servoConfig;if(!re){r({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const xe=typeof re.minAngle=="number"?re.minAngle:-45,Ee=typeof re.maxAngle=="number"?re.maxAngle:45,fe=typeof re.homeAngle=="number"?re.homeAngle:(xe+Ee)/2,we=typeof f.current=="number"?rl(f.current,xe,Ee):null,Ae=we??rl(fe,xe,Ee);r({type:"control/set-camera-config",payload:{config:re,angle:Ae}}),f.current=Ae},[E.servoConfig]),m.useEffect(()=>{f.current=typeof s.camera.angle=="number"?s.camera.angle:f.current},[s.camera.angle]),m.useEffect(()=>{E.roverId&&E.enableSensorStream()},[E.roverId,E.enableSensorStream]);const X=m.useCallback(re=>{r({type:"control/set-mode",payload:re})},[]),L=m.useCallback(()=>{r({type:"control/record-intent"})},[]),z=m.useRef(s.drive.speeds),K=m.useRef(s.aux),V=m.useMemo(()=>JSON.stringify(j.scales),[j.scales]),F=m.useRef(0),W=m.useRef(0);m.useEffect(()=>{z.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{K.current=s.aux},[s.aux]),m.useEffect(()=>{if(!E.roverId||j.adminImmune||!j.isActive)return;const re=Math.max(0,Number(j?.config?.outputRateMs)||0),xe=typeof performance<"u"?performance.now():Date.now(),Ee=z.current||{left:0,right:0},fe=K.current||{main:0,side:0,vacuum:0},we=!!(Ee.left||Ee.right),Ae=!!(fe.main||fe.side||fe.vacuum);!we&&!Ae||(we&&xe-F.current>=re&&(F.current=xe,E.sendDriveDirect(Ee)),Ae&&xe-W.current>=re&&(W.current=xe,E.sendAuxMotors(fe)))},[V,j.adminImmune,j.config,j.isActive,E]);const ie=m.useCallback((re,xe={})=>{const Ee=zj(re,xe.speedOptions);r({type:"control/update-drive",payload:{...Ee,source:xe.source??null}}),L(),E.sendDriveDirect(Ee.speeds)},[E,L]),oe=m.useCallback((re={})=>{const xe=E.sendAuxMotors(re)??re;r({type:"control/set-aux-motors",payload:xe}),L()},[E,L]),$=m.useCallback((re,xe)=>{if(!re)return!1;const Ee=Rr(xe);if(!Ee)return!1;const fe=Jp(s.keymap);return fe[re]=[Ee],r({type:"control/set-keymap",payload:fe}),v(we=>({...we??{},keymap:fe})),!0},[s.keymap,v]),T=m.useCallback(()=>{const re=Jp(mr);r({type:"control/set-keymap",payload:re}),v(xe=>({...xe??{},keymap:re}))},[v]),H=m.useCallback(re=>{if(!E.servoConfig)return;const xe=Zj(E.servoConfig,re);r({type:"control/set-camera-angle",payload:xe}),E.sendServoAngle(xe),f.current=xe,L()},[E,L]),J=m.useCallback((re=0)=>{const xe=E.servoConfig;if(!xe)return;const Ee=typeof re=="number"&&re!==0?re:xe.nudgeDegrees||1,fe=typeof f.current=="number"?f.current:typeof xe.homeAngle=="number"?xe.homeAngle:0;H(fe+Ee)},[E.servoConfig,H]),te=m.useCallback(()=>{const re=E.servoConfig;if(!re)return;const xe=typeof re.homeAngle=="number"?re.homeAngle:typeof re.minAngle=="number"&&typeof re.maxAngle=="number"?(re.minAngle+re.maxAngle)/2:0;H(xe)},[E.servoConfig,H]),ue=m.useCallback(async re=>{const xe=s.macros.find(fe=>fe.id===re)||null;if(!xe)return;let Ee=xe;re==="drive-sequence"?(B(),S?.length||(u.current=!0),L(),M||(Ee={...xe,steps:Ij(xe.steps)})):re==="seek-dock"&&L(),await E.runMacroSteps(Ee)},[M,E,L,S,s.macros,B]),q=m.useCallback(()=>{r({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),E.sendDriveDirect({left:0,right:0}),E.sendAuxMotors({main:0,side:0,vacuum:0})},[E]),_=m.useCallback(re=>{E.sendOiCommand(re)},[E]),I=m.useCallback(re=>{E.roverId&&E.emitCommand({type:"sensorStream",data:{sensorStream:{enable:re}}})},[E]),ne=m.useCallback(re=>{if(E.nightVision){if(typeof re=="boolean"){const xe=re?"off":"on";E.sendNightVision(xe)}else E.sendNightVision("toggle");L()}},[E,L]),me=m.useCallback(()=>{ne()},[ne]),ce=m.useCallback(re=>{const xe=typeof re=="number"?re:ll;return r({type:"control/set-song-note",payload:xe}),xe},[]),se=m.useCallback((re,xe)=>E.sendSong(re,xe),[E]),ve=m.useMemo(()=>{const re=N??cs,xe=re.waveform==="sine"?"sine":"saw",fe=[...Array.isArray(re.freqs)?re.freqs:cs.freqs,0,0,0,0].slice(0,4).map(we=>{const Ae=Number(we);return Number.isFinite(Ae)?Ae<=0?0:Math.min(5e3,Math.round(Ae)):0});return{waveform:xe,freqs:fe}},[N]),he=m.useCallback(()=>{if(!E.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const re=Date.now();return E.sendHorn({action:"start",...ve}),r({type:"control/set-horn-active",payload:!0}),h.current=re,x.current=re,p.current&&(clearTimeout(p.current),p.current=null),p.current=setTimeout(()=>{be()},Dj),L(),!0},[r,ve,E,L,s.horn?.active,s.horn?.heat,s.horn?.overheated]),be=m.useCallback(()=>{if(!E.horn)return;E.sendHorn({action:"stop"}),r({type:"control/set-horn-active",payload:!1}),p.current&&(clearTimeout(p.current),p.current=null);const re=Date.now(),xe=h.current||re,Ee=Math.max(0,re-xe);if(h.current=0,Ee>0){const fe=s.horn?.heat??0,we=Ee/1e3*Zi;let Ae=Math.max(0,Math.min(1,fe+we)),it=s.horn?.overheated??!1;Ae>=1&&(Ae=1,it=!0),r({type:"control/set-horn-heat",payload:{heat:Ae,overheated:it}})}},[r,E,s.horn?.heat,s.horn?.overheated,Zi]),Ve=m.useRef({active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}),De=m.useRef(be);m.useEffect(()=>{Ve.current={active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}},[s.horn?.active,s.horn?.heat,s.horn?.overheated]),m.useEffect(()=>{De.current=be},[be]);const Te=!!s.horn?.active||(s.horn?.heat??0)>0||!!s.horn?.overheated;m.useEffect(()=>{if(!Te)return;const xe=setInterval(()=>{const Ee=Date.now(),fe=x.current||Ee;x.current=Ee;const we=Math.min(1e3,Math.max(0,Ee-fe))/1e3,Ae=Ve.current,it=Ae.heat??0,le=!!Ae.active,de=!!Ae.overheated,Me=we*(le?Zi:-Gp);let ft=Math.max(0,Math.min(1,it+Me)),kt=de;ft>=1?(ft=1,kt=!0,le&&De.current()):kt&&ft<=Yp&&(kt=!1),(ft!==it||kt!==de)&&r({type:"control/set-horn-heat",payload:{heat:ft,overheated:kt}})},100);return()=>clearInterval(xe)},[r,Te,Gp,Yp,Zi]);const ze=m.useCallback((re,xe)=>{r({type:"control/register-input-state",payload:{source:re,state:xe}})},[]),$e=m.useCallback(re=>{r({type:"control/set-mic-ptt",payload:!!re})},[]),vt=m.useMemo(()=>({state:s,dispatch:r,pipeline:E,overcurrentLimiter:j,actions:{setMode:X,setDriveVector:ie,setAuxMotors:oe,setServoAngle:H,nudgeServo:J,goServoHome:te,runMacro:ue,stopAllMotion:q,sendOiCommand:_,setSensorStream:I,setNightVision:ne,toggleNightVision:me,updateKeyBinding:$,resetKeyBindings:T,registerInputState:ze,setSongNote:ce,sendSong:se,startHorn:he,stopHorn:be,setMicPttActive:$e}}),[s,E,j,X,ie,oe,H,J,te,ue,q,_,I,ne,me,$,T,ze,ce,se,he,be,$e]);return l.jsx(yg.Provider,{value:vt,children:n})}function Dt(){const n=m.useContext(yg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const Pj="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=",Sg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function Wj({children:n}){const s=sn(),r=pe($=>$.session),{pushAlert:o}=Xt(),{value:u}=Qe("audio",ut),[f,p]=m.useState([]),[h,x]=m.useState([]),[g,v]=m.useState(!1),y=m.useRef(null),N=m.useRef(null),M=m.useRef(null),C=m.useRef(new Map),S=m.useRef(new Map),w=m.useRef({isTyping:!1,lastSent:0}),j=Number.isFinite(u?.masterVolume)?u.masterVolume:ut.masterVolume,R=Number.isFinite(u?.alertVolume)?u.alertVolume:ut.alertVolume,k=Math.max(0,Math.min(1,j*R)),E=m.useCallback(()=>{const $=Array.from(C.current.values()).sort((T,H)=>T.lastUpdate-H.lastUpdate).map(T=>T.payload);x($)},[]),B=m.useCallback($=>!$||typeof $!="object"?null:$.typingId?$.typingId:$.fromDiscord?`discord:${$.discordUserId||$.discordUserName||$.nickname||"unknown"}`:`socket:${$.socketId||$.nickname||"unknown"}`,[]);m.useEffect(()=>{M.current=new Audio(Pj),M.current.volume=k,M.current.load()},[k]);const X=m.useCallback(()=>{const $=M.current;$&&($.volume=k,$.currentTime=0,$.play().catch(()=>{}))},[k]);m.useEffect(()=>{function $(T={}){p(H=>[...H.slice(-99),T]),!(T?.socketId&&r?.socketId&&T.socketId===r.socketId)&&(X(),o?.({kind:"chat",payload:T,id:`chat-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",$),()=>{s.off("chat:message",$)}},[X,r?.socketId,s]),m.useEffect(()=>{function $(T={}){const H=B(T);if(!H)return;const J=Date.now();if(T?.socketId&&r?.socketId&&T.socketId===r.socketId){T.isTyping||(C.current.delete(H),E());return}if(T.isTyping){C.current.set(H,{payload:T,expiresAt:J+6e3,lastUpdate:J});const te=S.current.get(H)||0;J-te>=2500&&(S.current.set(H,J),o?.({kind:"chat-typing",payload:T,id:`chat-typing-${H}-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else C.current.delete(H);E()}return s.on("chat:typing",$),()=>{s.off("chat:typing",$)}},[o,E,B,r?.socketId,s]),m.useEffect(()=>{const $=setInterval(()=>{const T=Date.now();let H=!1;C.current.forEach((J,te)=>{J.expiresAt<=T&&(C.current.delete(te),H=!0)}),H&&E()},2e3);return()=>clearInterval($)},[E]),m.useEffect(()=>{function $(T=[]){Array.isArray(T)&&p(H=>{if(H.length===0)return T.slice(-100);const J=new Set(T.map(ue=>ue?.id));return[...T,...H.filter(ue=>ue?.id&&!J.has(ue.id))].slice(-100)})}return s.on("chat:init",$),()=>{s.off("chat:init",$)}},[s]);const L=m.useCallback($=>{const T=!!$,H=Date.now(),J=w.current,te=!T&&J.isTyping;!(T&&(!J.isTyping||H-J.lastSent>=3500))&&!te||(w.current={isTyping:T,lastSent:H},s.emit("chat:typing",{isTyping:T}))},[s]),z=m.useCallback(($,T=null)=>new Promise((H,J)=>{s.emit("chat:send",{text:$,tts:T},(te={})=>{te.error?J(new Error(te.error)):H(te)})}),[s]),K=m.useCallback(($,T={})=>{(T?.target==="hud"?"hud":"panel")==="hud"?N.current=$:y.current=$},[]),V=m.useCallback(()=>{v(!0),(N.current||y.current)?.focus()},[]),F=m.useCallback(()=>{v(!1),N.current?.blur(),y.current?.blur()},[]),W=m.useCallback(()=>v(!0),[]),ie=m.useCallback(()=>v(!1),[]),oe=m.useMemo(()=>({messages:f,sendMessage:z,focusChat:V,blurChat:F,registerInputRef:K,onInputFocus:W,onInputBlur:ie,setTypingActive:L,typing:h,isChatFocused:g,selfSocketId:r?.socketId||null}),[F,V,g,f,ie,W,K,z,r?.socketId,L,h]);return l.jsx(Sg.Provider,{value:oe,children:n})}function cf(){const n=m.useContext(Sg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let jg=!1;function rd(n){jg=!!n}function Pp(){return jg}const eN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function Ng(n){if(!n||n.nodeType!==1)return!1;const s=n.tagName;if(s==="TEXTAREA"||n.isContentEditable)return!0;if(s!=="INPUT")return!1;const r=n.type?n.type.toLowerCase():"";return eN.has(r)}function tN(){return typeof document>"u"?!1:Ng(document.activeElement)}const id="keyboard",od={x:0,y:0,boost:!1},cd={main:0,side:0,vacuum:0},Wp=of[0],ex=of[1],uf=5,gr=500,vr=1,df=100;function ud(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):s}function nN(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(uf,Math.min(gr,r)):s}function wg(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(vr,Math.min(df,r)):s}function aN(n){const r=(wg(n,n)-vr)/(df-vr),o=gr-r*(gr-uf);return Math.round(o)}function sN(n){const s=nN(n,n),r=(gr-s)/(gr-uf),o=vr+r*(df-vr);return Math.round(o)}function lN(n){return Ng(n?.target)}function pt(n,s){if(!n||n.size===0)return!1;for(const r of s)if(n.has(r))return!0;return!1}function rN(n,s){const r=pt(s.driveForward,n),o=pt(s.driveBackward,n),u=pt(s.driveLeft,n),f=pt(s.driveRight,n),p=pt(s.boostModifier,n),h=pt(s.slowModifier,n);let x=0;r&&!o?x=1:o&&!r&&(x=-1);let g=0;u&&!f?g=-1:f&&!u&&(g=1);const v=h?.4:1;return{x:g*v,y:x*v,boost:p&&!h}}function iN(n,s){if(pt(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=pt(s.auxMainForward,n)?127:pt(s.auxMainReverse,n)?-127:0,u=pt(s.auxSideForward,n)?127:pt(s.auxSideReverse,n)?-70:0,f=pt(s.auxVacuumFast,n)?127:pt(s.auxVacuumSlow,n)?50:0;return{main:o,side:u,vacuum:f}}function oN(){const{state:n,actions:{setMode:s,setDriveVector:r,setAuxMotors:o,nudgeServo:u,runMacro:f,stopAllMotion:p,registerInputState:h,toggleNightVision:x,startHorn:g,stopHorn:v,setMicPttActive:y,setSongNote:N,sendSong:M}}=Dt(),C=pe(ce=>ce.session?.homeAssistant||null),{homeAssistantSetState:S}=Xt(),{focusChat:w,blurChat:j,isChatFocused:R}=cf(),{value:k}=Qe("inputs",Dn),E=m.useMemo(()=>Yj(n.keymap),[n.keymap]),B=m.useMemo(()=>{const ce=new Set;return Object.values(E).forEach(se=>{se&&se.forEach(ve=>ce.add(ve))}),ce},[E]),X=m.useMemo(()=>{const ce=Dn.keyboard,se=k?.keyboard??{};return{baseSpeed:ud(se.baseSpeed,ce.baseSpeed),turboSpeed:ud(se.turboSpeed,ce.turboSpeed),precisionSpeed:ud(se.precisionSpeed,ce.precisionSpeed)}},[k?.keyboard]),L=m.useMemo(()=>{const ce=Dn.keyboard,se=k?.keyboard??{},ve=wg(typeof se.tiltSpeed=="number"?se.tiltSpeed:typeof se.tiltIntervalMs=="number"?sN(se.tiltIntervalMs):ce.tiltSpeed,ce.tiltSpeed);return aN(ve)},[k?.keyboard]),z=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),K=m.useRef(new Set),V=m.useRef(od),F=m.useRef(cd),W=m.useRef(null),ie=m.useRef(null),oe=m.useRef(!1),$=m.useCallback(()=>{const ce=new Set(K.current);pt(E.boostModifier,ce);const ve=pt(E.slowModifier,ce)?{baseSpeed:X.precisionSpeed,boostSpeed:X.precisionSpeed}:{baseSpeed:X.baseSpeed,boostSpeed:X.turboSpeed},he=rN(ce,E),be=iN(ce,E);(he.x!==V.current.x||he.y!==V.current.y||he.boost!==V.current.boost)&&(V.current=he,r(he,{source:id,speedOptions:ve})),(be.main!==F.current.main||be.side!==F.current.side||be.vacuum!==F.current.vacuum)&&(F.current=be,o(be)),h(id,{keys:Array.from(ce),vector:he,aux:be})},[E,X,h,o,r]),T=m.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),H=m.useCallback(()=>{const ce=new Set(K.current),se=pt(E.cameraUp,ce),ve=pt(E.cameraDown,ce);return(se?1:0)-(ve?1:0)},[E]),J=m.useCallback(()=>{if(H()===0){T();return}if(W.current)return;const se=()=>{const ve=H();if(ve===0){T();return}u(ve*z),W.current=setTimeout(se,L)};W.current=setTimeout(se,0)},[H,u,L,z,T]),te=m.useCallback(()=>{ie.current&&(clearTimeout(ie.current),ie.current=null)},[]),ue=m.useCallback(()=>{const ce=new Set(K.current),se=pt(E.songNoteUp,ce),ve=pt(E.songNoteDown,ce);return(se?1:0)-(ve?1:0)},[E]),q=m.useCallback(ce=>{if(ce===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:ll)+ce;ve>ex?ve=Wp:ve<Wp&&(ve=ex);const he=N(ve);M([{note:he,duration:_d}],{slot:0})},[M,N,n.song?.note]),_=m.useCallback(()=>{if(ue()===0){te();return}if(ie.current)return;const se=()=>{const ve=ue();if(ve===0){te();return}q(ve),ie.current=setTimeout(se,Tj)};ie.current=setTimeout(se,0)},[ue,te,q]),I=m.useCallback(()=>{K.current.clear(),V.current=od,F.current=cd,T(),te(),oe.current&&(oe.current=!1,v()),y(!1),p(),h(id,{keys:[],vector:od,aux:cd})},[h,y,p,v,T,te]),ne=m.useCallback(ce=>{const se=C;if(!se?.enabled||!se?.connected||se?.lightPolicy?.locked||se?.lightPolicy?.lockedOn)return;const he=(se.entities||[]).filter(be=>(be.type==="light"||be.type==="switch")&&be.available!==!1&&be.state!=="unavailable");if(he.length!==0){if(ce==="on"){const be=he.find(Ve=>Ve.state!=="on");be&&S(be.id,"on").catch(()=>{});return}if(ce==="off")for(let be=he.length-1;be>=0;be-=1){const Ve=he[be];if(Ve.state==="on"){S(Ve.id,"off").catch(()=>{});break}}}},[S,C]);m.useEffect(()=>{function ce(he){if(Pp()||lN(he))return;const be=Kp(he);if(be.length===0)return;const Ve=new Set(be);if(pt(E.chatFocus,Ve)){he.preventDefault(),I(),R||w();return}be.some(Te=>B.has(Te))&&he.preventDefault();const De=be.filter(Te=>!K.current.has(Te));if(De.forEach(Te=>K.current.add(Te)),De.length>0)if(De.some(Te=>E.driveMacro?.has(Te)))s("drive"),f("drive-sequence");else if(De.some(Te=>E.dockMacro?.has(Te)))s("dock"),f("seek-dock");else if(De.some(Te=>E.nightVisionToggle?.has(Te)))x();else if(De.some(Te=>E.hornHonk?.has(Te))){if(!oe.current){const Te=g();oe.current=!!Te}}else De.some(Te=>E.micPtt?.has(Te))?y(!0):De.some(Te=>E.homeAssistantOn?.has(Te))?ne("on"):De.some(Te=>E.homeAssistantOff?.has(Te))&&ne("off");J(),_(),$()}function se(he){if(Pp())return;Kp(he).forEach(Ve=>K.current.delete(Ve)),oe.current&&!pt(E.hornHonk,K.current)&&(oe.current=!1,v()),pt(E.micPtt,K.current)||y(!1),J(),_(),$()}function ve(){I()}return window.addEventListener("keydown",ce,{capture:!0}),window.addEventListener("keyup",se,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",ce,{capture:!0}),window.removeEventListener("keyup",se,{capture:!0}),window.removeEventListener("blur",ve)}},[B,j,$,J,_,w,R,E.chatFocus,E.dockMacro,E.driveMacro,E.hornHonk,E.micPtt,I,f,y,s,p,te,g,v,ne]);const me=m.useRef(I);return m.useEffect(()=>{me.current=I},[I]),m.useEffect(()=>{me.current()},[n.roverId]),m.useEffect(()=>{oe.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{T(),te()},[T,te]),null}const cN=1.6;function Ag(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",r=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,u=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${r}::${o}::${u}`}function uN(n){return JSON.parse(JSON.stringify(n??{}))}function Cg(n,s){const r=uN(s);return r.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},r}function os(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function or(n,s){if(!n)return 0;const r=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(r,cN):n}function dd(n,s){const r=Math.abs(n);if(r<=s)return 0;const o=(r-s)/(1-s);return Math.sign(n)*o}function dN(n,s,r){const o=Math.hypot(n,s);if(o<=r)return{x:0,y:0};const f=(o-r)/(1-r)/o;return{x:n*f,y:s*f}}function go(n,s){if(!n||!Array.isArray(n.axes))return null;const r=n.axes[s];return Number.isFinite(r)?os(r):null}function Ld(n,s){if(!n||!Array.isArray(n.buttons))return null;const r=n.buttons[s];if(!r)return null;const o=typeof r.value=="number"?r.value:r.pressed?1:0;return{pressed:!!(r.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function fd(n,s=[]){for(const r of s)if(r){if(r.kind==="axis"){const o=go(n,r.index);if(o===null)continue;return{value:r.invert?-o:o,source:r}}if(r.kind==="buttonAxis"){const o=Ld(n,r.index);if(!o)continue;return{value:os(o.value),source:r}}}return{value:0,source:null}}function fN(n,s=[]){for(const r of s){if(!r||r.kind!=="axisPair")continue;const o=go(n,r.x),u=go(n,r.y);if(o===null||u===null)continue;const f=r.invertX?-o:o,p=r.invertY?-u:u;return{x:f,y:p,source:r}}return{x:0,y:0,source:null}}function as(n,s=[]){for(const r of s)if(r){if(r.kind==="button"){const o=Ld(n,r.index);if(!o)continue;return{pressed:o.pressed,source:r}}if(r.kind==="axisButton"){const o=go(n,r.index);if(o===null)continue;const u=r.direction||1,f=typeof r.threshold=="number"?r.threshold:.6;return{pressed:o*u>f,source:r}}if(r.kind==="buttonAxis"){const o=Ld(n,r.index);if(!o)continue;return{pressed:o.value>.5,source:r}}}return{pressed:!1,source:null}}function Eg(n,s){const r=s?.bindings??{},o=s?.calibration??{},u=r.drive??{},f=fN(n,u.sources);let p=os(f.x),h=os(f.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=dN(p,h,x);p=or(g.x,o.driveCurve),h=or(g.y,o.driveCurve);const v=r.cameraTilt??{},y=fd(n,v.sources),N=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let M=dd(os(y.value),N);M=or(M,o.cameraCurve);const C=Math.min(Math.max(o.auxDeadzone??.05,0),.6),S=r.mainBrush??{},w=fd(n,S.sources);let j=dd(os(w.value),C);j=or(j,o.auxCurve);const R=r.sideBrush??{},k=fd(n,R.sources);let E=dd(os(k.value),C);E=or(E,o.auxCurve);const B=as(n,r.vacuum?.sources),X=as(n,r.allAux?.sources),L=as(n,r.mainReverse?.sources),z=as(n,r.sideReverse?.sources),K=as(n,r.driveMacro?.sources),V=as(n,r.dockMacro?.sources),F=as(n,r.nightVisionToggle?.sources);return{driveVector:{x:p,y:h,boost:!1},cameraAxis:M,auxAxis:{main:j,side:E},buttons:{vacuum:B.pressed,allAux:X.pressed,mainReverse:L.pressed,sideReverse:z.pressed,driveMacro:K.pressed,dockMacro:V.pressed,nightVisionToggle:F.pressed},sources:{drive:f.source,cameraTilt:y.source,mainBrush:w.source,sideBrush:k.source,vacuum:B.source,allAux:X.source,mainReverse:L.source,sideReverse:z.source,driveMacro:K.source,dockMacro:V.source,nightVisionToggle:F.source}}}const fr=new Set;let sl=null,ol={pads:[],timestamp:0},Ii=!1,Ji=null;function tx(){return kg().some(n=>n?.connected!==!1)}function kg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function mN(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0})),signature:Ag(n)}}function vo(){ol={pads:kg().map(mN),timestamp:typeof performance<"u"?performance.now():Date.now()},fr.forEach(s=>s(ol))}function Mg(){if(vo(),ol.pads.length===0){zd();return}sl=requestAnimationFrame(Mg)}function nx(){sl||(vo(),ol.pads.length!==0&&(sl=requestAnimationFrame(Mg)))}function zd(){sl&&(cancelAnimationFrame(sl),sl=null)}function Rg(n){if(fr.add(n),!Ii&&typeof window<"u"){const s=()=>{vo(),fr.size!==0&&(tx()?nx():zd())};window.addEventListener("gamepadconnected",s),window.addEventListener("gamepaddisconnected",s),Ji=s,Ii=!0}return tx()?nx():vo(),n(ol),()=>{fr.delete(n),fr.size===0&&(zd(),Ii&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Ji),window.removeEventListener("gamepaddisconnected",Ji),Ji=null,Ii=!1))}}function hN(){const[n,s]=m.useState(ol);return m.useEffect(()=>Rg(s),[]),n}const el="gamepad",ss={x:0,y:0,boost:!1},ls={main:0,side:0,vacuum:0},pN=100,xN=100;function md(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function hd(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function gN(n){return n?Math.hypot(n.x||0,n.y||0):0}function vN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function bN(n,s){if(!n||n.length===0)return null;if(s){const r=n.find(o=>o.signature===s);if(r)return r}return n[0]}function yN(){const{state:n,actions:{setMode:s,setDriveVector:r,setAuxMotors:o,setServoAngle:u,runMacro:f,toggleNightVision:p,registerInputState:h}}=Dt(),{value:x,save:g}=Qe("gamepad",_a),v=m.useRef(new Set),y=m.useRef(ss),N=m.useRef(ls),M=m.useRef({main:!1,side:!1}),C=m.useRef(new Map),S=m.useRef(0),w=m.useRef(0),j=m.useRef(0),R=m.useRef(null),k=m.useCallback(L=>{const z=L.signature??Ag(L);x?.profiles?.[z]||v.current.has(z)||(v.current.add(z),g(K=>{const V=K??_a;if(V.profiles?.[z])return V;const F=V?.defaults?.profile??sa,W=Cg(L,F);return{...V,profiles:{...V.profiles??{},[z]:W}}}))},[x?.profiles,g]),E=m.useCallback((L,z)=>{const K=C.current.get(L)||!1;return C.current.set(L,z),z&&!K},[]),B=m.useCallback((L,z)=>{const K=n.camera?.config;if(!K)return;const V=typeof performance<"u"?performance.now():Date.now(),F=z?.cameraMode??"absolute",W=Math.max(1,Math.min(180,z?.cameraSensitivity??60));if(F==="velocity"){const H=Math.min(50,V-j.current||16),J=L*W*(H/1e3);if(Math.abs(J)<.01)return;const ue=(typeof R.current=="number"?R.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof K.homeAngle=="number"?K.homeAngle:0)+J;u(ue),R.current=ue,j.current=V;return}const ie=typeof K.minAngle=="number"?K.minAngle:-45,oe=typeof K.maxAngle=="number"?K.maxAngle:45,$=typeof K.homeAngle=="number"?K.homeAngle:(ie+oe)/2,T=L<0?$+L*($-ie):$+L*(oe-$);typeof R.current=="number"&&Math.abs(R.current-T)<.35&&V-j.current<80||(j.current=V,R.current=T,u(T))},[u,n.camera?.angle,n.camera?.config]),X=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>Rg(L=>{const z=bN(L.pads,X);if(!z){md(y.current,ss)||(y.current=ss,r(ss,{source:el})),hd(N.current,ls)||(N.current=ls,o(ls)),C.current=new Map,M.current={main:!1,side:!1},S.current=0,w.current=0,h(el,{connected:!1});return}if(tN()){md(y.current,ss)||(y.current=ss,r(ss,{source:el})),hd(N.current,ls)||(N.current=ls,o(ls)),C.current=new Map,M.current={main:!1,side:!1},h(el,{connected:!0,blocked:!0});return}k(z);const K=z.signature,V=x?.profiles?.[K]??x?.defaults?.profile??sa,F=Eg(z,V);if(!md(F.driveVector,y.current)){const J=typeof performance<"u"?performance.now():Date.now();(gN(F.driveVector)<.02||J-S.current>=pN)&&(y.current=F.driveVector,S.current=J,r(F.driveVector,{source:el}))}const W=V.calibration?.auxSideScale??.55,ie=Math.round(Math.min(Math.abs(F.auxAxis.main),1)*127),oe=Math.round(Math.min(Math.abs(F.auxAxis.side),1)*127),$=M.current.main?-ie:ie,T=M.current.side?-Math.round(oe*W):Math.round(oe*W);let H={main:F.auxAxis.main!==0?$:0,side:F.auxAxis.side!==0?T:0,vacuum:F.buttons.vacuum?127:0};if(F.buttons.allAux&&(H={main:127,side:127,vacuum:127}),!hd(H,N.current)){const J=typeof performance<"u"?performance.now():Date.now();(vN(H)||J-w.current>=xN)&&(N.current=H,w.current=J,o(H))}F.buttons.mainReverse&&E("mainReverse",!0)?M.current.main=!M.current.main:F.buttons.mainReverse||E("mainReverse",!1),F.buttons.sideReverse&&E("sideReverse",!0)?M.current.side=!M.current.side:F.buttons.sideReverse||E("sideReverse",!1),F.buttons.driveMacro&&E("driveMacro",!0)?(s("drive"),f("drive-sequence")):F.buttons.driveMacro||E("driveMacro",!1),F.buttons.dockMacro&&E("dockMacro",!0)?(s("dock"),f("seek-dock")):F.buttons.dockMacro||E("dockMacro",!1),F.buttons.nightVisionToggle&&E("nightVisionToggle",!0)?p():F.buttons.nightVisionToggle||E("nightVisionToggle",!1),Math.abs(F.cameraAxis)>.001&&B(F.cameraAxis,V.calibration),h(el,{connected:!0,signature:K,id:z.id,index:z.index,axes:z.axes,buttons:z.buttons,drive:F.driveVector,aux:H,cameraAxis:F.cameraAxis,bindings:F.sources})}),[X,k,x?.defaults?.profile,x?.profiles,E,B,h,f,o,r,s,p]),null}function qg(n){const s=n?.sensors||{},r=s.oiMode?.label||"Unknown",o=r.toLowerCase(),u=s.chargingState?.label||"",f=!!s.chargingSources?.homeBase,p=f&&u.toLowerCase()!=="not charging"&&u!=="";return{driving:o==="full",docked:f,charging:p,dockedNotCharging:f&&!p,dockingInProgress:!f&&!p&&o==="passive",oiLabel:r,chargingLabel:u}}function Tg(n){const s=fl(n);return m.useMemo(()=>qg(s),[s])}function tl({label:n,value:s,tone:r="neutral"}){const o=r==="good"?"border-emerald-200 bg-emerald-600 text-white":r==="warn"?"border-amber-200 bg-amber-600 text-white":r==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return l.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:l.jsx("span",{className:"text-base font-semibold md:text-lg",children:s})})}function ax({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function pd({label:n,tone:s}){const r=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return l.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${r}`,children:n})}function SN({instructions:n,onConfirm:s,onCancel:r,pending:o}){return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:l.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:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),l.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),l.jsx(Ud,{steps:n.steps,tone:"indigo"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[l.jsx("button",{type:"button",onClick:r,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),l.jsx("button",{type:"button",disabled:o,onClick:s,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 Dg({layout:n="desktop",expand:s=!1,fill:r=!1,driveDockState:o,compactHeightClass:u=""}){const f=n==="mobile",{state:{roverId:p,keymap:h},actions:x}=Dt(),g=fl(p),v=o??qg(g),{driving:y,docked:N,charging:M,dockingInProgress:C}=v,[S,w]=m.useState(null),[j,R]=m.useState(!1),[k,E]=m.useState(!1),B=!p||S!==null,X=!p||S!==null,L=An(h?.driveMacro?.[0]),z=An(h?.dockMacro?.[0]),K={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"]},V="Click this button to initate auto-dock.",F={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"]},W=N?"Docked":"Undocked",ie=N?"good":"bad",oe=M?"Charging":N?"Charging in 5s":"—",$=M?"good":N?"warn":"bad",T=async()=>{if(!(!p||S)){w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch($e){alert($e.message)}finally{w(null)}}},H=async()=>{if(!(!p||S)){R(!1),E(!1),w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch($e){alert($e.message)}finally{w(null)}}},J=async()=>{if(!(!p||S)){w("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch($e){alert($e.message)}finally{w(null),R(!1),E(!1)}}},te=()=>{X||(E(!0),R(!0))},ue="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",_="items-center justify-between",I="items-center justify-center",ne=f?"text-sm font-semibold":"",me="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ce="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",se="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",be=s||C,Ve=be?"h-full flex-1":r?"flex-1":"",De=f&&!be?u:"",Te=f&&!be?I:_,ze=f&&!be&&y&&N;if(!y&&!C)return l.jsxs("button",{type:"button",onClick:H,onContextMenu:$e=>$e.preventDefault(),disabled:B,className:`${ue} ${Ve} ${De} ${q} ${Te} ${ne} ${me}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!f&&be?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[L?l.jsx(ax,{label:L}):null,l.jsx(pd,{label:"Click to start",tone:"emerald"})]}):null]}),be?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-emerald-50/90",children:F.summary}),l.jsx(Ud,{steps:F.steps,tone:"emerald"})]}):null]}),be?l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(tl,{label:"Dock",value:W,tone:ie}),l.jsx(tl,{label:"Charge",value:oe,tone:$})]}):null]});if(C){const $e={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 l.jsxs("button",{type:"button",disabled:B,onClick:T,onContextMenu:vt=>vt.preventDefault(),className:`${ue} ${Ve} ${De} ${q} ${Te} ${ne} ${ce}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),be?l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:l.jsx(pd,{label:"Return to driving mode",tone:"emerald"})}):null]}),be?l.jsx("p",{className:"text-sm text-amber-50/90",children:$e.summary}):null]}),be?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(tl,{label:"Dock",value:W,tone:ie}),l.jsx(tl,{label:"Charge",value:oe,tone:$})]}),f?null:l.jsx(Ud,{steps:$e.steps,tone:"amber"})]}):null]})}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",disabled:X,onClick:te,onContextMenu:$e=>$e.preventDefault(),className:f?`flex w-full ${ue} ${De} ${q} ${Te} ${ne} ${ze?ve:se}`:`${ue} ${Ve} ${q} ${_} ${ne} ${se}`,children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:ze?"Docked!":"Dock and Charge"}),!f&&be?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[z?l.jsx(ax,{label:z}):null,l.jsx(pd,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!f&&be&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-indigo-50/90",children:V}),l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(tl,{label:"Dock",value:W,tone:ie}),l.jsx(tl,{label:"Charge",value:oe,tone:$})]}),l.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),k||!f&&j?l.jsx(SN,{instructions:K,pending:S==="dock",onCancel:()=>{E(!1),R(!1)},onConfirm:J}):null]})}function Ud({steps:n,tone:s="emerald"}){const r=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="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=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return l.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${r}`,children:n.map((u,f)=>l.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[f+1,"."]}),l.jsx("span",{className:"align-top",children:u})]}),f<n.length-1?l.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},u))})}function xd(n){return typeof n=="boolean"}function _g({nightVisionOn:n,disabled:s,onToggle:r,keyLabel:o,className:u="",heightClass:f=""}){const[p,h]=m.useState(xd(n)?n:null);m.useEffect(()=>{xd(n)&&h(n)},[n]);const x=xd(p),g=x?p:!1,v=x?g?"On":"Off":"—",y=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",N=()=>{if(s)return;const C=x?!g:!0;h(C),r?.(C)},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",f,u].filter(Boolean).join(" "),[u,g,f]);return l.jsxs("button",{type:"button",onClick:N,onContextMenu:C=>C.preventDefault(),disabled:s,"aria-pressed":g,className:M,children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?l.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${y}`,children:v})]})}function gd(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function Og({disabled:n,onStart:s,onStop:r,keyLabel:o,active:u,heat:f=0,className:p="",defaultShowSettings:h=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[v,y]=m.useState(!1),[N,M]=m.useState(h),{value:C,save:S}=Qe("horn",cs),[w,j]=m.useState(C?.waveform||cs.waveform),[R,k]=m.useState(()=>[...Array.isArray(C?.freqs)?C.freqs:cs.freqs,0,0,0,0].slice(0,4).map(T=>gd(T)));m.useEffect(()=>{j(C?.waveform||cs.waveform),Array.isArray(C?.freqs)&&k([...C.freqs,0,0,0,0].slice(0,4).map($=>gd($)))},[C?.freqs,C?.waveform]);const E=!!u,B=Math.max(0,Math.min(1,Number(f)||0)),X=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",E?"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",p].filter(Boolean).join(" "),[p,E]),L=()=>{n||v||(y(!0),s?.())},z=()=>{v&&(y(!1),r?.())};m.useEffect(()=>{!E&&v&&y(!1)},[E,v]);const K=w==="sine"?"sine":"saw",V=m.useCallback($=>{const T=$.target.value==="sine"?"sine":"saw";j(T),S(H=>({...H??{},waveform:T}))},[S]),F=m.useCallback(($,T)=>{k(H=>{const J=[...H];return J[$]=gd(T),S(te=>({...te??{},freqs:J})),J})},[S]),W=$=>{if(n)return;const T=$.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||($.preventDefault(),L())},ie=$=>{const T=$.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||($.preventDefault(),z())},oe=x?l.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),M(T=>!T)},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 l.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:W,onPointerUp:ie,onPointerLeave:z,onPointerCancel:z,onContextMenu:$=>$.preventDefault(),onBlur:z,className:X,children:[l.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${B*100}%, rgba(0,0,0,0) ${B*100}%)`}}),l.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${E?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),l.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[l.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[l.jsx("span",{children:"Horn"}),o?l.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),oe,l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${E?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:E?"Honk":"Hold"})]}),N?g?l.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:K,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:R.map(($,T)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:H=>F(T,H.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-${T}`))})]}):l.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:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:K,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),R.map(($,T)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:H=>F(T,H.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-${T}`))]}):null]})}function Pi(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function sx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Bg({value:n,min:s,max:r,step:o=.5,label:u="Camera Tilt",orientation:f="horizontal",onChange:p,onCommit:h,throttleMs:x=0,disabled:g=!1,keyDownLabel:v,keyUpLabel:y,className:N="",labelRowClass:M="",labelClass:C="",valueClass:S="",sliderClass:w="",endpointClass:j="",endpointLabelClass:R="",accentClass:k="",showValue:E=!0,showEndpoints:B}){const X=f==="vertical",z=typeof B=="boolean"?B:!X,[K,V]=m.useState(n),F=m.useRef(!1),W=m.useRef(null);m.useEffect(()=>{F.current||V(n)},[n]),m.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]);const ie=J=>{if(p){if(x>0){W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{p(J)},x);return}p(J)}},oe=J=>{const te=Number.parseFloat(J.target.value);Number.isNaN(te)||(F.current=!0,V(te),ie(te))},$=()=>{F.current=!1,W.current&&(clearTimeout(W.current),W.current=null),h?h(K):x>0&&p?.(K)};if(typeof s!="number"||typeof r!="number")return null;const T=[X?"h-28 w-5":"w-full",k,w].filter(Boolean).join(" "),H=l.jsx("input",{type:"range",orient:X?"vertical":void 0,min:s,max:r,step:o,value:Number.isFinite(K)?K:s,onChange:oe,onMouseUp:$,onTouchEnd:$,onPointerUp:$,disabled:g,className:T,style:X?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return X?l.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${N}`.trim(),children:[E?l.jsx("div",{className:`flex flex-col items-center ${M}`.trim(),children:l.jsx("span",{className:S,children:Pi(n)})}):null,l.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[l.jsx("span",{className:C,children:u}),H]})]}):l.jsxs("div",{className:`space-y-0.5 ${N}`.trim(),children:[l.jsxs("div",{className:`flex items-center justify-between ${M}`.trim(),children:[l.jsx("span",{className:C,children:u}),E?l.jsx("span",{className:S,children:Pi(n)}):null]}),l.jsxs("div",{children:[H,z?l.jsxs("div",{className:`mt-0 flex items-center justify-between ${j}`.trim(),children:[l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[v?l.jsx(sx,{label:v}):null,Pi(s)]}),l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[Pi(r),y?l.jsx(sx,{label:y}):null]})]}):null]})]})}function jN({disabled:n,layout:s,radius:r,onMove:o,onStop:u}){const f=m.useRef(null),p=m.useRef(null),h=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{p.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),u?.()},[u]),y=m.useCallback(S=>{if(n||p.current!==null)return;S.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),R=S.clientX-j.left,k=S.clientY-j.top;h.current={x:R,y:k},p.current=S.pointerId,w.setPointerCapture?.(S.pointerId),g({active:!0,base:{x:R,y:k},knob:{x:0,y:0}})},[n]),N=m.useCallback(S=>{if(n||p.current!==S.pointerId)return;S.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),R=S.clientX-j.left,k=S.clientY-j.top,E=R-h.current.x,B=k-h.current.y,X=Math.min(Math.hypot(E,B),r),L=Math.atan2(B,E),z=Math.cos(L)*X,K=Math.sin(L)*X,V={x:il(z/r),y:il(-K/r),boost:!1};g(F=>({...F,knob:{x:z,y:K}})),o?.(V)},[n,o,r]),M=m.useCallback(S=>{if(p.current!==S.pointerId)return;S.preventDefault(),f.current?.releasePointerCapture?.(S.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),l.jsxs("div",{ref:f,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:y,onPointerMove:N,onPointerUp:M,onPointerLeave:M,onPointerCancel:M,onContextMenu:S=>S.preventDefault(),children:[!x.active&&l.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[l.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),l.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&l.jsxs(l.Fragment,{children:[l.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}}),l.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 lx({id:n,label:s,values:r,color:o,disabled:u,onPress:f,onRelease:p}){return l.jsx("button",{type:"button",disabled:u,onPointerDown:h=>{h.preventDefault(),f(n,r)},onPointerUp:()=>p(n),onPointerLeave:()=>p(n),onPointerCancel:()=>p(n),onContextMenu:h=>h.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:s})}const Wi="mobile-joystick",NN=80,wN=.15,AN={main:0,side:0,vacuum:0},CN={main:127,side:127,vacuum:127},EN={main:-127,side:-127,vacuum:-127};function kN({layout:n}){const{state:{roverId:s},actions:{setDriveVector:r,registerInputState:o}}=Dt(),u=Tg(s),f=u.docked&&!u.driving,p=f||u.dockingInProgress,h=!s,x=NN,g=wN,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{h&&(v.current={x:0,y:0,boost:!1})},[h]);const y=m.useCallback((S={})=>{if(h)return;const w={x:il(S.x??0),y:il(S.y??0),boost:!!S.boost},j={x:v.current.x+(w.x-v.current.x)*(1-g),y:v.current.y+(w.y-v.current.y)*(1-g),boost:w.boost};v.current=j,r(j,{source:Wi}),o(Wi,{vector:j,lastEvent:"move"})},[h,o,r,g]),N=m.useCallback(()=>{if(h)return;const S={x:0,y:0,boost:!1};v.current=S,r(S,{source:Wi}),o(Wi,{vector:S,lastEvent:"stop"})},[h,o,r]),C=`flex h-full flex-col gap-0.5 text-slate-100 ${f?"max-h-screen self-start":""}`;return l.jsxs("div",{className:C,children:[l.jsx(Dg,{layout:"mobile",expand:p,driveDockState:u,compactHeightClass:"min-h-[5rem]"}),p?null:l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(jN,{disabled:h,layout:n,radius:x,onMove:y,onStop:N})})]})}function MN({layout:n}){const{state:{roverId:s,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,setAuxMotors:h,startHorn:x,stopHorn:g}}=Dt(),v=!s,y=m.useRef(null),N=r?.config,M=!!(s&&r?.enabled&&N),C=!!(s&&u?.nightVision),S=u?.nightVisionState,w=!!(s&&u?.horn),j=o?.overheated,R=typeof N?.minAngle=="number"?N.minAngle:-45,k=typeof N?.maxAngle=="number"?N.maxAngle:45,E=typeof r?.angle=="number"?r.angle:typeof N?.homeAngle=="number"?N.homeAngle:(R+k)/2,B=m.useCallback(z=>{C&&p(z)},[C,p]),X=m.useCallback((z,K)=>{v||(y.current=z,h(K))},[v,h]),L=m.useCallback(z=>{v||y.current===z&&(y.current=null,h(AN))},[v,h]);return l.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:[l.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[l.jsx(lx,{id:"aux-vac-forward",label:"Vacuum Forward",values:CN,color:"bg-fuchsia-600",disabled:v,onPress:X,onRelease:L}),l.jsx(lx,{id:"aux-vac-backward",label:"Vacuum Backward",values:EN,color:"bg-fuchsia-800",disabled:v,onPress:X,onRelease:L})]}),l.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[M?l.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:l.jsx(Bg,{value:E,min:R,max:k,step:.5,onChange:f,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,C?l.jsx(_g,{nightVisionOn:S?.nightVisionOn,disabled:v,onToggle:B,heightClass:"h-full"}):null]}),l.jsx("div",{className:"min-h-0",children:w?l.jsx(Og,{disabled:v||j,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function bo({layout:n,className:s=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:l.jsx(MN,{layout:n})})}function yo({layout:n,className:s=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:l.jsx(kN,{layout:n==="landscape"?"landscape":"portrait"})})}function RN({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",r=n?l.jsx(yo,{layout:"portrait",className:s}):l.jsx(bo,{layout:"portrait",className:s}),o=n?l.jsx(bo,{layout:"portrait",className:s}):l.jsx(yo,{layout:"portrait",className:s});return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r,o]})})}function qN(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,p]=m.useState({}),h=m.useRef(new Map),x=m.useMemo(()=>n.map(S=>typeof S=="string"?S:S.id),[n]),g=m.useMemo(()=>{const S=x.join("|");return u?`${S}|v:${u}`:S},[x,u]),v=m.useRef([]),[y,N]=m.useState(0),M=m.useRef(new Map),C=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const S=()=>N(w=>w+1);return r.on("connect",S),()=>r.off("connect",S)},[r]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{h.current.forEach(S=>URL.revokeObjectURL(S)),h.current.clear(),p({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let S=!1;const w=v.current,j=(k={},E)=>{if(S||!k.id||!E)return;const B=E.byteLength??E.length??0,X=Date.now(),L=M.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},z={count:L.count+1,totalBytes:L.totalBytes+B,lastLogAt:L.lastLogAt};if(C&&(!z.lastLogAt||X-z.lastLogAt>=1e4)){const W=z.count?z.totalBytes/z.count:0;console.log("[roomCamera]",k.id,`frame=${B}B`,`avg=${Math.round(W)}B`,`count=${z.count}`),z.lastLogAt=X}M.current.set(k.id,z);const K=new Blob([E],{type:"image/jpeg"}),V=URL.createObjectURL(K),F=h.current.get(k.id);F&&URL.revokeObjectURL(F),h.current.set(k.id,V),p(W=>({...W,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:V}}))},R=(k={})=>{S||!k.id||p(E=>({...E,[k.id]:{...E[k.id]||{},status:k.error?"error":E[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||E[k.id]?.ts||null,objectUrl:E[k.id]?.objectUrl||null}}))};return r.on("roomCamera:frame",j),r.on("roomCamera:status",R),r.emit("roomCamera:subscribe",{ids:w},(k={})=>{k.error}),()=>{S=!0,r.emit("roomCamera:unsubscribe",{ids:w}),r.off("roomCamera:frame",j),r.off("roomCamera:status",R),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,g,o,y,C]),f}function TN({feed:n,label:s}){const[r,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(f=>!f))},[n?.ts,n?.objectUrl]);const u=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return l.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?l.jsx("img",{src:n.objectUrl,alt:s,className:"h-full w-full object-cover"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),l.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:s}),l.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:[l.jsx("span",{className:`h-2 w-2 rounded-full ${r?"bg-emerald-400":"bg-slate-500"}`}),l.jsx("span",{children:u})]})]})}function DN(){return l.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),l.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const Lg=["horizontal","vertical"];function vd(n,s){return Lg.includes(n)?n:s}function ff({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:r=!1,hideHeader:o=!1,panelId:u=null}){const f=pe(S=>S.session?.roomCameras||[]),p=qN(f.map(S=>({id:S.id}))),{value:h,save:x}=Qe("roomCameraPanels",{}),[g,v]=m.useState(()=>vd(u?h?.[u]:n,"horizontal"));m.useEffect(()=>{if(!u)return;const S=h?.[u];S&&v(vd(S,"horizontal"))},[u,h?.[u]]);const y=s?vd(s,"horizontal"):g,N=y==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",M=!r&&!s&&f.length>0,C=S=>{v(S),u&&x(w=>({...w||{},[u]:S}))};return f.length===0?l.jsx(DN,{}):l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&l.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room cameras"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:M&&l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-500",children:"Layout:"}),l.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Lg.map(S=>l.jsx("button",{type:"button",className:`px-1 py-0.5 ${y===S?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>C(S),children:S==="vertical"?"Vertical":"Grid"},S))})]})})]}),l.jsx("div",{className:N,children:f.map(S=>{const w=p[S.id]||null;return l.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:l.jsx(TN,{feed:w,label:S.name||S.id})},S.id)})})]})}function mf(){const n=pe(r=>r.logs),s=m.useMemo(()=>n.slice().reverse(),[n]);return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Server logs"}),l.jsx("span",{children:n.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?l.jsx("p",{children:"No logs yet."}):s.map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.timestamp})," ",l.jsxs("span",{className:"text-lime-400",children:["[",r.level,"]"]})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{children:r.message})]},r.id))})]})}function _N(n){if(!n)return null;if(typeof n=="string"){const s=String(n).trim();return s?{type:"rover",id:s,key:s}:null}if(typeof n=="object"){if(n.type&&n.id){const s=String(n.id);let r=n.key;return r||(r=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:r}}if(n.roverId){const s=String(n.roverId);return{type:"rover",id:s,key:n.key||s}}if(n.roomCameraId){const s=String(n.roomCameraId);return{type:"room",id:s,key:n.key||`room:${s}`}}}return null}function ON(n=[]){const s=new Set,r=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),r.push(o))}),r.sort((o,u)=>o.key.localeCompare(u.key))}function br(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,p]=m.useState({}),h=m.useMemo(()=>Array.isArray(n)?ON(n.map(_N).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const M=h.map(C=>`${C.type}:${C.id}:${C.key}`).join("|");return u?`${M}|v:${u}`:M},[h,u]),g=m.useRef([]),[v,y]=m.useState(0);return m.useEffect(()=>{if(!r)return;const M=()=>y(C=>C+1);return r.on("connect",M),()=>{r.off("connect",M)}},[r]),m.useEffect(()=>{g.current=h},[h]),m.useEffect(()=>{if(!x||!o){p({});return}const M=g.current;let C=!1;function S(w){const j=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};r.emit("video:request",j,(R={})=>{C||p(k=>({...k,[w.key]:R}))})}return M.forEach(w=>{S(w)}),()=>{C=!0}},[r,x,o,v]),m.useMemo(()=>{if(!x||!o)return{};const M={};return h.forEach(C=>{f[C.key]&&(M[C.key]=f[C.key])}),M},[x,f,h])}function hf(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,p]=m.useState({}),h=m.useRef(new Map),x=m.useMemo(()=>n.map(S=>typeof S=="string"?S:S.id).filter(Boolean),[n]),g=m.useMemo(()=>{const S=x.join("|");return u?`${S}|v:${u}`:S},[x,u]),v=m.useRef([]),[y,N]=m.useState(0),M=m.useRef(new Map),C=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const S=()=>N(w=>w+1);return r.on("connect",S),()=>r.off("connect",S)},[r]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{h.current.forEach(S=>URL.revokeObjectURL(S)),h.current.clear(),p({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let S=!1;const w=v.current,j=(k={},E)=>{if(S||!k.id||!E)return;const B=E.byteLength??E.length??0,X=Date.now(),L=M.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},z={count:L.count+1,totalBytes:L.totalBytes+B,lastLogAt:L.lastLogAt};if(C&&(!z.lastLogAt||X-z.lastLogAt>=1e4)){const W=z.count?z.totalBytes/z.count:0;console.log("[roverSnapshot]",k.id,`frame=${B}B`,`avg=${Math.round(W)}B`,`count=${z.count}`),z.lastLogAt=X}M.current.set(k.id,z);const K=new Blob([E],{type:"image/jpeg"}),V=URL.createObjectURL(K),F=h.current.get(k.id);F&&URL.revokeObjectURL(F),h.current.set(k.id,V),p(W=>({...W,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:V}}))},R=(k={})=>{S||!k.id||p(E=>({...E,[k.id]:{...E[k.id]||{},status:k.error?"error":E[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||E[k.id]?.ts||null,objectUrl:E[k.id]?.objectUrl||null}}))};return r.on("roverSnapshot:frame",j),r.on("roverSnapshot:status",R),r.emit("roverSnapshot:subscribe",{ids:w},(k={})=>{k.error}),()=>{S=!0,r.emit("roverSnapshot:unsubscribe",{ids:w}),r.off("roverSnapshot:frame",j),r.off("roverSnapshot:status",R),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,g,o,y,C]),f}const BN={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function LN(n){if(typeof btoa=="function")return btoa(n);if(typeof Buffer<"u")return Buffer.from(n).toString("base64");throw new Error("No base64 encoder available")}function zN(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${LN(s)}`}}class rx{constructor({url:s,token:r,video:o,onStatus:u,audioOnly:f=!1,receiveAudio:p=!0}){this.url=s,this.token=r,this.video=o,this.audioOnly=f,this.receiveAudio=p,this.pc=null,this.abortController=null,this.onStatus=u}notify(s,r){typeof this.onStatus=="function"&&this.onStatus(s,r)}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 s=new RTCPeerConnection(BN);this.pc=s;const r=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(u=>r.addTrack(u)),this.video.srcObject=r,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const u=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...zN(this.token)},body:o.sdp,signal:this.abortController.signal});if(!u.ok)throw new Error(`WHEP request failed: ${u.status}`);const f=await u.text();await s.setRemoteDescription({type:"answer",sdp:f}),s.getReceivers().forEach(p=>{"playoutDelayHint"in p&&(p.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(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function zg(){const{value:n,save:s}=Qe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,u=>{s({hudMapDesktop:!!u})}]}const UN={discord:mg,kofi:Hp,"ko-fi":Hp,wiki:Sj,throne:jj},HN={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 VN(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const s=document.createElement("style");s.id=n,s.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(s)},[])}function $N(n,s){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof s=="string"&&s.trim()?s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function pf({id:n,label:s,url:r,className:o=""}){if(!r)return null;VN();const u=$N(n,s),f=UN[u]||Nj,p=HN[u]||null,h=s||n||"Link";return l.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":h,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 ${p?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:p||void 0,children:[l.jsx(f,{className:"mr-0"}),h]})}const yr=10;function Ug({batteryState:n=null,charge:s=null,config:r=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,u=n?.warnActive??null,f=n?.urgentActive??null,p=r?.Full??null,h=r?.Warn??null,x=r?.Urgent??null,g=s??n?.charge??null;let v=o;if(v==null&&(v=GN({charge:g,full:p,warn:h,urgent:x})),v==null)return{available:!1};const y=Math.max(0,Math.min(1,v/100)),N=u??(h!=null&&g!=null&&g<=h),M=f??(x!=null&&g!=null&&g<=x);return{available:!0,percent:y,percentDisplay:v,warnActive:N,urgentActive:M,warnDisplayPercent:yr}}function GN({charge:n,full:s,warn:r,urgent:o}){if(n!=null&&s!=null&&r!=null&&o!=null&&s>r&&r>o){const u=yr/100,f=1-u;if(n<=o)return 0;if(n<=r){const h=(n-o)/(r-o);return Math.round(Math.max(0,Math.min(1,h))*yr)}if(n>=s)return 100;const p=(n-r)/(s-r);return Math.round((u+Math.max(0,Math.min(1,p))*f)*100)}return null}const YN=1600,FN=800;function Nn(...n){return n.filter(Boolean).join(" ")}function XN({visual:n,orientation:s="horizontal",variant:r="inline",compact:o=!1,showLabel:u,className:f=""}){const p=r==="background",h=s==="vertical",x=u??!p;if(!n?.available){if(p){const W=yr,ie=Nn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),oe=h?{bottom:`${W}%`}:{left:`${W}%`},$=Nn("absolute inset-0 pointer-events-none",f);return l.jsxs("div",{className:$,children:[l.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),l.jsx("div",{className:ie,style:oe})]})}return h?null:l.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,v=Math.max(0,Math.min(100,g)),y=n.warnDisplayPercent??yr,N=!!n.urgentActive,M=!!n.warnActive,C=N?`${FN}ms`:M?`${YN}ms`:void 0,w=p?N||M?"bg-red-500/45":"bg-emerald-500/45":N||M?"bg-red-500":"bg-emerald-500",j=N||M?"bg-red-900/35":"bg-slate-900/35",R=N||M?"bg-red-900/45":"bg-slate-900/35",k=Nn(p?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",h&&!p?"flex flex-col items-center justify-center":"w-full",f);if(p){const W=h?{height:`${v}%`}:{width:`${v}%`},ie=Nn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",N&&"battery-urgent-flash"),oe=Nn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),$=h?{bottom:`${y}%`}:{left:`${y}%`};return l.jsxs("div",{className:k,children:[l.jsx("div",{className:Nn("absolute inset-0",j,N&&"battery-urgent-flash")}),l.jsx("div",{className:ie,style:{...W,animationDuration:C}}),l.jsx("div",{className:oe,style:$})]})}const E=Nn("relative overflow-hidden rounded-sm border border-slate-800",N||M?R:"bg-zinc-900/90",N&&"battery-urgent-flash",h?"w-full flex-1":o?"h-4":"h-5"),B=h?{height:`${v}%`}:{width:`${v}%`},X=Nn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",N&&"battery-urgent-flash"),L=Nn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),z=h?{bottom:`${y}%`}:{left:`${y}%`},K=`Battery ${g}%`,V=Nn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",h?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),F=Nn("rounded px-1.5 py-0.5",p?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return l.jsxs("div",{className:k,children:[l.jsxs("div",{className:E,children:[l.jsx("div",{className:X,style:{...B,animationDuration:C}}),l.jsx("div",{className:L,style:z})]}),x&&!h?l.jsx("div",{className:V,children:l.jsx("span",{className:F,children:K})}):null,x&&h?l.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:l.jsxs("span",{className:F,children:[g,"%"]})}):null]})}const Hd=an.memo(XN);function QN({mobileHud:n=!1,isActiveDriver:s=!1,idleSkipSeconds:r=null}){const o=n?"text-3xl":"text-5xl",u=n?"text-xs":"text-sm",f=n?"text-[0.55rem]":"text-[0.75rem]",p=n?"px-4 py-3":"px-6 py-4",h=s&&typeof r=="number";return l.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:l.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${p}`,children:[l.jsx("div",{className:`font-semibold text-amber-200 ${o}`,children:"IT IS YOUR TURN!"}),l.jsx("div",{className:`text-amber-200/80 ${u}`,children:"Start driving!"}),h?l.jsxs("div",{className:`text-red-100/90 ${f}`,children:["Idle skip in ",r,"s"]}):null]})})}function Mo(n){return Math.max(0,Math.min(1,n))}function Hg(n){return(n-90)*Math.PI/180}function hr(n,s,r,o){const u=Hg(o);return{x:n+r*Math.cos(u),y:s+r*Math.sin(u)}}function KN(n,s,r,o,u){let f=o,p=u;p<=f&&(p+=360);const h=hr(n,s,r,f),x=hr(n,s,r,p);return["M",h.x,h.y,"A",r,r,0,0,1,x.x,x.y].join(" ")}function xf(n,s){if(s)return"#ef4444";const r=Math.abs(n);return r>900?"#f59e0b":r>300?"#22c55e":"#64748b"}function ZN(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Mo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function IN(n,s){if(s)return"#ef4444";const r=Mo(n==null?0:n/4095),o=[47,55,69],u=[245,158,11],[f,p,h]=o.map((x,g)=>Math.round(x+(u[g]-x)*r));return`rgb(${f}, ${p}, ${h})`}function JN({count:n,totalSpan:s,gap:r,startAngle:o}){const f=(s-r*(n-1))/n,p=[];let h=o;for(let x=0;x<n;x+=1){const g=h+f;p.push({start:h,end:g}),h=g+r}return p}function bd({cx:n,cy:s,rInner:r,rOuter:o,startDeg:u,endDeg:f,color:p,pulse:h=!1,opacity:x=1}){const g=(r+o)/2,v=o-r,y=KN(n,s,g,u,f);return l.jsxs(l.Fragment,{children:[l.jsx("path",{d:y,stroke:p,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:x}),h?l.jsx("path",{d:y,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function PN({cx:n,cy:s,rBase:r,rTip:o,startDeg:u,endDeg:f,color:p,value:h,max:x}){const g=(u+f)/2,v=hr(n,s,o,g),y=Mo(h!=null?h/(x||1):0),N=Math.pow(y,.35),M=r-(r-o)*N,C=Math.max(o,Math.min(M,r)),S=hr(n,s,C,u),w=hr(n,s,C,f),j=`M ${v.x} ${v.y} L ${S.x} ${S.y} L ${w.x} ${w.y} Z`;return l.jsx("path",{d:j,fill:p,opacity:1,stroke:"none"})}function ix({cx:n,cy:s,current:r,drop:o,overcurrent:u,label:f}){const p=Math.abs(r),h=Mo(p/1200),x=xf(r,u),g=56,v=14,y=9,N=3,M=g*h,C=f==="L"?-1:1,S=C*(-y/2-N/2),w=C*(v/2+N/2),j=v+y+N+2,R=g+4;return l.jsxs("g",{transform:`translate(${n},${s})`,children:[l.jsx("rect",{x:-j/2,y:-R/2,width:j,height:R,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:S-v/2,y:-g/2,width:v,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),l.jsx("rect",{x:S-v/2,y:g/2-M,width:v,height:M,fill:x,className:u?"animate-pulse":""}),l.jsx("rect",{x:w-y/2,y:-g/2,width:y,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),l.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:f})]})}function WN({cx:n,cy:s,current:r,overcurrent:o}){let u=Math.abs(r);u<10&&(u=0);const f=xf(r*3,o),p=43,h=u>0?.65:null;return l.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:h?`spin ${h}s linear infinite`:"none",animationDirection:h?"reverse":"normal"},children:[l.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const v=Hg(g),y=n+p*Math.cos(v),N=s+p*Math.sin(v);return l.jsx("line",{x1:n,y1:s,x2:y,y2:N,stroke:f,strokeWidth:"4",strokeLinecap:"round"},g)}),o?l.jsx("circle",{cx:n,cy:s,r:p+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function ew({cx:n,cy:s,current:r,overcurrent:o,variant:u,dirtLeft:f,dirtRight:p}){const h=Math.abs(r),x=xf(r,o),g=1,v=96,y=12,N=`main-brush-pattern-a-${u}`,M=`main-brush-pattern-b-${u}`,C=h>0?.6:null,S=r>=0?1:-1;return l.jsxs("g",{children:[l.jsx("defs",{children:[N,M].map((w,j)=>l.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[l.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),l.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),C?l.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${S*(j===0?6:-6)}`,dur:`${C}s`,repeatCount:"indefinite"}):null]},w))}),l.jsx("rect",{x:n-v/2,y:s-14,width:v,height:y,rx:"3",fill:`url(#${N})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:n-v/2,y:s+4,width:v,height:y,rx:"3",fill:`url(#${M})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("circle",{cx:n-v/4,cy:s-8,r:3.5,fill:"#fbbf24"}),l.jsx("circle",{cx:n+v/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?l.jsx("rect",{x:n-v/2-4,y:s-16,width:v+8,height:y*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function tw({sensors:n={},variant:s="full",size:r,overlay:o=!1}){const u=r||(s==="mini"?190:260),f=u/2,p=u*.07,h=f,x=f+p,g=f*.8,v=g-4,y=g+4,N=g-14,M=g-6,C=g*.65,S=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},j=n?.wheelLeftCurrentMa??0,R=n?.wheelRightCurrentMa??0,k=n?.sideBrushCurrentMa??0,E=n?.mainBrushCurrentMa??0,B=6,X=S.bumpLeft?B:0,L=S.bumpRight?B:0,z=JN({count:6,totalSpan:140,gap:6,startAngle:-70}),K=["L","FL","CL","CR","FR","R"],V=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],F=z.map(($,T)=>({label:K[T],start:$.start,end:$.end,value:V[T]})),W=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],ie=V.filter($=>$!=null),oe=ie.length?Math.max(...ie,1200):1200;return l.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${u}px`,height:`${u}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),l.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",oe]})]}),l.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${u} ${u}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[l.jsx("circle",{cx:h,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),l.jsx(ix,{cx:h-C,cy:x,current:j,drop:S.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),l.jsx(ix,{cx:h+C,cy:x,current:R,drop:S.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),l.jsx(WN,{cx:h+g*.65,cy:x-g*.55,current:k,overcurrent:w.sideBrush}),l.jsx(ew,{cx:h,cy:x,current:E,overcurrent:w.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),F.map($=>{const T=ZN($.value,oe),H=y+4,J=H+28;return l.jsx(PN,{cx:h,cy:x,rBase:J,rTip:H,startDeg:$.start,endDeg:$.end,color:T,value:$.value,max:oe},$.label)}),W.map($=>l.jsx(bd,{cx:h,cy:x,rInner:N,rOuter:M,startDeg:$.start,endDeg:$.end,color:IN($.value,$.active),opacity:1,pulse:!!$.active},$.label)),l.jsx(bd,{cx:h,cy:x,rInner:v-X,rOuter:y-X,startDeg:-70,endDeg:-6,color:S.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!S.bumpLeft}),l.jsx(bd,{cx:h,cy:x,rInner:v-L,rOuter:y-L,startDeg:6,endDeg:70,color:S.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!S.bumpRight})]})]})}const Vd=an.memo(tw);function nw({sensors:n,label:s,roverColor:r=null,status:o,audioStatus:u,levelStatus:f,layoutFormat:p="desktop",variant:h="default",driverLabel:x=null,showTopDown:g=!1,mobileHud:v=!1,mapPosition:y="top-center",turnTimerText:N=null,labelScale:M=1}){const C=v,S=p==="mobile-portrait",w=C?"text-[0.45rem]":"text-[0.65rem]",j=C?"px-0.25 py-0.25":"px-1 py-0.5",R=C?"px-0.25 py-0.25":"px-0.5 py-0.5",k=C?"text-[0.55rem]":"text-[0.8rem]",E=C?"left-0.5 top-0.5":"left-1 top-1",B=C?"text-[0.5rem]":"text-[0.7rem]",X=C?"px-0.5 py-0.25":"px-1 py-0.5",L=C?"left-0.5 top-1/2":"left-1 top-1/2",z="bottom-0.5",K={transform:`translateX(-50%) scale(${M})`,transformOrigin:"center bottom"},V="240px",F=S?.3:C?.33:.7,ie={width:V,height:V,opacity:C?.6:.7,transform:y==="top-center"?`translateX(-50%) scale(${F})`:`scale(${F})`,transformOrigin:y==="bottom-left"?"bottom left":y==="top-center"?"top center":"top right",...y==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:y==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(h==="none")return null;if(h==="spectator"){const oe=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],$=!!n?.chargingSources?.homeBase,T=n?.chargingState?.label||"",H=!!(T&&T.toLowerCase()!=="not charging"),J=n?.oiMode?.label||"Unknown",te=J.toLowerCase(),ue=te==="full"?"bg-emerald-500/80 text-emerald-50":te==="safe"?"bg-amber-400/80 text-amber-950":te==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",q=$?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",_=H?"bg-emerald-500/80 text-emerald-50":$?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx("div",{className:`absolute ${E} font-medium text-slate-100 ${w}`,children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",o]}),u?l.jsxs("span",{children:["Audio: ",u]}):null,f?l.jsx("span",{className:"text-cyan-300",children:f}):null]})}),l.jsx("div",{className:`absolute ${L} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${w} ${j}`,children:l.jsxs("div",{className:"space-y-0.5 leading-tight",children:[l.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[l.jsx("span",{className:`rounded px-1.5 py-0.5 ${q}`,children:$?"Docked":"Undocked"}),l.jsx("span",{className:`rounded px-1.5 py-0.5 ${_}`,children:H?"Charging":"Not charging"}),l.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ue}`,children:["OI: ",J]})]}),oe.map(([I,ne])=>l.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:I}),l.jsx("span",{className:"font-semibold text-white",children:ne})]},I))]})}),l.jsx("div",{className:`absolute ${z} left-1/2`,style:K,children:l.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${R} ${k}`,children:[l.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ia(r,.18),children:s||"Unnamed Rover"}),x?l.jsxs("span",{className:"text-slate-300",children:["• ",x]}):null]})})]}),g?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...ie},children:l.jsx(Vd,{sensors:n,size:240,overlay:!0})}):null]})}return l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx("div",{className:`absolute ${E} font-medium text-slate-100 ${w}`,children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",o]}),u?l.jsxs("span",{children:["Audio: ",u]}):null,f?l.jsx("span",{className:"text-cyan-300",children:f}):null]})}),N?l.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${X} ${B}`,children:N}):null,l.jsx("div",{className:`absolute ${z} left-1/2`,style:K,children:l.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${R} ${k}`,children:l.jsxs("span",{children:["Rover:"," ",l.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ia(r,.18),children:['"',s||"Unnamed Rover",'"']})]})})}),g&&h!=="spectator"?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...ie},children:l.jsx(Vd,{sensors:n,size:240,overlay:!0})}):null]})}const aw=an.memo(nw),ox=2e3,sw=3e3,lw=3e3,rw=40,iw=1e3,ow={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function cw({motors:n,fill:s=0,compact:r=!1}){if(!n?.length)return null;const o=n.map(v=>ow[v]||v),u=r?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",f=r?"px-2 py-1":"px-4 py-2",p=r?"text-lg":"text-4xl",h=r?"text-xs":"text-xl",x=Math.max(0,Math.min(1,s)),g=`${Math.round(x*100)}%`;return l.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 ${u}`,children:l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx("div",{className:"absolute inset-0 overflow-hidden",children:l.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),l.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 ${p} ${f}`,children:[l.jsx("div",{children:"OVERCURRENT"}),l.jsx("div",{className:`mt-0 font-medium text-white ${h}`,children:o.join(", ")})]})]})})}const uw=an.memo(cw);function dw({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const r=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",u=s?"text-sm":"text-2xl";return l.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:l.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${u}`,children:l.jsx("div",{children:r})})})}const fw=an.memo(dw);function mw({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],r=s.filter(h=>h!=null).reduce((h,x)=>Math.max(h,x),1200),o=h=>Math.pow(Math.max(0,Math.min(1,(h??0)/r)),.35),u=h=>h==null||h<=0?"hsl(200 60% 18%)":`hsl(${(200+o(h)*360)%360} 100% 60%)`,f=6,p=12;return l.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((h,x)=>{const g=o(h),v=x<f/2?-1:1,y=`${g*100}%`,N=u(h);return l.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${p}px`},children:l.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:l.jsx("div",{className:"h-full",style:{width:y,background:N,float:v===-1?"right":"left"}})})},x)})})}const hw=an.memo(mw);function pw({compact:n=!1}){const s=pe(z=>z.session?.role||null),r=pe(z=>z.session?.assignment?.roverId||null),o=pe(z=>z.session?.roster||[]),{sendMessage:u,onInputFocus:f,onInputBlur:p,blurChat:h,registerInputRef:x,setTypingActive:g}=cf(),{value:v}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[y,N]=m.useState(""),[M,C]=m.useState(!1),S=s!=="spectator",w=s==="spectator",R=!!m.useMemo(()=>o.find(z=>String(z.id)===String(r))||null,[r,o])?.audio?.ttsEnabled,k=m.useMemo(()=>{if(!R)return null;const z=v?.engine==="espeak"?"espeak":"flite";if(z==="espeak"){let V=Number.isFinite(v?.pitch)?Math.round(v.pitch):void 0;return typeof V=="number"&&(V=Math.max(0,Math.min(99,V))),{speak:!0,engine:z,pitch:V}}const K=typeof v?.voice=="string"?v.voice:void 0;return{speak:!0,engine:z,voice:K}},[v?.engine,v?.pitch,v?.voice,R]),E=n?"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",B=n?"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",X=n?"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 L(z){if(z.preventDefault(),!S)return;const K=y.trim();if(K){C(!0);try{await u(K,k),N(""),h(),g(!1)}catch(V){alert(V.message)}finally{C(!1)}}}return w?null:l.jsxs("form",{onSubmit:L,className:E,children:[l.jsx("input",{className:B,value:y,onChange:z=>{const K=z.target.value;N(K),g(!!K.trim())},onFocus:z=>{f(z),g(!!y.trim())},onBlur:z=>{p(z),g(!1)},onKeyDown:z=>{z.key==="Enter"&&!y.trim()&&(z.preventDefault(),h(),g(!1))},ref:z=>x(z,{target:"hud"}),placeholder:S?"Chat (TTS)":"Spectator",disabled:!S}),l.jsx("button",{type:"submit",disabled:!S||M,className:X,children:"Speak"})]})}const xw=m.memo(pw);function Sr({sessionInfo:n,audioSessionInfo:s,videoMode:r="whep",snapshotFeed:o=null,qualityNotice:u=null,label:f,roverColor:p=null,forceMute:h=!1,telemetryFrame:x,batteryConfig:g,layoutFormat:v="desktop",hudVariant:y="default",driverLabel:N=null,hudForceMap:M=!1,hudMapPosition:C="top-center",hudLabelScale:S=1,fitParent:w=!1,overcurrentLimiter:j=null,showTurnCue:R=!1,turnTimerText:k=null,isActiveDriver:E=!1,idleSkipSeconds:B=null}){const X=pe(Se=>(Se.session?.socials||[]).find(qe=>String(qe?.id||qe?.label||"").toLowerCase()==="discord")?.url||null||Se.session?.discord?.invite||null),L=m.useRef(null),z=m.useRef(null),K=m.useRef(null),V=m.useRef(null),F=m.useRef(null),W=m.useRef(null),ie=m.useRef(null),oe=m.useRef(null),[$,T]=m.useState("idle"),[H,J]=m.useState(null),[te,ue]=m.useState("idle"),[q,_]=m.useState(null),[I,ne]=m.useState(0),[me,ce]=m.useState(0),[se,ve]=m.useState(!0),he=!!s?.url,be=r==="snapshot",Ve=x?.sensors,{value:De}=Qe("audio",ut),Te=Number.isFinite(De?.masterVolume)?De.masterVolume:ut.masterVolume,ze=Number.isFinite(De?.roverVolume)?De.roverVolume:ut.roverVolume,$e=typeof De?.mainBrushDuckEnabled=="boolean"?De.mainBrushDuckEnabled:typeof De?.autoLevelEnabled=="boolean"?De.autoLevelEnabled:ut.mainBrushDuckEnabled,vt=Number.isFinite(De?.mainBrushDuckAmount)?Math.max(0,Math.min(1,De.mainBrushDuckAmount)):ut.mainBrushDuckAmount,re=Math.max(0,Math.min(1,Te*ze)),xe=Ve?.batteryChargeMah??null,fe=!(v==="desktop"),we=fe?"top-right":C,[Ae]=zg(),it=M||fe?!0:Ae,le=Ug({charge:xe,config:g}),de=Ve?.wheelOvercurrents||null,Me=m.useMemo(()=>de==null?[]:Object.entries(de).filter(([,Se])=>!!Se).map(([Se])=>Se),[de]),ft=j?.caps||null,kt=j?.overcurrent?.groups||null,ds=m.useMemo(()=>{if(typeof window>"u")return{debugAudio:!1,debugHud:!1};const Se=new URLSearchParams(window.location.search);return{debugAudio:Se.has("debugAudio"),debugHud:Se.has("debugHud")}},[]),Qt=ds.debugAudio,Ba=ds.debugHud,qr=m.useMemo(()=>{if(!ft)return null;const Se=Number.isFinite(ft?.drive?.cap)?ft.drive.cap:1,Ke=Number.isFinite(ft?.aux?.cap)?ft.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(Se,Ke)))},[ft]),En=!!j?.isActive,ot=m.useMemo(()=>{const Se=Me.length?Me:En?["limiter"]:[],Ke=qr??(Me.length?1:0);return{motors:Se,fill:Ke,visible:!!Se.length}},[Me,En,qr]),Ot=!!((Number(Ve?.mainBrushCurrentMa)||0)>rw||Ve?.wheelOvercurrents?.mainBrush),Bt=$e&&Ot?1-vt:1,fs=Math.max(0,Math.min(1,re*Bt)),Bo=$e&&Ot&&vt>0?`Volume decreased ${Math.round(vt*1e3)/10}%`:null,Tr=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Tr.current={hasDedicatedAudio:he,audioUrl:s?.url||null,mainBrushDuckEnabled:$e,mainBrushDuckAmount:vt,mainBrushActive:Ot,baseRoverGain:re,effectiveRoverGain:fs}},[he,s?.url,$e,vt,Ot,re,fs]);const nt=m.useCallback((Se,Ke={})=>{if(!Qt)return;const et=z.current,qe=Tr.current,Ge={event:Se,ts:Date.now(),roverLabel:f||null,hasDedicatedAudio:qe.hasDedicatedAudio,audioUrl:qe.audioUrl,mainBrushDuckEnabled:qe.mainBrushDuckEnabled,mainBrushDuckAmount:qe.mainBrushDuckAmount,mainBrushActive:qe.mainBrushActive,baseRoverGain:qe.baseRoverGain,effectiveRoverGain:qe.effectiveRoverGain,element:et?{muted:et.muted,volume:et.volume,paused:et.paused,ended:et.ended,readyState:et.readyState,networkState:et.networkState}:null,...Ke};try{console.log(`[AudioDebug] ${Se} ${JSON.stringify(Ge)}`)}catch{console.log("[AudioDebug]",Se,Ge)}},[Qt,f]);m.useEffect(()=>{Ba&&console.log("[OvercurrentHUD]",{overlayVisible:ot.visible,overlayMotors:ot.motors,overlayFill:ot.fill,limiterActive:En,limiterCaps:ft,limiterGroups:kt,wheelOvercurrents:de})},[Ba,ot,En,ft,kt,de]),m.useEffect(()=>{nt("settings/update")},[nt]);const kn=m.useCallback(()=>{clearTimeout(K.current),K.current=setTimeout(()=>ne(Date.now()),ox)},[]),ca=m.useCallback(()=>{clearTimeout(V.current),V.current=setTimeout(()=>ce(Date.now()),ox)},[]),ln=m.useCallback(async()=>{const Se=L.current;if(Se)try{Se.muted=!0,await Se.play()}catch{}},[]),La=m.useCallback((Se=0)=>{if(h||he)return;clearTimeout(W.current);const Ke=()=>{clearTimeout(W.current),W.current=setTimeout(()=>{h||et()},sw)},et=async()=>{const qe=L.current;if(qe)try{await ln(),qe.muted=!1,await qe.play(),ve(!1)}catch{qe.muted=!0,ve(!0),Ke()}};W.current=setTimeout(et,Se)},[ln,h,he]);m.useEffect(()=>()=>{clearTimeout(K.current),clearTimeout(V.current),clearTimeout(W.current),clearInterval(F.current),ie.current&&(cancelAnimationFrame(ie.current),ie.current=null)},[]),m.useEffect(()=>{$==="playing"&&La(0)},[$,La]),m.useEffect(()=>{be&&(T("snapshot"),J(null))},[be]),m.useEffect(()=>{if(be||!n?.url||!L.current)return;let Se=!0,Ke;const et=setTimeout(()=>ve(!0),0),qe=(Ge,At)=>{Se&&(nt("video/status",{nextStatus:Ge,info:At||null}),T(Ge),J(At||null),Ge==="playing"&&ln(),["error","failed","disconnected","closed"].includes(Ge)&&kn())};return Ke=new rx({url:n.url,token:n.token,video:L.current,receiveAudio:!he,onStatus:qe}),Ke.start().catch(Ge=>{Se&&(T("error"),J(Ge.message),kn())}),()=>{Se=!1,clearTimeout(et),Ke?.stop()}},[be,n?.url,n?.token,I,kn,ln,he,nt]),m.useEffect(()=>{$==="stopped"&&n?.url&&kn()},[$,n?.url,kn]),m.useEffect(()=>{const Se=z.current;if(!Se||!s?.url){nt("route/no-audio-url"),oe.current=null;return}const Ke=Math.max(0,Math.min(1,fs)),et=oe.current==null?Math.max(0,Math.min(1,Se.volume)):oe.current;if(ie.current&&(cancelAnimationFrame(ie.current),ie.current=null),Ke>et){const qe=performance.now(),Ge=et,At=Ke-Ge,ua=Ua=>{const at=Math.min(1,(Ua-qe)/iw),ct=Ge+At*at;Se.volume=ct,oe.current=ct,at<1?ie.current=requestAnimationFrame(ua):ie.current=null};ie.current=requestAnimationFrame(ua)}else Se.volume=Ke,oe.current=Ke;nt("route/direct",{elementVolume:Ke,duckEnabled:$e,mainBrushActive:Ot,duckAmount:vt})},[s?.url,fs,$e,Ot,vt,nt]),m.useEffect(()=>{if(!s?.url||!z.current)return;let Se=!0,Ke;const et=(qe,Ge)=>{Se&&(nt("audio/status",{nextStatus:qe,info:Ge||null}),_(Ge||(qe==="connected"?"connected":null)),ue(At=>qe==="connected"&&(At==="playing"||At==="connecting")||qe==="new"?At:qe),["error","failed"].includes(qe)&&ca())};return Ke=new rx({url:s.url,token:s.token,video:z.current,audioOnly:!0,onStatus:et}),Ke.start().catch(qe=>{Se&&(ue("error"),_(qe.message),ca())}),()=>{Se=!1,Ke?.stop()}},[s?.url,s?.token,me,ca,nt]),m.useEffect(()=>{const Se=z.current;if(!s?.url||!Se){clearInterval(F.current);return}if(!["connecting","connected","playing","paused"].includes(te)){clearInterval(F.current);return}const et=async()=>{const qe=z.current;qe&&(qe.muted=!1,!(!qe.paused&&!qe.ended)&&(nt("retry/play-attempt"),qe.play().then(()=>{nt("retry/play-ok"),ue(Ge=>Ge==="connected"?"playing":Ge),_(Ge=>Ge==="paused"?null:Ge)}).catch(Ge=>{nt("retry/play-fail",{error:Ge?.message}),_(At=>At||Ge?.message||"autoplay blocked")})))};return et(),F.current=setInterval(et,lw),()=>clearInterval(F.current)},[s?.url,te,nt]),m.useEffect(()=>{const Se=z.current;if(!Se)return;const Ke=()=>{nt("element/play"),ue(at=>at==="error"?at:"playing"),_(null)},et=()=>{nt("element/pause"),ue(at=>["error","failed","disconnected","closed","stopped"].includes(at)?at:"paused"),_(at=>at||"paused")},qe=()=>{nt("element/ended"),ue(at=>at==="error"?at:"stopped"),_(at=>at||"ended")},Ge=()=>{const{error:at}=Se,ct=at?.message||"audio error";nt("element/error",{error:ct}),ue("error"),_(ct)},At=()=>nt("element/waiting"),ua=()=>nt("element/canplay"),Ua=()=>nt("element/stalled");return Se.addEventListener("play",Ke),Se.addEventListener("pause",et),Se.addEventListener("ended",qe),Se.addEventListener("error",Ge),Se.addEventListener("waiting",At),Se.addEventListener("canplay",ua),Se.addEventListener("stalled",Ua),()=>{Se.removeEventListener("play",Ke),Se.removeEventListener("pause",et),Se.removeEventListener("ended",qe),Se.removeEventListener("error",Ge),Se.removeEventListener("waiting",At),Se.removeEventListener("canplay",ua),Se.removeEventListener("stalled",Ua)}},[s?.url,nt]);const za=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",Lo=be?za:n?.url?$==="error"?`Error: ${H||"unknown"}`:H?`${$} (${H})`:$:"waiting",Dr=s?.error?`Error: ${s.error}`:s?.url?te==="error"?`Error: ${q||"unknown"}`:q?`${te} (${q})`:te:null,ms=y==="spectator",Lt=y==="none";return l.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[l.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[be?o?.objectUrl?l.jsx("img",{src:o.objectUrl,alt:f,className:"h-full w-full object-contain",draggable:!1}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):l.jsx("video",{ref:L,muted:h||se||he,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),l.jsx("audio",{ref:z,autoPlay:!0,hidden:!0}),!Lt&&R?l.jsx(QN,{mobileHud:fe,isActiveDriver:E,idleSkipSeconds:B}):null,Lt?null:l.jsx(aw,{sensors:Ve,label:f,roverColor:p,status:Lo,audioStatus:Dr,levelStatus:Bo,layoutFormat:v,variant:y,driverLabel:N,showTopDown:it,mobileHud:fe,mapPosition:we,turnTimerText:k,labelScale:S}),Lt?null:l.jsx(xw,{compact:fe}),!Lt&&Ba?l.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:${ot.visible?1:0} motors:${ot.motors.length} fill:${Math.round(ot.fill*100)}%`}):null,Lt?null:l.jsx(uw,{motors:ot.motors,fill:ot.fill,compact:fe}),Lt?null:l.jsx(fw,{battery:le,compact:fe}),!Lt&&ms&&le.available?l.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:l.jsx(Hd,{visual:le,orientation:"vertical",variant:"inline",compact:fe,className:"h-full w-4"})}):null,!Lt&&u?l.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:l.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${fe?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:"text-center",children:u}),l.jsx("div",{className:"pointer-events-auto mt-0",children:l.jsx(pf,{id:"discord",label:"Join our Discord server while you wait!",url:X})})]})}):null]}),!Lt&&!ms&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(hw,{sensors:Ve}),l.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:l.jsx(Hd,{visual:le,compact:fe})})]})]})}function gf({layoutFormat:n="desktop"}){const s=pe(se=>se.session?.mode||null),r=pe(se=>se.session?.assignment?.roverId??null),o=pe(se=>se.session?.roster??[]),u=pe(se=>se.session?.turnQueues??{}),f=pe(se=>se.session?.socketId||null),p=pe(se=>se.session?.activeDrivers??{}),{state:{song:h,lastControlIntentAt:x},overcurrentLimiter:g}=Dt(),[v,y]=m.useState(()=>Date.now()),[N,M]=m.useState(!1),[C,S]=m.useState(null),w=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s!=="turns")return;const se=setInterval(()=>y(Date.now()),250);return()=>clearInterval(se)},[s]);const R=!!(r&&o?o.find(se=>String(se.id)===String(r)):null)?.media?.audioPublishUrl,k=r?u?.[r]:null,E=r?p?.[r]:null,B=!!(f&&E===f),X=m.useMemo(()=>{const se=k?.queue||[];if(!se.length||!k?.current||se.length<=1)return null;const ve=se.findIndex(he=>he===k.current);return ve===-1?se[0]||null:se[(ve+1)%se.length]||null},[k?.queue,k?.current]),L=!!(f&&X===f),z=k?.deadline||null,K=k?.idleDeadline||null,V=z?z-v:null,F=K?K-v:null,W=s==="turns"&&L&&V!=null&&V<=5e3&&V>0,ie=s!=="turns"||B||W,oe=V!=null&&Number.isFinite(V)?Math.max(0,Math.ceil(V/1e3)):null,$=F!=null&&Number.isFinite(F)?Math.max(0,Math.ceil(F/1e3)):null,T=B?oe!=null?`${oe}s left`:null:L&&oe!=null?`Your turn in ${oe}s`:null,H=r?[...ie?[{type:"rover",id:r,key:r}]:[],...R?[{type:"rover",id:`${r}-audio`,key:`${r}-audio`}]:[]]:[],J=br(H),te=r&&ie?J[r]:null,ue=r&&R?J[`${r}-audio`]:null,q=hf(r?[r]:[],{enabled:!!r,version:s}),_=r&&q[r]||null,I=fl(r),ne=r&&o?o.find(se=>String(se.id)===String(r)):null,me=ne?.battery??null,ce=ne?.name||(r?`Rover ${r}`:"");return m.useEffect(()=>{if(s!=="turns"){M(!1),S(null),w.current={active:!1,roverId:null};return}const se=w.current,ve=B&&!se.active,he=B&&r&&r!==se.roverId;ve||he?(M(!0),S(Date.now())):!B&&se.active&&(M(!1),S(null)),w.current={active:B,roverId:r}},[B,r,s]),m.useEffect(()=>{!N||!C||x>C&&M(!1)},[x,C,N]),l.jsx("section",{className:"panel",children:r?l.jsx(Sr,{sessionInfo:te,videoMode:ie?"whep":"snapshot",snapshotFeed:_,audioSessionInfo:ue,label:ce,roverColor:ne?.color||null,telemetryFrame:I,batteryConfig:me,layoutFormat:n,overcurrentLimiter:g,songNote:h?.note,qualityNotice:ie?null:"Preview feed (low FPS) until your turn.",showTurnCue:N,turnTimerText:T,turnSeconds:oe,isActiveDriver:B,idleSkipSeconds:$}):l.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[l.jsx("p",{children:"You are not assigned to a rover."}),l.jsx("p",{className:"mt-0",children:l.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function So({label:n,tone:s="muted"}){const r=s==="success"?"bg-emerald-900 text-emerald-100":s==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return l.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${r}`,children:n})}function Ro(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function gw(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,r,o]=n,u=Math.max(0,Math.min(255,Number(s)))/255,f=Math.max(0,Math.min(255,Number(r)))/255,p=Math.max(0,Math.min(255,Number(o)))/255,h=Math.max(u,f,p),x=Math.min(u,f,p),g=h-x;if(g===0)return 0;let v=0;return h===u?v=(f-p)/g%6:h===f?v=(p-u)/g+2:v=(u-f)/g+4,Ro(Math.round(v*60))}function cx(n){const s=Ro(n),r=1,o=1-Math.abs(s/60%2-1);let u=0,f=0,p=0;return s<60?(u=r,f=o):s<120?(u=o,f=r):s<180?(f=r,p=o):s<240?(f=o,p=r):s<300?(u=o,p=r):(u=r,p=o),[Math.round(u*255),Math.round(f*255),Math.round(p*255)]}function ux(n){return n?Array.isArray(n.hsColor)?Ro(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?gw(n.rgbColor):0:0}function vw({entity:n,connected:s,controlsLocked:r,onToggle:o,onSetColor:u,onSetWhite:f}){const p=n.state==="unavailable"||!n.available,h=n.state==="on",x=n.type==="light"&&n.supportsColor,g=p?"warn":h?"success":"muted",v=p?"Unavailable":h?"On":"Off",y=r||!s||p,N=y||!x,[M,C]=m.useState(()=>ux(n)),S=m.useRef(M),w=m.useRef(!1),j=p?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":r?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":h?"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(!x||w.current)return;const z=ux(n);S.current=z,C(z)},[n.rgbColor,n.hsColor,x]);const R=z=>{const K=Ro(Number(z.target.value));S.current=K,C(K)},k=()=>{N||!u||u(n.id,cx(S.current))},E=z=>{z.stopPropagation()},B=z=>{E(z),!(N||!f)&&f(n.id)},L=`rgb(${(x?cx(S.current):[255,255,255]).join(",")})`;return l.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:y,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 ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[l.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),x&&l.jsxs(l.Fragment,{children:[l.jsx(So,{label:v,tone:g}),!s&&l.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),x?l.jsx("div",{className:"-mt-0.5 w-full",onClick:E,onPointerDown:z=>{E(z),w.current=!0},onPointerUp:z=>{E(z),w.current=!1,k()},onPointerCancel:z=>{E(z),w.current=!1,k()},onKeyUp:z=>{E(z),k()},onBlur:k,children:l.jsx("div",{className:"relative w-full",children:l.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:M,onChange:R,disabled:N,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsx(So,{label:v,tone:g}),!s&&l.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),x&&l.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[l.jsx("span",{role:"button",tabIndex:N?-1:0,onClick:B,onPointerDown:E,onKeyDown:z=>{N||(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),B(z))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":N,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${N?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),l.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:L}})]}),!x&&l.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:h?"Turn off":"Turn on"})]})}function Vg(){const{state:{keymap:n}}=Dt(),s=pe(N=>N.session?.homeAssistant||null),{homeAssistantToggle:r,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:u}=Xt(),f=m.useMemo(()=>s?.entities||[],[s?.entities]),p=s?.lightPolicy||null,h=!!(p?.locked||p?.lockedOn),x=p?.lockState||(p?.lockedOn?"on":null),g=An(n?.homeAssistantOn?.[0]),v=An(n?.homeAssistantOff?.[0]);if(!s?.enabled)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(f.length===0)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const y=!!s?.connected;return l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room Controls"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length}),h?l.jsx(So,{label:x==="off"?"Locked Off":"Locked On",tone:"warn"}):null,l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"On"}),g?l.jsx(dx,{label:g}):null]}),l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"Off"}),v?l.jsx(dx,{label:v}):null]})]})]}),l.jsx(So,{label:y?"Connected":"Offline",tone:y?"success":"warn"})]}),h?l.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:x==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,l.jsx("div",{className:"flex flex-wrap gap-0.5",children:f.map(N=>l.jsx(vw,{entity:N,connected:y,controlsLocked:h,onToggle:r,onSetColor:o,onSetWhite:u},N.id))})]})}function dx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function $g(){const{login:n,setRole:s}=Xt(),[r,o]=m.useState(""),[u,f]=m.useState(""),[p,h]=m.useState(!1);async function x(g){g.preventDefault(),h(!0);try{await n(r,u),o(""),f("")}catch(v){alert(v.message)}finally{h(!1)}}return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),l.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[l.jsx("input",{className:"field-input",placeholder:"Username",value:r,onChange:g=>o(g.target.value)}),l.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:u,onChange:g=>f(g.target.value)}),l.jsx("button",{type:"submit",disabled:p,className:"button-dark w-full disabled:opacity-50",children:p?"Logging in…":"Login"})]})]})}function fx(...n){return n.filter(Boolean).join(" ")}function bw(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function yw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Sw({title:n,roster:s=[],emptyText:r="No roster data.",renderActions:o=null}){return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),s.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:r}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(u=>{const f=!!(u?.private?.enabled&&u?.private?.open),p=!!u?.locked;return l.jsxs("li",{className:fx("surface flex flex-wrap items-center justify-between gap-0.5",p?"bg-red-900/40":f?"bg-amber-700/35 border border-amber-200/30":null),children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-slate-200",children:l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ia(u.color,.16),children:u.name})}),l.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[l.jsx("span",{children:u.locked?"locked":"free"}),u.lockReason&&l.jsx("span",{className:"rounded bg-black/30 px-1",children:u.lockReason}),l.jsxs("span",{className:fx("font-semibold",yw(u)),children:["Battery ",bw(u)]})]})]}),o?o(u):null]},u.id)})})]})}function jw(n){const s=n?.runtime||{},r=n?.output||{},o=n?.errors||{};return s.inFlight?{label:"IN FLIGHT",detail:s.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:s.outcome==="posted"?{label:"POSTED",detail:r.posted?`Last: ${r.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Nw(n,s){const r=Date.now(),u=(Array.isArray(n)?n:[]).map((f,p)=>{const h=String(f?.role||"").toLowerCase(),x=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),g=h==="system"?"LLM System":h==="assistant"?"LLM Context":h==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${p}`,message:{ts:r+p,nickname:g,text:x,role:"spectator",system:h==="system"}}});if(s!=null){const f=String(s);u.push({id:"llm-output",message:{ts:r+u.length+1,nickname:"LLM Output",text:f.trim()?f:"<empty>",role:"spectator",system:!0}})}return u}function ww({state:n,onClearHistory:s,clearingHistory:r}){const[o,u]=m.useState(null);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.counters||{},h=n.timings||{},x=n.input||{},g=n.output||{},v=n.errors||{},y=Array.isArray(n.history)?n.history:[],N=y.find(w=>w.runId===o)||(y.length?y[y.length-1]:null),M=jw(n),C=Nw(x.modelMessages,g.raw),S=[{label:"running",value:f.running?"yes":"no"},{label:"in flight",value:f.inFlight?"yes":"no"},{label:"phase",value:f.phase||"--"},{label:"run id",value:f.currentRunId??"--"},{label:"tick count",value:f.tickCount??0},{label:"last tick",value:f.lastTickAt?new Date(f.lastTickAt).toLocaleString():"never"},{label:"next run",value:f.nextRunAt?new Date(f.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:f.outcome||"--"},{label:"reason",value:f.reason||"--"},{label:"skip streak",value:p.skipStreak??0},{label:"clear count",value:p.clearCount??0},{label:"last gen",value:h.lastGenerationMs!=null?`${h.lastGenerationMs} ms`:"--"},{label:"avg gen",value:h.avgGenerationMs!=null?`${h.avgGenerationMs} ms`:"--"},{label:"gen count",value:h.generationCount??0},{label:"prompt chars",value:p.promptChars??0},{label:"active drivers",value:p.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:p.snapshotSummary?.rovers??0},{label:"snapshot chat",value:p.snapshotSummary?.chatMessages??0}];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:s,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear LLM History"})}),l.jsxs("div",{className:`surface border text-center ${M.className}`,children:[l.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:M.label}),l.jsx("div",{className:"text-xs text-slate-200",children:M.detail})]}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:S.map(w=>l.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:[w.label,": ",w.value]},w.label))}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.details?l.jsxs("details",{className:"surface text-xs text-red-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(v.details,null,2)})]}):null,g.generated?l.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?l.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),l.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:C.length?C.map(w=>l.jsx(lf,{message:w.message},w.id)):l.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),l.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),l.jsxs("div",{children:["Output at: ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Failed at: ",v.failedAt?new Date(v.failedAt).toLocaleString():"n/a"]})]})]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),l.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:y.length?y.slice().reverse().map(w=>l.jsxs("button",{type:"button",onClick:()=>u(w.runId),className:`w-full text-left surface ${N?.runId===w.runId?"border border-sky-400/50":""}`,children:[l.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",l.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",l.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",l.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):l.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),N?l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",N.runId," details"]}),l.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 Aw({state:n,onClearHistory:s,clearingHistory:r}){const[o,u]=m.useState(!1);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.config||{},h=n.output||{},x=n.timings||{},g=n.input||{},v=n.errors||{},y=()=>{const N=Array.isArray(g.modelMessages)?g.modelMessages:[];return N.length?N.map((M,C)=>{const S=String(M?.role||"unknown").toUpperCase(),w=String(M?.content||"");return`#${C+1} ${S}
|
||
${w}`}).join(`
|
||
|
||
----------------------------------------
|
||
|
||
`):"<none>"};return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:s,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear Overseer History"})}),l.jsxs("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:[l.jsxs("span",{className:"surface-muted",children:["running: ",f.running?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["phase: ",f.phase||"--"]}),l.jsxs("span",{className:"surface-muted",children:["tick: ",f.tickCount??0]}),l.jsxs("span",{className:"surface-muted",children:["trigger: ",f.lastTriggerReason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["name: ",p.name||"--"]}),l.jsxs("span",{className:"surface-muted",children:["model: ",p.model||"--"]}),l.jsxs("span",{className:"surface-muted",children:["observeOnly: ",p.observeOnly?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["decision: ",h.normalized||"--"]}),l.jsxs("span",{className:"surface-muted",children:["outcome: ",h.outcome||"--"]}),l.jsxs("span",{className:"surface-muted",children:["reason: ",h.reason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["last gen: ",x.lastGenerationMs!=null?`${x.lastGenerationMs}ms`:"--"]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Latest Context"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:g.stateUpdate||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Input (messages[])"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:y()})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact System Prompt"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:g.systemPrompt||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Transcript Rows"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(g.transcript||[],null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Tool Availability"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify({available:g.availableTools,blocked:g.blockedTools},null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Output"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:h.raw||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Live Tool Calls"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(h.liveToolCalls||[],null,2)})]}),l.jsxs("div",{className:"surface text-xs text-slate-200",children:[l.jsxs("div",{children:["Normalized decision: ",h.normalized||"--"]}),l.jsxs("div",{children:["Model input at: ",g.modelInputAt?new Date(g.modelInputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Model output at: ",h.outputAt?new Date(h.outputAt).toLocaleString():"n/a"]})]}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300",children:["Error: ",v.message]}):null,l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Recent Runs"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n.history||[],null,2)})]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>u(N=>!N),children:o?"Hide Full Payload":"Show Full Payload"}),o?l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)}):null]})}function Cw({health:n,roster:s=[]}){if(!n)return null;const r=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},u=x=>s.find(g=>String(g.id)===String(x))?.color||null,f=`${r.readyCount}/${r.totalCount} sources ready`,p=o.rovers.filter(x=>x.stale).length,h=o.rooms.filter(x=>x.stale).length;return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Replay segments"}),l.jsx("span",{className:"text-slate-400",children:f})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Rover snapshots"}),l.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rovers.length-p,"/",o.rovers.length," ok"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Room cameras"}),l.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rooms.length-h,"/",o.rooms.length," ok"]})]})]}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:r.sources.map(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:`${x.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:x.type==="rover"?ia(u(x.id),.16):void 0,children:x.label}),l.jsxs("span",{className:x.ready?"text-emerald-300":"text-amber-300",children:[x.recentCount,"/",x.neededCount]})]},`${x.type}:${x.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ia(u(x.id),.16),children:x.name}),l.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.stale?"stale":"ok"})]},`rover:${x.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:x.name}),l.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.error?"error":x.stale?"stale":"ok"})]},`room:${x.id}`))})]})}function Ew({entries:n}){const s=n||[];return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Admin IP log"}),l.jsx("span",{children:s.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?l.jsx("p",{children:"No admin log entries yet."}):s.slice().reverse().map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.ts?new Date(r.ts).toLocaleTimeString():"--"})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{className:"text-slate-200",children:r.message})," ",r.ip&&l.jsx("span",{className:"text-cyan-300",children:r.ip})," ",r.meta&&l.jsx("span",{className:"text-slate-500",children:JSON.stringify(r.meta)})]},r.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const kw=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Mw(){const{session:n,lockRover:s,setMode:r,requestControl:o,setGlobalObjective:u,setAdminReason:f,rebootRover:p,rebootServer:h,setAudioLevels:x,setPrivateSafety:g,llmControl:v,overseerControl:y,adminLogs:N,llmCommentaryState:M,overseerControlState:C}=kr(),S=m.useMemo(()=>n?.roster??[],[n?.roster]),[w,j]=m.useState({}),[R,k]=m.useState({}),[E,B]=m.useState(!1),[X,L]=m.useState(!1),[z,K]=m.useState(!1),V=n?.health||null,F=n?.globalObjective?.text||"",W=n?.globalObjective?.updatedAt||null,[ie,oe]=m.useState(F),$=n?.adminReason?.text||"",T=n?.adminReason?.updatedAt||null,[H,J]=m.useState($),te=n?.audioLevels||{},[ue,q]=m.useState({hornGain:Number.isFinite(te.hornGain)?te.hornGain:1,ttsGain:Number.isFinite(te.ttsGain)?te.ttsGain:1,forwardGain:Number.isFinite(te.forwardGain)?te.forwardGain:1}),[_,I]=m.useState({}),ne=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",me=n?.role==="lockdown"||n?.role==="lockdown-admin",ce=n?.mode??"open",se=async(le,de)=>{try{await s(le,de),j(Me=>({...Me,[le]:de}))}catch(Me){alert(Me.message)}},ve=async le=>{const de=le.target.value;try{await r(de)}catch(Me){alert(Me.message)}},he=async le=>{try{await o(le,{force:!0})}catch(de){alert(de.message)}},be=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){k(Me=>({...Me,[le.id]:!0}));try{await p(le.id)}catch(Me){alert(Me.message)}finally{k(Me=>({...Me,[le.id]:!1}))}}},Ve=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){B(!0);try{await h()}catch(de){alert(de.message),B(!1)}}},De=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){L(!0);try{await v("clearHistory")}catch(de){alert(de.message)}finally{L(!1)}}},Te=async()=>{if(window.confirm("Clear Overseer Control history now?")){K(!0);try{await y("clearHistory")}catch(de){alert(de.message)}finally{K(!1)}}},ze=async()=>{try{await u(ie)}catch(le){alert(le.message)}},$e=async()=>{try{await u(null)}catch(le){alert(le.message)}},vt=async()=>{try{await f(H)}catch(le){alert(le.message)}},re=async()=>{try{await f(null)}catch(le){alert(le.message)}},xe=le=>de=>{const Me=Number(de.target.value);q(ft=>({...ft||{},[le]:Number.isFinite(Me)?Me:1}))},Ee=async()=>{try{await x(ue)}catch(le){alert(le.message)}},fe=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{oe(F)},[F]),m.useEffect(()=>{J($)},[$]),m.useEffect(()=>{q({hornGain:Number.isFinite(te.hornGain)?te.hornGain:1,ttsGain:Number.isFinite(te.ttsGain)?te.ttsGain:1,forwardGain:Number.isFinite(te.forwardGain)?te.forwardGain:1})},[te.forwardGain,te.hornGain,te.ttsGain]),m.useEffect(()=>{const le={};(S||[]).forEach(de=>{de?.private?.enabled&&(le[de.id]={speedLimitEnabled:!!de?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(de?.private?.safety?.speedLimitMaxWheelSpeed)?de.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!de?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(de?.private?.safety?.overcurrentStopMs)?de.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!de?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(de?.private?.safety?.bumpBackoffSpeed)?de.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(de?.private?.safety?.bumpBackoffMs)?de.private.safety.bumpBackoffMs:350,cliffEnabled:!!de?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(de?.private?.safety?.cliffBackoffSpeed)?de.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(de?.private?.safety?.cliffBackoffMs)?de.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(de?.private?.safety?.triggerCooldownMs)?de.private.safety.triggerCooldownMs:800})}),I(le)},[S]);const we=m.useMemo(()=>{const le={};return S.forEach(de=>{le[de.id]=w[de.id]??de.locked}),le},[S,w]),Ae=(le,de={})=>{I(Me=>({...Me||{},[le]:{...Me?.[le]||{},...de||{}}}))},it=async le=>{try{const de=_?.[le];if(!de)return;await g(le,de)}catch(de){alert(de.message)}};return ne?l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[l.jsx("span",{children:"Admin controls"}),l.jsx("select",{value:ce,onChange:ve,className:"field-input text-sm",children:kw.map(le=>l.jsx("option",{value:le.key,children:le.label},le.key))})]}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:Ve,disabled:E,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:E?"Server rebooting...":"Reboot Server"}),l.jsx("button",{type:"button",onClick:fe,className:"button-dark",children:"Test Reward Popup"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?l.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Horn gain"}),l.jsxs("span",{children:[ue.hornGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.hornGain,onChange:xe("hornGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"TTS gain"}),l.jsxs("span",{children:[ue.ttsGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.ttsGain,onChange:xe("ttsGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Forward gain"}),l.jsxs("span",{children:[ue.forwardGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.forwardGain,onChange:xe("forwardGain"),className:"w-full accent-emerald-500"})]}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:Ee,className:"button-dark",children:"Apply audio levels"})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global objective"}),W?l.jsxs("span",{children:["Updated ",new Date(W).toLocaleString()]}):null]}),l.jsx("input",{type:"text",value:ie,onChange:le=>oe(le.target.value),placeholder:"Set a global objective",className:"field-input text-sm"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:ze,className:"button-dark",children:"Set objective"}),l.jsx("button",{type:"button",onClick:$e,className:"button-danger",children:"Clear"})]})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Admin mode reason"}),T?l.jsxs("span",{children:["Updated ",new Date(T).toLocaleString()]}):null]}),l.jsx("textarea",{value:H,onChange:le=>J(le.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:vt,className:"button-dark",children:"Set reason"}),l.jsx("button",{type:"button",onClick:re,className:"button-danger",children:"Clear"})]})]}),l.jsx(Sw,{roster:S,renderActions:le=>l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:()=>se(le.id,!we[le.id]),className:"button-dark",children:we[le.id]?"Unlock":"Lock"}),l.jsx("button",{type:"button",onClick:()=>he(le.id),className:"button-dark",children:"Force"}),l.jsx("button",{type:"button",onClick:()=>be(le),disabled:!!R[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:R[le.id]?"Rebooting...":"Reboot"}),le?.private?.enabled?l.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[l.jsx("div",{className:"text-slate-300",children:"Private safety"}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.speedLimitEnabled,disabled:!me,onChange:de=>Ae(le.id,{speedLimitEnabled:!!de.target.checked})}),l.jsx("span",{children:"Speed limit"})]}),l.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!me,value:_?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:de=>Ae(le.id,{speedLimitMaxWheelSpeed:Number(de.target.value)||250})}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.hardOvercurrentEnabled,disabled:!me,onChange:de=>Ae(le.id,{hardOvercurrentEnabled:!!de.target.checked})}),l.jsx("span",{children:"Hard overcurrent"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.hardBumpEnabled,disabled:!me,onChange:de=>Ae(le.id,{hardBumpEnabled:!!de.target.checked})}),l.jsx("span",{children:"Hard bump"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.cliffEnabled,disabled:!me,onChange:de=>Ae(le.id,{cliffEnabled:!!de.target.checked})}),l.jsx("span",{children:"Cliff safety"})]}),l.jsx("button",{type:"button",disabled:!me,onClick:()=>it(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),l.jsx(Cw,{health:V,roster:S}),l.jsx(ww,{state:M,onClearHistory:De,clearingHistory:X}),l.jsx(Aw,{state:C,onClearHistory:Te,clearingHistory:z}),l.jsx(Ew,{entries:N})]}):null}const Rw=[{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:"micPtt",label:"Mic Push To Talk",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 qw(n){return n.reduce((s,r)=>((s[r.group]||(s[r.group]=[])).push(r),s),{})}function Tw(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):s}const vf=5,jr=500,Nr=1,bf=100;function Dw(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(vf,Math.min(jr,r)):s}function mo(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(Nr,Math.min(bf,r)):s}function _w(n){const r=(mo(n,n)-Nr)/(bf-Nr),o=jr-r*(jr-vf);return Math.round(o)}function Ow(n){const s=Dw(n,n),r=(jr-s)/(jr-vf),o=Nr+r*(bf-Nr);return Math.round(o)}function Bw(n){const[s,r]=m.useState(null),o=m.useCallback(p=>{rd(!0),r(p)},[]),u=m.useCallback(()=>{rd(!1),r(null)},[]),f=m.useCallback((p,h)=>{if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){u();return}const x=Rr(h.key??"");x&&(n(p,x,h),u())},[u,n]);return m.useEffect(()=>()=>rd(!1),[]),{active:s,startCapture:o,cancel:u,captureFromEvent:f}}function eo({label:n,description:s,value:r,onChange:o,min:u=0,max:f=500,step:p=5}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("input",{type:"number",min:u,max:f,value:r,onChange:h=>o(h.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"})]}),s&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),l.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[l.jsx("input",{type:"range",min:u,max:f,step:p,value:r,onChange:h=>o(h.target.value),className:"h-2 flex-1 accent-emerald-400"}),l.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:r})]})]})}function Lw(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:r}}=Dt(),{value:o,save:u}=Qe("inputs",Dn),f={...Dn.keyboard,...o.keyboard??{}},p=m.useMemo(()=>typeof f.tiltSpeed=="number"?mo(f.tiltSpeed,Dn.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?mo(Ow(f.tiltIntervalMs),Dn.keyboard.tiltSpeed):Dn.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),h=m.useMemo(()=>qw(Rw),[]),{active:x,startCapture:g,cancel:v,captureFromEvent:y}=Bw((S,w)=>{s(S,w)}),N=m.useCallback(S=>n?.[S]?.[0]||mr[S]?.[0]||"",[n]),M=m.useCallback((S,w)=>{const j=Dn.keyboard,R=Tw(w,j[S]);u(k=>({...k??{},keyboard:{...k?.keyboard??j,[S]:R}}))},[u]),C=m.useCallback(S=>{const w=Dn.keyboard,j=mo(S,w.tiltSpeed),R=_w(j);u(k=>({...k??{},keyboard:{...k?.keyboard??w,tiltSpeed:j,tiltIntervalMs:R}}))},[u]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),l.jsx("button",{type:"button",onClick:()=>r(),className:"button-dark text-xs",children:"Reset defaults"})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(eo,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:S=>M("baseSpeed",S)}),l.jsx(eo,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:S=>M("turboSpeed",S)}),l.jsx(eo,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:S=>M("precisionSpeed",S)})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),l.jsx(eo,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:p,onChange:C,min:1,max:100,step:1})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([S,w])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.75rem] text-slate-400",children:S}),l.jsx("div",{className:"space-y-0.5",children:w.map(j=>{const R=N(j.id),k=x===j.id;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:j.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:An(R)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[k&&l.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),l.jsx("button",{type:"button",onClick:()=>g(j.id),onKeyDown:k?E=>y(j.id,E):void 0,autoFocus:k,className:`${k?"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:k?"Press a key…":"Change"})]})]},j.id)})})]},S))})]})}const aa=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),zw=[{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"}],mx=.45,Uw=.6;function cr({label:n,description:s,min:r,max:o,step:u,value:f,onChange:p}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("span",{className:"font-mono text-slate-400",children:aa.format(f)})]}),s&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),l.jsx("input",{type:"range",min:r,max:o,step:u,value:f,onChange:h=>p(Number(h.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function Hw(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const s=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${s?` (${s})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const s=n.direction<0?"<":">";return`Axis ${n.index} ${s} ${aa.format(n.threshold??.6)}`}return"Unassigned"}function Vw(n){return n.reduce((s,r)=>((s[r.section]||(s[r.section]=[])).push(r),s),{})}function $w(n,s){if(!n||n.length===0)return null;if(s){const r=n.find(o=>o.signature===s);if(r)return r}return n[0]}function Gw(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0}))}}function Yw(n,s,r){const o=(n.axes??[]).map((f,p)=>({index:p,delta:Math.abs((f??0)-(s.axes?.[p]??0)),value:f}));if(o.sort((f,p)=>p.delta-f.delta),r.kind==="axisPair"){const f=o.filter(p=>p.delta>mx).slice(0,2);return f.length<2?null:{kind:"axisPair",x:f[0].index,y:f[1].index,...r.invertDefaults??{}}}const u=o.find(f=>f.delta>mx);return u?{kind:"axis",index:u.index,...r.invertDefaults??{}}:null}function Fw(n,s,r){const o=n.buttons??[];for(let f=0;f<o.length;f+=1){const p=o[f],h=typeof p?.value=="number"?p.value:p?.pressed?1:0;if(p?.pressed||h>Uw)return r.kind==="axis"?{kind:"buttonAxis",index:f}:{kind:"button",index:f}}const u=n.axes??[];for(let f=0;f<u.length;f+=1){const p=u[f]??0,h=Math.abs(p-(s.axes?.[f]??0));if(Math.abs(p)>.7&&h>.5)return r.kind==="axis"?{kind:"axis",index:f,...r.invertDefaults??{}}:{kind:"axisButton",index:f,direction:p>=0?1:-1,threshold:.6}}return null}function Xw(n,s,r){if(!n)return null;if(r.kind==="axis"||r.kind==="axisPair"){const o=Yw(n,s,r);if(o)return o}return Fw(n,s,r)}function Qw(){const n=hN(),{value:s,save:r}=Qe("gamepad",_a),[o,u]=m.useState(null),f=m.useRef(null),p=m.useMemo(()=>Vw(zw),[]),h=m.useMemo(()=>$w(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=h?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??sa:s?.defaults?.profile??sa,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!h||!x||s?.profiles?.[x]||r(w=>{const j=w??_a;if(j.profiles?.[x])return j;const R=j?.defaults?.profile??sa,k=Cg(h,R);return{...j,profiles:{...j.profiles??{},[x]:k}}})},[h,x,s?.profiles,r]),m.useEffect(()=>{f.current=null},[o,x]),m.useEffect(()=>{if(!o||!h)return;if(!f.current){f.current=Gw(h);return}const w=Xw(h,f.current,o);w&&(r(j=>{const R=j??_a,k=R.profiles?.[x]??R?.defaults?.profile??sa,E={...k,bindings:{...k.bindings??{},[o.id]:{...k.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...R,profiles:{...R.profiles??{},[x]:E}}}),u(null))},[h,x,o,r]);const v=m.useCallback(w=>{r(j=>({...j??_a,activeSignature:w||null}))},[r]),y=m.useCallback(w=>{r(j=>{const R=j??_a,k=(x&&R.profiles?.[x])??R?.defaults?.profile??sa,E={...k,calibration:{...k.calibration??{},...w}};return x?{...R,profiles:{...R.profiles??{},[x]:E}}:{...R,defaults:{...R.defaults??{},profile:E}}})},[x,r]),N=m.useCallback((w,j)=>{r(R=>{const k=R??_a,E=(x&&k.profiles?.[x])??k?.defaults?.profile??sa,B=j(E.bindings?.[w]??{}),X={...E,bindings:{...E.bindings??{},[w]:B}};return x?{...k,profiles:{...k.profiles??{},[x]:X}}:{...k,defaults:{...k.defaults??{},profile:X}}})},[x,r]),M=m.useCallback(w=>{N(w.id,j=>({...j,sources:[]}))},[N]),C=m.useCallback((w,j)=>{N(w.id,R=>{const k=Array.isArray(R.sources)?[...R.sources]:[];if(!k[0])return R;const E={...k[0]};return j==="invertX"?E.invertX=!E.invertX:j==="invertY"?E.invertY=!E.invertY:E.invert=!E.invert,k[0]=E,{...R,sources:k}})},[N]),S=m.useMemo(()=>h?{outputs:Eg(h,g)}:null,[h,g]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:h?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&l.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[l.jsx("select",{value:x??"",onChange:w=>v(w.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(w=>l.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:h?.mapping??"unknown"})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(cr,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:w=>y({driveDeadzone:w})}),l.jsx(cr,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:w=>y({cameraDeadzone:w})}),l.jsx(cr,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:w=>y({auxDeadzone:w})}),l.jsx(cr,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:w=>y({auxSideScale:w})}),l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),l.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:w=>y({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[l.jsx("option",{value:"absolute",children:"Absolute"}),l.jsx("option",{value:"velocity",children:"Velocity"})]})]}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),l.jsx(cr,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:w=>y({cameraSensitivity:w})})]})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([w,j])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),l.jsx("div",{className:"space-y-0.5",children:j.map(R=>{const E=g.bindings?.[R.id]?.sources?.[0]??null;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:R.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Hw(E)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[R.kind==="axisPair"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:!E,onClick:()=>C(R,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),l.jsx("button",{type:"button",disabled:!E,onClick:()=>C(R,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),R.kind==="axis"&&l.jsx("button",{type:"button",disabled:!E,onClick:()=>C(R),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),l.jsx("button",{type:"button",onClick:()=>M(R),className:"button-dark text-[0.7rem]",children:"Clear"}),l.jsx("button",{type:"button",onClick:()=>u(R),className:`${o?.id===R.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===R.id?"Waiting…":"Capture"})]})]},R.id)})})]},w))}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),h?l.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[l.jsx("p",{className:"text-slate-400",children:"Raw axes"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.axes.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["A",j,": ",aa.format(w)]},`axis-${j}`))}),l.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.buttons.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["B",j,": ",aa.format(w.value)," ",w.pressed?"●":""]},`btn-${j}`))}),S?.outputs&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",aa.format(S.outputs.driveVector.x),","," ",aa.format(S.outputs.driveVector.y)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",aa.format(S.outputs.cameraAxis)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",aa.format(S.outputs.auxAxis.main)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",aa.format(S.outputs.auxAxis.side)]})]})]})]}):l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const Kw={drive:"Drive wheels",aux:"Aux motors"};function hx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function Zw({value:n,color:s="bg-emerald-500"}){const r=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return l.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:l.jsx("div",{className:`h-full ${s}`,style:{width:r}})})}function Iw(){const{state:{roverId:n},overcurrentLimiter:s}=Dt(),r=m.useMemo(()=>is.map(o=>o.key),[]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Overcurrent limiter"}),l.jsx("span",{children:s?.adminImmune?"Admin immune":"Active"})]}),n?l.jsxs("div",{className:"space-y-0.5",children:[r.map(o=>{const u=s?.caps?.[o]?.cap??0,f=s?.overcurrent?.groups?.[o]??!1,p=s?.scales?.perGroup?.[o]??1;return l.jsxs("div",{className:"surface space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-slate-200",children:Kw[o]||o}),l.jsx("span",{className:f?"text-red-300":"text-slate-400",children:f?"overcurrent":"ok"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Cap"}),l.jsx("span",{children:hx(u)})]}),l.jsx(Zw,{value:u,color:"bg-amber-500"}),l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Scale"}),l.jsx("span",{children:hx(p)})]})]})]},o)}),l.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),l.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),l.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Gg=m.createContext(null);function Yg(){const n=m.useContext(Gg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const px={primary:{base:"flex-1 px-0.5 py-0.5 text-sm font-medium 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"}},xx={none:"",pink:"bg-pink-500 text-white border-pink-200 hover:bg-pink-400",green:"bg-emerald-500 text-white border-emerald-200 hover:bg-emerald-400"},Fg="primary";function yf(...n){return n.filter(Boolean).join(" ")}function Sf({children:n,defaultTab:s,currentTab:r,onTabChange:o,variant:u=Fg}){const[f,p]=m.useState(s??null),[h,x]=m.useState([]),g=m.useCallback(M=>M?(x(C=>C.includes(M)?C:[...C,M]),()=>x(C=>C.includes(M)?C.filter(S=>S!==M):C)):()=>{},[]),v=r??f??h[0]??null;m.useEffect(()=>{s&&r===void 0&&p(s)},[s,r]);const y=m.useCallback(M=>{M&&(r===void 0&&p(M),o&&o(M))},[r,o]),N=m.useMemo(()=>({activeTab:v,setActiveTab:y,registerTab:g,variant:u}),[v,y,g,u]);return l.jsx(Gg.Provider,{value:N,children:n})}function jf({children:n,className:s=""}){return l.jsx("div",{className:yf("flex gap-0.5",s),children:n})}function tn({id:n,children:s,className:r="",disabled:o=!1,highlight:u="none"}){const{activeTab:f,setActiveTab:p,registerTab:h,variant:x}=Yg();m.useEffect(()=>h(n),[n,h]);const g=px[x]??px[Fg],v=f===n,y=xx[u]||xx.none,N=yf(g.base,y||(v?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",r);return l.jsx("button",{type:"button",className:N,onClick:()=>!o&&p(n),"aria-pressed":v,"aria-disabled":o,children:s})}function Nf({children:n,className:s=""}){return l.jsx("div",{className:yf("mt-0 space-y-0.5",s),children:n})}function nn({id:n,children:s,keepMounted:r=!1}){const{activeTab:o}=Yg(),u=o===n;return!u&&!r?null:!u&&r?l.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):l.jsx(l.Fragment,{children:s})}function Jw(){const{session:n}=kr(),s=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return l.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),l.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:s})]})}const gx=300,vx=240;function Pw(n,s){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(s||(s=new WeakSet),typeof n=="object"){if(s.has(n))return"[Circular]";s.add(n)}try{return JSON.stringify(n,(r,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function Ww(n){const r=n.map(o=>Pw(o)).join(" ");return r.length>vx?`${r.slice(0,vx)}…`:r}function eA(){const n=sn(),[s,r]=m.useState([]),o=m.useMemo(()=>s.reduce((u,f)=>(f.direction==="in"&&(u.in+=1),f.direction==="out"&&(u.out+=1),u),{in:0,out:0}),[s]);return m.useEffect(()=>{const u=(x,g,v)=>{r(y=>{const N=[...y,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:Ww(v),timestamp:new Date().toLocaleTimeString()}];return N.length>gx?N.slice(-gx):N})},f=(x,...g)=>u("in",x,g),p=(x,...g)=>u("out",x,g);n.onAny(f);let h=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(p),h=()=>n.offAnyOutgoing(p);else{const x=n.emit.bind(n);n.emit=(g,...v)=>(p(g,...v),x(g,...v)),h=()=>{n.emit=x}}return()=>{n.offAny(f),h&&h()}},[n]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Socket activity"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),l.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>r([]),children:"Clear"})]})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?l.jsx("p",{children:"No socket activity yet."}):s.slice().reverse().map(u=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-slate-400",children:u.timestamp})," ",l.jsxs("span",{className:u.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",u.direction.toUpperCase(),"]"]})," ",l.jsx("span",{className:"text-cyan-300",children:u.event})," ",l.jsx("span",{className:"text-slate-200",children:u.payload})]},u.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const tA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Xg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:r}}=Dt(),o=!!n,[u,f]=zg(),p=sn(),{value:h,save:x}=Qe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:v}=Qe("audio",ut),y=h?.connectionTransport||"websocket",N=!!h?.swapMobileControlColumns,M=typeof h?.driveMacroBackoffEnabled=="boolean"?h.driveMacroBackoffEnabled:!0,C=Number.isFinite(g?.masterVolume)?g.masterVolume:ut.masterVolume,S=Number.isFinite(g?.alertVolume)?g.alertVolume:ut.alertVolume,w=Number.isFinite(g?.roverVolume)?g.roverVolume:ut.roverVolume,j=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:ut.mainBrushDuckEnabled,R=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):ut.mainBrushDuckAmount,k=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),E=V=>{n&&r(V)},B=V=>{const F=V.target.value;x(W=>({...W??{},connectionTransport:F})),p?.io?.opts&&(p.io.opts.transports=F==="polling"?["polling"]:["websocket","polling"],p.disconnect(),p.connect())},X=V=>F=>{const W=Number(F.target.value),ie=Number.isFinite(W)?Math.max(0,Math.min(1,W)):0;v(oe=>({...oe??{},[V]:ie}))},L=V=>{const F=!!V.target.checked;v(W=>({...W??{},mainBrushDuckEnabled:F}))},z=V=>{const F=!!V.target.checked;x(W=>({...W??{},swapMobileControlColumns:F}))},K=V=>{const F=!!V.target.checked;x(W=>({...W??{},driveMacroBackoffEnabled:F}))};return l.jsxs(Sf,{defaultTab:"keybindings",children:[l.jsxs(jf,{children:[l.jsx(tn,{id:"keybindings",children:"Keybindings"}),l.jsx(tn,{id:"controller",children:"Controller"}),l.jsx(tn,{id:"page",children:"Page settings"}),l.jsx(tn,{id:"admin",children:"Admin"})]}),l.jsxs(Nf,{children:[l.jsx(nn,{id:"keybindings",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Lw,{})})}),l.jsx(nn,{id:"controller",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Qw,{})})}),l.jsx(nn,{id:"page",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"HUD"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:u,onChange:V=>f(V.target.checked)}),l.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:N,onChange:z}),l.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Macros"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:M,onChange:K}),l.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Audio"}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Master volume"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(C*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:C,onChange:X("masterVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Alert/page sounds"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(S*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:S,onChange:X("alertVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Rover audio"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:X("roverVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Main brush ducking"}),l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:j,onChange:L})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Main brush duck amount"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(R*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:R,onChange:X("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!j})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Connection"}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Transport"}),l.jsxs("select",{value:y,onChange:B,className:"field-input text-sm",children:[l.jsx("option",{value:"websocket",children:"WebSocket"}),l.jsx("option",{value:"polling",children:"Polling"})]})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),l.jsx(nn,{id:"admin",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:tA.map(V=>l.jsx("button",{type:"button",onClick:()=>s(V.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:V.label},V.key))})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),l.jsx("div",{className:"surface flex gap-0.5",children:k.map(V=>l.jsx("button",{type:"button",onClick:()=>E(V.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:V.label},V.key))}),!o&&l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),l.jsx($g,{}),l.jsx(Iw,{}),l.jsx(Mw,{}),l.jsx(Jw,{}),l.jsx(eA,{})]})})]})]})}const bx={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 column to move the rover, and hold the aux buttons in the other control column."]},{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 column beside the video feed to move the rover, and hold the aux buttons in the other control column."]},{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 nA(n){return bx[n]||bx.desktop}function Qg({actionId:n,keymap:s}){const r=s?.[n]?.[0]??"";return l.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:An(r)})}function yx(n,s){return n.map((r,o)=>typeof r=="string"?l.jsx("span",{children:r},`text-${o}`):r?.action?l.jsx(Qg,{actionId:r.action,keymap:s},`pill-${r.action}-${o}`):r?.text?l.jsx("span",{children:r.text},`span-${o}`):null)}function qo(n,s,r){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return yx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return yx(n,s)}return String(n??"")}function aA({hero:n,keymap:s}){return n?l.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&l.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&l.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(r=>l.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:r},r))})]}),n.bullets&&l.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((r,o)=>{const u=Array.isArray(r?.segments)?`hero-${o}`:`hero-${o}`;return l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(r,s)},u)})})]}):null}function sA({block:n,keymap:s}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((r,o)=>{const u=`item-${o}`;return l.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:qo(r,s)},u)})})]})}function lA({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return l.jsxs("div",{className:`surface space-y-0.5 border ${s} px-0.5 py-0.5`,children:[l.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((r,o)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(r,{})},`callout-${o}`))})]})}function rA({group:n,keymap:s}){return l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),l.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(r=>l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[l.jsx("span",{className:"text-slate-200",children:r.label}),l.jsx(Qg,{actionId:r.action,keymap:s})]},r.action))})]})}function iA({block:n,keymap:s}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(r=>l.jsx(rA,{group:r,keymap:s},r.id))})]}):null}function oA({block:n}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((s,r)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(s,{})},`gamepad-${r}`))})]}):null}function Sx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return l.jsx(sA,{block:n,keymap:s});case"callout":return l.jsx(lA,{block:n});case"keyboard":return l.jsx(iA,{block:n,keymap:s});case"gamepad":return l.jsx(oA,{block:n});default:return null}}function Kg({layout:n,keymap:s}){const r=m.useMemo(()=>nA(n),[n]),o=s||{},u=r.main||[],f=r.aside||[];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(aA,{hero:r.hero,keymap:o}),l.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[l.jsx("div",{className:"space-y-0.5",children:u.map((p,h)=>l.jsx(Sx,{block:p,keymap:o},p.title||h))}),l.jsx("div",{className:"space-y-0.5",children:f.map((p,h)=>l.jsx(Sx,{block:p,keymap:o},p.title||h))})]})]})}function Zg({layout:n,onOpenOverlay:s}){const{state:r}=Dt();return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Help"}),l.jsx("button",{type:"button",onClick:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),l.jsx(Kg,{layout:n,keymap:r?.keymap||{}})]})}const cA=["kal","rms","slt","ksp","bdl"],uA=Array.from({length:10},(n,s)=>s*10);function To({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:r=!1,allowSpectatorInput:o=!1}){const u=pe(_=>_.session?.role||null),f=pe(_=>_.session?.assignment?.roverId||null),p=pe(_=>_.session?.roster??[]),{messages:h,typing:x,sendMessage:g,registerInputRef:v,onInputFocus:y,onInputBlur:N,blurChat:M,setTypingActive:C}=cf(),{value:S,save:w}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[j,R]=m.useState(""),[k,E]=m.useState(!1),[B,X]=m.useState(!1),[L,z]=m.useState(()=>S?.engine||"flite"),[K,V]=m.useState(()=>S?.voice||"rms"),[F,W]=m.useState(()=>Number.isFinite(S?.pitch)?S.pitch:50),ie=u!=="spectator"||o,oe=m.useRef(null),T=!!m.useMemo(()=>p.find(_=>String(_.id)===String(f))||null,[f,p])?.audio?.ttsEnabled,H=m.useMemo(()=>h.slice(-200),[h]),J=m.useMemo(()=>x||[],[x]);m.useEffect(()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)},[H,J]),m.useEffect(()=>{const _=S?.engine||"flite",I=S?.voice||"rms",ne=Number.isFinite(S?.pitch)?S.pitch:50;L!==_&&z(_),K!==I&&V(I),F!==ne&&W(ne)},[L,F,S?.engine,S?.pitch,S?.voice,K]),m.useEffect(()=>{X(!!T)},[T]);const te=m.useMemo(()=>!T||!B?null:L==="espeak"?{speak:!0,engine:L,pitch:F}:{speak:!0,engine:L,voice:K},[L,F,B,T,K]);async function ue(_){if(_.preventDefault(),!ie||n)return;const ne=j.replace(/\\n/g,`
|
||
`).trim();if(ne){E(!0);try{await g(ne,te),R(""),M(),C(!1)}catch(me){alert(me.message)}finally{E(!1)}}}const q=r?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${r?"flex h-full flex-col overflow-hidden":""}`,children:[l.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${q}`,ref:oe,children:[H.length===0&&J.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):H.map(_=>l.jsx(lf,{message:_},_.id)),J.map(_=>l.jsx(xg,{message:_},`typing-${_.typingId||_.id}`))]}),!n&&l.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ue,children:[l.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:j,onChange:_=>{const I=_.target.value;R(I),C(!!I.trim())},onFocus:_=>{y(_),C(!!j.trim())},onBlur:_=>{N(_),C(!1)},onKeyDown:_=>{_.key==="Enter"&&!j.trim()&&(_.preventDefault(),M(),C(!1))},ref:_=>v(_,{target:"panel"}),placeholder:ie?"Type a message…":s?"":"Spectators cannot chat",disabled:!ie}),T&&l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:B,onChange:_=>X(_.target.checked),className:"accent-cyan-500"}),l.jsx("span",{children:"Speak"})]}),l.jsxs("select",{value:L,onChange:_=>{const I=_.target.value;z(I),w(ne=>({...ne||{},engine:I}))},className:"field-input text-xs",children:[l.jsx("option",{value:"flite",children:"flite"}),l.jsx("option",{value:"espeak",children:"espeak"})]}),L==="flite"?l.jsx("select",{value:K,onChange:_=>{const I=_.target.value;V(I),w(ne=>({...ne||{},voice:I}))},className:"field-input text-xs",children:cA.map(_=>l.jsx("option",{value:_,children:_},_))}):l.jsx("select",{value:F,onChange:_=>{const I=Number(_.target.value);W(I),w(ne=>({...ne||{},pitch:I}))},className:"field-input text-xs",children:uA.map(_=>l.jsxs("option",{value:_,children:["pitch ",_]},_))})]}),l.jsx("button",{type:"submit",disabled:!ie||k,className:"button-dark h-full disabled:opacity-50 self-stretch",children:k?"...":"Send"})]})]})}function Do({compact:n=!1}){const s=pe(y=>y.session?.role||null),{setNickname:r}=Xt(),{value:o,save:u}=Qe("profile",{nickname:""}),[f,p]=m.useState(o.nickname||""),[h,x]=m.useState(!1),g=s!=="spectator";m.useEffect(()=>{p(o.nickname||"")},[o.nickname]);async function v(y){if(y.preventDefault(),!g)return;const N=(f||"").trim().slice(0,32);if(N){x(!0);try{await r(N),u({nickname:N})}catch(M){alert(M.message)}finally{x(!1)}}}return l.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[l.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:y=>p(y.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),l.jsx("button",{type:"submit",disabled:!g||h,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:h?"Saving…":n?"Set":"Save"})]})}function dA({socials:n,discordInvite:s,kofiLink:r}){const o=Array.isArray(n)?n:null;if(o&&o.length)return o;const u=[];return s&&u.push({id:"discord",label:"Discord",url:s}),r&&u.push({id:"kofi",label:"Ko-fi",url:r}),u}function fA(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,r=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:r,url:o}:null}function Ig({className:n=""}){const s=pe(o=>({socials:o.session?.socials??[],discordInvite:o.session?.discord?.invite||null,kofiLink:o.session?.kofi?.link||null})),r=dA(s).map(fA).filter(Boolean).slice(0,4);return r.length?l.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:r.map(o=>l.jsx(pf,{...o},`${o.id||o.label}-${o.url}`))}):null}function mA({compact:n=!1}){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(Do,{compact:n})})})}function hA(){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx(Ig,{className:"flex-1 min-h-0"})})}function yd(...n){return n.filter(Boolean).join(" ")}function pA(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function xA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function gA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function vA(n,s){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${r} (you)`:r}function _o({title:n="Rovers"}){const s=pe(j=>j.session?.role||null),r=pe(j=>j.session?.roster??[]),o=pe(j=>j.session?.turnQueues??{}),u=pe(j=>j.session?.users??[]),f=pe(j=>j.session?.socketId||null),{requestControl:p}=Xt(),[h,x]=m.useState({}),[g,v]=m.useState(()=>Date.now()),y=m.useMemo(()=>s&&s!=="spectator",[s]),N=m.useMemo(()=>s==="admin"||s==="lockdown"||s==="lockdown-admin",[s]),M=m.useMemo(()=>Object.values(o||{}).some(j=>j?.deadline||j?.idleDeadline),[o]);m.useEffect(()=>{if(!M)return;const j=setInterval(()=>{v(Date.now())},1e3);return()=>clearInterval(j)},[M]);const C=m.useMemo(()=>{const j=new Set(r.map(k=>String(k.id))),R=Object.keys(o||{}).filter(k=>!j.has(String(k))).map(k=>({id:k,name:k,locked:!1,batteryState:null}));return[...r,...R]},[r,o]);async function S(j){if(j){x(R=>({...R,[j]:!0}));try{await p(j)}catch(R){alert(R.message)}finally{x(R=>({...R,[j]:!1}))}}}const w=j=>u.find(R=>R.socketId===j)||{socketId:j,nickname:null,role:null};return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),C.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:C.map(j=>{const R=String(j.id),k=o?.[R]||null,E=k?.queue||[],B=k?.idleDeadline||k?.deadline||null,X=B&&B>g?Math.ceil((B-g)/1e3):B?0:null,L=k?.current||null,z=L?E.findIndex(te=>te===L):-1,K=E.length>1?z>=0?E[(z+1)%E.length]:E[0]:null,V=!!(f&&L&&L===f),F=!!(f&&K&&K===f),W=X!=null&&(V||F),ie=!!j.locked,oe=ie&&!N,$=!!(j?.private?.enabled&&j?.private?.open),T=j.lockReason?`locked: ${j.lockReason}`:"locked",H=ie?T:h[R]?"...":"request",J=y&&!oe&&!h[R];return l.jsxs("li",{className:yd("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",ie?"bg-red-900/40":$?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&S(j.id)},children:[l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{className:"text-slate-200",children:l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ia(j.color,.16),children:j.name})}),W?l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:V?`${X}s left`:`Your turn in ${X}s`}):null]}),l.jsx("span",{className:yd("text-[0.75rem] font-semibold",xA(j)),children:pA(j)})]}),E.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):l.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:E.map((te,ue)=>{const q=w(te),_=te===L,I=!!(K&&te===K&&!_),ne=_?"bg-sky-600 text-white ring-2 ring-amber-300":I?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return l.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ne}`,children:[l.jsx("span",{className:`${gA(q.role)} font-semibold`,children:vA(q,f)}),_&&l.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),I&&l.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${R}-${te}-${ue}`)})})]}),y?l.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),S(j.id)},disabled:h[R]||oe,className:yd("button-dark disabled:opacity-40",ie&&"bg-red-600/70 text-white hover:bg-red-600"),children:H}):null]},j.id)})})]})}function bA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function yA(n,s){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${r} (you)`:r}function jo({hideNicknameForm:n=!1,hideHeader:s=!1,className:r="",fillHeight:o=!1,compact:u=!1}){const f=pe(y=>y.session?.role||null),p=pe(y=>y.session?.users??[]),h=pe(y=>y.session?.socketId||null),x=f!=="spectator",g=m.useMemo(()=>[...p].sort((y,N)=>y.socketId===h?-1:N.socketId===h?1:(y.nickname||"").localeCompare(N.nickname||"")),[h,p]),v=o?"flex-1 min-h-0 overflow-y-auto":u?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${r}`,children:[!n&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(Do,{compact:u})})}),l.jsx(Ig,{})]}),!x&&l.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),l.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!s&&l.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${u?"text-xs":""}`,children:[l.jsx("span",{children:"Users"}),l.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),l.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${v} ${u?"text-[0.8rem]":""}`,children:g.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(y=>l.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${bA(y.role)}`,children:yA(y,h)},y.socketId))})]})]})}const SA=/^cu_[a-f0-9]{32}$/,wr="field-input w-full max-w-sm text-left focus:ring-emerald-500",Oo="mx-auto w-full max-w-xl flex justify-center",pr="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function jA(n){const s=String(n||"").trim();return s?s.length<=10?`${s.slice(0,2)}***${s.slice(-2)}`:`${s.slice(0,6)}...${s.slice(-6)}`:""}const jx=8*1024*1024,rs=16e3,NA={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function Nx(n){let s="";for(let o=0;o<n.length;o+=32768){const u=n.subarray(o,o+32768);s+=String.fromCharCode(...u)}return btoa(s)}function wA(n){return typeof btoa=="function"?btoa(n):""}function AA(n){if(!n)return{};const s=wA(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function CA(n,s=1500){return new Promise(r=>{if(!n||n.iceGatheringState==="complete"){r();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",u),r()},s);function u(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",u),r())}n.addEventListener("icegatheringstatechange",u)})}function wx(n){if(!n)return!1;const s=n.connectionState,r=n.iceConnectionState;return s==="connected"||r==="connected"||r==="completed"}function EA(n,s=1e4){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(wx(n)){r();return}const u=setTimeout(()=>{p(),o(new Error("Peer connection timeout"))},s),f=()=>{wx(n)?(p(),r()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(p(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function p(){clearTimeout(u),n.removeEventListener("connectionstatechange",f),n.removeEventListener("iceconnectionstatechange",f)}n.addEventListener("connectionstatechange",f),n.addEventListener("iceconnectionstatechange",f)})}async function kA(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},r=s.encodings&&s.encodings[0]||{};s.encodings=[{...r,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function MA(n,s=6e3){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}const u=Date.now();let f=-1;const p=setInterval(async()=>{if(Date.now()-u>s){clearInterval(p),o(new Error("WHIP connected but no outbound audio flow"));return}try{const h=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of h){const g=await x.getStats();for(const v of g.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const y=Number(v.bytesSent||0),N=Number(v.packetsSent||0);if(f<0)f=y;else if(y>f+200||N>5){clearInterval(p),r();return}}}}catch{}},250)})}function RA(n){const s=n.reduce((u,f)=>u+f.length,0),r=new Float32Array(s);let o=0;for(const u of n)r.set(u,o),o+=u.length;return r}function qA(n){const s=new Int16Array(n.length);for(let r=0;r<n.length;r+=1){const o=Math.max(-1,Math.min(1,n[r]));s[r]=o<0?o*32768:o*32767}return s}function TA(n,s){const r=qA(n),o=r.length*2,u=new ArrayBuffer(44+o),f=new DataView(u),p=(x,g)=>{for(let v=0;v<g.length;v+=1)f.setUint8(x+v,g.charCodeAt(v))};p(0,"RIFF"),f.setUint32(4,36+o,!0),p(8,"WAVE"),p(12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,1,!0),f.setUint32(24,s,!0),f.setUint32(28,s*2,!0),f.setUint16(32,2,!0),f.setUint16(34,16,!0),p(36,"data"),f.setUint32(40,o,!0);let h=44;for(let x=0;x<r.length;x+=1,h+=2)f.setInt16(h,r[x],!0);return new Uint8Array(u)}function vn({label:n,active:s,detail:r=""}){return l.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"bg-emerald-500":"bg-slate-700"}`,children:[l.jsx("div",{className:"text-center font-medium",children:n}),l.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:r||(s?"active":"idle")})]})}function Ax({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function DA({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:r,stopUploadedAudio:o,startMicWhip:u,readyMicWhip:f,stopMicWhip:p}){const{state:h}=Dt(),{value:x,save:g}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[y,N]=m.useState(null),[M,C]=m.useState(!1),S=!!x?.openMicEnabled,j=(x?.pttMode==="clip"?"clip":"live")==="clip",[R,k]=m.useState("idle"),[E,B]=m.useState("idle"),[X,L]=m.useState(""),z=m.useRef(null),K=m.useRef(null),V=m.useRef(null),F=m.useRef(!1),W=m.useRef(""),ie=m.useRef(null),oe=m.useRef(null),$=m.useRef(null),T=m.useRef(null),H=m.useRef(null),J=m.useRef([]),te=m.useRef(!1),ue=m.useRef(rs),q=!!h?.mic?.pttActive,_=m.useMemo(()=>v&&s?.[v]||null,[s,v]),I=!!(_&&_.state!=="offline"&&!_.error),ne=_?.source==="upload"&&_?.state==="playing",me=_?.source==="mic-whip"&&(_?.state==="starting"||_?.state==="playing"),ce=!!(!j&&K.current&&(S||q)),se=!j&&(R==="live"||R==="starting"),ve=j&&E==="recording",he=j&&E==="sending",be=An(h?.keymap?.micPtt?.[0])||"M",Ve=m.useCallback(fe=>{const we=fe==="clip"?"clip":"live";g(Ae=>({...Ae||{},pttMode:we}))},[g]),De=async()=>{if(!v){L("Take control of your rover first.");return}if(!y){L("Select an audio file first.");return}if(y.size>jx){L(`File too large (max ${jx} bytes).`);return}C(!0),L("");try{const fe=await y.arrayBuffer(),we=Nx(new Uint8Array(fe));await r?.({roverId:v,name:y.name,mime:y.type||"",dataBase64:we}),L("Upload playback started.")}catch(fe){L(fe?.message||"Failed to play upload.")}finally{C(!1)}},Te=async()=>{if(!v){L("Take control of your rover first.");return}C(!0),L("");try{await o?.(v),L("Upload playback stopped.")}catch(fe){L(fe?.message||"Failed to stop upload.")}finally{C(!1)}},ze=m.useCallback(async fe=>{const we=String(fe||W.current||"").trim();if(F.current=!1,k("idle"),V.current){try{V.current.getSenders().forEach(Ae=>Ae.track?.stop())}catch{}try{V.current.close()}catch{}}if(V.current=null,z.current)try{z.current.getTracks().forEach(Ae=>Ae.stop())}catch{}if(z.current=null,K.current=null,we)try{await p?.(we)}catch{}W.current=""},[p]),$e=m.useCallback(async fe=>{const we=await u?.(fe),Ae=String(we?.whipUrl||"").trim(),it=String(we?.token||"").trim();if(!Ae||!it)throw new Error("WHIP endpoint unavailable");const le=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});z.current=le;const de=le.getAudioTracks()?.[0];if(K.current=de||null,de&&(de.enabled=!!(S||q)),de?.applyConstraints)try{await de.applyConstraints({channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const Me=new RTCPeerConnection(NA);V.current=Me,Me.onconnectionstatechange=()=>{if(!F.current)return;const Qt=Me.connectionState;if(Qt==="connected"){k("live");return}(Qt==="failed"||Qt==="disconnected"||Qt==="closed")&&(k("error"),L(`WHIP transport ${Qt}.`))},le.getAudioTracks().forEach(Qt=>{const Ba=Me.addTrack(Qt,le);kA(Ba)});const ft=await Me.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await Me.setLocalDescription(ft),await CA(Me,1800);const kt=await fetch(Ae,{method:"POST",headers:{"Content-Type":"application/sdp",...AA(it)},body:Me.localDescription?.sdp||ft.sdp});if(!kt.ok)throw new Error(`WHIP request failed: ${kt.status}`);const ds=await kt.text();await Me.setRemoteDescription({type:"answer",sdp:ds}),await EA(Me,1e4),await MA(Me,6e3),await f?.(fe)},[S,q,f,u]),vt=m.useCallback(async()=>{if(te.current=!1,T.current){try{T.current.disconnect()}catch{}T.current.onaudioprocess=null}if($.current)try{$.current.disconnect()}catch{}if(H.current)try{H.current.disconnect()}catch{}if(ie.current)try{ie.current.getTracks().forEach(fe=>fe.stop())}catch{}if(oe.current)try{await oe.current.close()}catch{}J.current=[],T.current=null,$.current=null,H.current=null,ie.current=null,oe.current=null,ue.current=rs},[]),re=m.useCallback(async()=>{if(ie.current&&oe.current&&T.current)return;B(de=>de==="recording"?de:"arming");const fe=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:rs,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),we=new AudioContext({latencyHint:"interactive"}),Ae=we.createMediaStreamSource(fe),it=we.createScriptProcessor(1024,1,1),le=we.createGain();le.gain.value=0,it.onaudioprocess=de=>{if(!te.current)return;const Me=de.inputBuffer.getChannelData(0);J.current.push(new Float32Array(Me))},Ae.connect(it),it.connect(le),le.connect(we.destination),ie.current=fe,oe.current=we,$.current=Ae,T.current=it,H.current=le,ue.current=we.sampleRate||rs},[]),xe=m.useCallback(async({send:fe})=>{const we=te.current;if(te.current=!1,!we){fe||B("idle");return}const Ae=J.current;if(J.current=[],!fe){B("idle");return}if(!v){B("idle");return}if(!Ae.length){B("idle");return}B("sending");try{const it=RA(Ae),le=TA(it,ue.current||rs),de=Nx(le);await r?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:de}),B("idle")}catch(it){B("error"),L(it?.message||"Failed to send PTT clip.")}},[r,v]),Ee=m.useCallback(async()=>{if(!v){L("Take control of your rover first.");return}await re(),J.current=[],te.current=!0,B("recording")},[re,v]);return m.useEffect(()=>{let fe=!1;async function we(){if(j){await ze(W.current||v);return}if(!v){await ze(W.current);return}if(!(F.current&&W.current===v)&&!(!S&&!q))try{k("starting"),L(""),F.current=!0,W.current=v,await $e(v),fe||k("live")}catch(Ae){fe||(k("error"),L(Ae?.message||"Failed to start mic forwarding.")),await ze(v)}}return we(),()=>{fe=!0}},[j,S,q,v,$e,ze]),m.useEffect(()=>{const fe=K.current;fe&&(fe.enabled=!!(!j&&(S||q)))},[j,S,q]),m.useEffect(()=>{let fe=!1;async function we(){if(!j||!v){te.current&&await xe({send:!1}),B("idle");return}try{await re(),!fe&&!te.current&&B("idle")}catch(Ae){fe||(B("error"),L(Ae?.message||"Microphone access failed for clip mode."))}}return we(),()=>{fe=!0}},[j,re,xe,v]),m.useEffect(()=>{let fe=!1;async function we(){if(j){if(!v){te.current&&await xe({send:!1});return}if(q){if(!te.current)try{L(""),await Ee()}catch(Ae){fe||(B("error"),L(Ae?.message||"Failed to start clip recording."))}}else te.current&&await xe({send:!0})}}return we(),()=>{fe=!0}},[j,xe,q,v,Ee]),m.useEffect(()=>()=>{ze(W.current||v),vt()},[v,ze,vt]),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"grid gap-1",children:[l.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[l.jsx("span",{children:"Push-to-Talk Key"}),l.jsx(Ax,{label:be})]})}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),l.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ve("live"),children:"Live Mic (WHIP)"}),l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ve("clip"),children:"Record Clip"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(vn,{label:"Mode",active:j,detail:j?"record clip":"live mic"}),l.jsx(vn,{label:"PTT hold",active:q,detail:q?"held":"released"}),l.jsx(vn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),l.jsx(vn,{label:"Playback",active:j&&ne,detail:j&&ne?"playing":"idle"})]})]})})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),l.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),l.jsx("input",{className:`${wr} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:M||!v,onChange:fe=>N(fe.target.files?.[0]||null)})]}),l.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:y?l.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[y.name," (",y.size," bytes)"]}):l.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!v,onClick:De,children:M?"Working...":"Play Upload"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!v,onClick:Te,children:"Stop"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),l.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:S,disabled:!v||j,onChange:fe=>g(we=>({...we||{},openMicEnabled:!!fe.target.checked}))}),l.jsx("span",{children:j?"Open mic (live mode only)":"Open mic"})]}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(vn,{label:"WHIP link",active:se,detail:R}),l.jsx(vn,{label:"Mic hot",active:ce,detail:ce?"transmitting":"muted"}),l.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",l.jsx(Ax,{label:be})," to talk"]})]})]})})]}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[l.jsx(vn,{label:"Forward pipe",active:I,detail:I?"connected":"offline"}),l.jsx(vn,{label:"Upload playback",active:ne,detail:ne?"playing":"idle"}),l.jsx(vn,{label:"Mic relay",active:me,detail:me?"active":"idle"}),l.jsx(vn,{label:"WHIP transport",active:se,detail:R}),l.jsx(vn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),l.jsx(vn,{label:"Clip sending",active:he,detail:he?"sending":"idle"})]}),X?l.jsx("div",{className:"text-xs text-slate-400 text-center",children:X}):null]})})]})})}function _A({pendingRequestId:n,currentStoredKey:s,nickname:r,requestVerification:o,applyIdentityKey:u,onMessage:f,fullWidth:p=!1}){const[h,x]=m.useState(0),[g,v]=m.useState(""),[y,N]=m.useState(!1),[M,C]=m.useState(!1),S=()=>{x(1),v(s),N(!1),f?.("")},w=()=>{x(0),N(!1)},j=async k=>{if(k.preventDefault(),!y){f?.("Please confirm your nickname agreement before sending.");return}if(h<3){f?.("Complete all request steps before sending.");return}C(!0),f?.("");try{const E=await u(g);await o?.(),v(E),x(0),N(!1),f?.("Verification request sent to lockdown admins.")}catch(E){f?.(E.message||"Failed to submit request.")}finally{C(!1)}},R=p?"w-full":Oo;return n?l.jsx("section",{className:`surface text-sm text-slate-300 ${R}`,children:l.jsxs("div",{className:pr,children:["Verification request pending: ",n]})}):h===0?l.jsx("section",{className:`surface ${R}`,children:l.jsxs("div",{className:pr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:S,disabled:M,children:"Request Verification"})]})}):l.jsx("form",{className:`surface ${R}`,onSubmit:j,children:l.jsxs("div",{className:pr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsx("div",{className:"mx-auto w-full max-w-sm",children:l.jsx(Do,{compact:!0})}),l.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",l.jsx("span",{className:"font-semibold",children:r||"(not set)"})]}),l.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:y,onChange:k=>N(k.target.checked)}),l.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!r||!y,onClick:()=>x(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,h===2?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsx("input",{className:wr,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,h===3?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),l.jsx("input",{className:wr,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:M||!g,children:"Confirm Request"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function OA({currentStoredKey:n,applyIdentityKey:s,onMessage:r,fullWidth:o=!1}){const[u,f]=m.useState(0),[p,h]=m.useState(""),[x,g]=m.useState(!1),v=()=>{f(1),h(""),r?.("")},y=()=>{f(0),h("")},N=async C=>{if(C.preventDefault(),!(u<2)){g(!0),r?.("");try{await s(p),f(0),h(""),r?.("Identity key restored.")}catch(S){r?.(S.message||"Failed to restore key.")}finally{g(!1)}}},M=o?"w-full":Oo;return l.jsx("section",{className:`surface ${M}`,children:l.jsxs("div",{className:pr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",jA(n)||"not set yet"]}),l.jsx("input",{className:wr,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),u===0?l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:v,disabled:x,children:"Restore Key"})]}):null,u===1?l.jsxs("div",{className:"space-y-0.5",children:[l.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."}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,children:"Cancel"})]})]}):null,u===2?l.jsxs("form",{className:"space-y-0.5",onSubmit:N,children:[l.jsx("input",{className:wr,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:p,onChange:C=>h(C.target.value.toLowerCase()),placeholder:"Paste key to restore"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!p,children:"Confirm Restore"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function BA({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:r,onMessage:o,fullWidth:u=!1}){const[f,p]=m.useState({}),h=m.useMemo(()=>{const v=new Map;return(s||[]).forEach(y=>{y?.roverId&&v.set(String(y.roverId),y)}),v},[s]),x=u?"w-full":Oo,g=async v=>{if(v){p(y=>({...y,[v]:!0})),o?.("");try{(await r?.(v))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(y){o?.(y.message||"Failed to send request.")}finally{p(y=>({...y,[v]:!1}))}}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:l.jsxs("div",{className:pr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?l.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):l.jsx("div",{className:"w-full space-y-0.5",children:n.map(v=>{const y=String(v.id),N=!!f[y],M=h.get(y);return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[l.jsxs("div",{className:"min-w-0 text-left",children:[l.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:v.name||y}),l.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:y})]}),M?l.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):l.jsx("button",{type:"button",onClick:()=>g(y),disabled:N,className:"button-dark text-xs disabled:opacity-50",children:N?"Sending...":"Request"})]},y)})})]})})}function al(n){return String(n||"").trim()}function LA(n){const s=al(n);return s?s.includes("DOCKINGRUNNING")?"Returning":s.includes("PAUSED")?"Paused":s.includes("HOUSECLEANINGRUNNING")?"Cleaning":s.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":s.includes("STATE_START")?"Starting":s.includes("STATE_IDLE")||s.includes("STATE_STANDBY")?"Idle":s:"--"}function Jg(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function to({label:n,value:s,tone:r="muted",valueClass:o="",hideLabel:u=!1}){return l.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${Jg(r)}`,children:[u?null:l.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),l.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(s||""),children:s})]})}function zA(n=[]){const u=[...n.filter(C=>C&&C.valid&&Number.isFinite(C.angleDeg)&&Number.isFinite(C.distanceMm))].sort((C,S)=>Number(C.angleDeg)-Number(S.angleDeg)),f=[];let p=[];for(const C of u){if(!p.length){p.push(C);continue}const S=p[p.length-1],w=Math.abs(Number(C.angleDeg)-Number(S.angleDeg)),j=Math.max(0,Number(S.distanceMm)),R=Math.max(0,Number(C.distanceMm)),k=Math.abs(R-j);if(w<=2&&k<=900){p.push(C);continue}f.push(p),p=[C]}p.length&&f.push(p);const h=f.map(C=>{const S=C.map(j=>Math.max(0,Number(j.distanceMm))),w=S.reduce((j,R)=>j+R,0)/Math.max(1,S.length);return{points:C,size:C.length,avgDistanceMm:w}}),g=h.reduce((C,S)=>S.size>(C?.size||0)?S:C,null)?.avgDistanceMm||1e3,v=h.filter(C=>{const S=C.size<=3,w=C.avgDistanceMm>g*1.8&&C.avgDistanceMm-g>1400;return!(S&&w)}).flatMap(C=>C.points),y=v.map(C=>Math.max(0,Number(C.distanceMm))).sort((C,S)=>C-S),N=Math.max(0,Math.floor((y.length-1)*.95)),M=Math.max(1e3,y[N]||1e3);return v.map(C=>{const S=(Number(C.angleDeg)-90)*Math.PI/180,w=Math.max(0,Number(C.distanceMm)),R=Math.max(0,Math.min(1,w/M))*102,k=110+Math.cos(S)*R,E=110+Math.sin(S)*R,X=38+Math.max(0,Math.min(255,Number(C.intensity)||0))/255*38;return{key:`${C.angleDeg}-${C.distanceMm}-${C.intensity}`,x:k,y:E,fill:`hsl(198 100% ${X}%)`}})}function UA({neato:n,lidar:s,lidarActive:r=!0,onStart:o,onSendHome:u,onLocate:f,onClearErrors:p,onPowerCycle:h,fullWidth:x=!1}){const[g,v]=m.useState(""),[y,N]=m.useState(!1),[M,C]=m.useState(!1),S=x?"w-full":"w-full max-w-xl",w=!!n?.configured,j=!!(n?.enabled&&n?.connected),R=!!n?.telemetry?.extPowerPresent,k=!!n?.telemetry?.chargingActive,E=LA(n?.telemetry?.uiState),B=al(n?.telemetry?.robotState)||"--",X=n?.telemetry?.batteryPercent,L=Number.isFinite(X)?`${X}%`:"--",z=n?.telemetry?.batteryVoltage,K=Number.isFinite(z)?`${z.toFixed(2)} V`:"--",V=al(n?.telemetry?.robotError)||"--",F=al(n?.telemetry?.robotAlert)||"--",W=Array.isArray(s?.points)?s.points:[],ie=m.useMemo(()=>r?zA(W):[],[r,W]),oe=al(s?.status)||"--",$=s?.debug&&typeof s.debug=="object"?s.debug:null,T=al($?.reason)||"--",H=$?.stats&&typeof $.stats=="object"?$.stats:null,J=n?.controls||{},te=!!J?.start?.available,ue=!!J?.sendHome?.available,q=!!J?.locate?.available,_=!!J?.clearErrors?.available,I=!!J?.powerCycle?.available,ne=w&&j&&te,me=w&&j&&ue,ce=w&&j&&q,se=w&&j&&_,ve=w&&j&&I,he=async(ze,$e)=>{if($e){v(ze);try{await $e()}catch{}finally{v("")}}},be=w?j?"Online":"Offline":"Not configured",Ve=w?j?"good":"danger":"warn",De=X==null?"muted":X>=60?"good":X>=25?"warn":"danger",Te=R?"Docked":E!=="--"?E:"Away from dock";return m.useEffect(()=>{if(!r||!s||!Array.isArray(s.points))return;N(!0);const ze=setTimeout(()=>{N(!1)},120);return()=>clearTimeout(ze)},[s,r]),l.jsx("section",{className:`surface text-sm text-slate-200 ${S}`,children:l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac. Be nice to him."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${Jg(Ve)}`,children:be})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)] gap-0.5",children:[l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Controls"}),l.jsx("button",{type:"button",disabled:!ne||!!g,onClick:()=>he("start",o),className:"rounded-md border border-sky-300 bg-emerald-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-emerald-500 disabled:opacity-50",children:g==="start"?"Starting...":"Start cleaning"}),l.jsx("button",{type:"button",disabled:!me||!!g,onClick:()=>he("sendHome",u),className:"rounded-md border border-sky-300 bg-sky-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-sky-500 disabled:opacity-50",children:g==="sendHome"?"Sending...":"Send to dock"}),l.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[l.jsx("button",{type:"button",disabled:!ce||!!g,onClick:()=>he("locate",f),className:"w-full rounded-md border border-sky-300 bg-fuchsia-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-sky-500 hover:bg-fuchsia-500 disabled:opacity-50",children:g==="locate"?"Playing...":"Play sound"}),l.jsx("button",{type:"button",disabled:!se||!!g,onClick:()=>he("clearErrors",p),className:"w-full rounded-md border border-sky-300 bg-amber-500 px-1 py-0.5 text-xs font-semibold text-slate-900 transition hover:border-sky-500 hover:bg-amber-400 disabled:opacity-50",children:g==="clearErrors"?"Clearing...":"Clear errors"}),l.jsx("button",{type:"button",disabled:!ve||!!g,onClick:()=>he("powerCycle",h),className:"w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50",children:g==="powerCycle"?"Cycling...":"Power cycle"})]}),l.jsxs("div",{className:"surface-muted grid gap-0.5 pt-0.25",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Power status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx(to,{label:"Battery",value:L,tone:De}),l.jsx(to,{label:"Voltage",value:K,tone:"muted"}),l.jsx(to,{label:"Docked",value:R?"Docked":"Not docked",tone:R?"good":"muted",hideLabel:!0}),l.jsx(to,{label:"Charging",value:k?"charging":"not charging",tone:k?"good":"muted",hideLabel:!0})]})]})]}),l.jsx("div",{className:"grid gap-0.5",children:l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Robot Status"}),l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(13rem,15rem)] gap-0.5 items-start",children:[l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot state (raw)"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:B})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Basic state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:Te})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"UI state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:E})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot error"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:V})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot alert"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:F})]})]}),l.jsxs("div",{className:`rounded-md px-1 py-0.5 ${y?"bg-emerald-900":"bg-slate-800"}`,children:[l.jsx("button",{type:"button",onClick:()=>C(ze=>!ze),className:"w-full text-left text-[0.72rem] text-slate-300",children:"Lidar"}),l.jsx("div",{className:"mt-0.25 text-center text-[0.68rem] text-slate-400",children:"Front of robot"}),l.jsx("div",{className:"mt-0.25 aspect-square rounded-md bg-slate-800 p-0",children:ie.length?l.jsxs("svg",{viewBox:"0 0 220 220",className:"h-full w-full",children:[l.jsx("rect",{x:"0",y:"0",width:"220",height:"220",fill:"#1e293b"}),l.jsx("rect",{x:"7",y:"7",width:"206",height:"206",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:"33",y:"33",width:"154",height:"154",fill:"none",stroke:"#475569",strokeWidth:"1"}),l.jsx("rect",{x:"59",y:"59",width:"102",height:"102",fill:"none",stroke:"#475569",strokeWidth:"1"}),l.jsx("rect",{x:"85",y:"85",width:"50",height:"50",fill:"none",stroke:"#334155",strokeWidth:"1"}),l.jsx("line",{x1:"110",y1:"7",x2:"110",y2:"213",stroke:"#475569",strokeWidth:"1"}),l.jsx("line",{x1:"7",y1:"110",x2:"213",y2:"110",stroke:"#475569",strokeWidth:"1"}),l.jsx("circle",{cx:"110",cy:"110",r:"4",fill:"#e2e8f0"}),ie.map(ze=>l.jsx("circle",{cx:ze.x,cy:ze.y,r:"1.8",fill:ze.fill},ze.key))]}):l.jsx("div",{className:"flex h-full items-center justify-center text-center text-xs text-slate-400",children:"Waiting for scan"})}),M?l.jsxs("div",{className:"mt-0.5 rounded-md bg-slate-900 px-0.75 py-0.5 font-mono text-[0.68rem] text-slate-300",children:[l.jsxs("div",{children:["Status: ",oe]}),l.jsxs("div",{children:["Reason: ",T]}),l.jsxs("div",{children:["Points: ",W.length]}),l.jsxs("div",{children:["Rotation: ",Number.isFinite(s?.rotationSpeed)?s.rotationSpeed.toFixed(2):"--"]}),l.jsxs("div",{children:["Request in flight: ",$?.requestInFlight?"yes":"no"]}),l.jsxs("div",{children:["Started at: ",$?.requestStartedAt||"--"]}),l.jsxs("div",{children:["Headers: ",H?.headersSeen??"--"]}),l.jsxs("div",{children:["Rotations: ",H?.rotationsSeen??"--"]}),l.jsxs("div",{children:["Scans ok: ",H?.scansOk??"--"]}),l.jsxs("div",{children:["Timeouts: ",H?.scansTimedOut??"--"]}),l.jsxs("div",{children:["Restarts: ",H?.scansRestarted??"--"]}),l.jsxs("div",{children:["Rotation no scan: ",H?.rotationsWithoutScan??"--"]}),l.jsxs("div",{children:["Parseable payloads: ",H?.parseablePayloads??"--"]}),l.jsxs("div",{children:["Point payloads: ",H?.pointPayloads??"--"]})]}):null]})]})]})})]}),!w||!j||!te||!ue||!q||!_||!I?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:w?j?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function HA(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function VA(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function $A({lift:n,onUp:s,onDown:r,fullWidth:o=!1}){const[u,f]=m.useState(""),[p,h]=m.useState(()=>Date.now()),x=o?"w-full":"w-full max-w-xl",g=!!n?.configured,v=!!(n?.enabled&&n?.connected),y=!!n?.busy,N=String(n?.target||"").toLowerCase(),M=String(n?.position||"").toLowerCase(),C=!!n?.availability?.upSwitch,S=!!n?.availability?.downSwitch,w=Number(n?.lastActionAt||0),j=Math.max(0,Number(n?.commandCooldownMs||0)),R=Math.max(0,w+j-p),k=!y&&R>0,E=y||k;m.useEffect(()=>{if(!E)return;const V=setInterval(()=>{h(Date.now())},100);return()=>clearInterval(V)},[E]),m.useEffect(()=>{h(Date.now())},[w,j,y]);const B=g?v?E?"Busy":"Ready":"Offline":"Not configured",X=g?v?E?"warn":"good":"danger":"warn",L=g&&v&&!E&&!u&&C&&S,z=m.useMemo(()=>Math.ceil(R/1e3),[R]),K=async(V,F)=>{if(F){f(V);try{await F()}catch{}finally{f("")}}};return l.jsxs("section",{className:`surface relative text-sm text-slate-200 ${x}`,children:[E?l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center rounded-md bg-slate-950/80 px-1.5 text-center",children:l.jsxs("div",{className:"space-y-0.25",children:[l.jsx("p",{className:"text-sm font-semibold text-slate-100",children:y?"Motion in progress":"Motion cooldown active"}),l.jsx("p",{className:"text-xs text-slate-300",children:"Controls are disabled while the lift is moving, otherwise it's tiny brain would get confused."}),!y&&k?l.jsxs("p",{className:"text-xs text-slate-400",children:["About ",z,"s remaining."]}):null]})}):null,l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${HA(X)}`,children:B})]}),l.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[l.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),l.jsx("div",{className:"text-base font-semibold text-slate-100",children:VA(M)})]}),l.jsx("button",{type:"button",disabled:!L,onClick:()=>K("down",r),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="down"||N==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="down"||N==="down"?"Lowering...":"Down"}),l.jsx("button",{type:"button",disabled:!L,onClick:()=>K("up",s),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="up"||N==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="up"||N==="up"?"Raising...":"Up"})]})}),!g||!v||!C||!S?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:g?v?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?l.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})]})}function Pg({isActive:n=!0}){const s=pe($=>$.session),r=pe($=>$.neatoLidar),{identifySession:o,requestVerification:u,requestPrivateRoverAccess:f,playUploadedAudio:p,stopUploadedAudio:h,startMicWhip:x,readyMicWhip:g,stopMicWhip:v,neatoStart:y,neatoSendHome:N,neatoLocate:M,neatoClearErrors:C,neatoPowerCycle:S,liftUp:w,liftDown:j}=Xt(),{value:R,save:k}=Qe("identity",{cookieUserId:""}),{value:E}=Qe("profile",{nickname:""}),B=m.useMemo(()=>(R?.cookieUserId||"").trim(),[R?.cookieUserId]),X=(E?.nickname||"").trim(),L=!!s?.isVerified,z=s?.verification?.pendingRequestId||null,K=s?.privateRoverAccess?.requestableRovers||[],V=s?.privateRoverAccess?.pendingRequests||[],F=String(s?.assignment?.roverId||"").trim(),[W,ie]=m.useState(""),oe=async $=>{const T=String($||"").trim().toLowerCase();if(!T)throw new Error("Identity key required.");if(!SA.test(T))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return k(H=>({...H||{},cookieUserId:T})),await o({cookieUserId:T,nickname:X}),T};return l.jsxs("section",{className:"space-y-2 text-base",children:[l.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[L?null:l.jsx("div",{className:"lg:col-span-2",children:l.jsx(_A,{pendingRequestId:z,currentStoredKey:B,nickname:X,requestVerification:u,applyIdentityKey:oe,onMessage:ie,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:L?l.jsxs("div",{className:"space-y-2",children:[l.jsx(UA,{neato:s?.neato||null,lidar:r,lidarActive:n,onStart:y,onSendHome:N,onLocate:M,onClearErrors:C,onPowerCycle:S,fullWidth:!0}),l.jsx($A,{lift:s?.lift||null,onUp:w,onDown:j,fullWidth:!0}),l.jsx(DA,{ownRoverId:F,audioForwardByRover:s?.audioForward||{},playUploadedAudio:p,stopUploadedAudio:h,startMicWhip:x,readyMicWhip:g,stopMicWhip:v})]}):l.jsx("section",{className:"surface h-full",children:l.jsx("div",{className:"flex h-full flex-col items-center justify-center text-center text-xs text-slate-400",children:"Verify your account to unlock VIP controls."})})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(BA,{requestableRovers:K,pendingRequests:V,requestPrivateRoverAccess:f,onMessage:ie,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(OA,{currentStoredKey:B,applyIdentityKey:oe,onMessage:ie,fullWidth:!0})})]}),W?l.jsx("div",{className:Oo,children:l.jsx("p",{className:"text-xs text-slate-400 text-center",children:W})}):null]})}const GA=420,YA=1200,FA={1:262,2:330,3:392,4:523};function No(){const n=pe(S=>S.session?.buttonBox?.buttons??[]),s=sn(),{value:r}=Qe("audio",ut),o=Number.isFinite(r?.masterVolume)?r.masterVolume:ut.masterVolume,u=Number.isFinite(r?.alertVolume)?r.alertVolume:ut.alertVolume,f=Math.max(0,Math.min(1,o*u)),p=m.useMemo(()=>{const S=Array.isArray(n)?n:[];return S.length===4?S:[1,2,3,4].map(w=>S.find(j=>Number(j?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n]),[h,x]=m.useState({}),[g,v]=m.useState({}),y=m.useRef(new Map),N=m.useRef(new Map),M=m.useRef({}),C=m.useRef(null);return m.useEffect(()=>{const S={};p.forEach(j=>{S[j.id]=Number(j.lastRewardAt||0)});const w=M.current||{};p.forEach(j=>{const R=Number(j.id),k=S[R]||0,E=Number(w[R]||0);if(k>0&&k!==E){v(L=>({...L,[R]:!0}));const B=N.current.get(R);B&&clearTimeout(B);const X=setTimeout(()=>{v(L=>({...L,[R]:!1})),N.current.delete(R)},YA);N.current.set(R,X)}}),M.current=S},[p]),m.useEffect(()=>{function S(j){const R=FA[j];if(!R||f<=0)return;let k=C.current;if(!k){const L=window.AudioContext||window.webkitAudioContext;if(!L)return;k=new L,C.current=k}const E=k.createOscillator(),B=k.createGain();E.type="square",E.frequency.value=R;const X=.14*f;B.gain.setValueAtTime(1e-4,k.currentTime),B.gain.exponentialRampToValueAtTime(Math.max(1e-4,X),k.currentTime+.01),B.gain.exponentialRampToValueAtTime(1e-4,k.currentTime+.2),E.connect(B),B.connect(k.destination),E.start(),E.stop(k.currentTime+.21)}function w(j={}){const R=Number(j.buttonId);if(!Number.isFinite(R)||R<1||R>4)return;x(B=>({...B,[R]:!0}));const k=y.current.get(R);k&&clearTimeout(k);const E=setTimeout(()=>{x(B=>({...B,[R]:!1})),y.current.delete(R)},GA);y.current.set(R,E),S(R)}return s.on("buttonBox:increment",w),()=>{s.off("buttonBox:increment",w)}},[f,s]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("header",{className:"panel-muted text-center text-sm",children:l.jsx("p",{children:"Button Box"})}),l.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:p.map(S=>{const w=Number(S.id),j=Number.isFinite(S.count)?S.count:0,R=Number.isFinite(S.goal)?S.goal:0,k=typeof S.rewardName=="string"&&S.rewardName.trim()?S.rewardName.trim():"Unassigned",E=Number.isFinite(S.rewardNumber)?S.rewardNumber:"?",B=!!h[w],X=!!g[w];return l.jsx(gg,{buttonId:w,count:j,goal:R,rewardNumber:E,rewardName:k,className:[B?"bg-cyan-900/45":"",X?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function XA(){const{state:{roverId:n}}=Dt(),r=fl(n)?.sensors||{};return l.jsx("section",{className:"panel-section",children:l.jsx("div",{className:"aspect-square w-full",children:l.jsx(Vd,{sensors:r})})})}function QA(){const{state:{roverId:n,keymap:s,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,startHorn:h,stopHorn:x}}=Dt(),g=Tg(n),v=g.docked&&!g.driving,y=r?.config,N=!!(n&&r?.enabled&&y),M=!!(n&&u?.nightVision),C=u?.nightVisionState,S=!!(n&&u?.horn),w=o?.overheated,j=typeof y?.minAngle=="number"?y.minAngle:-30,R=typeof y?.maxAngle=="number"?y.maxAngle:30,k=typeof r?.angle=="number"?r.angle:typeof y?.homeAngle=="number"?y.homeAngle:(j+R)/2,E=An(s?.nightVisionToggle?.[0]),B=An(s?.hornHonk?.[0]),X=An(s?.cameraUp?.[0]),L=An(s?.cameraDown?.[0]);return l.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[l.jsx(Dg,{layout:"desktop",expand:!0,driveDockState:g}),v?null:l.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[M&&l.jsx(_g,{nightVisionOn:C?.nightVisionOn,disabled:!n,onToggle:p,keyLabel:E}),S&&l.jsx(Og,{disabled:!n||w,onStart:h,onStop:x,keyLabel:B,active:o?.active,heat:o?.heat}),N&&l.jsx(Bg,{value:k,min:j,max:R,onChange:f,keyDownLabel:L,keyUpLabel:X,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 KA({layout:n,onOpenHelpOverlay:s}){const[r,o]=m.useState("telemetry"),u=pe(S=>!!S.session?.isVerified),f=pe(S=>String(S.session?.assignment?.roverId||"").trim()),p=pe(S=>{const w=String(S.session?.assignment?.roverId||"").trim();return w&&S.session?.audioForward?.[w]||null}),{state:h}=Dt(),{value:x}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),g=u?"bg-emerald-400":"bg-red-600",v=!!h?.mic?.pttActive,y=!!x?.openMicEnabled,N=x?.pttMode==="clip"?"clip":"live",M=!!(f&&u&&(N==="clip"?v:y||v)),C=!!(f&&u&&N==="clip"&&p?.source==="upload"&&p?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(Sf,{defaultTab:"telemetry",currentTab:r,onTabChange:o,children:[l.jsxs(jf,{children:[l.jsx(tn,{id:"telemetry",children:"Controls"}),l.jsx(tn,{id:"vip",highlight:C?"green":M?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-2",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${g}`,"aria-hidden":"true",title:u?"Verified":"Not verified"})]})}),l.jsx(tn,{id:"help",children:"Help"}),l.jsx(tn,{id:"settings",children:"Settings"})]}),l.jsxs(Nf,{children:[l.jsx(nn,{id:"telemetry",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[l.jsx(XA,{}),l.jsx(QA,{})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[l.jsx(_o,{}),l.jsx(af,{panelId:"replay-sources-desktop",fillHeight:!0}),l.jsx(hA,{})]}),l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[l.jsx(To,{fillHeight:!0}),l.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[l.jsx(jo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),l.jsx(mA,{compact:!0})]})]}),l.jsx(Vg,{}),l.jsx(No,{}),l.jsx(ff,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),l.jsx(nn,{id:"vip",keepMounted:!0,children:l.jsx(Pg,{isActive:r==="vip"})}),l.jsx(nn,{id:"help",children:l.jsx(Zg,{layout:n,onOpenOverlay:s})}),l.jsx(nn,{id:"settings",children:l.jsx(Xg,{})})]})]})})}const ZA=new Set(["admin","lockdown","lockdown-admin"]),IA=new Set(["lockdown","lockdown-admin"]),JA=new Set(["admin","lockdown"]);function PA(n="admin"){return n==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function WA(){const n=pe(y=>y.session?.mode||null),s=pe(y=>y.session?.role||null),r=pe(y=>y.session?.adminReason?.text||"");pe(y=>y.session?.adminReason?.updatedAt||null);const o=pe(y=>y.session?.timezone||"UTC"),u=pe(y=>(y.session?.socials||[]).find(C=>String(C?.id||C?.label||"").toLowerCase()==="discord")?.url||y.session?.discord?.invite||null),f=JA.has(n),p=n==="lockdown"?IA.has(s):ZA.has(s),[h,x]=m.useState(()=>new Date),g=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:o,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(h)}catch{return h.toLocaleTimeString()}},[h,o]);if(m.useEffect(()=>{const y=setInterval(()=>x(new Date),1e3);return()=>clearInterval(y)},[]),!f||p)return null;const v=PA(n);return l.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:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold",children:v.title}),l.jsx("p",{className:"text-sm text-slate-300",children:v.description})]}),l.jsxs("div",{className:"surface-muted space-y-0.5",children:[l.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),l.jsx("p",{className:"text-lg font-semibold text-slate-100",children:r||"No reason set."}),l.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",g]})]}),l.jsx("div",{className:"surface-muted",children:l.jsx($g,{})}),l.jsx("div",{className:"w-full justify-center items-center",children:l.jsx(pf,{id:"discord",label:"Join our Discord server for updates!",url:u})}),"You can still use the chat while the server is locked:",l.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[l.jsx(To,{}),l.jsx(Do,{})]})]})})}const e2="/assets/turn_alert-DVO8EZJa.mp3";function t2(n,s=1){const r=m.useRef(null);return m.useEffect(()=>{r.current=new Audio(n),r.current.volume=s,r.current.load()},[n,s]),()=>{r.current&&(r.current.volume=s,r.current.currentTime=0,r.current.play().catch(()=>{}))}}function n2(){const n=pe(v=>v.session?.socketId||null),s=pe(v=>v.session?.turnQueues||{}),r=pe(v=>v.session?.roster||[]),{pushAlert:o}=Xt(),{value:u}=Qe("audio",ut),f=Number.isFinite(u?.masterVolume)?u.masterVolume:ut.masterVolume,p=Number.isFinite(u?.alertVolume)?u.alertVolume:ut.alertVolume,h=Math.max(0,Math.min(1,f*p)),x=t2(e2,h),g=m.useRef(new Set);return m.useEffect(()=>{if(!n)return;const v=[];Object.entries(s).forEach(([y,N])=>{!N||!N.current||N.current!==n||g.current.has(y)||(v.push(y),g.current.add(y))}),Object.keys(s).forEach(y=>{(!s[y]||s[y].current!==n)&&g.current.delete(y)}),v.length!==0&&(v.forEach(y=>{const N=r.find(M=>String(M.id)===String(y))?.name||y;o({title:"Your turn!",message:`You now control ${N}.`,color:"#ff5722"})}),x())},[s,x,o,r,n]),null}function a2({visible:n,mode:s,onEnterFullscreen:r,onDismiss:o}){if(!n)return null;const u=s==="pwa-hint";return l.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:l.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:l.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[l.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),u?l.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",l.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):l.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."}),l.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[l.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:u?"Got it":"Not now"}),!u&&l.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:r,children:"Enter fullscreen"})]})]})})})}function s2({side:n="right",onClick:s}){const r=n==="left"?"left-2":"right-2";return l.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${r} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-cyan-200/50 bg-slate-900/70 text-cyan-100 shadow-lg backdrop-blur-sm transition hover:bg-slate-800/80 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:l.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Wg="fullscreenPromptDismissed",l2=new Set(["mobile-portrait","mobile-landscape"]),ev=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},r2=()=>{const n=ev();if(!n)return!1;try{return n.getItem(Wg)==="1"}catch{return!1}},Cx=()=>{const n=ev();if(n)try{n.setItem(Wg,"1")}catch{}},i2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Ex=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function o2(n){const s=l2.has(n),[r,o]=m.useState(!1),[u,f]=m.useState("native"),[p,h]=m.useState(!1),x=m.useMemo(()=>i2(),[]),g=m.useMemo(()=>Ex(),[]),v=m.useCallback(()=>{if(!s){o(!1),h(!1);return}if(!p&&r2()){o(!1);return}if(x){f("pwa-hint"),o(!0);return}if(!Ex()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[p,x,s]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const C=()=>{if(document.fullscreenElement){h(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",C),document.addEventListener("webkitfullscreenchange",C),()=>{document.removeEventListener("fullscreenchange",C),document.removeEventListener("webkitfullscreenchange",C)}},[v]);const y=m.useCallback(()=>{Cx(),h(!1),o(!1)},[]),N=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const C=document.documentElement;if(!C)return!1;const S=C.requestFullscreen||C.webkitRequestFullscreen||C.mozRequestFullScreen||C.msRequestFullscreen;if(!S)return!1;try{const w=S.call(C);return w&&typeof w.then=="function"&&await w,Cx(),h(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[x,s]),M=m.useCallback(()=>{s&&(h(!0),f(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(h(!1),o(!1))},[s]),{visible:r,mode:u,isIOS:x,nativeSupported:g,enterFullscreen:N,dismiss:y,showPrompt:M}}function c2({visible:n,layout:s,onClose:r,showOnLoad:o,onToggleShowOnLoad:u}){if(!n)return null;const{state:f}=Dt(),p=h=>{const x=!h.target.checked;u?.(x)};return l.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[l.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:[l.jsx("span",{className:"font-semibold",children:"Help & controls"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!o,onChange:p,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("button",{type:"button",onClick:r,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),l.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:l.jsx(Kg,{layout:s,keymap:f?.keymap||{}})})]})})}const u2=`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
|
||
shrimp
|
||
fling`;function d2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function f2(){const n=String(u2).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function wf(){const{setNickname:n}=Xt(),{value:s,status:r,save:o}=Qe("profile",{nickname:""}),u=m.useRef(!1);m.useEffect(()=>{if(r!=="ready"||u.current||(s.nickname||"").trim())return;u.current=!0;const p=d2(f2()).slice(0,32);if(!p)return;(async()=>{try{await n(p)}catch{}finally{o({nickname:p})}})()},[o,n,r,s.nickname])}function m2(){const n=sn(),s=pe(w=>w.connected),{identifySession:r}=Xt(),{value:o,status:u,save:f}=Qe("identity",{cookieUserId:""}),{value:p,status:h}=Qe("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),v=m.useRef(null),y=u==="ready"&&h==="ready",N=(o?.cookieUserId||"").trim(),M=(p?.nickname||"").trim(),C=m.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),S=m.useCallback(async()=>{if(!(!y||!s||!n?.id||x.current)){x.current=!0;try{const j=((await r({cookieUserId:N,nickname:M}))?.cookieUserId||"").trim();j&&j!==N&&f(R=>({...R||{},cookieUserId:j})),g.current=n.id,C()}catch{C(),v.current=setTimeout(()=>{S()},2e3)}finally{x.current=!1}}},[C,s,N,r,M,y,f,n?.id]);m.useEffect(()=>{!y||!s||!n?.id||g.current!==n.id&&S()},[s,y,S,n?.id]),m.useEffect(()=>{!y||!s||!n?.id||S()},[y,s,n?.id,N,M,S]),m.useEffect(()=>{const w=()=>{n?.connected&&S()},j=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&S()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",j)}},[S,n?.connected]),m.useEffect(()=>()=>C(),[C])}const Sd=1e4,jd=28,h2=14;function wo({layout:n="desktop",className:s="",dismissable:r=!0}){const o=pe(j=>{const R=j.session?.globalObjective?.text;return R?String(R).trim():""}),u=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[f,p]=m.useState(!1),[h,x]=m.useState(jd),[g,v]=m.useState(0),y=m.useRef(null),N=m.useRef(null),M=m.useRef(null);m.useEffect(()=>{if(!o){p(!1);return}if(p(!0),!u||!r)return;const j=Date.now();v(Sd);const R=setTimeout(()=>p(!1),Sd),k=setInterval(()=>{const E=Date.now()-j;v(Math.max(0,Sd-E))},250);return()=>{clearTimeout(R),clearInterval(k)}},[o,u]),m.useEffect(()=>{if(!o)return;x(jd);let j=0;const R=()=>{const E=M.current,B=N.current;if(!E||!B)return;const X=E.clientWidth;if(!X)return;const L=B.scrollWidth;if(!L)return;const z=Math.min(1,X/L),K=Math.max(h2,Math.floor(jd*z));x(K)};j=window.requestAnimationFrame(R);const k=new ResizeObserver(()=>{window.cancelAnimationFrame(j),j=window.requestAnimationFrame(R)});return y.current&&k.observe(y.current),()=>{window.cancelAnimationFrame(j),k.disconnect()}},[o]);const C=m.useMemo(()=>["panel-section flex w-full items-center justify-center",u?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",s].filter(Boolean).join(" "),[s,u]);if(!o||!f)return null;const S=u?Math.ceil(g/1e3):null,w=r?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return l.jsx("div",{ref:y,className:C,style:{fontSize:`${h}px`,lineHeight:1.1},...w,children:l.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[l.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:[l.jsx("span",{children:"Global"}),l.jsx("span",{children:"Objective"})]}),l.jsx("span",{ref:M,className:"flex-1 overflow-hidden text-slate-100",children:l.jsx("span",{ref:N,className:"block",children:o})}),u?l.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:[S,"s"]}):null]})})}const p2=3200;function x2(n={}){const s=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",r=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):r;return{rewardName:s,goal:r,count:o,ts:Date.now()}}function tv(){const n=sn(),{value:s}=Qe("audio",ut),r=Number.isFinite(s?.masterVolume)?s.masterVolume:ut.masterVolume,o=Number.isFinite(s?.alertVolume)?s.alertVolume:ut.alertVolume,u=Math.max(0,Math.min(1,r*o)),[f,p]=m.useState(null),h=m.useRef(null);return m.useEffect(()=>{h.current=new Audio("/tada.mp3"),h.current.volume=u,h.current.load()},[u]),m.useEffect(()=>{let x=null;function g(){const N=h.current;N&&(N.volume=u,N.currentTime=0,N.play().catch(()=>{}))}function v(N={}){const M=x2(N);p(M),g(),x&&clearTimeout(x),x=setTimeout(()=>{p(null)},p2)}function y(N){v(N?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",y),()=>{x&&clearTimeout(x),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",y)}},[u,n]),f?l.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:l.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:l.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[l.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",f.rewardName,"!"]}),l.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[f.count,"/",f.goal]})]}),l.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function g2(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function r(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:u}=window;o>=1024?s("desktop"):o>u?s("mobile-landscape"):s("mobile-portrait")}return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),n}function v2({layout:n,onOpenHelpOverlay:s}){return l.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[l.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[l.jsx(gf,{}),l.jsx(sj,{}),l.jsx(mf,{})]}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[l.jsx(wo,{layout:n}),l.jsx(KA,{layout:n,onOpenHelpOverlay:s})]})]})}function nv({layout:n,onOpenHelpOverlay:s,roomPanelId:r,showTelemetry:o=!0}){const[u,f]=m.useState("chat"),p=pe(j=>!!j.session?.isVerified),h=pe(j=>String(j.session?.assignment?.roverId||"").trim()),x=pe(j=>{const R=String(j.session?.assignment?.roverId||"").trim();return R&&j.session?.audioForward?.[R]||null}),{state:g}=Dt(),{value:v}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),y=p?"bg-emerald-400":"bg-amber-400",N=!!g?.mic?.pttActive,M=!!v?.openMicEnabled,C=v?.pttMode==="clip"?"clip":"live",S=!!(h&&p&&(C==="clip"?N:M||N)),w=!!(h&&p&&C==="clip"&&x?.source==="upload"&&x?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(Sf,{defaultTab:"chat",currentTab:u,onTabChange:f,children:[l.jsxs(jf,{children:[l.jsx(tn,{id:"chat",children:"Chat"}),l.jsx(tn,{id:"vip",highlight:w?"green":S?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${y}`,"aria-hidden":"true",title:p?"Verified":"Not verified"})]})}),l.jsx(tn,{id:"roomcontrols",children:"Room Controls"}),l.jsx(tn,{id:"help",children:"Help"}),l.jsx(tn,{id:"settings",children:"Settings"})]}),l.jsxs(Nf,{children:[l.jsx(nn,{id:"chat",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(To,{}),l.jsx(jo,{})]})}),l.jsx(nn,{id:"vip",keepMounted:!0,children:l.jsx(Pg,{isActive:u==="vip"})}),l.jsx(nn,{id:"roomcontrols",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Vg,{}),l.jsx(No,{}),l.jsx(ff,{panelId:r})]})}),l.jsx(nn,{id:"help",children:l.jsx(Zg,{layout:n,onOpenOverlay:s})}),l.jsx(nn,{id:"settings",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Xg,{}),l.jsx(mf,{})]})})]})]})})}function b2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx(gf,{layoutFormat:"mobile-portrait"}),l.jsx(RN,{swapColumns:s}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(af,{panelId:"replay-sources-mobile-portrait"}),l.jsx(_o,{})]}),l.jsx(nv,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function y2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const r="self-start h-[min(100svh,32rem)]",o=s?l.jsx(yo,{layout:"landscape",className:r}):l.jsx(bo,{layout:"landscape",className:r}),u=s?l.jsx(bo,{layout:"landscape",className:r}):l.jsx(yo,{layout:"landscape",className:r});return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.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:[o,l.jsxs("div",{children:[l.jsx(gf,{layoutFormat:"mobile-landscape"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(af,{panelId:"replay-sources-mobile-landscape"}),l.jsx(_o,{})]})]}),u]}),l.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:l.jsx(nv,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function S2(){const n=g2(),s=n==="desktop",r=o2(n);return l.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:l.jsx(j2,{layout:n,isDesktop:s,fullscreen:r})})}function j2({layout:n,isDesktop:s,fullscreen:r}){wf(),m2();const{visible:o,mode:u,isIOS:f,nativeSupported:p,enterFullscreen:h,dismiss:x,showPrompt:g}=r,{value:v,status:y,save:N}=Qe("help",{showOnLoad:!0}),{value:M}=Qe("page",{swapMobileControlColumns:!1}),C=!!M?.swapMobileControlColumns,S=C?"left":"right",w=!s&&(f||p),[j,R]=m.useState(!1);m.useEffect(()=>{y==="ready"&&R(v?.showOnLoad!==!1)},[y,v?.showOnLoad]);const k=m.useCallback(()=>R(!0),[]),E=m.useCallback(()=>R(!1),[]),B=m.useCallback(async()=>{if(f){g();return}await h()||g()},[h,f,g]),X=m.useCallback(z=>{const K=!!z;N(V=>({...V??{},showOnLoad:K})),K||R(!1)},[N]),L=m.useMemo(()=>s?l.jsx(v2,{layout:n,onOpenHelpOverlay:k}):n==="mobile-landscape"?l.jsx(y2,{onOpenHelpOverlay:k,swapMobileControlColumns:C}):l.jsx(b2,{onOpenHelpOverlay:k,swapMobileControlColumns:C}),[s,n,k,C]);return l.jsxs(Jj,{children:[l.jsx(oN,{}),l.jsx(yN,{}),l.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:l.jsx(wo,{layout:n}),L]}),l.jsx(rf,{}),l.jsx(tv,{}),l.jsx(n2,{}),l.jsx(WA,{}),l.jsx(c2,{visible:j,layout:n,onClose:E,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:X}),l.jsx(a2,{visible:o,mode:u,onEnterFullscreen:h,onDismiss:x}),w?l.jsx(s2,{side:S,onClick:B}):null]})}function av(){const{session:n,setRole:s,subscribeAll:r,connected:o}=kr(),[u,f]=m.useState(!1);return m.useEffect(()=>{let p=!1;async function h(){if(n?.mode==="lockdown"){f(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await r(),p||f(!0)}catch(x){console.error("Failed to enter spectator mode",x),p||f(!1)}}return h(),()=>{p=!0}},[o,n?.mode,n?.role,s,r]),u}function N2(){const[n,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia("(max-aspect-ratio: 4/3)"),o=u=>s(u.matches);return r.addEventListener?r.addEventListener("change",o):r.addListener(o),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o)}},[]),n}function w2({roverId:n,session:s}){const r=s?.activeDrivers?.[n]||null,u=(s?.users||[]).find(x=>x.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=s?.mode,p=s?.turnQueues?.[n];return f==="turns"&&p?.current?`${u} (turns)`:u}function A2({rover:n,frame:s,sessionInfo:r,videoMode:o,snapshotFeed:u,audioInfo:f,session:p}){const h=w2({roverId:n.id,session:p});return l.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:l.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:l.jsx(Sr,{sessionInfo:r,videoMode:o,snapshotFeed:u,audioSessionInfo:f,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:h,hudForceMap:!0,hudMapPosition:"top-center"})})})}function C2({roster:n,frames:s,videoSources:r,snapshotFeeds:o,audioSources:u,session:f,canSpectateVideo:p}){return n.length===0?l.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):l.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(h=>l.jsx(A2,{rover:h,frame:s[h.id],sessionInfo:p&&r[h.id]||null,videoMode:p?"whep":"snapshot",snapshotFeed:p?null:o[h.id],audioInfo:u[`${h.id}-audio`],session:f,showHudMap:!0,hudMapPosition:"bottom-left"},h.id))})}function E2(){return l.jsx("section",{className:"min-h-0",children:l.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:l.jsx(ff,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function k2({className:n=""}){return l.jsx("div",{className:`panel ${n}`,children:l.jsx(mf,{})})}function M2(){const{session:n}=kr(),s=n?.mode==="lockdown",r=!!n?.isLocalNetwork;wf(),av();const o=N2(),u=og(),f=n?.roster??[],p=hf(f.map(w=>w.id),{enabled:!s&&!r,version:n?.mode}),h=r?f.map(w=>({type:"rover",id:w.id,key:w.id})):[],x=br(h,{enabled:!s&&r,version:n?.mode}),g=f.flatMap(w=>w.media?.audioPublishUrl?[{type:"rover",id:`${w.id}-audio`,key:`${w.id}-audio`}]:[]),v=br(g,{enabled:!s,version:n?.mode});if(s)return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),l.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const y=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",C="",S=o?"h-64":"";return l.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[l.jsxs("main",{className:y,children:[l.jsxs("section",{className:M,children:[o?l.jsxs("div",{className:`${C} ${S} flex flex-col gap-0.5`,children:[l.jsx(wo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(No,{}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):l.jsxs("div",{className:C,children:[l.jsx(wo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(No,{})]}),l.jsx("div",{className:`${C} ${o?`${S} overflow-y-auto`:""}`,children:l.jsx("div",{className:"panel h-full",children:l.jsx(_o,{title:"Rovers"})})}),o?null:l.jsx("div",{className:`${C} flex-1 min-h-0`,children:l.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),l.jsx("div",{className:`${C} ${o?S:"flex-[1.1] min-h-0"}`,children:l.jsx(To,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),l.jsx("div",{className:`${C} ${o?S:""}`,children:l.jsx(k2,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),l.jsxs("section",{className:N,children:[l.jsx(C2,{roster:f,frames:u,videoSources:x,snapshotFeeds:p,audioSources:v,session:n,canSpectateVideo:r}),l.jsx(E2,{})]})]}),l.jsx(rf,{}),l.jsx(tv,{})]})}function R2(){return l.jsx(M2,{})}function q2({children:n}){return l.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:l.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:l.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}function T2({roverId:n,session:s}){const r=s?.activeDrivers?.[n]||null,u=(s?.users||[]).find(h=>h.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=s?.mode,p=s?.turnQueues?.[n];return f==="turns"&&p?.current?`${u}`:u}function D2({rover:n,frame:s}){const r=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Ug({batteryState:n?.batteryState??null,charge:r,config:o})}function nl({children:n,className:s="",maxSize:r=1e3,minSize:o=14,style:u=void 0}){const f=m.useRef(null),p=m.useRef(null),[h,x]=m.useState(r);return m.useLayoutEffect(()=>{const g=f.current,v=p.current;if(!g||!v)return;let y=null;const N=()=>{const S=g.clientWidth;if(!S){M();return}let w=o,j=r,R=o;for(;w<=j;){const k=Math.floor((w+j)/2);v.style.fontSize=`${k}px`,v.scrollWidth<=S?(R=k,w=k+1):j=k-1}x(R)},M=()=>{y&&cancelAnimationFrame(y),y=requestAnimationFrame(N)};M();const C=new ResizeObserver(M);return C.observe(g),()=>{y&&cancelAnimationFrame(y),C.disconnect()}},[n,r,o]),l.jsx("div",{ref:f,className:"w-full min-w-0",children:l.jsx("div",{ref:p,className:`whitespace-nowrap ${s}`,style:{fontSize:`${h}px`,lineHeight:1.1,...u||{}},children:n})})}function kx({rover:n,frame:s,driverLabel:r,sessionInfo:o,videoMode:u="snapshot",snapshotFeed:f,withDivider:p=!1,showPreview:h=!0,variant:x="stacked"}){const g=D2({rover:n,frame:s}),v=g?.available?g.percentDisplay:null,y=x==="active";return l.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${p?"border-r border-slate-700/60":""}`,children:[l.jsx(Hd,{visual:g,orientation:y?"vertical":"horizontal",variant:"background"}),y?l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(nl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ia(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(nl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):l.jsx("div",{}),l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(nl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(nl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ia(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(nl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):null,l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(nl,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),l.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:l.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:h?l.jsx("div",{className:"mt-auto w-full",children:l.jsx("div",{className:"w-full aspect-[4/3]",children:l.jsx(Sr,{sessionInfo:o,videoMode:u,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}const _2=2e4,O2=3600*1e3;function B2(){const{session:n}=kr(),s=av();wf();const r=n?.mode==="lockdown",o=!!n?.isLocalNetwork,u=og(),f=n?.roster??[],[p,h]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>f.filter(V=>x[V.id]),[f,x]),v=g.length?g:f,y=hf(v.map(V=>V.id),{enabled:!r&&!o,version:n?.mode}),N=m.useMemo(()=>o?v.map(V=>({type:"rover",id:V.id,key:V.id})):[],[o,v]),M=br(N,{enabled:!r&&o,version:n?.mode}),C=m.useMemo(()=>g.flatMap(V=>{if(!V?.id||!V.media?.audioPublishUrl)return[];const F=String(V.id);return[{type:"rover",id:`${F}-audio`,key:`${F}-audio`}]}),[g]),S=br(C,{enabled:!r,version:n?.mode}),w=m.useMemo(()=>{if(!g.length)return[];if(!o){const F=g.filter(W=>y[W.id]?.objectUrl);return F.length?F:g}const V=g.filter(F=>{const W=M[F.id];return W?.url&&!W?.error});return V.length?V:g},[g,y,M,o]),j=m.useMemo(()=>w.map(V=>({type:"rover",rover:V})),[w]),R=m.useMemo(()=>j.map(V=>`r:${V.rover.id}`).join("|"),[j]);m.useEffect(()=>{h(0)},[R]),m.useEffect(()=>{if(!j.length)return;const V=setInterval(()=>{h(F=>(F+1)%j.length)},_2);return()=>clearInterval(V)},[j.length,R]);const k=j.length?j[p%j.length]:null,E=k?.type==="rover"?k.rover:null,B=!o&&E&&y[E.id]||null,X=o&&E&&M[E.id]||null,L=E&&S[`${E.id}-audio`]||null,z=E&&u[E.id]||null,K=E?T2({roverId:E.id,session:n}):null;return r?l.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),l.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?l.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[l.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:s?E?l.jsx(q2,{children:o?l.jsx("div",{className:"relative h-full w-full",children:j.map(V=>{const F=V.rover,W=E?.id===F.id;return l.jsx("div",{className:`absolute inset-0 ${W?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsx(Sr,{sessionInfo:M[F.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:W?L:null,forceMute:!W,label:F.name||F.id,roverColor:F.color||null,telemetryFrame:u[F.id]||null,batteryConfig:F.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},F.id)})}):l.jsx(Sr,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:B,audioSessionInfo:L,label:E.name||E.id,roverColor:E.color||null,telemetryFrame:z,batteryConfig:E.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):l.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."}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),l.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:E?l.jsx(kx,{rover:E,frame:z,driverLabel:K,sessionInfo:o?X:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[E.id]||null,showPreview:!1,variant:"active"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):l.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:l.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:f.length?f.map(V=>l.jsx(kx,{rover:V,frame:u[V.id]||null,driverLabel:null,sessionInfo:o&&M[V.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[V.id]||null,showPreview:!0,withDivider:!1},V.id)):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function L2(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const s=new URL(window.location.href);s.searchParams.set("refresh",Date.now().toString()),window.location.replace(s.toString())},O2);return()=>clearTimeout(n)},[]),l.jsxs(l.Fragment,{children:[l.jsx(B2,{}),l.jsx(rf,{scale:3})]})}function no(n){if(!n||!n.length)return null;const s=Math.floor(Math.random()*n.length);return n[s]||null}function z2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const s=no(n),r=no(n),o=s?.classList?.[0]||null;if(o&&r?.classList)try{r.classList.add(o)}catch{}const u=no(n),f=no(n),p=u?.classList?.[1]||null;if(p&&f?.classList)try{f.classList.add(p)}catch{}}function U2(){const n=pe(s=>!!s.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const s=window.setInterval(()=>{z2()},1);return()=>{window.clearInterval(s)}},[n]),null}Ay.createRoot(document.getElementById("root")).render(l.jsx(m.StrictMode,{children:l.jsx(KS,{children:l.jsx(PS,{children:l.jsx(ej,{children:l.jsx(cj,{children:l.jsxs(Wj,{children:[l.jsx(U2,{}),l.jsx(H1,{children:l.jsxs(g1,{children:[l.jsx(ao,{path:"/",element:l.jsx(S2,{})}),l.jsx(ao,{path:"/spectate",element:l.jsx(R2,{})}),l.jsx(ao,{path:"/mini",element:l.jsx(L2,{})})]})})]})})})})})}));
|