mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 18:10:47 -04:00
126 lines
529 KiB
JavaScript
126 lines
529 KiB
JavaScript
(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function Xy(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var _u={exports:{}},Ps={};var t0;function Qy(){if(t0)return Ps;t0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var p in f)p!=="key"&&(d[p]=f[p])}else d=f;return f=d.ref,{$$typeof:a,type:o,key:h,ref:f!==void 0?f:null,props:d}}return Ps.Fragment=l,Ps.jsx=i,Ps.jsxs=i,Ps}var n0;function Ky(){return n0||(n0=1,_u.exports=Qy()),_u.exports}var r=Ky(),Ou={exports:{}},je={};var a0;function Zy(){if(a0)return je;a0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),j=Symbol.iterator;function q(k){return k===null||typeof k!="object"?null:(k=j&&k[j]||k["@@iterator"],typeof k=="function"?k:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,N={};function E(k,U,ne){this.props=k,this.context=U,this.refs=N,this.updater=ne||C}E.prototype.isReactComponent={},E.prototype.setState=function(k,U){if(typeof k!="object"&&typeof k!="function"&&k!=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,k,U,"setState")},E.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function A(){}A.prototype=E.prototype;function M(k,U,ne){this.props=k,this.context=U,this.refs=N,this.updater=ne||C}var T=M.prototype=new A;T.constructor=M,w(T,E.prototype),T.isPureReactComponent=!0;var B=Array.isArray;function Z(){}var O={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function L(k,U,ne){var ae=ne.ref;return{$$typeof:a,type:k,key:U,ref:ae!==void 0?ae:null,props:ne}}function V(k,U){return L(k.type,U,k.props)}function K(k){return typeof k=="object"&&k!==null&&k.$$typeof===a}function te(k){var U={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(ne){return U[ne]})}var ce=/\/+/g;function re(k,U){return typeof k=="object"&&k!==null&&k.key!=null?te(""+k.key):U.toString(36)}function F(k){switch(k.status){case"fulfilled":return k.value;case"rejected":throw k.reason;default:switch(typeof k.status=="string"?k.then(Z,Z):(k.status="pending",k.then(function(U){k.status==="pending"&&(k.status="fulfilled",k.value=U)},function(U){k.status==="pending"&&(k.status="rejected",k.reason=U)})),k.status){case"fulfilled":return k.value;case"rejected":throw k.reason}}throw k}function R(k,U,ne,ae,me){var ie=typeof k;(ie==="undefined"||ie==="boolean")&&(k=null);var oe=!1;if(k===null)oe=!0;else switch(ie){case"bigint":case"string":case"number":oe=!0;break;case"object":switch(k.$$typeof){case a:case l:oe=!0;break;case y:return oe=k._init,R(oe(k._payload),U,ne,ae,me)}}if(oe)return me=me(k),oe=ae===""?"."+re(k,0):ae,B(me)?(ne="",oe!=null&&(ne=oe.replace(ce,"$&/")+"/"),R(me,U,ne,"",function(ge){return ge})):me!=null&&(K(me)&&(me=V(me,ne+(me.key==null||k&&k.key===me.key?"":(""+me.key).replace(ce,"$&/")+"/")+oe)),U.push(me)),1;oe=0;var he=ae===""?".":ae+":";if(B(k))for(var pe=0;pe<k.length;pe++)ae=k[pe],ie=he+re(ae,pe),oe+=R(ae,U,ne,ie,me);else if(pe=q(k),typeof pe=="function")for(k=pe.call(k),pe=0;!(ae=k.next()).done;)ae=ae.value,ie=he+re(ae,pe++),oe+=R(ae,U,ne,ie,me);else if(ie==="object"){if(typeof k.then=="function")return R(F(k),U,ne,ae,me);throw U=String(k),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return oe}function X(k,U,ne){if(k==null)return k;var ae=[],me=0;return R(k,ae,"","",function(ie){return U.call(ne,ie,me++)}),ae}function W(k){if(k._status===-1){var U=k._result;U=U(),U.then(function(ne){(k._status===0||k._status===-1)&&(k._status=1,k._result=ne)},function(ne){(k._status===0||k._status===-1)&&(k._status=2,k._result=ne)}),k._status===-1&&(k._status=0,k._result=U)}if(k._status===1)return k._result.default;throw k._result}var se=typeof reportError=="function"?reportError:function(k){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof k=="object"&&k!==null&&typeof k.message=="string"?String(k.message):String(k),error:k});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",k);return}console.error(k)},ue={map:X,forEach:function(k,U,ne){X(k,function(){U.apply(this,arguments)},ne)},count:function(k){var U=0;return X(k,function(){U++}),U},toArray:function(k){return X(k,function(U){return U})||[]},only:function(k){if(!K(k))throw Error("React.Children.only expected to receive a single React element child.");return k}};return je.Activity=b,je.Children=ue,je.Component=E,je.Fragment=i,je.Profiler=f,je.PureComponent=M,je.StrictMode=o,je.Suspense=x,je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,je.__COMPILER_RUNTIME={__proto__:null,c:function(k){return O.H.useMemoCache(k)}},je.cache=function(k){return function(){return k.apply(null,arguments)}},je.cacheSignal=function(){return null},je.cloneElement=function(k,U,ne){if(k==null)throw Error("The argument must be a React element, but you passed "+k+".");var ae=w({},k.props),me=k.key;if(U!=null)for(ie in U.key!==void 0&&(me=""+U.key),U)!H.call(U,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&U.ref===void 0||(ae[ie]=U[ie]);var ie=arguments.length-2;if(ie===1)ae.children=ne;else if(1<ie){for(var oe=Array(ie),he=0;he<ie;he++)oe[he]=arguments[he+2];ae.children=oe}return L(k.type,me,ae)},je.createContext=function(k){return k={$$typeof:h,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null},k.Provider=k,k.Consumer={$$typeof:d,_context:k},k},je.createElement=function(k,U,ne){var ae,me={},ie=null;if(U!=null)for(ae in U.key!==void 0&&(ie=""+U.key),U)H.call(U,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(me[ae]=U[ae]);var oe=arguments.length-2;if(oe===1)me.children=ne;else if(1<oe){for(var he=Array(oe),pe=0;pe<oe;pe++)he[pe]=arguments[pe+2];me.children=he}if(k&&k.defaultProps)for(ae in oe=k.defaultProps,oe)me[ae]===void 0&&(me[ae]=oe[ae]);return L(k,ie,me)},je.createRef=function(){return{current:null}},je.forwardRef=function(k){return{$$typeof:p,render:k}},je.isValidElement=K,je.lazy=function(k){return{$$typeof:y,_payload:{_status:-1,_result:k},_init:W}},je.memo=function(k,U){return{$$typeof:g,type:k,compare:U===void 0?null:U}},je.startTransition=function(k){var U=O.T,ne={};O.T=ne;try{var ae=k(),me=O.S;me!==null&&me(ne,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(Z,se)}catch(ie){se(ie)}finally{U!==null&&ne.types!==null&&(U.types=ne.types),O.T=U}},je.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},je.use=function(k){return O.H.use(k)},je.useActionState=function(k,U,ne){return O.H.useActionState(k,U,ne)},je.useCallback=function(k,U){return O.H.useCallback(k,U)},je.useContext=function(k){return O.H.useContext(k)},je.useDebugValue=function(){},je.useDeferredValue=function(k,U){return O.H.useDeferredValue(k,U)},je.useEffect=function(k,U){return O.H.useEffect(k,U)},je.useEffectEvent=function(k){return O.H.useEffectEvent(k)},je.useId=function(){return O.H.useId()},je.useImperativeHandle=function(k,U,ne){return O.H.useImperativeHandle(k,U,ne)},je.useInsertionEffect=function(k,U){return O.H.useInsertionEffect(k,U)},je.useLayoutEffect=function(k,U){return O.H.useLayoutEffect(k,U)},je.useMemo=function(k,U){return O.H.useMemo(k,U)},je.useOptimistic=function(k,U){return O.H.useOptimistic(k,U)},je.useReducer=function(k,U,ne){return O.H.useReducer(k,U,ne)},je.useRef=function(k){return O.H.useRef(k)},je.useState=function(k){return O.H.useState(k)},je.useSyncExternalStore=function(k,U,ne){return O.H.useSyncExternalStore(k,U,ne)},je.useTransition=function(){return O.H.useTransition()},je.version="19.2.0",je}var l0;function qf(){return l0||(l0=1,Ou.exports=Zy()),Ou.exports}var m=qf();const ll=Xy(m);var Bu={exports:{}},Ws={},Lu={exports:{}},zu={};var s0;function Iy(){return s0||(s0=1,(function(a){function l(R,X){var W=R.length;R.push(X);e:for(;0<W;){var se=W-1>>>1,ue=R[se];if(0<f(ue,X))R[se]=X,R[W]=ue,W=se;else break e}}function i(R){return R.length===0?null:R[0]}function o(R){if(R.length===0)return null;var X=R[0],W=R.pop();if(W!==X){R[0]=W;e:for(var se=0,ue=R.length,k=ue>>>1;se<k;){var U=2*(se+1)-1,ne=R[U],ae=U+1,me=R[ae];if(0>f(ne,W))ae<ue&&0>f(me,ne)?(R[se]=me,R[ae]=W,se=ae):(R[se]=ne,R[U]=W,se=U);else if(ae<ue&&0>f(me,W))R[se]=me,R[ae]=W,se=ae;else break e}}return X}function f(R,X){var W=R.sortIndex-X.sortIndex;return W!==0?W:R.id-X.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;a.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var x=[],g=[],y=1,b=null,j=3,q=!1,C=!1,w=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function T(R){for(var X=i(g);X!==null;){if(X.callback===null)o(g);else if(X.startTime<=R)o(g),X.sortIndex=X.expirationTime,l(x,X);else break;X=i(g)}}function B(R){if(w=!1,T(R),!C)if(i(x)!==null)C=!0,Z||(Z=!0,te());else{var X=i(g);X!==null&&F(B,X.startTime-R)}}var Z=!1,O=-1,H=5,L=-1;function V(){return N?!0:!(a.unstable_now()-L<H)}function K(){if(N=!1,Z){var R=a.unstable_now();L=R;var X=!0;try{e:{C=!1,w&&(w=!1,A(O),O=-1),q=!0;var W=j;try{t:{for(T(R),b=i(x);b!==null&&!(b.expirationTime>R&&V());){var se=b.callback;if(typeof se=="function"){b.callback=null,j=b.priorityLevel;var ue=se(b.expirationTime<=R);if(R=a.unstable_now(),typeof ue=="function"){b.callback=ue,T(R),X=!0;break t}b===i(x)&&o(x),T(R)}else o(x);b=i(x)}if(b!==null)X=!0;else{var k=i(g);k!==null&&F(B,k.startTime-R),X=!1}}break e}finally{b=null,j=W,q=!1}X=void 0}}finally{X?te():Z=!1}}}var te;if(typeof M=="function")te=function(){M(K)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,re=ce.port2;ce.port1.onmessage=K,te=function(){re.postMessage(null)}}else te=function(){E(K,0)};function F(R,X){O=E(function(){R(a.unstable_now())},X)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(R){R.callback=null},a.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<R?Math.floor(1e3/R):5},a.unstable_getCurrentPriorityLevel=function(){return j},a.unstable_next=function(R){switch(j){case 1:case 2:case 3:var X=3;break;default:X=j}var W=j;j=X;try{return R()}finally{j=W}},a.unstable_requestPaint=function(){N=!0},a.unstable_runWithPriority=function(R,X){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var W=j;j=R;try{return X()}finally{j=W}},a.unstable_scheduleCallback=function(R,X,W){var se=a.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?se+W:se):W=se,R){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=W+ue,R={id:y++,callback:X,priorityLevel:R,startTime:W,expirationTime:ue,sortIndex:-1},W>se?(R.sortIndex=W,l(g,R),i(x)===null&&R===i(g)&&(w?(A(O),O=-1):w=!0,F(B,W-se))):(R.sortIndex=ue,l(x,R),C||q||(C=!0,Z||(Z=!0,te()))),R},a.unstable_shouldYield=V,a.unstable_wrapCallback=function(R){var X=j;return function(){var W=j;j=X;try{return R.apply(this,arguments)}finally{j=W}}}})(zu)),zu}var i0;function Jy(){return i0||(i0=1,Lu.exports=Iy()),Lu.exports}var Uu={exports:{}},Rt={};var r0;function Py(){if(r0)return Rt;r0=1;var a=qf();function l(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)g+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(l(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(x,g,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:x,containerInfo:g,implementation:y}}var h=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Rt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Rt.createPortal=function(x,g){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(l(299));return d(x,g,null,y)},Rt.flushSync=function(x){var g=h.T,y=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=y,o.d.f()}},Rt.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))},Rt.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},Rt.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin),j=typeof g.integrity=="string"?g.integrity:void 0,q=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:j,fetchPriority:q}):y==="script"&&o.d.X(x,{crossOrigin:b,integrity:j,fetchPriority:q,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Rt.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Rt.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,b=p(y,g.crossOrigin);o.d.L(x,y,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Rt.preloadModule=function(x,g){if(typeof x=="string")if(g){var y=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Rt.requestFormReset=function(x){o.d.r(x)},Rt.unstable_batchedUpdates=function(x,g){return x(g)},Rt.useFormState=function(x,g,y){return h.H.useFormState(x,g,y)},Rt.useFormStatus=function(){return h.H.useHostTransitionStatus()},Rt.version="19.2.0",Rt}var o0;function Wy(){if(o0)return Uu.exports;o0=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Uu.exports=Py(),Uu.exports}var c0;function eb(){if(c0)return Ws;c0=1;var a=Jy(),l=qf(),i=Wy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var n=e,s=t;;){var c=n.return;if(c===null)break;var u=c.alternate;if(u===null){if(s=c.return,s!==null){n=s;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===n)return x(c),e;if(u===s)return x(c),t;u=u.sibling}throw Error(o(188))}if(n.return!==s.return)n=c,s=u;else{for(var v=!1,S=c.child;S;){if(S===n){v=!0,n=c,s=u;break}if(S===s){v=!0,s=c,n=u;break}S=S.sibling}if(!v){for(S=u.child;S;){if(S===n){v=!0,n=u,s=c;break}if(S===s){v=!0,s=u,n=c;break}S=S.sibling}if(!v)throw Error(o(189))}}if(n.alternate!==s)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function y(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=y(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,j=Symbol.for("react.element"),q=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),M=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=K&&e[K]||e["@@iterator"],typeof e=="function"?e:null)}var ce=Symbol.for("react.client.reference");function re(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case E:return"Profiler";case N:return"StrictMode";case B:return"Suspense";case Z:return"SuspenseList";case L:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case M:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case T:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return t=e.displayName||null,t!==null?t:re(e.type)||"Memo";case H:t=e._payload,e=e._init;try{return re(e(t))}catch{}}return null}var F=Array.isArray,R=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},se=[],ue=-1;function k(e){return{current:e}}function U(e){0>ue||(e.current=se[ue],se[ue]=null,ue--)}function ne(e,t){ue++,se[ue]=e.current,e.current=t}var ae=k(null),me=k(null),ie=k(null),oe=k(null);function he(e,t){switch(ne(ie,t),ne(me,e),ne(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Np(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Np(t),e=wp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(ae),ne(ae,e)}function pe(){U(ae),U(me),U(ie)}function ge(e){e.memoizedState!==null&&ne(oe,e);var t=ae.current,n=wp(t,e.type);t!==n&&(ne(me,e),ne(ae,n))}function Oe(e){me.current===e&&(U(ae),U(me)),oe.current===e&&(U(oe),Ks._currentValue=W)}var Y,le;function fe(e){if(Y===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Y=t&&t[1]||"",le=-1<n.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+Y+e+le}var Ae=!1;function Ve(e,t){if(!e||Ae)return"";Ae=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(I){var Q=I}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(I){Q=I}e.call(ee.prototype)}}else{try{throw Error()}catch(I){Q=I}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(I){if(I&&Q&&typeof I.stack=="string")return[I.stack,Q.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=s.DetermineComponentFrameRoot(),v=u[0],S=u[1];if(v&&S){var D=v.split(`
|
||
`),G=S.split(`
|
||
`);for(c=s=0;s<D.length&&!D[s].includes("DetermineComponentFrameRoot");)s++;for(;c<G.length&&!G[c].includes("DetermineComponentFrameRoot");)c++;if(s===D.length||c===G.length)for(s=D.length-1,c=G.length-1;1<=s&&0<=c&&D[s]!==G[c];)c--;for(;1<=s&&0<=c;s--,c--)if(D[s]!==G[c]){if(s!==1||c!==1)do if(s--,c--,0>c||D[s]!==G[c]){var J=`
|
||
`+D[s].replace(" at new "," at ");return e.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",e.displayName)),J}while(1<=s&&0<=c);break}}}finally{Ae=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?fe(n):""}function Ie(e,t){switch(e.tag){case 26:case 27:case 5:return fe(e.type);case 16:return fe("Lazy");case 13:return e.child!==t&&t!==null?fe("Suspense Fallback"):fe("Suspense");case 19:return fe("SuspenseList");case 0:case 15:return Ve(e.type,!1);case 11:return Ve(e.type.render,!1);case 1:return Ve(e.type,!0);case 31:return fe("Activity");default:return""}}function qt(e){try{var t="",n=null;do t+=Ie(e,n),n=e,e=e.return;while(e);return t}catch(s){return`
|
||
Error generating stack: `+s.message+`
|
||
`+s.stack}}var Wt=Object.prototype.hasOwnProperty,ve=a.unstable_scheduleCallback,Ce=a.unstable_cancelCallback,$e=a.unstable_shouldYield,Tt=a.unstable_requestPaint,Ue=a.unstable_now,vt=a.unstable_getCurrentPriorityLevel,ft=a.unstable_ImmediatePriority,_t=a.unstable_UserBlockingPriority,gn=a.unstable_NormalPriority,il=a.unstable_LowPriority,Ot=a.unstable_IdlePriority,is=a.log,rs=a.unstable_setDisableYieldValue,vn=null,bt=null;function en(e){if(typeof is=="function"&&rs(e),bt&&typeof bt.setStrictMode=="function")try{bt.setStrictMode(vn,e)}catch{}}var dt=Math.clz32?Math.clz32:No,jo=Math.log,rl=Math.LN2;function No(e){return e>>>=0,e===0?32:31-(jo(e)/rl|0)|0}var Da=256,et=262144,ol=4194304;function Gt(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 ra(e,t,n){var s=e.pendingLanes;if(s===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var S=s&134217727;return S!==0?(s=S&~u,s!==0?c=Gt(s):(v&=S,v!==0?c=Gt(v):n||(n=S&~e,n!==0&&(c=Gt(n))))):(S=s&~u,S!==0?c=Gt(S):v!==0?c=Gt(v):n||(n=s&~e,n!==0&&(c=Gt(n)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,n=t&-t,u>=n||u===32&&(n&4194048)!==0)?t:c}function Cn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ni(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 wi(){var e=ol;return ol<<=1,(ol&62914560)===0&&(ol=4194304),e}function os(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function _a(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ci(e,t,n,s,c,u){var v=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var S=e.entanglements,D=e.expirationTimes,G=e.hiddenUpdates;for(n=v&~n;0<n;){var J=31-dt(n),ee=1<<J;S[J]=0,D[J]=-1;var Q=G[J];if(Q!==null)for(G[J]=null,J=0;J<Q.length;J++){var I=Q[J];I!==null&&(I.lane&=-536870913)}n&=~ee}s!==0&&tn(e,s,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function tn(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-dt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|n&261930}function be(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var s=31-dt(n),c=1<<s;c&t|e[s]&t&&(e[s]|=t),n&=~c}}function Je(e,t){var n=t&-t;return n=(n&42)!==0?1:Pe(n),(n&(e.suspendedLanes|t))!==0?0:n}function Pe(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 Ee(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ge(){var e=X.p;return e!==0?e:(e=window.event,e===void 0?32:Kp(e.type))}function jt(e,t){var n=X.p;try{return X.p=e,t()}finally{X.p=n}}var Bt=Math.random().toString(36).slice(2),st="__reactFiber$"+Bt,Be="__reactProps$"+Bt,nn="__reactContainer$"+Bt,wo="__reactEvents$"+Bt,Og="__reactListeners$"+Bt,Bg="__reactHandles$"+Bt,fd="__reactResources$"+Bt,cs="__reactMarker$"+Bt;function Co(e){delete e[st],delete e[Be],delete e[wo],delete e[Og],delete e[Bg]}function cl(e){var t=e[st];if(t)return t;for(var n=e.parentNode;n;){if(t=n[nn]||n[st]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Tp(e);e!==null;){if(n=e[st])return n;e=Tp(e)}return t}e=n,n=e.parentNode}return null}function ul(e){if(e=e[st]||e[nn]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function us(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function fl(e){var t=e[fd];return t||(t=e[fd]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function St(e){e[cs]=!0}var dd=new Set,md={};function Oa(e,t){dl(e,t),dl(e+"Capture",t)}function dl(e,t){for(md[e]=t,e=0;e<t.length;e++)dd.add(t[e])}var Lg=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]*$"),hd={},pd={};function zg(e){return Wt.call(pd,e)?!0:Wt.call(hd,e)?!1:Lg.test(e)?pd[e]=!0:(hd[e]=!0,!1)}function Ei(e,t,n){if(zg(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var s=t.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function ki(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Bn(e,t,n,s){if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+s)}}function an(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function xd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ug(e,t,n){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var c=s.get,u=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(v){n=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return n},setValue:function(v){n=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Eo(e){if(!e._valueTracker){var t=xd(e)?"checked":"value";e._valueTracker=Ug(e,t,""+e[t])}}function gd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),s="";return e&&(s=xd(e)?e.checked?"true":"false":e.value),e=s,e!==n?(t.setValue(e),!0):!1}function Mi(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 Hg=/[\n"\\]/g;function ln(e){return e.replace(Hg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function ko(e,t,n,s,c,u,v,S){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+an(t)):e.value!==""+an(t)&&(e.value=""+an(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Mo(e,v,an(t)):n!=null?Mo(e,v,an(n)):s!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.name=""+an(S):e.removeAttribute("name")}function vd(e,t,n,s,c,u,v,S){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||n!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){Eo(e);return}n=n!=null?""+an(n):"",t=t!=null?""+an(t):n,S||t===e.value||(e.value=t),e.defaultValue=t}s=s??c,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=S?e.checked:!!s,e.defaultChecked=!!s,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),Eo(e)}function Mo(e,t,n){t==="number"&&Mi(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function ml(e,t,n,s){if(e=e.options,t){t={};for(var c=0;c<n.length;c++)t["$"+n[c]]=!0;for(n=0;n<e.length;n++)c=t.hasOwnProperty("$"+e[n].value),e[n].selected!==c&&(e[n].selected=c),c&&s&&(e[n].defaultSelected=!0)}else{for(n=""+an(n),t=null,c=0;c<e.length;c++){if(e[c].value===n){e[c].selected=!0,s&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function yd(e,t,n){if(t!=null&&(t=""+an(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+an(n):""}function bd(e,t,n,s){if(t==null){if(s!=null){if(n!=null)throw Error(o(92));if(F(s)){if(1<s.length)throw Error(o(93));s=s[0]}n=s}n==null&&(n=""),t=n}n=an(t),e.defaultValue=n,s=e.textContent,s===n&&s!==""&&s!==null&&(e.value=s),Eo(e)}function hl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Vg=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 Sd(e,t,n){var s=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,n):typeof n!="number"||n===0||Vg.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Ad(e,t,n){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,n!=null){for(var s in n)!n.hasOwnProperty(s)||t!=null&&t.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var c in t)s=t[c],t.hasOwnProperty(c)&&n[c]!==s&&Sd(e,c,s)}else for(var u in t)t.hasOwnProperty(u)&&Sd(e,u,t[u])}function qo(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 $g=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"]]),Gg=/^[\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 qi(e){return Gg.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Ln(){}var Ro=null;function To(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var pl=null,xl=null;function jd(e){var t=ul(e);if(t&&(e=t.stateNode)){var n=e[Be]||null;e:switch(e=t.stateNode,t.type){case"input":if(ko(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+ln(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var s=n[t];if(s!==e&&s.form===e.form){var c=s[Be]||null;if(!c)throw Error(o(90));ko(s,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<n.length;t++)s=n[t],s.form===e.form&&gd(s)}break e;case"textarea":yd(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&ml(e,!!n.multiple,t,!1)}}}var Do=!1;function Nd(e,t,n){if(Do)return e(t,n);Do=!0;try{var s=e(t);return s}finally{if(Do=!1,(pl!==null||xl!==null)&&(gr(),pl&&(t=pl,e=xl,xl=pl=null,jd(t),e)))for(t=0;t<e.length;t++)jd(e[t])}}function fs(e,t){var n=e.stateNode;if(n===null)return null;var s=n[Be]||null;if(s===null)return null;n=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(o(231,t,typeof n));return n}var zn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_o=!1;if(zn)try{var ds={};Object.defineProperty(ds,"passive",{get:function(){_o=!0}}),window.addEventListener("test",ds,ds),window.removeEventListener("test",ds,ds)}catch{_o=!1}var oa=null,Oo=null,Ri=null;function wd(){if(Ri)return Ri;var e,t=Oo,n=t.length,s,c="value"in oa?oa.value:oa.textContent,u=c.length;for(e=0;e<n&&t[e]===c[e];e++);var v=n-e;for(s=1;s<=v&&t[n-s]===c[u-s];s++);return Ri=c.slice(e,1<s?1-s:void 0)}function Ti(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 Di(){return!0}function Cd(){return!1}function Lt(e){function t(n,s,c,u,v){this._reactName=n,this._targetInst=c,this.type=s,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var S in e)e.hasOwnProperty(S)&&(n=e[S],this[S]=n?n(u):u[S]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Di:Cd,this.isPropagationStopped=Cd,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Di)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Di)},persist:function(){},isPersistent:Di}),t}var Ba={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_i=Lt(Ba),ms=b({},Ba,{view:0,detail:0}),Yg=Lt(ms),Bo,Lo,hs,Oi=b({},ms,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Uo,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!==hs&&(hs&&e.type==="mousemove"?(Bo=e.screenX-hs.screenX,Lo=e.screenY-hs.screenY):Lo=Bo=0,hs=e),Bo)},movementY:function(e){return"movementY"in e?e.movementY:Lo}}),Ed=Lt(Oi),Fg=b({},Oi,{dataTransfer:0}),Xg=Lt(Fg),Qg=b({},ms,{relatedTarget:0}),zo=Lt(Qg),Kg=b({},Ba,{animationName:0,elapsedTime:0,pseudoElement:0}),Zg=Lt(Kg),Ig=b({},Ba,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Jg=Lt(Ig),Pg=b({},Ba,{data:0}),kd=Lt(Pg),Wg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ev={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"},tv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tv[e])?!!t[e]:!1}function Uo(){return nv}var av=b({},ms,{key:function(e){if(e.key){var t=Wg[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ti(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ev[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Uo,charCode:function(e){return e.type==="keypress"?Ti(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ti(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),lv=Lt(av),sv=b({},Oi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Md=Lt(sv),iv=b({},ms,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Uo}),rv=Lt(iv),ov=b({},Ba,{propertyName:0,elapsedTime:0,pseudoElement:0}),cv=Lt(ov),uv=b({},Oi,{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}),fv=Lt(uv),dv=b({},Ba,{newState:0,oldState:0}),mv=Lt(dv),hv=[9,13,27,32],Ho=zn&&"CompositionEvent"in window,ps=null;zn&&"documentMode"in document&&(ps=document.documentMode);var pv=zn&&"TextEvent"in window&&!ps,qd=zn&&(!Ho||ps&&8<ps&&11>=ps),Rd=" ",Td=!1;function Dd(e,t){switch(e){case"keyup":return hv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _d(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var gl=!1;function xv(e,t){switch(e){case"compositionend":return _d(t);case"keypress":return t.which!==32?null:(Td=!0,Rd);case"textInput":return e=t.data,e===Rd&&Td?null:e;default:return null}}function gv(e,t){if(gl)return e==="compositionend"||!Ho&&Dd(e,t)?(e=wd(),Ri=Oo=oa=null,gl=!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 qd&&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 Od(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!vv[e.type]:t==="textarea"}function Bd(e,t,n,s){pl?xl?xl.push(s):xl=[s]:pl=s,t=Nr(t,"onChange"),0<t.length&&(n=new _i("onChange","change",null,n,s),e.push({event:n,listeners:t}))}var xs=null,gs=null;function yv(e){vp(e,0)}function Bi(e){var t=us(e);if(gd(t))return e}function Ld(e,t){if(e==="change")return t}var zd=!1;if(zn){var Vo;if(zn){var $o="oninput"in document;if(!$o){var Ud=document.createElement("div");Ud.setAttribute("oninput","return;"),$o=typeof Ud.oninput=="function"}Vo=$o}else Vo=!1;zd=Vo&&(!document.documentMode||9<document.documentMode)}function Hd(){xs&&(xs.detachEvent("onpropertychange",Vd),gs=xs=null)}function Vd(e){if(e.propertyName==="value"&&Bi(gs)){var t=[];Bd(t,gs,e,To(e)),Nd(yv,t)}}function bv(e,t,n){e==="focusin"?(Hd(),xs=t,gs=n,xs.attachEvent("onpropertychange",Vd)):e==="focusout"&&Hd()}function Sv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Bi(gs)}function Av(e,t){if(e==="click")return Bi(t)}function jv(e,t){if(e==="input"||e==="change")return Bi(t)}function Nv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Yt=typeof Object.is=="function"?Object.is:Nv;function vs(e,t){if(Yt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(s=0;s<n.length;s++){var c=n[s];if(!Wt.call(t,c)||!Yt(e[c],t[c]))return!1}return!0}function $d(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gd(e,t){var n=$d(e);e=0;for(var s;n;){if(n.nodeType===3){if(s=e+n.textContent.length,e<=t&&s>=t)return{node:n,offset:t-e};e=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=$d(n)}}function Yd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Fd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Mi(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Mi(e.document)}return t}function Go(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 wv=zn&&"documentMode"in document&&11>=document.documentMode,vl=null,Yo=null,ys=null,Fo=!1;function Xd(e,t,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fo||vl==null||vl!==Mi(s)||(s=vl,"selectionStart"in s&&Go(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),ys&&vs(ys,s)||(ys=s,s=Nr(Yo,"onSelect"),0<s.length&&(t=new _i("onSelect","select",null,t,n),e.push({event:t,listeners:s}),t.target=vl)))}function La(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var yl={animationend:La("Animation","AnimationEnd"),animationiteration:La("Animation","AnimationIteration"),animationstart:La("Animation","AnimationStart"),transitionrun:La("Transition","TransitionRun"),transitionstart:La("Transition","TransitionStart"),transitioncancel:La("Transition","TransitionCancel"),transitionend:La("Transition","TransitionEnd")},Xo={},Qd={};zn&&(Qd=document.createElement("div").style,"AnimationEvent"in window||(delete yl.animationend.animation,delete yl.animationiteration.animation,delete yl.animationstart.animation),"TransitionEvent"in window||delete yl.transitionend.transition);function za(e){if(Xo[e])return Xo[e];if(!yl[e])return e;var t=yl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Qd)return Xo[e]=t[n];return e}var Kd=za("animationend"),Zd=za("animationiteration"),Id=za("animationstart"),Cv=za("transitionrun"),Ev=za("transitionstart"),kv=za("transitioncancel"),Jd=za("transitionend"),Pd=new Map,Qo="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(" ");Qo.push("scrollEnd");function yn(e,t){Pd.set(e,t),Oa(t,[e])}var Li=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)},sn=[],bl=0,Ko=0;function zi(){for(var e=bl,t=Ko=bl=0;t<e;){var n=sn[t];sn[t++]=null;var s=sn[t];sn[t++]=null;var c=sn[t];sn[t++]=null;var u=sn[t];if(sn[t++]=null,s!==null&&c!==null){var v=s.pending;v===null?c.next=c:(c.next=v.next,v.next=c),s.pending=c}u!==0&&Wd(n,c,u)}}function Ui(e,t,n,s){sn[bl++]=e,sn[bl++]=t,sn[bl++]=n,sn[bl++]=s,Ko|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Zo(e,t,n,s){return Ui(e,t,n,s),Hi(e)}function Ua(e,t){return Ui(e,null,null,t),Hi(e)}function Wd(e,t,n){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n);for(var c=!1,u=e.return;u!==null;)u.childLanes|=n,s=u.alternate,s!==null&&(s.childLanes|=n),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-dt(n),e=u.hiddenUpdates,s=e[c],s===null?e[c]=[t]:s.push(t),t.lane=n|536870912),u):null}function Hi(e){if(50<Vs)throw Vs=0,lu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Sl={};function Mv(e,t,n,s){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ft(e,t,n,s){return new Mv(e,t,n,s)}function Io(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Un(e,t){var n=e.alternate;return n===null?(n=Ft(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function em(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Vi(e,t,n,s,c,u){var v=0;if(s=e,typeof e=="function")Io(e)&&(v=1);else if(typeof e=="string")v=_y(e,n,ae.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case L:return e=Ft(31,n,t,c),e.elementType=L,e.lanes=u,e;case w:return Ha(n.children,c,u,t);case N:v=8,c|=24;break;case E:return e=Ft(12,n,t,c|2),e.elementType=E,e.lanes=u,e;case B:return e=Ft(13,n,t,c),e.elementType=B,e.lanes=u,e;case Z:return e=Ft(19,n,t,c),e.elementType=Z,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case M:v=10;break e;case A:v=9;break e;case T:v=11;break e;case O:v=14;break e;case H:v=16,s=null;break e}v=29,n=Error(o(130,e===null?"null":typeof e,"")),s=null}return t=Ft(v,n,t,c),t.elementType=e,t.type=s,t.lanes=u,t}function Ha(e,t,n,s){return e=Ft(7,e,s,t),e.lanes=n,e}function Jo(e,t,n){return e=Ft(6,e,null,t),e.lanes=n,e}function tm(e){var t=Ft(18,null,null,0);return t.stateNode=e,t}function Po(e,t,n){return t=Ft(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var nm=new WeakMap;function rn(e,t){if(typeof e=="object"&&e!==null){var n=nm.get(e);return n!==void 0?n:(t={value:e,source:t,stack:qt(t)},nm.set(e,t),t)}return{value:e,source:t,stack:qt(t)}}var Al=[],jl=0,$i=null,bs=0,on=[],cn=0,ca=null,En=1,kn="";function Hn(e,t){Al[jl++]=bs,Al[jl++]=$i,$i=e,bs=t}function am(e,t,n){on[cn++]=En,on[cn++]=kn,on[cn++]=ca,ca=e;var s=En;e=kn;var c=32-dt(s)-1;s&=~(1<<c),n+=1;var u=32-dt(t)+c;if(30<u){var v=c-c%5;u=(s&(1<<v)-1).toString(32),s>>=v,c-=v,En=1<<32-dt(t)+c|n<<c|s,kn=u+e}else En=1<<u|n<<c|s,kn=e}function Wo(e){e.return!==null&&(Hn(e,1),am(e,1,0))}function ec(e){for(;e===$i;)$i=Al[--jl],Al[jl]=null,bs=Al[--jl],Al[jl]=null;for(;e===ca;)ca=on[--cn],on[cn]=null,kn=on[--cn],on[cn]=null,En=on[--cn],on[cn]=null}function lm(e,t){on[cn++]=En,on[cn++]=kn,on[cn++]=ca,En=t.id,kn=t.overflow,ca=e}var Nt=null,tt=null,Te=!1,ua=null,un=!1,tc=Error(o(519));function fa(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ss(rn(t,e)),tc}function sm(e){var t=e.stateNode,n=e.type,s=e.memoizedProps;switch(t[st]=e,t[Be]=s,n){case"dialog":Me("cancel",t),Me("close",t);break;case"iframe":case"object":case"embed":Me("load",t);break;case"video":case"audio":for(n=0;n<Gs.length;n++)Me(Gs[n],t);break;case"source":Me("error",t);break;case"img":case"image":case"link":Me("error",t),Me("load",t);break;case"details":Me("toggle",t);break;case"input":Me("invalid",t),vd(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":Me("invalid",t);break;case"textarea":Me("invalid",t),bd(t,s.value,s.defaultValue,s.children)}n=s.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||s.suppressHydrationWarning===!0||Ap(t.textContent,n)?(s.popover!=null&&(Me("beforetoggle",t),Me("toggle",t)),s.onScroll!=null&&Me("scroll",t),s.onScrollEnd!=null&&Me("scrollend",t),s.onClick!=null&&(t.onclick=Ln),t=!0):t=!1,t||fa(e,!0)}function im(e){for(Nt=e.return;Nt;)switch(Nt.tag){case 5:case 31:case 13:un=!1;return;case 27:case 3:un=!0;return;default:Nt=Nt.return}}function Nl(e){if(e!==Nt)return!1;if(!Te)return im(e),Te=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||yu(e.type,e.memoizedProps)),n=!n),n&&tt&&fa(e),im(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));tt=Rp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));tt=Rp(e)}else t===27?(t=tt,wa(e.type)?(e=Nu,Nu=null,tt=e):tt=t):tt=Nt?dn(e.stateNode.nextSibling):null;return!0}function Va(){tt=Nt=null,Te=!1}function nc(){var e=ua;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),ua=null),e}function Ss(e){ua===null?ua=[e]:ua.push(e)}var ac=k(null),$a=null,Vn=null;function da(e,t,n){ne(ac,t._currentValue),t._currentValue=n}function $n(e){e._currentValue=ac.current,U(ac)}function lc(e,t,n){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===n)break;e=e.return}}function sc(e,t,n,s){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var v=c.child;u=u.firstContext;e:for(;u!==null;){var S=u;u=c;for(var D=0;D<t.length;D++)if(S.context===t[D]){u.lanes|=n,S=u.alternate,S!==null&&(S.lanes|=n),lc(u.return,n,e),s||(v=null);break e}u=S.next}}else if(c.tag===18){if(v=c.return,v===null)throw Error(o(341));v.lanes|=n,u=v.alternate,u!==null&&(u.lanes|=n),lc(v,n,e),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===e){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function wl(e,t,n,s){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var S=c.type;Yt(c.pendingProps.value,v.value)||(e!==null?e.push(S):e=[S])}}else if(c===oe.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Ks):e=[Ks])}c=c.return}e!==null&&sc(t,e,n,s),t.flags|=262144}function Gi(e){for(e=e.firstContext;e!==null;){if(!Yt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ga(e){$a=e,Vn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function wt(e){return rm($a,e)}function Yi(e,t){return $a===null&&Ga(e),rm(e,t)}function rm(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Vn===null){if(e===null)throw Error(o(308));Vn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Vn=Vn.next=t;return n}var qv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},Rv=a.unstable_scheduleCallback,Tv=a.unstable_NormalPriority,mt={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ic(){return{controller:new qv,data:new Map,refCount:0}}function As(e){e.refCount--,e.refCount===0&&Rv(Tv,function(){e.controller.abort()})}var js=null,rc=0,Cl=0,El=null;function Dv(e,t){if(js===null){var n=js=[];rc=0,Cl=uu(),El={status:"pending",value:void 0,then:function(s){n.push(s)}}}return rc++,t.then(om,om),t}function om(){if(--rc===0&&js!==null){El!==null&&(El.status="fulfilled");var e=js;js=null,Cl=0,El=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function _v(e,t){var n=[],s={status:"pending",value:null,reason:null,then:function(c){n.push(c)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var c=0;c<n.length;c++)(0,n[c])(t)},function(c){for(s.status="rejected",s.reason=c,c=0;c<n.length;c++)(0,n[c])(void 0)}),s}var cm=R.S;R.S=function(e,t){Xh=Ue(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Dv(e,t),cm!==null&&cm(e,t)};var Ya=k(null);function oc(){var e=Ya.current;return e!==null?e:We.pooledCache}function Fi(e,t){t===null?ne(Ya,Ya.current):ne(Ya,t.pool)}function um(){var e=oc();return e===null?null:{parent:mt._currentValue,pool:e}}var kl=Error(o(460)),cc=Error(o(474)),Xi=Error(o(542)),Qi={then:function(){}};function fm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function dm(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Ln,Ln),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,hm(e),e;default:if(typeof t.status=="string")t.then(Ln,Ln);else{if(e=We,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(s){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=s}},function(s){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=s}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,hm(e),e}throw Xa=t,kl}}function Fa(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Xa=n,kl):n}}var Xa=null;function mm(){if(Xa===null)throw Error(o(459));var e=Xa;return Xa=null,e}function hm(e){if(e===kl||e===Xi)throw Error(o(483))}var Ml=null,Ns=0;function Ki(e){var t=Ns;return Ns+=1,Ml===null&&(Ml=[]),dm(Ml,e,t)}function ws(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Zi(e,t){throw t.$$typeof===j?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function pm(e){function t(z,_){if(e){var $=z.deletions;$===null?(z.deletions=[_],z.flags|=16):$.push(_)}}function n(z,_){if(!e)return null;for(;_!==null;)t(z,_),_=_.sibling;return null}function s(z){for(var _=new Map;z!==null;)z.key!==null?_.set(z.key,z):_.set(z.index,z),z=z.sibling;return _}function c(z,_){return z=Un(z,_),z.index=0,z.sibling=null,z}function u(z,_,$){return z.index=$,e?($=z.alternate,$!==null?($=$.index,$<_?(z.flags|=67108866,_):$):(z.flags|=67108866,_)):(z.flags|=1048576,_)}function v(z){return e&&z.alternate===null&&(z.flags|=67108866),z}function S(z,_,$,P){return _===null||_.tag!==6?(_=Jo($,z.mode,P),_.return=z,_):(_=c(_,$),_.return=z,_)}function D(z,_,$,P){var ye=$.type;return ye===w?J(z,_,$.props.children,P,$.key):_!==null&&(_.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===H&&Fa(ye)===_.type)?(_=c(_,$.props),ws(_,$),_.return=z,_):(_=Vi($.type,$.key,$.props,null,z.mode,P),ws(_,$),_.return=z,_)}function G(z,_,$,P){return _===null||_.tag!==4||_.stateNode.containerInfo!==$.containerInfo||_.stateNode.implementation!==$.implementation?(_=Po($,z.mode,P),_.return=z,_):(_=c(_,$.children||[]),_.return=z,_)}function J(z,_,$,P,ye){return _===null||_.tag!==7?(_=Ha($,z.mode,P,ye),_.return=z,_):(_=c(_,$),_.return=z,_)}function ee(z,_,$){if(typeof _=="string"&&_!==""||typeof _=="number"||typeof _=="bigint")return _=Jo(""+_,z.mode,$),_.return=z,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case q:return $=Vi(_.type,_.key,_.props,null,z.mode,$),ws($,_),$.return=z,$;case C:return _=Po(_,z.mode,$),_.return=z,_;case H:return _=Fa(_),ee(z,_,$)}if(F(_)||te(_))return _=Ha(_,z.mode,$,null),_.return=z,_;if(typeof _.then=="function")return ee(z,Ki(_),$);if(_.$$typeof===M)return ee(z,Yi(z,_),$);Zi(z,_)}return null}function Q(z,_,$,P){var ye=_!==null?_.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return ye!==null?null:S(z,_,""+$,P);if(typeof $=="object"&&$!==null){switch($.$$typeof){case q:return $.key===ye?D(z,_,$,P):null;case C:return $.key===ye?G(z,_,$,P):null;case H:return $=Fa($),Q(z,_,$,P)}if(F($)||te($))return ye!==null?null:J(z,_,$,P,null);if(typeof $.then=="function")return Q(z,_,Ki($),P);if($.$$typeof===M)return Q(z,_,Yi(z,$),P);Zi(z,$)}return null}function I(z,_,$,P,ye){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return z=z.get($)||null,S(_,z,""+P,ye);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case q:return z=z.get(P.key===null?$:P.key)||null,D(_,z,P,ye);case C:return z=z.get(P.key===null?$:P.key)||null,G(_,z,P,ye);case H:return P=Fa(P),I(z,_,$,P,ye)}if(F(P)||te(P))return z=z.get($)||null,J(_,z,P,ye,null);if(typeof P.then=="function")return I(z,_,$,Ki(P),ye);if(P.$$typeof===M)return I(z,_,$,Yi(_,P),ye);Zi(_,P)}return null}function de(z,_,$,P){for(var ye=null,Le=null,xe=_,we=_=0,Re=null;xe!==null&&we<$.length;we++){xe.index>we?(Re=xe,xe=null):Re=xe.sibling;var ze=Q(z,xe,$[we],P);if(ze===null){xe===null&&(xe=Re);break}e&&xe&&ze.alternate===null&&t(z,xe),_=u(ze,_,we),Le===null?ye=ze:Le.sibling=ze,Le=ze,xe=Re}if(we===$.length)return n(z,xe),Te&&Hn(z,we),ye;if(xe===null){for(;we<$.length;we++)xe=ee(z,$[we],P),xe!==null&&(_=u(xe,_,we),Le===null?ye=xe:Le.sibling=xe,Le=xe);return Te&&Hn(z,we),ye}for(xe=s(xe);we<$.length;we++)Re=I(xe,z,we,$[we],P),Re!==null&&(e&&Re.alternate!==null&&xe.delete(Re.key===null?we:Re.key),_=u(Re,_,we),Le===null?ye=Re:Le.sibling=Re,Le=Re);return e&&xe.forEach(function(qa){return t(z,qa)}),Te&&Hn(z,we),ye}function Se(z,_,$,P){if($==null)throw Error(o(151));for(var ye=null,Le=null,xe=_,we=_=0,Re=null,ze=$.next();xe!==null&&!ze.done;we++,ze=$.next()){xe.index>we?(Re=xe,xe=null):Re=xe.sibling;var qa=Q(z,xe,ze.value,P);if(qa===null){xe===null&&(xe=Re);break}e&&xe&&qa.alternate===null&&t(z,xe),_=u(qa,_,we),Le===null?ye=qa:Le.sibling=qa,Le=qa,xe=Re}if(ze.done)return n(z,xe),Te&&Hn(z,we),ye;if(xe===null){for(;!ze.done;we++,ze=$.next())ze=ee(z,ze.value,P),ze!==null&&(_=u(ze,_,we),Le===null?ye=ze:Le.sibling=ze,Le=ze);return Te&&Hn(z,we),ye}for(xe=s(xe);!ze.done;we++,ze=$.next())ze=I(xe,z,we,ze.value,P),ze!==null&&(e&&ze.alternate!==null&&xe.delete(ze.key===null?we:ze.key),_=u(ze,_,we),Le===null?ye=ze:Le.sibling=ze,Le=ze);return e&&xe.forEach(function(Fy){return t(z,Fy)}),Te&&Hn(z,we),ye}function Ke(z,_,$,P){if(typeof $=="object"&&$!==null&&$.type===w&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case q:e:{for(var ye=$.key;_!==null;){if(_.key===ye){if(ye=$.type,ye===w){if(_.tag===7){n(z,_.sibling),P=c(_,$.props.children),P.return=z,z=P;break e}}else if(_.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===H&&Fa(ye)===_.type){n(z,_.sibling),P=c(_,$.props),ws(P,$),P.return=z,z=P;break e}n(z,_);break}else t(z,_);_=_.sibling}$.type===w?(P=Ha($.props.children,z.mode,P,$.key),P.return=z,z=P):(P=Vi($.type,$.key,$.props,null,z.mode,P),ws(P,$),P.return=z,z=P)}return v(z);case C:e:{for(ye=$.key;_!==null;){if(_.key===ye)if(_.tag===4&&_.stateNode.containerInfo===$.containerInfo&&_.stateNode.implementation===$.implementation){n(z,_.sibling),P=c(_,$.children||[]),P.return=z,z=P;break e}else{n(z,_);break}else t(z,_);_=_.sibling}P=Po($,z.mode,P),P.return=z,z=P}return v(z);case H:return $=Fa($),Ke(z,_,$,P)}if(F($))return de(z,_,$,P);if(te($)){if(ye=te($),typeof ye!="function")throw Error(o(150));return $=ye.call($),Se(z,_,$,P)}if(typeof $.then=="function")return Ke(z,_,Ki($),P);if($.$$typeof===M)return Ke(z,_,Yi(z,$),P);Zi(z,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,_!==null&&_.tag===6?(n(z,_.sibling),P=c(_,$),P.return=z,z=P):(n(z,_),P=Jo($,z.mode,P),P.return=z,z=P),v(z)):n(z,_)}return function(z,_,$,P){try{Ns=0;var ye=Ke(z,_,$,P);return Ml=null,ye}catch(xe){if(xe===kl||xe===Xi)throw xe;var Le=Ft(29,xe,null,z.mode);return Le.lanes=P,Le.return=z,Le}finally{}}}var Qa=pm(!0),xm=pm(!1),ma=!1;function uc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fc(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 ha(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function pa(e,t,n){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(He&2)!==0){var c=s.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),s.pending=t,t=Hi(e),Wd(e,null,n),t}return Ui(e,s,t,n),Hi(e)}function Cs(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,be(e,n)}}function dc(e,t){var n=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var c=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var v={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,n=n.next}while(n!==null);u===null?c=u=t:u=u.next=t}else c=u=t;n={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:s.shared,callbacks:s.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mc=!1;function Es(){if(mc){var e=El;if(e!==null)throw e}}function ks(e,t,n,s){mc=!1;var c=e.updateQueue;ma=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,S=c.shared.pending;if(S!==null){c.shared.pending=null;var D=S,G=D.next;D.next=null,v===null?u=G:v.next=G,v=D;var J=e.alternate;J!==null&&(J=J.updateQueue,S=J.lastBaseUpdate,S!==v&&(S===null?J.firstBaseUpdate=G:S.next=G,J.lastBaseUpdate=D))}if(u!==null){var ee=c.baseState;v=0,J=G=D=null,S=u;do{var Q=S.lane&-536870913,I=Q!==S.lane;if(I?(qe&Q)===Q:(s&Q)===Q){Q!==0&&Q===Cl&&(mc=!0),J!==null&&(J=J.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var de=e,Se=S;Q=t;var Ke=n;switch(Se.tag){case 1:if(de=Se.payload,typeof de=="function"){ee=de.call(Ke,ee,Q);break e}ee=de;break e;case 3:de.flags=de.flags&-65537|128;case 0:if(de=Se.payload,Q=typeof de=="function"?de.call(Ke,ee,Q):de,Q==null)break e;ee=b({},ee,Q);break e;case 2:ma=!0}}Q=S.callback,Q!==null&&(e.flags|=64,I&&(e.flags|=8192),I=c.callbacks,I===null?c.callbacks=[Q]:I.push(Q))}else I={lane:Q,tag:S.tag,payload:S.payload,callback:S.callback,next:null},J===null?(G=J=I,D=ee):J=J.next=I,v|=Q;if(S=S.next,S===null){if(S=c.shared.pending,S===null)break;I=S,S=I.next,I.next=null,c.lastBaseUpdate=I,c.shared.pending=null}}while(!0);J===null&&(D=ee),c.baseState=D,c.firstBaseUpdate=G,c.lastBaseUpdate=J,u===null&&(c.shared.lanes=0),ba|=v,e.lanes=v,e.memoizedState=ee}}function gm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function vm(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)gm(n[e],t)}var ql=k(null),Ii=k(0);function ym(e,t){e=Jn,ne(Ii,e),ne(ql,t),Jn=e|t.baseLanes}function hc(){ne(Ii,Jn),ne(ql,ql.current)}function pc(){Jn=Ii.current,U(ql),U(Ii)}var Xt=k(null),fn=null;function xa(e){var t=e.alternate;ne(ct,ct.current&1),ne(Xt,e),fn===null&&(t===null||ql.current!==null||t.memoizedState!==null)&&(fn=e)}function xc(e){ne(ct,ct.current),ne(Xt,e),fn===null&&(fn=e)}function bm(e){e.tag===22?(ne(ct,ct.current),ne(Xt,e),fn===null&&(fn=e)):ga()}function ga(){ne(ct,ct.current),ne(Xt,Xt.current)}function Qt(e){U(Xt),fn===e&&(fn=null),U(ct)}var ct=k(0);function Ji(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Au(n)||ju(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Gn=0,Ne=null,Xe=null,ht=null,Pi=!1,Rl=!1,Ka=!1,Wi=0,Ms=0,Tl=null,Ov=0;function it(){throw Error(o(321))}function gc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Yt(e[n],t[n]))return!1;return!0}function vc(e,t,n,s,c,u){return Gn=u,Ne=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=e===null||e.memoizedState===null?ah:Dc,Ka=!1,u=n(s,c),Ka=!1,Rl&&(u=Am(t,n,s,c)),Sm(e),u}function Sm(e){R.H=Ts;var t=Xe!==null&&Xe.next!==null;if(Gn=0,ht=Xe=Ne=null,Pi=!1,Ms=0,Tl=null,t)throw Error(o(300));e===null||pt||(e=e.dependencies,e!==null&&Gi(e)&&(pt=!0))}function Am(e,t,n,s){Ne=e;var c=0;do{if(Rl&&(Tl=null),Ms=0,Rl=!1,25<=c)throw Error(o(301));if(c+=1,ht=Xe=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}R.H=lh,u=t(n,s)}while(Rl);return u}function Bv(){var e=R.H,t=e.useState()[0];return t=typeof t.then=="function"?qs(t):t,e=e.useState()[0],(Xe!==null?Xe.memoizedState:null)!==e&&(Ne.flags|=1024),t}function yc(){var e=Wi!==0;return Wi=0,e}function bc(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Sc(e){if(Pi){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Pi=!1}Gn=0,ht=Xe=Ne=null,Rl=!1,Ms=Wi=0,Tl=null}function Dt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ht===null?Ne.memoizedState=ht=e:ht=ht.next=e,ht}function ut(){if(Xe===null){var e=Ne.alternate;e=e!==null?e.memoizedState:null}else e=Xe.next;var t=ht===null?Ne.memoizedState:ht.next;if(t!==null)ht=t,Xe=e;else{if(e===null)throw Ne.alternate===null?Error(o(467)):Error(o(310));Xe=e,e={memoizedState:Xe.memoizedState,baseState:Xe.baseState,baseQueue:Xe.baseQueue,queue:Xe.queue,next:null},ht===null?Ne.memoizedState=ht=e:ht=ht.next=e}return ht}function er(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function qs(e){var t=Ms;return Ms+=1,Tl===null&&(Tl=[]),e=dm(Tl,e,t),t=Ne,(ht===null?t.memoizedState:ht.next)===null&&(t=t.alternate,R.H=t===null||t.memoizedState===null?ah:Dc),e}function tr(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return qs(e);if(e.$$typeof===M)return wt(e)}throw Error(o(438,String(e)))}function Ac(e){var t=null,n=Ne.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var s=Ne.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(t={data:s.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=er(),Ne.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),s=0;s<e;s++)n[s]=V;return t.index++,n}function Yn(e,t){return typeof t=="function"?t(e):t}function nr(e){var t=ut();return jc(t,Xe,e)}function jc(e,t,n){var s=e.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=n;var c=e.baseQueue,u=s.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,s.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var S=v=null,D=null,G=t,J=!1;do{var ee=G.lane&-536870913;if(ee!==G.lane?(qe&ee)===ee:(Gn&ee)===ee){var Q=G.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ee===Cl&&(J=!0);else if((Gn&Q)===Q){G=G.next,Q===Cl&&(J=!0);continue}else ee={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(S=D=ee,v=u):D=D.next=ee,Ne.lanes|=Q,ba|=Q;ee=G.action,Ka&&n(u,ee),u=G.hasEagerState?G.eagerState:n(u,ee)}else Q={lane:ee,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(S=D=Q,v=u):D=D.next=Q,Ne.lanes|=ee,ba|=ee;G=G.next}while(G!==null&&G!==t);if(D===null?v=u:D.next=S,!Yt(u,e.memoizedState)&&(pt=!0,J&&(n=El,n!==null)))throw n;e.memoizedState=u,e.baseState=v,e.baseQueue=D,s.lastRenderedState=u}return c===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function Nc(e){var t=ut(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var s=n.dispatch,c=n.pending,u=t.memoizedState;if(c!==null){n.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Yt(u,t.memoizedState)||(pt=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),n.lastRenderedState=u}return[u,s]}function jm(e,t,n){var s=Ne,c=ut(),u=Te;if(u){if(n===void 0)throw Error(o(407));n=n()}else n=t();var v=!Yt((Xe||c).memoizedState,n);if(v&&(c.memoizedState=n,pt=!0),c=c.queue,Ec(Cm.bind(null,s,c,e),[e]),c.getSnapshot!==t||v||ht!==null&&ht.memoizedState.tag&1){if(s.flags|=2048,Dl(9,{destroy:void 0},wm.bind(null,s,c,n,t),null),We===null)throw Error(o(349));u||(Gn&127)!==0||Nm(s,t,n)}return n}function Nm(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ne.updateQueue,t===null?(t=er(),Ne.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function wm(e,t,n,s){t.value=n,t.getSnapshot=s,Em(t)&&km(e)}function Cm(e,t,n){return n(function(){Em(t)&&km(e)})}function Em(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Yt(e,n)}catch{return!0}}function km(e){var t=Ua(e,2);t!==null&&$t(t,e,2)}function wc(e){var t=Dt();if(typeof e=="function"){var n=e;if(e=n(),Ka){en(!0);try{n()}finally{en(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yn,lastRenderedState:e},t}function Mm(e,t,n,s){return e.baseState=n,jc(e,Xe,typeof s=="function"?s:Yn)}function Lv(e,t,n,s,c){if(sr(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){u.listeners.push(v)}};R.T!==null?n(!0):u.isTransition=!1,s(u),n=t.pending,n===null?(u.next=t.pending=u,qm(t,u)):(u.next=n.next,t.pending=n.next=u)}}function qm(e,t){var n=t.action,s=t.payload,c=e.state;if(t.isTransition){var u=R.T,v={};R.T=v;try{var S=n(c,s),D=R.S;D!==null&&D(v,S),Rm(e,t,S)}catch(G){Cc(e,t,G)}finally{u!==null&&v.types!==null&&(u.types=v.types),R.T=u}}else try{u=n(c,s),Rm(e,t,u)}catch(G){Cc(e,t,G)}}function Rm(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(s){Tm(e,t,s)},function(s){return Cc(e,t,s)}):Tm(e,t,n)}function Tm(e,t,n){t.status="fulfilled",t.value=n,Dm(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,qm(e,n)))}function Cc(e,t,n){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=n,Dm(t),t=t.next;while(t!==s)}e.action=null}function Dm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function _m(e,t){return t}function Om(e,t){if(Te){var n=We.formState;if(n!==null){e:{var s=Ne;if(Te){if(tt){t:{for(var c=tt,u=un;c.nodeType!==8;){if(!u){c=null;break t}if(c=dn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){tt=dn(c.nextSibling),s=c.data==="F!";break e}}fa(s)}s=!1}s&&(t=n[0])}}return n=Dt(),n.memoizedState=n.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_m,lastRenderedState:t},n.queue=s,n=eh.bind(null,Ne,s),s.dispatch=n,s=wc(!1),u=Tc.bind(null,Ne,!1,s.queue),s=Dt(),c={state:t,dispatch:null,action:e,pending:null},s.queue=c,n=Lv.bind(null,Ne,c,u,n),c.dispatch=n,s.memoizedState=e,[t,n,!1]}function Bm(e){var t=ut();return Lm(t,Xe,e)}function Lm(e,t,n){if(t=jc(e,t,_m)[0],e=nr(Yn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=qs(t)}catch(v){throw v===kl?Xi:v}else s=t;t=ut();var c=t.queue,u=c.dispatch;return n!==t.memoizedState&&(Ne.flags|=2048,Dl(9,{destroy:void 0},zv.bind(null,c,n),null)),[s,u,e]}function zv(e,t){e.action=t}function zm(e){var t=ut(),n=Xe;if(n!==null)return Lm(t,n,e);ut(),t=t.memoizedState,n=ut();var s=n.queue.dispatch;return n.memoizedState=e,[t,s,!1]}function Dl(e,t,n,s){return e={tag:e,create:n,deps:s,inst:t,next:null},t=Ne.updateQueue,t===null&&(t=er(),Ne.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(s=n.next,n.next=e,e.next=s,t.lastEffect=e),e}function Um(){return ut().memoizedState}function ar(e,t,n,s){var c=Dt();Ne.flags|=e,c.memoizedState=Dl(1|t,{destroy:void 0},n,s===void 0?null:s)}function lr(e,t,n,s){var c=ut();s=s===void 0?null:s;var u=c.memoizedState.inst;Xe!==null&&s!==null&&gc(s,Xe.memoizedState.deps)?c.memoizedState=Dl(t,u,n,s):(Ne.flags|=e,c.memoizedState=Dl(1|t,u,n,s))}function Hm(e,t){ar(8390656,8,e,t)}function Ec(e,t){lr(2048,8,e,t)}function Uv(e){Ne.flags|=4;var t=Ne.updateQueue;if(t===null)t=er(),Ne.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Vm(e){var t=ut().memoizedState;return Uv({ref:t,nextImpl:e}),function(){if((He&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function $m(e,t){return lr(4,2,e,t)}function Gm(e,t){return lr(4,4,e,t)}function Ym(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Fm(e,t,n){n=n!=null?n.concat([e]):null,lr(4,4,Ym.bind(null,t,e),n)}function kc(){}function Xm(e,t){var n=ut();t=t===void 0?null:t;var s=n.memoizedState;return t!==null&&gc(t,s[1])?s[0]:(n.memoizedState=[e,t],e)}function Qm(e,t){var n=ut();t=t===void 0?null:t;var s=n.memoizedState;if(t!==null&&gc(t,s[1]))return s[0];if(s=e(),Ka){en(!0);try{e()}finally{en(!1)}}return n.memoizedState=[s,t],s}function Mc(e,t,n){return n===void 0||(Gn&1073741824)!==0&&(qe&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Kh(),Ne.lanes|=e,ba|=e,n)}function Km(e,t,n,s){return Yt(n,t)?n:ql.current!==null?(e=Mc(e,n,s),Yt(e,t)||(pt=!0),e):(Gn&42)===0||(Gn&1073741824)!==0&&(qe&261930)===0?(pt=!0,e.memoizedState=n):(e=Kh(),Ne.lanes|=e,ba|=e,t)}function Zm(e,t,n,s,c){var u=X.p;X.p=u!==0&&8>u?u:8;var v=R.T,S={};R.T=S,Tc(e,!1,t,n);try{var D=c(),G=R.S;if(G!==null&&G(S,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var J=_v(D,s);Rs(e,t,J,It(e))}else Rs(e,t,s,It(e))}catch(ee){Rs(e,t,{then:function(){},status:"rejected",reason:ee},It())}finally{X.p=u,v!==null&&S.types!==null&&(v.types=S.types),R.T=v}}function Hv(){}function qc(e,t,n,s){if(e.tag!==5)throw Error(o(476));var c=Im(e).queue;Zm(e,c,t,W,n===null?Hv:function(){return Jm(e),n(s)})}function Im(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yn,lastRenderedState:W},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yn,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Jm(e){var t=Im(e);t.next===null&&(t=e.alternate.memoizedState),Rs(e,t.next.queue,{},It())}function Rc(){return wt(Ks)}function Pm(){return ut().memoizedState}function Wm(){return ut().memoizedState}function Vv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=It();e=ha(n);var s=pa(t,e,n);s!==null&&($t(s,t,n),Cs(s,t,n)),t={cache:ic()},e.payload=t;return}t=t.return}}function $v(e,t,n){var s=It();n={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},sr(e)?th(t,n):(n=Zo(e,t,n,s),n!==null&&($t(n,e,s),nh(n,t,s)))}function eh(e,t,n){var s=It();Rs(e,t,n,s)}function Rs(e,t,n,s){var c={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(sr(e))th(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var v=t.lastRenderedState,S=u(v,n);if(c.hasEagerState=!0,c.eagerState=S,Yt(S,v))return Ui(e,t,c,0),We===null&&zi(),!1}catch{}finally{}if(n=Zo(e,t,c,s),n!==null)return $t(n,e,s),nh(n,t,s),!0}return!1}function Tc(e,t,n,s){if(s={lane:2,revertLane:uu(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},sr(e)){if(t)throw Error(o(479))}else t=Zo(e,n,s,2),t!==null&&$t(t,e,2)}function sr(e){var t=e.alternate;return e===Ne||t!==null&&t===Ne}function th(e,t){Rl=Pi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function nh(e,t,n){if((n&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,be(e,n)}}var Ts={readContext:wt,use:tr,useCallback:it,useContext:it,useEffect:it,useImperativeHandle:it,useLayoutEffect:it,useInsertionEffect:it,useMemo:it,useReducer:it,useRef:it,useState:it,useDebugValue:it,useDeferredValue:it,useTransition:it,useSyncExternalStore:it,useId:it,useHostTransitionStatus:it,useFormState:it,useActionState:it,useOptimistic:it,useMemoCache:it,useCacheRefresh:it};Ts.useEffectEvent=it;var ah={readContext:wt,use:tr,useCallback:function(e,t){return Dt().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:Hm,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,ar(4194308,4,Ym.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ar(4194308,4,e,t)},useInsertionEffect:function(e,t){ar(4,2,e,t)},useMemo:function(e,t){var n=Dt();t=t===void 0?null:t;var s=e();if(Ka){en(!0);try{e()}finally{en(!1)}}return n.memoizedState=[s,t],s},useReducer:function(e,t,n){var s=Dt();if(n!==void 0){var c=n(t);if(Ka){en(!0);try{n(t)}finally{en(!1)}}}else c=t;return s.memoizedState=s.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},s.queue=e,e=e.dispatch=$v.bind(null,Ne,e),[s.memoizedState,e]},useRef:function(e){var t=Dt();return e={current:e},t.memoizedState=e},useState:function(e){e=wc(e);var t=e.queue,n=eh.bind(null,Ne,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:kc,useDeferredValue:function(e,t){var n=Dt();return Mc(n,e,t)},useTransition:function(){var e=wc(!1);return e=Zm.bind(null,Ne,e.queue,!0,!1),Dt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var s=Ne,c=Dt();if(Te){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),We===null)throw Error(o(349));(qe&127)!==0||Nm(s,t,n)}c.memoizedState=n;var u={value:n,getSnapshot:t};return c.queue=u,Hm(Cm.bind(null,s,u,e),[e]),s.flags|=2048,Dl(9,{destroy:void 0},wm.bind(null,s,u,n,t),null),n},useId:function(){var e=Dt(),t=We.identifierPrefix;if(Te){var n=kn,s=En;n=(s&~(1<<32-dt(s)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Wi++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Ov++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Rc,useFormState:Om,useActionState:Om,useOptimistic:function(e){var t=Dt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Tc.bind(null,Ne,!0,n),n.dispatch=t,[e,t]},useMemoCache:Ac,useCacheRefresh:function(){return Dt().memoizedState=Vv.bind(null,Ne)},useEffectEvent:function(e){var t=Dt(),n={impl:e};return t.memoizedState=n,function(){if((He&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},Dc={readContext:wt,use:tr,useCallback:Xm,useContext:wt,useEffect:Ec,useImperativeHandle:Fm,useInsertionEffect:$m,useLayoutEffect:Gm,useMemo:Qm,useReducer:nr,useRef:Um,useState:function(){return nr(Yn)},useDebugValue:kc,useDeferredValue:function(e,t){var n=ut();return Km(n,Xe.memoizedState,e,t)},useTransition:function(){var e=nr(Yn)[0],t=ut().memoizedState;return[typeof e=="boolean"?e:qs(e),t]},useSyncExternalStore:jm,useId:Pm,useHostTransitionStatus:Rc,useFormState:Bm,useActionState:Bm,useOptimistic:function(e,t){var n=ut();return Mm(n,Xe,e,t)},useMemoCache:Ac,useCacheRefresh:Wm};Dc.useEffectEvent=Vm;var lh={readContext:wt,use:tr,useCallback:Xm,useContext:wt,useEffect:Ec,useImperativeHandle:Fm,useInsertionEffect:$m,useLayoutEffect:Gm,useMemo:Qm,useReducer:Nc,useRef:Um,useState:function(){return Nc(Yn)},useDebugValue:kc,useDeferredValue:function(e,t){var n=ut();return Xe===null?Mc(n,e,t):Km(n,Xe.memoizedState,e,t)},useTransition:function(){var e=Nc(Yn)[0],t=ut().memoizedState;return[typeof e=="boolean"?e:qs(e),t]},useSyncExternalStore:jm,useId:Pm,useHostTransitionStatus:Rc,useFormState:zm,useActionState:zm,useOptimistic:function(e,t){var n=ut();return Xe!==null?Mm(n,Xe,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Ac,useCacheRefresh:Wm};lh.useEffectEvent=Vm;function _c(e,t,n,s){t=e.memoizedState,n=n(s,t),n=n==null?t:b({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Oc={enqueueSetState:function(e,t,n){e=e._reactInternals;var s=It(),c=ha(s);c.payload=t,n!=null&&(c.callback=n),t=pa(e,c,s),t!==null&&($t(t,e,s),Cs(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var s=It(),c=ha(s);c.tag=1,c.payload=t,n!=null&&(c.callback=n),t=pa(e,c,s),t!==null&&($t(t,e,s),Cs(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=It(),s=ha(n);s.tag=2,t!=null&&(s.callback=t),t=pa(e,s,n),t!==null&&($t(t,e,n),Cs(t,e,n))}};function sh(e,t,n,s,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,u,v):t.prototype&&t.prototype.isPureReactComponent?!vs(n,s)||!vs(c,u):!0}function ih(e,t,n,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,s),t.state!==e&&Oc.enqueueReplaceState(t,t.state,null)}function Za(e,t){var n=t;if("ref"in t){n={};for(var s in t)s!=="ref"&&(n[s]=t[s])}if(e=e.defaultProps){n===t&&(n=b({},n));for(var c in e)n[c]===void 0&&(n[c]=e[c])}return n}function rh(e){Li(e)}function oh(e){console.error(e)}function ch(e){Li(e)}function ir(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function uh(e,t,n){try{var s=e.onCaughtError;s(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Bc(e,t,n){return n=ha(n),n.tag=3,n.payload={element:null},n.callback=function(){ir(e,t)},n}function fh(e){return e=ha(e),e.tag=3,e}function dh(e,t,n,s){var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var u=s.value;e.payload=function(){return c(u)},e.callback=function(){uh(t,n,s)}}var v=n.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){uh(t,n,s),typeof c!="function"&&(Sa===null?Sa=new Set([this]):Sa.add(this));var S=s.stack;this.componentDidCatch(s.value,{componentStack:S!==null?S:""})})}function Gv(e,t,n,s,c){if(n.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=n.alternate,t!==null&&wl(t,n,c,!0),n=Xt.current,n!==null){switch(n.tag){case 31:case 13:return fn===null?vr():n.alternate===null&&rt===0&&(rt=3),n.flags&=-257,n.flags|=65536,n.lanes=c,s===Qi?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([s]):t.add(s),ru(e,s,c)),!1;case 22:return n.flags|=65536,s===Qi?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([s]):n.add(s)),ru(e,s,c)),!1}throw Error(o(435,n.tag))}return ru(e,s,c),vr(),!1}if(Te)return t=Xt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,s!==tc&&(e=Error(o(422),{cause:s}),Ss(rn(e,n)))):(s!==tc&&(t=Error(o(423),{cause:s}),Ss(rn(t,n))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,s=rn(s,n),c=Bc(e.stateNode,s,c),dc(e,c),rt!==4&&(rt=2)),!1;var u=Error(o(520),{cause:s});if(u=rn(u,n),Hs===null?Hs=[u]:Hs.push(u),rt!==4&&(rt=2),t===null)return!0;s=rn(s,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=c&-c,n.lanes|=e,e=Bc(n.stateNode,s,e),dc(n,e),!1;case 1:if(t=n.type,u=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(Sa===null||!Sa.has(u))))return n.flags|=65536,c&=-c,n.lanes|=c,c=fh(c),dh(c,e,n,s),dc(n,c),!1}n=n.return}while(n!==null);return!1}var Lc=Error(o(461)),pt=!1;function Ct(e,t,n,s){t.child=e===null?xm(t,null,n,s):Qa(t,e.child,n,s)}function mh(e,t,n,s,c){n=n.render;var u=t.ref;if("ref"in s){var v={};for(var S in s)S!=="ref"&&(v[S]=s[S])}else v=s;return Ga(t),s=vc(e,t,n,v,u,c),S=yc(),e!==null&&!pt?(bc(e,t,c),Fn(e,t,c)):(Te&&S&&Wo(t),t.flags|=1,Ct(e,t,s,c),t.child)}function hh(e,t,n,s,c){if(e===null){var u=n.type;return typeof u=="function"&&!Io(u)&&u.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=u,ph(e,t,u,s,c)):(e=Vi(n.type,null,s,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!Fc(e,c)){var v=u.memoizedProps;if(n=n.compare,n=n!==null?n:vs,n(v,s)&&e.ref===t.ref)return Fn(e,t,c)}return t.flags|=1,e=Un(u,s),e.ref=t.ref,e.return=t,t.child=e}function ph(e,t,n,s,c){if(e!==null){var u=e.memoizedProps;if(vs(u,s)&&e.ref===t.ref)if(pt=!1,t.pendingProps=s=u,Fc(e,c))(e.flags&131072)!==0&&(pt=!0);else return t.lanes=e.lanes,Fn(e,t,c)}return zc(e,t,n,s,c)}function xh(e,t,n,s){var c=s.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|n:n,e!==null){for(s=t.child=e.child,c=0;s!==null;)c=c|s.lanes|s.childLanes,s=s.sibling;s=c&~u}else s=0,t.child=null;return gh(e,t,u,n,s)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Fi(t,u!==null?u.cachePool:null),u!==null?ym(t,u):hc(),bm(t);else return s=t.lanes=536870912,gh(e,t,u!==null?u.baseLanes|n:n,n,s)}else u!==null?(Fi(t,u.cachePool),ym(t,u),ga(),t.memoizedState=null):(e!==null&&Fi(t,null),hc(),ga());return Ct(e,t,c,n),t.child}function Ds(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function gh(e,t,n,s,c){var u=oc();return u=u===null?null:{parent:mt._currentValue,pool:u},t.memoizedState={baseLanes:n,cachePool:u},e!==null&&Fi(t,null),hc(),bm(t),e!==null&&wl(e,t,s,!0),t.childLanes=c,null}function rr(e,t){return t=cr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function vh(e,t,n){return Qa(t,e.child,null,n),e=rr(t,t.pendingProps),e.flags|=2,Qt(t),t.memoizedState=null,e}function Yv(e,t,n){var s=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Te){if(s.mode==="hidden")return e=rr(t,s),t.lanes=536870912,Ds(null,e);if(xc(t),(e=tt)?(e=qp(e,un),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ca!==null?{id:En,overflow:kn}:null,retryLane:536870912,hydrationErrors:null},n=tm(e),n.return=t,t.child=n,Nt=t,tt=null)):e=null,e===null)throw fa(t);return t.lanes=536870912,null}return rr(t,s)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(xc(t),c)if(t.flags&256)t.flags&=-257,t=vh(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(pt||wl(e,t,n,!1),c=(n&e.childLanes)!==0,pt||c){if(s=We,s!==null&&(v=Je(s,n),v!==0&&v!==u.retryLane))throw u.retryLane=v,Ua(e,v),$t(s,e,v),Lc;vr(),t=vh(e,t,n)}else e=u.treeContext,tt=dn(v.nextSibling),Nt=t,Te=!0,ua=null,un=!1,e!==null&&lm(t,e),t=rr(t,s),t.flags|=4096;return t}return e=Un(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function or(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function zc(e,t,n,s,c){return Ga(t),n=vc(e,t,n,s,void 0,c),s=yc(),e!==null&&!pt?(bc(e,t,c),Fn(e,t,c)):(Te&&s&&Wo(t),t.flags|=1,Ct(e,t,n,c),t.child)}function yh(e,t,n,s,c,u){return Ga(t),t.updateQueue=null,n=Am(t,s,n,c),Sm(e),s=yc(),e!==null&&!pt?(bc(e,t,u),Fn(e,t,u)):(Te&&s&&Wo(t),t.flags|=1,Ct(e,t,n,u),t.child)}function bh(e,t,n,s,c){if(Ga(t),t.stateNode===null){var u=Sl,v=n.contextType;typeof v=="object"&&v!==null&&(u=wt(v)),u=new n(s,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Oc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=s,u.state=t.memoizedState,u.refs={},uc(t),v=n.contextType,u.context=typeof v=="object"&&v!==null?wt(v):Sl,u.state=t.memoizedState,v=n.getDerivedStateFromProps,typeof v=="function"&&(_c(t,n,v,s),u.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(v=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),v!==u.state&&Oc.enqueueReplaceState(u,u.state,null),ks(t,s,u,c),Es(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!0}else if(e===null){u=t.stateNode;var S=t.memoizedProps,D=Za(n,S);u.props=D;var G=u.context,J=n.contextType;v=Sl,typeof J=="object"&&J!==null&&(v=wt(J));var ee=n.getDerivedStateFromProps;J=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",S=t.pendingProps!==S,J||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(S||G!==v)&&ih(t,u,s,v),ma=!1;var Q=t.memoizedState;u.state=Q,ks(t,s,u,c),Es(),G=t.memoizedState,S||Q!==G||ma?(typeof ee=="function"&&(_c(t,n,ee,s),G=t.memoizedState),(D=ma||sh(t,n,D,s,Q,G,v))?(J||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=G),u.props=s,u.state=G,u.context=v,s=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{u=t.stateNode,fc(e,t),v=t.memoizedProps,J=Za(n,v),u.props=J,ee=t.pendingProps,Q=u.context,G=n.contextType,D=Sl,typeof G=="object"&&G!==null&&(D=wt(G)),S=n.getDerivedStateFromProps,(G=typeof S=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||Q!==D)&&ih(t,u,s,D),ma=!1,Q=t.memoizedState,u.state=Q,ks(t,s,u,c),Es();var I=t.memoizedState;v!==ee||Q!==I||ma||e!==null&&e.dependencies!==null&&Gi(e.dependencies)?(typeof S=="function"&&(_c(t,n,S,s),I=t.memoizedState),(J=ma||sh(t,n,J,s,Q,I,D)||e!==null&&e.dependencies!==null&&Gi(e.dependencies))?(G||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(s,I,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(s,I,D)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=I),u.props=s,u.state=I,u.context=D,s=J):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),s=!1)}return u=s,or(e,t),s=(t.flags&128)!==0,u||s?(u=t.stateNode,n=s&&typeof n.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&s?(t.child=Qa(t,e.child,null,c),t.child=Qa(t,null,n,c)):Ct(e,t,n,c),t.memoizedState=u.state,e=t.child):e=Fn(e,t,c),e}function Sh(e,t,n,s){return Va(),t.flags|=256,Ct(e,t,n,s),t.child}var Uc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hc(e){return{baseLanes:e,cachePool:um()}}function Vc(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Zt),e}function Ah(e,t,n){var s=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(ct.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Te){if(c?xa(t):ga(),(e=tt)?(e=qp(e,un),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ca!==null?{id:En,overflow:kn}:null,retryLane:536870912,hydrationErrors:null},n=tm(e),n.return=t,t.child=n,Nt=t,tt=null)):e=null,e===null)throw fa(t);return ju(e)?t.lanes=32:t.lanes=536870912,null}var S=s.children;return s=s.fallback,c?(ga(),c=t.mode,S=cr({mode:"hidden",children:S},c),s=Ha(s,c,n,null),S.return=t,s.return=t,S.sibling=s,t.child=S,s=t.child,s.memoizedState=Hc(n),s.childLanes=Vc(e,v,n),t.memoizedState=Uc,Ds(null,s)):(xa(t),$c(t,S))}var D=e.memoizedState;if(D!==null&&(S=D.dehydrated,S!==null)){if(u)t.flags&256?(xa(t),t.flags&=-257,t=Gc(e,t,n)):t.memoizedState!==null?(ga(),t.child=e.child,t.flags|=128,t=null):(ga(),S=s.fallback,c=t.mode,s=cr({mode:"visible",children:s.children},c),S=Ha(S,c,n,null),S.flags|=2,s.return=t,S.return=t,s.sibling=S,t.child=s,Qa(t,e.child,null,n),s=t.child,s.memoizedState=Hc(n),s.childLanes=Vc(e,v,n),t.memoizedState=Uc,t=Ds(null,s));else if(xa(t),ju(S)){if(v=S.nextSibling&&S.nextSibling.dataset,v)var G=v.dgst;v=G,s=Error(o(419)),s.stack="",s.digest=v,Ss({value:s,source:null,stack:null}),t=Gc(e,t,n)}else if(pt||wl(e,t,n,!1),v=(n&e.childLanes)!==0,pt||v){if(v=We,v!==null&&(s=Je(v,n),s!==0&&s!==D.retryLane))throw D.retryLane=s,Ua(e,s),$t(v,e,s),Lc;Au(S)||vr(),t=Gc(e,t,n)}else Au(S)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,tt=dn(S.nextSibling),Nt=t,Te=!0,ua=null,un=!1,e!==null&&lm(t,e),t=$c(t,s.children),t.flags|=4096);return t}return c?(ga(),S=s.fallback,c=t.mode,D=e.child,G=D.sibling,s=Un(D,{mode:"hidden",children:s.children}),s.subtreeFlags=D.subtreeFlags&65011712,G!==null?S=Un(G,S):(S=Ha(S,c,n,null),S.flags|=2),S.return=t,s.return=t,s.sibling=S,t.child=s,Ds(null,s),s=t.child,S=e.child.memoizedState,S===null?S=Hc(n):(c=S.cachePool,c!==null?(D=mt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=um(),S={baseLanes:S.baseLanes|n,cachePool:c}),s.memoizedState=S,s.childLanes=Vc(e,v,n),t.memoizedState=Uc,Ds(e.child,s)):(xa(t),n=e.child,e=n.sibling,n=Un(n,{mode:"visible",children:s.children}),n.return=t,n.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=n,t.memoizedState=null,n)}function $c(e,t){return t=cr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function cr(e,t){return e=Ft(22,e,null,t),e.lanes=0,e}function Gc(e,t,n){return Qa(t,e.child,null,n),e=$c(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function jh(e,t,n){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),lc(e.return,t,n)}function Yc(e,t,n,s,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:n,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=s,v.tail=n,v.tailMode=c,v.treeForkCount=u)}function Nh(e,t,n){var s=t.pendingProps,c=s.revealOrder,u=s.tail;s=s.children;var v=ct.current,S=(v&2)!==0;if(S?(v=v&1|2,t.flags|=128):v&=1,ne(ct,v),Ct(e,t,s,n),s=Te?bs:0,!S&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&jh(e,n,t);else if(e.tag===19)jh(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(n=t.child,c=null;n!==null;)e=n.alternate,e!==null&&Ji(e)===null&&(c=n),n=n.sibling;n=c,n===null?(c=t.child,t.child=null):(c=n.sibling,n.sibling=null),Yc(t,!1,c,n,u,s);break;case"backwards":case"unstable_legacy-backwards":for(n=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Ji(e)===null){t.child=c;break}e=c.sibling,c.sibling=n,n=c,c=e}Yc(t,!0,n,null,u,s);break;case"together":Yc(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function Fn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ba|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(wl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Un(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Un(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Fc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Gi(e)))}function Fv(e,t,n){switch(t.tag){case 3:he(t,t.stateNode.containerInfo),da(t,mt,e.memoizedState.cache),Va();break;case 27:case 5:ge(t);break;case 4:he(t,t.stateNode.containerInfo);break;case 10:da(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,xc(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(xa(t),t.flags|=128,null):(n&t.child.childLanes)!==0?Ah(e,t,n):(xa(t),e=Fn(e,t,n),e!==null?e.sibling:null);xa(t);break;case 19:var c=(e.flags&128)!==0;if(s=(n&t.childLanes)!==0,s||(wl(e,t,n,!1),s=(n&t.childLanes)!==0),c){if(s)return Nh(e,t,n);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),ne(ct,ct.current),s)break;return null;case 22:return t.lanes=0,xh(e,t,n,t.pendingProps);case 24:da(t,mt,e.memoizedState.cache)}return Fn(e,t,n)}function wh(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)pt=!0;else{if(!Fc(e,n)&&(t.flags&128)===0)return pt=!1,Fv(e,t,n);pt=(e.flags&131072)!==0}else pt=!1,Te&&(t.flags&1048576)!==0&&am(t,bs,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=Fa(t.elementType),t.type=e,typeof e=="function")Io(e)?(s=Za(e,s),t.tag=1,t=bh(null,t,e,s,n)):(t.tag=0,t=zc(null,t,e,s,n));else{if(e!=null){var c=e.$$typeof;if(c===T){t.tag=11,t=mh(null,t,e,s,n);break e}else if(c===O){t.tag=14,t=hh(null,t,e,s,n);break e}}throw t=re(e)||e,Error(o(306,t,""))}}return t;case 0:return zc(e,t,t.type,t.pendingProps,n);case 1:return s=t.type,c=Za(s,t.pendingProps),bh(e,t,s,c,n);case 3:e:{if(he(t,t.stateNode.containerInfo),e===null)throw Error(o(387));s=t.pendingProps;var u=t.memoizedState;c=u.element,fc(e,t),ks(t,s,null,n);var v=t.memoizedState;if(s=v.cache,da(t,mt,s),s!==u.cache&&sc(t,[mt],n,!0),Es(),s=v.element,u.isDehydrated)if(u={element:s,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=Sh(e,t,s,n);break e}else if(s!==c){c=rn(Error(o(424)),t),Ss(c),t=Sh(e,t,s,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(tt=dn(e.firstChild),Nt=t,Te=!0,ua=null,un=!0,n=xm(t,null,s,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Va(),s===c){t=Fn(e,t,n);break e}Ct(e,t,s,n)}t=t.child}return t;case 26:return or(e,t),e===null?(n=Bp(t.type,null,t.pendingProps,null))?t.memoizedState=n:Te||(n=t.type,e=t.pendingProps,s=wr(ie.current).createElement(n),s[st]=t,s[Be]=e,Et(s,n,e),St(s),t.stateNode=s):t.memoizedState=Bp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ge(t),e===null&&Te&&(s=t.stateNode=Dp(t.type,t.pendingProps,ie.current),Nt=t,un=!0,c=tt,wa(t.type)?(Nu=c,tt=dn(s.firstChild)):tt=c),Ct(e,t,t.pendingProps.children,n),or(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Te&&((c=s=tt)&&(s=Sy(s,t.type,t.pendingProps,un),s!==null?(t.stateNode=s,Nt=t,tt=dn(s.firstChild),un=!1,c=!0):c=!1),c||fa(t)),ge(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,s=u.children,yu(c,u)?s=null:v!==null&&yu(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=vc(e,t,Bv,null,null,n),Ks._currentValue=c),or(e,t),Ct(e,t,s,n),t.child;case 6:return e===null&&Te&&((e=n=tt)&&(n=Ay(n,t.pendingProps,un),n!==null?(t.stateNode=n,Nt=t,tt=null,e=!0):e=!1),e||fa(t)),null;case 13:return Ah(e,t,n);case 4:return he(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Qa(t,null,s,n):Ct(e,t,s,n),t.child;case 11:return mh(e,t,t.type,t.pendingProps,n);case 7:return Ct(e,t,t.pendingProps,n),t.child;case 8:return Ct(e,t,t.pendingProps.children,n),t.child;case 12:return Ct(e,t,t.pendingProps.children,n),t.child;case 10:return s=t.pendingProps,da(t,t.type,s.value),Ct(e,t,s.children,n),t.child;case 9:return c=t.type._context,s=t.pendingProps.children,Ga(t),c=wt(c),s=s(c),t.flags|=1,Ct(e,t,s,n),t.child;case 14:return hh(e,t,t.type,t.pendingProps,n);case 15:return ph(e,t,t.type,t.pendingProps,n);case 19:return Nh(e,t,n);case 31:return Yv(e,t,n);case 22:return xh(e,t,n,t.pendingProps);case 24:return Ga(t),s=wt(mt),e===null?(c=oc(),c===null&&(c=We,u=ic(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=n),c=u),t.memoizedState={parent:s,cache:c},uc(t),da(t,mt,c)):((e.lanes&n)!==0&&(fc(e,t),ks(t,null,null,n),Es()),c=e.memoizedState,u=t.memoizedState,c.parent!==s?(c={parent:s,cache:s},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),da(t,mt,s)):(s=u.cache,da(t,mt,s),s!==c.cache&&sc(t,[mt],n,!0))),Ct(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Xn(e){e.flags|=4}function Xc(e,t,n,s,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(Ph())e.flags|=8192;else throw Xa=Qi,cc}else e.flags&=-16777217}function Ch(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Vp(t))if(Ph())e.flags|=8192;else throw Xa=Qi,cc}function ur(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?wi():536870912,e.lanes|=t,Ll|=t)}function _s(e,t){if(!Te)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,s=0;if(t)for(var c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags&65011712,s|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=n,t}function Xv(e,t,n){var s=t.pendingProps;switch(ec(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(t),null;case 1:return nt(t),null;case 3:return n=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),$n(mt),pe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Nl(t)?Xn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,nc())),nt(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Xn(t),u!==null?(nt(t),Ch(t,u)):(nt(t),Xc(t,c,null,s,n))):u?u!==e.memoizedState?(Xn(t),nt(t),Ch(t,u)):(nt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&Xn(t),nt(t),Xc(t,c,e,s,n)),null;case 27:if(Oe(t),n=ie.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Xn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return nt(t),null}e=ae.current,Nl(t)?sm(t):(e=Dp(c,s,n),t.stateNode=e,Xn(t))}return nt(t),null;case 5:if(Oe(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Xn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return nt(t),null}if(u=ae.current,Nl(t))sm(t);else{var v=wr(ie.current);switch(u){case 1:u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=v.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof s.is=="string"?v.createElement("select",{is:s.is}):v.createElement("select"),s.multiple?u.multiple=!0:s.size&&(u.size=s.size);break;default:u=typeof s.is=="string"?v.createElement(c,{is:s.is}):v.createElement(c)}}u[st]=t,u[Be]=s;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=u;e:switch(Et(u,c,s),c){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&Xn(t)}}return nt(t),Xc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&Xn(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(o(166));if(e=ie.current,Nl(t)){if(e=t.stateNode,n=t.memoizedProps,s=null,c=Nt,c!==null)switch(c.tag){case 27:case 5:s=c.memoizedProps}e[st]=t,e=!!(e.nodeValue===n||s!==null&&s.suppressHydrationWarning===!0||Ap(e.nodeValue,n)),e||fa(t,!0)}else e=wr(e).createTextNode(s),e[st]=t,t.stateNode=e}return nt(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(s=Nl(t),n!==null){if(e===null){if(!s)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[st]=t}else Va(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;nt(t),e=!1}else n=nc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Qt(t),t):(Qt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return nt(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Nl(t),s!==null&&s.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[st]=t}else Va(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;nt(t),c=!1}else c=nc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Qt(t),t):(Qt(t),null)}return Qt(t),(t.flags&128)!==0?(t.lanes=n,t):(n=s!==null,e=e!==null&&e.memoizedState!==null,n&&(s=t.child,c=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(c=s.alternate.memoizedState.cachePool.pool),u=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),u!==c&&(s.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ur(t,t.updateQueue),nt(t),null);case 4:return pe(),e===null&&hu(t.stateNode.containerInfo),nt(t),null;case 10:return $n(t.type),nt(t),null;case 19:if(U(ct),s=t.memoizedState,s===null)return nt(t),null;if(c=(t.flags&128)!==0,u=s.rendering,u===null)if(c)_s(s,!1);else{if(rt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Ji(e),u!==null){for(t.flags|=128,_s(s,!1),e=u.updateQueue,t.updateQueue=e,ur(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)em(n,e),n=n.sibling;return ne(ct,ct.current&1|2),Te&&Hn(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&Ue()>pr&&(t.flags|=128,c=!0,_s(s,!1),t.lanes=4194304)}else{if(!c)if(e=Ji(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,ur(t,e),_s(s,!0),s.tail===null&&s.tailMode==="hidden"&&!u.alternate&&!Te)return nt(t),null}else 2*Ue()-s.renderingStartTime>pr&&n!==536870912&&(t.flags|=128,c=!0,_s(s,!1),t.lanes=4194304);s.isBackwards?(u.sibling=t.child,t.child=u):(e=s.last,e!==null?e.sibling=u:t.child=u,s.last=u)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Ue(),e.sibling=null,n=ct.current,ne(ct,c?n&1|2:n&1),Te&&Hn(t,s.treeForkCount),e):(nt(t),null);case 22:case 23:return Qt(t),pc(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(n&536870912)!==0&&(t.flags&128)===0&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),n=t.updateQueue,n!==null&&ur(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==n&&(t.flags|=2048),e!==null&&U(Ya),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$n(mt),nt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Qv(e,t){switch(ec(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $n(mt),pe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Oe(t),null;case 31:if(t.memoizedState!==null){if(Qt(t),t.alternate===null)throw Error(o(340));Va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Qt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return U(ct),null;case 4:return pe(),null;case 10:return $n(t.type),null;case 22:case 23:return Qt(t),pc(),e!==null&&U(Ya),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return $n(mt),null;case 25:return null;default:return null}}function Eh(e,t){switch(ec(t),t.tag){case 3:$n(mt),pe();break;case 26:case 27:case 5:Oe(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&Qt(t);break;case 13:Qt(t);break;case 19:U(ct);break;case 10:$n(t.type);break;case 22:case 23:Qt(t),pc(),e!==null&&U(Ya);break;case 24:$n(mt)}}function Os(e,t){try{var n=t.updateQueue,s=n!==null?n.lastEffect:null;if(s!==null){var c=s.next;n=c;do{if((n.tag&e)===e){s=void 0;var u=n.create,v=n.inst;s=u(),v.destroy=s}n=n.next}while(n!==c)}}catch(S){Fe(t,t.return,S)}}function va(e,t,n){try{var s=t.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var u=c.next;s=u;do{if((s.tag&e)===e){var v=s.inst,S=v.destroy;if(S!==void 0){v.destroy=void 0,c=t;var D=n,G=S;try{G()}catch(J){Fe(c,D,J)}}}s=s.next}while(s!==u)}}catch(J){Fe(t,t.return,J)}}function kh(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{vm(t,n)}catch(s){Fe(e,e.return,s)}}}function Mh(e,t,n){n.props=Za(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(s){Fe(e,t,s)}}function Bs(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof n=="function"?e.refCleanup=n(s):n.current=s}}catch(c){Fe(e,t,c)}}function Mn(e,t){var n=e.ref,s=e.refCleanup;if(n!==null)if(typeof s=="function")try{s()}catch(c){Fe(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(c){Fe(e,t,c)}else n.current=null}function qh(e){var t=e.type,n=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&s.focus();break e;case"img":n.src?s.src=n.src:n.srcSet&&(s.srcset=n.srcSet)}}catch(c){Fe(e,e.return,c)}}function Qc(e,t,n){try{var s=e.stateNode;py(s,e.type,n,t),s[Be]=t}catch(c){Fe(e,e.return,c)}}function Rh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wa(e.type)||e.tag===4}function Kc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Rh(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&&wa(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 Zc(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ln));else if(s!==4&&(s===27&&wa(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function fr(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(s!==4&&(s===27&&wa(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(fr(e,t,n),e=e.sibling;e!==null;)fr(e,t,n),e=e.sibling}function Th(e){var t=e.stateNode,n=e.memoizedProps;try{for(var s=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Et(t,s,n),t[st]=e,t[Be]=n}catch(u){Fe(e,e.return,u)}}var Qn=!1,xt=!1,Ic=!1,Dh=typeof WeakSet=="function"?WeakSet:Set,At=null;function Kv(e,t){if(e=e.containerInfo,gu=Tr,e=Fd(e),Go(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var c=s.anchorOffset,u=s.focusNode;s=s.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var v=0,S=-1,D=-1,G=0,J=0,ee=e,Q=null;t:for(;;){for(var I;ee!==n||c!==0&&ee.nodeType!==3||(S=v+c),ee!==u||s!==0&&ee.nodeType!==3||(D=v+s),ee.nodeType===3&&(v+=ee.nodeValue.length),(I=ee.firstChild)!==null;)Q=ee,ee=I;for(;;){if(ee===e)break t;if(Q===n&&++G===c&&(S=v),Q===u&&++J===s&&(D=v),(I=ee.nextSibling)!==null)break;ee=Q,Q=ee.parentNode}ee=I}n=S===-1||D===-1?null:{start:S,end:D}}else n=null}n=n||{start:0,end:0}}else n=null;for(vu={focusedElem:e,selectionRange:n},Tr=!1,At=t;At!==null;)if(t=At,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,At=e;else for(;At!==null;){switch(t=At,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)c=e[n],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,n=t,c=u.memoizedProps,u=u.memoizedState,s=n.stateNode;try{var de=Za(n.type,c);e=s.getSnapshotBeforeUpdate(de,u),s.__reactInternalSnapshotBeforeUpdate=e}catch(Se){Fe(n,n.return,Se)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)Su(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Su(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,At=e;break}At=t.return}}function _h(e,t,n){var s=n.flags;switch(n.tag){case 0:case 11:case 15:Zn(e,n),s&4&&Os(5,n);break;case 1:if(Zn(e,n),s&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(v){Fe(n,n.return,v)}else{var c=Za(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Fe(n,n.return,v)}}s&64&&kh(n),s&512&&Bs(n,n.return);break;case 3:if(Zn(e,n),s&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{vm(e,t)}catch(v){Fe(n,n.return,v)}}break;case 27:t===null&&s&4&&Th(n);case 26:case 5:Zn(e,n),t===null&&s&4&&qh(n),s&512&&Bs(n,n.return);break;case 12:Zn(e,n);break;case 31:Zn(e,n),s&4&&Lh(e,n);break;case 13:Zn(e,n),s&4&&zh(e,n),s&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=ay.bind(null,n),jy(e,n))));break;case 22:if(s=n.memoizedState!==null||Qn,!s){t=t!==null&&t.memoizedState!==null||xt,c=Qn;var u=xt;Qn=s,(xt=t)&&!u?In(e,n,(n.subtreeFlags&8772)!==0):Zn(e,n),Qn=c,xt=u}break;case 30:break;default:Zn(e,n)}}function Oh(e){var t=e.alternate;t!==null&&(e.alternate=null,Oh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Co(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 at=null,zt=!1;function Kn(e,t,n){for(n=n.child;n!==null;)Bh(e,t,n),n=n.sibling}function Bh(e,t,n){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(vn,n)}catch{}switch(n.tag){case 26:xt||Mn(n,t),Kn(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:xt||Mn(n,t);var s=at,c=zt;wa(n.type)&&(at=n.stateNode,zt=!1),Kn(e,t,n),Fs(n.stateNode),at=s,zt=c;break;case 5:xt||Mn(n,t);case 6:if(s=at,c=zt,at=null,Kn(e,t,n),at=s,zt=c,at!==null)if(zt)try{(at.nodeType===9?at.body:at.nodeName==="HTML"?at.ownerDocument.body:at).removeChild(n.stateNode)}catch(u){Fe(n,t,u)}else try{at.removeChild(n.stateNode)}catch(u){Fe(n,t,u)}break;case 18:at!==null&&(zt?(e=at,kp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Fl(e)):kp(at,n.stateNode));break;case 4:s=at,c=zt,at=n.stateNode.containerInfo,zt=!0,Kn(e,t,n),at=s,zt=c;break;case 0:case 11:case 14:case 15:va(2,n,t),xt||va(4,n,t),Kn(e,t,n);break;case 1:xt||(Mn(n,t),s=n.stateNode,typeof s.componentWillUnmount=="function"&&Mh(n,t,s)),Kn(e,t,n);break;case 21:Kn(e,t,n);break;case 22:xt=(s=xt)||n.memoizedState!==null,Kn(e,t,n),xt=s;break;default:Kn(e,t,n)}}function Lh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Fl(e)}catch(n){Fe(t,t.return,n)}}}function zh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Fl(e)}catch(n){Fe(t,t.return,n)}}function Zv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Dh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Dh),t;default:throw Error(o(435,e.tag))}}function dr(e,t){var n=Zv(e);t.forEach(function(s){if(!n.has(s)){n.add(s);var c=ly.bind(null,e,s);s.then(c,c)}})}function Ut(e,t){var n=t.deletions;if(n!==null)for(var s=0;s<n.length;s++){var c=n[s],u=e,v=t,S=v;e:for(;S!==null;){switch(S.tag){case 27:if(wa(S.type)){at=S.stateNode,zt=!1;break e}break;case 5:at=S.stateNode,zt=!1;break e;case 3:case 4:at=S.stateNode.containerInfo,zt=!0;break e}S=S.return}if(at===null)throw Error(o(160));Bh(u,v,c),at=null,zt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Uh(t,e),t=t.sibling}var bn=null;function Uh(e,t){var n=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),s&4&&(va(3,e,e.return),Os(3,e),va(5,e,e.return));break;case 1:Ut(t,e),Ht(e),s&512&&(xt||n===null||Mn(n,n.return)),s&64&&Qn&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?s:n.concat(s))));break;case 26:var c=bn;if(Ut(t,e),Ht(e),s&512&&(xt||n===null||Mn(n,n.return)),s&4){var u=n!==null?n.memoizedState:null;if(s=e.memoizedState,n===null)if(s===null)if(e.stateNode===null){e:{s=e.type,n=e.memoizedProps,c=c.ownerDocument||c;t:switch(s){case"title":u=c.getElementsByTagName("title")[0],(!u||u[cs]||u[st]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(s),c.head.insertBefore(u,c.querySelector("head > title"))),Et(u,s,n),u[st]=e,St(u),s=u;break e;case"link":var v=Up("link","href",c).get(s+(n.href||""));if(v){for(var S=0;S<v.length;S++)if(u=v[S],u.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&u.getAttribute("rel")===(n.rel==null?null:n.rel)&&u.getAttribute("title")===(n.title==null?null:n.title)&&u.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){v.splice(S,1);break t}}u=c.createElement(s),Et(u,s,n),c.head.appendChild(u);break;case"meta":if(v=Up("meta","content",c).get(s+(n.content||""))){for(S=0;S<v.length;S++)if(u=v[S],u.getAttribute("content")===(n.content==null?null:""+n.content)&&u.getAttribute("name")===(n.name==null?null:n.name)&&u.getAttribute("property")===(n.property==null?null:n.property)&&u.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&u.getAttribute("charset")===(n.charSet==null?null:n.charSet)){v.splice(S,1);break t}}u=c.createElement(s),Et(u,s,n),c.head.appendChild(u);break;default:throw Error(o(468,s))}u[st]=e,St(u),s=u}e.stateNode=s}else Hp(c,e.type,e.stateNode);else e.stateNode=zp(c,s,e.memoizedProps);else u!==s?(u===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):u.count--,s===null?Hp(c,e.type,e.stateNode):zp(c,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Qc(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ut(t,e),Ht(e),s&512&&(xt||n===null||Mn(n,n.return)),n!==null&&s&4&&Qc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),s&512&&(xt||n===null||Mn(n,n.return)),e.flags&32){c=e.stateNode;try{hl(c,"")}catch(de){Fe(e,e.return,de)}}s&4&&e.stateNode!=null&&(c=e.memoizedProps,Qc(e,c,n!==null?n.memoizedProps:c)),s&1024&&(Ic=!0);break;case 6:if(Ut(t,e),Ht(e),s&4){if(e.stateNode===null)throw Error(o(162));s=e.memoizedProps,n=e.stateNode;try{n.nodeValue=s}catch(de){Fe(e,e.return,de)}}break;case 3:if(kr=null,c=bn,bn=Cr(t.containerInfo),Ut(t,e),bn=c,Ht(e),s&4&&n!==null&&n.memoizedState.isDehydrated)try{Fl(t.containerInfo)}catch(de){Fe(e,e.return,de)}Ic&&(Ic=!1,Hh(e));break;case 4:s=bn,bn=Cr(e.stateNode.containerInfo),Ut(t,e),Ht(e),bn=s;break;case 12:Ut(t,e),Ht(e);break;case 31:Ut(t,e),Ht(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,dr(e,s)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(hr=Ue()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,dr(e,s)));break;case 22:c=e.memoizedState!==null;var D=n!==null&&n.memoizedState!==null,G=Qn,J=xt;if(Qn=G||c,xt=J||D,Ut(t,e),xt=J,Qn=G,Ht(e),s&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(n===null||D||Qn||xt||Ia(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){D=n=t;try{if(u=D.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{S=D.stateNode;var ee=D.memoizedProps.style,Q=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;S.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(de){Fe(D,D.return,de)}}}else if(t.tag===6){if(n===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(de){Fe(D,D.return,de)}}}else if(t.tag===18){if(n===null){D=t;try{var I=D.stateNode;c?Mp(I,!0):Mp(D.stateNode,!1)}catch(de){Fe(D,D.return,de)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}s&4&&(s=e.updateQueue,s!==null&&(n=s.retryQueue,n!==null&&(s.retryQueue=null,dr(e,n))));break;case 19:Ut(t,e),Ht(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,dr(e,s)));break;case 30:break;case 21:break;default:Ut(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{for(var n,s=e.return;s!==null;){if(Rh(s)){n=s;break}s=s.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode,u=Kc(e);fr(e,u,c);break;case 5:var v=n.stateNode;n.flags&32&&(hl(v,""),n.flags&=-33);var S=Kc(e);fr(e,S,v);break;case 3:case 4:var D=n.stateNode.containerInfo,G=Kc(e);Zc(e,G,D);break;default:throw Error(o(161))}}catch(J){Fe(e,e.return,J)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Hh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Hh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Zn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)_h(e,t.alternate,t),t=t.sibling}function Ia(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:va(4,t,t.return),Ia(t);break;case 1:Mn(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&Mh(t,t.return,n),Ia(t);break;case 27:Fs(t.stateNode);case 26:case 5:Mn(t,t.return),Ia(t);break;case 22:t.memoizedState===null&&Ia(t);break;case 30:Ia(t);break;default:Ia(t)}e=e.sibling}}function In(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var s=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:In(c,u,n),Os(4,u);break;case 1:if(In(c,u,n),s=u,c=s.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(G){Fe(s,s.return,G)}if(s=u,c=s.updateQueue,c!==null){var S=s.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)gm(D[c],S)}catch(G){Fe(s,s.return,G)}}n&&v&64&&kh(u),Bs(u,u.return);break;case 27:Th(u);case 26:case 5:In(c,u,n),n&&s===null&&v&4&&qh(u),Bs(u,u.return);break;case 12:In(c,u,n);break;case 31:In(c,u,n),n&&v&4&&Lh(c,u);break;case 13:In(c,u,n),n&&v&4&&zh(c,u);break;case 22:u.memoizedState===null&&In(c,u,n),Bs(u,u.return);break;case 30:break;default:In(c,u,n)}t=t.sibling}}function Jc(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&As(n))}function Pc(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&As(e))}function Sn(e,t,n,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Vh(e,t,n,s),t=t.sibling}function Vh(e,t,n,s){var c=t.flags;switch(t.tag){case 0:case 11:case 15:Sn(e,t,n,s),c&2048&&Os(9,t);break;case 1:Sn(e,t,n,s);break;case 3:Sn(e,t,n,s),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&As(e)));break;case 12:if(c&2048){Sn(e,t,n,s),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,S=u.onPostCommit;typeof S=="function"&&S(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Fe(t,t.return,D)}}else Sn(e,t,n,s);break;case 31:Sn(e,t,n,s);break;case 13:Sn(e,t,n,s);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?Sn(e,t,n,s):Ls(e,t):u._visibility&2?Sn(e,t,n,s):(u._visibility|=2,_l(e,t,n,s,(t.subtreeFlags&10256)!==0||!1)),c&2048&&Jc(v,t);break;case 24:Sn(e,t,n,s),c&2048&&Pc(t.alternate,t);break;default:Sn(e,t,n,s)}}function _l(e,t,n,s,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,S=n,D=s,G=v.flags;switch(v.tag){case 0:case 11:case 15:_l(u,v,S,D,c),Os(8,v);break;case 23:break;case 22:var J=v.stateNode;v.memoizedState!==null?J._visibility&2?_l(u,v,S,D,c):Ls(u,v):(J._visibility|=2,_l(u,v,S,D,c)),c&&G&2048&&Jc(v.alternate,v);break;case 24:_l(u,v,S,D,c),c&&G&2048&&Pc(v.alternate,v);break;default:_l(u,v,S,D,c)}t=t.sibling}}function Ls(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,s=t,c=s.flags;switch(s.tag){case 22:Ls(n,s),c&2048&&Jc(s.alternate,s);break;case 24:Ls(n,s),c&2048&&Pc(s.alternate,s);break;default:Ls(n,s)}t=t.sibling}}var zs=8192;function Ol(e,t,n){if(e.subtreeFlags&zs)for(e=e.child;e!==null;)$h(e,t,n),e=e.sibling}function $h(e,t,n){switch(e.tag){case 26:Ol(e,t,n),e.flags&zs&&e.memoizedState!==null&&Oy(n,bn,e.memoizedState,e.memoizedProps);break;case 5:Ol(e,t,n);break;case 3:case 4:var s=bn;bn=Cr(e.stateNode.containerInfo),Ol(e,t,n),bn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=zs,zs=16777216,Ol(e,t,n),zs=s):Ol(e,t,n));break;default:Ol(e,t,n)}}function Gh(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 Us(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];At=s,Fh(s,e)}Gh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Yh(e),e=e.sibling}function Yh(e){switch(e.tag){case 0:case 11:case 15:Us(e),e.flags&2048&&va(9,e,e.return);break;case 3:Us(e);break;case 12:Us(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,mr(e)):Us(e);break;default:Us(e)}}function mr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];At=s,Fh(s,e)}Gh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:va(8,t,t.return),mr(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,mr(t));break;default:mr(t)}e=e.sibling}}function Fh(e,t){for(;At!==null;){var n=At;switch(n.tag){case 0:case 11:case 15:va(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var s=n.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:As(n.memoizedState.cache)}if(s=n.child,s!==null)s.return=n,At=s;else e:for(n=e;At!==null;){s=At;var c=s.sibling,u=s.return;if(Oh(s),s===n){At=null;break e}if(c!==null){c.return=u,At=c;break e}At=u}}}var Iv={getCacheForType:function(e){var t=wt(mt),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return wt(mt).controller.signal}},Jv=typeof WeakMap=="function"?WeakMap:Map,He=0,We=null,ke=null,qe=0,Ye=0,Kt=null,ya=!1,Bl=!1,Wc=!1,Jn=0,rt=0,ba=0,Ja=0,eu=0,Zt=0,Ll=0,Hs=null,Vt=null,tu=!1,hr=0,Xh=0,pr=1/0,xr=null,Sa=null,yt=0,Aa=null,zl=null,Pn=0,nu=0,au=null,Qh=null,Vs=0,lu=null;function It(){return(He&2)!==0&&qe!==0?qe&-qe:R.T!==null?uu():Ge()}function Kh(){if(Zt===0)if((qe&536870912)===0||Te){var e=et;et<<=1,(et&3932160)===0&&(et=262144),Zt=e}else Zt=536870912;return e=Xt.current,e!==null&&(e.flags|=32),Zt}function $t(e,t,n){(e===We&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)&&(Ul(e,0),ja(e,qe,Zt,!1)),_a(e,n),((He&2)===0||e!==We)&&(e===We&&((He&2)===0&&(Ja|=n),rt===4&&ja(e,qe,Zt,!1)),qn(e))}function Zh(e,t,n){if((He&6)!==0)throw Error(o(327));var s=!n&&(t&127)===0&&(t&e.expiredLanes)===0||Cn(e,t),c=s?ey(e,t):iu(e,t,!0),u=s;do{if(c===0){Bl&&!s&&ja(e,t,0,!1);break}else{if(n=e.current.alternate,u&&!Pv(n)){c=iu(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var v=0;else v=e.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){t=v;e:{var S=e;c=Hs;var D=S.current.memoizedState.isDehydrated;if(D&&(Ul(S,v).flags|=256),v=iu(S,v,!1),v!==2){if(Wc&&!D){S.errorRecoveryDisabledLanes|=u,Ja|=u,c=4;break e}u=Vt,Vt=c,u!==null&&(Vt===null?Vt=u:Vt.push.apply(Vt,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){Ul(e,0),ja(e,t,0,!0);break}e:{switch(s=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ja(s,t,Zt,!ya);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=hr+300-Ue(),10<c)){if(ja(s,t,Zt,!ya),ra(s,0,!0)!==0)break e;Pn=t,s.timeoutHandle=Cp(Ih.bind(null,s,n,Vt,xr,tu,t,Zt,Ja,Ll,ya,u,"Throttled",-0,0),c);break e}Ih(s,n,Vt,xr,tu,t,Zt,Ja,Ll,ya,u,null,-0,0)}}break}while(!0);qn(e)}function Ih(e,t,n,s,c,u,v,S,D,G,J,ee,Q,I){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ln},$h(t,u,ee);var de=(u&62914560)===u?hr-Ue():(u&4194048)===u?Xh-Ue():0;if(de=By(ee,de),de!==null){Pn=u,e.cancelPendingCommit=de(lp.bind(null,e,t,u,n,s,c,v,S,D,J,ee,null,Q,I)),ja(e,u,v,!G);return}}lp(e,t,u,n,s,c,v,S,D)}function Pv(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var s=0;s<n.length;s++){var c=n[s],u=c.getSnapshot;c=c.value;try{if(!Yt(u(),c))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ja(e,t,n,s){t&=~eu,t&=~Ja,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var c=t;0<c;){var u=31-dt(c),v=1<<u;s[u]=-1,c&=~v}n!==0&&tn(e,n,t)}function gr(){return(He&6)===0?($s(0),!1):!0}function su(){if(ke!==null){if(Ye===0)var e=ke.return;else e=ke,Vn=$a=null,Sc(e),Ml=null,Ns=0,e=ke;for(;e!==null;)Eh(e.alternate,e),e=e.return;ke=null}}function Ul(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,vy(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Pn=0,su(),We=e,ke=n=Un(e.current,null),qe=t,Ye=0,Kt=null,ya=!1,Bl=Cn(e,t),Wc=!1,Ll=Zt=eu=Ja=ba=rt=0,Vt=Hs=null,tu=!1,(t&8)!==0&&(t|=t&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=t;0<s;){var c=31-dt(s),u=1<<c;t|=e[c],s&=~u}return Jn=t,zi(),n}function Jh(e,t){Ne=null,R.H=Ts,t===kl||t===Xi?(t=mm(),Ye=3):t===cc?(t=mm(),Ye=4):Ye=t===Lc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Kt=t,ke===null&&(rt=1,ir(e,rn(t,e.current)))}function Ph(){var e=Xt.current;return e===null?!0:(qe&4194048)===qe?fn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===fn:!1}function Wh(){var e=R.H;return R.H=Ts,e===null?Ts:e}function ep(){var e=R.A;return R.A=Iv,e}function vr(){rt=4,ya||(qe&4194048)!==qe&&Xt.current!==null||(Bl=!0),(ba&134217727)===0&&(Ja&134217727)===0||We===null||ja(We,qe,Zt,!1)}function iu(e,t,n){var s=He;He|=2;var c=Wh(),u=ep();(We!==e||qe!==t)&&(xr=null,Ul(e,t)),t=!1;var v=rt;e:do try{if(Ye!==0&&ke!==null){var S=ke,D=Kt;switch(Ye){case 8:su(),v=6;break e;case 3:case 2:case 9:case 6:Xt.current===null&&(t=!0);var G=Ye;if(Ye=0,Kt=null,Hl(e,S,D,G),n&&Bl){v=0;break e}break;default:G=Ye,Ye=0,Kt=null,Hl(e,S,D,G)}}Wv(),v=rt;break}catch(J){Jh(e,J)}while(!0);return t&&e.shellSuspendCounter++,Vn=$a=null,He=s,R.H=c,R.A=u,ke===null&&(We=null,qe=0,zi()),v}function Wv(){for(;ke!==null;)tp(ke)}function ey(e,t){var n=He;He|=2;var s=Wh(),c=ep();We!==e||qe!==t?(xr=null,pr=Ue()+500,Ul(e,t)):Bl=Cn(e,t);e:do try{if(Ye!==0&&ke!==null){t=ke;var u=Kt;t:switch(Ye){case 1:Ye=0,Kt=null,Hl(e,t,u,1);break;case 2:case 9:if(fm(u)){Ye=0,Kt=null,np(t);break}t=function(){Ye!==2&&Ye!==9||We!==e||(Ye=7),qn(e)},u.then(t,t);break e;case 3:Ye=7;break e;case 4:Ye=5;break e;case 7:fm(u)?(Ye=0,Kt=null,np(t)):(Ye=0,Kt=null,Hl(e,t,u,7));break;case 5:var v=null;switch(ke.tag){case 26:v=ke.memoizedState;case 5:case 27:var S=ke;if(v?Vp(v):S.stateNode.complete){Ye=0,Kt=null;var D=S.sibling;if(D!==null)ke=D;else{var G=S.return;G!==null?(ke=G,yr(G)):ke=null}break t}}Ye=0,Kt=null,Hl(e,t,u,5);break;case 6:Ye=0,Kt=null,Hl(e,t,u,6);break;case 8:su(),rt=6;break e;default:throw Error(o(462))}}ty();break}catch(J){Jh(e,J)}while(!0);return Vn=$a=null,R.H=s,R.A=c,He=n,ke!==null?0:(We=null,qe=0,zi(),rt)}function ty(){for(;ke!==null&&!$e();)tp(ke)}function tp(e){var t=wh(e.alternate,e,Jn);e.memoizedProps=e.pendingProps,t===null?yr(e):ke=t}function np(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=yh(n,t,t.pendingProps,t.type,void 0,qe);break;case 11:t=yh(n,t,t.pendingProps,t.type.render,t.ref,qe);break;case 5:Sc(t);default:Eh(n,t),t=ke=em(t,Jn),t=wh(n,t,Jn)}e.memoizedProps=e.pendingProps,t===null?yr(e):ke=t}function Hl(e,t,n,s){Vn=$a=null,Sc(t),Ml=null,Ns=0;var c=t.return;try{if(Gv(e,c,t,n,qe)){rt=1,ir(e,rn(n,e.current)),ke=null;return}}catch(u){if(c!==null)throw ke=c,u;rt=1,ir(e,rn(n,e.current)),ke=null;return}t.flags&32768?(Te||s===1?e=!0:Bl||(qe&536870912)!==0?e=!1:(ya=e=!0,(s===2||s===9||s===3||s===6)&&(s=Xt.current,s!==null&&s.tag===13&&(s.flags|=16384))),ap(t,e)):yr(t)}function yr(e){var t=e;do{if((t.flags&32768)!==0){ap(t,ya);return}e=t.return;var n=Xv(t.alternate,t,Jn);if(n!==null){ke=n;return}if(t=t.sibling,t!==null){ke=t;return}ke=t=e}while(t!==null);rt===0&&(rt=5)}function ap(e,t){do{var n=Qv(e.alternate,e);if(n!==null){n.flags&=32767,ke=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){ke=e;return}ke=e=n}while(e!==null);rt=6,ke=null}function lp(e,t,n,s,c,u,v,S,D){e.cancelPendingCommit=null;do br();while(yt!==0);if((He&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Ko,Ci(e,n,u,v,S,D),e===We&&(ke=We=null,qe=0),zl=t,Aa=e,Pn=n,nu=u,au=c,Qh=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,sy(gn,function(){return cp(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=R.T,R.T=null,c=X.p,X.p=2,v=He,He|=4;try{Kv(e,t,n)}finally{He=v,X.p=c,R.T=s}}yt=1,sp(),ip(),rp()}}function sp(){if(yt===1){yt=0;var e=Aa,t=zl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=R.T,R.T=null;var s=X.p;X.p=2;var c=He;He|=4;try{Uh(t,e);var u=vu,v=Fd(e.containerInfo),S=u.focusedElem,D=u.selectionRange;if(v!==S&&S&&S.ownerDocument&&Yd(S.ownerDocument.documentElement,S)){if(D!==null&&Go(S)){var G=D.start,J=D.end;if(J===void 0&&(J=G),"selectionStart"in S)S.selectionStart=G,S.selectionEnd=Math.min(J,S.value.length);else{var ee=S.ownerDocument||document,Q=ee&&ee.defaultView||window;if(Q.getSelection){var I=Q.getSelection(),de=S.textContent.length,Se=Math.min(D.start,de),Ke=D.end===void 0?Se:Math.min(D.end,de);!I.extend&&Se>Ke&&(v=Ke,Ke=Se,Se=v);var z=Gd(S,Se),_=Gd(S,Ke);if(z&&_&&(I.rangeCount!==1||I.anchorNode!==z.node||I.anchorOffset!==z.offset||I.focusNode!==_.node||I.focusOffset!==_.offset)){var $=ee.createRange();$.setStart(z.node,z.offset),I.removeAllRanges(),Se>Ke?(I.addRange($),I.extend(_.node,_.offset)):($.setEnd(_.node,_.offset),I.addRange($))}}}}for(ee=[],I=S;I=I.parentNode;)I.nodeType===1&&ee.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<ee.length;S++){var P=ee[S];P.element.scrollLeft=P.left,P.element.scrollTop=P.top}}Tr=!!gu,vu=gu=null}finally{He=c,X.p=s,R.T=n}}e.current=t,yt=2}}function ip(){if(yt===2){yt=0;var e=Aa,t=zl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=R.T,R.T=null;var s=X.p;X.p=2;var c=He;He|=4;try{_h(e,t.alternate,t)}finally{He=c,X.p=s,R.T=n}}yt=3}}function rp(){if(yt===4||yt===3){yt=0,Tt();var e=Aa,t=zl,n=Pn,s=Qh;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?yt=5:(yt=0,zl=Aa=null,op(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(Sa=null),Ee(n),t=t.stateNode,bt&&typeof bt.onCommitFiberRoot=="function")try{bt.onCommitFiberRoot(vn,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=R.T,c=X.p,X.p=2,R.T=null;try{for(var u=e.onRecoverableError,v=0;v<s.length;v++){var S=s[v];u(S.value,{componentStack:S.stack})}}finally{R.T=t,X.p=c}}(Pn&3)!==0&&br(),qn(e),c=e.pendingLanes,(n&261930)!==0&&(c&42)!==0?e===lu?Vs++:(Vs=0,lu=e):Vs=0,$s(0)}}function op(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,As(t)))}function br(){return sp(),ip(),rp(),cp()}function cp(){if(yt!==5)return!1;var e=Aa,t=nu;nu=0;var n=Ee(Pn),s=R.T,c=X.p;try{X.p=32>n?32:n,R.T=null,n=au,au=null;var u=Aa,v=Pn;if(yt=0,zl=Aa=null,Pn=0,(He&6)!==0)throw Error(o(331));var S=He;if(He|=4,Yh(u.current),Vh(u,u.current,v,n),He=S,$s(0,!1),bt&&typeof bt.onPostCommitFiberRoot=="function")try{bt.onPostCommitFiberRoot(vn,u)}catch{}return!0}finally{X.p=c,R.T=s,op(e,t)}}function up(e,t,n){t=rn(n,t),t=Bc(e.stateNode,t,2),e=pa(e,t,2),e!==null&&(_a(e,2),qn(e))}function Fe(e,t,n){if(e.tag===3)up(e,e,n);else for(;t!==null;){if(t.tag===3){up(t,e,n);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Sa===null||!Sa.has(s))){e=rn(n,e),n=fh(2),s=pa(t,n,2),s!==null&&(dh(n,s,t,e),_a(s,2),qn(s));break}}t=t.return}}function ru(e,t,n){var s=e.pingCache;if(s===null){s=e.pingCache=new Jv;var c=new Set;s.set(t,c)}else c=s.get(t),c===void 0&&(c=new Set,s.set(t,c));c.has(n)||(Wc=!0,c.add(n),e=ny.bind(null,e,t,n),t.then(e,e))}function ny(e,t,n){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,We===e&&(qe&n)===n&&(rt===4||rt===3&&(qe&62914560)===qe&&300>Ue()-hr?(He&2)===0&&Ul(e,0):eu|=n,Ll===qe&&(Ll=0)),qn(e)}function fp(e,t){t===0&&(t=wi()),e=Ua(e,t),e!==null&&(_a(e,t),qn(e))}function ay(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),fp(e,n)}function ly(e,t){var n=0;switch(e.tag){case 31:case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(n=c.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(o(314))}s!==null&&s.delete(t),fp(e,n)}function sy(e,t){return ve(e,t)}var Sr=null,Vl=null,ou=!1,Ar=!1,cu=!1,Na=0;function qn(e){e!==Vl&&e.next===null&&(Vl===null?Sr=Vl=e:Vl=Vl.next=e),Ar=!0,ou||(ou=!0,ry())}function $s(e,t){if(!cu&&Ar){cu=!0;do for(var n=!1,s=Sr;s!==null;){if(e!==0){var c=s.pendingLanes;if(c===0)var u=0;else{var v=s.suspendedLanes,S=s.pingedLanes;u=(1<<31-dt(42|e)+1)-1,u&=c&~(v&~S),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(n=!0,pp(s,u))}else u=qe,u=ra(s,s===We?u:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(u&3)===0||Cn(s,u)||(n=!0,pp(s,u));s=s.next}while(n);cu=!1}}function iy(){dp()}function dp(){Ar=ou=!1;var e=0;Na!==0&&gy()&&(e=Na);for(var t=Ue(),n=null,s=Sr;s!==null;){var c=s.next,u=mp(s,t);u===0?(s.next=null,n===null?Sr=c:n.next=c,c===null&&(Vl=n)):(n=s,(e!==0||(u&3)!==0)&&(Ar=!0)),s=c}yt!==0&&yt!==5||$s(e),Na!==0&&(Na=0)}function mp(e,t){for(var n=e.suspendedLanes,s=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-dt(u),S=1<<v,D=c[v];D===-1?((S&n)===0||(S&s)!==0)&&(c[v]=Ni(S,t)):D<=t&&(e.expiredLanes|=S),u&=~S}if(t=We,n=qe,n=ra(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,n===0||e===t&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&Ce(s),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||Cn(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(s!==null&&Ce(s),Ee(n)){case 2:case 8:n=_t;break;case 32:n=gn;break;case 268435456:n=Ot;break;default:n=gn}return s=hp.bind(null,e),n=ve(n,s),e.callbackPriority=t,e.callbackNode=n,t}return s!==null&&s!==null&&Ce(s),e.callbackPriority=2,e.callbackNode=null,2}function hp(e,t){if(yt!==0&&yt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(br()&&e.callbackNode!==n)return null;var s=qe;return s=ra(e,e===We?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Zh(e,s,t),mp(e,Ue()),e.callbackNode!=null&&e.callbackNode===n?hp.bind(null,e):null)}function pp(e,t){if(br())return null;Zh(e,t,!0)}function ry(){yy(function(){(He&6)!==0?ve(ft,iy):dp()})}function uu(){if(Na===0){var e=Cl;e===0&&(e=Da,Da<<=1,(Da&261888)===0&&(Da=256)),Na=e}return Na}function xp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:qi(""+e)}function gp(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function oy(e,t,n,s,c){if(t==="submit"&&n&&n.stateNode===c){var u=xp((c[Be]||null).action),v=s.submitter;v&&(t=(t=v[Be]||null)?xp(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var S=new _i("action","action",null,s,c);e.push({event:S,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(Na!==0){var D=v?gp(c,v):new FormData(c);qc(n,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(S.preventDefault(),D=v?gp(c,v):new FormData(c),qc(n,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var fu=0;fu<Qo.length;fu++){var du=Qo[fu],cy=du.toLowerCase(),uy=du[0].toUpperCase()+du.slice(1);yn(cy,"on"+uy)}yn(Kd,"onAnimationEnd"),yn(Zd,"onAnimationIteration"),yn(Id,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Cv,"onTransitionRun"),yn(Ev,"onTransitionStart"),yn(kv,"onTransitionCancel"),yn(Jd,"onTransitionEnd"),dl("onMouseEnter",["mouseout","mouseover"]),dl("onMouseLeave",["mouseout","mouseover"]),dl("onPointerEnter",["pointerout","pointerover"]),dl("onPointerLeave",["pointerout","pointerover"]),Oa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Oa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Oa("onBeforeInput",["compositionend","keypress","textInput","paste"]),Oa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Oa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Oa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gs="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(" "),fy=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Gs));function vp(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var s=e[n],c=s.event;s=s.listeners;e:{var u=void 0;if(t)for(var v=s.length-1;0<=v;v--){var S=s[v],D=S.instance,G=S.currentTarget;if(S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=G;try{u(c)}catch(J){Li(J)}c.currentTarget=null,u=D}else for(v=0;v<s.length;v++){if(S=s[v],D=S.instance,G=S.currentTarget,S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=G;try{u(c)}catch(J){Li(J)}c.currentTarget=null,u=D}}}}function Me(e,t){var n=t[wo];n===void 0&&(n=t[wo]=new Set);var s=e+"__bubble";n.has(s)||(yp(t,e,2,!1),n.add(s))}function mu(e,t,n){var s=0;t&&(s|=4),yp(n,e,s,t)}var jr="_reactListening"+Math.random().toString(36).slice(2);function hu(e){if(!e[jr]){e[jr]=!0,dd.forEach(function(n){n!=="selectionchange"&&(fy.has(n)||mu(n,!1,e),mu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[jr]||(t[jr]=!0,mu("selectionchange",!1,t))}}function yp(e,t,n,s){switch(Kp(t)){case 2:var c=Uy;break;case 8:c=Hy;break;default:c=Mu}n=c.bind(null,t,n,e),c=void 0,!_o||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),s?c!==void 0?e.addEventListener(t,n,{capture:!0,passive:c}):e.addEventListener(t,n,!0):c!==void 0?e.addEventListener(t,n,{passive:c}):e.addEventListener(t,n,!1)}function pu(e,t,n,s,c){var u=s;if((t&1)===0&&(t&2)===0&&s!==null)e:for(;;){if(s===null)return;var v=s.tag;if(v===3||v===4){var S=s.stateNode.containerInfo;if(S===c)break;if(v===4)for(v=s.return;v!==null;){var D=v.tag;if((D===3||D===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;S!==null;){if(v=cl(S),v===null)return;if(D=v.tag,D===5||D===6||D===26||D===27){s=u=v;continue e}S=S.parentNode}}s=s.return}Nd(function(){var G=u,J=To(n),ee=[];e:{var Q=Pd.get(e);if(Q!==void 0){var I=_i,de=e;switch(e){case"keypress":if(Ti(n)===0)break e;case"keydown":case"keyup":I=lv;break;case"focusin":de="focus",I=zo;break;case"focusout":de="blur",I=zo;break;case"beforeblur":case"afterblur":I=zo;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":I=Ed;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":I=Xg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":I=rv;break;case Kd:case Zd:case Id:I=Zg;break;case Jd:I=cv;break;case"scroll":case"scrollend":I=Yg;break;case"wheel":I=fv;break;case"copy":case"cut":case"paste":I=Jg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":I=Md;break;case"toggle":case"beforetoggle":I=mv}var Se=(t&4)!==0,Ke=!Se&&(e==="scroll"||e==="scrollend"),z=Se?Q!==null?Q+"Capture":null:Q;Se=[];for(var _=G,$;_!==null;){var P=_;if($=P.stateNode,P=P.tag,P!==5&&P!==26&&P!==27||$===null||z===null||(P=fs(_,z),P!=null&&Se.push(Ys(_,P,$))),Ke)break;_=_.return}0<Se.length&&(Q=new I(Q,de,null,n,J),ee.push({event:Q,listeners:Se}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",I=e==="mouseout"||e==="pointerout",Q&&n!==Ro&&(de=n.relatedTarget||n.fromElement)&&(cl(de)||de[nn]))break e;if((I||Q)&&(Q=J.window===J?J:(Q=J.ownerDocument)?Q.defaultView||Q.parentWindow:window,I?(de=n.relatedTarget||n.toElement,I=G,de=de?cl(de):null,de!==null&&(Ke=d(de),Se=de.tag,de!==Ke||Se!==5&&Se!==27&&Se!==6)&&(de=null)):(I=null,de=G),I!==de)){if(Se=Ed,P="onMouseLeave",z="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(Se=Md,P="onPointerLeave",z="onPointerEnter",_="pointer"),Ke=I==null?Q:us(I),$=de==null?Q:us(de),Q=new Se(P,_+"leave",I,n,J),Q.target=Ke,Q.relatedTarget=$,P=null,cl(J)===G&&(Se=new Se(z,_+"enter",de,n,J),Se.target=$,Se.relatedTarget=Ke,P=Se),Ke=P,I&&de)t:{for(Se=dy,z=I,_=de,$=0,P=z;P;P=Se(P))$++;P=0;for(var ye=_;ye;ye=Se(ye))P++;for(;0<$-P;)z=Se(z),$--;for(;0<P-$;)_=Se(_),P--;for(;$--;){if(z===_||_!==null&&z===_.alternate){Se=z;break t}z=Se(z),_=Se(_)}Se=null}else Se=null;I!==null&&bp(ee,Q,I,Se,!1),de!==null&&Ke!==null&&bp(ee,Ke,de,Se,!0)}}e:{if(Q=G?us(G):window,I=Q.nodeName&&Q.nodeName.toLowerCase(),I==="select"||I==="input"&&Q.type==="file")var Le=Ld;else if(Od(Q))if(zd)Le=jv;else{Le=Sv;var xe=bv}else I=Q.nodeName,!I||I.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?G&&qo(G.elementType)&&(Le=Ld):Le=Av;if(Le&&(Le=Le(e,G))){Bd(ee,Le,n,J);break e}xe&&xe(e,Q,G),e==="focusout"&&G&&Q.type==="number"&&G.memoizedProps.value!=null&&Mo(Q,"number",Q.value)}switch(xe=G?us(G):window,e){case"focusin":(Od(xe)||xe.contentEditable==="true")&&(vl=xe,Yo=G,ys=null);break;case"focusout":ys=Yo=vl=null;break;case"mousedown":Fo=!0;break;case"contextmenu":case"mouseup":case"dragend":Fo=!1,Xd(ee,n,J);break;case"selectionchange":if(wv)break;case"keydown":case"keyup":Xd(ee,n,J)}var we;if(Ho)e:{switch(e){case"compositionstart":var Re="onCompositionStart";break e;case"compositionend":Re="onCompositionEnd";break e;case"compositionupdate":Re="onCompositionUpdate";break e}Re=void 0}else gl?Dd(e,n)&&(Re="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(Re="onCompositionStart");Re&&(qd&&n.locale!=="ko"&&(gl||Re!=="onCompositionStart"?Re==="onCompositionEnd"&&gl&&(we=wd()):(oa=J,Oo="value"in oa?oa.value:oa.textContent,gl=!0)),xe=Nr(G,Re),0<xe.length&&(Re=new kd(Re,e,null,n,J),ee.push({event:Re,listeners:xe}),we?Re.data=we:(we=_d(n),we!==null&&(Re.data=we)))),(we=pv?xv(e,n):gv(e,n))&&(Re=Nr(G,"onBeforeInput"),0<Re.length&&(xe=new kd("onBeforeInput","beforeinput",null,n,J),ee.push({event:xe,listeners:Re}),xe.data=we)),oy(ee,e,G,n,J)}vp(ee,t)})}function Ys(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Nr(e,t){for(var n=t+"Capture",s=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=fs(e,n),c!=null&&s.unshift(Ys(e,c,u)),c=fs(e,t),c!=null&&s.push(Ys(e,c,u))),e.tag===3)return s;e=e.return}return[]}function dy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function bp(e,t,n,s,c){for(var u=t._reactName,v=[];n!==null&&n!==s;){var S=n,D=S.alternate,G=S.stateNode;if(S=S.tag,D!==null&&D===s)break;S!==5&&S!==26&&S!==27||G===null||(D=G,c?(G=fs(n,u),G!=null&&v.unshift(Ys(n,G,D))):c||(G=fs(n,u),G!=null&&v.push(Ys(n,G,D)))),n=n.return}v.length!==0&&e.push({event:t,listeners:v})}var my=/\r\n?/g,hy=/\u0000|\uFFFD/g;function Sp(e){return(typeof e=="string"?e:""+e).replace(my,`
|
||
`).replace(hy,"")}function Ap(e,t){return t=Sp(t),Sp(e)===t}function Qe(e,t,n,s,c,u){switch(n){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||hl(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&hl(e,""+s);break;case"className":ki(e,"class",s);break;case"tabIndex":ki(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":ki(e,n,s);break;case"style":Ad(e,s,u);break;case"data":if(t!=="object"){ki(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=qi(""+s),e.setAttribute(n,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(n==="formAction"?(t!=="input"&&Qe(e,t,"name",c.name,c,null),Qe(e,t,"formEncType",c.formEncType,c,null),Qe(e,t,"formMethod",c.formMethod,c,null),Qe(e,t,"formTarget",c.formTarget,c,null)):(Qe(e,t,"encType",c.encType,c,null),Qe(e,t,"method",c.method,c,null),Qe(e,t,"target",c.target,c,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=qi(""+s),e.setAttribute(n,s);break;case"onClick":s!=null&&(e.onclick=Ln);break;case"onScroll":s!=null&&Me("scroll",e);break;case"onScrollEnd":s!=null&&Me("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}n=qi(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""+s):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":s===!0?e.setAttribute(n,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,s):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(n,s):e.removeAttribute(n);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(n):e.setAttribute(n,s);break;case"popover":Me("beforetoggle",e),Me("toggle",e),Ei(e,"popover",s);break;case"xlinkActuate":Bn(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Bn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Bn(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Bn(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Bn(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Bn(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Bn(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Bn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Bn(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Ei(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=$g.get(n)||n,Ei(e,n,s))}}function xu(e,t,n,s,c,u){switch(n){case"style":Ad(e,s,u);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"children":typeof s=="string"?hl(e,s):(typeof s=="number"||typeof s=="bigint")&&hl(e,""+s);break;case"onScroll":s!=null&&Me("scroll",e);break;case"onScrollEnd":s!=null&&Me("scrollend",e);break;case"onClick":s!=null&&(e.onclick=Ln);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!md.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(c=n.endsWith("Capture"),t=n.slice(2,c?n.length-7:void 0),u=e[Be]||null,u=u!=null?u[n]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof s=="function")){typeof u!="function"&&u!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,s,c);break e}n in e?e[n]=s:s===!0?e.setAttribute(n,""):Ei(e,n,s)}}}function Et(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Me("error",e),Me("load",e);var s=!1,c=!1,u;for(u in n)if(n.hasOwnProperty(u)){var v=n[u];if(v!=null)switch(u){case"src":s=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Qe(e,t,u,v,n,null)}}c&&Qe(e,t,"srcSet",n.srcSet,n,null),s&&Qe(e,t,"src",n.src,n,null);return;case"input":Me("invalid",e);var S=u=v=c=null,D=null,G=null;for(s in n)if(n.hasOwnProperty(s)){var J=n[s];if(J!=null)switch(s){case"name":c=J;break;case"type":v=J;break;case"checked":D=J;break;case"defaultChecked":G=J;break;case"value":u=J;break;case"defaultValue":S=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(o(137,t));break;default:Qe(e,t,s,J,n,null)}}vd(e,u,S,D,G,v,c,!1);return;case"select":Me("invalid",e),s=v=u=null;for(c in n)if(n.hasOwnProperty(c)&&(S=n[c],S!=null))switch(c){case"value":u=S;break;case"defaultValue":v=S;break;case"multiple":s=S;default:Qe(e,t,c,S,n,null)}t=u,n=v,e.multiple=!!s,t!=null?ml(e,!!s,t,!1):n!=null&&ml(e,!!s,n,!0);return;case"textarea":Me("invalid",e),u=c=s=null;for(v in n)if(n.hasOwnProperty(v)&&(S=n[v],S!=null))switch(v){case"value":s=S;break;case"defaultValue":c=S;break;case"children":u=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(o(91));break;default:Qe(e,t,v,S,n,null)}bd(e,s,c,u);return;case"option":for(D in n)if(n.hasOwnProperty(D)&&(s=n[D],s!=null))switch(D){case"selected":e.selected=s&&typeof s!="function"&&typeof s!="symbol";break;default:Qe(e,t,D,s,n,null)}return;case"dialog":Me("beforetoggle",e),Me("toggle",e),Me("cancel",e),Me("close",e);break;case"iframe":case"object":Me("load",e);break;case"video":case"audio":for(s=0;s<Gs.length;s++)Me(Gs[s],e);break;case"image":Me("error",e),Me("load",e);break;case"details":Me("toggle",e);break;case"embed":case"source":case"link":Me("error",e),Me("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(G in n)if(n.hasOwnProperty(G)&&(s=n[G],s!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Qe(e,t,G,s,n,null)}return;default:if(qo(t)){for(J in n)n.hasOwnProperty(J)&&(s=n[J],s!==void 0&&xu(e,t,J,s,n,void 0));return}}for(S in n)n.hasOwnProperty(S)&&(s=n[S],s!=null&&Qe(e,t,S,s,n,null))}function py(e,t,n,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,v=null,S=null,D=null,G=null,J=null;for(I in n){var ee=n[I];if(n.hasOwnProperty(I)&&ee!=null)switch(I){case"checked":break;case"value":break;case"defaultValue":D=ee;default:s.hasOwnProperty(I)||Qe(e,t,I,null,s,ee)}}for(var Q in s){var I=s[Q];if(ee=n[Q],s.hasOwnProperty(Q)&&(I!=null||ee!=null))switch(Q){case"type":u=I;break;case"name":c=I;break;case"checked":G=I;break;case"defaultChecked":J=I;break;case"value":v=I;break;case"defaultValue":S=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:I!==ee&&Qe(e,t,Q,I,s,ee)}}ko(e,v,S,D,G,J,u,c);return;case"select":I=v=S=Q=null;for(u in n)if(D=n[u],n.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":I=D;default:s.hasOwnProperty(u)||Qe(e,t,u,null,s,D)}for(c in s)if(u=s[c],D=n[c],s.hasOwnProperty(c)&&(u!=null||D!=null))switch(c){case"value":Q=u;break;case"defaultValue":S=u;break;case"multiple":v=u;default:u!==D&&Qe(e,t,c,u,s,D)}t=S,n=v,s=I,Q!=null?ml(e,!!n,Q,!1):!!s!=!!n&&(t!=null?ml(e,!!n,t,!0):ml(e,!!n,n?[]:"",!1));return;case"textarea":I=Q=null;for(S in n)if(c=n[S],n.hasOwnProperty(S)&&c!=null&&!s.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:Qe(e,t,S,null,s,c)}for(v in s)if(c=s[v],u=n[v],s.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":Q=c;break;case"defaultValue":I=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Qe(e,t,v,c,s,u)}yd(e,Q,I);return;case"option":for(var de in n)if(Q=n[de],n.hasOwnProperty(de)&&Q!=null&&!s.hasOwnProperty(de))switch(de){case"selected":e.selected=!1;break;default:Qe(e,t,de,null,s,Q)}for(D in s)if(Q=s[D],I=n[D],s.hasOwnProperty(D)&&Q!==I&&(Q!=null||I!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Qe(e,t,D,Q,s,I)}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 Se in n)Q=n[Se],n.hasOwnProperty(Se)&&Q!=null&&!s.hasOwnProperty(Se)&&Qe(e,t,Se,null,s,Q);for(G in s)if(Q=s[G],I=n[G],s.hasOwnProperty(G)&&Q!==I&&(Q!=null||I!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Qe(e,t,G,Q,s,I)}return;default:if(qo(t)){for(var Ke in n)Q=n[Ke],n.hasOwnProperty(Ke)&&Q!==void 0&&!s.hasOwnProperty(Ke)&&xu(e,t,Ke,void 0,s,Q);for(J in s)Q=s[J],I=n[J],!s.hasOwnProperty(J)||Q===I||Q===void 0&&I===void 0||xu(e,t,J,Q,s,I);return}}for(var z in n)Q=n[z],n.hasOwnProperty(z)&&Q!=null&&!s.hasOwnProperty(z)&&Qe(e,t,z,null,s,Q);for(ee in s)Q=s[ee],I=n[ee],!s.hasOwnProperty(ee)||Q===I||Q==null&&I==null||Qe(e,t,ee,Q,s,I)}function jp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function xy(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),s=0;s<n.length;s++){var c=n[s],u=c.transferSize,v=c.initiatorType,S=c.duration;if(u&&S&&jp(v)){for(v=0,S=c.responseEnd,s+=1;s<n.length;s++){var D=n[s],G=D.startTime;if(G>S)break;var J=D.transferSize,ee=D.initiatorType;J&&jp(ee)&&(D=D.responseEnd,v+=J*(D<S?1:(S-G)/(D-G)))}if(--s,t+=8*(u+v)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var gu=null,vu=null;function wr(e){return e.nodeType===9?e:e.ownerDocument}function Np(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 wp(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 yu(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 bu=null;function gy(){var e=window.event;return e&&e.type==="popstate"?e===bu?!1:(bu=e,!0):(bu=null,!1)}var Cp=typeof setTimeout=="function"?setTimeout:void 0,vy=typeof clearTimeout=="function"?clearTimeout:void 0,Ep=typeof Promise=="function"?Promise:void 0,yy=typeof queueMicrotask=="function"?queueMicrotask:typeof Ep<"u"?function(e){return Ep.resolve(null).then(e).catch(by)}:Cp;function by(e){setTimeout(function(){throw e})}function wa(e){return e==="head"}function kp(e,t){var n=t,s=0;do{var c=n.nextSibling;if(e.removeChild(n),c&&c.nodeType===8)if(n=c.data,n==="/$"||n==="/&"){if(s===0){e.removeChild(c),Fl(t);return}s--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")s++;else if(n==="html")Fs(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Fs(n);for(var u=n.firstChild;u;){var v=u.nextSibling,S=u.nodeName;u[cs]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&u.rel.toLowerCase()==="stylesheet"||n.removeChild(u),u=v}}else n==="body"&&Fs(e.ownerDocument.body);n=c}while(n);Fl(t)}function Mp(e,t){var n=e;e=0;do{var s=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=s}while(n)}function Su(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Su(n),Co(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function Sy(e,t,n,s){for(;e.nodeType===1;){var c=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[cs])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=dn(e.nextSibling),e===null)break}return null}function Ay(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=dn(e.nextSibling),e===null))return null;return e}function qp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=dn(e.nextSibling),e===null))return null;return e}function Au(e){return e.data==="$?"||e.data==="$~"}function ju(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function jy(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var s=function(){t(),n.removeEventListener("DOMContentLoaded",s)};n.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function dn(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 Nu=null;function Rp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return dn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function Tp(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function Dp(e,t,n){switch(t=wr(n),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Fs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Co(e)}var mn=new Map,_p=new Set;function Cr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Wn=X.d;X.d={f:Ny,r:wy,D:Cy,C:Ey,L:ky,m:My,X:Ry,S:qy,M:Ty};function Ny(){var e=Wn.f(),t=gr();return e||t}function wy(e){var t=ul(e);t!==null&&t.tag===5&&t.type==="form"?Jm(t):Wn.r(e)}var $l=typeof document>"u"?null:document;function Op(e,t,n){var s=$l;if(s&&typeof t=="string"&&t){var c=ln(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof n=="string"&&(c+='[crossorigin="'+n+'"]'),_p.has(c)||(_p.add(c),e={rel:e,crossOrigin:n,href:t},s.querySelector(c)===null&&(t=s.createElement("link"),Et(t,"link",e),St(t),s.head.appendChild(t)))}}function Cy(e){Wn.D(e),Op("dns-prefetch",e,null)}function Ey(e,t){Wn.C(e,t),Op("preconnect",e,t)}function ky(e,t,n){Wn.L(e,t,n);var s=$l;if(s&&e&&t){var c='link[rel="preload"][as="'+ln(t)+'"]';t==="image"&&n&&n.imageSrcSet?(c+='[imagesrcset="'+ln(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(c+='[imagesizes="'+ln(n.imageSizes)+'"]')):c+='[href="'+ln(e)+'"]';var u=c;switch(t){case"style":u=Gl(e);break;case"script":u=Yl(e)}mn.has(u)||(e=b({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),mn.set(u,e),s.querySelector(c)!==null||t==="style"&&s.querySelector(Xs(u))||t==="script"&&s.querySelector(Qs(u))||(t=s.createElement("link"),Et(t,"link",e),St(t),s.head.appendChild(t)))}}function My(e,t){Wn.m(e,t);var n=$l;if(n&&e){var s=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+ln(s)+'"][href="'+ln(e)+'"]',u=c;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Yl(e)}if(!mn.has(u)&&(e=b({rel:"modulepreload",href:e},t),mn.set(u,e),n.querySelector(c)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Qs(u)))return}s=n.createElement("link"),Et(s,"link",e),St(s),n.head.appendChild(s)}}}function qy(e,t,n){Wn.S(e,t,n);var s=$l;if(s&&e){var c=fl(s).hoistableStyles,u=Gl(e);t=t||"default";var v=c.get(u);if(!v){var S={loading:0,preload:null};if(v=s.querySelector(Xs(u)))S.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},n),(n=mn.get(u))&&wu(e,n);var D=v=s.createElement("link");St(D),Et(D,"link",e),D._p=new Promise(function(G,J){D.onload=G,D.onerror=J}),D.addEventListener("load",function(){S.loading|=1}),D.addEventListener("error",function(){S.loading|=2}),S.loading|=4,Er(v,t,s)}v={type:"stylesheet",instance:v,count:1,state:S},c.set(u,v)}}}function Ry(e,t){Wn.X(e,t);var n=$l;if(n&&e){var s=fl(n).hoistableScripts,c=Yl(e),u=s.get(c);u||(u=n.querySelector(Qs(c)),u||(e=b({src:e,async:!0},t),(t=mn.get(c))&&Cu(e,t),u=n.createElement("script"),St(u),Et(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function Ty(e,t){Wn.M(e,t);var n=$l;if(n&&e){var s=fl(n).hoistableScripts,c=Yl(e),u=s.get(c);u||(u=n.querySelector(Qs(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=mn.get(c))&&Cu(e,t),u=n.createElement("script"),St(u),Et(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function Bp(e,t,n,s){var c=(c=ie.current)?Cr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Gl(n.href),n=fl(c).hoistableStyles,s=n.get(t),s||(s={type:"style",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Gl(n.href);var u=fl(c).hoistableStyles,v=u.get(e);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,v),(u=c.querySelector(Xs(e)))&&!u._p&&(v.instance=u,v.state.loading=5),mn.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mn.set(e,n),u||Dy(c,e,n,v.state))),t&&s===null)throw Error(o(528,""));return v}if(t&&s!==null)throw Error(o(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Yl(n),n=fl(c).hoistableScripts,s=n.get(t),s||(s={type:"script",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Gl(e){return'href="'+ln(e)+'"'}function Xs(e){return'link[rel="stylesheet"]['+e+"]"}function Lp(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Dy(e,t,n,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),Et(t,"link",n),St(t),e.head.appendChild(t))}function Yl(e){return'[src="'+ln(e)+'"]'}function Qs(e){return"script[async]"+e}function zp(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+ln(n.href)+'"]');if(s)return t.instance=s,St(s),s;var c=b({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),St(s),Et(s,"style",c),Er(s,n.precedence,e),t.instance=s;case"stylesheet":c=Gl(n.href);var u=e.querySelector(Xs(c));if(u)return t.state.loading|=4,t.instance=u,St(u),u;s=Lp(n),(c=mn.get(c))&&wu(s,c),u=(e.ownerDocument||e).createElement("link"),St(u);var v=u;return v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Et(u,"link",s),t.state.loading|=4,Er(u,n.precedence,e),t.instance=u;case"script":return u=Yl(n.src),(c=e.querySelector(Qs(u)))?(t.instance=c,St(c),c):(s=n,(c=mn.get(u))&&(s=b({},n),Cu(s,c)),e=e.ownerDocument||e,c=e.createElement("script"),St(c),Et(c,"link",s),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,Er(s,n.precedence,e));return t.instance}function Er(e,t,n){for(var s=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=s.length?s[s.length-1]:null,u=c,v=0;v<s.length;v++){var S=s[v];if(S.dataset.precedence===t)u=S;else if(u!==c)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function wu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Cu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var kr=null;function Up(e,t,n){if(kr===null){var s=new Map,c=kr=new Map;c.set(n,s)}else c=kr,s=c.get(n),s||(s=new Map,c.set(n,s));if(s.has(e))return s;for(s.set(e,null),n=n.getElementsByTagName(e),c=0;c<n.length;c++){var u=n[c];if(!(u[cs]||u[st]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var S=s.get(v);S?S.push(u):s.set(v,[u])}}return s}function Hp(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function _y(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Vp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Oy(e,t,n,s){if(n.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var c=Gl(s.href),u=t.querySelector(Xs(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Mr.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=u,St(u);return}u=t.ownerDocument||t,s=Lp(s),(c=mn.get(c))&&wu(s,c),u=u.createElement("link"),St(u);var v=u;v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Et(u,"link",s),n.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=Mr.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var Eu=0;function By(e,t){return e.stylesheets&&e.count===0&&Rr(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var s=setTimeout(function(){if(e.stylesheets&&Rr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Eu===0&&(Eu=62500*xy());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Rr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Eu?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(c)}}:null}function Mr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var qr=null;function Rr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,qr=new Map,t.forEach(Ly,e),qr=null,Mr.call(e))}function Ly(e,t){if(!(t.state.loading&4)){var n=qr.get(e);if(n)var s=n.get(null);else{n=new Map,qr.set(e,n);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var v=c[u];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(n.set(v.dataset.precedence,v),s=v)}s&&n.set(null,s)}c=t.instance,v=c.getAttribute("data-precedence"),u=n.get(v)||s,u===s&&n.set(null,c),n.set(v,c),this.count++,s=Mr.bind(this),c.addEventListener("load",s),c.addEventListener("error",s),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Ks={$$typeof:M,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function zy(e,t,n,s,c,u,v,S,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=os(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=os(0),this.hiddenUpdates=os(null),this.identifierPrefix=s,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function $p(e,t,n,s,c,u,v,S,D,G,J,ee){return e=new zy(e,t,n,v,D,G,J,ee,S),t=1,u===!0&&(t|=24),u=Ft(3,null,null,t),e.current=u,u.stateNode=e,t=ic(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:s,isDehydrated:n,cache:t},uc(u),e}function Gp(e){return e?(e=Sl,e):Sl}function Yp(e,t,n,s,c,u){c=Gp(c),s.context===null?s.context=c:s.pendingContext=c,s=ha(t),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=pa(e,s,t),n!==null&&($t(n,e,t),Cs(n,e,t))}function Fp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ku(e,t){Fp(e,t),(e=e.alternate)&&Fp(e,t)}function Xp(e){if(e.tag===13||e.tag===31){var t=Ua(e,67108864);t!==null&&$t(t,e,67108864),ku(e,67108864)}}function Qp(e){if(e.tag===13||e.tag===31){var t=It();t=Pe(t);var n=Ua(e,t);n!==null&&$t(n,e,t),ku(e,t)}}var Tr=!0;function Uy(e,t,n,s){var c=R.T;R.T=null;var u=X.p;try{X.p=2,Mu(e,t,n,s)}finally{X.p=u,R.T=c}}function Hy(e,t,n,s){var c=R.T;R.T=null;var u=X.p;try{X.p=8,Mu(e,t,n,s)}finally{X.p=u,R.T=c}}function Mu(e,t,n,s){if(Tr){var c=qu(s);if(c===null)pu(e,t,s,Dr,n),Zp(e,s);else if($y(c,e,t,n,s))s.stopPropagation();else if(Zp(e,s),t&4&&-1<Vy.indexOf(e)){for(;c!==null;){var u=ul(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=Gt(u.pendingLanes);if(v!==0){var S=u;for(S.pendingLanes|=2,S.entangledLanes|=2;v;){var D=1<<31-dt(v);S.entanglements[1]|=D,v&=~D}qn(u),(He&6)===0&&(pr=Ue()+500,$s(0))}}break;case 31:case 13:S=Ua(u,2),S!==null&&$t(S,u,2),gr(),ku(u,2)}if(u=qu(s),u===null&&pu(e,t,s,Dr,n),u===c)break;c=u}c!==null&&s.stopPropagation()}else pu(e,t,s,null,n)}}function qu(e){return e=To(e),Ru(e)}var Dr=null;function Ru(e){if(Dr=null,e=cl(e),e!==null){var t=d(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=h(t),e!==null)return e;e=null}else if(n===31){if(e=p(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Dr=e,null}function Kp(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(vt()){case ft:return 2;case _t:return 8;case gn:case il:return 32;case Ot:return 268435456;default:return 32}default:return 32}}var Tu=!1,Ca=null,Ea=null,ka=null,Zs=new Map,Is=new Map,Ma=[],Vy="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 Zp(e,t){switch(e){case"focusin":case"focusout":Ca=null;break;case"dragenter":case"dragleave":Ea=null;break;case"mouseover":case"mouseout":ka=null;break;case"pointerover":case"pointerout":Zs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Is.delete(t.pointerId)}}function Js(e,t,n,s,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:n,eventSystemFlags:s,nativeEvent:u,targetContainers:[c]},t!==null&&(t=ul(t),t!==null&&Xp(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function $y(e,t,n,s,c){switch(t){case"focusin":return Ca=Js(Ca,e,t,n,s,c),!0;case"dragenter":return Ea=Js(Ea,e,t,n,s,c),!0;case"mouseover":return ka=Js(ka,e,t,n,s,c),!0;case"pointerover":var u=c.pointerId;return Zs.set(u,Js(Zs.get(u)||null,e,t,n,s,c)),!0;case"gotpointercapture":return u=c.pointerId,Is.set(u,Js(Is.get(u)||null,e,t,n,s,c)),!0}return!1}function Ip(e){var t=cl(e.target);if(t!==null){var n=d(t);if(n!==null){if(t=n.tag,t===13){if(t=h(n),t!==null){e.blockedOn=t,jt(e.priority,function(){Qp(n)});return}}else if(t===31){if(t=p(n),t!==null){e.blockedOn=t,jt(e.priority,function(){Qp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function _r(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=qu(e.nativeEvent);if(n===null){n=e.nativeEvent;var s=new n.constructor(n.type,n);Ro=s,n.target.dispatchEvent(s),Ro=null}else return t=ul(n),t!==null&&Xp(t),e.blockedOn=n,!1;t.shift()}return!0}function Jp(e,t,n){_r(e)&&n.delete(t)}function Gy(){Tu=!1,Ca!==null&&_r(Ca)&&(Ca=null),Ea!==null&&_r(Ea)&&(Ea=null),ka!==null&&_r(ka)&&(ka=null),Zs.forEach(Jp),Is.forEach(Jp)}function Or(e,t){e.blockedOn===t&&(e.blockedOn=null,Tu||(Tu=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,Gy)))}var Br=null;function Pp(e){Br!==e&&(Br=e,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){Br===e&&(Br=null);for(var t=0;t<e.length;t+=3){var n=e[t],s=e[t+1],c=e[t+2];if(typeof s!="function"){if(Ru(s||n)===null)continue;break}var u=ul(n);u!==null&&(e.splice(t,3),t-=3,qc(u,{pending:!0,data:c,method:n.method,action:s},s,c))}}))}function Fl(e){function t(D){return Or(D,e)}Ca!==null&&Or(Ca,e),Ea!==null&&Or(Ea,e),ka!==null&&Or(ka,e),Zs.forEach(t),Is.forEach(t);for(var n=0;n<Ma.length;n++){var s=Ma[n];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Ma.length&&(n=Ma[0],n.blockedOn===null);)Ip(n),n.blockedOn===null&&Ma.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(s=0;s<n.length;s+=3){var c=n[s],u=n[s+1],v=c[Be]||null;if(typeof u=="function")v||Pp(n);else if(v){var S=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[Be]||null)S=v.formAction;else if(Ru(c)!==null)continue}else S=v.action;typeof S=="function"?n[s+1]=S:(n.splice(s,3),s-=3),Pp(n)}}}function Wp(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),s||setTimeout(n,20)}function n(){if(!s&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var s=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Du(e){this._internalRoot=e}Lr.prototype.render=Du.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current,s=It();Yp(n,s,e,t,null,null)},Lr.prototype.unmount=Du.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Yp(e.current,2,null,e,null,null),gr(),t[nn]=null}};function Lr(e){this._internalRoot=e}Lr.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ge();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ma.length&&t!==0&&t<Ma[n].priority;n++);Ma.splice(n,0,e),n===0&&Ip(e)}};var e0=l.version;if(e0!=="19.2.0")throw Error(o(527,e0,"19.2.0"));X.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Yy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zr.isDisabled&&zr.supportsFiber)try{vn=zr.inject(Yy),bt=zr}catch{}}return Ws.createRoot=function(e,t){if(!f(e))throw Error(o(299));var n=!1,s="",c=rh,u=oh,v=ch;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=$p(e,1,!1,null,null,n,s,null,c,u,v,Wp),e[nn]=t.current,hu(e),new Du(t)},Ws.hydrateRoot=function(e,t,n){if(!f(e))throw Error(o(299));var s=!1,c="",u=rh,v=oh,S=ch,D=null;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(v=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError),n.formState!==void 0&&(D=n.formState)),t=$p(e,1,!0,t,n??null,s,c,D,u,v,S,Wp),t.context=Gp(null),n=t.current,s=It(),s=Pe(s),c=ha(s),c.callback=null,pa(n,c,s),n=s,t.current.lanes=n,_a(t,n),qn(t),e[nn]=t.current,hu(e),new Lr(t)},Ws.version="19.2.0",Ws}var u0;function tb(){if(u0)return Bu.exports;u0=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Bu.exports=eb(),Bu.exports}var nb=tb();var f0="popstate";function ab(a={}){function l(o,f){let{pathname:d,search:h,hash:p}=o.location;return df("",{pathname:d,search:h,hash:p},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:ui(f)}return sb(l,i,null,a)}function lt(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function wn(a,l){if(!a){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function lb(){return Math.random().toString(36).substring(2,10)}function d0(a,l){return{usr:a.state,key:a.key,idx:l}}function df(a,l,i=null,o){return{pathname:typeof a=="string"?a:a.pathname,search:"",hash:"",...typeof l=="string"?ns(l):l,state:i,key:l&&l.key||o||lb()}}function ui({pathname:a="/",search:l="",hash:i=""}){return l&&l!=="?"&&(a+=l.charAt(0)==="?"?l:"?"+l),i&&i!=="#"&&(a+=i.charAt(0)==="#"?i:"#"+i),a}function ns(a){let l={};if(a){let i=a.indexOf("#");i>=0&&(l.hash=a.substring(i),a=a.substring(0,i));let o=a.indexOf("?");o>=0&&(l.search=a.substring(o),a=a.substring(0,o)),a&&(l.pathname=a)}return l}function sb(a,l,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,p="POP",x=null,g=y();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function y(){return(h.state||{idx:null}).idx}function b(){p="POP";let N=y(),E=N==null?null:N-g;g=N,x&&x({action:p,location:w.location,delta:E})}function j(N,E){p="PUSH";let A=df(w.location,N,E);g=y()+1;let M=d0(A,g),T=w.createHref(A);try{h.pushState(M,"",T)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;f.location.assign(T)}d&&x&&x({action:p,location:w.location,delta:1})}function q(N,E){p="REPLACE";let A=df(w.location,N,E);g=y();let M=d0(A,g),T=w.createHref(A);h.replaceState(M,"",T),d&&x&&x({action:p,location:w.location,delta:0})}function C(N){return ib(N)}let w={get action(){return p},get location(){return a(f,h)},listen(N){if(x)throw new Error("A history only accepts one active listener");return f.addEventListener(f0,b),x=N,()=>{f.removeEventListener(f0,b),x=null}},createHref(N){return l(f,N)},createURL:C,encodeLocation(N){let E=C(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:j,replace:q,go(N){return h.go(N)}};return w}function ib(a,l=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),lt(i,"No window.location.(origin|href) available to create URL");let o=typeof a=="string"?a:ui(a);return o=o.replace(/ $/,"%20"),!l&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function ux(a,l,i="/"){return rb(a,l,i,!1)}function rb(a,l,i,o){let f=typeof l=="string"?ns(l):l,d=sa(f.pathname||"/",i);if(d==null)return null;let h=fx(a);ob(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=yb(d);p=gb(h[x],g,o)}return p}function fx(a,l=[],i=[],o="",f=!1){let d=(h,p,x=f,g)=>{let y={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&x)return;lt(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let b=la([o,y.relativePath]),j=i.concat(y);h.children&&h.children.length>0&&(lt(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),fx(h.children,l,j,b,x)),!(h.path==null&&!h.index)&&l.push({path:b,score:pb(b,h.index),routesMeta:j})};return a.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))d(h,p);else for(let x of dx(h.path))d(h,p,!0,x)}),l}function dx(a){let l=a.split("/");if(l.length===0)return[];let[i,...o]=l,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=dx(o.join("/")),p=[];return p.push(...h.map(x=>x===""?d:[d,x].join("/"))),f&&p.push(...h),p.map(x=>a.startsWith("/")&&x===""?"/":x)}function ob(a){a.sort((l,i)=>l.score!==i.score?i.score-l.score:xb(l.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var cb=/^:[\w-]+$/,ub=3,fb=2,db=1,mb=10,hb=-2,m0=a=>a==="*";function pb(a,l){let i=a.split("/"),o=i.length;return i.some(m0)&&(o+=hb),l&&(o+=fb),i.filter(f=>!m0(f)).reduce((f,d)=>f+(cb.test(d)?ub:d===""?db:mb),o)}function xb(a,l){return a.length===l.length&&a.slice(0,-1).every((o,f)=>o===l[f])?a[a.length-1]-l[l.length-1]:0}function gb(a,l,i=!1){let{routesMeta:o}=a,f={},d="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,y=d==="/"?l:l.slice(d.length)||"/",b=ao({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},y),j=x.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=ao({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},y)),!b)return null;Object.assign(f,b.params),h.push({params:f,pathname:la([d,b.pathname]),pathnameBase:Nb(la([d,b.pathnameBase])),route:j}),b.pathnameBase!=="/"&&(d=la([d,b.pathnameBase]))}return h}function ao(a,l){typeof a=="string"&&(a={path:a,caseSensitive:!1,end:!0});let[i,o]=vb(a.path,a.caseSensitive,a.end),f=l.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),p=f.slice(1);return{params:o.reduce((g,{paramName:y,isOptional:b},j)=>{if(y==="*"){let C=p[j]||"";h=d.slice(0,d.length-C.length).replace(/(.)\/+$/,"$1")}const q=p[j];return b&&!q?g[y]=void 0:g[y]=(q||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:a}}function vb(a,l=!1,i=!0){wn(a==="*"||!a.endsWith("*")||a.endsWith("/*"),`Route path "${a}" will be treated as if it were "${a.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${a.replace(/\*$/,"/*")}".`);let o=[],f="^"+a.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return a.endsWith("*")?(o.push({paramName:"*"}),f+=a==="*"||a==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":a!==""&&a!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,l?void 0:"i"),o]}function yb(a){try{return a.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return wn(!1,`The URL path "${a}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),a}}function sa(a,l){if(l==="/")return a;if(!a.toLowerCase().startsWith(l.toLowerCase()))return null;let i=l.endsWith("/")?l.length-1:l.length,o=a.charAt(i);return o&&o!=="/"?null:a.slice(i)||"/"}var bb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Sb=a=>bb.test(a);function Ab(a,l="/"){let{pathname:i,search:o="",hash:f=""}=typeof a=="string"?ns(a):a,d;if(i)if(Sb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),wn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=h0(i.substring(1),"/"):d=h0(i,l)}else d=l;return{pathname:d,search:wb(o),hash:Cb(f)}}function h0(a,l){let i=l.replace(/\/+$/,"").split("/");return a.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Hu(a,l,i,o){return`Cannot include a '${a}' character in a manually specified \`to.${l}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function jb(a){return a.filter((l,i)=>i===0||l.route.path&&l.route.path.length>0)}function mx(a){let l=jb(a);return l.map((i,o)=>o===l.length-1?i.pathname:i.pathnameBase)}function hx(a,l,i,o=!1){let f;typeof a=="string"?f=ns(a):(f={...a},lt(!f.pathname||!f.pathname.includes("?"),Hu("?","pathname","search",f)),lt(!f.pathname||!f.pathname.includes("#"),Hu("#","pathname","hash",f)),lt(!f.search||!f.search.includes("#"),Hu("#","search","hash",f)));let d=a===""||f.pathname==="",h=d?"/":f.pathname,p;if(h==null)p=i;else{let b=l.length-1;if(!o&&h.startsWith("..")){let j=h.split("/");for(;j[0]==="..";)j.shift(),b-=1;f.pathname=j.join("/")}p=b>=0?l[b]:"/"}let x=Ab(f,p),g=h&&h!=="/"&&h.endsWith("/"),y=(d||h===".")&&i.endsWith("/");return!x.pathname.endsWith("/")&&(g||y)&&(x.pathname+="/"),x}var la=a=>a.join("/").replace(/\/\/+/g,"/"),Nb=a=>a.replace(/\/+$/,"").replace(/^\/*/,"/"),wb=a=>!a||a==="?"?"":a.startsWith("?")?a:"?"+a,Cb=a=>!a||a==="#"?"":a.startsWith("#")?a:"#"+a;function Eb(a){return a!=null&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.internal=="boolean"&&"data"in a}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var px=["POST","PUT","PATCH","DELETE"];new Set(px);var kb=["GET",...px];new Set(kb);var as=m.createContext(null);as.displayName="DataRouter";var mo=m.createContext(null);mo.displayName="DataRouterState";m.createContext(!1);var xx=m.createContext({isTransitioning:!1});xx.displayName="ViewTransition";var Mb=m.createContext(new Map);Mb.displayName="Fetchers";var qb=m.createContext(null);qb.displayName="Await";var _n=m.createContext(null);_n.displayName="Navigation";var yi=m.createContext(null);yi.displayName="Location";var ia=m.createContext({outlet:null,matches:[],isDataRoute:!1});ia.displayName="Route";var Rf=m.createContext(null);Rf.displayName="RouteError";function Rb(a,{relative:l}={}){lt(bi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(_n),{hash:f,pathname:d,search:h}=Si(a,{relative:l}),p=d;return i!=="/"&&(p=d==="/"?i:la([i,d])),o.createHref({pathname:p,search:h,hash:f})}function bi(){return m.useContext(yi)!=null}function sl(){return lt(bi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(yi).location}var gx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function vx(a){m.useContext(_n).static||m.useLayoutEffect(a)}function Tb(){let{isDataRoute:a}=m.useContext(ia);return a?Fb():Db()}function Db(){lt(bi(),"useNavigate() may be used only in the context of a <Router> component.");let a=m.useContext(as),{basename:l,navigator:i}=m.useContext(_n),{matches:o}=m.useContext(ia),{pathname:f}=sl(),d=JSON.stringify(mx(o)),h=m.useRef(!1);return vx(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(wn(h.current,gx),!h.current)return;if(typeof x=="number"){i.go(x);return}let y=hx(x,JSON.parse(d),f,g.relative==="path");a==null&&l!=="/"&&(y.pathname=y.pathname==="/"?l:la([l,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[l,i,d,f,a])}m.createContext(null);function Si(a,{relative:l}={}){let{matches:i}=m.useContext(ia),{pathname:o}=sl(),f=JSON.stringify(mx(i));return m.useMemo(()=>hx(a,JSON.parse(f),o,l==="path"),[a,f,o,l])}function _b(a,l){return yx(a,l)}function yx(a,l,i,o,f){lt(bi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(_n),{matches:h}=m.useContext(ia),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",y=p?p.pathnameBase:"/",b=p&&p.route;{let A=b&&b.path||"";bx(g,!b||A.endsWith("*")||A.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${A}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let j=sl(),q;if(l){let A=typeof l=="string"?ns(l):l;lt(y==="/"||A.pathname?.startsWith(y),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${y}" but pathname "${A.pathname}" was given in the \`location\` prop.`),q=A}else q=j;let C=q.pathname||"/",w=C;if(y!=="/"){let A=y.replace(/^\//,"").split("/");w="/"+C.replace(/^\//,"").split("/").slice(A.length).join("/")}let N=ux(a,{pathname:w});wn(b||N!=null,`No routes matched location "${q.pathname}${q.search}${q.hash}" `),wn(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${q.pathname}${q.search}${q.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 E=Ub(N&&N.map(A=>Object.assign({},A,{params:Object.assign({},x,A.params),pathname:la([y,d.encodeLocation?d.encodeLocation(A.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?y:la([y,d.encodeLocation?d.encodeLocation(A.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathnameBase])})),h,i,o,f);return l&&E?m.createElement(yi.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...q},navigationType:"POP"}},E):E}function Ob(){let a=Yb(),l=Eb(a)?`${a.status} ${a.statusText}`:a instanceof Error?a.message:JSON.stringify(a),i=a instanceof Error?a.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",a),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},l),i?m.createElement("pre",{style:f},i):null,h)}var Bb=m.createElement(Ob,null),Lb=class extends m.Component{constructor(a){super(a),this.state={location:a.location,revalidation:a.revalidation,error:a.error}}static getDerivedStateFromError(a){return{error:a}}static getDerivedStateFromProps(a,l){return l.location!==a.location||l.revalidation!=="idle"&&a.revalidation==="idle"?{error:a.error,location:a.location,revalidation:a.revalidation}:{error:a.error!==void 0?a.error:l.error,location:l.location,revalidation:a.revalidation||l.revalidation}}componentDidCatch(a,l){this.props.onError?this.props.onError(a,l):console.error("React Router caught the following error during render",a)}render(){return this.state.error!==void 0?m.createElement(ia.Provider,{value:this.props.routeContext},m.createElement(Rf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function zb({routeContext:a,match:l,children:i}){let o=m.useContext(as);return o&&o.static&&o.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=l.route.id),m.createElement(ia.Provider,{value:a},i)}function Ub(a,l=[],i=null,o=null,f=null){if(a==null){if(!i)return null;if(i.errors)a=i.matches;else if(l.length===0&&!i.initialized&&i.matches.length>0)a=i.matches;else return null}let d=a,h=i?.errors;if(h!=null){let y=d.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);lt(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,y+1))}let p=!1,x=-1;if(i)for(let y=0;y<d.length;y++){let b=d[y];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(x=y),b.route.id){let{loaderData:j,errors:q}=i,C=b.route.loader&&!j.hasOwnProperty(b.route.id)&&(!q||q[b.route.id]===void 0);if(b.route.lazy||C){p=!0,x>=0?d=d.slice(0,x+1):d=[d[0]];break}}}let g=i&&o?(y,b)=>{o(y,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:b})}:void 0;return d.reduceRight((y,b,j)=>{let q,C=!1,w=null,N=null;i&&(q=h&&b.route.id?h[b.route.id]:void 0,w=b.route.errorElement||Bb,p&&(x<0&&j===0?(bx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,N=null):x===j&&(C=!0,N=b.route.hydrateFallbackElement||null)));let E=l.concat(d.slice(0,j+1)),A=()=>{let M;return q?M=w:C?M=N:b.route.Component?M=m.createElement(b.route.Component,null):b.route.element?M=b.route.element:M=y,m.createElement(zb,{match:b,routeContext:{outlet:y,matches:E,isDataRoute:i!=null},children:M})};return i&&(b.route.ErrorBoundary||b.route.errorElement||j===0)?m.createElement(Lb,{location:i.location,revalidation:i.revalidation,component:w,error:q,children:A(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:g}):A()},null)}function Tf(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hb(a){let l=m.useContext(as);return lt(l,Tf(a)),l}function Vb(a){let l=m.useContext(mo);return lt(l,Tf(a)),l}function $b(a){let l=m.useContext(ia);return lt(l,Tf(a)),l}function Df(a){let l=$b(a),i=l.matches[l.matches.length-1];return lt(i.route.id,`${a} can only be used on routes that contain a unique "id"`),i.route.id}function Gb(){return Df("useRouteId")}function Yb(){let a=m.useContext(Rf),l=Vb("useRouteError"),i=Df("useRouteError");return a!==void 0?a:l.errors?.[i]}function Fb(){let{router:a}=Hb("useNavigate"),l=Df("useNavigate"),i=m.useRef(!1);return vx(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{wn(i.current,gx),i.current&&(typeof f=="number"?a.navigate(f):await a.navigate(f,{fromRouteId:l,...d}))},[a,l])}var p0={};function bx(a,l,i){!l&&!p0[a]&&(p0[a]=!0,wn(!1,i))}m.memo(Xb);function Xb({routes:a,future:l,state:i,unstable_onError:o}){return yx(a,void 0,i,o,l)}function Fr(a){lt(!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 Qb({basename:a="/",children:l=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){lt(!bi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=a.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=ns(i));let{pathname:x="/",search:g="",hash:y="",state:b=null,key:j="default"}=i,q=m.useMemo(()=>{let C=sa(x,h);return C==null?null:{location:{pathname:C,search:g,hash:y,state:b,key:j},navigationType:o}},[h,x,g,y,b,j,o]);return wn(q!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${y}" because it does not start with the basename, so the <Router> won't render anything.`),q==null?null:m.createElement(_n.Provider,{value:p},m.createElement(yi.Provider,{children:l,value:q}))}function Kb({children:a,location:l}){return _b(mf(a),l)}function mf(a,l=[]){let i=[];return m.Children.forEach(a,(o,f)=>{if(!m.isValidElement(o))return;let d=[...l,f];if(o.type===m.Fragment){i.push.apply(i,mf(o.props.children,d));return}lt(o.type===Fr,`[${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>`),lt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=mf(o.props.children,d)),i.push(h)}),i}var Xr="get",Qr="application/x-www-form-urlencoded";function ho(a){return a!=null&&typeof a.tagName=="string"}function Zb(a){return ho(a)&&a.tagName.toLowerCase()==="button"}function Ib(a){return ho(a)&&a.tagName.toLowerCase()==="form"}function Jb(a){return ho(a)&&a.tagName.toLowerCase()==="input"}function Pb(a){return!!(a.metaKey||a.altKey||a.ctrlKey||a.shiftKey)}function Wb(a,l){return a.button===0&&(!l||l==="_self")&&!Pb(a)}var Ur=null;function e1(){if(Ur===null)try{new FormData(document.createElement("form"),0),Ur=!1}catch{Ur=!0}return Ur}var t1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vu(a){return a!=null&&!t1.has(a)?(wn(!1,`"${a}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Qr}"`),null):a}function n1(a,l){let i,o,f,d,h;if(Ib(a)){let p=a.getAttribute("action");o=p?sa(p,l):null,i=a.getAttribute("method")||Xr,f=Vu(a.getAttribute("enctype"))||Qr,d=new FormData(a)}else if(Zb(a)||Jb(a)&&(a.type==="submit"||a.type==="image")){let p=a.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=a.getAttribute("formaction")||p.getAttribute("action");if(o=x?sa(x,l):null,i=a.getAttribute("formmethod")||p.getAttribute("method")||Xr,f=Vu(a.getAttribute("formenctype"))||Vu(p.getAttribute("enctype"))||Qr,d=new FormData(p,a),!e1()){let{name:g,type:y,value:b}=a;if(y==="image"){let j=g?`${g}.`:"";d.append(`${j}x`,"0"),d.append(`${j}y`,"0")}else g&&d.append(g,b)}}else{if(ho(a))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Xr,o=null,f=Qr,h=a}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function _f(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function a1(a,l,i){let o=typeof a=="string"?new URL(a,typeof window>"u"?"server://singlefetch/":window.location.origin):a;return o.pathname==="/"?o.pathname=`_root.${i}`:l&&sa(o.pathname,l)==="/"?o.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function l1(a,l){if(a.id in l)return l[a.id];try{let i=await import(a.module);return l[a.id]=i,i}catch(i){return console.error(`Error loading route module \`${a.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function s1(a){return a==null?!1:a.href==null?a.rel==="preload"&&typeof a.imageSrcSet=="string"&&typeof a.imageSizes=="string":typeof a.rel=="string"&&typeof a.href=="string"}async function i1(a,l,i){let o=await Promise.all(a.map(async f=>{let d=l.routes[f.route.id];if(d){let h=await l1(d,i);return h.links?h.links():[]}return[]}));return u1(o.flat(1).filter(s1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function x0(a,l,i,o,f,d){let h=(x,g)=>i[g]?x.route.id!==i[g].route.id:!0,p=(x,g)=>i[g].pathname!==x.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==x.params["*"];return d==="assets"?l.filter((x,g)=>h(x,g)||p(x,g)):d==="data"?l.filter((x,g)=>{let y=o.routes[x.route.id];if(!y||!y.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(a,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function r1(a,l,{includeHydrateFallback:i}={}){return o1(a.map(o=>{let f=l.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function o1(a){return[...new Set(a)]}function c1(a){let l={},i=Object.keys(a).sort();for(let o of i)l[o]=a[o];return l}function u1(a,l){let i=new Set;return new Set(l),a.reduce((o,f)=>{let d=JSON.stringify(c1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function Sx(){let a=m.useContext(as);return _f(a,"You must render this element inside a <DataRouterContext.Provider> element"),a}function f1(){let a=m.useContext(mo);return _f(a,"You must render this element inside a <DataRouterStateContext.Provider> element"),a}var Of=m.createContext(void 0);Of.displayName="FrameworkContext";function Ax(){let a=m.useContext(Of);return _f(a,"You must render this element inside a <HydratedRouter> element"),a}function d1(a,l){let i=m.useContext(Of),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:y,onTouchStart:b}=l,j=m.useRef(null);m.useEffect(()=>{if(a==="render"&&h(!0),a==="viewport"){let w=E=>{E.forEach(A=>{h(A.isIntersecting)})},N=new IntersectionObserver(w,{threshold:.5});return j.current&&N.observe(j.current),()=>{N.disconnect()}}},[a]),m.useEffect(()=>{if(o){let w=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(w)}}},[o]);let q=()=>{f(!0)},C=()=>{f(!1),h(!1)};return i?a!=="intent"?[d,j,{}]:[d,j,{onFocus:ei(p,q),onBlur:ei(x,C),onMouseEnter:ei(g,q),onMouseLeave:ei(y,C),onTouchStart:ei(b,q)}]:[!1,j,{}]}function ei(a,l){return i=>{a&&a(i),i.defaultPrevented||l(i)}}function m1({page:a,...l}){let{router:i}=Sx(),o=m.useMemo(()=>ux(i.routes,a,i.basename),[i.routes,a,i.basename]);return o?m.createElement(p1,{page:a,matches:o,...l}):null}function h1(a){let{manifest:l,routeModules:i}=Ax(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return i1(a,l,i).then(h=>{d||f(h)}),()=>{d=!0}},[a,l,i]),o}function p1({page:a,matches:l,...i}){let o=sl(),{manifest:f,routeModules:d}=Ax(),{basename:h}=Sx(),{loaderData:p,matches:x}=f1(),g=m.useMemo(()=>x0(a,l,x,f,o,"data"),[a,l,x,f,o]),y=m.useMemo(()=>x0(a,l,x,f,o,"assets"),[a,l,x,f,o]),b=m.useMemo(()=>{if(a===o.pathname+o.search+o.hash)return[];let C=new Set,w=!1;if(l.forEach(E=>{let A=f.routes[E.route.id];!A||!A.hasLoader||(!g.some(M=>M.route.id===E.route.id)&&E.route.id in p&&d[E.route.id]?.shouldRevalidate||A.hasClientLoader?w=!0:C.add(E.route.id))}),C.size===0)return[];let N=a1(a,h,"data");return w&&C.size>0&&N.searchParams.set("_routes",l.filter(E=>C.has(E.route.id)).map(E=>E.route.id).join(",")),[N.pathname+N.search]},[h,p,o,f,g,l,a,d]),j=m.useMemo(()=>r1(y,f),[y,f]),q=h1(y);return m.createElement(m.Fragment,null,b.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...i})),j.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...i})),q.map(({key:C,link:w})=>m.createElement("link",{key:C,nonce:i.nonce,...w})))}function x1(...a){return l=>{a.forEach(i=>{typeof i=="function"?i(l):i!=null&&(i.current=l)})}}var jx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{jx&&(window.__reactRouterVersion="7.9.6")}catch{}function g1({basename:a,children:l,window:i}){let o=m.useRef();o.current==null&&(o.current=ab({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>f.listen(p),[f,p]),m.createElement(Qb,{basename:a,children:l,location:d.location,navigationType:d.action,navigator:f})}var Nx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wx=m.forwardRef(function({onClick:l,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:p,target:x,to:g,preventScrollReset:y,viewTransition:b,...j},q){let{basename:C}=m.useContext(_n),w=typeof g=="string"&&Nx.test(g),N,E=!1;if(typeof g=="string"&&w&&(N=g,jx))try{let L=new URL(window.location.href),V=g.startsWith("//")?new URL(L.protocol+g):new URL(g),K=sa(V.pathname,C);V.origin===L.origin&&K!=null?g=K+V.search+V.hash:E=!0}catch{wn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let A=Rb(g,{relative:f}),[M,T,B]=d1(o,j),Z=S1(g,{replace:h,state:p,target:x,preventScrollReset:y,relative:f,viewTransition:b});function O(L){l&&l(L),L.defaultPrevented||Z(L)}let H=m.createElement("a",{...j,...B,href:N||A,onClick:E||d?l:O,ref:x1(q,T),target:x,"data-discover":!w&&i==="render"?"true":void 0});return M&&!w?m.createElement(m.Fragment,null,H,m.createElement(m1,{page:A})):H});wx.displayName="Link";var v1=m.forwardRef(function({"aria-current":l="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:p,children:x,...g},y){let b=Si(h,{relative:g.relative}),j=sl(),q=m.useContext(mo),{navigator:C,basename:w}=m.useContext(_n),N=q!=null&&C1(b)&&p===!0,E=C.encodeLocation?C.encodeLocation(b).pathname:b.pathname,A=j.pathname,M=q&&q.navigation&&q.navigation.location?q.navigation.location.pathname:null;i||(A=A.toLowerCase(),M=M?M.toLowerCase():null,E=E.toLowerCase()),M&&w&&(M=sa(M,w)||M);const T=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let B=A===E||!f&&A.startsWith(E)&&A.charAt(T)==="/",Z=M!=null&&(M===E||!f&&M.startsWith(E)&&M.charAt(E.length)==="/"),O={isActive:B,isPending:Z,isTransitioning:N},H=B?l:void 0,L;typeof o=="function"?L=o(O):L=[o,B?"active":null,Z?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let V=typeof d=="function"?d(O):d;return m.createElement(wx,{...g,"aria-current":H,className:L,ref:y,style:V,to:h,viewTransition:p},typeof x=="function"?x(O):x)});v1.displayName="NavLink";var y1=m.forwardRef(({discover:a="render",fetcherKey:l,navigate:i,reloadDocument:o,replace:f,state:d,method:h=Xr,action:p,onSubmit:x,relative:g,preventScrollReset:y,viewTransition:b,...j},q)=>{let C=N1(),w=w1(p,{relative:g}),N=h.toLowerCase()==="get"?"get":"post",E=typeof p=="string"&&Nx.test(p),A=M=>{if(x&&x(M),M.defaultPrevented)return;M.preventDefault();let T=M.nativeEvent.submitter,B=T?.getAttribute("formmethod")||h;C(T||M.currentTarget,{fetcherKey:l,method:B,navigate:i,replace:f,state:d,relative:g,preventScrollReset:y,viewTransition:b})};return m.createElement("form",{ref:q,method:N,action:w,onSubmit:o?x:A,...j,"data-discover":!E&&a==="render"?"true":void 0})});y1.displayName="Form";function b1(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Cx(a){let l=m.useContext(as);return lt(l,b1(a)),l}function S1(a,{target:l,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let p=Tb(),x=sl(),g=Si(a,{relative:d});return m.useCallback(y=>{if(Wb(y,l)){y.preventDefault();let b=i!==void 0?i:ui(x)===ui(g);p(a,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[x,p,g,i,o,l,a,f,d,h])}var A1=0,j1=()=>`__${String(++A1)}__`;function N1(){let{router:a}=Cx("useSubmit"),{basename:l}=m.useContext(_n),i=Gb();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:p,formData:x,body:g}=n1(o,l);if(f.navigate===!1){let y=f.fetcherKey||j1();await a.fetch(y,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,flushSync:f.flushSync})}else await a.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[a,l,i])}function w1(a,{relative:l}={}){let{basename:i}=m.useContext(_n),o=m.useContext(ia);lt(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...Si(a||".",{relative:l})},h=sl();if(a==null){d.search=h.search;let p=new URLSearchParams(d.search),x=p.getAll("index");if(x.some(y=>y==="")){p.delete("index"),x.filter(b=>b).forEach(b=>p.append("index",b));let y=p.toString();d.search=y?`?${y}`:""}}return(!a||a===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:la([i,d.pathname])),ui(d)}function C1(a,{relative:l}={}){let i=m.useContext(xx);lt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Cx("useViewTransitionState"),f=Si(a,{relative:l});if(!i.isTransitioning)return!1;let d=sa(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=sa(i.nextLocation.pathname,o)||i.nextLocation.pathname;return ao(f.pathname,h)!=null||ao(f.pathname,d)!=null}const Dn=Object.create(null);Dn.open="0";Dn.close="1";Dn.ping="2";Dn.pong="3";Dn.message="4";Dn.upgrade="5";Dn.noop="6";const Kr=Object.create(null);Object.keys(Dn).forEach(a=>{Kr[Dn[a]]=a});const hf={type:"error",data:"parser error"},Ex=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",kx=typeof ArrayBuffer=="function",Mx=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a&&a.buffer instanceof ArrayBuffer,Bf=({type:a,data:l},i,o)=>Ex&&l instanceof Blob?i?o(l):g0(l,o):kx&&(l instanceof ArrayBuffer||Mx(l))?i?o(l):g0(new Blob([l]),o):o(Dn[a]+(l||"")),g0=(a,l)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];l("b"+(o||""))},i.readAsDataURL(a)};function v0(a){return a instanceof Uint8Array?a:a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}let $u;function E1(a,l){if(Ex&&a.data instanceof Blob)return a.data.arrayBuffer().then(v0).then(l);if(kx&&(a.data instanceof ArrayBuffer||Mx(a.data)))return l(v0(a.data));Bf(a,!1,i=>{$u||($u=new TextEncoder),l($u.encode(i))})}const y0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ii=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let a=0;a<y0.length;a++)ii[y0.charCodeAt(a)]=a;const k1=a=>{let l=a.length*.75,i=a.length,o,f=0,d,h,p,x;a[a.length-1]==="="&&(l--,a[a.length-2]==="="&&l--);const g=new ArrayBuffer(l),y=new Uint8Array(g);for(o=0;o<i;o+=4)d=ii[a.charCodeAt(o)],h=ii[a.charCodeAt(o+1)],p=ii[a.charCodeAt(o+2)],x=ii[a.charCodeAt(o+3)],y[f++]=d<<2|h>>4,y[f++]=(h&15)<<4|p>>2,y[f++]=(p&3)<<6|x&63;return g},M1=typeof ArrayBuffer=="function",Lf=(a,l)=>{if(typeof a!="string")return{type:"message",data:qx(a,l)};const i=a.charAt(0);return i==="b"?{type:"message",data:q1(a.substring(1),l)}:Kr[i]?a.length>1?{type:Kr[i],data:a.substring(1)}:{type:Kr[i]}:hf},q1=(a,l)=>{if(M1){const i=k1(a);return qx(i,l)}else return{base64:!0,data:a}},qx=(a,l)=>{switch(l){case"blob":return a instanceof Blob?a:new Blob([a]);case"arraybuffer":default:return a instanceof ArrayBuffer?a:a.buffer}},Rx="",R1=(a,l)=>{const i=a.length,o=new Array(i);let f=0;a.forEach((d,h)=>{Bf(d,!1,p=>{o[h]=p,++f===i&&l(o.join(Rx))})})},T1=(a,l)=>{const i=a.split(Rx),o=[];for(let f=0;f<i.length;f++){const d=Lf(i[f],l);if(o.push(d),d.type==="error")break}return o};function D1(){return new TransformStream({transform(a,l){E1(a,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}a.data&&typeof a.data!="string"&&(f[0]|=128),l.enqueue(f),l.enqueue(i)})}})}let Gu;function Hr(a){return a.reduce((l,i)=>l+i.length,0)}function Vr(a,l){if(a[0].length===l)return a.shift();const i=new Uint8Array(l);let o=0;for(let f=0;f<l;f++)i[f]=a[0][o++],o===a[0].length&&(a.shift(),o=0);return a.length&&o<a[0].length&&(a[0]=a[0].slice(o)),i}function _1(a,l){Gu||(Gu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,p){for(i.push(h);;){if(o===0){if(Hr(i)<1)break;const x=Vr(i,1);d=(x[0]&128)===128,f=x[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if(Hr(i)<2)break;const x=Vr(i,2);f=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Hr(i)<8)break;const x=Vr(i,8),g=new DataView(x.buffer,x.byteOffset,x.length),y=g.getUint32(0);if(y>Math.pow(2,21)-1){p.enqueue(hf);break}f=y*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Hr(i)<f)break;const x=Vr(i,f);p.enqueue(Lf(d?x:Gu.decode(x),l)),o=0}if(f===0||f>a){p.enqueue(hf);break}}}})}const Tx=4;function gt(a){if(a)return O1(a)}function O1(a){for(var l in gt.prototype)a[l]=gt.prototype[l];return a}gt.prototype.on=gt.prototype.addEventListener=function(a,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(l),this};gt.prototype.once=function(a,l){function i(){this.off(a,i),l.apply(this,arguments)}return i.fn=l,this.on(a,i),this};gt.prototype.off=gt.prototype.removeListener=gt.prototype.removeAllListeners=gt.prototype.removeEventListener=function(a,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+a];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+a],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===l||o.fn===l){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+a],this};gt.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),i=this._callbacks["$"+a],o=1;o<arguments.length;o++)l[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,l)}return this};gt.prototype.emitReserved=gt.prototype.emit;gt.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]};gt.prototype.hasListeners=function(a){return!!this.listeners(a).length};const po=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,i)=>i(l,0),xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),B1="arraybuffer";function Dx(a,...l){return l.reduce((i,o)=>(a.hasOwnProperty(o)&&(i[o]=a[o]),i),{})}const L1=xn.setTimeout,z1=xn.clearTimeout;function xo(a,l){l.useNativeTimers?(a.setTimeoutFn=L1.bind(xn),a.clearTimeoutFn=z1.bind(xn)):(a.setTimeoutFn=xn.setTimeout.bind(xn),a.clearTimeoutFn=xn.clearTimeout.bind(xn))}const U1=1.33;function H1(a){return typeof a=="string"?V1(a):Math.ceil((a.byteLength||a.size)*U1)}function V1(a){let l=0,i=0;for(let o=0,f=a.length;o<f;o++)l=a.charCodeAt(o),l<128?i+=1:l<2048?i+=2:l<55296||l>=57344?i+=3:(o++,i+=4);return i}function _x(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $1(a){let l="";for(let i in a)a.hasOwnProperty(i)&&(l.length&&(l+="&"),l+=encodeURIComponent(i)+"="+encodeURIComponent(a[i]));return l}function G1(a){let l={},i=a.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");l[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return l}class Y1 extends Error{constructor(l,i,o){super(l),this.description=i,this.context=o,this.type="TransportError"}}class zf extends gt{constructor(l){super(),this.writable=!1,xo(this,l),this.opts=l,this.query=l.query,this.socket=l.socket,this.supportsBinary=!l.forceBase64}onError(l,i,o){return super.emitReserved("error",new Y1(l,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(l){this.readyState==="open"&&this.write(l)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(l){const i=Lf(l,this.socket.binaryType);this.onPacket(i)}onPacket(l){super.emitReserved("packet",l)}onClose(l){this.readyState="closed",super.emitReserved("close",l)}pause(l){}createUri(l,i={}){return l+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const l=this.opts.hostname;return l.indexOf(":")===-1?l:"["+l+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(l){const i=$1(l);return i.length?"?"+i:""}}class F1 extends zf{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(l){this.readyState="pausing";const i=()=>{this.readyState="paused",l()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(l){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};T1(l,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const l=()=>{this.write([{type:"close"}])};this.readyState==="open"?l():this.once("open",l)}write(l){this.writable=!1,R1(l,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const l=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=_x()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(l,i)}}let Ox=!1;try{Ox=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const X1=Ox;function Q1(){}class K1 extends F1{constructor(l){if(super(l),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||o!==l.port}}doWrite(l,i){const o=this.request({method:"POST",data:l});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=l}}class Tn extends gt{constructor(l,i,o){super(),this.createRequest=l,xo(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var l;const i=Dx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(l=this._opts.cookieJar)===null||l===void 0||l.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=Tn.requestsCount++,Tn.requests[this._index]=this)}_onError(l){this.emitReserved("error",l,this._xhr),this._cleanup(!0)}_cleanup(l){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Q1,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Tn.requests[this._index],this._xhr=null}}_onLoad(){const l=this._xhr.responseText;l!==null&&(this.emitReserved("data",l),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Tn.requestsCount=0;Tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",b0);else if(typeof addEventListener=="function"){const a="onpagehide"in xn?"pagehide":"unload";addEventListener(a,b0,!1)}}function b0(){for(let a in Tn.requests)Tn.requests.hasOwnProperty(a)&&Tn.requests[a].abort()}const Z1=(function(){const a=Bx({xdomain:!1});return a&&a.responseType!==null})();class I1 extends K1{constructor(l){super(l);const i=l&&l.forceBase64;this.supportsBinary=Z1&&!i}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new Tn(Bx,this.uri(),l)}}function Bx(a){const l=a.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||X1))return new XMLHttpRequest}catch{}if(!l)try{return new xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Lx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class J1 extends zf{get name(){return"websocket"}doOpen(){const l=this.uri(),i=this.opts.protocols,o=Lx?{}:Dx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(l,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=l=>this.onClose({description:"websocket connection closed",context:l}),this.ws.onmessage=l=>this.onData(l.data),this.ws.onerror=l=>this.onError("websocket error",l)}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;Bf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&po(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const l=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=_x()),this.supportsBinary||(i.b64=1),this.createUri(l,i)}}const Yu=xn.WebSocket||xn.MozWebSocket;class P1 extends J1{createSocket(l,i,o){return Lx?new Yu(l,i,o):i?new Yu(l,i):new Yu(l)}doWrite(l,i){this.ws.send(i)}}class W1 extends zf{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(l){return this.emitReserved("error",l)}this._transport.closed.then(()=>{this.onClose()}).catch(l=>{this.onError("webtransport error",l)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(l=>{const i=_1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=l.readable.pipeThrough(i).getReader(),f=D1();f.readable.pipeTo(l.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),d())}).catch(p=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;this._writer.write(o).then(()=>{f&&po(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const eS={websocket:P1,webtransport:W1,polling:I1},tS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,nS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function pf(a){if(a.length>8e3)throw"URI too long";const l=a,i=a.indexOf("["),o=a.indexOf("]");i!=-1&&o!=-1&&(a=a.substring(0,i)+a.substring(i,o).replace(/:/g,";")+a.substring(o,a.length));let f=tS.exec(a||""),d={},h=14;for(;h--;)d[nS[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=l,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=aS(d,d.path),d.queryKey=lS(d,d.query),d}function aS(a,l){const i=/\/{2,9}/g,o=l.replace(i,"/").split("/");return(l.slice(0,1)=="/"||l.length===0)&&o.splice(0,1),l.slice(-1)=="/"&&o.splice(o.length-1,1),o}function lS(a,l){const i={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const xf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Zr=[];xf&&addEventListener("offline",()=>{Zr.forEach(a=>a())},!1);class Ta extends gt{constructor(l,i){if(super(),this.binaryType=B1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,l&&typeof l=="object"&&(i=l,l=null),l){const o=pf(l);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=pf(i.host).host);xo(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=G1(this.opts.query)),xf&&(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"})},Zr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const i=Object.assign({},this.opts.query);i.EIO=Tx,i.transport=l,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[l]);return new this._transportsByName[l](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const l=this.opts.rememberUpgrade&&Ta.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(l);i.open(),this.setTransport(i)}setTransport(l){this.transport&&this.transport.removeAllListeners(),this.transport=l,l.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",Ta.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(l){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",l),this.emitReserved("heartbeat"),l.type){case"open":this.onHandshake(JSON.parse(l.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=l.data,this._onError(i);break;case"message":this.emitReserved("data",l.data),this.emitReserved("message",l.data);break}}onHandshake(l){this.emitReserved("handshake",l),this.id=l.sid,this.transport.query.sid=l.sid,this._pingInterval=l.pingInterval,this._pingTimeout=l.pingTimeout,this._maxPayload=l.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const l=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+l,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},l),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const l=this._getWritablePackets();this.transport.send(l),this._prevBufferLen=l.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=H1(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const l=Date.now()>this._pingTimeoutTime;return l&&(this._pingTimeoutTime=0,po(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),l}write(l,i,o){return this._sendPacket("message",l,i,o),this}send(l,i,o){return this._sendPacket("message",l,i,o),this}_sendPacket(l,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:l,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const l=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),l()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():l()}):this.upgrading?o():l()),this}_onError(l){if(Ta.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",l),this._onClose("transport error",l)}_onClose(l,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Zr.indexOf(this._offlineEventListener);o!==-1&&Zr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,i),this.writeBuffer=[],this._prevBufferLen=0}}}Ta.protocol=Tx;class sS extends Ta{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let l=0;l<this._upgrades.length;l++)this._probe(this._upgrades[l])}_probe(l){let i=this.createTransport(l),o=!1;Ta.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;Ta.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const j=new Error("probe error");j.transport=i.name,this.emitReserved("upgradeError",j)}}))};function d(){o||(o=!0,y(),i.close(),i=null)}const h=b=>{const j=new Error("probe error: "+b);j.transport=i.name,d(),this.emitReserved("upgradeError",j)};function p(){h("transport closed")}function x(){h("socket closed")}function g(b){i&&b.name!==i.name&&d()}const y=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&l!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(l){this._upgrades=this._filterUpgrades(l.upgrades),super.onHandshake(l)}_filterUpgrades(l){const i=[];for(let o=0;o<l.length;o++)~this.transports.indexOf(l[o])&&i.push(l[o]);return i}}let iS=class extends sS{constructor(l,i={}){const o=typeof l=="object"?l:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>eS[f]).filter(f=>!!f)),super(l,o)}};function rS(a,l="",i){let o=a;i=i||typeof location<"u"&&location,a==null&&(a=i.protocol+"//"+i.host),typeof a=="string"&&(a.charAt(0)==="/"&&(a.charAt(1)==="/"?a=i.protocol+a:a=i.host+a),/^(https?|wss?):\/\//.test(a)||(typeof i<"u"?a=i.protocol+"//"+a:a="https://"+a),o=pf(a)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+l,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const oS=typeof ArrayBuffer=="function",cS=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a.buffer instanceof ArrayBuffer,zx=Object.prototype.toString,uS=typeof Blob=="function"||typeof Blob<"u"&&zx.call(Blob)==="[object BlobConstructor]",fS=typeof File=="function"||typeof File<"u"&&zx.call(File)==="[object FileConstructor]";function Uf(a){return oS&&(a instanceof ArrayBuffer||cS(a))||uS&&a instanceof Blob||fS&&a instanceof File}function Ir(a,l){if(!a||typeof a!="object")return!1;if(Array.isArray(a)){for(let i=0,o=a.length;i<o;i++)if(Ir(a[i]))return!0;return!1}if(Uf(a))return!0;if(a.toJSON&&typeof a.toJSON=="function"&&arguments.length===1)return Ir(a.toJSON(),!0);for(const i in a)if(Object.prototype.hasOwnProperty.call(a,i)&&Ir(a[i]))return!0;return!1}function dS(a){const l=[],i=a.data,o=a;return o.data=gf(i,l),o.attachments=l.length,{packet:o,buffers:l}}function gf(a,l){if(!a)return a;if(Uf(a)){const i={_placeholder:!0,num:l.length};return l.push(a),i}else if(Array.isArray(a)){const i=new Array(a.length);for(let o=0;o<a.length;o++)i[o]=gf(a[o],l);return i}else if(typeof a=="object"&&!(a instanceof Date)){const i={};for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=gf(a[o],l));return i}return a}function mS(a,l){return a.data=vf(a.data,l),delete a.attachments,a}function vf(a,l){if(!a)return a;if(a&&a._placeholder===!0){if(typeof a.num=="number"&&a.num>=0&&a.num<l.length)return l[a.num];throw new Error("illegal attachments")}else if(Array.isArray(a))for(let i=0;i<a.length;i++)a[i]=vf(a[i],l);else if(typeof a=="object")for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&(a[i]=vf(a[i],l));return a}const hS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],pS=5;var De;(function(a){a[a.CONNECT=0]="CONNECT",a[a.DISCONNECT=1]="DISCONNECT",a[a.EVENT=2]="EVENT",a[a.ACK=3]="ACK",a[a.CONNECT_ERROR=4]="CONNECT_ERROR",a[a.BINARY_EVENT=5]="BINARY_EVENT",a[a.BINARY_ACK=6]="BINARY_ACK"})(De||(De={}));class xS{constructor(l){this.replacer=l}encode(l){return(l.type===De.EVENT||l.type===De.ACK)&&Ir(l)?this.encodeAsBinary({type:l.type===De.EVENT?De.BINARY_EVENT:De.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let i=""+l.type;return(l.type===De.BINARY_EVENT||l.type===De.BINARY_ACK)&&(i+=l.attachments+"-"),l.nsp&&l.nsp!=="/"&&(i+=l.nsp+","),l.id!=null&&(i+=l.id),l.data!=null&&(i+=JSON.stringify(l.data,this.replacer)),i}encodeAsBinary(l){const i=dS(l),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function S0(a){return Object.prototype.toString.call(a)==="[object Object]"}class Hf extends gt{constructor(l){super(),this.reviver=l}add(l){let i;if(typeof l=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(l);const o=i.type===De.BINARY_EVENT;o||i.type===De.BINARY_ACK?(i.type=o?De.EVENT:De.ACK,this.reconstructor=new gS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Uf(l)||l.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(l),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+l)}decodeString(l){let i=0;const o={type:Number(l.charAt(0))};if(De[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===De.BINARY_EVENT||o.type===De.BINARY_ACK){const d=i+1;for(;l.charAt(++i)!=="-"&&i!=l.length;);const h=l.substring(d,i);if(h!=Number(h)||l.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(l.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(l.charAt(i)===","||i===l.length););o.nsp=l.substring(d,i)}else o.nsp="/";const f=l.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=l.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===l.length)break}o.id=Number(l.substring(d,i+1))}if(l.charAt(++i)){const d=this.tryParse(l.substr(i));if(Hf.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(l){try{return JSON.parse(l,this.reviver)}catch{return!1}}static isPayloadValid(l,i){switch(l){case De.CONNECT:return S0(i);case De.DISCONNECT:return i===void 0;case De.CONNECT_ERROR:return typeof i=="string"||S0(i);case De.EVENT:case De.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&hS.indexOf(i[0])===-1);case De.ACK:case De.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class gS{constructor(l){this.packet=l,this.buffers=[],this.reconPack=l}takeBinaryData(l){if(this.buffers.push(l),this.buffers.length===this.reconPack.attachments){const i=mS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const vS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Hf,Encoder:xS,get PacketType(){return De},protocol:pS},Symbol.toStringTag,{value:"Module"}));function jn(a,l,i){return a.on(l,i),function(){a.off(l,i)}}const yS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ux extends gt{constructor(l,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=l,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const l=this.io;this.subs=[jn(l,"open",this.onopen.bind(this)),jn(l,"packet",this.onpacket.bind(this)),jn(l,"error",this.onerror.bind(this)),jn(l,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...l){return l.unshift("message"),this.emit.apply(this,l),this}emit(l,...i){var o,f,d;if(yS.hasOwnProperty(l))throw new Error('"'+l.toString()+'" is a reserved event name');if(i.unshift(l),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:De.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,b=i.pop();this._registerAckCallback(y,b),h.id=y}const p=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,x=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(l,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[l]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[l];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===l&&this.sendBuffer.splice(p,1);i.call(this,new Error("operation has timed out"))},f),h=(...p)=>{this.io.clearTimeoutFn(d),i.apply(this,p)};h.withError=!0,this.acks[l]=h}emitWithAck(l,...i){return new Promise((o,f)=>{const d=(h,p)=>h?f(h):o(p);d.withError=!0,i.push(d),this.emit(l,...i)})}_addToQueue(l){let i;typeof l[l.length-1]=="function"&&(i=l.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:l,flags:Object.assign({fromQueue:!0},this.flags)};l.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(l=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!l||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(l){l.nsp=this.nsp,this.io._packet(l)}onopen(){typeof this.auth=="function"?this.auth(l=>{this._sendConnectPacket(l)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(l){this.packet({type:De.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},l):l})}onerror(l){this.connected||this.emitReserved("connect_error",l)}onclose(l,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",l,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(l=>{if(!this.sendBuffer.some(o=>String(o.id)===l)){const o=this.acks[l];delete this.acks[l],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(l){if(l.nsp===this.nsp)switch(l.type){case De.CONNECT:l.data&&l.data.sid?this.onconnect(l.data.sid,l.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case De.EVENT:case De.BINARY_EVENT:this.onevent(l);break;case De.ACK:case De.BINARY_ACK:this.onack(l);break;case De.DISCONNECT:this.ondisconnect();break;case De.CONNECT_ERROR:this.destroy();const o=new Error(l.data.message);o.data=l.data.data,this.emitReserved("connect_error",o);break}}onevent(l){const i=l.data||[];l.id!=null&&i.push(this.ack(l.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(l){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)o.apply(this,l)}super.emit.apply(this,l),this._pid&&l.length&&typeof l[l.length-1]=="string"&&(this._lastOffset=l[l.length-1])}ack(l){const i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:De.ACK,id:l,data:f}))}}onack(l){const i=this.acks[l.id];typeof i=="function"&&(delete this.acks[l.id],i.withError&&l.data.unshift(null),i.apply(this,l.data))}onconnect(l,i){this.id=l,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(l=>this.emitEvent(l)),this.receiveBuffer=[],this.sendBuffer.forEach(l=>{this.notifyOutgoingListeners(l),this.packet(l)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(l=>l()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:De.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(l){return this.flags.compress=l,this}get volatile(){return this.flags.volatile=!0,this}timeout(l){return this.flags.timeout=l,this}onAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(l),this}prependAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(l),this}offAny(l){if(!this._anyListeners)return this;if(l){const i=this._anyListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(l),this}prependAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(l),this}offAnyOutgoing(l){if(!this._anyOutgoingListeners)return this;if(l){const i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(l){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,l.data)}}}function ls(a){a=a||{},this.ms=a.min||100,this.max=a.max||1e4,this.factor=a.factor||2,this.jitter=a.jitter>0&&a.jitter<=1?a.jitter:0,this.attempts=0}ls.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),i=Math.floor(l*this.jitter*a);a=(Math.floor(l*10)&1)==0?a-i:a+i}return Math.min(a,this.max)|0};ls.prototype.reset=function(){this.attempts=0};ls.prototype.setMin=function(a){this.ms=a};ls.prototype.setMax=function(a){this.max=a};ls.prototype.setJitter=function(a){this.jitter=a};class yf extends gt{constructor(l,i){var o;super(),this.nsps={},this.subs=[],l&&typeof l=="object"&&(i=l,l=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,xo(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new ls({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=l;const f=i.parser||vS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(l){return arguments.length?(this._reconnection=!!l,l||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(l){return l===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=l,this)}reconnectionDelay(l){var i;return l===void 0?this._reconnectionDelay:(this._reconnectionDelay=l,(i=this.backoff)===null||i===void 0||i.setMin(l),this)}randomizationFactor(l){var i;return l===void 0?this._randomizationFactor:(this._randomizationFactor=l,(i=this.backoff)===null||i===void 0||i.setJitter(l),this)}reconnectionDelayMax(l){var i;return l===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=l,(i=this.backoff)===null||i===void 0||i.setMax(l),this)}timeout(l){return arguments.length?(this._timeout=l,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(l){if(~this._readyState.indexOf("open"))return this;this.engine=new iS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=jn(i,"open",function(){o.onopen(),l&&l()}),d=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),l?l(p):this.maybeReconnectOnOpen()},h=jn(i,"error",d);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(f),this.subs.push(h),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(jn(l,"ping",this.onping.bind(this)),jn(l,"data",this.ondata.bind(this)),jn(l,"error",this.onerror.bind(this)),jn(l,"close",this.onclose.bind(this)),jn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(l){try{this.decoder.add(l)}catch(i){this.onclose("parse error",i)}}ondecoded(l){po(()=>{this.emitReserved("packet",l)},this.setTimeoutFn)}onerror(l){this.emitReserved("error",l)}socket(l,i){let o=this.nsps[l];return o?this._autoConnect&&!o.active&&o.connect():(o=new Ux(this,l,i),this.nsps[l]=o),o}_destroy(l){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(l){const i=this.encoder.encode(l);for(let o=0;o<i.length;o++)this.engine.write(i[o],l.options)}cleanup(){this.subs.forEach(l=>l()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(l,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",l,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const l=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{l.skipReconnect||(this.emitReserved("reconnect_attempt",l.backoff.attempts),!l.skipReconnect&&l.open(f=>{f?(l._reconnecting=!1,l.reconnect(),this.emitReserved("reconnect_error",f)):l.onreconnect()}))},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const l=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",l)}}const ti={};function Jr(a,l){typeof a=="object"&&(l=a,a=void 0),l=l||{};const i=rS(a,l.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=ti[f]&&d in ti[f].nsps,p=l.forceNew||l["force new connection"]||l.multiplex===!1||h;let x;return p?x=new yf(o,l):(ti[f]||(ti[f]=new yf(o,l)),x=ti[f]),i.query&&!l.query&&(l.query=i.queryKey),x.socket(i.path,l)}Object.assign(Jr,{Manager:yf,Socket:Ux,io:Jr,connect:Jr});const Hx="roverSettings",bS=3600*24*365;function SS(a){try{const l=decodeURIComponent(a??"");return JSON.parse(l)}catch(l){return console.warn("Failed to parse settings cookie",l),null}}function bf(){if(typeof document>"u")return{};const a=`${Hx}=`,l=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(a));if(!l)return{};const i=l.substring(a.length);return SS(i)??{}}function A0(a){if(typeof document>"u")return!1;try{const l=encodeURIComponent(JSON.stringify(a??{})),i=`${Hx}=${l}; path=/; max-age=${bS}; samesite=strict`;return document.cookie=i,!0}catch(l){return console.warn("Failed to write settings cookie",l),!1}}const Vx=window.location.origin;console.info("[socket] connecting to",Vx);const AS=bf(),jS=AS?.page?.connectionTransport||"websocket",NS=jS==="polling"?["polling"]:["websocket","polling"],Vf=Jr(Vx,{transports:NS,timeout:15e3});Vf.on("connect_error",a=>console.error("connect_error",a.code,a.message,a.data));const $x=m.createContext(Vf),wS=({children:a})=>r.jsx($x.Provider,{value:Vf,children:a}),On=()=>m.useContext($x),Gx=m.createContext({connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,identifySession:async()=>{},login:async()=>{},setRole:async()=>{},requestControl:async()=>{},releaseControl:async()=>{},subscribeAll:async()=>{},homeAssistantToggle:async()=>{},homeAssistantSetState:async()=>{},homeAssistantSetLightColor:async()=>{},setNickname:async()=>{},requestVerification:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},startMicWhip:async()=>{},readyMicWhip:async()=>{},stopMicWhip:async()=>{},setAudioLevels:async()=>{},llmControl:async()=>{}});function CS(a){return m.useCallback((l,i={})=>new Promise((o,f)=>{a.emit(l,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[a])}function ES({children:a}){const l=On(),i=CS(l),[o,f]=m.useState(null),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(null),[b,j]=m.useState(null),[q,C]=m.useState([]),[w,N]=m.useState(l.connected);m.useEffect(()=>{const M=()=>N(!0),T=()=>N(!1);return l.on("connect",M),l.on("disconnect",T),()=>{l.off("connect",M),l.off("disconnect",T)}},[l]),m.useEffect(()=>{function M(L){f(L)}function T(L=[]){h(L)}function B(L){h(V=>[...V.slice(-199),L])}function Z(L=[]){x(L)}function O(L){x(V=>[...V.slice(-199),L])}function H(L=null){const V=L&&typeof L=="object"?L:null,K=V?.debug?.status&&typeof V.debug.status=="object"?V.debug.status:null;y(V),j(K)}return l.on("session:sync",M),l.on("log:init",T),l.on("log:entry",B),l.on("adminlog:init",Z),l.on("adminlog:entry",O),l.on("llm:state",H),l.on("alert:new",(L={})=>{C(V=>[...V.slice(-49),{...L,receivedAt:Date.now()}])}),()=>{l.off("session:sync",M),l.off("log:init",T),l.off("log:entry",B),l.off("adminlog:init",Z),l.off("adminlog:entry",O),l.off("llm:state",H),l.off("alert:new")}},[l]);const E=m.useMemo(()=>({login:(M,T)=>i("auth:login",{username:M,password:T}),identifySession:({cookieUserId:M,nickname:T}={})=>i("session:identify",{cookieUserId:M,nickname:T}),setRole:M=>i("session:setRole",{role:M}),requestControl:(M,T={})=>i("session:requestControl",{roverId:M,...T}),releaseControl:M=>i("session:releaseControl",{roverId:M}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(M,T)=>i("session:lockRover",{roverId:M,locked:T}),setMode:M=>i("setMode",{mode:M}),homeAssistantToggle:M=>i("homeAssistant:toggle",{entityId:M}),homeAssistantSetState:(M,T)=>i("homeAssistant:setState",{entityId:M,state:T}),homeAssistantSetLightColor:(M,T)=>i("homeAssistant:lightColor",{entityId:M,rgbColor:T}),setNickname:M=>i("nickname:set",{nickname:M}),requestVerification:()=>i("verification:request"),triggerReplay:(M=[])=>i("replay:trigger",{sources:M}),setCommunityGoal:M=>i("communityGoal:set",{text:M}),setAdminReason:M=>i("adminReason:set",{text:M}),rebootRover:M=>i("command",{roverId:M,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:M,name:T,mime:B,dataBase64:Z})=>i("audio:uploadPlay",{roverId:M,name:T,mime:B,dataBase64:Z}),stopUploadedAudio:M=>i("audio:uploadStop",{roverId:M}),startMicWhip:M=>i("audio:micWhipStart",{roverId:M}),readyMicWhip:M=>i("audio:micWhipReady",{roverId:M}),stopMicWhip:M=>i("audio:micWhipStop",{roverId:M}),setAudioLevels:(M={})=>i("audioLevels:set",M),llmControl:(M,T={})=>i("llm:control",{controls:{action:M,...T}}),pushAlert:M=>C(T=>[...T.slice(-49),{...M,receivedAt:Date.now(),id:M.id||Math.random().toString(36).slice(2)}])}),[i]),A=m.useMemo(()=>({connected:w,session:o,logs:d,adminLogs:p,llmCommentaryState:g,llmCommentaryStatus:b,alerts:q,...E}),[E,p,q,w,g,b,d,o]);return r.jsx(Gx.Provider,{value:A,children:a})}function _e(){return m.useContext(Gx)}const Yx=m.createContext({frames:{}});function kS({children:a}){const l=On(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:p={},frame:x={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:p,raw:x?.data||null,receivedAt:Date.now()}}))}return l.on("sensorFrame",d),()=>{l.off("sensorFrame",d)}},[l]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(Yx.Provider,{value:f,children:a})}function $f(){return m.useContext(Yx).frames}function ss(a){const l=$f();return a?l[a]??null:null}const MS=650,qS={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 Fu(a){if(typeof a!="number"||a<=0)return null;const l=qS[a];return l?{code:a,...l}:null}function RS(a,l={}){const i=l.holdMs||MS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(p)},[i]),m.useEffect(()=>{const p=Date.now(),x=Fu(a?.infraredCharacterLeft),g=Fu(a?.infraredCharacterRight),y=Fu(a?.infraredCharacterOmni);!x&&!g&&!y||f(b=>({left:x?{...x,ts:p}:b.left,right:g?{...g,ts:p}:b.right,omni:y?{...y,ts:p}:b.omni}))},[a?.infraredCharacterLeft,a?.infraredCharacterRight,a?.infraredCharacterOmni]),m.useEffect(()=>{const{left:p,right:x,omni:g}=o;if(!(p?.ts||x?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:p?.code??0,omni:g?.code??0,right:x?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const p=Date.now(),x=N=>{if(!N)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const E=p-N.ts,A=E<=i;return{active:A,age:E,code:N.code,red:!!(N.red&&A),green:!!(N.green&&A),force:!!(N.force&&A)}},g=x(o.left),y=x(o.right),b=x(o.omni),j=g.force||y.force||b.force,q=g.active||y.active||b.active,C=g.active&&!y.active?"right":y.active&&!g.active?"left":"center",w=(y.active?1:0)-(g.active?1:0);return{visible:q,forceDetected:j,left:g,right:y,omni:b,bias:C,balance:Math.max(-1,Math.min(1,w))}},[o.left,o.right,o.omni,i,d])}function TS(){const{connected:a,session:l}=_e(),i=l?.assignment?.roverId,o=ss(i),f=o?.sensors||{},d=RS(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,p=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,g=f.batteryChargeMah,y=f.batteryCapacityMah;o?.receivedAt&&new Date(o.receivedAt).toLocaleTimeString();const b=o?.raw?o.raw:null,j=i?l?.activeDrivers?.[i]:null;return m.useMemo(()=>i?j?j===l?.socketId?"You":(l?.users||[]).find(C=>C.socketId===j)?.nickname||j.slice(0,6):"Available":"n/a",[j,i,l?.socketId,l?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[i?o?r.jsxs(r.Fragment,{children:[r.jsx(DS,{sensors:f,voltage:h,current:p,batteryTemp:x,charge:g,capacity:y}),r.jsx(_S,{sensors:f,dockState:d})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),b&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:b})]})}function DS({sensors:a,voltage:l,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",p=a?.oiMode?.label||"--",x=a?.chargingSources?.homeBase?"Yes":"No",g=a?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(ea,{label:"Voltage",value:l??"--"}),r.jsx(ea,{label:"Current",value:i??"--"}),r.jsx(ea,{label:"Battery temp",value:o??"--"}),r.jsx(ea,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(ea,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(ea,{label:"Charge",value:h}),r.jsx(ea,{label:"OI mode",value:p}),r.jsx(ea,{label:"Docked",value:x}),r.jsx(ea,{label:"Charging state",value:g})]})}function ea({label:a,value:l}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function _S({sensors:a,dockState:l}){const i=a?.bumpsAndWheelDrops||{},o=a?.wheelOvercurrents||{},f=[{label:"Left",value:a?.lightBumpLeftSignal},{label:"Front Left",value:a?.lightBumpFrontLeftSignal},{label:"Center Left",value:a?.lightBumpCenterLeftSignal},{label:"Center Right",value:a?.lightBumpCenterRightSignal},{label:"Front Right",value:a?.lightBumpFrontRightSignal},{label:"Right",value:a?.lightBumpRightSignal}],d=[{label:"Left",value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Front Left",value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Front Right",value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Right",value:a?.cliffRightSignal,active:a?.cliffRight}],h=[{label:"Wheel L",value:a?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:a?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:a?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:a?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Xl,{title:"Dock IR",children:[r.jsx(OS,{sensors:a}),r.jsx(BS,{state:l})]}),r.jsxs(Xl,{title:"Bumps & drops",children:[r.jsx(ta,{label:"Bump L",value:r.jsx(ni,{active:i.bumpLeft})}),r.jsx(ta,{label:"Bump R",value:r.jsx(ni,{active:i.bumpRight})}),r.jsx(ta,{label:"Wheel drop L",value:r.jsx(ni,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(ta,{label:"Wheel drop R",value:r.jsx(ni,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Xl,{title:"Light bumps (raw)",children:f.map(p=>r.jsx(ta,{label:p.label,value:ai(p.value)},p.label))}),r.jsx(Xl,{title:"Cliff sensors",children:d.map(p=>r.jsx(ta,{label:p.label,value:`${ai(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),r.jsx(Xl,{title:"Currents",children:h.map(p=>r.jsx(ta,{label:p.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:ai(p.value,"mA")}),p.over?r.jsx(ni,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),r.jsxs(Xl,{title:"Dirt detect",children:[r.jsx(ta,{label:"Left",value:ai(a?.dirtDetectLeft)}),r.jsx(ta,{label:"Right",value:ai(a?.dirtDetect)})]})]})}function Xl({title:a,children:l}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:a}),r.jsx("div",{className:"space-y-0.5",children:l})]})}function ta({label:a,value:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function ni({active:a,tone:l="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=l==="red"?a?"bg-red-600 text-white":"bg-slate-700 text-slate-300":l==="amber"?a?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":a?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(a?"true":"false")})}function ai(a,l){return a==null||Number.isNaN(a)?"--":l?`${a} ${l}`:a}function OS({sensors:a}){const l=a?.infraredCharacterLeft,i=a?.infraredCharacterRight,o=a?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(l)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function BS({state:a}){if(!a)return null;const l=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${a.left.code??"--"} (${l(a.left)}) · age ${i(a.left)}`}),r.jsx("div",{children:`Omni: ${a.omni.code??"--"} (${l(a.omni)}) · age ${i(a.omni)}`}),r.jsx("div",{children:`Right: ${a.right.code??"--"} (${l(a.right)}) · age ${i(a.right)}`})]})}const Fx=m.createContext(null);function LS({children:a}){const[l,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=bf();i({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=bf();i({status:"ready",data:p??{}})},[]),f=m.useCallback(p=>{const x=A0(p??{});return i(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),d=m.useCallback((p,x)=>{i(g=>{const y=g.data[p]||{},b=typeof x=="function"?x(y):{...y,...x??{}},j={...g.data,[p]:b};return A0(j)?{status:"ready",data:j}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:l.data,status:l.status,reload:o,saveAll:f,setNamespace:d}),[l,o,f,d]);return r.jsx(Fx.Provider,{value:h,children:a})}function zS(){const a=m.useContext(Fx);if(!a)throw new Error("useSettings must be used within SettingsProvider");return a}function Ze(a,l={}){const{data:i,status:o,setNamespace:f}=zS(),d=i[a]??l??{},h=m.useCallback(g=>{f(a,y=>{const b=y??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[a,f]),p=m.useCallback(g=>{f(a,()=>g??{})},[a,f]),x=m.useCallback(()=>{const g=typeof l=="object"?{...l}:l;f(a,()=>g??{})},[l,a,f]);return{value:d,status:o,save:h,replace:p,reset:x}}function US(a=[]){return a.map(l=>!l?.type||!l?.id?null:{type:l.type,id:String(l.id),label:l.label||String(l.id),key:`${l.type}:${l.id}`}).filter(Boolean)}function Gf({panelId:a="replay-sources",fillHeight:l=!1}){const{session:i,triggerReplay:o}=_e(),f=US(i?.replaySources||[]),{value:d,save:h}=Ze("replaySources",{}),[p,x]=m.useState([]),[g,y]=m.useState(!1),[b,j]=m.useState(null),[q,C]=m.useState(null),w=i?.replay||null,[N,E]=m.useState(0),A=m.useMemo(()=>{const L=i?.assignment?.roverId;return L?[`rover:${L}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const L=d?.[a];if(Array.isArray(L)&&L.length){x(L);return}x(A)},[d?.[a],A,a]),m.useEffect(()=>{const L=new Set(f.map(V=>V.key));x(V=>V.filter(K=>L.has(K)))},[f]);const M=m.useMemo(()=>({rovers:f.filter(L=>L.type==="rover"),rooms:f.filter(L=>L.type==="room")}),[f]);m.useEffect(()=>{if(!w?.lastTriggeredAt||!w?.cooldownMs){E(0);return}const L=()=>{const K=w.lastTriggeredAt+w.cooldownMs-Date.now();E(Math.max(0,K))};L();const V=setInterval(L,250);return()=>clearInterval(V)},[w?.lastTriggeredAt,w?.cooldownMs,w?.remainingMs]);const T=g||i?.mode==="lockdown"||N>0||!p.length,B=L=>{x(V=>{const K=V.includes(L)?V.filter(te=>te!==L):[...V,L];return h(te=>({...te||{},[a]:K})),K}),C(null)},Z=async()=>{if(!T){y(!0),j(null),C(null);try{const L=p.map(V=>{const[K,te]=V.split(":");return{type:K,id:te}});await o(L),C("Replay sent. Check the Discord replay channel.")}catch(L){j(L.message)}finally{y(!1)}}},O=l?"h-full flex flex-col":"",H=l?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${O}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${H}`,children:[r.jsx(j0,{title:"Rovers",items:M.rovers,selected:p,onToggle:B}),r.jsx(j0,{title:"Room Cams",items:M.rooms,selected:p,onToggle:B})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:Z,disabled:T,children:N>0?`Replay (${Math.ceil(N/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,q?r.jsx("div",{className:"text-xs text-emerald-300",children:q}):null]})]})}function j0({title:a,items:l,selected:i,onToggle:o}){return l.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:a}),r.jsx("div",{className:"space-y-0.5",children:l.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:"truncate",children:f.label})]},f.key))})]}):null}var Xx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},N0=ll.createContext&&ll.createContext(Xx),HS=["attr","size","title"];function VS(a,l){if(a==null)return{};var i=$S(a,l),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);for(f=0;f<d.length;f++)o=d[f],!(l.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(i[o]=a[o])}return i}function $S(a,l){if(a==null)return{};var i={};for(var o in a)if(Object.prototype.hasOwnProperty.call(a,o)){if(l.indexOf(o)>=0)continue;i[o]=a[o]}return i}function lo(){return lo=Object.assign?Object.assign.bind():function(a){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=i[o])}return a},lo.apply(this,arguments)}function w0(a,l){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);l&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(a,f).enumerable})),i.push.apply(i,o)}return i}function so(a){for(var l=1;l<arguments.length;l++){var i=arguments[l]!=null?arguments[l]:{};l%2?w0(Object(i),!0).forEach(function(o){GS(a,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):w0(Object(i)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(i,o))})}return a}function GS(a,l,i){return l=YS(l),l in a?Object.defineProperty(a,l,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[l]=i,a}function YS(a){var l=FS(a,"string");return typeof l=="symbol"?l:l+""}function FS(a,l){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var o=i.call(a,l);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(a)}function Qx(a){return a&&a.map((l,i)=>ll.createElement(l.tag,so({key:i},l.attr),Qx(l.child)))}function Ai(a){return l=>ll.createElement(XS,lo({attr:so({},a.attr)},l),Qx(a.child))}function XS(a){var l=i=>{var{attr:o,size:f,title:d}=a,h=VS(a,HS),p=f||i.size||"1em",x;return i.className&&(x=i.className),a.className&&(x=(x?x+" ":"")+a.className),ll.createElement("svg",lo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:x,style:so(so({color:a.color||i.color},i.style),a.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),d&&ll.createElement("title",null,d),a.children)};return N0!==void 0?ll.createElement(N0.Consumer,null,i=>l(i)):l(Xx)}function Kx(a){return Ai({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(a)}function QS(a){return Ai({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(a)}function C0(a){return Ai({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(a)}function KS(a){return Ai({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(a)}function ZS(a){return Ai({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function IS(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Yf(a){return!!a?.system}function JS(a){const l=new Date(a);return`${l.getHours().toString().padStart(2,"0")}:${l.getMinutes().toString().padStart(2,"0")}`}function E0(a){return a.nickname||a.socketId?.slice(0,6)||"unknown"}function PS({guildIconUrl:a,userAvatarUrl:l,label:i}){return!a&&!l?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${l?"bg-cover":""}`,style:l?{backgroundImage:`url(${l})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function Zx({message:a}){const l=a.fromDiscord?`${a.discordGuildName||"Discord"} · ${E0(a)}`:null,i=Yf(a),o=i?"text-emerald-300":IS(a.role);return r.jsxs(r.Fragment,{children:[a.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(Kx,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(PS,{guildIconUrl:a.discordGuildIconUrl,userAvatarUrl:a.discordUserAvatarUrl,label:l})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:E0(a)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,a.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",children:a.roverId})]})}function Ix(a){return Yf(a)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${a.role==="admin"||a.role==="lockdown"||a.role==="lockdown-admin"?"border border-amber-400/30":a.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function Ff({message:a}){const l=Yf(a);return r.jsxs("div",{className:Ix(a),children:[r.jsx(Zx,{message:a}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${l?"text-emerald-100":"text-slate-100"}`,children:a.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:JS(a.ts)})]})}function Jx({message:a}){return r.jsxs("div",{className:`${Ix(a)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(Zx,{message:a}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}const WS=3e3,eA="#2196f3";function tA(a){return a.id?a.id:a.timestamp?`${a.timestamp}-${a.message}`:`${a.title||"alert"}-${a.message}`}function Xf({scale:a=1}){const{alerts:l}=_e(),[i,o]=m.useState(()=>Date.now()),f=m.useMemo(()=>l.slice(-3).map(x=>({alert:x,key:tA(x)})),[l]);m.useEffect(()=>{if(!f.length)return;const x=setInterval(()=>o(Date.now()),200);return()=>clearInterval(x)},[f.length]);const d=f.map(x=>({...x,age:i-(x.alert.receivedAt??x.alert.timestamp??0)})).filter(x=>x.age<=WS);if(!d.length)return null;const h=a===1?void 0:{transform:`translateX(-50%) scale(${a})`,transformOrigin:"top center"},p=a===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:p,style:h,children:d.map(x=>r.jsx(nA,{alert:x.alert},x.key))})}function k0(a){const l=typeof a=="string"?a.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(l);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function nA({alert:a}){if(a.kind==="chat"&&a.payload)return r.jsx(Ff,{message:a.payload});if(a.kind==="chat-typing"&&a.payload)return r.jsx(Jx,{message:a.payload});const l=k0(a.color)||k0(eA),i=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:a.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:a.message})]})})}const Ql={main:[-127,127],side:[-127,127],vacuum:[0,127]},Xu={maxSpeed:500,baseSpeed:250,boostSpeed:400},Sf=100,Qf=[31,127],Wl=60,Af=8,aA=250,lA=4e3,Qu=.4,sA=.8,iA={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},oi={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"]},Px=[{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:Sf},{type:"oi",command:"dock"},{type:"pause",duration:Sf},{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 jf(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Nf(){return{main:0,side:0,vacuum:0}}function rA(){return{enabled:!1,angle:null,config:null}}function Pr(){return{note:Wl}}function ri(){return{active:!1,heat:0,overheated:!1}}function Wr(){return{pttActive:!1}}const M0={roverId:null,mode:"drive",drive:jf(),aux:Nf(),camera:rA(),song:Pr(),horn:ri(),mic:Wr(),lastControlIntentAt:0,macros:Px,keymap:oi,inputs:{}};function oA(a,l){switch(l.type){case"control/set-rover":return{...a,roverId:l.payload??null,drive:l.payload?a.drive:jf(),aux:l.payload?a.aux:Nf(),song:l.payload?a.song:Pr(),horn:l.payload?a.horn:ri(),mic:l.payload?a.mic:Wr(),lastControlIntentAt:l.payload?a.lastControlIntentAt:0};case"control/set-mode":return a.mode===l.payload?a:{...a,mode:l.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=l.payload;return{...a,drive:{vector:i??a.drive.vector,speeds:o??a.drive.speeds,source:f??a.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...a,aux:{...a.aux,...l.payload}};case"control/set-camera-config":return{...a,camera:{...a.camera,enabled:!!l.payload?.config,config:l.payload?.config??null,angle:typeof l.payload?.angle=="number"?l.payload.angle:l.payload?.config?l.payload.config.homeAngle??a.camera.angle:null}};case"control/set-camera-angle":return{...a,camera:{...a.camera,angle:l.payload}};case"control/register-input-state":{const i=l.payload?.source||"unknown";return{...a,inputs:{...a.inputs,[i]:{...a.inputs[i]??{},...l.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...a,keymap:{...a.keymap,...l.payload??{}}};case"control/set-macros":return{...a,macros:Array.isArray(l.payload)?l.payload:a.macros};case"control/reset":return{...a,drive:jf(),aux:Nf(),song:Pr(),horn:ri(),mic:Wr(),lastControlIntentAt:0};case"control/set-horn-active":return{...a,horn:{...a.horn||ri(),active:!!l.payload}};case"control/set-horn-heat":return{...a,horn:{...a.horn||ri(),heat:typeof l.payload?.heat=="number"?l.payload.heat:0,overheated:!!l.payload?.overheated}};case"control/record-intent":return{...a,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...a,song:{...a.song||Pr(),note:l.payload??Wl}};case"control/set-mic-ptt":return{...a,mic:{...a.mic||Wr(),pttActive:!!l.payload}};default:return a}}function es(a,l,i){return typeof a!="number"||Number.isNaN(a)?l:Math.max(l,Math.min(i,a))}function ts(a){return typeof a!="number"||Number.isNaN(a)?0:Math.max(-1,Math.min(1,a))}function hn(a,l){return!Array.isArray(l)||l.length!==2?a:es(a,l[0],l[1])}function cA(a={}){const l=ts(a.x??0),i=ts(a.y??0);return{x:l,y:i,boost:!!a.boost}}function uA(a={},l={}){const i=cA(a),o=typeof l.maxSpeed=="number"?l.maxSpeed:Xu.maxSpeed,f=typeof l.baseSpeed=="number"?l.baseSpeed:Xu.baseSpeed,d=typeof l.boostSpeed=="number"?l.boostSpeed:Xu.boostSpeed,h=i.boost?d:f,p=i.y*h,x=i.x*h;return{vector:i,speeds:{left:es(Math.round(p+x),-o,o),right:es(Math.round(p-x),-o,o)}}}function fA(a){const l=Array.isArray(a)?a:[],i=String.fromCharCode(...l);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(l).toString("base64");throw new Error("No base64 encoder available")}function q0(a){return new Promise(l=>setTimeout(l,a))}function dA(a={}){const{driveTransform:l,auxTransform:i}=a,o=On(),{session:f}=_e(),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(B=>String(B.id)===String(d))||null,[d,f?.roster]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),y=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((B,Z)=>{d&&o.emit("command",{roverId:d,...B},Z)},[o,d]),j=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),q=m.useCallback(B=>{if(!d)return null;const Z={left:hn(B?.left??0,[-500,500]),right:hn(B?.right??0,[-500,500])},O=l?l(Z):Z,H={left:hn(O?.left??0,[-500,500]),right:hn(O?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:H}}),H},[l,b,d]),C=m.useCallback(({main:B=0,side:Z=0,vacuum:O=0}={})=>{if(!d)return null;const H={main:hn(B,Ql.main),side:hn(Z,Ql.side),vacuum:hn(O,Ql.vacuum)},L=i?i(H):H,V={main:hn(L?.main??0,Ql.main),side:hn(L?.side??0,Ql.side),vacuum:hn(L?.vacuum??0,Ql.vacuum)};return b({type:"motors",data:{motorPwm:V}}),V},[i,b,d]),w=m.useCallback(B=>!d||!p?null:(b({type:"servo",data:{servo:{angle:B}}}),B),[b,d,p]),N=m.useCallback(B=>{if(!d)return!1;const Z=Array.isArray(B)?B:typeof B=="string"?iA[B]:null;return Z?(b({type:"raw",data:{raw:fA(Z)}}),j(),!0):!1},[b,j,d]),E=m.useCallback(async B=>{if(!(!B||!Array.isArray(B.steps)||!d))for(const Z of B.steps){if(!d)break;switch(Z.type){case"oi":N(Z.command);break;case"drive":q(Z.speeds??{left:0,right:0});break;case"motors":C(Z.values??{});break;case"servo":w(Z.angle);break;case"pause":await q0(Z.duration??Sf);break}if(Z.delay||Z.delayMs){const O=Z.delayMs??Z.delay;typeof O=="number"&&O>0&&await q0(O)}}},[d,N,q,C,w]),A=m.useCallback((B="toggle")=>!d||!x?null:(b({type:"nightVision",data:{nightVision:{action:B}}}),B),[b,x,d]),M=m.useCallback(B=>d?(b({type:"horn",data:{horn:B}}),B):null,[b,d]),T=m.useCallback((B=[],Z={})=>{if(!d)return null;const H=(Array.isArray(B)&&B.length>0?B:[{note:Wl,duration:Af}]).slice(0,16).map(L=>({note:hn(Math.round(L?.note??Wl),Qf),duration:hn(Math.round(L?.duration??Af),[1,255])}));return b({type:"song",data:{song:{notes:H,slot:Z.slot,loop:Z.loop}}}),H},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:y,horn:g,emitCommand:b,enableSensorStream:j,sendDriveDirect:q,sendAuxMotors:C,sendServoAngle:w,sendOiCommand:N,sendNightVision:A,sendHorn:M,sendSong:T,runMacroSteps:E}),[d,h,p,x,y,g,b,j,q,C,w,N,A,M,E])}const mA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},R0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function ji(a){if(typeof a!="string")return"";const l=a.toLowerCase();return mA[l]??l}function hA(a){const l=ji(a);if(!l)return null;if(R0[l])return R0[l];if(l.length===1){if(/[a-z]/.test(l))return`Key${l.toUpperCase()}`;if(/[0-9]/.test(l))return`Digit${l}`}return null}function Wx(a){const l=ji(a);return l?`key:${l}`:null}function pA(a){const l=hA(a);return l?`code:${l}`:null}function T0(a){const l=new Set,i=Wx(a?.key??"");i&&l.add(i);const o=a?.code?`code:${a.code}`:null;return o&&l.add(o),Array.from(l)}function xA(a={}){return Object.fromEntries(Object.entries(a).map(([l,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=Wx(String(d));h&&f.add(h);const p=pA(String(d));p&&f.add(p)}),[l,f]}))}function Nn(a){const l=ji(a);return l?l===" "?"Space":l==="\\"?"Backslash":l==="`"?"Backtick":l==="["?"[ or {":l==="]"?"] or }":l===";"?"; or :":l==="'"?`' or "`:l===","?", or <":l==="."?". or >":l==="/"?"/ or ?":l==="-"?"- or _":l==="="?"= or +":l==="arrowup"?"Arrow Up":l==="arrowdown"?"Arrow Down":l==="arrowleft"?"Arrow Left":l==="arrowright"?"Arrow Right":l.length===1?l.toUpperCase():l:"—"}const Rn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},aa={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}]}}},Ra={activeSignature:null,profiles:{},defaults:{profile:aa}},al={waveform:"saw",freqs:[440,550,660,0]},kt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Jl=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],gA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function D0(){return Jl.reduce((a,l)=>(a[l.key]={cap:1,clearSec:0},a),{})}function _0(a){return Number.isFinite(a)?Math.max(0,Math.min(1,a)):0}function vA(a,l={}){const{session:i}=_e(),d=(ss(a)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...gA,...l.config||{}}),[l.config]),[p,x]=m.useState(()=>D0()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),y=m.useRef(d);m.useEffect(()=>{y.current=d||{}},[d]),m.useEffect(()=>{x(D0())},[a]),m.useEffect(()=>{const C=setInterval(()=>{const w=typeof performance<"u"?performance.now():Date.now(),N=Math.max(0,w-g.current);g.current=w;const E=N/1e3;E<=0||x(A=>{let M=!1;const T={},B=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,Z=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,O=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return Jl.forEach(H=>{const L=A[H.key]||{cap:1,clearSec:0},V=Number.isFinite(L.cap)?L.cap:1,K=Number.isFinite(L.clearSec)?L.clearSec:0,te=H.motors.some(R=>!!y.current?.[R]),ce=te?0:K+E,re=!te&&ce>=O,F=_0(te?V-B*E:re?V+Z*E:V);(Math.abs(F-V)>1e-4||Math.abs(ce-K)>1e-4)&&(M=!0),T[H.key]={cap:F,clearSec:ce}}),M?T:A})},100);return()=>clearInterval(C)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec]);const b=m.useMemo(()=>{const C=Jl.reduce((w,N)=>{const E=p?.[N.key],A=Number.isFinite(E?.cap)?E.cap:1;return w[N.key]=_0(A),w},{});return{perGroup:C,drive:{left:C.drive??1,right:C.drive??1},aux:{main:C.aux??1,side:C.aux??1,vacuum:1}}},[p]),j=m.useMemo(()=>{const C={};Jl.forEach(N=>{N.motors.forEach(E=>{C[E]=!!d?.[E]})});const w=Jl.reduce((N,E)=>(N[E.key]=E.motors.some(A=>!!d?.[A]),N),{});return{motors:C,groups:w}},[d]),q=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:j,scales:b,isActive:(b?.drive?.left??1)<1||(b?.drive?.right??1)<1||(b?.aux?.main??1)<1||(b?.aux?.side??1)<1,config:h,adminImmune:q}),[p,j,b,h,q])}function yA(a={},l,i=!1){if(i||!l?.drive)return a;const o=typeof l.drive.left=="number"?l.drive.left:1,f=typeof l.drive.right=="number"?l.drive.right:1;return o>=.999&&f>=.999?a:{left:Math.round((a.left??0)*o),right:Math.round((a.right??0)*f)}}function bA(a={},l,i=!1){if(i||!l?.aux)return a;const o=typeof l.aux.main=="number"?l.aux.main:1,f=typeof l.aux.side=="number"?l.aux.side:1,d=typeof l.aux.vacuum=="number"?l.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?a:{main:Math.round((a.main??0)*o),side:Math.round((a.side??0)*f),vacuum:Math.round((a.vacuum??0)*d)}}const eg=m.createContext(null);function O0(a){return Object.fromEntries(Object.entries(a||{}).map(([l,i])=>[l,Array.isArray(i)?[...i]:[]]))}function SA(a,l){if(!a)return l;const i=typeof a.minAngle=="number"?a.minAngle:-45,o=typeof a.maxAngle=="number"?a.maxAngle:45;return es(l,i,o)}function AA({children:a}){const[l,i]=m.useReducer(oA,M0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(M0.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:y}=Ze("controls",{keymap:oi,macros:Px}),{value:b}=Ze("horn",al),{session:j,homeAssistantSetState:q}=_e(),C=j?.assignment?.roverId??null,w=vA(C),N=m.useCallback(Y=>yA(Y,w.scales,w.adminImmune),[w.adminImmune,w.scales]),E=m.useCallback(Y=>bA(Y,w.scales,w.adminImmune),[w.adminImmune,w.scales]),A=dA({driveTransform:N,auxTransform:E}),M=m.useCallback(()=>{const le=(j?.homeAssistant?.entities||[]).filter(fe=>(fe.type==="light"||fe.type==="switch")&&fe.available!==!1&&fe.state!=="on");if(le.length===0){f.current=!1;return}f.current=!0,le.forEach(fe=>{q(fe.id,"on").catch(()=>{})}),f.current=!1},[j?.homeAssistant?.entities,q]);m.useEffect(()=>{i({type:"control/set-rover",payload:A.roverId})},[A.roverId]),m.useEffect(()=>{const Y=o.current;o.current=l.mode,Y!=="drive"&&l.mode==="drive"&&j?.homeAssistant?.entities?M():Y!=="drive"&&l.mode==="drive"&&(f.current=!0)},[l.mode,j?.homeAssistant?.entities,M]),m.useEffect(()=>{f.current&&j?.homeAssistant?.entities&&M()},[j?.homeAssistant?.entities,M]),m.useEffect(()=>{const Y={...oi,...g?.keymap||{}};i({type:"control/set-keymap",payload:Y}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const Y=A.servoConfig;if(!Y){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const le=typeof Y.minAngle=="number"?Y.minAngle:-45,fe=typeof Y.maxAngle=="number"?Y.maxAngle:45,Ae=typeof Y.homeAngle=="number"?Y.homeAngle:(le+fe)/2,Ve=typeof d.current=="number"?es(d.current,le,fe):null,Ie=Ve??es(Ae,le,fe);i({type:"control/set-camera-config",payload:{config:Y,angle:Ie}}),d.current=Ie},[A.servoConfig]),m.useEffect(()=>{d.current=typeof l.camera.angle=="number"?l.camera.angle:d.current},[l.camera.angle]),m.useEffect(()=>{A.roverId&&A.enableSensorStream()},[A.roverId,A.enableSensorStream]);const T=m.useCallback(Y=>{i({type:"control/set-mode",payload:Y})},[]),B=m.useCallback(()=>{i({type:"control/record-intent"})},[]),Z=m.useRef(l.drive.speeds),O=m.useRef(l.aux),H=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),L=m.useRef(0),V=m.useRef(0);m.useEffect(()=>{Z.current=l.drive.speeds},[l.drive.speeds]),m.useEffect(()=>{O.current=l.aux},[l.aux]),m.useEffect(()=>{if(!A.roverId||w.adminImmune||!w.isActive)return;const Y=Math.max(0,Number(w?.config?.outputRateMs)||0),le=typeof performance<"u"?performance.now():Date.now(),fe=Z.current||{left:0,right:0},Ae=O.current||{main:0,side:0,vacuum:0},Ve=!!(fe.left||fe.right),Ie=!!(Ae.main||Ae.side||Ae.vacuum);!Ve&&!Ie||(Ve&&le-L.current>=Y&&(L.current=le,A.sendDriveDirect(fe)),Ie&&le-V.current>=Y&&(V.current=le,A.sendAuxMotors(Ae)))},[H,w.adminImmune,w.config,w.isActive,A]);const K=m.useCallback((Y,le={})=>{const fe=uA(Y,le.speedOptions);i({type:"control/update-drive",payload:{...fe,source:le.source??null}}),B(),A.sendDriveDirect(fe.speeds)},[A,B]),te=m.useCallback((Y={})=>{const le=A.sendAuxMotors(Y)??Y;i({type:"control/set-aux-motors",payload:le}),B()},[A,B]),ce=m.useCallback((Y,le)=>{if(!Y)return!1;const fe=ji(le);if(!fe)return!1;const Ae=O0(l.keymap);return Ae[Y]=[fe],i({type:"control/set-keymap",payload:Ae}),y(Ve=>({...Ve??{},keymap:Ae})),!0},[l.keymap,y]),re=m.useCallback(()=>{const Y=O0(oi);i({type:"control/set-keymap",payload:Y}),y(le=>({...le??{},keymap:Y}))},[y]),F=m.useCallback(Y=>{if(!A.servoConfig)return;const le=SA(A.servoConfig,Y);i({type:"control/set-camera-angle",payload:le}),A.sendServoAngle(le),d.current=le,B()},[A,B]),R=m.useCallback((Y=0)=>{const le=A.servoConfig;if(!le)return;const fe=typeof Y=="number"&&Y!==0?Y:le.nudgeDegrees||1,Ae=typeof d.current=="number"?d.current:typeof le.homeAngle=="number"?le.homeAngle:0;F(Ae+fe)},[A.servoConfig,F]),X=m.useCallback(()=>{const Y=A.servoConfig;if(!Y)return;const le=typeof Y.homeAngle=="number"?Y.homeAngle:typeof Y.minAngle=="number"&&typeof Y.maxAngle=="number"?(Y.minAngle+Y.maxAngle)/2:0;F(le)},[A.servoConfig,F]),W=m.useCallback(async Y=>{const le=l.macros.find(fe=>fe.id===Y)||null;le&&(Y==="drive-sequence"?(M(),j?.homeAssistant?.entities||(f.current=!0),B()):Y==="seek-dock"&&B(),await A.runMacroSteps(le))},[A,B,j?.homeAssistant?.entities,l.macros,M]),se=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),A.sendDriveDirect({left:0,right:0}),A.sendAuxMotors({main:0,side:0,vacuum:0})},[A]),ue=m.useCallback(Y=>{A.sendOiCommand(Y)},[A]),k=m.useCallback(Y=>{A.roverId&&A.emitCommand({type:"sensorStream",data:{sensorStream:{enable:Y}}})},[A]),U=m.useCallback(Y=>{if(A.nightVision){if(typeof Y=="boolean"){const le=Y?"off":"on";A.sendNightVision(le)}else A.sendNightVision("toggle");B()}},[A,B]),ne=m.useCallback(()=>{U()},[U]),ae=m.useCallback(Y=>{const le=typeof Y=="number"?Y:Wl;return i({type:"control/set-song-note",payload:le}),le},[]),me=m.useCallback((Y,le)=>A.sendSong(Y,le),[A]),ie=m.useMemo(()=>{const Y=b??al,le=Y.waveform==="sine"?"sine":"saw",Ae=[...Array.isArray(Y.freqs)?Y.freqs:al.freqs,0,0,0,0].slice(0,4).map(Ve=>{const Ie=Number(Ve);return Number.isFinite(Ie)?Ie<=0?0:Math.min(5e3,Math.round(Ie)):0});return{waveform:le,freqs:Ae}},[b]),oe=m.useCallback(()=>{if(!A.horn)return;if(l.horn?.overheated||(l.horn?.heat??0)>=1||l.horn?.active)return!1;const Y=Date.now();return A.sendHorn({action:"start",...ie}),i({type:"control/set-horn-active",payload:!0}),p.current=Y,x.current=Y,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{he()},lA),B(),!0},[i,ie,A,B,l.horn?.active,l.horn?.heat,l.horn?.overheated]),he=m.useCallback(()=>{if(!A.horn)return;A.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const Y=Date.now(),le=p.current||Y,fe=Math.max(0,Y-le);if(p.current=0,fe>0){const Ae=l.horn?.heat??0,Ve=fe/1e3*Qu;let Ie=Math.max(0,Math.min(1,Ae+Ve)),qt=l.horn?.overheated??!1;Ie>=1&&(Ie=1,qt=!0),i({type:"control/set-horn-heat",payload:{heat:Ie,overheated:qt}})}},[i,A,l.horn?.heat,l.horn?.overheated,Qu]);m.useEffect(()=>{const le=setInterval(()=>{const fe=Date.now(),Ae=x.current||fe;x.current=fe;const Ve=Math.min(1e3,Math.max(0,fe-Ae))/1e3,Ie=l.horn?.heat??0,qt=!!l.horn?.active,Wt=!!l.horn?.overheated,ve=Ve*(qt?Qu:-.2);let Ce=Math.max(0,Math.min(1,Ie+ve)),$e=Wt;Ce>=1?(Ce=1,$e=!0,qt&&he()):$e&&Ce<=sA&&($e=!1),(Ce!==Ie||$e!==Wt)&&i({type:"control/set-horn-heat",payload:{heat:Ce,overheated:$e}})},100);return()=>clearInterval(le)},[i,l.horn?.active,l.horn?.heat,l.horn?.overheated,he]);const pe=m.useCallback((Y,le)=>{i({type:"control/register-input-state",payload:{source:Y,state:le}})},[]),ge=m.useCallback(Y=>{i({type:"control/set-mic-ptt",payload:!!Y})},[]),Oe=m.useMemo(()=>({state:l,dispatch:i,pipeline:A,overcurrentLimiter:w,actions:{setMode:T,setDriveVector:K,setAuxMotors:te,setServoAngle:F,nudgeServo:R,goServoHome:X,runMacro:W,stopAllMotion:se,sendOiCommand:ue,setSensorStream:k,setNightVision:U,toggleNightVision:ne,updateKeyBinding:ce,resetKeyBindings:re,registerInputState:pe,setSongNote:ae,sendSong:me,startHorn:oe,stopHorn:he,setMicPttActive:ge}}),[l,A,w,T,K,te,F,R,X,W,se,ue,k,U,ne,ce,re,pe,ae,me,oe,he,ge]);return r.jsx(eg.Provider,{value:Oe,children:a})}function Mt(){const a=m.useContext(eg);if(!a)throw new Error("useControlSystem must be used within ControlSystemProvider");return a}const jA="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=",tg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function NA({children:a}){const l=On(),{session:i,pushAlert:o}=_e(),{value:f}=Ze("audio",kt),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,y]=m.useState(!1),b=m.useRef(null),j=m.useRef(null),q=m.useRef(null),C=m.useRef(new Map),w=m.useRef(new Map),N=m.useRef({isTyping:!1,lastSent:0}),E=Number.isFinite(f?.masterVolume)?f.masterVolume:kt.masterVolume,A=Number.isFinite(f?.alertVolume)?f.alertVolume:kt.alertVolume,M=Math.max(0,Math.min(1,E*A)),T=m.useCallback(()=>{const F=Array.from(C.current.values()).sort((R,X)=>R.lastUpdate-X.lastUpdate).map(R=>R.payload);x(F)},[]),B=m.useCallback(F=>!F||typeof F!="object"?null:F.typingId?F.typingId:F.fromDiscord?`discord:${F.discordUserId||F.discordUserName||F.nickname||"unknown"}`:`socket:${F.socketId||F.nickname||"unknown"}`,[]);m.useEffect(()=>{q.current=new Audio(jA),q.current.volume=M,q.current.load()},[M]);const Z=m.useCallback(()=>{const F=q.current;F&&(F.volume=M,F.currentTime=0,F.play().catch(()=>{}))},[M]);m.useEffect(()=>{function F(R={}){h(X=>[...X.slice(-99),R]),!(R?.socketId&&i?.socketId&&R.socketId===i.socketId)&&(Z(),o?.({kind:"chat",payload:R,id:`chat-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return l.on("chat:message",F),()=>{l.off("chat:message",F)}},[Z,i?.socketId,l]),m.useEffect(()=>{function F(R={}){const X=B(R);if(!X)return;const W=Date.now();if(R?.socketId&&i?.socketId&&R.socketId===i.socketId){R.isTyping||(C.current.delete(X),T());return}if(R.isTyping){C.current.set(X,{payload:R,expiresAt:W+6e3,lastUpdate:W});const se=w.current.get(X)||0;W-se>=2500&&(w.current.set(X,W),o?.({kind:"chat-typing",payload:R,id:`chat-typing-${X}-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:W}))}else C.current.delete(X);T()}return l.on("chat:typing",F),()=>{l.off("chat:typing",F)}},[o,T,B,i?.socketId,l]),m.useEffect(()=>{const F=setInterval(()=>{const R=Date.now();let X=!1;C.current.forEach((W,se)=>{W.expiresAt<=R&&(C.current.delete(se),X=!0)}),X&&T()},2e3);return()=>clearInterval(F)},[T]),m.useEffect(()=>{function F(R=[]){Array.isArray(R)&&h(X=>{if(X.length===0)return R.slice(-100);const W=new Set(R.map(ue=>ue?.id));return[...R,...X.filter(ue=>ue?.id&&!W.has(ue.id))].slice(-100)})}return l.on("chat:init",F),()=>{l.off("chat:init",F)}},[l]);const O=m.useCallback(F=>{const R=!!F,X=Date.now(),W=N.current,se=!R&&W.isTyping;!(R&&(!W.isTyping||X-W.lastSent>=3500))&&!se||(N.current={isTyping:R,lastSent:X},l.emit("chat:typing",{isTyping:R}))},[l]),H=m.useCallback((F,R=null)=>new Promise((X,W)=>{l.emit("chat:send",{text:F,tts:R},(se={})=>{se.error?W(new Error(se.error)):X(se)})}),[l]),L=m.useCallback((F,R={})=>{(R?.target==="hud"?"hud":"panel")==="hud"?j.current=F:b.current=F},[]),V=m.useCallback(()=>{y(!0),(j.current||b.current)?.focus()},[]),K=m.useCallback(()=>{y(!1),j.current?.blur(),b.current?.blur()},[]),te=m.useCallback(()=>y(!0),[]),ce=m.useCallback(()=>y(!1),[]),re=m.useMemo(()=>({messages:d,sendMessage:H,focusChat:V,blurChat:K,registerInputRef:L,onInputFocus:te,onInputBlur:ce,setTypingActive:O,typing:p,isChatFocused:g,selfSocketId:i?.socketId||null}),[K,V,g,d,ce,te,L,H,i?.socketId,O,p]);return r.jsx(tg.Provider,{value:re,children:a})}function Kf(){const a=m.useContext(tg);if(!a)throw new Error("useChat must be used inside ChatProvider");return a}let ng=!1;function Ku(a){ng=!!a}function B0(){return ng}const wA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function ag(a){if(!a||a.nodeType!==1)return!1;const l=a.tagName;if(l==="TEXTAREA"||a.isContentEditable)return!0;if(l!=="INPUT")return!1;const i=a.type?a.type.toLowerCase():"";return wA.has(i)}function CA(){return typeof document>"u"?!1:ag(document.activeElement)}const Zu="keyboard",Iu={x:0,y:0,boost:!1},Ju={main:0,side:0,vacuum:0},L0=Qf[0],z0=Qf[1],Zf=5,fi=500,di=1,If=100;function Pu(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}function EA(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(Zf,Math.min(fi,i)):l}function lg(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(di,Math.min(If,i)):l}function kA(a){const i=(lg(a,a)-di)/(If-di),o=fi-i*(fi-Zf);return Math.round(o)}function MA(a){const l=EA(a,a),i=(fi-l)/(fi-Zf),o=di+i*(If-di);return Math.round(o)}function qA(a){return ag(a?.target)}function ot(a,l){if(!a||a.size===0)return!1;for(const i of l)if(a.has(i))return!0;return!1}function RA(a,l){const i=ot(l.driveForward,a),o=ot(l.driveBackward,a),f=ot(l.driveLeft,a),d=ot(l.driveRight,a),h=ot(l.boostModifier,a),p=ot(l.slowModifier,a);let x=0;i&&!o?x=1:o&&!i&&(x=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const y=p?.4:1;return{x:g*y,y:x*y,boost:h&&!p}}function TA(a,l){if(ot(l.auxAllForward,a))return{main:127,side:127,vacuum:127};const o=ot(l.auxMainForward,a)?127:ot(l.auxMainReverse,a)?-127:0,f=ot(l.auxSideForward,a)?127:ot(l.auxSideReverse,a)?-70:0,d=ot(l.auxVacuumFast,a)?127:ot(l.auxVacuumSlow,a)?50:0;return{main:o,side:f,vacuum:d}}function DA(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:y,setMicPttActive:b,setSongNote:j,sendSong:q}}=Mt(),{session:C,homeAssistantSetState:w}=_e(),{focusChat:N,blurChat:E,isChatFocused:A}=Kf(),{value:M}=Ze("inputs",Rn),T=m.useMemo(()=>xA(a.keymap),[a.keymap]),B=m.useMemo(()=>{const ie=new Set;return Object.values(T).forEach(oe=>{oe&&oe.forEach(he=>ie.add(he))}),ie},[T]),Z=m.useMemo(()=>{const ie=Rn.keyboard,oe=M?.keyboard??{};return{baseSpeed:Pu(oe.baseSpeed,ie.baseSpeed),turboSpeed:Pu(oe.turboSpeed,ie.turboSpeed),precisionSpeed:Pu(oe.precisionSpeed,ie.precisionSpeed)}},[M?.keyboard]),O=m.useMemo(()=>{const ie=Rn.keyboard,oe=M?.keyboard??{},he=lg(typeof oe.tiltSpeed=="number"?oe.tiltSpeed:typeof oe.tiltIntervalMs=="number"?MA(oe.tiltIntervalMs):ie.tiltSpeed,ie.tiltSpeed);return kA(he)},[M?.keyboard]),H=m.useMemo(()=>Math.abs(a.camera?.config?.nudgeDegrees||1),[a.camera?.config?.nudgeDegrees]),L=m.useRef(new Set),V=m.useRef(Iu),K=m.useRef(Ju),te=m.useRef(null),ce=m.useRef(null),re=m.useRef(!1),F=m.useCallback(()=>{const ie=new Set(L.current);ot(T.boostModifier,ie);const he=ot(T.slowModifier,ie)?{baseSpeed:Z.precisionSpeed,boostSpeed:Z.precisionSpeed}:{baseSpeed:Z.baseSpeed,boostSpeed:Z.turboSpeed},pe=RA(ie,T),ge=TA(ie,T);(pe.x!==V.current.x||pe.y!==V.current.y||pe.boost!==V.current.boost)&&(V.current=pe,i(pe,{source:Zu,speedOptions:he})),(ge.main!==K.current.main||ge.side!==K.current.side||ge.vacuum!==K.current.vacuum)&&(K.current=ge,o(ge)),p(Zu,{keys:Array.from(ie),vector:pe,aux:ge})},[T,Z,p,o,i]),R=m.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),X=m.useCallback(()=>{const ie=new Set(L.current),oe=ot(T.cameraUp,ie),he=ot(T.cameraDown,ie);return(oe?1:0)-(he?1:0)},[T]),W=m.useCallback(()=>{if(X()===0){R();return}if(te.current)return;const oe=()=>{const he=X();if(he===0){R();return}f(he*H),te.current=setTimeout(oe,O)};te.current=setTimeout(oe,0)},[X,f,O,H,R]),se=m.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),ue=m.useCallback(()=>{const ie=new Set(L.current),oe=ot(T.songNoteUp,ie),he=ot(T.songNoteDown,ie);return(oe?1:0)-(he?1:0)},[T]),k=m.useCallback(ie=>{if(ie===0)return;let he=(typeof a.song?.note=="number"?a.song.note:Wl)+ie;he>z0?he=L0:he<L0&&(he=z0);const pe=j(he);q([{note:pe,duration:Af}],{slot:0})},[q,j,a.song?.note]),U=m.useCallback(()=>{if(ue()===0){se();return}if(ce.current)return;const oe=()=>{const he=ue();if(he===0){se();return}k(he),ce.current=setTimeout(oe,aA)};ce.current=setTimeout(oe,0)},[ue,se,k]),ne=m.useCallback(()=>{L.current.clear(),V.current=Iu,K.current=Ju,R(),se(),re.current&&(re.current=!1,y()),b(!1),h(),p(Zu,{keys:[],vector:Iu,aux:Ju})},[p,b,h,y,R,se]),ae=m.useCallback(ie=>{const oe=C?.homeAssistant;if(!oe?.enabled||!oe?.connected)return;const pe=(oe.entities||[]).filter(ge=>(ge.type==="light"||ge.type==="switch")&&ge.available!==!1&&ge.state!=="unavailable");if(pe.length!==0){if(ie==="on"){const ge=pe.find(Oe=>Oe.state!=="on");ge&&w(ge.id,"on").catch(()=>{});return}if(ie==="off")for(let ge=pe.length-1;ge>=0;ge-=1){const Oe=pe[ge];if(Oe.state==="on"){w(Oe.id,"off").catch(()=>{});break}}}},[w,C?.homeAssistant]);m.useEffect(()=>{function ie(pe){if(B0()||qA(pe))return;const ge=T0(pe);if(ge.length===0)return;const Oe=new Set(ge);if(ot(T.chatFocus,Oe)){pe.preventDefault(),ne(),A||N();return}ge.some(le=>B.has(le))&&pe.preventDefault();const Y=ge.filter(le=>!L.current.has(le));if(Y.forEach(le=>L.current.add(le)),Y.length>0)if(Y.some(le=>T.driveMacro?.has(le)))l("drive"),d("drive-sequence");else if(Y.some(le=>T.dockMacro?.has(le)))l("dock"),d("seek-dock");else if(Y.some(le=>T.nightVisionToggle?.has(le)))x();else if(Y.some(le=>T.hornHonk?.has(le))){if(!re.current){const le=g();re.current=!!le}}else Y.some(le=>T.micPtt?.has(le))?b(!0):Y.some(le=>T.homeAssistantOn?.has(le))?ae("on"):Y.some(le=>T.homeAssistantOff?.has(le))&&ae("off");W(),U(),F()}function oe(pe){if(B0())return;T0(pe).forEach(Oe=>L.current.delete(Oe)),re.current&&!ot(T.hornHonk,L.current)&&(re.current=!1,y()),ot(T.micPtt,L.current)||b(!1),W(),U(),F()}function he(){ne()}return window.addEventListener("keydown",ie,{capture:!0}),window.addEventListener("keyup",oe,{capture:!0}),window.addEventListener("blur",he),()=>{window.removeEventListener("keydown",ie,{capture:!0}),window.removeEventListener("keyup",oe,{capture:!0}),window.removeEventListener("blur",he)}},[B,E,F,W,U,N,A,T.chatFocus,T.dockMacro,T.driveMacro,T.hornHonk,T.micPtt,ne,d,b,l,h,se,g,y,ae]);const me=m.useRef(ne);return m.useEffect(()=>{me.current=ne},[ne]),m.useEffect(()=>{me.current()},[a.roverId]),m.useEffect(()=>{re.current=!!a.horn?.active},[a.horn?.active]),m.useEffect(()=>()=>{R(),se()},[R,se]),null}const _A=1.6;function sg(a){if(!a)return"unknown::none::0::0";const l=a.id||"unknown",i=a.mapping||"none",o=Array.isArray(a.axes)?a.axes.length:0,f=Array.isArray(a.buttons)?a.buttons.length:0;return`${l}::${i}::${o}::${f}`}function OA(a){return JSON.parse(JSON.stringify(a??{}))}function ig(a,l){const i=OA(l);return i.meta={id:a?.id??"Unknown",mapping:a?.mapping??"none",axes:a?.axes?.length??0,buttons:a?.buttons?.length??0},i}function nl(a){return Number.isFinite(a)?Math.max(-1,Math.min(1,a)):0}function li(a,l){if(!a)return 0;const i=Math.abs(a);return l==="expo"?Math.sign(a)*Math.pow(i,_A):a}function Wu(a,l){const i=Math.abs(a);if(i<=l)return 0;const o=(i-l)/(1-l);return Math.sign(a)*o}function BA(a,l,i){const o=Math.hypot(a,l);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:a*d,y:l*d}}function io(a,l){if(!a||!Array.isArray(a.axes))return null;const i=a.axes[l];return Number.isFinite(i)?nl(i):null}function wf(a,l){if(!a||!Array.isArray(a.buttons))return null;const i=a.buttons[l];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function ef(a,l=[]){for(const i of l)if(i){if(i.kind==="axis"){const o=io(a,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=wf(a,i.index);if(!o)continue;return{value:nl(o.value),source:i}}}return{value:0,source:null}}function LA(a,l=[]){for(const i of l){if(!i||i.kind!=="axisPair")continue;const o=io(a,i.x),f=io(a,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function Pa(a,l=[]){for(const i of l)if(i){if(i.kind==="button"){const o=wf(a,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=io(a,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=wf(a,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function rg(a,l){const i=l?.bindings??{},o=l?.calibration??{},f=i.drive??{},d=LA(a,f.sources);let h=nl(d.x),p=nl(d.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=BA(h,p,x);h=li(g.x,o.driveCurve),p=li(g.y,o.driveCurve);const y=i.cameraTilt??{},b=ef(a,y.sources),j=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let q=Wu(nl(b.value),j);q=li(q,o.cameraCurve);const C=Math.min(Math.max(o.auxDeadzone??.05,0),.6),w=i.mainBrush??{},N=ef(a,w.sources);let E=Wu(nl(N.value),C);E=li(E,o.auxCurve);const A=i.sideBrush??{},M=ef(a,A.sources);let T=Wu(nl(M.value),C);T=li(T,o.auxCurve);const B=Pa(a,i.vacuum?.sources),Z=Pa(a,i.allAux?.sources),O=Pa(a,i.mainReverse?.sources),H=Pa(a,i.sideReverse?.sources),L=Pa(a,i.driveMacro?.sources),V=Pa(a,i.dockMacro?.sources),K=Pa(a,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:q,auxAxis:{main:E,side:T},buttons:{vacuum:B.pressed,allAux:Z.pressed,mainReverse:O.pressed,sideReverse:H.pressed,driveMacro:L.pressed,dockMacro:V.pressed,nightVisionToggle:K.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:N.source,sideBrush:M.source,vacuum:B.source,allAux:Z.source,mainReverse:O.source,sideReverse:H.source,driveMacro:L.source,dockMacro:V.source,nightVisionToggle:K.source}}}const eo=new Set;let Pl=null,ro={pads:[],timestamp:0};function zA(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const a=navigator.getGamepads();return a?Array.from(a).filter(Boolean):[]}function UA(a){return{index:a.index,id:a.id,mapping:a.mapping,connected:a.connected!==!1,timestamp:a.timestamp,axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0})),signature:sg(a)}}function HA(){ro={pads:zA().map(UA),timestamp:typeof performance<"u"?performance.now():Date.now()},eo.forEach(l=>l(ro))}function og(){HA(),Pl=requestAnimationFrame(og)}function VA(){Pl||(Pl=requestAnimationFrame(og))}function $A(){Pl&&(cancelAnimationFrame(Pl),Pl=null)}function cg(a){return eo.add(a),VA(),a(ro),()=>{eo.delete(a),eo.size===0&&$A()}}function GA(){const[a,l]=m.useState(ro);return m.useEffect(()=>cg(l),[]),a}const Kl="gamepad",Wa={x:0,y:0,boost:!1},el={main:0,side:0,vacuum:0},YA=100,FA=100;function tf(a,l){return a&&l&&a.x===l.x&&a.y===l.y&&a.boost===l.boost}function nf(a,l){return a&&l&&a.main===l.main&&a.side===l.side&&a.vacuum===l.vacuum}function XA(a){return a?Math.hypot(a.x||0,a.y||0):0}function QA(a){return a?!a.main&&!a.side&&!a.vacuum:!0}function KA(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function ZA(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:p}}=Mt(),{value:x,save:g}=Ze("gamepad",Ra),y=m.useRef(new Set),b=m.useRef(Wa),j=m.useRef(el),q=m.useRef({main:!1,side:!1}),C=m.useRef(new Map),w=m.useRef(0),N=m.useRef(0),E=m.useRef(0),A=m.useRef(null),M=m.useCallback(O=>{const H=O.signature??sg(O);x?.profiles?.[H]||y.current.has(H)||(y.current.add(H),g(L=>{const V=L??Ra;if(V.profiles?.[H])return V;const K=V?.defaults?.profile??aa,te=ig(O,K);return{...V,profiles:{...V.profiles??{},[H]:te}}}))},[x?.profiles,g]),T=m.useCallback((O,H)=>{const L=C.current.get(O)||!1;return C.current.set(O,H),H&&!L},[]),B=m.useCallback((O,H)=>{const L=a.camera?.config;if(!L)return;const V=typeof performance<"u"?performance.now():Date.now(),K=H?.cameraMode??"absolute",te=Math.max(1,Math.min(180,H?.cameraSensitivity??60));if(K==="velocity"){const X=Math.min(50,V-E.current||16),W=O*te*(X/1e3);if(Math.abs(W)<.01)return;const ue=(typeof A.current=="number"?A.current:typeof a.camera?.angle=="number"?a.camera.angle:typeof L.homeAngle=="number"?L.homeAngle:0)+W;f(ue),A.current=ue,E.current=V;return}const ce=typeof L.minAngle=="number"?L.minAngle:-45,re=typeof L.maxAngle=="number"?L.maxAngle:45,F=typeof L.homeAngle=="number"?L.homeAngle:(ce+re)/2,R=O<0?F+O*(F-ce):F+O*(re-F);typeof A.current=="number"&&Math.abs(A.current-R)<.35&&V-E.current<80||(E.current=V,A.current=R,f(R))},[f,a.camera?.angle,a.camera?.config]),Z=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>cg(O=>{const H=KA(O.pads,Z);if(!H){tf(b.current,Wa)||(b.current=Wa,i(Wa,{source:Kl})),nf(j.current,el)||(j.current=el,o(el)),C.current=new Map,q.current={main:!1,side:!1},w.current=0,N.current=0,p(Kl,{connected:!1});return}if(CA()){tf(b.current,Wa)||(b.current=Wa,i(Wa,{source:Kl})),nf(j.current,el)||(j.current=el,o(el)),C.current=new Map,q.current={main:!1,side:!1},p(Kl,{connected:!0,blocked:!0});return}M(H);const L=H.signature,V=x?.profiles?.[L]??x?.defaults?.profile??aa,K=rg(H,V);if(!tf(K.driveVector,b.current)){const W=typeof performance<"u"?performance.now():Date.now();(XA(K.driveVector)<.02||W-w.current>=YA)&&(b.current=K.driveVector,w.current=W,i(K.driveVector,{source:Kl}))}const te=V.calibration?.auxSideScale??.55,ce=Math.round(Math.min(Math.abs(K.auxAxis.main),1)*127),re=Math.round(Math.min(Math.abs(K.auxAxis.side),1)*127),F=q.current.main?-ce:ce,R=q.current.side?-Math.round(re*te):Math.round(re*te);let X={main:K.auxAxis.main!==0?F:0,side:K.auxAxis.side!==0?R:0,vacuum:K.buttons.vacuum?127:0};if(K.buttons.allAux&&(X={main:127,side:127,vacuum:127}),!nf(X,j.current)){const W=typeof performance<"u"?performance.now():Date.now();(QA(X)||W-N.current>=FA)&&(j.current=X,N.current=W,o(X))}K.buttons.mainReverse&&T("mainReverse",!0)?q.current.main=!q.current.main:K.buttons.mainReverse||T("mainReverse",!1),K.buttons.sideReverse&&T("sideReverse",!0)?q.current.side=!q.current.side:K.buttons.sideReverse||T("sideReverse",!1),K.buttons.driveMacro&&T("driveMacro",!0)?(l("drive"),d("drive-sequence")):K.buttons.driveMacro||T("driveMacro",!1),K.buttons.dockMacro&&T("dockMacro",!0)?(l("dock"),d("seek-dock")):K.buttons.dockMacro||T("dockMacro",!1),K.buttons.nightVisionToggle&&T("nightVisionToggle",!0)?h():K.buttons.nightVisionToggle||T("nightVisionToggle",!1),Math.abs(K.cameraAxis)>.001&&B(K.cameraAxis,V.calibration),p(Kl,{connected:!0,signature:L,id:H.id,index:H.index,axes:H.axes,buttons:H.buttons,drive:K.driveVector,aux:X,cameraAxis:K.cameraAxis,bindings:K.sources})}),[Z,M,x?.defaults?.profile,x?.profiles,T,B,p,d,o,i,l,h]),null}function ug(a){const l=a?.sensors||{},i=l.oiMode?.label||"Unknown",o=i.toLowerCase(),f=l.chargingState?.label||"",d=!!l.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function fg(a){const l=ss(a);return m.useMemo(()=>ug(l),[l])}function Zl({label:a,value:l,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:l})})}function U0({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function af({label:a,tone:l}){const i=l==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":l==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:a})}function IA({instructions:a,onConfirm:l,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:a.summary}),r.jsx(Cf,{steps:a.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick:l,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function dg({layout:a="desktop",expand:l=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=a==="mobile",{state:{roverId:h,keymap:p},actions:x}=Mt(),g=ss(h),y=o??ug(g),{driving:b,docked:j,charging:q,dockingInProgress:C}=y,[w,N]=m.useState(null),[E,A]=m.useState(!1),[M,T]=m.useState(!1),B=!h||w!==null,Z=!h||w!==null,O=Nn(p?.driveMacro?.[0]),H=Nn(p?.dockMacro?.[0]),L={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.",K={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},te=j?"Docked":"Undocked",ce=j?"good":"bad",re=q?"Charging":j?"Charging in 5s":"—",F=q?"good":j?"warn":"bad",R=async()=>{if(!(!h||w)){N("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ae){alert(Ae.message)}finally{N(null)}}},X=async()=>{if(!(!h||w)){A(!1),T(!1),N("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ae){alert(Ae.message)}finally{N(null)}}},W=async()=>{if(!(!h||w)){N("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(Ae){alert(Ae.message)}finally{N(null),A(!1),T(!1)}}},se=()=>{Z||(T(!0),A(!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",k="text-center",U="items-center justify-between",ne="items-center justify-center",ae=d?"text-sm font-semibold":"",me="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ie="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",oe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",he="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ge=l||C,Oe=ge?"h-full flex-1":i?"flex-1":"",Y=d&&!ge?f:"",le=d&&!ge?ne:U,fe=d&&!ge&&b&&j;if(!b&&!C)return r.jsxs("button",{type:"button",onClick:X,onContextMenu:Ae=>Ae.preventDefault(),disabled:B,className:`${ue} ${Oe} ${Y} ${k} ${le} ${ae} ${me}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&ge?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[O?r.jsx(U0,{label:O}):null,r.jsx(af,{label:"Click to start",tone:"emerald"})]}):null]}),ge?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:K.summary}),r.jsx(Cf,{steps:K.steps,tone:"emerald"})]}):null]}),ge?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Zl,{label:"Dock",value:te,tone:ce}),r.jsx(Zl,{label:"Charge",value:re,tone:F})]}):null]});if(C){const Ae={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:B,onClick:R,onContextMenu:Ve=>Ve.preventDefault(),className:`${ue} ${Oe} ${Y} ${k} ${le} ${ae} ${ie}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),ge?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(af,{label:"Return to driving mode",tone:"emerald"})}):null]}),ge?r.jsx("p",{className:"text-sm text-amber-50/90",children:Ae.summary}):null]}),ge?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Zl,{label:"Dock",value:te,tone:ce}),r.jsx(Zl,{label:"Charge",value:re,tone:F})]}),d?null:r.jsx(Cf,{steps:Ae.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:Z,onClick:se,onContextMenu:Ae=>Ae.preventDefault(),className:d?`flex w-full ${ue} ${Y} ${k} ${le} ${ae} ${fe?he:oe}`:`${ue} ${Oe} ${k} ${U} ${ae} ${oe}`,children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:fe?"Docked!":"Dock and Charge"}),!d&&ge?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[H?r.jsx(U0,{label:H}):null,r.jsx(af,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&ge&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:V}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Zl,{label:"Dock",value:te,tone:ce}),r.jsx(Zl,{label:"Charge",value:re,tone:F})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),M||!d&&E?r.jsx(IA,{instructions:L,pending:w==="dock",onCancel:()=>{T(!1),A(!1)},onConfirm:W}):null]})}function Cf({steps:a,tone:l="emerald"}){const i=l==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":l==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=l==="emerald"?"text-emerald-200":l==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:a.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<a.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function lf(a){return typeof a=="boolean"}function mg({nightVisionOn:a,disabled:l,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,p]=m.useState(lf(a)?a:null);m.useEffect(()=>{lf(a)&&p(a)},[a]);const x=lf(h),g=x?h:!1,y=x?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",j=()=>{if(l)return;const C=x?!g:!0;p(C),i?.(C)},q=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:j,onContextMenu:C=>C.preventDefault(),disabled:l,"aria-pressed":g,className:q,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:y})]})}function sf(a){const l=Number(a);return!Number.isFinite(l)||l<=0?0:Math.min(5e3,Math.round(l))}function hg({disabled:a,onStart:l,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[y,b]=m.useState(!1),[j,q]=m.useState(p),{value:C,save:w}=Ze("horn",al),[N,E]=m.useState(C?.waveform||al.waveform),[A,M]=m.useState(()=>[...Array.isArray(C?.freqs)?C.freqs:al.freqs,0,0,0,0].slice(0,4).map(R=>sf(R)));m.useEffect(()=>{E(C?.waveform||al.waveform),Array.isArray(C?.freqs)&&M([...C.freqs,0,0,0,0].slice(0,4).map(F=>sf(F)))},[C?.freqs,C?.waveform]);const T=!!f,B=Math.max(0,Math.min(1,Number(d)||0)),Z=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",T?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,T]),O=()=>{a||y||(b(!0),l?.())},H=()=>{y&&(b(!1),i?.())};m.useEffect(()=>{!T&&y&&b(!1)},[T,y]);const L=N==="sine"?"sine":"saw",V=m.useCallback(F=>{const R=F.target.value==="sine"?"sine":"saw";E(R),w(X=>({...X??{},waveform:R}))},[w]),K=m.useCallback((F,R)=>{M(X=>{const W=[...X];return W[F]=sf(R),w(se=>({...se??{},freqs:W})),W})},[w]),te=F=>{if(a)return;const R=F.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||(F.preventDefault(),O())},ce=F=>{const R=F.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||(F.preventDefault(),H())},re=x?r.jsx("button",{type:"button",onClick:F=>{F.preventDefault(),q(R=>!R)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:j?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":y,onPointerDown:te,onPointerUp:ce,onPointerLeave:H,onPointerCancel:H,onContextMenu:F=>F.preventDefault(),onBlur:H,className:Z,children:[r.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}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${T?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),re,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${T?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:T?"Honk":"Hold"})]}),j?g?r.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:L,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:A.map((F,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:F,onChange:X=>K(R,X.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:L,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),A.map((F,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:F,onChange:X=>K(R,X.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))]}):null]})}function $r(a){return typeof a!="number"||Number.isNaN(a)?"—":`${a>0?"+":""}${a.toFixed(1)}°`}function H0({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function pg({value:a,min:l,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:y,keyUpLabel:b,className:j="",labelRowClass:q="",labelClass:C="",valueClass:w="",sliderClass:N="",endpointClass:E="",endpointLabelClass:A="",accentClass:M="",showValue:T=!0,showEndpoints:B}){const Z=d==="vertical",H=typeof B=="boolean"?B:!Z,[L,V]=m.useState(a),K=m.useRef(!1),te=m.useRef(null);m.useEffect(()=>{K.current||V(a)},[a]),m.useEffect(()=>()=>{te.current&&clearTimeout(te.current)},[]);const ce=W=>{if(h){if(x>0){te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{h(W)},x);return}h(W)}},re=W=>{const se=Number.parseFloat(W.target.value);Number.isNaN(se)||(K.current=!0,V(se),ce(se))},F=()=>{K.current=!1,te.current&&(clearTimeout(te.current),te.current=null),p?p(L):x>0&&h?.(L)};if(typeof l!="number"||typeof i!="number")return null;const R=[Z?"h-28 w-5":"w-full",M,N].filter(Boolean).join(" "),X=r.jsx("input",{type:"range",orient:Z?"vertical":void 0,min:l,max:i,step:o,value:Number.isFinite(L)?L:l,onChange:re,onMouseUp:F,onTouchEnd:F,onPointerUp:F,disabled:g,className:R,style:Z?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return Z?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${j}`.trim(),children:[T?r.jsx("div",{className:`flex flex-col items-center ${q}`.trim(),children:r.jsx("span",{className:w,children:$r(a)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:C,children:f}),X]})]}):r.jsxs("div",{className:`space-y-0.5 ${j}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${q}`.trim(),children:[r.jsx("span",{className:C,children:f}),T?r.jsx("span",{className:w,children:$r(a)}):null]}),r.jsxs("div",{children:[X,H?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${E}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[y?r.jsx(H0,{label:y}):null,$r(l)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${A}`.trim(),children:[$r(i),b?r.jsx(H0,{label:b}):null]})]}):null]})]})}const Gr="mobile-joystick",JA=80,PA=.15,WA={main:0,side:0,vacuum:0},ej={main:127,side:127,vacuum:127},tj={main:-127,side:-127,vacuum:-127};function nj({disabled:a,layout:l,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),y=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(w=>{if(a||h.current!==null)return;w.preventDefault();const N=d.current;if(!N)return;const E=N.getBoundingClientRect(),A=w.clientX-E.left,M=w.clientY-E.top;p.current={x:A,y:M},h.current=w.pointerId,N.setPointerCapture?.(w.pointerId),g({active:!0,base:{x:A,y:M},knob:{x:0,y:0}})},[a]),j=m.useCallback(w=>{if(a||h.current!==w.pointerId)return;w.preventDefault();const N=d.current;if(!N)return;const E=N.getBoundingClientRect(),A=w.clientX-E.left,M=w.clientY-E.top,T=A-p.current.x,B=M-p.current.y,Z=Math.min(Math.hypot(T,B),i),O=Math.atan2(B,T),H=Math.cos(O)*Z,L=Math.sin(O)*Z,V={x:ts(H/i),y:ts(-L/i),boost:!1};g(K=>({...K,knob:{x:H,y:L}})),o?.(V)},[a,o]),q=m.useCallback(w=>{if(h.current!==w.pointerId)return;w.preventDefault(),d.current?.releasePointerCapture?.(w.pointerId),y()},[y]);return m.useEffect(()=>{a&&y()},[a,y]),r.jsxs("div",{ref:d,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:j,onPointerUp:q,onPointerLeave:q,onPointerCancel:q,onContextMenu:w=>w.preventDefault(),children:[!x.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:x.base.x,top:x.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function aj({layout:a}){const{state:{roverId:l},actions:{setDriveVector:i,registerInputState:o}}=Mt(),f=fg(l),d=f.docked&&!f.driving,h=d||f.dockingInProgress,p=!l,x=JA,g=PA,y=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(y.current={x:0,y:0,boost:!1})},[p]);const b=m.useCallback((w={})=>{if(p)return;const N={x:ts(w.x??0),y:ts(w.y??0),boost:!!w.boost},E={x:y.current.x+(N.x-y.current.x)*(1-g),y:y.current.y+(N.y-y.current.y)*(1-g),boost:N.boost};y.current=E,i(E,{source:Gr}),o(Gr,{vector:E,lastEvent:"move"})},[p,o,i,g]),j=m.useCallback(()=>{if(p)return;const w={x:0,y:0,boost:!1};y.current=w,i(w,{source:Gr}),o(Gr,{vector:w,lastEvent:"stop"})},[p,o,i]),C=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:C,children:[r.jsx(dg,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(nj,{disabled:p,layout:a,radius:x,onMove:b,onStop:j})})]})}function V0({id:a,label:l,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:p=>{p.preventDefault(),d(a,i)},onPointerUp:()=>h(a),onPointerLeave:()=>h(a),onPointerCancel:()=>h(a),onContextMenu:p=>p.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:l})}function lj({layout:a}){const{state:{roverId:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=Mt(),y=!l,b=m.useRef(null),j=i?.config,q=!!(l&&i?.enabled&&j),C=!!(l&&f?.nightVision),w=f?.nightVisionState,N=!!(l&&f?.horn),E=o?.overheated,A=typeof j?.minAngle=="number"?j.minAngle:-45,M=typeof j?.maxAngle=="number"?j.maxAngle:45,T=typeof i?.angle=="number"?i.angle:typeof j?.homeAngle=="number"?j.homeAngle:(A+M)/2,B=m.useCallback(H=>{C&&h(H)},[C,h]),Z=m.useCallback((H,L)=>{y||(b.current=H,p(L))},[y,p]),O=m.useCallback(H=>{y||b.current===H&&(b.current=null,p(WA))},[y,p]);return r.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[r.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[r.jsx(V0,{id:"aux-vac-forward",label:"Vacuum Forward",values:ej,color:"bg-fuchsia-600",disabled:y,onPress:Z,onRelease:O}),r.jsx(V0,{id:"aux-vac-backward",label:"Vacuum Backward",values:tj,color:"bg-fuchsia-800",disabled:y,onPress:Z,onRelease:O})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[q?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(pg,{value:T,min:A,max:M,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,C?r.jsx(mg,{nightVisionOn:w?.nightVisionOn,disabled:y,onToggle:B,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:N?r.jsx(hg,{disabled:y||E,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function oo({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(lj,{layout:a})})}function co({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(aj,{layout:a==="landscape"?"landscape":"portrait"})})}function sj({swapColumns:a=!1}){const l="h-[min(60svh,24rem)]",i=a?r.jsx(co,{layout:"portrait",className:l}):r.jsx(oo,{layout:"portrait",className:l}),o=a?r.jsx(oo,{layout:"portrait",className:l}):r.jsx(co,{layout:"portrait",className:l});return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[i,o]})})}function ij(a=[],l={}){const i=On(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>a.map(C=>typeof C=="string"?C:C.id),[a]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),y=m.useRef([]),[b,j]=m.useState(0),q=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>j(w=>w+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let C=!1;const w=y.current,N=(A={},M)=>{if(C||!A.id||!M)return;const T=M.byteLength??M.length??0,B=Date.now(),Z=q.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:Z.count+1,totalBytes:Z.totalBytes+T,lastLogAt:Z.lastLogAt};if(!O.lastLogAt||B-O.lastLogAt>=1e4){const K=O.count?O.totalBytes/O.count:0;console.log("[roomCamera]",A.id,`frame=${T}B`,`avg=${Math.round(K)}B`,`count=${O.count}`),O.lastLogAt=B}q.current.set(A.id,O);const H=new Blob([M],{type:"image/jpeg"}),L=URL.createObjectURL(H),V=p.current.get(A.id);V&&URL.revokeObjectURL(V),p.current.set(A.id,L),h(K=>({...K,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:L}}))},E=(A={})=>{C||!A.id||h(M=>({...M,[A.id]:{...M[A.id]||{},status:A.error?"error":M[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||M[A.id]?.ts||null,objectUrl:M[A.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",N),i.on("roomCamera:status",E),i.emit("roomCamera:subscribe",{ids:w},(A={})=>{A.error}),()=>{C=!0,i.emit("roomCamera:unsubscribe",{ids:w}),i.off("roomCamera:frame",N),i.off("roomCamera:status",E),p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear()}},[i,g,o,b]),d}function rj({feed:a,label:l}){const[i,o]=m.useState(!1);m.useEffect(()=>{a&&(!a.ts&&!a.objectUrl||o(d=>!d))},[a?.ts,a?.objectUrl]);const f=m.useMemo(()=>a?a.error?`Error: ${a.error}`:a.status||"Connecting…":"Connecting…",[a]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[a?.objectUrl?r.jsx("img",{src:a.objectUrl,alt:l,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:l}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function oj(){return r.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),r.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const xg=["horizontal","vertical"];function rf(a,l){return xg.includes(a)?a:l}function Jf({defaultOrientation:a="horizontal",orientation:l,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=_e(),h=d?.roomCameras||[],p=ij(h.map(N=>({id:N.id}))),{value:x,save:g}=Ze("roomCameraPanels",{}),[y,b]=m.useState(()=>rf(f?x?.[f]:a,"horizontal"));m.useEffect(()=>{if(!f)return;const N=x?.[f];N&&b(rf(N,"horizontal"))},[f,x?.[f]]);const j=l?rf(l,"horizontal"):y,q=j==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!i&&!l&&h.length>0,w=N=>{b(N),f&&g(E=>({...E||{},[f]:N}))};return h.length===0?r.jsx(oj,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:C&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:xg.map(N=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${j===N?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>w(N),children:N==="vertical"?"Vertical":"Grid"},N))})]})})]}),r.jsx("div",{className:q,children:h.map(N=>{const E=p[N.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(rj,{feed:E,label:N.name||N.id})},N.id)})})]})}function Pf(){const{logs:a}=_e();return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:a.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?r.jsx("p",{children:"No logs yet."}):a.slice().reverse().map(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",l.level,"]"]})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{children:l.message})]},l.id))})]})}function cj(a){if(!a)return null;if(typeof a=="string"){const l=String(a).trim();return l?{type:"rover",id:l,key:l}:null}if(typeof a=="object"){if(a.type&&a.id){const l=String(a.id);let i=a.key;return i||(i=a.type==="room"?`room:${l}`:l),{type:a.type,id:l,key:i}}if(a.roverId){const l=String(a.roverId);return{type:"rover",id:l,key:a.key||l}}if(a.roomCameraId){const l=String(a.roomCameraId);return{type:"room",id:l,key:a.key||`room:${l}`}}}return null}function uj(a=[]){const l=new Set,i=[];return a.forEach(o=>{!o?.key||l.has(o.key)||(l.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function mi(a=[],l={}){const i=On(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(a)?uj(a.map(cj).filter(Boolean)):[],[a]),x=m.useMemo(()=>{const q=p.map(C=>`${C.type}:${C.id}:${C.key}`).join("|");return f?`${q}|v:${f}`:q},[p,f]),g=m.useRef([]),[y,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const q=()=>b(C=>C+1);return i.on("connect",q),()=>{i.off("connect",q)}},[i]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const q=g.current;let C=!1;function w(N){const E=N.type==="room"?{roomCameraId:N.id}:{roverId:N.id};i.emit("video:request",E,(A={})=>{C||h(M=>({...M,[N.key]:A}))})}return q.forEach(N=>{w(N)}),()=>{C=!0}},[i,x,o,y]),m.useMemo(()=>{if(!x||!o)return{};const q={};return p.forEach(C=>{d[C.key]&&(q[C.key]=d[C.key])}),q},[x,d,p])}function Wf(a=[],l={}){const i=On(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>a.map(C=>typeof C=="string"?C:C.id).filter(Boolean),[a]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),y=m.useRef([]),[b,j]=m.useState(0),q=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>j(w=>w+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{y.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear(),h({});return}if(!y.current.length||!i)return;let C=!1;const w=y.current,N=(A={},M)=>{if(C||!A.id||!M)return;const T=M.byteLength??M.length??0,B=Date.now(),Z=q.current.get(A.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:Z.count+1,totalBytes:Z.totalBytes+T,lastLogAt:Z.lastLogAt};if(!O.lastLogAt||B-O.lastLogAt>=1e4){const K=O.count?O.totalBytes/O.count:0;console.log("[roverSnapshot]",A.id,`frame=${T}B`,`avg=${Math.round(K)}B`,`count=${O.count}`),O.lastLogAt=B}q.current.set(A.id,O);const H=new Blob([M],{type:"image/jpeg"}),L=URL.createObjectURL(H),V=p.current.get(A.id);V&&URL.revokeObjectURL(V),p.current.set(A.id,L),h(K=>({...K,[A.id]:{status:"playing",ts:A.ts||Date.now(),error:null,objectUrl:L}}))},E=(A={})=>{C||!A.id||h(M=>({...M,[A.id]:{...M[A.id]||{},status:A.error?"error":M[A.id]?.status||"connecting",error:A.error||null,ts:A.ts||M[A.id]?.ts||null,objectUrl:M[A.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",N),i.on("roverSnapshot:status",E),i.emit("roverSnapshot:subscribe",{ids:w},(A={})=>{A.error}),()=>{C=!0,i.emit("roverSnapshot:unsubscribe",{ids:w}),i.off("roverSnapshot:frame",N),i.off("roverSnapshot:status",E),p.current.forEach(A=>URL.revokeObjectURL(A)),p.current.clear()}},[i,g,o,b]),d}const fj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function dj(a){if(typeof btoa=="function")return btoa(a);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function mj(a){if(!a)return{};const l=`${a}:${a}`;return{Authorization:`Basic ${dj(l)}`}}class $0{constructor({url:l,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=l,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(l,i){typeof this.onStatus=="function"&&this.onStatus(l,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const l=new RTCPeerConnection(fj);this.pc=l;const i=new MediaStream;l.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?l.addTransceiver("audio",{direction:"recvonly"}):(l.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&l.addTransceiver("audio",{direction:"recvonly"})),l.onconnectionstatechange=()=>{this.notify(l.connectionState)},l.oniceconnectionstatechange=()=>{const o=l.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await l.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await l.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...mj(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await l.setRemoteDescription({type:"answer",sdp:d}),l.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(l=>l.track?.stop()),this.pc.getReceivers().forEach(l=>l.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function Ef({sensors:a={},variant:l="full",size:i,overlay:o=!1}){const f=i||(l==="mini"?190:260),d=f/2,h=f*.07,p=d,x=d+h,g=d*.8,y=g-4,b=g+4,j=g-14,q=g-6,C=g*.65,w=a?.bumpsAndWheelDrops||{},N=a?.wheelOvercurrents||{},E=a?.wheelLeftCurrentMa??0,A=a?.wheelRightCurrentMa??0,M=a?.sideBrushCurrentMa??0,T=a?.mainBrushCurrentMa??0,B=6,Z=w.bumpLeft?B:0,O=w.bumpRight?B:0,H=bj({count:6,totalSpan:140,gap:6,startAngle:-70}),L=["L","FL","CL","CR","FR","R"],V=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],K=H.map((F,R)=>({label:L[R],start:F.start,end:F.end,value:V[R]})),te=[{label:"Cliff L",start:-60,end:-46,value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:a?.cliffRightSignal,active:a?.cliffRight}],ce=V.filter(F=>F!=null),re=ce.length?Math.max(...ce,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${f}px`,height:`${f}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),r.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",re]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:p,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(G0,{cx:p-C,cy:x,current:E,drop:w.wheelDropLeft,overcurrent:N.leftWheel,label:"L"}),r.jsx(G0,{cx:p+C,cy:x,current:A,drop:w.wheelDropRight,overcurrent:N.rightWheel,label:"R"}),r.jsx(xj,{cx:p+g*.65,cy:x-g*.55,current:M,overcurrent:N.sideBrush}),r.jsx(gj,{cx:p,cy:x,current:T,overcurrent:N.mainBrush,variant:l,dirtLeft:a?.dirtDetectLeft,dirtRight:a?.dirtDetect}),K.map(F=>{const R=vj(F.value,re),X=b+4,W=X+28;return r.jsx(hj,{cx:p,cy:x,rBase:W,rTip:X,startDeg:F.start,endDeg:F.end,color:R,value:F.value,max:re},F.label)}),te.map(F=>{const R=yj(F.value,F.active);return r.jsx(of,{cx:p,cy:x,rInner:j,rOuter:q,startDeg:F.start,endDeg:F.end,color:R,opacity:1,pulse:!!F.active},F.label)}),r.jsx(of,{cx:p,cy:x,rInner:y-Z,rOuter:b-Z,startDeg:-70,endDeg:-6,color:w.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpLeft}),r.jsx(of,{cx:p,cy:x,rInner:y-O,rOuter:b-O,startDeg:6,endDeg:70,color:w.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpRight})]})]})}function of({cx:a,cy:l,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:p=!1,opacity:x=1}){const g=(i+o)/2,y=o-i,b=pj(a,l,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:h,strokeWidth:y,strokeLinecap:"round",fill:"none",opacity:x}),p?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:y,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function hj({cx:a,cy:l,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:p,max:x}){const g=(f+d)/2,y=ci(a,l,o,g),b=go(p!=null?p/(x||1):0),j=Math.pow(b,.35),q=i-(i-o)*j,C=ci(a,l,q,f),w=ci(a,l,q,d),N=`M ${y.x} ${y.y} L ${C.x} ${C.y} L ${w.x} ${w.y} Z`;return r.jsx("path",{d:N,fill:h,opacity:1,stroke:"none"})}function pj(a,l,i,o,f){let d=o,h=f;h<=d&&(h+=360);const p=ci(a,l,i,d),x=ci(a,l,i,h);return["M",p.x,p.y,"A",i,i,0,0,1,x.x,x.y].join(" ")}function ci(a,l,i,o){const f=gg(o);return{x:a+i*Math.cos(f),y:l+i*Math.sin(f)}}function gg(a){return(a-90)*Math.PI/180}function ed(a,l){if(l)return"#ef4444";const i=Math.abs(a);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function go(a){return Math.max(0,Math.min(1,a))}function G0({cx:a,cy:l,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),p=go(h/1200),x=ed(i,f),g=56,y=14,b=9,j=3,q=g*p,C=d==="L"?-1:1,w=C*(-b/2-j/2),N=C*(y/2+j/2),E=y+b+j+2,A=g+4;return r.jsxs("g",{transform:`translate(${a},${l})`,children:[r.jsx("rect",{x:-E/2,y:-A/2,width:E,height:A,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:w-y/2,y:-g/2,width:y,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:w-y/2,y:g/2-q,width:y,height:q,fill:x,className:f?"animate-pulse":""}),r.jsx("rect",{x:N-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function xj({cx:a,cy:l,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=ed(i*3,o),h=43,p=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${a}px ${l}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[r.jsx("circle",{cx:a,cy:l,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const y=gg(g),b=a+h*Math.cos(y),j=l+h*Math.sin(y);return r.jsx("line",{x1:a,y1:l,x2:b,y2:j,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:a,cy:l,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function gj({cx:a,cy:l,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const p=Math.abs(i),x=ed(i,o),g=1,y=96,b=12,j=`main-brush-pattern-a-${f}`,q=`main-brush-pattern-b-${f}`,C=p>0?.6:null,w=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[j,q].map((N,E)=>r.jsxs("pattern",{id:N,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),C?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${w*(E===0?6:-6)}`,dur:`${C}s`,repeatCount:"indefinite"}):null]},N))}),r.jsx("rect",{x:a-y/2,y:l-14,width:y,height:b,rx:"3",fill:`url(#${j})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:a-y/2,y:l+4,width:y,height:b,rx:"3",fill:`url(#${q})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:a-y/4,cy:l-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:a+y/4,cy:l+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:a-y/2-4,y:l-16,width:y+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function vj(a,l){if(a==null||a<=0)return"hsl(200 60% 18%)";const o=go(a/(l||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function yj(a,l){if(l)return"#ef4444";const i=go(a==null?0:a/4095),o=[47,55,69],f=[245,158,11],[d,h,p]=o.map((x,g)=>Math.round(x+(f[g]-x)*i));return`rgb(${d}, ${h}, ${p})`}function bj({count:a,totalSpan:l,gap:i,startAngle:o}){const d=(l-i*(a-1))/a,h=[];let p=o;for(let x=0;x<a;x+=1){const g=p+d;h.push({start:p,end:g}),p=g+i}return h}function vg(){const{value:a,save:l}=Ze("page",{hudMapDesktop:!1});return[!!a?.hudMapDesktop,f=>{l({hudMapDesktop:!!f})}]}const Sj={discord:Kx,kofi:C0,"ko-fi":C0,wiki:QS,throne:KS},Aj={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 jj(){m.useEffect(()=>{if(typeof document>"u")return;const a="social-button-keyframes";if(document.getElementById(a))return;const l=document.createElement("style");l.id=a,l.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(l)},[])}function Nj(a,l){return typeof a=="string"&&a.trim()?a.trim().toLowerCase():typeof l=="string"&&l.trim()?l.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function td({id:a,label:l,url:i,className:o=""}){if(!i)return null;jj();const f=Nj(a,l),d=Sj[f]||ZS,h=Aj[f]||null,p=l||a||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),p]})}const hi=10;function yg({batteryState:a=null,charge:l=null,config:i=null}){const o=a?.percentDisplay!=null&&Number.isFinite(a.percentDisplay)?Math.round(a.percentDisplay):null,f=a?.warnActive??null,d=a?.urgentActive??null,h=i?.Full??null,p=i?.Warn??null,x=i?.Urgent??null,g=l??a?.charge??null;let y=o;if(y==null&&(y=wj({charge:g,full:h,warn:p,urgent:x})),y==null)return{available:!1};const b=Math.max(0,Math.min(1,y/100)),j=f??(p!=null&&g!=null&&g<=p),q=d??(x!=null&&g!=null&&g<=x);return{available:!0,percent:b,percentDisplay:y,warnActive:j,urgentActive:q,warnDisplayPercent:hi}}function wj({charge:a,full:l,warn:i,urgent:o}){if(a!=null&&l!=null&&i!=null&&o!=null&&l>i&&i>o){const f=hi/100,d=1-f;if(a<=o)return 0;if(a<=i){const p=(a-o)/(i-o);return Math.round(Math.max(0,Math.min(1,p))*hi)}if(a>=l)return 100;const h=(a-i)/(l-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const Cj=1600,Ej=800;function An(...a){return a.filter(Boolean).join(" ")}function kf({visual:a,orientation:l="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",p=l==="vertical",x=f??!h;if(!a?.available){if(h){const te=hi,ce=An("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!j&&"battery-tick-warn"),re=p?{bottom:`${te}%`}:{left:`${te}%`},F=An("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:F,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:ce,style:re})]})}return p?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=a.percentDisplay??0,y=Math.max(0,Math.min(100,g)),b=a.warnDisplayPercent??hi,j=!!a.urgentActive,q=!!a.warnActive,C=j?`${Ej}ms`:q?`${Cj}ms`:void 0,N=h?j||q?"bg-red-500/45":"bg-emerald-500/45":j||q?"bg-red-500":"bg-emerald-500",E=j||q?"bg-red-900/35":"bg-slate-900/35",A=j||q?"bg-red-900/45":"bg-slate-900/35",M=An(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const te=p?{height:`${y}%`}:{width:`${y}%`},ce=An("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",N,"transition-[width,height]",j&&"battery-urgent-flash"),re=An("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!j&&"battery-tick-warn"),F=p?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:M,children:[r.jsx("div",{className:An("absolute inset-0",E,j&&"battery-urgent-flash")}),r.jsx("div",{className:ce,style:{...te,animationDuration:C}}),r.jsx("div",{className:re,style:F})]})}const T=An("relative overflow-hidden rounded-sm border border-slate-800",j||q?A:"bg-zinc-900/90",j&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),B=p?{height:`${y}%`}:{width:`${y}%`},Z=An("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",N,"transition-[width,height]",j&&"battery-urgent-flash"),O=An("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!j&&"battery-tick-warn"),H=p?{bottom:`${b}%`}:{left:`${b}%`},L=`Battery ${g}%`,V=An("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",p?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),K=An("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:M,children:[r.jsxs("div",{className:T,children:[r.jsx("div",{className:Z,style:{...B,animationDuration:C}}),r.jsx("div",{className:O,style:H})]}),x&&!p?r.jsx("div",{className:V,children:r.jsx("span",{className:K,children:L})}):null,x&&p?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:K,children:[g,"%"]})}):null]})}const Y0=2e3,kj=3e3,Mj=3e3,qj=40,Rj=1e3;function pi({sessionInfo:a,audioSessionInfo:l,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,forceMute:h=!1,telemetryFrame:p,batteryConfig:x,layoutFormat:g="desktop",hudVariant:y="default",driverLabel:b=null,hudForceMap:j=!1,hudMapPosition:q="top-center",hudLabelScale:C=1,fitParent:w=!1,overcurrentLimiter:N=null,showTurnCue:E=!1,turnTimerText:A=null,turnSeconds:M=null,isActiveDriver:T=!1,idleSkipSeconds:B=null}){const{session:Z}=_e(),O=m.useRef(null),H=m.useRef(null),L=m.useRef(null),V=m.useRef(null),K=m.useRef(null),te=m.useRef(null),ce=m.useRef(null),re=m.useRef(null),[F,R]=m.useState("idle"),[X,W]=m.useState(null),[se,ue]=m.useState("idle"),[k,U]=m.useState(null),[ne,ae]=m.useState(0),[me,ie]=m.useState(0),[oe,he]=m.useState(!0),pe=!!l?.url,ge=i==="snapshot",Oe=p?.sensors,{value:Y}=Ze("audio",kt),le=Number.isFinite(Y?.masterVolume)?Y.masterVolume:kt.masterVolume,fe=Number.isFinite(Y?.roverVolume)?Y.roverVolume:kt.roverVolume,Ae=typeof Y?.mainBrushDuckEnabled=="boolean"?Y.mainBrushDuckEnabled:typeof Y?.autoLevelEnabled=="boolean"?Y.autoLevelEnabled:kt.mainBrushDuckEnabled,Ve=Number.isFinite(Y?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Y.mainBrushDuckAmount)):kt.mainBrushDuckAmount,Ie=Math.max(0,Math.min(1,le*fe)),qt=Oe?.batteryChargeMah??null,Wt=g==="desktop",ve=!Wt,Ce=ve?"top-right":q,[$e]=vg(),Tt=j||ve?!0:$e,Ue=yg({charge:qt,config:x}),vt=Oe?.wheelOvercurrents||null,ft=vt==null?[]:Object.entries(vt).filter(([,be])=>!!be).map(([be])=>be),_t=N?.caps||null,gn=N?.overcurrent?.groups||null,il=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),Ot=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),is=m.useMemo(()=>{if(!_t)return null;const be=Number.isFinite(_t?.drive?.cap)?_t.drive.cap:1,Je=Number.isFinite(_t?.aux?.cap)?_t.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(be,Je)))},[_t]),rs=!!N?.isActive,vn=ft.length?ft:rs?["limiter"]:[],bt=is??(ft.length?1:0),en=!!vn.length,dt=!!((Number(Oe?.mainBrushCurrentMa)||0)>qj||Oe?.wheelOvercurrents?.mainBrush),jo=Ae&&dt?1-Ve:1,rl=Math.max(0,Math.min(1,Ie*jo)),No=Ae&&dt&&Ve>0?`Volume decreased ${Math.round(Ve*1e3)/10}%`:null,Da=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Da.current={hasDedicatedAudio:pe,audioUrl:l?.url||null,mainBrushDuckEnabled:Ae,mainBrushDuckAmount:Ve,mainBrushActive:dt,baseRoverGain:Ie,effectiveRoverGain:rl}},[pe,l?.url,Ae,Ve,dt,Ie,rl]);const et=m.useCallback((be,Je={})=>{if(!il)return;const Pe=H.current,Ee=Da.current,Ge={event:be,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:Ee.hasDedicatedAudio,audioUrl:Ee.audioUrl,mainBrushDuckEnabled:Ee.mainBrushDuckEnabled,mainBrushDuckAmount:Ee.mainBrushDuckAmount,mainBrushActive:Ee.mainBrushActive,baseRoverGain:Ee.baseRoverGain,effectiveRoverGain:Ee.effectiveRoverGain,element:Pe?{muted:Pe.muted,volume:Pe.volume,paused:Pe.paused,ended:Pe.ended,readyState:Pe.readyState,networkState:Pe.networkState}:null,...Je};try{console.log(`[AudioDebug] ${be} ${JSON.stringify(Ge)}`)}catch{console.log("[AudioDebug]",be,Ge)}},[il,d]),ol=Z?.socials?.find(be=>String(be?.id||be?.label||"").toLowerCase()==="discord")?.url||Z?.discord?.invite||null;m.useEffect(()=>{Ot&&console.log("[OvercurrentHUD]",{overlayVisible:en,overlayMotors:vn,overlayFill:bt,limiterActive:rs,limiterCaps:_t,limiterGroups:gn,wheelOvercurrents:vt})},[Ot,bt,vn,en,rs,_t,gn,vt]),m.useEffect(()=>{et("settings/update")},[et]);const Gt=m.useCallback(()=>{clearTimeout(L.current),L.current=setTimeout(()=>ae(Date.now()),Y0)},[]),ra=m.useCallback(()=>{clearTimeout(V.current),V.current=setTimeout(()=>ie(Date.now()),Y0)},[]),Cn=m.useCallback(async()=>{const be=O.current;if(be)try{be.muted=!0,await be.play()}catch{}},[]),Ni=m.useCallback((be=0)=>{if(h||pe)return;clearTimeout(te.current);const Je=()=>{clearTimeout(te.current),te.current=setTimeout(()=>{h||Pe()},kj)},Pe=async()=>{const Ee=O.current;if(Ee)try{await Cn(),Ee.muted=!1,await Ee.play(),he(!1)}catch{Ee.muted=!0,he(!0),Je()}};te.current=setTimeout(Pe,be)},[Cn,h,pe]);m.useEffect(()=>()=>{clearTimeout(L.current),clearTimeout(V.current),clearTimeout(te.current),clearInterval(K.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{F==="playing"&&Ni(0)},[F,Ni]),m.useEffect(()=>{ge&&(R("snapshot"),W(null))},[ge]),m.useEffect(()=>{if(ge||!a?.url||!O.current)return;let be=!0,Je;const Pe=setTimeout(()=>he(!0),0),Ee=(Ge,jt)=>{be&&(et("video/status",{nextStatus:Ge,info:jt||null}),R(Ge),W(jt||null),Ge==="playing"&&Cn(),["error","failed","disconnected","closed"].includes(Ge)&&Gt())};return Je=new $0({url:a.url,token:a.token,video:O.current,receiveAudio:!pe,onStatus:Ee}),Je.start().catch(Ge=>{be&&(R("error"),W(Ge.message),Gt())}),()=>{be=!1,clearTimeout(Pe),Je?.stop()}},[ge,a?.url,a?.token,ne,Gt,Cn,pe,et]),m.useEffect(()=>{F==="stopped"&&a?.url&&Gt()},[F,a?.url,Gt]),m.useEffect(()=>{const be=H.current;if(!be||!l?.url){et("route/no-audio-url"),re.current=null;return}const Je=Math.max(0,Math.min(1,rl)),Pe=re.current==null?Math.max(0,Math.min(1,be.volume)):re.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),Je>Pe){const Ee=performance.now(),Ge=Pe,jt=Je-Ge,Bt=st=>{const Be=Math.min(1,(st-Ee)/Rj),nn=Ge+jt*Be;be.volume=nn,re.current=nn,Be<1?ce.current=requestAnimationFrame(Bt):ce.current=null};ce.current=requestAnimationFrame(Bt)}else be.volume=Je,re.current=Je;et("route/direct",{elementVolume:Je,duckEnabled:Ae,mainBrushActive:dt,duckAmount:Ve})},[l?.url,rl,Ae,dt,Ve,et]),m.useEffect(()=>{if(!l?.url||!H.current)return;let be=!0,Je;const Pe=(Ee,Ge)=>{be&&(et("audio/status",{nextStatus:Ee,info:Ge||null}),U(Ge||(Ee==="connected"?"connected":null)),ue(jt=>Ee==="connected"&&(jt==="playing"||jt==="connecting")||Ee==="new"?jt:Ee),["error","failed"].includes(Ee)&&ra())};return Je=new $0({url:l.url,token:l.token,video:H.current,audioOnly:!0,onStatus:Pe}),Je.start().catch(Ee=>{be&&(ue("error"),U(Ee.message),ra())}),()=>{be=!1,Je?.stop()}},[l?.url,l?.token,me,ra,et]),m.useEffect(()=>{const be=H.current;if(!l?.url||!be){clearInterval(K.current);return}if(!["connecting","connected","playing","paused"].includes(se)){clearInterval(K.current);return}const Pe=async()=>{const Ee=H.current;Ee&&(Ee.muted=!1,!(!Ee.paused&&!Ee.ended)&&(et("retry/play-attempt"),Ee.play().then(()=>{et("retry/play-ok"),ue(Ge=>Ge==="connected"?"playing":Ge),U(Ge=>Ge==="paused"?null:Ge)}).catch(Ge=>{et("retry/play-fail",{error:Ge?.message}),U(jt=>jt||Ge?.message||"autoplay blocked")})))};return Pe(),K.current=setInterval(Pe,Mj),()=>clearInterval(K.current)},[l?.url,se,et]),m.useEffect(()=>{const be=H.current;if(!be)return;const Je=()=>{et("element/play"),ue(Be=>Be==="error"?Be:"playing"),U(null)},Pe=()=>{et("element/pause"),ue(Be=>["error","failed","disconnected","closed","stopped"].includes(Be)?Be:"paused"),U(Be=>Be||"paused")},Ee=()=>{et("element/ended"),ue(Be=>Be==="error"?Be:"stopped"),U(Be=>Be||"ended")},Ge=()=>{const{error:Be}=be,nn=Be?.message||"audio error";et("element/error",{error:nn}),ue("error"),U(nn)},jt=()=>et("element/waiting"),Bt=()=>et("element/canplay"),st=()=>et("element/stalled");return be.addEventListener("play",Je),be.addEventListener("pause",Pe),be.addEventListener("ended",Ee),be.addEventListener("error",Ge),be.addEventListener("waiting",jt),be.addEventListener("canplay",Bt),be.addEventListener("stalled",st),()=>{be.removeEventListener("play",Je),be.removeEventListener("pause",Pe),be.removeEventListener("ended",Ee),be.removeEventListener("error",Ge),be.removeEventListener("waiting",jt),be.removeEventListener("canplay",Bt),be.removeEventListener("stalled",st)}},[l?.url,et]);const wi=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",os=ge?wi:a?.url?F==="error"?`Error: ${X||"unknown"}`:X?`${F} (${X})`:F:"waiting",_a=l?.error?`Error: ${l.error}`:l?.url?se==="error"?`Error: ${k||"unknown"}`:k?`${se} (${k})`:se:null,Ci=y==="spectator",tn=y==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[ge?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:O,muted:h||oe||pe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:H,autoPlay:!0,hidden:!0}),!tn&&E?r.jsx(_j,{mobileHud:ve,turnSeconds:M,isActiveDriver:T,idleSkipSeconds:B}):null,tn?null:r.jsx(Dj,{frame:p,sensors:Oe,label:d,status:os,audioStatus:_a,levelStatus:No,desktopLayout:Wt,layoutFormat:g,variant:y,driverLabel:b,battery:Ue,showTopDown:Tt,mobileHud:ve,mapPosition:Ce,turnTimerText:A,labelScale:C}),tn?null:r.jsx(zj,{compact:ve}),!tn&&Ot?r.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${en?1:0} motors:${vn.length} fill:${Math.round(bt*100)}%`}):null,tn?null:r.jsx(Bj,{motors:vn,fill:bt,compact:ve}),tn?null:r.jsx(Lj,{battery:Ue,compact:ve}),!tn&&Ci&&Ue.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(kf,{visual:Ue,orientation:"vertical",variant:"inline",compact:ve,className:"h-full w-4"})}):null,!tn&&f?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:r.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${ve?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:f}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(td,{id:"discord",label:"Join our Discord server while you wait!",url:ol})})]})}):null]}),!tn&&!Ci&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Tj,{sensors:Oe}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(kf,{visual:Ue,compact:ve})})]})]})}function Tj({sensors:a}){const l=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],i=l.filter(p=>p!=null).reduce((p,x)=>Math.max(p,x),1200),o=p=>Math.pow(Math.max(0,Math.min(1,(p??0)/i)),.35),f=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:l.map((p,x)=>{const g=o(p),y=x<d/2?-1:1,b=`${g*100}%`,j=f(p);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:b,background:j,float:y===-1?"right":"left"}})})},x)})})}function Dj({frame:a,sensors:l,label:i,status:o,audioStatus:f,levelStatus:d,desktopLayout:h=!0,layoutFormat:p="desktop",variant:x="default",driverLabel:g=null,battery:y,showTopDown:b=!1,mobileHud:j=!1,mapPosition:q="top-center",turnTimerText:C=null,labelScale:w=1}){l?.bumpsAndWheelDrops;const[N,E]=m.useState(()=>Date.now());m.useEffect(()=>{const W=setInterval(()=>E(Date.now()),150);return()=>clearInterval(W)},[]),a?.receivedAt&&N-a.receivedAt<200;const A=j,M=p==="mobile-portrait",T=A?"text-[0.45rem]":"text-[0.65rem]",B=A?"px-0.25 py-0.25":"px-1 py-0.5",Z=A?"px-0.25 py-0.25":"px-0.5 py-0.5",O=A?"text-[0.55rem]":"text-[0.8rem]",H=A?"left-0.5 top-0.5":"left-1 top-1",L=A?"text-[0.5rem]":"text-[0.7rem]",V=A?"px-0.5 py-0.25":"px-1 py-0.5",K=A?"left-0.5 top-1/2":"left-1 top-1/2",te="bottom-0.5",ce={transform:`translateX(-50%) scale(${w})`,transformOrigin:"center bottom"},re="240px",F=M?.3:A?.33:.7,X={width:re,height:re,opacity:A?.6:.7,transform:q==="top-center"?`translateX(-50%) scale(${F})`:`scale(${F})`,transformOrigin:q==="bottom-left"?"bottom left":q==="top-center"?"top center":"top right",...q==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:q==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(x==="none")return null;if(x==="spectator"){const W=[["Voltage",l?.voltageMv!=null?`${(l.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",l?.currentMa!=null?`${l.currentMa} mA`:"--"],["Charge",l?.batteryChargeMah!=null?`${l.batteryChargeMah}`:"--"],["OI",l?.oiMode?.label||"--"]],se=!!l?.chargingSources?.homeBase,ue=l?.chargingState?.label||"",k=!!(ue&&ue.toLowerCase()!=="not charging"),U=l?.oiMode?.label||"Unknown",ne=U.toLowerCase(),ae=ne==="full"?"bg-emerald-500/80 text-emerald-50":ne==="safe"?"bg-amber-400/80 text-amber-950":ne==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",me=se?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",ie=k?"bg-emerald-500/80 text-emerald-50":se?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${H} font-medium text-slate-100 ${T}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),r.jsx("div",{className:`absolute ${K} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${T} ${B}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${me}`,children:se?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ie}`,children:k?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ae}`,children:["OI: ",U]})]}),W.map(([oe,he])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:oe}),r.jsx("span",{className:"font-semibold text-white",children:he})]},oe))]})}),r.jsx("div",{className:`absolute ${te} left-1/2`,style:ce,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${Z} ${O}`,children:[r.jsx("span",{className:"font-semibold text-white",children:i||"Unnamed Rover"}),g?r.jsxs("span",{className:"text-slate-300",children:["• ",g]}):null]})})]}),b?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...X},children:r.jsx(Ef,{sensors:l,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${H} font-medium text-slate-100 ${T}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),C?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${V} ${L}`,children:C}):null,r.jsx("div",{className:`absolute ${te} left-1/2`,style:ce,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${Z} ${O}`,children:r.jsxs("span",{children:['Rover: "',i||"Unnamed Rover",'"']})})}),b&&x!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...X},children:r.jsx(Ef,{sensors:l,size:240,overlay:!0})}):null]})}function _j({mobileHud:a=!1,turnSeconds:l=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=a?"text-3xl":"text-5xl",d=a?"text-xs":"text-sm",h=a?"text-[0.55rem]":"text-[0.75rem]",p=a?"px-4 py-3":"px-6 py-4",x=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${p}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),x?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const Oj={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Bj({motors:a,fill:l=0,compact:i=!1}){if(!a?.length)return null;const o=a.map(y=>Oj[y]||y),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",p=i?"text-xs":"text-xl",x=Math.max(0,Math.min(1,l)),g=`${Math.round(x*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}function Lj({battery:a,compact:l=!1}){if(!a?.available||!a.warnActive&&!a.urgentActive)return null;const i=a.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=l?"p-2 top-6":"p-4 top-10",f=l?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function zj({compact:a=!1}){const{session:l}=_e(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:p}=Kf(),{value:x}=Ze("tts",{engine:"flite",voice:"rms",pitch:50}),[g,y]=m.useState(""),[b,j]=m.useState(!1),q=l?.role!=="spectator",C=l?.role==="spectator",w=l?.assignment?.roverId||null,E=!!m.useMemo(()=>l?.roster?.find(O=>String(O.id)===String(w))||null,[w,l?.roster])?.audio?.ttsEnabled,A=m.useMemo(()=>{if(!E)return null;const O=x?.engine==="espeak"?"espeak":"flite";if(O==="espeak"){let L=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof L=="number"&&(L=Math.max(0,Math.min(99,L))),{speak:!0,engine:O,pitch:L}}const H=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:O,voice:H}},[x?.engine,x?.pitch,x?.voice,E]),M=a?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",T=a?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",B=a?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function Z(O){if(O.preventDefault(),!q)return;const H=g.trim();if(H){j(!0);try{await i(H,A),y(""),d(),p(!1)}catch(L){alert(L.message)}finally{j(!1)}}}return C?null:r.jsxs("form",{onSubmit:Z,className:M,children:[r.jsx("input",{className:T,value:g,onChange:O=>{const H=O.target.value;y(H),p(!!H.trim())},onFocus:O=>{o(O),p(!!g.trim())},onBlur:O=>{f(O),p(!1)},onKeyDown:O=>{O.key==="Enter"&&!g.trim()&&(O.preventDefault(),d(),p(!1))},ref:O=>h(O,{target:"hud"}),placeholder:q?"Chat (TTS)":"Spectator",disabled:!q}),r.jsx("button",{type:"submit",disabled:!q||b,className:B,children:"Speak"})]})}function nd({layoutFormat:a="desktop"}){const{session:l}=_e(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=Mt(),[d,h]=m.useState(()=>Date.now()),[p,x]=m.useState(!1),[g,y]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(l?.mode!=="turns")return;const ae=setInterval(()=>h(Date.now()),250);return()=>clearInterval(ae)},[l?.mode]);const j=l?.assignment?.roverId,C=!!(j&&l?.roster?l.roster.find(ae=>String(ae.id)===String(j)):null)?.media?.audioPublishUrl,w=j?l?.turnQueues?.[j]:null,N=l?.socketId||null,E=j?l?.activeDrivers?.[j]:null,A=!!(N&&E===N),M=m.useMemo(()=>{const ae=w?.queue||[];if(!ae.length||!w?.current||ae.length<=1)return null;const me=ae.findIndex(ie=>ie===w.current);return me===-1?ae[0]||null:ae[(me+1)%ae.length]||null},[w?.queue,w?.current]),T=!!(N&&M===N),B=w?.deadline||null,Z=w?.idleDeadline||null,O=B?B-d:null,H=Z?Z-d:null,L=l?.mode==="turns"&&T&&O!=null&&O<=5e3&&O>0,V=l?.mode!=="turns"||A||L,K=O!=null&&Number.isFinite(O)?Math.max(0,Math.ceil(O/1e3)):null,te=H!=null&&Number.isFinite(H)?Math.max(0,Math.ceil(H/1e3)):null,ce=A?K!=null?`${K}s left`:null:T&&K!=null?`Your turn in ${K}s`:null,re=j?[...V?[{type:"rover",id:j,key:j}]:[],...C?[{type:"rover",id:`${j}-audio`,key:`${j}-audio`}]:[]]:[],F=mi(re),R=j&&V?F[j]:null,X=j&&C?F[`${j}-audio`]:null,W=Wf(j?[j]:[],{enabled:!!j,version:l?.mode}),se=j&&W[j]||null,ue=ss(j),k=j&&l?.roster?l.roster.find(ae=>String(ae.id)===String(j)):null,U=k?.battery??null,ne=k?.name||(j?`Rover ${j}`:"");return m.useEffect(()=>{if(l?.mode!=="turns"){x(!1),y(null),b.current={active:!1,roverId:null};return}const ae=b.current,me=A&&!ae.active,ie=A&&j&&j!==ae.roverId;me||ie?(x(!0),y(Date.now())):!A&&ae.active&&(x(!1),y(null)),b.current={active:A,roverId:j}},[A,j,l?.mode]),m.useEffect(()=>{!p||!g||o>g&&x(!1)},[o,g,p]),r.jsx("section",{className:"panel",children:j?r.jsx(pi,{sessionInfo:R,videoMode:V?"whep":"snapshot",snapshotFeed:se,audioSessionInfo:X,label:ne,telemetryFrame:ue,batteryConfig:U,layoutFormat:a,overcurrentLimiter:f,songNote:i?.note,qualityNotice:V?null:"Preview feed (low FPS) until your turn.",showTurnCue:p,turnTimerText:ce,turnSeconds:K,isActiveDriver:A,idleSkipSeconds:te}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function Mf({label:a,tone:l="muted"}){const i=l==="success"?"bg-emerald-900 text-emerald-100":l==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:a})}function vo(a){if(!Number.isFinite(a))return 0;const l=a%360;return l<0?l+360:l}function Uj(a){if(!Array.isArray(a)||a.length<3)return 0;const[l,i,o]=a,f=Math.max(0,Math.min(255,Number(l)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(f,d,h),x=Math.min(f,d,h),g=p-x;if(g===0)return 0;let y=0;return p===f?y=(d-h)/g%6:p===d?y=(h-f)/g+2:y=(f-d)/g+4,vo(Math.round(y*60))}function F0(a){const l=vo(a),i=1,o=1-Math.abs(l/60%2-1);let f=0,d=0,h=0;return l<60?(f=i,d=o):l<120?(f=o,d=i):l<180?(d=i,h=o):l<240?(d=o,h=i):l<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function X0(a){return a?Array.isArray(a.hsColor)?vo(Number(a.hsColor[0])):Array.isArray(a.rgbColor)?Uj(a.rgbColor):0:0}function Hj({entity:a,connected:l,onToggle:i,onSetColor:o}){const f=a.state==="unavailable"||!a.available,d=a.state==="on",h=a.type==="light"&&a.supportsColor,p=f?"warn":d?"success":"muted",x=f?"Unavailable":d?"On":"Off",g=!l||f,y=g||!h,[b,j]=m.useState(()=>X0(a)),q=m.useRef(b),C=m.useRef(!1),w=f?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":d?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!h||C.current)return;const B=X0(a);q.current=B,j(B)},[a.rgbColor,a.hsColor,h]);const N=B=>{const Z=vo(Number(B.target.value));q.current=Z,j(Z)},E=()=>{y||!o||o(a.id,F0(q.current))},A=B=>{B.stopPropagation()},T=`rgb(${(h?F0(q.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>i(a.id),disabled:g,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${w} disabled:opacity-60 disabled:hover:bg-inherit`,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[r.jsx("span",{className:"truncate font-semibold text-white",children:a.name||a.id}),h&&r.jsxs(r.Fragment,{children:[r.jsx(Mf,{label:x,tone:p}),!l&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),h?r.jsx("div",{className:"-mt-0.5 w-full",onClick:A,onPointerDown:B=>{A(B),C.current=!0},onPointerUp:B=>{A(B),C.current=!1,E()},onPointerCancel:B=>{A(B),C.current=!1,E()},onKeyUp:B=>{A(B),E()},onBlur:E,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:b,onChange:N,disabled:y,"aria-label":`Set color for ${a.name||a.id}`,className:"ha-hue-slider w-full"})})}):r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsx(Mf,{label:x,tone:p}),!l&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),h&&r.jsx("span",{className:"pointer-events-none absolute right-1 top-1 h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:T}}),!h&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:d?"Turn off":"Turn on"})]})}function bg(){const{state:{keymap:a}}=Mt(),{session:l,homeAssistantToggle:i,homeAssistantSetLightColor:o}=_e(),f=l?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=Nn(a?.homeAssistantOn?.[0]),p=Nn(a?.homeAssistantOff?.[0]);if(!f?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(d.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const x=!!f?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:d.length}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"On"}),h?r.jsx(Q0,{label:h}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),p?r.jsx(Q0,{label:p}):null]})]})]}),r.jsx(Mf,{label:x?"Connected":"Offline",tone:x?"success":"warn"})]}),r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(g=>r.jsx(Hj,{entity:g,connected:x,onToggle:i,onSetColor:o},g.id))})]})}function Q0({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function Sg(){const{login:a,setRole:l}=_e(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await a(i,f),o(""),d("")}catch(y){alert(y.message)}finally{p(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function K0(...a){return a.filter(Boolean).join(" ")}function Vj(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function $j(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Gj({title:a,roster:l=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),l.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:l.map(f=>r.jsxs("li",{className:K0("surface flex flex-wrap items-center justify-between gap-0.5",f.locked&&"bg-red-900/40"),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:f.name}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:K0("font-semibold",$j(f)),children:["Battery ",Vj(f)]})]})]}),o?o(f):null]},f.id))})]})}const Yj=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Fj(){const{session:a,lockRover:l,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:p,setAudioLevels:x,llmControl:g,adminLogs:y,llmCommentaryState:b}=_e(),j=m.useMemo(()=>a?.roster??[],[a?.roster]),[q,C]=m.useState({}),[w,N]=m.useState({}),[E,A]=m.useState(!1),[M,T]=m.useState(!1),B=a?.health||null,Z=a?.communityGoal?.text||"",O=a?.communityGoal?.updatedAt||null,[H,L]=m.useState(Z),V=a?.adminReason?.text||"",K=a?.adminReason?.updatedAt||null,[te,ce]=m.useState(V),re=a?.audioLevels||{},[F,R]=m.useState({hornGain:Number.isFinite(re.hornGain)?re.hornGain:1,ttsGain:Number.isFinite(re.ttsGain)?re.ttsGain:1,forwardGain:Number.isFinite(re.forwardGain)?re.forwardGain:1}),X=a?.role==="admin"||a?.role==="lockdown"||a?.role==="lockdown-admin",W=a?.mode??"open",se=async(Y,le)=>{try{await l(Y,le),C(fe=>({...fe,[Y]:le}))}catch(fe){alert(fe.message)}},ue=async Y=>{const le=Y.target.value;try{await i(le)}catch(fe){alert(fe.message)}},k=async Y=>{try{await o(Y,{force:!0})}catch(le){alert(le.message)}},U=async Y=>{if(!(!Y?.id||!window.confirm(`Reboot rover "${Y.name||Y.id}" now?`))){N(fe=>({...fe,[Y.id]:!0}));try{await h(Y.id)}catch(fe){alert(fe.message)}finally{N(fe=>({...fe,[Y.id]:!1}))}}},ne=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){A(!0);try{await p()}catch(le){alert(le.message),A(!1)}}},ae=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){T(!0);try{await g("clearHistory")}catch(le){alert(le.message)}finally{T(!1)}}},me=async()=>{try{await f(H)}catch(Y){alert(Y.message)}},ie=async()=>{try{await f(null)}catch(Y){alert(Y.message)}},oe=async()=>{try{await d(te)}catch(Y){alert(Y.message)}},he=async()=>{try{await d(null)}catch(Y){alert(Y.message)}},pe=Y=>le=>{const fe=Number(le.target.value);R(Ae=>({...Ae||{},[Y]:Number.isFinite(fe)?fe:1}))},ge=async()=>{try{await x(F)}catch(Y){alert(Y.message)}};m.useEffect(()=>{L(Z)},[Z]),m.useEffect(()=>{ce(V)},[V]),m.useEffect(()=>{R({hornGain:Number.isFinite(re.hornGain)?re.hornGain:1,ttsGain:Number.isFinite(re.ttsGain)?re.ttsGain:1,forwardGain:Number.isFinite(re.forwardGain)?re.forwardGain:1})},[re.forwardGain,re.hornGain,re.ttsGain]);const Oe=m.useMemo(()=>{const Y={};return j.forEach(le=>{Y[le.id]=q[le.id]??le.locked}),Y},[j,q]);return X?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:W,onChange:ue,className:"field-input text-sm",children:Yj.map(Y=>r.jsx("option",{value:Y.key,children:Y.label},Y.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ne,disabled:E,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:E?"Server rebooting...":"Reboot Server"})}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),a?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(a.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[F.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:F.hornGain,onChange:pe("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[F.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:F.ttsGain,onChange:pe("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[F.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:F.forwardGain,onChange:pe("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ge,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),O?r.jsxs("span",{children:["Updated ",new Date(O).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:H,onChange:Y=>L(Y.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:me,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:ie,className:"button-danger",children:"Clear"})]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Admin mode reason"}),K?r.jsxs("span",{children:["Updated ",new Date(K).toLocaleString()]}):null]}),r.jsx("textarea",{value:te,onChange:Y=>ce(Y.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:oe,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:he,className:"button-danger",children:"Clear"})]})]}),r.jsx(Gj,{roster:j,renderActions:Y=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>se(Y.id,!Oe[Y.id]),className:"button-dark",children:Oe[Y.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>k(Y.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>U(Y),disabled:!!w[Y.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:w[Y.id]?"Rebooting...":"Reboot"})]})}),r.jsx(Zj,{health:B}),r.jsx(Xj,{state:b,onClearHistory:ae,clearingHistory:M}),r.jsx(Ij,{entries:y})]}):null}function Xj({state:a,onClearHistory:l,clearingHistory:i}){const[o,f]=m.useState(null);if(!a)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=a.runtime||{},h=a.counters||{},p=a.timings||{},x=a.input||{},g=a.output||{},y=a.errors||{},b=Array.isArray(a.history)?a.history:[],j=b.find(N=>N.runId===o)||(b.length?b[b.length-1]:null),q=Qj(a),C=Kj(x.modelMessages,g.raw),w=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:l,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${q.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:q.label}),r.jsx("div",{className:"text-xs text-slate-200",children:q.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:w.map(N=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[N.label,": ",N.value]},N.label))}),y.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",y.message]}):null,y.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(y.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:C.length?C.map(N=>r.jsx(Ff,{message:N.message},N.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",y.failedAt?new Date(y.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(a,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(N=>r.jsxs("button",{type:"button",onClick:()=>f(N.runId),className:`w-full text-left surface ${j?.runId===N.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",N.runId]})," ",r.jsx("span",{className:"text-slate-200",children:N.outcome||N.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:N.durationMs!=null?`${N.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:N.reason||""})]},N.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),j?r.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[r.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",j.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(j,null,2)})]}):null]})}function Qj(a){const l=a?.runtime||{},i=a?.output||{},o=a?.errors||{};return l.inFlight?{label:"IN FLIGHT",detail:l.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:l.outcome==="posted"?{label:"POSTED",detail:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:l.outcome==="skipped"?{label:"SKIPPED",detail:l.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:l.outcome==="failed"?{label:"FAILED",detail:o.message||l.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:l.running?"IDLE":"STOPPED",detail:l.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Kj(a,l){const i=Date.now(),f=(Array.isArray(a)?a:[]).map((d,h)=>{const p=String(d?.role||"").toLowerCase(),x=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(l!=null){const d=String(l);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function Zj({health:a}){if(!a)return null;const l=a.replay||{sources:[],readyCount:0,totalCount:0},i=a.snapshots||{rovers:[],rooms:[]},o=`${l.readyCount}/${l.totalCount} sources ready`,f=i.rovers.filter(h=>h.stale).length,d=i.rooms.filter(h=>h.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:o})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:f?"text-amber-300":"text-emerald-300",children:[i.rovers.length-f,"/",i.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:d?"text-amber-300":"text-emerald-300",children:[i.rooms.length-d,"/",i.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:l.sources.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.label}),r.jsxs("span",{className:h.ready?"text-emerald-300":"text-amber-300",children:[h.recentCount,"/",h.neededCount]})]},`${h.type}:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rovers.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.stale?"stale":"ok"})]},`rover:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rooms.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.error?"error":h.stale?"stale":"ok"})]},`room:${h.id}`))})]})}function Ij({entries:a}){const l=a||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:l.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No admin log entries yet."}):l.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const Jj=[{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 Pj(a){return a.reduce((l,i)=>((l[i.group]||(l[i.group]=[])).push(i),l),{})}function Wj(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}const ad=5,xi=500,gi=1,ld=100;function eN(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(ad,Math.min(xi,i)):l}function to(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(gi,Math.min(ld,i)):l}function tN(a){const i=(to(a,a)-gi)/(ld-gi),o=xi-i*(xi-ad);return Math.round(o)}function nN(a){const l=eN(a,a),i=(xi-l)/(xi-ad),o=gi+i*(ld-gi);return Math.round(o)}function aN(a){const[l,i]=m.useState(null),o=m.useCallback(h=>{Ku(!0),i(h)},[]),f=m.useCallback(()=>{Ku(!1),i(null)},[]),d=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){f();return}const x=ji(p.key??"");x&&(a(h,x,p),f())},[f,a]);return m.useEffect(()=>()=>Ku(!1),[]),{active:l,startCapture:o,cancel:f,captureFromEvent:d}}function Yr({label:a,description:l,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function lN(){const{state:{keymap:a},actions:{updateKeyBinding:l,resetKeyBindings:i}}=Mt(),{value:o,save:f}=Ze("inputs",Rn),d={...Rn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?to(d.tiltSpeed,Rn.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?to(nN(d.tiltIntervalMs),Rn.keyboard.tiltSpeed):Rn.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),p=m.useMemo(()=>Pj(Jj),[]),{active:x,startCapture:g,cancel:y,captureFromEvent:b}=aN((w,N)=>{l(w,N)}),j=m.useCallback(w=>a?.[w]?.[0]||oi[w]?.[0]||"",[a]),q=m.useCallback((w,N)=>{const E=Rn.keyboard,A=Wj(N,E[w]);f(M=>({...M??{},keyboard:{...M?.keyboard??E,[w]:A}}))},[f]),C=m.useCallback(w=>{const N=Rn.keyboard,E=to(w,N.tiltSpeed),A=tN(E);f(M=>({...M??{},keyboard:{...M?.keyboard??N,tiltSpeed:E,tiltIntervalMs:A}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Yr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:w=>q("baseSpeed",w)}),r.jsx(Yr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:w=>q("turboSpeed",w)}),r.jsx(Yr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:w=>q("precisionSpeed",w)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx(Yr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:C,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([w,N])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:w}),r.jsx("div",{className:"space-y-0.5",children:N.map(E=>{const A=j(E.id),M=x===E.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:E.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Nn(A)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[M&&r.jsx("button",{type:"button",onClick:()=>y(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(E.id),onKeyDown:M?T=>b(E.id,T):void 0,autoFocus:M,className:`${M?"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:M?"Press a key…":"Change"})]})]},E.id)})})]},w))})]})}const na=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),sN=[{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"}],Z0=.45,iN=.6;function si({label:a,description:l,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("span",{className:"font-mono text-slate-400",children:na.format(d)})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function rN(a){if(!a)return"Unassigned";if(a.kind==="axisPair"){const l=`${a.invertX?"X inv ":""}${a.invertY?"Y inv":""}`.trim();return`Axes ${a.x}/${a.y}${l?` (${l})`:""}`}if(a.kind==="axis")return`Axis ${a.index}${a.invert?" (inv)":""}`;if(a.kind==="button")return`Button ${a.index}`;if(a.kind==="buttonAxis")return`Button ${a.index} (analog)`;if(a.kind==="axisButton"){const l=a.direction<0?"<":">";return`Axis ${a.index} ${l} ${na.format(a.threshold??.6)}`}return"Unassigned"}function oN(a){return a.reduce((l,i)=>((l[i.section]||(l[i.section]=[])).push(i),l),{})}function cN(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function uN(a){return{axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0}))}}function fN(a,l,i){const o=(a.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(l.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>Z0).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>Z0);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function dN(a,l,i){const o=a.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>iN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=a.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,p=Math.abs(h-(l.axes?.[d]??0));if(Math.abs(h)>.7&&p>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function mN(a,l,i){if(!a)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=fN(a,l,i);if(o)return o}return dN(a,l,i)}function hN(){const a=GA(),{value:l,save:i}=Ze("gamepad",Ra),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>oN(sN),[]),p=m.useMemo(()=>cN(a.pads,l.activeSignature),[a.pads,l.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?l?.profiles?.[x]??l?.defaults?.profile??aa:l?.defaults?.profile??aa,[x,l?.defaults?.profile,l?.profiles]);m.useEffect(()=>{!p||!x||l?.profiles?.[x]||i(N=>{const E=N??Ra;if(E.profiles?.[x])return E;const A=E?.defaults?.profile??aa,M=ig(p,A);return{...E,profiles:{...E.profiles??{},[x]:M}}})},[p,x,l?.profiles,i]),m.useEffect(()=>{d.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!d.current){d.current=uN(p);return}const N=mN(p,d.current,o);N&&(i(E=>{const A=E??Ra,M=A.profiles?.[x]??A?.defaults?.profile??aa,T={...M,bindings:{...M.bindings??{},[o.id]:{...M.bindings?.[o.id]??{},kind:o.kind,sources:[N]}}};return{...A,profiles:{...A.profiles??{},[x]:T}}}),f(null))},[p,x,o,i]);const y=m.useCallback(N=>{i(E=>({...E??Ra,activeSignature:N||null}))},[i]),b=m.useCallback(N=>{i(E=>{const A=E??Ra,M=(x&&A.profiles?.[x])??A?.defaults?.profile??aa,T={...M,calibration:{...M.calibration??{},...N}};return x?{...A,profiles:{...A.profiles??{},[x]:T}}:{...A,defaults:{...A.defaults??{},profile:T}}})},[x,i]),j=m.useCallback((N,E)=>{i(A=>{const M=A??Ra,T=(x&&M.profiles?.[x])??M?.defaults?.profile??aa,B=E(T.bindings?.[N]??{}),Z={...T,bindings:{...T.bindings??{},[N]:B}};return x?{...M,profiles:{...M.profiles??{},[x]:Z}}:{...M,defaults:{...M.defaults??{},profile:Z}}})},[x,i]),q=m.useCallback(N=>{j(N.id,E=>({...E,sources:[]}))},[j]),C=m.useCallback((N,E)=>{j(N.id,A=>{const M=Array.isArray(A.sources)?[...A.sources]:[];if(!M[0])return A;const T={...M[0]};return E==="invertX"?T.invertX=!T.invertX:E==="invertY"?T.invertY=!T.invertY:T.invert=!T.invert,M[0]=T,{...A,sources:M}})},[j]),w=m.useMemo(()=>p?{outputs:rg(p,g)}:null,[p,g]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),a.pads.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[r.jsx("select",{value:x??"",onChange:N=>y(N.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:a.pads.map(N=>r.jsx("option",{value:N.signature,children:N.id||"Unknown controller"},N.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(si,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:N=>b({driveDeadzone:N})}),r.jsx(si,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:N=>b({cameraDeadzone:N})}),r.jsx(si,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:N=>b({auxDeadzone:N})}),r.jsx(si,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:N=>b({auxSideScale:N})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:N=>b({cameraMode:N.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(si,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:N=>b({cameraSensitivity:N})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([N,E])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:N}),r.jsx("div",{className:"space-y-0.5",children:E.map(A=>{const T=g.bindings?.[A.id]?.sources?.[0]??null;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:A.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:rN(T)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[A.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(A,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(A,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),A.kind==="axis"&&r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(A),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>q(A),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(A),className:`${o?.id===A.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===A.id?"Waiting…":"Capture"})]})]},A.id)})})]},N))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?r.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[r.jsx("p",{className:"text-slate-400",children:"Raw axes"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((N,E)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",E,": ",na.format(N)]},`axis-${E}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((N,E)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",E,": ",na.format(N.value)," ",N.pressed?"●":""]},`btn-${E}`))}),w?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",na.format(w.outputs.driveVector.x),","," ",na.format(w.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",na.format(w.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",na.format(w.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",na.format(w.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const pN={drive:"Drive wheels",aux:"Aux motors"};function I0(a){return Number.isFinite(a)?`${Math.round(a*100)}%`:"--"}function xN({value:a,color:l="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,a))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${l}`,style:{width:i}})})}function gN(){const{state:{roverId:a},overcurrentLimiter:l}=Mt(),i=m.useMemo(()=>Jl.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:l?.adminImmune?"Admin immune":"Active"})]}),a?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=l?.caps?.[o]?.cap??0,d=l?.overcurrent?.groups?.[o]??!1,h=l?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:pN[o]||o}),r.jsx("span",{className:d?"text-red-300":"text-slate-400",children:d?"overcurrent":"ok"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Cap"}),r.jsx("span",{children:I0(f)})]}),r.jsx(xN,{value:f,color:"bg-amber-500"}),r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Scale"}),r.jsx("span",{children:I0(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${l?.config?.downRatePerSec}/s · Up rate ${l?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${l?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${l?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Ag=m.createContext(null);function jg(){const a=m.useContext(Ag);if(!a)throw new Error("Tabs components must be used within a <Tabs> provider.");return a}const J0={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"}},P0={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"},Ng="primary";function sd(...a){return a.filter(Boolean).join(" ")}function id({children:a,defaultTab:l,currentTab:i,onTabChange:o,variant:f=Ng}){const[d,h]=m.useState(l??null),[p,x]=m.useState([]),g=m.useCallback(q=>q?(x(C=>C.includes(q)?C:[...C,q]),()=>x(C=>C.includes(q)?C.filter(w=>w!==q):C)):()=>{},[]),y=i??d??p[0]??null;m.useEffect(()=>{l&&i===void 0&&h(l)},[l,i]);const b=m.useCallback(q=>{q&&(i===void 0&&h(q),o&&o(q))},[i,o]),j=m.useMemo(()=>({activeTab:y,setActiveTab:b,registerTab:g,variant:f}),[y,b,g,f]);return r.jsx(Ag.Provider,{value:j,children:a})}function rd({children:a,className:l=""}){return r.jsx("div",{className:sd("flex gap-0.5",l),children:a})}function Jt({id:a,children:l,className:i="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:h,registerTab:p,variant:x}=jg();m.useEffect(()=>p(a),[a,p]);const g=J0[x]??J0[Ng],y=d===a,b=P0[f]||P0.none,j=sd(g.base,b||(y?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:j,onClick:()=>!o&&h(a),"aria-pressed":y,"aria-disabled":o,children:l})}function od({children:a,className:l=""}){return r.jsx("div",{className:sd("mt-0 space-y-0.5",l),children:a})}function Pt({id:a,children:l,keepMounted:i=!1}){const{activeTab:o}=jg(),f=o===a;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:l}):r.jsx(r.Fragment,{children:l})}function vN(){const{session:a}=_e(),l=m.useMemo(()=>JSON.stringify(a??{},null,2),[a]);return r.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),r.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:l})]})}const W0=300,ex=240;function yN(a,l){if(a===void 0)return"undefined";if(a===null)return"null";if(typeof a=="string")return a;if(typeof a=="number"||typeof a=="boolean")return String(a);if(typeof a=="function")return"[Function]";if(a instanceof Error)return`${a.name}: ${a.message}`;if(a instanceof Date)return a.toISOString();if(l||(l=new WeakSet),typeof a=="object"){if(l.has(a))return"[Circular]";l.add(a)}try{return JSON.stringify(a,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(a)}}function bN(a){const i=a.map(o=>yN(o)).join(" ");return i.length>ex?`${i.slice(0,ex)}…`:i}function SN(){const a=On(),[l,i]=m.useState([]),o=m.useMemo(()=>l.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[l]);return m.useEffect(()=>{const f=(x,g,y)=>{i(b=>{const j=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:bN(y),timestamp:new Date().toLocaleTimeString()}];return j.length>W0?j.slice(-W0):j})},d=(x,...g)=>f("in",x,g),h=(x,...g)=>f("out",x,g);a.onAny(d);let p=null;if(typeof a.onAnyOutgoing=="function")a.onAnyOutgoing(h),p=()=>a.offAnyOutgoing(h);else{const x=a.emit.bind(a);a.emit=(g,...y)=>(h(g,...y),x(g,...y)),p=()=>{a.emit=x}}return()=>{a.offAny(d),p&&p()}},[a]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No socket activity yet."}):l.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const AN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function wg(){const{state:{roverId:a},actions:{sendOiCommand:l,setSensorStream:i}}=Mt(),o=!!a,[f,d]=vg(),h=On(),{value:p,save:x}=Ze("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1}),{value:g,save:y}=Ze("audio",kt),b=p?.connectionTransport||"websocket",j=!!p?.swapMobileControlColumns,q=Number.isFinite(g?.masterVolume)?g.masterVolume:kt.masterVolume,C=Number.isFinite(g?.alertVolume)?g.alertVolume:kt.alertVolume,w=Number.isFinite(g?.roverVolume)?g.roverVolume:kt.roverVolume,N=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:kt.mainBrushDuckEnabled,E=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):kt.mainBrushDuckAmount,A=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=H=>{a&&i(H)},T=H=>{const L=H.target.value;x(V=>({...V??{},connectionTransport:L})),h?.io?.opts&&(h.io.opts.transports=L==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},B=H=>L=>{const V=Number(L.target.value),K=Number.isFinite(V)?Math.max(0,Math.min(1,V)):0;y(te=>({...te??{},[H]:K}))},Z=H=>{const L=!!H.target.checked;y(V=>({...V??{},mainBrushDuckEnabled:L}))},O=H=>{const L=!!H.target.checked;x(V=>({...V??{},swapMobileControlColumns:L}))};return r.jsxs(id,{defaultTab:"keybindings",children:[r.jsxs(rd,{children:[r.jsx(Jt,{id:"keybindings",children:"Keybindings"}),r.jsx(Jt,{id:"controller",children:"Controller"}),r.jsx(Jt,{id:"page",children:"Page settings"}),r.jsx(Jt,{id:"admin",children:"Admin"})]}),r.jsxs(od,{children:[r.jsx(Pt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(lN,{})})}),r.jsx(Pt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(hN,{})})}),r.jsx(Pt,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:H=>d(H.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:j,onChange:O}),r.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(q*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:q,onChange:B("masterVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Alert/page sounds"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(C*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:C,onChange:B("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:B("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:N,onChange:Z})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:B("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!N})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:T,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(Pt,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:AN.map(H=>r.jsx("button",{type:"button",onClick:()=>l(H.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:H.label},H.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:A.map(H=>r.jsx("button",{type:"button",onClick:()=>M(H.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:H.label},H.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(Sg,{}),r.jsx(gN,{}),r.jsx(Fj,{}),r.jsx(vN,{}),r.jsx(SN,{})]})})]})]})}const tx={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 jN(a){return tx[a]||tx.desktop}function Cg({actionId:a,keymap:l}){const i=l?.[a]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:Nn(i)})}function nx(a,l){return a.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(Cg,{actionId:i.action,keymap:l},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function yo(a,l,i){if(typeof a=="string")return a;if(Array.isArray(a?.segments))return nx(a.segments,l);if(a&&typeof a=="object"){if(typeof a.text=="string")return a.text;if(Array.isArray(a))return nx(a,l)}return String(a??"")}function NN({hero:a,keymap:l}){return a?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:a.title}),a.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:a.subtitle})]}),a.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:a.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),a.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:a.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:yo(i,l)},f)})})]}):null}function wN({block:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:yo(i,l)},f)})})]})}function CN({block:a}){const l=a.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${l} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:a.title}),a.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:yo(i,{})},`callout-${o}`))})]})}function EN({group:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:a.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:a.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(Cg,{actionId:i.action,keymap:l})]},i.action))})]})}function kN({block:a,keymap:l}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:a.title}),a.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:a.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:a.groups?.map(i=>r.jsx(EN,{group:i,keymap:l},i.id))})]}):null}function MN({block:a}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items?.map((l,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:yo(l,{})},`gamepad-${i}`))})]}):null}function ax({block:a,keymap:l}){if(!a)return null;switch(a.type){case"list":return r.jsx(wN,{block:a,keymap:l});case"callout":return r.jsx(CN,{block:a});case"keyboard":return r.jsx(kN,{block:a,keymap:l});case"gamepad":return r.jsx(MN,{block:a});default:return null}}function Eg({layout:a,keymap:l}){const i=m.useMemo(()=>jN(a),[a]),o=l||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(NN,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>r.jsx(ax,{block:h,keymap:o},h.title||p))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,p)=>r.jsx(ax,{block:h,keymap:o},h.title||p))})]})]})}function kg({layout:a,onOpenOverlay:l}){const{state:i}=Mt();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:l,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(Eg,{layout:a,keymap:i?.keymap||{}})]})}const qN=["kal","rms","slt","ksp","bdl"],RN=Array.from({length:10},(a,l)=>l*10);function bo({hideInput:a=!1,hideSpectatorNotice:l=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=_e(),{messages:d,typing:h,sendMessage:p,registerInputRef:x,onInputFocus:g,onInputBlur:y,blurChat:b,setTypingActive:j}=Kf(),{value:q,save:C}=Ze("tts",{engine:"flite",voice:"rms",pitch:50}),[w,N]=m.useState(""),[E,A]=m.useState(!1),[M,T]=m.useState(!1),[B,Z]=m.useState(()=>q?.engine||"flite"),[O,H]=m.useState(()=>q?.voice||"rms"),[L,V]=m.useState(()=>Number.isFinite(q?.pitch)?q.pitch:50),K=f?.role!=="spectator"||o,te=m.useRef(null),ce=f?.assignment?.roverId||null,F=!!m.useMemo(()=>f?.roster?.find(k=>String(k.id)===String(ce))||null,[ce,f?.roster])?.audio?.ttsEnabled,R=m.useMemo(()=>d.slice(-200),[d]),X=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[R,X]),m.useEffect(()=>{const k=q?.engine||"flite",U=q?.voice||"rms",ne=Number.isFinite(q?.pitch)?q.pitch:50;B!==k&&Z(k),O!==U&&H(U),L!==ne&&V(ne)},[B,L,q?.engine,q?.pitch,q?.voice,O]),m.useEffect(()=>{T(!!F)},[F]);const W=m.useMemo(()=>!F||!M?null:B==="espeak"?{speak:!0,engine:B,pitch:L}:{speak:!0,engine:B,voice:O},[B,L,M,F,O]);async function se(k){if(k.preventDefault(),!K||a)return;const ne=w.replace(/\\n/g,`
|
||
`).trim();if(ne){A(!0);try{await p(ne,W),N(""),b(),j(!1)}catch(ae){alert(ae.message)}finally{A(!1)}}}const ue=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${ue}`,ref:te,children:[R.length===0&&X.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):R.map(k=>r.jsx(Ff,{message:k},k.id)),X.map(k=>r.jsx(Jx,{message:k},`typing-${k.typingId||k.id}`))]}),!a&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:se,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:w,onChange:k=>{const U=k.target.value;N(U),j(!!U.trim())},onFocus:k=>{g(k),j(!!w.trim())},onBlur:k=>{y(k),j(!1)},onKeyDown:k=>{k.key==="Enter"&&!w.trim()&&(k.preventDefault(),b(),j(!1))},ref:k=>x(k,{target:"panel"}),placeholder:K?"Type a message…":l?"":"Spectators cannot chat",disabled:!K}),F&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:M,onChange:k=>T(k.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:B,onChange:k=>{const U=k.target.value;Z(U),C(ne=>({...ne||{},engine:U}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),B==="flite"?r.jsx("select",{value:O,onChange:k=>{const U=k.target.value;H(U),C(ne=>({...ne||{},voice:U}))},className:"field-input text-xs",children:qN.map(k=>r.jsx("option",{value:k,children:k},k))}):r.jsx("select",{value:L,onChange:k=>{const U=Number(k.target.value);V(U),C(ne=>({...ne||{},pitch:U}))},className:"field-input text-xs",children:RN.map(k=>r.jsxs("option",{value:k,children:["pitch ",k]},k))})]}),r.jsx("button",{type:"submit",disabled:!K||E,className:"button-dark h-full disabled:opacity-50 self-stretch",children:E?"...":"Send"})]})]})}function So({compact:a=!1}){const{session:l,setNickname:i}=_e(),{value:o,save:f}=Ze("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=l?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function y(b){if(b.preventDefault(),!g)return;const j=(d||"").trim().slice(0,32);if(j){x(!0);try{await i(j),f({nickname:j})}catch(q){alert(q.message)}finally{x(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:y,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":a?"Set":"Save"})]})}function TN(a){const l=Array.isArray(a?.socials)?a.socials:null;if(l&&l.length)return l;const i=[];return a?.discord?.invite&&i.push({id:"discord",label:"Discord",url:a.discord.invite}),a?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:a.kofi.link}),i}function DN(a){if(!a||typeof a!="object")return null;const l=a.id||a.service||a.key||a.name||null,i=a.label||a.title||a.name||l||"Link",o=a.url||a.link||a.href||null;return o?{id:l,label:i,url:o}:null}function Mg({className:a=""}){const{session:l}=_e(),i=TN(l).map(DN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${a}`,children:i.map(o=>r.jsx(td,{...o},`${o.id||o.label}-${o.url}`))}):null}function _N({compact:a=!1}){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(So,{compact:a})})})}function ON(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Mg,{className:"flex-1 min-h-0"})})}function cf(...a){return a.filter(Boolean).join(" ")}function BN(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function LN(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function zN(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function UN(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function Ao({title:a="Rovers"}){const{session:l,requestControl:i}=_e(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),p=m.useMemo(()=>l?.role&&l.role!=="spectator",[l?.role]),x=l?.roster??[],g=l?.turnQueues??{},y=l?.users??[],b=l?.socketId||null,j=m.useMemo(()=>Object.values(g||{}).some(N=>N?.deadline||N?.idleDeadline),[g]);m.useEffect(()=>{if(!j)return;const N=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(N)},[j]);const q=m.useMemo(()=>{const N=new Set(x.map(A=>String(A.id))),E=Object.keys(g||{}).filter(A=>!N.has(String(A))).map(A=>({id:A,name:A,locked:!1,batteryState:null}));return[...x,...E]},[x,g]);async function C(N){if(N){f(E=>({...E,[N]:!0}));try{await i(N)}catch(E){alert(E.message)}finally{f(E=>({...E,[N]:!1}))}}}const w=N=>y.find(E=>E.socketId===N)||{socketId:N,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),q.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:q.map(N=>{const E=String(N.id),A=g?.[E]||null,M=A?.queue||[],T=A?.idleDeadline||A?.deadline||null,B=T&&T>d?Math.ceil((T-d)/1e3):T?0:null,Z=A?.current||null,O=Z?M.findIndex(R=>R===Z):-1,H=M.length>1?O>=0?M[(O+1)%M.length]:M[0]:null,L=!!(b&&Z&&Z===b),V=!!(b&&H&&H===b),K=B!=null&&(L||V),te=!!N.locked,ce=N.lockReason?`locked: ${N.lockReason}`:"locked",re=te?ce:o[E]?"...":"request",F=p&&!te&&!o[E];return r.jsxs("li",{className:cf("surface flex flex-wrap items-start justify-between gap-0.5",F&&"cursor-pointer",te&&"bg-red-900/40"),onClick:()=>{F&&C(N.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:N.name}),K?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:L?`${B}s left`:`Your turn in ${B}s`}):null]}),r.jsx("span",{className:cf("text-[0.75rem] font-semibold",LN(N)),children:BN(N)})]}),M.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:M.map((R,X)=>{const W=w(R),se=R===Z,ue=!!(H&&R===H&&!se),k=se?"bg-sky-600 text-white ring-2 ring-amber-300":ue?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return r.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${k}`,children:[r.jsx("span",{className:`${zN(W.role)} font-semibold`,children:UN(W,b)}),se&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),ue&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${E}-${R}-${X}`)})})]}),p?r.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),C(N.id)},disabled:o[E]||te,className:cf("button-dark disabled:opacity-40",te&&"bg-red-600/70 text-white hover:bg-red-600"),children:re}):null]},N.id)})})]})}function HN(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function VN(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function uo({hideNicknameForm:a=!1,hideHeader:l=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=_e(),h=d?.role!=="spectator",p=d?.users??[],x=d?.socketId||null,g=m.useMemo(()=>[...p].sort((b,j)=>b.socketId===x?-1:j.socketId===x?1:(b.nickname||"").localeCompare(j.nickname||"")),[x,p]),y=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!a&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(So,{compact:f})})}),r.jsx(Mg,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!l&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${y} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(b=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${HN(b.role)}`,children:VN(b,x)},b.socketId))})]})]})}const $N=/^cu_[a-f0-9]{32}$/,vi="field-input w-full max-w-sm text-left focus:ring-emerald-500",cd="mx-auto w-full max-w-xl flex justify-center",no="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function GN(a){const l=String(a||"").trim();return l?l.length<=10?`${l.slice(0,2)}***${l.slice(-2)}`:`${l.slice(0,6)}...${l.slice(-6)}`:""}const lx=8*1024*1024,tl=16e3,YN={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function sx(a){let l="";for(let o=0;o<a.length;o+=32768){const f=a.subarray(o,o+32768);l+=String.fromCharCode(...f)}return btoa(l)}function FN(a){return typeof btoa=="function"?btoa(a):""}function XN(a){if(!a)return{};const l=FN(`${a}:${a}`);return l?{Authorization:`Basic ${l}`}:{}}function QN(a,l=1500){return new Promise(i=>{if(!a||a.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{a.removeEventListener("icegatheringstatechange",f),i()},l);function f(){a.iceGatheringState==="complete"&&(clearTimeout(o),a.removeEventListener("icegatheringstatechange",f),i())}a.addEventListener("icegatheringstatechange",f)})}function ix(a){if(!a)return!1;const l=a.connectionState,i=a.iceConnectionState;return l==="connected"||i==="connected"||i==="completed"}function KN(a,l=1e4){return new Promise((i,o)=>{if(!a){o(new Error("Peer connection missing"));return}if(ix(a)){i();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},l),d=()=>{ix(a)?(h(),i()):(a.connectionState==="failed"||a.connectionState==="closed"||a.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${a.connectionState||a.iceConnectionState}`)))};function h(){clearTimeout(f),a.removeEventListener("connectionstatechange",d),a.removeEventListener("iceconnectionstatechange",d)}a.addEventListener("connectionstatechange",d),a.addEventListener("iceconnectionstatechange",d)})}async function ZN(a){if(!a?.getParameters||!a?.setParameters)return;const l=a.getParameters()||{},i=l.encodings&&l.encodings[0]||{};l.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await a.setParameters(l)}catch{}}function IN(a,l=6e3){return new Promise((i,o)=>{if(!a){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>l){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=a.getSenders().filter(x=>x.track?.kind==="audio");for(const x of p){const g=await x.getStats();for(const y of g.values()){if(y.type!=="outbound-rtp"||y.kind!=="audio")continue;const b=Number(y.bytesSent||0),j=Number(y.packetsSent||0);if(d<0)d=b;else if(b>d+200||j>5){clearInterval(h),i();return}}}}catch{}},250)})}function pn({label:a,active:l,detail:i=""}){return r.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${l?"bg-emerald-500":"bg-slate-700"}`,children:[r.jsx("div",{className:"text-center font-medium",children:a}),r.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:i||(l?"active":"idle")})]})}function rx({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function JN(a){const l=a.reduce((f,d)=>f+d.length,0),i=new Float32Array(l);let o=0;for(const f of a)i.set(f,o),o+=f.length;return i}function PN(a){const l=new Int16Array(a.length);for(let i=0;i<a.length;i+=1){const o=Math.max(-1,Math.min(1,a[i]));l[i]=o<0?o*32768:o*32767}return l}function WN(a,l){const i=PN(a),o=i.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),h=(x,g)=>{for(let y=0;y<g.length;y+=1)d.setUint8(x+y,g.charCodeAt(y))};h(0,"RIFF"),d.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,l,!0),d.setUint32(28,l*2,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),h(36,"data"),d.setUint32(40,o,!0);let p=44;for(let x=0;x<i.length;x+=1,p+=2)d.setInt16(p,i[x],!0);return new Uint8Array(f)}function ew({ownRoverId:a="",audioForwardByRover:l={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:p}=Mt(),{value:x,save:g}=Ze("vipAudio",{openMicEnabled:!1,pttMode:"live"}),y=String(a||"").trim(),[b,j]=m.useState(null),[q,C]=m.useState(!1),w=!!x?.openMicEnabled,E=(x?.pttMode==="clip"?"clip":"live")==="clip",[A,M]=m.useState("idle"),[T,B]=m.useState("idle"),[Z,O]=m.useState(""),H=m.useRef(null),L=m.useRef(null),V=m.useRef(null),K=m.useRef(!1),te=m.useRef(""),ce=m.useRef(null),re=m.useRef(null),F=m.useRef(null),R=m.useRef(null),X=m.useRef(null),W=m.useRef([]),se=m.useRef(!1),ue=m.useRef(tl),k=!!p?.mic?.pttActive,U=m.useMemo(()=>y&&l?.[y]||null,[l,y]),ne=!!(U&&U.state!=="offline"&&!U.error),ae=U?.source==="upload"&&U?.state==="playing",me=U?.source==="mic-whip"&&(U?.state==="starting"||U?.state==="playing"),ie=!!(!E&&L.current&&(w||k)),oe=!E&&(A==="live"||A==="starting"),he=E&&T==="recording",pe=E&&T==="sending",ge=Nn(p?.keymap?.micPtt?.[0])||"M",Oe=m.useCallback(ve=>{const Ce=ve==="clip"?"clip":"live";g($e=>({...$e||{},pttMode:Ce}))},[g]),Y=async()=>{if(!y){O("Take control of your rover first.");return}if(!b){O("Select an audio file first.");return}if(b.size>lx){O(`File too large (max ${lx} bytes).`);return}C(!0),O("");try{const ve=await b.arrayBuffer(),Ce=sx(new Uint8Array(ve));await i?.({roverId:y,name:b.name,mime:b.type||"",dataBase64:Ce}),O("Upload playback started.")}catch(ve){O(ve?.message||"Failed to play upload.")}finally{C(!1)}},le=async()=>{if(!y){O("Take control of your rover first.");return}C(!0),O("");try{await o?.(y),O("Upload playback stopped.")}catch(ve){O(ve?.message||"Failed to stop upload.")}finally{C(!1)}},fe=m.useCallback(async ve=>{const Ce=String(ve||te.current||"").trim();if(K.current=!1,M("idle"),V.current){try{V.current.getSenders().forEach($e=>$e.track?.stop())}catch{}try{V.current.close()}catch{}}if(V.current=null,H.current)try{H.current.getTracks().forEach($e=>$e.stop())}catch{}if(H.current=null,L.current=null,Ce)try{await h?.(Ce)}catch{}te.current=""},[h]),Ae=m.useCallback(async ve=>{const Ce=await f?.(ve),$e=String(Ce?.whipUrl||"").trim(),Tt=String(Ce?.token||"").trim();if(!$e||!Tt)throw new Error("WHIP endpoint unavailable");const Ue=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:tl,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});H.current=Ue;const vt=Ue.getAudioTracks()?.[0];if(L.current=vt||null,vt&&(vt.enabled=!!(w||k)),vt?.applyConstraints)try{await vt.applyConstraints({channelCount:1,sampleRate:tl,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const ft=new RTCPeerConnection(YN);V.current=ft,ft.onconnectionstatechange=()=>{if(!K.current)return;const Ot=ft.connectionState;if(Ot==="connected"){M("live");return}(Ot==="failed"||Ot==="disconnected"||Ot==="closed")&&(M("error"),O(`WHIP transport ${Ot}.`))},Ue.getAudioTracks().forEach(Ot=>{const is=ft.addTrack(Ot,Ue);ZN(is)});const _t=await ft.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await ft.setLocalDescription(_t),await QN(ft,1800);const gn=await fetch($e,{method:"POST",headers:{"Content-Type":"application/sdp",...XN(Tt)},body:ft.localDescription?.sdp||_t.sdp});if(!gn.ok)throw new Error(`WHIP request failed: ${gn.status}`);const il=await gn.text();await ft.setRemoteDescription({type:"answer",sdp:il}),await KN(ft,1e4),await IN(ft,6e3),await d?.(ve)},[w,k,d,f]),Ve=m.useCallback(async()=>{if(se.current=!1,R.current){try{R.current.disconnect()}catch{}R.current.onaudioprocess=null}if(F.current)try{F.current.disconnect()}catch{}if(X.current)try{X.current.disconnect()}catch{}if(ce.current)try{ce.current.getTracks().forEach(ve=>ve.stop())}catch{}if(re.current)try{await re.current.close()}catch{}W.current=[],R.current=null,F.current=null,X.current=null,ce.current=null,re.current=null,ue.current=tl},[]),Ie=m.useCallback(async()=>{if(ce.current&&re.current&&R.current)return;B(vt=>vt==="recording"?vt:"arming");const ve=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:tl,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),Ce=new AudioContext({latencyHint:"interactive"}),$e=Ce.createMediaStreamSource(ve),Tt=Ce.createScriptProcessor(1024,1,1),Ue=Ce.createGain();Ue.gain.value=0,Tt.onaudioprocess=vt=>{if(!se.current)return;const ft=vt.inputBuffer.getChannelData(0);W.current.push(new Float32Array(ft))},$e.connect(Tt),Tt.connect(Ue),Ue.connect(Ce.destination),ce.current=ve,re.current=Ce,F.current=$e,R.current=Tt,X.current=Ue,ue.current=Ce.sampleRate||tl},[]),qt=m.useCallback(async({send:ve})=>{const Ce=se.current;if(se.current=!1,!Ce){ve||B("idle");return}const $e=W.current;if(W.current=[],!ve){B("idle");return}if(!y){B("idle");return}if(!$e.length){B("idle");return}B("sending");try{const Tt=JN($e),Ue=WN(Tt,ue.current||tl),vt=sx(Ue);await i?.({roverId:y,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:vt}),B("idle")}catch(Tt){B("error"),O(Tt?.message||"Failed to send PTT clip.")}},[i,y]),Wt=m.useCallback(async()=>{if(!y){O("Take control of your rover first.");return}await Ie(),W.current=[],se.current=!0,B("recording")},[Ie,y]);return m.useEffect(()=>{let ve=!1;async function Ce(){if(E){await fe(te.current||y);return}if(!y){await fe(te.current);return}if(!(K.current&&te.current===y)&&!(!w&&!k))try{M("starting"),O(""),K.current=!0,te.current=y,await Ae(y),ve||M("live")}catch($e){ve||(M("error"),O($e?.message||"Failed to start mic forwarding.")),await fe(y)}}return Ce(),()=>{ve=!0}},[E,w,k,y,Ae,fe]),m.useEffect(()=>{const ve=L.current;ve&&(ve.enabled=!!(!E&&(w||k)))},[E,w,k]),m.useEffect(()=>{let ve=!1;async function Ce(){if(!E||!y){se.current&&await qt({send:!1}),B("idle");return}try{await Ie(),!ve&&!se.current&&B("idle")}catch($e){ve||(B("error"),O($e?.message||"Microphone access failed for clip mode."))}}return Ce(),()=>{ve=!0}},[E,Ie,qt,y]),m.useEffect(()=>{let ve=!1;async function Ce(){if(E){if(!y){se.current&&await qt({send:!1});return}if(k){if(!se.current)try{O(""),await Wt()}catch($e){ve||(B("error"),O($e?.message||"Failed to start clip recording."))}}else se.current&&await qt({send:!0})}}return Ce(),()=>{ve=!0}},[E,qt,k,y,Wt]),m.useEffect(()=>()=>{fe(te.current||y),Ve()},[y,fe,Ve]),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[r.jsx("span",{children:"Push-to-Talk Key"}),r.jsx(rx,{label:ge})]})}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),r.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."}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${E?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Oe("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${E?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Oe("clip"),children:"Record Clip"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(pn,{label:"Mode",active:E,detail:E?"record clip":"live mic"}),r.jsx(pn,{label:"PTT hold",active:k,detail:k?"held":"released"}),r.jsx(pn,{label:"Recording",active:he,detail:he?"capturing":"idle"}),r.jsx(pn,{label:"Playback",active:E&&ae,detail:E&&ae?"playing":"idle"})]})]})})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),r.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:`${vi} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:q||!y,onChange:ve=>j(ve.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):r.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:q||!y,onClick:Y,children:q?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:q||!y,onClick:le,children:"Stop"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),r.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:[r.jsx("input",{type:"checkbox",checked:w,disabled:!y||E,onChange:ve=>g(Ce=>({...Ce||{},openMicEnabled:!!ve.target.checked}))}),r.jsx("span",{children:E?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(pn,{label:"WHIP link",active:oe,detail:A}),r.jsx(pn,{label:"Mic hot",active:ie,detail:ie?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(rx,{label:ge})," to talk"]})]})]})})]}),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[r.jsx(pn,{label:"Forward pipe",active:ne,detail:ne?"connected":"offline"}),r.jsx(pn,{label:"Upload playback",active:ae,detail:ae?"playing":"idle"}),r.jsx(pn,{label:"Mic relay",active:me,detail:me?"active":"idle"}),r.jsx(pn,{label:"WHIP transport",active:oe,detail:A}),r.jsx(pn,{label:"Clip recording",active:he,detail:he?"recording":"idle"}),r.jsx(pn,{label:"Clip sending",active:pe,detail:pe?"sending":"idle"})]}),Z?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:Z}):null]})})]})}function tw({pendingRequestId:a,currentStoredKey:l,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:h=!1}){const[p,x]=m.useState(0),[g,y]=m.useState(""),[b,j]=m.useState(!1),[q,C]=m.useState(!1),w=()=>{x(1),y(l),j(!1),d?.("")},N=()=>{x(0),j(!1)},E=async M=>{if(M.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(p<3){d?.("Complete all request steps before sending.");return}C(!0),d?.("");try{const T=await f(g);await o?.(),y(T),x(0),j(!1),d?.("Verification request sent to lockdown admins.")}catch(T){d?.(T.message||"Failed to submit request.")}finally{C(!1)}},A=h?"w-full":cd;return a?r.jsx("section",{className:`surface text-sm text-slate-300 ${A}`,children:r.jsxs("div",{className:no,children:["Verification request pending: ",a]})}):p===0?r.jsx("section",{className:`surface ${A}`,children:r.jsxs("div",{className:no,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,disabled:q,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${A}`,onSubmit:E,children:r.jsxs("div",{className:no,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",p," of 3"]}),p===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(So,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:M=>j(M.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!b,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:N,children:"Cancel"})]})]}):null,p===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:vi,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:M=>y(M.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,p===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:vi,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:M=>y(M.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:q||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function nw({currentStoredKey:a,applyIdentityKey:l,onMessage:i,fullWidth:o=!1}){const[f,d]=m.useState(0),[h,p]=m.useState(""),[x,g]=m.useState(!1),y=()=>{d(1),p(""),i?.("")},b=()=>{d(0),p("")},j=async C=>{if(C.preventDefault(),!(f<2)){g(!0),i?.("");try{await l(h),d(0),p(""),i?.("Identity key restored.")}catch(w){i?.(w.message||"Failed to restore key.")}finally{g(!1)}}},q=o?"w-full":cd;return r.jsx("section",{className:`surface ${q}`,children:r.jsxs("div",{className:no,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",GN(a)||"not set yet"]}),r.jsx("input",{className:vi,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:a,readOnly:!0,placeholder:"Identity key"}),f===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!a,onClick:()=>navigator.clipboard?.writeText(a),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,disabled:x,children:"Restore Key"})]}):null,f===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,f===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:j,children:[r.jsx("input",{className:vi,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:C=>p(C.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!h,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function qg(){const{session:a,identifySession:l,requestVerification:i,playUploadedAudio:o,stopUploadedAudio:f,startMicWhip:d,readyMicWhip:h,stopMicWhip:p}=_e(),{value:x,save:g}=Ze("identity",{cookieUserId:""}),{value:y}=Ze("profile",{nickname:""}),b=m.useMemo(()=>(x?.cookieUserId||"").trim(),[x?.cookieUserId]),j=(y?.nickname||"").trim(),q=!!a?.isVerified,C=a?.verification?.pendingRequestId||null,w=String(a?.assignment?.roverId||"").trim(),[N,E]=m.useState(""),A=async M=>{const T=String(M||"").trim().toLowerCase();if(!T)throw new Error("Identity key required.");if(!$N.test(T))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return g(B=>({...B||{},cookieUserId:T})),await l({cookieUserId:T,nickname:j}),T};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[r.jsx("div",{className:"lg:col-span-2",children:q?r.jsx("section",{className:"surface w-full",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center",children:[r.jsx("p",{className:"text-sm text-emerald-300",children:"Verification complete"}),r.jsx("p",{className:"text-xs text-slate-400",children:"VIP controls are unlocked for your assigned rover."})]})}):r.jsx(tw,{pendingRequestId:C,currentStoredKey:b,nickname:j,requestVerification:i,applyIdentityKey:A,onMessage:E,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:q?r.jsx(ew,{ownRoverId:w,audioForwardByRover:a?.audioForward||{},playUploadedAudio:o,stopUploadedAudio:f,startMicWhip:d,readyMicWhip:h,stopMicWhip:p}):r.jsx("section",{className:"surface h-full",children:r.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."})})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(nw,{currentStoredKey:b,applyIdentityKey:A,onMessage:E,fullWidth:!0})})]}),N?r.jsx("div",{className:cd,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:N})}):null]})}function aw(){const{state:{roverId:a}}=Mt(),i=ss(a)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Ef,{sensors:i})})})}function lw(){const{state:{roverId:a,keymap:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:p,stopHorn:x}}=Mt(),g=fg(a),y=g.docked&&!g.driving,b=i?.config,j=!!(a&&i?.enabled&&b),q=!!(a&&f?.nightVision),C=f?.nightVisionState,w=!!(a&&f?.horn),N=o?.overheated,E=typeof b?.minAngle=="number"?b.minAngle:-30,A=typeof b?.maxAngle=="number"?b.maxAngle:30,M=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(E+A)/2,T=Nn(l?.nightVisionToggle?.[0]),B=Nn(l?.hornHonk?.[0]),Z=Nn(l?.cameraUp?.[0]),O=Nn(l?.cameraDown?.[0]);return r.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[r.jsx(dg,{layout:"desktop",expand:!0,driveDockState:g}),y?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[q&&r.jsx(mg,{nightVisionOn:C?.nightVisionOn,disabled:!a,onToggle:h,keyLabel:T}),w&&r.jsx(hg,{disabled:!a||N,onStart:p,onStop:x,keyLabel:B,active:o?.active,heat:o?.heat}),j&&r.jsx(pg,{value:M,min:E,max:A,onChange:d,keyDownLabel:O,keyUpLabel:Z,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 sw({layout:a,onOpenHelpOverlay:l}){const{session:i}=_e(),{state:o}=Mt(),{value:f}=Ze("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=i?.isVerified?"bg-emerald-400":"bg-red-600",h=String(i?.assignment?.roverId||"").trim(),p=h?i?.audioForward?.[h]:null,x=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,y=f?.pttMode==="clip"?"clip":"live",b=!!(h&&i?.isVerified&&(y==="clip"?x:g||x)),j=!!(h&&i?.isVerified&&y==="clip"&&p?.source==="upload"&&p?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(id,{defaultTab:"telemetry",children:[r.jsxs(rd,{children:[r.jsx(Jt,{id:"telemetry",children:"Controls"}),r.jsx(Jt,{id:"vip",highlight:j?"green":b?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${d}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Jt,{id:"help",children:"Help"}),r.jsx(Jt,{id:"settings",children:"Settings"})]}),r.jsxs(od,{children:[r.jsx(Pt,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(aw,{}),r.jsx(lw,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(Ao,{}),r.jsx(Gf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(ON,{})]}),r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[r.jsx(bo,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(uo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(_N,{compact:!0})]})]}),r.jsx(bg,{}),r.jsx(Jf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Pt,{id:"vip",keepMounted:!0,children:r.jsx(qg,{})}),r.jsx(Pt,{id:"help",children:r.jsx(kg,{layout:a,onOpenOverlay:l})}),r.jsx(Pt,{id:"settings",children:r.jsx(wg,{})})]})]})})}const iw=new Set(["admin","lockdown","lockdown-admin"]),rw=new Set(["lockdown","lockdown-admin"]),ow=new Set(["admin","lockdown"]);function cw(a="admin"){return a==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function uw(){const{session:a}=_e(),l=a?.mode,i=a?.role,o=a?.adminReason?.text||"";a?.adminReason?.updatedAt;const f=a?.timezone||"UTC",d=a?.socials?.find(j=>String(j?.id||j?.label||"").toLowerCase()==="discord")?.url||a?.discord?.invite||null,h=ow.has(l),p=l==="lockdown"?rw.has(i):iw.has(i),[x,g]=m.useState(()=>new Date),y=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,f]);if(m.useEffect(()=>{const j=setInterval(()=>g(new Date),1e3);return()=>clearInterval(j)},[]),!h||p)return null;const b=cw(l);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children:b.title}),r.jsx("p",{className:"text-sm text-slate-300",children:b.description})]}),r.jsxs("div",{className:"surface-muted space-y-0.5",children:[r.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),r.jsx("p",{className:"text-lg font-semibold text-slate-100",children:o||"No reason set."}),r.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",y]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(Sg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(td,{id:"discord",label:"Join our Discord server for updates!",url:d})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(bo,{}),r.jsx(So,{})]})]})})}const fw="/assets/turn_alert-DVO8EZJa.mp3";function dw(a,l=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(a),i.current.volume=l,i.current.load()},[a,l]),()=>{i.current&&(i.current.volume=l,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function mw(){const{session:a,pushAlert:l}=_e(),{value:i}=Ze("audio",kt),o=Number.isFinite(i?.masterVolume)?i.masterVolume:kt.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:kt.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=dw(fw,d),p=m.useRef(new Set),x=m.useMemo(()=>a?.turnQueues||{},[a?.turnQueues]),g=a?.socketId||null;return m.useEffect(()=>{if(!g)return;const y=[];Object.entries(x).forEach(([b,j])=>{!j||!j.current||j.current!==g||p.current.has(b)||(y.push(b),p.current.add(b))}),Object.keys(x).forEach(b=>{(!x[b]||x[b].current!==g)&&p.current.delete(b)}),y.length!==0&&(y.forEach(b=>{const j=a?.roster?.find(q=>String(q.id)===String(b))?.name||b;l({title:"Your turn!",message:`You now control ${j}.`,color:"#ff5722"})}),h())},[x,h,l,a?.roster,g]),null}function hw({visible:a,mode:l,onEnterFullscreen:i,onDismiss:o}){if(!a)return null;const f=l==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}const Rg="fullscreenPromptDismissed",pw=new Set(["mobile-portrait","mobile-landscape"]),Tg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},xw=()=>{const a=Tg();if(!a)return!1;try{return a.getItem(Rg)==="1"}catch{return!1}},ox=()=>{const a=Tg();if(a)try{a.setItem(Rg,"1")}catch{}},gw=()=>{if(typeof navigator>"u")return!1;const a=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(a)},vw=()=>{if(typeof document>"u")return!1;const a=document;return!!(a.fullscreenEnabled||a.webkitFullscreenEnabled||a.mozFullScreenEnabled||a.msFullscreenEnabled)};function yw(a){const l=pw.has(a),[i,o]=m.useState(!1),[f,d]=m.useState("native"),h=m.useMemo(()=>gw(),[]),p=m.useCallback(()=>{if(!l){o(!1);return}if(xw()){o(!1);return}if(h){d("pwa-hint"),o(!0);return}if(!vw()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,l]);m.useEffect(()=>{p()},[p]),m.useEffect(()=>{if(typeof document>"u")return;const y=()=>{if(document.fullscreenElement){o(!1);return}p()};return document.addEventListener("fullscreenchange",y),document.addEventListener("webkitfullscreenchange",y),()=>{document.removeEventListener("fullscreenchange",y),document.removeEventListener("webkitfullscreenchange",y)}},[p]);const x=m.useCallback(()=>{ox(),o(!1)},[]),g=m.useCallback(async()=>{if(!l||h||typeof document>"u")return!1;const y=document.documentElement;if(!y)return!1;const b=y.requestFullscreen||y.webkitRequestFullscreen||y.mozRequestFullScreen||y.msRequestFullscreen;if(!b)return!1;try{const j=b.call(y);return j&&typeof j.then=="function"&&await j,ox(),o(!1),!0}catch(j){return console.warn("Failed to enter fullscreen",j),!1}},[h,l]);return m.useEffect(()=>{l||o(!1)},[l]),{visible:i,mode:f,enterFullscreen:g,dismiss:x}}function bw({visible:a,layout:l,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!a)return null;const{state:d}=Mt(),h=p=>{const x=!p.target.checked;f?.(x)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(Eg,{layout:l,keymap:d?.keymap||{}})})]})})}const Sw=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
`;function Aw(a){return a?a.charAt(0).toUpperCase()+a.slice(1):""}function jw(){const a=String(Sw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return a.length?(a[Math.floor(Math.random()*a.length)]||"").trim():""}function ud(){const{setNickname:a}=_e(),{value:l,status:i,save:o}=Ze("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(l.nickname||"").trim())return;f.current=!0;const h=Aw(jw()).slice(0,32);if(!h)return;(async()=>{try{await a(h)}catch{}finally{o({nickname:h})}})()},[o,a,i,l.nickname])}function Nw(){const a=On(),{connected:l,identifySession:i}=_e(),{value:o,status:f,save:d}=Ze("identity",{cookieUserId:""}),{value:h,status:p}=Ze("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),b=f==="ready"&&p==="ready",j=(o?.cookieUserId||"").trim(),q=(h?.nickname||"").trim(),C=m.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),w=m.useCallback(async()=>{if(!(!b||!l||!a?.id||x.current)){x.current=!0;try{const E=((await i({cookieUserId:j,nickname:q}))?.cookieUserId||"").trim();E&&E!==j&&d(A=>({...A||{},cookieUserId:E})),g.current=a.id,C()}catch{C(),y.current=setTimeout(()=>{w()},2e3)}finally{x.current=!1}}},[C,l,j,i,q,b,d,a?.id]);m.useEffect(()=>{!b||!l||!a?.id||g.current!==a.id&&w()},[l,b,w,a?.id]),m.useEffect(()=>{!b||!l||!a?.id||w()},[b,l,a?.id,j,q,w]),m.useEffect(()=>{const N=()=>{a?.connected&&w()},E=()=>{typeof document>"u"||document.visibilityState!=="visible"||a?.connected&&w()};return window.addEventListener("online",N),document.addEventListener("visibilitychange",E),()=>{window.removeEventListener("online",N),document.removeEventListener("visibilitychange",E)}},[w,a?.connected]),m.useEffect(()=>()=>C(),[C])}const uf=1e4,ff=28,ww=14;function fo({layout:a="desktop",className:l="",dismissable:i=!0}){const{session:o}=_e(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=a==="mobile-portrait"||a==="mobile-landscape"||a==="mobile",[h,p]=m.useState(!1),[x,g]=m.useState(ff),[y,b]=m.useState(0),j=m.useRef(null),q=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!f){p(!1);return}if(p(!0),!d||!i)return;const A=Date.now();b(uf);const M=setTimeout(()=>p(!1),uf),T=setInterval(()=>{const B=Date.now()-A;b(Math.max(0,uf-B))},250);return()=>{clearTimeout(M),clearInterval(T)}},[f,d]),m.useEffect(()=>{if(!f)return;g(ff);let A=0;const M=()=>{const B=C.current,Z=q.current;if(!B||!Z)return;const O=B.clientWidth;if(!O)return;const H=Z.scrollWidth;if(!H)return;const L=Math.min(1,O/H),V=Math.max(ww,Math.floor(ff*L));g(V)};A=window.requestAnimationFrame(M);const T=new ResizeObserver(()=>{window.cancelAnimationFrame(A),A=window.requestAnimationFrame(M)});return j.current&&T.observe(j.current),()=>{window.cancelAnimationFrame(A),T.disconnect()}},[f]);const w=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",l].filter(Boolean).join(" "),[l,d]);if(!f||!h)return null;const N=d?Math.ceil(y/1e3):null,E=i?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:j,className:w,style:{fontSize:`${x}px`,lineHeight:1.1},...E,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:q,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[N,"s"]}):null]})})}function Cw(){const[a,l]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?l("desktop"):o>f?l("mobile-landscape"):l("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),a}function Ew({layout:a,onOpenHelpOverlay:l}){return r.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[r.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[r.jsx(nd,{}),r.jsx(TS,{}),r.jsx(Pf,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(fo,{layout:a}),r.jsx(sw,{layout:a,onOpenHelpOverlay:l})]})]})}function Dg({layout:a,onOpenHelpOverlay:l,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=_e(),{state:d}=Mt(),{value:h}=Ze("vipAudio",{openMicEnabled:!1,pttMode:"live"}),p=f?.isVerified?"bg-emerald-400":"bg-amber-400",x=String(f?.assignment?.roverId||"").trim(),g=x?f?.audioForward?.[x]:null,y=!!d?.mic?.pttActive,b=!!h?.openMicEnabled,j=h?.pttMode==="clip"?"clip":"live",q=!!(x&&f?.isVerified&&(j==="clip"?y:b||y)),C=!!(x&&f?.isVerified&&j==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(id,{defaultTab:"chat",children:[r.jsxs(rd,{children:[r.jsx(Jt,{id:"chat",children:"Chat"}),r.jsx(Jt,{id:"vip",highlight:C?"green":q?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${p}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Jt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Jt,{id:"help",children:"Help"}),r.jsx(Jt,{id:"settings",children:"Settings"})]}),r.jsxs(od,{children:[r.jsx(Pt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(bo,{}),r.jsx(uo,{})]})}),r.jsx(Pt,{id:"vip",keepMounted:!0,children:r.jsx(qg,{})}),r.jsx(Pt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(bg,{}),r.jsx(Jf,{panelId:i})]})}),r.jsx(Pt,{id:"help",children:r.jsx(kg,{layout:a,onOpenOverlay:l})}),r.jsx(Pt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(wg,{}),r.jsx(Pf,{})]})})]})]})})}function kw({onOpenHelpOverlay:a,swapMobileControlColumns:l=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(nd,{layoutFormat:"mobile-portrait"}),r.jsx(sj,{swapColumns:l}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Gf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(Ao,{})]}),r.jsx(Dg,{layout:"mobile-portrait",onOpenHelpOverlay:a,roomPanelId:"mobile-portrait-room"})]})}function Mw({onOpenHelpOverlay:a,swapMobileControlColumns:l=!1}){const i="self-start h-[min(100svh,32rem)]",o=l?r.jsx(co,{layout:"landscape",className:i}):r.jsx(oo,{layout:"landscape",className:i}),f=l?r.jsx(oo,{layout:"landscape",className:i}):r.jsx(co,{layout:"landscape",className:i});return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,r.jsxs("div",{children:[r.jsx(nd,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Gf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(Ao,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Dg,{layout:"mobile-landscape",onOpenHelpOverlay:a,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function qw(){const a=Cw(),l=a==="desktop",i=yw(a);return r.jsx("div",{className:`bg-black text-slate-100 ${l?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(Rw,{layout:a,isDesktop:l,fullscreen:i})})}function Rw({layout:a,isDesktop:l,fullscreen:i}){ud(),Nw();const{visible:o,mode:f,enterFullscreen:d,dismiss:h}=i,{value:p,status:x,save:g}=Ze("help",{showOnLoad:!0}),{value:y}=Ze("page",{swapMobileControlColumns:!1}),b=!!y?.swapMobileControlColumns,[j,q]=m.useState(!1);m.useEffect(()=>{x==="ready"&&q(p?.showOnLoad!==!1)},[x,p?.showOnLoad]);const C=m.useCallback(()=>q(!0),[]),w=m.useCallback(()=>q(!1),[]),N=m.useCallback(A=>{const M=!!A;g(T=>({...T??{},showOnLoad:M})),M||q(!1)},[g]),E=m.useMemo(()=>l?r.jsx(Ew,{layout:a,onOpenHelpOverlay:C}):a==="mobile-landscape"?r.jsx(Mw,{onOpenHelpOverlay:C,swapMobileControlColumns:b}):r.jsx(kw,{onOpenHelpOverlay:C,swapMobileControlColumns:b}),[l,a,C,b]);return r.jsxs(AA,{children:[r.jsx(DA,{}),r.jsx(ZA,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${l?"h-full overflow-hidden":""}`,children:[l?null:r.jsx(fo,{layout:a}),E]}),r.jsx(Xf,{}),r.jsx(mw,{}),r.jsx(uw,{}),r.jsx(bw,{visible:j,layout:a,onClose:w,showOnLoad:p?.showOnLoad!==!1,onToggleShowOnLoad:N}),r.jsx(hw,{visible:o,mode:f,onEnterFullscreen:d,onDismiss:h})]})}function _g(){const{session:a,setRole:l,subscribeAll:i,connected:o}=_e(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(a?.mode==="lockdown"){d(!1);return}try{a?.role!=="spectator"&&await l("spectator"),await i(),h||d(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||d(!1)}}return p(),()=>{h=!0}},[o,a?.mode,a?.role,l,i]),f}function Tw(){const[a,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>l(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),a}function Dw({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f} (turns)`:f}function _w({rover:a,frame:l,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const p=Dw({roverId:a.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(pi,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:a.name,telemetryFrame:l,batteryConfig:a.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function Ow({roster:a,frames:l,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return a.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:a.map(p=>r.jsx(_w,{rover:p,frame:l[p.id],sessionInfo:h&&i[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:f[`${p.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function Bw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(Jf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Lw({className:a=""}){return r.jsx("div",{className:`panel ${a}`,children:r.jsx(Pf,{})})}function zw(){const{session:a}=_e(),l=a?.mode==="lockdown",i=!!a?.isLocalNetwork;ud(),_g();const o=Tw(),f=$f(),d=a?.roster??[],h=Wf(d.map(N=>N.id),{enabled:!l&&!i,version:a?.mode}),p=i?d.map(N=>({type:"rover",id:N.id,key:N.id})):[],x=mi(p,{enabled:!l&&i,version:a?.mode}),g=d.flatMap(N=>N.media?.audioPublishUrl?[{type:"rover",id:`${N.id}-audio`,key:`${N.id}-audio`}]:[]),y=mi(g,{enabled:!l,version:a?.mode});if(l)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const b=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",j=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",q=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="",w=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:b,children:[r.jsxs("section",{className:q,children:[o?r.jsxs("div",{className:`${C} ${w} flex flex-col gap-0.5`,children:[r.jsx(fo,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(uo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsx("div",{className:C,children:r.jsx(fo,{layout:"desktop",dismissable:!1,className:"text-sm"})}),r.jsx("div",{className:`${C} ${o?`${w} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(Ao,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${C} flex-1 min-h-0`,children:r.jsx(uo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${C} ${o?w:"flex-[1.1] min-h-0"}`,children:r.jsx(bo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${C} ${o?w:""}`,children:r.jsx(Lw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:j,children:[r.jsx(Ow,{roster:d,frames:f,videoSources:x,snapshotFeeds:h,audioSources:y,session:a,canSpectateVideo:i}),r.jsx(Bw,{})]})]}),r.jsx(Xf,{})]})}function Uw(){return r.jsx(zw,{})}const Hw=2e4,Vw=3600*1e3;function $w({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f}`:f}function Gw({rover:a,frame:l}){const i=l?.sensors?.batteryChargeMah??null,o=a?.battery??null;return yg({batteryState:a?.batteryState??null,charge:i,config:o})}function cx({rover:a,frame:l,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=Gw({rover:a,frame:l}),y=g?.available?g.percentDisplay:null,b=x==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(kf,{visual:g,orientation:b?"vertical":"horizontal",variant:"background"}),b?r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:y==null?"--%":`${y}%`})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Il,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:y==null?"--%":`${y}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(pi,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:a.name||a.id,telemetryFrame:l,batteryConfig:a.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function Il({children:a,className:l="",maxSize:i=1e3,minSize:o=14}){const f=m.useRef(null),d=m.useRef(null),[h,p]=m.useState(i);return m.useLayoutEffect(()=>{const x=f.current,g=d.current;if(!x||!g)return;let y=null;const b=()=>{const C=x.clientWidth;if(!C){j();return}let w=o,N=i,E=o;for(;w<=N;){const A=Math.floor((w+N)/2);g.style.fontSize=`${A}px`,g.scrollWidth<=C?(E=A,w=A+1):N=A-1}p(E)},j=()=>{y&&cancelAnimationFrame(y),y=requestAnimationFrame(b)};j();const q=new ResizeObserver(j);return q.observe(x),()=>{y&&cancelAnimationFrame(y),q.disconnect()}},[a,i,o]),r.jsx("div",{ref:f,className:"w-full min-w-0",children:r.jsx("div",{ref:d,className:`whitespace-nowrap ${l}`,style:{fontSize:`${h}px`,lineHeight:1.1},children:a})})}function Yw(){const{session:a}=_e(),l=_g();ud();const i=a?.mode==="lockdown",o=!!a?.isLocalNetwork,f=$f(),d=a?.roster??[],[h,p]=m.useState(0),x=a?.activeDrivers||{},g=m.useMemo(()=>d.filter(V=>x[V.id]),[d,x]),y=g.length?g:d,b=Wf(y.map(V=>V.id),{enabled:!i&&!o,version:a?.mode}),j=m.useMemo(()=>o?y.map(V=>({type:"rover",id:V.id,key:V.id})):[],[o,y]),q=mi(j,{enabled:!i&&o,version:a?.mode}),C=m.useMemo(()=>g.flatMap(V=>{if(!V?.id||!V.media?.audioPublishUrl)return[];const K=String(V.id);return[{type:"rover",id:`${K}-audio`,key:`${K}-audio`}]}),[g]),w=mi(C,{enabled:!i,version:a?.mode}),N=m.useMemo(()=>{if(!g.length)return[];if(!o){const K=g.filter(te=>b[te.id]?.objectUrl);return K.length?K:g}const V=g.filter(K=>{const te=q[K.id];return te?.url&&!te?.error});return V.length?V:g},[g,b,q,o]),E=m.useMemo(()=>N.map(V=>({type:"rover",rover:V})),[N]),A=m.useMemo(()=>E.map(V=>`r:${V.rover.id}`).join("|"),[E]);m.useEffect(()=>{p(0)},[A]),m.useEffect(()=>{if(!E.length)return;const V=setInterval(()=>{p(K=>(K+1)%E.length)},Hw);return()=>clearInterval(V)},[E.length,A]);const M=E.length?E[h%E.length]:null,T=M?.type==="rover"?M.rover:null,B=!o&&T&&b[T.id]||null,Z=o&&T&&q[T.id]||null,O=T&&w[`${T.id}-audio`]||null,H=T&&f[T.id]||null,L=T?$w({roverId:T.id,session:a}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:l?T?r.jsx(Xw,{children:o?r.jsx("div",{className:"relative h-full w-full",children:E.map(V=>{const K=V.rover,te=T?.id===K.id;return r.jsx("div",{className:`absolute inset-0 ${te?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(pi,{sessionInfo:q[K.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:te?O:null,forceMute:!te,label:K.name||K.id,telemetryFrame:f[K.id]||null,batteryConfig:K.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},K.id)})}):r.jsx(pi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:B,audioSessionInfo:O,label:T.name||T.id,telemetryFrame:H,batteryConfig:T.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:T?r.jsx(cx,{rover:T,frame:H,driverLabel:L,sessionInfo:o?Z:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[T.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((V,K)=>r.jsx(cx,{rover:V,frame:f[V.id]||null,driverLabel:null,sessionInfo:o&&q[V.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[V.id]||null,showPreview:!0,withDivider:!1},V.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function Fw(){return m.useEffect(()=>{if(typeof window>"u")return;const a=setTimeout(()=>{const l=new URL(window.location.href);l.searchParams.set("refresh",Date.now().toString()),window.location.replace(l.toString())},Vw);return()=>clearTimeout(a)},[]),r.jsxs(r.Fragment,{children:[r.jsx(Yw,{}),r.jsx(Xf,{scale:3})]})}function Xw({children:a}){return r.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:r.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:r.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:a})})})}nb.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(wS,{children:r.jsx(ES,{children:r.jsx(kS,{children:r.jsx(LS,{children:r.jsx(NA,{children:r.jsx(g1,{children:r.jsxs(Kb,{children:[r.jsx(Fr,{path:"/",element:r.jsx(qw,{})}),r.jsx(Fr,{path:"/spectate",element:r.jsx(Uw,{})}),r.jsx(Fr,{path:"/mini",element:r.jsx(Fw,{})})]})})})})})})})}));
|