mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
132 lines
579 KiB
JavaScript
132 lines
579 KiB
JavaScript
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.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 gy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Pu={exports:{}},cr={};var vp;function by(){if(vp)return cr;vp=1;var n=Symbol.for("react.transitional.element"),s=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 cr.Fragment=s,cr.jsx=r,cr.jsxs=r,cr}var yp;function vy(){return yp||(yp=1,Pu.exports=by()),Pu.exports}var l=vy(),Wu={exports:{}},ke={};var Sp;function yy(){if(Sp)return ke;Sp=1;var n=Symbol.for("react.transitional.element"),s=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"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),N=Symbol.iterator;function M(R){return R===null||typeof R!="object"?null:(R=N&&R[N]||R["@@iterator"],typeof R=="function"?R:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,w={};function j(R,_,Z){this.props=R,this.context=_,this.refs=w,this.updater=Z||k}j.prototype.isReactComponent={},j.prototype.setState=function(R,_){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,_,"setState")},j.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function T(){}T.prototype=j.prototype;function E(R,_,Z){this.props=R,this.context=_,this.refs=w,this.updater=Z||k}var C=E.prototype=new T;C.constructor=E,S(C,j.prototype),C.isPureReactComponent=!0;var L=Array.isArray;function G(){}var O={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function K(R,_,Z){var ee=Z.ref;return{$$typeof:n,type:R,key:_,ref:ee!==void 0?ee:null,props:Z}}function $(R,_){return K(R.type,_,R.props)}function X(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function P(R){var _={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(Z){return _[Z]})}var ce=/\/+/g;function ie(R,_){return typeof R=="object"&&R!==null&&R.key!=null?P(""+R.key):_.toString(36)}function V(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(G,G):(R.status="pending",R.then(function(_){R.status==="pending"&&(R.status="fulfilled",R.value=_)},function(_){R.status==="pending"&&(R.status="rejected",R.reason=_)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function q(R,_,Z,ee,fe){var oe=typeof R;(oe==="undefined"||oe==="boolean")&&(R=null);var ue=!1;if(R===null)ue=!0;else switch(oe){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(R.$$typeof){case n:case s:ue=!0;break;case b:return ue=R._init,q(ue(R._payload),_,Z,ee,fe)}}if(ue)return fe=fe(R),ue=ee===""?"."+ie(R,0):ee,L(fe)?(Z="",ue!=null&&(Z=ue.replace(ce,"$&/")+"/"),q(fe,_,Z,"",function(ye){return ye})):fe!=null&&(X(fe)&&(fe=$(fe,Z+(fe.key==null||R&&R.key===fe.key?"":(""+fe.key).replace(ce,"$&/")+"/")+ue)),_.push(fe)),1;ue=0;var ge=ee===""?".":ee+":";if(L(R))for(var ve=0;ve<R.length;ve++)ee=R[ve],oe=ge+ie(ee,ve),ue+=q(ee,_,Z,oe,fe);else if(ve=M(R),typeof ve=="function")for(R=ve.call(R),ve=0;!(ee=R.next()).done;)ee=ee.value,oe=ge+ie(ee,ve++),ue+=q(ee,_,Z,oe,fe);else if(oe==="object"){if(typeof R.then=="function")return q(V(R),_,Z,ee,fe);throw _=String(R),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.")}return ue}function H(R,_,Z){if(R==null)return R;var ee=[],fe=0;return q(R,ee,"","",function(oe){return _.call(Z,oe,fe++)}),ee}function J(R){if(R._status===-1){var _=R._result;_=_(),_.then(function(Z){(R._status===0||R._status===-1)&&(R._status=1,R._result=Z)},function(Z){(R._status===0||R._status===-1)&&(R._status=2,R._result=Z)}),R._status===-1&&(R._status=0,R._result=_)}if(R._status===1)return R._result.default;throw R._result}var te=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var _=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(_))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},de={map:H,forEach:function(R,_,Z){H(R,function(){_.apply(this,arguments)},Z)},count:function(R){var _=0;return H(R,function(){_++}),_},toArray:function(R){return H(R,function(_){return _})||[]},only:function(R){if(!X(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return ke.Activity=v,ke.Children=de,ke.Component=j,ke.Fragment=r,ke.Profiler=u,ke.PureComponent=E,ke.StrictMode=o,ke.Suspense=x,ke.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,ke.__COMPILER_RUNTIME={__proto__:null,c:function(R){return O.H.useMemoCache(R)}},ke.cache=function(R){return function(){return R.apply(null,arguments)}},ke.cacheSignal=function(){return null},ke.cloneElement=function(R,_,Z){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var ee=S({},R.props),fe=R.key;if(_!=null)for(oe in _.key!==void 0&&(fe=""+_.key),_)!z.call(_,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&_.ref===void 0||(ee[oe]=_[oe]);var oe=arguments.length-2;if(oe===1)ee.children=Z;else if(1<oe){for(var ue=Array(oe),ge=0;ge<oe;ge++)ue[ge]=arguments[ge+2];ee.children=ue}return K(R.type,fe,ee)},ke.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:f,_context:R},R},ke.createElement=function(R,_,Z){var ee,fe={},oe=null;if(_!=null)for(ee in _.key!==void 0&&(oe=""+_.key),_)z.call(_,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(fe[ee]=_[ee]);var ue=arguments.length-2;if(ue===1)fe.children=Z;else if(1<ue){for(var ge=Array(ue),ve=0;ve<ue;ve++)ge[ve]=arguments[ve+2];fe.children=ge}if(R&&R.defaultProps)for(ee in ue=R.defaultProps,ue)fe[ee]===void 0&&(fe[ee]=ue[ee]);return K(R,oe,fe)},ke.createRef=function(){return{current:null}},ke.forwardRef=function(R){return{$$typeof:p,render:R}},ke.isValidElement=X,ke.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:J}},ke.memo=function(R,_){return{$$typeof:g,type:R,compare:_===void 0?null:_}},ke.startTransition=function(R){var _=O.T,Z={};O.T=Z;try{var ee=R(),fe=O.S;fe!==null&&fe(Z,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(G,te)}catch(oe){te(oe)}finally{_!==null&&Z.types!==null&&(_.types=Z.types),O.T=_}},ke.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},ke.use=function(R){return O.H.use(R)},ke.useActionState=function(R,_,Z){return O.H.useActionState(R,_,Z)},ke.useCallback=function(R,_){return O.H.useCallback(R,_)},ke.useContext=function(R){return O.H.useContext(R)},ke.useDebugValue=function(){},ke.useDeferredValue=function(R,_){return O.H.useDeferredValue(R,_)},ke.useEffect=function(R,_){return O.H.useEffect(R,_)},ke.useEffectEvent=function(R){return O.H.useEffectEvent(R)},ke.useId=function(){return O.H.useId()},ke.useImperativeHandle=function(R,_,Z){return O.H.useImperativeHandle(R,_,Z)},ke.useInsertionEffect=function(R,_){return O.H.useInsertionEffect(R,_)},ke.useLayoutEffect=function(R,_){return O.H.useLayoutEffect(R,_)},ke.useMemo=function(R,_){return O.H.useMemo(R,_)},ke.useOptimistic=function(R,_){return O.H.useOptimistic(R,_)},ke.useReducer=function(R,_,Z){return O.H.useReducer(R,_,Z)},ke.useRef=function(R){return O.H.useRef(R)},ke.useState=function(R){return O.H.useState(R)},ke.useSyncExternalStore=function(R,_,Z){return O.H.useSyncExternalStore(R,_,Z)},ke.useTransition=function(){return O.H.useTransition()},ke.version="19.2.0",ke}var jp;function Kd(){return jp||(jp=1,Wu.exports=yy()),Wu.exports}var m=Kd();const an=gy(m);var ed={exports:{}},ur={},td={exports:{}},nd={};var Np;function Sy(){return Np||(Np=1,(function(n){function s(q,H){var J=q.length;q.push(H);e:for(;0<J;){var te=J-1>>>1,de=q[te];if(0<u(de,H))q[te]=H,q[J]=de,J=te;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 te=0,de=q.length,R=de>>>1;te<R;){var _=2*(te+1)-1,Z=q[_],ee=_+1,fe=q[ee];if(0>u(Z,J))ee<de&&0>u(fe,Z)?(q[te]=fe,q[ee]=J,te=ee):(q[te]=Z,q[_]=J,te=_);else if(ee<de&&0>u(fe,J))q[te]=fe,q[ee]=J,te=ee;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 x=[],g=[],b=1,v=null,N=3,M=!1,k=!1,S=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function C(q){for(var H=r(g);H!==null;){if(H.callback===null)o(g);else if(H.startTime<=q)o(g),H.sortIndex=H.expirationTime,s(x,H);else break;H=r(g)}}function L(q){if(S=!1,C(q),!k)if(r(x)!==null)k=!0,G||(G=!0,P());else{var H=r(g);H!==null&&V(L,H.startTime-q)}}var G=!1,O=-1,z=5,K=-1;function $(){return w?!0:!(n.unstable_now()-K<z)}function X(){if(w=!1,G){var q=n.unstable_now();K=q;var H=!0;try{e:{k=!1,S&&(S=!1,T(O),O=-1),M=!0;var J=N;try{t:{for(C(q),v=r(x);v!==null&&!(v.expirationTime>q&&$());){var te=v.callback;if(typeof te=="function"){v.callback=null,N=v.priorityLevel;var de=te(v.expirationTime<=q);if(q=n.unstable_now(),typeof de=="function"){v.callback=de,C(q),H=!0;break t}v===r(x)&&o(x),C(q)}else o(x);v=r(x)}if(v!==null)H=!0;else{var R=r(g);R!==null&&V(L,R.startTime-q),H=!1}}break e}finally{v=null,N=J,M=!1}H=void 0}}finally{H?P():G=!1}}}var P;if(typeof E=="function")P=function(){E(X)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,ie=ce.port2;ce.port1.onmessage=X,P=function(){ie.postMessage(null)}}else P=function(){j(X,0)};function V(q,H){O=j(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 N},n.unstable_next=function(q){switch(N){case 1:case 2:case 3:var H=3;break;default:H=N}var J=N;N=H;try{return q()}finally{N=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=N;N=q;try{return H()}finally{N=J}},n.unstable_scheduleCallback=function(q,H,J){var te=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?te+J:te):J=te,q){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=J+de,q={id:b++,callback:H,priorityLevel:q,startTime:J,expirationTime:de,sortIndex:-1},J>te?(q.sortIndex=J,s(g,q),r(x)===null&&q===r(g)&&(S?(T(O),O=-1):S=!0,V(L,J-te))):(q.sortIndex=de,s(x,q),k||M||(k=!0,G||(G=!0,P()))),q},n.unstable_shouldYield=$,n.unstable_wrapCallback=function(q){var H=N;return function(){var J=N;N=H;try{return q.apply(this,arguments)}finally{N=J}}}})(nd)),nd}var wp;function jy(){return wp||(wp=1,td.exports=Sy()),td.exports}var ad={exports:{}},Ot={};var Ap;function Ny(){if(Ap)return Ot;Ap=1;var n=Kd();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)g+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+x+"; visit "+g+" 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(s(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(x,g,b){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:v==null?null:""+v,children:x,containerInfo:g,implementation:b}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Ot.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Ot.createPortal=function(x,g){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return f(x,g,null,b)},Ot.flushSync=function(x){var g=h.T,b=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=b,o.d.f()}},Ot.preconnect=function(x,g){typeof x=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,o.d.C(x,g))},Ot.prefetchDNS=function(x){typeof x=="string"&&o.d.D(x)},Ot.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var b=g.as,v=p(b,g.crossOrigin),N=typeof g.integrity=="string"?g.integrity:void 0,M=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;b==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:v,integrity:N,fetchPriority:M}):b==="script"&&o.d.X(x,{crossOrigin:v,integrity:N,fetchPriority:M,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},Ot.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var b=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Ot.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var b=g.as,v=p(b,g.crossOrigin);o.d.L(x,b,{crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Ot.preloadModule=function(x,g){if(typeof x=="string")if(g){var b=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Ot.requestFormReset=function(x){o.d.r(x)},Ot.unstable_batchedUpdates=function(x,g){return x(g)},Ot.useFormState=function(x,g,b){return h.H.useFormState(x,g,b)},Ot.useFormStatus=function(){return h.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var Cp;function wy(){if(Cp)return ad.exports;Cp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),ad.exports=Ny(),ad.exports}var kp;function Ay(){if(kp)return ur;kp=1;var n=jy(),s=Kd(),r=wy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(f(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,i=t;;){var c=a.return;if(c===null)break;var d=c.alternate;if(d===null){if(i=c.return,i!==null){a=i;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===a)return x(c),e;if(d===i)return x(c),t;d=d.sibling}throw Error(o(188))}if(a.return!==i.return)a=c,i=d;else{for(var y=!1,A=c.child;A;){if(A===a){y=!0,a=c,i=d;break}if(A===i){y=!0,i=c,a=d;break}A=A.sibling}if(!y){for(A=d.child;A;){if(A===a){y=!0,a=d,i=c;break}if(A===i){y=!0,i=d,a=c;break}A=A.sibling}if(!y)throw Error(o(189))}}if(a.alternate!==i)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function b(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=b(e),t!==null)return t;e=e.sibling}return null}var v=Object.assign,N=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),E=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function P(e){return e===null||typeof e!="object"?null:(e=X&&e[X]||e["@@iterator"],typeof e=="function"?e:null)}var ce=Symbol.for("react.client.reference");function ie(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case j:return"Profiler";case w:return"StrictMode";case L:return"Suspense";case G:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case E:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case C: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 V=Array.isArray,q=s.__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},te=[],de=-1;function R(e){return{current:e}}function _(e){0>de||(e.current=te[de],te[de]=null,de--)}function Z(e,t){de++,te[de]=e.current,e.current=t}var ee=R(null),fe=R(null),oe=R(null),ue=R(null);function ge(e,t){switch(Z(oe,t),Z(fe,e),Z(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?$0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=$0(t),e=G0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_(ee),Z(ee,e)}function ve(){_(ee),_(fe),_(oe)}function ye(e){e.memoizedState!==null&&Z(ue,e);var t=ee.current,a=G0(t,e.type);t!==a&&(Z(fe,e),Z(ee,a))}function Ye(e){fe.current===e&&(_(ee),_(fe)),ue.current===e&&(_(ue),lr._currentValue=J)}var Ke,Me;function De(e){if(Ke===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Ke=t&&t[1]||"",Me=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+Ke+e+Me}var _e=!1;function Ct(e,t){if(!e||_e)return"";_e=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(I){var Q=I}Reflect.construct(e,[],ae)}else{try{ae.call()}catch(I){Q=I}e.call(ae.prototype)}}else{try{throw Error()}catch(I){Q=I}(ae=e())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(I){if(I&&Q&&typeof I.stack=="string")return[I.stack,Q.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],A=d[1];if(y&&A){var D=y.split(`
|
||
`),Y=A.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{_e=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?De(a):""}function re(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De("Lazy");case 13:return e.child!==t&&t!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Ct(e.type,!1);case 11:return Ct(e.type.render,!1);case 1:return Ct(e.type,!0);case 31:return De("Activity");default:return""}}function se(e){try{var t="",a=null;do t+=re(e,a),a=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var je=Object.prototype.hasOwnProperty,me=n.unstable_scheduleCallback,Ae=n.unstable_cancelCallback,Ce=n.unstable_shouldYield,Pe=n.unstable_requestPaint,le=n.unstable_now,he=n.unstable_getCurrentPriorityLevel,Oe=n.unstable_ImmediatePriority,Lt=n.unstable_UserBlockingPriority,nt=n.unstable_NormalPriority,fl=n.unstable_LowPriority,ln=n.unstable_IdlePriority,ml=n.log,fs=n.unstable_setDisableYieldValue,Sn=null,jt=null;function kt(e){if(typeof ml=="function"&&fs(e),jt&&typeof jt.setStrictMode=="function")try{jt.setStrictMode(Sn,e)}catch{}}var Dt=Math.clz32?Math.clz32:hl,Hr=Math.log,Vr=Math.LN2;function hl(e){return e>>>=0,e===0?32:31-(Hr(e)/Vr|0)|0}var Ua=256,Hn=262144,zt=4194304;function Ut(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 ms(e,t,a){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var A=i&134217727;return A!==0?(i=A&~d,i!==0?c=Ut(i):(y&=A,y!==0?c=Ut(y):a||(a=A&~e,a!==0&&(c=Ut(a))))):(A=i&~d,A!==0?c=Ut(A):y!==0?c=Ut(y):a||(a=i&~e,a!==0&&(c=Ut(a)))),c===0?0:t!==0&&t!==c&&(t&d)===0&&(d=c&-c,a=t&-t,d>=a||d===32&&(a&4194048)!==0)?t:c}function Mn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Fo(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 pl(){var e=zt;return zt<<=1,(zt&62914560)===0&&(zt=4194304),e}function st(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function jn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function xl(e,t,a,i,c,d){var y=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var A=e.entanglements,D=e.expirationTimes,Y=e.hiddenUpdates;for(a=y&~a;0<a;){var W=31-Dt(a),ae=1<<W;A[W]=0,D[W]=-1;var Q=Y[W];if(Q!==null)for(Y[W]=null,W=0;W<Q.length;W++){var I=Q[W];I!==null&&(I.lane&=-536870913)}a&=~ae}i!==0&&Ha(e,i,0),d!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=d&~(y&~t))}function Ha(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-Dt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|a&261930}function gl(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var i=31-Dt(a),c=1<<i;c&t|e[i]&t&&(e[i]|=t),a&=~c}}function $r(e,t){var a=t&-t;return a=(a&42)!==0?1:bl(a),(a&(e.suspendedLanes|t))!==0?0:a}function bl(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 vl(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function yl(){var e=H.p;return e!==0?e:(e=window.event,e===void 0?32:fp(e.type))}function Ht(e,t){var a=H.p;try{return H.p=e,t()}finally{H.p=a}}var Rn=Math.random().toString(36).slice(2),pe="__reactFiber$"+Rn,Re="__reactProps$"+Rn,Xe="__reactContainer$"+Rn,Te="__reactEvents$"+Rn,Ie="__reactListeners$"+Rn,_t="__reactHandles$"+Rn,ma="__reactResources$"+Rn,Tn="__reactMarker$"+Rn;function mt(e){delete e[pe],delete e[Re],delete e[Te],delete e[Ie],delete e[_t]}function rn(e){var t=e[pe];if(t)return t;for(var a=e.parentNode;a;){if(t=a[Xe]||a[pe]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Z0(e);e!==null;){if(a=e[pe])return a;e=Z0(e)}return t}e=a,a=e.parentNode}return null}function hs(e){if(e=e[pe]||e[Xe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Sl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ps(e){var t=e[ma];return t||(t=e[ma]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Nt(e){e[Tn]=!0}var Rf=new Set,Tf={};function Va(e,t){xs(e,t),xs(e+"Capture",t)}function xs(e,t){for(Tf[e]=t,e=0;e<t.length;e++)Rf.add(t[e])}var ob=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]*$"),qf={},Df={};function cb(e){return je.call(Df,e)?!0:je.call(qf,e)?!1:ob.test(e)?Df[e]=!0:(qf[e]=!0,!1)}function Gr(e,t,a){if(cb(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function Fr(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Vn(e,t,a,i){if(i===null)e.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+i)}}function on(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _f(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ub(e,t,a){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,d=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(y){a=""+y,d.call(this,y)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Yo(e){if(!e._valueTracker){var t=_f(e)?"checked":"value";e._valueTracker=ub(e,t,""+e[t])}}function Of(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),i="";return e&&(i=_f(e)?e.checked?"true":"false":e.value),e=i,e!==a?(t.setValue(e),!0):!1}function Yr(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 db=/[\n"\\]/g;function cn(e){return e.replace(db,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Xo(e,t,a,i,c,d,y,A){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=""+on(t)):e.value!==""+on(t)&&(e.value=""+on(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?Qo(e,y,on(t)):a!=null?Qo(e,y,on(a)):i!=null&&e.removeAttribute("value"),c==null&&d!=null&&(e.defaultChecked=!!d),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+on(A):e.removeAttribute("name")}function Bf(e,t,a,i,c,d,y,A){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.type=d),t!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){Yo(e);return}a=a!=null?""+on(a):"",t=t!=null?""+on(t):a,A||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=A?e.checked:!!i,e.defaultChecked=!!i,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),Yo(e)}function Qo(e,t,a){t==="number"&&Yr(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function gs(e,t,a,i){if(e=e.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<e.length;a++)c=t.hasOwnProperty("$"+e[a].value),e[a].selected!==c&&(e[a].selected=c),c&&i&&(e[a].defaultSelected=!0)}else{for(a=""+on(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Lf(e,t,a){if(t!=null&&(t=""+on(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+on(a):""}function zf(e,t,a,i){if(t==null){if(i!=null){if(a!=null)throw Error(o(92));if(V(i)){if(1<i.length)throw Error(o(93));i=i[0]}a=i}a==null&&(a=""),t=a}a=on(t),e.defaultValue=a,i=e.textContent,i===a&&i!==""&&i!==null&&(e.value=i),Yo(e)}function bs(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var fb=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 Uf(e,t,a){var i=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,a):typeof a!="number"||a===0||fb.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Hf(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var i in a)!a.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&a[c]!==i&&Uf(e,c,i)}else for(var d in t)t.hasOwnProperty(d)&&Uf(e,d,t[d])}function Ko(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 mb=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"]]),hb=/^[\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 Xr(e){return hb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function $n(){}var Io=null;function Zo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var vs=null,ys=null;function Vf(e){var t=hs(e);if(t&&(e=t.stateNode)){var a=e[Re]||null;e:switch(e=t.stateNode,t.type){case"input":if(Xo(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+cn(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var i=a[t];if(i!==e&&i.form===e.form){var c=i[Re]||null;if(!c)throw Error(o(90));Xo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)i=a[t],i.form===e.form&&Of(i)}break e;case"textarea":Lf(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&gs(e,!!a.multiple,t,!1)}}}var Jo=!1;function $f(e,t,a){if(Jo)return e(t,a);Jo=!0;try{var i=e(t);return i}finally{if(Jo=!1,(vs!==null||ys!==null)&&(Di(),vs&&(t=vs,e=ys,ys=vs=null,Vf(t),e)))for(t=0;t<e.length;t++)Vf(e[t])}}function jl(e,t){var a=e.stateNode;if(a===null)return null;var i=a[Re]||null;if(i===null)return null;a=i[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Gn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Po=!1;if(Gn)try{var Nl={};Object.defineProperty(Nl,"passive",{get:function(){Po=!0}}),window.addEventListener("test",Nl,Nl),window.removeEventListener("test",Nl,Nl)}catch{Po=!1}var ha=null,Wo=null,Qr=null;function Gf(){if(Qr)return Qr;var e,t=Wo,a=t.length,i,c="value"in ha?ha.value:ha.textContent,d=c.length;for(e=0;e<a&&t[e]===c[e];e++);var y=a-e;for(i=1;i<=y&&t[a-i]===c[d-i];i++);return Qr=c.slice(e,1<i?1-i:void 0)}function Kr(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 Ir(){return!0}function Ff(){return!1}function Vt(e){function t(a,i,c,d,y){this._reactName=a,this._targetInst=c,this.type=i,this.nativeEvent=d,this.target=y,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(a=e[A],this[A]=a?a(d):d[A]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Ir:Ff,this.isPropagationStopped=Ff,this}return v(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ir)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ir)},persist:function(){},isPersistent:Ir}),t}var $a={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zr=Vt($a),wl=v({},$a,{view:0,detail:0}),pb=Vt(wl),ec,tc,Al,Jr=v({},wl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ac,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!==Al&&(Al&&e.type==="mousemove"?(ec=e.screenX-Al.screenX,tc=e.screenY-Al.screenY):tc=ec=0,Al=e),ec)},movementY:function(e){return"movementY"in e?e.movementY:tc}}),Yf=Vt(Jr),xb=v({},Jr,{dataTransfer:0}),gb=Vt(xb),bb=v({},wl,{relatedTarget:0}),nc=Vt(bb),vb=v({},$a,{animationName:0,elapsedTime:0,pseudoElement:0}),yb=Vt(vb),Sb=v({},$a,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),jb=Vt(Sb),Nb=v({},$a,{data:0}),Xf=Vt(Nb),wb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ab={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"},Cb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kb(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Cb[e])?!!t[e]:!1}function ac(){return kb}var Eb=v({},wl,{key:function(e){if(e.key){var t=wb[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Kr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ab[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ac,charCode:function(e){return e.type==="keypress"?Kr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Kr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Mb=Vt(Eb),Rb=v({},Jr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qf=Vt(Rb),Tb=v({},wl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ac}),qb=Vt(Tb),Db=v({},$a,{propertyName:0,elapsedTime:0,pseudoElement:0}),_b=Vt(Db),Ob=v({},Jr,{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}),Bb=Vt(Ob),Lb=v({},$a,{newState:0,oldState:0}),zb=Vt(Lb),Ub=[9,13,27,32],sc=Gn&&"CompositionEvent"in window,Cl=null;Gn&&"documentMode"in document&&(Cl=document.documentMode);var Hb=Gn&&"TextEvent"in window&&!Cl,Kf=Gn&&(!sc||Cl&&8<Cl&&11>=Cl),If=" ",Zf=!1;function Jf(e,t){switch(e){case"keyup":return Ub.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ss=!1;function Vb(e,t){switch(e){case"compositionend":return Pf(t);case"keypress":return t.which!==32?null:(Zf=!0,If);case"textInput":return e=t.data,e===If&&Zf?null:e;default:return null}}function $b(e,t){if(Ss)return e==="compositionend"||!sc&&Jf(e,t)?(e=Gf(),Qr=Wo=ha=null,Ss=!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 Kf&&t.locale!=="ko"?null:t.data;default:return null}}var Gb={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 Wf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Gb[e.type]:t==="textarea"}function em(e,t,a,i){vs?ys?ys.push(i):ys=[i]:vs=i,t=Hi(t,"onChange"),0<t.length&&(a=new Zr("onChange","change",null,a,i),e.push({event:a,listeners:t}))}var kl=null,El=null;function Fb(e){B0(e,0)}function Pr(e){var t=Sl(e);if(Of(t))return e}function tm(e,t){if(e==="change")return t}var nm=!1;if(Gn){var lc;if(Gn){var rc="oninput"in document;if(!rc){var am=document.createElement("div");am.setAttribute("oninput","return;"),rc=typeof am.oninput=="function"}lc=rc}else lc=!1;nm=lc&&(!document.documentMode||9<document.documentMode)}function sm(){kl&&(kl.detachEvent("onpropertychange",lm),El=kl=null)}function lm(e){if(e.propertyName==="value"&&Pr(El)){var t=[];em(t,El,e,Zo(e)),$f(Fb,t)}}function Yb(e,t,a){e==="focusin"?(sm(),kl=t,El=a,kl.attachEvent("onpropertychange",lm)):e==="focusout"&&sm()}function Xb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Pr(El)}function Qb(e,t){if(e==="click")return Pr(t)}function Kb(e,t){if(e==="input"||e==="change")return Pr(t)}function Ib(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Kt=typeof Object.is=="function"?Object.is:Ib;function Ml(e,t){if(Kt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;for(i=0;i<a.length;i++){var c=a[i];if(!je.call(t,c)||!Kt(e[c],t[c]))return!1}return!0}function rm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function im(e,t){var a=rm(e);e=0;for(var i;a;){if(a.nodeType===3){if(i=e+a.textContent.length,e<=t&&i>=t)return{node:a,offset:t-e};e=i}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=rm(a)}}function om(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?om(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Yr(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Yr(e.document)}return t}function ic(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 Zb=Gn&&"documentMode"in document&&11>=document.documentMode,js=null,oc=null,Rl=null,cc=!1;function um(e,t,a){var i=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;cc||js==null||js!==Yr(i)||(i=js,"selectionStart"in i&&ic(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}),Rl&&Ml(Rl,i)||(Rl=i,i=Hi(oc,"onSelect"),0<i.length&&(t=new Zr("onSelect","select",null,t,a),e.push({event:t,listeners:i}),t.target=js)))}function Ga(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Ns={animationend:Ga("Animation","AnimationEnd"),animationiteration:Ga("Animation","AnimationIteration"),animationstart:Ga("Animation","AnimationStart"),transitionrun:Ga("Transition","TransitionRun"),transitionstart:Ga("Transition","TransitionStart"),transitioncancel:Ga("Transition","TransitionCancel"),transitionend:Ga("Transition","TransitionEnd")},uc={},dm={};Gn&&(dm=document.createElement("div").style,"AnimationEvent"in window||(delete Ns.animationend.animation,delete Ns.animationiteration.animation,delete Ns.animationstart.animation),"TransitionEvent"in window||delete Ns.transitionend.transition);function Fa(e){if(uc[e])return uc[e];if(!Ns[e])return e;var t=Ns[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in dm)return uc[e]=t[a];return e}var fm=Fa("animationend"),mm=Fa("animationiteration"),hm=Fa("animationstart"),Jb=Fa("transitionrun"),Pb=Fa("transitionstart"),Wb=Fa("transitioncancel"),pm=Fa("transitionend"),xm=new Map,dc="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(" ");dc.push("scrollEnd");function Nn(e,t){xm.set(e,t),Va(t,[e])}var Wr=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)},un=[],ws=0,fc=0;function ei(){for(var e=ws,t=fc=ws=0;t<e;){var a=un[t];un[t++]=null;var i=un[t];un[t++]=null;var c=un[t];un[t++]=null;var d=un[t];if(un[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&&gm(a,c,d)}}function ti(e,t,a,i){un[ws++]=e,un[ws++]=t,un[ws++]=a,un[ws++]=i,fc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function mc(e,t,a,i){return ti(e,t,a,i),ni(e)}function Ya(e,t){return ti(e,null,null,t),ni(e)}function gm(e,t,a){e.lanes|=a;var i=e.alternate;i!==null&&(i.lanes|=a);for(var c=!1,d=e.return;d!==null;)d.childLanes|=a,i=d.alternate,i!==null&&(i.childLanes|=a),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-Dt(a),e=d.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=a|536870912),d):null}function ni(e){if(50<Pl)throw Pl=0,ju=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var As={};function ev(e,t,a,i){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function It(e,t,a,i){return new ev(e,t,a,i)}function hc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Fn(e,t){var a=e.alternate;return a===null?(a=It(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function bm(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ai(e,t,a,i,c,d){var y=0;if(i=e,typeof e=="function")hc(e)&&(y=1);else if(typeof e=="string")y=ly(e,a,ee.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case K:return e=It(31,a,t,c),e.elementType=K,e.lanes=d,e;case S:return Xa(a.children,c,d,t);case w:y=8,c|=24;break;case j:return e=It(12,a,t,c|2),e.elementType=j,e.lanes=d,e;case L:return e=It(13,a,t,c),e.elementType=L,e.lanes=d,e;case G:return e=It(19,a,t,c),e.elementType=G,e.lanes=d,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case E:y=10;break e;case T:y=9;break e;case C:y=11;break e;case O:y=14;break e;case z:y=16,i=null;break e}y=29,a=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=It(y,a,t,c),t.elementType=e,t.type=i,t.lanes=d,t}function Xa(e,t,a,i){return e=It(7,e,i,t),e.lanes=a,e}function pc(e,t,a){return e=It(6,e,null,t),e.lanes=a,e}function vm(e){var t=It(18,null,null,0);return t.stateNode=e,t}function xc(e,t,a){return t=It(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ym=new WeakMap;function dn(e,t){if(typeof e=="object"&&e!==null){var a=ym.get(e);return a!==void 0?a:(t={value:e,source:t,stack:se(t)},ym.set(e,t),t)}return{value:e,source:t,stack:se(t)}}var Cs=[],ks=0,si=null,Tl=0,fn=[],mn=0,pa=null,qn=1,Dn="";function Yn(e,t){Cs[ks++]=Tl,Cs[ks++]=si,si=e,Tl=t}function Sm(e,t,a){fn[mn++]=qn,fn[mn++]=Dn,fn[mn++]=pa,pa=e;var i=qn;e=Dn;var c=32-Dt(i)-1;i&=~(1<<c),a+=1;var d=32-Dt(t)+c;if(30<d){var y=c-c%5;d=(i&(1<<y)-1).toString(32),i>>=y,c-=y,qn=1<<32-Dt(t)+c|a<<c|i,Dn=d+e}else qn=1<<d|a<<c|i,Dn=e}function gc(e){e.return!==null&&(Yn(e,1),Sm(e,1,0))}function bc(e){for(;e===si;)si=Cs[--ks],Cs[ks]=null,Tl=Cs[--ks],Cs[ks]=null;for(;e===pa;)pa=fn[--mn],fn[mn]=null,Dn=fn[--mn],fn[mn]=null,qn=fn[--mn],fn[mn]=null}function jm(e,t){fn[mn++]=qn,fn[mn++]=Dn,fn[mn++]=pa,qn=t.id,Dn=t.overflow,pa=e}var Et=null,lt=null,He=!1,xa=null,hn=!1,vc=Error(o(519));function ga(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ql(dn(t,e)),vc}function Nm(e){var t=e.stateNode,a=e.type,i=e.memoizedProps;switch(t[pe]=e,t[Re]=i,a){case"dialog":Le("cancel",t),Le("close",t);break;case"iframe":case"object":case"embed":Le("load",t);break;case"video":case"audio":for(a=0;a<er.length;a++)Le(er[a],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),Bf(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),zf(t,i.value,i.defaultValue,i.children)}a=i.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||i.suppressHydrationWarning===!0||H0(t.textContent,a)?(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=$n),t=!0):t=!1,t||ga(e,!0)}function wm(e){for(Et=e.return;Et;)switch(Et.tag){case 5:case 31:case 13:hn=!1;return;case 27:case 3:hn=!0;return;default:Et=Et.return}}function Es(e){if(e!==Et)return!1;if(!He)return wm(e),He=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Lu(e.type,e.memoizedProps)),a=!a),a&<&&ga(e),wm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));lt=I0(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));lt=I0(e)}else t===27?(t=lt,Ta(e.type)?(e=$u,$u=null,lt=e):lt=t):lt=Et?xn(e.stateNode.nextSibling):null;return!0}function Qa(){lt=Et=null,He=!1}function yc(){var e=xa;return e!==null&&(Yt===null?Yt=e:Yt.push.apply(Yt,e),xa=null),e}function ql(e){xa===null?xa=[e]:xa.push(e)}var Sc=R(null),Ka=null,Xn=null;function ba(e,t,a){Z(Sc,t._currentValue),t._currentValue=a}function Qn(e){e._currentValue=Sc.current,_(Sc)}function jc(e,t,a){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===a)break;e=e.return}}function Nc(e,t,a,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 A=d;d=c;for(var D=0;D<t.length;D++)if(A.context===t[D]){d.lanes|=a,A=d.alternate,A!==null&&(A.lanes|=a),jc(d.return,a,e),i||(y=null);break e}d=A.next}}else if(c.tag===18){if(y=c.return,y===null)throw Error(o(341));y.lanes|=a,d=y.alternate,d!==null&&(d.lanes|=a),jc(y,a,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 Ms(e,t,a,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 A=c.type;Kt(c.pendingProps.value,y.value)||(e!==null?e.push(A):e=[A])}}else if(c===ue.current){if(y=c.alternate,y===null)throw Error(o(387));y.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(lr):e=[lr])}c=c.return}e!==null&&Nc(t,e,a,i),t.flags|=262144}function li(e){for(e=e.firstContext;e!==null;){if(!Kt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ia(e){Ka=e,Xn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Mt(e){return Am(Ka,e)}function ri(e,t){return Ka===null&&Ia(e),Am(e,t)}function Am(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Xn===null){if(e===null)throw Error(o(308));Xn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Xn=Xn.next=t;return a}var tv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},nv=n.unstable_scheduleCallback,av=n.unstable_NormalPriority,xt={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function wc(){return{controller:new tv,data:new Map,refCount:0}}function Dl(e){e.refCount--,e.refCount===0&&nv(av,function(){e.controller.abort()})}var _l=null,Ac=0,Rs=0,Ts=null;function sv(e,t){if(_l===null){var a=_l=[];Ac=0,Rs=Eu(),Ts={status:"pending",value:void 0,then:function(i){a.push(i)}}}return Ac++,t.then(Cm,Cm),t}function Cm(){if(--Ac===0&&_l!==null){Ts!==null&&(Ts.status="fulfilled");var e=_l;_l=null,Rs=0,Ts=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function lv(e,t){var a=[],i={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),i}var km=q.S;q.S=function(e,t){u0=le(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&sv(e,t),km!==null&&km(e,t)};var Za=R(null);function Cc(){var e=Za.current;return e!==null?e:at.pooledCache}function ii(e,t){t===null?Z(Za,Za.current):Z(Za,t.pool)}function Em(){var e=Cc();return e===null?null:{parent:xt._currentValue,pool:e}}var qs=Error(o(460)),kc=Error(o(474)),oi=Error(o(542)),ci={then:function(){}};function Mm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Rm(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then($n,$n),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,qm(e),e;default:if(typeof t.status=="string")t.then($n,$n);else{if(e=at,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,qm(e),e}throw Pa=t,qs}}function Ja(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Pa=a,qs):a}}var Pa=null;function Tm(){if(Pa===null)throw Error(o(459));var e=Pa;return Pa=null,e}function qm(e){if(e===qs||e===oi)throw Error(o(483))}var Ds=null,Ol=0;function ui(e){var t=Ol;return Ol+=1,Ds===null&&(Ds=[]),Rm(Ds,e,t)}function Bl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function di(e,t){throw t.$$typeof===N?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Dm(e){function t(U,B){if(e){var F=U.deletions;F===null?(U.deletions=[B],U.flags|=16):F.push(B)}}function a(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=Fn(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 A(U,B,F,ne){return B===null||B.tag!==6?(B=pc(F,U.mode,ne),B.return=U,B):(B=c(B,F),B.return=U,B)}function D(U,B,F,ne){var Ne=F.type;return Ne===S?W(U,B,F.props.children,ne,F.key):B!==null&&(B.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===z&&Ja(Ne)===B.type)?(B=c(B,F.props),Bl(B,F),B.return=U,B):(B=ai(F.type,F.key,F.props,null,U.mode,ne),Bl(B,F),B.return=U,B)}function Y(U,B,F,ne){return B===null||B.tag!==4||B.stateNode.containerInfo!==F.containerInfo||B.stateNode.implementation!==F.implementation?(B=xc(F,U.mode,ne),B.return=U,B):(B=c(B,F.children||[]),B.return=U,B)}function W(U,B,F,ne,Ne){return B===null||B.tag!==7?(B=Xa(F,U.mode,ne,Ne),B.return=U,B):(B=c(B,F),B.return=U,B)}function ae(U,B,F){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=pc(""+B,U.mode,F),B.return=U,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case M:return F=ai(B.type,B.key,B.props,null,U.mode,F),Bl(F,B),F.return=U,F;case k:return B=xc(B,U.mode,F),B.return=U,B;case z:return B=Ja(B),ae(U,B,F)}if(V(B)||P(B))return B=Xa(B,U.mode,F,null),B.return=U,B;if(typeof B.then=="function")return ae(U,ui(B),F);if(B.$$typeof===E)return ae(U,ri(U,B),F);di(U,B)}return null}function Q(U,B,F,ne){var Ne=B!==null?B.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return Ne!==null?null:A(U,B,""+F,ne);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case M:return F.key===Ne?D(U,B,F,ne):null;case k:return F.key===Ne?Y(U,B,F,ne):null;case z:return F=Ja(F),Q(U,B,F,ne)}if(V(F)||P(F))return Ne!==null?null:W(U,B,F,ne,null);if(typeof F.then=="function")return Q(U,B,ui(F),ne);if(F.$$typeof===E)return Q(U,B,ri(U,F),ne);di(U,F)}return null}function I(U,B,F,ne,Ne){if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return U=U.get(F)||null,A(B,U,""+ne,Ne);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case M:return U=U.get(ne.key===null?F:ne.key)||null,D(B,U,ne,Ne);case k:return U=U.get(ne.key===null?F:ne.key)||null,Y(B,U,ne,Ne);case z:return ne=Ja(ne),I(U,B,F,ne,Ne)}if(V(ne)||P(ne))return U=U.get(F)||null,W(B,U,ne,Ne,null);if(typeof ne.then=="function")return I(U,B,F,ui(ne),Ne);if(ne.$$typeof===E)return I(U,B,F,ri(B,ne),Ne);di(B,ne)}return null}function be(U,B,F,ne){for(var Ne=null,$e=null,Se=B,qe=B=0,Ue=null;Se!==null&&qe<F.length;qe++){Se.index>qe?(Ue=Se,Se=null):Ue=Se.sibling;var Ge=Q(U,Se,F[qe],ne);if(Ge===null){Se===null&&(Se=Ue);break}e&&Se&&Ge.alternate===null&&t(U,Se),B=d(Ge,B,qe),$e===null?Ne=Ge:$e.sibling=Ge,$e=Ge,Se=Ue}if(qe===F.length)return a(U,Se),He&&Yn(U,qe),Ne;if(Se===null){for(;qe<F.length;qe++)Se=ae(U,F[qe],ne),Se!==null&&(B=d(Se,B,qe),$e===null?Ne=Se:$e.sibling=Se,$e=Se);return He&&Yn(U,qe),Ne}for(Se=i(Se);qe<F.length;qe++)Ue=I(Se,U,qe,F[qe],ne),Ue!==null&&(e&&Ue.alternate!==null&&Se.delete(Ue.key===null?qe:Ue.key),B=d(Ue,B,qe),$e===null?Ne=Ue:$e.sibling=Ue,$e=Ue);return e&&Se.forEach(function(Ba){return t(U,Ba)}),He&&Yn(U,qe),Ne}function we(U,B,F,ne){if(F==null)throw Error(o(151));for(var Ne=null,$e=null,Se=B,qe=B=0,Ue=null,Ge=F.next();Se!==null&&!Ge.done;qe++,Ge=F.next()){Se.index>qe?(Ue=Se,Se=null):Ue=Se.sibling;var Ba=Q(U,Se,Ge.value,ne);if(Ba===null){Se===null&&(Se=Ue);break}e&&Se&&Ba.alternate===null&&t(U,Se),B=d(Ba,B,qe),$e===null?Ne=Ba:$e.sibling=Ba,$e=Ba,Se=Ue}if(Ge.done)return a(U,Se),He&&Yn(U,qe),Ne;if(Se===null){for(;!Ge.done;qe++,Ge=F.next())Ge=ae(U,Ge.value,ne),Ge!==null&&(B=d(Ge,B,qe),$e===null?Ne=Ge:$e.sibling=Ge,$e=Ge);return He&&Yn(U,qe),Ne}for(Se=i(Se);!Ge.done;qe++,Ge=F.next())Ge=I(Se,U,qe,Ge.value,ne),Ge!==null&&(e&&Ge.alternate!==null&&Se.delete(Ge.key===null?qe:Ge.key),B=d(Ge,B,qe),$e===null?Ne=Ge:$e.sibling=Ge,$e=Ge);return e&&Se.forEach(function(xy){return t(U,xy)}),He&&Yn(U,qe),Ne}function tt(U,B,F,ne){if(typeof F=="object"&&F!==null&&F.type===S&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case M:e:{for(var Ne=F.key;B!==null;){if(B.key===Ne){if(Ne=F.type,Ne===S){if(B.tag===7){a(U,B.sibling),ne=c(B,F.props.children),ne.return=U,U=ne;break e}}else if(B.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===z&&Ja(Ne)===B.type){a(U,B.sibling),ne=c(B,F.props),Bl(ne,F),ne.return=U,U=ne;break e}a(U,B);break}else t(U,B);B=B.sibling}F.type===S?(ne=Xa(F.props.children,U.mode,ne,F.key),ne.return=U,U=ne):(ne=ai(F.type,F.key,F.props,null,U.mode,ne),Bl(ne,F),ne.return=U,U=ne)}return y(U);case k:e:{for(Ne=F.key;B!==null;){if(B.key===Ne)if(B.tag===4&&B.stateNode.containerInfo===F.containerInfo&&B.stateNode.implementation===F.implementation){a(U,B.sibling),ne=c(B,F.children||[]),ne.return=U,U=ne;break e}else{a(U,B);break}else t(U,B);B=B.sibling}ne=xc(F,U.mode,ne),ne.return=U,U=ne}return y(U);case z:return F=Ja(F),tt(U,B,F,ne)}if(V(F))return be(U,B,F,ne);if(P(F)){if(Ne=P(F),typeof Ne!="function")throw Error(o(150));return F=Ne.call(F),we(U,B,F,ne)}if(typeof F.then=="function")return tt(U,B,ui(F),ne);if(F.$$typeof===E)return tt(U,B,ri(U,F),ne);di(U,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,B!==null&&B.tag===6?(a(U,B.sibling),ne=c(B,F),ne.return=U,U=ne):(a(U,B),ne=pc(F,U.mode,ne),ne.return=U,U=ne),y(U)):a(U,B)}return function(U,B,F,ne){try{Ol=0;var Ne=tt(U,B,F,ne);return Ds=null,Ne}catch(Se){if(Se===qs||Se===oi)throw Se;var $e=It(29,Se,null,U.mode);return $e.lanes=ne,$e.return=U,$e}finally{}}}var Wa=Dm(!0),_m=Dm(!1),va=!1;function Ec(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Mc(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 ya(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Sa(e,t,a){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(Qe&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=ni(e),gm(e,null,a),t}return ti(e,i,t,a),ni(e)}function Ll(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,gl(e,a)}}function Rc(e,t){var a=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,a===i)){var c=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?c=d=y:d=d.next=y,a=a.next}while(a!==null);d===null?c=d=t:d=d.next=t}else c=d=t;a={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:d,shared:i.shared,callbacks:i.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Tc=!1;function zl(){if(Tc){var e=Ts;if(e!==null)throw e}}function Ul(e,t,a,i){Tc=!1;var c=e.updateQueue;va=!1;var d=c.firstBaseUpdate,y=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var D=A,Y=D.next;D.next=null,y===null?d=Y:y.next=Y,y=D;var W=e.alternate;W!==null&&(W=W.updateQueue,A=W.lastBaseUpdate,A!==y&&(A===null?W.firstBaseUpdate=Y:A.next=Y,W.lastBaseUpdate=D))}if(d!==null){var ae=c.baseState;y=0,W=Y=D=null,A=d;do{var Q=A.lane&-536870913,I=Q!==A.lane;if(I?(ze&Q)===Q:(i&Q)===Q){Q!==0&&Q===Rs&&(Tc=!0),W!==null&&(W=W.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var be=e,we=A;Q=t;var tt=a;switch(we.tag){case 1:if(be=we.payload,typeof be=="function"){ae=be.call(tt,ae,Q);break e}ae=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=we.payload,Q=typeof be=="function"?be.call(tt,ae,Q):be,Q==null)break e;ae=v({},ae,Q);break e;case 2:va=!0}}Q=A.callback,Q!==null&&(e.flags|=64,I&&(e.flags|=8192),I=c.callbacks,I===null?c.callbacks=[Q]:I.push(Q))}else I={lane:Q,tag:A.tag,payload:A.payload,callback:A.callback,next:null},W===null?(Y=W=I,D=ae):W=W.next=I,y|=Q;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;I=A,A=I.next,I.next=null,c.lastBaseUpdate=I,c.shared.pending=null}}while(!0);W===null&&(D=ae),c.baseState=D,c.firstBaseUpdate=Y,c.lastBaseUpdate=W,d===null&&(c.shared.lanes=0),Ca|=y,e.lanes=y,e.memoizedState=ae}}function Om(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Bm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)Om(a[e],t)}var _s=R(null),fi=R(0);function Lm(e,t){e=na,Z(fi,e),Z(_s,t),na=e|t.baseLanes}function qc(){Z(fi,na),Z(_s,_s.current)}function Dc(){na=fi.current,_(_s),_(fi)}var Zt=R(null),pn=null;function ja(e){var t=e.alternate;Z(ht,ht.current&1),Z(Zt,e),pn===null&&(t===null||_s.current!==null||t.memoizedState!==null)&&(pn=e)}function _c(e){Z(ht,ht.current),Z(Zt,e),pn===null&&(pn=e)}function zm(e){e.tag===22?(Z(ht,ht.current),Z(Zt,e),pn===null&&(pn=e)):Na()}function Na(){Z(ht,ht.current),Z(Zt,Zt.current)}function Jt(e){_(Zt),pn===e&&(pn=null),_(ht)}var ht=R(0);function mi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Hu(a)||Vu(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Kn=0,Ee=null,We=null,gt=null,hi=!1,Os=!1,es=!1,pi=0,Hl=0,Bs=null,rv=0;function ut(){throw Error(o(321))}function Oc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Kt(e[a],t[a]))return!1;return!0}function Bc(e,t,a,i,c,d){return Kn=d,Ee=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,q.H=e===null||e.memoizedState===null?Sh:Jc,es=!1,d=a(i,c),es=!1,Os&&(d=Hm(t,a,i,c)),Um(e),d}function Um(e){q.H=Gl;var t=We!==null&&We.next!==null;if(Kn=0,gt=We=Ee=null,hi=!1,Hl=0,Bs=null,t)throw Error(o(300));e===null||bt||(e=e.dependencies,e!==null&&li(e)&&(bt=!0))}function Hm(e,t,a,i){Ee=e;var c=0;do{if(Os&&(Bs=null),Hl=0,Os=!1,25<=c)throw Error(o(301));if(c+=1,gt=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=jh,d=t(a,i)}while(Os);return d}function iv(){var e=q.H,t=e.useState()[0];return t=typeof t.then=="function"?Vl(t):t,e=e.useState()[0],(We!==null?We.memoizedState:null)!==e&&(Ee.flags|=1024),t}function Lc(){var e=pi!==0;return pi=0,e}function zc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Uc(e){if(hi){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}hi=!1}Kn=0,gt=We=Ee=null,Os=!1,Hl=pi=0,Bs=null}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?Ee.memoizedState=gt=e:gt=gt.next=e,gt}function pt(){if(We===null){var e=Ee.alternate;e=e!==null?e.memoizedState:null}else e=We.next;var t=gt===null?Ee.memoizedState:gt.next;if(t!==null)gt=t,We=e;else{if(e===null)throw Ee.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},gt===null?Ee.memoizedState=gt=e:gt=gt.next=e}return gt}function xi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Vl(e){var t=Hl;return Hl+=1,Bs===null&&(Bs=[]),e=Rm(Bs,e,t),t=Ee,(gt===null?t.memoizedState:gt.next)===null&&(t=t.alternate,q.H=t===null||t.memoizedState===null?Sh:Jc),e}function gi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Vl(e);if(e.$$typeof===E)return Mt(e)}throw Error(o(438,String(e)))}function Hc(e){var t=null,a=Ee.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var i=Ee.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=xi(),Ee.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),i=0;i<e;i++)a[i]=$;return t.index++,a}function In(e,t){return typeof t=="function"?t(e):t}function bi(e){var t=pt();return Vc(t,We,e)}function Vc(e,t,a){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=a;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 A=y=null,D=null,Y=t,W=!1;do{var ae=Y.lane&-536870913;if(ae!==Y.lane?(ze&ae)===ae:(Kn&ae)===ae){var Q=Y.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),ae===Rs&&(W=!0);else if((Kn&Q)===Q){Y=Y.next,Q===Rs&&(W=!0);continue}else ae={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(A=D=ae,y=d):D=D.next=ae,Ee.lanes|=Q,Ca|=Q;ae=Y.action,es&&a(d,ae),d=Y.hasEagerState?Y.eagerState:a(d,ae)}else Q={lane:ae,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},D===null?(A=D=Q,y=d):D=D.next=Q,Ee.lanes|=ae,Ca|=ae;Y=Y.next}while(Y!==null&&Y!==t);if(D===null?y=d:D.next=A,!Kt(d,e.memoizedState)&&(bt=!0,W&&(a=Ts,a!==null)))throw a;e.memoizedState=d,e.baseState=y,e.baseQueue=D,i.lastRenderedState=d}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function $c(e){var t=pt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var i=a.dispatch,c=a.pending,d=t.memoizedState;if(c!==null){a.pending=null;var y=c=c.next;do d=e(d,y.action),y=y.next;while(y!==c);Kt(d,t.memoizedState)||(bt=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),a.lastRenderedState=d}return[d,i]}function Vm(e,t,a){var i=Ee,c=pt(),d=He;if(d){if(a===void 0)throw Error(o(407));a=a()}else a=t();var y=!Kt((We||c).memoizedState,a);if(y&&(c.memoizedState=a,bt=!0),c=c.queue,Yc(Fm.bind(null,i,c,e),[e]),c.getSnapshot!==t||y||gt!==null&>.memoizedState.tag&1){if(i.flags|=2048,Ls(9,{destroy:void 0},Gm.bind(null,i,c,a,t),null),at===null)throw Error(o(349));d||(Kn&127)!==0||$m(i,t,a)}return a}function $m(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ee.updateQueue,t===null?(t=xi(),Ee.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Gm(e,t,a,i){t.value=a,t.getSnapshot=i,Ym(t)&&Xm(e)}function Fm(e,t,a){return a(function(){Ym(t)&&Xm(e)})}function Ym(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Kt(e,a)}catch{return!0}}function Xm(e){var t=Ya(e,2);t!==null&&Xt(t,e,2)}function Gc(e){var t=Bt();if(typeof e=="function"){var a=e;if(e=a(),es){kt(!0);try{a()}finally{kt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:e},t}function Qm(e,t,a,i){return e.baseState=a,Vc(e,We,typeof i=="function"?i:In)}function ov(e,t,a,i,c){if(Si(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?a(!0):d.isTransition=!1,i(d),a=t.pending,a===null?(d.next=t.pending=d,Km(t,d)):(d.next=a.next,t.pending=a.next=d)}}function Km(e,t){var a=t.action,i=t.payload,c=e.state;if(t.isTransition){var d=q.T,y={};q.T=y;try{var A=a(c,i),D=q.S;D!==null&&D(y,A),Im(e,t,A)}catch(Y){Fc(e,t,Y)}finally{d!==null&&y.types!==null&&(d.types=y.types),q.T=d}}else try{d=a(c,i),Im(e,t,d)}catch(Y){Fc(e,t,Y)}}function Im(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(i){Zm(e,t,i)},function(i){return Fc(e,t,i)}):Zm(e,t,a)}function Zm(e,t,a){t.status="fulfilled",t.value=a,Jm(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Km(e,a)))}function Fc(e,t,a){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=a,Jm(t),t=t.next;while(t!==i)}e.action=null}function Jm(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Pm(e,t){return t}function Wm(e,t){if(He){var a=at.formState;if(a!==null){e:{var i=Ee;if(He){if(lt){t:{for(var c=lt,d=hn;c.nodeType!==8;){if(!d){c=null;break t}if(c=xn(c.nextSibling),c===null){c=null;break t}}d=c.data,c=d==="F!"||d==="F"?c:null}if(c){lt=xn(c.nextSibling),i=c.data==="F!";break e}}ga(i)}i=!1}i&&(t=a[0])}}return a=Bt(),a.memoizedState=a.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pm,lastRenderedState:t},a.queue=i,a=bh.bind(null,Ee,i),i.dispatch=a,i=Gc(!1),d=Zc.bind(null,Ee,!1,i.queue),i=Bt(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,a=ov.bind(null,Ee,c,d,a),c.dispatch=a,i.memoizedState=e,[t,a,!1]}function eh(e){var t=pt();return th(t,We,e)}function th(e,t,a){if(t=Vc(e,t,Pm)[0],e=bi(In)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=Vl(t)}catch(y){throw y===qs?oi:y}else i=t;t=pt();var c=t.queue,d=c.dispatch;return a!==t.memoizedState&&(Ee.flags|=2048,Ls(9,{destroy:void 0},cv.bind(null,c,a),null)),[i,d,e]}function cv(e,t){e.action=t}function nh(e){var t=pt(),a=We;if(a!==null)return th(t,a,e);pt(),t=t.memoizedState,a=pt();var i=a.queue.dispatch;return a.memoizedState=e,[t,i,!1]}function Ls(e,t,a,i){return e={tag:e,create:a,deps:i,inst:t,next:null},t=Ee.updateQueue,t===null&&(t=xi(),Ee.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(i=a.next,a.next=e,e.next=i,t.lastEffect=e),e}function ah(){return pt().memoizedState}function vi(e,t,a,i){var c=Bt();Ee.flags|=e,c.memoizedState=Ls(1|t,{destroy:void 0},a,i===void 0?null:i)}function yi(e,t,a,i){var c=pt();i=i===void 0?null:i;var d=c.memoizedState.inst;We!==null&&i!==null&&Oc(i,We.memoizedState.deps)?c.memoizedState=Ls(t,d,a,i):(Ee.flags|=e,c.memoizedState=Ls(1|t,d,a,i))}function sh(e,t){vi(8390656,8,e,t)}function Yc(e,t){yi(2048,8,e,t)}function uv(e){Ee.flags|=4;var t=Ee.updateQueue;if(t===null)t=xi(),Ee.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function lh(e){var t=pt().memoizedState;return uv({ref:t,nextImpl:e}),function(){if((Qe&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function rh(e,t){return yi(4,2,e,t)}function ih(e,t){return yi(4,4,e,t)}function oh(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ch(e,t,a){a=a!=null?a.concat([e]):null,yi(4,4,oh.bind(null,t,e),a)}function Xc(){}function uh(e,t){var a=pt();t=t===void 0?null:t;var i=a.memoizedState;return t!==null&&Oc(t,i[1])?i[0]:(a.memoizedState=[e,t],e)}function dh(e,t){var a=pt();t=t===void 0?null:t;var i=a.memoizedState;if(t!==null&&Oc(t,i[1]))return i[0];if(i=e(),es){kt(!0);try{e()}finally{kt(!1)}}return a.memoizedState=[i,t],i}function Qc(e,t,a){return a===void 0||(Kn&1073741824)!==0&&(ze&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=f0(),Ee.lanes|=e,Ca|=e,a)}function fh(e,t,a,i){return Kt(a,t)?a:_s.current!==null?(e=Qc(e,a,i),Kt(e,t)||(bt=!0),e):(Kn&42)===0||(Kn&1073741824)!==0&&(ze&261930)===0?(bt=!0,e.memoizedState=a):(e=f0(),Ee.lanes|=e,Ca|=e,t)}function mh(e,t,a,i,c){var d=H.p;H.p=d!==0&&8>d?d:8;var y=q.T,A={};q.T=A,Zc(e,!1,t,a);try{var D=c(),Y=q.S;if(Y!==null&&Y(A,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var W=lv(D,i);$l(e,t,W,en(e))}else $l(e,t,i,en(e))}catch(ae){$l(e,t,{then:function(){},status:"rejected",reason:ae},en())}finally{H.p=d,y!==null&&A.types!==null&&(y.types=A.types),q.T=y}}function dv(){}function Kc(e,t,a,i){if(e.tag!==5)throw Error(o(476));var c=hh(e).queue;mh(e,c,t,J,a===null?dv:function(){return ph(e),a(i)})}function hh(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:In,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ph(e){var t=hh(e);t.next===null&&(t=e.alternate.memoizedState),$l(e,t.next.queue,{},en())}function Ic(){return Mt(lr)}function xh(){return pt().memoizedState}function gh(){return pt().memoizedState}function fv(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=en();e=ya(a);var i=Sa(t,e,a);i!==null&&(Xt(i,t,a),Ll(i,t,a)),t={cache:wc()},e.payload=t;return}t=t.return}}function mv(e,t,a){var i=en();a={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Si(e)?vh(t,a):(a=mc(e,t,a,i),a!==null&&(Xt(a,e,i),yh(a,t,i)))}function bh(e,t,a){var i=en();$l(e,t,a,i)}function $l(e,t,a,i){var c={lane:i,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Si(e))vh(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,A=d(y,a);if(c.hasEagerState=!0,c.eagerState=A,Kt(A,y))return ti(e,t,c,0),at===null&&ei(),!1}catch{}finally{}if(a=mc(e,t,c,i),a!==null)return Xt(a,e,i),yh(a,t,i),!0}return!1}function Zc(e,t,a,i){if(i={lane:2,revertLane:Eu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Si(e)){if(t)throw Error(o(479))}else t=mc(e,a,i,2),t!==null&&Xt(t,e,2)}function Si(e){var t=e.alternate;return e===Ee||t!==null&&t===Ee}function vh(e,t){Os=hi=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function yh(e,t,a){if((a&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,a|=i,t.lanes=a,gl(e,a)}}var Gl={readContext:Mt,use:gi,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useLayoutEffect:ut,useInsertionEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useSyncExternalStore:ut,useId:ut,useHostTransitionStatus:ut,useFormState:ut,useActionState:ut,useOptimistic:ut,useMemoCache:ut,useCacheRefresh:ut};Gl.useEffectEvent=ut;var Sh={readContext:Mt,use:gi,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:Mt,useEffect:sh,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,vi(4194308,4,oh.bind(null,t,e),a)},useLayoutEffect:function(e,t){return vi(4194308,4,e,t)},useInsertionEffect:function(e,t){vi(4,2,e,t)},useMemo:function(e,t){var a=Bt();t=t===void 0?null:t;var i=e();if(es){kt(!0);try{e()}finally{kt(!1)}}return a.memoizedState=[i,t],i},useReducer:function(e,t,a){var i=Bt();if(a!==void 0){var c=a(t);if(es){kt(!0);try{a(t)}finally{kt(!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=mv.bind(null,Ee,e),[i.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:function(e){e=Gc(e);var t=e.queue,a=bh.bind(null,Ee,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Xc,useDeferredValue:function(e,t){var a=Bt();return Qc(a,e,t)},useTransition:function(){var e=Gc(!1);return e=mh.bind(null,Ee,e.queue,!0,!1),Bt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var i=Ee,c=Bt();if(He){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),at===null)throw Error(o(349));(ze&127)!==0||$m(i,t,a)}c.memoizedState=a;var d={value:a,getSnapshot:t};return c.queue=d,sh(Fm.bind(null,i,d,e),[e]),i.flags|=2048,Ls(9,{destroy:void 0},Gm.bind(null,i,d,a,t),null),a},useId:function(){var e=Bt(),t=at.identifierPrefix;if(He){var a=Dn,i=qn;a=(i&~(1<<32-Dt(i)-1)).toString(32)+a,t="_"+t+"R_"+a,a=pi++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=rv++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Ic,useFormState:Wm,useActionState:Wm,useOptimistic:function(e){var t=Bt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Zc.bind(null,Ee,!0,a),a.dispatch=t,[e,t]},useMemoCache:Hc,useCacheRefresh:function(){return Bt().memoizedState=fv.bind(null,Ee)},useEffectEvent:function(e){var t=Bt(),a={impl:e};return t.memoizedState=a,function(){if((Qe&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Jc={readContext:Mt,use:gi,useCallback:uh,useContext:Mt,useEffect:Yc,useImperativeHandle:ch,useInsertionEffect:rh,useLayoutEffect:ih,useMemo:dh,useReducer:bi,useRef:ah,useState:function(){return bi(In)},useDebugValue:Xc,useDeferredValue:function(e,t){var a=pt();return fh(a,We.memoizedState,e,t)},useTransition:function(){var e=bi(In)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:Vl(e),t]},useSyncExternalStore:Vm,useId:xh,useHostTransitionStatus:Ic,useFormState:eh,useActionState:eh,useOptimistic:function(e,t){var a=pt();return Qm(a,We,e,t)},useMemoCache:Hc,useCacheRefresh:gh};Jc.useEffectEvent=lh;var jh={readContext:Mt,use:gi,useCallback:uh,useContext:Mt,useEffect:Yc,useImperativeHandle:ch,useInsertionEffect:rh,useLayoutEffect:ih,useMemo:dh,useReducer:$c,useRef:ah,useState:function(){return $c(In)},useDebugValue:Xc,useDeferredValue:function(e,t){var a=pt();return We===null?Qc(a,e,t):fh(a,We.memoizedState,e,t)},useTransition:function(){var e=$c(In)[0],t=pt().memoizedState;return[typeof e=="boolean"?e:Vl(e),t]},useSyncExternalStore:Vm,useId:xh,useHostTransitionStatus:Ic,useFormState:nh,useActionState:nh,useOptimistic:function(e,t){var a=pt();return We!==null?Qm(a,We,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Hc,useCacheRefresh:gh};jh.useEffectEvent=lh;function Pc(e,t,a,i){t=e.memoizedState,a=a(i,t),a=a==null?t:v({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Wc={enqueueSetState:function(e,t,a){e=e._reactInternals;var i=en(),c=ya(i);c.payload=t,a!=null&&(c.callback=a),t=Sa(e,c,i),t!==null&&(Xt(t,e,i),Ll(t,e,i))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var i=en(),c=ya(i);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=Sa(e,c,i),t!==null&&(Xt(t,e,i),Ll(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=en(),i=ya(a);i.tag=2,t!=null&&(i.callback=t),t=Sa(e,i,a),t!==null&&(Xt(t,e,a),Ll(t,e,a))}};function Nh(e,t,a,i,c,d,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,d,y):t.prototype&&t.prototype.isPureReactComponent?!Ml(a,i)||!Ml(c,d):!0}function wh(e,t,a,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,i),t.state!==e&&Wc.enqueueReplaceState(t,t.state,null)}function ts(e,t){var a=t;if("ref"in t){a={};for(var i in t)i!=="ref"&&(a[i]=t[i])}if(e=e.defaultProps){a===t&&(a=v({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function Ah(e){Wr(e)}function Ch(e){console.error(e)}function kh(e){Wr(e)}function ji(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function Eh(e,t,a){try{var i=e.onCaughtError;i(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function eu(e,t,a){return a=ya(a),a.tag=3,a.payload={element:null},a.callback=function(){ji(e,t)},a}function Mh(e){return e=ya(e),e.tag=3,e}function Rh(e,t,a,i){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;e.payload=function(){return c(d)},e.callback=function(){Eh(t,a,i)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Eh(t,a,i),typeof c!="function"&&(ka===null?ka=new Set([this]):ka.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})})}function hv(e,t,a,i,c){if(a.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=a.alternate,t!==null&&Ms(t,a,c,!0),a=Zt.current,a!==null){switch(a.tag){case 31:case 13:return pn===null?_i():a.alternate===null&&dt===0&&(dt=3),a.flags&=-257,a.flags|=65536,a.lanes=c,i===ci?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([i]):t.add(i),Au(e,i,c)),!1;case 22:return a.flags|=65536,i===ci?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([i]):a.add(i)),Au(e,i,c)),!1}throw Error(o(435,a.tag))}return Au(e,i,c),_i(),!1}if(He)return t=Zt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==vc&&(e=Error(o(422),{cause:i}),ql(dn(e,a)))):(i!==vc&&(t=Error(o(423),{cause:i}),ql(dn(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=dn(i,a),c=eu(e.stateNode,i,c),Rc(e,c),dt!==4&&(dt=2)),!1;var d=Error(o(520),{cause:i});if(d=dn(d,a),Jl===null?Jl=[d]:Jl.push(d),dt!==4&&(dt=2),t===null)return!0;i=dn(i,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=eu(a.stateNode,i,e),Rc(a,e),!1;case 1:if(t=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(ka===null||!ka.has(d))))return a.flags|=65536,c&=-c,a.lanes|=c,c=Mh(c),Rh(c,e,a,i),Rc(a,c),!1}a=a.return}while(a!==null);return!1}var tu=Error(o(461)),bt=!1;function Rt(e,t,a,i){t.child=e===null?_m(t,null,a,i):Wa(t,e.child,a,i)}function Th(e,t,a,i,c){a=a.render;var d=t.ref;if("ref"in i){var y={};for(var A in i)A!=="ref"&&(y[A]=i[A])}else y=i;return Ia(t),i=Bc(e,t,a,y,d,c),A=Lc(),e!==null&&!bt?(zc(e,t,c),Zn(e,t,c)):(He&&A&&gc(t),t.flags|=1,Rt(e,t,i,c),t.child)}function qh(e,t,a,i,c){if(e===null){var d=a.type;return typeof d=="function"&&!hc(d)&&d.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=d,Dh(e,t,d,i,c)):(e=ai(a.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(d=e.child,!cu(e,c)){var y=d.memoizedProps;if(a=a.compare,a=a!==null?a:Ml,a(y,i)&&e.ref===t.ref)return Zn(e,t,c)}return t.flags|=1,e=Fn(d,i),e.ref=t.ref,e.return=t,t.child=e}function Dh(e,t,a,i,c){if(e!==null){var d=e.memoizedProps;if(Ml(d,i)&&e.ref===t.ref)if(bt=!1,t.pendingProps=i=d,cu(e,c))(e.flags&131072)!==0&&(bt=!0);else return t.lanes=e.lanes,Zn(e,t,c)}return nu(e,t,a,i,c)}function _h(e,t,a,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|a:a,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~d}else i=0,t.child=null;return Oh(e,t,d,a,i)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ii(t,d!==null?d.cachePool:null),d!==null?Lm(t,d):qc(),zm(t);else return i=t.lanes=536870912,Oh(e,t,d!==null?d.baseLanes|a:a,a,i)}else d!==null?(ii(t,d.cachePool),Lm(t,d),Na(),t.memoizedState=null):(e!==null&&ii(t,null),qc(),Na());return Rt(e,t,c,a),t.child}function Fl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Oh(e,t,a,i,c){var d=Cc();return d=d===null?null:{parent:xt._currentValue,pool:d},t.memoizedState={baseLanes:a,cachePool:d},e!==null&&ii(t,null),qc(),zm(t),e!==null&&Ms(e,t,i,!0),t.childLanes=c,null}function Ni(e,t){return t=Ai({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Bh(e,t,a){return Wa(t,e.child,null,a),e=Ni(t,t.pendingProps),e.flags|=2,Jt(t),t.memoizedState=null,e}function pv(e,t,a){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(He){if(i.mode==="hidden")return e=Ni(t,i),t.lanes=536870912,Fl(null,e);if(_c(t),(e=lt)?(e=K0(e,hn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pa!==null?{id:qn,overflow:Dn}:null,retryLane:536870912,hydrationErrors:null},a=vm(e),a.return=t,t.child=a,Et=t,lt=null)):e=null,e===null)throw ga(t);return t.lanes=536870912,null}return Ni(t,i)}var d=e.memoizedState;if(d!==null){var y=d.dehydrated;if(_c(t),c)if(t.flags&256)t.flags&=-257,t=Bh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(bt||Ms(e,t,a,!1),c=(a&e.childLanes)!==0,bt||c){if(i=at,i!==null&&(y=$r(i,a),y!==0&&y!==d.retryLane))throw d.retryLane=y,Ya(e,y),Xt(i,e,y),tu;_i(),t=Bh(e,t,a)}else e=d.treeContext,lt=xn(y.nextSibling),Et=t,He=!0,xa=null,hn=!1,e!==null&&jm(t,e),t=Ni(t,i),t.flags|=4096;return t}return e=Fn(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function wi(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(o(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function nu(e,t,a,i,c){return Ia(t),a=Bc(e,t,a,i,void 0,c),i=Lc(),e!==null&&!bt?(zc(e,t,c),Zn(e,t,c)):(He&&i&&gc(t),t.flags|=1,Rt(e,t,a,c),t.child)}function Lh(e,t,a,i,c,d){return Ia(t),t.updateQueue=null,a=Hm(t,i,a,c),Um(e),i=Lc(),e!==null&&!bt?(zc(e,t,d),Zn(e,t,d)):(He&&i&&gc(t),t.flags|=1,Rt(e,t,a,d),t.child)}function zh(e,t,a,i,c){if(Ia(t),t.stateNode===null){var d=As,y=a.contextType;typeof y=="object"&&y!==null&&(d=Mt(y)),d=new a(i,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Wc,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=i,d.state=t.memoizedState,d.refs={},Ec(t),y=a.contextType,d.context=typeof y=="object"&&y!==null?Mt(y):As,d.state=t.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Pc(t,a,y,i),d.state=t.memoizedState),typeof a.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&&Wc.enqueueReplaceState(d,d.state,null),Ul(t,i,d,c),zl(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){d=t.stateNode;var A=t.memoizedProps,D=ts(a,A);d.props=D;var Y=d.context,W=a.contextType;y=As,typeof W=="object"&&W!==null&&(y=Mt(W));var ae=a.getDerivedStateFromProps;W=typeof ae=="function"||typeof d.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,W||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(A||Y!==y)&&wh(t,d,i,y),va=!1;var Q=t.memoizedState;d.state=Q,Ul(t,i,d,c),zl(),Y=t.memoizedState,A||Q!==Y||va?(typeof ae=="function"&&(Pc(t,a,ae,i),Y=t.memoizedState),(D=va||Nh(t,a,D,i,Q,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,Mc(e,t),y=t.memoizedProps,W=ts(a,y),d.props=W,ae=t.pendingProps,Q=d.context,Y=a.contextType,D=As,typeof Y=="object"&&Y!==null&&(D=Mt(Y)),A=a.getDerivedStateFromProps,(Y=typeof A=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(y!==ae||Q!==D)&&wh(t,d,i,D),va=!1,Q=t.memoizedState,d.state=Q,Ul(t,i,d,c),zl();var I=t.memoizedState;y!==ae||Q!==I||va||e!==null&&e.dependencies!==null&&li(e.dependencies)?(typeof A=="function"&&(Pc(t,a,A,i),I=t.memoizedState),(W=va||Nh(t,a,W,i,Q,I,D)||e!==null&&e.dependencies!==null&&li(e.dependencies))?(Y||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(i,I,D),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(i,I,D)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=I),d.props=i,d.state=I,d.context=D,i=W):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),i=!1)}return d=i,wi(e,t),i=(t.flags&128)!==0,d||i?(d=t.stateNode,a=i&&typeof a.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,e!==null&&i?(t.child=Wa(t,e.child,null,c),t.child=Wa(t,null,a,c)):Rt(e,t,a,c),t.memoizedState=d.state,e=t.child):e=Zn(e,t,c),e}function Uh(e,t,a,i){return Qa(),t.flags|=256,Rt(e,t,a,i),t.child}var au={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function su(e){return{baseLanes:e,cachePool:Em()}}function lu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Wt),e}function Hh(e,t,a){var i=t.pendingProps,c=!1,d=(t.flags&128)!==0,y;if((y=d)||(y=e!==null&&e.memoizedState===null?!1:(ht.current&2)!==0),y&&(c=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(He){if(c?ja(t):Na(),(e=lt)?(e=K0(e,hn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pa!==null?{id:qn,overflow:Dn}:null,retryLane:536870912,hydrationErrors:null},a=vm(e),a.return=t,t.child=a,Et=t,lt=null)):e=null,e===null)throw ga(t);return Vu(e)?t.lanes=32:t.lanes=536870912,null}var A=i.children;return i=i.fallback,c?(Na(),c=t.mode,A=Ai({mode:"hidden",children:A},c),i=Xa(i,c,a,null),A.return=t,i.return=t,A.sibling=i,t.child=A,i=t.child,i.memoizedState=su(a),i.childLanes=lu(e,y,a),t.memoizedState=au,Fl(null,i)):(ja(t),ru(t,A))}var D=e.memoizedState;if(D!==null&&(A=D.dehydrated,A!==null)){if(d)t.flags&256?(ja(t),t.flags&=-257,t=iu(e,t,a)):t.memoizedState!==null?(Na(),t.child=e.child,t.flags|=128,t=null):(Na(),A=i.fallback,c=t.mode,i=Ai({mode:"visible",children:i.children},c),A=Xa(A,c,a,null),A.flags|=2,i.return=t,A.return=t,i.sibling=A,t.child=i,Wa(t,e.child,null,a),i=t.child,i.memoizedState=su(a),i.childLanes=lu(e,y,a),t.memoizedState=au,t=Fl(null,i));else if(ja(t),Vu(A)){if(y=A.nextSibling&&A.nextSibling.dataset,y)var Y=y.dgst;y=Y,i=Error(o(419)),i.stack="",i.digest=y,ql({value:i,source:null,stack:null}),t=iu(e,t,a)}else if(bt||Ms(e,t,a,!1),y=(a&e.childLanes)!==0,bt||y){if(y=at,y!==null&&(i=$r(y,a),i!==0&&i!==D.retryLane))throw D.retryLane=i,Ya(e,i),Xt(y,e,i),tu;Hu(A)||_i(),t=iu(e,t,a)}else Hu(A)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,lt=xn(A.nextSibling),Et=t,He=!0,xa=null,hn=!1,e!==null&&jm(t,e),t=ru(t,i.children),t.flags|=4096);return t}return c?(Na(),A=i.fallback,c=t.mode,D=e.child,Y=D.sibling,i=Fn(D,{mode:"hidden",children:i.children}),i.subtreeFlags=D.subtreeFlags&65011712,Y!==null?A=Fn(Y,A):(A=Xa(A,c,a,null),A.flags|=2),A.return=t,i.return=t,i.sibling=A,t.child=i,Fl(null,i),i=t.child,A=e.child.memoizedState,A===null?A=su(a):(c=A.cachePool,c!==null?(D=xt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=Em(),A={baseLanes:A.baseLanes|a,cachePool:c}),i.memoizedState=A,i.childLanes=lu(e,y,a),t.memoizedState=au,Fl(e.child,i)):(ja(t),a=e.child,e=a.sibling,a=Fn(a,{mode:"visible",children:i.children}),a.return=t,a.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=a,t.memoizedState=null,a)}function ru(e,t){return t=Ai({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ai(e,t){return e=It(22,e,null,t),e.lanes=0,e}function iu(e,t,a){return Wa(t,e.child,null,a),e=ru(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Vh(e,t,a){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),jc(e.return,t,a)}function ou(e,t,a,i,c,d){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:a,tailMode:c,treeForkCount:d}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=i,y.tail=a,y.tailMode=c,y.treeForkCount=d)}function $h(e,t,a){var i=t.pendingProps,c=i.revealOrder,d=i.tail;i=i.children;var y=ht.current,A=(y&2)!==0;if(A?(y=y&1|2,t.flags|=128):y&=1,Z(ht,y),Rt(e,t,i,a),i=He?Tl:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Vh(e,a,t);else if(e.tag===19)Vh(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(a=t.child,c=null;a!==null;)e=a.alternate,e!==null&&mi(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),ou(t,!1,c,a,d,i);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&mi(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}ou(t,!0,a,null,d,i);break;case"together":ou(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Zn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Ca|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ms(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,a=Fn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Fn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function cu(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&li(e)))}function xv(e,t,a){switch(t.tag){case 3:ge(t,t.stateNode.containerInfo),ba(t,xt,e.memoizedState.cache),Qa();break;case 27:case 5:ye(t);break;case 4:ge(t,t.stateNode.containerInfo);break;case 10:ba(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,_c(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(ja(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Hh(e,t,a):(ja(t),e=Zn(e,t,a),e!==null?e.sibling:null);ja(t);break;case 19:var c=(e.flags&128)!==0;if(i=(a&t.childLanes)!==0,i||(Ms(e,t,a,!1),i=(a&t.childLanes)!==0),c){if(i)return $h(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),Z(ht,ht.current),i)break;return null;case 22:return t.lanes=0,_h(e,t,a,t.pendingProps);case 24:ba(t,xt,e.memoizedState.cache)}return Zn(e,t,a)}function Gh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)bt=!0;else{if(!cu(e,a)&&(t.flags&128)===0)return bt=!1,xv(e,t,a);bt=(e.flags&131072)!==0}else bt=!1,He&&(t.flags&1048576)!==0&&Sm(t,Tl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=Ja(t.elementType),t.type=e,typeof e=="function")hc(e)?(i=ts(e,i),t.tag=1,t=zh(null,t,e,i,a)):(t.tag=0,t=nu(null,t,e,i,a));else{if(e!=null){var c=e.$$typeof;if(c===C){t.tag=11,t=Th(null,t,e,i,a);break e}else if(c===O){t.tag=14,t=qh(null,t,e,i,a);break e}}throw t=ie(e)||e,Error(o(306,t,""))}}return t;case 0:return nu(e,t,t.type,t.pendingProps,a);case 1:return i=t.type,c=ts(i,t.pendingProps),zh(e,t,i,c,a);case 3:e:{if(ge(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var d=t.memoizedState;c=d.element,Mc(e,t),Ul(t,i,null,a);var y=t.memoizedState;if(i=y.cache,ba(t,xt,i),i!==d.cache&&Nc(t,[xt],a,!0),zl(),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=Uh(e,t,i,a);break e}else if(i!==c){c=dn(Error(o(424)),t),ql(c),t=Uh(e,t,i,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(lt=xn(e.firstChild),Et=t,He=!0,xa=null,hn=!0,a=_m(t,null,i,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Qa(),i===c){t=Zn(e,t,a);break e}Rt(e,t,i,a)}t=t.child}return t;case 26:return wi(e,t),e===null?(a=ep(t.type,null,t.pendingProps,null))?t.memoizedState=a:He||(a=t.type,e=t.pendingProps,i=Vi(oe.current).createElement(a),i[pe]=t,i[Re]=e,Tt(i,a,e),Nt(i),t.stateNode=i):t.memoizedState=ep(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ye(t),e===null&&He&&(i=t.stateNode=J0(t.type,t.pendingProps,oe.current),Et=t,hn=!0,c=lt,Ta(t.type)?($u=c,lt=xn(i.firstChild)):lt=c),Rt(e,t,t.pendingProps.children,a),wi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&He&&((c=i=lt)&&(i=Xv(i,t.type,t.pendingProps,hn),i!==null?(t.stateNode=i,Et=t,lt=xn(i.firstChild),hn=!1,c=!0):c=!1),c||ga(t)),ye(t),c=t.type,d=t.pendingProps,y=e!==null?e.memoizedProps:null,i=d.children,Lu(c,d)?i=null:y!==null&&Lu(c,y)&&(t.flags|=32),t.memoizedState!==null&&(c=Bc(e,t,iv,null,null,a),lr._currentValue=c),wi(e,t),Rt(e,t,i,a),t.child;case 6:return e===null&&He&&((e=a=lt)&&(a=Qv(a,t.pendingProps,hn),a!==null?(t.stateNode=a,Et=t,lt=null,e=!0):e=!1),e||ga(t)),null;case 13:return Hh(e,t,a);case 4:return ge(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Wa(t,null,i,a):Rt(e,t,i,a),t.child;case 11:return Th(e,t,t.type,t.pendingProps,a);case 7:return Rt(e,t,t.pendingProps,a),t.child;case 8:return Rt(e,t,t.pendingProps.children,a),t.child;case 12:return Rt(e,t,t.pendingProps.children,a),t.child;case 10:return i=t.pendingProps,ba(t,t.type,i.value),Rt(e,t,i.children,a),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Ia(t),c=Mt(c),i=i(c),t.flags|=1,Rt(e,t,i,a),t.child;case 14:return qh(e,t,t.type,t.pendingProps,a);case 15:return Dh(e,t,t.type,t.pendingProps,a);case 19:return $h(e,t,a);case 31:return pv(e,t,a);case 22:return _h(e,t,a,t.pendingProps);case 24:return Ia(t),i=Mt(xt),e===null?(c=Cc(),c===null&&(c=at,d=wc(),c.pooledCache=d,d.refCount++,d!==null&&(c.pooledCacheLanes|=a),c=d),t.memoizedState={parent:i,cache:c},Ec(t),ba(t,xt,c)):((e.lanes&a)!==0&&(Mc(e,t),Ul(t,null,null,a),zl()),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),ba(t,xt,i)):(i=d.cache,ba(t,xt,i),i!==c.cache&&Nc(t,[xt],a,!0))),Rt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Jn(e){e.flags|=4}function uu(e,t,a,i,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(x0())e.flags|=8192;else throw Pa=ci,kc}else e.flags&=-16777217}function Fh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!lp(t))if(x0())e.flags|=8192;else throw Pa=ci,kc}function Ci(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?pl():536870912,e.lanes|=t,Vs|=t)}function Yl(e,t){if(!He)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function rt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,i=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=a,t}function gv(e,t,a){var i=t.pendingProps;switch(bc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rt(t),null;case 1:return rt(t),null;case 3:return a=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Qn(xt),ve(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Es(t)?Jn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,yc())),rt(t),null;case 26:var c=t.type,d=t.memoizedState;return e===null?(Jn(t),d!==null?(rt(t),Fh(t,d)):(rt(t),uu(t,c,null,i,a))):d?d!==e.memoizedState?(Jn(t),rt(t),Fh(t,d)):(rt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&Jn(t),rt(t),uu(t,c,e,i,a)),null;case 27:if(Ye(t),a=oe.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Jn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return rt(t),null}e=ee.current,Es(t)?Nm(t):(e=J0(c,i,a),t.stateNode=e,Jn(t))}return rt(t),null;case 5:if(Ye(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&Jn(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return rt(t),null}if(d=ee.current,Es(t))Nm(t);else{var y=Vi(oe.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[pe]=t,d[Re]=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(Tt(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&&Jn(t)}}return rt(t),uu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Jn(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=oe.current,Es(t)){if(e=t.stateNode,a=t.memoizedProps,i=null,c=Et,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[pe]=t,e=!!(e.nodeValue===a||i!==null&&i.suppressHydrationWarning===!0||H0(e.nodeValue,a)),e||ga(t,!0)}else e=Vi(e).createTextNode(i),e[pe]=t,t.stateNode=e}return rt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(i=Es(t),a!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[pe]=t}else Qa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;rt(t),e=!1}else a=yc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Jt(t),t):(Jt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return rt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Es(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[pe]=t}else Qa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;rt(t),c=!1}else c=yc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Jt(t),t):(Jt(t),null)}return Jt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=i!==null,e=e!==null&&e.memoizedState!==null,a&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==c&&(i.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),Ci(t,t.updateQueue),rt(t),null);case 4:return ve(),e===null&&qu(t.stateNode.containerInfo),rt(t),null;case 10:return Qn(t.type),rt(t),null;case 19:if(_(ht),i=t.memoizedState,i===null)return rt(t),null;if(c=(t.flags&128)!==0,d=i.rendering,d===null)if(c)Yl(i,!1);else{if(dt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(d=mi(e),d!==null){for(t.flags|=128,Yl(i,!1),e=d.updateQueue,t.updateQueue=e,Ci(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)bm(a,e),a=a.sibling;return Z(ht,ht.current&1|2),He&&Yn(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&le()>Ti&&(t.flags|=128,c=!0,Yl(i,!1),t.lanes=4194304)}else{if(!c)if(e=mi(d),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,Ci(t,e),Yl(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!He)return rt(t),null}else 2*le()-i.renderingStartTime>Ti&&a!==536870912&&(t.flags|=128,c=!0,Yl(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,a=ht.current,Z(ht,c?a&1|2:a&1),He&&Yn(t,i.treeForkCount),e):(rt(t),null);case 22:case 23:return Jt(t),Dc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(a&536870912)!==0&&(t.flags&128)===0&&(rt(t),t.subtreeFlags&6&&(t.flags|=8192)):rt(t),a=t.updateQueue,a!==null&&Ci(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==a&&(t.flags|=2048),e!==null&&_(Za),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Qn(xt),rt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function bv(e,t){switch(bc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Qn(xt),ve(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ye(t),null;case 31:if(t.memoizedState!==null){if(Jt(t),t.alternate===null)throw Error(o(340));Qa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Jt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Qa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _(ht),null;case 4:return ve(),null;case 10:return Qn(t.type),null;case 22:case 23:return Jt(t),Dc(),e!==null&&_(Za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Qn(xt),null;case 25:return null;default:return null}}function Yh(e,t){switch(bc(t),t.tag){case 3:Qn(xt),ve();break;case 26:case 27:case 5:Ye(t);break;case 4:ve();break;case 31:t.memoizedState!==null&&Jt(t);break;case 13:Jt(t);break;case 19:_(ht);break;case 10:Qn(t.type);break;case 22:case 23:Jt(t),Dc(),e!==null&&_(Za);break;case 24:Qn(xt)}}function Xl(e,t){try{var a=t.updateQueue,i=a!==null?a.lastEffect:null;if(i!==null){var c=i.next;a=c;do{if((a.tag&e)===e){i=void 0;var d=a.create,y=a.inst;i=d(),y.destroy=i}a=a.next}while(a!==c)}}catch(A){Je(t,t.return,A)}}function wa(e,t,a){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,A=y.destroy;if(A!==void 0){y.destroy=void 0,c=t;var D=a,Y=A;try{Y()}catch(W){Je(c,D,W)}}}i=i.next}while(i!==d)}}catch(W){Je(t,t.return,W)}}function Xh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Bm(t,a)}catch(i){Je(e,e.return,i)}}}function Qh(e,t,a){a.props=ts(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(i){Je(e,t,i)}}function Ql(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof a=="function"?e.refCleanup=a(i):a.current=i}}catch(c){Je(e,t,c)}}function _n(e,t){var a=e.ref,i=e.refCleanup;if(a!==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 a=="function")try{a(null)}catch(c){Je(e,t,c)}else a.current=null}function Kh(e){var t=e.type,a=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&i.focus();break e;case"img":a.src?i.src=a.src:a.srcSet&&(i.srcset=a.srcSet)}}catch(c){Je(e,e.return,c)}}function du(e,t,a){try{var i=e.stateNode;Hv(i,e.type,a,t),i[Re]=t}catch(c){Je(e,e.return,c)}}function Ih(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ta(e.type)||e.tag===4}function fu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ih(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&&Ta(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 mu(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=$n));else if(i!==4&&(i===27&&Ta(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(mu(e,t,a),e=e.sibling;e!==null;)mu(e,t,a),e=e.sibling}function ki(e,t,a){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(i!==4&&(i===27&&Ta(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(ki(e,t,a),e=e.sibling;e!==null;)ki(e,t,a),e=e.sibling}function Zh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Tt(t,i,a),t[pe]=e,t[Re]=a}catch(d){Je(e,e.return,d)}}var Pn=!1,vt=!1,hu=!1,Jh=typeof WeakSet=="function"?WeakSet:Set,wt=null;function vv(e,t){if(e=e.containerInfo,Ou=Ki,e=cm(e),ic(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var i=a.getSelection&&a.getSelection();if(i&&i.rangeCount!==0){a=i.anchorNode;var c=i.anchorOffset,d=i.focusNode;i=i.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var y=0,A=-1,D=-1,Y=0,W=0,ae=e,Q=null;t:for(;;){for(var I;ae!==a||c!==0&&ae.nodeType!==3||(A=y+c),ae!==d||i!==0&&ae.nodeType!==3||(D=y+i),ae.nodeType===3&&(y+=ae.nodeValue.length),(I=ae.firstChild)!==null;)Q=ae,ae=I;for(;;){if(ae===e)break t;if(Q===a&&++Y===c&&(A=y),Q===d&&++W===i&&(D=y),(I=ae.nextSibling)!==null)break;ae=Q,Q=ae.parentNode}ae=I}a=A===-1||D===-1?null:{start:A,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Bu={focusedElem:e,selectionRange:a},Ki=!1,wt=t;wt!==null;)if(t=wt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,wt=e;else for(;wt!==null;){switch(t=wt,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(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&d!==null){e=void 0,a=t,c=d.memoizedProps,d=d.memoizedState,i=a.stateNode;try{var be=ts(a.type,c);e=i.getSnapshotBeforeUpdate(be,d),i.__reactInternalSnapshotBeforeUpdate=e}catch(we){Je(a,a.return,we)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Uu(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Uu(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,wt=e;break}wt=t.return}}function Ph(e,t,a){var i=a.flags;switch(a.tag){case 0:case 11:case 15:ea(e,a),i&4&&Xl(5,a);break;case 1:if(ea(e,a),i&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(y){Je(a,a.return,y)}else{var c=ts(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Je(a,a.return,y)}}i&64&&Xh(a),i&512&&Ql(a,a.return);break;case 3:if(ea(e,a),i&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Bm(e,t)}catch(y){Je(a,a.return,y)}}break;case 27:t===null&&i&4&&Zh(a);case 26:case 5:ea(e,a),t===null&&i&4&&Kh(a),i&512&&Ql(a,a.return);break;case 12:ea(e,a);break;case 31:ea(e,a),i&4&&t0(e,a);break;case 13:ea(e,a),i&4&&n0(e,a),i&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=Ev.bind(null,a),Kv(e,a))));break;case 22:if(i=a.memoizedState!==null||Pn,!i){t=t!==null&&t.memoizedState!==null||vt,c=Pn;var d=vt;Pn=i,(vt=t)&&!d?ta(e,a,(a.subtreeFlags&8772)!==0):ea(e,a),Pn=c,vt=d}break;case 30:break;default:ea(e,a)}}function Wh(e){var t=e.alternate;t!==null&&(e.alternate=null,Wh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&mt(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 it=null,$t=!1;function Wn(e,t,a){for(a=a.child;a!==null;)e0(e,t,a),a=a.sibling}function e0(e,t,a){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(Sn,a)}catch{}switch(a.tag){case 26:vt||_n(a,t),Wn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:vt||_n(a,t);var i=it,c=$t;Ta(a.type)&&(it=a.stateNode,$t=!1),Wn(e,t,a),nr(a.stateNode),it=i,$t=c;break;case 5:vt||_n(a,t);case 6:if(i=it,c=$t,it=null,Wn(e,t,a),it=i,$t=c,it!==null)if($t)try{(it.nodeType===9?it.body:it.nodeName==="HTML"?it.ownerDocument.body:it).removeChild(a.stateNode)}catch(d){Je(a,t,d)}else try{it.removeChild(a.stateNode)}catch(d){Je(a,t,d)}break;case 18:it!==null&&($t?(e=it,X0(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Is(e)):X0(it,a.stateNode));break;case 4:i=it,c=$t,it=a.stateNode.containerInfo,$t=!0,Wn(e,t,a),it=i,$t=c;break;case 0:case 11:case 14:case 15:wa(2,a,t),vt||wa(4,a,t),Wn(e,t,a);break;case 1:vt||(_n(a,t),i=a.stateNode,typeof i.componentWillUnmount=="function"&&Qh(a,t,i)),Wn(e,t,a);break;case 21:Wn(e,t,a);break;case 22:vt=(i=vt)||a.memoizedState!==null,Wn(e,t,a),vt=i;break;default:Wn(e,t,a)}}function t0(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Is(e)}catch(a){Je(t,t.return,a)}}}function n0(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Is(e)}catch(a){Je(t,t.return,a)}}function yv(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Jh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Jh),t;default:throw Error(o(435,e.tag))}}function Ei(e,t){var a=yv(e);t.forEach(function(i){if(!a.has(i)){a.add(i);var c=Mv.bind(null,e,i);i.then(c,c)}})}function Gt(e,t){var a=t.deletions;if(a!==null)for(var i=0;i<a.length;i++){var c=a[i],d=e,y=t,A=y;e:for(;A!==null;){switch(A.tag){case 27:if(Ta(A.type)){it=A.stateNode,$t=!1;break e}break;case 5:it=A.stateNode,$t=!1;break e;case 3:case 4:it=A.stateNode.containerInfo,$t=!0;break e}A=A.return}if(it===null)throw Error(o(160));e0(d,y,c),it=null,$t=!1,d=c.alternate,d!==null&&(d.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)a0(t,e),t=t.sibling}var wn=null;function a0(e,t){var a=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Gt(t,e),Ft(e),i&4&&(wa(3,e,e.return),Xl(3,e),wa(5,e,e.return));break;case 1:Gt(t,e),Ft(e),i&512&&(vt||a===null||_n(a,a.return)),i&64&&Pn&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?i:a.concat(i))));break;case 26:var c=wn;if(Gt(t,e),Ft(e),i&512&&(vt||a===null||_n(a,a.return)),i&4){var d=a!==null?a.memoizedState:null;if(i=e.memoizedState,a===null)if(i===null)if(e.stateNode===null){e:{i=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":d=c.getElementsByTagName("title")[0],(!d||d[Tn]||d[pe]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=c.createElement(i),c.head.insertBefore(d,c.querySelector("head > title"))),Tt(d,i,a),d[pe]=e,Nt(d),i=d;break e;case"link":var y=ap("link","href",c).get(i+(a.href||""));if(y){for(var A=0;A<y.length;A++)if(d=y[A],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(A,1);break t}}d=c.createElement(i),Tt(d,i,a),c.head.appendChild(d);break;case"meta":if(y=ap("meta","content",c).get(i+(a.content||""))){for(A=0;A<y.length;A++)if(d=y[A],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(A,1);break t}}d=c.createElement(i),Tt(d,i,a),c.head.appendChild(d);break;default:throw Error(o(468,i))}d[pe]=e,Nt(d),i=d}e.stateNode=i}else sp(c,e.type,e.stateNode);else e.stateNode=np(c,i,e.memoizedProps);else d!==i?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,i===null?sp(c,e.type,e.stateNode):np(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&du(e,e.memoizedProps,a.memoizedProps)}break;case 27:Gt(t,e),Ft(e),i&512&&(vt||a===null||_n(a,a.return)),a!==null&&i&4&&du(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Gt(t,e),Ft(e),i&512&&(vt||a===null||_n(a,a.return)),e.flags&32){c=e.stateNode;try{bs(c,"")}catch(be){Je(e,e.return,be)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,du(e,c,a!==null?a.memoizedProps:c)),i&1024&&(hu=!0);break;case 6:if(Gt(t,e),Ft(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,a=e.stateNode;try{a.nodeValue=i}catch(be){Je(e,e.return,be)}}break;case 3:if(Fi=null,c=wn,wn=$i(t.containerInfo),Gt(t,e),wn=c,Ft(e),i&4&&a!==null&&a.memoizedState.isDehydrated)try{Is(t.containerInfo)}catch(be){Je(e,e.return,be)}hu&&(hu=!1,s0(e));break;case 4:i=wn,wn=$i(e.stateNode.containerInfo),Gt(t,e),Ft(e),wn=i;break;case 12:Gt(t,e),Ft(e);break;case 31:Gt(t,e),Ft(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Ei(e,i)));break;case 13:Gt(t,e),Ft(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Ri=le()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Ei(e,i)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,Y=Pn,W=vt;if(Pn=Y||c,vt=W||D,Gt(t,e),vt=W,Pn=Y,Ft(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||Pn||vt||ns(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=t;try{if(d=D.stateNode,c)y=d.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{A=D.stateNode;var ae=D.memoizedProps.style,Q=ae!=null&&ae.hasOwnProperty("display")?ae.display:null;A.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(be){Je(D,D.return,be)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(be){Je(D,D.return,be)}}}else if(t.tag===18){if(a===null){D=t;try{var I=D.stateNode;c?Q0(I,!0):Q0(D.stateNode,!1)}catch(be){Je(D,D.return,be)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(a=i.retryQueue,a!==null&&(i.retryQueue=null,Ei(e,a))));break;case 19:Gt(t,e),Ft(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Ei(e,i)));break;case 30:break;case 21:break;default:Gt(t,e),Ft(e)}}function Ft(e){var t=e.flags;if(t&2){try{for(var a,i=e.return;i!==null;){if(Ih(i)){a=i;break}i=i.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,d=fu(e);ki(e,d,c);break;case 5:var y=a.stateNode;a.flags&32&&(bs(y,""),a.flags&=-33);var A=fu(e);ki(e,A,y);break;case 3:case 4:var D=a.stateNode.containerInfo,Y=fu(e);mu(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 s0(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;s0(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ea(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Ph(e,t.alternate,t),t=t.sibling}function ns(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:wa(4,t,t.return),ns(t);break;case 1:_n(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Qh(t,t.return,a),ns(t);break;case 27:nr(t.stateNode);case 26:case 5:_n(t,t.return),ns(t);break;case 22:t.memoizedState===null&&ns(t);break;case 30:ns(t);break;default:ns(t)}e=e.sibling}}function ta(e,t,a){for(a=a&&(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:ta(c,d,a),Xl(4,d);break;case 1:if(ta(c,d,a),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 A=i.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)Om(D[c],A)}catch(Y){Je(i,i.return,Y)}}a&&y&64&&Xh(d),Ql(d,d.return);break;case 27:Zh(d);case 26:case 5:ta(c,d,a),a&&i===null&&y&4&&Kh(d),Ql(d,d.return);break;case 12:ta(c,d,a);break;case 31:ta(c,d,a),a&&y&4&&t0(c,d);break;case 13:ta(c,d,a),a&&y&4&&n0(c,d);break;case 22:d.memoizedState===null&&ta(c,d,a),Ql(d,d.return);break;case 30:break;default:ta(c,d,a)}t=t.sibling}}function pu(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Dl(a))}function xu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Dl(e))}function An(e,t,a,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)l0(e,t,a,i),t=t.sibling}function l0(e,t,a,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:An(e,t,a,i),c&2048&&Xl(9,t);break;case 1:An(e,t,a,i);break;case 3:An(e,t,a,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Dl(e)));break;case 12:if(c&2048){An(e,t,a,i),e=t.stateNode;try{var d=t.memoizedProps,y=d.id,A=d.onPostCommit;typeof A=="function"&&A(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Je(t,t.return,D)}}else An(e,t,a,i);break;case 31:An(e,t,a,i);break;case 13:An(e,t,a,i);break;case 23:break;case 22:d=t.stateNode,y=t.alternate,t.memoizedState!==null?d._visibility&2?An(e,t,a,i):Kl(e,t):d._visibility&2?An(e,t,a,i):(d._visibility|=2,zs(e,t,a,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&pu(y,t);break;case 24:An(e,t,a,i),c&2048&&xu(t.alternate,t);break;default:An(e,t,a,i)}}function zs(e,t,a,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=e,y=t,A=a,D=i,Y=y.flags;switch(y.tag){case 0:case 11:case 15:zs(d,y,A,D,c),Xl(8,y);break;case 23:break;case 22:var W=y.stateNode;y.memoizedState!==null?W._visibility&2?zs(d,y,A,D,c):Kl(d,y):(W._visibility|=2,zs(d,y,A,D,c)),c&&Y&2048&&pu(y.alternate,y);break;case 24:zs(d,y,A,D,c),c&&Y&2048&&xu(y.alternate,y);break;default:zs(d,y,A,D,c)}t=t.sibling}}function Kl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,i=t,c=i.flags;switch(i.tag){case 22:Kl(a,i),c&2048&&pu(i.alternate,i);break;case 24:Kl(a,i),c&2048&&xu(i.alternate,i);break;default:Kl(a,i)}t=t.sibling}}var Il=8192;function Us(e,t,a){if(e.subtreeFlags&Il)for(e=e.child;e!==null;)r0(e,t,a),e=e.sibling}function r0(e,t,a){switch(e.tag){case 26:Us(e,t,a),e.flags&Il&&e.memoizedState!==null&&ry(a,wn,e.memoizedState,e.memoizedProps);break;case 5:Us(e,t,a);break;case 3:case 4:var i=wn;wn=$i(e.stateNode.containerInfo),Us(e,t,a),wn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=Il,Il=16777216,Us(e,t,a),Il=i):Us(e,t,a));break;default:Us(e,t,a)}}function i0(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 Zl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];wt=i,c0(i,e)}i0(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)o0(e),e=e.sibling}function o0(e){switch(e.tag){case 0:case 11:case 15:Zl(e),e.flags&2048&&wa(9,e,e.return);break;case 3:Zl(e);break;case 12:Zl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Mi(e)):Zl(e);break;default:Zl(e)}}function Mi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var i=t[a];wt=i,c0(i,e)}i0(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:wa(8,t,t.return),Mi(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,Mi(t));break;default:Mi(t)}e=e.sibling}}function c0(e,t){for(;wt!==null;){var a=wt;switch(a.tag){case 0:case 11:case 15:wa(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var i=a.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Dl(a.memoizedState.cache)}if(i=a.child,i!==null)i.return=a,wt=i;else e:for(a=e;wt!==null;){i=wt;var c=i.sibling,d=i.return;if(Wh(i),i===a){wt=null;break e}if(c!==null){c.return=d,wt=c;break e}wt=d}}}var Sv={getCacheForType:function(e){var t=Mt(xt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Mt(xt).controller.signal}},jv=typeof WeakMap=="function"?WeakMap:Map,Qe=0,at=null,Be=null,ze=0,Ze=0,Pt=null,Aa=!1,Hs=!1,gu=!1,na=0,dt=0,Ca=0,as=0,bu=0,Wt=0,Vs=0,Jl=null,Yt=null,vu=!1,Ri=0,u0=0,Ti=1/0,qi=null,ka=null,St=0,Ea=null,$s=null,aa=0,yu=0,Su=null,d0=null,Pl=0,ju=null;function en(){return(Qe&2)!==0&&ze!==0?ze&-ze:q.T!==null?Eu():yl()}function f0(){if(Wt===0)if((ze&536870912)===0||He){var e=Hn;Hn<<=1,(Hn&3932160)===0&&(Hn=262144),Wt=e}else Wt=536870912;return e=Zt.current,e!==null&&(e.flags|=32),Wt}function Xt(e,t,a){(e===at&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)&&(Gs(e,0),Ma(e,ze,Wt,!1)),jn(e,a),((Qe&2)===0||e!==at)&&(e===at&&((Qe&2)===0&&(as|=a),dt===4&&Ma(e,ze,Wt,!1)),On(e))}function m0(e,t,a){if((Qe&6)!==0)throw Error(o(327));var i=!a&&(t&127)===0&&(t&e.expiredLanes)===0||Mn(e,t),c=i?Av(e,t):wu(e,t,!0),d=i;do{if(c===0){Hs&&!i&&Ma(e,t,0,!1);break}else{if(a=e.current.alternate,d&&!Nv(a)){c=wu(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 A=e;c=Jl;var D=A.current.memoizedState.isDehydrated;if(D&&(Gs(A,y).flags|=256),y=wu(A,y,!1),y!==2){if(gu&&!D){A.errorRecoveryDisabledLanes|=d,as|=d,c=4;break e}d=Yt,Yt=c,d!==null&&(Yt===null?Yt=d:Yt.push.apply(Yt,d))}c=y}if(d=!1,c!==2)continue}}if(c===1){Gs(e,0),Ma(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:Ma(i,t,Wt,!Aa);break e;case 2:Yt=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=Ri+300-le(),10<c)){if(Ma(i,t,Wt,!Aa),ms(i,0,!0)!==0)break e;aa=t,i.timeoutHandle=F0(h0.bind(null,i,a,Yt,qi,vu,t,Wt,as,Vs,Aa,d,"Throttled",-0,0),c);break e}h0(i,a,Yt,qi,vu,t,Wt,as,Vs,Aa,d,null,-0,0)}}break}while(!0);On(e)}function h0(e,t,a,i,c,d,y,A,D,Y,W,ae,Q,I){if(e.timeoutHandle=-1,ae=t.subtreeFlags,ae&8192||(ae&16785408)===16785408){ae={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:$n},r0(t,d,ae);var be=(d&62914560)===d?Ri-le():(d&4194048)===d?u0-le():0;if(be=iy(ae,be),be!==null){aa=d,e.cancelPendingCommit=be(j0.bind(null,e,t,d,a,i,c,y,A,D,W,ae,null,Q,I)),Ma(e,d,y,!Y);return}}j0(e,t,d,a,i,c,y,A,D)}function Nv(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var i=0;i<a.length;i++){var c=a[i],d=c.getSnapshot;c=c.value;try{if(!Kt(d(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ma(e,t,a,i){t&=~bu,t&=~as,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var d=31-Dt(c),y=1<<d;i[d]=-1,c&=~y}a!==0&&Ha(e,a,t)}function Di(){return(Qe&6)===0?(Wl(0),!1):!0}function Nu(){if(Be!==null){if(Ze===0)var e=Be.return;else e=Be,Xn=Ka=null,Uc(e),Ds=null,Ol=0,e=Be;for(;e!==null;)Yh(e.alternate,e),e=e.return;Be=null}}function Gs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Gv(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),aa=0,Nu(),at=e,Be=a=Fn(e.current,null),ze=t,Ze=0,Pt=null,Aa=!1,Hs=Mn(e,t),gu=!1,Vs=Wt=bu=as=Ca=dt=0,Yt=Jl=null,vu=!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-Dt(i),d=1<<c;t|=e[c],i&=~d}return na=t,ei(),a}function p0(e,t){Ee=null,q.H=Gl,t===qs||t===oi?(t=Tm(),Ze=3):t===kc?(t=Tm(),Ze=4):Ze=t===tu?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Pt=t,Be===null&&(dt=1,ji(e,dn(t,e.current)))}function x0(){var e=Zt.current;return e===null?!0:(ze&4194048)===ze?pn===null:(ze&62914560)===ze||(ze&536870912)!==0?e===pn:!1}function g0(){var e=q.H;return q.H=Gl,e===null?Gl:e}function b0(){var e=q.A;return q.A=Sv,e}function _i(){dt=4,Aa||(ze&4194048)!==ze&&Zt.current!==null||(Hs=!0),(Ca&134217727)===0&&(as&134217727)===0||at===null||Ma(at,ze,Wt,!1)}function wu(e,t,a){var i=Qe;Qe|=2;var c=g0(),d=b0();(at!==e||ze!==t)&&(qi=null,Gs(e,t)),t=!1;var y=dt;e:do try{if(Ze!==0&&Be!==null){var A=Be,D=Pt;switch(Ze){case 8:Nu(),y=6;break e;case 3:case 2:case 9:case 6:Zt.current===null&&(t=!0);var Y=Ze;if(Ze=0,Pt=null,Fs(e,A,D,Y),a&&Hs){y=0;break e}break;default:Y=Ze,Ze=0,Pt=null,Fs(e,A,D,Y)}}wv(),y=dt;break}catch(W){p0(e,W)}while(!0);return t&&e.shellSuspendCounter++,Xn=Ka=null,Qe=i,q.H=c,q.A=d,Be===null&&(at=null,ze=0,ei()),y}function wv(){for(;Be!==null;)v0(Be)}function Av(e,t){var a=Qe;Qe|=2;var i=g0(),c=b0();at!==e||ze!==t?(qi=null,Ti=le()+500,Gs(e,t)):Hs=Mn(e,t);e:do try{if(Ze!==0&&Be!==null){t=Be;var d=Pt;t:switch(Ze){case 1:Ze=0,Pt=null,Fs(e,t,d,1);break;case 2:case 9:if(Mm(d)){Ze=0,Pt=null,y0(t);break}t=function(){Ze!==2&&Ze!==9||at!==e||(Ze=7),On(e)},d.then(t,t);break e;case 3:Ze=7;break e;case 4:Ze=5;break e;case 7:Mm(d)?(Ze=0,Pt=null,y0(t)):(Ze=0,Pt=null,Fs(e,t,d,7));break;case 5:var y=null;switch(Be.tag){case 26:y=Be.memoizedState;case 5:case 27:var A=Be;if(y?lp(y):A.stateNode.complete){Ze=0,Pt=null;var D=A.sibling;if(D!==null)Be=D;else{var Y=A.return;Y!==null?(Be=Y,Oi(Y)):Be=null}break t}}Ze=0,Pt=null,Fs(e,t,d,5);break;case 6:Ze=0,Pt=null,Fs(e,t,d,6);break;case 8:Nu(),dt=6;break e;default:throw Error(o(462))}}Cv();break}catch(W){p0(e,W)}while(!0);return Xn=Ka=null,q.H=i,q.A=c,Qe=a,Be!==null?0:(at=null,ze=0,ei(),dt)}function Cv(){for(;Be!==null&&!Ce();)v0(Be)}function v0(e){var t=Gh(e.alternate,e,na);e.memoizedProps=e.pendingProps,t===null?Oi(e):Be=t}function y0(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Lh(a,t,t.pendingProps,t.type,void 0,ze);break;case 11:t=Lh(a,t,t.pendingProps,t.type.render,t.ref,ze);break;case 5:Uc(t);default:Yh(a,t),t=Be=bm(t,na),t=Gh(a,t,na)}e.memoizedProps=e.pendingProps,t===null?Oi(e):Be=t}function Fs(e,t,a,i){Xn=Ka=null,Uc(t),Ds=null,Ol=0;var c=t.return;try{if(hv(e,c,t,a,ze)){dt=1,ji(e,dn(a,e.current)),Be=null;return}}catch(d){if(c!==null)throw Be=c,d;dt=1,ji(e,dn(a,e.current)),Be=null;return}t.flags&32768?(He||i===1?e=!0:Hs||(ze&536870912)!==0?e=!1:(Aa=e=!0,(i===2||i===9||i===3||i===6)&&(i=Zt.current,i!==null&&i.tag===13&&(i.flags|=16384))),S0(t,e)):Oi(t)}function Oi(e){var t=e;do{if((t.flags&32768)!==0){S0(t,Aa);return}e=t.return;var a=gv(t.alternate,t,na);if(a!==null){Be=a;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);dt===0&&(dt=5)}function S0(e,t){do{var a=bv(e.alternate,e);if(a!==null){a.flags&=32767,Be=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Be=e;return}Be=e=a}while(e!==null);dt=6,Be=null}function j0(e,t,a,i,c,d,y,A,D){e.cancelPendingCommit=null;do Bi();while(St!==0);if((Qe&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(d=t.lanes|t.childLanes,d|=fc,xl(e,a,d,y,A,D),e===at&&(Be=at=null,ze=0),$s=t,Ea=e,aa=a,yu=d,Su=c,d0=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Rv(nt,function(){return k0(),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=Qe,Qe|=4;try{vv(e,t,a)}finally{Qe=y,H.p=c,q.T=i}}St=1,N0(),w0(),A0()}}function N0(){if(St===1){St=0;var e=Ea,t=$s,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=q.T,q.T=null;var i=H.p;H.p=2;var c=Qe;Qe|=4;try{a0(t,e);var d=Bu,y=cm(e.containerInfo),A=d.focusedElem,D=d.selectionRange;if(y!==A&&A&&A.ownerDocument&&om(A.ownerDocument.documentElement,A)){if(D!==null&&ic(A)){var Y=D.start,W=D.end;if(W===void 0&&(W=Y),"selectionStart"in A)A.selectionStart=Y,A.selectionEnd=Math.min(W,A.value.length);else{var ae=A.ownerDocument||document,Q=ae&&ae.defaultView||window;if(Q.getSelection){var I=Q.getSelection(),be=A.textContent.length,we=Math.min(D.start,be),tt=D.end===void 0?we:Math.min(D.end,be);!I.extend&&we>tt&&(y=tt,tt=we,we=y);var U=im(A,we),B=im(A,tt);if(U&&B&&(I.rangeCount!==1||I.anchorNode!==U.node||I.anchorOffset!==U.offset||I.focusNode!==B.node||I.focusOffset!==B.offset)){var F=ae.createRange();F.setStart(U.node,U.offset),I.removeAllRanges(),we>tt?(I.addRange(F),I.extend(B.node,B.offset)):(F.setEnd(B.node,B.offset),I.addRange(F))}}}}for(ae=[],I=A;I=I.parentNode;)I.nodeType===1&&ae.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ae.length;A++){var ne=ae[A];ne.element.scrollLeft=ne.left,ne.element.scrollTop=ne.top}}Ki=!!Ou,Bu=Ou=null}finally{Qe=c,H.p=i,q.T=a}}e.current=t,St=2}}function w0(){if(St===2){St=0;var e=Ea,t=$s,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=q.T,q.T=null;var i=H.p;H.p=2;var c=Qe;Qe|=4;try{Ph(e,t.alternate,t)}finally{Qe=c,H.p=i,q.T=a}}St=3}}function A0(){if(St===4||St===3){St=0,Pe();var e=Ea,t=$s,a=aa,i=d0;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?St=5:(St=0,$s=Ea=null,C0(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(ka=null),vl(a),t=t.stateNode,jt&&typeof jt.onCommitFiberRoot=="function")try{jt.onCommitFiberRoot(Sn,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 A=i[y];d(A.value,{componentStack:A.stack})}}finally{q.T=t,H.p=c}}(aa&3)!==0&&Bi(),On(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===ju?Pl++:(Pl=0,ju=e):Pl=0,Wl(0)}}function C0(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Dl(t)))}function Bi(){return N0(),w0(),A0(),k0()}function k0(){if(St!==5)return!1;var e=Ea,t=yu;yu=0;var a=vl(aa),i=q.T,c=H.p;try{H.p=32>a?32:a,q.T=null,a=Su,Su=null;var d=Ea,y=aa;if(St=0,$s=Ea=null,aa=0,(Qe&6)!==0)throw Error(o(331));var A=Qe;if(Qe|=4,o0(d.current),l0(d,d.current,y,a),Qe=A,Wl(0,!1),jt&&typeof jt.onPostCommitFiberRoot=="function")try{jt.onPostCommitFiberRoot(Sn,d)}catch{}return!0}finally{H.p=c,q.T=i,C0(e,t)}}function E0(e,t,a){t=dn(a,t),t=eu(e.stateNode,t,2),e=Sa(e,t,2),e!==null&&(jn(e,2),On(e))}function Je(e,t,a){if(e.tag===3)E0(e,e,a);else for(;t!==null;){if(t.tag===3){E0(t,e,a);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(ka===null||!ka.has(i))){e=dn(a,e),a=Mh(2),i=Sa(t,a,2),i!==null&&(Rh(a,i,t,e),jn(i,2),On(i));break}}t=t.return}}function Au(e,t,a){var i=e.pingCache;if(i===null){i=e.pingCache=new jv;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(a)||(gu=!0,c.add(a),e=kv.bind(null,e,t,a),t.then(e,e))}function kv(e,t,a){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,at===e&&(ze&a)===a&&(dt===4||dt===3&&(ze&62914560)===ze&&300>le()-Ri?(Qe&2)===0&&Gs(e,0):bu|=a,Vs===ze&&(Vs=0)),On(e)}function M0(e,t){t===0&&(t=pl()),e=Ya(e,t),e!==null&&(jn(e,t),On(e))}function Ev(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),M0(e,a)}function Mv(e,t){var a=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),M0(e,a)}function Rv(e,t){return me(e,t)}var Li=null,Ys=null,Cu=!1,zi=!1,ku=!1,Ra=0;function On(e){e!==Ys&&e.next===null&&(Ys===null?Li=Ys=e:Ys=Ys.next=e),zi=!0,Cu||(Cu=!0,qv())}function Wl(e,t){if(!ku&&zi){ku=!0;do for(var a=!1,i=Li;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var d=0;else{var y=i.suspendedLanes,A=i.pingedLanes;d=(1<<31-Dt(42|e)+1)-1,d&=c&~(y&~A),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,D0(i,d))}else d=ze,d=ms(i,i===at?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(d&3)===0||Mn(i,d)||(a=!0,D0(i,d));i=i.next}while(a);ku=!1}}function Tv(){R0()}function R0(){zi=Cu=!1;var e=0;Ra!==0&&$v()&&(e=Ra);for(var t=le(),a=null,i=Li;i!==null;){var c=i.next,d=T0(i,t);d===0?(i.next=null,a===null?Li=c:a.next=c,c===null&&(Ys=a)):(a=i,(e!==0||(d&3)!==0)&&(zi=!0)),i=c}St!==0&&St!==5||Wl(e),Ra!==0&&(Ra=0)}function T0(e,t){for(var a=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,d=e.pendingLanes&-62914561;0<d;){var y=31-Dt(d),A=1<<y,D=c[y];D===-1?((A&a)===0||(A&i)!==0)&&(c[y]=Fo(A,t)):D<=t&&(e.expiredLanes|=A),d&=~A}if(t=at,a=ze,a=ms(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,a===0||e===t&&(Ze===2||Ze===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&Ae(i),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||Mn(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(i!==null&&Ae(i),vl(a)){case 2:case 8:a=Lt;break;case 32:a=nt;break;case 268435456:a=ln;break;default:a=nt}return i=q0.bind(null,e),a=me(a,i),e.callbackPriority=t,e.callbackNode=a,t}return i!==null&&i!==null&&Ae(i),e.callbackPriority=2,e.callbackNode=null,2}function q0(e,t){if(St!==0&&St!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Bi()&&e.callbackNode!==a)return null;var i=ze;return i=ms(e,e===at?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(m0(e,i,t),T0(e,le()),e.callbackNode!=null&&e.callbackNode===a?q0.bind(null,e):null)}function D0(e,t){if(Bi())return null;m0(e,t,!0)}function qv(){Fv(function(){(Qe&6)!==0?me(Oe,Tv):R0()})}function Eu(){if(Ra===0){var e=Rs;e===0&&(e=Ua,Ua<<=1,(Ua&261888)===0&&(Ua=256)),Ra=e}return Ra}function _0(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Xr(""+e)}function O0(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function Dv(e,t,a,i,c){if(t==="submit"&&a&&a.stateNode===c){var d=_0((c[Re]||null).action),y=i.submitter;y&&(t=(t=y[Re]||null)?_0(t.formAction):y.getAttribute("formAction"),t!==null&&(d=t,y=null));var A=new Zr("action","action",null,i,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ra!==0){var D=y?O0(c,y):new FormData(c);Kc(a,{pending:!0,data:D,method:c.method,action:d},null,D)}}else typeof d=="function"&&(A.preventDefault(),D=y?O0(c,y):new FormData(c),Kc(a,{pending:!0,data:D,method:c.method,action:d},d,D))},currentTarget:c}]})}}for(var Mu=0;Mu<dc.length;Mu++){var Ru=dc[Mu],_v=Ru.toLowerCase(),Ov=Ru[0].toUpperCase()+Ru.slice(1);Nn(_v,"on"+Ov)}Nn(fm,"onAnimationEnd"),Nn(mm,"onAnimationIteration"),Nn(hm,"onAnimationStart"),Nn("dblclick","onDoubleClick"),Nn("focusin","onFocus"),Nn("focusout","onBlur"),Nn(Jb,"onTransitionRun"),Nn(Pb,"onTransitionStart"),Nn(Wb,"onTransitionCancel"),Nn(pm,"onTransitionEnd"),xs("onMouseEnter",["mouseout","mouseover"]),xs("onMouseLeave",["mouseout","mouseover"]),xs("onPointerEnter",["pointerout","pointerover"]),xs("onPointerLeave",["pointerout","pointerover"]),Va("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Va("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Va("onBeforeInput",["compositionend","keypress","textInput","paste"]),Va("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var er="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(" "),Bv=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(er));function B0(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var i=e[a],c=i.event;i=i.listeners;e:{var d=void 0;if(t)for(var y=i.length-1;0<=y;y--){var A=i[y],D=A.instance,Y=A.currentTarget;if(A=A.listener,D!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(W){Wr(W)}c.currentTarget=null,d=D}else for(y=0;y<i.length;y++){if(A=i[y],D=A.instance,Y=A.currentTarget,A=A.listener,D!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=Y;try{d(c)}catch(W){Wr(W)}c.currentTarget=null,d=D}}}}function Le(e,t){var a=t[Te];a===void 0&&(a=t[Te]=new Set);var i=e+"__bubble";a.has(i)||(L0(t,e,2,!1),a.add(i))}function Tu(e,t,a){var i=0;t&&(i|=4),L0(a,e,i,t)}var Ui="_reactListening"+Math.random().toString(36).slice(2);function qu(e){if(!e[Ui]){e[Ui]=!0,Rf.forEach(function(a){a!=="selectionchange"&&(Bv.has(a)||Tu(a,!1,e),Tu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ui]||(t[Ui]=!0,Tu("selectionchange",!1,t))}}function L0(e,t,a,i){switch(fp(t)){case 2:var c=uy;break;case 8:c=dy;break;default:c=Qu}a=c.bind(null,t,a,e),c=void 0,!Po||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,a,{capture:!0,passive:c}):e.addEventListener(t,a,!0):c!==void 0?e.addEventListener(t,a,{passive:c}):e.addEventListener(t,a,!1)}function Du(e,t,a,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 A=i.stateNode.containerInfo;if(A===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(;A!==null;){if(y=rn(A),y===null)return;if(D=y.tag,D===5||D===6||D===26||D===27){i=d=y;continue e}A=A.parentNode}}i=i.return}$f(function(){var Y=d,W=Zo(a),ae=[];e:{var Q=xm.get(e);if(Q!==void 0){var I=Zr,be=e;switch(e){case"keypress":if(Kr(a)===0)break e;case"keydown":case"keyup":I=Mb;break;case"focusin":be="focus",I=nc;break;case"focusout":be="blur",I=nc;break;case"beforeblur":case"afterblur":I=nc;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":I=Yf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":I=gb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":I=qb;break;case fm:case mm:case hm:I=yb;break;case pm:I=_b;break;case"scroll":case"scrollend":I=pb;break;case"wheel":I=Bb;break;case"copy":case"cut":case"paste":I=jb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":I=Qf;break;case"toggle":case"beforetoggle":I=zb}var we=(t&4)!==0,tt=!we&&(e==="scroll"||e==="scrollend"),U=we?Q!==null?Q+"Capture":null:Q;we=[];for(var B=Y,F;B!==null;){var ne=B;if(F=ne.stateNode,ne=ne.tag,ne!==5&&ne!==26&&ne!==27||F===null||U===null||(ne=jl(B,U),ne!=null&&we.push(tr(B,ne,F))),tt)break;B=B.return}0<we.length&&(Q=new I(Q,be,null,a,W),ae.push({event:Q,listeners:we}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",I=e==="mouseout"||e==="pointerout",Q&&a!==Io&&(be=a.relatedTarget||a.fromElement)&&(rn(be)||be[Xe]))break e;if((I||Q)&&(Q=W.window===W?W:(Q=W.ownerDocument)?Q.defaultView||Q.parentWindow:window,I?(be=a.relatedTarget||a.toElement,I=Y,be=be?rn(be):null,be!==null&&(tt=f(be),we=be.tag,be!==tt||we!==5&&we!==27&&we!==6)&&(be=null)):(I=null,be=Y),I!==be)){if(we=Yf,ne="onMouseLeave",U="onMouseEnter",B="mouse",(e==="pointerout"||e==="pointerover")&&(we=Qf,ne="onPointerLeave",U="onPointerEnter",B="pointer"),tt=I==null?Q:Sl(I),F=be==null?Q:Sl(be),Q=new we(ne,B+"leave",I,a,W),Q.target=tt,Q.relatedTarget=F,ne=null,rn(W)===Y&&(we=new we(U,B+"enter",be,a,W),we.target=F,we.relatedTarget=tt,ne=we),tt=ne,I&&be)t:{for(we=Lv,U=I,B=be,F=0,ne=U;ne;ne=we(ne))F++;ne=0;for(var Ne=B;Ne;Ne=we(Ne))ne++;for(;0<F-ne;)U=we(U),F--;for(;0<ne-F;)B=we(B),ne--;for(;F--;){if(U===B||B!==null&&U===B.alternate){we=U;break t}U=we(U),B=we(B)}we=null}else we=null;I!==null&&z0(ae,Q,I,we,!1),be!==null&&tt!==null&&z0(ae,tt,be,we,!0)}}e:{if(Q=Y?Sl(Y):window,I=Q.nodeName&&Q.nodeName.toLowerCase(),I==="select"||I==="input"&&Q.type==="file")var $e=tm;else if(Wf(Q))if(nm)$e=Kb;else{$e=Xb;var Se=Yb}else I=Q.nodeName,!I||I.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?Y&&Ko(Y.elementType)&&($e=tm):$e=Qb;if($e&&($e=$e(e,Y))){em(ae,$e,a,W);break e}Se&&Se(e,Q,Y),e==="focusout"&&Y&&Q.type==="number"&&Y.memoizedProps.value!=null&&Qo(Q,"number",Q.value)}switch(Se=Y?Sl(Y):window,e){case"focusin":(Wf(Se)||Se.contentEditable==="true")&&(js=Se,oc=Y,Rl=null);break;case"focusout":Rl=oc=js=null;break;case"mousedown":cc=!0;break;case"contextmenu":case"mouseup":case"dragend":cc=!1,um(ae,a,W);break;case"selectionchange":if(Zb)break;case"keydown":case"keyup":um(ae,a,W)}var qe;if(sc)e:{switch(e){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else Ss?Jf(e,a)&&(Ue="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Ue="onCompositionStart");Ue&&(Kf&&a.locale!=="ko"&&(Ss||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&Ss&&(qe=Gf()):(ha=W,Wo="value"in ha?ha.value:ha.textContent,Ss=!0)),Se=Hi(Y,Ue),0<Se.length&&(Ue=new Xf(Ue,e,null,a,W),ae.push({event:Ue,listeners:Se}),qe?Ue.data=qe:(qe=Pf(a),qe!==null&&(Ue.data=qe)))),(qe=Hb?Vb(e,a):$b(e,a))&&(Ue=Hi(Y,"onBeforeInput"),0<Ue.length&&(Se=new Xf("onBeforeInput","beforeinput",null,a,W),ae.push({event:Se,listeners:Ue}),Se.data=qe)),Dv(ae,e,Y,a,W)}B0(ae,t)})}function tr(e,t,a){return{instance:e,listener:t,currentTarget:a}}function Hi(e,t){for(var a=t+"Capture",i=[];e!==null;){var c=e,d=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||d===null||(c=jl(e,a),c!=null&&i.unshift(tr(e,c,d)),c=jl(e,t),c!=null&&i.push(tr(e,c,d))),e.tag===3)return i;e=e.return}return[]}function Lv(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function z0(e,t,a,i,c){for(var d=t._reactName,y=[];a!==null&&a!==i;){var A=a,D=A.alternate,Y=A.stateNode;if(A=A.tag,D!==null&&D===i)break;A!==5&&A!==26&&A!==27||Y===null||(D=Y,c?(Y=jl(a,d),Y!=null&&y.unshift(tr(a,Y,D))):c||(Y=jl(a,d),Y!=null&&y.push(tr(a,Y,D)))),a=a.return}y.length!==0&&e.push({event:t,listeners:y})}var zv=/\r\n?/g,Uv=/\u0000|\uFFFD/g;function U0(e){return(typeof e=="string"?e:""+e).replace(zv,`
|
||
`).replace(Uv,"")}function H0(e,t){return t=U0(t),U0(e)===t}function et(e,t,a,i,c,d){switch(a){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||bs(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&bs(e,""+i);break;case"className":Fr(e,"class",i);break;case"tabIndex":Fr(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Fr(e,a,i);break;case"style":Hf(e,i,d);break;case"data":if(t!=="object"){Fr(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(a);break}i=Xr(""+i),e.setAttribute(a,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="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(a);break}i=Xr(""+i),e.setAttribute(a,i);break;case"onClick":i!=null&&(e.onclick=$n);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(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}a=Xr(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""+i):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":i===!0?e.setAttribute(a,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(a,i):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(a,i):e.removeAttribute(a);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(a):e.setAttribute(a,i);break;case"popover":Le("beforetoggle",e),Le("toggle",e),Gr(e,"popover",i);break;case"xlinkActuate":Vn(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":Vn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":Vn(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":Vn(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":Vn(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":Vn(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":Vn(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":Vn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":Vn(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":Gr(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=mb.get(a)||a,Gr(e,a,i))}}function _u(e,t,a,i,c,d){switch(a){case"style":Hf(e,i,d);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(a=i.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof i=="string"?bs(e,i):(typeof i=="number"||typeof i=="bigint")&&bs(e,""+i);break;case"onScroll":i!=null&&Le("scroll",e);break;case"onScrollEnd":i!=null&&Le("scrollend",e);break;case"onClick":i!=null&&(e.onclick=$n);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Tf.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),d=e[Re]||null,d=d!=null?d[a]:null,typeof d=="function"&&e.removeEventListener(t,d,c),typeof i=="function")){typeof d!="function"&&d!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,i,c);break e}a in e?e[a]=i:i===!0?e.setAttribute(a,""):Gr(e,a,i)}}}function Tt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Le("error",e),Le("load",e);var i=!1,c=!1,d;for(d in a)if(a.hasOwnProperty(d)){var y=a[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,a,null)}}c&&et(e,t,"srcSet",a.srcSet,a,null),i&&et(e,t,"src",a.src,a,null);return;case"input":Le("invalid",e);var A=d=y=c=null,D=null,Y=null;for(i in a)if(a.hasOwnProperty(i)){var W=a[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":A=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(o(137,t));break;default:et(e,t,i,W,a,null)}}Bf(e,d,A,D,Y,y,c,!1);return;case"select":Le("invalid",e),i=y=d=null;for(c in a)if(a.hasOwnProperty(c)&&(A=a[c],A!=null))switch(c){case"value":d=A;break;case"defaultValue":y=A;break;case"multiple":i=A;default:et(e,t,c,A,a,null)}t=d,a=y,e.multiple=!!i,t!=null?gs(e,!!i,t,!1):a!=null&&gs(e,!!i,a,!0);return;case"textarea":Le("invalid",e),d=c=i=null;for(y in a)if(a.hasOwnProperty(y)&&(A=a[y],A!=null))switch(y){case"value":i=A;break;case"defaultValue":c=A;break;case"children":d=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:et(e,t,y,A,a,null)}zf(e,i,c,d);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(i=a[D],i!=null))switch(D){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:et(e,t,D,i,a,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<er.length;i++)Le(er[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 a)if(a.hasOwnProperty(Y)&&(i=a[Y],i!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:et(e,t,Y,i,a,null)}return;default:if(Ko(t)){for(W in a)a.hasOwnProperty(W)&&(i=a[W],i!==void 0&&_u(e,t,W,i,a,void 0));return}}for(A in a)a.hasOwnProperty(A)&&(i=a[A],i!=null&&et(e,t,A,i,a,null))}function Hv(e,t,a,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,d=null,y=null,A=null,D=null,Y=null,W=null;for(I in a){var ae=a[I];if(a.hasOwnProperty(I)&&ae!=null)switch(I){case"checked":break;case"value":break;case"defaultValue":D=ae;default:i.hasOwnProperty(I)||et(e,t,I,null,i,ae)}}for(var Q in i){var I=i[Q];if(ae=a[Q],i.hasOwnProperty(Q)&&(I!=null||ae!=null))switch(Q){case"type":d=I;break;case"name":c=I;break;case"checked":Y=I;break;case"defaultChecked":W=I;break;case"value":y=I;break;case"defaultValue":A=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:I!==ae&&et(e,t,Q,I,i,ae)}}Xo(e,y,A,D,Y,W,d,c);return;case"select":I=y=A=Q=null;for(d in a)if(D=a[d],a.hasOwnProperty(d)&&D!=null)switch(d){case"value":break;case"multiple":I=D;default:i.hasOwnProperty(d)||et(e,t,d,null,i,D)}for(c in i)if(d=i[c],D=a[c],i.hasOwnProperty(c)&&(d!=null||D!=null))switch(c){case"value":Q=d;break;case"defaultValue":A=d;break;case"multiple":y=d;default:d!==D&&et(e,t,c,d,i,D)}t=A,a=y,i=I,Q!=null?gs(e,!!a,Q,!1):!!i!=!!a&&(t!=null?gs(e,!!a,t,!0):gs(e,!!a,a?[]:"",!1));return;case"textarea":I=Q=null;for(A in a)if(c=a[A],a.hasOwnProperty(A)&&c!=null&&!i.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:et(e,t,A,null,i,c)}for(y in i)if(c=i[y],d=a[y],i.hasOwnProperty(y)&&(c!=null||d!=null))switch(y){case"value":Q=c;break;case"defaultValue":I=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==d&&et(e,t,y,c,i,d)}Lf(e,Q,I);return;case"option":for(var be in a)if(Q=a[be],a.hasOwnProperty(be)&&Q!=null&&!i.hasOwnProperty(be))switch(be){case"selected":e.selected=!1;break;default:et(e,t,be,null,i,Q)}for(D in i)if(Q=i[D],I=a[D],i.hasOwnProperty(D)&&Q!==I&&(Q!=null||I!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:et(e,t,D,Q,i,I)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var we in a)Q=a[we],a.hasOwnProperty(we)&&Q!=null&&!i.hasOwnProperty(we)&&et(e,t,we,null,i,Q);for(Y in i)if(Q=i[Y],I=a[Y],i.hasOwnProperty(Y)&&Q!==I&&(Q!=null||I!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:et(e,t,Y,Q,i,I)}return;default:if(Ko(t)){for(var tt in a)Q=a[tt],a.hasOwnProperty(tt)&&Q!==void 0&&!i.hasOwnProperty(tt)&&_u(e,t,tt,void 0,i,Q);for(W in i)Q=i[W],I=a[W],!i.hasOwnProperty(W)||Q===I||Q===void 0&&I===void 0||_u(e,t,W,Q,i,I);return}}for(var U in a)Q=a[U],a.hasOwnProperty(U)&&Q!=null&&!i.hasOwnProperty(U)&&et(e,t,U,null,i,Q);for(ae in i)Q=i[ae],I=a[ae],!i.hasOwnProperty(ae)||Q===I||Q==null&&I==null||et(e,t,ae,Q,i,I)}function V0(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Vv(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),i=0;i<a.length;i++){var c=a[i],d=c.transferSize,y=c.initiatorType,A=c.duration;if(d&&A&&V0(y)){for(y=0,A=c.responseEnd,i+=1;i<a.length;i++){var D=a[i],Y=D.startTime;if(Y>A)break;var W=D.transferSize,ae=D.initiatorType;W&&V0(ae)&&(D=D.responseEnd,y+=W*(D<A?1:(A-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 Ou=null,Bu=null;function Vi(e){return e.nodeType===9?e:e.ownerDocument}function $0(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 G0(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 Lu(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 zu=null;function $v(){var e=window.event;return e&&e.type==="popstate"?e===zu?!1:(zu=e,!0):(zu=null,!1)}var F0=typeof setTimeout=="function"?setTimeout:void 0,Gv=typeof clearTimeout=="function"?clearTimeout:void 0,Y0=typeof Promise=="function"?Promise:void 0,Fv=typeof queueMicrotask=="function"?queueMicrotask:typeof Y0<"u"?function(e){return Y0.resolve(null).then(e).catch(Yv)}:F0;function Yv(e){setTimeout(function(){throw e})}function Ta(e){return e==="head"}function X0(e,t){var a=t,i=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(i===0){e.removeChild(c),Is(t);return}i--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")i++;else if(a==="html")nr(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,nr(a);for(var d=a.firstChild;d;){var y=d.nextSibling,A=d.nodeName;d[Tn]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=y}}else a==="body"&&nr(e.ownerDocument.body);a=c}while(a);Is(t)}function Q0(e,t){var a=e;e=0;do{var i=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),i&&i.nodeType===8)if(a=i.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=i}while(a)}function Uu(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Uu(a),mt(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Xv(e,t,a,i){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[Tn])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=xn(e.nextSibling),e===null)break}return null}function Qv(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=xn(e.nextSibling),e===null))return null;return e}function K0(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=xn(e.nextSibling),e===null))return null;return e}function Hu(e){return e.data==="$?"||e.data==="$~"}function Vu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Kv(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var i=function(){t(),a.removeEventListener("DOMContentLoaded",i)};a.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function xn(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 $u=null;function I0(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return xn(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Z0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function J0(e,t,a){switch(t=Vi(a),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function nr(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);mt(e)}var gn=new Map,P0=new Set;function $i(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var sa=H.d;H.d={f:Iv,r:Zv,D:Jv,C:Pv,L:Wv,m:ey,X:ny,S:ty,M:ay};function Iv(){var e=sa.f(),t=Di();return e||t}function Zv(e){var t=hs(e);t!==null&&t.tag===5&&t.type==="form"?ph(t):sa.r(e)}var Xs=typeof document>"u"?null:document;function W0(e,t,a){var i=Xs;if(i&&typeof t=="string"&&t){var c=cn(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),P0.has(c)||(P0.add(c),e={rel:e,crossOrigin:a,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Tt(t,"link",e),Nt(t),i.head.appendChild(t)))}}function Jv(e){sa.D(e),W0("dns-prefetch",e,null)}function Pv(e,t){sa.C(e,t),W0("preconnect",e,t)}function Wv(e,t,a){sa.L(e,t,a);var i=Xs;if(i&&e&&t){var c='link[rel="preload"][as="'+cn(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+cn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+cn(a.imageSizes)+'"]')):c+='[href="'+cn(e)+'"]';var d=c;switch(t){case"style":d=Qs(e);break;case"script":d=Ks(e)}gn.has(d)||(e=v({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),gn.set(d,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(ar(d))||t==="script"&&i.querySelector(sr(d))||(t=i.createElement("link"),Tt(t,"link",e),Nt(t),i.head.appendChild(t)))}}function ey(e,t){sa.m(e,t);var a=Xs;if(a&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+cn(i)+'"][href="'+cn(e)+'"]',d=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Ks(e)}if(!gn.has(d)&&(e=v({rel:"modulepreload",href:e},t),gn.set(d,e),a.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(sr(d)))return}i=a.createElement("link"),Tt(i,"link",e),Nt(i),a.head.appendChild(i)}}}function ty(e,t,a){sa.S(e,t,a);var i=Xs;if(i&&e){var c=ps(i).hoistableStyles,d=Qs(e);t=t||"default";var y=c.get(d);if(!y){var A={loading:0,preload:null};if(y=i.querySelector(ar(d)))A.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":t},a),(a=gn.get(d))&&Gu(e,a);var D=y=i.createElement("link");Nt(D),Tt(D,"link",e),D._p=new Promise(function(Y,W){D.onload=Y,D.onerror=W}),D.addEventListener("load",function(){A.loading|=1}),D.addEventListener("error",function(){A.loading|=2}),A.loading|=4,Gi(y,t,i)}y={type:"stylesheet",instance:y,count:1,state:A},c.set(d,y)}}}function ny(e,t){sa.X(e,t);var a=Xs;if(a&&e){var i=ps(a).hoistableScripts,c=Ks(e),d=i.get(c);d||(d=a.querySelector(sr(c)),d||(e=v({src:e,async:!0},t),(t=gn.get(c))&&Fu(e,t),d=a.createElement("script"),Nt(d),Tt(d,"link",e),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function ay(e,t){sa.M(e,t);var a=Xs;if(a&&e){var i=ps(a).hoistableScripts,c=Ks(e),d=i.get(c);d||(d=a.querySelector(sr(c)),d||(e=v({src:e,async:!0,type:"module"},t),(t=gn.get(c))&&Fu(e,t),d=a.createElement("script"),Nt(d),Tt(d,"link",e),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function ep(e,t,a,i){var c=(c=oe.current)?$i(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Qs(a.href),a=ps(c).hoistableStyles,i=a.get(t),i||(i={type:"style",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Qs(a.href);var d=ps(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(ar(e)))&&!d._p&&(y.instance=d,y.state.loading=5),gn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},gn.set(e,a),d||sy(c,e,a,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=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ks(a),a=ps(c).hoistableScripts,i=a.get(t),i||(i={type:"script",instance:null,count:0,state:null},a.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Qs(e){return'href="'+cn(e)+'"'}function ar(e){return'link[rel="stylesheet"]['+e+"]"}function tp(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function sy(e,t,a,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Tt(t,"link",a),Nt(t),e.head.appendChild(t))}function Ks(e){return'[src="'+cn(e)+'"]'}function sr(e){return"script[async]"+e}function np(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+cn(a.href)+'"]');if(i)return t.instance=i,Nt(i),i;var c=v({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Nt(i),Tt(i,"style",c),Gi(i,a.precedence,e),t.instance=i;case"stylesheet":c=Qs(a.href);var d=e.querySelector(ar(c));if(d)return t.state.loading|=4,t.instance=d,Nt(d),d;i=tp(a),(c=gn.get(c))&&Gu(i,c),d=(e.ownerDocument||e).createElement("link"),Nt(d);var y=d;return y._p=new Promise(function(A,D){y.onload=A,y.onerror=D}),Tt(d,"link",i),t.state.loading|=4,Gi(d,a.precedence,e),t.instance=d;case"script":return d=Ks(a.src),(c=e.querySelector(sr(d)))?(t.instance=c,Nt(c),c):(i=a,(c=gn.get(d))&&(i=v({},a),Fu(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),Nt(c),Tt(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,Gi(i,a.precedence,e));return t.instance}function Gi(e,t,a){for(var i=a.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 A=i[y];if(A.dataset.precedence===t)d=A;else if(d!==c)break}d?d.parentNode.insertBefore(e,d.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function Gu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Fu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Fi=null;function ap(e,t,a){if(Fi===null){var i=new Map,c=Fi=new Map;c.set(a,i)}else c=Fi,i=c.get(a),i||(i=new Map,c.set(a,i));if(i.has(e))return i;for(i.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var d=a[c];if(!(d[Tn]||d[pe]||e==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var y=d.getAttribute(t)||"";y=e+y;var A=i.get(y);A?A.push(d):i.set(y,[d])}}return i}function sp(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ly(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function lp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ry(e,t,a,i){if(a.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Qs(i.href),d=t.querySelector(ar(c));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Yi.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=d,Nt(d);return}d=t.ownerDocument||t,i=tp(i),(c=gn.get(c))&&Gu(i,c),d=d.createElement("link"),Nt(d);var y=d;y._p=new Promise(function(A,D){y.onload=A,y.onerror=D}),Tt(d,"link",i),a.instance=d}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Yi.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Yu=0;function iy(e,t){return e.stylesheets&&e.count===0&&Qi(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var i=setTimeout(function(){if(e.stylesheets&&Qi(e,e.stylesheets),e.unsuspend){var d=e.unsuspend;e.unsuspend=null,d()}},6e4+t);0<e.imgBytes&&Yu===0&&(Yu=62500*Vv());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Qi(e,e.stylesheets),e.unsuspend)){var d=e.unsuspend;e.unsuspend=null,d()}},(e.imgBytes>Yu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Yi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qi(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xi=null;function Qi(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xi=new Map,t.forEach(oy,e),Xi=null,Yi.call(e))}function oy(e,t){if(!(t.state.loading&4)){var a=Xi.get(e);if(a)var i=a.get(null);else{a=new Map,Xi.set(e,a);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")&&(a.set(y.dataset.precedence,y),i=y)}i&&a.set(null,i)}c=t.instance,y=c.getAttribute("data-precedence"),d=a.get(y)||i,d===i&&a.set(null,c),a.set(y,c),this.count++,i=Yi.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 lr={$$typeof:E,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function cy(e,t,a,i,c,d,y,A,D){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=st(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=st(0),this.hiddenUpdates=st(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 rp(e,t,a,i,c,d,y,A,D,Y,W,ae){return e=new cy(e,t,a,y,D,Y,W,ae,A),t=1,d===!0&&(t|=24),d=It(3,null,null,t),e.current=d,d.stateNode=e,t=wc(),t.refCount++,e.pooledCache=t,t.refCount++,d.memoizedState={element:i,isDehydrated:a,cache:t},Ec(d),e}function ip(e){return e?(e=As,e):As}function op(e,t,a,i,c,d){c=ip(c),i.context===null?i.context=c:i.pendingContext=c,i=ya(t),i.payload={element:a},d=d===void 0?null:d,d!==null&&(i.callback=d),a=Sa(e,i,t),a!==null&&(Xt(a,e,t),Ll(a,e,t))}function cp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Xu(e,t){cp(e,t),(e=e.alternate)&&cp(e,t)}function up(e){if(e.tag===13||e.tag===31){var t=Ya(e,67108864);t!==null&&Xt(t,e,67108864),Xu(e,67108864)}}function dp(e){if(e.tag===13||e.tag===31){var t=en();t=bl(t);var a=Ya(e,t);a!==null&&Xt(a,e,t),Xu(e,t)}}var Ki=!0;function uy(e,t,a,i){var c=q.T;q.T=null;var d=H.p;try{H.p=2,Qu(e,t,a,i)}finally{H.p=d,q.T=c}}function dy(e,t,a,i){var c=q.T;q.T=null;var d=H.p;try{H.p=8,Qu(e,t,a,i)}finally{H.p=d,q.T=c}}function Qu(e,t,a,i){if(Ki){var c=Ku(i);if(c===null)Du(e,t,i,Ii,a),mp(e,i);else if(my(c,e,t,a,i))i.stopPropagation();else if(mp(e,i),t&4&&-1<fy.indexOf(e)){for(;c!==null;){var d=hs(c);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var y=Ut(d.pendingLanes);if(y!==0){var A=d;for(A.pendingLanes|=2,A.entangledLanes|=2;y;){var D=1<<31-Dt(y);A.entanglements[1]|=D,y&=~D}On(d),(Qe&6)===0&&(Ti=le()+500,Wl(0))}}break;case 31:case 13:A=Ya(d,2),A!==null&&Xt(A,d,2),Di(),Xu(d,2)}if(d=Ku(i),d===null&&Du(e,t,i,Ii,a),d===c)break;c=d}c!==null&&i.stopPropagation()}else Du(e,t,i,null,a)}}function Ku(e){return e=Zo(e),Iu(e)}var Ii=null;function Iu(e){if(Ii=null,e=rn(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ii=e,null}function fp(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 Oe:return 2;case Lt:return 8;case nt:case fl:return 32;case ln:return 268435456;default:return 32}default:return 32}}var Zu=!1,qa=null,Da=null,_a=null,rr=new Map,ir=new Map,Oa=[],fy="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function mp(e,t){switch(e){case"focusin":case"focusout":qa=null;break;case"dragenter":case"dragleave":Da=null;break;case"mouseover":case"mouseout":_a=null;break;case"pointerover":case"pointerout":rr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ir.delete(t.pointerId)}}function or(e,t,a,i,c,d){return e===null||e.nativeEvent!==d?(e={blockedOn:t,domEventName:a,eventSystemFlags:i,nativeEvent:d,targetContainers:[c]},t!==null&&(t=hs(t),t!==null&&up(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function my(e,t,a,i,c){switch(t){case"focusin":return qa=or(qa,e,t,a,i,c),!0;case"dragenter":return Da=or(Da,e,t,a,i,c),!0;case"mouseover":return _a=or(_a,e,t,a,i,c),!0;case"pointerover":var d=c.pointerId;return rr.set(d,or(rr.get(d)||null,e,t,a,i,c)),!0;case"gotpointercapture":return d=c.pointerId,ir.set(d,or(ir.get(d)||null,e,t,a,i,c)),!0}return!1}function hp(e){var t=rn(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,Ht(e.priority,function(){dp(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,Ht(e.priority,function(){dp(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Zi(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Ku(e.nativeEvent);if(a===null){a=e.nativeEvent;var i=new a.constructor(a.type,a);Io=i,a.target.dispatchEvent(i),Io=null}else return t=hs(a),t!==null&&up(t),e.blockedOn=a,!1;t.shift()}return!0}function pp(e,t,a){Zi(e)&&a.delete(t)}function hy(){Zu=!1,qa!==null&&Zi(qa)&&(qa=null),Da!==null&&Zi(Da)&&(Da=null),_a!==null&&Zi(_a)&&(_a=null),rr.forEach(pp),ir.forEach(pp)}function Ji(e,t){e.blockedOn===t&&(e.blockedOn=null,Zu||(Zu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,hy)))}var Pi=null;function xp(e){Pi!==e&&(Pi=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Pi===e&&(Pi=null);for(var t=0;t<e.length;t+=3){var a=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Iu(i||a)===null)continue;break}var d=hs(a);d!==null&&(e.splice(t,3),t-=3,Kc(d,{pending:!0,data:c,method:a.method,action:i},i,c))}}))}function Is(e){function t(D){return Ji(D,e)}qa!==null&&Ji(qa,e),Da!==null&&Ji(Da,e),_a!==null&&Ji(_a,e),rr.forEach(t),ir.forEach(t);for(var a=0;a<Oa.length;a++){var i=Oa[a];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Oa.length&&(a=Oa[0],a.blockedOn===null);)hp(a),a.blockedOn===null&&Oa.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(i=0;i<a.length;i+=3){var c=a[i],d=a[i+1],y=c[Re]||null;if(typeof d=="function")y||xp(a);else if(y){var A=null;if(d&&d.hasAttribute("formAction")){if(c=d,y=d[Re]||null)A=y.formAction;else if(Iu(c)!==null)continue}else A=y.action;typeof A=="function"?a[i+1]=A:(a.splice(i,3),i-=3),xp(a)}}}function gp(){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(a,20)}function a(){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(a,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Ju(e){this._internalRoot=e}Wi.prototype.render=Ju.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,i=en();op(a,i,e,t,null,null)},Wi.prototype.unmount=Ju.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;op(e.current,2,null,e,null,null),Di(),t[Xe]=null}};function Wi(e){this._internalRoot=e}Wi.prototype.unstable_scheduleHydration=function(e){if(e){var t=yl();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Oa.length&&t!==0&&t<Oa[a].priority;a++);Oa.splice(a,0,e),a===0&&hp(e)}};var bp=s.version;if(bp!=="19.2.0")throw Error(o(527,bp,"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=g(t),e=e!==null?b(e):null,e=e===null?null:e.stateNode,e};var py={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var eo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eo.isDisabled&&eo.supportsFiber)try{Sn=eo.inject(py),jt=eo}catch{}}return ur.createRoot=function(e,t){if(!u(e))throw Error(o(299));var a=!1,i="",c=Ah,d=Ch,y=kh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=rp(e,1,!1,null,null,a,i,null,c,d,y,gp),e[Xe]=t.current,qu(e),new Ju(t)},ur.hydrateRoot=function(e,t,a){if(!u(e))throw Error(o(299));var i=!1,c="",d=Ah,y=Ch,A=kh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(A=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=rp(e,1,!0,t,a??null,i,c,D,d,y,A,gp),t.context=ip(null),a=t.current,i=en(),i=bl(i),c=ya(i),c.callback=null,Sa(a,c,i),a=i,t.current.lanes=a,jn(t,a),On(t),e[Xe]=t.current,qu(e),new Wi(t)},ur.version="19.2.0",ur}var Ep;function Cy(){if(Ep)return ed.exports;Ep=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),ed.exports=Ay(),ed.exports}var ky=Cy();var Mp="popstate";function Ey(n={}){function s(o,u){let{pathname:f,search:h,hash:p}=o.location;return Ed("",{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:Nr(u)}return Ry(s,r,null,n)}function ct(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function En(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function My(){return Math.random().toString(36).substring(2,10)}function Rp(n,s){return{usr:n.state,key:n.key,idx:s}}function Ed(n,s,r=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?ol(s):s,state:r,key:s&&s.key||o||My()}}function Nr({pathname:n="/",search:s="",hash:r=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),r&&r!=="#"&&(n+=r.charAt(0)==="#"?r:"#"+r),n}function ol(n){let s={};if(n){let r=n.indexOf("#");r>=0&&(s.hash=n.substring(r),n=n.substring(0,r));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function Ry(n,s,r,o={}){let{window:u=document.defaultView,v5Compat:f=!1}=o,h=u.history,p="POP",x=null,g=b();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function b(){return(h.state||{idx:null}).idx}function v(){p="POP";let w=b(),j=w==null?null:w-g;g=w,x&&x({action:p,location:S.location,delta:j})}function N(w,j){p="PUSH";let T=Ed(S.location,w,j);g=b()+1;let E=Rp(T,g),C=S.createHref(T);try{h.pushState(E,"",C)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;u.location.assign(C)}f&&x&&x({action:p,location:S.location,delta:1})}function M(w,j){p="REPLACE";let T=Ed(S.location,w,j);g=b();let E=Rp(T,g),C=S.createHref(T);h.replaceState(E,"",C),f&&x&&x({action:p,location:S.location,delta:0})}function k(w){return Ty(w)}let S={get action(){return p},get location(){return n(u,h)},listen(w){if(x)throw new Error("A history only accepts one active listener");return u.addEventListener(Mp,v),x=w,()=>{u.removeEventListener(Mp,v),x=null}},createHref(w){return s(u,w)},createURL:k,encodeLocation(w){let j=k(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:N,replace:M,go(w){return h.go(w)}};return S}function Ty(n,s=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),ct(r,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:Nr(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=r+o),new URL(o,r)}function Dx(n,s,r="/"){return qy(n,s,r,!1)}function qy(n,s,r,o){let u=typeof s=="string"?ol(s):s,f=ua(u.pathname||"/",r);if(f==null)return null;let h=_x(n);Dy(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=Fy(f);p=$y(h[x],g,o)}return p}function _x(n,s=[],r=[],o="",u=!1){let f=(h,p,x=u,g)=>{let b={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(b.relativePath.startsWith("/")){if(!b.relativePath.startsWith(o)&&x)return;ct(b.relativePath.startsWith(o),`Absolute route path "${b.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),b.relativePath=b.relativePath.slice(o.length)}let v=ca([o,b.relativePath]),N=r.concat(b);h.children&&h.children.length>0&&(ct(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),_x(h.children,s,N,v,x)),!(h.path==null&&!h.index)&&s.push({path:v,score:Hy(v,h.index),routesMeta:N})};return n.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))f(h,p);else for(let x of Ox(h.path))f(h,p,!0,x)}),s}function Ox(n){let s=n.split("/");if(s.length===0)return[];let[r,...o]=s,u=r.endsWith("?"),f=r.replace(/\?$/,"");if(o.length===0)return u?[f,""]:[f];let h=Ox(o.join("/")),p=[];return p.push(...h.map(x=>x===""?f:[f,x].join("/"))),u&&p.push(...h),p.map(x=>n.startsWith("/")&&x===""?"/":x)}function Dy(n){n.sort((s,r)=>s.score!==r.score?r.score-s.score:Vy(s.routesMeta.map(o=>o.childrenIndex),r.routesMeta.map(o=>o.childrenIndex)))}var _y=/^:[\w-]+$/,Oy=3,By=2,Ly=1,zy=10,Uy=-2,Tp=n=>n==="*";function Hy(n,s){let r=n.split("/"),o=r.length;return r.some(Tp)&&(o+=Uy),s&&(o+=By),r.filter(u=>!Tp(u)).reduce((u,f)=>u+(_y.test(f)?Oy:f===""?Ly:zy),o)}function Vy(n,s){return n.length===s.length&&n.slice(0,-1).every((o,u)=>o===s[u])?n[n.length-1]-s[s.length-1]:0}function $y(n,s,r=!1){let{routesMeta:o}=n,u={},f="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,b=f==="/"?s:s.slice(f.length)||"/",v=No({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},b),N=x.route;if(!v&&g&&r&&!o[o.length-1].route.index&&(v=No({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},b)),!v)return null;Object.assign(u,v.params),h.push({params:u,pathname:ca([f,v.pathname]),pathnameBase:Iy(ca([f,v.pathnameBase])),route:N}),v.pathnameBase!=="/"&&(f=ca([f,v.pathnameBase]))}return h}function No(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[r,o]=Gy(n.path,n.caseSensitive,n.end),u=s.match(r);if(!u)return null;let f=u[0],h=f.replace(/(.)\/+$/,"$1"),p=u.slice(1);return{params:o.reduce((g,{paramName:b,isOptional:v},N)=>{if(b==="*"){let k=p[N]||"";h=f.slice(0,f.length-k.length).replace(/(.)\/+$/,"$1")}const M=p[N];return v&&!M?g[b]=void 0:g[b]=(M||"").replace(/%2F/g,"/"),g},{}),pathname:f,pathnameBase:h,pattern:n}}function Gy(n,s=!1,r=!0){En(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,s?void 0:"i"),o]}function Fy(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return En(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function ua(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,o=n.charAt(r);return o&&o!=="/"?null:n.slice(r)||"/"}var Yy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Xy=n=>Yy.test(n);function Qy(n,s="/"){let{pathname:r,search:o="",hash:u=""}=typeof n=="string"?ol(n):n,f;if(r)if(Xy(r))f=r;else{if(r.includes("//")){let h=r;r=r.replace(/\/\/+/g,"/"),En(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${r}`)}r.startsWith("/")?f=qp(r.substring(1),"/"):f=qp(r,s)}else f=s;return{pathname:f,search:Zy(o),hash:Jy(u)}}function qp(n,s){let r=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?r.length>1&&r.pop():u!=="."&&r.push(u)}),r.length>1?r.join("/"):"/"}function sd(n,s,r,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` 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 Ky(n){return n.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function Bx(n){let s=Ky(n);return s.map((r,o)=>o===s.length-1?r.pathname:r.pathnameBase)}function Lx(n,s,r,o=!1){let u;typeof n=="string"?u=ol(n):(u={...n},ct(!u.pathname||!u.pathname.includes("?"),sd("?","pathname","search",u)),ct(!u.pathname||!u.pathname.includes("#"),sd("#","pathname","hash",u)),ct(!u.search||!u.search.includes("#"),sd("#","search","hash",u)));let f=n===""||u.pathname==="",h=f?"/":u.pathname,p;if(h==null)p=r;else{let v=s.length-1;if(!o&&h.startsWith("..")){let N=h.split("/");for(;N[0]==="..";)N.shift(),v-=1;u.pathname=N.join("/")}p=v>=0?s[v]:"/"}let x=Qy(u,p),g=h&&h!=="/"&&h.endsWith("/"),b=(f||h===".")&&r.endsWith("/");return!x.pathname.endsWith("/")&&(g||b)&&(x.pathname+="/"),x}var ca=n=>n.join("/").replace(/\/\/+/g,"/"),Iy=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Zy=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Jy=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Py(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 zx=["POST","PUT","PATCH","DELETE"];new Set(zx);var Wy=["GET",...zx];new Set(Wy);var cl=m.createContext(null);cl.displayName="DataRouter";var _o=m.createContext(null);_o.displayName="DataRouterState";m.createContext(!1);var Ux=m.createContext({isTransitioning:!1});Ux.displayName="ViewTransition";var e1=m.createContext(new Map);e1.displayName="Fetchers";var t1=m.createContext(null);t1.displayName="Await";var Un=m.createContext(null);Un.displayName="Navigation";var Dr=m.createContext(null);Dr.displayName="Location";var fa=m.createContext({outlet:null,matches:[],isDataRoute:!1});fa.displayName="Route";var Id=m.createContext(null);Id.displayName="RouteError";function n1(n,{relative:s}={}){ct(_r(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=m.useContext(Un),{hash:u,pathname:f,search:h}=Or(n,{relative:s}),p=f;return r!=="/"&&(p=f==="/"?r:ca([r,f])),o.createHref({pathname:p,search:h,hash:u})}function _r(){return m.useContext(Dr)!=null}function ds(){return ct(_r(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Dr).location}var Hx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Vx(n){m.useContext(Un).static||m.useLayoutEffect(n)}function a1(){let{isDataRoute:n}=m.useContext(fa);return n?x1():s1()}function s1(){ct(_r(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(cl),{basename:s,navigator:r}=m.useContext(Un),{matches:o}=m.useContext(fa),{pathname:u}=ds(),f=JSON.stringify(Bx(o)),h=m.useRef(!1);return Vx(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(En(h.current,Hx),!h.current)return;if(typeof x=="number"){r.go(x);return}let b=Lx(x,JSON.parse(f),u,g.relative==="path");n==null&&s!=="/"&&(b.pathname=b.pathname==="/"?s:ca([s,b.pathname])),(g.replace?r.replace:r.push)(b,g.state,g)},[s,r,f,u,n])}m.createContext(null);function Or(n,{relative:s}={}){let{matches:r}=m.useContext(fa),{pathname:o}=ds(),u=JSON.stringify(Bx(r));return m.useMemo(()=>Lx(n,JSON.parse(u),o,s==="path"),[n,u,o,s])}function l1(n,s){return $x(n,s)}function $x(n,s,r,o,u){ct(_r(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(Un),{matches:h}=m.useContext(fa),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",b=p?p.pathnameBase:"/",v=p&&p.route;{let T=v&&v.path||"";Gx(g,!v||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${T}">) 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="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let N=ds(),M;if(s){let T=typeof s=="string"?ol(s):s;ct(b==="/"||T.pathname?.startsWith(b),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${b}" but pathname "${T.pathname}" was given in the \`location\` prop.`),M=T}else M=N;let k=M.pathname||"/",S=k;if(b!=="/"){let T=b.replace(/^\//,"").split("/");S="/"+k.replace(/^\//,"").split("/").slice(T.length).join("/")}let w=Dx(n,{pathname:S});En(v||w!=null,`No routes matched location "${M.pathname}${M.search}${M.hash}" `),En(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${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 j=u1(w&&w.map(T=>Object.assign({},T,{params:Object.assign({},x,T.params),pathname:ca([b,f.encodeLocation?f.encodeLocation(T.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?b:ca([b,f.encodeLocation?f.encodeLocation(T.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),h,r,o,u);return s&&j?m.createElement(Dr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...M},navigationType:"POP"}},j):j}function r1(){let n=p1(),s=Py(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"}},s),r?m.createElement("pre",{style:u},r):null,h)}var i1=m.createElement(r1,null),o1=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(fa.Provider,{value:this.props.routeContext},m.createElement(Id.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function c1({routeContext:n,match:s,children:r}){let o=m.useContext(cl);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(fa.Provider,{value:n},r)}function u1(n,s=[],r=null,o=null,u=null){if(n==null){if(!r)return null;if(r.errors)n=r.matches;else if(s.length===0&&!r.initialized&&r.matches.length>0)n=r.matches;else return null}let f=n,h=r?.errors;if(h!=null){let b=f.findIndex(v=>v.route.id&&h?.[v.route.id]!==void 0);ct(b>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),f=f.slice(0,Math.min(f.length,b+1))}let p=!1,x=-1;if(r)for(let b=0;b<f.length;b++){let v=f[b];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(x=b),v.route.id){let{loaderData:N,errors:M}=r,k=v.route.loader&&!N.hasOwnProperty(v.route.id)&&(!M||M[v.route.id]===void 0);if(v.route.lazy||k){p=!0,x>=0?f=f.slice(0,x+1):f=[f[0]];break}}}let g=r&&o?(b,v)=>{o(b,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:v})}:void 0;return f.reduceRight((b,v,N)=>{let M,k=!1,S=null,w=null;r&&(M=h&&v.route.id?h[v.route.id]:void 0,S=v.route.errorElement||i1,p&&(x<0&&N===0?(Gx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,w=null):x===N&&(k=!0,w=v.route.hydrateFallbackElement||null)));let j=s.concat(f.slice(0,N+1)),T=()=>{let E;return M?E=S:k?E=w:v.route.Component?E=m.createElement(v.route.Component,null):v.route.element?E=v.route.element:E=b,m.createElement(c1,{match:v,routeContext:{outlet:b,matches:j,isDataRoute:r!=null},children:E})};return r&&(v.route.ErrorBoundary||v.route.errorElement||N===0)?m.createElement(o1,{location:r.location,revalidation:r.revalidation,component:S,error:M,children:T(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:g}):T()},null)}function Zd(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function d1(n){let s=m.useContext(cl);return ct(s,Zd(n)),s}function f1(n){let s=m.useContext(_o);return ct(s,Zd(n)),s}function m1(n){let s=m.useContext(fa);return ct(s,Zd(n)),s}function Jd(n){let s=m1(n),r=s.matches[s.matches.length-1];return ct(r.route.id,`${n} can only be used on routes that contain a unique "id"`),r.route.id}function h1(){return Jd("useRouteId")}function p1(){let n=m.useContext(Id),s=f1("useRouteError"),r=Jd("useRouteError");return n!==void 0?n:s.errors?.[r]}function x1(){let{router:n}=d1("useNavigate"),s=Jd("useNavigate"),r=m.useRef(!1);return Vx(()=>{r.current=!0}),m.useCallback(async(u,f={})=>{En(r.current,Hx),r.current&&(typeof u=="number"?n.navigate(u):await n.navigate(u,{fromRouteId:s,...f}))},[n,s])}var Dp={};function Gx(n,s,r){!s&&!Dp[n]&&(Dp[n]=!0,En(!1,r))}m.memo(g1);function g1({routes:n,future:s,state:r,unstable_onError:o}){return $x(n,void 0,r,o,s)}function mo(n){ct(!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 b1({basename:n="/",children:s=null,location:r,navigationType:o="POP",navigator:u,static:f=!1}){ct(!_r(),"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=ol(r));let{pathname:x="/",search:g="",hash:b="",state:v=null,key:N="default"}=r,M=m.useMemo(()=>{let k=ua(x,h);return k==null?null:{location:{pathname:k,search:g,hash:b,state:v,key:N},navigationType:o}},[h,x,g,b,v,N,o]);return En(M!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${b}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:m.createElement(Un.Provider,{value:p},m.createElement(Dr.Provider,{children:s,value:M}))}function v1({children:n,location:s}){return l1(Md(n),s)}function Md(n,s=[]){let r=[];return m.Children.forEach(n,(o,u)=>{if(!m.isValidElement(o))return;let f=[...s,u];if(o.type===m.Fragment){r.push.apply(r,Md(o.props.children,f));return}ct(o.type===mo,`[${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>`),ct(!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=Md(o.props.children,f)),r.push(h)}),r}var ho="get",po="application/x-www-form-urlencoded";function Oo(n){return n!=null&&typeof n.tagName=="string"}function y1(n){return Oo(n)&&n.tagName.toLowerCase()==="button"}function S1(n){return Oo(n)&&n.tagName.toLowerCase()==="form"}function j1(n){return Oo(n)&&n.tagName.toLowerCase()==="input"}function N1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function w1(n,s){return n.button===0&&(!s||s==="_self")&&!N1(n)}var to=null;function A1(){if(to===null)try{new FormData(document.createElement("form"),0),to=!1}catch{to=!0}return to}var C1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ld(n){return n!=null&&!C1.has(n)?(En(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${po}"`),null):n}function k1(n,s){let r,o,u,f,h;if(S1(n)){let p=n.getAttribute("action");o=p?ua(p,s):null,r=n.getAttribute("method")||ho,u=ld(n.getAttribute("enctype"))||po,f=new FormData(n)}else if(y1(n)||j1(n)&&(n.type==="submit"||n.type==="image")){let p=n.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=n.getAttribute("formaction")||p.getAttribute("action");if(o=x?ua(x,s):null,r=n.getAttribute("formmethod")||p.getAttribute("method")||ho,u=ld(n.getAttribute("formenctype"))||ld(p.getAttribute("enctype"))||po,f=new FormData(p,n),!A1()){let{name:g,type:b,value:v}=n;if(b==="image"){let N=g?`${g}.`:"";f.append(`${N}x`,"0"),f.append(`${N}y`,"0")}else g&&f.append(g,v)}}else{if(Oo(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ho,o=null,u=po,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 Pd(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function E1(n,s,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}`:s&&ua(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function M1(n,s){if(n.id in s)return s[n.id];try{let r=await import(n.module);return s[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 R1(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 T1(n,s,r){let o=await Promise.all(n.map(async u=>{let f=s.routes[u.route.id];if(f){let h=await M1(f,r);return h.links?h.links():[]}return[]}));return O1(o.flat(1).filter(R1).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function _p(n,s,r,o,u,f){let h=(x,g)=>r[g]?x.route.id!==r[g].route.id:!0,p=(x,g)=>r[g].pathname!==x.pathname||r[g].route.path?.endsWith("*")&&r[g].params["*"]!==x.params["*"];return f==="assets"?s.filter((x,g)=>h(x,g)||p(x,g)):f==="data"?s.filter((x,g)=>{let b=o.routes[x.route.id];if(!b||!b.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let v=x.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function q1(n,s,{includeHydrateFallback:r}={}){return D1(n.map(o=>{let u=s.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 D1(n){return[...new Set(n)]}function _1(n){let s={},r=Object.keys(n).sort();for(let o of r)s[o]=n[o];return s}function O1(n,s){let r=new Set;return new Set(s),n.reduce((o,u)=>{let f=JSON.stringify(_1(u));return r.has(f)||(r.add(f),o.push({key:f,link:u})),o},[])}function Fx(){let n=m.useContext(cl);return Pd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function B1(){let n=m.useContext(_o);return Pd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Wd=m.createContext(void 0);Wd.displayName="FrameworkContext";function Yx(){let n=m.useContext(Wd);return Pd(n,"You must render this element inside a <HydratedRouter> element"),n}function L1(n,s){let r=m.useContext(Wd),[o,u]=m.useState(!1),[f,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:b,onTouchStart:v}=s,N=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let S=j=>{j.forEach(T=>{h(T.isIntersecting)})},w=new IntersectionObserver(S,{threshold:.5});return N.current&&w.observe(N.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let S=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(S)}}},[o]);let M=()=>{u(!0)},k=()=>{u(!1),h(!1)};return r?n!=="intent"?[f,N,{}]:[f,N,{onFocus:dr(p,M),onBlur:dr(x,k),onMouseEnter:dr(g,M),onMouseLeave:dr(b,k),onTouchStart:dr(v,M)}]:[!1,N,{}]}function dr(n,s){return r=>{n&&n(r),r.defaultPrevented||s(r)}}function z1({page:n,...s}){let{router:r}=Fx(),o=m.useMemo(()=>Dx(r.routes,n,r.basename),[r.routes,n,r.basename]);return o?m.createElement(H1,{page:n,matches:o,...s}):null}function U1(n){let{manifest:s,routeModules:r}=Yx(),[o,u]=m.useState([]);return m.useEffect(()=>{let f=!1;return T1(n,s,r).then(h=>{f||u(h)}),()=>{f=!0}},[n,s,r]),o}function H1({page:n,matches:s,...r}){let o=ds(),{manifest:u,routeModules:f}=Yx(),{basename:h}=Fx(),{loaderData:p,matches:x}=B1(),g=m.useMemo(()=>_p(n,s,x,u,o,"data"),[n,s,x,u,o]),b=m.useMemo(()=>_p(n,s,x,u,o,"assets"),[n,s,x,u,o]),v=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let k=new Set,S=!1;if(s.forEach(j=>{let T=u.routes[j.route.id];!T||!T.hasLoader||(!g.some(E=>E.route.id===j.route.id)&&j.route.id in p&&f[j.route.id]?.shouldRevalidate||T.hasClientLoader?S=!0:k.add(j.route.id))}),k.size===0)return[];let w=E1(n,h,"data");return S&&k.size>0&&w.searchParams.set("_routes",s.filter(j=>k.has(j.route.id)).map(j=>j.route.id).join(",")),[w.pathname+w.search]},[h,p,o,u,g,s,n,f]),N=m.useMemo(()=>q1(b,u),[b,u]),M=U1(b);return m.createElement(m.Fragment,null,v.map(k=>m.createElement("link",{key:k,rel:"prefetch",as:"fetch",href:k,...r})),N.map(k=>m.createElement("link",{key:k,rel:"modulepreload",href:k,...r})),M.map(({key:k,link:S})=>m.createElement("link",{key:k,nonce:r.nonce,...S})))}function V1(...n){return s=>{n.forEach(r=>{typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Xx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Xx&&(window.__reactRouterVersion="7.9.6")}catch{}function $1({basename:n,children:s,window:r}){let o=m.useRef();o.current==null&&(o.current=Ey({window:r,v5Compat:!0}));let u=o.current,[f,h]=m.useState({action:u.action,location:u.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>u.listen(p),[u,p]),m.createElement(b1,{basename:n,children:s,location:f.location,navigationType:f.action,navigator:u})}var Qx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Kx=m.forwardRef(function({onClick:s,discover:r="render",prefetch:o="none",relative:u,reloadDocument:f,replace:h,state:p,target:x,to:g,preventScrollReset:b,viewTransition:v,...N},M){let{basename:k}=m.useContext(Un),S=typeof g=="string"&&Qx.test(g),w,j=!1;if(typeof g=="string"&&S&&(w=g,Xx))try{let K=new URL(window.location.href),$=g.startsWith("//")?new URL(K.protocol+g):new URL(g),X=ua($.pathname,k);$.origin===K.origin&&X!=null?g=X+$.search+$.hash:j=!0}catch{En(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=n1(g,{relative:u}),[E,C,L]=L1(o,N),G=X1(g,{replace:h,state:p,target:x,preventScrollReset:b,relative:u,viewTransition:v});function O(K){s&&s(K),K.defaultPrevented||G(K)}let z=m.createElement("a",{...N,...L,href:w||T,onClick:j||f?s:O,ref:V1(M,C),target:x,"data-discover":!S&&r==="render"?"true":void 0});return E&&!S?m.createElement(m.Fragment,null,z,m.createElement(z1,{page:T})):z});Kx.displayName="Link";var G1=m.forwardRef(function({"aria-current":s="page",caseSensitive:r=!1,className:o="",end:u=!1,style:f,to:h,viewTransition:p,children:x,...g},b){let v=Or(h,{relative:g.relative}),N=ds(),M=m.useContext(_o),{navigator:k,basename:S}=m.useContext(Un),w=M!=null&&J1(v)&&p===!0,j=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=N.pathname,E=M&&M.navigation&&M.navigation.location?M.navigation.location.pathname:null;r||(T=T.toLowerCase(),E=E?E.toLowerCase():null,j=j.toLowerCase()),E&&S&&(E=ua(E,S)||E);const C=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let L=T===j||!u&&T.startsWith(j)&&T.charAt(C)==="/",G=E!=null&&(E===j||!u&&E.startsWith(j)&&E.charAt(j.length)==="/"),O={isActive:L,isPending:G,isTransitioning:w},z=L?s:void 0,K;typeof o=="function"?K=o(O):K=[o,L?"active":null,G?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let $=typeof f=="function"?f(O):f;return m.createElement(Kx,{...g,"aria-current":z,className:K,ref:b,style:$,to:h,viewTransition:p},typeof x=="function"?x(O):x)});G1.displayName="NavLink";var F1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:r,reloadDocument:o,replace:u,state:f,method:h=ho,action:p,onSubmit:x,relative:g,preventScrollReset:b,viewTransition:v,...N},M)=>{let k=I1(),S=Z1(p,{relative:g}),w=h.toLowerCase()==="get"?"get":"post",j=typeof p=="string"&&Qx.test(p),T=E=>{if(x&&x(E),E.defaultPrevented)return;E.preventDefault();let C=E.nativeEvent.submitter,L=C?.getAttribute("formmethod")||h;k(C||E.currentTarget,{fetcherKey:s,method:L,navigate:r,replace:u,state:f,relative:g,preventScrollReset:b,viewTransition:v})};return m.createElement("form",{ref:M,method:w,action:S,onSubmit:o?x:T,...N,"data-discover":!j&&n==="render"?"true":void 0})});F1.displayName="Form";function Y1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ix(n){let s=m.useContext(cl);return ct(s,Y1(n)),s}function X1(n,{target:s,replace:r,state:o,preventScrollReset:u,relative:f,viewTransition:h}={}){let p=a1(),x=ds(),g=Or(n,{relative:f});return m.useCallback(b=>{if(w1(b,s)){b.preventDefault();let v=r!==void 0?r:Nr(x)===Nr(g);p(n,{replace:v,state:o,preventScrollReset:u,relative:f,viewTransition:h})}},[x,p,g,r,o,s,n,u,f,h])}var Q1=0,K1=()=>`__${String(++Q1)}__`;function I1(){let{router:n}=Ix("useSubmit"),{basename:s}=m.useContext(Un),r=h1();return m.useCallback(async(o,u={})=>{let{action:f,method:h,encType:p,formData:x,body:g}=k1(o,s);if(u.navigate===!1){let b=u.fetcherKey||K1();await n.fetch(b,r,u.action||f,{preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||h,formEncType:u.encType||p,flushSync:u.flushSync})}else await n.navigate(u.action||f,{preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||h,formEncType:u.encType||p,replace:u.replace,state:u.state,fromRouteId:r,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,s,r])}function Z1(n,{relative:s}={}){let{basename:r}=m.useContext(Un),o=m.useContext(fa);ct(o,"useFormAction must be used inside a RouteContext");let[u]=o.matches.slice(-1),f={...Or(n||".",{relative:s})},h=ds();if(n==null){f.search=h.search;let p=new URLSearchParams(f.search),x=p.getAll("index");if(x.some(b=>b==="")){p.delete("index"),x.filter(v=>v).forEach(v=>p.append("index",v));let b=p.toString();f.search=b?`?${b}`:""}}return(!n||n===".")&&u.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(f.pathname=f.pathname==="/"?r:ca([r,f.pathname])),Nr(f)}function J1(n,{relative:s}={}){let r=m.useContext(Ux);ct(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Ix("useViewTransitionState"),u=Or(n,{relative:s});if(!r.isTransitioning)return!1;let f=ua(r.currentLocation.pathname,o)||r.currentLocation.pathname,h=ua(r.nextLocation.pathname,o)||r.nextLocation.pathname;return No(u.pathname,h)!=null||No(u.pathname,f)!=null}const zn=Object.create(null);zn.open="0";zn.close="1";zn.ping="2";zn.pong="3";zn.message="4";zn.upgrade="5";zn.noop="6";const xo=Object.create(null);Object.keys(zn).forEach(n=>{xo[zn[n]]=n});const Rd={type:"error",data:"parser error"},Zx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Jx=typeof ArrayBuffer=="function",Px=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,ef=({type:n,data:s},r,o)=>Zx&&s instanceof Blob?r?o(s):Op(s,o):Jx&&(s instanceof ArrayBuffer||Px(s))?r?o(s):Op(new Blob([s]),o):o(zn[n]+(s||"")),Op=(n,s)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];s("b"+(o||""))},r.readAsDataURL(n)};function Bp(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let rd;function P1(n,s){if(Zx&&n.data instanceof Blob)return n.data.arrayBuffer().then(Bp).then(s);if(Jx&&(n.data instanceof ArrayBuffer||Px(n.data)))return s(Bp(n.data));ef(n,!1,r=>{rd||(rd=new TextEncoder),s(rd.encode(r))})}const Lp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Lp.length;n++)gr[Lp.charCodeAt(n)]=n;const W1=n=>{let s=n.length*.75,r=n.length,o,u=0,f,h,p,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),b=new Uint8Array(g);for(o=0;o<r;o+=4)f=gr[n.charCodeAt(o)],h=gr[n.charCodeAt(o+1)],p=gr[n.charCodeAt(o+2)],x=gr[n.charCodeAt(o+3)],b[u++]=f<<2|h>>4,b[u++]=(h&15)<<4|p>>2,b[u++]=(p&3)<<6|x&63;return g},eS=typeof ArrayBuffer=="function",tf=(n,s)=>{if(typeof n!="string")return{type:"message",data:Wx(n,s)};const r=n.charAt(0);return r==="b"?{type:"message",data:tS(n.substring(1),s)}:xo[r]?n.length>1?{type:xo[r],data:n.substring(1)}:{type:xo[r]}:Rd},tS=(n,s)=>{if(eS){const r=W1(n);return Wx(r,s)}else return{base64:!0,data:n}},Wx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},eg="",nS=(n,s)=>{const r=n.length,o=new Array(r);let u=0;n.forEach((f,h)=>{ef(f,!1,p=>{o[h]=p,++u===r&&s(o.join(eg))})})},aS=(n,s)=>{const r=n.split(eg),o=[];for(let u=0;u<r.length;u++){const f=tf(r[u],s);if(o.push(f),f.type==="error")break}return o};function sS(){return new TransformStream({transform(n,s){P1(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),s.enqueue(u),s.enqueue(r)})}})}let id;function no(n){return n.reduce((s,r)=>s+r.length,0)}function ao(n,s){if(n[0].length===s)return n.shift();const r=new Uint8Array(s);let o=0;for(let u=0;u<s;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 lS(n,s){id||(id=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(no(r)<1)break;const x=ao(r,1);f=(x[0]&128)===128,u=x[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(no(r)<2)break;const x=ao(r,2);u=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(no(r)<8)break;const x=ao(r,8),g=new DataView(x.buffer,x.byteOffset,x.length),b=g.getUint32(0);if(b>Math.pow(2,21)-1){p.enqueue(Rd);break}u=b*Math.pow(2,32)+g.getUint32(4),o=3}else{if(no(r)<u)break;const x=ao(r,u);p.enqueue(tf(f?x:id.decode(x),s)),o=0}if(u===0||u>n){p.enqueue(Rd);break}}}})}const tg=4;function yt(n){if(n)return rS(n)}function rS(n){for(var s in yt.prototype)n[s]=yt.prototype[s];return n}yt.prototype.on=yt.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};yt.prototype.once=function(n,s){function r(){this.off(n,r),s.apply(this,arguments)}return r.fn=s,this.on(n,r),this};yt.prototype.off=yt.prototype.removeListener=yt.prototype.removeAllListeners=yt.prototype.removeEventListener=function(n,s){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===s||o.fn===s){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+n],this};yt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].apply(this,s)}return this};yt.prototype.emitReserved=yt.prototype.emit;yt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};yt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Bo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,r)=>r(s,0),yn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),iS="arraybuffer";function ng(n,...s){return s.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const oS=yn.setTimeout,cS=yn.clearTimeout;function Lo(n,s){s.useNativeTimers?(n.setTimeoutFn=oS.bind(yn),n.clearTimeoutFn=cS.bind(yn)):(n.setTimeoutFn=yn.setTimeout.bind(yn),n.clearTimeoutFn=yn.clearTimeout.bind(yn))}const uS=1.33;function dS(n){return typeof n=="string"?fS(n):Math.ceil((n.byteLength||n.size)*uS)}function fS(n){let s=0,r=0;for(let o=0,u=n.length;o<u;o++)s=n.charCodeAt(o),s<128?r+=1:s<2048?r+=2:s<55296||s>=57344?r+=3:(o++,r+=4);return r}function ag(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function mS(n){let s="";for(let r in n)n.hasOwnProperty(r)&&(s.length&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return s}function hS(n){let s={},r=n.split("&");for(let o=0,u=r.length;o<u;o++){let f=r[o].split("=");s[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return s}class pS extends Error{constructor(s,r,o){super(s),this.description=r,this.context=o,this.type="TransportError"}}class nf extends yt{constructor(s){super(),this.writable=!1,Lo(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,r,o){return super.emitReserved("error",new pS(s,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(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const r=tf(s,this.socket.binaryType);this.onPacket(r)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,r={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const s=this.opts.hostname;return s.indexOf(":")===-1?s:"["+s+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(s){const r=mS(s);return r.length?"?"+r:""}}class xS extends nf{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const r=()=>{this.readyState="paused",s()};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(s){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)};aS(s,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const s=()=>{this.write([{type:"close"}])};this.readyState==="open"?s():this.once("open",s)}write(s){this.writable=!1,nS(s,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=ag()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(s,r)}}let sg=!1;try{sg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const gS=sg;function bS(){}class vS extends xS{constructor(s){if(super(s),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,r){const o=this.request({method:"POST",data:s});o.on("success",r),o.on("error",(u,f)=>{this.onError("xhr post error",u,f)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=s}}class Ln extends yt{constructor(s,r,o){super(),this.createRequest=s,Lo(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 s;const r=ng(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{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var 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=Ln.requestsCount++,Ln.requests[this._index]=this)}_onError(s){this.emitReserved("error",s,this._xhr),this._cleanup(!0)}_cleanup(s){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=bS,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ln.requests[this._index],this._xhr=null}}_onLoad(){const s=this._xhr.responseText;s!==null&&(this.emitReserved("data",s),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Ln.requestsCount=0;Ln.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",zp);else if(typeof addEventListener=="function"){const n="onpagehide"in yn?"pagehide":"unload";addEventListener(n,zp,!1)}}function zp(){for(let n in Ln.requests)Ln.requests.hasOwnProperty(n)&&Ln.requests[n].abort()}const yS=(function(){const n=lg({xdomain:!1});return n&&n.responseType!==null})();class SS extends vS{constructor(s){super(s);const r=s&&s.forceBase64;this.supportsBinary=yS&&!r}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Ln(lg,this.uri(),s)}}function lg(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||gS))return new XMLHttpRequest}catch{}if(!s)try{return new yn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const rg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jS extends nf{get name(){return"websocket"}doOpen(){const s=this.uri(),r=this.opts.protocols,o=rg?{}:ng(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(s,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=s=>this.onClose({description:"websocket connection closed",context:s}),this.ws.onmessage=s=>this.onData(s.data),this.ws.onerror=s=>this.onError("websocket error",s)}write(s){this.writable=!1;for(let r=0;r<s.length;r++){const o=s[r],u=r===s.length-1;ef(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 s=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=ag()),this.supportsBinary||(r.b64=1),this.createUri(s,r)}}const od=yn.WebSocket||yn.MozWebSocket;class NS extends jS{createSocket(s,r,o){return rg?new od(s,r,o):r?new od(s,r):new od(s)}doWrite(s,r){this.ws.send(r)}}class wS extends nf{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(s){return this.emitReserved("error",s)}this._transport.closed.then(()=>{this.onClose()}).catch(s=>{this.onError("webtransport error",s)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(s=>{const r=lS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(r).getReader(),u=sS();u.readable.pipeTo(s.writable),this._writer=u.writable.getWriter();const f=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),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(s){this.writable=!1;for(let r=0;r<s.length;r++){const o=s[r],u=r===s.length-1;this._writer.write(o).then(()=>{u&&Bo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const AS={websocket:NS,webtransport:wS,polling:SS},CS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,kS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Td(n){if(n.length>8e3)throw"URI too long";const s=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=CS.exec(n||""),f={},h=14;for(;h--;)f[kS[h]]=u[h]||"";return r!=-1&&o!=-1&&(f.source=s,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=ES(f,f.path),f.queryKey=MS(f,f.query),f}function ES(n,s){const r=/\/{2,9}/g,o=s.replace(r,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function MS(n,s){const r={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,f){u&&(r[u]=f)}),r}const qd=typeof addEventListener=="function"&&typeof removeEventListener=="function",go=[];qd&&addEventListener("offline",()=>{go.forEach(n=>n())},!1);class za extends yt{constructor(s,r){if(super(),this.binaryType=iS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(r=s,s=null),s){const o=Td(s);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=Td(r.host).host);Lo(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=hS(this.opts.query)),qd&&(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"})},go.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const r=Object.assign({},this.opts.query);r.EIO=tg,r.transport=s,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[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&za.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(s);r.open(),this.setTransport(r)}setTransport(s){this.transport&&this.transport.removeAllListeners(),this.transport=s,s.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",za.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=s.data,this._onError(r);break;case"message":this.emitReserved("data",s.data),this.emitReserved("message",s.data);break}}onHandshake(s){this.emitReserved("handshake",s),this.id=s.sid,this.transport.query.sid=s.sid,this._pingInterval=s.pingInterval,this._pingTimeout=s.pingTimeout,this._maxPayload=s.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const s=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+s,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},s),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const s=this._getWritablePackets();this.transport.send(s),this._prevBufferLen=s.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=dS(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,Bo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,r,o){return this._sendPacket("message",s,r,o),this}send(s,r,o){return this._sendPacket("message",s,r,o),this}_sendPacket(s,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:s,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),u&&this.once("flush",u),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),s()},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():s()}):this.upgrading?o():s()),this}_onError(s){if(za.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,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(),qd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=go.indexOf(this._offlineEventListener);o!==-1&&go.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,r),this.writeBuffer=[],this._prevBufferLen=0}}}za.protocol=tg;class RS extends za{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let r=this.createTransport(s),o=!1;za.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;za.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(b(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const N=new Error("probe error");N.transport=r.name,this.emitReserved("upgradeError",N)}}))};function f(){o||(o=!0,b(),r.close(),r=null)}const h=v=>{const N=new Error("probe error: "+v);N.transport=r.name,f(),this.emitReserved("upgradeError",N)};function p(){h("transport closed")}function x(){h("socket closed")}function g(v){r&&v.name!==r.name&&f()}const b=()=>{r.removeListener("open",u),r.removeListener("error",h),r.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};r.once("open",u),r.once("error",h),r.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const r=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&r.push(s[o]);return r}}let TS=class extends RS{constructor(s,r={}){const o=typeof s=="object"?s:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>AS[u]).filter(u=>!!u)),super(s,o)}};function qS(n,s="",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=Td(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+s,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const DS=typeof ArrayBuffer=="function",_S=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ig=Object.prototype.toString,OS=typeof Blob=="function"||typeof Blob<"u"&&ig.call(Blob)==="[object BlobConstructor]",BS=typeof File=="function"||typeof File<"u"&&ig.call(File)==="[object FileConstructor]";function af(n){return DS&&(n instanceof ArrayBuffer||_S(n))||OS&&n instanceof Blob||BS&&n instanceof File}function bo(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(bo(n[r]))return!0;return!1}if(af(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return bo(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&bo(n[r]))return!0;return!1}function LS(n){const s=[],r=n.data,o=n;return o.data=Dd(r,s),o.attachments=s.length,{packet:o,buffers:s}}function Dd(n,s){if(!n)return n;if(af(n)){const r={_placeholder:!0,num:s.length};return s.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=Dd(n[o],s);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]=Dd(n[o],s));return r}return n}function zS(n,s){return n.data=_d(n.data,s),delete n.attachments,n}function _d(n,s){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<s.length)return s[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=_d(n[r],s);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=_d(n[r],s));return n}const US=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],HS=5;var Ve;(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"})(Ve||(Ve={}));class VS{constructor(s){this.replacer=s}encode(s){return(s.type===Ve.EVENT||s.type===Ve.ACK)&&bo(s)?this.encodeAsBinary({type:s.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let r=""+s.type;return(s.type===Ve.BINARY_EVENT||s.type===Ve.BINARY_ACK)&&(r+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(r+=s.nsp+","),s.id!=null&&(r+=s.id),s.data!=null&&(r+=JSON.stringify(s.data,this.replacer)),r}encodeAsBinary(s){const r=LS(s),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function Up(n){return Object.prototype.toString.call(n)==="[object Object]"}class sf extends yt{constructor(s){super(),this.reviver=s}add(s){let r;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(s);const o=r.type===Ve.BINARY_EVENT;o||r.type===Ve.BINARY_ACK?(r.type=o?Ve.EVENT:Ve.ACK,this.reconstructor=new $S(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(af(s)||s.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(s),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: "+s)}decodeString(s){let r=0;const o={type:Number(s.charAt(0))};if(Ve[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Ve.BINARY_EVENT||o.type===Ve.BINARY_ACK){const f=r+1;for(;s.charAt(++r)!=="-"&&r!=s.length;);const h=s.substring(f,r);if(h!=Number(h)||s.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(s.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(s.charAt(r)===","||r===s.length););o.nsp=s.substring(f,r)}else o.nsp="/";const u=s.charAt(r+1);if(u!==""&&Number(u)==u){const f=r+1;for(;++r;){const h=s.charAt(r);if(h==null||Number(h)!=h){--r;break}if(r===s.length)break}o.id=Number(s.substring(f,r+1))}if(s.charAt(++r)){const f=this.tryParse(s.substr(r));if(sf.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,r){switch(s){case Ve.CONNECT:return Up(r);case Ve.DISCONNECT:return r===void 0;case Ve.CONNECT_ERROR:return typeof r=="string"||Up(r);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&US.indexOf(r[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class $S{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const r=zS(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const GS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:sf,Encoder:VS,get PacketType(){return Ve},protocol:HS},Symbol.toStringTag,{value:"Module"}));function kn(n,s,r){return n.on(s,r),function(){n.off(s,r)}}const FS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class og extends yt{constructor(s,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=s,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 s=this.io;this.subs=[kn(s,"open",this.onopen.bind(this)),kn(s,"packet",this.onpacket.bind(this)),kn(s,"error",this.onerror.bind(this)),kn(s,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...s){return s.unshift("message"),this.emit.apply(this,s),this}emit(s,...r){var o,u,f;if(FS.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(r.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const h={type:Ve.EVENT,data:r};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const b=this.ids++,v=r.pop();this._registerAckCallback(b,v),h.id=b}const p=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,x=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(s,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[s]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===s&&this.sendBuffer.splice(p,1);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[s]=h}emitWithAck(s,...r){return new Promise((o,u)=>{const f=(h,p)=>h?u(h):o(p);f.withError=!0,r.push(f),this.emit(s,...r)})}_addToQueue(s){let r;typeof s[s.length-1]=="function"&&(r=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.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(s=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!s||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(s){s.nsp=this.nsp,this.io._packet(s)}onopen(){typeof this.auth=="function"?this.auth(s=>{this._sendConnectPacket(s)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(s){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},s):s})}onerror(s){this.connected||this.emitReserved("connect_error",s)}onclose(s,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(s=>{if(!this.sendBuffer.some(o=>String(o.id)===s)){const o=this.acks[s];delete this.acks[s],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(s){if(s.nsp===this.nsp)switch(s.type){case Ve.CONNECT:s.data&&s.data.sid?this.onconnect(s.data.sid,s.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(s);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(s);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const o=new Error(s.data.message);o.data=s.data.data,this.emitReserved("connect_error",o);break}}onevent(s){const r=s.data||[];s.id!=null&&r.push(this.ack(s.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,s)}super.emit.apply(this,s),this._pid&&s.length&&typeof s[s.length-1]=="string"&&(this._lastOffset=s[s.length-1])}ack(s){const r=this;let o=!1;return function(...u){o||(o=!0,r.packet({type:Ve.ACK,id:s,data:u}))}}onack(s){const r=this.acks[s.id];typeof r=="function"&&(delete this.acks[s.id],r.withError&&s.data.unshift(null),r.apply(this,s.data))}onconnect(s,r){this.id=s,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(s=>this.emitEvent(s)),this.receiveBuffer=[],this.sendBuffer.forEach(s=>{this.notifyOutgoingListeners(s),this.packet(s)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(s=>s()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(s){return this.flags.compress=s,this}get volatile(){return this.flags.volatile=!0,this}timeout(s){return this.flags.timeout=s,this}onAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(s),this}prependAny(s){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(s),this}offAny(s){if(!this._anyListeners)return this;if(s){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(s===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(s),this}prependAnyOutgoing(s){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(s),this}offAnyOutgoing(s){if(!this._anyOutgoingListeners)return this;if(s){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(s===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,s.data)}}}function ul(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}ul.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),r=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};ul.prototype.reset=function(){this.attempts=0};ul.prototype.setMin=function(n){this.ms=n};ul.prototype.setMax=function(n){this.max=n};ul.prototype.setJitter=function(n){this.jitter=n};class Od extends yt{constructor(s,r){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(r=s,s=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Lo(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 ul({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=s;const u=r.parser||GS;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(s){return arguments.length?(this._reconnection=!!s,s||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(s){return s===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=s,this)}reconnectionDelay(s){var r;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(r=this.backoff)===null||r===void 0||r.setMin(s),this)}randomizationFactor(s){var r;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(r=this.backoff)===null||r===void 0||r.setJitter(s),this)}reconnectionDelayMax(s){var r;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(r=this.backoff)===null||r===void 0||r.setMax(s),this)}timeout(s){return arguments.length?(this._timeout=s,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(s){if(~this._readyState.indexOf("open"))return this;this.engine=new TS(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=kn(r,"open",function(){o.onopen(),s&&s()}),f=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),s?s(p):this.maybeReconnectOnOpen()},h=kn(r,"error",f);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{u(),f(new Error("timeout")),r.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(u),this.subs.push(h),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(kn(s,"ping",this.onping.bind(this)),kn(s,"data",this.ondata.bind(this)),kn(s,"error",this.onerror.bind(this)),kn(s,"close",this.onclose.bind(this)),kn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(r){this.onclose("parse error",r)}}ondecoded(s){Bo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,r){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new og(this,s,r),this.nsps[s]=o),o}_destroy(s){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(s){const r=this.encoder.encode(s);for(let o=0;o<r.length;o++)this.engine.write(r[o],s.options)}cleanup(){this.subs.forEach(s=>s()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(s,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const s=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(u=>{u?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",u)):s.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const s=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",s)}}const fr={};function vo(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const r=qS(n,s.path||"/socket.io"),o=r.source,u=r.id,f=r.path,h=fr[u]&&f in fr[u].nsps,p=s.forceNew||s["force new connection"]||s.multiplex===!1||h;let x;return p?x=new Od(o,s):(fr[u]||(fr[u]=new Od(o,s)),x=fr[u]),r.query&&!s.query&&(s.query=r.queryKey),x.socket(r.path,s)}Object.assign(vo,{Manager:Od,Socket:og,io:vo,connect:vo});const cg="roverSettings",YS=3600*24*365;function XS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function Bd(){if(typeof document>"u")return{};const n=`${cg}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const r=s.substring(n.length);return XS(r)??{}}function Hp(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),r=`${cg}=${s}; path=/; max-age=${YS}; samesite=strict`;return document.cookie=r,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const ug=window.location.origin;console.info("[socket] connecting to",ug);const QS=Bd(),KS=QS?.page?.connectionTransport||"websocket",IS=KS==="polling"?["polling"]:["websocket","polling"],lf=vo(ug,{transports:IS,timeout:15e3});lf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const dg=m.createContext(lf),ZS=({children:n})=>l.jsx(dg.Provider,{value:lf,children:n}),sn=()=>m.useContext(dg),JS={connected:!1,session:null,neatoLidar:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,overseerControlState:null,alerts:[]},rf=m.createContext(null);function PS(n){return m.useCallback((s,r={})=>new Promise((o,u)=>{n.emit(s,r,(f={})=>{f.error?u(new Error(f.error)):o(f)})}),[n])}function WS(n){return typeof n=="function"?n:s=>s}function ej({children:n}){const s=sn(),r=PS(s),o=m.useRef({...JS,connected:s.connected}),u=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),h=m.useCallback(b=>{const v=o.current,N=typeof b=="function"?b(v):{...v,...b||{}};N!==v&&(o.current=N,u.current.forEach(M=>{const k=M.selector(N);M.equalityFn(M.current,k)||(M.current=k,M.listener(k))}))},[]),p=m.useCallback((b,v,N=Object.is)=>{const M=WS(b),k={selector:M,equalityFn:N,listener:v,current:M(o.current)};return u.current.add(k),()=>{u.current.delete(k)}},[]);m.useEffect(()=>{const b=()=>{h(N=>N.connected?N:{...N,connected:!0})},v=()=>{h(N=>N.connected?{...N,connected:!1}:N)};return s.on("connect",b),s.on("disconnect",v),()=>{s.off("connect",b),s.off("disconnect",v)}},[h,s]),m.useEffect(()=>{function b(E){h(C=>({...C,session:E}))}function v(E=[]){h(C=>({...C,logs:E}))}function N(E){h(C=>({...C,logs:[...C.logs.slice(-199),E]}))}function M(E=[]){h(C=>({...C,adminLogs:E}))}function k(E){h(C=>({...C,adminLogs:[...C.adminLogs.slice(-199),E]}))}function S(E=null){const C=E&&typeof E=="object"?E:null,L=C?.debug?.status&&typeof C.debug.status=="object"?C.debug.status:null;h(G=>({...G,llmCommentaryState:C,llmCommentaryStatus:L}))}function w(E={}){h(C=>({...C,alerts:[...C.alerts.slice(-49),{...E,receivedAt:Date.now()}]}))}function j(E=null){const C=E&&typeof E=="object"?E:null;h(L=>({...L,overseerControlState:C}))}function T(E=null){const C=E&&typeof E=="object"?E:null;h(L=>({...L,neatoLidar:C}))}return s.on("session:sync",b),s.on("neato:lidar",T),s.on("log:init",v),s.on("log:entry",N),s.on("adminlog:init",M),s.on("adminlog:entry",k),s.on("llm:state",S),s.on("overseer:state",j),s.on("alert:new",w),()=>{s.off("session:sync",b),s.off("neato:lidar",T),s.off("log:init",v),s.off("log:entry",N),s.off("adminlog:init",M),s.off("adminlog:entry",k),s.off("llm:state",S),s.off("overseer:state",j),s.off("alert:new",w)}},[h,s]);const x=m.useMemo(()=>({login:(b,v)=>r("auth:login",{username:b,password:v}),identifySession:({cookieUserId:b,nickname:v}={})=>r("session:identify",{cookieUserId:b,nickname:v}),setRole:b=>r("session:setRole",{role:b}),requestControl:(b,v={})=>r("session:requestControl",{roverId:b,...v}),releaseControl:b=>r("session:releaseControl",{roverId:b}),subscribeAll:()=>r("session:subscribeAll"),lockRover:(b,v)=>r("session:lockRover",{roverId:b,locked:v}),setMode:b=>r("setMode",{mode:b}),homeAssistantToggle:b=>r("homeAssistant:toggle",{entityId:b}),homeAssistantSetState:(b,v)=>r("homeAssistant:setState",{entityId:b,state:v}),homeAssistantSetLightColor:(b,v)=>r("homeAssistant:lightColor",{entityId:b,rgbColor:v}),homeAssistantSetLightWhite:b=>r("homeAssistant:lightWhite",{entityId:b}),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:b=>r("nickname:set",{nickname:b}),requestVerification:()=>r("verification:request"),requestPrivateRoverAccess:b=>r("session:privateRover:requestAccess",{roverId:b}),triggerReplay:(b=[],v="")=>b&&typeof b=="object"&&!Array.isArray(b)?r("replay:trigger",b):r("replay:trigger",{sources:b,title:v}),setGlobalObjective:b=>r("globalObjective:set",{text:b}),setAdminReason:b=>r("adminReason:set",{text:b}),rebootRover:b=>r("command",{roverId:b,type:"reboot",data:{reboot:{}}}),rebootServer:()=>r("server:reboot"),playUploadedAudio:({roverId:b,name:v,mime:N,dataBase64:M})=>r("audio:uploadPlay",{roverId:b,name:v,mime:N,dataBase64:M}),stopUploadedAudio:b=>r("audio:uploadStop",{roverId:b}),startMicWhip:b=>r("audio:micWhipStart",{roverId:b}),readyMicWhip:b=>r("audio:micWhipReady",{roverId:b}),stopMicWhip:b=>r("audio:micWhipStop",{roverId:b}),setAudioLevels:(b={})=>r("audioLevels:set",b),setPrivateSafety:(b,v={})=>r("session:privateSafety:set",{roverId:b,safety:v}),llmControl:(b,v={})=>r("llm:control",{controls:{action:b,...v}}),overseerControl:(b,v={})=>r("overseer:control",{controls:{action:b,...v}}),pushAlert:b=>h(v=>({...v,alerts:[...v.alerts.slice(-49),{...b,receivedAt:Date.now(),id:b.id||Math.random().toString(36).slice(2)}]}))}),[r,h]),g=m.useMemo(()=>({getState:f,subscribe:p,actions:x}),[x,f,p]);return l.jsx(rf.Provider,{value:g,children:n})}function xe(n,s=Object.is){const r=m.useContext(rf);if(!r)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const u=m.useRef(s);u.current=s;const[f,h]=m.useState(()=>n(r.getState()));return m.useEffect(()=>(h(p=>{const x=o.current(r.getState());return u.current(p,x)?p:x}),r.subscribe(p=>o.current(p),p=>{h(x=>u.current(x,p)?x:p)},(p,x)=>u.current(p,x))),[r]),f}function Qt(){const n=m.useContext(rf);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function Br(){const n=xe(r=>r),s=Qt();return m.useMemo(()=>({...n,...s}),[s,n])}const tj=Object.freeze({}),Ld=null,of=m.createContext(null);function nj({children:n}){const s=sn(),r=m.useRef({}),o=m.useRef(new Map),u=m.useRef(new Set),f=p=>{const x=o.current.get(p);x&&x.forEach(g=>g()),u.current.forEach(g=>g())},h=m.useMemo(()=>({getFrames:()=>r.current,getFrame:p=>p?r.current[p]??Ld:Ld,subscribeAll:p=>(u.current.add(p),()=>{u.current.delete(p)}),subscribeRover:(p,x)=>{if(!p)return()=>{};let g=o.current.get(p);return g||(g=new Set,o.current.set(p,g)),g.add(x),()=>{const b=o.current.get(p);b&&(b.delete(x),b.size||o.current.delete(p))}}}),[]);return m.useEffect(()=>{function p({roverId:x,sensors:g={},frame:b={}}){x&&(r.current={...r.current,[x]:{roverId:x,sensors:g,raw:b?.data||null,receivedAt:Date.now()}},f(x))}return s.on("sensorFrame",p),()=>{s.off("sensorFrame",p)}},[s]),l.jsx(of.Provider,{value:h,children:n})}function fg(){const n=m.useContext(of);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>tj)}function dl(n){const s=m.useContext(of);if(!s)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(r=>s.subscribeRover(n,r),()=>s.getFrame(n),()=>Ld)}const aj=650,sj={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 cd(n){if(typeof n!="number"||n<=0)return null;const s=sj[n];return s?{code:n,...s}:null}function lj(n,s={}){const r=s.holdMs||aj,[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(),x=cd(n?.infraredCharacterLeft),g=cd(n?.infraredCharacterRight),b=cd(n?.infraredCharacterOmni);!x&&!g&&!b||u(v=>({left:x?{...x,ts:p}:v.left,right:g?{...g,ts:p}:v.right,omni:b?{...b,ts:p}:v.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const p=Date.now(),x=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const j=p-w.ts,T=j<=r;return{active:T,age:j,code:w.code,red:!!(w.red&&T),green:!!(w.green&&T),force:!!(w.force&&T)}},g=x(o.left),b=x(o.right),v=x(o.omni),N=g.force||b.force||v.force,M=g.active||b.active||v.active,k=g.active&&!b.active?"right":b.active&&!g.active?"left":"center",S=(b.active?1:0)-(g.active?1:0);return{visible:M,forceDetected:N,left:g,right:b,omni:v,bias:k,balance:Math.max(-1,Math.min(1,S))}},[o.left,o.right,o.omni,r,f])}function rj(){xe(M=>M.connected);const n=xe(M=>M.session?.assignment?.roverId??null),s=xe(M=>{const k=M.session?.assignment?.roverId;return k&&M.session?.activeDrivers?.[k]||null}),r=xe(M=>M.session?.socketId||null),o=xe(M=>M.session?.users??[]),u=dl(n),f=u?.sensors||{},h=lj(f),p=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,x=f.currentMa!=null?`${f.currentMa} mA`:null,g=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,b=f.batteryChargeMah,v=f.batteryCapacityMah;u?.receivedAt&&new Date(u.receivedAt).toLocaleTimeString();const N=u?.raw?u.raw:null;return m.useMemo(()=>n?s?s===r?"You":o.find(k=>k.socketId===s)?.nickname||s.slice(0,6):"Available":"n/a",[s,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(ij,{sensors:f,voltage:p,current:x,batteryTemp:g,charge:b,capacity:v}),l.jsx(oj,{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."}),N&&l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:N})]})}function ij({sensors:n,voltage:s,current:r,batteryTemp:o,charge:u,capacity:f}){const h=u!=null&&f?`${Math.round(u/f*100)}`:"--",p=n?.oiMode?.label||"--",x=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[l.jsx(la,{label:"Voltage",value:s??"--"}),l.jsx(la,{label:"Current",value:r??"--"}),l.jsx(la,{label:"Battery temp",value:o??"--"}),l.jsx(la,{label:"Charge",value:u!=null?`${u} mAh`:"--"}),l.jsx(la,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),l.jsx(la,{label:"Charge",value:h}),l.jsx(la,{label:"OI mode",value:p}),l.jsx(la,{label:"Docked",value:x}),l.jsx(la,{label:"Charging state",value:g})]})}function la({label:n,value:s}){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:s})]})}function oj({sensors:n,dockState:s}){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(Zs,{title:"Dock IR",children:[l.jsx(cj,{sensors:n}),l.jsx(uj,{state:s})]}),l.jsxs(Zs,{title:"Bumps & drops",children:[l.jsx(ra,{label:"Bump L",value:l.jsx(mr,{active:r.bumpLeft})}),l.jsx(ra,{label:"Bump R",value:l.jsx(mr,{active:r.bumpRight})}),l.jsx(ra,{label:"Wheel drop L",value:l.jsx(mr,{active:r.wheelDropLeft,tone:"amber"})}),l.jsx(ra,{label:"Wheel drop R",value:l.jsx(mr,{active:r.wheelDropRight,tone:"amber"})})]}),l.jsx(Zs,{title:"Light bumps (raw)",children:u.map(p=>l.jsx(ra,{label:p.label,value:hr(p.value)},p.label))}),l.jsx(Zs,{title:"Cliff sensors",children:f.map(p=>l.jsx(ra,{label:p.label,value:`${hr(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),l.jsx(Zs,{title:"Currents",children:h.map(p=>l.jsx(ra,{label:p.label,value:l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:hr(p.value,"mA")}),p.over?l.jsx(mr,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),l.jsxs(Zs,{title:"Dirt detect",children:[l.jsx(ra,{label:"Left",value:hr(n?.dirtDetectLeft)}),l.jsx(ra,{label:"Right",value:hr(n?.dirtDetect)})]})]})}function Zs({title:n,children:s}){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:s})]})}function ra({label:n,value:s}){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:s})]})}function mr({active:n,tone:s="green",label:r}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",u=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return l.jsx("span",{className:`${o} ${u}`,children:r||(n?"true":"false")})}function hr(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function cj({sensors:n}){const s=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(s)]}),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 uj({state:n}){if(!n)return null;const s=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??"--"} (${s(n.left)}) · age ${r(n.left)}`}),l.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${r(n.omni)}`}),l.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${r(n.right)}`})]})}const mg=m.createContext(null);function dj({children:n}){const[s,r]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=Bd();r({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=Bd();r({status:"ready",data:p??{}})},[]),u=m.useCallback(p=>{const x=Hp(p??{});return r(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),f=m.useCallback((p,x)=>{r(g=>{const b=g.data[p]||{},v=typeof x=="function"?x(b):{...b,...x??{}},N={...g.data,[p]:v};return Hp(N)?{status:"ready",data:N}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:u,setNamespace:f}),[s,o,u,f]);return l.jsx(mg.Provider,{value:h,children:n})}function fj(){const n=m.useContext(mg);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Fe(n,s={}){const{data:r,status:o,setNamespace:u}=fj(),f=r[n]??s??{},h=m.useCallback(g=>{u(n,b=>{const v=b??{};return typeof g=="function"?g(v):{...v,...g??{}}})},[n,u]),p=m.useCallback(g=>{u(n,()=>g??{})},[n,u]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;u(n,()=>g??{})},[s,n,u]);return{value:f,status:o,save:h,replace:p,reset:x}}const mj=/^#[0-9A-Fa-f]{6}$/;function cf(n){const s=typeof n=="string"?n.trim():"";return!s||!mj.test(s)?null:s.toUpperCase()}function da(n,s=.2){const r=cf(n);if(!r)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,u=hg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.65)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function hj(n,s=.2){const r=cf(n);if(!r)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,u=hg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.55)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function hg(n){const s=cf(n);return s?{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16)}:null}function pj(n=[]){return n.map(s=>!s?.type||!s?.id?null:{type:s.type,id:String(s.id),label:s.label||String(s.id),color:s.color||null,key:`${s.type}:${s.id}`}).filter(Boolean)}function uf({panelId:n="replay-sources",fillHeight:s=!1}){const r=xe(R=>R.session?.replaySources??[]),o=xe(R=>R.session?.mode||null),u=xe(R=>R.session?.assignment?.roverId??null),f=xe(R=>R.session?.users??[]),h=xe(R=>R.session?.socketId||null),p=xe(R=>R.session?.roster??[]),x=xe(R=>R.session?.replay||null),{triggerReplay:g}=Qt(),b=pj(r||[]),{value:v,save:N}=Fe("replaySources",{}),[M,k]=m.useState([]),[S,w]=m.useState(!1),[j,T]=m.useState(null),[E,C]=m.useState(null),[L,G]=m.useState(""),[O,z]=m.useState(!1),[K,$]=m.useState(!0),[X,P]=m.useState(0),ce=m.useMemo(()=>{const R=u;return R?[`rover:${R}`]:[]},[u]),ie=m.useMemo(()=>{const _=((Array.isArray(f)?f.find(fe=>fe?.socketId===h):null)?.nickname||"Someone").trim()||"Someone",Z=u||null,ee=Z&&Array.isArray(p)?p.find(fe=>String(fe?.id)===String(Z))?.name||Z:"a rover";return`${_} driving ${ee}`},[f,h,u,p]);m.useEffect(()=>{const R=v?.[n];if(Array.isArray(R)&&R.length){k(R);return}k(ce)},[v?.[n],ce,n]),m.useEffect(()=>{const R=v?.[`${n}:includeSidebar`];if(typeof R=="boolean"){$(R);return}$(!0)},[v?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{O||G(ie)},[ie,O]),m.useEffect(()=>{const R=new Set(b.map(_=>_.key));k(_=>_.filter(Z=>R.has(Z)))},[b]);const V=m.useMemo(()=>({rovers:b.filter(R=>R.type==="rover"),rooms:b.filter(R=>R.type==="room")}),[b]);m.useEffect(()=>{if(!x?.lastTriggeredAt||!x?.cooldownMs){P(0);return}const R=()=>{const Z=x.lastTriggeredAt+x.cooldownMs-Date.now();P(Math.max(0,Z))};R();const _=setInterval(R,250);return()=>clearInterval(_)},[x?.lastTriggeredAt,x?.cooldownMs,x?.remainingMs]);const q=S||o==="lockdown"||X>0||!M.length,H=R=>{k(_=>{const Z=_.includes(R)?_.filter(ee=>ee!==R):[..._,R];return N(ee=>({...ee||{},[n]:Z})),Z}),C(null)},J=async()=>{if(!q){w(!0),T(null),C(null);try{const R=M.map(Z=>{const[ee,fe]=Z.split(":");return{type:ee,id:fe}}),_=String(L||"").trim()||ie;await g({sources:R,title:_,includeSidebar:K}),C("Replay sent. Check the Discord replay channel.")}catch(R){T(R.message)}finally{w(!1)}}},te=s?"h-full flex flex-col":"",de=s?"flex-1 min-h-0 overflow-y-auto":"";return l.jsxs("section",{className:`panel-section p-0.75 text-sm ${te}`,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:b.length})]}),l.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${de}`,children:[l.jsx(Vp,{title:"Rovers",items:V.rovers,selected:M,onToggle:H}),l.jsx(Vp,{title:"Room Cams",items:V.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:R=>{G(R.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:K,onChange:R=>{const _=!!R.target.checked;$(_),N(Z=>({...Z||{},[`${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:X>0?`Replay (${Math.ceil(X/1e3)}s)`:S?"Replay…":"Replay"}),j?l.jsx("div",{className:"text-xs text-amber-400",children:j}):null,E?l.jsx("div",{className:"text-xs text-emerald-300",children:E}):null]})]})}function Vp({title:n,items:s,selected:r,onToggle:o}){return s.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:s.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"?da(u.color,.16):void 0,children:u.label})]},u.key))})]}):null}var pg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$p=an.createContext&&an.createContext(pg),xj=["attr","size","title"];function gj(n,s){if(n==null)return{};var r=bj(n,s),o,u;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(u=0;u<f.length;u++)o=f[u],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(r[o]=n[o])}return r}function bj(n,s){if(n==null)return{};var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;r[o]=n[o]}return r}function wo(){return wo=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}return n},wo.apply(this,arguments)}function Gp(n,s){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(n,u).enumerable})),r.push.apply(r,o)}return r}function Ao(n){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Gp(Object(r),!0).forEach(function(o){vj(n,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Gp(Object(r)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(r,o))})}return n}function vj(n,s,r){return s=yj(s),s in n?Object.defineProperty(n,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[s]=r,n}function yj(n){var s=Sj(n,"string");return typeof s=="symbol"?s:s+""}function Sj(n,s){if(typeof n!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var o=r.call(n,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function xg(n){return n&&n.map((s,r)=>an.createElement(s.tag,Ao({key:r},s.attr),xg(s.child)))}function Lr(n){return s=>an.createElement(jj,wo({attr:Ao({},n.attr)},s),xg(n.child))}function jj(n){var s=r=>{var{attr:o,size:u,title:f}=n,h=gj(n,xj),p=u||r.size||"1em",x;return r.className&&(x=r.className),n.className&&(x=(x?x+" ":"")+n.className),an.createElement("svg",wo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,o,h,{className:x,style:Ao(Ao({color:n.color||r.color},r.style),n.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),f&&an.createElement("title",null,f),n.children)};return $p!==void 0?an.createElement($p.Consumer,null,r=>s(r)):s(pg)}function gg(n){return Lr({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 Nj(n){return Lr({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 Fp(n){return Lr({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 wj(n){return Lr({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 Aj(n){return Lr({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 Cj(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 df(n){return!!n?.system}function kj(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function Yp(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Ej({guildIconUrl:n,userAvatarUrl:s,label:r}){return!n&&!s?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 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function bg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${Yp(n)}`:null,r=df(n),o=r?"text-emerald-300":Cj(n.role);return l.jsxs(l.Fragment,{children:[n.fromDiscord?l.jsxs(l.Fragment,{children:[l.jsx(gg,{className:"h-3.5 w-3.5 text-indigo-200"}),l.jsx(Ej,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,l.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:Yp(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:hj(n.roverColor,.14),children:n.roverId})]})}function vg(n){return df(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 ff({message:n}){const s=df(n);return l.jsxs("div",{className:vg(n),children:[l.jsx(bg,{message:n}),l.jsx("span",{className:`min-w-0 break-words leading-tight whitespace-pre-wrap ${s?"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:kj(n.ts)})]})}function yg({message:n}){return l.jsxs("div",{className:`${vg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[l.jsx(bg,{message:n}),l.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function Sg({buttonId:n,count:s,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:[s," / ",r]}),l.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",u]})]})}const Mj=3e3,Rj=3500,Tj="#2196f3";function qj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function mf({scale:n=1}){const s=xe(N=>N.alerts),r=xe(N=>N.session?.buttonBox?.buttons??[]),{pushAlert:o}=Qt(),u=sn(),[f,h]=m.useState(()=>Date.now());m.useEffect(()=>{function N(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)||{},j=Number.isFinite(M.count)?M.count:Number(w.count)||0,T=Number.isFinite(w.goal)?w.goal:0,E=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",C=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${k}`,kind:"buttonbox-active",lifetimeMs:Rj,payload:{buttonId:k,count:j,goal:T,rewardNumber:E,rewardName:C}})}return u.on("buttonBox:increment",N),()=>{u.off("buttonBox:increment",N)}},[o,r,u]);const p=m.useMemo(()=>s.slice(-12).map(N=>({alert:N,key:qj(N)})),[s]);m.useEffect(()=>{if(!p.length)return;const N=setInterval(()=>h(Date.now()),200);return()=>clearInterval(N)},[p.length]);const x=new Map;p.forEach(N=>{const M=f-(N.alert.receivedAt??N.alert.timestamp??0),k=Number.isFinite(N.alert.lifetimeMs)?N.alert.lifetimeMs:Mj;M<=k&&x.set(N.key,{...N,age:M})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const b=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},v=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:v,style:b,children:g.map(N=>l.jsx(Dj,{alert:N.alert},N.key))})}function Xp(n){const s=typeof n=="string"?n.trim():"",r=/^#?([0-9a-fA-F]{6})$/.exec(s);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 Dj({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(Sg,{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(ff,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return l.jsx(yg,{message:n.payload});const s=Xp(n.color)||Xp(Tj),r=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return 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 Js={main:[-127,127],side:[-127,127],vacuum:[0,127]},ud={maxSpeed:500,baseSpeed:250,boostSpeed:400},zd=100,hf=[31,127],sl=60,Ud=8,_j=250,Oj=4e3,so=.4,Qp=.2,Kp=.8,Bj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},yr={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"]},jg=[{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:zd},{type:"oi",command:"dock"},{type:"pause",duration:zd},{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 Hd(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Vd(){return{main:0,side:0,vacuum:0}}function Lj(){return{enabled:!1,angle:null,config:null}}function yo(){return{note:sl}}function br(){return{active:!1,heat:0,overheated:!1}}function So(){return{pttActive:!1}}const Ip={roverId:null,mode:"drive",drive:Hd(),aux:Vd(),camera:Lj(),song:yo(),horn:br(),mic:So(),lastControlIntentAt:0,macros:jg,keymap:yr,inputs:{}};function zj(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Hd(),aux:s.payload?n.aux:Vd(),song:s.payload?n.song:yo(),horn:s.payload?n.horn:br(),mic:s.payload?n.mic:So(),lastControlIntentAt:s.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===s.payload?n:{...n,mode:s.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:r,speeds:o,source:u}=s.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,...s.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!s.payload?.config,config:s.payload?.config??null,angle:typeof s.payload?.angle=="number"?s.payload.angle:s.payload?.config?s.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:s.payload}};case"control/register-input-state":{const r=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[r]:{...n.inputs[r]??{},...s.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...s.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(s.payload)?s.payload:n.macros};case"control/reset":return{...n,drive:Hd(),aux:Vd(),song:yo(),horn:br(),mic:So(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||br(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||br(),heat:typeof s.payload?.heat=="number"?s.payload.heat:0,overheated:!!s.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||yo(),note:s.payload??sl}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||So(),pttActive:!!s.payload}};default:return n}}function ll(n,s,r){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(r,n))}function rl(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function bn(n,s){return!Array.isArray(s)||s.length!==2?n:ll(n,s[0],s[1])}function Uj(n={}){const s=rl(n.x??0),r=rl(n.y??0);return{x:s,y:r,boost:!!n.boost}}function Hj(n={},s={}){const r=Uj(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:ud.maxSpeed,u=typeof s.baseSpeed=="number"?s.baseSpeed:ud.baseSpeed,f=typeof s.boostSpeed=="number"?s.boostSpeed:ud.boostSpeed,h=r.boost?f:u,p=r.y*h,x=r.x*h;return{vector:r,speeds:{left:ll(Math.round(p+x),-o,o),right:ll(Math.round(p-x),-o,o)}}}function Vj(n){const s=Array.isArray(n)?n:[],r=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(r);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function Zp(n){return new Promise(s=>setTimeout(s,n))}function $j(n={}){const{driveTransform:s,auxTransform:r}=n,o=sn(),u=xe(L=>L.session?.assignment?.roverId??null),f=xe(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]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),b=m.useMemo(()=>h?.nightVision?.state??null,[h]),v=m.useCallback((L,G)=>{u&&o.emit("command",{roverId:u,...L},G)},[o,u]),N=m.useCallback(()=>{u&&v({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[v,u]),M=m.useCallback(L=>{if(!u)return null;const G={left:bn(L?.left??0,[-500,500]),right:bn(L?.right??0,[-500,500])},O=s?s(G):G,z={left:bn(O?.left??0,[-500,500]),right:bn(O?.right??0,[-500,500])};return v({type:"drive",data:{driveDirect:z}}),z},[s,v,u]),k=m.useCallback(({main:L=0,side:G=0,vacuum:O=0}={})=>{if(!u)return null;const z={main:bn(L,Js.main),side:bn(G,Js.side),vacuum:bn(O,Js.vacuum)},K=r?r(z):z,$={main:bn(K?.main??0,Js.main),side:bn(K?.side??0,Js.side),vacuum:bn(K?.vacuum??0,Js.vacuum)};return v({type:"motors",data:{motorPwm:$}}),$},[r,v,u]),S=m.useCallback(L=>!u||!p?null:(v({type:"servo",data:{servo:{angle:L}}}),L),[v,u,p]),w=m.useCallback(L=>{if(!u)return!1;const G=Array.isArray(L)?L:typeof L=="string"?Bj[L]:null;return G?(v({type:"raw",data:{raw:Vj(G)}}),N(),!0):!1},[v,N,u]),j=m.useCallback(async L=>{if(!(!L||!Array.isArray(L.steps)||!u))for(const G of L.steps){if(!u)break;switch(G.type){case"oi":w(G.command);break;case"drive":M(G.speeds??{left:0,right:0});break;case"motors":k(G.values??{});break;case"servo":S(G.angle);break;case"pause":await Zp(G.duration??zd);break}if(G.delay||G.delayMs){const O=G.delayMs??G.delay;typeof O=="number"&&O>0&&await Zp(O)}}},[u,w,M,k,S]),T=m.useCallback((L="toggle")=>!u||!x?null:(v({type:"nightVision",data:{nightVision:{action:L}}}),L),[v,x,u]),E=m.useCallback(L=>u?(v({type:"horn",data:{horn:L}}),L):null,[v,u]),C=m.useCallback((L=[],G={})=>{if(!u)return null;const z=(Array.isArray(L)&&L.length>0?L:[{note:sl,duration:Ud}]).slice(0,16).map(K=>({note:bn(Math.round(K?.note??sl),hf),duration:bn(Math.round(K?.duration??Ud),[1,255])}));return v({type:"song",data:{song:{notes:z,slot:G.slot,loop:G.loop}}}),z},[v,u]);return m.useMemo(()=>({roverId:u,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:b,horn:g,emitCommand:v,enableSensorStream:N,sendDriveDirect:M,sendAuxMotors:k,sendServoAngle:S,sendOiCommand:w,sendNightVision:T,sendHorn:E,sendSong:C,runMacroSteps:j}),[u,h,p,x,b,g,v,N,M,k,S,w,T,E,j])}const Gj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Jp={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function zr(n){if(typeof n!="string")return"";const s=n.toLowerCase();return Gj[s]??s}function Fj(n){const s=zr(n);if(!s)return null;if(Jp[s])return Jp[s];if(s.length===1){if(/[a-z]/.test(s))return`Key${s.toUpperCase()}`;if(/[0-9]/.test(s))return`Digit${s}`}return null}function Ng(n){const s=zr(n);return s?`key:${s}`:null}function Yj(n){const s=Fj(n);return s?`code:${s}`:null}function Pp(n){const s=new Set,r=Ng(n?.key??"");r&&s.add(r);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function Xj(n={}){return Object.fromEntries(Object.entries(n).map(([s,r])=>{const o=Array.isArray(r)?r:[r],u=new Set;return o.forEach(f=>{const h=Ng(String(f));h&&u.add(h);const p=Yj(String(f));p&&u.add(p)}),[s,u]}))}function qt(n){const s=zr(n);return s?s===" "?"Space":s==="\\"?"Backslash":s==="`"?"Backtick":s==="["?"[ or {":s==="]"?"] or }":s===";"?"; or :":s==="'"?`' or "`:s===","?", or <":s==="."?". or >":s==="/"?"/ or ?":s==="-"?"- or _":s==="="?"= or +":s==="arrowup"?"Arrow Up":s==="arrowdown"?"Arrow Down":s==="arrowleft"?"Arrow Left":s==="arrowright"?"Arrow Right":s.length===1?s.toUpperCase():s:"—"}const Bn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},oa={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}]}}},La={activeSignature:null,profiles:{},defaults:{profile:oa}},us={waveform:"saw",freqs:[440,550,660,0]},ot={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},os=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Qj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Wp(){return os.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function ex(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Kj(n,s={}){const r=xe(j=>j.session?.role||null),f=(dl(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...Qj,...s.config||{}}),[s.config]),[p,x]=m.useState(()=>Wp()),g=m.useRef(0),b=m.useRef(f);m.useEffect(()=>{b.current=f||{}},[f]),m.useEffect(()=>{x(Wp()),g.current=0},[n]);const v=m.useMemo(()=>os.some(j=>j.motors.some(T=>!!f?.[T])),[f]),N=m.useMemo(()=>Object.values(p||{}).some(j=>(Number.isFinite(j?.cap)?j.cap:1)<.999),[p]),M=!!n&&(v||N);m.useEffect(()=>{if(!M)return;g.current=typeof performance<"u"?performance.now():Date.now();const j=setInterval(()=>{const T=typeof performance<"u"?performance.now():Date.now(),E=Math.max(0,T-g.current);g.current=T;const C=Math.min(.25,E/1e3);C<=0||x(L=>{let G=!1;const O={},z=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,K=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,$=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return os.forEach(X=>{const P=L[X.key]||{cap:1,clearSec:0},ce=Number.isFinite(P.cap)?P.cap:1,ie=Number.isFinite(P.clearSec)?P.clearSec:0,V=X.motors.some(te=>!!b.current?.[te]),q=V?0:ie+C,H=!V&&q>=$,J=ex(V?ce-z*C:H?ce+K*C:ce);(Math.abs(J-ce)>1e-4||Math.abs(q-ie)>1e-4)&&(G=!0),O[X.key]={cap:J,clearSec:q}}),G?O:L})},100);return()=>clearInterval(j)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec,n,M]);const k=m.useMemo(()=>{const j=os.reduce((T,E)=>{const C=p?.[E.key],L=Number.isFinite(C?.cap)?C.cap:1;return T[E.key]=ex(L),T},{});return{perGroup:j,drive:{left:j.drive??1,right:j.drive??1},aux:{main:j.aux??1,side:j.aux??1,vacuum:1}}},[p]),S=m.useMemo(()=>{const j={};os.forEach(E=>{E.motors.forEach(C=>{j[C]=!!f?.[C]})});const T=os.reduce((E,C)=>(E[C.key]=C.motors.some(L=>!!f?.[L]),E),{});return{motors:j,groups:T}},[f]),w=r==="admin"||r==="lockdown"||r==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:S,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,S,k,h,w])}function Ij(n={},s,r=!1){if(r||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,u=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&u>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*u)}}function Zj(n={},s,r=!1){if(r||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,u=typeof s.aux.side=="number"?s.aux.side:1,f=typeof s.aux.vacuum=="number"?s.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 wg=m.createContext(null);function tx(n){return Object.fromEntries(Object.entries(n||{}).map(([s,r])=>[s,Array.isArray(r)?[...r]:[]]))}function Jj(n,s){if(!n)return s;const r=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return ll(s,r,o)}function Pj(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[r,o,u]=s,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 Wj({children:n}){const[s,r]=m.useReducer(zj,Ip),o=m.useRef(null),u=m.useRef(!1),f=m.useRef(Ip.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:b}=Fe("controls",{keymap:yr,macros:jg}),{value:v}=Fe("page",{driveMacroBackoffEnabled:!0}),{value:N}=Fe("horn",us),M=typeof v?.driveMacroBackoffEnabled=="boolean"?v.driveMacroBackoffEnabled:!0,k=xe(re=>re.session?.assignment?.roverId??null),S=xe(re=>re.session?.homeAssistant?.entities??[]),{homeAssistantSetState:w}=Qt(),j=Kj(k),T=m.useCallback(re=>Ij(re,j.scales,j.adminImmune),[j.adminImmune,j.scales]),E=m.useCallback(re=>Zj(re,j.scales,j.adminImmune),[j.adminImmune,j.scales]),C=$j({driveTransform:T,auxTransform:E}),L=m.useCallback(()=>{const se=(S||[]).filter(je=>(je.type==="light"||je.type==="switch")&&je.available!==!1&&je.state!=="on");if(se.length===0){u.current=!1;return}u.current=!0,se.forEach(je=>{w(je.id,"on").catch(()=>{})}),u.current=!1},[S,w]);m.useEffect(()=>{r({type:"control/set-rover",payload:C.roverId})},[C.roverId]),m.useEffect(()=>{const re=o.current;o.current=s.mode,re!=="drive"&&s.mode==="drive"&&S?.length?L():re!=="drive"&&s.mode==="drive"&&(u.current=!0)},[s.mode,S,L]),m.useEffect(()=>{u.current&&S?.length&&L()},[S,L]),m.useEffect(()=>{const re={...yr,...g?.keymap||{}};r({type:"control/set-keymap",payload:re}),g?.macros&&r({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const re=C.servoConfig;if(!re){r({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const se=typeof re.minAngle=="number"?re.minAngle:-45,je=typeof re.maxAngle=="number"?re.maxAngle:45,me=typeof re.homeAngle=="number"?re.homeAngle:(se+je)/2,Ae=typeof f.current=="number"?ll(f.current,se,je):null,Ce=Ae??ll(me,se,je);r({type:"control/set-camera-config",payload:{config:re,angle:Ce}}),f.current=Ce},[C.servoConfig]),m.useEffect(()=>{f.current=typeof s.camera.angle=="number"?s.camera.angle:f.current},[s.camera.angle]),m.useEffect(()=>{C.roverId&&C.enableSensorStream()},[C.roverId,C.enableSensorStream]);const G=m.useCallback(re=>{r({type:"control/set-mode",payload:re})},[]),O=m.useCallback(()=>{r({type:"control/record-intent"})},[]),z=m.useRef(s.drive.speeds),K=m.useRef(s.aux),$=m.useMemo(()=>JSON.stringify(j.scales),[j.scales]),X=m.useRef(0),P=m.useRef(0);m.useEffect(()=>{z.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{K.current=s.aux},[s.aux]),m.useEffect(()=>{if(!C.roverId||j.adminImmune||!j.isActive)return;const re=Math.max(0,Number(j?.config?.outputRateMs)||0),se=typeof performance<"u"?performance.now():Date.now(),je=z.current||{left:0,right:0},me=K.current||{main:0,side:0,vacuum:0},Ae=!!(je.left||je.right),Ce=!!(me.main||me.side||me.vacuum);!Ae&&!Ce||(Ae&&se-X.current>=re&&(X.current=se,C.sendDriveDirect(je)),Ce&&se-P.current>=re&&(P.current=se,C.sendAuxMotors(me)))},[$,j.adminImmune,j.config,j.isActive,C]);const ce=m.useCallback((re,se={})=>{const je=Hj(re,se.speedOptions);r({type:"control/update-drive",payload:{...je,source:se.source??null}}),O(),C.sendDriveDirect(je.speeds)},[C,O]),ie=m.useCallback((re={})=>{const se=C.sendAuxMotors(re)??re;r({type:"control/set-aux-motors",payload:se}),O()},[C,O]),V=m.useCallback((re,se)=>{if(!re)return!1;const je=zr(se);if(!je)return!1;const me=tx(s.keymap);return me[re]=[je],r({type:"control/set-keymap",payload:me}),b(Ae=>({...Ae??{},keymap:me})),!0},[s.keymap,b]),q=m.useCallback(()=>{const re=tx(yr);r({type:"control/set-keymap",payload:re}),b(se=>({...se??{},keymap:re}))},[b]),H=m.useCallback(re=>{if(!C.servoConfig)return;const se=Jj(C.servoConfig,re);r({type:"control/set-camera-angle",payload:se}),C.sendServoAngle(se),f.current=se,O()},[C,O]),J=m.useCallback((re=0)=>{const se=C.servoConfig;if(!se)return;const je=typeof re=="number"&&re!==0?re:se.nudgeDegrees||1,me=typeof f.current=="number"?f.current:typeof se.homeAngle=="number"?se.homeAngle:0;H(me+je)},[C.servoConfig,H]),te=m.useCallback(()=>{const re=C.servoConfig;if(!re)return;const se=typeof re.homeAngle=="number"?re.homeAngle:typeof re.minAngle=="number"&&typeof re.maxAngle=="number"?(re.minAngle+re.maxAngle)/2:0;H(se)},[C.servoConfig,H]),de=m.useCallback(async re=>{const se=s.macros.find(me=>me.id===re)||null;if(!se)return;let je=se;re==="drive-sequence"?(L(),S?.length||(u.current=!0),O(),M||(je={...se,steps:Pj(se.steps)})):re==="seek-dock"&&O(),await C.runMacroSteps(je)},[M,C,O,S,s.macros,L]),R=m.useCallback(()=>{r({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),C.sendDriveDirect({left:0,right:0}),C.sendAuxMotors({main:0,side:0,vacuum:0})},[C]),_=m.useCallback(re=>{C.sendOiCommand(re)},[C]),Z=m.useCallback(re=>{C.roverId&&C.emitCommand({type:"sensorStream",data:{sensorStream:{enable:re}}})},[C]),ee=m.useCallback(re=>{if(C.nightVision){if(typeof re=="boolean"){const se=re?"off":"on";C.sendNightVision(se)}else C.sendNightVision("toggle");O()}},[C,O]),fe=m.useCallback(()=>{ee()},[ee]),oe=m.useCallback(re=>{const se=typeof re=="number"?re:sl;return r({type:"control/set-song-note",payload:se}),se},[]),ue=m.useCallback((re,se)=>C.sendSong(re,se),[C]),ge=m.useMemo(()=>{const re=N??us,se=re.waveform==="sine"?"sine":"saw",me=[...Array.isArray(re.freqs)?re.freqs:us.freqs,0,0,0,0].slice(0,4).map(Ae=>{const Ce=Number(Ae);return Number.isFinite(Ce)?Ce<=0?0:Math.min(5e3,Math.round(Ce)):0});return{waveform:se,freqs:me}},[N]),ve=m.useCallback(()=>{if(!C.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const re=Date.now();return C.sendHorn({action:"start",...ge}),r({type:"control/set-horn-active",payload:!0}),p.current=re,x.current=re,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{ye()},Oj),O(),!0},[r,ge,C,O,s.horn?.active,s.horn?.heat,s.horn?.overheated]),ye=m.useCallback(()=>{if(!C.horn)return;C.sendHorn({action:"stop"}),r({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const re=Date.now(),se=p.current||re,je=Math.max(0,re-se);if(p.current=0,je>0){const me=s.horn?.heat??0,Ae=je/1e3*so;let Ce=Math.max(0,Math.min(1,me+Ae)),Pe=s.horn?.overheated??!1;Ce>=1&&(Ce=1,Pe=!0),r({type:"control/set-horn-heat",payload:{heat:Ce,overheated:Pe}})}},[r,C,s.horn?.heat,s.horn?.overheated,so]),Ye=m.useRef({active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}),Ke=m.useRef(ye);m.useEffect(()=>{Ye.current={active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}},[s.horn?.active,s.horn?.heat,s.horn?.overheated]),m.useEffect(()=>{Ke.current=ye},[ye]);const Me=!!s.horn?.active||(s.horn?.heat??0)>0||!!s.horn?.overheated;m.useEffect(()=>{if(!Me)return;const se=setInterval(()=>{const je=Date.now(),me=x.current||je;x.current=je;const Ae=Math.min(1e3,Math.max(0,je-me))/1e3,Ce=Ye.current,Pe=Ce.heat??0,le=!!Ce.active,he=!!Ce.overheated,Oe=Ae*(le?so:-Qp);let Lt=Math.max(0,Math.min(1,Pe+Oe)),nt=he;Lt>=1?(Lt=1,nt=!0,le&&Ke.current()):nt&&Lt<=Kp&&(nt=!1),(Lt!==Pe||nt!==he)&&r({type:"control/set-horn-heat",payload:{heat:Lt,overheated:nt}})},100);return()=>clearInterval(se)},[r,Me,Qp,Kp,so]);const De=m.useCallback((re,se)=>{r({type:"control/register-input-state",payload:{source:re,state:se}})},[]),_e=m.useCallback(re=>{r({type:"control/set-mic-ptt",payload:!!re})},[]),Ct=m.useMemo(()=>({state:s,dispatch:r,pipeline:C,overcurrentLimiter:j,actions:{setMode:G,setDriveVector:ce,setAuxMotors:ie,setServoAngle:H,nudgeServo:J,goServoHome:te,runMacro:de,stopAllMotion:R,sendOiCommand:_,setSensorStream:Z,setNightVision:ee,toggleNightVision:fe,updateKeyBinding:V,resetKeyBindings:q,registerInputState:De,setSongNote:oe,sendSong:ue,startHorn:ve,stopHorn:ye,setMicPttActive:_e}}),[s,C,j,G,ce,ie,H,J,te,de,R,_,Z,ee,fe,V,q,De,oe,ue,ve,ye,_e]);return l.jsx(wg.Provider,{value:Ct,children:n})}function At(){const n=m.useContext(wg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const eN="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=",Ag=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function tN({children:n}){const s=sn(),r=xe(V=>V.session),{pushAlert:o}=Qt(),{value:u}=Fe("audio",ot),[f,h]=m.useState([]),[p,x]=m.useState([]),[g,b]=m.useState(!1),v=m.useRef(null),N=m.useRef(null),M=m.useRef(null),k=m.useRef(new Map),S=m.useRef(new Map),w=m.useRef({isTyping:!1,lastSent:0}),j=Number.isFinite(u?.masterVolume)?u.masterVolume:ot.masterVolume,T=Number.isFinite(u?.alertVolume)?u.alertVolume:ot.alertVolume,E=Math.max(0,Math.min(1,j*T)),C=m.useCallback(()=>{const V=Array.from(k.current.values()).sort((q,H)=>q.lastUpdate-H.lastUpdate).map(q=>q.payload);x(V)},[]),L=m.useCallback(V=>!V||typeof V!="object"?null:V.typingId?V.typingId:V.fromDiscord?`discord:${V.discordUserId||V.discordUserName||V.nickname||"unknown"}`:`socket:${V.socketId||V.nickname||"unknown"}`,[]);m.useEffect(()=>{M.current=new Audio(eN),M.current.volume=E,M.current.load()},[E]);const G=m.useCallback(()=>{const V=M.current;V&&(V.volume=E,V.currentTime=0,V.play().catch(()=>{}))},[E]);m.useEffect(()=>{function V(q={}){h(H=>[...H.slice(-99),q]),!(q?.socketId&&r?.socketId&&q.socketId===r.socketId)&&(G(),o?.({kind:"chat",payload:q,id:`chat-${q.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",V),()=>{s.off("chat:message",V)}},[G,r?.socketId,s]),m.useEffect(()=>{function V(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),C());return}if(q.isTyping){k.current.set(H,{payload:q,expiresAt:J+6e3,lastUpdate:J});const te=S.current.get(H)||0;J-te>=2500&&(S.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);C()}return s.on("chat:typing",V),()=>{s.off("chat:typing",V)}},[o,C,L,r?.socketId,s]),m.useEffect(()=>{const V=setInterval(()=>{const q=Date.now();let H=!1;k.current.forEach((J,te)=>{J.expiresAt<=q&&(k.current.delete(te),H=!0)}),H&&C()},2e3);return()=>clearInterval(V)},[C]),m.useEffect(()=>{function V(q=[]){Array.isArray(q)&&h(H=>{if(H.length===0)return q.slice(-100);const J=new Set(q.map(de=>de?.id));return[...q,...H.filter(de=>de?.id&&!J.has(de.id))].slice(-100)})}return s.on("chat:init",V),()=>{s.off("chat:init",V)}},[s]);const O=m.useCallback(V=>{const q=!!V,H=Date.now(),J=w.current,te=!q&&J.isTyping;!(q&&(!J.isTyping||H-J.lastSent>=3500))&&!te||(w.current={isTyping:q,lastSent:H},s.emit("chat:typing",{isTyping:q}))},[s]),z=m.useCallback((V,q=null)=>new Promise((H,J)=>{s.emit("chat:send",{text:V,tts:q},(te={})=>{te.error?J(new Error(te.error)):H(te)})}),[s]),K=m.useCallback((V,q={})=>{(q?.target==="hud"?"hud":"panel")==="hud"?N.current=V:v.current=V},[]),$=m.useCallback(()=>{b(!0),(N.current||v.current)?.focus()},[]),X=m.useCallback(()=>{b(!1),N.current?.blur(),v.current?.blur()},[]),P=m.useCallback(()=>b(!0),[]),ce=m.useCallback(()=>b(!1),[]),ie=m.useMemo(()=>({messages:f,sendMessage:z,focusChat:$,blurChat:X,registerInputRef:K,onInputFocus:P,onInputBlur:ce,setTypingActive:O,typing:p,isChatFocused:g,selfSocketId:r?.socketId||null}),[X,$,g,f,ce,P,K,z,r?.socketId,O,p]);return l.jsx(Ag.Provider,{value:ie,children:n})}function pf(){const n=m.useContext(Ag);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let Cg=!1;function dd(n){Cg=!!n}function nx(){return Cg}const nN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function kg(n){if(!n||n.nodeType!==1)return!1;const s=n.tagName;if(s==="TEXTAREA"||n.isContentEditable)return!0;if(s!=="INPUT")return!1;const r=n.type?n.type.toLowerCase():"";return nN.has(r)}function aN(){return typeof document>"u"?!1:kg(document.activeElement)}const fd="keyboard",md={x:0,y:0,boost:!1},hd={main:0,side:0,vacuum:0},ax=hf[0],sx=hf[1],xf=5,wr=500,Ar=1,gf=100;function pd(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):s}function sN(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(xf,Math.min(wr,r)):s}function Eg(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(Ar,Math.min(gf,r)):s}function lN(n){const r=(Eg(n,n)-Ar)/(gf-Ar),o=wr-r*(wr-xf);return Math.round(o)}function rN(n){const s=sN(n,n),r=(wr-s)/(wr-xf),o=Ar+r*(gf-Ar);return Math.round(o)}function iN(n){return kg(n?.target)}function ft(n,s){if(!n||n.size===0)return!1;for(const r of s)if(n.has(r))return!0;return!1}function oN(n,s){const r=ft(s.driveForward,n),o=ft(s.driveBackward,n),u=ft(s.driveLeft,n),f=ft(s.driveRight,n),h=ft(s.boostModifier,n),p=ft(s.slowModifier,n);let x=0;r&&!o?x=1:o&&!r&&(x=-1);let g=0;u&&!f?g=-1:f&&!u&&(g=1);const b=p?.4:1;return{x:g*b,y:x*b,boost:h&&!p}}function cN(n,s){if(ft(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=ft(s.auxMainForward,n)?127:ft(s.auxMainReverse,n)?-127:0,u=ft(s.auxSideForward,n)?127:ft(s.auxSideReverse,n)?-70:0,f=ft(s.auxVacuumFast,n)?127:ft(s.auxVacuumSlow,n)?50:0;return{main:o,side:u,vacuum:f}}function uN(){const{state:n,actions:{setMode:s,setDriveVector:r,setAuxMotors:o,nudgeServo:u,runMacro:f,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:b,setMicPttActive:v,setSongNote:N,sendSong:M}}=At(),k=xe(oe=>oe.session?.homeAssistant||null),{homeAssistantSetState:S}=Qt(),{focusChat:w,blurChat:j,isChatFocused:T}=pf(),{value:E}=Fe("inputs",Bn),C=m.useMemo(()=>Xj(n.keymap),[n.keymap]),L=m.useMemo(()=>{const oe=new Set;return Object.values(C).forEach(ue=>{ue&&ue.forEach(ge=>oe.add(ge))}),oe},[C]),G=m.useMemo(()=>{const oe=Bn.keyboard,ue=E?.keyboard??{};return{baseSpeed:pd(ue.baseSpeed,oe.baseSpeed),turboSpeed:pd(ue.turboSpeed,oe.turboSpeed),precisionSpeed:pd(ue.precisionSpeed,oe.precisionSpeed)}},[E?.keyboard]),O=m.useMemo(()=>{const oe=Bn.keyboard,ue=E?.keyboard??{},ge=Eg(typeof ue.tiltSpeed=="number"?ue.tiltSpeed:typeof ue.tiltIntervalMs=="number"?rN(ue.tiltIntervalMs):oe.tiltSpeed,oe.tiltSpeed);return lN(ge)},[E?.keyboard]),z=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),K=m.useRef(new Set),$=m.useRef(md),X=m.useRef(hd),P=m.useRef(null),ce=m.useRef(null),ie=m.useRef(!1),V=m.useCallback(()=>{const oe=new Set(K.current);ft(C.boostModifier,oe);const ge=ft(C.slowModifier,oe)?{baseSpeed:G.precisionSpeed,boostSpeed:G.precisionSpeed}:{baseSpeed:G.baseSpeed,boostSpeed:G.turboSpeed},ve=oN(oe,C),ye=cN(oe,C);(ve.x!==$.current.x||ve.y!==$.current.y||ve.boost!==$.current.boost)&&($.current=ve,r(ve,{source:fd,speedOptions:ge})),(ye.main!==X.current.main||ye.side!==X.current.side||ye.vacuum!==X.current.vacuum)&&(X.current=ye,o(ye)),p(fd,{keys:Array.from(oe),vector:ve,aux:ye})},[C,G,p,o,r]),q=m.useCallback(()=>{P.current&&(clearTimeout(P.current),P.current=null)},[]),H=m.useCallback(()=>{const oe=new Set(K.current),ue=ft(C.cameraUp,oe),ge=ft(C.cameraDown,oe);return(ue?1:0)-(ge?1:0)},[C]),J=m.useCallback(()=>{if(H()===0){q();return}if(P.current)return;const ue=()=>{const ge=H();if(ge===0){q();return}u(ge*z),P.current=setTimeout(ue,O)};P.current=setTimeout(ue,0)},[H,u,O,z,q]),te=m.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),de=m.useCallback(()=>{const oe=new Set(K.current),ue=ft(C.songNoteUp,oe),ge=ft(C.songNoteDown,oe);return(ue?1:0)-(ge?1:0)},[C]),R=m.useCallback(oe=>{if(oe===0)return;let ge=(typeof n.song?.note=="number"?n.song.note:sl)+oe;ge>sx?ge=ax:ge<ax&&(ge=sx);const ve=N(ge);M([{note:ve,duration:Ud}],{slot:0})},[M,N,n.song?.note]),_=m.useCallback(()=>{if(de()===0){te();return}if(ce.current)return;const ue=()=>{const ge=de();if(ge===0){te();return}R(ge),ce.current=setTimeout(ue,_j)};ce.current=setTimeout(ue,0)},[de,te,R]),Z=m.useCallback(()=>{K.current.clear(),$.current=md,X.current=hd,q(),te(),ie.current&&(ie.current=!1,b()),v(!1),h(),p(fd,{keys:[],vector:md,aux:hd})},[p,v,h,b,q,te]),ee=m.useCallback(oe=>{const ue=k;if(!ue?.enabled||!ue?.connected||ue?.lightPolicy?.locked||ue?.lightPolicy?.lockedOn)return;const ve=(ue.entities||[]).filter(ye=>(ye.type==="light"||ye.type==="switch")&&ye.available!==!1&&ye.state!=="unavailable");if(ve.length!==0){if(oe==="on"){const ye=ve.find(Ye=>Ye.state!=="on");ye&&S(ye.id,"on").catch(()=>{});return}if(oe==="off")for(let ye=ve.length-1;ye>=0;ye-=1){const Ye=ve[ye];if(Ye.state==="on"){S(Ye.id,"off").catch(()=>{});break}}}},[S,k]);m.useEffect(()=>{function oe(ve){if(nx()||iN(ve))return;const ye=Pp(ve);if(ye.length===0)return;const Ye=new Set(ye);if(ft(C.chatFocus,Ye)){ve.preventDefault(),Z(),T||w();return}ye.some(Me=>L.has(Me))&&ve.preventDefault();const Ke=ye.filter(Me=>!K.current.has(Me));if(Ke.forEach(Me=>K.current.add(Me)),Ke.length>0)if(Ke.some(Me=>C.driveMacro?.has(Me)))s("drive"),f("drive-sequence");else if(Ke.some(Me=>C.dockMacro?.has(Me)))s("dock"),f("seek-dock");else if(Ke.some(Me=>C.nightVisionToggle?.has(Me)))x();else if(Ke.some(Me=>C.hornHonk?.has(Me))){if(!ie.current){const Me=g();ie.current=!!Me}}else Ke.some(Me=>C.micPtt?.has(Me))?v(!0):Ke.some(Me=>C.homeAssistantOn?.has(Me))?ee("on"):Ke.some(Me=>C.homeAssistantOff?.has(Me))&&ee("off");J(),_(),V()}function ue(ve){if(nx())return;Pp(ve).forEach(Ye=>K.current.delete(Ye)),ie.current&&!ft(C.hornHonk,K.current)&&(ie.current=!1,b()),ft(C.micPtt,K.current)||v(!1),J(),_(),V()}function ge(){Z()}return window.addEventListener("keydown",oe,{capture:!0}),window.addEventListener("keyup",ue,{capture:!0}),window.addEventListener("blur",ge),()=>{window.removeEventListener("keydown",oe,{capture:!0}),window.removeEventListener("keyup",ue,{capture:!0}),window.removeEventListener("blur",ge)}},[L,j,V,J,_,w,T,C.chatFocus,C.dockMacro,C.driveMacro,C.hornHonk,C.micPtt,Z,f,v,s,h,te,g,b,ee]);const fe=m.useRef(Z);return m.useEffect(()=>{fe.current=Z},[Z]),m.useEffect(()=>{fe.current()},[n.roverId]),m.useEffect(()=>{ie.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{q(),te()},[q,te]),null}const dN=1.6;function Mg(n){if(!n)return"unknown::none::0::0";const s=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`${s}::${r}::${o}::${u}`}function fN(n){return JSON.parse(JSON.stringify(n??{}))}function Rg(n,s){const r=fN(s);return r.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},r}function cs(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function pr(n,s){if(!n)return 0;const r=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(r,dN):n}function xd(n,s){const r=Math.abs(n);if(r<=s)return 0;const o=(r-s)/(1-s);return Math.sign(n)*o}function mN(n,s,r){const o=Math.hypot(n,s);if(o<=r)return{x:0,y:0};const f=(o-r)/(1-r)/o;return{x:n*f,y:s*f}}function Co(n,s){if(!n||!Array.isArray(n.axes))return null;const r=n.axes[s];return Number.isFinite(r)?cs(r):null}function $d(n,s){if(!n||!Array.isArray(n.buttons))return null;const r=n.buttons[s];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 gd(n,s=[]){for(const r of s)if(r){if(r.kind==="axis"){const o=Co(n,r.index);if(o===null)continue;return{value:r.invert?-o:o,source:r}}if(r.kind==="buttonAxis"){const o=$d(n,r.index);if(!o)continue;return{value:cs(o.value),source:r}}}return{value:0,source:null}}function hN(n,s=[]){for(const r of s){if(!r||r.kind!=="axisPair")continue;const o=Co(n,r.x),u=Co(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 ss(n,s=[]){for(const r of s)if(r){if(r.kind==="button"){const o=$d(n,r.index);if(!o)continue;return{pressed:o.pressed,source:r}}if(r.kind==="axisButton"){const o=Co(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=$d(n,r.index);if(!o)continue;return{pressed:o.value>.5,source:r}}}return{pressed:!1,source:null}}function Tg(n,s){const r=s?.bindings??{},o=s?.calibration??{},u=r.drive??{},f=hN(n,u.sources);let h=cs(f.x),p=cs(f.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=mN(h,p,x);h=pr(g.x,o.driveCurve),p=pr(g.y,o.driveCurve);const b=r.cameraTilt??{},v=gd(n,b.sources),N=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let M=xd(cs(v.value),N);M=pr(M,o.cameraCurve);const k=Math.min(Math.max(o.auxDeadzone??.05,0),.6),S=r.mainBrush??{},w=gd(n,S.sources);let j=xd(cs(w.value),k);j=pr(j,o.auxCurve);const T=r.sideBrush??{},E=gd(n,T.sources);let C=xd(cs(E.value),k);C=pr(C,o.auxCurve);const L=ss(n,r.vacuum?.sources),G=ss(n,r.allAux?.sources),O=ss(n,r.mainReverse?.sources),z=ss(n,r.sideReverse?.sources),K=ss(n,r.driveMacro?.sources),$=ss(n,r.dockMacro?.sources),X=ss(n,r.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:M,auxAxis:{main:j,side:C},buttons:{vacuum:L.pressed,allAux:G.pressed,mainReverse:O.pressed,sideReverse:z.pressed,driveMacro:K.pressed,dockMacro:$.pressed,nightVisionToggle:X.pressed},sources:{drive:f.source,cameraTilt:v.source,mainBrush:w.source,sideBrush:E.source,vacuum:L.source,allAux:G.source,mainReverse:O.source,sideReverse:z.source,driveMacro:K.source,dockMacro:$.source,nightVisionToggle:X.source}}}const vr=new Set;let al=null,il={pads:[],timestamp:0},lo=!1,ro=null;function lx(){return qg().some(n=>n?.connected!==!1)}function qg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function pN(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0})),signature:Mg(n)}}function ko(){il={pads:qg().map(pN),timestamp:typeof performance<"u"?performance.now():Date.now()},vr.forEach(s=>s(il))}function Dg(){if(ko(),il.pads.length===0){Gd();return}al=requestAnimationFrame(Dg)}function rx(){al||(ko(),il.pads.length!==0&&(al=requestAnimationFrame(Dg)))}function Gd(){al&&(cancelAnimationFrame(al),al=null)}function _g(n){if(vr.add(n),!lo&&typeof window<"u"){const s=()=>{ko(),vr.size!==0&&(lx()?rx():Gd())};window.addEventListener("gamepadconnected",s),window.addEventListener("gamepaddisconnected",s),ro=s,lo=!0}return lx()?rx():ko(),n(il),()=>{vr.delete(n),vr.size===0&&(Gd(),lo&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",ro),window.removeEventListener("gamepaddisconnected",ro),ro=null,lo=!1))}}function xN(){const[n,s]=m.useState(il);return m.useEffect(()=>_g(s),[]),n}const Ps="gamepad",ls={x:0,y:0,boost:!1},rs={main:0,side:0,vacuum:0},gN=100,bN=100;function bd(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function vd(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function vN(n){return n?Math.hypot(n.x||0,n.y||0):0}function yN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function SN(n,s){if(!n||n.length===0)return null;if(s){const r=n.find(o=>o.signature===s);if(r)return r}return n[0]}function jN(){const{state:n,actions:{setMode:s,setDriveVector:r,setAuxMotors:o,setServoAngle:u,runMacro:f,toggleNightVision:h,registerInputState:p}}=At(),{value:x,save:g}=Fe("gamepad",La),b=m.useRef(new Set),v=m.useRef(ls),N=m.useRef(rs),M=m.useRef({main:!1,side:!1}),k=m.useRef(new Map),S=m.useRef(0),w=m.useRef(0),j=m.useRef(0),T=m.useRef(null),E=m.useCallback(O=>{const z=O.signature??Mg(O);x?.profiles?.[z]||b.current.has(z)||(b.current.add(z),g(K=>{const $=K??La;if($.profiles?.[z])return $;const X=$?.defaults?.profile??oa,P=Rg(O,X);return{...$,profiles:{...$.profiles??{},[z]:P}}}))},[x?.profiles,g]),C=m.useCallback((O,z)=>{const K=k.current.get(O)||!1;return k.current.set(O,z),z&&!K},[]),L=m.useCallback((O,z)=>{const K=n.camera?.config;if(!K)return;const $=typeof performance<"u"?performance.now():Date.now(),X=z?.cameraMode??"absolute",P=Math.max(1,Math.min(180,z?.cameraSensitivity??60));if(X==="velocity"){const H=Math.min(50,$-j.current||16),J=O*P*(H/1e3);if(Math.abs(J)<.01)return;const de=(typeof T.current=="number"?T.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof K.homeAngle=="number"?K.homeAngle:0)+J;u(de),T.current=de,j.current=$;return}const ce=typeof K.minAngle=="number"?K.minAngle:-45,ie=typeof K.maxAngle=="number"?K.maxAngle:45,V=typeof K.homeAngle=="number"?K.homeAngle:(ce+ie)/2,q=O<0?V+O*(V-ce):V+O*(ie-V);typeof T.current=="number"&&Math.abs(T.current-q)<.35&&$-j.current<80||(j.current=$,T.current=q,u(q))},[u,n.camera?.angle,n.camera?.config]),G=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>_g(O=>{const z=SN(O.pads,G);if(!z){bd(v.current,ls)||(v.current=ls,r(ls,{source:Ps})),vd(N.current,rs)||(N.current=rs,o(rs)),k.current=new Map,M.current={main:!1,side:!1},S.current=0,w.current=0,p(Ps,{connected:!1});return}if(aN()){bd(v.current,ls)||(v.current=ls,r(ls,{source:Ps})),vd(N.current,rs)||(N.current=rs,o(rs)),k.current=new Map,M.current={main:!1,side:!1},p(Ps,{connected:!0,blocked:!0});return}E(z);const K=z.signature,$=x?.profiles?.[K]??x?.defaults?.profile??oa,X=Tg(z,$);if(!bd(X.driveVector,v.current)){const J=typeof performance<"u"?performance.now():Date.now();(vN(X.driveVector)<.02||J-S.current>=gN)&&(v.current=X.driveVector,S.current=J,r(X.driveVector,{source:Ps}))}const P=$.calibration?.auxSideScale??.55,ce=Math.round(Math.min(Math.abs(X.auxAxis.main),1)*127),ie=Math.round(Math.min(Math.abs(X.auxAxis.side),1)*127),V=M.current.main?-ce:ce,q=M.current.side?-Math.round(ie*P):Math.round(ie*P);let H={main:X.auxAxis.main!==0?V:0,side:X.auxAxis.side!==0?q:0,vacuum:X.buttons.vacuum?127:0};if(X.buttons.allAux&&(H={main:127,side:127,vacuum:127}),!vd(H,N.current)){const J=typeof performance<"u"?performance.now():Date.now();(yN(H)||J-w.current>=bN)&&(N.current=H,w.current=J,o(H))}X.buttons.mainReverse&&C("mainReverse",!0)?M.current.main=!M.current.main:X.buttons.mainReverse||C("mainReverse",!1),X.buttons.sideReverse&&C("sideReverse",!0)?M.current.side=!M.current.side:X.buttons.sideReverse||C("sideReverse",!1),X.buttons.driveMacro&&C("driveMacro",!0)?(s("drive"),f("drive-sequence")):X.buttons.driveMacro||C("driveMacro",!1),X.buttons.dockMacro&&C("dockMacro",!0)?(s("dock"),f("seek-dock")):X.buttons.dockMacro||C("dockMacro",!1),X.buttons.nightVisionToggle&&C("nightVisionToggle",!0)?h():X.buttons.nightVisionToggle||C("nightVisionToggle",!1),Math.abs(X.cameraAxis)>.001&&L(X.cameraAxis,$.calibration),p(Ps,{connected:!0,signature:K,id:z.id,index:z.index,axes:z.axes,buttons:z.buttons,drive:X.driveVector,aux:H,cameraAxis:X.cameraAxis,bindings:X.sources})}),[G,E,x?.defaults?.profile,x?.profiles,C,L,p,f,o,r,s,h]),null}function Og(n){const s=n?.sensors||{},r=s.oiMode?.label||"Unknown",o=r.toLowerCase(),u=s.chargingState?.label||"",f=!!s.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 Bg(n){const s=dl(n);return m.useMemo(()=>Og(s),[s])}function Ws({label:n,value:s,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:s})})}function ix({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function yd({label:n,tone:s}){const r=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return l.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${r}`,children:n})}function NN({instructions:n,onConfirm:s,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(Fd,{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:s,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Docking…":"Confirm Dock"})]})]})})}function Lg({layout:n="desktop",expand:s=!1,fill:r=!1,driveDockState:o,compactHeightClass:u=""}){const f=n==="mobile",{state:{roverId:h,keymap:p},actions:x}=At(),g=dl(h),b=o??Og(g),{driving:v,docked:N,charging:M,dockingInProgress:k}=b,[S,w]=m.useState(null),[j,T]=m.useState(!1),[E,C]=m.useState(!1),L=!h||S!==null,G=!h||S!==null,O=qt(p?.driveMacro?.[0]),z=qt(p?.dockMacro?.[0]),K={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},$="Click this button to initate auto-dock.",X={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=N?"Docked":"Undocked",ce=N?"good":"bad",ie=M?"Charging":N?"Charging in 5s":"—",V=M?"good":N?"warn":"bad",q=async()=>{if(!(!h||S)){w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(_e){alert(_e.message)}finally{w(null)}}},H=async()=>{if(!(!h||S)){T(!1),C(!1),w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(_e){alert(_e.message)}finally{w(null)}}},J=async()=>{if(!(!h||S)){w("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(_e){alert(_e.message)}finally{w(null),T(!1),C(!1)}}},te=()=>{G||(C(!0),T(!0))},de="flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-0.75 py-0.75 text-slate-100 shadow-md transition hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 select-none no-touch-select",R="text-center",_="items-center justify-between",Z="items-center justify-center",ee=f?"text-sm font-semibold":"",fe="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",oe="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ue="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ge="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",ye=s||k,Ye=ye?"h-full flex-1":r?"flex-1":"",Ke=f&&!ye?u:"",Me=f&&!ye?Z:_,De=f&&!ye&&v&&N;if(!v&&!k)return l.jsxs("button",{type:"button",onClick:H,onContextMenu:_e=>_e.preventDefault(),disabled:L,className:`${de} ${Ye} ${Ke} ${R} ${Me} ${ee} ${fe}`,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&&ye?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[O?l.jsx(ix,{label:O}):null,l.jsx(yd,{label:"Click to start",tone:"emerald"})]}):null]}),ye?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-emerald-50/90",children:X.summary}),l.jsx(Fd,{steps:X.steps,tone:"emerald"})]}):null]}),ye?l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Ws,{label:"Dock",value:P,tone:ce}),l.jsx(Ws,{label:"Charge",value:ie,tone:V})]}):null]});if(k){const _e={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:Ct=>Ct.preventDefault(),className:`${de} ${Ye} ${Ke} ${R} ${Me} ${ee} ${oe}`,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"}),ye?l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:l.jsx(yd,{label:"Return to driving mode",tone:"emerald"})}):null]}),ye?l.jsx("p",{className:"text-sm text-amber-50/90",children:_e.summary}):null]}),ye?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Ws,{label:"Dock",value:P,tone:ce}),l.jsx(Ws,{label:"Charge",value:ie,tone:V})]}),f?null:l.jsx(Fd,{steps:_e.steps,tone:"amber"})]}):null]})}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",disabled:G,onClick:te,onContextMenu:_e=>_e.preventDefault(),className:f?`flex w-full ${de} ${Ke} ${R} ${Me} ${ee} ${De?ge:ue}`:`${de} ${Ye} ${R} ${_} ${ee} ${ue}`,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:De?"Docked!":"Dock and Charge"}),!f&&ye?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[z?l.jsx(ix,{label:z}):null,l.jsx(yd,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!f&&ye&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-indigo-50/90",children:$}),l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Ws,{label:"Dock",value:P,tone:ce}),l.jsx(Ws,{label:"Charge",value:ie,tone:V})]}),l.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),E||!f&&j?l.jsx(NN,{instructions:K,pending:S==="dock",onCancel:()=>{C(!1),T(!1)},onConfirm:J}):null]})}function Fd({steps:n,tone:s="emerald"}){const r=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return 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 Sd(n){return typeof n=="boolean"}function zg({nightVisionOn:n,disabled:s,onToggle:r,keyLabel:o,className:u="",heightClass:f=""}){const[h,p]=m.useState(Sd(n)?n:null);m.useEffect(()=>{Sd(n)&&p(n)},[n]);const x=Sd(h),g=x?h:!1,b=x?g?"On":"Off":"—",v=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",N=()=>{if(s)return;const k=x?!g:!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",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",f,u].filter(Boolean).join(" "),[u,g,f]);return l.jsxs("button",{type:"button",onClick:N,onContextMenu:k=>k.preventDefault(),disabled:s,"aria-pressed":g,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 ${v}`,children:b})]})}function jd(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function Ug({disabled:n,onStart:s,onStop:r,keyLabel:o,active:u,heat:f=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[b,v]=m.useState(!1),[N,M]=m.useState(p),{value:k,save:S}=Fe("horn",us),[w,j]=m.useState(k?.waveform||us.waveform),[T,E]=m.useState(()=>[...Array.isArray(k?.freqs)?k.freqs:us.freqs,0,0,0,0].slice(0,4).map(q=>jd(q)));m.useEffect(()=>{j(k?.waveform||us.waveform),Array.isArray(k?.freqs)&&E([...k.freqs,0,0,0,0].slice(0,4).map(V=>jd(V)))},[k?.freqs,k?.waveform]);const C=!!u,L=Math.max(0,Math.min(1,Number(f)||0)),G=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",C?"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,C]),O=()=>{n||b||(v(!0),s?.())},z=()=>{b&&(v(!1),r?.())};m.useEffect(()=>{!C&&b&&v(!1)},[C,b]);const K=w==="sine"?"sine":"saw",$=m.useCallback(V=>{const q=V.target.value==="sine"?"sine":"saw";j(q),S(H=>({...H??{},waveform:q}))},[S]),X=m.useCallback((V,q)=>{E(H=>{const J=[...H];return J[V]=jd(q),S(te=>({...te??{},freqs:J})),J})},[S]),P=V=>{if(n)return;const q=V.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(V.preventDefault(),O())},ce=V=>{const q=V.target?.tagName?.toLowerCase();q==="input"||q==="select"||q==="option"||q==="label"||q==="button"||(V.preventDefault(),z())},ie=x?l.jsx("button",{type:"button",onClick:V=>{V.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:N?"Hide":"Settings"}):null;return l.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":b,onPointerDown:P,onPointerUp:ce,onPointerLeave:z,onPointerCancel:z,onContextMenu:V=>V.preventDefault(),onBlur:z,className:G,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 ${C?"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 ${C?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:C?"Honk":"Hold"})]}),N?g?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:K,onChange:$,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:T.map((V,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:V,onChange:H=>X(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:K,onChange:$,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"})]})]}),T.map((V,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:V,onChange:H=>X(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 io(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function ox({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Hg({value:n,min:s,max:r,step:o=.5,label:u="Camera Tilt",orientation:f="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:b,keyUpLabel:v,className:N="",labelRowClass:M="",labelClass:k="",valueClass:S="",sliderClass:w="",endpointClass:j="",endpointLabelClass:T="",accentClass:E="",showValue:C=!0,showEndpoints:L}){const G=f==="vertical",z=typeof L=="boolean"?L:!G,[K,$]=m.useState(n),X=m.useRef(!1),P=m.useRef(null);m.useEffect(()=>{X.current||$(n)},[n]),m.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);const ce=J=>{if(h){if(x>0){P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{h(J)},x);return}h(J)}},ie=J=>{const te=Number.parseFloat(J.target.value);Number.isNaN(te)||(X.current=!0,$(te),ce(te))},V=()=>{X.current=!1,P.current&&(clearTimeout(P.current),P.current=null),p?p(K):x>0&&h?.(K)};if(typeof s!="number"||typeof r!="number")return null;const q=[G?"h-28 w-5":"w-full",E,w].filter(Boolean).join(" "),H=l.jsx("input",{type:"range",orient:G?"vertical":void 0,min:s,max:r,step:o,value:Number.isFinite(K)?K:s,onChange:ie,onMouseUp:V,onTouchEnd:V,onPointerUp:V,disabled:g,className:q,style:G?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return G?l.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${N}`.trim(),children:[C?l.jsx("div",{className:`flex flex-col items-center ${M}`.trim(),children:l.jsx("span",{className:S,children:io(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 ${N}`.trim(),children:[l.jsxs("div",{className:`flex items-center justify-between ${M}`.trim(),children:[l.jsx("span",{className:k,children:u}),C?l.jsx("span",{className:S,children:io(n)}):null]}),l.jsxs("div",{children:[H,z?l.jsxs("div",{className:`mt-0 flex items-center justify-between ${j}`.trim(),children:[l.jsxs("span",{className:`flex items-center gap-0.5 ${T}`.trim(),children:[b?l.jsx(ox,{label:b}):null,io(s)]}),l.jsxs("span",{className:`flex items-center gap-0.5 ${T}`.trim(),children:[io(r),v?l.jsx(ox,{label:v}):null]})]}):null]})]})}function wN({disabled:n,layout:s,radius:r,onMove:o,onStop:u}){const f=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),b=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),u?.()},[u]),v=m.useCallback(S=>{if(n||h.current!==null)return;S.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),T=S.clientX-j.left,E=S.clientY-j.top;p.current={x:T,y:E},h.current=S.pointerId,w.setPointerCapture?.(S.pointerId),g({active:!0,base:{x:T,y:E},knob:{x:0,y:0}})},[n]),N=m.useCallback(S=>{if(n||h.current!==S.pointerId)return;S.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),T=S.clientX-j.left,E=S.clientY-j.top,C=T-p.current.x,L=E-p.current.y,G=Math.min(Math.hypot(C,L),r),O=Math.atan2(L,C),z=Math.cos(O)*G,K=Math.sin(O)*G,$={x:rl(z/r),y:rl(-K/r),boost:!1};g(X=>({...X,knob:{x:z,y:K}})),o?.($)},[n,o,r]),M=m.useCallback(S=>{if(h.current!==S.pointerId)return;S.preventDefault(),f.current?.releasePointerCapture?.(S.pointerId),b()},[b]);return m.useEffect(()=>{n&&b()},[n,b]),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:v,onPointerMove:N,onPointerUp:M,onPointerLeave:M,onPointerCancel:M,onContextMenu:S=>S.preventDefault(),children:[!x.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"})]}),x.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:x.base.x,top:x.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:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function cx({id:n,label:s,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:s})}const oo="mobile-joystick",AN=80,CN=.15,kN={main:0,side:0,vacuum:0},EN={main:127,side:127,vacuum:127},MN={main:-127,side:-127,vacuum:-127};function RN({layout:n}){const{state:{roverId:s},actions:{setDriveVector:r,registerInputState:o}}=At(),u=Bg(s),f=u.docked&&!u.driving,h=f||u.dockingInProgress,p=!s,x=AN,g=CN,b=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(b.current={x:0,y:0,boost:!1})},[p]);const v=m.useCallback((S={})=>{if(p)return;const w={x:rl(S.x??0),y:rl(S.y??0),boost:!!S.boost},j={x:b.current.x+(w.x-b.current.x)*(1-g),y:b.current.y+(w.y-b.current.y)*(1-g),boost:w.boost};b.current=j,r(j,{source:oo}),o(oo,{vector:j,lastEvent:"move"})},[p,o,r,g]),N=m.useCallback(()=>{if(p)return;const S={x:0,y:0,boost:!1};b.current=S,r(S,{source:oo}),o(oo,{vector:S,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(Lg,{layout:"mobile",expand:h,driveDockState:u,compactHeightClass:"min-h-[5rem]"}),h?null:l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(wN,{disabled:p,layout:n,radius:x,onMove:v,onStop:N})})]})}function TN({layout:n}){const{state:{roverId:s,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=At(),b=!s,v=m.useRef(null),N=r?.config,M=!!(s&&r?.enabled&&N),k=!!(s&&u?.nightVision),S=u?.nightVisionState,w=!!(s&&u?.horn),j=o?.overheated,T=typeof N?.minAngle=="number"?N.minAngle:-45,E=typeof N?.maxAngle=="number"?N.maxAngle:45,C=typeof r?.angle=="number"?r.angle:typeof N?.homeAngle=="number"?N.homeAngle:(T+E)/2,L=m.useCallback(z=>{k&&h(z)},[k,h]),G=m.useCallback((z,K)=>{b||(v.current=z,p(K))},[b,p]),O=m.useCallback(z=>{b||v.current===z&&(v.current=null,p(kN))},[b,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(cx,{id:"aux-vac-forward",label:"Vacuum Forward",values:EN,color:"bg-fuchsia-600",disabled:b,onPress:G,onRelease:O}),l.jsx(cx,{id:"aux-vac-backward",label:"Vacuum Backward",values:MN,color:"bg-fuchsia-800",disabled:b,onPress:G,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(Hg,{value:C,min:T,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(zg,{nightVisionOn:S?.nightVisionOn,disabled:b,onToggle:L,heightClass:"h-full"}):null]}),l.jsx("div",{className:"min-h-0",children:w?l.jsx(Ug,{disabled:b||j,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function Eo({layout:n,className:s=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:l.jsx(TN,{layout:n})})}function Mo({layout:n,className:s=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:l.jsx(RN,{layout:n==="landscape"?"landscape":"portrait"})})}function qN({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",r=n?l.jsx(Mo,{layout:"portrait",className:s}):l.jsx(Eo,{layout:"portrait",className:s}),o=n?l.jsx(Eo,{layout:"portrait",className:s}):l.jsx(Mo,{layout:"portrait",className:s});return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r,o]})})}function DN(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(S=>typeof S=="string"?S:S.id),[n]),g=m.useMemo(()=>{const S=x.join("|");return u?`${S}|v:${u}`:S},[x,u]),b=m.useRef([]),[v,N]=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 S=()=>N(w=>w+1);return r.on("connect",S),()=>r.off("connect",S)},[r]),m.useEffect(()=>{b.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(S=>URL.revokeObjectURL(S)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!b.current.length||!r)return;let S=!1;const w=b.current,j=(E={},C)=>{if(S||!E.id||!C)return;const L=C.byteLength??C.length??0,G=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||G-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=G}M.current.set(E.id,z);const K=new Blob([C],{type:"image/jpeg"}),$=URL.createObjectURL(K),X=p.current.get(E.id);X&&URL.revokeObjectURL(X),p.current.set(E.id,$),h(P=>({...P,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:$}}))},T=(E={})=>{S||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return r.on("roomCamera:frame",j),r.on("roomCamera:status",T),r.emit("roomCamera:subscribe",{ids:w},(E={})=>{E.error}),()=>{S=!0,r.emit("roomCamera:unsubscribe",{ids:w}),r.off("roomCamera:frame",j),r.off("roomCamera:status",T),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[r,g,o,v,k]),f}function _N({feed:n,label:s}){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:s,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:s}),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 ON(){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 Vg=["horizontal","vertical"];function Nd(n,s){return Vg.includes(n)?n:s}function bf({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:r=!1,hideHeader:o=!1,panelId:u=null}){const f=xe(S=>S.session?.roomCameras||[]),h=DN(f.map(S=>({id:S.id}))),{value:p,save:x}=Fe("roomCameraPanels",{}),[g,b]=m.useState(()=>Nd(u?p?.[u]:n,"horizontal"));m.useEffect(()=>{if(!u)return;const S=p?.[u];S&&b(Nd(S,"horizontal"))},[u,p?.[u]]);const v=s?Nd(s,"horizontal"):g,N=v==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",M=!r&&!s&&f.length>0,k=S=>{b(S),u&&x(w=>({...w||{},[u]:S}))};return f.length===0?l.jsx(ON,{}):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:Vg.map(S=>l.jsx("button",{type:"button",className:`px-1 py-0.5 ${v===S?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>k(S),children:S==="vertical"?"Vertical":"Grid"},S))})]})})]}),l.jsx("div",{className:N,children:f.map(S=>{const w=h[S.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(_N,{feed:w,label:S.name||S.id})},S.id)})})]})}function vf(){const n=xe(r=>r.logs),s=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."}):s.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))})]})}function BN(n){if(!n)return null;if(typeof n=="string"){const s=String(n).trim();return s?{type:"rover",id:s,key:s}:null}if(typeof n=="object"){if(n.type&&n.id){const s=String(n.id);let r=n.key;return r||(r=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:r}}if(n.roverId){const s=String(n.roverId);return{type:"rover",id:s,key:n.key||s}}if(n.roomCameraId){const s=String(n.roomCameraId);return{type:"room",id:s,key:n.key||`room:${s}`}}}return null}function LN(n=[]){const s=new Set,r=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),r.push(o))}),r.sort((o,u)=>o.key.localeCompare(u.key))}function Cr(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(n)?LN(n.map(BN).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const M=p.map(k=>`${k.type}:${k.id}:${k.key}`).join("|");return u?`${M}|v:${u}`:M},[p,u]),g=m.useRef([]),[b,v]=m.useState(0);return m.useEffect(()=>{if(!r)return;const M=()=>v(k=>k+1);return r.on("connect",M),()=>{r.off("connect",M)}},[r]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const M=g.current;let k=!1;function S(w){const j=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};r.emit("video:request",j,(T={})=>{k||h(E=>({...E,[w.key]:T}))})}return M.forEach(w=>{S(w)}),()=>{k=!0}},[r,x,o,b]),m.useMemo(()=>{if(!x||!o)return{};const M={};return p.forEach(k=>{f[k.key]&&(M[k.key]=f[k.key])}),M},[x,f,p])}function yf(n=[],s={}){const r=sn(),{enabled:o=!0,version:u=null}=s,[f,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(S=>typeof S=="string"?S:S.id).filter(Boolean),[n]),g=m.useMemo(()=>{const S=x.join("|");return u?`${S}|v:${u}`:S},[x,u]),b=m.useRef([]),[v,N]=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 S=()=>N(w=>w+1);return r.on("connect",S),()=>r.off("connect",S)},[r]),m.useEffect(()=>{b.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(S=>URL.revokeObjectURL(S)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear(),h({});return}if(!b.current.length||!r)return;let S=!1;const w=b.current,j=(E={},C)=>{if(S||!E.id||!C)return;const L=C.byteLength??C.length??0,G=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||G-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=G}M.current.set(E.id,z);const K=new Blob([C],{type:"image/jpeg"}),$=URL.createObjectURL(K),X=p.current.get(E.id);X&&URL.revokeObjectURL(X),p.current.set(E.id,$),h(P=>({...P,[E.id]:{status:"playing",ts:E.ts||Date.now(),error:null,objectUrl:$}}))},T=(E={})=>{S||!E.id||h(C=>({...C,[E.id]:{...C[E.id]||{},status:E.error?"error":C[E.id]?.status||"connecting",error:E.error||null,ts:E.ts||C[E.id]?.ts||null,objectUrl:C[E.id]?.objectUrl||null}}))};return r.on("roverSnapshot:frame",j),r.on("roverSnapshot:status",T),r.emit("roverSnapshot:subscribe",{ids:w},(E={})=>{E.error}),()=>{S=!0,r.emit("roverSnapshot:unsubscribe",{ids:w}),r.off("roverSnapshot:frame",j),r.off("roverSnapshot:status",T),p.current.forEach(E=>URL.revokeObjectURL(E)),p.current.clear()}},[r,g,o,v,k]),f}const zN={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function UN(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 HN(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${UN(s)}`}}class ux{constructor({url:s,token:r,video:o,onStatus:u,audioOnly:f=!1,receiveAudio:h=!0}){this.url=s,this.token=r,this.video=o,this.audioOnly=f,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=u}notify(s,r){typeof this.onStatus=="function"&&this.onStatus(s,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 s=new RTCPeerConnection(zN);this.pc=s;const r=new MediaStream;s.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?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const u=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...HN(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 s.setRemoteDescription({type:"answer",sdp:f}),s.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function $g(){const{value:n,save:s}=Fe("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,u=>{s({hudMapDesktop:!!u})}]}const VN={discord:gg,kofi:Fp,"ko-fi":Fp,wiki:Nj,throne:wj},$N={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 GN(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const s=document.createElement("style");s.id=n,s.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(s)},[])}function FN(n,s){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof s=="string"&&s.trim()?s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function kr({id:n,label:s,url:r,className:o=""}){if(!r)return null;GN();const u=FN(n,s),f=VN[u]||Aj,h=$N[u]||null,p=s||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]})}const Er=10;function Gg({batteryState:n=null,charge:s=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,x=r?.Urgent??null,g=s??n?.charge??null;let b=o;if(b==null&&(b=YN({charge:g,full:h,warn:p,urgent:x})),b==null)return{available:!1};const v=Math.max(0,Math.min(1,b/100)),N=u??(p!=null&&g!=null&&g<=p),M=f??(x!=null&&g!=null&&g<=x);return{available:!0,percent:v,percentDisplay:b,warnActive:N,urgentActive:M,warnDisplayPercent:Er}}function YN({charge:n,full:s,warn:r,urgent:o}){if(n!=null&&s!=null&&r!=null&&o!=null&&s>r&&r>o){const u=Er/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))*Er)}if(n>=s)return 100;const h=(n-r)/(s-r);return Math.round((u+Math.max(0,Math.min(1,h))*f)*100)}return null}const XN=1600,QN=800;function Cn(...n){return n.filter(Boolean).join(" ")}function KN({visual:n,orientation:s="horizontal",variant:r="inline",compact:o=!1,showLabel:u,className:f=""}){const h=r==="background",p=s==="vertical",x=u??!h;if(!n?.available){if(h){const P=Er,ce=Cn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),ie=p?{bottom:`${P}%`}:{left:`${P}%`},V=Cn("absolute inset-0 pointer-events-none",f);return l.jsxs("div",{className:V,children:[l.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),l.jsx("div",{className:ce,style:ie})]})}return p?null:l.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,b=Math.max(0,Math.min(100,g)),v=n.warnDisplayPercent??Er,N=!!n.urgentActive,M=!!n.warnActive,k=N?`${QN}ms`:M?`${XN}ms`:void 0,w=h?N||M?"bg-red-500/45":"bg-emerald-500/45":N||M?"bg-red-500":"bg-emerald-500",j=N||M?"bg-red-900/35":"bg-slate-900/35",T=N||M?"bg-red-900/45":"bg-slate-900/35",E=Cn(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:`${b}%`}:{width:`${b}%`},ce=Cn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",N&&"battery-urgent-flash"),ie=Cn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),V=p?{bottom:`${v}%`}:{left:`${v}%`};return l.jsxs("div",{className:E,children:[l.jsx("div",{className:Cn("absolute inset-0",j,N&&"battery-urgent-flash")}),l.jsx("div",{className:ce,style:{...P,animationDuration:k}}),l.jsx("div",{className:ie,style:V})]})}const C=Cn("relative overflow-hidden rounded-sm border border-slate-800",N||M?T:"bg-zinc-900/90",N&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),L=p?{height:`${b}%`}:{width:`${b}%`},G=Cn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",N&&"battery-urgent-flash"),O=Cn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",M&&!N&&"battery-tick-warn"),z=p?{bottom:`${v}%`}:{left:`${v}%`},K=`Battery ${g}%`,$=Cn("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"),X=Cn("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:C,children:[l.jsx("div",{className:G,style:{...L,animationDuration:k}}),l.jsx("div",{className:O,style:z})]}),x&&!p?l.jsx("div",{className:$,children:l.jsx("span",{className:X,children:K})}):null,x&&p?l.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:l.jsxs("span",{className:X,children:[g,"%"]})}):null]})}const Yd=an.memo(KN);function IN({mobileHud:n=!1,isActiveDriver:s=!1,idleSkipSeconds:r=null}){const o=n?"text-3xl":"text-5xl",u=n?"text-xs":"text-sm",f=n?"text-[0.55rem]":"text-[0.75rem]",h=n?"px-4 py-3":"px-6 py-4",p=s&&typeof r=="number";return 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 ${h}`,children:[l.jsx("div",{className:`font-semibold text-amber-200 ${o}`,children:"IT IS YOUR TURN!"}),l.jsx("div",{className:`text-amber-200/80 ${u}`,children:"Start driving!"}),p?l.jsxs("div",{className:`text-red-100/90 ${f}`,children:["Idle skip in ",r,"s"]}):null]})})}function zo(n){return Math.max(0,Math.min(1,n))}function Fg(n){return(n-90)*Math.PI/180}function Sr(n,s,r,o){const u=Fg(o);return{x:n+r*Math.cos(u),y:s+r*Math.sin(u)}}function ZN(n,s,r,o,u){let f=o,h=u;h<=f&&(h+=360);const p=Sr(n,s,r,f),x=Sr(n,s,r,h);return["M",p.x,p.y,"A",r,r,0,0,1,x.x,x.y].join(" ")}function Sf(n,s){if(s)return"#ef4444";const r=Math.abs(n);return r>900?"#f59e0b":r>300?"#22c55e":"#64748b"}function JN(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=zo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function PN(n,s){if(s)return"#ef4444";const r=zo(n==null?0:n/4095),o=[47,55,69],u=[245,158,11],[f,h,p]=o.map((x,g)=>Math.round(x+(u[g]-x)*r));return`rgb(${f}, ${h}, ${p})`}function WN({count:n,totalSpan:s,gap:r,startAngle:o}){const f=(s-r*(n-1))/n,h=[];let p=o;for(let x=0;x<n;x+=1){const g=p+f;h.push({start:p,end:g}),p=g+r}return h}function wd({cx:n,cy:s,rInner:r,rOuter:o,startDeg:u,endDeg:f,color:h,pulse:p=!1,opacity:x=1}){const g=(r+o)/2,b=o-r,v=ZN(n,s,g,u,f);return l.jsxs(l.Fragment,{children:[l.jsx("path",{d:v,stroke:h,strokeWidth:b,strokeLinecap:"round",fill:"none",opacity:x}),p?l.jsx("path",{d:v,stroke:"#ef4444",strokeWidth:b,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function ew({cx:n,cy:s,rBase:r,rTip:o,startDeg:u,endDeg:f,color:h,value:p,max:x}){const g=(u+f)/2,b=Sr(n,s,o,g),v=zo(p!=null?p/(x||1):0),N=Math.pow(v,.35),M=r-(r-o)*N,k=Math.max(o,Math.min(M,r)),S=Sr(n,s,k,u),w=Sr(n,s,k,f),j=`M ${b.x} ${b.y} L ${S.x} ${S.y} L ${w.x} ${w.y} Z`;return l.jsx("path",{d:j,fill:h,opacity:1,stroke:"none"})}function dx({cx:n,cy:s,current:r,drop:o,overcurrent:u,label:f}){const h=Math.abs(r),p=zo(h/1200),x=Sf(r,u),g=56,b=14,v=9,N=3,M=g*p,k=f==="L"?-1:1,S=k*(-v/2-N/2),w=k*(b/2+N/2),j=b+v+N+2,T=g+4;return l.jsxs("g",{transform:`translate(${n},${s})`,children:[l.jsx("rect",{x:-j/2,y:-T/2,width:j,height:T,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:S-b/2,y:-g/2,width:b,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),l.jsx("rect",{x:S-b/2,y:g/2-M,width:b,height:M,fill:x,className:u?"animate-pulse":""}),l.jsx("rect",{x:w-v/2,y:-g/2,width:v,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),l.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:f})]})}function tw({cx:n,cy:s,current:r,overcurrent:o}){let u=Math.abs(r);u<10&&(u=0);const f=Sf(r*3,o),h=43,p=u>0?.65:null;return l.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[l.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const b=Fg(g),v=n+h*Math.cos(b),N=s+h*Math.sin(b);return l.jsx("line",{x1:n,y1:s,x2:v,y2:N,stroke:f,strokeWidth:"4",strokeLinecap:"round"},g)}),o?l.jsx("circle",{cx:n,cy:s,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function nw({cx:n,cy:s,current:r,overcurrent:o,variant:u,dirtLeft:f,dirtRight:h}){const p=Math.abs(r),x=Sf(r,o),g=1,b=96,v=12,N=`main-brush-pattern-a-${u}`,M=`main-brush-pattern-b-${u}`,k=p>0?.6:null,S=r>=0?1:-1;return l.jsxs("g",{children:[l.jsx("defs",{children:[N,M].map((w,j)=>l.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[l.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),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 ${S*(j===0?6:-6)}`,dur:`${k}s`,repeatCount:"indefinite"}):null]},w))}),l.jsx("rect",{x:n-b/2,y:s-14,width:b,height:v,rx:"3",fill:`url(#${N})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:n-b/2,y:s+4,width:b,height:v,rx:"3",fill:`url(#${M})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("circle",{cx:n-b/4,cy:s-8,r:3.5,fill:"#fbbf24"}),l.jsx("circle",{cx:n+b/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?l.jsx("rect",{x:n-b/2-4,y:s-16,width:b+8,height:v*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function aw({sensors:n={},variant:s="full",size:r,overlay:o=!1}){const u=r||(s==="mini"?190:260),f=u/2,h=u*.07,p=f,x=f+h,g=f*.8,b=g-4,v=g+4,N=g-14,M=g-6,k=g*.65,S=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},j=n?.wheelLeftCurrentMa??0,T=n?.wheelRightCurrentMa??0,E=n?.sideBrushCurrentMa??0,C=n?.mainBrushCurrentMa??0,L=6,G=S.bumpLeft?L:0,O=S.bumpRight?L:0,z=WN({count:6,totalSpan:140,gap:6,startAngle:-70}),K=["L","FL","CL","CR","FR","R"],$=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],X=z.map((V,q)=>({label:K[q],start:V.start,end:V.end,value:$[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}],ce=$.filter(V=>V!=null),ie=ce.length?Math.max(...ce,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:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),l.jsx(dx,{cx:p-k,cy:x,current:j,drop:S.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),l.jsx(dx,{cx:p+k,cy:x,current:T,drop:S.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),l.jsx(tw,{cx:p+g*.65,cy:x-g*.55,current:E,overcurrent:w.sideBrush}),l.jsx(nw,{cx:p,cy:x,current:C,overcurrent:w.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),X.map(V=>{const q=JN(V.value,ie),H=v+4,J=H+28;return l.jsx(ew,{cx:p,cy:x,rBase:J,rTip:H,startDeg:V.start,endDeg:V.end,color:q,value:V.value,max:ie},V.label)}),P.map(V=>l.jsx(wd,{cx:p,cy:x,rInner:N,rOuter:M,startDeg:V.start,endDeg:V.end,color:PN(V.value,V.active),opacity:1,pulse:!!V.active},V.label)),l.jsx(wd,{cx:p,cy:x,rInner:b-G,rOuter:v-G,startDeg:-70,endDeg:-6,color:S.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!S.bumpLeft}),l.jsx(wd,{cx:p,cy:x,rInner:b-O,rOuter:v-O,startDeg:6,endDeg:70,color:S.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!S.bumpRight})]})]})}const Xd=an.memo(aw);function sw({sensors:n,label:s,roverColor:r=null,status:o,audioStatus:u,levelStatus:f,layoutFormat:h="desktop",variant:p="default",driverLabel:x=null,showTopDown:g=!1,mobileHud:b=!1,mapPosition:v="top-center",turnTimerText:N=null,turnTimerFlashActive:M=!1,labelScale:k=1}){const S=b,w=h==="mobile-portrait",j=S?"text-[0.45rem]":"text-[0.65rem]",T=S?"px-0.25 py-0.25":"px-1 py-0.5",E=S?"px-0.25 py-0.25":"px-0.5 py-0.5",C=S?"text-[0.55rem]":"text-[0.8rem]",L=S?"left-0.5 top-0.5":"left-1 top-1",G=S?"text-[0.5rem]":"text-[0.7rem]",O=S?"px-0.5 py-0.25":"px-1 py-0.5",z=S?"left-0.5 top-1/2":"left-1 top-1/2",K="bottom-0.5",$={transform:`translateX(-50%) scale(${k})`,transformOrigin:"center bottom"},X="240px",P=w?.3:S?.33:.7,ie={width:X,height:X,opacity:S?.6:.7,transform:v==="top-center"?`translateX(-50%) scale(${P})`:`scale(${P})`,transformOrigin:v==="bottom-left"?"bottom left":v==="top-center"?"top center":"top right",...v==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:v==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(p==="none")return null;if(p==="spectator"){const V=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],q=!!n?.chargingSources?.homeBase,H=n?.chargingState?.label||"",J=!!(H&&H.toLowerCase()!=="not charging"),te=n?.oiMode?.label||"Unknown",de=te.toLowerCase(),R=de==="full"?"bg-emerald-500/80 text-emerald-50":de==="safe"?"bg-amber-400/80 text-amber-950":de==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",_=q?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",Z=J?"bg-emerald-500/80 text-emerald-50":q?"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 ${L} font-medium text-slate-100 ${j}`,children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",o]}),u?l.jsxs("span",{children:["Audio: ",u]}):null,f?l.jsx("span",{className:"text-cyan-300",children:f}):null]})}),l.jsx("div",{className:`absolute ${z} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${j} ${T}`,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 ${_}`,children:q?"Docked":"Undocked"}),l.jsx("span",{className:`rounded px-1.5 py-0.5 ${Z}`,children:J?"Charging":"Not charging"}),l.jsxs("span",{className:`rounded px-1.5 py-0.5 ${R}`,children:["OI: ",te]})]}),V.map(([ee,fe])=>l.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:ee}),l.jsx("span",{className:"font-semibold text-white",children:fe})]},ee))]})}),l.jsx("div",{className:`absolute ${K} left-1/2`,style:$,children:l.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${E} ${C}`,children:[l.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:da(r,.18),children:s||"Unnamed Rover"}),x?l.jsxs("span",{className:"text-slate-300",children:["• ",x]}):null]})})]}),g?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...ie},children:l.jsx(Xd,{sensors:n,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 ${L} font-medium text-slate-100 ${j}`,children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",o]}),u?l.jsxs("span",{children:["Audio: ",u]}):null,f?l.jsx("span",{className:"text-cyan-300",children:f}):null]})}),N?l.jsx("div",{className:`absolute bottom-1 left-1 rounded border ${M?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${O} ${G}`,children:N}):null,l.jsx("div",{className:`absolute ${K} left-1/2`,style:$,children:l.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${E} ${C}`,children:l.jsxs("span",{children:["Rover:"," ",l.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:da(r,.18),children:['"',s||"Unnamed Rover",'"']})]})})}),g&&p!=="spectator"?l.jsx("div",{className:"pointer-events-none absolute rounded",style:{...ie},children:l.jsx(Xd,{sensors:n,size:240,overlay:!0})}):null]})}const lw=an.memo(sw),fx=5e3,rw=700;function iw({description:n,variant:s="default",mobileHud:r=!1,displayKey:o="",controlIntentAt:u=0}){const[f,h]=m.useState(!1),[p,x]=m.useState(!1),g=m.useRef(0),b=m.useRef(null),v=m.useRef(null);return m.useEffect(()=>()=>{clearTimeout(b.current),clearTimeout(v.current)},[]),m.useEffect(()=>{if(s!=="default"||!n){h(!1),x(!1),clearTimeout(b.current),clearTimeout(v.current);return}clearTimeout(b.current),clearTimeout(v.current),h(!0),x(!1),g.current=Number(u)||0},[u,n,o,s]),m.useEffect(()=>{s!=="default"||!n||!f||p||(Number(u)||0)<=g.current||b.current||v.current||(b.current=setTimeout(()=>{x(!0),b.current=null},fx),v.current=setTimeout(()=>{h(!1),v.current=null},fx+rw))},[u,n,p,f,s]),n?s==="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:n})}):s!=="default"||!f?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/70 bg-neutral-900/45 px-2 py-1 text-center font-semibold text-slate-100 shadow-xl transition-opacity duration-700 ${p?"opacity-0":"opacity-100"} ${r?"text-[1rem] leading-tight":"text-[1.5rem] leading-tight"}`,children:[l.jsx("p",{children:"Just so you know, this rover"}),l.jsx("p",{children:n}),l.jsx("p",{className:`${r?"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 mx=2e3,ow=3e3,cw=3e3,uw=40,dw=1e3,fw={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function mw({motors:n,fill:s=0,compact:r=!1}){if(!n?.length)return null;const o=n.map(b=>fw[b]||b),u=r?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",f=r?"px-2 py-1":"px-4 py-2",h=r?"text-lg":"text-4xl",p=r?"text-xs":"text-xl",x=Math.max(0,Math.min(1,s)),g=`${Math.round(x*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 ${u}`,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:g}})}),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 ${h} ${f}`,children:[l.jsx("div",{children:"OVERCURRENT"}),l.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}const hw=an.memo(mw);function pw({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const r=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",u=s?"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 ${o}`,children:l.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${u}`,children:l.jsx("div",{children:r})})})}const xw=an.memo(pw);function gw({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],r=s.filter(p=>p!=null).reduce((p,x)=>Math.max(p,x),1200),o=p=>Math.pow(Math.max(0,Math.min(1,(p??0)/r)),.35),u=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,f=6,h=12;return l.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((p,x)=>{const g=o(p),b=x<f/2?-1:1,v=`${g*100}%`,N=u(p);return l.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}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:v,background:N,float:b===-1?"right":"left"}})})},x)})})}const bw=an.memo(gw);function vw({compact:n=!1}){const s=xe(z=>z.session?.role||null),r=xe(z=>z.session?.assignment?.roverId||null),o=xe(z=>z.session?.roster||[]),{sendMessage:u,onInputFocus:f,onInputBlur:h,blurChat:p,registerInputRef:x,setTypingActive:g}=pf(),{value:b}=Fe("tts",{engine:"flite",voice:"rms",pitch:50}),[v,N]=m.useState(""),[M,k]=m.useState(!1),S=s!=="spectator",w=s==="spectator",T=!!m.useMemo(()=>o.find(z=>String(z.id)===String(r))||null,[r,o])?.audio?.ttsEnabled,E=m.useMemo(()=>{if(!T)return null;const z=b?.engine==="espeak"?"espeak":"flite";if(z==="espeak"){let $=Number.isFinite(b?.pitch)?Math.round(b.pitch):void 0;return typeof $=="number"&&($=Math.max(0,Math.min(99,$))),{speak:!0,engine:z,pitch:$}}const K=typeof b?.voice=="string"?b.voice:void 0;return{speak:!0,engine:z,voice:K}},[b?.engine,b?.pitch,b?.voice,T]),C=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",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",G=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(),!S)return;const K=v.trim();if(K){k(!0);try{await u(K,E),N(""),p(),g(!1)}catch($){alert($.message)}finally{k(!1)}}}return w?null:l.jsxs("form",{onSubmit:O,className:C,children:[l.jsx("input",{className:L,value:v,onChange:z=>{const K=z.target.value;N(K),g(!!K.trim())},onFocus:z=>{f(z),g(!!v.trim())},onBlur:z=>{h(z),g(!1)},onKeyDown:z=>{z.key==="Enter"&&!v.trim()&&(z.preventDefault(),p(),g(!1))},ref:z=>x(z,{target:"hud"}),placeholder:S?"Chat (TTS)":"Spectator",disabled:!S}),l.jsx("button",{type:"submit",disabled:!S||M,className:G,children:"Speak"})]})}const yw=m.memo(vw);function Mr({sessionInfo:n,audioSessionInfo:s,videoMode:r="whep",snapshotFeed:o=null,qualityNotice:u=null,label:f,roverDescription:h=null,roverColor:p=null,forceMute:x=!1,telemetryFrame:g,batteryConfig:b,layoutFormat:v="desktop",hudVariant:N="default",driverLabel:M=null,hudForceMap:k=!1,hudMapPosition:S="top-center",hudLabelScale:w=1,fitParent:j=!1,overcurrentLimiter:T=null,showTurnCue:E=!1,turnTimerText:C=null,isActiveDriver:L=!1,idleSkipSeconds:G=null,showNotTurnNotice:O=!1,notTurnCountdownText:z=null,showPreviewReason:K=!1,notTurnFlashAt:$=0,controlIntentAt:X=0}){const P=xe(pe=>(pe.session?.socials||[]).find(Te=>String(Te?.id||Te?.label||"").toLowerCase()==="discord")?.url||null||pe.session?.discord?.invite||null),ce=m.useRef(null),ie=m.useRef(null),V=m.useRef(null),q=m.useRef(null),H=m.useRef(null),J=m.useRef(null),te=m.useRef(null),de=m.useRef(null),[R,_]=m.useState("idle"),[Z,ee]=m.useState(null),[fe,oe]=m.useState("idle"),[ue,ge]=m.useState(null),[ve,ye]=m.useState(0),[Ye,Ke]=m.useState(0),[Me,De]=m.useState(!0),[_e,Ct]=m.useState(!1),re=!!s?.url,se=r==="snapshot",je=g?.sensors,{value:me}=Fe("audio",ot),Ae=Number.isFinite(me?.masterVolume)?me.masterVolume:ot.masterVolume,Ce=Number.isFinite(me?.roverVolume)?me.roverVolume:ot.roverVolume,Pe=typeof me?.mainBrushDuckEnabled=="boolean"?me.mainBrushDuckEnabled:typeof me?.autoLevelEnabled=="boolean"?me.autoLevelEnabled:ot.mainBrushDuckEnabled,le=Number.isFinite(me?.mainBrushDuckAmount)?Math.max(0,Math.min(1,me.mainBrushDuckAmount)):ot.mainBrushDuckAmount,he=Math.max(0,Math.min(1,Ae*Ce)),Oe=je?.batteryChargeMah??null,nt=!(v==="desktop"),fl=nt?"top-right":S,[ln]=$g(),ml=k||nt?!0:ln,fs=Gg({charge:Oe,config:b}),Sn=je?.wheelOvercurrents||null,jt=m.useMemo(()=>Sn==null?[]:Object.entries(Sn).filter(([,pe])=>!!pe).map(([pe])=>pe),[Sn]),kt=T?.caps||null,Dt=T?.overcurrent?.groups||null,Hr=m.useMemo(()=>{if(typeof window>"u")return{debugAudio:!1,debugHud:!1};const pe=new URLSearchParams(window.location.search);return{debugAudio:pe.has("debugAudio"),debugHud:pe.has("debugHud")}},[]),Vr=Hr.debugAudio,hl=Hr.debugHud,Ua=m.useMemo(()=>{if(!kt)return null;const pe=Number.isFinite(kt?.drive?.cap)?kt.drive.cap:1,Re=Number.isFinite(kt?.aux?.cap)?kt.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(pe,Re)))},[kt]),Hn=!!T?.isActive,zt=m.useMemo(()=>{const pe=jt.length?jt:Hn?["limiter"]:[],Re=Ua??(jt.length?1:0);return{motors:pe,fill:Re,visible:!!pe.length}},[jt,Hn,Ua]),Ut=!!((Number(je?.mainBrushCurrentMa)||0)>uw||je?.wheelOvercurrents?.mainBrush),ms=Pe&&Ut?1-le:1,Mn=Math.max(0,Math.min(1,he*ms)),Fo=Pe&&Ut&&le>0?`Volume decreased ${Math.round(le*1e3)/10}%`:null,pl=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{pl.current={hasDedicatedAudio:re,audioUrl:s?.url||null,mainBrushDuckEnabled:Pe,mainBrushDuckAmount:le,mainBrushActive:Ut,baseRoverGain:he,effectiveRoverGain:Mn}},[re,s?.url,Pe,le,Ut,he,Mn]);const st=m.useCallback((pe,Re={})=>{if(!Vr)return;const Xe=ie.current,Te=pl.current,Ie={event:pe,ts:Date.now(),roverLabel:f||null,hasDedicatedAudio:Te.hasDedicatedAudio,audioUrl:Te.audioUrl,mainBrushDuckEnabled:Te.mainBrushDuckEnabled,mainBrushDuckAmount:Te.mainBrushDuckAmount,mainBrushActive:Te.mainBrushActive,baseRoverGain:Te.baseRoverGain,effectiveRoverGain:Te.effectiveRoverGain,element:Xe?{muted:Xe.muted,volume:Xe.volume,paused:Xe.paused,ended:Xe.ended,readyState:Xe.readyState,networkState:Xe.networkState}:null,...Re};try{console.log(`[AudioDebug] ${pe} ${JSON.stringify(Ie)}`)}catch{console.log("[AudioDebug]",pe,Ie)}},[Vr,f]);m.useEffect(()=>{hl&&console.log("[OvercurrentHUD]",{overlayVisible:zt.visible,overlayMotors:zt.motors,overlayFill:zt.fill,limiterActive:Hn,limiterCaps:kt,limiterGroups:Dt,wheelOvercurrents:Sn})},[hl,zt,Hn,kt,Dt,Sn]),m.useEffect(()=>{st("settings/update")},[st]);const jn=m.useCallback(()=>{clearTimeout(V.current),V.current=setTimeout(()=>ye(Date.now()),mx)},[]),xl=m.useCallback(()=>{clearTimeout(q.current),q.current=setTimeout(()=>Ke(Date.now()),mx)},[]),Ha=m.useCallback(async()=>{const pe=ce.current;if(pe)try{pe.muted=!0,await pe.play()}catch{}},[]),gl=m.useCallback((pe=0)=>{if(x||re)return;clearTimeout(J.current);const Re=()=>{clearTimeout(J.current),J.current=setTimeout(()=>{x||Xe()},ow)},Xe=async()=>{const Te=ce.current;if(Te)try{await Ha(),Te.muted=!1,await Te.play(),De(!1)}catch{Te.muted=!0,De(!0),Re()}};J.current=setTimeout(Xe,pe)},[Ha,x,re]);m.useEffect(()=>()=>{clearTimeout(V.current),clearTimeout(q.current),clearTimeout(J.current),clearInterval(H.current),te.current&&(cancelAnimationFrame(te.current),te.current=null)},[]),m.useEffect(()=>{if(!O||!$)return;Ct(!0);const pe=setTimeout(()=>Ct(!1),650);return()=>clearTimeout(pe)},[O,$]),m.useEffect(()=>{R==="playing"&&gl(0)},[R,gl]),m.useEffect(()=>{se&&(_("snapshot"),ee(null))},[se]),m.useEffect(()=>{if(se||!n?.url||!ce.current)return;let pe=!0,Re;const Xe=setTimeout(()=>De(!0),0),Te=(Ie,_t)=>{pe&&(st("video/status",{nextStatus:Ie,info:_t||null}),_(Ie),ee(_t||null),Ie==="playing"&&Ha(),["error","failed","disconnected","closed"].includes(Ie)&&jn())};return Re=new ux({url:n.url,token:n.token,video:ce.current,receiveAudio:!re,onStatus:Te}),Re.start().catch(Ie=>{pe&&(_("error"),ee(Ie.message),jn())}),()=>{pe=!1,clearTimeout(Xe),Re?.stop()}},[se,n?.url,n?.token,ve,jn,Ha,re,st]),m.useEffect(()=>{R==="stopped"&&n?.url&&jn()},[R,n?.url,jn]),m.useEffect(()=>{const pe=ie.current;if(!pe||!s?.url){st("route/no-audio-url"),de.current=null;return}const Re=Math.max(0,Math.min(1,Mn)),Xe=de.current==null?Math.max(0,Math.min(1,pe.volume)):de.current;if(te.current&&(cancelAnimationFrame(te.current),te.current=null),Re>Xe){const Te=performance.now(),Ie=Xe,_t=Re-Ie,ma=Tn=>{const mt=Math.min(1,(Tn-Te)/dw),rn=Ie+_t*mt;pe.volume=rn,de.current=rn,mt<1?te.current=requestAnimationFrame(ma):te.current=null};te.current=requestAnimationFrame(ma)}else pe.volume=Re,de.current=Re;st("route/direct",{elementVolume:Re,duckEnabled:Pe,mainBrushActive:Ut,duckAmount:le})},[s?.url,Mn,Pe,Ut,le,st]),m.useEffect(()=>{if(!s?.url||!ie.current)return;let pe=!0,Re;const Xe=(Te,Ie)=>{pe&&(st("audio/status",{nextStatus:Te,info:Ie||null}),ge(Ie||(Te==="connected"?"connected":null)),oe(_t=>Te==="connected"&&(_t==="playing"||_t==="connecting")||Te==="new"?_t:Te),["error","failed"].includes(Te)&&xl())};return Re=new ux({url:s.url,token:s.token,video:ie.current,audioOnly:!0,onStatus:Xe}),Re.start().catch(Te=>{pe&&(oe("error"),ge(Te.message),xl())}),()=>{pe=!1,Re?.stop()}},[s?.url,s?.token,Ye,xl,st]),m.useEffect(()=>{const pe=ie.current;if(!s?.url||!pe){clearInterval(H.current);return}if(!["connecting","connected","playing","paused"].includes(fe)){clearInterval(H.current);return}const Xe=async()=>{const Te=ie.current;Te&&(Te.muted=!1,!(!Te.paused&&!Te.ended)&&(st("retry/play-attempt"),Te.play().then(()=>{st("retry/play-ok"),oe(Ie=>Ie==="connected"?"playing":Ie),ge(Ie=>Ie==="paused"?null:Ie)}).catch(Ie=>{st("retry/play-fail",{error:Ie?.message}),ge(_t=>_t||Ie?.message||"autoplay blocked")})))};return Xe(),H.current=setInterval(Xe,cw),()=>clearInterval(H.current)},[s?.url,fe,st]),m.useEffect(()=>{const pe=ie.current;if(!pe)return;const Re=()=>{st("element/play"),oe(mt=>mt==="error"?mt:"playing"),ge(null)},Xe=()=>{st("element/pause"),oe(mt=>["error","failed","disconnected","closed","stopped"].includes(mt)?mt:"paused"),ge(mt=>mt||"paused")},Te=()=>{st("element/ended"),oe(mt=>mt==="error"?mt:"stopped"),ge(mt=>mt||"ended")},Ie=()=>{const{error:mt}=pe,rn=mt?.message||"audio error";st("element/error",{error:rn}),oe("error"),ge(rn)},_t=()=>st("element/waiting"),ma=()=>st("element/canplay"),Tn=()=>st("element/stalled");return pe.addEventListener("play",Re),pe.addEventListener("pause",Xe),pe.addEventListener("ended",Te),pe.addEventListener("error",Ie),pe.addEventListener("waiting",_t),pe.addEventListener("canplay",ma),pe.addEventListener("stalled",Tn),()=>{pe.removeEventListener("play",Re),pe.removeEventListener("pause",Xe),pe.removeEventListener("ended",Te),pe.removeEventListener("error",Ie),pe.removeEventListener("waiting",_t),pe.removeEventListener("canplay",ma),pe.removeEventListener("stalled",Tn)}},[s?.url,st]);const $r=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",bl=se?$r:n?.url?R==="error"?`Error: ${Z||"unknown"}`:Z?`${R} (${Z})`:R:"waiting",vl=s?.error?`Error: ${s.error}`:s?.url?fe==="error"?`Error: ${ue||"unknown"}`:ue?`${fe} (${ue})`:fe:null,yl=N==="spectator",Ht=N==="none",Rn=`${f||""}::${h||""}`;return l.jsxs("div",{className:`flex flex-col gap-0.5 ${j?"h-full":""}`,children:[l.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${j?"h-full flex-1":"aspect-[4/3]"}`,children:[se?o?.objectUrl?l.jsx("img",{src:o.objectUrl,alt:f,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:ce,muted:x||Me||re,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),l.jsx("audio",{ref:ie,autoPlay:!0,hidden:!0}),!Ht&&E?l.jsx(IN,{mobileHud:nt,isActiveDriver:L,idleSkipSeconds:G}):null,Ht?null:l.jsx(iw,{description:h,variant:N,mobileHud:nt,displayKey:Rn,controlIntentAt:X}),Ht?null:l.jsx(lw,{sensors:je,label:f,roverColor:p,status:bl,audioStatus:vl,levelStatus:Fo,layoutFormat:v,variant:N,driverLabel:M,showTopDown:ml,mobileHud:nt,mapPosition:fl,turnTimerText:C,turnTimerFlashActive:_e,labelScale:w}),Ht?null:l.jsx(yw,{compact:nt}),!Ht&&hl?l.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${zt.visible?1:0} motors:${zt.motors.length} fill:${Math.round(zt.fill*100)}%`}):null,Ht?null:l.jsx(hw,{motors:zt.motors,fill:zt.fill,compact:nt}),Ht?null:l.jsx(xw,{battery:fs,compact:nt}),!Ht&&yl&&fs.available?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(Yd,{visual:fs,orientation:"vertical",variant:"inline",compact:nt,className:"h-full w-4"})}):null,!Ht&&u?l.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:l.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${nt?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:"text-center",children:u}),l.jsx("div",{className:"pointer-events-auto mt-0",children:l.jsx(kr,{id:"discord",label:"Join our Discord server while you wait!",url:P})})]})}):null,!Ht&&O?l.jsx("div",{className:"pointer-events-none absolute bottom-1 left-1 z-40",children:l.jsxs("div",{className:`w-fit rounded border ${_e?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${nt?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:_e?"text-[0.82rem] font-semibold text-red-50":"text-[0.82rem] font-semibold text-white",children:"Not your turn to drive!"}),z?l.jsx("div",{className:_e?"text-red-100/95":"text-amber-100",children:z}):null,K?l.jsx("div",{className:_e?"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(kr,{id:"discord",label:"Join our Discord while you wait!",url:P})})]})}):null]}),!Ht&&!yl&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(bw,{sensors:je}),l.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:l.jsx(Yd,{visual:fs,compact:nt})})]})]})}function Sw(n=[]){const s=new Set;return n.forEach(r=>{if(String(r?.role||"")==="spectator")return;const u=String(r?.roverId||"").trim(),f=String(r?.socketId||"").trim();!u||!f||s.add(f)}),s.size}function jf({layoutFormat:n="desktop"}){const s=xe(se=>se.session?.mode||null),r=xe(se=>se.session?.assignment?.roverId??null),o=xe(se=>se.session?.roster??[]),u=xe(se=>se.session?.users??[]),f=xe(se=>se.session?.turnQueues??{}),h=xe(se=>se.session?.socketId||null),p=xe(se=>se.session?.activeDrivers??{}),{state:{song:x,lastControlIntentAt:g},overcurrentLimiter:b}=At(),[v,N]=m.useState(()=>Date.now()),[M,k]=m.useState(!1),[S,w]=m.useState(null),[j,T]=m.useState(0),E=m.useRef({initialized:!1,roverId:null,activeDriverId:null}),C=m.useRef(g||0);m.useEffect(()=>{if(s!=="turns")return;const se=setInterval(()=>N(Date.now()),250);return()=>clearInterval(se)},[s]);const G=!!(r&&o?o.find(se=>String(se.id)===String(r)):null)?.media?.audioPublishUrl,O=r?f?.[r]:null,z=r?p?.[r]:null,K=!!(h&&z===h),$=m.useMemo(()=>{const se=O?.queue||[];if(!se.length||!O?.current||se.length<=1)return null;const je=se.findIndex(me=>me===O.current);return je===-1?se[0]||null:se[(je+1)%se.length]||null},[O?.queue,O?.current]),X=!!(h&&$===h),P=O?.deadline||null,ce=O?.idleDeadline||null,ie=P?P-v:null,V=ce?ce-v:null,q=s==="turns",H=o.length,J=m.useMemo(()=>Sw(u),[u]),te=q&&J>H,de=q&&X&&ie!=null&&ie<=5e3&&ie>0,R=q&&!K,_=R&&!de&&te,Z=!_,ee=ie!=null&&Number.isFinite(ie)?Math.max(0,Math.ceil(ie/1e3)):null,fe=V!=null&&Number.isFinite(V)?Math.max(0,Math.ceil(V/1e3)):null,oe=m.useMemo(()=>!q||!K?null:ee!=null?`${ee}s left`:"Your turn",[q,K,ee]),ue=m.useMemo(()=>!R||!X||ee==null?null:`${ee} seconds until your turn.`,[R,X,ee]),ge=r?[...Z?[{type:"rover",id:r,key:r}]:[],...G?[{type:"rover",id:`${r}-audio`,key:`${r}-audio`}]:[]]:[],ve=Cr(ge),ye=r&&Z?ve[r]:null,Ye=r&&G?ve[`${r}-audio`]:null,Ke=yf(r?[r]:[],{enabled:!!r,version:s}),Me=r&&Ke[r]||null,De=dl(r),_e=r&&o?o.find(se=>String(se.id)===String(r)):null,Ct=_e?.battery??null,re=_e?.name||(r?`Rover ${r}`:"");return m.useEffect(()=>{if(s!=="turns"){k(!1),w(null),E.current={initialized:!1,roverId:null,activeDriverId:null};return}const se=E.current,je=z||null;if(!h||!r){k(!1),w(null),E.current={initialized:!1,roverId:null,activeDriverId:null};return}if(!se.initialized||se.roverId!==r){E.current={initialized:!0,roverId:r,activeDriverId:je};return}!!se.activeDriverId&&se.activeDriverId!==h&&je===h?(k(!0),w(Date.now())):je!==h&&M&&(k(!1),w(null)),E.current={initialized:!0,roverId:r,activeDriverId:je}},[z,s,r,h,M]),m.useEffect(()=>{!M||!S||g>S&&k(!1)},[g,S,M]),m.useEffect(()=>{const se=Number(C.current)||0,je=Number(g)||0;je>se&&R&&T(Date.now()),C.current=je},[R,g]),l.jsx("section",{className:"panel",children:r?l.jsx(Mr,{sessionInfo:ye,videoMode:Z?"whep":"snapshot",snapshotFeed:Me,audioSessionInfo:Ye,label:re,roverDescription:_e?.description,roverColor:_e?.color||null,telemetryFrame:De,batteryConfig:Ct,layoutFormat:n,overcurrentLimiter:b,songNote:x?.note,qualityNotice:null,showTurnCue:M,turnTimerText:oe,turnSeconds:ee,isActiveDriver:K,idleSkipSeconds:fe,showNotTurnNotice:R,notTurnCountdownText:ue,showPreviewReason:_,notTurnFlashAt:j,controlIntentAt:g}):l.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[l.jsx("p",{children:"You are not assigned to a rover."}),l.jsx("p",{className:"mt-0",children:l.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function Ro({label:n,tone:s="muted"}){const r=s==="success"?"bg-emerald-900 text-emerald-100":s==="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 Uo(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function jw(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,r,o]=n,u=Math.max(0,Math.min(255,Number(s)))/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),x=Math.min(u,f,h),g=p-x;if(g===0)return 0;let b=0;return p===u?b=(f-h)/g%6:p===f?b=(h-u)/g+2:b=(u-f)/g+4,Uo(Math.round(b*60))}function hx(n){const s=Uo(n),r=1,o=1-Math.abs(s/60%2-1);let u=0,f=0,h=0;return s<60?(u=r,f=o):s<120?(u=o,f=r):s<180?(f=r,h=o):s<240?(f=o,h=r):s<300?(u=o,h=r):(u=r,h=o),[Math.round(u*255),Math.round(f*255),Math.round(h*255)]}function px(n){return n?Array.isArray(n.hsColor)?Uo(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?jw(n.rgbColor):0:0}function Nw({entity:n,connected:s,controlsLocked:r,onToggle:o,onSetColor:u,onSetWhite:f}){const h=n.state==="unavailable"||!n.available,p=n.state==="on",x=n.type==="light"&&n.supportsColor,g=h?"warn":p?"success":"muted",b=h?"Unavailable":p?"On":"Off",v=r||!s||h,N=v||!x,[M,k]=m.useState(()=>px(n)),S=m.useRef(M),w=m.useRef(!1),j=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(!x||w.current)return;const z=px(n);S.current=z,k(z)},[n.rgbColor,n.hsColor,x]);const T=z=>{const K=Uo(Number(z.target.value));S.current=K,k(K)},E=()=>{N||!u||u(n.id,hx(S.current))},C=z=>{z.stopPropagation()},L=z=>{C(z),!(N||!f)&&f(n.id)},O=`rgb(${(x?hx(S.current):[255,255,255]).join(",")})`;return l.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:v,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[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}),x&&l.jsxs(l.Fragment,{children:[l.jsx(Ro,{label:b,tone:g}),!s&&l.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),x?l.jsx("div",{className:"-mt-0.5 w-full",onClick:C,onPointerDown:z=>{C(z),w.current=!0},onPointerUp:z=>{C(z),w.current=!1,E()},onPointerCancel:z=>{C(z),w.current=!1,E()},onKeyUp:z=>{C(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:T,disabled:N,"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(Ro,{label:b,tone:g}),!s&&l.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),x&&l.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[l.jsx("span",{role:"button",tabIndex:N?-1:0,onClick:L,onPointerDown:C,onKeyDown:z=>{N||(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":N,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 ${N?"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}})]}),!x&&l.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:p?"Turn off":"Turn on"})]})}function Yg(){const{state:{keymap:n}}=At(),s=xe(N=>N.session?.homeAssistant||null),{homeAssistantToggle:r,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:u}=Qt(),f=m.useMemo(()=>s?.entities||[],[s?.entities]),h=s?.lightPolicy||null,p=!!(h?.locked||h?.lockedOn),x=h?.lockState||(h?.lockedOn?"on":null),g=qt(n?.homeAssistantOn?.[0]),b=qt(n?.homeAssistantOff?.[0]);if(!s?.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 v=!!s?.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(Ro,{label:x==="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"}),g?l.jsx(xx,{label:g}):null]}),l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"Off"}),b?l.jsx(xx,{label:b}):null]})]})]}),l.jsx(Ro,{label:v?"Connected":"Offline",tone:v?"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:x==="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(N=>l.jsx(Nw,{entity:N,connected:v,controlsLocked:p,onToggle:r,onSetColor:o,onSetWhite:u},N.id))})]})}function xx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Xg(){const{login:n,setRole:s}=Qt(),[r,o]=m.useState(""),[u,f]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await n(r,u),o(""),f("")}catch(b){alert(b.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:x,children:[l.jsx("input",{className:"field-input",placeholder:"Username",value:r,onChange:g=>o(g.target.value)}),l.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:u,onChange:g=>f(g.target.value)}),l.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function gx(...n){return n.filter(Boolean).join(" ")}function ww(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function Aw(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Cw({title:n,roster:s=[],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}),s.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:r}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(u=>{const f=!!(u?.private?.enabled&&u?.private?.open),h=!!u?.locked;return l.jsxs("li",{className:gx("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:da(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:gx("font-semibold",Aw(u)),children:["Battery ",ww(u)]})]})]}),o?o(u):null]},u.id)})})]})}function kw(n){const s=n?.runtime||{},r=n?.output||{},o=n?.errors||{};return s.inFlight?{label:"IN FLIGHT",detail:s.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:s.outcome==="posted"?{label:"POSTED",detail:r.posted?`Last: ${r.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Ew(n,s){const r=Date.now(),u=(Array.isArray(n)?n:[]).map((f,h)=>{const p=String(f?.role||"").toLowerCase(),x=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:r+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(s!=null){const f=String(s);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 Mw({state:n,onClearHistory:s,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||{},x=n.input||{},g=n.output||{},b=n.errors||{},v=Array.isArray(n.history)?n.history:[],N=v.find(w=>w.runId===o)||(v.length?v[v.length-1]:null),M=kw(n),k=Ew(x.modelMessages,g.raw),S=[{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:s,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:S.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))}),b.message?l.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",b.message]}):null,b.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(b.details,null,2)})]}):null,g.generated?l.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?l.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.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(ff,{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: ",g.raw?.trim()?g.raw:"<none>"]}),l.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),l.jsxs("div",{children:["Output at: ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Failed at: ",b.failedAt?new Date(b.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:v.length?v.slice().reverse().map(w=>l.jsxs("button",{type:"button",onClick:()=>u(w.runId),className:`w-full text-left surface ${N?.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."})})]}),N?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 #",N.runId," details"]}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(N,null,2)})]}):null]})}function Rw({state:n,onClearHistory:s,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||{},x=n.timings||{},g=n.input||{},b=n.errors||{},v=()=>{const N=Array.isArray(g.modelMessages)?g.modelMessages:[];return N.length?N.map((M,k)=>{const S=String(M?.role||"unknown").toUpperCase(),w=String(M?.content||"");return`#${k+1} ${S}
|
||
${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:s,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: ",x.lastGenerationMs!=null?`${x.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:g.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:v()})]}),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:g.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(g.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:g.availableTools,blocked:g.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: ",g.modelInputAt?new Date(g.modelInputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Model output at: ",p.outputAt?new Date(p.outputAt).toLocaleString():"n/a"]})]}),b.message?l.jsxs("div",{className:"surface text-xs text-red-300",children:["Error: ",b.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(N=>!N),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 Tw({health:n,roster:s=[]}){if(!n)return null;const r=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},u=x=>s.find(g=>String(g.id)===String(x))?.color||null,f=`${r.readyCount}/${r.totalCount} sources ready`,h=o.rovers.filter(x=>x.stale).length,p=o.rooms.filter(x=>x.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(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:`${x.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:x.type==="rover"?da(u(x.id),.16):void 0,children:x.label}),l.jsxs("span",{className:x.ready?"text-emerald-300":"text-amber-300",children:[x.recentCount,"/",x.neededCount]})]},`${x.type}:${x.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:da(u(x.id),.16),children:x.name}),l.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.stale?"stale":"ok"})]},`rover:${x.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(x=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:x.name}),l.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.error?"error":x.stale?"stale":"ok"})]},`room:${x.id}`))})]})}function qw({entries:n}){const s=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:s.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?l.jsx("p",{children:"No admin log entries yet."}):s.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 Dw=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function _w(){const{session:n,lockRover:s,setMode:r,requestControl:o,setGlobalObjective:u,setAdminReason:f,rebootRover:h,rebootServer:p,setAudioLevels:x,setPrivateSafety:g,llmControl:b,overseerControl:v,adminLogs:N,llmCommentaryState:M,overseerControlState:k}=Br(),S=m.useMemo(()=>n?.roster??[],[n?.roster]),[w,j]=m.useState({}),[T,E]=m.useState({}),[C,L]=m.useState(!1),[G,O]=m.useState(!1),[z,K]=m.useState(!1),$=n?.health||null,X=n?.globalObjective?.text||"",P=n?.globalObjective?.updatedAt||null,[ce,ie]=m.useState(X),V=n?.adminReason?.text||"",q=n?.adminReason?.updatedAt||null,[H,J]=m.useState(V),te=n?.audioLevels||{},[de,R]=m.useState({hornGain:Number.isFinite(te.hornGain)?te.hornGain:1,ttsGain:Number.isFinite(te.ttsGain)?te.ttsGain:1,forwardGain:Number.isFinite(te.forwardGain)?te.forwardGain:1}),[_,Z]=m.useState({}),ee=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",fe=n?.role==="lockdown"||n?.role==="lockdown-admin",oe=n?.mode??"open",ue=async(le,he)=>{try{await s(le,he),j(Oe=>({...Oe,[le]:he}))}catch(Oe){alert(Oe.message)}},ge=async le=>{const he=le.target.value;try{await r(he)}catch(Oe){alert(Oe.message)}},ve=async le=>{try{await o(le,{force:!0})}catch(he){alert(he.message)}},ye=async le=>{if(!(!le?.id||!window.confirm(`Reboot rover "${le.name||le.id}" now?`))){E(Oe=>({...Oe,[le.id]:!0}));try{await h(le.id)}catch(Oe){alert(Oe.message)}finally{E(Oe=>({...Oe,[le.id]:!1}))}}},Ye=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)}}},Ke=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 b("clearHistory")}catch(he){alert(he.message)}finally{O(!1)}}},Me=async()=>{if(window.confirm("Clear Overseer Control history now?")){K(!0);try{await v("clearHistory")}catch(he){alert(he.message)}finally{K(!1)}}},De=async()=>{try{await u(ce)}catch(le){alert(le.message)}},_e=async()=>{try{await u(null)}catch(le){alert(le.message)}},Ct=async()=>{try{await f(H)}catch(le){alert(le.message)}},re=async()=>{try{await f(null)}catch(le){alert(le.message)}},se=le=>he=>{const Oe=Number(he.target.value);R(Lt=>({...Lt||{},[le]:Number.isFinite(Oe)?Oe:1}))},je=async()=>{try{await x(de)}catch(le){alert(le.message)}},me=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{ie(X)},[X]),m.useEffect(()=>{J(V)},[V]),m.useEffect(()=>{R({hornGain:Number.isFinite(te.hornGain)?te.hornGain:1,ttsGain:Number.isFinite(te.ttsGain)?te.ttsGain:1,forwardGain:Number.isFinite(te.forwardGain)?te.forwardGain:1})},[te.forwardGain,te.hornGain,te.ttsGain]),m.useEffect(()=>{const le={};(S||[]).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})}),Z(le)},[S]);const Ae=m.useMemo(()=>{const le={};return S.forEach(he=>{le[he.id]=w[he.id]??he.locked}),le},[S,w]),Ce=(le,he={})=>{Z(Oe=>({...Oe||{},[le]:{...Oe?.[le]||{},...he||{}}}))},Pe=async le=>{try{const he=_?.[le];if(!he)return;await g(le,he)}catch(he){alert(he.message)}};return ee?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:oe,onChange:ge,className:"field-input text-sm",children:Dw.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:Ye,disabled:C,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:C?"Server rebooting...":"Reboot Server"}),l.jsx("button",{type:"button",onClick:me,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:[de.hornGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:de.hornGain,onChange:se("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:[de.ttsGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:de.ttsGain,onChange:se("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:[de.forwardGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:de.forwardGain,onChange:se("forwardGain"),className:"w-full accent-emerald-500"})]}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:je,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:ce,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:De,className:"button-dark",children:"Set objective"}),l.jsx("button",{type:"button",onClick:_e,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:Ct,className:"button-dark",children:"Set reason"}),l.jsx("button",{type:"button",onClick:re,className:"button-danger",children:"Clear"})]})]}),l.jsx(Cw,{roster:S,renderActions:le=>l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:()=>ue(le.id,!Ae[le.id]),className:"button-dark",children:Ae[le.id]?"Unlock":"Lock"}),l.jsx("button",{type:"button",onClick:()=>ve(le.id),className:"button-dark",children:"Force"}),l.jsx("button",{type:"button",onClick:()=>ye(le),disabled:!!T[le.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:T[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:!fe,onChange:he=>Ce(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:!fe,value:_?.[le.id]?.speedLimitMaxWheelSpeed??250,onChange:he=>Ce(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:!fe,onChange:he=>Ce(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:!fe,onChange:he=>Ce(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:!fe,onChange:he=>Ce(le.id,{cliffEnabled:!!he.target.checked})}),l.jsx("span",{children:"Cliff safety"})]}),l.jsx("button",{type:"button",disabled:!fe,onClick:()=>Pe(le.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),l.jsx(Tw,{health:$,roster:S}),l.jsx(Mw,{state:M,onClearHistory:Ke,clearingHistory:G}),l.jsx(Rw,{state:k,onClearHistory:Me,clearingHistory:z}),l.jsx(qw,{entries:N})]}):null}const Ow=[{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 Bw(n){return n.reduce((s,r)=>((s[r.group]||(s[r.group]=[])).push(r),s),{})}function Lw(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):s}const Nf=5,Rr=500,Tr=1,wf=100;function zw(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(Nf,Math.min(Rr,r)):s}function jo(n,s){const r=Number(n);return Number.isFinite(r)?Math.max(Tr,Math.min(wf,r)):s}function Uw(n){const r=(jo(n,n)-Tr)/(wf-Tr),o=Rr-r*(Rr-Nf);return Math.round(o)}function Hw(n){const s=zw(n,n),r=(Rr-s)/(Rr-Nf),o=Tr+r*(wf-Tr);return Math.round(o)}function Vw(n){const[s,r]=m.useState(null),o=m.useCallback(h=>{dd(!0),r(h)},[]),u=m.useCallback(()=>{dd(!1),r(null)},[]),f=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){u();return}const x=zr(p.key??"");x&&(n(h,x,p),u())},[u,n]);return m.useEffect(()=>()=>dd(!1),[]),{active:s,startCapture:o,cancel:u,captureFromEvent:f}}function co({label:n,description:s,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"})]}),s&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),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 $w(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:r}}=At(),{value:o,save:u}=Fe("inputs",Bn),f={...Bn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof f.tiltSpeed=="number"?jo(f.tiltSpeed,Bn.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?jo(Hw(f.tiltIntervalMs),Bn.keyboard.tiltSpeed):Bn.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),p=m.useMemo(()=>Bw(Ow),[]),{active:x,startCapture:g,cancel:b,captureFromEvent:v}=Vw((S,w)=>{s(S,w)}),N=m.useCallback(S=>n?.[S]?.[0]||yr[S]?.[0]||"",[n]),M=m.useCallback((S,w)=>{const j=Bn.keyboard,T=Lw(w,j[S]);u(E=>({...E??{},keyboard:{...E?.keyboard??j,[S]:T}}))},[u]),k=m.useCallback(S=>{const w=Bn.keyboard,j=jo(S,w.tiltSpeed),T=Uw(j);u(E=>({...E??{},keyboard:{...E?.keyboard??w,tiltSpeed:j,tiltIntervalMs:T}}))},[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(co,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:S=>M("baseSpeed",S)}),l.jsx(co,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:S=>M("turboSpeed",S)}),l.jsx(co,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:S=>M("precisionSpeed",S)})]})]}),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(co,{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(([S,w])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.75rem] text-slate-400",children:S}),l.jsx("div",{className:"space-y-0.5",children:w.map(j=>{const T=N(j.id),E=x===j.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:j.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:qt(T)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[E&&l.jsx("button",{type:"button",onClick:()=>b(),className:"button-danger text-[0.7rem]",children:"Cancel"}),l.jsx("button",{type:"button",onClick:()=>g(j.id),onKeyDown:E?C=>v(j.id,C):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"})]})]},j.id)})})]},S))})]})}const ia=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),Gw=[{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"}],bx=.45,Fw=.6;function xr({label:n,description:s,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:ia.format(f)})]}),s&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),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 Yw(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const s=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${s?` (${s})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const s=n.direction<0?"<":">";return`Axis ${n.index} ${s} ${ia.format(n.threshold??.6)}`}return"Unassigned"}function Xw(n){return n.reduce((s,r)=>((s[r.section]||(s[r.section]=[])).push(r),s),{})}function Qw(n,s){if(!n||n.length===0)return null;if(s){const r=n.find(o=>o.signature===s);if(r)return r}return n[0]}function Kw(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(s=>({pressed:!!s?.pressed,value:typeof s?.value=="number"?s.value:s?.pressed?1:0}))}}function Iw(n,s,r){const o=(n.axes??[]).map((f,h)=>({index:h,delta:Math.abs((f??0)-(s.axes?.[h]??0)),value:f}));if(o.sort((f,h)=>h.delta-f.delta),r.kind==="axisPair"){const f=o.filter(h=>h.delta>bx).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>bx);return u?{kind:"axis",index:u.index,...r.invertDefaults??{}}:null}function Zw(n,s,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>Fw)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-(s.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 Jw(n,s,r){if(!n)return null;if(r.kind==="axis"||r.kind==="axisPair"){const o=Iw(n,s,r);if(o)return o}return Zw(n,s,r)}function Pw(){const n=xN(),{value:s,save:r}=Fe("gamepad",La),[o,u]=m.useState(null),f=m.useRef(null),h=m.useMemo(()=>Xw(Gw),[]),p=m.useMemo(()=>Qw(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??oa:s?.defaults?.profile??oa,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!p||!x||s?.profiles?.[x]||r(w=>{const j=w??La;if(j.profiles?.[x])return j;const T=j?.defaults?.profile??oa,E=Rg(p,T);return{...j,profiles:{...j.profiles??{},[x]:E}}})},[p,x,s?.profiles,r]),m.useEffect(()=>{f.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!f.current){f.current=Kw(p);return}const w=Jw(p,f.current,o);w&&(r(j=>{const T=j??La,E=T.profiles?.[x]??T?.defaults?.profile??oa,C={...E,bindings:{...E.bindings??{},[o.id]:{...E.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...T,profiles:{...T.profiles??{},[x]:C}}}),u(null))},[p,x,o,r]);const b=m.useCallback(w=>{r(j=>({...j??La,activeSignature:w||null}))},[r]),v=m.useCallback(w=>{r(j=>{const T=j??La,E=(x&&T.profiles?.[x])??T?.defaults?.profile??oa,C={...E,calibration:{...E.calibration??{},...w}};return x?{...T,profiles:{...T.profiles??{},[x]:C}}:{...T,defaults:{...T.defaults??{},profile:C}}})},[x,r]),N=m.useCallback((w,j)=>{r(T=>{const E=T??La,C=(x&&E.profiles?.[x])??E?.defaults?.profile??oa,L=j(C.bindings?.[w]??{}),G={...C,bindings:{...C.bindings??{},[w]:L}};return x?{...E,profiles:{...E.profiles??{},[x]:G}}:{...E,defaults:{...E.defaults??{},profile:G}}})},[x,r]),M=m.useCallback(w=>{N(w.id,j=>({...j,sources:[]}))},[N]),k=m.useCallback((w,j)=>{N(w.id,T=>{const E=Array.isArray(T.sources)?[...T.sources]:[];if(!E[0])return T;const C={...E[0]};return j==="invertX"?C.invertX=!C.invertX:j==="invertY"?C.invertY=!C.invertY:C.invert=!C.invert,E[0]=C,{...T,sources:E}})},[N]),S=m.useMemo(()=>p?{outputs:Tg(p,g)}:null,[p,g]);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:x??"",onChange:w=>b(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(xr,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:w=>v({driveDeadzone:w})}),l.jsx(xr,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:w=>v({cameraDeadzone:w})}),l.jsx(xr,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:w=>v({auxDeadzone:w})}),l.jsx(xr,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:w=>v({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:g.calibration?.cameraMode??"absolute",onChange:w=>v({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(xr,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:w=>v({cameraSensitivity:w})})]})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([w,j])=>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:j.map(T=>{const C=g.bindings?.[T.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:T.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Yw(C)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[T.kind==="axisPair"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:!C,onClick:()=>k(T,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),l.jsx("button",{type:"button",disabled:!C,onClick:()=>k(T,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),T.kind==="axis"&&l.jsx("button",{type:"button",disabled:!C,onClick:()=>k(T),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),l.jsx("button",{type:"button",onClick:()=>M(T),className:"button-dark text-[0.7rem]",children:"Clear"}),l.jsx("button",{type:"button",onClick:()=>u(T),className:`${o?.id===T.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===T.id?"Waiting…":"Capture"})]})]},T.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,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["A",j,": ",ia.format(w)]},`axis-${j}`))}),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,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["B",j,": ",ia.format(w.value)," ",w.pressed?"●":""]},`btn-${j}`))}),S?.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: ",ia.format(S.outputs.driveVector.x),","," ",ia.format(S.outputs.driveVector.y)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",ia.format(S.outputs.cameraAxis)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",ia.format(S.outputs.auxAxis.main)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",ia.format(S.outputs.auxAxis.side)]})]})]})]}):l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const Ww={drive:"Drive wheels",aux:"Aux motors"};function vx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function eA({value:n,color:s="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 ${s}`,style:{width:r}})})}function tA(){const{state:{roverId:n},overcurrentLimiter:s}=At(),r=m.useMemo(()=>os.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:s?.adminImmune?"Admin immune":"Active"})]}),n?l.jsxs("div",{className:"space-y-0.5",children:[r.map(o=>{const u=s?.caps?.[o]?.cap??0,f=s?.overcurrent?.groups?.[o]??!1,h=s?.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:Ww[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:vx(u)})]}),l.jsx(eA,{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:vx(h)})]})]})]},o)}),l.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),l.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),l.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Qg=m.createContext(null);function Kg(){const n=m.useContext(Qg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const yx={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"}},Sx={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 Af(...n){return n.filter(Boolean).join(" ")}function Cf({children:n,defaultTab:s,currentTab:r,onTabChange:o,variant:u=Ig}){const[f,h]=m.useState(s??null),[p,x]=m.useState([]),g=m.useCallback(M=>M?(x(k=>k.includes(M)?k:[...k,M]),()=>x(k=>k.includes(M)?k.filter(S=>S!==M):k)):()=>{},[]),b=r??f??p[0]??null;m.useEffect(()=>{s&&r===void 0&&h(s)},[s,r]);const v=m.useCallback(M=>{M&&(r===void 0&&h(M),o&&o(M))},[r,o]),N=m.useMemo(()=>({activeTab:b,setActiveTab:v,registerTab:g,variant:u}),[b,v,g,u]);return l.jsx(Qg.Provider,{value:N,children:n})}function kf({children:n,className:s=""}){return l.jsx("div",{className:Af("flex gap-0.5",s),children:n})}function tn({id:n,children:s,className:r="",disabled:o=!1,highlight:u="none"}){const{activeTab:f,setActiveTab:h,registerTab:p,variant:x}=Kg();m.useEffect(()=>p(n),[n,p]);const g=yx[x]??yx[Ig],b=f===n,v=Sx[u]||Sx.none,N=Af(g.base,v||(b?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",r);return l.jsx("button",{type:"button",className:N,onClick:()=>!o&&h(n),"aria-pressed":b,"aria-disabled":o,children:s})}function Ef({children:n,className:s=""}){return l.jsx("div",{className:Af("mt-0 space-y-0.5",s),children:n})}function nn({id:n,children:s,keepMounted:r=!1}){const{activeTab:o}=Kg(),u=o===n;return!u&&!r?null:!u&&r?l.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):l.jsx(l.Fragment,{children:s})}function nA(){const{session:n}=Br(),s=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:s})]})}const jx=300,Nx=240;function aA(n,s){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(s||(s=new WeakSet),typeof n=="object"){if(s.has(n))return"[Circular]";s.add(n)}try{return JSON.stringify(n,(r,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function sA(n){const r=n.map(o=>aA(o)).join(" ");return r.length>Nx?`${r.slice(0,Nx)}…`:r}function lA(){const n=sn(),[s,r]=m.useState([]),o=m.useMemo(()=>s.reduce((u,f)=>(f.direction==="in"&&(u.in+=1),f.direction==="out"&&(u.out+=1),u),{in:0,out:0}),[s]);return m.useEffect(()=>{const u=(x,g,b)=>{r(v=>{const N=[...v,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:sA(b),timestamp:new Date().toLocaleTimeString()}];return N.length>jx?N.slice(-jx):N})},f=(x,...g)=>u("in",x,g),h=(x,...g)=>u("out",x,g);n.onAny(f);let p=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),p=()=>n.offAnyOutgoing(h);else{const x=n.emit.bind(n);n.emit=(g,...b)=>(h(g,...b),x(g,...b)),p=()=>{n.emit=x}}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:s.length===0?l.jsx("p",{children:"No socket activity yet."}):s.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 rA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Zg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:r}}=At(),o=!!n,[u,f]=$g(),h=sn(),{value:p,save:x}=Fe("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:b}=Fe("audio",ot),v=p?.connectionTransport||"websocket",N=!!p?.swapMobileControlColumns,M=typeof p?.driveMacroBackoffEnabled=="boolean"?p.driveMacroBackoffEnabled:!0,k=Number.isFinite(g?.masterVolume)?g.masterVolume:ot.masterVolume,S=Number.isFinite(g?.alertVolume)?g.alertVolume:ot.alertVolume,w=Number.isFinite(g?.roverVolume)?g.roverVolume:ot.roverVolume,j=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:ot.mainBrushDuckEnabled,T=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):ot.mainBrushDuckAmount,E=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),C=$=>{n&&r($)},L=$=>{const X=$.target.value;x(P=>({...P??{},connectionTransport:X})),h?.io?.opts&&(h.io.opts.transports=X==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},G=$=>X=>{const P=Number(X.target.value),ce=Number.isFinite(P)?Math.max(0,Math.min(1,P)):0;b(ie=>({...ie??{},[$]:ce}))},O=$=>{const X=!!$.target.checked;b(P=>({...P??{},mainBrushDuckEnabled:X}))},z=$=>{const X=!!$.target.checked;x(P=>({...P??{},swapMobileControlColumns:X}))},K=$=>{const X=!!$.target.checked;x(P=>({...P??{},driveMacroBackoffEnabled:X}))};return l.jsxs(Cf,{defaultTab:"keybindings",children:[l.jsxs(kf,{children:[l.jsx(tn,{id:"keybindings",children:"Keybindings"}),l.jsx(tn,{id:"controller",children:"Controller"}),l.jsx(tn,{id:"page",children:"Page settings"}),l.jsx(tn,{id:"admin",children:"Admin"})]}),l.jsxs(Ef,{children:[l.jsx(nn,{id:"keybindings",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx($w,{})})}),l.jsx(nn,{id:"controller",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Pw,{})})}),l.jsx(nn,{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:$=>f($.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:N,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:K}),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:G("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(S*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:S,onChange:G("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:G("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:j,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(T*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:T,onChange:G("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!j})]}),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:v,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(nn,{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:rA.map($=>l.jsx("button",{type:"button",onClick:()=>s($.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:$.label},$.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($=>l.jsx("button",{type:"button",onClick:()=>C($.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:$.label},$.key))}),!o&&l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),l.jsx(Xg,{}),l.jsx(tA,{}),l.jsx(_w,{}),l.jsx(nA,{}),l.jsx(lA,{})]})})]})]})}const wx={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 iA(n){return wx[n]||wx.desktop}function Jg({actionId:n,keymap:s}){const r=s?.[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:qt(r)})}function Ax(n,s){return n.map((r,o)=>typeof r=="string"?l.jsx("span",{children:r},`text-${o}`):r?.action?l.jsx(Jg,{actionId:r.action,keymap:s},`pill-${r.action}-${o}`):r?.text?l.jsx("span",{children:r.text},`span-${o}`):null)}function Ho(n,s,r){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return Ax(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return Ax(n,s)}return String(n??"")}function oA({hero:n,keymap:s}){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:Ho(r,s)},u)})})]}):null}function cA({block:n,keymap:s}){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:Ho(r,s)},u)})})]})}function uA({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return l.jsxs("div",{className:`surface space-y-0.5 border ${s} 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:Ho(r,{})},`callout-${o}`))})]})}function dA({group:n,keymap:s}){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(Jg,{actionId:r.action,keymap:s})]},r.action))})]})}function fA({block:n,keymap:s}){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(dA,{group:r,keymap:s},r.id))})]}):null}function mA({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((s,r)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Ho(s,{})},`gamepad-${r}`))})]}):null}function Cx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return l.jsx(cA,{block:n,keymap:s});case"callout":return l.jsx(uA,{block:n});case"keyboard":return l.jsx(fA,{block:n,keymap:s});case"gamepad":return l.jsx(mA,{block:n});default:return null}}function Pg({layout:n,keymap:s}){const r=m.useMemo(()=>iA(n),[n]),o=s||{},u=r.main||[],f=r.aside||[];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(oA,{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(Cx,{block:h,keymap:o},h.title||p))}),l.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>l.jsx(Cx,{block:h,keymap:o},h.title||p))})]})]})}function Wg({layout:n,onOpenOverlay:s}){const{state:r}=At();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:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),l.jsx(Pg,{layout:n,keymap:r?.keymap||{}})]})}const hA=["kal","rms","slt","ksp","bdl"],pA=Array.from({length:10},(n,s)=>s*10);function Vo({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:r=!1,allowSpectatorInput:o=!1}){const u=xe(_=>_.session?.role||null),f=xe(_=>_.session?.assignment?.roverId||null),h=xe(_=>_.session?.roster??[]),{messages:p,typing:x,sendMessage:g,registerInputRef:b,onInputFocus:v,onInputBlur:N,blurChat:M,setTypingActive:k}=pf(),{value:S,save:w}=Fe("tts",{engine:"flite",voice:"rms",pitch:50}),[j,T]=m.useState(""),[E,C]=m.useState(!1),[L,G]=m.useState(!1),[O,z]=m.useState(()=>S?.engine||"flite"),[K,$]=m.useState(()=>S?.voice||"rms"),[X,P]=m.useState(()=>Number.isFinite(S?.pitch)?S.pitch:50),ce=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(()=>x||[],[x]);m.useEffect(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[H,J]),m.useEffect(()=>{const _=S?.engine||"flite",Z=S?.voice||"rms",ee=Number.isFinite(S?.pitch)?S.pitch:50;O!==_&&z(_),K!==Z&&$(Z),X!==ee&&P(ee)},[O,X,S?.engine,S?.pitch,S?.voice,K]),m.useEffect(()=>{G(!!q)},[q]);const te=m.useMemo(()=>!q||!L?null:O==="espeak"?{speak:!0,engine:O,pitch:X}:{speak:!0,engine:O,voice:K},[O,X,L,q,K]);async function de(_){if(_.preventDefault(),!ce||n)return;const ee=j.replace(/\\n/g,`
|
||
`).trim();if(ee){C(!0);try{await g(ee,te),T(""),M(),k(!1)}catch(fe){alert(fe.message)}finally{C(!1)}}}const R=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 ${R}`,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(ff,{message:_},_.id)),J.map(_=>l.jsx(yg,{message:_},`typing-${_.typingId||_.id}`))]}),!n&&l.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:de,children:[l.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:j,onChange:_=>{const Z=_.target.value;T(Z),k(!!Z.trim())},onFocus:_=>{v(_),k(!!j.trim())},onBlur:_=>{N(_),k(!1)},onKeyDown:_=>{_.key==="Enter"&&!j.trim()&&(_.preventDefault(),M(),k(!1))},ref:_=>b(_,{target:"panel"}),placeholder:ce?"Type a message…":s?"":"Spectators cannot chat",disabled:!ce}),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:_=>G(_.target.checked),className:"accent-cyan-500"}),l.jsx("span",{children:"Speak"})]}),l.jsxs("select",{value:O,onChange:_=>{const Z=_.target.value;z(Z),w(ee=>({...ee||{},engine:Z}))},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:K,onChange:_=>{const Z=_.target.value;$(Z),w(ee=>({...ee||{},voice:Z}))},className:"field-input text-xs",children:hA.map(_=>l.jsx("option",{value:_,children:_},_))}):l.jsx("select",{value:X,onChange:_=>{const Z=Number(_.target.value);P(Z),w(ee=>({...ee||{},pitch:Z}))},className:"field-input text-xs",children:pA.map(_=>l.jsxs("option",{value:_,children:["pitch ",_]},_))})]}),l.jsx("button",{type:"submit",disabled:!ce||E,className:"button-dark h-full disabled:opacity-50 self-stretch",children:E?"...":"Send"})]})]})}function Ur({compact:n=!1}){const s=xe(v=>v.session?.role||null),{setNickname:r}=Qt(),{value:o,save:u}=Fe("profile",{nickname:""}),[f,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=s!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function b(v){if(v.preventDefault(),!g)return;const N=(f||"").trim().slice(0,32);if(N){x(!0);try{await r(N),u({nickname:N})}catch(M){alert(M.message)}finally{x(!1)}}}return l.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:b,children:[l.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:v=>h(v.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),l.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":n?"Set":"Save"})]})}function xA({socials:n,discordInvite:s,kofiLink:r}){const o=Array.isArray(n)?n:null;if(o&&o.length)return o;const u=[];return s&&u.push({id:"discord",label:"Discord",url:s}),r&&u.push({id:"kofi",label:"Ko-fi",url:r}),u}function gA(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,r=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:r,url:o}:null}function eb({className:n=""}){const s=xe(o=>({socials:o.session?.socials??[],discordInvite:o.session?.discord?.invite||null,kofiLink:o.session?.kofi?.link||null})),r=xA(s).map(gA).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(kr,{...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(Ur,{compact:n})})})}function vA(){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx(eb,{className:"flex-1 min-h-0"})})}function Ad(...n){return n.filter(Boolean).join(" ")}function yA(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function SA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function jA(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 NA(n,s){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${r} (you)`:r}function $o({title:n="Rovers"}){const s=xe(j=>j.session?.role||null),r=xe(j=>j.session?.roster??[]),o=xe(j=>j.session?.turnQueues??{}),u=xe(j=>j.session?.users??[]),f=xe(j=>j.session?.socketId||null),{requestControl:h}=Qt(),[p,x]=m.useState({}),[g,b]=m.useState(()=>Date.now()),v=m.useMemo(()=>s&&s!=="spectator",[s]),N=m.useMemo(()=>s==="admin"||s==="lockdown"||s==="lockdown-admin",[s]),M=m.useMemo(()=>Object.values(o||{}).some(j=>j?.deadline||j?.idleDeadline),[o]);m.useEffect(()=>{if(!M)return;const j=setInterval(()=>{b(Date.now())},1e3);return()=>clearInterval(j)},[M]);const k=m.useMemo(()=>{const j=new Set(r.map(E=>String(E.id))),T=Object.keys(o||{}).filter(E=>!j.has(String(E))).map(E=>({id:E,name:E,locked:!1,batteryState:null}));return[...r,...T]},[r,o]);async function S(j){if(j){x(T=>({...T,[j]:!0}));try{await h(j)}catch(T){alert(T.message)}finally{x(T=>({...T,[j]:!1}))}}}const w=j=>u.find(T=>T.socketId===j)||{socketId:j,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(j=>{const T=String(j.id),E=o?.[T]||null,C=E?.queue||[],L=E?.idleDeadline||E?.deadline||null,G=L&&L>g?Math.ceil((L-g)/1e3):L?0:null,O=E?.current||null,z=O?C.findIndex(te=>te===O):-1,K=C.length>1?z>=0?C[(z+1)%C.length]:C[0]:null,$=!!(f&&O&&O===f),X=!!(f&&K&&K===f),P=G!=null&&($||X),ce=!!j.locked,ie=ce&&!N,V=!!(j?.private?.enabled&&j?.private?.open),q=j.lockReason?`locked: ${j.lockReason}`:"locked",H=ce?q:p[T]?"...":"request",J=v&&!ie&&!p[T];return l.jsxs("li",{className:Ad("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",ce?"bg-red-900/40":V?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&S(j.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:da(j.color,.16),children:j.name}),j.description?l.jsx("span",{className:"min-w-0 flex-1 truncate text-[0.7rem] text-slate-400",children:j.description}):null]}),P?l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:$?`${G}s left`:`Your turn in ${G}s`}):null]}),l.jsx("span",{className:Ad("text-[0.75rem] font-semibold",SA(j)),children:yA(j)})]}),C.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:C.map((te,de)=>{const R=w(te),_=te===O,Z=!!(K&&te===K&&!_),ee=_?"bg-sky-600 text-white ring-2 ring-amber-300":Z?"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] ${ee}`,children:[l.jsx("span",{className:`${jA(R.role)} font-semibold`,children:NA(R,f)}),_&&l.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),Z&&l.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${T}-${te}-${de}`)})})]}),v?l.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),S(j.id)},disabled:p[T]||ie,className:Ad("button-dark disabled:opacity-40",ce&&"bg-red-600/70 text-white hover:bg-red-600"),children:H}):null]},j.id)})})]})}function wA(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 AA(n,s){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${r} (you)`:r}function To({hideNicknameForm:n=!1,hideHeader:s=!1,className:r="",fillHeight:o=!1,compact:u=!1}){const f=xe(v=>v.session?.role||null),h=xe(v=>v.session?.users??[]),p=xe(v=>v.session?.socketId||null),x=f!=="spectator",g=m.useMemo(()=>[...h].sort((v,N)=>v.socketId===p?-1:N.socketId===p?1:(v.nickname||"").localeCompare(N.nickname||"")),[p,h]),b=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(Ur,{compact:u})})}),l.jsx(eb,{})]}),!x&&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:[!s&&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:g.length})]}),l.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${b} ${u?"text-[0.8rem]":""}`,children:g.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(v=>l.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${wA(v.role)}`,children:AA(v,p)},v.socketId))})]})]})}const CA=/^cu_[a-f0-9]{32}$/,qr="field-input w-full max-w-sm text-left focus:ring-emerald-500",Go="mx-auto w-full max-w-xl flex justify-center",jr="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function kA(n){const s=String(n||"").trim();return s?s.length<=10?`${s.slice(0,2)}***${s.slice(-2)}`:`${s.slice(0,6)}...${s.slice(-6)}`:""}const kx=8*1024*1024,is=16e3,EA={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function Ex(n){let s="";for(let o=0;o<n.length;o+=32768){const u=n.subarray(o,o+32768);s+=String.fromCharCode(...u)}return btoa(s)}function MA(n){return typeof btoa=="function"?btoa(n):""}function RA(n){if(!n)return{};const s=MA(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function TA(n,s=1500){return new Promise(r=>{if(!n||n.iceGatheringState==="complete"){r();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",u),r()},s);function u(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",u),r())}n.addEventListener("icegatheringstatechange",u)})}function Mx(n){if(!n)return!1;const s=n.connectionState,r=n.iceConnectionState;return s==="connected"||r==="connected"||r==="completed"}function qA(n,s=1e4){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Mx(n)){r();return}const u=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},s),f=()=>{Mx(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 DA(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},r=s.encodings&&s.encodings[0]||{};s.encodings=[{...r,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function _A(n,s=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>s){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of p){const g=await x.getStats();for(const b of g.values()){if(b.type!=="outbound-rtp"||b.kind!=="audio")continue;const v=Number(b.bytesSent||0),N=Number(b.packetsSent||0);if(f<0)f=v;else if(v>f+200||N>5){clearInterval(h),r();return}}}}catch{}},250)})}function OA(n){const s=n.reduce((u,f)=>u+f.length,0),r=new Float32Array(s);let o=0;for(const u of n)r.set(u,o),o+=u.length;return r}function BA(n){const s=new Int16Array(n.length);for(let r=0;r<n.length;r+=1){const o=Math.max(-1,Math.min(1,n[r]));s[r]=o<0?o*32768:o*32767}return s}function LA(n,s){const r=BA(n),o=r.length*2,u=new ArrayBuffer(44+o),f=new DataView(u),h=(x,g)=>{for(let b=0;b<g.length;b+=1)f.setUint8(x+b,g.charCodeAt(b))};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,s,!0),f.setUint32(28,s*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 x=0;x<r.length;x+=1,p+=2)f.setInt16(p,r[x],!0);return new Uint8Array(u)}function vn({label:n,active:s,detail:r=""}){return l.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"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||(s?"active":"idle")})]})}function Qd({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function zA({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:r,stopUploadedAudio:o,startMicWhip:u,readyMicWhip:f,stopMicWhip:h}){const{state:p}=At(),{value:x,save:g}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),b=String(n||"").trim(),[v,N]=m.useState(null),[M,k]=m.useState(!1),S=!!x?.openMicEnabled,j=(x?.pttMode==="clip"?"clip":"live")==="clip",[T,E]=m.useState("idle"),[C,L]=m.useState("idle"),[G,O]=m.useState(""),z=m.useRef(null),K=m.useRef(null),$=m.useRef(null),X=m.useRef(!1),P=m.useRef(""),ce=m.useRef(null),ie=m.useRef(null),V=m.useRef(null),q=m.useRef(null),H=m.useRef(null),J=m.useRef([]),te=m.useRef(!1),de=m.useRef(is),R=!!p?.mic?.pttActive,_=m.useMemo(()=>b&&s?.[b]||null,[s,b]),Z=!!(_&&_.state!=="offline"&&!_.error),ee=_?.source==="upload"&&_?.state==="playing",fe=_?.source==="mic-whip"&&(_?.state==="starting"||_?.state==="playing"),oe=!!(!j&&K.current&&(S||R)),ue=!j&&(T==="live"||T==="starting"),ge=j&&C==="recording",ve=j&&C==="sending",ye=qt(p?.keymap?.micPtt?.[0])||"M",Ye=m.useCallback(me=>{const Ae=me==="clip"?"clip":"live";g(Ce=>({...Ce||{},pttMode:Ae}))},[g]),Ke=async()=>{if(!b){O("Take control of your rover first.");return}if(!v){O("Select an audio file first.");return}if(v.size>kx){O(`File too large (max ${kx} bytes).`);return}k(!0),O("");try{const me=await v.arrayBuffer(),Ae=Ex(new Uint8Array(me));await r?.({roverId:b,name:v.name,mime:v.type||"",dataBase64:Ae}),O("Upload playback started.")}catch(me){O(me?.message||"Failed to play upload.")}finally{k(!1)}},Me=async()=>{if(!b){O("Take control of your rover first.");return}k(!0),O("");try{await o?.(b),O("Upload playback stopped.")}catch(me){O(me?.message||"Failed to stop upload.")}finally{k(!1)}},De=m.useCallback(async me=>{const Ae=String(me||P.current||"").trim();if(X.current=!1,E("idle"),$.current){try{$.current.getSenders().forEach(Ce=>Ce.track?.stop())}catch{}try{$.current.close()}catch{}}if($.current=null,z.current)try{z.current.getTracks().forEach(Ce=>Ce.stop())}catch{}if(z.current=null,K.current=null,Ae)try{await h?.(Ae)}catch{}P.current=""},[h]),_e=m.useCallback(async me=>{const Ae=await u?.(me),Ce=String(Ae?.whipUrl||"").trim(),Pe=String(Ae?.token||"").trim();if(!Ce||!Pe)throw new Error("WHIP endpoint unavailable");const le=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});z.current=le;const he=le.getAudioTracks()?.[0];if(K.current=he||null,he&&(he.enabled=!!(S||R)),he?.applyConstraints)try{await he.applyConstraints({channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const Oe=new RTCPeerConnection(EA);$.current=Oe,Oe.onconnectionstatechange=()=>{if(!X.current)return;const ln=Oe.connectionState;if(ln==="connected"){E("live");return}(ln==="failed"||ln==="disconnected"||ln==="closed")&&(E("error"),O(`WHIP transport ${ln}.`))},le.getAudioTracks().forEach(ln=>{const ml=Oe.addTrack(ln,le);DA(ml)});const Lt=await Oe.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await Oe.setLocalDescription(Lt),await TA(Oe,1800);const nt=await fetch(Ce,{method:"POST",headers:{"Content-Type":"application/sdp",...RA(Pe)},body:Oe.localDescription?.sdp||Lt.sdp});if(!nt.ok)throw new Error(`WHIP request failed: ${nt.status}`);const fl=await nt.text();await Oe.setRemoteDescription({type:"answer",sdp:fl}),await qA(Oe,1e4),await _A(Oe,6e3),await f?.(me)},[S,R,f,u]),Ct=m.useCallback(async()=>{if(te.current=!1,q.current){try{q.current.disconnect()}catch{}q.current.onaudioprocess=null}if(V.current)try{V.current.disconnect()}catch{}if(H.current)try{H.current.disconnect()}catch{}if(ce.current)try{ce.current.getTracks().forEach(me=>me.stop())}catch{}if(ie.current)try{await ie.current.close()}catch{}J.current=[],q.current=null,V.current=null,H.current=null,ce.current=null,ie.current=null,de.current=is},[]),re=m.useCallback(async()=>{if(ce.current&&ie.current&&q.current)return;L(he=>he==="recording"?he:"arming");const me=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),Ae=new AudioContext({latencyHint:"interactive"}),Ce=Ae.createMediaStreamSource(me),Pe=Ae.createScriptProcessor(1024,1,1),le=Ae.createGain();le.gain.value=0,Pe.onaudioprocess=he=>{if(!te.current)return;const Oe=he.inputBuffer.getChannelData(0);J.current.push(new Float32Array(Oe))},Ce.connect(Pe),Pe.connect(le),le.connect(Ae.destination),ce.current=me,ie.current=Ae,V.current=Ce,q.current=Pe,H.current=le,de.current=Ae.sampleRate||is},[]),se=m.useCallback(async({send:me})=>{const Ae=te.current;if(te.current=!1,!Ae){me||L("idle");return}const Ce=J.current;if(J.current=[],!me){L("idle");return}if(!b){L("idle");return}if(!Ce.length){L("idle");return}L("sending");try{const Pe=OA(Ce),le=LA(Pe,de.current||is),he=Ex(le);await r?.({roverId:b,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:he}),L("idle")}catch(Pe){L("error"),O(Pe?.message||"Failed to send PTT clip.")}},[r,b]),je=m.useCallback(async()=>{if(!b){O("Take control of your rover first.");return}await re(),J.current=[],te.current=!0,L("recording")},[re,b]);return m.useEffect(()=>{let me=!1;async function Ae(){if(j){await De(P.current||b);return}if(!b){await De(P.current);return}if(!(X.current&&P.current===b)&&!(!S&&!R))try{E("starting"),O(""),X.current=!0,P.current=b,await _e(b),me||E("live")}catch(Ce){me||(E("error"),O(Ce?.message||"Failed to start mic forwarding.")),await De(b)}}return Ae(),()=>{me=!0}},[j,S,R,b,_e,De]),m.useEffect(()=>{const me=K.current;me&&(me.enabled=!!(!j&&(S||R)))},[j,S,R]),m.useEffect(()=>{let me=!1;async function Ae(){if(!j||!b){te.current&&await se({send:!1}),L("idle");return}try{await re(),!me&&!te.current&&L("idle")}catch(Ce){me||(L("error"),O(Ce?.message||"Microphone access failed for clip mode."))}}return Ae(),()=>{me=!0}},[j,re,se,b]),m.useEffect(()=>{let me=!1;async function Ae(){if(j){if(!b){te.current&&await se({send:!1});return}if(R){if(!te.current)try{O(""),await je()}catch(Ce){me||(L("error"),O(Ce?.message||"Failed to start clip recording."))}}else te.current&&await se({send:!0})}}return Ae(),()=>{me=!0}},[j,se,R,b,je]),m.useEffect(()=>()=>{De(P.current||b),Ct()},[b,De,Ct]),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(Qd,{label:ye})]})}),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 ${j?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Ye("live"),children:"Live Mic (WHIP)"}),l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Ye("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(vn,{label:"Mode",active:j,detail:j?"record clip":"live mic"}),l.jsx(vn,{label:"PTT hold",active:R,detail:R?"held":"released"}),l.jsx(vn,{label:"Recording",active:ge,detail:ge?"capturing":"idle"}),l.jsx(vn,{label:"Playback",active:j&&ee,detail:j&&ee?"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:`${qr} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:M||!b,onChange:me=>N(me.target.files?.[0]||null)})]}),l.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:v?l.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[v.name," (",v.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||!b,onClick:Ke,children:M?"Working...":"Play Upload"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:M||!b,onClick:Me,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:S,disabled:!b||j,onChange:me=>g(Ae=>({...Ae||{},openMicEnabled:!!me.target.checked}))}),l.jsx("span",{children:j?"Open mic (live mode only)":"Open mic"})]}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(vn,{label:"WHIP link",active:ue,detail:T}),l.jsx(vn,{label:"Mic hot",active:oe,detail:oe?"transmitting":"muted"}),l.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",l.jsx(Qd,{label:ye})," 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(vn,{label:"Forward pipe",active:Z,detail:Z?"connected":"offline"}),l.jsx(vn,{label:"Upload playback",active:ee,detail:ee?"playing":"idle"}),l.jsx(vn,{label:"Mic relay",active:fe,detail:fe?"active":"idle"}),l.jsx(vn,{label:"WHIP transport",active:ue,detail:T}),l.jsx(vn,{label:"Clip recording",active:ge,detail:ge?"recording":"idle"}),l.jsx(vn,{label:"Clip sending",active:ve,detail:ve?"sending":"idle"})]}),G?l.jsx("div",{className:"text-xs text-slate-400 text-center",children:G}):null]})})]})})}function UA({pendingRequestId:n,currentStoredKey:s,nickname:r,requestVerification:o,applyIdentityKey:u,onMessage:f,fullWidth:h=!1}){const[p,x]=m.useState(0),[g,b]=m.useState(""),[v,N]=m.useState(!1),[M,k]=m.useState(!1),S=()=>{x(1),b(s),N(!1),f?.("")},w=()=>{x(0),N(!1)},j=async E=>{if(E.preventDefault(),!v){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 C=await u(g);await o?.(),b(C),x(0),N(!1),f?.("Verification request sent to lockdown admins.")}catch(C){f?.(C.message||"Failed to submit request.")}finally{k(!1)}},T=h?"w-full":Go;return n?l.jsx("section",{className:`surface text-sm text-slate-300 ${T}`,children:l.jsxs("div",{className:jr,children:["Verification request pending: ",n]})}):p===0?l.jsx("section",{className:`surface ${T}`,children:l.jsxs("div",{className:jr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:S,disabled:M,children:"Request Verification"})]})}):l.jsx("form",{className:`surface ${T}`,onSubmit:j,children:l.jsxs("div",{className:jr,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(Ur,{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:v,onChange:E=>N(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||!v,onClick:()=>x(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:qr,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:E=>b(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:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(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:qr,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:E=>b(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||!g,children:"Confirm Request"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function HA({currentStoredKey:n,applyIdentityKey:s,onMessage:r,fullWidth:o=!1}){const[u,f]=m.useState(0),[h,p]=m.useState(""),[x,g]=m.useState(!1),b=()=>{f(1),p(""),r?.("")},v=()=>{f(0),p("")},N=async k=>{if(k.preventDefault(),!(u<2)){g(!0),r?.("");try{await s(h),f(0),p(""),r?.("Identity key restored.")}catch(S){r?.(S.message||"Failed to restore key.")}finally{g(!1)}}},M=o?"w-full":Go;return l.jsx("section",{className:`surface ${M}`,children:l.jsxs("div",{className:jr,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",kA(n)||"not set yet"]}),l.jsx("input",{className:qr,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:b,disabled:x,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:v,children:"Cancel"})]})]}):null,u===2?l.jsxs("form",{className:"space-y-0.5",onSubmit:N,children:[l.jsx("input",{className:qr,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:x||!h,children:"Confirm Restore"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function VA({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:r,onMessage:o,fullWidth:u=!1}){const[f,h]=m.useState({}),p=m.useMemo(()=>{const b=new Map;return(s||[]).forEach(v=>{v?.roverId&&b.set(String(v.roverId),v)}),b},[s]),x=u?"w-full":Go,g=async b=>{if(b){h(v=>({...v,[b]:!0})),o?.("");try{(await r?.(b))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(v){o?.(v.message||"Failed to send request.")}finally{h(v=>({...v,[b]:!1}))}}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:l.jsxs("div",{className:jr,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(b=>{const v=String(b.id),N=!!f[v],M=p.get(v);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:b.name||v}),l.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:v})]}),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:()=>g(v),disabled:N,className:"button-dark text-xs disabled:opacity-50",children:N?"Sending...":"Request"})]},v)})})]})})}function nl(n){return String(n||"").trim()}function $A(n){const s=nl(n);return s?s.includes("DOCKINGRUNNING")?"Returning":s.includes("PAUSED")?"Paused":s.includes("HOUSECLEANINGRUNNING")?"Cleaning":s.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":s.includes("STATE_START")?"Starting":s.includes("STATE_IDLE")||s.includes("STATE_STANDBY")?"Idle":s:"--"}function tb(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 uo({label:n,value:s,tone:r="muted",valueClass:o="",hideLabel:u=!1}){return l.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${tb(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(s||""),children:s})]})}function GA(n=[]){const u=[...n.filter(k=>k&&k.valid&&Number.isFinite(k.angleDeg)&&Number.isFinite(k.distanceMm))].sort((k,S)=>Number(k.angleDeg)-Number(S.angleDeg)),f=[];let h=[];for(const k of u){if(!h.length){h.push(k);continue}const S=h[h.length-1],w=Math.abs(Number(k.angleDeg)-Number(S.angleDeg)),j=Math.max(0,Number(S.distanceMm)),T=Math.max(0,Number(k.distanceMm)),E=Math.abs(T-j);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 S=k.map(j=>Math.max(0,Number(j.distanceMm))),w=S.reduce((j,T)=>j+T,0)/Math.max(1,S.length);return{points:k,size:k.length,avgDistanceMm:w}}),g=p.reduce((k,S)=>S.size>(k?.size||0)?S:k,null)?.avgDistanceMm||1e3,b=p.filter(k=>{const S=k.size<=3,w=k.avgDistanceMm>g*1.8&&k.avgDistanceMm-g>1400;return!(S&&w)}).flatMap(k=>k.points),v=b.map(k=>Math.max(0,Number(k.distanceMm))).sort((k,S)=>k-S),N=Math.max(0,Math.floor((v.length-1)*.95)),M=Math.max(1e3,v[N]||1e3);return b.map(k=>{const S=(Number(k.angleDeg)-90)*Math.PI/180,w=Math.max(0,Number(k.distanceMm)),T=Math.max(0,Math.min(1,w/M))*102,E=110+Math.cos(S)*T,C=110+Math.sin(S)*T,G=38+Math.max(0,Math.min(255,Number(k.intensity)||0))/255*38;return{key:`${k.angleDeg}-${k.distanceMm}-${k.intensity}`,x:E,y:C,fill:`hsl(198 100% ${G}%)`}})}function FA({neato:n,lidar:s,lidarActive:r=!0,onStart:o,onSendHome:u,onLocate:f,onClearErrors:h,onPowerCycle:p,fullWidth:x=!1}){const[g,b]=m.useState(""),[v,N]=m.useState(!1),[M,k]=m.useState(!1),S=x?"w-full":"w-full max-w-xl",w=!!n?.configured,j=!!(n?.enabled&&n?.connected),T=!!n?.telemetry?.extPowerPresent,E=!!n?.telemetry?.chargingActive,C=$A(n?.telemetry?.uiState),L=nl(n?.telemetry?.robotState)||"--",G=n?.telemetry?.batteryPercent,O=Number.isFinite(G)?`${G}%`:"--",z=n?.telemetry?.batteryVoltage,K=Number.isFinite(z)?`${z.toFixed(2)} V`:"--",$=nl(n?.telemetry?.robotError)||"--",X=nl(n?.telemetry?.robotAlert)||"--",P=Array.isArray(s?.points)?s.points:[],ce=m.useMemo(()=>r?GA(P):[],[r,P]),ie=nl(s?.status)||"--",V=s?.debug&&typeof s.debug=="object"?s.debug:null,q=nl(V?.reason)||"--",H=V?.stats&&typeof V.stats=="object"?V.stats:null,J=n?.controls||{},te=!!J?.start?.available,de=!!J?.sendHome?.available,R=!!J?.locate?.available,_=!!J?.clearErrors?.available,Z=!!J?.powerCycle?.available,ee=w&&j&&te,fe=w&&j&&de,oe=w&&j&&R,ue=w&&j&&_,ge=w&&j&&Z,ve=async(De,_e)=>{if(_e){b(De);try{await _e()}catch{}finally{b("")}}},ye=w?j?"Online":"Offline":"Not configured",Ye=w?j?"good":"danger":"warn",Ke=G==null?"muted":G>=60?"good":G>=25?"warn":"danger",Me=T?"Docked":C!=="--"?C:"Away from dock";return m.useEffect(()=>{if(!r||!s||!Array.isArray(s.points))return;N(!0);const De=setTimeout(()=>{N(!1)},120);return()=>clearTimeout(De)},[s,r]),l.jsx("section",{className:`surface text-sm text-slate-200 ${S}`,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 ${tb(Ye)}`,children:ye})]}),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:!ee||!!g,onClick:()=>ve("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:g==="start"?"Starting...":"Start cleaning"}),l.jsx("button",{type:"button",disabled:!fe||!!g,onClick:()=>ve("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:g==="sendHome"?"Sending...":"Send to dock"}),l.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[l.jsx("button",{type:"button",disabled:!oe||!!g,onClick:()=>ve("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:g==="locate"?"Playing...":"Play sound"}),l.jsx("button",{type:"button",disabled:!ue||!!g,onClick:()=>ve("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:g==="clearErrors"?"Clearing...":"Clear errors"}),l.jsx("button",{type:"button",disabled:!ge||!!g,onClick:()=>ve("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:g==="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(uo,{label:"Battery",value:O,tone:Ke}),l.jsx(uo,{label:"Voltage",value:K,tone:"muted"}),l.jsx(uo,{label:"Docked",value:T?"Docked":"Not docked",tone:T?"good":"muted",hideLabel:!0}),l.jsx(uo,{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:Me})]}),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:C})]}),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:$})]}),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:X})]})]}),l.jsxs("div",{className:`rounded-md px-1 py-0.5 ${v?"bg-emerald-900":"bg-slate-800"}`,children:[l.jsx("button",{type:"button",onClick:()=>k(De=>!De),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:ce.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"}),ce.map(De=>l.jsx("circle",{cx:De.x,cy:De.y,r:"1.8",fill:De.fill},De.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(s?.rotationSpeed)?s.rotationSpeed.toFixed(2):"--"]}),l.jsxs("div",{children:["Request in flight: ",V?.requestInFlight?"yes":"no"]}),l.jsxs("div",{children:["Started at: ",V?.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||!j||!te||!de||!R||!_||!Z?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:w?j?"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 YA(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 XA(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function QA({lift:n,onUp:s,onDown:r,fullWidth:o=!1}){const[u,f]=m.useState(""),[h,p]=m.useState(()=>Date.now()),x=o?"w-full":"w-full max-w-xl",g=!!n?.configured,b=!!(n?.enabled&&n?.connected),v=!!n?.busy,N=String(n?.target||"").toLowerCase(),M=String(n?.position||"").toLowerCase(),k=!!n?.availability?.upSwitch,S=!!n?.availability?.downSwitch,w=Number(n?.lastActionAt||0),j=Math.max(0,Number(n?.commandCooldownMs||0)),T=Math.max(0,w+j-h),E=!v&&T>0,C=v||E;m.useEffect(()=>{if(!C)return;const $=setInterval(()=>{p(Date.now())},100);return()=>clearInterval($)},[C]),m.useEffect(()=>{p(Date.now())},[w,j,v]);const L=g?b?C?"Busy":"Ready":"Offline":"Not configured",G=g?b?C?"warn":"good":"danger":"warn",O=g&&b&&!C&&!u&&k&&S,z=m.useMemo(()=>Math.ceil(T/1e3),[T]),K=async($,X)=>{if(X){f($);try{await X()}catch{}finally{f("")}}};return l.jsxs("section",{className:`surface relative text-sm text-slate-200 ${x}`,children:[C?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:v?"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."}),!v&&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 ${YA(G)}`,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:XA(M)})]}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>K("down",r),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="down"||N==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="down"||N==="down"?"Lowering...":"Down"}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>K("up",s),className:`button-dark w-full text-sm disabled:opacity-50 ${M==="up"||N==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="up"||N==="up"?"Raising...":"Up"})]})}),!g||!b||!k||!S?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:g?b?"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 nb({isActive:n=!0}){const s=xe(V=>V.session),r=xe(V=>V.neatoLidar),{identifySession:o,requestVerification:u,requestPrivateRoverAccess:f,playUploadedAudio:h,stopUploadedAudio:p,startMicWhip:x,readyMicWhip:g,stopMicWhip:b,neatoStart:v,neatoSendHome:N,neatoLocate:M,neatoClearErrors:k,neatoPowerCycle:S,liftUp:w,liftDown:j}=Qt(),{value:T,save:E}=Fe("identity",{cookieUserId:""}),{value:C}=Fe("profile",{nickname:""}),L=m.useMemo(()=>(T?.cookieUserId||"").trim(),[T?.cookieUserId]),G=(C?.nickname||"").trim(),O=!!s?.isVerified,z=s?.verification?.pendingRequestId||null,K=s?.privateRoverAccess?.requestableRovers||[],$=s?.privateRoverAccess?.pendingRequests||[],X=String(s?.assignment?.roverId||"").trim(),[P,ce]=m.useState(""),ie=async V=>{const q=String(V||"").trim().toLowerCase();if(!q)throw new Error("Identity key required.");if(!CA.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:G}),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(UA,{pendingRequestId:z,currentStoredKey:L,nickname:G,requestVerification:u,applyIdentityKey:ie,onMessage:ce,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:O?l.jsxs("div",{className:"space-y-2",children:[l.jsx(FA,{neato:s?.neato||null,lidar:r,lidarActive:n,onStart:v,onSendHome:N,onLocate:M,onClearErrors:k,onPowerCycle:S,fullWidth:!0}),l.jsx(QA,{lift:s?.lift||null,onUp:w,onDown:j,fullWidth:!0}),l.jsx(zA,{ownRoverId:X,audioForwardByRover:s?.audioForward||{},playUploadedAudio:h,stopUploadedAudio:p,startMicWhip:x,readyMicWhip:g,stopMicWhip:b})]}):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(VA,{requestableRovers:K,pendingRequests:$,requestPrivateRoverAccess:f,onMessage:ce,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(HA,{currentStoredKey:L,applyIdentityKey:ie,onMessage:ce,fullWidth:!0})})]}),P?l.jsx("div",{className:Go,children:l.jsx("p",{className:"text-xs text-slate-400 text-center",children:P})}):null]})}const KA=420,IA=1200,ZA={1:262,2:330,3:392,4:523};function qo(){const n=xe(S=>S.session?.buttonBox?.buttons??[]),s=sn(),{value:r}=Fe("audio",ot),o=Number.isFinite(r?.masterVolume)?r.masterVolume:ot.masterVolume,u=Number.isFinite(r?.alertVolume)?r.alertVolume:ot.alertVolume,f=Math.max(0,Math.min(1,o*u)),h=m.useMemo(()=>{const S=Array.isArray(n)?n:[];return S.length===4?S:[1,2,3,4].map(w=>S.find(j=>Number(j?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n]),[p,x]=m.useState({}),[g,b]=m.useState({}),v=m.useRef(new Map),N=m.useRef(new Map),M=m.useRef({}),k=m.useRef(null);return m.useEffect(()=>{const S={};h.forEach(j=>{S[j.id]=Number(j.lastRewardAt||0)});const w=M.current||{};h.forEach(j=>{const T=Number(j.id),E=S[T]||0,C=Number(w[T]||0);if(E>0&&E!==C){b(O=>({...O,[T]:!0}));const L=N.current.get(T);L&&clearTimeout(L);const G=setTimeout(()=>{b(O=>({...O,[T]:!1})),N.current.delete(T)},IA);N.current.set(T,G)}}),M.current=S},[h]),m.useEffect(()=>{function S(j){const T=ZA[j];if(!T||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 C=E.createOscillator(),L=E.createGain();C.type="square",C.frequency.value=T;const G=.14*f;L.gain.setValueAtTime(1e-4,E.currentTime),L.gain.exponentialRampToValueAtTime(Math.max(1e-4,G),E.currentTime+.01),L.gain.exponentialRampToValueAtTime(1e-4,E.currentTime+.2),C.connect(L),L.connect(E.destination),C.start(),C.stop(E.currentTime+.21)}function w(j={}){const T=Number(j.buttonId);if(!Number.isFinite(T)||T<1||T>4)return;x(L=>({...L,[T]:!0}));const E=v.current.get(T);E&&clearTimeout(E);const C=setTimeout(()=>{x(L=>({...L,[T]:!1})),v.current.delete(T)},KA);v.current.set(T,C),S(T)}return s.on("buttonBox:increment",w),()=>{s.off("buttonBox:increment",w)}},[f,s]),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(S=>{const w=Number(S.id),j=Number.isFinite(S.count)?S.count:0,T=Number.isFinite(S.goal)?S.goal:0,E=typeof S.rewardName=="string"&&S.rewardName.trim()?S.rewardName.trim():"Unassigned",C=Number.isFinite(S.rewardNumber)?S.rewardNumber:"?",L=!!p[w],G=!!g[w];return l.jsx(Sg,{buttonId:w,count:j,goal:T,rewardNumber:C,rewardName:E,className:[L?"bg-cyan-900/45":"",G?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function JA(){const{state:{roverId:n}}=At(),r=dl(n)?.sensors||{};return l.jsx("section",{className:"panel-section",children:l.jsx("div",{className:"aspect-square w-full",children:l.jsx(Xd,{sensors:r})})})}function PA(){const{state:{roverId:n,keymap:s,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:h,startHorn:p,stopHorn:x}}=At(),g=Bg(n),b=g.docked&&!g.driving,v=r?.config,N=!!(n&&r?.enabled&&v),M=!!(n&&u?.nightVision),k=u?.nightVisionState,S=!!(n&&u?.horn),w=o?.overheated,j=typeof v?.minAngle=="number"?v.minAngle:-30,T=typeof v?.maxAngle=="number"?v.maxAngle:30,E=typeof r?.angle=="number"?r.angle:typeof v?.homeAngle=="number"?v.homeAngle:(j+T)/2,C=qt(s?.nightVisionToggle?.[0]),L=qt(s?.hornHonk?.[0]),G=qt(s?.cameraUp?.[0]),O=qt(s?.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(Lg,{layout:"desktop",expand:!0,driveDockState:g}),b?null:l.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[M&&l.jsx(zg,{nightVisionOn:k?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:C}),S&&l.jsx(Ug,{disabled:!n||w,onStart:p,onStop:x,keyLabel:L,active:o?.active,heat:o?.heat}),N&&l.jsx(Hg,{value:E,min:j,max:T,onChange:f,keyDownLabel:O,keyUpLabel:G,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 WA({layout:n,onOpenHelpOverlay:s}){const[r,o]=m.useState("telemetry"),u=xe(S=>!!S.session?.isVerified),f=xe(S=>String(S.session?.assignment?.roverId||"").trim()),h=xe(S=>{const w=String(S.session?.assignment?.roverId||"").trim();return w&&S.session?.audioForward?.[w]||null}),{state:p}=At(),{value:x}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),g=u?"bg-emerald-400":"bg-red-600",b=!!p?.mic?.pttActive,v=!!x?.openMicEnabled,N=x?.pttMode==="clip"?"clip":"live",M=!!(f&&u&&(N==="clip"?b:v||b)),k=!!(f&&u&&N==="clip"&&h?.source==="upload"&&h?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(Cf,{defaultTab:"telemetry",currentTab:r,onTabChange:o,children:[l.jsxs(kf,{children:[l.jsx(tn,{id:"telemetry",children:"Controls"}),l.jsx(tn,{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 ${g}`,"aria-hidden":"true",title:u?"Verified":"Not verified"})]})}),l.jsx(tn,{id:"help",children:"Help"}),l.jsx(tn,{id:"settings",children:"Settings"})]}),l.jsxs(Ef,{children:[l.jsx(nn,{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(JA,{}),l.jsx(PA,{})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[l.jsx($o,{}),l.jsx(uf,{panelId:"replay-sources-desktop",fillHeight:!0}),l.jsx(vA,{})]}),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(Vo,{fillHeight:!0}),l.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[l.jsx(To,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),l.jsx(bA,{compact:!0})]})]}),l.jsx(Yg,{}),l.jsx(qo,{}),l.jsx(bf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),l.jsx(nn,{id:"vip",keepMounted:!0,children:l.jsx(nb,{isActive:r==="vip"})}),l.jsx(nn,{id:"help",children:l.jsx(Wg,{layout:n,onOpenOverlay:s})}),l.jsx(nn,{id:"settings",children:l.jsx(Zg,{})})]})]})})}const e2=new Set(["admin","lockdown","lockdown-admin"]),t2=new Set(["lockdown","lockdown-admin"]),n2=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 s2(){const n=xe(v=>v.session?.mode||null),s=xe(v=>v.session?.role||null),r=xe(v=>v.session?.adminReason?.text||"");xe(v=>v.session?.adminReason?.updatedAt||null);const o=xe(v=>v.session?.timezone||"UTC"),u=xe(v=>(v.session?.socials||[]).find(k=>String(k?.id||k?.label||"").toLowerCase()==="discord")?.url||v.session?.discord?.invite||null),f=n2.has(n),h=n==="lockdown"?t2.has(s):e2.has(s),[p,x]=m.useState(()=>new Date),g=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 v=setInterval(()=>x(new Date),1e3);return()=>clearInterval(v)},[]),!f||h)return null;const b=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:b.title}),l.jsx("p",{className:"text-sm text-slate-300",children:b.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: ",g]})]}),l.jsx("div",{className:"surface-muted",children:l.jsx(Xg,{})}),l.jsx("div",{className:"w-full justify-center items-center",children:l.jsx(kr,{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(Vo,{}),l.jsx(Ur,{})]})]})})}const l2="/assets/turn_alert-DVO8EZJa.mp3";function r2(n,s=1){const r=m.useRef(null);return m.useEffect(()=>{r.current=new Audio(n),r.current.volume=s,r.current.load()},[n,s]),()=>{r.current&&(r.current.volume=s,r.current.currentTime=0,r.current.play().catch(()=>{}))}}function i2(){const n=xe(b=>b.session?.socketId||null),s=xe(b=>b.session?.turnQueues||{}),r=xe(b=>b.session?.roster||[]),{pushAlert:o}=Qt(),{value:u}=Fe("audio",ot),f=Number.isFinite(u?.masterVolume)?u.masterVolume:ot.masterVolume,h=Number.isFinite(u?.alertVolume)?u.alertVolume:ot.alertVolume,p=Math.max(0,Math.min(1,f*h)),x=r2(l2,p),g=m.useRef(new Set);return m.useEffect(()=>{if(!n)return;const b=[];Object.entries(s).forEach(([v,N])=>{!N||!N.current||N.current!==n||g.current.has(v)||(b.push(v),g.current.add(v))}),Object.keys(s).forEach(v=>{(!s[v]||s[v].current!==n)&&g.current.delete(v)}),b.length!==0&&(b.forEach(v=>{const N=r.find(M=>String(M.id)===String(v))?.name||v;o({title:"Your turn!",message:`You now control ${N}.`,color:"#ff5722"})}),x())},[s,x,o,r,n]),null}function o2({visible:n,mode:s,onEnterFullscreen:r,onDismiss:o}){if(!n)return null;const u=s==="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 c2({side:n="right",onClick:s}){const r=n==="left"?"left-2":"right-2";return l.jsx("button",{type:"button",onClick:s,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 ab="fullscreenPromptDismissed",u2=new Set(["mobile-portrait","mobile-landscape"]),sb=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},d2=()=>{const n=sb();if(!n)return!1;try{return n.getItem(ab)==="1"}catch{return!1}},Rx=()=>{const n=sb();if(n)try{n.setItem(ab,"1")}catch{}},f2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Tx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function m2(n){const s=u2.has(n),[r,o]=m.useState(!1),[u,f]=m.useState("native"),[h,p]=m.useState(!1),x=m.useMemo(()=>f2(),[]),g=m.useMemo(()=>Tx(),[]),b=m.useCallback(()=>{if(!s){o(!1),p(!1);return}if(!h&&d2()){o(!1);return}if(x){f("pwa-hint"),o(!0);return}if(!Tx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[h,x,s]);m.useEffect(()=>{b()},[b]),m.useEffect(()=>{if(typeof document>"u")return;const k=()=>{if(document.fullscreenElement){p(!1),o(!1);return}b()};return document.addEventListener("fullscreenchange",k),document.addEventListener("webkitfullscreenchange",k),()=>{document.removeEventListener("fullscreenchange",k),document.removeEventListener("webkitfullscreenchange",k)}},[b]);const v=m.useCallback(()=>{Rx(),p(!1),o(!1)},[]),N=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const k=document.documentElement;if(!k)return!1;const S=k.requestFullscreen||k.webkitRequestFullscreen||k.mozRequestFullScreen||k.msRequestFullscreen;if(!S)return!1;try{const w=S.call(k);return w&&typeof w.then=="function"&&await w,Rx(),p(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[x,s]),M=m.useCallback(()=>{s&&(p(!0),f(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(p(!1),o(!1))},[s]),{visible:r,mode:u,isIOS:x,nativeSupported:g,enterFullscreen:N,dismiss:v,showPrompt:M}}function h2({visible:n,layout:s,onClose:r,showOnLoad:o,onToggleShowOnLoad:u}){if(!n)return null;const{state:f}=At(),h=p=>{const x=!p.target.checked;u?.(x)};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(Pg,{layout:s,keymap:f?.keymap||{}})})]})})}function el({label:n,keyLabel:s}){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(Qd,{label:s})]})}function p2({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(el,{label:"Forward",keyLabel:qt(n?.driveForward?.[0])}),l.jsx(el,{label:"Backward",keyLabel:qt(n?.driveBackward?.[0])}),l.jsx(el,{label:"Turn Left",keyLabel:qt(n?.driveLeft?.[0])}),l.jsx(el,{label:"Turn Right",keyLabel:qt(n?.driveRight?.[0])}),l.jsx(el,{label:"Move faster",keyLabel:qt(n?.boostModifier?.[0])}),l.jsx(el,{label:"Move slower",keyLabel:qt(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 x2(){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 g2({visible:n,layout:s,showOnLoad:r,onToggleShowOnLoad:o,onOpenHelp:u,onClose:f}){const{state:h}=At(),p=s==="desktop",x=xe(v=>(v.session?.socials||[]).find(k=>String(k?.id||k?.label||"").toLowerCase()==="discord")?.url||v.session?.discord?.invite||null),g=m.useMemo(()=>h?.keymap||{},[h?.keymap]);if(!n)return null;const b=v=>{const N=!v.target.checked;o?.(N)};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(p2,{keymap:g}):l.jsx(x2,{})}),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(Ur,{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(kr,{id:"discord",label:"Join Discord",url:x})]})]})]}),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:b,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 v2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function y2(){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 Mf(){const{setNickname:n}=Qt(),{value:s,status:r,save:o}=Fe("profile",{nickname:""}),u=m.useRef(!1);m.useEffect(()=>{if(r!=="ready"||u.current||(s.nickname||"").trim())return;u.current=!0;const h=v2(y2()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,r,s.nickname])}function S2(){const n=sn(),s=xe(w=>w.connected),{identifySession:r}=Qt(),{value:o,status:u,save:f}=Fe("identity",{cookieUserId:""}),{value:h,status:p}=Fe("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),b=m.useRef(null),v=u==="ready"&&p==="ready",N=(o?.cookieUserId||"").trim(),M=(h?.nickname||"").trim(),k=m.useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null)},[]),S=m.useCallback(async()=>{if(!(!v||!s||!n?.id||x.current)){x.current=!0;try{const j=((await r({cookieUserId:N,nickname:M}))?.cookieUserId||"").trim();j&&j!==N&&f(T=>({...T||{},cookieUserId:j})),g.current=n.id,k()}catch{k(),b.current=setTimeout(()=>{S()},2e3)}finally{x.current=!1}}},[k,s,N,r,M,v,f,n?.id]);m.useEffect(()=>{!v||!s||!n?.id||g.current!==n.id&&S()},[s,v,S,n?.id]),m.useEffect(()=>{!v||!s||!n?.id||S()},[v,s,n?.id,N,M,S]),m.useEffect(()=>{const w=()=>{n?.connected&&S()},j=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&S()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",j)}},[S,n?.connected]),m.useEffect(()=>()=>k(),[k])}const Cd=1e4,kd=28,j2=14;function Do({layout:n="desktop",className:s="",dismissable:r=!0}){const o=xe(j=>{const T=j.session?.globalObjective?.text;return T?String(T).trim():""}),u=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[f,h]=m.useState(!1),[p,x]=m.useState(kd),[g,b]=m.useState(0),v=m.useRef(null),N=m.useRef(null),M=m.useRef(null);m.useEffect(()=>{if(!o){h(!1);return}if(h(!0),!u||!r)return;const j=Date.now();b(Cd);const T=setTimeout(()=>h(!1),Cd),E=setInterval(()=>{const C=Date.now()-j;b(Math.max(0,Cd-C))},250);return()=>{clearTimeout(T),clearInterval(E)}},[o,u]),m.useEffect(()=>{if(!o)return;x(kd);let j=0;const T=()=>{const C=M.current,L=N.current;if(!C||!L)return;const G=C.clientWidth;if(!G)return;const O=L.scrollWidth;if(!O)return;const z=Math.min(1,G/O),K=Math.max(j2,Math.floor(kd*z));x(K)};j=window.requestAnimationFrame(T);const E=new ResizeObserver(()=>{window.cancelAnimationFrame(j),j=window.requestAnimationFrame(T)});return v.current&&E.observe(v.current),()=>{window.cancelAnimationFrame(j),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",s].filter(Boolean).join(" "),[s,u]);if(!o||!f)return null;const S=u?Math.ceil(g/1e3):null,w=r?{onClick:()=>h(!1),role:"button",tabIndex:0}:{};return l.jsx("div",{ref:v,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:N,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:[S,"s"]}):null]})})}const N2=3200;function w2(n={}){const s=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:s,goal:r,count:o,ts:Date.now()}}function lb(){const n=sn(),{value:s}=Fe("audio",ot),r=Number.isFinite(s?.masterVolume)?s.masterVolume:ot.masterVolume,o=Number.isFinite(s?.alertVolume)?s.alertVolume:ot.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 x=null;function g(){const N=p.current;N&&(N.volume=u,N.currentTime=0,N.play().catch(()=>{}))}function b(N={}){const M=w2(N);h(M),g(),x&&clearTimeout(x),x=setTimeout(()=>{h(null)},N2)}function v(N){b(N?.detail||{})}return n.on("buttonBox:rewardRun",b),window.addEventListener("buttonBox:rewardRunLocalTest",v),()=>{x&&clearTimeout(x),n.off("buttonBox:rewardRun",b),window.removeEventListener("buttonBox:rewardRunLocalTest",v)}},[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 A2(){const[n,s]=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?s("desktop"):o>u?s("mobile-landscape"):s("mobile-portrait")}return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),n}function C2({layout:n,onOpenHelpOverlay:s}){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(jf,{}),l.jsx(rj,{}),l.jsx(vf,{})]}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[l.jsx(Do,{layout:n}),l.jsx(WA,{layout:n,onOpenHelpOverlay:s})]})]})}function rb({layout:n,onOpenHelpOverlay:s,roomPanelId:r,showTelemetry:o=!0}){const[u,f]=m.useState("chat"),h=xe(j=>!!j.session?.isVerified),p=xe(j=>String(j.session?.assignment?.roverId||"").trim()),x=xe(j=>{const T=String(j.session?.assignment?.roverId||"").trim();return T&&j.session?.audioForward?.[T]||null}),{state:g}=At(),{value:b}=Fe("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=h?"bg-emerald-400":"bg-amber-400",N=!!g?.mic?.pttActive,M=!!b?.openMicEnabled,k=b?.pttMode==="clip"?"clip":"live",S=!!(p&&h&&(k==="clip"?N:M||N)),w=!!(p&&h&&k==="clip"&&x?.source==="upload"&&x?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(Cf,{defaultTab:"chat",currentTab:u,onTabChange:f,children:[l.jsxs(kf,{children:[l.jsx(tn,{id:"chat",children:"Chat"}),l.jsx(tn,{id:"vip",highlight:w?"green":S?"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 ${v}`,"aria-hidden":"true",title:h?"Verified":"Not verified"})]})}),l.jsx(tn,{id:"roomcontrols",children:"Room Controls"}),l.jsx(tn,{id:"help",children:"Help"}),l.jsx(tn,{id:"settings",children:"Settings"})]}),l.jsxs(Ef,{children:[l.jsx(nn,{id:"chat",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Vo,{}),l.jsx(To,{})]})}),l.jsx(nn,{id:"vip",keepMounted:!0,children:l.jsx(nb,{isActive:u==="vip"})}),l.jsx(nn,{id:"roomcontrols",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Yg,{}),l.jsx(qo,{}),l.jsx(bf,{panelId:r})]})}),l.jsx(nn,{id:"help",children:l.jsx(Wg,{layout:n,onOpenOverlay:s})}),l.jsx(nn,{id:"settings",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Zg,{}),l.jsx(vf,{})]})})]})]})})}function k2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx(jf,{layoutFormat:"mobile-portrait"}),l.jsx(qN,{swapColumns:s}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(uf,{panelId:"replay-sources-mobile-portrait"}),l.jsx($o,{})]}),l.jsx(rb,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function E2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const r="self-start h-[min(100svh,32rem)]",o=s?l.jsx(Mo,{layout:"landscape",className:r}):l.jsx(Eo,{layout:"landscape",className:r}),u=s?l.jsx(Eo,{layout:"landscape",className:r}):l.jsx(Mo,{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(jf,{layoutFormat:"mobile-landscape"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(uf,{panelId:"replay-sources-mobile-landscape"}),l.jsx($o,{})]})]}),u]}),l.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:l.jsx(rb,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function M2(){const n=A2(),s=n==="desktop",r=m2(n);return l.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:l.jsx(R2,{layout:n,isDesktop:s,fullscreen:r})})}function R2({layout:n,isDesktop:s,fullscreen:r}){Mf(),S2();const{visible:o,mode:u,isIOS:f,nativeSupported:h,enterFullscreen:p,dismiss:x,showPrompt:g}=r,{value:b,save:v}=Fe("help",{showOnLoad:!0}),{value:N,status:M,save:k}=Fe("quickstart",{showOnLoad:!0}),{value:S}=Fe("page",{swapMobileControlColumns:!1}),w=!!S?.swapMobileControlColumns,j=w?"left":"right",T=!s&&(f||h),[E,C]=m.useState(!1),[L,G]=m.useState(!1);m.useEffect(()=>{M==="ready"&&G(N?.showOnLoad!==!1)},[M,N?.showOnLoad]);const O=m.useCallback(()=>C(!0),[]),z=m.useCallback(()=>C(!1),[]),K=m.useCallback(()=>G(!1),[]),$=m.useCallback(async()=>{if(f){g();return}await p()||g()},[p,f,g]),X=m.useCallback(ie=>{const V=!!ie;k(q=>({...q??{},showOnLoad:V})),V||G(!1)},[k]),P=m.useCallback(()=>{G(!1),C(!0)},[]),ce=m.useMemo(()=>s?l.jsx(C2,{layout:n,onOpenHelpOverlay:O}):n==="mobile-landscape"?l.jsx(E2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}):l.jsx(k2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}),[s,n,O,w]);return l.jsxs(Wj,{children:[l.jsx(uN,{}),l.jsx(jN,{}),l.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:l.jsx(Do,{layout:n}),ce]}),l.jsx(mf,{}),l.jsx(lb,{}),l.jsx(i2,{}),l.jsx(s2,{}),l.jsx(h2,{visible:E,layout:n,onClose:z,showOnLoad:b?.showOnLoad!==!1,onToggleShowOnLoad:ie=>v(V=>({...V??{},showOnLoad:!!ie}))}),l.jsx(o2,{visible:o,mode:u,onEnterFullscreen:p,onDismiss:x}),l.jsx(g2,{visible:L,layout:n,showOnLoad:N?.showOnLoad!==!1,onToggleShowOnLoad:X,onOpenHelp:P,onClose:K}),T?l.jsx(c2,{side:j,onClick:$}):null]})}function ib(){const{session:n,setRole:s,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 s("spectator"),await r(),h||f(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||f(!1)}}return p(),()=>{h=!0}},[o,n?.mode,n?.role,s,r]),u}function T2(){const[n,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia("(max-aspect-ratio: 4/3)"),o=u=>s(u.matches);return r.addEventListener?r.addEventListener("change",o):r.addListener(o),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o)}},[]),n}function q2({roverId:n,session:s}){const r=s?.activeDrivers?.[n]||null,u=(s?.users||[]).find(x=>x.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=s?.mode,h=s?.turnQueues?.[n];return f==="turns"&&h?.current?`${u} (turns)`:u}function D2({rover:n,frame:s,sessionInfo:r,videoMode:o,snapshotFeed:u,audioInfo:f,session:h}){const p=q2({roverId:n.id,session:h});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(Mr,{sessionInfo:r,videoMode:o,snapshotFeed:u,audioSessionInfo:f,label:n.name,roverDescription:n.description,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function _2({roster:n,frames:s,videoSources:r,snapshotFeeds:o,audioSources:u,session:f,canSpectateVideo:h}){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(p=>l.jsx(D2,{rover:p,frame:s[p.id],sessionInfo:h&&r[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:u[`${p.id}-audio`],session:f,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function O2(){return l.jsx("section",{className:"min-h-0",children:l.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:l.jsx(bf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function B2({className:n=""}){return l.jsx("div",{className:`panel ${n}`,children:l.jsx(vf,{})})}function L2(){const{session:n}=Br(),s=n?.mode==="lockdown",r=!!n?.isLocalNetwork;Mf(),ib();const o=T2(),u=fg(),f=n?.roster??[],h=yf(f.map(w=>w.id),{enabled:!s&&!r,version:n?.mode}),p=r?f.map(w=>({type:"rover",id:w.id,key:w.id})):[],x=Cr(p,{enabled:!s&&r,version:n?.mode}),g=f.flatMap(w=>w.media?.audioPublishUrl?[{type:"rover",id:`${w.id}-audio`,key:`${w.id}-audio`}]:[]),b=Cr(g,{enabled:!s,version:n?.mode});if(s)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 v=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",N=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",M=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",k="",S=o?"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:v,children:[l.jsxs("section",{className:M,children:[o?l.jsxs("div",{className:`${k} ${S} flex flex-col gap-0.5`,children:[l.jsx(Do,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(qo,{}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(To,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):l.jsxs("div",{className:k,children:[l.jsx(Do,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(qo,{})]}),l.jsx("div",{className:`${k} ${o?`${S} overflow-y-auto`:""}`,children:l.jsx("div",{className:"panel h-full",children:l.jsx($o,{title:"Rovers"})})}),o?null:l.jsx("div",{className:`${k} flex-1 min-h-0`,children:l.jsx(To,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),l.jsx("div",{className:`${k} ${o?S:"flex-[1.1] min-h-0"}`,children:l.jsx(Vo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),l.jsx("div",{className:`${k} ${o?S:""}`,children:l.jsx(B2,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),l.jsxs("section",{className:N,children:[l.jsx(_2,{roster:f,frames:u,videoSources:x,snapshotFeeds:h,audioSources:b,session:n,canSpectateVideo:r}),l.jsx(O2,{})]})]}),l.jsx(mf,{}),l.jsx(lb,{})]})}function z2(){return l.jsx(L2,{})}function U2({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 H2({roverId:n,session:s}){const r=s?.activeDrivers?.[n]||null,u=(s?.users||[]).find(p=>p.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=s?.mode,h=s?.turnQueues?.[n];return f==="turns"&&h?.current?`${u}`:u}function V2({rover:n,frame:s}){const r=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Gg({batteryState:n?.batteryState??null,charge:r,config:o})}function tl({children:n,className:s="",maxSize:r=1e3,minSize:o=14,style:u=void 0}){const f=m.useRef(null),h=m.useRef(null),[p,x]=m.useState(r);return m.useLayoutEffect(()=>{const g=f.current,b=h.current;if(!g||!b)return;let v=null;const N=()=>{const S=g.clientWidth;if(!S){M();return}let w=o,j=r,T=o;for(;w<=j;){const E=Math.floor((w+j)/2);b.style.fontSize=`${E}px`,b.scrollWidth<=S?(T=E,w=E+1):j=E-1}x(T)},M=()=>{v&&cancelAnimationFrame(v),v=requestAnimationFrame(N)};M();const k=new ResizeObserver(M);return k.observe(g),()=>{v&&cancelAnimationFrame(v),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 ${s}`,style:{fontSize:`${p}px`,lineHeight:1.1,...u||{}},children:n})})}function qx({rover:n,frame:s,driverLabel:r,sessionInfo:o,videoMode:u="snapshot",snapshotFeed:f,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=V2({rover:n,frame:s}),b=g?.available?g.percentDisplay:null,v=x==="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(Yd,{visual:g,orientation:v?"vertical":"horizontal",variant:"background"}),v?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(tl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:da(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(tl,{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(tl,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:b==null?"--%":`${b}%`})})})]}):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(tl,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:da(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(tl,{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(tl,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:b==null?"--%":`${b}%`})})})]}),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(Mr,{sessionInfo:o,videoMode:u,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}const $2=2e4,G2=3600*1e3;function F2(){const{session:n}=Br(),s=ib();Mf();const r=n?.mode==="lockdown",o=!!n?.isLocalNetwork,u=fg(),f=n?.roster??[],[h,p]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>f.filter($=>x[$.id]),[f,x]),b=g.length?g:f,v=yf(b.map($=>$.id),{enabled:!r&&!o,version:n?.mode}),N=m.useMemo(()=>o?b.map($=>({type:"rover",id:$.id,key:$.id})):[],[o,b]),M=Cr(N,{enabled:!r&&o,version:n?.mode}),k=m.useMemo(()=>g.flatMap($=>{if(!$?.id||!$.media?.audioPublishUrl)return[];const X=String($.id);return[{type:"rover",id:`${X}-audio`,key:`${X}-audio`}]}),[g]),S=Cr(k,{enabled:!r,version:n?.mode}),w=m.useMemo(()=>{if(!g.length)return[];if(!o){const X=g.filter(P=>v[P.id]?.objectUrl);return X.length?X:g}const $=g.filter(X=>{const P=M[X.id];return P?.url&&!P?.error});return $.length?$:g},[g,v,M,o]),j=m.useMemo(()=>w.map($=>({type:"rover",rover:$})),[w]),T=m.useMemo(()=>j.map($=>`r:${$.rover.id}`).join("|"),[j]);m.useEffect(()=>{p(0)},[T]),m.useEffect(()=>{if(!j.length)return;const $=setInterval(()=>{p(X=>(X+1)%j.length)},$2);return()=>clearInterval($)},[j.length,T]);const E=j.length?j[h%j.length]:null,C=E?.type==="rover"?E.rover:null,L=!o&&C&&v[C.id]||null,G=o&&C&&M[C.id]||null,O=C&&S[`${C.id}-audio`]||null,z=C&&u[C.id]||null,K=C?H2({roverId:C.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."})]})}):g.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:s?C?l.jsx(U2,{children:o?l.jsx("div",{className:"relative h-full w-full",children:j.map($=>{const X=$.rover,P=C?.id===X.id;return l.jsx("div",{className:`absolute inset-0 ${P?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsx(Mr,{sessionInfo:M[X.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:P?O:null,forceMute:!P,label:X.name||X.id,roverColor:X.color||null,telemetryFrame:u[X.id]||null,batteryConfig:X.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},X.id)})}):l.jsx(Mr,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:L,audioSessionInfo:O,label:C.name||C.id,roverColor:C.color||null,telemetryFrame:z,batteryConfig:C.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):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:C?l.jsx(qx,{rover:C,frame:z,driverLabel:K,sessionInfo:o?G:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:v[C.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($=>l.jsx(qx,{rover:$,frame:u[$.id]||null,driverLabel:null,sessionInfo:o&&M[$.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:v[$.id]||null,showPreview:!0,withDivider:!1},$.id)):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function Y2(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const s=new URL(window.location.href);s.searchParams.set("refresh",Date.now().toString()),window.location.replace(s.toString())},G2);return()=>clearTimeout(n)},[]),l.jsxs(l.Fragment,{children:[l.jsx(F2,{}),l.jsx(mf,{scale:3})]})}function fo(n){if(!n||!n.length)return null;const s=Math.floor(Math.random()*n.length);return n[s]||null}function X2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const s=fo(n),r=fo(n),o=s?.classList?.[0]||null;if(o&&r?.classList)try{r.classList.add(o)}catch{}const u=fo(n),f=fo(n),h=u?.classList?.[1]||null;if(h&&f?.classList)try{f.classList.add(h)}catch{}}function Q2(){const n=xe(s=>!!s.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const s=window.setInterval(()=>{X2()},1);return()=>{window.clearInterval(s)}},[n]),null}ky.createRoot(document.getElementById("root")).render(l.jsx(m.StrictMode,{children:l.jsx(ZS,{children:l.jsx(ej,{children:l.jsx(nj,{children:l.jsx(dj,{children:l.jsxs(tN,{children:[l.jsx(Q2,{}),l.jsx($1,{children:l.jsxs(v1,{children:[l.jsx(mo,{path:"/",element:l.jsx(M2,{})}),l.jsx(mo,{path:"/spectate",element:l.jsx(z2,{})}),l.jsx(mo,{path:"/mini",element:l.jsx(Y2,{})})]})})]})})})})})}));
|