mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
126 lines
519 KiB
JavaScript
126 lines
519 KiB
JavaScript
(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function $y(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ru={exports:{}},Ks={};var I0;function Gy(){if(I0)return Ks;I0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var x in f)x!=="key"&&(d[x]=f[x])}else d=f;return f=d.ref,{$$typeof:a,type:o,key:h,ref:f!==void 0?f:null,props:d}}return Ks.Fragment=l,Ks.jsx=i,Ks.jsxs=i,Ks}var W0;function Yy(){return W0||(W0=1,Ru.exports=Gy()),Ru.exports}var r=Yy(),Tu={exports:{}},Ae={};var P0;function Xy(){if(P0)return Ae;P0=1;var a=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),N=Symbol.iterator;function q(E){return E===null||typeof E!="object"?null:(E=N&&E[N]||E["@@iterator"],typeof E=="function"?E:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,j={};function k(E,V,te){this.props=E,this.context=V,this.refs=j,this.updater=te||C}k.prototype.isReactComponent={},k.prototype.setState=function(E,V){if(typeof E!="object"&&typeof E!="function"&&E!=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,E,V,"setState")},k.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function S(){}S.prototype=k.prototype;function M(E,V,te){this.props=E,this.context=V,this.refs=j,this.updater=te||C}var T=M.prototype=new S;T.constructor=M,w(T,k.prototype),T.isPureReactComponent=!0;var L=Array.isArray;function H(){}var O={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function z(E,V,te){var ne=te.ref;return{$$typeof:a,type:E,key:V,ref:ne!==void 0?ne:null,props:te}}function K(E,V){return z(E.type,V,E.props)}function Z(E){return typeof E=="object"&&E!==null&&E.$$typeof===a}function ae(E){var V={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(te){return V[te]})}var ue=/\/+/g;function le(E,V){return typeof E=="object"&&E!==null&&E.key!=null?ae(""+E.key):V.toString(36)}function U(E){switch(E.status){case"fulfilled":return E.value;case"rejected":throw E.reason;default:switch(typeof E.status=="string"?E.then(H,H):(E.status="pending",E.then(function(V){E.status==="pending"&&(E.status="fulfilled",E.value=V)},function(V){E.status==="pending"&&(E.status="rejected",E.reason=V)})),E.status){case"fulfilled":return E.value;case"rejected":throw E.reason}}throw E}function R(E,V,te,ne,de){var re=typeof E;(re==="undefined"||re==="boolean")&&(E=null);var ce=!1;if(E===null)ce=!0;else switch(re){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(E.$$typeof){case a:case l:ce=!0;break;case b:return ce=E._init,R(ce(E._payload),V,te,ne,de)}}if(ce)return de=de(E),ce=ne===""?"."+le(E,0):ne,L(de)?(te="",ce!=null&&(te=ce.replace(ue,"$&/")+"/"),R(de,V,te,"",function(ge){return ge})):de!=null&&(Z(de)&&(de=K(de,te+(de.key==null||E&&E.key===de.key?"":(""+de.key).replace(ue,"$&/")+"/")+ce)),V.push(de)),1;ce=0;var xe=ne===""?".":ne+":";if(L(E))for(var pe=0;pe<E.length;pe++)ne=E[pe],re=xe+le(ne,pe),ce+=R(ne,V,te,re,de);else if(pe=q(E),typeof pe=="function")for(E=pe.call(E),pe=0;!(ne=E.next()).done;)ne=ne.value,re=xe+le(ne,pe++),ce+=R(ne,V,te,re,de);else if(re==="object"){if(typeof E.then=="function")return R(U(E),V,te,ne,de);throw V=String(E),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return ce}function Q(E,V,te){if(E==null)return E;var ne=[],de=0;return R(E,ne,"","",function(re){return V.call(te,re,de++)}),ne}function P(E){if(E._status===-1){var V=E._result;V=V(),V.then(function(te){(E._status===0||E._status===-1)&&(E._status=1,E._result=te)},function(te){(E._status===0||E._status===-1)&&(E._status=2,E._result=te)}),E._status===-1&&(E._status=0,E._result=V)}if(E._status===1)return E._result.default;throw E._result}var ie=typeof reportError=="function"?reportError:function(E){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=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(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",E);return}console.error(E)},oe={map:Q,forEach:function(E,V,te){Q(E,function(){V.apply(this,arguments)},te)},count:function(E){var V=0;return Q(E,function(){V++}),V},toArray:function(E){return Q(E,function(V){return V})||[]},only:function(E){if(!Z(E))throw Error("React.Children.only expected to receive a single React element child.");return E}};return Ae.Activity=y,Ae.Children=oe,Ae.Component=k,Ae.Fragment=i,Ae.Profiler=f,Ae.PureComponent=M,Ae.StrictMode=o,Ae.Suspense=p,Ae.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Ae.__COMPILER_RUNTIME={__proto__:null,c:function(E){return O.H.useMemoCache(E)}},Ae.cache=function(E){return function(){return E.apply(null,arguments)}},Ae.cacheSignal=function(){return null},Ae.cloneElement=function(E,V,te){if(E==null)throw Error("The argument must be a React element, but you passed "+E+".");var ne=w({},E.props),de=E.key;if(V!=null)for(re in V.key!==void 0&&(de=""+V.key),V)!F.call(V,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&V.ref===void 0||(ne[re]=V[re]);var re=arguments.length-2;if(re===1)ne.children=te;else if(1<re){for(var ce=Array(re),xe=0;xe<re;xe++)ce[xe]=arguments[xe+2];ne.children=ce}return z(E.type,de,ne)},Ae.createContext=function(E){return E={$$typeof:h,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null},E.Provider=E,E.Consumer={$$typeof:d,_context:E},E},Ae.createElement=function(E,V,te){var ne,de={},re=null;if(V!=null)for(ne in V.key!==void 0&&(re=""+V.key),V)F.call(V,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(de[ne]=V[ne]);var ce=arguments.length-2;if(ce===1)de.children=te;else if(1<ce){for(var xe=Array(ce),pe=0;pe<ce;pe++)xe[pe]=arguments[pe+2];de.children=xe}if(E&&E.defaultProps)for(ne in ce=E.defaultProps,ce)de[ne]===void 0&&(de[ne]=ce[ne]);return z(E,re,de)},Ae.createRef=function(){return{current:null}},Ae.forwardRef=function(E){return{$$typeof:x,render:E}},Ae.isValidElement=Z,Ae.lazy=function(E){return{$$typeof:b,_payload:{_status:-1,_result:E},_init:P}},Ae.memo=function(E,V){return{$$typeof:g,type:E,compare:V===void 0?null:V}},Ae.startTransition=function(E){var V=O.T,te={};O.T=te;try{var ne=E(),de=O.S;de!==null&&de(te,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(H,ie)}catch(re){ie(re)}finally{V!==null&&te.types!==null&&(V.types=te.types),O.T=V}},Ae.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Ae.use=function(E){return O.H.use(E)},Ae.useActionState=function(E,V,te){return O.H.useActionState(E,V,te)},Ae.useCallback=function(E,V){return O.H.useCallback(E,V)},Ae.useContext=function(E){return O.H.useContext(E)},Ae.useDebugValue=function(){},Ae.useDeferredValue=function(E,V){return O.H.useDeferredValue(E,V)},Ae.useEffect=function(E,V){return O.H.useEffect(E,V)},Ae.useEffectEvent=function(E){return O.H.useEffectEvent(E)},Ae.useId=function(){return O.H.useId()},Ae.useImperativeHandle=function(E,V,te){return O.H.useImperativeHandle(E,V,te)},Ae.useInsertionEffect=function(E,V){return O.H.useInsertionEffect(E,V)},Ae.useLayoutEffect=function(E,V){return O.H.useLayoutEffect(E,V)},Ae.useMemo=function(E,V){return O.H.useMemo(E,V)},Ae.useOptimistic=function(E,V){return O.H.useOptimistic(E,V)},Ae.useReducer=function(E,V,te){return O.H.useReducer(E,V,te)},Ae.useRef=function(E){return O.H.useRef(E)},Ae.useState=function(E){return O.H.useState(E)},Ae.useSyncExternalStore=function(E,V,te){return O.H.useSyncExternalStore(E,V,te)},Ae.useTransition=function(){return O.H.useTransition()},Ae.version="19.2.0",Ae}var ep;function Ef(){return ep||(ep=1,Tu.exports=Xy()),Tu.exports}var m=Ef();const Wa=$y(m);var Du={exports:{}},Zs={},_u={exports:{}},Ou={};var tp;function Fy(){return tp||(tp=1,(function(a){function l(R,Q){var P=R.length;R.push(Q);e:for(;0<P;){var ie=P-1>>>1,oe=R[ie];if(0<f(oe,Q))R[ie]=Q,R[P]=oe,P=ie;else break e}}function i(R){return R.length===0?null:R[0]}function o(R){if(R.length===0)return null;var Q=R[0],P=R.pop();if(P!==Q){R[0]=P;e:for(var ie=0,oe=R.length,E=oe>>>1;ie<E;){var V=2*(ie+1)-1,te=R[V],ne=V+1,de=R[ne];if(0>f(te,P))ne<oe&&0>f(de,te)?(R[ie]=de,R[ne]=P,ie=ne):(R[ie]=te,R[V]=P,ie=V);else if(ne<oe&&0>f(de,P))R[ie]=de,R[ne]=P,ie=ne;else break e}}return Q}function f(R,Q){var P=R.sortIndex-Q.sortIndex;return P!==0?P:R.id-Q.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;a.unstable_now=function(){return d.now()}}else{var h=Date,x=h.now();a.unstable_now=function(){return h.now()-x}}var p=[],g=[],b=1,y=null,N=3,q=!1,C=!1,w=!1,j=!1,k=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function T(R){for(var Q=i(g);Q!==null;){if(Q.callback===null)o(g);else if(Q.startTime<=R)o(g),Q.sortIndex=Q.expirationTime,l(p,Q);else break;Q=i(g)}}function L(R){if(w=!1,T(R),!C)if(i(p)!==null)C=!0,H||(H=!0,ae());else{var Q=i(g);Q!==null&&U(L,Q.startTime-R)}}var H=!1,O=-1,F=5,z=-1;function K(){return j?!0:!(a.unstable_now()-z<F)}function Z(){if(j=!1,H){var R=a.unstable_now();z=R;var Q=!0;try{e:{C=!1,w&&(w=!1,S(O),O=-1),q=!0;var P=N;try{t:{for(T(R),y=i(p);y!==null&&!(y.expirationTime>R&&K());){var ie=y.callback;if(typeof ie=="function"){y.callback=null,N=y.priorityLevel;var oe=ie(y.expirationTime<=R);if(R=a.unstable_now(),typeof oe=="function"){y.callback=oe,T(R),Q=!0;break t}y===i(p)&&o(p),T(R)}else o(p);y=i(p)}if(y!==null)Q=!0;else{var E=i(g);E!==null&&U(L,E.startTime-R),Q=!1}}break e}finally{y=null,N=P,q=!1}Q=void 0}}finally{Q?ae():H=!1}}}var ae;if(typeof M=="function")ae=function(){M(Z)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,le=ue.port2;ue.port1.onmessage=Z,ae=function(){le.postMessage(null)}}else ae=function(){k(Z,0)};function U(R,Q){O=k(function(){R(a.unstable_now())},Q)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(R){R.callback=null},a.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<R?Math.floor(1e3/R):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_next=function(R){switch(N){case 1:case 2:case 3:var Q=3;break;default:Q=N}var P=N;N=Q;try{return R()}finally{N=P}},a.unstable_requestPaint=function(){j=!0},a.unstable_runWithPriority=function(R,Q){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var P=N;N=R;try{return Q()}finally{N=P}},a.unstable_scheduleCallback=function(R,Q,P){var ie=a.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?ie+P:ie):P=ie,R){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=P+oe,R={id:b++,callback:Q,priorityLevel:R,startTime:P,expirationTime:oe,sortIndex:-1},P>ie?(R.sortIndex=P,l(g,R),i(p)===null&&R===i(g)&&(w?(S(O),O=-1):w=!0,U(L,P-ie))):(R.sortIndex=oe,l(p,R),C||q||(C=!0,H||(H=!0,ae()))),R},a.unstable_shouldYield=K,a.unstable_wrapCallback=function(R){var Q=N;return function(){var P=N;N=Q;try{return R.apply(this,arguments)}finally{N=P}}}})(Ou)),Ou}var np;function Qy(){return np||(np=1,_u.exports=Fy()),_u.exports}var Bu={exports:{}},wt={};var ap;function Ky(){if(ap)return wt;ap=1;var a=Ef();function l(p){var g="https://react.dev/errors/"+p;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)g+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+p+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(l(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(p,g,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:y==null?null:""+y,children:p,containerInfo:g,implementation:b}}var h=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function x(p,g){if(p==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return wt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,wt.createPortal=function(p,g){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(l(299));return d(p,g,null,b)},wt.flushSync=function(p){var g=h.T,b=o.p;try{if(h.T=null,o.p=2,p)return p()}finally{h.T=g,o.p=b,o.d.f()}},wt.preconnect=function(p,g){typeof p=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(p,g))},wt.prefetchDNS=function(p){typeof p=="string"&&o.d.D(p)},wt.preinit=function(p,g){if(typeof p=="string"&&g&&typeof g.as=="string"){var b=g.as,y=x(b,g.crossOrigin),N=typeof g.integrity=="string"?g.integrity:void 0,q=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;b==="style"?o.d.S(p,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:y,integrity:N,fetchPriority:q}):b==="script"&&o.d.X(p,{crossOrigin:y,integrity:N,fetchPriority:q,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},wt.preinitModule=function(p,g){if(typeof p=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var b=x(g.as,g.crossOrigin);o.d.M(p,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(p)},wt.preload=function(p,g){if(typeof p=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var b=g.as,y=x(b,g.crossOrigin);o.d.L(p,b,{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})}},wt.preloadModule=function(p,g){if(typeof p=="string")if(g){var b=x(g.as,g.crossOrigin);o.d.m(p,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(p)},wt.requestFormReset=function(p){o.d.r(p)},wt.unstable_batchedUpdates=function(p,g){return p(g)},wt.useFormState=function(p,g,b){return h.H.useFormState(p,g,b)},wt.useFormStatus=function(){return h.H.useHostTransitionStatus()},wt.version="19.2.0",wt}var lp;function Zy(){if(lp)return Bu.exports;lp=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Bu.exports=Ky(),Bu.exports}var sp;function Jy(){if(sp)return Zs;sp=1;var a=Qy(),l=Ef(),i=Zy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var n=e,s=t;;){var c=n.return;if(c===null)break;var u=c.alternate;if(u===null){if(s=c.return,s!==null){n=s;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===n)return p(c),e;if(u===s)return p(c),t;u=u.sibling}throw Error(o(188))}if(n.return!==s.return)n=c,s=u;else{for(var v=!1,A=c.child;A;){if(A===n){v=!0,n=c,s=u;break}if(A===s){v=!0,s=c,n=u;break}A=A.sibling}if(!v){for(A=u.child;A;){if(A===n){v=!0,n=u,s=c;break}if(A===s){v=!0,s=u,n=c;break}A=A.sibling}if(!v)throw Error(o(189))}}if(n.alternate!==s)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function b(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=b(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,N=Symbol.for("react.element"),q=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),M=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),K=Symbol.for("react.memo_cache_sentinel"),Z=Symbol.iterator;function ae(e){return e===null||typeof e!="object"?null:(e=Z&&e[Z]||e["@@iterator"],typeof e=="function"?e:null)}var ue=Symbol.for("react.client.reference");function le(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case k:return"Profiler";case j:return"StrictMode";case L:return"Suspense";case H:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case M:return e.displayName||"Context";case S:return(e._context.displayName||"Context")+".Consumer";case T:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return t=e.displayName||null,t!==null?t:le(e.type)||"Memo";case F:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var U=Array.isArray,R=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},ie=[],oe=-1;function E(e){return{current:e}}function V(e){0>oe||(e.current=ie[oe],ie[oe]=null,oe--)}function te(e,t){oe++,ie[oe]=e.current,e.current=t}var ne=E(null),de=E(null),re=E(null),ce=E(null);function xe(e,t){switch(te(re,t),te(de,e),te(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?b0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=b0(t),e=S0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(ne),te(ne,e)}function pe(){V(ne),V(de),V(re)}function ge(e){e.memoizedState!==null&&te(ce,e);var t=ne.current,n=S0(t,e.type);t!==n&&(te(de,e),te(ne,n))}function ze(e){de.current===e&&(V(ne),V(de)),ce.current===e&&(V(ce),Ys._currentValue=P)}var Y,se;function he(e){if(Y===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Y=t&&t[1]||"",se=-1<n.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+Y+e+se}var Se=!1;function Ye(e,t){if(!e||Se)return"";Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(J){var X=J}Reflect.construct(e,[],ee)}else{try{ee.call()}catch(J){X=J}e.call(ee.prototype)}}else{try{throw Error()}catch(J){X=J}(ee=e())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch(J){if(J&&X&&typeof J.stack=="string")return[J.stack,X.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=s.DetermineComponentFrameRoot(),v=u[0],A=u[1];if(v&&A){var D=v.split(`
|
||
`),G=A.split(`
|
||
`);for(c=s=0;s<D.length&&!D[s].includes("DetermineComponentFrameRoot");)s++;for(;c<G.length&&!G[c].includes("DetermineComponentFrameRoot");)c++;if(s===D.length||c===G.length)for(s=D.length-1,c=G.length-1;1<=s&&0<=c&&D[s]!==G[c];)c--;for(;1<=s&&0<=c;s--,c--)if(D[s]!==G[c]){if(s!==1||c!==1)do if(s--,c--,0>c||D[s]!==G[c]){var I=`
|
||
`+D[s].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=s&&0<=c);break}}}finally{Se=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?he(n):""}function et(e,t){switch(e.tag){case 26:case 27:case 5:return he(e.type);case 16:return he("Lazy");case 13:return e.child!==t&&t!==null?he("Suspense Fallback"):he("Suspense");case 19:return he("SuspenseList");case 0:case 15:return Ye(e.type,!1);case 11:return Ye(e.type.render,!1);case 1:return Ye(e.type,!0);case 31:return he("Activity");default:return""}}function xn(e){try{var t="",n=null;do t+=et(e,n),n=e,e=e.return;while(e);return t}catch(s){return`
|
||
Error generating stack: `+s.message+`
|
||
`+s.stack}}var kn=Object.prototype.hasOwnProperty,Nt=a.unstable_scheduleCallback,rn=a.unstable_cancelCallback,qn=a.unstable_shouldYield,vo=a.unstable_requestPaint,mt=a.unstable_now,el=a.unstable_getCurrentPriorityLevel,tl=a.unstable_ImmediatePriority,on=a.unstable_UserBlockingPriority,Ea=a.unstable_NormalPriority,Si=a.unstable_LowPriority,nl=a.unstable_IdlePriority,yo=a.log,as=a.unstable_setDisableYieldValue,cn=null,pt=null;function Xt(e){if(typeof yo=="function"&&as(e),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(cn,e)}catch{}}var rt=Math.clz32?Math.clz32:So,bo=Math.log,al=Math.LN2;function So(e){return e>>>=0,e===0?32:31-(bo(e)/al|0)|0}var ka=256,Ke=262144,ll=4194304;function Ot(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 ta(e,t,n){var s=e.pendingLanes;if(s===0)return 0;var c=0,u=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var A=s&134217727;return A!==0?(s=A&~u,s!==0?c=Ot(s):(v&=A,v!==0?c=Ot(v):n||(n=A&~e,n!==0&&(c=Ot(n))))):(A=s&~u,A!==0?c=Ot(A):v!==0?c=Ot(v):n||(n=s&~e,n!==0&&(c=Ot(n)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,n=t&-t,u>=n||u===32&&(n&4194048)!==0)?t:c}function gn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ai(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 ji(){var e=ll;return ll<<=1,(ll&62914560)===0&&(ll=4194304),e}function ls(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function qa(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ni(e,t,n,s,c,u){var v=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var A=e.entanglements,D=e.expirationTimes,G=e.hiddenUpdates;for(n=v&~n;0<n;){var I=31-rt(n),ee=1<<I;A[I]=0,D[I]=-1;var X=G[I];if(X!==null)for(G[I]=null,I=0;I<X.length;I++){var J=X[I];J!==null&&(J.lane&=-536870913)}n&=~ee}s!==0&&Ft(e,s,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(v&~t))}function Ft(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-rt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|n&261930}function ye(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var s=31-rt(n),c=1<<s;c&t|e[s]&t&&(e[s]|=t),n&=~c}}function Xe(e,t){var n=t&-t;return n=(n&42)!==0?1:Fe(n),(n&(e.suspendedLanes|t))!==0?0:n}function Fe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function we(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Le(){var e=Q.p;return e!==0?e:(e=window.event,e===void 0?32:Y0(e.type))}function vt(e,t){var n=Q.p;try{return Q.p=e,t()}finally{Q.p=n}}var kt=Math.random().toString(36).slice(2),tt="__reactFiber$"+kt,De="__reactProps$"+kt,Qt="__reactContainer$"+kt,Ao="__reactEvents$"+kt,Rg="__reactListeners$"+kt,Tg="__reactHandles$"+kt,rd="__reactResources$"+kt,ss="__reactMarker$"+kt;function jo(e){delete e[tt],delete e[De],delete e[Ao],delete e[Rg],delete e[Tg]}function sl(e){var t=e[tt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qt]||n[tt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=k0(e);e!==null;){if(n=e[tt])return n;e=k0(e)}return t}e=n,n=e.parentNode}return null}function il(e){if(e=e[tt]||e[Qt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function is(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function rl(e){var t=e[rd];return t||(t=e[rd]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function xt(e){e[ss]=!0}var od=new Set,cd={};function Ma(e,t){ol(e,t),ol(e+"Capture",t)}function ol(e,t){for(cd[e]=t,e=0;e<t.length;e++)od.add(t[e])}var Dg=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]*$"),ud={},fd={};function _g(e){return kn.call(fd,e)?!0:kn.call(ud,e)?!1:Dg.test(e)?fd[e]=!0:(ud[e]=!0,!1)}function wi(e,t,n){if(_g(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var s=t.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Ci(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Mn(e,t,n,s){if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+s)}}function Kt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function dd(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Og(e,t,n){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var c=s.get,u=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(v){n=""+v,u.call(this,v)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return n},setValue:function(v){n=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function No(e){if(!e._valueTracker){var t=dd(e)?"checked":"value";e._valueTracker=Og(e,t,""+e[t])}}function md(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),s="";return e&&(s=dd(e)?e.checked?"true":"false":e.value),e=s,e!==n?(t.setValue(e),!0):!1}function Ei(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 Bg=/[\n"\\]/g;function Zt(e){return e.replace(Bg,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function wo(e,t,n,s,c,u,v,A){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Kt(t)):e.value!==""+Kt(t)&&(e.value=""+Kt(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Co(e,v,Kt(t)):n!=null?Co(e,v,Kt(n)):s!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+Kt(A):e.removeAttribute("name")}function hd(e,t,n,s,c,u,v,A){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||n!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){No(e);return}n=n!=null?""+Kt(n):"",t=t!=null?""+Kt(t):n,A||t===e.value||(e.value=t),e.defaultValue=t}s=s??c,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=A?e.checked:!!s,e.defaultChecked=!!s,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),No(e)}function Co(e,t,n){t==="number"&&Ei(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function cl(e,t,n,s){if(e=e.options,t){t={};for(var c=0;c<n.length;c++)t["$"+n[c]]=!0;for(n=0;n<e.length;n++)c=t.hasOwnProperty("$"+e[n].value),e[n].selected!==c&&(e[n].selected=c),c&&s&&(e[n].defaultSelected=!0)}else{for(n=""+Kt(n),t=null,c=0;c<e.length;c++){if(e[c].value===n){e[c].selected=!0,s&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function pd(e,t,n){if(t!=null&&(t=""+Kt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Kt(n):""}function xd(e,t,n,s){if(t==null){if(s!=null){if(n!=null)throw Error(o(92));if(U(s)){if(1<s.length)throw Error(o(93));s=s[0]}n=s}n==null&&(n=""),t=n}n=Kt(t),e.defaultValue=n,s=e.textContent,s===n&&s!==""&&s!==null&&(e.value=s),No(e)}function ul(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Lg=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 gd(e,t,n){var s=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,n):typeof n!="number"||n===0||Lg.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function vd(e,t,n){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,n!=null){for(var s in n)!n.hasOwnProperty(s)||t!=null&&t.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var c in t)s=t[c],t.hasOwnProperty(c)&&n[c]!==s&&gd(e,c,s)}else for(var u in t)t.hasOwnProperty(u)&&gd(e,u,t[u])}function Eo(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 zg=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"]]),Ug=/^[\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 ki(e){return Ug.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Rn(){}var ko=null;function qo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var fl=null,dl=null;function yd(e){var t=il(e);if(t&&(e=t.stateNode)){var n=e[De]||null;e:switch(e=t.stateNode,t.type){case"input":if(wo(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Zt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var s=n[t];if(s!==e&&s.form===e.form){var c=s[De]||null;if(!c)throw Error(o(90));wo(s,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<n.length;t++)s=n[t],s.form===e.form&&md(s)}break e;case"textarea":pd(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&cl(e,!!n.multiple,t,!1)}}}var Mo=!1;function bd(e,t,n){if(Mo)return e(t,n);Mo=!0;try{var s=e(t);return s}finally{if(Mo=!1,(fl!==null||dl!==null)&&(pr(),fl&&(t=fl,e=dl,dl=fl=null,yd(t),e)))for(t=0;t<e.length;t++)yd(e[t])}}function rs(e,t){var n=e.stateNode;if(n===null)return null;var s=n[De]||null;if(s===null)return null;n=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(o(231,t,typeof n));return n}var Tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ro=!1;if(Tn)try{var os={};Object.defineProperty(os,"passive",{get:function(){Ro=!0}}),window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Ro=!1}var na=null,To=null,qi=null;function Sd(){if(qi)return qi;var e,t=To,n=t.length,s,c="value"in na?na.value:na.textContent,u=c.length;for(e=0;e<n&&t[e]===c[e];e++);var v=n-e;for(s=1;s<=v&&t[n-s]===c[u-s];s++);return qi=c.slice(e,1<s?1-s:void 0)}function Mi(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 Ri(){return!0}function Ad(){return!1}function qt(e){function t(n,s,c,u,v){this._reactName=n,this._targetInst=c,this.type=s,this.nativeEvent=u,this.target=v,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(n=e[A],this[A]=n?n(u):u[A]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Ri:Ad,this.isPropagationStopped=Ad,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ri)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ri)},persist:function(){},isPersistent:Ri}),t}var Ra={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ti=qt(Ra),cs=y({},Ra,{view:0,detail:0}),Hg=qt(cs),Do,_o,us,Di=y({},cs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bo,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!==us&&(us&&e.type==="mousemove"?(Do=e.screenX-us.screenX,_o=e.screenY-us.screenY):_o=Do=0,us=e),Do)},movementY:function(e){return"movementY"in e?e.movementY:_o}}),jd=qt(Di),Vg=y({},Di,{dataTransfer:0}),$g=qt(Vg),Gg=y({},cs,{relatedTarget:0}),Oo=qt(Gg),Yg=y({},Ra,{animationName:0,elapsedTime:0,pseudoElement:0}),Xg=qt(Yg),Fg=y({},Ra,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Qg=qt(Fg),Kg=y({},Ra,{data:0}),Nd=qt(Kg),Zg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jg={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"},Ig={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Wg(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ig[e])?!!t[e]:!1}function Bo(){return Wg}var Pg=y({},cs,{key:function(e){if(e.key){var t=Zg[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Mi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Jg[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bo,charCode:function(e){return e.type==="keypress"?Mi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Mi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ev=qt(Pg),tv=y({},Di,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wd=qt(tv),nv=y({},cs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bo}),av=qt(nv),lv=y({},Ra,{propertyName:0,elapsedTime:0,pseudoElement:0}),sv=qt(lv),iv=y({},Di,{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}),rv=qt(iv),ov=y({},Ra,{newState:0,oldState:0}),cv=qt(ov),uv=[9,13,27,32],Lo=Tn&&"CompositionEvent"in window,fs=null;Tn&&"documentMode"in document&&(fs=document.documentMode);var fv=Tn&&"TextEvent"in window&&!fs,Cd=Tn&&(!Lo||fs&&8<fs&&11>=fs),Ed=" ",kd=!1;function qd(e,t){switch(e){case"keyup":return uv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Md(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ml=!1;function dv(e,t){switch(e){case"compositionend":return Md(t);case"keypress":return t.which!==32?null:(kd=!0,Ed);case"textInput":return e=t.data,e===Ed&&kd?null:e;default:return null}}function mv(e,t){if(ml)return e==="compositionend"||!Lo&&qd(e,t)?(e=Sd(),qi=To=na=null,ml=!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 Cd&&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 Rd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!hv[e.type]:t==="textarea"}function Td(e,t,n,s){fl?dl?dl.push(s):dl=[s]:fl=s,t=Ar(t,"onChange"),0<t.length&&(n=new Ti("onChange","change",null,n,s),e.push({event:n,listeners:t}))}var ds=null,ms=null;function pv(e){h0(e,0)}function _i(e){var t=is(e);if(md(t))return e}function Dd(e,t){if(e==="change")return t}var _d=!1;if(Tn){var zo;if(Tn){var Uo="oninput"in document;if(!Uo){var Od=document.createElement("div");Od.setAttribute("oninput","return;"),Uo=typeof Od.oninput=="function"}zo=Uo}else zo=!1;_d=zo&&(!document.documentMode||9<document.documentMode)}function Bd(){ds&&(ds.detachEvent("onpropertychange",Ld),ms=ds=null)}function Ld(e){if(e.propertyName==="value"&&_i(ms)){var t=[];Td(t,ms,e,qo(e)),bd(pv,t)}}function xv(e,t,n){e==="focusin"?(Bd(),ds=t,ms=n,ds.attachEvent("onpropertychange",Ld)):e==="focusout"&&Bd()}function gv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return _i(ms)}function vv(e,t){if(e==="click")return _i(t)}function yv(e,t){if(e==="input"||e==="change")return _i(t)}function bv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Bt=typeof Object.is=="function"?Object.is:bv;function hs(e,t){if(Bt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(s=0;s<n.length;s++){var c=n[s];if(!kn.call(t,c)||!Bt(e[c],t[c]))return!1}return!0}function zd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ud(e,t){var n=zd(e);e=0;for(var s;n;){if(n.nodeType===3){if(s=e+n.textContent.length,e<=t&&s>=t)return{node:n,offset:t-e};e=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=zd(n)}}function Hd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ei(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ei(e.document)}return t}function Ho(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 Sv=Tn&&"documentMode"in document&&11>=document.documentMode,hl=null,Vo=null,ps=null,$o=!1;function $d(e,t,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$o||hl==null||hl!==Ei(s)||(s=hl,"selectionStart"in s&&Ho(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),ps&&hs(ps,s)||(ps=s,s=Ar(Vo,"onSelect"),0<s.length&&(t=new Ti("onSelect","select",null,t,n),e.push({event:t,listeners:s}),t.target=hl)))}function Ta(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var pl={animationend:Ta("Animation","AnimationEnd"),animationiteration:Ta("Animation","AnimationIteration"),animationstart:Ta("Animation","AnimationStart"),transitionrun:Ta("Transition","TransitionRun"),transitionstart:Ta("Transition","TransitionStart"),transitioncancel:Ta("Transition","TransitionCancel"),transitionend:Ta("Transition","TransitionEnd")},Go={},Gd={};Tn&&(Gd=document.createElement("div").style,"AnimationEvent"in window||(delete pl.animationend.animation,delete pl.animationiteration.animation,delete pl.animationstart.animation),"TransitionEvent"in window||delete pl.transitionend.transition);function Da(e){if(Go[e])return Go[e];if(!pl[e])return e;var t=pl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gd)return Go[e]=t[n];return e}var Yd=Da("animationend"),Xd=Da("animationiteration"),Fd=Da("animationstart"),Av=Da("transitionrun"),jv=Da("transitionstart"),Nv=Da("transitioncancel"),Qd=Da("transitionend"),Kd=new Map,Yo="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Yo.push("scrollEnd");function un(e,t){Kd.set(e,t),Ma(t,[e])}var Oi=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)},Jt=[],xl=0,Xo=0;function Bi(){for(var e=xl,t=Xo=xl=0;t<e;){var n=Jt[t];Jt[t++]=null;var s=Jt[t];Jt[t++]=null;var c=Jt[t];Jt[t++]=null;var u=Jt[t];if(Jt[t++]=null,s!==null&&c!==null){var v=s.pending;v===null?c.next=c:(c.next=v.next,v.next=c),s.pending=c}u!==0&&Zd(n,c,u)}}function Li(e,t,n,s){Jt[xl++]=e,Jt[xl++]=t,Jt[xl++]=n,Jt[xl++]=s,Xo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Fo(e,t,n,s){return Li(e,t,n,s),zi(e)}function _a(e,t){return Li(e,null,null,t),zi(e)}function Zd(e,t,n){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n);for(var c=!1,u=e.return;u!==null;)u.childLanes|=n,s=u.alternate,s!==null&&(s.childLanes|=n),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-rt(n),e=u.hiddenUpdates,s=e[c],s===null?e[c]=[t]:s.push(t),t.lane=n|536870912),u):null}function zi(e){if(50<Ls)throw Ls=0,tu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var gl={};function wv(e,t,n,s){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lt(e,t,n,s){return new wv(e,t,n,s)}function Qo(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Dn(e,t){var n=e.alternate;return n===null?(n=Lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Jd(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ui(e,t,n,s,c,u){var v=0;if(s=e,typeof e=="function")Qo(e)&&(v=1);else if(typeof e=="string")v=My(e,n,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=Lt(31,n,t,c),e.elementType=z,e.lanes=u,e;case w:return Oa(n.children,c,u,t);case j:v=8,c|=24;break;case k:return e=Lt(12,n,t,c|2),e.elementType=k,e.lanes=u,e;case L:return e=Lt(13,n,t,c),e.elementType=L,e.lanes=u,e;case H:return e=Lt(19,n,t,c),e.elementType=H,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case M:v=10;break e;case S:v=9;break e;case T:v=11;break e;case O:v=14;break e;case F:v=16,s=null;break e}v=29,n=Error(o(130,e===null?"null":typeof e,"")),s=null}return t=Lt(v,n,t,c),t.elementType=e,t.type=s,t.lanes=u,t}function Oa(e,t,n,s){return e=Lt(7,e,s,t),e.lanes=n,e}function Ko(e,t,n){return e=Lt(6,e,null,t),e.lanes=n,e}function Id(e){var t=Lt(18,null,null,0);return t.stateNode=e,t}function Zo(e,t,n){return t=Lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Wd=new WeakMap;function It(e,t){if(typeof e=="object"&&e!==null){var n=Wd.get(e);return n!==void 0?n:(t={value:e,source:t,stack:xn(t)},Wd.set(e,t),t)}return{value:e,source:t,stack:xn(t)}}var vl=[],yl=0,Hi=null,xs=0,Wt=[],Pt=0,aa=null,vn=1,yn="";function _n(e,t){vl[yl++]=xs,vl[yl++]=Hi,Hi=e,xs=t}function Pd(e,t,n){Wt[Pt++]=vn,Wt[Pt++]=yn,Wt[Pt++]=aa,aa=e;var s=vn;e=yn;var c=32-rt(s)-1;s&=~(1<<c),n+=1;var u=32-rt(t)+c;if(30<u){var v=c-c%5;u=(s&(1<<v)-1).toString(32),s>>=v,c-=v,vn=1<<32-rt(t)+c|n<<c|s,yn=u+e}else vn=1<<u|n<<c|s,yn=e}function Jo(e){e.return!==null&&(_n(e,1),Pd(e,1,0))}function Io(e){for(;e===Hi;)Hi=vl[--yl],vl[yl]=null,xs=vl[--yl],vl[yl]=null;for(;e===aa;)aa=Wt[--Pt],Wt[Pt]=null,yn=Wt[--Pt],Wt[Pt]=null,vn=Wt[--Pt],Wt[Pt]=null}function em(e,t){Wt[Pt++]=vn,Wt[Pt++]=yn,Wt[Pt++]=aa,vn=t.id,yn=t.overflow,aa=e}var yt=null,Ze=null,Me=!1,la=null,en=!1,Wo=Error(o(519));function sa(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw gs(It(t,e)),Wo}function tm(e){var t=e.stateNode,n=e.type,s=e.memoizedProps;switch(t[tt]=e,t[De]=s,n){case"dialog":Ee("cancel",t),Ee("close",t);break;case"iframe":case"object":case"embed":Ee("load",t);break;case"video":case"audio":for(n=0;n<Us.length;n++)Ee(Us[n],t);break;case"source":Ee("error",t);break;case"img":case"image":case"link":Ee("error",t),Ee("load",t);break;case"details":Ee("toggle",t);break;case"input":Ee("invalid",t),hd(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":Ee("invalid",t);break;case"textarea":Ee("invalid",t),xd(t,s.value,s.defaultValue,s.children)}n=s.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||s.suppressHydrationWarning===!0||v0(t.textContent,n)?(s.popover!=null&&(Ee("beforetoggle",t),Ee("toggle",t)),s.onScroll!=null&&Ee("scroll",t),s.onScrollEnd!=null&&Ee("scrollend",t),s.onClick!=null&&(t.onclick=Rn),t=!0):t=!1,t||sa(e,!0)}function nm(e){for(yt=e.return;yt;)switch(yt.tag){case 5:case 31:case 13:en=!1;return;case 27:case 3:en=!0;return;default:yt=yt.return}}function bl(e){if(e!==yt)return!1;if(!Me)return nm(e),Me=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||xu(e.type,e.memoizedProps)),n=!n),n&&Ze&&sa(e),nm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));Ze=E0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));Ze=E0(e)}else t===27?(t=Ze,ya(e.type)?(e=Su,Su=null,Ze=e):Ze=t):Ze=yt?nn(e.stateNode.nextSibling):null;return!0}function Ba(){Ze=yt=null,Me=!1}function Po(){var e=la;return e!==null&&(Dt===null?Dt=e:Dt.push.apply(Dt,e),la=null),e}function gs(e){la===null?la=[e]:la.push(e)}var ec=E(null),La=null,On=null;function ia(e,t,n){te(ec,t._currentValue),t._currentValue=n}function Bn(e){e._currentValue=ec.current,V(ec)}function tc(e,t,n){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===n)break;e=e.return}}function nc(e,t,n,s){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var v=c.child;u=u.firstContext;e:for(;u!==null;){var A=u;u=c;for(var D=0;D<t.length;D++)if(A.context===t[D]){u.lanes|=n,A=u.alternate,A!==null&&(A.lanes|=n),tc(u.return,n,e),s||(v=null);break e}u=A.next}}else if(c.tag===18){if(v=c.return,v===null)throw Error(o(341));v.lanes|=n,u=v.alternate,u!==null&&(u.lanes|=n),tc(v,n,e),v=null}else v=c.child;if(v!==null)v.return=c;else for(v=c;v!==null;){if(v===e){v=null;break}if(c=v.sibling,c!==null){c.return=v.return,v=c;break}v=v.return}c=v}}function Sl(e,t,n,s){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var v=c.alternate;if(v===null)throw Error(o(387));if(v=v.memoizedProps,v!==null){var A=c.type;Bt(c.pendingProps.value,v.value)||(e!==null?e.push(A):e=[A])}}else if(c===ce.current){if(v=c.alternate,v===null)throw Error(o(387));v.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Ys):e=[Ys])}c=c.return}e!==null&&nc(t,e,n,s),t.flags|=262144}function Vi(e){for(e=e.firstContext;e!==null;){if(!Bt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function za(e){La=e,On=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function bt(e){return am(La,e)}function $i(e,t){return La===null&&za(e),am(e,t)}function am(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},On===null){if(e===null)throw Error(o(308));On=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else On=On.next=t;return n}var Cv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},Ev=a.unstable_scheduleCallback,kv=a.unstable_NormalPriority,ot={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ac(){return{controller:new Cv,data:new Map,refCount:0}}function vs(e){e.refCount--,e.refCount===0&&Ev(kv,function(){e.controller.abort()})}var ys=null,lc=0,Al=0,jl=null;function qv(e,t){if(ys===null){var n=ys=[];lc=0,Al=ru(),jl={status:"pending",value:void 0,then:function(s){n.push(s)}}}return lc++,t.then(lm,lm),t}function lm(){if(--lc===0&&ys!==null){jl!==null&&(jl.status="fulfilled");var e=ys;ys=null,Al=0,jl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Mv(e,t){var n=[],s={status:"pending",value:null,reason:null,then:function(c){n.push(c)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var c=0;c<n.length;c++)(0,n[c])(t)},function(c){for(s.status="rejected",s.reason=c,c=0;c<n.length;c++)(0,n[c])(void 0)}),s}var sm=R.S;R.S=function(e,t){$h=mt(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&qv(e,t),sm!==null&&sm(e,t)};var Ua=E(null);function sc(){var e=Ua.current;return e!==null?e:Qe.pooledCache}function Gi(e,t){t===null?te(Ua,Ua.current):te(Ua,t.pool)}function im(){var e=sc();return e===null?null:{parent:ot._currentValue,pool:e}}var Nl=Error(o(460)),ic=Error(o(474)),Yi=Error(o(542)),Xi={then:function(){}};function rm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function om(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Rn,Rn),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,um(e),e;default:if(typeof t.status=="string")t.then(Rn,Rn);else{if(e=Qe,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(s){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=s}},function(s){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=s}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,um(e),e}throw Va=t,Nl}}function Ha(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Va=n,Nl):n}}var Va=null;function cm(){if(Va===null)throw Error(o(459));var e=Va;return Va=null,e}function um(e){if(e===Nl||e===Yi)throw Error(o(483))}var wl=null,bs=0;function Fi(e){var t=bs;return bs+=1,wl===null&&(wl=[]),om(wl,e,t)}function Ss(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Qi(e,t){throw t.$$typeof===N?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function fm(e){function t(B,_){if(e){var $=B.deletions;$===null?(B.deletions=[_],B.flags|=16):$.push(_)}}function n(B,_){if(!e)return null;for(;_!==null;)t(B,_),_=_.sibling;return null}function s(B){for(var _=new Map;B!==null;)B.key!==null?_.set(B.key,B):_.set(B.index,B),B=B.sibling;return _}function c(B,_){return B=Dn(B,_),B.index=0,B.sibling=null,B}function u(B,_,$){return B.index=$,e?($=B.alternate,$!==null?($=$.index,$<_?(B.flags|=67108866,_):$):(B.flags|=67108866,_)):(B.flags|=1048576,_)}function v(B){return e&&B.alternate===null&&(B.flags|=67108866),B}function A(B,_,$,W){return _===null||_.tag!==6?(_=Ko($,B.mode,W),_.return=B,_):(_=c(_,$),_.return=B,_)}function D(B,_,$,W){var ve=$.type;return ve===w?I(B,_,$.props.children,W,$.key):_!==null&&(_.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===F&&Ha(ve)===_.type)?(_=c(_,$.props),Ss(_,$),_.return=B,_):(_=Ui($.type,$.key,$.props,null,B.mode,W),Ss(_,$),_.return=B,_)}function G(B,_,$,W){return _===null||_.tag!==4||_.stateNode.containerInfo!==$.containerInfo||_.stateNode.implementation!==$.implementation?(_=Zo($,B.mode,W),_.return=B,_):(_=c(_,$.children||[]),_.return=B,_)}function I(B,_,$,W,ve){return _===null||_.tag!==7?(_=Oa($,B.mode,W,ve),_.return=B,_):(_=c(_,$),_.return=B,_)}function ee(B,_,$){if(typeof _=="string"&&_!==""||typeof _=="number"||typeof _=="bigint")return _=Ko(""+_,B.mode,$),_.return=B,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case q:return $=Ui(_.type,_.key,_.props,null,B.mode,$),Ss($,_),$.return=B,$;case C:return _=Zo(_,B.mode,$),_.return=B,_;case F:return _=Ha(_),ee(B,_,$)}if(U(_)||ae(_))return _=Oa(_,B.mode,$,null),_.return=B,_;if(typeof _.then=="function")return ee(B,Fi(_),$);if(_.$$typeof===M)return ee(B,$i(B,_),$);Qi(B,_)}return null}function X(B,_,$,W){var ve=_!==null?_.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return ve!==null?null:A(B,_,""+$,W);if(typeof $=="object"&&$!==null){switch($.$$typeof){case q:return $.key===ve?D(B,_,$,W):null;case C:return $.key===ve?G(B,_,$,W):null;case F:return $=Ha($),X(B,_,$,W)}if(U($)||ae($))return ve!==null?null:I(B,_,$,W,null);if(typeof $.then=="function")return X(B,_,Fi($),W);if($.$$typeof===M)return X(B,_,$i(B,$),W);Qi(B,$)}return null}function J(B,_,$,W,ve){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return B=B.get($)||null,A(_,B,""+W,ve);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case q:return B=B.get(W.key===null?$:W.key)||null,D(_,B,W,ve);case C:return B=B.get(W.key===null?$:W.key)||null,G(_,B,W,ve);case F:return W=Ha(W),J(B,_,$,W,ve)}if(U(W)||ae(W))return B=B.get($)||null,I(_,B,W,ve,null);if(typeof W.then=="function")return J(B,_,$,Fi(W),ve);if(W.$$typeof===M)return J(B,_,$,$i(_,W),ve);Qi(_,W)}return null}function fe(B,_,$,W){for(var ve=null,_e=null,me=_,Ne=_=0,qe=null;me!==null&&Ne<$.length;Ne++){me.index>Ne?(qe=me,me=null):qe=me.sibling;var Oe=X(B,me,$[Ne],W);if(Oe===null){me===null&&(me=qe);break}e&&me&&Oe.alternate===null&&t(B,me),_=u(Oe,_,Ne),_e===null?ve=Oe:_e.sibling=Oe,_e=Oe,me=qe}if(Ne===$.length)return n(B,me),Me&&_n(B,Ne),ve;if(me===null){for(;Ne<$.length;Ne++)me=ee(B,$[Ne],W),me!==null&&(_=u(me,_,Ne),_e===null?ve=me:_e.sibling=me,_e=me);return Me&&_n(B,Ne),ve}for(me=s(me);Ne<$.length;Ne++)qe=J(me,B,Ne,$[Ne],W),qe!==null&&(e&&qe.alternate!==null&&me.delete(qe.key===null?Ne:qe.key),_=u(qe,_,Ne),_e===null?ve=qe:_e.sibling=qe,_e=qe);return e&&me.forEach(function(Na){return t(B,Na)}),Me&&_n(B,Ne),ve}function be(B,_,$,W){if($==null)throw Error(o(151));for(var ve=null,_e=null,me=_,Ne=_=0,qe=null,Oe=$.next();me!==null&&!Oe.done;Ne++,Oe=$.next()){me.index>Ne?(qe=me,me=null):qe=me.sibling;var Na=X(B,me,Oe.value,W);if(Na===null){me===null&&(me=qe);break}e&&me&&Na.alternate===null&&t(B,me),_=u(Na,_,Ne),_e===null?ve=Na:_e.sibling=Na,_e=Na,me=qe}if(Oe.done)return n(B,me),Me&&_n(B,Ne),ve;if(me===null){for(;!Oe.done;Ne++,Oe=$.next())Oe=ee(B,Oe.value,W),Oe!==null&&(_=u(Oe,_,Ne),_e===null?ve=Oe:_e.sibling=Oe,_e=Oe);return Me&&_n(B,Ne),ve}for(me=s(me);!Oe.done;Ne++,Oe=$.next())Oe=J(me,B,Ne,Oe.value,W),Oe!==null&&(e&&Oe.alternate!==null&&me.delete(Oe.key===null?Ne:Oe.key),_=u(Oe,_,Ne),_e===null?ve=Oe:_e.sibling=Oe,_e=Oe);return e&&me.forEach(function(Vy){return t(B,Vy)}),Me&&_n(B,Ne),ve}function Ge(B,_,$,W){if(typeof $=="object"&&$!==null&&$.type===w&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case q:e:{for(var ve=$.key;_!==null;){if(_.key===ve){if(ve=$.type,ve===w){if(_.tag===7){n(B,_.sibling),W=c(_,$.props.children),W.return=B,B=W;break e}}else if(_.elementType===ve||typeof ve=="object"&&ve!==null&&ve.$$typeof===F&&Ha(ve)===_.type){n(B,_.sibling),W=c(_,$.props),Ss(W,$),W.return=B,B=W;break e}n(B,_);break}else t(B,_);_=_.sibling}$.type===w?(W=Oa($.props.children,B.mode,W,$.key),W.return=B,B=W):(W=Ui($.type,$.key,$.props,null,B.mode,W),Ss(W,$),W.return=B,B=W)}return v(B);case C:e:{for(ve=$.key;_!==null;){if(_.key===ve)if(_.tag===4&&_.stateNode.containerInfo===$.containerInfo&&_.stateNode.implementation===$.implementation){n(B,_.sibling),W=c(_,$.children||[]),W.return=B,B=W;break e}else{n(B,_);break}else t(B,_);_=_.sibling}W=Zo($,B.mode,W),W.return=B,B=W}return v(B);case F:return $=Ha($),Ge(B,_,$,W)}if(U($))return fe(B,_,$,W);if(ae($)){if(ve=ae($),typeof ve!="function")throw Error(o(150));return $=ve.call($),be(B,_,$,W)}if(typeof $.then=="function")return Ge(B,_,Fi($),W);if($.$$typeof===M)return Ge(B,_,$i(B,$),W);Qi(B,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,_!==null&&_.tag===6?(n(B,_.sibling),W=c(_,$),W.return=B,B=W):(n(B,_),W=Ko($,B.mode,W),W.return=B,B=W),v(B)):n(B,_)}return function(B,_,$,W){try{bs=0;var ve=Ge(B,_,$,W);return wl=null,ve}catch(me){if(me===Nl||me===Yi)throw me;var _e=Lt(29,me,null,B.mode);return _e.lanes=W,_e.return=B,_e}finally{}}}var $a=fm(!0),dm=fm(!1),ra=!1;function rc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oc(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 oa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ca(e,t,n){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Be&2)!==0){var c=s.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),s.pending=t,t=zi(e),Zd(e,null,n),t}return Li(e,s,t,n),zi(e)}function As(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,ye(e,n)}}function cc(e,t){var n=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var c=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var v={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};u===null?c=u=v:u=u.next=v,n=n.next}while(n!==null);u===null?c=u=t:u=u.next=t}else c=u=t;n={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:s.shared,callbacks:s.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var uc=!1;function js(){if(uc){var e=jl;if(e!==null)throw e}}function Ns(e,t,n,s){uc=!1;var c=e.updateQueue;ra=!1;var u=c.firstBaseUpdate,v=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var D=A,G=D.next;D.next=null,v===null?u=G:v.next=G,v=D;var I=e.alternate;I!==null&&(I=I.updateQueue,A=I.lastBaseUpdate,A!==v&&(A===null?I.firstBaseUpdate=G:A.next=G,I.lastBaseUpdate=D))}if(u!==null){var ee=c.baseState;v=0,I=G=D=null,A=u;do{var X=A.lane&-536870913,J=X!==A.lane;if(J?(ke&X)===X:(s&X)===X){X!==0&&X===Al&&(uc=!0),I!==null&&(I=I.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var fe=e,be=A;X=t;var Ge=n;switch(be.tag){case 1:if(fe=be.payload,typeof fe=="function"){ee=fe.call(Ge,ee,X);break e}ee=fe;break e;case 3:fe.flags=fe.flags&-65537|128;case 0:if(fe=be.payload,X=typeof fe=="function"?fe.call(Ge,ee,X):fe,X==null)break e;ee=y({},ee,X);break e;case 2:ra=!0}}X=A.callback,X!==null&&(e.flags|=64,J&&(e.flags|=8192),J=c.callbacks,J===null?c.callbacks=[X]:J.push(X))}else J={lane:X,tag:A.tag,payload:A.payload,callback:A.callback,next:null},I===null?(G=I=J,D=ee):I=I.next=J,v|=X;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;J=A,A=J.next,J.next=null,c.lastBaseUpdate=J,c.shared.pending=null}}while(!0);I===null&&(D=ee),c.baseState=D,c.firstBaseUpdate=G,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),ha|=v,e.lanes=v,e.memoizedState=ee}}function mm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function hm(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)mm(n[e],t)}var Cl=E(null),Ki=E(0);function pm(e,t){e=Xn,te(Ki,e),te(Cl,t),Xn=e|t.baseLanes}function fc(){te(Ki,Xn),te(Cl,Cl.current)}function dc(){Xn=Ki.current,V(Cl),V(Ki)}var zt=E(null),tn=null;function ua(e){var t=e.alternate;te(st,st.current&1),te(zt,e),tn===null&&(t===null||Cl.current!==null||t.memoizedState!==null)&&(tn=e)}function mc(e){te(st,st.current),te(zt,e),tn===null&&(tn=e)}function xm(e){e.tag===22?(te(st,st.current),te(zt,e),tn===null&&(tn=e)):fa()}function fa(){te(st,st.current),te(zt,zt.current)}function Ut(e){V(zt),tn===e&&(tn=null),V(st)}var st=E(0);function Zi(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||yu(n)||bu(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ln=0,je=null,Ve=null,ct=null,Ji=!1,El=!1,Ga=!1,Ii=0,ws=0,kl=null,Rv=0;function nt(){throw Error(o(321))}function hc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Bt(e[n],t[n]))return!1;return!0}function pc(e,t,n,s,c,u){return Ln=u,je=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=e===null||e.memoizedState===null?Pm:Mc,Ga=!1,u=n(s,c),Ga=!1,El&&(u=vm(t,n,s,c)),gm(e),u}function gm(e){R.H=ks;var t=Ve!==null&&Ve.next!==null;if(Ln=0,ct=Ve=je=null,Ji=!1,ws=0,kl=null,t)throw Error(o(300));e===null||ut||(e=e.dependencies,e!==null&&Vi(e)&&(ut=!0))}function vm(e,t,n,s){je=e;var c=0;do{if(El&&(kl=null),ws=0,El=!1,25<=c)throw Error(o(301));if(c+=1,ct=Ve=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}R.H=eh,u=t(n,s)}while(El);return u}function Tv(){var e=R.H,t=e.useState()[0];return t=typeof t.then=="function"?Cs(t):t,e=e.useState()[0],(Ve!==null?Ve.memoizedState:null)!==e&&(je.flags|=1024),t}function xc(){var e=Ii!==0;return Ii=0,e}function gc(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function vc(e){if(Ji){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ji=!1}Ln=0,ct=Ve=je=null,El=!1,ws=Ii=0,kl=null}function Ct(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ct===null?je.memoizedState=ct=e:ct=ct.next=e,ct}function it(){if(Ve===null){var e=je.alternate;e=e!==null?e.memoizedState:null}else e=Ve.next;var t=ct===null?je.memoizedState:ct.next;if(t!==null)ct=t,Ve=e;else{if(e===null)throw je.alternate===null?Error(o(467)):Error(o(310));Ve=e,e={memoizedState:Ve.memoizedState,baseState:Ve.baseState,baseQueue:Ve.baseQueue,queue:Ve.queue,next:null},ct===null?je.memoizedState=ct=e:ct=ct.next=e}return ct}function Wi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Cs(e){var t=ws;return ws+=1,kl===null&&(kl=[]),e=om(kl,e,t),t=je,(ct===null?t.memoizedState:ct.next)===null&&(t=t.alternate,R.H=t===null||t.memoizedState===null?Pm:Mc),e}function Pi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Cs(e);if(e.$$typeof===M)return bt(e)}throw Error(o(438,String(e)))}function yc(e){var t=null,n=je.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var s=je.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(t={data:s.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Wi(),je.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),s=0;s<e;s++)n[s]=K;return t.index++,n}function zn(e,t){return typeof t=="function"?t(e):t}function er(e){var t=it();return bc(t,Ve,e)}function bc(e,t,n){var s=e.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=n;var c=e.baseQueue,u=s.pending;if(u!==null){if(c!==null){var v=c.next;c.next=u.next,u.next=v}t.baseQueue=c=u,s.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var A=v=null,D=null,G=t,I=!1;do{var ee=G.lane&-536870913;if(ee!==G.lane?(ke&ee)===ee:(Ln&ee)===ee){var X=G.revertLane;if(X===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ee===Al&&(I=!0);else if((Ln&X)===X){G=G.next,X===Al&&(I=!0);continue}else ee={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(A=D=ee,v=u):D=D.next=ee,je.lanes|=X,ha|=X;ee=G.action,Ga&&n(u,ee),u=G.hasEagerState?G.eagerState:n(u,ee)}else X={lane:ee,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},D===null?(A=D=X,v=u):D=D.next=X,je.lanes|=ee,ha|=ee;G=G.next}while(G!==null&&G!==t);if(D===null?v=u:D.next=A,!Bt(u,e.memoizedState)&&(ut=!0,I&&(n=jl,n!==null)))throw n;e.memoizedState=u,e.baseState=v,e.baseQueue=D,s.lastRenderedState=u}return c===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function Sc(e){var t=it(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var s=n.dispatch,c=n.pending,u=t.memoizedState;if(c!==null){n.pending=null;var v=c=c.next;do u=e(u,v.action),v=v.next;while(v!==c);Bt(u,t.memoizedState)||(ut=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),n.lastRenderedState=u}return[u,s]}function ym(e,t,n){var s=je,c=it(),u=Me;if(u){if(n===void 0)throw Error(o(407));n=n()}else n=t();var v=!Bt((Ve||c).memoizedState,n);if(v&&(c.memoizedState=n,ut=!0),c=c.queue,Nc(Am.bind(null,s,c,e),[e]),c.getSnapshot!==t||v||ct!==null&&ct.memoizedState.tag&1){if(s.flags|=2048,ql(9,{destroy:void 0},Sm.bind(null,s,c,n,t),null),Qe===null)throw Error(o(349));u||(Ln&127)!==0||bm(s,t,n)}return n}function bm(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=je.updateQueue,t===null?(t=Wi(),je.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Sm(e,t,n,s){t.value=n,t.getSnapshot=s,jm(t)&&Nm(e)}function Am(e,t,n){return n(function(){jm(t)&&Nm(e)})}function jm(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Bt(e,n)}catch{return!0}}function Nm(e){var t=_a(e,2);t!==null&&_t(t,e,2)}function Ac(e){var t=Ct();if(typeof e=="function"){var n=e;if(e=n(),Ga){Xt(!0);try{n()}finally{Xt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:e},t}function wm(e,t,n,s){return e.baseState=n,bc(e,Ve,typeof s=="function"?s:zn)}function Dv(e,t,n,s,c){if(ar(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){u.listeners.push(v)}};R.T!==null?n(!0):u.isTransition=!1,s(u),n=t.pending,n===null?(u.next=t.pending=u,Cm(t,u)):(u.next=n.next,t.pending=n.next=u)}}function Cm(e,t){var n=t.action,s=t.payload,c=e.state;if(t.isTransition){var u=R.T,v={};R.T=v;try{var A=n(c,s),D=R.S;D!==null&&D(v,A),Em(e,t,A)}catch(G){jc(e,t,G)}finally{u!==null&&v.types!==null&&(u.types=v.types),R.T=u}}else try{u=n(c,s),Em(e,t,u)}catch(G){jc(e,t,G)}}function Em(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(s){km(e,t,s)},function(s){return jc(e,t,s)}):km(e,t,n)}function km(e,t,n){t.status="fulfilled",t.value=n,qm(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Cm(e,n)))}function jc(e,t,n){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=n,qm(t),t=t.next;while(t!==s)}e.action=null}function qm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Mm(e,t){return t}function Rm(e,t){if(Me){var n=Qe.formState;if(n!==null){e:{var s=je;if(Me){if(Ze){t:{for(var c=Ze,u=en;c.nodeType!==8;){if(!u){c=null;break t}if(c=nn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){Ze=nn(c.nextSibling),s=c.data==="F!";break e}}sa(s)}s=!1}s&&(t=n[0])}}return n=Ct(),n.memoizedState=n.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mm,lastRenderedState:t},n.queue=s,n=Jm.bind(null,je,s),s.dispatch=n,s=Ac(!1),u=qc.bind(null,je,!1,s.queue),s=Ct(),c={state:t,dispatch:null,action:e,pending:null},s.queue=c,n=Dv.bind(null,je,c,u,n),c.dispatch=n,s.memoizedState=e,[t,n,!1]}function Tm(e){var t=it();return Dm(t,Ve,e)}function Dm(e,t,n){if(t=bc(e,t,Mm)[0],e=er(zn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=Cs(t)}catch(v){throw v===Nl?Yi:v}else s=t;t=it();var c=t.queue,u=c.dispatch;return n!==t.memoizedState&&(je.flags|=2048,ql(9,{destroy:void 0},_v.bind(null,c,n),null)),[s,u,e]}function _v(e,t){e.action=t}function _m(e){var t=it(),n=Ve;if(n!==null)return Dm(t,n,e);it(),t=t.memoizedState,n=it();var s=n.queue.dispatch;return n.memoizedState=e,[t,s,!1]}function ql(e,t,n,s){return e={tag:e,create:n,deps:s,inst:t,next:null},t=je.updateQueue,t===null&&(t=Wi(),je.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(s=n.next,n.next=e,e.next=s,t.lastEffect=e),e}function Om(){return it().memoizedState}function tr(e,t,n,s){var c=Ct();je.flags|=e,c.memoizedState=ql(1|t,{destroy:void 0},n,s===void 0?null:s)}function nr(e,t,n,s){var c=it();s=s===void 0?null:s;var u=c.memoizedState.inst;Ve!==null&&s!==null&&hc(s,Ve.memoizedState.deps)?c.memoizedState=ql(t,u,n,s):(je.flags|=e,c.memoizedState=ql(1|t,u,n,s))}function Bm(e,t){tr(8390656,8,e,t)}function Nc(e,t){nr(2048,8,e,t)}function Ov(e){je.flags|=4;var t=je.updateQueue;if(t===null)t=Wi(),je.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Lm(e){var t=it().memoizedState;return Ov({ref:t,nextImpl:e}),function(){if((Be&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function zm(e,t){return nr(4,2,e,t)}function Um(e,t){return nr(4,4,e,t)}function Hm(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Vm(e,t,n){n=n!=null?n.concat([e]):null,nr(4,4,Hm.bind(null,t,e),n)}function wc(){}function $m(e,t){var n=it();t=t===void 0?null:t;var s=n.memoizedState;return t!==null&&hc(t,s[1])?s[0]:(n.memoizedState=[e,t],e)}function Gm(e,t){var n=it();t=t===void 0?null:t;var s=n.memoizedState;if(t!==null&&hc(t,s[1]))return s[0];if(s=e(),Ga){Xt(!0);try{e()}finally{Xt(!1)}}return n.memoizedState=[s,t],s}function Cc(e,t,n){return n===void 0||(Ln&1073741824)!==0&&(ke&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Yh(),je.lanes|=e,ha|=e,n)}function Ym(e,t,n,s){return Bt(n,t)?n:Cl.current!==null?(e=Cc(e,n,s),Bt(e,t)||(ut=!0),e):(Ln&42)===0||(Ln&1073741824)!==0&&(ke&261930)===0?(ut=!0,e.memoizedState=n):(e=Yh(),je.lanes|=e,ha|=e,t)}function Xm(e,t,n,s,c){var u=Q.p;Q.p=u!==0&&8>u?u:8;var v=R.T,A={};R.T=A,qc(e,!1,t,n);try{var D=c(),G=R.S;if(G!==null&&G(A,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var I=Mv(D,s);Es(e,t,I,$t(e))}else Es(e,t,s,$t(e))}catch(ee){Es(e,t,{then:function(){},status:"rejected",reason:ee},$t())}finally{Q.p=u,v!==null&&A.types!==null&&(v.types=A.types),R.T=v}}function Bv(){}function Ec(e,t,n,s){if(e.tag!==5)throw Error(o(476));var c=Fm(e).queue;Xm(e,c,t,P,n===null?Bv:function(){return Qm(e),n(s)})}function Fm(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:P},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Qm(e){var t=Fm(e);t.next===null&&(t=e.alternate.memoizedState),Es(e,t.next.queue,{},$t())}function kc(){return bt(Ys)}function Km(){return it().memoizedState}function Zm(){return it().memoizedState}function Lv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=$t();e=oa(n);var s=ca(t,e,n);s!==null&&(_t(s,t,n),As(s,t,n)),t={cache:ac()},e.payload=t;return}t=t.return}}function zv(e,t,n){var s=$t();n={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ar(e)?Im(t,n):(n=Fo(e,t,n,s),n!==null&&(_t(n,e,s),Wm(n,t,s)))}function Jm(e,t,n){var s=$t();Es(e,t,n,s)}function Es(e,t,n,s){var c={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ar(e))Im(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var v=t.lastRenderedState,A=u(v,n);if(c.hasEagerState=!0,c.eagerState=A,Bt(A,v))return Li(e,t,c,0),Qe===null&&Bi(),!1}catch{}finally{}if(n=Fo(e,t,c,s),n!==null)return _t(n,e,s),Wm(n,t,s),!0}return!1}function qc(e,t,n,s){if(s={lane:2,revertLane:ru(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},ar(e)){if(t)throw Error(o(479))}else t=Fo(e,n,s,2),t!==null&&_t(t,e,2)}function ar(e){var t=e.alternate;return e===je||t!==null&&t===je}function Im(e,t){El=Ji=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Wm(e,t,n){if((n&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,ye(e,n)}}var ks={readContext:bt,use:Pi,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useLayoutEffect:nt,useInsertionEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useSyncExternalStore:nt,useId:nt,useHostTransitionStatus:nt,useFormState:nt,useActionState:nt,useOptimistic:nt,useMemoCache:nt,useCacheRefresh:nt};ks.useEffectEvent=nt;var Pm={readContext:bt,use:Pi,useCallback:function(e,t){return Ct().memoizedState=[e,t===void 0?null:t],e},useContext:bt,useEffect:Bm,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,tr(4194308,4,Hm.bind(null,t,e),n)},useLayoutEffect:function(e,t){return tr(4194308,4,e,t)},useInsertionEffect:function(e,t){tr(4,2,e,t)},useMemo:function(e,t){var n=Ct();t=t===void 0?null:t;var s=e();if(Ga){Xt(!0);try{e()}finally{Xt(!1)}}return n.memoizedState=[s,t],s},useReducer:function(e,t,n){var s=Ct();if(n!==void 0){var c=n(t);if(Ga){Xt(!0);try{n(t)}finally{Xt(!1)}}}else c=t;return s.memoizedState=s.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},s.queue=e,e=e.dispatch=zv.bind(null,je,e),[s.memoizedState,e]},useRef:function(e){var t=Ct();return e={current:e},t.memoizedState=e},useState:function(e){e=Ac(e);var t=e.queue,n=Jm.bind(null,je,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:wc,useDeferredValue:function(e,t){var n=Ct();return Cc(n,e,t)},useTransition:function(){var e=Ac(!1);return e=Xm.bind(null,je,e.queue,!0,!1),Ct().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var s=je,c=Ct();if(Me){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Qe===null)throw Error(o(349));(ke&127)!==0||bm(s,t,n)}c.memoizedState=n;var u={value:n,getSnapshot:t};return c.queue=u,Bm(Am.bind(null,s,u,e),[e]),s.flags|=2048,ql(9,{destroy:void 0},Sm.bind(null,s,u,n,t),null),n},useId:function(){var e=Ct(),t=Qe.identifierPrefix;if(Me){var n=yn,s=vn;n=(s&~(1<<32-rt(s)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Ii++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Rv++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:kc,useFormState:Rm,useActionState:Rm,useOptimistic:function(e){var t=Ct();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=qc.bind(null,je,!0,n),n.dispatch=t,[e,t]},useMemoCache:yc,useCacheRefresh:function(){return Ct().memoizedState=Lv.bind(null,je)},useEffectEvent:function(e){var t=Ct(),n={impl:e};return t.memoizedState=n,function(){if((Be&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},Mc={readContext:bt,use:Pi,useCallback:$m,useContext:bt,useEffect:Nc,useImperativeHandle:Vm,useInsertionEffect:zm,useLayoutEffect:Um,useMemo:Gm,useReducer:er,useRef:Om,useState:function(){return er(zn)},useDebugValue:wc,useDeferredValue:function(e,t){var n=it();return Ym(n,Ve.memoizedState,e,t)},useTransition:function(){var e=er(zn)[0],t=it().memoizedState;return[typeof e=="boolean"?e:Cs(e),t]},useSyncExternalStore:ym,useId:Km,useHostTransitionStatus:kc,useFormState:Tm,useActionState:Tm,useOptimistic:function(e,t){var n=it();return wm(n,Ve,e,t)},useMemoCache:yc,useCacheRefresh:Zm};Mc.useEffectEvent=Lm;var eh={readContext:bt,use:Pi,useCallback:$m,useContext:bt,useEffect:Nc,useImperativeHandle:Vm,useInsertionEffect:zm,useLayoutEffect:Um,useMemo:Gm,useReducer:Sc,useRef:Om,useState:function(){return Sc(zn)},useDebugValue:wc,useDeferredValue:function(e,t){var n=it();return Ve===null?Cc(n,e,t):Ym(n,Ve.memoizedState,e,t)},useTransition:function(){var e=Sc(zn)[0],t=it().memoizedState;return[typeof e=="boolean"?e:Cs(e),t]},useSyncExternalStore:ym,useId:Km,useHostTransitionStatus:kc,useFormState:_m,useActionState:_m,useOptimistic:function(e,t){var n=it();return Ve!==null?wm(n,Ve,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:yc,useCacheRefresh:Zm};eh.useEffectEvent=Lm;function Rc(e,t,n,s){t=e.memoizedState,n=n(s,t),n=n==null?t:y({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Tc={enqueueSetState:function(e,t,n){e=e._reactInternals;var s=$t(),c=oa(s);c.payload=t,n!=null&&(c.callback=n),t=ca(e,c,s),t!==null&&(_t(t,e,s),As(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var s=$t(),c=oa(s);c.tag=1,c.payload=t,n!=null&&(c.callback=n),t=ca(e,c,s),t!==null&&(_t(t,e,s),As(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=$t(),s=oa(n);s.tag=2,t!=null&&(s.callback=t),t=ca(e,s,n),t!==null&&(_t(t,e,n),As(t,e,n))}};function th(e,t,n,s,c,u,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,u,v):t.prototype&&t.prototype.isPureReactComponent?!hs(n,s)||!hs(c,u):!0}function nh(e,t,n,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,s),t.state!==e&&Tc.enqueueReplaceState(t,t.state,null)}function Ya(e,t){var n=t;if("ref"in t){n={};for(var s in t)s!=="ref"&&(n[s]=t[s])}if(e=e.defaultProps){n===t&&(n=y({},n));for(var c in e)n[c]===void 0&&(n[c]=e[c])}return n}function ah(e){Oi(e)}function lh(e){console.error(e)}function sh(e){Oi(e)}function lr(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function ih(e,t,n){try{var s=e.onCaughtError;s(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Dc(e,t,n){return n=oa(n),n.tag=3,n.payload={element:null},n.callback=function(){lr(e,t)},n}function rh(e){return e=oa(e),e.tag=3,e}function oh(e,t,n,s){var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var u=s.value;e.payload=function(){return c(u)},e.callback=function(){ih(t,n,s)}}var v=n.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){ih(t,n,s),typeof c!="function"&&(pa===null?pa=new Set([this]):pa.add(this));var A=s.stack;this.componentDidCatch(s.value,{componentStack:A!==null?A:""})})}function Uv(e,t,n,s,c){if(n.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=n.alternate,t!==null&&Sl(t,n,c,!0),n=zt.current,n!==null){switch(n.tag){case 31:case 13:return tn===null?xr():n.alternate===null&&at===0&&(at=3),n.flags&=-257,n.flags|=65536,n.lanes=c,s===Xi?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([s]):t.add(s),lu(e,s,c)),!1;case 22:return n.flags|=65536,s===Xi?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([s]):n.add(s)),lu(e,s,c)),!1}throw Error(o(435,n.tag))}return lu(e,s,c),xr(),!1}if(Me)return t=zt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,s!==Wo&&(e=Error(o(422),{cause:s}),gs(It(e,n)))):(s!==Wo&&(t=Error(o(423),{cause:s}),gs(It(t,n))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,s=It(s,n),c=Dc(e.stateNode,s,c),cc(e,c),at!==4&&(at=2)),!1;var u=Error(o(520),{cause:s});if(u=It(u,n),Bs===null?Bs=[u]:Bs.push(u),at!==4&&(at=2),t===null)return!0;s=It(s,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=c&-c,n.lanes|=e,e=Dc(n.stateNode,s,e),cc(n,e),!1;case 1:if(t=n.type,u=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(pa===null||!pa.has(u))))return n.flags|=65536,c&=-c,n.lanes|=c,c=rh(c),oh(c,e,n,s),cc(n,c),!1}n=n.return}while(n!==null);return!1}var _c=Error(o(461)),ut=!1;function St(e,t,n,s){t.child=e===null?dm(t,null,n,s):$a(t,e.child,n,s)}function ch(e,t,n,s,c){n=n.render;var u=t.ref;if("ref"in s){var v={};for(var A in s)A!=="ref"&&(v[A]=s[A])}else v=s;return za(t),s=pc(e,t,n,v,u,c),A=xc(),e!==null&&!ut?(gc(e,t,c),Un(e,t,c)):(Me&&A&&Jo(t),t.flags|=1,St(e,t,s,c),t.child)}function uh(e,t,n,s,c){if(e===null){var u=n.type;return typeof u=="function"&&!Qo(u)&&u.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=u,fh(e,t,u,s,c)):(e=Ui(n.type,null,s,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!$c(e,c)){var v=u.memoizedProps;if(n=n.compare,n=n!==null?n:hs,n(v,s)&&e.ref===t.ref)return Un(e,t,c)}return t.flags|=1,e=Dn(u,s),e.ref=t.ref,e.return=t,t.child=e}function fh(e,t,n,s,c){if(e!==null){var u=e.memoizedProps;if(hs(u,s)&&e.ref===t.ref)if(ut=!1,t.pendingProps=s=u,$c(e,c))(e.flags&131072)!==0&&(ut=!0);else return t.lanes=e.lanes,Un(e,t,c)}return Oc(e,t,n,s,c)}function dh(e,t,n,s){var c=s.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|n:n,e!==null){for(s=t.child=e.child,c=0;s!==null;)c=c|s.lanes|s.childLanes,s=s.sibling;s=c&~u}else s=0,t.child=null;return mh(e,t,u,n,s)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Gi(t,u!==null?u.cachePool:null),u!==null?pm(t,u):fc(),xm(t);else return s=t.lanes=536870912,mh(e,t,u!==null?u.baseLanes|n:n,n,s)}else u!==null?(Gi(t,u.cachePool),pm(t,u),fa(),t.memoizedState=null):(e!==null&&Gi(t,null),fc(),fa());return St(e,t,c,n),t.child}function qs(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function mh(e,t,n,s,c){var u=sc();return u=u===null?null:{parent:ot._currentValue,pool:u},t.memoizedState={baseLanes:n,cachePool:u},e!==null&&Gi(t,null),fc(),xm(t),e!==null&&Sl(e,t,s,!0),t.childLanes=c,null}function sr(e,t){return t=rr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function hh(e,t,n){return $a(t,e.child,null,n),e=sr(t,t.pendingProps),e.flags|=2,Ut(t),t.memoizedState=null,e}function Hv(e,t,n){var s=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Me){if(s.mode==="hidden")return e=sr(t,s),t.lanes=536870912,qs(null,e);if(mc(t),(e=Ze)?(e=C0(e,en),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:aa!==null?{id:vn,overflow:yn}:null,retryLane:536870912,hydrationErrors:null},n=Id(e),n.return=t,t.child=n,yt=t,Ze=null)):e=null,e===null)throw sa(t);return t.lanes=536870912,null}return sr(t,s)}var u=e.memoizedState;if(u!==null){var v=u.dehydrated;if(mc(t),c)if(t.flags&256)t.flags&=-257,t=hh(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(ut||Sl(e,t,n,!1),c=(n&e.childLanes)!==0,ut||c){if(s=Qe,s!==null&&(v=Xe(s,n),v!==0&&v!==u.retryLane))throw u.retryLane=v,_a(e,v),_t(s,e,v),_c;xr(),t=hh(e,t,n)}else e=u.treeContext,Ze=nn(v.nextSibling),yt=t,Me=!0,la=null,en=!1,e!==null&&em(t,e),t=sr(t,s),t.flags|=4096;return t}return e=Dn(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ir(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Oc(e,t,n,s,c){return za(t),n=pc(e,t,n,s,void 0,c),s=xc(),e!==null&&!ut?(gc(e,t,c),Un(e,t,c)):(Me&&s&&Jo(t),t.flags|=1,St(e,t,n,c),t.child)}function ph(e,t,n,s,c,u){return za(t),t.updateQueue=null,n=vm(t,s,n,c),gm(e),s=xc(),e!==null&&!ut?(gc(e,t,u),Un(e,t,u)):(Me&&s&&Jo(t),t.flags|=1,St(e,t,n,u),t.child)}function xh(e,t,n,s,c){if(za(t),t.stateNode===null){var u=gl,v=n.contextType;typeof v=="object"&&v!==null&&(u=bt(v)),u=new n(s,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Tc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=s,u.state=t.memoizedState,u.refs={},rc(t),v=n.contextType,u.context=typeof v=="object"&&v!==null?bt(v):gl,u.state=t.memoizedState,v=n.getDerivedStateFromProps,typeof v=="function"&&(Rc(t,n,v,s),u.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(v=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),v!==u.state&&Tc.enqueueReplaceState(u,u.state,null),Ns(t,s,u,c),js(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!0}else if(e===null){u=t.stateNode;var A=t.memoizedProps,D=Ya(n,A);u.props=D;var G=u.context,I=n.contextType;v=gl,typeof I=="object"&&I!==null&&(v=bt(I));var ee=n.getDerivedStateFromProps;I=typeof ee=="function"||typeof u.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(A||G!==v)&&nh(t,u,s,v),ra=!1;var X=t.memoizedState;u.state=X,Ns(t,s,u,c),js(),G=t.memoizedState,A||X!==G||ra?(typeof ee=="function"&&(Rc(t,n,ee,s),G=t.memoizedState),(D=ra||th(t,n,D,s,X,G,v))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=G),u.props=s,u.state=G,u.context=v,s=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{u=t.stateNode,oc(e,t),v=t.memoizedProps,I=Ya(n,v),u.props=I,ee=t.pendingProps,X=u.context,G=n.contextType,D=gl,typeof G=="object"&&G!==null&&(D=bt(G)),A=n.getDerivedStateFromProps,(G=typeof A=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(v!==ee||X!==D)&&nh(t,u,s,D),ra=!1,X=t.memoizedState,u.state=X,Ns(t,s,u,c),js();var J=t.memoizedState;v!==ee||X!==J||ra||e!==null&&e.dependencies!==null&&Vi(e.dependencies)?(typeof A=="function"&&(Rc(t,n,A,s),J=t.memoizedState),(I=ra||th(t,n,I,s,X,J,D)||e!==null&&e.dependencies!==null&&Vi(e.dependencies))?(G||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(s,J,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(s,J,D)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=J),u.props=s,u.state=J,u.context=D,s=I):(typeof u.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(t.flags|=1024),s=!1)}return u=s,ir(e,t),s=(t.flags&128)!==0,u||s?(u=t.stateNode,n=s&&typeof n.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&s?(t.child=$a(t,e.child,null,c),t.child=$a(t,null,n,c)):St(e,t,n,c),t.memoizedState=u.state,e=t.child):e=Un(e,t,c),e}function gh(e,t,n,s){return Ba(),t.flags|=256,St(e,t,n,s),t.child}var Bc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Lc(e){return{baseLanes:e,cachePool:im()}}function zc(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Vt),e}function vh(e,t,n){var s=t.pendingProps,c=!1,u=(t.flags&128)!==0,v;if((v=u)||(v=e!==null&&e.memoizedState===null?!1:(st.current&2)!==0),v&&(c=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,e===null){if(Me){if(c?ua(t):fa(),(e=Ze)?(e=C0(e,en),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:aa!==null?{id:vn,overflow:yn}:null,retryLane:536870912,hydrationErrors:null},n=Id(e),n.return=t,t.child=n,yt=t,Ze=null)):e=null,e===null)throw sa(t);return bu(e)?t.lanes=32:t.lanes=536870912,null}var A=s.children;return s=s.fallback,c?(fa(),c=t.mode,A=rr({mode:"hidden",children:A},c),s=Oa(s,c,n,null),A.return=t,s.return=t,A.sibling=s,t.child=A,s=t.child,s.memoizedState=Lc(n),s.childLanes=zc(e,v,n),t.memoizedState=Bc,qs(null,s)):(ua(t),Uc(t,A))}var D=e.memoizedState;if(D!==null&&(A=D.dehydrated,A!==null)){if(u)t.flags&256?(ua(t),t.flags&=-257,t=Hc(e,t,n)):t.memoizedState!==null?(fa(),t.child=e.child,t.flags|=128,t=null):(fa(),A=s.fallback,c=t.mode,s=rr({mode:"visible",children:s.children},c),A=Oa(A,c,n,null),A.flags|=2,s.return=t,A.return=t,s.sibling=A,t.child=s,$a(t,e.child,null,n),s=t.child,s.memoizedState=Lc(n),s.childLanes=zc(e,v,n),t.memoizedState=Bc,t=qs(null,s));else if(ua(t),bu(A)){if(v=A.nextSibling&&A.nextSibling.dataset,v)var G=v.dgst;v=G,s=Error(o(419)),s.stack="",s.digest=v,gs({value:s,source:null,stack:null}),t=Hc(e,t,n)}else if(ut||Sl(e,t,n,!1),v=(n&e.childLanes)!==0,ut||v){if(v=Qe,v!==null&&(s=Xe(v,n),s!==0&&s!==D.retryLane))throw D.retryLane=s,_a(e,s),_t(v,e,s),_c;yu(A)||xr(),t=Hc(e,t,n)}else yu(A)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,Ze=nn(A.nextSibling),yt=t,Me=!0,la=null,en=!1,e!==null&&em(t,e),t=Uc(t,s.children),t.flags|=4096);return t}return c?(fa(),A=s.fallback,c=t.mode,D=e.child,G=D.sibling,s=Dn(D,{mode:"hidden",children:s.children}),s.subtreeFlags=D.subtreeFlags&65011712,G!==null?A=Dn(G,A):(A=Oa(A,c,n,null),A.flags|=2),A.return=t,s.return=t,s.sibling=A,t.child=s,qs(null,s),s=t.child,A=e.child.memoizedState,A===null?A=Lc(n):(c=A.cachePool,c!==null?(D=ot._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=im(),A={baseLanes:A.baseLanes|n,cachePool:c}),s.memoizedState=A,s.childLanes=zc(e,v,n),t.memoizedState=Bc,qs(e.child,s)):(ua(t),n=e.child,e=n.sibling,n=Dn(n,{mode:"visible",children:s.children}),n.return=t,n.sibling=null,e!==null&&(v=t.deletions,v===null?(t.deletions=[e],t.flags|=16):v.push(e)),t.child=n,t.memoizedState=null,n)}function Uc(e,t){return t=rr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function rr(e,t){return e=Lt(22,e,null,t),e.lanes=0,e}function Hc(e,t,n){return $a(t,e.child,null,n),e=Uc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function yh(e,t,n){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),tc(e.return,t,n)}function Vc(e,t,n,s,c,u){var v=e.memoizedState;v===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:n,tailMode:c,treeForkCount:u}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=s,v.tail=n,v.tailMode=c,v.treeForkCount=u)}function bh(e,t,n){var s=t.pendingProps,c=s.revealOrder,u=s.tail;s=s.children;var v=st.current,A=(v&2)!==0;if(A?(v=v&1|2,t.flags|=128):v&=1,te(st,v),St(e,t,s,n),s=Me?xs:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&yh(e,n,t);else if(e.tag===19)yh(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(n=t.child,c=null;n!==null;)e=n.alternate,e!==null&&Zi(e)===null&&(c=n),n=n.sibling;n=c,n===null?(c=t.child,t.child=null):(c=n.sibling,n.sibling=null),Vc(t,!1,c,n,u,s);break;case"backwards":case"unstable_legacy-backwards":for(n=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Zi(e)===null){t.child=c;break}e=c.sibling,c.sibling=n,n=c,c=e}Vc(t,!0,n,null,u,s);break;case"together":Vc(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function Un(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ha|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Sl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Dn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Dn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function $c(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Vi(e)))}function Vv(e,t,n){switch(t.tag){case 3:xe(t,t.stateNode.containerInfo),ia(t,ot,e.memoizedState.cache),Ba();break;case 27:case 5:ge(t);break;case 4:xe(t,t.stateNode.containerInfo);break;case 10:ia(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,mc(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(ua(t),t.flags|=128,null):(n&t.child.childLanes)!==0?vh(e,t,n):(ua(t),e=Un(e,t,n),e!==null?e.sibling:null);ua(t);break;case 19:var c=(e.flags&128)!==0;if(s=(n&t.childLanes)!==0,s||(Sl(e,t,n,!1),s=(n&t.childLanes)!==0),c){if(s)return bh(e,t,n);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),te(st,st.current),s)break;return null;case 22:return t.lanes=0,dh(e,t,n,t.pendingProps);case 24:ia(t,ot,e.memoizedState.cache)}return Un(e,t,n)}function Sh(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ut=!0;else{if(!$c(e,n)&&(t.flags&128)===0)return ut=!1,Vv(e,t,n);ut=(e.flags&131072)!==0}else ut=!1,Me&&(t.flags&1048576)!==0&&Pd(t,xs,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=Ha(t.elementType),t.type=e,typeof e=="function")Qo(e)?(s=Ya(e,s),t.tag=1,t=xh(null,t,e,s,n)):(t.tag=0,t=Oc(null,t,e,s,n));else{if(e!=null){var c=e.$$typeof;if(c===T){t.tag=11,t=ch(null,t,e,s,n);break e}else if(c===O){t.tag=14,t=uh(null,t,e,s,n);break e}}throw t=le(e)||e,Error(o(306,t,""))}}return t;case 0:return Oc(e,t,t.type,t.pendingProps,n);case 1:return s=t.type,c=Ya(s,t.pendingProps),xh(e,t,s,c,n);case 3:e:{if(xe(t,t.stateNode.containerInfo),e===null)throw Error(o(387));s=t.pendingProps;var u=t.memoizedState;c=u.element,oc(e,t),Ns(t,s,null,n);var v=t.memoizedState;if(s=v.cache,ia(t,ot,s),s!==u.cache&&nc(t,[ot],n,!0),js(),s=v.element,u.isDehydrated)if(u={element:s,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=gh(e,t,s,n);break e}else if(s!==c){c=It(Error(o(424)),t),gs(c),t=gh(e,t,s,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Ze=nn(e.firstChild),yt=t,Me=!0,la=null,en=!0,n=dm(t,null,s,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ba(),s===c){t=Un(e,t,n);break e}St(e,t,s,n)}t=t.child}return t;case 26:return ir(e,t),e===null?(n=T0(t.type,null,t.pendingProps,null))?t.memoizedState=n:Me||(n=t.type,e=t.pendingProps,s=jr(re.current).createElement(n),s[tt]=t,s[De]=e,At(s,n,e),xt(s),t.stateNode=s):t.memoizedState=T0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ge(t),e===null&&Me&&(s=t.stateNode=q0(t.type,t.pendingProps,re.current),yt=t,en=!0,c=Ze,ya(t.type)?(Su=c,Ze=nn(s.firstChild)):Ze=c),St(e,t,t.pendingProps.children,n),ir(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Me&&((c=s=Ze)&&(s=gy(s,t.type,t.pendingProps,en),s!==null?(t.stateNode=s,yt=t,Ze=nn(s.firstChild),en=!1,c=!0):c=!1),c||sa(t)),ge(t),c=t.type,u=t.pendingProps,v=e!==null?e.memoizedProps:null,s=u.children,xu(c,u)?s=null:v!==null&&xu(c,v)&&(t.flags|=32),t.memoizedState!==null&&(c=pc(e,t,Tv,null,null,n),Ys._currentValue=c),ir(e,t),St(e,t,s,n),t.child;case 6:return e===null&&Me&&((e=n=Ze)&&(n=vy(n,t.pendingProps,en),n!==null?(t.stateNode=n,yt=t,Ze=null,e=!0):e=!1),e||sa(t)),null;case 13:return vh(e,t,n);case 4:return xe(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=$a(t,null,s,n):St(e,t,s,n),t.child;case 11:return ch(e,t,t.type,t.pendingProps,n);case 7:return St(e,t,t.pendingProps,n),t.child;case 8:return St(e,t,t.pendingProps.children,n),t.child;case 12:return St(e,t,t.pendingProps.children,n),t.child;case 10:return s=t.pendingProps,ia(t,t.type,s.value),St(e,t,s.children,n),t.child;case 9:return c=t.type._context,s=t.pendingProps.children,za(t),c=bt(c),s=s(c),t.flags|=1,St(e,t,s,n),t.child;case 14:return uh(e,t,t.type,t.pendingProps,n);case 15:return fh(e,t,t.type,t.pendingProps,n);case 19:return bh(e,t,n);case 31:return Hv(e,t,n);case 22:return dh(e,t,n,t.pendingProps);case 24:return za(t),s=bt(ot),e===null?(c=sc(),c===null&&(c=Qe,u=ac(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=n),c=u),t.memoizedState={parent:s,cache:c},rc(t),ia(t,ot,c)):((e.lanes&n)!==0&&(oc(e,t),Ns(t,null,null,n),js()),c=e.memoizedState,u=t.memoizedState,c.parent!==s?(c={parent:s,cache:s},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),ia(t,ot,s)):(s=u.cache,ia(t,ot,s),s!==c.cache&&nc(t,[ot],n,!0))),St(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Hn(e){e.flags|=4}function Gc(e,t,n,s,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(Kh())e.flags|=8192;else throw Va=Xi,ic}else e.flags&=-16777217}function Ah(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!L0(t))if(Kh())e.flags|=8192;else throw Va=Xi,ic}function or(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?ji():536870912,e.lanes|=t,Dl|=t)}function Ms(e,t){if(!Me)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function Je(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,s=0;if(t)for(var c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags&65011712,s|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)n|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=n,t}function $v(e,t,n){var s=t.pendingProps;switch(Io(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(t),null;case 1:return Je(t),null;case 3:return n=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Bn(ot),pe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(bl(t)?Hn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Po())),Je(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Hn(t),u!==null?(Je(t),Ah(t,u)):(Je(t),Gc(t,c,null,s,n))):u?u!==e.memoizedState?(Hn(t),Je(t),Ah(t,u)):(Je(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&Hn(t),Je(t),Gc(t,c,e,s,n)),null;case 27:if(ze(t),n=re.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Hn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return Je(t),null}e=ne.current,bl(t)?tm(t):(e=q0(c,s,n),t.stateNode=e,Hn(t))}return Je(t),null;case 5:if(ze(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Hn(t);else{if(!s){if(t.stateNode===null)throw Error(o(166));return Je(t),null}if(u=ne.current,bl(t))tm(t);else{var v=jr(re.current);switch(u){case 1:u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=v.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=v.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=v.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof s.is=="string"?v.createElement("select",{is:s.is}):v.createElement("select"),s.multiple?u.multiple=!0:s.size&&(u.size=s.size);break;default:u=typeof s.is=="string"?v.createElement(c,{is:s.is}):v.createElement(c)}}u[tt]=t,u[De]=s;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)u.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=u;e:switch(At(u,c,s),c){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&Hn(t)}}return Je(t),Gc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&Hn(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(o(166));if(e=re.current,bl(t)){if(e=t.stateNode,n=t.memoizedProps,s=null,c=yt,c!==null)switch(c.tag){case 27:case 5:s=c.memoizedProps}e[tt]=t,e=!!(e.nodeValue===n||s!==null&&s.suppressHydrationWarning===!0||v0(e.nodeValue,n)),e||sa(t,!0)}else e=jr(e).createTextNode(s),e[tt]=t,t.stateNode=e}return Je(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(s=bl(t),n!==null){if(e===null){if(!s)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[tt]=t}else Ba(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Je(t),e=!1}else n=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ut(t),t):(Ut(t),null);if((t.flags&128)!==0)throw Error(o(558))}return Je(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=bl(t),s!==null&&s.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[tt]=t}else Ba(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Je(t),c=!1}else c=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Ut(t),t):(Ut(t),null)}return Ut(t),(t.flags&128)!==0?(t.lanes=n,t):(n=s!==null,e=e!==null&&e.memoizedState!==null,n&&(s=t.child,c=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(c=s.alternate.memoizedState.cachePool.pool),u=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),u!==c&&(s.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),or(t,t.updateQueue),Je(t),null);case 4:return pe(),e===null&&fu(t.stateNode.containerInfo),Je(t),null;case 10:return Bn(t.type),Je(t),null;case 19:if(V(st),s=t.memoizedState,s===null)return Je(t),null;if(c=(t.flags&128)!==0,u=s.rendering,u===null)if(c)Ms(s,!1);else{if(at!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Zi(e),u!==null){for(t.flags|=128,Ms(s,!1),e=u.updateQueue,t.updateQueue=e,or(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Jd(n,e),n=n.sibling;return te(st,st.current&1|2),Me&&_n(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&mt()>mr&&(t.flags|=128,c=!0,Ms(s,!1),t.lanes=4194304)}else{if(!c)if(e=Zi(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,or(t,e),Ms(s,!0),s.tail===null&&s.tailMode==="hidden"&&!u.alternate&&!Me)return Je(t),null}else 2*mt()-s.renderingStartTime>mr&&n!==536870912&&(t.flags|=128,c=!0,Ms(s,!1),t.lanes=4194304);s.isBackwards?(u.sibling=t.child,t.child=u):(e=s.last,e!==null?e.sibling=u:t.child=u,s.last=u)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=mt(),e.sibling=null,n=st.current,te(st,c?n&1|2:n&1),Me&&_n(t,s.treeForkCount),e):(Je(t),null);case 22:case 23:return Ut(t),dc(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(n&536870912)!==0&&(t.flags&128)===0&&(Je(t),t.subtreeFlags&6&&(t.flags|=8192)):Je(t),n=t.updateQueue,n!==null&&or(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==n&&(t.flags|=2048),e!==null&&V(Ua),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Bn(ot),Je(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Gv(e,t){switch(Io(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Bn(ot),pe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if(Ut(t),t.alternate===null)throw Error(o(340));Ba()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ut(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ba()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(st),null;case 4:return pe(),null;case 10:return Bn(t.type),null;case 22:case 23:return Ut(t),dc(),e!==null&&V(Ua),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Bn(ot),null;case 25:return null;default:return null}}function jh(e,t){switch(Io(t),t.tag){case 3:Bn(ot),pe();break;case 26:case 27:case 5:ze(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&Ut(t);break;case 13:Ut(t);break;case 19:V(st);break;case 10:Bn(t.type);break;case 22:case 23:Ut(t),dc(),e!==null&&V(Ua);break;case 24:Bn(ot)}}function Rs(e,t){try{var n=t.updateQueue,s=n!==null?n.lastEffect:null;if(s!==null){var c=s.next;n=c;do{if((n.tag&e)===e){s=void 0;var u=n.create,v=n.inst;s=u(),v.destroy=s}n=n.next}while(n!==c)}}catch(A){He(t,t.return,A)}}function da(e,t,n){try{var s=t.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var u=c.next;s=u;do{if((s.tag&e)===e){var v=s.inst,A=v.destroy;if(A!==void 0){v.destroy=void 0,c=t;var D=n,G=A;try{G()}catch(I){He(c,D,I)}}}s=s.next}while(s!==u)}}catch(I){He(t,t.return,I)}}function Nh(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{hm(t,n)}catch(s){He(e,e.return,s)}}}function wh(e,t,n){n.props=Ya(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(s){He(e,t,s)}}function Ts(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof n=="function"?e.refCleanup=n(s):n.current=s}}catch(c){He(e,t,c)}}function bn(e,t){var n=e.ref,s=e.refCleanup;if(n!==null)if(typeof s=="function")try{s()}catch(c){He(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(c){He(e,t,c)}else n.current=null}function Ch(e){var t=e.type,n=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&s.focus();break e;case"img":n.src?s.src=n.src:n.srcSet&&(s.srcset=n.srcSet)}}catch(c){He(e,e.return,c)}}function Yc(e,t,n){try{var s=e.stateNode;fy(s,e.type,n,t),s[De]=t}catch(c){He(e,e.return,c)}}function Eh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ya(e.type)||e.tag===4}function Xc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Eh(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&&ya(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 Fc(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Rn));else if(s!==4&&(s===27&&ya(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Fc(e,t,n),e=e.sibling;e!==null;)Fc(e,t,n),e=e.sibling}function cr(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(s!==4&&(s===27&&ya(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(cr(e,t,n),e=e.sibling;e!==null;)cr(e,t,n),e=e.sibling}function kh(e){var t=e.stateNode,n=e.memoizedProps;try{for(var s=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);At(t,s,n),t[tt]=e,t[De]=n}catch(u){He(e,e.return,u)}}var Vn=!1,ft=!1,Qc=!1,qh=typeof WeakSet=="function"?WeakSet:Set,gt=null;function Yv(e,t){if(e=e.containerInfo,hu=Mr,e=Vd(e),Ho(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var c=s.anchorOffset,u=s.focusNode;s=s.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var v=0,A=-1,D=-1,G=0,I=0,ee=e,X=null;t:for(;;){for(var J;ee!==n||c!==0&&ee.nodeType!==3||(A=v+c),ee!==u||s!==0&&ee.nodeType!==3||(D=v+s),ee.nodeType===3&&(v+=ee.nodeValue.length),(J=ee.firstChild)!==null;)X=ee,ee=J;for(;;){if(ee===e)break t;if(X===n&&++G===c&&(A=v),X===u&&++I===s&&(D=v),(J=ee.nextSibling)!==null)break;ee=X,X=ee.parentNode}ee=J}n=A===-1||D===-1?null:{start:A,end:D}}else n=null}n=n||{start:0,end:0}}else n=null;for(pu={focusedElem:e,selectionRange:n},Mr=!1,gt=t;gt!==null;)if(t=gt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,gt=e;else for(;gt!==null;){switch(t=gt,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)c=e[n],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,n=t,c=u.memoizedProps,u=u.memoizedState,s=n.stateNode;try{var fe=Ya(n.type,c);e=s.getSnapshotBeforeUpdate(fe,u),s.__reactInternalSnapshotBeforeUpdate=e}catch(be){He(n,n.return,be)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)vu(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":vu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,gt=e;break}gt=t.return}}function Mh(e,t,n){var s=n.flags;switch(n.tag){case 0:case 11:case 15:Gn(e,n),s&4&&Rs(5,n);break;case 1:if(Gn(e,n),s&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(v){He(n,n.return,v)}else{var c=Ya(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(v){He(n,n.return,v)}}s&64&&Nh(n),s&512&&Ts(n,n.return);break;case 3:if(Gn(e,n),s&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{hm(e,t)}catch(v){He(n,n.return,v)}}break;case 27:t===null&&s&4&&kh(n);case 26:case 5:Gn(e,n),t===null&&s&4&&Ch(n),s&512&&Ts(n,n.return);break;case 12:Gn(e,n);break;case 31:Gn(e,n),s&4&&Dh(e,n);break;case 13:Gn(e,n),s&4&&_h(e,n),s&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Pv.bind(null,n),yy(e,n))));break;case 22:if(s=n.memoizedState!==null||Vn,!s){t=t!==null&&t.memoizedState!==null||ft,c=Vn;var u=ft;Vn=s,(ft=t)&&!u?Yn(e,n,(n.subtreeFlags&8772)!==0):Gn(e,n),Vn=c,ft=u}break;case 30:break;default:Gn(e,n)}}function Rh(e){var t=e.alternate;t!==null&&(e.alternate=null,Rh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&jo(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ie=null,Mt=!1;function $n(e,t,n){for(n=n.child;n!==null;)Th(e,t,n),n=n.sibling}function Th(e,t,n){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(cn,n)}catch{}switch(n.tag){case 26:ft||bn(n,t),$n(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:ft||bn(n,t);var s=Ie,c=Mt;ya(n.type)&&(Ie=n.stateNode,Mt=!1),$n(e,t,n),Vs(n.stateNode),Ie=s,Mt=c;break;case 5:ft||bn(n,t);case 6:if(s=Ie,c=Mt,Ie=null,$n(e,t,n),Ie=s,Mt=c,Ie!==null)if(Mt)try{(Ie.nodeType===9?Ie.body:Ie.nodeName==="HTML"?Ie.ownerDocument.body:Ie).removeChild(n.stateNode)}catch(u){He(n,t,u)}else try{Ie.removeChild(n.stateNode)}catch(u){He(n,t,u)}break;case 18:Ie!==null&&(Mt?(e=Ie,N0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Vl(e)):N0(Ie,n.stateNode));break;case 4:s=Ie,c=Mt,Ie=n.stateNode.containerInfo,Mt=!0,$n(e,t,n),Ie=s,Mt=c;break;case 0:case 11:case 14:case 15:da(2,n,t),ft||da(4,n,t),$n(e,t,n);break;case 1:ft||(bn(n,t),s=n.stateNode,typeof s.componentWillUnmount=="function"&&wh(n,t,s)),$n(e,t,n);break;case 21:$n(e,t,n);break;case 22:ft=(s=ft)||n.memoizedState!==null,$n(e,t,n),ft=s;break;default:$n(e,t,n)}}function Dh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vl(e)}catch(n){He(t,t.return,n)}}}function _h(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vl(e)}catch(n){He(t,t.return,n)}}function Xv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new qh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new qh),t;default:throw Error(o(435,e.tag))}}function ur(e,t){var n=Xv(e);t.forEach(function(s){if(!n.has(s)){n.add(s);var c=ey.bind(null,e,s);s.then(c,c)}})}function Rt(e,t){var n=t.deletions;if(n!==null)for(var s=0;s<n.length;s++){var c=n[s],u=e,v=t,A=v;e:for(;A!==null;){switch(A.tag){case 27:if(ya(A.type)){Ie=A.stateNode,Mt=!1;break e}break;case 5:Ie=A.stateNode,Mt=!1;break e;case 3:case 4:Ie=A.stateNode.containerInfo,Mt=!0;break e}A=A.return}if(Ie===null)throw Error(o(160));Th(u,v,c),Ie=null,Mt=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Oh(t,e),t=t.sibling}var fn=null;function Oh(e,t){var n=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Rt(t,e),Tt(e),s&4&&(da(3,e,e.return),Rs(3,e),da(5,e,e.return));break;case 1:Rt(t,e),Tt(e),s&512&&(ft||n===null||bn(n,n.return)),s&64&&Vn&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?s:n.concat(s))));break;case 26:var c=fn;if(Rt(t,e),Tt(e),s&512&&(ft||n===null||bn(n,n.return)),s&4){var u=n!==null?n.memoizedState:null;if(s=e.memoizedState,n===null)if(s===null)if(e.stateNode===null){e:{s=e.type,n=e.memoizedProps,c=c.ownerDocument||c;t:switch(s){case"title":u=c.getElementsByTagName("title")[0],(!u||u[ss]||u[tt]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(s),c.head.insertBefore(u,c.querySelector("head > title"))),At(u,s,n),u[tt]=e,xt(u),s=u;break e;case"link":var v=O0("link","href",c).get(s+(n.href||""));if(v){for(var A=0;A<v.length;A++)if(u=v[A],u.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&u.getAttribute("rel")===(n.rel==null?null:n.rel)&&u.getAttribute("title")===(n.title==null?null:n.title)&&u.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){v.splice(A,1);break t}}u=c.createElement(s),At(u,s,n),c.head.appendChild(u);break;case"meta":if(v=O0("meta","content",c).get(s+(n.content||""))){for(A=0;A<v.length;A++)if(u=v[A],u.getAttribute("content")===(n.content==null?null:""+n.content)&&u.getAttribute("name")===(n.name==null?null:n.name)&&u.getAttribute("property")===(n.property==null?null:n.property)&&u.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&u.getAttribute("charset")===(n.charSet==null?null:n.charSet)){v.splice(A,1);break t}}u=c.createElement(s),At(u,s,n),c.head.appendChild(u);break;default:throw Error(o(468,s))}u[tt]=e,xt(u),s=u}e.stateNode=s}else B0(c,e.type,e.stateNode);else e.stateNode=_0(c,s,e.memoizedProps);else u!==s?(u===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):u.count--,s===null?B0(c,e.type,e.stateNode):_0(c,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Yc(e,e.memoizedProps,n.memoizedProps)}break;case 27:Rt(t,e),Tt(e),s&512&&(ft||n===null||bn(n,n.return)),n!==null&&s&4&&Yc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Rt(t,e),Tt(e),s&512&&(ft||n===null||bn(n,n.return)),e.flags&32){c=e.stateNode;try{ul(c,"")}catch(fe){He(e,e.return,fe)}}s&4&&e.stateNode!=null&&(c=e.memoizedProps,Yc(e,c,n!==null?n.memoizedProps:c)),s&1024&&(Qc=!0);break;case 6:if(Rt(t,e),Tt(e),s&4){if(e.stateNode===null)throw Error(o(162));s=e.memoizedProps,n=e.stateNode;try{n.nodeValue=s}catch(fe){He(e,e.return,fe)}}break;case 3:if(Cr=null,c=fn,fn=Nr(t.containerInfo),Rt(t,e),fn=c,Tt(e),s&4&&n!==null&&n.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(fe){He(e,e.return,fe)}Qc&&(Qc=!1,Bh(e));break;case 4:s=fn,fn=Nr(e.stateNode.containerInfo),Rt(t,e),Tt(e),fn=s;break;case 12:Rt(t,e),Tt(e);break;case 31:Rt(t,e),Tt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ur(e,s)));break;case 13:Rt(t,e),Tt(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(dr=mt()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ur(e,s)));break;case 22:c=e.memoizedState!==null;var D=n!==null&&n.memoizedState!==null,G=Vn,I=ft;if(Vn=G||c,ft=I||D,Rt(t,e),ft=I,Vn=G,Tt(e),s&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(n===null||D||Vn||ft||Xa(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){D=n=t;try{if(u=D.stateNode,c)v=u.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{A=D.stateNode;var ee=D.memoizedProps.style,X=ee!=null&&ee.hasOwnProperty("display")?ee.display:null;A.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(fe){He(D,D.return,fe)}}}else if(t.tag===6){if(n===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(fe){He(D,D.return,fe)}}}else if(t.tag===18){if(n===null){D=t;try{var J=D.stateNode;c?w0(J,!0):w0(D.stateNode,!1)}catch(fe){He(D,D.return,fe)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}s&4&&(s=e.updateQueue,s!==null&&(n=s.retryQueue,n!==null&&(s.retryQueue=null,ur(e,n))));break;case 19:Rt(t,e),Tt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ur(e,s)));break;case 30:break;case 21:break;default:Rt(t,e),Tt(e)}}function Tt(e){var t=e.flags;if(t&2){try{for(var n,s=e.return;s!==null;){if(Eh(s)){n=s;break}s=s.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode,u=Xc(e);cr(e,u,c);break;case 5:var v=n.stateNode;n.flags&32&&(ul(v,""),n.flags&=-33);var A=Xc(e);cr(e,A,v);break;case 3:case 4:var D=n.stateNode.containerInfo,G=Xc(e);Fc(e,G,D);break;default:throw Error(o(161))}}catch(I){He(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Bh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Bh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Gn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Mh(e,t.alternate,t),t=t.sibling}function Xa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:da(4,t,t.return),Xa(t);break;case 1:bn(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&wh(t,t.return,n),Xa(t);break;case 27:Vs(t.stateNode);case 26:case 5:bn(t,t.return),Xa(t);break;case 22:t.memoizedState===null&&Xa(t);break;case 30:Xa(t);break;default:Xa(t)}e=e.sibling}}function Yn(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var s=t.alternate,c=e,u=t,v=u.flags;switch(u.tag){case 0:case 11:case 15:Yn(c,u,n),Rs(4,u);break;case 1:if(Yn(c,u,n),s=u,c=s.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(G){He(s,s.return,G)}if(s=u,c=s.updateQueue,c!==null){var A=s.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)mm(D[c],A)}catch(G){He(s,s.return,G)}}n&&v&64&&Nh(u),Ts(u,u.return);break;case 27:kh(u);case 26:case 5:Yn(c,u,n),n&&s===null&&v&4&&Ch(u),Ts(u,u.return);break;case 12:Yn(c,u,n);break;case 31:Yn(c,u,n),n&&v&4&&Dh(c,u);break;case 13:Yn(c,u,n),n&&v&4&&_h(c,u);break;case 22:u.memoizedState===null&&Yn(c,u,n),Ts(u,u.return);break;case 30:break;default:Yn(c,u,n)}t=t.sibling}}function Kc(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&vs(n))}function Zc(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&vs(e))}function dn(e,t,n,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Lh(e,t,n,s),t=t.sibling}function Lh(e,t,n,s){var c=t.flags;switch(t.tag){case 0:case 11:case 15:dn(e,t,n,s),c&2048&&Rs(9,t);break;case 1:dn(e,t,n,s);break;case 3:dn(e,t,n,s),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&vs(e)));break;case 12:if(c&2048){dn(e,t,n,s),e=t.stateNode;try{var u=t.memoizedProps,v=u.id,A=u.onPostCommit;typeof A=="function"&&A(v,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){He(t,t.return,D)}}else dn(e,t,n,s);break;case 31:dn(e,t,n,s);break;case 13:dn(e,t,n,s);break;case 23:break;case 22:u=t.stateNode,v=t.alternate,t.memoizedState!==null?u._visibility&2?dn(e,t,n,s):Ds(e,t):u._visibility&2?dn(e,t,n,s):(u._visibility|=2,Ml(e,t,n,s,(t.subtreeFlags&10256)!==0||!1)),c&2048&&Kc(v,t);break;case 24:dn(e,t,n,s),c&2048&&Zc(t.alternate,t);break;default:dn(e,t,n,s)}}function Ml(e,t,n,s,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,v=t,A=n,D=s,G=v.flags;switch(v.tag){case 0:case 11:case 15:Ml(u,v,A,D,c),Rs(8,v);break;case 23:break;case 22:var I=v.stateNode;v.memoizedState!==null?I._visibility&2?Ml(u,v,A,D,c):Ds(u,v):(I._visibility|=2,Ml(u,v,A,D,c)),c&&G&2048&&Kc(v.alternate,v);break;case 24:Ml(u,v,A,D,c),c&&G&2048&&Zc(v.alternate,v);break;default:Ml(u,v,A,D,c)}t=t.sibling}}function Ds(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,s=t,c=s.flags;switch(s.tag){case 22:Ds(n,s),c&2048&&Kc(s.alternate,s);break;case 24:Ds(n,s),c&2048&&Zc(s.alternate,s);break;default:Ds(n,s)}t=t.sibling}}var _s=8192;function Rl(e,t,n){if(e.subtreeFlags&_s)for(e=e.child;e!==null;)zh(e,t,n),e=e.sibling}function zh(e,t,n){switch(e.tag){case 26:Rl(e,t,n),e.flags&_s&&e.memoizedState!==null&&Ry(n,fn,e.memoizedState,e.memoizedProps);break;case 5:Rl(e,t,n);break;case 3:case 4:var s=fn;fn=Nr(e.stateNode.containerInfo),Rl(e,t,n),fn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=_s,_s=16777216,Rl(e,t,n),_s=s):Rl(e,t,n));break;default:Rl(e,t,n)}}function Uh(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 Os(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];gt=s,Vh(s,e)}Uh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Hh(e),e=e.sibling}function Hh(e){switch(e.tag){case 0:case 11:case 15:Os(e),e.flags&2048&&da(9,e,e.return);break;case 3:Os(e);break;case 12:Os(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,fr(e)):Os(e);break;default:Os(e)}}function fr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];gt=s,Vh(s,e)}Uh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:da(8,t,t.return),fr(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,fr(t));break;default:fr(t)}e=e.sibling}}function Vh(e,t){for(;gt!==null;){var n=gt;switch(n.tag){case 0:case 11:case 15:da(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var s=n.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:vs(n.memoizedState.cache)}if(s=n.child,s!==null)s.return=n,gt=s;else e:for(n=e;gt!==null;){s=gt;var c=s.sibling,u=s.return;if(Rh(s),s===n){gt=null;break e}if(c!==null){c.return=u,gt=c;break e}gt=u}}}var Fv={getCacheForType:function(e){var t=bt(ot),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return bt(ot).controller.signal}},Qv=typeof WeakMap=="function"?WeakMap:Map,Be=0,Qe=null,Ce=null,ke=0,Ue=0,Ht=null,ma=!1,Tl=!1,Jc=!1,Xn=0,at=0,ha=0,Fa=0,Ic=0,Vt=0,Dl=0,Bs=null,Dt=null,Wc=!1,dr=0,$h=0,mr=1/0,hr=null,pa=null,ht=0,xa=null,_l=null,Fn=0,Pc=0,eu=null,Gh=null,Ls=0,tu=null;function $t(){return(Be&2)!==0&&ke!==0?ke&-ke:R.T!==null?ru():Le()}function Yh(){if(Vt===0)if((ke&536870912)===0||Me){var e=Ke;Ke<<=1,(Ke&3932160)===0&&(Ke=262144),Vt=e}else Vt=536870912;return e=zt.current,e!==null&&(e.flags|=32),Vt}function _t(e,t,n){(e===Qe&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)&&(Ol(e,0),ga(e,ke,Vt,!1)),qa(e,n),((Be&2)===0||e!==Qe)&&(e===Qe&&((Be&2)===0&&(Fa|=n),at===4&&ga(e,ke,Vt,!1)),Sn(e))}function Xh(e,t,n){if((Be&6)!==0)throw Error(o(327));var s=!n&&(t&127)===0&&(t&e.expiredLanes)===0||gn(e,t),c=s?Jv(e,t):au(e,t,!0),u=s;do{if(c===0){Tl&&!s&&ga(e,t,0,!1);break}else{if(n=e.current.alternate,u&&!Kv(n)){c=au(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var v=0;else v=e.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){t=v;e:{var A=e;c=Bs;var D=A.current.memoizedState.isDehydrated;if(D&&(Ol(A,v).flags|=256),v=au(A,v,!1),v!==2){if(Jc&&!D){A.errorRecoveryDisabledLanes|=u,Fa|=u,c=4;break e}u=Dt,Dt=c,u!==null&&(Dt===null?Dt=u:Dt.push.apply(Dt,u))}c=v}if(u=!1,c!==2)continue}}if(c===1){Ol(e,0),ga(e,t,0,!0);break}e:{switch(s=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ga(s,t,Vt,!ma);break e;case 2:Dt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=dr+300-mt(),10<c)){if(ga(s,t,Vt,!ma),ta(s,0,!0)!==0)break e;Fn=t,s.timeoutHandle=A0(Fh.bind(null,s,n,Dt,hr,Wc,t,Vt,Fa,Dl,ma,u,"Throttled",-0,0),c);break e}Fh(s,n,Dt,hr,Wc,t,Vt,Fa,Dl,ma,u,null,-0,0)}}break}while(!0);Sn(e)}function Fh(e,t,n,s,c,u,v,A,D,G,I,ee,X,J){if(e.timeoutHandle=-1,ee=t.subtreeFlags,ee&8192||(ee&16785408)===16785408){ee={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Rn},zh(t,u,ee);var fe=(u&62914560)===u?dr-mt():(u&4194048)===u?$h-mt():0;if(fe=Ty(ee,fe),fe!==null){Fn=u,e.cancelPendingCommit=fe(e0.bind(null,e,t,u,n,s,c,v,A,D,I,ee,null,X,J)),ga(e,u,v,!G);return}}e0(e,t,u,n,s,c,v,A,D)}function Kv(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var s=0;s<n.length;s++){var c=n[s],u=c.getSnapshot;c=c.value;try{if(!Bt(u(),c))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ga(e,t,n,s){t&=~Ic,t&=~Fa,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var c=t;0<c;){var u=31-rt(c),v=1<<u;s[u]=-1,c&=~v}n!==0&&Ft(e,n,t)}function pr(){return(Be&6)===0?(zs(0),!1):!0}function nu(){if(Ce!==null){if(Ue===0)var e=Ce.return;else e=Ce,On=La=null,vc(e),wl=null,bs=0,e=Ce;for(;e!==null;)jh(e.alternate,e),e=e.return;Ce=null}}function Ol(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,hy(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Fn=0,nu(),Qe=e,Ce=n=Dn(e.current,null),ke=t,Ue=0,Ht=null,ma=!1,Tl=gn(e,t),Jc=!1,Dl=Vt=Ic=Fa=ha=at=0,Dt=Bs=null,Wc=!1,(t&8)!==0&&(t|=t&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=t;0<s;){var c=31-rt(s),u=1<<c;t|=e[c],s&=~u}return Xn=t,Bi(),n}function Qh(e,t){je=null,R.H=ks,t===Nl||t===Yi?(t=cm(),Ue=3):t===ic?(t=cm(),Ue=4):Ue=t===_c?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ht=t,Ce===null&&(at=1,lr(e,It(t,e.current)))}function Kh(){var e=zt.current;return e===null?!0:(ke&4194048)===ke?tn===null:(ke&62914560)===ke||(ke&536870912)!==0?e===tn:!1}function Zh(){var e=R.H;return R.H=ks,e===null?ks:e}function Jh(){var e=R.A;return R.A=Fv,e}function xr(){at=4,ma||(ke&4194048)!==ke&&zt.current!==null||(Tl=!0),(ha&134217727)===0&&(Fa&134217727)===0||Qe===null||ga(Qe,ke,Vt,!1)}function au(e,t,n){var s=Be;Be|=2;var c=Zh(),u=Jh();(Qe!==e||ke!==t)&&(hr=null,Ol(e,t)),t=!1;var v=at;e:do try{if(Ue!==0&&Ce!==null){var A=Ce,D=Ht;switch(Ue){case 8:nu(),v=6;break e;case 3:case 2:case 9:case 6:zt.current===null&&(t=!0);var G=Ue;if(Ue=0,Ht=null,Bl(e,A,D,G),n&&Tl){v=0;break e}break;default:G=Ue,Ue=0,Ht=null,Bl(e,A,D,G)}}Zv(),v=at;break}catch(I){Qh(e,I)}while(!0);return t&&e.shellSuspendCounter++,On=La=null,Be=s,R.H=c,R.A=u,Ce===null&&(Qe=null,ke=0,Bi()),v}function Zv(){for(;Ce!==null;)Ih(Ce)}function Jv(e,t){var n=Be;Be|=2;var s=Zh(),c=Jh();Qe!==e||ke!==t?(hr=null,mr=mt()+500,Ol(e,t)):Tl=gn(e,t);e:do try{if(Ue!==0&&Ce!==null){t=Ce;var u=Ht;t:switch(Ue){case 1:Ue=0,Ht=null,Bl(e,t,u,1);break;case 2:case 9:if(rm(u)){Ue=0,Ht=null,Wh(t);break}t=function(){Ue!==2&&Ue!==9||Qe!==e||(Ue=7),Sn(e)},u.then(t,t);break e;case 3:Ue=7;break e;case 4:Ue=5;break e;case 7:rm(u)?(Ue=0,Ht=null,Wh(t)):(Ue=0,Ht=null,Bl(e,t,u,7));break;case 5:var v=null;switch(Ce.tag){case 26:v=Ce.memoizedState;case 5:case 27:var A=Ce;if(v?L0(v):A.stateNode.complete){Ue=0,Ht=null;var D=A.sibling;if(D!==null)Ce=D;else{var G=A.return;G!==null?(Ce=G,gr(G)):Ce=null}break t}}Ue=0,Ht=null,Bl(e,t,u,5);break;case 6:Ue=0,Ht=null,Bl(e,t,u,6);break;case 8:nu(),at=6;break e;default:throw Error(o(462))}}Iv();break}catch(I){Qh(e,I)}while(!0);return On=La=null,R.H=s,R.A=c,Be=n,Ce!==null?0:(Qe=null,ke=0,Bi(),at)}function Iv(){for(;Ce!==null&&!qn();)Ih(Ce)}function Ih(e){var t=Sh(e.alternate,e,Xn);e.memoizedProps=e.pendingProps,t===null?gr(e):Ce=t}function Wh(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=ph(n,t,t.pendingProps,t.type,void 0,ke);break;case 11:t=ph(n,t,t.pendingProps,t.type.render,t.ref,ke);break;case 5:vc(t);default:jh(n,t),t=Ce=Jd(t,Xn),t=Sh(n,t,Xn)}e.memoizedProps=e.pendingProps,t===null?gr(e):Ce=t}function Bl(e,t,n,s){On=La=null,vc(t),wl=null,bs=0;var c=t.return;try{if(Uv(e,c,t,n,ke)){at=1,lr(e,It(n,e.current)),Ce=null;return}}catch(u){if(c!==null)throw Ce=c,u;at=1,lr(e,It(n,e.current)),Ce=null;return}t.flags&32768?(Me||s===1?e=!0:Tl||(ke&536870912)!==0?e=!1:(ma=e=!0,(s===2||s===9||s===3||s===6)&&(s=zt.current,s!==null&&s.tag===13&&(s.flags|=16384))),Ph(t,e)):gr(t)}function gr(e){var t=e;do{if((t.flags&32768)!==0){Ph(t,ma);return}e=t.return;var n=$v(t.alternate,t,Xn);if(n!==null){Ce=n;return}if(t=t.sibling,t!==null){Ce=t;return}Ce=t=e}while(t!==null);at===0&&(at=5)}function Ph(e,t){do{var n=Gv(e.alternate,e);if(n!==null){n.flags&=32767,Ce=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ce=e;return}Ce=e=n}while(e!==null);at=6,Ce=null}function e0(e,t,n,s,c,u,v,A,D){e.cancelPendingCommit=null;do vr();while(ht!==0);if((Be&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=Xo,Ni(e,n,u,v,A,D),e===Qe&&(Ce=Qe=null,ke=0),_l=t,xa=e,Fn=n,Pc=u,eu=c,Gh=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,ty(Ea,function(){return s0(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=R.T,R.T=null,c=Q.p,Q.p=2,v=Be,Be|=4;try{Yv(e,t,n)}finally{Be=v,Q.p=c,R.T=s}}ht=1,t0(),n0(),a0()}}function t0(){if(ht===1){ht=0;var e=xa,t=_l,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=R.T,R.T=null;var s=Q.p;Q.p=2;var c=Be;Be|=4;try{Oh(t,e);var u=pu,v=Vd(e.containerInfo),A=u.focusedElem,D=u.selectionRange;if(v!==A&&A&&A.ownerDocument&&Hd(A.ownerDocument.documentElement,A)){if(D!==null&&Ho(A)){var G=D.start,I=D.end;if(I===void 0&&(I=G),"selectionStart"in A)A.selectionStart=G,A.selectionEnd=Math.min(I,A.value.length);else{var ee=A.ownerDocument||document,X=ee&&ee.defaultView||window;if(X.getSelection){var J=X.getSelection(),fe=A.textContent.length,be=Math.min(D.start,fe),Ge=D.end===void 0?be:Math.min(D.end,fe);!J.extend&&be>Ge&&(v=Ge,Ge=be,be=v);var B=Ud(A,be),_=Ud(A,Ge);if(B&&_&&(J.rangeCount!==1||J.anchorNode!==B.node||J.anchorOffset!==B.offset||J.focusNode!==_.node||J.focusOffset!==_.offset)){var $=ee.createRange();$.setStart(B.node,B.offset),J.removeAllRanges(),be>Ge?(J.addRange($),J.extend(_.node,_.offset)):($.setEnd(_.node,_.offset),J.addRange($))}}}}for(ee=[],J=A;J=J.parentNode;)J.nodeType===1&&ee.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ee.length;A++){var W=ee[A];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}Mr=!!hu,pu=hu=null}finally{Be=c,Q.p=s,R.T=n}}e.current=t,ht=2}}function n0(){if(ht===2){ht=0;var e=xa,t=_l,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=R.T,R.T=null;var s=Q.p;Q.p=2;var c=Be;Be|=4;try{Mh(e,t.alternate,t)}finally{Be=c,Q.p=s,R.T=n}}ht=3}}function a0(){if(ht===4||ht===3){ht=0,vo();var e=xa,t=_l,n=Fn,s=Gh;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ht=5:(ht=0,_l=xa=null,l0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(pa=null),we(n),t=t.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(cn,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=R.T,c=Q.p,Q.p=2,R.T=null;try{for(var u=e.onRecoverableError,v=0;v<s.length;v++){var A=s[v];u(A.value,{componentStack:A.stack})}}finally{R.T=t,Q.p=c}}(Fn&3)!==0&&vr(),Sn(e),c=e.pendingLanes,(n&261930)!==0&&(c&42)!==0?e===tu?Ls++:(Ls=0,tu=e):Ls=0,zs(0)}}function l0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,vs(t)))}function vr(){return t0(),n0(),a0(),s0()}function s0(){if(ht!==5)return!1;var e=xa,t=Pc;Pc=0;var n=we(Fn),s=R.T,c=Q.p;try{Q.p=32>n?32:n,R.T=null,n=eu,eu=null;var u=xa,v=Fn;if(ht=0,_l=xa=null,Fn=0,(Be&6)!==0)throw Error(o(331));var A=Be;if(Be|=4,Hh(u.current),Lh(u,u.current,v,n),Be=A,zs(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(cn,u)}catch{}return!0}finally{Q.p=c,R.T=s,l0(e,t)}}function i0(e,t,n){t=It(n,t),t=Dc(e.stateNode,t,2),e=ca(e,t,2),e!==null&&(qa(e,2),Sn(e))}function He(e,t,n){if(e.tag===3)i0(e,e,n);else for(;t!==null;){if(t.tag===3){i0(t,e,n);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(pa===null||!pa.has(s))){e=It(n,e),n=rh(2),s=ca(t,n,2),s!==null&&(oh(n,s,t,e),qa(s,2),Sn(s));break}}t=t.return}}function lu(e,t,n){var s=e.pingCache;if(s===null){s=e.pingCache=new Qv;var c=new Set;s.set(t,c)}else c=s.get(t),c===void 0&&(c=new Set,s.set(t,c));c.has(n)||(Jc=!0,c.add(n),e=Wv.bind(null,e,t,n),t.then(e,e))}function Wv(e,t,n){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Qe===e&&(ke&n)===n&&(at===4||at===3&&(ke&62914560)===ke&&300>mt()-dr?(Be&2)===0&&Ol(e,0):Ic|=n,Dl===ke&&(Dl=0)),Sn(e)}function r0(e,t){t===0&&(t=ji()),e=_a(e,t),e!==null&&(qa(e,t),Sn(e))}function Pv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),r0(e,n)}function ey(e,t){var n=0;switch(e.tag){case 31:case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(n=c.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(o(314))}s!==null&&s.delete(t),r0(e,n)}function ty(e,t){return Nt(e,t)}var yr=null,Ll=null,su=!1,br=!1,iu=!1,va=0;function Sn(e){e!==Ll&&e.next===null&&(Ll===null?yr=Ll=e:Ll=Ll.next=e),br=!0,su||(su=!0,ay())}function zs(e,t){if(!iu&&br){iu=!0;do for(var n=!1,s=yr;s!==null;){if(e!==0){var c=s.pendingLanes;if(c===0)var u=0;else{var v=s.suspendedLanes,A=s.pingedLanes;u=(1<<31-rt(42|e)+1)-1,u&=c&~(v&~A),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(n=!0,f0(s,u))}else u=ke,u=ta(s,s===Qe?u:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(u&3)===0||gn(s,u)||(n=!0,f0(s,u));s=s.next}while(n);iu=!1}}function ny(){o0()}function o0(){br=su=!1;var e=0;va!==0&&my()&&(e=va);for(var t=mt(),n=null,s=yr;s!==null;){var c=s.next,u=c0(s,t);u===0?(s.next=null,n===null?yr=c:n.next=c,c===null&&(Ll=n)):(n=s,(e!==0||(u&3)!==0)&&(br=!0)),s=c}ht!==0&&ht!==5||zs(e),va!==0&&(va=0)}function c0(e,t){for(var n=e.suspendedLanes,s=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var v=31-rt(u),A=1<<v,D=c[v];D===-1?((A&n)===0||(A&s)!==0)&&(c[v]=Ai(A,t)):D<=t&&(e.expiredLanes|=A),u&=~A}if(t=Qe,n=ke,n=ta(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,n===0||e===t&&(Ue===2||Ue===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&rn(s),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||gn(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(s!==null&&rn(s),we(n)){case 2:case 8:n=on;break;case 32:n=Ea;break;case 268435456:n=nl;break;default:n=Ea}return s=u0.bind(null,e),n=Nt(n,s),e.callbackPriority=t,e.callbackNode=n,t}return s!==null&&s!==null&&rn(s),e.callbackPriority=2,e.callbackNode=null,2}function u0(e,t){if(ht!==0&&ht!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(vr()&&e.callbackNode!==n)return null;var s=ke;return s=ta(e,e===Qe?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Xh(e,s,t),c0(e,mt()),e.callbackNode!=null&&e.callbackNode===n?u0.bind(null,e):null)}function f0(e,t){if(vr())return null;Xh(e,t,!0)}function ay(){py(function(){(Be&6)!==0?Nt(tl,ny):o0()})}function ru(){if(va===0){var e=Al;e===0&&(e=ka,ka<<=1,(ka&261888)===0&&(ka=256)),va=e}return va}function d0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ki(""+e)}function m0(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function ly(e,t,n,s,c){if(t==="submit"&&n&&n.stateNode===c){var u=d0((c[De]||null).action),v=s.submitter;v&&(t=(t=v[De]||null)?d0(t.formAction):v.getAttribute("formAction"),t!==null&&(u=t,v=null));var A=new Ti("action","action",null,s,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(va!==0){var D=v?m0(c,v):new FormData(c);Ec(n,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(A.preventDefault(),D=v?m0(c,v):new FormData(c),Ec(n,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var ou=0;ou<Yo.length;ou++){var cu=Yo[ou],sy=cu.toLowerCase(),iy=cu[0].toUpperCase()+cu.slice(1);un(sy,"on"+iy)}un(Yd,"onAnimationEnd"),un(Xd,"onAnimationIteration"),un(Fd,"onAnimationStart"),un("dblclick","onDoubleClick"),un("focusin","onFocus"),un("focusout","onBlur"),un(Av,"onTransitionRun"),un(jv,"onTransitionStart"),un(Nv,"onTransitionCancel"),un(Qd,"onTransitionEnd"),ol("onMouseEnter",["mouseout","mouseover"]),ol("onMouseLeave",["mouseout","mouseover"]),ol("onPointerEnter",["pointerout","pointerover"]),ol("onPointerLeave",["pointerout","pointerover"]),Ma("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ma("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ma("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ma("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ma("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ma("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Us="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(" "),ry=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Us));function h0(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var s=e[n],c=s.event;s=s.listeners;e:{var u=void 0;if(t)for(var v=s.length-1;0<=v;v--){var A=s[v],D=A.instance,G=A.currentTarget;if(A=A.listener,D!==u&&c.isPropagationStopped())break e;u=A,c.currentTarget=G;try{u(c)}catch(I){Oi(I)}c.currentTarget=null,u=D}else for(v=0;v<s.length;v++){if(A=s[v],D=A.instance,G=A.currentTarget,A=A.listener,D!==u&&c.isPropagationStopped())break e;u=A,c.currentTarget=G;try{u(c)}catch(I){Oi(I)}c.currentTarget=null,u=D}}}}function Ee(e,t){var n=t[Ao];n===void 0&&(n=t[Ao]=new Set);var s=e+"__bubble";n.has(s)||(p0(t,e,2,!1),n.add(s))}function uu(e,t,n){var s=0;t&&(s|=4),p0(n,e,s,t)}var Sr="_reactListening"+Math.random().toString(36).slice(2);function fu(e){if(!e[Sr]){e[Sr]=!0,od.forEach(function(n){n!=="selectionchange"&&(ry.has(n)||uu(n,!1,e),uu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Sr]||(t[Sr]=!0,uu("selectionchange",!1,t))}}function p0(e,t,n,s){switch(Y0(t)){case 2:var c=Oy;break;case 8:c=By;break;default:c=Cu}n=c.bind(null,t,n,e),c=void 0,!Ro||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),s?c!==void 0?e.addEventListener(t,n,{capture:!0,passive:c}):e.addEventListener(t,n,!0):c!==void 0?e.addEventListener(t,n,{passive:c}):e.addEventListener(t,n,!1)}function du(e,t,n,s,c){var u=s;if((t&1)===0&&(t&2)===0&&s!==null)e:for(;;){if(s===null)return;var v=s.tag;if(v===3||v===4){var A=s.stateNode.containerInfo;if(A===c)break;if(v===4)for(v=s.return;v!==null;){var D=v.tag;if((D===3||D===4)&&v.stateNode.containerInfo===c)return;v=v.return}for(;A!==null;){if(v=sl(A),v===null)return;if(D=v.tag,D===5||D===6||D===26||D===27){s=u=v;continue e}A=A.parentNode}}s=s.return}bd(function(){var G=u,I=qo(n),ee=[];e:{var X=Kd.get(e);if(X!==void 0){var J=Ti,fe=e;switch(e){case"keypress":if(Mi(n)===0)break e;case"keydown":case"keyup":J=ev;break;case"focusin":fe="focus",J=Oo;break;case"focusout":fe="blur",J=Oo;break;case"beforeblur":case"afterblur":J=Oo;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=jd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=$g;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=av;break;case Yd:case Xd:case Fd:J=Xg;break;case Qd:J=sv;break;case"scroll":case"scrollend":J=Hg;break;case"wheel":J=rv;break;case"copy":case"cut":case"paste":J=Qg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=wd;break;case"toggle":case"beforetoggle":J=cv}var be=(t&4)!==0,Ge=!be&&(e==="scroll"||e==="scrollend"),B=be?X!==null?X+"Capture":null:X;be=[];for(var _=G,$;_!==null;){var W=_;if($=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||$===null||B===null||(W=rs(_,B),W!=null&&be.push(Hs(_,W,$))),Ge)break;_=_.return}0<be.length&&(X=new J(X,fe,null,n,I),ee.push({event:X,listeners:be}))}}if((t&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",J=e==="mouseout"||e==="pointerout",X&&n!==ko&&(fe=n.relatedTarget||n.fromElement)&&(sl(fe)||fe[Qt]))break e;if((J||X)&&(X=I.window===I?I:(X=I.ownerDocument)?X.defaultView||X.parentWindow:window,J?(fe=n.relatedTarget||n.toElement,J=G,fe=fe?sl(fe):null,fe!==null&&(Ge=d(fe),be=fe.tag,fe!==Ge||be!==5&&be!==27&&be!==6)&&(fe=null)):(J=null,fe=G),J!==fe)){if(be=jd,W="onMouseLeave",B="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(be=wd,W="onPointerLeave",B="onPointerEnter",_="pointer"),Ge=J==null?X:is(J),$=fe==null?X:is(fe),X=new be(W,_+"leave",J,n,I),X.target=Ge,X.relatedTarget=$,W=null,sl(I)===G&&(be=new be(B,_+"enter",fe,n,I),be.target=$,be.relatedTarget=Ge,W=be),Ge=W,J&&fe)t:{for(be=oy,B=J,_=fe,$=0,W=B;W;W=be(W))$++;W=0;for(var ve=_;ve;ve=be(ve))W++;for(;0<$-W;)B=be(B),$--;for(;0<W-$;)_=be(_),W--;for(;$--;){if(B===_||_!==null&&B===_.alternate){be=B;break t}B=be(B),_=be(_)}be=null}else be=null;J!==null&&x0(ee,X,J,be,!1),fe!==null&&Ge!==null&&x0(ee,Ge,fe,be,!0)}}e:{if(X=G?is(G):window,J=X.nodeName&&X.nodeName.toLowerCase(),J==="select"||J==="input"&&X.type==="file")var _e=Dd;else if(Rd(X))if(_d)_e=yv;else{_e=gv;var me=xv}else J=X.nodeName,!J||J.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?G&&Eo(G.elementType)&&(_e=Dd):_e=vv;if(_e&&(_e=_e(e,G))){Td(ee,_e,n,I);break e}me&&me(e,X,G),e==="focusout"&&G&&X.type==="number"&&G.memoizedProps.value!=null&&Co(X,"number",X.value)}switch(me=G?is(G):window,e){case"focusin":(Rd(me)||me.contentEditable==="true")&&(hl=me,Vo=G,ps=null);break;case"focusout":ps=Vo=hl=null;break;case"mousedown":$o=!0;break;case"contextmenu":case"mouseup":case"dragend":$o=!1,$d(ee,n,I);break;case"selectionchange":if(Sv)break;case"keydown":case"keyup":$d(ee,n,I)}var Ne;if(Lo)e:{switch(e){case"compositionstart":var qe="onCompositionStart";break e;case"compositionend":qe="onCompositionEnd";break e;case"compositionupdate":qe="onCompositionUpdate";break e}qe=void 0}else ml?qd(e,n)&&(qe="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(qe="onCompositionStart");qe&&(Cd&&n.locale!=="ko"&&(ml||qe!=="onCompositionStart"?qe==="onCompositionEnd"&&ml&&(Ne=Sd()):(na=I,To="value"in na?na.value:na.textContent,ml=!0)),me=Ar(G,qe),0<me.length&&(qe=new Nd(qe,e,null,n,I),ee.push({event:qe,listeners:me}),Ne?qe.data=Ne:(Ne=Md(n),Ne!==null&&(qe.data=Ne)))),(Ne=fv?dv(e,n):mv(e,n))&&(qe=Ar(G,"onBeforeInput"),0<qe.length&&(me=new Nd("onBeforeInput","beforeinput",null,n,I),ee.push({event:me,listeners:qe}),me.data=Ne)),ly(ee,e,G,n,I)}h0(ee,t)})}function Hs(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ar(e,t){for(var n=t+"Capture",s=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=rs(e,n),c!=null&&s.unshift(Hs(e,c,u)),c=rs(e,t),c!=null&&s.push(Hs(e,c,u))),e.tag===3)return s;e=e.return}return[]}function oy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function x0(e,t,n,s,c){for(var u=t._reactName,v=[];n!==null&&n!==s;){var A=n,D=A.alternate,G=A.stateNode;if(A=A.tag,D!==null&&D===s)break;A!==5&&A!==26&&A!==27||G===null||(D=G,c?(G=rs(n,u),G!=null&&v.unshift(Hs(n,G,D))):c||(G=rs(n,u),G!=null&&v.push(Hs(n,G,D)))),n=n.return}v.length!==0&&e.push({event:t,listeners:v})}var cy=/\r\n?/g,uy=/\u0000|\uFFFD/g;function g0(e){return(typeof e=="string"?e:""+e).replace(cy,`
|
||
`).replace(uy,"")}function v0(e,t){return t=g0(t),g0(e)===t}function $e(e,t,n,s,c,u){switch(n){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||ul(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&ul(e,""+s);break;case"className":Ci(e,"class",s);break;case"tabIndex":Ci(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":Ci(e,n,s);break;case"style":vd(e,s,u);break;case"data":if(t!=="object"){Ci(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=ki(""+s),e.setAttribute(n,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(n==="formAction"?(t!=="input"&&$e(e,t,"name",c.name,c,null),$e(e,t,"formEncType",c.formEncType,c,null),$e(e,t,"formMethod",c.formMethod,c,null),$e(e,t,"formTarget",c.formTarget,c,null)):($e(e,t,"encType",c.encType,c,null),$e(e,t,"method",c.method,c,null),$e(e,t,"target",c.target,c,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=ki(""+s),e.setAttribute(n,s);break;case"onClick":s!=null&&(e.onclick=Rn);break;case"onScroll":s!=null&&Ee("scroll",e);break;case"onScrollEnd":s!=null&&Ee("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}n=ki(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""+s):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":s===!0?e.setAttribute(n,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,s):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(n,s):e.removeAttribute(n);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(n):e.setAttribute(n,s);break;case"popover":Ee("beforetoggle",e),Ee("toggle",e),wi(e,"popover",s);break;case"xlinkActuate":Mn(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Mn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Mn(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Mn(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Mn(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Mn(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Mn(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":wi(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=zg.get(n)||n,wi(e,n,s))}}function mu(e,t,n,s,c,u){switch(n){case"style":vd(e,s,u);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(o(61));if(n=s.__html,n!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"children":typeof s=="string"?ul(e,s):(typeof s=="number"||typeof s=="bigint")&&ul(e,""+s);break;case"onScroll":s!=null&&Ee("scroll",e);break;case"onScrollEnd":s!=null&&Ee("scrollend",e);break;case"onClick":s!=null&&(e.onclick=Rn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!cd.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(c=n.endsWith("Capture"),t=n.slice(2,c?n.length-7:void 0),u=e[De]||null,u=u!=null?u[n]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof s=="function")){typeof u!="function"&&u!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,s,c);break e}n in e?e[n]=s:s===!0?e.setAttribute(n,""):wi(e,n,s)}}}function At(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ee("error",e),Ee("load",e);var s=!1,c=!1,u;for(u in n)if(n.hasOwnProperty(u)){var v=n[u];if(v!=null)switch(u){case"src":s=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:$e(e,t,u,v,n,null)}}c&&$e(e,t,"srcSet",n.srcSet,n,null),s&&$e(e,t,"src",n.src,n,null);return;case"input":Ee("invalid",e);var A=u=v=c=null,D=null,G=null;for(s in n)if(n.hasOwnProperty(s)){var I=n[s];if(I!=null)switch(s){case"name":c=I;break;case"type":v=I;break;case"checked":D=I;break;case"defaultChecked":G=I;break;case"value":u=I;break;case"defaultValue":A=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:$e(e,t,s,I,n,null)}}hd(e,u,A,D,G,v,c,!1);return;case"select":Ee("invalid",e),s=v=u=null;for(c in n)if(n.hasOwnProperty(c)&&(A=n[c],A!=null))switch(c){case"value":u=A;break;case"defaultValue":v=A;break;case"multiple":s=A;default:$e(e,t,c,A,n,null)}t=u,n=v,e.multiple=!!s,t!=null?cl(e,!!s,t,!1):n!=null&&cl(e,!!s,n,!0);return;case"textarea":Ee("invalid",e),u=c=s=null;for(v in n)if(n.hasOwnProperty(v)&&(A=n[v],A!=null))switch(v){case"value":s=A;break;case"defaultValue":c=A;break;case"children":u=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:$e(e,t,v,A,n,null)}xd(e,s,c,u);return;case"option":for(D in n)if(n.hasOwnProperty(D)&&(s=n[D],s!=null))switch(D){case"selected":e.selected=s&&typeof s!="function"&&typeof s!="symbol";break;default:$e(e,t,D,s,n,null)}return;case"dialog":Ee("beforetoggle",e),Ee("toggle",e),Ee("cancel",e),Ee("close",e);break;case"iframe":case"object":Ee("load",e);break;case"video":case"audio":for(s=0;s<Us.length;s++)Ee(Us[s],e);break;case"image":Ee("error",e),Ee("load",e);break;case"details":Ee("toggle",e);break;case"embed":case"source":case"link":Ee("error",e),Ee("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in n)if(n.hasOwnProperty(G)&&(s=n[G],s!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:$e(e,t,G,s,n,null)}return;default:if(Eo(t)){for(I in n)n.hasOwnProperty(I)&&(s=n[I],s!==void 0&&mu(e,t,I,s,n,void 0));return}}for(A in n)n.hasOwnProperty(A)&&(s=n[A],s!=null&&$e(e,t,A,s,n,null))}function fy(e,t,n,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,v=null,A=null,D=null,G=null,I=null;for(J in n){var ee=n[J];if(n.hasOwnProperty(J)&&ee!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":D=ee;default:s.hasOwnProperty(J)||$e(e,t,J,null,s,ee)}}for(var X in s){var J=s[X];if(ee=n[X],s.hasOwnProperty(X)&&(J!=null||ee!=null))switch(X){case"type":u=J;break;case"name":c=J;break;case"checked":G=J;break;case"defaultChecked":I=J;break;case"value":v=J;break;case"defaultValue":A=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(o(137,t));break;default:J!==ee&&$e(e,t,X,J,s,ee)}}wo(e,v,A,D,G,I,u,c);return;case"select":J=v=A=X=null;for(u in n)if(D=n[u],n.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":J=D;default:s.hasOwnProperty(u)||$e(e,t,u,null,s,D)}for(c in s)if(u=s[c],D=n[c],s.hasOwnProperty(c)&&(u!=null||D!=null))switch(c){case"value":X=u;break;case"defaultValue":A=u;break;case"multiple":v=u;default:u!==D&&$e(e,t,c,u,s,D)}t=A,n=v,s=J,X!=null?cl(e,!!n,X,!1):!!s!=!!n&&(t!=null?cl(e,!!n,t,!0):cl(e,!!n,n?[]:"",!1));return;case"textarea":J=X=null;for(A in n)if(c=n[A],n.hasOwnProperty(A)&&c!=null&&!s.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:$e(e,t,A,null,s,c)}for(v in s)if(c=s[v],u=n[v],s.hasOwnProperty(v)&&(c!=null||u!=null))switch(v){case"value":X=c;break;case"defaultValue":J=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&$e(e,t,v,c,s,u)}pd(e,X,J);return;case"option":for(var fe in n)if(X=n[fe],n.hasOwnProperty(fe)&&X!=null&&!s.hasOwnProperty(fe))switch(fe){case"selected":e.selected=!1;break;default:$e(e,t,fe,null,s,X)}for(D in s)if(X=s[D],J=n[D],s.hasOwnProperty(D)&&X!==J&&(X!=null||J!=null))switch(D){case"selected":e.selected=X&&typeof X!="function"&&typeof X!="symbol";break;default:$e(e,t,D,X,s,J)}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 be in n)X=n[be],n.hasOwnProperty(be)&&X!=null&&!s.hasOwnProperty(be)&&$e(e,t,be,null,s,X);for(G in s)if(X=s[G],J=n[G],s.hasOwnProperty(G)&&X!==J&&(X!=null||J!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(o(137,t));break;default:$e(e,t,G,X,s,J)}return;default:if(Eo(t)){for(var Ge in n)X=n[Ge],n.hasOwnProperty(Ge)&&X!==void 0&&!s.hasOwnProperty(Ge)&&mu(e,t,Ge,void 0,s,X);for(I in s)X=s[I],J=n[I],!s.hasOwnProperty(I)||X===J||X===void 0&&J===void 0||mu(e,t,I,X,s,J);return}}for(var B in n)X=n[B],n.hasOwnProperty(B)&&X!=null&&!s.hasOwnProperty(B)&&$e(e,t,B,null,s,X);for(ee in s)X=s[ee],J=n[ee],!s.hasOwnProperty(ee)||X===J||X==null&&J==null||$e(e,t,ee,X,s,J)}function y0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function dy(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),s=0;s<n.length;s++){var c=n[s],u=c.transferSize,v=c.initiatorType,A=c.duration;if(u&&A&&y0(v)){for(v=0,A=c.responseEnd,s+=1;s<n.length;s++){var D=n[s],G=D.startTime;if(G>A)break;var I=D.transferSize,ee=D.initiatorType;I&&y0(ee)&&(D=D.responseEnd,v+=I*(D<A?1:(A-G)/(D-G)))}if(--s,t+=8*(u+v)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var hu=null,pu=null;function jr(e){return e.nodeType===9?e:e.ownerDocument}function b0(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 S0(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 xu(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 gu=null;function my(){var e=window.event;return e&&e.type==="popstate"?e===gu?!1:(gu=e,!0):(gu=null,!1)}var A0=typeof setTimeout=="function"?setTimeout:void 0,hy=typeof clearTimeout=="function"?clearTimeout:void 0,j0=typeof Promise=="function"?Promise:void 0,py=typeof queueMicrotask=="function"?queueMicrotask:typeof j0<"u"?function(e){return j0.resolve(null).then(e).catch(xy)}:A0;function xy(e){setTimeout(function(){throw e})}function ya(e){return e==="head"}function N0(e,t){var n=t,s=0;do{var c=n.nextSibling;if(e.removeChild(n),c&&c.nodeType===8)if(n=c.data,n==="/$"||n==="/&"){if(s===0){e.removeChild(c),Vl(t);return}s--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")s++;else if(n==="html")Vs(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Vs(n);for(var u=n.firstChild;u;){var v=u.nextSibling,A=u.nodeName;u[ss]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&u.rel.toLowerCase()==="stylesheet"||n.removeChild(u),u=v}}else n==="body"&&Vs(e.ownerDocument.body);n=c}while(n);Vl(t)}function w0(e,t){var n=e;e=0;do{var s=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=s}while(n)}function vu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":vu(n),jo(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function gy(e,t,n,s){for(;e.nodeType===1;){var c=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[ss])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=nn(e.nextSibling),e===null)break}return null}function vy(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=nn(e.nextSibling),e===null))return null;return e}function C0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=nn(e.nextSibling),e===null))return null;return e}function yu(e){return e.data==="$?"||e.data==="$~"}function bu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function yy(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var s=function(){t(),n.removeEventListener("DOMContentLoaded",s)};n.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function nn(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 Su=null;function E0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return nn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function k0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function q0(e,t,n){switch(t=jr(n),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Vs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);jo(e)}var an=new Map,M0=new Set;function Nr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Qn=Q.d;Q.d={f:by,r:Sy,D:Ay,C:jy,L:Ny,m:wy,X:Ey,S:Cy,M:ky};function by(){var e=Qn.f(),t=pr();return e||t}function Sy(e){var t=il(e);t!==null&&t.tag===5&&t.type==="form"?Qm(t):Qn.r(e)}var zl=typeof document>"u"?null:document;function R0(e,t,n){var s=zl;if(s&&typeof t=="string"&&t){var c=Zt(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof n=="string"&&(c+='[crossorigin="'+n+'"]'),M0.has(c)||(M0.add(c),e={rel:e,crossOrigin:n,href:t},s.querySelector(c)===null&&(t=s.createElement("link"),At(t,"link",e),xt(t),s.head.appendChild(t)))}}function Ay(e){Qn.D(e),R0("dns-prefetch",e,null)}function jy(e,t){Qn.C(e,t),R0("preconnect",e,t)}function Ny(e,t,n){Qn.L(e,t,n);var s=zl;if(s&&e&&t){var c='link[rel="preload"][as="'+Zt(t)+'"]';t==="image"&&n&&n.imageSrcSet?(c+='[imagesrcset="'+Zt(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(c+='[imagesizes="'+Zt(n.imageSizes)+'"]')):c+='[href="'+Zt(e)+'"]';var u=c;switch(t){case"style":u=Ul(e);break;case"script":u=Hl(e)}an.has(u)||(e=y({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),an.set(u,e),s.querySelector(c)!==null||t==="style"&&s.querySelector($s(u))||t==="script"&&s.querySelector(Gs(u))||(t=s.createElement("link"),At(t,"link",e),xt(t),s.head.appendChild(t)))}}function wy(e,t){Qn.m(e,t);var n=zl;if(n&&e){var s=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+Zt(s)+'"][href="'+Zt(e)+'"]',u=c;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Hl(e)}if(!an.has(u)&&(e=y({rel:"modulepreload",href:e},t),an.set(u,e),n.querySelector(c)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Gs(u)))return}s=n.createElement("link"),At(s,"link",e),xt(s),n.head.appendChild(s)}}}function Cy(e,t,n){Qn.S(e,t,n);var s=zl;if(s&&e){var c=rl(s).hoistableStyles,u=Ul(e);t=t||"default";var v=c.get(u);if(!v){var A={loading:0,preload:null};if(v=s.querySelector($s(u)))A.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},n),(n=an.get(u))&&Au(e,n);var D=v=s.createElement("link");xt(D),At(D,"link",e),D._p=new Promise(function(G,I){D.onload=G,D.onerror=I}),D.addEventListener("load",function(){A.loading|=1}),D.addEventListener("error",function(){A.loading|=2}),A.loading|=4,wr(v,t,s)}v={type:"stylesheet",instance:v,count:1,state:A},c.set(u,v)}}}function Ey(e,t){Qn.X(e,t);var n=zl;if(n&&e){var s=rl(n).hoistableScripts,c=Hl(e),u=s.get(c);u||(u=n.querySelector(Gs(c)),u||(e=y({src:e,async:!0},t),(t=an.get(c))&&ju(e,t),u=n.createElement("script"),xt(u),At(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function ky(e,t){Qn.M(e,t);var n=zl;if(n&&e){var s=rl(n).hoistableScripts,c=Hl(e),u=s.get(c);u||(u=n.querySelector(Gs(c)),u||(e=y({src:e,async:!0,type:"module"},t),(t=an.get(c))&&ju(e,t),u=n.createElement("script"),xt(u),At(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},s.set(c,u))}}function T0(e,t,n,s){var c=(c=re.current)?Nr(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Ul(n.href),n=rl(c).hoistableStyles,s=n.get(t),s||(s={type:"style",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Ul(n.href);var u=rl(c).hoistableStyles,v=u.get(e);if(v||(c=c.ownerDocument||c,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,v),(u=c.querySelector($s(e)))&&!u._p&&(v.instance=u,v.state.loading=5),an.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},an.set(e,n),u||qy(c,e,n,v.state))),t&&s===null)throw Error(o(528,""));return v}if(t&&s!==null)throw Error(o(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Hl(n),n=rl(c).hoistableScripts,s=n.get(t),s||(s={type:"script",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ul(e){return'href="'+Zt(e)+'"'}function $s(e){return'link[rel="stylesheet"]['+e+"]"}function D0(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function qy(e,t,n,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),At(t,"link",n),xt(t),e.head.appendChild(t))}function Hl(e){return'[src="'+Zt(e)+'"]'}function Gs(e){return"script[async]"+e}function _0(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+Zt(n.href)+'"]');if(s)return t.instance=s,xt(s),s;var c=y({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),xt(s),At(s,"style",c),wr(s,n.precedence,e),t.instance=s;case"stylesheet":c=Ul(n.href);var u=e.querySelector($s(c));if(u)return t.state.loading|=4,t.instance=u,xt(u),u;s=D0(n),(c=an.get(c))&&Au(s,c),u=(e.ownerDocument||e).createElement("link"),xt(u);var v=u;return v._p=new Promise(function(A,D){v.onload=A,v.onerror=D}),At(u,"link",s),t.state.loading|=4,wr(u,n.precedence,e),t.instance=u;case"script":return u=Hl(n.src),(c=e.querySelector(Gs(u)))?(t.instance=c,xt(c),c):(s=n,(c=an.get(u))&&(s=y({},n),ju(s,c)),e=e.ownerDocument||e,c=e.createElement("script"),xt(c),At(c,"link",s),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,wr(s,n.precedence,e));return t.instance}function wr(e,t,n){for(var s=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=s.length?s[s.length-1]:null,u=c,v=0;v<s.length;v++){var A=s[v];if(A.dataset.precedence===t)u=A;else if(u!==c)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Au(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function ju(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Cr=null;function O0(e,t,n){if(Cr===null){var s=new Map,c=Cr=new Map;c.set(n,s)}else c=Cr,s=c.get(n),s||(s=new Map,c.set(n,s));if(s.has(e))return s;for(s.set(e,null),n=n.getElementsByTagName(e),c=0;c<n.length;c++){var u=n[c];if(!(u[ss]||u[tt]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var v=u.getAttribute(t)||"";v=e+v;var A=s.get(v);A?A.push(u):s.set(v,[u])}}return s}function B0(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function My(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function L0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Ry(e,t,n,s){if(n.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var c=Ul(s.href),u=t.querySelector($s(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Er.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=u,xt(u);return}u=t.ownerDocument||t,s=D0(s),(c=an.get(c))&&Au(s,c),u=u.createElement("link"),xt(u);var v=u;v._p=new Promise(function(A,D){v.onload=A,v.onerror=D}),At(u,"link",s),n.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=Er.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var Nu=0;function Ty(e,t){return e.stylesheets&&e.count===0&&qr(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var s=setTimeout(function(){if(e.stylesheets&&qr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Nu===0&&(Nu=62500*dy());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&qr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Nu?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(c)}}:null}function Er(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)qr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var kr=null;function qr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,kr=new Map,t.forEach(Dy,e),kr=null,Er.call(e))}function Dy(e,t){if(!(t.state.loading&4)){var n=kr.get(e);if(n)var s=n.get(null);else{n=new Map,kr.set(e,n);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var v=c[u];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(n.set(v.dataset.precedence,v),s=v)}s&&n.set(null,s)}c=t.instance,v=c.getAttribute("data-precedence"),u=n.get(v)||s,u===s&&n.set(null,c),n.set(v,c),this.count++,s=Er.bind(this),c.addEventListener("load",s),c.addEventListener("error",s),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Ys={$$typeof:M,Provider:null,Consumer:null,_currentValue:P,_currentValue2:P,_threadCount:0};function _y(e,t,n,s,c,u,v,A,D){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ls(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ls(0),this.hiddenUpdates=ls(null),this.identifierPrefix=s,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function z0(e,t,n,s,c,u,v,A,D,G,I,ee){return e=new _y(e,t,n,v,D,G,I,ee,A),t=1,u===!0&&(t|=24),u=Lt(3,null,null,t),e.current=u,u.stateNode=e,t=ac(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:s,isDehydrated:n,cache:t},rc(u),e}function U0(e){return e?(e=gl,e):gl}function H0(e,t,n,s,c,u){c=U0(c),s.context===null?s.context=c:s.pendingContext=c,s=oa(t),s.payload={element:n},u=u===void 0?null:u,u!==null&&(s.callback=u),n=ca(e,s,t),n!==null&&(_t(n,e,t),As(n,e,t))}function V0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function wu(e,t){V0(e,t),(e=e.alternate)&&V0(e,t)}function $0(e){if(e.tag===13||e.tag===31){var t=_a(e,67108864);t!==null&&_t(t,e,67108864),wu(e,67108864)}}function G0(e){if(e.tag===13||e.tag===31){var t=$t();t=Fe(t);var n=_a(e,t);n!==null&&_t(n,e,t),wu(e,t)}}var Mr=!0;function Oy(e,t,n,s){var c=R.T;R.T=null;var u=Q.p;try{Q.p=2,Cu(e,t,n,s)}finally{Q.p=u,R.T=c}}function By(e,t,n,s){var c=R.T;R.T=null;var u=Q.p;try{Q.p=8,Cu(e,t,n,s)}finally{Q.p=u,R.T=c}}function Cu(e,t,n,s){if(Mr){var c=Eu(s);if(c===null)du(e,t,s,Rr,n),X0(e,s);else if(zy(c,e,t,n,s))s.stopPropagation();else if(X0(e,s),t&4&&-1<Ly.indexOf(e)){for(;c!==null;){var u=il(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var v=Ot(u.pendingLanes);if(v!==0){var A=u;for(A.pendingLanes|=2,A.entangledLanes|=2;v;){var D=1<<31-rt(v);A.entanglements[1]|=D,v&=~D}Sn(u),(Be&6)===0&&(mr=mt()+500,zs(0))}}break;case 31:case 13:A=_a(u,2),A!==null&&_t(A,u,2),pr(),wu(u,2)}if(u=Eu(s),u===null&&du(e,t,s,Rr,n),u===c)break;c=u}c!==null&&s.stopPropagation()}else du(e,t,s,null,n)}}function Eu(e){return e=qo(e),ku(e)}var Rr=null;function ku(e){if(Rr=null,e=sl(e),e!==null){var t=d(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=h(t),e!==null)return e;e=null}else if(n===31){if(e=x(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Rr=e,null}function Y0(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(el()){case tl:return 2;case on:return 8;case Ea:case Si:return 32;case nl:return 268435456;default:return 32}default:return 32}}var qu=!1,ba=null,Sa=null,Aa=null,Xs=new Map,Fs=new Map,ja=[],Ly="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 X0(e,t){switch(e){case"focusin":case"focusout":ba=null;break;case"dragenter":case"dragleave":Sa=null;break;case"mouseover":case"mouseout":Aa=null;break;case"pointerover":case"pointerout":Xs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fs.delete(t.pointerId)}}function Qs(e,t,n,s,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:n,eventSystemFlags:s,nativeEvent:u,targetContainers:[c]},t!==null&&(t=il(t),t!==null&&$0(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function zy(e,t,n,s,c){switch(t){case"focusin":return ba=Qs(ba,e,t,n,s,c),!0;case"dragenter":return Sa=Qs(Sa,e,t,n,s,c),!0;case"mouseover":return Aa=Qs(Aa,e,t,n,s,c),!0;case"pointerover":var u=c.pointerId;return Xs.set(u,Qs(Xs.get(u)||null,e,t,n,s,c)),!0;case"gotpointercapture":return u=c.pointerId,Fs.set(u,Qs(Fs.get(u)||null,e,t,n,s,c)),!0}return!1}function F0(e){var t=sl(e.target);if(t!==null){var n=d(t);if(n!==null){if(t=n.tag,t===13){if(t=h(n),t!==null){e.blockedOn=t,vt(e.priority,function(){G0(n)});return}}else if(t===31){if(t=x(n),t!==null){e.blockedOn=t,vt(e.priority,function(){G0(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Tr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Eu(e.nativeEvent);if(n===null){n=e.nativeEvent;var s=new n.constructor(n.type,n);ko=s,n.target.dispatchEvent(s),ko=null}else return t=il(n),t!==null&&$0(t),e.blockedOn=n,!1;t.shift()}return!0}function Q0(e,t,n){Tr(e)&&n.delete(t)}function Uy(){qu=!1,ba!==null&&Tr(ba)&&(ba=null),Sa!==null&&Tr(Sa)&&(Sa=null),Aa!==null&&Tr(Aa)&&(Aa=null),Xs.forEach(Q0),Fs.forEach(Q0)}function Dr(e,t){e.blockedOn===t&&(e.blockedOn=null,qu||(qu=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,Uy)))}var _r=null;function K0(e){_r!==e&&(_r=e,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){_r===e&&(_r=null);for(var t=0;t<e.length;t+=3){var n=e[t],s=e[t+1],c=e[t+2];if(typeof s!="function"){if(ku(s||n)===null)continue;break}var u=il(n);u!==null&&(e.splice(t,3),t-=3,Ec(u,{pending:!0,data:c,method:n.method,action:s},s,c))}}))}function Vl(e){function t(D){return Dr(D,e)}ba!==null&&Dr(ba,e),Sa!==null&&Dr(Sa,e),Aa!==null&&Dr(Aa,e),Xs.forEach(t),Fs.forEach(t);for(var n=0;n<ja.length;n++){var s=ja[n];s.blockedOn===e&&(s.blockedOn=null)}for(;0<ja.length&&(n=ja[0],n.blockedOn===null);)F0(n),n.blockedOn===null&&ja.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(s=0;s<n.length;s+=3){var c=n[s],u=n[s+1],v=c[De]||null;if(typeof u=="function")v||K0(n);else if(v){var A=null;if(u&&u.hasAttribute("formAction")){if(c=u,v=u[De]||null)A=v.formAction;else if(ku(c)!==null)continue}else A=v.action;typeof A=="function"?n[s+1]=A:(n.splice(s,3),s-=3),K0(n)}}}function Z0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(v){return c=v})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),s||setTimeout(n,20)}function n(){if(!s&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var s=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Mu(e){this._internalRoot=e}Or.prototype.render=Mu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current,s=$t();H0(n,s,e,t,null,null)},Or.prototype.unmount=Mu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;H0(e.current,2,null,e,null,null),pr(),t[Qt]=null}};function Or(e){this._internalRoot=e}Or.prototype.unstable_scheduleHydration=function(e){if(e){var t=Le();e={blockedOn:null,target:e,priority:t};for(var n=0;n<ja.length&&t!==0&&t<ja[n].priority;n++);ja.splice(n,0,e),n===0&&F0(e)}};var J0=l.version;if(J0!=="19.2.0")throw Error(o(527,J0,"19.2.0"));Q.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?b(e):null,e=e===null?null:e.stateNode,e};var Hy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Br=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Br.isDisabled&&Br.supportsFiber)try{cn=Br.inject(Hy),pt=Br}catch{}}return Zs.createRoot=function(e,t){if(!f(e))throw Error(o(299));var n=!1,s="",c=ah,u=lh,v=sh;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=z0(e,1,!1,null,null,n,s,null,c,u,v,Z0),e[Qt]=t.current,fu(e),new Mu(t)},Zs.hydrateRoot=function(e,t,n){if(!f(e))throw Error(o(299));var s=!1,c="",u=ah,v=lh,A=sh,D=null;return n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(v=n.onCaughtError),n.onRecoverableError!==void 0&&(A=n.onRecoverableError),n.formState!==void 0&&(D=n.formState)),t=z0(e,1,!0,t,n??null,s,c,D,u,v,A,Z0),t.context=U0(null),n=t.current,s=$t(),s=Fe(s),c=oa(s),c.callback=null,ca(n,c,s),n=s,t.current.lanes=n,qa(t,n),Sn(t),e[Qt]=t.current,fu(e),new Or(t)},Zs.version="19.2.0",Zs}var ip;function Iy(){if(ip)return Du.exports;ip=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Du.exports=Jy(),Du.exports}var Wy=Iy();var rp="popstate";function Py(a={}){function l(o,f){let{pathname:d,search:h,hash:x}=o.location;return cf("",{pathname:d,search:h,hash:x},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:ri(f)}return tb(l,i,null,a)}function Pe(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function pn(a,l){if(!a){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function eb(){return Math.random().toString(36).substring(2,10)}function op(a,l){return{usr:a.state,key:a.key,idx:l}}function cf(a,l,i=null,o){return{pathname:typeof a=="string"?a:a.pathname,search:"",hash:"",...typeof l=="string"?Pl(l):l,state:i,key:l&&l.key||o||eb()}}function ri({pathname:a="/",search:l="",hash:i=""}){return l&&l!=="?"&&(a+=l.charAt(0)==="?"?l:"?"+l),i&&i!=="#"&&(a+=i.charAt(0)==="#"?i:"#"+i),a}function Pl(a){let l={};if(a){let i=a.indexOf("#");i>=0&&(l.hash=a.substring(i),a=a.substring(0,i));let o=a.indexOf("?");o>=0&&(l.search=a.substring(o),a=a.substring(0,o)),a&&(l.pathname=a)}return l}function tb(a,l,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,x="POP",p=null,g=b();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function b(){return(h.state||{idx:null}).idx}function y(){x="POP";let j=b(),k=j==null?null:j-g;g=j,p&&p({action:x,location:w.location,delta:k})}function N(j,k){x="PUSH";let S=cf(w.location,j,k);g=b()+1;let M=op(S,g),T=w.createHref(S);try{h.pushState(M,"",T)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;f.location.assign(T)}d&&p&&p({action:x,location:w.location,delta:1})}function q(j,k){x="REPLACE";let S=cf(w.location,j,k);g=b();let M=op(S,g),T=w.createHref(S);h.replaceState(M,"",T),d&&p&&p({action:x,location:w.location,delta:0})}function C(j){return nb(j)}let w={get action(){return x},get location(){return a(f,h)},listen(j){if(p)throw new Error("A history only accepts one active listener");return f.addEventListener(rp,y),p=j,()=>{f.removeEventListener(rp,y),p=null}},createHref(j){return l(f,j)},createURL:C,encodeLocation(j){let k=C(j);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:N,replace:q,go(j){return h.go(j)}};return w}function nb(a,l=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),Pe(i,"No window.location.(origin|href) available to create URL");let o=typeof a=="string"?a:ri(a);return o=o.replace(/ $/,"%20"),!l&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function lx(a,l,i="/"){return ab(a,l,i,!1)}function ab(a,l,i,o){let f=typeof l=="string"?Pl(l):l,d=Pn(f.pathname||"/",i);if(d==null)return null;let h=sx(a);lb(h);let x=null;for(let p=0;x==null&&p<h.length;++p){let g=pb(d);x=mb(h[p],g,o)}return x}function sx(a,l=[],i=[],o="",f=!1){let d=(h,x,p=f,g)=>{let b={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:x,route:h};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(o)&&p)return;Pe(b.relativePath.startsWith(o),`Absolute route path "${b.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(o.length)}let y=Wn([o,b.relativePath]),N=i.concat(b);h.children&&h.children.length>0&&(Pe(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),sx(h.children,l,N,y,p)),!(h.path==null&&!h.index)&&l.push({path:y,score:fb(y,h.index),routesMeta:N})};return a.forEach((h,x)=>{if(h.path===""||!h.path?.includes("?"))d(h,x);else for(let p of ix(h.path))d(h,x,!0,p)}),l}function ix(a){let l=a.split("/");if(l.length===0)return[];let[i,...o]=l,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=ix(o.join("/")),x=[];return x.push(...h.map(p=>p===""?d:[d,p].join("/"))),f&&x.push(...h),x.map(p=>a.startsWith("/")&&p===""?"/":p)}function lb(a){a.sort((l,i)=>l.score!==i.score?i.score-l.score:db(l.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var sb=/^:[\w-]+$/,ib=3,rb=2,ob=1,cb=10,ub=-2,cp=a=>a==="*";function fb(a,l){let i=a.split("/"),o=i.length;return i.some(cp)&&(o+=ub),l&&(o+=rb),i.filter(f=>!cp(f)).reduce((f,d)=>f+(sb.test(d)?ib:d===""?ob:cb),o)}function db(a,l){return a.length===l.length&&a.slice(0,-1).every((o,f)=>o===l[f])?a[a.length-1]-l[l.length-1]:0}function mb(a,l,i=!1){let{routesMeta:o}=a,f={},d="/",h=[];for(let x=0;x<o.length;++x){let p=o[x],g=x===o.length-1,b=d==="/"?l:l.slice(d.length)||"/",y=eo({path:p.relativePath,caseSensitive:p.caseSensitive,end:g},b),N=p.route;if(!y&&g&&i&&!o[o.length-1].route.index&&(y=eo({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},b)),!y)return null;Object.assign(f,y.params),h.push({params:f,pathname:Wn([d,y.pathname]),pathnameBase:bb(Wn([d,y.pathnameBase])),route:N}),y.pathnameBase!=="/"&&(d=Wn([d,y.pathnameBase]))}return h}function eo(a,l){typeof a=="string"&&(a={path:a,caseSensitive:!1,end:!0});let[i,o]=hb(a.path,a.caseSensitive,a.end),f=l.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),x=f.slice(1);return{params:o.reduce((g,{paramName:b,isOptional:y},N)=>{if(b==="*"){let C=x[N]||"";h=d.slice(0,d.length-C.length).replace(/(.)\/+$/,"$1")}const q=x[N];return y&&!q?g[b]=void 0:g[b]=(q||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:a}}function hb(a,l=!1,i=!0){pn(a==="*"||!a.endsWith("*")||a.endsWith("/*"),`Route path "${a}" will be treated as if it were "${a.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${a.replace(/\*$/,"/*")}".`);let o=[],f="^"+a.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,x,p)=>(o.push({paramName:x,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return a.endsWith("*")?(o.push({paramName:"*"}),f+=a==="*"||a==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":a!==""&&a!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,l?void 0:"i"),o]}function pb(a){try{return a.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return pn(!1,`The URL path "${a}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),a}}function Pn(a,l){if(l==="/")return a;if(!a.toLowerCase().startsWith(l.toLowerCase()))return null;let i=l.endsWith("/")?l.length-1:l.length,o=a.charAt(i);return o&&o!=="/"?null:a.slice(i)||"/"}var xb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gb=a=>xb.test(a);function vb(a,l="/"){let{pathname:i,search:o="",hash:f=""}=typeof a=="string"?Pl(a):a,d;if(i)if(gb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),pn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=up(i.substring(1),"/"):d=up(i,l)}else d=l;return{pathname:d,search:Sb(o),hash:Ab(f)}}function up(a,l){let i=l.replace(/\/+$/,"").split("/");return a.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Lu(a,l,i,o){return`Cannot include a '${a}' character in a manually specified \`to.${l}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function yb(a){return a.filter((l,i)=>i===0||l.route.path&&l.route.path.length>0)}function rx(a){let l=yb(a);return l.map((i,o)=>o===l.length-1?i.pathname:i.pathnameBase)}function ox(a,l,i,o=!1){let f;typeof a=="string"?f=Pl(a):(f={...a},Pe(!f.pathname||!f.pathname.includes("?"),Lu("?","pathname","search",f)),Pe(!f.pathname||!f.pathname.includes("#"),Lu("#","pathname","hash",f)),Pe(!f.search||!f.search.includes("#"),Lu("#","search","hash",f)));let d=a===""||f.pathname==="",h=d?"/":f.pathname,x;if(h==null)x=i;else{let y=l.length-1;if(!o&&h.startsWith("..")){let N=h.split("/");for(;N[0]==="..";)N.shift(),y-=1;f.pathname=N.join("/")}x=y>=0?l[y]:"/"}let p=vb(f,x),g=h&&h!=="/"&&h.endsWith("/"),b=(d||h===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(g||b)&&(p.pathname+="/"),p}var Wn=a=>a.join("/").replace(/\/\/+/g,"/"),bb=a=>a.replace(/\/+$/,"").replace(/^\/*/,"/"),Sb=a=>!a||a==="?"?"":a.startsWith("?")?a:"?"+a,Ab=a=>!a||a==="#"?"":a.startsWith("#")?a:"#"+a;function jb(a){return a!=null&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.internal=="boolean"&&"data"in a}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var cx=["POST","PUT","PATCH","DELETE"];new Set(cx);var Nb=["GET",...cx];new Set(Nb);var es=m.createContext(null);es.displayName="DataRouter";var ro=m.createContext(null);ro.displayName="DataRouterState";m.createContext(!1);var ux=m.createContext({isTransitioning:!1});ux.displayName="ViewTransition";var wb=m.createContext(new Map);wb.displayName="Fetchers";var Cb=m.createContext(null);Cb.displayName="Await";var Cn=m.createContext(null);Cn.displayName="Navigation";var xi=m.createContext(null);xi.displayName="Location";var ea=m.createContext({outlet:null,matches:[],isDataRoute:!1});ea.displayName="Route";var kf=m.createContext(null);kf.displayName="RouteError";function Eb(a,{relative:l}={}){Pe(gi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(Cn),{hash:f,pathname:d,search:h}=vi(a,{relative:l}),x=d;return i!=="/"&&(x=d==="/"?i:Wn([i,d])),o.createHref({pathname:x,search:h,hash:f})}function gi(){return m.useContext(xi)!=null}function Pa(){return Pe(gi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(xi).location}var fx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function dx(a){m.useContext(Cn).static||m.useLayoutEffect(a)}function kb(){let{isDataRoute:a}=m.useContext(ea);return a?Vb():qb()}function qb(){Pe(gi(),"useNavigate() may be used only in the context of a <Router> component.");let a=m.useContext(es),{basename:l,navigator:i}=m.useContext(Cn),{matches:o}=m.useContext(ea),{pathname:f}=Pa(),d=JSON.stringify(rx(o)),h=m.useRef(!1);return dx(()=>{h.current=!0}),m.useCallback((p,g={})=>{if(pn(h.current,fx),!h.current)return;if(typeof p=="number"){i.go(p);return}let b=ox(p,JSON.parse(d),f,g.relative==="path");a==null&&l!=="/"&&(b.pathname=b.pathname==="/"?l:Wn([l,b.pathname])),(g.replace?i.replace:i.push)(b,g.state,g)},[l,i,d,f,a])}m.createContext(null);function vi(a,{relative:l}={}){let{matches:i}=m.useContext(ea),{pathname:o}=Pa(),f=JSON.stringify(rx(i));return m.useMemo(()=>ox(a,JSON.parse(f),o,l==="path"),[a,f,o,l])}function Mb(a,l){return mx(a,l)}function mx(a,l,i,o,f){Pe(gi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(Cn),{matches:h}=m.useContext(ea),x=h[h.length-1],p=x?x.params:{},g=x?x.pathname:"/",b=x?x.pathnameBase:"/",y=x&&x.route;{let S=y&&y.path||"";hx(g,!y||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${S}">) 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="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let N=Pa(),q;if(l){let S=typeof l=="string"?Pl(l):l;Pe(b==="/"||S.pathname?.startsWith(b),`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 "${b}" but pathname "${S.pathname}" was given in the \`location\` prop.`),q=S}else q=N;let C=q.pathname||"/",w=C;if(b!=="/"){let S=b.replace(/^\//,"").split("/");w="/"+C.replace(/^\//,"").split("/").slice(S.length).join("/")}let j=lx(a,{pathname:w});pn(y||j!=null,`No routes matched location "${q.pathname}${q.search}${q.hash}" `),pn(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${q.pathname}${q.search}${q.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let k=Ob(j&&j.map(S=>Object.assign({},S,{params:Object.assign({},p,S.params),pathname:Wn([b,d.encodeLocation?d.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?b:Wn([b,d.encodeLocation?d.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),h,i,o,f);return l&&k?m.createElement(xi.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...q},navigationType:"POP"}},k):k}function Rb(){let a=Hb(),l=jb(a)?`${a.status} ${a.statusText}`:a instanceof Error?a.message:JSON.stringify(a),i=a instanceof Error?a.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",a),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},l),i?m.createElement("pre",{style:f},i):null,h)}var Tb=m.createElement(Rb,null),Db=class extends m.Component{constructor(a){super(a),this.state={location:a.location,revalidation:a.revalidation,error:a.error}}static getDerivedStateFromError(a){return{error:a}}static getDerivedStateFromProps(a,l){return l.location!==a.location||l.revalidation!=="idle"&&a.revalidation==="idle"?{error:a.error,location:a.location,revalidation:a.revalidation}:{error:a.error!==void 0?a.error:l.error,location:l.location,revalidation:a.revalidation||l.revalidation}}componentDidCatch(a,l){this.props.onError?this.props.onError(a,l):console.error("React Router caught the following error during render",a)}render(){return this.state.error!==void 0?m.createElement(ea.Provider,{value:this.props.routeContext},m.createElement(kf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function _b({routeContext:a,match:l,children:i}){let o=m.useContext(es);return o&&o.static&&o.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=l.route.id),m.createElement(ea.Provider,{value:a},i)}function Ob(a,l=[],i=null,o=null,f=null){if(a==null){if(!i)return null;if(i.errors)a=i.matches;else if(l.length===0&&!i.initialized&&i.matches.length>0)a=i.matches;else return null}let d=a,h=i?.errors;if(h!=null){let b=d.findIndex(y=>y.route.id&&h?.[y.route.id]!==void 0);Pe(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,b+1))}let x=!1,p=-1;if(i)for(let b=0;b<d.length;b++){let y=d[b];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(p=b),y.route.id){let{loaderData:N,errors:q}=i,C=y.route.loader&&!N.hasOwnProperty(y.route.id)&&(!q||q[y.route.id]===void 0);if(y.route.lazy||C){x=!0,p>=0?d=d.slice(0,p+1):d=[d[0]];break}}}let g=i&&o?(b,y)=>{o(b,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:y})}:void 0;return d.reduceRight((b,y,N)=>{let q,C=!1,w=null,j=null;i&&(q=h&&y.route.id?h[y.route.id]:void 0,w=y.route.errorElement||Tb,x&&(p<0&&N===0?(hx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,j=null):p===N&&(C=!0,j=y.route.hydrateFallbackElement||null)));let k=l.concat(d.slice(0,N+1)),S=()=>{let M;return q?M=w:C?M=j:y.route.Component?M=m.createElement(y.route.Component,null):y.route.element?M=y.route.element:M=b,m.createElement(_b,{match:y,routeContext:{outlet:b,matches:k,isDataRoute:i!=null},children:M})};return i&&(y.route.ErrorBoundary||y.route.errorElement||N===0)?m.createElement(Db,{location:i.location,revalidation:i.revalidation,component:w,error:q,children:S(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:g}):S()},null)}function qf(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bb(a){let l=m.useContext(es);return Pe(l,qf(a)),l}function Lb(a){let l=m.useContext(ro);return Pe(l,qf(a)),l}function zb(a){let l=m.useContext(ea);return Pe(l,qf(a)),l}function Mf(a){let l=zb(a),i=l.matches[l.matches.length-1];return Pe(i.route.id,`${a} can only be used on routes that contain a unique "id"`),i.route.id}function Ub(){return Mf("useRouteId")}function Hb(){let a=m.useContext(kf),l=Lb("useRouteError"),i=Mf("useRouteError");return a!==void 0?a:l.errors?.[i]}function Vb(){let{router:a}=Bb("useNavigate"),l=Mf("useNavigate"),i=m.useRef(!1);return dx(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{pn(i.current,fx),i.current&&(typeof f=="number"?a.navigate(f):await a.navigate(f,{fromRouteId:l,...d}))},[a,l])}var fp={};function hx(a,l,i){!l&&!fp[a]&&(fp[a]=!0,pn(!1,i))}m.memo($b);function $b({routes:a,future:l,state:i,unstable_onError:o}){return mx(a,void 0,i,o,l)}function Gr(a){Pe(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Gb({basename:a="/",children:l=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){Pe(!gi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=a.replace(/^\/*/,"/"),x=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=Pl(i));let{pathname:p="/",search:g="",hash:b="",state:y=null,key:N="default"}=i,q=m.useMemo(()=>{let C=Pn(p,h);return C==null?null:{location:{pathname:C,search:g,hash:b,state:y,key:N},navigationType:o}},[h,p,g,b,y,N,o]);return pn(q!=null,`<Router basename="${h}"> is not able to match the URL "${p}${g}${b}" because it does not start with the basename, so the <Router> won't render anything.`),q==null?null:m.createElement(Cn.Provider,{value:x},m.createElement(xi.Provider,{children:l,value:q}))}function Yb({children:a,location:l}){return Mb(uf(a),l)}function uf(a,l=[]){let i=[];return m.Children.forEach(a,(o,f)=>{if(!m.isValidElement(o))return;let d=[...l,f];if(o.type===m.Fragment){i.push.apply(i,uf(o.props.children,d));return}Pe(o.type===Gr,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Pe(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=uf(o.props.children,d)),i.push(h)}),i}var Yr="get",Xr="application/x-www-form-urlencoded";function oo(a){return a!=null&&typeof a.tagName=="string"}function Xb(a){return oo(a)&&a.tagName.toLowerCase()==="button"}function Fb(a){return oo(a)&&a.tagName.toLowerCase()==="form"}function Qb(a){return oo(a)&&a.tagName.toLowerCase()==="input"}function Kb(a){return!!(a.metaKey||a.altKey||a.ctrlKey||a.shiftKey)}function Zb(a,l){return a.button===0&&(!l||l==="_self")&&!Kb(a)}var Lr=null;function Jb(){if(Lr===null)try{new FormData(document.createElement("form"),0),Lr=!1}catch{Lr=!0}return Lr}var Ib=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function zu(a){return a!=null&&!Ib.has(a)?(pn(!1,`"${a}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Xr}"`),null):a}function Wb(a,l){let i,o,f,d,h;if(Fb(a)){let x=a.getAttribute("action");o=x?Pn(x,l):null,i=a.getAttribute("method")||Yr,f=zu(a.getAttribute("enctype"))||Xr,d=new FormData(a)}else if(Xb(a)||Qb(a)&&(a.type==="submit"||a.type==="image")){let x=a.form;if(x==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=a.getAttribute("formaction")||x.getAttribute("action");if(o=p?Pn(p,l):null,i=a.getAttribute("formmethod")||x.getAttribute("method")||Yr,f=zu(a.getAttribute("formenctype"))||zu(x.getAttribute("enctype"))||Xr,d=new FormData(x,a),!Jb()){let{name:g,type:b,value:y}=a;if(b==="image"){let N=g?`${g}.`:"";d.append(`${N}x`,"0"),d.append(`${N}y`,"0")}else g&&d.append(g,y)}}else{if(oo(a))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=Yr,o=null,f=Xr,h=a}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Rf(a,l){if(a===!1||a===null||typeof a>"u")throw new Error(l)}function Pb(a,l,i){let o=typeof a=="string"?new URL(a,typeof window>"u"?"server://singlefetch/":window.location.origin):a;return o.pathname==="/"?o.pathname=`_root.${i}`:l&&Pn(o.pathname,l)==="/"?o.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function e1(a,l){if(a.id in l)return l[a.id];try{let i=await import(a.module);return l[a.id]=i,i}catch(i){return console.error(`Error loading route module \`${a.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function t1(a){return a==null?!1:a.href==null?a.rel==="preload"&&typeof a.imageSrcSet=="string"&&typeof a.imageSizes=="string":typeof a.rel=="string"&&typeof a.href=="string"}async function n1(a,l,i){let o=await Promise.all(a.map(async f=>{let d=l.routes[f.route.id];if(d){let h=await e1(d,i);return h.links?h.links():[]}return[]}));return i1(o.flat(1).filter(t1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function dp(a,l,i,o,f,d){let h=(p,g)=>i[g]?p.route.id!==i[g].route.id:!0,x=(p,g)=>i[g].pathname!==p.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==p.params["*"];return d==="assets"?l.filter((p,g)=>h(p,g)||x(p,g)):d==="data"?l.filter((p,g)=>{let b=o.routes[p.route.id];if(!b||!b.hasLoader)return!1;if(h(p,g)||x(p,g))return!0;if(p.route.shouldRevalidate){let y=p.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(a,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function a1(a,l,{includeHydrateFallback:i}={}){return l1(a.map(o=>{let f=l.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function l1(a){return[...new Set(a)]}function s1(a){let l={},i=Object.keys(a).sort();for(let o of i)l[o]=a[o];return l}function i1(a,l){let i=new Set;return new Set(l),a.reduce((o,f)=>{let d=JSON.stringify(s1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function px(){let a=m.useContext(es);return Rf(a,"You must render this element inside a <DataRouterContext.Provider> element"),a}function r1(){let a=m.useContext(ro);return Rf(a,"You must render this element inside a <DataRouterStateContext.Provider> element"),a}var Tf=m.createContext(void 0);Tf.displayName="FrameworkContext";function xx(){let a=m.useContext(Tf);return Rf(a,"You must render this element inside a <HydratedRouter> element"),a}function o1(a,l){let i=m.useContext(Tf),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:x,onBlur:p,onMouseEnter:g,onMouseLeave:b,onTouchStart:y}=l,N=m.useRef(null);m.useEffect(()=>{if(a==="render"&&h(!0),a==="viewport"){let w=k=>{k.forEach(S=>{h(S.isIntersecting)})},j=new IntersectionObserver(w,{threshold:.5});return N.current&&j.observe(N.current),()=>{j.disconnect()}}},[a]),m.useEffect(()=>{if(o){let w=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(w)}}},[o]);let q=()=>{f(!0)},C=()=>{f(!1),h(!1)};return i?a!=="intent"?[d,N,{}]:[d,N,{onFocus:Js(x,q),onBlur:Js(p,C),onMouseEnter:Js(g,q),onMouseLeave:Js(b,C),onTouchStart:Js(y,q)}]:[!1,N,{}]}function Js(a,l){return i=>{a&&a(i),i.defaultPrevented||l(i)}}function c1({page:a,...l}){let{router:i}=px(),o=m.useMemo(()=>lx(i.routes,a,i.basename),[i.routes,a,i.basename]);return o?m.createElement(f1,{page:a,matches:o,...l}):null}function u1(a){let{manifest:l,routeModules:i}=xx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return n1(a,l,i).then(h=>{d||f(h)}),()=>{d=!0}},[a,l,i]),o}function f1({page:a,matches:l,...i}){let o=Pa(),{manifest:f,routeModules:d}=xx(),{basename:h}=px(),{loaderData:x,matches:p}=r1(),g=m.useMemo(()=>dp(a,l,p,f,o,"data"),[a,l,p,f,o]),b=m.useMemo(()=>dp(a,l,p,f,o,"assets"),[a,l,p,f,o]),y=m.useMemo(()=>{if(a===o.pathname+o.search+o.hash)return[];let C=new Set,w=!1;if(l.forEach(k=>{let S=f.routes[k.route.id];!S||!S.hasLoader||(!g.some(M=>M.route.id===k.route.id)&&k.route.id in x&&d[k.route.id]?.shouldRevalidate||S.hasClientLoader?w=!0:C.add(k.route.id))}),C.size===0)return[];let j=Pb(a,h,"data");return w&&C.size>0&&j.searchParams.set("_routes",l.filter(k=>C.has(k.route.id)).map(k=>k.route.id).join(",")),[j.pathname+j.search]},[h,x,o,f,g,l,a,d]),N=m.useMemo(()=>a1(b,f),[b,f]),q=u1(b);return m.createElement(m.Fragment,null,y.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...i})),N.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...i})),q.map(({key:C,link:w})=>m.createElement("link",{key:C,nonce:i.nonce,...w})))}function d1(...a){return l=>{a.forEach(i=>{typeof i=="function"?i(l):i!=null&&(i.current=l)})}}var gx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{gx&&(window.__reactRouterVersion="7.9.6")}catch{}function m1({basename:a,children:l,window:i}){let o=m.useRef();o.current==null&&(o.current=Py({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),x=m.useCallback(p=>{m.startTransition(()=>h(p))},[h]);return m.useLayoutEffect(()=>f.listen(x),[f,x]),m.createElement(Gb,{basename:a,children:l,location:d.location,navigationType:d.action,navigator:f})}var vx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yx=m.forwardRef(function({onClick:l,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:x,target:p,to:g,preventScrollReset:b,viewTransition:y,...N},q){let{basename:C}=m.useContext(Cn),w=typeof g=="string"&&vx.test(g),j,k=!1;if(typeof g=="string"&&w&&(j=g,gx))try{let z=new URL(window.location.href),K=g.startsWith("//")?new URL(z.protocol+g):new URL(g),Z=Pn(K.pathname,C);K.origin===z.origin&&Z!=null?g=Z+K.search+K.hash:k=!0}catch{pn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let S=Eb(g,{relative:f}),[M,T,L]=o1(o,N),H=g1(g,{replace:h,state:x,target:p,preventScrollReset:b,relative:f,viewTransition:y});function O(z){l&&l(z),z.defaultPrevented||H(z)}let F=m.createElement("a",{...N,...L,href:j||S,onClick:k||d?l:O,ref:d1(q,T),target:p,"data-discover":!w&&i==="render"?"true":void 0});return M&&!w?m.createElement(m.Fragment,null,F,m.createElement(c1,{page:S})):F});yx.displayName="Link";var h1=m.forwardRef(function({"aria-current":l="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:x,children:p,...g},b){let y=vi(h,{relative:g.relative}),N=Pa(),q=m.useContext(ro),{navigator:C,basename:w}=m.useContext(Cn),j=q!=null&&A1(y)&&x===!0,k=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,S=N.pathname,M=q&&q.navigation&&q.navigation.location?q.navigation.location.pathname:null;i||(S=S.toLowerCase(),M=M?M.toLowerCase():null,k=k.toLowerCase()),M&&w&&(M=Pn(M,w)||M);const T=k!=="/"&&k.endsWith("/")?k.length-1:k.length;let L=S===k||!f&&S.startsWith(k)&&S.charAt(T)==="/",H=M!=null&&(M===k||!f&&M.startsWith(k)&&M.charAt(k.length)==="/"),O={isActive:L,isPending:H,isTransitioning:j},F=L?l:void 0,z;typeof o=="function"?z=o(O):z=[o,L?"active":null,H?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let K=typeof d=="function"?d(O):d;return m.createElement(yx,{...g,"aria-current":F,className:z,ref:b,style:K,to:h,viewTransition:x},typeof p=="function"?p(O):p)});h1.displayName="NavLink";var p1=m.forwardRef(({discover:a="render",fetcherKey:l,navigate:i,reloadDocument:o,replace:f,state:d,method:h=Yr,action:x,onSubmit:p,relative:g,preventScrollReset:b,viewTransition:y,...N},q)=>{let C=b1(),w=S1(x,{relative:g}),j=h.toLowerCase()==="get"?"get":"post",k=typeof x=="string"&&vx.test(x),S=M=>{if(p&&p(M),M.defaultPrevented)return;M.preventDefault();let T=M.nativeEvent.submitter,L=T?.getAttribute("formmethod")||h;C(T||M.currentTarget,{fetcherKey:l,method:L,navigate:i,replace:f,state:d,relative:g,preventScrollReset:b,viewTransition:y})};return m.createElement("form",{ref:q,method:j,action:w,onSubmit:o?p:S,...N,"data-discover":!k&&a==="render"?"true":void 0})});p1.displayName="Form";function x1(a){return`${a} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bx(a){let l=m.useContext(es);return Pe(l,x1(a)),l}function g1(a,{target:l,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let x=kb(),p=Pa(),g=vi(a,{relative:d});return m.useCallback(b=>{if(Zb(b,l)){b.preventDefault();let y=i!==void 0?i:ri(p)===ri(g);x(a,{replace:y,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[p,x,g,i,o,l,a,f,d,h])}var v1=0,y1=()=>`__${String(++v1)}__`;function b1(){let{router:a}=bx("useSubmit"),{basename:l}=m.useContext(Cn),i=Ub();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:x,formData:p,body:g}=Wb(o,l);if(f.navigate===!1){let b=f.fetcherKey||y1();await a.fetch(b,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||h,formEncType:f.encType||x,flushSync:f.flushSync})}else await a.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:p,body:g,formMethod:f.method||h,formEncType:f.encType||x,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[a,l,i])}function S1(a,{relative:l}={}){let{basename:i}=m.useContext(Cn),o=m.useContext(ea);Pe(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...vi(a||".",{relative:l})},h=Pa();if(a==null){d.search=h.search;let x=new URLSearchParams(d.search),p=x.getAll("index");if(p.some(b=>b==="")){x.delete("index"),p.filter(y=>y).forEach(y=>x.append("index",y));let b=x.toString();d.search=b?`?${b}`:""}}return(!a||a===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:Wn([i,d.pathname])),ri(d)}function A1(a,{relative:l}={}){let i=m.useContext(ux);Pe(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=bx("useViewTransitionState"),f=vi(a,{relative:l});if(!i.isTransitioning)return!1;let d=Pn(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=Pn(i.nextLocation.pathname,o)||i.nextLocation.pathname;return eo(f.pathname,h)!=null||eo(f.pathname,d)!=null}const wn=Object.create(null);wn.open="0";wn.close="1";wn.ping="2";wn.pong="3";wn.message="4";wn.upgrade="5";wn.noop="6";const Fr=Object.create(null);Object.keys(wn).forEach(a=>{Fr[wn[a]]=a});const ff={type:"error",data:"parser error"},Sx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ax=typeof ArrayBuffer=="function",jx=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a&&a.buffer instanceof ArrayBuffer,Df=({type:a,data:l},i,o)=>Sx&&l instanceof Blob?i?o(l):mp(l,o):Ax&&(l instanceof ArrayBuffer||jx(l))?i?o(l):mp(new Blob([l]),o):o(wn[a]+(l||"")),mp=(a,l)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];l("b"+(o||""))},i.readAsDataURL(a)};function hp(a){return a instanceof Uint8Array?a:a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}let Uu;function j1(a,l){if(Sx&&a.data instanceof Blob)return a.data.arrayBuffer().then(hp).then(l);if(Ax&&(a.data instanceof ArrayBuffer||jx(a.data)))return l(hp(a.data));Df(a,!1,i=>{Uu||(Uu=new TextEncoder),l(Uu.encode(i))})}const pp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ni=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let a=0;a<pp.length;a++)ni[pp.charCodeAt(a)]=a;const N1=a=>{let l=a.length*.75,i=a.length,o,f=0,d,h,x,p;a[a.length-1]==="="&&(l--,a[a.length-2]==="="&&l--);const g=new ArrayBuffer(l),b=new Uint8Array(g);for(o=0;o<i;o+=4)d=ni[a.charCodeAt(o)],h=ni[a.charCodeAt(o+1)],x=ni[a.charCodeAt(o+2)],p=ni[a.charCodeAt(o+3)],b[f++]=d<<2|h>>4,b[f++]=(h&15)<<4|x>>2,b[f++]=(x&3)<<6|p&63;return g},w1=typeof ArrayBuffer=="function",_f=(a,l)=>{if(typeof a!="string")return{type:"message",data:Nx(a,l)};const i=a.charAt(0);return i==="b"?{type:"message",data:C1(a.substring(1),l)}:Fr[i]?a.length>1?{type:Fr[i],data:a.substring(1)}:{type:Fr[i]}:ff},C1=(a,l)=>{if(w1){const i=N1(a);return Nx(i,l)}else return{base64:!0,data:a}},Nx=(a,l)=>{switch(l){case"blob":return a instanceof Blob?a:new Blob([a]);case"arraybuffer":default:return a instanceof ArrayBuffer?a:a.buffer}},wx="",E1=(a,l)=>{const i=a.length,o=new Array(i);let f=0;a.forEach((d,h)=>{Df(d,!1,x=>{o[h]=x,++f===i&&l(o.join(wx))})})},k1=(a,l)=>{const i=a.split(wx),o=[];for(let f=0;f<i.length;f++){const d=_f(i[f],l);if(o.push(d),d.type==="error")break}return o};function q1(){return new TransformStream({transform(a,l){j1(a,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}a.data&&typeof a.data!="string"&&(f[0]|=128),l.enqueue(f),l.enqueue(i)})}})}let Hu;function zr(a){return a.reduce((l,i)=>l+i.length,0)}function Ur(a,l){if(a[0].length===l)return a.shift();const i=new Uint8Array(l);let o=0;for(let f=0;f<l;f++)i[f]=a[0][o++],o===a[0].length&&(a.shift(),o=0);return a.length&&o<a[0].length&&(a[0]=a[0].slice(o)),i}function M1(a,l){Hu||(Hu=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,x){for(i.push(h);;){if(o===0){if(zr(i)<1)break;const p=Ur(i,1);d=(p[0]&128)===128,f=p[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if(zr(i)<2)break;const p=Ur(i,2);f=new DataView(p.buffer,p.byteOffset,p.length).getUint16(0),o=3}else if(o===2){if(zr(i)<8)break;const p=Ur(i,8),g=new DataView(p.buffer,p.byteOffset,p.length),b=g.getUint32(0);if(b>Math.pow(2,21)-1){x.enqueue(ff);break}f=b*Math.pow(2,32)+g.getUint32(4),o=3}else{if(zr(i)<f)break;const p=Ur(i,f);x.enqueue(_f(d?p:Hu.decode(p),l)),o=0}if(f===0||f>a){x.enqueue(ff);break}}}})}const Cx=4;function dt(a){if(a)return R1(a)}function R1(a){for(var l in dt.prototype)a[l]=dt.prototype[l];return a}dt.prototype.on=dt.prototype.addEventListener=function(a,l){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(l),this};dt.prototype.once=function(a,l){function i(){this.off(a,i),l.apply(this,arguments)}return i.fn=l,this.on(a,i),this};dt.prototype.off=dt.prototype.removeListener=dt.prototype.removeAllListeners=dt.prototype.removeEventListener=function(a,l){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+a];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+a],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===l||o.fn===l){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+a],this};dt.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var l=new Array(arguments.length-1),i=this._callbacks["$"+a],o=1;o<arguments.length;o++)l[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,l)}return this};dt.prototype.emitReserved=dt.prototype.emit;dt.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]};dt.prototype.hasListeners=function(a){return!!this.listeners(a).length};const co=typeof Promise=="function"&&typeof Promise.resolve=="function"?l=>Promise.resolve().then(l):(l,i)=>i(l,0),sn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),T1="arraybuffer";function Ex(a,...l){return l.reduce((i,o)=>(a.hasOwnProperty(o)&&(i[o]=a[o]),i),{})}const D1=sn.setTimeout,_1=sn.clearTimeout;function uo(a,l){l.useNativeTimers?(a.setTimeoutFn=D1.bind(sn),a.clearTimeoutFn=_1.bind(sn)):(a.setTimeoutFn=sn.setTimeout.bind(sn),a.clearTimeoutFn=sn.clearTimeout.bind(sn))}const O1=1.33;function B1(a){return typeof a=="string"?L1(a):Math.ceil((a.byteLength||a.size)*O1)}function L1(a){let l=0,i=0;for(let o=0,f=a.length;o<f;o++)l=a.charCodeAt(o),l<128?i+=1:l<2048?i+=2:l<55296||l>=57344?i+=3:(o++,i+=4);return i}function kx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function z1(a){let l="";for(let i in a)a.hasOwnProperty(i)&&(l.length&&(l+="&"),l+=encodeURIComponent(i)+"="+encodeURIComponent(a[i]));return l}function U1(a){let l={},i=a.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");l[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return l}class H1 extends Error{constructor(l,i,o){super(l),this.description=i,this.context=o,this.type="TransportError"}}class Of extends dt{constructor(l){super(),this.writable=!1,uo(this,l),this.opts=l,this.query=l.query,this.socket=l.socket,this.supportsBinary=!l.forceBase64}onError(l,i,o){return super.emitReserved("error",new H1(l,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(l){this.readyState==="open"&&this.write(l)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(l){const i=_f(l,this.socket.binaryType);this.onPacket(i)}onPacket(l){super.emitReserved("packet",l)}onClose(l){this.readyState="closed",super.emitReserved("close",l)}pause(l){}createUri(l,i={}){return l+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const l=this.opts.hostname;return l.indexOf(":")===-1?l:"["+l+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(l){const i=z1(l);return i.length?"?"+i:""}}class V1 extends Of{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(l){this.readyState="pausing";const i=()=>{this.readyState="paused",l()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(l){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};k1(l,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const l=()=>{this.write([{type:"close"}])};this.readyState==="open"?l():this.once("open",l)}write(l){this.writable=!1,E1(l,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const l=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=kx()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(l,i)}}let qx=!1;try{qx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const $1=qx;function G1(){}class Y1 extends V1{constructor(l){if(super(l),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&l.hostname!==location.hostname||o!==l.port}}doWrite(l,i){const o=this.request({method:"POST",data:l});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const l=this.request();l.on("data",this.onData.bind(this)),l.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=l}}class Nn extends dt{constructor(l,i,o){super(),this.createRequest=l,uo(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var l;const i=Ex(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(l=this._opts.cookieJar)===null||l===void 0||l.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=Nn.requestsCount++,Nn.requests[this._index]=this)}_onError(l){this.emitReserved("error",l,this._xhr),this._cleanup(!0)}_cleanup(l){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=G1,l)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Nn.requests[this._index],this._xhr=null}}_onLoad(){const l=this._xhr.responseText;l!==null&&(this.emitReserved("data",l),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Nn.requestsCount=0;Nn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",xp);else if(typeof addEventListener=="function"){const a="onpagehide"in sn?"pagehide":"unload";addEventListener(a,xp,!1)}}function xp(){for(let a in Nn.requests)Nn.requests.hasOwnProperty(a)&&Nn.requests[a].abort()}const X1=(function(){const a=Mx({xdomain:!1});return a&&a.responseType!==null})();class F1 extends Y1{constructor(l){super(l);const i=l&&l.forceBase64;this.supportsBinary=X1&&!i}request(l={}){return Object.assign(l,{xd:this.xd},this.opts),new Nn(Mx,this.uri(),l)}}function Mx(a){const l=a.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!l||$1))return new XMLHttpRequest}catch{}if(!l)try{return new sn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Rx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Q1 extends Of{get name(){return"websocket"}doOpen(){const l=this.uri(),i=this.opts.protocols,o=Rx?{}:Ex(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(l,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=l=>this.onClose({description:"websocket connection closed",context:l}),this.ws.onmessage=l=>this.onData(l.data),this.ws.onerror=l=>this.onError("websocket error",l)}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;Df(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&co(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const l=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=kx()),this.supportsBinary||(i.b64=1),this.createUri(l,i)}}const Vu=sn.WebSocket||sn.MozWebSocket;class K1 extends Q1{createSocket(l,i,o){return Rx?new Vu(l,i,o):i?new Vu(l,i):new Vu(l)}doWrite(l,i){this.ws.send(i)}}class Z1 extends Of{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(l){return this.emitReserved("error",l)}this._transport.closed.then(()=>{this.onClose()}).catch(l=>{this.onError("webtransport error",l)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(l=>{const i=M1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=l.readable.pipeThrough(i).getReader(),f=q1();f.readable.pipeTo(l.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:x,value:p})=>{x||(this.onPacket(p),d())}).catch(x=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(l){this.writable=!1;for(let i=0;i<l.length;i++){const o=l[i],f=i===l.length-1;this._writer.write(o).then(()=>{f&&co(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var l;(l=this._transport)===null||l===void 0||l.close()}}const J1={websocket:K1,webtransport:Z1,polling:F1},I1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,W1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function df(a){if(a.length>8e3)throw"URI too long";const l=a,i=a.indexOf("["),o=a.indexOf("]");i!=-1&&o!=-1&&(a=a.substring(0,i)+a.substring(i,o).replace(/:/g,";")+a.substring(o,a.length));let f=I1.exec(a||""),d={},h=14;for(;h--;)d[W1[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=l,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=P1(d,d.path),d.queryKey=eS(d,d.query),d}function P1(a,l){const i=/\/{2,9}/g,o=l.replace(i,"/").split("/");return(l.slice(0,1)=="/"||l.length===0)&&o.splice(0,1),l.slice(-1)=="/"&&o.splice(o.length-1,1),o}function eS(a,l){const i={};return l.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const mf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Qr=[];mf&&addEventListener("offline",()=>{Qr.forEach(a=>a())},!1);class Ca extends dt{constructor(l,i){if(super(),this.binaryType=T1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,l&&typeof l=="object"&&(i=l,l=null),l){const o=df(l);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=df(i.host).host);uo(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=U1(this.opts.query)),mf&&(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"})},Qr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(l){const i=Object.assign({},this.opts.query);i.EIO=Cx,i.transport=l,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[l]);return new this._transportsByName[l](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const l=this.opts.rememberUpgrade&&Ca.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(l);i.open(),this.setTransport(i)}setTransport(l){this.transport&&this.transport.removeAllListeners(),this.transport=l,l.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",Ca.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(l){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",l),this.emitReserved("heartbeat"),l.type){case"open":this.onHandshake(JSON.parse(l.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=l.data,this._onError(i);break;case"message":this.emitReserved("data",l.data),this.emitReserved("message",l.data);break}}onHandshake(l){this.emitReserved("handshake",l),this.id=l.sid,this.transport.query.sid=l.sid,this._pingInterval=l.pingInterval,this._pingTimeout=l.pingTimeout,this._maxPayload=l.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const l=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+l,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},l),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const l=this._getWritablePackets();this.transport.send(l),this._prevBufferLen=l.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=B1(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const l=Date.now()>this._pingTimeoutTime;return l&&(this._pingTimeoutTime=0,co(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),l}write(l,i,o){return this._sendPacket("message",l,i,o),this}send(l,i,o){return this._sendPacket("message",l,i,o),this}_sendPacket(l,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:l,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const l=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),l()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():l()}):this.upgrading?o():l()),this}_onError(l){if(Ca.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",l),this._onClose("transport error",l)}_onClose(l,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),mf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Qr.indexOf(this._offlineEventListener);o!==-1&&Qr.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",l,i),this.writeBuffer=[],this._prevBufferLen=0}}}Ca.protocol=Cx;class tS extends Ca{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let l=0;l<this._upgrades.length;l++)this._probe(this._upgrades[l])}_probe(l){let i=this.createTransport(l),o=!1;Ca.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",y=>{if(!o)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;Ca.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(b(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const N=new Error("probe error");N.transport=i.name,this.emitReserved("upgradeError",N)}}))};function d(){o||(o=!0,b(),i.close(),i=null)}const h=y=>{const N=new Error("probe error: "+y);N.transport=i.name,d(),this.emitReserved("upgradeError",N)};function x(){h("transport closed")}function p(){h("socket closed")}function g(y){i&&y.name!==i.name&&d()}const b=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",x),this.off("close",p),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",x),this.once("close",p),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&l!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(l){this._upgrades=this._filterUpgrades(l.upgrades),super.onHandshake(l)}_filterUpgrades(l){const i=[];for(let o=0;o<l.length;o++)~this.transports.indexOf(l[o])&&i.push(l[o]);return i}}let nS=class extends tS{constructor(l,i={}){const o=typeof l=="object"?l:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>J1[f]).filter(f=>!!f)),super(l,o)}};function aS(a,l="",i){let o=a;i=i||typeof location<"u"&&location,a==null&&(a=i.protocol+"//"+i.host),typeof a=="string"&&(a.charAt(0)==="/"&&(a.charAt(1)==="/"?a=i.protocol+a:a=i.host+a),/^(https?|wss?):\/\//.test(a)||(typeof i<"u"?a=i.protocol+"//"+a:a="https://"+a),o=df(a)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+l,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const lS=typeof ArrayBuffer=="function",sS=a=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(a):a.buffer instanceof ArrayBuffer,Tx=Object.prototype.toString,iS=typeof Blob=="function"||typeof Blob<"u"&&Tx.call(Blob)==="[object BlobConstructor]",rS=typeof File=="function"||typeof File<"u"&&Tx.call(File)==="[object FileConstructor]";function Bf(a){return lS&&(a instanceof ArrayBuffer||sS(a))||iS&&a instanceof Blob||rS&&a instanceof File}function Kr(a,l){if(!a||typeof a!="object")return!1;if(Array.isArray(a)){for(let i=0,o=a.length;i<o;i++)if(Kr(a[i]))return!0;return!1}if(Bf(a))return!0;if(a.toJSON&&typeof a.toJSON=="function"&&arguments.length===1)return Kr(a.toJSON(),!0);for(const i in a)if(Object.prototype.hasOwnProperty.call(a,i)&&Kr(a[i]))return!0;return!1}function oS(a){const l=[],i=a.data,o=a;return o.data=hf(i,l),o.attachments=l.length,{packet:o,buffers:l}}function hf(a,l){if(!a)return a;if(Bf(a)){const i={_placeholder:!0,num:l.length};return l.push(a),i}else if(Array.isArray(a)){const i=new Array(a.length);for(let o=0;o<a.length;o++)i[o]=hf(a[o],l);return i}else if(typeof a=="object"&&!(a instanceof Date)){const i={};for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=hf(a[o],l));return i}return a}function cS(a,l){return a.data=pf(a.data,l),delete a.attachments,a}function pf(a,l){if(!a)return a;if(a&&a._placeholder===!0){if(typeof a.num=="number"&&a.num>=0&&a.num<l.length)return l[a.num];throw new Error("illegal attachments")}else if(Array.isArray(a))for(let i=0;i<a.length;i++)a[i]=pf(a[i],l);else if(typeof a=="object")for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&(a[i]=pf(a[i],l));return a}const uS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],fS=5;var Re;(function(a){a[a.CONNECT=0]="CONNECT",a[a.DISCONNECT=1]="DISCONNECT",a[a.EVENT=2]="EVENT",a[a.ACK=3]="ACK",a[a.CONNECT_ERROR=4]="CONNECT_ERROR",a[a.BINARY_EVENT=5]="BINARY_EVENT",a[a.BINARY_ACK=6]="BINARY_ACK"})(Re||(Re={}));class dS{constructor(l){this.replacer=l}encode(l){return(l.type===Re.EVENT||l.type===Re.ACK)&&Kr(l)?this.encodeAsBinary({type:l.type===Re.EVENT?Re.BINARY_EVENT:Re.BINARY_ACK,nsp:l.nsp,data:l.data,id:l.id}):[this.encodeAsString(l)]}encodeAsString(l){let i=""+l.type;return(l.type===Re.BINARY_EVENT||l.type===Re.BINARY_ACK)&&(i+=l.attachments+"-"),l.nsp&&l.nsp!=="/"&&(i+=l.nsp+","),l.id!=null&&(i+=l.id),l.data!=null&&(i+=JSON.stringify(l.data,this.replacer)),i}encodeAsBinary(l){const i=oS(l),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function gp(a){return Object.prototype.toString.call(a)==="[object Object]"}class Lf extends dt{constructor(l){super(),this.reviver=l}add(l){let i;if(typeof l=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(l);const o=i.type===Re.BINARY_EVENT;o||i.type===Re.BINARY_ACK?(i.type=o?Re.EVENT:Re.ACK,this.reconstructor=new mS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Bf(l)||l.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(l),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+l)}decodeString(l){let i=0;const o={type:Number(l.charAt(0))};if(Re[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Re.BINARY_EVENT||o.type===Re.BINARY_ACK){const d=i+1;for(;l.charAt(++i)!=="-"&&i!=l.length;);const h=l.substring(d,i);if(h!=Number(h)||l.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(l.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(l.charAt(i)===","||i===l.length););o.nsp=l.substring(d,i)}else o.nsp="/";const f=l.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=l.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===l.length)break}o.id=Number(l.substring(d,i+1))}if(l.charAt(++i)){const d=this.tryParse(l.substr(i));if(Lf.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(l){try{return JSON.parse(l,this.reviver)}catch{return!1}}static isPayloadValid(l,i){switch(l){case Re.CONNECT:return gp(i);case Re.DISCONNECT:return i===void 0;case Re.CONNECT_ERROR:return typeof i=="string"||gp(i);case Re.EVENT:case Re.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&uS.indexOf(i[0])===-1);case Re.ACK:case Re.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mS{constructor(l){this.packet=l,this.buffers=[],this.reconPack=l}takeBinaryData(l){if(this.buffers.push(l),this.buffers.length===this.reconPack.attachments){const i=cS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const hS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Lf,Encoder:dS,get PacketType(){return Re},protocol:fS},Symbol.toStringTag,{value:"Module"}));function hn(a,l,i){return a.on(l,i),function(){a.off(l,i)}}const pS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Dx extends dt{constructor(l,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=l,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const l=this.io;this.subs=[hn(l,"open",this.onopen.bind(this)),hn(l,"packet",this.onpacket.bind(this)),hn(l,"error",this.onerror.bind(this)),hn(l,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...l){return l.unshift("message"),this.emit.apply(this,l),this}emit(l,...i){var o,f,d;if(pS.hasOwnProperty(l))throw new Error('"'+l.toString()+'" is a reserved event name');if(i.unshift(l),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:Re.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const b=this.ids++,y=i.pop();this._registerAckCallback(b,y),h.id=b}const x=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,p=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!x||(p?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(l,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[l]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[l];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===l&&this.sendBuffer.splice(x,1);i.call(this,new Error("operation has timed out"))},f),h=(...x)=>{this.io.clearTimeoutFn(d),i.apply(this,x)};h.withError=!0,this.acks[l]=h}emitWithAck(l,...i){return new Promise((o,f)=>{const d=(h,x)=>h?f(h):o(x);d.withError=!0,i.push(d),this.emit(l,...i)})}_addToQueue(l){let i;typeof l[l.length-1]=="function"&&(i=l.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:l,flags:Object.assign({fromQueue:!0},this.flags)};l.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(l=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!l||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(l){l.nsp=this.nsp,this.io._packet(l)}onopen(){typeof this.auth=="function"?this.auth(l=>{this._sendConnectPacket(l)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(l){this.packet({type:Re.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},l):l})}onerror(l){this.connected||this.emitReserved("connect_error",l)}onclose(l,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",l,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(l=>{if(!this.sendBuffer.some(o=>String(o.id)===l)){const o=this.acks[l];delete this.acks[l],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(l){if(l.nsp===this.nsp)switch(l.type){case Re.CONNECT:l.data&&l.data.sid?this.onconnect(l.data.sid,l.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Re.EVENT:case Re.BINARY_EVENT:this.onevent(l);break;case Re.ACK:case Re.BINARY_ACK:this.onack(l);break;case Re.DISCONNECT:this.ondisconnect();break;case Re.CONNECT_ERROR:this.destroy();const o=new Error(l.data.message);o.data=l.data.data,this.emitReserved("connect_error",o);break}}onevent(l){const i=l.data||[];l.id!=null&&i.push(this.ack(l.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(l){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)o.apply(this,l)}super.emit.apply(this,l),this._pid&&l.length&&typeof l[l.length-1]=="string"&&(this._lastOffset=l[l.length-1])}ack(l){const i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:Re.ACK,id:l,data:f}))}}onack(l){const i=this.acks[l.id];typeof i=="function"&&(delete this.acks[l.id],i.withError&&l.data.unshift(null),i.apply(this,l.data))}onconnect(l,i){this.id=l,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(l=>this.emitEvent(l)),this.receiveBuffer=[],this.sendBuffer.forEach(l=>{this.notifyOutgoingListeners(l),this.packet(l)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(l=>l()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Re.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(l){return this.flags.compress=l,this}get volatile(){return this.flags.volatile=!0,this}timeout(l){return this.flags.timeout=l,this}onAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(l),this}prependAny(l){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(l),this}offAny(l){if(!this._anyListeners)return this;if(l){const i=this._anyListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(l),this}prependAnyOutgoing(l){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(l),this}offAnyOutgoing(l){if(!this._anyOutgoingListeners)return this;if(l){const i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(l===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(l){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,l.data)}}}function ts(a){a=a||{},this.ms=a.min||100,this.max=a.max||1e4,this.factor=a.factor||2,this.jitter=a.jitter>0&&a.jitter<=1?a.jitter:0,this.attempts=0}ts.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var l=Math.random(),i=Math.floor(l*this.jitter*a);a=(Math.floor(l*10)&1)==0?a-i:a+i}return Math.min(a,this.max)|0};ts.prototype.reset=function(){this.attempts=0};ts.prototype.setMin=function(a){this.ms=a};ts.prototype.setMax=function(a){this.max=a};ts.prototype.setJitter=function(a){this.jitter=a};class xf extends dt{constructor(l,i){var o;super(),this.nsps={},this.subs=[],l&&typeof l=="object"&&(i=l,l=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,uo(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new ts({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=l;const f=i.parser||hS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(l){return arguments.length?(this._reconnection=!!l,l||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(l){return l===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=l,this)}reconnectionDelay(l){var i;return l===void 0?this._reconnectionDelay:(this._reconnectionDelay=l,(i=this.backoff)===null||i===void 0||i.setMin(l),this)}randomizationFactor(l){var i;return l===void 0?this._randomizationFactor:(this._randomizationFactor=l,(i=this.backoff)===null||i===void 0||i.setJitter(l),this)}reconnectionDelayMax(l){var i;return l===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=l,(i=this.backoff)===null||i===void 0||i.setMax(l),this)}timeout(l){return arguments.length?(this._timeout=l,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(l){if(~this._readyState.indexOf("open"))return this;this.engine=new nS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=hn(i,"open",function(){o.onopen(),l&&l()}),d=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),l?l(x):this.maybeReconnectOnOpen()},h=hn(i,"error",d);if(this._timeout!==!1){const x=this._timeout,p=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},x);this.opts.autoUnref&&p.unref(),this.subs.push(()=>{this.clearTimeoutFn(p)})}return this.subs.push(f),this.subs.push(h),this}connect(l){return this.open(l)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const l=this.engine;this.subs.push(hn(l,"ping",this.onping.bind(this)),hn(l,"data",this.ondata.bind(this)),hn(l,"error",this.onerror.bind(this)),hn(l,"close",this.onclose.bind(this)),hn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(l){try{this.decoder.add(l)}catch(i){this.onclose("parse error",i)}}ondecoded(l){co(()=>{this.emitReserved("packet",l)},this.setTimeoutFn)}onerror(l){this.emitReserved("error",l)}socket(l,i){let o=this.nsps[l];return o?this._autoConnect&&!o.active&&o.connect():(o=new Dx(this,l,i),this.nsps[l]=o),o}_destroy(l){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(l){const i=this.encoder.encode(l);for(let o=0;o<i.length;o++)this.engine.write(i[o],l.options)}cleanup(){this.subs.forEach(l=>l()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(l,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",l,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const l=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{l.skipReconnect||(this.emitReserved("reconnect_attempt",l.backoff.attempts),!l.skipReconnect&&l.open(f=>{f?(l._reconnecting=!1,l.reconnect(),this.emitReserved("reconnect_error",f)):l.onreconnect()}))},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const l=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",l)}}const Is={};function Zr(a,l){typeof a=="object"&&(l=a,a=void 0),l=l||{};const i=aS(a,l.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=Is[f]&&d in Is[f].nsps,x=l.forceNew||l["force new connection"]||l.multiplex===!1||h;let p;return x?p=new xf(o,l):(Is[f]||(Is[f]=new xf(o,l)),p=Is[f]),i.query&&!l.query&&(l.query=i.queryKey),p.socket(i.path,l)}Object.assign(Zr,{Manager:xf,Socket:Dx,io:Zr,connect:Zr});const _x="roverSettings",xS=3600*24*365;function gS(a){try{const l=decodeURIComponent(a??"");return JSON.parse(l)}catch(l){return console.warn("Failed to parse settings cookie",l),null}}function gf(){if(typeof document>"u")return{};const a=`${_x}=`,l=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(a));if(!l)return{};const i=l.substring(a.length);return gS(i)??{}}function vp(a){if(typeof document>"u")return!1;try{const l=encodeURIComponent(JSON.stringify(a??{})),i=`${_x}=${l}; path=/; max-age=${xS}; samesite=strict`;return document.cookie=i,!0}catch(l){return console.warn("Failed to write settings cookie",l),!1}}const Ox=window.location.origin;console.info("[socket] connecting to",Ox);const vS=gf(),yS=vS?.page?.connectionTransport||"websocket",bS=yS==="polling"?["polling"]:["websocket","polling"],zf=Zr(Ox,{transports:bS,timeout:15e3});zf.on("connect_error",a=>console.error("connect_error",a.code,a.message,a.data));const Bx=m.createContext(zf),SS=({children:a})=>r.jsx(Bx.Provider,{value:zf,children:a}),En=()=>m.useContext(Bx),Lx=m.createContext({connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,identifySession:async()=>{},login:async()=>{},setRole:async()=>{},requestControl:async()=>{},releaseControl:async()=>{},subscribeAll:async()=>{},homeAssistantToggle:async()=>{},homeAssistantSetState:async()=>{},homeAssistantSetLightColor:async()=>{},setNickname:async()=>{},requestVerification:async()=>{},triggerReplay:async()=>{},setCommunityGoal:async()=>{},setAdminReason:async()=>{},rebootRover:async()=>{},rebootServer:async()=>{},playUploadedAudio:async()=>{},stopUploadedAudio:async()=>{},startMicWhip:async()=>{},readyMicWhip:async()=>{},stopMicWhip:async()=>{},setAudioLevels:async()=>{},llmControl:async()=>{}});function AS(a){return m.useCallback((l,i={})=>new Promise((o,f)=>{a.emit(l,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[a])}function jS({children:a}){const l=En(),i=AS(l),[o,f]=m.useState(null),[d,h]=m.useState([]),[x,p]=m.useState([]),[g,b]=m.useState(null),[y,N]=m.useState(null),[q,C]=m.useState([]),[w,j]=m.useState(l.connected);m.useEffect(()=>{const M=()=>j(!0),T=()=>j(!1);return l.on("connect",M),l.on("disconnect",T),()=>{l.off("connect",M),l.off("disconnect",T)}},[l]),m.useEffect(()=>{function M(z){f(z)}function T(z=[]){h(z)}function L(z){h(K=>[...K.slice(-199),z])}function H(z=[]){p(z)}function O(z){p(K=>[...K.slice(-199),z])}function F(z=null){const K=z&&typeof z=="object"?z:null,Z=K?.debug?.status&&typeof K.debug.status=="object"?K.debug.status:null;b(K),N(Z)}return l.on("session:sync",M),l.on("log:init",T),l.on("log:entry",L),l.on("adminlog:init",H),l.on("adminlog:entry",O),l.on("llm:state",F),l.on("alert:new",(z={})=>{C(K=>[...K.slice(-49),{...z,receivedAt:Date.now()}])}),()=>{l.off("session:sync",M),l.off("log:init",T),l.off("log:entry",L),l.off("adminlog:init",H),l.off("adminlog:entry",O),l.off("llm:state",F),l.off("alert:new")}},[l]);const k=m.useMemo(()=>({login:(M,T)=>i("auth:login",{username:M,password:T}),identifySession:({cookieUserId:M,nickname:T}={})=>i("session:identify",{cookieUserId:M,nickname:T}),setRole:M=>i("session:setRole",{role:M}),requestControl:(M,T={})=>i("session:requestControl",{roverId:M,...T}),releaseControl:M=>i("session:releaseControl",{roverId:M}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(M,T)=>i("session:lockRover",{roverId:M,locked:T}),setMode:M=>i("setMode",{mode:M}),homeAssistantToggle:M=>i("homeAssistant:toggle",{entityId:M}),homeAssistantSetState:(M,T)=>i("homeAssistant:setState",{entityId:M,state:T}),homeAssistantSetLightColor:(M,T)=>i("homeAssistant:lightColor",{entityId:M,rgbColor:T}),setNickname:M=>i("nickname:set",{nickname:M}),requestVerification:()=>i("verification:request"),triggerReplay:(M=[])=>i("replay:trigger",{sources:M}),setCommunityGoal:M=>i("communityGoal:set",{text:M}),setAdminReason:M=>i("adminReason:set",{text:M}),rebootRover:M=>i("command",{roverId:M,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:M,name:T,mime:L,dataBase64:H})=>i("audio:uploadPlay",{roverId:M,name:T,mime:L,dataBase64:H}),stopUploadedAudio:M=>i("audio:uploadStop",{roverId:M}),startMicWhip:M=>i("audio:micWhipStart",{roverId:M}),readyMicWhip:M=>i("audio:micWhipReady",{roverId:M}),stopMicWhip:M=>i("audio:micWhipStop",{roverId:M}),setAudioLevels:(M={})=>i("audioLevels:set",M),llmControl:(M,T={})=>i("llm:control",{controls:{action:M,...T}}),pushAlert:M=>C(T=>[...T.slice(-49),{...M,receivedAt:Date.now(),id:M.id||Math.random().toString(36).slice(2)}])}),[i]),S=m.useMemo(()=>({connected:w,session:o,logs:d,adminLogs:x,llmCommentaryState:g,llmCommentaryStatus:y,alerts:q,...k}),[k,x,q,w,g,y,d,o]);return r.jsx(Lx.Provider,{value:S,children:a})}function Te(){return m.useContext(Lx)}const zx=m.createContext({frames:{}});function NS({children:a}){const l=En(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:x={},frame:p={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:x,raw:p?.data||null,receivedAt:Date.now()}}))}return l.on("sensorFrame",d),()=>{l.off("sensorFrame",d)}},[l]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(zx.Provider,{value:f,children:a})}function Uf(){return m.useContext(zx).frames}function ns(a){const l=Uf();return a?l[a]??null:null}const wS=650,CS={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 $u(a){if(typeof a!="number"||a<=0)return null;const l=CS[a];return l?{code:a,...l}:null}function ES(a,l={}){const i=l.holdMs||wS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const x=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(x)},[i]),m.useEffect(()=>{const x=Date.now(),p=$u(a?.infraredCharacterLeft),g=$u(a?.infraredCharacterRight),b=$u(a?.infraredCharacterOmni);!p&&!g&&!b||f(y=>({left:p?{...p,ts:x}:y.left,right:g?{...g,ts:x}:y.right,omni:b?{...b,ts:x}:y.omni}))},[a?.infraredCharacterLeft,a?.infraredCharacterRight,a?.infraredCharacterOmni]),m.useEffect(()=>{const{left:x,right:p,omni:g}=o;if(!(x?.ts||p?.ts||g?.ts))return;const y=new Date().toISOString();console.debug("[DockIR]",y,{left:x?.code??0,omni:g?.code??0,right:p?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const x=Date.now(),p=j=>{if(!j)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const k=x-j.ts,S=k<=i;return{active:S,age:k,code:j.code,red:!!(j.red&&S),green:!!(j.green&&S),force:!!(j.force&&S)}},g=p(o.left),b=p(o.right),y=p(o.omni),N=g.force||b.force||y.force,q=g.active||b.active||y.active,C=g.active&&!b.active?"right":b.active&&!g.active?"left":"center",w=(b.active?1:0)-(g.active?1:0);return{visible:q,forceDetected:N,left:g,right:b,omni:y,bias:C,balance:Math.max(-1,Math.min(1,w))}},[o.left,o.right,o.omni,i,d])}function kS(){const{connected:a,session:l}=Te(),i=l?.assignment?.roverId,o=ns(i),f=o?.sensors||{},d=ES(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,x=f.currentMa!=null?`${f.currentMa} mA`:null,p=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,g=f.batteryChargeMah,b=f.batteryCapacityMah;o?.receivedAt&&new Date(o.receivedAt).toLocaleTimeString();const y=o?.raw?o.raw:null,N=i?l?.activeDrivers?.[i]:null;return m.useMemo(()=>i?N?N===l?.socketId?"You":(l?.users||[]).find(C=>C.socketId===N)?.nickname||N.slice(0,6):"Available":"n/a",[N,i,l?.socketId,l?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[i?o?r.jsxs(r.Fragment,{children:[r.jsx(qS,{sensors:f,voltage:h,current:x,batteryTemp:p,charge:g,capacity:b}),r.jsx(MS,{sensors:f,dockState:d})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),y&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:y})]})}function qS({sensors:a,voltage:l,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",x=a?.oiMode?.label||"--",p=a?.chargingSources?.homeBase?"Yes":"No",g=a?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(Kn,{label:"Voltage",value:l??"--"}),r.jsx(Kn,{label:"Current",value:i??"--"}),r.jsx(Kn,{label:"Battery temp",value:o??"--"}),r.jsx(Kn,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(Kn,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(Kn,{label:"Charge",value:h}),r.jsx(Kn,{label:"OI mode",value:x}),r.jsx(Kn,{label:"Docked",value:p}),r.jsx(Kn,{label:"Charging state",value:g})]})}function Kn({label:a,value:l}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function MS({sensors:a,dockState:l}){const i=a?.bumpsAndWheelDrops||{},o=a?.wheelOvercurrents||{},f=[{label:"Left",value:a?.lightBumpLeftSignal},{label:"Front Left",value:a?.lightBumpFrontLeftSignal},{label:"Center Left",value:a?.lightBumpCenterLeftSignal},{label:"Center Right",value:a?.lightBumpCenterRightSignal},{label:"Front Right",value:a?.lightBumpFrontRightSignal},{label:"Right",value:a?.lightBumpRightSignal}],d=[{label:"Left",value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Front Left",value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Front Right",value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Right",value:a?.cliffRightSignal,active:a?.cliffRight}],h=[{label:"Wheel L",value:a?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:a?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:a?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:a?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs($l,{title:"Dock IR",children:[r.jsx(RS,{sensors:a}),r.jsx(TS,{state:l})]}),r.jsxs($l,{title:"Bumps & drops",children:[r.jsx(Zn,{label:"Bump L",value:r.jsx(Ws,{active:i.bumpLeft})}),r.jsx(Zn,{label:"Bump R",value:r.jsx(Ws,{active:i.bumpRight})}),r.jsx(Zn,{label:"Wheel drop L",value:r.jsx(Ws,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(Zn,{label:"Wheel drop R",value:r.jsx(Ws,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx($l,{title:"Light bumps (raw)",children:f.map(x=>r.jsx(Zn,{label:x.label,value:Ps(x.value)},x.label))}),r.jsx($l,{title:"Cliff sensors",children:d.map(x=>r.jsx(Zn,{label:x.label,value:`${Ps(x.value)} · ${x.active?"bool: true":"bool: false"}`},x.label))}),r.jsx($l,{title:"Currents",children:h.map(x=>r.jsx(Zn,{label:x.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:Ps(x.value,"mA")}),x.over?r.jsx(Ws,{active:!0,tone:"red",label:"over"}):null]})},x.label))}),r.jsxs($l,{title:"Dirt detect",children:[r.jsx(Zn,{label:"Left",value:Ps(a?.dirtDetectLeft)}),r.jsx(Zn,{label:"Right",value:Ps(a?.dirtDetect)})]})]})}function $l({title:a,children:l}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:a}),r.jsx("div",{className:"space-y-0.5",children:l})]})}function Zn({label:a,value:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:a}),r.jsx("span",{className:"text-slate-100",children:l})]})}function Ws({active:a,tone:l="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=l==="red"?a?"bg-red-600 text-white":"bg-slate-700 text-slate-300":l==="amber"?a?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":a?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(a?"true":"false")})}function Ps(a,l){return a==null||Number.isNaN(a)?"--":l?`${a} ${l}`:a}function RS({sensors:a}){const l=a?.infraredCharacterLeft,i=a?.infraredCharacterRight,o=a?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(l)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function TS({state:a}){if(!a)return null;const l=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${a.left.code??"--"} (${l(a.left)}) · age ${i(a.left)}`}),r.jsx("div",{children:`Omni: ${a.omni.code??"--"} (${l(a.omni)}) · age ${i(a.omni)}`}),r.jsx("div",{children:`Right: ${a.right.code??"--"} (${l(a.right)}) · age ${i(a.right)}`})]})}const Ux=m.createContext(null);function DS({children:a}){const[l,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const x=gf();i({status:"ready",data:x??{}})},[]);const o=m.useCallback(()=>{const x=gf();i({status:"ready",data:x??{}})},[]),f=m.useCallback(x=>{const p=vp(x??{});return i(p?{status:"ready",data:x??{}}:g=>({...g,status:"error"})),p},[]),d=m.useCallback((x,p)=>{i(g=>{const b=g.data[x]||{},y=typeof p=="function"?p(b):{...b,...p??{}},N={...g.data,[x]:y};return vp(N)?{status:"ready",data:N}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:l.data,status:l.status,reload:o,saveAll:f,setNamespace:d}),[l,o,f,d]);return r.jsx(Ux.Provider,{value:h,children:a})}function _S(){const a=m.useContext(Ux);if(!a)throw new Error("useSettings must be used within SettingsProvider");return a}function We(a,l={}){const{data:i,status:o,setNamespace:f}=_S(),d=i[a]??l??{},h=m.useCallback(g=>{f(a,b=>{const y=b??{};return typeof g=="function"?g(y):{...y,...g??{}}})},[a,f]),x=m.useCallback(g=>{f(a,()=>g??{})},[a,f]),p=m.useCallback(()=>{const g=typeof l=="object"?{...l}:l;f(a,()=>g??{})},[l,a,f]);return{value:d,status:o,save:h,replace:x,reset:p}}function OS(a=[]){return a.map(l=>!l?.type||!l?.id?null:{type:l.type,id:String(l.id),label:l.label||String(l.id),key:`${l.type}:${l.id}`}).filter(Boolean)}function Hf({panelId:a="replay-sources",fillHeight:l=!1}){const{session:i,triggerReplay:o}=Te(),f=OS(i?.replaySources||[]),{value:d,save:h}=We("replaySources",{}),[x,p]=m.useState([]),[g,b]=m.useState(!1),[y,N]=m.useState(null),[q,C]=m.useState(null),w=i?.replay||null,[j,k]=m.useState(0),S=m.useMemo(()=>{const z=i?.assignment?.roverId;return z?[`rover:${z}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const z=d?.[a];if(Array.isArray(z)&&z.length){p(z);return}p(S)},[d?.[a],S,a]),m.useEffect(()=>{const z=new Set(f.map(K=>K.key));p(K=>K.filter(Z=>z.has(Z)))},[f]);const M=m.useMemo(()=>({rovers:f.filter(z=>z.type==="rover"),rooms:f.filter(z=>z.type==="room")}),[f]);m.useEffect(()=>{if(!w?.lastTriggeredAt||!w?.cooldownMs){k(0);return}const z=()=>{const Z=w.lastTriggeredAt+w.cooldownMs-Date.now();k(Math.max(0,Z))};z();const K=setInterval(z,250);return()=>clearInterval(K)},[w?.lastTriggeredAt,w?.cooldownMs,w?.remainingMs]);const T=g||i?.mode==="lockdown"||j>0||!x.length,L=z=>{p(K=>{const Z=K.includes(z)?K.filter(ae=>ae!==z):[...K,z];return h(ae=>({...ae||{},[a]:Z})),Z}),C(null)},H=async()=>{if(!T){b(!0),N(null),C(null);try{const z=x.map(K=>{const[Z,ae]=K.split(":");return{type:Z,id:ae}});await o(z),C("Replay sent. Check the Discord replay channel.")}catch(z){N(z.message)}finally{b(!1)}}},O=l?"h-full flex flex-col":"",F=l?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${O}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${F}`,children:[r.jsx(yp,{title:"Rovers",items:M.rovers,selected:x,onToggle:L}),r.jsx(yp,{title:"Room Cams",items:M.rooms,selected:x,onToggle:L})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:H,disabled:T,children:j>0?`Replay (${Math.ceil(j/1e3)}s)`:g?"Replay…":"Replay"}),y?r.jsx("div",{className:"text-xs text-amber-400",children:y}):null,q?r.jsx("div",{className:"text-xs text-emerald-300",children:q}):null]})]})}function yp({title:a,items:l,selected:i,onToggle:o}){return l.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:a}),r.jsx("div",{className:"space-y-0.5",children:l.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:"truncate",children:f.label})]},f.key))})]}):null}var Hx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},bp=Wa.createContext&&Wa.createContext(Hx),BS=["attr","size","title"];function LS(a,l){if(a==null)return{};var i=zS(a,l),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);for(f=0;f<d.length;f++)o=d[f],!(l.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(i[o]=a[o])}return i}function zS(a,l){if(a==null)return{};var i={};for(var o in a)if(Object.prototype.hasOwnProperty.call(a,o)){if(l.indexOf(o)>=0)continue;i[o]=a[o]}return i}function to(){return to=Object.assign?Object.assign.bind():function(a){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(a[o]=i[o])}return a},to.apply(this,arguments)}function Sp(a,l){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);l&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(a,f).enumerable})),i.push.apply(i,o)}return i}function no(a){for(var l=1;l<arguments.length;l++){var i=arguments[l]!=null?arguments[l]:{};l%2?Sp(Object(i),!0).forEach(function(o){US(a,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):Sp(Object(i)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(i,o))})}return a}function US(a,l,i){return l=HS(l),l in a?Object.defineProperty(a,l,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[l]=i,a}function HS(a){var l=VS(a,"string");return typeof l=="symbol"?l:l+""}function VS(a,l){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var o=i.call(a,l);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(a)}function Vx(a){return a&&a.map((l,i)=>Wa.createElement(l.tag,no({key:i},l.attr),Vx(l.child)))}function yi(a){return l=>Wa.createElement($S,to({attr:no({},a.attr)},l),Vx(a.child))}function $S(a){var l=i=>{var{attr:o,size:f,title:d}=a,h=LS(a,BS),x=f||i.size||"1em",p;return i.className&&(p=i.className),a.className&&(p=(p?p+" ":"")+a.className),Wa.createElement("svg",to({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:p,style:no(no({color:a.color||i.color},i.style),a.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),d&&Wa.createElement("title",null,d),a.children)};return bp!==void 0?Wa.createElement(bp.Consumer,null,i=>l(i)):l(Hx)}function $x(a){return yi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(a)}function GS(a){return yi({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(a)}function Ap(a){return yi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(a)}function YS(a){return yi({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(a)}function XS(a){return yi({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function FS(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Vf(a){return!!a?.system}function QS(a){const l=new Date(a);return`${l.getHours().toString().padStart(2,"0")}:${l.getMinutes().toString().padStart(2,"0")}`}function jp(a){return a.nickname||a.socketId?.slice(0,6)||"unknown"}function KS({guildIconUrl:a,userAvatarUrl:l,label:i}){return!a&&!l?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${l?"bg-cover":""}`,style:l?{backgroundImage:`url(${l})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function Gx({message:a}){const l=a.fromDiscord?`${a.discordGuildName||"Discord"} · ${jp(a)}`:null,i=Vf(a),o=i?"text-emerald-300":FS(a.role);return r.jsxs(r.Fragment,{children:[a.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx($x,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(KS,{guildIconUrl:a.discordGuildIconUrl,userAvatarUrl:a.discordUserAvatarUrl,label:l})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:jp(a)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,a.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",children:a.roverId})]})}function Yx(a){return Vf(a)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${a.role==="admin"||a.role==="lockdown"||a.role==="lockdown-admin"?"border border-amber-400/30":a.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function $f({message:a}){const l=Vf(a);return r.jsxs("div",{className:Yx(a),children:[r.jsx(Gx,{message:a}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${l?"text-emerald-100":"text-slate-100"}`,children:a.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:QS(a.ts)})]})}function Xx({message:a}){return r.jsxs("div",{className:`${Yx(a)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(Gx,{message:a}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}const ZS=3e3,JS="#2196f3";function IS(a){return a.id?a.id:a.timestamp?`${a.timestamp}-${a.message}`:`${a.title||"alert"}-${a.message}`}function Gf({scale:a=1}){const{alerts:l}=Te(),[i,o]=m.useState(()=>Date.now()),f=m.useMemo(()=>l.slice(-3).map(p=>({alert:p,key:IS(p)})),[l]);m.useEffect(()=>{if(!f.length)return;const p=setInterval(()=>o(Date.now()),200);return()=>clearInterval(p)},[f.length]);const d=f.map(p=>({...p,age:i-(p.alert.receivedAt??p.alert.timestamp??0)})).filter(p=>p.age<=ZS);if(!d.length)return null;const h=a===1?void 0:{transform:`translateX(-50%) scale(${a})`,transformOrigin:"top center"},x=a===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:x,style:h,children:d.map(p=>r.jsx(WS,{alert:p.alert},p.key))})}function Np(a){const l=typeof a=="string"?a.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(l);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function WS({alert:a}){if(a.kind==="chat"&&a.payload)return r.jsx($f,{message:a.payload});if(a.kind==="chat-typing"&&a.payload)return r.jsx(Xx,{message:a.payload});const l=Np(a.color)||Np(JS),i=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=l?`rgba(${l.r}, ${l.g}, ${l.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:a.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:a.message})]})})}const Gl={main:[-127,127],side:[-127,127],vacuum:[0,127]},Gu={maxSpeed:500,baseSpeed:250,boostSpeed:400},vf=100,Yf=[31,127],Jl=60,yf=8,PS=250,eA=4e3,Yu=.4,tA=.8,nA={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},li={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"]},Fx=[{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:vf},{type:"oi",command:"dock"},{type:"pause",duration:vf},{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 Sf(){return{main:0,side:0,vacuum:0}}function aA(){return{enabled:!1,angle:null,config:null}}function Jr(){return{note:Jl}}function ai(){return{active:!1,heat:0,overheated:!1}}function Ir(){return{pttActive:!1}}const wp={roverId:null,mode:"drive",drive:bf(),aux:Sf(),camera:aA(),song:Jr(),horn:ai(),mic:Ir(),lastControlIntentAt:0,macros:Fx,keymap:li,inputs:{}};function lA(a,l){switch(l.type){case"control/set-rover":return{...a,roverId:l.payload??null,drive:l.payload?a.drive:bf(),aux:l.payload?a.aux:Sf(),song:l.payload?a.song:Jr(),horn:l.payload?a.horn:ai(),mic:l.payload?a.mic:Ir(),lastControlIntentAt:l.payload?a.lastControlIntentAt:0};case"control/set-mode":return a.mode===l.payload?a:{...a,mode:l.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:i,speeds:o,source:f}=l.payload;return{...a,drive:{vector:i??a.drive.vector,speeds:o??a.drive.speeds,source:f??a.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...a,aux:{...a.aux,...l.payload}};case"control/set-camera-config":return{...a,camera:{...a.camera,enabled:!!l.payload?.config,config:l.payload?.config??null,angle:typeof l.payload?.angle=="number"?l.payload.angle:l.payload?.config?l.payload.config.homeAngle??a.camera.angle:null}};case"control/set-camera-angle":return{...a,camera:{...a.camera,angle:l.payload}};case"control/register-input-state":{const i=l.payload?.source||"unknown";return{...a,inputs:{...a.inputs,[i]:{...a.inputs[i]??{},...l.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...a,keymap:{...a.keymap,...l.payload??{}}};case"control/set-macros":return{...a,macros:Array.isArray(l.payload)?l.payload:a.macros};case"control/reset":return{...a,drive:bf(),aux:Sf(),song:Jr(),horn:ai(),mic:Ir(),lastControlIntentAt:0};case"control/set-horn-active":return{...a,horn:{...a.horn||ai(),active:!!l.payload}};case"control/set-horn-heat":return{...a,horn:{...a.horn||ai(),heat:typeof l.payload?.heat=="number"?l.payload.heat:0,overheated:!!l.payload?.overheated}};case"control/record-intent":return{...a,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...a,song:{...a.song||Jr(),note:l.payload??Jl}};case"control/set-mic-ptt":return{...a,mic:{...a.mic||Ir(),pttActive:!!l.payload}};default:return a}}function Il(a,l,i){return typeof a!="number"||Number.isNaN(a)?l:Math.max(l,Math.min(i,a))}function Wl(a){return typeof a!="number"||Number.isNaN(a)?0:Math.max(-1,Math.min(1,a))}function ln(a,l){return!Array.isArray(l)||l.length!==2?a:Il(a,l[0],l[1])}function sA(a={}){const l=Wl(a.x??0),i=Wl(a.y??0);return{x:l,y:i,boost:!!a.boost}}function iA(a={},l={}){const i=sA(a),o=typeof l.maxSpeed=="number"?l.maxSpeed:Gu.maxSpeed,f=typeof l.baseSpeed=="number"?l.baseSpeed:Gu.baseSpeed,d=typeof l.boostSpeed=="number"?l.boostSpeed:Gu.boostSpeed,h=i.boost?d:f,x=i.y*h,p=i.x*h;return{vector:i,speeds:{left:Il(Math.round(x+p),-o,o),right:Il(Math.round(x-p),-o,o)}}}function rA(a){const l=Array.isArray(a)?a:[],i=String.fromCharCode(...l);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(l).toString("base64");throw new Error("No base64 encoder available")}function Cp(a){return new Promise(l=>setTimeout(l,a))}function oA(a={}){const{driveTransform:l,auxTransform:i}=a,o=En(),{session:f}=Te(),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(L=>String(L.id)===String(d))||null,[d,f?.roster]),x=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),p=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),b=m.useMemo(()=>h?.nightVision?.state??null,[h]),y=m.useCallback((L,H)=>{d&&o.emit("command",{roverId:d,...L},H)},[o,d]),N=m.useCallback(()=>{d&&y({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[y,d]),q=m.useCallback(L=>{if(!d)return null;const H={left:ln(L?.left??0,[-500,500]),right:ln(L?.right??0,[-500,500])},O=l?l(H):H,F={left:ln(O?.left??0,[-500,500]),right:ln(O?.right??0,[-500,500])};return y({type:"drive",data:{driveDirect:F}}),F},[l,y,d]),C=m.useCallback(({main:L=0,side:H=0,vacuum:O=0}={})=>{if(!d)return null;const F={main:ln(L,Gl.main),side:ln(H,Gl.side),vacuum:ln(O,Gl.vacuum)},z=i?i(F):F,K={main:ln(z?.main??0,Gl.main),side:ln(z?.side??0,Gl.side),vacuum:ln(z?.vacuum??0,Gl.vacuum)};return y({type:"motors",data:{motorPwm:K}}),K},[i,y,d]),w=m.useCallback(L=>!d||!x?null:(y({type:"servo",data:{servo:{angle:L}}}),L),[y,d,x]),j=m.useCallback(L=>{if(!d)return!1;const H=Array.isArray(L)?L:typeof L=="string"?nA[L]:null;return H?(y({type:"raw",data:{raw:rA(H)}}),N(),!0):!1},[y,N,d]),k=m.useCallback(async L=>{if(!(!L||!Array.isArray(L.steps)||!d))for(const H of L.steps){if(!d)break;switch(H.type){case"oi":j(H.command);break;case"drive":q(H.speeds??{left:0,right:0});break;case"motors":C(H.values??{});break;case"servo":w(H.angle);break;case"pause":await Cp(H.duration??vf);break}if(H.delay||H.delayMs){const O=H.delayMs??H.delay;typeof O=="number"&&O>0&&await Cp(O)}}},[d,j,q,C,w]),S=m.useCallback((L="toggle")=>!d||!p?null:(y({type:"nightVision",data:{nightVision:{action:L}}}),L),[y,p,d]),M=m.useCallback(L=>d?(y({type:"horn",data:{horn:L}}),L):null,[y,d]),T=m.useCallback((L=[],H={})=>{if(!d)return null;const F=(Array.isArray(L)&&L.length>0?L:[{note:Jl,duration:yf}]).slice(0,16).map(z=>({note:ln(Math.round(z?.note??Jl),Yf),duration:ln(Math.round(z?.duration??yf),[1,255])}));return y({type:"song",data:{song:{notes:F,slot:H.slot,loop:H.loop}}}),F},[y,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:x,nightVision:p,nightVisionState:b,horn:g,emitCommand:y,enableSensorStream:N,sendDriveDirect:q,sendAuxMotors:C,sendServoAngle:w,sendOiCommand:j,sendNightVision:S,sendHorn:M,sendSong:T,runMacroSteps:k}),[d,h,x,p,b,g,y,N,q,C,w,j,S,M,k])}const cA={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Ep={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function bi(a){if(typeof a!="string")return"";const l=a.toLowerCase();return cA[l]??l}function uA(a){const l=bi(a);if(!l)return null;if(Ep[l])return Ep[l];if(l.length===1){if(/[a-z]/.test(l))return`Key${l.toUpperCase()}`;if(/[0-9]/.test(l))return`Digit${l}`}return null}function Qx(a){const l=bi(a);return l?`key:${l}`:null}function fA(a){const l=uA(a);return l?`code:${l}`:null}function kp(a){const l=new Set,i=Qx(a?.key??"");i&&l.add(i);const o=a?.code?`code:${a.code}`:null;return o&&l.add(o),Array.from(l)}function dA(a={}){return Object.fromEntries(Object.entries(a).map(([l,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=Qx(String(d));h&&f.add(h);const x=fA(String(d));x&&f.add(x)}),[l,f]}))}function jn(a){const l=bi(a);return l?l===" "?"Space":l==="\\"?"Backslash":l==="`"?"Backtick":l==="["?"[ or {":l==="]"?"] or }":l===";"?"; or :":l==="'"?`' or "`:l===","?", or <":l==="."?". or >":l==="/"?"/ or ?":l==="-"?"- or _":l==="="?"= or +":l==="arrowup"?"Arrow Up":l==="arrowdown"?"Arrow Down":l==="arrowleft"?"Arrow Left":l==="arrowright"?"Arrow Right":l.length===1?l.toUpperCase():l:"—"}const An={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},In={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}]}}},wa={activeSignature:null,profiles:{},defaults:{profile:In}},Ia={waveform:"saw",freqs:[440,550,660,0]},jt={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Ql=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],mA={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function qp(){return Ql.reduce((a,l)=>(a[l.key]={cap:1,clearSec:0},a),{})}function Mp(a){return Number.isFinite(a)?Math.max(0,Math.min(1,a)):0}function hA(a,l={}){const{session:i}=Te(),d=(ns(a)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...mA,...l.config||{}}),[l.config]),[x,p]=m.useState(()=>qp()),g=m.useRef(typeof performance<"u"?performance.now():Date.now()),b=m.useRef(d);m.useEffect(()=>{b.current=d||{}},[d]),m.useEffect(()=>{p(qp())},[a]),m.useEffect(()=>{const C=setInterval(()=>{const w=typeof performance<"u"?performance.now():Date.now(),j=Math.max(0,w-g.current);g.current=w;const k=j/1e3;k<=0||p(S=>{let M=!1;const T={},L=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,H=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,O=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return Ql.forEach(F=>{const z=S[F.key]||{cap:1,clearSec:0},K=Number.isFinite(z.cap)?z.cap:1,Z=Number.isFinite(z.clearSec)?z.clearSec:0,ae=F.motors.some(R=>!!b.current?.[R]),ue=ae?0:Z+k,le=!ae&&ue>=O,U=Mp(ae?K-L*k:le?K+H*k:K);(Math.abs(U-K)>1e-4||Math.abs(ue-Z)>1e-4)&&(M=!0),T[F.key]={cap:U,clearSec:ue}}),M?T:S})},100);return()=>clearInterval(C)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec]);const y=m.useMemo(()=>{const C=Ql.reduce((w,j)=>{const k=x?.[j.key],S=Number.isFinite(k?.cap)?k.cap:1;return w[j.key]=Mp(S),w},{});return{perGroup:C,drive:{left:C.drive??1,right:C.drive??1},aux:{main:C.aux??1,side:C.aux??1,vacuum:1}}},[x]),N=m.useMemo(()=>{const C={};Ql.forEach(j=>{j.motors.forEach(k=>{C[k]=!!d?.[k]})});const w=Ql.reduce((j,k)=>(j[k.key]=k.motors.some(S=>!!d?.[S]),j),{});return{motors:C,groups:w}},[d]),q=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:x,overcurrent:N,scales:y,isActive:(y?.drive?.left??1)<1||(y?.drive?.right??1)<1||(y?.aux?.main??1)<1||(y?.aux?.side??1)<1,config:h,adminImmune:q}),[x,N,y,h,q])}function pA(a={},l,i=!1){if(i||!l?.drive)return a;const o=typeof l.drive.left=="number"?l.drive.left:1,f=typeof l.drive.right=="number"?l.drive.right:1;return o>=.999&&f>=.999?a:{left:Math.round((a.left??0)*o),right:Math.round((a.right??0)*f)}}function xA(a={},l,i=!1){if(i||!l?.aux)return a;const o=typeof l.aux.main=="number"?l.aux.main:1,f=typeof l.aux.side=="number"?l.aux.side:1,d=typeof l.aux.vacuum=="number"?l.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?a:{main:Math.round((a.main??0)*o),side:Math.round((a.side??0)*f),vacuum:Math.round((a.vacuum??0)*d)}}const Kx=m.createContext(null);function Rp(a){return Object.fromEntries(Object.entries(a||{}).map(([l,i])=>[l,Array.isArray(i)?[...i]:[]]))}function gA(a,l){if(!a)return l;const i=typeof a.minAngle=="number"?a.minAngle:-45,o=typeof a.maxAngle=="number"?a.maxAngle:45;return Il(l,i,o)}function vA({children:a}){const[l,i]=m.useReducer(lA,wp),o=m.useRef(null),f=m.useRef(!1),d=m.useRef(wp.camera.angle),h=m.useRef(null),x=m.useRef(0),p=m.useRef(0),{value:g,save:b}=We("controls",{keymap:li,macros:Fx}),{value:y}=We("horn",Ia),{session:N,homeAssistantSetState:q}=Te(),C=N?.assignment?.roverId??null,w=hA(C),j=m.useCallback(Y=>pA(Y,w.scales,w.adminImmune),[w.adminImmune,w.scales]),k=m.useCallback(Y=>xA(Y,w.scales,w.adminImmune),[w.adminImmune,w.scales]),S=oA({driveTransform:j,auxTransform:k}),M=m.useCallback(()=>{const se=(N?.homeAssistant?.entities||[]).filter(he=>(he.type==="light"||he.type==="switch")&&he.available!==!1&&he.state!=="on");if(se.length===0){f.current=!1;return}f.current=!0,se.forEach(he=>{q(he.id,"on").catch(()=>{})}),f.current=!1},[N?.homeAssistant?.entities,q]);m.useEffect(()=>{i({type:"control/set-rover",payload:S.roverId})},[S.roverId]),m.useEffect(()=>{const Y=o.current;o.current=l.mode,Y!=="drive"&&l.mode==="drive"&&N?.homeAssistant?.entities?M():Y!=="drive"&&l.mode==="drive"&&(f.current=!0)},[l.mode,N?.homeAssistant?.entities,M]),m.useEffect(()=>{f.current&&N?.homeAssistant?.entities&&M()},[N?.homeAssistant?.entities,M]),m.useEffect(()=>{const Y={...li,...g?.keymap||{}};i({type:"control/set-keymap",payload:Y}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const Y=S.servoConfig;if(!Y){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const se=typeof Y.minAngle=="number"?Y.minAngle:-45,he=typeof Y.maxAngle=="number"?Y.maxAngle:45,Se=typeof Y.homeAngle=="number"?Y.homeAngle:(se+he)/2,Ye=typeof d.current=="number"?Il(d.current,se,he):null,et=Ye??Il(Se,se,he);i({type:"control/set-camera-config",payload:{config:Y,angle:et}}),d.current=et},[S.servoConfig]),m.useEffect(()=>{d.current=typeof l.camera.angle=="number"?l.camera.angle:d.current},[l.camera.angle]),m.useEffect(()=>{S.roverId&&S.enableSensorStream()},[S.roverId,S.enableSensorStream]);const T=m.useCallback(Y=>{i({type:"control/set-mode",payload:Y})},[]),L=m.useCallback(()=>{i({type:"control/record-intent"})},[]),H=m.useRef(l.drive.speeds),O=m.useRef(l.aux),F=m.useMemo(()=>JSON.stringify(w.scales),[w.scales]),z=m.useRef(0),K=m.useRef(0);m.useEffect(()=>{H.current=l.drive.speeds},[l.drive.speeds]),m.useEffect(()=>{O.current=l.aux},[l.aux]),m.useEffect(()=>{if(!S.roverId||w.adminImmune||!w.isActive)return;const Y=Math.max(0,Number(w?.config?.outputRateMs)||0),se=typeof performance<"u"?performance.now():Date.now(),he=H.current||{left:0,right:0},Se=O.current||{main:0,side:0,vacuum:0},Ye=!!(he.left||he.right),et=!!(Se.main||Se.side||Se.vacuum);!Ye&&!et||(Ye&&se-z.current>=Y&&(z.current=se,S.sendDriveDirect(he)),et&&se-K.current>=Y&&(K.current=se,S.sendAuxMotors(Se)))},[F,w.adminImmune,w.config,w.isActive,S]);const Z=m.useCallback((Y,se={})=>{const he=iA(Y,se.speedOptions);i({type:"control/update-drive",payload:{...he,source:se.source??null}}),L(),S.sendDriveDirect(he.speeds)},[S,L]),ae=m.useCallback((Y={})=>{const se=S.sendAuxMotors(Y)??Y;i({type:"control/set-aux-motors",payload:se}),L()},[S,L]),ue=m.useCallback((Y,se)=>{if(!Y)return!1;const he=bi(se);if(!he)return!1;const Se=Rp(l.keymap);return Se[Y]=[he],i({type:"control/set-keymap",payload:Se}),b(Ye=>({...Ye??{},keymap:Se})),!0},[l.keymap,b]),le=m.useCallback(()=>{const Y=Rp(li);i({type:"control/set-keymap",payload:Y}),b(se=>({...se??{},keymap:Y}))},[b]),U=m.useCallback(Y=>{if(!S.servoConfig)return;const se=gA(S.servoConfig,Y);i({type:"control/set-camera-angle",payload:se}),S.sendServoAngle(se),d.current=se,L()},[S,L]),R=m.useCallback((Y=0)=>{const se=S.servoConfig;if(!se)return;const he=typeof Y=="number"&&Y!==0?Y:se.nudgeDegrees||1,Se=typeof d.current=="number"?d.current:typeof se.homeAngle=="number"?se.homeAngle:0;U(Se+he)},[S.servoConfig,U]),Q=m.useCallback(()=>{const Y=S.servoConfig;if(!Y)return;const se=typeof Y.homeAngle=="number"?Y.homeAngle:typeof Y.minAngle=="number"&&typeof Y.maxAngle=="number"?(Y.minAngle+Y.maxAngle)/2:0;U(se)},[S.servoConfig,U]),P=m.useCallback(async Y=>{const se=l.macros.find(he=>he.id===Y)||null;se&&(Y==="drive-sequence"?(M(),N?.homeAssistant?.entities||(f.current=!0),L()):Y==="seek-dock"&&L(),await S.runMacroSteps(se))},[S,L,N?.homeAssistant?.entities,l.macros,M]),ie=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),S.sendDriveDirect({left:0,right:0}),S.sendAuxMotors({main:0,side:0,vacuum:0})},[S]),oe=m.useCallback(Y=>{S.sendOiCommand(Y)},[S]),E=m.useCallback(Y=>{S.roverId&&S.emitCommand({type:"sensorStream",data:{sensorStream:{enable:Y}}})},[S]),V=m.useCallback(Y=>{if(S.nightVision){if(typeof Y=="boolean"){const se=Y?"off":"on";S.sendNightVision(se)}else S.sendNightVision("toggle");L()}},[S,L]),te=m.useCallback(()=>{V()},[V]),ne=m.useCallback(Y=>{const se=typeof Y=="number"?Y:Jl;return i({type:"control/set-song-note",payload:se}),se},[]),de=m.useCallback((Y,se)=>S.sendSong(Y,se),[S]),re=m.useMemo(()=>{const Y=y??Ia,se=Y.waveform==="sine"?"sine":"saw",Se=[...Array.isArray(Y.freqs)?Y.freqs:Ia.freqs,0,0,0,0].slice(0,4).map(Ye=>{const et=Number(Ye);return Number.isFinite(et)?et<=0?0:Math.min(5e3,Math.round(et)):0});return{waveform:se,freqs:Se}},[y]),ce=m.useCallback(()=>{if(!S.horn)return;if(l.horn?.overheated||(l.horn?.heat??0)>=1||l.horn?.active)return!1;const Y=Date.now();return S.sendHorn({action:"start",...re}),i({type:"control/set-horn-active",payload:!0}),x.current=Y,p.current=Y,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},eA),L(),!0},[i,re,S,L,l.horn?.active,l.horn?.heat,l.horn?.overheated]),xe=m.useCallback(()=>{if(!S.horn)return;S.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const Y=Date.now(),se=x.current||Y,he=Math.max(0,Y-se);if(x.current=0,he>0){const Se=l.horn?.heat??0,Ye=he/1e3*Yu;let et=Math.max(0,Math.min(1,Se+Ye)),xn=l.horn?.overheated??!1;et>=1&&(et=1,xn=!0),i({type:"control/set-horn-heat",payload:{heat:et,overheated:xn}})}},[i,S,l.horn?.heat,l.horn?.overheated,Yu]);m.useEffect(()=>{const se=setInterval(()=>{const he=Date.now(),Se=p.current||he;p.current=he;const Ye=Math.min(1e3,Math.max(0,he-Se))/1e3,et=l.horn?.heat??0,xn=!!l.horn?.active,kn=!!l.horn?.overheated,Nt=Ye*(xn?Yu:-.2);let rn=Math.max(0,Math.min(1,et+Nt)),qn=kn;rn>=1?(rn=1,qn=!0,xn&&xe()):qn&&rn<=tA&&(qn=!1),(rn!==et||qn!==kn)&&i({type:"control/set-horn-heat",payload:{heat:rn,overheated:qn}})},100);return()=>clearInterval(se)},[i,l.horn?.active,l.horn?.heat,l.horn?.overheated,xe]);const pe=m.useCallback((Y,se)=>{i({type:"control/register-input-state",payload:{source:Y,state:se}})},[]),ge=m.useCallback(Y=>{i({type:"control/set-mic-ptt",payload:!!Y})},[]),ze=m.useMemo(()=>({state:l,dispatch:i,pipeline:S,overcurrentLimiter:w,actions:{setMode:T,setDriveVector:Z,setAuxMotors:ae,setServoAngle:U,nudgeServo:R,goServoHome:Q,runMacro:P,stopAllMotion:ie,sendOiCommand:oe,setSensorStream:E,setNightVision:V,toggleNightVision:te,updateKeyBinding:ue,resetKeyBindings:le,registerInputState:pe,setSongNote:ne,sendSong:de,startHorn:ce,stopHorn:xe,setMicPttActive:ge}}),[l,S,w,T,Z,ae,U,R,Q,P,ie,oe,E,V,te,ue,le,pe,ne,de,ce,xe,ge]);return r.jsx(Kx.Provider,{value:ze,children:a})}function Et(){const a=m.useContext(Kx);if(!a)throw new Error("useControlSystem must be used within ControlSystemProvider");return a}const yA="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=",Zx=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function bA({children:a}){const l=En(),{session:i,pushAlert:o}=Te(),{value:f}=We("audio",jt),[d,h]=m.useState([]),[x,p]=m.useState([]),[g,b]=m.useState(!1),y=m.useRef(null),N=m.useRef(null),q=m.useRef(null),C=m.useRef(new Map),w=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),k=Number.isFinite(f?.masterVolume)?f.masterVolume:jt.masterVolume,S=Number.isFinite(f?.alertVolume)?f.alertVolume:jt.alertVolume,M=Math.max(0,Math.min(1,k*S)),T=m.useCallback(()=>{const U=Array.from(C.current.values()).sort((R,Q)=>R.lastUpdate-Q.lastUpdate).map(R=>R.payload);p(U)},[]),L=m.useCallback(U=>!U||typeof U!="object"?null:U.typingId?U.typingId:U.fromDiscord?`discord:${U.discordUserId||U.discordUserName||U.nickname||"unknown"}`:`socket:${U.socketId||U.nickname||"unknown"}`,[]);m.useEffect(()=>{q.current=new Audio(yA),q.current.volume=M,q.current.load()},[M]);const H=m.useCallback(()=>{const U=q.current;U&&(U.volume=M,U.currentTime=0,U.play().catch(()=>{}))},[M]);m.useEffect(()=>{function U(R={}){h(Q=>[...Q.slice(-99),R]),!(R?.socketId&&i?.socketId&&R.socketId===i.socketId)&&(H(),o?.({kind:"chat",payload:R,id:`chat-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return l.on("chat:message",U),()=>{l.off("chat:message",U)}},[H,i?.socketId,l]),m.useEffect(()=>{function U(R={}){const Q=L(R);if(!Q)return;const P=Date.now();if(R?.socketId&&i?.socketId&&R.socketId===i.socketId){R.isTyping||(C.current.delete(Q),T());return}if(R.isTyping){C.current.set(Q,{payload:R,expiresAt:P+6e3,lastUpdate:P});const ie=w.current.get(Q)||0;P-ie>=2500&&(w.current.set(Q,P),o?.({kind:"chat-typing",payload:R,id:`chat-typing-${Q}-${R.id||Math.random().toString(36).slice(2)}`,receivedAt:P}))}else C.current.delete(Q);T()}return l.on("chat:typing",U),()=>{l.off("chat:typing",U)}},[o,T,L,i?.socketId,l]),m.useEffect(()=>{const U=setInterval(()=>{const R=Date.now();let Q=!1;C.current.forEach((P,ie)=>{P.expiresAt<=R&&(C.current.delete(ie),Q=!0)}),Q&&T()},2e3);return()=>clearInterval(U)},[T]),m.useEffect(()=>{function U(R=[]){Array.isArray(R)&&h(Q=>{if(Q.length===0)return R.slice(-100);const P=new Set(R.map(oe=>oe?.id));return[...R,...Q.filter(oe=>oe?.id&&!P.has(oe.id))].slice(-100)})}return l.on("chat:init",U),()=>{l.off("chat:init",U)}},[l]);const O=m.useCallback(U=>{const R=!!U,Q=Date.now(),P=j.current,ie=!R&&P.isTyping;!(R&&(!P.isTyping||Q-P.lastSent>=3500))&&!ie||(j.current={isTyping:R,lastSent:Q},l.emit("chat:typing",{isTyping:R}))},[l]),F=m.useCallback((U,R=null)=>new Promise((Q,P)=>{l.emit("chat:send",{text:U,tts:R},(ie={})=>{ie.error?P(new Error(ie.error)):Q(ie)})}),[l]),z=m.useCallback((U,R={})=>{(R?.target==="hud"?"hud":"panel")==="hud"?N.current=U:y.current=U},[]),K=m.useCallback(()=>{b(!0),(N.current||y.current)?.focus()},[]),Z=m.useCallback(()=>{b(!1),N.current?.blur(),y.current?.blur()},[]),ae=m.useCallback(()=>b(!0),[]),ue=m.useCallback(()=>b(!1),[]),le=m.useMemo(()=>({messages:d,sendMessage:F,focusChat:K,blurChat:Z,registerInputRef:z,onInputFocus:ae,onInputBlur:ue,setTypingActive:O,typing:x,isChatFocused:g,selfSocketId:i?.socketId||null}),[Z,K,g,d,ue,ae,z,F,i?.socketId,O,x]);return r.jsx(Zx.Provider,{value:le,children:a})}function Xf(){const a=m.useContext(Zx);if(!a)throw new Error("useChat must be used inside ChatProvider");return a}let Jx=!1;function Xu(a){Jx=!!a}function Tp(){return Jx}const SA=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function Ix(a){if(!a||a.nodeType!==1)return!1;const l=a.tagName;if(l==="TEXTAREA"||a.isContentEditable)return!0;if(l!=="INPUT")return!1;const i=a.type?a.type.toLowerCase():"";return SA.has(i)}function AA(){return typeof document>"u"?!1:Ix(document.activeElement)}const Fu="keyboard",Qu={x:0,y:0,boost:!1},Ku={main:0,side:0,vacuum:0},Dp=Yf[0],_p=Yf[1],Ff=5,oi=500,ci=1,Qf=100;function Zu(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}function jA(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(Ff,Math.min(oi,i)):l}function Wx(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(ci,Math.min(Qf,i)):l}function NA(a){const i=(Wx(a,a)-ci)/(Qf-ci),o=oi-i*(oi-Ff);return Math.round(o)}function wA(a){const l=jA(a,a),i=(oi-l)/(oi-Ff),o=ci+i*(Qf-ci);return Math.round(o)}function CA(a){return Ix(a?.target)}function lt(a,l){if(!a||a.size===0)return!1;for(const i of l)if(a.has(i))return!0;return!1}function EA(a,l){const i=lt(l.driveForward,a),o=lt(l.driveBackward,a),f=lt(l.driveLeft,a),d=lt(l.driveRight,a),h=lt(l.boostModifier,a),x=lt(l.slowModifier,a);let p=0;i&&!o?p=1:o&&!i&&(p=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const b=x?.4:1;return{x:g*b,y:p*b,boost:h&&!x}}function kA(a,l){if(lt(l.auxAllForward,a))return{main:127,side:127,vacuum:127};const o=lt(l.auxMainForward,a)?127:lt(l.auxMainReverse,a)?-127:0,f=lt(l.auxSideForward,a)?127:lt(l.auxSideReverse,a)?-70:0,d=lt(l.auxVacuumFast,a)?127:lt(l.auxVacuumSlow,a)?50:0;return{main:o,side:f,vacuum:d}}function qA(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:x,toggleNightVision:p,startHorn:g,stopHorn:b,setMicPttActive:y,setSongNote:N,sendSong:q}}=Et(),{session:C,homeAssistantSetState:w}=Te(),{focusChat:j,blurChat:k,isChatFocused:S}=Xf(),{value:M}=We("inputs",An),T=m.useMemo(()=>dA(a.keymap),[a.keymap]),L=m.useMemo(()=>{const re=new Set;return Object.values(T).forEach(ce=>{ce&&ce.forEach(xe=>re.add(xe))}),re},[T]),H=m.useMemo(()=>{const re=An.keyboard,ce=M?.keyboard??{};return{baseSpeed:Zu(ce.baseSpeed,re.baseSpeed),turboSpeed:Zu(ce.turboSpeed,re.turboSpeed),precisionSpeed:Zu(ce.precisionSpeed,re.precisionSpeed)}},[M?.keyboard]),O=m.useMemo(()=>{const re=An.keyboard,ce=M?.keyboard??{},xe=Wx(typeof ce.tiltSpeed=="number"?ce.tiltSpeed:typeof ce.tiltIntervalMs=="number"?wA(ce.tiltIntervalMs):re.tiltSpeed,re.tiltSpeed);return NA(xe)},[M?.keyboard]),F=m.useMemo(()=>Math.abs(a.camera?.config?.nudgeDegrees||1),[a.camera?.config?.nudgeDegrees]),z=m.useRef(new Set),K=m.useRef(Qu),Z=m.useRef(Ku),ae=m.useRef(null),ue=m.useRef(null),le=m.useRef(!1),U=m.useCallback(()=>{const re=new Set(z.current);lt(T.boostModifier,re);const xe=lt(T.slowModifier,re)?{baseSpeed:H.precisionSpeed,boostSpeed:H.precisionSpeed}:{baseSpeed:H.baseSpeed,boostSpeed:H.turboSpeed},pe=EA(re,T),ge=kA(re,T);(pe.x!==K.current.x||pe.y!==K.current.y||pe.boost!==K.current.boost)&&(K.current=pe,i(pe,{source:Fu,speedOptions:xe})),(ge.main!==Z.current.main||ge.side!==Z.current.side||ge.vacuum!==Z.current.vacuum)&&(Z.current=ge,o(ge)),x(Fu,{keys:Array.from(re),vector:pe,aux:ge})},[T,H,x,o,i]),R=m.useCallback(()=>{ae.current&&(clearTimeout(ae.current),ae.current=null)},[]),Q=m.useCallback(()=>{const re=new Set(z.current),ce=lt(T.cameraUp,re),xe=lt(T.cameraDown,re);return(ce?1:0)-(xe?1:0)},[T]),P=m.useCallback(()=>{if(Q()===0){R();return}if(ae.current)return;const ce=()=>{const xe=Q();if(xe===0){R();return}f(xe*F),ae.current=setTimeout(ce,O)};ae.current=setTimeout(ce,0)},[Q,f,O,F,R]),ie=m.useCallback(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),oe=m.useCallback(()=>{const re=new Set(z.current),ce=lt(T.songNoteUp,re),xe=lt(T.songNoteDown,re);return(ce?1:0)-(xe?1:0)},[T]),E=m.useCallback(re=>{if(re===0)return;let xe=(typeof a.song?.note=="number"?a.song.note:Jl)+re;xe>_p?xe=Dp:xe<Dp&&(xe=_p);const pe=N(xe);q([{note:pe,duration:yf}],{slot:0})},[q,N,a.song?.note]),V=m.useCallback(()=>{if(oe()===0){ie();return}if(ue.current)return;const ce=()=>{const xe=oe();if(xe===0){ie();return}E(xe),ue.current=setTimeout(ce,PS)};ue.current=setTimeout(ce,0)},[oe,ie,E]),te=m.useCallback(()=>{z.current.clear(),K.current=Qu,Z.current=Ku,R(),ie(),le.current&&(le.current=!1,b()),y(!1),h(),x(Fu,{keys:[],vector:Qu,aux:Ku})},[x,y,h,b,R,ie]),ne=m.useCallback(re=>{const ce=C?.homeAssistant;if(!ce?.enabled||!ce?.connected)return;const pe=(ce.entities||[]).filter(ge=>(ge.type==="light"||ge.type==="switch")&&ge.available!==!1&&ge.state!=="unavailable");if(pe.length!==0){if(re==="on"){const ge=pe.find(ze=>ze.state!=="on");ge&&w(ge.id,"on").catch(()=>{});return}if(re==="off")for(let ge=pe.length-1;ge>=0;ge-=1){const ze=pe[ge];if(ze.state==="on"){w(ze.id,"off").catch(()=>{});break}}}},[w,C?.homeAssistant]);m.useEffect(()=>{function re(pe){if(Tp()||CA(pe))return;const ge=kp(pe);if(ge.length===0)return;const ze=new Set(ge);if(lt(T.chatFocus,ze)){pe.preventDefault(),te(),S||j();return}ge.some(se=>L.has(se))&&pe.preventDefault();const Y=ge.filter(se=>!z.current.has(se));if(Y.forEach(se=>z.current.add(se)),Y.length>0)if(Y.some(se=>T.driveMacro?.has(se)))l("drive"),d("drive-sequence");else if(Y.some(se=>T.dockMacro?.has(se)))l("dock"),d("seek-dock");else if(Y.some(se=>T.nightVisionToggle?.has(se)))p();else if(Y.some(se=>T.hornHonk?.has(se))){if(!le.current){const se=g();le.current=!!se}}else Y.some(se=>T.micPtt?.has(se))?y(!0):Y.some(se=>T.homeAssistantOn?.has(se))?ne("on"):Y.some(se=>T.homeAssistantOff?.has(se))&&ne("off");P(),V(),U()}function ce(pe){if(Tp())return;kp(pe).forEach(ze=>z.current.delete(ze)),le.current&&!lt(T.hornHonk,z.current)&&(le.current=!1,b()),lt(T.micPtt,z.current)||y(!1),P(),V(),U()}function xe(){te()}return window.addEventListener("keydown",re,{capture:!0}),window.addEventListener("keyup",ce,{capture:!0}),window.addEventListener("blur",xe),()=>{window.removeEventListener("keydown",re,{capture:!0}),window.removeEventListener("keyup",ce,{capture:!0}),window.removeEventListener("blur",xe)}},[L,k,U,P,V,j,S,T.chatFocus,T.dockMacro,T.driveMacro,T.hornHonk,T.micPtt,te,d,y,l,h,ie,g,b,ne]);const de=m.useRef(te);return m.useEffect(()=>{de.current=te},[te]),m.useEffect(()=>{de.current()},[a.roverId]),m.useEffect(()=>{le.current=!!a.horn?.active},[a.horn?.active]),m.useEffect(()=>()=>{R(),ie()},[R,ie]),null}const MA=1.6;function Px(a){if(!a)return"unknown::none::0::0";const l=a.id||"unknown",i=a.mapping||"none",o=Array.isArray(a.axes)?a.axes.length:0,f=Array.isArray(a.buttons)?a.buttons.length:0;return`${l}::${i}::${o}::${f}`}function RA(a){return JSON.parse(JSON.stringify(a??{}))}function eg(a,l){const i=RA(l);return i.meta={id:a?.id??"Unknown",mapping:a?.mapping??"none",axes:a?.axes?.length??0,buttons:a?.buttons?.length??0},i}function Ja(a){return Number.isFinite(a)?Math.max(-1,Math.min(1,a)):0}function ei(a,l){if(!a)return 0;const i=Math.abs(a);return l==="expo"?Math.sign(a)*Math.pow(i,MA):a}function Ju(a,l){const i=Math.abs(a);if(i<=l)return 0;const o=(i-l)/(1-l);return Math.sign(a)*o}function TA(a,l,i){const o=Math.hypot(a,l);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:a*d,y:l*d}}function ao(a,l){if(!a||!Array.isArray(a.axes))return null;const i=a.axes[l];return Number.isFinite(i)?Ja(i):null}function Af(a,l){if(!a||!Array.isArray(a.buttons))return null;const i=a.buttons[l];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function Iu(a,l=[]){for(const i of l)if(i){if(i.kind==="axis"){const o=ao(a,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=Af(a,i.index);if(!o)continue;return{value:Ja(o.value),source:i}}}return{value:0,source:null}}function DA(a,l=[]){for(const i of l){if(!i||i.kind!=="axisPair")continue;const o=ao(a,i.x),f=ao(a,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function Qa(a,l=[]){for(const i of l)if(i){if(i.kind==="button"){const o=Af(a,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=ao(a,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=Af(a,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function tg(a,l){const i=l?.bindings??{},o=l?.calibration??{},f=i.drive??{},d=DA(a,f.sources);let h=Ja(d.x),x=Ja(d.y);const p=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=TA(h,x,p);h=ei(g.x,o.driveCurve),x=ei(g.y,o.driveCurve);const b=i.cameraTilt??{},y=Iu(a,b.sources),N=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let q=Ju(Ja(y.value),N);q=ei(q,o.cameraCurve);const C=Math.min(Math.max(o.auxDeadzone??.05,0),.6),w=i.mainBrush??{},j=Iu(a,w.sources);let k=Ju(Ja(j.value),C);k=ei(k,o.auxCurve);const S=i.sideBrush??{},M=Iu(a,S.sources);let T=Ju(Ja(M.value),C);T=ei(T,o.auxCurve);const L=Qa(a,i.vacuum?.sources),H=Qa(a,i.allAux?.sources),O=Qa(a,i.mainReverse?.sources),F=Qa(a,i.sideReverse?.sources),z=Qa(a,i.driveMacro?.sources),K=Qa(a,i.dockMacro?.sources),Z=Qa(a,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:x,boost:!1},cameraAxis:q,auxAxis:{main:k,side:T},buttons:{vacuum:L.pressed,allAux:H.pressed,mainReverse:O.pressed,sideReverse:F.pressed,driveMacro:z.pressed,dockMacro:K.pressed,nightVisionToggle:Z.pressed},sources:{drive:d.source,cameraTilt:y.source,mainBrush:j.source,sideBrush:M.source,vacuum:L.source,allAux:H.source,mainReverse:O.source,sideReverse:F.source,driveMacro:z.source,dockMacro:K.source,nightVisionToggle:Z.source}}}const Wr=new Set;let Kl=null,lo={pads:[],timestamp:0};function _A(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const a=navigator.getGamepads();return a?Array.from(a).filter(Boolean):[]}function OA(a){return{index:a.index,id:a.id,mapping:a.mapping,connected:a.connected!==!1,timestamp:a.timestamp,axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0})),signature:Px(a)}}function BA(){lo={pads:_A().map(OA),timestamp:typeof performance<"u"?performance.now():Date.now()},Wr.forEach(l=>l(lo))}function ng(){BA(),Kl=requestAnimationFrame(ng)}function LA(){Kl||(Kl=requestAnimationFrame(ng))}function zA(){Kl&&(cancelAnimationFrame(Kl),Kl=null)}function ag(a){return Wr.add(a),LA(),a(lo),()=>{Wr.delete(a),Wr.size===0&&zA()}}function UA(){const[a,l]=m.useState(lo);return m.useEffect(()=>ag(l),[]),a}const Yl="gamepad",Ka={x:0,y:0,boost:!1},Za={main:0,side:0,vacuum:0},HA=100,VA=100;function Wu(a,l){return a&&l&&a.x===l.x&&a.y===l.y&&a.boost===l.boost}function Pu(a,l){return a&&l&&a.main===l.main&&a.side===l.side&&a.vacuum===l.vacuum}function $A(a){return a?Math.hypot(a.x||0,a.y||0):0}function GA(a){return a?!a.main&&!a.side&&!a.vacuum:!0}function YA(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function XA(){const{state:a,actions:{setMode:l,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:x}}=Et(),{value:p,save:g}=We("gamepad",wa),b=m.useRef(new Set),y=m.useRef(Ka),N=m.useRef(Za),q=m.useRef({main:!1,side:!1}),C=m.useRef(new Map),w=m.useRef(0),j=m.useRef(0),k=m.useRef(0),S=m.useRef(null),M=m.useCallback(O=>{const F=O.signature??Px(O);p?.profiles?.[F]||b.current.has(F)||(b.current.add(F),g(z=>{const K=z??wa;if(K.profiles?.[F])return K;const Z=K?.defaults?.profile??In,ae=eg(O,Z);return{...K,profiles:{...K.profiles??{},[F]:ae}}}))},[p?.profiles,g]),T=m.useCallback((O,F)=>{const z=C.current.get(O)||!1;return C.current.set(O,F),F&&!z},[]),L=m.useCallback((O,F)=>{const z=a.camera?.config;if(!z)return;const K=typeof performance<"u"?performance.now():Date.now(),Z=F?.cameraMode??"absolute",ae=Math.max(1,Math.min(180,F?.cameraSensitivity??60));if(Z==="velocity"){const Q=Math.min(50,K-k.current||16),P=O*ae*(Q/1e3);if(Math.abs(P)<.01)return;const oe=(typeof S.current=="number"?S.current:typeof a.camera?.angle=="number"?a.camera.angle:typeof z.homeAngle=="number"?z.homeAngle:0)+P;f(oe),S.current=oe,k.current=K;return}const ue=typeof z.minAngle=="number"?z.minAngle:-45,le=typeof z.maxAngle=="number"?z.maxAngle:45,U=typeof z.homeAngle=="number"?z.homeAngle:(ue+le)/2,R=O<0?U+O*(U-ue):U+O*(le-U);typeof S.current=="number"&&Math.abs(S.current-R)<.35&&K-k.current<80||(k.current=K,S.current=R,f(R))},[f,a.camera?.angle,a.camera?.config]),H=m.useMemo(()=>p?.activeSignature??null,[p?.activeSignature]);return m.useEffect(()=>ag(O=>{const F=YA(O.pads,H);if(!F){Wu(y.current,Ka)||(y.current=Ka,i(Ka,{source:Yl})),Pu(N.current,Za)||(N.current=Za,o(Za)),C.current=new Map,q.current={main:!1,side:!1},w.current=0,j.current=0,x(Yl,{connected:!1});return}if(AA()){Wu(y.current,Ka)||(y.current=Ka,i(Ka,{source:Yl})),Pu(N.current,Za)||(N.current=Za,o(Za)),C.current=new Map,q.current={main:!1,side:!1},x(Yl,{connected:!0,blocked:!0});return}M(F);const z=F.signature,K=p?.profiles?.[z]??p?.defaults?.profile??In,Z=tg(F,K);if(!Wu(Z.driveVector,y.current)){const P=typeof performance<"u"?performance.now():Date.now();($A(Z.driveVector)<.02||P-w.current>=HA)&&(y.current=Z.driveVector,w.current=P,i(Z.driveVector,{source:Yl}))}const ae=K.calibration?.auxSideScale??.55,ue=Math.round(Math.min(Math.abs(Z.auxAxis.main),1)*127),le=Math.round(Math.min(Math.abs(Z.auxAxis.side),1)*127),U=q.current.main?-ue:ue,R=q.current.side?-Math.round(le*ae):Math.round(le*ae);let Q={main:Z.auxAxis.main!==0?U:0,side:Z.auxAxis.side!==0?R:0,vacuum:Z.buttons.vacuum?127:0};if(Z.buttons.allAux&&(Q={main:127,side:127,vacuum:127}),!Pu(Q,N.current)){const P=typeof performance<"u"?performance.now():Date.now();(GA(Q)||P-j.current>=VA)&&(N.current=Q,j.current=P,o(Q))}Z.buttons.mainReverse&&T("mainReverse",!0)?q.current.main=!q.current.main:Z.buttons.mainReverse||T("mainReverse",!1),Z.buttons.sideReverse&&T("sideReverse",!0)?q.current.side=!q.current.side:Z.buttons.sideReverse||T("sideReverse",!1),Z.buttons.driveMacro&&T("driveMacro",!0)?(l("drive"),d("drive-sequence")):Z.buttons.driveMacro||T("driveMacro",!1),Z.buttons.dockMacro&&T("dockMacro",!0)?(l("dock"),d("seek-dock")):Z.buttons.dockMacro||T("dockMacro",!1),Z.buttons.nightVisionToggle&&T("nightVisionToggle",!0)?h():Z.buttons.nightVisionToggle||T("nightVisionToggle",!1),Math.abs(Z.cameraAxis)>.001&&L(Z.cameraAxis,K.calibration),x(Yl,{connected:!0,signature:z,id:F.id,index:F.index,axes:F.axes,buttons:F.buttons,drive:Z.driveVector,aux:Q,cameraAxis:Z.cameraAxis,bindings:Z.sources})}),[H,M,p?.defaults?.profile,p?.profiles,T,L,x,d,o,i,l,h]),null}function lg(a){const l=a?.sensors||{},i=l.oiMode?.label||"Unknown",o=i.toLowerCase(),f=l.chargingState?.label||"",d=!!l.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function sg(a){const l=ns(a);return m.useMemo(()=>lg(l),[l])}function Xl({label:a,value:l,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:l})})}function Op({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function ef({label:a,tone:l}){const i=l==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":l==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:a})}function FA({instructions:a,onConfirm:l,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:a.summary}),r.jsx(jf,{steps:a.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick:l,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function ig({layout:a="desktop",expand:l=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=a==="mobile",{state:{roverId:h,keymap:x},actions:p}=Et(),g=ns(h),b=o??lg(g),{driving:y,docked:N,charging:q,dockingInProgress:C}=b,[w,j]=m.useState(null),[k,S]=m.useState(!1),[M,T]=m.useState(!1),L=!h||w!==null,H=!h||w!==null,O=jn(x?.driveMacro?.[0]),F=jn(x?.dockMacro?.[0]),z={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},K="Click this button to initate auto-dock.",Z={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},ae=N?"Docked":"Undocked",ue=N?"good":"bad",le=q?"Charging":N?"Charging in 5s":"—",U=q?"good":N?"warn":"bad",R=async()=>{if(!(!h||w)){j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(Se){alert(Se.message)}finally{j(null)}}},Q=async()=>{if(!(!h||w)){S(!1),T(!1),j("drive");try{p.setMode("drive"),await p.runMacro("drive-sequence")}catch(Se){alert(Se.message)}finally{j(null)}}},P=async()=>{if(!(!h||w)){j("dock");try{p.setMode("dock"),await p.runMacro("seek-dock")}catch(Se){alert(Se.message)}finally{j(null),S(!1),T(!1)}}},ie=()=>{H||(T(!0),S(!0))},oe="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",E="text-center",V="items-center justify-between",te="items-center justify-center",ne=d?"text-sm font-semibold":"",de="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",re="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ce="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",xe="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ge=l||C,ze=ge?"h-full flex-1":i?"flex-1":"",Y=d&&!ge?f:"",se=d&&!ge?te:V,he=d&&!ge&&y&&N;if(!y&&!C)return r.jsxs("button",{type:"button",onClick:Q,onContextMenu:Se=>Se.preventDefault(),disabled:L,className:`${oe} ${ze} ${Y} ${E} ${se} ${ne} ${de}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&ge?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[O?r.jsx(Op,{label:O}):null,r.jsx(ef,{label:"Click to start",tone:"emerald"})]}):null]}),ge?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:Z.summary}),r.jsx(jf,{steps:Z.steps,tone:"emerald"})]}):null]}),ge?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Xl,{label:"Dock",value:ae,tone:ue}),r.jsx(Xl,{label:"Charge",value:le,tone:U})]}):null]});if(C){const Se={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:L,onClick:R,onContextMenu:Ye=>Ye.preventDefault(),className:`${oe} ${ze} ${Y} ${E} ${se} ${ne} ${re}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),ge?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(ef,{label:"Return to driving mode",tone:"emerald"})}):null]}),ge?r.jsx("p",{className:"text-sm text-amber-50/90",children:Se.summary}):null]}),ge?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Xl,{label:"Dock",value:ae,tone:ue}),r.jsx(Xl,{label:"Charge",value:le,tone:U})]}),d?null:r.jsx(jf,{steps:Se.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:H,onClick:ie,onContextMenu:Se=>Se.preventDefault(),className:d?`flex w-full ${oe} ${Y} ${E} ${se} ${ne} ${he?xe:ce}`:`${oe} ${ze} ${E} ${V} ${ne} ${ce}`,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:he?"Docked!":"Dock and Charge"}),!d&&ge?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[F?r.jsx(Op,{label:F}):null,r.jsx(ef,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&ge&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:K}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(Xl,{label:"Dock",value:ae,tone:ue}),r.jsx(Xl,{label:"Charge",value:le,tone:U})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),M||!d&&k?r.jsx(FA,{instructions:z,pending:w==="dock",onCancel:()=>{T(!1),S(!1)},onConfirm:P}):null]})}function jf({steps:a,tone:l="emerald"}){const i=l==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":l==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=l==="emerald"?"text-emerald-200":l==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:a.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<a.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function tf(a){return typeof a=="boolean"}function rg({nightVisionOn:a,disabled:l,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,x]=m.useState(tf(a)?a:null);m.useEffect(()=>{tf(a)&&x(a)},[a]);const p=tf(h),g=p?h:!1,b=p?g?"On":"Off":"—",y=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",N=()=>{if(l)return;const C=p?!g:!0;x(C),i?.(C)},q=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:N,onContextMenu:C=>C.preventDefault(),disabled:l,"aria-pressed":g,className:q,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${y}`,children:b})]})}function nf(a){const l=Number(a);return!Number.isFinite(l)||l<=0?0:Math.min(5e3,Math.round(l))}function og({disabled:a,onStart:l,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:x=!0,showSettingsToggle:p=!1,compactSettings:g=!1}){const[b,y]=m.useState(!1),[N,q]=m.useState(x),{value:C,save:w}=We("horn",Ia),[j,k]=m.useState(C?.waveform||Ia.waveform),[S,M]=m.useState(()=>[...Array.isArray(C?.freqs)?C.freqs:Ia.freqs,0,0,0,0].slice(0,4).map(R=>nf(R)));m.useEffect(()=>{k(C?.waveform||Ia.waveform),Array.isArray(C?.freqs)&&M([...C.freqs,0,0,0,0].slice(0,4).map(U=>nf(U)))},[C?.freqs,C?.waveform]);const T=!!f,L=Math.max(0,Math.min(1,Number(d)||0)),H=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",T?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,T]),O=()=>{a||b||(y(!0),l?.())},F=()=>{b&&(y(!1),i?.())};m.useEffect(()=>{!T&&b&&y(!1)},[T,b]);const z=j==="sine"?"sine":"saw",K=m.useCallback(U=>{const R=U.target.value==="sine"?"sine":"saw";k(R),w(Q=>({...Q??{},waveform:R}))},[w]),Z=m.useCallback((U,R)=>{M(Q=>{const P=[...Q];return P[U]=nf(R),w(ie=>({...ie??{},freqs:P})),P})},[w]),ae=U=>{if(a)return;const R=U.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||(U.preventDefault(),O())},ue=U=>{const R=U.target?.tagName?.toLowerCase();R==="input"||R==="select"||R==="option"||R==="label"||R==="button"||(U.preventDefault(),F())},le=p?r.jsx("button",{type:"button",onClick:U=>{U.preventDefault(),q(R=>!R)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:N?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":b,onPointerDown:ae,onPointerUp:ue,onPointerLeave:F,onPointerCancel:F,onContextMenu:U=>U.preventDefault(),onBlur:F,className:H,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${L*100}%, rgba(0,0,0,0) ${L*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${T?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),le,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${T?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:T?"Honk":"Hold"})]}),N?g?r.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:K,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:S.map((U,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:U,onChange:Q=>Z(R,Q.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:K,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"})]})]}),S.map((U,R)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:R+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:U,onChange:Q=>Z(R,Q.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${R}`))]}):null]})}function Hr(a){return typeof a!="number"||Number.isNaN(a)?"—":`${a>0?"+":""}${a.toFixed(1)}°`}function Bp({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function cg({value:a,min:l,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:x,throttleMs:p=0,disabled:g=!1,keyDownLabel:b,keyUpLabel:y,className:N="",labelRowClass:q="",labelClass:C="",valueClass:w="",sliderClass:j="",endpointClass:k="",endpointLabelClass:S="",accentClass:M="",showValue:T=!0,showEndpoints:L}){const H=d==="vertical",F=typeof L=="boolean"?L:!H,[z,K]=m.useState(a),Z=m.useRef(!1),ae=m.useRef(null);m.useEffect(()=>{Z.current||K(a)},[a]),m.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);const ue=P=>{if(h){if(p>0){ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{h(P)},p);return}h(P)}},le=P=>{const ie=Number.parseFloat(P.target.value);Number.isNaN(ie)||(Z.current=!0,K(ie),ue(ie))},U=()=>{Z.current=!1,ae.current&&(clearTimeout(ae.current),ae.current=null),x?x(z):p>0&&h?.(z)};if(typeof l!="number"||typeof i!="number")return null;const R=[H?"h-28 w-5":"w-full",M,j].filter(Boolean).join(" "),Q=r.jsx("input",{type:"range",orient:H?"vertical":void 0,min:l,max:i,step:o,value:Number.isFinite(z)?z:l,onChange:le,onMouseUp:U,onTouchEnd:U,onPointerUp:U,disabled:g,className:R,style:H?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return H?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${N}`.trim(),children:[T?r.jsx("div",{className:`flex flex-col items-center ${q}`.trim(),children:r.jsx("span",{className:w,children:Hr(a)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:C,children:f}),Q]})]}):r.jsxs("div",{className:`space-y-0.5 ${N}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${q}`.trim(),children:[r.jsx("span",{className:C,children:f}),T?r.jsx("span",{className:w,children:Hr(a)}):null]}),r.jsxs("div",{children:[Q,F?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${k}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${S}`.trim(),children:[b?r.jsx(Bp,{label:b}):null,Hr(l)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${S}`.trim(),children:[Hr(i),y?r.jsx(Bp,{label:y}):null]})]}):null]})]})}const Vr="mobile-joystick",QA=80,KA=.15,ZA={main:0,side:0,vacuum:0},JA={main:127,side:127,vacuum:127},IA={main:-127,side:-127,vacuum:-127};function WA({disabled:a,layout:l,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),x=m.useRef({x:0,y:0}),[p,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),b=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),y=m.useCallback(w=>{if(a||h.current!==null)return;w.preventDefault();const j=d.current;if(!j)return;const k=j.getBoundingClientRect(),S=w.clientX-k.left,M=w.clientY-k.top;x.current={x:S,y:M},h.current=w.pointerId,j.setPointerCapture?.(w.pointerId),g({active:!0,base:{x:S,y:M},knob:{x:0,y:0}})},[a]),N=m.useCallback(w=>{if(a||h.current!==w.pointerId)return;w.preventDefault();const j=d.current;if(!j)return;const k=j.getBoundingClientRect(),S=w.clientX-k.left,M=w.clientY-k.top,T=S-x.current.x,L=M-x.current.y,H=Math.min(Math.hypot(T,L),i),O=Math.atan2(L,T),F=Math.cos(O)*H,z=Math.sin(O)*H,K={x:Wl(F/i),y:Wl(-z/i),boost:!1};g(Z=>({...Z,knob:{x:F,y:z}})),o?.(K)},[a,o]),q=m.useCallback(w=>{if(h.current!==w.pointerId)return;w.preventDefault(),d.current?.releasePointerCapture?.(w.pointerId),b()},[b]);return m.useEffect(()=>{a&&b()},[a,b]),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:N,onPointerUp:q,onPointerLeave:q,onPointerCancel:q,onContextMenu:w=>w.preventDefault(),children:[!p.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),p.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:p.base.x,top:p.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:p.base.x+p.knob.x,top:p.base.y+p.knob.y}})]})]})}function PA({layout:a}){const{state:{roverId:l},actions:{setDriveVector:i,registerInputState:o}}=Et(),f=sg(l),d=f.docked&&!f.driving,h=d||f.dockingInProgress,x=!l,p=QA,g=KA,b=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{x&&(b.current={x:0,y:0,boost:!1})},[x]);const y=m.useCallback((w={})=>{if(x)return;const j={x:Wl(w.x??0),y:Wl(w.y??0),boost:!!w.boost},k={x:b.current.x+(j.x-b.current.x)*(1-g),y:b.current.y+(j.y-b.current.y)*(1-g),boost:j.boost};b.current=k,i(k,{source:Vr}),o(Vr,{vector:k,lastEvent:"move"})},[x,o,i,g]),N=m.useCallback(()=>{if(x)return;const w={x:0,y:0,boost:!1};b.current=w,i(w,{source:Vr}),o(Vr,{vector:w,lastEvent:"stop"})},[x,o,i]),C=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:C,children:[r.jsx(ig,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(WA,{disabled:x,layout:a,radius:p,onMove:y,onStop:N})})]})}function Lp({id:a,label:l,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:x=>{x.preventDefault(),d(a,i)},onPointerUp:()=>h(a),onPointerLeave:()=>h(a),onPointerCancel:()=>h(a),onContextMenu:x=>x.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:l})}function ej({layout:a}){const{state:{roverId:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:x,startHorn:p,stopHorn:g}}=Et(),b=!l,y=m.useRef(null),N=i?.config,q=!!(l&&i?.enabled&&N),C=!!(l&&f?.nightVision),w=f?.nightVisionState,j=!!(l&&f?.horn),k=o?.overheated,S=typeof N?.minAngle=="number"?N.minAngle:-45,M=typeof N?.maxAngle=="number"?N.maxAngle:45,T=typeof i?.angle=="number"?i.angle:typeof N?.homeAngle=="number"?N.homeAngle:(S+M)/2,L=m.useCallback(F=>{C&&h(F)},[C,h]),H=m.useCallback((F,z)=>{b||(y.current=F,x(z))},[b,x]),O=m.useCallback(F=>{b||y.current===F&&(y.current=null,x(ZA))},[b,x]);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(Lp,{id:"aux-vac-forward",label:"Vacuum Forward",values:JA,color:"bg-fuchsia-600",disabled:b,onPress:H,onRelease:O}),r.jsx(Lp,{id:"aux-vac-backward",label:"Vacuum Backward",values:IA,color:"bg-fuchsia-800",disabled:b,onPress:H,onRelease:O})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[q?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(cg,{value:T,min:S,max:M,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,C?r.jsx(rg,{nightVisionOn:w?.nightVisionOn,disabled:b,onToggle:L,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:j?r.jsx(og,{disabled:b||k,onStart:p,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function ug({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(ej,{layout:a})})}function fg({layout:a,className:l=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${l}`.trim(),children:r.jsx(PA,{layout:a==="landscape"?"landscape":"portrait"})})}function tj(){const a="h-[min(60svh,24rem)]";return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r.jsx(ug,{layout:"portrait",className:a}),r.jsx(fg,{layout:"portrait",className:a})]})})}function nj(a=[],l={}){const i=En(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),x=m.useRef(new Map),p=m.useMemo(()=>a.map(C=>typeof C=="string"?C:C.id),[a]),g=m.useMemo(()=>{const C=p.join("|");return f?`${C}|v:${f}`:C},[p,f]),b=m.useRef([]),[y,N]=m.useState(0),q=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>N(w=>w+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{b.current=p},[g,p]),m.useEffect(()=>{x.current.forEach(C=>URL.revokeObjectURL(C)),x.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){x.current.forEach(S=>URL.revokeObjectURL(S)),x.current.clear(),h({});return}if(!b.current.length||!i)return;let C=!1;const w=b.current,j=(S={},M)=>{if(C||!S.id||!M)return;const T=M.byteLength??M.length??0,L=Date.now(),H=q.current.get(S.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:H.count+1,totalBytes:H.totalBytes+T,lastLogAt:H.lastLogAt};if(!O.lastLogAt||L-O.lastLogAt>=1e4){const Z=O.count?O.totalBytes/O.count:0;console.log("[roomCamera]",S.id,`frame=${T}B`,`avg=${Math.round(Z)}B`,`count=${O.count}`),O.lastLogAt=L}q.current.set(S.id,O);const F=new Blob([M],{type:"image/jpeg"}),z=URL.createObjectURL(F),K=x.current.get(S.id);K&&URL.revokeObjectURL(K),x.current.set(S.id,z),h(Z=>({...Z,[S.id]:{status:"playing",ts:S.ts||Date.now(),error:null,objectUrl:z}}))},k=(S={})=>{C||!S.id||h(M=>({...M,[S.id]:{...M[S.id]||{},status:S.error?"error":M[S.id]?.status||"connecting",error:S.error||null,ts:S.ts||M[S.id]?.ts||null,objectUrl:M[S.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",j),i.on("roomCamera:status",k),i.emit("roomCamera:subscribe",{ids:w},(S={})=>{S.error}),()=>{C=!0,i.emit("roomCamera:unsubscribe",{ids:w}),i.off("roomCamera:frame",j),i.off("roomCamera:status",k),x.current.forEach(S=>URL.revokeObjectURL(S)),x.current.clear()}},[i,g,o,y]),d}function aj({feed:a,label:l}){const[i,o]=m.useState(!1);m.useEffect(()=>{a&&(!a.ts&&!a.objectUrl||o(d=>!d))},[a?.ts,a?.objectUrl]);const f=m.useMemo(()=>a?a.error?`Error: ${a.error}`:a.status||"Connecting…":"Connecting…",[a]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[a?.objectUrl?r.jsx("img",{src:a.objectUrl,alt:l,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:l}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function lj(){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 dg=["horizontal","vertical"];function af(a,l){return dg.includes(a)?a:l}function Kf({defaultOrientation:a="horizontal",orientation:l,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=Te(),h=d?.roomCameras||[],x=nj(h.map(j=>({id:j.id}))),{value:p,save:g}=We("roomCameraPanels",{}),[b,y]=m.useState(()=>af(f?p?.[f]:a,"horizontal"));m.useEffect(()=>{if(!f)return;const j=p?.[f];j&&y(af(j,"horizontal"))},[f,p?.[f]]);const N=l?af(l,"horizontal"):b,q=N==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!i&&!l&&h.length>0,w=j=>{y(j),f&&g(k=>({...k||{},[f]:j}))};return h.length===0?r.jsx(lj,{}):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:dg.map(j=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${N===j?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>w(j),children:j==="vertical"?"Vertical":"Grid"},j))})]})})]}),r.jsx("div",{className:q,children:h.map(j=>{const k=x[j.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(aj,{feed:k,label:j.name||j.id})},j.id)})})]})}function Zf(){const{logs:a}=Te();return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:a.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?r.jsx("p",{children:"No logs yet."}):a.slice().reverse().map(l=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:l.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",l.level,"]"]})," ",l.label&&r.jsxs("span",{className:"text-teal-400",children:["[",l.label,"]"]})," ",r.jsx("span",{children:l.message})]},l.id))})]})}function sj(a){if(!a)return null;if(typeof a=="string"){const l=String(a).trim();return l?{type:"rover",id:l,key:l}:null}if(typeof a=="object"){if(a.type&&a.id){const l=String(a.id);let i=a.key;return i||(i=a.type==="room"?`room:${l}`:l),{type:a.type,id:l,key:i}}if(a.roverId){const l=String(a.roverId);return{type:"rover",id:l,key:a.key||l}}if(a.roomCameraId){const l=String(a.roomCameraId);return{type:"room",id:l,key:a.key||`room:${l}`}}}return null}function ij(a=[]){const l=new Set,i=[];return a.forEach(o=>{!o?.key||l.has(o.key)||(l.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function ui(a=[],l={}){const i=En(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),x=m.useMemo(()=>Array.isArray(a)?ij(a.map(sj).filter(Boolean)):[],[a]),p=m.useMemo(()=>{const q=x.map(C=>`${C.type}:${C.id}:${C.key}`).join("|");return f?`${q}|v:${f}`:q},[x,f]),g=m.useRef([]),[b,y]=m.useState(0);return m.useEffect(()=>{if(!i)return;const q=()=>y(C=>C+1);return i.on("connect",q),()=>{i.off("connect",q)}},[i]),m.useEffect(()=>{g.current=x},[x]),m.useEffect(()=>{if(!p||!o){h({});return}const q=g.current;let C=!1;function w(j){const k=j.type==="room"?{roomCameraId:j.id}:{roverId:j.id};i.emit("video:request",k,(S={})=>{C||h(M=>({...M,[j.key]:S}))})}return q.forEach(j=>{w(j)}),()=>{C=!0}},[i,p,o,b]),m.useMemo(()=>{if(!p||!o)return{};const q={};return x.forEach(C=>{d[C.key]&&(q[C.key]=d[C.key])}),q},[p,d,x])}function Jf(a=[],l={}){const i=En(),{enabled:o=!0,version:f=null}=l,[d,h]=m.useState({}),x=m.useRef(new Map),p=m.useMemo(()=>a.map(C=>typeof C=="string"?C:C.id).filter(Boolean),[a]),g=m.useMemo(()=>{const C=p.join("|");return f?`${C}|v:${f}`:C},[p,f]),b=m.useRef([]),[y,N]=m.useState(0),q=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>N(w=>w+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{b.current=p},[g,p]),m.useEffect(()=>{x.current.forEach(C=>URL.revokeObjectURL(C)),x.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){x.current.forEach(S=>URL.revokeObjectURL(S)),x.current.clear(),h({});return}if(!b.current.length||!i)return;let C=!1;const w=b.current,j=(S={},M)=>{if(C||!S.id||!M)return;const T=M.byteLength??M.length??0,L=Date.now(),H=q.current.get(S.id)||{count:0,totalBytes:0,lastLogAt:0},O={count:H.count+1,totalBytes:H.totalBytes+T,lastLogAt:H.lastLogAt};if(!O.lastLogAt||L-O.lastLogAt>=1e4){const Z=O.count?O.totalBytes/O.count:0;console.log("[roverSnapshot]",S.id,`frame=${T}B`,`avg=${Math.round(Z)}B`,`count=${O.count}`),O.lastLogAt=L}q.current.set(S.id,O);const F=new Blob([M],{type:"image/jpeg"}),z=URL.createObjectURL(F),K=x.current.get(S.id);K&&URL.revokeObjectURL(K),x.current.set(S.id,z),h(Z=>({...Z,[S.id]:{status:"playing",ts:S.ts||Date.now(),error:null,objectUrl:z}}))},k=(S={})=>{C||!S.id||h(M=>({...M,[S.id]:{...M[S.id]||{},status:S.error?"error":M[S.id]?.status||"connecting",error:S.error||null,ts:S.ts||M[S.id]?.ts||null,objectUrl:M[S.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",j),i.on("roverSnapshot:status",k),i.emit("roverSnapshot:subscribe",{ids:w},(S={})=>{S.error}),()=>{C=!0,i.emit("roverSnapshot:unsubscribe",{ids:w}),i.off("roverSnapshot:frame",j),i.off("roverSnapshot:status",k),x.current.forEach(S=>URL.revokeObjectURL(S)),x.current.clear()}},[i,g,o,y]),d}const rj={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function oj(a){if(typeof btoa=="function")return btoa(a);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function cj(a){if(!a)return{};const l=`${a}:${a}`;return{Authorization:`Basic ${oj(l)}`}}class zp{constructor({url:l,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=l,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(l,i){typeof this.onStatus=="function"&&this.onStatus(l,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const l=new RTCPeerConnection(rj);this.pc=l;const i=new MediaStream;l.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?l.addTransceiver("audio",{direction:"recvonly"}):(l.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&l.addTransceiver("audio",{direction:"recvonly"})),l.onconnectionstatechange=()=>{this.notify(l.connectionState)},l.oniceconnectionstatechange=()=>{const o=l.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await l.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await l.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...cj(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await l.setRemoteDescription({type:"answer",sdp:d}),l.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(l=>l.track?.stop()),this.pc.getReceivers().forEach(l=>l.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function Nf({sensors:a={},variant:l="full",size:i,overlay:o=!1}){const f=i||(l==="mini"?190:260),d=f/2,h=f*.07,x=d,p=d+h,g=d*.8,b=g-4,y=g+4,N=g-14,q=g-6,C=g*.65,w=a?.bumpsAndWheelDrops||{},j=a?.wheelOvercurrents||{},k=a?.wheelLeftCurrentMa??0,S=a?.wheelRightCurrentMa??0,M=a?.sideBrushCurrentMa??0,T=a?.mainBrushCurrentMa??0,L=6,H=w.bumpLeft?L:0,O=w.bumpRight?L:0,F=xj({count:6,totalSpan:140,gap:6,startAngle:-70}),z=["L","FL","CL","CR","FR","R"],K=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],Z=F.map((U,R)=>({label:z[R],start:U.start,end:U.end,value:K[R]})),ae=[{label:"Cliff L",start:-60,end:-46,value:a?.cliffLeftSignal,active:a?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:a?.cliffFrontLeftSignal,active:a?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:a?.cliffFrontRightSignal,active:a?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:a?.cliffRightSignal,active:a?.cliffRight}],ue=K.filter(U=>U!=null),le=ue.length?Math.max(...ue,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–",le]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:x,cy:p,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(Up,{cx:x-C,cy:p,current:k,drop:w.wheelDropLeft,overcurrent:j.leftWheel,label:"L"}),r.jsx(Up,{cx:x+C,cy:p,current:S,drop:w.wheelDropRight,overcurrent:j.rightWheel,label:"R"}),r.jsx(dj,{cx:x+g*.65,cy:p-g*.55,current:M,overcurrent:j.sideBrush}),r.jsx(mj,{cx:x,cy:p,current:T,overcurrent:j.mainBrush,variant:l,dirtLeft:a?.dirtDetectLeft,dirtRight:a?.dirtDetect}),Z.map(U=>{const R=hj(U.value,le),Q=y+4,P=Q+28;return r.jsx(uj,{cx:x,cy:p,rBase:P,rTip:Q,startDeg:U.start,endDeg:U.end,color:R,value:U.value,max:le},U.label)}),ae.map(U=>{const R=pj(U.value,U.active);return r.jsx(lf,{cx:x,cy:p,rInner:N,rOuter:q,startDeg:U.start,endDeg:U.end,color:R,opacity:1,pulse:!!U.active},U.label)}),r.jsx(lf,{cx:x,cy:p,rInner:b-H,rOuter:y-H,startDeg:-70,endDeg:-6,color:w.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpLeft}),r.jsx(lf,{cx:x,cy:p,rInner:b-O,rOuter:y-O,startDeg:6,endDeg:70,color:w.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!w.bumpRight})]})]})}function lf({cx:a,cy:l,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:x=!1,opacity:p=1}){const g=(i+o)/2,b=o-i,y=fj(a,l,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:y,stroke:h,strokeWidth:b,strokeLinecap:"round",fill:"none",opacity:p}),x?r.jsx("path",{d:y,stroke:"#ef4444",strokeWidth:b,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function uj({cx:a,cy:l,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:x,max:p}){const g=(f+d)/2,b=si(a,l,o,g),y=fo(x!=null?x/(p||1):0),N=Math.pow(y,.35),q=i-(i-o)*N,C=si(a,l,q,f),w=si(a,l,q,d),j=`M ${b.x} ${b.y} L ${C.x} ${C.y} L ${w.x} ${w.y} Z`;return r.jsx("path",{d:j,fill:h,opacity:1,stroke:"none"})}function fj(a,l,i,o,f){let d=o,h=f;h<=d&&(h+=360);const x=si(a,l,i,d),p=si(a,l,i,h);return["M",x.x,x.y,"A",i,i,0,0,1,p.x,p.y].join(" ")}function si(a,l,i,o){const f=mg(o);return{x:a+i*Math.cos(f),y:l+i*Math.sin(f)}}function mg(a){return(a-90)*Math.PI/180}function If(a,l){if(l)return"#ef4444";const i=Math.abs(a);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function fo(a){return Math.max(0,Math.min(1,a))}function Up({cx:a,cy:l,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),x=fo(h/1200),p=If(i,f),g=56,b=14,y=9,N=3,q=g*x,C=d==="L"?-1:1,w=C*(-y/2-N/2),j=C*(b/2+N/2),k=b+y+N+2,S=g+4;return r.jsxs("g",{transform:`translate(${a},${l})`,children:[r.jsx("rect",{x:-k/2,y:-S/2,width:k,height:S,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:w-b/2,y:-g/2,width:b,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:w-b/2,y:g/2-q,width:b,height:q,fill:p,className:f?"animate-pulse":""}),r.jsx("rect",{x:j-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 dj({cx:a,cy:l,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=If(i*3,o),h=43,x=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${a}px ${l}px`,animation:x?`spin ${x}s linear infinite`:"none",animationDirection:x?"reverse":"normal"},children:[r.jsx("circle",{cx:a,cy:l,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const b=mg(g),y=a+h*Math.cos(b),N=l+h*Math.sin(b);return r.jsx("line",{x1:a,y1:l,x2:y,y2:N,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:a,cy:l,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function mj({cx:a,cy:l,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const x=Math.abs(i),p=If(i,o),g=1,b=96,y=12,N=`main-brush-pattern-a-${f}`,q=`main-brush-pattern-b-${f}`,C=x>0?.6:null,w=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[N,q].map((j,k)=>r.jsxs("pattern",{id:j,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:p,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),C?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${w*(k===0?6:-6)}`,dur:`${C}s`,repeatCount:"indefinite"}):null]},j))}),r.jsx("rect",{x:a-b/2,y:l-14,width:b,height:y,rx:"3",fill:`url(#${N})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:a-b/2,y:l+4,width:b,height:y,rx:"3",fill:`url(#${q})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:a-b/4,cy:l-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:a+b/4,cy:l+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:a-b/2-4,y:l-16,width:b+8,height:y*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function hj(a,l){if(a==null||a<=0)return"hsl(200 60% 18%)";const o=fo(a/(l||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function pj(a,l){if(l)return"#ef4444";const i=fo(a==null?0:a/4095),o=[47,55,69],f=[245,158,11],[d,h,x]=o.map((p,g)=>Math.round(p+(f[g]-p)*i));return`rgb(${d}, ${h}, ${x})`}function xj({count:a,totalSpan:l,gap:i,startAngle:o}){const d=(l-i*(a-1))/a,h=[];let x=o;for(let p=0;p<a;p+=1){const g=x+d;h.push({start:x,end:g}),x=g+i}return h}function hg(){const{value:a,save:l}=We("page",{hudMapDesktop:!1});return[!!a?.hudMapDesktop,f=>{l({hudMapDesktop:!!f})}]}const gj={discord:$x,kofi:Ap,"ko-fi":Ap,wiki:GS,throne:YS},vj={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 yj(){m.useEffect(()=>{if(typeof document>"u")return;const a="social-button-keyframes";if(document.getElementById(a))return;const l=document.createElement("style");l.id=a,l.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(l)},[])}function bj(a,l){return typeof a=="string"&&a.trim()?a.trim().toLowerCase():typeof l=="string"&&l.trim()?l.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function Wf({id:a,label:l,url:i,className:o=""}){if(!i)return null;yj();const f=bj(a,l),d=gj[f]||XS,h=vj[f]||null,x=l||a||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":x,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"}),x]})}const fi=10;function pg({batteryState:a=null,charge:l=null,config:i=null}){const o=a?.percentDisplay!=null&&Number.isFinite(a.percentDisplay)?Math.round(a.percentDisplay):null,f=a?.warnActive??null,d=a?.urgentActive??null,h=i?.Full??null,x=i?.Warn??null,p=i?.Urgent??null,g=l??a?.charge??null;let b=o;if(b==null&&(b=Sj({charge:g,full:h,warn:x,urgent:p})),b==null)return{available:!1};const y=Math.max(0,Math.min(1,b/100)),N=f??(x!=null&&g!=null&&g<=x),q=d??(p!=null&&g!=null&&g<=p);return{available:!0,percent:y,percentDisplay:b,warnActive:N,urgentActive:q,warnDisplayPercent:fi}}function Sj({charge:a,full:l,warn:i,urgent:o}){if(a!=null&&l!=null&&i!=null&&o!=null&&l>i&&i>o){const f=fi/100,d=1-f;if(a<=o)return 0;if(a<=i){const x=(a-o)/(i-o);return Math.round(Math.max(0,Math.min(1,x))*fi)}if(a>=l)return 100;const h=(a-i)/(l-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const Aj=1600,jj=800;function mn(...a){return a.filter(Boolean).join(" ")}function wf({visual:a,orientation:l="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",x=l==="vertical",p=f??!h;if(!a?.available){if(h){const ae=fi,ue=mn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!N&&"battery-tick-warn"),le=x?{bottom:`${ae}%`}:{left:`${ae}%`},U=mn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:U,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:ue,style:le})]})}return x?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=a.percentDisplay??0,b=Math.max(0,Math.min(100,g)),y=a.warnDisplayPercent??fi,N=!!a.urgentActive,q=!!a.warnActive,C=N?`${jj}ms`:q?`${Aj}ms`:void 0,j=h?N||q?"bg-red-500/45":"bg-emerald-500/45":N||q?"bg-red-500":"bg-emerald-500",k=N||q?"bg-red-900/35":"bg-slate-900/35",S=N||q?"bg-red-900/45":"bg-slate-900/35",M=mn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",x&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const ae=x?{height:`${b}%`}:{width:`${b}%`},ue=mn("absolute",x?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",N&&"battery-urgent-flash"),le=mn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!N&&"battery-tick-warn"),U=x?{bottom:`${y}%`}:{left:`${y}%`};return r.jsxs("div",{className:M,children:[r.jsx("div",{className:mn("absolute inset-0",k,N&&"battery-urgent-flash")}),r.jsx("div",{className:ue,style:{...ae,animationDuration:C}}),r.jsx("div",{className:le,style:U})]})}const T=mn("relative overflow-hidden rounded-sm border border-slate-800",N||q?S:"bg-zinc-900/90",N&&"battery-urgent-flash",x?"w-full flex-1":o?"h-4":"h-5"),L=x?{height:`${b}%`}:{width:`${b}%`},H=mn("absolute",x?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",j,"transition-[width,height]",N&&"battery-urgent-flash"),O=mn("absolute z-10",x?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",q&&!N&&"battery-tick-warn"),F=x?{bottom:`${y}%`}:{left:`${y}%`},z=`Battery ${g}%`,K=mn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",x?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Z=mn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:M,children:[r.jsxs("div",{className:T,children:[r.jsx("div",{className:H,style:{...L,animationDuration:C}}),r.jsx("div",{className:O,style:F})]}),p&&!x?r.jsx("div",{className:K,children:r.jsx("span",{className:Z,children:z})}):null,p&&x?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:Z,children:[g,"%"]})}):null]})}const Hp=2e3,Nj=3e3,wj=3e3,Cj=40,Ej=1e3;function di({sessionInfo:a,audioSessionInfo:l,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,forceMute:h=!1,telemetryFrame:x,batteryConfig:p,layoutFormat:g="desktop",hudVariant:b="default",driverLabel:y=null,hudForceMap:N=!1,hudMapPosition:q="top-center",hudLabelScale:C=1,fitParent:w=!1,overcurrentLimiter:j=null,showTurnCue:k=!1,turnTimerText:S=null,turnSeconds:M=null,isActiveDriver:T=!1,idleSkipSeconds:L=null}){const{session:H}=Te(),O=m.useRef(null),F=m.useRef(null),z=m.useRef(null),K=m.useRef(null),Z=m.useRef(null),ae=m.useRef(null),ue=m.useRef(null),le=m.useRef(null),[U,R]=m.useState("idle"),[Q,P]=m.useState(null),[ie,oe]=m.useState("idle"),[E,V]=m.useState(null),[te,ne]=m.useState(0),[de,re]=m.useState(0),[ce,xe]=m.useState(!0),pe=!!l?.url,ge=i==="snapshot",ze=x?.sensors,{value:Y}=We("audio",jt),se=Number.isFinite(Y?.masterVolume)?Y.masterVolume:jt.masterVolume,he=Number.isFinite(Y?.roverVolume)?Y.roverVolume:jt.roverVolume,Se=typeof Y?.mainBrushDuckEnabled=="boolean"?Y.mainBrushDuckEnabled:typeof Y?.autoLevelEnabled=="boolean"?Y.autoLevelEnabled:jt.mainBrushDuckEnabled,Ye=Number.isFinite(Y?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Y.mainBrushDuckAmount)):jt.mainBrushDuckAmount,et=Math.max(0,Math.min(1,se*he)),xn=ze?.batteryChargeMah??null,kn=g==="desktop",Nt=!kn,rn=Nt?"top-right":q,[qn]=hg(),vo=N||Nt?!0:qn,mt=pg({charge:xn,config:p}),el=ze?.wheelOvercurrents||null,tl=el==null?[]:Object.entries(el).filter(([,ye])=>!!ye).map(([ye])=>ye),on=j?.caps||null,Ea=j?.overcurrent?.groups||null,Si=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),nl=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),yo=m.useMemo(()=>{if(!on)return null;const ye=Number.isFinite(on?.drive?.cap)?on.drive.cap:1,Xe=Number.isFinite(on?.aux?.cap)?on.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(ye,Xe)))},[on]),as=!!j?.isActive,cn=tl.length?tl:as?["limiter"]:[],pt=yo??(tl.length?1:0),Xt=!!cn.length,rt=!!((Number(ze?.mainBrushCurrentMa)||0)>Cj||ze?.wheelOvercurrents?.mainBrush),bo=Se&&rt?1-Ye:1,al=Math.max(0,Math.min(1,et*bo)),So=Se&&rt&&Ye>0?`Volume decreased ${Math.round(Ye*1e3)/10}%`:null,ka=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{ka.current={hasDedicatedAudio:pe,audioUrl:l?.url||null,mainBrushDuckEnabled:Se,mainBrushDuckAmount:Ye,mainBrushActive:rt,baseRoverGain:et,effectiveRoverGain:al}},[pe,l?.url,Se,Ye,rt,et,al]);const Ke=m.useCallback((ye,Xe={})=>{if(!Si)return;const Fe=F.current,we=ka.current,Le={event:ye,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:we.hasDedicatedAudio,audioUrl:we.audioUrl,mainBrushDuckEnabled:we.mainBrushDuckEnabled,mainBrushDuckAmount:we.mainBrushDuckAmount,mainBrushActive:we.mainBrushActive,baseRoverGain:we.baseRoverGain,effectiveRoverGain:we.effectiveRoverGain,element:Fe?{muted:Fe.muted,volume:Fe.volume,paused:Fe.paused,ended:Fe.ended,readyState:Fe.readyState,networkState:Fe.networkState}:null,...Xe};try{console.log(`[AudioDebug] ${ye} ${JSON.stringify(Le)}`)}catch{console.log("[AudioDebug]",ye,Le)}},[Si,d]),ll=H?.socials?.find(ye=>String(ye?.id||ye?.label||"").toLowerCase()==="discord")?.url||H?.discord?.invite||null;m.useEffect(()=>{nl&&console.log("[OvercurrentHUD]",{overlayVisible:Xt,overlayMotors:cn,overlayFill:pt,limiterActive:as,limiterCaps:on,limiterGroups:Ea,wheelOvercurrents:el})},[nl,pt,cn,Xt,as,on,Ea,el]),m.useEffect(()=>{Ke("settings/update")},[Ke]);const Ot=m.useCallback(()=>{clearTimeout(z.current),z.current=setTimeout(()=>ne(Date.now()),Hp)},[]),ta=m.useCallback(()=>{clearTimeout(K.current),K.current=setTimeout(()=>re(Date.now()),Hp)},[]),gn=m.useCallback(async()=>{const ye=O.current;if(ye)try{ye.muted=!0,await ye.play()}catch{}},[]),Ai=m.useCallback((ye=0)=>{if(h||pe)return;clearTimeout(ae.current);const Xe=()=>{clearTimeout(ae.current),ae.current=setTimeout(()=>{h||Fe()},Nj)},Fe=async()=>{const we=O.current;if(we)try{await gn(),we.muted=!1,await we.play(),xe(!1)}catch{we.muted=!0,xe(!0),Xe()}};ae.current=setTimeout(Fe,ye)},[gn,h,pe]);m.useEffect(()=>()=>{clearTimeout(z.current),clearTimeout(K.current),clearTimeout(ae.current),clearInterval(Z.current),ue.current&&(cancelAnimationFrame(ue.current),ue.current=null)},[]),m.useEffect(()=>{U==="playing"&&Ai(0)},[U,Ai]),m.useEffect(()=>{ge&&(R("snapshot"),P(null))},[ge]),m.useEffect(()=>{if(ge||!a?.url||!O.current)return;let ye=!0,Xe;const Fe=setTimeout(()=>xe(!0),0),we=(Le,vt)=>{ye&&(Ke("video/status",{nextStatus:Le,info:vt||null}),R(Le),P(vt||null),Le==="playing"&&gn(),["error","failed","disconnected","closed"].includes(Le)&&Ot())};return Xe=new zp({url:a.url,token:a.token,video:O.current,receiveAudio:!pe,onStatus:we}),Xe.start().catch(Le=>{ye&&(R("error"),P(Le.message),Ot())}),()=>{ye=!1,clearTimeout(Fe),Xe?.stop()}},[ge,a?.url,a?.token,te,Ot,gn,pe,Ke]),m.useEffect(()=>{U==="stopped"&&a?.url&&Ot()},[U,a?.url,Ot]),m.useEffect(()=>{const ye=F.current;if(!ye||!l?.url){Ke("route/no-audio-url"),le.current=null;return}const Xe=Math.max(0,Math.min(1,al)),Fe=le.current==null?Math.max(0,Math.min(1,ye.volume)):le.current;if(ue.current&&(cancelAnimationFrame(ue.current),ue.current=null),Xe>Fe){const we=performance.now(),Le=Fe,vt=Xe-Le,kt=tt=>{const De=Math.min(1,(tt-we)/Ej),Qt=Le+vt*De;ye.volume=Qt,le.current=Qt,De<1?ue.current=requestAnimationFrame(kt):ue.current=null};ue.current=requestAnimationFrame(kt)}else ye.volume=Xe,le.current=Xe;Ke("route/direct",{elementVolume:Xe,duckEnabled:Se,mainBrushActive:rt,duckAmount:Ye})},[l?.url,al,Se,rt,Ye,Ke]),m.useEffect(()=>{if(!l?.url||!F.current)return;let ye=!0,Xe;const Fe=(we,Le)=>{ye&&(Ke("audio/status",{nextStatus:we,info:Le||null}),V(Le||(we==="connected"?"connected":null)),oe(vt=>we==="connected"&&(vt==="playing"||vt==="connecting")||we==="new"?vt:we),["error","failed"].includes(we)&&ta())};return Xe=new zp({url:l.url,token:l.token,video:F.current,audioOnly:!0,onStatus:Fe}),Xe.start().catch(we=>{ye&&(oe("error"),V(we.message),ta())}),()=>{ye=!1,Xe?.stop()}},[l?.url,l?.token,de,ta,Ke]),m.useEffect(()=>{const ye=F.current;if(!l?.url||!ye){clearInterval(Z.current);return}if(!["connecting","connected","playing","paused"].includes(ie)){clearInterval(Z.current);return}const Fe=async()=>{const we=F.current;we&&(we.muted=!1,!(!we.paused&&!we.ended)&&(Ke("retry/play-attempt"),we.play().then(()=>{Ke("retry/play-ok"),oe(Le=>Le==="connected"?"playing":Le),V(Le=>Le==="paused"?null:Le)}).catch(Le=>{Ke("retry/play-fail",{error:Le?.message}),V(vt=>vt||Le?.message||"autoplay blocked")})))};return Fe(),Z.current=setInterval(Fe,wj),()=>clearInterval(Z.current)},[l?.url,ie,Ke]),m.useEffect(()=>{const ye=F.current;if(!ye)return;const Xe=()=>{Ke("element/play"),oe(De=>De==="error"?De:"playing"),V(null)},Fe=()=>{Ke("element/pause"),oe(De=>["error","failed","disconnected","closed","stopped"].includes(De)?De:"paused"),V(De=>De||"paused")},we=()=>{Ke("element/ended"),oe(De=>De==="error"?De:"stopped"),V(De=>De||"ended")},Le=()=>{const{error:De}=ye,Qt=De?.message||"audio error";Ke("element/error",{error:Qt}),oe("error"),V(Qt)},vt=()=>Ke("element/waiting"),kt=()=>Ke("element/canplay"),tt=()=>Ke("element/stalled");return ye.addEventListener("play",Xe),ye.addEventListener("pause",Fe),ye.addEventListener("ended",we),ye.addEventListener("error",Le),ye.addEventListener("waiting",vt),ye.addEventListener("canplay",kt),ye.addEventListener("stalled",tt),()=>{ye.removeEventListener("play",Xe),ye.removeEventListener("pause",Fe),ye.removeEventListener("ended",we),ye.removeEventListener("error",Le),ye.removeEventListener("waiting",vt),ye.removeEventListener("canplay",kt),ye.removeEventListener("stalled",tt)}},[l?.url,Ke]);const ji=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",ls=ge?ji:a?.url?U==="error"?`Error: ${Q||"unknown"}`:Q?`${U} (${Q})`:U:"waiting",qa=l?.error?`Error: ${l.error}`:l?.url?ie==="error"?`Error: ${E||"unknown"}`:E?`${ie} (${E})`:ie:null,Ni=b==="spectator",Ft=b==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[ge?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:O,muted:h||ce||pe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:F,autoPlay:!0,hidden:!0}),!Ft&&k?r.jsx(Mj,{mobileHud:Nt,turnSeconds:M,isActiveDriver:T,idleSkipSeconds:L}):null,Ft?null:r.jsx(qj,{frame:x,sensors:ze,label:d,status:ls,audioStatus:qa,levelStatus:So,desktopLayout:kn,layoutFormat:g,variant:b,driverLabel:y,battery:mt,showTopDown:vo,mobileHud:Nt,mapPosition:rn,turnTimerText:S,labelScale:C}),Ft?null:r.jsx(_j,{compact:Nt}),!Ft&&nl?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:${Xt?1:0} motors:${cn.length} fill:${Math.round(pt*100)}%`}):null,Ft?null:r.jsx(Tj,{motors:cn,fill:pt,compact:Nt}),Ft?null:r.jsx(Dj,{battery:mt,compact:Nt}),!Ft&&Ni&&mt.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(wf,{visual:mt,orientation:"vertical",variant:"inline",compact:Nt,className:"h-full w-4"})}):null,!Ft&&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 ${Nt?"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(Wf,{id:"discord",label:"Join our Discord server while you wait!",url:ll})})]})}):null]}),!Ft&&!Ni&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(kj,{sensors:ze}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(wf,{visual:mt,compact:Nt})})]})]})}function kj({sensors:a}){const l=[a?.lightBumpLeftSignal,a?.lightBumpFrontLeftSignal,a?.lightBumpCenterLeftSignal,a?.lightBumpCenterRightSignal,a?.lightBumpFrontRightSignal,a?.lightBumpRightSignal],i=l.filter(x=>x!=null).reduce((x,p)=>Math.max(x,p),1200),o=x=>Math.pow(Math.max(0,Math.min(1,(x??0)/i)),.35),f=x=>x==null||x<=0?"hsl(200 60% 18%)":`hsl(${(200+o(x)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:l.map((x,p)=>{const g=o(x),b=p<d/2?-1:1,y=`${g*100}%`,N=f(x);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:N,float:b===-1?"right":"left"}})})},p)})})}function qj({frame:a,sensors:l,label:i,status:o,audioStatus:f,levelStatus:d,desktopLayout:h=!0,layoutFormat:x="desktop",variant:p="default",driverLabel:g=null,battery:b,showTopDown:y=!1,mobileHud:N=!1,mapPosition:q="top-center",turnTimerText:C=null,labelScale:w=1}){l?.bumpsAndWheelDrops;const[j,k]=m.useState(()=>Date.now());m.useEffect(()=>{const P=setInterval(()=>k(Date.now()),150);return()=>clearInterval(P)},[]),a?.receivedAt&&j-a.receivedAt<200;const S=N,M=x==="mobile-portrait",T=S?"text-[0.45rem]":"text-[0.65rem]",L=S?"px-0.25 py-0.25":"px-1 py-0.5",H=S?"px-0.25 py-0.25":"px-0.5 py-0.5",O=S?"text-[0.55rem]":"text-[0.8rem]",F=S?"left-0.5 top-0.5":"left-1 top-1",z=S?"text-[0.5rem]":"text-[0.7rem]",K=S?"px-0.5 py-0.25":"px-1 py-0.5",Z=S?"left-0.5 top-1/2":"left-1 top-1/2",ae="bottom-0.5",ue={transform:`translateX(-50%) scale(${w})`,transformOrigin:"center bottom"},le="240px",U=M?.3:S?.33:.7,Q={width:le,height:le,opacity:S?.6:.7,transform:q==="top-center"?`translateX(-50%) scale(${U})`:`scale(${U})`,transformOrigin:q==="bottom-left"?"bottom left":q==="top-center"?"top center":"top right",...q==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:q==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(p==="none")return null;if(p==="spectator"){const P=[["Voltage",l?.voltageMv!=null?`${(l.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",l?.currentMa!=null?`${l.currentMa} mA`:"--"],["Charge",l?.batteryChargeMah!=null?`${l.batteryChargeMah}`:"--"],["OI",l?.oiMode?.label||"--"]],ie=!!l?.chargingSources?.homeBase,oe=l?.chargingState?.label||"",E=!!(oe&&oe.toLowerCase()!=="not charging"),V=l?.oiMode?.label||"Unknown",te=V.toLowerCase(),ne=te==="full"?"bg-emerald-500/80 text-emerald-50":te==="safe"?"bg-amber-400/80 text-amber-950":te==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",de=ie?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",re=E?"bg-emerald-500/80 text-emerald-50":ie?"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 ${F} font-medium text-slate-100 ${T}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),r.jsx("div",{className:`absolute ${Z} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${T} ${L}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${de}`,children:ie?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${re}`,children:E?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ne}`,children:["OI: ",V]})]}),P.map(([ce,xe])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:ce}),r.jsx("span",{className:"font-semibold text-white",children:xe})]},ce))]})}),r.jsx("div",{className:`absolute ${ae} left-1/2`,style:ue,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${H} ${O}`,children:[r.jsx("span",{className:"font-semibold text-white",children:i||"Unnamed Rover"}),g?r.jsxs("span",{className:"text-slate-300",children:["• ",g]}):null]})})]}),y?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...Q},children:r.jsx(Nf,{sensors:l,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${F} font-medium text-slate-100 ${T}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",o]}),f?r.jsxs("span",{children:["Audio: ",f]}):null,d?r.jsx("span",{className:"text-cyan-300",children:d}):null]})}),C?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${K} ${z}`,children:C}):null,r.jsx("div",{className:`absolute ${ae} left-1/2`,style:ue,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${H} ${O}`,children:r.jsxs("span",{children:['Rover: "',i||"Unnamed Rover",'"']})})}),y&&p!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...Q},children:r.jsx(Nf,{sensors:l,size:240,overlay:!0})}):null]})}function Mj({mobileHud:a=!1,turnSeconds:l=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=a?"text-3xl":"text-5xl",d=a?"text-xs":"text-sm",h=a?"text-[0.55rem]":"text-[0.75rem]",x=a?"px-4 py-3":"px-6 py-4",p=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${x}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),p?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const Rj={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function Tj({motors:a,fill:l=0,compact:i=!1}){if(!a?.length)return null;const o=a.map(b=>Rj[b]||b),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",x=i?"text-xs":"text-xl",p=Math.max(0,Math.min(1,l)),g=`${Math.round(p*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${x}`,children:o.join(", ")})]})]})})}function Dj({battery:a,compact:l=!1}){if(!a?.available||!a.warnActive&&!a.urgentActive)return null;const i=a.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=l?"p-2 top-6":"p-4 top-10",f=l?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function _j({compact:a=!1}){const{session:l}=Te(),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:x}=Xf(),{value:p}=We("tts",{engine:"flite",voice:"rms",pitch:50}),[g,b]=m.useState(""),[y,N]=m.useState(!1),q=l?.role!=="spectator",C=l?.role==="spectator",w=l?.assignment?.roverId||null,k=!!m.useMemo(()=>l?.roster?.find(O=>String(O.id)===String(w))||null,[w,l?.roster])?.audio?.ttsEnabled,S=m.useMemo(()=>{if(!k)return null;const O=p?.engine==="espeak"?"espeak":"flite";if(O==="espeak"){let z=Number.isFinite(p?.pitch)?Math.round(p.pitch):void 0;return typeof z=="number"&&(z=Math.max(0,Math.min(99,z))),{speak:!0,engine:O,pitch:z}}const F=typeof p?.voice=="string"?p.voice:void 0;return{speak:!0,engine:O,voice:F}},[p?.engine,p?.pitch,p?.voice,k]),M=a?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",T=a?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",L=a?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function H(O){if(O.preventDefault(),!q)return;const F=g.trim();if(F){N(!0);try{await i(F,S),b(""),d(),x(!1)}catch(z){alert(z.message)}finally{N(!1)}}}return C?null:r.jsxs("form",{onSubmit:H,className:M,children:[r.jsx("input",{className:T,value:g,onChange:O=>{const F=O.target.value;b(F),x(!!F.trim())},onFocus:O=>{o(O),x(!!g.trim())},onBlur:O=>{f(O),x(!1)},onKeyDown:O=>{O.key==="Enter"&&!g.trim()&&(O.preventDefault(),d(),x(!1))},ref:O=>h(O,{target:"hud"}),placeholder:q?"Chat (TTS)":"Spectator",disabled:!q}),r.jsx("button",{type:"submit",disabled:!q||y,className:L,children:"Speak"})]})}function Pf({layoutFormat:a="desktop"}){const{session:l}=Te(),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=Et(),[d,h]=m.useState(()=>Date.now()),[x,p]=m.useState(!1),[g,b]=m.useState(null),y=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(l?.mode!=="turns")return;const ne=setInterval(()=>h(Date.now()),250);return()=>clearInterval(ne)},[l?.mode]);const N=l?.assignment?.roverId,C=!!(N&&l?.roster?l.roster.find(ne=>String(ne.id)===String(N)):null)?.media?.audioPublishUrl,w=N?l?.turnQueues?.[N]:null,j=l?.socketId||null,k=N?l?.activeDrivers?.[N]:null,S=!!(j&&k===j),M=m.useMemo(()=>{const ne=w?.queue||[];if(!ne.length||!w?.current||ne.length<=1)return null;const de=ne.findIndex(re=>re===w.current);return de===-1?ne[0]||null:ne[(de+1)%ne.length]||null},[w?.queue,w?.current]),T=!!(j&&M===j),L=w?.deadline||null,H=w?.idleDeadline||null,O=L?L-d:null,F=H?H-d:null,z=l?.mode==="turns"&&T&&O!=null&&O<=5e3&&O>0,K=l?.mode!=="turns"||S||z,Z=O!=null&&Number.isFinite(O)?Math.max(0,Math.ceil(O/1e3)):null,ae=F!=null&&Number.isFinite(F)?Math.max(0,Math.ceil(F/1e3)):null,ue=S?Z!=null?`${Z}s left`:null:T&&Z!=null?`Your turn in ${Z}s`:null,le=N?[...K?[{type:"rover",id:N,key:N}]:[],...C?[{type:"rover",id:`${N}-audio`,key:`${N}-audio`}]:[]]:[],U=ui(le),R=N&&K?U[N]:null,Q=N&&C?U[`${N}-audio`]:null,P=Jf(N?[N]:[],{enabled:!!N,version:l?.mode}),ie=N&&P[N]||null,oe=ns(N),E=N&&l?.roster?l.roster.find(ne=>String(ne.id)===String(N)):null,V=E?.battery??null,te=E?.name||(N?`Rover ${N}`:"");return m.useEffect(()=>{if(l?.mode!=="turns"){p(!1),b(null),y.current={active:!1,roverId:null};return}const ne=y.current,de=S&&!ne.active,re=S&&N&&N!==ne.roverId;de||re?(p(!0),b(Date.now())):!S&&ne.active&&(p(!1),b(null)),y.current={active:S,roverId:N}},[S,N,l?.mode]),m.useEffect(()=>{!x||!g||o>g&&p(!1)},[o,g,x]),r.jsx("section",{className:"panel",children:N?r.jsx(di,{sessionInfo:R,videoMode:K?"whep":"snapshot",snapshotFeed:ie,audioSessionInfo:Q,label:te,telemetryFrame:oe,batteryConfig:V,layoutFormat:a,overcurrentLimiter:f,songNote:i?.note,qualityNotice:K?null:"Preview feed (low FPS) until your turn.",showTurnCue:x,turnTimerText:ue,turnSeconds:Z,isActiveDriver:S,idleSkipSeconds:ae}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function Cf({label:a,tone:l="muted"}){const i=l==="success"?"bg-emerald-900 text-emerald-100":l==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:a})}function mo(a){if(!Number.isFinite(a))return 0;const l=a%360;return l<0?l+360:l}function Oj(a){if(!Array.isArray(a)||a.length<3)return 0;const[l,i,o]=a,f=Math.max(0,Math.min(255,Number(l)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,x=Math.max(f,d,h),p=Math.min(f,d,h),g=x-p;if(g===0)return 0;let b=0;return x===f?b=(d-h)/g%6:x===d?b=(h-f)/g+2:b=(f-d)/g+4,mo(Math.round(b*60))}function Vp(a){const l=mo(a),i=1,o=1-Math.abs(l/60%2-1);let f=0,d=0,h=0;return l<60?(f=i,d=o):l<120?(f=o,d=i):l<180?(d=i,h=o):l<240?(d=o,h=i):l<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function $p(a){return a?Array.isArray(a.hsColor)?mo(Number(a.hsColor[0])):Array.isArray(a.rgbColor)?Oj(a.rgbColor):0:0}function Bj({entity:a,connected:l,onToggle:i,onSetColor:o}){const f=a.state==="unavailable"||!a.available,d=a.state==="on",h=a.type==="light"&&a.supportsColor,x=f?"warn":d?"success":"muted",p=f?"Unavailable":d?"On":"Off",g=!l||f,b=g||!h,[y,N]=m.useState(()=>$p(a)),q=m.useRef(y),C=m.useRef(!1),w=f?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":d?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!h||C.current)return;const L=$p(a);q.current=L,N(L)},[a.rgbColor,a.hsColor,h]);const j=L=>{const H=mo(Number(L.target.value));q.current=H,N(H)},k=()=>{b||!o||o(a.id,Vp(q.current))},S=L=>{L.stopPropagation()},T=`rgb(${(h?Vp(q.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>i(a.id),disabled:g,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${w} disabled:opacity-60 disabled:hover:bg-inherit`,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[r.jsx("span",{className:"truncate font-semibold text-white",children:a.name||a.id}),h&&r.jsxs(r.Fragment,{children:[r.jsx(Cf,{label:p,tone:x}),!l&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),h?r.jsx("div",{className:"-mt-0.5 w-full",onClick:S,onPointerDown:L=>{S(L),C.current=!0},onPointerUp:L=>{S(L),C.current=!1,k()},onPointerCancel:L=>{S(L),C.current=!1,k()},onKeyUp:L=>{S(L),k()},onBlur:k,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:y,onChange:j,disabled:b,"aria-label":`Set color for ${a.name||a.id}`,className:"ha-hue-slider w-full"})})}):r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsx(Cf,{label:p,tone:x}),!l&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),h&&r.jsx("span",{className:"pointer-events-none absolute right-1 top-1 h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:T}}),!h&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:d?"Turn off":"Turn on"})]})}function xg(){const{state:{keymap:a}}=Et(),{session:l,homeAssistantToggle:i,homeAssistantSetLightColor:o}=Te(),f=l?.homeAssistant,d=m.useMemo(()=>f?.entities||[],[f?.entities]),h=jn(a?.homeAssistantOn?.[0]),x=jn(a?.homeAssistantOff?.[0]);if(!f?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(d.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const p=!!f?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:d.length}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"On"}),h?r.jsx(Gp,{label:h}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),x?r.jsx(Gp,{label:x}):null]})]})]}),r.jsx(Cf,{label:p?"Connected":"Offline",tone:p?"success":"warn"})]}),r.jsx("div",{className:"flex flex-wrap gap-0.5",children:d.map(g=>r.jsx(Bj,{entity:g,connected:p,onToggle:i,onSetColor:o},g.id))})]})}function Gp({label:a}){return a?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:a}):null}function gg(){const{login:a,setRole:l}=Te(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,x]=m.useState(!1);async function p(g){g.preventDefault(),x(!0);try{await a(i,f),o(""),d("")}catch(b){alert(b.message)}finally{x(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:p,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function Yp(...a){return a.filter(Boolean).join(" ")}function Lj(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function zj(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Uj({title:a,roster:l=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),l.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:l.map(f=>r.jsxs("li",{className:Yp("surface flex flex-wrap items-center justify-between gap-0.5",f.locked&&"bg-red-900/40"),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:f.name}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:Yp("font-semibold",zj(f)),children:["Battery ",Lj(f)]})]})]}),o?o(f):null]},f.id))})]})}const Hj=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Vj(){const{session:a,lockRover:l,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:x,setAudioLevels:p,llmControl:g,adminLogs:b,llmCommentaryState:y}=Te(),N=m.useMemo(()=>a?.roster??[],[a?.roster]),[q,C]=m.useState({}),[w,j]=m.useState({}),[k,S]=m.useState(!1),[M,T]=m.useState(!1),L=a?.health||null,H=a?.communityGoal?.text||"",O=a?.communityGoal?.updatedAt||null,[F,z]=m.useState(H),K=a?.adminReason?.text||"",Z=a?.adminReason?.updatedAt||null,[ae,ue]=m.useState(K),le=a?.audioLevels||{},[U,R]=m.useState({hornGain:Number.isFinite(le.hornGain)?le.hornGain:1,ttsGain:Number.isFinite(le.ttsGain)?le.ttsGain:1,forwardGain:Number.isFinite(le.forwardGain)?le.forwardGain:1}),Q=a?.role==="admin"||a?.role==="lockdown"||a?.role==="lockdown-admin",P=a?.mode??"open",ie=async(Y,se)=>{try{await l(Y,se),C(he=>({...he,[Y]:se}))}catch(he){alert(he.message)}},oe=async Y=>{const se=Y.target.value;try{await i(se)}catch(he){alert(he.message)}},E=async Y=>{try{await o(Y,{force:!0})}catch(se){alert(se.message)}},V=async Y=>{if(!(!Y?.id||!window.confirm(`Reboot rover "${Y.name||Y.id}" now?`))){j(he=>({...he,[Y.id]:!0}));try{await h(Y.id)}catch(he){alert(he.message)}finally{j(he=>({...he,[Y.id]:!1}))}}},te=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){S(!0);try{await x()}catch(se){alert(se.message),S(!1)}}},ne=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){T(!0);try{await g("clearHistory")}catch(se){alert(se.message)}finally{T(!1)}}},de=async()=>{try{await f(F)}catch(Y){alert(Y.message)}},re=async()=>{try{await f(null)}catch(Y){alert(Y.message)}},ce=async()=>{try{await d(ae)}catch(Y){alert(Y.message)}},xe=async()=>{try{await d(null)}catch(Y){alert(Y.message)}},pe=Y=>se=>{const he=Number(se.target.value);R(Se=>({...Se||{},[Y]:Number.isFinite(he)?he:1}))},ge=async()=>{try{await p(U)}catch(Y){alert(Y.message)}};m.useEffect(()=>{z(H)},[H]),m.useEffect(()=>{ue(K)},[K]),m.useEffect(()=>{R({hornGain:Number.isFinite(le.hornGain)?le.hornGain:1,ttsGain:Number.isFinite(le.ttsGain)?le.ttsGain:1,forwardGain:Number.isFinite(le.forwardGain)?le.forwardGain:1})},[le.forwardGain,le.hornGain,le.ttsGain]);const ze=m.useMemo(()=>{const Y={};return N.forEach(se=>{Y[se.id]=q[se.id]??se.locked}),Y},[N,q]);return Q?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:P,onChange:oe,className:"field-input text-sm",children:Hj.map(Y=>r.jsx("option",{value:Y.key,children:Y.label},Y.key))})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:te,disabled:k,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:k?"Server rebooting...":"Reboot Server"})}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),a?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(a.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[U.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:U.hornGain,onChange:pe("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[U.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:U.ttsGain,onChange:pe("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[U.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:U.forwardGain,onChange:pe("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:ge,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),O?r.jsxs("span",{children:["Updated ",new Date(O).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:F,onChange:Y=>z(Y.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:de,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:re,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"}),Z?r.jsxs("span",{children:["Updated ",new Date(Z).toLocaleString()]}):null]}),r.jsx("textarea",{value:ae,onChange:Y=>ue(Y.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:ce,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:xe,className:"button-danger",children:"Clear"})]})]}),r.jsx(Uj,{roster:N,renderActions:Y=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>ie(Y.id,!ze[Y.id]),className:"button-dark",children:ze[Y.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>E(Y.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>V(Y),disabled:!!w[Y.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:w[Y.id]?"Rebooting...":"Reboot"})]})}),r.jsx(Xj,{health:L}),r.jsx($j,{state:y,onClearHistory:ne,clearingHistory:M}),r.jsx(Fj,{entries:b})]}):null}function $j({state:a,onClearHistory:l,clearingHistory:i}){const[o,f]=m.useState(null);if(!a)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=a.runtime||{},h=a.counters||{},x=a.timings||{},p=a.input||{},g=a.output||{},b=a.errors||{},y=Array.isArray(a.history)?a.history:[],N=y.find(j=>j.runId===o)||(y.length?y[y.length-1]:null),q=Gj(a),C=Yj(p.modelMessages,g.raw),w=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:x.lastGenerationMs!=null?`${x.lastGenerationMs} ms`:"--"},{label:"avg gen",value:x.avgGenerationMs!=null?`${x.avgGenerationMs} ms`:"--"},{label:"gen count",value:x.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:l,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${q.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:q.label}),r.jsx("div",{className:"text-xs text-slate-200",children:q.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:w.map(j=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[j.label,": ",j.value]},j.label))}),b.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",b.message]}):null,b.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(b.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(j=>r.jsx($f,{message:j.message},j.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",b.failedAt?new Date(b.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(a,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:y.length?y.slice().reverse().map(j=>r.jsxs("button",{type:"button",onClick:()=>f(j.runId),className:`w-full text-left surface ${N?.runId===j.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",j.runId]})," ",r.jsx("span",{className:"text-slate-200",children:j.outcome||j.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:j.durationMs!=null?`${j.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:j.reason||""})]},j.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),N?r.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[r.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",N.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(N,null,2)})]}):null]})}function Gj(a){const l=a?.runtime||{},i=a?.output||{},o=a?.errors||{};return l.inFlight?{label:"IN FLIGHT",detail:l.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:l.outcome==="posted"?{label:"POSTED",detail:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:l.outcome==="skipped"?{label:"SKIPPED",detail:l.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:l.outcome==="failed"?{label:"FAILED",detail:o.message||l.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:l.running?"IDLE":"STOPPED",detail:l.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Yj(a,l){const i=Date.now(),f=(Array.isArray(a)?a:[]).map((d,h)=>{const x=String(d?.role||"").toLowerCase(),p=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=x==="system"?"LLM System":x==="assistant"?"LLM Context":x==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:p,role:"spectator",system:x==="system"}}});if(l!=null){const d=String(l);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function Xj({health:a}){if(!a)return null;const l=a.replay||{sources:[],readyCount:0,totalCount:0},i=a.snapshots||{rovers:[],rooms:[]},o=`${l.readyCount}/${l.totalCount} sources ready`,f=i.rovers.filter(h=>h.stale).length,d=i.rooms.filter(h=>h.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:o})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:f?"text-amber-300":"text-emerald-300",children:[i.rovers.length-f,"/",i.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:d?"text-amber-300":"text-emerald-300",children:[i.rooms.length-d,"/",i.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:l.sources.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.label}),r.jsxs("span",{className:h.ready?"text-emerald-300":"text-amber-300",children:[h.recentCount,"/",h.neededCount]})]},`${h.type}:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rovers.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.stale?"stale":"ok"})]},`rover:${h.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.rooms.map(h=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:h.name}),r.jsx("span",{className:h.stale?"text-amber-300":"text-emerald-300",children:h.error?"error":h.stale?"stale":"ok"})]},`room:${h.id}`))})]})}function Fj({entries:a}){const l=a||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:l.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No admin log entries yet."}):l.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const Qj=[{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 Kj(a){return a.reduce((l,i)=>((l[i.group]||(l[i.group]=[])).push(i),l),{})}function Zj(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):l}const ed=5,mi=500,hi=1,td=100;function Jj(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(ed,Math.min(mi,i)):l}function Pr(a,l){const i=Number(a);return Number.isFinite(i)?Math.max(hi,Math.min(td,i)):l}function Ij(a){const i=(Pr(a,a)-hi)/(td-hi),o=mi-i*(mi-ed);return Math.round(o)}function Wj(a){const l=Jj(a,a),i=(mi-l)/(mi-ed),o=hi+i*(td-hi);return Math.round(o)}function Pj(a){const[l,i]=m.useState(null),o=m.useCallback(h=>{Xu(!0),i(h)},[]),f=m.useCallback(()=>{Xu(!1),i(null)},[]),d=m.useCallback((h,x)=>{if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){f();return}const p=bi(x.key??"");p&&(a(h,p,x),f())},[f,a]);return m.useEffect(()=>()=>Xu(!1),[]),{active:l,startCapture:o,cancel:f,captureFromEvent:d}}function $r({label:a,description:l,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:x=>o(x.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:x=>o(x.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function eN(){const{state:{keymap:a},actions:{updateKeyBinding:l,resetKeyBindings:i}}=Et(),{value:o,save:f}=We("inputs",An),d={...An.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?Pr(d.tiltSpeed,An.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?Pr(Wj(d.tiltIntervalMs),An.keyboard.tiltSpeed):An.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),x=m.useMemo(()=>Kj(Qj),[]),{active:p,startCapture:g,cancel:b,captureFromEvent:y}=Pj((w,j)=>{l(w,j)}),N=m.useCallback(w=>a?.[w]?.[0]||li[w]?.[0]||"",[a]),q=m.useCallback((w,j)=>{const k=An.keyboard,S=Zj(j,k[w]);f(M=>({...M??{},keyboard:{...M?.keyboard??k,[w]:S}}))},[f]),C=m.useCallback(w=>{const j=An.keyboard,k=Pr(w,j.tiltSpeed),S=Ij(k);f(M=>({...M??{},keyboard:{...M?.keyboard??j,tiltSpeed:k,tiltIntervalMs:S}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx($r,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:w=>q("baseSpeed",w)}),r.jsx($r,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:w=>q("turboSpeed",w)}),r.jsx($r,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:w=>q("precisionSpeed",w)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx($r,{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(x).map(([w,j])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:w}),r.jsx("div",{className:"space-y-0.5",children:j.map(k=>{const S=N(k.id),M=p===k.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:k.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:jn(S)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[M&&r.jsx("button",{type:"button",onClick:()=>b(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(k.id),onKeyDown:M?T=>y(k.id,T):void 0,autoFocus:M,className:`${M?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium transition-colors`,children:M?"Press a key…":"Change"})]})]},k.id)})})]},w))})]})}const Jn=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),tN=[{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"}],Xp=.45,nN=.6;function ti({label:a,description:l,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:a}),r.jsx("span",{className:"font-mono text-slate-400",children:Jn.format(d)})]}),l&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:l}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:x=>h(Number(x.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function aN(a){if(!a)return"Unassigned";if(a.kind==="axisPair"){const l=`${a.invertX?"X inv ":""}${a.invertY?"Y inv":""}`.trim();return`Axes ${a.x}/${a.y}${l?` (${l})`:""}`}if(a.kind==="axis")return`Axis ${a.index}${a.invert?" (inv)":""}`;if(a.kind==="button")return`Button ${a.index}`;if(a.kind==="buttonAxis")return`Button ${a.index} (analog)`;if(a.kind==="axisButton"){const l=a.direction<0?"<":">";return`Axis ${a.index} ${l} ${Jn.format(a.threshold??.6)}`}return"Unassigned"}function lN(a){return a.reduce((l,i)=>((l[i.section]||(l[i.section]=[])).push(i),l),{})}function sN(a,l){if(!a||a.length===0)return null;if(l){const i=a.find(o=>o.signature===l);if(i)return i}return a[0]}function iN(a){return{axes:Array.from(a.axes??[]),buttons:(a.buttons??[]).map(l=>({pressed:!!l?.pressed,value:typeof l?.value=="number"?l.value:l?.pressed?1:0}))}}function rN(a,l,i){const o=(a.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(l.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>Xp).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>Xp);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function oN(a,l,i){const o=a.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],x=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||x>nN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=a.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,x=Math.abs(h-(l.axes?.[d]??0));if(Math.abs(h)>.7&&x>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function cN(a,l,i){if(!a)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=rN(a,l,i);if(o)return o}return oN(a,l,i)}function uN(){const a=UA(),{value:l,save:i}=We("gamepad",wa),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>lN(tN),[]),x=m.useMemo(()=>sN(a.pads,l.activeSignature),[a.pads,l.activeSignature]),p=x?.signature??null,g=m.useMemo(()=>p?l?.profiles?.[p]??l?.defaults?.profile??In:l?.defaults?.profile??In,[p,l?.defaults?.profile,l?.profiles]);m.useEffect(()=>{!x||!p||l?.profiles?.[p]||i(j=>{const k=j??wa;if(k.profiles?.[p])return k;const S=k?.defaults?.profile??In,M=eg(x,S);return{...k,profiles:{...k.profiles??{},[p]:M}}})},[x,p,l?.profiles,i]),m.useEffect(()=>{d.current=null},[o,p]),m.useEffect(()=>{if(!o||!x)return;if(!d.current){d.current=iN(x);return}const j=cN(x,d.current,o);j&&(i(k=>{const S=k??wa,M=S.profiles?.[p]??S?.defaults?.profile??In,T={...M,bindings:{...M.bindings??{},[o.id]:{...M.bindings?.[o.id]??{},kind:o.kind,sources:[j]}}};return{...S,profiles:{...S.profiles??{},[p]:T}}}),f(null))},[x,p,o,i]);const b=m.useCallback(j=>{i(k=>({...k??wa,activeSignature:j||null}))},[i]),y=m.useCallback(j=>{i(k=>{const S=k??wa,M=(p&&S.profiles?.[p])??S?.defaults?.profile??In,T={...M,calibration:{...M.calibration??{},...j}};return p?{...S,profiles:{...S.profiles??{},[p]:T}}:{...S,defaults:{...S.defaults??{},profile:T}}})},[p,i]),N=m.useCallback((j,k)=>{i(S=>{const M=S??wa,T=(p&&M.profiles?.[p])??M?.defaults?.profile??In,L=k(T.bindings?.[j]??{}),H={...T,bindings:{...T.bindings??{},[j]:L}};return p?{...M,profiles:{...M.profiles??{},[p]:H}}:{...M,defaults:{...M.defaults??{},profile:H}}})},[p,i]),q=m.useCallback(j=>{N(j.id,k=>({...k,sources:[]}))},[N]),C=m.useCallback((j,k)=>{N(j.id,S=>{const M=Array.isArray(S.sources)?[...S.sources]:[];if(!M[0])return S;const T={...M[0]};return k==="invertX"?T.invertX=!T.invertX:k==="invertY"?T.invertY=!T.invertY:T.invert=!T.invert,M[0]=T,{...S,sources:M}})},[N]),w=m.useMemo(()=>x?{outputs:tg(x,g)}:null,[x,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:x?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),a.pads.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[r.jsx("select",{value:p??"",onChange:j=>b(j.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:a.pads.map(j=>r.jsx("option",{value:j.signature,children:j.id||"Unknown controller"},j.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:x?.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(ti,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:j=>y({driveDeadzone:j})}),r.jsx(ti,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:j=>y({cameraDeadzone:j})}),r.jsx(ti,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:j=>y({auxDeadzone:j})}),r.jsx(ti,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:j=>y({auxSideScale:j})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:j=>y({cameraMode:j.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(ti,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:j=>y({cameraSensitivity:j})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([j,k])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:j}),r.jsx("div",{className:"space-y-0.5",children:k.map(S=>{const T=g.bindings?.[S.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:S.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:aN(T)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[S.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(S,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(S,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),S.kind==="axis"&&r.jsx("button",{type:"button",disabled:!T,onClick:()=>C(S),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>q(S),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(S),className:`${o?.id===S.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===S.id?"Waiting…":"Capture"})]})]},S.id)})})]},j))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),x?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:x.axes.map((j,k)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",k,": ",Jn.format(j)]},`axis-${k}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:x.buttons.map((j,k)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",k,": ",Jn.format(j.value)," ",j.pressed?"●":""]},`btn-${k}`))}),w?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",Jn.format(w.outputs.driveVector.x),","," ",Jn.format(w.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",Jn.format(w.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",Jn.format(w.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",Jn.format(w.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const fN={drive:"Drive wheels",aux:"Aux motors"};function Fp(a){return Number.isFinite(a)?`${Math.round(a*100)}%`:"--"}function dN({value:a,color:l="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,a))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${l}`,style:{width:i}})})}function mN(){const{state:{roverId:a},overcurrentLimiter:l}=Et(),i=m.useMemo(()=>Ql.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:l?.adminImmune?"Admin immune":"Active"})]}),a?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=l?.caps?.[o]?.cap??0,d=l?.overcurrent?.groups?.[o]??!1,h=l?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:fN[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:Fp(f)})]}),r.jsx(dN,{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:Fp(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${l?.config?.downRatePerSec}/s · Up rate ${l?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${l?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${l?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const vg=m.createContext(null);function yg(){const a=m.useContext(vg);if(!a)throw new Error("Tabs components must be used within a <Tabs> provider.");return a}const Qp={primary:{base:"flex-1 px-0.5 py-0.5 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-slate-500 rounded-md border border-slate-800",active:"bg-sky-600 text-white border-white",inactive:"bg-zinc-900 text-slate-300 hover:bg-sky-500 hover:text-white"}},bg="primary";function nd(...a){return a.filter(Boolean).join(" ")}function ad({children:a,defaultTab:l,currentTab:i,onTabChange:o,variant:f=bg}){const[d,h]=m.useState(l??null),[x,p]=m.useState([]),g=m.useCallback(q=>q?(p(C=>C.includes(q)?C:[...C,q]),()=>p(C=>C.includes(q)?C.filter(w=>w!==q):C)):()=>{},[]),b=i??d??x[0]??null;m.useEffect(()=>{l&&i===void 0&&h(l)},[l,i]);const y=m.useCallback(q=>{q&&(i===void 0&&h(q),o&&o(q))},[i,o]),N=m.useMemo(()=>({activeTab:b,setActiveTab:y,registerTab:g,variant:f}),[b,y,g,f]);return r.jsx(vg.Provider,{value:N,children:a})}function ld({children:a,className:l=""}){return r.jsx("div",{className:nd("flex gap-0.5",l),children:a})}function Gt({id:a,children:l,className:i="",disabled:o=!1}){const{activeTab:f,setActiveTab:d,registerTab:h,variant:x}=yg();m.useEffect(()=>h(a),[a,h]);const p=Qp[x]??Qp[bg],g=f===a,b=nd(p.base,g?p.active:p.inactive,o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:b,onClick:()=>!o&&d(a),"aria-pressed":g,"aria-disabled":o,children:l})}function sd({children:a,className:l=""}){return r.jsx("div",{className:nd("mt-0 space-y-0.5",l),children:a})}function Yt({id:a,children:l,keepMounted:i=!1}){const{activeTab:o}=yg(),f=o===a;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:l}):r.jsx(r.Fragment,{children:l})}function hN(){const{session:a}=Te(),l=m.useMemo(()=>JSON.stringify(a??{},null,2),[a]);return r.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),r.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:l})]})}const Kp=300,Zp=240;function pN(a,l){if(a===void 0)return"undefined";if(a===null)return"null";if(typeof a=="string")return a;if(typeof a=="number"||typeof a=="boolean")return String(a);if(typeof a=="function")return"[Function]";if(a instanceof Error)return`${a.name}: ${a.message}`;if(a instanceof Date)return a.toISOString();if(l||(l=new WeakSet),typeof a=="object"){if(l.has(a))return"[Circular]";l.add(a)}try{return JSON.stringify(a,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(a)}}function xN(a){const i=a.map(o=>pN(o)).join(" ");return i.length>Zp?`${i.slice(0,Zp)}…`:i}function gN(){const a=En(),[l,i]=m.useState([]),o=m.useMemo(()=>l.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[l]);return m.useEffect(()=>{const f=(p,g,b)=>{i(y=>{const N=[...y,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:p,event:g,payload:xN(b),timestamp:new Date().toLocaleTimeString()}];return N.length>Kp?N.slice(-Kp):N})},d=(p,...g)=>f("in",p,g),h=(p,...g)=>f("out",p,g);a.onAny(d);let x=null;if(typeof a.onAnyOutgoing=="function")a.onAnyOutgoing(h),x=()=>a.offAnyOutgoing(h);else{const p=a.emit.bind(a);a.emit=(g,...b)=>(h(g,...b),p(g,...b)),x=()=>{a.emit=p}}return()=>{a.offAny(d),x&&x()}},[a]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:l.length===0?r.jsx("p",{children:"No socket activity yet."}):l.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const vN=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Sg(){const{state:{roverId:a},actions:{sendOiCommand:l,setSensorStream:i}}=Et(),o=!!a,[f,d]=hg(),h=En(),{value:x,save:p}=We("page",{hudMapDesktop:!1,connectionTransport:"websocket"}),{value:g,save:b}=We("audio",jt),y=x?.connectionTransport||"websocket",N=Number.isFinite(g?.masterVolume)?g.masterVolume:jt.masterVolume,q=Number.isFinite(g?.alertVolume)?g.alertVolume:jt.alertVolume,C=Number.isFinite(g?.roverVolume)?g.roverVolume:jt.roverVolume,w=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:jt.mainBrushDuckEnabled,j=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):jt.mainBrushDuckAmount,k=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),S=H=>{a&&i(H)},M=H=>{const O=H.target.value;p(F=>({...F??{},connectionTransport:O})),h?.io?.opts&&(h.io.opts.transports=O==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},T=H=>O=>{const F=Number(O.target.value),z=Number.isFinite(F)?Math.max(0,Math.min(1,F)):0;b(K=>({...K??{},[H]:z}))},L=H=>{const O=!!H.target.checked;b(F=>({...F??{},mainBrushDuckEnabled:O}))};return r.jsxs(ad,{defaultTab:"keybindings",children:[r.jsxs(ld,{children:[r.jsx(Gt,{id:"keybindings",children:"Keybindings"}),r.jsx(Gt,{id:"controller",children:"Controller"}),r.jsx(Gt,{id:"page",children:"Page settings"}),r.jsx(Gt,{id:"admin",children:"Admin"})]}),r.jsxs(sd,{children:[r.jsx(Yt,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(eN,{})})}),r.jsx(Yt,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(uN,{})})}),r.jsx(Yt,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:H=>d(H.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:T("masterVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Alert/page sounds"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(q*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:q,onChange:T("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(C*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:C,onChange:T("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:w,onChange:L})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(j*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:j,onChange:T("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!w})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:y,onChange:M,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(Yt,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:vN.map(H=>r.jsx("button",{type:"button",onClick:()=>l(H.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:H.label},H.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:k.map(H=>r.jsx("button",{type:"button",onClick:()=>S(H.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:H.label},H.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(gg,{}),r.jsx(mN,{}),r.jsx(Vj,{}),r.jsx(hN,{}),r.jsx(gN,{})]})})]})]})}const Jp={desktop:{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel, on the bottom left of the page below the rover video.",{segments:["Toggle chat focus with ",{action:"chatFocus"},". Press ",{action:"chatFocus"}," again to send."]}]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen, or press ',{action:"driveMacro"}," on your keyboard to put the rover into driving mode."]},"Refer to the controls for the controls for the rover."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen, or press ',{action:"dockMacro"}," on your keyboard to start docking."]},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}],aside:[{type:"keyboard",title:"Keyboard controls",footnote:"Per-browser; adjust bindings and speeds in Settings → Keybindings.",groups:[{id:"movement",title:"Movement",items:[{action:"driveForward",label:"Forward"},{action:"driveBackward",label:"Backward"},{action:"driveLeft",label:"Turn left"},{action:"driveRight",label:"Turn right"},{action:"boostModifier",label:"Boost speed"},{action:"slowModifier",label:"Precision speed"}]},{id:"macros",title:"Rover modes & chat",items:[{action:"driveMacro",label:"Drive macro"},{action:"dockMacro",label:"Dock macro"},{action:"chatFocus",label:"Chat focus"}]},{id:"camera",title:"Camera",items:[{action:"cameraUp",label:"Tilt up"},{action:"cameraDown",label:"Tilt down"},{action:"nightVisionToggle",label:"Toggle night vision"}]},{id:"motors",title:"Rover Aux Motors",items:[{action:"auxMainForward",label:"Main brush forward"},{action:"auxMainReverse",label:"Main brush reverse"},{action:"auxSideForward",label:"Side brush forward"},{action:"auxSideReverse",label:"Side brush reverse"},{action:"auxVacuumFast",label:"Vacuum max"},{action:"auxVacuumSlow",label:"Vacuum low"},{action:"auxAllForward",label:"All motors forward"}]},{id:"audio",title:"Audio / Song",items:[{action:"songNoteUp",label:"Song note up"},{action:"songNoteDown",label:"Song note down"}]},{id:"room-controls",title:"Room Controls",items:[{action:"homeAssistantOn",label:"Next room control on"},{action:"homeAssistantOff",label:"Next room control off (reverse)"}]}]},{type:"gamepad",title:"Gamepad / joystick",items:["Gamepad controls are fully configurable to handle inconsistent browser mappings.","Use Settings → Controller to bind inputs, calibrate deadzones, and view diagnostics.","If inputs behave oddly, the diagnostics panel will show raw axis/button values."]}]},"mobile-portrait":{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen to put the rover into driving mode.']},"Look below the rover video. Use the joystick on the right to move the rover, and hold the buttons on the left to run the aux motors."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]},"mobile-landscape":{main:[{type:"list",title:"Chat and nicknames",items:["Scroll down to see more of the page.","Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button, or the "Drive" button to put the rover into driving mode.']},"Use the joystick to the right of the video feed to move the rover, and hold the buttons on the left to run the aux motors."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" or the "Dock" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]}};function yN(a){return Jp[a]||Jp.desktop}function Ag({actionId:a,keymap:l}){const i=l?.[a]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:jn(i)})}function Ip(a,l){return a.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(Ag,{actionId:i.action,keymap:l},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function ho(a,l,i){if(typeof a=="string")return a;if(Array.isArray(a?.segments))return Ip(a.segments,l);if(a&&typeof a=="object"){if(typeof a.text=="string")return a.text;if(Array.isArray(a))return Ip(a,l)}return String(a??"")}function bN({hero:a,keymap:l}){return a?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:a.title}),a.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:a.subtitle})]}),a.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:a.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),a.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:a.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:ho(i,l)},f)})})]}):null}function SN({block:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:ho(i,l)},f)})})]})}function AN({block:a}){const l=a.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${l} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:a.title}),a.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:ho(i,{})},`callout-${o}`))})]})}function jN({group:a,keymap:l}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:a.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:a.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(Ag,{actionId:i.action,keymap:l})]},i.action))})]})}function NN({block:a,keymap:l}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:a.title}),a.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:a.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:a.groups?.map(i=>r.jsx(jN,{group:i,keymap:l},i.id))})]}):null}function wN({block:a}){return a?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:a.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:a.items?.map((l,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:ho(l,{})},`gamepad-${i}`))})]}):null}function Wp({block:a,keymap:l}){if(!a)return null;switch(a.type){case"list":return r.jsx(SN,{block:a,keymap:l});case"callout":return r.jsx(AN,{block:a});case"keyboard":return r.jsx(NN,{block:a,keymap:l});case"gamepad":return r.jsx(wN,{block:a});default:return null}}function jg({layout:a,keymap:l}){const i=m.useMemo(()=>yN(a),[a]),o=l||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(bN,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,x)=>r.jsx(Wp,{block:h,keymap:o},h.title||x))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,x)=>r.jsx(Wp,{block:h,keymap:o},h.title||x))})]})]})}function Ng({layout:a,onOpenOverlay:l}){const{state:i}=Et();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:l,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(jg,{layout:a,keymap:i?.keymap||{}})]})}const CN=["kal","rms","slt","ksp","bdl"],EN=Array.from({length:10},(a,l)=>l*10);function po({hideInput:a=!1,hideSpectatorNotice:l=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const{session:f}=Te(),{messages:d,typing:h,sendMessage:x,registerInputRef:p,onInputFocus:g,onInputBlur:b,blurChat:y,setTypingActive:N}=Xf(),{value:q,save:C}=We("tts",{engine:"flite",voice:"rms",pitch:50}),[w,j]=m.useState(""),[k,S]=m.useState(!1),[M,T]=m.useState(!1),[L,H]=m.useState(()=>q?.engine||"flite"),[O,F]=m.useState(()=>q?.voice||"rms"),[z,K]=m.useState(()=>Number.isFinite(q?.pitch)?q.pitch:50),Z=f?.role!=="spectator"||o,ae=m.useRef(null),ue=f?.assignment?.roverId||null,U=!!m.useMemo(()=>f?.roster?.find(E=>String(E.id)===String(ue))||null,[ue,f?.roster])?.audio?.ttsEnabled,R=m.useMemo(()=>d.slice(-200),[d]),Q=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{ae.current&&(ae.current.scrollTop=ae.current.scrollHeight)},[R,Q]),m.useEffect(()=>{const E=q?.engine||"flite",V=q?.voice||"rms",te=Number.isFinite(q?.pitch)?q.pitch:50;L!==E&&H(E),O!==V&&F(V),z!==te&&K(te)},[L,z,q?.engine,q?.pitch,q?.voice,O]),m.useEffect(()=>{T(!!U)},[U]);const P=m.useMemo(()=>!U||!M?null:L==="espeak"?{speak:!0,engine:L,pitch:z}:{speak:!0,engine:L,voice:O},[L,z,M,U,O]);async function ie(E){if(E.preventDefault(),!Z||a)return;const te=w.replace(/\\n/g,`
|
||
`).trim();if(te){S(!0);try{await x(te,P),j(""),y(),N(!1)}catch(ne){alert(ne.message)}finally{S(!1)}}}const oe=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${oe}`,ref:ae,children:[R.length===0&&Q.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):R.map(E=>r.jsx($f,{message:E},E.id)),Q.map(E=>r.jsx(Xx,{message:E},`typing-${E.typingId||E.id}`))]}),!a&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ie,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:w,onChange:E=>{const V=E.target.value;j(V),N(!!V.trim())},onFocus:E=>{g(E),N(!!w.trim())},onBlur:E=>{b(E),N(!1)},onKeyDown:E=>{E.key==="Enter"&&!w.trim()&&(E.preventDefault(),y(),N(!1))},ref:E=>p(E,{target:"panel"}),placeholder:Z?"Type a message…":l?"":"Spectators cannot chat",disabled:!Z}),U&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:M,onChange:E=>T(E.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:L,onChange:E=>{const V=E.target.value;H(V),C(te=>({...te||{},engine:V}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),L==="flite"?r.jsx("select",{value:O,onChange:E=>{const V=E.target.value;F(V),C(te=>({...te||{},voice:V}))},className:"field-input text-xs",children:CN.map(E=>r.jsx("option",{value:E,children:E},E))}):r.jsx("select",{value:z,onChange:E=>{const V=Number(E.target.value);K(V),C(te=>({...te||{},pitch:V}))},className:"field-input text-xs",children:EN.map(E=>r.jsxs("option",{value:E,children:["pitch ",E]},E))})]}),r.jsx("button",{type:"submit",disabled:!Z||k,className:"button-dark h-full disabled:opacity-50 self-stretch",children:k?"...":"Send"})]})]})}function xo({compact:a=!1}){const{session:l,setNickname:i}=Te(),{value:o,save:f}=We("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[x,p]=m.useState(!1),g=l?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function b(y){if(y.preventDefault(),!g)return;const N=(d||"").trim().slice(0,32);if(N){p(!0);try{await i(N),f({nickname:N})}catch(q){alert(q.message)}finally{p(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:b,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||x,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:x?"Saving…":a?"Set":"Save"})]})}function kN(a){const l=Array.isArray(a?.socials)?a.socials:null;if(l&&l.length)return l;const i=[];return a?.discord?.invite&&i.push({id:"discord",label:"Discord",url:a.discord.invite}),a?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:a.kofi.link}),i}function qN(a){if(!a||typeof a!="object")return null;const l=a.id||a.service||a.key||a.name||null,i=a.label||a.title||a.name||l||"Link",o=a.url||a.link||a.href||null;return o?{id:l,label:i,url:o}:null}function wg({className:a=""}){const{session:l}=Te(),i=kN(l).map(qN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${a}`,children:i.map(o=>r.jsx(Wf,{...o},`${o.id||o.label}-${o.url}`))}):null}function MN({compact:a=!1}){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(xo,{compact:a})})})}function RN(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(wg,{className:"flex-1 min-h-0"})})}function sf(...a){return a.filter(Boolean).join(" ")}function TN(a){const l=a?.batteryState?.percentDisplay;return l==null?"--":`${l}%`}function DN(a){return a?.batteryState?a.batteryState.urgentActive?"text-red-400":a.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function _N(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function ON(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function go({title:a="Rovers"}){const{session:l,requestControl:i}=Te(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),x=m.useMemo(()=>l?.role&&l.role!=="spectator",[l?.role]),p=l?.roster??[],g=l?.turnQueues??{},b=l?.users??[],y=l?.socketId||null,N=m.useMemo(()=>Object.values(g||{}).some(j=>j?.deadline||j?.idleDeadline),[g]);m.useEffect(()=>{if(!N)return;const j=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(j)},[N]);const q=m.useMemo(()=>{const j=new Set(p.map(S=>String(S.id))),k=Object.keys(g||{}).filter(S=>!j.has(String(S))).map(S=>({id:S,name:S,locked:!1,batteryState:null}));return[...p,...k]},[p,g]);async function C(j){if(j){f(k=>({...k,[j]:!0}));try{await i(j)}catch(k){alert(k.message)}finally{f(k=>({...k,[j]:!1}))}}}const w=j=>b.find(k=>k.socketId===j)||{socketId:j,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[a&&r.jsx("p",{className:"text-sm text-slate-400",children:a}),q.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:q.map(j=>{const k=String(j.id),S=g?.[k]||null,M=S?.queue||[],T=S?.idleDeadline||S?.deadline||null,L=T&&T>d?Math.ceil((T-d)/1e3):T?0:null,H=S?.current||null,O=H?M.findIndex(R=>R===H):-1,F=M.length>1?O>=0?M[(O+1)%M.length]:M[0]:null,z=!!(y&&H&&H===y),K=!!(y&&F&&F===y),Z=L!=null&&(z||K),ae=!!j.locked,ue=j.lockReason?`locked: ${j.lockReason}`:"locked",le=ae?ue:o[k]?"...":"request",U=x&&!ae&&!o[k];return r.jsxs("li",{className:sf("surface flex flex-wrap items-start justify-between gap-0.5",U&&"cursor-pointer",ae&&"bg-red-900/40"),onClick:()=>{U&&C(j.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:j.name}),Z?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:z?`${L}s left`:`Your turn in ${L}s`}):null]}),r.jsx("span",{className:sf("text-[0.75rem] font-semibold",DN(j)),children:TN(j)})]}),M.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:M.map((R,Q)=>{const P=w(R),ie=R===H,oe=!!(F&&R===F&&!ie),E=ie?"bg-sky-600 text-white ring-2 ring-amber-300":oe?"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] ${E}`,children:[r.jsx("span",{className:`${_N(P.role)} font-semibold`,children:ON(P,y)}),ie&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),oe&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${k}-${R}-${Q}`)})})]}),x?r.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),C(j.id)},disabled:o[k]||ae,className:sf("button-dark disabled:opacity-40",ae&&"bg-red-600/70 text-white hover:bg-red-600"),children:le}):null]},j.id)})})]})}function BN(a){switch(a){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function LN(a,l){if(!a)return"";const i=a.nickname||a.socketId?.slice(0,6)||"unknown";return a.socketId&&a.socketId===l?`${i} (you)`:i}function so({hideNicknameForm:a=!1,hideHeader:l=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=Te(),h=d?.role!=="spectator",x=d?.users??[],p=d?.socketId||null,g=m.useMemo(()=>[...x].sort((y,N)=>y.socketId===p?-1:N.socketId===p?1:(y.nickname||"").localeCompare(N.nickname||"")),[p,x]),b=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!a&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(xo,{compact:f})})}),r.jsx(wg,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!l&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${b} ${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] ${BN(y.role)}`,children:LN(y,p)},y.socketId))})]})]})}const zN=/^cu_[a-f0-9]{32}$/,pi="field-input w-full max-w-sm text-left focus:ring-emerald-500",Zl="mx-auto w-full max-w-xl flex justify-center",ii="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function UN(a){const l=String(a||"").trim();return l?l.length<=10?`${l.slice(0,2)}***${l.slice(-2)}`:`${l.slice(0,6)}...${l.slice(-6)}`:""}const Pp=8*1024*1024,ex=16e3,HN={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function VN(a){let l="";for(let o=0;o<a.length;o+=32768){const f=a.subarray(o,o+32768);l+=String.fromCharCode(...f)}return btoa(l)}function $N(a){return typeof btoa=="function"?btoa(a):""}function GN(a){if(!a)return{};const l=$N(`${a}:${a}`);return l?{Authorization:`Basic ${l}`}:{}}function YN(a,l=1500){return new Promise(i=>{if(!a||a.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{a.removeEventListener("icegatheringstatechange",f),i()},l);function f(){a.iceGatheringState==="complete"&&(clearTimeout(o),a.removeEventListener("icegatheringstatechange",f),i())}a.addEventListener("icegatheringstatechange",f)})}function tx(a){if(!a)return!1;const l=a.connectionState,i=a.iceConnectionState;return l==="connected"||i==="connected"||i==="completed"}function XN(a,l=1e4){return new Promise((i,o)=>{if(!a){o(new Error("Peer connection missing"));return}if(tx(a)){i();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},l),d=()=>{tx(a)?(h(),i()):(a.connectionState==="failed"||a.connectionState==="closed"||a.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${a.connectionState||a.iceConnectionState}`)))};function h(){clearTimeout(f),a.removeEventListener("connectionstatechange",d),a.removeEventListener("iceconnectionstatechange",d)}a.addEventListener("connectionstatechange",d),a.addEventListener("iceconnectionstatechange",d)})}async function FN(a){if(!a?.getParameters||!a?.setParameters)return;const l=a.getParameters()||{},i=l.encodings&&l.encodings[0]||{};l.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await a.setParameters(l)}catch{}}function QN(a,l=6e3){return new Promise((i,o)=>{if(!a){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>l){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const x=a.getSenders().filter(p=>p.track?.kind==="audio");for(const p of x){const g=await p.getStats();for(const b of g.values()){if(b.type!=="outbound-rtp"||b.kind!=="audio")continue;const y=Number(b.bytesSent||0),N=Number(b.packetsSent||0);if(d<0)d=y;else if(y>d+200||N>5){clearInterval(h),i();return}}}}catch{}},250)})}function KN({ownRoverId:a="",audioForwardByRover:l={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:x}=Et(),p=String(a||"").trim(),[g,b]=m.useState(null),[y,N]=m.useState(!1),[q,C]=m.useState(!1),[w,j]=m.useState("idle"),[k,S]=m.useState(""),M=m.useRef(null),T=m.useRef(null),L=m.useRef(null),H=m.useRef(!1),O=m.useRef(""),F=!!x?.mic?.pttActive,z=m.useMemo(()=>p&&l?.[p]||null,[l,p]),K=async()=>{if(!p){S("Take control of your rover first.");return}if(!g){S("Select an audio file first.");return}if(g.size>Pp){S(`File too large (max ${Pp} bytes).`);return}N(!0),S("");try{const le=await g.arrayBuffer(),U=VN(new Uint8Array(le));await i?.({roverId:p,name:g.name,mime:g.type||"",dataBase64:U}),S("Upload playback started.")}catch(le){S(le?.message||"Failed to play upload.")}finally{N(!1)}},Z=async()=>{if(!p){S("Take control of your rover first.");return}N(!0),S("");try{await o?.(p),S("Upload playback stopped.")}catch(le){S(le?.message||"Failed to stop upload.")}finally{N(!1)}},ae=m.useCallback(async le=>{const U=String(le||O.current||"").trim();if(H.current=!1,j("idle"),L.current){try{L.current.getSenders().forEach(R=>R.track?.stop())}catch{}try{L.current.close()}catch{}}if(L.current=null,M.current)try{M.current.getTracks().forEach(R=>R.stop())}catch{}if(M.current=null,T.current=null,U)try{await h?.(U)}catch{}O.current=""},[h]),ue=m.useCallback(async le=>{const U=await f?.(le),R=String(U?.whipUrl||"").trim(),Q=String(U?.token||"").trim();if(!R||!Q)throw new Error("WHIP endpoint unavailable");const P=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:ex,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});M.current=P;const ie=P.getAudioTracks()?.[0];if(T.current=ie||null,ie&&(ie.enabled=!!(q||F)),ie?.applyConstraints)try{await ie.applyConstraints({channelCount:1,sampleRate:ex,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const oe=new RTCPeerConnection(HN);L.current=oe,oe.onconnectionstatechange=()=>{if(!H.current)return;const ne=oe.connectionState;if(ne==="connected"){j("live");return}(ne==="failed"||ne==="disconnected"||ne==="closed")&&(j("error"),S(`WHIP transport ${ne}.`))},P.getAudioTracks().forEach(ne=>{const de=oe.addTrack(ne,P);FN(de)});const E=await oe.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await oe.setLocalDescription(E),await YN(oe,1800);const V=await fetch(R,{method:"POST",headers:{"Content-Type":"application/sdp",...GN(Q)},body:oe.localDescription?.sdp||E.sdp});if(!V.ok)throw new Error(`WHIP request failed: ${V.status}`);const te=await V.text();await oe.setRemoteDescription({type:"answer",sdp:te}),await XN(oe,1e4),await QN(oe,6e3),await d?.(le)},[q,F,d,f]);return m.useEffect(()=>{let le=!1;async function U(){if(!p){await ae(O.current);return}if(!(H.current&&O.current===p)&&!(!q&&!F))try{j("starting"),S(""),H.current=!0,O.current=p,await ue(p),le||j("live")}catch(R){le||(j("error"),S(R?.message||"Failed to start mic forwarding.")),await ae(p)}}return U(),()=>{le=!0}},[q,F,p,ue,ae]),m.useEffect(()=>{const le=T.current;le&&(le.enabled=!!(q||F))},[q,F]),m.useEffect(()=>()=>{ae(O.current||p)},[p,ae]),r.jsx("section",{className:`surface ${Zl}`,children:r.jsxs("div",{className:ii,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"VIP Audio Upload"}),r.jsxs("label",{className:"grid w-full gap-0.5 text-xs text-slate-300",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:pi,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:y||!p,onChange:le=>b(le.target.files?.[0]||null)})]}),g?r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:[g.name," (",g.size," bytes)"]}):null,r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:y||!p,onClick:K,children:y?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:y||!p,onClick:Z,children:"Stop"})]}),r.jsxs("div",{className:"surface-muted mx-auto flex w-full max-w-sm flex-col gap-0.5 p-0.5 text-xs text-slate-300 text-center",children:[r.jsx("p",{className:"text-slate-200",children:"Microphone Forwarding"}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:q,disabled:!p,onChange:le=>C(!!le.target.checked)}),r.jsx("span",{children:"Open mic"})]}),r.jsxs("p",{className:"text-slate-400",children:["PTT key: ",x?.keymap?.micPtt?.[0]||"m"," (hold)"]}),r.jsxs("p",{className:"text-slate-400",children:["mic: ",w]}),r.jsx("p",{className:"text-slate-500",children:"transport: whip"})]}),z?r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["state: ",z.state||"idle",z.error?` | error: ${z.error}`:""]}):null,k?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:k}):null]})})}function ZN({pendingRequestId:a,currentStoredKey:l,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d}){const[h,x]=m.useState(0),[p,g]=m.useState(""),[b,y]=m.useState(!1),[N,q]=m.useState(!1),C=()=>{x(1),g(l),y(!1),d?.("")},w=()=>{x(0),y(!1)},j=async k=>{if(k.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(h<3){d?.("Complete all request steps before sending.");return}q(!0),d?.("");try{const S=await f(p);await o?.(),g(S),x(0),y(!1),d?.("Verification request sent to lockdown admins.")}catch(S){d?.(S.message||"Failed to submit request.")}finally{q(!1)}};return a?r.jsx("section",{className:`surface text-sm text-slate-300 ${Zl}`,children:r.jsxs("div",{className:ii,children:["Verification request pending: ",a]})}):h===0?r.jsx("section",{className:`surface ${Zl}`,children:r.jsxs("div",{className:ii,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:C,disabled:N,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${Zl}`,onSubmit:j,children:r.jsxs("div",{className:ii,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(xo,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:k=>y(k.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!b,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,h===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:pi,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:p,onChange:k=>g(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!p,onClick:()=>navigator.clipboard?.writeText(p),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!p,onClick:()=>x(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,h===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:pi,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:p,onChange:k=>g(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:N||!p,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function JN({currentStoredKey:a,applyIdentityKey:l,onMessage:i}){const[o,f]=m.useState(0),[d,h]=m.useState(""),[x,p]=m.useState(!1),g=()=>{f(1),h(""),i?.("")},b=()=>{f(0),h("")},y=async N=>{if(N.preventDefault(),!(o<2)){p(!0),i?.("");try{await l(d),f(0),h(""),i?.("Identity key restored.")}catch(q){i?.(q.message||"Failed to restore key.")}finally{p(!1)}}};return r.jsx("section",{className:`surface ${Zl}`,children:r.jsxs("div",{className:ii,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",UN(a)||"not set yet"]}),r.jsx("input",{className:pi,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:a,readOnly:!0,placeholder:"Identity key"}),o===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!a,onClick:()=>navigator.clipboard?.writeText(a),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:g,disabled:x,children:"Restore Key"})]}):null,o===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,o===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:y,children:[r.jsx("input",{className:pi,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:d,onChange:N=>h(N.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!d,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function Cg(){const{session:a,identifySession:l,requestVerification:i,playUploadedAudio:o,stopUploadedAudio:f,startMicWhip:d,readyMicWhip:h,stopMicWhip:x}=Te(),{value:p,save:g}=We("identity",{cookieUserId:""}),{value:b}=We("profile",{nickname:""}),y=m.useMemo(()=>(p?.cookieUserId||"").trim(),[p?.cookieUserId]),N=(b?.nickname||"").trim(),q=!!a?.isVerified,C=a?.verification?.pendingRequestId||null,w=String(a?.assignment?.roverId||"").trim(),[j,k]=m.useState(""),S=async M=>{const T=String(M||"").trim().toLowerCase();if(!T)throw new Error("Identity key required.");if(!zN.test(T))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return g(L=>({...L||{},cookieUserId:T})),await l({cookieUserId:T,nickname:N}),T};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[q?r.jsx(KN,{ownRoverId:w,audioForwardByRover:a?.audioForward||{},playUploadedAudio:o,stopUploadedAudio:f,startMicWhip:d,readyMicWhip:h,stopMicWhip:x}):r.jsx(ZN,{pendingRequestId:C,currentStoredKey:y,nickname:N,requestVerification:i,applyIdentityKey:S,onMessage:k}),r.jsx(JN,{currentStoredKey:y,applyIdentityKey:S,onMessage:k}),j?r.jsx("div",{className:Zl,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:j})}):null]})}function IN(){const{state:{roverId:a}}=Et(),i=ns(a)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(Nf,{sensors:i})})})}function WN(){const{state:{roverId:a,keymap:l,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:x,stopHorn:p}}=Et(),g=sg(a),b=g.docked&&!g.driving,y=i?.config,N=!!(a&&i?.enabled&&y),q=!!(a&&f?.nightVision),C=f?.nightVisionState,w=!!(a&&f?.horn),j=o?.overheated,k=typeof y?.minAngle=="number"?y.minAngle:-30,S=typeof y?.maxAngle=="number"?y.maxAngle:30,M=typeof i?.angle=="number"?i.angle:typeof y?.homeAngle=="number"?y.homeAngle:(k+S)/2,T=jn(l?.nightVisionToggle?.[0]),L=jn(l?.hornHonk?.[0]),H=jn(l?.cameraUp?.[0]),O=jn(l?.cameraDown?.[0]);return r.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[r.jsx(ig,{layout:"desktop",expand:!0,driveDockState:g}),b?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[q&&r.jsx(rg,{nightVisionOn:C?.nightVisionOn,disabled:!a,onToggle:h,keyLabel:T}),w&&r.jsx(og,{disabled:!a||j,onStart:x,onStop:p,keyLabel:L,active:o?.active,heat:o?.heat}),N&&r.jsx(cg,{value:M,min:k,max:S,onChange:d,keyDownLabel:O,keyUpLabel:H,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 PN({layout:a,onOpenHelpOverlay:l}){const{session:i}=Te(),o=i?.isVerified?"bg-emerald-400":"bg-red-600";return r.jsx("section",{className:"panel text-base",children:r.jsxs(ad,{defaultTab:"telemetry",children:[r.jsxs(ld,{children:[r.jsx(Gt,{id:"telemetry",children:"Controls"}),r.jsx(Gt,{id:"vip",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${o}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Gt,{id:"help",children:"Help"}),r.jsx(Gt,{id:"settings",children:"Settings"})]}),r.jsxs(sd,{children:[r.jsx(Yt,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(IN,{}),r.jsx(WN,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(go,{}),r.jsx(Hf,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(RN,{})]}),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(po,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(so,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(MN,{compact:!0})]})]}),r.jsx(xg,{}),r.jsx(Kf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(Yt,{id:"vip",children:r.jsx(Cg,{})}),r.jsx(Yt,{id:"help",children:r.jsx(Ng,{layout:a,onOpenOverlay:l})}),r.jsx(Yt,{id:"settings",children:r.jsx(Sg,{})})]})]})})}const ew=new Set(["admin","lockdown","lockdown-admin"]),tw=new Set(["lockdown","lockdown-admin"]),nw=new Set(["admin","lockdown"]);function aw(a="admin"){return a==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function lw(){const{session:a}=Te(),l=a?.mode,i=a?.role,o=a?.adminReason?.text||"";a?.adminReason?.updatedAt;const f=a?.timezone||"UTC",d=a?.socials?.find(N=>String(N?.id||N?.label||"").toLowerCase()==="discord")?.url||a?.discord?.invite||null,h=nw.has(l),x=l==="lockdown"?tw.has(i):ew.has(i),[p,g]=m.useState(()=>new Date),b=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(p)}catch{return p.toLocaleTimeString()}},[p,f]);if(m.useEffect(()=>{const N=setInterval(()=>g(new Date),1e3);return()=>clearInterval(N)},[]),!h||x)return null;const y=aw(l);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children: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: ",b]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(gg,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(Wf,{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(po,{}),r.jsx(xo,{})]})]})})}const sw="/assets/turn_alert-DVO8EZJa.mp3";function iw(a,l=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(a),i.current.volume=l,i.current.load()},[a,l]),()=>{i.current&&(i.current.volume=l,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function rw(){const{session:a,pushAlert:l}=Te(),{value:i}=We("audio",jt),o=Number.isFinite(i?.masterVolume)?i.masterVolume:jt.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:jt.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=iw(sw,d),x=m.useRef(new Set),p=m.useMemo(()=>a?.turnQueues||{},[a?.turnQueues]),g=a?.socketId||null;return m.useEffect(()=>{if(!g)return;const b=[];Object.entries(p).forEach(([y,N])=>{!N||!N.current||N.current!==g||x.current.has(y)||(b.push(y),x.current.add(y))}),Object.keys(p).forEach(y=>{(!p[y]||p[y].current!==g)&&x.current.delete(y)}),b.length!==0&&(b.forEach(y=>{const N=a?.roster?.find(q=>String(q.id)===String(y))?.name||y;l({title:"Your turn!",message:`You now control ${N}.`,color:"#ff5722"})}),h())},[p,h,l,a?.roster,g]),null}function ow({visible:a,mode:l,onEnterFullscreen:i,onDismiss:o}){if(!a)return null;const f=l==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}const Eg="fullscreenPromptDismissed",cw=new Set(["mobile-portrait","mobile-landscape"]),kg=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},uw=()=>{const a=kg();if(!a)return!1;try{return a.getItem(Eg)==="1"}catch{return!1}},nx=()=>{const a=kg();if(a)try{a.setItem(Eg,"1")}catch{}},fw=()=>{if(typeof navigator>"u")return!1;const a=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(a)},dw=()=>{if(typeof document>"u")return!1;const a=document;return!!(a.fullscreenEnabled||a.webkitFullscreenEnabled||a.mozFullScreenEnabled||a.msFullscreenEnabled)};function mw(a){const l=cw.has(a),[i,o]=m.useState(!1),[f,d]=m.useState("native"),h=m.useMemo(()=>fw(),[]),x=m.useCallback(()=>{if(!l){o(!1);return}if(uw()){o(!1);return}if(h){d("pwa-hint"),o(!0);return}if(!dw()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,l]);m.useEffect(()=>{x()},[x]),m.useEffect(()=>{if(typeof document>"u")return;const b=()=>{if(document.fullscreenElement){o(!1);return}x()};return document.addEventListener("fullscreenchange",b),document.addEventListener("webkitfullscreenchange",b),()=>{document.removeEventListener("fullscreenchange",b),document.removeEventListener("webkitfullscreenchange",b)}},[x]);const p=m.useCallback(()=>{nx(),o(!1)},[]),g=m.useCallback(async()=>{if(!l||h||typeof document>"u")return!1;const b=document.documentElement;if(!b)return!1;const y=b.requestFullscreen||b.webkitRequestFullscreen||b.mozRequestFullScreen||b.msRequestFullscreen;if(!y)return!1;try{const N=y.call(b);return N&&typeof N.then=="function"&&await N,nx(),o(!1),!0}catch(N){return console.warn("Failed to enter fullscreen",N),!1}},[h,l]);return m.useEffect(()=>{l||o(!1)},[l]),{visible:i,mode:f,enterFullscreen:g,dismiss:p}}function hw({visible:a,layout:l,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!a)return null;const{state:d}=Et(),h=x=>{const p=!x.target.checked;f?.(p)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(jg,{layout:l,keymap:d?.keymap||{}})})]})})}const pw=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
`;function xw(a){return a?a.charAt(0).toUpperCase()+a.slice(1):""}function gw(){const a=String(pw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return a.length?(a[Math.floor(Math.random()*a.length)]||"").trim():""}function id(){const{setNickname:a}=Te(),{value:l,status:i,save:o}=We("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(l.nickname||"").trim())return;f.current=!0;const h=xw(gw()).slice(0,32);if(!h)return;(async()=>{try{await a(h)}catch{}finally{o({nickname:h})}})()},[o,a,i,l.nickname])}function vw(){const a=En(),{connected:l,identifySession:i}=Te(),{value:o,status:f,save:d}=We("identity",{cookieUserId:""}),{value:h,status:x}=We("profile",{nickname:""}),p=m.useRef(!1),g=m.useRef(null),b=m.useRef(null),y=f==="ready"&&x==="ready",N=(o?.cookieUserId||"").trim(),q=(h?.nickname||"").trim(),C=m.useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null)},[]),w=m.useCallback(async()=>{if(!(!y||!l||!a?.id||p.current)){p.current=!0;try{const k=((await i({cookieUserId:N,nickname:q}))?.cookieUserId||"").trim();k&&k!==N&&d(S=>({...S||{},cookieUserId:k})),g.current=a.id,C()}catch{C(),b.current=setTimeout(()=>{w()},2e3)}finally{p.current=!1}}},[C,l,N,i,q,y,d,a?.id]);m.useEffect(()=>{!y||!l||!a?.id||g.current!==a.id&&w()},[l,y,w,a?.id]),m.useEffect(()=>{!y||!l||!a?.id||w()},[y,l,a?.id,N,q,w]),m.useEffect(()=>{const j=()=>{a?.connected&&w()},k=()=>{typeof document>"u"||document.visibilityState!=="visible"||a?.connected&&w()};return window.addEventListener("online",j),document.addEventListener("visibilitychange",k),()=>{window.removeEventListener("online",j),document.removeEventListener("visibilitychange",k)}},[w,a?.connected]),m.useEffect(()=>()=>C(),[C])}const rf=1e4,of=28,yw=14;function io({layout:a="desktop",className:l="",dismissable:i=!0}){const{session:o}=Te(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=a==="mobile-portrait"||a==="mobile-landscape"||a==="mobile",[h,x]=m.useState(!1),[p,g]=m.useState(of),[b,y]=m.useState(0),N=m.useRef(null),q=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!f){x(!1);return}if(x(!0),!d||!i)return;const S=Date.now();y(rf);const M=setTimeout(()=>x(!1),rf),T=setInterval(()=>{const L=Date.now()-S;y(Math.max(0,rf-L))},250);return()=>{clearTimeout(M),clearInterval(T)}},[f,d]),m.useEffect(()=>{if(!f)return;g(of);let S=0;const M=()=>{const L=C.current,H=q.current;if(!L||!H)return;const O=L.clientWidth;if(!O)return;const F=H.scrollWidth;if(!F)return;const z=Math.min(1,O/F),K=Math.max(yw,Math.floor(of*z));g(K)};S=window.requestAnimationFrame(M);const T=new ResizeObserver(()=>{window.cancelAnimationFrame(S),S=window.requestAnimationFrame(M)});return N.current&&T.observe(N.current),()=>{window.cancelAnimationFrame(S),T.disconnect()}},[f]);const w=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",l].filter(Boolean).join(" "),[l,d]);if(!f||!h)return null;const j=d?Math.ceil(b/1e3):null,k=i?{onClick:()=>x(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:N,className:w,style:{fontSize:`${p}px`,lineHeight:1.1},...k,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:q,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[j,"s"]}):null]})})}function bw(){const[a,l]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?l("desktop"):o>f?l("mobile-landscape"):l("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),a}function Sw({layout:a,onOpenHelpOverlay:l}){return r.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[r.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[r.jsx(Pf,{}),r.jsx(kS,{}),r.jsx(Zf,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(io,{layout:a}),r.jsx(PN,{layout:a,onOpenHelpOverlay:l})]})]})}function qg({layout:a,onOpenHelpOverlay:l,roomPanelId:i,showTelemetry:o=!0}){const{session:f}=Te(),d=f?.isVerified?"bg-emerald-400":"bg-amber-400";return r.jsx("section",{className:"panel text-base",children:r.jsxs(ad,{defaultTab:"chat",children:[r.jsxs(ld,{children:[r.jsx(Gt,{id:"chat",children:"Chat"}),r.jsx(Gt,{id:"vip",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${d}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Gt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Gt,{id:"help",children:"Help"}),r.jsx(Gt,{id:"settings",children:"Settings"})]}),r.jsxs(sd,{children:[r.jsx(Yt,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(po,{}),r.jsx(so,{})]})}),r.jsx(Yt,{id:"vip",children:r.jsx(Cg,{})}),r.jsx(Yt,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(xg,{}),r.jsx(Kf,{panelId:i})]})}),r.jsx(Yt,{id:"help",children:r.jsx(Ng,{layout:a,onOpenOverlay:l})}),r.jsx(Yt,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Sg,{}),r.jsx(Zf,{})]})})]})]})})}function Aw({onOpenHelpOverlay:a}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(Pf,{layoutFormat:"mobile-portrait"}),r.jsx(tj,{}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Hf,{panelId:"replay-sources-mobile-portrait"}),r.jsx(go,{})]}),r.jsx(qg,{layout:"mobile-portrait",onOpenHelpOverlay:a,roomPanelId:"mobile-portrait-room"})]})}function jw({onOpenHelpOverlay:a}){const l="self-start h-[min(100svh,32rem)]";return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[r.jsx(ug,{layout:"landscape",className:l}),r.jsxs("div",{children:[r.jsx(Pf,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(Hf,{panelId:"replay-sources-mobile-landscape"}),r.jsx(go,{})]})]}),r.jsx(fg,{layout:"landscape",className:l})]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(qg,{layout:"mobile-landscape",onOpenHelpOverlay:a,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function Nw(){const a=bw(),l=a==="desktop",i=mw(a);return r.jsx("div",{className:`bg-black text-slate-100 ${l?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(ww,{layout:a,isDesktop:l,fullscreen:i})})}function ww({layout:a,isDesktop:l,fullscreen:i}){id(),vw();const{visible:o,mode:f,enterFullscreen:d,dismiss:h}=i,{value:x,status:p,save:g}=We("help",{showOnLoad:!0}),[b,y]=m.useState(!1);m.useEffect(()=>{p==="ready"&&y(x?.showOnLoad!==!1)},[p,x?.showOnLoad]);const N=m.useCallback(()=>y(!0),[]),q=m.useCallback(()=>y(!1),[]),C=m.useCallback(j=>{const k=!!j;g(S=>({...S??{},showOnLoad:k})),k||y(!1)},[g]),w=m.useMemo(()=>l?r.jsx(Sw,{layout:a,onOpenHelpOverlay:N}):a==="mobile-landscape"?r.jsx(jw,{onOpenHelpOverlay:N}):r.jsx(Aw,{onOpenHelpOverlay:N}),[l,a,N]);return r.jsxs(vA,{children:[r.jsx(qA,{}),r.jsx(XA,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${l?"h-full overflow-hidden":""}`,children:[l?null:r.jsx(io,{layout:a}),w]}),r.jsx(Gf,{}),r.jsx(rw,{}),r.jsx(lw,{}),r.jsx(hw,{visible:b,layout:a,onClose:q,showOnLoad:x?.showOnLoad!==!1,onToggleShowOnLoad:C}),r.jsx(ow,{visible:o,mode:f,onEnterFullscreen:d,onDismiss:h})]})}function Mg(){const{session:a,setRole:l,subscribeAll:i,connected:o}=Te(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function x(){if(a?.mode==="lockdown"){d(!1);return}try{a?.role!=="spectator"&&await l("spectator"),await i(),h||d(!0)}catch(p){console.error("Failed to enter spectator mode",p),h||d(!1)}}return x(),()=>{h=!0}},[o,a?.mode,a?.role,l,i]),f}function Cw(){const[a,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>l(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),a}function Ew({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f} (turns)`:f}function kw({rover:a,frame:l,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const x=Ew({roverId:a.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(di,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:a.name,telemetryFrame:l,batteryConfig:a.battery,hudVariant:"spectator",driverLabel:x,hudForceMap:!0,hudMapPosition:"top-center"})})})}function qw({roster:a,frames:l,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return a.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:a.map(x=>r.jsx(kw,{rover:x,frame:l[x.id],sessionInfo:h&&i[x.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[x.id],audioInfo:f[`${x.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},x.id))})}function Mw(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(Kf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Rw({className:a=""}){return r.jsx("div",{className:`panel ${a}`,children:r.jsx(Zf,{})})}function Tw(){const{session:a}=Te(),l=a?.mode==="lockdown",i=!!a?.isLocalNetwork;id(),Mg();const o=Cw(),f=Uf(),d=a?.roster??[],h=Jf(d.map(j=>j.id),{enabled:!l&&!i,version:a?.mode}),x=i?d.map(j=>({type:"rover",id:j.id,key:j.id})):[],p=ui(x,{enabled:!l&&i,version:a?.mode}),g=d.flatMap(j=>j.media?.audioPublishUrl?[{type:"rover",id:`${j.id}-audio`,key:`${j.id}-audio`}]:[]),b=ui(g,{enabled:!l,version:a?.mode});if(l)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const y=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",N=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",q=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",C="",w=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:y,children:[r.jsxs("section",{className:q,children:[o?r.jsxs("div",{className:`${C} ${w} flex flex-col gap-0.5`,children:[r.jsx(io,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(so,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsx("div",{className:C,children:r.jsx(io,{layout:"desktop",dismissable:!1,className:"text-sm"})}),r.jsx("div",{className:`${C} ${o?`${w} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(go,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${C} flex-1 min-h-0`,children:r.jsx(so,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${C} ${o?w:"flex-[1.1] min-h-0"}`,children:r.jsx(po,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${C} ${o?w:""}`,children:r.jsx(Rw,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:N,children:[r.jsx(qw,{roster:d,frames:f,videoSources:p,snapshotFeeds:h,audioSources:b,session:a,canSpectateVideo:i}),r.jsx(Mw,{})]})]}),r.jsx(Gf,{})]})}function Dw(){return r.jsx(Tw,{})}const _w=2e4,Ow=3600*1e3;function Bw({roverId:a,session:l}){const i=l?.activeDrivers?.[a]||null,f=(l?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=l?.mode,h=l?.turnQueues?.[a];return d==="turns"&&h?.current?`${f}`:f}function Lw({rover:a,frame:l}){const i=l?.sensors?.batteryChargeMah??null,o=a?.battery??null;return pg({batteryState:a?.batteryState??null,charge:i,config:o})}function ax({rover:a,frame:l,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:x=!0,variant:p="stacked"}){const g=Lw({rover:a,frame:l}),b=g?.available?g.percentDisplay:null,y=p==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(wf,{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(Fl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Fl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Fl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:b==null?"--%":`${b}%`})})})]}):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(Fl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:18,children:a.name||a.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(Fl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(Fl,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:b==null?"--%":`${b}%`})})})]}),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:x?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(di,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:a.name||a.id,telemetryFrame:l,batteryConfig:a.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function Fl({children:a,className:l="",maxSize:i=1e3,minSize:o=14}){const f=m.useRef(null),d=m.useRef(null),[h,x]=m.useState(i);return m.useLayoutEffect(()=>{const p=f.current,g=d.current;if(!p||!g)return;let b=null;const y=()=>{const C=p.clientWidth;if(!C){N();return}let w=o,j=i,k=o;for(;w<=j;){const S=Math.floor((w+j)/2);g.style.fontSize=`${S}px`,g.scrollWidth<=C?(k=S,w=S+1):j=S-1}x(k)},N=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(y)};N();const q=new ResizeObserver(N);return q.observe(p),()=>{b&&cancelAnimationFrame(b),q.disconnect()}},[a,i,o]),r.jsx("div",{ref:f,className:"w-full min-w-0",children:r.jsx("div",{ref:d,className:`whitespace-nowrap ${l}`,style:{fontSize:`${h}px`,lineHeight:1.1},children:a})})}function zw(){const{session:a}=Te(),l=Mg();id();const i=a?.mode==="lockdown",o=!!a?.isLocalNetwork,f=Uf(),d=a?.roster??[],[h,x]=m.useState(0),p=a?.activeDrivers||{},g=m.useMemo(()=>d.filter(K=>p[K.id]),[d,p]),b=g.length?g:d,y=Jf(b.map(K=>K.id),{enabled:!i&&!o,version:a?.mode}),N=m.useMemo(()=>o?b.map(K=>({type:"rover",id:K.id,key:K.id})):[],[o,b]),q=ui(N,{enabled:!i&&o,version:a?.mode}),C=m.useMemo(()=>g.flatMap(K=>{if(!K?.id||!K.media?.audioPublishUrl)return[];const Z=String(K.id);return[{type:"rover",id:`${Z}-audio`,key:`${Z}-audio`}]}),[g]),w=ui(C,{enabled:!i,version:a?.mode}),j=m.useMemo(()=>{if(!g.length)return[];if(!o){const Z=g.filter(ae=>y[ae.id]?.objectUrl);return Z.length?Z:g}const K=g.filter(Z=>{const ae=q[Z.id];return ae?.url&&!ae?.error});return K.length?K:g},[g,y,q,o]),k=m.useMemo(()=>j.map(K=>({type:"rover",rover:K})),[j]),S=m.useMemo(()=>k.map(K=>`r:${K.rover.id}`).join("|"),[k]);m.useEffect(()=>{x(0)},[S]),m.useEffect(()=>{if(!k.length)return;const K=setInterval(()=>{x(Z=>(Z+1)%k.length)},_w);return()=>clearInterval(K)},[k.length,S]);const M=k.length?k[h%k.length]:null,T=M?.type==="rover"?M.rover:null,L=!o&&T&&y[T.id]||null,H=o&&T&&q[T.id]||null,O=T&&w[`${T.id}-audio`]||null,F=T&&f[T.id]||null,z=T?Bw({roverId:T.id,session:a}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:l?T?r.jsx(Hw,{children:o?r.jsx("div",{className:"relative h-full w-full",children:k.map(K=>{const Z=K.rover,ae=T?.id===Z.id;return r.jsx("div",{className:`absolute inset-0 ${ae?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(di,{sessionInfo:q[Z.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:ae?O:null,forceMute:!ae,label:Z.name||Z.id,telemetryFrame:f[Z.id]||null,batteryConfig:Z.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},Z.id)})}):r.jsx(di,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:L,audioSessionInfo:O,label:T.name||T.id,telemetryFrame:F,batteryConfig:T.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:T?r.jsx(ax,{rover:T,frame:F,driverLabel:z,sessionInfo:o?H:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[T.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((K,Z)=>r.jsx(ax,{rover:K,frame:f[K.id]||null,driverLabel:null,sessionInfo:o&&q[K.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:y[K.id]||null,showPreview:!0,withDivider:!1},K.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function Uw(){return m.useEffect(()=>{if(typeof window>"u")return;const a=setTimeout(()=>{const l=new URL(window.location.href);l.searchParams.set("refresh",Date.now().toString()),window.location.replace(l.toString())},Ow);return()=>clearTimeout(a)},[]),r.jsxs(r.Fragment,{children:[r.jsx(zw,{}),r.jsx(Gf,{scale:3})]})}function Hw({children:a}){return r.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:r.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:r.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:a})})})}Wy.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(SS,{children:r.jsx(jS,{children:r.jsx(NS,{children:r.jsx(DS,{children:r.jsx(bA,{children:r.jsx(m1,{children:r.jsxs(Yb,{children:[r.jsx(Gr,{path:"/",element:r.jsx(Nw,{})}),r.jsx(Gr,{path:"/spectate",element:r.jsx(Dw,{})}),r.jsx(Gr,{path:"/mini",element:r.jsx(Uw,{})})]})})})})})})})}));
|