mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
127 lines
556 KiB
JavaScript
127 lines
556 KiB
JavaScript
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function l(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=l(f);fetch(f.href,d)}})();function hy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qu={exports:{}},ai={};var h0;function py(){if(h0)return ai;h0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var p in f)p!=="key"&&(d[p]=f[p])}else d=f;return f=d.ref,{$$typeof:n,type:o,key:h,ref:f!==void 0?f:null,props:d}}return ai.Fragment=s,ai.jsx=l,ai.jsxs=l,ai}var p0;function xy(){return p0||(p0=1,Qu.exports=py()),Qu.exports}var r=xy(),Ku={exports:{}},Ne={};var x0;function gy(){if(x0)return Ne;x0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function E(R){return R===null||typeof R!="object"?null:(R=S&&R[S]||R["@@iterator"],typeof R=="function"?R:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,w={};function A(R,V,ne){this.props=R,this.context=V,this.refs=w,this.updater=ne||C}A.prototype.isReactComponent={},A.prototype.setState=function(R,V){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,V,"setState")},A.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=A.prototype;function T(R,V,ne){this.props=R,this.context=V,this.refs=w,this.updater=ne||C}var M=T.prototype=new N;M.constructor=T,k(M,A.prototype),M.isPureReactComponent=!0;var O=Array.isArray;function K(){}var D={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function Q(R,V,ne){var se=ne.ref;return{$$typeof:n,type:R,key:V,ref:se!==void 0?se:null,props:ne}}function $(R,V){return Q(R.type,V,R.props)}function F(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function W(R){var V={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ne){return V[ne]})}var re=/\/+/g;function ce(R,V){return typeof R=="object"&&R!==null&&R.key!=null?W(""+R.key):V.toString(36)}function H(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(K,K):(R.status="pending",R.then(function(V){R.status==="pending"&&(R.status="fulfilled",R.value=V)},function(V){R.status==="pending"&&(R.status="rejected",R.reason=V)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function q(R,V,ne,se,pe){var oe=typeof R;(oe==="undefined"||oe==="boolean")&&(R=null);var fe=!1;if(R===null)fe=!0;else switch(oe){case"bigint":case"string":case"number":fe=!0;break;case"object":switch(R.$$typeof){case n:case s:fe=!0;break;case v:return fe=R._init,q(fe(R._payload),V,ne,se,pe)}}if(fe)return pe=pe(R),fe=se===""?"."+ce(R,0):se,O(pe)?(ne="",fe!=null&&(ne=fe.replace(re,"$&/")+"/"),q(pe,V,ne,"",function(xe){return xe})):pe!=null&&(F(pe)&&(pe=$(pe,ne+(pe.key==null||R&&R.key===pe.key?"":(""+pe.key).replace(re,"$&/")+"/")+fe)),V.push(pe)),1;fe=0;var be=se===""?".":se+":";if(O(R))for(var ve=0;ve<R.length;ve++)se=R[ve],oe=be+ce(se,ve),fe+=q(se,V,ne,oe,pe);else if(ve=E(R),typeof ve=="function")for(R=ve.call(R),ve=0;!(se=R.next()).done;)se=se.value,oe=be+ce(se,ve++),fe+=q(se,V,ne,oe,pe);else if(oe==="object"){if(typeof R.then=="function")return q(H(R),V,ne,se,pe);throw V=String(R),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return fe}function L(R,V,ne){if(R==null)return R;var se=[],pe=0;return q(R,se,"","",function(oe){return V.call(ne,oe,pe++)}),se}function Z(R){if(R._status===-1){var V=R._result;V=V(),V.then(function(ne){(R._status===0||R._status===-1)&&(R._status=1,R._result=ne)},function(ne){(R._status===0||R._status===-1)&&(R._status=2,R._result=ne)}),R._status===-1&&(R._status=0,R._result=V)}if(R._status===1)return R._result.default;throw R._result}var ae=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},ue={map:L,forEach:function(R,V,ne){L(R,function(){V.apply(this,arguments)},ne)},count:function(R){var V=0;return L(R,function(){V++}),V},toArray:function(R){return L(R,function(V){return V})||[]},only:function(R){if(!F(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ne.Activity=y,Ne.Children=ue,Ne.Component=A,Ne.Fragment=l,Ne.Profiler=f,Ne.PureComponent=T,Ne.StrictMode=o,Ne.Suspense=x,Ne.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,Ne.__COMPILER_RUNTIME={__proto__:null,c:function(R){return D.H.useMemoCache(R)}},Ne.cache=function(R){return function(){return R.apply(null,arguments)}},Ne.cacheSignal=function(){return null},Ne.cloneElement=function(R,V,ne){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var se=k({},R.props),pe=R.key;if(V!=null)for(oe in V.key!==void 0&&(pe=""+V.key),V)!U.call(V,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&V.ref===void 0||(se[oe]=V[oe]);var oe=arguments.length-2;if(oe===1)se.children=ne;else if(1<oe){for(var fe=Array(oe),be=0;be<oe;be++)fe[be]=arguments[be+2];se.children=fe}return Q(R.type,pe,se)},Ne.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:d,_context:R},R},Ne.createElement=function(R,V,ne){var se,pe={},oe=null;if(V!=null)for(se in V.key!==void 0&&(oe=""+V.key),V)U.call(V,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(pe[se]=V[se]);var fe=arguments.length-2;if(fe===1)pe.children=ne;else if(1<fe){for(var be=Array(fe),ve=0;ve<fe;ve++)be[ve]=arguments[ve+2];pe.children=be}if(R&&R.defaultProps)for(se in fe=R.defaultProps,fe)pe[se]===void 0&&(pe[se]=fe[se]);return Q(R,oe,pe)},Ne.createRef=function(){return{current:null}},Ne.forwardRef=function(R){return{$$typeof:p,render:R}},Ne.isValidElement=F,Ne.lazy=function(R){return{$$typeof:v,_payload:{_status:-1,_result:R},_init:Z}},Ne.memo=function(R,V){return{$$typeof:g,type:R,compare:V===void 0?null:V}},Ne.startTransition=function(R){var V=D.T,ne={};D.T=ne;try{var se=R(),pe=D.S;pe!==null&&pe(ne,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(K,ae)}catch(oe){ae(oe)}finally{V!==null&&ne.types!==null&&(V.types=ne.types),D.T=V}},Ne.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},Ne.use=function(R){return D.H.use(R)},Ne.useActionState=function(R,V,ne){return D.H.useActionState(R,V,ne)},Ne.useCallback=function(R,V){return D.H.useCallback(R,V)},Ne.useContext=function(R){return D.H.useContext(R)},Ne.useDebugValue=function(){},Ne.useDeferredValue=function(R,V){return D.H.useDeferredValue(R,V)},Ne.useEffect=function(R,V){return D.H.useEffect(R,V)},Ne.useEffectEvent=function(R){return D.H.useEffectEvent(R)},Ne.useId=function(){return D.H.useId()},Ne.useImperativeHandle=function(R,V,ne){return D.H.useImperativeHandle(R,V,ne)},Ne.useInsertionEffect=function(R,V){return D.H.useInsertionEffect(R,V)},Ne.useLayoutEffect=function(R,V){return D.H.useLayoutEffect(R,V)},Ne.useMemo=function(R,V){return D.H.useMemo(R,V)},Ne.useOptimistic=function(R,V){return D.H.useOptimistic(R,V)},Ne.useReducer=function(R,V,ne){return D.H.useReducer(R,V,ne)},Ne.useRef=function(R){return D.H.useRef(R)},Ne.useState=function(R){return D.H.useState(R)},Ne.useSyncExternalStore=function(R,V,ne){return D.H.useSyncExternalStore(R,V,ne)},Ne.useTransition=function(){return D.H.useTransition()},Ne.version="19.2.0",Ne}var g0;function $f(){return g0||(g0=1,Ku.exports=gy()),Ku.exports}var m=$f();const cs=hy(m);var Zu={exports:{}},si={},Iu={exports:{}},Ju={};var v0;function vy(){return v0||(v0=1,(function(n){function s(q,L){var Z=q.length;q.push(L);e:for(;0<Z;){var ae=Z-1>>>1,ue=q[ae];if(0<f(ue,L))q[ae]=L,q[Z]=ue,Z=ae;else break e}}function l(q){return q.length===0?null:q[0]}function o(q){if(q.length===0)return null;var L=q[0],Z=q.pop();if(Z!==L){q[0]=Z;e:for(var ae=0,ue=q.length,R=ue>>>1;ae<R;){var V=2*(ae+1)-1,ne=q[V],se=V+1,pe=q[se];if(0>f(ne,Z))se<ue&&0>f(pe,ne)?(q[ae]=pe,q[se]=Z,ae=se):(q[ae]=ne,q[V]=Z,ae=V);else if(se<ue&&0>f(pe,Z))q[ae]=pe,q[se]=Z,ae=se;else break e}}return L}function f(q,L){var Z=q.sortIndex-L.sortIndex;return Z!==0?Z:q.id-L.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 h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var x=[],g=[],v=1,y=null,S=3,E=!1,C=!1,k=!1,w=!1,A=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function M(q){for(var L=l(g);L!==null;){if(L.callback===null)o(g);else if(L.startTime<=q)o(g),L.sortIndex=L.expirationTime,s(x,L);else break;L=l(g)}}function O(q){if(k=!1,M(q),!C)if(l(x)!==null)C=!0,K||(K=!0,W());else{var L=l(g);L!==null&&H(O,L.startTime-q)}}var K=!1,D=-1,U=5,Q=-1;function $(){return w?!0:!(n.unstable_now()-Q<U)}function F(){if(w=!1,K){var q=n.unstable_now();Q=q;var L=!0;try{e:{C=!1,k&&(k=!1,N(D),D=-1),E=!0;var Z=S;try{t:{for(M(q),y=l(x);y!==null&&!(y.expirationTime>q&&$());){var ae=y.callback;if(typeof ae=="function"){y.callback=null,S=y.priorityLevel;var ue=ae(y.expirationTime<=q);if(q=n.unstable_now(),typeof ue=="function"){y.callback=ue,M(q),L=!0;break t}y===l(x)&&o(x),M(q)}else o(x);y=l(x)}if(y!==null)L=!0;else{var R=l(g);R!==null&&H(O,R.startTime-q),L=!1}}break e}finally{y=null,S=Z,E=!1}L=void 0}}finally{L?W():K=!1}}}var W;if(typeof T=="function")W=function(){T(F)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,ce=re.port2;re.port1.onmessage=F,W=function(){ce.postMessage(null)}}else W=function(){A(F,0)};function H(q,L){D=A(function(){q(n.unstable_now())},L)}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(q){q.callback=null},n.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<q?Math.floor(1e3/q):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(q){switch(S){case 1:case 2:case 3:var L=3;break;default:L=S}var Z=S;S=L;try{return q()}finally{S=Z}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(q,L){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var Z=S;S=q;try{return L()}finally{S=Z}},n.unstable_scheduleCallback=function(q,L,Z){var ae=n.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?ae+Z:ae):Z=ae,q){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=Z+ue,q={id:v++,callback:L,priorityLevel:q,startTime:Z,expirationTime:ue,sortIndex:-1},Z>ae?(q.sortIndex=Z,s(g,q),l(x)===null&&q===l(g)&&(k?(N(D),D=-1):k=!0,H(O,Z-ae))):(q.sortIndex=ue,s(x,q),C||E||(C=!0,K||(K=!0,W()))),q},n.unstable_shouldYield=$,n.unstable_wrapCallback=function(q){var L=S;return function(){var Z=S;S=L;try{return q.apply(this,arguments)}finally{S=Z}}}})(Ju)),Ju}var b0;function by(){return b0||(b0=1,Iu.exports=vy()),Iu.exports}var Pu={exports:{}},Bt={};var y0;function yy(){if(y0)return Bt;y0=1;var n=$f();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)g+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(){}var o={d:{f:l,r:function(){throw Error(s(522))},D:l,C:l,L:l,m:l,X:l,S:l,M:l},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(x,g,v){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:y==null?null:""+y,children:x,containerInfo:g,implementation:v}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Bt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Bt.createPortal=function(x,g){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return d(x,g,null,v)},Bt.flushSync=function(x){var g=h.T,v=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=v,o.d.f()}},Bt.preconnect=function(x,g){typeof x=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(x,g))},Bt.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},Bt.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var v=g.as,y=p(v,g.crossOrigin),S=typeof g.integrity=="string"?g.integrity:void 0,E=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;v==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:E}):v==="script"&&o.d.X(x,{crossOrigin:y,integrity:S,fetchPriority:E,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Bt.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var v=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Bt.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var v=g.as,y=p(v,g.crossOrigin);o.d.L(x,v,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Bt.preloadModule=function(x,g){if(typeof x=="string")if(g){var v=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Bt.requestFormReset=function(x){o.d.r(x)},Bt.unstable_batchedUpdates=function(x,g){return x(g)},Bt.useFormState=function(x,g,v){return h.H.useFormState(x,g,v)},Bt.useFormStatus=function(){return h.H.useHostTransitionStatus()},Bt.version="19.2.0",Bt}var S0;function Sy(){if(S0)return Pu.exports;S0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Pu.exports=yy(),Pu.exports}var j0;function jy(){if(j0)return si;j0=1;var n=by(),s=$f(),l=Sy();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 h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,i=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(i=c.return,i!==null){a=i;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return x(c),e;if(u===i)return x(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==i.return)a=c,i=u;else{for(var b=!1,j=c.child;j;){if(j===a){b=!0,a=c,i=u;break}if(j===i){b=!0,i=c,a=u;break}j=j.sibling}if(!b){for(j=u.child;j;){if(j===a){b=!0,a=u,i=c;break}if(j===i){b=!0,i=u,a=c;break}j=j.sibling}if(!b)throw Error(o(189))}}if(a.alternate!==i)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),E=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),T=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function W(e){return e===null||typeof e!="object"?null:(e=F&&e[F]||e["@@iterator"],typeof e=="function"?e:null)}var re=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===re?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case A:return"Profiler";case w:return"StrictMode";case O:return"Suspense";case K:return"SuspenseList";case Q:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case T:return e.displayName||"Context";case N: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 D:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case U:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var H=Array.isArray,q=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},ae=[],ue=-1;function R(e){return{current:e}}function V(e){0>ue||(e.current=ae[ue],ae[ue]=null,ue--)}function ne(e,t){ue++,ae[ue]=e.current,e.current=t}var se=R(null),pe=R(null),oe=R(null),fe=R(null);function be(e,t){switch(ne(oe,t),ne(pe,e),ne(se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Lp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Lp(t),e=zp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(se),ne(se,e)}function ve(){V(se),V(pe),V(oe)}function xe(e){e.memoizedState!==null&&ne(fe,e);var t=se.current,a=zp(t,e.type);t!==a&&(ne(pe,e),ne(se,a))}function Le(e){pe.current===e&&(V(se),V(pe)),fe.current===e&&(V(fe),Wl._currentValue=Z)}var De,Ee;function nt(e){if(De===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);De=t&&t[1]||"",Ee=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+De+e+Ee}var Ve=!1;function mt(e,t){if(!e||Ve)return"";Ve=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var te=function(){throw Error()};if(Object.defineProperty(te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(te,[])}catch(I){var X=I}Reflect.construct(e,[],te)}else{try{te.call()}catch(I){X=I}e.call(te.prototype)}}else{try{throw Error()}catch(I){X=I}(te=e())&&typeof te.catch=="function"&&te.catch(function(){})}}catch(I){if(I&&X&&typeof I.stack=="string")return[I.stack,X.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=i.DetermineComponentFrameRoot(),b=u[0],j=u[1];if(b&&j){var _=b.split(`
|
||
`),Y=j.split(`
|
||
`);for(c=i=0;i<_.length&&!_[i].includes("DetermineComponentFrameRoot");)i++;for(;c<Y.length&&!Y[c].includes("DetermineComponentFrameRoot");)c++;if(i===_.length||c===Y.length)for(i=_.length-1,c=Y.length-1;1<=i&&0<=c&&_[i]!==Y[c];)c--;for(;1<=i&&0<=c;i--,c--)if(_[i]!==Y[c]){if(i!==1||c!==1)do if(i--,c--,0>c||_[i]!==Y[c]){var P=`
|
||
`+_[i].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),P}while(1<=i&&0<=c);break}}}finally{Ve=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?nt(a):""}function ie(e,t){switch(e.tag){case 26:case 27:case 5:return nt(e.type);case 16:return nt("Lazy");case 13:return e.child!==t&&t!==null?nt("Suspense Fallback"):nt("Suspense");case 19:return nt("SuspenseList");case 0:case 15:return mt(e.type,!1);case 11:return mt(e.type.render,!1);case 1:return mt(e.type,!0);case 31:return nt("Activity");default:return""}}function me(e){try{var t="",a=null;do t+=ie(e,a),a=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var le=Object.prototype.hasOwnProperty,J=n.unstable_scheduleCallback,he=n.unstable_cancelCallback,Ae=n.unstable_shouldYield,ht=n.unstable_requestPaint,Oe=n.unstable_now,rt=n.unstable_getCurrentPriorityLevel,ot=n.unstable_ImmediatePriority,gt=n.unstable_UserBlockingPriority,kt=n.unstable_NormalPriority,fs=n.unstable_LowPriority,Lt=n.unstable_IdlePriority,fl=n.log,dl=n.unstable_setDisableYieldValue,yn=null,wt=null;function an(e){if(typeof fl=="function"&&dl(e),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(yn,e)}catch{}}var vt=Math.clz32?Math.clz32:Lo,Oo=Math.log,ds=Math.LN2;function Lo(e){return e>>>=0,e===0?32:31-(Oo(e)/ds|0)|0}var Oa=256,We=262144,ms=4194304;function Ft(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 ua(e,t,a){var i=e.pendingLanes;if(i===0)return 0;var c=0,u=e.suspendedLanes,b=e.pingedLanes;e=e.warmLanes;var j=i&134217727;return j!==0?(i=j&~u,i!==0?c=Ft(i):(b&=j,b!==0?c=Ft(b):a||(a=j&~e,a!==0&&(c=Ft(a))))):(j=i&~u,j!==0?c=Ft(j):b!==0?c=Ft(b):a||(a=i&~e,a!==0&&(c=Ft(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 Mn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function qi(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 Ti(){var e=ms;return ms<<=1,(ms&62914560)===0&&(ms=4194304),e}function ml(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 Di(e,t,a,i,c,u){var b=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var j=e.entanglements,_=e.expirationTimes,Y=e.hiddenUpdates;for(a=b&~a;0<a;){var P=31-vt(a),te=1<<P;j[P]=0,_[P]=-1;var X=Y[P];if(X!==null)for(Y[P]=null,P=0;P<X.length;P++){var I=X[P];I!==null&&(I.lane&=-536870913)}a&=~te}i!==0&&sn(e,i,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(b&~t))}function sn(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-vt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|a&261930}function ye(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var i=31-vt(a),c=1<<i;c&t|e[i]&t&&(e[i]|=t),a&=~c}}function Ie(e,t){var a=t&-t;return a=(a&42)!==0?1:Je(a),(a&(e.suspendedLanes|t))!==0?0:a}function Je(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 ke(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ye(){var e=L.p;return e!==0?e:(e=window.event,e===void 0?32:r0(e.type))}function Mt(e,t){var a=L.p;try{return L.p=e,t()}finally{L.p=a}}var zt=Math.random().toString(36).slice(2),ct="__reactFiber$"+zt,ze="__reactProps$"+zt,ln="__reactContainer$"+zt,zo="__reactEvents$"+zt,av="__reactListeners$"+zt,sv="__reactHandles$"+zt,Nd="__reactResources$"+zt,hl="__reactMarker$"+zt;function Uo(e){delete e[ct],delete e[ze],delete e[zo],delete e[av],delete e[sv]}function hs(e){var t=e[ct];if(t)return t;for(var a=e.parentNode;a;){if(t=a[ln]||a[ct]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Fp(e);e!==null;){if(a=e[ct])return a;e=Fp(e)}return t}e=a,a=e.parentNode}return null}function ps(e){if(e=e[ct]||e[ln]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function pl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function xs(e){var t=e[Nd];return t||(t=e[Nd]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ct(e){e[hl]=!0}var wd=new Set,Cd={};function za(e,t){gs(e,t),gs(e+"Capture",t)}function gs(e,t){for(Cd[e]=t,e=0;e<t.length;e++)wd.add(t[e])}var lv=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]*$"),Ed={},kd={};function iv(e){return le.call(kd,e)?!0:le.call(Ed,e)?!1:lv.test(e)?kd[e]=!0:(Ed[e]=!0,!1)}function _i(e,t,a){if(iv(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function Bi(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 zn(e,t,a,i){if(i===null)e.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+i)}}function rn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Md(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function rv(e,t,a){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,u=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(b){a=""+b,u.call(this,b)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return a},setValue:function(b){a=""+b},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ho(e){if(!e._valueTracker){var t=Md(e)?"checked":"value";e._valueTracker=rv(e,t,""+e[t])}}function Rd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),i="";return e&&(i=Md(e)?e.checked?"true":"false":e.value),e=i,e!==a?(t.setValue(e),!0):!1}function Oi(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 ov=/[\n"\\]/g;function on(e){return e.replace(ov,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Vo(e,t,a,i,c,u,b,j){e.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.type=b:e.removeAttribute("type"),t!=null?b==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+rn(t)):e.value!==""+rn(t)&&(e.value=""+rn(t)):b!=="submit"&&b!=="reset"||e.removeAttribute("value"),t!=null?$o(e,b,rn(t)):a!=null?$o(e,b,rn(a)):i!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.name=""+rn(j):e.removeAttribute("name")}function qd(e,t,a,i,c,u,b,j){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)){Ho(e);return}a=a!=null?""+rn(a):"",t=t!=null?""+rn(t):a,j||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=j?e.checked:!!i,e.defaultChecked=!!i,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(e.name=b),Ho(e)}function $o(e,t,a){t==="number"&&Oi(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function vs(e,t,a,i){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&i&&(e[a].defaultSelected=!0)}else{for(a=""+rn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Td(e,t,a){if(t!=null&&(t=""+rn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+rn(a):""}function Dd(e,t,a,i){if(t==null){if(i!=null){if(a!=null)throw Error(o(92));if(H(i)){if(1<i.length)throw Error(o(93));i=i[0]}a=i}a==null&&(a=""),t=a}a=rn(t),e.defaultValue=a,i=e.textContent,i===a&&i!==""&&i!==null&&(e.value=i),Ho(e)}function bs(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var cv=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 _d(e,t,a){var i=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,a):typeof a!="number"||a===0||cv.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Bd(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var i in a)!a.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&a[c]!==i&&_d(e,c,i)}else for(var u in t)t.hasOwnProperty(u)&&_d(e,u,t[u])}function Go(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var uv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),fv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Li(e){return fv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Un(){}var Yo=null;function Fo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ys=null,Ss=null;function Od(e){var t=ps(e);if(t&&(e=t.stateNode)){var a=e[ze]||null;e:switch(e=t.stateNode,t.type){case"input":if(Vo(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+on(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var i=a[t];if(i!==e&&i.form===e.form){var c=i[ze]||null;if(!c)throw Error(o(90));Vo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)i=a[t],i.form===e.form&&Rd(i)}break e;case"textarea":Td(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&vs(e,!!a.multiple,t,!1)}}}var Xo=!1;function Ld(e,t,a){if(Xo)return e(t,a);Xo=!0;try{var i=e(t);return i}finally{if(Xo=!1,(ys!==null||Ss!==null)&&(Nr(),ys&&(t=ys,e=Ss,Ss=ys=null,Od(t),e)))for(t=0;t<e.length;t++)Od(e[t])}}function xl(e,t){var a=e.stateNode;if(a===null)return null;var i=a[ze]||null;if(i===null)return null;a=i[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Hn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qo=!1;if(Hn)try{var gl={};Object.defineProperty(gl,"passive",{get:function(){Qo=!0}}),window.addEventListener("test",gl,gl),window.removeEventListener("test",gl,gl)}catch{Qo=!1}var fa=null,Ko=null,zi=null;function zd(){if(zi)return zi;var e,t=Ko,a=t.length,i,c="value"in fa?fa.value:fa.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var b=a-e;for(i=1;i<=b&&t[a-i]===c[u-i];i++);return zi=c.slice(e,1<i?1-i:void 0)}function Ui(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 Hi(){return!0}function Ud(){return!1}function Ut(e){function t(a,i,c,u,b){this._reactName=a,this._targetInst=c,this.type=i,this.nativeEvent=u,this.target=b,this.currentTarget=null;for(var j in e)e.hasOwnProperty(j)&&(a=e[j],this[j]=a?a(u):u[j]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Hi:Ud,this.isPropagationStopped=Ud,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Hi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Hi)},persist:function(){},isPersistent:Hi}),t}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vi=Ut(Ua),vl=y({},Ua,{view:0,detail:0}),dv=Ut(vl),Zo,Io,bl,$i=y({},vl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Po,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==bl&&(bl&&e.type==="mousemove"?(Zo=e.screenX-bl.screenX,Io=e.screenY-bl.screenY):Io=Zo=0,bl=e),Zo)},movementY:function(e){return"movementY"in e?e.movementY:Io}}),Hd=Ut($i),mv=y({},$i,{dataTransfer:0}),hv=Ut(mv),pv=y({},vl,{relatedTarget:0}),Jo=Ut(pv),xv=y({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),gv=Ut(xv),vv=y({},Ua,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),bv=Ut(vv),yv=y({},Ua,{data:0}),Vd=Ut(yv),Sv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jv={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"},Av={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Nv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Av[e])?!!t[e]:!1}function Po(){return Nv}var wv=y({},vl,{key:function(e){if(e.key){var t=Sv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?jv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Po,charCode:function(e){return e.type==="keypress"?Ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Cv=Ut(wv),Ev=y({},$i,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$d=Ut(Ev),kv=y({},vl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Po}),Mv=Ut(kv),Rv=y({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),qv=Ut(Rv),Tv=y({},$i,{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}),Dv=Ut(Tv),_v=y({},Ua,{newState:0,oldState:0}),Bv=Ut(_v),Ov=[9,13,27,32],Wo=Hn&&"CompositionEvent"in window,yl=null;Hn&&"documentMode"in document&&(yl=document.documentMode);var Lv=Hn&&"TextEvent"in window&&!yl,Gd=Hn&&(!Wo||yl&&8<yl&&11>=yl),Yd=" ",Fd=!1;function Xd(e,t){switch(e){case"keyup":return Ov.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var js=!1;function zv(e,t){switch(e){case"compositionend":return Qd(t);case"keypress":return t.which!==32?null:(Fd=!0,Yd);case"textInput":return e=t.data,e===Yd&&Fd?null:e;default:return null}}function Uv(e,t){if(js)return e==="compositionend"||!Wo&&Xd(e,t)?(e=zd(),zi=Ko=fa=null,js=!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 Gd&&t.locale!=="ko"?null:t.data;default:return null}}var Hv={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 Kd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Hv[e.type]:t==="textarea"}function Zd(e,t,a,i){ys?Ss?Ss.push(i):Ss=[i]:ys=i,t=qr(t,"onChange"),0<t.length&&(a=new Vi("onChange","change",null,a,i),e.push({event:a,listeners:t}))}var Sl=null,jl=null;function Vv(e){qp(e,0)}function Gi(e){var t=pl(e);if(Rd(t))return e}function Id(e,t){if(e==="change")return t}var Jd=!1;if(Hn){var ec;if(Hn){var tc="oninput"in document;if(!tc){var Pd=document.createElement("div");Pd.setAttribute("oninput","return;"),tc=typeof Pd.oninput=="function"}ec=tc}else ec=!1;Jd=ec&&(!document.documentMode||9<document.documentMode)}function Wd(){Sl&&(Sl.detachEvent("onpropertychange",em),jl=Sl=null)}function em(e){if(e.propertyName==="value"&&Gi(jl)){var t=[];Zd(t,jl,e,Fo(e)),Ld(Vv,t)}}function $v(e,t,a){e==="focusin"?(Wd(),Sl=t,jl=a,Sl.attachEvent("onpropertychange",em)):e==="focusout"&&Wd()}function Gv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Gi(jl)}function Yv(e,t){if(e==="click")return Gi(t)}function Fv(e,t){if(e==="input"||e==="change")return Gi(t)}function Xv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xt=typeof Object.is=="function"?Object.is:Xv;function Al(e,t){if(Xt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;for(i=0;i<a.length;i++){var c=a[i];if(!le.call(t,c)||!Xt(e[c],t[c]))return!1}return!0}function tm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nm(e,t){var a=tm(e);e=0;for(var i;a;){if(a.nodeType===3){if(i=e+a.textContent.length,e<=t&&i>=t)return{node:a,offset:t-e};e=i}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=tm(a)}}function am(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?am(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function sm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Oi(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=Oi(e.document)}return t}function nc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Qv=Hn&&"documentMode"in document&&11>=document.documentMode,As=null,ac=null,Nl=null,sc=!1;function lm(e,t,a){var i=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;sc||As==null||As!==Oi(i)||(i=As,"selectionStart"in i&&nc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Nl&&Al(Nl,i)||(Nl=i,i=qr(ac,"onSelect"),0<i.length&&(t=new Vi("onSelect","select",null,t,a),e.push({event:t,listeners:i}),t.target=As)))}function Ha(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Ns={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")},lc={},im={};Hn&&(im=document.createElement("div").style,"AnimationEvent"in window||(delete Ns.animationend.animation,delete Ns.animationiteration.animation,delete Ns.animationstart.animation),"TransitionEvent"in window||delete Ns.transitionend.transition);function Va(e){if(lc[e])return lc[e];if(!Ns[e])return e;var t=Ns[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in im)return lc[e]=t[a];return e}var rm=Va("animationend"),om=Va("animationiteration"),cm=Va("animationstart"),Kv=Va("transitionrun"),Zv=Va("transitionstart"),Iv=Va("transitioncancel"),um=Va("transitionend"),fm=new Map,ic="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(" ");ic.push("scrollEnd");function Sn(e,t){fm.set(e,t),za(t,[e])}var Yi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},cn=[],ws=0,rc=0;function Fi(){for(var e=ws,t=rc=ws=0;t<e;){var a=cn[t];cn[t++]=null;var i=cn[t];cn[t++]=null;var c=cn[t];cn[t++]=null;var u=cn[t];if(cn[t++]=null,i!==null&&c!==null){var b=i.pending;b===null?c.next=c:(c.next=b.next,b.next=c),i.pending=c}u!==0&&dm(a,c,u)}}function Xi(e,t,a,i){cn[ws++]=e,cn[ws++]=t,cn[ws++]=a,cn[ws++]=i,rc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function oc(e,t,a,i){return Xi(e,t,a,i),Qi(e)}function $a(e,t){return Xi(e,null,null,t),Qi(e)}function dm(e,t,a){e.lanes|=a;var i=e.alternate;i!==null&&(i.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,i=u.alternate,i!==null&&(i.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-vt(a),e=u.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=a|536870912),u):null}function Qi(e){if(50<Xl)throw Xl=0,gu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Cs={};function Jv(e,t,a,i){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qt(e,t,a,i){return new Jv(e,t,a,i)}function cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vn(e,t){var a=e.alternate;return a===null?(a=Qt(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 mm(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 Ki(e,t,a,i,c,u){var b=0;if(i=e,typeof e=="function")cc(e)&&(b=1);else if(typeof e=="string")b=ny(e,a,se.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Q:return e=Qt(31,a,t,c),e.elementType=Q,e.lanes=u,e;case k:return Ga(a.children,c,u,t);case w:b=8,c|=24;break;case A:return e=Qt(12,a,t,c|2),e.elementType=A,e.lanes=u,e;case O:return e=Qt(13,a,t,c),e.elementType=O,e.lanes=u,e;case K:return e=Qt(19,a,t,c),e.elementType=K,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case T:b=10;break e;case N:b=9;break e;case M:b=11;break e;case D:b=14;break e;case U:b=16,i=null;break e}b=29,a=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Qt(b,a,t,c),t.elementType=e,t.type=i,t.lanes=u,t}function Ga(e,t,a,i){return e=Qt(7,e,i,t),e.lanes=a,e}function uc(e,t,a){return e=Qt(6,e,null,t),e.lanes=a,e}function hm(e){var t=Qt(18,null,null,0);return t.stateNode=e,t}function fc(e,t,a){return t=Qt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var pm=new WeakMap;function un(e,t){if(typeof e=="object"&&e!==null){var a=pm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:me(t)},pm.set(e,t),t)}return{value:e,source:t,stack:me(t)}}var Es=[],ks=0,Zi=null,wl=0,fn=[],dn=0,da=null,Rn=1,qn="";function $n(e,t){Es[ks++]=wl,Es[ks++]=Zi,Zi=e,wl=t}function xm(e,t,a){fn[dn++]=Rn,fn[dn++]=qn,fn[dn++]=da,da=e;var i=Rn;e=qn;var c=32-vt(i)-1;i&=~(1<<c),a+=1;var u=32-vt(t)+c;if(30<u){var b=c-c%5;u=(i&(1<<b)-1).toString(32),i>>=b,c-=b,Rn=1<<32-vt(t)+c|a<<c|i,qn=u+e}else Rn=1<<u|a<<c|i,qn=e}function dc(e){e.return!==null&&($n(e,1),xm(e,1,0))}function mc(e){for(;e===Zi;)Zi=Es[--ks],Es[ks]=null,wl=Es[--ks],Es[ks]=null;for(;e===da;)da=fn[--dn],fn[dn]=null,qn=fn[--dn],fn[dn]=null,Rn=fn[--dn],fn[dn]=null}function gm(e,t){fn[dn++]=Rn,fn[dn++]=qn,fn[dn++]=da,Rn=t.id,qn=t.overflow,da=e}var Rt=null,et=null,_e=!1,ma=null,mn=!1,hc=Error(o(519));function ha(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Cl(un(t,e)),hc}function vm(e){var t=e.stateNode,a=e.type,i=e.memoizedProps;switch(t[ct]=e,t[ze]=i,a){case"dialog":Re("cancel",t),Re("close",t);break;case"iframe":case"object":case"embed":Re("load",t);break;case"video":case"audio":for(a=0;a<Kl.length;a++)Re(Kl[a],t);break;case"source":Re("error",t);break;case"img":case"image":case"link":Re("error",t),Re("load",t);break;case"details":Re("toggle",t);break;case"input":Re("invalid",t),qd(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Re("invalid",t);break;case"textarea":Re("invalid",t),Dd(t,i.value,i.defaultValue,i.children)}a=i.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||i.suppressHydrationWarning===!0||Bp(t.textContent,a)?(i.popover!=null&&(Re("beforetoggle",t),Re("toggle",t)),i.onScroll!=null&&Re("scroll",t),i.onScrollEnd!=null&&Re("scrollend",t),i.onClick!=null&&(t.onclick=Un),t=!0):t=!1,t||ha(e,!0)}function bm(e){for(Rt=e.return;Rt;)switch(Rt.tag){case 5:case 31:case 13:mn=!1;return;case 27:case 3:mn=!0;return;default:Rt=Rt.return}}function Ms(e){if(e!==Rt)return!1;if(!_e)return bm(e),_e=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Tu(e.type,e.memoizedProps)),a=!a),a&&et&&ha(e),bm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));et=Yp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));et=Yp(e)}else t===27?(t=et,ka(e.type)?(e=Lu,Lu=null,et=e):et=t):et=Rt?pn(e.stateNode.nextSibling):null;return!0}function Ya(){et=Rt=null,_e=!1}function pc(){var e=ma;return e!==null&&(Gt===null?Gt=e:Gt.push.apply(Gt,e),ma=null),e}function Cl(e){ma===null?ma=[e]:ma.push(e)}var xc=R(null),Fa=null,Gn=null;function pa(e,t,a){ne(xc,t._currentValue),t._currentValue=a}function Yn(e){e._currentValue=xc.current,V(xc)}function gc(e,t,a){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===a)break;e=e.return}}function vc(e,t,a,i){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var b=c.child;u=u.firstContext;e:for(;u!==null;){var j=u;u=c;for(var _=0;_<t.length;_++)if(j.context===t[_]){u.lanes|=a,j=u.alternate,j!==null&&(j.lanes|=a),gc(u.return,a,e),i||(b=null);break e}u=j.next}}else if(c.tag===18){if(b=c.return,b===null)throw Error(o(341));b.lanes|=a,u=b.alternate,u!==null&&(u.lanes|=a),gc(b,a,e),b=null}else b=c.child;if(b!==null)b.return=c;else for(b=c;b!==null;){if(b===e){b=null;break}if(c=b.sibling,c!==null){c.return=b.return,b=c;break}b=b.return}c=b}}function Rs(e,t,a,i){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 b=c.alternate;if(b===null)throw Error(o(387));if(b=b.memoizedProps,b!==null){var j=c.type;Xt(c.pendingProps.value,b.value)||(e!==null?e.push(j):e=[j])}}else if(c===fe.current){if(b=c.alternate,b===null)throw Error(o(387));b.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Wl):e=[Wl])}c=c.return}e!==null&&vc(t,e,a,i),t.flags|=262144}function Ii(e){for(e=e.firstContext;e!==null;){if(!Xt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xa(e){Fa=e,Gn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function qt(e){return ym(Fa,e)}function Ji(e,t){return Fa===null&&Xa(e),ym(e,t)}function ym(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Gn===null){if(e===null)throw Error(o(308));Gn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Gn=Gn.next=t;return a}var Pv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Wv=n.unstable_scheduleCallback,eb=n.unstable_NormalPriority,bt={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bc(){return{controller:new Pv,data:new Map,refCount:0}}function El(e){e.refCount--,e.refCount===0&&Wv(eb,function(){e.controller.abort()})}var kl=null,yc=0,qs=0,Ts=null;function tb(e,t){if(kl===null){var a=kl=[];yc=0,qs=Au(),Ts={status:"pending",value:void 0,then:function(i){a.push(i)}}}return yc++,t.then(Sm,Sm),t}function Sm(){if(--yc===0&&kl!==null){Ts!==null&&(Ts.status="fulfilled");var e=kl;kl=null,qs=0,Ts=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function nb(e,t){var a=[],i={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),i}var jm=q.S;q.S=function(e,t){lp=Oe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&tb(e,t),jm!==null&&jm(e,t)};var Qa=R(null);function Sc(){var e=Qa.current;return e!==null?e:Pe.pooledCache}function Pi(e,t){t===null?ne(Qa,Qa.current):ne(Qa,t.pool)}function Am(){var e=Sc();return e===null?null:{parent:bt._currentValue,pool:e}}var Ds=Error(o(460)),jc=Error(o(474)),Wi=Error(o(542)),er={then:function(){}};function Nm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function wm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Un,Un),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Em(e),e;default:if(typeof t.status=="string")t.then(Un,Un);else{if(e=Pe,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Em(e),e}throw Za=t,Ds}}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,Ds):a}}var Za=null;function Cm(){if(Za===null)throw Error(o(459));var e=Za;return Za=null,e}function Em(e){if(e===Ds||e===Wi)throw Error(o(483))}var _s=null,Ml=0;function tr(e){var t=Ml;return Ml+=1,_s===null&&(_s=[]),wm(_s,e,t)}function Rl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function nr(e,t){throw t.$$typeof===S?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function km(e){function t(z,B){if(e){var G=z.deletions;G===null?(z.deletions=[B],z.flags|=16):G.push(B)}}function a(z,B){if(!e)return null;for(;B!==null;)t(z,B),B=B.sibling;return null}function i(z){for(var B=new Map;z!==null;)z.key!==null?B.set(z.key,z):B.set(z.index,z),z=z.sibling;return B}function c(z,B){return z=Vn(z,B),z.index=0,z.sibling=null,z}function u(z,B,G){return z.index=G,e?(G=z.alternate,G!==null?(G=G.index,G<B?(z.flags|=67108866,B):G):(z.flags|=67108866,B)):(z.flags|=1048576,B)}function b(z){return e&&z.alternate===null&&(z.flags|=67108866),z}function j(z,B,G,ee){return B===null||B.tag!==6?(B=uc(G,z.mode,ee),B.return=z,B):(B=c(B,G),B.return=z,B)}function _(z,B,G,ee){var Se=G.type;return Se===k?P(z,B,G.props.children,ee,G.key):B!==null&&(B.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===U&&Ka(Se)===B.type)?(B=c(B,G.props),Rl(B,G),B.return=z,B):(B=Ki(G.type,G.key,G.props,null,z.mode,ee),Rl(B,G),B.return=z,B)}function Y(z,B,G,ee){return B===null||B.tag!==4||B.stateNode.containerInfo!==G.containerInfo||B.stateNode.implementation!==G.implementation?(B=fc(G,z.mode,ee),B.return=z,B):(B=c(B,G.children||[]),B.return=z,B)}function P(z,B,G,ee,Se){return B===null||B.tag!==7?(B=Ga(G,z.mode,ee,Se),B.return=z,B):(B=c(B,G),B.return=z,B)}function te(z,B,G){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=uc(""+B,z.mode,G),B.return=z,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case E:return G=Ki(B.type,B.key,B.props,null,z.mode,G),Rl(G,B),G.return=z,G;case C:return B=fc(B,z.mode,G),B.return=z,B;case U:return B=Ka(B),te(z,B,G)}if(H(B)||W(B))return B=Ga(B,z.mode,G,null),B.return=z,B;if(typeof B.then=="function")return te(z,tr(B),G);if(B.$$typeof===T)return te(z,Ji(z,B),G);nr(z,B)}return null}function X(z,B,G,ee){var Se=B!==null?B.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Se!==null?null:j(z,B,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case E:return G.key===Se?_(z,B,G,ee):null;case C:return G.key===Se?Y(z,B,G,ee):null;case U:return G=Ka(G),X(z,B,G,ee)}if(H(G)||W(G))return Se!==null?null:P(z,B,G,ee,null);if(typeof G.then=="function")return X(z,B,tr(G),ee);if(G.$$typeof===T)return X(z,B,Ji(z,G),ee);nr(z,G)}return null}function I(z,B,G,ee,Se){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return z=z.get(G)||null,j(B,z,""+ee,Se);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case E:return z=z.get(ee.key===null?G:ee.key)||null,_(B,z,ee,Se);case C:return z=z.get(ee.key===null?G:ee.key)||null,Y(B,z,ee,Se);case U:return ee=Ka(ee),I(z,B,G,ee,Se)}if(H(ee)||W(ee))return z=z.get(G)||null,P(B,z,ee,Se,null);if(typeof ee.then=="function")return I(z,B,G,tr(ee),Se);if(ee.$$typeof===T)return I(z,B,G,Ji(B,ee),Se);nr(B,ee)}return null}function de(z,B,G,ee){for(var Se=null,Ue=null,ge=B,Ce=B=0,Te=null;ge!==null&&Ce<G.length;Ce++){ge.index>Ce?(Te=ge,ge=null):Te=ge.sibling;var He=X(z,ge,G[Ce],ee);if(He===null){ge===null&&(ge=Te);break}e&&ge&&He.alternate===null&&t(z,ge),B=u(He,B,Ce),Ue===null?Se=He:Ue.sibling=He,Ue=He,ge=Te}if(Ce===G.length)return a(z,ge),_e&&$n(z,Ce),Se;if(ge===null){for(;Ce<G.length;Ce++)ge=te(z,G[Ce],ee),ge!==null&&(B=u(ge,B,Ce),Ue===null?Se=ge:Ue.sibling=ge,Ue=ge);return _e&&$n(z,Ce),Se}for(ge=i(ge);Ce<G.length;Ce++)Te=I(ge,z,Ce,G[Ce],ee),Te!==null&&(e&&Te.alternate!==null&&ge.delete(Te.key===null?Ce:Te.key),B=u(Te,B,Ce),Ue===null?Se=Te:Ue.sibling=Te,Ue=Te);return e&&ge.forEach(function(Da){return t(z,Da)}),_e&&$n(z,Ce),Se}function je(z,B,G,ee){if(G==null)throw Error(o(151));for(var Se=null,Ue=null,ge=B,Ce=B=0,Te=null,He=G.next();ge!==null&&!He.done;Ce++,He=G.next()){ge.index>Ce?(Te=ge,ge=null):Te=ge.sibling;var Da=X(z,ge,He.value,ee);if(Da===null){ge===null&&(ge=Te);break}e&&ge&&Da.alternate===null&&t(z,ge),B=u(Da,B,Ce),Ue===null?Se=Da:Ue.sibling=Da,Ue=Da,ge=Te}if(He.done)return a(z,ge),_e&&$n(z,Ce),Se;if(ge===null){for(;!He.done;Ce++,He=G.next())He=te(z,He.value,ee),He!==null&&(B=u(He,B,Ce),Ue===null?Se=He:Ue.sibling=He,Ue=He);return _e&&$n(z,Ce),Se}for(ge=i(ge);!He.done;Ce++,He=G.next())He=I(ge,z,Ce,He.value,ee),He!==null&&(e&&He.alternate!==null&&ge.delete(He.key===null?Ce:He.key),B=u(He,B,Ce),Ue===null?Se=He:Ue.sibling=He,Ue=He);return e&&ge.forEach(function(my){return t(z,my)}),_e&&$n(z,Ce),Se}function Ze(z,B,G,ee){if(typeof G=="object"&&G!==null&&G.type===k&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case E:e:{for(var Se=G.key;B!==null;){if(B.key===Se){if(Se=G.type,Se===k){if(B.tag===7){a(z,B.sibling),ee=c(B,G.props.children),ee.return=z,z=ee;break e}}else if(B.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===U&&Ka(Se)===B.type){a(z,B.sibling),ee=c(B,G.props),Rl(ee,G),ee.return=z,z=ee;break e}a(z,B);break}else t(z,B);B=B.sibling}G.type===k?(ee=Ga(G.props.children,z.mode,ee,G.key),ee.return=z,z=ee):(ee=Ki(G.type,G.key,G.props,null,z.mode,ee),Rl(ee,G),ee.return=z,z=ee)}return b(z);case C:e:{for(Se=G.key;B!==null;){if(B.key===Se)if(B.tag===4&&B.stateNode.containerInfo===G.containerInfo&&B.stateNode.implementation===G.implementation){a(z,B.sibling),ee=c(B,G.children||[]),ee.return=z,z=ee;break e}else{a(z,B);break}else t(z,B);B=B.sibling}ee=fc(G,z.mode,ee),ee.return=z,z=ee}return b(z);case U:return G=Ka(G),Ze(z,B,G,ee)}if(H(G))return de(z,B,G,ee);if(W(G)){if(Se=W(G),typeof Se!="function")throw Error(o(150));return G=Se.call(G),je(z,B,G,ee)}if(typeof G.then=="function")return Ze(z,B,tr(G),ee);if(G.$$typeof===T)return Ze(z,B,Ji(z,G),ee);nr(z,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,B!==null&&B.tag===6?(a(z,B.sibling),ee=c(B,G),ee.return=z,z=ee):(a(z,B),ee=uc(G,z.mode,ee),ee.return=z,z=ee),b(z)):a(z,B)}return function(z,B,G,ee){try{Ml=0;var Se=Ze(z,B,G,ee);return _s=null,Se}catch(ge){if(ge===Ds||ge===Wi)throw ge;var Ue=Qt(29,ge,null,z.mode);return Ue.lanes=ee,Ue.return=z,Ue}finally{}}}var Ia=km(!0),Mm=km(!1),xa=!1;function Ac(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Nc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ga(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function va(e,t,a){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,($e&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Qi(e),dm(e,null,a),t}return Xi(e,i,t,a),Qi(e)}function ql(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,ye(e,a)}}function wc(e,t){var a=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,a===i)){var c=null,u=null;if(a=a.firstBaseUpdate,a!==null){do{var b={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};u===null?c=u=b:u=u.next=b,a=a.next}while(a!==null);u===null?c=u=t:u=u.next=t}else c=u=t;a={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:i.shared,callbacks:i.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Cc=!1;function Tl(){if(Cc){var e=Ts;if(e!==null)throw e}}function Dl(e,t,a,i){Cc=!1;var c=e.updateQueue;xa=!1;var u=c.firstBaseUpdate,b=c.lastBaseUpdate,j=c.shared.pending;if(j!==null){c.shared.pending=null;var _=j,Y=_.next;_.next=null,b===null?u=Y:b.next=Y,b=_;var P=e.alternate;P!==null&&(P=P.updateQueue,j=P.lastBaseUpdate,j!==b&&(j===null?P.firstBaseUpdate=Y:j.next=Y,P.lastBaseUpdate=_))}if(u!==null){var te=c.baseState;b=0,P=Y=_=null,j=u;do{var X=j.lane&-536870913,I=X!==j.lane;if(I?(qe&X)===X:(i&X)===X){X!==0&&X===qs&&(Cc=!0),P!==null&&(P=P.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var de=e,je=j;X=t;var Ze=a;switch(je.tag){case 1:if(de=je.payload,typeof de=="function"){te=de.call(Ze,te,X);break e}te=de;break e;case 3:de.flags=de.flags&-65537|128;case 0:if(de=je.payload,X=typeof de=="function"?de.call(Ze,te,X):de,X==null)break e;te=y({},te,X);break e;case 2:xa=!0}}X=j.callback,X!==null&&(e.flags|=64,I&&(e.flags|=8192),I=c.callbacks,I===null?c.callbacks=[X]:I.push(X))}else I={lane:X,tag:j.tag,payload:j.payload,callback:j.callback,next:null},P===null?(Y=P=I,_=te):P=P.next=I,b|=X;if(j=j.next,j===null){if(j=c.shared.pending,j===null)break;I=j,j=I.next,I.next=null,c.lastBaseUpdate=I,c.shared.pending=null}}while(!0);P===null&&(_=te),c.baseState=_,c.firstBaseUpdate=Y,c.lastBaseUpdate=P,u===null&&(c.shared.lanes=0),Aa|=b,e.lanes=b,e.memoizedState=te}}function Rm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function qm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)Rm(a[e],t)}var Bs=R(null),ar=R(0);function Tm(e,t){e=Wn,ne(ar,e),ne(Bs,t),Wn=e|t.baseLanes}function Ec(){ne(ar,Wn),ne(Bs,Bs.current)}function kc(){Wn=ar.current,V(Bs),V(ar)}var Kt=R(null),hn=null;function ba(e){var t=e.alternate;ne(pt,pt.current&1),ne(Kt,e),hn===null&&(t===null||Bs.current!==null||t.memoizedState!==null)&&(hn=e)}function Mc(e){ne(pt,pt.current),ne(Kt,e),hn===null&&(hn=e)}function Dm(e){e.tag===22?(ne(pt,pt.current),ne(Kt,e),hn===null&&(hn=e)):ya()}function ya(){ne(pt,pt.current),ne(Kt,Kt.current)}function Zt(e){V(Kt),hn===e&&(hn=null),V(pt)}var pt=R(0);function sr(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Bu(a)||Ou(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 Fn=0,we=null,Qe=null,yt=null,lr=!1,Os=!1,Ja=!1,ir=0,_l=0,Ls=null,ab=0;function ut(){throw Error(o(321))}function Rc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Xt(e[a],t[a]))return!1;return!0}function qc(e,t,a,i,c,u){return Fn=u,we=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,q.H=e===null||e.memoizedState===null?xh:Xc,Ja=!1,u=a(i,c),Ja=!1,Os&&(u=Bm(t,a,i,c)),_m(e),u}function _m(e){q.H=Ll;var t=Qe!==null&&Qe.next!==null;if(Fn=0,yt=Qe=we=null,lr=!1,_l=0,Ls=null,t)throw Error(o(300));e===null||St||(e=e.dependencies,e!==null&&Ii(e)&&(St=!0))}function Bm(e,t,a,i){we=e;var c=0;do{if(Os&&(Ls=null),_l=0,Os=!1,25<=c)throw Error(o(301));if(c+=1,yt=Qe=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}q.H=gh,u=t(a,i)}while(Os);return u}function sb(){var e=q.H,t=e.useState()[0];return t=typeof t.then=="function"?Bl(t):t,e=e.useState()[0],(Qe!==null?Qe.memoizedState:null)!==e&&(we.flags|=1024),t}function Tc(){var e=ir!==0;return ir=0,e}function Dc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function _c(e){if(lr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}lr=!1}Fn=0,yt=Qe=we=null,Os=!1,_l=ir=0,Ls=null}function Ot(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yt===null?we.memoizedState=yt=e:yt=yt.next=e,yt}function xt(){if(Qe===null){var e=we.alternate;e=e!==null?e.memoizedState:null}else e=Qe.next;var t=yt===null?we.memoizedState:yt.next;if(t!==null)yt=t,Qe=e;else{if(e===null)throw we.alternate===null?Error(o(467)):Error(o(310));Qe=e,e={memoizedState:Qe.memoizedState,baseState:Qe.baseState,baseQueue:Qe.baseQueue,queue:Qe.queue,next:null},yt===null?we.memoizedState=yt=e:yt=yt.next=e}return yt}function rr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bl(e){var t=_l;return _l+=1,Ls===null&&(Ls=[]),e=wm(Ls,e,t),t=we,(yt===null?t.memoizedState:yt.next)===null&&(t=t.alternate,q.H=t===null||t.memoizedState===null?xh:Xc),e}function or(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Bl(e);if(e.$$typeof===T)return qt(e)}throw Error(o(438,String(e)))}function Bc(e){var t=null,a=we.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var i=we.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=rr(),we.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),i=0;i<e;i++)a[i]=$;return t.index++,a}function Xn(e,t){return typeof t=="function"?t(e):t}function cr(e){var t=xt();return Oc(t,Qe,e)}function Oc(e,t,a){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=a;var c=e.baseQueue,u=i.pending;if(u!==null){if(c!==null){var b=c.next;c.next=u.next,u.next=b}t.baseQueue=c=u,i.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var j=b=null,_=null,Y=t,P=!1;do{var te=Y.lane&-536870913;if(te!==Y.lane?(qe&te)===te:(Fn&te)===te){var X=Y.revertLane;if(X===0)_!==null&&(_=_.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),te===qs&&(P=!0);else if((Fn&X)===X){Y=Y.next,X===qs&&(P=!0);continue}else te={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},_===null?(j=_=te,b=u):_=_.next=te,we.lanes|=X,Aa|=X;te=Y.action,Ja&&a(u,te),u=Y.hasEagerState?Y.eagerState:a(u,te)}else X={lane:te,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},_===null?(j=_=X,b=u):_=_.next=X,we.lanes|=te,Aa|=te;Y=Y.next}while(Y!==null&&Y!==t);if(_===null?b=u:_.next=j,!Xt(u,e.memoizedState)&&(St=!0,P&&(a=Ts,a!==null)))throw a;e.memoizedState=u,e.baseState=b,e.baseQueue=_,i.lastRenderedState=u}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Lc(e){var t=xt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var i=a.dispatch,c=a.pending,u=t.memoizedState;if(c!==null){a.pending=null;var b=c=c.next;do u=e(u,b.action),b=b.next;while(b!==c);Xt(u,t.memoizedState)||(St=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,i]}function Om(e,t,a){var i=we,c=xt(),u=_e;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var b=!Xt((Qe||c).memoizedState,a);if(b&&(c.memoizedState=a,St=!0),c=c.queue,Hc(Um.bind(null,i,c,e),[e]),c.getSnapshot!==t||b||yt!==null&&yt.memoizedState.tag&1){if(i.flags|=2048,zs(9,{destroy:void 0},zm.bind(null,i,c,a,t),null),Pe===null)throw Error(o(349));u||(Fn&127)!==0||Lm(i,t,a)}return a}function Lm(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=we.updateQueue,t===null?(t=rr(),we.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function zm(e,t,a,i){t.value=a,t.getSnapshot=i,Hm(t)&&Vm(e)}function Um(e,t,a){return a(function(){Hm(t)&&Vm(e)})}function Hm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Xt(e,a)}catch{return!0}}function Vm(e){var t=$a(e,2);t!==null&&Yt(t,e,2)}function zc(e){var t=Ot();if(typeof e=="function"){var a=e;if(e=a(),Ja){an(!0);try{a()}finally{an(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xn,lastRenderedState:e},t}function $m(e,t,a,i){return e.baseState=a,Oc(e,Qe,typeof i=="function"?i:Xn)}function lb(e,t,a,i,c){if(dr(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(b){u.listeners.push(b)}};q.T!==null?a(!0):u.isTransition=!1,i(u),a=t.pending,a===null?(u.next=t.pending=u,Gm(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Gm(e,t){var a=t.action,i=t.payload,c=e.state;if(t.isTransition){var u=q.T,b={};q.T=b;try{var j=a(c,i),_=q.S;_!==null&&_(b,j),Ym(e,t,j)}catch(Y){Uc(e,t,Y)}finally{u!==null&&b.types!==null&&(u.types=b.types),q.T=u}}else try{u=a(c,i),Ym(e,t,u)}catch(Y){Uc(e,t,Y)}}function Ym(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(i){Fm(e,t,i)},function(i){return Uc(e,t,i)}):Fm(e,t,a)}function Fm(e,t,a){t.status="fulfilled",t.value=a,Xm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Gm(e,a)))}function Uc(e,t,a){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=a,Xm(t),t=t.next;while(t!==i)}e.action=null}function Xm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Qm(e,t){return t}function Km(e,t){if(_e){var a=Pe.formState;if(a!==null){e:{var i=we;if(_e){if(et){t:{for(var c=et,u=mn;c.nodeType!==8;){if(!u){c=null;break t}if(c=pn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){et=pn(c.nextSibling),i=c.data==="F!";break e}}ha(i)}i=!1}i&&(t=a[0])}}return a=Ot(),a.memoizedState=a.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qm,lastRenderedState:t},a.queue=i,a=mh.bind(null,we,i),i.dispatch=a,i=zc(!1),u=Fc.bind(null,we,!1,i.queue),i=Ot(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,a=lb.bind(null,we,c,u,a),c.dispatch=a,i.memoizedState=e,[t,a,!1]}function Zm(e){var t=xt();return Im(t,Qe,e)}function Im(e,t,a){if(t=Oc(e,t,Qm)[0],e=cr(Xn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=Bl(t)}catch(b){throw b===Ds?Wi:b}else i=t;t=xt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(we.flags|=2048,zs(9,{destroy:void 0},ib.bind(null,c,a),null)),[i,u,e]}function ib(e,t){e.action=t}function Jm(e){var t=xt(),a=Qe;if(a!==null)return Im(t,a,e);xt(),t=t.memoizedState,a=xt();var i=a.queue.dispatch;return a.memoizedState=e,[t,i,!1]}function zs(e,t,a,i){return e={tag:e,create:a,deps:i,inst:t,next:null},t=we.updateQueue,t===null&&(t=rr(),we.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(i=a.next,a.next=e,e.next=i,t.lastEffect=e),e}function Pm(){return xt().memoizedState}function ur(e,t,a,i){var c=Ot();we.flags|=e,c.memoizedState=zs(1|t,{destroy:void 0},a,i===void 0?null:i)}function fr(e,t,a,i){var c=xt();i=i===void 0?null:i;var u=c.memoizedState.inst;Qe!==null&&i!==null&&Rc(i,Qe.memoizedState.deps)?c.memoizedState=zs(t,u,a,i):(we.flags|=e,c.memoizedState=zs(1|t,u,a,i))}function Wm(e,t){ur(8390656,8,e,t)}function Hc(e,t){fr(2048,8,e,t)}function rb(e){we.flags|=4;var t=we.updateQueue;if(t===null)t=rr(),we.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function eh(e){var t=xt().memoizedState;return rb({ref:t,nextImpl:e}),function(){if(($e&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function th(e,t){return fr(4,2,e,t)}function nh(e,t){return fr(4,4,e,t)}function ah(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 sh(e,t,a){a=a!=null?a.concat([e]):null,fr(4,4,ah.bind(null,t,e),a)}function Vc(){}function lh(e,t){var a=xt();t=t===void 0?null:t;var i=a.memoizedState;return t!==null&&Rc(t,i[1])?i[0]:(a.memoizedState=[e,t],e)}function ih(e,t){var a=xt();t=t===void 0?null:t;var i=a.memoizedState;if(t!==null&&Rc(t,i[1]))return i[0];if(i=e(),Ja){an(!0);try{e()}finally{an(!1)}}return a.memoizedState=[i,t],i}function $c(e,t,a){return a===void 0||(Fn&1073741824)!==0&&(qe&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=rp(),we.lanes|=e,Aa|=e,a)}function rh(e,t,a,i){return Xt(a,t)?a:Bs.current!==null?(e=$c(e,a,i),Xt(e,t)||(St=!0),e):(Fn&42)===0||(Fn&1073741824)!==0&&(qe&261930)===0?(St=!0,e.memoizedState=a):(e=rp(),we.lanes|=e,Aa|=e,t)}function oh(e,t,a,i,c){var u=L.p;L.p=u!==0&&8>u?u:8;var b=q.T,j={};q.T=j,Fc(e,!1,t,a);try{var _=c(),Y=q.S;if(Y!==null&&Y(j,_),_!==null&&typeof _=="object"&&typeof _.then=="function"){var P=nb(_,i);Ol(e,t,P,Pt(e))}else Ol(e,t,i,Pt(e))}catch(te){Ol(e,t,{then:function(){},status:"rejected",reason:te},Pt())}finally{L.p=u,b!==null&&j.types!==null&&(b.types=j.types),q.T=b}}function ob(){}function Gc(e,t,a,i){if(e.tag!==5)throw Error(o(476));var c=ch(e).queue;oh(e,c,t,Z,a===null?ob:function(){return uh(e),a(i)})}function ch(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xn,lastRenderedState:Z},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function uh(e){var t=ch(e);t.next===null&&(t=e.alternate.memoizedState),Ol(e,t.next.queue,{},Pt())}function Yc(){return qt(Wl)}function fh(){return xt().memoizedState}function dh(){return xt().memoizedState}function cb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Pt();e=ga(a);var i=va(t,e,a);i!==null&&(Yt(i,t,a),ql(i,t,a)),t={cache:bc()},e.payload=t;return}t=t.return}}function ub(e,t,a){var i=Pt();a={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},dr(e)?hh(t,a):(a=oc(e,t,a,i),a!==null&&(Yt(a,e,i),ph(a,t,i)))}function mh(e,t,a){var i=Pt();Ol(e,t,a,i)}function Ol(e,t,a,i){var c={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(dr(e))hh(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var b=t.lastRenderedState,j=u(b,a);if(c.hasEagerState=!0,c.eagerState=j,Xt(j,b))return Xi(e,t,c,0),Pe===null&&Fi(),!1}catch{}finally{}if(a=oc(e,t,c,i),a!==null)return Yt(a,e,i),ph(a,t,i),!0}return!1}function Fc(e,t,a,i){if(i={lane:2,revertLane:Au(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},dr(e)){if(t)throw Error(o(479))}else t=oc(e,a,i,2),t!==null&&Yt(t,e,2)}function dr(e){var t=e.alternate;return e===we||t!==null&&t===we}function hh(e,t){Os=lr=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function ph(e,t,a){if((a&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,ye(e,a)}}var Ll={readContext:qt,use:or,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useLayoutEffect:ut,useInsertionEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useSyncExternalStore:ut,useId:ut,useHostTransitionStatus:ut,useFormState:ut,useActionState:ut,useOptimistic:ut,useMemoCache:ut,useCacheRefresh:ut};Ll.useEffectEvent=ut;var xh={readContext:qt,use:or,useCallback:function(e,t){return Ot().memoizedState=[e,t===void 0?null:t],e},useContext:qt,useEffect:Wm,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,ur(4194308,4,ah.bind(null,t,e),a)},useLayoutEffect:function(e,t){return ur(4194308,4,e,t)},useInsertionEffect:function(e,t){ur(4,2,e,t)},useMemo:function(e,t){var a=Ot();t=t===void 0?null:t;var i=e();if(Ja){an(!0);try{e()}finally{an(!1)}}return a.memoizedState=[i,t],i},useReducer:function(e,t,a){var i=Ot();if(a!==void 0){var c=a(t);if(Ja){an(!0);try{a(t)}finally{an(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=ub.bind(null,we,e),[i.memoizedState,e]},useRef:function(e){var t=Ot();return e={current:e},t.memoizedState=e},useState:function(e){e=zc(e);var t=e.queue,a=mh.bind(null,we,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Vc,useDeferredValue:function(e,t){var a=Ot();return $c(a,e,t)},useTransition:function(){var e=zc(!1);return e=oh.bind(null,we,e.queue,!0,!1),Ot().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var i=we,c=Ot();if(_e){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),Pe===null)throw Error(o(349));(qe&127)!==0||Lm(i,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,Wm(Um.bind(null,i,u,e),[e]),i.flags|=2048,zs(9,{destroy:void 0},zm.bind(null,i,u,a,t),null),a},useId:function(){var e=Ot(),t=Pe.identifierPrefix;if(_e){var a=qn,i=Rn;a=(i&~(1<<32-vt(i)-1)).toString(32)+a,t="_"+t+"R_"+a,a=ir++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=ab++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Yc,useFormState:Km,useActionState:Km,useOptimistic:function(e){var t=Ot();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Fc.bind(null,we,!0,a),a.dispatch=t,[e,t]},useMemoCache:Bc,useCacheRefresh:function(){return Ot().memoizedState=cb.bind(null,we)},useEffectEvent:function(e){var t=Ot(),a={impl:e};return t.memoizedState=a,function(){if(($e&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Xc={readContext:qt,use:or,useCallback:lh,useContext:qt,useEffect:Hc,useImperativeHandle:sh,useInsertionEffect:th,useLayoutEffect:nh,useMemo:ih,useReducer:cr,useRef:Pm,useState:function(){return cr(Xn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=xt();return rh(a,Qe.memoizedState,e,t)},useTransition:function(){var e=cr(Xn)[0],t=xt().memoizedState;return[typeof e=="boolean"?e:Bl(e),t]},useSyncExternalStore:Om,useId:fh,useHostTransitionStatus:Yc,useFormState:Zm,useActionState:Zm,useOptimistic:function(e,t){var a=xt();return $m(a,Qe,e,t)},useMemoCache:Bc,useCacheRefresh:dh};Xc.useEffectEvent=eh;var gh={readContext:qt,use:or,useCallback:lh,useContext:qt,useEffect:Hc,useImperativeHandle:sh,useInsertionEffect:th,useLayoutEffect:nh,useMemo:ih,useReducer:Lc,useRef:Pm,useState:function(){return Lc(Xn)},useDebugValue:Vc,useDeferredValue:function(e,t){var a=xt();return Qe===null?$c(a,e,t):rh(a,Qe.memoizedState,e,t)},useTransition:function(){var e=Lc(Xn)[0],t=xt().memoizedState;return[typeof e=="boolean"?e:Bl(e),t]},useSyncExternalStore:Om,useId:fh,useHostTransitionStatus:Yc,useFormState:Jm,useActionState:Jm,useOptimistic:function(e,t){var a=xt();return Qe!==null?$m(a,Qe,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Bc,useCacheRefresh:dh};gh.useEffectEvent=eh;function Qc(e,t,a,i){t=e.memoizedState,a=a(i,t),a=a==null?t:y({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Kc={enqueueSetState:function(e,t,a){e=e._reactInternals;var i=Pt(),c=ga(i);c.payload=t,a!=null&&(c.callback=a),t=va(e,c,i),t!==null&&(Yt(t,e,i),ql(t,e,i))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var i=Pt(),c=ga(i);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=va(e,c,i),t!==null&&(Yt(t,e,i),ql(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Pt(),i=ga(a);i.tag=2,t!=null&&(i.callback=t),t=va(e,i,a),t!==null&&(Yt(t,e,a),ql(t,e,a))}};function vh(e,t,a,i,c,u,b){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,u,b):t.prototype&&t.prototype.isPureReactComponent?!Al(a,i)||!Al(c,u):!0}function bh(e,t,a,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,i),t.state!==e&&Kc.enqueueReplaceState(t,t.state,null)}function Pa(e,t){var a=t;if("ref"in t){a={};for(var i in t)i!=="ref"&&(a[i]=t[i])}if(e=e.defaultProps){a===t&&(a=y({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function yh(e){Yi(e)}function Sh(e){console.error(e)}function jh(e){Yi(e)}function mr(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function Ah(e,t,a){try{var i=e.onCaughtError;i(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Zc(e,t,a){return a=ga(a),a.tag=3,a.payload={element:null},a.callback=function(){mr(e,t)},a}function Nh(e){return e=ga(e),e.tag=3,e}function wh(e,t,a,i){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=i.value;e.payload=function(){return c(u)},e.callback=function(){Ah(t,a,i)}}var b=a.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(e.callback=function(){Ah(t,a,i),typeof c!="function"&&(Na===null?Na=new Set([this]):Na.add(this));var j=i.stack;this.componentDidCatch(i.value,{componentStack:j!==null?j:""})})}function fb(e,t,a,i,c){if(a.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=a.alternate,t!==null&&Rs(t,a,c,!0),a=Kt.current,a!==null){switch(a.tag){case 31:case 13:return hn===null?wr():a.alternate===null&&ft===0&&(ft=3),a.flags&=-257,a.flags|=65536,a.lanes=c,i===er?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([i]):t.add(i),yu(e,i,c)),!1;case 22:return a.flags|=65536,i===er?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([i]):a.add(i)),yu(e,i,c)),!1}throw Error(o(435,a.tag))}return yu(e,i,c),wr(),!1}if(_e)return t=Kt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==hc&&(e=Error(o(422),{cause:i}),Cl(un(e,a)))):(i!==hc&&(t=Error(o(423),{cause:i}),Cl(un(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=un(i,a),c=Zc(e.stateNode,i,c),wc(e,c),ft!==4&&(ft=2)),!1;var u=Error(o(520),{cause:i});if(u=un(u,a),Fl===null?Fl=[u]:Fl.push(u),ft!==4&&(ft=2),t===null)return!0;i=un(i,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Zc(a.stateNode,i,e),wc(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"&&(Na===null||!Na.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=Nh(c),wh(c,e,a,i),wc(a,c),!1}a=a.return}while(a!==null);return!1}var Ic=Error(o(461)),St=!1;function Tt(e,t,a,i){t.child=e===null?Mm(t,null,a,i):Ia(t,e.child,a,i)}function Ch(e,t,a,i,c){a=a.render;var u=t.ref;if("ref"in i){var b={};for(var j in i)j!=="ref"&&(b[j]=i[j])}else b=i;return Xa(t),i=qc(e,t,a,b,u,c),j=Tc(),e!==null&&!St?(Dc(e,t,c),Qn(e,t,c)):(_e&&j&&dc(t),t.flags|=1,Tt(e,t,i,c),t.child)}function Eh(e,t,a,i,c){if(e===null){var u=a.type;return typeof u=="function"&&!cc(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,kh(e,t,u,i,c)):(e=Ki(a.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!su(e,c)){var b=u.memoizedProps;if(a=a.compare,a=a!==null?a:Al,a(b,i)&&e.ref===t.ref)return Qn(e,t,c)}return t.flags|=1,e=Vn(u,i),e.ref=t.ref,e.return=t,t.child=e}function kh(e,t,a,i,c){if(e!==null){var u=e.memoizedProps;if(Al(u,i)&&e.ref===t.ref)if(St=!1,t.pendingProps=i=u,su(e,c))(e.flags&131072)!==0&&(St=!0);else return t.lanes=e.lanes,Qn(e,t,c)}return Jc(e,t,a,i,c)}function Mh(e,t,a,i){var c=i.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|a:a,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~u}else i=0,t.child=null;return Rh(e,t,u,a,i)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Pi(t,u!==null?u.cachePool:null),u!==null?Tm(t,u):Ec(),Dm(t);else return i=t.lanes=536870912,Rh(e,t,u!==null?u.baseLanes|a:a,a,i)}else u!==null?(Pi(t,u.cachePool),Tm(t,u),ya(),t.memoizedState=null):(e!==null&&Pi(t,null),Ec(),ya());return Tt(e,t,c,a),t.child}function zl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Rh(e,t,a,i,c){var u=Sc();return u=u===null?null:{parent:bt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Pi(t,null),Ec(),Dm(t),e!==null&&Rs(e,t,i,!0),t.childLanes=c,null}function hr(e,t){return t=xr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function qh(e,t,a){return Ia(t,e.child,null,a),e=hr(t,t.pendingProps),e.flags|=2,Zt(t),t.memoizedState=null,e}function db(e,t,a){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(_e){if(i.mode==="hidden")return e=hr(t,i),t.lanes=536870912,zl(null,e);if(Mc(t),(e=et)?(e=Gp(e,mn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:da!==null?{id:Rn,overflow:qn}:null,retryLane:536870912,hydrationErrors:null},a=hm(e),a.return=t,t.child=a,Rt=t,et=null)):e=null,e===null)throw ha(t);return t.lanes=536870912,null}return hr(t,i)}var u=e.memoizedState;if(u!==null){var b=u.dehydrated;if(Mc(t),c)if(t.flags&256)t.flags&=-257,t=qh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(St||Rs(e,t,a,!1),c=(a&e.childLanes)!==0,St||c){if(i=Pe,i!==null&&(b=Ie(i,a),b!==0&&b!==u.retryLane))throw u.retryLane=b,$a(e,b),Yt(i,e,b),Ic;wr(),t=qh(e,t,a)}else e=u.treeContext,et=pn(b.nextSibling),Rt=t,_e=!0,ma=null,mn=!1,e!==null&&gm(t,e),t=hr(t,i),t.flags|=4096;return t}return e=Vn(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pr(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Jc(e,t,a,i,c){return Xa(t),a=qc(e,t,a,i,void 0,c),i=Tc(),e!==null&&!St?(Dc(e,t,c),Qn(e,t,c)):(_e&&i&&dc(t),t.flags|=1,Tt(e,t,a,c),t.child)}function Th(e,t,a,i,c,u){return Xa(t),t.updateQueue=null,a=Bm(t,i,a,c),_m(e),i=Tc(),e!==null&&!St?(Dc(e,t,u),Qn(e,t,u)):(_e&&i&&dc(t),t.flags|=1,Tt(e,t,a,u),t.child)}function Dh(e,t,a,i,c){if(Xa(t),t.stateNode===null){var u=Cs,b=a.contextType;typeof b=="object"&&b!==null&&(u=qt(b)),u=new a(i,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Kc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=i,u.state=t.memoizedState,u.refs={},Ac(t),b=a.contextType,u.context=typeof b=="object"&&b!==null?qt(b):Cs,u.state=t.memoizedState,b=a.getDerivedStateFromProps,typeof b=="function"&&(Qc(t,a,b,i),u.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(b=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),b!==u.state&&Kc.enqueueReplaceState(u,u.state,null),Dl(t,i,u,c),Tl(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){u=t.stateNode;var j=t.memoizedProps,_=Pa(a,j);u.props=_;var Y=u.context,P=a.contextType;b=Cs,typeof P=="object"&&P!==null&&(b=qt(P));var te=a.getDerivedStateFromProps;P=typeof te=="function"||typeof u.getSnapshotBeforeUpdate=="function",j=t.pendingProps!==j,P||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(j||Y!==b)&&bh(t,u,i,b),xa=!1;var X=t.memoizedState;u.state=X,Dl(t,i,u,c),Tl(),Y=t.memoizedState,j||X!==Y||xa?(typeof te=="function"&&(Qc(t,a,te,i),Y=t.memoizedState),(_=xa||vh(t,a,_,i,X,Y,b))?(P||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=i,t.memoizedState=Y),u.props=i,u.state=Y,u.context=b,i=_):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{u=t.stateNode,Nc(e,t),b=t.memoizedProps,P=Pa(a,b),u.props=P,te=t.pendingProps,X=u.context,Y=a.contextType,_=Cs,typeof Y=="object"&&Y!==null&&(_=qt(Y)),j=a.getDerivedStateFromProps,(Y=typeof j=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(b!==te||X!==_)&&bh(t,u,i,_),xa=!1,X=t.memoizedState,u.state=X,Dl(t,i,u,c),Tl();var I=t.memoizedState;b!==te||X!==I||xa||e!==null&&e.dependencies!==null&&Ii(e.dependencies)?(typeof j=="function"&&(Qc(t,a,j,i),I=t.memoizedState),(P=xa||vh(t,a,P,i,X,I,_)||e!==null&&e.dependencies!==null&&Ii(e.dependencies))?(Y||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(i,I,_),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(i,I,_)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=I),u.props=i,u.state=I,u.context=_,i=P):(typeof u.componentDidUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),i=!1)}return u=i,pr(e,t),i=(t.flags&128)!==0,u||i?(u=t.stateNode,a=i&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&i?(t.child=Ia(t,e.child,null,c),t.child=Ia(t,null,a,c)):Tt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Qn(e,t,c),e}function _h(e,t,a,i){return Ya(),t.flags|=256,Tt(e,t,a,i),t.child}var Pc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wc(e){return{baseLanes:e,cachePool:Am()}}function eu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Jt),e}function Bh(e,t,a){var i=t.pendingProps,c=!1,u=(t.flags&128)!==0,b;if((b=u)||(b=e!==null&&e.memoizedState===null?!1:(pt.current&2)!==0),b&&(c=!0,t.flags&=-129),b=(t.flags&32)!==0,t.flags&=-33,e===null){if(_e){if(c?ba(t):ya(),(e=et)?(e=Gp(e,mn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:da!==null?{id:Rn,overflow:qn}:null,retryLane:536870912,hydrationErrors:null},a=hm(e),a.return=t,t.child=a,Rt=t,et=null)):e=null,e===null)throw ha(t);return Ou(e)?t.lanes=32:t.lanes=536870912,null}var j=i.children;return i=i.fallback,c?(ya(),c=t.mode,j=xr({mode:"hidden",children:j},c),i=Ga(i,c,a,null),j.return=t,i.return=t,j.sibling=i,t.child=j,i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,b,a),t.memoizedState=Pc,zl(null,i)):(ba(t),tu(t,j))}var _=e.memoizedState;if(_!==null&&(j=_.dehydrated,j!==null)){if(u)t.flags&256?(ba(t),t.flags&=-257,t=nu(e,t,a)):t.memoizedState!==null?(ya(),t.child=e.child,t.flags|=128,t=null):(ya(),j=i.fallback,c=t.mode,i=xr({mode:"visible",children:i.children},c),j=Ga(j,c,a,null),j.flags|=2,i.return=t,j.return=t,i.sibling=j,t.child=i,Ia(t,e.child,null,a),i=t.child,i.memoizedState=Wc(a),i.childLanes=eu(e,b,a),t.memoizedState=Pc,t=zl(null,i));else if(ba(t),Ou(j)){if(b=j.nextSibling&&j.nextSibling.dataset,b)var Y=b.dgst;b=Y,i=Error(o(419)),i.stack="",i.digest=b,Cl({value:i,source:null,stack:null}),t=nu(e,t,a)}else if(St||Rs(e,t,a,!1),b=(a&e.childLanes)!==0,St||b){if(b=Pe,b!==null&&(i=Ie(b,a),i!==0&&i!==_.retryLane))throw _.retryLane=i,$a(e,i),Yt(b,e,i),Ic;Bu(j)||wr(),t=nu(e,t,a)}else Bu(j)?(t.flags|=192,t.child=e.child,t=null):(e=_.treeContext,et=pn(j.nextSibling),Rt=t,_e=!0,ma=null,mn=!1,e!==null&&gm(t,e),t=tu(t,i.children),t.flags|=4096);return t}return c?(ya(),j=i.fallback,c=t.mode,_=e.child,Y=_.sibling,i=Vn(_,{mode:"hidden",children:i.children}),i.subtreeFlags=_.subtreeFlags&65011712,Y!==null?j=Vn(Y,j):(j=Ga(j,c,a,null),j.flags|=2),j.return=t,i.return=t,i.sibling=j,t.child=i,zl(null,i),i=t.child,j=e.child.memoizedState,j===null?j=Wc(a):(c=j.cachePool,c!==null?(_=bt._currentValue,c=c.parent!==_?{parent:_,pool:_}:c):c=Am(),j={baseLanes:j.baseLanes|a,cachePool:c}),i.memoizedState=j,i.childLanes=eu(e,b,a),t.memoizedState=Pc,zl(e.child,i)):(ba(t),a=e.child,e=a.sibling,a=Vn(a,{mode:"visible",children:i.children}),a.return=t,a.sibling=null,e!==null&&(b=t.deletions,b===null?(t.deletions=[e],t.flags|=16):b.push(e)),t.child=a,t.memoizedState=null,a)}function tu(e,t){return t=xr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function xr(e,t){return e=Qt(22,e,null,t),e.lanes=0,e}function nu(e,t,a){return Ia(t,e.child,null,a),e=tu(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Oh(e,t,a){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),gc(e.return,t,a)}function au(e,t,a,i,c,u){var b=e.memoizedState;b===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:a,tailMode:c,treeForkCount:u}:(b.isBackwards=t,b.rendering=null,b.renderingStartTime=0,b.last=i,b.tail=a,b.tailMode=c,b.treeForkCount=u)}function Lh(e,t,a){var i=t.pendingProps,c=i.revealOrder,u=i.tail;i=i.children;var b=pt.current,j=(b&2)!==0;if(j?(b=b&1|2,t.flags|=128):b&=1,ne(pt,b),Tt(e,t,i,a),i=_e?wl:0,!j&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Oh(e,a,t);else if(e.tag===19)Oh(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&&sr(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),au(t,!1,c,a,u,i);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&sr(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}au(t,!0,a,null,u,i);break;case"together":au(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Qn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Aa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Rs(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=Vn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Vn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function su(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Ii(e)))}function mb(e,t,a){switch(t.tag){case 3:be(t,t.stateNode.containerInfo),pa(t,bt,e.memoizedState.cache),Ya();break;case 27:case 5:xe(t);break;case 4:be(t,t.stateNode.containerInfo);break;case 10:pa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Mc(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(ba(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Bh(e,t,a):(ba(t),e=Qn(e,t,a),e!==null?e.sibling:null);ba(t);break;case 19:var c=(e.flags&128)!==0;if(i=(a&t.childLanes)!==0,i||(Rs(e,t,a,!1),i=(a&t.childLanes)!==0),c){if(i)return Lh(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),ne(pt,pt.current),i)break;return null;case 22:return t.lanes=0,Mh(e,t,a,t.pendingProps);case 24:pa(t,bt,e.memoizedState.cache)}return Qn(e,t,a)}function zh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)St=!0;else{if(!su(e,a)&&(t.flags&128)===0)return St=!1,mb(e,t,a);St=(e.flags&131072)!==0}else St=!1,_e&&(t.flags&1048576)!==0&&xm(t,wl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Ka(t.elementType),t.type=e,typeof e=="function")cc(e)?(i=Pa(e,i),t.tag=1,t=Dh(null,t,e,i,a)):(t.tag=0,t=Jc(null,t,e,i,a));else{if(e!=null){var c=e.$$typeof;if(c===M){t.tag=11,t=Ch(null,t,e,i,a);break e}else if(c===D){t.tag=14,t=Eh(null,t,e,i,a);break e}}throw t=ce(e)||e,Error(o(306,t,""))}}return t;case 0:return Jc(e,t,t.type,t.pendingProps,a);case 1:return i=t.type,c=Pa(i,t.pendingProps),Dh(e,t,i,c,a);case 3:e:{if(be(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var u=t.memoizedState;c=u.element,Nc(e,t),Dl(t,i,null,a);var b=t.memoizedState;if(i=b.cache,pa(t,bt,i),i!==u.cache&&vc(t,[bt],a,!0),Tl(),i=b.element,u.isDehydrated)if(u={element:i,isDehydrated:!1,cache:b.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=_h(e,t,i,a);break e}else if(i!==c){c=un(Error(o(424)),t),Cl(c),t=_h(e,t,i,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(et=pn(e.firstChild),Rt=t,_e=!0,ma=null,mn=!0,a=Mm(t,null,i,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Ya(),i===c){t=Qn(e,t,a);break e}Tt(e,t,i,a)}t=t.child}return t;case 26:return pr(e,t),e===null?(a=Zp(t.type,null,t.pendingProps,null))?t.memoizedState=a:_e||(a=t.type,e=t.pendingProps,i=Tr(oe.current).createElement(a),i[ct]=t,i[ze]=e,Dt(i,a,e),Ct(i),t.stateNode=i):t.memoizedState=Zp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&_e&&(i=t.stateNode=Xp(t.type,t.pendingProps,oe.current),Rt=t,mn=!0,c=et,ka(t.type)?(Lu=c,et=pn(i.firstChild)):et=c),Tt(e,t,t.pendingProps.children,a),pr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&_e&&((c=i=et)&&(i=Gb(i,t.type,t.pendingProps,mn),i!==null?(t.stateNode=i,Rt=t,et=pn(i.firstChild),mn=!1,c=!0):c=!1),c||ha(t)),xe(t),c=t.type,u=t.pendingProps,b=e!==null?e.memoizedProps:null,i=u.children,Tu(c,u)?i=null:b!==null&&Tu(c,b)&&(t.flags|=32),t.memoizedState!==null&&(c=qc(e,t,sb,null,null,a),Wl._currentValue=c),pr(e,t),Tt(e,t,i,a),t.child;case 6:return e===null&&_e&&((e=a=et)&&(a=Yb(a,t.pendingProps,mn),a!==null?(t.stateNode=a,Rt=t,et=null,e=!0):e=!1),e||ha(t)),null;case 13:return Bh(e,t,a);case 4:return be(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ia(t,null,i,a):Tt(e,t,i,a),t.child;case 11:return Ch(e,t,t.type,t.pendingProps,a);case 7:return Tt(e,t,t.pendingProps,a),t.child;case 8:return Tt(e,t,t.pendingProps.children,a),t.child;case 12:return Tt(e,t,t.pendingProps.children,a),t.child;case 10:return i=t.pendingProps,pa(t,t.type,i.value),Tt(e,t,i.children,a),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Xa(t),c=qt(c),i=i(c),t.flags|=1,Tt(e,t,i,a),t.child;case 14:return Eh(e,t,t.type,t.pendingProps,a);case 15:return kh(e,t,t.type,t.pendingProps,a);case 19:return Lh(e,t,a);case 31:return db(e,t,a);case 22:return Mh(e,t,a,t.pendingProps);case 24:return Xa(t),i=qt(bt),e===null?(c=Sc(),c===null&&(c=Pe,u=bc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:i,cache:c},Ac(t),pa(t,bt,c)):((e.lanes&a)!==0&&(Nc(e,t),Dl(t,null,null,a),Tl()),c=e.memoizedState,u=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),pa(t,bt,i)):(i=u.cache,pa(t,bt,i),i!==c.cache&&vc(t,[bt],a,!0))),Tt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Kn(e){e.flags|=4}function lu(e,t,a,i,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(fp())e.flags|=8192;else throw Za=er,jc}else e.flags&=-16777217}function Uh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!e0(t))if(fp())e.flags|=8192;else throw Za=er,jc}function gr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Ti():536870912,e.lanes|=t,$s|=t)}function Ul(e,t){if(!_e)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function tt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,i=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=a,t}function hb(e,t,a){var i=t.pendingProps;switch(mc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return tt(t),null;case 1:return tt(t),null;case 3:return a=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Yn(bt),ve(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Ms(t)?Kn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,pc())),tt(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Kn(t),u!==null?(tt(t),Uh(t,u)):(tt(t),lu(t,c,null,i,a))):u?u!==e.memoizedState?(Kn(t),tt(t),Uh(t,u)):(tt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&Kn(t),tt(t),lu(t,c,e,i,a)),null;case 27:if(Le(t),a=oe.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Kn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return tt(t),null}e=se.current,Ms(t)?vm(t):(e=Xp(c,i,a),t.stateNode=e,Kn(t))}return tt(t),null;case 5:if(Le(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Kn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return tt(t),null}if(u=se.current,Ms(t))vm(t);else{var b=Tr(oe.current);switch(u){case 1:u=b.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=b.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=b.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=b.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=b.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof i.is=="string"?b.createElement("select",{is:i.is}):b.createElement("select"),i.multiple?u.multiple=!0:i.size&&(u.size=i.size);break;default:u=typeof i.is=="string"?b.createElement(c,{is:i.is}):b.createElement(c)}}u[ct]=t,u[ze]=i;e:for(b=t.child;b!==null;){if(b.tag===5||b.tag===6)u.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===t)break e;for(;b.sibling===null;){if(b.return===null||b.return===t)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}t.stateNode=u;e:switch(Dt(u,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Kn(t)}}return tt(t),lu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Kn(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=oe.current,Ms(t)){if(e=t.stateNode,a=t.memoizedProps,i=null,c=Rt,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[ct]=t,e=!!(e.nodeValue===a||i!==null&&i.suppressHydrationWarning===!0||Bp(e.nodeValue,a)),e||ha(t,!0)}else e=Tr(e).createTextNode(i),e[ct]=t,t.stateNode=e}return tt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(i=Ms(t),a!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[ct]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;tt(t),e=!1}else a=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Zt(t),t):(Zt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return tt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Ms(t),i!==null&&i.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[ct]=t}else Ya(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;tt(t),c=!1}else c=pc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Zt(t),t):(Zt(t),null)}return Zt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=i!==null,e=e!==null&&e.memoizedState!==null,a&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),u=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),u!==c&&(i.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),gr(t,t.updateQueue),tt(t),null);case 4:return ve(),e===null&&Eu(t.stateNode.containerInfo),tt(t),null;case 10:return Yn(t.type),tt(t),null;case 19:if(V(pt),i=t.memoizedState,i===null)return tt(t),null;if(c=(t.flags&128)!==0,u=i.rendering,u===null)if(c)Ul(i,!1);else{if(ft!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=sr(e),u!==null){for(t.flags|=128,Ul(i,!1),e=u.updateQueue,t.updateQueue=e,gr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)mm(a,e),a=a.sibling;return ne(pt,pt.current&1|2),_e&&$n(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Oe()>jr&&(t.flags|=128,c=!0,Ul(i,!1),t.lanes=4194304)}else{if(!c)if(e=sr(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,gr(t,e),Ul(i,!0),i.tail===null&&i.tailMode==="hidden"&&!u.alternate&&!_e)return tt(t),null}else 2*Oe()-i.renderingStartTime>jr&&a!==536870912&&(t.flags|=128,c=!0,Ul(i,!1),t.lanes=4194304);i.isBackwards?(u.sibling=t.child,t.child=u):(e=i.last,e!==null?e.sibling=u:t.child=u,i.last=u)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Oe(),e.sibling=null,a=pt.current,ne(pt,c?a&1|2:a&1),_e&&$n(t,i.treeForkCount),e):(tt(t),null);case 22:case 23:return Zt(t),kc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(a&536870912)!==0&&(t.flags&128)===0&&(tt(t),t.subtreeFlags&6&&(t.flags|=8192)):tt(t),a=t.updateQueue,a!==null&&gr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==a&&(t.flags|=2048),e!==null&&V(Qa),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Yn(bt),tt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function pb(e,t){switch(mc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Yn(bt),ve(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Le(t),null;case 31:if(t.memoizedState!==null){if(Zt(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(Zt(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 V(pt),null;case 4:return ve(),null;case 10:return Yn(t.type),null;case 22:case 23:return Zt(t),kc(),e!==null&&V(Qa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Yn(bt),null;case 25:return null;default:return null}}function Hh(e,t){switch(mc(t),t.tag){case 3:Yn(bt),ve();break;case 26:case 27:case 5:Le(t);break;case 4:ve();break;case 31:t.memoizedState!==null&&Zt(t);break;case 13:Zt(t);break;case 19:V(pt);break;case 10:Yn(t.type);break;case 22:case 23:Zt(t),kc(),e!==null&&V(Qa);break;case 24:Yn(bt)}}function Hl(e,t){try{var a=t.updateQueue,i=a!==null?a.lastEffect:null;if(i!==null){var c=i.next;a=c;do{if((a.tag&e)===e){i=void 0;var u=a.create,b=a.inst;i=u(),b.destroy=i}a=a.next}while(a!==c)}}catch(j){Xe(t,t.return,j)}}function Sa(e,t,a){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var u=c.next;i=u;do{if((i.tag&e)===e){var b=i.inst,j=b.destroy;if(j!==void 0){b.destroy=void 0,c=t;var _=a,Y=j;try{Y()}catch(P){Xe(c,_,P)}}}i=i.next}while(i!==u)}}catch(P){Xe(t,t.return,P)}}function Vh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{qm(t,a)}catch(i){Xe(e,e.return,i)}}}function $h(e,t,a){a.props=Pa(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(i){Xe(e,t,i)}}function Vl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof a=="function"?e.refCleanup=a(i):a.current=i}}catch(c){Xe(e,t,c)}}function Tn(e,t){var a=e.ref,i=e.refCleanup;if(a!==null)if(typeof i=="function")try{i()}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 Gh(e){var t=e.type,a=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&i.focus();break e;case"img":a.src?i.src=a.src:a.srcSet&&(i.srcset=a.srcSet)}}catch(c){Xe(e,e.return,c)}}function iu(e,t,a){try{var i=e.stateNode;Lb(i,e.type,a,t),i[ze]=t}catch(c){Xe(e,e.return,c)}}function Yh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ka(e.type)||e.tag===4}function ru(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Yh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ka(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ou(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=Un));else if(i!==4&&(i===27&&ka(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(ou(e,t,a),e=e.sibling;e!==null;)ou(e,t,a),e=e.sibling}function vr(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(i!==4&&(i===27&&ka(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(vr(e,t,a),e=e.sibling;e!==null;)vr(e,t,a),e=e.sibling}function Fh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Dt(t,i,a),t[ct]=e,t[ze]=a}catch(u){Xe(e,e.return,u)}}var Zn=!1,jt=!1,cu=!1,Xh=typeof WeakSet=="function"?WeakSet:Set,Et=null;function xb(e,t){if(e=e.containerInfo,Ru=Ur,e=sm(e),nc(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var i=a.getSelection&&a.getSelection();if(i&&i.rangeCount!==0){a=i.anchorNode;var c=i.anchorOffset,u=i.focusNode;i=i.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var b=0,j=-1,_=-1,Y=0,P=0,te=e,X=null;t:for(;;){for(var I;te!==a||c!==0&&te.nodeType!==3||(j=b+c),te!==u||i!==0&&te.nodeType!==3||(_=b+i),te.nodeType===3&&(b+=te.nodeValue.length),(I=te.firstChild)!==null;)X=te,te=I;for(;;){if(te===e)break t;if(X===a&&++Y===c&&(j=b),X===u&&++P===i&&(_=b),(I=te.nextSibling)!==null)break;te=X,X=te.parentNode}te=I}a=j===-1||_===-1?null:{start:j,end:_}}else a=null}a=a||{start:0,end:0}}else a=null;for(qu={focusedElem:e,selectionRange:a},Ur=!1,Et=t;Et!==null;)if(t=Et,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Et=e;else for(;Et!==null;){switch(t=Et,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,i=a.stateNode;try{var de=Pa(a.type,c);e=i.getSnapshotBeforeUpdate(de,u),i.__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)_u(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":_u(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,Et=e;break}Et=t.return}}function Qh(e,t,a){var i=a.flags;switch(a.tag){case 0:case 11:case 15:Jn(e,a),i&4&&Hl(5,a);break;case 1:if(Jn(e,a),i&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(b){Xe(a,a.return,b)}else{var c=Pa(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(b){Xe(a,a.return,b)}}i&64&&Vh(a),i&512&&Vl(a,a.return);break;case 3:if(Jn(e,a),i&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{qm(e,t)}catch(b){Xe(a,a.return,b)}}break;case 27:t===null&&i&4&&Fh(a);case 26:case 5:Jn(e,a),t===null&&i&4&&Gh(a),i&512&&Vl(a,a.return);break;case 12:Jn(e,a);break;case 31:Jn(e,a),i&4&&Ih(e,a);break;case 13:Jn(e,a),i&4&&Jh(e,a),i&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=wb.bind(null,a),Fb(e,a))));break;case 22:if(i=a.memoizedState!==null||Zn,!i){t=t!==null&&t.memoizedState!==null||jt,c=Zn;var u=jt;Zn=i,(jt=t)&&!u?Pn(e,a,(a.subtreeFlags&8772)!==0):Jn(e,a),Zn=c,jt=u}break;case 30:break;default:Jn(e,a)}}function Kh(e){var t=e.alternate;t!==null&&(e.alternate=null,Kh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Uo(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var at=null,Ht=!1;function In(e,t,a){for(a=a.child;a!==null;)Zh(e,t,a),a=a.sibling}function Zh(e,t,a){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(yn,a)}catch{}switch(a.tag){case 26:jt||Tn(a,t),In(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:jt||Tn(a,t);var i=at,c=Ht;ka(a.type)&&(at=a.stateNode,Ht=!1),In(e,t,a),Il(a.stateNode),at=i,Ht=c;break;case 5:jt||Tn(a,t);case 6:if(i=at,c=Ht,at=null,In(e,t,a),at=i,Ht=c,at!==null)if(Ht)try{(at.nodeType===9?at.body:at.nodeName==="HTML"?at.ownerDocument.body:at).removeChild(a.stateNode)}catch(u){Xe(a,t,u)}else try{at.removeChild(a.stateNode)}catch(u){Xe(a,t,u)}break;case 18:at!==null&&(Ht?(e=at,Vp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Is(e)):Vp(at,a.stateNode));break;case 4:i=at,c=Ht,at=a.stateNode.containerInfo,Ht=!0,In(e,t,a),at=i,Ht=c;break;case 0:case 11:case 14:case 15:Sa(2,a,t),jt||Sa(4,a,t),In(e,t,a);break;case 1:jt||(Tn(a,t),i=a.stateNode,typeof i.componentWillUnmount=="function"&&$h(a,t,i)),In(e,t,a);break;case 21:In(e,t,a);break;case 22:jt=(i=jt)||a.memoizedState!==null,In(e,t,a),jt=i;break;default:In(e,t,a)}}function Ih(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Is(e)}catch(a){Xe(t,t.return,a)}}}function Jh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Is(e)}catch(a){Xe(t,t.return,a)}}function gb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Xh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Xh),t;default:throw Error(o(435,e.tag))}}function br(e,t){var a=gb(e);t.forEach(function(i){if(!a.has(i)){a.add(i);var c=Cb.bind(null,e,i);i.then(c,c)}})}function Vt(e,t){var a=t.deletions;if(a!==null)for(var i=0;i<a.length;i++){var c=a[i],u=e,b=t,j=b;e:for(;j!==null;){switch(j.tag){case 27:if(ka(j.type)){at=j.stateNode,Ht=!1;break e}break;case 5:at=j.stateNode,Ht=!1;break e;case 3:case 4:at=j.stateNode.containerInfo,Ht=!0;break e}j=j.return}if(at===null)throw Error(o(160));Zh(u,b,c),at=null,Ht=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Ph(t,e),t=t.sibling}var jn=null;function Ph(e,t){var a=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vt(t,e),$t(e),i&4&&(Sa(3,e,e.return),Hl(3,e),Sa(5,e,e.return));break;case 1:Vt(t,e),$t(e),i&512&&(jt||a===null||Tn(a,a.return)),i&64&&Zn&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?i:a.concat(i))));break;case 26:var c=jn;if(Vt(t,e),$t(e),i&512&&(jt||a===null||Tn(a,a.return)),i&4){var u=a!==null?a.memoizedState:null;if(i=e.memoizedState,a===null)if(i===null)if(e.stateNode===null){e:{i=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":u=c.getElementsByTagName("title")[0],(!u||u[hl]||u[ct]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(i),c.head.insertBefore(u,c.querySelector("head > title"))),Dt(u,i,a),u[ct]=e,Ct(u),i=u;break e;case"link":var b=Pp("link","href",c).get(i+(a.href||""));if(b){for(var j=0;j<b.length;j++)if(u=b[j],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)){b.splice(j,1);break t}}u=c.createElement(i),Dt(u,i,a),c.head.appendChild(u);break;case"meta":if(b=Pp("meta","content",c).get(i+(a.content||""))){for(j=0;j<b.length;j++)if(u=b[j],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)){b.splice(j,1);break t}}u=c.createElement(i),Dt(u,i,a),c.head.appendChild(u);break;default:throw Error(o(468,i))}u[ct]=e,Ct(u),i=u}e.stateNode=i}else Wp(c,e.type,e.stateNode);else e.stateNode=Jp(c,i,e.memoizedProps);else u!==i?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,i===null?Wp(c,e.type,e.stateNode):Jp(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&iu(e,e.memoizedProps,a.memoizedProps)}break;case 27:Vt(t,e),$t(e),i&512&&(jt||a===null||Tn(a,a.return)),a!==null&&i&4&&iu(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Vt(t,e),$t(e),i&512&&(jt||a===null||Tn(a,a.return)),e.flags&32){c=e.stateNode;try{bs(c,"")}catch(de){Xe(e,e.return,de)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,iu(e,c,a!==null?a.memoizedProps:c)),i&1024&&(cu=!0);break;case 6:if(Vt(t,e),$t(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,a=e.stateNode;try{a.nodeValue=i}catch(de){Xe(e,e.return,de)}}break;case 3:if(Br=null,c=jn,jn=Dr(t.containerInfo),Vt(t,e),jn=c,$t(e),i&4&&a!==null&&a.memoizedState.isDehydrated)try{Is(t.containerInfo)}catch(de){Xe(e,e.return,de)}cu&&(cu=!1,Wh(e));break;case 4:i=jn,jn=Dr(e.stateNode.containerInfo),Vt(t,e),$t(e),jn=i;break;case 12:Vt(t,e),$t(e);break;case 31:Vt(t,e),$t(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,br(e,i)));break;case 13:Vt(t,e),$t(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Sr=Oe()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,br(e,i)));break;case 22:c=e.memoizedState!==null;var _=a!==null&&a.memoizedState!==null,Y=Zn,P=jt;if(Zn=Y||c,jt=P||_,Vt(t,e),jt=P,Zn=Y,$t(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||_||Zn||jt||Wa(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){_=a=t;try{if(u=_.stateNode,c)b=u.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{j=_.stateNode;var te=_.memoizedProps.style,X=te!=null&&te.hasOwnProperty("display")?te.display:null;j.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(de){Xe(_,_.return,de)}}}else if(t.tag===6){if(a===null){_=t;try{_.stateNode.nodeValue=c?"":_.memoizedProps}catch(de){Xe(_,_.return,de)}}}else if(t.tag===18){if(a===null){_=t;try{var I=_.stateNode;c?$p(I,!0):$p(_.stateNode,!1)}catch(de){Xe(_,_.return,de)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(a=i.retryQueue,a!==null&&(i.retryQueue=null,br(e,a))));break;case 19:Vt(t,e),$t(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,br(e,i)));break;case 30:break;case 21:break;default:Vt(t,e),$t(e)}}function $t(e){var t=e.flags;if(t&2){try{for(var a,i=e.return;i!==null;){if(Yh(i)){a=i;break}i=i.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=ru(e);vr(e,u,c);break;case 5:var b=a.stateNode;a.flags&32&&(bs(b,""),a.flags&=-33);var j=ru(e);vr(e,j,b);break;case 3:case 4:var _=a.stateNode.containerInfo,Y=ru(e);ou(e,Y,_);break;default:throw Error(o(161))}}catch(P){Xe(e,e.return,P)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Wh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Wh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Jn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Qh(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:Sa(4,t,t.return),Wa(t);break;case 1:Tn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&$h(t,t.return,a),Wa(t);break;case 27:Il(t.stateNode);case 26:case 5:Tn(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 Pn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,u=t,b=u.flags;switch(u.tag){case 0:case 11:case 15:Pn(c,u,a),Hl(4,u);break;case 1:if(Pn(c,u,a),i=u,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(Y){Xe(i,i.return,Y)}if(i=u,c=i.updateQueue,c!==null){var j=i.stateNode;try{var _=c.shared.hiddenCallbacks;if(_!==null)for(c.shared.hiddenCallbacks=null,c=0;c<_.length;c++)Rm(_[c],j)}catch(Y){Xe(i,i.return,Y)}}a&&b&64&&Vh(u),Vl(u,u.return);break;case 27:Fh(u);case 26:case 5:Pn(c,u,a),a&&i===null&&b&4&&Gh(u),Vl(u,u.return);break;case 12:Pn(c,u,a);break;case 31:Pn(c,u,a),a&&b&4&&Ih(c,u);break;case 13:Pn(c,u,a),a&&b&4&&Jh(c,u);break;case 22:u.memoizedState===null&&Pn(c,u,a),Vl(u,u.return);break;case 30:break;default:Pn(c,u,a)}t=t.sibling}}function uu(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&El(a))}function fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&El(e))}function An(e,t,a,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)ep(e,t,a,i),t=t.sibling}function ep(e,t,a,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:An(e,t,a,i),c&2048&&Hl(9,t);break;case 1:An(e,t,a,i);break;case 3:An(e,t,a,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&El(e)));break;case 12:if(c&2048){An(e,t,a,i),e=t.stateNode;try{var u=t.memoizedProps,b=u.id,j=u.onPostCommit;typeof j=="function"&&j(b,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(_){Xe(t,t.return,_)}}else An(e,t,a,i);break;case 31:An(e,t,a,i);break;case 13:An(e,t,a,i);break;case 23:break;case 22:u=t.stateNode,b=t.alternate,t.memoizedState!==null?u._visibility&2?An(e,t,a,i):$l(e,t):u._visibility&2?An(e,t,a,i):(u._visibility|=2,Us(e,t,a,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&uu(b,t);break;case 24:An(e,t,a,i),c&2048&&fu(t.alternate,t);break;default:An(e,t,a,i)}}function Us(e,t,a,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,b=t,j=a,_=i,Y=b.flags;switch(b.tag){case 0:case 11:case 15:Us(u,b,j,_,c),Hl(8,b);break;case 23:break;case 22:var P=b.stateNode;b.memoizedState!==null?P._visibility&2?Us(u,b,j,_,c):$l(u,b):(P._visibility|=2,Us(u,b,j,_,c)),c&&Y&2048&&uu(b.alternate,b);break;case 24:Us(u,b,j,_,c),c&&Y&2048&&fu(b.alternate,b);break;default:Us(u,b,j,_,c)}t=t.sibling}}function $l(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,i=t,c=i.flags;switch(i.tag){case 22:$l(a,i),c&2048&&uu(i.alternate,i);break;case 24:$l(a,i),c&2048&&fu(i.alternate,i);break;default:$l(a,i)}t=t.sibling}}var Gl=8192;function Hs(e,t,a){if(e.subtreeFlags&Gl)for(e=e.child;e!==null;)tp(e,t,a),e=e.sibling}function tp(e,t,a){switch(e.tag){case 26:Hs(e,t,a),e.flags&Gl&&e.memoizedState!==null&&ay(a,jn,e.memoizedState,e.memoizedProps);break;case 5:Hs(e,t,a);break;case 3:case 4:var i=jn;jn=Dr(e.stateNode.containerInfo),Hs(e,t,a),jn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=Gl,Gl=16777216,Hs(e,t,a),Gl=i):Hs(e,t,a));break;default:Hs(e,t,a)}}function np(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 Yl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];Et=i,sp(i,e)}np(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)ap(e),e=e.sibling}function ap(e){switch(e.tag){case 0:case 11:case 15:Yl(e),e.flags&2048&&Sa(9,e,e.return);break;case 3:Yl(e);break;case 12:Yl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,yr(e)):Yl(e);break;default:Yl(e)}}function yr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];Et=i,sp(i,e)}np(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Sa(8,t,t.return),yr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,yr(t));break;default:yr(t)}e=e.sibling}}function sp(e,t){for(;Et!==null;){var a=Et;switch(a.tag){case 0:case 11:case 15:Sa(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var i=a.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:El(a.memoizedState.cache)}if(i=a.child,i!==null)i.return=a,Et=i;else e:for(a=e;Et!==null;){i=Et;var c=i.sibling,u=i.return;if(Kh(i),i===a){Et=null;break e}if(c!==null){c.return=u,Et=c;break e}Et=u}}}var vb={getCacheForType:function(e){var t=qt(bt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return qt(bt).controller.signal}},bb=typeof WeakMap=="function"?WeakMap:Map,$e=0,Pe=null,Me=null,qe=0,Fe=0,It=null,ja=!1,Vs=!1,du=!1,Wn=0,ft=0,Aa=0,es=0,mu=0,Jt=0,$s=0,Fl=null,Gt=null,hu=!1,Sr=0,lp=0,jr=1/0,Ar=null,Na=null,Nt=0,wa=null,Gs=null,ea=0,pu=0,xu=null,ip=null,Xl=0,gu=null;function Pt(){return($e&2)!==0&&qe!==0?qe&-qe:q.T!==null?Au():Ye()}function rp(){if(Jt===0)if((qe&536870912)===0||_e){var e=We;We<<=1,(We&3932160)===0&&(We=262144),Jt=e}else Jt=536870912;return e=Kt.current,e!==null&&(e.flags|=32),Jt}function Yt(e,t,a){(e===Pe&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)&&(Ys(e,0),Ca(e,qe,Jt,!1)),La(e,a),(($e&2)===0||e!==Pe)&&(e===Pe&&(($e&2)===0&&(es|=a),ft===4&&Ca(e,qe,Jt,!1)),Dn(e))}function op(e,t,a){if(($e&6)!==0)throw Error(o(327));var i=!a&&(t&127)===0&&(t&e.expiredLanes)===0||Mn(e,t),c=i?jb(e,t):bu(e,t,!0),u=i;do{if(c===0){Vs&&!i&&Ca(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!yb(a)){c=bu(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var b=0;else b=e.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){t=b;e:{var j=e;c=Fl;var _=j.current.memoizedState.isDehydrated;if(_&&(Ys(j,b).flags|=256),b=bu(j,b,!1),b!==2){if(du&&!_){j.errorRecoveryDisabledLanes|=u,es|=u,c=4;break e}u=Gt,Gt=c,u!==null&&(Gt===null?Gt=u:Gt.push.apply(Gt,u))}c=b}if(u=!1,c!==2)continue}}if(c===1){Ys(e,0),Ca(e,t,0,!0);break}e:{switch(i=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:Ca(i,t,Jt,!ja);break e;case 2:Gt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=Sr+300-Oe(),10<c)){if(Ca(i,t,Jt,!ja),ua(i,0,!0)!==0)break e;ea=t,i.timeoutHandle=Up(cp.bind(null,i,a,Gt,Ar,hu,t,Jt,es,$s,ja,u,"Throttled",-0,0),c);break e}cp(i,a,Gt,Ar,hu,t,Jt,es,$s,ja,u,null,-0,0)}}break}while(!0);Dn(e)}function cp(e,t,a,i,c,u,b,j,_,Y,P,te,X,I){if(e.timeoutHandle=-1,te=t.subtreeFlags,te&8192||(te&16785408)===16785408){te={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Un},tp(t,u,te);var de=(u&62914560)===u?Sr-Oe():(u&4194048)===u?lp-Oe():0;if(de=sy(te,de),de!==null){ea=u,e.cancelPendingCommit=de(gp.bind(null,e,t,u,a,i,c,b,j,_,P,te,null,X,I)),Ca(e,u,b,!Y);return}}gp(e,t,u,a,i,c,b,j,_)}function yb(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var i=0;i<a.length;i++){var c=a[i],u=c.getSnapshot;c=c.value;try{if(!Xt(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 Ca(e,t,a,i){t&=~mu,t&=~es,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var u=31-vt(c),b=1<<u;i[u]=-1,c&=~b}a!==0&&sn(e,a,t)}function Nr(){return($e&6)===0?(Ql(0),!1):!0}function vu(){if(Me!==null){if(Fe===0)var e=Me.return;else e=Me,Gn=Fa=null,_c(e),_s=null,Ml=0,e=Me;for(;e!==null;)Hh(e.alternate,e),e=e.return;Me=null}}function Ys(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Hb(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),ea=0,vu(),Pe=e,Me=a=Vn(e.current,null),qe=t,Fe=0,It=null,ja=!1,Vs=Mn(e,t),du=!1,$s=Jt=mu=es=Aa=ft=0,Gt=Fl=null,hu=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-vt(i),u=1<<c;t|=e[c],i&=~u}return Wn=t,Fi(),a}function up(e,t){we=null,q.H=Ll,t===Ds||t===Wi?(t=Cm(),Fe=3):t===jc?(t=Cm(),Fe=4):Fe=t===Ic?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,It=t,Me===null&&(ft=1,mr(e,un(t,e.current)))}function fp(){var e=Kt.current;return e===null?!0:(qe&4194048)===qe?hn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===hn:!1}function dp(){var e=q.H;return q.H=Ll,e===null?Ll:e}function mp(){var e=q.A;return q.A=vb,e}function wr(){ft=4,ja||(qe&4194048)!==qe&&Kt.current!==null||(Vs=!0),(Aa&134217727)===0&&(es&134217727)===0||Pe===null||Ca(Pe,qe,Jt,!1)}function bu(e,t,a){var i=$e;$e|=2;var c=dp(),u=mp();(Pe!==e||qe!==t)&&(Ar=null,Ys(e,t)),t=!1;var b=ft;e:do try{if(Fe!==0&&Me!==null){var j=Me,_=It;switch(Fe){case 8:vu(),b=6;break e;case 3:case 2:case 9:case 6:Kt.current===null&&(t=!0);var Y=Fe;if(Fe=0,It=null,Fs(e,j,_,Y),a&&Vs){b=0;break e}break;default:Y=Fe,Fe=0,It=null,Fs(e,j,_,Y)}}Sb(),b=ft;break}catch(P){up(e,P)}while(!0);return t&&e.shellSuspendCounter++,Gn=Fa=null,$e=i,q.H=c,q.A=u,Me===null&&(Pe=null,qe=0,Fi()),b}function Sb(){for(;Me!==null;)hp(Me)}function jb(e,t){var a=$e;$e|=2;var i=dp(),c=mp();Pe!==e||qe!==t?(Ar=null,jr=Oe()+500,Ys(e,t)):Vs=Mn(e,t);e:do try{if(Fe!==0&&Me!==null){t=Me;var u=It;t:switch(Fe){case 1:Fe=0,It=null,Fs(e,t,u,1);break;case 2:case 9:if(Nm(u)){Fe=0,It=null,pp(t);break}t=function(){Fe!==2&&Fe!==9||Pe!==e||(Fe=7),Dn(e)},u.then(t,t);break e;case 3:Fe=7;break e;case 4:Fe=5;break e;case 7:Nm(u)?(Fe=0,It=null,pp(t)):(Fe=0,It=null,Fs(e,t,u,7));break;case 5:var b=null;switch(Me.tag){case 26:b=Me.memoizedState;case 5:case 27:var j=Me;if(b?e0(b):j.stateNode.complete){Fe=0,It=null;var _=j.sibling;if(_!==null)Me=_;else{var Y=j.return;Y!==null?(Me=Y,Cr(Y)):Me=null}break t}}Fe=0,It=null,Fs(e,t,u,5);break;case 6:Fe=0,It=null,Fs(e,t,u,6);break;case 8:vu(),ft=6;break e;default:throw Error(o(462))}}Ab();break}catch(P){up(e,P)}while(!0);return Gn=Fa=null,q.H=i,q.A=c,$e=a,Me!==null?0:(Pe=null,qe=0,Fi(),ft)}function Ab(){for(;Me!==null&&!Ae();)hp(Me)}function hp(e){var t=zh(e.alternate,e,Wn);e.memoizedProps=e.pendingProps,t===null?Cr(e):Me=t}function pp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Th(a,t,t.pendingProps,t.type,void 0,qe);break;case 11:t=Th(a,t,t.pendingProps,t.type.render,t.ref,qe);break;case 5:_c(t);default:Hh(a,t),t=Me=mm(t,Wn),t=zh(a,t,Wn)}e.memoizedProps=e.pendingProps,t===null?Cr(e):Me=t}function Fs(e,t,a,i){Gn=Fa=null,_c(t),_s=null,Ml=0;var c=t.return;try{if(fb(e,c,t,a,qe)){ft=1,mr(e,un(a,e.current)),Me=null;return}}catch(u){if(c!==null)throw Me=c,u;ft=1,mr(e,un(a,e.current)),Me=null;return}t.flags&32768?(_e||i===1?e=!0:Vs||(qe&536870912)!==0?e=!1:(ja=e=!0,(i===2||i===9||i===3||i===6)&&(i=Kt.current,i!==null&&i.tag===13&&(i.flags|=16384))),xp(t,e)):Cr(t)}function Cr(e){var t=e;do{if((t.flags&32768)!==0){xp(t,ja);return}e=t.return;var a=hb(t.alternate,t,Wn);if(a!==null){Me=a;return}if(t=t.sibling,t!==null){Me=t;return}Me=t=e}while(t!==null);ft===0&&(ft=5)}function xp(e,t){do{var a=pb(e.alternate,e);if(a!==null){a.flags&=32767,Me=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Me=e;return}Me=e=a}while(e!==null);ft=6,Me=null}function gp(e,t,a,i,c,u,b,j,_){e.cancelPendingCommit=null;do Er();while(Nt!==0);if(($e&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=rc,Di(e,a,u,b,j,_),e===Pe&&(Me=Pe=null,qe=0),Gs=t,wa=e,ea=a,pu=u,xu=c,ip=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Eb(kt,function(){return jp(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=q.T,q.T=null,c=L.p,L.p=2,b=$e,$e|=4;try{xb(e,t,a)}finally{$e=b,L.p=c,q.T=i}}Nt=1,vp(),bp(),yp()}}function vp(){if(Nt===1){Nt=0;var e=wa,t=Gs,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=q.T,q.T=null;var i=L.p;L.p=2;var c=$e;$e|=4;try{Ph(t,e);var u=qu,b=sm(e.containerInfo),j=u.focusedElem,_=u.selectionRange;if(b!==j&&j&&j.ownerDocument&&am(j.ownerDocument.documentElement,j)){if(_!==null&&nc(j)){var Y=_.start,P=_.end;if(P===void 0&&(P=Y),"selectionStart"in j)j.selectionStart=Y,j.selectionEnd=Math.min(P,j.value.length);else{var te=j.ownerDocument||document,X=te&&te.defaultView||window;if(X.getSelection){var I=X.getSelection(),de=j.textContent.length,je=Math.min(_.start,de),Ze=_.end===void 0?je:Math.min(_.end,de);!I.extend&&je>Ze&&(b=Ze,Ze=je,je=b);var z=nm(j,je),B=nm(j,Ze);if(z&&B&&(I.rangeCount!==1||I.anchorNode!==z.node||I.anchorOffset!==z.offset||I.focusNode!==B.node||I.focusOffset!==B.offset)){var G=te.createRange();G.setStart(z.node,z.offset),I.removeAllRanges(),je>Ze?(I.addRange(G),I.extend(B.node,B.offset)):(G.setEnd(B.node,B.offset),I.addRange(G))}}}}for(te=[],I=j;I=I.parentNode;)I.nodeType===1&&te.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<te.length;j++){var ee=te[j];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Ur=!!Ru,qu=Ru=null}finally{$e=c,L.p=i,q.T=a}}e.current=t,Nt=2}}function bp(){if(Nt===2){Nt=0;var e=wa,t=Gs,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=q.T,q.T=null;var i=L.p;L.p=2;var c=$e;$e|=4;try{Qh(e,t.alternate,t)}finally{$e=c,L.p=i,q.T=a}}Nt=3}}function yp(){if(Nt===4||Nt===3){Nt=0,ht();var e=wa,t=Gs,a=ea,i=ip;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Nt=5:(Nt=0,Gs=wa=null,Sp(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(Na=null),ke(a),t=t.stateNode,wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(yn,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=q.T,c=L.p,L.p=2,q.T=null;try{for(var u=e.onRecoverableError,b=0;b<i.length;b++){var j=i[b];u(j.value,{componentStack:j.stack})}}finally{q.T=t,L.p=c}}(ea&3)!==0&&Er(),Dn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===gu?Xl++:(Xl=0,gu=e):Xl=0,Ql(0)}}function Sp(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,El(t)))}function Er(){return vp(),bp(),yp(),jp()}function jp(){if(Nt!==5)return!1;var e=wa,t=pu;pu=0;var a=ke(ea),i=q.T,c=L.p;try{L.p=32>a?32:a,q.T=null,a=xu,xu=null;var u=wa,b=ea;if(Nt=0,Gs=wa=null,ea=0,($e&6)!==0)throw Error(o(331));var j=$e;if($e|=4,ap(u.current),ep(u,u.current,b,a),$e=j,Ql(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(yn,u)}catch{}return!0}finally{L.p=c,q.T=i,Sp(e,t)}}function Ap(e,t,a){t=un(a,t),t=Zc(e.stateNode,t,2),e=va(e,t,2),e!==null&&(La(e,2),Dn(e))}function Xe(e,t,a){if(e.tag===3)Ap(e,e,a);else for(;t!==null;){if(t.tag===3){Ap(t,e,a);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Na===null||!Na.has(i))){e=un(a,e),a=Nh(2),i=va(t,a,2),i!==null&&(wh(a,i,t,e),La(i,2),Dn(i));break}}t=t.return}}function yu(e,t,a){var i=e.pingCache;if(i===null){i=e.pingCache=new bb;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(a)||(du=!0,c.add(a),e=Nb.bind(null,e,t,a),t.then(e,e))}function Nb(e,t,a){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,Pe===e&&(qe&a)===a&&(ft===4||ft===3&&(qe&62914560)===qe&&300>Oe()-Sr?($e&2)===0&&Ys(e,0):mu|=a,$s===qe&&($s=0)),Dn(e)}function Np(e,t){t===0&&(t=Ti()),e=$a(e,t),e!==null&&(La(e,t),Dn(e))}function wb(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),Np(e,a)}function Cb(e,t){var a=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),Np(e,a)}function Eb(e,t){return J(e,t)}var kr=null,Xs=null,Su=!1,Mr=!1,ju=!1,Ea=0;function Dn(e){e!==Xs&&e.next===null&&(Xs===null?kr=Xs=e:Xs=Xs.next=e),Mr=!0,Su||(Su=!0,Mb())}function Ql(e,t){if(!ju&&Mr){ju=!0;do for(var a=!1,i=kr;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var u=0;else{var b=i.suspendedLanes,j=i.pingedLanes;u=(1<<31-vt(42|e)+1)-1,u&=c&~(b&~j),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,kp(i,u))}else u=qe,u=ua(i,i===Pe?u:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(u&3)===0||Mn(i,u)||(a=!0,kp(i,u));i=i.next}while(a);ju=!1}}function kb(){wp()}function wp(){Mr=Su=!1;var e=0;Ea!==0&&Ub()&&(e=Ea);for(var t=Oe(),a=null,i=kr;i!==null;){var c=i.next,u=Cp(i,t);u===0?(i.next=null,a===null?kr=c:a.next=c,c===null&&(Xs=a)):(a=i,(e!==0||(u&3)!==0)&&(Mr=!0)),i=c}Nt!==0&&Nt!==5||Ql(e),Ea!==0&&(Ea=0)}function Cp(e,t){for(var a=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var b=31-vt(u),j=1<<b,_=c[b];_===-1?((j&a)===0||(j&i)!==0)&&(c[b]=qi(j,t)):_<=t&&(e.expiredLanes|=j),u&=~j}if(t=Pe,a=qe,a=ua(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,a===0||e===t&&(Fe===2||Fe===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&he(i),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||Mn(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(i!==null&&he(i),ke(a)){case 2:case 8:a=gt;break;case 32:a=kt;break;case 268435456:a=Lt;break;default:a=kt}return i=Ep.bind(null,e),a=J(a,i),e.callbackPriority=t,e.callbackNode=a,t}return i!==null&&i!==null&&he(i),e.callbackPriority=2,e.callbackNode=null,2}function Ep(e,t){if(Nt!==0&&Nt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Er()&&e.callbackNode!==a)return null;var i=qe;return i=ua(e,e===Pe?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(op(e,i,t),Cp(e,Oe()),e.callbackNode!=null&&e.callbackNode===a?Ep.bind(null,e):null)}function kp(e,t){if(Er())return null;op(e,t,!0)}function Mb(){Vb(function(){($e&6)!==0?J(ot,kb):wp()})}function Au(){if(Ea===0){var e=qs;e===0&&(e=Oa,Oa<<=1,(Oa&261888)===0&&(Oa=256)),Ea=e}return Ea}function Mp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Li(""+e)}function Rp(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 Rb(e,t,a,i,c){if(t==="submit"&&a&&a.stateNode===c){var u=Mp((c[ze]||null).action),b=i.submitter;b&&(t=(t=b[ze]||null)?Mp(t.formAction):b.getAttribute("formAction"),t!==null&&(u=t,b=null));var j=new Vi("action","action",null,i,c);e.push({event:j,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ea!==0){var _=b?Rp(c,b):new FormData(c);Gc(a,{pending:!0,data:_,method:c.method,action:u},null,_)}}else typeof u=="function"&&(j.preventDefault(),_=b?Rp(c,b):new FormData(c),Gc(a,{pending:!0,data:_,method:c.method,action:u},u,_))},currentTarget:c}]})}}for(var Nu=0;Nu<ic.length;Nu++){var wu=ic[Nu],qb=wu.toLowerCase(),Tb=wu[0].toUpperCase()+wu.slice(1);Sn(qb,"on"+Tb)}Sn(rm,"onAnimationEnd"),Sn(om,"onAnimationIteration"),Sn(cm,"onAnimationStart"),Sn("dblclick","onDoubleClick"),Sn("focusin","onFocus"),Sn("focusout","onBlur"),Sn(Kv,"onTransitionRun"),Sn(Zv,"onTransitionStart"),Sn(Iv,"onTransitionCancel"),Sn(um,"onTransitionEnd"),gs("onMouseEnter",["mouseout","mouseover"]),gs("onMouseLeave",["mouseout","mouseover"]),gs("onPointerEnter",["pointerout","pointerover"]),gs("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 Kl="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(" "),Db=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kl));function qp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var i=e[a],c=i.event;i=i.listeners;e:{var u=void 0;if(t)for(var b=i.length-1;0<=b;b--){var j=i[b],_=j.instance,Y=j.currentTarget;if(j=j.listener,_!==u&&c.isPropagationStopped())break e;u=j,c.currentTarget=Y;try{u(c)}catch(P){Yi(P)}c.currentTarget=null,u=_}else for(b=0;b<i.length;b++){if(j=i[b],_=j.instance,Y=j.currentTarget,j=j.listener,_!==u&&c.isPropagationStopped())break e;u=j,c.currentTarget=Y;try{u(c)}catch(P){Yi(P)}c.currentTarget=null,u=_}}}}function Re(e,t){var a=t[zo];a===void 0&&(a=t[zo]=new Set);var i=e+"__bubble";a.has(i)||(Tp(t,e,2,!1),a.add(i))}function Cu(e,t,a){var i=0;t&&(i|=4),Tp(a,e,i,t)}var Rr="_reactListening"+Math.random().toString(36).slice(2);function Eu(e){if(!e[Rr]){e[Rr]=!0,wd.forEach(function(a){a!=="selectionchange"&&(Db.has(a)||Cu(a,!1,e),Cu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Rr]||(t[Rr]=!0,Cu("selectionchange",!1,t))}}function Tp(e,t,a,i){switch(r0(t)){case 2:var c=ry;break;case 8:c=oy;break;default:c=$u}a=c.bind(null,t,a,e),c=void 0,!Qo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function ku(e,t,a,i,c){var u=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var b=i.tag;if(b===3||b===4){var j=i.stateNode.containerInfo;if(j===c)break;if(b===4)for(b=i.return;b!==null;){var _=b.tag;if((_===3||_===4)&&b.stateNode.containerInfo===c)return;b=b.return}for(;j!==null;){if(b=hs(j),b===null)return;if(_=b.tag,_===5||_===6||_===26||_===27){i=u=b;continue e}j=j.parentNode}}i=i.return}Ld(function(){var Y=u,P=Fo(a),te=[];e:{var X=fm.get(e);if(X!==void 0){var I=Vi,de=e;switch(e){case"keypress":if(Ui(a)===0)break e;case"keydown":case"keyup":I=Cv;break;case"focusin":de="focus",I=Jo;break;case"focusout":de="blur",I=Jo;break;case"beforeblur":case"afterblur":I=Jo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":I=Hd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":I=hv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":I=Mv;break;case rm:case om:case cm:I=gv;break;case um:I=qv;break;case"scroll":case"scrollend":I=dv;break;case"wheel":I=Dv;break;case"copy":case"cut":case"paste":I=bv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":I=$d;break;case"toggle":case"beforetoggle":I=Bv}var je=(t&4)!==0,Ze=!je&&(e==="scroll"||e==="scrollend"),z=je?X!==null?X+"Capture":null:X;je=[];for(var B=Y,G;B!==null;){var ee=B;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||z===null||(ee=xl(B,z),ee!=null&&je.push(Zl(B,ee,G))),Ze)break;B=B.return}0<je.length&&(X=new I(X,de,null,a,P),te.push({event:X,listeners:je}))}}if((t&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",I=e==="mouseout"||e==="pointerout",X&&a!==Yo&&(de=a.relatedTarget||a.fromElement)&&(hs(de)||de[ln]))break e;if((I||X)&&(X=P.window===P?P:(X=P.ownerDocument)?X.defaultView||X.parentWindow:window,I?(de=a.relatedTarget||a.toElement,I=Y,de=de?hs(de):null,de!==null&&(Ze=d(de),je=de.tag,de!==Ze||je!==5&&je!==27&&je!==6)&&(de=null)):(I=null,de=Y),I!==de)){if(je=Hd,ee="onMouseLeave",z="onMouseEnter",B="mouse",(e==="pointerout"||e==="pointerover")&&(je=$d,ee="onPointerLeave",z="onPointerEnter",B="pointer"),Ze=I==null?X:pl(I),G=de==null?X:pl(de),X=new je(ee,B+"leave",I,a,P),X.target=Ze,X.relatedTarget=G,ee=null,hs(P)===Y&&(je=new je(z,B+"enter",de,a,P),je.target=G,je.relatedTarget=Ze,ee=je),Ze=ee,I&&de)t:{for(je=_b,z=I,B=de,G=0,ee=z;ee;ee=je(ee))G++;ee=0;for(var Se=B;Se;Se=je(Se))ee++;for(;0<G-ee;)z=je(z),G--;for(;0<ee-G;)B=je(B),ee--;for(;G--;){if(z===B||B!==null&&z===B.alternate){je=z;break t}z=je(z),B=je(B)}je=null}else je=null;I!==null&&Dp(te,X,I,je,!1),de!==null&&Ze!==null&&Dp(te,Ze,de,je,!0)}}e:{if(X=Y?pl(Y):window,I=X.nodeName&&X.nodeName.toLowerCase(),I==="select"||I==="input"&&X.type==="file")var Ue=Id;else if(Kd(X))if(Jd)Ue=Fv;else{Ue=Gv;var ge=$v}else I=X.nodeName,!I||I.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?Y&&Go(Y.elementType)&&(Ue=Id):Ue=Yv;if(Ue&&(Ue=Ue(e,Y))){Zd(te,Ue,a,P);break e}ge&&ge(e,X,Y),e==="focusout"&&Y&&X.type==="number"&&Y.memoizedProps.value!=null&&$o(X,"number",X.value)}switch(ge=Y?pl(Y):window,e){case"focusin":(Kd(ge)||ge.contentEditable==="true")&&(As=ge,ac=Y,Nl=null);break;case"focusout":Nl=ac=As=null;break;case"mousedown":sc=!0;break;case"contextmenu":case"mouseup":case"dragend":sc=!1,lm(te,a,P);break;case"selectionchange":if(Qv)break;case"keydown":case"keyup":lm(te,a,P)}var Ce;if(Wo)e:{switch(e){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else js?Xd(e,a)&&(Te="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Te="onCompositionStart");Te&&(Gd&&a.locale!=="ko"&&(js||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&js&&(Ce=zd()):(fa=P,Ko="value"in fa?fa.value:fa.textContent,js=!0)),ge=qr(Y,Te),0<ge.length&&(Te=new Vd(Te,e,null,a,P),te.push({event:Te,listeners:ge}),Ce?Te.data=Ce:(Ce=Qd(a),Ce!==null&&(Te.data=Ce)))),(Ce=Lv?zv(e,a):Uv(e,a))&&(Te=qr(Y,"onBeforeInput"),0<Te.length&&(ge=new Vd("onBeforeInput","beforeinput",null,a,P),te.push({event:ge,listeners:Te}),ge.data=Ce)),Rb(te,e,Y,a,P)}qp(te,t)})}function Zl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function qr(e,t){for(var a=t+"Capture",i=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=xl(e,a),c!=null&&i.unshift(Zl(e,c,u)),c=xl(e,t),c!=null&&i.push(Zl(e,c,u))),e.tag===3)return i;e=e.return}return[]}function _b(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dp(e,t,a,i,c){for(var u=t._reactName,b=[];a!==null&&a!==i;){var j=a,_=j.alternate,Y=j.stateNode;if(j=j.tag,_!==null&&_===i)break;j!==5&&j!==26&&j!==27||Y===null||(_=Y,c?(Y=xl(a,u),Y!=null&&b.unshift(Zl(a,Y,_))):c||(Y=xl(a,u),Y!=null&&b.push(Zl(a,Y,_)))),a=a.return}b.length!==0&&e.push({event:t,listeners:b})}var Bb=/\r\n?/g,Ob=/\u0000|\uFFFD/g;function _p(e){return(typeof e=="string"?e:""+e).replace(Bb,`
|
||
`).replace(Ob,"")}function Bp(e,t){return t=_p(t),_p(e)===t}function Ke(e,t,a,i,c,u){switch(a){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||bs(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&bs(e,""+i);break;case"className":Bi(e,"class",i);break;case"tabIndex":Bi(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Bi(e,a,i);break;case"style":Bd(e,i,u);break;case"data":if(t!=="object"){Bi(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Li(""+i),e.setAttribute(a,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(a==="formAction"?(t!=="input"&&Ke(e,t,"name",c.name,c,null),Ke(e,t,"formEncType",c.formEncType,c,null),Ke(e,t,"formMethod",c.formMethod,c,null),Ke(e,t,"formTarget",c.formTarget,c,null)):(Ke(e,t,"encType",c.encType,c,null),Ke(e,t,"method",c.method,c,null),Ke(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Li(""+i),e.setAttribute(a,i);break;case"onClick":i!=null&&(e.onclick=Un);break;case"onScroll":i!=null&&Re("scroll",e);break;case"onScrollEnd":i!=null&&Re("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}a=Li(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""+i):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":i===!0?e.setAttribute(a,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,i):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(a,i):e.removeAttribute(a);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(a):e.setAttribute(a,i);break;case"popover":Re("beforetoggle",e),Re("toggle",e),_i(e,"popover",i);break;case"xlinkActuate":zn(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":zn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":zn(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":zn(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":zn(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":zn(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":zn(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":zn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":zn(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":_i(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=uv.get(a)||a,_i(e,a,i))}}function Mu(e,t,a,i,c,u){switch(a){case"style":Bd(e,i,u);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof i=="string"?bs(e,i):(typeof i=="number"||typeof i=="bigint")&&bs(e,""+i);break;case"onScroll":i!=null&&Re("scroll",e);break;case"onScrollEnd":i!=null&&Re("scrollend",e);break;case"onClick":i!=null&&(e.onclick=Un);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Cd.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[ze]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof i=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,i,c);break e}a in e?e[a]=i:i===!0?e.setAttribute(a,""):_i(e,a,i)}}}function Dt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Re("error",e),Re("load",e);var i=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var b=a[u];if(b!=null)switch(u){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ke(e,t,u,b,a,null)}}c&&Ke(e,t,"srcSet",a.srcSet,a,null),i&&Ke(e,t,"src",a.src,a,null);return;case"input":Re("invalid",e);var j=u=b=c=null,_=null,Y=null;for(i in a)if(a.hasOwnProperty(i)){var P=a[i];if(P!=null)switch(i){case"name":c=P;break;case"type":b=P;break;case"checked":_=P;break;case"defaultChecked":Y=P;break;case"value":u=P;break;case"defaultValue":j=P;break;case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(o(137,t));break;default:Ke(e,t,i,P,a,null)}}qd(e,u,j,_,Y,b,c,!1);return;case"select":Re("invalid",e),i=b=u=null;for(c in a)if(a.hasOwnProperty(c)&&(j=a[c],j!=null))switch(c){case"value":u=j;break;case"defaultValue":b=j;break;case"multiple":i=j;default:Ke(e,t,c,j,a,null)}t=u,a=b,e.multiple=!!i,t!=null?vs(e,!!i,t,!1):a!=null&&vs(e,!!i,a,!0);return;case"textarea":Re("invalid",e),u=c=i=null;for(b in a)if(a.hasOwnProperty(b)&&(j=a[b],j!=null))switch(b){case"value":i=j;break;case"defaultValue":c=j;break;case"children":u=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(o(91));break;default:Ke(e,t,b,j,a,null)}Dd(e,i,c,u);return;case"option":for(_ in a)if(a.hasOwnProperty(_)&&(i=a[_],i!=null))switch(_){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Ke(e,t,_,i,a,null)}return;case"dialog":Re("beforetoggle",e),Re("toggle",e),Re("cancel",e),Re("close",e);break;case"iframe":case"object":Re("load",e);break;case"video":case"audio":for(i=0;i<Kl.length;i++)Re(Kl[i],e);break;case"image":Re("error",e),Re("load",e);break;case"details":Re("toggle",e);break;case"embed":case"source":case"link":Re("error",e),Re("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Y in a)if(a.hasOwnProperty(Y)&&(i=a[Y],i!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Ke(e,t,Y,i,a,null)}return;default:if(Go(t)){for(P in a)a.hasOwnProperty(P)&&(i=a[P],i!==void 0&&Mu(e,t,P,i,a,void 0));return}}for(j in a)a.hasOwnProperty(j)&&(i=a[j],i!=null&&Ke(e,t,j,i,a,null))}function Lb(e,t,a,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,b=null,j=null,_=null,Y=null,P=null;for(I in a){var te=a[I];if(a.hasOwnProperty(I)&&te!=null)switch(I){case"checked":break;case"value":break;case"defaultValue":_=te;default:i.hasOwnProperty(I)||Ke(e,t,I,null,i,te)}}for(var X in i){var I=i[X];if(te=a[X],i.hasOwnProperty(X)&&(I!=null||te!=null))switch(X){case"type":u=I;break;case"name":c=I;break;case"checked":Y=I;break;case"defaultChecked":P=I;break;case"value":b=I;break;case"defaultValue":j=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:I!==te&&Ke(e,t,X,I,i,te)}}Vo(e,b,j,_,Y,P,u,c);return;case"select":I=b=j=X=null;for(u in a)if(_=a[u],a.hasOwnProperty(u)&&_!=null)switch(u){case"value":break;case"multiple":I=_;default:i.hasOwnProperty(u)||Ke(e,t,u,null,i,_)}for(c in i)if(u=i[c],_=a[c],i.hasOwnProperty(c)&&(u!=null||_!=null))switch(c){case"value":X=u;break;case"defaultValue":j=u;break;case"multiple":b=u;default:u!==_&&Ke(e,t,c,u,i,_)}t=j,a=b,i=I,X!=null?vs(e,!!a,X,!1):!!i!=!!a&&(t!=null?vs(e,!!a,t,!0):vs(e,!!a,a?[]:"",!1));return;case"textarea":I=X=null;for(j in a)if(c=a[j],a.hasOwnProperty(j)&&c!=null&&!i.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:Ke(e,t,j,null,i,c)}for(b in i)if(c=i[b],u=a[b],i.hasOwnProperty(b)&&(c!=null||u!=null))switch(b){case"value":X=c;break;case"defaultValue":I=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Ke(e,t,b,c,i,u)}Td(e,X,I);return;case"option":for(var de in a)if(X=a[de],a.hasOwnProperty(de)&&X!=null&&!i.hasOwnProperty(de))switch(de){case"selected":e.selected=!1;break;default:Ke(e,t,de,null,i,X)}for(_ in i)if(X=i[_],I=a[_],i.hasOwnProperty(_)&&X!==I&&(X!=null||I!=null))switch(_){case"selected":e.selected=X&&typeof X!="function"&&typeof X!="symbol";break;default:Ke(e,t,_,X,i,I)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var je in a)X=a[je],a.hasOwnProperty(je)&&X!=null&&!i.hasOwnProperty(je)&&Ke(e,t,je,null,i,X);for(Y in i)if(X=i[Y],I=a[Y],i.hasOwnProperty(Y)&&X!==I&&(X!=null||I!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(o(137,t));break;default:Ke(e,t,Y,X,i,I)}return;default:if(Go(t)){for(var Ze in a)X=a[Ze],a.hasOwnProperty(Ze)&&X!==void 0&&!i.hasOwnProperty(Ze)&&Mu(e,t,Ze,void 0,i,X);for(P in i)X=i[P],I=a[P],!i.hasOwnProperty(P)||X===I||X===void 0&&I===void 0||Mu(e,t,P,X,i,I);return}}for(var z in a)X=a[z],a.hasOwnProperty(z)&&X!=null&&!i.hasOwnProperty(z)&&Ke(e,t,z,null,i,X);for(te in i)X=i[te],I=a[te],!i.hasOwnProperty(te)||X===I||X==null&&I==null||Ke(e,t,te,X,i,I)}function Op(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function zb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),i=0;i<a.length;i++){var c=a[i],u=c.transferSize,b=c.initiatorType,j=c.duration;if(u&&j&&Op(b)){for(b=0,j=c.responseEnd,i+=1;i<a.length;i++){var _=a[i],Y=_.startTime;if(Y>j)break;var P=_.transferSize,te=_.initiatorType;P&&Op(te)&&(_=_.responseEnd,b+=P*(_<j?1:(j-Y)/(_-Y)))}if(--i,t+=8*(u+b)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Ru=null,qu=null;function Tr(e){return e.nodeType===9?e:e.ownerDocument}function Lp(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 zp(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Tu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Du=null;function Ub(){var e=window.event;return e&&e.type==="popstate"?e===Du?!1:(Du=e,!0):(Du=null,!1)}var Up=typeof setTimeout=="function"?setTimeout:void 0,Hb=typeof clearTimeout=="function"?clearTimeout:void 0,Hp=typeof Promise=="function"?Promise:void 0,Vb=typeof queueMicrotask=="function"?queueMicrotask:typeof Hp<"u"?function(e){return Hp.resolve(null).then(e).catch($b)}:Up;function $b(e){setTimeout(function(){throw e})}function ka(e){return e==="head"}function Vp(e,t){var a=t,i=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(i===0){e.removeChild(c),Is(t);return}i--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")i++;else if(a==="html")Il(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Il(a);for(var u=a.firstChild;u;){var b=u.nextSibling,j=u.nodeName;u[hl]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=b}}else a==="body"&&Il(e.ownerDocument.body);a=c}while(a);Is(t)}function $p(e,t){var a=e;e=0;do{var i=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),i&&i.nodeType===8)if(a=i.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=i}while(a)}function _u(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":_u(a),Uo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Gb(e,t,a,i){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[hl])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=pn(e.nextSibling),e===null)break}return null}function Yb(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=pn(e.nextSibling),e===null))return null;return e}function Gp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=pn(e.nextSibling),e===null))return null;return e}function Bu(e){return e.data==="$?"||e.data==="$~"}function Ou(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Fb(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var i=function(){t(),a.removeEventListener("DOMContentLoaded",i)};a.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function pn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Lu=null;function Yp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return pn(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Fp(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 Xp(e,t,a){switch(t=Tr(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 Il(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Uo(e)}var xn=new Map,Qp=new Set;function Dr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ta=L.d;L.d={f:Xb,r:Qb,D:Kb,C:Zb,L:Ib,m:Jb,X:Wb,S:Pb,M:ey};function Xb(){var e=ta.f(),t=Nr();return e||t}function Qb(e){var t=ps(e);t!==null&&t.tag===5&&t.type==="form"?uh(t):ta.r(e)}var Qs=typeof document>"u"?null:document;function Kp(e,t,a){var i=Qs;if(i&&typeof t=="string"&&t){var c=on(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Qp.has(c)||(Qp.add(c),e={rel:e,crossOrigin:a,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Dt(t,"link",e),Ct(t),i.head.appendChild(t)))}}function Kb(e){ta.D(e),Kp("dns-prefetch",e,null)}function Zb(e,t){ta.C(e,t),Kp("preconnect",e,t)}function Ib(e,t,a){ta.L(e,t,a);var i=Qs;if(i&&e&&t){var c='link[rel="preload"][as="'+on(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+on(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+on(a.imageSizes)+'"]')):c+='[href="'+on(e)+'"]';var u=c;switch(t){case"style":u=Ks(e);break;case"script":u=Zs(e)}xn.has(u)||(e=y({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),xn.set(u,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(Jl(u))||t==="script"&&i.querySelector(Pl(u))||(t=i.createElement("link"),Dt(t,"link",e),Ct(t),i.head.appendChild(t)))}}function Jb(e,t){ta.m(e,t);var a=Qs;if(a&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+on(i)+'"][href="'+on(e)+'"]',u=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Zs(e)}if(!xn.has(u)&&(e=y({rel:"modulepreload",href:e},t),xn.set(u,e),a.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Pl(u)))return}i=a.createElement("link"),Dt(i,"link",e),Ct(i),a.head.appendChild(i)}}}function Pb(e,t,a){ta.S(e,t,a);var i=Qs;if(i&&e){var c=xs(i).hoistableStyles,u=Ks(e);t=t||"default";var b=c.get(u);if(!b){var j={loading:0,preload:null};if(b=i.querySelector(Jl(u)))j.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},a),(a=xn.get(u))&&zu(e,a);var _=b=i.createElement("link");Ct(_),Dt(_,"link",e),_._p=new Promise(function(Y,P){_.onload=Y,_.onerror=P}),_.addEventListener("load",function(){j.loading|=1}),_.addEventListener("error",function(){j.loading|=2}),j.loading|=4,_r(b,t,i)}b={type:"stylesheet",instance:b,count:1,state:j},c.set(u,b)}}}function Wb(e,t){ta.X(e,t);var a=Qs;if(a&&e){var i=xs(a).hoistableScripts,c=Zs(e),u=i.get(c);u||(u=a.querySelector(Pl(c)),u||(e=y({src:e,async:!0},t),(t=xn.get(c))&&Uu(e,t),u=a.createElement("script"),Ct(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},i.set(c,u))}}function ey(e,t){ta.M(e,t);var a=Qs;if(a&&e){var i=xs(a).hoistableScripts,c=Zs(e),u=i.get(c);u||(u=a.querySelector(Pl(c)),u||(e=y({src:e,async:!0,type:"module"},t),(t=xn.get(c))&&Uu(e,t),u=a.createElement("script"),Ct(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},i.set(c,u))}}function Zp(e,t,a,i){var c=(c=oe.current)?Dr(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=Ks(a.href),a=xs(c).hoistableStyles,i=a.get(t),i||(i={type:"style",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Ks(a.href);var u=xs(c).hoistableStyles,b=u.get(e);if(b||(c=c.ownerDocument||c,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,b),(u=c.querySelector(Jl(e)))&&!u._p&&(b.instance=u,b.state.loading=5),xn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},xn.set(e,a),u||ty(c,e,a,b.state))),t&&i===null)throw Error(o(528,""));return b}if(t&&i!==null)throw Error(o(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Zs(a),a=xs(c).hoistableScripts,i=a.get(t),i||(i={type:"script",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ks(e){return'href="'+on(e)+'"'}function Jl(e){return'link[rel="stylesheet"]['+e+"]"}function Ip(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function ty(e,t,a,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Dt(t,"link",a),Ct(t),e.head.appendChild(t))}function Zs(e){return'[src="'+on(e)+'"]'}function Pl(e){return"script[async]"+e}function Jp(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+on(a.href)+'"]');if(i)return t.instance=i,Ct(i),i;var c=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Ct(i),Dt(i,"style",c),_r(i,a.precedence,e),t.instance=i;case"stylesheet":c=Ks(a.href);var u=e.querySelector(Jl(c));if(u)return t.state.loading|=4,t.instance=u,Ct(u),u;i=Ip(a),(c=xn.get(c))&&zu(i,c),u=(e.ownerDocument||e).createElement("link"),Ct(u);var b=u;return b._p=new Promise(function(j,_){b.onload=j,b.onerror=_}),Dt(u,"link",i),t.state.loading|=4,_r(u,a.precedence,e),t.instance=u;case"script":return u=Zs(a.src),(c=e.querySelector(Pl(u)))?(t.instance=c,Ct(c),c):(i=a,(c=xn.get(u))&&(i=y({},a),Uu(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),Ct(c),Dt(c,"link",i),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,_r(i,a.precedence,e));return t.instance}function _r(e,t,a){for(var i=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,u=c,b=0;b<i.length;b++){var j=i[b];if(j.dataset.precedence===t)u=j;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 zu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Uu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Br=null;function Pp(e,t,a){if(Br===null){var i=new Map,c=Br=new Map;c.set(a,i)}else c=Br,i=c.get(a),i||(i=new Map,c.set(a,i));if(i.has(e))return i;for(i.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[hl]||u[ct]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var b=u.getAttribute(t)||"";b=e+b;var j=i.get(b);j?j.push(u):i.set(b,[u])}}return i}function Wp(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ny(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 e0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ay(e,t,a,i){if(a.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Ks(i.href),u=t.querySelector(Jl(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Or.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,Ct(u);return}u=t.ownerDocument||t,i=Ip(i),(c=xn.get(c))&&zu(i,c),u=u.createElement("link"),Ct(u);var b=u;b._p=new Promise(function(j,_){b.onload=j,b.onerror=_}),Dt(u,"link",i),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=Or.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Hu=0;function sy(e,t){return e.stylesheets&&e.count===0&&zr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var i=setTimeout(function(){if(e.stylesheets&&zr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Hu===0&&(Hu=62500*zb());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&zr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Hu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Or(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Lr=null;function zr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Lr=new Map,t.forEach(ly,e),Lr=null,Or.call(e))}function ly(e,t){if(!(t.state.loading&4)){var a=Lr.get(e);if(a)var i=a.get(null);else{a=new Map,Lr.set(e,a);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var b=c[u];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(a.set(b.dataset.precedence,b),i=b)}i&&a.set(null,i)}c=t.instance,b=c.getAttribute("data-precedence"),u=a.get(b)||i,u===i&&a.set(null,c),a.set(b,c),this.count++,i=Or.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Wl={$$typeof:T,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function iy(e,t,a,i,c,u,b,j,_){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=ml(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ml(0),this.hiddenUpdates=ml(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_,this.incompleteTransitions=new Map}function t0(e,t,a,i,c,u,b,j,_,Y,P,te){return e=new iy(e,t,a,b,_,Y,P,te,j),t=1,u===!0&&(t|=24),u=Qt(3,null,null,t),e.current=u,u.stateNode=e,t=bc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:i,isDehydrated:a,cache:t},Ac(u),e}function n0(e){return e?(e=Cs,e):Cs}function a0(e,t,a,i,c,u){c=n0(c),i.context===null?i.context=c:i.pendingContext=c,i=ga(t),i.payload={element:a},u=u===void 0?null:u,u!==null&&(i.callback=u),a=va(e,i,t),a!==null&&(Yt(a,e,t),ql(a,e,t))}function s0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Vu(e,t){s0(e,t),(e=e.alternate)&&s0(e,t)}function l0(e){if(e.tag===13||e.tag===31){var t=$a(e,67108864);t!==null&&Yt(t,e,67108864),Vu(e,67108864)}}function i0(e){if(e.tag===13||e.tag===31){var t=Pt();t=Je(t);var a=$a(e,t);a!==null&&Yt(a,e,t),Vu(e,t)}}var Ur=!0;function ry(e,t,a,i){var c=q.T;q.T=null;var u=L.p;try{L.p=2,$u(e,t,a,i)}finally{L.p=u,q.T=c}}function oy(e,t,a,i){var c=q.T;q.T=null;var u=L.p;try{L.p=8,$u(e,t,a,i)}finally{L.p=u,q.T=c}}function $u(e,t,a,i){if(Ur){var c=Gu(i);if(c===null)ku(e,t,i,Hr,a),o0(e,i);else if(uy(c,e,t,a,i))i.stopPropagation();else if(o0(e,i),t&4&&-1<cy.indexOf(e)){for(;c!==null;){var u=ps(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var b=Ft(u.pendingLanes);if(b!==0){var j=u;for(j.pendingLanes|=2,j.entangledLanes|=2;b;){var _=1<<31-vt(b);j.entanglements[1]|=_,b&=~_}Dn(u),($e&6)===0&&(jr=Oe()+500,Ql(0))}}break;case 31:case 13:j=$a(u,2),j!==null&&Yt(j,u,2),Nr(),Vu(u,2)}if(u=Gu(i),u===null&&ku(e,t,i,Hr,a),u===c)break;c=u}c!==null&&i.stopPropagation()}else ku(e,t,i,null,a)}}function Gu(e){return e=Fo(e),Yu(e)}var Hr=null;function Yu(e){if(Hr=null,e=hs(e),e!==null){var t=d(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(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 Hr=e,null}function r0(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(rt()){case ot:return 2;case gt:return 8;case kt:case fs:return 32;case Lt:return 268435456;default:return 32}default:return 32}}var Fu=!1,Ma=null,Ra=null,qa=null,ei=new Map,ti=new Map,Ta=[],cy="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 o0(e,t){switch(e){case"focusin":case"focusout":Ma=null;break;case"dragenter":case"dragleave":Ra=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":ei.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ti.delete(t.pointerId)}}function ni(e,t,a,i,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:i,nativeEvent:u,targetContainers:[c]},t!==null&&(t=ps(t),t!==null&&l0(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function uy(e,t,a,i,c){switch(t){case"focusin":return Ma=ni(Ma,e,t,a,i,c),!0;case"dragenter":return Ra=ni(Ra,e,t,a,i,c),!0;case"mouseover":return qa=ni(qa,e,t,a,i,c),!0;case"pointerover":var u=c.pointerId;return ei.set(u,ni(ei.get(u)||null,e,t,a,i,c)),!0;case"gotpointercapture":return u=c.pointerId,ti.set(u,ni(ti.get(u)||null,e,t,a,i,c)),!0}return!1}function c0(e){var t=hs(e.target);if(t!==null){var a=d(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,Mt(e.priority,function(){i0(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,Mt(e.priority,function(){i0(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 Vr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Gu(e.nativeEvent);if(a===null){a=e.nativeEvent;var i=new a.constructor(a.type,a);Yo=i,a.target.dispatchEvent(i),Yo=null}else return t=ps(a),t!==null&&l0(t),e.blockedOn=a,!1;t.shift()}return!0}function u0(e,t,a){Vr(e)&&a.delete(t)}function fy(){Fu=!1,Ma!==null&&Vr(Ma)&&(Ma=null),Ra!==null&&Vr(Ra)&&(Ra=null),qa!==null&&Vr(qa)&&(qa=null),ei.forEach(u0),ti.forEach(u0)}function $r(e,t){e.blockedOn===t&&(e.blockedOn=null,Fu||(Fu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,fy)))}var Gr=null;function f0(e){Gr!==e&&(Gr=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Gr===e&&(Gr=null);for(var t=0;t<e.length;t+=3){var a=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Yu(i||a)===null)continue;break}var u=ps(a);u!==null&&(e.splice(t,3),t-=3,Gc(u,{pending:!0,data:c,method:a.method,action:i},i,c))}}))}function Is(e){function t(_){return $r(_,e)}Ma!==null&&$r(Ma,e),Ra!==null&&$r(Ra,e),qa!==null&&$r(qa,e),ei.forEach(t),ti.forEach(t);for(var a=0;a<Ta.length;a++){var i=Ta[a];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Ta.length&&(a=Ta[0],a.blockedOn===null);)c0(a),a.blockedOn===null&&Ta.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(i=0;i<a.length;i+=3){var c=a[i],u=a[i+1],b=c[ze]||null;if(typeof u=="function")b||f0(a);else if(b){var j=null;if(u&&u.hasAttribute("formAction")){if(c=u,b=u[ze]||null)j=b.formAction;else if(Yu(c)!==null)continue}else j=b.action;typeof j=="function"?a[i+1]=j:(a.splice(i,3),i-=3),f0(a)}}}function d0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(b){return c=b})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),i||setTimeout(a,20)}function a(){if(!i&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Xu(e){this._internalRoot=e}Yr.prototype.render=Xu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,i=Pt();a0(a,i,e,t,null,null)},Yr.prototype.unmount=Xu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;a0(e.current,2,null,e,null,null),Nr(),t[ln]=null}};function Yr(e){this._internalRoot=e}Yr.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Ta.length&&t!==0&&t<Ta[a].priority;a++);Ta.splice(a,0,e),a===0&&c0(e)}};var m0=s.version;if(m0!=="19.2.0")throw Error(o(527,m0,"19.2.0"));L.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var dy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Fr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fr.isDisabled&&Fr.supportsFiber)try{yn=Fr.inject(dy),wt=Fr}catch{}}return si.createRoot=function(e,t){if(!f(e))throw Error(o(299));var a=!1,i="",c=yh,u=Sh,b=jh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(b=t.onRecoverableError)),t=t0(e,1,!1,null,null,a,i,null,c,u,b,d0),e[ln]=t.current,Eu(e),new Xu(t)},si.hydrateRoot=function(e,t,a){if(!f(e))throw Error(o(299));var i=!1,c="",u=yh,b=Sh,j=jh,_=null;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(u=a.onUncaughtError),a.onCaughtError!==void 0&&(b=a.onCaughtError),a.onRecoverableError!==void 0&&(j=a.onRecoverableError),a.formState!==void 0&&(_=a.formState)),t=t0(e,1,!0,t,a??null,i,c,_,u,b,j,d0),t.context=n0(null),a=t.current,i=Pt(),i=Je(i),c=ga(i),c.callback=null,va(a,c,i),a=i,t.current.lanes=a,La(t,a),Dn(t),e[ln]=t.current,Eu(e),new Yr(t)},si.version="19.2.0",si}var A0;function Ay(){if(A0)return Zu.exports;A0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Zu.exports=jy(),Zu.exports}var Ny=Ay();var N0="popstate";function wy(n={}){function s(o,f){let{pathname:d,search:h,hash:p}=o.location;return Nf("",{pathname:d,search:h,hash:p},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function l(o,f){return typeof f=="string"?f:gi(f)}return Ey(s,l,null,n)}function lt(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function En(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Cy(){return Math.random().toString(36).substring(2,10)}function w0(n,s){return{usr:n.state,key:n.key,idx:s}}function Nf(n,s,l=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?rl(s):s,state:l,key:s&&s.key||o||Cy()}}function gi({pathname:n="/",search:s="",hash:l=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),l&&l!=="#"&&(n+=l.charAt(0)==="#"?l:"#"+l),n}function rl(n){let s={};if(n){let l=n.indexOf("#");l>=0&&(s.hash=n.substring(l),n=n.substring(0,l));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function Ey(n,s,l,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,p="POP",x=null,g=v();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function v(){return(h.state||{idx:null}).idx}function y(){p="POP";let w=v(),A=w==null?null:w-g;g=w,x&&x({action:p,location:k.location,delta:A})}function S(w,A){p="PUSH";let N=Nf(k.location,w,A);g=v()+1;let T=w0(N,g),M=k.createHref(N);try{h.pushState(T,"",M)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;f.location.assign(M)}d&&x&&x({action:p,location:k.location,delta:1})}function E(w,A){p="REPLACE";let N=Nf(k.location,w,A);g=v();let T=w0(N,g),M=k.createHref(N);h.replaceState(T,"",M),d&&x&&x({action:p,location:k.location,delta:0})}function C(w){return ky(w)}let k={get action(){return p},get location(){return n(f,h)},listen(w){if(x)throw new Error("A history only accepts one active listener");return f.addEventListener(N0,y),x=w,()=>{f.removeEventListener(N0,y),x=null}},createHref(w){return s(f,w)},createURL:C,encodeLocation(w){let A=C(w);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:S,replace:E,go(w){return h.go(w)}};return k}function ky(n,s=!1){let l="http://localhost";typeof window<"u"&&(l=window.location.origin!=="null"?window.location.origin:window.location.href),lt(l,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:gi(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=l+o),new URL(o,l)}function kx(n,s,l="/"){return My(n,s,l,!1)}function My(n,s,l,o){let f=typeof s=="string"?rl(s):s,d=ra(f.pathname||"/",l);if(d==null)return null;let h=Mx(n);Ry(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=Vy(d);p=Uy(h[x],g,o)}return p}function Mx(n,s=[],l=[],o="",f=!1){let d=(h,p,x=f,g)=>{let v={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&x)return;lt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let y=ia([o,v.relativePath]),S=l.concat(v);h.children&&h.children.length>0&&(lt(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Mx(h.children,s,S,y,x)),!(h.path==null&&!h.index)&&s.push({path:y,score:Ly(y,h.index),routesMeta:S})};return n.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))d(h,p);else for(let x of Rx(h.path))d(h,p,!0,x)}),s}function Rx(n){let s=n.split("/");if(s.length===0)return[];let[l,...o]=s,f=l.endsWith("?"),d=l.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=Rx(o.join("/")),p=[];return p.push(...h.map(x=>x===""?d:[d,x].join("/"))),f&&p.push(...h),p.map(x=>n.startsWith("/")&&x===""?"/":x)}function Ry(n){n.sort((s,l)=>s.score!==l.score?l.score-s.score:zy(s.routesMeta.map(o=>o.childrenIndex),l.routesMeta.map(o=>o.childrenIndex)))}var qy=/^:[\w-]+$/,Ty=3,Dy=2,_y=1,By=10,Oy=-2,C0=n=>n==="*";function Ly(n,s){let l=n.split("/"),o=l.length;return l.some(C0)&&(o+=Oy),s&&(o+=Dy),l.filter(f=>!C0(f)).reduce((f,d)=>f+(qy.test(d)?Ty:d===""?_y:By),o)}function zy(n,s){return n.length===s.length&&n.slice(0,-1).every((o,f)=>o===s[f])?n[n.length-1]-s[s.length-1]:0}function Uy(n,s,l=!1){let{routesMeta:o}=n,f={},d="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,v=d==="/"?s:s.slice(d.length)||"/",y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},v),S=x.route;if(!y&&g&&l&&!o[o.length-1].route.index&&(y=ho({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!y)return null;Object.assign(f,y.params),h.push({params:f,pathname:ia([d,y.pathname]),pathnameBase:Xy(ia([d,y.pathnameBase])),route:S}),y.pathnameBase!=="/"&&(d=ia([d,y.pathnameBase]))}return h}function ho(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[l,o]=Hy(n.path,n.caseSensitive,n.end),f=s.match(l);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),p=f.slice(1);return{params:o.reduce((g,{paramName:v,isOptional:y},S)=>{if(v==="*"){let C=p[S]||"";h=d.slice(0,d.length-C.length).replace(/(.)\/+$/,"$1")}const E=p[S];return y&&!E?g[v]=void 0:g[v]=(E||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:n}}function Hy(n,s=!1,l=!0){En(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,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),f+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):l?f+="\\/*$":n!==""&&n!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,s?void 0:"i"),o]}function Vy(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return En(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function ra(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let l=s.endsWith("/")?s.length-1:s.length,o=n.charAt(l);return o&&o!=="/"?null:n.slice(l)||"/"}var $y=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gy=n=>$y.test(n);function Yy(n,s="/"){let{pathname:l,search:o="",hash:f=""}=typeof n=="string"?rl(n):n,d;if(l)if(Gy(l))d=l;else{if(l.includes("//")){let h=l;l=l.replace(/\/\/+/g,"/"),En(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${l}`)}l.startsWith("/")?d=E0(l.substring(1),"/"):d=E0(l,s)}else d=s;return{pathname:d,search:Qy(o),hash:Ky(f)}}function E0(n,s){let l=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(f=>{f===".."?l.length>1&&l.pop():f!=="."&&l.push(f)}),l.length>1?l.join("/"):"/"}function Wu(n,s,l,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${l}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Fy(n){return n.filter((s,l)=>l===0||s.route.path&&s.route.path.length>0)}function qx(n){let s=Fy(n);return s.map((l,o)=>o===s.length-1?l.pathname:l.pathnameBase)}function Tx(n,s,l,o=!1){let f;typeof n=="string"?f=rl(n):(f={...n},lt(!f.pathname||!f.pathname.includes("?"),Wu("?","pathname","search",f)),lt(!f.pathname||!f.pathname.includes("#"),Wu("#","pathname","hash",f)),lt(!f.search||!f.search.includes("#"),Wu("#","search","hash",f)));let d=n===""||f.pathname==="",h=d?"/":f.pathname,p;if(h==null)p=l;else{let y=s.length-1;if(!o&&h.startsWith("..")){let S=h.split("/");for(;S[0]==="..";)S.shift(),y-=1;f.pathname=S.join("/")}p=y>=0?s[y]:"/"}let x=Yy(f,p),g=h&&h!=="/"&&h.endsWith("/"),v=(d||h===".")&&l.endsWith("/");return!x.pathname.endsWith("/")&&(g||v)&&(x.pathname+="/"),x}var ia=n=>n.join("/").replace(/\/\/+/g,"/"),Xy=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Qy=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Ky=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Zy(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 Dx=["POST","PUT","PATCH","DELETE"];new Set(Dx);var Iy=["GET",...Dx];new Set(Iy);var ol=m.createContext(null);ol.displayName="DataRouter";var wo=m.createContext(null);wo.displayName="DataRouterState";m.createContext(!1);var _x=m.createContext({isTransitioning:!1});_x.displayName="ViewTransition";var Jy=m.createContext(new Map);Jy.displayName="Fetchers";var Py=m.createContext(null);Py.displayName="Await";var Ln=m.createContext(null);Ln.displayName="Navigation";var Ci=m.createContext(null);Ci.displayName="Location";var ca=m.createContext({outlet:null,matches:[],isDataRoute:!1});ca.displayName="Route";var Gf=m.createContext(null);Gf.displayName="RouteError";function Wy(n,{relative:s}={}){lt(Ei(),"useHref() may be used only in the context of a <Router> component.");let{basename:l,navigator:o}=m.useContext(Ln),{hash:f,pathname:d,search:h}=ki(n,{relative:s}),p=d;return l!=="/"&&(p=d==="/"?l:ia([l,d])),o.createHref({pathname:p,search:h,hash:f})}function Ei(){return m.useContext(Ci)!=null}function us(){return lt(Ei(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ci).location}var Bx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ox(n){m.useContext(Ln).static||m.useLayoutEffect(n)}function e1(){let{isDataRoute:n}=m.useContext(ca);return n?m1():t1()}function t1(){lt(Ei(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(ol),{basename:s,navigator:l}=m.useContext(Ln),{matches:o}=m.useContext(ca),{pathname:f}=us(),d=JSON.stringify(qx(o)),h=m.useRef(!1);return Ox(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(En(h.current,Bx),!h.current)return;if(typeof x=="number"){l.go(x);return}let v=Tx(x,JSON.parse(d),f,g.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:ia([s,v.pathname])),(g.replace?l.replace:l.push)(v,g.state,g)},[s,l,d,f,n])}m.createContext(null);function ki(n,{relative:s}={}){let{matches:l}=m.useContext(ca),{pathname:o}=us(),f=JSON.stringify(qx(l));return m.useMemo(()=>Tx(n,JSON.parse(f),o,s==="path"),[n,f,o,s])}function n1(n,s){return Lx(n,s)}function Lx(n,s,l,o,f){lt(Ei(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(Ln),{matches:h}=m.useContext(ca),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",v=p?p.pathnameBase:"/",y=p&&p.route;{let N=y&&y.path||"";zx(g,!y||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${N}">) 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="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let S=us(),E;if(s){let N=typeof s=="string"?rl(s):s;lt(v==="/"||N.pathname?.startsWith(v),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${v}" but pathname "${N.pathname}" was given in the \`location\` prop.`),E=N}else E=S;let C=E.pathname||"/",k=C;if(v!=="/"){let N=v.replace(/^\//,"").split("/");k="/"+C.replace(/^\//,"").split("/").slice(N.length).join("/")}let w=kx(n,{pathname:k});En(y||w!=null,`No routes matched location "${E.pathname}${E.search}${E.hash}" `),En(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${E.pathname}${E.search}${E.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 A=r1(w&&w.map(N=>Object.assign({},N,{params:Object.assign({},x,N.params),pathname:ia([v,d.encodeLocation?d.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?v:ia([v,d.encodeLocation?d.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),h,l,o,f);return s&&A?m.createElement(Ci.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...E},navigationType:"POP"}},A):A}function a1(){let n=d1(),s=Zy(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),l=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},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),l?m.createElement("pre",{style:f},l):null,h)}var s1=m.createElement(a1,null),l1=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(ca.Provider,{value:this.props.routeContext},m.createElement(Gf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function i1({routeContext:n,match:s,children:l}){let o=m.useContext(ol);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(ca.Provider,{value:n},l)}function r1(n,s=[],l=null,o=null,f=null){if(n==null){if(!l)return null;if(l.errors)n=l.matches;else if(s.length===0&&!l.initialized&&l.matches.length>0)n=l.matches;else return null}let d=n,h=l?.errors;if(h!=null){let v=d.findIndex(y=>y.route.id&&h?.[y.route.id]!==void 0);lt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,v+1))}let p=!1,x=-1;if(l)for(let v=0;v<d.length;v++){let y=d[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(x=v),y.route.id){let{loaderData:S,errors:E}=l,C=y.route.loader&&!S.hasOwnProperty(y.route.id)&&(!E||E[y.route.id]===void 0);if(y.route.lazy||C){p=!0,x>=0?d=d.slice(0,x+1):d=[d[0]];break}}}let g=l&&o?(v,y)=>{o(v,{location:l.location,params:l.matches?.[0]?.params??{},errorInfo:y})}:void 0;return d.reduceRight((v,y,S)=>{let E,C=!1,k=null,w=null;l&&(E=h&&y.route.id?h[y.route.id]:void 0,k=y.route.errorElement||s1,p&&(x<0&&S===0?(zx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,w=null):x===S&&(C=!0,w=y.route.hydrateFallbackElement||null)));let A=s.concat(d.slice(0,S+1)),N=()=>{let T;return E?T=k:C?T=w:y.route.Component?T=m.createElement(y.route.Component,null):y.route.element?T=y.route.element:T=v,m.createElement(i1,{match:y,routeContext:{outlet:v,matches:A,isDataRoute:l!=null},children:T})};return l&&(y.route.ErrorBoundary||y.route.errorElement||S===0)?m.createElement(l1,{location:l.location,revalidation:l.revalidation,component:k,error:E,children:N(),routeContext:{outlet:null,matches:A,isDataRoute:!0},onError:g}):N()},null)}function Yf(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function o1(n){let s=m.useContext(ol);return lt(s,Yf(n)),s}function c1(n){let s=m.useContext(wo);return lt(s,Yf(n)),s}function u1(n){let s=m.useContext(ca);return lt(s,Yf(n)),s}function Ff(n){let s=u1(n),l=s.matches[s.matches.length-1];return lt(l.route.id,`${n} can only be used on routes that contain a unique "id"`),l.route.id}function f1(){return Ff("useRouteId")}function d1(){let n=m.useContext(Gf),s=c1("useRouteError"),l=Ff("useRouteError");return n!==void 0?n:s.errors?.[l]}function m1(){let{router:n}=o1("useNavigate"),s=Ff("useNavigate"),l=m.useRef(!1);return Ox(()=>{l.current=!0}),m.useCallback(async(f,d={})=>{En(l.current,Bx),l.current&&(typeof f=="number"?n.navigate(f):await n.navigate(f,{fromRouteId:s,...d}))},[n,s])}var k0={};function zx(n,s,l){!s&&!k0[n]&&(k0[n]=!0,En(!1,l))}m.memo(h1);function h1({routes:n,future:s,state:l,unstable_onError:o}){return Lx(n,void 0,l,o,s)}function no(n){lt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function p1({basename:n="/",children:s=null,location:l,navigationType:o="POP",navigator:f,static:d=!1}){lt(!Ei(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof l=="string"&&(l=rl(l));let{pathname:x="/",search:g="",hash:v="",state:y=null,key:S="default"}=l,E=m.useMemo(()=>{let C=ra(x,h);return C==null?null:{location:{pathname:C,search:g,hash:v,state:y,key:S},navigationType:o}},[h,x,g,v,y,S,o]);return En(E!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(Ln.Provider,{value:p},m.createElement(Ci.Provider,{children:s,value:E}))}function x1({children:n,location:s}){return n1(wf(n),s)}function wf(n,s=[]){let l=[];return m.Children.forEach(n,(o,f)=>{if(!m.isValidElement(o))return;let d=[...s,f];if(o.type===m.Fragment){l.push.apply(l,wf(o.props.children,d));return}lt(o.type===no,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),lt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=wf(o.props.children,d)),l.push(h)}),l}var ao="get",so="application/x-www-form-urlencoded";function Co(n){return n!=null&&typeof n.tagName=="string"}function g1(n){return Co(n)&&n.tagName.toLowerCase()==="button"}function v1(n){return Co(n)&&n.tagName.toLowerCase()==="form"}function b1(n){return Co(n)&&n.tagName.toLowerCase()==="input"}function y1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function S1(n,s){return n.button===0&&(!s||s==="_self")&&!y1(n)}var Xr=null;function j1(){if(Xr===null)try{new FormData(document.createElement("form"),0),Xr=!1}catch{Xr=!0}return Xr}var A1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ef(n){return n!=null&&!A1.has(n)?(En(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${so}"`),null):n}function N1(n,s){let l,o,f,d,h;if(v1(n)){let p=n.getAttribute("action");o=p?ra(p,s):null,l=n.getAttribute("method")||ao,f=ef(n.getAttribute("enctype"))||so,d=new FormData(n)}else if(g1(n)||b1(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=n.getAttribute("formaction")||p.getAttribute("action");if(o=x?ra(x,s):null,l=n.getAttribute("formmethod")||p.getAttribute("method")||ao,f=ef(n.getAttribute("formenctype"))||ef(p.getAttribute("enctype"))||so,d=new FormData(p,n),!j1()){let{name:g,type:v,value:y}=n;if(v==="image"){let S=g?`${g}.`:"";d.append(`${S}x`,"0"),d.append(`${S}y`,"0")}else g&&d.append(g,y)}}else{if(Co(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');l=ao,o=null,f=so,h=n}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:l.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Xf(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function w1(n,s,l){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${l}`:s&&ra(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${l}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${l}`,o}async function C1(n,s){if(n.id in s)return s[n.id];try{let l=await import(n.module);return s[n.id]=l,l}catch(l){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(l),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function E1(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 k1(n,s,l){let o=await Promise.all(n.map(async f=>{let d=s.routes[f.route.id];if(d){let h=await C1(d,l);return h.links?h.links():[]}return[]}));return T1(o.flat(1).filter(E1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function M0(n,s,l,o,f,d){let h=(x,g)=>l[g]?x.route.id!==l[g].route.id:!0,p=(x,g)=>l[g].pathname!==x.pathname||l[g].route.path?.endsWith("*")&&l[g].params["*"]!==x.params["*"];return d==="assets"?s.filter((x,g)=>h(x,g)||p(x,g)):d==="data"?s.filter((x,g)=>{let v=o.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let y=x.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:l[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function M1(n,s,{includeHydrateFallback:l}={}){return R1(n.map(o=>{let f=s.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)),l&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function R1(n){return[...new Set(n)]}function q1(n){let s={},l=Object.keys(n).sort();for(let o of l)s[o]=n[o];return s}function T1(n,s){let l=new Set;return new Set(s),n.reduce((o,f)=>{let d=JSON.stringify(q1(f));return l.has(d)||(l.add(d),o.push({key:d,link:f})),o},[])}function Ux(){let n=m.useContext(ol);return Xf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function D1(){let n=m.useContext(wo);return Xf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Qf=m.createContext(void 0);Qf.displayName="FrameworkContext";function Hx(){let n=m.useContext(Qf);return Xf(n,"You must render this element inside a <HydratedRouter> element"),n}function _1(n,s){let l=m.useContext(Qf),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:v,onTouchStart:y}=s,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let k=A=>{A.forEach(N=>{h(N.isIntersecting)})},w=new IntersectionObserver(k,{threshold:.5});return S.current&&w.observe(S.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let k=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(k)}}},[o]);let E=()=>{f(!0)},C=()=>{f(!1),h(!1)};return l?n!=="intent"?[d,S,{}]:[d,S,{onFocus:li(p,E),onBlur:li(x,C),onMouseEnter:li(g,E),onMouseLeave:li(v,C),onTouchStart:li(y,E)}]:[!1,S,{}]}function li(n,s){return l=>{n&&n(l),l.defaultPrevented||s(l)}}function B1({page:n,...s}){let{router:l}=Ux(),o=m.useMemo(()=>kx(l.routes,n,l.basename),[l.routes,n,l.basename]);return o?m.createElement(L1,{page:n,matches:o,...s}):null}function O1(n){let{manifest:s,routeModules:l}=Hx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return k1(n,s,l).then(h=>{d||f(h)}),()=>{d=!0}},[n,s,l]),o}function L1({page:n,matches:s,...l}){let o=us(),{manifest:f,routeModules:d}=Hx(),{basename:h}=Ux(),{loaderData:p,matches:x}=D1(),g=m.useMemo(()=>M0(n,s,x,f,o,"data"),[n,s,x,f,o]),v=m.useMemo(()=>M0(n,s,x,f,o,"assets"),[n,s,x,f,o]),y=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let C=new Set,k=!1;if(s.forEach(A=>{let N=f.routes[A.route.id];!N||!N.hasLoader||(!g.some(T=>T.route.id===A.route.id)&&A.route.id in p&&d[A.route.id]?.shouldRevalidate||N.hasClientLoader?k=!0:C.add(A.route.id))}),C.size===0)return[];let w=w1(n,h,"data");return k&&C.size>0&&w.searchParams.set("_routes",s.filter(A=>C.has(A.route.id)).map(A=>A.route.id).join(",")),[w.pathname+w.search]},[h,p,o,f,g,s,n,d]),S=m.useMemo(()=>M1(v,f),[v,f]),E=O1(v);return m.createElement(m.Fragment,null,y.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...l})),S.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...l})),E.map(({key:C,link:k})=>m.createElement("link",{key:C,nonce:l.nonce,...k})))}function z1(...n){return s=>{n.forEach(l=>{typeof l=="function"?l(s):l!=null&&(l.current=s)})}}var Vx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Vx&&(window.__reactRouterVersion="7.9.6")}catch{}function U1({basename:n,children:s,window:l}){let o=m.useRef();o.current==null&&(o.current=wy({window:l,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>f.listen(p),[f,p]),m.createElement(p1,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:f})}var $x=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gx=m.forwardRef(function({onClick:s,discover:l="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:p,target:x,to:g,preventScrollReset:v,viewTransition:y,...S},E){let{basename:C}=m.useContext(Ln),k=typeof g=="string"&&$x.test(g),w,A=!1;if(typeof g=="string"&&k&&(w=g,Vx))try{let Q=new URL(window.location.href),$=g.startsWith("//")?new URL(Q.protocol+g):new URL(g),F=ra($.pathname,C);$.origin===Q.origin&&F!=null?g=F+$.search+$.hash:A=!0}catch{En(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let N=Wy(g,{relative:f}),[T,M,O]=_1(o,S),K=G1(g,{replace:h,state:p,target:x,preventScrollReset:v,relative:f,viewTransition:y});function D(Q){s&&s(Q),Q.defaultPrevented||K(Q)}let U=m.createElement("a",{...S,...O,href:w||N,onClick:A||d?s:D,ref:z1(E,M),target:x,"data-discover":!k&&l==="render"?"true":void 0});return T&&!k?m.createElement(m.Fragment,null,U,m.createElement(B1,{page:N})):U});Gx.displayName="Link";var H1=m.forwardRef(function({"aria-current":s="page",caseSensitive:l=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:p,children:x,...g},v){let y=ki(h,{relative:g.relative}),S=us(),E=m.useContext(wo),{navigator:C,basename:k}=m.useContext(Ln),w=E!=null&&K1(y)&&p===!0,A=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,N=S.pathname,T=E&&E.navigation&&E.navigation.location?E.navigation.location.pathname:null;l||(N=N.toLowerCase(),T=T?T.toLowerCase():null,A=A.toLowerCase()),T&&k&&(T=ra(T,k)||T);const M=A!=="/"&&A.endsWith("/")?A.length-1:A.length;let O=N===A||!f&&N.startsWith(A)&&N.charAt(M)==="/",K=T!=null&&(T===A||!f&&T.startsWith(A)&&T.charAt(A.length)==="/"),D={isActive:O,isPending:K,isTransitioning:w},U=O?s:void 0,Q;typeof o=="function"?Q=o(D):Q=[o,O?"active":null,K?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let $=typeof d=="function"?d(D):d;return m.createElement(Gx,{...g,"aria-current":U,className:Q,ref:v,style:$,to:h,viewTransition:p},typeof x=="function"?x(D):x)});H1.displayName="NavLink";var V1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:l,reloadDocument:o,replace:f,state:d,method:h=ao,action:p,onSubmit:x,relative:g,preventScrollReset:v,viewTransition:y,...S},E)=>{let C=X1(),k=Q1(p,{relative:g}),w=h.toLowerCase()==="get"?"get":"post",A=typeof p=="string"&&$x.test(p),N=T=>{if(x&&x(T),T.defaultPrevented)return;T.preventDefault();let M=T.nativeEvent.submitter,O=M?.getAttribute("formmethod")||h;C(M||T.currentTarget,{fetcherKey:s,method:O,navigate:l,replace:f,state:d,relative:g,preventScrollReset:v,viewTransition:y})};return m.createElement("form",{ref:E,method:w,action:k,onSubmit:o?x:N,...S,"data-discover":!A&&n==="render"?"true":void 0})});V1.displayName="Form";function $1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yx(n){let s=m.useContext(ol);return lt(s,$1(n)),s}function G1(n,{target:s,replace:l,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let p=e1(),x=us(),g=ki(n,{relative:d});return m.useCallback(v=>{if(S1(v,s)){v.preventDefault();let y=l!==void 0?l:gi(x)===gi(g);p(n,{replace:y,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[x,p,g,l,o,s,n,f,d,h])}var Y1=0,F1=()=>`__${String(++Y1)}__`;function X1(){let{router:n}=Yx("useSubmit"),{basename:s}=m.useContext(Ln),l=f1();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:p,formData:x,body:g}=N1(o,s);if(f.navigate===!1){let v=f.fetcherKey||F1();await n.fetch(v,l,f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,flushSync:f.flushSync})}else await n.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:l,flushSync:f.flushSync,viewTransition:f.viewTransition})},[n,s,l])}function Q1(n,{relative:s}={}){let{basename:l}=m.useContext(Ln),o=m.useContext(ca);lt(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...ki(n||".",{relative:s})},h=us();if(n==null){d.search=h.search;let p=new URLSearchParams(d.search),x=p.getAll("index");if(x.some(v=>v==="")){p.delete("index"),x.filter(y=>y).forEach(y=>p.append("index",y));let v=p.toString();d.search=v?`?${v}`:""}}return(!n||n===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),l!=="/"&&(d.pathname=d.pathname==="/"?l:ia([l,d.pathname])),gi(d)}function K1(n,{relative:s}={}){let l=m.useContext(_x);lt(l!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Yx("useViewTransitionState"),f=ki(n,{relative:s});if(!l.isTransitioning)return!1;let d=ra(l.currentLocation.pathname,o)||l.currentLocation.pathname,h=ra(l.nextLocation.pathname,o)||l.nextLocation.pathname;return ho(f.pathname,h)!=null||ho(f.pathname,d)!=null}const On=Object.create(null);On.open="0";On.close="1";On.ping="2";On.pong="3";On.message="4";On.upgrade="5";On.noop="6";const lo=Object.create(null);Object.keys(On).forEach(n=>{lo[On[n]]=n});const Cf={type:"error",data:"parser error"},Fx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Xx=typeof ArrayBuffer=="function",Qx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Kf=({type:n,data:s},l,o)=>Fx&&s instanceof Blob?l?o(s):R0(s,o):Xx&&(s instanceof ArrayBuffer||Qx(s))?l?o(s):R0(new Blob([s]),o):o(On[n]+(s||"")),R0=(n,s)=>{const l=new FileReader;return l.onload=function(){const o=l.result.split(",")[1];s("b"+(o||""))},l.readAsDataURL(n)};function q0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let tf;function Z1(n,s){if(Fx&&n.data instanceof Blob)return n.data.arrayBuffer().then(q0).then(s);if(Xx&&(n.data instanceof ArrayBuffer||Qx(n.data)))return s(q0(n.data));Kf(n,!1,l=>{tf||(tf=new TextEncoder),s(tf.encode(l))})}const T0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<T0.length;n++)fi[T0.charCodeAt(n)]=n;const I1=n=>{let s=n.length*.75,l=n.length,o,f=0,d,h,p,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),v=new Uint8Array(g);for(o=0;o<l;o+=4)d=fi[n.charCodeAt(o)],h=fi[n.charCodeAt(o+1)],p=fi[n.charCodeAt(o+2)],x=fi[n.charCodeAt(o+3)],v[f++]=d<<2|h>>4,v[f++]=(h&15)<<4|p>>2,v[f++]=(p&3)<<6|x&63;return g},J1=typeof ArrayBuffer=="function",Zf=(n,s)=>{if(typeof n!="string")return{type:"message",data:Kx(n,s)};const l=n.charAt(0);return l==="b"?{type:"message",data:P1(n.substring(1),s)}:lo[l]?n.length>1?{type:lo[l],data:n.substring(1)}:{type:lo[l]}:Cf},P1=(n,s)=>{if(J1){const l=I1(n);return Kx(l,s)}else return{base64:!0,data:n}},Kx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Zx="",W1=(n,s)=>{const l=n.length,o=new Array(l);let f=0;n.forEach((d,h)=>{Kf(d,!1,p=>{o[h]=p,++f===l&&s(o.join(Zx))})})},eS=(n,s)=>{const l=n.split(Zx),o=[];for(let f=0;f<l.length;f++){const d=Zf(l[f],s);if(o.push(d),d.type==="error")break}return o};function tS(){return new TransformStream({transform(n,s){Z1(n,l=>{const o=l.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),s.enqueue(f),s.enqueue(l)})}})}let nf;function Qr(n){return n.reduce((s,l)=>s+l.length,0)}function Kr(n,s){if(n[0].length===s)return n.shift();const l=new Uint8Array(s);let o=0;for(let f=0;f<s;f++)l[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)),l}function nS(n,s){nf||(nf=new TextDecoder);const l=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,p){for(l.push(h);;){if(o===0){if(Qr(l)<1)break;const x=Kr(l,1);d=(x[0]&128)===128,f=x[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if(Qr(l)<2)break;const x=Kr(l,2);f=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Qr(l)<8)break;const x=Kr(l,8),g=new DataView(x.buffer,x.byteOffset,x.length),v=g.getUint32(0);if(v>Math.pow(2,21)-1){p.enqueue(Cf);break}f=v*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Qr(l)<f)break;const x=Kr(l,f);p.enqueue(Zf(d?x:nf.decode(x),s)),o=0}if(f===0||f>n){p.enqueue(Cf);break}}}})}const Ix=4;function At(n){if(n)return aS(n)}function aS(n){for(var s in At.prototype)n[s]=At.prototype[s];return n}At.prototype.on=At.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};At.prototype.once=function(n,s){function l(){this.off(n,l),s.apply(this,arguments)}return l.fn=s,this.on(n,l),this};At.prototype.off=At.prototype.removeListener=At.prototype.removeAllListeners=At.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var l=this._callbacks["$"+n];if(!l)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,f=0;f<l.length;f++)if(o=l[f],o===s||o.fn===s){l.splice(f,1);break}return l.length===0&&delete this._callbacks["$"+n],this};At.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),l=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(l){l=l.slice(0);for(var o=0,f=l.length;o<f;++o)l[o].apply(this,s)}return this};At.prototype.emitReserved=At.prototype.emit;At.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};At.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Eo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,l)=>l(s,0),bn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),sS="arraybuffer";function Jx(n,...s){return s.reduce((l,o)=>(n.hasOwnProperty(o)&&(l[o]=n[o]),l),{})}const lS=bn.setTimeout,iS=bn.clearTimeout;function ko(n,s){s.useNativeTimers?(n.setTimeoutFn=lS.bind(bn),n.clearTimeoutFn=iS.bind(bn)):(n.setTimeoutFn=bn.setTimeout.bind(bn),n.clearTimeoutFn=bn.clearTimeout.bind(bn))}const rS=1.33;function oS(n){return typeof n=="string"?cS(n):Math.ceil((n.byteLength||n.size)*rS)}function cS(n){let s=0,l=0;for(let o=0,f=n.length;o<f;o++)s=n.charCodeAt(o),s<128?l+=1:s<2048?l+=2:s<55296||s>=57344?l+=3:(o++,l+=4);return l}function Px(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function uS(n){let s="";for(let l in n)n.hasOwnProperty(l)&&(s.length&&(s+="&"),s+=encodeURIComponent(l)+"="+encodeURIComponent(n[l]));return s}function fS(n){let s={},l=n.split("&");for(let o=0,f=l.length;o<f;o++){let d=l[o].split("=");s[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return s}class dS extends Error{constructor(s,l,o){super(s),this.description=l,this.context=o,this.type="TransportError"}}class If extends At{constructor(s){super(),this.writable=!1,ko(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,l,o){return super.emitReserved("error",new dS(s,l,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const l=Zf(s,this.socket.binaryType);this.onPacket(l)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,l={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(l)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const l=uS(s);return l.length?"?"+l:""}}class mS extends If{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const l=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||l()})),this.writable||(o++,this.once("drain",function(){--o||l()}))}else l()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const l=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)};eS(s,this.socket.binaryType).forEach(l),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,W1(s,l=>{this.doWrite(l,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",l=this.query||{};return this.opts.timestampRequests!==!1&&(l[this.opts.timestampParam]=Px()),!this.supportsBinary&&!l.sid&&(l.b64=1),this.createUri(s,l)}}let Wx=!1;try{Wx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const hS=Wx;function pS(){}class xS extends mS{constructor(s){if(super(s),typeof location<"u"){const l=location.protocol==="https:";let o=location.port;o||(o=l?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,l){const o=this.request({method:"POST",data:s});o.on("success",l),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(l,o)=>{this.onError("xhr poll error",l,o)}),this.pollXhr=s}}class Bn extends At{constructor(s,l,o){super(),this.createRequest=s,ko(this,o),this._opts=o,this._method=o.method||"GET",this._uri=l,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const l=Jx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");l.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(l);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{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var 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=Bn.requestsCount++,Bn.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pS,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Bn.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Bn.requestsCount=0;Bn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",D0);else if(typeof addEventListener=="function"){const n="onpagehide"in bn?"pagehide":"unload";addEventListener(n,D0,!1)}}function D0(){for(let n in Bn.requests)Bn.requests.hasOwnProperty(n)&&Bn.requests[n].abort()}const gS=(function(){const n=eg({xdomain:!1});return n&&n.responseType!==null})();class vS extends xS{constructor(s){super(s);const l=s&&s.forceBase64;this.supportsBinary=gS&&!l}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Bn(eg,this.uri(),s)}}function eg(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||hS))return new XMLHttpRequest}catch{}if(!s)try{return new bn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const tg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class bS extends If{get name(){return"websocket"}doOpen(){const s=this.uri(),l=this.opts.protocols,o=tg?{}:Jx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,l,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=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let l=0;l<s.length;l++){const o=s[l],f=l===s.length-1;Kf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&Eo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const s=this.opts.secure?"wss":"ws",l=this.query||{};return this.opts.timestampRequests&&(l[this.opts.timestampParam]=Px()),this.supportsBinary||(l.b64=1),this.createUri(s,l)}}const af=bn.WebSocket||bn.MozWebSocket;class yS extends bS{createSocket(s,l,o){return tg?new af(s,l,o):l?new af(s,l):new af(s)}doWrite(s,l){this.ws.send(l)}}class SS extends If{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const l=nS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(l).getReader(),f=tS();f.readable.pipeTo(s.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),d())}).catch(p=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let l=0;l<s.length;l++){const o=s[l],f=l===s.length-1;this._writer.write(o).then(()=>{f&&Eo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const jS={websocket:yS,webtransport:SS,polling:vS},AS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,NS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ef(n){if(n.length>8e3)throw"URI too long";const s=n,l=n.indexOf("["),o=n.indexOf("]");l!=-1&&o!=-1&&(n=n.substring(0,l)+n.substring(l,o).replace(/:/g,";")+n.substring(o,n.length));let f=AS.exec(n||""),d={},h=14;for(;h--;)d[NS[h]]=f[h]||"";return l!=-1&&o!=-1&&(d.source=s,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=wS(d,d.path),d.queryKey=CS(d,d.query),d}function wS(n,s){const l=/\/{2,9}/g,o=s.replace(l,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function CS(n,s){const l={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(l[f]=d)}),l}const kf=typeof addEventListener=="function"&&typeof removeEventListener=="function",io=[];kf&&addEventListener("offline",()=>{io.forEach(n=>n())},!1);class Ba extends At{constructor(s,l){if(super(),this.binaryType=sS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(l=s,s=null),s){const o=Ef(s);l.hostname=o.host,l.secure=o.protocol==="https"||o.protocol==="wss",l.port=o.port,o.query&&(l.query=o.query)}else l.host&&(l.hostname=Ef(l.host).host);ko(this,l),this.secure=l.secure!=null?l.secure:typeof location<"u"&&location.protocol==="https:",l.hostname&&!l.port&&(l.port=this.secure?"443":"80"),this.hostname=l.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=l.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},l.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},l),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=fS(this.opts.query)),kf&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},io.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const l=Object.assign({},this.opts.query);l.EIO=Ix,l.transport=s,this.id&&(l.sid=this.id);const o=Object.assign({},this.opts,{query:l,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&Ba.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const l=this.createTransport(s);l.open(),this.setTransport(l)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",l=>this._onClose("transport close",l))}onOpen(){this.readyState="open",Ba.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const l=new Error("server error");l.code=s.data,this._onError(l);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let l=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(l+=oS(f)),o>0&&l>this._maxPayload)return this.writeBuffer.slice(0,o);l+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,Eo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,l,o){return this._sendPacket("message",s,l,o),this}send(s,l,o){return this._sendPacket("message",s,l,o),this}_sendPacket(s,l,o,f){if(typeof l=="function"&&(f=l,l=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:s,data:l,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},l=()=>{this.off("upgrade",l),this.off("upgradeError",l),s()},o=()=>{this.once("upgrade",l),this.once("upgradeError",l)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():s()}):this.upgrading?o():s()),this}_onError(s){if(Ba.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,l){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(),kf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=io.indexOf(this._offlineEventListener);o!==-1&&io.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,l),this.writeBuffer=[],this._prevBufferLen=0}}}Ba.protocol=Ix;class ES extends Ba{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let l=this.createTransport(s),o=!1;Ba.priorWebsocketSuccess=!1;const f=()=>{o||(l.send([{type:"ping",data:"probe"}]),l.once("packet",y=>{if(!o)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",l),!l)return;Ba.priorWebsocketSuccess=l.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(l),l.send([{type:"upgrade"}]),this.emitReserved("upgrade",l),l=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=l.name,this.emitReserved("upgradeError",S)}}))};function d(){o||(o=!0,v(),l.close(),l=null)}const h=y=>{const S=new Error("probe error: "+y);S.transport=l.name,d(),this.emitReserved("upgradeError",S)};function p(){h("transport closed")}function x(){h("socket closed")}function g(y){l&&y.name!==l.name&&d()}const v=()=>{l.removeListener("open",f),l.removeListener("error",h),l.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};l.once("open",f),l.once("error",h),l.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||l.open()},200):l.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const l=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&l.push(s[o]);return l}}let kS=class extends ES{constructor(s,l={}){const o=typeof s=="object"?s:l;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>jS[f]).filter(f=>!!f)),super(s,o)}};function MS(n,s="",l){let o=n;l=l||typeof location<"u"&&location,n==null&&(n=l.protocol+"//"+l.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=l.protocol+n:n=l.host+n),/^(https?|wss?):\/\//.test(n)||(typeof l<"u"?n=l.protocol+"//"+n:n="https://"+n),o=Ef(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+s,o.href=o.protocol+"://"+d+(l&&l.port===o.port?"":":"+o.port),o}const RS=typeof ArrayBuffer=="function",qS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ng=Object.prototype.toString,TS=typeof Blob=="function"||typeof Blob<"u"&&ng.call(Blob)==="[object BlobConstructor]",DS=typeof File=="function"||typeof File<"u"&&ng.call(File)==="[object FileConstructor]";function Jf(n){return RS&&(n instanceof ArrayBuffer||qS(n))||TS&&n instanceof Blob||DS&&n instanceof File}function ro(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let l=0,o=n.length;l<o;l++)if(ro(n[l]))return!0;return!1}if(Jf(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ro(n.toJSON(),!0);for(const l in n)if(Object.prototype.hasOwnProperty.call(n,l)&&ro(n[l]))return!0;return!1}function _S(n){const s=[],l=n.data,o=n;return o.data=Mf(l,s),o.attachments=s.length,{packet:o,buffers:s}}function Mf(n,s){if(!n)return n;if(Jf(n)){const l={_placeholder:!0,num:s.length};return s.push(n),l}else if(Array.isArray(n)){const l=new Array(n.length);for(let o=0;o<n.length;o++)l[o]=Mf(n[o],s);return l}else if(typeof n=="object"&&!(n instanceof Date)){const l={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(l[o]=Mf(n[o],s));return l}return n}function BS(n,s){return n.data=Rf(n.data,s),delete n.attachments,n}function Rf(n,s){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<s.length)return s[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let l=0;l<n.length;l++)n[l]=Rf(n[l],s);else if(typeof n=="object")for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(n[l]=Rf(n[l],s));return n}const OS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],LS=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 zS{constructor(s){this.replacer=s}encode(s){return(s.type===Be.EVENT||s.type===Be.ACK)&&ro(s)?this.encodeAsBinary({type:s.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let l=""+s.type;return(s.type===Be.BINARY_EVENT||s.type===Be.BINARY_ACK)&&(l+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(l+=s.nsp+","),s.id!=null&&(l+=s.id),s.data!=null&&(l+=JSON.stringify(s.data,this.replacer)),l}encodeAsBinary(s){const l=_S(s),o=this.encodeAsString(l.packet),f=l.buffers;return f.unshift(o),f}}function _0(n){return Object.prototype.toString.call(n)==="[object Object]"}class Pf extends At{constructor(s){super(),this.reviver=s}add(s){let l;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");l=this.decodeString(s);const o=l.type===Be.BINARY_EVENT;o||l.type===Be.BINARY_ACK?(l.type=o?Be.EVENT:Be.ACK,this.reconstructor=new US(l),l.attachments===0&&super.emitReserved("decoded",l)):super.emitReserved("decoded",l)}else if(Jf(s)||s.base64)if(this.reconstructor)l=this.reconstructor.takeBinaryData(s),l&&(this.reconstructor=null,super.emitReserved("decoded",l));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let l=0;const o={type:Number(s.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=l+1;for(;s.charAt(++l)!=="-"&&l!=s.length;);const h=s.substring(d,l);if(h!=Number(h)||s.charAt(l)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(s.charAt(l+1)==="/"){const d=l+1;for(;++l&&!(s.charAt(l)===","||l===s.length););o.nsp=s.substring(d,l)}else o.nsp="/";const f=s.charAt(l+1);if(f!==""&&Number(f)==f){const d=l+1;for(;++l;){const h=s.charAt(l);if(h==null||Number(h)!=h){--l;break}if(l===s.length)break}o.id=Number(s.substring(d,l+1))}if(s.charAt(++l)){const d=this.tryParse(s.substr(l));if(Pf.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,l){switch(s){case Be.CONNECT:return _0(l);case Be.DISCONNECT:return l===void 0;case Be.CONNECT_ERROR:return typeof l=="string"||_0(l);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(l)&&(typeof l[0]=="number"||typeof l[0]=="string"&&OS.indexOf(l[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(l)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class US{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const l=BS(this.reconPack,this.buffers);return this.finishedReconstruction(),l}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const HS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Pf,Encoder:zS,get PacketType(){return Be},protocol:LS},Symbol.toStringTag,{value:"Module"}));function wn(n,s,l){return n.on(s,l),function(){n.off(s,l)}}const VS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ag extends At{constructor(s,l,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=l,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[wn(s,"open",this.onopen.bind(this)),wn(s,"packet",this.onpacket.bind(this)),wn(s,"error",this.onerror.bind(this)),wn(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...l){var o,f,d;if(VS.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(l.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(l),this;const h={type:Be.EVENT,data:l};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof l[l.length-1]=="function"){const v=this.ids++,y=l.pop();this._registerAckCallback(v,y),h.id=v}const p=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,x=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(s,l){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[s]=l;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===s&&this.sendBuffer.splice(p,1);l.call(this,new Error("operation has timed out"))},f),h=(...p)=>{this.io.clearTimeoutFn(d),l.apply(this,p)};h.withError=!0,this.acks[s]=h}emitWithAck(s,...l){return new Promise((o,f)=>{const d=(h,p)=>h?f(h):o(p);d.withError=!0,l.push(d),this.emit(s,...l)})}_addToQueue(s){let l;typeof s[s.length-1]=="function"&&(l=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),l&&l(f)):(this._queue.shift(),l&&l(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const l=this._queue[0];l.pending&&!s||(l.pending=!0,l.tryCount++,this.flags=l.flags,this.emit.apply(this,l.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:Be.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,l){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,l),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(o=>String(o.id)===s)){const o=this.acks[s];delete this.acks[s],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case Be.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Be.EVENT:case Be.BINARY_EVENT:this.onevent(s);break;case Be.ACK:case Be.BINARY_ACK:this.onack(s);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const o=new Error(s.data.message);o.data=s.data.data,this.emitReserved("connect_error",o);break}}onevent(s){const l=s.data||[];s.id!=null&&l.push(this.ack(s.id)),this.connected?this.emitEvent(l):this.receiveBuffer.push(Object.freeze(l))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const l=this._anyListeners.slice();for(const o of l)o.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const l=this;let o=!1;return function(...f){o||(o=!0,l.packet({type:Be.ACK,id:s,data:f}))}}onack(s){const l=this.acks[s.id];typeof l=="function"&&(delete this.acks[s.id],l.withError&&s.data.unshift(null),l.apply(this,s.data))}onconnect(s,l){this.id=s,this.recovered=l&&this._pid===l,this._pid=l,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Be.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const l=this._anyListeners;for(let o=0;o<l.length;o++)if(s===l[o])return l.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const l=this._anyOutgoingListeners;for(let o=0;o<l.length;o++)if(s===l[o])return l.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const l=this._anyOutgoingListeners.slice();for(const o of l)o.apply(this,s.data)}}}function cl(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}cl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),l=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-l:n+l}return Math.min(n,this.max)|0};cl.prototype.reset=function(){this.attempts=0};cl.prototype.setMin=function(n){this.ms=n};cl.prototype.setMax=function(n){this.max=n};cl.prototype.setJitter=function(n){this.jitter=n};class qf extends At{constructor(s,l){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(l=s,s=void 0),l=l||{},l.path=l.path||"/socket.io",this.opts=l,ko(this,l),this.reconnection(l.reconnection!==!1),this.reconnectionAttempts(l.reconnectionAttempts||1/0),this.reconnectionDelay(l.reconnectionDelay||1e3),this.reconnectionDelayMax(l.reconnectionDelayMax||5e3),this.randomizationFactor((o=l.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new cl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(l.timeout==null?2e4:l.timeout),this._readyState="closed",this.uri=s;const f=l.parser||HS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=l.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var l;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(l=this.backoff)===null||l===void 0||l.setMin(s),this)}randomizationFactor(s){var l;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(l=this.backoff)===null||l===void 0||l.setJitter(s),this)}reconnectionDelayMax(s){var l;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(l=this.backoff)===null||l===void 0||l.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new kS(this.uri,this.opts);const l=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=wn(l,"open",function(){o.onopen(),s&&s()}),d=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),s?s(p):this.maybeReconnectOnOpen()},h=wn(l,"error",d);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),l.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(f),this.subs.push(h),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(wn(s,"ping",this.onping.bind(this)),wn(s,"data",this.ondata.bind(this)),wn(s,"error",this.onerror.bind(this)),wn(s,"close",this.onclose.bind(this)),wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(l){this.onclose("parse error",l)}}ondecoded(s){Eo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,l){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new ag(this,s,l),this.nsps[s]=o),o}_destroy(s){const l=Object.keys(this.nsps);for(const o of l)if(this.nsps[o].active)return;this._close()}_packet(s){const l=this.encoder.encode(s);for(let o=0;o<l.length;o++)this.engine.write(l[o],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,l){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,l),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const l=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(f=>{f?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",f)):s.onreconnect()}))},l);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const ii={};function oo(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const l=MS(n,s.path||"/socket.io"),o=l.source,f=l.id,d=l.path,h=ii[f]&&d in ii[f].nsps,p=s.forceNew||s["force new connection"]||s.multiplex===!1||h;let x;return p?x=new qf(o,s):(ii[f]||(ii[f]=new qf(o,s)),x=ii[f]),l.query&&!s.query&&(s.query=l.queryKey),x.socket(l.path,s)}Object.assign(oo,{Manager:qf,Socket:ag,io:oo,connect:oo});const sg="roverSettings",$S=3600*24*365;function GS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function Tf(){if(typeof document>"u")return{};const n=`${sg}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const l=s.substring(n.length);return GS(l)??{}}function B0(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),l=`${sg}=${s}; path=/; max-age=${$S}; samesite=strict`;return document.cookie=l,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const lg=window.location.origin;console.info("[socket] connecting to",lg);const YS=Tf(),FS=YS?.page?.connectionTransport||"websocket",XS=FS==="polling"?["polling"]:["websocket","polling"],Wf=oo(lg,{transports:XS,timeout:15e3});Wf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const ig=m.createContext(Wf),QS=({children:n})=>r.jsx(ig.Provider,{value:Wf,children:n}),tn=()=>m.useContext(ig),KS={connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,alerts:[]},ed=m.createContext(null);function ZS(n){return m.useCallback((s,l={})=>new Promise((o,f)=>{n.emit(s,l,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[n])}function IS(n){return typeof n=="function"?n:s=>s}function JS({children:n}){const s=tn(),l=ZS(s),o=m.useRef({...KS,connected:s.connected}),f=m.useRef(new Set),d=m.useCallback(()=>o.current,[]),h=m.useCallback(v=>{const y=o.current,S=typeof v=="function"?v(y):{...y,...v||{}};S!==y&&(o.current=S,f.current.forEach(E=>{const C=E.selector(S);E.equalityFn(E.current,C)||(E.current=C,E.listener(C))}))},[]),p=m.useCallback((v,y,S=Object.is)=>{const E=IS(v),C={selector:E,equalityFn:S,listener:y,current:E(o.current)};return f.current.add(C),()=>{f.current.delete(C)}},[]);m.useEffect(()=>{const v=()=>{h(S=>S.connected?S:{...S,connected:!0})},y=()=>{h(S=>S.connected?{...S,connected:!1}:S)};return s.on("connect",v),s.on("disconnect",y),()=>{s.off("connect",v),s.off("disconnect",y)}},[h,s]),m.useEffect(()=>{function v(A){h(N=>({...N,session:A}))}function y(A=[]){h(N=>({...N,logs:A}))}function S(A){h(N=>({...N,logs:[...N.logs.slice(-199),A]}))}function E(A=[]){h(N=>({...N,adminLogs:A}))}function C(A){h(N=>({...N,adminLogs:[...N.adminLogs.slice(-199),A]}))}function k(A=null){const N=A&&typeof A=="object"?A:null,T=N?.debug?.status&&typeof N.debug.status=="object"?N.debug.status:null;h(M=>({...M,llmCommentaryState:N,llmCommentaryStatus:T}))}function w(A={}){h(N=>({...N,alerts:[...N.alerts.slice(-49),{...A,receivedAt:Date.now()}]}))}return s.on("session:sync",v),s.on("log:init",y),s.on("log:entry",S),s.on("adminlog:init",E),s.on("adminlog:entry",C),s.on("llm:state",k),s.on("alert:new",w),()=>{s.off("session:sync",v),s.off("log:init",y),s.off("log:entry",S),s.off("adminlog:init",E),s.off("adminlog:entry",C),s.off("llm:state",k),s.off("alert:new",w)}},[h,s]);const x=m.useMemo(()=>({login:(v,y)=>l("auth:login",{username:v,password:y}),identifySession:({cookieUserId:v,nickname:y}={})=>l("session:identify",{cookieUserId:v,nickname:y}),setRole:v=>l("session:setRole",{role:v}),requestControl:(v,y={})=>l("session:requestControl",{roverId:v,...y}),releaseControl:v=>l("session:releaseControl",{roverId:v}),subscribeAll:()=>l("session:subscribeAll"),lockRover:(v,y)=>l("session:lockRover",{roverId:v,locked:y}),setMode:v=>l("setMode",{mode:v}),homeAssistantToggle:v=>l("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,y)=>l("homeAssistant:setState",{entityId:v,state:y}),homeAssistantSetLightColor:(v,y)=>l("homeAssistant:lightColor",{entityId:v,rgbColor:y}),homeAssistantSetLightWhite:v=>l("homeAssistant:lightWhite",{entityId:v}),neatoStart:()=>l("neato:start"),neatoSendHome:()=>l("neato:sendHome"),neatoLocate:()=>l("neato:locate"),neatoClearErrors:()=>l("neato:clearErrors"),liftUp:()=>l("lift:up"),liftDown:()=>l("lift:down"),setNickname:v=>l("nickname:set",{nickname:v}),requestVerification:()=>l("verification:request"),requestPrivateRoverAccess:v=>l("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[],y="")=>v&&typeof v=="object"&&!Array.isArray(v)?l("replay:trigger",v):l("replay:trigger",{sources:v,title:y}),setCommunityGoal:v=>l("communityGoal:set",{text:v}),setAdminReason:v=>l("adminReason:set",{text:v}),rebootRover:v=>l("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>l("server:reboot"),playUploadedAudio:({roverId:v,name:y,mime:S,dataBase64:E})=>l("audio:uploadPlay",{roverId:v,name:y,mime:S,dataBase64:E}),stopUploadedAudio:v=>l("audio:uploadStop",{roverId:v}),startMicWhip:v=>l("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>l("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>l("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>l("audioLevels:set",v),setPrivateSafety:(v,y={})=>l("session:privateSafety:set",{roverId:v,safety:y}),llmControl:(v,y={})=>l("llm:control",{controls:{action:v,...y}}),pushAlert:v=>h(y=>({...y,alerts:[...y.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[l,h]),g=m.useMemo(()=>({getState:d,subscribe:p,actions:x}),[x,d,p]);return r.jsx(ed.Provider,{value:g,children:n})}function it(n,s=Object.is){const l=m.useContext(ed);if(!l)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const f=m.useRef(s);f.current=s;const[d,h]=m.useState(()=>n(l.getState()));return m.useEffect(()=>(h(p=>{const x=o.current(l.getState());return f.current(p,x)?p:x}),l.subscribe(p=>o.current(p),p=>{h(x=>f.current(x,p)?x:p)},(p,x)=>f.current(p,x))),[l]),d}function kn(){const n=m.useContext(ed);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function nn(){const n=it(l=>l),s=kn();return m.useMemo(()=>({...n,...s}),[s,n])}const rg=m.createContext({frames:{}});function PS({children:n}){const s=tn(),[l,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:p={},frame:x={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:p,raw:x?.data||null,receivedAt:Date.now()}}))}return s.on("sensorFrame",d),()=>{s.off("sensorFrame",d)}},[s]);const f=m.useMemo(()=>({frames:l}),[l]);return r.jsx(rg.Provider,{value:f,children:n})}function td(){return m.useContext(rg).frames}function ul(n){const s=td();return n?s[n]??null:null}const WS=650,ej={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 sf(n){if(typeof n!="number"||n<=0)return null;const s=ej[n];return s?{code:n,...s}:null}function tj(n,s={}){const l=s.holdMs||WS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(l/2,100));return()=>clearInterval(p)},[l]),m.useEffect(()=>{const p=Date.now(),x=sf(n?.infraredCharacterLeft),g=sf(n?.infraredCharacterRight),v=sf(n?.infraredCharacterOmni);!x&&!g&&!v||f(y=>({left:x?{...x,ts:p}:y.left,right:g?{...g,ts:p}:y.right,omni:v?{...v,ts:p}:y.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useEffect(()=>{const{left:p,right:x,omni:g}=o;if(!(p?.ts||x?.ts||g?.ts))return;const y=new Date().toISOString();console.debug("[DockIR]",y,{left:p?.code??0,omni:g?.code??0,right:x?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const p=Date.now(),x=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const A=p-w.ts,N=A<=l;return{active:N,age:A,code:w.code,red:!!(w.red&&N),green:!!(w.green&&N),force:!!(w.force&&N)}},g=x(o.left),v=x(o.right),y=x(o.omni),S=g.force||v.force||y.force,E=g.active||v.active||y.active,C=g.active&&!v.active?"right":v.active&&!g.active?"left":"center",k=(v.active?1:0)-(g.active?1:0);return{visible:E,forceDetected:S,left:g,right:v,omni:y,bias:C,balance:Math.max(-1,Math.min(1,k))}},[o.left,o.right,o.omni,l,d])}function nj(){it(S=>S.connected);const n=it(S=>S.session),s=n?.assignment?.roverId,l=ul(s),o=l?.sensors||{},f=tj(o),d=o.voltageMv!=null?`${(o.voltageMv/1e3).toFixed(2)} V`:null,h=o.currentMa!=null?`${o.currentMa} mA`:null,p=o.batteryTemperatureC!=null?`${o.batteryTemperatureC} °C`:null,x=o.batteryChargeMah,g=o.batteryCapacityMah;l?.receivedAt&&new Date(l.receivedAt).toLocaleTimeString();const v=l?.raw?l.raw:null,y=s?n?.activeDrivers?.[s]:null;return m.useMemo(()=>s?y?y===n?.socketId?"You":(n?.users||[]).find(E=>E.socketId===y)?.nickname||y.slice(0,6):"Available":"n/a",[y,s,n?.socketId,n?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[s?l?r.jsxs(r.Fragment,{children:[r.jsx(aj,{sensors:o,voltage:d,current:h,batteryTemp:p,charge:x,capacity:g}),r.jsx(sj,{sensors:o,dockState:f})]}):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."}),v&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:v})]})}function aj({sensors:n,voltage:s,current:l,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",p=n?.oiMode?.label||"--",x=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(na,{label:"Voltage",value:s??"--"}),r.jsx(na,{label:"Current",value:l??"--"}),r.jsx(na,{label:"Battery temp",value:o??"--"}),r.jsx(na,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(na,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(na,{label:"Charge",value:h}),r.jsx(na,{label:"OI mode",value:p}),r.jsx(na,{label:"Docked",value:x}),r.jsx(na,{label:"Charging state",value:g})]})}function na({label:n,value:s}){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:s})]})}function sj({sensors:n,dockState:s}){const l=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}],h=[{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(Js,{title:"Dock IR",children:[r.jsx(lj,{sensors:n}),r.jsx(ij,{state:s})]}),r.jsxs(Js,{title:"Bumps & drops",children:[r.jsx(aa,{label:"Bump L",value:r.jsx(ri,{active:l.bumpLeft})}),r.jsx(aa,{label:"Bump R",value:r.jsx(ri,{active:l.bumpRight})}),r.jsx(aa,{label:"Wheel drop L",value:r.jsx(ri,{active:l.wheelDropLeft,tone:"amber"})}),r.jsx(aa,{label:"Wheel drop R",value:r.jsx(ri,{active:l.wheelDropRight,tone:"amber"})})]}),r.jsx(Js,{title:"Light bumps (raw)",children:f.map(p=>r.jsx(aa,{label:p.label,value:oi(p.value)},p.label))}),r.jsx(Js,{title:"Cliff sensors",children:d.map(p=>r.jsx(aa,{label:p.label,value:`${oi(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),r.jsx(Js,{title:"Currents",children:h.map(p=>r.jsx(aa,{label:p.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:oi(p.value,"mA")}),p.over?r.jsx(ri,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),r.jsxs(Js,{title:"Dirt detect",children:[r.jsx(aa,{label:"Left",value:oi(n?.dirtDetectLeft)}),r.jsx(aa,{label:"Right",value:oi(n?.dirtDetect)})]})]})}function Js({title:n,children:s}){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:s})]})}function aa({label:n,value:s}){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:s})]})}function ri({active:n,tone:s="green",label:l}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:l||(n?"true":"false")})}function oi(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function lj({sensors:n}){const s=n?.infraredCharacterLeft,l=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(s)]}),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(l)]})]})}function ij({state:n}){if(!n)return null;const s=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},l=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??"--"} (${s(n.left)}) · age ${l(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${l(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${l(n.right)}`})]})}const og=m.createContext(null);function rj({children:n}){const[s,l]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=Tf();l({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=Tf();l({status:"ready",data:p??{}})},[]),f=m.useCallback(p=>{const x=B0(p??{});return l(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),d=m.useCallback((p,x)=>{l(g=>{const v=g.data[p]||{},y=typeof x=="function"?x(v):{...v,...x??{}},S={...g.data,[p]:y};return B0(S)?{status:"ready",data:S}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:f,setNamespace:d}),[s,o,f,d]);return r.jsx(og.Provider,{value:h,children:n})}function oj(){const n=m.useContext(og);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Ge(n,s={}){const{data:l,status:o,setNamespace:f}=oj(),d=l[n]??s??{},h=m.useCallback(g=>{f(n,v=>{const y=v??{};return typeof g=="function"?g(y):{...y,...g??{}}})},[n,f]),p=m.useCallback(g=>{f(n,()=>g??{})},[n,f]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;f(n,()=>g??{})},[s,n,f]);return{value:d,status:o,save:h,replace:p,reset:x}}const cj=/^#[0-9A-Fa-f]{6}$/;function nd(n){const s=typeof n=="string"?n.trim():"";return!s||!cj.test(s)?null:s.toUpperCase()}function oa(n,s=.2){const l=nd(n);if(!l)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=cg(l);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.65)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function uj(n,s=.2){const l=nd(n);if(!l)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=cg(l);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.55)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function cg(n){const s=nd(n);return s?{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16)}:null}function fj(n=[]){return n.map(s=>!s?.type||!s?.id?null:{type:s.type,id:String(s.id),label:s.label||String(s.id),color:s.color||null,key:`${s.type}:${s.id}`}).filter(Boolean)}function ad({panelId:n="replay-sources",fillHeight:s=!1}){const{session:l,triggerReplay:o}=nn(),f=fj(l?.replaySources||[]),{value:d,save:h}=Ge("replaySources",{}),[p,x]=m.useState([]),[g,v]=m.useState(!1),[y,S]=m.useState(null),[E,C]=m.useState(null),[k,w]=m.useState(""),[A,N]=m.useState(!1),[T,M]=m.useState(!0),O=l?.replay||null,[K,D]=m.useState(0),U=m.useMemo(()=>{const q=l?.assignment?.roverId;return q?[`rover:${q}`]:[]},[l?.assignment?.roverId]),Q=m.useMemo(()=>{const L=((Array.isArray(l?.users)?l.users.find(ue=>ue?.socketId===l?.socketId):null)?.nickname||"Someone").trim()||"Someone",Z=l?.assignment?.roverId||null,ae=Z&&Array.isArray(l?.roster)?l.roster.find(ue=>String(ue?.id)===String(Z))?.name||Z:"a rover";return`${L} driving ${ae}`},[l?.users,l?.socketId,l?.assignment?.roverId,l?.roster]);m.useEffect(()=>{const q=d?.[n];if(Array.isArray(q)&&q.length){x(q);return}x(U)},[d?.[n],U,n]),m.useEffect(()=>{const q=d?.[`${n}:includeSidebar`];if(typeof q=="boolean"){M(q);return}M(!0)},[d?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{A||w(Q)},[Q,A]),m.useEffect(()=>{const q=new Set(f.map(L=>L.key));x(L=>L.filter(Z=>q.has(Z)))},[f]);const $=m.useMemo(()=>({rovers:f.filter(q=>q.type==="rover"),rooms:f.filter(q=>q.type==="room")}),[f]);m.useEffect(()=>{if(!O?.lastTriggeredAt||!O?.cooldownMs){D(0);return}const q=()=>{const Z=O.lastTriggeredAt+O.cooldownMs-Date.now();D(Math.max(0,Z))};q();const L=setInterval(q,250);return()=>clearInterval(L)},[O?.lastTriggeredAt,O?.cooldownMs,O?.remainingMs]);const F=g||l?.mode==="lockdown"||K>0||!p.length,W=q=>{x(L=>{const Z=L.includes(q)?L.filter(ae=>ae!==q):[...L,q];return h(ae=>({...ae||{},[n]:Z})),Z}),C(null)},re=async()=>{if(!F){v(!0),S(null),C(null);try{const q=p.map(Z=>{const[ae,ue]=Z.split(":");return{type:ae,id:ue}}),L=String(k||"").trim()||Q;await o({sources:q,title:L,includeSidebar:T}),C("Replay sent. Check the Discord replay channel.")}catch(q){S(q.message)}finally{v(!1)}}},ce=s?"h-full flex flex-col":"",H=s?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${ce}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${H}`,children:[r.jsx(O0,{title:"Rovers",items:$.rovers,selected:p,onToggle:W}),r.jsx(O0,{title:"Room Cams",items:$.rooms,selected:p,onToggle:W})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),r.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:k,onChange:q=>{w(q.target.value),N(!0)},placeholder:Q,maxLength:120}),r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:T,onChange:q=>{const L=!!q.target.checked;M(L),h(Z=>({...Z||{},[`${n}:includeSidebar`]:L}))},className:"accent-emerald-400"}),r.jsx("span",{children:"Include replay sidebar"})]}),r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:re,disabled:F,children:K>0?`Replay (${Math.ceil(K/1e3)}s)`:g?"Replay…":"Replay"}),y?r.jsx("div",{className:"text-xs text-amber-400",children:y}):null,E?r.jsx("div",{className:"text-xs text-emerald-300",children:E}):null]})]})}function O0({title:n,items:s,selected:l,onToggle:o}){return s.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:s.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:l.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"?oa(f.color,.16):void 0,children:f.label})]},f.key))})]}):null}var ug={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},L0=cs.createContext&&cs.createContext(ug),dj=["attr","size","title"];function mj(n,s){if(n==null)return{};var l=hj(n,s),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(n);for(f=0;f<d.length;f++)o=d[f],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(l[o]=n[o])}return l}function hj(n,s){if(n==null)return{};var l={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;l[o]=n[o]}return l}function po(){return po=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var l=arguments[s];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(n[o]=l[o])}return n},po.apply(this,arguments)}function z0(n,s){var l=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(n,f).enumerable})),l.push.apply(l,o)}return l}function xo(n){for(var s=1;s<arguments.length;s++){var l=arguments[s]!=null?arguments[s]:{};s%2?z0(Object(l),!0).forEach(function(o){pj(n,o,l[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(l)):z0(Object(l)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(l,o))})}return n}function pj(n,s,l){return s=xj(s),s in n?Object.defineProperty(n,s,{value:l,enumerable:!0,configurable:!0,writable:!0}):n[s]=l,n}function xj(n){var s=gj(n,"string");return typeof s=="symbol"?s:s+""}function gj(n,s){if(typeof n!="object"||!n)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var o=l.call(n,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function fg(n){return n&&n.map((s,l)=>cs.createElement(s.tag,xo({key:l},s.attr),fg(s.child)))}function Mi(n){return s=>cs.createElement(vj,po({attr:xo({},n.attr)},s),fg(n.child))}function vj(n){var s=l=>{var{attr:o,size:f,title:d}=n,h=mj(n,dj),p=f||l.size||"1em",x;return l.className&&(x=l.className),n.className&&(x=(x?x+" ":"")+n.className),cs.createElement("svg",po({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},l.attr,o,h,{className:x,style:xo(xo({color:n.color||l.color},l.style),n.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),d&&cs.createElement("title",null,d),n.children)};return L0!==void 0?cs.createElement(L0.Consumer,null,l=>s(l)):s(ug)}function dg(n){return Mi({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 bj(n){return Mi({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 U0(n){return Mi({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 yj(n){return Mi({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 Sj(n){return Mi({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 jj(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 sd(n){return!!n?.system}function Aj(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function H0(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Nj({guildIconUrl:n,userAvatarUrl:s,label:l}){return!n&&!s?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:l,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 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function mg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${H0(n)}`:null,l=sd(n),o=l?"text-emerald-300":jj(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(dg,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(Nj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:H0(n)}),l?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:uj(n.roverColor,.14),children:n.roverId})]})}function hg(n){return sd(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 ld({message:n}){const s=sd(n);return r.jsxs("div",{className:hg(n),children:[r.jsx(mg,{message:n}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${s?"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:Aj(n.ts)})]})}function pg({message:n}){return r.jsxs("div",{className:`${hg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(mg,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function xg({buttonId:n,count:s,goal:l,rewardNumber:o,rewardName:f,className:d=""}){return r.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",d].filter(Boolean).join(" "),children:[r.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),r.jsxs("p",{className:"text-sm font-semibold text-white",children:[s," / ",l]}),r.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",f]})]})}const wj=3e3,Cj=3500,Ej="#2196f3";function kj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function id({scale:n=1}){const s=it(S=>S.alerts),l=it(S=>S.session),{pushAlert:o}=kn(),f=tn(),[d,h]=m.useState(()=>Date.now());m.useEffect(()=>{function S(E={}){const C=Number(E.buttonId);if(!Number.isFinite(C)||C<1||C>4)return;const w=(Array.isArray(l?.buttonBox?.buttons)?l.buttonBox.buttons:[]).find(O=>Number(O?.id)===C)||{},A=Number.isFinite(E.count)?E.count:Number(w.count)||0,N=Number.isFinite(w.goal)?w.goal:0,T=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",M=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${C}`,kind:"buttonbox-active",lifetimeMs:Cj,payload:{buttonId:C,count:A,goal:N,rewardNumber:T,rewardName:M}})}return f.on("buttonBox:increment",S),()=>{f.off("buttonBox:increment",S)}},[o,l?.buttonBox?.buttons,f]);const p=m.useMemo(()=>s.slice(-12).map(S=>({alert:S,key:kj(S)})),[s]);m.useEffect(()=>{if(!p.length)return;const S=setInterval(()=>h(Date.now()),200);return()=>clearInterval(S)},[p.length]);const x=new Map;p.forEach(S=>{const E=d-(S.alert.receivedAt??S.alert.timestamp??0),C=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:wj;E<=C&&x.set(S.key,{...S,age:E})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},y=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:y,style:v,children:g.map(S=>r.jsx(Mj,{alert:S.alert},S.key))})}function V0(n){const s=typeof n=="string"?n.trim():"",l=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!l)return null;const o=l[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function Mj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const f=n.payload;return r.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:r.jsx(xg,{buttonId:f.buttonId,count:f.count,goal:f.goal,rewardNumber:f.rewardNumber,rewardName:f.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return r.jsx(ld,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(pg,{message:n.payload});const s=V0(n.color)||V0(Ej),l=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return 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:l,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 Ps={main:[-127,127],side:[-127,127],vacuum:[0,127]},lf={maxSpeed:500,baseSpeed:250,boostSpeed:400},Df=100,rd=[31,127],al=60,_f=8,Rj=250,qj=4e3,Zr=.4,$0=.2,G0=.8,Tj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},hi={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"]},gg=[{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:Df},{type:"oi",command:"dock"},{type:"pause",duration:Df},{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 Bf(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Of(){return{main:0,side:0,vacuum:0}}function Dj(){return{enabled:!1,angle:null,config:null}}function co(){return{note:al}}function di(){return{active:!1,heat:0,overheated:!1}}function uo(){return{pttActive:!1}}const Y0={roverId:null,mode:"drive",drive:Bf(),aux:Of(),camera:Dj(),song:co(),horn:di(),mic:uo(),lastControlIntentAt:0,macros:gg,keymap:hi,inputs:{}};function _j(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Bf(),aux:s.payload?n.aux:Of(),song:s.payload?n.song:co(),horn:s.payload?n.horn:di(),mic:s.payload?n.mic:uo(),lastControlIntentAt:s.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===s.payload?n:{...n,mode:s.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:l,speeds:o,source:f}=s.payload;return{...n,drive:{vector:l??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,...s.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!s.payload?.config,config:s.payload?.config??null,angle:typeof s.payload?.angle=="number"?s.payload.angle:s.payload?.config?s.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:s.payload}};case"control/register-input-state":{const l=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[l]:{...n.inputs[l]??{},...s.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...s.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(s.payload)?s.payload:n.macros};case"control/reset":return{...n,drive:Bf(),aux:Of(),song:co(),horn:di(),mic:uo(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||di(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||di(),heat:typeof s.payload?.heat=="number"?s.payload.heat:0,overheated:!!s.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||co(),note:s.payload??al}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||uo(),pttActive:!!s.payload}};default:return n}}function sl(n,s,l){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(l,n))}function ll(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function gn(n,s){return!Array.isArray(s)||s.length!==2?n:sl(n,s[0],s[1])}function Bj(n={}){const s=ll(n.x??0),l=ll(n.y??0);return{x:s,y:l,boost:!!n.boost}}function Oj(n={},s={}){const l=Bj(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:lf.maxSpeed,f=typeof s.baseSpeed=="number"?s.baseSpeed:lf.baseSpeed,d=typeof s.boostSpeed=="number"?s.boostSpeed:lf.boostSpeed,h=l.boost?d:f,p=l.y*h,x=l.x*h;return{vector:l,speeds:{left:sl(Math.round(p+x),-o,o),right:sl(Math.round(p-x),-o,o)}}}function Lj(n){const s=Array.isArray(n)?n:[],l=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(l);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function F0(n){return new Promise(s=>setTimeout(s,n))}function zj(n={}){const{driveTransform:s,auxTransform:l}=n,o=tn(),f=it(O=>O.session),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(O=>String(O.id)===String(d))||null,[d,f?.roster]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),v=m.useMemo(()=>h?.nightVision?.state??null,[h]),y=m.useCallback((O,K)=>{d&&o.emit("command",{roverId:d,...O},K)},[o,d]),S=m.useCallback(()=>{d&&y({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[y,d]),E=m.useCallback(O=>{if(!d)return null;const K={left:gn(O?.left??0,[-500,500]),right:gn(O?.right??0,[-500,500])},D=s?s(K):K,U={left:gn(D?.left??0,[-500,500]),right:gn(D?.right??0,[-500,500])};return y({type:"drive",data:{driveDirect:U}}),U},[s,y,d]),C=m.useCallback(({main:O=0,side:K=0,vacuum:D=0}={})=>{if(!d)return null;const U={main:gn(O,Ps.main),side:gn(K,Ps.side),vacuum:gn(D,Ps.vacuum)},Q=l?l(U):U,$={main:gn(Q?.main??0,Ps.main),side:gn(Q?.side??0,Ps.side),vacuum:gn(Q?.vacuum??0,Ps.vacuum)};return y({type:"motors",data:{motorPwm:$}}),$},[l,y,d]),k=m.useCallback(O=>!d||!p?null:(y({type:"servo",data:{servo:{angle:O}}}),O),[y,d,p]),w=m.useCallback(O=>{if(!d)return!1;const K=Array.isArray(O)?O:typeof O=="string"?Tj[O]:null;return K?(y({type:"raw",data:{raw:Lj(K)}}),S(),!0):!1},[y,S,d]),A=m.useCallback(async O=>{if(!(!O||!Array.isArray(O.steps)||!d))for(const K of O.steps){if(!d)break;switch(K.type){case"oi":w(K.command);break;case"drive":E(K.speeds??{left:0,right:0});break;case"motors":C(K.values??{});break;case"servo":k(K.angle);break;case"pause":await F0(K.duration??Df);break}if(K.delay||K.delayMs){const D=K.delayMs??K.delay;typeof D=="number"&&D>0&&await F0(D)}}},[d,w,E,C,k]),N=m.useCallback((O="toggle")=>!d||!x?null:(y({type:"nightVision",data:{nightVision:{action:O}}}),O),[y,x,d]),T=m.useCallback(O=>d?(y({type:"horn",data:{horn:O}}),O):null,[y,d]),M=m.useCallback((O=[],K={})=>{if(!d)return null;const U=(Array.isArray(O)&&O.length>0?O:[{note:al,duration:_f}]).slice(0,16).map(Q=>({note:gn(Math.round(Q?.note??al),rd),duration:gn(Math.round(Q?.duration??_f),[1,255])}));return y({type:"song",data:{song:{notes:U,slot:K.slot,loop:K.loop}}}),U},[y,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:v,horn:g,emitCommand:y,enableSensorStream:S,sendDriveDirect:E,sendAuxMotors:C,sendServoAngle:k,sendOiCommand:w,sendNightVision:N,sendHorn:T,sendSong:M,runMacroSteps:A}),[d,h,p,x,v,g,y,S,E,C,k,w,N,T,A])}const Uj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},X0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Ri(n){if(typeof n!="string")return"";const s=n.toLowerCase();return Uj[s]??s}function Hj(n){const s=Ri(n);if(!s)return null;if(X0[s])return X0[s];if(s.length===1){if(/[a-z]/.test(s))return`Key${s.toUpperCase()}`;if(/[0-9]/.test(s))return`Digit${s}`}return null}function vg(n){const s=Ri(n);return s?`key:${s}`:null}function Vj(n){const s=Hj(n);return s?`code:${s}`:null}function Q0(n){const s=new Set,l=vg(n?.key??"");l&&s.add(l);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function $j(n={}){return Object.fromEntries(Object.entries(n).map(([s,l])=>{const o=Array.isArray(l)?l:[l],f=new Set;return o.forEach(d=>{const h=vg(String(d));h&&f.add(h);const p=Vj(String(d));p&&f.add(p)}),[s,f]}))}function Cn(n){const s=Ri(n);return s?s===" "?"Space":s==="\\"?"Backslash":s==="`"?"Backtick":s==="["?"[ or {":s==="]"?"] or }":s===";"?"; or :":s==="'"?`' or "`:s===","?", or <":s==="."?". or >":s==="/"?"/ or ?":s==="-"?"- or _":s==="="?"= or +":s==="arrowup"?"Arrow Up":s==="arrowdown"?"Arrow Down":s==="arrowleft"?"Arrow Left":s==="arrowright"?"Arrow Right":s.length===1?s.toUpperCase():s:"—"}const _n={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:100,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}]}}},_a={activeSignature:null,profiles:{},defaults:{profile:la}},os={waveform:"saw",freqs:[440,550,660,0]},st={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},is=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Gj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function K0(){return is.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function Z0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Yj(n,s={}){const l=it(A=>A.session),d=(ul(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...Gj,...s.config||{}}),[s.config]),[p,x]=m.useState(()=>K0()),g=m.useRef(0),v=m.useRef(d);m.useEffect(()=>{v.current=d||{}},[d]),m.useEffect(()=>{x(K0()),g.current=0},[n]);const y=m.useMemo(()=>is.some(A=>A.motors.some(N=>!!d?.[N])),[d]),S=m.useMemo(()=>Object.values(p||{}).some(A=>(Number.isFinite(A?.cap)?A.cap:1)<.999),[p]),E=!!n&&(y||S);m.useEffect(()=>{if(!E)return;g.current=typeof performance<"u"?performance.now():Date.now();const A=setInterval(()=>{const N=typeof performance<"u"?performance.now():Date.now(),T=Math.max(0,N-g.current);g.current=N;const M=Math.min(.25,T/1e3);M<=0||x(O=>{let K=!1;const D={},U=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,Q=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,$=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return is.forEach(F=>{const W=O[F.key]||{cap:1,clearSec:0},re=Number.isFinite(W.cap)?W.cap:1,ce=Number.isFinite(W.clearSec)?W.clearSec:0,H=F.motors.some(ae=>!!v.current?.[ae]),q=H?0:ce+M,L=!H&&q>=$,Z=Z0(H?re-U*M:L?re+Q*M:re);(Math.abs(Z-re)>1e-4||Math.abs(q-ce)>1e-4)&&(K=!0),D[F.key]={cap:Z,clearSec:q}}),K?D:O})},100);return()=>clearInterval(A)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec,n,E]);const C=m.useMemo(()=>{const A=is.reduce((N,T)=>{const M=p?.[T.key],O=Number.isFinite(M?.cap)?M.cap:1;return N[T.key]=Z0(O),N},{});return{perGroup:A,drive:{left:A.drive??1,right:A.drive??1},aux:{main:A.aux??1,side:A.aux??1,vacuum:1}}},[p]),k=m.useMemo(()=>{const A={};is.forEach(T=>{T.motors.forEach(M=>{A[M]=!!d?.[M]})});const N=is.reduce((T,M)=>(T[M.key]=M.motors.some(O=>!!d?.[O]),T),{});return{motors:A,groups:N}},[d]),w=l?.role==="admin"||l?.role==="lockdown"||l?.role==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:k,scales:C,isActive:(C?.drive?.left??1)<1||(C?.drive?.right??1)<1||(C?.aux?.main??1)<1||(C?.aux?.side??1)<1,config:h,adminImmune:w}),[p,k,C,h,w])}function Fj(n={},s,l=!1){if(l||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,f=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&f>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*f)}}function Xj(n={},s,l=!1){if(l||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,f=typeof s.aux.side=="number"?s.aux.side:1,d=typeof s.aux.vacuum=="number"?s.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 bg=m.createContext(null);function I0(n){return Object.fromEntries(Object.entries(n||{}).map(([s,l])=>[s,Array.isArray(l)?[...l]:[]]))}function Qj(n,s){if(!n)return s;const l=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return sl(s,l,o)}function Kj(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[l,o,f]=s,d=l?.type==="drive"&&Number(l?.speeds?.left)===-300&&Number(l?.speeds?.right)===-300,h=o?.type==="pause"&&Number(o?.duration)===600,p=f?.type==="drive"&&Number(f?.speeds?.left)===0&&Number(f?.speeds?.right)===0;return!d||!h||!p?n:n.slice(0,-3)}function Zj({children:n}){const[s,l]=m.useReducer(_j,Y0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(Y0.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:v}=Ge("controls",{keymap:hi,macros:gg}),{value:y}=Ge("page",{driveMacroBackoffEnabled:!0}),{value:S}=Ge("horn",os),E=typeof y?.driveMacroBackoffEnabled=="boolean"?y.driveMacroBackoffEnabled:!0,C=it(ie=>ie.session),{homeAssistantSetState:k}=kn(),w=C?.assignment?.roverId??null,A=Yj(w),N=m.useCallback(ie=>Fj(ie,A.scales,A.adminImmune),[A.adminImmune,A.scales]),T=m.useCallback(ie=>Xj(ie,A.scales,A.adminImmune),[A.adminImmune,A.scales]),M=zj({driveTransform:N,auxTransform:T}),O=m.useCallback(()=>{const me=(C?.homeAssistant?.entities||[]).filter(le=>(le.type==="light"||le.type==="switch")&&le.available!==!1&&le.state!=="on");if(me.length===0){f.current=!1;return}f.current=!0,me.forEach(le=>{k(le.id,"on").catch(()=>{})}),f.current=!1},[C?.homeAssistant?.entities,k]);m.useEffect(()=>{l({type:"control/set-rover",payload:M.roverId})},[M.roverId]),m.useEffect(()=>{const ie=o.current;o.current=s.mode,ie!=="drive"&&s.mode==="drive"&&C?.homeAssistant?.entities?O():ie!=="drive"&&s.mode==="drive"&&(f.current=!0)},[s.mode,C?.homeAssistant?.entities,O]),m.useEffect(()=>{f.current&&C?.homeAssistant?.entities&&O()},[C?.homeAssistant?.entities,O]),m.useEffect(()=>{const ie={...hi,...g?.keymap||{}};l({type:"control/set-keymap",payload:ie}),g?.macros&&l({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const ie=M.servoConfig;if(!ie){l({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const me=typeof ie.minAngle=="number"?ie.minAngle:-45,le=typeof ie.maxAngle=="number"?ie.maxAngle:45,J=typeof ie.homeAngle=="number"?ie.homeAngle:(me+le)/2,he=typeof d.current=="number"?sl(d.current,me,le):null,Ae=he??sl(J,me,le);l({type:"control/set-camera-config",payload:{config:ie,angle:Ae}}),d.current=Ae},[M.servoConfig]),m.useEffect(()=>{d.current=typeof s.camera.angle=="number"?s.camera.angle:d.current},[s.camera.angle]),m.useEffect(()=>{M.roverId&&M.enableSensorStream()},[M.roverId,M.enableSensorStream]);const K=m.useCallback(ie=>{l({type:"control/set-mode",payload:ie})},[]),D=m.useCallback(()=>{l({type:"control/record-intent"})},[]),U=m.useRef(s.drive.speeds),Q=m.useRef(s.aux),$=m.useMemo(()=>JSON.stringify(A.scales),[A.scales]),F=m.useRef(0),W=m.useRef(0);m.useEffect(()=>{U.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{Q.current=s.aux},[s.aux]),m.useEffect(()=>{if(!M.roverId||A.adminImmune||!A.isActive)return;const ie=Math.max(0,Number(A?.config?.outputRateMs)||0),me=typeof performance<"u"?performance.now():Date.now(),le=U.current||{left:0,right:0},J=Q.current||{main:0,side:0,vacuum:0},he=!!(le.left||le.right),Ae=!!(J.main||J.side||J.vacuum);!he&&!Ae||(he&&me-F.current>=ie&&(F.current=me,M.sendDriveDirect(le)),Ae&&me-W.current>=ie&&(W.current=me,M.sendAuxMotors(J)))},[$,A.adminImmune,A.config,A.isActive,M]);const re=m.useCallback((ie,me={})=>{const le=Oj(ie,me.speedOptions);l({type:"control/update-drive",payload:{...le,source:me.source??null}}),D(),M.sendDriveDirect(le.speeds)},[M,D]),ce=m.useCallback((ie={})=>{const me=M.sendAuxMotors(ie)??ie;l({type:"control/set-aux-motors",payload:me}),D()},[M,D]),H=m.useCallback((ie,me)=>{if(!ie)return!1;const le=Ri(me);if(!le)return!1;const J=I0(s.keymap);return J[ie]=[le],l({type:"control/set-keymap",payload:J}),v(he=>({...he??{},keymap:J})),!0},[s.keymap,v]),q=m.useCallback(()=>{const ie=I0(hi);l({type:"control/set-keymap",payload:ie}),v(me=>({...me??{},keymap:ie}))},[v]),L=m.useCallback(ie=>{if(!M.servoConfig)return;const me=Qj(M.servoConfig,ie);l({type:"control/set-camera-angle",payload:me}),M.sendServoAngle(me),d.current=me,D()},[M,D]),Z=m.useCallback((ie=0)=>{const me=M.servoConfig;if(!me)return;const le=typeof ie=="number"&&ie!==0?ie:me.nudgeDegrees||1,J=typeof d.current=="number"?d.current:typeof me.homeAngle=="number"?me.homeAngle:0;L(J+le)},[M.servoConfig,L]),ae=m.useCallback(()=>{const ie=M.servoConfig;if(!ie)return;const me=typeof ie.homeAngle=="number"?ie.homeAngle:typeof ie.minAngle=="number"&&typeof ie.maxAngle=="number"?(ie.minAngle+ie.maxAngle)/2:0;L(me)},[M.servoConfig,L]),ue=m.useCallback(async ie=>{const me=s.macros.find(J=>J.id===ie)||null;if(!me)return;let le=me;ie==="drive-sequence"?(O(),C?.homeAssistant?.entities||(f.current=!0),D(),E||(le={...me,steps:Kj(me.steps)})):ie==="seek-dock"&&D(),await M.runMacroSteps(le)},[E,M,D,C?.homeAssistant?.entities,s.macros,O]),R=m.useCallback(()=>{l({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]),V=m.useCallback(ie=>{M.sendOiCommand(ie)},[M]),ne=m.useCallback(ie=>{M.roverId&&M.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ie}}})},[M]),se=m.useCallback(ie=>{if(M.nightVision){if(typeof ie=="boolean"){const me=ie?"off":"on";M.sendNightVision(me)}else M.sendNightVision("toggle");D()}},[M,D]),pe=m.useCallback(()=>{se()},[se]),oe=m.useCallback(ie=>{const me=typeof ie=="number"?ie:al;return l({type:"control/set-song-note",payload:me}),me},[]),fe=m.useCallback((ie,me)=>M.sendSong(ie,me),[M]),be=m.useMemo(()=>{const ie=S??os,me=ie.waveform==="sine"?"sine":"saw",J=[...Array.isArray(ie.freqs)?ie.freqs:os.freqs,0,0,0,0].slice(0,4).map(he=>{const Ae=Number(he);return Number.isFinite(Ae)?Ae<=0?0:Math.min(5e3,Math.round(Ae)):0});return{waveform:me,freqs:J}},[S]),ve=m.useCallback(()=>{if(!M.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const ie=Date.now();return M.sendHorn({action:"start",...be}),l({type:"control/set-horn-active",payload:!0}),p.current=ie,x.current=ie,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},qj),D(),!0},[l,be,M,D,s.horn?.active,s.horn?.heat,s.horn?.overheated]),xe=m.useCallback(()=>{if(!M.horn)return;M.sendHorn({action:"stop"}),l({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const ie=Date.now(),me=p.current||ie,le=Math.max(0,ie-me);if(p.current=0,le>0){const J=s.horn?.heat??0,he=le/1e3*Zr;let Ae=Math.max(0,Math.min(1,J+he)),ht=s.horn?.overheated??!1;Ae>=1&&(Ae=1,ht=!0),l({type:"control/set-horn-heat",payload:{heat:Ae,overheated:ht}})}},[l,M,s.horn?.heat,s.horn?.overheated,Zr]),Le=m.useRef({active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}),De=m.useRef(xe);m.useEffect(()=>{Le.current={active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}},[s.horn?.active,s.horn?.heat,s.horn?.overheated]),m.useEffect(()=>{De.current=xe},[xe]);const Ee=!!s.horn?.active||(s.horn?.heat??0)>0||!!s.horn?.overheated;m.useEffect(()=>{if(!Ee)return;const me=setInterval(()=>{const le=Date.now(),J=x.current||le;x.current=le;const he=Math.min(1e3,Math.max(0,le-J))/1e3,Ae=Le.current,ht=Ae.heat??0,Oe=!!Ae.active,rt=!!Ae.overheated,ot=he*(Oe?Zr:-$0);let gt=Math.max(0,Math.min(1,ht+ot)),kt=rt;gt>=1?(gt=1,kt=!0,Oe&&De.current()):kt&><=G0&&(kt=!1),(gt!==ht||kt!==rt)&&l({type:"control/set-horn-heat",payload:{heat:gt,overheated:kt}})},100);return()=>clearInterval(me)},[l,Ee,$0,G0,Zr]);const nt=m.useCallback((ie,me)=>{l({type:"control/register-input-state",payload:{source:ie,state:me}})},[]),Ve=m.useCallback(ie=>{l({type:"control/set-mic-ptt",payload:!!ie})},[]),mt=m.useMemo(()=>({state:s,dispatch:l,pipeline:M,overcurrentLimiter:A,actions:{setMode:K,setDriveVector:re,setAuxMotors:ce,setServoAngle:L,nudgeServo:Z,goServoHome:ae,runMacro:ue,stopAllMotion:R,sendOiCommand:V,setSensorStream:ne,setNightVision:se,toggleNightVision:pe,updateKeyBinding:H,resetKeyBindings:q,registerInputState:nt,setSongNote:oe,sendSong:fe,startHorn:ve,stopHorn:xe,setMicPttActive:Ve}}),[s,M,A,K,re,ce,L,Z,ae,ue,R,V,ne,se,pe,H,q,nt,oe,fe,ve,xe,Ve]);return r.jsx(bg.Provider,{value:mt,children:n})}function _t(){const n=m.useContext(bg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const Ij="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=",yg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function Jj({children:n}){const s=tn(),l=it(H=>H.session),{pushAlert:o}=kn(),{value:f}=Ge("audio",st),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,v]=m.useState(!1),y=m.useRef(null),S=m.useRef(null),E=m.useRef(null),C=m.useRef(new Map),k=m.useRef(new Map),w=m.useRef({isTyping:!1,lastSent:0}),A=Number.isFinite(f?.masterVolume)?f.masterVolume:st.masterVolume,N=Number.isFinite(f?.alertVolume)?f.alertVolume:st.alertVolume,T=Math.max(0,Math.min(1,A*N)),M=m.useCallback(()=>{const H=Array.from(C.current.values()).sort((q,L)=>q.lastUpdate-L.lastUpdate).map(q=>q.payload);x(H)},[]),O=m.useCallback(H=>!H||typeof H!="object"?null:H.typingId?H.typingId:H.fromDiscord?`discord:${H.discordUserId||H.discordUserName||H.nickname||"unknown"}`:`socket:${H.socketId||H.nickname||"unknown"}`,[]);m.useEffect(()=>{E.current=new Audio(Ij),E.current.volume=T,E.current.load()},[T]);const K=m.useCallback(()=>{const H=E.current;H&&(H.volume=T,H.currentTime=0,H.play().catch(()=>{}))},[T]);m.useEffect(()=>{function H(q={}){h(L=>[...L.slice(-99),q]),!(q?.socketId&&l?.socketId&&q.socketId===l.socketId)&&(K(),o?.({kind:"chat",payload:q,id:`chat-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",H),()=>{s.off("chat:message",H)}},[K,l?.socketId,s]),m.useEffect(()=>{function H(q={}){const L=O(q);if(!L)return;const Z=Date.now();if(q?.socketId&&l?.socketId&&q.socketId===l.socketId){q.isTyping||(C.current.delete(L),M());return}if(q.isTyping){C.current.set(L,{payload:q,expiresAt:Z+6e3,lastUpdate:Z});const ae=k.current.get(L)||0;Z-ae>=2500&&(k.current.set(L,Z),o?.({kind:"chat-typing",payload:q,id:`chat-typing-${L}-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Z}))}else C.current.delete(L);M()}return s.on("chat:typing",H),()=>{s.off("chat:typing",H)}},[o,M,O,l?.socketId,s]),m.useEffect(()=>{const H=setInterval(()=>{const q=Date.now();let L=!1;C.current.forEach((Z,ae)=>{Z.expiresAt<=q&&(C.current.delete(ae),L=!0)}),L&&M()},2e3);return()=>clearInterval(H)},[M]),m.useEffect(()=>{function H(q=[]){Array.isArray(q)&&h(L=>{if(L.length===0)return q.slice(-100);const Z=new Set(q.map(ue=>ue?.id));return[...q,...L.filter(ue=>ue?.id&&!Z.has(ue.id))].slice(-100)})}return s.on("chat:init",H),()=>{s.off("chat:init",H)}},[s]);const D=m.useCallback(H=>{const q=!!H,L=Date.now(),Z=w.current,ae=!q&&Z.isTyping;!(q&&(!Z.isTyping||L-Z.lastSent>=3500))&&!ae||(w.current={isTyping:q,lastSent:L},s.emit("chat:typing",{isTyping:q}))},[s]),U=m.useCallback((H,q=null)=>new Promise((L,Z)=>{s.emit("chat:send",{text:H,tts:q},(ae={})=>{ae.error?Z(new Error(ae.error)):L(ae)})}),[s]),Q=m.useCallback((H,q={})=>{(q?.target==="hud"?"hud":"panel")==="hud"?S.current=H:y.current=H},[]),$=m.useCallback(()=>{v(!0),(S.current||y.current)?.focus()},[]),F=m.useCallback(()=>{v(!1),S.current?.blur(),y.current?.blur()},[]),W=m.useCallback(()=>v(!0),[]),re=m.useCallback(()=>v(!1),[]),ce=m.useMemo(()=>({messages:d,sendMessage:U,focusChat:$,blurChat:F,registerInputRef:Q,onInputFocus:W,onInputBlur:re,setTypingActive:D,typing:p,isChatFocused:g,selfSocketId:l?.socketId||null}),[F,$,g,d,re,W,Q,U,l?.socketId,D,p]);return r.jsx(yg.Provider,{value:ce,children:n})}function od(){const n=m.useContext(yg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let Sg=!1;function rf(n){Sg=!!n}function J0(){return Sg}const Pj=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function jg(n){if(!n||n.nodeType!==1)return!1;const s=n.tagName;if(s==="TEXTAREA"||n.isContentEditable)return!0;if(s!=="INPUT")return!1;const l=n.type?n.type.toLowerCase():"";return Pj.has(l)}function Wj(){return typeof document>"u"?!1:jg(document.activeElement)}const of="keyboard",cf={x:0,y:0,boost:!1},uf={main:0,side:0,vacuum:0},P0=rd[0],W0=rd[1],cd=5,vi=500,bi=1,ud=100;function ff(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(0,Math.min(500,l)):s}function eA(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(cd,Math.min(vi,l)):s}function Ag(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(bi,Math.min(ud,l)):s}function tA(n){const l=(Ag(n,n)-bi)/(ud-bi),o=vi-l*(vi-cd);return Math.round(o)}function nA(n){const s=eA(n,n),l=(vi-s)/(vi-cd),o=bi+l*(ud-bi);return Math.round(o)}function aA(n){return jg(n?.target)}function dt(n,s){if(!n||n.size===0)return!1;for(const l of s)if(n.has(l))return!0;return!1}function sA(n,s){const l=dt(s.driveForward,n),o=dt(s.driveBackward,n),f=dt(s.driveLeft,n),d=dt(s.driveRight,n),h=dt(s.boostModifier,n),p=dt(s.slowModifier,n);let x=0;l&&!o?x=1:o&&!l&&(x=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const v=p?.4:1;return{x:g*v,y:x*v,boost:h&&!p}}function lA(n,s){if(dt(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=dt(s.auxMainForward,n)?127:dt(s.auxMainReverse,n)?-127:0,f=dt(s.auxSideForward,n)?127:dt(s.auxSideReverse,n)?-70:0,d=dt(s.auxVacuumFast,n)?127:dt(s.auxVacuumSlow,n)?50:0;return{main:o,side:f,vacuum:d}}function iA(){const{state:n,actions:{setMode:s,setDriveVector:l,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:v,setMicPttActive:y,setSongNote:S,sendSong:E}}=_t(),C=it(oe=>oe.session),{homeAssistantSetState:k}=kn(),{focusChat:w,blurChat:A,isChatFocused:N}=od(),{value:T}=Ge("inputs",_n),M=m.useMemo(()=>$j(n.keymap),[n.keymap]),O=m.useMemo(()=>{const oe=new Set;return Object.values(M).forEach(fe=>{fe&&fe.forEach(be=>oe.add(be))}),oe},[M]),K=m.useMemo(()=>{const oe=_n.keyboard,fe=T?.keyboard??{};return{baseSpeed:ff(fe.baseSpeed,oe.baseSpeed),turboSpeed:ff(fe.turboSpeed,oe.turboSpeed),precisionSpeed:ff(fe.precisionSpeed,oe.precisionSpeed)}},[T?.keyboard]),D=m.useMemo(()=>{const oe=_n.keyboard,fe=T?.keyboard??{},be=Ag(typeof fe.tiltSpeed=="number"?fe.tiltSpeed:typeof fe.tiltIntervalMs=="number"?nA(fe.tiltIntervalMs):oe.tiltSpeed,oe.tiltSpeed);return tA(be)},[T?.keyboard]),U=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),Q=m.useRef(new Set),$=m.useRef(cf),F=m.useRef(uf),W=m.useRef(null),re=m.useRef(null),ce=m.useRef(!1),H=m.useCallback(()=>{const oe=new Set(Q.current);dt(M.boostModifier,oe);const be=dt(M.slowModifier,oe)?{baseSpeed:K.precisionSpeed,boostSpeed:K.precisionSpeed}:{baseSpeed:K.baseSpeed,boostSpeed:K.turboSpeed},ve=sA(oe,M),xe=lA(oe,M);(ve.x!==$.current.x||ve.y!==$.current.y||ve.boost!==$.current.boost)&&($.current=ve,l(ve,{source:of,speedOptions:be})),(xe.main!==F.current.main||xe.side!==F.current.side||xe.vacuum!==F.current.vacuum)&&(F.current=xe,o(xe)),p(of,{keys:Array.from(oe),vector:ve,aux:xe})},[M,K,p,o,l]),q=m.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),L=m.useCallback(()=>{const oe=new Set(Q.current),fe=dt(M.cameraUp,oe),be=dt(M.cameraDown,oe);return(fe?1:0)-(be?1:0)},[M]),Z=m.useCallback(()=>{if(L()===0){q();return}if(W.current)return;const fe=()=>{const be=L();if(be===0){q();return}f(be*U),W.current=setTimeout(fe,D)};W.current=setTimeout(fe,0)},[L,f,D,U,q]),ae=m.useCallback(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),ue=m.useCallback(()=>{const oe=new Set(Q.current),fe=dt(M.songNoteUp,oe),be=dt(M.songNoteDown,oe);return(fe?1:0)-(be?1:0)},[M]),R=m.useCallback(oe=>{if(oe===0)return;let be=(typeof n.song?.note=="number"?n.song.note:al)+oe;be>W0?be=P0:be<P0&&(be=W0);const ve=S(be);E([{note:ve,duration:_f}],{slot:0})},[E,S,n.song?.note]),V=m.useCallback(()=>{if(ue()===0){ae();return}if(re.current)return;const fe=()=>{const be=ue();if(be===0){ae();return}R(be),re.current=setTimeout(fe,Rj)};re.current=setTimeout(fe,0)},[ue,ae,R]),ne=m.useCallback(()=>{Q.current.clear(),$.current=cf,F.current=uf,q(),ae(),ce.current&&(ce.current=!1,v()),y(!1),h(),p(of,{keys:[],vector:cf,aux:uf})},[p,y,h,v,q,ae]),se=m.useCallback(oe=>{const fe=C?.homeAssistant;if(!fe?.enabled||!fe?.connected||fe?.lightPolicy?.locked||fe?.lightPolicy?.lockedOn)return;const ve=(fe.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ve.length!==0){if(oe==="on"){const xe=ve.find(Le=>Le.state!=="on");xe&&k(xe.id,"on").catch(()=>{});return}if(oe==="off")for(let xe=ve.length-1;xe>=0;xe-=1){const Le=ve[xe];if(Le.state==="on"){k(Le.id,"off").catch(()=>{});break}}}},[k,C?.homeAssistant]);m.useEffect(()=>{function oe(ve){if(J0()||aA(ve))return;const xe=Q0(ve);if(xe.length===0)return;const Le=new Set(xe);if(dt(M.chatFocus,Le)){ve.preventDefault(),ne(),N||w();return}xe.some(Ee=>O.has(Ee))&&ve.preventDefault();const De=xe.filter(Ee=>!Q.current.has(Ee));if(De.forEach(Ee=>Q.current.add(Ee)),De.length>0)if(De.some(Ee=>M.driveMacro?.has(Ee)))s("drive"),d("drive-sequence");else if(De.some(Ee=>M.dockMacro?.has(Ee)))s("dock"),d("seek-dock");else if(De.some(Ee=>M.nightVisionToggle?.has(Ee)))x();else if(De.some(Ee=>M.hornHonk?.has(Ee))){if(!ce.current){const Ee=g();ce.current=!!Ee}}else De.some(Ee=>M.micPtt?.has(Ee))?y(!0):De.some(Ee=>M.homeAssistantOn?.has(Ee))?se("on"):De.some(Ee=>M.homeAssistantOff?.has(Ee))&&se("off");Z(),V(),H()}function fe(ve){if(J0())return;Q0(ve).forEach(Le=>Q.current.delete(Le)),ce.current&&!dt(M.hornHonk,Q.current)&&(ce.current=!1,v()),dt(M.micPtt,Q.current)||y(!1),Z(),V(),H()}function be(){ne()}return window.addEventListener("keydown",oe,{capture:!0}),window.addEventListener("keyup",fe,{capture:!0}),window.addEventListener("blur",be),()=>{window.removeEventListener("keydown",oe,{capture:!0}),window.removeEventListener("keyup",fe,{capture:!0}),window.removeEventListener("blur",be)}},[O,A,H,Z,V,w,N,M.chatFocus,M.dockMacro,M.driveMacro,M.hornHonk,M.micPtt,ne,d,y,s,h,ae,g,v,se]);const pe=m.useRef(ne);return m.useEffect(()=>{pe.current=ne},[ne]),m.useEffect(()=>{pe.current()},[n.roverId]),m.useEffect(()=>{ce.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{q(),ae()},[q,ae]),null}const rA=1.6;function Ng(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",l=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,f=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${l}::${o}::${f}`}function oA(n){return JSON.parse(JSON.stringify(n??{}))}function wg(n,s){const l=oA(s);return l.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},l}function rs(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function ci(n,s){if(!n)return 0;const l=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(l,rA):n}function df(n,s){const l=Math.abs(n);if(l<=s)return 0;const o=(l-s)/(1-s);return Math.sign(n)*o}function cA(n,s,l){const o=Math.hypot(n,s);if(o<=l)return{x:0,y:0};const d=(o-l)/(1-l)/o;return{x:n*d,y:s*d}}function go(n,s){if(!n||!Array.isArray(n.axes))return null;const l=n.axes[s];return Number.isFinite(l)?rs(l):null}function Lf(n,s){if(!n||!Array.isArray(n.buttons))return null;const l=n.buttons[s];if(!l)return null;const o=typeof l.value=="number"?l.value:l.pressed?1:0;return{pressed:!!(l.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function mf(n,s=[]){for(const l of s)if(l){if(l.kind==="axis"){const o=go(n,l.index);if(o===null)continue;return{value:l.invert?-o:o,source:l}}if(l.kind==="buttonAxis"){const o=Lf(n,l.index);if(!o)continue;return{value:rs(o.value),source:l}}}return{value:0,source:null}}function uA(n,s=[]){for(const l of s){if(!l||l.kind!=="axisPair")continue;const o=go(n,l.x),f=go(n,l.y);if(o===null||f===null)continue;const d=l.invertX?-o:o,h=l.invertY?-f:f;return{x:d,y:h,source:l}}return{x:0,y:0,source:null}}function ts(n,s=[]){for(const l of s)if(l){if(l.kind==="button"){const o=Lf(n,l.index);if(!o)continue;return{pressed:o.pressed,source:l}}if(l.kind==="axisButton"){const o=go(n,l.index);if(o===null)continue;const f=l.direction||1,d=typeof l.threshold=="number"?l.threshold:.6;return{pressed:o*f>d,source:l}}if(l.kind==="buttonAxis"){const o=Lf(n,l.index);if(!o)continue;return{pressed:o.value>.5,source:l}}}return{pressed:!1,source:null}}function Cg(n,s){const l=s?.bindings??{},o=s?.calibration??{},f=l.drive??{},d=uA(n,f.sources);let h=rs(d.x),p=rs(d.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=cA(h,p,x);h=ci(g.x,o.driveCurve),p=ci(g.y,o.driveCurve);const v=l.cameraTilt??{},y=mf(n,v.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let E=df(rs(y.value),S);E=ci(E,o.cameraCurve);const C=Math.min(Math.max(o.auxDeadzone??.05,0),.6),k=l.mainBrush??{},w=mf(n,k.sources);let A=df(rs(w.value),C);A=ci(A,o.auxCurve);const N=l.sideBrush??{},T=mf(n,N.sources);let M=df(rs(T.value),C);M=ci(M,o.auxCurve);const O=ts(n,l.vacuum?.sources),K=ts(n,l.allAux?.sources),D=ts(n,l.mainReverse?.sources),U=ts(n,l.sideReverse?.sources),Q=ts(n,l.driveMacro?.sources),$=ts(n,l.dockMacro?.sources),F=ts(n,l.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:E,auxAxis:{main:A,side:M},buttons:{vacuum:O.pressed,allAux:K.pressed,mainReverse:D.pressed,sideReverse:U.pressed,driveMacro:Q.pressed,dockMacro:$.pressed,nightVisionToggle:F.pressed},sources:{drive:d.source,cameraTilt:y.source,mainBrush:w.source,sideBrush:T.source,vacuum:O.source,allAux:K.source,mainReverse:D.source,sideReverse:U.source,driveMacro:Q.source,dockMacro:$.source,nightVisionToggle:F.source}}}const mi=new Set;let nl=null,il={pads:[],timestamp:0},Ir=!1,Jr=null;function ex(){return Eg().some(n=>n?.connected!==!1)}function Eg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function fA(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0})),signature:Ng(n)}}function vo(){il={pads:Eg().map(fA),timestamp:typeof performance<"u"?performance.now():Date.now()},mi.forEach(s=>s(il))}function kg(){if(vo(),il.pads.length===0){zf();return}nl=requestAnimationFrame(kg)}function tx(){nl||(vo(),il.pads.length!==0&&(nl=requestAnimationFrame(kg)))}function zf(){nl&&(cancelAnimationFrame(nl),nl=null)}function Mg(n){if(mi.add(n),!Ir&&typeof window<"u"){const s=()=>{vo(),mi.size!==0&&(ex()?tx():zf())};window.addEventListener("gamepadconnected",s),window.addEventListener("gamepaddisconnected",s),Jr=s,Ir=!0}return ex()?tx():vo(),n(il),()=>{mi.delete(n),mi.size===0&&(zf(),Ir&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Jr),window.removeEventListener("gamepaddisconnected",Jr),Jr=null,Ir=!1))}}function dA(){const[n,s]=m.useState(il);return m.useEffect(()=>Mg(s),[]),n}const Ws="gamepad",ns={x:0,y:0,boost:!1},as={main:0,side:0,vacuum:0},mA=100,hA=100;function hf(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function pf(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function pA(n){return n?Math.hypot(n.x||0,n.y||0):0}function xA(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function gA(n,s){if(!n||n.length===0)return null;if(s){const l=n.find(o=>o.signature===s);if(l)return l}return n[0]}function vA(){const{state:n,actions:{setMode:s,setDriveVector:l,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:p}}=_t(),{value:x,save:g}=Ge("gamepad",_a),v=m.useRef(new Set),y=m.useRef(ns),S=m.useRef(as),E=m.useRef({main:!1,side:!1}),C=m.useRef(new Map),k=m.useRef(0),w=m.useRef(0),A=m.useRef(0),N=m.useRef(null),T=m.useCallback(D=>{const U=D.signature??Ng(D);x?.profiles?.[U]||v.current.has(U)||(v.current.add(U),g(Q=>{const $=Q??_a;if($.profiles?.[U])return $;const F=$?.defaults?.profile??la,W=wg(D,F);return{...$,profiles:{...$.profiles??{},[U]:W}}}))},[x?.profiles,g]),M=m.useCallback((D,U)=>{const Q=C.current.get(D)||!1;return C.current.set(D,U),U&&!Q},[]),O=m.useCallback((D,U)=>{const Q=n.camera?.config;if(!Q)return;const $=typeof performance<"u"?performance.now():Date.now(),F=U?.cameraMode??"absolute",W=Math.max(1,Math.min(180,U?.cameraSensitivity??60));if(F==="velocity"){const L=Math.min(50,$-A.current||16),Z=D*W*(L/1e3);if(Math.abs(Z)<.01)return;const ue=(typeof N.current=="number"?N.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof Q.homeAngle=="number"?Q.homeAngle:0)+Z;f(ue),N.current=ue,A.current=$;return}const re=typeof Q.minAngle=="number"?Q.minAngle:-45,ce=typeof Q.maxAngle=="number"?Q.maxAngle:45,H=typeof Q.homeAngle=="number"?Q.homeAngle:(re+ce)/2,q=D<0?H+D*(H-re):H+D*(ce-H);typeof N.current=="number"&&Math.abs(N.current-q)<.35&&$-A.current<80||(A.current=$,N.current=q,f(q))},[f,n.camera?.angle,n.camera?.config]),K=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>Mg(D=>{const U=gA(D.pads,K);if(!U){hf(y.current,ns)||(y.current=ns,l(ns,{source:Ws})),pf(S.current,as)||(S.current=as,o(as)),C.current=new Map,E.current={main:!1,side:!1},k.current=0,w.current=0,p(Ws,{connected:!1});return}if(Wj()){hf(y.current,ns)||(y.current=ns,l(ns,{source:Ws})),pf(S.current,as)||(S.current=as,o(as)),C.current=new Map,E.current={main:!1,side:!1},p(Ws,{connected:!0,blocked:!0});return}T(U);const Q=U.signature,$=x?.profiles?.[Q]??x?.defaults?.profile??la,F=Cg(U,$);if(!hf(F.driveVector,y.current)){const Z=typeof performance<"u"?performance.now():Date.now();(pA(F.driveVector)<.02||Z-k.current>=mA)&&(y.current=F.driveVector,k.current=Z,l(F.driveVector,{source:Ws}))}const W=$.calibration?.auxSideScale??.55,re=Math.round(Math.min(Math.abs(F.auxAxis.main),1)*127),ce=Math.round(Math.min(Math.abs(F.auxAxis.side),1)*127),H=E.current.main?-re:re,q=E.current.side?-Math.round(ce*W):Math.round(ce*W);let L={main:F.auxAxis.main!==0?H:0,side:F.auxAxis.side!==0?q:0,vacuum:F.buttons.vacuum?127:0};if(F.buttons.allAux&&(L={main:127,side:127,vacuum:127}),!pf(L,S.current)){const Z=typeof performance<"u"?performance.now():Date.now();(xA(L)||Z-w.current>=hA)&&(S.current=L,w.current=Z,o(L))}F.buttons.mainReverse&&M("mainReverse",!0)?E.current.main=!E.current.main:F.buttons.mainReverse||M("mainReverse",!1),F.buttons.sideReverse&&M("sideReverse",!0)?E.current.side=!E.current.side:F.buttons.sideReverse||M("sideReverse",!1),F.buttons.driveMacro&&M("driveMacro",!0)?(s("drive"),d("drive-sequence")):F.buttons.driveMacro||M("driveMacro",!1),F.buttons.dockMacro&&M("dockMacro",!0)?(s("dock"),d("seek-dock")):F.buttons.dockMacro||M("dockMacro",!1),F.buttons.nightVisionToggle&&M("nightVisionToggle",!0)?h():F.buttons.nightVisionToggle||M("nightVisionToggle",!1),Math.abs(F.cameraAxis)>.001&&O(F.cameraAxis,$.calibration),p(Ws,{connected:!0,signature:Q,id:U.id,index:U.index,axes:U.axes,buttons:U.buttons,drive:F.driveVector,aux:L,cameraAxis:F.cameraAxis,bindings:F.sources})}),[K,T,x?.defaults?.profile,x?.profiles,M,O,p,d,o,l,s,h]),null}function Rg(n){const s=n?.sensors||{},l=s.oiMode?.label||"Unknown",o=l.toLowerCase(),f=s.chargingState?.label||"",d=!!s.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:l,chargingLabel:f}}function qg(n){const s=ul(n);return m.useMemo(()=>Rg(s),[s])}function el({label:n,value:s,tone:l="neutral"}){const o=l==="good"?"border-emerald-200 bg-emerald-600 text-white":l==="warn"?"border-amber-200 bg-amber-600 text-white":l==="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:s})})}function nx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function xf({label:n,tone:s}){const l=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${l}`,children:n})}function bA({instructions:n,onConfirm:s,onCancel:l,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(Uf,{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:l,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:s,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function Tg({layout:n="desktop",expand:s=!1,fill:l=!1,driveDockState:o,compactHeightClass:f=""}){const d=n==="mobile",{state:{roverId:h,keymap:p},actions:x}=_t(),g=ul(h),v=o??Rg(g),{driving:y,docked:S,charging:E,dockingInProgress:C}=v,[k,w]=m.useState(null),[A,N]=m.useState(!1),[T,M]=m.useState(!1),O=!h||k!==null,K=!h||k!==null,D=Cn(p?.driveMacro?.[0]),U=Cn(p?.dockMacro?.[0]),Q={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"]},$="Click this button to initate auto-dock.",F={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},W=S?"Docked":"Undocked",re=S?"good":"bad",ce=E?"Charging":S?"Charging in 5s":"—",H=E?"good":S?"warn":"bad",q=async()=>{if(!(!h||k)){w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ve){alert(Ve.message)}finally{w(null)}}},L=async()=>{if(!(!h||k)){N(!1),M(!1),w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Ve){alert(Ve.message)}finally{w(null)}}},Z=async()=>{if(!(!h||k)){w("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(Ve){alert(Ve.message)}finally{w(null),N(!1),M(!1)}}},ae=()=>{K||(M(!0),N(!0))},ue="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",R="text-center",V="items-center justify-between",ne="items-center justify-center",se=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",oe="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",fe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",be="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=s||C,Le=xe?"h-full flex-1":l?"flex-1":"",De=d&&!xe?f:"",Ee=d&&!xe?ne:V,nt=d&&!xe&&y&&S;if(!y&&!C)return r.jsxs("button",{type:"button",onClick:L,onContextMenu:Ve=>Ve.preventDefault(),disabled:O,className:`${ue} ${Le} ${De} ${R} ${Ee} ${se} ${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:[D?r.jsx(nx,{label:D}):null,r.jsx(xf,{label:"Click to start",tone:"emerald"})]}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:F.summary}),r.jsx(Uf,{steps:F.steps,tone:"emerald"})]}):null]}),xe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(el,{label:"Dock",value:W,tone:re}),r.jsx(el,{label:"Charge",value:ce,tone:H})]}):null]});if(C){const Ve={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:O,onClick:q,onContextMenu:mt=>mt.preventDefault(),className:`${ue} ${Le} ${De} ${R} ${Ee} ${se} ${oe}`,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(xf,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?r.jsx("p",{className:"text-sm text-amber-50/90",children:Ve.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(el,{label:"Dock",value:W,tone:re}),r.jsx(el,{label:"Charge",value:ce,tone:H})]}),d?null:r.jsx(Uf,{steps:Ve.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:K,onClick:ae,onContextMenu:Ve=>Ve.preventDefault(),className:d?`flex w-full ${ue} ${De} ${R} ${Ee} ${se} ${nt?be:fe}`:`${ue} ${Le} ${R} ${V} ${se} ${fe}`,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:nt?"Docked!":"Dock and Charge"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[U?r.jsx(nx,{label:U}):null,r.jsx(xf,{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:$}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(el,{label:"Dock",value:W,tone:re}),r.jsx(el,{label:"Charge",value:ce,tone:H})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),T||!d&&A?r.jsx(bA,{instructions:Q,pending:k==="dock",onCancel:()=>{M(!1),N(!1)},onConfirm:Z}):null]})}function Uf({steps:n,tone:s="emerald"}){const l=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${l}`,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 gf(n){return typeof n=="boolean"}function Dg({nightVisionOn:n,disabled:s,onToggle:l,keyLabel:o,className:f="",heightClass:d=""}){const[h,p]=m.useState(gf(n)?n:null);m.useEffect(()=>{gf(n)&&p(n)},[n]);const x=gf(h),g=x?h:!1,v=x?g?"On":"Off":"—",y=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(s)return;const C=x?!g:!0;p(C),l?.(C)},E=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:S,onContextMenu:C=>C.preventDefault(),disabled:s,"aria-pressed":g,className:E,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 ${y}`,children:v})]})}function vf(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function _g({disabled:n,onStart:s,onStop:l,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[v,y]=m.useState(!1),[S,E]=m.useState(p),{value:C,save:k}=Ge("horn",os),[w,A]=m.useState(C?.waveform||os.waveform),[N,T]=m.useState(()=>[...Array.isArray(C?.freqs)?C.freqs:os.freqs,0,0,0,0].slice(0,4).map(q=>vf(q)));m.useEffect(()=>{A(C?.waveform||os.waveform),Array.isArray(C?.freqs)&&T([...C.freqs,0,0,0,0].slice(0,4).map(H=>vf(H)))},[C?.freqs,C?.waveform]);const M=!!f,O=Math.max(0,Math.min(1,Number(d)||0)),K=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",h].filter(Boolean).join(" "),[h,M]),D=()=>{n||v||(y(!0),s?.())},U=()=>{v&&(y(!1),l?.())};m.useEffect(()=>{!M&&v&&y(!1)},[M,v]);const Q=w==="sine"?"sine":"saw",$=m.useCallback(H=>{const q=H.target.value==="sine"?"sine":"saw";A(q),k(L=>({...L??{},waveform:q}))},[k]),F=m.useCallback((H,q)=>{T(L=>{const Z=[...L];return Z[H]=vf(q),k(ae=>({...ae??{},freqs:Z})),Z})},[k]),W=H=>{if(n)return;const q=H.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(H.preventDefault(),D())},re=H=>{const q=H.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(H.preventDefault(),U())},ce=x?r.jsx("button",{type:"button",onClick:H=>{H.preventDefault(),E(q=>!q)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:S?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:W,onPointerUp:re,onPointerLeave:U,onPointerCancel:U,onContextMenu:H=>H.preventDefault(),onBlur:U,className:K,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${O*100}%, rgba(0,0,0,0) ${O*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"})]}),S?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:Q,onChange:$,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:N.map((H,q)=>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:q+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:H,onChange:L=>F(q,L.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-${q}`))})]}):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:Q,onChange:$,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"})]})]}),N.map((H,q)=>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:q+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:H,onChange:L=>F(q,L.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-${q}`))]}):null]})}function Pr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function ax({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Bg({value:n,min:s,max:l,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:v,keyUpLabel:y,className:S="",labelRowClass:E="",labelClass:C="",valueClass:k="",sliderClass:w="",endpointClass:A="",endpointLabelClass:N="",accentClass:T="",showValue:M=!0,showEndpoints:O}){const K=d==="vertical",U=typeof O=="boolean"?O:!K,[Q,$]=m.useState(n),F=m.useRef(!1),W=m.useRef(null);m.useEffect(()=>{F.current||$(n)},[n]),m.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]);const re=Z=>{if(h){if(x>0){W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{h(Z)},x);return}h(Z)}},ce=Z=>{const ae=Number.parseFloat(Z.target.value);Number.isNaN(ae)||(F.current=!0,$(ae),re(ae))},H=()=>{F.current=!1,W.current&&(clearTimeout(W.current),W.current=null),p?p(Q):x>0&&h?.(Q)};if(typeof s!="number"||typeof l!="number")return null;const q=[K?"h-28 w-5":"w-full",T,w].filter(Boolean).join(" "),L=r.jsx("input",{type:"range",orient:K?"vertical":void 0,min:s,max:l,step:o,value:Number.isFinite(Q)?Q:s,onChange:ce,onMouseUp:H,onTouchEnd:H,onPointerUp:H,disabled:g,className:q,style:K?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return K?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[M?r.jsx("div",{className:`flex flex-col items-center ${E}`.trim(),children:r.jsx("span",{className:k,children:Pr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:C,children:f}),L]})]}):r.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${E}`.trim(),children:[r.jsx("span",{className:C,children:f}),M?r.jsx("span",{className:k,children:Pr(n)}):null]}),r.jsxs("div",{children:[L,U?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${A}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${N}`.trim(),children:[v?r.jsx(ax,{label:v}):null,Pr(s)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${N}`.trim(),children:[Pr(l),y?r.jsx(ax,{label:y}):null]})]}):null]})]})}function yA({disabled:n,layout:s,radius:l,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),y=m.useCallback(k=>{if(n||h.current!==null)return;k.preventDefault();const w=d.current;if(!w)return;const A=w.getBoundingClientRect(),N=k.clientX-A.left,T=k.clientY-A.top;p.current={x:N,y:T},h.current=k.pointerId,w.setPointerCapture?.(k.pointerId),g({active:!0,base:{x:N,y:T},knob:{x:0,y:0}})},[n]),S=m.useCallback(k=>{if(n||h.current!==k.pointerId)return;k.preventDefault();const w=d.current;if(!w)return;const A=w.getBoundingClientRect(),N=k.clientX-A.left,T=k.clientY-A.top,M=N-p.current.x,O=T-p.current.y,K=Math.min(Math.hypot(M,O),l),D=Math.atan2(O,M),U=Math.cos(D)*K,Q=Math.sin(D)*K,$={x:ll(U/l),y:ll(-Q/l),boost:!1};g(F=>({...F,knob:{x:U,y:Q}})),o?.($)},[n,o,l]),E=m.useCallback(k=>{if(h.current!==k.pointerId)return;k.preventDefault(),d.current?.releasePointerCapture?.(k.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),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:y,onPointerMove:S,onPointerUp:E,onPointerLeave:E,onPointerCancel:E,onContextMenu:k=>k.preventDefault(),children:[!x.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:x.base.x,top:x.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function sx({id:n,label:s,values:l,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:p=>{p.preventDefault(),d(n,l)},onPointerUp:()=>h(n),onPointerLeave:()=>h(n),onPointerCancel:()=>h(n),onContextMenu:p=>p.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:s})}const Wr="mobile-joystick",SA=80,jA=.15,AA={main:0,side:0,vacuum:0},NA={main:127,side:127,vacuum:127},wA={main:-127,side:-127,vacuum:-127};function CA({layout:n}){const{state:{roverId:s},actions:{setDriveVector:l,registerInputState:o}}=_t(),f=qg(s),d=f.docked&&!f.driving,h=d||f.dockingInProgress,p=!s,x=SA,g=jA,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(v.current={x:0,y:0,boost:!1})},[p]);const y=m.useCallback((k={})=>{if(p)return;const w={x:ll(k.x??0),y:ll(k.y??0),boost:!!k.boost},A={x:v.current.x+(w.x-v.current.x)*(1-g),y:v.current.y+(w.y-v.current.y)*(1-g),boost:w.boost};v.current=A,l(A,{source:Wr}),o(Wr,{vector:A,lastEvent:"move"})},[p,o,l,g]),S=m.useCallback(()=>{if(p)return;const k={x:0,y:0,boost:!1};v.current=k,l(k,{source:Wr}),o(Wr,{vector:k,lastEvent:"stop"})},[p,o,l]),C=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:C,children:[r.jsx(Tg,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(yA,{disabled:p,layout:n,radius:x,onMove:y,onStop:S})})]})}function EA({layout:n}){const{state:{roverId:s,camera:l,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=_t(),v=!s,y=m.useRef(null),S=l?.config,E=!!(s&&l?.enabled&&S),C=!!(s&&f?.nightVision),k=f?.nightVisionState,w=!!(s&&f?.horn),A=o?.overheated,N=typeof S?.minAngle=="number"?S.minAngle:-45,T=typeof S?.maxAngle=="number"?S.maxAngle:45,M=typeof l?.angle=="number"?l.angle:typeof S?.homeAngle=="number"?S.homeAngle:(N+T)/2,O=m.useCallback(U=>{C&&h(U)},[C,h]),K=m.useCallback((U,Q)=>{v||(y.current=U,p(Q))},[v,p]),D=m.useCallback(U=>{v||y.current===U&&(y.current=null,p(AA))},[v,p]);return r.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[r.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[r.jsx(sx,{id:"aux-vac-forward",label:"Vacuum Forward",values:NA,color:"bg-fuchsia-600",disabled:v,onPress:K,onRelease:D}),r.jsx(sx,{id:"aux-vac-backward",label:"Vacuum Backward",values:wA,color:"bg-fuchsia-800",disabled:v,onPress:K,onRelease:D})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[E?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(Bg,{value:M,min:N,max:T,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,C?r.jsx(Dg,{nightVisionOn:k?.nightVisionOn,disabled:v,onToggle:O,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:w?r.jsx(_g,{disabled:v||A,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function bo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(EA,{layout:n})})}function yo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(CA,{layout:n==="landscape"?"landscape":"portrait"})})}function kA({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",l=n?r.jsx(yo,{layout:"portrait",className:s}):r.jsx(bo,{layout:"portrait",className:s}),o=n?r.jsx(bo,{layout:"portrait",className:s}):r.jsx(yo,{layout:"portrait",className:s});return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[l,o]})})}function MA(n=[],s={}){const l=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(C=>typeof C=="string"?C:C.id),[n]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),v=m.useRef([]),[y,S]=m.useState(0),E=m.useRef(new Map);return m.useEffect(()=>{if(!l)return;const C=()=>S(k=>k+1);return l.on("connect",C),()=>l.off("connect",C)},[l]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({});return}if(!v.current.length||!l)return;let C=!1;const k=v.current,w=(N={},T)=>{if(C||!N.id||!T)return;const M=T.byteLength??T.length??0,O=Date.now(),K=E.current.get(N.id)||{count:0,totalBytes:0,lastLogAt:0},D={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!D.lastLogAt||O-D.lastLogAt>=1e4){const F=D.count?D.totalBytes/D.count:0;console.log("[roomCamera]",N.id,`frame=${M}B`,`avg=${Math.round(F)}B`,`count=${D.count}`),D.lastLogAt=O}E.current.set(N.id,D);const U=new Blob([T],{type:"image/jpeg"}),Q=URL.createObjectURL(U),$=p.current.get(N.id);$&&URL.revokeObjectURL($),p.current.set(N.id,Q),h(F=>({...F,[N.id]:{status:"playing",ts:N.ts||Date.now(),error:null,objectUrl:Q}}))},A=(N={})=>{C||!N.id||h(T=>({...T,[N.id]:{...T[N.id]||{},status:N.error?"error":T[N.id]?.status||"connecting",error:N.error||null,ts:N.ts||T[N.id]?.ts||null,objectUrl:T[N.id]?.objectUrl||null}}))};return l.on("roomCamera:frame",w),l.on("roomCamera:status",A),l.emit("roomCamera:subscribe",{ids:k},(N={})=>{N.error}),()=>{C=!0,l.emit("roomCamera:unsubscribe",{ids:k}),l.off("roomCamera:frame",w),l.off("roomCamera:status",A),p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear()}},[l,g,o,y]),d}function RA({feed:n,label:s}){const[l,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:s,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:s}),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 ${l?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function qA(){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 Og=["horizontal","vertical"];function bf(n,s){return Og.includes(n)?n:s}function fd({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:l=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=nn(),h=d?.roomCameras||[],p=MA(h.map(w=>({id:w.id}))),{value:x,save:g}=Ge("roomCameraPanels",{}),[v,y]=m.useState(()=>bf(f?x?.[f]:n,"horizontal"));m.useEffect(()=>{if(!f)return;const w=x?.[f];w&&y(bf(w,"horizontal"))},[f,x?.[f]]);const S=s?bf(s,"horizontal"):v,E=S==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!l&&!s&&h.length>0,k=w=>{y(w),f&&g(A=>({...A||{},[f]:w}))};return h.length===0?r.jsx(qA,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:C&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Og.map(w=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${S===w?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>k(w),children:w==="vertical"?"Vertical":"Grid"},w))})]})})]}),r.jsx("div",{className:E,children:h.map(w=>{const A=p[w.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(RA,{feed:A,label:w.name||w.id})},w.id)})})]})}function dd(){const n=it(s=>s.logs);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(s=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:s.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",s.level,"]"]})," ",s.label&&r.jsxs("span",{className:"text-teal-400",children:["[",s.label,"]"]})," ",r.jsx("span",{children:s.message})]},s.id))})]})}function TA(n){if(!n)return null;if(typeof n=="string"){const s=String(n).trim();return s?{type:"rover",id:s,key:s}:null}if(typeof n=="object"){if(n.type&&n.id){const s=String(n.id);let l=n.key;return l||(l=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:l}}if(n.roverId){const s=String(n.roverId);return{type:"rover",id:s,key:n.key||s}}if(n.roomCameraId){const s=String(n.roomCameraId);return{type:"room",id:s,key:n.key||`room:${s}`}}}return null}function DA(n=[]){const s=new Set,l=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),l.push(o))}),l.sort((o,f)=>o.key.localeCompare(f.key))}function yi(n=[],s={}){const l=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(n)?DA(n.map(TA).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const E=p.map(C=>`${C.type}:${C.id}:${C.key}`).join("|");return f?`${E}|v:${f}`:E},[p,f]),g=m.useRef([]),[v,y]=m.useState(0);return m.useEffect(()=>{if(!l)return;const E=()=>y(C=>C+1);return l.on("connect",E),()=>{l.off("connect",E)}},[l]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const E=g.current;let C=!1;function k(w){const A=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};l.emit("video:request",A,(N={})=>{C||h(T=>({...T,[w.key]:N}))})}return E.forEach(w=>{k(w)}),()=>{C=!0}},[l,x,o,v]),m.useMemo(()=>{if(!x||!o)return{};const E={};return p.forEach(C=>{d[C.key]&&(E[C.key]=d[C.key])}),E},[x,d,p])}function md(n=[],s={}){const l=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(C=>typeof C=="string"?C:C.id).filter(Boolean),[n]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),v=m.useRef([]),[y,S]=m.useState(0),E=m.useRef(new Map);return m.useEffect(()=>{if(!l)return;const C=()=>S(k=>k+1);return l.on("connect",C),()=>l.off("connect",C)},[l]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({});return}if(!v.current.length||!l)return;let C=!1;const k=v.current,w=(N={},T)=>{if(C||!N.id||!T)return;const M=T.byteLength??T.length??0,O=Date.now(),K=E.current.get(N.id)||{count:0,totalBytes:0,lastLogAt:0},D={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!D.lastLogAt||O-D.lastLogAt>=1e4){const F=D.count?D.totalBytes/D.count:0;console.log("[roverSnapshot]",N.id,`frame=${M}B`,`avg=${Math.round(F)}B`,`count=${D.count}`),D.lastLogAt=O}E.current.set(N.id,D);const U=new Blob([T],{type:"image/jpeg"}),Q=URL.createObjectURL(U),$=p.current.get(N.id);$&&URL.revokeObjectURL($),p.current.set(N.id,Q),h(F=>({...F,[N.id]:{status:"playing",ts:N.ts||Date.now(),error:null,objectUrl:Q}}))},A=(N={})=>{C||!N.id||h(T=>({...T,[N.id]:{...T[N.id]||{},status:N.error?"error":T[N.id]?.status||"connecting",error:N.error||null,ts:N.ts||T[N.id]?.ts||null,objectUrl:T[N.id]?.objectUrl||null}}))};return l.on("roverSnapshot:frame",w),l.on("roverSnapshot:status",A),l.emit("roverSnapshot:subscribe",{ids:k},(N={})=>{N.error}),()=>{C=!0,l.emit("roverSnapshot:unsubscribe",{ids:k}),l.off("roverSnapshot:frame",w),l.off("roverSnapshot:status",A),p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear()}},[l,g,o,y]),d}const _A={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function BA(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 OA(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${BA(s)}`}}class lx{constructor({url:s,token:l,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=s,this.token=l,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(s,l){typeof this.onStatus=="function"&&this.onStatus(s,l)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const s=new RTCPeerConnection(_A);this.pc=s;const l=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>l.addTrack(f)),this.video.srcObject=l,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...OA(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 s.setRemoteDescription({type:"answer",sdp:d}),s.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function Lg(){const{value:n,save:s}=Ge("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,f=>{s({hudMapDesktop:!!f})}]}const LA={discord:dg,kofi:U0,"ko-fi":U0,wiki:bj,throne:yj},zA={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 UA(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const s=document.createElement("style");s.id=n,s.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(s)},[])}function HA(n,s){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof s=="string"&&s.trim()?s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function hd({id:n,label:s,url:l,className:o=""}){if(!l)return null;UA();const f=HA(n,s),d=LA[f]||Sj,h=zA[f]||null,p=s||n||"Link";return r.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),p]})}const Si=10;function zg({batteryState:n=null,charge:s=null,config:l=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,f=n?.warnActive??null,d=n?.urgentActive??null,h=l?.Full??null,p=l?.Warn??null,x=l?.Urgent??null,g=s??n?.charge??null;let v=o;if(v==null&&(v=VA({charge:g,full:h,warn:p,urgent:x})),v==null)return{available:!1};const y=Math.max(0,Math.min(1,v/100)),S=f??(p!=null&&g!=null&&g<=p),E=d??(x!=null&&g!=null&&g<=x);return{available:!0,percent:y,percentDisplay:v,warnActive:S,urgentActive:E,warnDisplayPercent:Si}}function VA({charge:n,full:s,warn:l,urgent:o}){if(n!=null&&s!=null&&l!=null&&o!=null&&s>l&&l>o){const f=Si/100,d=1-f;if(n<=o)return 0;if(n<=l){const p=(n-o)/(l-o);return Math.round(Math.max(0,Math.min(1,p))*Si)}if(n>=s)return 100;const h=(n-l)/(s-l);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const $A=1600,GA=800;function Nn(...n){return n.filter(Boolean).join(" ")}function Hf({visual:n,orientation:s="horizontal",variant:l="inline",compact:o=!1,showLabel:f,className:d=""}){const h=l==="background",p=s==="vertical",x=f??!h;if(!n?.available){if(h){const W=Si,re=Nn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",E&&!S&&"battery-tick-warn"),ce=p?{bottom:`${W}%`}:{left:`${W}%`},H=Nn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:H,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:re,style:ce})]})}return p?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,v=Math.max(0,Math.min(100,g)),y=n.warnDisplayPercent??Si,S=!!n.urgentActive,E=!!n.warnActive,C=S?`${GA}ms`:E?`${$A}ms`:void 0,w=h?S||E?"bg-red-500/45":"bg-emerald-500/45":S||E?"bg-red-500":"bg-emerald-500",A=S||E?"bg-red-900/35":"bg-slate-900/35",N=S||E?"bg-red-900/45":"bg-slate-900/35",T=Nn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const W=p?{height:`${v}%`}:{width:`${v}%`},re=Nn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),ce=Nn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",E&&!S&&"battery-tick-warn"),H=p?{bottom:`${y}%`}:{left:`${y}%`};return r.jsxs("div",{className:T,children:[r.jsx("div",{className:Nn("absolute inset-0",A,S&&"battery-urgent-flash")}),r.jsx("div",{className:re,style:{...W,animationDuration:C}}),r.jsx("div",{className:ce,style:H})]})}const M=Nn("relative overflow-hidden rounded-sm border border-slate-800",S||E?N:"bg-zinc-900/90",S&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),O=p?{height:`${v}%`}:{width:`${v}%`},K=Nn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),D=Nn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",E&&!S&&"battery-tick-warn"),U=p?{bottom:`${y}%`}:{left:`${y}%`},Q=`Battery ${g}%`,$=Nn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",p?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),F=Nn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:T,children:[r.jsxs("div",{className:M,children:[r.jsx("div",{className:K,style:{...O,animationDuration:C}}),r.jsx("div",{className:D,style:U})]}),x&&!p?r.jsx("div",{className:$,children:r.jsx("span",{className:F,children:Q})}):null,x&&p?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:F,children:[g,"%"]})}):null]})}function YA({mobileHud:n=!1,isActiveDriver:s=!1,idleSkipSeconds:l=null}){const o=n?"text-3xl":"text-5xl",f=n?"text-xs":"text-sm",d=n?"text-[0.55rem]":"text-[0.75rem]",h=n?"px-4 py-3":"px-6 py-4",p=s&&typeof l=="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 ${o}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${f}`,children:"Start driving!"}),p?r.jsxs("div",{className:`text-red-100/90 ${d}`,children:["Idle skip in ",l,"s"]}):null]})})}function Mo(n){return Math.max(0,Math.min(1,n))}function Ug(n){return(n-90)*Math.PI/180}function pi(n,s,l,o){const f=Ug(o);return{x:n+l*Math.cos(f),y:s+l*Math.sin(f)}}function FA(n,s,l,o,f){let d=o,h=f;h<=d&&(h+=360);const p=pi(n,s,l,d),x=pi(n,s,l,h);return["M",p.x,p.y,"A",l,l,0,0,1,x.x,x.y].join(" ")}function pd(n,s){if(s)return"#ef4444";const l=Math.abs(n);return l>900?"#f59e0b":l>300?"#22c55e":"#64748b"}function XA(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Mo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function QA(n,s){if(s)return"#ef4444";const l=Mo(n==null?0:n/4095),o=[47,55,69],f=[245,158,11],[d,h,p]=o.map((x,g)=>Math.round(x+(f[g]-x)*l));return`rgb(${d}, ${h}, ${p})`}function KA({count:n,totalSpan:s,gap:l,startAngle:o}){const d=(s-l*(n-1))/n,h=[];let p=o;for(let x=0;x<n;x+=1){const g=p+d;h.push({start:p,end:g}),p=g+l}return h}function yf({cx:n,cy:s,rInner:l,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:p=!1,opacity:x=1}){const g=(l+o)/2,v=o-l,y=FA(n,s,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:y,stroke:h,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:x}),p?r.jsx("path",{d:y,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function ZA({cx:n,cy:s,rBase:l,rTip:o,startDeg:f,endDeg:d,color:h,value:p,max:x}){const g=(f+d)/2,v=pi(n,s,o,g),y=Mo(p!=null?p/(x||1):0),S=Math.pow(y,.35),E=l-(l-o)*S,C=Math.max(o,Math.min(E,l)),k=pi(n,s,C,f),w=pi(n,s,C,d),A=`M ${v.x} ${v.y} L ${k.x} ${k.y} L ${w.x} ${w.y} Z`;return r.jsx("path",{d:A,fill:h,opacity:1,stroke:"none"})}function ix({cx:n,cy:s,current:l,drop:o,overcurrent:f,label:d}){const h=Math.abs(l),p=Mo(h/1200),x=pd(l,f),g=56,v=14,y=9,S=3,E=g*p,C=d==="L"?-1:1,k=C*(-y/2-S/2),w=C*(v/2+S/2),A=v+y+S+2,N=g+4;return r.jsxs("g",{transform:`translate(${n},${s})`,children:[r.jsx("rect",{x:-A/2,y:-N/2,width:A,height:N,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:k-v/2,y:-g/2,width:v,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:k-v/2,y:g/2-E,width:v,height:E,fill:x,className:f?"animate-pulse":""}),r.jsx("rect",{x:w-y/2,y:-g/2,width:y,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 IA({cx:n,cy:s,current:l,overcurrent:o}){let f=Math.abs(l);f<10&&(f=0);const d=pd(l*3,o),h=43,p=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const v=Ug(g),y=n+h*Math.cos(v),S=s+h*Math.sin(v);return r.jsx("line",{x1:n,y1:s,x2:y,y2:S,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:s,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function JA({cx:n,cy:s,current:l,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const p=Math.abs(l),x=pd(l,o),g=1,v=96,y=12,S=`main-brush-pattern-a-${f}`,E=`main-brush-pattern-b-${f}`,C=p>0?.6:null,k=l>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[S,E].map((w,A)=>r.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),C?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${k*(A===0?6:-6)}`,dur:`${C}s`,repeatCount:"indefinite"}):null]},w))}),r.jsx("rect",{x:n-v/2,y:s-14,width:v,height:y,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-v/2,y:s+4,width:v,height:y,rx:"3",fill:`url(#${E})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-v/4,cy:s-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+v/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-v/2-4,y:s-16,width:v+8,height:y*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function Vf({sensors:n={},variant:s="full",size:l,overlay:o=!1}){const f=l||(s==="mini"?190:260),d=f/2,h=f*.07,p=d,x=d+h,g=d*.8,v=g-4,y=g+4,S=g-14,E=g-6,C=g*.65,k=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},A=n?.wheelLeftCurrentMa??0,N=n?.wheelRightCurrentMa??0,T=n?.sideBrushCurrentMa??0,M=n?.mainBrushCurrentMa??0,O=6,K=k.bumpLeft?O:0,D=k.bumpRight?O:0,U=KA({count:6,totalSpan:140,gap:6,startAngle:-70}),Q=["L","FL","CL","CR","FR","R"],$=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],F=U.map((H,q)=>({label:Q[q],start:H.start,end:H.end,value:$[q]})),W=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],re=$.filter(H=>H!=null),ce=re.length?Math.max(...re,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:p,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(ix,{cx:p-C,cy:x,current:A,drop:k.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),r.jsx(ix,{cx:p+C,cy:x,current:N,drop:k.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),r.jsx(IA,{cx:p+g*.65,cy:x-g*.55,current:T,overcurrent:w.sideBrush}),r.jsx(JA,{cx:p,cy:x,current:M,overcurrent:w.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),F.map(H=>{const q=XA(H.value,ce),L=y+4,Z=L+28;return r.jsx(ZA,{cx:p,cy:x,rBase:Z,rTip:L,startDeg:H.start,endDeg:H.end,color:q,value:H.value,max:ce},H.label)}),W.map(H=>r.jsx(yf,{cx:p,cy:x,rInner:S,rOuter:E,startDeg:H.start,endDeg:H.end,color:QA(H.value,H.active),opacity:1,pulse:!!H.active},H.label)),r.jsx(yf,{cx:p,cy:x,rInner:v-K,rOuter:y-K,startDeg:-70,endDeg:-6,color:k.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!k.bumpLeft}),r.jsx(yf,{cx:p,cy:x,rInner:v-D,rOuter:y-D,startDeg:6,endDeg:70,color:k.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!k.bumpRight})]})]})}function PA({sensors:n,label:s,roverColor:l=null,status:o,audioStatus:f,levelStatus:d,layoutFormat:h="desktop",variant:p="default",driverLabel:x=null,showTopDown:g=!1,mobileHud:v=!1,mapPosition:y="top-center",turnTimerText:S=null,labelScale:E=1}){const C=v,k=h==="mobile-portrait",w=C?"text-[0.45rem]":"text-[0.65rem]",A=C?"px-0.25 py-0.25":"px-1 py-0.5",N=C?"px-0.25 py-0.25":"px-0.5 py-0.5",T=C?"text-[0.55rem]":"text-[0.8rem]",M=C?"left-0.5 top-0.5":"left-1 top-1",O=C?"text-[0.5rem]":"text-[0.7rem]",K=C?"px-0.5 py-0.25":"px-1 py-0.5",D=C?"left-0.5 top-1/2":"left-1 top-1/2",U="bottom-0.5",Q={transform:`translateX(-50%) scale(${E})`,transformOrigin:"center bottom"},$="240px",F=k?.3:C?.33:.7,re={width:$,height:$,opacity:C?.6:.7,transform:y==="top-center"?`translateX(-50%) scale(${F})`:`scale(${F})`,transformOrigin:y==="bottom-left"?"bottom left":y==="top-center"?"top center":"top right",...y==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:y==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(p==="none")return null;if(p==="spectator"){const ce=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],H=!!n?.chargingSources?.homeBase,q=n?.chargingState?.label||"",L=!!(q&&q.toLowerCase()!=="not charging"),Z=n?.oiMode?.label||"Unknown",ae=Z.toLowerCase(),ue=ae==="full"?"bg-emerald-500/80 text-emerald-50":ae==="safe"?"bg-amber-400/80 text-amber-950":ae==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",R=H?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",V=L?"bg-emerald-500/80 text-emerald-50":H?"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 ${M} font-medium text-slate-100 ${w}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),r.jsx("div",{className:`absolute ${D} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${w} ${A}`,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 ${R}`,children:H?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${V}`,children:L?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ue}`,children:["OI: ",Z]})]}),ce.map(([ne,se])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ne}),r.jsx("span",{className:"font-semibold text-white",children:se})]},ne))]})}),r.jsx("div",{className:`absolute ${U} left-1/2`,style:Q,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${N} ${T}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:oa(l,.18),children:s||"Unnamed Rover"}),x?r.jsxs("span",{className:"text-slate-300",children:["• ",x]}):null]})})]}),g?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...re},children:r.jsx(Vf,{sensors:n,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 ${M} font-medium text-slate-100 ${w}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),S?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${K} ${O}`,children:S}):null,r.jsx("div",{className:`absolute ${U} left-1/2`,style:Q,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${N} ${T}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:oa(l,.18),children:['"',s||"Unnamed Rover",'"']})]})})}),g&&p!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...re},children:r.jsx(Vf,{sensors:n,size:240,overlay:!0})}):null]})}const rx=2e3,WA=3e3,eN=3e3,tN=40,nN=1e3,aN={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function sN({motors:n,fill:s=0,compact:l=!1}){if(!n?.length)return null;const o=n.map(v=>aN[v]||v),f=l?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=l?"px-2 py-1":"px-4 py-2",h=l?"text-lg":"text-4xl",p=l?"text-xs":"text-xl",x=Math.max(0,Math.min(1,s)),g=`${Math.round(x*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}function lN({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const l=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",f=s?"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:l})})})}function iN({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],l=s.filter(p=>p!=null).reduce((p,x)=>Math.max(p,x),1200),o=p=>Math.pow(Math.max(0,Math.min(1,(p??0)/l)),.35),f=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((p,x)=>{const g=o(p),v=x<d/2?-1:1,y=`${g*100}%`,S=f(p);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:y,background:S,float:v===-1?"right":"left"}})})},x)})})}function rN({compact:n=!1}){const s=it(D=>D.session),{sendMessage:l,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:p}=od(),{value:x}=Ge("tts",{engine:"flite",voice:"rms",pitch:50}),[g,v]=m.useState(""),[y,S]=m.useState(!1),E=s?.role!=="spectator",C=s?.role==="spectator",k=s?.assignment?.roverId||null,A=!!m.useMemo(()=>s?.roster?.find(D=>String(D.id)===String(k))||null,[k,s?.roster])?.audio?.ttsEnabled,N=m.useMemo(()=>{if(!A)return null;const D=x?.engine==="espeak"?"espeak":"flite";if(D==="espeak"){let Q=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof Q=="number"&&(Q=Math.max(0,Math.min(99,Q))),{speak:!0,engine:D,pitch:Q}}const U=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:D,voice:U}},[x?.engine,x?.pitch,x?.voice,A]),T=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",O=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 K(D){if(D.preventDefault(),!E)return;const U=g.trim();if(U){S(!0);try{await l(U,N),v(""),d(),p(!1)}catch(Q){alert(Q.message)}finally{S(!1)}}}return C?null:r.jsxs("form",{onSubmit:K,className:T,children:[r.jsx("input",{className:M,value:g,onChange:D=>{const U=D.target.value;v(U),p(!!U.trim())},onFocus:D=>{o(D),p(!!g.trim())},onBlur:D=>{f(D),p(!1)},onKeyDown:D=>{D.key==="Enter"&&!g.trim()&&(D.preventDefault(),d(),p(!1))},ref:D=>h(D,{target:"hud"}),placeholder:E?"Chat (TTS)":"Spectator",disabled:!E}),r.jsx("button",{type:"submit",disabled:!E||y,className:O,children:"Speak"})]})}function ji({sessionInfo:n,audioSessionInfo:s,videoMode:l="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,roverColor:h=null,forceMute:p=!1,telemetryFrame:x,batteryConfig:g,layoutFormat:v="desktop",hudVariant:y="default",driverLabel:S=null,hudForceMap:E=!1,hudMapPosition:C="top-center",hudLabelScale:k=1,fitParent:w=!1,overcurrentLimiter:A=null,showTurnCue:N=!1,turnTimerText:T=null,isActiveDriver:M=!1,idleSkipSeconds:O=null}){const K=it(ye=>ye.session),D=m.useRef(null),U=m.useRef(null),Q=m.useRef(null),$=m.useRef(null),F=m.useRef(null),W=m.useRef(null),re=m.useRef(null),ce=m.useRef(null),[H,q]=m.useState("idle"),[L,Z]=m.useState(null),[ae,ue]=m.useState("idle"),[R,V]=m.useState(null),[ne,se]=m.useState(0),[pe,oe]=m.useState(0),[fe,be]=m.useState(!0),ve=!!s?.url,xe=l==="snapshot",Le=x?.sensors,{value:De}=Ge("audio",st),Ee=Number.isFinite(De?.masterVolume)?De.masterVolume:st.masterVolume,nt=Number.isFinite(De?.roverVolume)?De.roverVolume:st.roverVolume,Ve=typeof De?.mainBrushDuckEnabled=="boolean"?De.mainBrushDuckEnabled:typeof De?.autoLevelEnabled=="boolean"?De.autoLevelEnabled:st.mainBrushDuckEnabled,mt=Number.isFinite(De?.mainBrushDuckAmount)?Math.max(0,Math.min(1,De.mainBrushDuckAmount)):st.mainBrushDuckAmount,ie=Math.max(0,Math.min(1,Ee*nt)),me=Le?.batteryChargeMah??null,J=!(v==="desktop"),he=J?"top-right":C,[Ae]=Lg(),ht=E||J?!0:Ae,Oe=zg({charge:me,config:g}),rt=Le?.wheelOvercurrents||null,ot=rt==null?[]:Object.entries(rt).filter(([,ye])=>!!ye).map(([ye])=>ye),gt=A?.caps||null,kt=A?.overcurrent?.groups||null,fs=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),Lt=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),fl=m.useMemo(()=>{if(!gt)return null;const ye=Number.isFinite(gt?.drive?.cap)?gt.drive.cap:1,Ie=Number.isFinite(gt?.aux?.cap)?gt.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(ye,Ie)))},[gt]),dl=!!A?.isActive,yn=ot.length?ot:dl?["limiter"]:[],wt=fl??(ot.length?1:0),an=!!yn.length,vt=!!((Number(Le?.mainBrushCurrentMa)||0)>tN||Le?.wheelOvercurrents?.mainBrush),Oo=Ve&&vt?1-mt:1,ds=Math.max(0,Math.min(1,ie*Oo)),Lo=Ve&&vt&&mt>0?`Volume decreased ${Math.round(mt*1e3)/10}%`:null,Oa=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Oa.current={hasDedicatedAudio:ve,audioUrl:s?.url||null,mainBrushDuckEnabled:Ve,mainBrushDuckAmount:mt,mainBrushActive:vt,baseRoverGain:ie,effectiveRoverGain:ds}},[ve,s?.url,Ve,mt,vt,ie,ds]);const We=m.useCallback((ye,Ie={})=>{if(!fs)return;const Je=U.current,ke=Oa.current,Ye={event:ye,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:ke.hasDedicatedAudio,audioUrl:ke.audioUrl,mainBrushDuckEnabled:ke.mainBrushDuckEnabled,mainBrushDuckAmount:ke.mainBrushDuckAmount,mainBrushActive:ke.mainBrushActive,baseRoverGain:ke.baseRoverGain,effectiveRoverGain:ke.effectiveRoverGain,element:Je?{muted:Je.muted,volume:Je.volume,paused:Je.paused,ended:Je.ended,readyState:Je.readyState,networkState:Je.networkState}:null,...Ie};try{console.log(`[AudioDebug] ${ye} ${JSON.stringify(Ye)}`)}catch{console.log("[AudioDebug]",ye,Ye)}},[fs,d]),ms=K?.socials?.find(ye=>String(ye?.id||ye?.label||"").toLowerCase()==="discord")?.url||K?.discord?.invite||null;m.useEffect(()=>{Lt&&console.log("[OvercurrentHUD]",{overlayVisible:an,overlayMotors:yn,overlayFill:wt,limiterActive:dl,limiterCaps:gt,limiterGroups:kt,wheelOvercurrents:rt})},[Lt,wt,yn,an,dl,gt,kt,rt]),m.useEffect(()=>{We("settings/update")},[We]);const Ft=m.useCallback(()=>{clearTimeout(Q.current),Q.current=setTimeout(()=>se(Date.now()),rx)},[]),ua=m.useCallback(()=>{clearTimeout($.current),$.current=setTimeout(()=>oe(Date.now()),rx)},[]),Mn=m.useCallback(async()=>{const ye=D.current;if(ye)try{ye.muted=!0,await ye.play()}catch{}},[]),qi=m.useCallback((ye=0)=>{if(p||ve)return;clearTimeout(W.current);const Ie=()=>{clearTimeout(W.current),W.current=setTimeout(()=>{p||Je()},WA)},Je=async()=>{const ke=D.current;if(ke)try{await Mn(),ke.muted=!1,await ke.play(),be(!1)}catch{ke.muted=!0,be(!0),Ie()}};W.current=setTimeout(Je,ye)},[Mn,p,ve]);m.useEffect(()=>()=>{clearTimeout(Q.current),clearTimeout($.current),clearTimeout(W.current),clearInterval(F.current),re.current&&(cancelAnimationFrame(re.current),re.current=null)},[]),m.useEffect(()=>{H==="playing"&&qi(0)},[H,qi]),m.useEffect(()=>{xe&&(q("snapshot"),Z(null))},[xe]),m.useEffect(()=>{if(xe||!n?.url||!D.current)return;let ye=!0,Ie;const Je=setTimeout(()=>be(!0),0),ke=(Ye,Mt)=>{ye&&(We("video/status",{nextStatus:Ye,info:Mt||null}),q(Ye),Z(Mt||null),Ye==="playing"&&Mn(),["error","failed","disconnected","closed"].includes(Ye)&&Ft())};return Ie=new lx({url:n.url,token:n.token,video:D.current,receiveAudio:!ve,onStatus:ke}),Ie.start().catch(Ye=>{ye&&(q("error"),Z(Ye.message),Ft())}),()=>{ye=!1,clearTimeout(Je),Ie?.stop()}},[xe,n?.url,n?.token,ne,Ft,Mn,ve,We]),m.useEffect(()=>{H==="stopped"&&n?.url&&Ft()},[H,n?.url,Ft]),m.useEffect(()=>{const ye=U.current;if(!ye||!s?.url){We("route/no-audio-url"),ce.current=null;return}const Ie=Math.max(0,Math.min(1,ds)),Je=ce.current==null?Math.max(0,Math.min(1,ye.volume)):ce.current;if(re.current&&(cancelAnimationFrame(re.current),re.current=null),Ie>Je){const ke=performance.now(),Ye=Je,Mt=Ie-Ye,zt=ct=>{const ze=Math.min(1,(ct-ke)/nN),ln=Ye+Mt*ze;ye.volume=ln,ce.current=ln,ze<1?re.current=requestAnimationFrame(zt):re.current=null};re.current=requestAnimationFrame(zt)}else ye.volume=Ie,ce.current=Ie;We("route/direct",{elementVolume:Ie,duckEnabled:Ve,mainBrushActive:vt,duckAmount:mt})},[s?.url,ds,Ve,vt,mt,We]),m.useEffect(()=>{if(!s?.url||!U.current)return;let ye=!0,Ie;const Je=(ke,Ye)=>{ye&&(We("audio/status",{nextStatus:ke,info:Ye||null}),V(Ye||(ke==="connected"?"connected":null)),ue(Mt=>ke==="connected"&&(Mt==="playing"||Mt==="connecting")||ke==="new"?Mt:ke),["error","failed"].includes(ke)&&ua())};return Ie=new lx({url:s.url,token:s.token,video:U.current,audioOnly:!0,onStatus:Je}),Ie.start().catch(ke=>{ye&&(ue("error"),V(ke.message),ua())}),()=>{ye=!1,Ie?.stop()}},[s?.url,s?.token,pe,ua,We]),m.useEffect(()=>{const ye=U.current;if(!s?.url||!ye){clearInterval(F.current);return}if(!["connecting","connected","playing","paused"].includes(ae)){clearInterval(F.current);return}const Je=async()=>{const ke=U.current;ke&&(ke.muted=!1,!(!ke.paused&&!ke.ended)&&(We("retry/play-attempt"),ke.play().then(()=>{We("retry/play-ok"),ue(Ye=>Ye==="connected"?"playing":Ye),V(Ye=>Ye==="paused"?null:Ye)}).catch(Ye=>{We("retry/play-fail",{error:Ye?.message}),V(Mt=>Mt||Ye?.message||"autoplay blocked")})))};return Je(),F.current=setInterval(Je,eN),()=>clearInterval(F.current)},[s?.url,ae,We]),m.useEffect(()=>{const ye=U.current;if(!ye)return;const Ie=()=>{We("element/play"),ue(ze=>ze==="error"?ze:"playing"),V(null)},Je=()=>{We("element/pause"),ue(ze=>["error","failed","disconnected","closed","stopped"].includes(ze)?ze:"paused"),V(ze=>ze||"paused")},ke=()=>{We("element/ended"),ue(ze=>ze==="error"?ze:"stopped"),V(ze=>ze||"ended")},Ye=()=>{const{error:ze}=ye,ln=ze?.message||"audio error";We("element/error",{error:ln}),ue("error"),V(ln)},Mt=()=>We("element/waiting"),zt=()=>We("element/canplay"),ct=()=>We("element/stalled");return ye.addEventListener("play",Ie),ye.addEventListener("pause",Je),ye.addEventListener("ended",ke),ye.addEventListener("error",Ye),ye.addEventListener("waiting",Mt),ye.addEventListener("canplay",zt),ye.addEventListener("stalled",ct),()=>{ye.removeEventListener("play",Ie),ye.removeEventListener("pause",Je),ye.removeEventListener("ended",ke),ye.removeEventListener("error",Ye),ye.removeEventListener("waiting",Mt),ye.removeEventListener("canplay",zt),ye.removeEventListener("stalled",ct)}},[s?.url,We]);const Ti=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",ml=xe?Ti:n?.url?H==="error"?`Error: ${L||"unknown"}`:L?`${H} (${L})`:H:"waiting",La=s?.error?`Error: ${s.error}`:s?.url?ae==="error"?`Error: ${R||"unknown"}`:R?`${ae} (${R})`:ae:null,Di=y==="spectator",sn=y==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[xe?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:D,muted:p||fe||ve,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:U,autoPlay:!0,hidden:!0}),!sn&&N?r.jsx(YA,{mobileHud:J,isActiveDriver:M,idleSkipSeconds:O}):null,sn?null:r.jsx(PA,{sensors:Le,label:d,roverColor:h,status:ml,audioStatus:La,levelStatus:Lo,layoutFormat:v,variant:y,driverLabel:S,showTopDown:ht,mobileHud:J,mapPosition:he,turnTimerText:T,labelScale:k}),sn?null:r.jsx(rN,{compact:J}),!sn&&Lt?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:${an?1:0} motors:${yn.length} fill:${Math.round(wt*100)}%`}):null,sn?null:r.jsx(sN,{motors:yn,fill:wt,compact:J}),sn?null:r.jsx(lN,{battery:Oe,compact:J}),!sn&&Di&&Oe.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(Hf,{visual:Oe,orientation:"vertical",variant:"inline",compact:J,className:"h-full w-4"})}):null,!sn&&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 ${J?"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(hd,{id:"discord",label:"Join our Discord server while you wait!",url:ms})})]})}):null]}),!sn&&!Di&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(iN,{sensors:Le}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Hf,{visual:Oe,compact:J})})]})]})}function xd({layoutFormat:n="desktop"}){const s=it(se=>se.session),{state:{song:l,lastControlIntentAt:o},overcurrentLimiter:f}=_t(),[d,h]=m.useState(()=>Date.now()),[p,x]=m.useState(!1),[g,v]=m.useState(null),y=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s?.mode!=="turns")return;const se=setInterval(()=>h(Date.now()),250);return()=>clearInterval(se)},[s?.mode]);const S=s?.assignment?.roverId,C=!!(S&&s?.roster?s.roster.find(se=>String(se.id)===String(S)):null)?.media?.audioPublishUrl,k=S?s?.turnQueues?.[S]:null,w=s?.socketId||null,A=S?s?.activeDrivers?.[S]:null,N=!!(w&&A===w),T=m.useMemo(()=>{const se=k?.queue||[];if(!se.length||!k?.current||se.length<=1)return null;const pe=se.findIndex(oe=>oe===k.current);return pe===-1?se[0]||null:se[(pe+1)%se.length]||null},[k?.queue,k?.current]),M=!!(w&&T===w),O=k?.deadline||null,K=k?.idleDeadline||null,D=O?O-d:null,U=K?K-d:null,Q=s?.mode==="turns"&&M&&D!=null&&D<=5e3&&D>0,$=s?.mode!=="turns"||N||Q,F=D!=null&&Number.isFinite(D)?Math.max(0,Math.ceil(D/1e3)):null,W=U!=null&&Number.isFinite(U)?Math.max(0,Math.ceil(U/1e3)):null,re=N?F!=null?`${F}s left`:null:M&&F!=null?`Your turn in ${F}s`:null,ce=S?[...$?[{type:"rover",id:S,key:S}]:[],...C?[{type:"rover",id:`${S}-audio`,key:`${S}-audio`}]:[]]:[],H=yi(ce),q=S&&$?H[S]:null,L=S&&C?H[`${S}-audio`]:null,Z=md(S?[S]:[],{enabled:!!S,version:s?.mode}),ae=S&&Z[S]||null,ue=ul(S),R=S&&s?.roster?s.roster.find(se=>String(se.id)===String(S)):null,V=R?.battery??null,ne=R?.name||(S?`Rover ${S}`:"");return m.useEffect(()=>{if(s?.mode!=="turns"){x(!1),v(null),y.current={active:!1,roverId:null};return}const se=y.current,pe=N&&!se.active,oe=N&&S&&S!==se.roverId;pe||oe?(x(!0),v(Date.now())):!N&&se.active&&(x(!1),v(null)),y.current={active:N,roverId:S}},[N,S,s?.mode]),m.useEffect(()=>{!p||!g||o>g&&x(!1)},[o,g,p]),r.jsx("section",{className:"panel",children:S?r.jsx(ji,{sessionInfo:q,videoMode:$?"whep":"snapshot",snapshotFeed:ae,audioSessionInfo:L,label:ne,roverColor:R?.color||null,telemetryFrame:ue,batteryConfig:V,layoutFormat:n,overcurrentLimiter:f,songNote:l?.note,qualityNotice:$?null:"Preview feed (low FPS) until your turn.",showTurnCue:p,turnTimerText:re,turnSeconds:F,isActiveDriver:N,idleSkipSeconds:W}):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 So({label:n,tone:s="muted"}){const l=s==="success"?"bg-emerald-900 text-emerald-100":s==="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 ${l}`,children:n})}function Ro(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function oN(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,l,o]=n,f=Math.max(0,Math.min(255,Number(s)))/255,d=Math.max(0,Math.min(255,Number(l)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(f,d,h),x=Math.min(f,d,h),g=p-x;if(g===0)return 0;let v=0;return p===f?v=(d-h)/g%6:p===d?v=(h-f)/g+2:v=(f-d)/g+4,Ro(Math.round(v*60))}function ox(n){const s=Ro(n),l=1,o=1-Math.abs(s/60%2-1);let f=0,d=0,h=0;return s<60?(f=l,d=o):s<120?(f=o,d=l):s<180?(d=l,h=o):s<240?(d=o,h=l):s<300?(f=o,h=l):(f=l,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function cx(n){return n?Array.isArray(n.hsColor)?Ro(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?oN(n.rgbColor):0:0}function cN({entity:n,connected:s,controlsLocked:l,onToggle:o,onSetColor:f,onSetWhite:d}){const h=n.state==="unavailable"||!n.available,p=n.state==="on",x=n.type==="light"&&n.supportsColor,g=h?"warn":p?"success":"muted",v=h?"Unavailable":p?"On":"Off",y=l||!s||h,S=y||!x,[E,C]=m.useState(()=>cx(n)),k=m.useRef(E),w=m.useRef(!1),A=h?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":l?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":p?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!x||w.current)return;const U=cx(n);k.current=U,C(U)},[n.rgbColor,n.hsColor,x]);const N=U=>{const Q=Ro(Number(U.target.value));k.current=Q,C(Q)},T=()=>{S||!f||f(n.id,ox(k.current))},M=U=>{U.stopPropagation()},O=U=>{M(U),!(S||!d)&&d(n.id)},D=`rgb(${(x?ox(k.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 ${A} 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}),x&&r.jsxs(r.Fragment,{children:[r.jsx(So,{label:v,tone:g}),!s&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),x?r.jsx("div",{className:"-mt-0.5 w-full",onClick:M,onPointerDown:U=>{M(U),w.current=!0},onPointerUp:U=>{M(U),w.current=!1,T()},onPointerCancel:U=>{M(U),w.current=!1,T()},onKeyUp:U=>{M(U),T()},onBlur:T,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:E,onChange:N,disabled:S,"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(So,{label:v,tone:g}),!s&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),x&&r.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[r.jsx("span",{role:"button",tabIndex:S?-1:0,onClick:O,onPointerDown:M,onKeyDown:U=>{S||(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),O(U))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":S,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),r.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:D}})]}),!x&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:p?"Turn off":"Turn on"})]})}function Hg(){const{state:{keymap:n}}=_t(),s=it(E=>E.session),{homeAssistantToggle:l,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:f}=kn(),d=s?.homeAssistant,h=m.useMemo(()=>d?.entities||[],[d?.entities]),p=d?.lightPolicy||null,x=!!(p?.locked||p?.lockedOn),g=p?.lockState||(p?.lockedOn?"on":null),v=Cn(n?.homeAssistantOn?.[0]),y=Cn(n?.homeAssistantOff?.[0]);if(!d?.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(h.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 S=!!d?.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:h.length}),x?r.jsx(So,{label:g==="off"?"Locked Off":"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"}),v?r.jsx(ux,{label:v}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),y?r.jsx(ux,{label:y}):null]})]})]}),r.jsx(So,{label:S?"Connected":"Offline",tone:S?"success":"warn"})]}),x?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:g==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,r.jsx("div",{className:"flex flex-wrap gap-0.5",children:h.map(E=>r.jsx(cN,{entity:E,connected:S,controlsLocked:x,onToggle:l,onSetColor:o,onSetWhite:f},E.id))})]})}function ux({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Vg(){const{login:n,setRole:s}=kn(),[l,o]=m.useState(""),[f,d]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await n(l,f),o(""),d("")}catch(v){alert(v.message)}finally{p(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:l,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function fx(...n){return n.filter(Boolean).join(" ")}function uN(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function fN(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function dN({title:n,roster:s=[],emptyText:l="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}),s.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:l}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(f=>{const d=!!(f?.private?.enabled&&f?.private?.open),h=!!f?.locked;return r.jsxs("li",{className:fx("surface flex flex-wrap items-center justify-between gap-0.5",h?"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:oa(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:fx("font-semibold",fN(f)),children:["Battery ",uN(f)]})]})]}),o?o(f):null]},f.id)})})]})}function mN(n){const s=n?.runtime||{},l=n?.output||{},o=n?.errors||{};return s.inFlight?{label:"IN FLIGHT",detail:s.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:s.outcome==="posted"?{label:"POSTED",detail:l.posted?`Last: ${l.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function hN(n,s){const l=Date.now(),f=(Array.isArray(n)?n:[]).map((d,h)=>{const p=String(d?.role||"").toLowerCase(),x=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:l+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(s!=null){const d=String(s);f.push({id:"llm-output",message:{ts:l+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function pN({state:n,onClearHistory:s,clearingHistory:l}){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||{},h=n.counters||{},p=n.timings||{},x=n.input||{},g=n.output||{},v=n.errors||{},y=Array.isArray(n.history)?n.history:[],S=y.find(w=>w.runId===o)||(y.length?y[y.length-1]:null),E=mN(n),C=hN(x.modelMessages,g.raw),k=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:s,disabled:!!l,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:l?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${E.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:E.label}),r.jsx("div",{className:"text-xs text-slate-200",children:E.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:k.map(w=>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:[w.label,": ",w.value]},w.label))}),v.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.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(v.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:C.length?C.map(w=>r.jsx(ld,{message:w.message},w.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: ",v.failedAt?new Date(v.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:y.length?y.slice().reverse().map(w=>r.jsxs("button",{type:"button",onClick:()=>f(w.runId),className:`w-full text-left surface ${S?.runId===w.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",r.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),S?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 #",S.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(S,null,2)})]}):null]})}function xN({health:n,roster:s=[]}){if(!n)return null;const l=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},f=x=>s.find(g=>String(g.id)===String(x))?.color||null,d=`${l.readyCount}/${l.totalCount} sources ready`,h=o.rovers.filter(x=>x.stale).length,p=o.rooms.filter(x=>x.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:h?"text-amber-300":"text-emerald-300",children:[o.rovers.length-h,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rooms.length-p,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:l.sources.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:`${x.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:x.type==="rover"?oa(f(x.id),.16):void 0,children:x.label}),r.jsxs("span",{className:x.ready?"text-emerald-300":"text-amber-300",children:[x.recentCount,"/",x.neededCount]})]},`${x.type}:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:oa(f(x.id),.16),children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.stale?"stale":"ok"})]},`rover:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.error?"error":x.stale?"stale":"ok"})]},`room:${x.id}`))})]})}function gN({entries:n}){const s=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:s.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No admin log entries yet."}):s.slice().reverse().map(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.ts?new Date(l.ts).toLocaleTimeString():"--"})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:l.message})," ",l.ip&&r.jsx("span",{className:"text-cyan-300",children:l.ip})," ",l.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(l.meta)})]},l.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const vN=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function bN(){const{session:n,lockRover:s,setMode:l,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:p,setAudioLevels:x,setPrivateSafety:g,llmControl:v,adminLogs:y,llmCommentaryState:S}=nn(),E=m.useMemo(()=>n?.roster??[],[n?.roster]),[C,k]=m.useState({}),[w,A]=m.useState({}),[N,T]=m.useState(!1),[M,O]=m.useState(!1),K=n?.health||null,D=n?.communityGoal?.text||"",U=n?.communityGoal?.updatedAt||null,[Q,$]=m.useState(D),F=n?.adminReason?.text||"",W=n?.adminReason?.updatedAt||null,[re,ce]=m.useState(F),H=n?.audioLevels||{},[q,L]=m.useState({hornGain:Number.isFinite(H.hornGain)?H.hornGain:1,ttsGain:Number.isFinite(H.ttsGain)?H.ttsGain:1,forwardGain:Number.isFinite(H.forwardGain)?H.forwardGain:1}),[Z,ae]=m.useState({}),ue=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",R=n?.role==="lockdown"||n?.role==="lockdown-admin",V=n?.mode??"open",ne=async(le,J)=>{try{await s(le,J),k(he=>({...he,[le]:J}))}catch(he){alert(he.message)}},se=async le=>{const J=le.target.value;try{await l(J)}catch(he){alert(he.message)}},pe=async le=>{try{await o(le,{force:!0})}catch(J){alert(J.message)}},oe=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){A(he=>({...he,[le.id]:!0}));try{await h(le.id)}catch(he){alert(he.message)}finally{A(he=>({...he,[le.id]:!1}))}}},fe=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){T(!0);try{await p()}catch(J){alert(J.message),T(!1)}}},be=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){O(!0);try{await v("clearHistory")}catch(J){alert(J.message)}finally{O(!1)}}},ve=async()=>{try{await f(Q)}catch(le){alert(le.message)}},xe=async()=>{try{await f(null)}catch(le){alert(le.message)}},Le=async()=>{try{await d(re)}catch(le){alert(le.message)}},De=async()=>{try{await d(null)}catch(le){alert(le.message)}},Ee=le=>J=>{const he=Number(J.target.value);L(Ae=>({...Ae||{},[le]:Number.isFinite(he)?he:1}))},nt=async()=>{try{await x(q)}catch(le){alert(le.message)}},Ve=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{$(D)},[D]),m.useEffect(()=>{ce(F)},[F]),m.useEffect(()=>{L({hornGain:Number.isFinite(H.hornGain)?H.hornGain:1,ttsGain:Number.isFinite(H.ttsGain)?H.ttsGain:1,forwardGain:Number.isFinite(H.forwardGain)?H.forwardGain:1})},[H.forwardGain,H.hornGain,H.ttsGain]),m.useEffect(()=>{const le={};(E||[]).forEach(J=>{J?.private?.enabled&&(le[J.id]={speedLimitEnabled:!!J?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(J?.private?.safety?.speedLimitMaxWheelSpeed)?J.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!J?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(J?.private?.safety?.overcurrentStopMs)?J.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!J?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(J?.private?.safety?.bumpBackoffSpeed)?J.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(J?.private?.safety?.bumpBackoffMs)?J.private.safety.bumpBackoffMs:350,cliffEnabled:!!J?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(J?.private?.safety?.cliffBackoffSpeed)?J.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(J?.private?.safety?.cliffBackoffMs)?J.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(J?.private?.safety?.triggerCooldownMs)?J.private.safety.triggerCooldownMs:800})}),ae(le)},[E]);const mt=m.useMemo(()=>{const le={};return E.forEach(J=>{le[J.id]=C[J.id]??J.locked}),le},[E,C]),ie=(le,J={})=>{ae(he=>({...he||{},[le]:{...he?.[le]||{},...J||{}}}))},me=async le=>{try{const J=Z?.[le];if(!J)return;await g(le,J)}catch(J){alert(J.message)}};return ue?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:V,onChange:se,className:"field-input text-sm",children:vN.map(le=>r.jsx("option",{value:le.key,children:le.label},le.key))})]}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:fe,disabled:N,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:N?"Server rebooting...":"Reboot Server"}),r.jsx("button",{type:"button",onClick:Ve,className:"button-dark",children:"Test Reward Popup"})]}),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:[q.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.hornGain,onChange:Ee("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:[q.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.ttsGain,onChange:Ee("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:[q.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:q.forwardGain,onChange:Ee("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:nt,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"}),U?r.jsxs("span",{children:["Updated ",new Date(U).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:Q,onChange:le=>$(le.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:ve,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"}),W?r.jsxs("span",{children:["Updated ",new Date(W).toLocaleString()]}):null]}),r.jsx("textarea",{value:re,onChange:le=>ce(le.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:Le,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:De,className:"button-danger",children:"Clear"})]})]}),r.jsx(dN,{roster:E,renderActions:le=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>ne(le.id,!mt[le.id]),className:"button-dark",children:mt[le.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>pe(le.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>oe(le),disabled:!!w[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:w[le.id]?"Rebooting...":"Reboot"}),le?.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:!!Z?.[le.id]?.speedLimitEnabled,disabled:!R,onChange:J=>ie(le.id,{speedLimitEnabled:!!J.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:!R,value:Z?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:J=>ie(le.id,{speedLimitMaxWheelSpeed:Number(J.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!Z?.[le.id]?.hardOvercurrentEnabled,disabled:!R,onChange:J=>ie(le.id,{hardOvercurrentEnabled:!!J.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:!!Z?.[le.id]?.hardBumpEnabled,disabled:!R,onChange:J=>ie(le.id,{hardBumpEnabled:!!J.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:!!Z?.[le.id]?.cliffEnabled,disabled:!R,onChange:J=>ie(le.id,{cliffEnabled:!!J.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!R,onClick:()=>me(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(xN,{health:K,roster:E}),r.jsx(pN,{state:S,onClearHistory:be,clearingHistory:M}),r.jsx(gN,{entries:y})]}):null}const yN=[{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((s,l)=>((s[l.group]||(s[l.group]=[])).push(l),s),{})}function jN(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(0,Math.min(500,l)):s}const gd=5,Ai=500,Ni=1,vd=100;function AN(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(gd,Math.min(Ai,l)):s}function fo(n,s){const l=Number(n);return Number.isFinite(l)?Math.max(Ni,Math.min(vd,l)):s}function NN(n){const l=(fo(n,n)-Ni)/(vd-Ni),o=Ai-l*(Ai-gd);return Math.round(o)}function wN(n){const s=AN(n,n),l=(Ai-s)/(Ai-gd),o=Ni+l*(vd-Ni);return Math.round(o)}function CN(n){const[s,l]=m.useState(null),o=m.useCallback(h=>{rf(!0),l(h)},[]),f=m.useCallback(()=>{rf(!1),l(null)},[]),d=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){f();return}const x=Ri(p.key??"");x&&(n(h,x,p),f())},[f,n]);return m.useEffect(()=>()=>rf(!1),[]),{active:s,startCapture:o,cancel:f,captureFromEvent:d}}function eo({label:n,description:s,value:l,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("input",{type:"number",min:f,max:d,value:l,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:l,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:l})]})]})}function EN(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:l}}=_t(),{value:o,save:f}=Ge("inputs",_n),d={..._n.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?fo(d.tiltSpeed,_n.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?fo(wN(d.tiltIntervalMs),_n.keyboard.tiltSpeed):_n.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),p=m.useMemo(()=>SN(yN),[]),{active:x,startCapture:g,cancel:v,captureFromEvent:y}=CN((k,w)=>{s(k,w)}),S=m.useCallback(k=>n?.[k]?.[0]||hi[k]?.[0]||"",[n]),E=m.useCallback((k,w)=>{const A=_n.keyboard,N=jN(w,A[k]);f(T=>({...T??{},keyboard:{...T?.keyboard??A,[k]:N}}))},[f]),C=m.useCallback(k=>{const w=_n.keyboard,A=fo(k,w.tiltSpeed),N=NN(A);f(T=>({...T??{},keyboard:{...T?.keyboard??w,tiltSpeed:A,tiltIntervalMs:N}}))},[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:()=>l(),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(eo,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:k=>E("baseSpeed",k)}),r.jsx(eo,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:k=>E("turboSpeed",k)}),r.jsx(eo,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:k=>E("precisionSpeed",k)})]})]}),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(eo,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:C,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([k,w])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:k}),r.jsx("div",{className:"space-y-0.5",children:w.map(A=>{const N=S(A.id),T=x===A.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:A.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Cn(N)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[T&&r.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(A.id),onKeyDown:T?M=>y(A.id,M):void 0,autoFocus:T,className:`${T?"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:T?"Press a key…":"Change"})]})]},A.id)})})]},k))})]})}const sa=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),kN=[{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"}],dx=.45,MN=.6;function ui({label:n,description:s,min:l,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("span",{className:"font-mono text-slate-400",children:sa.format(d)})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsx("input",{type:"range",min:l,max:o,step:f,value:d,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function RN(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const s=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${s?` (${s})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const s=n.direction<0?"<":">";return`Axis ${n.index} ${s} ${sa.format(n.threshold??.6)}`}return"Unassigned"}function qN(n){return n.reduce((s,l)=>((s[l.section]||(s[l.section]=[])).push(l),s),{})}function TN(n,s){if(!n||n.length===0)return null;if(s){const l=n.find(o=>o.signature===s);if(l)return l}return n[0]}function DN(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0}))}}function _N(n,s,l){const o=(n.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(s.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),l.kind==="axisPair"){const d=o.filter(h=>h.delta>dx).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...l.invertDefaults??{}}}const f=o.find(d=>d.delta>dx);return f?{kind:"axis",index:f.index,...l.invertDefaults??{}}:null}function BN(n,s,l){const o=n.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>MN)return l.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=n.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,p=Math.abs(h-(s.axes?.[d]??0));if(Math.abs(h)>.7&&p>.5)return l.kind==="axis"?{kind:"axis",index:d,...l.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function ON(n,s,l){if(!n)return null;if(l.kind==="axis"||l.kind==="axisPair"){const o=_N(n,s,l);if(o)return o}return BN(n,s,l)}function LN(){const n=dA(),{value:s,save:l}=Ge("gamepad",_a),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>qN(kN),[]),p=m.useMemo(()=>TN(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??la:s?.defaults?.profile??la,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!p||!x||s?.profiles?.[x]||l(w=>{const A=w??_a;if(A.profiles?.[x])return A;const N=A?.defaults?.profile??la,T=wg(p,N);return{...A,profiles:{...A.profiles??{},[x]:T}}})},[p,x,s?.profiles,l]),m.useEffect(()=>{d.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!d.current){d.current=DN(p);return}const w=ON(p,d.current,o);w&&(l(A=>{const N=A??_a,T=N.profiles?.[x]??N?.defaults?.profile??la,M={...T,bindings:{...T.bindings??{},[o.id]:{...T.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...N,profiles:{...N.profiles??{},[x]:M}}}),f(null))},[p,x,o,l]);const v=m.useCallback(w=>{l(A=>({...A??_a,activeSignature:w||null}))},[l]),y=m.useCallback(w=>{l(A=>{const N=A??_a,T=(x&&N.profiles?.[x])??N?.defaults?.profile??la,M={...T,calibration:{...T.calibration??{},...w}};return x?{...N,profiles:{...N.profiles??{},[x]:M}}:{...N,defaults:{...N.defaults??{},profile:M}}})},[x,l]),S=m.useCallback((w,A)=>{l(N=>{const T=N??_a,M=(x&&T.profiles?.[x])??T?.defaults?.profile??la,O=A(M.bindings?.[w]??{}),K={...M,bindings:{...M.bindings??{},[w]:O}};return x?{...T,profiles:{...T.profiles??{},[x]:K}}:{...T,defaults:{...T.defaults??{},profile:K}}})},[x,l]),E=m.useCallback(w=>{S(w.id,A=>({...A,sources:[]}))},[S]),C=m.useCallback((w,A)=>{S(w.id,N=>{const T=Array.isArray(N.sources)?[...N.sources]:[];if(!T[0])return N;const M={...T[0]};return A==="invertX"?M.invertX=!M.invertX:A==="invertY"?M.invertY=!M.invertY:M.invert=!M.invert,T[0]=M,{...N,sources:T}})},[S]),k=m.useMemo(()=>p?{outputs:Cg(p,g)}:null,[p,g]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),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:x??"",onChange:w=>v(w.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(w=>r.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(ui,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:w=>y({driveDeadzone:w})}),r.jsx(ui,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:w=>y({cameraDeadzone:w})}),r.jsx(ui,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:w=>y({auxDeadzone:w})}),r.jsx(ui,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:w=>y({auxSideScale:w})}),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:w=>y({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[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(ui,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:w=>y({cameraSensitivity:w})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([w,A])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),r.jsx("div",{className:"space-y-0.5",children:A.map(N=>{const M=g.bindings?.[N.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:N.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:RN(M)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[N.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),N.kind==="axis"&&r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>E(N),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(N),className:`${o?.id===N.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===N.id?"Waiting…":"Capture"})]})]},N.id)})})]},w))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?r.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[r.jsx("p",{className:"text-slate-400",children:"Raw axes"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((w,A)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",A,": ",sa.format(w)]},`axis-${A}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((w,A)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",A,": ",sa.format(w.value)," ",w.pressed?"●":""]},`btn-${A}`))}),k?.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: ",sa.format(k.outputs.driveVector.x),","," ",sa.format(k.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",sa.format(k.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",sa.format(k.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",sa.format(k.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const zN={drive:"Drive wheels",aux:"Aux motors"};function mx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function UN({value:n,color:s="bg-emerald-500"}){const l=`${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 ${s}`,style:{width:l}})})}function HN(){const{state:{roverId:n},overcurrentLimiter:s}=_t(),l=m.useMemo(()=>is.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:s?.adminImmune?"Admin immune":"Active"})]}),n?r.jsxs("div",{className:"space-y-0.5",children:[l.map(o=>{const f=s?.caps?.[o]?.cap??0,d=s?.overcurrent?.groups?.[o]??!1,h=s?.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:zN[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:mx(f)})]}),r.jsx(UN,{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:mx(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const $g=m.createContext(null);function Gg(){const n=m.useContext($g);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const hx={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"}},px={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"},Yg="primary";function bd(...n){return n.filter(Boolean).join(" ")}function yd({children:n,defaultTab:s,currentTab:l,onTabChange:o,variant:f=Yg}){const[d,h]=m.useState(s??null),[p,x]=m.useState([]),g=m.useCallback(E=>E?(x(C=>C.includes(E)?C:[...C,E]),()=>x(C=>C.includes(E)?C.filter(k=>k!==E):C)):()=>{},[]),v=l??d??p[0]??null;m.useEffect(()=>{s&&l===void 0&&h(s)},[s,l]);const y=m.useCallback(E=>{E&&(l===void 0&&h(E),o&&o(E))},[l,o]),S=m.useMemo(()=>({activeTab:v,setActiveTab:y,registerTab:g,variant:f}),[v,y,g,f]);return r.jsx($g.Provider,{value:S,children:n})}function Sd({children:n,className:s=""}){return r.jsx("div",{className:bd("flex gap-0.5",s),children:n})}function Wt({id:n,children:s,className:l="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:h,registerTab:p,variant:x}=Gg();m.useEffect(()=>p(n),[n,p]);const g=hx[x]??hx[Yg],v=d===n,y=px[f]||px.none,S=bd(g.base,y||(v?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",l);return r.jsx("button",{type:"button",className:S,onClick:()=>!o&&h(n),"aria-pressed":v,"aria-disabled":o,children:s})}function jd({children:n,className:s=""}){return r.jsx("div",{className:bd("mt-0 space-y-0.5",s),children:n})}function en({id:n,children:s,keepMounted:l=!1}){const{activeTab:o}=Gg(),f=o===n;return!f&&!l?null:!f&&l?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):r.jsx(r.Fragment,{children:s})}function VN(){const{session:n}=nn(),s=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:s})]})}const xx=300,gx=240;function $N(n,s){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(s||(s=new WeakSet),typeof n=="object"){if(s.has(n))return"[Circular]";s.add(n)}try{return JSON.stringify(n,(l,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function GN(n){const l=n.map(o=>$N(o)).join(" ");return l.length>gx?`${l.slice(0,gx)}…`:l}function YN(){const n=tn(),[s,l]=m.useState([]),o=m.useMemo(()=>s.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[s]);return m.useEffect(()=>{const f=(x,g,v)=>{l(y=>{const S=[...y,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:GN(v),timestamp:new Date().toLocaleTimeString()}];return S.length>xx?S.slice(-xx):S})},d=(x,...g)=>f("in",x,g),h=(x,...g)=>f("out",x,g);n.onAny(d);let p=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),p=()=>n.offAnyOutgoing(h);else{const x=n.emit.bind(n);n.emit=(g,...v)=>(h(g,...v),x(g,...v)),p=()=>{n.emit=x}}return()=>{n.offAny(d),p&&p()}},[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:()=>l([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No socket activity yet."}):s.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 FN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Fg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:l}}=_t(),o=!!n,[f,d]=Lg(),h=tn(),{value:p,save:x}=Ge("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:v}=Ge("audio",st),y=p?.connectionTransport||"websocket",S=!!p?.swapMobileControlColumns,E=typeof p?.driveMacroBackoffEnabled=="boolean"?p.driveMacroBackoffEnabled:!0,C=Number.isFinite(g?.masterVolume)?g.masterVolume:st.masterVolume,k=Number.isFinite(g?.alertVolume)?g.alertVolume:st.alertVolume,w=Number.isFinite(g?.roverVolume)?g.roverVolume:st.roverVolume,A=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:st.mainBrushDuckEnabled,N=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):st.mainBrushDuckAmount,T=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=$=>{n&&l($)},O=$=>{const F=$.target.value;x(W=>({...W??{},connectionTransport:F})),h?.io?.opts&&(h.io.opts.transports=F==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},K=$=>F=>{const W=Number(F.target.value),re=Number.isFinite(W)?Math.max(0,Math.min(1,W)):0;v(ce=>({...ce??{},[$]:re}))},D=$=>{const F=!!$.target.checked;v(W=>({...W??{},mainBrushDuckEnabled:F}))},U=$=>{const F=!!$.target.checked;x(W=>({...W??{},swapMobileControlColumns:F}))},Q=$=>{const F=!!$.target.checked;x(W=>({...W??{},driveMacroBackoffEnabled:F}))};return r.jsxs(yd,{defaultTab:"keybindings",children:[r.jsxs(Sd,{children:[r.jsx(Wt,{id:"keybindings",children:"Keybindings"}),r.jsx(Wt,{id:"controller",children:"Controller"}),r.jsx(Wt,{id:"page",children:"Page settings"}),r.jsx(Wt,{id:"admin",children:"Admin"})]}),r.jsxs(jd,{children:[r.jsx(en,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(EN,{})})}),r.jsx(en,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(LN,{})})}),r.jsx(en,{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:$=>d($.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:S,onChange:U}),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:E,onChange:Q}),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(C*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:C,onChange:K("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(k*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:k,onChange:K("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:K("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:A,onChange:D})]}),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(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:K("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!A})]}),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:y,onChange:O,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(en,{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:FN.map($=>r.jsx("button",{type:"button",onClick:()=>s($.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:$.label},$.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:T.map($=>r.jsx("button",{type:"button",onClick:()=>M($.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:$.label},$.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(Vg,{}),r.jsx(HN,{}),r.jsx(bN,{}),r.jsx(VN,{}),r.jsx(YN,{})]})})]})]})}const vx={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 XN(n){return vx[n]||vx.desktop}function Xg({actionId:n,keymap:s}){const l=s?.[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:Cn(l)})}function bx(n,s){return n.map((l,o)=>typeof l=="string"?r.jsx("span",{children:l},`text-${o}`):l?.action?r.jsx(Xg,{actionId:l.action,keymap:s},`pill-${l.action}-${o}`):l?.text?r.jsx("span",{children:l.text},`span-${o}`):null)}function qo(n,s,l){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return bx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return bx(n,s)}return String(n??"")}function QN({hero:n,keymap:s}){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(l=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:l},l))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((l,o)=>{const f=Array.isArray(l?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(l,s)},f)})})]}):null}function KN({block:n,keymap:s}){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((l,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:qo(l,s)},f)})})]})}function ZN({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${s} 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((l,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(l,{})},`callout-${o}`))})]})}function IN({group:n,keymap:s}){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(l=>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:l.label}),r.jsx(Xg,{actionId:l.action,keymap:s})]},l.action))})]})}function JN({block:n,keymap:s}){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(l=>r.jsx(IN,{group:l,keymap:s},l.id))})]}):null}function PN({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((s,l)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:qo(s,{})},`gamepad-${l}`))})]}):null}function yx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return r.jsx(KN,{block:n,keymap:s});case"callout":return r.jsx(ZN,{block:n});case"keyboard":return r.jsx(JN,{block:n,keymap:s});case"gamepad":return r.jsx(PN,{block:n});default:return null}}function Qg({layout:n,keymap:s}){const l=m.useMemo(()=>XN(n),[n]),o=s||{},f=l.main||[],d=l.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(QN,{hero:l.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>r.jsx(yx,{block:h,keymap:o},h.title||p))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,p)=>r.jsx(yx,{block:h,keymap:o},h.title||p))})]})]})}function Kg({layout:n,onOpenOverlay:s}){const{state:l}=_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:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(Qg,{layout:n,keymap:l?.keymap||{}})]})}const WN=["kal","rms","slt","ksp","bdl"],ew=Array.from({length:10},(n,s)=>s*10);function To({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:l=!1,allowSpectatorInput:o=!1}){const f=it(R=>R.session),{messages:d,typing:h,sendMessage:p,registerInputRef:x,onInputFocus:g,onInputBlur:v,blurChat:y,setTypingActive:S}=od(),{value:E,save:C}=Ge("tts",{engine:"flite",voice:"rms",pitch:50}),[k,w]=m.useState(""),[A,N]=m.useState(!1),[T,M]=m.useState(!1),[O,K]=m.useState(()=>E?.engine||"flite"),[D,U]=m.useState(()=>E?.voice||"rms"),[Q,$]=m.useState(()=>Number.isFinite(E?.pitch)?E.pitch:50),F=f?.role!=="spectator"||o,W=m.useRef(null),re=f?.assignment?.roverId||null,H=!!m.useMemo(()=>f?.roster?.find(R=>String(R.id)===String(re))||null,[re,f?.roster])?.audio?.ttsEnabled,q=m.useMemo(()=>d.slice(-200),[d]),L=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{W.current&&(W.current.scrollTop=W.current.scrollHeight)},[q,L]),m.useEffect(()=>{const R=E?.engine||"flite",V=E?.voice||"rms",ne=Number.isFinite(E?.pitch)?E.pitch:50;O!==R&&K(R),D!==V&&U(V),Q!==ne&&$(ne)},[O,Q,E?.engine,E?.pitch,E?.voice,D]),m.useEffect(()=>{M(!!H)},[H]);const Z=m.useMemo(()=>!H||!T?null:O==="espeak"?{speak:!0,engine:O,pitch:Q}:{speak:!0,engine:O,voice:D},[O,Q,T,H,D]);async function ae(R){if(R.preventDefault(),!F||n)return;const ne=k.replace(/\\n/g,`
|
||
`).trim();if(ne){N(!0);try{await p(ne,Z),w(""),y(),S(!1)}catch(se){alert(se.message)}finally{N(!1)}}}const ue=l?"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 ${l?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${ue}`,ref:W,children:[q.length===0&&L.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):q.map(R=>r.jsx(ld,{message:R},R.id)),L.map(R=>r.jsx(pg,{message:R},`typing-${R.typingId||R.id}`))]}),!n&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ae,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:k,onChange:R=>{const V=R.target.value;w(V),S(!!V.trim())},onFocus:R=>{g(R),S(!!k.trim())},onBlur:R=>{v(R),S(!1)},onKeyDown:R=>{R.key==="Enter"&&!k.trim()&&(R.preventDefault(),y(),S(!1))},ref:R=>x(R,{target:"panel"}),placeholder:F?"Type a message…":s?"":"Spectators cannot chat",disabled:!F}),H&&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:T,onChange:R=>M(R.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:O,onChange:R=>{const V=R.target.value;K(V),C(ne=>({...ne||{},engine:V}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),O==="flite"?r.jsx("select",{value:D,onChange:R=>{const V=R.target.value;U(V),C(ne=>({...ne||{},voice:V}))},className:"field-input text-xs",children:WN.map(R=>r.jsx("option",{value:R,children:R},R))}):r.jsx("select",{value:Q,onChange:R=>{const V=Number(R.target.value);$(V),C(ne=>({...ne||{},pitch:V}))},className:"field-input text-xs",children:ew.map(R=>r.jsxs("option",{value:R,children:["pitch ",R]},R))})]}),r.jsx("button",{type:"submit",disabled:!F||A,className:"button-dark h-full disabled:opacity-50 self-stretch",children:A?"...":"Send"})]})]})}function Do({compact:n=!1}){const{session:s,setNickname:l}=nn(),{value:o,save:f}=Ge("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=s?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function v(y){if(y.preventDefault(),!g)return;const S=(d||"").trim().slice(0,32);if(S){x(!0);try{await l(S),f({nickname:S})}catch(E){alert(E.message)}finally{x(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:y=>h(y.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":n?"Set":"Save"})]})}function tw(n){const s=Array.isArray(n?.socials)?n.socials:null;if(s&&s.length)return s;const l=[];return n?.discord?.invite&&l.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&l.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),l}function nw(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,l=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:l,url:o}:null}function Zg({className:n=""}){const{session:s}=nn(),l=tw(s).map(nw).filter(Boolean).slice(0,4);return l.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:l.map(o=>r.jsx(hd,{...o},`${o.id||o.label}-${o.url}`))}):null}function aw({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(Do,{compact:n})})})}function sw(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Zg,{className:"flex-1 min-h-0"})})}function Sf(...n){return n.filter(Boolean).join(" ")}function lw(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function iw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function rw(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 ow(n,s){if(!n)return"";const l=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${l} (you)`:l}function _o({title:n="Rovers"}){const s=it(A=>A.session),{requestControl:l}=kn(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),p=m.useMemo(()=>s?.role&&s.role!=="spectator",[s?.role]),x=m.useMemo(()=>s?.role==="admin"||s?.role==="lockdown"||s?.role==="lockdown-admin",[s?.role]),g=s?.roster??[],v=s?.turnQueues??{},y=s?.users??[],S=s?.socketId||null,E=m.useMemo(()=>Object.values(v||{}).some(A=>A?.deadline||A?.idleDeadline),[v]);m.useEffect(()=>{if(!E)return;const A=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(A)},[E]);const C=m.useMemo(()=>{const A=new Set(g.map(T=>String(T.id))),N=Object.keys(v||{}).filter(T=>!A.has(String(T))).map(T=>({id:T,name:T,locked:!1,batteryState:null}));return[...g,...N]},[g,v]);async function k(A){if(A){f(N=>({...N,[A]:!0}));try{await l(A)}catch(N){alert(N.message)}finally{f(N=>({...N,[A]:!1}))}}}const w=A=>y.find(N=>N.socketId===A)||{socketId:A,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}),C.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:C.map(A=>{const N=String(A.id),T=v?.[N]||null,M=T?.queue||[],O=T?.idleDeadline||T?.deadline||null,K=O&&O>d?Math.ceil((O-d)/1e3):O?0:null,D=T?.current||null,U=D?M.findIndex(ae=>ae===D):-1,Q=M.length>1?U>=0?M[(U+1)%M.length]:M[0]:null,$=!!(S&&D&&D===S),F=!!(S&&Q&&Q===S),W=K!=null&&($||F),re=!!A.locked,ce=re&&!x,H=!!(A?.private?.enabled&&A?.private?.open),q=A.lockReason?`locked: ${A.lockReason}`:"locked",L=re?q:o[N]?"...":"request",Z=p&&!ce&&!o[N];return r.jsxs("li",{className:Sf("surface flex flex-wrap items-start justify-between gap-0.5",Z&&"cursor-pointer",re?"bg-red-900/40":H?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{Z&&k(A.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:oa(A.color,.16),children:A.name})}),W?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:$?`${K}s left`:`Your turn in ${K}s`}):null]}),r.jsx("span",{className:Sf("text-[0.75rem] font-semibold",iw(A)),children:lw(A)})]}),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((ae,ue)=>{const R=w(ae),V=ae===D,ne=!!(Q&&ae===Q&&!V),se=V?"bg-sky-600 text-white ring-2 ring-amber-300":ne?"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] ${se}`,children:[r.jsx("span",{className:`${rw(R.role)} font-semibold`,children:ow(R,S)}),V&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),ne&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${N}-${ae}-${ue}`)})})]}),p?r.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),k(A.id)},disabled:o[N]||ce,className:Sf("button-dark disabled:opacity-40",re&&"bg-red-600/70 text-white hover:bg-red-600"),children:L}):null]},A.id)})})]})}function cw(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 uw(n,s){if(!n)return"";const l=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${l} (you)`:l}function jo({hideNicknameForm:n=!1,hideHeader:s=!1,className:l="",fillHeight:o=!1,compact:f=!1}){const{session:d}=nn(),h=d?.role!=="spectator",p=d?.users??[],x=d?.socketId||null,g=m.useMemo(()=>[...p].sort((y,S)=>y.socketId===x?-1:S.socketId===x?1:(y.nickname||"").localeCompare(S.nickname||"")),[x,p]),v=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":""} ${l}`,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(Do,{compact:f})})}),r.jsx(Zg,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!s&&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 ${v} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(y=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${cw(y.role)}`,children:uw(y,x)},y.socketId))})]})]})}const fw=/^cu_[a-f0-9]{32}$/,wi="field-input w-full max-w-sm text-left focus:ring-emerald-500",Bo="mx-auto w-full max-w-xl flex justify-center",xi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function dw(n){const s=String(n||"").trim();return s?s.length<=10?`${s.slice(0,2)}***${s.slice(-2)}`:`${s.slice(0,6)}...${s.slice(-6)}`:""}const Sx=8*1024*1024,ss=16e3,mw={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function jx(n){let s="";for(let o=0;o<n.length;o+=32768){const f=n.subarray(o,o+32768);s+=String.fromCharCode(...f)}return btoa(s)}function hw(n){return typeof btoa=="function"?btoa(n):""}function pw(n){if(!n)return{};const s=hw(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function xw(n,s=1500){return new Promise(l=>{if(!n||n.iceGatheringState==="complete"){l();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",f),l()},s);function f(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",f),l())}n.addEventListener("icegatheringstatechange",f)})}function Ax(n){if(!n)return!1;const s=n.connectionState,l=n.iceConnectionState;return s==="connected"||l==="connected"||l==="completed"}function gw(n,s=1e4){return new Promise((l,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Ax(n)){l();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},s),d=()=>{Ax(n)?(h(),l()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function h(){clearTimeout(f),n.removeEventListener("connectionstatechange",d),n.removeEventListener("iceconnectionstatechange",d)}n.addEventListener("connectionstatechange",d),n.addEventListener("iceconnectionstatechange",d)})}async function vw(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},l=s.encodings&&s.encodings[0]||{};s.encodings=[{...l,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function bw(n,s=6e3){return new Promise((l,o)=>{if(!n){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>s){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of p){const g=await x.getStats();for(const v of g.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const y=Number(v.bytesSent||0),S=Number(v.packetsSent||0);if(d<0)d=y;else if(y>d+200||S>5){clearInterval(h),l();return}}}}catch{}},250)})}function yw(n){const s=n.reduce((f,d)=>f+d.length,0),l=new Float32Array(s);let o=0;for(const f of n)l.set(f,o),o+=f.length;return l}function Sw(n){const s=new Int16Array(n.length);for(let l=0;l<n.length;l+=1){const o=Math.max(-1,Math.min(1,n[l]));s[l]=o<0?o*32768:o*32767}return s}function jw(n,s){const l=Sw(n),o=l.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),h=(x,g)=>{for(let v=0;v<g.length;v+=1)d.setUint8(x+v,g.charCodeAt(v))};h(0,"RIFF"),d.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,s,!0),d.setUint32(28,s*2,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),h(36,"data"),d.setUint32(40,o,!0);let p=44;for(let x=0;x<l.length;x+=1,p+=2)d.setInt16(p,l[x],!0);return new Uint8Array(f)}function vn({label:n,active:s,detail:l=""}){return r.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"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:l||(s?"active":"idle")})]})}function Nx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Aw({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:l,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:p}=_t(),{value:x,save:g}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[y,S]=m.useState(null),[E,C]=m.useState(!1),k=!!x?.openMicEnabled,A=(x?.pttMode==="clip"?"clip":"live")==="clip",[N,T]=m.useState("idle"),[M,O]=m.useState("idle"),[K,D]=m.useState(""),U=m.useRef(null),Q=m.useRef(null),$=m.useRef(null),F=m.useRef(!1),W=m.useRef(""),re=m.useRef(null),ce=m.useRef(null),H=m.useRef(null),q=m.useRef(null),L=m.useRef(null),Z=m.useRef([]),ae=m.useRef(!1),ue=m.useRef(ss),R=!!p?.mic?.pttActive,V=m.useMemo(()=>v&&s?.[v]||null,[s,v]),ne=!!(V&&V.state!=="offline"&&!V.error),se=V?.source==="upload"&&V?.state==="playing",pe=V?.source==="mic-whip"&&(V?.state==="starting"||V?.state==="playing"),oe=!!(!A&&Q.current&&(k||R)),fe=!A&&(N==="live"||N==="starting"),be=A&&M==="recording",ve=A&&M==="sending",xe=Cn(p?.keymap?.micPtt?.[0])||"M",Le=m.useCallback(J=>{const he=J==="clip"?"clip":"live";g(Ae=>({...Ae||{},pttMode:he}))},[g]),De=async()=>{if(!v){D("Take control of your rover first.");return}if(!y){D("Select an audio file first.");return}if(y.size>Sx){D(`File too large (max ${Sx} bytes).`);return}C(!0),D("");try{const J=await y.arrayBuffer(),he=jx(new Uint8Array(J));await l?.({roverId:v,name:y.name,mime:y.type||"",dataBase64:he}),D("Upload playback started.")}catch(J){D(J?.message||"Failed to play upload.")}finally{C(!1)}},Ee=async()=>{if(!v){D("Take control of your rover first.");return}C(!0),D("");try{await o?.(v),D("Upload playback stopped.")}catch(J){D(J?.message||"Failed to stop upload.")}finally{C(!1)}},nt=m.useCallback(async J=>{const he=String(J||W.current||"").trim();if(F.current=!1,T("idle"),$.current){try{$.current.getSenders().forEach(Ae=>Ae.track?.stop())}catch{}try{$.current.close()}catch{}}if($.current=null,U.current)try{U.current.getTracks().forEach(Ae=>Ae.stop())}catch{}if(U.current=null,Q.current=null,he)try{await h?.(he)}catch{}W.current=""},[h]),Ve=m.useCallback(async J=>{const he=await f?.(J),Ae=String(he?.whipUrl||"").trim(),ht=String(he?.token||"").trim();if(!Ae||!ht)throw new Error("WHIP endpoint unavailable");const Oe=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});U.current=Oe;const rt=Oe.getAudioTracks()?.[0];if(Q.current=rt||null,rt&&(rt.enabled=!!(k||R)),rt?.applyConstraints)try{await rt.applyConstraints({channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const ot=new RTCPeerConnection(mw);$.current=ot,ot.onconnectionstatechange=()=>{if(!F.current)return;const Lt=ot.connectionState;if(Lt==="connected"){T("live");return}(Lt==="failed"||Lt==="disconnected"||Lt==="closed")&&(T("error"),D(`WHIP transport ${Lt}.`))},Oe.getAudioTracks().forEach(Lt=>{const fl=ot.addTrack(Lt,Oe);vw(fl)});const gt=await ot.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await ot.setLocalDescription(gt),await xw(ot,1800);const kt=await fetch(Ae,{method:"POST",headers:{"Content-Type":"application/sdp",...pw(ht)},body:ot.localDescription?.sdp||gt.sdp});if(!kt.ok)throw new Error(`WHIP request failed: ${kt.status}`);const fs=await kt.text();await ot.setRemoteDescription({type:"answer",sdp:fs}),await gw(ot,1e4),await bw(ot,6e3),await d?.(J)},[k,R,d,f]),mt=m.useCallback(async()=>{if(ae.current=!1,q.current){try{q.current.disconnect()}catch{}q.current.onaudioprocess=null}if(H.current)try{H.current.disconnect()}catch{}if(L.current)try{L.current.disconnect()}catch{}if(re.current)try{re.current.getTracks().forEach(J=>J.stop())}catch{}if(ce.current)try{await ce.current.close()}catch{}Z.current=[],q.current=null,H.current=null,L.current=null,re.current=null,ce.current=null,ue.current=ss},[]),ie=m.useCallback(async()=>{if(re.current&&ce.current&&q.current)return;O(rt=>rt==="recording"?rt:"arming");const J=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ss,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),he=new AudioContext({latencyHint:"interactive"}),Ae=he.createMediaStreamSource(J),ht=he.createScriptProcessor(1024,1,1),Oe=he.createGain();Oe.gain.value=0,ht.onaudioprocess=rt=>{if(!ae.current)return;const ot=rt.inputBuffer.getChannelData(0);Z.current.push(new Float32Array(ot))},Ae.connect(ht),ht.connect(Oe),Oe.connect(he.destination),re.current=J,ce.current=he,H.current=Ae,q.current=ht,L.current=Oe,ue.current=he.sampleRate||ss},[]),me=m.useCallback(async({send:J})=>{const he=ae.current;if(ae.current=!1,!he){J||O("idle");return}const Ae=Z.current;if(Z.current=[],!J){O("idle");return}if(!v){O("idle");return}if(!Ae.length){O("idle");return}O("sending");try{const ht=yw(Ae),Oe=jw(ht,ue.current||ss),rt=jx(Oe);await l?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:rt}),O("idle")}catch(ht){O("error"),D(ht?.message||"Failed to send PTT clip.")}},[l,v]),le=m.useCallback(async()=>{if(!v){D("Take control of your rover first.");return}await ie(),Z.current=[],ae.current=!0,O("recording")},[ie,v]);return m.useEffect(()=>{let J=!1;async function he(){if(A){await nt(W.current||v);return}if(!v){await nt(W.current);return}if(!(F.current&&W.current===v)&&!(!k&&!R))try{T("starting"),D(""),F.current=!0,W.current=v,await Ve(v),J||T("live")}catch(Ae){J||(T("error"),D(Ae?.message||"Failed to start mic forwarding.")),await nt(v)}}return he(),()=>{J=!0}},[A,k,R,v,Ve,nt]),m.useEffect(()=>{const J=Q.current;J&&(J.enabled=!!(!A&&(k||R)))},[A,k,R]),m.useEffect(()=>{let J=!1;async function he(){if(!A||!v){ae.current&&await me({send:!1}),O("idle");return}try{await ie(),!J&&!ae.current&&O("idle")}catch(Ae){J||(O("error"),D(Ae?.message||"Microphone access failed for clip mode."))}}return he(),()=>{J=!0}},[A,ie,me,v]),m.useEffect(()=>{let J=!1;async function he(){if(A){if(!v){ae.current&&await me({send:!1});return}if(R){if(!ae.current)try{D(""),await le()}catch(Ae){J||(O("error"),D(Ae?.message||"Failed to start clip recording."))}}else ae.current&&await me({send:!0})}}return he(),()=>{J=!0}},[A,me,R,v,le]),m.useEffect(()=>()=>{nt(W.current||v),mt()},[v,nt,mt]),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"grid gap-1",children:[r.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),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(Nx,{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 ${A?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Le("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${A?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Le("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(vn,{label:"Mode",active:A,detail:A?"record clip":"live mic"}),r.jsx(vn,{label:"PTT hold",active:R,detail:R?"held":"released"}),r.jsx(vn,{label:"Recording",active:be,detail:be?"capturing":"idle"}),r.jsx(vn,{label:"Playback",active:A&&se,detail:A&&se?"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:`${wi} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:E||!v,onChange:J=>S(J.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:y?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[y.name," (",y.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:E||!v,onClick:De,children:E?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:E||!v,onClick:Ee,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:k,disabled:!v||A,onChange:J=>g(he=>({...he||{},openMicEnabled:!!J.target.checked}))}),r.jsx("span",{children:A?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(vn,{label:"WHIP link",active:fe,detail:N}),r.jsx(vn,{label:"Mic hot",active:oe,detail:oe?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(Nx,{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(vn,{label:"Forward pipe",active:ne,detail:ne?"connected":"offline"}),r.jsx(vn,{label:"Upload playback",active:se,detail:se?"playing":"idle"}),r.jsx(vn,{label:"Mic relay",active:pe,detail:pe?"active":"idle"}),r.jsx(vn,{label:"WHIP transport",active:fe,detail:N}),r.jsx(vn,{label:"Clip recording",active:be,detail:be?"recording":"idle"}),r.jsx(vn,{label:"Clip sending",active:ve,detail:ve?"sending":"idle"})]}),K?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:K}):null]})})]})})}function Nw({pendingRequestId:n,currentStoredKey:s,nickname:l,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:h=!1}){const[p,x]=m.useState(0),[g,v]=m.useState(""),[y,S]=m.useState(!1),[E,C]=m.useState(!1),k=()=>{x(1),v(s),S(!1),d?.("")},w=()=>{x(0),S(!1)},A=async T=>{if(T.preventDefault(),!y){d?.("Please confirm your nickname agreement before sending.");return}if(p<3){d?.("Complete all request steps before sending.");return}C(!0),d?.("");try{const M=await f(g);await o?.(),v(M),x(0),S(!1),d?.("Verification request sent to lockdown admins.")}catch(M){d?.(M.message||"Failed to submit request.")}finally{C(!1)}},N=h?"w-full":Bo;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${N}`,children:r.jsxs("div",{className:xi,children:["Verification request pending: ",n]})}):p===0?r.jsx("section",{className:`surface ${N}`,children:r.jsxs("div",{className:xi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:k,disabled:E,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${N}`,onSubmit:A,children:r.jsxs("div",{className:xi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",p," of 3"]}),p===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(Do,{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:l||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:y,onChange:T=>S(T.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:!l||!y,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,p===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:wi,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:T=>v(T.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,p===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:wi,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:T=>v(T.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:E||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function ww({currentStoredKey:n,applyIdentityKey:s,onMessage:l,fullWidth:o=!1}){const[f,d]=m.useState(0),[h,p]=m.useState(""),[x,g]=m.useState(!1),v=()=>{d(1),p(""),l?.("")},y=()=>{d(0),p("")},S=async C=>{if(C.preventDefault(),!(f<2)){g(!0),l?.("");try{await s(h),d(0),p(""),l?.("Identity key restored.")}catch(k){l?.(k.message||"Failed to restore key.")}finally{g(!1)}}},E=o?"w-full":Bo;return r.jsx("section",{className:`surface ${E}`,children:r.jsxs("div",{className:xi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",dw(n)||"not set yet"]}),r.jsx("input",{className:wi,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:v,disabled:x,children:"Restore Key"})]}):null,f===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:y,children:"Cancel"})]})]}):null,f===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[r.jsx("input",{className:wi,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:C=>p(C.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!h,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function Cw({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:l,onMessage:o,fullWidth:f=!1}){const[d,h]=m.useState({}),p=m.useMemo(()=>{const v=new Map;return(s||[]).forEach(y=>{y?.roverId&&v.set(String(y.roverId),y)}),v},[s]),x=f?"w-full":Bo,g=async v=>{if(v){h(y=>({...y,[v]:!0})),o?.("");try{(await l?.(v))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(y){o?.(y.message||"Failed to send request.")}finally{h(y=>({...y,[v]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:r.jsxs("div",{className:xi,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(v=>{const y=String(v.id),S=!!d[y],E=p.get(y);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:v.name||y}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:y})]}),E?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(y),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},y)})})]})})}function mo(n){return String(n||"").trim()}function Ew(n){const s=mo(n);return s?s.includes("DOCKINGRUNNING")?"Returning":s.includes("PAUSED")?"Paused":s.includes("HOUSECLEANINGRUNNING")?"Cleaning":s.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":s.includes("STATE_START")?"Starting":s.includes("STATE_IDLE")||s.includes("STATE_STANDBY")?"Idle":s:"--"}function Ig(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":n==="info"?"bg-sky-600 text-white":"bg-slate-700 text-slate-100"}function ls({label:n,value:s,tone:l="muted",valueClass:o=""}){return r.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${Ig(l)}`,children:[r.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),r.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(s||""),children:s})]})}function kw({neato:n,onStart:s,onSendHome:l,onLocate:o,onClearErrors:f,fullWidth:d=!1}){const[h,p]=m.useState(""),x=d?"w-full":"w-full max-w-xl",g=!!n?.configured,v=!!(n?.enabled&&n?.connected),y=!!n?.telemetry?.extPowerPresent,S=!!n?.telemetry?.chargingActive,E=Ew(n?.telemetry?.uiState),C=mo(n?.telemetry?.uiState).toUpperCase(),k=n?.telemetry?.batteryPercent,w=Number.isFinite(k)?`${k}%`:"--",A=n?.telemetry?.batteryVoltage,N=Number.isFinite(A)?`${A.toFixed(2)} V`:"--",T=mo(n?.telemetry?.robotError)||"--",M=mo(n?.telemetry?.robotAlert)||"--",O=T!=="--"&&!/^no errors$/i.test(T)&&!/^200/.test(T),K=M!=="--"&&!/^200/.test(M),D=n?.controls||{},U=!!D?.start?.available,Q=!!D?.sendHome?.available,$=!!D?.locate?.available,F=!!D?.clearErrors?.available,W=m.useMemo(()=>{const R=C.includes("STATE_IDLE")||C.includes("STATE_STANDBY");return y||R?{key:"start",label:"Start cleaning",pending:"Starting...",toneClass:"bg-emerald-600 hover:bg-emerald-500 text-white",canRun:U,fn:s}:{key:"home",label:"Send to dock",pending:"Sending...",toneClass:"bg-sky-600 hover:bg-sky-500 text-white",canRun:Q,fn:l}},[y,C,U,s,Q,l]),re=g&&v&&W.canRun,ce=g&&v&&$,H=g&&v&&F,q=async(R,V)=>{if(V){p(R);try{await V()}catch{}finally{p("")}}},L=g?v?"Online":"Offline":"Not configured",Z=g?v?"good":"danger":"warn",ae=k==null?"muted":k>=60?"good":k>=25?"warn":"danger",ue=y?"Docked":E!=="--"?E:"Away from dock";return r.jsx("section",{className:`surface text-sm text-slate-200 ${x}`,children:r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),r.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac"})]}),r.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${Ig(Z)}`,children:L})]}),r.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[r.jsx("div",{className:"text-xs text-slate-300",children:"State"}),r.jsx("div",{className:"text-base font-semibold text-slate-100",children:ue})]}),r.jsx("button",{type:"button",disabled:!re||!!h,onClick:()=>q(W.key,W.fn),className:`rounded-md px-1 py-1 text-base font-semibold transition disabled:opacity-50 ${W.toneClass}`,children:h===W.key?W.pending:W.label})]}),r.jsx("button",{type:"button",disabled:!ce||!!h,onClick:()=>q("locate",o),className:"rounded-md bg-fuchsia-600 px-1 py-0.75 text-sm font-semibold text-white transition hover:bg-fuchsia-500 disabled:opacity-50",children:h==="locate"?"Playing...":"Play sound"}),r.jsx("button",{type:"button",disabled:!H||!!h,onClick:()=>q("clearErrors",f),className:"rounded-md bg-amber-500 px-1 py-0.75 text-sm font-semibold text-slate-900 transition hover:bg-amber-400 disabled:opacity-50",children:h==="clearErrors"?"Clearing...":"Clear errors"})]})}),r.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:r.jsxs("div",{className:"grid gap-0.5 grid-cols-2 sm:grid-cols-3 lg:grid-cols-7",children:[r.jsx(ls,{label:"Battery",value:w,tone:ae}),r.jsx(ls,{label:"Voltage",value:N,tone:A==null?"muted":"info"}),r.jsx(ls,{label:"Docked",value:y?"Yes":"No",tone:y?"info":"muted"}),r.jsx(ls,{label:"Charging",value:S?"Yes":"No",tone:S?"info":"muted"}),r.jsx(ls,{label:"UI state",value:E,tone:"muted",valueClass:"truncate"}),r.jsx(ls,{label:"Robot error",value:T,tone:O?"danger":"muted",valueClass:"truncate"}),r.jsx(ls,{label:"Robot alert",value:M,tone:K?"warn":"muted",valueClass:"truncate"})]})}),!g||!v||!W.canRun||!$||!F?r.jsx("p",{className:"text-xs text-slate-400 text-center",children:g?v?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function Mw(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function Rw(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Stopped":n==="conflict"?"Conflict":"--"}function qw({lift:n,onUp:s,onDown:l,fullWidth:o=!1}){const[f,d]=m.useState(""),h=o?"w-full":"w-full max-w-xl",p=!!n?.configured,x=!!(n?.enabled&&n?.connected),g=!!n?.busy,v=String(n?.target||"").toLowerCase(),y=String(n?.position||"").toLowerCase(),S=!!n?.availability?.upSwitch,E=!!n?.availability?.downSwitch,C=p?x?g?"Busy":"Ready":"Offline":"Not configured",k=p?x?g?"warn":"good":"danger":"warn",w=p&&x&&!g&&!f&&S&&E,A=async(N,T)=>{if(T){d(N);try{await T()}catch{}finally{d("")}}};return r.jsx("section",{className:`surface text-sm text-slate-200 ${h}`,children:r.jsxs("div",{className:"grid gap-0.5",children:[r.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),r.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),r.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${Mw(k)}`,children:C})]}),r.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[r.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[r.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),r.jsx("div",{className:"text-base font-semibold text-slate-100",children:Rw(y)})]}),r.jsx("button",{type:"button",disabled:!w,onClick:()=>A("down",l),className:`rounded-md px-1 py-0.75 text-base font-semibold transition disabled:opacity-50 ${y==="down"||v==="down"?"bg-sky-600 text-white":"bg-slate-700 text-slate-100 hover:bg-slate-600"}`,children:f==="down"||v==="down"?"Lowering...":"Down"}),r.jsx("button",{type:"button",disabled:!w,onClick:()=>A("up",s),className:`rounded-md px-1 py-0.75 text-base font-semibold transition disabled:opacity-50 ${y==="up"||v==="up"?"bg-emerald-600 text-white":"bg-slate-700 text-slate-100 hover:bg-slate-600"}`,children:f==="up"||v==="up"?"Raising...":"Up"})]})}),!p||!x||!S||!E?r.jsx("p",{className:"text-xs text-slate-400 text-center",children:p?x?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?r.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})})}function Jg(){const{session:n,identifySession:s,requestVerification:l,requestPrivateRoverAccess:o,playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x,neatoStart:g,neatoSendHome:v,neatoLocate:y,neatoClearErrors:S,liftUp:E,liftDown:C}=nn(),{value:k,save:w}=Ge("identity",{cookieUserId:""}),{value:A}=Ge("profile",{nickname:""}),N=m.useMemo(()=>(k?.cookieUserId||"").trim(),[k?.cookieUserId]),T=(A?.nickname||"").trim(),M=!!n?.isVerified,O=n?.verification?.pendingRequestId||null,K=n?.privateRoverAccess?.requestableRovers||[],D=n?.privateRoverAccess?.pendingRequests||[],U=String(n?.assignment?.roverId||"").trim(),[Q,$]=m.useState(""),F=async W=>{const re=String(W||"").trim().toLowerCase();if(!re)throw new Error("Identity key required.");if(!fw.test(re))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return w(ce=>({...ce||{},cookieUserId:re})),await s({cookieUserId:re,nickname:T}),re};return r.jsxs("section",{className:"space-y-2 text-base",children:[r.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[M?null:r.jsx("div",{className:"lg:col-span-2",children:r.jsx(Nw,{pendingRequestId:O,currentStoredKey:N,nickname:T,requestVerification:l,applyIdentityKey:F,onMessage:$,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:M?r.jsxs("div",{className:"space-y-2",children:[r.jsx(kw,{neato:n?.neato||null,onStart:g,onSendHome:v,onLocate:y,onClearErrors:S,fullWidth:!0}),r.jsx(qw,{lift:n?.lift||null,onUp:E,onDown:C,fullWidth:!0}),r.jsx(Aw,{ownRoverId:U,audioForwardByRover:n?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x})]}):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(Cw,{requestableRovers:K,pendingRequests:D,requestPrivateRoverAccess:o,onMessage:$,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(ww,{currentStoredKey:N,applyIdentityKey:F,onMessage:$,fullWidth:!0})})]}),Q?r.jsx("div",{className:Bo,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:Q})}):null]})}const Tw=420,Dw=1200,_w={1:262,2:330,3:392,4:523};function Ao(){const{session:n}=nn(),s=tn(),{value:l}=Ge("audio",st),o=Number.isFinite(l?.masterVolume)?l.masterVolume:st.masterVolume,f=Number.isFinite(l?.alertVolume)?l.alertVolume:st.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=m.useMemo(()=>{const k=Array.isArray(n?.buttonBox?.buttons)?n.buttonBox.buttons:[];return k.length===4?k:[1,2,3,4].map(w=>k.find(A=>Number(A?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n?.buttonBox?.buttons]),[p,x]=m.useState({}),[g,v]=m.useState({}),y=m.useRef(new Map),S=m.useRef(new Map),E=m.useRef({}),C=m.useRef(null);return m.useEffect(()=>{const k={};h.forEach(A=>{k[A.id]=Number(A.lastRewardAt||0)});const w=E.current||{};h.forEach(A=>{const N=Number(A.id),T=k[N]||0,M=Number(w[N]||0);if(T>0&&T!==M){v(D=>({...D,[N]:!0}));const O=S.current.get(N);O&&clearTimeout(O);const K=setTimeout(()=>{v(D=>({...D,[N]:!1})),S.current.delete(N)},Dw);S.current.set(N,K)}}),E.current=k},[h]),m.useEffect(()=>{function k(A){const N=_w[A];if(!N||d<=0)return;let T=C.current;if(!T){const D=window.AudioContext||window.webkitAudioContext;if(!D)return;T=new D,C.current=T}const M=T.createOscillator(),O=T.createGain();M.type="square",M.frequency.value=N;const K=.14*d;O.gain.setValueAtTime(1e-4,T.currentTime),O.gain.exponentialRampToValueAtTime(Math.max(1e-4,K),T.currentTime+.01),O.gain.exponentialRampToValueAtTime(1e-4,T.currentTime+.2),M.connect(O),O.connect(T.destination),M.start(),M.stop(T.currentTime+.21)}function w(A={}){const N=Number(A.buttonId);if(!Number.isFinite(N)||N<1||N>4)return;x(O=>({...O,[N]:!0}));const T=y.current.get(N);T&&clearTimeout(T);const M=setTimeout(()=>{x(O=>({...O,[N]:!1})),y.current.delete(N)},Tw);y.current.set(N,M),k(N)}return s.on("buttonBox:increment",w),()=>{s.off("buttonBox:increment",w)}},[d,s]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("header",{className:"panel-muted text-center text-sm",children:r.jsx("p",{children:"Button Box"})}),r.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:h.map(k=>{const w=Number(k.id),A=Number.isFinite(k.count)?k.count:0,N=Number.isFinite(k.goal)?k.goal:0,T=typeof k.rewardName=="string"&&k.rewardName.trim()?k.rewardName.trim():"Unassigned",M=Number.isFinite(k.rewardNumber)?k.rewardNumber:"?",O=!!p[w],K=!!g[w];return r.jsx(xg,{buttonId:w,count:A,goal:N,rewardNumber:M,rewardName:T,className:[O?"bg-cyan-900/45":"",K?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function Bw(){const{state:{roverId:n}}=_t(),l=ul(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Vf,{sensors:l})})})}function Ow(){const{state:{roverId:n,keymap:s,camera:l,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:p,stopHorn:x}}=_t(),g=qg(n),v=g.docked&&!g.driving,y=l?.config,S=!!(n&&l?.enabled&&y),E=!!(n&&f?.nightVision),C=f?.nightVisionState,k=!!(n&&f?.horn),w=o?.overheated,A=typeof y?.minAngle=="number"?y.minAngle:-30,N=typeof y?.maxAngle=="number"?y.maxAngle:30,T=typeof l?.angle=="number"?l.angle:typeof y?.homeAngle=="number"?y.homeAngle:(A+N)/2,M=Cn(s?.nightVisionToggle?.[0]),O=Cn(s?.hornHonk?.[0]),K=Cn(s?.cameraUp?.[0]),D=Cn(s?.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(Tg,{layout:"desktop",expand:!0,driveDockState:g}),v?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[E&&r.jsx(Dg,{nightVisionOn:C?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:M}),k&&r.jsx(_g,{disabled:!n||w,onStart:p,onStop:x,keyLabel:O,active:o?.active,heat:o?.heat}),S&&r.jsx(Bg,{value:T,min:A,max:N,onChange:d,keyDownLabel:D,keyUpLabel:K,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 Lw({layout:n,onOpenHelpOverlay:s}){const l=it(E=>E.session),{state:o}=_t(),{value:f}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=l?.isVerified?"bg-emerald-400":"bg-red-600",h=String(l?.assignment?.roverId||"").trim(),p=h?l?.audioForward?.[h]:null,x=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,v=f?.pttMode==="clip"?"clip":"live",y=!!(h&&l?.isVerified&&(v==="clip"?x:g||x)),S=!!(h&&l?.isVerified&&v==="clip"&&p?.source==="upload"&&p?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(yd,{defaultTab:"telemetry",children:[r.jsxs(Sd,{children:[r.jsx(Wt,{id:"telemetry",children:"Controls"}),r.jsx(Wt,{id:"vip",highlight:S?"green":y?"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:l?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(jd,{children:[r.jsx(en,{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(Bw,{}),r.jsx(Ow,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(_o,{}),r.jsx(ad,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(sw,{})]}),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(To,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(jo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(aw,{compact:!0})]})]}),r.jsx(Hg,{}),r.jsx(Ao,{}),r.jsx(fd,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Jg,{})}),r.jsx(en,{id:"help",children:r.jsx(Kg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsx(Fg,{})})]})]})})}const zw=new Set(["admin","lockdown","lockdown-admin"]),Uw=new Set(["lockdown","lockdown-admin"]),Hw=new Set(["admin","lockdown"]);function Vw(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 $w(){const n=it(S=>S.session),s=n?.mode,l=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const f=n?.timezone||"UTC",d=n?.socials?.find(S=>String(S?.id||S?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,h=Hw.has(s),p=s==="lockdown"?Uw.has(l):zw.has(l),[x,g]=m.useState(()=>new Date),v=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,f]);if(m.useEffect(()=>{const S=setInterval(()=>g(new Date),1e3);return()=>clearInterval(S)},[]),!h||p)return null;const y=Vw(s);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:y.title}),r.jsx("p",{className:"text-sm text-slate-300",children:y.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: ",v]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(Vg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(hd,{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(To,{}),r.jsx(Do,{})]})]})})}const Gw="/assets/turn_alert-DVO8EZJa.mp3";function Yw(n,s=1){const l=m.useRef(null);return m.useEffect(()=>{l.current=new Audio(n),l.current.volume=s,l.current.load()},[n,s]),()=>{l.current&&(l.current.volume=s,l.current.currentTime=0,l.current.play().catch(()=>{}))}}function Fw(){const n=it(v=>v.session),{pushAlert:s}=kn(),{value:l}=Ge("audio",st),o=Number.isFinite(l?.masterVolume)?l.masterVolume:st.masterVolume,f=Number.isFinite(l?.alertVolume)?l.alertVolume:st.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=Yw(Gw,d),p=m.useRef(new Set),x=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const v=[];Object.entries(x).forEach(([y,S])=>{!S||!S.current||S.current!==g||p.current.has(y)||(v.push(y),p.current.add(y))}),Object.keys(x).forEach(y=>{(!x[y]||x[y].current!==g)&&p.current.delete(y)}),v.length!==0&&(v.forEach(y=>{const S=n?.roster?.find(E=>String(E.id)===String(y))?.name||y;s({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),h())},[x,h,s,n?.roster,g]),null}function Xw({visible:n,mode:s,onEnterFullscreen:l,onDismiss:o}){if(!n)return null;const f=s==="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:l,children:"Enter fullscreen"})]})]})})})}function Qw({side:n="right",onClick:s}){const l=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${l} 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 Pg="fullscreenPromptDismissed",Kw=new Set(["mobile-portrait","mobile-landscape"]),Wg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},Zw=()=>{const n=Wg();if(!n)return!1;try{return n.getItem(Pg)==="1"}catch{return!1}},wx=()=>{const n=Wg();if(n)try{n.setItem(Pg,"1")}catch{}},Iw=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Cx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function Jw(n){const s=Kw.has(n),[l,o]=m.useState(!1),[f,d]=m.useState("native"),[h,p]=m.useState(!1),x=m.useMemo(()=>Iw(),[]),g=m.useMemo(()=>Cx(),[]),v=m.useCallback(()=>{if(!s){o(!1),p(!1);return}if(!h&&Zw()){o(!1);return}if(x){d("pwa-hint"),o(!0);return}if(!Cx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,x,s]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const C=()=>{if(document.fullscreenElement){p(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",C),document.addEventListener("webkitfullscreenchange",C),()=>{document.removeEventListener("fullscreenchange",C),document.removeEventListener("webkitfullscreenchange",C)}},[v]);const y=m.useCallback(()=>{wx(),p(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const C=document.documentElement;if(!C)return!1;const k=C.requestFullscreen||C.webkitRequestFullscreen||C.mozRequestFullScreen||C.msRequestFullscreen;if(!k)return!1;try{const w=k.call(C);return w&&typeof w.then=="function"&&await w,wx(),p(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[x,s]),E=m.useCallback(()=>{s&&(p(!0),d(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(p(!1),o(!1))},[s]),{visible:l,mode:f,isIOS:x,nativeSupported:g,enterFullscreen:S,dismiss:y,showPrompt:E}}function Pw({visible:n,layout:s,onClose:l,showOnLoad:o,onToggleShowOnLoad:f}){if(!n)return null;const{state:d}=_t(),h=p=>{const x=!p.target.checked;f?.(x)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:l,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(Qg,{layout:s,keymap:d?.keymap||{}})})]})})}const Ww=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
shrimp
|
||
fling`;function e2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function t2(){const n=String(Ww).split(/\r?\n/).map(l=>l.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function Ad(){const{setNickname:n}=kn(),{value:s,status:l,save:o}=Ge("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(l!=="ready"||f.current||(s.nickname||"").trim())return;f.current=!0;const h=e2(t2()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,l,s.nickname])}function n2(){const n=tn(),s=it(w=>w.connected),{identifySession:l}=kn(),{value:o,status:f,save:d}=Ge("identity",{cookieUserId:""}),{value:h,status:p}=Ge("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),v=m.useRef(null),y=f==="ready"&&p==="ready",S=(o?.cookieUserId||"").trim(),E=(h?.nickname||"").trim(),C=m.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),k=m.useCallback(async()=>{if(!(!y||!s||!n?.id||x.current)){x.current=!0;try{const A=((await l({cookieUserId:S,nickname:E}))?.cookieUserId||"").trim();A&&A!==S&&d(N=>({...N||{},cookieUserId:A})),g.current=n.id,C()}catch{C(),v.current=setTimeout(()=>{k()},2e3)}finally{x.current=!1}}},[C,s,S,l,E,y,d,n?.id]);m.useEffect(()=>{!y||!s||!n?.id||g.current!==n.id&&k()},[s,y,k,n?.id]),m.useEffect(()=>{!y||!s||!n?.id||k()},[y,s,n?.id,S,E,k]),m.useEffect(()=>{const w=()=>{n?.connected&&k()},A=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&k()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",A)}},[k,n?.connected]),m.useEffect(()=>()=>C(),[C])}const jf=1e4,Af=28,a2=14;function No({layout:n="desktop",className:s="",dismissable:l=!0}){const{session:o}=nn(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[h,p]=m.useState(!1),[x,g]=m.useState(Af),[v,y]=m.useState(0),S=m.useRef(null),E=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!f){p(!1);return}if(p(!0),!d||!l)return;const N=Date.now();y(jf);const T=setTimeout(()=>p(!1),jf),M=setInterval(()=>{const O=Date.now()-N;y(Math.max(0,jf-O))},250);return()=>{clearTimeout(T),clearInterval(M)}},[f,d]),m.useEffect(()=>{if(!f)return;g(Af);let N=0;const T=()=>{const O=C.current,K=E.current;if(!O||!K)return;const D=O.clientWidth;if(!D)return;const U=K.scrollWidth;if(!U)return;const Q=Math.min(1,D/U),$=Math.max(a2,Math.floor(Af*Q));g($)};N=window.requestAnimationFrame(T);const M=new ResizeObserver(()=>{window.cancelAnimationFrame(N),N=window.requestAnimationFrame(T)});return S.current&&M.observe(S.current),()=>{window.cancelAnimationFrame(N),M.disconnect()}},[f]);const k=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",s].filter(Boolean).join(" "),[s,d]);if(!f||!h)return null;const w=d?Math.ceil(v/1e3):null,A=l?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:S,className:k,style:{fontSize:`${x}px`,lineHeight:1.1},...A,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:E,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:[w,"s"]}):null]})})}const s2=3200;function l2(n={}){const s=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",l=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):l;return{rewardName:s,goal:l,count:o,ts:Date.now()}}function ev(){const n=tn(),{value:s}=Ge("audio",st),l=Number.isFinite(s?.masterVolume)?s.masterVolume:st.masterVolume,o=Number.isFinite(s?.alertVolume)?s.alertVolume:st.alertVolume,f=Math.max(0,Math.min(1,l*o)),[d,h]=m.useState(null),p=m.useRef(null);return m.useEffect(()=>{p.current=new Audio("/tada.mp3"),p.current.volume=f,p.current.load()},[f]),m.useEffect(()=>{let x=null;function g(){const S=p.current;S&&(S.volume=f,S.currentTime=0,S.play().catch(()=>{}))}function v(S={}){const E=l2(S);h(E),g(),x&&clearTimeout(x),x=setTimeout(()=>{h(null)},s2)}function y(S){v(S?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",y),()=>{x&&clearTimeout(x),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",y)}},[f,n]),d?r.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:r.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:r.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[r.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",d.rewardName,"!"]}),r.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[d.count,"/",d.goal]})]}),r.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function i2(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function l(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?s("desktop"):o>f?s("mobile-landscape"):s("mobile-portrait")}return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[]),n}function r2({layout:n,onOpenHelpOverlay:s}){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(xd,{}),r.jsx(nj,{}),r.jsx(dd,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(No,{layout:n}),r.jsx(Lw,{layout:n,onOpenHelpOverlay:s})]})]})}function tv({layout:n,onOpenHelpOverlay:s,roomPanelId:l,showTelemetry:o=!0}){const f=it(k=>k.session),{state:d}=_t(),{value:h}=Ge("vipAudio",{openMicEnabled:!1,pttMode:"live"}),p=f?.isVerified?"bg-emerald-400":"bg-amber-400",x=String(f?.assignment?.roverId||"").trim(),g=x?f?.audioForward?.[x]:null,v=!!d?.mic?.pttActive,y=!!h?.openMicEnabled,S=h?.pttMode==="clip"?"clip":"live",E=!!(x&&f?.isVerified&&(S==="clip"?v:y||v)),C=!!(x&&f?.isVerified&&S==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(yd,{defaultTab:"chat",children:[r.jsxs(Sd,{children:[r.jsx(Wt,{id:"chat",children:"Chat"}),r.jsx(Wt,{id:"vip",highlight:C?"green":E?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${p}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(jd,{children:[r.jsx(en,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(To,{}),r.jsx(jo,{})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Jg,{})}),r.jsx(en,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Hg,{}),r.jsx(Ao,{}),r.jsx(fd,{panelId:l})]})}),r.jsx(en,{id:"help",children:r.jsx(Kg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Fg,{}),r.jsx(dd,{})]})})]})]})})}function o2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(xd,{layoutFormat:"mobile-portrait"}),r.jsx(kA,{swapColumns:s}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(ad,{panelId:"replay-sources-mobile-portrait"}),r.jsx(_o,{})]}),r.jsx(tv,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function c2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const l="self-start h-[min(100svh,32rem)]",o=s?r.jsx(yo,{layout:"landscape",className:l}):r.jsx(bo,{layout:"landscape",className:l}),f=s?r.jsx(bo,{layout:"landscape",className:l}):r.jsx(yo,{layout:"landscape",className:l});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(xd,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(ad,{panelId:"replay-sources-mobile-landscape"}),r.jsx(_o,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(tv,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function u2(){const n=i2(),s=n==="desktop",l=Jw(n);return r.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(f2,{layout:n,isDesktop:s,fullscreen:l})})}function f2({layout:n,isDesktop:s,fullscreen:l}){Ad(),n2();const{visible:o,mode:f,isIOS:d,nativeSupported:h,enterFullscreen:p,dismiss:x,showPrompt:g}=l,{value:v,status:y,save:S}=Ge("help",{showOnLoad:!0}),{value:E}=Ge("page",{swapMobileControlColumns:!1}),C=!!E?.swapMobileControlColumns,k=C?"left":"right",w=!s&&(d||h),[A,N]=m.useState(!1);m.useEffect(()=>{y==="ready"&&N(v?.showOnLoad!==!1)},[y,v?.showOnLoad]);const T=m.useCallback(()=>N(!0),[]),M=m.useCallback(()=>N(!1),[]),O=m.useCallback(async()=>{if(d){g();return}await p()||g()},[p,d,g]),K=m.useCallback(U=>{const Q=!!U;S($=>({...$??{},showOnLoad:Q})),Q||N(!1)},[S]),D=m.useMemo(()=>s?r.jsx(r2,{layout:n,onOpenHelpOverlay:T}):n==="mobile-landscape"?r.jsx(c2,{onOpenHelpOverlay:T,swapMobileControlColumns:C}):r.jsx(o2,{onOpenHelpOverlay:T,swapMobileControlColumns:C}),[s,n,T,C]);return r.jsxs(Zj,{children:[r.jsx(iA,{}),r.jsx(vA,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:r.jsx(No,{layout:n}),D]}),r.jsx(id,{}),r.jsx(ev,{}),r.jsx(Fw,{}),r.jsx($w,{}),r.jsx(Pw,{visible:A,layout:n,onClose:M,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:K}),r.jsx(Xw,{visible:o,mode:f,onEnterFullscreen:p,onDismiss:x}),w?r.jsx(Qw,{side:k,onClick:O}):null]})}function nv(){const{session:n,setRole:s,subscribeAll:l,connected:o}=nn(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(n?.mode==="lockdown"){d(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await l(),h||d(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||d(!1)}}return p(),()=>{h=!0}},[o,n?.mode,n?.role,s,l]),f}function d2(){const[n,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const l=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>s(f.matches);return l.addEventListener?l.addEventListener("change",o):l.addListener(o),()=>{l.removeEventListener?l.removeEventListener("change",o):l.removeListener(o)}},[]),n}function m2({roverId:n,session:s}){const l=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(x=>x.socketId===l)?.nickname||(l?l.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f} (turns)`:f}function h2({rover:n,frame:s,sessionInfo:l,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const p=m2({roverId:n.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(ji,{sessionInfo:l,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function p2({roster:n,frames:s,videoSources:l,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){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(p=>r.jsx(h2,{rover:p,frame:s[p.id],sessionInfo:h&&l[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:f[`${p.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function x2(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(fd,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function g2({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(dd,{})})}function v2(){const{session:n}=nn(),s=n?.mode==="lockdown",l=!!n?.isLocalNetwork;Ad(),nv();const o=d2(),f=td(),d=n?.roster??[],h=md(d.map(w=>w.id),{enabled:!s&&!l,version:n?.mode}),p=l?d.map(w=>({type:"rover",id:w.id,key:w.id})):[],x=yi(p,{enabled:!s&&l,version:n?.mode}),g=d.flatMap(w=>w.media?.audioPublishUrl?[{type:"rover",id:`${w.id}-audio`,key:`${w.id}-audio`}]:[]),v=yi(g,{enabled:!s,version:n?.mode});if(s)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 y=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",S=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",E=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",C="",k=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:y,children:[r.jsxs("section",{className:E,children:[o?r.jsxs("div",{className:`${C} ${k} flex flex-col gap-0.5`,children:[r.jsx(No,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(Ao,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsxs("div",{className:C,children:[r.jsx(No,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(Ao,{})]}),r.jsx("div",{className:`${C} ${o?`${k} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(_o,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${C} flex-1 min-h-0`,children:r.jsx(jo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${C} ${o?k:"flex-[1.1] min-h-0"}`,children:r.jsx(To,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${C} ${o?k:""}`,children:r.jsx(g2,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:S,children:[r.jsx(p2,{roster:d,frames:f,videoSources:x,snapshotFeeds:h,audioSources:v,session:n,canSpectateVideo:l}),r.jsx(x2,{})]})]}),r.jsx(id,{}),r.jsx(ev,{})]})}function b2(){return r.jsx(v2,{})}function y2({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})})})}function S2({roverId:n,session:s}){const l=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(p=>p.socketId===l)?.nickname||(l?l.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f}`:f}function j2({rover:n,frame:s}){const l=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return zg({batteryState:n?.batteryState??null,charge:l,config:o})}function tl({children:n,className:s="",maxSize:l=1e3,minSize:o=14,style:f=void 0}){const d=m.useRef(null),h=m.useRef(null),[p,x]=m.useState(l);return m.useLayoutEffect(()=>{const g=d.current,v=h.current;if(!g||!v)return;let y=null;const S=()=>{const k=g.clientWidth;if(!k){E();return}let w=o,A=l,N=o;for(;w<=A;){const T=Math.floor((w+A)/2);v.style.fontSize=`${T}px`,v.scrollWidth<=k?(N=T,w=T+1):A=T-1}x(N)},E=()=>{y&&cancelAnimationFrame(y),y=requestAnimationFrame(S)};E();const C=new ResizeObserver(E);return C.observe(g),()=>{y&&cancelAnimationFrame(y),C.disconnect()}},[n,l,o]),r.jsx("div",{ref:d,className:"w-full min-w-0",children:r.jsx("div",{ref:h,className:`whitespace-nowrap ${s}`,style:{fontSize:`${p}px`,lineHeight:1.1,...f||{}},children:n})})}function Ex({rover:n,frame:s,driverLabel:l,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=j2({rover:n,frame:s}),v=g?.available?g.percentDisplay:null,y=x==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(Hf,{visual:g,orientation:y?"vertical":"horizontal",variant:"background"}),y?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(tl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:oa(n.color,.18),children:n.name||n.id})}),l?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(tl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:l})}):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(tl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):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(tl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:oa(n.color,.18),children:n.name||n.id})}),l?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(tl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:l})}):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(tl,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(ji,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}const A2=2e4,N2=3600*1e3;function w2(){const{session:n}=nn(),s=nv();Ad();const l=n?.mode==="lockdown",o=!!n?.isLocalNetwork,f=td(),d=n?.roster??[],[h,p]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>d.filter($=>x[$.id]),[d,x]),v=g.length?g:d,y=md(v.map($=>$.id),{enabled:!l&&!o,version:n?.mode}),S=m.useMemo(()=>o?v.map($=>({type:"rover",id:$.id,key:$.id})):[],[o,v]),E=yi(S,{enabled:!l&&o,version:n?.mode}),C=m.useMemo(()=>g.flatMap($=>{if(!$?.id||!$.media?.audioPublishUrl)return[];const F=String($.id);return[{type:"rover",id:`${F}-audio`,key:`${F}-audio`}]}),[g]),k=yi(C,{enabled:!l,version:n?.mode}),w=m.useMemo(()=>{if(!g.length)return[];if(!o){const F=g.filter(W=>y[W.id]?.objectUrl);return F.length?F:g}const $=g.filter(F=>{const W=E[F.id];return W?.url&&!W?.error});return $.length?$:g},[g,y,E,o]),A=m.useMemo(()=>w.map($=>({type:"rover",rover:$})),[w]),N=m.useMemo(()=>A.map($=>`r:${$.rover.id}`).join("|"),[A]);m.useEffect(()=>{p(0)},[N]),m.useEffect(()=>{if(!A.length)return;const $=setInterval(()=>{p(F=>(F+1)%A.length)},A2);return()=>clearInterval($)},[A.length,N]);const T=A.length?A[h%A.length]:null,M=T?.type==="rover"?T.rover:null,O=!o&&M&&y[M.id]||null,K=o&&M&&E[M.id]||null,D=M&&k[`${M.id}-audio`]||null,U=M&&f[M.id]||null,Q=M?S2({roverId:M.id,session:n}):null;return l?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:s?M?r.jsx(y2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:A.map($=>{const F=$.rover,W=M?.id===F.id;return r.jsx("div",{className:`absolute inset-0 ${W?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(ji,{sessionInfo:E[F.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:W?D:null,forceMute:!W,label:F.name||F.id,roverColor:F.color||null,telemetryFrame:f[F.id]||null,batteryConfig:F.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},F.id)})}):r.jsx(ji,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:O,audioSessionInfo:D,label:M.name||M.id,roverColor:M.color||null,telemetryFrame:U,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(Ex,{rover:M,frame:U,driverLabel:Q,sessionInfo:o?K:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[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($=>r.jsx(Ex,{rover:$,frame:f[$.id]||null,driverLabel:null,sessionInfo:o&&E[$.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[$.id]||null,showPreview:!0,withDivider:!1},$.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function C2(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const s=new URL(window.location.href);s.searchParams.set("refresh",Date.now().toString()),window.location.replace(s.toString())},N2);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(w2,{}),r.jsx(id,{scale:3})]})}function to(n){if(!n||!n.length)return null;const s=Math.floor(Math.random()*n.length);return n[s]||null}function E2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const s=to(n),l=to(n),o=s?.classList?.[0]||null;if(o&&l?.classList)try{l.classList.add(o)}catch{}const f=to(n),d=to(n),h=f?.classList?.[1]||null;if(h&&d?.classList)try{d.classList.add(h)}catch{}}function k2(){const n=it(s=>!!s.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const s=window.setInterval(()=>{E2()},1);return()=>{window.clearInterval(s)}},[n]),null}Ny.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(QS,{children:r.jsx(JS,{children:r.jsx(PS,{children:r.jsx(rj,{children:r.jsxs(Jj,{children:[r.jsx(k2,{}),r.jsx(U1,{children:r.jsxs(x1,{children:[r.jsx(no,{path:"/",element:r.jsx(u2,{})}),r.jsx(no,{path:"/spectate",element:r.jsx(b2,{})}),r.jsx(no,{path:"/mini",element:r.jsx(C2,{})})]})})]})})})})})}));
|