Files
MultiRoombaRover/server/public/assets/index-BVMt6HLR.js
T
2026-04-09 19:30:42 -04:00

126 lines
538 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){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 x of d.addedNodes)x.tagName==="LINK"&&x.rel==="modulepreload"&&o(x)}).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 Iy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Lu={exports:{}},ni={};var a0;function Jy(){if(a0)return ni;a0=1;var n=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(o,f,d){var x=null;if(d!==void 0&&(x=""+d),f.key!==void 0&&(x=""+f.key),"key"in f){d={};for(var h in f)h!=="key"&&(d[h]=f[h])}else d=f;return f=d.ref,{$$typeof:n,type:o,key:x,ref:f!==void 0?f:null,props:d}}return ni.Fragment=l,ni.jsx=i,ni.jsxs=i,ni}var l0;function Py(){return l0||(l0=1,Lu.exports=Jy()),Lu.exports}var r=Py(),zu={exports:{}},Ce={};var s0;function Wy(){if(s0)return Ce;s0=1;var n=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"),x=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),A=Symbol.iterator;function R(k){return k===null||typeof k!="object"?null:(k=A&&k[A]||k["@@iterator"],typeof k=="function"?k:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},q=Object.assign,j={};function w(k,H,P){this.props=k,this.context=H,this.refs=j,this.updater=P||N}w.prototype.isReactComponent={},w.prototype.setState=function(k,H){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,H,"setState")},w.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function E(){}E.prototype=w.prototype;function C(k,H,P){this.props=k,this.context=H,this.refs=j,this.updater=P||N}var M=C.prototype=new E;M.constructor=C,q(M,w.prototype),M.isPureReactComponent=!0;var U=Array.isArray;function X(){}var _={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function B(k,H,P){var ne=P.ref;return{$$typeof:n,type:k,key:H,ref:ne!==void 0?ne:null,props:P}}function z(k,H){return B(k.type,H,k.props)}function Y(k){return typeof k=="object"&&k!==null&&k.$$typeof===n}function te(k){var H={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(P){return H[P]})}var fe=/\/+/g;function ce(k,H){return typeof k=="object"&&k!==null&&k.key!=null?te(""+k.key):H.toString(36)}function G(k){switch(k.status){case"fulfilled":return k.value;case"rejected":throw k.reason;default:switch(typeof k.status=="string"?k.then(X,X):(k.status="pending",k.then(function(H){k.status==="pending"&&(k.status="fulfilled",k.value=H)},function(H){k.status==="pending"&&(k.status="rejected",k.reason=H)})),k.status){case"fulfilled":return k.value;case"rejected":throw k.reason}}throw k}function T(k,H,P,ne,pe){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 n:case l:oe=!0;break;case y:return oe=k._init,T(oe(k._payload),H,P,ne,pe)}}if(oe)return pe=pe(k),oe=ne===""?"."+ce(k,0):ne,U(pe)?(P="",oe!=null&&(P=oe.replace(fe,"$&/")+"/"),T(pe,H,P,"",function(xe){return xe})):pe!=null&&(Y(pe)&&(pe=z(pe,P+(pe.key==null||k&&k.key===pe.key?"":(""+pe.key).replace(fe,"$&/")+"/")+oe)),H.push(pe)),1;oe=0;var ve=ne===""?".":ne+":";if(U(k))for(var ye=0;ye<k.length;ye++)ne=k[ye],ie=ve+ce(ne,ye),oe+=T(ne,H,P,ie,pe);else if(ye=R(k),typeof ye=="function")for(k=ye.call(k),ye=0;!(ne=k.next()).done;)ne=ne.value,ie=ve+ce(ne,ye++),oe+=T(ne,H,P,ie,pe);else if(ie==="object"){if(typeof k.then=="function")return T(G(k),H,P,ne,pe);throw H=String(k),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return oe}function F(k,H,P){if(k==null)return k;var ne=[],pe=0;return T(k,ne,"","",function(ie){return H.call(P,ie,pe++)}),ne}function J(k){if(k._status===-1){var H=k._result;H=H(),H.then(function(P){(k._status===0||k._status===-1)&&(k._status=1,k._result=P)},function(P){(k._status===0||k._status===-1)&&(k._status=2,k._result=P)}),k._status===-1&&(k._status=0,k._result=H)}if(k._status===1)return k._result.default;throw k._result}var le=typeof reportError=="function"?reportError:function(k){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=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(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",k);return}console.error(k)},de={map:F,forEach:function(k,H,P){F(k,function(){H.apply(this,arguments)},P)},count:function(k){var H=0;return F(k,function(){H++}),H},toArray:function(k){return F(k,function(H){return H})||[]},only:function(k){if(!Y(k))throw Error("React.Children.only expected to receive a single React element child.");return k}};return Ce.Activity=b,Ce.Children=de,Ce.Component=w,Ce.Fragment=i,Ce.Profiler=f,Ce.PureComponent=C,Ce.StrictMode=o,Ce.Suspense=p,Ce.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,Ce.__COMPILER_RUNTIME={__proto__:null,c:function(k){return _.H.useMemoCache(k)}},Ce.cache=function(k){return function(){return k.apply(null,arguments)}},Ce.cacheSignal=function(){return null},Ce.cloneElement=function(k,H,P){if(k==null)throw Error("The argument must be a React element, but you passed "+k+".");var ne=q({},k.props),pe=k.key;if(H!=null)for(ie in H.key!==void 0&&(pe=""+H.key),H)!K.call(H,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&H.ref===void 0||(ne[ie]=H[ie]);var ie=arguments.length-2;if(ie===1)ne.children=P;else if(1<ie){for(var oe=Array(ie),ve=0;ve<ie;ve++)oe[ve]=arguments[ve+2];ne.children=oe}return B(k.type,pe,ne)},Ce.createContext=function(k){return k={$$typeof:x,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null},k.Provider=k,k.Consumer={$$typeof:d,_context:k},k},Ce.createElement=function(k,H,P){var ne,pe={},ie=null;if(H!=null)for(ne in H.key!==void 0&&(ie=""+H.key),H)K.call(H,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(pe[ne]=H[ne]);var oe=arguments.length-2;if(oe===1)pe.children=P;else if(1<oe){for(var ve=Array(oe),ye=0;ye<oe;ye++)ve[ye]=arguments[ye+2];pe.children=ve}if(k&&k.defaultProps)for(ne in oe=k.defaultProps,oe)pe[ne]===void 0&&(pe[ne]=oe[ne]);return B(k,ie,pe)},Ce.createRef=function(){return{current:null}},Ce.forwardRef=function(k){return{$$typeof:h,render:k}},Ce.isValidElement=Y,Ce.lazy=function(k){return{$$typeof:y,_payload:{_status:-1,_result:k},_init:J}},Ce.memo=function(k,H){return{$$typeof:g,type:k,compare:H===void 0?null:H}},Ce.startTransition=function(k){var H=_.T,P={};_.T=P;try{var ne=k(),pe=_.S;pe!==null&&pe(P,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(X,le)}catch(ie){le(ie)}finally{H!==null&&P.types!==null&&(H.types=P.types),_.T=H}},Ce.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},Ce.use=function(k){return _.H.use(k)},Ce.useActionState=function(k,H,P){return _.H.useActionState(k,H,P)},Ce.useCallback=function(k,H){return _.H.useCallback(k,H)},Ce.useContext=function(k){return _.H.useContext(k)},Ce.useDebugValue=function(){},Ce.useDeferredValue=function(k,H){return _.H.useDeferredValue(k,H)},Ce.useEffect=function(k,H){return _.H.useEffect(k,H)},Ce.useEffectEvent=function(k){return _.H.useEffectEvent(k)},Ce.useId=function(){return _.H.useId()},Ce.useImperativeHandle=function(k,H,P){return _.H.useImperativeHandle(k,H,P)},Ce.useInsertionEffect=function(k,H){return _.H.useInsertionEffect(k,H)},Ce.useLayoutEffect=function(k,H){return _.H.useLayoutEffect(k,H)},Ce.useMemo=function(k,H){return _.H.useMemo(k,H)},Ce.useOptimistic=function(k,H){return _.H.useOptimistic(k,H)},Ce.useReducer=function(k,H,P){return _.H.useReducer(k,H,P)},Ce.useRef=function(k){return _.H.useRef(k)},Ce.useState=function(k){return _.H.useState(k)},Ce.useSyncExternalStore=function(k,H,P){return _.H.useSyncExternalStore(k,H,P)},Ce.useTransition=function(){return _.H.useTransition()},Ce.version="19.2.0",Ce}var i0;function Tf(){return i0||(i0=1,zu.exports=Wy()),zu.exports}var m=Tf();const rl=Iy(m);var Uu={exports:{}},ai={},Hu={exports:{}},Vu={};var r0;function eb(){return r0||(r0=1,(function(n){function l(T,F){var J=T.length;T.push(F);e:for(;0<J;){var le=J-1>>>1,de=T[le];if(0<f(de,F))T[le]=F,T[J]=de,J=le;else break e}}function i(T){return T.length===0?null:T[0]}function o(T){if(T.length===0)return null;var F=T[0],J=T.pop();if(J!==F){T[0]=J;e:for(var le=0,de=T.length,k=de>>>1;le<k;){var H=2*(le+1)-1,P=T[H],ne=H+1,pe=T[ne];if(0>f(P,J))ne<de&&0>f(pe,P)?(T[le]=pe,T[ne]=J,le=ne):(T[le]=P,T[H]=J,le=H);else if(ne<de&&0>f(pe,J))T[le]=pe,T[ne]=J,le=ne;else break e}}return F}function f(T,F){var J=T.sortIndex-F.sortIndex;return J!==0?J:T.id-F.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var x=Date,h=x.now();n.unstable_now=function(){return x.now()-h}}var p=[],g=[],y=1,b=null,A=3,R=!1,N=!1,q=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;function M(T){for(var F=i(g);F!==null;){if(F.callback===null)o(g);else if(F.startTime<=T)o(g),F.sortIndex=F.expirationTime,l(p,F);else break;F=i(g)}}function U(T){if(q=!1,M(T),!N)if(i(p)!==null)N=!0,X||(X=!0,te());else{var F=i(g);F!==null&&G(U,F.startTime-T)}}var X=!1,_=-1,K=5,B=-1;function z(){return j?!0:!(n.unstable_now()-B<K)}function Y(){if(j=!1,X){var T=n.unstable_now();B=T;var F=!0;try{e:{N=!1,q&&(q=!1,E(_),_=-1),R=!0;var J=A;try{t:{for(M(T),b=i(p);b!==null&&!(b.expirationTime>T&&z());){var le=b.callback;if(typeof le=="function"){b.callback=null,A=b.priorityLevel;var de=le(b.expirationTime<=T);if(T=n.unstable_now(),typeof de=="function"){b.callback=de,M(T),F=!0;break t}b===i(p)&&o(p),M(T)}else o(p);b=i(p)}if(b!==null)F=!0;else{var k=i(g);k!==null&&G(U,k.startTime-T),F=!1}}break e}finally{b=null,A=J,R=!1}F=void 0}}finally{F?te():X=!1}}}var te;if(typeof C=="function")te=function(){C(Y)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,ce=fe.port2;fe.port1.onmessage=Y,te=function(){ce.postMessage(null)}}else te=function(){w(Y,0)};function G(T,F){_=w(function(){T(n.unstable_now())},F)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return A},n.unstable_next=function(T){switch(A){case 1:case 2:case 3:var F=3;break;default:F=A}var J=A;A=F;try{return T()}finally{A=J}},n.unstable_requestPaint=function(){j=!0},n.unstable_runWithPriority=function(T,F){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=A;A=T;try{return F()}finally{A=J}},n.unstable_scheduleCallback=function(T,F,J){var le=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?le+J:le):J=le,T){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=J+de,T={id:y++,callback:F,priorityLevel:T,startTime:J,expirationTime:de,sortIndex:-1},J>le?(T.sortIndex=J,l(g,T),i(p)===null&&T===i(g)&&(q?(E(_),_=-1):q=!0,G(U,J-le))):(T.sortIndex=de,l(p,T),N||R||(N=!0,X||(X=!0,te()))),T},n.unstable_shouldYield=z,n.unstable_wrapCallback=function(T){var F=A;return function(){var J=A;A=F;try{return T.apply(this,arguments)}finally{A=J}}}})(Vu)),Vu}var o0;function tb(){return o0||(o0=1,Hu.exports=eb()),Hu.exports}var $u={exports:{}},Ot={};var c0;function nb(){if(c0)return Ot;c0=1;var n=Tf();function l(p){var g="https://react.dev/errors/"+p;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 #"+p+"; 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(p,g,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:p,containerInfo:g,implementation:y}}var x=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,g){if(p==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Ot.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Ot.createPortal=function(p,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(p,g,null,y)},Ot.flushSync=function(p){var g=x.T,y=o.p;try{if(x.T=null,o.p=2,p)return p()}finally{x.T=g,o.p=y,o.d.f()}},Ot.preconnect=function(p,g){typeof p=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(p,g))},Ot.prefetchDNS=function(p){typeof p=="string"&&o.d.D(p)},Ot.preinit=function(p,g){if(typeof p=="string"&&g&&typeof g.as=="string"){var y=g.as,b=h(y,g.crossOrigin),A=typeof g.integrity=="string"?g.integrity:void 0,R=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;y==="style"?o.d.S(p,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:A,fetchPriority:R}):y==="script"&&o.d.X(p,{crossOrigin:b,integrity:A,fetchPriority:R,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Ot.preinitModule=function(p,g){if(typeof p=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var y=h(g.as,g.crossOrigin);o.d.M(p,{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(p)},Ot.preload=function(p,g){if(typeof p=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var y=g.as,b=h(y,g.crossOrigin);o.d.L(p,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})}},Ot.preloadModule=function(p,g){if(typeof p=="string")if(g){var y=h(g.as,g.crossOrigin);o.d.m(p,{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(p)},Ot.requestFormReset=function(p){o.d.r(p)},Ot.unstable_batchedUpdates=function(p,g){return p(g)},Ot.useFormState=function(p,g,y){return x.H.useFormState(p,g,y)},Ot.useFormStatus=function(){return x.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var u0;function ab(){if(u0)return $u.exports;u0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(l){console.error(l)}}return n(),$u.exports=nb(),$u.exports}var f0;function lb(){if(f0)return ai;f0=1;var n=tb(),l=Tf(),i=ab();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function x(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function h(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(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 a=e,s=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(s=c.return,s!==null){a=s;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return p(c),e;if(u===s)return p(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==s.return)a=c,s=u;else{for(var v=!1,S=c.child;S;){if(S===a){v=!0,a=c,s=u;break}if(S===s){v=!0,s=c,a=u;break}S=S.sibling}if(!v){for(S=u.child;S;){if(S===a){v=!0,a=u,s=c;break}if(S===s){v=!0,s=u,a=c;break}S=S.sibling}if(!v)throw Error(o(189))}}if(a.alternate!==s)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?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,A=Symbol.for("react.element"),R=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),C=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),z=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=Y&&e[Y]||e["@@iterator"],typeof e=="function"?e:null)}var fe=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case q:return"Fragment";case w:return"Profiler";case j:return"StrictMode";case U:return"Suspense";case X:return"SuspenseList";case B:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case N:return"Portal";case C:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case M:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case K:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var G=Array.isArray,T=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},le=[],de=-1;function k(e){return{current:e}}function H(e){0>de||(e.current=le[de],le[de]=null,de--)}function P(e,t){de++,le[de]=e.current,e.current=t}var ne=k(null),pe=k(null),ie=k(null),oe=k(null);function ve(e,t){switch(P(ie,t),P(pe,e),P(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Cp(t),e=Ep(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(ne),P(ne,e)}function ye(){H(ne),H(pe),H(ie)}function xe(e){e.memoizedState!==null&&P(oe,e);var t=ne.current,a=Ep(t,e.type);t!==a&&(P(pe,e),P(ne,a))}function Ue(e){pe.current===e&&(H(ne),H(pe)),oe.current===e&&(H(oe),Ps._currentValue=J)}var $e,Ne;function ae(e){if($e===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);$e=t&&t[1]||"",Ne=-1<a.stack.indexOf(`
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+$e+e+Ne}var ue=!1;function be(e,t){if(!e||ue)return"";ue=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(Z){var Q=Z}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(Z){Q=Z}e.call(ee.prototype)}}else{try{throw Error()}catch(Z){Q=Z}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(Z){if(Z&&Q&&typeof Z.stack=="string")return[Z.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(`
`),$=S.split(`
`);for(c=s=0;s<D.length&&!D[s].includes("DetermineComponentFrameRoot");)s++;for(;c<$.length&&!$[c].includes("DetermineComponentFrameRoot");)c++;if(s===D.length||c===$.length)for(s=D.length-1,c=$.length-1;1<=s&&0<=c&&D[s]!==$[c];)c--;for(;1<=s&&0<=c;s--,c--)if(D[s]!==$[c]){if(s!==1||c!==1)do if(s--,c--,0>c||D[s]!==$[c]){var I=`
`+D[s].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=s&&0<=c);break}}}finally{ue=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?ae(a):""}function Me(e,t){switch(e.tag){case 26:case 27:case 5:return ae(e.type);case 16:return ae("Lazy");case 13:return e.child!==t&&t!==null?ae("Suspense Fallback"):ae("Suspense");case 19:return ae("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ae("Activity");default:return""}}function se(e){try{var t="",a=null;do t+=Me(e,a),a=e,e=e.return;while(e);return t}catch(s){return`
Error generating stack: `+s.message+`
`+s.stack}}var re=Object.prototype.hasOwnProperty,me=n.unstable_scheduleCallback,we=n.unstable_cancelCallback,et=n.unstable_shouldYield,dt=n.unstable_requestPaint,Le=n.unstable_now,xt=n.unstable_getCurrentPriorityLevel,mt=n.unstable_ImmediatePriority,Tn=n.unstable_UserBlockingPriority,Et=n.unstable_NormalPriority,cl=n.unstable_LowPriority,Gt=n.unstable_IdlePriority,Oa=n.log,Co=n.unstable_setDisableYieldValue,Dn=null,At=null;function Yt(e){if(typeof Oa=="function"&&Co(e),At&&typeof At.setStrictMode=="function")try{At.setStrictMode(Dn,e)}catch{}}var kt=Math.clz32?Math.clz32:ul,ca=Math.log,Eo=Math.LN2;function ul(e){return e>>>=0,e===0?32:31-(ca(e)/Eo|0)|0}var fl=256,Ba=262144,tt=4194304;function _n(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 An(e,t,a){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=_n(s):(v&=S,v!==0?c=_n(v):a||(a=S&~e,a!==0&&(c=_n(a))))):(S=s&~u,S!==0?c=_n(S):v!==0?c=_n(v):a||(a=s&~e,a!==0&&(c=_n(a)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,a=t&-t,u>=a||u===32&&(a&4194048)!==0)?t:c}function On(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function dl(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 us(){var e=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),e}function fs(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function La(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ko(e,t,a,s,c,u){var v=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var S=e.entanglements,D=e.expirationTimes,$=e.hiddenUpdates;for(a=v&~a;0<a;){var I=31-kt(a),ee=1<<I;S[I]=0,D[I]=-1;var Q=$[I];if(Q!==null)for($[I]=null,I=0;I<Q.length;I++){var Z=Q[I];Z!==null&&(Z.lane&=-536870913)}a&=~ee}s!==0&&ds(e,s,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function ds(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-kt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|a&261930}function en(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var s=31-kt(a),c=1<<s;c&t|e[s]&t&&(e[s]|=t),a&=~c}}function Ae(e,t){var a=t&-t;return a=(a&42)!==0?1:Ke(a),(a&(e.suspendedLanes|t))!==0?0:a}function Ke(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 Pe(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function qe(){var e=F.p;return e!==0?e:(e=window.event,e===void 0?32:Ip(e.type))}function Ye(e,t){var a=F.p;try{return F.p=e,t()}finally{F.p=a}}var it=Math.random().toString(36).slice(2),rt="__reactFiber$"+it,jt="__reactProps$"+it,lt="__reactContainer$"+it,Bn="__reactEvents$"+it,Ug="__reactListeners$"+it,Hg="__reactHandles$"+it,md="__reactResources$"+it,ms="__reactMarker$"+it;function Mo(e){delete e[rt],delete e[jt],delete e[Bn],delete e[Ug],delete e[Hg]}function ml(e){var t=e[rt];if(t)return t;for(var a=e.parentNode;a;){if(t=a[lt]||a[rt]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=_p(e);e!==null;){if(a=e[rt])return a;e=_p(e)}return t}e=a,a=e.parentNode}return null}function hl(e){if(e=e[rt]||e[lt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function hs(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function pl(e){var t=e[md];return t||(t=e[md]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function wt(e){e[ms]=!0}var hd=new Set,pd={};function za(e,t){xl(e,t),xl(e+"Capture",t)}function xl(e,t){for(pd[e]=t,e=0;e<t.length;e++)hd.add(t[e])}var Vg=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]*$"),xd={},gd={};function $g(e){return re.call(gd,e)?!0:re.call(xd,e)?!1:Vg.test(e)?gd[e]=!0:(xd[e]=!0,!1)}function Mi(e,t,a){if($g(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){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,""+a)}}function qi(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Ln(e,t,a,s){if(s===null)e.removeAttribute(a);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+s)}}function tn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Gg(e,t,a){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){a=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return a},setValue:function(v){a=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qo(e){if(!e._valueTracker){var t=vd(e)?"checked":"value";e._valueTracker=Gg(e,t,""+e[t])}}function yd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),s="";return e&&(s=vd(e)?e.checked?"true":"false":e.value),e=s,e!==a?(t.setValue(e),!0):!1}function Ri(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 Yg=/[\n"\\]/g;function nn(e){return e.replace(Yg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Ro(e,t,a,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=""+tn(t)):e.value!==""+tn(t)&&(e.value=""+tn(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?To(e,v,tn(t)):a!=null?To(e,v,tn(a)):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=""+tn(S):e.removeAttribute("name")}function bd(e,t,a,s,c,u,v,S){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||a!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){qo(e);return}a=a!=null?""+tn(a):"",t=t!=null?""+tn(t):a,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),qo(e)}function To(e,t,a){t==="number"&&Ri(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function gl(e,t,a,s){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&s&&(e[a].defaultSelected=!0)}else{for(a=""+tn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,s&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Sd(e,t,a){if(t!=null&&(t=""+tn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+tn(a):""}function Ad(e,t,a,s){if(t==null){if(s!=null){if(a!=null)throw Error(o(92));if(G(s)){if(1<s.length)throw Error(o(93));s=s[0]}a=s}a==null&&(a=""),t=a}a=tn(t),e.defaultValue=a,s=e.textContent,s===a&&s!==""&&s!==null&&(e.value=s),qo(e)}function vl(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var Fg=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 jd(e,t,a){var s=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,a):typeof a!="number"||a===0||Fg.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Nd(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var s in a)!a.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)&&a[c]!==s&&jd(e,c,s)}else for(var u in t)t.hasOwnProperty(u)&&jd(e,u,t[u])}function Do(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 Xg=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"]]),Qg=/^[\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 Ti(e){return Qg.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function zn(){}var _o=null;function Oo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var yl=null,bl=null;function wd(e){var t=hl(e);if(t&&(e=t.stateNode)){var a=e[jt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Ro(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+nn(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var s=a[t];if(s!==e&&s.form===e.form){var c=s[jt]||null;if(!c)throw Error(o(90));Ro(s,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)s=a[t],s.form===e.form&&yd(s)}break e;case"textarea":Sd(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&gl(e,!!a.multiple,t,!1)}}}var Bo=!1;function Cd(e,t,a){if(Bo)return e(t,a);Bo=!0;try{var s=e(t);return s}finally{if(Bo=!1,(yl!==null||bl!==null)&&(yr(),yl&&(t=yl,e=bl,bl=yl=null,wd(t),e)))for(t=0;t<e.length;t++)wd(e[t])}}function ps(e,t){var a=e.stateNode;if(a===null)return null;var s=a[jt]||null;if(s===null)return null;a=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(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Un=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Lo=!1;if(Un)try{var xs={};Object.defineProperty(xs,"passive",{get:function(){Lo=!0}}),window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{Lo=!1}var ua=null,zo=null,Di=null;function Ed(){if(Di)return Di;var e,t=zo,a=t.length,s,c="value"in ua?ua.value:ua.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var v=a-e;for(s=1;s<=v&&t[a-s]===c[u-s];s++);return Di=c.slice(e,1<s?1-s:void 0)}function _i(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 Oi(){return!0}function kd(){return!1}function Lt(e){function t(a,s,c,u,v){this._reactName=a,this._targetInst=c,this.type=s,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var S in e)e.hasOwnProperty(S)&&(a=e[S],this[S]=a?a(u):u[S]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Oi:kd,this.isPropagationStopped=kd,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Oi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Oi)},persist:function(){},isPersistent:Oi}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=Lt(Ua),gs=b({},Ua,{view:0,detail:0}),Kg=Lt(gs),Uo,Ho,vs,Li=b({},gs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$o,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!==vs&&(vs&&e.type==="mousemove"?(Uo=e.screenX-vs.screenX,Ho=e.screenY-vs.screenY):Ho=Uo=0,vs=e),Uo)},movementY:function(e){return"movementY"in e?e.movementY:Ho}}),Md=Lt(Li),Zg=b({},Li,{dataTransfer:0}),Ig=Lt(Zg),Jg=b({},gs,{relatedTarget:0}),Vo=Lt(Jg),Pg=b({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),Wg=Lt(Pg),ev=b({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tv=Lt(ev),nv=b({},Ua,{data:0}),qd=Lt(nv),av={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lv={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"},sv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function iv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=sv[e])?!!t[e]:!1}function $o(){return iv}var rv=b({},gs,{key:function(e){if(e.key){var t=av[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_i(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?lv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$o,charCode:function(e){return e.type==="keypress"?_i(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_i(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ov=Lt(rv),cv=b({},Li,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Rd=Lt(cv),uv=b({},gs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$o}),fv=Lt(uv),dv=b({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),mv=Lt(dv),hv=b({},Li,{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}),pv=Lt(hv),xv=b({},Ua,{newState:0,oldState:0}),gv=Lt(xv),vv=[9,13,27,32],Go=Un&&"CompositionEvent"in window,ys=null;Un&&"documentMode"in document&&(ys=document.documentMode);var yv=Un&&"TextEvent"in window&&!ys,Td=Un&&(!Go||ys&&8<ys&&11>=ys),Dd=" ",_d=!1;function Od(e,t){switch(e){case"keyup":return vv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sl=!1;function bv(e,t){switch(e){case"compositionend":return Bd(t);case"keypress":return t.which!==32?null:(_d=!0,Dd);case"textInput":return e=t.data,e===Dd&&_d?null:e;default:return null}}function Sv(e,t){if(Sl)return e==="compositionend"||!Go&&Od(e,t)?(e=Ed(),Di=zo=ua=null,Sl=!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 Td&&t.locale!=="ko"?null:t.data;default:return null}}var Av={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 Ld(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Av[e.type]:t==="textarea"}function zd(e,t,a,s){yl?bl?bl.push(s):bl=[s]:yl=s,t=Cr(t,"onChange"),0<t.length&&(a=new Bi("onChange","change",null,a,s),e.push({event:a,listeners:t}))}var bs=null,Ss=null;function jv(e){bp(e,0)}function zi(e){var t=hs(e);if(yd(t))return e}function Ud(e,t){if(e==="change")return t}var Hd=!1;if(Un){var Yo;if(Un){var Fo="oninput"in document;if(!Fo){var Vd=document.createElement("div");Vd.setAttribute("oninput","return;"),Fo=typeof Vd.oninput=="function"}Yo=Fo}else Yo=!1;Hd=Yo&&(!document.documentMode||9<document.documentMode)}function $d(){bs&&(bs.detachEvent("onpropertychange",Gd),Ss=bs=null)}function Gd(e){if(e.propertyName==="value"&&zi(Ss)){var t=[];zd(t,Ss,e,Oo(e)),Cd(jv,t)}}function Nv(e,t,a){e==="focusin"?($d(),bs=t,Ss=a,bs.attachEvent("onpropertychange",Gd)):e==="focusout"&&$d()}function wv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zi(Ss)}function Cv(e,t){if(e==="click")return zi(t)}function Ev(e,t){if(e==="input"||e==="change")return zi(t)}function kv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ft=typeof Object.is=="function"?Object.is:kv;function As(e,t){if(Ft(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(s=0;s<a.length;s++){var c=a[s];if(!re.call(t,c)||!Ft(e[c],t[c]))return!1}return!0}function Yd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Fd(e,t){var a=Yd(e);e=0;for(var s;a;){if(a.nodeType===3){if(s=e+a.textContent.length,e<=t&&s>=t)return{node:a,offset:t-e};e=s}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Yd(a)}}function Xd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ri(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Ri(e.document)}return t}function Xo(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 Mv=Un&&"documentMode"in document&&11>=document.documentMode,Al=null,Qo=null,js=null,Ko=!1;function Kd(e,t,a){var s=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ko||Al==null||Al!==Ri(s)||(s=Al,"selectionStart"in s&&Xo(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}),js&&As(js,s)||(js=s,s=Cr(Qo,"onSelect"),0<s.length&&(t=new Bi("onSelect","select",null,t,a),e.push({event:t,listeners:s}),t.target=Al)))}function Ha(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var jl={animationend:Ha("Animation","AnimationEnd"),animationiteration:Ha("Animation","AnimationIteration"),animationstart:Ha("Animation","AnimationStart"),transitionrun:Ha("Transition","TransitionRun"),transitionstart:Ha("Transition","TransitionStart"),transitioncancel:Ha("Transition","TransitionCancel"),transitionend:Ha("Transition","TransitionEnd")},Zo={},Zd={};Un&&(Zd=document.createElement("div").style,"AnimationEvent"in window||(delete jl.animationend.animation,delete jl.animationiteration.animation,delete jl.animationstart.animation),"TransitionEvent"in window||delete jl.transitionend.transition);function Va(e){if(Zo[e])return Zo[e];if(!jl[e])return e;var t=jl[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Zd)return Zo[e]=t[a];return e}var Id=Va("animationend"),Jd=Va("animationiteration"),Pd=Va("animationstart"),qv=Va("transitionrun"),Rv=Va("transitionstart"),Tv=Va("transitioncancel"),Wd=Va("transitionend"),em=new Map,Io="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(" ");Io.push("scrollEnd");function pn(e,t){em.set(e,t),za(t,[e])}var Ui=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)},an=[],Nl=0,Jo=0;function Hi(){for(var e=Nl,t=Jo=Nl=0;t<e;){var a=an[t];an[t++]=null;var s=an[t];an[t++]=null;var c=an[t];an[t++]=null;var u=an[t];if(an[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&&tm(a,c,u)}}function Vi(e,t,a,s){an[Nl++]=e,an[Nl++]=t,an[Nl++]=a,an[Nl++]=s,Jo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Po(e,t,a,s){return Vi(e,t,a,s),$i(e)}function $a(e,t){return Vi(e,null,null,t),$i(e)}function tm(e,t,a){e.lanes|=a;var s=e.alternate;s!==null&&(s.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,s=u.alternate,s!==null&&(s.childLanes|=a),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-kt(a),e=u.hiddenUpdates,s=e[c],s===null?e[c]=[t]:s.push(t),t.lane=a|536870912),u):null}function $i(e){if(50<Fs)throw Fs=0,ru=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var wl={};function Dv(e,t,a,s){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,a,s){return new Dv(e,t,a,s)}function Wo(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hn(e,t){var a=e.alternate;return a===null?(a=Xt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function nm(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Gi(e,t,a,s,c,u){var v=0;if(s=e,typeof e=="function")Wo(e)&&(v=1);else if(typeof e=="string")v=zy(e,a,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case B:return e=Xt(31,a,t,c),e.elementType=B,e.lanes=u,e;case q:return Ga(a.children,c,u,t);case j:v=8,c|=24;break;case w:return e=Xt(12,a,t,c|2),e.elementType=w,e.lanes=u,e;case U:return e=Xt(13,a,t,c),e.elementType=U,e.lanes=u,e;case X:return e=Xt(19,a,t,c),e.elementType=X,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case C:v=10;break e;case E:v=9;break e;case M:v=11;break e;case _:v=14;break e;case K:v=16,s=null;break e}v=29,a=Error(o(130,e===null?"null":typeof e,"")),s=null}return t=Xt(v,a,t,c),t.elementType=e,t.type=s,t.lanes=u,t}function Ga(e,t,a,s){return e=Xt(7,e,s,t),e.lanes=a,e}function ec(e,t,a){return e=Xt(6,e,null,t),e.lanes=a,e}function am(e){var t=Xt(18,null,null,0);return t.stateNode=e,t}function tc(e,t,a){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var lm=new WeakMap;function ln(e,t){if(typeof e=="object"&&e!==null){var a=lm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:se(t)},lm.set(e,t),t)}return{value:e,source:t,stack:se(t)}}var Cl=[],El=0,Yi=null,Ns=0,sn=[],rn=0,fa=null,jn=1,Nn="";function Vn(e,t){Cl[El++]=Ns,Cl[El++]=Yi,Yi=e,Ns=t}function sm(e,t,a){sn[rn++]=jn,sn[rn++]=Nn,sn[rn++]=fa,fa=e;var s=jn;e=Nn;var c=32-kt(s)-1;s&=~(1<<c),a+=1;var u=32-kt(t)+c;if(30<u){var v=c-c%5;u=(s&(1<<v)-1).toString(32),s>>=v,c-=v,jn=1<<32-kt(t)+c|a<<c|s,Nn=u+e}else jn=1<<u|a<<c|s,Nn=e}function nc(e){e.return!==null&&(Vn(e,1),sm(e,1,0))}function ac(e){for(;e===Yi;)Yi=Cl[--El],Cl[El]=null,Ns=Cl[--El],Cl[El]=null;for(;e===fa;)fa=sn[--rn],sn[rn]=null,Nn=sn[--rn],sn[rn]=null,jn=sn[--rn],sn[rn]=null}function im(e,t){sn[rn++]=jn,sn[rn++]=Nn,sn[rn++]=fa,jn=t.id,Nn=t.overflow,fa=e}var Mt=null,nt=null,Oe=!1,da=null,on=!1,lc=Error(o(519));function ma(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ws(ln(t,e)),lc}function rm(e){var t=e.stateNode,a=e.type,s=e.memoizedProps;switch(t[rt]=e,t[jt]=s,a){case"dialog":Te("cancel",t),Te("close",t);break;case"iframe":case"object":case"embed":Te("load",t);break;case"video":case"audio":for(a=0;a<Qs.length;a++)Te(Qs[a],t);break;case"source":Te("error",t);break;case"img":case"image":case"link":Te("error",t),Te("load",t);break;case"details":Te("toggle",t);break;case"input":Te("invalid",t),bd(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":Te("invalid",t);break;case"textarea":Te("invalid",t),Ad(t,s.value,s.defaultValue,s.children)}a=s.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||s.suppressHydrationWarning===!0||Np(t.textContent,a)?(s.popover!=null&&(Te("beforetoggle",t),Te("toggle",t)),s.onScroll!=null&&Te("scroll",t),s.onScrollEnd!=null&&Te("scrollend",t),s.onClick!=null&&(t.onclick=zn),t=!0):t=!1,t||ma(e,!0)}function om(e){for(Mt=e.return;Mt;)switch(Mt.tag){case 5:case 31:case 13:on=!1;return;case 27:case 3:on=!0;return;default:Mt=Mt.return}}function kl(e){if(e!==Mt)return!1;if(!Oe)return om(e),Oe=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Au(e.type,e.memoizedProps)),a=!a),a&&nt&&ma(e),om(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Dp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Dp(e)}else t===27?(t=nt,Ea(e.type)?(e=Eu,Eu=null,nt=e):nt=t):nt=Mt?un(e.stateNode.nextSibling):null;return!0}function Ya(){nt=Mt=null,Oe=!1}function sc(){var e=da;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),da=null),e}function ws(e){da===null?da=[e]:da.push(e)}var ic=k(null),Fa=null,$n=null;function ha(e,t,a){P(ic,t._currentValue),t._currentValue=a}function Gn(e){e._currentValue=ic.current,H(ic)}function rc(e,t,a){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===a)break;e=e.return}}function oc(e,t,a,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|=a,S=u.alternate,S!==null&&(S.lanes|=a),rc(u.return,a,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|=a,u=v.alternate,u!==null&&(u.lanes|=a),rc(v,a,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 Ml(e,t,a,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;Ft(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(Ps):e=[Ps])}c=c.return}e!==null&&oc(t,e,a,s),t.flags|=262144}function Fi(e){for(e=e.firstContext;e!==null;){if(!Ft(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xa(e){Fa=e,$n=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function qt(e){return cm(Fa,e)}function Xi(e,t){return Fa===null&&Xa(e),cm(e,t)}function cm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},$n===null){if(e===null)throw Error(o(308));$n=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $n=$n.next=t;return a}var _v=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Ov=n.unstable_scheduleCallback,Bv=n.unstable_NormalPriority,gt={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function cc(){return{controller:new _v,data:new Map,refCount:0}}function Cs(e){e.refCount--,e.refCount===0&&Ov(Bv,function(){e.controller.abort()})}var Es=null,uc=0,ql=0,Rl=null;function Lv(e,t){if(Es===null){var a=Es=[];uc=0,ql=mu(),Rl={status:"pending",value:void 0,then:function(s){a.push(s)}}}return uc++,t.then(um,um),t}function um(){if(--uc===0&&Es!==null){Rl!==null&&(Rl.status="fulfilled");var e=Es;Es=null,ql=0,Rl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function zv(e,t){var a=[],s={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(s.status="rejected",s.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),s}var fm=T.S;T.S=function(e,t){Kh=Le(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Lv(e,t),fm!==null&&fm(e,t)};var Qa=k(null);function fc(){var e=Qa.current;return e!==null?e:We.pooledCache}function Qi(e,t){t===null?P(Qa,Qa.current):P(Qa,t.pool)}function dm(){var e=fc();return e===null?null:{parent:gt._currentValue,pool:e}}var Tl=Error(o(460)),dc=Error(o(474)),Ki=Error(o(542)),Zi={then:function(){}};function mm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function hm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(zn,zn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,xm(e),e;default:if(typeof t.status=="string")t.then(zn,zn);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,xm(e),e}throw Za=t,Tl}}function Ka(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Za=a,Tl):a}}var Za=null;function pm(){if(Za===null)throw Error(o(459));var e=Za;return Za=null,e}function xm(e){if(e===Tl||e===Ki)throw Error(o(483))}var Dl=null,ks=0;function Ii(e){var t=ks;return ks+=1,Dl===null&&(Dl=[]),hm(Dl,e,t)}function Ms(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ji(e,t){throw t.$$typeof===A?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gm(e){function t(L,O){if(e){var V=L.deletions;V===null?(L.deletions=[O],L.flags|=16):V.push(O)}}function a(L,O){if(!e)return null;for(;O!==null;)t(L,O),O=O.sibling;return null}function s(L){for(var O=new Map;L!==null;)L.key!==null?O.set(L.key,L):O.set(L.index,L),L=L.sibling;return O}function c(L,O){return L=Hn(L,O),L.index=0,L.sibling=null,L}function u(L,O,V){return L.index=V,e?(V=L.alternate,V!==null?(V=V.index,V<O?(L.flags|=67108866,O):V):(L.flags|=67108866,O)):(L.flags|=1048576,O)}function v(L){return e&&L.alternate===null&&(L.flags|=67108866),L}function S(L,O,V,W){return O===null||O.tag!==6?(O=ec(V,L.mode,W),O.return=L,O):(O=c(O,V),O.return=L,O)}function D(L,O,V,W){var Se=V.type;return Se===q?I(L,O,V.props.children,W,V.key):O!==null&&(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===K&&Ka(Se)===O.type)?(O=c(O,V.props),Ms(O,V),O.return=L,O):(O=Gi(V.type,V.key,V.props,null,L.mode,W),Ms(O,V),O.return=L,O)}function $(L,O,V,W){return O===null||O.tag!==4||O.stateNode.containerInfo!==V.containerInfo||O.stateNode.implementation!==V.implementation?(O=tc(V,L.mode,W),O.return=L,O):(O=c(O,V.children||[]),O.return=L,O)}function I(L,O,V,W,Se){return O===null||O.tag!==7?(O=Ga(V,L.mode,W,Se),O.return=L,O):(O=c(O,V),O.return=L,O)}function ee(L,O,V){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=ec(""+O,L.mode,V),O.return=L,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case R:return V=Gi(O.type,O.key,O.props,null,L.mode,V),Ms(V,O),V.return=L,V;case N:return O=tc(O,L.mode,V),O.return=L,O;case K:return O=Ka(O),ee(L,O,V)}if(G(O)||te(O))return O=Ga(O,L.mode,V,null),O.return=L,O;if(typeof O.then=="function")return ee(L,Ii(O),V);if(O.$$typeof===C)return ee(L,Xi(L,O),V);Ji(L,O)}return null}function Q(L,O,V,W){var Se=O!==null?O.key:null;if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return Se!==null?null:S(L,O,""+V,W);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case R:return V.key===Se?D(L,O,V,W):null;case N:return V.key===Se?$(L,O,V,W):null;case K:return V=Ka(V),Q(L,O,V,W)}if(G(V)||te(V))return Se!==null?null:I(L,O,V,W,null);if(typeof V.then=="function")return Q(L,O,Ii(V),W);if(V.$$typeof===C)return Q(L,O,Xi(L,V),W);Ji(L,V)}return null}function Z(L,O,V,W,Se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return L=L.get(V)||null,S(O,L,""+W,Se);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case R:return L=L.get(W.key===null?V:W.key)||null,D(O,L,W,Se);case N:return L=L.get(W.key===null?V:W.key)||null,$(O,L,W,Se);case K:return W=Ka(W),Z(L,O,V,W,Se)}if(G(W)||te(W))return L=L.get(V)||null,I(O,L,W,Se,null);if(typeof W.then=="function")return Z(L,O,V,Ii(W),Se);if(W.$$typeof===C)return Z(L,O,V,Xi(O,W),Se);Ji(O,W)}return null}function he(L,O,V,W){for(var Se=null,He=null,ge=O,ke=O=0,_e=null;ge!==null&&ke<V.length;ke++){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ve=Q(L,ge,V[ke],W);if(Ve===null){ge===null&&(ge=_e);break}e&&ge&&Ve.alternate===null&&t(L,ge),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve,ge=_e}if(ke===V.length)return a(L,ge),Oe&&Vn(L,ke),Se;if(ge===null){for(;ke<V.length;ke++)ge=ee(L,V[ke],W),ge!==null&&(O=u(ge,O,ke),He===null?Se=ge:He.sibling=ge,He=ge);return Oe&&Vn(L,ke),Se}for(ge=s(ge);ke<V.length;ke++)_e=Z(ge,L,ke,V[ke],W),_e!==null&&(e&&_e.alternate!==null&&ge.delete(_e.key===null?ke:_e.key),O=u(_e,O,ke),He===null?Se=_e:He.sibling=_e,He=_e);return e&&ge.forEach(function(Ta){return t(L,Ta)}),Oe&&Vn(L,ke),Se}function je(L,O,V,W){if(V==null)throw Error(o(151));for(var Se=null,He=null,ge=O,ke=O=0,_e=null,Ve=V.next();ge!==null&&!Ve.done;ke++,Ve=V.next()){ge.index>ke?(_e=ge,ge=null):_e=ge.sibling;var Ta=Q(L,ge,Ve.value,W);if(Ta===null){ge===null&&(ge=_e);break}e&&ge&&Ta.alternate===null&&t(L,ge),O=u(Ta,O,ke),He===null?Se=Ta:He.sibling=Ta,He=Ta,ge=_e}if(Ve.done)return a(L,ge),Oe&&Vn(L,ke),Se;if(ge===null){for(;!Ve.done;ke++,Ve=V.next())Ve=ee(L,Ve.value,W),Ve!==null&&(O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return Oe&&Vn(L,ke),Se}for(ge=s(ge);!Ve.done;ke++,Ve=V.next())Ve=Z(ge,L,ke,Ve.value,W),Ve!==null&&(e&&Ve.alternate!==null&&ge.delete(Ve.key===null?ke:Ve.key),O=u(Ve,O,ke),He===null?Se=Ve:He.sibling=Ve,He=Ve);return e&&ge.forEach(function(Zy){return t(L,Zy)}),Oe&&Vn(L,ke),Se}function Je(L,O,V,W){if(typeof V=="object"&&V!==null&&V.type===q&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case R:e:{for(var Se=V.key;O!==null;){if(O.key===Se){if(Se=V.type,Se===q){if(O.tag===7){a(L,O.sibling),W=c(O,V.props.children),W.return=L,L=W;break e}}else if(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===K&&Ka(Se)===O.type){a(L,O.sibling),W=c(O,V.props),Ms(W,V),W.return=L,L=W;break e}a(L,O);break}else t(L,O);O=O.sibling}V.type===q?(W=Ga(V.props.children,L.mode,W,V.key),W.return=L,L=W):(W=Gi(V.type,V.key,V.props,null,L.mode,W),Ms(W,V),W.return=L,L=W)}return v(L);case N:e:{for(Se=V.key;O!==null;){if(O.key===Se)if(O.tag===4&&O.stateNode.containerInfo===V.containerInfo&&O.stateNode.implementation===V.implementation){a(L,O.sibling),W=c(O,V.children||[]),W.return=L,L=W;break e}else{a(L,O);break}else t(L,O);O=O.sibling}W=tc(V,L.mode,W),W.return=L,L=W}return v(L);case K:return V=Ka(V),Je(L,O,V,W)}if(G(V))return he(L,O,V,W);if(te(V)){if(Se=te(V),typeof Se!="function")throw Error(o(150));return V=Se.call(V),je(L,O,V,W)}if(typeof V.then=="function")return Je(L,O,Ii(V),W);if(V.$$typeof===C)return Je(L,O,Xi(L,V),W);Ji(L,V)}return typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint"?(V=""+V,O!==null&&O.tag===6?(a(L,O.sibling),W=c(O,V),W.return=L,L=W):(a(L,O),W=ec(V,L.mode,W),W.return=L,L=W),v(L)):a(L,O)}return function(L,O,V,W){try{ks=0;var Se=Je(L,O,V,W);return Dl=null,Se}catch(ge){if(ge===Tl||ge===Ki)throw ge;var He=Xt(29,ge,null,L.mode);return He.lanes=W,He.return=L,He}finally{}}}var Ia=gm(!0),vm=gm(!1),pa=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function hc(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 xa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ga(e,t,a){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Ge&2)!==0){var c=s.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),s.pending=t,t=$i(e),tm(e,null,a),t}return Vi(e,s,t,a),$i(e)}function qs(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,a|=s,t.lanes=a,en(e,a)}}function pc(e,t){var a=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,a===s)){var c=null,u=null;if(a=a.firstBaseUpdate,a!==null){do{var v={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,a=a.next}while(a!==null);u===null?c=u=t:u=u.next=t}else c=u=t;a={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:s.shared,callbacks:s.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var xc=!1;function Rs(){if(xc){var e=Rl;if(e!==null)throw e}}function Ts(e,t,a,s){xc=!1;var c=e.updateQueue;pa=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,S=c.shared.pending;if(S!==null){c.shared.pending=null;var D=S,$=D.next;D.next=null,v===null?u=$:v.next=$,v=D;var I=e.alternate;I!==null&&(I=I.updateQueue,S=I.lastBaseUpdate,S!==v&&(S===null?I.firstBaseUpdate=$:S.next=$,I.lastBaseUpdate=D))}if(u!==null){var ee=c.baseState;v=0,I=$=D=null,S=u;do{var Q=S.lane&-536870913,Z=Q!==S.lane;if(Z?(De&Q)===Q:(s&Q)===Q){Q!==0&&Q===ql&&(xc=!0),I!==null&&(I=I.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var he=e,je=S;Q=t;var Je=a;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){ee=he.call(Je,ee,Q);break e}ee=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,Q=typeof he=="function"?he.call(Je,ee,Q):he,Q==null)break e;ee=b({},ee,Q);break e;case 2:pa=!0}}Q=S.callback,Q!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[Q]:Z.push(Q))}else Z={lane:Q,tag:S.tag,payload:S.payload,callback:S.callback,next:null},I===null?($=I=Z,D=ee):I=I.next=Z,v|=Q;if(S=S.next,S===null){if(S=c.shared.pending,S===null)break;Z=S,S=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);I===null&&(D=ee),c.baseState=D,c.firstBaseUpdate=$,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),Aa|=v,e.lanes=v,e.memoizedState=ee}}function ym(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function bm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)ym(a[e],t)}var _l=k(null),Pi=k(0);function Sm(e,t){e=Pn,P(Pi,e),P(_l,t),Pn=e|t.baseLanes}function gc(){P(Pi,Pn),P(_l,_l.current)}function vc(){Pn=Pi.current,H(_l),H(Pi)}var Qt=k(null),cn=null;function va(e){var t=e.alternate;P(ht,ht.current&1),P(Qt,e),cn===null&&(t===null||_l.current!==null||t.memoizedState!==null)&&(cn=e)}function yc(e){P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)}function Am(e){e.tag===22?(P(ht,ht.current),P(Qt,e),cn===null&&(cn=e)):ya()}function ya(){P(ht,ht.current),P(Qt,Qt.current)}function Kt(e){H(Qt),cn===e&&(cn=null),H(ht)}var ht=k(0);function Wi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||wu(a)||Cu(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Yn=0,Ee=null,Ze=null,vt=null,er=!1,Ol=!1,Ja=!1,tr=0,Ds=0,Bl=null,Uv=0;function ct(){throw Error(o(321))}function bc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Ft(e[a],t[a]))return!1;return!0}function Sc(e,t,a,s,c,u){return Yn=u,Ee=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?sh:Bc,Ja=!1,u=a(s,c),Ja=!1,Ol&&(u=Nm(t,a,s,c)),jm(e),u}function jm(e){T.H=Bs;var t=Ze!==null&&Ze.next!==null;if(Yn=0,vt=Ze=Ee=null,er=!1,Ds=0,Bl=null,t)throw Error(o(300));e===null||yt||(e=e.dependencies,e!==null&&Fi(e)&&(yt=!0))}function Nm(e,t,a,s){Ee=e;var c=0;do{if(Ol&&(Bl=null),Ds=0,Ol=!1,25<=c)throw Error(o(301));if(c+=1,vt=Ze=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}T.H=ih,u=t(a,s)}while(Ol);return u}function Hv(){var e=T.H,t=e.useState()[0];return t=typeof t.then=="function"?_s(t):t,e=e.useState()[0],(Ze!==null?Ze.memoizedState:null)!==e&&(Ee.flags|=1024),t}function Ac(){var e=tr!==0;return tr=0,e}function jc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Nc(e){if(er){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}er=!1}Yn=0,vt=Ze=Ee=null,Ol=!1,Ds=tr=0,Bl=null}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vt===null?Ee.memoizedState=vt=e:vt=vt.next=e,vt}function pt(){if(Ze===null){var e=Ee.alternate;e=e!==null?e.memoizedState:null}else e=Ze.next;var t=vt===null?Ee.memoizedState:vt.next;if(t!==null)vt=t,Ze=e;else{if(e===null)throw Ee.alternate===null?Error(o(467)):Error(o(310));Ze=e,e={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},vt===null?Ee.memoizedState=vt=e:vt=vt.next=e}return vt}function nr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function _s(e){var t=Ds;return Ds+=1,Bl===null&&(Bl=[]),e=hm(Bl,e,t),t=Ee,(vt===null?t.memoizedState:vt.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?sh:Bc),e}function ar(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return _s(e);if(e.$$typeof===C)return qt(e)}throw Error(o(438,String(e)))}function wc(e){var t=null,a=Ee.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var s=Ee.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}),a===null&&(a=nr(),Ee.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),s=0;s<e;s++)a[s]=z;return t.index++,a}function Fn(e,t){return typeof t=="function"?t(e):t}function lr(e){var t=pt();return Cc(t,Ze,e)}function Cc(e,t,a){var s=e.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=a;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,$=t,I=!1;do{var ee=$.lane&-536870913;if(ee!==$.lane?(De&ee)===ee:(Yn&ee)===ee){var Q=$.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),ee===ql&&(I=!0);else if((Yn&Q)===Q){$=$.next,Q===ql&&(I=!0);continue}else ee={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},D===null?(S=D=ee,v=u):D=D.next=ee,Ee.lanes|=Q,Aa|=Q;ee=$.action,Ja&&a(u,ee),u=$.hasEagerState?$.eagerState:a(u,ee)}else Q={lane:ee,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},D===null?(S=D=Q,v=u):D=D.next=Q,Ee.lanes|=ee,Aa|=ee;$=$.next}while($!==null&&$!==t);if(D===null?v=u:D.next=S,!Ft(u,e.memoizedState)&&(yt=!0,I&&(a=Rl,a!==null)))throw a;e.memoizedState=u,e.baseState=v,e.baseQueue=D,s.lastRenderedState=u}return c===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function Ec(e){var t=pt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var s=a.dispatch,c=a.pending,u=t.memoizedState;if(c!==null){a.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Ft(u,t.memoizedState)||(yt=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,s]}function wm(e,t,a){var s=Ee,c=pt(),u=Oe;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var v=!Ft((Ze||c).memoizedState,a);if(v&&(c.memoizedState=a,yt=!0),c=c.queue,qc(km.bind(null,s,c,e),[e]),c.getSnapshot!==t||v||vt!==null&&vt.memoizedState.tag&1){if(s.flags|=2048,Ll(9,{destroy:void 0},Em.bind(null,s,c,a,t),null),We===null)throw Error(o(349));u||(Yn&127)!==0||Cm(s,t,a)}return a}function Cm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ee.updateQueue,t===null?(t=nr(),Ee.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Em(e,t,a,s){t.value=a,t.getSnapshot=s,Mm(t)&&qm(e)}function km(e,t,a){return a(function(){Mm(t)&&qm(e)})}function Mm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Ft(e,a)}catch{return!0}}function qm(e){var t=$a(e,2);t!==null&&$t(t,e,2)}function kc(e){var t=Bt();if(typeof e=="function"){var a=e;if(e=a(),Ja){Yt(!0);try{a()}finally{Yt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:e},t}function Rm(e,t,a,s){return e.baseState=a,Cc(e,Ze,typeof s=="function"?s:Fn)}function Vv(e,t,a,s,c){if(rr(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)}};T.T!==null?a(!0):u.isTransition=!1,s(u),a=t.pending,a===null?(u.next=t.pending=u,Tm(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Tm(e,t){var a=t.action,s=t.payload,c=e.state;if(t.isTransition){var u=T.T,v={};T.T=v;try{var S=a(c,s),D=T.S;D!==null&&D(v,S),Dm(e,t,S)}catch($){Mc(e,t,$)}finally{u!==null&&v.types!==null&&(u.types=v.types),T.T=u}}else try{u=a(c,s),Dm(e,t,u)}catch($){Mc(e,t,$)}}function Dm(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(s){_m(e,t,s)},function(s){return Mc(e,t,s)}):_m(e,t,a)}function _m(e,t,a){t.status="fulfilled",t.value=a,Om(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Tm(e,a)))}function Mc(e,t,a){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=a,Om(t),t=t.next;while(t!==s)}e.action=null}function Om(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Bm(e,t){return t}function Lm(e,t){if(Oe){var a=We.formState;if(a!==null){e:{var s=Ee;if(Oe){if(nt){t:{for(var c=nt,u=on;c.nodeType!==8;){if(!u){c=null;break t}if(c=un(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){nt=un(c.nextSibling),s=c.data==="F!";break e}}ma(s)}s=!1}s&&(t=a[0])}}return a=Bt(),a.memoizedState=a.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bm,lastRenderedState:t},a.queue=s,a=nh.bind(null,Ee,s),s.dispatch=a,s=kc(!1),u=Oc.bind(null,Ee,!1,s.queue),s=Bt(),c={state:t,dispatch:null,action:e,pending:null},s.queue=c,a=Vv.bind(null,Ee,c,u,a),c.dispatch=a,s.memoizedState=e,[t,a,!1]}function zm(e){var t=pt();return Um(t,Ze,e)}function Um(e,t,a){if(t=Cc(e,t,Bm)[0],e=lr(Fn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=_s(t)}catch(v){throw v===Tl?Ki:v}else s=t;t=pt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(Ee.flags|=2048,Ll(9,{destroy:void 0},$v.bind(null,c,a),null)),[s,u,e]}function $v(e,t){e.action=t}function Hm(e){var t=pt(),a=Ze;if(a!==null)return Um(t,a,e);pt(),t=t.memoizedState,a=pt();var s=a.queue.dispatch;return a.memoizedState=e,[t,s,!1]}function Ll(e,t,a,s){return e={tag:e,create:a,deps:s,inst:t,next:null},t=Ee.updateQueue,t===null&&(t=nr(),Ee.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(s=a.next,a.next=e,e.next=s,t.lastEffect=e),e}function Vm(){return pt().memoizedState}function sr(e,t,a,s){var c=Bt();Ee.flags|=e,c.memoizedState=Ll(1|t,{destroy:void 0},a,s===void 0?null:s)}function ir(e,t,a,s){var c=pt();s=s===void 0?null:s;var u=c.memoizedState.inst;Ze!==null&&s!==null&&bc(s,Ze.memoizedState.deps)?c.memoizedState=Ll(t,u,a,s):(Ee.flags|=e,c.memoizedState=Ll(1|t,u,a,s))}function $m(e,t){sr(8390656,8,e,t)}function qc(e,t){ir(2048,8,e,t)}function Gv(e){Ee.flags|=4;var t=Ee.updateQueue;if(t===null)t=nr(),Ee.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Gm(e){var t=pt().memoizedState;return Gv({ref:t,nextImpl:e}),function(){if((Ge&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Ym(e,t){return ir(4,2,e,t)}function Fm(e,t){return ir(4,4,e,t)}function Xm(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Qm(e,t,a){a=a!=null?a.concat([e]):null,ir(4,4,Xm.bind(null,t,e),a)}function Rc(){}function Km(e,t){var a=pt();t=t===void 0?null:t;var s=a.memoizedState;return t!==null&&bc(t,s[1])?s[0]:(a.memoizedState=[e,t],e)}function Zm(e,t){var a=pt();t=t===void 0?null:t;var s=a.memoizedState;if(t!==null&&bc(t,s[1]))return s[0];if(s=e(),Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[s,t],s}function Tc(e,t,a){return a===void 0||(Yn&1073741824)!==0&&(De&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Ih(),Ee.lanes|=e,Aa|=e,a)}function Im(e,t,a,s){return Ft(a,t)?a:_l.current!==null?(e=Tc(e,a,s),Ft(e,t)||(yt=!0),e):(Yn&42)===0||(Yn&1073741824)!==0&&(De&261930)===0?(yt=!0,e.memoizedState=a):(e=Ih(),Ee.lanes|=e,Aa|=e,t)}function Jm(e,t,a,s,c){var u=F.p;F.p=u!==0&&8>u?u:8;var v=T.T,S={};T.T=S,Oc(e,!1,t,a);try{var D=c(),$=T.S;if($!==null&&$(S,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var I=zv(D,s);Os(e,t,I,Jt(e))}else Os(e,t,s,Jt(e))}catch(ee){Os(e,t,{then:function(){},status:"rejected",reason:ee},Jt())}finally{F.p=u,v!==null&&S.types!==null&&(v.types=S.types),T.T=v}}function Yv(){}function Dc(e,t,a,s){if(e.tag!==5)throw Error(o(476));var c=Pm(e).queue;Jm(e,c,t,J,a===null?Yv:function(){return Wm(e),a(s)})}function Pm(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Wm(e){var t=Pm(e);t.next===null&&(t=e.alternate.memoizedState),Os(e,t.next.queue,{},Jt())}function _c(){return qt(Ps)}function eh(){return pt().memoizedState}function th(){return pt().memoizedState}function Fv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Jt();e=xa(a);var s=ga(t,e,a);s!==null&&($t(s,t,a),qs(s,t,a)),t={cache:cc()},e.payload=t;return}t=t.return}}function Xv(e,t,a){var s=Jt();a={lane:s,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},rr(e)?ah(t,a):(a=Po(e,t,a,s),a!==null&&($t(a,e,s),lh(a,t,s)))}function nh(e,t,a){var s=Jt();Os(e,t,a,s)}function Os(e,t,a,s){var c={lane:s,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(rr(e))ah(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,a);if(c.hasEagerState=!0,c.eagerState=S,Ft(S,v))return Vi(e,t,c,0),We===null&&Hi(),!1}catch{}finally{}if(a=Po(e,t,c,s),a!==null)return $t(a,e,s),lh(a,t,s),!0}return!1}function Oc(e,t,a,s){if(s={lane:2,revertLane:mu(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},rr(e)){if(t)throw Error(o(479))}else t=Po(e,a,s,2),t!==null&&$t(t,e,2)}function rr(e){var t=e.alternate;return e===Ee||t!==null&&t===Ee}function ah(e,t){Ol=er=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function lh(e,t,a){if((a&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,a|=s,t.lanes=a,en(e,a)}}var Bs={readContext:qt,use:ar,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Bs.useEffectEvent=ct;var sh={readContext:qt,use:ar,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:qt,useEffect:$m,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,sr(4194308,4,Xm.bind(null,t,e),a)},useLayoutEffect:function(e,t){return sr(4194308,4,e,t)},useInsertionEffect:function(e,t){sr(4,2,e,t)},useMemo:function(e,t){var a=Bt();t=t===void 0?null:t;var s=e();if(Ja){Yt(!0);try{e()}finally{Yt(!1)}}return a.memoizedState=[s,t],s},useReducer:function(e,t,a){var s=Bt();if(a!==void 0){var c=a(t);if(Ja){Yt(!0);try{a(t)}finally{Yt(!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=Xv.bind(null,Ee,e),[s.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:function(e){e=kc(e);var t=e.queue,a=nh.bind(null,Ee,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Rc,useDeferredValue:function(e,t){var a=Bt();return Tc(a,e,t)},useTransition:function(){var e=kc(!1);return e=Jm.bind(null,Ee,e.queue,!0,!1),Bt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var s=Ee,c=Bt();if(Oe){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),We===null)throw Error(o(349));(De&127)!==0||Cm(s,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,$m(km.bind(null,s,u,e),[e]),s.flags|=2048,Ll(9,{destroy:void 0},Em.bind(null,s,u,a,t),null),a},useId:function(){var e=Bt(),t=We.identifierPrefix;if(Oe){var a=Nn,s=jn;a=(s&~(1<<32-kt(s)-1)).toString(32)+a,t="_"+t+"R_"+a,a=tr++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=Uv++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:_c,useFormState:Lm,useActionState:Lm,useOptimistic:function(e){var t=Bt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Oc.bind(null,Ee,!0,a),a.dispatch=t,[e,t]},useMemoCache:wc,useCacheRefresh:function(){return Bt().memoizedState=Fv.bind(null,Ee)},useEffectEvent:function(e){var t=Bt(),a={impl:e};return t.memoizedState=a,function(){if((Ge&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Bc={readContext:qt,use:ar,useCallback:Km,useContext:qt,useEffect:qc,useImperativeHandle:Qm,useInsertionEffect:Ym,useLayoutEffect:Fm,useMemo:Zm,useReducer:lr,useRef:Vm,useState:function(){return lr(Fn)},useDebugValue:Rc,useDeferredValue:function(e,t){var a=pt();return Im(a,Ze.memoizedState,e,t)},useTransition:function(){var e=lr(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_s(e),t]},useSyncExternalStore:wm,useId:eh,useHostTransitionStatus:_c,useFormState:zm,useActionState:zm,useOptimistic:function(e,t){var a=pt();return Rm(a,Ze,e,t)},useMemoCache:wc,useCacheRefresh:th};Bc.useEffectEvent=Gm;var ih={readContext:qt,use:ar,useCallback:Km,useContext:qt,useEffect:qc,useImperativeHandle:Qm,useInsertionEffect:Ym,useLayoutEffect:Fm,useMemo:Zm,useReducer:Ec,useRef:Vm,useState:function(){return Ec(Fn)},useDebugValue:Rc,useDeferredValue:function(e,t){var a=pt();return Ze===null?Tc(a,e,t):Im(a,Ze.memoizedState,e,t)},useTransition:function(){var e=Ec(Fn)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:_s(e),t]},useSyncExternalStore:wm,useId:eh,useHostTransitionStatus:_c,useFormState:Hm,useActionState:Hm,useOptimistic:function(e,t){var a=pt();return Ze!==null?Rm(a,Ze,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:wc,useCacheRefresh:th};ih.useEffectEvent=Gm;function Lc(e,t,a,s){t=e.memoizedState,a=a(s,t),a=a==null?t:b({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var zc={enqueueSetState:function(e,t,a){e=e._reactInternals;var s=Jt(),c=xa(s);c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,s),t!==null&&($t(t,e,s),qs(t,e,s))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var s=Jt(),c=xa(s);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=ga(e,c,s),t!==null&&($t(t,e,s),qs(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Jt(),s=xa(a);s.tag=2,t!=null&&(s.callback=t),t=ga(e,s,a),t!==null&&($t(t,e,a),qs(t,e,a))}};function rh(e,t,a,s,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,u,v):t.prototype&&t.prototype.isPureReactComponent?!As(a,s)||!As(c,u):!0}function oh(e,t,a,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,s),t.state!==e&&zc.enqueueReplaceState(t,t.state,null)}function Pa(e,t){var a=t;if("ref"in t){a={};for(var s in t)s!=="ref"&&(a[s]=t[s])}if(e=e.defaultProps){a===t&&(a=b({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function ch(e){Ui(e)}function uh(e){console.error(e)}function fh(e){Ui(e)}function or(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function dh(e,t,a){try{var s=e.onCaughtError;s(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Uc(e,t,a){return a=xa(a),a.tag=3,a.payload={element:null},a.callback=function(){or(e,t)},a}function mh(e){return e=xa(e),e.tag=3,e}function hh(e,t,a,s){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=s.value;e.payload=function(){return c(u)},e.callback=function(){dh(t,a,s)}}var v=a.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){dh(t,a,s),typeof c!="function"&&(ja===null?ja=new Set([this]):ja.add(this));var S=s.stack;this.componentDidCatch(s.value,{componentStack:S!==null?S:""})})}function Qv(e,t,a,s,c){if(a.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=a.alternate,t!==null&&Ml(t,a,c,!0),a=Qt.current,a!==null){switch(a.tag){case 31:case 13:return cn===null?br():a.alternate===null&&ut===0&&(ut=3),a.flags&=-257,a.flags|=65536,a.lanes=c,s===Zi?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([s]):t.add(s),uu(e,s,c)),!1;case 22:return a.flags|=65536,s===Zi?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([s]):a.add(s)),uu(e,s,c)),!1}throw Error(o(435,a.tag))}return uu(e,s,c),br(),!1}if(Oe)return t=Qt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,s!==lc&&(e=Error(o(422),{cause:s}),ws(ln(e,a)))):(s!==lc&&(t=Error(o(423),{cause:s}),ws(ln(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,s=ln(s,a),c=Uc(e.stateNode,s,c),pc(e,c),ut!==4&&(ut=2)),!1;var u=Error(o(520),{cause:s});if(u=ln(u,a),Ys===null?Ys=[u]:Ys.push(u),ut!==4&&(ut=2),t===null)return!0;s=ln(s,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Uc(a.stateNode,s,e),pc(a,e),!1;case 1:if(t=a.type,u=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(ja===null||!ja.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=mh(c),hh(c,e,a,s),pc(a,c),!1}a=a.return}while(a!==null);return!1}var Hc=Error(o(461)),yt=!1;function Rt(e,t,a,s){t.child=e===null?vm(t,null,a,s):Ia(t,e.child,a,s)}function ph(e,t,a,s,c){a=a.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 Xa(t),s=Sc(e,t,a,v,u,c),S=Ac(),e!==null&&!yt?(jc(e,t,c),Xn(e,t,c)):(Oe&&S&&nc(t),t.flags|=1,Rt(e,t,s,c),t.child)}function xh(e,t,a,s,c){if(e===null){var u=a.type;return typeof u=="function"&&!Wo(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,gh(e,t,u,s,c)):(e=Gi(a.type,null,s,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!Kc(e,c)){var v=u.memoizedProps;if(a=a.compare,a=a!==null?a:As,a(v,s)&&e.ref===t.ref)return Xn(e,t,c)}return t.flags|=1,e=Hn(u,s),e.ref=t.ref,e.return=t,t.child=e}function gh(e,t,a,s,c){if(e!==null){var u=e.memoizedProps;if(As(u,s)&&e.ref===t.ref)if(yt=!1,t.pendingProps=s=u,Kc(e,c))(e.flags&131072)!==0&&(yt=!0);else return t.lanes=e.lanes,Xn(e,t,c)}return Vc(e,t,a,s,c)}function vh(e,t,a,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|a:a,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 yh(e,t,u,a,s)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Qi(t,u!==null?u.cachePool:null),u!==null?Sm(t,u):gc(),Am(t);else return s=t.lanes=536870912,yh(e,t,u!==null?u.baseLanes|a:a,a,s)}else u!==null?(Qi(t,u.cachePool),Sm(t,u),ya(),t.memoizedState=null):(e!==null&&Qi(t,null),gc(),ya());return Rt(e,t,c,a),t.child}function Ls(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function yh(e,t,a,s,c){var u=fc();return u=u===null?null:{parent:gt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Qi(t,null),gc(),Am(t),e!==null&&Ml(e,t,s,!0),t.childLanes=c,null}function cr(e,t){return t=fr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function bh(e,t,a){return Ia(t,e.child,null,a),e=cr(t,t.pendingProps),e.flags|=2,Kt(t),t.memoizedState=null,e}function Kv(e,t,a){var s=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Oe){if(s.mode==="hidden")return e=cr(t,s),t.lanes=536870912,Ls(null,e);if(yc(t),(e=nt)?(e=Tp(e,on),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:jn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},a=am(e),a.return=t,t.child=a,Mt=t,nt=null)):e=null,e===null)throw ma(t);return t.lanes=536870912,null}return cr(t,s)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(yc(t),c)if(t.flags&256)t.flags&=-257,t=bh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(yt||Ml(e,t,a,!1),c=(a&e.childLanes)!==0,yt||c){if(s=We,s!==null&&(v=Ae(s,a),v!==0&&v!==u.retryLane))throw u.retryLane=v,$a(e,v),$t(s,e,v),Hc;br(),t=bh(e,t,a)}else e=u.treeContext,nt=un(v.nextSibling),Mt=t,Oe=!0,da=null,on=!1,e!==null&&im(t,e),t=cr(t,s),t.flags|=4096;return t}return e=Hn(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ur(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Vc(e,t,a,s,c){return Xa(t),a=Sc(e,t,a,s,void 0,c),s=Ac(),e!==null&&!yt?(jc(e,t,c),Xn(e,t,c)):(Oe&&s&&nc(t),t.flags|=1,Rt(e,t,a,c),t.child)}function Sh(e,t,a,s,c,u){return Xa(t),t.updateQueue=null,a=Nm(t,s,a,c),jm(e),s=Ac(),e!==null&&!yt?(jc(e,t,u),Xn(e,t,u)):(Oe&&s&&nc(t),t.flags|=1,Rt(e,t,a,u),t.child)}function Ah(e,t,a,s,c){if(Xa(t),t.stateNode===null){var u=wl,v=a.contextType;typeof v=="object"&&v!==null&&(u=qt(v)),u=new a(s,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=zc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=s,u.state=t.memoizedState,u.refs={},mc(t),v=a.contextType,u.context=typeof v=="object"&&v!==null?qt(v):wl,u.state=t.memoizedState,v=a.getDerivedStateFromProps,typeof v=="function"&&(Lc(t,a,v,s),u.state=t.memoizedState),typeof a.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&&zc.enqueueReplaceState(u,u.state,null),Ts(t,s,u,c),Rs(),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=Pa(a,S);u.props=D;var $=u.context,I=a.contextType;v=wl,typeof I=="object"&&I!==null&&(v=qt(I));var ee=a.getDerivedStateFromProps;I=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",S=t.pendingProps!==S,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(S||$!==v)&&oh(t,u,s,v),pa=!1;var Q=t.memoizedState;u.state=Q,Ts(t,s,u,c),Rs(),$=t.memoizedState,S||Q!==$||pa?(typeof ee=="function"&&(Lc(t,a,ee,s),$=t.memoizedState),(D=pa||rh(t,a,D,s,Q,$,v))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=$),u.props=s,u.state=$,u.context=v,s=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{u=t.stateNode,hc(e,t),v=t.memoizedProps,I=Pa(a,v),u.props=I,ee=t.pendingProps,Q=u.context,$=a.contextType,D=wl,typeof $=="object"&&$!==null&&(D=qt($)),S=a.getDerivedStateFromProps,($=typeof S=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||Q!==D)&&oh(t,u,s,D),pa=!1,Q=t.memoizedState,u.state=Q,Ts(t,s,u,c),Rs();var Z=t.memoizedState;v!==ee||Q!==Z||pa||e!==null&&e.dependencies!==null&&Fi(e.dependencies)?(typeof S=="function"&&(Lc(t,a,S,s),Z=t.memoizedState),(I=pa||rh(t,a,I,s,Q,Z,D)||e!==null&&e.dependencies!==null&&Fi(e.dependencies))?($||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(s,Z,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(s,Z,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=Z),u.props=s,u.state=Z,u.context=D,s=I):(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,ur(e,t),s=(t.flags&128)!==0,u||s?(u=t.stateNode,a=s&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&s?(t.child=Ia(t,e.child,null,c),t.child=Ia(t,null,a,c)):Rt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Xn(e,t,c),e}function jh(e,t,a,s){return Ya(),t.flags|=256,Rt(e,t,a,s),t.child}var $c={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gc(e){return{baseLanes:e,cachePool:dm()}}function Yc(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=It),e}function Nh(e,t,a){var s=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(ht.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Oe){if(c?va(t):ya(),(e=nt)?(e=Tp(e,on),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:fa!==null?{id:jn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},a=am(e),a.return=t,t.child=a,Mt=t,nt=null)):e=null,e===null)throw ma(t);return Cu(e)?t.lanes=32:t.lanes=536870912,null}var S=s.children;return s=s.fallback,c?(ya(),c=t.mode,S=fr({mode:"hidden",children:S},c),s=Ga(s,c,a,null),S.return=t,s.return=t,S.sibling=s,t.child=S,s=t.child,s.memoizedState=Gc(a),s.childLanes=Yc(e,v,a),t.memoizedState=$c,Ls(null,s)):(va(t),Fc(t,S))}var D=e.memoizedState;if(D!==null&&(S=D.dehydrated,S!==null)){if(u)t.flags&256?(va(t),t.flags&=-257,t=Xc(e,t,a)):t.memoizedState!==null?(ya(),t.child=e.child,t.flags|=128,t=null):(ya(),S=s.fallback,c=t.mode,s=fr({mode:"visible",children:s.children},c),S=Ga(S,c,a,null),S.flags|=2,s.return=t,S.return=t,s.sibling=S,t.child=s,Ia(t,e.child,null,a),s=t.child,s.memoizedState=Gc(a),s.childLanes=Yc(e,v,a),t.memoizedState=$c,t=Ls(null,s));else if(va(t),Cu(S)){if(v=S.nextSibling&&S.nextSibling.dataset,v)var $=v.dgst;v=$,s=Error(o(419)),s.stack="",s.digest=v,ws({value:s,source:null,stack:null}),t=Xc(e,t,a)}else if(yt||Ml(e,t,a,!1),v=(a&e.childLanes)!==0,yt||v){if(v=We,v!==null&&(s=Ae(v,a),s!==0&&s!==D.retryLane))throw D.retryLane=s,$a(e,s),$t(v,e,s),Hc;wu(S)||br(),t=Xc(e,t,a)}else wu(S)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,nt=un(S.nextSibling),Mt=t,Oe=!0,da=null,on=!1,e!==null&&im(t,e),t=Fc(t,s.children),t.flags|=4096);return t}return c?(ya(),S=s.fallback,c=t.mode,D=e.child,$=D.sibling,s=Hn(D,{mode:"hidden",children:s.children}),s.subtreeFlags=D.subtreeFlags&65011712,$!==null?S=Hn($,S):(S=Ga(S,c,a,null),S.flags|=2),S.return=t,s.return=t,s.sibling=S,t.child=s,Ls(null,s),s=t.child,S=e.child.memoizedState,S===null?S=Gc(a):(c=S.cachePool,c!==null?(D=gt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=dm(),S={baseLanes:S.baseLanes|a,cachePool:c}),s.memoizedState=S,s.childLanes=Yc(e,v,a),t.memoizedState=$c,Ls(e.child,s)):(va(t),a=e.child,e=a.sibling,a=Hn(a,{mode:"visible",children:s.children}),a.return=t,a.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=a,t.memoizedState=null,a)}function Fc(e,t){return t=fr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function fr(e,t){return e=Xt(22,e,null,t),e.lanes=0,e}function Xc(e,t,a){return Ia(t,e.child,null,a),e=Fc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wh(e,t,a){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),rc(e.return,t,a)}function Qc(e,t,a,s,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:a,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=s,v.tail=a,v.tailMode=c,v.treeForkCount=u)}function Ch(e,t,a){var s=t.pendingProps,c=s.revealOrder,u=s.tail;s=s.children;var v=ht.current,S=(v&2)!==0;if(S?(v=v&1|2,t.flags|=128):v&=1,P(ht,v),Rt(e,t,s,a),s=Oe?Ns:0,!S&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wh(e,a,t);else if(e.tag===19)wh(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(a=t.child,c=null;a!==null;)e=a.alternate,e!==null&&Wi(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),Qc(t,!1,c,a,u,s);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Wi(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}Qc(t,!0,a,null,u,s);break;case"together":Qc(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function Xn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Aa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ml(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,a=Hn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Hn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function Kc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Fi(e)))}function Zv(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),ha(t,gt,e.memoizedState.cache),Ya();break;case 27:case 5:xe(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:ha(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,yc(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(va(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Nh(e,t,a):(va(t),e=Xn(e,t,a),e!==null?e.sibling:null);va(t);break;case 19:var c=(e.flags&128)!==0;if(s=(a&t.childLanes)!==0,s||(Ml(e,t,a,!1),s=(a&t.childLanes)!==0),c){if(s)return Ch(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),P(ht,ht.current),s)break;return null;case 22:return t.lanes=0,vh(e,t,a,t.pendingProps);case 24:ha(t,gt,e.memoizedState.cache)}return Xn(e,t,a)}function Eh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)yt=!0;else{if(!Kc(e,a)&&(t.flags&128)===0)return yt=!1,Zv(e,t,a);yt=(e.flags&131072)!==0}else yt=!1,Oe&&(t.flags&1048576)!==0&&sm(t,Ns,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=Ka(t.elementType),t.type=e,typeof e=="function")Wo(e)?(s=Pa(e,s),t.tag=1,t=Ah(null,t,e,s,a)):(t.tag=0,t=Vc(null,t,e,s,a));else{if(e!=null){var c=e.$$typeof;if(c===M){t.tag=11,t=ph(null,t,e,s,a);break e}else if(c===_){t.tag=14,t=xh(null,t,e,s,a);break e}}throw t=ce(e)||e,Error(o(306,t,""))}}return t;case 0:return Vc(e,t,t.type,t.pendingProps,a);case 1:return s=t.type,c=Pa(s,t.pendingProps),Ah(e,t,s,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));s=t.pendingProps;var u=t.memoizedState;c=u.element,hc(e,t),Ts(t,s,null,a);var v=t.memoizedState;if(s=v.cache,ha(t,gt,s),s!==u.cache&&oc(t,[gt],a,!0),Rs(),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=jh(e,t,s,a);break e}else if(s!==c){c=ln(Error(o(424)),t),ws(c),t=jh(e,t,s,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(nt=un(e.firstChild),Mt=t,Oe=!0,da=null,on=!0,a=vm(t,null,s,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Ya(),s===c){t=Xn(e,t,a);break e}Rt(e,t,s,a)}t=t.child}return t;case 26:return ur(e,t),e===null?(a=zp(t.type,null,t.pendingProps,null))?t.memoizedState=a:Oe||(a=t.type,e=t.pendingProps,s=Er(ie.current).createElement(a),s[rt]=t,s[jt]=e,Tt(s,a,e),wt(s),t.stateNode=s):t.memoizedState=zp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Oe&&(s=t.stateNode=Op(t.type,t.pendingProps,ie.current),Mt=t,on=!0,c=nt,Ea(t.type)?(Eu=c,nt=un(s.firstChild)):nt=c),Rt(e,t,t.pendingProps.children,a),ur(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Oe&&((c=s=nt)&&(s=wy(s,t.type,t.pendingProps,on),s!==null?(t.stateNode=s,Mt=t,nt=un(s.firstChild),on=!1,c=!0):c=!1),c||ma(t)),xe(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,s=u.children,Au(c,u)?s=null:v!==null&&Au(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=Sc(e,t,Hv,null,null,a),Ps._currentValue=c),ur(e,t),Rt(e,t,s,a),t.child;case 6:return e===null&&Oe&&((e=a=nt)&&(a=Cy(a,t.pendingProps,on),a!==null?(t.stateNode=a,Mt=t,nt=null,e=!0):e=!1),e||ma(t)),null;case 13:return Nh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Ia(t,null,s,a):Rt(e,t,s,a),t.child;case 11:return ph(e,t,t.type,t.pendingProps,a);case 7:return Rt(e,t,t.pendingProps,a),t.child;case 8:return Rt(e,t,t.pendingProps.children,a),t.child;case 12:return Rt(e,t,t.pendingProps.children,a),t.child;case 10:return s=t.pendingProps,ha(t,t.type,s.value),Rt(e,t,s.children,a),t.child;case 9:return c=t.type._context,s=t.pendingProps.children,Xa(t),c=qt(c),s=s(c),t.flags|=1,Rt(e,t,s,a),t.child;case 14:return xh(e,t,t.type,t.pendingProps,a);case 15:return gh(e,t,t.type,t.pendingProps,a);case 19:return Ch(e,t,a);case 31:return Kv(e,t,a);case 22:return vh(e,t,a,t.pendingProps);case 24:return Xa(t),s=qt(gt),e===null?(c=fc(),c===null&&(c=We,u=cc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:s,cache:c},mc(t),ha(t,gt,c)):((e.lanes&a)!==0&&(hc(e,t),Ts(t,null,null,a),Rs()),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),ha(t,gt,s)):(s=u.cache,ha(t,gt,s),s!==c.cache&&oc(t,[gt],a,!0))),Rt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Qn(e){e.flags|=4}function Zc(e,t,a,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(ep())e.flags|=8192;else throw Za=Zi,dc}else e.flags&=-16777217}function kh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Gp(t))if(ep())e.flags|=8192;else throw Za=Zi,dc}function dr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?us():536870912,e.lanes|=t,Vl|=t)}function zs(e,t){if(!Oe)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var s=null;a!==null;)a.alternate!==null&&(s=a),a=a.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function at(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,s=0;if(t)for(var c=e.child;c!==null;)a|=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;)a|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=a,t}function Iv(e,t,a){var s=t.pendingProps;switch(ac(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return at(t),null;case 1:return at(t),null;case 3:return a=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Gn(gt),ye(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(kl(t)?Qn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,sc())),at(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Qn(t),u!==null?(at(t),kh(t,u)):(at(t),Zc(t,c,null,s,a))):u?u!==e.memoizedState?(Qn(t),at(t),kh(t,u)):(at(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&Qn(t),at(t),Zc(t,c,e,s,a)),null;case 27:if(Ue(t),a=ie.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Qn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return at(t),null}e=ne.current,kl(t)?rm(t):(e=Op(c,s,a),t.stateNode=e,Qn(t))}return at(t),null;case 5:if(Ue(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Qn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return at(t),null}if(u=ne.current,kl(t))rm(t);else{var v=Er(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[rt]=t,u[jt]=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(Tt(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&&Qn(t)}}return at(t),Zc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&Qn(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(o(166));if(e=ie.current,kl(t)){if(e=t.stateNode,a=t.memoizedProps,s=null,c=Mt,c!==null)switch(c.tag){case 27:case 5:s=c.memoizedProps}e[rt]=t,e=!!(e.nodeValue===a||s!==null&&s.suppressHydrationWarning===!0||Np(e.nodeValue,a)),e||ma(t,!0)}else e=Er(e).createTextNode(s),e[rt]=t,t.stateNode=e}return at(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(s=kl(t),a!==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[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),e=!1}else a=sc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Kt(t),t):(Kt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return at(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=kl(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[rt]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;at(t),c=!1}else c=sc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Kt(t),t):(Kt(t),null)}return Kt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=s!==null,e=e!==null&&e.memoizedState!==null,a&&(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)),a!==e&&a&&(t.child.flags|=8192),dr(t,t.updateQueue),at(t),null);case 4:return ye(),e===null&&gu(t.stateNode.containerInfo),at(t),null;case 10:return Gn(t.type),at(t),null;case 19:if(H(ht),s=t.memoizedState,s===null)return at(t),null;if(c=(t.flags&128)!==0,u=s.rendering,u===null)if(c)zs(s,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Wi(e),u!==null){for(t.flags|=128,zs(s,!1),e=u.updateQueue,t.updateQueue=e,dr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)nm(a,e),a=a.sibling;return P(ht,ht.current&1|2),Oe&&Vn(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&Le()>gr&&(t.flags|=128,c=!0,zs(s,!1),t.lanes=4194304)}else{if(!c)if(e=Wi(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,dr(t,e),zs(s,!0),s.tail===null&&s.tailMode==="hidden"&&!u.alternate&&!Oe)return at(t),null}else 2*Le()-s.renderingStartTime>gr&&a!==536870912&&(t.flags|=128,c=!0,zs(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=Le(),e.sibling=null,a=ht.current,P(ht,c?a&1|2:a&1),Oe&&Vn(t,s.treeForkCount),e):(at(t),null);case 22:case 23:return Kt(t),vc(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(a&536870912)!==0&&(t.flags&128)===0&&(at(t),t.subtreeFlags&6&&(t.flags|=8192)):at(t),a=t.updateQueue,a!==null&&dr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==a&&(t.flags|=2048),e!==null&&H(Qa),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Gn(gt),at(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Jv(e,t){switch(ac(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gn(gt),ye(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ue(t),null;case 31:if(t.memoizedState!==null){if(Kt(t),t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Kt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ya()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(ht),null;case 4:return ye(),null;case 10:return Gn(t.type),null;case 22:case 23:return Kt(t),vc(),e!==null&&H(Qa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gn(gt),null;case 25:return null;default:return null}}function Mh(e,t){switch(ac(t),t.tag){case 3:Gn(gt),ye();break;case 26:case 27:case 5:Ue(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&Kt(t);break;case 13:Kt(t);break;case 19:H(ht);break;case 10:Gn(t.type);break;case 22:case 23:Kt(t),vc(),e!==null&&H(Qa);break;case 24:Gn(gt)}}function Us(e,t){try{var a=t.updateQueue,s=a!==null?a.lastEffect:null;if(s!==null){var c=s.next;a=c;do{if((a.tag&e)===e){s=void 0;var u=a.create,v=a.inst;s=u(),v.destroy=s}a=a.next}while(a!==c)}}catch(S){Xe(t,t.return,S)}}function ba(e,t,a){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=a,$=S;try{$()}catch(I){Xe(c,D,I)}}}s=s.next}while(s!==u)}}catch(I){Xe(t,t.return,I)}}function qh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{bm(t,a)}catch(s){Xe(e,e.return,s)}}}function Rh(e,t,a){a.props=Pa(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(s){Xe(e,t,s)}}function Hs(e,t){try{var a=e.ref;if(a!==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 a=="function"?e.refCleanup=a(s):a.current=s}}catch(c){Xe(e,t,c)}}function wn(e,t){var a=e.ref,s=e.refCleanup;if(a!==null)if(typeof s=="function")try{s()}catch(c){Xe(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(c){Xe(e,t,c)}else a.current=null}function Th(e){var t=e.type,a=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&s.focus();break e;case"img":a.src?s.src=a.src:a.srcSet&&(s.srcset=a.srcSet)}}catch(c){Xe(e,e.return,c)}}function Ic(e,t,a){try{var s=e.stateNode;yy(s,e.type,a,t),s[jt]=t}catch(c){Xe(e,e.return,c)}}function Dh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ea(e.type)||e.tag===4}function Jc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Dh(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&&Ea(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 Pc(e,t,a){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=zn));else if(s!==4&&(s===27&&Ea(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(Pc(e,t,a),e=e.sibling;e!==null;)Pc(e,t,a),e=e.sibling}function mr(e,t,a){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(s!==4&&(s===27&&Ea(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(mr(e,t,a),e=e.sibling;e!==null;)mr(e,t,a),e=e.sibling}function _h(e){var t=e.stateNode,a=e.memoizedProps;try{for(var s=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Tt(t,s,a),t[rt]=e,t[jt]=a}catch(u){Xe(e,e.return,u)}}var Kn=!1,bt=!1,Wc=!1,Oh=typeof WeakSet=="function"?WeakSet:Set,Ct=null;function Pv(e,t){if(e=e.containerInfo,bu=_r,e=Qd(e),Xo(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var s=a.getSelection&&a.getSelection();if(s&&s.rangeCount!==0){a=s.anchorNode;var c=s.anchorOffset,u=s.focusNode;s=s.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var v=0,S=-1,D=-1,$=0,I=0,ee=e,Q=null;t:for(;;){for(var Z;ee!==a||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),(Z=ee.firstChild)!==null;)Q=ee,ee=Z;for(;;){if(ee===e)break t;if(Q===a&&++$===c&&(S=v),Q===u&&++I===s&&(D=v),(Z=ee.nextSibling)!==null)break;ee=Q,Q=ee.parentNode}ee=Z}a=S===-1||D===-1?null:{start:S,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Su={focusedElem:e,selectionRange:a},_r=!1,Ct=t;Ct!==null;)if(t=Ct,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ct=e;else for(;Ct!==null;){switch(t=Ct,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(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,a=t,c=u.memoizedProps,u=u.memoizedState,s=a.stateNode;try{var he=Pa(a.type,c);e=s.getSnapshotBeforeUpdate(he,u),s.__reactInternalSnapshotBeforeUpdate=e}catch(je){Xe(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Nu(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Nu(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,Ct=e;break}Ct=t.return}}function Bh(e,t,a){var s=a.flags;switch(a.tag){case 0:case 11:case 15:In(e,a),s&4&&Us(5,a);break;case 1:if(In(e,a),s&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(v){Xe(a,a.return,v)}else{var c=Pa(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){Xe(a,a.return,v)}}s&64&&qh(a),s&512&&Hs(a,a.return);break;case 3:if(In(e,a),s&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{bm(e,t)}catch(v){Xe(a,a.return,v)}}break;case 27:t===null&&s&4&&_h(a);case 26:case 5:In(e,a),t===null&&s&4&&Th(a),s&512&&Hs(a,a.return);break;case 12:In(e,a);break;case 31:In(e,a),s&4&&Uh(e,a);break;case 13:In(e,a),s&4&&Hh(e,a),s&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=ry.bind(null,a),Ey(e,a))));break;case 22:if(s=a.memoizedState!==null||Kn,!s){t=t!==null&&t.memoizedState!==null||bt,c=Kn;var u=bt;Kn=s,(bt=t)&&!u?Jn(e,a,(a.subtreeFlags&8772)!==0):In(e,a),Kn=c,bt=u}break;case 30:break;default:In(e,a)}}function Lh(e){var t=e.alternate;t!==null&&(e.alternate=null,Lh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Mo(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 st=null,zt=!1;function Zn(e,t,a){for(a=a.child;a!==null;)zh(e,t,a),a=a.sibling}function zh(e,t,a){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Dn,a)}catch{}switch(a.tag){case 26:bt||wn(a,t),Zn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:bt||wn(a,t);var s=st,c=zt;Ea(a.type)&&(st=a.stateNode,zt=!1),Zn(e,t,a),Zs(a.stateNode),st=s,zt=c;break;case 5:bt||wn(a,t);case 6:if(s=st,c=zt,st=null,Zn(e,t,a),st=s,zt=c,st!==null)if(zt)try{(st.nodeType===9?st.body:st.nodeName==="HTML"?st.ownerDocument.body:st).removeChild(a.stateNode)}catch(u){Xe(a,t,u)}else try{st.removeChild(a.stateNode)}catch(u){Xe(a,t,u)}break;case 18:st!==null&&(zt?(e=st,qp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Zl(e)):qp(st,a.stateNode));break;case 4:s=st,c=zt,st=a.stateNode.containerInfo,zt=!0,Zn(e,t,a),st=s,zt=c;break;case 0:case 11:case 14:case 15:ba(2,a,t),bt||ba(4,a,t),Zn(e,t,a);break;case 1:bt||(wn(a,t),s=a.stateNode,typeof s.componentWillUnmount=="function"&&Rh(a,t,s)),Zn(e,t,a);break;case 21:Zn(e,t,a);break;case 22:bt=(s=bt)||a.memoizedState!==null,Zn(e,t,a),bt=s;break;default:Zn(e,t,a)}}function Uh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zl(e)}catch(a){Xe(t,t.return,a)}}}function Hh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zl(e)}catch(a){Xe(t,t.return,a)}}function Wv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Oh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Oh),t;default:throw Error(o(435,e.tag))}}function hr(e,t){var a=Wv(e);t.forEach(function(s){if(!a.has(s)){a.add(s);var c=oy.bind(null,e,s);s.then(c,c)}})}function Ut(e,t){var a=t.deletions;if(a!==null)for(var s=0;s<a.length;s++){var c=a[s],u=e,v=t,S=v;e:for(;S!==null;){switch(S.tag){case 27:if(Ea(S.type)){st=S.stateNode,zt=!1;break e}break;case 5:st=S.stateNode,zt=!1;break e;case 3:case 4:st=S.stateNode.containerInfo,zt=!0;break e}S=S.return}if(st===null)throw Error(o(160));zh(u,v,c),st=null,zt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Vh(t,e),t=t.sibling}var xn=null;function Vh(e,t){var a=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),s&4&&(ba(3,e,e.return),Us(3,e),ba(5,e,e.return));break;case 1:Ut(t,e),Ht(e),s&512&&(bt||a===null||wn(a,a.return)),s&64&&Kn&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?s:a.concat(s))));break;case 26:var c=xn;if(Ut(t,e),Ht(e),s&512&&(bt||a===null||wn(a,a.return)),s&4){var u=a!==null?a.memoizedState:null;if(s=e.memoizedState,a===null)if(s===null)if(e.stateNode===null){e:{s=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(s){case"title":u=c.getElementsByTagName("title")[0],(!u||u[ms]||u[rt]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(s),c.head.insertBefore(u,c.querySelector("head > title"))),Tt(u,s,a),u[rt]=e,wt(u),s=u;break e;case"link":var v=Vp("link","href",c).get(s+(a.href||""));if(v){for(var S=0;S<v.length;S++)if(u=v[S],u.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&u.getAttribute("rel")===(a.rel==null?null:a.rel)&&u.getAttribute("title")===(a.title==null?null:a.title)&&u.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){v.splice(S,1);break t}}u=c.createElement(s),Tt(u,s,a),c.head.appendChild(u);break;case"meta":if(v=Vp("meta","content",c).get(s+(a.content||""))){for(S=0;S<v.length;S++)if(u=v[S],u.getAttribute("content")===(a.content==null?null:""+a.content)&&u.getAttribute("name")===(a.name==null?null:a.name)&&u.getAttribute("property")===(a.property==null?null:a.property)&&u.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&u.getAttribute("charset")===(a.charSet==null?null:a.charSet)){v.splice(S,1);break t}}u=c.createElement(s),Tt(u,s,a),c.head.appendChild(u);break;default:throw Error(o(468,s))}u[rt]=e,wt(u),s=u}e.stateNode=s}else $p(c,e.type,e.stateNode);else e.stateNode=Hp(c,s,e.memoizedProps);else u!==s?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,s===null?$p(c,e.type,e.stateNode):Hp(c,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Ic(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ut(t,e),Ht(e),s&512&&(bt||a===null||wn(a,a.return)),a!==null&&s&4&&Ic(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),s&512&&(bt||a===null||wn(a,a.return)),e.flags&32){c=e.stateNode;try{vl(c,"")}catch(he){Xe(e,e.return,he)}}s&4&&e.stateNode!=null&&(c=e.memoizedProps,Ic(e,c,a!==null?a.memoizedProps:c)),s&1024&&(Wc=!0);break;case 6:if(Ut(t,e),Ht(e),s&4){if(e.stateNode===null)throw Error(o(162));s=e.memoizedProps,a=e.stateNode;try{a.nodeValue=s}catch(he){Xe(e,e.return,he)}}break;case 3:if(qr=null,c=xn,xn=kr(t.containerInfo),Ut(t,e),xn=c,Ht(e),s&4&&a!==null&&a.memoizedState.isDehydrated)try{Zl(t.containerInfo)}catch(he){Xe(e,e.return,he)}Wc&&(Wc=!1,$h(e));break;case 4:s=xn,xn=kr(e.stateNode.containerInfo),Ut(t,e),Ht(e),xn=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,hr(e,s)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(xr=Le()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,hr(e,s)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,$=Kn,I=bt;if(Kn=$||c,bt=I||D,Ut(t,e),bt=I,Kn=$,Ht(e),s&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||Kn||bt||Wa(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=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(he){Xe(D,D.return,he)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(he){Xe(D,D.return,he)}}}else if(t.tag===18){if(a===null){D=t;try{var Z=D.stateNode;c?Rp(Z,!0):Rp(D.stateNode,!1)}catch(he){Xe(D,D.return,he)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}s&4&&(s=e.updateQueue,s!==null&&(a=s.retryQueue,a!==null&&(s.retryQueue=null,hr(e,a))));break;case 19:Ut(t,e),Ht(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,hr(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 a,s=e.return;s!==null;){if(Dh(s)){a=s;break}s=s.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=Jc(e);mr(e,u,c);break;case 5:var v=a.stateNode;a.flags&32&&(vl(v,""),a.flags&=-33);var S=Jc(e);mr(e,S,v);break;case 3:case 4:var D=a.stateNode.containerInfo,$=Jc(e);Pc(e,$,D);break;default:throw Error(o(161))}}catch(I){Xe(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function $h(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;$h(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function In(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Bh(e,t.alternate,t),t=t.sibling}function Wa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ba(4,t,t.return),Wa(t);break;case 1:wn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Rh(t,t.return,a),Wa(t);break;case 27:Zs(t.stateNode);case 26:case 5:wn(t,t.return),Wa(t);break;case 22:t.memoizedState===null&&Wa(t);break;case 30:Wa(t);break;default:Wa(t)}e=e.sibling}}function Jn(e,t,a){for(a=a&&(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:Jn(c,u,a),Us(4,u);break;case 1:if(Jn(c,u,a),s=u,c=s.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch($){Xe(s,s.return,$)}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++)ym(D[c],S)}catch($){Xe(s,s.return,$)}}a&&v&64&&qh(u),Hs(u,u.return);break;case 27:_h(u);case 26:case 5:Jn(c,u,a),a&&s===null&&v&4&&Th(u),Hs(u,u.return);break;case 12:Jn(c,u,a);break;case 31:Jn(c,u,a),a&&v&4&&Uh(c,u);break;case 13:Jn(c,u,a),a&&v&4&&Hh(c,u);break;case 22:u.memoizedState===null&&Jn(c,u,a),Hs(u,u.return);break;case 30:break;default:Jn(c,u,a)}t=t.sibling}}function eu(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cs(a))}function tu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cs(e))}function gn(e,t,a,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Gh(e,t,a,s),t=t.sibling}function Gh(e,t,a,s){var c=t.flags;switch(t.tag){case 0:case 11:case 15:gn(e,t,a,s),c&2048&&Us(9,t);break;case 1:gn(e,t,a,s);break;case 3:gn(e,t,a,s),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cs(e)));break;case 12:if(c&2048){gn(e,t,a,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){Xe(t,t.return,D)}}else gn(e,t,a,s);break;case 31:gn(e,t,a,s);break;case 13:gn(e,t,a,s);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?gn(e,t,a,s):Vs(e,t):u._visibility&2?gn(e,t,a,s):(u._visibility|=2,zl(e,t,a,s,(t.subtreeFlags&10256)!==0||!1)),c&2048&&eu(v,t);break;case 24:gn(e,t,a,s),c&2048&&tu(t.alternate,t);break;default:gn(e,t,a,s)}}function zl(e,t,a,s,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,S=a,D=s,$=v.flags;switch(v.tag){case 0:case 11:case 15:zl(u,v,S,D,c),Us(8,v);break;case 23:break;case 22:var I=v.stateNode;v.memoizedState!==null?I._visibility&2?zl(u,v,S,D,c):Vs(u,v):(I._visibility|=2,zl(u,v,S,D,c)),c&&$&2048&&eu(v.alternate,v);break;case 24:zl(u,v,S,D,c),c&&$&2048&&tu(v.alternate,v);break;default:zl(u,v,S,D,c)}t=t.sibling}}function Vs(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,s=t,c=s.flags;switch(s.tag){case 22:Vs(a,s),c&2048&&eu(s.alternate,s);break;case 24:Vs(a,s),c&2048&&tu(s.alternate,s);break;default:Vs(a,s)}t=t.sibling}}var $s=8192;function Ul(e,t,a){if(e.subtreeFlags&$s)for(e=e.child;e!==null;)Yh(e,t,a),e=e.sibling}function Yh(e,t,a){switch(e.tag){case 26:Ul(e,t,a),e.flags&$s&&e.memoizedState!==null&&Uy(a,xn,e.memoizedState,e.memoizedProps);break;case 5:Ul(e,t,a);break;case 3:case 4:var s=xn;xn=kr(e.stateNode.containerInfo),Ul(e,t,a),xn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=$s,$s=16777216,Ul(e,t,a),$s=s):Ul(e,t,a));break;default:Ul(e,t,a)}}function Fh(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 Gs(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var s=t[a];Ct=s,Qh(s,e)}Fh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Xh(e),e=e.sibling}function Xh(e){switch(e.tag){case 0:case 11:case 15:Gs(e),e.flags&2048&&ba(9,e,e.return);break;case 3:Gs(e);break;case 12:Gs(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,pr(e)):Gs(e);break;default:Gs(e)}}function pr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var s=t[a];Ct=s,Qh(s,e)}Fh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ba(8,t,t.return),pr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,pr(t));break;default:pr(t)}e=e.sibling}}function Qh(e,t){for(;Ct!==null;){var a=Ct;switch(a.tag){case 0:case 11:case 15:ba(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var s=a.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:Cs(a.memoizedState.cache)}if(s=a.child,s!==null)s.return=a,Ct=s;else e:for(a=e;Ct!==null;){s=Ct;var c=s.sibling,u=s.return;if(Lh(s),s===a){Ct=null;break e}if(c!==null){c.return=u,Ct=c;break e}Ct=u}}}var ey={getCacheForType:function(e){var t=qt(gt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return qt(gt).controller.signal}},ty=typeof WeakMap=="function"?WeakMap:Map,Ge=0,We=null,Re=null,De=0,Fe=0,Zt=null,Sa=!1,Hl=!1,nu=!1,Pn=0,ut=0,Aa=0,el=0,au=0,It=0,Vl=0,Ys=null,Vt=null,lu=!1,xr=0,Kh=0,gr=1/0,vr=null,ja=null,Nt=0,Na=null,$l=null,Wn=0,su=0,iu=null,Zh=null,Fs=0,ru=null;function Jt(){return(Ge&2)!==0&&De!==0?De&-De:T.T!==null?mu():qe()}function Ih(){if(It===0)if((De&536870912)===0||Oe){var e=Ba;Ba<<=1,(Ba&3932160)===0&&(Ba=262144),It=e}else It=536870912;return e=Qt.current,e!==null&&(e.flags|=32),It}function $t(e,t,a){(e===We&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)&&(Gl(e,0),wa(e,De,It,!1)),La(e,a),((Ge&2)===0||e!==We)&&(e===We&&((Ge&2)===0&&(el|=a),ut===4&&wa(e,De,It,!1)),Cn(e))}function Jh(e,t,a){if((Ge&6)!==0)throw Error(o(327));var s=!a&&(t&127)===0&&(t&e.expiredLanes)===0||On(e,t),c=s?ly(e,t):cu(e,t,!0),u=s;do{if(c===0){Hl&&!s&&wa(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!ny(a)){c=cu(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=Ys;var D=S.current.memoizedState.isDehydrated;if(D&&(Gl(S,v).flags|=256),v=cu(S,v,!1),v!==2){if(nu&&!D){S.errorRecoveryDisabledLanes|=u,el|=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){Gl(e,0),wa(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:wa(s,t,It,!Sa);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=xr+300-Le(),10<c)){if(wa(s,t,It,!Sa),An(s,0,!0)!==0)break e;Wn=t,s.timeoutHandle=kp(Ph.bind(null,s,a,Vt,vr,lu,t,It,el,Vl,Sa,u,"Throttled",-0,0),c);break e}Ph(s,a,Vt,vr,lu,t,It,el,Vl,Sa,u,null,-0,0)}}break}while(!0);Cn(e)}function Ph(e,t,a,s,c,u,v,S,D,$,I,ee,Q,Z){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zn},Yh(t,u,ee);var he=(u&62914560)===u?xr-Le():(u&4194048)===u?Kh-Le():0;if(he=Hy(ee,he),he!==null){Wn=u,e.cancelPendingCommit=he(ip.bind(null,e,t,u,a,s,c,v,S,D,I,ee,null,Q,Z)),wa(e,u,v,!$);return}}ip(e,t,u,a,s,c,v,S,D)}function ny(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var s=0;s<a.length;s++){var c=a[s],u=c.getSnapshot;c=c.value;try{if(!Ft(u(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function wa(e,t,a,s){t&=~au,t&=~el,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var c=t;0<c;){var u=31-kt(c),v=1<<u;s[u]=-1,c&=~v}a!==0&&ds(e,a,t)}function yr(){return(Ge&6)===0?(Xs(0),!1):!0}function ou(){if(Re!==null){if(Fe===0)var e=Re.return;else e=Re,$n=Fa=null,Nc(e),Dl=null,ks=0,e=Re;for(;e!==null;)Mh(e.alternate,e),e=e.return;Re=null}}function Gl(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ay(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Wn=0,ou(),We=e,Re=a=Hn(e.current,null),De=t,Fe=0,Zt=null,Sa=!1,Hl=On(e,t),nu=!1,Vl=It=au=el=Aa=ut=0,Vt=Ys=null,lu=!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-kt(s),u=1<<c;t|=e[c],s&=~u}return Pn=t,Hi(),a}function Wh(e,t){Ee=null,T.H=Bs,t===Tl||t===Ki?(t=pm(),Fe=3):t===dc?(t=pm(),Fe=4):Fe=t===Hc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Zt=t,Re===null&&(ut=1,or(e,ln(t,e.current)))}function ep(){var e=Qt.current;return e===null?!0:(De&4194048)===De?cn===null:(De&62914560)===De||(De&536870912)!==0?e===cn:!1}function tp(){var e=T.H;return T.H=Bs,e===null?Bs:e}function np(){var e=T.A;return T.A=ey,e}function br(){ut=4,Sa||(De&4194048)!==De&&Qt.current!==null||(Hl=!0),(Aa&134217727)===0&&(el&134217727)===0||We===null||wa(We,De,It,!1)}function cu(e,t,a){var s=Ge;Ge|=2;var c=tp(),u=np();(We!==e||De!==t)&&(vr=null,Gl(e,t)),t=!1;var v=ut;e:do try{if(Fe!==0&&Re!==null){var S=Re,D=Zt;switch(Fe){case 8:ou(),v=6;break e;case 3:case 2:case 9:case 6:Qt.current===null&&(t=!0);var $=Fe;if(Fe=0,Zt=null,Yl(e,S,D,$),a&&Hl){v=0;break e}break;default:$=Fe,Fe=0,Zt=null,Yl(e,S,D,$)}}ay(),v=ut;break}catch(I){Wh(e,I)}while(!0);return t&&e.shellSuspendCounter++,$n=Fa=null,Ge=s,T.H=c,T.A=u,Re===null&&(We=null,De=0,Hi()),v}function ay(){for(;Re!==null;)ap(Re)}function ly(e,t){var a=Ge;Ge|=2;var s=tp(),c=np();We!==e||De!==t?(vr=null,gr=Le()+500,Gl(e,t)):Hl=On(e,t);e:do try{if(Fe!==0&&Re!==null){t=Re;var u=Zt;t:switch(Fe){case 1:Fe=0,Zt=null,Yl(e,t,u,1);break;case 2:case 9:if(mm(u)){Fe=0,Zt=null,lp(t);break}t=function(){Fe!==2&&Fe!==9||We!==e||(Fe=7),Cn(e)},u.then(t,t);break e;case 3:Fe=7;break e;case 4:Fe=5;break e;case 7:mm(u)?(Fe=0,Zt=null,lp(t)):(Fe=0,Zt=null,Yl(e,t,u,7));break;case 5:var v=null;switch(Re.tag){case 26:v=Re.memoizedState;case 5:case 27:var S=Re;if(v?Gp(v):S.stateNode.complete){Fe=0,Zt=null;var D=S.sibling;if(D!==null)Re=D;else{var $=S.return;$!==null?(Re=$,Sr($)):Re=null}break t}}Fe=0,Zt=null,Yl(e,t,u,5);break;case 6:Fe=0,Zt=null,Yl(e,t,u,6);break;case 8:ou(),ut=6;break e;default:throw Error(o(462))}}sy();break}catch(I){Wh(e,I)}while(!0);return $n=Fa=null,T.H=s,T.A=c,Ge=a,Re!==null?0:(We=null,De=0,Hi(),ut)}function sy(){for(;Re!==null&&!et();)ap(Re)}function ap(e){var t=Eh(e.alternate,e,Pn);e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function lp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Sh(a,t,t.pendingProps,t.type,void 0,De);break;case 11:t=Sh(a,t,t.pendingProps,t.type.render,t.ref,De);break;case 5:Nc(t);default:Mh(a,t),t=Re=nm(t,Pn),t=Eh(a,t,Pn)}e.memoizedProps=e.pendingProps,t===null?Sr(e):Re=t}function Yl(e,t,a,s){$n=Fa=null,Nc(t),Dl=null,ks=0;var c=t.return;try{if(Qv(e,c,t,a,De)){ut=1,or(e,ln(a,e.current)),Re=null;return}}catch(u){if(c!==null)throw Re=c,u;ut=1,or(e,ln(a,e.current)),Re=null;return}t.flags&32768?(Oe||s===1?e=!0:Hl||(De&536870912)!==0?e=!1:(Sa=e=!0,(s===2||s===9||s===3||s===6)&&(s=Qt.current,s!==null&&s.tag===13&&(s.flags|=16384))),sp(t,e)):Sr(t)}function Sr(e){var t=e;do{if((t.flags&32768)!==0){sp(t,Sa);return}e=t.return;var a=Iv(t.alternate,t,Pn);if(a!==null){Re=a;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);ut===0&&(ut=5)}function sp(e,t){do{var a=Jv(e.alternate,e);if(a!==null){a.flags&=32767,Re=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Re=e;return}Re=e=a}while(e!==null);ut=6,Re=null}function ip(e,t,a,s,c,u,v,S,D){e.cancelPendingCommit=null;do Ar();while(Nt!==0);if((Ge&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Jo,ko(e,a,u,v,S,D),e===We&&(Re=We=null,De=0),$l=t,Na=e,Wn=a,su=u,iu=c,Zh=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,cy(Et,function(){return fp(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=T.T,T.T=null,c=F.p,F.p=2,v=Ge,Ge|=4;try{Pv(e,t,a)}finally{Ge=v,F.p=c,T.T=s}}Nt=1,rp(),op(),cp()}}function rp(){if(Nt===1){Nt=0;var e=Na,t=$l,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=T.T,T.T=null;var s=F.p;F.p=2;var c=Ge;Ge|=4;try{Vh(t,e);var u=Su,v=Qd(e.containerInfo),S=u.focusedElem,D=u.selectionRange;if(v!==S&&S&&S.ownerDocument&&Xd(S.ownerDocument.documentElement,S)){if(D!==null&&Xo(S)){var $=D.start,I=D.end;if(I===void 0&&(I=$),"selectionStart"in S)S.selectionStart=$,S.selectionEnd=Math.min(I,S.value.length);else{var ee=S.ownerDocument||document,Q=ee&&ee.defaultView||window;if(Q.getSelection){var Z=Q.getSelection(),he=S.textContent.length,je=Math.min(D.start,he),Je=D.end===void 0?je:Math.min(D.end,he);!Z.extend&&je>Je&&(v=Je,Je=je,je=v);var L=Fd(S,je),O=Fd(S,Je);if(L&&O&&(Z.rangeCount!==1||Z.anchorNode!==L.node||Z.anchorOffset!==L.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var V=ee.createRange();V.setStart(L.node,L.offset),Z.removeAllRanges(),je>Je?(Z.addRange(V),Z.extend(O.node,O.offset)):(V.setEnd(O.node,O.offset),Z.addRange(V))}}}}for(ee=[],Z=S;Z=Z.parentNode;)Z.nodeType===1&&ee.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<ee.length;S++){var W=ee[S];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}_r=!!bu,Su=bu=null}finally{Ge=c,F.p=s,T.T=a}}e.current=t,Nt=2}}function op(){if(Nt===2){Nt=0;var e=Na,t=$l,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=T.T,T.T=null;var s=F.p;F.p=2;var c=Ge;Ge|=4;try{Bh(e,t.alternate,t)}finally{Ge=c,F.p=s,T.T=a}}Nt=3}}function cp(){if(Nt===4||Nt===3){Nt=0,dt();var e=Na,t=$l,a=Wn,s=Zh;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Nt=5:(Nt=0,$l=Na=null,up(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(ja=null),Pe(a),t=t.stateNode,At&&typeof At.onCommitFiberRoot=="function")try{At.onCommitFiberRoot(Dn,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=T.T,c=F.p,F.p=2,T.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{T.T=t,F.p=c}}(Wn&3)!==0&&Ar(),Cn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===ru?Fs++:(Fs=0,ru=e):Fs=0,Xs(0)}}function up(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cs(t)))}function Ar(){return rp(),op(),cp(),fp()}function fp(){if(Nt!==5)return!1;var e=Na,t=su;su=0;var a=Pe(Wn),s=T.T,c=F.p;try{F.p=32>a?32:a,T.T=null,a=iu,iu=null;var u=Na,v=Wn;if(Nt=0,$l=Na=null,Wn=0,(Ge&6)!==0)throw Error(o(331));var S=Ge;if(Ge|=4,Xh(u.current),Gh(u,u.current,v,a),Ge=S,Xs(0,!1),At&&typeof At.onPostCommitFiberRoot=="function")try{At.onPostCommitFiberRoot(Dn,u)}catch{}return!0}finally{F.p=c,T.T=s,up(e,t)}}function dp(e,t,a){t=ln(a,t),t=Uc(e.stateNode,t,2),e=ga(e,t,2),e!==null&&(La(e,2),Cn(e))}function Xe(e,t,a){if(e.tag===3)dp(e,e,a);else for(;t!==null;){if(t.tag===3){dp(t,e,a);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(ja===null||!ja.has(s))){e=ln(a,e),a=mh(2),s=ga(t,a,2),s!==null&&(hh(a,s,t,e),La(s,2),Cn(s));break}}t=t.return}}function uu(e,t,a){var s=e.pingCache;if(s===null){s=e.pingCache=new ty;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(a)||(nu=!0,c.add(a),e=iy.bind(null,e,t,a),t.then(e,e))}function iy(e,t,a){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,We===e&&(De&a)===a&&(ut===4||ut===3&&(De&62914560)===De&&300>Le()-xr?(Ge&2)===0&&Gl(e,0):au|=a,Vl===De&&(Vl=0)),Cn(e)}function mp(e,t){t===0&&(t=us()),e=$a(e,t),e!==null&&(La(e,t),Cn(e))}function ry(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),mp(e,a)}function oy(e,t){var a=0;switch(e.tag){case 31:case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(a=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),mp(e,a)}function cy(e,t){return me(e,t)}var jr=null,Fl=null,fu=!1,Nr=!1,du=!1,Ca=0;function Cn(e){e!==Fl&&e.next===null&&(Fl===null?jr=Fl=e:Fl=Fl.next=e),Nr=!0,fu||(fu=!0,fy())}function Xs(e,t){if(!du&&Nr){du=!0;do for(var a=!1,s=jr;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-kt(42|e)+1)-1,u&=c&~(v&~S),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,gp(s,u))}else u=De,u=An(s,s===We?u:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(u&3)===0||On(s,u)||(a=!0,gp(s,u));s=s.next}while(a);du=!1}}function uy(){hp()}function hp(){Nr=fu=!1;var e=0;Ca!==0&&Sy()&&(e=Ca);for(var t=Le(),a=null,s=jr;s!==null;){var c=s.next,u=pp(s,t);u===0?(s.next=null,a===null?jr=c:a.next=c,c===null&&(Fl=a)):(a=s,(e!==0||(u&3)!==0)&&(Nr=!0)),s=c}Nt!==0&&Nt!==5||Xs(e),Ca!==0&&(Ca=0)}function pp(e,t){for(var a=e.suspendedLanes,s=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-kt(u),S=1<<v,D=c[v];D===-1?((S&a)===0||(S&s)!==0)&&(c[v]=dl(S,t)):D<=t&&(e.expiredLanes|=S),u&=~S}if(t=We,a=De,a=An(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,a===0||e===t&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&we(s),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||On(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(s!==null&&we(s),Pe(a)){case 2:case 8:a=Tn;break;case 32:a=Et;break;case 268435456:a=Gt;break;default:a=Et}return s=xp.bind(null,e),a=me(a,s),e.callbackPriority=t,e.callbackNode=a,t}return s!==null&&s!==null&&we(s),e.callbackPriority=2,e.callbackNode=null,2}function xp(e,t){if(Nt!==0&&Nt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Ar()&&e.callbackNode!==a)return null;var s=De;return s=An(e,e===We?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Jh(e,s,t),pp(e,Le()),e.callbackNode!=null&&e.callbackNode===a?xp.bind(null,e):null)}function gp(e,t){if(Ar())return null;Jh(e,t,!0)}function fy(){jy(function(){(Ge&6)!==0?me(mt,uy):hp()})}function mu(){if(Ca===0){var e=ql;e===0&&(e=fl,fl<<=1,(fl&261888)===0&&(fl=256)),Ca=e}return Ca}function vp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ti(""+e)}function yp(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function dy(e,t,a,s,c){if(t==="submit"&&a&&a.stateNode===c){var u=vp((c[jt]||null).action),v=s.submitter;v&&(t=(t=v[jt]||null)?vp(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var S=new Bi("action","action",null,s,c);e.push({event:S,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(Ca!==0){var D=v?yp(c,v):new FormData(c);Dc(a,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(S.preventDefault(),D=v?yp(c,v):new FormData(c),Dc(a,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var hu=0;hu<Io.length;hu++){var pu=Io[hu],my=pu.toLowerCase(),hy=pu[0].toUpperCase()+pu.slice(1);pn(my,"on"+hy)}pn(Id,"onAnimationEnd"),pn(Jd,"onAnimationIteration"),pn(Pd,"onAnimationStart"),pn("dblclick","onDoubleClick"),pn("focusin","onFocus"),pn("focusout","onBlur"),pn(qv,"onTransitionRun"),pn(Rv,"onTransitionStart"),pn(Tv,"onTransitionCancel"),pn(Wd,"onTransitionEnd"),xl("onMouseEnter",["mouseout","mouseover"]),xl("onMouseLeave",["mouseout","mouseover"]),xl("onPointerEnter",["pointerout","pointerover"]),xl("onPointerLeave",["pointerout","pointerover"]),za("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),za("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),za("onBeforeInput",["compositionend","keypress","textInput","paste"]),za("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),za("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qs="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(" "),py=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qs));function bp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var s=e[a],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,$=S.currentTarget;if(S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=$;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}else for(v=0;v<s.length;v++){if(S=s[v],D=S.instance,$=S.currentTarget,S=S.listener,D!==u&&c.isPropagationStopped())break e;u=S,c.currentTarget=$;try{u(c)}catch(I){Ui(I)}c.currentTarget=null,u=D}}}}function Te(e,t){var a=t[Bn];a===void 0&&(a=t[Bn]=new Set);var s=e+"__bubble";a.has(s)||(Sp(t,e,2,!1),a.add(s))}function xu(e,t,a){var s=0;t&&(s|=4),Sp(a,e,s,t)}var wr="_reactListening"+Math.random().toString(36).slice(2);function gu(e){if(!e[wr]){e[wr]=!0,hd.forEach(function(a){a!=="selectionchange"&&(py.has(a)||xu(a,!1,e),xu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wr]||(t[wr]=!0,xu("selectionchange",!1,t))}}function Sp(e,t,a,s){switch(Ip(t)){case 2:var c=Gy;break;case 8:c=Yy;break;default:c=Tu}a=c.bind(null,t,a,e),c=void 0,!Lo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),s?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function vu(e,t,a,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=ml(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}Cd(function(){var $=u,I=Oo(a),ee=[];e:{var Q=em.get(e);if(Q!==void 0){var Z=Bi,he=e;switch(e){case"keypress":if(_i(a)===0)break e;case"keydown":case"keyup":Z=ov;break;case"focusin":he="focus",Z=Vo;break;case"focusout":he="blur",Z=Vo;break;case"beforeblur":case"afterblur":Z=Vo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Md;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=Ig;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=fv;break;case Id:case Jd:case Pd:Z=Wg;break;case Wd:Z=mv;break;case"scroll":case"scrollend":Z=Kg;break;case"wheel":Z=pv;break;case"copy":case"cut":case"paste":Z=tv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Rd;break;case"toggle":case"beforetoggle":Z=gv}var je=(t&4)!==0,Je=!je&&(e==="scroll"||e==="scrollend"),L=je?Q!==null?Q+"Capture":null:Q;je=[];for(var O=$,V;O!==null;){var W=O;if(V=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||V===null||L===null||(W=ps(O,L),W!=null&&je.push(Ks(O,W,V))),Je)break;O=O.return}0<je.length&&(Q=new Z(Q,he,null,a,I),ee.push({event:Q,listeners:je}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",Q&&a!==_o&&(he=a.relatedTarget||a.fromElement)&&(ml(he)||he[lt]))break e;if((Z||Q)&&(Q=I.window===I?I:(Q=I.ownerDocument)?Q.defaultView||Q.parentWindow:window,Z?(he=a.relatedTarget||a.toElement,Z=$,he=he?ml(he):null,he!==null&&(Je=d(he),je=he.tag,he!==Je||je!==5&&je!==27&&je!==6)&&(he=null)):(Z=null,he=$),Z!==he)){if(je=Md,W="onMouseLeave",L="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(je=Rd,W="onPointerLeave",L="onPointerEnter",O="pointer"),Je=Z==null?Q:hs(Z),V=he==null?Q:hs(he),Q=new je(W,O+"leave",Z,a,I),Q.target=Je,Q.relatedTarget=V,W=null,ml(I)===$&&(je=new je(L,O+"enter",he,a,I),je.target=V,je.relatedTarget=Je,W=je),Je=W,Z&&he)t:{for(je=xy,L=Z,O=he,V=0,W=L;W;W=je(W))V++;W=0;for(var Se=O;Se;Se=je(Se))W++;for(;0<V-W;)L=je(L),V--;for(;0<W-V;)O=je(O),W--;for(;V--;){if(L===O||O!==null&&L===O.alternate){je=L;break t}L=je(L),O=je(O)}je=null}else je=null;Z!==null&&Ap(ee,Q,Z,je,!1),he!==null&&Je!==null&&Ap(ee,Je,he,je,!0)}}e:{if(Q=$?hs($):window,Z=Q.nodeName&&Q.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Q.type==="file")var He=Ud;else if(Ld(Q))if(Hd)He=Ev;else{He=wv;var ge=Nv}else Z=Q.nodeName,!Z||Z.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?$&&Do($.elementType)&&(He=Ud):He=Cv;if(He&&(He=He(e,$))){zd(ee,He,a,I);break e}ge&&ge(e,Q,$),e==="focusout"&&$&&Q.type==="number"&&$.memoizedProps.value!=null&&To(Q,"number",Q.value)}switch(ge=$?hs($):window,e){case"focusin":(Ld(ge)||ge.contentEditable==="true")&&(Al=ge,Qo=$,js=null);break;case"focusout":js=Qo=Al=null;break;case"mousedown":Ko=!0;break;case"contextmenu":case"mouseup":case"dragend":Ko=!1,Kd(ee,a,I);break;case"selectionchange":if(Mv)break;case"keydown":case"keyup":Kd(ee,a,I)}var ke;if(Go)e:{switch(e){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Sl?Od(e,a)&&(_e="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(_e="onCompositionStart");_e&&(Td&&a.locale!=="ko"&&(Sl||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Sl&&(ke=Ed()):(ua=I,zo="value"in ua?ua.value:ua.textContent,Sl=!0)),ge=Cr($,_e),0<ge.length&&(_e=new qd(_e,e,null,a,I),ee.push({event:_e,listeners:ge}),ke?_e.data=ke:(ke=Bd(a),ke!==null&&(_e.data=ke)))),(ke=yv?bv(e,a):Sv(e,a))&&(_e=Cr($,"onBeforeInput"),0<_e.length&&(ge=new qd("onBeforeInput","beforeinput",null,a,I),ee.push({event:ge,listeners:_e}),ge.data=ke)),dy(ee,e,$,a,I)}bp(ee,t)})}function Ks(e,t,a){return{instance:e,listener:t,currentTarget:a}}function Cr(e,t){for(var a=t+"Capture",s=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=ps(e,a),c!=null&&s.unshift(Ks(e,c,u)),c=ps(e,t),c!=null&&s.push(Ks(e,c,u))),e.tag===3)return s;e=e.return}return[]}function xy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ap(e,t,a,s,c){for(var u=t._reactName,v=[];a!==null&&a!==s;){var S=a,D=S.alternate,$=S.stateNode;if(S=S.tag,D!==null&&D===s)break;S!==5&&S!==26&&S!==27||$===null||(D=$,c?($=ps(a,u),$!=null&&v.unshift(Ks(a,$,D))):c||($=ps(a,u),$!=null&&v.push(Ks(a,$,D)))),a=a.return}v.length!==0&&e.push({event:t,listeners:v})}var gy=/\r\n?/g,vy=/\u0000|\uFFFD/g;function jp(e){return(typeof e=="string"?e:""+e).replace(gy,`
`).replace(vy,"")}function Np(e,t){return t=jp(t),jp(e)===t}function Ie(e,t,a,s,c,u){switch(a){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||vl(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&vl(e,""+s);break;case"className":qi(e,"class",s);break;case"tabIndex":qi(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":qi(e,a,s);break;case"style":Nd(e,s,u);break;case"data":if(t!=="object"){qi(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(a);break}s=Ti(""+s),e.setAttribute(a,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(a==="formAction"?(t!=="input"&&Ie(e,t,"name",c.name,c,null),Ie(e,t,"formEncType",c.formEncType,c,null),Ie(e,t,"formMethod",c.formMethod,c,null),Ie(e,t,"formTarget",c.formTarget,c,null)):(Ie(e,t,"encType",c.encType,c,null),Ie(e,t,"method",c.method,c,null),Ie(e,t,"target",c.target,c,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(a);break}s=Ti(""+s),e.setAttribute(a,s);break;case"onClick":s!=null&&(e.onclick=zn);break;case"onScroll":s!=null&&Te("scroll",e);break;case"onScrollEnd":s!=null&&Te("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(a=s.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}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}a=Ti(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,""+s):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":s===!0?e.setAttribute(a,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,s):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(a,s):e.removeAttribute(a);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(a):e.setAttribute(a,s);break;case"popover":Te("beforetoggle",e),Te("toggle",e),Mi(e,"popover",s);break;case"xlinkActuate":Ln(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Ln(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Ln(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Ln(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Ln(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Ln(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Ln(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Mi(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Xg.get(a)||a,Mi(e,a,s))}}function yu(e,t,a,s,c,u){switch(a){case"style":Nd(e,s,u);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(a=s.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof s=="string"?vl(e,s):(typeof s=="number"||typeof s=="bigint")&&vl(e,""+s);break;case"onScroll":s!=null&&Te("scroll",e);break;case"onScrollEnd":s!=null&&Te("scrollend",e);break;case"onClick":s!=null&&(e.onclick=zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!pd.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),u=e[jt]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof s=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,s,c);break e}a in e?e[a]=s:s===!0?e.setAttribute(a,""):Mi(e,a,s)}}}function Tt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Te("error",e),Te("load",e);var s=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var v=a[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:Ie(e,t,u,v,a,null)}}c&&Ie(e,t,"srcSet",a.srcSet,a,null),s&&Ie(e,t,"src",a.src,a,null);return;case"input":Te("invalid",e);var S=u=v=c=null,D=null,$=null;for(s in a)if(a.hasOwnProperty(s)){var I=a[s];if(I!=null)switch(s){case"name":c=I;break;case"type":v=I;break;case"checked":D=I;break;case"defaultChecked":$=I;break;case"value":u=I;break;case"defaultValue":S=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:Ie(e,t,s,I,a,null)}}bd(e,u,S,D,$,v,c,!1);return;case"select":Te("invalid",e),s=v=u=null;for(c in a)if(a.hasOwnProperty(c)&&(S=a[c],S!=null))switch(c){case"value":u=S;break;case"defaultValue":v=S;break;case"multiple":s=S;default:Ie(e,t,c,S,a,null)}t=u,a=v,e.multiple=!!s,t!=null?gl(e,!!s,t,!1):a!=null&&gl(e,!!s,a,!0);return;case"textarea":Te("invalid",e),u=c=s=null;for(v in a)if(a.hasOwnProperty(v)&&(S=a[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:Ie(e,t,v,S,a,null)}Ad(e,s,c,u);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(s=a[D],s!=null))switch(D){case"selected":e.selected=s&&typeof s!="function"&&typeof s!="symbol";break;default:Ie(e,t,D,s,a,null)}return;case"dialog":Te("beforetoggle",e),Te("toggle",e),Te("cancel",e),Te("close",e);break;case"iframe":case"object":Te("load",e);break;case"video":case"audio":for(s=0;s<Qs.length;s++)Te(Qs[s],e);break;case"image":Te("error",e),Te("load",e);break;case"details":Te("toggle",e);break;case"embed":case"source":case"link":Te("error",e),Te("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($ in a)if(a.hasOwnProperty($)&&(s=a[$],s!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ie(e,t,$,s,a,null)}return;default:if(Do(t)){for(I in a)a.hasOwnProperty(I)&&(s=a[I],s!==void 0&&yu(e,t,I,s,a,void 0));return}}for(S in a)a.hasOwnProperty(S)&&(s=a[S],s!=null&&Ie(e,t,S,s,a,null))}function yy(e,t,a,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,$=null,I=null;for(Z in a){var ee=a[Z];if(a.hasOwnProperty(Z)&&ee!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ee;default:s.hasOwnProperty(Z)||Ie(e,t,Z,null,s,ee)}}for(var Q in s){var Z=s[Q];if(ee=a[Q],s.hasOwnProperty(Q)&&(Z!=null||ee!=null))switch(Q){case"type":u=Z;break;case"name":c=Z;break;case"checked":$=Z;break;case"defaultChecked":I=Z;break;case"value":v=Z;break;case"defaultValue":S=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ee&&Ie(e,t,Q,Z,s,ee)}}Ro(e,v,S,D,$,I,u,c);return;case"select":Z=v=S=Q=null;for(u in a)if(D=a[u],a.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":Z=D;default:s.hasOwnProperty(u)||Ie(e,t,u,null,s,D)}for(c in s)if(u=s[c],D=a[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&&Ie(e,t,c,u,s,D)}t=S,a=v,s=Z,Q!=null?gl(e,!!a,Q,!1):!!s!=!!a&&(t!=null?gl(e,!!a,t,!0):gl(e,!!a,a?[]:"",!1));return;case"textarea":Z=Q=null;for(S in a)if(c=a[S],a.hasOwnProperty(S)&&c!=null&&!s.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:Ie(e,t,S,null,s,c)}for(v in s)if(c=s[v],u=a[v],s.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":Q=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ie(e,t,v,c,s,u)}Sd(e,Q,Z);return;case"option":for(var he in a)if(Q=a[he],a.hasOwnProperty(he)&&Q!=null&&!s.hasOwnProperty(he))switch(he){case"selected":e.selected=!1;break;default:Ie(e,t,he,null,s,Q)}for(D in s)if(Q=s[D],Z=a[D],s.hasOwnProperty(D)&&Q!==Z&&(Q!=null||Z!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Ie(e,t,D,Q,s,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var je in a)Q=a[je],a.hasOwnProperty(je)&&Q!=null&&!s.hasOwnProperty(je)&&Ie(e,t,je,null,s,Q);for($ in s)if(Q=s[$],Z=a[$],s.hasOwnProperty($)&&Q!==Z&&(Q!=null||Z!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Ie(e,t,$,Q,s,Z)}return;default:if(Do(t)){for(var Je in a)Q=a[Je],a.hasOwnProperty(Je)&&Q!==void 0&&!s.hasOwnProperty(Je)&&yu(e,t,Je,void 0,s,Q);for(I in s)Q=s[I],Z=a[I],!s.hasOwnProperty(I)||Q===Z||Q===void 0&&Z===void 0||yu(e,t,I,Q,s,Z);return}}for(var L in a)Q=a[L],a.hasOwnProperty(L)&&Q!=null&&!s.hasOwnProperty(L)&&Ie(e,t,L,null,s,Q);for(ee in s)Q=s[ee],Z=a[ee],!s.hasOwnProperty(ee)||Q===Z||Q==null&&Z==null||Ie(e,t,ee,Q,s,Z)}function wp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function by(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),s=0;s<a.length;s++){var c=a[s],u=c.transferSize,v=c.initiatorType,S=c.duration;if(u&&S&&wp(v)){for(v=0,S=c.responseEnd,s+=1;s<a.length;s++){var D=a[s],$=D.startTime;if($>S)break;var I=D.transferSize,ee=D.initiatorType;I&&wp(ee)&&(D=D.responseEnd,v+=I*(D<S?1:(S-$)/(D-$)))}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 bu=null,Su=null;function Er(e){return e.nodeType===9?e:e.ownerDocument}function Cp(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 Ep(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 Au(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 ju=null;function Sy(){var e=window.event;return e&&e.type==="popstate"?e===ju?!1:(ju=e,!0):(ju=null,!1)}var kp=typeof setTimeout=="function"?setTimeout:void 0,Ay=typeof clearTimeout=="function"?clearTimeout:void 0,Mp=typeof Promise=="function"?Promise:void 0,jy=typeof queueMicrotask=="function"?queueMicrotask:typeof Mp<"u"?function(e){return Mp.resolve(null).then(e).catch(Ny)}:kp;function Ny(e){setTimeout(function(){throw e})}function Ea(e){return e==="head"}function qp(e,t){var a=t,s=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(s===0){e.removeChild(c),Zl(t);return}s--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")s++;else if(a==="html")Zs(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zs(a);for(var u=a.firstChild;u;){var v=u.nextSibling,S=u.nodeName;u[ms]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=v}}else a==="body"&&Zs(e.ownerDocument.body);a=c}while(a);Zl(t)}function Rp(e,t){var a=e;e=0;do{var s=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),s&&s.nodeType===8)if(a=s.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=s}while(a)}function Nu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Nu(a),Mo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function wy(e,t,a,s){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[ms])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=un(e.nextSibling),e===null)break}return null}function Cy(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=un(e.nextSibling),e===null))return null;return e}function Tp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=un(e.nextSibling),e===null))return null;return e}function wu(e){return e.data==="$?"||e.data==="$~"}function Cu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Ey(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var s=function(){t(),a.removeEventListener("DOMContentLoaded",s)};a.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function un(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 Eu=null;function Dp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return un(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function _p(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function Op(e,t,a){switch(t=Er(a),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Zs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Mo(e)}var fn=new Map,Bp=new Set;function kr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ea=F.d;F.d={f:ky,r:My,D:qy,C:Ry,L:Ty,m:Dy,X:Oy,S:_y,M:By};function ky(){var e=ea.f(),t=yr();return e||t}function My(e){var t=hl(e);t!==null&&t.tag===5&&t.type==="form"?Wm(t):ea.r(e)}var Xl=typeof document>"u"?null:document;function Lp(e,t,a){var s=Xl;if(s&&typeof t=="string"&&t){var c=nn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Bp.has(c)||(Bp.add(c),e={rel:e,crossOrigin:a,href:t},s.querySelector(c)===null&&(t=s.createElement("link"),Tt(t,"link",e),wt(t),s.head.appendChild(t)))}}function qy(e){ea.D(e),Lp("dns-prefetch",e,null)}function Ry(e,t){ea.C(e,t),Lp("preconnect",e,t)}function Ty(e,t,a){ea.L(e,t,a);var s=Xl;if(s&&e&&t){var c='link[rel="preload"][as="'+nn(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+nn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+nn(a.imageSizes)+'"]')):c+='[href="'+nn(e)+'"]';var u=c;switch(t){case"style":u=Ql(e);break;case"script":u=Kl(e)}fn.has(u)||(e=b({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),fn.set(u,e),s.querySelector(c)!==null||t==="style"&&s.querySelector(Is(u))||t==="script"&&s.querySelector(Js(u))||(t=s.createElement("link"),Tt(t,"link",e),wt(t),s.head.appendChild(t)))}}function Dy(e,t){ea.m(e,t);var a=Xl;if(a&&e){var s=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+nn(s)+'"][href="'+nn(e)+'"]',u=c;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Kl(e)}if(!fn.has(u)&&(e=b({rel:"modulepreload",href:e},t),fn.set(u,e),a.querySelector(c)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Js(u)))return}s=a.createElement("link"),Tt(s,"link",e),wt(s),a.head.appendChild(s)}}}function _y(e,t,a){ea.S(e,t,a);var s=Xl;if(s&&e){var c=pl(s).hoistableStyles,u=Ql(e);t=t||"default";var v=c.get(u);if(!v){var S={loading:0,preload:null};if(v=s.querySelector(Is(u)))S.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},a),(a=fn.get(u))&&ku(e,a);var D=v=s.createElement("link");wt(D),Tt(D,"link",e),D._p=new Promise(function($,I){D.onload=$,D.onerror=I}),D.addEventListener("load",function(){S.loading|=1}),D.addEventListener("error",function(){S.loading|=2}),S.loading|=4,Mr(v,t,s)}v={type:"stylesheet",instance:v,count:1,state:S},c.set(u,v)}}}function Oy(e,t){ea.X(e,t);var a=Xl;if(a&&e){var s=pl(a).hoistableScripts,c=Kl(e),u=s.get(c);u||(u=a.querySelector(Js(c)),u||(e=b({src:e,async:!0},t),(t=fn.get(c))&&Mu(e,t),u=a.createElement("script"),wt(u),Tt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function By(e,t){ea.M(e,t);var a=Xl;if(a&&e){var s=pl(a).hoistableScripts,c=Kl(e),u=s.get(c);u||(u=a.querySelector(Js(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=fn.get(c))&&Mu(e,t),u=a.createElement("script"),wt(u),Tt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function zp(e,t,a,s){var c=(c=ie.current)?kr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Ql(a.href),a=pl(c).hoistableStyles,s=a.get(t),s||(s={type:"style",instance:null,count:0,state:null},a.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Ql(a.href);var u=pl(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(Is(e)))&&!u._p&&(v.instance=u,v.state.loading=5),fn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},fn.set(e,a),u||Ly(c,e,a,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=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Kl(a),a=pl(c).hoistableScripts,s=a.get(t),s||(s={type:"script",instance:null,count:0,state:null},a.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ql(e){return'href="'+nn(e)+'"'}function Is(e){return'link[rel="stylesheet"]['+e+"]"}function Up(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Ly(e,t,a,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}),Tt(t,"link",a),wt(t),e.head.appendChild(t))}function Kl(e){return'[src="'+nn(e)+'"]'}function Js(e){return"script[async]"+e}function Hp(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+nn(a.href)+'"]');if(s)return t.instance=s,wt(s),s;var c=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),wt(s),Tt(s,"style",c),Mr(s,a.precedence,e),t.instance=s;case"stylesheet":c=Ql(a.href);var u=e.querySelector(Is(c));if(u)return t.state.loading|=4,t.instance=u,wt(u),u;s=Up(a),(c=fn.get(c))&&ku(s,c),u=(e.ownerDocument||e).createElement("link"),wt(u);var v=u;return v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Tt(u,"link",s),t.state.loading|=4,Mr(u,a.precedence,e),t.instance=u;case"script":return u=Kl(a.src),(c=e.querySelector(Js(u)))?(t.instance=c,wt(c),c):(s=a,(c=fn.get(u))&&(s=b({},a),Mu(s,c)),e=e.ownerDocument||e,c=e.createElement("script"),wt(c),Tt(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,Mr(s,a.precedence,e));return t.instance}function Mr(e,t,a){for(var s=a.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=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function ku(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Mu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var qr=null;function Vp(e,t,a){if(qr===null){var s=new Map,c=qr=new Map;c.set(a,s)}else c=qr,s=c.get(a),s||(s=new Map,c.set(a,s));if(s.has(e))return s;for(s.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[ms]||u[rt]||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 $p(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function zy(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Gp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Uy(e,t,a,s){if(a.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Ql(s.href),u=t.querySelector(Is(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Rr.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,wt(u);return}u=t.ownerDocument||t,s=Up(s),(c=fn.get(c))&&ku(s,c),u=u.createElement("link"),wt(u);var v=u;v._p=new Promise(function(S,D){v.onload=S,v.onerror=D}),Tt(u,"link",s),a.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Rr.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var qu=0;function Hy(e,t){return e.stylesheets&&e.count===0&&Dr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var s=setTimeout(function(){if(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&qu===0&&(qu=62500*by());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Dr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>qu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(c)}}:null}function Rr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Dr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Tr=null;function Dr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Tr=new Map,t.forEach(Vy,e),Tr=null,Rr.call(e))}function Vy(e,t){if(!(t.state.loading&4)){var a=Tr.get(e);if(a)var s=a.get(null);else{a=new Map,Tr.set(e,a);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")&&(a.set(v.dataset.precedence,v),s=v)}s&&a.set(null,s)}c=t.instance,v=c.getAttribute("data-precedence"),u=a.get(v)||s,u===s&&a.set(null,c),a.set(v,c),this.count++,s=Rr.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 Ps={$$typeof:C,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function $y(e,t,a,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=fs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fs(0),this.hiddenUpdates=fs(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 Yp(e,t,a,s,c,u,v,S,D,$,I,ee){return e=new $y(e,t,a,v,D,$,I,ee,S),t=1,u===!0&&(t|=24),u=Xt(3,null,null,t),e.current=u,u.stateNode=e,t=cc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:s,isDehydrated:a,cache:t},mc(u),e}function Fp(e){return e?(e=wl,e):wl}function Xp(e,t,a,s,c,u){c=Fp(c),s.context===null?s.context=c:s.pendingContext=c,s=xa(t),s.payload={element:a},u=u===void 0?null:u,u!==null&&(s.callback=u),a=ga(e,s,t),a!==null&&($t(a,e,t),qs(a,e,t))}function Qp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Ru(e,t){Qp(e,t),(e=e.alternate)&&Qp(e,t)}function Kp(e){if(e.tag===13||e.tag===31){var t=$a(e,67108864);t!==null&&$t(t,e,67108864),Ru(e,67108864)}}function Zp(e){if(e.tag===13||e.tag===31){var t=Jt();t=Ke(t);var a=$a(e,t);a!==null&&$t(a,e,t),Ru(e,t)}}var _r=!0;function Gy(e,t,a,s){var c=T.T;T.T=null;var u=F.p;try{F.p=2,Tu(e,t,a,s)}finally{F.p=u,T.T=c}}function Yy(e,t,a,s){var c=T.T;T.T=null;var u=F.p;try{F.p=8,Tu(e,t,a,s)}finally{F.p=u,T.T=c}}function Tu(e,t,a,s){if(_r){var c=Du(s);if(c===null)vu(e,t,s,Or,a),Jp(e,s);else if(Xy(c,e,t,a,s))s.stopPropagation();else if(Jp(e,s),t&4&&-1<Fy.indexOf(e)){for(;c!==null;){var u=hl(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=_n(u.pendingLanes);if(v!==0){var S=u;for(S.pendingLanes|=2,S.entangledLanes|=2;v;){var D=1<<31-kt(v);S.entanglements[1]|=D,v&=~D}Cn(u),(Ge&6)===0&&(gr=Le()+500,Xs(0))}}break;case 31:case 13:S=$a(u,2),S!==null&&$t(S,u,2),yr(),Ru(u,2)}if(u=Du(s),u===null&&vu(e,t,s,Or,a),u===c)break;c=u}c!==null&&s.stopPropagation()}else vu(e,t,s,null,a)}}function Du(e){return e=Oo(e),_u(e)}var Or=null;function _u(e){if(Or=null,e=ml(e),e!==null){var t=d(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=x(t),e!==null)return e;e=null}else if(a===31){if(e=h(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Or=e,null}function Ip(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(xt()){case mt:return 2;case Tn:return 8;case Et:case cl:return 32;case Gt:return 268435456;default:return 32}default:return 32}}var Ou=!1,ka=null,Ma=null,qa=null,Ws=new Map,ei=new Map,Ra=[],Fy="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 Jp(e,t){switch(e){case"focusin":case"focusout":ka=null;break;case"dragenter":case"dragleave":Ma=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":Ws.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(t.pointerId)}}function ti(e,t,a,s,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:s,nativeEvent:u,targetContainers:[c]},t!==null&&(t=hl(t),t!==null&&Kp(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function Xy(e,t,a,s,c){switch(t){case"focusin":return ka=ti(ka,e,t,a,s,c),!0;case"dragenter":return Ma=ti(Ma,e,t,a,s,c),!0;case"mouseover":return qa=ti(qa,e,t,a,s,c),!0;case"pointerover":var u=c.pointerId;return Ws.set(u,ti(Ws.get(u)||null,e,t,a,s,c)),!0;case"gotpointercapture":return u=c.pointerId,ei.set(u,ti(ei.get(u)||null,e,t,a,s,c)),!0}return!1}function Pp(e){var t=ml(e.target);if(t!==null){var a=d(t);if(a!==null){if(t=a.tag,t===13){if(t=x(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Zp(a)});return}}else if(t===31){if(t=h(a),t!==null){e.blockedOn=t,Ye(e.priority,function(){Zp(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Br(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Du(e.nativeEvent);if(a===null){a=e.nativeEvent;var s=new a.constructor(a.type,a);_o=s,a.target.dispatchEvent(s),_o=null}else return t=hl(a),t!==null&&Kp(t),e.blockedOn=a,!1;t.shift()}return!0}function Wp(e,t,a){Br(e)&&a.delete(t)}function Qy(){Ou=!1,ka!==null&&Br(ka)&&(ka=null),Ma!==null&&Br(Ma)&&(Ma=null),qa!==null&&Br(qa)&&(qa=null),Ws.forEach(Wp),ei.forEach(Wp)}function Lr(e,t){e.blockedOn===t&&(e.blockedOn=null,Ou||(Ou=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Qy)))}var zr=null;function e0(e){zr!==e&&(zr=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){zr===e&&(zr=null);for(var t=0;t<e.length;t+=3){var a=e[t],s=e[t+1],c=e[t+2];if(typeof s!="function"){if(_u(s||a)===null)continue;break}var u=hl(a);u!==null&&(e.splice(t,3),t-=3,Dc(u,{pending:!0,data:c,method:a.method,action:s},s,c))}}))}function Zl(e){function t(D){return Lr(D,e)}ka!==null&&Lr(ka,e),Ma!==null&&Lr(Ma,e),qa!==null&&Lr(qa,e),Ws.forEach(t),ei.forEach(t);for(var a=0;a<Ra.length;a++){var s=Ra[a];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Ra.length&&(a=Ra[0],a.blockedOn===null);)Pp(a),a.blockedOn===null&&Ra.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(s=0;s<a.length;s+=3){var c=a[s],u=a[s+1],v=c[jt]||null;if(typeof u=="function")v||e0(a);else if(v){var S=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[jt]||null)S=v.formAction;else if(_u(c)!==null)continue}else S=v.action;typeof S=="function"?a[s+1]=S:(a.splice(s,3),s-=3),e0(a)}}}function t0(){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(a,20)}function a(){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(a,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Bu(e){this._internalRoot=e}Ur.prototype.render=Bu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,s=Jt();Xp(a,s,e,t,null,null)},Ur.prototype.unmount=Bu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Xp(e.current,2,null,e,null,null),yr(),t[lt]=null}};function Ur(e){this._internalRoot=e}Ur.prototype.unstable_scheduleHydration=function(e){if(e){var t=qe();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Ra.length&&t!==0&&t<Ra[a].priority;a++);Ra.splice(a,0,e),a===0&&Pp(e)}};var n0=l.version;if(n0!=="19.2.0")throw Error(o(527,n0,"19.2.0"));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Ky={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hr.isDisabled&&Hr.supportsFiber)try{Dn=Hr.inject(Ky),At=Hr}catch{}}return ai.createRoot=function(e,t){if(!f(e))throw Error(o(299));var a=!1,s="",c=ch,u=uh,v=fh;return t!=null&&(t.unstable_strictMode===!0&&(a=!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=Yp(e,1,!1,null,null,a,s,null,c,u,v,t0),e[lt]=t.current,gu(e),new Bu(t)},ai.hydrateRoot=function(e,t,a){if(!f(e))throw Error(o(299));var s=!1,c="",u=ch,v=uh,S=fh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(s=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(u=a.onUncaughtError),a.onCaughtError!==void 0&&(v=a.onCaughtError),a.onRecoverableError!==void 0&&(S=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=Yp(e,1,!0,t,a??null,s,c,D,u,v,S,t0),t.context=Fp(null),a=t.current,s=Jt(),s=Ke(s),c=xa(s),c.callback=null,ga(a,c,s),a=s,t.current.lanes=a,La(t,a),Cn(t),e[lt]=t.current,gu(e),new Ur(t)},ai.version="19.2.0",ai}var d0;function sb(){if(d0)return Uu.exports;d0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(l){console.error(l)}}return n(),Uu.exports=lb(),Uu.exports}var ib=sb();var m0="popstate";function rb(n={}){function l(o,f){let{pathname:d,search:x,hash:h}=o.location;return pf("",{pathname:d,search:x,hash:h},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:pi(f)}return cb(l,i,null,n)}function ot(n,l){if(n===!1||n===null||typeof n>"u")throw new Error(l)}function Sn(n,l){if(!n){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function ob(){return Math.random().toString(36).substring(2,10)}function h0(n,l){return{usr:n.state,key:n.key,idx:l}}function pf(n,l,i=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof l=="string"?is(l):l,state:i,key:l&&l.key||o||ob()}}function pi({pathname:n="/",search:l="",hash:i=""}){return l&&l!=="?"&&(n+=l.charAt(0)==="?"?l:"?"+l),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function is(n){let l={};if(n){let i=n.indexOf("#");i>=0&&(l.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(l.search=n.substring(o),n=n.substring(0,o)),n&&(l.pathname=n)}return l}function cb(n,l,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,x=f.history,h="POP",p=null,g=y();g==null&&(g=0,x.replaceState({...x.state,idx:g},""));function y(){return(x.state||{idx:null}).idx}function b(){h="POP";let j=y(),w=j==null?null:j-g;g=j,p&&p({action:h,location:q.location,delta:w})}function A(j,w){h="PUSH";let E=pf(q.location,j,w);g=y()+1;let C=h0(E,g),M=q.createHref(E);try{x.pushState(C,"",M)}catch(U){if(U instanceof DOMException&&U.name==="DataCloneError")throw U;f.location.assign(M)}d&&p&&p({action:h,location:q.location,delta:1})}function R(j,w){h="REPLACE";let E=pf(q.location,j,w);g=y();let C=h0(E,g),M=q.createHref(E);x.replaceState(C,"",M),d&&p&&p({action:h,location:q.location,delta:0})}function N(j){return ub(j)}let q={get action(){return h},get location(){return n(f,x)},listen(j){if(p)throw new Error("A history only accepts one active listener");return f.addEventListener(m0,b),p=j,()=>{f.removeEventListener(m0,b),p=null}},createHref(j){return l(f,j)},createURL:N,encodeLocation(j){let w=N(j);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:A,replace:R,go(j){return x.go(j)}};return q}function ub(n,l=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),ot(i,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:pi(n);return o=o.replace(/ $/,"%20"),!l&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function mx(n,l,i="/"){return fb(n,l,i,!1)}function fb(n,l,i,o){let f=typeof l=="string"?is(l):l,d=ia(f.pathname||"/",i);if(d==null)return null;let x=hx(n);db(x);let h=null;for(let p=0;h==null&&p<x.length;++p){let g=jb(d);h=Sb(x[p],g,o)}return h}function hx(n,l=[],i=[],o="",f=!1){let d=(x,h,p=f,g)=>{let y={relativePath:g===void 0?x.path||"":g,caseSensitive:x.caseSensitive===!0,childrenIndex:h,route:x};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;ot(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=sa([o,y.relativePath]),A=i.concat(y);x.children&&x.children.length>0&&(ot(x.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),hx(x.children,l,A,b,p)),!(x.path==null&&!x.index)&&l.push({path:b,score:yb(b,x.index),routesMeta:A})};return n.forEach((x,h)=>{if(x.path===""||!x.path?.includes("?"))d(x,h);else for(let p of px(x.path))d(x,h,!0,p)}),l}function px(n){let l=n.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 x=px(o.join("/")),h=[];return h.push(...x.map(p=>p===""?d:[d,p].join("/"))),f&&h.push(...x),h.map(p=>n.startsWith("/")&&p===""?"/":p)}function db(n){n.sort((l,i)=>l.score!==i.score?i.score-l.score:bb(l.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var mb=/^:[\w-]+$/,hb=3,pb=2,xb=1,gb=10,vb=-2,p0=n=>n==="*";function yb(n,l){let i=n.split("/"),o=i.length;return i.some(p0)&&(o+=vb),l&&(o+=pb),i.filter(f=>!p0(f)).reduce((f,d)=>f+(mb.test(d)?hb:d===""?xb:gb),o)}function bb(n,l){return n.length===l.length&&n.slice(0,-1).every((o,f)=>o===l[f])?n[n.length-1]-l[l.length-1]:0}function Sb(n,l,i=!1){let{routesMeta:o}=n,f={},d="/",x=[];for(let h=0;h<o.length;++h){let p=o[h],g=h===o.length-1,y=d==="/"?l:l.slice(d.length)||"/",b=lo({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},y),A=p.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=lo({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!b)return null;Object.assign(f,b.params),x.push({params:f,pathname:sa([d,b.pathname]),pathnameBase:kb(sa([d,b.pathnameBase])),route:A}),b.pathnameBase!=="/"&&(d=sa([d,b.pathnameBase]))}return x}function lo(n,l){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=Ab(n.path,n.caseSensitive,n.end),f=l.match(i);if(!f)return null;let d=f[0],x=d.replace(/(.)\/+$/,"$1"),h=f.slice(1);return{params:o.reduce((g,{paramName:y,isOptional:b},A)=>{if(y==="*"){let N=h[A]||"";x=d.slice(0,d.length-N.length).replace(/(.)\/+$/,"$1")}const R=h[A];return b&&!R?g[y]=void 0:g[y]=(R||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:x,pattern:n}}function Ab(n,l=!1,i=!0){Sn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],f="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(x,h,p)=>(o.push({paramName:h,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),f+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":n!==""&&n!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,l?void 0:"i"),o]}function jb(n){try{return n.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return Sn(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),n}}function ia(n,l){if(l==="/")return n;if(!n.toLowerCase().startsWith(l.toLowerCase()))return null;let i=l.endsWith("/")?l.length-1:l.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}var Nb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wb=n=>Nb.test(n);function Cb(n,l="/"){let{pathname:i,search:o="",hash:f=""}=typeof n=="string"?is(n):n,d;if(i)if(wb(i))d=i;else{if(i.includes("//")){let x=i;i=i.replace(/\/\/+/g,"/"),Sn(!1,`Pathnames cannot have embedded double slashes - normalizing ${x} -> ${i}`)}i.startsWith("/")?d=x0(i.substring(1),"/"):d=x0(i,l)}else d=l;return{pathname:d,search:Mb(o),hash:qb(f)}}function x0(n,l){let i=l.replace(/\/+$/,"").split("/");return n.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Gu(n,l,i,o){return`Cannot include a '${n}' 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 Eb(n){return n.filter((l,i)=>i===0||l.route.path&&l.route.path.length>0)}function xx(n){let l=Eb(n);return l.map((i,o)=>o===l.length-1?i.pathname:i.pathnameBase)}function gx(n,l,i,o=!1){let f;typeof n=="string"?f=is(n):(f={...n},ot(!f.pathname||!f.pathname.includes("?"),Gu("?","pathname","search",f)),ot(!f.pathname||!f.pathname.includes("#"),Gu("#","pathname","hash",f)),ot(!f.search||!f.search.includes("#"),Gu("#","search","hash",f)));let d=n===""||f.pathname==="",x=d?"/":f.pathname,h;if(x==null)h=i;else{let b=l.length-1;if(!o&&x.startsWith("..")){let A=x.split("/");for(;A[0]==="..";)A.shift(),b-=1;f.pathname=A.join("/")}h=b>=0?l[b]:"/"}let p=Cb(f,h),g=x&&x!=="/"&&x.endsWith("/"),y=(d||x===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(g||y)&&(p.pathname+="/"),p}var sa=n=>n.join("/").replace(/\/\/+/g,"/"),kb=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Mb=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,qb=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Rb(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var vx=["POST","PUT","PATCH","DELETE"];new Set(vx);var Tb=["GET",...vx];new Set(Tb);var rs=m.createContext(null);rs.displayName="DataRouter";var po=m.createContext(null);po.displayName="DataRouterState";m.createContext(!1);var yx=m.createContext({isTransitioning:!1});yx.displayName="ViewTransition";var Db=m.createContext(new Map);Db.displayName="Fetchers";var _b=m.createContext(null);_b.displayName="Await";var qn=m.createContext(null);qn.displayName="Navigation";var Ni=m.createContext(null);Ni.displayName="Location";var oa=m.createContext({outlet:null,matches:[],isDataRoute:!1});oa.displayName="Route";var Df=m.createContext(null);Df.displayName="RouteError";function Ob(n,{relative:l}={}){ot(wi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(qn),{hash:f,pathname:d,search:x}=Ci(n,{relative:l}),h=d;return i!=="/"&&(h=d==="/"?i:sa([i,d])),o.createHref({pathname:h,search:x,hash:f})}function wi(){return m.useContext(Ni)!=null}function ol(){return ot(wi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ni).location}var bx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Sx(n){m.useContext(qn).static||m.useLayoutEffect(n)}function Bb(){let{isDataRoute:n}=m.useContext(oa);return n?Zb():Lb()}function Lb(){ot(wi(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(rs),{basename:l,navigator:i}=m.useContext(qn),{matches:o}=m.useContext(oa),{pathname:f}=ol(),d=JSON.stringify(xx(o)),x=m.useRef(!1);return Sx(()=>{x.current=!0}),m.useCallback((p,g={})=>{if(Sn(x.current,bx),!x.current)return;if(typeof p=="number"){i.go(p);return}let y=gx(p,JSON.parse(d),f,g.relative==="path");n==null&&l!=="/"&&(y.pathname=y.pathname==="/"?l:sa([l,y.pathname])),(g.replace?i.replace:i.push)(y,g.state,g)},[l,i,d,f,n])}m.createContext(null);function Ci(n,{relative:l}={}){let{matches:i}=m.useContext(oa),{pathname:o}=ol(),f=JSON.stringify(xx(i));return m.useMemo(()=>gx(n,JSON.parse(f),o,l==="path"),[n,f,o,l])}function zb(n,l){return Ax(n,l)}function Ax(n,l,i,o,f){ot(wi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(qn),{matches:x}=m.useContext(oa),h=x[x.length-1],p=h?h.params:{},g=h?h.pathname:"/",y=h?h.pathnameBase:"/",b=h&&h.route;{let E=b&&b.path||"";jx(g,!b||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${E}">) 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="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let A=ol(),R;if(l){let E=typeof l=="string"?is(l):l;ot(y==="/"||E.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 "${E.pathname}" was given in the \`location\` prop.`),R=E}else R=A;let N=R.pathname||"/",q=N;if(y!=="/"){let E=y.replace(/^\//,"").split("/");q="/"+N.replace(/^\//,"").split("/").slice(E.length).join("/")}let j=mx(n,{pathname:q});Sn(b||j!=null,`No routes matched location "${R.pathname}${R.search}${R.hash}" `),Sn(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${R.pathname}${R.search}${R.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 w=Gb(j&&j.map(E=>Object.assign({},E,{params:Object.assign({},p,E.params),pathname:sa([y,d.encodeLocation?d.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?y:sa([y,d.encodeLocation?d.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),x,i,o,f);return l&&w?m.createElement(Ni.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...R},navigationType:"POP"}},w):w}function Ub(){let n=Kb(),l=Rb(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},x=null;return console.error("Error handled by React Router default ErrorBoundary:",n),x=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,x)}var Hb=m.createElement(Ub,null),Vb=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,l){return l.location!==n.location||l.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:l.error,location:l.location,revalidation:n.revalidation||l.revalidation}}componentDidCatch(n,l){this.props.onError?this.props.onError(n,l):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(oa.Provider,{value:this.props.routeContext},m.createElement(Df.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function $b({routeContext:n,match:l,children:i}){let o=m.useContext(rs);return o&&o.static&&o.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=l.route.id),m.createElement(oa.Provider,{value:n},i)}function Gb(n,l=[],i=null,o=null,f=null){if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(l.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let d=n,x=i?.errors;if(x!=null){let y=d.findIndex(b=>b.route.id&&x?.[b.route.id]!==void 0);ot(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(x).join(",")}`),d=d.slice(0,Math.min(d.length,y+1))}let h=!1,p=-1;if(i)for(let y=0;y<d.length;y++){let b=d[y];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(p=y),b.route.id){let{loaderData:A,errors:R}=i,N=b.route.loader&&!A.hasOwnProperty(b.route.id)&&(!R||R[b.route.id]===void 0);if(b.route.lazy||N){h=!0,p>=0?d=d.slice(0,p+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,A)=>{let R,N=!1,q=null,j=null;i&&(R=x&&b.route.id?x[b.route.id]:void 0,q=b.route.errorElement||Hb,h&&(p<0&&A===0?(jx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,j=null):p===A&&(N=!0,j=b.route.hydrateFallbackElement||null)));let w=l.concat(d.slice(0,A+1)),E=()=>{let C;return R?C=q:N?C=j:b.route.Component?C=m.createElement(b.route.Component,null):b.route.element?C=b.route.element:C=y,m.createElement($b,{match:b,routeContext:{outlet:y,matches:w,isDataRoute:i!=null},children:C})};return i&&(b.route.ErrorBoundary||b.route.errorElement||A===0)?m.createElement(Vb,{location:i.location,revalidation:i.revalidation,component:q,error:R,children:E(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:g}):E()},null)}function _f(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yb(n){let l=m.useContext(rs);return ot(l,_f(n)),l}function Fb(n){let l=m.useContext(po);return ot(l,_f(n)),l}function Xb(n){let l=m.useContext(oa);return ot(l,_f(n)),l}function Of(n){let l=Xb(n),i=l.matches[l.matches.length-1];return ot(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function Qb(){return Of("useRouteId")}function Kb(){let n=m.useContext(Df),l=Fb("useRouteError"),i=Of("useRouteError");return n!==void 0?n:l.errors?.[i]}function Zb(){let{router:n}=Yb("useNavigate"),l=Of("useNavigate"),i=m.useRef(!1);return Sx(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{Sn(i.current,bx),i.current&&(typeof f=="number"?n.navigate(f):await n.navigate(f,{fromRouteId:l,...d}))},[n,l])}var g0={};function jx(n,l,i){!l&&!g0[n]&&(g0[n]=!0,Sn(!1,i))}m.memo(Ib);function Ib({routes:n,future:l,state:i,unstable_onError:o}){return Ax(n,void 0,i,o,l)}function Qr(n){ot(!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 Jb({basename:n="/",children:l=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){ot(!wi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let x=n.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:x,navigator:f,static:d,future:{}}),[x,f,d]);typeof i=="string"&&(i=is(i));let{pathname:p="/",search:g="",hash:y="",state:b=null,key:A="default"}=i,R=m.useMemo(()=>{let N=ia(p,x);return N==null?null:{location:{pathname:N,search:g,hash:y,state:b,key:A},navigationType:o}},[x,p,g,y,b,A,o]);return Sn(R!=null,`<Router basename="${x}"> is not able to match the URL "${p}${g}${y}" because it does not start with the basename, so the <Router> won't render anything.`),R==null?null:m.createElement(qn.Provider,{value:h},m.createElement(Ni.Provider,{children:l,value:R}))}function Pb({children:n,location:l}){return zb(xf(n),l)}function xf(n,l=[]){let i=[];return m.Children.forEach(n,(o,f)=>{if(!m.isValidElement(o))return;let d=[...l,f];if(o.type===m.Fragment){i.push.apply(i,xf(o.props.children,d));return}ot(o.type===Qr,`[${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>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let x={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&&(x.children=xf(o.props.children,d)),i.push(x)}),i}var Kr="get",Zr="application/x-www-form-urlencoded";function xo(n){return n!=null&&typeof n.tagName=="string"}function Wb(n){return xo(n)&&n.tagName.toLowerCase()==="button"}function e1(n){return xo(n)&&n.tagName.toLowerCase()==="form"}function t1(n){return xo(n)&&n.tagName.toLowerCase()==="input"}function n1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function a1(n,l){return n.button===0&&(!l||l==="_self")&&!n1(n)}var Vr=null;function l1(){if(Vr===null)try{new FormData(document.createElement("form"),0),Vr=!1}catch{Vr=!0}return Vr}var s1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Yu(n){return n!=null&&!s1.has(n)?(Sn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zr}"`),null):n}function i1(n,l){let i,o,f,d,x;if(e1(n)){let h=n.getAttribute("action");o=h?ia(h,l):null,i=n.getAttribute("method")||Kr,f=Yu(n.getAttribute("enctype"))||Zr,d=new FormData(n)}else if(Wb(n)||t1(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=n.getAttribute("formaction")||h.getAttribute("action");if(o=p?ia(p,l):null,i=n.getAttribute("formmethod")||h.getAttribute("method")||Kr,f=Yu(n.getAttribute("formenctype"))||Yu(h.getAttribute("enctype"))||Zr,d=new FormData(h,n),!l1()){let{name:g,type:y,value:b}=n;if(y==="image"){let A=g?`${g}.`:"";d.append(`${A}x`,"0"),d.append(`${A}y`,"0")}else g&&d.append(g,b)}}else{if(xo(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Kr,o=null,f=Zr,x=n}return d&&f==="text/plain"&&(x=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:x}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Bf(n,l){if(n===!1||n===null||typeof n>"u")throw new Error(l)}function r1(n,l,i){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${i}`:l&&ia(o.pathname,l)==="/"?o.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function o1(n,l){if(n.id in l)return l[n.id];try{let i=await import(n.module);return l[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function c1(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function u1(n,l,i){let o=await Promise.all(n.map(async f=>{let d=l.routes[f.route.id];if(d){let x=await o1(d,i);return x.links?x.links():[]}return[]}));return h1(o.flat(1).filter(c1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function v0(n,l,i,o,f,d){let x=(p,g)=>i[g]?p.route.id!==i[g].route.id:!0,h=(p,g)=>i[g].pathname!==p.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==p.params["*"];return d==="assets"?l.filter((p,g)=>x(p,g)||h(p,g)):d==="data"?l.filter((p,g)=>{let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(x(p,g)||h(p,g))return!0;if(p.route.shouldRevalidate){let b=p.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function f1(n,l,{includeHydrateFallback:i}={}){return d1(n.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 d1(n){return[...new Set(n)]}function m1(n){let l={},i=Object.keys(n).sort();for(let o of i)l[o]=n[o];return l}function h1(n,l){let i=new Set;return new Set(l),n.reduce((o,f)=>{let d=JSON.stringify(m1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function Nx(){let n=m.useContext(rs);return Bf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function p1(){let n=m.useContext(po);return Bf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Lf=m.createContext(void 0);Lf.displayName="FrameworkContext";function wx(){let n=m.useContext(Lf);return Bf(n,"You must render this element inside a <HydratedRouter> element"),n}function x1(n,l){let i=m.useContext(Lf),[o,f]=m.useState(!1),[d,x]=m.useState(!1),{onFocus:h,onBlur:p,onMouseEnter:g,onMouseLeave:y,onTouchStart:b}=l,A=m.useRef(null);m.useEffect(()=>{if(n==="render"&&x(!0),n==="viewport"){let q=w=>{w.forEach(E=>{x(E.isIntersecting)})},j=new IntersectionObserver(q,{threshold:.5});return A.current&&j.observe(A.current),()=>{j.disconnect()}}},[n]),m.useEffect(()=>{if(o){let q=setTimeout(()=>{x(!0)},100);return()=>{clearTimeout(q)}}},[o]);let R=()=>{f(!0)},N=()=>{f(!1),x(!1)};return i?n!=="intent"?[d,A,{}]:[d,A,{onFocus:li(h,R),onBlur:li(p,N),onMouseEnter:li(g,R),onMouseLeave:li(y,N),onTouchStart:li(b,R)}]:[!1,A,{}]}function li(n,l){return i=>{n&&n(i),i.defaultPrevented||l(i)}}function g1({page:n,...l}){let{router:i}=Nx(),o=m.useMemo(()=>mx(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?m.createElement(y1,{page:n,matches:o,...l}):null}function v1(n){let{manifest:l,routeModules:i}=wx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return u1(n,l,i).then(x=>{d||f(x)}),()=>{d=!0}},[n,l,i]),o}function y1({page:n,matches:l,...i}){let o=ol(),{manifest:f,routeModules:d}=wx(),{basename:x}=Nx(),{loaderData:h,matches:p}=p1(),g=m.useMemo(()=>v0(n,l,p,f,o,"data"),[n,l,p,f,o]),y=m.useMemo(()=>v0(n,l,p,f,o,"assets"),[n,l,p,f,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let N=new Set,q=!1;if(l.forEach(w=>{let E=f.routes[w.route.id];!E||!E.hasLoader||(!g.some(C=>C.route.id===w.route.id)&&w.route.id in h&&d[w.route.id]?.shouldRevalidate||E.hasClientLoader?q=!0:N.add(w.route.id))}),N.size===0)return[];let j=r1(n,x,"data");return q&&N.size>0&&j.searchParams.set("_routes",l.filter(w=>N.has(w.route.id)).map(w=>w.route.id).join(",")),[j.pathname+j.search]},[x,h,o,f,g,l,n,d]),A=m.useMemo(()=>f1(y,f),[y,f]),R=v1(y);return m.createElement(m.Fragment,null,b.map(N=>m.createElement("link",{key:N,rel:"prefetch",as:"fetch",href:N,...i})),A.map(N=>m.createElement("link",{key:N,rel:"modulepreload",href:N,...i})),R.map(({key:N,link:q})=>m.createElement("link",{key:N,nonce:i.nonce,...q})))}function b1(...n){return l=>{n.forEach(i=>{typeof i=="function"?i(l):i!=null&&(i.current=l)})}}var Cx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Cx&&(window.__reactRouterVersion="7.9.6")}catch{}function S1({basename:n,children:l,window:i}){let o=m.useRef();o.current==null&&(o.current=rb({window:i,v5Compat:!0}));let f=o.current,[d,x]=m.useState({action:f.action,location:f.location}),h=m.useCallback(p=>{m.startTransition(()=>x(p))},[x]);return m.useLayoutEffect(()=>f.listen(h),[f,h]),m.createElement(Jb,{basename:n,children:l,location:d.location,navigationType:d.action,navigator:f})}var Ex=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kx=m.forwardRef(function({onClick:l,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:x,state:h,target:p,to:g,preventScrollReset:y,viewTransition:b,...A},R){let{basename:N}=m.useContext(qn),q=typeof g=="string"&&Ex.test(g),j,w=!1;if(typeof g=="string"&&q&&(j=g,Cx))try{let B=new URL(window.location.href),z=g.startsWith("//")?new URL(B.protocol+g):new URL(g),Y=ia(z.pathname,N);z.origin===B.origin&&Y!=null?g=Y+z.search+z.hash:w=!0}catch{Sn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Ob(g,{relative:f}),[C,M,U]=x1(o,A),X=w1(g,{replace:x,state:h,target:p,preventScrollReset:y,relative:f,viewTransition:b});function _(B){l&&l(B),B.defaultPrevented||X(B)}let K=m.createElement("a",{...A,...U,href:j||E,onClick:w||d?l:_,ref:b1(R,M),target:p,"data-discover":!q&&i==="render"?"true":void 0});return C&&!q?m.createElement(m.Fragment,null,K,m.createElement(g1,{page:E})):K});kx.displayName="Link";var A1=m.forwardRef(function({"aria-current":l="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:x,viewTransition:h,children:p,...g},y){let b=Ci(x,{relative:g.relative}),A=ol(),R=m.useContext(po),{navigator:N,basename:q}=m.useContext(qn),j=R!=null&&q1(b)&&h===!0,w=N.encodeLocation?N.encodeLocation(b).pathname:b.pathname,E=A.pathname,C=R&&R.navigation&&R.navigation.location?R.navigation.location.pathname:null;i||(E=E.toLowerCase(),C=C?C.toLowerCase():null,w=w.toLowerCase()),C&&q&&(C=ia(C,q)||C);const M=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let U=E===w||!f&&E.startsWith(w)&&E.charAt(M)==="/",X=C!=null&&(C===w||!f&&C.startsWith(w)&&C.charAt(w.length)==="/"),_={isActive:U,isPending:X,isTransitioning:j},K=U?l:void 0,B;typeof o=="function"?B=o(_):B=[o,U?"active":null,X?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let z=typeof d=="function"?d(_):d;return m.createElement(kx,{...g,"aria-current":K,className:B,ref:y,style:z,to:x,viewTransition:h},typeof p=="function"?p(_):p)});A1.displayName="NavLink";var j1=m.forwardRef(({discover:n="render",fetcherKey:l,navigate:i,reloadDocument:o,replace:f,state:d,method:x=Kr,action:h,onSubmit:p,relative:g,preventScrollReset:y,viewTransition:b,...A},R)=>{let N=k1(),q=M1(h,{relative:g}),j=x.toLowerCase()==="get"?"get":"post",w=typeof h=="string"&&Ex.test(h),E=C=>{if(p&&p(C),C.defaultPrevented)return;C.preventDefault();let M=C.nativeEvent.submitter,U=M?.getAttribute("formmethod")||x;N(M||C.currentTarget,{fetcherKey:l,method:U,navigate:i,replace:f,state:d,relative:g,preventScrollReset:y,viewTransition:b})};return m.createElement("form",{ref:R,method:j,action:q,onSubmit:o?p:E,...A,"data-discover":!w&&n==="render"?"true":void 0})});j1.displayName="Form";function N1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Mx(n){let l=m.useContext(rs);return ot(l,N1(n)),l}function w1(n,{target:l,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:x}={}){let h=Bb(),p=ol(),g=Ci(n,{relative:d});return m.useCallback(y=>{if(a1(y,l)){y.preventDefault();let b=i!==void 0?i:pi(p)===pi(g);h(n,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:x})}},[p,h,g,i,o,l,n,f,d,x])}var C1=0,E1=()=>`__${String(++C1)}__`;function k1(){let{router:n}=Mx("useSubmit"),{basename:l}=m.useContext(qn),i=Qb();return m.useCallback(async(o,f={})=>{let{action:d,method:x,encType:h,formData:p,body:g}=i1(o,l);if(f.navigate===!1){let y=f.fetcherKey||E1();await n.fetch(y,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||x,formEncType:f.encType||h,flushSync:f.flushSync})}else await n.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||x,formEncType:f.encType||h,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[n,l,i])}function M1(n,{relative:l}={}){let{basename:i}=m.useContext(qn),o=m.useContext(oa);ot(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...Ci(n||".",{relative:l})},x=ol();if(n==null){d.search=x.search;let h=new URLSearchParams(d.search),p=h.getAll("index");if(p.some(y=>y==="")){h.delete("index"),p.filter(b=>b).forEach(b=>h.append("index",b));let y=h.toString();d.search=y?`?${y}`:""}}return(!n||n===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:sa([i,d.pathname])),pi(d)}function q1(n,{relative:l}={}){let i=m.useContext(yx);ot(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Mx("useViewTransitionState"),f=Ci(n,{relative:l});if(!i.isTransitioning)return!1;let d=ia(i.currentLocation.pathname,o)||i.currentLocation.pathname,x=ia(i.nextLocation.pathname,o)||i.nextLocation.pathname;return lo(f.pathname,x)!=null||lo(f.pathname,d)!=null}const Mn=Object.create(null);Mn.open="0";Mn.close="1";Mn.ping="2";Mn.pong="3";Mn.message="4";Mn.upgrade="5";Mn.noop="6";const Ir=Object.create(null);Object.keys(Mn).forEach(n=>{Ir[Mn[n]]=n});const gf={type:"error",data:"parser error"},qx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Rx=typeof ArrayBuffer=="function",Tx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,zf=({type:n,data:l},i,o)=>qx&&l instanceof Blob?i?o(l):y0(l,o):Rx&&(l instanceof ArrayBuffer||Tx(l))?i?o(l):y0(new Blob([l]),o):o(Mn[n]+(l||"")),y0=(n,l)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];l("b"+(o||""))},i.readAsDataURL(n)};function b0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Fu;function R1(n,l){if(qx&&n.data instanceof Blob)return n.data.arrayBuffer().then(b0).then(l);if(Rx&&(n.data instanceof ArrayBuffer||Tx(n.data)))return l(b0(n.data));zf(n,!1,i=>{Fu||(Fu=new TextEncoder),l(Fu.encode(i))})}const S0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ui=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<S0.length;n++)ui[S0.charCodeAt(n)]=n;const T1=n=>{let l=n.length*.75,i=n.length,o,f=0,d,x,h,p;n[n.length-1]==="="&&(l--,n[n.length-2]==="="&&l--);const g=new ArrayBuffer(l),y=new Uint8Array(g);for(o=0;o<i;o+=4)d=ui[n.charCodeAt(o)],x=ui[n.charCodeAt(o+1)],h=ui[n.charCodeAt(o+2)],p=ui[n.charCodeAt(o+3)],y[f++]=d<<2|x>>4,y[f++]=(x&15)<<4|h>>2,y[f++]=(h&3)<<6|p&63;return g},D1=typeof ArrayBuffer=="function",Uf=(n,l)=>{if(typeof n!="string")return{type:"message",data:Dx(n,l)};const i=n.charAt(0);return i==="b"?{type:"message",data:_1(n.substring(1),l)}:Ir[i]?n.length>1?{type:Ir[i],data:n.substring(1)}:{type:Ir[i]}:gf},_1=(n,l)=>{if(D1){const i=T1(n);return Dx(i,l)}else return{base64:!0,data:n}},Dx=(n,l)=>{switch(l){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},_x="",O1=(n,l)=>{const i=n.length,o=new Array(i);let f=0;n.forEach((d,x)=>{zf(d,!1,h=>{o[x]=h,++f===i&&l(o.join(_x))})})},B1=(n,l)=>{const i=n.split(_x),o=[];for(let f=0;f<i.length;f++){const d=Uf(i[f],l);if(o.push(d),d.type==="error")break}return o};function L1(){return new TransformStream({transform(n,l){R1(n,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))}n.data&&typeof n.data!="string"&&(f[0]|=128),l.enqueue(f),l.enqueue(i)})}})}let Xu;function $r(n){return n.reduce((l,i)=>l+i.length,0)}function Gr(n,l){if(n[0].length===l)return n.shift();const i=new Uint8Array(l);let o=0;for(let f=0;f<l;f++)i[f]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),i}function z1(n,l){Xu||(Xu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(x,h){for(i.push(x);;){if(o===0){if($r(i)<1)break;const p=Gr(i,1);d=(p[0]&128)===128,f=p[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if($r(i)<2)break;const p=Gr(i,2);f=new DataView(p.buffer,p.byteOffset,p.length).getUint16(0),o=3}else if(o===2){if($r(i)<8)break;const p=Gr(i,8),g=new DataView(p.buffer,p.byteOffset,p.length),y=g.getUint32(0);if(y>Math.pow(2,21)-1){h.enqueue(gf);break}f=y*Math.pow(2,32)+g.getUint32(4),o=3}else{if($r(i)<f)break;const p=Gr(i,f);h.enqueue(Uf(d?p:Xu.decode(p),l)),o=0}if(f===0||f>n){h.enqueue(gf);break}}}})}const Ox=4;function St(n){if(n)return U1(n)}function U1(n){for(var l in St.prototype)n[l]=St.prototype[l];return n}St.prototype.on=St.prototype.addEventListener=function(n,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(l),this};St.prototype.once=function(n,l){function i(){this.off(n,i),l.apply(this,arguments)}return i.fn=l,this.on(n,i),this};St.prototype.off=St.prototype.removeListener=St.prototype.removeAllListeners=St.prototype.removeEventListener=function(n,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],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["$"+n],this};St.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),i=this._callbacks["$"+n],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};St.prototype.emitReserved=St.prototype.emit;St.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};St.prototype.hasListeners=function(n){return!!this.listeners(n).length};const go=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,i)=>i(l,0),hn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),H1="arraybuffer";function Bx(n,...l){return l.reduce((i,o)=>(n.hasOwnProperty(o)&&(i[o]=n[o]),i),{})}const V1=hn.setTimeout,$1=hn.clearTimeout;function vo(n,l){l.useNativeTimers?(n.setTimeoutFn=V1.bind(hn),n.clearTimeoutFn=$1.bind(hn)):(n.setTimeoutFn=hn.setTimeout.bind(hn),n.clearTimeoutFn=hn.clearTimeout.bind(hn))}const G1=1.33;function Y1(n){return typeof n=="string"?F1(n):Math.ceil((n.byteLength||n.size)*G1)}function F1(n){let l=0,i=0;for(let o=0,f=n.length;o<f;o++)l=n.charCodeAt(o),l<128?i+=1:l<2048?i+=2:l<55296||l>=57344?i+=3:(o++,i+=4);return i}function Lx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function X1(n){let l="";for(let i in n)n.hasOwnProperty(i)&&(l.length&&(l+="&"),l+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return l}function Q1(n){let l={},i=n.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 K1 extends Error{constructor(l,i,o){super(l),this.description=i,this.context=o,this.type="TransportError"}}class Hf extends St{constructor(l){super(),this.writable=!1,vo(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 K1(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=Uf(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=X1(l);return i.length?"?"+i:""}}class Z1 extends Hf{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)};B1(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,O1(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]=Lx()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(l,i)}}let zx=!1;try{zx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const I1=zx;function J1(){}class P1 extends Z1{constructor(l){if(super(l),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||o!==l.port}}doWrite(l,i){const o=this.request({method:"POST",data:l});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=l}}class kn extends St{constructor(l,i,o){super(),this.createRequest=l,vo(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=Bx(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=kn.requestsCount++,kn.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=J1,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete kn.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()}}kn.requestsCount=0;kn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",A0);else if(typeof addEventListener=="function"){const n="onpagehide"in hn?"pagehide":"unload";addEventListener(n,A0,!1)}}function A0(){for(let n in kn.requests)kn.requests.hasOwnProperty(n)&&kn.requests[n].abort()}const W1=(function(){const n=Ux({xdomain:!1});return n&&n.responseType!==null})();class eS extends P1{constructor(l){super(l);const i=l&&l.forceBase64;this.supportsBinary=W1&&!i}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new kn(Ux,this.uri(),l)}}function Ux(n){const l=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||I1))return new XMLHttpRequest}catch{}if(!l)try{return new hn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Hx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tS extends Hf{get name(){return"websocket"}doOpen(){const l=this.uri(),i=this.opts.protocols,o=Hx?{}:Bx(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;zf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&go(()=>{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]=Lx()),this.supportsBinary||(i.b64=1),this.createUri(l,i)}}const Qu=hn.WebSocket||hn.MozWebSocket;class nS extends tS{createSocket(l,i,o){return Hx?new Qu(l,i,o):i?new Qu(l,i):new Qu(l)}doWrite(l,i){this.ws.send(i)}}class aS extends Hf{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=z1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=l.readable.pipeThrough(i).getReader(),f=L1();f.readable.pipeTo(l.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:h,value:p})=>{h||(this.onPacket(p),d())}).catch(h=>{})};d();const x={type:"open"};this.query.sid&&(x.data=`{"sid":"${this.query.sid}"}`),this._writer.write(x).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&&go(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const lS={websocket:nS,webtransport:aS,polling:eS},sS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,iS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function vf(n){if(n.length>8e3)throw"URI too long";const l=n,i=n.indexOf("["),o=n.indexOf("]");i!=-1&&o!=-1&&(n=n.substring(0,i)+n.substring(i,o).replace(/:/g,";")+n.substring(o,n.length));let f=sS.exec(n||""),d={},x=14;for(;x--;)d[iS[x]]=f[x]||"";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=rS(d,d.path),d.queryKey=oS(d,d.query),d}function rS(n,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 oS(n,l){const i={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const yf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Jr=[];yf&&addEventListener("offline",()=>{Jr.forEach(n=>n())},!1);class _a extends St{constructor(l,i){if(super(),this.binaryType=H1,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=vf(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=vf(i.host).host);vo(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=Q1(this.opts.query)),yf&&(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"})},Jr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const i=Object.assign({},this.opts.query);i.EIO=Ox,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&&_a.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",_a.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+=Y1(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,go(()=>{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(_a.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(),yf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Jr.indexOf(this._offlineEventListener);o!==-1&&Jr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,i),this.writeBuffer=[],this._prevBufferLen=0}}}_a.protocol=Ox;class cS extends _a{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;_a.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;_a.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 A=new Error("probe error");A.transport=i.name,this.emitReserved("upgradeError",A)}}))};function d(){o||(o=!0,y(),i.close(),i=null)}const x=b=>{const A=new Error("probe error: "+b);A.transport=i.name,d(),this.emitReserved("upgradeError",A)};function h(){x("transport closed")}function p(){x("socket closed")}function g(b){i&&b.name!==i.name&&d()}const y=()=>{i.removeListener("open",f),i.removeListener("error",x),i.removeListener("close",h),this.off("close",p),this.off("upgrading",g)};i.once("open",f),i.once("error",x),i.once("close",h),this.once("close",p),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 uS=class extends cS{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=>lS[f]).filter(f=>!!f)),super(l,o)}};function fS(n,l="",i){let o=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),o=vf(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const 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 dS=typeof ArrayBuffer=="function",mS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Vx=Object.prototype.toString,hS=typeof Blob=="function"||typeof Blob<"u"&&Vx.call(Blob)==="[object BlobConstructor]",pS=typeof File=="function"||typeof File<"u"&&Vx.call(File)==="[object FileConstructor]";function Vf(n){return dS&&(n instanceof ArrayBuffer||mS(n))||hS&&n instanceof Blob||pS&&n instanceof File}function Pr(n,l){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,o=n.length;i<o;i++)if(Pr(n[i]))return!0;return!1}if(Vf(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Pr(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&Pr(n[i]))return!0;return!1}function xS(n){const l=[],i=n.data,o=n;return o.data=bf(i,l),o.attachments=l.length,{packet:o,buffers:l}}function bf(n,l){if(!n)return n;if(Vf(n)){const i={_placeholder:!0,num:l.length};return l.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]=bf(n[o],l);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=bf(n[o],l));return i}return n}function gS(n,l){return n.data=Sf(n.data,l),delete n.attachments,n}function Sf(n,l){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<l.length)return l[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let i=0;i<n.length;i++)n[i]=Sf(n[i],l);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=Sf(n[i],l));return n}const vS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],yS=5;var Be;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class bS{constructor(l){this.replacer=l}encode(l){return(l.type===Be.EVENT||l.type===Be.ACK)&&Pr(l)?this.encodeAsBinary({type:l.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let i=""+l.type;return(l.type===Be.BINARY_EVENT||l.type===Be.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=xS(l),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function j0(n){return Object.prototype.toString.call(n)==="[object Object]"}class $f extends St{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===Be.BINARY_EVENT;o||i.type===Be.BINARY_ACK?(i.type=o?Be.EVENT:Be.ACK,this.reconstructor=new SS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Vf(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(Be[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Be.BINARY_EVENT||o.type===Be.BINARY_ACK){const d=i+1;for(;l.charAt(++i)!=="-"&&i!=l.length;);const x=l.substring(d,i);if(x!=Number(x)||l.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(x)}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 x=l.charAt(i);if(x==null||Number(x)!=x){--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($f.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 Be.CONNECT:return j0(i);case Be.DISCONNECT:return i===void 0;case Be.CONNECT_ERROR:return typeof i=="string"||j0(i);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&vS.indexOf(i[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class SS{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=gS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const AS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$f,Encoder:bS,get PacketType(){return Be},protocol:yS},Symbol.toStringTag,{value:"Module"}));function yn(n,l,i){return n.on(l,i),function(){n.off(l,i)}}const jS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class $x extends St{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=[yn(l,"open",this.onopen.bind(this)),yn(l,"packet",this.onpacket.bind(this)),yn(l,"error",this.onerror.bind(this)),yn(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(jS.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 x={type:Be.EVENT,data:i};if(x.options={},x.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const y=this.ids++,b=i.pop();this._registerAckCallback(y,b),x.id=y}const h=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,p=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!h||(p?(this.notifyOutgoingListeners(x),this.packet(x)):this.sendBuffer.push(x)),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 h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===l&&this.sendBuffer.splice(h,1);i.call(this,new Error("operation has timed out"))},f),x=(...h)=>{this.io.clearTimeoutFn(d),i.apply(this,h)};x.withError=!0,this.acks[l]=x}emitWithAck(l,...i){return new Promise((o,f)=>{const d=(x,h)=>x?f(x):o(h);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:Be.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 Be.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 Be.EVENT:case Be.BINARY_EVENT:this.onevent(l);break;case Be.ACK:case Be.BINARY_ACK:this.onack(l);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.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:Be.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:Be.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 os(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}os.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),i=Math.floor(l*this.jitter*n);n=(Math.floor(l*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};os.prototype.reset=function(){this.attempts=0};os.prototype.setMin=function(n){this.ms=n};os.prototype.setMax=function(n){this.max=n};os.prototype.setJitter=function(n){this.jitter=n};class Af extends St{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,vo(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 os({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||AS;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 uS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=yn(i,"open",function(){o.onopen(),l&&l()}),d=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),l?l(h):this.maybeReconnectOnOpen()},x=yn(i,"error",d);if(this._timeout!==!1){const h=this._timeout,p=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},h);this.opts.autoUnref&&p.unref(),this.subs.push(()=>{this.clearTimeoutFn(p)})}return this.subs.push(f),this.subs.push(x),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(yn(l,"ping",this.onping.bind(this)),yn(l,"data",this.ondata.bind(this)),yn(l,"error",this.onerror.bind(this)),yn(l,"close",this.onclose.bind(this)),yn(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){go(()=>{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 $x(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 si={};function Wr(n,l){typeof n=="object"&&(l=n,n=void 0),l=l||{};const i=fS(n,l.path||"/socket.io"),o=i.source,f=i.id,d=i.path,x=si[f]&&d in si[f].nsps,h=l.forceNew||l["force new connection"]||l.multiplex===!1||x;let p;return h?p=new Af(o,l):(si[f]||(si[f]=new Af(o,l)),p=si[f]),i.query&&!l.query&&(l.query=i.queryKey),p.socket(i.path,l)}Object.assign(Wr,{Manager:Af,Socket:$x,io:Wr,connect:Wr});const Gx="roverSettings",NS=3600*24*365;function wS(n){try{const l=decodeURIComponent(n??"");return JSON.parse(l)}catch(l){return console.warn("Failed to parse settings cookie",l),null}}function jf(){if(typeof document>"u")return{};const n=`${Gx}=`,l=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!l)return{};const i=l.substring(n.length);return wS(i)??{}}function N0(n){if(typeof document>"u")return!1;try{const l=encodeURIComponent(JSON.stringify(n??{})),i=`${Gx}=${l}; path=/; max-age=${NS}; samesite=strict`;return document.cookie=i,!0}catch(l){return console.warn("Failed to write settings cookie",l),!1}}const Yx=window.location.origin;console.info("[socket] connecting to",Yx);const CS=jf(),ES=CS?.page?.connectionTransport||"websocket",kS=ES==="polling"?["polling"]:["websocket","polling"],Gf=Wr(Yx,{transports:kS,timeout:15e3});Gf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const Fx=m.createContext(Gf),MS=({children:n})=>r.jsx(Fx.Provider,{value:Gf,children:n}),Rn=()=>m.useContext(Fx),Xx=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()=>{},requestPrivateRoverAccess:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},startMicWhip:async()=>{},readyMicWhip:async()=>{},stopMicWhip:async()=>{},setAudioLevels:async()=>{},setPrivateSafety:async()=>{},llmControl:async()=>{}});function qS(n){return m.useCallback((l,i={})=>new Promise((o,f)=>{n.emit(l,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[n])}function RS({children:n}){const l=Rn(),i=qS(l),[o,f]=m.useState(null),[d,x]=m.useState([]),[h,p]=m.useState([]),[g,y]=m.useState(null),[b,A]=m.useState(null),[R,N]=m.useState([]),[q,j]=m.useState(l.connected);m.useEffect(()=>{const C=()=>j(!0),M=()=>j(!1);return l.on("connect",C),l.on("disconnect",M),()=>{l.off("connect",C),l.off("disconnect",M)}},[l]),m.useEffect(()=>{function C(B){f(B)}function M(B=[]){x(B)}function U(B){x(z=>[...z.slice(-199),B])}function X(B=[]){p(B)}function _(B){p(z=>[...z.slice(-199),B])}function K(B=null){const z=B&&typeof B=="object"?B:null,Y=z?.debug?.status&&typeof z.debug.status=="object"?z.debug.status:null;y(z),A(Y)}return l.on("session:sync",C),l.on("log:init",M),l.on("log:entry",U),l.on("adminlog:init",X),l.on("adminlog:entry",_),l.on("llm:state",K),l.on("alert:new",(B={})=>{N(z=>[...z.slice(-49),{...B,receivedAt:Date.now()}])}),()=>{l.off("session:sync",C),l.off("log:init",M),l.off("log:entry",U),l.off("adminlog:init",X),l.off("adminlog:entry",_),l.off("llm:state",K),l.off("alert:new")}},[l]);const w=m.useMemo(()=>({login:(C,M)=>i("auth:login",{username:C,password:M}),identifySession:({cookieUserId:C,nickname:M}={})=>i("session:identify",{cookieUserId:C,nickname:M}),setRole:C=>i("session:setRole",{role:C}),requestControl:(C,M={})=>i("session:requestControl",{roverId:C,...M}),releaseControl:C=>i("session:releaseControl",{roverId:C}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(C,M)=>i("session:lockRover",{roverId:C,locked:M}),setMode:C=>i("setMode",{mode:C}),homeAssistantToggle:C=>i("homeAssistant:toggle",{entityId:C}),homeAssistantSetState:(C,M)=>i("homeAssistant:setState",{entityId:C,state:M}),homeAssistantSetLightColor:(C,M)=>i("homeAssistant:lightColor",{entityId:C,rgbColor:M}),setNickname:C=>i("nickname:set",{nickname:C}),requestVerification:()=>i("verification:request"),requestPrivateRoverAccess:C=>i("session:privateRover:requestAccess",{roverId:C}),triggerReplay:(C=[])=>i("replay:trigger",{sources:C}),setCommunityGoal:C=>i("communityGoal:set",{text:C}),setAdminReason:C=>i("adminReason:set",{text:C}),rebootRover:C=>i("command",{roverId:C,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:C,name:M,mime:U,dataBase64:X})=>i("audio:uploadPlay",{roverId:C,name:M,mime:U,dataBase64:X}),stopUploadedAudio:C=>i("audio:uploadStop",{roverId:C}),startMicWhip:C=>i("audio:micWhipStart",{roverId:C}),readyMicWhip:C=>i("audio:micWhipReady",{roverId:C}),stopMicWhip:C=>i("audio:micWhipStop",{roverId:C}),setAudioLevels:(C={})=>i("audioLevels:set",C),setPrivateSafety:(C,M={})=>i("session:privateSafety:set",{roverId:C,safety:M}),llmControl:(C,M={})=>i("llm:control",{controls:{action:C,...M}}),pushAlert:C=>N(M=>[...M.slice(-49),{...C,receivedAt:Date.now(),id:C.id||Math.random().toString(36).slice(2)}])}),[i]),E=m.useMemo(()=>({connected:q,session:o,logs:d,adminLogs:h,llmCommentaryState:g,llmCommentaryStatus:b,alerts:R,...w}),[w,h,R,q,g,b,d,o]);return r.jsx(Xx.Provider,{value:E,children:n})}function ze(){return m.useContext(Xx)}const Qx=m.createContext({frames:{}});function TS({children:n}){const l=Rn(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:x,sensors:h={},frame:p={}}){x&&o(g=>({...g,[x]:{roverId:x,sensors:h,raw:p?.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(Qx.Provider,{value:f,children:n})}function Yf(){return m.useContext(Qx).frames}function cs(n){const l=Yf();return n?l[n]??null:null}const DS=650,_S={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 Ku(n){if(typeof n!="number"||n<=0)return null;const l=_S[n];return l?{code:n,...l}:null}function OS(n,l={}){const i=l.holdMs||DS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,x]=m.useState(0);return m.useEffect(()=>{const h=setInterval(()=>x(Date.now()),Math.max(i/2,100));return()=>clearInterval(h)},[i]),m.useEffect(()=>{const h=Date.now(),p=Ku(n?.infraredCharacterLeft),g=Ku(n?.infraredCharacterRight),y=Ku(n?.infraredCharacterOmni);!p&&!g&&!y||f(b=>({left:p?{...p,ts:h}:b.left,right:g?{...g,ts:h}:b.right,omni:y?{...y,ts:h}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useEffect(()=>{const{left:h,right:p,omni:g}=o;if(!(h?.ts||p?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:h?.code??0,omni:g?.code??0,right:p?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const h=Date.now(),p=j=>{if(!j)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const w=h-j.ts,E=w<=i;return{active:E,age:w,code:j.code,red:!!(j.red&&E),green:!!(j.green&&E),force:!!(j.force&&E)}},g=p(o.left),y=p(o.right),b=p(o.omni),A=g.force||y.force||b.force,R=g.active||y.active||b.active,N=g.active&&!y.active?"right":y.active&&!g.active?"left":"center",q=(y.active?1:0)-(g.active?1:0);return{visible:R,forceDetected:A,left:g,right:y,omni:b,bias:N,balance:Math.max(-1,Math.min(1,q))}},[o.left,o.right,o.omni,i,d])}function BS(){const{connected:n,session:l}=ze(),i=l?.assignment?.roverId,o=cs(i),f=o?.sensors||{},d=OS(f),x=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,h=f.currentMa!=null?`${f.currentMa} mA`:null,p=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,A=i?l?.activeDrivers?.[i]:null;return m.useMemo(()=>i?A?A===l?.socketId?"You":(l?.users||[]).find(N=>N.socketId===A)?.nickname||A.slice(0,6):"Available":"n/a",[A,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(LS,{sensors:f,voltage:x,current:h,batteryTemp:p,charge:g,capacity:y}),r.jsx(zS,{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 LS({sensors:n,voltage:l,current:i,batteryTemp:o,charge:f,capacity:d}){const x=f!=null&&d?`${Math.round(f/d*100)}`:"--",h=n?.oiMode?.label||"--",p=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(ta,{label:"Voltage",value:l??"--"}),r.jsx(ta,{label:"Current",value:i??"--"}),r.jsx(ta,{label:"Battery temp",value:o??"--"}),r.jsx(ta,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(ta,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(ta,{label:"Charge",value:x}),r.jsx(ta,{label:"OI mode",value:h}),r.jsx(ta,{label:"Docked",value:p}),r.jsx(ta,{label:"Charging state",value:g})]})}function ta({label:n,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:n}),r.jsx("span",{className:"text-slate-100",children:l})]})}function zS({sensors:n,dockState:l}){const i=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},f=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],d=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],x=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Il,{title:"Dock IR",children:[r.jsx(US,{sensors:n}),r.jsx(HS,{state:l})]}),r.jsxs(Il,{title:"Bumps & drops",children:[r.jsx(na,{label:"Bump L",value:r.jsx(ii,{active:i.bumpLeft})}),r.jsx(na,{label:"Bump R",value:r.jsx(ii,{active:i.bumpRight})}),r.jsx(na,{label:"Wheel drop L",value:r.jsx(ii,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(na,{label:"Wheel drop R",value:r.jsx(ii,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Il,{title:"Light bumps (raw)",children:f.map(h=>r.jsx(na,{label:h.label,value:ri(h.value)},h.label))}),r.jsx(Il,{title:"Cliff sensors",children:d.map(h=>r.jsx(na,{label:h.label,value:`${ri(h.value)} · ${h.active?"bool: true":"bool: false"}`},h.label))}),r.jsx(Il,{title:"Currents",children:x.map(h=>r.jsx(na,{label:h.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:ri(h.value,"mA")}),h.over?r.jsx(ii,{active:!0,tone:"red",label:"over"}):null]})},h.label))}),r.jsxs(Il,{title:"Dirt detect",children:[r.jsx(na,{label:"Left",value:ri(n?.dirtDetectLeft)}),r.jsx(na,{label:"Right",value:ri(n?.dirtDetect)})]})]})}function Il({title:n,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:n}),r.jsx("div",{className:"space-y-0.5",children:l})]})}function na({label:n,value:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:n}),r.jsx("span",{className:"text-slate-100",children:l})]})}function ii({active:n,tone:l="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=l==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":l==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(n?"true":"false")})}function ri(n,l){return n==null||Number.isNaN(n)?"--":l?`${n} ${l}`:n}function US({sensors:n}){const l=n?.infraredCharacterLeft,i=n?.infraredCharacterRight,o=n?.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 HS({state:n}){if(!n)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: ${n.left.code??"--"} (${l(n.left)}) · age ${i(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${l(n.omni)}) · age ${i(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${l(n.right)}) · age ${i(n.right)}`})]})}const Kx=m.createContext(null);function VS({children:n}){const[l,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const h=jf();i({status:"ready",data:h??{}})},[]);const o=m.useCallback(()=>{const h=jf();i({status:"ready",data:h??{}})},[]),f=m.useCallback(h=>{const p=N0(h??{});return i(p?{status:"ready",data:h??{}}:g=>({...g,status:"error"})),p},[]),d=m.useCallback((h,p)=>{i(g=>{const y=g.data[h]||{},b=typeof p=="function"?p(y):{...y,...p??{}},A={...g.data,[h]:b};return N0(A)?{status:"ready",data:A}:{...g,status:"error"}})},[]),x=m.useMemo(()=>({data:l.data,status:l.status,reload:o,saveAll:f,setNamespace:d}),[l,o,f,d]);return r.jsx(Kx.Provider,{value:x,children:n})}function $S(){const n=m.useContext(Kx);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Qe(n,l={}){const{data:i,status:o,setNamespace:f}=$S(),d=i[n]??l??{},x=m.useCallback(g=>{f(n,y=>{const b=y??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[n,f]),h=m.useCallback(g=>{f(n,()=>g??{})},[n,f]),p=m.useCallback(()=>{const g=typeof l=="object"?{...l}:l;f(n,()=>g??{})},[l,n,f]);return{value:d,status:o,save:x,replace:h,reset:p}}const GS=/^#[0-9A-Fa-f]{6}$/;function Ff(n){const l=typeof n=="string"?n.trim():"";return!l||!GS.test(l)?null:l.toUpperCase()}function ra(n,l=.2){const i=Ff(n);if(!i)return;const o=Number.isFinite(l)?Math.max(0,Math.min(1,l)):.2,f=Zx(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.65)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function YS(n,l=.2){const i=Ff(n);if(!i)return;const o=Number.isFinite(l)?Math.max(0,Math.min(1,l)):.2,f=Zx(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.55)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function Zx(n){const l=Ff(n);return l?{r:parseInt(l.slice(1,3),16),g:parseInt(l.slice(3,5),16),b:parseInt(l.slice(5,7),16)}:null}function FS(n=[]){return n.map(l=>!l?.type||!l?.id?null:{type:l.type,id:String(l.id),label:l.label||String(l.id),color:l.color||null,key:`${l.type}:${l.id}`}).filter(Boolean)}function Xf({panelId:n="replay-sources",fillHeight:l=!1}){const{session:i,triggerReplay:o}=ze(),f=FS(i?.replaySources||[]),{value:d,save:x}=Qe("replaySources",{}),[h,p]=m.useState([]),[g,y]=m.useState(!1),[b,A]=m.useState(null),[R,N]=m.useState(null),q=i?.replay||null,[j,w]=m.useState(0),E=m.useMemo(()=>{const B=i?.assignment?.roverId;return B?[`rover:${B}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const B=d?.[n];if(Array.isArray(B)&&B.length){p(B);return}p(E)},[d?.[n],E,n]),m.useEffect(()=>{const B=new Set(f.map(z=>z.key));p(z=>z.filter(Y=>B.has(Y)))},[f]);const C=m.useMemo(()=>({rovers:f.filter(B=>B.type==="rover"),rooms:f.filter(B=>B.type==="room")}),[f]);m.useEffect(()=>{if(!q?.lastTriggeredAt||!q?.cooldownMs){w(0);return}const B=()=>{const Y=q.lastTriggeredAt+q.cooldownMs-Date.now();w(Math.max(0,Y))};B();const z=setInterval(B,250);return()=>clearInterval(z)},[q?.lastTriggeredAt,q?.cooldownMs,q?.remainingMs]);const M=g||i?.mode==="lockdown"||j>0||!h.length,U=B=>{p(z=>{const Y=z.includes(B)?z.filter(te=>te!==B):[...z,B];return x(te=>({...te||{},[n]:Y})),Y}),N(null)},X=async()=>{if(!M){y(!0),A(null),N(null);try{const B=h.map(z=>{const[Y,te]=z.split(":");return{type:Y,id:te}});await o(B),N("Replay sent. Check the Discord replay channel.")}catch(B){A(B.message)}finally{y(!1)}}},_=l?"h-full flex flex-col":"",K=l?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${_}`,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 ${K}`,children:[r.jsx(w0,{title:"Rovers",items:C.rovers,selected:h,onToggle:U}),r.jsx(w0,{title:"Room Cams",items:C.rooms,selected:h,onToggle:U})]}),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:X,disabled:M,children:j>0?`Replay (${Math.ceil(j/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,R?r.jsx("div",{className:"text-xs text-emerald-300",children:R}):null]})]})}function w0({title:n,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:n}),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 ${f.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:f.type==="rover"?ra(f.color,.16):void 0,children:f.label})]},f.key))})]}):null}var Ix={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},C0=rl.createContext&&rl.createContext(Ix),XS=["attr","size","title"];function QS(n,l){if(n==null)return{};var i=KS(n,l),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(n);for(f=0;f<d.length;f++)o=d[f],!(l.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(i[o]=n[o])}return i}function KS(n,l){if(n==null)return{};var i={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(l.indexOf(o)>=0)continue;i[o]=n[o]}return i}function so(){return so=Object.assign?Object.assign.bind():function(n){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])}return n},so.apply(this,arguments)}function E0(n,l){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);l&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(n,f).enumerable})),i.push.apply(i,o)}return i}function io(n){for(var l=1;l<arguments.length;l++){var i=arguments[l]!=null?arguments[l]:{};l%2?E0(Object(i),!0).forEach(function(o){ZS(n,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):E0(Object(i)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(i,o))})}return n}function ZS(n,l,i){return l=IS(l),l in n?Object.defineProperty(n,l,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[l]=i,n}function IS(n){var l=JS(n,"string");return typeof l=="symbol"?l:l+""}function JS(n,l){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var o=i.call(n,l);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(n)}function Jx(n){return n&&n.map((l,i)=>rl.createElement(l.tag,io({key:i},l.attr),Jx(l.child)))}function Ei(n){return l=>rl.createElement(PS,so({attr:io({},n.attr)},l),Jx(n.child))}function PS(n){var l=i=>{var{attr:o,size:f,title:d}=n,x=QS(n,XS),h=f||i.size||"1em",p;return i.className&&(p=i.className),n.className&&(p=(p?p+" ":"")+n.className),rl.createElement("svg",so({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,x,{className:p,style:io(io({color:n.color||i.color},i.style),n.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),d&&rl.createElement("title",null,d),n.children)};return C0!==void 0?rl.createElement(C0.Consumer,null,i=>l(i)):l(Ix)}function Px(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(n)}function WS(n){return Ei({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function k0(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(n)}function eA(n){return Ei({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function tA(n){return Ei({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function nA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Qf(n){return!!n?.system}function aA(n){const l=new Date(n);return`${l.getHours().toString().padStart(2,"0")}:${l.getMinutes().toString().padStart(2,"0")}`}function M0(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function lA({guildIconUrl:n,userAvatarUrl:l,label:i}){return!n&&!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 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,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 Wx({message:n}){const l=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${M0(n)}`:null,i=Qf(n),o=i?"text-emerald-300":nA(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(Px,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(lA,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:l})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:M0(n)}),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,n.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:YS(n.roverColor,.14),children:n.roverId})]})}function eg(n){return Qf(n)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${n.role==="admin"||n.role==="lockdown"||n.role==="lockdown-admin"?"border border-amber-400/30":n.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function Kf({message:n}){const l=Qf(n);return r.jsxs("div",{className:eg(n),children:[r.jsx(Wx,{message:n}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${l?"text-emerald-100":"text-slate-100"}`,children:n.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:aA(n.ts)})]})}function tg({message:n}){return r.jsxs("div",{className:`${eg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(Wx,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}const sA=3e3,iA="#2196f3";function rA(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function Zf({scale:n=1}){const{alerts:l}=ze(),[i,o]=m.useState(()=>Date.now()),f=m.useMemo(()=>l.slice(-3).map(p=>({alert:p,key:rA(p)})),[l]);m.useEffect(()=>{if(!f.length)return;const p=setInterval(()=>o(Date.now()),200);return()=>clearInterval(p)},[f.length]);const d=f.map(p=>({...p,age:i-(p.alert.receivedAt??p.alert.timestamp??0)})).filter(p=>p.age<=sA);if(!d.length)return null;const x=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},h=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:h,style:x,children:d.map(p=>r.jsx(oA,{alert:p.alert},p.key))})}function q0(n){const l=typeof n=="string"?n.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 oA({alert:n}){if(n.kind==="chat"&&n.payload)return r.jsx(Kf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(tg,{message:n.payload});const l=q0(n.color)||q0(iA),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:n.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:n.message})]})})}const Jl={main:[-127,127],side:[-127,127],vacuum:[0,127]},Zu={maxSpeed:500,baseSpeed:250,boostSpeed:400},Nf=100,If=[31,127],as=60,wf=8,cA=250,uA=4e3,Iu=.4,fA=.8,dA={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},di={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"]},ng=[{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:Nf},{type:"oi",command:"dock"},{type:"pause",duration:Nf},{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 Cf(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Ef(){return{main:0,side:0,vacuum:0}}function mA(){return{enabled:!1,angle:null,config:null}}function eo(){return{note:as}}function fi(){return{active:!1,heat:0,overheated:!1}}function to(){return{pttActive:!1}}const R0={roverId:null,mode:"drive",drive:Cf(),aux:Ef(),camera:mA(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0,macros:ng,keymap:di,inputs:{}};function hA(n,l){switch(l.type){case"control/set-rover":return{...n,roverId:l.payload??null,drive:l.payload?n.drive:Cf(),aux:l.payload?n.aux:Ef(),song:l.payload?n.song:eo(),horn:l.payload?n.horn:fi(),mic:l.payload?n.mic:to(),lastControlIntentAt:l.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===l.payload?n:{...n,mode:l.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=l.payload;return{...n,drive:{vector:i??n.drive.vector,speeds:o??n.drive.speeds,source:f??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...l.payload}};case"control/set-camera-config":return{...n,camera:{...n.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??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:l.payload}};case"control/register-input-state":{const i=l.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[i]:{...n.inputs[i]??{},...l.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...l.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(l.payload)?l.payload:n.macros};case"control/reset":return{...n,drive:Cf(),aux:Ef(),song:eo(),horn:fi(),mic:to(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||fi(),active:!!l.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||fi(),heat:typeof l.payload?.heat=="number"?l.payload.heat:0,overheated:!!l.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||eo(),note:l.payload??as}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||to(),pttActive:!!l.payload}};default:return n}}function ls(n,l,i){return typeof n!="number"||Number.isNaN(n)?l:Math.max(l,Math.min(i,n))}function ss(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function dn(n,l){return!Array.isArray(l)||l.length!==2?n:ls(n,l[0],l[1])}function pA(n={}){const l=ss(n.x??0),i=ss(n.y??0);return{x:l,y:i,boost:!!n.boost}}function xA(n={},l={}){const i=pA(n),o=typeof l.maxSpeed=="number"?l.maxSpeed:Zu.maxSpeed,f=typeof l.baseSpeed=="number"?l.baseSpeed:Zu.baseSpeed,d=typeof l.boostSpeed=="number"?l.boostSpeed:Zu.boostSpeed,x=i.boost?d:f,h=i.y*x,p=i.x*x;return{vector:i,speeds:{left:ls(Math.round(h+p),-o,o),right:ls(Math.round(h-p),-o,o)}}}function gA(n){const l=Array.isArray(n)?n:[],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 T0(n){return new Promise(l=>setTimeout(l,n))}function vA(n={}){const{driveTransform:l,auxTransform:i}=n,o=Rn(),{session:f}=ze(),d=f?.assignment?.roverId,x=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(U=>String(U.id)===String(d))||null,[d,f?.roster]),h=m.useMemo(()=>!x?.cameraServo||!x.cameraServo.enabled?null:x.cameraServo,[x]),p=m.useMemo(()=>!x?.nightVision||!x.nightVision.enabled?null:x.nightVision,[x]),g=m.useMemo(()=>!x?.horn||!x.horn.enabled?null:x.horn,[x]),y=m.useMemo(()=>x?.nightVision?.state??null,[x]),b=m.useCallback((U,X)=>{d&&o.emit("command",{roverId:d,...U},X)},[o,d]),A=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),R=m.useCallback(U=>{if(!d)return null;const X={left:dn(U?.left??0,[-500,500]),right:dn(U?.right??0,[-500,500])},_=l?l(X):X,K={left:dn(_?.left??0,[-500,500]),right:dn(_?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:K}}),K},[l,b,d]),N=m.useCallback(({main:U=0,side:X=0,vacuum:_=0}={})=>{if(!d)return null;const K={main:dn(U,Jl.main),side:dn(X,Jl.side),vacuum:dn(_,Jl.vacuum)},B=i?i(K):K,z={main:dn(B?.main??0,Jl.main),side:dn(B?.side??0,Jl.side),vacuum:dn(B?.vacuum??0,Jl.vacuum)};return b({type:"motors",data:{motorPwm:z}}),z},[i,b,d]),q=m.useCallback(U=>!d||!h?null:(b({type:"servo",data:{servo:{angle:U}}}),U),[b,d,h]),j=m.useCallback(U=>{if(!d)return!1;const X=Array.isArray(U)?U:typeof U=="string"?dA[U]:null;return X?(b({type:"raw",data:{raw:gA(X)}}),A(),!0):!1},[b,A,d]),w=m.useCallback(async U=>{if(!(!U||!Array.isArray(U.steps)||!d))for(const X of U.steps){if(!d)break;switch(X.type){case"oi":j(X.command);break;case"drive":R(X.speeds??{left:0,right:0});break;case"motors":N(X.values??{});break;case"servo":q(X.angle);break;case"pause":await T0(X.duration??Nf);break}if(X.delay||X.delayMs){const _=X.delayMs??X.delay;typeof _=="number"&&_>0&&await T0(_)}}},[d,j,R,N,q]),E=m.useCallback((U="toggle")=>!d||!p?null:(b({type:"nightVision",data:{nightVision:{action:U}}}),U),[b,p,d]),C=m.useCallback(U=>d?(b({type:"horn",data:{horn:U}}),U):null,[b,d]),M=m.useCallback((U=[],X={})=>{if(!d)return null;const K=(Array.isArray(U)&&U.length>0?U:[{note:as,duration:wf}]).slice(0,16).map(B=>({note:dn(Math.round(B?.note??as),If),duration:dn(Math.round(B?.duration??wf),[1,255])}));return b({type:"song",data:{song:{notes:K,slot:X.slot,loop:X.loop}}}),K},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:x,servoConfig:h,nightVision:p,nightVisionState:y,horn:g,emitCommand:b,enableSensorStream:A,sendDriveDirect:R,sendAuxMotors:N,sendServoAngle:q,sendOiCommand:j,sendNightVision:E,sendHorn:C,sendSong:M,runMacroSteps:w}),[d,x,h,p,y,g,b,A,R,N,q,j,E,C,w])}const yA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},D0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function ki(n){if(typeof n!="string")return"";const l=n.toLowerCase();return yA[l]??l}function bA(n){const l=ki(n);if(!l)return null;if(D0[l])return D0[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 ag(n){const l=ki(n);return l?`key:${l}`:null}function SA(n){const l=bA(n);return l?`code:${l}`:null}function _0(n){const l=new Set,i=ag(n?.key??"");i&&l.add(i);const o=n?.code?`code:${n.code}`:null;return o&&l.add(o),Array.from(l)}function AA(n={}){return Object.fromEntries(Object.entries(n).map(([l,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const x=ag(String(d));x&&f.add(x);const h=SA(String(d));h&&f.add(h)}),[l,f]}))}function bn(n){const l=ki(n);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 En={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},la={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}]}}},Da={activeSignature:null,profiles:{},defaults:{profile:la}},il={waveform:"saw",freqs:[440,550,660,0]},Dt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},ts=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],jA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function O0(){return ts.reduce((n,l)=>(n[l.key]={cap:1,clearSec:0},n),{})}function B0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function NA(n,l={}){const{session:i}=ze(),d=(cs(n)?.sensors||{})?.wheelOvercurrents||{},x=m.useMemo(()=>({...jA,...l.config||{}}),[l.config]),[h,p]=m.useState(()=>O0()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),y=m.useRef(d);m.useEffect(()=>{y.current=d||{}},[d]),m.useEffect(()=>{p(O0())},[n]),m.useEffect(()=>{const N=setInterval(()=>{const q=typeof performance<"u"?performance.now():Date.now(),j=Math.max(0,q-g.current);g.current=q;const w=j/1e3;w<=0||p(E=>{let C=!1;const M={},U=Number.isFinite(x.downRatePerSec)?Math.max(0,x.downRatePerSec):0,X=Number.isFinite(x.upRatePerSec)?Math.max(0,x.upRatePerSec):0,_=Number.isFinite(x.releaseDelaySec)?Math.max(0,x.releaseDelaySec):0;return ts.forEach(K=>{const B=E[K.key]||{cap:1,clearSec:0},z=Number.isFinite(B.cap)?B.cap:1,Y=Number.isFinite(B.clearSec)?B.clearSec:0,te=K.motors.some(T=>!!y.current?.[T]),fe=te?0:Y+w,ce=!te&&fe>=_,G=B0(te?z-U*w:ce?z+X*w:z);(Math.abs(G-z)>1e-4||Math.abs(fe-Y)>1e-4)&&(C=!0),M[K.key]={cap:G,clearSec:fe}}),C?M:E})},100);return()=>clearInterval(N)},[x.downRatePerSec,x.releaseDelaySec,x.upRatePerSec]);const b=m.useMemo(()=>{const N=ts.reduce((q,j)=>{const w=h?.[j.key],E=Number.isFinite(w?.cap)?w.cap:1;return q[j.key]=B0(E),q},{});return{perGroup:N,drive:{left:N.drive??1,right:N.drive??1},aux:{main:N.aux??1,side:N.aux??1,vacuum:1}}},[h]),A=m.useMemo(()=>{const N={};ts.forEach(j=>{j.motors.forEach(w=>{N[w]=!!d?.[w]})});const q=ts.reduce((j,w)=>(j[w.key]=w.motors.some(E=>!!d?.[E]),j),{});return{motors:N,groups:q}},[d]),R=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:h,overcurrent:A,scales:b,isActive:(b?.drive?.left??1)<1||(b?.drive?.right??1)<1||(b?.aux?.main??1)<1||(b?.aux?.side??1)<1,config:x,adminImmune:R}),[h,A,b,x,R])}function wA(n={},l,i=!1){if(i||!l?.drive)return n;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?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*f)}}function CA(n={},l,i=!1){if(i||!l?.aux)return n;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?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*f),vacuum:Math.round((n.vacuum??0)*d)}}const lg=m.createContext(null);function L0(n){return Object.fromEntries(Object.entries(n||{}).map(([l,i])=>[l,Array.isArray(i)?[...i]:[]]))}function EA(n,l){if(!n)return l;const i=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return ls(l,i,o)}function kA(n=[]){if(!Array.isArray(n)||n.length<3)return n;const l=n.slice(-3),[i,o,f]=l,d=i?.type==="drive"&&Number(i?.speeds?.left)===-300&&Number(i?.speeds?.right)===-300,x=o?.type==="pause"&&Number(o?.duration)===600,h=f?.type==="drive"&&Number(f?.speeds?.left)===0&&Number(f?.speeds?.right)===0;return!d||!x||!h?n:n.slice(0,-3)}function MA({children:n}){const[l,i]=m.useReducer(hA,R0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(R0.camera.angle),x=m.useRef(null),h=m.useRef(0),p=m.useRef(0),{value:g,save:y}=Qe("controls",{keymap:di,macros:ng}),{value:b}=Qe("page",{driveMacroBackoffEnabled:!0}),{value:A}=Qe("horn",il),R=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,{session:N,homeAssistantSetState:q}=ze(),j=N?.assignment?.roverId??null,w=NA(j),E=m.useCallback(ae=>wA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),C=m.useCallback(ae=>CA(ae,w.scales,w.adminImmune),[w.adminImmune,w.scales]),M=vA({driveTransform:E,auxTransform:C}),U=m.useCallback(()=>{const ue=(N?.homeAssistant?.entities||[]).filter(be=>(be.type==="light"||be.type==="switch")&&be.available!==!1&&be.state!=="on");if(ue.length===0){f.current=!1;return}f.current=!0,ue.forEach(be=>{q(be.id,"on").catch(()=>{})}),f.current=!1},[N?.homeAssistant?.entities,q]);m.useEffect(()=>{i({type:"control/set-rover",payload:M.roverId})},[M.roverId]),m.useEffect(()=>{const ae=o.current;o.current=l.mode,ae!=="drive"&&l.mode==="drive"&&N?.homeAssistant?.entities?U():ae!=="drive"&&l.mode==="drive"&&(f.current=!0)},[l.mode,N?.homeAssistant?.entities,U]),m.useEffect(()=>{f.current&&N?.homeAssistant?.entities&&U()},[N?.homeAssistant?.entities,U]),m.useEffect(()=>{const ae={...di,...g?.keymap||{}};i({type:"control/set-keymap",payload:ae}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const ae=M.servoConfig;if(!ae){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const ue=typeof ae.minAngle=="number"?ae.minAngle:-45,be=typeof ae.maxAngle=="number"?ae.maxAngle:45,Me=typeof ae.homeAngle=="number"?ae.homeAngle:(ue+be)/2,se=typeof d.current=="number"?ls(d.current,ue,be):null,re=se??ls(Me,ue,be);i({type:"control/set-camera-config",payload:{config:ae,angle:re}}),d.current=re},[M.servoConfig]),m.useEffect(()=>{d.current=typeof l.camera.angle=="number"?l.camera.angle:d.current},[l.camera.angle]),m.useEffect(()=>{M.roverId&&M.enableSensorStream()},[M.roverId,M.enableSensorStream]);const X=m.useCallback(ae=>{i({type:"control/set-mode",payload:ae})},[]),_=m.useCallback(()=>{i({type:"control/record-intent"})},[]),K=m.useRef(l.drive.speeds),B=m.useRef(l.aux),z=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),Y=m.useRef(0),te=m.useRef(0);m.useEffect(()=>{K.current=l.drive.speeds},[l.drive.speeds]),m.useEffect(()=>{B.current=l.aux},[l.aux]),m.useEffect(()=>{if(!M.roverId||w.adminImmune||!w.isActive)return;const ae=Math.max(0,Number(w?.config?.outputRateMs)||0),ue=typeof performance<"u"?performance.now():Date.now(),be=K.current||{left:0,right:0},Me=B.current||{main:0,side:0,vacuum:0},se=!!(be.left||be.right),re=!!(Me.main||Me.side||Me.vacuum);!se&&!re||(se&&ue-Y.current>=ae&&(Y.current=ue,M.sendDriveDirect(be)),re&&ue-te.current>=ae&&(te.current=ue,M.sendAuxMotors(Me)))},[z,w.adminImmune,w.config,w.isActive,M]);const fe=m.useCallback((ae,ue={})=>{const be=xA(ae,ue.speedOptions);i({type:"control/update-drive",payload:{...be,source:ue.source??null}}),_(),M.sendDriveDirect(be.speeds)},[M,_]),ce=m.useCallback((ae={})=>{const ue=M.sendAuxMotors(ae)??ae;i({type:"control/set-aux-motors",payload:ue}),_()},[M,_]),G=m.useCallback((ae,ue)=>{if(!ae)return!1;const be=ki(ue);if(!be)return!1;const Me=L0(l.keymap);return Me[ae]=[be],i({type:"control/set-keymap",payload:Me}),y(se=>({...se??{},keymap:Me})),!0},[l.keymap,y]),T=m.useCallback(()=>{const ae=L0(di);i({type:"control/set-keymap",payload:ae}),y(ue=>({...ue??{},keymap:ae}))},[y]),F=m.useCallback(ae=>{if(!M.servoConfig)return;const ue=EA(M.servoConfig,ae);i({type:"control/set-camera-angle",payload:ue}),M.sendServoAngle(ue),d.current=ue,_()},[M,_]),J=m.useCallback((ae=0)=>{const ue=M.servoConfig;if(!ue)return;const be=typeof ae=="number"&&ae!==0?ae:ue.nudgeDegrees||1,Me=typeof d.current=="number"?d.current:typeof ue.homeAngle=="number"?ue.homeAngle:0;F(Me+be)},[M.servoConfig,F]),le=m.useCallback(()=>{const ae=M.servoConfig;if(!ae)return;const ue=typeof ae.homeAngle=="number"?ae.homeAngle:typeof ae.minAngle=="number"&&typeof ae.maxAngle=="number"?(ae.minAngle+ae.maxAngle)/2:0;F(ue)},[M.servoConfig,F]),de=m.useCallback(async ae=>{const ue=l.macros.find(Me=>Me.id===ae)||null;if(!ue)return;let be=ue;ae==="drive-sequence"?(U(),N?.homeAssistant?.entities||(f.current=!0),_(),R||(be={...ue,steps:kA(ue.steps)})):ae==="seek-dock"&&_(),await M.runMacroSteps(be)},[R,M,_,N?.homeAssistant?.entities,l.macros,U]),k=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),M.sendDriveDirect({left:0,right:0}),M.sendAuxMotors({main:0,side:0,vacuum:0})},[M]),H=m.useCallback(ae=>{M.sendOiCommand(ae)},[M]),P=m.useCallback(ae=>{M.roverId&&M.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ae}}})},[M]),ne=m.useCallback(ae=>{if(M.nightVision){if(typeof ae=="boolean"){const ue=ae?"off":"on";M.sendNightVision(ue)}else M.sendNightVision("toggle");_()}},[M,_]),pe=m.useCallback(()=>{ne()},[ne]),ie=m.useCallback(ae=>{const ue=typeof ae=="number"?ae:as;return i({type:"control/set-song-note",payload:ue}),ue},[]),oe=m.useCallback((ae,ue)=>M.sendSong(ae,ue),[M]),ve=m.useMemo(()=>{const ae=A??il,ue=ae.waveform==="sine"?"sine":"saw",Me=[...Array.isArray(ae.freqs)?ae.freqs:il.freqs,0,0,0,0].slice(0,4).map(se=>{const re=Number(se);return Number.isFinite(re)?re<=0?0:Math.min(5e3,Math.round(re)):0});return{waveform:ue,freqs:Me}},[A]),ye=m.useCallback(()=>{if(!M.horn)return;if(l.horn?.overheated||(l.horn?.heat??0)>=1||l.horn?.active)return!1;const ae=Date.now();return M.sendHorn({action:"start",...ve}),i({type:"control/set-horn-active",payload:!0}),h.current=ae,p.current=ae,x.current&&(clearTimeout(x.current),x.current=null),x.current=setTimeout(()=>{xe()},uA),_(),!0},[i,ve,M,_,l.horn?.active,l.horn?.heat,l.horn?.overheated]),xe=m.useCallback(()=>{if(!M.horn)return;M.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),x.current&&(clearTimeout(x.current),x.current=null);const ae=Date.now(),ue=h.current||ae,be=Math.max(0,ae-ue);if(h.current=0,be>0){const Me=l.horn?.heat??0,se=be/1e3*Iu;let re=Math.max(0,Math.min(1,Me+se)),me=l.horn?.overheated??!1;re>=1&&(re=1,me=!0),i({type:"control/set-horn-heat",payload:{heat:re,overheated:me}})}},[i,M,l.horn?.heat,l.horn?.overheated,Iu]);m.useEffect(()=>{const ue=setInterval(()=>{const be=Date.now(),Me=p.current||be;p.current=be;const se=Math.min(1e3,Math.max(0,be-Me))/1e3,re=l.horn?.heat??0,me=!!l.horn?.active,we=!!l.horn?.overheated,et=se*(me?Iu:-.2);let dt=Math.max(0,Math.min(1,re+et)),Le=we;dt>=1?(dt=1,Le=!0,me&&xe()):Le&&dt<=fA&&(Le=!1),(dt!==re||Le!==we)&&i({type:"control/set-horn-heat",payload:{heat:dt,overheated:Le}})},100);return()=>clearInterval(ue)},[i,l.horn?.active,l.horn?.heat,l.horn?.overheated,xe]);const Ue=m.useCallback((ae,ue)=>{i({type:"control/register-input-state",payload:{source:ae,state:ue}})},[]),$e=m.useCallback(ae=>{i({type:"control/set-mic-ptt",payload:!!ae})},[]),Ne=m.useMemo(()=>({state:l,dispatch:i,pipeline:M,overcurrentLimiter:w,actions:{setMode:X,setDriveVector:fe,setAuxMotors:ce,setServoAngle:F,nudgeServo:J,goServoHome:le,runMacro:de,stopAllMotion:k,sendOiCommand:H,setSensorStream:P,setNightVision:ne,toggleNightVision:pe,updateKeyBinding:G,resetKeyBindings:T,registerInputState:Ue,setSongNote:ie,sendSong:oe,startHorn:ye,stopHorn:xe,setMicPttActive:$e}}),[l,M,w,X,fe,ce,F,J,le,de,k,H,P,ne,pe,G,T,Ue,ie,oe,ye,xe,$e]);return r.jsx(lg.Provider,{value:Ne,children:n})}function _t(){const n=m.useContext(lg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const qA="data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAANAAAIpQBKSkpKSkpKXFxcXFxcXFxra2tra2tra3p6enp6enqJiYmJiYmJiZiYmJiYmJiYpqampqamprW1tbW1tbW1xMTExMTExMTT09PT09PT4uLi4uLi4uLx8fHx8fHx8f////////8AAABQTEFNRTMuMTAwBLkAAAAAAAAAABUgJAUYQQAB4AAACKVpqtMZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//ugxAAAwqQPR8CIwCh0BCj5jDwlIAAjW87wAACcOsAKPMk8ARj8w9OAWwNlV/gCgQMHEhAOVnFaNzWWAPI2zyjHjd8FAoKqyAa88AAAAABNjEd9CQOglIY9dtC+a51bGZrZgTewD3c+AAYx5hxIMheIcudKAyaykG1/h5EsPB0iTEFNRTMuMTAwqqqqqqrIBZqvAAAAAC9JXFIAHrCgAp0D0hUYOInIluqg1TNdKCzMeAAFQCKKsxUmVfireKILLBgSVgb4qBVtPWpMQU1FMy4xMDCqqqqqqqqqqqqqqqqpApm/AAAAAC7QYaHPHoCjkCysmc+QY9NNWRbKE+mqowNobwAAoSQQMLGChDlOrKMqVMC/6xy/CXbFaL7AZUxBTUUzLjEwMFVVVVVVVVVVVacDqZ8AAAAAMgzaYFBPNgIOnVCQfFfwmBBhLVNJQSdxdQRofwAGxF9xAAYs4AZDuE87li0YCASIBwaCiXUj+2BqTEFNRTMuMTAwqqqqqqqqlwOonwAAAAAtkABQSEZ1INNDgx8HeaaLCXiu5dqSciylQNXjv8GdmACQ5ogYKbnsmxkoChog+w9IhU6GsgzCIQBSxFpMQQAAMBiHjgAAAAv6FQQILmJmGLltnax9HszIVEAoEq1p8olpcPLlGpXFastuWosKNFlmlqADJbwAEFRI4iJJy0oDumUW//sgxOEAw5wfU8fnAGBvg6n5nDxUh7QuwcEzkK5Ztz7AZUxBTUUzLjEwMFVVVVVVVZUAhd8AAAAALZAAamQMWKtC7Avib0WLplt2IAp0SKV0pFFxCADLX6AIPFrWJIBQqPGW/x0QDTRLGaQYCRAZzKeoU6uqTEFN6AB3n/7wAAAxq//7EMT0AMPUHU/MawJgc4PpuYy8VQZjocBw2OgQQyQyECnbABEUC/ZoM0J56Jm0tqzNJaq8KospqUAQ5/QBghnCqQAhR4Mz1D1gJPstYsI1sYIg079I5cYjY6pMQU1FMy4xMDCqqqqq//sQxPUAw+AdT8zvAih6hCk5nWBFqqqWAFOf4AAAAEAIQZPkMcwUzFVE51cSBjIHpJRIEIjWgGar9VhgCUvwAFAUMk0RCpMkwXjPQDcoLBU+n5RuR4ZrPQLPckxBTUUzLjEwMKqqqqr/+xDE9oDEAB1NzG8CKIGEKPmd5EWqxgBWn9AAAAAKIiC5GcLJIczCEvNbWsF31jo4Bw0rXktvJF5YRyABlj+ABIQ2RGsHgdc0XsPntoEDUzaQOjTBqblFPUE1TEFNRckAt68AAAAALv/7EMT4AMQIHU3M7wIojwUo+Y2MZfAgKcwITAQIYN1TosJeLtDA0ubWNrFSADJoln4AC0hVaLiIIUChs+4HST4BgCpQHITPMBQkEnj73ORZfylh+sRLEGUiNIpMQU1FMy4xMDCqqqqq//sQxP6AxlgtK+13Yih3hCj5neBNqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrIkT7UNAZ7NS7yMqcihSKLMn8DlKYq8ZdPCVEoJBuWqkxBTUUzLjEwMKqqqqr/+xDE+ADEXCVHzGjDIIQEqLm9PIWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT+AMWoL0XNcwJoiASoeY3gVaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxPgAxHAnRcxvAmiBBKj5jehEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDE+IDEmCVDzPMCKH6EqLmNYE2qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT9gEPgI0vMZwQgvYWlPY5gFaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxOYDw+gpIIfgwWgAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",sg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function RA({children:n}){const l=Rn(),{session:i,pushAlert:o}=ze(),{value:f}=Qe("audio",Dt),[d,x]=m.useState([]),[h,p]=m.useState([]),[g,y]=m.useState(!1),b=m.useRef(null),A=m.useRef(null),R=m.useRef(null),N=m.useRef(new Map),q=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),w=Number.isFinite(f?.masterVolume)?f.masterVolume:Dt.masterVolume,E=Number.isFinite(f?.alertVolume)?f.alertVolume:Dt.alertVolume,C=Math.max(0,Math.min(1,w*E)),M=m.useCallback(()=>{const G=Array.from(N.current.values()).sort((T,F)=>T.lastUpdate-F.lastUpdate).map(T=>T.payload);p(G)},[]),U=m.useCallback(G=>!G||typeof G!="object"?null:G.typingId?G.typingId:G.fromDiscord?`discord:${G.discordUserId||G.discordUserName||G.nickname||"unknown"}`:`socket:${G.socketId||G.nickname||"unknown"}`,[]);m.useEffect(()=>{R.current=new Audio(qA),R.current.volume=C,R.current.load()},[C]);const X=m.useCallback(()=>{const G=R.current;G&&(G.volume=C,G.currentTime=0,G.play().catch(()=>{}))},[C]);m.useEffect(()=>{function G(T={}){x(F=>[...F.slice(-99),T]),!(T?.socketId&&i?.socketId&&T.socketId===i.socketId)&&(X(),o?.({kind:"chat",payload:T,id:`chat-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return l.on("chat:message",G),()=>{l.off("chat:message",G)}},[X,i?.socketId,l]),m.useEffect(()=>{function G(T={}){const F=U(T);if(!F)return;const J=Date.now();if(T?.socketId&&i?.socketId&&T.socketId===i.socketId){T.isTyping||(N.current.delete(F),M());return}if(T.isTyping){N.current.set(F,{payload:T,expiresAt:J+6e3,lastUpdate:J});const le=q.current.get(F)||0;J-le>=2500&&(q.current.set(F,J),o?.({kind:"chat-typing",payload:T,id:`chat-typing-${F}-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else N.current.delete(F);M()}return l.on("chat:typing",G),()=>{l.off("chat:typing",G)}},[o,M,U,i?.socketId,l]),m.useEffect(()=>{const G=setInterval(()=>{const T=Date.now();let F=!1;N.current.forEach((J,le)=>{J.expiresAt<=T&&(N.current.delete(le),F=!0)}),F&&M()},2e3);return()=>clearInterval(G)},[M]),m.useEffect(()=>{function G(T=[]){Array.isArray(T)&&x(F=>{if(F.length===0)return T.slice(-100);const J=new Set(T.map(de=>de?.id));return[...T,...F.filter(de=>de?.id&&!J.has(de.id))].slice(-100)})}return l.on("chat:init",G),()=>{l.off("chat:init",G)}},[l]);const _=m.useCallback(G=>{const T=!!G,F=Date.now(),J=j.current,le=!T&&J.isTyping;!(T&&(!J.isTyping||F-J.lastSent>=3500))&&!le||(j.current={isTyping:T,lastSent:F},l.emit("chat:typing",{isTyping:T}))},[l]),K=m.useCallback((G,T=null)=>new Promise((F,J)=>{l.emit("chat:send",{text:G,tts:T},(le={})=>{le.error?J(new Error(le.error)):F(le)})}),[l]),B=m.useCallback((G,T={})=>{(T?.target==="hud"?"hud":"panel")==="hud"?A.current=G:b.current=G},[]),z=m.useCallback(()=>{y(!0),(A.current||b.current)?.focus()},[]),Y=m.useCallback(()=>{y(!1),A.current?.blur(),b.current?.blur()},[]),te=m.useCallback(()=>y(!0),[]),fe=m.useCallback(()=>y(!1),[]),ce=m.useMemo(()=>({messages:d,sendMessage:K,focusChat:z,blurChat:Y,registerInputRef:B,onInputFocus:te,onInputBlur:fe,setTypingActive:_,typing:h,isChatFocused:g,selfSocketId:i?.socketId||null}),[Y,z,g,d,fe,te,B,K,i?.socketId,_,h]);return r.jsx(sg.Provider,{value:ce,children:n})}function Jf(){const n=m.useContext(sg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let ig=!1;function Ju(n){ig=!!n}function z0(){return ig}const TA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function rg(n){if(!n||n.nodeType!==1)return!1;const l=n.tagName;if(l==="TEXTAREA"||n.isContentEditable)return!0;if(l!=="INPUT")return!1;const i=n.type?n.type.toLowerCase():"";return TA.has(i)}function DA(){return typeof document>"u"?!1:rg(document.activeElement)}const Pu="keyboard",Wu={x:0,y:0,boost:!1},ef={main:0,side:0,vacuum:0},U0=If[0],H0=If[1],Pf=5,xi=500,gi=1,Wf=100;function tf(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}function _A(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(Pf,Math.min(xi,i)):l}function og(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(gi,Math.min(Wf,i)):l}function OA(n){const i=(og(n,n)-gi)/(Wf-gi),o=xi-i*(xi-Pf);return Math.round(o)}function BA(n){const l=_A(n,n),i=(xi-l)/(xi-Pf),o=gi+i*(Wf-gi);return Math.round(o)}function LA(n){return rg(n?.target)}function ft(n,l){if(!n||n.size===0)return!1;for(const i of l)if(n.has(i))return!0;return!1}function zA(n,l){const i=ft(l.driveForward,n),o=ft(l.driveBackward,n),f=ft(l.driveLeft,n),d=ft(l.driveRight,n),x=ft(l.boostModifier,n),h=ft(l.slowModifier,n);let p=0;i&&!o?p=1:o&&!i&&(p=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const y=h?.4:1;return{x:g*y,y:p*y,boost:x&&!h}}function UA(n,l){if(ft(l.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=ft(l.auxMainForward,n)?127:ft(l.auxMainReverse,n)?-127:0,f=ft(l.auxSideForward,n)?127:ft(l.auxSideReverse,n)?-70:0,d=ft(l.auxVacuumFast,n)?127:ft(l.auxVacuumSlow,n)?50:0;return{main:o,side:f,vacuum:d}}function HA(){const{state:n,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:x,registerInputState:h,toggleNightVision:p,startHorn:g,stopHorn:y,setMicPttActive:b,setSongNote:A,sendSong:R}}=_t(),{session:N,homeAssistantSetState:q}=ze(),{focusChat:j,blurChat:w,isChatFocused:E}=Jf(),{value:C}=Qe("inputs",En),M=m.useMemo(()=>AA(n.keymap),[n.keymap]),U=m.useMemo(()=>{const ie=new Set;return Object.values(M).forEach(oe=>{oe&&oe.forEach(ve=>ie.add(ve))}),ie},[M]),X=m.useMemo(()=>{const ie=En.keyboard,oe=C?.keyboard??{};return{baseSpeed:tf(oe.baseSpeed,ie.baseSpeed),turboSpeed:tf(oe.turboSpeed,ie.turboSpeed),precisionSpeed:tf(oe.precisionSpeed,ie.precisionSpeed)}},[C?.keyboard]),_=m.useMemo(()=>{const ie=En.keyboard,oe=C?.keyboard??{},ve=og(typeof oe.tiltSpeed=="number"?oe.tiltSpeed:typeof oe.tiltIntervalMs=="number"?BA(oe.tiltIntervalMs):ie.tiltSpeed,ie.tiltSpeed);return OA(ve)},[C?.keyboard]),K=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),B=m.useRef(new Set),z=m.useRef(Wu),Y=m.useRef(ef),te=m.useRef(null),fe=m.useRef(null),ce=m.useRef(!1),G=m.useCallback(()=>{const ie=new Set(B.current);ft(M.boostModifier,ie);const ve=ft(M.slowModifier,ie)?{baseSpeed:X.precisionSpeed,boostSpeed:X.precisionSpeed}:{baseSpeed:X.baseSpeed,boostSpeed:X.turboSpeed},ye=zA(ie,M),xe=UA(ie,M);(ye.x!==z.current.x||ye.y!==z.current.y||ye.boost!==z.current.boost)&&(z.current=ye,i(ye,{source:Pu,speedOptions:ve})),(xe.main!==Y.current.main||xe.side!==Y.current.side||xe.vacuum!==Y.current.vacuum)&&(Y.current=xe,o(xe)),h(Pu,{keys:Array.from(ie),vector:ye,aux:xe})},[M,X,h,o,i]),T=m.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),F=m.useCallback(()=>{const ie=new Set(B.current),oe=ft(M.cameraUp,ie),ve=ft(M.cameraDown,ie);return(oe?1:0)-(ve?1:0)},[M]),J=m.useCallback(()=>{if(F()===0){T();return}if(te.current)return;const oe=()=>{const ve=F();if(ve===0){T();return}f(ve*K),te.current=setTimeout(oe,_)};te.current=setTimeout(oe,0)},[F,f,_,K,T]),le=m.useCallback(()=>{fe.current&&(clearTimeout(fe.current),fe.current=null)},[]),de=m.useCallback(()=>{const ie=new Set(B.current),oe=ft(M.songNoteUp,ie),ve=ft(M.songNoteDown,ie);return(oe?1:0)-(ve?1:0)},[M]),k=m.useCallback(ie=>{if(ie===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:as)+ie;ve>H0?ve=U0:ve<U0&&(ve=H0);const ye=A(ve);R([{note:ye,duration:wf}],{slot:0})},[R,A,n.song?.note]),H=m.useCallback(()=>{if(de()===0){le();return}if(fe.current)return;const oe=()=>{const ve=de();if(ve===0){le();return}k(ve),fe.current=setTimeout(oe,cA)};fe.current=setTimeout(oe,0)},[de,le,k]),P=m.useCallback(()=>{B.current.clear(),z.current=Wu,Y.current=ef,T(),le(),ce.current&&(ce.current=!1,y()),b(!1),x(),h(Pu,{keys:[],vector:Wu,aux:ef})},[h,b,x,y,T,le]),ne=m.useCallback(ie=>{const oe=N?.homeAssistant;if(!oe?.enabled||!oe?.connected||oe?.lightPolicy?.lockedOn)return;const ye=(oe.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ye.length!==0){if(ie==="on"){const xe=ye.find(Ue=>Ue.state!=="on");xe&&q(xe.id,"on").catch(()=>{});return}if(ie==="off")for(let xe=ye.length-1;xe>=0;xe-=1){const Ue=ye[xe];if(Ue.state==="on"){q(Ue.id,"off").catch(()=>{});break}}}},[q,N?.homeAssistant]);m.useEffect(()=>{function ie(ye){if(z0()||LA(ye))return;const xe=_0(ye);if(xe.length===0)return;const Ue=new Set(xe);if(ft(M.chatFocus,Ue)){ye.preventDefault(),P(),E||j();return}xe.some(Ne=>U.has(Ne))&&ye.preventDefault();const $e=xe.filter(Ne=>!B.current.has(Ne));if($e.forEach(Ne=>B.current.add(Ne)),$e.length>0)if($e.some(Ne=>M.driveMacro?.has(Ne)))l("drive"),d("drive-sequence");else if($e.some(Ne=>M.dockMacro?.has(Ne)))l("dock"),d("seek-dock");else if($e.some(Ne=>M.nightVisionToggle?.has(Ne)))p();else if($e.some(Ne=>M.hornHonk?.has(Ne))){if(!ce.current){const Ne=g();ce.current=!!Ne}}else $e.some(Ne=>M.micPtt?.has(Ne))?b(!0):$e.some(Ne=>M.homeAssistantOn?.has(Ne))?ne("on"):$e.some(Ne=>M.homeAssistantOff?.has(Ne))&&ne("off");J(),H(),G()}function oe(ye){if(z0())return;_0(ye).forEach(Ue=>B.current.delete(Ue)),ce.current&&!ft(M.hornHonk,B.current)&&(ce.current=!1,y()),ft(M.micPtt,B.current)||b(!1),J(),H(),G()}function ve(){P()}return window.addEventListener("keydown",ie,{capture:!0}),window.addEventListener("keyup",oe,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",ie,{capture:!0}),window.removeEventListener("keyup",oe,{capture:!0}),window.removeEventListener("blur",ve)}},[U,w,G,J,H,j,E,M.chatFocus,M.dockMacro,M.driveMacro,M.hornHonk,M.micPtt,P,d,b,l,x,le,g,y,ne]);const pe=m.useRef(P);return m.useEffect(()=>{pe.current=P},[P]),m.useEffect(()=>{pe.current()},[n.roverId]),m.useEffect(()=>{ce.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{T(),le()},[T,le]),null}const VA=1.6;function cg(n){if(!n)return"unknown::none::0::0";const l=n.id||"unknown",i=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,f=Array.isArray(n.buttons)?n.buttons.length:0;return`${l}::${i}::${o}::${f}`}function $A(n){return JSON.parse(JSON.stringify(n??{}))}function ug(n,l){const i=$A(l);return i.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},i}function sl(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function oi(n,l){if(!n)return 0;const i=Math.abs(n);return l==="expo"?Math.sign(n)*Math.pow(i,VA):n}function nf(n,l){const i=Math.abs(n);if(i<=l)return 0;const o=(i-l)/(1-l);return Math.sign(n)*o}function GA(n,l,i){const o=Math.hypot(n,l);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:n*d,y:l*d}}function ro(n,l){if(!n||!Array.isArray(n.axes))return null;const i=n.axes[l];return Number.isFinite(i)?sl(i):null}function kf(n,l){if(!n||!Array.isArray(n.buttons))return null;const i=n.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 af(n,l=[]){for(const i of l)if(i){if(i.kind==="axis"){const o=ro(n,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=kf(n,i.index);if(!o)continue;return{value:sl(o.value),source:i}}}return{value:0,source:null}}function YA(n,l=[]){for(const i of l){if(!i||i.kind!=="axisPair")continue;const o=ro(n,i.x),f=ro(n,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,x=i.invertY?-f:f;return{x:d,y:x,source:i}}return{x:0,y:0,source:null}}function tl(n,l=[]){for(const i of l)if(i){if(i.kind==="button"){const o=kf(n,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=ro(n,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=kf(n,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function fg(n,l){const i=l?.bindings??{},o=l?.calibration??{},f=i.drive??{},d=YA(n,f.sources);let x=sl(d.x),h=sl(d.y);const p=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=GA(x,h,p);x=oi(g.x,o.driveCurve),h=oi(g.y,o.driveCurve);const y=i.cameraTilt??{},b=af(n,y.sources),A=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let R=nf(sl(b.value),A);R=oi(R,o.cameraCurve);const N=Math.min(Math.max(o.auxDeadzone??.05,0),.6),q=i.mainBrush??{},j=af(n,q.sources);let w=nf(sl(j.value),N);w=oi(w,o.auxCurve);const E=i.sideBrush??{},C=af(n,E.sources);let M=nf(sl(C.value),N);M=oi(M,o.auxCurve);const U=tl(n,i.vacuum?.sources),X=tl(n,i.allAux?.sources),_=tl(n,i.mainReverse?.sources),K=tl(n,i.sideReverse?.sources),B=tl(n,i.driveMacro?.sources),z=tl(n,i.dockMacro?.sources),Y=tl(n,i.nightVisionToggle?.sources);return{driveVector:{x,y:h,boost:!1},cameraAxis:R,auxAxis:{main:w,side:M},buttons:{vacuum:U.pressed,allAux:X.pressed,mainReverse:_.pressed,sideReverse:K.pressed,driveMacro:B.pressed,dockMacro:z.pressed,nightVisionToggle:Y.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:j.source,sideBrush:C.source,vacuum:U.source,allAux:X.source,mainReverse:_.source,sideReverse:K.source,driveMacro:B.source,dockMacro:z.source,nightVisionToggle:Y.source}}}const no=new Set;let ns=null,oo={pads:[],timestamp:0};function FA(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function XA(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0})),signature:cg(n)}}function QA(){oo={pads:FA().map(XA),timestamp:typeof performance<"u"?performance.now():Date.now()},no.forEach(l=>l(oo))}function dg(){QA(),ns=requestAnimationFrame(dg)}function KA(){ns||(ns=requestAnimationFrame(dg))}function ZA(){ns&&(cancelAnimationFrame(ns),ns=null)}function mg(n){return no.add(n),KA(),n(oo),()=>{no.delete(n),no.size===0&&ZA()}}function IA(){const[n,l]=m.useState(oo);return m.useEffect(()=>mg(l),[]),n}const Pl="gamepad",nl={x:0,y:0,boost:!1},al={main:0,side:0,vacuum:0},JA=100,PA=100;function lf(n,l){return n&&l&&n.x===l.x&&n.y===l.y&&n.boost===l.boost}function sf(n,l){return n&&l&&n.main===l.main&&n.side===l.side&&n.vacuum===l.vacuum}function WA(n){return n?Math.hypot(n.x||0,n.y||0):0}function ej(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function tj(n,l){if(!n||n.length===0)return null;if(l){const i=n.find(o=>o.signature===l);if(i)return i}return n[0]}function nj(){const{state:n,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:x,registerInputState:h}}=_t(),{value:p,save:g}=Qe("gamepad",Da),y=m.useRef(new Set),b=m.useRef(nl),A=m.useRef(al),R=m.useRef({main:!1,side:!1}),N=m.useRef(new Map),q=m.useRef(0),j=m.useRef(0),w=m.useRef(0),E=m.useRef(null),C=m.useCallback(_=>{const K=_.signature??cg(_);p?.profiles?.[K]||y.current.has(K)||(y.current.add(K),g(B=>{const z=B??Da;if(z.profiles?.[K])return z;const Y=z?.defaults?.profile??la,te=ug(_,Y);return{...z,profiles:{...z.profiles??{},[K]:te}}}))},[p?.profiles,g]),M=m.useCallback((_,K)=>{const B=N.current.get(_)||!1;return N.current.set(_,K),K&&!B},[]),U=m.useCallback((_,K)=>{const B=n.camera?.config;if(!B)return;const z=typeof performance<"u"?performance.now():Date.now(),Y=K?.cameraMode??"absolute",te=Math.max(1,Math.min(180,K?.cameraSensitivity??60));if(Y==="velocity"){const F=Math.min(50,z-w.current||16),J=_*te*(F/1e3);if(Math.abs(J)<.01)return;const de=(typeof E.current=="number"?E.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof B.homeAngle=="number"?B.homeAngle:0)+J;f(de),E.current=de,w.current=z;return}const fe=typeof B.minAngle=="number"?B.minAngle:-45,ce=typeof B.maxAngle=="number"?B.maxAngle:45,G=typeof B.homeAngle=="number"?B.homeAngle:(fe+ce)/2,T=_<0?G+_*(G-fe):G+_*(ce-G);typeof E.current=="number"&&Math.abs(E.current-T)<.35&&z-w.current<80||(w.current=z,E.current=T,f(T))},[f,n.camera?.angle,n.camera?.config]),X=m.useMemo(()=>p?.activeSignature??null,[p?.activeSignature]);return m.useEffect(()=>mg(_=>{const K=tj(_.pads,X);if(!K){lf(b.current,nl)||(b.current=nl,i(nl,{source:Pl})),sf(A.current,al)||(A.current=al,o(al)),N.current=new Map,R.current={main:!1,side:!1},q.current=0,j.current=0,h(Pl,{connected:!1});return}if(DA()){lf(b.current,nl)||(b.current=nl,i(nl,{source:Pl})),sf(A.current,al)||(A.current=al,o(al)),N.current=new Map,R.current={main:!1,side:!1},h(Pl,{connected:!0,blocked:!0});return}C(K);const B=K.signature,z=p?.profiles?.[B]??p?.defaults?.profile??la,Y=fg(K,z);if(!lf(Y.driveVector,b.current)){const J=typeof performance<"u"?performance.now():Date.now();(WA(Y.driveVector)<.02||J-q.current>=JA)&&(b.current=Y.driveVector,q.current=J,i(Y.driveVector,{source:Pl}))}const te=z.calibration?.auxSideScale??.55,fe=Math.round(Math.min(Math.abs(Y.auxAxis.main),1)*127),ce=Math.round(Math.min(Math.abs(Y.auxAxis.side),1)*127),G=R.current.main?-fe:fe,T=R.current.side?-Math.round(ce*te):Math.round(ce*te);let F={main:Y.auxAxis.main!==0?G:0,side:Y.auxAxis.side!==0?T:0,vacuum:Y.buttons.vacuum?127:0};if(Y.buttons.allAux&&(F={main:127,side:127,vacuum:127}),!sf(F,A.current)){const J=typeof performance<"u"?performance.now():Date.now();(ej(F)||J-j.current>=PA)&&(A.current=F,j.current=J,o(F))}Y.buttons.mainReverse&&M("mainReverse",!0)?R.current.main=!R.current.main:Y.buttons.mainReverse||M("mainReverse",!1),Y.buttons.sideReverse&&M("sideReverse",!0)?R.current.side=!R.current.side:Y.buttons.sideReverse||M("sideReverse",!1),Y.buttons.driveMacro&&M("driveMacro",!0)?(l("drive"),d("drive-sequence")):Y.buttons.driveMacro||M("driveMacro",!1),Y.buttons.dockMacro&&M("dockMacro",!0)?(l("dock"),d("seek-dock")):Y.buttons.dockMacro||M("dockMacro",!1),Y.buttons.nightVisionToggle&&M("nightVisionToggle",!0)?x():Y.buttons.nightVisionToggle||M("nightVisionToggle",!1),Math.abs(Y.cameraAxis)>.001&&U(Y.cameraAxis,z.calibration),h(Pl,{connected:!0,signature:B,id:K.id,index:K.index,axes:K.axes,buttons:K.buttons,drive:Y.driveVector,aux:F,cameraAxis:Y.cameraAxis,bindings:Y.sources})}),[X,C,p?.defaults?.profile,p?.profiles,M,U,h,d,o,i,l,x]),null}function hg(n){const l=n?.sensors||{},i=l.oiMode?.label||"Unknown",o=i.toLowerCase(),f=l.chargingState?.label||"",d=!!l.chargingSources?.homeBase,x=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:x,dockedNotCharging:d&&!x,dockingInProgress:!d&&!x&&o==="passive",oiLabel:i,chargingLabel:f}}function pg(n){const l=cs(n);return m.useMemo(()=>hg(l),[l])}function Wl({label:n,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 V0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function rf({label:n,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:n})}function aj({instructions:n,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:n.summary}),r.jsx(Mf,{steps:n.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 xg({layout:n="desktop",expand:l=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=n==="mobile",{state:{roverId:x,keymap:h},actions:p}=_t(),g=cs(x),y=o??hg(g),{driving:b,docked:A,charging:R,dockingInProgress:N}=y,[q,j]=m.useState(null),[w,E]=m.useState(!1),[C,M]=m.useState(!1),U=!x||q!==null,X=!x||q!==null,_=bn(h?.driveMacro?.[0]),K=bn(h?.dockMacro?.[0]),B={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"]},z="Click this button to initate auto-dock.",Y={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=A?"Docked":"Undocked",fe=A?"good":"bad",ce=R?"Charging":A?"Charging in 5s":"—",G=R?"good":A?"warn":"bad",T=async()=>{if(!(!x||q)){j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},F=async()=>{if(!(!x||q)){E(!1),M(!1),j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(ue){alert(ue.message)}finally{j(null)}}},J=async()=>{if(!(!x||q)){j("dock");try{p.setMode("dock"),await p.runMacro("seek-dock")}catch(ue){alert(ue.message)}finally{j(null),E(!1),M(!1)}}},le=()=>{X||(M(!0),E(!0))},de="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",H="items-center justify-between",P="items-center justify-center",ne=d?"text-sm font-semibold":"",pe="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",ve="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=l||N,Ue=xe?"h-full flex-1":i?"flex-1":"",$e=d&&!xe?f:"",Ne=d&&!xe?P:H,ae=d&&!xe&&b&&A;if(!b&&!N)return r.jsxs("button",{type:"button",onClick:F,onContextMenu:ue=>ue.preventDefault(),disabled:U,className:`${de} ${Ue} ${$e} ${k} ${Ne} ${ne} ${pe}`,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&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[_?r.jsx(V0,{label:_}):null,r.jsx(rf,{label:"Click to start",tone:"emerald"})]}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:Y.summary}),r.jsx(Mf,{steps:Y.steps,tone:"emerald"})]}):null]}),xe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Wl,{label:"Dock",value:te,tone:fe}),r.jsx(Wl,{label:"Charge",value:ce,tone:G})]}):null]});if(N){const ue={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:U,onClick:T,onContextMenu:be=>be.preventDefault(),className:`${de} ${Ue} ${$e} ${k} ${Ne} ${ne} ${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"}),xe?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(rf,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?r.jsx("p",{className:"text-sm text-amber-50/90",children:ue.summary}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Wl,{label:"Dock",value:te,tone:fe}),r.jsx(Wl,{label:"Charge",value:ce,tone:G})]}),d?null:r.jsx(Mf,{steps:ue.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:X,onClick:le,onContextMenu:ue=>ue.preventDefault(),className:d?`flex w-full ${de} ${$e} ${k} ${Ne} ${ne} ${ae?ve:oe}`:`${de} ${Ue} ${k} ${H} ${ne} ${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:ae?"Docked!":"Dock and Charge"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[K?r.jsx(V0,{label:K}):null,r.jsx(rf,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&xe&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:z}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Wl,{label:"Dock",value:te,tone:fe}),r.jsx(Wl,{label:"Charge",value:ce,tone:G})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),C||!d&&w?r.jsx(aj,{instructions:B,pending:q==="dock",onCancel:()=>{M(!1),E(!1)},onConfirm:J}):null]})}function Mf({steps:n,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:n.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<n.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function of(n){return typeof n=="boolean"}function gg({nightVisionOn:n,disabled:l,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[x,h]=m.useState(of(n)?n:null);m.useEffect(()=>{of(n)&&h(n)},[n]);const p=of(x),g=p?x:!1,y=p?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",A=()=>{if(l)return;const N=p?!g:!0;h(N),i?.(N)},R=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:A,onContextMenu:N=>N.preventDefault(),disabled:l,"aria-pressed":g,className:R,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 cf(n){const l=Number(n);return!Number.isFinite(l)||l<=0?0:Math.min(5e3,Math.round(l))}function vg({disabled:n,onStart:l,onStop:i,keyLabel:o,active:f,heat:d=0,className:x="",defaultShowSettings:h=!0,showSettingsToggle:p=!1,compactSettings:g=!1}){const[y,b]=m.useState(!1),[A,R]=m.useState(h),{value:N,save:q}=Qe("horn",il),[j,w]=m.useState(N?.waveform||il.waveform),[E,C]=m.useState(()=>[...Array.isArray(N?.freqs)?N.freqs:il.freqs,0,0,0,0].slice(0,4).map(T=>cf(T)));m.useEffect(()=>{w(N?.waveform||il.waveform),Array.isArray(N?.freqs)&&C([...N.freqs,0,0,0,0].slice(0,4).map(G=>cf(G)))},[N?.freqs,N?.waveform]);const M=!!f,U=Math.max(0,Math.min(1,Number(d)||0)),X=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",M?"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",x].filter(Boolean).join(" "),[x,M]),_=()=>{n||y||(b(!0),l?.())},K=()=>{y&&(b(!1),i?.())};m.useEffect(()=>{!M&&y&&b(!1)},[M,y]);const B=j==="sine"?"sine":"saw",z=m.useCallback(G=>{const T=G.target.value==="sine"?"sine":"saw";w(T),q(F=>({...F??{},waveform:T}))},[q]),Y=m.useCallback((G,T)=>{C(F=>{const J=[...F];return J[G]=cf(T),q(le=>({...le??{},freqs:J})),J})},[q]),te=G=>{if(n)return;const T=G.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(G.preventDefault(),_())},fe=G=>{const T=G.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(G.preventDefault(),K())},ce=p?r.jsx("button",{type:"button",onClick:G=>{G.preventDefault(),R(T=>!T)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:A?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":y,onPointerDown:te,onPointerUp:fe,onPointerLeave:K,onPointerCancel:K,onContextMenu:G=>G.preventDefault(),onBlur:K,className:X,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${U*100}%, rgba(0,0,0,0) ${U*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${M?"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]}),ce,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${M?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:M?"Honk":"Hold"})]}),A?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:B,onChange:z,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:E.map((G,T)=>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:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:G,onChange:F=>Y(T,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))})]}):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:B,onChange:z,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"})]})]}),E.map((G,T)=>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:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:G,onChange:F=>Y(T,F.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))]}):null]})}function Yr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function $0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function yg({value:n,min:l,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:x,onCommit:h,throttleMs:p=0,disabled:g=!1,keyDownLabel:y,keyUpLabel:b,className:A="",labelRowClass:R="",labelClass:N="",valueClass:q="",sliderClass:j="",endpointClass:w="",endpointLabelClass:E="",accentClass:C="",showValue:M=!0,showEndpoints:U}){const X=d==="vertical",K=typeof U=="boolean"?U:!X,[B,z]=m.useState(n),Y=m.useRef(!1),te=m.useRef(null);m.useEffect(()=>{Y.current||z(n)},[n]),m.useEffect(()=>()=>{te.current&&clearTimeout(te.current)},[]);const fe=J=>{if(x){if(p>0){te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{x(J)},p);return}x(J)}},ce=J=>{const le=Number.parseFloat(J.target.value);Number.isNaN(le)||(Y.current=!0,z(le),fe(le))},G=()=>{Y.current=!1,te.current&&(clearTimeout(te.current),te.current=null),h?h(B):p>0&&x?.(B)};if(typeof l!="number"||typeof i!="number")return null;const T=[X?"h-28 w-5":"w-full",C,j].filter(Boolean).join(" "),F=r.jsx("input",{type:"range",orient:X?"vertical":void 0,min:l,max:i,step:o,value:Number.isFinite(B)?B:l,onChange:ce,onMouseUp:G,onTouchEnd:G,onPointerUp:G,disabled:g,className:T,style:X?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return X?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${A}`.trim(),children:[M?r.jsx("div",{className:`flex flex-col items-center ${R}`.trim(),children:r.jsx("span",{className:q,children:Yr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:N,children:f}),F]})]}):r.jsxs("div",{className:`space-y-0.5 ${A}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${R}`.trim(),children:[r.jsx("span",{className:N,children:f}),M?r.jsx("span",{className:q,children:Yr(n)}):null]}),r.jsxs("div",{children:[F,K?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${w}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[y?r.jsx($0,{label:y}):null,Yr(l)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${E}`.trim(),children:[Yr(i),b?r.jsx($0,{label:b}):null]})]}):null]})]})}const Fr="mobile-joystick",lj=80,sj=.15,ij={main:0,side:0,vacuum:0},rj={main:127,side:127,vacuum:127},oj={main:-127,side:-127,vacuum:-127};function cj({disabled:n,layout:l,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),x=m.useRef(null),h=m.useRef({x:0,y:0}),[p,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),y=m.useCallback(()=>{x.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(q=>{if(n||x.current!==null)return;q.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=q.clientX-w.left,C=q.clientY-w.top;h.current={x:E,y:C},x.current=q.pointerId,j.setPointerCapture?.(q.pointerId),g({active:!0,base:{x:E,y:C},knob:{x:0,y:0}})},[n]),A=m.useCallback(q=>{if(n||x.current!==q.pointerId)return;q.preventDefault();const j=d.current;if(!j)return;const w=j.getBoundingClientRect(),E=q.clientX-w.left,C=q.clientY-w.top,M=E-h.current.x,U=C-h.current.y,X=Math.min(Math.hypot(M,U),i),_=Math.atan2(U,M),K=Math.cos(_)*X,B=Math.sin(_)*X,z={x:ss(K/i),y:ss(-B/i),boost:!1};g(Y=>({...Y,knob:{x:K,y:B}})),o?.(z)},[n,o]),R=m.useCallback(q=>{if(x.current!==q.pointerId)return;q.preventDefault(),d.current?.releasePointerCapture?.(q.pointerId),y()},[y]);return m.useEffect(()=>{n&&y()},[n,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:A,onPointerUp:R,onPointerLeave:R,onPointerCancel:R,onContextMenu:q=>q.preventDefault(),children:[!p.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"})]}),p.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:p.base.x,top:p.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:p.base.x+p.knob.x,top:p.base.y+p.knob.y}})]})]})}function uj({layout:n}){const{state:{roverId:l},actions:{setDriveVector:i,registerInputState:o}}=_t(),f=pg(l),d=f.docked&&!f.driving,x=d||f.dockingInProgress,h=!l,p=lj,g=sj,y=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{h&&(y.current={x:0,y:0,boost:!1})},[h]);const b=m.useCallback((q={})=>{if(h)return;const j={x:ss(q.x??0),y:ss(q.y??0),boost:!!q.boost},w={x:y.current.x+(j.x-y.current.x)*(1-g),y:y.current.y+(j.y-y.current.y)*(1-g),boost:j.boost};y.current=w,i(w,{source:Fr}),o(Fr,{vector:w,lastEvent:"move"})},[h,o,i,g]),A=m.useCallback(()=>{if(h)return;const q={x:0,y:0,boost:!1};y.current=q,i(q,{source:Fr}),o(Fr,{vector:q,lastEvent:"stop"})},[h,o,i]),N=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:N,children:[r.jsx(xg,{layout:"mobile",expand:x,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),x?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(cj,{disabled:h,layout:n,radius:p,onMove:b,onStop:A})})]})}function G0({id:n,label:l,values:i,color:o,disabled:f,onPress:d,onRelease:x}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:h=>{h.preventDefault(),d(n,i)},onPointerUp:()=>x(n),onPointerLeave:()=>x(n),onPointerCancel:()=>x(n),onContextMenu:h=>h.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:l})}function fj({layout:n}){const{state:{roverId:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:x,setAuxMotors:h,startHorn:p,stopHorn:g}}=_t(),y=!l,b=m.useRef(null),A=i?.config,R=!!(l&&i?.enabled&&A),N=!!(l&&f?.nightVision),q=f?.nightVisionState,j=!!(l&&f?.horn),w=o?.overheated,E=typeof A?.minAngle=="number"?A.minAngle:-45,C=typeof A?.maxAngle=="number"?A.maxAngle:45,M=typeof i?.angle=="number"?i.angle:typeof A?.homeAngle=="number"?A.homeAngle:(E+C)/2,U=m.useCallback(K=>{N&&x(K)},[N,x]),X=m.useCallback((K,B)=>{y||(b.current=K,h(B))},[y,h]),_=m.useCallback(K=>{y||b.current===K&&(b.current=null,h(ij))},[y,h]);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(G0,{id:"aux-vac-forward",label:"Vacuum Forward",values:rj,color:"bg-fuchsia-600",disabled:y,onPress:X,onRelease:_}),r.jsx(G0,{id:"aux-vac-backward",label:"Vacuum Backward",values:oj,color:"bg-fuchsia-800",disabled:y,onPress:X,onRelease:_})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[R?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(yg,{value:M,min:E,max:C,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,N?r.jsx(gg,{nightVisionOn:q?.nightVisionOn,disabled:y,onToggle:U,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:j?r.jsx(vg,{disabled:y||w,onStart:p,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function co({layout:n,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(fj,{layout:n})})}function uo({layout:n,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(uj,{layout:n==="landscape"?"landscape":"portrait"})})}function dj({swapColumns:n=!1}){const l="h-[min(60svh,24rem)]",i=n?r.jsx(uo,{layout:"portrait",className:l}):r.jsx(co,{layout:"portrait",className:l}),o=n?r.jsx(co,{layout:"portrait",className:l}):r.jsx(uo,{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 mj(n=[],l={}){const i=Rn(),{enabled:o=!0,version:f=null}=l,[d,x]=m.useState({}),h=m.useRef(new Map),p=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),g=m.useMemo(()=>{const N=p.join("|");return f?`${N}|v:${f}`:N},[p,f]),y=m.useRef([]),[b,A]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>A(q=>q+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=p},[g,p]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),x({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(E=>URL.revokeObjectURL(E)),h.current.clear(),x({});return}if(!y.current.length||!i)return;let N=!1;const q=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,U=Date.now(),X=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:X.count+1,totalBytes:X.totalBytes+M,lastLogAt:X.lastLogAt};if(!_.lastLogAt||U-_.lastLogAt>=1e4){const Y=_.count?_.totalBytes/_.count:0;console.log("[roomCamera]",E.id,`frame=${M}B`,`avg=${Math.round(Y)}B`,`count=${_.count}`),_.lastLogAt=U}R.current.set(E.id,_);const K=new Blob([C],{type:"image/jpeg"}),B=URL.createObjectURL(K),z=h.current.get(E.id);z&&URL.revokeObjectURL(z),h.current.set(E.id,B),x(Y=>({...Y,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:B}}))},w=(E={})=>{N||!E.id||x(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",j),i.on("roomCamera:status",w),i.emit("roomCamera:subscribe",{ids:q},(E={})=>{E.error}),()=>{N=!0,i.emit("roomCamera:unsubscribe",{ids:q}),i.off("roomCamera:frame",j),i.off("roomCamera:status",w),h.current.forEach(E=>URL.revokeObjectURL(E)),h.current.clear()}},[i,g,o,b]),d}function hj({feed:n,label:l}){const[i,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(d=>!d))},[n?.ts,n?.objectUrl]);const f=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?r.jsx("img",{src:n.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 pj(){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 bg=["horizontal","vertical"];function uf(n,l){return bg.includes(n)?n:l}function ed({defaultOrientation:n="horizontal",orientation:l,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=ze(),x=d?.roomCameras||[],h=mj(x.map(j=>({id:j.id}))),{value:p,save:g}=Qe("roomCameraPanels",{}),[y,b]=m.useState(()=>uf(f?p?.[f]:n,"horizontal"));m.useEffect(()=>{if(!f)return;const j=p?.[f];j&&b(uf(j,"horizontal"))},[f,p?.[f]]);const A=l?uf(l,"horizontal"):y,R=A==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",N=!i&&!l&&x.length>0,q=j=>{b(j),f&&g(w=>({...w||{},[f]:j}))};return x.length===0?r.jsx(pj,{}):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:x.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:N&&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:bg.map(j=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${A===j?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>q(j),children:j==="vertical"?"Vertical":"Grid"},j))})]})})]}),r.jsx("div",{className:R,children:x.map(j=>{const w=h[j.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(hj,{feed:w,label:j.name||j.id})},j.id)})})]})}function td(){const{logs:n}=ze();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:n.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?r.jsx("p",{children:"No logs yet."}):n.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 xj(n){if(!n)return null;if(typeof n=="string"){const l=String(n).trim();return l?{type:"rover",id:l,key:l}:null}if(typeof n=="object"){if(n.type&&n.id){const l=String(n.id);let i=n.key;return i||(i=n.type==="room"?`room:${l}`:l),{type:n.type,id:l,key:i}}if(n.roverId){const l=String(n.roverId);return{type:"rover",id:l,key:n.key||l}}if(n.roomCameraId){const l=String(n.roomCameraId);return{type:"room",id:l,key:n.key||`room:${l}`}}}return null}function gj(n=[]){const l=new Set,i=[];return n.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 vi(n=[],l={}){const i=Rn(),{enabled:o=!0,version:f=null}=l,[d,x]=m.useState({}),h=m.useMemo(()=>Array.isArray(n)?gj(n.map(xj).filter(Boolean)):[],[n]),p=m.useMemo(()=>{const R=h.map(N=>`${N.type}:${N.id}:${N.key}`).join("|");return f?`${R}|v:${f}`:R},[h,f]),g=m.useRef([]),[y,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const R=()=>b(N=>N+1);return i.on("connect",R),()=>{i.off("connect",R)}},[i]),m.useEffect(()=>{g.current=h},[h]),m.useEffect(()=>{if(!p||!o){x({});return}const R=g.current;let N=!1;function q(j){const w=j.type==="room"?{roomCameraId:j.id}:{roverId:j.id};i.emit("video:request",w,(E={})=>{N||x(C=>({...C,[j.key]:E}))})}return R.forEach(j=>{q(j)}),()=>{N=!0}},[i,p,o,y]),m.useMemo(()=>{if(!p||!o)return{};const R={};return h.forEach(N=>{d[N.key]&&(R[N.key]=d[N.key])}),R},[p,d,h])}function nd(n=[],l={}){const i=Rn(),{enabled:o=!0,version:f=null}=l,[d,x]=m.useState({}),h=m.useRef(new Map),p=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),g=m.useMemo(()=>{const N=p.join("|");return f?`${N}|v:${f}`:N},[p,f]),y=m.useRef([]),[b,A]=m.useState(0),R=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const N=()=>A(q=>q+1);return i.on("connect",N),()=>i.off("connect",N)},[i]),m.useEffect(()=>{y.current=p},[g,p]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),x({})},[g]),m.useEffect(()=>{if(!o){h.current.forEach(E=>URL.revokeObjectURL(E)),h.current.clear(),x({});return}if(!y.current.length||!i)return;let N=!1;const q=y.current,j=(E={},C)=>{if(N||!E.id||!C)return;const M=C.byteLength??C.length??0,U=Date.now(),X=R.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:X.count+1,totalBytes:X.totalBytes+M,lastLogAt:X.lastLogAt};if(!_.lastLogAt||U-_.lastLogAt>=1e4){const Y=_.count?_.totalBytes/_.count:0;console.log("[roverSnapshot]",E.id,`frame=${M}B`,`avg=${Math.round(Y)}B`,`count=${_.count}`),_.lastLogAt=U}R.current.set(E.id,_);const K=new Blob([C],{type:"image/jpeg"}),B=URL.createObjectURL(K),z=h.current.get(E.id);z&&URL.revokeObjectURL(z),h.current.set(E.id,B),x(Y=>({...Y,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:B}}))},w=(E={})=>{N||!E.id||x(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",j),i.on("roverSnapshot:status",w),i.emit("roverSnapshot:subscribe",{ids:q},(E={})=>{E.error}),()=>{N=!0,i.emit("roverSnapshot:unsubscribe",{ids:q}),i.off("roverSnapshot:frame",j),i.off("roverSnapshot:status",w),h.current.forEach(E=>URL.revokeObjectURL(E)),h.current.clear()}},[i,g,o,b]),d}const vj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function yj(n){if(typeof btoa=="function")return btoa(n);if(typeof Buffer<"u")return Buffer.from(n).toString("base64");throw new Error("No base64 encoder available")}function bj(n){if(!n)return{};const l=`${n}:${n}`;return{Authorization:`Basic ${yj(l)}`}}class Y0{constructor({url:l,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:x=!0}){this.url=l,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=x,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(vj);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",...bj(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(x=>{"playoutDelayHint"in x&&(x.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 qf({sensors:n={},variant:l="full",size:i,overlay:o=!1}){const f=i||(l==="mini"?190:260),d=f/2,x=f*.07,h=d,p=d+x,g=d*.8,y=g-4,b=g+4,A=g-14,R=g-6,N=g*.65,q=n?.bumpsAndWheelDrops||{},j=n?.wheelOvercurrents||{},w=n?.wheelLeftCurrentMa??0,E=n?.wheelRightCurrentMa??0,C=n?.sideBrushCurrentMa??0,M=n?.mainBrushCurrentMa??0,U=6,X=q.bumpLeft?U:0,_=q.bumpRight?U:0,K=Ej({count:6,totalSpan:140,gap:6,startAngle:-70}),B=["L","FL","CL","CR","FR","R"],z=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],Y=K.map((G,T)=>({label:B[T],start:G.start,end:G.end,value:z[T]})),te=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],fe=z.filter(G=>G!=null),ce=fe.length?Math.max(...fe,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",ce]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:h,cy:p,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(F0,{cx:h-N,cy:p,current:w,drop:q.wheelDropLeft,overcurrent:j.leftWheel,label:"L"}),r.jsx(F0,{cx:h+N,cy:p,current:E,drop:q.wheelDropRight,overcurrent:j.rightWheel,label:"R"}),r.jsx(jj,{cx:h+g*.65,cy:p-g*.55,current:C,overcurrent:j.sideBrush}),r.jsx(Nj,{cx:h,cy:p,current:M,overcurrent:j.mainBrush,variant:l,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),Y.map(G=>{const T=wj(G.value,ce),F=b+4,J=F+28;return r.jsx(Sj,{cx:h,cy:p,rBase:J,rTip:F,startDeg:G.start,endDeg:G.end,color:T,value:G.value,max:ce},G.label)}),te.map(G=>{const T=Cj(G.value,G.active);return r.jsx(ff,{cx:h,cy:p,rInner:A,rOuter:R,startDeg:G.start,endDeg:G.end,color:T,opacity:1,pulse:!!G.active},G.label)}),r.jsx(ff,{cx:h,cy:p,rInner:y-X,rOuter:b-X,startDeg:-70,endDeg:-6,color:q.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!q.bumpLeft}),r.jsx(ff,{cx:h,cy:p,rInner:y-_,rOuter:b-_,startDeg:6,endDeg:70,color:q.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!q.bumpRight})]})]})}function ff({cx:n,cy:l,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:x,pulse:h=!1,opacity:p=1}){const g=(i+o)/2,y=o-i,b=Aj(n,l,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:x,strokeWidth:y,strokeLinecap:"round",fill:"none",opacity:p}),h?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:y,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function Sj({cx:n,cy:l,rBase:i,rTip:o,startDeg:f,endDeg:d,color:x,value:h,max:p}){const g=(f+d)/2,y=mi(n,l,o,g),b=yo(h!=null?h/(p||1):0),A=Math.pow(b,.35),R=i-(i-o)*A,N=mi(n,l,R,f),q=mi(n,l,R,d),j=`M ${y.x} ${y.y} L ${N.x} ${N.y} L ${q.x} ${q.y} Z`;return r.jsx("path",{d:j,fill:x,opacity:1,stroke:"none"})}function Aj(n,l,i,o,f){let d=o,x=f;x<=d&&(x+=360);const h=mi(n,l,i,d),p=mi(n,l,i,x);return["M",h.x,h.y,"A",i,i,0,0,1,p.x,p.y].join(" ")}function mi(n,l,i,o){const f=Sg(o);return{x:n+i*Math.cos(f),y:l+i*Math.sin(f)}}function Sg(n){return(n-90)*Math.PI/180}function ad(n,l){if(l)return"#ef4444";const i=Math.abs(n);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function yo(n){return Math.max(0,Math.min(1,n))}function F0({cx:n,cy:l,current:i,drop:o,overcurrent:f,label:d}){const x=Math.abs(i),h=yo(x/1200),p=ad(i,f),g=56,y=14,b=9,A=3,R=g*h,N=d==="L"?-1:1,q=N*(-b/2-A/2),j=N*(y/2+A/2),w=y+b+A+2,E=g+4;return r.jsxs("g",{transform:`translate(${n},${l})`,children:[r.jsx("rect",{x:-w/2,y:-E/2,width:w,height:E,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:q-y/2,y:-g/2,width:y,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:q-y/2,y:g/2-R,width:y,height:R,fill:p,className:f?"animate-pulse":""}),r.jsx("rect",{x:j-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function jj({cx:n,cy:l,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=ad(i*3,o),x=43,h=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${l}px`,animation:h?`spin ${h}s linear infinite`:"none",animationDirection:h?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:l,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const y=Sg(g),b=n+x*Math.cos(y),A=l+x*Math.sin(y);return r.jsx("line",{x1:n,y1:l,x2:b,y2:A,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:l,r:x+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function Nj({cx:n,cy:l,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:x}){const h=Math.abs(i),p=ad(i,o),g=1,y=96,b=12,A=`main-brush-pattern-a-${f}`,R=`main-brush-pattern-b-${f}`,N=h>0?.6:null,q=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[A,R].map((j,w)=>r.jsxs("pattern",{id:j,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:p,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),N?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${q*(w===0?6:-6)}`,dur:`${N}s`,repeatCount:"indefinite"}):null]},j))}),r.jsx("rect",{x:n-y/2,y:l-14,width:y,height:b,rx:"3",fill:`url(#${A})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-y/2,y:l+4,width:y,height:b,rx:"3",fill:`url(#${R})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-y/4,cy:l-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+y/4,cy:l+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-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 wj(n,l){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=yo(n/(l||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function Cj(n,l){if(l)return"#ef4444";const i=yo(n==null?0:n/4095),o=[47,55,69],f=[245,158,11],[d,x,h]=o.map((p,g)=>Math.round(p+(f[g]-p)*i));return`rgb(${d}, ${x}, ${h})`}function Ej({count:n,totalSpan:l,gap:i,startAngle:o}){const d=(l-i*(n-1))/n,x=[];let h=o;for(let p=0;p<n;p+=1){const g=h+d;x.push({start:h,end:g}),h=g+i}return x}function Ag(){const{value:n,save:l}=Qe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,f=>{l({hudMapDesktop:!!f})}]}const kj={discord:Px,kofi:k0,"ko-fi":k0,wiki:WS,throne:eA},Mj={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 qj(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const l=document.createElement("style");l.id=n,l.textContent=`
@keyframes socialGradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
`,document.head.appendChild(l)},[])}function Rj(n,l){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof l=="string"&&l.trim()?l.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function ld({id:n,label:l,url:i,className:o=""}){if(!i)return null;qj();const f=Rj(n,l),d=kj[f]||tA,x=Mj[f]||null,h=l||n||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":h,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${x?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:x||void 0,children:[r.jsx(d,{className:"mr-0"}),h]})}const yi=10;function jg({batteryState:n=null,charge:l=null,config:i=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,f=n?.warnActive??null,d=n?.urgentActive??null,x=i?.Full??null,h=i?.Warn??null,p=i?.Urgent??null,g=l??n?.charge??null;let y=o;if(y==null&&(y=Tj({charge:g,full:x,warn:h,urgent:p})),y==null)return{available:!1};const b=Math.max(0,Math.min(1,y/100)),A=f??(h!=null&&g!=null&&g<=h),R=d??(p!=null&&g!=null&&g<=p);return{available:!0,percent:b,percentDisplay:y,warnActive:A,urgentActive:R,warnDisplayPercent:yi}}function Tj({charge:n,full:l,warn:i,urgent:o}){if(n!=null&&l!=null&&i!=null&&o!=null&&l>i&&i>o){const f=yi/100,d=1-f;if(n<=o)return 0;if(n<=i){const h=(n-o)/(i-o);return Math.round(Math.max(0,Math.min(1,h))*yi)}if(n>=l)return 100;const x=(n-i)/(l-i);return Math.round((f+Math.max(0,Math.min(1,x))*d)*100)}return null}const Dj=1600,_j=800;function vn(...n){return n.filter(Boolean).join(" ")}function Rf({visual:n,orientation:l="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const x=i==="background",h=l==="vertical",p=f??!x;if(!n?.available){if(x){const te=yi,fe=vn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),ce=h?{bottom:`${te}%`}:{left:`${te}%`},G=vn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:G,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:fe,style:ce})]})}return h?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,y=Math.max(0,Math.min(100,g)),b=n.warnDisplayPercent??yi,A=!!n.urgentActive,R=!!n.warnActive,N=A?`${_j}ms`:R?`${Dj}ms`:void 0,j=x?A||R?"bg-red-500/45":"bg-emerald-500/45":A||R?"bg-red-500":"bg-emerald-500",w=A||R?"bg-red-900/35":"bg-slate-900/35",E=A||R?"bg-red-900/45":"bg-slate-900/35",C=vn(x?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",h&&!x?"flex flex-col items-center justify-center":"w-full",d);if(x){const te=h?{height:`${y}%`}:{width:`${y}%`},fe=vn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",A&&"battery-urgent-flash"),ce=vn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),G=h?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:C,children:[r.jsx("div",{className:vn("absolute inset-0",w,A&&"battery-urgent-flash")}),r.jsx("div",{className:fe,style:{...te,animationDuration:N}}),r.jsx("div",{className:ce,style:G})]})}const M=vn("relative overflow-hidden rounded-sm border border-slate-800",A||R?E:"bg-zinc-900/90",A&&"battery-urgent-flash",h?"w-full flex-1":o?"h-4":"h-5"),U=h?{height:`${y}%`}:{width:`${y}%`},X=vn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",A&&"battery-urgent-flash"),_=vn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",R&&!A&&"battery-tick-warn"),K=h?{bottom:`${b}%`}:{left:`${b}%`},B=`Battery ${g}%`,z=vn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",h?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Y=vn("rounded px-1.5 py-0.5",x?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:C,children:[r.jsxs("div",{className:M,children:[r.jsx("div",{className:X,style:{...U,animationDuration:N}}),r.jsx("div",{className:_,style:K})]}),p&&!h?r.jsx("div",{className:z,children:r.jsx("span",{className:Y,children:B})}):null,p&&h?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:Y,children:[g,"%"]})}):null]})}const X0=2e3,Oj=3e3,Bj=3e3,Lj=40,zj=1e3;function bi({sessionInfo:n,audioSessionInfo:l,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,roverColor:x=null,forceMute:h=!1,telemetryFrame:p,batteryConfig:g,layoutFormat:y="desktop",hudVariant:b="default",driverLabel:A=null,hudForceMap:R=!1,hudMapPosition:N="top-center",hudLabelScale:q=1,fitParent:j=!1,overcurrentLimiter:w=null,showTurnCue:E=!1,turnTimerText:C=null,turnSeconds:M=null,isActiveDriver:U=!1,idleSkipSeconds:X=null}){const{session:_}=ze(),K=m.useRef(null),B=m.useRef(null),z=m.useRef(null),Y=m.useRef(null),te=m.useRef(null),fe=m.useRef(null),ce=m.useRef(null),G=m.useRef(null),[T,F]=m.useState("idle"),[J,le]=m.useState(null),[de,k]=m.useState("idle"),[H,P]=m.useState(null),[ne,pe]=m.useState(0),[ie,oe]=m.useState(0),[ve,ye]=m.useState(!0),xe=!!l?.url,Ue=i==="snapshot",$e=p?.sensors,{value:Ne}=Qe("audio",Dt),ae=Number.isFinite(Ne?.masterVolume)?Ne.masterVolume:Dt.masterVolume,ue=Number.isFinite(Ne?.roverVolume)?Ne.roverVolume:Dt.roverVolume,be=typeof Ne?.mainBrushDuckEnabled=="boolean"?Ne.mainBrushDuckEnabled:typeof Ne?.autoLevelEnabled=="boolean"?Ne.autoLevelEnabled:Dt.mainBrushDuckEnabled,Me=Number.isFinite(Ne?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ne.mainBrushDuckAmount)):Dt.mainBrushDuckAmount,se=Math.max(0,Math.min(1,ae*ue)),re=$e?.batteryChargeMah??null,me=y==="desktop",we=!me,et=we?"top-right":N,[dt]=Ag(),Le=R||we?!0:dt,xt=jg({charge:re,config:g}),mt=$e?.wheelOvercurrents||null,Tn=mt==null?[]:Object.entries(mt).filter(([,Ae])=>!!Ae).map(([Ae])=>Ae),Et=w?.caps||null,cl=w?.overcurrent?.groups||null,Gt=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),Oa=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),Co=m.useMemo(()=>{if(!Et)return null;const Ae=Number.isFinite(Et?.drive?.cap)?Et.drive.cap:1,Ke=Number.isFinite(Et?.aux?.cap)?Et.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(Ae,Ke)))},[Et]),Dn=!!w?.isActive,At=Tn.length?Tn:Dn?["limiter"]:[],Yt=Co??(Tn.length?1:0),kt=!!At.length,ca=!!((Number($e?.mainBrushCurrentMa)||0)>Lj||$e?.wheelOvercurrents?.mainBrush),Eo=be&&ca?1-Me:1,ul=Math.max(0,Math.min(1,se*Eo)),fl=be&&ca&&Me>0?`Volume decreased ${Math.round(Me*1e3)/10}%`:null,Ba=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ba.current={hasDedicatedAudio:xe,audioUrl:l?.url||null,mainBrushDuckEnabled:be,mainBrushDuckAmount:Me,mainBrushActive:ca,baseRoverGain:se,effectiveRoverGain:ul}},[xe,l?.url,be,Me,ca,se,ul]);const tt=m.useCallback((Ae,Ke={})=>{if(!Gt)return;const Pe=B.current,qe=Ba.current,Ye={event:Ae,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:qe.hasDedicatedAudio,audioUrl:qe.audioUrl,mainBrushDuckEnabled:qe.mainBrushDuckEnabled,mainBrushDuckAmount:qe.mainBrushDuckAmount,mainBrushActive:qe.mainBrushActive,baseRoverGain:qe.baseRoverGain,effectiveRoverGain:qe.effectiveRoverGain,element:Pe?{muted:Pe.muted,volume:Pe.volume,paused:Pe.paused,ended:Pe.ended,readyState:Pe.readyState,networkState:Pe.networkState}:null,...Ke};try{console.log(`[AudioDebug] ${Ae} ${JSON.stringify(Ye)}`)}catch{console.log("[AudioDebug]",Ae,Ye)}},[Gt,d]),_n=_?.socials?.find(Ae=>String(Ae?.id||Ae?.label||"").toLowerCase()==="discord")?.url||_?.discord?.invite||null;m.useEffect(()=>{Oa&&console.log("[OvercurrentHUD]",{overlayVisible:kt,overlayMotors:At,overlayFill:Yt,limiterActive:Dn,limiterCaps:Et,limiterGroups:cl,wheelOvercurrents:mt})},[Oa,Yt,At,kt,Dn,Et,cl,mt]),m.useEffect(()=>{tt("settings/update")},[tt]);const An=m.useCallback(()=>{clearTimeout(z.current),z.current=setTimeout(()=>pe(Date.now()),X0)},[]),On=m.useCallback(()=>{clearTimeout(Y.current),Y.current=setTimeout(()=>oe(Date.now()),X0)},[]),dl=m.useCallback(async()=>{const Ae=K.current;if(Ae)try{Ae.muted=!0,await Ae.play()}catch{}},[]),us=m.useCallback((Ae=0)=>{if(h||xe)return;clearTimeout(fe.current);const Ke=()=>{clearTimeout(fe.current),fe.current=setTimeout(()=>{h||Pe()},Oj)},Pe=async()=>{const qe=K.current;if(qe)try{await dl(),qe.muted=!1,await qe.play(),ye(!1)}catch{qe.muted=!0,ye(!0),Ke()}};fe.current=setTimeout(Pe,Ae)},[dl,h,xe]);m.useEffect(()=>()=>{clearTimeout(z.current),clearTimeout(Y.current),clearTimeout(fe.current),clearInterval(te.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{T==="playing"&&us(0)},[T,us]),m.useEffect(()=>{Ue&&(F("snapshot"),le(null))},[Ue]),m.useEffect(()=>{if(Ue||!n?.url||!K.current)return;let Ae=!0,Ke;const Pe=setTimeout(()=>ye(!0),0),qe=(Ye,it)=>{Ae&&(tt("video/status",{nextStatus:Ye,info:it||null}),F(Ye),le(it||null),Ye==="playing"&&dl(),["error","failed","disconnected","closed"].includes(Ye)&&An())};return Ke=new Y0({url:n.url,token:n.token,video:K.current,receiveAudio:!xe,onStatus:qe}),Ke.start().catch(Ye=>{Ae&&(F("error"),le(Ye.message),An())}),()=>{Ae=!1,clearTimeout(Pe),Ke?.stop()}},[Ue,n?.url,n?.token,ne,An,dl,xe,tt]),m.useEffect(()=>{T==="stopped"&&n?.url&&An()},[T,n?.url,An]),m.useEffect(()=>{const Ae=B.current;if(!Ae||!l?.url){tt("route/no-audio-url"),G.current=null;return}const Ke=Math.max(0,Math.min(1,ul)),Pe=G.current==null?Math.max(0,Math.min(1,Ae.volume)):G.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),Ke>Pe){const qe=performance.now(),Ye=Pe,it=Ke-Ye,rt=jt=>{const lt=Math.min(1,(jt-qe)/zj),Bn=Ye+it*lt;Ae.volume=Bn,G.current=Bn,lt<1?ce.current=requestAnimationFrame(rt):ce.current=null};ce.current=requestAnimationFrame(rt)}else Ae.volume=Ke,G.current=Ke;tt("route/direct",{elementVolume:Ke,duckEnabled:be,mainBrushActive:ca,duckAmount:Me})},[l?.url,ul,be,ca,Me,tt]),m.useEffect(()=>{if(!l?.url||!B.current)return;let Ae=!0,Ke;const Pe=(qe,Ye)=>{Ae&&(tt("audio/status",{nextStatus:qe,info:Ye||null}),P(Ye||(qe==="connected"?"connected":null)),k(it=>qe==="connected"&&(it==="playing"||it==="connecting")||qe==="new"?it:qe),["error","failed"].includes(qe)&&On())};return Ke=new Y0({url:l.url,token:l.token,video:B.current,audioOnly:!0,onStatus:Pe}),Ke.start().catch(qe=>{Ae&&(k("error"),P(qe.message),On())}),()=>{Ae=!1,Ke?.stop()}},[l?.url,l?.token,ie,On,tt]),m.useEffect(()=>{const Ae=B.current;if(!l?.url||!Ae){clearInterval(te.current);return}if(!["connecting","connected","playing","paused"].includes(de)){clearInterval(te.current);return}const Pe=async()=>{const qe=B.current;qe&&(qe.muted=!1,!(!qe.paused&&!qe.ended)&&(tt("retry/play-attempt"),qe.play().then(()=>{tt("retry/play-ok"),k(Ye=>Ye==="connected"?"playing":Ye),P(Ye=>Ye==="paused"?null:Ye)}).catch(Ye=>{tt("retry/play-fail",{error:Ye?.message}),P(it=>it||Ye?.message||"autoplay blocked")})))};return Pe(),te.current=setInterval(Pe,Bj),()=>clearInterval(te.current)},[l?.url,de,tt]),m.useEffect(()=>{const Ae=B.current;if(!Ae)return;const Ke=()=>{tt("element/play"),k(lt=>lt==="error"?lt:"playing"),P(null)},Pe=()=>{tt("element/pause"),k(lt=>["error","failed","disconnected","closed","stopped"].includes(lt)?lt:"paused"),P(lt=>lt||"paused")},qe=()=>{tt("element/ended"),k(lt=>lt==="error"?lt:"stopped"),P(lt=>lt||"ended")},Ye=()=>{const{error:lt}=Ae,Bn=lt?.message||"audio error";tt("element/error",{error:Bn}),k("error"),P(Bn)},it=()=>tt("element/waiting"),rt=()=>tt("element/canplay"),jt=()=>tt("element/stalled");return Ae.addEventListener("play",Ke),Ae.addEventListener("pause",Pe),Ae.addEventListener("ended",qe),Ae.addEventListener("error",Ye),Ae.addEventListener("waiting",it),Ae.addEventListener("canplay",rt),Ae.addEventListener("stalled",jt),()=>{Ae.removeEventListener("play",Ke),Ae.removeEventListener("pause",Pe),Ae.removeEventListener("ended",qe),Ae.removeEventListener("error",Ye),Ae.removeEventListener("waiting",it),Ae.removeEventListener("canplay",rt),Ae.removeEventListener("stalled",jt)}},[l?.url,tt]);const fs=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",La=Ue?fs:n?.url?T==="error"?`Error: ${J||"unknown"}`:J?`${T} (${J})`:T:"waiting",ko=l?.error?`Error: ${l.error}`:l?.url?de==="error"?`Error: ${H||"unknown"}`:H?`${de} (${H})`:de:null,ds=b==="spectator",en=b==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${j?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${j?"h-full flex-1":"aspect-[4/3]"}`,children:[Ue?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:K,muted:h||ve||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:B,autoPlay:!0,hidden:!0}),!en&&E?r.jsx(Vj,{mobileHud:we,turnSeconds:M,isActiveDriver:U,idleSkipSeconds:X}):null,en?null:r.jsx(Hj,{frame:p,sensors:$e,label:d,roverColor:x,status:La,audioStatus:ko,levelStatus:fl,desktopLayout:me,layoutFormat:y,variant:b,driverLabel:A,battery:xt,showTopDown:Le,mobileHud:we,mapPosition:et,turnTimerText:C,labelScale:q}),en?null:r.jsx(Fj,{compact:we}),!en&&Oa?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:${kt?1:0} motors:${At.length} fill:${Math.round(Yt*100)}%`}):null,en?null:r.jsx(Gj,{motors:At,fill:Yt,compact:we}),en?null:r.jsx(Yj,{battery:xt,compact:we}),!en&&ds&&xt.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(Rf,{visual:xt,orientation:"vertical",variant:"inline",compact:we,className:"h-full w-4"})}):null,!en&&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 ${we?"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(ld,{id:"discord",label:"Join our Discord server while you wait!",url:_n})})]})}):null]}),!en&&!ds&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Uj,{sensors:$e}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Rf,{visual:xt,compact:we})})]})]})}function Uj({sensors:n}){const l=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],i=l.filter(h=>h!=null).reduce((h,p)=>Math.max(h,p),1200),o=h=>Math.pow(Math.max(0,Math.min(1,(h??0)/i)),.35),f=h=>h==null||h<=0?"hsl(200 60% 18%)":`hsl(${(200+o(h)*360)%360} 100% 60%)`,d=6,x=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:l.map((h,p)=>{const g=o(h),y=p<d/2?-1:1,b=`${g*100}%`,A=f(h);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${x}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:A,float:y===-1?"right":"left"}})})},p)})})}function Hj({frame:n,sensors:l,label:i,roverColor:o=null,status:f,audioStatus:d,levelStatus:x,desktopLayout:h=!0,layoutFormat:p="desktop",variant:g="default",driverLabel:y=null,battery:b,showTopDown:A=!1,mobileHud:R=!1,mapPosition:N="top-center",turnTimerText:q=null,labelScale:j=1}){l?.bumpsAndWheelDrops;const[w,E]=m.useState(()=>Date.now());m.useEffect(()=>{const le=setInterval(()=>E(Date.now()),150);return()=>clearInterval(le)},[]),n?.receivedAt&&w-n.receivedAt<200;const C=R,M=p==="mobile-portrait",U=C?"text-[0.45rem]":"text-[0.65rem]",X=C?"px-0.25 py-0.25":"px-1 py-0.5",_=C?"px-0.25 py-0.25":"px-0.5 py-0.5",K=C?"text-[0.55rem]":"text-[0.8rem]",B=C?"left-0.5 top-0.5":"left-1 top-1",z=C?"text-[0.5rem]":"text-[0.7rem]",Y=C?"px-0.5 py-0.25":"px-1 py-0.5",te=C?"left-0.5 top-1/2":"left-1 top-1/2",fe="bottom-0.5",ce={transform:`translateX(-50%) scale(${j})`,transformOrigin:"center bottom"},G="240px",T=M?.3:C?.33:.7,J={width:G,height:G,opacity:C?.6:.7,transform:N==="top-center"?`translateX(-50%) scale(${T})`:`scale(${T})`,transformOrigin:N==="bottom-left"?"bottom left":N==="top-center"?"top center":"top right",...N==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:N==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(g==="none")return null;if(g==="spectator"){const le=[["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||"--"]],de=!!l?.chargingSources?.homeBase,k=l?.chargingState?.label||"",H=!!(k&&k.toLowerCase()!=="not charging"),P=l?.oiMode?.label||"Unknown",ne=P.toLowerCase(),pe=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",ie=de?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",oe=H?"bg-emerald-500/80 text-emerald-50":de?"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 ${B} font-medium text-slate-100 ${U}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,x?r.jsx("span",{className:"text-cyan-300",children:x}):null]})}),r.jsx("div",{className:`absolute ${te} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${U} ${X}`,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 ${ie}`,children:de?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${oe}`,children:H?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${pe}`,children:["OI: ",P]})]}),le.map(([ve,ye])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ve}),r.jsx("span",{className:"font-semibold text-white",children:ye})]},ve))]})}),r.jsx("div",{className:`absolute ${fe} left-1/2`,style:ce,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${_} ${K}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:i||"Unnamed Rover"}),y?r.jsxs("span",{className:"text-slate-300",children:["• ",y]}):null]})})]}),A?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(qf,{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 ${B} font-medium text-slate-100 ${U}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,x?r.jsx("span",{className:"text-cyan-300",children:x}):null]})}),q?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${Y} ${z}`,children:q}):null,r.jsx("div",{className:`absolute ${fe} left-1/2`,style:ce,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${_} ${K}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(o,.18),children:['"',i||"Unnamed Rover",'"']})]})})}),A&&g!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:r.jsx(qf,{sensors:l,size:240,overlay:!0})}):null]})}function Vj({mobileHud:n=!1,turnSeconds:l=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=n?"text-3xl":"text-5xl",d=n?"text-xs":"text-sm",x=n?"text-[0.55rem]":"text-[0.75rem]",h=n?"px-4 py-3":"px-6 py-4",p=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 ${h}`,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!"}),p?r.jsxs("div",{className:`text-red-100/90 ${x}`,children:["Idle skip in ",o,"s"]}):null]})})}const $j={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Gj({motors:n,fill:l=0,compact:i=!1}){if(!n?.length)return null;const o=n.map(y=>$j[y]||y),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",x=i?"text-lg":"text-4xl",h=i?"text-xs":"text-xl",p=Math.max(0,Math.min(1,l)),g=`${Math.round(p*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 ${x} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${h}`,children:o.join(", ")})]})]})})}function Yj({battery:n,compact:l=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const i=n.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 Fj({compact:n=!1}){const{session:l}=ze(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:x,setTypingActive:h}=Jf(),{value:p}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[g,y]=m.useState(""),[b,A]=m.useState(!1),R=l?.role!=="spectator",N=l?.role==="spectator",q=l?.assignment?.roverId||null,w=!!m.useMemo(()=>l?.roster?.find(_=>String(_.id)===String(q))||null,[q,l?.roster])?.audio?.ttsEnabled,E=m.useMemo(()=>{if(!w)return null;const _=p?.engine==="espeak"?"espeak":"flite";if(_==="espeak"){let B=Number.isFinite(p?.pitch)?Math.round(p.pitch):void 0;return typeof B=="number"&&(B=Math.max(0,Math.min(99,B))),{speak:!0,engine:_,pitch:B}}const K=typeof p?.voice=="string"?p.voice:void 0;return{speak:!0,engine:_,voice:K}},[p?.engine,p?.pitch,p?.voice,w]),C=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",M=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",U=n?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function X(_){if(_.preventDefault(),!R)return;const K=g.trim();if(K){A(!0);try{await i(K,E),y(""),d(),h(!1)}catch(B){alert(B.message)}finally{A(!1)}}}return N?null:r.jsxs("form",{onSubmit:X,className:C,children:[r.jsx("input",{className:M,value:g,onChange:_=>{const K=_.target.value;y(K),h(!!K.trim())},onFocus:_=>{o(_),h(!!g.trim())},onBlur:_=>{f(_),h(!1)},onKeyDown:_=>{_.key==="Enter"&&!g.trim()&&(_.preventDefault(),d(),h(!1))},ref:_=>x(_,{target:"hud"}),placeholder:R?"Chat (TTS)":"Spectator",disabled:!R}),r.jsx("button",{type:"submit",disabled:!R||b,className:U,children:"Speak"})]})}function sd({layoutFormat:n="desktop"}){const{session:l}=ze(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=_t(),[d,x]=m.useState(()=>Date.now()),[h,p]=m.useState(!1),[g,y]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(l?.mode!=="turns")return;const ne=setInterval(()=>x(Date.now()),250);return()=>clearInterval(ne)},[l?.mode]);const A=l?.assignment?.roverId,N=!!(A&&l?.roster?l.roster.find(ne=>String(ne.id)===String(A)):null)?.media?.audioPublishUrl,q=A?l?.turnQueues?.[A]:null,j=l?.socketId||null,w=A?l?.activeDrivers?.[A]:null,E=!!(j&&w===j),C=m.useMemo(()=>{const ne=q?.queue||[];if(!ne.length||!q?.current||ne.length<=1)return null;const pe=ne.findIndex(ie=>ie===q.current);return pe===-1?ne[0]||null:ne[(pe+1)%ne.length]||null},[q?.queue,q?.current]),M=!!(j&&C===j),U=q?.deadline||null,X=q?.idleDeadline||null,_=U?U-d:null,K=X?X-d:null,B=l?.mode==="turns"&&M&&_!=null&&_<=5e3&&_>0,z=l?.mode!=="turns"||E||B,Y=_!=null&&Number.isFinite(_)?Math.max(0,Math.ceil(_/1e3)):null,te=K!=null&&Number.isFinite(K)?Math.max(0,Math.ceil(K/1e3)):null,fe=E?Y!=null?`${Y}s left`:null:M&&Y!=null?`Your turn in ${Y}s`:null,ce=A?[...z?[{type:"rover",id:A,key:A}]:[],...N?[{type:"rover",id:`${A}-audio`,key:`${A}-audio`}]:[]]:[],G=vi(ce),T=A&&z?G[A]:null,F=A&&N?G[`${A}-audio`]:null,J=nd(A?[A]:[],{enabled:!!A,version:l?.mode}),le=A&&J[A]||null,de=cs(A),k=A&&l?.roster?l.roster.find(ne=>String(ne.id)===String(A)):null,H=k?.battery??null,P=k?.name||(A?`Rover ${A}`:"");return m.useEffect(()=>{if(l?.mode!=="turns"){p(!1),y(null),b.current={active:!1,roverId:null};return}const ne=b.current,pe=E&&!ne.active,ie=E&&A&&A!==ne.roverId;pe||ie?(p(!0),y(Date.now())):!E&&ne.active&&(p(!1),y(null)),b.current={active:E,roverId:A}},[E,A,l?.mode]),m.useEffect(()=>{!h||!g||o>g&&p(!1)},[o,g,h]),r.jsx("section",{className:"panel",children:A?r.jsx(bi,{sessionInfo:T,videoMode:z?"whep":"snapshot",snapshotFeed:le,audioSessionInfo:F,label:P,roverColor:k?.color||null,telemetryFrame:de,batteryConfig:H,layoutFormat:n,overcurrentLimiter:f,songNote:i?.note,qualityNotice:z?null:"Preview feed (low FPS) until your turn.",showTurnCue:h,turnTimerText:fe,turnSeconds:Y,isActiveDriver:E,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 fo({label:n,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:n})}function bo(n){if(!Number.isFinite(n))return 0;const l=n%360;return l<0?l+360:l}function Xj(n){if(!Array.isArray(n)||n.length<3)return 0;const[l,i,o]=n,f=Math.max(0,Math.min(255,Number(l)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,x=Math.max(0,Math.min(255,Number(o)))/255,h=Math.max(f,d,x),p=Math.min(f,d,x),g=h-p;if(g===0)return 0;let y=0;return h===f?y=(d-x)/g%6:h===d?y=(x-f)/g+2:y=(f-d)/g+4,bo(Math.round(y*60))}function Q0(n){const l=bo(n),i=1,o=1-Math.abs(l/60%2-1);let f=0,d=0,x=0;return l<60?(f=i,d=o):l<120?(f=o,d=i):l<180?(d=i,x=o):l<240?(d=o,x=i):l<300?(f=o,x=i):(f=i,x=o),[Math.round(f*255),Math.round(d*255),Math.round(x*255)]}function K0(n){return n?Array.isArray(n.hsColor)?bo(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?Xj(n.rgbColor):0:0}function Qj({entity:n,connected:l,controlsLocked:i,onToggle:o,onSetColor:f}){const d=n.state==="unavailable"||!n.available,x=n.state==="on",h=n.type==="light"&&n.supportsColor,p=d?"warn":x?"success":"muted",g=d?"Unavailable":x?"On":"Off",y=i||!l||d,b=y||!h,[A,R]=m.useState(()=>K0(n)),N=m.useRef(A),q=m.useRef(!1),j=d?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":i?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":x?"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||q.current)return;const X=K0(n);N.current=X,R(X)},[n.rgbColor,n.hsColor,h]);const w=X=>{const _=bo(Number(X.target.value));N.current=_,R(_)},E=()=>{b||!f||f(n.id,Q0(N.current))},C=X=>{X.stopPropagation()},U=`rgb(${(h?Q0(N.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:y,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[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:n.name||n.id}),h&&r.jsxs(r.Fragment,{children:[r.jsx(fo,{label:g,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:C,onPointerDown:X=>{C(X),q.current=!0},onPointerUp:X=>{C(X),q.current=!1,E()},onPointerCancel:X=>{C(X),q.current=!1,E()},onKeyUp:X=>{C(X),E()},onBlur:E,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:A,onChange:w,disabled:b,"aria-label":`Set color for ${n.name||n.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(fo,{label:g,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:U}}),!h&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:x?"Turn off":"Turn on"})]})}function Ng(){const{state:{keymap:n}}=_t(),{session:l,homeAssistantToggle:i,homeAssistantSetLightColor:o}=ze(),f=l?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=!!(f?.lightPolicy||null)?.lockedOn,p=bn(n?.homeAssistantOn?.[0]),g=bn(n?.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 y=!!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}),h?r.jsx(fo,{label:"Locked On",tone:"warn"}):null,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"}),p?r.jsx(Z0,{label:p}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),g?r.jsx(Z0,{label:g}):null]})]})]}),r.jsx(fo,{label:y?"Connected":"Offline",tone:y?"success":"warn"})]}),h?r.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:"Lights are locked on. Room controls are disabled."}):null,r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(b=>r.jsx(Qj,{entity:b,connected:y,controlsLocked:h,onToggle:i,onSetColor:o},b.id))})]})}function Z0({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function wg(){const{login:n,setRole:l}=ze(),[i,o]=m.useState(""),[f,d]=m.useState(""),[x,h]=m.useState(!1);async function p(g){g.preventDefault(),h(!0);try{await n(i,f),o(""),d("")}catch(y){alert(y.message)}finally{h(!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:p,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:x,className:"button-dark w-full disabled:opacity-50",children:x?"Logging in…":"Login"})]})]})}function I0(...n){return n.filter(Boolean).join(" ")}function Kj(n){const l=n?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function Zj(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Ij({title:n,roster:l=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),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=>{const d=!!(f?.private?.enabled&&f?.private?.open),x=!!f?.locked;return r.jsxs("li",{className:I0("surface flex flex-wrap items-center justify-between gap-0.5",x?"bg-red-900/40":d?"bg-amber-700/35 border border-amber-200/30":null),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f.color,.16),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:I0("font-semibold",Zj(f)),children:["Battery ",Kj(f)]})]})]}),o?o(f):null]},f.id)})})]})}const Jj=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Pj(){const{session:n,lockRover:l,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:x,rebootServer:h,setAudioLevels:p,setPrivateSafety:g,llmControl:y,adminLogs:b,llmCommentaryState:A}=ze(),R=m.useMemo(()=>n?.roster??[],[n?.roster]),[N,q]=m.useState({}),[j,w]=m.useState({}),[E,C]=m.useState(!1),[M,U]=m.useState(!1),X=n?.health||null,_=n?.communityGoal?.text||"",K=n?.communityGoal?.updatedAt||null,[B,z]=m.useState(_),Y=n?.adminReason?.text||"",te=n?.adminReason?.updatedAt||null,[fe,ce]=m.useState(Y),G=n?.audioLevels||{},[T,F]=m.useState({hornGain:Number.isFinite(G.hornGain)?G.hornGain:1,ttsGain:Number.isFinite(G.ttsGain)?G.ttsGain:1,forwardGain:Number.isFinite(G.forwardGain)?G.forwardGain:1}),[J,le]=m.useState({}),de=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",k=n?.role==="lockdown"||n?.role==="lockdown-admin",H=n?.mode??"open",P=async(se,re)=>{try{await l(se,re),q(me=>({...me,[se]:re}))}catch(me){alert(me.message)}},ne=async se=>{const re=se.target.value;try{await i(re)}catch(me){alert(me.message)}},pe=async se=>{try{await o(se,{force:!0})}catch(re){alert(re.message)}},ie=async se=>{if(!(!se?.id||!window.confirm(`Reboot rover "${se.name||se.id}" now?`))){w(me=>({...me,[se.id]:!0}));try{await x(se.id)}catch(me){alert(me.message)}finally{w(me=>({...me,[se.id]:!1}))}}},oe=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){C(!0);try{await h()}catch(re){alert(re.message),C(!1)}}},ve=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){U(!0);try{await y("clearHistory")}catch(re){alert(re.message)}finally{U(!1)}}},ye=async()=>{try{await f(B)}catch(se){alert(se.message)}},xe=async()=>{try{await f(null)}catch(se){alert(se.message)}},Ue=async()=>{try{await d(fe)}catch(se){alert(se.message)}},$e=async()=>{try{await d(null)}catch(se){alert(se.message)}},Ne=se=>re=>{const me=Number(re.target.value);F(we=>({...we||{},[se]:Number.isFinite(me)?me:1}))},ae=async()=>{try{await p(T)}catch(se){alert(se.message)}};m.useEffect(()=>{z(_)},[_]),m.useEffect(()=>{ce(Y)},[Y]),m.useEffect(()=>{F({hornGain:Number.isFinite(G.hornGain)?G.hornGain:1,ttsGain:Number.isFinite(G.ttsGain)?G.ttsGain:1,forwardGain:Number.isFinite(G.forwardGain)?G.forwardGain:1})},[G.forwardGain,G.hornGain,G.ttsGain]),m.useEffect(()=>{const se={};(R||[]).forEach(re=>{re?.private?.enabled&&(se[re.id]={speedLimitEnabled:!!re?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(re?.private?.safety?.speedLimitMaxWheelSpeed)?re.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!re?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(re?.private?.safety?.overcurrentStopMs)?re.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!re?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(re?.private?.safety?.bumpBackoffSpeed)?re.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(re?.private?.safety?.bumpBackoffMs)?re.private.safety.bumpBackoffMs:350,cliffEnabled:!!re?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(re?.private?.safety?.cliffBackoffSpeed)?re.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(re?.private?.safety?.cliffBackoffMs)?re.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(re?.private?.safety?.triggerCooldownMs)?re.private.safety.triggerCooldownMs:800})}),le(se)},[R]);const ue=m.useMemo(()=>{const se={};return R.forEach(re=>{se[re.id]=N[re.id]??re.locked}),se},[R,N]),be=(se,re={})=>{le(me=>({...me||{},[se]:{...me?.[se]||{},...re||{}}}))},Me=async se=>{try{const re=J?.[se];if(!re)return;await g(se,re)}catch(re){alert(re.message)}};return de?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:H,onChange:ne,className:"field-input text-sm",children:Jj.map(se=>r.jsx("option",{value:se.key,children:se.label},se.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:oe,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"}),n?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(n.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:[T.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.hornGain,onChange:Ne("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:[T.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.ttsGain,onChange:Ne("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:[T.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.forwardGain,onChange:Ne("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ae,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"}),K?r.jsxs("span",{children:["Updated ",new Date(K).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:B,onChange:se=>z(se.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:ye,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:xe,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"}),te?r.jsxs("span",{children:["Updated ",new Date(te).toLocaleString()]}):null]}),r.jsx("textarea",{value:fe,onChange:se=>ce(se.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:Ue,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:$e,className:"button-danger",children:"Clear"})]})]}),r.jsx(Ij,{roster:R,renderActions:se=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>P(se.id,!ue[se.id]),className:"button-dark",children:ue[se.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>pe(se.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>ie(se),disabled:!!j[se.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:j[se.id]?"Rebooting...":"Reboot"}),se?.private?.enabled?r.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[r.jsx("div",{className:"text-slate-300",children:"Private safety"}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.speedLimitEnabled,disabled:!k,onChange:re=>be(se.id,{speedLimitEnabled:!!re.target.checked})}),r.jsx("span",{children:"Speed limit"})]}),r.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!k,value:J?.[se.id]?.speedLimitMaxWheelSpeed??250,onChange:re=>be(se.id,{speedLimitMaxWheelSpeed:Number(re.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.hardOvercurrentEnabled,disabled:!k,onChange:re=>be(se.id,{hardOvercurrentEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard overcurrent"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.hardBumpEnabled,disabled:!k,onChange:re=>be(se.id,{hardBumpEnabled:!!re.target.checked})}),r.jsx("span",{children:"Hard bump"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.cliffEnabled,disabled:!k,onChange:re=>be(se.id,{cliffEnabled:!!re.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!k,onClick:()=>Me(se.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(nN,{health:X,roster:R}),r.jsx(Wj,{state:A,onClearHistory:ve,clearingHistory:M}),r.jsx(aN,{entries:b})]}):null}function Wj({state:n,onClearHistory:l,clearingHistory:i}){const[o,f]=m.useState(null);if(!n)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=n.runtime||{},x=n.counters||{},h=n.timings||{},p=n.input||{},g=n.output||{},y=n.errors||{},b=Array.isArray(n.history)?n.history:[],A=b.find(j=>j.runId===o)||(b.length?b[b.length-1]:null),R=eN(n),N=tN(p.modelMessages,g.raw),q=[{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:x.skipStreak??0},{label:"clear count",value:x.clearCount??0},{label:"last gen",value:h.lastGenerationMs!=null?`${h.lastGenerationMs} ms`:"--"},{label:"avg gen",value:h.avgGenerationMs!=null?`${h.avgGenerationMs} ms`:"--"},{label:"gen count",value:h.generationCount??0},{label:"prompt chars",value:x.promptChars??0},{label:"active drivers",value:x.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:x.snapshotSummary?.rovers??0},{label:"snapshot chat",value:x.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 ${R.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:R.label}),r.jsx("div",{className:"text-xs text-slate-200",children:R.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:q.map(j=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[j.label,": ",j.value]},j.label))}),y.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",y.message]}):null,y.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(y.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:N.length?N.map(j=>r.jsx(Kf,{message:j.message},j.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",y.failedAt?new Date(y.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(j=>r.jsxs("button",{type:"button",onClick:()=>f(j.runId),className:`w-full text-left surface ${A?.runId===j.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",j.runId]})," ",r.jsx("span",{className:"text-slate-200",children:j.outcome||j.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:j.durationMs!=null?`${j.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:j.reason||""})]},j.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),A?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 #",A.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(A,null,2)})]}):null]})}function eN(n){const l=n?.runtime||{},i=n?.output||{},o=n?.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 tN(n,l){const i=Date.now(),f=(Array.isArray(n)?n:[]).map((d,x)=>{const h=String(d?.role||"").toLowerCase(),p=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=h==="system"?"LLM System":h==="assistant"?"LLM Context":h==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${x}`,message:{ts:i+x,nickname:g,text:p,role:"spectator",system:h==="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 nN({health:n,roster:l=[]}){if(!n)return null;const i=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},f=p=>l.find(g=>String(g.id)===String(p))?.color||null,d=`${i.readyCount}/${i.totalCount} sources ready`,x=o.rovers.filter(p=>p.stale).length,h=o.rooms.filter(p=>p.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:d})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:x?"text-amber-300":"text-emerald-300",children:[o.rovers.length-x,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rooms.length-h,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.sources.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:`${p.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:p.type==="rover"?ra(f(p.id),.16):void 0,children:p.label}),r.jsxs("span",{className:p.ready?"text-emerald-300":"text-amber-300",children:[p.recentCount,"/",p.neededCount]})]},`${p.type}:${p.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(f(p.id),.16),children:p.name}),r.jsx("span",{className:p.stale?"text-amber-300":"text-emerald-300",children:p.stale?"stale":"ok"})]},`rover:${p.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(p=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:p.name}),r.jsx("span",{className:p.stale?"text-amber-300":"text-emerald-300",children:p.error?"error":p.stale?"stale":"ok"})]},`room:${p.id}`))})]})}function aN({entries:n}){const l=n||[];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 lN=[{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 sN(n){return n.reduce((l,i)=>((l[i.group]||(l[i.group]=[])).push(i),l),{})}function iN(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}const id=5,Si=500,Ai=1,rd=100;function rN(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(id,Math.min(Si,i)):l}function ao(n,l){const i=Number(n);return Number.isFinite(i)?Math.max(Ai,Math.min(rd,i)):l}function oN(n){const i=(ao(n,n)-Ai)/(rd-Ai),o=Si-i*(Si-id);return Math.round(o)}function cN(n){const l=rN(n,n),i=(Si-l)/(Si-id),o=Ai+i*(rd-Ai);return Math.round(o)}function uN(n){const[l,i]=m.useState(null),o=m.useCallback(x=>{Ju(!0),i(x)},[]),f=m.useCallback(()=>{Ju(!1),i(null)},[]),d=m.useCallback((x,h)=>{if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){f();return}const p=ki(h.key??"");p&&(n(x,p,h),f())},[f,n]);return m.useEffect(()=>()=>Ju(!1),[]),{active:l,startCapture:o,cancel:f,captureFromEvent:d}}function Xr({label:n,description:l,value:i,onChange:o,min:f=0,max:d=500,step:x=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:n}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:h=>o(h.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),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:x,value:i,onChange:h=>o(h.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 fN(){const{state:{keymap:n},actions:{updateKeyBinding:l,resetKeyBindings:i}}=_t(),{value:o,save:f}=Qe("inputs",En),d={...En.keyboard,...o.keyboard??{}},x=m.useMemo(()=>typeof d.tiltSpeed=="number"?ao(d.tiltSpeed,En.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?ao(cN(d.tiltIntervalMs),En.keyboard.tiltSpeed):En.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),h=m.useMemo(()=>sN(lN),[]),{active:p,startCapture:g,cancel:y,captureFromEvent:b}=uN((q,j)=>{l(q,j)}),A=m.useCallback(q=>n?.[q]?.[0]||di[q]?.[0]||"",[n]),R=m.useCallback((q,j)=>{const w=En.keyboard,E=iN(j,w[q]);f(C=>({...C??{},keyboard:{...C?.keyboard??w,[q]:E}}))},[f]),N=m.useCallback(q=>{const j=En.keyboard,w=ao(q,j.tiltSpeed),E=oN(w);f(C=>({...C??{},keyboard:{...C?.keyboard??j,tiltSpeed:w,tiltIntervalMs:E}}))},[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(Xr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:q=>R("baseSpeed",q)}),r.jsx(Xr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:q=>R("turboSpeed",q)}),r.jsx(Xr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:q=>R("precisionSpeed",q)})]})]}),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(Xr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:x,onChange:N,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([q,j])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:q}),r.jsx("div",{className:"space-y-0.5",children:j.map(w=>{const E=A(w.id),C=p===w.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:w.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:bn(E)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[C&&r.jsx("button",{type:"button",onClick:()=>y(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(w.id),onKeyDown:C?M=>b(w.id,M):void 0,autoFocus:C,className:`${C?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium transition-colors`,children:C?"Press a key…":"Change"})]})]},w.id)})})]},q))})]})}const aa=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),dN=[{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"}],J0=.45,mN=.6;function ci({label:n,description:l,min:i,max:o,step:f,value:d,onChange:x}){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:n}),r.jsx("span",{className:"font-mono text-slate-400",children:aa.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:h=>x(Number(h.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function hN(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const l=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${l?` (${l})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const l=n.direction<0?"<":">";return`Axis ${n.index} ${l} ${aa.format(n.threshold??.6)}`}return"Unassigned"}function pN(n){return n.reduce((l,i)=>((l[i.section]||(l[i.section]=[])).push(i),l),{})}function xN(n,l){if(!n||n.length===0)return null;if(l){const i=n.find(o=>o.signature===l);if(i)return i}return n[0]}function gN(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0}))}}function vN(n,l,i){const o=(n.axes??[]).map((d,x)=>({index:x,delta:Math.abs((d??0)-(l.axes?.[x]??0)),value:d}));if(o.sort((d,x)=>x.delta-d.delta),i.kind==="axisPair"){const d=o.filter(x=>x.delta>J0).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>J0);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function yN(n,l,i){const o=n.buttons??[];for(let d=0;d<o.length;d+=1){const x=o[d],h=typeof x?.value=="number"?x.value:x?.pressed?1:0;if(x?.pressed||h>mN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=n.axes??[];for(let d=0;d<f.length;d+=1){const x=f[d]??0,h=Math.abs(x-(l.axes?.[d]??0));if(Math.abs(x)>.7&&h>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:x>=0?1:-1,threshold:.6}}return null}function bN(n,l,i){if(!n)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=vN(n,l,i);if(o)return o}return yN(n,l,i)}function SN(){const n=IA(),{value:l,save:i}=Qe("gamepad",Da),[o,f]=m.useState(null),d=m.useRef(null),x=m.useMemo(()=>pN(dN),[]),h=m.useMemo(()=>xN(n.pads,l.activeSignature),[n.pads,l.activeSignature]),p=h?.signature??null,g=m.useMemo(()=>p?l?.profiles?.[p]??l?.defaults?.profile??la:l?.defaults?.profile??la,[p,l?.defaults?.profile,l?.profiles]);m.useEffect(()=>{!h||!p||l?.profiles?.[p]||i(j=>{const w=j??Da;if(w.profiles?.[p])return w;const E=w?.defaults?.profile??la,C=ug(h,E);return{...w,profiles:{...w.profiles??{},[p]:C}}})},[h,p,l?.profiles,i]),m.useEffect(()=>{d.current=null},[o,p]),m.useEffect(()=>{if(!o||!h)return;if(!d.current){d.current=gN(h);return}const j=bN(h,d.current,o);j&&(i(w=>{const E=w??Da,C=E.profiles?.[p]??E?.defaults?.profile??la,M={...C,bindings:{...C.bindings??{},[o.id]:{...C.bindings?.[o.id]??{},kind:o.kind,sources:[j]}}};return{...E,profiles:{...E.profiles??{},[p]:M}}}),f(null))},[h,p,o,i]);const y=m.useCallback(j=>{i(w=>({...w??Da,activeSignature:j||null}))},[i]),b=m.useCallback(j=>{i(w=>{const E=w??Da,C=(p&&E.profiles?.[p])??E?.defaults?.profile??la,M={...C,calibration:{...C.calibration??{},...j}};return p?{...E,profiles:{...E.profiles??{},[p]:M}}:{...E,defaults:{...E.defaults??{},profile:M}}})},[p,i]),A=m.useCallback((j,w)=>{i(E=>{const C=E??Da,M=(p&&C.profiles?.[p])??C?.defaults?.profile??la,U=w(M.bindings?.[j]??{}),X={...M,bindings:{...M.bindings??{},[j]:U}};return p?{...C,profiles:{...C.profiles??{},[p]:X}}:{...C,defaults:{...C.defaults??{},profile:X}}})},[p,i]),R=m.useCallback(j=>{A(j.id,w=>({...w,sources:[]}))},[A]),N=m.useCallback((j,w)=>{A(j.id,E=>{const C=Array.isArray(E.sources)?[...E.sources]:[];if(!C[0])return E;const M={...C[0]};return w==="invertX"?M.invertX=!M.invertX:w==="invertY"?M.invertY=!M.invertY:M.invert=!M.invert,C[0]=M,{...E,sources:C}})},[A]),q=m.useMemo(()=>h?{outputs:fg(h,g)}:null,[h,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:h?"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"}),n.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:p??"",onChange:j=>y(j.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(j=>r.jsx("option",{value:j.signature,children:j.id||"Unknown controller"},j.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:h?.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(ci,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:j=>b({driveDeadzone:j})}),r.jsx(ci,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:j=>b({cameraDeadzone:j})}),r.jsx(ci,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:j=>b({auxDeadzone:j})}),r.jsx(ci,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:j=>b({auxSideScale:j})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:j=>b({cameraMode:j.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(ci,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:j=>b({cameraSensitivity:j})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(x).map(([j,w])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:j}),r.jsx("div",{className:"space-y-0.5",children:w.map(E=>{const M=g.bindings?.[E.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:E.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:hN(M)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[E.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),E.kind==="axis"&&r.jsx("button",{type:"button",disabled:!M,onClick:()=>N(E),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>R(E),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(E),className:`${o?.id===E.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===E.id?"Waiting…":"Capture"})]})]},E.id)})})]},j))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),h?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:h.axes.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",w,": ",aa.format(j)]},`axis-${w}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.buttons.map((j,w)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",w,": ",aa.format(j.value)," ",j.pressed?"●":""]},`btn-${w}`))}),q?.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: ",aa.format(q.outputs.driveVector.x),","," ",aa.format(q.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",aa.format(q.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",aa.format(q.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",aa.format(q.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const AN={drive:"Drive wheels",aux:"Aux motors"};function P0(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function jN({value:n,color:l="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,n))*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 NN(){const{state:{roverId:n},overcurrentLimiter:l}=_t(),i=m.useMemo(()=>ts.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"})]}),n?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,x=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:AN[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:P0(f)})]}),r.jsx(jN,{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:P0(x)})]})]})]},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 Cg=m.createContext(null);function Eg(){const n=m.useContext(Cg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const W0={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"}},ex={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"},kg="primary";function od(...n){return n.filter(Boolean).join(" ")}function cd({children:n,defaultTab:l,currentTab:i,onTabChange:o,variant:f=kg}){const[d,x]=m.useState(l??null),[h,p]=m.useState([]),g=m.useCallback(R=>R?(p(N=>N.includes(R)?N:[...N,R]),()=>p(N=>N.includes(R)?N.filter(q=>q!==R):N)):()=>{},[]),y=i??d??h[0]??null;m.useEffect(()=>{l&&i===void 0&&x(l)},[l,i]);const b=m.useCallback(R=>{R&&(i===void 0&&x(R),o&&o(R))},[i,o]),A=m.useMemo(()=>({activeTab:y,setActiveTab:b,registerTab:g,variant:f}),[y,b,g,f]);return r.jsx(Cg.Provider,{value:A,children:n})}function ud({children:n,className:l=""}){return r.jsx("div",{className:od("flex gap-0.5",l),children:n})}function Pt({id:n,children:l,className:i="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:x,registerTab:h,variant:p}=Eg();m.useEffect(()=>h(n),[n,h]);const g=W0[p]??W0[kg],y=d===n,b=ex[f]||ex.none,A=od(g.base,b||(y?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:A,onClick:()=>!o&&x(n),"aria-pressed":y,"aria-disabled":o,children:l})}function fd({children:n,className:l=""}){return r.jsx("div",{className:od("mt-0 space-y-0.5",l),children:n})}function Wt({id:n,children:l,keepMounted:i=!1}){const{activeTab:o}=Eg(),f=o===n;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:l}):r.jsx(r.Fragment,{children:l})}function wN(){const{session:n}=ze(),l=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);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 tx=300,nx=240;function CN(n,l){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(l||(l=new WeakSet),typeof n=="object"){if(l.has(n))return"[Circular]";l.add(n)}try{return JSON.stringify(n,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function EN(n){const i=n.map(o=>CN(o)).join(" ");return i.length>nx?`${i.slice(0,nx)}…`:i}function kN(){const n=Rn(),[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=(p,g,y)=>{i(b=>{const A=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:p,event:g,payload:EN(y),timestamp:new Date().toLocaleTimeString()}];return A.length>tx?A.slice(-tx):A})},d=(p,...g)=>f("in",p,g),x=(p,...g)=>f("out",p,g);n.onAny(d);let h=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(x),h=()=>n.offAnyOutgoing(x);else{const p=n.emit.bind(n);n.emit=(g,...y)=>(x(g,...y),p(g,...y)),h=()=>{n.emit=p}}return()=>{n.offAny(d),h&&h()}},[n]),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 MN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Mg(){const{state:{roverId:n},actions:{sendOiCommand:l,setSensorStream:i}}=_t(),o=!!n,[f,d]=Ag(),x=Rn(),{value:h,save:p}=Qe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:y}=Qe("audio",Dt),b=h?.connectionTransport||"websocket",A=!!h?.swapMobileControlColumns,R=typeof h?.driveMacroBackoffEnabled=="boolean"?h.driveMacroBackoffEnabled:!0,N=Number.isFinite(g?.masterVolume)?g.masterVolume:Dt.masterVolume,q=Number.isFinite(g?.alertVolume)?g.alertVolume:Dt.alertVolume,j=Number.isFinite(g?.roverVolume)?g.roverVolume:Dt.roverVolume,w=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:Dt.mainBrushDuckEnabled,E=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):Dt.mainBrushDuckAmount,C=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=z=>{n&&i(z)},U=z=>{const Y=z.target.value;p(te=>({...te??{},connectionTransport:Y})),x?.io?.opts&&(x.io.opts.transports=Y==="polling"?["polling"]:["websocket","polling"],x.disconnect(),x.connect())},X=z=>Y=>{const te=Number(Y.target.value),fe=Number.isFinite(te)?Math.max(0,Math.min(1,te)):0;y(ce=>({...ce??{},[z]:fe}))},_=z=>{const Y=!!z.target.checked;y(te=>({...te??{},mainBrushDuckEnabled:Y}))},K=z=>{const Y=!!z.target.checked;p(te=>({...te??{},swapMobileControlColumns:Y}))},B=z=>{const Y=!!z.target.checked;p(te=>({...te??{},driveMacroBackoffEnabled:Y}))};return r.jsxs(cd,{defaultTab:"keybindings",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"keybindings",children:"Keybindings"}),r.jsx(Pt,{id:"controller",children:"Controller"}),r.jsx(Pt,{id:"page",children:"Page settings"}),r.jsx(Pt,{id:"admin",children:"Admin"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(fN,{})})}),r.jsx(Wt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(SN,{})})}),r.jsx(Wt,{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:z=>d(z.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:A,onChange:K}),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:"Macros"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:R,onChange:B}),r.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:X("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(q*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:q,onChange:X("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(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:X("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:w,onChange:_})]}),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:X("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!w})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:U,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(Wt,{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:MN.map(z=>r.jsx("button",{type:"button",onClick:()=>l(z.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:z.label},z.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:C.map(z=>r.jsx("button",{type:"button",onClick:()=>M(z.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:z.label},z.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(wg,{}),r.jsx(NN,{}),r.jsx(Pj,{}),r.jsx(wN,{}),r.jsx(kN,{})]})})]})]})}const ax={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 qN(n){return ax[n]||ax.desktop}function qg({actionId:n,keymap:l}){const i=l?.[n]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:bn(i)})}function lx(n,l){return n.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(qg,{actionId:i.action,keymap:l},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function So(n,l,i){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return lx(n.segments,l);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return lx(n,l)}return String(n??"")}function RN({hero:n,keymap:l}){return n?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:n.title}),n.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.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:So(i,l)},f)})})]}):null}function TN({block:n,keymap:l}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.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:So(i,l)},f)})})]})}function DN({block:n}){const l=n.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:n.title}),n.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:So(i,{})},`callout-${o}`))})]})}function _N({group:n,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:n.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.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(qg,{actionId:i.action,keymap:l})]},i.action))})]})}function ON({block:n,keymap:l}){return n?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:n.title}),n.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(i=>r.jsx(_N,{group:i,keymap:l},i.id))})]}):null}function BN({block:n}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((l,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:So(l,{})},`gamepad-${i}`))})]}):null}function sx({block:n,keymap:l}){if(!n)return null;switch(n.type){case"list":return r.jsx(TN,{block:n,keymap:l});case"callout":return r.jsx(DN,{block:n});case"keyboard":return r.jsx(ON,{block:n,keymap:l});case"gamepad":return r.jsx(BN,{block:n});default:return null}}function Rg({layout:n,keymap:l}){const i=m.useMemo(()=>qN(n),[n]),o=l||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(RN,{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((x,h)=>r.jsx(sx,{block:x,keymap:o},x.title||h))}),r.jsx("div",{className:"space-y-0.5",children:d.map((x,h)=>r.jsx(sx,{block:x,keymap:o},x.title||h))})]})]})}function Tg({layout:n,onOpenOverlay:l}){const{state:i}=_t();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(Rg,{layout:n,keymap:i?.keymap||{}})]})}const LN=["kal","rms","slt","ksp","bdl"],zN=Array.from({length:10},(n,l)=>l*10);function Ao({hideInput:n=!1,hideSpectatorNotice:l=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=ze(),{messages:d,typing:x,sendMessage:h,registerInputRef:p,onInputFocus:g,onInputBlur:y,blurChat:b,setTypingActive:A}=Jf(),{value:R,save:N}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[q,j]=m.useState(""),[w,E]=m.useState(!1),[C,M]=m.useState(!1),[U,X]=m.useState(()=>R?.engine||"flite"),[_,K]=m.useState(()=>R?.voice||"rms"),[B,z]=m.useState(()=>Number.isFinite(R?.pitch)?R.pitch:50),Y=f?.role!=="spectator"||o,te=m.useRef(null),fe=f?.assignment?.roverId||null,G=!!m.useMemo(()=>f?.roster?.find(k=>String(k.id)===String(fe))||null,[fe,f?.roster])?.audio?.ttsEnabled,T=m.useMemo(()=>d.slice(-200),[d]),F=m.useMemo(()=>x||[],[x]);m.useEffect(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[T,F]),m.useEffect(()=>{const k=R?.engine||"flite",H=R?.voice||"rms",P=Number.isFinite(R?.pitch)?R.pitch:50;U!==k&&X(k),_!==H&&K(H),B!==P&&z(P)},[U,B,R?.engine,R?.pitch,R?.voice,_]),m.useEffect(()=>{M(!!G)},[G]);const J=m.useMemo(()=>!G||!C?null:U==="espeak"?{speak:!0,engine:U,pitch:B}:{speak:!0,engine:U,voice:_},[U,B,C,G,_]);async function le(k){if(k.preventDefault(),!Y||n)return;const P=q.replace(/\\n/g,`
`).trim();if(P){E(!0);try{await h(P,J),j(""),b(),A(!1)}catch(ne){alert(ne.message)}finally{E(!1)}}}const de=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 ${de}`,ref:te,children:[T.length===0&&F.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):T.map(k=>r.jsx(Kf,{message:k},k.id)),F.map(k=>r.jsx(tg,{message:k},`typing-${k.typingId||k.id}`))]}),!n&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:le,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:q,onChange:k=>{const H=k.target.value;j(H),A(!!H.trim())},onFocus:k=>{g(k),A(!!q.trim())},onBlur:k=>{y(k),A(!1)},onKeyDown:k=>{k.key==="Enter"&&!q.trim()&&(k.preventDefault(),b(),A(!1))},ref:k=>p(k,{target:"panel"}),placeholder:Y?"Type a message…":l?"":"Spectators cannot chat",disabled:!Y}),G&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:C,onChange:k=>M(k.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:U,onChange:k=>{const H=k.target.value;X(H),N(P=>({...P||{},engine:H}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),U==="flite"?r.jsx("select",{value:_,onChange:k=>{const H=k.target.value;K(H),N(P=>({...P||{},voice:H}))},className:"field-input text-xs",children:LN.map(k=>r.jsx("option",{value:k,children:k},k))}):r.jsx("select",{value:B,onChange:k=>{const H=Number(k.target.value);z(H),N(P=>({...P||{},pitch:H}))},className:"field-input text-xs",children:zN.map(k=>r.jsxs("option",{value:k,children:["pitch ",k]},k))})]}),r.jsx("button",{type:"submit",disabled:!Y||w,className:"button-dark h-full disabled:opacity-50 self-stretch",children:w?"...":"Send"})]})]})}function jo({compact:n=!1}){const{session:l,setNickname:i}=ze(),{value:o,save:f}=Qe("profile",{nickname:""}),[d,x]=m.useState(o.nickname||""),[h,p]=m.useState(!1),g=l?.role!=="spectator";m.useEffect(()=>{x(o.nickname||"")},[o.nickname]);async function y(b){if(b.preventDefault(),!g)return;const A=(d||"").trim().slice(0,32);if(A){p(!0);try{await i(A),f({nickname:A})}catch(R){alert(R.message)}finally{p(!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=>x(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||h,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:h?"Saving…":n?"Set":"Save"})]})}function UN(n){const l=Array.isArray(n?.socials)?n.socials:null;if(l&&l.length)return l;const i=[];return n?.discord?.invite&&i.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),i}function HN(n){if(!n||typeof n!="object")return null;const l=n.id||n.service||n.key||n.name||null,i=n.label||n.title||n.name||l||"Link",o=n.url||n.link||n.href||null;return o?{id:l,label:i,url:o}:null}function Dg({className:n=""}){const{session:l}=ze(),i=UN(l).map(HN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:i.map(o=>r.jsx(ld,{...o},`${o.id||o.label}-${o.url}`))}):null}function VN({compact:n=!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(jo,{compact:n})})})}function $N(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Dg,{className:"flex-1 min-h-0"})})}function df(...n){return n.filter(Boolean).join(" ")}function GN(n){const l=n?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function YN(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function FN(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function XN(n,l){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===l?`${i} (you)`:i}function No({title:n="Rovers"}){const{session:l,requestControl:i}=ze(),[o,f]=m.useState({}),[d,x]=m.useState(()=>Date.now()),h=m.useMemo(()=>l?.role&&l.role!=="spectator",[l?.role]),p=m.useMemo(()=>l?.role==="admin"||l?.role==="lockdown"||l?.role==="lockdown-admin",[l?.role]),g=l?.roster??[],y=l?.turnQueues??{},b=l?.users??[],A=l?.socketId||null,R=m.useMemo(()=>Object.values(y||{}).some(w=>w?.deadline||w?.idleDeadline),[y]);m.useEffect(()=>{if(!R)return;const w=setInterval(()=>{x(Date.now())},1e3);return()=>clearInterval(w)},[R]);const N=m.useMemo(()=>{const w=new Set(g.map(C=>String(C.id))),E=Object.keys(y||{}).filter(C=>!w.has(String(C))).map(C=>({id:C,name:C,locked:!1,batteryState:null}));return[...g,...E]},[g,y]);async function q(w){if(w){f(E=>({...E,[w]:!0}));try{await i(w)}catch(E){alert(E.message)}finally{f(E=>({...E,[w]:!1}))}}}const j=w=>b.find(E=>E.socketId===w)||{socketId:w,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),N.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:N.map(w=>{const E=String(w.id),C=y?.[E]||null,M=C?.queue||[],U=C?.idleDeadline||C?.deadline||null,X=U&&U>d?Math.ceil((U-d)/1e3):U?0:null,_=C?.current||null,K=_?M.findIndex(le=>le===_):-1,B=M.length>1?K>=0?M[(K+1)%M.length]:M[0]:null,z=!!(A&&_&&_===A),Y=!!(A&&B&&B===A),te=X!=null&&(z||Y),fe=!!w.locked,ce=fe&&!p,G=!!(w?.private?.enabled&&w?.private?.open),T=w.lockReason?`locked: ${w.lockReason}`:"locked",F=fe?T:o[E]?"...":"request",J=h&&!ce&&!o[E];return r.jsxs("li",{className:df("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",fe?"bg-red-900/40":G?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&q(w.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:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ra(w.color,.16),children:w.name})}),te?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:z?`${X}s left`:`Your turn in ${X}s`}):null]}),r.jsx("span",{className:df("text-[0.75rem] font-semibold",YN(w)),children:GN(w)})]}),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((le,de)=>{const k=j(le),H=le===_,P=!!(B&&le===B&&!H),ne=H?"bg-sky-600 text-white ring-2 ring-amber-300":P?"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] ${ne}`,children:[r.jsx("span",{className:`${FN(k.role)} font-semibold`,children:XN(k,A)}),H&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),P&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${E}-${le}-${de}`)})})]}),h?r.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),q(w.id)},disabled:o[E]||ce,className:df("button-dark disabled:opacity-40",fe&&"bg-red-600/70 text-white hover:bg-red-600"),children:F}):null]},w.id)})})]})}function QN(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function KN(n,l){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===l?`${i} (you)`:i}function mo({hideNicknameForm:n=!1,hideHeader:l=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=ze(),x=d?.role!=="spectator",h=d?.users??[],p=d?.socketId||null,g=m.useMemo(()=>[...h].sort((b,A)=>b.socketId===p?-1:A.socketId===p?1:(b.nickname||"").localeCompare(A.nickname||"")),[p,h]),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:[!n&&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(jo,{compact:f})})}),r.jsx(Dg,{})]}),!x&&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] ${QN(b.role)}`,children:KN(b,p)},b.socketId))})]})]})}const ZN=/^cu_[a-f0-9]{32}$/,ji="field-input w-full max-w-sm text-left focus:ring-emerald-500",wo="mx-auto w-full max-w-xl flex justify-center",hi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function IN(n){const l=String(n||"").trim();return l?l.length<=10?`${l.slice(0,2)}***${l.slice(-2)}`:`${l.slice(0,6)}...${l.slice(-6)}`:""}const ix=8*1024*1024,ll=16e3,JN={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function rx(n){let l="";for(let o=0;o<n.length;o+=32768){const f=n.subarray(o,o+32768);l+=String.fromCharCode(...f)}return btoa(l)}function PN(n){return typeof btoa=="function"?btoa(n):""}function WN(n){if(!n)return{};const l=PN(`${n}:${n}`);return l?{Authorization:`Basic ${l}`}:{}}function ew(n,l=1500){return new Promise(i=>{if(!n||n.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",f),i()},l);function f(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",f),i())}n.addEventListener("icegatheringstatechange",f)})}function ox(n){if(!n)return!1;const l=n.connectionState,i=n.iceConnectionState;return l==="connected"||i==="connected"||i==="completed"}function tw(n,l=1e4){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(ox(n)){i();return}const f=setTimeout(()=>{x(),o(new Error("Peer connection timeout"))},l),d=()=>{ox(n)?(x(),i()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(x(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function x(){clearTimeout(f),n.removeEventListener("connectionstatechange",d),n.removeEventListener("iceconnectionstatechange",d)}n.addEventListener("connectionstatechange",d),n.addEventListener("iceconnectionstatechange",d)})}async function nw(n){if(!n?.getParameters||!n?.setParameters)return;const l=n.getParameters()||{},i=l.encodings&&l.encodings[0]||{};l.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(l)}catch{}}function aw(n,l=6e3){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const x=setInterval(async()=>{if(Date.now()-f>l){clearInterval(x),o(new Error("WHIP connected but no outbound audio flow"));return}try{const h=n.getSenders().filter(p=>p.track?.kind==="audio");for(const p of h){const g=await p.getStats();for(const y of g.values()){if(y.type!=="outbound-rtp"||y.kind!=="audio")continue;const b=Number(y.bytesSent||0),A=Number(y.packetsSent||0);if(d<0)d=b;else if(b>d+200||A>5){clearInterval(x),i();return}}}}catch{}},250)})}function mn({label:n,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:n}),r.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:i||(l?"active":"idle")})]})}function cx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function lw(n){const l=n.reduce((f,d)=>f+d.length,0),i=new Float32Array(l);let o=0;for(const f of n)i.set(f,o),o+=f.length;return i}function sw(n){const l=new Int16Array(n.length);for(let i=0;i<n.length;i+=1){const o=Math.max(-1,Math.min(1,n[i]));l[i]=o<0?o*32768:o*32767}return l}function iw(n,l){const i=sw(n),o=i.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),x=(p,g)=>{for(let y=0;y<g.length;y+=1)d.setUint8(p+y,g.charCodeAt(y))};x(0,"RIFF"),d.setUint32(4,36+o,!0),x(8,"WAVE"),x(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),x(36,"data"),d.setUint32(40,o,!0);let h=44;for(let p=0;p<i.length;p+=1,h+=2)d.setInt16(h,i[p],!0);return new Uint8Array(f)}function rw({ownRoverId:n="",audioForwardByRover:l={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:x}){const{state:h}=_t(),{value:p,save:g}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),y=String(n||"").trim(),[b,A]=m.useState(null),[R,N]=m.useState(!1),q=!!p?.openMicEnabled,w=(p?.pttMode==="clip"?"clip":"live")==="clip",[E,C]=m.useState("idle"),[M,U]=m.useState("idle"),[X,_]=m.useState(""),K=m.useRef(null),B=m.useRef(null),z=m.useRef(null),Y=m.useRef(!1),te=m.useRef(""),fe=m.useRef(null),ce=m.useRef(null),G=m.useRef(null),T=m.useRef(null),F=m.useRef(null),J=m.useRef([]),le=m.useRef(!1),de=m.useRef(ll),k=!!h?.mic?.pttActive,H=m.useMemo(()=>y&&l?.[y]||null,[l,y]),P=!!(H&&H.state!=="offline"&&!H.error),ne=H?.source==="upload"&&H?.state==="playing",pe=H?.source==="mic-whip"&&(H?.state==="starting"||H?.state==="playing"),ie=!!(!w&&B.current&&(q||k)),oe=!w&&(E==="live"||E==="starting"),ve=w&&M==="recording",ye=w&&M==="sending",xe=bn(h?.keymap?.micPtt?.[0])||"M",Ue=m.useCallback(me=>{const we=me==="clip"?"clip":"live";g(et=>({...et||{},pttMode:we}))},[g]),$e=async()=>{if(!y){_("Take control of your rover first.");return}if(!b){_("Select an audio file first.");return}if(b.size>ix){_(`File too large (max ${ix} bytes).`);return}N(!0),_("");try{const me=await b.arrayBuffer(),we=rx(new Uint8Array(me));await i?.({roverId:y,name:b.name,mime:b.type||"",dataBase64:we}),_("Upload playback started.")}catch(me){_(me?.message||"Failed to play upload.")}finally{N(!1)}},Ne=async()=>{if(!y){_("Take control of your rover first.");return}N(!0),_("");try{await o?.(y),_("Upload playback stopped.")}catch(me){_(me?.message||"Failed to stop upload.")}finally{N(!1)}},ae=m.useCallback(async me=>{const we=String(me||te.current||"").trim();if(Y.current=!1,C("idle"),z.current){try{z.current.getSenders().forEach(et=>et.track?.stop())}catch{}try{z.current.close()}catch{}}if(z.current=null,K.current)try{K.current.getTracks().forEach(et=>et.stop())}catch{}if(K.current=null,B.current=null,we)try{await x?.(we)}catch{}te.current=""},[x]),ue=m.useCallback(async me=>{const we=await f?.(me),et=String(we?.whipUrl||"").trim(),dt=String(we?.token||"").trim();if(!et||!dt)throw new Error("WHIP endpoint unavailable");const Le=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ll,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});K.current=Le;const xt=Le.getAudioTracks()?.[0];if(B.current=xt||null,xt&&(xt.enabled=!!(q||k)),xt?.applyConstraints)try{await xt.applyConstraints({channelCount:1,sampleRate:ll,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const mt=new RTCPeerConnection(JN);z.current=mt,mt.onconnectionstatechange=()=>{if(!Y.current)return;const Gt=mt.connectionState;if(Gt==="connected"){C("live");return}(Gt==="failed"||Gt==="disconnected"||Gt==="closed")&&(C("error"),_(`WHIP transport ${Gt}.`))},Le.getAudioTracks().forEach(Gt=>{const Oa=mt.addTrack(Gt,Le);nw(Oa)});const Tn=await mt.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await mt.setLocalDescription(Tn),await ew(mt,1800);const Et=await fetch(et,{method:"POST",headers:{"Content-Type":"application/sdp",...WN(dt)},body:mt.localDescription?.sdp||Tn.sdp});if(!Et.ok)throw new Error(`WHIP request failed: ${Et.status}`);const cl=await Et.text();await mt.setRemoteDescription({type:"answer",sdp:cl}),await tw(mt,1e4),await aw(mt,6e3),await d?.(me)},[q,k,d,f]),be=m.useCallback(async()=>{if(le.current=!1,T.current){try{T.current.disconnect()}catch{}T.current.onaudioprocess=null}if(G.current)try{G.current.disconnect()}catch{}if(F.current)try{F.current.disconnect()}catch{}if(fe.current)try{fe.current.getTracks().forEach(me=>me.stop())}catch{}if(ce.current)try{await ce.current.close()}catch{}J.current=[],T.current=null,G.current=null,F.current=null,fe.current=null,ce.current=null,de.current=ll},[]),Me=m.useCallback(async()=>{if(fe.current&&ce.current&&T.current)return;U(xt=>xt==="recording"?xt:"arming");const me=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ll,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),we=new AudioContext({latencyHint:"interactive"}),et=we.createMediaStreamSource(me),dt=we.createScriptProcessor(1024,1,1),Le=we.createGain();Le.gain.value=0,dt.onaudioprocess=xt=>{if(!le.current)return;const mt=xt.inputBuffer.getChannelData(0);J.current.push(new Float32Array(mt))},et.connect(dt),dt.connect(Le),Le.connect(we.destination),fe.current=me,ce.current=we,G.current=et,T.current=dt,F.current=Le,de.current=we.sampleRate||ll},[]),se=m.useCallback(async({send:me})=>{const we=le.current;if(le.current=!1,!we){me||U("idle");return}const et=J.current;if(J.current=[],!me){U("idle");return}if(!y){U("idle");return}if(!et.length){U("idle");return}U("sending");try{const dt=lw(et),Le=iw(dt,de.current||ll),xt=rx(Le);await i?.({roverId:y,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:xt}),U("idle")}catch(dt){U("error"),_(dt?.message||"Failed to send PTT clip.")}},[i,y]),re=m.useCallback(async()=>{if(!y){_("Take control of your rover first.");return}await Me(),J.current=[],le.current=!0,U("recording")},[Me,y]);return m.useEffect(()=>{let me=!1;async function we(){if(w){await ae(te.current||y);return}if(!y){await ae(te.current);return}if(!(Y.current&&te.current===y)&&!(!q&&!k))try{C("starting"),_(""),Y.current=!0,te.current=y,await ue(y),me||C("live")}catch(et){me||(C("error"),_(et?.message||"Failed to start mic forwarding.")),await ae(y)}}return we(),()=>{me=!0}},[w,q,k,y,ue,ae]),m.useEffect(()=>{const me=B.current;me&&(me.enabled=!!(!w&&(q||k)))},[w,q,k]),m.useEffect(()=>{let me=!1;async function we(){if(!w||!y){le.current&&await se({send:!1}),U("idle");return}try{await Me(),!me&&!le.current&&U("idle")}catch(et){me||(U("error"),_(et?.message||"Microphone access failed for clip mode."))}}return we(),()=>{me=!0}},[w,Me,se,y]),m.useEffect(()=>{let me=!1;async function we(){if(w){if(!y){le.current&&await se({send:!1});return}if(k){if(!le.current)try{_(""),await re()}catch(et){me||(U("error"),_(et?.message||"Failed to start clip recording."))}}else le.current&&await se({send:!0})}}return we(),()=>{me=!0}},[w,se,k,y,re]),m.useEffect(()=>()=>{ae(te.current||y),be()},[y,ae,be]),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(cx,{label:xe})]})}),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 ${w?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ue("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${w?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ue("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(mn,{label:"Mode",active:w,detail:w?"record clip":"live mic"}),r.jsx(mn,{label:"PTT hold",active:k,detail:k?"held":"released"}),r.jsx(mn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),r.jsx(mn,{label:"Playback",active:w&&ne,detail:w&&ne?"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:`${ji} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:R||!y,onChange:me=>A(me.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:R||!y,onClick:$e,children:R?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:R||!y,onClick:Ne,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:q,disabled:!y||w,onChange:me=>g(we=>({...we||{},openMicEnabled:!!me.target.checked}))}),r.jsx("span",{children:w?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(mn,{label:"WHIP link",active:oe,detail:E}),r.jsx(mn,{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(cx,{label:xe})," 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(mn,{label:"Forward pipe",active:P,detail:P?"connected":"offline"}),r.jsx(mn,{label:"Upload playback",active:ne,detail:ne?"playing":"idle"}),r.jsx(mn,{label:"Mic relay",active:pe,detail:pe?"active":"idle"}),r.jsx(mn,{label:"WHIP transport",active:oe,detail:E}),r.jsx(mn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),r.jsx(mn,{label:"Clip sending",active:ye,detail:ye?"sending":"idle"})]}),X?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:X}):null]})})]})}function ow({pendingRequestId:n,currentStoredKey:l,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:x=!1}){const[h,p]=m.useState(0),[g,y]=m.useState(""),[b,A]=m.useState(!1),[R,N]=m.useState(!1),q=()=>{p(1),y(l),A(!1),d?.("")},j=()=>{p(0),A(!1)},w=async C=>{if(C.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(h<3){d?.("Complete all request steps before sending.");return}N(!0),d?.("");try{const M=await f(g);await o?.(),y(M),p(0),A(!1),d?.("Verification request sent to lockdown admins.")}catch(M){d?.(M.message||"Failed to submit request.")}finally{N(!1)}},E=x?"w-full":wo;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${E}`,children:r.jsxs("div",{className:hi,children:["Verification request pending: ",n]})}):h===0?r.jsx("section",{className:`surface ${E}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:q,disabled:R,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${E}`,onSubmit:w,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(jo,{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:C=>A(C.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:()=>p(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:j,children:"Cancel"})]})]}):null,h===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.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:()=>p(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(1),children:"Back"})]})]}):null,h===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:ji,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:C=>y(C.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:R||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>p(2),children:"Back"})]})]}):null]})})}function cw({currentStoredKey:n,applyIdentityKey:l,onMessage:i,fullWidth:o=!1}){const[f,d]=m.useState(0),[x,h]=m.useState(""),[p,g]=m.useState(!1),y=()=>{d(1),h(""),i?.("")},b=()=>{d(0),h("")},A=async N=>{if(N.preventDefault(),!(f<2)){g(!0),i?.("");try{await l(x),d(0),h(""),i?.("Identity key restored.")}catch(q){i?.(q.message||"Failed to restore key.")}finally{g(!1)}}},R=o?"w-full":wo;return r.jsx("section",{className:`surface ${R}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",IN(n)||"not set yet"]}),r.jsx("input",{className:ji,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,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:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,disabled:p,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:A,children:[r.jsx("input",{className:ji,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:x,onChange:N=>h(N.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:p||!x,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function uw({requestableRovers:n=[],pendingRequests:l=[],requestPrivateRoverAccess:i,onMessage:o,fullWidth:f=!1}){const[d,x]=m.useState({}),h=m.useMemo(()=>{const y=new Map;return(l||[]).forEach(b=>{b?.roverId&&y.set(String(b.roverId),b)}),y},[l]),p=f?"w-full":wo,g=async y=>{if(y){x(b=>({...b,[y]:!0})),o?.("");try{(await i?.(y))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{x(b=>({...b,[y]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${p}`,children:r.jsxs("div",{className:hi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?r.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):r.jsx("div",{className:"w-full space-y-0.5",children:n.map(y=>{const b=String(y.id),A=!!d[b],R=h.get(b);return r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:y.name||b}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),R?r.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):r.jsx("button",{type:"button",onClick:()=>g(b),disabled:A,className:"button-dark text-xs disabled:opacity-50",children:A?"Sending...":"Request"})]},b)})})]})})}function _g(){const{session:n,identifySession:l,requestVerification:i,requestPrivateRoverAccess:o,playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:x,readyMicWhip:h,stopMicWhip:p}=ze(),{value:g,save:y}=Qe("identity",{cookieUserId:""}),{value:b}=Qe("profile",{nickname:""}),A=m.useMemo(()=>(g?.cookieUserId||"").trim(),[g?.cookieUserId]),R=(b?.nickname||"").trim(),N=!!n?.isVerified,q=n?.verification?.pendingRequestId||null,j=n?.privateRoverAccess?.requestableRovers||[],w=n?.privateRoverAccess?.pendingRequests||[],E=String(n?.assignment?.roverId||"").trim(),[C,M]=m.useState(""),U=async X=>{const _=String(X||"").trim().toLowerCase();if(!_)throw new Error("Identity key required.");if(!ZN.test(_))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return y(K=>({...K||{},cookieUserId:_})),await l({cookieUserId:_,nickname:R}),_};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:N?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(ow,{pendingRequestId:q,currentStoredKey:A,nickname:R,requestVerification:i,applyIdentityKey:U,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:N?r.jsx(rw,{ownRoverId:E,audioForwardByRover:n?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:x,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(uw,{requestableRovers:j,pendingRequests:w,requestPrivateRoverAccess:o,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(cw,{currentStoredKey:A,applyIdentityKey:U,onMessage:M,fullWidth:!0})})]}),C?r.jsx("div",{className:wo,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:C})}):null]})}function fw(){const{state:{roverId:n}}=_t(),i=cs(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(qf,{sensors:i})})})}function dw(){const{state:{roverId:n,keymap:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:x,startHorn:h,stopHorn:p}}=_t(),g=pg(n),y=g.docked&&!g.driving,b=i?.config,A=!!(n&&i?.enabled&&b),R=!!(n&&f?.nightVision),N=f?.nightVisionState,q=!!(n&&f?.horn),j=o?.overheated,w=typeof b?.minAngle=="number"?b.minAngle:-30,E=typeof b?.maxAngle=="number"?b.maxAngle:30,C=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(w+E)/2,M=bn(l?.nightVisionToggle?.[0]),U=bn(l?.hornHonk?.[0]),X=bn(l?.cameraUp?.[0]),_=bn(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(xg,{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:[R&&r.jsx(gg,{nightVisionOn:N?.nightVisionOn,disabled:!n,onToggle:x,keyLabel:M}),q&&r.jsx(vg,{disabled:!n||j,onStart:h,onStop:p,keyLabel:U,active:o?.active,heat:o?.heat}),A&&r.jsx(yg,{value:C,min:w,max:E,onChange:d,keyDownLabel:_,keyUpLabel:X,className:"space-y-0.5 px-1 py-1",labelRowClass:"text-xs text-slate-300",labelClass:"",valueClass:"font-mono text-slate-100",sliderClass:"w-full",accentClass:"accent-emerald-400",endpointClass:"text-[0.7rem] text-slate-400"})]})]})}function mw({layout:n,onOpenHelpOverlay:l}){const{session:i}=ze(),{state:o}=_t(),{value:f}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=i?.isVerified?"bg-emerald-400":"bg-red-600",x=String(i?.assignment?.roverId||"").trim(),h=x?i?.audioForward?.[x]:null,p=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,y=f?.pttMode==="clip"?"clip":"live",b=!!(x&&i?.isVerified&&(y==="clip"?p:g||p)),A=!!(x&&i?.isVerified&&y==="clip"&&h?.source==="upload"&&h?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(cd,{defaultTab:"telemetry",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"telemetry",children:"Controls"}),r.jsx(Pt,{id:"vip",highlight:A?"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(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{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(fw,{}),r.jsx(dw,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(No,{}),r.jsx(Xf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx($N,{})]}),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(Ao,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(mo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(VN,{compact:!0})]})]}),r.jsx(Ng,{}),r.jsx(ed,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(_g,{})}),r.jsx(Wt,{id:"help",children:r.jsx(Tg,{layout:n,onOpenOverlay:l})}),r.jsx(Wt,{id:"settings",children:r.jsx(Mg,{})})]})]})})}const hw=new Set(["admin","lockdown","lockdown-admin"]),pw=new Set(["lockdown","lockdown-admin"]),xw=new Set(["admin","lockdown"]);function gw(n="admin"){return n==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function vw(){const{session:n}=ze(),l=n?.mode,i=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const f=n?.timezone||"UTC",d=n?.socials?.find(A=>String(A?.id||A?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,x=xw.has(l),h=l==="lockdown"?pw.has(i):hw.has(i),[p,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(p)}catch{return p.toLocaleTimeString()}},[p,f]);if(m.useEffect(()=>{const A=setInterval(()=>g(new Date),1e3);return()=>clearInterval(A)},[]),!x||h)return null;const b=gw(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(wg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(ld,{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(Ao,{}),r.jsx(jo,{})]})]})})}const yw="/assets/turn_alert-DVO8EZJa.mp3";function bw(n,l=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(n),i.current.volume=l,i.current.load()},[n,l]),()=>{i.current&&(i.current.volume=l,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function Sw(){const{session:n,pushAlert:l}=ze(),{value:i}=Qe("audio",Dt),o=Number.isFinite(i?.masterVolume)?i.masterVolume:Dt.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:Dt.alertVolume,d=Math.max(0,Math.min(1,o*f)),x=bw(yw,d),h=m.useRef(new Set),p=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const y=[];Object.entries(p).forEach(([b,A])=>{!A||!A.current||A.current!==g||h.current.has(b)||(y.push(b),h.current.add(b))}),Object.keys(p).forEach(b=>{(!p[b]||p[b].current!==g)&&h.current.delete(b)}),y.length!==0&&(y.forEach(b=>{const A=n?.roster?.find(R=>String(R.id)===String(b))?.name||b;l({title:"Your turn!",message:`You now control ${A}.`,color:"#ff5722"})}),x())},[p,x,l,n?.roster,g]),null}function Aw({visible:n,mode:l,onEnterFullscreen:i,onDismiss:o}){if(!n)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"})]})]})})})}function jw({side:n="right",onClick:l}){const i=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:l,className:`fixed bottom-2 ${i} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-cyan-200/50 bg-slate-900/70 text-cyan-100 shadow-lg backdrop-blur-sm transition hover:bg-slate-800/80 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:r.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:r.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Og="fullscreenPromptDismissed",Nw=new Set(["mobile-portrait","mobile-landscape"]),Bg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},ww=()=>{const n=Bg();if(!n)return!1;try{return n.getItem(Og)==="1"}catch{return!1}},ux=()=>{const n=Bg();if(n)try{n.setItem(Og,"1")}catch{}},Cw=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},fx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function Ew(n){const l=Nw.has(n),[i,o]=m.useState(!1),[f,d]=m.useState("native"),[x,h]=m.useState(!1),p=m.useMemo(()=>Cw(),[]),g=m.useMemo(()=>fx(),[]),y=m.useCallback(()=>{if(!l){o(!1),h(!1);return}if(!x&&ww()){o(!1);return}if(p){d("pwa-hint"),o(!0);return}if(!fx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[x,p,l]);m.useEffect(()=>{y()},[y]),m.useEffect(()=>{if(typeof document>"u")return;const N=()=>{if(document.fullscreenElement){h(!1),o(!1);return}y()};return document.addEventListener("fullscreenchange",N),document.addEventListener("webkitfullscreenchange",N),()=>{document.removeEventListener("fullscreenchange",N),document.removeEventListener("webkitfullscreenchange",N)}},[y]);const b=m.useCallback(()=>{ux(),h(!1),o(!1)},[]),A=m.useCallback(async()=>{if(!l||p||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const N=document.documentElement;if(!N)return!1;const q=N.requestFullscreen||N.webkitRequestFullscreen||N.mozRequestFullScreen||N.msRequestFullscreen;if(!q)return!1;try{const j=q.call(N);return j&&typeof j.then=="function"&&await j,ux(),h(!1),o(!1),!0}catch(j){return console.warn("Failed to enter fullscreen",j),!1}},[p,l]),R=m.useCallback(()=>{l&&(h(!0),d(p?"pwa-hint":"native"),o(!0))},[p,l]);return m.useEffect(()=>{l||(h(!1),o(!1))},[l]),{visible:i,mode:f,isIOS:p,nativeSupported:g,enterFullscreen:A,dismiss:b,showPrompt:R}}function kw({visible:n,layout:l,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!n)return null;const{state:d}=_t(),x=h=>{const p=!h.target.checked;f?.(p)};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:x,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(Rg,{layout:l,keymap:d?.keymap||{}})})]})})}const Mw=`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 qw(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function Rw(){const n=String(Mw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function dd(){const{setNickname:n}=ze(),{value:l,status:i,save:o}=Qe("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(l.nickname||"").trim())return;f.current=!0;const x=qw(Rw()).slice(0,32);if(!x)return;(async()=>{try{await n(x)}catch{}finally{o({nickname:x})}})()},[o,n,i,l.nickname])}function Tw(){const n=Rn(),{connected:l,identifySession:i}=ze(),{value:o,status:f,save:d}=Qe("identity",{cookieUserId:""}),{value:x,status:h}=Qe("profile",{nickname:""}),p=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),b=f==="ready"&&h==="ready",A=(o?.cookieUserId||"").trim(),R=(x?.nickname||"").trim(),N=m.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),q=m.useCallback(async()=>{if(!(!b||!l||!n?.id||p.current)){p.current=!0;try{const w=((await i({cookieUserId:A,nickname:R}))?.cookieUserId||"").trim();w&&w!==A&&d(E=>({...E||{},cookieUserId:w})),g.current=n.id,N()}catch{N(),y.current=setTimeout(()=>{q()},2e3)}finally{p.current=!1}}},[N,l,A,i,R,b,d,n?.id]);m.useEffect(()=>{!b||!l||!n?.id||g.current!==n.id&&q()},[l,b,q,n?.id]),m.useEffect(()=>{!b||!l||!n?.id||q()},[b,l,n?.id,A,R,q]),m.useEffect(()=>{const j=()=>{n?.connected&&q()},w=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&q()};return window.addEventListener("online",j),document.addEventListener("visibilitychange",w),()=>{window.removeEventListener("online",j),document.removeEventListener("visibilitychange",w)}},[q,n?.connected]),m.useEffect(()=>()=>N(),[N])}const mf=1e4,hf=28,Dw=14;function ho({layout:n="desktop",className:l="",dismissable:i=!0}){const{session:o}=ze(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[x,h]=m.useState(!1),[p,g]=m.useState(hf),[y,b]=m.useState(0),A=m.useRef(null),R=m.useRef(null),N=m.useRef(null);m.useEffect(()=>{if(!f){h(!1);return}if(h(!0),!d||!i)return;const E=Date.now();b(mf);const C=setTimeout(()=>h(!1),mf),M=setInterval(()=>{const U=Date.now()-E;b(Math.max(0,mf-U))},250);return()=>{clearTimeout(C),clearInterval(M)}},[f,d]),m.useEffect(()=>{if(!f)return;g(hf);let E=0;const C=()=>{const U=N.current,X=R.current;if(!U||!X)return;const _=U.clientWidth;if(!_)return;const K=X.scrollWidth;if(!K)return;const B=Math.min(1,_/K),z=Math.max(Dw,Math.floor(hf*B));g(z)};E=window.requestAnimationFrame(C);const M=new ResizeObserver(()=>{window.cancelAnimationFrame(E),E=window.requestAnimationFrame(C)});return A.current&&M.observe(A.current),()=>{window.cancelAnimationFrame(E),M.disconnect()}},[f]);const q=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||!x)return null;const j=d?Math.ceil(y/1e3):null,w=i?{onClick:()=>h(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:A,className:q,style:{fontSize:`${p}px`,lineHeight:1.1},...w,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:N,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:R,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[j,"s"]}):null]})})}function _w(){const[n,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)},[]),n}function Ow({layout:n,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(sd,{}),r.jsx(BS,{}),r.jsx(td,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(ho,{layout:n}),r.jsx(mw,{layout:n,onOpenHelpOverlay:l})]})]})}function Lg({layout:n,onOpenHelpOverlay:l,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=ze(),{state:d}=_t(),{value:x}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),h=f?.isVerified?"bg-emerald-400":"bg-amber-400",p=String(f?.assignment?.roverId||"").trim(),g=p?f?.audioForward?.[p]:null,y=!!d?.mic?.pttActive,b=!!x?.openMicEnabled,A=x?.pttMode==="clip"?"clip":"live",R=!!(p&&f?.isVerified&&(A==="clip"?y:b||y)),N=!!(p&&f?.isVerified&&A==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(cd,{defaultTab:"chat",children:[r.jsxs(ud,{children:[r.jsx(Pt,{id:"chat",children:"Chat"}),r.jsx(Pt,{id:"vip",highlight:N?"green":R?"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 ${h}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Pt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Pt,{id:"help",children:"Help"}),r.jsx(Pt,{id:"settings",children:"Settings"})]}),r.jsxs(fd,{children:[r.jsx(Wt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ao,{}),r.jsx(mo,{})]})}),r.jsx(Wt,{id:"vip",keepMounted:!0,children:r.jsx(_g,{})}),r.jsx(Wt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ng,{}),r.jsx(ed,{panelId:i})]})}),r.jsx(Wt,{id:"help",children:r.jsx(Tg,{layout:n,onOpenOverlay:l})}),r.jsx(Wt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Mg,{}),r.jsx(td,{})]})})]})]})})}function Bw({onOpenHelpOverlay:n,swapMobileControlColumns:l=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(sd,{layoutFormat:"mobile-portrait"}),r.jsx(dj,{swapColumns:l}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Xf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(No,{})]}),r.jsx(Lg,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function Lw({onOpenHelpOverlay:n,swapMobileControlColumns:l=!1}){const i="self-start h-[min(100svh,32rem)]",o=l?r.jsx(uo,{layout:"landscape",className:i}):r.jsx(co,{layout:"landscape",className:i}),f=l?r.jsx(co,{layout:"landscape",className:i}):r.jsx(uo,{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(sd,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Xf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(No,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Lg,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function zw(){const n=_w(),l=n==="desktop",i=Ew(n);return r.jsx("div",{className:`bg-black text-slate-100 ${l?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(Uw,{layout:n,isDesktop:l,fullscreen:i})})}function Uw({layout:n,isDesktop:l,fullscreen:i}){dd(),Tw();const{visible:o,mode:f,isIOS:d,nativeSupported:x,enterFullscreen:h,dismiss:p,showPrompt:g}=i,{value:y,status:b,save:A}=Qe("help",{showOnLoad:!0}),{value:R}=Qe("page",{swapMobileControlColumns:!1}),N=!!R?.swapMobileControlColumns,q=N?"left":"right",j=!l&&(d||x),[w,E]=m.useState(!1);m.useEffect(()=>{b==="ready"&&E(y?.showOnLoad!==!1)},[b,y?.showOnLoad]);const C=m.useCallback(()=>E(!0),[]),M=m.useCallback(()=>E(!1),[]),U=m.useCallback(async()=>{if(d){g();return}await h()||g()},[h,d,g]),X=m.useCallback(K=>{const B=!!K;A(z=>({...z??{},showOnLoad:B})),B||E(!1)},[A]),_=m.useMemo(()=>l?r.jsx(Ow,{layout:n,onOpenHelpOverlay:C}):n==="mobile-landscape"?r.jsx(Lw,{onOpenHelpOverlay:C,swapMobileControlColumns:N}):r.jsx(Bw,{onOpenHelpOverlay:C,swapMobileControlColumns:N}),[l,n,C,N]);return r.jsxs(MA,{children:[r.jsx(HA,{}),r.jsx(nj,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${l?"h-full overflow-hidden":""}`,children:[l?null:r.jsx(ho,{layout:n}),_]}),r.jsx(Zf,{}),r.jsx(Sw,{}),r.jsx(vw,{}),r.jsx(kw,{visible:w,layout:n,onClose:M,showOnLoad:y?.showOnLoad!==!1,onToggleShowOnLoad:X}),r.jsx(Aw,{visible:o,mode:f,onEnterFullscreen:h,onDismiss:p}),j?r.jsx(jw,{side:q,onClick:U}):null]})}function zg(){const{session:n,setRole:l,subscribeAll:i,connected:o}=ze(),[f,d]=m.useState(!1);return m.useEffect(()=>{let x=!1;async function h(){if(n?.mode==="lockdown"){d(!1);return}try{n?.role!=="spectator"&&await l("spectator"),await i(),x||d(!0)}catch(p){console.error("Failed to enter spectator mode",p),x||d(!1)}}return h(),()=>{x=!0}},[o,n?.mode,n?.role,l,i]),f}function Hw(){const[n,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)}},[]),n}function Vw({roverId:n,session:l}){const i=l?.activeDrivers?.[n]||null,f=(l?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,x=l?.turnQueues?.[n];return d==="turns"&&x?.current?`${f} (turns)`:f}function $w({rover:n,frame:l,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:x}){const h=Vw({roverId:n.id,session:x});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(bi,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:n.name,roverColor:n.color||null,telemetryFrame:l,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:h,hudForceMap:!0,hudMapPosition:"top-center"})})})}function Gw({roster:n,frames:l,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:x}){return n.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:n.map(h=>r.jsx($w,{rover:h,frame:l[h.id],sessionInfo:x&&i[h.id]||null,videoMode:x?"whep":"snapshot",snapshotFeed:x?null:o[h.id],audioInfo:f[`${h.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},h.id))})}function Yw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(ed,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Fw({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(td,{})})}function Xw(){const{session:n}=ze(),l=n?.mode==="lockdown",i=!!n?.isLocalNetwork;dd(),zg();const o=Hw(),f=Yf(),d=n?.roster??[],x=nd(d.map(j=>j.id),{enabled:!l&&!i,version:n?.mode}),h=i?d.map(j=>({type:"rover",id:j.id,key:j.id})):[],p=vi(h,{enabled:!l&&i,version:n?.mode}),g=d.flatMap(j=>j.media?.audioPublishUrl?[{type:"rover",id:`${j.id}-audio`,key:`${j.id}-audio`}]:[]),y=vi(g,{enabled:!l,version:n?.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]",A=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",R=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",N="",q=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:R,children:[o?r.jsxs("div",{className:`${N} ${q} flex flex-col gap-0.5`,children:[r.jsx(ho,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(mo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsx("div",{className:N,children:r.jsx(ho,{layout:"desktop",dismissable:!1,className:"text-sm"})}),r.jsx("div",{className:`${N} ${o?`${q} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(No,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${N} flex-1 min-h-0`,children:r.jsx(mo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${N} ${o?q:"flex-[1.1] min-h-0"}`,children:r.jsx(Ao,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${N} ${o?q:""}`,children:r.jsx(Fw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:A,children:[r.jsx(Gw,{roster:d,frames:f,videoSources:p,snapshotFeeds:x,audioSources:y,session:n,canSpectateVideo:i}),r.jsx(Yw,{})]})]}),r.jsx(Zf,{})]})}function Qw(){return r.jsx(Xw,{})}const Kw=2e4,Zw=3600*1e3;function Iw({roverId:n,session:l}){const i=l?.activeDrivers?.[n]||null,f=(l?.users||[]).find(h=>h.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,x=l?.turnQueues?.[n];return d==="turns"&&x?.current?`${f}`:f}function Jw({rover:n,frame:l}){const i=l?.sensors?.batteryChargeMah??null,o=n?.battery??null;return jg({batteryState:n?.batteryState??null,charge:i,config:o})}function dx({rover:n,frame:l,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:x=!1,showPreview:h=!0,variant:p="stacked"}){const g=Jw({rover:n,frame:l}),y=g?.available?g.percentDisplay:null,b=p==="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 ${x?"border-r border-slate-700/60":""}`,children:[r.jsx(Rf,{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(es,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(es,{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(es,{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(es,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ra(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(es,{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(es,{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:h?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(bi,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:l,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function es({children:n,className:l="",maxSize:i=1e3,minSize:o=14,style:f=void 0}){const d=m.useRef(null),x=m.useRef(null),[h,p]=m.useState(i);return m.useLayoutEffect(()=>{const g=d.current,y=x.current;if(!g||!y)return;let b=null;const A=()=>{const q=g.clientWidth;if(!q){R();return}let j=o,w=i,E=o;for(;j<=w;){const C=Math.floor((j+w)/2);y.style.fontSize=`${C}px`,y.scrollWidth<=q?(E=C,j=C+1):w=C-1}p(E)},R=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(A)};R();const N=new ResizeObserver(R);return N.observe(g),()=>{b&&cancelAnimationFrame(b),N.disconnect()}},[n,i,o]),r.jsx("div",{ref:d,className:"w-full min-w-0",children:r.jsx("div",{ref:x,className:`whitespace-nowrap ${l}`,style:{fontSize:`${h}px`,lineHeight:1.1,...f||{}},children:n})})}function Pw(){const{session:n}=ze(),l=zg();dd();const i=n?.mode==="lockdown",o=!!n?.isLocalNetwork,f=Yf(),d=n?.roster??[],[x,h]=m.useState(0),p=n?.activeDrivers||{},g=m.useMemo(()=>d.filter(z=>p[z.id]),[d,p]),y=g.length?g:d,b=nd(y.map(z=>z.id),{enabled:!i&&!o,version:n?.mode}),A=m.useMemo(()=>o?y.map(z=>({type:"rover",id:z.id,key:z.id})):[],[o,y]),R=vi(A,{enabled:!i&&o,version:n?.mode}),N=m.useMemo(()=>g.flatMap(z=>{if(!z?.id||!z.media?.audioPublishUrl)return[];const Y=String(z.id);return[{type:"rover",id:`${Y}-audio`,key:`${Y}-audio`}]}),[g]),q=vi(N,{enabled:!i,version:n?.mode}),j=m.useMemo(()=>{if(!g.length)return[];if(!o){const Y=g.filter(te=>b[te.id]?.objectUrl);return Y.length?Y:g}const z=g.filter(Y=>{const te=R[Y.id];return te?.url&&!te?.error});return z.length?z:g},[g,b,R,o]),w=m.useMemo(()=>j.map(z=>({type:"rover",rover:z})),[j]),E=m.useMemo(()=>w.map(z=>`r:${z.rover.id}`).join("|"),[w]);m.useEffect(()=>{h(0)},[E]),m.useEffect(()=>{if(!w.length)return;const z=setInterval(()=>{h(Y=>(Y+1)%w.length)},Kw);return()=>clearInterval(z)},[w.length,E]);const C=w.length?w[x%w.length]:null,M=C?.type==="rover"?C.rover:null,U=!o&&M&&b[M.id]||null,X=o&&M&&R[M.id]||null,_=M&&q[`${M.id}-audio`]||null,K=M&&f[M.id]||null,B=M?Iw({roverId:M.id,session:n}):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?M?r.jsx(e2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:w.map(z=>{const Y=z.rover,te=M?.id===Y.id;return r.jsx("div",{className:`absolute inset-0 ${te?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(bi,{sessionInfo:R[Y.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:te?_:null,forceMute:!te,label:Y.name||Y.id,roverColor:Y.color||null,telemetryFrame:f[Y.id]||null,batteryConfig:Y.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},Y.id)})}):r.jsx(bi,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:U,audioSessionInfo:_,label:M.name||M.id,roverColor:M.color||null,telemetryFrame:K,batteryConfig:M.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:M?r.jsx(dx,{rover:M,frame:K,driverLabel:B,sessionInfo:o?X:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[M.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((z,Y)=>r.jsx(dx,{rover:z,frame:f[z.id]||null,driverLabel:null,sessionInfo:o&&R[z.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[z.id]||null,showPreview:!0,withDivider:!1},z.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function Ww(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const l=new URL(window.location.href);l.searchParams.set("refresh",Date.now().toString()),window.location.replace(l.toString())},Zw);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(Pw,{}),r.jsx(Zf,{scale:3})]})}function e2({children:n}){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:n})})})}ib.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(MS,{children:r.jsx(RS,{children:r.jsx(TS,{children:r.jsx(VS,{children:r.jsx(RA,{children:r.jsx(S1,{children:r.jsxs(Pb,{children:[r.jsx(Qr,{path:"/",element:r.jsx(zw,{})}),r.jsx(Qr,{path:"/spectate",element:r.jsx(Qw,{})}),r.jsx(Qr,{path:"/mini",element:r.jsx(Ww,{})})]})})})})})})})}));