mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
132 lines
577 KiB
JavaScript
132 lines
577 KiB
JavaScript
(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))o(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();function yy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Vu={exports:{}},Il={};var pp;function Sy(){if(pp)return Il;pp=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(o,u,f){var h=null;if(f!==void 0&&(h=""+f),u.key!==void 0&&(h=""+u.key),"key"in u){f={};for(var p in u)p!=="key"&&(f[p]=u[p])}else f=u;return u=f.ref,{$$typeof:n,type:o,key:h,ref:u!==void 0?u:null,props:f}}return Il.Fragment=a,Il.jsx=r,Il.jsxs=r,Il}var xp;function jy(){return xp||(xp=1,Vu.exports=Sy()),Vu.exports}var l=jy(),$u={exports:{}},Me={};var gp;function Ny(){if(gp)return Me;gp=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),j=Symbol.iterator;function M(T){return T===null||typeof T!="object"?null:(T=j&&T[j]||T["@@iterator"],typeof T=="function"?T:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function S(T,_,K){this.props=T,this.context=_,this.refs=w,this.updater=K||k}S.prototype.isReactComponent={},S.prototype.setState=function(T,_){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,_,"setState")},S.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function R(){}R.prototype=S.prototype;function E(T,_,K){this.props=T,this.context=_,this.refs=w,this.updater=K||k}var A=E.prototype=new R;A.constructor=E,N(A,S.prototype),A.isPureReactComponent=!0;var L=Array.isArray;function V(){}var O={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function X(T,_,K){var ne=K.ref;return{$$typeof:n,type:T,key:_,ref:ne!==void 0?ne:null,props:K}}function G(T,_){return X(T.type,_,T.props)}function Q(T){return typeof T=="object"&&T!==null&&T.$$typeof===n}function P(T){var _={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(K){return _[K]})}var oe=/\/+/g;function ie(T,_){return typeof T=="object"&&T!==null&&T.key!=null?P(""+T.key):_.toString(36)}function $(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(V,V):(T.status="pending",T.then(function(_){T.status==="pending"&&(T.status="fulfilled",T.value=_)},function(_){T.status==="pending"&&(T.status="rejected",T.reason=_)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,_,K,ne,me){var ce=typeof T;(ce==="undefined"||ce==="boolean")&&(T=null);var fe=!1;if(T===null)fe=!0;else switch(ce){case"bigint":case"string":case"number":fe=!0;break;case"object":switch(T.$$typeof){case n:case a:fe=!0;break;case v:return fe=T._init,q(fe(T._payload),_,K,ne,me)}}if(fe)return me=me(T),fe=ne===""?"."+ie(T,0):ne,L(me)?(K="",fe!=null&&(K=fe.replace(oe,"$&/")+"/"),q(me,_,K,"",function(xe){return xe})):me!=null&&(Q(me)&&(me=G(me,K+(me.key==null||T&&T.key===me.key?"":(""+me.key).replace(oe,"$&/")+"/")+fe)),_.push(me)),1;fe=0;var be=ne===""?".":ne+":";if(L(T))for(var ge=0;ge<T.length;ge++)ne=T[ge],ce=be+ie(ne,ge),fe+=q(ne,_,K,ce,me);else if(ge=M(T),typeof ge=="function")for(T=ge.call(T),ge=0;!(ne=T.next()).done;)ne=ne.value,ce=be+ie(ne,ge++),fe+=q(ne,_,K,ce,me);else if(ce==="object"){if(typeof T.then=="function")return q($(T),_,K,ne,me);throw _=String(T),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.")}return fe}function H(T,_,K){if(T==null)return T;var ne=[],me=0;return q(T,ne,"","",function(ce){return _.call(K,ce,me++)}),ne}function J(T){if(T._status===-1){var _=T._result;_=_(),_.then(function(K){(T._status===0||T._status===-1)&&(T._status=1,T._result=K)},function(K){(T._status===0||T._status===-1)&&(T._status=2,T._result=K)}),T._status===-1&&(T._status=0,T._result=_)}if(T._status===1)return T._result.default;throw T._result}var ee=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var _=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(_))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)},ue={map:H,forEach:function(T,_,K){H(T,function(){_.apply(this,arguments)},K)},count:function(T){var _=0;return H(T,function(){_++}),_},toArray:function(T){return H(T,function(_){return _})||[]},only:function(T){if(!Q(T))throw Error("React.Children.only expected to receive a single React element child.");return T}};return Me.Activity=b,Me.Children=ue,Me.Component=S,Me.Fragment=r,Me.Profiler=u,Me.PureComponent=E,Me.StrictMode=o,Me.Suspense=g,Me.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Me.__COMPILER_RUNTIME={__proto__:null,c:function(T){return O.H.useMemoCache(T)}},Me.cache=function(T){return function(){return T.apply(null,arguments)}},Me.cacheSignal=function(){return null},Me.cloneElement=function(T,_,K){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var ne=N({},T.props),me=T.key;if(_!=null)for(ce in _.key!==void 0&&(me=""+_.key),_)!z.call(_,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&_.ref===void 0||(ne[ce]=_[ce]);var ce=arguments.length-2;if(ce===1)ne.children=K;else if(1<ce){for(var fe=Array(ce),be=0;be<ce;be++)fe[be]=arguments[be+2];ne.children=fe}return X(T.type,me,ne)},Me.createContext=function(T){return T={$$typeof:h,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:f,_context:T},T},Me.createElement=function(T,_,K){var ne,me={},ce=null;if(_!=null)for(ne in _.key!==void 0&&(ce=""+_.key),_)z.call(_,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(me[ne]=_[ne]);var fe=arguments.length-2;if(fe===1)me.children=K;else if(1<fe){for(var be=Array(fe),ge=0;ge<fe;ge++)be[ge]=arguments[ge+2];me.children=be}if(T&&T.defaultProps)for(ne in fe=T.defaultProps,fe)me[ne]===void 0&&(me[ne]=fe[ne]);return X(T,ce,me)},Me.createRef=function(){return{current:null}},Me.forwardRef=function(T){return{$$typeof:p,render:T}},Me.isValidElement=Q,Me.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:J}},Me.memo=function(T,_){return{$$typeof:x,type:T,compare:_===void 0?null:_}},Me.startTransition=function(T){var _=O.T,K={};O.T=K;try{var ne=T(),me=O.S;me!==null&&me(K,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(V,ee)}catch(ce){ee(ce)}finally{_!==null&&K.types!==null&&(_.types=K.types),O.T=_}},Me.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Me.use=function(T){return O.H.use(T)},Me.useActionState=function(T,_,K){return O.H.useActionState(T,_,K)},Me.useCallback=function(T,_){return O.H.useCallback(T,_)},Me.useContext=function(T){return O.H.useContext(T)},Me.useDebugValue=function(){},Me.useDeferredValue=function(T,_){return O.H.useDeferredValue(T,_)},Me.useEffect=function(T,_){return O.H.useEffect(T,_)},Me.useEffectEvent=function(T){return O.H.useEffectEvent(T)},Me.useId=function(){return O.H.useId()},Me.useImperativeHandle=function(T,_,K){return O.H.useImperativeHandle(T,_,K)},Me.useInsertionEffect=function(T,_){return O.H.useInsertionEffect(T,_)},Me.useLayoutEffect=function(T,_){return O.H.useLayoutEffect(T,_)},Me.useMemo=function(T,_){return O.H.useMemo(T,_)},Me.useOptimistic=function(T,_){return O.H.useOptimistic(T,_)},Me.useReducer=function(T,_,K){return O.H.useReducer(T,_,K)},Me.useRef=function(T){return O.H.useRef(T)},Me.useState=function(T){return O.H.useState(T)},Me.useSyncExternalStore=function(T,_,K){return O.H.useSyncExternalStore(T,_,K)},Me.useTransition=function(){return O.H.useTransition()},Me.version="19.2.0",Me}var vp;function Ld(){return vp||(vp=1,$u.exports=Ny()),$u.exports}var m=Ld();const Ot=yy(m);var Gu={exports:{}},Kl={},Fu={exports:{}},Yu={};var bp;function wy(){return bp||(bp=1,(function(n){function a(q,H){var J=q.length;q.push(H);e:for(;0<J;){var ee=J-1>>>1,ue=q[ee];if(0<u(ue,H))q[ee]=H,q[J]=ue,J=ee;else break e}}function r(q){return q.length===0?null:q[0]}function o(q){if(q.length===0)return null;var H=q[0],J=q.pop();if(J!==H){q[0]=J;e:for(var ee=0,ue=q.length,T=ue>>>1;ee<T;){var _=2*(ee+1)-1,K=q[_],ne=_+1,me=q[ne];if(0>u(K,J))ne<ue&&0>u(me,K)?(q[ee]=me,q[ne]=J,ee=ne):(q[ee]=K,q[_]=J,ee=_);else if(ne<ue&&0>u(me,J))q[ee]=me,q[ne]=J,ee=ne;else break e}}return H}function u(q,H){var J=q.sortIndex-H.sortIndex;return J!==0?J:q.id-H.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var g=[],x=[],v=1,b=null,j=3,M=!1,k=!1,N=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function A(q){for(var H=r(x);H!==null;){if(H.callback===null)o(x);else if(H.startTime<=q)o(x),H.sortIndex=H.expirationTime,a(g,H);else break;H=r(x)}}function L(q){if(N=!1,A(q),!k)if(r(g)!==null)k=!0,V||(V=!0,P());else{var H=r(x);H!==null&&$(L,H.startTime-q)}}var V=!1,O=-1,z=5,X=-1;function G(){return w?!0:!(n.unstable_now()-X<z)}function Q(){if(w=!1,V){var q=n.unstable_now();X=q;var H=!0;try{e:{k=!1,N&&(N=!1,R(O),O=-1),M=!0;var J=j;try{t:{for(A(q),b=r(g);b!==null&&!(b.expirationTime>q&&G());){var ee=b.callback;if(typeof ee=="function"){b.callback=null,j=b.priorityLevel;var ue=ee(b.expirationTime<=q);if(q=n.unstable_now(),typeof ue=="function"){b.callback=ue,A(q),H=!0;break t}b===r(g)&&o(g),A(q)}else o(g);b=r(g)}if(b!==null)H=!0;else{var T=r(x);T!==null&&$(L,T.startTime-q),H=!1}}break e}finally{b=null,j=J,M=!1}H=void 0}}finally{H?P():V=!1}}}var P;if(typeof E=="function")P=function(){E(Q)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,ie=oe.port2;oe.port1.onmessage=Q,P=function(){ie.postMessage(null)}}else P=function(){S(Q,0)};function $(q,H){O=S(function(){q(n.unstable_now())},H)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(q){q.callback=null},n.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<q?Math.floor(1e3/q):5},n.unstable_getCurrentPriorityLevel=function(){return j},n.unstable_next=function(q){switch(j){case 1:case 2:case 3:var H=3;break;default:H=j}var J=j;j=H;try{return q()}finally{j=J}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(q,H){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var J=j;j=q;try{return H()}finally{j=J}},n.unstable_scheduleCallback=function(q,H,J){var ee=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ee+J:ee):J=ee,q){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=J+ue,q={id:v++,callback:H,priorityLevel:q,startTime:J,expirationTime:ue,sortIndex:-1},J>ee?(q.sortIndex=J,a(x,q),r(g)===null&&q===r(x)&&(N?(R(O),O=-1):N=!0,$(L,J-ee))):(q.sortIndex=ue,a(g,q),k||M||(k=!0,V||(V=!0,P()))),q},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(q){var H=j;return function(){var J=j;j=H;try{return q.apply(this,arguments)}finally{j=J}}}})(Yu)),Yu}var yp;function Ay(){return yp||(yp=1,Fu.exports=wy()),Fu.exports}var Xu={exports:{}},Dt={};var Sp;function Cy(){if(Sp)return Dt;Sp=1;var n=Ld();function a(g){var x="https://react.dev/errors/"+g;if(1<arguments.length){x+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)x+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+g+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var o={d:{f:r,r:function(){throw Error(a(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function f(g,x,v){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:g,containerInfo:x,implementation:v}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,x){if(g==="font")return"";if(typeof x=="string")return x==="use-credentials"?x:""}return Dt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Dt.createPortal=function(g,x){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)throw Error(a(299));return f(g,x,null,v)},Dt.flushSync=function(g){var x=h.T,v=o.p;try{if(h.T=null,o.p=2,g)return g()}finally{h.T=x,o.p=v,o.d.f()}},Dt.preconnect=function(g,x){typeof g=="string"&&(x?(x=x.crossOrigin,x=typeof x=="string"?x==="use-credentials"?x:"":void 0):x=null,o.d.C(g,x))},Dt.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},Dt.preinit=function(g,x){if(typeof g=="string"&&x&&typeof x.as=="string"){var v=x.as,b=p(v,x.crossOrigin),j=typeof x.integrity=="string"?x.integrity:void 0,M=typeof x.fetchPriority=="string"?x.fetchPriority:void 0;v==="style"?o.d.S(g,typeof x.precedence=="string"?x.precedence:void 0,{crossOrigin:b,integrity:j,fetchPriority:M}):v==="script"&&o.d.X(g,{crossOrigin:b,integrity:j,fetchPriority:M,nonce:typeof x.nonce=="string"?x.nonce:void 0})}},Dt.preinitModule=function(g,x){if(typeof g=="string")if(typeof x=="object"&&x!==null){if(x.as==null||x.as==="script"){var v=p(x.as,x.crossOrigin);o.d.M(g,{crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0})}}else x==null&&o.d.M(g)},Dt.preload=function(g,x){if(typeof g=="string"&&typeof x=="object"&&x!==null&&typeof x.as=="string"){var v=x.as,b=p(v,x.crossOrigin);o.d.L(g,v,{crossOrigin:b,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0,type:typeof x.type=="string"?x.type:void 0,fetchPriority:typeof x.fetchPriority=="string"?x.fetchPriority:void 0,referrerPolicy:typeof x.referrerPolicy=="string"?x.referrerPolicy:void 0,imageSrcSet:typeof x.imageSrcSet=="string"?x.imageSrcSet:void 0,imageSizes:typeof x.imageSizes=="string"?x.imageSizes:void 0,media:typeof x.media=="string"?x.media:void 0})}},Dt.preloadModule=function(g,x){if(typeof g=="string")if(x){var v=p(x.as,x.crossOrigin);o.d.m(g,{as:typeof x.as=="string"&&x.as!=="script"?x.as:void 0,crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0})}else o.d.m(g)},Dt.requestFormReset=function(g){o.d.r(g)},Dt.unstable_batchedUpdates=function(g,x){return g(x)},Dt.useFormState=function(g,x,v){return h.H.useFormState(g,x,v)},Dt.useFormStatus=function(){return h.H.useHostTransitionStatus()},Dt.version="19.2.0",Dt}var jp;function ky(){if(jp)return Xu.exports;jp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Xu.exports=Cy(),Xu.exports}var Np;function Ey(){if(Np)return Kl;Np=1;var n=Ay(),a=Ld(),r=ky();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(f(e)!==e)throw Error(o(188))}function x(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var s=e,i=t;;){var c=s.return;if(c===null)break;var d=c.alternate;if(d===null){if(i=c.return,i!==null){s=i;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===s)return g(c),e;if(d===i)return g(c),t;d=d.sibling}throw Error(o(188))}if(s.return!==i.return)s=c,i=d;else{for(var y=!1,C=c.child;C;){if(C===s){y=!0,s=c,i=d;break}if(C===i){y=!0,i=c,s=d;break}C=C.sibling}if(!y){for(C=d.child;C;){if(C===s){y=!0,s=d,i=c;break}if(C===i){y=!0,i=d,s=c;break}C=C.sibling}if(!y)throw Error(o(189))}}if(s.alternate!==i)throw Error(o(190))}if(s.tag!==3)throw Error(o(188));return s.stateNode.current===s?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,j=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),E=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function P(e){return e===null||typeof e!="object"?null:(e=Q&&e[Q]||e["@@iterator"],typeof e=="function"?e:null)}var oe=Symbol.for("react.client.reference");function ie(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case S:return"Profiler";case w:return"StrictMode";case L:return"Suspense";case V:return"SuspenseList";case X:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case E:return e.displayName||"Context";case R:return(e._context.displayName||"Context")+".Consumer";case A: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:ie(e.type)||"Memo";case z:t=e._payload,e=e._init;try{return ie(e(t))}catch{}}return null}var $=Array.isArray,q=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ee=[],ue=-1;function T(e){return{current:e}}function _(e){0>ue||(e.current=ee[ue],ee[ue]=null,ue--)}function K(e,t){ue++,ee[ue]=e.current,e.current=t}var ne=T(null),me=T(null),ce=T(null),fe=T(null);function be(e,t){switch(K(ce,t),K(me,e),K(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?z0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=z0(t),e=U0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_(ne),K(ne,e)}function ge(){_(ne),_(me),_(ce)}function xe(e){e.memoizedState!==null&&K(fe,e);var t=ne.current,s=U0(t,e.type);t!==s&&(K(me,e),K(ne,s))}function ze(e){me.current===e&&(_(ne),_(me)),fe.current===e&&(_(fe),Fl._currentValue=J)}var Ee,Te;function Oe(e){if(Ee===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||"",Te=-1<s.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+Ee+e+Te}var Ue=!1;function ht(e,t){if(!e||Ue)return"";Ue=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var se=function(){throw Error()};if(Object.defineProperty(se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(se,[])}catch(Z){var I=Z}Reflect.construct(e,[],se)}else{try{se.call()}catch(Z){I=Z}e.call(se.prototype)}}else{try{throw Error()}catch(Z){I=Z}(se=e())&&typeof se.catch=="function"&&se.catch(function(){})}}catch(Z){if(Z&&I&&typeof Z.stack=="string")return[Z.stack,I.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=i.DetermineComponentFrameRoot(),y=d[0],C=d[1];if(y&&C){var D=y.split(`
|
||
`),Y=C.split(`
|
||
`);for(c=i=0;i<D.length&&!D[i].includes("DetermineComponentFrameRoot");)i++;for(;c<Y.length&&!Y[c].includes("DetermineComponentFrameRoot");)c++;if(i===D.length||c===Y.length)for(i=D.length-1,c=Y.length-1;1<=i&&0<=c&&D[i]!==Y[c];)c--;for(;1<=i&&0<=c;i--,c--)if(D[i]!==Y[c]){if(i!==1||c!==1)do if(i--,c--,0>c||D[i]!==Y[c]){var W=`
|
||
`+D[i].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),W}while(1<=i&&0<=c);break}}}finally{Ue=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?Oe(s):""}function re(e,t){switch(e.tag){case 26:case 27:case 5:return Oe(e.type);case 16:return Oe("Lazy");case 13:return e.child!==t&&t!==null?Oe("Suspense Fallback"):Oe("Suspense");case 19:return Oe("SuspenseList");case 0:case 15:return ht(e.type,!1);case 11:return ht(e.type.render,!1);case 1:return ht(e.type,!0);case 31:return Oe("Activity");default:return""}}function ae(e){try{var t="",s=null;do t+=re(e,s),s=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var Se=Object.prototype.hasOwnProperty,pe=n.unstable_scheduleCallback,je=n.unstable_cancelCallback,Ae=n.unstable_shouldYield,Re=n.unstable_requestPaint,le=n.unstable_now,he=n.unstable_getCurrentPriorityLevel,De=n.unstable_ImmediatePriority,Tt=n.unstable_UserBlockingPriority,qt=n.unstable_NormalPriority,nl=n.unstable_LowPriority,Ft=n.unstable_IdlePriority,Ne=n.log,st=n.unstable_setDisableYieldValue,Ke=null,ke=null;function He(e){if(typeof Ne=="function"&&st(e),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(Ke,e)}catch{}}var Pe=Math.clz32?Math.clz32:yt,Ms=Math.log,na=Math.LN2;function yt(e){return e>>>=0,e===0?32:31-(Ms(e)/na|0)|0}var jn=256,Nr=262144,wr=4194304;function Rs(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 Ar(e,t,s){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var C=i&134217727;return C!==0?(i=C&~d,i!==0?c=Rs(i):(y&=C,y!==0?c=Rs(y):s||(s=C&~e,s!==0&&(c=Rs(s))))):(C=i&~d,C!==0?c=Rs(C):y!==0?c=Rs(y):s||(s=i&~e,s!==0&&(c=Rs(s)))),c===0?0:t!==0&&t!==c&&(t&d)===0&&(d=c&-c,s=t&-t,d>=s||d===32&&(s&4194048)!==0)?t:c}function sl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function iv(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 bf(){var e=wr;return wr<<=1,(wr&62914560)===0&&(wr=4194304),e}function Mo(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function al(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ov(e,t,s,i,c,d){var y=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var C=e.entanglements,D=e.expirationTimes,Y=e.hiddenUpdates;for(s=y&~s;0<s;){var W=31-Pe(s),se=1<<W;C[W]=0,D[W]=-1;var I=Y[W];if(I!==null)for(Y[W]=null,W=0;W<I.length;W++){var Z=I[W];Z!==null&&(Z.lane&=-536870913)}s&=~se}i!==0&&yf(e,i,0),d!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=d&~(y&~t))}function yf(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-Pe(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|s&261930}function Sf(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var i=31-Pe(s),c=1<<i;c&t|e[i]&t&&(e[i]|=t),s&=~c}}function jf(e,t){var s=t&-t;return s=(s&42)!==0?1:Ro(s),(s&(e.suspendedLanes|t))!==0?0:s}function Ro(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 To(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Nf(){var e=H.p;return e!==0?e:(e=window.event,e===void 0?32:op(e.type))}function wf(e,t){var s=H.p;try{return H.p=e,t()}finally{H.p=s}}var ss=Math.random().toString(36).slice(2),At="__reactFiber$"+ss,Bt="__reactProps$"+ss,sa="__reactContainer$"+ss,qo="__reactEvents$"+ss,cv="__reactListeners$"+ss,uv="__reactHandles$"+ss,Af="__reactResources$"+ss,ll="__reactMarker$"+ss;function Do(e){delete e[At],delete e[Bt],delete e[qo],delete e[cv],delete e[uv]}function aa(e){var t=e[At];if(t)return t;for(var s=e.parentNode;s;){if(t=s[sa]||s[At]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=X0(e);e!==null;){if(s=e[At])return s;e=X0(e)}return t}e=s,s=e.parentNode}return null}function la(e){if(e=e[At]||e[sa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function rl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ra(e){var t=e[Af];return t||(t=e[Af]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function jt(e){e[ll]=!0}var Cf=new Set,kf={};function Ts(e,t){ia(e,t),ia(e+"Capture",t)}function ia(e,t){for(kf[e]=t,e=0;e<t.length;e++)Cf.add(t[e])}var dv=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]*$"),Ef={},Mf={};function fv(e){return Se.call(Mf,e)?!0:Se.call(Ef,e)?!1:dv.test(e)?Mf[e]=!0:(Ef[e]=!0,!1)}function Cr(e,t,s){if(fv(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function kr(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Tn(e,t,s,i){if(i===null)e.removeAttribute(s);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+i)}}function tn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Rf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function mv(e,t,s){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,d=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(y){s=""+y,d.call(this,y)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return s},setValue:function(y){s=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function _o(e){if(!e._valueTracker){var t=Rf(e)?"checked":"value";e._valueTracker=mv(e,t,""+e[t])}}function Tf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),i="";return e&&(i=Rf(e)?e.checked?"true":"false":e.value),e=i,e!==s?(t.setValue(e),!0):!1}function Er(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 hv=/[\n"\\]/g;function nn(e){return e.replace(hv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Oo(e,t,s,i,c,d,y,C){e.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.type=y:e.removeAttribute("type"),t!=null?y==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+tn(t)):e.value!==""+tn(t)&&(e.value=""+tn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?Bo(e,y,tn(t)):s!=null?Bo(e,y,tn(s)):i!=null&&e.removeAttribute("value"),c==null&&d!=null&&(e.defaultChecked=!!d),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?e.name=""+tn(C):e.removeAttribute("name")}function qf(e,t,s,i,c,d,y,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.type=d),t!=null||s!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){_o(e);return}s=s!=null?""+tn(s):"",t=t!=null?""+tn(t):s,C||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=C?e.checked:!!i,e.defaultChecked=!!i,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),_o(e)}function Bo(e,t,s){t==="number"&&Er(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function oa(e,t,s,i){if(e=e.options,t){t={};for(var c=0;c<s.length;c++)t["$"+s[c]]=!0;for(s=0;s<e.length;s++)c=t.hasOwnProperty("$"+e[s].value),e[s].selected!==c&&(e[s].selected=c),c&&i&&(e[s].defaultSelected=!0)}else{for(s=""+tn(s),t=null,c=0;c<e.length;c++){if(e[c].value===s){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Df(e,t,s){if(t!=null&&(t=""+tn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+tn(s):""}function _f(e,t,s,i){if(t==null){if(i!=null){if(s!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}s=i}s==null&&(s=""),t=s}s=tn(t),e.defaultValue=s,i=e.textContent,i===s&&i!==""&&i!==null&&(e.value=i),_o(e)}function ca(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var pv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Of(e,t,s){var i=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,s):typeof s!="number"||s===0||pv.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function Bf(e,t,s){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,s!=null){for(var i in s)!s.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&s[c]!==i&&Of(e,c,i)}else for(var d in t)t.hasOwnProperty(d)&&Of(e,d,t[d])}function Lo(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 xv=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"]]),gv=/^[\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 Mr(e){return gv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function qn(){}var zo=null;function Uo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ua=null,da=null;function Lf(e){var t=la(e);if(t&&(e=t.stateNode)){var s=e[Bt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Oo(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+nn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var i=s[t];if(i!==e&&i.form===e.form){var c=i[Bt]||null;if(!c)throw Error(o(90));Oo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<s.length;t++)i=s[t],i.form===e.form&&Tf(i)}break e;case"textarea":Df(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&oa(e,!!s.multiple,t,!1)}}}var Ho=!1;function zf(e,t,s){if(Ho)return e(t,s);Ho=!0;try{var i=e(t);return i}finally{if(Ho=!1,(ua!==null||da!==null)&&(xi(),ua&&(t=ua,e=da,da=ua=null,Lf(t),e)))for(t=0;t<e.length;t++)Lf(e[t])}}function il(e,t){var s=e.stateNode;if(s===null)return null;var i=s[Bt]||null;if(i===null)return null;s=i[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(o(231,t,typeof s));return s}var Dn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vo=!1;if(Dn)try{var ol={};Object.defineProperty(ol,"passive",{get:function(){Vo=!0}}),window.addEventListener("test",ol,ol),window.removeEventListener("test",ol,ol)}catch{Vo=!1}var as=null,$o=null,Rr=null;function Uf(){if(Rr)return Rr;var e,t=$o,s=t.length,i,c="value"in as?as.value:as.textContent,d=c.length;for(e=0;e<s&&t[e]===c[e];e++);var y=s-e;for(i=1;i<=y&&t[s-i]===c[d-i];i++);return Rr=c.slice(e,1<i?1-i:void 0)}function Tr(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 qr(){return!0}function Hf(){return!1}function Lt(e){function t(s,i,c,d,y){this._reactName=s,this._targetInst=c,this.type=i,this.nativeEvent=d,this.target=y,this.currentTarget=null;for(var C in e)e.hasOwnProperty(C)&&(s=e[C],this[C]=s?s(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?qr:Hf,this.isPropagationStopped=Hf,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=qr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=qr)},persist:function(){},isPersistent:qr}),t}var qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Dr=Lt(qs),cl=b({},qs,{view:0,detail:0}),vv=Lt(cl),Go,Fo,ul,_r=b({},cl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xo,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!==ul&&(ul&&e.type==="mousemove"?(Go=e.screenX-ul.screenX,Fo=e.screenY-ul.screenY):Fo=Go=0,ul=e),Go)},movementY:function(e){return"movementY"in e?e.movementY:Fo}}),Vf=Lt(_r),bv=b({},_r,{dataTransfer:0}),yv=Lt(bv),Sv=b({},cl,{relatedTarget:0}),Yo=Lt(Sv),jv=b({},qs,{animationName:0,elapsedTime:0,pseudoElement:0}),Nv=Lt(jv),wv=b({},qs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Av=Lt(wv),Cv=b({},qs,{data:0}),$f=Lt(Cv),kv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ev={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Mv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Rv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Mv[e])?!!t[e]:!1}function Xo(){return Rv}var Tv=b({},cl,{key:function(e){if(e.key){var t=kv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Tr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ev[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xo,charCode:function(e){return e.type==="keypress"?Tr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Tr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),qv=Lt(Tv),Dv=b({},_r,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gf=Lt(Dv),_v=b({},cl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xo}),Ov=Lt(_v),Bv=b({},qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lv=Lt(Bv),zv=b({},_r,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Uv=Lt(zv),Hv=b({},qs,{newState:0,oldState:0}),Vv=Lt(Hv),$v=[9,13,27,32],Qo=Dn&&"CompositionEvent"in window,dl=null;Dn&&"documentMode"in document&&(dl=document.documentMode);var Gv=Dn&&"TextEvent"in window&&!dl,Ff=Dn&&(!Qo||dl&&8<dl&&11>=dl),Yf=" ",Xf=!1;function Qf(e,t){switch(e){case"keyup":return $v.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function If(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fa=!1;function Fv(e,t){switch(e){case"compositionend":return If(t);case"keypress":return t.which!==32?null:(Xf=!0,Yf);case"textInput":return e=t.data,e===Yf&&Xf?null:e;default:return null}}function Yv(e,t){if(fa)return e==="compositionend"||!Qo&&Qf(e,t)?(e=Uf(),Rr=$o=as=null,fa=!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 Ff&&t.locale!=="ko"?null:t.data;default:return null}}var Xv={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 Kf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Xv[e.type]:t==="textarea"}function Zf(e,t,s,i){ua?da?da.push(i):da=[i]:ua=i,t=Ni(t,"onChange"),0<t.length&&(s=new Dr("onChange","change",null,s,i),e.push({event:s,listeners:t}))}var fl=null,ml=null;function Qv(e){q0(e,0)}function Or(e){var t=rl(e);if(Tf(t))return e}function Jf(e,t){if(e==="change")return t}var Pf=!1;if(Dn){var Io;if(Dn){var Ko="oninput"in document;if(!Ko){var Wf=document.createElement("div");Wf.setAttribute("oninput","return;"),Ko=typeof Wf.oninput=="function"}Io=Ko}else Io=!1;Pf=Io&&(!document.documentMode||9<document.documentMode)}function em(){fl&&(fl.detachEvent("onpropertychange",tm),ml=fl=null)}function tm(e){if(e.propertyName==="value"&&Or(ml)){var t=[];Zf(t,ml,e,Uo(e)),zf(Qv,t)}}function Iv(e,t,s){e==="focusin"?(em(),fl=t,ml=s,fl.attachEvent("onpropertychange",tm)):e==="focusout"&&em()}function Kv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Or(ml)}function Zv(e,t){if(e==="click")return Or(t)}function Jv(e,t){if(e==="input"||e==="change")return Or(t)}function Pv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Yt=typeof Object.is=="function"?Object.is:Pv;function hl(e,t){if(Yt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(i=0;i<s.length;i++){var c=s[i];if(!Se.call(t,c)||!Yt(e[c],t[c]))return!1}return!0}function nm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function sm(e,t){var s=nm(e);e=0;for(var i;s;){if(s.nodeType===3){if(i=e+s.textContent.length,e<=t&&i>=t)return{node:s,offset:t-e};e=i}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=nm(s)}}function am(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?am(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function lm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Er(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Er(e.document)}return t}function Zo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Wv=Dn&&"documentMode"in document&&11>=document.documentMode,ma=null,Jo=null,pl=null,Po=!1;function rm(e,t,s){var i=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Po||ma==null||ma!==Er(i)||(i=ma,"selectionStart"in i&&Zo(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),pl&&hl(pl,i)||(pl=i,i=Ni(Jo,"onSelect"),0<i.length&&(t=new Dr("onSelect","select",null,t,s),e.push({event:t,listeners:i}),t.target=ma)))}function Ds(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var ha={animationend:Ds("Animation","AnimationEnd"),animationiteration:Ds("Animation","AnimationIteration"),animationstart:Ds("Animation","AnimationStart"),transitionrun:Ds("Transition","TransitionRun"),transitionstart:Ds("Transition","TransitionStart"),transitioncancel:Ds("Transition","TransitionCancel"),transitionend:Ds("Transition","TransitionEnd")},Wo={},im={};Dn&&(im=document.createElement("div").style,"AnimationEvent"in window||(delete ha.animationend.animation,delete ha.animationiteration.animation,delete ha.animationstart.animation),"TransitionEvent"in window||delete ha.transitionend.transition);function _s(e){if(Wo[e])return Wo[e];if(!ha[e])return e;var t=ha[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in im)return Wo[e]=t[s];return e}var om=_s("animationend"),cm=_s("animationiteration"),um=_s("animationstart"),eb=_s("transitionrun"),tb=_s("transitionstart"),nb=_s("transitioncancel"),dm=_s("transitionend"),fm=new Map,ec="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(" ");ec.push("scrollEnd");function xn(e,t){fm.set(e,t),Ts(t,[e])}var Br=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},sn=[],pa=0,tc=0;function Lr(){for(var e=pa,t=tc=pa=0;t<e;){var s=sn[t];sn[t++]=null;var i=sn[t];sn[t++]=null;var c=sn[t];sn[t++]=null;var d=sn[t];if(sn[t++]=null,i!==null&&c!==null){var y=i.pending;y===null?c.next=c:(c.next=y.next,y.next=c),i.pending=c}d!==0&&mm(s,c,d)}}function zr(e,t,s,i){sn[pa++]=e,sn[pa++]=t,sn[pa++]=s,sn[pa++]=i,tc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function nc(e,t,s,i){return zr(e,t,s,i),Ur(e)}function Os(e,t){return zr(e,null,null,t),Ur(e)}function mm(e,t,s){e.lanes|=s;var i=e.alternate;i!==null&&(i.lanes|=s);for(var c=!1,d=e.return;d!==null;)d.childLanes|=s,i=d.alternate,i!==null&&(i.childLanes|=s),d.tag===22&&(e=d.stateNode,e===null||e._visibility&1||(c=!0)),e=d,d=d.return;return e.tag===3?(d=e.stateNode,c&&t!==null&&(c=31-Pe(s),e=d.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=s|536870912),d):null}function Ur(e){if(50<Ll)throw Ll=0,du=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var xa={};function sb(e,t,s,i){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,s,i){return new sb(e,t,s,i)}function sc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _n(e,t){var s=e.alternate;return s===null?(s=Xt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function hm(e,t){e.flags&=65011714;var s=e.alternate;return s===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=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hr(e,t,s,i,c,d){var y=0;if(i=e,typeof e=="function")sc(e)&&(y=1);else if(typeof e=="string")y=oy(e,s,ne.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case X:return e=Xt(31,s,t,c),e.elementType=X,e.lanes=d,e;case N:return Bs(s.children,c,d,t);case w:y=8,c|=24;break;case S:return e=Xt(12,s,t,c|2),e.elementType=S,e.lanes=d,e;case L:return e=Xt(13,s,t,c),e.elementType=L,e.lanes=d,e;case V:return e=Xt(19,s,t,c),e.elementType=V,e.lanes=d,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case E:y=10;break e;case R:y=9;break e;case A:y=11;break e;case O:y=14;break e;case z:y=16,i=null;break e}y=29,s=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Xt(y,s,t,c),t.elementType=e,t.type=i,t.lanes=d,t}function Bs(e,t,s,i){return e=Xt(7,e,i,t),e.lanes=s,e}function ac(e,t,s){return e=Xt(6,e,null,t),e.lanes=s,e}function pm(e){var t=Xt(18,null,null,0);return t.stateNode=e,t}function lc(e,t,s){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var xm=new WeakMap;function an(e,t){if(typeof e=="object"&&e!==null){var s=xm.get(e);return s!==void 0?s:(t={value:e,source:t,stack:ae(t)},xm.set(e,t),t)}return{value:e,source:t,stack:ae(t)}}var ga=[],va=0,Vr=null,xl=0,ln=[],rn=0,ls=null,Nn=1,wn="";function On(e,t){ga[va++]=xl,ga[va++]=Vr,Vr=e,xl=t}function gm(e,t,s){ln[rn++]=Nn,ln[rn++]=wn,ln[rn++]=ls,ls=e;var i=Nn;e=wn;var c=32-Pe(i)-1;i&=~(1<<c),s+=1;var d=32-Pe(t)+c;if(30<d){var y=c-c%5;d=(i&(1<<y)-1).toString(32),i>>=y,c-=y,Nn=1<<32-Pe(t)+c|s<<c|i,wn=d+e}else Nn=1<<d|s<<c|i,wn=e}function rc(e){e.return!==null&&(On(e,1),gm(e,1,0))}function ic(e){for(;e===Vr;)Vr=ga[--va],ga[va]=null,xl=ga[--va],ga[va]=null;for(;e===ls;)ls=ln[--rn],ln[rn]=null,wn=ln[--rn],ln[rn]=null,Nn=ln[--rn],ln[rn]=null}function vm(e,t){ln[rn++]=Nn,ln[rn++]=wn,ln[rn++]=ls,Nn=t.id,wn=t.overflow,ls=e}var Ct=null,at=null,Ge=!1,rs=null,on=!1,oc=Error(o(519));function is(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw gl(an(t,e)),oc}function bm(e){var t=e.stateNode,s=e.type,i=e.memoizedProps;switch(t[At]=e,t[Bt]=i,s){case"dialog":Le("cancel",t),Le("close",t);break;case"iframe":case"object":case"embed":Le("load",t);break;case"video":case"audio":for(s=0;s<Ul.length;s++)Le(Ul[s],t);break;case"source":Le("error",t);break;case"img":case"image":case"link":Le("error",t),Le("load",t);break;case"details":Le("toggle",t);break;case"input":Le("invalid",t),qf(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Le("invalid",t);break;case"textarea":Le("invalid",t),_f(t,i.value,i.defaultValue,i.children)}s=i.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||i.suppressHydrationWarning===!0||B0(t.textContent,s)?(i.popover!=null&&(Le("beforetoggle",t),Le("toggle",t)),i.onScroll!=null&&Le("scroll",t),i.onScrollEnd!=null&&Le("scrollend",t),i.onClick!=null&&(t.onclick=qn),t=!0):t=!1,t||is(e,!0)}function ym(e){for(Ct=e.return;Ct;)switch(Ct.tag){case 5:case 31:case 13:on=!1;return;case 27:case 3:on=!0;return;default:Ct=Ct.return}}function ba(e){if(e!==Ct)return!1;if(!Ge)return ym(e),Ge=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||Cu(e.type,e.memoizedProps)),s=!s),s&&at&&is(e),ym(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));at=Y0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));at=Y0(e)}else t===27?(t=at,Ss(e.type)?(e=Tu,Tu=null,at=e):at=t):at=Ct?un(e.stateNode.nextSibling):null;return!0}function Ls(){at=Ct=null,Ge=!1}function cc(){var e=rs;return e!==null&&(Vt===null?Vt=e:Vt.push.apply(Vt,e),rs=null),e}function gl(e){rs===null?rs=[e]:rs.push(e)}var uc=T(null),zs=null,Bn=null;function os(e,t,s){K(uc,t._currentValue),t._currentValue=s}function Ln(e){e._currentValue=uc.current,_(uc)}function dc(e,t,s){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===s)break;e=e.return}}function fc(e,t,s,i){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var d=c.dependencies;if(d!==null){var y=c.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=c;for(var D=0;D<t.length;D++)if(C.context===t[D]){d.lanes|=s,C=d.alternate,C!==null&&(C.lanes|=s),dc(d.return,s,e),i||(y=null);break e}d=C.next}}else if(c.tag===18){if(y=c.return,y===null)throw Error(o(341));y.lanes|=s,d=y.alternate,d!==null&&(d.lanes|=s),dc(y,s,e),y=null}else y=c.child;if(y!==null)y.return=c;else for(y=c;y!==null;){if(y===e){y=null;break}if(c=y.sibling,c!==null){c.return=y.return,y=c;break}y=y.return}c=y}}function ya(e,t,s,i){e=null;for(var c=t,d=!1;c!==null;){if(!d){if((c.flags&524288)!==0)d=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var y=c.alternate;if(y===null)throw Error(o(387));if(y=y.memoizedProps,y!==null){var C=c.type;Yt(c.pendingProps.value,y.value)||(e!==null?e.push(C):e=[C])}}else if(c===fe.current){if(y=c.alternate,y===null)throw Error(o(387));y.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Fl):e=[Fl])}c=c.return}e!==null&&fc(t,e,s,i),t.flags|=262144}function $r(e){for(e=e.firstContext;e!==null;){if(!Yt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Us(e){zs=e,Bn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function kt(e){return Sm(zs,e)}function Gr(e,t){return zs===null&&Us(e),Sm(e,t)}function Sm(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Bn===null){if(e===null)throw Error(o(308));Bn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Bn=Bn.next=t;return s}var ab=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},lb=n.unstable_scheduleCallback,rb=n.unstable_NormalPriority,pt={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mc(){return{controller:new ab,data:new Map,refCount:0}}function vl(e){e.refCount--,e.refCount===0&&lb(rb,function(){e.controller.abort()})}var bl=null,hc=0,Sa=0,ja=null;function ib(e,t){if(bl===null){var s=bl=[];hc=0,Sa=gu(),ja={status:"pending",value:void 0,then:function(i){s.push(i)}}}return hc++,t.then(jm,jm),t}function jm(){if(--hc===0&&bl!==null){ja!==null&&(ja.status="fulfilled");var e=bl;bl=null,Sa=0,ja=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ob(e,t){var s=[],i={status:"pending",value:null,reason:null,then:function(c){s.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<s.length;c++)(0,s[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<s.length;c++)(0,s[c])(void 0)}),i}var Nm=q.S;q.S=function(e,t){r0=le(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&ib(e,t),Nm!==null&&Nm(e,t)};var Hs=T(null);function pc(){var e=Hs.current;return e!==null?e:nt.pooledCache}function Fr(e,t){t===null?K(Hs,Hs.current):K(Hs,t.pool)}function wm(){var e=pc();return e===null?null:{parent:pt._currentValue,pool:e}}var Na=Error(o(460)),xc=Error(o(474)),Yr=Error(o(542)),Xr={then:function(){}};function Am(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Cm(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(qn,qn),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Em(e),e;default:if(typeof t.status=="string")t.then(qn,qn);else{if(e=nt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Em(e),e}throw $s=t,Na}}function Vs(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?($s=s,Na):s}}var $s=null;function km(){if($s===null)throw Error(o(459));var e=$s;return $s=null,e}function Em(e){if(e===Na||e===Yr)throw Error(o(483))}var wa=null,yl=0;function Qr(e){var t=yl;return yl+=1,wa===null&&(wa=[]),Cm(wa,e,t)}function Sl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ir(e,t){throw t.$$typeof===j?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Mm(e){function t(U,B){if(e){var F=U.deletions;F===null?(U.deletions=[B],U.flags|=16):F.push(B)}}function s(U,B){if(!e)return null;for(;B!==null;)t(U,B),B=B.sibling;return null}function i(U){for(var B=new Map;U!==null;)U.key!==null?B.set(U.key,U):B.set(U.index,U),U=U.sibling;return B}function c(U,B){return U=_n(U,B),U.index=0,U.sibling=null,U}function d(U,B,F){return U.index=F,e?(F=U.alternate,F!==null?(F=F.index,F<B?(U.flags|=67108866,B):F):(U.flags|=67108866,B)):(U.flags|=1048576,B)}function y(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function C(U,B,F,te){return B===null||B.tag!==6?(B=ac(F,U.mode,te),B.return=U,B):(B=c(B,F),B.return=U,B)}function D(U,B,F,te){var we=F.type;return we===N?W(U,B,F.props.children,te,F.key):B!==null&&(B.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===z&&Vs(we)===B.type)?(B=c(B,F.props),Sl(B,F),B.return=U,B):(B=Hr(F.type,F.key,F.props,null,U.mode,te),Sl(B,F),B.return=U,B)}function Y(U,B,F,te){return B===null||B.tag!==4||B.stateNode.containerInfo!==F.containerInfo||B.stateNode.implementation!==F.implementation?(B=lc(F,U.mode,te),B.return=U,B):(B=c(B,F.children||[]),B.return=U,B)}function W(U,B,F,te,we){return B===null||B.tag!==7?(B=Bs(F,U.mode,te,we),B.return=U,B):(B=c(B,F),B.return=U,B)}function se(U,B,F){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=ac(""+B,U.mode,F),B.return=U,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case M:return F=Hr(B.type,B.key,B.props,null,U.mode,F),Sl(F,B),F.return=U,F;case k:return B=lc(B,U.mode,F),B.return=U,B;case z:return B=Vs(B),se(U,B,F)}if($(B)||P(B))return B=Bs(B,U.mode,F,null),B.return=U,B;if(typeof B.then=="function")return se(U,Qr(B),F);if(B.$$typeof===E)return se(U,Gr(U,B),F);Ir(U,B)}return null}function I(U,B,F,te){var we=B!==null?B.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return we!==null?null:C(U,B,""+F,te);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case M:return F.key===we?D(U,B,F,te):null;case k:return F.key===we?Y(U,B,F,te):null;case z:return F=Vs(F),I(U,B,F,te)}if($(F)||P(F))return we!==null?null:W(U,B,F,te,null);if(typeof F.then=="function")return I(U,B,Qr(F),te);if(F.$$typeof===E)return I(U,B,Gr(U,F),te);Ir(U,F)}return null}function Z(U,B,F,te,we){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return U=U.get(F)||null,C(B,U,""+te,we);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case M:return U=U.get(te.key===null?F:te.key)||null,D(B,U,te,we);case k:return U=U.get(te.key===null?F:te.key)||null,Y(B,U,te,we);case z:return te=Vs(te),Z(U,B,F,te,we)}if($(te)||P(te))return U=U.get(F)||null,W(B,U,te,we,null);if(typeof te.then=="function")return Z(U,B,F,Qr(te),we);if(te.$$typeof===E)return Z(U,B,F,Gr(B,te),we);Ir(B,te)}return null}function ve(U,B,F,te){for(var we=null,Ye=null,ye=B,_e=B=0,$e=null;ye!==null&&_e<F.length;_e++){ye.index>_e?($e=ye,ye=null):$e=ye.sibling;var Xe=I(U,ye,F[_e],te);if(Xe===null){ye===null&&(ye=$e);break}e&&ye&&Xe.alternate===null&&t(U,ye),B=d(Xe,B,_e),Ye===null?we=Xe:Ye.sibling=Xe,Ye=Xe,ye=$e}if(_e===F.length)return s(U,ye),Ge&&On(U,_e),we;if(ye===null){for(;_e<F.length;_e++)ye=se(U,F[_e],te),ye!==null&&(B=d(ye,B,_e),Ye===null?we=ye:Ye.sibling=ye,Ye=ye);return Ge&&On(U,_e),we}for(ye=i(ye);_e<F.length;_e++)$e=Z(ye,U,_e,F[_e],te),$e!==null&&(e&&$e.alternate!==null&&ye.delete($e.key===null?_e:$e.key),B=d($e,B,_e),Ye===null?we=$e:Ye.sibling=$e,Ye=$e);return e&&ye.forEach(function(Cs){return t(U,Cs)}),Ge&&On(U,_e),we}function Ce(U,B,F,te){if(F==null)throw Error(o(151));for(var we=null,Ye=null,ye=B,_e=B=0,$e=null,Xe=F.next();ye!==null&&!Xe.done;_e++,Xe=F.next()){ye.index>_e?($e=ye,ye=null):$e=ye.sibling;var Cs=I(U,ye,Xe.value,te);if(Cs===null){ye===null&&(ye=$e);break}e&&ye&&Cs.alternate===null&&t(U,ye),B=d(Cs,B,_e),Ye===null?we=Cs:Ye.sibling=Cs,Ye=Cs,ye=$e}if(Xe.done)return s(U,ye),Ge&&On(U,_e),we;if(ye===null){for(;!Xe.done;_e++,Xe=F.next())Xe=se(U,Xe.value,te),Xe!==null&&(B=d(Xe,B,_e),Ye===null?we=Xe:Ye.sibling=Xe,Ye=Xe);return Ge&&On(U,_e),we}for(ye=i(ye);!Xe.done;_e++,Xe=F.next())Xe=Z(ye,U,_e,Xe.value,te),Xe!==null&&(e&&Xe.alternate!==null&&ye.delete(Xe.key===null?_e:Xe.key),B=d(Xe,B,_e),Ye===null?we=Xe:Ye.sibling=Xe,Ye=Xe);return e&&ye.forEach(function(by){return t(U,by)}),Ge&&On(U,_e),we}function tt(U,B,F,te){if(typeof F=="object"&&F!==null&&F.type===N&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case M:e:{for(var we=F.key;B!==null;){if(B.key===we){if(we=F.type,we===N){if(B.tag===7){s(U,B.sibling),te=c(B,F.props.children),te.return=U,U=te;break e}}else if(B.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===z&&Vs(we)===B.type){s(U,B.sibling),te=c(B,F.props),Sl(te,F),te.return=U,U=te;break e}s(U,B);break}else t(U,B);B=B.sibling}F.type===N?(te=Bs(F.props.children,U.mode,te,F.key),te.return=U,U=te):(te=Hr(F.type,F.key,F.props,null,U.mode,te),Sl(te,F),te.return=U,U=te)}return y(U);case k:e:{for(we=F.key;B!==null;){if(B.key===we)if(B.tag===4&&B.stateNode.containerInfo===F.containerInfo&&B.stateNode.implementation===F.implementation){s(U,B.sibling),te=c(B,F.children||[]),te.return=U,U=te;break e}else{s(U,B);break}else t(U,B);B=B.sibling}te=lc(F,U.mode,te),te.return=U,U=te}return y(U);case z:return F=Vs(F),tt(U,B,F,te)}if($(F))return ve(U,B,F,te);if(P(F)){if(we=P(F),typeof we!="function")throw Error(o(150));return F=we.call(F),Ce(U,B,F,te)}if(typeof F.then=="function")return tt(U,B,Qr(F),te);if(F.$$typeof===E)return tt(U,B,Gr(U,F),te);Ir(U,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,B!==null&&B.tag===6?(s(U,B.sibling),te=c(B,F),te.return=U,U=te):(s(U,B),te=ac(F,U.mode,te),te.return=U,U=te),y(U)):s(U,B)}return function(U,B,F,te){try{yl=0;var we=tt(U,B,F,te);return wa=null,we}catch(ye){if(ye===Na||ye===Yr)throw ye;var Ye=Xt(29,ye,null,U.mode);return Ye.lanes=te,Ye.return=U,Ye}finally{}}}var Gs=Mm(!0),Rm=Mm(!1),cs=!1;function gc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function vc(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 us(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ds(e,t,s){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(Ie&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Ur(e),mm(e,null,s),t}return zr(e,i,t,s),Ur(e)}function jl(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,Sf(e,s)}}function bc(e,t){var s=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,s===i)){var c=null,d=null;if(s=s.firstBaseUpdate,s!==null){do{var y={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};d===null?c=d=y:d=d.next=y,s=s.next}while(s!==null);d===null?c=d=t:d=d.next=t}else c=d=t;s={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:d,shared:i.shared,callbacks:i.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var yc=!1;function Nl(){if(yc){var e=ja;if(e!==null)throw e}}function wl(e,t,s,i){yc=!1;var c=e.updateQueue;cs=!1;var d=c.firstBaseUpdate,y=c.lastBaseUpdate,C=c.shared.pending;if(C!==null){c.shared.pending=null;var D=C,Y=D.next;D.next=null,y===null?d=Y:y.next=Y,y=D;var W=e.alternate;W!==null&&(W=W.updateQueue,C=W.lastBaseUpdate,C!==y&&(C===null?W.firstBaseUpdate=Y:C.next=Y,W.lastBaseUpdate=D))}if(d!==null){var se=c.baseState;y=0,W=Y=D=null,C=d;do{var I=C.lane&-536870913,Z=I!==C.lane;if(Z?(Ve&I)===I:(i&I)===I){I!==0&&I===Sa&&(yc=!0),W!==null&&(W=W.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var ve=e,Ce=C;I=t;var tt=s;switch(Ce.tag){case 1:if(ve=Ce.payload,typeof ve=="function"){se=ve.call(tt,se,I);break e}se=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ce.payload,I=typeof ve=="function"?ve.call(tt,se,I):ve,I==null)break e;se=b({},se,I);break e;case 2:cs=!0}}I=C.callback,I!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[I]:Z.push(I))}else Z={lane:I,tag:C.tag,payload:C.payload,callback:C.callback,next:null},W===null?(Y=W=Z,D=se):W=W.next=Z,y|=I;if(C=C.next,C===null){if(C=c.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);W===null&&(D=se),c.baseState=D,c.firstBaseUpdate=Y,c.lastBaseUpdate=W,d===null&&(c.shared.lanes=0),xs|=y,e.lanes=y,e.memoizedState=se}}function Tm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function qm(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)Tm(s[e],t)}var Aa=T(null),Kr=T(0);function Dm(e,t){e=Xn,K(Kr,e),K(Aa,t),Xn=e|t.baseLanes}function Sc(){K(Kr,Xn),K(Aa,Aa.current)}function jc(){Xn=Kr.current,_(Aa),_(Kr)}var Qt=T(null),cn=null;function fs(e){var t=e.alternate;K(ft,ft.current&1),K(Qt,e),cn===null&&(t===null||Aa.current!==null||t.memoizedState!==null)&&(cn=e)}function Nc(e){K(ft,ft.current),K(Qt,e),cn===null&&(cn=e)}function _m(e){e.tag===22?(K(ft,ft.current),K(Qt,e),cn===null&&(cn=e)):ms()}function ms(){K(ft,ft.current),K(Qt,Qt.current)}function It(e){_(Qt),cn===e&&(cn=null),_(ft)}var ft=T(0);function Zr(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Mu(s)||Ru(s)))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 zn=0,qe=null,We=null,xt=null,Jr=!1,Ca=!1,Fs=!1,Pr=0,Al=0,ka=null,cb=0;function ct(){throw Error(o(321))}function wc(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Yt(e[s],t[s]))return!1;return!0}function Ac(e,t,s,i,c,d){return zn=d,qe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,q.H=e===null||e.memoizedState===null?gh:Hc,Fs=!1,d=s(i,c),Fs=!1,Ca&&(d=Bm(t,s,i,c)),Om(e),d}function Om(e){q.H=El;var t=We!==null&&We.next!==null;if(zn=0,xt=We=qe=null,Jr=!1,Al=0,ka=null,t)throw Error(o(300));e===null||gt||(e=e.dependencies,e!==null&&$r(e)&&(gt=!0))}function Bm(e,t,s,i){qe=e;var c=0;do{if(Ca&&(ka=null),Al=0,Ca=!1,25<=c)throw Error(o(301));if(c+=1,xt=We=null,e.updateQueue!=null){var d=e.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}q.H=vh,d=t(s,i)}while(Ca);return d}function ub(){var e=q.H,t=e.useState()[0];return t=typeof t.then=="function"?Cl(t):t,e=e.useState()[0],(We!==null?We.memoizedState:null)!==e&&(qe.flags|=1024),t}function Cc(){var e=Pr!==0;return Pr=0,e}function kc(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function Ec(e){if(Jr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Jr=!1}zn=0,xt=We=qe=null,Ca=!1,Al=Pr=0,ka=null}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xt===null?qe.memoizedState=xt=e:xt=xt.next=e,xt}function mt(){if(We===null){var e=qe.alternate;e=e!==null?e.memoizedState:null}else e=We.next;var t=xt===null?qe.memoizedState:xt.next;if(t!==null)xt=t,We=e;else{if(e===null)throw qe.alternate===null?Error(o(467)):Error(o(310));We=e,e={memoizedState:We.memoizedState,baseState:We.baseState,baseQueue:We.baseQueue,queue:We.queue,next:null},xt===null?qe.memoizedState=xt=e:xt=xt.next=e}return xt}function Wr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Cl(e){var t=Al;return Al+=1,ka===null&&(ka=[]),e=Cm(ka,e,t),t=qe,(xt===null?t.memoizedState:xt.next)===null&&(t=t.alternate,q.H=t===null||t.memoizedState===null?gh:Hc),e}function ei(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Cl(e);if(e.$$typeof===E)return kt(e)}throw Error(o(438,String(e)))}function Mc(e){var t=null,s=qe.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var i=qe.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=Wr(),qe.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),i=0;i<e;i++)s[i]=G;return t.index++,s}function Un(e,t){return typeof t=="function"?t(e):t}function ti(e){var t=mt();return Rc(t,We,e)}function Rc(e,t,s){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=s;var c=e.baseQueue,d=i.pending;if(d!==null){if(c!==null){var y=c.next;c.next=d.next,d.next=y}t.baseQueue=c=d,i.pending=null}if(d=e.baseState,c===null)e.memoizedState=d;else{t=c.next;var C=y=null,D=null,Y=t,W=!1;do{var se=Y.lane&-536870913;if(se!==Y.lane?(Ve&se)===se:(zn&se)===se){var I=Y.revertLane;if(I===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),se===Sa&&(W=!0);else if((zn&I)===I){Y=Y.next,I===Sa&&(W=!0);continue}else se={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(C=D=se,y=d):D=D.next=se,qe.lanes|=I,xs|=I;se=Y.action,Fs&&s(d,se),d=Y.hasEagerState?Y.eagerState:s(d,se)}else I={lane:se,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(C=D=I,y=d):D=D.next=I,qe.lanes|=se,xs|=se;Y=Y.next}while(Y!==null&&Y!==t);if(D===null?y=d:D.next=C,!Yt(d,e.memoizedState)&&(gt=!0,W&&(s=ja,s!==null)))throw s;e.memoizedState=d,e.baseState=y,e.baseQueue=D,i.lastRenderedState=d}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Tc(e){var t=mt(),s=t.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=e;var i=s.dispatch,c=s.pending,d=t.memoizedState;if(c!==null){s.pending=null;var y=c=c.next;do d=e(d,y.action),y=y.next;while(y!==c);Yt(d,t.memoizedState)||(gt=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),s.lastRenderedState=d}return[d,i]}function Lm(e,t,s){var i=qe,c=mt(),d=Ge;if(d){if(s===void 0)throw Error(o(407));s=s()}else s=t();var y=!Yt((We||c).memoizedState,s);if(y&&(c.memoizedState=s,gt=!0),c=c.queue,_c(Hm.bind(null,i,c,e),[e]),c.getSnapshot!==t||y||xt!==null&&xt.memoizedState.tag&1){if(i.flags|=2048,Ea(9,{destroy:void 0},Um.bind(null,i,c,s,t),null),nt===null)throw Error(o(349));d||(zn&127)!==0||zm(i,t,s)}return s}function zm(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=qe.updateQueue,t===null?(t=Wr(),qe.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Um(e,t,s,i){t.value=s,t.getSnapshot=i,Vm(t)&&$m(e)}function Hm(e,t,s){return s(function(){Vm(t)&&$m(e)})}function Vm(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Yt(e,s)}catch{return!0}}function $m(e){var t=Os(e,2);t!==null&&$t(t,e,2)}function qc(e){var t=_t();if(typeof e=="function"){var s=e;if(e=s(),Fs){He(!0);try{s()}finally{He(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:e},t}function Gm(e,t,s,i){return e.baseState=s,Rc(e,We,typeof i=="function"?i:Un)}function db(e,t,s,i,c){if(ai(e))throw Error(o(485));if(e=t.action,e!==null){var d={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){d.listeners.push(y)}};q.T!==null?s(!0):d.isTransition=!1,i(d),s=t.pending,s===null?(d.next=t.pending=d,Fm(t,d)):(d.next=s.next,t.pending=s.next=d)}}function Fm(e,t){var s=t.action,i=t.payload,c=e.state;if(t.isTransition){var d=q.T,y={};q.T=y;try{var C=s(c,i),D=q.S;D!==null&&D(y,C),Ym(e,t,C)}catch(Y){Dc(e,t,Y)}finally{d!==null&&y.types!==null&&(d.types=y.types),q.T=d}}else try{d=s(c,i),Ym(e,t,d)}catch(Y){Dc(e,t,Y)}}function Ym(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(i){Xm(e,t,i)},function(i){return Dc(e,t,i)}):Xm(e,t,s)}function Xm(e,t,s){t.status="fulfilled",t.value=s,Qm(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Fm(e,s)))}function Dc(e,t,s){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=s,Qm(t),t=t.next;while(t!==i)}e.action=null}function Qm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Im(e,t){return t}function Km(e,t){if(Ge){var s=nt.formState;if(s!==null){e:{var i=qe;if(Ge){if(at){t:{for(var c=at,d=on;c.nodeType!==8;){if(!d){c=null;break t}if(c=un(c.nextSibling),c===null){c=null;break t}}d=c.data,c=d==="F!"||d==="F"?c:null}if(c){at=un(c.nextSibling),i=c.data==="F!";break e}}is(i)}i=!1}i&&(t=s[0])}}return s=_t(),s.memoizedState=s.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Im,lastRenderedState:t},s.queue=i,s=hh.bind(null,qe,i),i.dispatch=s,i=qc(!1),d=Uc.bind(null,qe,!1,i.queue),i=_t(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,s=db.bind(null,qe,c,d,s),c.dispatch=s,i.memoizedState=e,[t,s,!1]}function Zm(e){var t=mt();return Jm(t,We,e)}function Jm(e,t,s){if(t=Rc(e,t,Im)[0],e=ti(Un)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=Cl(t)}catch(y){throw y===Na?Yr:y}else i=t;t=mt();var c=t.queue,d=c.dispatch;return s!==t.memoizedState&&(qe.flags|=2048,Ea(9,{destroy:void 0},fb.bind(null,c,s),null)),[i,d,e]}function fb(e,t){e.action=t}function Pm(e){var t=mt(),s=We;if(s!==null)return Jm(t,s,e);mt(),t=t.memoizedState,s=mt();var i=s.queue.dispatch;return s.memoizedState=e,[t,i,!1]}function Ea(e,t,s,i){return e={tag:e,create:s,deps:i,inst:t,next:null},t=qe.updateQueue,t===null&&(t=Wr(),qe.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(i=s.next,s.next=e,e.next=i,t.lastEffect=e),e}function Wm(){return mt().memoizedState}function ni(e,t,s,i){var c=_t();qe.flags|=e,c.memoizedState=Ea(1|t,{destroy:void 0},s,i===void 0?null:i)}function si(e,t,s,i){var c=mt();i=i===void 0?null:i;var d=c.memoizedState.inst;We!==null&&i!==null&&wc(i,We.memoizedState.deps)?c.memoizedState=Ea(t,d,s,i):(qe.flags|=e,c.memoizedState=Ea(1|t,d,s,i))}function eh(e,t){ni(8390656,8,e,t)}function _c(e,t){si(2048,8,e,t)}function mb(e){qe.flags|=4;var t=qe.updateQueue;if(t===null)t=Wr(),qe.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function th(e){var t=mt().memoizedState;return mb({ref:t,nextImpl:e}),function(){if((Ie&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function nh(e,t){return si(4,2,e,t)}function sh(e,t){return si(4,4,e,t)}function ah(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function lh(e,t,s){s=s!=null?s.concat([e]):null,si(4,4,ah.bind(null,t,e),s)}function Oc(){}function rh(e,t){var s=mt();t=t===void 0?null:t;var i=s.memoizedState;return t!==null&&wc(t,i[1])?i[0]:(s.memoizedState=[e,t],e)}function ih(e,t){var s=mt();t=t===void 0?null:t;var i=s.memoizedState;if(t!==null&&wc(t,i[1]))return i[0];if(i=e(),Fs){He(!0);try{e()}finally{He(!1)}}return s.memoizedState=[i,t],i}function Bc(e,t,s){return s===void 0||(zn&1073741824)!==0&&(Ve&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=o0(),qe.lanes|=e,xs|=e,s)}function oh(e,t,s,i){return Yt(s,t)?s:Aa.current!==null?(e=Bc(e,s,i),Yt(e,t)||(gt=!0),e):(zn&42)===0||(zn&1073741824)!==0&&(Ve&261930)===0?(gt=!0,e.memoizedState=s):(e=o0(),qe.lanes|=e,xs|=e,t)}function ch(e,t,s,i,c){var d=H.p;H.p=d!==0&&8>d?d:8;var y=q.T,C={};q.T=C,Uc(e,!1,t,s);try{var D=c(),Y=q.S;if(Y!==null&&Y(C,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var W=ob(D,i);kl(e,t,W,Jt(e))}else kl(e,t,i,Jt(e))}catch(se){kl(e,t,{then:function(){},status:"rejected",reason:se},Jt())}finally{H.p=d,y!==null&&C.types!==null&&(y.types=C.types),q.T=y}}function hb(){}function Lc(e,t,s,i){if(e.tag!==5)throw Error(o(476));var c=uh(e).queue;ch(e,c,t,J,s===null?hb:function(){return dh(e),s(i)})}function uh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:J},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function dh(e){var t=uh(e);t.next===null&&(t=e.alternate.memoizedState),kl(e,t.next.queue,{},Jt())}function zc(){return kt(Fl)}function fh(){return mt().memoizedState}function mh(){return mt().memoizedState}function pb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Jt();e=us(s);var i=ds(t,e,s);i!==null&&($t(i,t,s),jl(i,t,s)),t={cache:mc()},e.payload=t;return}t=t.return}}function xb(e,t,s){var i=Jt();s={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},ai(e)?ph(t,s):(s=nc(e,t,s,i),s!==null&&($t(s,e,i),xh(s,t,i)))}function hh(e,t,s){var i=Jt();kl(e,t,s,i)}function kl(e,t,s,i){var c={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(ai(e))ph(t,c);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=t.lastRenderedReducer,d!==null))try{var y=t.lastRenderedState,C=d(y,s);if(c.hasEagerState=!0,c.eagerState=C,Yt(C,y))return zr(e,t,c,0),nt===null&&Lr(),!1}catch{}finally{}if(s=nc(e,t,c,i),s!==null)return $t(s,e,i),xh(s,t,i),!0}return!1}function Uc(e,t,s,i){if(i={lane:2,revertLane:gu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},ai(e)){if(t)throw Error(o(479))}else t=nc(e,s,i,2),t!==null&&$t(t,e,2)}function ai(e){var t=e.alternate;return e===qe||t!==null&&t===qe}function ph(e,t){Ca=Jr=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function xh(e,t,s){if((s&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,Sf(e,s)}}var El={readContext:kt,use:ei,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};El.useEffectEvent=ct;var gh={readContext:kt,use:ei,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:kt,useEffect:eh,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,ni(4194308,4,ah.bind(null,t,e),s)},useLayoutEffect:function(e,t){return ni(4194308,4,e,t)},useInsertionEffect:function(e,t){ni(4,2,e,t)},useMemo:function(e,t){var s=_t();t=t===void 0?null:t;var i=e();if(Fs){He(!0);try{e()}finally{He(!1)}}return s.memoizedState=[i,t],i},useReducer:function(e,t,s){var i=_t();if(s!==void 0){var c=s(t);if(Fs){He(!0);try{s(t)}finally{He(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=xb.bind(null,qe,e),[i.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:function(e){e=qc(e);var t=e.queue,s=hh.bind(null,qe,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:Oc,useDeferredValue:function(e,t){var s=_t();return Bc(s,e,t)},useTransition:function(){var e=qc(!1);return e=ch.bind(null,qe,e.queue,!0,!1),_t().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var i=qe,c=_t();if(Ge){if(s===void 0)throw Error(o(407));s=s()}else{if(s=t(),nt===null)throw Error(o(349));(Ve&127)!==0||zm(i,t,s)}c.memoizedState=s;var d={value:s,getSnapshot:t};return c.queue=d,eh(Hm.bind(null,i,d,e),[e]),i.flags|=2048,Ea(9,{destroy:void 0},Um.bind(null,i,d,s,t),null),s},useId:function(){var e=_t(),t=nt.identifierPrefix;if(Ge){var s=wn,i=Nn;s=(i&~(1<<32-Pe(i)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Pr++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=cb++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:zc,useFormState:Km,useActionState:Km,useOptimistic:function(e){var t=_t();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=Uc.bind(null,qe,!0,s),s.dispatch=t,[e,t]},useMemoCache:Mc,useCacheRefresh:function(){return _t().memoizedState=pb.bind(null,qe)},useEffectEvent:function(e){var t=_t(),s={impl:e};return t.memoizedState=s,function(){if((Ie&2)!==0)throw Error(o(440));return s.impl.apply(void 0,arguments)}}},Hc={readContext:kt,use:ei,useCallback:rh,useContext:kt,useEffect:_c,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:sh,useMemo:ih,useReducer:ti,useRef:Wm,useState:function(){return ti(Un)},useDebugValue:Oc,useDeferredValue:function(e,t){var s=mt();return oh(s,We.memoizedState,e,t)},useTransition:function(){var e=ti(Un)[0],t=mt().memoizedState;return[typeof e=="boolean"?e:Cl(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:zc,useFormState:Zm,useActionState:Zm,useOptimistic:function(e,t){var s=mt();return Gm(s,We,e,t)},useMemoCache:Mc,useCacheRefresh:mh};Hc.useEffectEvent=th;var vh={readContext:kt,use:ei,useCallback:rh,useContext:kt,useEffect:_c,useImperativeHandle:lh,useInsertionEffect:nh,useLayoutEffect:sh,useMemo:ih,useReducer:Tc,useRef:Wm,useState:function(){return Tc(Un)},useDebugValue:Oc,useDeferredValue:function(e,t){var s=mt();return We===null?Bc(s,e,t):oh(s,We.memoizedState,e,t)},useTransition:function(){var e=Tc(Un)[0],t=mt().memoizedState;return[typeof e=="boolean"?e:Cl(e),t]},useSyncExternalStore:Lm,useId:fh,useHostTransitionStatus:zc,useFormState:Pm,useActionState:Pm,useOptimistic:function(e,t){var s=mt();return We!==null?Gm(s,We,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:Mc,useCacheRefresh:mh};vh.useEffectEvent=th;function Vc(e,t,s,i){t=e.memoizedState,s=s(i,t),s=s==null?t:b({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var $c={enqueueSetState:function(e,t,s){e=e._reactInternals;var i=Jt(),c=us(i);c.payload=t,s!=null&&(c.callback=s),t=ds(e,c,i),t!==null&&($t(t,e,i),jl(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var i=Jt(),c=us(i);c.tag=1,c.payload=t,s!=null&&(c.callback=s),t=ds(e,c,i),t!==null&&($t(t,e,i),jl(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Jt(),i=us(s);i.tag=2,t!=null&&(i.callback=t),t=ds(e,i,s),t!==null&&($t(t,e,s),jl(t,e,s))}};function bh(e,t,s,i,c,d,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,d,y):t.prototype&&t.prototype.isPureReactComponent?!hl(s,i)||!hl(c,d):!0}function yh(e,t,s,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,i),t.state!==e&&$c.enqueueReplaceState(t,t.state,null)}function Ys(e,t){var s=t;if("ref"in t){s={};for(var i in t)i!=="ref"&&(s[i]=t[i])}if(e=e.defaultProps){s===t&&(s=b({},s));for(var c in e)s[c]===void 0&&(s[c]=e[c])}return s}function Sh(e){Br(e)}function jh(e){console.error(e)}function Nh(e){Br(e)}function li(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function wh(e,t,s){try{var i=e.onCaughtError;i(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Gc(e,t,s){return s=us(s),s.tag=3,s.payload={element:null},s.callback=function(){li(e,t)},s}function Ah(e){return e=us(e),e.tag=3,e}function Ch(e,t,s,i){var c=s.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;e.payload=function(){return c(d)},e.callback=function(){wh(t,s,i)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){wh(t,s,i),typeof c!="function"&&(gs===null?gs=new Set([this]):gs.add(this));var C=i.stack;this.componentDidCatch(i.value,{componentStack:C!==null?C:""})})}function gb(e,t,s,i,c){if(s.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=s.alternate,t!==null&&ya(t,s,c,!0),s=Qt.current,s!==null){switch(s.tag){case 31:case 13:return cn===null?gi():s.alternate===null&&ut===0&&(ut=3),s.flags&=-257,s.flags|=65536,s.lanes=c,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([i]):t.add(i),hu(e,i,c)),!1;case 22:return s.flags|=65536,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([i]):s.add(i)),hu(e,i,c)),!1}throw Error(o(435,s.tag))}return hu(e,i,c),gi(),!1}if(Ge)return t=Qt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==oc&&(e=Error(o(422),{cause:i}),gl(an(e,s)))):(i!==oc&&(t=Error(o(423),{cause:i}),gl(an(t,s))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=an(i,s),c=Gc(e.stateNode,i,c),bc(e,c),ut!==4&&(ut=2)),!1;var d=Error(o(520),{cause:i});if(d=an(d,s),Bl===null?Bl=[d]:Bl.push(d),ut!==4&&(ut=2),t===null)return!0;i=an(i,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=c&-c,s.lanes|=e,e=Gc(s.stateNode,i,e),bc(s,e),!1;case 1:if(t=s.type,d=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(gs===null||!gs.has(d))))return s.flags|=65536,c&=-c,s.lanes|=c,c=Ah(c),Ch(c,e,s,i),bc(s,c),!1}s=s.return}while(s!==null);return!1}var Fc=Error(o(461)),gt=!1;function Et(e,t,s,i){t.child=e===null?Rm(t,null,s,i):Gs(t,e.child,s,i)}function kh(e,t,s,i,c){s=s.render;var d=t.ref;if("ref"in i){var y={};for(var C in i)C!=="ref"&&(y[C]=i[C])}else y=i;return Us(t),i=Ac(e,t,s,y,d,c),C=Cc(),e!==null&&!gt?(kc(e,t,c),Hn(e,t,c)):(Ge&&C&&rc(t),t.flags|=1,Et(e,t,i,c),t.child)}function Eh(e,t,s,i,c){if(e===null){var d=s.type;return typeof d=="function"&&!sc(d)&&d.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=d,Mh(e,t,d,i,c)):(e=Hr(s.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(d=e.child,!Pc(e,c)){var y=d.memoizedProps;if(s=s.compare,s=s!==null?s:hl,s(y,i)&&e.ref===t.ref)return Hn(e,t,c)}return t.flags|=1,e=_n(d,i),e.ref=t.ref,e.return=t,t.child=e}function Mh(e,t,s,i,c){if(e!==null){var d=e.memoizedProps;if(hl(d,i)&&e.ref===t.ref)if(gt=!1,t.pendingProps=i=d,Pc(e,c))(e.flags&131072)!==0&&(gt=!0);else return t.lanes=e.lanes,Hn(e,t,c)}return Yc(e,t,s,i,c)}function Rh(e,t,s,i){var c=i.children,d=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(d=d!==null?d.baseLanes|s:s,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~d}else i=0,t.child=null;return Th(e,t,d,s,i)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Fr(t,d!==null?d.cachePool:null),d!==null?Dm(t,d):Sc(),_m(t);else return i=t.lanes=536870912,Th(e,t,d!==null?d.baseLanes|s:s,s,i)}else d!==null?(Fr(t,d.cachePool),Dm(t,d),ms(),t.memoizedState=null):(e!==null&&Fr(t,null),Sc(),ms());return Et(e,t,c,s),t.child}function Ml(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Th(e,t,s,i,c){var d=pc();return d=d===null?null:{parent:pt._currentValue,pool:d},t.memoizedState={baseLanes:s,cachePool:d},e!==null&&Fr(t,null),Sc(),_m(t),e!==null&&ya(e,t,i,!0),t.childLanes=c,null}function ri(e,t){return t=oi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function qh(e,t,s){return Gs(t,e.child,null,s),e=ri(t,t.pendingProps),e.flags|=2,It(t),t.memoizedState=null,e}function vb(e,t,s){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ge){if(i.mode==="hidden")return e=ri(t,i),t.lanes=536870912,Ml(null,e);if(Nc(t),(e=at)?(e=F0(e,on),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ls!==null?{id:Nn,overflow:wn}:null,retryLane:536870912,hydrationErrors:null},s=pm(e),s.return=t,t.child=s,Ct=t,at=null)):e=null,e===null)throw is(t);return t.lanes=536870912,null}return ri(t,i)}var d=e.memoizedState;if(d!==null){var y=d.dehydrated;if(Nc(t),c)if(t.flags&256)t.flags&=-257,t=qh(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(gt||ya(e,t,s,!1),c=(s&e.childLanes)!==0,gt||c){if(i=nt,i!==null&&(y=jf(i,s),y!==0&&y!==d.retryLane))throw d.retryLane=y,Os(e,y),$t(i,e,y),Fc;gi(),t=qh(e,t,s)}else e=d.treeContext,at=un(y.nextSibling),Ct=t,Ge=!0,rs=null,on=!1,e!==null&&vm(t,e),t=ri(t,i),t.flags|=4096;return t}return e=_n(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ii(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(o(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function Yc(e,t,s,i,c){return Us(t),s=Ac(e,t,s,i,void 0,c),i=Cc(),e!==null&&!gt?(kc(e,t,c),Hn(e,t,c)):(Ge&&i&&rc(t),t.flags|=1,Et(e,t,s,c),t.child)}function Dh(e,t,s,i,c,d){return Us(t),t.updateQueue=null,s=Bm(t,i,s,c),Om(e),i=Cc(),e!==null&&!gt?(kc(e,t,d),Hn(e,t,d)):(Ge&&i&&rc(t),t.flags|=1,Et(e,t,s,d),t.child)}function _h(e,t,s,i,c){if(Us(t),t.stateNode===null){var d=xa,y=s.contextType;typeof y=="object"&&y!==null&&(d=kt(y)),d=new s(i,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=$c,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=i,d.state=t.memoizedState,d.refs={},gc(t),y=s.contextType,d.context=typeof y=="object"&&y!==null?kt(y):xa,d.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Vc(t,s,y,i),d.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(y=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),y!==d.state&&$c.enqueueReplaceState(d,d.state,null),wl(t,i,d,c),Nl(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){d=t.stateNode;var C=t.memoizedProps,D=Ys(s,C);d.props=D;var Y=d.context,W=s.contextType;y=xa,typeof W=="object"&&W!==null&&(y=kt(W));var se=s.getDerivedStateFromProps;W=typeof se=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=t.pendingProps!==C,W||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||Y!==y)&&yh(t,d,i,y),cs=!1;var I=t.memoizedState;d.state=I,wl(t,i,d,c),Nl(),Y=t.memoizedState,C||I!==Y||cs?(typeof se=="function"&&(Vc(t,s,se,i),Y=t.memoizedState),(D=cs||bh(t,s,D,i,I,Y,y))?(W||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(t.flags|=4194308)):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=Y),d.props=i,d.state=Y,d.context=y,i=D):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{d=t.stateNode,vc(e,t),y=t.memoizedProps,W=Ys(s,y),d.props=W,se=t.pendingProps,I=d.context,Y=s.contextType,D=xa,typeof Y=="object"&&Y!==null&&(D=kt(Y)),C=s.getDerivedStateFromProps,(Y=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(y!==se||I!==D)&&yh(t,d,i,D),cs=!1,I=t.memoizedState,d.state=I,wl(t,i,d,c),Nl();var Z=t.memoizedState;y!==se||I!==Z||cs||e!==null&&e.dependencies!==null&&$r(e.dependencies)?(typeof C=="function"&&(Vc(t,s,C,i),Z=t.memoizedState),(W=cs||bh(t,s,W,i,I,Z,D)||e!==null&&e.dependencies!==null&&$r(e.dependencies))?(Y||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(i,Z,D),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(i,Z,D)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&I===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&I===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=Z),d.props=i,d.state=Z,d.context=D,i=W):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&I===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&I===e.memoizedState||(t.flags|=1024),i=!1)}return d=i,ii(e,t),i=(t.flags&128)!==0,d||i?(d=t.stateNode,s=i&&typeof s.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,e!==null&&i?(t.child=Gs(t,e.child,null,c),t.child=Gs(t,null,s,c)):Et(e,t,s,c),t.memoizedState=d.state,e=t.child):e=Hn(e,t,c),e}function Oh(e,t,s,i){return Ls(),t.flags|=256,Et(e,t,s,i),t.child}var Xc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Qc(e){return{baseLanes:e,cachePool:wm()}}function Ic(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Zt),e}function Bh(e,t,s){var i=t.pendingProps,c=!1,d=(t.flags&128)!==0,y;if((y=d)||(y=e!==null&&e.memoizedState===null?!1:(ft.current&2)!==0),y&&(c=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ge){if(c?fs(t):ms(),(e=at)?(e=F0(e,on),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ls!==null?{id:Nn,overflow:wn}:null,retryLane:536870912,hydrationErrors:null},s=pm(e),s.return=t,t.child=s,Ct=t,at=null)):e=null,e===null)throw is(t);return Ru(e)?t.lanes=32:t.lanes=536870912,null}var C=i.children;return i=i.fallback,c?(ms(),c=t.mode,C=oi({mode:"hidden",children:C},c),i=Bs(i,c,s,null),C.return=t,i.return=t,C.sibling=i,t.child=C,i=t.child,i.memoizedState=Qc(s),i.childLanes=Ic(e,y,s),t.memoizedState=Xc,Ml(null,i)):(fs(t),Kc(t,C))}var D=e.memoizedState;if(D!==null&&(C=D.dehydrated,C!==null)){if(d)t.flags&256?(fs(t),t.flags&=-257,t=Zc(e,t,s)):t.memoizedState!==null?(ms(),t.child=e.child,t.flags|=128,t=null):(ms(),C=i.fallback,c=t.mode,i=oi({mode:"visible",children:i.children},c),C=Bs(C,c,s,null),C.flags|=2,i.return=t,C.return=t,i.sibling=C,t.child=i,Gs(t,e.child,null,s),i=t.child,i.memoizedState=Qc(s),i.childLanes=Ic(e,y,s),t.memoizedState=Xc,t=Ml(null,i));else if(fs(t),Ru(C)){if(y=C.nextSibling&&C.nextSibling.dataset,y)var Y=y.dgst;y=Y,i=Error(o(419)),i.stack="",i.digest=y,gl({value:i,source:null,stack:null}),t=Zc(e,t,s)}else if(gt||ya(e,t,s,!1),y=(s&e.childLanes)!==0,gt||y){if(y=nt,y!==null&&(i=jf(y,s),i!==0&&i!==D.retryLane))throw D.retryLane=i,Os(e,i),$t(y,e,i),Fc;Mu(C)||gi(),t=Zc(e,t,s)}else Mu(C)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,at=un(C.nextSibling),Ct=t,Ge=!0,rs=null,on=!1,e!==null&&vm(t,e),t=Kc(t,i.children),t.flags|=4096);return t}return c?(ms(),C=i.fallback,c=t.mode,D=e.child,Y=D.sibling,i=_n(D,{mode:"hidden",children:i.children}),i.subtreeFlags=D.subtreeFlags&65011712,Y!==null?C=_n(Y,C):(C=Bs(C,c,s,null),C.flags|=2),C.return=t,i.return=t,i.sibling=C,t.child=i,Ml(null,i),i=t.child,C=e.child.memoizedState,C===null?C=Qc(s):(c=C.cachePool,c!==null?(D=pt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=wm(),C={baseLanes:C.baseLanes|s,cachePool:c}),i.memoizedState=C,i.childLanes=Ic(e,y,s),t.memoizedState=Xc,Ml(e.child,i)):(fs(t),s=e.child,e=s.sibling,s=_n(s,{mode:"visible",children:i.children}),s.return=t,s.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=s,t.memoizedState=null,s)}function Kc(e,t){return t=oi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function oi(e,t){return e=Xt(22,e,null,t),e.lanes=0,e}function Zc(e,t,s){return Gs(t,e.child,null,s),e=Kc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Lh(e,t,s){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),dc(e.return,t,s)}function Jc(e,t,s,i,c,d){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:s,tailMode:c,treeForkCount:d}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=i,y.tail=s,y.tailMode=c,y.treeForkCount=d)}function zh(e,t,s){var i=t.pendingProps,c=i.revealOrder,d=i.tail;i=i.children;var y=ft.current,C=(y&2)!==0;if(C?(y=y&1|2,t.flags|=128):y&=1,K(ft,y),Et(e,t,i,s),i=Ge?xl:0,!C&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Lh(e,s,t);else if(e.tag===19)Lh(e,s,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(s=t.child,c=null;s!==null;)e=s.alternate,e!==null&&Zr(e)===null&&(c=s),s=s.sibling;s=c,s===null?(c=t.child,t.child=null):(c=s.sibling,s.sibling=null),Jc(t,!1,c,s,d,i);break;case"backwards":case"unstable_legacy-backwards":for(s=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Zr(e)===null){t.child=c;break}e=c.sibling,c.sibling=s,s=c,c=e}Jc(t,!0,s,null,d,i);break;case"together":Jc(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Hn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),xs|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(ya(e,t,s,!1),(s&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,s=_n(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=_n(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Pc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&$r(e)))}function bb(e,t,s){switch(t.tag){case 3:be(t,t.stateNode.containerInfo),os(t,pt,e.memoizedState.cache),Ls();break;case 27:case 5:xe(t);break;case 4:be(t,t.stateNode.containerInfo);break;case 10:os(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Nc(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(fs(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Bh(e,t,s):(fs(t),e=Hn(e,t,s),e!==null?e.sibling:null);fs(t);break;case 19:var c=(e.flags&128)!==0;if(i=(s&t.childLanes)!==0,i||(ya(e,t,s,!1),i=(s&t.childLanes)!==0),c){if(i)return zh(e,t,s);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),K(ft,ft.current),i)break;return null;case 22:return t.lanes=0,Rh(e,t,s,t.pendingProps);case 24:os(t,pt,e.memoizedState.cache)}return Hn(e,t,s)}function Uh(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)gt=!0;else{if(!Pc(e,s)&&(t.flags&128)===0)return gt=!1,bb(e,t,s);gt=(e.flags&131072)!==0}else gt=!1,Ge&&(t.flags&1048576)!==0&&gm(t,xl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Vs(t.elementType),t.type=e,typeof e=="function")sc(e)?(i=Ys(e,i),t.tag=1,t=_h(null,t,e,i,s)):(t.tag=0,t=Yc(null,t,e,i,s));else{if(e!=null){var c=e.$$typeof;if(c===A){t.tag=11,t=kh(null,t,e,i,s);break e}else if(c===O){t.tag=14,t=Eh(null,t,e,i,s);break e}}throw t=ie(e)||e,Error(o(306,t,""))}}return t;case 0:return Yc(e,t,t.type,t.pendingProps,s);case 1:return i=t.type,c=Ys(i,t.pendingProps),_h(e,t,i,c,s);case 3:e:{if(be(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var d=t.memoizedState;c=d.element,vc(e,t),wl(t,i,null,s);var y=t.memoizedState;if(i=y.cache,os(t,pt,i),i!==d.cache&&fc(t,[pt],s,!0),Nl(),i=y.element,d.isDehydrated)if(d={element:i,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=d,t.memoizedState=d,t.flags&256){t=Oh(e,t,i,s);break e}else if(i!==c){c=an(Error(o(424)),t),gl(c),t=Oh(e,t,i,s);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(at=un(e.firstChild),Ct=t,Ge=!0,rs=null,on=!0,s=Rm(t,null,i,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(Ls(),i===c){t=Hn(e,t,s);break e}Et(e,t,i,s)}t=t.child}return t;case 26:return ii(e,t),e===null?(s=Z0(t.type,null,t.pendingProps,null))?t.memoizedState=s:Ge||(s=t.type,e=t.pendingProps,i=wi(ce.current).createElement(s),i[At]=t,i[Bt]=e,Mt(i,s,e),jt(i),t.stateNode=i):t.memoizedState=Z0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Ge&&(i=t.stateNode=Q0(t.type,t.pendingProps,ce.current),Ct=t,on=!0,c=at,Ss(t.type)?(Tu=c,at=un(i.firstChild)):at=c),Et(e,t,t.pendingProps.children,s),ii(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ge&&((c=i=at)&&(i=Kb(i,t.type,t.pendingProps,on),i!==null?(t.stateNode=i,Ct=t,at=un(i.firstChild),on=!1,c=!0):c=!1),c||is(t)),xe(t),c=t.type,d=t.pendingProps,y=e!==null?e.memoizedProps:null,i=d.children,Cu(c,d)?i=null:y!==null&&Cu(c,y)&&(t.flags|=32),t.memoizedState!==null&&(c=Ac(e,t,ub,null,null,s),Fl._currentValue=c),ii(e,t),Et(e,t,i,s),t.child;case 6:return e===null&&Ge&&((e=s=at)&&(s=Zb(s,t.pendingProps,on),s!==null?(t.stateNode=s,Ct=t,at=null,e=!0):e=!1),e||is(t)),null;case 13:return Bh(e,t,s);case 4:return be(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Gs(t,null,i,s):Et(e,t,i,s),t.child;case 11:return kh(e,t,t.type,t.pendingProps,s);case 7:return Et(e,t,t.pendingProps,s),t.child;case 8:return Et(e,t,t.pendingProps.children,s),t.child;case 12:return Et(e,t,t.pendingProps.children,s),t.child;case 10:return i=t.pendingProps,os(t,t.type,i.value),Et(e,t,i.children,s),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Us(t),c=kt(c),i=i(c),t.flags|=1,Et(e,t,i,s),t.child;case 14:return Eh(e,t,t.type,t.pendingProps,s);case 15:return Mh(e,t,t.type,t.pendingProps,s);case 19:return zh(e,t,s);case 31:return vb(e,t,s);case 22:return Rh(e,t,s,t.pendingProps);case 24:return Us(t),i=kt(pt),e===null?(c=pc(),c===null&&(c=nt,d=mc(),c.pooledCache=d,d.refCount++,d!==null&&(c.pooledCacheLanes|=s),c=d),t.memoizedState={parent:i,cache:c},gc(t),os(t,pt,c)):((e.lanes&s)!==0&&(vc(e,t),wl(t,null,null,s),Nl()),c=e.memoizedState,d=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),os(t,pt,i)):(i=d.cache,os(t,pt,i),i!==c.cache&&fc(t,[pt],s,!0))),Et(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Vn(e){e.flags|=4}function Wc(e,t,s,i,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(f0())e.flags|=8192;else throw $s=Xr,xc}else e.flags&=-16777217}function Hh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!tp(t))if(f0())e.flags|=8192;else throw $s=Xr,xc}function ci(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?bf():536870912,e.lanes|=t,qa|=t)}function Rl(e,t){if(!Ge)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var i=null;s!==null;)s.alternate!==null&&(i=s),s=s.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function lt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,i=0;if(t)for(var c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=s,t}function yb(e,t,s){var i=t.pendingProps;switch(ic(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return lt(t),null;case 1:return lt(t),null;case 3:return s=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Ln(pt),ge(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(ba(t)?Vn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,cc())),lt(t),null;case 26:var c=t.type,d=t.memoizedState;return e===null?(Vn(t),d!==null?(lt(t),Hh(t,d)):(lt(t),Wc(t,c,null,i,s))):d?d!==e.memoizedState?(Vn(t),lt(t),Hh(t,d)):(lt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&Vn(t),lt(t),Wc(t,c,e,i,s)),null;case 27:if(ze(t),s=ce.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Vn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return lt(t),null}e=ne.current,ba(t)?bm(t):(e=Q0(c,i,s),t.stateNode=e,Vn(t))}return lt(t),null;case 5:if(ze(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Vn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return lt(t),null}if(d=ne.current,ba(t))bm(t);else{var y=wi(ce.current);switch(d){case 1:d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":d=y.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof i.is=="string"?y.createElement("select",{is:i.is}):y.createElement("select"),i.multiple?d.multiple=!0:i.size&&(d.size=i.size);break;default:d=typeof i.is=="string"?y.createElement(c,{is:i.is}):y.createElement(c)}}d[At]=t,d[Bt]=i;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)d.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===t)break e;for(;y.sibling===null;){if(y.return===null||y.return===t)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}t.stateNode=d;e:switch(Mt(d,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Vn(t)}}return lt(t),Wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Vn(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=ce.current,ba(t)){if(e=t.stateNode,s=t.memoizedProps,i=null,c=Ct,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[At]=t,e=!!(e.nodeValue===s||i!==null&&i.suppressHydrationWarning===!0||B0(e.nodeValue,s)),e||is(t,!0)}else e=wi(e).createTextNode(i),e[At]=t,t.stateNode=e}return lt(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(i=ba(t),s!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[At]=t}else Ls(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;lt(t),e=!1}else s=cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(It(t),t):(It(t),null);if((t.flags&128)!==0)throw Error(o(558))}return lt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=ba(t),i!==null&&i.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[At]=t}else Ls(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;lt(t),c=!1}else c=cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(It(t),t):(It(t),null)}return It(t),(t.flags&128)!==0?(t.lanes=s,t):(s=i!==null,e=e!==null&&e.memoizedState!==null,s&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==c&&(i.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),ci(t,t.updateQueue),lt(t),null);case 4:return ge(),e===null&&Su(t.stateNode.containerInfo),lt(t),null;case 10:return Ln(t.type),lt(t),null;case 19:if(_(ft),i=t.memoizedState,i===null)return lt(t),null;if(c=(t.flags&128)!==0,d=i.rendering,d===null)if(c)Rl(i,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(d=Zr(e),d!==null){for(t.flags|=128,Rl(i,!1),e=d.updateQueue,t.updateQueue=e,ci(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)hm(s,e),s=s.sibling;return K(ft,ft.current&1|2),Ge&&On(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&le()>hi&&(t.flags|=128,c=!0,Rl(i,!1),t.lanes=4194304)}else{if(!c)if(e=Zr(d),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,ci(t,e),Rl(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!Ge)return lt(t),null}else 2*le()-i.renderingStartTime>hi&&s!==536870912&&(t.flags|=128,c=!0,Rl(i,!1),t.lanes=4194304);i.isBackwards?(d.sibling=t.child,t.child=d):(e=i.last,e!==null?e.sibling=d:t.child=d,i.last=d)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=le(),e.sibling=null,s=ft.current,K(ft,c?s&1|2:s&1),Ge&&On(t,i.treeForkCount),e):(lt(t),null);case 22:case 23:return It(t),jc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(s&536870912)!==0&&(t.flags&128)===0&&(lt(t),t.subtreeFlags&6&&(t.flags|=8192)):lt(t),s=t.updateQueue,s!==null&&ci(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==s&&(t.flags|=2048),e!==null&&_(Hs),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Ln(pt),lt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Sb(e,t){switch(ic(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ln(pt),ge(),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(It(t),t.alternate===null)throw Error(o(340));Ls()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(It(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ls()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _(ft),null;case 4:return ge(),null;case 10:return Ln(t.type),null;case 22:case 23:return It(t),jc(),e!==null&&_(Hs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ln(pt),null;case 25:return null;default:return null}}function Vh(e,t){switch(ic(t),t.tag){case 3:Ln(pt),ge();break;case 26:case 27:case 5:ze(t);break;case 4:ge();break;case 31:t.memoizedState!==null&&It(t);break;case 13:It(t);break;case 19:_(ft);break;case 10:Ln(t.type);break;case 22:case 23:It(t),jc(),e!==null&&_(Hs);break;case 24:Ln(pt)}}function Tl(e,t){try{var s=t.updateQueue,i=s!==null?s.lastEffect:null;if(i!==null){var c=i.next;s=c;do{if((s.tag&e)===e){i=void 0;var d=s.create,y=s.inst;i=d(),y.destroy=i}s=s.next}while(s!==c)}}catch(C){Je(t,t.return,C)}}function hs(e,t,s){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var d=c.next;i=d;do{if((i.tag&e)===e){var y=i.inst,C=y.destroy;if(C!==void 0){y.destroy=void 0,c=t;var D=s,Y=C;try{Y()}catch(W){Je(c,D,W)}}}i=i.next}while(i!==d)}}catch(W){Je(t,t.return,W)}}function $h(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{qm(t,s)}catch(i){Je(e,e.return,i)}}}function Gh(e,t,s){s.props=Ys(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(i){Je(e,t,i)}}function ql(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof s=="function"?e.refCleanup=s(i):s.current=i}}catch(c){Je(e,t,c)}}function An(e,t){var s=e.ref,i=e.refCleanup;if(s!==null)if(typeof i=="function")try{i()}catch(c){Je(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(c){Je(e,t,c)}else s.current=null}function Fh(e){var t=e.type,s=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&i.focus();break e;case"img":s.src?i.src=s.src:s.srcSet&&(i.srcset=s.srcSet)}}catch(c){Je(e,e.return,c)}}function eu(e,t,s){try{var i=e.stateNode;Gb(i,e.type,s,t),i[Bt]=t}catch(c){Je(e,e.return,c)}}function Yh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ss(e.type)||e.tag===4}function tu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Yh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Ss(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 nu(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=qn));else if(i!==4&&(i===27&&Ss(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(nu(e,t,s),e=e.sibling;e!==null;)nu(e,t,s),e=e.sibling}function ui(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(i!==4&&(i===27&&Ss(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(ui(e,t,s),e=e.sibling;e!==null;)ui(e,t,s),e=e.sibling}function Xh(e){var t=e.stateNode,s=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Mt(t,i,s),t[At]=e,t[Bt]=s}catch(d){Je(e,e.return,d)}}var $n=!1,vt=!1,su=!1,Qh=typeof WeakSet=="function"?WeakSet:Set,Nt=null;function jb(e,t){if(e=e.containerInfo,wu=Ti,e=lm(e),Zo(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var i=s.getSelection&&s.getSelection();if(i&&i.rangeCount!==0){s=i.anchorNode;var c=i.anchorOffset,d=i.focusNode;i=i.focusOffset;try{s.nodeType,d.nodeType}catch{s=null;break e}var y=0,C=-1,D=-1,Y=0,W=0,se=e,I=null;t:for(;;){for(var Z;se!==s||c!==0&&se.nodeType!==3||(C=y+c),se!==d||i!==0&&se.nodeType!==3||(D=y+i),se.nodeType===3&&(y+=se.nodeValue.length),(Z=se.firstChild)!==null;)I=se,se=Z;for(;;){if(se===e)break t;if(I===s&&++Y===c&&(C=y),I===d&&++W===i&&(D=y),(Z=se.nextSibling)!==null)break;se=I,I=se.parentNode}se=Z}s=C===-1||D===-1?null:{start:C,end:D}}else s=null}s=s||{start:0,end:0}}else s=null;for(Au={focusedElem:e,selectionRange:s},Ti=!1,Nt=t;Nt!==null;)if(t=Nt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Nt=e;else for(;Nt!==null;){switch(t=Nt,d=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)c=e[s],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&d!==null){e=void 0,s=t,c=d.memoizedProps,d=d.memoizedState,i=s.stateNode;try{var ve=Ys(s.type,c);e=i.getSnapshotBeforeUpdate(ve,d),i.__reactInternalSnapshotBeforeUpdate=e}catch(Ce){Je(s,s.return,Ce)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)Eu(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Eu(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,Nt=e;break}Nt=t.return}}function Ih(e,t,s){var i=s.flags;switch(s.tag){case 0:case 11:case 15:Fn(e,s),i&4&&Tl(5,s);break;case 1:if(Fn(e,s),i&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){Je(s,s.return,y)}else{var c=Ys(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Je(s,s.return,y)}}i&64&&$h(s),i&512&&ql(s,s.return);break;case 3:if(Fn(e,s),i&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{qm(e,t)}catch(y){Je(s,s.return,y)}}break;case 27:t===null&&i&4&&Xh(s);case 26:case 5:Fn(e,s),t===null&&i&4&&Fh(s),i&512&&ql(s,s.return);break;case 12:Fn(e,s);break;case 31:Fn(e,s),i&4&&Jh(e,s);break;case 13:Fn(e,s),i&4&&Ph(e,s),i&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Tb.bind(null,s),Jb(e,s))));break;case 22:if(i=s.memoizedState!==null||$n,!i){t=t!==null&&t.memoizedState!==null||vt,c=$n;var d=vt;$n=i,(vt=t)&&!d?Yn(e,s,(s.subtreeFlags&8772)!==0):Fn(e,s),$n=c,vt=d}break;case 30:break;default:Fn(e,s)}}function Kh(e){var t=e.alternate;t!==null&&(e.alternate=null,Kh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Do(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var rt=null,zt=!1;function Gn(e,t,s){for(s=s.child;s!==null;)Zh(e,t,s),s=s.sibling}function Zh(e,t,s){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(Ke,s)}catch{}switch(s.tag){case 26:vt||An(s,t),Gn(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:vt||An(s,t);var i=rt,c=zt;Ss(s.type)&&(rt=s.stateNode,zt=!1),Gn(e,t,s),Vl(s.stateNode),rt=i,zt=c;break;case 5:vt||An(s,t);case 6:if(i=rt,c=zt,rt=null,Gn(e,t,s),rt=i,zt=c,rt!==null)if(zt)try{(rt.nodeType===9?rt.body:rt.nodeName==="HTML"?rt.ownerDocument.body:rt).removeChild(s.stateNode)}catch(d){Je(s,t,d)}else try{rt.removeChild(s.stateNode)}catch(d){Je(s,t,d)}break;case 18:rt!==null&&(zt?(e=rt,$0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Ha(e)):$0(rt,s.stateNode));break;case 4:i=rt,c=zt,rt=s.stateNode.containerInfo,zt=!0,Gn(e,t,s),rt=i,zt=c;break;case 0:case 11:case 14:case 15:hs(2,s,t),vt||hs(4,s,t),Gn(e,t,s);break;case 1:vt||(An(s,t),i=s.stateNode,typeof i.componentWillUnmount=="function"&&Gh(s,t,i)),Gn(e,t,s);break;case 21:Gn(e,t,s);break;case 22:vt=(i=vt)||s.memoizedState!==null,Gn(e,t,s),vt=i;break;default:Gn(e,t,s)}}function Jh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ha(e)}catch(s){Je(t,t.return,s)}}}function Ph(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ha(e)}catch(s){Je(t,t.return,s)}}function Nb(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 di(e,t){var s=Nb(e);t.forEach(function(i){if(!s.has(i)){s.add(i);var c=qb.bind(null,e,i);i.then(c,c)}})}function Ut(e,t){var s=t.deletions;if(s!==null)for(var i=0;i<s.length;i++){var c=s[i],d=e,y=t,C=y;e:for(;C!==null;){switch(C.tag){case 27:if(Ss(C.type)){rt=C.stateNode,zt=!1;break e}break;case 5:rt=C.stateNode,zt=!1;break e;case 3:case 4:rt=C.stateNode.containerInfo,zt=!0;break e}C=C.return}if(rt===null)throw Error(o(160));Zh(d,y,c),rt=null,zt=!1,d=c.alternate,d!==null&&(d.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Wh(t,e),t=t.sibling}var gn=null;function Wh(e,t){var s=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ut(t,e),Ht(e),i&4&&(hs(3,e,e.return),Tl(3,e),hs(5,e,e.return));break;case 1:Ut(t,e),Ht(e),i&512&&(vt||s===null||An(s,s.return)),i&64&&$n&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?i:s.concat(i))));break;case 26:var c=gn;if(Ut(t,e),Ht(e),i&512&&(vt||s===null||An(s,s.return)),i&4){var d=s!==null?s.memoizedState:null;if(i=e.memoizedState,s===null)if(i===null)if(e.stateNode===null){e:{i=e.type,s=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":d=c.getElementsByTagName("title")[0],(!d||d[ll]||d[At]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=c.createElement(i),c.head.insertBefore(d,c.querySelector("head > title"))),Mt(d,i,s),d[At]=e,jt(d),i=d;break e;case"link":var y=W0("link","href",c).get(i+(s.href||""));if(y){for(var C=0;C<y.length;C++)if(d=y[C],d.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&d.getAttribute("rel")===(s.rel==null?null:s.rel)&&d.getAttribute("title")===(s.title==null?null:s.title)&&d.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){y.splice(C,1);break t}}d=c.createElement(i),Mt(d,i,s),c.head.appendChild(d);break;case"meta":if(y=W0("meta","content",c).get(i+(s.content||""))){for(C=0;C<y.length;C++)if(d=y[C],d.getAttribute("content")===(s.content==null?null:""+s.content)&&d.getAttribute("name")===(s.name==null?null:s.name)&&d.getAttribute("property")===(s.property==null?null:s.property)&&d.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&d.getAttribute("charset")===(s.charSet==null?null:s.charSet)){y.splice(C,1);break t}}d=c.createElement(i),Mt(d,i,s),c.head.appendChild(d);break;default:throw Error(o(468,i))}d[At]=e,jt(d),i=d}e.stateNode=i}else ep(c,e.type,e.stateNode);else e.stateNode=P0(c,i,e.memoizedProps);else d!==i?(d===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):d.count--,i===null?ep(c,e.type,e.stateNode):P0(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&eu(e,e.memoizedProps,s.memoizedProps)}break;case 27:Ut(t,e),Ht(e),i&512&&(vt||s===null||An(s,s.return)),s!==null&&i&4&&eu(e,e.memoizedProps,s.memoizedProps);break;case 5:if(Ut(t,e),Ht(e),i&512&&(vt||s===null||An(s,s.return)),e.flags&32){c=e.stateNode;try{ca(c,"")}catch(ve){Je(e,e.return,ve)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,eu(e,c,s!==null?s.memoizedProps:c)),i&1024&&(su=!0);break;case 6:if(Ut(t,e),Ht(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,s=e.stateNode;try{s.nodeValue=i}catch(ve){Je(e,e.return,ve)}}break;case 3:if(ki=null,c=gn,gn=Ai(t.containerInfo),Ut(t,e),gn=c,Ht(e),i&4&&s!==null&&s.memoizedState.isDehydrated)try{Ha(t.containerInfo)}catch(ve){Je(e,e.return,ve)}su&&(su=!1,e0(e));break;case 4:i=gn,gn=Ai(e.stateNode.containerInfo),Ut(t,e),Ht(e),gn=i;break;case 12:Ut(t,e),Ht(e);break;case 31:Ut(t,e),Ht(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,di(e,i)));break;case 13:Ut(t,e),Ht(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(mi=le()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,di(e,i)));break;case 22:c=e.memoizedState!==null;var D=s!==null&&s.memoizedState!==null,Y=$n,W=vt;if($n=Y||c,vt=W||D,Ut(t,e),vt=W,$n=Y,Ht(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(s===null||D||$n||vt||Xs(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){D=s=t;try{if(d=D.stateNode,c)y=d.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{C=D.stateNode;var se=D.memoizedProps.style,I=se!=null&&se.hasOwnProperty("display")?se.display:null;C.style.display=I==null||typeof I=="boolean"?"":(""+I).trim()}}catch(ve){Je(D,D.return,ve)}}}else if(t.tag===6){if(s===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(ve){Je(D,D.return,ve)}}}else if(t.tag===18){if(s===null){D=t;try{var Z=D.stateNode;c?G0(Z,!0):G0(D.stateNode,!1)}catch(ve){Je(D,D.return,ve)}}}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;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(s=i.retryQueue,s!==null&&(i.retryQueue=null,di(e,s))));break;case 19:Ut(t,e),Ht(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,di(e,i)));break;case 30:break;case 21:break;default:Ut(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{for(var s,i=e.return;i!==null;){if(Yh(i)){s=i;break}i=i.return}if(s==null)throw Error(o(160));switch(s.tag){case 27:var c=s.stateNode,d=tu(e);ui(e,d,c);break;case 5:var y=s.stateNode;s.flags&32&&(ca(y,""),s.flags&=-33);var C=tu(e);ui(e,C,y);break;case 3:case 4:var D=s.stateNode.containerInfo,Y=tu(e);nu(e,Y,D);break;default:throw Error(o(161))}}catch(W){Je(e,e.return,W)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function e0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;e0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Fn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Ih(e,t.alternate,t),t=t.sibling}function Xs(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:hs(4,t,t.return),Xs(t);break;case 1:An(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Gh(t,t.return,s),Xs(t);break;case 27:Vl(t.stateNode);case 26:case 5:An(t,t.return),Xs(t);break;case 22:t.memoizedState===null&&Xs(t);break;case 30:Xs(t);break;default:Xs(t)}e=e.sibling}}function Yn(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,d=t,y=d.flags;switch(d.tag){case 0:case 11:case 15:Yn(c,d,s),Tl(4,d);break;case 1:if(Yn(c,d,s),i=d,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(Y){Je(i,i.return,Y)}if(i=d,c=i.updateQueue,c!==null){var C=i.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)Tm(D[c],C)}catch(Y){Je(i,i.return,Y)}}s&&y&64&&$h(d),ql(d,d.return);break;case 27:Xh(d);case 26:case 5:Yn(c,d,s),s&&i===null&&y&4&&Fh(d),ql(d,d.return);break;case 12:Yn(c,d,s);break;case 31:Yn(c,d,s),s&&y&4&&Jh(c,d);break;case 13:Yn(c,d,s),s&&y&4&&Ph(c,d);break;case 22:d.memoizedState===null&&Yn(c,d,s),ql(d,d.return);break;case 30:break;default:Yn(c,d,s)}t=t.sibling}}function au(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&vl(s))}function lu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&vl(e))}function vn(e,t,s,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)t0(e,t,s,i),t=t.sibling}function t0(e,t,s,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:vn(e,t,s,i),c&2048&&Tl(9,t);break;case 1:vn(e,t,s,i);break;case 3:vn(e,t,s,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&vl(e)));break;case 12:if(c&2048){vn(e,t,s,i),e=t.stateNode;try{var d=t.memoizedProps,y=d.id,C=d.onPostCommit;typeof C=="function"&&C(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Je(t,t.return,D)}}else vn(e,t,s,i);break;case 31:vn(e,t,s,i);break;case 13:vn(e,t,s,i);break;case 23:break;case 22:d=t.stateNode,y=t.alternate,t.memoizedState!==null?d._visibility&2?vn(e,t,s,i):Dl(e,t):d._visibility&2?vn(e,t,s,i):(d._visibility|=2,Ma(e,t,s,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&au(y,t);break;case 24:vn(e,t,s,i),c&2048&&lu(t.alternate,t);break;default:vn(e,t,s,i)}}function Ma(e,t,s,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=e,y=t,C=s,D=i,Y=y.flags;switch(y.tag){case 0:case 11:case 15:Ma(d,y,C,D,c),Tl(8,y);break;case 23:break;case 22:var W=y.stateNode;y.memoizedState!==null?W._visibility&2?Ma(d,y,C,D,c):Dl(d,y):(W._visibility|=2,Ma(d,y,C,D,c)),c&&Y&2048&&au(y.alternate,y);break;case 24:Ma(d,y,C,D,c),c&&Y&2048&&lu(y.alternate,y);break;default:Ma(d,y,C,D,c)}t=t.sibling}}function Dl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,i=t,c=i.flags;switch(i.tag){case 22:Dl(s,i),c&2048&&au(i.alternate,i);break;case 24:Dl(s,i),c&2048&&lu(i.alternate,i);break;default:Dl(s,i)}t=t.sibling}}var _l=8192;function Ra(e,t,s){if(e.subtreeFlags&_l)for(e=e.child;e!==null;)n0(e,t,s),e=e.sibling}function n0(e,t,s){switch(e.tag){case 26:Ra(e,t,s),e.flags&_l&&e.memoizedState!==null&&cy(s,gn,e.memoizedState,e.memoizedProps);break;case 5:Ra(e,t,s);break;case 3:case 4:var i=gn;gn=Ai(e.stateNode.containerInfo),Ra(e,t,s),gn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=_l,_l=16777216,Ra(e,t,s),_l=i):Ra(e,t,s));break;default:Ra(e,t,s)}}function s0(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 Ol(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];Nt=i,l0(i,e)}s0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)a0(e),e=e.sibling}function a0(e){switch(e.tag){case 0:case 11:case 15:Ol(e),e.flags&2048&&hs(9,e,e.return);break;case 3:Ol(e);break;case 12:Ol(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,fi(e)):Ol(e);break;default:Ol(e)}}function fi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];Nt=i,l0(i,e)}s0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:hs(8,t,t.return),fi(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,fi(t));break;default:fi(t)}e=e.sibling}}function l0(e,t){for(;Nt!==null;){var s=Nt;switch(s.tag){case 0:case 11:case 15:hs(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var i=s.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:vl(s.memoizedState.cache)}if(i=s.child,i!==null)i.return=s,Nt=i;else e:for(s=e;Nt!==null;){i=Nt;var c=i.sibling,d=i.return;if(Kh(i),i===s){Nt=null;break e}if(c!==null){c.return=d,Nt=c;break e}Nt=d}}}var wb={getCacheForType:function(e){var t=kt(pt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return kt(pt).controller.signal}},Ab=typeof WeakMap=="function"?WeakMap:Map,Ie=0,nt=null,Be=null,Ve=0,Ze=0,Kt=null,ps=!1,Ta=!1,ru=!1,Xn=0,ut=0,xs=0,Qs=0,iu=0,Zt=0,qa=0,Bl=null,Vt=null,ou=!1,mi=0,r0=0,hi=1/0,pi=null,gs=null,St=0,vs=null,Da=null,Qn=0,cu=0,uu=null,i0=null,Ll=0,du=null;function Jt(){return(Ie&2)!==0&&Ve!==0?Ve&-Ve:q.T!==null?gu():Nf()}function o0(){if(Zt===0)if((Ve&536870912)===0||Ge){var e=Nr;Nr<<=1,(Nr&3932160)===0&&(Nr=262144),Zt=e}else Zt=536870912;return e=Qt.current,e!==null&&(e.flags|=32),Zt}function $t(e,t,s){(e===nt&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)&&(_a(e,0),bs(e,Ve,Zt,!1)),al(e,s),((Ie&2)===0||e!==nt)&&(e===nt&&((Ie&2)===0&&(Qs|=s),ut===4&&bs(e,Ve,Zt,!1)),Cn(e))}function c0(e,t,s){if((Ie&6)!==0)throw Error(o(327));var i=!s&&(t&127)===0&&(t&e.expiredLanes)===0||sl(e,t),c=i?Eb(e,t):mu(e,t,!0),d=i;do{if(c===0){Ta&&!i&&bs(e,t,0,!1);break}else{if(s=e.current.alternate,d&&!Cb(s)){c=mu(e,t,!1),d=!1;continue}if(c===2){if(d=t,e.errorRecoveryDisabledLanes&d)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var C=e;c=Bl;var D=C.current.memoizedState.isDehydrated;if(D&&(_a(C,y).flags|=256),y=mu(C,y,!1),y!==2){if(ru&&!D){C.errorRecoveryDisabledLanes|=d,Qs|=d,c=4;break e}d=Vt,Vt=c,d!==null&&(Vt===null?Vt=d:Vt.push.apply(Vt,d))}c=y}if(d=!1,c!==2)continue}}if(c===1){_a(e,0),bs(e,t,0,!0);break}e:{switch(i=e,d=c,d){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:bs(i,t,Zt,!ps);break e;case 2:Vt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=mi+300-le(),10<c)){if(bs(i,t,Zt,!ps),Ar(i,0,!0)!==0)break e;Qn=t,i.timeoutHandle=H0(u0.bind(null,i,s,Vt,pi,ou,t,Zt,Qs,qa,ps,d,"Throttled",-0,0),c);break e}u0(i,s,Vt,pi,ou,t,Zt,Qs,qa,ps,d,null,-0,0)}}break}while(!0);Cn(e)}function u0(e,t,s,i,c,d,y,C,D,Y,W,se,I,Z){if(e.timeoutHandle=-1,se=t.subtreeFlags,se&8192||(se&16785408)===16785408){se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qn},n0(t,d,se);var ve=(d&62914560)===d?mi-le():(d&4194048)===d?r0-le():0;if(ve=uy(se,ve),ve!==null){Qn=d,e.cancelPendingCommit=ve(v0.bind(null,e,t,d,s,i,c,y,C,D,W,se,null,I,Z)),bs(e,d,y,!Y);return}}v0(e,t,d,s,i,c,y,C,D)}function Cb(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var i=0;i<s.length;i++){var c=s[i],d=c.getSnapshot;c=c.value;try{if(!Yt(d(),c))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;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 bs(e,t,s,i){t&=~iu,t&=~Qs,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var d=31-Pe(c),y=1<<d;i[d]=-1,c&=~y}s!==0&&yf(e,s,t)}function xi(){return(Ie&6)===0?(zl(0),!1):!0}function fu(){if(Be!==null){if(Ze===0)var e=Be.return;else e=Be,Bn=zs=null,Ec(e),wa=null,yl=0,e=Be;for(;e!==null;)Vh(e.alternate,e),e=e.return;Be=null}}function _a(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,Xb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Qn=0,fu(),nt=e,Be=s=_n(e.current,null),Ve=t,Ze=0,Kt=null,ps=!1,Ta=sl(e,t),ru=!1,qa=Zt=iu=Qs=xs=ut=0,Vt=Bl=null,ou=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-Pe(i),d=1<<c;t|=e[c],i&=~d}return Xn=t,Lr(),s}function d0(e,t){qe=null,q.H=El,t===Na||t===Yr?(t=km(),Ze=3):t===xc?(t=km(),Ze=4):Ze=t===Fc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Kt=t,Be===null&&(ut=1,li(e,an(t,e.current)))}function f0(){var e=Qt.current;return e===null?!0:(Ve&4194048)===Ve?cn===null:(Ve&62914560)===Ve||(Ve&536870912)!==0?e===cn:!1}function m0(){var e=q.H;return q.H=El,e===null?El:e}function h0(){var e=q.A;return q.A=wb,e}function gi(){ut=4,ps||(Ve&4194048)!==Ve&&Qt.current!==null||(Ta=!0),(xs&134217727)===0&&(Qs&134217727)===0||nt===null||bs(nt,Ve,Zt,!1)}function mu(e,t,s){var i=Ie;Ie|=2;var c=m0(),d=h0();(nt!==e||Ve!==t)&&(pi=null,_a(e,t)),t=!1;var y=ut;e:do try{if(Ze!==0&&Be!==null){var C=Be,D=Kt;switch(Ze){case 8:fu(),y=6;break e;case 3:case 2:case 9:case 6:Qt.current===null&&(t=!0);var Y=Ze;if(Ze=0,Kt=null,Oa(e,C,D,Y),s&&Ta){y=0;break e}break;default:Y=Ze,Ze=0,Kt=null,Oa(e,C,D,Y)}}kb(),y=ut;break}catch(W){d0(e,W)}while(!0);return t&&e.shellSuspendCounter++,Bn=zs=null,Ie=i,q.H=c,q.A=d,Be===null&&(nt=null,Ve=0,Lr()),y}function kb(){for(;Be!==null;)p0(Be)}function Eb(e,t){var s=Ie;Ie|=2;var i=m0(),c=h0();nt!==e||Ve!==t?(pi=null,hi=le()+500,_a(e,t)):Ta=sl(e,t);e:do try{if(Ze!==0&&Be!==null){t=Be;var d=Kt;t:switch(Ze){case 1:Ze=0,Kt=null,Oa(e,t,d,1);break;case 2:case 9:if(Am(d)){Ze=0,Kt=null,x0(t);break}t=function(){Ze!==2&&Ze!==9||nt!==e||(Ze=7),Cn(e)},d.then(t,t);break e;case 3:Ze=7;break e;case 4:Ze=5;break e;case 7:Am(d)?(Ze=0,Kt=null,x0(t)):(Ze=0,Kt=null,Oa(e,t,d,7));break;case 5:var y=null;switch(Be.tag){case 26:y=Be.memoizedState;case 5:case 27:var C=Be;if(y?tp(y):C.stateNode.complete){Ze=0,Kt=null;var D=C.sibling;if(D!==null)Be=D;else{var Y=C.return;Y!==null?(Be=Y,vi(Y)):Be=null}break t}}Ze=0,Kt=null,Oa(e,t,d,5);break;case 6:Ze=0,Kt=null,Oa(e,t,d,6);break;case 8:fu(),ut=6;break e;default:throw Error(o(462))}}Mb();break}catch(W){d0(e,W)}while(!0);return Bn=zs=null,q.H=i,q.A=c,Ie=s,Be!==null?0:(nt=null,Ve=0,Lr(),ut)}function Mb(){for(;Be!==null&&!Ae();)p0(Be)}function p0(e){var t=Uh(e.alternate,e,Xn);e.memoizedProps=e.pendingProps,t===null?vi(e):Be=t}function x0(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Dh(s,t,t.pendingProps,t.type,void 0,Ve);break;case 11:t=Dh(s,t,t.pendingProps,t.type.render,t.ref,Ve);break;case 5:Ec(t);default:Vh(s,t),t=Be=hm(t,Xn),t=Uh(s,t,Xn)}e.memoizedProps=e.pendingProps,t===null?vi(e):Be=t}function Oa(e,t,s,i){Bn=zs=null,Ec(t),wa=null,yl=0;var c=t.return;try{if(gb(e,c,t,s,Ve)){ut=1,li(e,an(s,e.current)),Be=null;return}}catch(d){if(c!==null)throw Be=c,d;ut=1,li(e,an(s,e.current)),Be=null;return}t.flags&32768?(Ge||i===1?e=!0:Ta||(Ve&536870912)!==0?e=!1:(ps=e=!0,(i===2||i===9||i===3||i===6)&&(i=Qt.current,i!==null&&i.tag===13&&(i.flags|=16384))),g0(t,e)):vi(t)}function vi(e){var t=e;do{if((t.flags&32768)!==0){g0(t,ps);return}e=t.return;var s=yb(t.alternate,t,Xn);if(s!==null){Be=s;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);ut===0&&(ut=5)}function g0(e,t){do{var s=Sb(e.alternate,e);if(s!==null){s.flags&=32767,Be=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){Be=e;return}Be=e=s}while(e!==null);ut=6,Be=null}function v0(e,t,s,i,c,d,y,C,D){e.cancelPendingCommit=null;do bi();while(St!==0);if((Ie&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(d=t.lanes|t.childLanes,d|=tc,ov(e,s,d,y,C,D),e===nt&&(Be=nt=null,Ve=0),Da=t,vs=e,Qn=s,cu=d,uu=c,i0=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Db(qt,function(){return N0(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=q.T,q.T=null,c=H.p,H.p=2,y=Ie,Ie|=4;try{jb(e,t,s)}finally{Ie=y,H.p=c,q.T=i}}St=1,b0(),y0(),S0()}}function b0(){if(St===1){St=0;var e=vs,t=Da,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=q.T,q.T=null;var i=H.p;H.p=2;var c=Ie;Ie|=4;try{Wh(t,e);var d=Au,y=lm(e.containerInfo),C=d.focusedElem,D=d.selectionRange;if(y!==C&&C&&C.ownerDocument&&am(C.ownerDocument.documentElement,C)){if(D!==null&&Zo(C)){var Y=D.start,W=D.end;if(W===void 0&&(W=Y),"selectionStart"in C)C.selectionStart=Y,C.selectionEnd=Math.min(W,C.value.length);else{var se=C.ownerDocument||document,I=se&&se.defaultView||window;if(I.getSelection){var Z=I.getSelection(),ve=C.textContent.length,Ce=Math.min(D.start,ve),tt=D.end===void 0?Ce:Math.min(D.end,ve);!Z.extend&&Ce>tt&&(y=tt,tt=Ce,Ce=y);var U=sm(C,Ce),B=sm(C,tt);if(U&&B&&(Z.rangeCount!==1||Z.anchorNode!==U.node||Z.anchorOffset!==U.offset||Z.focusNode!==B.node||Z.focusOffset!==B.offset)){var F=se.createRange();F.setStart(U.node,U.offset),Z.removeAllRanges(),Ce>tt?(Z.addRange(F),Z.extend(B.node,B.offset)):(F.setEnd(B.node,B.offset),Z.addRange(F))}}}}for(se=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&se.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<se.length;C++){var te=se[C];te.element.scrollLeft=te.left,te.element.scrollTop=te.top}}Ti=!!wu,Au=wu=null}finally{Ie=c,H.p=i,q.T=s}}e.current=t,St=2}}function y0(){if(St===2){St=0;var e=vs,t=Da,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=q.T,q.T=null;var i=H.p;H.p=2;var c=Ie;Ie|=4;try{Ih(e,t.alternate,t)}finally{Ie=c,H.p=i,q.T=s}}St=3}}function S0(){if(St===4||St===3){St=0,Re();var e=vs,t=Da,s=Qn,i=i0;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?St=5:(St=0,Da=vs=null,j0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(gs=null),To(s),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot=="function")try{ke.onCommitFiberRoot(Ke,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=q.T,c=H.p,H.p=2,q.T=null;try{for(var d=e.onRecoverableError,y=0;y<i.length;y++){var C=i[y];d(C.value,{componentStack:C.stack})}}finally{q.T=t,H.p=c}}(Qn&3)!==0&&bi(),Cn(e),c=e.pendingLanes,(s&261930)!==0&&(c&42)!==0?e===du?Ll++:(Ll=0,du=e):Ll=0,zl(0)}}function j0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,vl(t)))}function bi(){return b0(),y0(),S0(),N0()}function N0(){if(St!==5)return!1;var e=vs,t=cu;cu=0;var s=To(Qn),i=q.T,c=H.p;try{H.p=32>s?32:s,q.T=null,s=uu,uu=null;var d=vs,y=Qn;if(St=0,Da=vs=null,Qn=0,(Ie&6)!==0)throw Error(o(331));var C=Ie;if(Ie|=4,a0(d.current),t0(d,d.current,y,s),Ie=C,zl(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(Ke,d)}catch{}return!0}finally{H.p=c,q.T=i,j0(e,t)}}function w0(e,t,s){t=an(s,t),t=Gc(e.stateNode,t,2),e=ds(e,t,2),e!==null&&(al(e,2),Cn(e))}function Je(e,t,s){if(e.tag===3)w0(e,e,s);else for(;t!==null;){if(t.tag===3){w0(t,e,s);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(gs===null||!gs.has(i))){e=an(s,e),s=Ah(2),i=ds(t,s,2),i!==null&&(Ch(s,i,t,e),al(i,2),Cn(i));break}}t=t.return}}function hu(e,t,s){var i=e.pingCache;if(i===null){i=e.pingCache=new Ab;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(s)||(ru=!0,c.add(s),e=Rb.bind(null,e,t,s),t.then(e,e))}function Rb(e,t,s){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,nt===e&&(Ve&s)===s&&(ut===4||ut===3&&(Ve&62914560)===Ve&&300>le()-mi?(Ie&2)===0&&_a(e,0):iu|=s,qa===Ve&&(qa=0)),Cn(e)}function A0(e,t){t===0&&(t=bf()),e=Os(e,t),e!==null&&(al(e,t),Cn(e))}function Tb(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),A0(e,s)}function qb(e,t){var s=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(s=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),A0(e,s)}function Db(e,t){return pe(e,t)}var yi=null,Ba=null,pu=!1,Si=!1,xu=!1,ys=0;function Cn(e){e!==Ba&&e.next===null&&(Ba===null?yi=Ba=e:Ba=Ba.next=e),Si=!0,pu||(pu=!0,Ob())}function zl(e,t){if(!xu&&Si){xu=!0;do for(var s=!1,i=yi;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var d=0;else{var y=i.suspendedLanes,C=i.pingedLanes;d=(1<<31-Pe(42|e)+1)-1,d&=c&~(y&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(s=!0,M0(i,d))}else d=Ve,d=Ar(i,i===nt?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(d&3)===0||sl(i,d)||(s=!0,M0(i,d));i=i.next}while(s);xu=!1}}function _b(){C0()}function C0(){Si=pu=!1;var e=0;ys!==0&&Yb()&&(e=ys);for(var t=le(),s=null,i=yi;i!==null;){var c=i.next,d=k0(i,t);d===0?(i.next=null,s===null?yi=c:s.next=c,c===null&&(Ba=s)):(s=i,(e!==0||(d&3)!==0)&&(Si=!0)),i=c}St!==0&&St!==5||zl(e),ys!==0&&(ys=0)}function k0(e,t){for(var s=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,d=e.pendingLanes&-62914561;0<d;){var y=31-Pe(d),C=1<<y,D=c[y];D===-1?((C&s)===0||(C&i)!==0)&&(c[y]=iv(C,t)):D<=t&&(e.expiredLanes|=C),d&=~C}if(t=nt,s=Ve,s=Ar(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,s===0||e===t&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&je(i),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||sl(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(i!==null&&je(i),To(s)){case 2:case 8:s=Tt;break;case 32:s=qt;break;case 268435456:s=Ft;break;default:s=qt}return i=E0.bind(null,e),s=pe(s,i),e.callbackPriority=t,e.callbackNode=s,t}return i!==null&&i!==null&&je(i),e.callbackPriority=2,e.callbackNode=null,2}function E0(e,t){if(St!==0&&St!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(bi()&&e.callbackNode!==s)return null;var i=Ve;return i=Ar(e,e===nt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(c0(e,i,t),k0(e,le()),e.callbackNode!=null&&e.callbackNode===s?E0.bind(null,e):null)}function M0(e,t){if(bi())return null;c0(e,t,!0)}function Ob(){Qb(function(){(Ie&6)!==0?pe(De,_b):C0()})}function gu(){if(ys===0){var e=Sa;e===0&&(e=jn,jn<<=1,(jn&261888)===0&&(jn=256)),ys=e}return ys}function R0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Mr(""+e)}function T0(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function Bb(e,t,s,i,c){if(t==="submit"&&s&&s.stateNode===c){var d=R0((c[Bt]||null).action),y=i.submitter;y&&(t=(t=y[Bt]||null)?R0(t.formAction):y.getAttribute("formAction"),t!==null&&(d=t,y=null));var C=new Dr("action","action",null,i,c);e.push({event:C,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(ys!==0){var D=y?T0(c,y):new FormData(c);Lc(s,{pending:!0,data:D,method:c.method,action:d},null,D)}}else typeof d=="function"&&(C.preventDefault(),D=y?T0(c,y):new FormData(c),Lc(s,{pending:!0,data:D,method:c.method,action:d},d,D))},currentTarget:c}]})}}for(var vu=0;vu<ec.length;vu++){var bu=ec[vu],Lb=bu.toLowerCase(),zb=bu[0].toUpperCase()+bu.slice(1);xn(Lb,"on"+zb)}xn(om,"onAnimationEnd"),xn(cm,"onAnimationIteration"),xn(um,"onAnimationStart"),xn("dblclick","onDoubleClick"),xn("focusin","onFocus"),xn("focusout","onBlur"),xn(eb,"onTransitionRun"),xn(tb,"onTransitionStart"),xn(nb,"onTransitionCancel"),xn(dm,"onTransitionEnd"),ia("onMouseEnter",["mouseout","mouseover"]),ia("onMouseLeave",["mouseout","mouseover"]),ia("onPointerEnter",["pointerout","pointerover"]),ia("onPointerLeave",["pointerout","pointerover"]),Ts("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ts("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ts("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ts("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ts("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ts("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ul="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(" "),Ub=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ul));function q0(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var i=e[s],c=i.event;i=i.listeners;e:{var d=void 0;if(t)for(var y=i.length-1;0<=y;y--){var C=i[y],D=C.instance,Y=C.currentTarget;if(C=C.listener,D!==d&&c.isPropagationStopped())break e;d=C,c.currentTarget=Y;try{d(c)}catch(W){Br(W)}c.currentTarget=null,d=D}else for(y=0;y<i.length;y++){if(C=i[y],D=C.instance,Y=C.currentTarget,C=C.listener,D!==d&&c.isPropagationStopped())break e;d=C,c.currentTarget=Y;try{d(c)}catch(W){Br(W)}c.currentTarget=null,d=D}}}}function Le(e,t){var s=t[qo];s===void 0&&(s=t[qo]=new Set);var i=e+"__bubble";s.has(i)||(D0(t,e,2,!1),s.add(i))}function yu(e,t,s){var i=0;t&&(i|=4),D0(s,e,i,t)}var ji="_reactListening"+Math.random().toString(36).slice(2);function Su(e){if(!e[ji]){e[ji]=!0,Cf.forEach(function(s){s!=="selectionchange"&&(Ub.has(s)||yu(s,!1,e),yu(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ji]||(t[ji]=!0,yu("selectionchange",!1,t))}}function D0(e,t,s,i){switch(op(t)){case 2:var c=my;break;case 8:c=hy;break;default:c=Bu}s=c.bind(null,t,s,e),c=void 0,!Vo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,s,{capture:!0,passive:c}):e.addEventListener(t,s,!0):c!==void 0?e.addEventListener(t,s,{passive:c}):e.addEventListener(t,s,!1)}function ju(e,t,s,i,c){var d=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var y=i.tag;if(y===3||y===4){var C=i.stateNode.containerInfo;if(C===c)break;if(y===4)for(y=i.return;y!==null;){var D=y.tag;if((D===3||D===4)&&y.stateNode.containerInfo===c)return;y=y.return}for(;C!==null;){if(y=aa(C),y===null)return;if(D=y.tag,D===5||D===6||D===26||D===27){i=d=y;continue e}C=C.parentNode}}i=i.return}zf(function(){var Y=d,W=Uo(s),se=[];e:{var I=fm.get(e);if(I!==void 0){var Z=Dr,ve=e;switch(e){case"keypress":if(Tr(s)===0)break e;case"keydown":case"keyup":Z=qv;break;case"focusin":ve="focus",Z=Yo;break;case"focusout":ve="blur",Z=Yo;break;case"beforeblur":case"afterblur":Z=Yo;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Vf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=yv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=Ov;break;case om:case cm:case um:Z=Nv;break;case dm:Z=Lv;break;case"scroll":case"scrollend":Z=vv;break;case"wheel":Z=Uv;break;case"copy":case"cut":case"paste":Z=Av;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Gf;break;case"toggle":case"beforetoggle":Z=Vv}var Ce=(t&4)!==0,tt=!Ce&&(e==="scroll"||e==="scrollend"),U=Ce?I!==null?I+"Capture":null:I;Ce=[];for(var B=Y,F;B!==null;){var te=B;if(F=te.stateNode,te=te.tag,te!==5&&te!==26&&te!==27||F===null||U===null||(te=il(B,U),te!=null&&Ce.push(Hl(B,te,F))),tt)break;B=B.return}0<Ce.length&&(I=new Z(I,ve,null,s,W),se.push({event:I,listeners:Ce}))}}if((t&7)===0){e:{if(I=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",I&&s!==zo&&(ve=s.relatedTarget||s.fromElement)&&(aa(ve)||ve[sa]))break e;if((Z||I)&&(I=W.window===W?W:(I=W.ownerDocument)?I.defaultView||I.parentWindow:window,Z?(ve=s.relatedTarget||s.toElement,Z=Y,ve=ve?aa(ve):null,ve!==null&&(tt=f(ve),Ce=ve.tag,ve!==tt||Ce!==5&&Ce!==27&&Ce!==6)&&(ve=null)):(Z=null,ve=Y),Z!==ve)){if(Ce=Vf,te="onMouseLeave",U="onMouseEnter",B="mouse",(e==="pointerout"||e==="pointerover")&&(Ce=Gf,te="onPointerLeave",U="onPointerEnter",B="pointer"),tt=Z==null?I:rl(Z),F=ve==null?I:rl(ve),I=new Ce(te,B+"leave",Z,s,W),I.target=tt,I.relatedTarget=F,te=null,aa(W)===Y&&(Ce=new Ce(U,B+"enter",ve,s,W),Ce.target=F,Ce.relatedTarget=tt,te=Ce),tt=te,Z&&ve)t:{for(Ce=Hb,U=Z,B=ve,F=0,te=U;te;te=Ce(te))F++;te=0;for(var we=B;we;we=Ce(we))te++;for(;0<F-te;)U=Ce(U),F--;for(;0<te-F;)B=Ce(B),te--;for(;F--;){if(U===B||B!==null&&U===B.alternate){Ce=U;break t}U=Ce(U),B=Ce(B)}Ce=null}else Ce=null;Z!==null&&_0(se,I,Z,Ce,!1),ve!==null&&tt!==null&&_0(se,tt,ve,Ce,!0)}}e:{if(I=Y?rl(Y):window,Z=I.nodeName&&I.nodeName.toLowerCase(),Z==="select"||Z==="input"&&I.type==="file")var Ye=Jf;else if(Kf(I))if(Pf)Ye=Jv;else{Ye=Kv;var ye=Iv}else Z=I.nodeName,!Z||Z.toLowerCase()!=="input"||I.type!=="checkbox"&&I.type!=="radio"?Y&&Lo(Y.elementType)&&(Ye=Jf):Ye=Zv;if(Ye&&(Ye=Ye(e,Y))){Zf(se,Ye,s,W);break e}ye&&ye(e,I,Y),e==="focusout"&&Y&&I.type==="number"&&Y.memoizedProps.value!=null&&Bo(I,"number",I.value)}switch(ye=Y?rl(Y):window,e){case"focusin":(Kf(ye)||ye.contentEditable==="true")&&(ma=ye,Jo=Y,pl=null);break;case"focusout":pl=Jo=ma=null;break;case"mousedown":Po=!0;break;case"contextmenu":case"mouseup":case"dragend":Po=!1,rm(se,s,W);break;case"selectionchange":if(Wv)break;case"keydown":case"keyup":rm(se,s,W)}var _e;if(Qo)e:{switch(e){case"compositionstart":var $e="onCompositionStart";break e;case"compositionend":$e="onCompositionEnd";break e;case"compositionupdate":$e="onCompositionUpdate";break e}$e=void 0}else fa?Qf(e,s)&&($e="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&($e="onCompositionStart");$e&&(Ff&&s.locale!=="ko"&&(fa||$e!=="onCompositionStart"?$e==="onCompositionEnd"&&fa&&(_e=Uf()):(as=W,$o="value"in as?as.value:as.textContent,fa=!0)),ye=Ni(Y,$e),0<ye.length&&($e=new $f($e,e,null,s,W),se.push({event:$e,listeners:ye}),_e?$e.data=_e:(_e=If(s),_e!==null&&($e.data=_e)))),(_e=Gv?Fv(e,s):Yv(e,s))&&($e=Ni(Y,"onBeforeInput"),0<$e.length&&(ye=new $f("onBeforeInput","beforeinput",null,s,W),se.push({event:ye,listeners:$e}),ye.data=_e)),Bb(se,e,Y,s,W)}q0(se,t)})}function Hl(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Ni(e,t){for(var s=t+"Capture",i=[];e!==null;){var c=e,d=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||d===null||(c=il(e,s),c!=null&&i.unshift(Hl(e,c,d)),c=il(e,t),c!=null&&i.push(Hl(e,c,d))),e.tag===3)return i;e=e.return}return[]}function Hb(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function _0(e,t,s,i,c){for(var d=t._reactName,y=[];s!==null&&s!==i;){var C=s,D=C.alternate,Y=C.stateNode;if(C=C.tag,D!==null&&D===i)break;C!==5&&C!==26&&C!==27||Y===null||(D=Y,c?(Y=il(s,d),Y!=null&&y.unshift(Hl(s,Y,D))):c||(Y=il(s,d),Y!=null&&y.push(Hl(s,Y,D)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var Vb=/\r\n?/g,$b=/\u0000|\uFFFD/g;function O0(e){return(typeof e=="string"?e:""+e).replace(Vb,`
|
||
`).replace($b,"")}function B0(e,t){return t=O0(t),O0(e)===t}function et(e,t,s,i,c,d){switch(s){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||ca(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&ca(e,""+i);break;case"className":kr(e,"class",i);break;case"tabIndex":kr(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":kr(e,s,i);break;case"style":Bf(e,i,d);break;case"data":if(t!=="object"){kr(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Mr(""+i),e.setAttribute(s,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(s==="formAction"?(t!=="input"&&et(e,t,"name",c.name,c,null),et(e,t,"formEncType",c.formEncType,c,null),et(e,t,"formMethod",c.formMethod,c,null),et(e,t,"formTarget",c.formTarget,c,null)):(et(e,t,"encType",c.encType,c,null),et(e,t,"method",c.method,c,null),et(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Mr(""+i),e.setAttribute(s,i);break;case"onClick":i!=null&&(e.onclick=qn);break;case"onScroll":i!=null&&Le("scroll",e);break;case"onScrollEnd":i!=null&&Le("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}s=Mr(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""+i):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":i===!0?e.setAttribute(s,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,i):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(s,i):e.removeAttribute(s);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(s):e.setAttribute(s,i);break;case"popover":Le("beforetoggle",e),Le("toggle",e),Cr(e,"popover",i);break;case"xlinkActuate":Tn(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":Tn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":Tn(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":Tn(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":Tn(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":Tn(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":Tn(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":Tn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":Tn(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":Cr(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=xv.get(s)||s,Cr(e,s,i))}}function Nu(e,t,s,i,c,d){switch(s){case"style":Bf(e,i,d);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"children":typeof i=="string"?ca(e,i):(typeof i=="number"||typeof i=="bigint")&&ca(e,""+i);break;case"onScroll":i!=null&&Le("scroll",e);break;case"onScrollEnd":i!=null&&Le("scrollend",e);break;case"onClick":i!=null&&(e.onclick=qn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!kf.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(c=s.endsWith("Capture"),t=s.slice(2,c?s.length-7:void 0),d=e[Bt]||null,d=d!=null?d[s]:null,typeof d=="function"&&e.removeEventListener(t,d,c),typeof i=="function")){typeof d!="function"&&d!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,i,c);break e}s in e?e[s]=i:i===!0?e.setAttribute(s,""):Cr(e,s,i)}}}function Mt(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Le("error",e),Le("load",e);var i=!1,c=!1,d;for(d in s)if(s.hasOwnProperty(d)){var y=s[d];if(y!=null)switch(d){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:et(e,t,d,y,s,null)}}c&&et(e,t,"srcSet",s.srcSet,s,null),i&&et(e,t,"src",s.src,s,null);return;case"input":Le("invalid",e);var C=d=y=c=null,D=null,Y=null;for(i in s)if(s.hasOwnProperty(i)){var W=s[i];if(W!=null)switch(i){case"name":c=W;break;case"type":y=W;break;case"checked":D=W;break;case"defaultChecked":Y=W;break;case"value":d=W;break;case"defaultValue":C=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(o(137,t));break;default:et(e,t,i,W,s,null)}}qf(e,d,C,D,Y,y,c,!1);return;case"select":Le("invalid",e),i=y=d=null;for(c in s)if(s.hasOwnProperty(c)&&(C=s[c],C!=null))switch(c){case"value":d=C;break;case"defaultValue":y=C;break;case"multiple":i=C;default:et(e,t,c,C,s,null)}t=d,s=y,e.multiple=!!i,t!=null?oa(e,!!i,t,!1):s!=null&&oa(e,!!i,s,!0);return;case"textarea":Le("invalid",e),d=c=i=null;for(y in s)if(s.hasOwnProperty(y)&&(C=s[y],C!=null))switch(y){case"value":i=C;break;case"defaultValue":c=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(o(91));break;default:et(e,t,y,C,s,null)}_f(e,i,c,d);return;case"option":for(D in s)if(s.hasOwnProperty(D)&&(i=s[D],i!=null))switch(D){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:et(e,t,D,i,s,null)}return;case"dialog":Le("beforetoggle",e),Le("toggle",e),Le("cancel",e),Le("close",e);break;case"iframe":case"object":Le("load",e);break;case"video":case"audio":for(i=0;i<Ul.length;i++)Le(Ul[i],e);break;case"image":Le("error",e),Le("load",e);break;case"details":Le("toggle",e);break;case"embed":case"source":case"link":Le("error",e),Le("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Y in s)if(s.hasOwnProperty(Y)&&(i=s[Y],i!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:et(e,t,Y,i,s,null)}return;default:if(Lo(t)){for(W in s)s.hasOwnProperty(W)&&(i=s[W],i!==void 0&&Nu(e,t,W,i,s,void 0));return}}for(C in s)s.hasOwnProperty(C)&&(i=s[C],i!=null&&et(e,t,C,i,s,null))}function Gb(e,t,s,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,d=null,y=null,C=null,D=null,Y=null,W=null;for(Z in s){var se=s[Z];if(s.hasOwnProperty(Z)&&se!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=se;default:i.hasOwnProperty(Z)||et(e,t,Z,null,i,se)}}for(var I in i){var Z=i[I];if(se=s[I],i.hasOwnProperty(I)&&(Z!=null||se!=null))switch(I){case"type":d=Z;break;case"name":c=Z;break;case"checked":Y=Z;break;case"defaultChecked":W=Z;break;case"value":y=Z;break;case"defaultValue":C=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==se&&et(e,t,I,Z,i,se)}}Oo(e,y,C,D,Y,W,d,c);return;case"select":Z=y=C=I=null;for(d in s)if(D=s[d],s.hasOwnProperty(d)&&D!=null)switch(d){case"value":break;case"multiple":Z=D;default:i.hasOwnProperty(d)||et(e,t,d,null,i,D)}for(c in i)if(d=i[c],D=s[c],i.hasOwnProperty(c)&&(d!=null||D!=null))switch(c){case"value":I=d;break;case"defaultValue":C=d;break;case"multiple":y=d;default:d!==D&&et(e,t,c,d,i,D)}t=C,s=y,i=Z,I!=null?oa(e,!!s,I,!1):!!i!=!!s&&(t!=null?oa(e,!!s,t,!0):oa(e,!!s,s?[]:"",!1));return;case"textarea":Z=I=null;for(C in s)if(c=s[C],s.hasOwnProperty(C)&&c!=null&&!i.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:et(e,t,C,null,i,c)}for(y in i)if(c=i[y],d=s[y],i.hasOwnProperty(y)&&(c!=null||d!=null))switch(y){case"value":I=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==d&&et(e,t,y,c,i,d)}Df(e,I,Z);return;case"option":for(var ve in s)if(I=s[ve],s.hasOwnProperty(ve)&&I!=null&&!i.hasOwnProperty(ve))switch(ve){case"selected":e.selected=!1;break;default:et(e,t,ve,null,i,I)}for(D in i)if(I=i[D],Z=s[D],i.hasOwnProperty(D)&&I!==Z&&(I!=null||Z!=null))switch(D){case"selected":e.selected=I&&typeof I!="function"&&typeof I!="symbol";break;default:et(e,t,D,I,i,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ce in s)I=s[Ce],s.hasOwnProperty(Ce)&&I!=null&&!i.hasOwnProperty(Ce)&&et(e,t,Ce,null,i,I);for(Y in i)if(I=i[Y],Z=s[Y],i.hasOwnProperty(Y)&&I!==Z&&(I!=null||Z!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:et(e,t,Y,I,i,Z)}return;default:if(Lo(t)){for(var tt in s)I=s[tt],s.hasOwnProperty(tt)&&I!==void 0&&!i.hasOwnProperty(tt)&&Nu(e,t,tt,void 0,i,I);for(W in i)I=i[W],Z=s[W],!i.hasOwnProperty(W)||I===Z||I===void 0&&Z===void 0||Nu(e,t,W,I,i,Z);return}}for(var U in s)I=s[U],s.hasOwnProperty(U)&&I!=null&&!i.hasOwnProperty(U)&&et(e,t,U,null,i,I);for(se in i)I=i[se],Z=s[se],!i.hasOwnProperty(se)||I===Z||I==null&&Z==null||et(e,t,se,I,i,Z)}function L0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Fb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),i=0;i<s.length;i++){var c=s[i],d=c.transferSize,y=c.initiatorType,C=c.duration;if(d&&C&&L0(y)){for(y=0,C=c.responseEnd,i+=1;i<s.length;i++){var D=s[i],Y=D.startTime;if(Y>C)break;var W=D.transferSize,se=D.initiatorType;W&&L0(se)&&(D=D.responseEnd,y+=W*(D<C?1:(C-Y)/(D-Y)))}if(--i,t+=8*(d+y)/(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 wu=null,Au=null;function wi(e){return e.nodeType===9?e:e.ownerDocument}function z0(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function U0(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Cu(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 ku=null;function Yb(){var e=window.event;return e&&e.type==="popstate"?e===ku?!1:(ku=e,!0):(ku=null,!1)}var H0=typeof setTimeout=="function"?setTimeout:void 0,Xb=typeof clearTimeout=="function"?clearTimeout:void 0,V0=typeof Promise=="function"?Promise:void 0,Qb=typeof queueMicrotask=="function"?queueMicrotask:typeof V0<"u"?function(e){return V0.resolve(null).then(e).catch(Ib)}:H0;function Ib(e){setTimeout(function(){throw e})}function Ss(e){return e==="head"}function $0(e,t){var s=t,i=0;do{var c=s.nextSibling;if(e.removeChild(s),c&&c.nodeType===8)if(s=c.data,s==="/$"||s==="/&"){if(i===0){e.removeChild(c),Ha(t);return}i--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")i++;else if(s==="html")Vl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,Vl(s);for(var d=s.firstChild;d;){var y=d.nextSibling,C=d.nodeName;d[ll]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||s.removeChild(d),d=y}}else s==="body"&&Vl(e.ownerDocument.body);s=c}while(s);Ha(t)}function G0(e,t){var s=e;e=0;do{var i=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=i}while(s)}function Eu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":Eu(s),Do(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function Kb(e,t,s,i){for(;e.nodeType===1;){var c=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[ll])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(d=e.getAttribute("rel"),d==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(d!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(d=e.getAttribute("src"),(d!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&d&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var d=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===d)return e}else return e;if(e=un(e.nextSibling),e===null)break}return null}function Zb(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=un(e.nextSibling),e===null))return null;return e}function F0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=un(e.nextSibling),e===null))return null;return e}function Mu(e){return e.data==="$?"||e.data==="$~"}function Ru(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Jb(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var i=function(){t(),s.removeEventListener("DOMContentLoaded",i)};s.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function un(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Tu=null;function Y0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return un(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function X0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function Q0(e,t,s){switch(t=wi(s),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 Vl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Do(e)}var dn=new Map,I0=new Set;function Ai(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var In=H.d;H.d={f:Pb,r:Wb,D:ey,C:ty,L:ny,m:sy,X:ly,S:ay,M:ry};function Pb(){var e=In.f(),t=xi();return e||t}function Wb(e){var t=la(e);t!==null&&t.tag===5&&t.type==="form"?dh(t):In.r(e)}var La=typeof document>"u"?null:document;function K0(e,t,s){var i=La;if(i&&typeof t=="string"&&t){var c=nn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof s=="string"&&(c+='[crossorigin="'+s+'"]'),I0.has(c)||(I0.add(c),e={rel:e,crossOrigin:s,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Mt(t,"link",e),jt(t),i.head.appendChild(t)))}}function ey(e){In.D(e),K0("dns-prefetch",e,null)}function ty(e,t){In.C(e,t),K0("preconnect",e,t)}function ny(e,t,s){In.L(e,t,s);var i=La;if(i&&e&&t){var c='link[rel="preload"][as="'+nn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(c+='[imagesrcset="'+nn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(c+='[imagesizes="'+nn(s.imageSizes)+'"]')):c+='[href="'+nn(e)+'"]';var d=c;switch(t){case"style":d=za(e);break;case"script":d=Ua(e)}dn.has(d)||(e=b({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),dn.set(d,e),i.querySelector(c)!==null||t==="style"&&i.querySelector($l(d))||t==="script"&&i.querySelector(Gl(d))||(t=i.createElement("link"),Mt(t,"link",e),jt(t),i.head.appendChild(t)))}}function sy(e,t){In.m(e,t);var s=La;if(s&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+nn(i)+'"][href="'+nn(e)+'"]',d=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Ua(e)}if(!dn.has(d)&&(e=b({rel:"modulepreload",href:e},t),dn.set(d,e),s.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Gl(d)))return}i=s.createElement("link"),Mt(i,"link",e),jt(i),s.head.appendChild(i)}}}function ay(e,t,s){In.S(e,t,s);var i=La;if(i&&e){var c=ra(i).hoistableStyles,d=za(e);t=t||"default";var y=c.get(d);if(!y){var C={loading:0,preload:null};if(y=i.querySelector($l(d)))C.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},s),(s=dn.get(d))&&qu(e,s);var D=y=i.createElement("link");jt(D),Mt(D,"link",e),D._p=new Promise(function(Y,W){D.onload=Y,D.onerror=W}),D.addEventListener("load",function(){C.loading|=1}),D.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Ci(y,t,i)}y={type:"stylesheet",instance:y,count:1,state:C},c.set(d,y)}}}function ly(e,t){In.X(e,t);var s=La;if(s&&e){var i=ra(s).hoistableScripts,c=Ua(e),d=i.get(c);d||(d=s.querySelector(Gl(c)),d||(e=b({src:e,async:!0},t),(t=dn.get(c))&&Du(e,t),d=s.createElement("script"),jt(d),Mt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function ry(e,t){In.M(e,t);var s=La;if(s&&e){var i=ra(s).hoistableScripts,c=Ua(e),d=i.get(c);d||(d=s.querySelector(Gl(c)),d||(e=b({src:e,async:!0,type:"module"},t),(t=dn.get(c))&&Du(e,t),d=s.createElement("script"),jt(d),Mt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function Z0(e,t,s,i){var c=(c=ce.current)?Ai(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=za(s.href),s=ra(c).hoistableStyles,i=s.get(t),i||(i={type:"style",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=za(s.href);var d=ra(c).hoistableStyles,y=d.get(e);if(y||(c=c.ownerDocument||c,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(e,y),(d=c.querySelector($l(e)))&&!d._p&&(y.instance=d,y.state.loading=5),dn.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},dn.set(e,s),d||iy(c,e,s,y.state))),t&&i===null)throw Error(o(528,""));return y}if(t&&i!==null)throw Error(o(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ua(s),s=ra(c).hoistableScripts,i=s.get(t),i||(i={type:"script",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function za(e){return'href="'+nn(e)+'"'}function $l(e){return'link[rel="stylesheet"]['+e+"]"}function J0(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function iy(e,t,s,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Mt(t,"link",s),jt(t),e.head.appendChild(t))}function Ua(e){return'[src="'+nn(e)+'"]'}function Gl(e){return"script[async]"+e}function P0(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+nn(s.href)+'"]');if(i)return t.instance=i,jt(i),i;var c=b({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),jt(i),Mt(i,"style",c),Ci(i,s.precedence,e),t.instance=i;case"stylesheet":c=za(s.href);var d=e.querySelector($l(c));if(d)return t.state.loading|=4,t.instance=d,jt(d),d;i=J0(s),(c=dn.get(c))&&qu(i,c),d=(e.ownerDocument||e).createElement("link"),jt(d);var y=d;return y._p=new Promise(function(C,D){y.onload=C,y.onerror=D}),Mt(d,"link",i),t.state.loading|=4,Ci(d,s.precedence,e),t.instance=d;case"script":return d=Ua(s.src),(c=e.querySelector(Gl(d)))?(t.instance=c,jt(c),c):(i=s,(c=dn.get(d))&&(i=b({},s),Du(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),jt(c),Mt(c,"link",i),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,Ci(i,s.precedence,e));return t.instance}function Ci(e,t,s){for(var i=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,d=c,y=0;y<i.length;y++){var C=i[y];if(C.dataset.precedence===t)d=C;else if(d!==c)break}d?d.parentNode.insertBefore(e,d.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function qu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Du(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ki=null;function W0(e,t,s){if(ki===null){var i=new Map,c=ki=new Map;c.set(s,i)}else c=ki,i=c.get(s),i||(i=new Map,c.set(s,i));if(i.has(e))return i;for(i.set(e,null),s=s.getElementsByTagName(e),c=0;c<s.length;c++){var d=s[c];if(!(d[ll]||d[At]||e==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var y=d.getAttribute(t)||"";y=e+y;var C=i.get(y);C?C.push(d):i.set(y,[d])}}return i}function ep(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function oy(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function tp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function cy(e,t,s,i){if(s.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var c=za(i.href),d=t.querySelector($l(c));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Ei.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=d,jt(d);return}d=t.ownerDocument||t,i=J0(i),(c=dn.get(c))&&qu(i,c),d=d.createElement("link"),jt(d);var y=d;y._p=new Promise(function(C,D){y.onload=C,y.onerror=D}),Mt(d,"link",i),s.instance=d}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Ei.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var _u=0;function uy(e,t){return e.stylesheets&&e.count===0&&Ri(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var i=setTimeout(function(){if(e.stylesheets&&Ri(e,e.stylesheets),e.unsuspend){var d=e.unsuspend;e.unsuspend=null,d()}},6e4+t);0<e.imgBytes&&_u===0&&(_u=62500*Fb());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ri(e,e.stylesheets),e.unsuspend)){var d=e.unsuspend;e.unsuspend=null,d()}},(e.imgBytes>_u?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Ei(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ri(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Mi=null;function Ri(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Mi=new Map,t.forEach(dy,e),Mi=null,Ei.call(e))}function dy(e,t){if(!(t.state.loading&4)){var s=Mi.get(e);if(s)var i=s.get(null);else{s=new Map,Mi.set(e,s);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<c.length;d++){var y=c[d];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(s.set(y.dataset.precedence,y),i=y)}i&&s.set(null,i)}c=t.instance,y=c.getAttribute("data-precedence"),d=s.get(y)||i,d===i&&s.set(null,c),s.set(y,c),this.count++,i=Ei.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),d?d.parentNode.insertBefore(c,d.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Fl={$$typeof:E,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function fy(e,t,s,i,c,d,y,C,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=Mo(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mo(0),this.hiddenUpdates=Mo(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=d,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function np(e,t,s,i,c,d,y,C,D,Y,W,se){return e=new fy(e,t,s,y,D,Y,W,se,C),t=1,d===!0&&(t|=24),d=Xt(3,null,null,t),e.current=d,d.stateNode=e,t=mc(),t.refCount++,e.pooledCache=t,t.refCount++,d.memoizedState={element:i,isDehydrated:s,cache:t},gc(d),e}function sp(e){return e?(e=xa,e):xa}function ap(e,t,s,i,c,d){c=sp(c),i.context===null?i.context=c:i.pendingContext=c,i=us(t),i.payload={element:s},d=d===void 0?null:d,d!==null&&(i.callback=d),s=ds(e,i,t),s!==null&&($t(s,e,t),jl(s,e,t))}function lp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Ou(e,t){lp(e,t),(e=e.alternate)&&lp(e,t)}function rp(e){if(e.tag===13||e.tag===31){var t=Os(e,67108864);t!==null&&$t(t,e,67108864),Ou(e,67108864)}}function ip(e){if(e.tag===13||e.tag===31){var t=Jt();t=Ro(t);var s=Os(e,t);s!==null&&$t(s,e,t),Ou(e,t)}}var Ti=!0;function my(e,t,s,i){var c=q.T;q.T=null;var d=H.p;try{H.p=2,Bu(e,t,s,i)}finally{H.p=d,q.T=c}}function hy(e,t,s,i){var c=q.T;q.T=null;var d=H.p;try{H.p=8,Bu(e,t,s,i)}finally{H.p=d,q.T=c}}function Bu(e,t,s,i){if(Ti){var c=Lu(i);if(c===null)ju(e,t,i,qi,s),cp(e,i);else if(xy(c,e,t,s,i))i.stopPropagation();else if(cp(e,i),t&4&&-1<py.indexOf(e)){for(;c!==null;){var d=la(c);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var y=Rs(d.pendingLanes);if(y!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;y;){var D=1<<31-Pe(y);C.entanglements[1]|=D,y&=~D}Cn(d),(Ie&6)===0&&(hi=le()+500,zl(0))}}break;case 31:case 13:C=Os(d,2),C!==null&&$t(C,d,2),xi(),Ou(d,2)}if(d=Lu(i),d===null&&ju(e,t,i,qi,s),d===c)break;c=d}c!==null&&i.stopPropagation()}else ju(e,t,i,null,s)}}function Lu(e){return e=Uo(e),zu(e)}var qi=null;function zu(e){if(qi=null,e=aa(e),e!==null){var t=f(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=h(t),e!==null)return e;e=null}else if(s===31){if(e=p(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return qi=e,null}function op(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(he()){case De:return 2;case Tt:return 8;case qt:case nl:return 32;case Ft:return 268435456;default:return 32}default:return 32}}var Uu=!1,js=null,Ns=null,ws=null,Yl=new Map,Xl=new Map,As=[],py="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function cp(e,t){switch(e){case"focusin":case"focusout":js=null;break;case"dragenter":case"dragleave":Ns=null;break;case"mouseover":case"mouseout":ws=null;break;case"pointerover":case"pointerout":Yl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xl.delete(t.pointerId)}}function Ql(e,t,s,i,c,d){return e===null||e.nativeEvent!==d?(e={blockedOn:t,domEventName:s,eventSystemFlags:i,nativeEvent:d,targetContainers:[c]},t!==null&&(t=la(t),t!==null&&rp(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function xy(e,t,s,i,c){switch(t){case"focusin":return js=Ql(js,e,t,s,i,c),!0;case"dragenter":return Ns=Ql(Ns,e,t,s,i,c),!0;case"mouseover":return ws=Ql(ws,e,t,s,i,c),!0;case"pointerover":var d=c.pointerId;return Yl.set(d,Ql(Yl.get(d)||null,e,t,s,i,c)),!0;case"gotpointercapture":return d=c.pointerId,Xl.set(d,Ql(Xl.get(d)||null,e,t,s,i,c)),!0}return!1}function up(e){var t=aa(e.target);if(t!==null){var s=f(t);if(s!==null){if(t=s.tag,t===13){if(t=h(s),t!==null){e.blockedOn=t,wf(e.priority,function(){ip(s)});return}}else if(t===31){if(t=p(s),t!==null){e.blockedOn=t,wf(e.priority,function(){ip(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Di(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=Lu(e.nativeEvent);if(s===null){s=e.nativeEvent;var i=new s.constructor(s.type,s);zo=i,s.target.dispatchEvent(i),zo=null}else return t=la(s),t!==null&&rp(t),e.blockedOn=s,!1;t.shift()}return!0}function dp(e,t,s){Di(e)&&s.delete(t)}function gy(){Uu=!1,js!==null&&Di(js)&&(js=null),Ns!==null&&Di(Ns)&&(Ns=null),ws!==null&&Di(ws)&&(ws=null),Yl.forEach(dp),Xl.forEach(dp)}function _i(e,t){e.blockedOn===t&&(e.blockedOn=null,Uu||(Uu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,gy)))}var Oi=null;function fp(e){Oi!==e&&(Oi=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Oi===e&&(Oi=null);for(var t=0;t<e.length;t+=3){var s=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(zu(i||s)===null)continue;break}var d=la(s);d!==null&&(e.splice(t,3),t-=3,Lc(d,{pending:!0,data:c,method:s.method,action:i},i,c))}}))}function Ha(e){function t(D){return _i(D,e)}js!==null&&_i(js,e),Ns!==null&&_i(Ns,e),ws!==null&&_i(ws,e),Yl.forEach(t),Xl.forEach(t);for(var s=0;s<As.length;s++){var i=As[s];i.blockedOn===e&&(i.blockedOn=null)}for(;0<As.length&&(s=As[0],s.blockedOn===null);)up(s),s.blockedOn===null&&As.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(i=0;i<s.length;i+=3){var c=s[i],d=s[i+1],y=c[Bt]||null;if(typeof d=="function")y||fp(s);else if(y){var C=null;if(d&&d.hasAttribute("formAction")){if(c=d,y=d[Bt]||null)C=y.formAction;else if(zu(c)!==null)continue}else C=y.action;typeof C=="function"?s[i+1]=C:(s.splice(i,3),i-=3),fp(s)}}}function mp(){function e(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(y){return c=y})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),i||setTimeout(s,20)}function s(){if(!i&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Hu(e){this._internalRoot=e}Bi.prototype.render=Hu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var s=t.current,i=Jt();ap(s,i,e,t,null,null)},Bi.prototype.unmount=Hu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ap(e.current,2,null,e,null,null),xi(),t[sa]=null}};function Bi(e){this._internalRoot=e}Bi.prototype.unstable_scheduleHydration=function(e){if(e){var t=Nf();e={blockedOn:null,target:e,priority:t};for(var s=0;s<As.length&&t!==0&&t<As[s].priority;s++);As.splice(s,0,e),s===0&&up(e)}};var hp=a.version;if(hp!=="19.2.0")throw Error(o(527,hp,"19.2.0"));H.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=x(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var vy={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Li=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Li.isDisabled&&Li.supportsFiber)try{Ke=Li.inject(vy),ke=Li}catch{}}return Kl.createRoot=function(e,t){if(!u(e))throw Error(o(299));var s=!1,i="",c=Sh,d=jh,y=Nh;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=np(e,1,!1,null,null,s,i,null,c,d,y,mp),e[sa]=t.current,Su(e),new Hu(t)},Kl.hydrateRoot=function(e,t,s){if(!u(e))throw Error(o(299));var i=!1,c="",d=Sh,y=jh,C=Nh,D=null;return s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(C=s.onRecoverableError),s.formState!==void 0&&(D=s.formState)),t=np(e,1,!0,t,s??null,i,c,D,d,y,C,mp),t.context=sp(null),s=t.current,i=Jt(),i=Ro(i),c=us(i),c.callback=null,ds(s,c,i),s=i,t.current.lanes=s,al(t,s),Cn(t),e[sa]=t.current,Su(e),new Bi(t)},Kl.version="19.2.0",Kl}var wp;function My(){if(wp)return Gu.exports;wp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Gu.exports=Ey(),Gu.exports}var Ry=My();var Ap="popstate";function Ty(n={}){function a(o,u){let{pathname:f,search:h,hash:p}=o.location;return gd("",{pathname:f,search:h,hash:p},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function r(o,u){return typeof u=="string"?u:or(u)}return Dy(a,r,null,n)}function ot(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function Sn(n,a){if(!n){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function qy(){return Math.random().toString(36).substring(2,10)}function Cp(n,a){return{usr:n.state,key:n.key,idx:a}}function gd(n,a,r=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof a=="string"?Wa(a):a,state:r,key:a&&a.key||o||qy()}}function or({pathname:n="/",search:a="",hash:r=""}){return a&&a!=="?"&&(n+=a.charAt(0)==="?"?a:"?"+a),r&&r!=="#"&&(n+=r.charAt(0)==="#"?r:"#"+r),n}function Wa(n){let a={};if(n){let r=n.indexOf("#");r>=0&&(a.hash=n.substring(r),n=n.substring(0,r));let o=n.indexOf("?");o>=0&&(a.search=n.substring(o),n=n.substring(0,o)),n&&(a.pathname=n)}return a}function Dy(n,a,r,o={}){let{window:u=document.defaultView,v5Compat:f=!1}=o,h=u.history,p="POP",g=null,x=v();x==null&&(x=0,h.replaceState({...h.state,idx:x},""));function v(){return(h.state||{idx:null}).idx}function b(){p="POP";let w=v(),S=w==null?null:w-x;x=w,g&&g({action:p,location:N.location,delta:S})}function j(w,S){p="PUSH";let R=gd(N.location,w,S);x=v()+1;let E=Cp(R,x),A=N.createHref(R);try{h.pushState(E,"",A)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;u.location.assign(A)}f&&g&&g({action:p,location:N.location,delta:1})}function M(w,S){p="REPLACE";let R=gd(N.location,w,S);x=v();let E=Cp(R,x),A=N.createHref(R);h.replaceState(E,"",A),f&&g&&g({action:p,location:N.location,delta:0})}function k(w){return _y(w)}let N={get action(){return p},get location(){return n(u,h)},listen(w){if(g)throw new Error("A history only accepts one active listener");return u.addEventListener(Ap,b),g=w,()=>{u.removeEventListener(Ap,b),g=null}},createHref(w){return a(u,w)},createURL:k,encodeLocation(w){let S=k(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:j,replace:M,go(w){return h.go(w)}};return N}function _y(n,a=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),ot(r,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:or(n);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=r+o),new URL(o,r)}function Mx(n,a,r="/"){return Oy(n,a,r,!1)}function Oy(n,a,r,o){let u=typeof a=="string"?Wa(a):a,f=es(u.pathname||"/",r);if(f==null)return null;let h=Rx(n);By(h);let p=null;for(let g=0;p==null&&g<h.length;++g){let x=Qy(f);p=Yy(h[g],x,o)}return p}function Rx(n,a=[],r=[],o="",u=!1){let f=(h,p,g=u,x)=>{let v={relativePath:x===void 0?h.path||"":x,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&g)return;ot(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=Wn([o,v.relativePath]),j=r.concat(v);h.children&&h.children.length>0&&(ot(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),Rx(h.children,a,j,b,g)),!(h.path==null&&!h.index)&&a.push({path:b,score:Gy(b,h.index),routesMeta:j})};return n.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))f(h,p);else for(let g of Tx(h.path))f(h,p,!0,g)}),a}function Tx(n){let a=n.split("/");if(a.length===0)return[];let[r,...o]=a,u=r.endsWith("?"),f=r.replace(/\?$/,"");if(o.length===0)return u?[f,""]:[f];let h=Tx(o.join("/")),p=[];return p.push(...h.map(g=>g===""?f:[f,g].join("/"))),u&&p.push(...h),p.map(g=>n.startsWith("/")&&g===""?"/":g)}function By(n){n.sort((a,r)=>a.score!==r.score?r.score-a.score:Fy(a.routesMeta.map(o=>o.childrenIndex),r.routesMeta.map(o=>o.childrenIndex)))}var Ly=/^:[\w-]+$/,zy=3,Uy=2,Hy=1,Vy=10,$y=-2,kp=n=>n==="*";function Gy(n,a){let r=n.split("/"),o=r.length;return r.some(kp)&&(o+=$y),a&&(o+=Uy),r.filter(u=>!kp(u)).reduce((u,f)=>u+(Ly.test(f)?zy:f===""?Hy:Vy),o)}function Fy(n,a){return n.length===a.length&&n.slice(0,-1).every((o,u)=>o===a[u])?n[n.length-1]-a[a.length-1]:0}function Yy(n,a,r=!1){let{routesMeta:o}=n,u={},f="/",h=[];for(let p=0;p<o.length;++p){let g=o[p],x=p===o.length-1,v=f==="/"?a:a.slice(f.length)||"/",b=lo({path:g.relativePath,caseSensitive:g.caseSensitive,end:x},v),j=g.route;if(!b&&x&&r&&!o[o.length-1].route.index&&(b=lo({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},v)),!b)return null;Object.assign(u,b.params),h.push({params:u,pathname:Wn([f,b.pathname]),pathnameBase:Py(Wn([f,b.pathnameBase])),route:j}),b.pathnameBase!=="/"&&(f=Wn([f,b.pathnameBase]))}return h}function lo(n,a){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[r,o]=Xy(n.path,n.caseSensitive,n.end),u=a.match(r);if(!u)return null;let f=u[0],h=f.replace(/(.)\/+$/,"$1"),p=u.slice(1);return{params:o.reduce((x,{paramName:v,isOptional:b},j)=>{if(v==="*"){let k=p[j]||"";h=f.slice(0,f.length-k.length).replace(/(.)\/+$/,"$1")}const M=p[j];return b&&!M?x[v]=void 0:x[v]=(M||"").replace(/%2F/g,"/"),x},{}),pathname:f,pathnameBase:h,pattern:n}}function Xy(n,a=!1,r=!0){Sn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,g)=>(o.push({paramName:p,isOptional:g!=null}),g?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,a?void 0:"i"),o]}function Qy(n){try{return n.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return Sn(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),n}}function es(n,a){if(a==="/")return n;if(!n.toLowerCase().startsWith(a.toLowerCase()))return null;let r=a.endsWith("/")?a.length-1:a.length,o=n.charAt(r);return o&&o!=="/"?null:n.slice(r)||"/"}var Iy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ky=n=>Iy.test(n);function Zy(n,a="/"){let{pathname:r,search:o="",hash:u=""}=typeof n=="string"?Wa(n):n,f;if(r)if(Ky(r))f=r;else{if(r.includes("//")){let h=r;r=r.replace(/\/\/+/g,"/"),Sn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${r}`)}r.startsWith("/")?f=Ep(r.substring(1),"/"):f=Ep(r,a)}else f=a;return{pathname:f,search:Wy(o),hash:e1(u)}}function Ep(n,a){let r=a.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?r.length>1&&r.pop():u!=="."&&r.push(u)}),r.length>1?r.join("/"):"/"}function Qu(n,a,r,o){return`Cannot include a '${n}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Jy(n){return n.filter((a,r)=>r===0||a.route.path&&a.route.path.length>0)}function qx(n){let a=Jy(n);return a.map((r,o)=>o===a.length-1?r.pathname:r.pathnameBase)}function Dx(n,a,r,o=!1){let u;typeof n=="string"?u=Wa(n):(u={...n},ot(!u.pathname||!u.pathname.includes("?"),Qu("?","pathname","search",u)),ot(!u.pathname||!u.pathname.includes("#"),Qu("#","pathname","hash",u)),ot(!u.search||!u.search.includes("#"),Qu("#","search","hash",u)));let f=n===""||u.pathname==="",h=f?"/":u.pathname,p;if(h==null)p=r;else{let b=a.length-1;if(!o&&h.startsWith("..")){let j=h.split("/");for(;j[0]==="..";)j.shift(),b-=1;u.pathname=j.join("/")}p=b>=0?a[b]:"/"}let g=Zy(u,p),x=h&&h!=="/"&&h.endsWith("/"),v=(f||h===".")&&r.endsWith("/");return!g.pathname.endsWith("/")&&(x||v)&&(g.pathname+="/"),g}var Wn=n=>n.join("/").replace(/\/\/+/g,"/"),Py=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Wy=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,e1=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function t1(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _x=["POST","PUT","PATCH","DELETE"];new Set(_x);var n1=["GET",..._x];new Set(n1);var el=m.createContext(null);el.displayName="DataRouter";var go=m.createContext(null);go.displayName="DataRouterState";m.createContext(!1);var Ox=m.createContext({isTransitioning:!1});Ox.displayName="ViewTransition";var s1=m.createContext(new Map);s1.displayName="Fetchers";var a1=m.createContext(null);a1.displayName="Await";var Rn=m.createContext(null);Rn.displayName="Navigation";var xr=m.createContext(null);xr.displayName="Location";var ns=m.createContext({outlet:null,matches:[],isDataRoute:!1});ns.displayName="Route";var zd=m.createContext(null);zd.displayName="RouteError";function l1(n,{relative:a}={}){ot(gr(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=m.useContext(Rn),{hash:u,pathname:f,search:h}=vr(n,{relative:a}),p=f;return r!=="/"&&(p=f==="/"?r:Wn([r,f])),o.createHref({pathname:p,search:h,hash:u})}function gr(){return m.useContext(xr)!=null}function ta(){return ot(gr(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(xr).location}var Bx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Lx(n){m.useContext(Rn).static||m.useLayoutEffect(n)}function r1(){let{isDataRoute:n}=m.useContext(ns);return n?b1():i1()}function i1(){ot(gr(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(el),{basename:a,navigator:r}=m.useContext(Rn),{matches:o}=m.useContext(ns),{pathname:u}=ta(),f=JSON.stringify(qx(o)),h=m.useRef(!1);return Lx(()=>{h.current=!0}),m.useCallback((g,x={})=>{if(Sn(h.current,Bx),!h.current)return;if(typeof g=="number"){r.go(g);return}let v=Dx(g,JSON.parse(f),u,x.relative==="path");n==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:Wn([a,v.pathname])),(x.replace?r.replace:r.push)(v,x.state,x)},[a,r,f,u,n])}m.createContext(null);function vr(n,{relative:a}={}){let{matches:r}=m.useContext(ns),{pathname:o}=ta(),u=JSON.stringify(qx(r));return m.useMemo(()=>Dx(n,JSON.parse(u),o,a==="path"),[n,u,o,a])}function o1(n,a){return zx(n,a)}function zx(n,a,r,o,u){ot(gr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(Rn),{matches:h}=m.useContext(ns),p=h[h.length-1],g=p?p.params:{},x=p?p.pathname:"/",v=p?p.pathnameBase:"/",b=p&&p.route;{let R=b&&b.path||"";Ux(x,!b||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${x}" (under <Route path="${R}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${R}"> to <Route path="${R==="/"?"*":`${R}/*`}">.`)}let j=ta(),M;if(a){let R=typeof a=="string"?Wa(a):a;ot(v==="/"||R.pathname?.startsWith(v),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${v}" but pathname "${R.pathname}" was given in the \`location\` prop.`),M=R}else M=j;let k=M.pathname||"/",N=k;if(v!=="/"){let R=v.replace(/^\//,"").split("/");N="/"+k.replace(/^\//,"").split("/").slice(R.length).join("/")}let w=Mx(n,{pathname:N});Sn(b||w!=null,`No routes matched location "${M.pathname}${M.search}${M.hash}" `),Sn(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${M.pathname}${M.search}${M.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=m1(w&&w.map(R=>Object.assign({},R,{params:Object.assign({},g,R.params),pathname:Wn([v,f.encodeLocation?f.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?v:Wn([v,f.encodeLocation?f.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),h,r,o,u);return a&&S?m.createElement(xr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...M},navigationType:"POP"}},S):S}function c1(){let n=v1(),a=t1(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),r=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:o},f={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:f},"ErrorBoundary")," or"," ",m.createElement("code",{style:f},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},a),r?m.createElement("pre",{style:u},r):null,h)}var u1=m.createElement(c1,null),d1=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,a){return a.location!==n.location||a.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:a.error,location:a.location,revalidation:n.revalidation||a.revalidation}}componentDidCatch(n,a){this.props.onError?this.props.onError(n,a):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(ns.Provider,{value:this.props.routeContext},m.createElement(zd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function f1({routeContext:n,match:a,children:r}){let o=m.useContext(el);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(ns.Provider,{value:n},r)}function m1(n,a=[],r=null,o=null,u=null){if(n==null){if(!r)return null;if(r.errors)n=r.matches;else if(a.length===0&&!r.initialized&&r.matches.length>0)n=r.matches;else return null}let f=n,h=r?.errors;if(h!=null){let v=f.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);ot(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),f=f.slice(0,Math.min(f.length,v+1))}let p=!1,g=-1;if(r)for(let v=0;v<f.length;v++){let b=f[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(g=v),b.route.id){let{loaderData:j,errors:M}=r,k=b.route.loader&&!j.hasOwnProperty(b.route.id)&&(!M||M[b.route.id]===void 0);if(b.route.lazy||k){p=!0,g>=0?f=f.slice(0,g+1):f=[f[0]];break}}}let x=r&&o?(v,b)=>{o(v,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:b})}:void 0;return f.reduceRight((v,b,j)=>{let M,k=!1,N=null,w=null;r&&(M=h&&b.route.id?h[b.route.id]:void 0,N=b.route.errorElement||u1,p&&(g<0&&j===0?(Ux("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,w=null):g===j&&(k=!0,w=b.route.hydrateFallbackElement||null)));let S=a.concat(f.slice(0,j+1)),R=()=>{let E;return M?E=N:k?E=w:b.route.Component?E=m.createElement(b.route.Component,null):b.route.element?E=b.route.element:E=v,m.createElement(f1,{match:b,routeContext:{outlet:v,matches:S,isDataRoute:r!=null},children:E})};return r&&(b.route.ErrorBoundary||b.route.errorElement||j===0)?m.createElement(d1,{location:r.location,revalidation:r.revalidation,component:N,error:M,children:R(),routeContext:{outlet:null,matches:S,isDataRoute:!0},onError:x}):R()},null)}function Ud(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function h1(n){let a=m.useContext(el);return ot(a,Ud(n)),a}function p1(n){let a=m.useContext(go);return ot(a,Ud(n)),a}function x1(n){let a=m.useContext(ns);return ot(a,Ud(n)),a}function Hd(n){let a=x1(n),r=a.matches[a.matches.length-1];return ot(r.route.id,`${n} can only be used on routes that contain a unique "id"`),r.route.id}function g1(){return Hd("useRouteId")}function v1(){let n=m.useContext(zd),a=p1("useRouteError"),r=Hd("useRouteError");return n!==void 0?n:a.errors?.[r]}function b1(){let{router:n}=h1("useNavigate"),a=Hd("useNavigate"),r=m.useRef(!1);return Lx(()=>{r.current=!0}),m.useCallback(async(u,f={})=>{Sn(r.current,Bx),r.current&&(typeof u=="number"?n.navigate(u):await n.navigate(u,{fromRouteId:a,...f}))},[n,a])}var Mp={};function Ux(n,a,r){!a&&!Mp[n]&&(Mp[n]=!0,Sn(!1,r))}m.memo(y1);function y1({routes:n,future:a,state:r,unstable_onError:o}){return zx(n,void 0,r,o,a)}function Ki(n){ot(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function S1({basename:n="/",children:a=null,location:r,navigationType:o="POP",navigator:u,static:f=!1}){ot(!gr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:u,static:f,future:{}}),[h,u,f]);typeof r=="string"&&(r=Wa(r));let{pathname:g="/",search:x="",hash:v="",state:b=null,key:j="default"}=r,M=m.useMemo(()=>{let k=es(g,h);return k==null?null:{location:{pathname:k,search:x,hash:v,state:b,key:j},navigationType:o}},[h,g,x,v,b,j,o]);return Sn(M!=null,`<Router basename="${h}"> is not able to match the URL "${g}${x}${v}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:m.createElement(Rn.Provider,{value:p},m.createElement(xr.Provider,{children:a,value:M}))}function j1({children:n,location:a}){return o1(vd(n),a)}function vd(n,a=[]){let r=[];return m.Children.forEach(n,(o,u)=>{if(!m.isValidElement(o))return;let f=[...a,u];if(o.type===m.Fragment){r.push.apply(r,vd(o.props.children,f));return}ot(o.type===Ki,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||f.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=vd(o.props.children,f)),r.push(h)}),r}var Zi="get",Ji="application/x-www-form-urlencoded";function vo(n){return n!=null&&typeof n.tagName=="string"}function N1(n){return vo(n)&&n.tagName.toLowerCase()==="button"}function w1(n){return vo(n)&&n.tagName.toLowerCase()==="form"}function A1(n){return vo(n)&&n.tagName.toLowerCase()==="input"}function C1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function k1(n,a){return n.button===0&&(!a||a==="_self")&&!C1(n)}var zi=null;function E1(){if(zi===null)try{new FormData(document.createElement("form"),0),zi=!1}catch{zi=!0}return zi}var M1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Iu(n){return n!=null&&!M1.has(n)?(Sn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ji}"`),null):n}function R1(n,a){let r,o,u,f,h;if(w1(n)){let p=n.getAttribute("action");o=p?es(p,a):null,r=n.getAttribute("method")||Zi,u=Iu(n.getAttribute("enctype"))||Ji,f=new FormData(n)}else if(N1(n)||A1(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=n.getAttribute("formaction")||p.getAttribute("action");if(o=g?es(g,a):null,r=n.getAttribute("formmethod")||p.getAttribute("method")||Zi,u=Iu(n.getAttribute("formenctype"))||Iu(p.getAttribute("enctype"))||Ji,f=new FormData(p,n),!E1()){let{name:x,type:v,value:b}=n;if(v==="image"){let j=x?`${x}.`:"";f.append(`${j}x`,"0"),f.append(`${j}y`,"0")}else x&&f.append(x,b)}}else{if(vo(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Zi,o=null,u=Ji,h=n}return f&&u==="text/plain"&&(h=f,f=void 0),{action:o,method:r.toLowerCase(),encType:u,formData:f,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Vd(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function T1(n,a,r){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${r}`:a&&es(o.pathname,a)==="/"?o.pathname=`${a.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function q1(n,a){if(n.id in a)return a[n.id];try{let r=await import(n.module);return a[n.id]=r,r}catch(r){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function D1(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function _1(n,a,r){let o=await Promise.all(n.map(async u=>{let f=a.routes[u.route.id];if(f){let h=await q1(f,r);return h.links?h.links():[]}return[]}));return z1(o.flat(1).filter(D1).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function Rp(n,a,r,o,u,f){let h=(g,x)=>r[x]?g.route.id!==r[x].route.id:!0,p=(g,x)=>r[x].pathname!==g.pathname||r[x].route.path?.endsWith("*")&&r[x].params["*"]!==g.params["*"];return f==="assets"?a.filter((g,x)=>h(g,x)||p(g,x)):f==="data"?a.filter((g,x)=>{let v=o.routes[g.route.id];if(!v||!v.hasLoader)return!1;if(h(g,x)||p(g,x))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function O1(n,a,{includeHydrateFallback:r}={}){return B1(n.map(o=>{let u=a.routes[o.route.id];if(!u)return[];let f=[u.module];return u.clientActionModule&&(f=f.concat(u.clientActionModule)),u.clientLoaderModule&&(f=f.concat(u.clientLoaderModule)),r&&u.hydrateFallbackModule&&(f=f.concat(u.hydrateFallbackModule)),u.imports&&(f=f.concat(u.imports)),f}).flat(1))}function B1(n){return[...new Set(n)]}function L1(n){let a={},r=Object.keys(n).sort();for(let o of r)a[o]=n[o];return a}function z1(n,a){let r=new Set;return new Set(a),n.reduce((o,u)=>{let f=JSON.stringify(L1(u));return r.has(f)||(r.add(f),o.push({key:f,link:u})),o},[])}function Hx(){let n=m.useContext(el);return Vd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function U1(){let n=m.useContext(go);return Vd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var $d=m.createContext(void 0);$d.displayName="FrameworkContext";function Vx(){let n=m.useContext($d);return Vd(n,"You must render this element inside a <HydratedRouter> element"),n}function H1(n,a){let r=m.useContext($d),[o,u]=m.useState(!1),[f,h]=m.useState(!1),{onFocus:p,onBlur:g,onMouseEnter:x,onMouseLeave:v,onTouchStart:b}=a,j=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let N=S=>{S.forEach(R=>{h(R.isIntersecting)})},w=new IntersectionObserver(N,{threshold:.5});return j.current&&w.observe(j.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let N=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(N)}}},[o]);let M=()=>{u(!0)},k=()=>{u(!1),h(!1)};return r?n!=="intent"?[f,j,{}]:[f,j,{onFocus:Zl(p,M),onBlur:Zl(g,k),onMouseEnter:Zl(x,M),onMouseLeave:Zl(v,k),onTouchStart:Zl(b,M)}]:[!1,j,{}]}function Zl(n,a){return r=>{n&&n(r),r.defaultPrevented||a(r)}}function V1({page:n,...a}){let{router:r}=Hx(),o=m.useMemo(()=>Mx(r.routes,n,r.basename),[r.routes,n,r.basename]);return o?m.createElement(G1,{page:n,matches:o,...a}):null}function $1(n){let{manifest:a,routeModules:r}=Vx(),[o,u]=m.useState([]);return m.useEffect(()=>{let f=!1;return _1(n,a,r).then(h=>{f||u(h)}),()=>{f=!0}},[n,a,r]),o}function G1({page:n,matches:a,...r}){let o=ta(),{manifest:u,routeModules:f}=Vx(),{basename:h}=Hx(),{loaderData:p,matches:g}=U1(),x=m.useMemo(()=>Rp(n,a,g,u,o,"data"),[n,a,g,u,o]),v=m.useMemo(()=>Rp(n,a,g,u,o,"assets"),[n,a,g,u,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let k=new Set,N=!1;if(a.forEach(S=>{let R=u.routes[S.route.id];!R||!R.hasLoader||(!x.some(E=>E.route.id===S.route.id)&&S.route.id in p&&f[S.route.id]?.shouldRevalidate||R.hasClientLoader?N=!0:k.add(S.route.id))}),k.size===0)return[];let w=T1(n,h,"data");return N&&k.size>0&&w.searchParams.set("_routes",a.filter(S=>k.has(S.route.id)).map(S=>S.route.id).join(",")),[w.pathname+w.search]},[h,p,o,u,x,a,n,f]),j=m.useMemo(()=>O1(v,u),[v,u]),M=$1(v);return m.createElement(m.Fragment,null,b.map(k=>m.createElement("link",{key:k,rel:"prefetch",as:"fetch",href:k,...r})),j.map(k=>m.createElement("link",{key:k,rel:"modulepreload",href:k,...r})),M.map(({key:k,link:N})=>m.createElement("link",{key:k,nonce:r.nonce,...N})))}function F1(...n){return a=>{n.forEach(r=>{typeof r=="function"?r(a):r!=null&&(r.current=a)})}}var $x=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{$x&&(window.__reactRouterVersion="7.9.6")}catch{}function Y1({basename:n,children:a,window:r}){let o=m.useRef();o.current==null&&(o.current=Ty({window:r,v5Compat:!0}));let u=o.current,[f,h]=m.useState({action:u.action,location:u.location}),p=m.useCallback(g=>{m.startTransition(()=>h(g))},[h]);return m.useLayoutEffect(()=>u.listen(p),[u,p]),m.createElement(S1,{basename:n,children:a,location:f.location,navigationType:f.action,navigator:u})}var Gx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fx=m.forwardRef(function({onClick:a,discover:r="render",prefetch:o="none",relative:u,reloadDocument:f,replace:h,state:p,target:g,to:x,preventScrollReset:v,viewTransition:b,...j},M){let{basename:k}=m.useContext(Rn),N=typeof x=="string"&&Gx.test(x),w,S=!1;if(typeof x=="string"&&N&&(w=x,$x))try{let X=new URL(window.location.href),G=x.startsWith("//")?new URL(X.protocol+x):new URL(x),Q=es(G.pathname,k);G.origin===X.origin&&Q!=null?x=Q+G.search+G.hash:S=!0}catch{Sn(!1,`<Link to="${x}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let R=l1(x,{relative:u}),[E,A,L]=H1(o,j),V=K1(x,{replace:h,state:p,target:g,preventScrollReset:v,relative:u,viewTransition:b});function O(X){a&&a(X),X.defaultPrevented||V(X)}let z=m.createElement("a",{...j,...L,href:w||R,onClick:S||f?a:O,ref:F1(M,A),target:g,"data-discover":!N&&r==="render"?"true":void 0});return E&&!N?m.createElement(m.Fragment,null,z,m.createElement(V1,{page:R})):z});Fx.displayName="Link";var X1=m.forwardRef(function({"aria-current":a="page",caseSensitive:r=!1,className:o="",end:u=!1,style:f,to:h,viewTransition:p,children:g,...x},v){let b=vr(h,{relative:x.relative}),j=ta(),M=m.useContext(go),{navigator:k,basename:N}=m.useContext(Rn),w=M!=null&&eS(b)&&p===!0,S=k.encodeLocation?k.encodeLocation(b).pathname:b.pathname,R=j.pathname,E=M&&M.navigation&&M.navigation.location?M.navigation.location.pathname:null;r||(R=R.toLowerCase(),E=E?E.toLowerCase():null,S=S.toLowerCase()),E&&N&&(E=es(E,N)||E);const A=S!=="/"&&S.endsWith("/")?S.length-1:S.length;let L=R===S||!u&&R.startsWith(S)&&R.charAt(A)==="/",V=E!=null&&(E===S||!u&&E.startsWith(S)&&E.charAt(S.length)==="/"),O={isActive:L,isPending:V,isTransitioning:w},z=L?a:void 0,X;typeof o=="function"?X=o(O):X=[o,L?"active":null,V?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let G=typeof f=="function"?f(O):f;return m.createElement(Fx,{...x,"aria-current":z,className:X,ref:v,style:G,to:h,viewTransition:p},typeof g=="function"?g(O):g)});X1.displayName="NavLink";var Q1=m.forwardRef(({discover:n="render",fetcherKey:a,navigate:r,reloadDocument:o,replace:u,state:f,method:h=Zi,action:p,onSubmit:g,relative:x,preventScrollReset:v,viewTransition:b,...j},M)=>{let k=P1(),N=W1(p,{relative:x}),w=h.toLowerCase()==="get"?"get":"post",S=typeof p=="string"&&Gx.test(p),R=E=>{if(g&&g(E),E.defaultPrevented)return;E.preventDefault();let A=E.nativeEvent.submitter,L=A?.getAttribute("formmethod")||h;k(A||E.currentTarget,{fetcherKey:a,method:L,navigate:r,replace:u,state:f,relative:x,preventScrollReset:v,viewTransition:b})};return m.createElement("form",{ref:M,method:w,action:N,onSubmit:o?g:R,...j,"data-discover":!S&&n==="render"?"true":void 0})});Q1.displayName="Form";function I1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yx(n){let a=m.useContext(el);return ot(a,I1(n)),a}function K1(n,{target:a,replace:r,state:o,preventScrollReset:u,relative:f,viewTransition:h}={}){let p=r1(),g=ta(),x=vr(n,{relative:f});return m.useCallback(v=>{if(k1(v,a)){v.preventDefault();let b=r!==void 0?r:or(g)===or(x);p(n,{replace:b,state:o,preventScrollReset:u,relative:f,viewTransition:h})}},[g,p,x,r,o,a,n,u,f,h])}var Z1=0,J1=()=>`__${String(++Z1)}__`;function P1(){let{router:n}=Yx("useSubmit"),{basename:a}=m.useContext(Rn),r=g1();return m.useCallback(async(o,u={})=>{let{action:f,method:h,encType:p,formData:g,body:x}=R1(o,a);if(u.navigate===!1){let v=u.fetcherKey||J1();await n.fetch(v,r,u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||h,formEncType:u.encType||p,flushSync:u.flushSync})}else await n.navigate(u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||h,formEncType:u.encType||p,replace:u.replace,state:u.state,fromRouteId:r,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,a,r])}function W1(n,{relative:a}={}){let{basename:r}=m.useContext(Rn),o=m.useContext(ns);ot(o,"useFormAction must be used inside a RouteContext");let[u]=o.matches.slice(-1),f={...vr(n||".",{relative:a})},h=ta();if(n==null){f.search=h.search;let p=new URLSearchParams(f.search),g=p.getAll("index");if(g.some(v=>v==="")){p.delete("index"),g.filter(b=>b).forEach(b=>p.append("index",b));let v=p.toString();f.search=v?`?${v}`:""}}return(!n||n===".")&&u.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(f.pathname=f.pathname==="/"?r:Wn([r,f.pathname])),or(f)}function eS(n,{relative:a}={}){let r=m.useContext(Ox);ot(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Yx("useViewTransitionState"),u=vr(n,{relative:a});if(!r.isTransitioning)return!1;let f=es(r.currentLocation.pathname,o)||r.currentLocation.pathname,h=es(r.nextLocation.pathname,o)||r.nextLocation.pathname;return lo(u.pathname,h)!=null||lo(u.pathname,f)!=null}const Mn=Object.create(null);Mn.open="0";Mn.close="1";Mn.ping="2";Mn.pong="3";Mn.message="4";Mn.upgrade="5";Mn.noop="6";const Pi=Object.create(null);Object.keys(Mn).forEach(n=>{Pi[Mn[n]]=n});const bd={type:"error",data:"parser error"},Xx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Qx=typeof ArrayBuffer=="function",Ix=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Gd=({type:n,data:a},r,o)=>Xx&&a instanceof Blob?r?o(a):Tp(a,o):Qx&&(a instanceof ArrayBuffer||Ix(a))?r?o(a):Tp(new Blob([a]),o):o(Mn[n]+(a||"")),Tp=(n,a)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];a("b"+(o||""))},r.readAsDataURL(n)};function qp(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Ku;function tS(n,a){if(Xx&&n.data instanceof Blob)return n.data.arrayBuffer().then(qp).then(a);if(Qx&&(n.data instanceof ArrayBuffer||Ix(n.data)))return a(qp(n.data));Gd(n,!1,r=>{Ku||(Ku=new TextEncoder),a(Ku.encode(r))})}const Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Dp.length;n++)nr[Dp.charCodeAt(n)]=n;const nS=n=>{let a=n.length*.75,r=n.length,o,u=0,f,h,p,g;n[n.length-1]==="="&&(a--,n[n.length-2]==="="&&a--);const x=new ArrayBuffer(a),v=new Uint8Array(x);for(o=0;o<r;o+=4)f=nr[n.charCodeAt(o)],h=nr[n.charCodeAt(o+1)],p=nr[n.charCodeAt(o+2)],g=nr[n.charCodeAt(o+3)],v[u++]=f<<2|h>>4,v[u++]=(h&15)<<4|p>>2,v[u++]=(p&3)<<6|g&63;return x},sS=typeof ArrayBuffer=="function",Fd=(n,a)=>{if(typeof n!="string")return{type:"message",data:Kx(n,a)};const r=n.charAt(0);return r==="b"?{type:"message",data:aS(n.substring(1),a)}:Pi[r]?n.length>1?{type:Pi[r],data:n.substring(1)}:{type:Pi[r]}:bd},aS=(n,a)=>{if(sS){const r=nS(n);return Kx(r,a)}else return{base64:!0,data:n}},Kx=(n,a)=>{switch(a){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Zx="",lS=(n,a)=>{const r=n.length,o=new Array(r);let u=0;n.forEach((f,h)=>{Gd(f,!1,p=>{o[h]=p,++u===r&&a(o.join(Zx))})})},rS=(n,a)=>{const r=n.split(Zx),o=[];for(let u=0;u<r.length;u++){const f=Fd(r[u],a);if(o.push(f),f.type==="error")break}return o};function iS(){return new TransformStream({transform(n,a){tS(n,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const f=new DataView(u.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{u=new Uint8Array(9);const f=new DataView(u.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(u[0]|=128),a.enqueue(u),a.enqueue(r)})}})}let Zu;function Ui(n){return n.reduce((a,r)=>a+r.length,0)}function Hi(n,a){if(n[0].length===a)return n.shift();const r=new Uint8Array(a);let o=0;for(let u=0;u<a;u++)r[u]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function oS(n,a){Zu||(Zu=new TextDecoder);const r=[];let o=0,u=-1,f=!1;return new TransformStream({transform(h,p){for(r.push(h);;){if(o===0){if(Ui(r)<1)break;const g=Hi(r,1);f=(g[0]&128)===128,u=g[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Ui(r)<2)break;const g=Hi(r,2);u=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(Ui(r)<8)break;const g=Hi(r,8),x=new DataView(g.buffer,g.byteOffset,g.length),v=x.getUint32(0);if(v>Math.pow(2,21)-1){p.enqueue(bd);break}u=v*Math.pow(2,32)+x.getUint32(4),o=3}else{if(Ui(r)<u)break;const g=Hi(r,u);p.enqueue(Fd(f?g:Zu.decode(g),a)),o=0}if(u===0||u>n){p.enqueue(bd);break}}}})}const Jx=4;function bt(n){if(n)return cS(n)}function cS(n){for(var a in bt.prototype)n[a]=bt.prototype[a];return n}bt.prototype.on=bt.prototype.addEventListener=function(n,a){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(a),this};bt.prototype.once=function(n,a){function r(){this.off(n,r),a.apply(this,arguments)}return r.fn=a,this.on(n,r),this};bt.prototype.off=bt.prototype.removeListener=bt.prototype.removeAllListeners=bt.prototype.removeEventListener=function(n,a){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,u=0;u<r.length;u++)if(o=r[u],o===a||o.fn===a){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+n],this};bt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var a=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)a[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].apply(this,a)}return this};bt.prototype.emitReserved=bt.prototype.emit;bt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};bt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const bo=typeof Promise=="function"&&typeof Promise.resolve=="function"?a=>Promise.resolve().then(a):(a,r)=>r(a,0),hn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),uS="arraybuffer";function Px(n,...a){return a.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const dS=hn.setTimeout,fS=hn.clearTimeout;function yo(n,a){a.useNativeTimers?(n.setTimeoutFn=dS.bind(hn),n.clearTimeoutFn=fS.bind(hn)):(n.setTimeoutFn=hn.setTimeout.bind(hn),n.clearTimeoutFn=hn.clearTimeout.bind(hn))}const mS=1.33;function hS(n){return typeof n=="string"?pS(n):Math.ceil((n.byteLength||n.size)*mS)}function pS(n){let a=0,r=0;for(let o=0,u=n.length;o<u;o++)a=n.charCodeAt(o),a<128?r+=1:a<2048?r+=2:a<55296||a>=57344?r+=3:(o++,r+=4);return r}function Wx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function xS(n){let a="";for(let r in n)n.hasOwnProperty(r)&&(a.length&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return a}function gS(n){let a={},r=n.split("&");for(let o=0,u=r.length;o<u;o++){let f=r[o].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return a}class vS extends Error{constructor(a,r,o){super(a),this.description=r,this.context=o,this.type="TransportError"}}class Yd extends bt{constructor(a){super(),this.writable=!1,yo(this,a),this.opts=a,this.query=a.query,this.socket=a.socket,this.supportsBinary=!a.forceBase64}onError(a,r,o){return super.emitReserved("error",new vS(a,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(a){this.readyState==="open"&&this.write(a)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(a){const r=Fd(a,this.socket.binaryType);this.onPacket(r)}onPacket(a){super.emitReserved("packet",a)}onClose(a){this.readyState="closed",super.emitReserved("close",a)}pause(a){}createUri(a,r={}){return a+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const a=this.opts.hostname;return a.indexOf(":")===-1?a:"["+a+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(a){const r=xS(a);return r.length?"?"+r:""}}class bS extends Yd{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(a){this.readyState="pausing";const r=()=>{this.readyState="paused",a()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(a){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};rS(a,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const a=()=>{this.write([{type:"close"}])};this.readyState==="open"?a():this.once("open",a)}write(a){this.writable=!1,lS(a,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const a=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=Wx()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(a,r)}}let eg=!1;try{eg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const yS=eg;function SS(){}class jS extends bS{constructor(a){if(super(a),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&a.hostname!==location.hostname||o!==a.port}}doWrite(a,r){const o=this.request({method:"POST",data:a});o.on("success",r),o.on("error",(u,f)=>{this.onError("xhr post error",u,f)})}doPoll(){const a=this.request();a.on("data",this.onData.bind(this)),a.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=a}}class En extends bt{constructor(a,r,o){super(),this.createRequest=a,yo(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var a;const r=Px(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(a=this._opts.cookieJar)===null||a===void 0||a.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=En.requestsCount++,En.requests[this._index]=this)}_onError(a){this.emitReserved("error",a,this._xhr),this._cleanup(!0)}_cleanup(a){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=SS,a)try{this._xhr.abort()}catch{}typeof document<"u"&&delete En.requests[this._index],this._xhr=null}}_onLoad(){const a=this._xhr.responseText;a!==null&&(this.emitReserved("data",a),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}En.requestsCount=0;En.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",_p);else if(typeof addEventListener=="function"){const n="onpagehide"in hn?"pagehide":"unload";addEventListener(n,_p,!1)}}function _p(){for(let n in En.requests)En.requests.hasOwnProperty(n)&&En.requests[n].abort()}const NS=(function(){const n=tg({xdomain:!1});return n&&n.responseType!==null})();class wS extends jS{constructor(a){super(a);const r=a&&a.forceBase64;this.supportsBinary=NS&&!r}request(a={}){return Object.assign(a,{xd:this.xd},this.opts),new En(tg,this.uri(),a)}}function tg(n){const a=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!a||yS))return new XMLHttpRequest}catch{}if(!a)try{return new hn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ng=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class AS extends Yd{get name(){return"websocket"}doOpen(){const a=this.uri(),r=this.opts.protocols,o=ng?{}:Px(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(a,r,o)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=a=>this.onClose({description:"websocket connection closed",context:a}),this.ws.onmessage=a=>this.onData(a.data),this.ws.onerror=a=>this.onError("websocket error",a)}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;Gd(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}u&&bo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const a=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=Wx()),this.supportsBinary||(r.b64=1),this.createUri(a,r)}}const Ju=hn.WebSocket||hn.MozWebSocket;class CS extends AS{createSocket(a,r,o){return ng?new Ju(a,r,o):r?new Ju(a,r):new Ju(a)}doWrite(a,r){this.ws.send(r)}}class kS extends Yd{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(a){return this.emitReserved("error",a)}this._transport.closed.then(()=>{this.onClose()}).catch(a=>{this.onError("webtransport error",a)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(a=>{const r=oS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=a.readable.pipeThrough(r).getReader(),u=iS();u.readable.pipeTo(a.writable),this._writer=u.writable.getWriter();const f=()=>{o.read().then(({done:p,value:g})=>{p||(this.onPacket(g),f())}).catch(p=>{})};f();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;this._writer.write(o).then(()=>{u&&bo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var a;(a=this._transport)===null||a===void 0||a.close()}}const ES={websocket:CS,webtransport:kS,polling:wS},MS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,RS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function yd(n){if(n.length>8e3)throw"URI too long";const a=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let u=MS.exec(n||""),f={},h=14;for(;h--;)f[RS[h]]=u[h]||"";return r!=-1&&o!=-1&&(f.source=a,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=TS(f,f.path),f.queryKey=qS(f,f.query),f}function TS(n,a){const r=/\/{2,9}/g,o=a.replace(r,"/").split("/");return(a.slice(0,1)=="/"||a.length===0)&&o.splice(0,1),a.slice(-1)=="/"&&o.splice(o.length-1,1),o}function qS(n,a){const r={};return a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,f){u&&(r[u]=f)}),r}const Sd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Wi=[];Sd&&addEventListener("offline",()=>{Wi.forEach(n=>n())},!1);class Es extends bt{constructor(a,r){if(super(),this.binaryType=uS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,a&&typeof a=="object"&&(r=a,a=null),a){const o=yd(a);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=yd(r.host).host);yo(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{const u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=gS(this.opts.query)),Sd&&(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"})},Wi.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(a){const r=Object.assign({},this.opts.query);r.EIO=Jx,r.transport=a,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[a]);return new this._transportsByName[a](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const a=this.opts.rememberUpgrade&&Es.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(a);r.open(),this.setTransport(r)}setTransport(a){this.transport&&this.transport.removeAllListeners(),this.transport=a,a.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Es.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(a){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",a),this.emitReserved("heartbeat"),a.type){case"open":this.onHandshake(JSON.parse(a.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=a.data,this._onError(r);break;case"message":this.emitReserved("data",a.data),this.emitReserved("message",a.data);break}}onHandshake(a){this.emitReserved("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this._pingInterval=a.pingInterval,this._pingTimeout=a.pingTimeout,this._maxPayload=a.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const a=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+a,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},a),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 a=this._getWritablePackets();this.transport.send(a),this._prevBufferLen=a.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=hS(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const a=Date.now()>this._pingTimeoutTime;return a&&(this._pingTimeoutTime=0,bo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),a}write(a,r,o){return this._sendPacket("message",a,r,o),this}send(a,r,o){return this._sendPacket("message",a,r,o),this}_sendPacket(a,r,o,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:a,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),u&&this.once("flush",u),this.flush()}close(){const a=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),a()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():a()}):this.upgrading?o():a()),this}_onError(a){if(Es.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",a),this._onClose("transport error",a)}_onClose(a,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Sd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Wi.indexOf(this._offlineEventListener);o!==-1&&Wi.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",a,r),this.writeBuffer=[],this._prevBufferLen=0}}}Es.protocol=Jx;class DS extends Es{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let a=0;a<this._upgrades.length;a++)this._probe(this._upgrades[a])}_probe(a){let r=this.createTransport(a),o=!1;Es.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Es.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const j=new Error("probe error");j.transport=r.name,this.emitReserved("upgradeError",j)}}))};function f(){o||(o=!0,v(),r.close(),r=null)}const h=b=>{const j=new Error("probe error: "+b);j.transport=r.name,f(),this.emitReserved("upgradeError",j)};function p(){h("transport closed")}function g(){h("socket closed")}function x(b){r&&b.name!==r.name&&f()}const v=()=>{r.removeListener("open",u),r.removeListener("error",h),r.removeListener("close",p),this.off("close",g),this.off("upgrading",x)};r.once("open",u),r.once("error",h),r.once("close",p),this.once("close",g),this.once("upgrading",x),this._upgrades.indexOf("webtransport")!==-1&&a!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(a){this._upgrades=this._filterUpgrades(a.upgrades),super.onHandshake(a)}_filterUpgrades(a){const r=[];for(let o=0;o<a.length;o++)~this.transports.indexOf(a[o])&&r.push(a[o]);return r}}let _S=class extends DS{constructor(a,r={}){const o=typeof a=="object"?a:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>ES[u]).filter(u=>!!u)),super(a,o)}};function OS(n,a="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=yd(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+a,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const BS=typeof ArrayBuffer=="function",LS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,sg=Object.prototype.toString,zS=typeof Blob=="function"||typeof Blob<"u"&&sg.call(Blob)==="[object BlobConstructor]",US=typeof File=="function"||typeof File<"u"&&sg.call(File)==="[object FileConstructor]";function Xd(n){return BS&&(n instanceof ArrayBuffer||LS(n))||zS&&n instanceof Blob||US&&n instanceof File}function eo(n,a){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(eo(n[r]))return!0;return!1}if(Xd(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return eo(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&eo(n[r]))return!0;return!1}function HS(n){const a=[],r=n.data,o=n;return o.data=jd(r,a),o.attachments=a.length,{packet:o,buffers:a}}function jd(n,a){if(!n)return n;if(Xd(n)){const r={_placeholder:!0,num:a.length};return a.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=jd(n[o],a);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=jd(n[o],a));return r}return n}function VS(n,a){return n.data=Nd(n.data,a),delete n.attachments,n}function Nd(n,a){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<a.length)return a[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Nd(n[r],a);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Nd(n[r],a));return n}const $S=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],GS=5;var Fe;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Fe||(Fe={}));class FS{constructor(a){this.replacer=a}encode(a){return(a.type===Fe.EVENT||a.type===Fe.ACK)&&eo(a)?this.encodeAsBinary({type:a.type===Fe.EVENT?Fe.BINARY_EVENT:Fe.BINARY_ACK,nsp:a.nsp,data:a.data,id:a.id}):[this.encodeAsString(a)]}encodeAsString(a){let r=""+a.type;return(a.type===Fe.BINARY_EVENT||a.type===Fe.BINARY_ACK)&&(r+=a.attachments+"-"),a.nsp&&a.nsp!=="/"&&(r+=a.nsp+","),a.id!=null&&(r+=a.id),a.data!=null&&(r+=JSON.stringify(a.data,this.replacer)),r}encodeAsBinary(a){const r=HS(a),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function Op(n){return Object.prototype.toString.call(n)==="[object Object]"}class Qd extends bt{constructor(a){super(),this.reviver=a}add(a){let r;if(typeof a=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(a);const o=r.type===Fe.BINARY_EVENT;o||r.type===Fe.BINARY_ACK?(r.type=o?Fe.EVENT:Fe.ACK,this.reconstructor=new YS(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Xd(a)||a.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(a),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+a)}decodeString(a){let r=0;const o={type:Number(a.charAt(0))};if(Fe[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Fe.BINARY_EVENT||o.type===Fe.BINARY_ACK){const f=r+1;for(;a.charAt(++r)!=="-"&&r!=a.length;);const h=a.substring(f,r);if(h!=Number(h)||a.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(a.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(a.charAt(r)===","||r===a.length););o.nsp=a.substring(f,r)}else o.nsp="/";const u=a.charAt(r+1);if(u!==""&&Number(u)==u){const f=r+1;for(;++r;){const h=a.charAt(r);if(h==null||Number(h)!=h){--r;break}if(r===a.length)break}o.id=Number(a.substring(f,r+1))}if(a.charAt(++r)){const f=this.tryParse(a.substr(r));if(Qd.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(a){try{return JSON.parse(a,this.reviver)}catch{return!1}}static isPayloadValid(a,r){switch(a){case Fe.CONNECT:return Op(r);case Fe.DISCONNECT:return r===void 0;case Fe.CONNECT_ERROR:return typeof r=="string"||Op(r);case Fe.EVENT:case Fe.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&$S.indexOf(r[0])===-1);case Fe.ACK:case Fe.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class YS{constructor(a){this.packet=a,this.buffers=[],this.reconPack=a}takeBinaryData(a){if(this.buffers.push(a),this.buffers.length===this.reconPack.attachments){const r=VS(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const XS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Qd,Encoder:FS,get PacketType(){return Fe},protocol:GS},Symbol.toStringTag,{value:"Module"}));function yn(n,a,r){return n.on(a,r),function(){n.off(a,r)}}const QS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ag extends bt{constructor(a,r,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=a,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const a=this.io;this.subs=[yn(a,"open",this.onopen.bind(this)),yn(a,"packet",this.onpacket.bind(this)),yn(a,"error",this.onerror.bind(this)),yn(a,"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(...a){return a.unshift("message"),this.emit.apply(this,a),this}emit(a,...r){var o,u,f;if(QS.hasOwnProperty(a))throw new Error('"'+a.toString()+'" is a reserved event name');if(r.unshift(a),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const h={type:Fe.EVENT,data:r};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const v=this.ids++,b=r.pop();this._registerAckCallback(v,b),h.id=v}const p=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!p||(g?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(a,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[a]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[a];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===a&&this.sendBuffer.splice(p,1);r.call(this,new Error("operation has timed out"))},u),h=(...p)=>{this.io.clearTimeoutFn(f),r.apply(this,p)};h.withError=!0,this.acks[a]=h}emitWithAck(a,...r){return new Promise((o,u)=>{const f=(h,p)=>h?u(h):o(p);f.withError=!0,r.push(f),this.emit(a,...r)})}_addToQueue(a){let r;typeof a[a.length-1]=="function"&&(r=a.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:a,flags:Object.assign({fromQueue:!0},this.flags)};a.push((u,...f)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(a=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!a||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(a){a.nsp=this.nsp,this.io._packet(a)}onopen(){typeof this.auth=="function"?this.auth(a=>{this._sendConnectPacket(a)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(a){this.packet({type:Fe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},a):a})}onerror(a){this.connected||this.emitReserved("connect_error",a)}onclose(a,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",a,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(a=>{if(!this.sendBuffer.some(o=>String(o.id)===a)){const o=this.acks[a];delete this.acks[a],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(a){if(a.nsp===this.nsp)switch(a.type){case Fe.CONNECT:a.data&&a.data.sid?this.onconnect(a.data.sid,a.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 Fe.EVENT:case Fe.BINARY_EVENT:this.onevent(a);break;case Fe.ACK:case Fe.BINARY_ACK:this.onack(a);break;case Fe.DISCONNECT:this.ondisconnect();break;case Fe.CONNECT_ERROR:this.destroy();const o=new Error(a.data.message);o.data=a.data.data,this.emitReserved("connect_error",o);break}}onevent(a){const r=a.data||[];a.id!=null&&r.push(this.ack(a.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(a){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,a)}super.emit.apply(this,a),this._pid&&a.length&&typeof a[a.length-1]=="string"&&(this._lastOffset=a[a.length-1])}ack(a){const r=this;let o=!1;return function(...u){o||(o=!0,r.packet({type:Fe.ACK,id:a,data:u}))}}onack(a){const r=this.acks[a.id];typeof r=="function"&&(delete this.acks[a.id],r.withError&&a.data.unshift(null),r.apply(this,a.data))}onconnect(a,r){this.id=a,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(a=>this.emitEvent(a)),this.receiveBuffer=[],this.sendBuffer.forEach(a=>{this.notifyOutgoingListeners(a),this.packet(a)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(a=>a()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Fe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(a){return this.flags.compress=a,this}get volatile(){return this.flags.volatile=!0,this}timeout(a){return this.flags.timeout=a,this}onAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(a),this}prependAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(a),this}offAny(a){if(!this._anyListeners)return this;if(a){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(a),this}prependAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(a),this}offAnyOutgoing(a){if(!this._anyOutgoingListeners)return this;if(a){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(a){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,a.data)}}}function tl(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}tl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var a=Math.random(),r=Math.floor(a*this.jitter*n);n=(Math.floor(a*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};tl.prototype.reset=function(){this.attempts=0};tl.prototype.setMin=function(n){this.ms=n};tl.prototype.setMax=function(n){this.max=n};tl.prototype.setJitter=function(n){this.jitter=n};class wd extends bt{constructor(a,r){var o;super(),this.nsps={},this.subs=[],a&&typeof a=="object"&&(r=a,a=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,yo(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new tl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=a;const u=r.parser||XS;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(a){return arguments.length?(this._reconnection=!!a,a||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(a){return a===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=a,this)}reconnectionDelay(a){var r;return a===void 0?this._reconnectionDelay:(this._reconnectionDelay=a,(r=this.backoff)===null||r===void 0||r.setMin(a),this)}randomizationFactor(a){var r;return a===void 0?this._randomizationFactor:(this._randomizationFactor=a,(r=this.backoff)===null||r===void 0||r.setJitter(a),this)}reconnectionDelayMax(a){var r;return a===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=a,(r=this.backoff)===null||r===void 0||r.setMax(a),this)}timeout(a){return arguments.length?(this._timeout=a,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(a){if(~this._readyState.indexOf("open"))return this;this.engine=new _S(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=yn(r,"open",function(){o.onopen(),a&&a()}),f=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),a?a(p):this.maybeReconnectOnOpen()},h=yn(r,"error",f);if(this._timeout!==!1){const p=this._timeout,g=this.setTimeoutFn(()=>{u(),f(new Error("timeout")),r.close()},p);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(u),this.subs.push(h),this}connect(a){return this.open(a)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const a=this.engine;this.subs.push(yn(a,"ping",this.onping.bind(this)),yn(a,"data",this.ondata.bind(this)),yn(a,"error",this.onerror.bind(this)),yn(a,"close",this.onclose.bind(this)),yn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(a){try{this.decoder.add(a)}catch(r){this.onclose("parse error",r)}}ondecoded(a){bo(()=>{this.emitReserved("packet",a)},this.setTimeoutFn)}onerror(a){this.emitReserved("error",a)}socket(a,r){let o=this.nsps[a];return o?this._autoConnect&&!o.active&&o.connect():(o=new ag(this,a,r),this.nsps[a]=o),o}_destroy(a){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(a){const r=this.encoder.encode(a);for(let o=0;o<r.length;o++)this.engine.write(r[o],a.options)}cleanup(){this.subs.forEach(a=>a()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(a,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",a,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const a=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{a.skipReconnect||(this.emitReserved("reconnect_attempt",a.backoff.attempts),!a.skipReconnect&&a.open(u=>{u?(a._reconnecting=!1,a.reconnect(),this.emitReserved("reconnect_error",u)):a.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const a=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",a)}}const Jl={};function to(n,a){typeof n=="object"&&(a=n,n=void 0),a=a||{};const r=OS(n,a.path||"/socket.io"),o=r.source,u=r.id,f=r.path,h=Jl[u]&&f in Jl[u].nsps,p=a.forceNew||a["force new connection"]||a.multiplex===!1||h;let g;return p?g=new wd(o,a):(Jl[u]||(Jl[u]=new wd(o,a)),g=Jl[u]),r.query&&!a.query&&(a.query=r.queryKey),g.socket(r.path,a)}Object.assign(to,{Manager:wd,Socket:ag,io:to,connect:to});const lg="roverSettings",IS=3600*24*365;function KS(n){try{const a=decodeURIComponent(n??"");return JSON.parse(a)}catch(a){return console.warn("Failed to parse settings cookie",a),null}}function Ad(){if(typeof document>"u")return{};const n=`${lg}=`,a=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!a)return{};const r=a.substring(n.length);return KS(r)??{}}function Bp(n){if(typeof document>"u")return!1;try{const a=encodeURIComponent(JSON.stringify(n??{})),r=`${lg}=${a}; path=/; max-age=${IS}; samesite=strict`;return document.cookie=r,!0}catch(a){return console.warn("Failed to write settings cookie",a),!1}}const rg=window.location.origin;console.info("[socket] connecting to",rg);const ZS=Ad(),JS=ZS?.page?.connectionTransport||"websocket",PS=JS==="polling"?["polling"]:["websocket","polling"],Id=to(rg,{transports:PS,timeout:15e3});Id.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const ig=m.createContext(Id),WS=({children:n})=>l.jsx(ig.Provider,{value:Id,children:n}),en=()=>m.useContext(ig),ej={connected:!1,session:null,neatoLidar:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,overseerControlState:null,alerts:[]},Kd=m.createContext(null);function tj(n){return m.useCallback((a,r={})=>new Promise((o,u)=>{n.emit(a,r,(f={})=>{f.error?u(new Error(f.error)):o(f)})}),[n])}function nj(n){return typeof n=="function"?n:a=>a}function sj({children:n}){const a=en(),r=tj(a),o=m.useRef({...ej,connected:a.connected}),u=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),h=m.useCallback(v=>{const b=o.current,j=typeof v=="function"?v(b):{...b,...v||{}};j!==b&&(o.current=j,u.current.forEach(M=>{const k=M.selector(j);M.equalityFn(M.current,k)||(M.current=k,M.listener(k))}))},[]),p=m.useCallback((v,b,j=Object.is)=>{const M=nj(v),k={selector:M,equalityFn:j,listener:b,current:M(o.current)};return u.current.add(k),()=>{u.current.delete(k)}},[]);m.useEffect(()=>{const v=()=>{h(j=>j.connected?j:{...j,connected:!0})},b=()=>{h(j=>j.connected?{...j,connected:!1}:j)};return a.on("connect",v),a.on("disconnect",b),()=>{a.off("connect",v),a.off("disconnect",b)}},[h,a]),m.useEffect(()=>{function v(E){h(A=>({...A,session:E}))}function b(E=[]){h(A=>({...A,logs:E}))}function j(E){h(A=>({...A,logs:[...A.logs.slice(-199),E]}))}function M(E=[]){h(A=>({...A,adminLogs:E}))}function k(E){h(A=>({...A,adminLogs:[...A.adminLogs.slice(-199),E]}))}function N(E=null){const A=E&&typeof E=="object"?E:null,L=A?.debug?.status&&typeof A.debug.status=="object"?A.debug.status:null;h(V=>({...V,llmCommentaryState:A,llmCommentaryStatus:L}))}function w(E={}){h(A=>({...A,alerts:[...A.alerts.slice(-49),{...E,receivedAt:Date.now()}]}))}function S(E=null){const A=E&&typeof E=="object"?E:null;h(L=>({...L,overseerControlState:A}))}function R(E=null){const A=E&&typeof E=="object"?E:null;h(L=>({...L,neatoLidar:A}))}return a.on("session:sync",v),a.on("neato:lidar",R),a.on("log:init",b),a.on("log:entry",j),a.on("adminlog:init",M),a.on("adminlog:entry",k),a.on("llm:state",N),a.on("overseer:state",S),a.on("alert:new",w),()=>{a.off("session:sync",v),a.off("neato:lidar",R),a.off("log:init",b),a.off("log:entry",j),a.off("adminlog:init",M),a.off("adminlog:entry",k),a.off("llm:state",N),a.off("overseer:state",S),a.off("alert:new",w)}},[h,a]);const g=m.useMemo(()=>({login:(v,b)=>r("auth:login",{username:v,password:b}),identifySession:({cookieUserId:v,nickname:b}={})=>r("session:identify",{cookieUserId:v,nickname:b}),setRole:v=>r("session:setRole",{role:v}),requestControl:(v,b={})=>r("session:requestControl",{roverId:v,...b}),releaseControl:v=>r("session:releaseControl",{roverId:v}),subscribeAll:()=>r("session:subscribeAll"),lockRover:(v,b)=>r("session:lockRover",{roverId:v,locked:b}),setMode:v=>r("setMode",{mode:v}),homeAssistantToggle:v=>r("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,b)=>r("homeAssistant:setState",{entityId:v,state:b}),homeAssistantSetLightColor:(v,b)=>r("homeAssistant:lightColor",{entityId:v,rgbColor:b}),homeAssistantSetLightWhite:v=>r("homeAssistant:lightWhite",{entityId:v}),neatoStart:()=>r("neato:start"),neatoSendHome:()=>r("neato:sendHome"),neatoLocate:()=>r("neato:locate"),neatoClearErrors:()=>r("neato:clearErrors"),neatoPowerCycle:()=>r("neato:powerCycle"),liftUp:()=>r("lift:up"),liftDown:()=>r("lift:down"),setNickname:v=>r("nickname:set",{nickname:v}),requestVerification:()=>r("verification:request"),requestPrivateRoverAccess:v=>r("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[],b="")=>v&&typeof v=="object"&&!Array.isArray(v)?r("replay:trigger",v):r("replay:trigger",{sources:v,title:b}),setGlobalObjective:v=>r("globalObjective:set",{text:v}),setAdminReason:v=>r("adminReason:set",{text:v}),rebootRover:v=>r("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>r("server:reboot"),playUploadedAudio:({roverId:v,name:b,mime:j,dataBase64:M})=>r("audio:uploadPlay",{roverId:v,name:b,mime:j,dataBase64:M}),stopUploadedAudio:v=>r("audio:uploadStop",{roverId:v}),startMicWhip:v=>r("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>r("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>r("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>r("audioLevels:set",v),setPrivateSafety:(v,b={})=>r("session:privateSafety:set",{roverId:v,safety:b}),llmControl:(v,b={})=>r("llm:control",{controls:{action:v,...b}}),overseerControl:(v,b={})=>r("overseer:control",{controls:{action:v,...b}}),pushAlert:v=>h(b=>({...b,alerts:[...b.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[r,h]),x=m.useMemo(()=>({getState:f,subscribe:p,actions:g}),[g,f,p]);return l.jsx(Kd.Provider,{value:x,children:n})}function de(n,a=Object.is){const r=m.useContext(Kd);if(!r)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const u=m.useRef(a);u.current=a;const[f,h]=m.useState(()=>n(r.getState()));return m.useEffect(()=>(h(p=>{const g=o.current(r.getState());return u.current(p,g)?p:g}),r.subscribe(p=>o.current(p),p=>{h(g=>u.current(g,p)?g:p)},(p,g)=>u.current(p,g))),[r]),f}function Gt(){const n=m.useContext(Kd);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function br(){const n=de(r=>r),a=Gt();return m.useMemo(()=>({...n,...a}),[a,n])}const aj=Object.freeze({}),Cd=null,Zd=m.createContext(null);function lj({children:n}){const a=en(),r=m.useRef({}),o=m.useRef(new Map),u=m.useRef(new Set),f=p=>{const g=o.current.get(p);g&&g.forEach(x=>x()),u.current.forEach(x=>x())},h=m.useMemo(()=>({getFrames:()=>r.current,getFrame:p=>p?r.current[p]??Cd:Cd,subscribeAll:p=>(u.current.add(p),()=>{u.current.delete(p)}),subscribeRover:(p,g)=>{if(!p)return()=>{};let x=o.current.get(p);return x||(x=new Set,o.current.set(p,x)),x.add(g),()=>{const v=o.current.get(p);v&&(v.delete(g),v.size||o.current.delete(p))}}}),[]);return m.useEffect(()=>{function p({roverId:g,sensors:x={},frame:v={}}){g&&(r.current={...r.current,[g]:{roverId:g,sensors:x,raw:v?.data||null,receivedAt:Date.now()}},f(g))}return a.on("sensorFrame",p),()=>{a.off("sensorFrame",p)}},[a]),l.jsx(Zd.Provider,{value:h,children:n})}function rj(){const n=m.useContext(Zd);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>aj)}function pn(n){const a=m.useContext(Zd);if(!a)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(r=>a.subscribeRover(n,r),()=>a.getFrame(n),()=>Cd)}const ij=650,oj={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 Pu(n){if(typeof n!="number"||n<=0)return null;const a=oj[n];return a?{code:n,...a}:null}function cj(n,a={}){const r=a.holdMs||ij,[o,u]=m.useState({left:null,right:null,omni:null}),[f,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(r/2,100));return()=>clearInterval(p)},[r]),m.useEffect(()=>{const p=Date.now(),g=Pu(n?.infraredCharacterLeft),x=Pu(n?.infraredCharacterRight),v=Pu(n?.infraredCharacterOmni);!g&&!x&&!v||u(b=>({left:g?{...g,ts:p}:b.left,right:x?{...x,ts:p}:b.right,omni:v?{...v,ts:p}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const p=Date.now(),g=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const S=p-w.ts,R=S<=r;return{active:R,age:S,code:w.code,red:!!(w.red&&R),green:!!(w.green&&R),force:!!(w.force&&R)}},x=g(o.left),v=g(o.right),b=g(o.omni),j=x.force||v.force||b.force,M=x.active||v.active||b.active,k=x.active&&!v.active?"right":v.active&&!x.active?"left":"center",N=(v.active?1:0)-(x.active?1:0);return{visible:M,forceDetected:j,left:x,right:v,omni:b,bias:k,balance:Math.max(-1,Math.min(1,N))}},[o.left,o.right,o.omni,r,f])}function uj(){de(M=>M.connected);const n=de(M=>M.session?.assignment?.roverId??null),a=de(M=>{const k=M.session?.assignment?.roverId;return k&&M.session?.activeDrivers?.[k]||null}),r=de(M=>M.session?.socketId||null),o=de(M=>M.session?.users??[]),u=pn(n),f=u?.sensors||{},h=cj(f),p=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,g=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,v=f.batteryChargeMah,b=f.batteryCapacityMah;u?.receivedAt&&new Date(u.receivedAt).toLocaleTimeString();const j=u?.raw?u.raw:null;return m.useMemo(()=>n?a?a===r?"You":o.find(k=>k.socketId===a)?.nickname||a.slice(0,6):"Available":"n/a",[a,n,r,o]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[n?u?l.jsxs(l.Fragment,{children:[l.jsx(dj,{sensors:f,voltage:p,current:g,batteryTemp:x,charge:v,capacity:b}),l.jsx(fj,{sensors:f,dockState:h})]}):l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):l.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),j&&l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:j})]})}function dj({sensors:n,voltage:a,current:r,batteryTemp:o,charge:u,capacity:f}){const h=u!=null&&f?`${Math.round(u/f*100)}`:"--",p=n?.oiMode?.label||"--",g=n?.chargingSources?.homeBase?"Yes":"No",x=n?.chargingState?.label||"--";return l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[l.jsx(Kn,{label:"Voltage",value:a??"--"}),l.jsx(Kn,{label:"Current",value:r??"--"}),l.jsx(Kn,{label:"Battery temp",value:o??"--"}),l.jsx(Kn,{label:"Charge",value:u!=null?`${u} mAh`:"--"}),l.jsx(Kn,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),l.jsx(Kn,{label:"Charge",value:h}),l.jsx(Kn,{label:"OI mode",value:p}),l.jsx(Kn,{label:"Docked",value:g}),l.jsx(Kn,{label:"Charging state",value:x})]})}function Kn({label:n,value:a}){return l.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[l.jsx("span",{className:"text-slate-400",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function fj({sensors:n,dockState:a}){const r=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},u=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],f=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],h=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs(Va,{title:"Dock IR",children:[l.jsx(mj,{sensors:n}),l.jsx(hj,{state:a})]}),l.jsxs(Va,{title:"Bumps & drops",children:[l.jsx(Zn,{label:"Bump L",value:l.jsx(Pl,{active:r.bumpLeft})}),l.jsx(Zn,{label:"Bump R",value:l.jsx(Pl,{active:r.bumpRight})}),l.jsx(Zn,{label:"Wheel drop L",value:l.jsx(Pl,{active:r.wheelDropLeft,tone:"amber"})}),l.jsx(Zn,{label:"Wheel drop R",value:l.jsx(Pl,{active:r.wheelDropRight,tone:"amber"})})]}),l.jsx(Va,{title:"Light bumps (raw)",children:u.map(p=>l.jsx(Zn,{label:p.label,value:Wl(p.value)},p.label))}),l.jsx(Va,{title:"Cliff sensors",children:f.map(p=>l.jsx(Zn,{label:p.label,value:`${Wl(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),l.jsx(Va,{title:"Currents",children:h.map(p=>l.jsx(Zn,{label:p.label,value:l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:Wl(p.value,"mA")}),p.over?l.jsx(Pl,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),l.jsxs(Va,{title:"Dirt detect",children:[l.jsx(Zn,{label:"Left",value:Wl(n?.dirtDetectLeft)}),l.jsx(Zn,{label:"Right",value:Wl(n?.dirtDetect)})]})]})}function Va({title:n,children:a}){return l.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[l.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),l.jsx("div",{className:"space-y-0.5",children:a})]})}function Zn({label:n,value:a}){return l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-300",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function Pl({active:n,tone:a="green",label:r}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",u=a==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":a==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return l.jsx("span",{className:`${o} ${u}`,children:r||(n?"true":"false")})}function Wl(n,a){return n==null||Number.isNaN(n)?"--":a?`${n} ${a}`:n}function mj({sensors:n}){const a=n?.infraredCharacterLeft,r=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,u=f=>l.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${f?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:f||"--"});return l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"L"}),u(a)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"O"}),u(o)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"R"}),u(r)]})]})}function hj({state:n}){if(!n)return null;const a=o=>{const u=[];return o?.red&&u.push("R"),o?.green&&u.push("G"),o?.force&&u.push("F"),u.length?u.join(""):"none"},r=o=>o?.age!=null?`${o.age}ms`:"--";return l.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Left: ${n.left.code??"--"} (${a(n.left)}) · age ${r(n.left)}`}),l.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${a(n.omni)}) · age ${r(n.omni)}`}),l.jsx("div",{children:`Right: ${n.right.code??"--"} (${a(n.right)}) · age ${r(n.right)}`})]})}const og=m.createContext(null);function pj({children:n}){const[a,r]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=Ad();r({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=Ad();r({status:"ready",data:p??{}})},[]),u=m.useCallback(p=>{const g=Bp(p??{});return r(g?{status:"ready",data:p??{}}:x=>({...x,status:"error"})),g},[]),f=m.useCallback((p,g)=>{r(x=>{const v=x.data[p]||{},b=typeof g=="function"?g(v):{...v,...g??{}},j={...x.data,[p]:b};return Bp(j)?{status:"ready",data:j}:{...x,status:"error"}})},[]),h=m.useMemo(()=>({data:a.data,status:a.status,reload:o,saveAll:u,setNamespace:f}),[a,o,u,f]);return l.jsx(og.Provider,{value:h,children:n})}function xj(){const n=m.useContext(og);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Qe(n,a={}){const{data:r,status:o,setNamespace:u}=xj(),f=r[n]??a??{},h=m.useCallback(x=>{u(n,v=>{const b=v??{};return typeof x=="function"?x(b):{...b,...x??{}}})},[n,u]),p=m.useCallback(x=>{u(n,()=>x??{})},[n,u]),g=m.useCallback(()=>{const x=typeof a=="object"?{...a}:a;u(n,()=>x??{})},[a,n,u]);return{value:f,status:o,save:h,replace:p,reset:g}}const gj=/^#[0-9A-Fa-f]{6}$/;function Jd(n){const a=typeof n=="string"?n.trim():"";return!a||!gj.test(a)?null:a.toUpperCase()}function ts(n,a=.2){const r=Jd(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=cg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.65)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function vj(n,a=.2){const r=Jd(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=cg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.55)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function cg(n){const a=Jd(n);return a?{r:parseInt(a.slice(1,3),16),g:parseInt(a.slice(3,5),16),b:parseInt(a.slice(5,7),16)}:null}function bj(n=[]){return n.map(a=>!a?.type||!a?.id?null:{type:a.type,id:String(a.id),label:a.label||String(a.id),color:a.color||null,key:`${a.type}:${a.id}`}).filter(Boolean)}function Pd({panelId:n="replay-sources",fillHeight:a=!1}){const r=de(T=>T.session?.replaySources??[]),o=de(T=>T.session?.mode||null),u=de(T=>T.session?.assignment?.roverId??null),f=de(T=>T.session?.users??[]),h=de(T=>T.session?.socketId||null),p=de(T=>T.session?.roster??[]),g=de(T=>T.session?.replay||null),{triggerReplay:x}=Gt(),v=bj(r||[]),{value:b,save:j}=Qe("replaySources",{}),[M,k]=m.useState([]),[N,w]=m.useState(!1),[S,R]=m.useState(null),[E,A]=m.useState(null),[L,V]=m.useState(""),[O,z]=m.useState(!1),[X,G]=m.useState(!0),[Q,P]=m.useState(0),oe=m.useMemo(()=>{const T=u;return T?[`rover:${T}`]:[]},[u]),ie=m.useMemo(()=>{const _=((Array.isArray(f)?f.find(me=>me?.socketId===h):null)?.nickname||"Someone").trim()||"Someone",K=u||null,ne=K&&Array.isArray(p)?p.find(me=>String(me?.id)===String(K))?.name||K:"a rover";return`${_} driving ${ne}`},[f,h,u,p]);m.useEffect(()=>{const T=b?.[n];if(Array.isArray(T)&&T.length){k(T);return}k(oe)},[b?.[n],oe,n]),m.useEffect(()=>{const T=b?.[`${n}:includeSidebar`];if(typeof T=="boolean"){G(T);return}G(!0)},[b?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{O||V(ie)},[ie,O]),m.useEffect(()=>{const T=new Set(v.map(_=>_.key));k(_=>_.filter(K=>T.has(K)))},[v]);const $=m.useMemo(()=>({rovers:v.filter(T=>T.type==="rover"),rooms:v.filter(T=>T.type==="room")}),[v]);m.useEffect(()=>{if(!g?.lastTriggeredAt||!g?.cooldownMs){P(0);return}const T=()=>{const K=g.lastTriggeredAt+g.cooldownMs-Date.now();P(Math.max(0,K))};T();const _=setInterval(T,250);return()=>clearInterval(_)},[g?.lastTriggeredAt,g?.cooldownMs,g?.remainingMs]);const q=N||o==="lockdown"||Q>0||!M.length,H=T=>{k(_=>{const K=_.includes(T)?_.filter(ne=>ne!==T):[..._,T];return j(ne=>({...ne||{},[n]:K})),K}),A(null)},J=async()=>{if(!q){w(!0),R(null),A(null);try{const T=M.map(K=>{const[ne,me]=K.split(":");return{type:ne,id:me}}),_=String(L||"").trim()||ie;await x({sources:T,title:_,includeSidebar:X}),A("Replay sent. Check the Discord replay channel.")}catch(T){R(T.message)}finally{w(!1)}}},ee=a?"h-full flex flex-col":"",ue=a?"flex-1 min-h-0 overflow-y-auto":"";return l.jsxs("section",{className:`panel-section p-0.75 text-sm ${ee}`,children:[l.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[l.jsx("span",{children:"Replay Sources"}),l.jsx("span",{children:v.length})]}),l.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${ue}`,children:[l.jsx(Lp,{title:"Rovers",items:$.rovers,selected:M,onToggle:H}),l.jsx(Lp,{title:"Room Cams",items:$.rooms,selected:M,onToggle:H})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),l.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:L,onChange:T=>{V(T.target.value),z(!0)},placeholder:ie,maxLength:120}),l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:X,onChange:T=>{const _=!!T.target.checked;G(_),j(K=>({...K||{},[`${n}:includeSidebar`]:_}))},className:"accent-emerald-400"}),l.jsx("span",{children:"Include replay sidebar"})]}),l.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:J,disabled:q,children:Q>0?`Replay (${Math.ceil(Q/1e3)}s)`:N?"Replay…":"Replay"}),S?l.jsx("div",{className:"text-xs text-amber-400",children:S}):null,E?l.jsx("div",{className:"text-xs text-emerald-300",children:E}):null]})]})}function Lp({title:n,items:a,selected:r,onToggle:o}){return a.length?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs",children:n}),l.jsx("div",{className:"space-y-0.5",children:a.map(u=>l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:r.includes(u.key),onChange:()=>o(u.key),className:"accent-emerald-400"}),l.jsx("span",{className:`truncate ${u.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:u.type==="rover"?ts(u.color,.16):void 0,children:u.label})]},u.key))})]}):null}var ug={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},zp=Ot.createContext&&Ot.createContext(ug),yj=["attr","size","title"];function Sj(n,a){if(n==null)return{};var r=jj(n,a),o,u;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(u=0;u<f.length;u++)o=f[u],!(a.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(r[o]=n[o])}return r}function jj(n,a){if(n==null)return{};var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(a.indexOf(o)>=0)continue;r[o]=n[o]}return r}function ro(){return ro=Object.assign?Object.assign.bind():function(n){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}return n},ro.apply(this,arguments)}function Up(n,a){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);a&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(n,u).enumerable})),r.push.apply(r,o)}return r}function io(n){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?Up(Object(r),!0).forEach(function(o){Nj(n,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Up(Object(r)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(r,o))})}return n}function Nj(n,a,r){return a=wj(a),a in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r,n}function wj(n){var a=Aj(n,"string");return typeof a=="symbol"?a:a+""}function Aj(n,a){if(typeof n!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var o=r.call(n,a);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function dg(n){return n&&n.map((a,r)=>Ot.createElement(a.tag,io({key:r},a.attr),dg(a.child)))}function yr(n){return a=>Ot.createElement(Cj,ro({attr:io({},n.attr)},a),dg(n.child))}function Cj(n){var a=r=>{var{attr:o,size:u,title:f}=n,h=Sj(n,yj),p=u||r.size||"1em",g;return r.className&&(g=r.className),n.className&&(g=(g?g+" ":"")+n.className),Ot.createElement("svg",ro({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,o,h,{className:g,style:io(io({color:n.color||r.color},r.style),n.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),f&&Ot.createElement("title",null,f),n.children)};return zp!==void 0?Ot.createElement(zp.Consumer,null,r=>a(r)):a(ug)}function fg(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(n)}function kj(n){return yr({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function Hp(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(n)}function Ej(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function Mj(n){return yr({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function Rj(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function Wd(n){return!!n?.system}function Tj(n){const a=new Date(n);return`${a.getHours().toString().padStart(2,"0")}:${a.getMinutes().toString().padStart(2,"0")}`}function Vp(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function qj({guildIconUrl:n,userAvatarUrl:a,label:r}){return!n&&!a?null:l.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:r,children:[l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function mg({message:n}){const a=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${Vp(n)}`:null,r=Wd(n),o=r?"text-emerald-300":Rj(n.role);return l.jsxs(l.Fragment,{children:[n.fromDiscord?l.jsxs(l.Fragment,{children:[l.jsx(fg,{className:"h-3.5 w-3.5 text-indigo-200"}),l.jsx(qj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:a})]}):null,l.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:Vp(n)}),r?l.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:vj(n.roverColor,.14),children:n.roverId})]})}function hg(n){return Wd(n)?"surface-muted relative flex flex-wrap items-start gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted relative flex flex-wrap items-start gap-0.5 text-sm ${n.role==="admin"||n.role==="lockdown"||n.role==="lockdown-admin"?"border border-amber-400/30":n.fromDiscord?"border border-indigo-400/30 bg-indigo-900/20":""}`}function ef({message:n}){const a=Wd(n);return l.jsxs("div",{className:hg(n),children:[l.jsx(mg,{message:n}),l.jsx("span",{className:`min-w-0 break-words leading-tight whitespace-pre-wrap ${a?"text-emerald-100":"text-slate-100"}`,children:n.text}),l.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:Tj(n.ts)})]})}function pg({message:n}){return l.jsxs("div",{className:`${hg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[l.jsx(mg,{message:n}),l.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function xg({buttonId:n,count:a,goal:r,rewardNumber:o,rewardName:u,className:f=""}){return l.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",f].filter(Boolean).join(" "),children:[l.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),l.jsxs("p",{className:"text-sm font-semibold text-white",children:[a," / ",r]}),l.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",u]})]})}const Dj=3e3,_j=3500,Oj="#2196f3";function Bj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function tf({scale:n=1}){const a=de(j=>j.alerts),r=de(j=>j.session?.buttonBox?.buttons??[]),{pushAlert:o}=Gt(),u=en(),[f,h]=m.useState(()=>Date.now());m.useEffect(()=>{function j(M={}){const k=Number(M.buttonId);if(!Number.isFinite(k)||k<1||k>4)return;const w=(Array.isArray(r)?r:[]).find(L=>Number(L?.id)===k)||{},S=Number.isFinite(M.count)?M.count:Number(w.count)||0,R=Number.isFinite(w.goal)?w.goal:0,E=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",A=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${k}`,kind:"buttonbox-active",lifetimeMs:_j,payload:{buttonId:k,count:S,goal:R,rewardNumber:E,rewardName:A}})}return u.on("buttonBox:increment",j),()=>{u.off("buttonBox:increment",j)}},[o,r,u]);const p=m.useMemo(()=>a.slice(-12).map(j=>({alert:j,key:Bj(j)})),[a]);m.useEffect(()=>{if(!p.length)return;const j=setInterval(()=>h(Date.now()),200);return()=>clearInterval(j)},[p.length]);const g=new Map;p.forEach(j=>{const M=f-(j.alert.receivedAt??j.alert.timestamp??0),k=Number.isFinite(j.alert.lifetimeMs)?j.alert.lifetimeMs:Dj;M<=k&&g.set(j.key,{...j,age:M})});const x=Array.from(g.values()).slice(-3);if(!x.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},b=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return l.jsx("div",{className:b,style:v,children:x.map(j=>l.jsx(Lj,{alert:j.alert},j.key))})}function $p(n){const a=typeof n=="string"?n.trim():"",r=/^#?([0-9a-fA-F]{6})$/.exec(a);if(!r)return null;const o=r[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function Lj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const u=n.payload;return l.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:l.jsx(xg,{buttonId:u.buttonId,count:u.count,goal:u.goal,rewardNumber:u.rewardNumber,rewardName:u.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return l.jsx(ef,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return l.jsx(pg,{message:n.payload});const a=$p(n.color)||$p(Oj),r=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return l.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:r,border:`1px solid ${o}`},children:l.jsxs("p",{className:"truncate text-slate-100",children:[l.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),l.jsx("span",{className:"text-slate-500",children:" · "}),l.jsx("span",{className:"text-white",children:n.message})]})})}const $a={main:[-127,127],side:[-127,127],vacuum:[0,127]},Wu={maxSpeed:500,baseSpeed:250,boostSpeed:400},kd=100,nf=[31,127],Ka=60,Ed=8,zj=250,Uj=4e3,Vi=.4,Gp=.2,Fp=.8,Hj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},lr={driveForward:["w"],driveBackward:["s"],driveLeft:["a"],driveRight:["d"],boostModifier:["\\"],slowModifier:["shift"],auxMainForward:["i"],auxMainReverse:["k"],auxSideForward:["o"],auxSideReverse:["l"],auxVacuumFast:["p"],auxVacuumSlow:[";"],auxAllForward:[","],cameraUp:["u"],cameraDown:["j"],nightVisionToggle:["e"],hornHonk:["h"],micPtt:["m"],driveMacro:["f"],dockMacro:["g"],chatFocus:["enter"],songNoteUp:["ArrowUp"],songNoteDown:["ArrowDown"],homeAssistantOn:["ArrowRight"],homeAssistantOff:["ArrowLeft"]},gg=[{id:"drive-sequence",label:"Drive",description:"Start, undock, and full command sequence used by the drive button.",steps:[{type:"servo",angle:0},{type:"oi",command:"start"},{type:"pause",duration:kd},{type:"oi",command:"dock"},{type:"pause",duration:kd},{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 Md(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Rd(){return{main:0,side:0,vacuum:0}}function Vj(){return{enabled:!1,angle:null,config:null}}function no(){return{note:Ka}}function sr(){return{active:!1,heat:0,overheated:!1}}function so(){return{pttActive:!1}}const Yp={roverId:null,mode:"drive",drive:Md(),aux:Rd(),camera:Vj(),song:no(),horn:sr(),mic:so(),lastControlIntentAt:0,macros:gg,keymap:lr,inputs:{}};function $j(n,a){switch(a.type){case"control/set-rover":return{...n,roverId:a.payload??null,drive:a.payload?n.drive:Md(),aux:a.payload?n.aux:Rd(),song:a.payload?n.song:no(),horn:a.payload?n.horn:sr(),mic:a.payload?n.mic:so(),lastControlIntentAt:a.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===a.payload?n:{...n,mode:a.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:r,speeds:o,source:u}=a.payload;return{...n,drive:{vector:r??n.drive.vector,speeds:o??n.drive.speeds,source:u??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...a.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!a.payload?.config,config:a.payload?.config??null,angle:typeof a.payload?.angle=="number"?a.payload.angle:a.payload?.config?a.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:a.payload}};case"control/register-input-state":{const r=a.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[r]:{...n.inputs[r]??{},...a.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...a.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(a.payload)?a.payload:n.macros};case"control/reset":return{...n,drive:Md(),aux:Rd(),song:no(),horn:sr(),mic:so(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||sr(),active:!!a.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||sr(),heat:typeof a.payload?.heat=="number"?a.payload.heat:0,overheated:!!a.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||no(),note:a.payload??Ka}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||so(),pttActive:!!a.payload}};default:return n}}function Za(n,a,r){return typeof n!="number"||Number.isNaN(n)?a:Math.max(a,Math.min(r,n))}function Ja(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function fn(n,a){return!Array.isArray(a)||a.length!==2?n:Za(n,a[0],a[1])}function Gj(n={}){const a=Ja(n.x??0),r=Ja(n.y??0);return{x:a,y:r,boost:!!n.boost}}function Fj(n={},a={}){const r=Gj(n),o=typeof a.maxSpeed=="number"?a.maxSpeed:Wu.maxSpeed,u=typeof a.baseSpeed=="number"?a.baseSpeed:Wu.baseSpeed,f=typeof a.boostSpeed=="number"?a.boostSpeed:Wu.boostSpeed,h=r.boost?f:u,p=r.y*h,g=r.x*h;return{vector:r,speeds:{left:Za(Math.round(p+g),-o,o),right:Za(Math.round(p-g),-o,o)}}}function Yj(n){const a=Array.isArray(n)?n:[],r=String.fromCharCode(...a);if(typeof btoa=="function")return btoa(r);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function Xp(n){return new Promise(a=>setTimeout(a,n))}function Xj(n={}){const{driveTransform:a,auxTransform:r}=n,o=en(),u=de(L=>L.session?.assignment?.roverId??null),f=de(L=>L.session?.roster??[]),h=m.useMemo(()=>!u||!Array.isArray(f)?null:f.find(L=>String(L.id)===String(u))||null,[u,f]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),g=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),x=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),v=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((L,V)=>{u&&o.emit("command",{roverId:u,...L},V)},[o,u]),j=m.useCallback(()=>{u&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,u]),M=m.useCallback(L=>{if(!u)return null;const V={left:fn(L?.left??0,[-500,500]),right:fn(L?.right??0,[-500,500])},O=a?a(V):V,z={left:fn(O?.left??0,[-500,500]),right:fn(O?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:z}}),z},[a,b,u]),k=m.useCallback(({main:L=0,side:V=0,vacuum:O=0}={})=>{if(!u)return null;const z={main:fn(L,$a.main),side:fn(V,$a.side),vacuum:fn(O,$a.vacuum)},X=r?r(z):z,G={main:fn(X?.main??0,$a.main),side:fn(X?.side??0,$a.side),vacuum:fn(X?.vacuum??0,$a.vacuum)};return b({type:"motors",data:{motorPwm:G}}),G},[r,b,u]),N=m.useCallback(L=>!u||!p?null:(b({type:"servo",data:{servo:{angle:L}}}),L),[b,u,p]),w=m.useCallback(L=>{if(!u)return!1;const V=Array.isArray(L)?L:typeof L=="string"?Hj[L]:null;return V?(b({type:"raw",data:{raw:Yj(V)}}),j(),!0):!1},[b,j,u]),S=m.useCallback(async L=>{if(!(!L||!Array.isArray(L.steps)||!u))for(const V of L.steps){if(!u)break;switch(V.type){case"oi":w(V.command);break;case"drive":M(V.speeds??{left:0,right:0});break;case"motors":k(V.values??{});break;case"servo":N(V.angle);break;case"pause":await Xp(V.duration??kd);break}if(V.delay||V.delayMs){const O=V.delayMs??V.delay;typeof O=="number"&&O>0&&await Xp(O)}}},[u,w,M,k,N]),R=m.useCallback((L="toggle")=>!u||!g?null:(b({type:"nightVision",data:{nightVision:{action:L}}}),L),[b,g,u]),E=m.useCallback(L=>u?(b({type:"horn",data:{horn:L}}),L):null,[b,u]),A=m.useCallback((L=[],V={})=>{if(!u)return null;const z=(Array.isArray(L)&&L.length>0?L:[{note:Ka,duration:Ed}]).slice(0,16).map(X=>({note:fn(Math.round(X?.note??Ka),nf),duration:fn(Math.round(X?.duration??Ed),[1,255])}));return b({type:"song",data:{song:{notes:z,slot:V.slot,loop:V.loop}}}),z},[b,u]);return m.useMemo(()=>({roverId:u,rosterEntry:h,servoConfig:p,nightVision:g,nightVisionState:v,horn:x,emitCommand:b,enableSensorStream:j,sendDriveDirect:M,sendAuxMotors:k,sendServoAngle:N,sendOiCommand:w,sendNightVision:R,sendHorn:E,sendSong:A,runMacroSteps:S}),[u,h,p,g,v,x,b,j,M,k,N,w,R,E,S])}const Qj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Qp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Sr(n){if(typeof n!="string")return"";const a=n.toLowerCase();return Qj[a]??a}function Ij(n){const a=Sr(n);if(!a)return null;if(Qp[a])return Qp[a];if(a.length===1){if(/[a-z]/.test(a))return`Key${a.toUpperCase()}`;if(/[0-9]/.test(a))return`Digit${a}`}return null}function vg(n){const a=Sr(n);return a?`key:${a}`:null}function Kj(n){const a=Ij(n);return a?`code:${a}`:null}function Ip(n){const a=new Set,r=vg(n?.key??"");r&&a.add(r);const o=n?.code?`code:${n.code}`:null;return o&&a.add(o),Array.from(a)}function Zj(n={}){return Object.fromEntries(Object.entries(n).map(([a,r])=>{const o=Array.isArray(r)?r:[r],u=new Set;return o.forEach(f=>{const h=vg(String(f));h&&u.add(h);const p=Kj(String(f));p&&u.add(p)}),[a,u]}))}function Rt(n){const a=Sr(n);return a?a===" "?"Space":a==="\\"?"Backslash":a==="`"?"Backtick":a==="["?"[ or {":a==="]"?"] or }":a===";"?"; or :":a==="'"?`' or "`:a===","?", or <":a==="."?". or >":a==="/"?"/ or ?":a==="-"?"- or _":a==="="?"= or +":a==="arrowup"?"Arrow Up":a==="arrowdown"?"Arrow Down":a==="arrowleft"?"Arrow Left":a==="arrowright"?"Arrow Right":a.length===1?a.toUpperCase():a:"—"}const kn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},Pn={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}]}}},ks={activeSignature:null,profiles:{},defaults:{profile:Pn}},ea={waveform:"saw",freqs:[440,550,660,0]},it={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Ps=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Jj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Kp(){return Ps.reduce((n,a)=>(n[a.key]={cap:1,clearSec:0},n),{})}function Zp(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Pj(n,a={}){const r=de(S=>S.session?.role||null),f=(pn(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...Jj,...a.config||{}}),[a.config]),[p,g]=m.useState(()=>Kp()),x=m.useRef(0),v=m.useRef(f);m.useEffect(()=>{v.current=f||{}},[f]),m.useEffect(()=>{g(Kp()),x.current=0},[n]);const b=m.useMemo(()=>Ps.some(S=>S.motors.some(R=>!!f?.[R])),[f]),j=m.useMemo(()=>Object.values(p||{}).some(S=>(Number.isFinite(S?.cap)?S.cap:1)<.999),[p]),M=!!n&&(b||j);m.useEffect(()=>{if(!M)return;x.current=typeof performance<"u"?performance.now():Date.now();const S=setInterval(()=>{const R=typeof performance<"u"?performance.now():Date.now(),E=Math.max(0,R-x.current);x.current=R;const A=Math.min(.25,E/1e3);A<=0||g(L=>{let V=!1;const O={},z=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,X=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,G=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return Ps.forEach(Q=>{const P=L[Q.key]||{cap:1,clearSec:0},oe=Number.isFinite(P.cap)?P.cap:1,ie=Number.isFinite(P.clearSec)?P.clearSec:0,$=Q.motors.some(ee=>!!v.current?.[ee]),q=$?0:ie+A,H=!$&&q>=G,J=Zp($?oe-z*A:H?oe+X*A:oe);(Math.abs(J-oe)>1e-4||Math.abs(q-ie)>1e-4)&&(V=!0),O[Q.key]={cap:J,clearSec:q}}),V?O:L})},100);return()=>clearInterval(S)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec,n,M]);const k=m.useMemo(()=>{const S=Ps.reduce((R,E)=>{const A=p?.[E.key],L=Number.isFinite(A?.cap)?A.cap:1;return R[E.key]=Zp(L),R},{});return{perGroup:S,drive:{left:S.drive??1,right:S.drive??1},aux:{main:S.aux??1,side:S.aux??1,vacuum:1}}},[p]),N=m.useMemo(()=>{const S={};Ps.forEach(E=>{E.motors.forEach(A=>{S[A]=!!f?.[A]})});const R=Ps.reduce((E,A)=>(E[A.key]=A.motors.some(L=>!!f?.[L]),E),{});return{motors:S,groups:R}},[f]),w=r==="admin"||r==="lockdown"||r==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:N,scales:k,isActive:(k?.drive?.left??1)<1||(k?.drive?.right??1)<1||(k?.aux?.main??1)<1||(k?.aux?.side??1)<1,config:h,adminImmune:w}),[p,N,k,h,w])}function Wj(n={},a,r=!1){if(r||!a?.drive)return n;const o=typeof a.drive.left=="number"?a.drive.left:1,u=typeof a.drive.right=="number"?a.drive.right:1;return o>=.999&&u>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*u)}}function eN(n={},a,r=!1){if(r||!a?.aux)return n;const o=typeof a.aux.main=="number"?a.aux.main:1,u=typeof a.aux.side=="number"?a.aux.side:1,f=typeof a.aux.vacuum=="number"?a.aux.vacuum:1;return o>=.999&&u>=.999&&f>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*u),vacuum:Math.round((n.vacuum??0)*f)}}const bg=m.createContext(null);function Jp(n){return Object.fromEntries(Object.entries(n||{}).map(([a,r])=>[a,Array.isArray(r)?[...r]:[]]))}function tN(n,a){if(!n)return a;const r=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return Za(a,r,o)}function nN(n=[]){if(!Array.isArray(n)||n.length<3)return n;const a=n.slice(-3),[r,o,u]=a,f=r?.type==="drive"&&Number(r?.speeds?.left)===-300&&Number(r?.speeds?.right)===-300,h=o?.type==="pause"&&Number(o?.duration)===600,p=u?.type==="drive"&&Number(u?.speeds?.left)===0&&Number(u?.speeds?.right)===0;return!f||!h||!p?n:n.slice(0,-3)}function sN({children:n}){const[a,r]=m.useReducer($j,Yp),o=m.useRef(null),u=m.useRef(!1),f=m.useRef(Yp.camera.angle),h=m.useRef(null),p=m.useRef(0),g=m.useRef(0),{value:x,save:v}=Qe("controls",{keymap:lr,macros:gg}),{value:b}=Qe("page",{driveMacroBackoffEnabled:!0}),{value:j}=Qe("horn",ea),M=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,k=de(re=>re.session?.assignment?.roverId??null),N=de(re=>re.session?.homeAssistant?.entities??[]),{homeAssistantSetState:w}=Gt(),S=Pj(k),R=m.useCallback(re=>Wj(re,S.scales,S.adminImmune),[S.adminImmune,S.scales]),E=m.useCallback(re=>eN(re,S.scales,S.adminImmune),[S.adminImmune,S.scales]),A=Xj({driveTransform:R,auxTransform:E}),L=m.useCallback(()=>{const ae=(N||[]).filter(Se=>(Se.type==="light"||Se.type==="switch")&&Se.available!==!1&&Se.state!=="on");if(ae.length===0){u.current=!1;return}u.current=!0,ae.forEach(Se=>{w(Se.id,"on").catch(()=>{})}),u.current=!1},[N,w]);m.useEffect(()=>{r({type:"control/set-rover",payload:A.roverId})},[A.roverId]),m.useEffect(()=>{const re=o.current;o.current=a.mode,re!=="drive"&&a.mode==="drive"&&N?.length?L():re!=="drive"&&a.mode==="drive"&&(u.current=!0)},[a.mode,N,L]),m.useEffect(()=>{u.current&&N?.length&&L()},[N,L]),m.useEffect(()=>{const re={...lr,...x?.keymap||{}};r({type:"control/set-keymap",payload:re}),x?.macros&&r({type:"control/set-macros",payload:x.macros})},[x?.keymap,x?.macros]),m.useEffect(()=>{const re=A.servoConfig;if(!re){r({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const ae=typeof re.minAngle=="number"?re.minAngle:-45,Se=typeof re.maxAngle=="number"?re.maxAngle:45,pe=typeof re.homeAngle=="number"?re.homeAngle:(ae+Se)/2,je=typeof f.current=="number"?Za(f.current,ae,Se):null,Ae=je??Za(pe,ae,Se);r({type:"control/set-camera-config",payload:{config:re,angle:Ae}}),f.current=Ae},[A.servoConfig]),m.useEffect(()=>{f.current=typeof a.camera.angle=="number"?a.camera.angle:f.current},[a.camera.angle]),m.useEffect(()=>{A.roverId&&A.enableSensorStream()},[A.roverId,A.enableSensorStream]);const V=m.useCallback(re=>{r({type:"control/set-mode",payload:re})},[]),O=m.useCallback(()=>{r({type:"control/record-intent"})},[]),z=m.useRef(a.drive.speeds),X=m.useRef(a.aux),G=m.useMemo(()=>JSON.stringify(S.scales),[S.scales]),Q=m.useRef(0),P=m.useRef(0);m.useEffect(()=>{z.current=a.drive.speeds},[a.drive.speeds]),m.useEffect(()=>{X.current=a.aux},[a.aux]),m.useEffect(()=>{if(!A.roverId||S.adminImmune||!S.isActive)return;const re=Math.max(0,Number(S?.config?.outputRateMs)||0),ae=typeof performance<"u"?performance.now():Date.now(),Se=z.current||{left:0,right:0},pe=X.current||{main:0,side:0,vacuum:0},je=!!(Se.left||Se.right),Ae=!!(pe.main||pe.side||pe.vacuum);!je&&!Ae||(je&&ae-Q.current>=re&&(Q.current=ae,A.sendDriveDirect(Se)),Ae&&ae-P.current>=re&&(P.current=ae,A.sendAuxMotors(pe)))},[G,S.adminImmune,S.config,S.isActive,A]);const oe=m.useCallback((re,ae={})=>{const Se=Fj(re,ae.speedOptions);r({type:"control/update-drive",payload:{...Se,source:ae.source??null}}),O(),A.sendDriveDirect(Se.speeds)},[A,O]),ie=m.useCallback((re={})=>{const ae=A.sendAuxMotors(re)??re;r({type:"control/set-aux-motors",payload:ae}),O()},[A,O]),$=m.useCallback((re,ae)=>{if(!re)return!1;const Se=Sr(ae);if(!Se)return!1;const pe=Jp(a.keymap);return pe[re]=[Se],r({type:"control/set-keymap",payload:pe}),v(je=>({...je??{},keymap:pe})),!0},[a.keymap,v]),q=m.useCallback(()=>{const re=Jp(lr);r({type:"control/set-keymap",payload:re}),v(ae=>({...ae??{},keymap:re}))},[v]),H=m.useCallback(re=>{if(!A.servoConfig)return;const ae=tN(A.servoConfig,re);r({type:"control/set-camera-angle",payload:ae}),A.sendServoAngle(ae),f.current=ae,O()},[A,O]),J=m.useCallback((re=0)=>{const ae=A.servoConfig;if(!ae)return;const Se=typeof re=="number"&&re!==0?re:ae.nudgeDegrees||1,pe=typeof f.current=="number"?f.current:typeof ae.homeAngle=="number"?ae.homeAngle:0;H(pe+Se)},[A.servoConfig,H]),ee=m.useCallback(()=>{const re=A.servoConfig;if(!re)return;const ae=typeof re.homeAngle=="number"?re.homeAngle:typeof re.minAngle=="number"&&typeof re.maxAngle=="number"?(re.minAngle+re.maxAngle)/2:0;H(ae)},[A.servoConfig,H]),ue=m.useCallback(async re=>{const ae=a.macros.find(pe=>pe.id===re)||null;if(!ae)return;let Se=ae;re==="drive-sequence"?(L(),N?.length||(u.current=!0),O(),M||(Se={...ae,steps:nN(ae.steps)})):re==="seek-dock"&&O(),await A.runMacroSteps(Se)},[M,A,O,N,a.macros,L]),T=m.useCallback(()=>{r({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),A.sendDriveDirect({left:0,right:0}),A.sendAuxMotors({main:0,side:0,vacuum:0})},[A]),_=m.useCallback(re=>{A.sendOiCommand(re)},[A]),K=m.useCallback(re=>{A.roverId&&A.emitCommand({type:"sensorStream",data:{sensorStream:{enable:re}}})},[A]),ne=m.useCallback(re=>{if(A.nightVision){if(typeof re=="boolean"){const ae=re?"off":"on";A.sendNightVision(ae)}else A.sendNightVision("toggle");O()}},[A,O]),me=m.useCallback(()=>{ne()},[ne]),ce=m.useCallback(re=>{const ae=typeof re=="number"?re:Ka;return r({type:"control/set-song-note",payload:ae}),ae},[]),fe=m.useCallback((re,ae)=>A.sendSong(re,ae),[A]),be=m.useMemo(()=>{const re=j??ea,ae=re.waveform==="sine"?"sine":"saw",pe=[...Array.isArray(re.freqs)?re.freqs:ea.freqs,0,0,0,0].slice(0,4).map(je=>{const Ae=Number(je);return Number.isFinite(Ae)?Ae<=0?0:Math.min(5e3,Math.round(Ae)):0});return{waveform:ae,freqs:pe}},[j]),ge=m.useCallback(()=>{if(!A.horn)return;if(a.horn?.overheated||(a.horn?.heat??0)>=1||a.horn?.active)return!1;const re=Date.now();return A.sendHorn({action:"start",...be}),r({type:"control/set-horn-active",payload:!0}),p.current=re,g.current=re,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},Uj),O(),!0},[r,be,A,O,a.horn?.active,a.horn?.heat,a.horn?.overheated]),xe=m.useCallback(()=>{if(!A.horn)return;A.sendHorn({action:"stop"}),r({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const re=Date.now(),ae=p.current||re,Se=Math.max(0,re-ae);if(p.current=0,Se>0){const pe=a.horn?.heat??0,je=Se/1e3*Vi;let Ae=Math.max(0,Math.min(1,pe+je)),Re=a.horn?.overheated??!1;Ae>=1&&(Ae=1,Re=!0),r({type:"control/set-horn-heat",payload:{heat:Ae,overheated:Re}})}},[r,A,a.horn?.heat,a.horn?.overheated,Vi]),ze=m.useRef({active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}),Ee=m.useRef(xe);m.useEffect(()=>{ze.current={active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}},[a.horn?.active,a.horn?.heat,a.horn?.overheated]),m.useEffect(()=>{Ee.current=xe},[xe]);const Te=!!a.horn?.active||(a.horn?.heat??0)>0||!!a.horn?.overheated;m.useEffect(()=>{if(!Te)return;const ae=setInterval(()=>{const Se=Date.now(),pe=g.current||Se;g.current=Se;const je=Math.min(1e3,Math.max(0,Se-pe))/1e3,Ae=ze.current,Re=Ae.heat??0,le=!!Ae.active,he=!!Ae.overheated,De=je*(le?Vi:-Gp);let Tt=Math.max(0,Math.min(1,Re+De)),qt=he;Tt>=1?(Tt=1,qt=!0,le&&Ee.current()):qt&&Tt<=Fp&&(qt=!1),(Tt!==Re||qt!==he)&&r({type:"control/set-horn-heat",payload:{heat:Tt,overheated:qt}})},100);return()=>clearInterval(ae)},[r,Te,Gp,Fp,Vi]);const Oe=m.useCallback((re,ae)=>{r({type:"control/register-input-state",payload:{source:re,state:ae}})},[]),Ue=m.useCallback(re=>{r({type:"control/set-mic-ptt",payload:!!re})},[]),ht=m.useMemo(()=>({state:a,dispatch:r,pipeline:A,overcurrentLimiter:S,actions:{setMode:V,setDriveVector:oe,setAuxMotors:ie,setServoAngle:H,nudgeServo:J,goServoHome:ee,runMacro:ue,stopAllMotion:T,sendOiCommand:_,setSensorStream:K,setNightVision:ne,toggleNightVision:me,updateKeyBinding:$,resetKeyBindings:q,registerInputState:Oe,setSongNote:ce,sendSong:fe,startHorn:ge,stopHorn:xe,setMicPttActive:Ue}}),[a,A,S,V,oe,ie,H,J,ee,ue,T,_,K,ne,me,$,q,Oe,ce,fe,ge,xe,Ue]);return l.jsx(bg.Provider,{value:ht,children:n})}function wt(){const n=m.useContext(bg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const aN="data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAANAAAIpQBKSkpKSkpKXFxcXFxcXFxra2tra2tra3p6enp6enqJiYmJiYmJiZiYmJiYmJiYpqampqamprW1tbW1tbW1xMTExMTExMTT09PT09PT4uLi4uLi4uLx8fHx8fHx8f////////8AAABQTEFNRTMuMTAwBLkAAAAAAAAAABUgJAUYQQAB4AAACKVpqtMZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//ugxAAAwqQPR8CIwCh0BCj5jDwlIAAjW87wAACcOsAKPMk8ARj8w9OAWwNlV/gCgQMHEhAOVnFaNzWWAPI2zyjHjd8FAoKqyAa88AAAAABNjEd9CQOglIY9dtC+a51bGZrZgTewD3c+AAYx5hxIMheIcudKAyaykG1/h5EsPB0iTEFNRTMuMTAwqqqqqqrIBZqvAAAAAC9JXFIAHrCgAp0D0hUYOInIluqg1TNdKCzMeAAFQCKKsxUmVfireKILLBgSVgb4qBVtPWpMQU1FMy4xMDCqqqqqqqqqqqqqqqqpApm/AAAAAC7QYaHPHoCjkCysmc+QY9NNWRbKE+mqowNobwAAoSQQMLGChDlOrKMqVMC/6xy/CXbFaL7AZUxBTUUzLjEwMFVVVVVVVVVVVacDqZ8AAAAAMgzaYFBPNgIOnVCQfFfwmBBhLVNJQSdxdQRofwAGxF9xAAYs4AZDuE87li0YCASIBwaCiXUj+2BqTEFNRTMuMTAwqqqqqqqqlwOonwAAAAAtkABQSEZ1INNDgx8HeaaLCXiu5dqSciylQNXjv8GdmACQ5ogYKbnsmxkoChog+w9IhU6GsgzCIQBSxFpMQQAAMBiHjgAAAAv6FQQILmJmGLltnax9HszIVEAoEq1p8olpcPLlGpXFastuWosKNFlmlqADJbwAEFRI4iJJy0oDumUW//sgxOEAw5wfU8fnAGBvg6n5nDxUh7QuwcEzkK5Ztz7AZUxBTUUzLjEwMFVVVVVVVZUAhd8AAAAALZAAamQMWKtC7Avib0WLplt2IAp0SKV0pFFxCADLX6AIPFrWJIBQqPGW/x0QDTRLGaQYCRAZzKeoU6uqTEFN6AB3n/7wAAAxq//7EMT0AMPUHU/MawJgc4PpuYy8VQZjocBw2OgQQyQyECnbABEUC/ZoM0J56Jm0tqzNJaq8KospqUAQ5/QBghnCqQAhR4Mz1D1gJPstYsI1sYIg079I5cYjY6pMQU1FMy4xMDCqqqqq//sQxPUAw+AdT8zvAih6hCk5nWBFqqqWAFOf4AAAAEAIQZPkMcwUzFVE51cSBjIHpJRIEIjWgGar9VhgCUvwAFAUMk0RCpMkwXjPQDcoLBU+n5RuR4ZrPQLPckxBTUUzLjEwMKqqqqr/+xDE9oDEAB1NzG8CKIGEKPmd5EWqxgBWn9AAAAAKIiC5GcLJIczCEvNbWsF31jo4Bw0rXktvJF5YRyABlj+ABIQ2RGsHgdc0XsPntoEDUzaQOjTBqblFPUE1TEFNRckAt68AAAAALv/7EMT4AMQIHU3M7wIojwUo+Y2MZfAgKcwITAQIYN1TosJeLtDA0ubWNrFSADJoln4AC0hVaLiIIUChs+4HST4BgCpQHITPMBQkEnj73ORZfylh+sRLEGUiNIpMQU1FMy4xMDCqqqqq//sQxP6AxlgtK+13Yih3hCj5neBNqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrIkT7UNAZ7NS7yMqcihSKLMn8DlKYq8ZdPCVEoJBuWqkxBTUUzLjEwMKqqqqr/+xDE+ADEXCVHzGjDIIQEqLm9PIWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT+AMWoL0XNcwJoiASoeY3gVaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxPgAxHAnRcxvAmiBBKj5jehEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDE+IDEmCVDzPMCKH6EqLmNYE2qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMT9gEPgI0vMZwQgvYWlPY5gFaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxOYDw+gpIIfgwWgAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",yg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function lN({children:n}){const a=en(),r=de($=>$.session),{pushAlert:o}=Gt(),{value:u}=Qe("audio",it),[f,h]=m.useState([]),[p,g]=m.useState([]),[x,v]=m.useState(!1),b=m.useRef(null),j=m.useRef(null),M=m.useRef(null),k=m.useRef(new Map),N=m.useRef(new Map),w=m.useRef({isTyping:!1,lastSent:0}),S=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,R=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,E=Math.max(0,Math.min(1,S*R)),A=m.useCallback(()=>{const $=Array.from(k.current.values()).sort((q,H)=>q.lastUpdate-H.lastUpdate).map(q=>q.payload);g($)},[]),L=m.useCallback($=>!$||typeof $!="object"?null:$.typingId?$.typingId:$.fromDiscord?`discord:${$.discordUserId||$.discordUserName||$.nickname||"unknown"}`:`socket:${$.socketId||$.nickname||"unknown"}`,[]);m.useEffect(()=>{M.current=new Audio(aN),M.current.volume=E,M.current.load()},[E]);const V=m.useCallback(()=>{const $=M.current;$&&($.volume=E,$.currentTime=0,$.play().catch(()=>{}))},[E]);m.useEffect(()=>{function $(q={}){h(H=>[...H.slice(-99),q]),!(q?.socketId&&r?.socketId&&q.socketId===r.socketId)&&(V(),o?.({kind:"chat",payload:q,id:`chat-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return a.on("chat:message",$),()=>{a.off("chat:message",$)}},[V,r?.socketId,a]),m.useEffect(()=>{function $(q={}){const H=L(q);if(!H)return;const J=Date.now();if(q?.socketId&&r?.socketId&&q.socketId===r.socketId){q.isTyping||(k.current.delete(H),A());return}if(q.isTyping){k.current.set(H,{payload:q,expiresAt:J+6e3,lastUpdate:J});const ee=N.current.get(H)||0;J-ee>=2500&&(N.current.set(H,J),o?.({kind:"chat-typing",payload:q,id:`chat-typing-${H}-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else k.current.delete(H);A()}return a.on("chat:typing",$),()=>{a.off("chat:typing",$)}},[o,A,L,r?.socketId,a]),m.useEffect(()=>{const $=setInterval(()=>{const q=Date.now();let H=!1;k.current.forEach((J,ee)=>{J.expiresAt<=q&&(k.current.delete(ee),H=!0)}),H&&A()},2e3);return()=>clearInterval($)},[A]),m.useEffect(()=>{function $(q=[]){Array.isArray(q)&&h(H=>{if(H.length===0)return q.slice(-100);const J=new Set(q.map(ue=>ue?.id));return[...q,...H.filter(ue=>ue?.id&&!J.has(ue.id))].slice(-100)})}return a.on("chat:init",$),()=>{a.off("chat:init",$)}},[a]);const O=m.useCallback($=>{const q=!!$,H=Date.now(),J=w.current,ee=!q&&J.isTyping;!(q&&(!J.isTyping||H-J.lastSent>=3500))&&!ee||(w.current={isTyping:q,lastSent:H},a.emit("chat:typing",{isTyping:q}))},[a]),z=m.useCallback(($,q=null)=>new Promise((H,J)=>{a.emit("chat:send",{text:$,tts:q},(ee={})=>{ee.error?J(new Error(ee.error)):H(ee)})}),[a]),X=m.useCallback(($,q={})=>{(q?.target==="hud"?"hud":"panel")==="hud"?j.current=$:b.current=$},[]),G=m.useCallback(()=>{v(!0),(j.current||b.current)?.focus()},[]),Q=m.useCallback(()=>{v(!1),j.current?.blur(),b.current?.blur()},[]),P=m.useCallback(()=>v(!0),[]),oe=m.useCallback(()=>v(!1),[]),ie=m.useMemo(()=>({messages:f,sendMessage:z,focusChat:G,blurChat:Q,registerInputRef:X,onInputFocus:P,onInputBlur:oe,setTypingActive:O,typing:p,isChatFocused:x,selfSocketId:r?.socketId||null}),[Q,G,x,f,oe,P,X,z,r?.socketId,O,p]);return l.jsx(yg.Provider,{value:ie,children:n})}function sf(){const n=m.useContext(yg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let Sg=!1;function ed(n){Sg=!!n}function Pp(){return Sg}const rN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function jg(n){if(!n||n.nodeType!==1)return!1;const a=n.tagName;if(a==="TEXTAREA"||n.isContentEditable)return!0;if(a!=="INPUT")return!1;const r=n.type?n.type.toLowerCase():"";return rN.has(r)}function iN(){return typeof document>"u"?!1:jg(document.activeElement)}const td="keyboard",nd={x:0,y:0,boost:!1},sd={main:0,side:0,vacuum:0},Wp=nf[0],ex=nf[1],af=5,cr=500,ur=1,lf=100;function ad(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}function oN(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(af,Math.min(cr,r)):a}function Ng(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(ur,Math.min(lf,r)):a}function cN(n){const r=(Ng(n,n)-ur)/(lf-ur),o=cr-r*(cr-af);return Math.round(o)}function uN(n){const a=oN(n,n),r=(cr-a)/(cr-af),o=ur+r*(lf-ur);return Math.round(o)}function dN(n){return jg(n?.target)}function dt(n,a){if(!n||n.size===0)return!1;for(const r of a)if(n.has(r))return!0;return!1}function fN(n,a){const r=dt(a.driveForward,n),o=dt(a.driveBackward,n),u=dt(a.driveLeft,n),f=dt(a.driveRight,n),h=dt(a.boostModifier,n),p=dt(a.slowModifier,n);let g=0;r&&!o?g=1:o&&!r&&(g=-1);let x=0;u&&!f?x=-1:f&&!u&&(x=1);const v=p?.4:1;return{x:x*v,y:g*v,boost:h&&!p}}function mN(n,a){if(dt(a.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=dt(a.auxMainForward,n)?127:dt(a.auxMainReverse,n)?-127:0,u=dt(a.auxSideForward,n)?127:dt(a.auxSideReverse,n)?-70:0,f=dt(a.auxVacuumFast,n)?127:dt(a.auxVacuumSlow,n)?50:0;return{main:o,side:u,vacuum:f}}function hN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,nudgeServo:u,runMacro:f,stopAllMotion:h,registerInputState:p,toggleNightVision:g,startHorn:x,stopHorn:v,setMicPttActive:b,setSongNote:j,sendSong:M}}=wt(),k=de(ce=>ce.session?.homeAssistant||null),{homeAssistantSetState:N}=Gt(),{focusChat:w,blurChat:S,isChatFocused:R}=sf(),{value:E}=Qe("inputs",kn),A=m.useMemo(()=>Zj(n.keymap),[n.keymap]),L=m.useMemo(()=>{const ce=new Set;return Object.values(A).forEach(fe=>{fe&&fe.forEach(be=>ce.add(be))}),ce},[A]),V=m.useMemo(()=>{const ce=kn.keyboard,fe=E?.keyboard??{};return{baseSpeed:ad(fe.baseSpeed,ce.baseSpeed),turboSpeed:ad(fe.turboSpeed,ce.turboSpeed),precisionSpeed:ad(fe.precisionSpeed,ce.precisionSpeed)}},[E?.keyboard]),O=m.useMemo(()=>{const ce=kn.keyboard,fe=E?.keyboard??{},be=Ng(typeof fe.tiltSpeed=="number"?fe.tiltSpeed:typeof fe.tiltIntervalMs=="number"?uN(fe.tiltIntervalMs):ce.tiltSpeed,ce.tiltSpeed);return cN(be)},[E?.keyboard]),z=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),X=m.useRef(new Set),G=m.useRef(nd),Q=m.useRef(sd),P=m.useRef(null),oe=m.useRef(null),ie=m.useRef(!1),$=m.useCallback(()=>{const ce=new Set(X.current);dt(A.boostModifier,ce);const be=dt(A.slowModifier,ce)?{baseSpeed:V.precisionSpeed,boostSpeed:V.precisionSpeed}:{baseSpeed:V.baseSpeed,boostSpeed:V.turboSpeed},ge=fN(ce,A),xe=mN(ce,A);(ge.x!==G.current.x||ge.y!==G.current.y||ge.boost!==G.current.boost)&&(G.current=ge,r(ge,{source:td,speedOptions:be})),(xe.main!==Q.current.main||xe.side!==Q.current.side||xe.vacuum!==Q.current.vacuum)&&(Q.current=xe,o(xe)),p(td,{keys:Array.from(ce),vector:ge,aux:xe})},[A,V,p,o,r]),q=m.useCallback(()=>{P.current&&(clearTimeout(P.current),P.current=null)},[]),H=m.useCallback(()=>{const ce=new Set(X.current),fe=dt(A.cameraUp,ce),be=dt(A.cameraDown,ce);return(fe?1:0)-(be?1:0)},[A]),J=m.useCallback(()=>{if(H()===0){q();return}if(P.current)return;const fe=()=>{const be=H();if(be===0){q();return}u(be*z),P.current=setTimeout(fe,O)};P.current=setTimeout(fe,0)},[H,u,O,z,q]),ee=m.useCallback(()=>{oe.current&&(clearTimeout(oe.current),oe.current=null)},[]),ue=m.useCallback(()=>{const ce=new Set(X.current),fe=dt(A.songNoteUp,ce),be=dt(A.songNoteDown,ce);return(fe?1:0)-(be?1:0)},[A]),T=m.useCallback(ce=>{if(ce===0)return;let be=(typeof n.song?.note=="number"?n.song.note:Ka)+ce;be>ex?be=Wp:be<Wp&&(be=ex);const ge=j(be);M([{note:ge,duration:Ed}],{slot:0})},[M,j,n.song?.note]),_=m.useCallback(()=>{if(ue()===0){ee();return}if(oe.current)return;const fe=()=>{const be=ue();if(be===0){ee();return}T(be),oe.current=setTimeout(fe,zj)};oe.current=setTimeout(fe,0)},[ue,ee,T]),K=m.useCallback(()=>{X.current.clear(),G.current=nd,Q.current=sd,q(),ee(),ie.current&&(ie.current=!1,v()),b(!1),h(),p(td,{keys:[],vector:nd,aux:sd})},[p,b,h,v,q,ee]),ne=m.useCallback(ce=>{const fe=k;if(!fe?.enabled||!fe?.connected||fe?.lightPolicy?.locked||fe?.lightPolicy?.lockedOn)return;const ge=(fe.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ge.length!==0){if(ce==="on"){const xe=ge.find(ze=>ze.state!=="on");xe&&N(xe.id,"on").catch(()=>{});return}if(ce==="off")for(let xe=ge.length-1;xe>=0;xe-=1){const ze=ge[xe];if(ze.state==="on"){N(ze.id,"off").catch(()=>{});break}}}},[N,k]);m.useEffect(()=>{function ce(ge){if(Pp()||dN(ge))return;const xe=Ip(ge);if(xe.length===0)return;const ze=new Set(xe);if(dt(A.chatFocus,ze)){ge.preventDefault(),K(),R||w();return}xe.some(Te=>L.has(Te))&&ge.preventDefault();const Ee=xe.filter(Te=>!X.current.has(Te));if(Ee.forEach(Te=>X.current.add(Te)),Ee.length>0)if(Ee.some(Te=>A.driveMacro?.has(Te)))a("drive"),f("drive-sequence");else if(Ee.some(Te=>A.dockMacro?.has(Te)))a("dock"),f("seek-dock");else if(Ee.some(Te=>A.nightVisionToggle?.has(Te)))g();else if(Ee.some(Te=>A.hornHonk?.has(Te))){if(!ie.current){const Te=x();ie.current=!!Te}}else Ee.some(Te=>A.micPtt?.has(Te))?b(!0):Ee.some(Te=>A.homeAssistantOn?.has(Te))?ne("on"):Ee.some(Te=>A.homeAssistantOff?.has(Te))&&ne("off");J(),_(),$()}function fe(ge){if(Pp())return;Ip(ge).forEach(ze=>X.current.delete(ze)),ie.current&&!dt(A.hornHonk,X.current)&&(ie.current=!1,v()),dt(A.micPtt,X.current)||b(!1),J(),_(),$()}function be(){K()}return window.addEventListener("keydown",ce,{capture:!0}),window.addEventListener("keyup",fe,{capture:!0}),window.addEventListener("blur",be),()=>{window.removeEventListener("keydown",ce,{capture:!0}),window.removeEventListener("keyup",fe,{capture:!0}),window.removeEventListener("blur",be)}},[L,S,$,J,_,w,R,A.chatFocus,A.dockMacro,A.driveMacro,A.hornHonk,A.micPtt,K,f,b,a,h,ee,x,v,ne]);const me=m.useRef(K);return m.useEffect(()=>{me.current=K},[K]),m.useEffect(()=>{me.current()},[n.roverId]),m.useEffect(()=>{ie.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{q(),ee()},[q,ee]),null}const pN=1.6;function wg(n){if(!n)return"unknown::none::0::0";const a=n.id||"unknown",r=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,u=Array.isArray(n.buttons)?n.buttons.length:0;return`${a}::${r}::${o}::${u}`}function xN(n){return JSON.parse(JSON.stringify(n??{}))}function Ag(n,a){const r=xN(a);return r.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},r}function Ws(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function er(n,a){if(!n)return 0;const r=Math.abs(n);return a==="expo"?Math.sign(n)*Math.pow(r,pN):n}function ld(n,a){const r=Math.abs(n);if(r<=a)return 0;const o=(r-a)/(1-a);return Math.sign(n)*o}function gN(n,a,r){const o=Math.hypot(n,a);if(o<=r)return{x:0,y:0};const f=(o-r)/(1-r)/o;return{x:n*f,y:a*f}}function oo(n,a){if(!n||!Array.isArray(n.axes))return null;const r=n.axes[a];return Number.isFinite(r)?Ws(r):null}function Td(n,a){if(!n||!Array.isArray(n.buttons))return null;const r=n.buttons[a];if(!r)return null;const o=typeof r.value=="number"?r.value:r.pressed?1:0;return{pressed:!!(r.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function rd(n,a=[]){for(const r of a)if(r){if(r.kind==="axis"){const o=oo(n,r.index);if(o===null)continue;return{value:r.invert?-o:o,source:r}}if(r.kind==="buttonAxis"){const o=Td(n,r.index);if(!o)continue;return{value:Ws(o.value),source:r}}}return{value:0,source:null}}function vN(n,a=[]){for(const r of a){if(!r||r.kind!=="axisPair")continue;const o=oo(n,r.x),u=oo(n,r.y);if(o===null||u===null)continue;const f=r.invertX?-o:o,h=r.invertY?-u:u;return{x:f,y:h,source:r}}return{x:0,y:0,source:null}}function Is(n,a=[]){for(const r of a)if(r){if(r.kind==="button"){const o=Td(n,r.index);if(!o)continue;return{pressed:o.pressed,source:r}}if(r.kind==="axisButton"){const o=oo(n,r.index);if(o===null)continue;const u=r.direction||1,f=typeof r.threshold=="number"?r.threshold:.6;return{pressed:o*u>f,source:r}}if(r.kind==="buttonAxis"){const o=Td(n,r.index);if(!o)continue;return{pressed:o.value>.5,source:r}}}return{pressed:!1,source:null}}function Cg(n,a){const r=a?.bindings??{},o=a?.calibration??{},u=r.drive??{},f=vN(n,u.sources);let h=Ws(f.x),p=Ws(f.y);const g=Math.min(Math.max(o.driveDeadzone??.18,0),.8),x=gN(h,p,g);h=er(x.x,o.driveCurve),p=er(x.y,o.driveCurve);const v=r.cameraTilt??{},b=rd(n,v.sources),j=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let M=ld(Ws(b.value),j);M=er(M,o.cameraCurve);const k=Math.min(Math.max(o.auxDeadzone??.05,0),.6),N=r.mainBrush??{},w=rd(n,N.sources);let S=ld(Ws(w.value),k);S=er(S,o.auxCurve);const R=r.sideBrush??{},E=rd(n,R.sources);let A=ld(Ws(E.value),k);A=er(A,o.auxCurve);const L=Is(n,r.vacuum?.sources),V=Is(n,r.allAux?.sources),O=Is(n,r.mainReverse?.sources),z=Is(n,r.sideReverse?.sources),X=Is(n,r.driveMacro?.sources),G=Is(n,r.dockMacro?.sources),Q=Is(n,r.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:M,auxAxis:{main:S,side:A},buttons:{vacuum:L.pressed,allAux:V.pressed,mainReverse:O.pressed,sideReverse:z.pressed,driveMacro:X.pressed,dockMacro:G.pressed,nightVisionToggle:Q.pressed},sources:{drive:f.source,cameraTilt:b.source,mainBrush:w.source,sideBrush:E.source,vacuum:L.source,allAux:V.source,mainReverse:O.source,sideReverse:z.source,driveMacro:X.source,dockMacro:G.source,nightVisionToggle:Q.source}}}const ar=new Set;let Ia=null,Pa={pads:[],timestamp:0},$i=!1,Gi=null;function tx(){return kg().some(n=>n?.connected!==!1)}function kg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function bN(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0})),signature:wg(n)}}function co(){Pa={pads:kg().map(bN),timestamp:typeof performance<"u"?performance.now():Date.now()},ar.forEach(a=>a(Pa))}function Eg(){if(co(),Pa.pads.length===0){qd();return}Ia=requestAnimationFrame(Eg)}function nx(){Ia||(co(),Pa.pads.length!==0&&(Ia=requestAnimationFrame(Eg)))}function qd(){Ia&&(cancelAnimationFrame(Ia),Ia=null)}function Mg(n){if(ar.add(n),!$i&&typeof window<"u"){const a=()=>{co(),ar.size!==0&&(tx()?nx():qd())};window.addEventListener("gamepadconnected",a),window.addEventListener("gamepaddisconnected",a),Gi=a,$i=!0}return tx()?nx():co(),n(Pa),()=>{ar.delete(n),ar.size===0&&(qd(),$i&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Gi),window.removeEventListener("gamepaddisconnected",Gi),Gi=null,$i=!1))}}function yN(){const[n,a]=m.useState(Pa);return m.useEffect(()=>Mg(a),[]),n}const Ga="gamepad",Ks={x:0,y:0,boost:!1},Zs={main:0,side:0,vacuum:0},SN=100,jN=100;function id(n,a){return n&&a&&n.x===a.x&&n.y===a.y&&n.boost===a.boost}function od(n,a){return n&&a&&n.main===a.main&&n.side===a.side&&n.vacuum===a.vacuum}function NN(n){return n?Math.hypot(n.x||0,n.y||0):0}function wN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function AN(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function CN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,setServoAngle:u,runMacro:f,toggleNightVision:h,registerInputState:p}}=wt(),{value:g,save:x}=Qe("gamepad",ks),v=m.useRef(new Set),b=m.useRef(Ks),j=m.useRef(Zs),M=m.useRef({main:!1,side:!1}),k=m.useRef(new Map),N=m.useRef(0),w=m.useRef(0),S=m.useRef(0),R=m.useRef(null),E=m.useCallback(O=>{const z=O.signature??wg(O);g?.profiles?.[z]||v.current.has(z)||(v.current.add(z),x(X=>{const G=X??ks;if(G.profiles?.[z])return G;const Q=G?.defaults?.profile??Pn,P=Ag(O,Q);return{...G,profiles:{...G.profiles??{},[z]:P}}}))},[g?.profiles,x]),A=m.useCallback((O,z)=>{const X=k.current.get(O)||!1;return k.current.set(O,z),z&&!X},[]),L=m.useCallback((O,z)=>{const X=n.camera?.config;if(!X)return;const G=typeof performance<"u"?performance.now():Date.now(),Q=z?.cameraMode??"absolute",P=Math.max(1,Math.min(180,z?.cameraSensitivity??60));if(Q==="velocity"){const H=Math.min(50,G-S.current||16),J=O*P*(H/1e3);if(Math.abs(J)<.01)return;const ue=(typeof R.current=="number"?R.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof X.homeAngle=="number"?X.homeAngle:0)+J;u(ue),R.current=ue,S.current=G;return}const oe=typeof X.minAngle=="number"?X.minAngle:-45,ie=typeof X.maxAngle=="number"?X.maxAngle:45,$=typeof X.homeAngle=="number"?X.homeAngle:(oe+ie)/2,q=O<0?$+O*($-oe):$+O*(ie-$);typeof R.current=="number"&&Math.abs(R.current-q)<.35&&G-S.current<80||(S.current=G,R.current=q,u(q))},[u,n.camera?.angle,n.camera?.config]),V=m.useMemo(()=>g?.activeSignature??null,[g?.activeSignature]);return m.useEffect(()=>Mg(O=>{const z=AN(O.pads,V);if(!z){id(b.current,Ks)||(b.current=Ks,r(Ks,{source:Ga})),od(j.current,Zs)||(j.current=Zs,o(Zs)),k.current=new Map,M.current={main:!1,side:!1},N.current=0,w.current=0,p(Ga,{connected:!1});return}if(iN()){id(b.current,Ks)||(b.current=Ks,r(Ks,{source:Ga})),od(j.current,Zs)||(j.current=Zs,o(Zs)),k.current=new Map,M.current={main:!1,side:!1},p(Ga,{connected:!0,blocked:!0});return}E(z);const X=z.signature,G=g?.profiles?.[X]??g?.defaults?.profile??Pn,Q=Cg(z,G);if(!id(Q.driveVector,b.current)){const J=typeof performance<"u"?performance.now():Date.now();(NN(Q.driveVector)<.02||J-N.current>=SN)&&(b.current=Q.driveVector,N.current=J,r(Q.driveVector,{source:Ga}))}const P=G.calibration?.auxSideScale??.55,oe=Math.round(Math.min(Math.abs(Q.auxAxis.main),1)*127),ie=Math.round(Math.min(Math.abs(Q.auxAxis.side),1)*127),$=M.current.main?-oe:oe,q=M.current.side?-Math.round(ie*P):Math.round(ie*P);let H={main:Q.auxAxis.main!==0?$:0,side:Q.auxAxis.side!==0?q:0,vacuum:Q.buttons.vacuum?127:0};if(Q.buttons.allAux&&(H={main:127,side:127,vacuum:127}),!od(H,j.current)){const J=typeof performance<"u"?performance.now():Date.now();(wN(H)||J-w.current>=jN)&&(j.current=H,w.current=J,o(H))}Q.buttons.mainReverse&&A("mainReverse",!0)?M.current.main=!M.current.main:Q.buttons.mainReverse||A("mainReverse",!1),Q.buttons.sideReverse&&A("sideReverse",!0)?M.current.side=!M.current.side:Q.buttons.sideReverse||A("sideReverse",!1),Q.buttons.driveMacro&&A("driveMacro",!0)?(a("drive"),f("drive-sequence")):Q.buttons.driveMacro||A("driveMacro",!1),Q.buttons.dockMacro&&A("dockMacro",!0)?(a("dock"),f("seek-dock")):Q.buttons.dockMacro||A("dockMacro",!1),Q.buttons.nightVisionToggle&&A("nightVisionToggle",!0)?h():Q.buttons.nightVisionToggle||A("nightVisionToggle",!1),Math.abs(Q.cameraAxis)>.001&&L(Q.cameraAxis,G.calibration),p(Ga,{connected:!0,signature:X,id:z.id,index:z.index,axes:z.axes,buttons:z.buttons,drive:Q.driveVector,aux:H,cameraAxis:Q.cameraAxis,bindings:Q.sources})}),[V,E,g?.defaults?.profile,g?.profiles,A,L,p,f,o,r,a,h]),null}function Rg(n){const a=n?.sensors||{},r=a.oiMode?.label||"Unknown",o=r.toLowerCase(),u=a.chargingState?.label||"",f=!!a.chargingSources?.homeBase,h=f&&u.toLowerCase()!=="not charging"&&u!=="";return{driving:o==="full",docked:f,charging:h,dockedNotCharging:f&&!h,dockingInProgress:!f&&!h&&o==="passive",oiLabel:r,chargingLabel:u}}function Tg(n){const a=pn(n);return m.useMemo(()=>Rg(a),[a])}function Fa({label:n,value:a,tone:r="neutral"}){const o=r==="good"?"border-emerald-200 bg-emerald-600 text-white":r==="warn"?"border-amber-200 bg-amber-600 text-white":r==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return l.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:l.jsx("span",{className:"text-base font-semibold md:text-lg",children:a})})}function sx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function cd({label:n,tone:a}){const r=a==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":a==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return l.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${r}`,children:n})}function kN({instructions:n,onConfirm:a,onCancel:r,pending:o}){return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),l.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),l.jsx(Dd,{steps:n.steps,tone:"indigo"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[l.jsx("button",{type:"button",onClick:r,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),l.jsx("button",{type:"button",disabled:o,onClick:a,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 qg({layout:n="desktop",expand:a=!1,fill:r=!1,driveDockState:o,compactHeightClass:u=""}){const f=n==="mobile",{state:{roverId:h,keymap:p},actions:g}=wt(),x=pn(h),v=o??Rg(x),{driving:b,docked:j,charging:M,dockingInProgress:k}=v,[N,w]=m.useState(null),[S,R]=m.useState(!1),[E,A]=m.useState(!1),L=!h||N!==null,V=!h||N!==null,O=Rt(p?.driveMacro?.[0]),z=Rt(p?.dockMacro?.[0]),X={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"]},G="Click this button to initate auto-dock.",Q={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"]},P=j?"Docked":"Undocked",oe=j?"good":"bad",ie=M?"Charging":j?"Charging in 5s":"—",$=M?"good":j?"warn":"bad",q=async()=>{if(!(!h||N)){w("drive");try{g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ue){alert(Ue.message)}finally{w(null)}}},H=async()=>{if(!(!h||N)){R(!1),A(!1),w("drive");try{g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ue){alert(Ue.message)}finally{w(null)}}},J=async()=>{if(!(!h||N)){w("dock");try{g.setMode("dock"),await g.runMacro("seek-dock")}catch(Ue){alert(Ue.message)}finally{w(null),R(!1),A(!1)}}},ee=()=>{V||(A(!0),R(!0))},ue="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",T="text-center",_="items-center justify-between",K="items-center justify-center",ne=f?"text-sm font-semibold":"",me="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",ce="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",fe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",be="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=a||k,ze=xe?"h-full flex-1":r?"flex-1":"",Ee=f&&!xe?u:"",Te=f&&!xe?K:_,Oe=f&&!xe&&b&&j;if(!b&&!k)return l.jsxs("button",{type:"button",onClick:H,onContextMenu:Ue=>Ue.preventDefault(),disabled:L,className:`${ue} ${ze} ${Ee} ${T} ${Te} ${ne} ${me}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!f&&xe?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[O?l.jsx(sx,{label:O}):null,l.jsx(cd,{label:"Click to start",tone:"emerald"})]}):null]}),xe?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-emerald-50/90",children:Q.summary}),l.jsx(Dd,{steps:Q.steps,tone:"emerald"})]}):null]}),xe?l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:P,tone:oe}),l.jsx(Fa,{label:"Charge",value:ie,tone:$})]}):null]});if(k){const Ue={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return l.jsxs("button",{type:"button",disabled:L,onClick:q,onContextMenu:ht=>ht.preventDefault(),className:`${ue} ${ze} ${Ee} ${T} ${Te} ${ne} ${ce}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),xe?l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:l.jsx(cd,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?l.jsx("p",{className:"text-sm text-amber-50/90",children:Ue.summary}):null]}),xe?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:P,tone:oe}),l.jsx(Fa,{label:"Charge",value:ie,tone:$})]}),f?null:l.jsx(Dd,{steps:Ue.steps,tone:"amber"})]}):null]})}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",disabled:V,onClick:ee,onContextMenu:Ue=>Ue.preventDefault(),className:f?`flex w-full ${ue} ${Ee} ${T} ${Te} ${ne} ${Oe?be:fe}`:`${ue} ${ze} ${T} ${_} ${ne} ${fe}`,children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:Oe?"Docked!":"Dock and Charge"}),!f&&xe?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[z?l.jsx(sx,{label:z}):null,l.jsx(cd,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!f&&xe&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-indigo-50/90",children:G}),l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:P,tone:oe}),l.jsx(Fa,{label:"Charge",value:ie,tone:$})]}),l.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),E||!f&&S?l.jsx(kN,{instructions:X,pending:N==="dock",onCancel:()=>{A(!1),R(!1)},onConfirm:J}):null]})}function Dd({steps:n,tone:a="emerald"}){const r=a==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":a==="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=a==="emerald"?"text-emerald-200":a==="amber"?"text-amber-200":"text-indigo-200";return l.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${r}`,children:n.map((u,f)=>l.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[f+1,"."]}),l.jsx("span",{className:"align-top",children:u})]}),f<n.length-1?l.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},u))})}function ud(n){return typeof n=="boolean"}function Dg({nightVisionOn:n,disabled:a,onToggle:r,keyLabel:o,className:u="",heightClass:f=""}){const[h,p]=m.useState(ud(n)?n:null);m.useEffect(()=>{ud(n)&&p(n)},[n]);const g=ud(h),x=g?h:!1,v=g?x?"On":"Off":"—",b=x?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",j=()=>{if(a)return;const k=g?!x:!0;p(k),r?.(k)},M=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",x?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",f,u].filter(Boolean).join(" "),[u,x,f]);return l.jsxs("button",{type:"button",onClick:j,onContextMenu:k=>k.preventDefault(),disabled:a,"aria-pressed":x,className:M,children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?l.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:v})]})}function dd(n){const a=Number(n);return!Number.isFinite(a)||a<=0?0:Math.min(5e3,Math.round(a))}function _g({disabled:n,onStart:a,onStop:r,keyLabel:o,active:u,heat:f=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:g=!1,compactSettings:x=!1}){const[v,b]=m.useState(!1),[j,M]=m.useState(p),{value:k,save:N}=Qe("horn",ea),[w,S]=m.useState(k?.waveform||ea.waveform),[R,E]=m.useState(()=>[...Array.isArray(k?.freqs)?k.freqs:ea.freqs,0,0,0,0].slice(0,4).map(q=>dd(q)));m.useEffect(()=>{S(k?.waveform||ea.waveform),Array.isArray(k?.freqs)&&E([...k.freqs,0,0,0,0].slice(0,4).map($=>dd($)))},[k?.freqs,k?.waveform]);const A=!!u,L=Math.max(0,Math.min(1,Number(f)||0)),V=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",A?"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,A]),O=()=>{n||v||(b(!0),a?.())},z=()=>{v&&(b(!1),r?.())};m.useEffect(()=>{!A&&v&&b(!1)},[A,v]);const X=w==="sine"?"sine":"saw",G=m.useCallback($=>{const q=$.target.value==="sine"?"sine":"saw";S(q),N(H=>({...H??{},waveform:q}))},[N]),Q=m.useCallback(($,q)=>{E(H=>{const J=[...H];return J[$]=dd(q),N(ee=>({...ee??{},freqs:J})),J})},[N]),P=$=>{if(n)return;const q=$.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||($.preventDefault(),O())},oe=$=>{const q=$.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||($.preventDefault(),z())},ie=g?l.jsx("button",{type:"button",onClick:$=>{$.preventDefault(),M(q=>!q)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:j?"Hide":"Settings"}):null;return l.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:P,onPointerUp:oe,onPointerLeave:z,onPointerCancel:z,onContextMenu:$=>$.preventDefault(),onBlur:z,className:V,children:[l.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}%)`}}),l.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${A?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),l.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[l.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[l.jsx("span",{children:"Horn"}),o?l.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),ie,l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${A?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:A?"Honk":"Hold"})]}),j?x?l.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:X,onChange:G,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:R.map(($,q)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:q+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:H=>Q(q,H.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${q}`))})]}):l.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:X,onChange:G,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),R.map(($,q)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:q+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:$,onChange:H=>Q(q,H.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${q}`))]}):null]})}function Fi(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function ax({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Og({value:n,min:a,max:r,step:o=.5,label:u="Camera Tilt",orientation:f="horizontal",onChange:h,onCommit:p,throttleMs:g=0,disabled:x=!1,keyDownLabel:v,keyUpLabel:b,className:j="",labelRowClass:M="",labelClass:k="",valueClass:N="",sliderClass:w="",endpointClass:S="",endpointLabelClass:R="",accentClass:E="",showValue:A=!0,showEndpoints:L}){const V=f==="vertical",z=typeof L=="boolean"?L:!V,[X,G]=m.useState(n),Q=m.useRef(!1),P=m.useRef(null);m.useEffect(()=>{Q.current||G(n)},[n]),m.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);const oe=J=>{if(h){if(g>0){P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{h(J)},g);return}h(J)}},ie=J=>{const ee=Number.parseFloat(J.target.value);Number.isNaN(ee)||(Q.current=!0,G(ee),oe(ee))},$=()=>{Q.current=!1,P.current&&(clearTimeout(P.current),P.current=null),p?p(X):g>0&&h?.(X)};if(typeof a!="number"||typeof r!="number")return null;const q=[V?"h-28 w-5":"w-full",E,w].filter(Boolean).join(" "),H=l.jsx("input",{type:"range",orient:V?"vertical":void 0,min:a,max:r,step:o,value:Number.isFinite(X)?X:a,onChange:ie,onMouseUp:$,onTouchEnd:$,onPointerUp:$,disabled:x,className:q,style:V?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return V?l.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${j}`.trim(),children:[A?l.jsx("div",{className:`flex flex-col items-center ${M}`.trim(),children:l.jsx("span",{className:N,children:Fi(n)})}):null,l.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[l.jsx("span",{className:k,children:u}),H]})]}):l.jsxs("div",{className:`space-y-0.5 ${j}`.trim(),children:[l.jsxs("div",{className:`flex items-center justify-between ${M}`.trim(),children:[l.jsx("span",{className:k,children:u}),A?l.jsx("span",{className:N,children:Fi(n)}):null]}),l.jsxs("div",{children:[H,z?l.jsxs("div",{className:`mt-0 flex items-center justify-between ${S}`.trim(),children:[l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[v?l.jsx(ax,{label:v}):null,Fi(a)]}),l.jsxs("span",{className:`flex items-center gap-0.5 ${R}`.trim(),children:[Fi(r),b?l.jsx(ax,{label:b}):null]})]}):null]})]})}function EN({disabled:n,layout:a,radius:r,onMove:o,onStop:u}){const f=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[g,x]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{h.current=null,x({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),u?.()},[u]),b=m.useCallback(N=>{if(n||h.current!==null)return;N.preventDefault();const w=f.current;if(!w)return;const S=w.getBoundingClientRect(),R=N.clientX-S.left,E=N.clientY-S.top;p.current={x:R,y:E},h.current=N.pointerId,w.setPointerCapture?.(N.pointerId),x({active:!0,base:{x:R,y:E},knob:{x:0,y:0}})},[n]),j=m.useCallback(N=>{if(n||h.current!==N.pointerId)return;N.preventDefault();const w=f.current;if(!w)return;const S=w.getBoundingClientRect(),R=N.clientX-S.left,E=N.clientY-S.top,A=R-p.current.x,L=E-p.current.y,V=Math.min(Math.hypot(A,L),r),O=Math.atan2(L,A),z=Math.cos(O)*V,X=Math.sin(O)*V,G={x:Ja(z/r),y:Ja(-X/r),boost:!1};x(Q=>({...Q,knob:{x:z,y:X}})),o?.(G)},[n,o,r]),M=m.useCallback(N=>{if(h.current!==N.pointerId)return;N.preventDefault(),f.current?.releasePointerCapture?.(N.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),l.jsxs("div",{ref:f,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:j,onPointerUp:M,onPointerLeave:M,onPointerCancel:M,onContextMenu:N=>N.preventDefault(),children:[!g.active&&l.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[l.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),l.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),g.active&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:g.base.x,top:g.base.y}}),l.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:g.base.x+g.knob.x,top:g.base.y+g.knob.y}})]})]})}function lx({id:n,label:a,values:r,color:o,disabled:u,onPress:f,onRelease:h}){return l.jsx("button",{type:"button",disabled:u,onPointerDown:p=>{p.preventDefault(),f(n,r)},onPointerUp:()=>h(n),onPointerLeave:()=>h(n),onPointerCancel:()=>h(n),onContextMenu:p=>p.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:a})}const Yi="mobile-joystick",MN=80,RN=.15,TN={main:0,side:0,vacuum:0},qN={main:127,side:127,vacuum:127},DN={main:-127,side:-127,vacuum:-127};function _N({layout:n}){const{state:{roverId:a},actions:{setDriveVector:r,registerInputState:o}}=wt(),u=Tg(a),f=u.docked&&!u.driving,h=f||u.dockingInProgress,p=!a,g=MN,x=RN,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(v.current={x:0,y:0,boost:!1})},[p]);const b=m.useCallback((N={})=>{if(p)return;const w={x:Ja(N.x??0),y:Ja(N.y??0),boost:!!N.boost},S={x:v.current.x+(w.x-v.current.x)*(1-x),y:v.current.y+(w.y-v.current.y)*(1-x),boost:w.boost};v.current=S,r(S,{source:Yi}),o(Yi,{vector:S,lastEvent:"move"})},[p,o,r,x]),j=m.useCallback(()=>{if(p)return;const N={x:0,y:0,boost:!1};v.current=N,r(N,{source:Yi}),o(Yi,{vector:N,lastEvent:"stop"})},[p,o,r]),k=`flex h-full flex-col gap-0.5 text-slate-100 ${f?"max-h-screen self-start":""}`;return l.jsxs("div",{className:k,children:[l.jsx(qg,{layout:"mobile",expand:h,driveDockState:u,compactHeightClass:"min-h-[5rem]"}),h?null:l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(EN,{disabled:p,layout:n,radius:g,onMove:b,onStop:j})})]})}function ON({layout:n}){const{state:{roverId:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:h,setAuxMotors:p,startHorn:g,stopHorn:x}}=wt(),v=!a,b=m.useRef(null),j=r?.config,M=!!(a&&r?.enabled&&j),k=!!(a&&u?.nightVision),N=u?.nightVisionState,w=!!(a&&u?.horn),S=o?.overheated,R=typeof j?.minAngle=="number"?j.minAngle:-45,E=typeof j?.maxAngle=="number"?j.maxAngle:45,A=typeof r?.angle=="number"?r.angle:typeof j?.homeAngle=="number"?j.homeAngle:(R+E)/2,L=m.useCallback(z=>{k&&h(z)},[k,h]),V=m.useCallback((z,X)=>{v||(b.current=z,p(X))},[v,p]),O=m.useCallback(z=>{v||b.current===z&&(b.current=null,p(TN))},[v,p]);return l.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[l.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[l.jsx(lx,{id:"aux-vac-forward",label:"Vacuum Forward",values:qN,color:"bg-fuchsia-600",disabled:v,onPress:V,onRelease:O}),l.jsx(lx,{id:"aux-vac-backward",label:"Vacuum Backward",values:DN,color:"bg-fuchsia-800",disabled:v,onPress:V,onRelease:O})]}),l.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[M?l.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:l.jsx(Og,{value:A,min:R,max:E,step:.5,onChange:f,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,k?l.jsx(Dg,{nightVisionOn:N?.nightVisionOn,disabled:v,onToggle:L,heightClass:"h-full"}):null]}),l.jsx("div",{className:"min-h-0",children:w?l.jsx(_g,{disabled:v||S,onStart:g,onStop:x,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function uo({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx(ON,{layout:n})})}function fo({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx(_N,{layout:n==="landscape"?"landscape":"portrait"})})}function BN({swapColumns:n=!1}){const a="h-[min(60svh,24rem)]",r=n?l.jsx(fo,{layout:"portrait",className:a}):l.jsx(uo,{layout:"portrait",className:a}),o=n?l.jsx(uo,{layout:"portrait",className:a}):l.jsx(fo,{layout:"portrait",className:a});return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r,o]})})}function LN(n=[],a={}){const r=en(),{enabled:o=!0,version:u=null}=a,[f,h]=m.useState({}),p=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,j]=m.useState(0),M=m.useRef(new Map),k=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>j(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({})},[x]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,S=(E={},A)=>{if(N||!E.id||!A)return;const L=A.byteLength??A.length??0,V=Date.now(),O=M.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},z={count:O.count+1,totalBytes:O.totalBytes+L,lastLogAt:O.lastLogAt};if(k&&(!z.lastLogAt||V-z.lastLogAt>=1e4)){const P=z.count?z.totalBytes/z.count:0;console.log("[roomCamera]",E.id,`frame=${L}B`,`avg=${Math.round(P)}B`,`count=${z.count}`),z.lastLogAt=V}M.current.set(E.id,z);const X=new Blob([A],{type:"image/jpeg"}),G=URL.createObjectURL(X),Q=p.current.get(E.id);Q&&URL.revokeObjectURL(Q),p.current.set(E.id,G),h(P=>({...P,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:G}}))},R=(E={})=>{N||!E.id||h(A=>({...A,[E.id]:{...A[E.id]||{},status:E.error?"error":A[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||A[E.id]?.ts||null,objectUrl:A[E.id]?.objectUrl||null}}))};return r.on("roomCamera:frame",S),r.on("roomCamera:status",R),r.emit("roomCamera:subscribe",{ids:w},(E={})=>{E.error}),()=>{N=!0,r.emit("roomCamera:unsubscribe",{ids:w}),r.off("roomCamera:frame",S),r.off("roomCamera:status",R),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[r,x,o,b,k]),f}function zN({feed:n,label:a}){const[r,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(f=>!f))},[n?.ts,n?.objectUrl]);const u=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return l.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?l.jsx("img",{src:n.objectUrl,alt:a,className:"h-full w-full object-cover"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),l.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:a}),l.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[l.jsx("span",{className:`h-2 w-2 rounded-full ${r?"bg-emerald-400":"bg-slate-500"}`}),l.jsx("span",{children:u})]})]})}function UN(){return l.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),l.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const Bg=["horizontal","vertical"];function fd(n,a){return Bg.includes(n)?n:a}function rf({defaultOrientation:n="horizontal",orientation:a,hideLayoutToggle:r=!1,hideHeader:o=!1,panelId:u=null}){const f=de(N=>N.session?.roomCameras||[]),h=LN(f.map(N=>({id:N.id}))),{value:p,save:g}=Qe("roomCameraPanels",{}),[x,v]=m.useState(()=>fd(u?p?.[u]:n,"horizontal"));m.useEffect(()=>{if(!u)return;const N=p?.[u];N&&v(fd(N,"horizontal"))},[u,p?.[u]]);const b=a?fd(a,"horizontal"):x,j=b==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",M=!r&&!a&&f.length>0,k=N=>{v(N),u&&g(w=>({...w||{},[u]:N}))};return f.length===0?l.jsx(UN,{}):l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&l.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room cameras"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:M&&l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-500",children:"Layout:"}),l.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Bg.map(N=>l.jsx("button",{type:"button",className:`px-1 py-0.5 ${b===N?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>k(N),children:N==="vertical"?"Vertical":"Grid"},N))})]})})]}),l.jsx("div",{className:j,children:f.map(N=>{const w=h[N.id]||null;return l.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:l.jsx(zN,{feed:w,label:N.name||N.id})},N.id)})})]})}function of(){const n=de(r=>r.logs),a=m.useMemo(()=>n.slice().reverse(),[n]);return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Server logs"}),l.jsx("span",{children:n.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?l.jsx("p",{children:"No logs yet."}):a.map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.timestamp})," ",l.jsxs("span",{className:"text-lime-400",children:["[",r.level,"]"]})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{children:r.message})]},r.id))})]})}const HN={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function VN(n){if(typeof btoa=="function")return btoa(n);if(typeof Buffer<"u")return Buffer.from(n).toString("base64");throw new Error("No base64 encoder available")}function $N(n){if(!n)return{};const a=`${n}:${n}`;return{Authorization:`Basic ${VN(a)}`}}class rx{constructor({url:a,token:r,video:o,onStatus:u,audioOnly:f=!1,receiveAudio:h=!0}){this.url=a,this.token=r,this.video=o,this.audioOnly=f,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=u}notify(a,r){typeof this.onStatus=="function"&&this.onStatus(a,r)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const a=new RTCPeerConnection(HN);this.pc=a;const r=new MediaStream;a.ontrack=o=>{o.streams[0]?.getTracks().forEach(u=>r.addTrack(u)),this.video.srcObject=r,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?a.addTransceiver("audio",{direction:"recvonly"}):(a.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&a.addTransceiver("audio",{direction:"recvonly"})),a.onconnectionstatechange=()=>{this.notify(a.connectionState)},a.oniceconnectionstatechange=()=>{const o=a.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await a.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await a.setLocalDescription(o);const u=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...$N(this.token)},body:o.sdp,signal:this.abortController.signal});if(!u.ok)throw new Error(`WHEP request failed: ${u.status}`);const f=await u.text();await a.setRemoteDescription({type:"answer",sdp:f}),a.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(a=>a.track?.stop()),this.pc.getReceivers().forEach(a=>a.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function GN(n){if(!n)return null;if(typeof n=="string"){const a=String(n).trim();return a?{type:"rover",id:a,key:a}:null}if(typeof n=="object"){if(n.type&&n.id){const a=String(n.id);let r=n.key;return r||(r=n.type==="room"?`room:${a}`:a),{type:n.type,id:a,key:r}}if(n.roverId){const a=String(n.roverId);return{type:"rover",id:a,key:n.key||a}}if(n.roomCameraId){const a=String(n.roomCameraId);return{type:"room",id:a,key:n.key||`room:${a}`}}}return null}function FN(n=[]){const a=new Set,r=[];return n.forEach(o=>{!o?.key||a.has(o.key)||(a.add(o.key),r.push(o))}),r.sort((o,u)=>o.key.localeCompare(u.key))}function _d(n=[],a={}){const r=en(),{enabled:o=!0,version:u=null}=a,[f,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(n)?FN(n.map(GN).filter(Boolean)):[],[n]),g=m.useMemo(()=>{const M=p.map(k=>`${k.type}:${k.id}:${k.key}`).join("|");return u?`${M}|v:${u}`:M},[p,u]),x=m.useRef([]),[v,b]=m.useState(0);return m.useEffect(()=>{if(!r)return;const M=()=>b(k=>k+1);return r.on("connect",M),()=>{r.off("connect",M)}},[r]),m.useEffect(()=>{x.current=p},[p]),m.useEffect(()=>{if(!g||!o){h({});return}const M=x.current;let k=!1;function N(w){const S=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};r.emit("video:request",S,(R={})=>{k||h(E=>({...E,[w.key]:R}))})}return M.forEach(w=>{N(w)}),()=>{k=!0}},[r,g,o,v]),m.useMemo(()=>{if(!g||!o)return{};const M={};return p.forEach(k=>{f[k.key]&&(M[k.key]=f[k.key])}),M},[g,f,p])}function Lg(n=[],a={}){const r=en(),{enabled:o=!0,version:u=null}=a,[f,h]=m.useState({}),p=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,j]=m.useState(0),M=m.useRef(new Map),k=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>j(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({})},[x]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,S=(E={},A)=>{if(N||!E.id||!A)return;const L=A.byteLength??A.length??0,V=Date.now(),O=M.current.get(E.id)||{count:0,totalBytes:0,lastLogAt:0},z={count:O.count+1,totalBytes:O.totalBytes+L,lastLogAt:O.lastLogAt};if(k&&(!z.lastLogAt||V-z.lastLogAt>=1e4)){const P=z.count?z.totalBytes/z.count:0;console.log("[roverSnapshot]",E.id,`frame=${L}B`,`avg=${Math.round(P)}B`,`count=${z.count}`),z.lastLogAt=V}M.current.set(E.id,z);const X=new Blob([A],{type:"image/jpeg"}),G=URL.createObjectURL(X),Q=p.current.get(E.id);Q&&URL.revokeObjectURL(Q),p.current.set(E.id,G),h(P=>({...P,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:G}}))},R=(E={})=>{N||!E.id||h(A=>({...A,[E.id]:{...A[E.id]||{},status:E.error?"error":A[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||A[E.id]?.ts||null,objectUrl:A[E.id]?.objectUrl||null}}))};return r.on("roverSnapshot:frame",S),r.on("roverSnapshot:status",R),r.emit("roverSnapshot:subscribe",{ids:w},(E={})=>{E.error}),()=>{N=!0,r.emit("roverSnapshot:unsubscribe",{ids:w}),r.off("roverSnapshot:frame",S),r.off("roverSnapshot:status",R),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[r,x,o,b,k]),f}const ix=2e3,YN=3e3,XN=3e3,QN=40,IN=1e3;function dr({roverId:n=null,sessionInfo:a=null,audioSessionInfo:r=null,videoMode:o=null,snapshotFeed:u=null,label:f,forceMute:h=!1,sensors:p}){const g=de(Ne=>Ne.session?.assignment?.roverId??null),x=n??g,v=de(Ne=>Ne.session?.mode||null),b=de(Ne=>!!Ne.session?.isLocalNetwork),j=de(Ne=>x&&Array.isArray(Ne.session?.roster)&&Ne.session.roster.find(st=>String(st.id)===String(x))||null),M=!!j?.media?.audioPublishUrl,k=o?o==="whep":b,N=m.useMemo(()=>!x||!k?[]:[{type:"rover",id:x,key:x},...M?[{type:"rover",id:`${x}-audio`,key:`${x}-audio`}]:[]],[x,k,M]),w=_d(N,{enabled:!!(x&&k),version:v}),S=a??(x&&w[x]||null),R=r??(x&&M&&w[`${x}-audio`]||null),E=Lg(x?[x]:[],{enabled:!!(x&&!S?.url),version:v}),A=u??(x&&E[x]||null),L=f||j?.name||(x?`Rover ${x}`:"Rover"),V=pn(x),O=p??V?.sensors??null,z=m.useRef(null),X=m.useRef(null),G=m.useRef(null),Q=m.useRef(null),P=m.useRef(null),oe=m.useRef(null),ie=m.useRef(null),$=m.useRef(null),[q,H]=m.useState("idle"),[J,ee]=m.useState(null),[ue,T]=m.useState("idle"),[_,K]=m.useState(null),[ne,me]=m.useState(0),[ce,fe]=m.useState(0),[be,ge]=m.useState(!0),xe=!!R?.url,ze=o==="snapshot"||!o&&!S?.url,{value:Ee}=Qe("audio",it),Te=Number.isFinite(Ee?.masterVolume)?Ee.masterVolume:it.masterVolume,Oe=Number.isFinite(Ee?.roverVolume)?Ee.roverVolume:it.roverVolume,Ue=typeof Ee?.mainBrushDuckEnabled=="boolean"?Ee.mainBrushDuckEnabled:typeof Ee?.autoLevelEnabled=="boolean"?Ee.autoLevelEnabled:it.mainBrushDuckEnabled,ht=Number.isFinite(Ee?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ee.mainBrushDuckAmount)):it.mainBrushDuckAmount,re=Math.max(0,Math.min(1,Te*Oe)),ae=!!((Number(O?.mainBrushCurrentMa)||0)>QN||O?.wheelOvercurrents?.mainBrush),Se=Ue&&ae?1-ht:1,pe=Math.max(0,Math.min(1,re*Se)),je=m.useMemo(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has("debugAudio"),[]),Ae=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{Ae.current={hasDedicatedAudio:xe,audioUrl:R?.url||null,mainBrushDuckEnabled:Ue,mainBrushDuckAmount:ht,mainBrushActive:ae,baseRoverGain:re,effectiveRoverGain:pe}},[xe,R?.url,Ue,ht,ae,re,pe]);const Re=m.useCallback((Ne,st={})=>{if(!je)return;const Ke=X.current,ke=Ae.current,He={event:Ne,ts:Date.now(),roverLabel:L||null,hasDedicatedAudio:ke.hasDedicatedAudio,audioUrl:ke.audioUrl,mainBrushDuckEnabled:ke.mainBrushDuckEnabled,mainBrushDuckAmount:ke.mainBrushDuckAmount,mainBrushActive:ke.mainBrushActive,baseRoverGain:ke.baseRoverGain,effectiveRoverGain:ke.effectiveRoverGain,element:Ke?{muted:Ke.muted,volume:Ke.volume,paused:Ke.paused,ended:Ke.ended,readyState:Ke.readyState,networkState:Ke.networkState}:null,...st};try{console.log(`[AudioDebug] ${Ne} ${JSON.stringify(He)}`)}catch{console.log("[AudioDebug]",Ne,He)}},[je,L]);m.useEffect(()=>{Re("settings/update")},[Re]);const le=m.useCallback(()=>{clearTimeout(G.current),G.current=setTimeout(()=>me(Date.now()),ix)},[]),he=m.useCallback(()=>{clearTimeout(Q.current),Q.current=setTimeout(()=>fe(Date.now()),ix)},[]),De=m.useCallback(async()=>{const Ne=z.current;if(Ne)try{Ne.muted=!0,await Ne.play()}catch{}},[]),Tt=m.useCallback((Ne=0)=>{if(h||xe)return;clearTimeout(oe.current);const st=()=>{clearTimeout(oe.current),oe.current=setTimeout(()=>{h||Ke()},YN)},Ke=async()=>{const ke=z.current;if(ke)try{await De(),ke.muted=!1,await ke.play(),ge(!1)}catch{ke.muted=!0,ge(!0),st()}};oe.current=setTimeout(Ke,Ne)},[De,h,xe]);m.useEffect(()=>()=>{clearTimeout(G.current),clearTimeout(Q.current),clearTimeout(oe.current),clearInterval(P.current),ie.current&&(cancelAnimationFrame(ie.current),ie.current=null)},[]),m.useEffect(()=>{q==="playing"&&Tt(0)},[q,Tt]),m.useEffect(()=>{ze&&(H("snapshot"),ee(null))},[ze]),m.useEffect(()=>{if(ze||!S?.url||!z.current)return;let Ne=!0,st;const Ke=setTimeout(()=>ge(!0),0),ke=(He,Pe)=>{Ne&&(Re("video/status",{nextStatus:He,info:Pe||null}),H(He),ee(Pe||null),He==="playing"&&De(),["error","failed","disconnected","closed"].includes(He)&&le())};return st=new rx({url:S.url,token:S.token,video:z.current,receiveAudio:!xe,onStatus:ke}),st.start().catch(He=>{Ne&&(H("error"),ee(He.message),le())}),()=>{Ne=!1,clearTimeout(Ke),st?.stop()}},[ze,S?.url,S?.token,ne,le,De,xe,Re]),m.useEffect(()=>{q==="stopped"&&S?.url&&le()},[q,S?.url,le]),m.useEffect(()=>{const Ne=X.current;if(!Ne||!R?.url){Re("route/no-audio-url"),$.current=null;return}const st=Math.max(0,Math.min(1,pe)),Ke=$.current==null?Math.max(0,Math.min(1,Ne.volume)):$.current;if(ie.current&&(cancelAnimationFrame(ie.current),ie.current=null),st>Ke){const ke=performance.now(),He=Ke,Pe=st-He,Ms=na=>{const yt=Math.min(1,(na-ke)/IN),jn=He+Pe*yt;Ne.volume=jn,$.current=jn,yt<1?ie.current=requestAnimationFrame(Ms):ie.current=null};ie.current=requestAnimationFrame(Ms)}else Ne.volume=st,$.current=st;Re("route/direct",{elementVolume:st,duckEnabled:Ue,mainBrushActive:ae,duckAmount:ht})},[R?.url,pe,Ue,ae,ht,Re]),m.useEffect(()=>{if(!R?.url||!X.current)return;let Ne=!0,st;const Ke=(ke,He)=>{Ne&&(Re("audio/status",{nextStatus:ke,info:He||null}),K(He||(ke==="connected"?"connected":null)),T(Pe=>ke==="connected"&&(Pe==="playing"||Pe==="connecting")||ke==="new"?Pe:ke),["error","failed"].includes(ke)&&he())};return st=new rx({url:R.url,token:R.token,video:X.current,audioOnly:!0,onStatus:Ke}),st.start().catch(ke=>{Ne&&(T("error"),K(ke.message),he())}),()=>{Ne=!1,st?.stop()}},[R?.url,R?.token,ce,he,Re]),m.useEffect(()=>{const Ne=X.current;if(!R?.url||!Ne){clearInterval(P.current);return}if(!["connecting","connected","playing","paused"].includes(ue)){clearInterval(P.current);return}const Ke=async()=>{const ke=X.current;ke&&(ke.muted=!1,!(!ke.paused&&!ke.ended)&&(Re("retry/play-attempt"),ke.play().then(()=>{Re("retry/play-ok"),T(He=>He==="connected"?"playing":He),K(He=>He==="paused"?null:He)}).catch(He=>{Re("retry/play-fail",{error:He?.message}),K(Pe=>Pe||He?.message||"autoplay blocked")})))};return Ke(),P.current=setInterval(Ke,XN),()=>clearInterval(P.current)},[R?.url,ue,Re]),m.useEffect(()=>{const Ne=X.current;if(!Ne)return;const st=()=>{Re("element/play"),T(yt=>yt==="error"?yt:"playing"),K(null)},Ke=()=>{Re("element/pause"),T(yt=>["error","failed","disconnected","closed","stopped"].includes(yt)?yt:"paused"),K(yt=>yt||"paused")},ke=()=>{Re("element/ended"),T(yt=>yt==="error"?yt:"stopped"),K(yt=>yt||"ended")},He=()=>{const{error:yt}=Ne,jn=yt?.message||"audio error";Re("element/error",{error:jn}),T("error"),K(jn)},Pe=()=>Re("element/waiting"),Ms=()=>Re("element/canplay"),na=()=>Re("element/stalled");return Ne.addEventListener("play",st),Ne.addEventListener("pause",Ke),Ne.addEventListener("ended",ke),Ne.addEventListener("error",He),Ne.addEventListener("waiting",Pe),Ne.addEventListener("canplay",Ms),Ne.addEventListener("stalled",na),()=>{Ne.removeEventListener("play",st),Ne.removeEventListener("pause",Ke),Ne.removeEventListener("ended",ke),Ne.removeEventListener("error",He),Ne.removeEventListener("waiting",Pe),Ne.removeEventListener("canplay",Ms),Ne.removeEventListener("stalled",na)}},[R?.url,Re]);const qt=A?.error?`Error: ${A.error}`:A?.objectUrl?"snapshot":A?.status||"waiting",nl=ze?qt:S?.url?q==="error"?`Error: ${J||"unknown"}`:J?`${q} (${J})`:q:"waiting",Ft=R?.error?`Error: ${R.error}`:R?.url?ue==="error"?`Error: ${_||"unknown"}`:_?`${ue} (${_})`:ue:null;return l.jsxs(l.Fragment,{children:[ze?A?.objectUrl?l.jsx("img",{src:A.objectUrl,alt:L,className:"h-full w-full object-contain",draggable:!1}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):l.jsx("video",{ref:z,muted:h||be||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),l.jsx("audio",{ref:X,autoPlay:!0,hidden:!0}),l.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-20 font-medium text-slate-100 text-[0.65rem]",children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",nl]}),Ft?l.jsxs("span",{children:["Audio: ",Ft]}):null]})})]})}const KN={discord:fg,kofi:Hp,"ko-fi":Hp,wiki:kj,throne:Ej},ZN={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 JN(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const a=document.createElement("style");a.id=n,a.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(a)},[])}function PN(n,a){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof a=="string"&&a.trim()?a.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function So({id:n,label:a,url:r,className:o=""}){if(!r)return null;JN();const u=PN(n,a),f=KN[u]||Mj,h=ZN[u]||null,p=a||n||"Link";return l.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[l.jsx(f,{className:"mr-0"}),p]})}function WN({roverId:n=null,mobileHud:a=!1,discordUrl:r=null}){const o=de(ae=>ae.session?.assignment?.roverId??null),u=n??o,f=de(ae=>ae.session?.mode||null),h=de(ae=>ae.session?.roster??[]),p=de(ae=>ae.session?.users??[]),g=de(ae=>ae.session?.turnQueues??{}),x=de(ae=>ae.session?.socketId||null),v=de(ae=>ae.session?.activeDrivers??{}),b=de(ae=>(ae.session?.socials||[]).find(je=>String(je?.id||je?.label||"").toLowerCase()==="discord")?.url||null||ae.session?.discord?.invite||null),{state:{lastControlIntentAt:j}}=wt(),M=r||b,[k,N]=m.useState(()=>Date.now()),[w,S]=m.useState(!1),[R,E]=m.useState(null),[A,L]=m.useState(!1),[V,O]=m.useState(0),z=m.useRef({initialized:!1,roverId:null,activeDriverId:null}),X=m.useRef(j||0),G=a?"text-[0.5rem]":"text-[0.7rem]",Q=a?"px-0.5 py-0.25":"px-1 py-0.5",P=a?"text-3xl":"text-5xl",oe=a?"text-xs":"text-sm",ie=a?"text-[0.55rem]":"text-[0.75rem]",$=a?"px-4 py-3":"px-6 py-4",q=u?g?.[u]:null,H=u?v?.[u]:null,J=!!(x&&H===x),ee=m.useMemo(()=>{const ae=q?.queue||[];if(!ae.length||!q?.current||ae.length<=1)return null;const Se=ae.findIndex(pe=>pe===q.current);return Se===-1?ae[0]||null:ae[(Se+1)%ae.length]||null},[q?.queue,q?.current]),ue=!!(x&&ee===x),T=q?.deadline||null,_=q?.idleDeadline||null,K=T?T-k:null,ne=_?_-k:null,me=f==="turns",ce=h.length,fe=m.useMemo(()=>{const ae=new Set;return p.forEach(Se=>{if(String(Se?.role||"")==="spectator")return;const je=String(Se?.roverId||"").trim(),Ae=String(Se?.socketId||"").trim();!je||!Ae||ae.add(Ae)}),ae.size},[p]),be=me&&fe>ce,ge=me&&ue&&K!=null&&K<=5e3&&K>0,xe=me&&!J,ze=xe&&!ge&&be,Ee=K!=null&&Number.isFinite(K)?Math.max(0,Math.ceil(K/1e3)):null,Te=ne!=null&&Number.isFinite(ne)?Math.max(0,Math.ceil(ne/1e3)):null,Oe=m.useMemo(()=>!me||!J?null:Ee!=null?`${Ee}s left`:"Your turn",[me,J,Ee]),Ue=m.useMemo(()=>!xe||!ue||Ee==null?null:`${Ee} seconds until your turn.`,[xe,ue,Ee]),ht=J&&typeof Te=="number",re=A;return m.useEffect(()=>{if(f!=="turns")return;const ae=setInterval(()=>N(Date.now()),250);return()=>clearInterval(ae)},[f]),m.useEffect(()=>{if(f!=="turns"){S(!1),E(null),z.current={initialized:!1,roverId:null,activeDriverId:null};return}const ae=z.current,Se=H||null;if(!x||!u){S(!1),E(null),z.current={initialized:!1,roverId:null,activeDriverId:null};return}if(!ae.initialized||ae.roverId!==u){z.current={initialized:!0,roverId:u,activeDriverId:Se};return}!!ae.activeDriverId&&ae.activeDriverId!==x&&Se===x?(S(!0),E(Date.now())):Se!==x&&w&&(S(!1),E(null)),z.current={initialized:!0,roverId:u,activeDriverId:Se}},[H,f,u,x,w]),m.useEffect(()=>{!w||!R||j>R&&S(!1)},[j,w,R]),m.useEffect(()=>{const ae=Number(X.current)||0,Se=Number(j)||0;Se>ae&&xe&&O(Date.now()),X.current=Se},[j,xe]),m.useEffect(()=>{if(!xe||!V)return;L(!0);const ae=setTimeout(()=>L(!1),650);return()=>clearTimeout(ae)},[xe,V]),l.jsxs(l.Fragment,{children:[w?l.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:l.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${$}`,children:[l.jsx("div",{className:`font-semibold text-amber-200 ${P}`,children:"IT IS YOUR TURN!"}),l.jsx("div",{className:`text-amber-200/80 ${oe}`,children:"Start driving!"}),ht?l.jsxs("div",{className:`text-red-100/90 ${ie}`,children:["Idle skip in ",Te,"s"]}):null]})}):null,Oe?l.jsx("div",{className:`pointer-events-none absolute bottom-1 left-1 rounded border ${re?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${Q} ${G}`,children:Oe}):null,xe?l.jsx("div",{className:"pointer-events-none absolute bottom-1 left-1 z-40",children:l.jsxs("div",{className:`w-fit rounded border ${A?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${a?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:A?"text-[0.82rem] font-semibold text-red-50":"text-[0.82rem] font-semibold text-white",children:"Not your turn to drive!"}),Ue?l.jsx("div",{className:A?"text-red-100/95":"text-amber-100",children:Ue}):null,ze?l.jsx("div",{className:A?"text-red-100/90":"text-amber-200/85",children:"Video switched to preview mode to save bandwidth."}):null,l.jsx("div",{className:"pointer-events-auto mt-0.5",children:l.jsx(So,{id:"discord",label:"Join our Discord while you wait!",url:M})})]})}):null]})}const ew=Ot.memo(WN);function zg(){const{value:n,save:a}=Qe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,u=>{a({hudMapDesktop:!!u})}]}function jo(n){return Math.max(0,Math.min(1,n))}function Ug(n){return(n-90)*Math.PI/180}function rr(n,a,r,o){const u=Ug(o);return{x:n+r*Math.cos(u),y:a+r*Math.sin(u)}}function tw(n,a,r,o,u){let f=o,h=u;h<=f&&(h+=360);const p=rr(n,a,r,f),g=rr(n,a,r,h);return["M",p.x,p.y,"A",r,r,0,0,1,g.x,g.y].join(" ")}function cf(n,a){if(a)return"#ef4444";const r=Math.abs(n);return r>900?"#f59e0b":r>300?"#22c55e":"#64748b"}function nw(n,a){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=jo(n/(a||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function sw(n,a){if(a)return"#ef4444";const r=jo(n==null?0:n/4095),o=[47,55,69],u=[245,158,11],[f,h,p]=o.map((g,x)=>Math.round(g+(u[x]-g)*r));return`rgb(${f}, ${h}, ${p})`}function aw({count:n,totalSpan:a,gap:r,startAngle:o}){const f=(a-r*(n-1))/n,h=[];let p=o;for(let g=0;g<n;g+=1){const x=p+f;h.push({start:p,end:x}),p=x+r}return h}function md({cx:n,cy:a,rInner:r,rOuter:o,startDeg:u,endDeg:f,color:h,pulse:p=!1,opacity:g=1}){const x=(r+o)/2,v=o-r,b=tw(n,a,x,u,f);return l.jsxs(l.Fragment,{children:[l.jsx("path",{d:b,stroke:h,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:g}),p?l.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function lw({cx:n,cy:a,rBase:r,rTip:o,startDeg:u,endDeg:f,color:h,value:p,max:g}){const x=(u+f)/2,v=rr(n,a,o,x),b=jo(p!=null?p/(g||1):0),j=Math.pow(b,.35),M=r-(r-o)*j,k=Math.max(o,Math.min(M,r)),N=rr(n,a,k,u),w=rr(n,a,k,f),S=`M ${v.x} ${v.y} L ${N.x} ${N.y} L ${w.x} ${w.y} Z`;return l.jsx("path",{d:S,fill:h,opacity:1,stroke:"none"})}function ox({cx:n,cy:a,current:r,drop:o,overcurrent:u,label:f}){const h=Math.abs(r),p=jo(h/1200),g=cf(r,u),x=56,v=14,b=9,j=3,M=x*p,k=f==="L"?-1:1,N=k*(-b/2-j/2),w=k*(v/2+j/2),S=v+b+j+2,R=x+4;return l.jsxs("g",{transform:`translate(${n},${a})`,children:[l.jsx("rect",{x:-S/2,y:-R/2,width:S,height:R,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:N-v/2,y:-x/2,width:v,height:x,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),l.jsx("rect",{x:N-v/2,y:x/2-M,width:v,height:M,fill:g,className:u?"animate-pulse":""}),l.jsx("rect",{x:w-b/2,y:-x/2,width:b,height:x,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),l.jsx("text",{x:0,y:x/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:f})]})}function rw({cx:n,cy:a,current:r,overcurrent:o}){let u=Math.abs(r);u<10&&(u=0);const f=cf(r*3,o),h=43,p=u>0?.65:null;return l.jsxs("g",{style:{transformOrigin:`${n}px ${a}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[l.jsx("circle",{cx:n,cy:a,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(x=>{const v=Ug(x),b=n+h*Math.cos(v),j=a+h*Math.sin(v);return l.jsx("line",{x1:n,y1:a,x2:b,y2:j,stroke:f,strokeWidth:"4",strokeLinecap:"round"},x)}),o?l.jsx("circle",{cx:n,cy:a,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function iw({cx:n,cy:a,current:r,overcurrent:o,variant:u,dirtLeft:f,dirtRight:h}){const p=Math.abs(r),g=cf(r,o),x=1,v=96,b=12,j=`main-brush-pattern-a-${u}`,M=`main-brush-pattern-b-${u}`,k=p>0?.6:null,N=r>=0?1:-1;return l.jsxs("g",{children:[l.jsx("defs",{children:[j,M].map((w,S)=>l.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[l.jsx("rect",{width:"6",height:"6",fill:g,opacity:x}),l.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),k?l.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${N*(S===0?6:-6)}`,dur:`${k}s`,repeatCount:"indefinite"}):null]},w))}),l.jsx("rect",{x:n-v/2,y:a-14,width:v,height:b,rx:"3",fill:`url(#${j})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:n-v/2,y:a+4,width:v,height:b,rx:"3",fill:`url(#${M})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("circle",{cx:n-v/4,cy:a-8,r:3.5,fill:"#fbbf24"}),l.jsx("circle",{cx:n+v/4,cy:a+8,r:3.5,fill:"#fbbf24"}),o?l.jsx("rect",{x:n-v/2-4,y:a-16,width:v+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function ow({sensors:n={},variant:a="full",size:r,overlay:o=!1}){const u=r||(a==="mini"?190:260),f=u/2,h=u*.07,p=f,g=f+h,x=f*.8,v=x-4,b=x+4,j=x-14,M=x-6,k=x*.65,N=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},S=n?.wheelLeftCurrentMa??0,R=n?.wheelRightCurrentMa??0,E=n?.sideBrushCurrentMa??0,A=n?.mainBrushCurrentMa??0,L=6,V=N.bumpLeft?L:0,O=N.bumpRight?L:0,z=aw({count:6,totalSpan:140,gap:6,startAngle:-70}),X=["L","FL","CL","CR","FR","R"],G=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],Q=z.map(($,q)=>({label:X[q],start:$.start,end:$.end,value:G[q]})),P=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],oe=G.filter($=>$!=null),ie=oe.length?Math.max(...oe,1200):1200;return l.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${u}px`,height:`${u}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),l.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",ie]})]}),l.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${u} ${u}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[l.jsx("circle",{cx:p,cy:g,r:x,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),l.jsx(ox,{cx:p-k,cy:g,current:S,drop:N.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),l.jsx(ox,{cx:p+k,cy:g,current:R,drop:N.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),l.jsx(rw,{cx:p+x*.65,cy:g-x*.55,current:E,overcurrent:w.sideBrush}),l.jsx(iw,{cx:p,cy:g,current:A,overcurrent:w.mainBrush,variant:a,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),Q.map($=>{const q=nw($.value,ie),H=b+4,J=H+28;return l.jsx(lw,{cx:p,cy:g,rBase:J,rTip:H,startDeg:$.start,endDeg:$.end,color:q,value:$.value,max:ie},$.label)}),P.map($=>l.jsx(md,{cx:p,cy:g,rInner:j,rOuter:M,startDeg:$.start,endDeg:$.end,color:sw($.value,$.active),opacity:1,pulse:!!$.active},$.label)),l.jsx(md,{cx:p,cy:g,rInner:v-V,rOuter:b-V,startDeg:-70,endDeg:-6,color:N.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpLeft}),l.jsx(md,{cx:p,cy:g,rInner:v-O,rOuter:b-O,startDeg:6,endDeg:70,color:N.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpRight})]})]})}const Od=Ot.memo(ow);function cw({roverId:n=null,sensors:a,label:r,roverColor:o=null,layoutFormat:u="desktop",variant:f="default",driverLabel:h=null,showTopDown:p=void 0,mobileHud:g=!1,mapPosition:x=null,labelScale:v=1}){const b=de(ee=>ee.session?.assignment?.roverId??null),j=n??b,M=pn(j),k=de(ee=>{if(!j)return{label:null,roverColor:null};const T=(ee.session?.roster||[]).find(_=>String(_.id)===String(j));return{label:T?.name||null,roverColor:T?.color||null}}),N=de(ee=>{if(!j||f!=="spectator")return null;const ue=ee.session?.activeDrivers?.[j]||null,_=(ee.session?.users||[]).find(K=>String(K.socketId||"")===String(ue||""));return _?.nickname||_?.name||null}),w=a??M?.sensors??null,S=r??k.label??null,R=o??k.roverColor??null,E=h??N,A=g,[L]=zg(),V=typeof p=="boolean"?p:f==="spectator"||A?!0:L,O=x||(f==="spectator"?"top-center":A?"top-right":"top-center"),z=u==="mobile-portrait",X=A?"px-0.25 py-0.25":"px-1 py-0.5",G=A?"px-0.25 py-0.25":"px-0.5 py-0.5",Q=A?"text-[0.55rem]":"text-[0.8rem]",P=A?"left-0.5 top-1/2":"left-1 top-1/2",oe="bottom-0.5",ie={transform:`translateX(-50%) scale(${v})`,transformOrigin:"center bottom"},$="240px",q=z?.3:A?.33:.7,J={width:$,height:$,opacity:A?.6:.7,transform:O==="top-center"?`translateX(-50%) scale(${q})`:`scale(${q})`,transformOrigin:O==="bottom-left"?"bottom left":O==="top-center"?"top center":"top right",...O==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:O==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(f==="none")return null;if(f==="spectator"){const ee=[["Voltage",w?.voltageMv!=null?`${(w.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",w?.currentMa!=null?`${w.currentMa} mA`:"--"],["Charge",w?.batteryChargeMah!=null?`${w.batteryChargeMah}`:"--"],["OI",w?.oiMode?.label||"--"]],ue=!!w?.chargingSources?.homeBase,T=w?.chargingState?.label||"",_=!!(T&&T.toLowerCase()!=="not charging"),K=w?.oiMode?.label||"Unknown",ne=K.toLowerCase(),me=ne==="full"?"bg-emerald-500/80 text-emerald-50":ne==="safe"?"bg-amber-400/80 text-amber-950":ne==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",ce=ue?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",fe=_?"bg-emerald-500/80 text-emerald-50":ue?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx("div",{className:`absolute ${P} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${A?"text-[0.45rem]":"text-[0.65rem]"} ${X}`,children:l.jsxs("div",{className:"space-y-0.5 leading-tight",children:[l.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[l.jsx("span",{className:`rounded px-1.5 py-0.5 ${ce}`,children:ue?"Docked":"Undocked"}),l.jsx("span",{className:`rounded px-1.5 py-0.5 ${fe}`,children:_?"Charging":"Not charging"}),l.jsxs("span",{className:`rounded px-1.5 py-0.5 ${me}`,children:["OI: ",K]})]}),ee.map(([be,ge])=>l.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:be}),l.jsx("span",{className:"font-semibold text-white",children:ge})]},be))]})}),l.jsx("div",{className:`absolute ${oe} left-1/2`,style:ie,children:l.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${G} ${Q}`,children:[l.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ts(R,.18),children:S||"Unnamed Rover"}),E?l.jsxs("span",{className:"text-slate-300",children:["• ",E]}):null]})})]}),V?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:l.jsx(Od,{sensors:w,size:240,overlay:!0})}):null]})}return l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx("div",{className:`absolute ${oe} left-1/2`,style:ie,children:l.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${G} ${Q}`,children:l.jsxs("span",{children:["Rover:"," ",l.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ts(R,.18),children:['"',S||"Unnamed Rover",'"']})]})})}),V&&f!=="spectator"?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...J},children:l.jsx(Od,{sensors:w,size:240,overlay:!0})}):null]})}const Hg=Ot.memo(cw),cx=5e3,uw=700;function Vg({roverId:n=null,description:a,variant:r="default",mobileHud:o=!1,displayKey:u="",controlIntentAt:f}){const h=de(E=>E.session?.assignment?.roverId??null),p=n??h,g=de(E=>p&&(E.session?.roster||[]).find(V=>String(V.id)===String(p))?.description||null),x=a??g,v=typeof f=="number"?f:0,b=u||`${p||""}::${x||""}`,[j,M]=m.useState(!1),[k,N]=m.useState(!1),w=m.useRef(0),S=m.useRef(null),R=m.useRef(null);return m.useEffect(()=>()=>{clearTimeout(S.current),clearTimeout(R.current)},[]),m.useEffect(()=>{if(r!=="default"||!x){M(!1),N(!1),clearTimeout(S.current),clearTimeout(R.current);return}clearTimeout(S.current),clearTimeout(R.current),M(!0),N(!1),w.current=Number(v)||0},[x,b,v,r]),m.useEffect(()=>{r!=="default"||!x||!j||k||(Number(v)||0)<=w.current||S.current||R.current||(S.current=setTimeout(()=>{N(!0),S.current=null},cx),R.current=setTimeout(()=>{M(!1),R.current=null},cx+uw))},[v,x,k,j,r]),x?r==="spectator"?l.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1 z-50 flex justify-center",children:l.jsx("div",{className:"surface max-w-[92%] border border-slate-600/80 px-1 py-0.5 text-center text-[0.62rem] leading-tight text-slate-100 shadow-lg",children:x})}):r!=="default"||!j?null:l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center",children:l.jsxs("div",{className:`surface max-w-[94%] border border-slate-400 bg-neutral-900 px-2 py-1 text-center font-semibold text-slate-100 shadow-xl transition-opacity duration-700 ${k?"opacity-0":"opacity-100"} ${o?"text-[1rem] leading-tight":"text-[1.5rem] leading-tight"}`,children:[l.jsx("p",{children:"Just so you know, this rover"}),l.jsx("p",{children:x}),l.jsx("p",{className:`${o?"text-[0.58rem]":"text-[0.72rem]"} mt-0.5 font-normal text-slate-300`,children:"This fades 5 seconds after your first control input."})]})}):null}const dw={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function fw({roverId:n=null,sensors:a,overcurrentLimiter:r=null,compact:o=!1}){const u=de(O=>O.session?.assignment?.roverId??null),h=pn(n??u),p=a??h?.sensors??null,g=r??null,x=p?.wheelOvercurrents||null,v=m.useMemo(()=>x==null?[]:Object.entries(x).filter(([,O])=>!!O).map(([O])=>O),[x]),b=g?.caps||null,j=m.useMemo(()=>{if(!b)return null;const O=Number.isFinite(b?.drive?.cap)?b.drive.cap:1,z=Number.isFinite(b?.aux?.cap)?b.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(O,z)))},[b]),M=!!g?.isActive,k=m.useMemo(()=>v.length?v:M?["limiter"]:[],[v,M]),N=j??(v.length?1:0);if(!k?.length)return null;const w=k.map(O=>dw[O]||O),S=o?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",R=o?"px-2 py-1":"px-4 py-2",E=o?"text-lg":"text-4xl",A=o?"text-xs":"text-xl",L=Math.max(0,Math.min(1,N)),V=`${Math.round(L*100)}%`;return l.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${S}`,children:l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx("div",{className:"absolute inset-0 overflow-hidden",children:l.jsx("div",{className:"h-full bg-red-700/60",style:{width:V}})}),l.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${E} ${R}`,children:[l.jsx("div",{children:"OVERCURRENT"}),l.jsx("div",{className:`mt-0 font-medium text-white ${A}`,children:w.join(", ")})]})]})})}const $g=Ot.memo(fw),fr=10;function No({batteryState:n=null,charge:a=null,config:r=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,u=n?.warnActive??null,f=n?.urgentActive??null,h=r?.Full??null,p=r?.Warn??null,g=r?.Urgent??null,x=a??n?.charge??null;let v=o;if(v==null&&(v=mw({charge:x,full:h,warn:p,urgent:g})),v==null)return{available:!1};const b=Math.max(0,Math.min(1,v/100)),j=u??(p!=null&&x!=null&&x<=p),M=f??(g!=null&&x!=null&&x<=g);return{available:!0,percent:b,percentDisplay:v,warnActive:j,urgentActive:M,warnDisplayPercent:fr}}function mw({charge:n,full:a,warn:r,urgent:o}){if(n!=null&&a!=null&&r!=null&&o!=null&&a>r&&r>o){const u=fr/100,f=1-u;if(n<=o)return 0;if(n<=r){const p=(n-o)/(r-o);return Math.round(Math.max(0,Math.min(1,p))*fr)}if(n>=a)return 100;const h=(n-r)/(a-r);return Math.round((u+Math.max(0,Math.min(1,h))*f)*100)}return null}function hw({roverId:n=null,sensors:a,batteryConfig:r,compact:o=!1}){const u=de(k=>k.session?.assignment?.roverId??null),f=n??u,h=pn(f),p=de(k=>f?(k.session?.roster||[]).find(S=>String(S.id)===String(f))?.battery??null:null),g=a??h?.sensors??null,x=r??p,v=No({charge:g?.batteryChargeMah??null,config:x});if(!v?.available||!v.warnActive&&!v.urgentActive)return null;const b=v.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",j=o?"p-2 top-6":"p-4 top-10",M=o?"text-sm":"text-2xl";return l.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${j}`,children:l.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${M}`,children:l.jsx("div",{children:b})})})}const Gg=Ot.memo(hw);function pw({roverId:n=null,sensors:a}){const r=de(j=>j.session?.assignment?.roverId??null),u=pn(n??r),f=a??u?.sensors??null,h=[f?.lightBumpLeftSignal,f?.lightBumpFrontLeftSignal,f?.lightBumpCenterLeftSignal,f?.lightBumpCenterRightSignal,f?.lightBumpFrontRightSignal,f?.lightBumpRightSignal],p=h.filter(j=>j!=null).reduce((j,M)=>Math.max(j,M),1200),g=j=>Math.pow(Math.max(0,Math.min(1,(j??0)/p)),.35),x=j=>j==null||j<=0?"hsl(200 60% 18%)":`hsl(${(200+g(j)*360)%360} 100% 60%)`,v=6,b=12;return l.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:h.map((j,M)=>{const k=g(j),N=M<v/2?-1:1,w=`${k*100}%`,S=x(j);return l.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${b}px`},children:l.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:l.jsx("div",{className:"h-full",style:{width:w,background:S,float:N===-1?"right":"left"}})})},M)})})}const xw=Ot.memo(pw),gw=1600,vw=800;function bn(...n){return n.filter(Boolean).join(" ")}function bw({visual:n,orientation:a="horizontal",variant:r="inline",compact:o=!1,showLabel:u,className:f=""}){const h=r==="background",p=a==="vertical",g=u??!h;if(!n?.available){if(h){const P=fr,oe=bn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!j&&"battery-tick-warn"),ie=p?{bottom:`${P}%`}:{left:`${P}%`},$=bn("absolute inset-0 pointer-events-none",f);return l.jsxs("div",{className:$,children:[l.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),l.jsx("div",{className:oe,style:ie})]})}return p?null:l.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const x=n.percentDisplay??0,v=Math.max(0,Math.min(100,x)),b=n.warnDisplayPercent??fr,j=!!n.urgentActive,M=!!n.warnActive,k=j?`${vw}ms`:M?`${gw}ms`:void 0,w=h?j||M?"bg-red-500/45":"bg-emerald-500/45":j||M?"bg-red-500":"bg-emerald-500",S=j||M?"bg-red-900/35":"bg-slate-900/35",R=j||M?"bg-red-900/45":"bg-slate-900/35",E=bn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",f);if(h){const P=p?{height:`${v}%`}:{width:`${v}%`},oe=bn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",j&&"battery-urgent-flash"),ie=bn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!j&&"battery-tick-warn"),$=p?{bottom:`${b}%`}:{left:`${b}%`};return l.jsxs("div",{className:E,children:[l.jsx("div",{className:bn("absolute inset-0",S,j&&"battery-urgent-flash")}),l.jsx("div",{className:oe,style:{...P,animationDuration:k}}),l.jsx("div",{className:ie,style:$})]})}const A=bn("relative overflow-hidden rounded-sm border border-slate-800",j||M?R:"bg-zinc-900/90",j&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),L=p?{height:`${v}%`}:{width:`${v}%`},V=bn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",j&&"battery-urgent-flash"),O=bn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!j&&"battery-tick-warn"),z=p?{bottom:`${b}%`}:{left:`${b}%`},X=`Battery ${x}%`,G=bn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",p?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),Q=bn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return l.jsxs("div",{className:E,children:[l.jsxs("div",{className:A,children:[l.jsx("div",{className:V,style:{...L,animationDuration:k}}),l.jsx("div",{className:O,style:z})]}),g&&!p?l.jsx("div",{className:G,children:l.jsx("span",{className:Q,children:X})}):null,g&&p?l.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:l.jsxs("span",{className:Q,children:[x,"%"]})}):null]})}const uf=Ot.memo(bw);function yw({roverId:n=null,mobileHud:a=!1}){const r=de(g=>g.session?.assignment?.roverId??null),o=n??r,f=pn(o)?.sensors??null,h=de(g=>o?(g.session?.roster||[]).find(b=>String(b.id)===String(o))?.battery??null:null),p=No({charge:f?.batteryChargeMah??null,config:h});return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(xw,{roverId:o}),l.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:l.jsx(uf,{visual:p,compact:a})})]})}function Sw({compact:n=!1}){const a=de(z=>z.session?.role||null),r=de(z=>z.session?.assignment?.roverId||null),o=de(z=>z.session?.roster||[]),{sendMessage:u,onInputFocus:f,onInputBlur:h,blurChat:p,registerInputRef:g,setTypingActive:x}=sf(),{value:v}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[b,j]=m.useState(""),[M,k]=m.useState(!1),N=a!=="spectator",w=a==="spectator",R=!!m.useMemo(()=>o.find(z=>String(z.id)===String(r))||null,[r,o])?.audio?.ttsEnabled,E=m.useMemo(()=>{if(!R)return null;const z=v?.engine==="espeak"?"espeak":"flite";if(z==="espeak"){let G=Number.isFinite(v?.pitch)?Math.round(v.pitch):void 0;return typeof G=="number"&&(G=Math.max(0,Math.min(99,G))),{speak:!0,engine:z,pitch:G}}const X=typeof v?.voice=="string"?v.voice:void 0;return{speak:!0,engine:z,voice:X}},[v?.engine,v?.pitch,v?.voice,R]),A=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",L=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",V=n?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function O(z){if(z.preventDefault(),!N)return;const X=b.trim();if(X){k(!0);try{await u(X,E),j(""),p(),x(!1)}catch(G){alert(G.message)}finally{k(!1)}}}return w?null:l.jsxs("form",{onSubmit:O,className:A,children:[l.jsx("input",{className:L,value:b,onChange:z=>{const X=z.target.value;j(X),x(!!X.trim())},onFocus:z=>{f(z),x(!!b.trim())},onBlur:z=>{h(z),x(!1)},onKeyDown:z=>{z.key==="Enter"&&!b.trim()&&(z.preventDefault(),p(),x(!1))},ref:z=>g(z,{target:"hud"}),placeholder:N?"Chat (TTS)":"Spectator",disabled:!N}),l.jsx("button",{type:"submit",disabled:!N||M,className:V,children:"Speak"})]})}const jw=m.memo(Sw);function df({layoutFormat:n="desktop"}){const a=n!=="desktop";return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsxs("div",{className:"relative w-full overflow-hidden bg-black aspect-[4/3]",children:[l.jsx(dr,{}),l.jsx(ew,{mobileHud:a}),l.jsx(Vg,{variant:"default",mobileHud:a}),l.jsx(Hg,{layoutFormat:n,variant:"default",mobileHud:a,labelScale:1}),l.jsx(jw,{compact:a}),l.jsx($g,{compact:a}),l.jsx(Gg,{compact:a})]}),l.jsx(yw,{mobileHud:a})]})})}function mo({label:n,tone:a="muted"}){const r=a==="success"?"bg-emerald-900 text-emerald-100":a==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return l.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${r}`,children:n})}function wo(n){if(!Number.isFinite(n))return 0;const a=n%360;return a<0?a+360:a}function Nw(n){if(!Array.isArray(n)||n.length<3)return 0;const[a,r,o]=n,u=Math.max(0,Math.min(255,Number(a)))/255,f=Math.max(0,Math.min(255,Number(r)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(u,f,h),g=Math.min(u,f,h),x=p-g;if(x===0)return 0;let v=0;return p===u?v=(f-h)/x%6:p===f?v=(h-u)/x+2:v=(u-f)/x+4,wo(Math.round(v*60))}function ux(n){const a=wo(n),r=1,o=1-Math.abs(a/60%2-1);let u=0,f=0,h=0;return a<60?(u=r,f=o):a<120?(u=o,f=r):a<180?(f=r,h=o):a<240?(f=o,h=r):a<300?(u=o,h=r):(u=r,h=o),[Math.round(u*255),Math.round(f*255),Math.round(h*255)]}function dx(n){return n?Array.isArray(n.hsColor)?wo(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?Nw(n.rgbColor):0:0}function ww({entity:n,connected:a,controlsLocked:r,onToggle:o,onSetColor:u,onSetWhite:f}){const h=n.state==="unavailable"||!n.available,p=n.state==="on",g=n.type==="light"&&n.supportsColor,x=h?"warn":p?"success":"muted",v=h?"Unavailable":p?"On":"Off",b=r||!a||h,j=b||!g,[M,k]=m.useState(()=>dx(n)),N=m.useRef(M),w=m.useRef(!1),S=h?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":r?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":p?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!g||w.current)return;const z=dx(n);N.current=z,k(z)},[n.rgbColor,n.hsColor,g]);const R=z=>{const X=wo(Number(z.target.value));N.current=X,k(X)},E=()=>{j||!u||u(n.id,ux(N.current))},A=z=>{z.stopPropagation()},L=z=>{A(z),!(j||!f)&&f(n.id)},O=`rgb(${(g?ux(N.current):[255,255,255]).join(",")})`;return l.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:b,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 ${S} disabled:opacity-60 disabled:hover:bg-inherit`,children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[l.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),g&&l.jsxs(l.Fragment,{children:[l.jsx(mo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),g?l.jsx("div",{className:"-mt-0.5 w-full",onClick:A,onPointerDown:z=>{A(z),w.current=!0},onPointerUp:z=>{A(z),w.current=!1,E()},onPointerCancel:z=>{A(z),w.current=!1,E()},onKeyUp:z=>{A(z),E()},onBlur:E,children:l.jsx("div",{className:"relative w-full",children:l.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:M,onChange:R,disabled:j,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsx(mo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),g&&l.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[l.jsx("span",{role:"button",tabIndex:j?-1:0,onClick:L,onPointerDown:A,onKeyDown:z=>{j||(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),L(z))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":j,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${j?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),l.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:O}})]}),!g&&l.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:p?"Turn off":"Turn on"})]})}function Fg(){const{state:{keymap:n}}=wt(),a=de(j=>j.session?.homeAssistant||null),{homeAssistantToggle:r,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:u}=Gt(),f=m.useMemo(()=>a?.entities||[],[a?.entities]),h=a?.lightPolicy||null,p=!!(h?.locked||h?.lockedOn),g=h?.lockState||(h?.lockedOn?"on":null),x=Rt(n?.homeAssistantOn?.[0]),v=Rt(n?.homeAssistantOff?.[0]);if(!a?.enabled)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(f.length===0)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const b=!!a?.connected;return l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room Controls"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length}),p?l.jsx(mo,{label:g==="off"?"Locked Off":"Locked On",tone:"warn"}):null,l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"On"}),x?l.jsx(fx,{label:x}):null]}),l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"Off"}),v?l.jsx(fx,{label:v}):null]})]})]}),l.jsx(mo,{label:b?"Connected":"Offline",tone:b?"success":"warn"})]}),p?l.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:g==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,l.jsx("div",{className:"flex flex-wrap gap-0.5",children:f.map(j=>l.jsx(ww,{entity:j,connected:b,controlsLocked:p,onToggle:r,onSetColor:o,onSetWhite:u},j.id))})]})}function fx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Yg(){const{login:n,setRole:a}=Gt(),[r,o]=m.useState(""),[u,f]=m.useState(""),[h,p]=m.useState(!1);async function g(x){x.preventDefault(),p(!0);try{await n(r,u),o(""),f("")}catch(v){alert(v.message)}finally{p(!1)}}return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),l.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:g,children:[l.jsx("input",{className:"field-input",placeholder:"Username",value:r,onChange:x=>o(x.target.value)}),l.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:u,onChange:x=>f(x.target.value)}),l.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function mx(...n){return n.filter(Boolean).join(" ")}function Aw(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function Cw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function kw({title:n,roster:a=[],emptyText:r="No roster data.",renderActions:o=null}){return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),a.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:r}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:a.map(u=>{const f=!!(u?.private?.enabled&&u?.private?.open),h=!!u?.locked;return l.jsxs("li",{className:mx("surface flex flex-wrap items-center justify-between gap-0.5",h?"bg-red-900/40":f?"bg-amber-700/35 border border-amber-200/30":null),children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-slate-200",children:l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ts(u.color,.16),children:u.name})}),l.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[l.jsx("span",{children:u.locked?"locked":"free"}),u.lockReason&&l.jsx("span",{className:"rounded bg-black/30 px-1",children:u.lockReason}),l.jsxs("span",{className:mx("font-semibold",Cw(u)),children:["Battery ",Aw(u)]})]})]}),o?o(u):null]},u.id)})})]})}function Ew(n){const a=n?.runtime||{},r=n?.output||{},o=n?.errors||{};return a.inFlight?{label:"IN FLIGHT",detail:a.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:a.outcome==="posted"?{label:"POSTED",detail:r.posted?`Last: ${r.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:a.outcome==="skipped"?{label:"SKIPPED",detail:a.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:a.outcome==="failed"?{label:"FAILED",detail:o.message||a.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:a.running?"IDLE":"STOPPED",detail:a.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Mw(n,a){const r=Date.now(),u=(Array.isArray(n)?n:[]).map((f,h)=>{const p=String(f?.role||"").toLowerCase(),g=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),x=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:r+h,nickname:x,text:g,role:"spectator",system:p==="system"}}});if(a!=null){const f=String(a);u.push({id:"llm-output",message:{ts:r+u.length+1,nickname:"LLM Output",text:f.trim()?f:"<empty>",role:"spectator",system:!0}})}return u}function Rw({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(null);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},h=n.counters||{},p=n.timings||{},g=n.input||{},x=n.output||{},v=n.errors||{},b=Array.isArray(n.history)?n.history:[],j=b.find(w=>w.runId===o)||(b.length?b[b.length-1]:null),M=Ew(n),k=Mw(g.modelMessages,x.raw),N=[{label:"running",value:f.running?"yes":"no"},{label:"in flight",value:f.inFlight?"yes":"no"},{label:"phase",value:f.phase||"--"},{label:"run id",value:f.currentRunId??"--"},{label:"tick count",value:f.tickCount??0},{label:"last tick",value:f.lastTickAt?new Date(f.lastTickAt).toLocaleString():"never"},{label:"next run",value:f.nextRunAt?new Date(f.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:f.outcome||"--"},{label:"reason",value:f.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear LLM History"})}),l.jsxs("div",{className:`surface border text-center ${M.className}`,children:[l.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:M.label}),l.jsx("div",{className:"text-xs text-slate-200",children:M.detail})]}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:N.map(w=>l.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[w.label,": ",w.value]},w.label))}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.details?l.jsxs("details",{className:"surface text-xs text-red-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(v.details,null,2)})]}):null,x.generated?l.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",x.generated]}):null,x.posted?l.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",x.posted]}):null,l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),l.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:k.length?k.map(w=>l.jsx(ef,{message:w.message},w.id)):l.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{children:["Raw output: ",x.raw?.trim()?x.raw:"<none>"]}),l.jsxs("div",{children:["Posted: ",x.posted||"<none>"]}),l.jsxs("div",{children:["Output at: ",x.modelOutputAt?new Date(x.modelOutputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Failed at: ",v.failedAt?new Date(v.failedAt).toLocaleString():"n/a"]})]})]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),l.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(w=>l.jsxs("button",{type:"button",onClick:()=>u(w.runId),className:`w-full text-left surface ${j?.runId===w.runId?"border border-sky-400/50":""}`,children:[l.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",l.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",l.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",l.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):l.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),j?l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",j.runId," details"]}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(j,null,2)})]}):null]})}function Tw({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(!1);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},h=n.config||{},p=n.output||{},g=n.timings||{},x=n.input||{},v=n.errors||{},b=()=>{const j=Array.isArray(x.modelMessages)?x.modelMessages:[];return j.length?j.map((M,k)=>{const N=String(M?.role||"unknown").toUpperCase(),w=String(M?.content||"");return`#${k+1} ${N}
|
||
${w}`}).join(`
|
||
|
||
----------------------------------------
|
||
|
||
`):"<none>"};return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear Overseer History"})}),l.jsxs("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:[l.jsxs("span",{className:"surface-muted",children:["running: ",f.running?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["phase: ",f.phase||"--"]}),l.jsxs("span",{className:"surface-muted",children:["tick: ",f.tickCount??0]}),l.jsxs("span",{className:"surface-muted",children:["trigger: ",f.lastTriggerReason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["name: ",h.name||"--"]}),l.jsxs("span",{className:"surface-muted",children:["model: ",h.model||"--"]}),l.jsxs("span",{className:"surface-muted",children:["observeOnly: ",h.observeOnly?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["decision: ",p.normalized||"--"]}),l.jsxs("span",{className:"surface-muted",children:["outcome: ",p.outcome||"--"]}),l.jsxs("span",{className:"surface-muted",children:["reason: ",p.reason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["last gen: ",g.lastGenerationMs!=null?`${g.lastGenerationMs}ms`:"--"]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Latest Context"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.stateUpdate||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Input (messages[])"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:b()})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact System Prompt"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.systemPrompt||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Transcript Rows"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(x.transcript||[],null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Tool Availability"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify({available:x.availableTools,blocked:x.blockedTools},null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Output"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:p.raw||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Live Tool Calls"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(p.liveToolCalls||[],null,2)})]}),l.jsxs("div",{className:"surface text-xs text-slate-200",children:[l.jsxs("div",{children:["Normalized decision: ",p.normalized||"--"]}),l.jsxs("div",{children:["Model input at: ",x.modelInputAt?new Date(x.modelInputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Model output at: ",p.outputAt?new Date(p.outputAt).toLocaleString():"n/a"]})]}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300",children:["Error: ",v.message]}):null,l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Recent Runs"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n.history||[],null,2)})]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>u(j=>!j),children:o?"Hide Full Payload":"Show Full Payload"}),o?l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)}):null]})}function qw({health:n,roster:a=[]}){if(!n)return null;const r=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},u=g=>a.find(x=>String(x.id)===String(g))?.color||null,f=`${r.readyCount}/${r.totalCount} sources ready`,h=o.rovers.filter(g=>g.stale).length,p=o.rooms.filter(g=>g.stale).length;return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Replay segments"}),l.jsx("span",{className:"text-slate-400",children:f})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Rover snapshots"}),l.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rovers.length-h,"/",o.rovers.length," ok"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Room cameras"}),l.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rooms.length-p,"/",o.rooms.length," ok"]})]})]}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:r.sources.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:`${g.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:g.type==="rover"?ts(u(g.id),.16):void 0,children:g.label}),l.jsxs("span",{className:g.ready?"text-emerald-300":"text-amber-300",children:[g.recentCount,"/",g.neededCount]})]},`${g.type}:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ts(u(g.id),.16),children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.stale?"stale":"ok"})]},`rover:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.error?"error":g.stale?"stale":"ok"})]},`room:${g.id}`))})]})}function Dw({entries:n}){const a=n||[];return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Admin IP log"}),l.jsx("span",{children:a.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No admin log entries yet."}):a.slice().reverse().map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.ts?new Date(r.ts).toLocaleTimeString():"--"})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{className:"text-slate-200",children:r.message})," ",r.ip&&l.jsx("span",{className:"text-cyan-300",children:r.ip})," ",r.meta&&l.jsx("span",{className:"text-slate-500",children:JSON.stringify(r.meta)})]},r.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const _w=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Ow(){const{session:n,lockRover:a,setMode:r,requestControl:o,setGlobalObjective:u,setAdminReason:f,rebootRover:h,rebootServer:p,setAudioLevels:g,setPrivateSafety:x,llmControl:v,overseerControl:b,adminLogs:j,llmCommentaryState:M,overseerControlState:k}=br(),N=m.useMemo(()=>n?.roster??[],[n?.roster]),[w,S]=m.useState({}),[R,E]=m.useState({}),[A,L]=m.useState(!1),[V,O]=m.useState(!1),[z,X]=m.useState(!1),G=n?.health||null,Q=n?.globalObjective?.text||"",P=n?.globalObjective?.updatedAt||null,[oe,ie]=m.useState(Q),$=n?.adminReason?.text||"",q=n?.adminReason?.updatedAt||null,[H,J]=m.useState($),ee=n?.audioLevels||{},[ue,T]=m.useState({hornGain:Number.isFinite(ee.hornGain)?ee.hornGain:1,ttsGain:Number.isFinite(ee.ttsGain)?ee.ttsGain:1,forwardGain:Number.isFinite(ee.forwardGain)?ee.forwardGain:1}),[_,K]=m.useState({}),ne=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",me=n?.role==="lockdown"||n?.role==="lockdown-admin",ce=n?.mode??"open",fe=async(le,he)=>{try{await a(le,he),S(De=>({...De,[le]:he}))}catch(De){alert(De.message)}},be=async le=>{const he=le.target.value;try{await r(he)}catch(De){alert(De.message)}},ge=async le=>{try{await o(le,{force:!0})}catch(he){alert(he.message)}},xe=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){E(De=>({...De,[le.id]:!0}));try{await h(le.id)}catch(De){alert(De.message)}finally{E(De=>({...De,[le.id]:!1}))}}},ze=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){L(!0);try{await p()}catch(he){alert(he.message),L(!1)}}},Ee=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){O(!0);try{await v("clearHistory")}catch(he){alert(he.message)}finally{O(!1)}}},Te=async()=>{if(window.confirm("Clear Overseer Control history now?")){X(!0);try{await b("clearHistory")}catch(he){alert(he.message)}finally{X(!1)}}},Oe=async()=>{try{await u(oe)}catch(le){alert(le.message)}},Ue=async()=>{try{await u(null)}catch(le){alert(le.message)}},ht=async()=>{try{await f(H)}catch(le){alert(le.message)}},re=async()=>{try{await f(null)}catch(le){alert(le.message)}},ae=le=>he=>{const De=Number(he.target.value);T(Tt=>({...Tt||{},[le]:Number.isFinite(De)?De:1}))},Se=async()=>{try{await g(ue)}catch(le){alert(le.message)}},pe=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{ie(Q)},[Q]),m.useEffect(()=>{J($)},[$]),m.useEffect(()=>{T({hornGain:Number.isFinite(ee.hornGain)?ee.hornGain:1,ttsGain:Number.isFinite(ee.ttsGain)?ee.ttsGain:1,forwardGain:Number.isFinite(ee.forwardGain)?ee.forwardGain:1})},[ee.forwardGain,ee.hornGain,ee.ttsGain]),m.useEffect(()=>{const le={};(N||[]).forEach(he=>{he?.private?.enabled&&(le[he.id]={speedLimitEnabled:!!he?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(he?.private?.safety?.speedLimitMaxWheelSpeed)?he.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!he?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(he?.private?.safety?.overcurrentStopMs)?he.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!he?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(he?.private?.safety?.bumpBackoffSpeed)?he.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(he?.private?.safety?.bumpBackoffMs)?he.private.safety.bumpBackoffMs:350,cliffEnabled:!!he?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(he?.private?.safety?.cliffBackoffSpeed)?he.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(he?.private?.safety?.cliffBackoffMs)?he.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(he?.private?.safety?.triggerCooldownMs)?he.private.safety.triggerCooldownMs:800})}),K(le)},[N]);const je=m.useMemo(()=>{const le={};return N.forEach(he=>{le[he.id]=w[he.id]??he.locked}),le},[N,w]),Ae=(le,he={})=>{K(De=>({...De||{},[le]:{...De?.[le]||{},...he||{}}}))},Re=async le=>{try{const he=_?.[le];if(!he)return;await x(le,he)}catch(he){alert(he.message)}};return ne?l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[l.jsx("span",{children:"Admin controls"}),l.jsx("select",{value:ce,onChange:be,className:"field-input text-sm",children:_w.map(le=>l.jsx("option",{value:le.key,children:le.label},le.key))})]}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:ze,disabled:A,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:A?"Server rebooting...":"Reboot Server"}),l.jsx("button",{type:"button",onClick:pe,className:"button-dark",children:"Test Reward Popup"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?l.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Horn gain"}),l.jsxs("span",{children:[ue.hornGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.hornGain,onChange:ae("hornGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"TTS gain"}),l.jsxs("span",{children:[ue.ttsGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.ttsGain,onChange:ae("ttsGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Forward gain"}),l.jsxs("span",{children:[ue.forwardGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ue.forwardGain,onChange:ae("forwardGain"),className:"w-full accent-emerald-500"})]}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:Se,className:"button-dark",children:"Apply audio levels"})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global objective"}),P?l.jsxs("span",{children:["Updated ",new Date(P).toLocaleString()]}):null]}),l.jsx("input",{type:"text",value:oe,onChange:le=>ie(le.target.value),placeholder:"Set a global objective",className:"field-input text-sm"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:Oe,className:"button-dark",children:"Set objective"}),l.jsx("button",{type:"button",onClick:Ue,className:"button-danger",children:"Clear"})]})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Admin mode reason"}),q?l.jsxs("span",{children:["Updated ",new Date(q).toLocaleString()]}):null]}),l.jsx("textarea",{value:H,onChange:le=>J(le.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:ht,className:"button-dark",children:"Set reason"}),l.jsx("button",{type:"button",onClick:re,className:"button-danger",children:"Clear"})]})]}),l.jsx(kw,{roster:N,renderActions:le=>l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:()=>fe(le.id,!je[le.id]),className:"button-dark",children:je[le.id]?"Unlock":"Lock"}),l.jsx("button",{type:"button",onClick:()=>ge(le.id),className:"button-dark",children:"Force"}),l.jsx("button",{type:"button",onClick:()=>xe(le),disabled:!!R[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:R[le.id]?"Rebooting...":"Reboot"}),le?.private?.enabled?l.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[l.jsx("div",{className:"text-slate-300",children:"Private safety"}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.speedLimitEnabled,disabled:!me,onChange:he=>Ae(le.id,{speedLimitEnabled:!!he.target.checked})}),l.jsx("span",{children:"Speed limit"})]}),l.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!me,value:_?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:he=>Ae(le.id,{speedLimitMaxWheelSpeed:Number(he.target.value)||250})}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.hardOvercurrentEnabled,disabled:!me,onChange:he=>Ae(le.id,{hardOvercurrentEnabled:!!he.target.checked})}),l.jsx("span",{children:"Hard overcurrent"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.hardBumpEnabled,disabled:!me,onChange:he=>Ae(le.id,{hardBumpEnabled:!!he.target.checked})}),l.jsx("span",{children:"Hard bump"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!_?.[le.id]?.cliffEnabled,disabled:!me,onChange:he=>Ae(le.id,{cliffEnabled:!!he.target.checked})}),l.jsx("span",{children:"Cliff safety"})]}),l.jsx("button",{type:"button",disabled:!me,onClick:()=>Re(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),l.jsx(qw,{health:G,roster:N}),l.jsx(Rw,{state:M,onClearHistory:Ee,clearingHistory:V}),l.jsx(Tw,{state:k,onClearHistory:Te,clearingHistory:z}),l.jsx(Dw,{entries:j})]}):null}const Bw=[{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 Lw(n){return n.reduce((a,r)=>((a[r.group]||(a[r.group]=[])).push(r),a),{})}function zw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}const ff=5,mr=500,hr=1,mf=100;function Uw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(ff,Math.min(mr,r)):a}function ao(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(hr,Math.min(mf,r)):a}function Hw(n){const r=(ao(n,n)-hr)/(mf-hr),o=mr-r*(mr-ff);return Math.round(o)}function Vw(n){const a=Uw(n,n),r=(mr-a)/(mr-ff),o=hr+r*(mf-hr);return Math.round(o)}function $w(n){const[a,r]=m.useState(null),o=m.useCallback(h=>{ed(!0),r(h)},[]),u=m.useCallback(()=>{ed(!1),r(null)},[]),f=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){u();return}const g=Sr(p.key??"");g&&(n(h,g,p),u())},[u,n]);return m.useEffect(()=>()=>ed(!1),[]),{active:a,startCapture:o,cancel:u,captureFromEvent:f}}function Xi({label:n,description:a,value:r,onChange:o,min:u=0,max:f=500,step:h=5}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("input",{type:"number",min:u,max:f,value:r,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[l.jsx("input",{type:"range",min:u,max:f,step:h,value:r,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),l.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:r})]})]})}function Gw(){const{state:{keymap:n},actions:{updateKeyBinding:a,resetKeyBindings:r}}=wt(),{value:o,save:u}=Qe("inputs",kn),f={...kn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof f.tiltSpeed=="number"?ao(f.tiltSpeed,kn.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?ao(Vw(f.tiltIntervalMs),kn.keyboard.tiltSpeed):kn.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),p=m.useMemo(()=>Lw(Bw),[]),{active:g,startCapture:x,cancel:v,captureFromEvent:b}=$w((N,w)=>{a(N,w)}),j=m.useCallback(N=>n?.[N]?.[0]||lr[N]?.[0]||"",[n]),M=m.useCallback((N,w)=>{const S=kn.keyboard,R=zw(w,S[N]);u(E=>({...E??{},keyboard:{...E?.keyboard??S,[N]:R}}))},[u]),k=m.useCallback(N=>{const w=kn.keyboard,S=ao(N,w.tiltSpeed),R=Hw(S);u(E=>({...E??{},keyboard:{...E?.keyboard??w,tiltSpeed:S,tiltIntervalMs:R}}))},[u]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),l.jsx("button",{type:"button",onClick:()=>r(),className:"button-dark text-xs",children:"Reset defaults"})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Xi,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:N=>M("baseSpeed",N)}),l.jsx(Xi,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:N=>M("turboSpeed",N)}),l.jsx(Xi,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:N=>M("precisionSpeed",N)})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),l.jsx(Xi,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:k,min:1,max:100,step:1})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([N,w])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.75rem] text-slate-400",children:N}),l.jsx("div",{className:"space-y-0.5",children:w.map(S=>{const R=j(S.id),E=g===S.id;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:S.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Rt(R)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[E&&l.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),l.jsx("button",{type:"button",onClick:()=>x(S.id),onKeyDown:E?A=>b(S.id,A):void 0,autoFocus:E,className:`${E?"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:E?"Press a key…":"Change"})]})]},S.id)})})]},N))})]})}const Jn=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),Fw=[{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"}],hx=.45,Yw=.6;function tr({label:n,description:a,min:r,max:o,step:u,value:f,onChange:h}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("span",{className:"font-mono text-slate-400",children:Jn.format(f)})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsx("input",{type:"range",min:r,max:o,step:u,value:f,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function Xw(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const a=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${a?` (${a})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const a=n.direction<0?"<":">";return`Axis ${n.index} ${a} ${Jn.format(n.threshold??.6)}`}return"Unassigned"}function Qw(n){return n.reduce((a,r)=>((a[r.section]||(a[r.section]=[])).push(r),a),{})}function Iw(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function Kw(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0}))}}function Zw(n,a,r){const o=(n.axes??[]).map((f,h)=>({index:h,delta:Math.abs((f??0)-(a.axes?.[h]??0)),value:f}));if(o.sort((f,h)=>h.delta-f.delta),r.kind==="axisPair"){const f=o.filter(h=>h.delta>hx).slice(0,2);return f.length<2?null:{kind:"axisPair",x:f[0].index,y:f[1].index,...r.invertDefaults??{}}}const u=o.find(f=>f.delta>hx);return u?{kind:"axis",index:u.index,...r.invertDefaults??{}}:null}function Jw(n,a,r){const o=n.buttons??[];for(let f=0;f<o.length;f+=1){const h=o[f],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>Yw)return r.kind==="axis"?{kind:"buttonAxis",index:f}:{kind:"button",index:f}}const u=n.axes??[];for(let f=0;f<u.length;f+=1){const h=u[f]??0,p=Math.abs(h-(a.axes?.[f]??0));if(Math.abs(h)>.7&&p>.5)return r.kind==="axis"?{kind:"axis",index:f,...r.invertDefaults??{}}:{kind:"axisButton",index:f,direction:h>=0?1:-1,threshold:.6}}return null}function Pw(n,a,r){if(!n)return null;if(r.kind==="axis"||r.kind==="axisPair"){const o=Zw(n,a,r);if(o)return o}return Jw(n,a,r)}function Ww(){const n=yN(),{value:a,save:r}=Qe("gamepad",ks),[o,u]=m.useState(null),f=m.useRef(null),h=m.useMemo(()=>Qw(Fw),[]),p=m.useMemo(()=>Iw(n.pads,a.activeSignature),[n.pads,a.activeSignature]),g=p?.signature??null,x=m.useMemo(()=>g?a?.profiles?.[g]??a?.defaults?.profile??Pn:a?.defaults?.profile??Pn,[g,a?.defaults?.profile,a?.profiles]);m.useEffect(()=>{!p||!g||a?.profiles?.[g]||r(w=>{const S=w??ks;if(S.profiles?.[g])return S;const R=S?.defaults?.profile??Pn,E=Ag(p,R);return{...S,profiles:{...S.profiles??{},[g]:E}}})},[p,g,a?.profiles,r]),m.useEffect(()=>{f.current=null},[o,g]),m.useEffect(()=>{if(!o||!p)return;if(!f.current){f.current=Kw(p);return}const w=Pw(p,f.current,o);w&&(r(S=>{const R=S??ks,E=R.profiles?.[g]??R?.defaults?.profile??Pn,A={...E,bindings:{...E.bindings??{},[o.id]:{...E.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...R,profiles:{...R.profiles??{},[g]:A}}}),u(null))},[p,g,o,r]);const v=m.useCallback(w=>{r(S=>({...S??ks,activeSignature:w||null}))},[r]),b=m.useCallback(w=>{r(S=>{const R=S??ks,E=(g&&R.profiles?.[g])??R?.defaults?.profile??Pn,A={...E,calibration:{...E.calibration??{},...w}};return g?{...R,profiles:{...R.profiles??{},[g]:A}}:{...R,defaults:{...R.defaults??{},profile:A}}})},[g,r]),j=m.useCallback((w,S)=>{r(R=>{const E=R??ks,A=(g&&E.profiles?.[g])??E?.defaults?.profile??Pn,L=S(A.bindings?.[w]??{}),V={...A,bindings:{...A.bindings??{},[w]:L}};return g?{...E,profiles:{...E.profiles??{},[g]:V}}:{...E,defaults:{...E.defaults??{},profile:V}}})},[g,r]),M=m.useCallback(w=>{j(w.id,S=>({...S,sources:[]}))},[j]),k=m.useCallback((w,S)=>{j(w.id,R=>{const E=Array.isArray(R.sources)?[...R.sources]:[];if(!E[0])return R;const A={...E[0]};return S==="invertX"?A.invertX=!A.invertX:S==="invertY"?A.invertY=!A.invertY:A.invert=!A.invert,E[0]=A,{...R,sources:E}})},[j]),N=m.useMemo(()=>p?{outputs:Cg(p,x)}:null,[p,x]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&l.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[l.jsx("select",{value:g??"",onChange:w=>v(w.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(w=>l.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(tr,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:x.calibration?.driveDeadzone??.18,onChange:w=>b({driveDeadzone:w})}),l.jsx(tr,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:x.calibration?.cameraDeadzone??.08,onChange:w=>b({cameraDeadzone:w})}),l.jsx(tr,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:x.calibration?.auxDeadzone??.05,onChange:w=>b({auxDeadzone:w})}),l.jsx(tr,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:x.calibration?.auxSideScale??.55,onChange:w=>b({auxSideScale:w})}),l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),l.jsxs("select",{value:x.calibration?.cameraMode??"absolute",onChange:w=>b({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[l.jsx("option",{value:"absolute",children:"Absolute"}),l.jsx("option",{value:"velocity",children:"Velocity"})]})]}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),l.jsx(tr,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:x.calibration?.cameraSensitivity??60,onChange:w=>b({cameraSensitivity:w})})]})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([w,S])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),l.jsx("div",{className:"space-y-0.5",children:S.map(R=>{const A=x.bindings?.[R.id]?.sources?.[0]??null;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:R.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Xw(A)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[R.kind==="axisPair"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:!A,onClick:()=>k(R,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),l.jsx("button",{type:"button",disabled:!A,onClick:()=>k(R,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),R.kind==="axis"&&l.jsx("button",{type:"button",disabled:!A,onClick:()=>k(R),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),l.jsx("button",{type:"button",onClick:()=>M(R),className:"button-dark text-[0.7rem]",children:"Clear"}),l.jsx("button",{type:"button",onClick:()=>u(R),className:`${o?.id===R.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===R.id?"Waiting…":"Capture"})]})]},R.id)})})]},w))}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?l.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[l.jsx("p",{className:"text-slate-400",children:"Raw axes"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((w,S)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["A",S,": ",Jn.format(w)]},`axis-${S}`))}),l.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((w,S)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["B",S,": ",Jn.format(w.value)," ",w.pressed?"●":""]},`btn-${S}`))}),N?.outputs&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",Jn.format(N.outputs.driveVector.x),","," ",Jn.format(N.outputs.driveVector.y)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",Jn.format(N.outputs.cameraAxis)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",Jn.format(N.outputs.auxAxis.main)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",Jn.format(N.outputs.auxAxis.side)]})]})]})]}):l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const eA={drive:"Drive wheels",aux:"Aux motors"};function px(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function tA({value:n,color:a="bg-emerald-500"}){const r=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return l.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:l.jsx("div",{className:`h-full ${a}`,style:{width:r}})})}function nA(){const{state:{roverId:n},overcurrentLimiter:a}=wt(),r=m.useMemo(()=>Ps.map(o=>o.key),[]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Overcurrent limiter"}),l.jsx("span",{children:a?.adminImmune?"Admin immune":"Active"})]}),n?l.jsxs("div",{className:"space-y-0.5",children:[r.map(o=>{const u=a?.caps?.[o]?.cap??0,f=a?.overcurrent?.groups?.[o]??!1,h=a?.scales?.perGroup?.[o]??1;return l.jsxs("div",{className:"surface space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-slate-200",children:eA[o]||o}),l.jsx("span",{className:f?"text-red-300":"text-slate-400",children:f?"overcurrent":"ok"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Cap"}),l.jsx("span",{children:px(u)})]}),l.jsx(tA,{value:u,color:"bg-amber-500"}),l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Scale"}),l.jsx("span",{children:px(h)})]})]})]},o)}),l.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Down rate ${a?.config?.downRatePerSec}/s · Up rate ${a?.config?.upRatePerSec}/s`}),l.jsx("div",{children:`Release delay ${a?.config?.releaseDelaySec}s`}),l.jsx("div",{children:`Output rate ${a?.config?.outputRateMs}ms`})]})]}):l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Xg=m.createContext(null);function Qg(){const n=m.useContext(Xg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const xx={primary:{base:"flex-1 px-0.5 py-0.5 text-sm font-medium focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-slate-500 rounded-md border border-slate-800",active:"bg-sky-600 text-white border-white",inactive:"bg-zinc-900 text-slate-300 hover:bg-sky-500 hover:text-white"}},gx={none:"",pink:"bg-pink-500 text-white border-pink-200 hover:bg-pink-400",green:"bg-emerald-500 text-white border-emerald-200 hover:bg-emerald-400"},Ig="primary";function hf(...n){return n.filter(Boolean).join(" ")}function pf({children:n,defaultTab:a,currentTab:r,onTabChange:o,variant:u=Ig}){const[f,h]=m.useState(a??null),[p,g]=m.useState([]),x=m.useCallback(M=>M?(g(k=>k.includes(M)?k:[...k,M]),()=>g(k=>k.includes(M)?k.filter(N=>N!==M):k)):()=>{},[]),v=r??f??p[0]??null;m.useEffect(()=>{a&&r===void 0&&h(a)},[a,r]);const b=m.useCallback(M=>{M&&(r===void 0&&h(M),o&&o(M))},[r,o]),j=m.useMemo(()=>({activeTab:v,setActiveTab:b,registerTab:x,variant:u}),[v,b,x,u]);return l.jsx(Xg.Provider,{value:j,children:n})}function xf({children:n,className:a=""}){return l.jsx("div",{className:hf("flex gap-0.5",a),children:n})}function Pt({id:n,children:a,className:r="",disabled:o=!1,highlight:u="none"}){const{activeTab:f,setActiveTab:h,registerTab:p,variant:g}=Qg();m.useEffect(()=>p(n),[n,p]);const x=xx[g]??xx[Ig],v=f===n,b=gx[u]||gx.none,j=hf(x.base,b||(v?x.active:x.inactive),o?"cursor-not-allowed opacity-50":"",r);return l.jsx("button",{type:"button",className:j,onClick:()=>!o&&h(n),"aria-pressed":v,"aria-disabled":o,children:a})}function gf({children:n,className:a=""}){return l.jsx("div",{className:hf("mt-0 space-y-0.5",a),children:n})}function Wt({id:n,children:a,keepMounted:r=!1}){const{activeTab:o}=Qg(),u=o===n;return!u&&!r?null:!u&&r?l.jsx("div",{hidden:!0,"aria-hidden":"true",children:a}):l.jsx(l.Fragment,{children:a})}function sA(){const{session:n}=br(),a=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return l.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),l.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:a})]})}const vx=300,bx=240;function aA(n,a){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(a||(a=new WeakSet),typeof n=="object"){if(a.has(n))return"[Circular]";a.add(n)}try{return JSON.stringify(n,(r,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function lA(n){const r=n.map(o=>aA(o)).join(" ");return r.length>bx?`${r.slice(0,bx)}…`:r}function rA(){const n=en(),[a,r]=m.useState([]),o=m.useMemo(()=>a.reduce((u,f)=>(f.direction==="in"&&(u.in+=1),f.direction==="out"&&(u.out+=1),u),{in:0,out:0}),[a]);return m.useEffect(()=>{const u=(g,x,v)=>{r(b=>{const j=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:g,event:x,payload:lA(v),timestamp:new Date().toLocaleTimeString()}];return j.length>vx?j.slice(-vx):j})},f=(g,...x)=>u("in",g,x),h=(g,...x)=>u("out",g,x);n.onAny(f);let p=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),p=()=>n.offAnyOutgoing(h);else{const g=n.emit.bind(n);n.emit=(x,...v)=>(h(x,...v),g(x,...v)),p=()=>{n.emit=g}}return()=>{n.offAny(f),p&&p()}},[n]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Socket activity"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),l.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>r([]),children:"Clear"})]})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No socket activity yet."}):a.slice().reverse().map(u=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-slate-400",children:u.timestamp})," ",l.jsxs("span",{className:u.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",u.direction.toUpperCase(),"]"]})," ",l.jsx("span",{className:"text-cyan-300",children:u.event})," ",l.jsx("span",{className:"text-slate-200",children:u.payload})]},u.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const iA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Kg(){const{state:{roverId:n},actions:{sendOiCommand:a,setSensorStream:r}}=wt(),o=!!n,[u,f]=zg(),h=en(),{value:p,save:g}=Qe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:x,save:v}=Qe("audio",it),b=p?.connectionTransport||"websocket",j=!!p?.swapMobileControlColumns,M=typeof p?.driveMacroBackoffEnabled=="boolean"?p.driveMacroBackoffEnabled:!0,k=Number.isFinite(x?.masterVolume)?x.masterVolume:it.masterVolume,N=Number.isFinite(x?.alertVolume)?x.alertVolume:it.alertVolume,w=Number.isFinite(x?.roverVolume)?x.roverVolume:it.roverVolume,S=typeof x?.mainBrushDuckEnabled=="boolean"?x.mainBrushDuckEnabled:typeof x?.autoLevelEnabled=="boolean"?x.autoLevelEnabled:it.mainBrushDuckEnabled,R=Number.isFinite(x?.mainBrushDuckAmount)?Math.max(0,Math.min(1,x.mainBrushDuckAmount)):it.mainBrushDuckAmount,E=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),A=G=>{n&&r(G)},L=G=>{const Q=G.target.value;g(P=>({...P??{},connectionTransport:Q})),h?.io?.opts&&(h.io.opts.transports=Q==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},V=G=>Q=>{const P=Number(Q.target.value),oe=Number.isFinite(P)?Math.max(0,Math.min(1,P)):0;v(ie=>({...ie??{},[G]:oe}))},O=G=>{const Q=!!G.target.checked;v(P=>({...P??{},mainBrushDuckEnabled:Q}))},z=G=>{const Q=!!G.target.checked;g(P=>({...P??{},swapMobileControlColumns:Q}))},X=G=>{const Q=!!G.target.checked;g(P=>({...P??{},driveMacroBackoffEnabled:Q}))};return l.jsxs(pf,{defaultTab:"keybindings",children:[l.jsxs(xf,{children:[l.jsx(Pt,{id:"keybindings",children:"Keybindings"}),l.jsx(Pt,{id:"controller",children:"Controller"}),l.jsx(Pt,{id:"page",children:"Page settings"}),l.jsx(Pt,{id:"admin",children:"Admin"})]}),l.jsxs(gf,{children:[l.jsx(Wt,{id:"keybindings",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Gw,{})})}),l.jsx(Wt,{id:"controller",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Ww,{})})}),l.jsx(Wt,{id:"page",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"HUD"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:u,onChange:G=>f(G.target.checked)}),l.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:j,onChange:z}),l.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Macros"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:M,onChange:X}),l.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Audio"}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Master volume"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(k*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:k,onChange:V("masterVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Alert/page sounds"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:V("alertVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Rover audio"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:V("roverVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Main brush ducking"}),l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:S,onChange:O})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Main brush duck amount"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(R*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:R,onChange:V("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!S})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Connection"}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Transport"}),l.jsxs("select",{value:b,onChange:L,className:"field-input text-sm",children:[l.jsx("option",{value:"websocket",children:"WebSocket"}),l.jsx("option",{value:"polling",children:"Polling"})]})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),l.jsx(Wt,{id:"admin",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:iA.map(G=>l.jsx("button",{type:"button",onClick:()=>a(G.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:G.label},G.key))})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),l.jsx("div",{className:"surface flex gap-0.5",children:E.map(G=>l.jsx("button",{type:"button",onClick:()=>A(G.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:G.label},G.key))}),!o&&l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),l.jsx(Yg,{}),l.jsx(nA,{}),l.jsx(Ow,{}),l.jsx(sA,{}),l.jsx(rA,{})]})})]})]})}const yx={desktop:{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel, on the bottom left of the page below the rover video.",{segments:["Toggle chat focus with ",{action:"chatFocus"},". Press ",{action:"chatFocus"}," again to send."]}]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen, or press ',{action:"driveMacro"}," on your keyboard to put the rover into driving mode."]},"Refer to the controls for the controls for the rover."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen, or press ',{action:"dockMacro"}," on your keyboard to start docking."]},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}],aside:[{type:"keyboard",title:"Keyboard controls",footnote:"Per-browser; adjust bindings and speeds in Settings → Keybindings.",groups:[{id:"movement",title:"Movement",items:[{action:"driveForward",label:"Forward"},{action:"driveBackward",label:"Backward"},{action:"driveLeft",label:"Turn left"},{action:"driveRight",label:"Turn right"},{action:"boostModifier",label:"Boost speed"},{action:"slowModifier",label:"Precision speed"}]},{id:"macros",title:"Rover modes & chat",items:[{action:"driveMacro",label:"Drive macro"},{action:"dockMacro",label:"Dock macro"},{action:"chatFocus",label:"Chat focus"}]},{id:"camera",title:"Camera",items:[{action:"cameraUp",label:"Tilt up"},{action:"cameraDown",label:"Tilt down"},{action:"nightVisionToggle",label:"Toggle night vision"}]},{id:"motors",title:"Rover Aux Motors",items:[{action:"auxMainForward",label:"Main brush forward"},{action:"auxMainReverse",label:"Main brush reverse"},{action:"auxSideForward",label:"Side brush forward"},{action:"auxSideReverse",label:"Side brush reverse"},{action:"auxVacuumFast",label:"Vacuum max"},{action:"auxVacuumSlow",label:"Vacuum low"},{action:"auxAllForward",label:"All motors forward"}]},{id:"audio",title:"Audio / Song",items:[{action:"songNoteUp",label:"Song note up"},{action:"songNoteDown",label:"Song note down"}]},{id:"room-controls",title:"Room Controls",items:[{action:"homeAssistantOn",label:"Next room control on"},{action:"homeAssistantOff",label:"Next room control off (reverse)"}]}]},{type:"gamepad",title:"Gamepad / joystick",items:["Gamepad controls are fully configurable to handle inconsistent browser mappings.","Use Settings → Controller to bind inputs, calibrate deadzones, and view diagnostics.","If inputs behave oddly, the diagnostics panel will show raw axis/button values."]}]},"mobile-portrait":{main:[{type:"list",title:"Chat and nicknames",items:["Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button onscreen to put the rover into driving mode.']},"Look below the rover video. Use the joystick column to move the rover, and hold the aux buttons in the other control column."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]},"mobile-landscape":{main:[{type:"list",title:"Chat and nicknames",items:["Scroll down to see more of the page.","Set a nickname in the user list panel below.","Tap in the chat box to send messages in the chat."]},{type:"list",title:"Driving the rover",items:[{segments:['Press the "Start Driving" button, or the "Drive" button to put the rover into driving mode.']},"Use the joystick column beside the video feed to move the rover, and hold the aux buttons in the other control column."]},{type:"list",title:"Docking the rover",items:["Line up the rover to the dock, about a foot away, then:",{segments:['Press the "Dock and Charge" or the "Dock" button onscreen to start docking.']},"Wait for the rover to confirm it is docked and charging before leaving it unattended."]}]}};function oA(n){return yx[n]||yx.desktop}function Zg({actionId:n,keymap:a}){const r=a?.[n]?.[0]??"";return l.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:Rt(r)})}function Sx(n,a){return n.map((r,o)=>typeof r=="string"?l.jsx("span",{children:r},`text-${o}`):r?.action?l.jsx(Zg,{actionId:r.action,keymap:a},`pill-${r.action}-${o}`):r?.text?l.jsx("span",{children:r.text},`span-${o}`):null)}function Ao(n,a,r){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return Sx(n.segments,a);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return Sx(n,a)}return String(n??"")}function cA({hero:n,keymap:a}){return n?l.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&l.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&l.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(r=>l.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:r},r))})]}),n.bullets&&l.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((r,o)=>{const u=Array.isArray(r?.segments)?`hero-${o}`:`hero-${o}`;return l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(r,a)},u)})})]}):null}function uA({block:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((r,o)=>{const u=`item-${o}`;return l.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:Ao(r,a)},u)})})]})}function dA({block:n}){const a=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return l.jsxs("div",{className:`surface space-y-0.5 border ${a} px-0.5 py-0.5`,children:[l.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((r,o)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(r,{})},`callout-${o}`))})]})}function fA({group:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),l.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(r=>l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[l.jsx("span",{className:"text-slate-200",children:r.label}),l.jsx(Zg,{actionId:r.action,keymap:a})]},r.action))})]})}function mA({block:n,keymap:a}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(r=>l.jsx(fA,{group:r,keymap:a},r.id))})]}):null}function hA({block:n}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((a,r)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ao(a,{})},`gamepad-${r}`))})]}):null}function jx({block:n,keymap:a}){if(!n)return null;switch(n.type){case"list":return l.jsx(uA,{block:n,keymap:a});case"callout":return l.jsx(dA,{block:n});case"keyboard":return l.jsx(mA,{block:n,keymap:a});case"gamepad":return l.jsx(hA,{block:n});default:return null}}function Jg({layout:n,keymap:a}){const r=m.useMemo(()=>oA(n),[n]),o=a||{},u=r.main||[],f=r.aside||[];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(cA,{hero:r.hero,keymap:o}),l.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[l.jsx("div",{className:"space-y-0.5",children:u.map((h,p)=>l.jsx(jx,{block:h,keymap:o},h.title||p))}),l.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>l.jsx(jx,{block:h,keymap:o},h.title||p))})]})]})}function Pg({layout:n,onOpenOverlay:a}){const{state:r}=wt();return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Help"}),l.jsx("button",{type:"button",onClick:a,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),l.jsx(Jg,{layout:n,keymap:r?.keymap||{}})]})}const pA=["kal","rms","slt","ksp","bdl"],xA=Array.from({length:10},(n,a)=>a*10);function Co({hideInput:n=!1,hideSpectatorNotice:a=!1,fillHeight:r=!1,allowSpectatorInput:o=!1}){const u=de(_=>_.session?.role||null),f=de(_=>_.session?.assignment?.roverId||null),h=de(_=>_.session?.roster??[]),{messages:p,typing:g,sendMessage:x,registerInputRef:v,onInputFocus:b,onInputBlur:j,blurChat:M,setTypingActive:k}=sf(),{value:N,save:w}=Qe("tts",{engine:"flite",voice:"rms",pitch:50}),[S,R]=m.useState(""),[E,A]=m.useState(!1),[L,V]=m.useState(!1),[O,z]=m.useState(()=>N?.engine||"flite"),[X,G]=m.useState(()=>N?.voice||"rms"),[Q,P]=m.useState(()=>Number.isFinite(N?.pitch)?N.pitch:50),oe=u!=="spectator"||o,ie=m.useRef(null),q=!!m.useMemo(()=>h.find(_=>String(_.id)===String(f))||null,[f,h])?.audio?.ttsEnabled,H=m.useMemo(()=>p.slice(-200),[p]),J=m.useMemo(()=>g||[],[g]);m.useEffect(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[H,J]),m.useEffect(()=>{const _=N?.engine||"flite",K=N?.voice||"rms",ne=Number.isFinite(N?.pitch)?N.pitch:50;O!==_&&z(_),X!==K&&G(K),Q!==ne&&P(ne)},[O,Q,N?.engine,N?.pitch,N?.voice,X]),m.useEffect(()=>{V(!!q)},[q]);const ee=m.useMemo(()=>!q||!L?null:O==="espeak"?{speak:!0,engine:O,pitch:Q}:{speak:!0,engine:O,voice:X},[O,Q,L,q,X]);async function ue(_){if(_.preventDefault(),!oe||n)return;const ne=S.replace(/\\n/g,`
|
||
`).trim();if(ne){A(!0);try{await x(ne,ee),R(""),M(),k(!1)}catch(me){alert(me.message)}finally{A(!1)}}}const T=r?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${r?"flex h-full flex-col overflow-hidden":""}`,children:[l.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${T}`,ref:ie,children:[H.length===0&&J.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):H.map(_=>l.jsx(ef,{message:_},_.id)),J.map(_=>l.jsx(pg,{message:_},`typing-${_.typingId||_.id}`))]}),!n&&l.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ue,children:[l.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:S,onChange:_=>{const K=_.target.value;R(K),k(!!K.trim())},onFocus:_=>{b(_),k(!!S.trim())},onBlur:_=>{j(_),k(!1)},onKeyDown:_=>{_.key==="Enter"&&!S.trim()&&(_.preventDefault(),M(),k(!1))},ref:_=>v(_,{target:"panel"}),placeholder:oe?"Type a message…":a?"":"Spectators cannot chat",disabled:!oe}),q&&l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:L,onChange:_=>V(_.target.checked),className:"accent-cyan-500"}),l.jsx("span",{children:"Speak"})]}),l.jsxs("select",{value:O,onChange:_=>{const K=_.target.value;z(K),w(ne=>({...ne||{},engine:K}))},className:"field-input text-xs",children:[l.jsx("option",{value:"flite",children:"flite"}),l.jsx("option",{value:"espeak",children:"espeak"})]}),O==="flite"?l.jsx("select",{value:X,onChange:_=>{const K=_.target.value;G(K),w(ne=>({...ne||{},voice:K}))},className:"field-input text-xs",children:pA.map(_=>l.jsx("option",{value:_,children:_},_))}):l.jsx("select",{value:Q,onChange:_=>{const K=Number(_.target.value);P(K),w(ne=>({...ne||{},pitch:K}))},className:"field-input text-xs",children:xA.map(_=>l.jsxs("option",{value:_,children:["pitch ",_]},_))})]}),l.jsx("button",{type:"submit",disabled:!oe||E,className:"button-dark h-full disabled:opacity-50 self-stretch",children:E?"...":"Send"})]})]})}function jr({compact:n=!1}){const a=de(b=>b.session?.role||null),{setNickname:r}=Gt(),{value:o,save:u}=Qe("profile",{nickname:""}),[f,h]=m.useState(o.nickname||""),[p,g]=m.useState(!1),x=a!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function v(b){if(b.preventDefault(),!x)return;const j=(f||"").trim().slice(0,32);if(j){g(!0);try{await r(j),u({nickname:j})}catch(M){alert(M.message)}finally{g(!1)}}}return l.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[l.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!x}),l.jsx("button",{type:"submit",disabled:!x||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":n?"Set":"Save"})]})}function gA({socials:n,discordInvite:a,kofiLink:r}){const o=Array.isArray(n)?n:null;if(o&&o.length)return o;const u=[];return a&&u.push({id:"discord",label:"Discord",url:a}),r&&u.push({id:"kofi",label:"Ko-fi",url:r}),u}function vA(n){if(!n||typeof n!="object")return null;const a=n.id||n.service||n.key||n.name||null,r=n.label||n.title||n.name||a||"Link",o=n.url||n.link||n.href||null;return o?{id:a,label:r,url:o}:null}function Wg({className:n=""}){const a=de(o=>({socials:o.session?.socials??[],discordInvite:o.session?.discord?.invite||null,kofiLink:o.session?.kofi?.link||null})),r=gA(a).map(vA).filter(Boolean).slice(0,4);return r.length?l.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:r.map(o=>l.jsx(So,{...o},`${o.id||o.label}-${o.url}`))}):null}function bA({compact:n=!1}){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:n})})})}function yA(){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx(Wg,{className:"flex-1 min-h-0"})})}function hd(...n){return n.filter(Boolean).join(" ")}function SA(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function jA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function NA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function wA(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function ko({title:n="Rovers"}){const a=de(S=>S.session?.role||null),r=de(S=>S.session?.roster??[]),o=de(S=>S.session?.turnQueues??{}),u=de(S=>S.session?.users??[]),f=de(S=>S.session?.socketId||null),{requestControl:h}=Gt(),[p,g]=m.useState({}),[x,v]=m.useState(()=>Date.now()),b=m.useMemo(()=>a&&a!=="spectator",[a]),j=m.useMemo(()=>a==="admin"||a==="lockdown"||a==="lockdown-admin",[a]),M=m.useMemo(()=>Object.values(o||{}).some(S=>S?.deadline||S?.idleDeadline),[o]);m.useEffect(()=>{if(!M)return;const S=setInterval(()=>{v(Date.now())},1e3);return()=>clearInterval(S)},[M]);const k=m.useMemo(()=>{const S=new Set(r.map(E=>String(E.id))),R=Object.keys(o||{}).filter(E=>!S.has(String(E))).map(E=>({id:E,name:E,locked:!1,batteryState:null}));return[...r,...R]},[r,o]);async function N(S){if(S){g(R=>({...R,[S]:!0}));try{await h(S)}catch(R){alert(R.message)}finally{g(R=>({...R,[S]:!1}))}}}const w=S=>u.find(R=>R.socketId===S)||{socketId:S,nickname:null,role:null};return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),k.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:k.map(S=>{const R=String(S.id),E=o?.[R]||null,A=E?.queue||[],L=E?.idleDeadline||E?.deadline||null,V=L&&L>x?Math.ceil((L-x)/1e3):L?0:null,O=E?.current||null,z=O?A.findIndex(ee=>ee===O):-1,X=A.length>1?z>=0?A[(z+1)%A.length]:A[0]:null,G=!!(f&&O&&O===f),Q=!!(f&&X&&X===f),P=V!=null&&(G||Q),oe=!!S.locked,ie=oe&&!j,$=!!(S?.private?.enabled&&S?.private?.open),q=S.lockReason?`locked: ${S.lockReason}`:"locked",H=oe?q:p[R]?"...":"request",J=b&&!ie&&!p[R];return l.jsxs("li",{className:hd("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",oe?"bg-red-900/40":$?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&N(S.id)},children:[l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[l.jsxs("p",{className:"min-w-0 flex items-center gap-0.5 whitespace-nowrap text-slate-200",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ts(S.color,.16),children:S.name}),S.description?l.jsx("span",{className:"min-w-0 flex-1 truncate text-[0.7rem] text-slate-400",children:S.description}):null]}),P?l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:G?`${V}s left`:`Your turn in ${V}s`}):null]}),l.jsx("span",{className:hd("text-[0.75rem] font-semibold",jA(S)),children:SA(S)})]}),A.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):l.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:A.map((ee,ue)=>{const T=w(ee),_=ee===O,K=!!(X&&ee===X&&!_),ne=_?"bg-sky-600 text-white ring-2 ring-amber-300":K?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return l.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ne}`,children:[l.jsx("span",{className:`${NA(T.role)} font-semibold`,children:wA(T,f)}),_&&l.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),K&&l.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${R}-${ee}-${ue}`)})})]}),b?l.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),N(S.id)},disabled:p[R]||ie,className:hd("button-dark disabled:opacity-40",oe&&"bg-red-600/70 text-white hover:bg-red-600"),children:H}):null]},S.id)})})]})}function AA(n){switch(n){case"admin":case"lockdown":case"lockdown-admin":return"text-amber-300";case"spectator":return"text-slate-400";default:return"text-sky-300"}}function CA(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function ho({hideNicknameForm:n=!1,hideHeader:a=!1,className:r="",fillHeight:o=!1,compact:u=!1}){const f=de(b=>b.session?.role||null),h=de(b=>b.session?.users??[]),p=de(b=>b.session?.socketId||null),g=f!=="spectator",x=m.useMemo(()=>[...h].sort((b,j)=>b.socketId===p?-1:j.socketId===p?1:(b.nickname||"").localeCompare(j.nickname||"")),[p,h]),v=o?"flex-1 min-h-0 overflow-y-auto":u?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${r}`,children:[!n&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:u})})}),l.jsx(Wg,{})]}),!g&&l.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),l.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!a&&l.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${u?"text-xs":""}`,children:[l.jsx("span",{children:"Users"}),l.jsx("span",{className:"text-xs text-slate-500",children:x.length})]}),l.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${v} ${u?"text-[0.8rem]":""}`,children:x.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):x.map(b=>l.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${AA(b.role)}`,children:CA(b,p)},b.socketId))})]})]})}const kA=/^cu_[a-f0-9]{32}$/,pr="field-input w-full max-w-sm text-left focus:ring-emerald-500",Eo="mx-auto w-full max-w-xl flex justify-center",ir="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function EA(n){const a=String(n||"").trim();return a?a.length<=10?`${a.slice(0,2)}***${a.slice(-2)}`:`${a.slice(0,6)}...${a.slice(-6)}`:""}const Nx=8*1024*1024,Js=16e3,MA={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function wx(n){let a="";for(let o=0;o<n.length;o+=32768){const u=n.subarray(o,o+32768);a+=String.fromCharCode(...u)}return btoa(a)}function RA(n){return typeof btoa=="function"?btoa(n):""}function TA(n){if(!n)return{};const a=RA(`${n}:${n}`);return a?{Authorization:`Basic ${a}`}:{}}function qA(n,a=1500){return new Promise(r=>{if(!n||n.iceGatheringState==="complete"){r();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",u),r()},a);function u(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",u),r())}n.addEventListener("icegatheringstatechange",u)})}function Ax(n){if(!n)return!1;const a=n.connectionState,r=n.iceConnectionState;return a==="connected"||r==="connected"||r==="completed"}function DA(n,a=1e4){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Ax(n)){r();return}const u=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},a),f=()=>{Ax(n)?(h(),r()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function h(){clearTimeout(u),n.removeEventListener("connectionstatechange",f),n.removeEventListener("iceconnectionstatechange",f)}n.addEventListener("connectionstatechange",f),n.addEventListener("iceconnectionstatechange",f)})}async function _A(n){if(!n?.getParameters||!n?.setParameters)return;const a=n.getParameters()||{},r=a.encodings&&a.encodings[0]||{};a.encodings=[{...r,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(a)}catch{}}function OA(n,a=6e3){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}const u=Date.now();let f=-1;const h=setInterval(async()=>{if(Date.now()-u>a){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=n.getSenders().filter(g=>g.track?.kind==="audio");for(const g of p){const x=await g.getStats();for(const v of x.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const b=Number(v.bytesSent||0),j=Number(v.packetsSent||0);if(f<0)f=b;else if(b>f+200||j>5){clearInterval(h),r();return}}}}catch{}},250)})}function BA(n){const a=n.reduce((u,f)=>u+f.length,0),r=new Float32Array(a);let o=0;for(const u of n)r.set(u,o),o+=u.length;return r}function LA(n){const a=new Int16Array(n.length);for(let r=0;r<n.length;r+=1){const o=Math.max(-1,Math.min(1,n[r]));a[r]=o<0?o*32768:o*32767}return a}function zA(n,a){const r=LA(n),o=r.length*2,u=new ArrayBuffer(44+o),f=new DataView(u),h=(g,x)=>{for(let v=0;v<x.length;v+=1)f.setUint8(g+v,x.charCodeAt(v))};h(0,"RIFF"),f.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,1,!0),f.setUint32(24,a,!0),f.setUint32(28,a*2,!0),f.setUint16(32,2,!0),f.setUint16(34,16,!0),h(36,"data"),f.setUint32(40,o,!0);let p=44;for(let g=0;g<r.length;g+=1,p+=2)f.setInt16(p,r[g],!0);return new Uint8Array(u)}function mn({label:n,active:a,detail:r=""}){return l.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${a?"bg-emerald-500":"bg-slate-700"}`,children:[l.jsx("div",{className:"text-center font-medium",children:n}),l.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:r||(a?"active":"idle")})]})}function Bd({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function UA({ownRoverId:n="",audioForwardByRover:a={},playUploadedAudio:r,stopUploadedAudio:o,startMicWhip:u,readyMicWhip:f,stopMicWhip:h}){const{state:p}=wt(),{value:g,save:x}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[b,j]=m.useState(null),[M,k]=m.useState(!1),N=!!g?.openMicEnabled,S=(g?.pttMode==="clip"?"clip":"live")==="clip",[R,E]=m.useState("idle"),[A,L]=m.useState("idle"),[V,O]=m.useState(""),z=m.useRef(null),X=m.useRef(null),G=m.useRef(null),Q=m.useRef(!1),P=m.useRef(""),oe=m.useRef(null),ie=m.useRef(null),$=m.useRef(null),q=m.useRef(null),H=m.useRef(null),J=m.useRef([]),ee=m.useRef(!1),ue=m.useRef(Js),T=!!p?.mic?.pttActive,_=m.useMemo(()=>v&&a?.[v]||null,[a,v]),K=!!(_&&_.state!=="offline"&&!_.error),ne=_?.source==="upload"&&_?.state==="playing",me=_?.source==="mic-whip"&&(_?.state==="starting"||_?.state==="playing"),ce=!!(!S&&X.current&&(N||T)),fe=!S&&(R==="live"||R==="starting"),be=S&&A==="recording",ge=S&&A==="sending",xe=Rt(p?.keymap?.micPtt?.[0])||"M",ze=m.useCallback(pe=>{const je=pe==="clip"?"clip":"live";x(Ae=>({...Ae||{},pttMode:je}))},[x]),Ee=async()=>{if(!v){O("Take control of your rover first.");return}if(!b){O("Select an audio file first.");return}if(b.size>Nx){O(`File too large (max ${Nx} bytes).`);return}k(!0),O("");try{const pe=await b.arrayBuffer(),je=wx(new Uint8Array(pe));await r?.({roverId:v,name:b.name,mime:b.type||"",dataBase64:je}),O("Upload playback started.")}catch(pe){O(pe?.message||"Failed to play upload.")}finally{k(!1)}},Te=async()=>{if(!v){O("Take control of your rover first.");return}k(!0),O("");try{await o?.(v),O("Upload playback stopped.")}catch(pe){O(pe?.message||"Failed to stop upload.")}finally{k(!1)}},Oe=m.useCallback(async pe=>{const je=String(pe||P.current||"").trim();if(Q.current=!1,E("idle"),G.current){try{G.current.getSenders().forEach(Ae=>Ae.track?.stop())}catch{}try{G.current.close()}catch{}}if(G.current=null,z.current)try{z.current.getTracks().forEach(Ae=>Ae.stop())}catch{}if(z.current=null,X.current=null,je)try{await h?.(je)}catch{}P.current=""},[h]),Ue=m.useCallback(async pe=>{const je=await u?.(pe),Ae=String(je?.whipUrl||"").trim(),Re=String(je?.token||"").trim();if(!Ae||!Re)throw new Error("WHIP endpoint unavailable");const le=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Js,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});z.current=le;const he=le.getAudioTracks()?.[0];if(X.current=he||null,he&&(he.enabled=!!(N||T)),he?.applyConstraints)try{await he.applyConstraints({channelCount:1,sampleRate:Js,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const De=new RTCPeerConnection(MA);G.current=De,De.onconnectionstatechange=()=>{if(!Q.current)return;const Ft=De.connectionState;if(Ft==="connected"){E("live");return}(Ft==="failed"||Ft==="disconnected"||Ft==="closed")&&(E("error"),O(`WHIP transport ${Ft}.`))},le.getAudioTracks().forEach(Ft=>{const Ne=De.addTrack(Ft,le);_A(Ne)});const Tt=await De.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await De.setLocalDescription(Tt),await qA(De,1800);const qt=await fetch(Ae,{method:"POST",headers:{"Content-Type":"application/sdp",...TA(Re)},body:De.localDescription?.sdp||Tt.sdp});if(!qt.ok)throw new Error(`WHIP request failed: ${qt.status}`);const nl=await qt.text();await De.setRemoteDescription({type:"answer",sdp:nl}),await DA(De,1e4),await OA(De,6e3),await f?.(pe)},[N,T,f,u]),ht=m.useCallback(async()=>{if(ee.current=!1,q.current){try{q.current.disconnect()}catch{}q.current.onaudioprocess=null}if($.current)try{$.current.disconnect()}catch{}if(H.current)try{H.current.disconnect()}catch{}if(oe.current)try{oe.current.getTracks().forEach(pe=>pe.stop())}catch{}if(ie.current)try{await ie.current.close()}catch{}J.current=[],q.current=null,$.current=null,H.current=null,oe.current=null,ie.current=null,ue.current=Js},[]),re=m.useCallback(async()=>{if(oe.current&&ie.current&&q.current)return;L(he=>he==="recording"?he:"arming");const pe=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Js,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),je=new AudioContext({latencyHint:"interactive"}),Ae=je.createMediaStreamSource(pe),Re=je.createScriptProcessor(1024,1,1),le=je.createGain();le.gain.value=0,Re.onaudioprocess=he=>{if(!ee.current)return;const De=he.inputBuffer.getChannelData(0);J.current.push(new Float32Array(De))},Ae.connect(Re),Re.connect(le),le.connect(je.destination),oe.current=pe,ie.current=je,$.current=Ae,q.current=Re,H.current=le,ue.current=je.sampleRate||Js},[]),ae=m.useCallback(async({send:pe})=>{const je=ee.current;if(ee.current=!1,!je){pe||L("idle");return}const Ae=J.current;if(J.current=[],!pe){L("idle");return}if(!v){L("idle");return}if(!Ae.length){L("idle");return}L("sending");try{const Re=BA(Ae),le=zA(Re,ue.current||Js),he=wx(le);await r?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:he}),L("idle")}catch(Re){L("error"),O(Re?.message||"Failed to send PTT clip.")}},[r,v]),Se=m.useCallback(async()=>{if(!v){O("Take control of your rover first.");return}await re(),J.current=[],ee.current=!0,L("recording")},[re,v]);return m.useEffect(()=>{let pe=!1;async function je(){if(S){await Oe(P.current||v);return}if(!v){await Oe(P.current);return}if(!(Q.current&&P.current===v)&&!(!N&&!T))try{E("starting"),O(""),Q.current=!0,P.current=v,await Ue(v),pe||E("live")}catch(Ae){pe||(E("error"),O(Ae?.message||"Failed to start mic forwarding.")),await Oe(v)}}return je(),()=>{pe=!0}},[S,N,T,v,Ue,Oe]),m.useEffect(()=>{const pe=X.current;pe&&(pe.enabled=!!(!S&&(N||T)))},[S,N,T]),m.useEffect(()=>{let pe=!1;async function je(){if(!S||!v){ee.current&&await ae({send:!1}),L("idle");return}try{await re(),!pe&&!ee.current&&L("idle")}catch(Ae){pe||(L("error"),O(Ae?.message||"Microphone access failed for clip mode."))}}return je(),()=>{pe=!0}},[S,re,ae,v]),m.useEffect(()=>{let pe=!1;async function je(){if(S){if(!v){ee.current&&await ae({send:!1});return}if(T){if(!ee.current)try{O(""),await Se()}catch(Ae){pe||(L("error"),O(Ae?.message||"Failed to start clip recording."))}}else ee.current&&await ae({send:!0})}}return je(),()=>{pe=!0}},[S,ae,T,v,Se]),m.useEffect(()=>()=>{Oe(P.current||v),ht()},[v,Oe,ht]),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"grid gap-1",children:[l.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[l.jsx("span",{children:"Push-to-Talk Key"}),l.jsx(Bd,{label:xe})]})}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),l.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${S?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>ze("live"),children:"Live Mic (WHIP)"}),l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${S?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>ze("clip"),children:"Record Clip"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(mn,{label:"Mode",active:S,detail:S?"record clip":"live mic"}),l.jsx(mn,{label:"PTT hold",active:T,detail:T?"held":"released"}),l.jsx(mn,{label:"Recording",active:be,detail:be?"capturing":"idle"}),l.jsx(mn,{label:"Playback",active:S&&ne,detail:S&&ne?"playing":"idle"})]})]})})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),l.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),l.jsx("input",{className:`${pr} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:M||!v,onChange:pe=>j(pe.target.files?.[0]||null)})]}),l.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?l.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):l.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!v,onClick:Ee,children:M?"Working...":"Play Upload"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!v,onClick:Te,children:"Stop"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),l.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:N,disabled:!v||S,onChange:pe=>x(je=>({...je||{},openMicEnabled:!!pe.target.checked}))}),l.jsx("span",{children:S?"Open mic (live mode only)":"Open mic"})]}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(mn,{label:"WHIP link",active:fe,detail:R}),l.jsx(mn,{label:"Mic hot",active:ce,detail:ce?"transmitting":"muted"}),l.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",l.jsx(Bd,{label:xe})," to talk"]})]})]})})]}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[l.jsx(mn,{label:"Forward pipe",active:K,detail:K?"connected":"offline"}),l.jsx(mn,{label:"Upload playback",active:ne,detail:ne?"playing":"idle"}),l.jsx(mn,{label:"Mic relay",active:me,detail:me?"active":"idle"}),l.jsx(mn,{label:"WHIP transport",active:fe,detail:R}),l.jsx(mn,{label:"Clip recording",active:be,detail:be?"recording":"idle"}),l.jsx(mn,{label:"Clip sending",active:ge,detail:ge?"sending":"idle"})]}),V?l.jsx("div",{className:"text-xs text-slate-400 text-center",children:V}):null]})})]})})}function HA({pendingRequestId:n,currentStoredKey:a,nickname:r,requestVerification:o,applyIdentityKey:u,onMessage:f,fullWidth:h=!1}){const[p,g]=m.useState(0),[x,v]=m.useState(""),[b,j]=m.useState(!1),[M,k]=m.useState(!1),N=()=>{g(1),v(a),j(!1),f?.("")},w=()=>{g(0),j(!1)},S=async E=>{if(E.preventDefault(),!b){f?.("Please confirm your nickname agreement before sending.");return}if(p<3){f?.("Complete all request steps before sending.");return}k(!0),f?.("");try{const A=await u(x);await o?.(),v(A),g(0),j(!1),f?.("Verification request sent to lockdown admins.")}catch(A){f?.(A.message||"Failed to submit request.")}finally{k(!1)}},R=h?"w-full":Eo;return n?l.jsx("section",{className:`surface text-sm text-slate-300 ${R}`,children:l.jsxs("div",{className:ir,children:["Verification request pending: ",n]})}):p===0?l.jsx("section",{className:`surface ${R}`,children:l.jsxs("div",{className:ir,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:N,disabled:M,children:"Request Verification"})]})}):l.jsx("form",{className:`surface ${R}`,onSubmit:S,children:l.jsxs("div",{className:ir,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",p," of 3"]}),p===1?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),l.jsx("div",{className:"mx-auto w-full max-w-sm",children:l.jsx(jr,{compact:!0})}),l.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",l.jsx("span",{className:"font-semibold",children:r||"(not set)"})]}),l.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:E=>j(E.target.checked)}),l.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!r||!b,onClick:()=>g(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,p===2?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),l.jsx("input",{className:pr,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:x,onChange:E=>v(E.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>navigator.clipboard?.writeText(x),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>g(3),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(1),children:"Back"})]})]}):null,p===3?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),l.jsx("input",{className:pr,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:x,onChange:E=>v(E.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:M||!x,children:"Confirm Request"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(2),children:"Back"})]})]}):null]})})}function VA({currentStoredKey:n,applyIdentityKey:a,onMessage:r,fullWidth:o=!1}){const[u,f]=m.useState(0),[h,p]=m.useState(""),[g,x]=m.useState(!1),v=()=>{f(1),p(""),r?.("")},b=()=>{f(0),p("")},j=async k=>{if(k.preventDefault(),!(u<2)){x(!0),r?.("");try{await a(h),f(0),p(""),r?.("Identity key restored.")}catch(N){r?.(N.message||"Failed to restore key.")}finally{x(!1)}}},M=o?"w-full":Eo;return l.jsx("section",{className:`surface ${M}`,children:l.jsxs("div",{className:ir,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",EA(n)||"not set yet"]}),l.jsx("input",{className:pr,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),u===0?l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:v,disabled:g,children:"Restore Key"})]}):null,u===1?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,u===2?l.jsxs("form",{className:"space-y-0.5",onSubmit:j,children:[l.jsx("input",{className:pr,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:k=>p(k.target.value.toLowerCase()),placeholder:"Paste key to restore"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:g||!h,children:"Confirm Restore"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function $A({requestableRovers:n=[],pendingRequests:a=[],requestPrivateRoverAccess:r,onMessage:o,fullWidth:u=!1}){const[f,h]=m.useState({}),p=m.useMemo(()=>{const v=new Map;return(a||[]).forEach(b=>{b?.roverId&&v.set(String(b.roverId),b)}),v},[a]),g=u?"w-full":Eo,x=async v=>{if(v){h(b=>({...b,[v]:!0})),o?.("");try{(await r?.(v))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{h(b=>({...b,[v]:!1}))}}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${g}`,children:l.jsxs("div",{className:ir,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?l.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):l.jsx("div",{className:"w-full space-y-0.5",children:n.map(v=>{const b=String(v.id),j=!!f[b],M=p.get(b);return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[l.jsxs("div",{className:"min-w-0 text-left",children:[l.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:v.name||b}),l.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),M?l.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):l.jsx("button",{type:"button",onClick:()=>x(b),disabled:j,className:"button-dark text-xs disabled:opacity-50",children:j?"Sending...":"Request"})]},b)})})]})})}function Qa(n){return String(n||"").trim()}function GA(n){const a=Qa(n);return a?a.includes("DOCKINGRUNNING")?"Returning":a.includes("PAUSED")?"Paused":a.includes("HOUSECLEANINGRUNNING")?"Cleaning":a.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":a.includes("STATE_START")?"Starting":a.includes("STATE_IDLE")||a.includes("STATE_STANDBY")?"Idle":a:"--"}function ev(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function Qi({label:n,value:a,tone:r="muted",valueClass:o="",hideLabel:u=!1}){return l.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${ev(r)}`,children:[u?null:l.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),l.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(a||""),children:a})]})}function FA(n=[]){const u=[...n.filter(k=>k&&k.valid&&Number.isFinite(k.angleDeg)&&Number.isFinite(k.distanceMm))].sort((k,N)=>Number(k.angleDeg)-Number(N.angleDeg)),f=[];let h=[];for(const k of u){if(!h.length){h.push(k);continue}const N=h[h.length-1],w=Math.abs(Number(k.angleDeg)-Number(N.angleDeg)),S=Math.max(0,Number(N.distanceMm)),R=Math.max(0,Number(k.distanceMm)),E=Math.abs(R-S);if(w<=2&&E<=900){h.push(k);continue}f.push(h),h=[k]}h.length&&f.push(h);const p=f.map(k=>{const N=k.map(S=>Math.max(0,Number(S.distanceMm))),w=N.reduce((S,R)=>S+R,0)/Math.max(1,N.length);return{points:k,size:k.length,avgDistanceMm:w}}),x=p.reduce((k,N)=>N.size>(k?.size||0)?N:k,null)?.avgDistanceMm||1e3,v=p.filter(k=>{const N=k.size<=3,w=k.avgDistanceMm>x*1.8&&k.avgDistanceMm-x>1400;return!(N&&w)}).flatMap(k=>k.points),b=v.map(k=>Math.max(0,Number(k.distanceMm))).sort((k,N)=>k-N),j=Math.max(0,Math.floor((b.length-1)*.95)),M=Math.max(1e3,b[j]||1e3);return v.map(k=>{const N=(Number(k.angleDeg)-90)*Math.PI/180,w=Math.max(0,Number(k.distanceMm)),R=Math.max(0,Math.min(1,w/M))*102,E=110+Math.cos(N)*R,A=110+Math.sin(N)*R,V=38+Math.max(0,Math.min(255,Number(k.intensity)||0))/255*38;return{key:`${k.angleDeg}-${k.distanceMm}-${k.intensity}`,x:E,y:A,fill:`hsl(198 100% ${V}%)`}})}function YA({neato:n,lidar:a,lidarActive:r=!0,onStart:o,onSendHome:u,onLocate:f,onClearErrors:h,onPowerCycle:p,fullWidth:g=!1}){const[x,v]=m.useState(""),[b,j]=m.useState(!1),[M,k]=m.useState(!1),N=g?"w-full":"w-full max-w-xl",w=!!n?.configured,S=!!(n?.enabled&&n?.connected),R=!!n?.telemetry?.extPowerPresent,E=!!n?.telemetry?.chargingActive,A=GA(n?.telemetry?.uiState),L=Qa(n?.telemetry?.robotState)||"--",V=n?.telemetry?.batteryPercent,O=Number.isFinite(V)?`${V}%`:"--",z=n?.telemetry?.batteryVoltage,X=Number.isFinite(z)?`${z.toFixed(2)} V`:"--",G=Qa(n?.telemetry?.robotError)||"--",Q=Qa(n?.telemetry?.robotAlert)||"--",P=Array.isArray(a?.points)?a.points:[],oe=m.useMemo(()=>r?FA(P):[],[r,P]),ie=Qa(a?.status)||"--",$=a?.debug&&typeof a.debug=="object"?a.debug:null,q=Qa($?.reason)||"--",H=$?.stats&&typeof $.stats=="object"?$.stats:null,J=n?.controls||{},ee=!!J?.start?.available,ue=!!J?.sendHome?.available,T=!!J?.locate?.available,_=!!J?.clearErrors?.available,K=!!J?.powerCycle?.available,ne=w&&S&&ee,me=w&&S&&ue,ce=w&&S&&T,fe=w&&S&&_,be=w&&S&&K,ge=async(Oe,Ue)=>{if(Ue){v(Oe);try{await Ue()}catch{}finally{v("")}}},xe=w?S?"Online":"Offline":"Not configured",ze=w?S?"good":"danger":"warn",Ee=V==null?"muted":V>=60?"good":V>=25?"warn":"danger",Te=R?"Docked":A!=="--"?A:"Away from dock";return m.useEffect(()=>{if(!r||!a||!Array.isArray(a.points))return;j(!0);const Oe=setTimeout(()=>{j(!1)},120);return()=>clearTimeout(Oe)},[a,r]),l.jsx("section",{className:`surface text-sm text-slate-200 ${N}`,children:l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac. Be nice to him."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${ev(ze)}`,children:xe})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)] gap-0.5",children:[l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Controls"}),l.jsx("button",{type:"button",disabled:!ne||!!x,onClick:()=>ge("start",o),className:"rounded-md border border-sky-300 bg-emerald-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-emerald-500 disabled:opacity-50",children:x==="start"?"Starting...":"Start cleaning"}),l.jsx("button",{type:"button",disabled:!me||!!x,onClick:()=>ge("sendHome",u),className:"rounded-md border border-sky-300 bg-sky-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-sky-500 disabled:opacity-50",children:x==="sendHome"?"Sending...":"Send to dock"}),l.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[l.jsx("button",{type:"button",disabled:!ce||!!x,onClick:()=>ge("locate",f),className:"w-full rounded-md border border-sky-300 bg-fuchsia-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-sky-500 hover:bg-fuchsia-500 disabled:opacity-50",children:x==="locate"?"Playing...":"Play sound"}),l.jsx("button",{type:"button",disabled:!fe||!!x,onClick:()=>ge("clearErrors",h),className:"w-full rounded-md border border-sky-300 bg-amber-500 px-1 py-0.5 text-xs font-semibold text-slate-900 transition hover:border-sky-500 hover:bg-amber-400 disabled:opacity-50",children:x==="clearErrors"?"Clearing...":"Clear errors"}),l.jsx("button",{type:"button",disabled:!be||!!x,onClick:()=>ge("powerCycle",p),className:"w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50",children:x==="powerCycle"?"Cycling...":"Power cycle"})]}),l.jsxs("div",{className:"surface-muted grid gap-0.5 pt-0.25",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Power status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx(Qi,{label:"Battery",value:O,tone:Ee}),l.jsx(Qi,{label:"Voltage",value:X,tone:"muted"}),l.jsx(Qi,{label:"Docked",value:R?"Docked":"Not docked",tone:R?"good":"muted",hideLabel:!0}),l.jsx(Qi,{label:"Charging",value:E?"charging":"not charging",tone:E?"good":"muted",hideLabel:!0})]})]})]}),l.jsx("div",{className:"grid gap-0.5",children:l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Robot Status"}),l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(13rem,15rem)] gap-0.5 items-start",children:[l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot state (raw)"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:L})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Basic state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:Te})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"UI state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:A})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot error"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:G})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot alert"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:Q})]})]}),l.jsxs("div",{className:`rounded-md px-1 py-0.5 ${b?"bg-emerald-900":"bg-slate-800"}`,children:[l.jsx("button",{type:"button",onClick:()=>k(Oe=>!Oe),className:"w-full text-left text-[0.72rem] text-slate-300",children:"Lidar"}),l.jsx("div",{className:"mt-0.25 text-center text-[0.68rem] text-slate-400",children:"Front of robot"}),l.jsx("div",{className:"mt-0.25 aspect-square rounded-md bg-slate-800 p-0",children:oe.length?l.jsxs("svg",{viewBox:"0 0 220 220",className:"h-full w-full",children:[l.jsx("rect",{x:"0",y:"0",width:"220",height:"220",fill:"#1e293b"}),l.jsx("rect",{x:"7",y:"7",width:"206",height:"206",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:"33",y:"33",width:"154",height:"154",fill:"none",stroke:"#475569",strokeWidth:"1"}),l.jsx("rect",{x:"59",y:"59",width:"102",height:"102",fill:"none",stroke:"#475569",strokeWidth:"1"}),l.jsx("rect",{x:"85",y:"85",width:"50",height:"50",fill:"none",stroke:"#334155",strokeWidth:"1"}),l.jsx("line",{x1:"110",y1:"7",x2:"110",y2:"213",stroke:"#475569",strokeWidth:"1"}),l.jsx("line",{x1:"7",y1:"110",x2:"213",y2:"110",stroke:"#475569",strokeWidth:"1"}),l.jsx("circle",{cx:"110",cy:"110",r:"4",fill:"#e2e8f0"}),oe.map(Oe=>l.jsx("circle",{cx:Oe.x,cy:Oe.y,r:"1.8",fill:Oe.fill},Oe.key))]}):l.jsx("div",{className:"flex h-full items-center justify-center text-center text-xs text-slate-400",children:"Waiting for scan"})}),M?l.jsxs("div",{className:"mt-0.5 rounded-md bg-slate-900 px-0.75 py-0.5 font-mono text-[0.68rem] text-slate-300",children:[l.jsxs("div",{children:["Status: ",ie]}),l.jsxs("div",{children:["Reason: ",q]}),l.jsxs("div",{children:["Points: ",P.length]}),l.jsxs("div",{children:["Rotation: ",Number.isFinite(a?.rotationSpeed)?a.rotationSpeed.toFixed(2):"--"]}),l.jsxs("div",{children:["Request in flight: ",$?.requestInFlight?"yes":"no"]}),l.jsxs("div",{children:["Started at: ",$?.requestStartedAt||"--"]}),l.jsxs("div",{children:["Headers: ",H?.headersSeen??"--"]}),l.jsxs("div",{children:["Rotations: ",H?.rotationsSeen??"--"]}),l.jsxs("div",{children:["Scans ok: ",H?.scansOk??"--"]}),l.jsxs("div",{children:["Timeouts: ",H?.scansTimedOut??"--"]}),l.jsxs("div",{children:["Restarts: ",H?.scansRestarted??"--"]}),l.jsxs("div",{children:["Rotation no scan: ",H?.rotationsWithoutScan??"--"]}),l.jsxs("div",{children:["Parseable payloads: ",H?.parseablePayloads??"--"]}),l.jsxs("div",{children:["Point payloads: ",H?.pointPayloads??"--"]})]}):null]})]})]})})]}),!w||!S||!ee||!ue||!T||!_||!K?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:w?S?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function XA(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function QA(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function IA({lift:n,onUp:a,onDown:r,fullWidth:o=!1}){const[u,f]=m.useState(""),[h,p]=m.useState(()=>Date.now()),g=o?"w-full":"w-full max-w-xl",x=!!n?.configured,v=!!(n?.enabled&&n?.connected),b=!!n?.busy,j=String(n?.target||"").toLowerCase(),M=String(n?.position||"").toLowerCase(),k=!!n?.availability?.upSwitch,N=!!n?.availability?.downSwitch,w=Number(n?.lastActionAt||0),S=Math.max(0,Number(n?.commandCooldownMs||0)),R=Math.max(0,w+S-h),E=!b&&R>0,A=b||E;m.useEffect(()=>{if(!A)return;const G=setInterval(()=>{p(Date.now())},100);return()=>clearInterval(G)},[A]),m.useEffect(()=>{p(Date.now())},[w,S,b]);const L=x?v?A?"Busy":"Ready":"Offline":"Not configured",V=x?v?A?"warn":"good":"danger":"warn",O=x&&v&&!A&&!u&&k&&N,z=m.useMemo(()=>Math.ceil(R/1e3),[R]),X=async(G,Q)=>{if(Q){f(G);try{await Q()}catch{}finally{f("")}}};return l.jsxs("section",{className:`surface relative text-sm text-slate-200 ${g}`,children:[A?l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center rounded-md bg-slate-950/80 px-1.5 text-center",children:l.jsxs("div",{className:"space-y-0.25",children:[l.jsx("p",{className:"text-sm font-semibold text-slate-100",children:b?"Preparing to move":"Moving!"}),l.jsx("p",{className:"text-xs text-slate-300",children:"Controls are disabled while the lift is moving, otherwise its tiny brain would get confused."}),!b&&E?l.jsxs("p",{className:"text-xs text-slate-400",children:["About ",z,"s remaining."]}):null]})}):null,l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${XA(V)}`,children:L})]}),l.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[l.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),l.jsx("div",{className:"text-base font-semibold text-slate-100",children:QA(M)})]}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>X("down",r),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="down"||j==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="down"||j==="down"?"Lowering...":"Down"}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>X("up",a),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="up"||j==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="up"||j==="up"?"Raising...":"Up"})]})}),!x||!v||!k||!N?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:x?v?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?l.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})]})}function tv({isActive:n=!0}){const a=de($=>$.session),r=de($=>$.neatoLidar),{identifySession:o,requestVerification:u,requestPrivateRoverAccess:f,playUploadedAudio:h,stopUploadedAudio:p,startMicWhip:g,readyMicWhip:x,stopMicWhip:v,neatoStart:b,neatoSendHome:j,neatoLocate:M,neatoClearErrors:k,neatoPowerCycle:N,liftUp:w,liftDown:S}=Gt(),{value:R,save:E}=Qe("identity",{cookieUserId:""}),{value:A}=Qe("profile",{nickname:""}),L=m.useMemo(()=>(R?.cookieUserId||"").trim(),[R?.cookieUserId]),V=(A?.nickname||"").trim(),O=!!a?.isVerified,z=a?.verification?.pendingRequestId||null,X=a?.privateRoverAccess?.requestableRovers||[],G=a?.privateRoverAccess?.pendingRequests||[],Q=String(a?.assignment?.roverId||"").trim(),[P,oe]=m.useState(""),ie=async $=>{const q=String($||"").trim().toLowerCase();if(!q)throw new Error("Identity key required.");if(!kA.test(q))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return E(H=>({...H||{},cookieUserId:q})),await o({cookieUserId:q,nickname:V}),q};return l.jsxs("section",{className:"space-y-2 text-base",children:[l.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[O?null:l.jsx("div",{className:"lg:col-span-2",children:l.jsx(HA,{pendingRequestId:z,currentStoredKey:L,nickname:V,requestVerification:u,applyIdentityKey:ie,onMessage:oe,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:O?l.jsxs("div",{className:"space-y-2",children:[l.jsx(YA,{neato:a?.neato||null,lidar:r,lidarActive:n,onStart:b,onSendHome:j,onLocate:M,onClearErrors:k,onPowerCycle:N,fullWidth:!0}),l.jsx(IA,{lift:a?.lift||null,onUp:w,onDown:S,fullWidth:!0}),l.jsx(UA,{ownRoverId:Q,audioForwardByRover:a?.audioForward||{},playUploadedAudio:h,stopUploadedAudio:p,startMicWhip:g,readyMicWhip:x,stopMicWhip:v})]}):l.jsx("section",{className:"surface h-full",children:l.jsx("div",{className:"flex h-full flex-col items-center justify-center text-center text-xs text-slate-400",children:"Verify your account to unlock VIP controls."})})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx($A,{requestableRovers:X,pendingRequests:G,requestPrivateRoverAccess:f,onMessage:oe,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(VA,{currentStoredKey:L,applyIdentityKey:ie,onMessage:oe,fullWidth:!0})})]}),P?l.jsx("div",{className:Eo,children:l.jsx("p",{className:"text-xs text-slate-400 text-center",children:P})}):null]})}const KA=420,ZA=1200,JA={1:262,2:330,3:392,4:523};function po(){const n=de(N=>N.session?.buttonBox?.buttons??[]),a=en(),{value:r}=Qe("audio",it),o=Number.isFinite(r?.masterVolume)?r.masterVolume:it.masterVolume,u=Number.isFinite(r?.alertVolume)?r.alertVolume:it.alertVolume,f=Math.max(0,Math.min(1,o*u)),h=m.useMemo(()=>{const N=Array.isArray(n)?n:[];return N.length===4?N:[1,2,3,4].map(w=>N.find(S=>Number(S?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n]),[p,g]=m.useState({}),[x,v]=m.useState({}),b=m.useRef(new Map),j=m.useRef(new Map),M=m.useRef({}),k=m.useRef(null);return m.useEffect(()=>{const N={};h.forEach(S=>{N[S.id]=Number(S.lastRewardAt||0)});const w=M.current||{};h.forEach(S=>{const R=Number(S.id),E=N[R]||0,A=Number(w[R]||0);if(E>0&&E!==A){v(O=>({...O,[R]:!0}));const L=j.current.get(R);L&&clearTimeout(L);const V=setTimeout(()=>{v(O=>({...O,[R]:!1})),j.current.delete(R)},ZA);j.current.set(R,V)}}),M.current=N},[h]),m.useEffect(()=>{function N(S){const R=JA[S];if(!R||f<=0)return;let E=k.current;if(!E){const O=window.AudioContext||window.webkitAudioContext;if(!O)return;E=new O,k.current=E}const A=E.createOscillator(),L=E.createGain();A.type="square",A.frequency.value=R;const V=.14*f;L.gain.setValueAtTime(1e-4,E.currentTime),L.gain.exponentialRampToValueAtTime(Math.max(1e-4,V),E.currentTime+.01),L.gain.exponentialRampToValueAtTime(1e-4,E.currentTime+.2),A.connect(L),L.connect(E.destination),A.start(),A.stop(E.currentTime+.21)}function w(S={}){const R=Number(S.buttonId);if(!Number.isFinite(R)||R<1||R>4)return;g(L=>({...L,[R]:!0}));const E=b.current.get(R);E&&clearTimeout(E);const A=setTimeout(()=>{g(L=>({...L,[R]:!1})),b.current.delete(R)},KA);b.current.set(R,A),N(R)}return a.on("buttonBox:increment",w),()=>{a.off("buttonBox:increment",w)}},[f,a]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("header",{className:"panel-muted text-center text-sm",children:l.jsx("p",{children:"Button Box"})}),l.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:h.map(N=>{const w=Number(N.id),S=Number.isFinite(N.count)?N.count:0,R=Number.isFinite(N.goal)?N.goal:0,E=typeof N.rewardName=="string"&&N.rewardName.trim()?N.rewardName.trim():"Unassigned",A=Number.isFinite(N.rewardNumber)?N.rewardNumber:"?",L=!!p[w],V=!!x[w];return l.jsx(xg,{buttonId:w,count:S,goal:R,rewardNumber:A,rewardName:E,className:[L?"bg-cyan-900/45":"",V?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function PA(){const{state:{roverId:n}}=wt(),r=pn(n)?.sensors||{};return l.jsx("section",{className:"panel-section",children:l.jsx("div",{className:"aspect-square w-full",children:l.jsx(Od,{sensors:r})})})}function WA(){const{state:{roverId:n,keymap:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:h,startHorn:p,stopHorn:g}}=wt(),x=Tg(n),v=x.docked&&!x.driving,b=r?.config,j=!!(n&&r?.enabled&&b),M=!!(n&&u?.nightVision),k=u?.nightVisionState,N=!!(n&&u?.horn),w=o?.overheated,S=typeof b?.minAngle=="number"?b.minAngle:-30,R=typeof b?.maxAngle=="number"?b.maxAngle:30,E=typeof r?.angle=="number"?r.angle:typeof b?.homeAngle=="number"?b.homeAngle:(S+R)/2,A=Rt(a?.nightVisionToggle?.[0]),L=Rt(a?.hornHonk?.[0]),V=Rt(a?.cameraUp?.[0]),O=Rt(a?.cameraDown?.[0]);return l.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[l.jsx(qg,{layout:"desktop",expand:!0,driveDockState:x}),v?null:l.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[M&&l.jsx(Dg,{nightVisionOn:k?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:A}),N&&l.jsx(_g,{disabled:!n||w,onStart:p,onStop:g,keyLabel:L,active:o?.active,heat:o?.heat}),j&&l.jsx(Og,{value:E,min:S,max:R,onChange:f,keyDownLabel:O,keyUpLabel:V,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 e2({layout:n,onOpenHelpOverlay:a}){const[r,o]=m.useState("telemetry"),u=de(N=>!!N.session?.isVerified),f=de(N=>String(N.session?.assignment?.roverId||"").trim()),h=de(N=>{const w=String(N.session?.assignment?.roverId||"").trim();return w&&N.session?.audioForward?.[w]||null}),{state:p}=wt(),{value:g}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),x=u?"bg-emerald-400":"bg-red-600",v=!!p?.mic?.pttActive,b=!!g?.openMicEnabled,j=g?.pttMode==="clip"?"clip":"live",M=!!(f&&u&&(j==="clip"?v:b||v)),k=!!(f&&u&&j==="clip"&&h?.source==="upload"&&h?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(pf,{defaultTab:"telemetry",currentTab:r,onTabChange:o,children:[l.jsxs(xf,{children:[l.jsx(Pt,{id:"telemetry",children:"Controls"}),l.jsx(Pt,{id:"vip",highlight:k?"green":M?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-2",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${x}`,"aria-hidden":"true",title:u?"Verified":"Not verified"})]})}),l.jsx(Pt,{id:"help",children:"Help"}),l.jsx(Pt,{id:"settings",children:"Settings"})]}),l.jsxs(gf,{children:[l.jsx(Wt,{id:"telemetry",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[l.jsx(PA,{}),l.jsx(WA,{})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[l.jsx(ko,{}),l.jsx(Pd,{panelId:"replay-sources-desktop",fillHeight:!0}),l.jsx(yA,{})]}),l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[l.jsx(Co,{fillHeight:!0}),l.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[l.jsx(ho,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),l.jsx(bA,{compact:!0})]})]}),l.jsx(Fg,{}),l.jsx(po,{}),l.jsx(rf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),l.jsx(Wt,{id:"vip",keepMounted:!0,children:l.jsx(tv,{isActive:r==="vip"})}),l.jsx(Wt,{id:"help",children:l.jsx(Pg,{layout:n,onOpenOverlay:a})}),l.jsx(Wt,{id:"settings",children:l.jsx(Kg,{})})]})]})})}const t2=new Set(["admin","lockdown","lockdown-admin"]),n2=new Set(["lockdown","lockdown-admin"]),s2=new Set(["admin","lockdown"]);function a2(n="admin"){return n==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function l2(){const n=de(b=>b.session?.mode||null),a=de(b=>b.session?.role||null),r=de(b=>b.session?.adminReason?.text||"");de(b=>b.session?.adminReason?.updatedAt||null);const o=de(b=>b.session?.timezone||"UTC"),u=de(b=>(b.session?.socials||[]).find(k=>String(k?.id||k?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),f=s2.has(n),h=n==="lockdown"?n2.has(a):t2.has(a),[p,g]=m.useState(()=>new Date),x=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:o,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(p)}catch{return p.toLocaleTimeString()}},[p,o]);if(m.useEffect(()=>{const b=setInterval(()=>g(new Date),1e3);return()=>clearInterval(b)},[]),!f||h)return null;const v=a2(n);return l.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black px-0.5 py-0.5",children:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold",children:v.title}),l.jsx("p",{className:"text-sm text-slate-300",children:v.description})]}),l.jsxs("div",{className:"surface-muted space-y-0.5",children:[l.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),l.jsx("p",{className:"text-lg font-semibold text-slate-100",children:r||"No reason set."}),l.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",x]})]}),l.jsx("div",{className:"surface-muted",children:l.jsx(Yg,{})}),l.jsx("div",{className:"w-full justify-center items-center",children:l.jsx(So,{id:"discord",label:"Join our Discord server for updates!",url:u})}),"You can still use the chat while the server is locked:",l.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[l.jsx(Co,{}),l.jsx(jr,{})]})]})})}const r2="/assets/turn_alert-DVO8EZJa.mp3";function i2(n,a=1){const r=m.useRef(null);return m.useEffect(()=>{r.current=new Audio(n),r.current.volume=a,r.current.load()},[n,a]),()=>{r.current&&(r.current.volume=a,r.current.currentTime=0,r.current.play().catch(()=>{}))}}function o2(){const n=de(v=>v.session?.socketId||null),a=de(v=>v.session?.turnQueues||{}),r=de(v=>v.session?.roster||[]),{pushAlert:o}=Gt(),{value:u}=Qe("audio",it),f=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,h=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,p=Math.max(0,Math.min(1,f*h)),g=i2(r2,p),x=m.useRef(new Set);return m.useEffect(()=>{if(!n)return;const v=[];Object.entries(a).forEach(([b,j])=>{!j||!j.current||j.current!==n||x.current.has(b)||(v.push(b),x.current.add(b))}),Object.keys(a).forEach(b=>{(!a[b]||a[b].current!==n)&&x.current.delete(b)}),v.length!==0&&(v.forEach(b=>{const j=r.find(M=>String(M.id)===String(b))?.name||b;o({title:"Your turn!",message:`You now control ${j}.`,color:"#ff5722"})}),g())},[a,g,o,r,n]),null}function c2({visible:n,mode:a,onEnterFullscreen:r,onDismiss:o}){if(!n)return null;const u=a==="pwa-hint";return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center p-1 pointer-events-none bg-black/20",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-sm surface center",children:l.jsxs("div",{className:"space-y-0.5 p-1 text-sm text-slate-100",children:[l.jsx("h2",{className:"text-base font-semibold text-white border-b border-slate-700",children:"Better in fullscreen!"}),u?l.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",l.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen then makes it fullscreen."]}):l.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),l.jsx("p",{className:"text-xs border-t border-b border-slate-700 p-0.5 text-blue-300 text-center",children:"This will only show once just to let you know. There is a fullscreen button in the bottom right for later use."}),l.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[l.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:u?"Got it":"Not now"}),!u&&l.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:r,children:"Enter fullscreen"})]})]})})})}function u2({side:n="right",onClick:a}){const r=n==="left"?"left-2":"right-2";return l.jsx("button",{type:"button",onClick:a,className:`fixed bottom-2 ${r} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-black text-slate-200 transition hover:bg-zinc-900 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:l.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const nv="fullscreenPromptDismissed",d2=new Set(["mobile-portrait","mobile-landscape"]),sv=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},f2=()=>{const n=sv();if(!n)return!1;try{return n.getItem(nv)==="1"}catch{return!1}},Cx=()=>{const n=sv();if(n)try{n.setItem(nv,"1")}catch{}},m2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},kx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function h2(n){const a=d2.has(n),[r,o]=m.useState(!1),[u,f]=m.useState("native"),[h,p]=m.useState(!1),g=m.useMemo(()=>m2(),[]),x=m.useMemo(()=>kx(),[]),v=m.useCallback(()=>{if(!a){o(!1),p(!1);return}if(!h&&f2()){o(!1);return}if(g){f("pwa-hint"),o(!0);return}if(!kx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[h,g,a]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const k=()=>{if(document.fullscreenElement){p(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",k),document.addEventListener("webkitfullscreenchange",k),()=>{document.removeEventListener("fullscreenchange",k),document.removeEventListener("webkitfullscreenchange",k)}},[v]);const b=m.useCallback(()=>{Cx(),p(!1),o(!1)},[]),j=m.useCallback(async()=>{if(!a||g||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const k=document.documentElement;if(!k)return!1;const N=k.requestFullscreen||k.webkitRequestFullscreen||k.mozRequestFullScreen||k.msRequestFullscreen;if(!N)return!1;try{const w=N.call(k);return w&&typeof w.then=="function"&&await w,Cx(),p(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[g,a]),M=m.useCallback(()=>{a&&(p(!0),f(g?"pwa-hint":"native"),o(!0))},[g,a]);return m.useEffect(()=>{a||(p(!1),o(!1))},[a]),{visible:r,mode:u,isIOS:g,nativeSupported:x,enterFullscreen:j,dismiss:b,showPrompt:M}}function p2({visible:n,layout:a,onClose:r,showOnLoad:o,onToggleShowOnLoad:u}){if(!n)return null;const{state:f}=wt(),h=p=>{const g=!p.target.checked;u?.(g)};return l.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:"Help & controls"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("button",{type:"button",onClick:r,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),l.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:l.jsx(Jg,{layout:a,keymap:f?.keymap||{}})})]})})}function Ya({label:n,keyLabel:a}){return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.35 text-[0.8rem] text-slate-200",children:[l.jsx("span",{children:n}),l.jsx(Bd,{label:a})]})}function x2({keymap:n}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:"2. Use the drive controls to move your rover:"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Ya,{label:"Forward",keyLabel:Rt(n?.driveForward?.[0])}),l.jsx(Ya,{label:"Backward",keyLabel:Rt(n?.driveBackward?.[0])}),l.jsx(Ya,{label:"Turn Left",keyLabel:Rt(n?.driveLeft?.[0])}),l.jsx(Ya,{label:"Turn Right",keyLabel:Rt(n?.driveRight?.[0])}),l.jsx(Ya,{label:"Move faster",keyLabel:Rt(n?.boostModifier?.[0])}),l.jsx(Ya,{label:"Move slower",keyLabel:Rt(n?.slowModifier?.[0])})]})]}),l.jsx("p",{className:"text-sm text-slate-200",children:'3. When done, please dock your rover! Line up with the dock and press "Dock and Charge".'})]})}function g2(){return l.jsxs("div",{className:"space-y-0.5 text-sm text-slate-200",children:[l.jsx("p",{children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsx("p",{children:"2. Touch and hold in Joystick area to move."}),l.jsx("p",{children:"3. Use the other column for motor, horn, and camera controls."}),l.jsx("p",{children:'4. When done, please dock your rover! Line up with the dock and press "Dock and Charge".'})]})}function v2({visible:n,layout:a,showOnLoad:r,onToggleShowOnLoad:o,onOpenHelp:u,onClose:f}){const{state:h}=wt(),p=a==="desktop",g=de(b=>(b.session?.socials||[]).find(k=>String(k?.id||k?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),x=m.useMemo(()=>h?.keymap||{},[h?.keymap]);if(!n)return null;const v=b=>{const j=!b.target.checked;o?.(j)};return l.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center bg-black/75 p-0.5 items-center",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-3xl overflow-hidden shadow-2xl",children:[l.jsx("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.35 text-sm text-slate-200",children:l.jsx("span",{className:"font-semibold text-xl",children:"Welcome! To get started:"})}),l.jsxs("div",{className:`grid gap-0.5 p-0.5 ${p?"md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]":"grid-cols-1"}`,children:[l.jsx("section",{className:"space-y-0.5 border-b border-slate-700",children:p?l.jsx(x2,{keymap:x}):l.jsx(g2,{})}),l.jsxs("section",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-left",children:"Next..."}),l.jsxs("div",{className:"surface space-y-0.5 p-0.5 border-b border-slate-700",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Set your nickname"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"Nicknames are assigned randomly by default, you can change yours here."}),l.jsx(jr,{compact:!0})]}),l.jsxs("div",{className:"surface p-0.5",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Join our Discord server!"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"We have an active and welcoming community :3"}),l.jsx(So,{id:"discord",label:"Join Discord",url:g})]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5 border-t border-slate-700 px-0.5 py-0.35 text-[0.8rem]",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:!r,onChange:v,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("div",{className:"flex items-center gap-0.5",children:l.jsx("button",{type:"button",onClick:f,className:"button-dark px-1 py-0.25 text-2xl bg-green-600 hover:bg-green-400 hover:border-green-100 border-green-400",children:"Got it! Let me in!"})})]})]})})}const b2=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
shrimp
|
||
fling`;function y2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function S2(){const n=String(b2).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function vf(){const{setNickname:n}=Gt(),{value:a,status:r,save:o}=Qe("profile",{nickname:""}),u=m.useRef(!1);m.useEffect(()=>{if(r!=="ready"||u.current||(a.nickname||"").trim())return;u.current=!0;const h=y2(S2()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,r,a.nickname])}function j2(){const n=en(),a=de(w=>w.connected),{identifySession:r}=Gt(),{value:o,status:u,save:f}=Qe("identity",{cookieUserId:""}),{value:h,status:p}=Qe("profile",{nickname:""}),g=m.useRef(!1),x=m.useRef(null),v=m.useRef(null),b=u==="ready"&&p==="ready",j=(o?.cookieUserId||"").trim(),M=(h?.nickname||"").trim(),k=m.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),N=m.useCallback(async()=>{if(!(!b||!a||!n?.id||g.current)){g.current=!0;try{const S=((await r({cookieUserId:j,nickname:M}))?.cookieUserId||"").trim();S&&S!==j&&f(R=>({...R||{},cookieUserId:S})),x.current=n.id,k()}catch{k(),v.current=setTimeout(()=>{N()},2e3)}finally{g.current=!1}}},[k,a,j,r,M,b,f,n?.id]);m.useEffect(()=>{!b||!a||!n?.id||x.current!==n.id&&N()},[a,b,N,n?.id]),m.useEffect(()=>{!b||!a||!n?.id||N()},[b,a,n?.id,j,M,N]),m.useEffect(()=>{const w=()=>{n?.connected&&N()},S=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&N()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",S)}},[N,n?.connected]),m.useEffect(()=>()=>k(),[k])}const pd=1e4,xd=28,N2=14;function xo({layout:n="desktop",className:a="",dismissable:r=!0}){const o=de(S=>{const R=S.session?.globalObjective?.text;return R?String(R).trim():""}),u=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[f,h]=m.useState(!1),[p,g]=m.useState(xd),[x,v]=m.useState(0),b=m.useRef(null),j=m.useRef(null),M=m.useRef(null);m.useEffect(()=>{if(!o){h(!1);return}if(h(!0),!u||!r)return;const S=Date.now();v(pd);const R=setTimeout(()=>h(!1),pd),E=setInterval(()=>{const A=Date.now()-S;v(Math.max(0,pd-A))},250);return()=>{clearTimeout(R),clearInterval(E)}},[o,u]),m.useEffect(()=>{if(!o)return;g(xd);let S=0;const R=()=>{const A=M.current,L=j.current;if(!A||!L)return;const V=A.clientWidth;if(!V)return;const O=L.scrollWidth;if(!O)return;const z=Math.min(1,V/O),X=Math.max(N2,Math.floor(xd*z));g(X)};S=window.requestAnimationFrame(R);const E=new ResizeObserver(()=>{window.cancelAnimationFrame(S),S=window.requestAnimationFrame(R)});return b.current&&E.observe(b.current),()=>{window.cancelAnimationFrame(S),E.disconnect()}},[o]);const k=m.useMemo(()=>["panel-section flex w-full items-center justify-center",u?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",a].filter(Boolean).join(" "),[a,u]);if(!o||!f)return null;const N=u?Math.ceil(x/1e3):null,w=r?{onClick:()=>h(!1),role:"button",tabIndex:0}:{};return l.jsx("div",{ref:b,className:k,style:{fontSize:`${p}px`,lineHeight:1.1},...w,children:l.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[l.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[l.jsx("span",{children:"Global"}),l.jsx("span",{children:"Objective"})]}),l.jsx("span",{ref:M,className:"flex-1 overflow-hidden text-slate-100",children:l.jsx("span",{ref:j,className:"block",children:o})}),u?l.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[N,"s"]}):null]})})}const w2=3200;function A2(n={}){const a=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",r=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):r;return{rewardName:a,goal:r,count:o,ts:Date.now()}}function av(){const n=en(),{value:a}=Qe("audio",it),r=Number.isFinite(a?.masterVolume)?a.masterVolume:it.masterVolume,o=Number.isFinite(a?.alertVolume)?a.alertVolume:it.alertVolume,u=Math.max(0,Math.min(1,r*o)),[f,h]=m.useState(null),p=m.useRef(null);return m.useEffect(()=>{p.current=new Audio("/tada.mp3"),p.current.volume=u,p.current.load()},[u]),m.useEffect(()=>{let g=null;function x(){const j=p.current;j&&(j.volume=u,j.currentTime=0,j.play().catch(()=>{}))}function v(j={}){const M=A2(j);h(M),x(),g&&clearTimeout(g),g=setTimeout(()=>{h(null)},w2)}function b(j){v(j?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",b),()=>{g&&clearTimeout(g),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",b)}},[u,n]),f?l.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:l.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:l.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[l.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",f.rewardName,"!"]}),l.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[f.count,"/",f.goal]})]}),l.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function C2(){const[n,a]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function r(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:u}=window;o>=1024?a("desktop"):o>u?a("mobile-landscape"):a("mobile-portrait")}return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),n}function k2({layout:n,onOpenHelpOverlay:a}){return l.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[l.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[l.jsx(df,{}),l.jsx(uj,{}),l.jsx(of,{})]}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[l.jsx(xo,{layout:n}),l.jsx(e2,{layout:n,onOpenHelpOverlay:a})]})]})}function lv({layout:n,onOpenHelpOverlay:a,roomPanelId:r,showTelemetry:o=!0}){const[u,f]=m.useState("chat"),h=de(S=>!!S.session?.isVerified),p=de(S=>String(S.session?.assignment?.roverId||"").trim()),g=de(S=>{const R=String(S.session?.assignment?.roverId||"").trim();return R&&S.session?.audioForward?.[R]||null}),{state:x}=wt(),{value:v}=Qe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),b=h?"bg-emerald-400":"bg-amber-400",j=!!x?.mic?.pttActive,M=!!v?.openMicEnabled,k=v?.pttMode==="clip"?"clip":"live",N=!!(p&&h&&(k==="clip"?j:M||j)),w=!!(p&&h&&k==="clip"&&g?.source==="upload"&&g?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(pf,{defaultTab:"chat",currentTab:u,onTabChange:f,children:[l.jsxs(xf,{children:[l.jsx(Pt,{id:"chat",children:"Chat"}),l.jsx(Pt,{id:"vip",highlight:w?"green":N?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${b}`,"aria-hidden":"true",title:h?"Verified":"Not verified"})]})}),l.jsx(Pt,{id:"roomcontrols",children:"Room Controls"}),l.jsx(Pt,{id:"help",children:"Help"}),l.jsx(Pt,{id:"settings",children:"Settings"})]}),l.jsxs(gf,{children:[l.jsx(Wt,{id:"chat",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Co,{}),l.jsx(ho,{})]})}),l.jsx(Wt,{id:"vip",keepMounted:!0,children:l.jsx(tv,{isActive:u==="vip"})}),l.jsx(Wt,{id:"roomcontrols",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Fg,{}),l.jsx(po,{}),l.jsx(rf,{panelId:r})]})}),l.jsx(Wt,{id:"help",children:l.jsx(Pg,{layout:n,onOpenOverlay:a})}),l.jsx(Wt,{id:"settings",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Kg,{}),l.jsx(of,{})]})})]})]})})}function E2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx(df,{layoutFormat:"mobile-portrait"}),l.jsx(BN,{swapColumns:a}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(Pd,{panelId:"replay-sources-mobile-portrait"}),l.jsx(ko,{})]}),l.jsx(lv,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function M2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){const r="self-start h-[min(100svh,32rem)]",o=a?l.jsx(fo,{layout:"landscape",className:r}):l.jsx(uo,{layout:"landscape",className:r}),u=a?l.jsx(uo,{layout:"landscape",className:r}):l.jsx(fo,{layout:"landscape",className:r});return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,l.jsxs("div",{children:[l.jsx(df,{layoutFormat:"mobile-landscape"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(Pd,{panelId:"replay-sources-mobile-landscape"}),l.jsx(ko,{})]})]}),u]}),l.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:l.jsx(lv,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function R2(){const n=C2(),a=n==="desktop",r=h2(n);return l.jsx("div",{className:`bg-black text-slate-100 ${a?"h-screen overflow-hidden":"min-h-screen"}`,children:l.jsx(T2,{layout:n,isDesktop:a,fullscreen:r})})}function T2({layout:n,isDesktop:a,fullscreen:r}){vf(),j2();const{visible:o,mode:u,isIOS:f,nativeSupported:h,enterFullscreen:p,dismiss:g,showPrompt:x}=r,{value:v,save:b}=Qe("help",{showOnLoad:!0}),{value:j,status:M,save:k}=Qe("quickstart",{showOnLoad:!0}),{value:N}=Qe("page",{swapMobileControlColumns:!1}),w=!!N?.swapMobileControlColumns,S=w?"left":"right",R=!a&&(f||h),[E,A]=m.useState(!1),[L,V]=m.useState(!1);m.useEffect(()=>{M==="ready"&&V(j?.showOnLoad!==!1)},[M,j?.showOnLoad]);const O=m.useCallback(()=>A(!0),[]),z=m.useCallback(()=>A(!1),[]),X=m.useCallback(()=>V(!1),[]),G=m.useCallback(async()=>{if(f){x();return}await p()||x()},[p,f,x]),Q=m.useCallback(ie=>{const $=!!ie;k(q=>({...q??{},showOnLoad:$})),$||V(!1)},[k]),P=m.useCallback(()=>{V(!1),A(!0)},[]),oe=m.useMemo(()=>a?l.jsx(k2,{layout:n,onOpenHelpOverlay:O}):n==="mobile-landscape"?l.jsx(M2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}):l.jsx(E2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}),[a,n,O,w]);return l.jsxs(sN,{children:[l.jsx(hN,{}),l.jsx(CN,{}),l.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${a?"h-full overflow-hidden":""}`,children:[a?null:l.jsx(xo,{layout:n}),oe]}),l.jsx(tf,{}),l.jsx(av,{}),l.jsx(o2,{}),l.jsx(l2,{}),l.jsx(p2,{visible:E,layout:n,onClose:z,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:ie=>b($=>({...$??{},showOnLoad:!!ie}))}),l.jsx(c2,{visible:o,mode:u,onEnterFullscreen:p,onDismiss:g}),l.jsx(v2,{visible:L,layout:n,showOnLoad:j?.showOnLoad!==!1,onToggleShowOnLoad:Q,onOpenHelp:P,onClose:X}),R?l.jsx(u2,{side:S,onClick:G}):null]})}function rv(){const{session:n,setRole:a,subscribeAll:r,connected:o}=br(),[u,f]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(n?.mode==="lockdown"){f(!1);return}try{n?.role!=="spectator"&&await a("spectator"),await r(),h||f(!0)}catch(g){console.error("Failed to enter spectator mode",g),h||f(!1)}}return p(),()=>{h=!0}},[o,n?.mode,n?.role,a,r]),u}function q2(){const[n,a]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia("(max-aspect-ratio: 4/3)"),o=u=>a(u.matches);return r.addEventListener?r.addEventListener("change",o):r.addListener(o),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o)}},[]),n}function D2({show:n=!1,roverId:a=null,sensors:r,batteryConfig:o,mobileHud:u=!1}){const f=pn(a),h=de(v=>a?(v.session?.roster||[]).find(M=>String(M.id)===String(a))?.battery??null:null),p=r??f?.sensors??null,g=o??h,x=No({charge:p?.batteryChargeMah??null,config:g});return!n||!x?.available?null:l.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:l.jsx(uf,{visual:x,orientation:"vertical",variant:"inline",compact:u,className:"h-full w-4"})})}const _2=Ot.memo(D2);function O2({roverId:n=null,label:a,fitParent:r=!1,layoutFormat:o="desktop"}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${r?"h-full":""}`,children:l.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${r?"h-full flex-1":"aspect-[4/3]"}`,children:[l.jsx(dr,{roverId:n,label:a}),l.jsx(Vg,{roverId:n,variant:"spectator",mobileHud:!1}),l.jsx(Hg,{roverId:n,layoutFormat:o,variant:"spectator",mobileHud:!1,labelScale:1}),l.jsx($g,{roverId:n,compact:!1}),l.jsx(Gg,{roverId:n,compact:!1}),l.jsx(_2,{show:!0,roverId:n,mobileHud:!1})]})})}function B2({rover:n}){return l.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:l.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:l.jsx(O2,{roverId:n.id,label:n.name})})})}function L2({roster:n}){return n.length===0?l.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):l.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(a=>l.jsx(B2,{rover:a},a.id))})}function z2(){return l.jsx("section",{className:"min-h-0",children:l.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:l.jsx(rf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function U2({className:n=""}){return l.jsx("div",{className:`panel ${n}`,children:l.jsx(of,{})})}function H2(){const{session:n}=br(),a=n?.mode==="lockdown";vf(),rv();const r=q2(),o=n?.roster??[];if(a)return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),l.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const u=r?"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]",f=r?"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",h=r?"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",p="",g=r?"h-64":"";return l.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[l.jsxs("main",{className:u,children:[l.jsxs("section",{className:h,children:[r?l.jsxs("div",{className:`${p} ${g} flex flex-col gap-0.5`,children:[l.jsx(xo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(po,{}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(ho,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):l.jsxs("div",{className:p,children:[l.jsx(xo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(po,{})]}),l.jsx("div",{className:`${p} ${r?`${g} overflow-y-auto`:""}`,children:l.jsx("div",{className:"panel h-full",children:l.jsx(ko,{title:"Rovers"})})}),r?null:l.jsx("div",{className:`${p} flex-1 min-h-0`,children:l.jsx(ho,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),l.jsx("div",{className:`${p} ${r?g:"flex-[1.1] min-h-0"}`,children:l.jsx(Co,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),l.jsx("div",{className:`${p} ${r?g:""}`,children:l.jsx(U2,{className:`${r?"h-full":"h-40"} overflow-hidden`})})]}),l.jsxs("section",{className:f,children:[l.jsx(L2,{roster:o}),l.jsx(z2,{})]})]}),l.jsx(tf,{}),l.jsx(av,{})]})}function V2(){return l.jsx(H2,{})}function $2({children:n}){return l.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:l.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:l.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}function G2({roverId:n,session:a}){const r=a?.activeDrivers?.[n]||null,u=(a?.users||[]).find(p=>p.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=a?.mode,h=a?.turnQueues?.[n];return f==="turns"&&h?.current?`${u}`:u}function F2({rover:n,frame:a}){const r=a?.sensors?.batteryChargeMah??null,o=n?.battery??null;return No({batteryState:n?.batteryState??null,charge:r,config:o})}function Xa({children:n,className:a="",maxSize:r=1e3,minSize:o=14,style:u=void 0}){const f=m.useRef(null),h=m.useRef(null),[p,g]=m.useState(r);return m.useLayoutEffect(()=>{const x=f.current,v=h.current;if(!x||!v)return;let b=null;const j=()=>{const N=x.clientWidth;if(!N){M();return}let w=o,S=r,R=o;for(;w<=S;){const E=Math.floor((w+S)/2);v.style.fontSize=`${E}px`,v.scrollWidth<=N?(R=E,w=E+1):S=E-1}g(R)},M=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(j)};M();const k=new ResizeObserver(M);return k.observe(x),()=>{b&&cancelAnimationFrame(b),k.disconnect()}},[n,r,o]),l.jsx("div",{ref:f,className:"w-full min-w-0",children:l.jsx("div",{ref:h,className:`whitespace-nowrap ${a}`,style:{fontSize:`${p}px`,lineHeight:1.1,...u||{}},children:n})})}function Ex({rover:n,frame:a,driverLabel:r,sessionInfo:o,videoMode:u="snapshot",snapshotFeed:f,withDivider:h=!1,showPreview:p=!0,variant:g="stacked"}){const x=F2({rover:n,frame:a}),v=x?.available?x.percentDisplay:null,b=g==="active";return l.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[l.jsx(uf,{visual:x,orientation:b?"vertical":"horizontal",variant:"background"}),b?l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ts(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):l.jsx("div",{}),l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ts(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):null,l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),l.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:l.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?l.jsx("div",{className:"mt-auto w-full",children:l.jsx("div",{className:"w-full aspect-[4/3]",children:l.jsx(dr,{sessionInfo:o,videoMode:u,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,sensors:a?.sensors||null})})}):null})})]})]})}const Y2=2e4,X2=3600*1e3;function Q2(){const{session:n}=br(),a=rv();vf();const r=n?.mode==="lockdown",o=!!n?.isLocalNetwork,u=rj(),f=n?.roster??[],[h,p]=m.useState(0),g=n?.activeDrivers||{},x=m.useMemo(()=>f.filter(G=>g[G.id]),[f,g]),v=x.length?x:f,b=Lg(v.map(G=>G.id),{enabled:!r&&!o,version:n?.mode}),j=m.useMemo(()=>o?v.map(G=>({type:"rover",id:G.id,key:G.id})):[],[o,v]),M=_d(j,{enabled:!r&&o,version:n?.mode}),k=m.useMemo(()=>x.flatMap(G=>{if(!G?.id||!G.media?.audioPublishUrl)return[];const Q=String(G.id);return[{type:"rover",id:`${Q}-audio`,key:`${Q}-audio`}]}),[x]),N=_d(k,{enabled:!r,version:n?.mode}),w=m.useMemo(()=>{if(!x.length)return[];if(!o){const Q=x.filter(P=>b[P.id]?.objectUrl);return Q.length?Q:x}const G=x.filter(Q=>{const P=M[Q.id];return P?.url&&!P?.error});return G.length?G:x},[x,b,M,o]),S=m.useMemo(()=>w.map(G=>({type:"rover",rover:G})),[w]),R=m.useMemo(()=>S.map(G=>`r:${G.rover.id}`).join("|"),[S]);m.useEffect(()=>{p(0)},[R]),m.useEffect(()=>{if(!S.length)return;const G=setInterval(()=>{p(Q=>(Q+1)%S.length)},Y2);return()=>clearInterval(G)},[S.length,R]);const E=S.length?S[h%S.length]:null,A=E?.type==="rover"?E.rover:null,L=!o&&A&&b[A.id]||null,V=o&&A&&M[A.id]||null,O=A&&N[`${A.id}-audio`]||null,z=A&&u[A.id]||null,X=A?G2({roverId:A.id,session:n}):null;return r?l.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),l.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):x.length?l.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[l.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:a?A?l.jsx($2,{children:o?l.jsx("div",{className:"relative h-full w-full",children:S.map(G=>{const Q=G.rover,P=A?.id===Q.id;return l.jsx("div",{className:`absolute inset-0 ${P?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsx(dr,{sessionInfo:M[Q.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:P?O:null,forceMute:!P,label:Q.name||Q.id,sensors:u[Q.id]?.sensors||null})},Q.id)})}):l.jsx(dr,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:L,audioSessionInfo:O,label:A.name||A.id,sensors:z?.sensors||null})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:x.length?"No sources available.":"No active drivers."}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),l.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:A?l.jsx(Ex,{rover:A,frame:z,driverLabel:X,sessionInfo:o?V:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[A.id]||null,showPreview:!1,variant:"active"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):l.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:l.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:f.length?f.map(G=>l.jsx(Ex,{rover:G,frame:u[G.id]||null,driverLabel:null,sessionInfo:o&&M[G.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[G.id]||null,showPreview:!0,withDivider:!1},G.id)):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function I2(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const a=new URL(window.location.href);a.searchParams.set("refresh",Date.now().toString()),window.location.replace(a.toString())},X2);return()=>clearTimeout(n)},[]),l.jsxs(l.Fragment,{children:[l.jsx(Q2,{}),l.jsx(tf,{scale:3})]})}function Ii(n){if(!n||!n.length)return null;const a=Math.floor(Math.random()*n.length);return n[a]||null}function K2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const a=Ii(n),r=Ii(n),o=a?.classList?.[0]||null;if(o&&r?.classList)try{r.classList.add(o)}catch{}const u=Ii(n),f=Ii(n),h=u?.classList?.[1]||null;if(h&&f?.classList)try{f.classList.add(h)}catch{}}function Z2(){const n=de(a=>!!a.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const a=window.setInterval(()=>{K2()},1);return()=>{window.clearInterval(a)}},[n]),null}Ry.createRoot(document.getElementById("root")).render(l.jsx(m.StrictMode,{children:l.jsx(WS,{children:l.jsx(sj,{children:l.jsx(lj,{children:l.jsx(pj,{children:l.jsxs(lN,{children:[l.jsx(Z2,{}),l.jsx(Y1,{children:l.jsxs(j1,{children:[l.jsx(Ki,{path:"/",element:l.jsx(R2,{})}),l.jsx(Ki,{path:"/spectate",element:l.jsx(V2,{})}),l.jsx(Ki,{path:"/mini",element:l.jsx(I2,{})})]})})]})})})})})}));
|