mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
126 lines
548 KiB
JavaScript
126 lines
548 KiB
JavaScript
(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))o(f);new MutationObserver(f=>{for(const d of f)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function i(f){const d={};return f.integrity&&(d.integrity=f.integrity),f.referrerPolicy&&(d.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?d.credentials="include":f.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(f){if(f.ep)return;f.ep=!0;const d=i(f);fetch(f.href,d)}})();function fb(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fu={exports:{}},li={};var d0;function db(){if(d0)return li;d0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function i(o,f,d){var h=null;if(d!==void 0&&(h=""+d),f.key!==void 0&&(h=""+f.key),"key"in f){d={};for(var p in f)p!=="key"&&(d[p]=f[p])}else d=f;return f=d.ref,{$$typeof:n,type:o,key:h,ref:f!==void 0?f:null,props:d}}return li.Fragment=s,li.jsx=i,li.jsxs=i,li}var m0;function mb(){return m0||(m0=1,Fu.exports=db()),Fu.exports}var r=mb(),Xu={exports:{}},we={};var h0;function hb(){if(h0)return we;h0=1;var n=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function k(R){return R===null||typeof R!="object"?null:(R=S&&R[S]||R["@@iterator"],typeof R=="function"?R:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,w={};function A(R,U,ee){this.props=R,this.context=U,this.refs=w,this.updater=ee||C}A.prototype.isReactComponent={},A.prototype.setState=function(R,U){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,U,"setState")},A.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=A.prototype;function q(R,U,ee){this.props=R,this.context=U,this.refs=w,this.updater=ee||C}var M=q.prototype=new N;M.constructor=q,E(M,A.prototype),M.isPureReactComponent=!0;var B=Array.isArray;function K(){}var _={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function z(R,U,ee){var ae=ee.ref;return{$$typeof:n,type:R,key:U,ref:ae!==void 0?ae:null,props:ee}}function V(R,U){return z(R.type,U,R.props)}function X(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function te(R){var U={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ee){return U[ee]})}var ue=/\/+/g;function ce(R,U){return typeof R=="object"&&R!==null&&R.key!=null?te(""+R.key):U.toString(36)}function Y(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(K,K):(R.status="pending",R.then(function(U){R.status==="pending"&&(R.status="fulfilled",R.value=U)},function(U){R.status==="pending"&&(R.status="rejected",R.reason=U)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function T(R,U,ee,ae,pe){var re=typeof R;(re==="undefined"||re==="boolean")&&(R=null);var oe=!1;if(R===null)oe=!0;else switch(re){case"bigint":case"string":case"number":oe=!0;break;case"object":switch(R.$$typeof){case n:case s:oe=!0;break;case v:return oe=R._init,T(oe(R._payload),U,ee,ae,pe)}}if(oe)return pe=pe(R),oe=ae===""?"."+ce(R,0):ae,B(pe)?(ee="",oe!=null&&(ee=oe.replace(ue,"$&/")+"/"),T(pe,U,ee,"",function(xe){return xe})):pe!=null&&(X(pe)&&(pe=V(pe,ee+(pe.key==null||R&&R.key===pe.key?"":(""+pe.key).replace(ue,"$&/")+"/")+oe)),U.push(pe)),1;oe=0;var ve=ae===""?".":ae+":";if(B(R))for(var ye=0;ye<R.length;ye++)ae=R[ye],re=ve+ce(ae,ye),oe+=T(ae,U,ee,re,pe);else if(ye=k(R),typeof ye=="function")for(R=ye.call(R),ye=0;!(ae=R.next()).done;)ae=ae.value,re=ve+ce(ae,ye++),oe+=T(ae,U,ee,re,pe);else if(re==="object"){if(typeof R.then=="function")return T(Y(R),U,ee,ae,pe);throw U=String(R),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return oe}function $(R,U,ee){if(R==null)return R;var ae=[],pe=0;return T(R,ae,"","",function(re){return U.call(ee,re,pe++)}),ae}function J(R){if(R._status===-1){var U=R._result;U=U(),U.then(function(ee){(R._status===0||R._status===-1)&&(R._status=1,R._result=ee)},function(ee){(R._status===0||R._status===-1)&&(R._status=2,R._result=ee)}),R._status===-1&&(R._status=0,R._result=U)}if(R._status===1)return R._result.default;throw R._result}var ie=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=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(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},de={map:$,forEach:function(R,U,ee){$(R,function(){U.apply(this,arguments)},ee)},count:function(R){var U=0;return $(R,function(){U++}),U},toArray:function(R){return $(R,function(U){return U})||[]},only:function(R){if(!X(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return we.Activity=b,we.Children=de,we.Component=A,we.Fragment=i,we.Profiler=f,we.PureComponent=q,we.StrictMode=o,we.Suspense=x,we.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,we.__COMPILER_RUNTIME={__proto__:null,c:function(R){return _.H.useMemoCache(R)}},we.cache=function(R){return function(){return R.apply(null,arguments)}},we.cacheSignal=function(){return null},we.cloneElement=function(R,U,ee){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var ae=E({},R.props),pe=R.key;if(U!=null)for(re in U.key!==void 0&&(pe=""+U.key),U)!H.call(U,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&U.ref===void 0||(ae[re]=U[re]);var re=arguments.length-2;if(re===1)ae.children=ee;else if(1<re){for(var oe=Array(re),ve=0;ve<re;ve++)oe[ve]=arguments[ve+2];ae.children=oe}return z(R.type,pe,ae)},we.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:d,_context:R},R},we.createElement=function(R,U,ee){var ae,pe={},re=null;if(U!=null)for(ae in U.key!==void 0&&(re=""+U.key),U)H.call(U,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(pe[ae]=U[ae]);var oe=arguments.length-2;if(oe===1)pe.children=ee;else if(1<oe){for(var ve=Array(oe),ye=0;ye<oe;ye++)ve[ye]=arguments[ye+2];pe.children=ve}if(R&&R.defaultProps)for(ae in oe=R.defaultProps,oe)pe[ae]===void 0&&(pe[ae]=oe[ae]);return z(R,re,pe)},we.createRef=function(){return{current:null}},we.forwardRef=function(R){return{$$typeof:p,render:R}},we.isValidElement=X,we.lazy=function(R){return{$$typeof:v,_payload:{_status:-1,_result:R},_init:J}},we.memo=function(R,U){return{$$typeof:g,type:R,compare:U===void 0?null:U}},we.startTransition=function(R){var U=_.T,ee={};_.T=ee;try{var ae=R(),pe=_.S;pe!==null&&pe(ee,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(K,ie)}catch(re){ie(re)}finally{U!==null&&ee.types!==null&&(U.types=ee.types),_.T=U}},we.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},we.use=function(R){return _.H.use(R)},we.useActionState=function(R,U,ee){return _.H.useActionState(R,U,ee)},we.useCallback=function(R,U){return _.H.useCallback(R,U)},we.useContext=function(R){return _.H.useContext(R)},we.useDebugValue=function(){},we.useDeferredValue=function(R,U){return _.H.useDeferredValue(R,U)},we.useEffect=function(R,U){return _.H.useEffect(R,U)},we.useEffectEvent=function(R){return _.H.useEffectEvent(R)},we.useId=function(){return _.H.useId()},we.useImperativeHandle=function(R,U,ee){return _.H.useImperativeHandle(R,U,ee)},we.useInsertionEffect=function(R,U){return _.H.useInsertionEffect(R,U)},we.useLayoutEffect=function(R,U){return _.H.useLayoutEffect(R,U)},we.useMemo=function(R,U){return _.H.useMemo(R,U)},we.useOptimistic=function(R,U){return _.H.useOptimistic(R,U)},we.useReducer=function(R,U,ee){return _.H.useReducer(R,U,ee)},we.useRef=function(R){return _.H.useRef(R)},we.useState=function(R){return _.H.useState(R)},we.useSyncExternalStore=function(R,U,ee){return _.H.useSyncExternalStore(R,U,ee)},we.useTransition=function(){return _.H.useTransition()},we.version="19.2.0",we}var p0;function Hf(){return p0||(p0=1,Xu.exports=hb()),Xu.exports}var m=Hf();const us=fb(m);var Qu={exports:{}},ii={},Ku={exports:{}},Zu={};var x0;function pb(){return x0||(x0=1,(function(n){function s(T,$){var J=T.length;T.push($);e:for(;0<J;){var ie=J-1>>>1,de=T[ie];if(0<f(de,$))T[ie]=$,T[J]=de,J=ie;else break e}}function i(T){return T.length===0?null:T[0]}function o(T){if(T.length===0)return null;var $=T[0],J=T.pop();if(J!==$){T[0]=J;e:for(var ie=0,de=T.length,R=de>>>1;ie<R;){var U=2*(ie+1)-1,ee=T[U],ae=U+1,pe=T[ae];if(0>f(ee,J))ae<de&&0>f(pe,ee)?(T[ie]=pe,T[ae]=J,ie=ae):(T[ie]=ee,T[U]=J,ie=U);else if(ae<de&&0>f(pe,J))T[ie]=pe,T[ae]=J,ie=ae;else break e}}return $}function f(T,$){var J=T.sortIndex-$.sortIndex;return J!==0?J:T.id-$.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var x=[],g=[],v=1,b=null,S=3,k=!1,C=!1,E=!1,w=!1,A=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,q=typeof setImmediate<"u"?setImmediate:null;function M(T){for(var $=i(g);$!==null;){if($.callback===null)o(g);else if($.startTime<=T)o(g),$.sortIndex=$.expirationTime,s(x,$);else break;$=i(g)}}function B(T){if(E=!1,M(T),!C)if(i(x)!==null)C=!0,K||(K=!0,te());else{var $=i(g);$!==null&&Y(B,$.startTime-T)}}var K=!1,_=-1,H=5,z=-1;function V(){return w?!0:!(n.unstable_now()-z<H)}function X(){if(w=!1,K){var T=n.unstable_now();z=T;var $=!0;try{e:{C=!1,E&&(E=!1,N(_),_=-1),k=!0;var J=S;try{t:{for(M(T),b=i(x);b!==null&&!(b.expirationTime>T&&V());){var ie=b.callback;if(typeof ie=="function"){b.callback=null,S=b.priorityLevel;var de=ie(b.expirationTime<=T);if(T=n.unstable_now(),typeof de=="function"){b.callback=de,M(T),$=!0;break t}b===i(x)&&o(x),M(T)}else o(x);b=i(x)}if(b!==null)$=!0;else{var R=i(g);R!==null&&Y(B,R.startTime-T),$=!1}}break e}finally{b=null,S=J,k=!1}$=void 0}}finally{$?te():K=!1}}}var te;if(typeof q=="function")te=function(){q(X)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,ce=ue.port2;ue.port1.onmessage=X,te=function(){ce.postMessage(null)}}else te=function(){A(X,0)};function Y(T,$){_=A(function(){T(n.unstable_now())},$)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(T){T.callback=null},n.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<T?Math.floor(1e3/T):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(T){switch(S){case 1:case 2:case 3:var $=3;break;default:$=S}var J=S;S=$;try{return T()}finally{S=J}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(T,$){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=S;S=T;try{return $()}finally{S=J}},n.unstable_scheduleCallback=function(T,$,J){var ie=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ie+J:ie):J=ie,T){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=J+de,T={id:v++,callback:$,priorityLevel:T,startTime:J,expirationTime:de,sortIndex:-1},J>ie?(T.sortIndex=J,s(g,T),i(x)===null&&T===i(g)&&(E?(N(_),_=-1):E=!0,Y(B,J-ie))):(T.sortIndex=de,s(x,T),C||k||(C=!0,K||(K=!0,te()))),T},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(T){var $=S;return function(){var J=S;S=$;try{return T.apply(this,arguments)}finally{S=J}}}})(Zu)),Zu}var g0;function xb(){return g0||(g0=1,Ku.exports=pb()),Ku.exports}var Iu={exports:{}},Ot={};var v0;function gb(){if(v0)return Ot;v0=1;var n=Hf();function s(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)g+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var o={d:{f:i,r:function(){throw Error(s(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},f=Symbol.for("react.portal");function d(x,g,v){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:f,key:b==null?null:""+b,children:x,containerInfo:g,implementation:v}}var h=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return Ot.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Ot.createPortal=function(x,g){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(s(299));return d(x,g,null,v)},Ot.flushSync=function(x){var g=h.T,v=o.p;try{if(h.T=null,o.p=2,x)return x()}finally{h.T=g,o.p=v,o.d.f()}},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 v=g.as,b=p(v,g.crossOrigin),S=typeof g.integrity=="string"?g.integrity:void 0,k=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;v==="style"?o.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:S,fetchPriority:k}):v==="script"&&o.d.X(x,{crossOrigin:b,integrity:S,fetchPriority:k,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 v=p(g.as,g.crossOrigin);o.d.M(x,{crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&o.d.M(x)},Ot.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var v=g.as,b=p(v,g.crossOrigin);o.d.L(x,v,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},Ot.preloadModule=function(x,g){if(typeof x=="string")if(g){var v=p(g.as,g.crossOrigin);o.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:v,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else o.d.m(x)},Ot.requestFormReset=function(x){o.d.r(x)},Ot.unstable_batchedUpdates=function(x,g){return x(g)},Ot.useFormState=function(x,g,v){return h.H.useFormState(x,g,v)},Ot.useFormStatus=function(){return h.H.useHostTransitionStatus()},Ot.version="19.2.0",Ot}var y0;function vb(){if(y0)return Iu.exports;y0=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(),Iu.exports=gb(),Iu.exports}var b0;function yb(){if(b0)return ii;b0=1;var n=xb(),s=Hf(),i=vb();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(d(e)!==e)throw Error(o(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(o(188));return t!==e?null:e}for(var a=e,l=t;;){var c=a.return;if(c===null)break;var u=c.alternate;if(u===null){if(l=c.return,l!==null){a=l;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===a)return x(c),e;if(u===l)return x(c),t;u=u.sibling}throw Error(o(188))}if(a.return!==l.return)a=c,l=u;else{for(var y=!1,j=c.child;j;){if(j===a){y=!0,a=c,l=u;break}if(j===l){y=!0,l=c,a=u;break}j=j.sibling}if(!y){for(j=u.child;j;){if(j===a){y=!0,a=u,l=c;break}if(j===l){y=!0,l=u,a=c;break}j=j.sibling}if(!y)throw Error(o(189))}}if(a.alternate!==l)throw Error(o(190))}if(a.tag!==3)throw Error(o(188));return a.stateNode.current===a?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,S=Symbol.for("react.element"),k=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),q=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function te(e){return e===null||typeof e!="object"?null:(e=X&&e[X]||e["@@iterator"],typeof e=="function"?e:null)}var ue=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case A:return"Profiler";case w:return"StrictMode";case B:return"Suspense";case K:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case q:return e.displayName||"Context";case N:return(e._context.displayName||"Context")+".Consumer";case M:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case H:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var Y=Array.isArray,T=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ie=[],de=-1;function R(e){return{current:e}}function U(e){0>de||(e.current=ie[de],ie[de]=null,de--)}function ee(e,t){de++,ie[de]=e.current,e.current=t}var ae=R(null),pe=R(null),re=R(null),oe=R(null);function ve(e,t){switch(ee(re,t),ee(pe,e),ee(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Op(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Op(t),e=Bp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(ae),ee(ae,e)}function ye(){U(ae),U(pe),U(re)}function xe(e){e.memoizedState!==null&&ee(oe,e);var t=ae.current,a=Bp(t,e.type);t!==a&&(ee(pe,e),ee(ae,a))}function Oe(e){pe.current===e&&(U(ae),U(pe)),oe.current===e&&(U(oe),ti._currentValue=J)}var ze,Ae;function tt(e){if(ze===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);ze=t&&t[1]||"",Ae=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+ze+e+Ae}var Je=!1;function vt(e,t){if(!e||Je)return"";Je=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var ne=function(){throw Error()};if(Object.defineProperty(ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ne,[])}catch(Z){var Q=Z}Reflect.construct(e,[],ne)}else{try{ne.call()}catch(Z){Q=Z}e.call(ne.prototype)}}else{try{throw Error()}catch(Z){Q=Z}(ne=e())&&typeof ne.catch=="function"&&ne.catch(function(){})}}catch(Z){if(Z&&Q&&typeof Z.stack=="string")return[Z.stack,Q.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=l.DetermineComponentFrameRoot(),y=u[0],j=u[1];if(y&&j){var D=y.split(`
|
||
`),F=j.split(`
|
||
`);for(c=l=0;l<D.length&&!D[l].includes("DetermineComponentFrameRoot");)l++;for(;c<F.length&&!F[c].includes("DetermineComponentFrameRoot");)c++;if(l===D.length||c===F.length)for(l=D.length-1,c=F.length-1;1<=l&&0<=c&&D[l]!==F[c];)c--;for(;1<=l&&0<=c;l--,c--)if(D[l]!==F[c]){if(l!==1||c!==1)do if(l--,c--,0>c||D[l]!==F[c]){var I=`
|
||
`+D[l].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=l&&0<=c);break}}}finally{Je=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?tt(a):""}function le(e,t){switch(e.tag){case 26:case 27:case 5:return tt(e.type);case 16:return tt("Lazy");case 13:return e.child!==t&&t!==null?tt("Suspense Fallback"):tt("Suspense");case 19:return tt("SuspenseList");case 0:case 15:return vt(e.type,!1);case 11:return vt(e.type.render,!1);case 1:return vt(e.type,!0);case 31:return tt("Activity");default:return""}}function me(e){try{var t="",a=null;do t+=le(e,a),a=e,e=e.return;while(e);return t}catch(l){return`
|
||
Error generating stack: `+l.message+`
|
||
`+l.stack}}var se=Object.prototype.hasOwnProperty,P=n.unstable_scheduleCallback,fe=n.unstable_cancelCallback,Ne=n.unstable_shouldYield,pt=n.unstable_requestPaint,Ve=n.unstable_now,st=n.unstable_getCurrentPriorityLevel,lt=n.unstable_ImmediatePriority,Bt=n.unstable_UserBlockingPriority,it=n.unstable_NormalPriority,ds=n.unstable_LowPriority,Yt=n.unstable_IdlePriority,La=n.log,_o=n.unstable_setDisableYieldValue,On=null,Nt=null;function Ft(e){if(typeof La=="function"&&_o(e),Nt&&typeof Nt.setStrictMode=="function")try{Nt.setStrictMode(On,e)}catch{}}var Mt=Math.clz32?Math.clz32:ms,fa=Math.log,Oo=Math.LN2;function ms(e){return e>>>=0,e===0?32:31-(fa(e)/Oo|0)|0}var hs=256,za=262144,Pe=4194304;function Bn(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 Cn(e,t,a){var l=e.pendingLanes;if(l===0)return 0;var c=0,u=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var j=l&134217727;return j!==0?(l=j&~u,l!==0?c=Bn(l):(y&=j,y!==0?c=Bn(y):a||(a=j&~e,a!==0&&(c=Bn(a))))):(j=l&~u,j!==0?c=Bn(j):y!==0?c=Bn(y):a||(a=l&~e,a!==0&&(c=Bn(a)))),c===0?0:t!==0&&t!==c&&(t&u)===0&&(u=c&-c,a=t&-t,u>=a||u===32&&(a&4194048)!==0)?t:c}function Ln(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ps(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 ml(){var e=Pe;return Pe<<=1,(Pe&62914560)===0&&(Pe=4194304),e}function hl(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function Ua(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Bo(e,t,a,l,c,u){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 j=e.entanglements,D=e.expirationTimes,F=e.hiddenUpdates;for(a=y&~a;0<a;){var I=31-Mt(a),ne=1<<I;j[I]=0,D[I]=-1;var Q=F[I];if(Q!==null)for(F[I]=null,I=0;I<Q.length;I++){var Z=Q[I];Z!==null&&(Z.lane&=-536870913)}a&=~ne}l!==0&&pl(e,l,0),u!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=u&~(y&~t))}function pl(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-Mt(t);e.entangledLanes|=t,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function an(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-Mt(a),c=1<<l;c&t|e[l]&t&&(e[l]|=t),a&=~c}}function be(e,t){var a=t&-t;return a=(a&42)!==0?1:Fe(a),(a&(e.suspendedLanes|t))!==0?0:a}function Fe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ze(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ke(){var e=$.p;return e!==0?e:(e=window.event,e===void 0?32:l0(e.type))}function $e(e,t){var a=$.p;try{return $.p=e,t()}finally{$.p=a}}var rt=Math.random().toString(36).slice(2),ot="__reactFiber$"+rt,wt="__reactProps$"+rt,nt="__reactContainer$"+rt,zn="__reactEvents$"+rt,ev="__reactListeners$"+rt,tv="__reactHandles$"+rt,jd="__reactResources$"+rt,xl="__reactMarker$"+rt;function Lo(e){delete e[ot],delete e[wt],delete e[zn],delete e[ev],delete e[tv]}function xs(e){var t=e[ot];if(t)return t;for(var a=e.parentNode;a;){if(t=a[nt]||a[ot]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Gp(e);e!==null;){if(a=e[ot])return a;e=Gp(e)}return t}e=a,a=e.parentNode}return null}function gs(e){if(e=e[ot]||e[nt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function gl(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function vs(e){var t=e[jd];return t||(t=e[jd]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Et(e){e[xl]=!0}var Ad=new Set,Nd={};function Ha(e,t){ys(e,t),ys(e+"Capture",t)}function ys(e,t){for(Nd[e]=t,e=0;e<t.length;e++)Ad.add(t[e])}var nv=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]*$"),wd={},Cd={};function av(e){return se.call(Cd,e)?!0:se.call(wd,e)?!1:nv.test(e)?Cd[e]=!0:(wd[e]=!0,!1)}function Di(e,t,a){if(av(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function _i(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 Un(e,t,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+l)}}function sn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ed(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function sv(e,t,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,u=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(y){a=""+y,u.call(this,y)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function zo(e){if(!e._valueTracker){var t=Ed(e)?"checked":"value";e._valueTracker=sv(e,t,""+e[t])}}function kd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=Ed(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.setValue(e),!0):!1}function Oi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var lv=/[\n"\\]/g;function ln(e){return e.replace(lv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Uo(e,t,a,l,c,u,y,j){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=""+sn(t)):e.value!==""+sn(t)&&(e.value=""+sn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?Ho(e,y,sn(t)):a!=null?Ho(e,y,sn(a)):l!=null&&e.removeAttribute("value"),c==null&&u!=null&&(e.defaultChecked=!!u),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.name=""+sn(j):e.removeAttribute("name")}function Md(e,t,a,l,c,u,y,j){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||a!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){zo(e);return}a=a!=null?""+sn(a):"",t=t!=null?""+sn(t):a,j||t===e.value||(e.value=t),e.defaultValue=t}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=j?e.checked:!!l,e.defaultChecked=!!l,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),zo(e)}function Ho(e,t,a){t==="number"&&Oi(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function bs(e,t,a,l){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&&l&&(e[a].defaultSelected=!0)}else{for(a=""+sn(a),t=null,c=0;c<e.length;c++){if(e[c].value===a){e[c].selected=!0,l&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Rd(e,t,a){if(t!=null&&(t=""+sn(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+sn(a):""}function qd(e,t,a,l){if(t==null){if(l!=null){if(a!=null)throw Error(o(92));if(Y(l)){if(1<l.length)throw Error(o(93));l=l[0]}a=l}a==null&&(a=""),t=a}a=sn(t),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),zo(e)}function Ss(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var iv=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 Td(e,t,a){var l=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":l?e.setProperty(t,a):typeof a!="number"||a===0||iv.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Dd(e,t,a){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var c in t)l=t[c],t.hasOwnProperty(c)&&a[c]!==l&&Td(e,c,l)}else for(var u in t)t.hasOwnProperty(u)&&Td(e,u,t[u])}function Vo(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 rv=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"]]),ov=/^[\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 Bi(e){return ov.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Hn(){}var $o=null;function Go(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var js=null,As=null;function _d(e){var t=gs(e);if(t&&(e=t.stateNode)){var a=e[wt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Uo(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="'+ln(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var c=l[wt]||null;if(!c)throw Error(o(90));Uo(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)l=a[t],l.form===e.form&&kd(l)}break e;case"textarea":Rd(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&bs(e,!!a.multiple,t,!1)}}}var Yo=!1;function Od(e,t,a){if(Yo)return e(t,a);Yo=!0;try{var l=e(t);return l}finally{if(Yo=!1,(js!==null||As!==null)&&(Ar(),js&&(t=js,e=As,As=js=null,_d(t),e)))for(t=0;t<e.length;t++)_d(e[t])}}function vl(e,t){var a=e.stateNode;if(a===null)return null;var l=a[wt]||null;if(l===null)return null;a=l[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":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(o(231,t,typeof a));return a}var Vn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fo=!1;if(Vn)try{var yl={};Object.defineProperty(yl,"passive",{get:function(){Fo=!0}}),window.addEventListener("test",yl,yl),window.removeEventListener("test",yl,yl)}catch{Fo=!1}var da=null,Xo=null,Li=null;function Bd(){if(Li)return Li;var e,t=Xo,a=t.length,l,c="value"in da?da.value:da.textContent,u=c.length;for(e=0;e<a&&t[e]===c[e];e++);var y=a-e;for(l=1;l<=y&&t[a-l]===c[u-l];l++);return Li=c.slice(e,1<l?1-l:void 0)}function zi(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 Ui(){return!0}function Ld(){return!1}function zt(e){function t(a,l,c,u,y){this._reactName=a,this._targetInst=c,this.type=l,this.nativeEvent=u,this.target=y,this.currentTarget=null;for(var j in e)e.hasOwnProperty(j)&&(a=e[j],this[j]=a?a(u):u[j]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?Ui:Ld,this.isPropagationStopped=Ld,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ui)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ui)},persist:function(){},isPersistent:Ui}),t}var Va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hi=zt(Va),bl=b({},Va,{view:0,detail:0}),cv=zt(bl),Qo,Ko,Sl,Vi=b({},bl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Io,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!==Sl&&(Sl&&e.type==="mousemove"?(Qo=e.screenX-Sl.screenX,Ko=e.screenY-Sl.screenY):Ko=Qo=0,Sl=e),Qo)},movementY:function(e){return"movementY"in e?e.movementY:Ko}}),zd=zt(Vi),uv=b({},Vi,{dataTransfer:0}),fv=zt(uv),dv=b({},bl,{relatedTarget:0}),Zo=zt(dv),mv=b({},Va,{animationName:0,elapsedTime:0,pseudoElement:0}),hv=zt(mv),pv=b({},Va,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),xv=zt(pv),gv=b({},Va,{data:0}),Ud=zt(gv),vv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yv={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"},bv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=bv[e])?!!t[e]:!1}function Io(){return Sv}var jv=b({},bl,{key:function(e){if(e.key){var t=vv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=zi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?yv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Io,charCode:function(e){return e.type==="keypress"?zi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?zi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Av=zt(jv),Nv=b({},Vi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hd=zt(Nv),wv=b({},bl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Io}),Cv=zt(wv),Ev=b({},Va,{propertyName:0,elapsedTime:0,pseudoElement:0}),kv=zt(Ev),Mv=b({},Vi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Rv=zt(Mv),qv=b({},Va,{newState:0,oldState:0}),Tv=zt(qv),Dv=[9,13,27,32],Jo=Vn&&"CompositionEvent"in window,jl=null;Vn&&"documentMode"in document&&(jl=document.documentMode);var _v=Vn&&"TextEvent"in window&&!jl,Vd=Vn&&(!Jo||jl&&8<jl&&11>=jl),$d=" ",Gd=!1;function Yd(e,t){switch(e){case"keyup":return Dv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ns=!1;function Ov(e,t){switch(e){case"compositionend":return Fd(t);case"keypress":return t.which!==32?null:(Gd=!0,$d);case"textInput":return e=t.data,e===$d&&Gd?null:e;default:return null}}function Bv(e,t){if(Ns)return e==="compositionend"||!Jo&&Yd(e,t)?(e=Bd(),Li=Xo=da=null,Ns=!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 Vd&&t.locale!=="ko"?null:t.data;default:return null}}var Lv={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 Xd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Lv[e.type]:t==="textarea"}function Qd(e,t,a,l){js?As?As.push(l):As=[l]:js=l,t=Rr(t,"onChange"),0<t.length&&(a=new Hi("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var Al=null,Nl=null;function zv(e){Mp(e,0)}function $i(e){var t=gl(e);if(kd(t))return e}function Kd(e,t){if(e==="change")return t}var Zd=!1;if(Vn){var Po;if(Vn){var Wo="oninput"in document;if(!Wo){var Id=document.createElement("div");Id.setAttribute("oninput","return;"),Wo=typeof Id.oninput=="function"}Po=Wo}else Po=!1;Zd=Po&&(!document.documentMode||9<document.documentMode)}function Jd(){Al&&(Al.detachEvent("onpropertychange",Pd),Nl=Al=null)}function Pd(e){if(e.propertyName==="value"&&$i(Nl)){var t=[];Qd(t,Nl,e,Go(e)),Od(zv,t)}}function Uv(e,t,a){e==="focusin"?(Jd(),Al=t,Nl=a,Al.attachEvent("onpropertychange",Pd)):e==="focusout"&&Jd()}function Hv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return $i(Nl)}function Vv(e,t){if(e==="click")return $i(t)}function $v(e,t){if(e==="input"||e==="change")return $i(t)}function Gv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xt=typeof Object.is=="function"?Object.is:Gv;function wl(e,t){if(Xt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var c=a[l];if(!se.call(t,c)||!Xt(e[c],t[c]))return!1}return!0}function Wd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function em(e,t){var a=Wd(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Wd(a)}}function tm(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?tm(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function nm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Oi(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=Oi(e.document)}return t}function ec(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 Yv=Vn&&"documentMode"in document&&11>=document.documentMode,ws=null,tc=null,Cl=null,nc=!1;function am(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;nc||ws==null||ws!==Oi(l)||(l=ws,"selectionStart"in l&&ec(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Cl&&wl(Cl,l)||(Cl=l,l=Rr(tc,"onSelect"),0<l.length&&(t=new Hi("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=ws)))}function $a(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Cs={animationend:$a("Animation","AnimationEnd"),animationiteration:$a("Animation","AnimationIteration"),animationstart:$a("Animation","AnimationStart"),transitionrun:$a("Transition","TransitionRun"),transitionstart:$a("Transition","TransitionStart"),transitioncancel:$a("Transition","TransitionCancel"),transitionend:$a("Transition","TransitionEnd")},ac={},sm={};Vn&&(sm=document.createElement("div").style,"AnimationEvent"in window||(delete Cs.animationend.animation,delete Cs.animationiteration.animation,delete Cs.animationstart.animation),"TransitionEvent"in window||delete Cs.transitionend.transition);function Ga(e){if(ac[e])return ac[e];if(!Cs[e])return e;var t=Cs[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in sm)return ac[e]=t[a];return e}var lm=Ga("animationend"),im=Ga("animationiteration"),rm=Ga("animationstart"),Fv=Ga("transitionrun"),Xv=Ga("transitionstart"),Qv=Ga("transitioncancel"),om=Ga("transitionend"),cm=new Map,sc="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(" ");sc.push("scrollEnd");function vn(e,t){cm.set(e,t),Ha(t,[e])}var Gi=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)},rn=[],Es=0,lc=0;function Yi(){for(var e=Es,t=lc=Es=0;t<e;){var a=rn[t];rn[t++]=null;var l=rn[t];rn[t++]=null;var c=rn[t];rn[t++]=null;var u=rn[t];if(rn[t++]=null,l!==null&&c!==null){var y=l.pending;y===null?c.next=c:(c.next=y.next,y.next=c),l.pending=c}u!==0&&um(a,c,u)}}function Fi(e,t,a,l){rn[Es++]=e,rn[Es++]=t,rn[Es++]=a,rn[Es++]=l,lc|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function ic(e,t,a,l){return Fi(e,t,a,l),Xi(e)}function Ya(e,t){return Fi(e,null,null,t),Xi(e)}function um(e,t,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var c=!1,u=e.return;u!==null;)u.childLanes|=a,l=u.alternate,l!==null&&(l.childLanes|=a),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(c=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,c&&t!==null&&(c=31-Mt(a),e=u.hiddenUpdates,l=e[c],l===null?e[c]=[t]:l.push(t),t.lane=a|536870912),u):null}function Xi(e){if(50<Kl)throw Kl=0,pu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ks={};function Kv(e,t,a,l){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=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qt(e,t,a,l){return new Kv(e,t,a,l)}function rc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $n(e,t){var a=e.alternate;return a===null?(a=Qt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function fm(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 Qi(e,t,a,l,c,u){var y=0;if(l=e,typeof e=="function")rc(e)&&(y=1);else if(typeof e=="string")y=Wy(e,a,ae.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=Qt(31,a,t,c),e.elementType=z,e.lanes=u,e;case E:return Fa(a.children,c,u,t);case w:y=8,c|=24;break;case A:return e=Qt(12,a,t,c|2),e.elementType=A,e.lanes=u,e;case B:return e=Qt(13,a,t,c),e.elementType=B,e.lanes=u,e;case K:return e=Qt(19,a,t,c),e.elementType=K,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case q:y=10;break e;case N:y=9;break e;case M:y=11;break e;case _:y=14;break e;case H:y=16,l=null;break e}y=29,a=Error(o(130,e===null?"null":typeof e,"")),l=null}return t=Qt(y,a,t,c),t.elementType=e,t.type=l,t.lanes=u,t}function Fa(e,t,a,l){return e=Qt(7,e,l,t),e.lanes=a,e}function oc(e,t,a){return e=Qt(6,e,null,t),e.lanes=a,e}function dm(e){var t=Qt(18,null,null,0);return t.stateNode=e,t}function cc(e,t,a){return t=Qt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var mm=new WeakMap;function on(e,t){if(typeof e=="object"&&e!==null){var a=mm.get(e);return a!==void 0?a:(t={value:e,source:t,stack:me(t)},mm.set(e,t),t)}return{value:e,source:t,stack:me(t)}}var Ms=[],Rs=0,Ki=null,El=0,cn=[],un=0,ma=null,En=1,kn="";function Gn(e,t){Ms[Rs++]=El,Ms[Rs++]=Ki,Ki=e,El=t}function hm(e,t,a){cn[un++]=En,cn[un++]=kn,cn[un++]=ma,ma=e;var l=En;e=kn;var c=32-Mt(l)-1;l&=~(1<<c),a+=1;var u=32-Mt(t)+c;if(30<u){var y=c-c%5;u=(l&(1<<y)-1).toString(32),l>>=y,c-=y,En=1<<32-Mt(t)+c|a<<c|l,kn=u+e}else En=1<<u|a<<c|l,kn=e}function uc(e){e.return!==null&&(Gn(e,1),hm(e,1,0))}function fc(e){for(;e===Ki;)Ki=Ms[--Rs],Ms[Rs]=null,El=Ms[--Rs],Ms[Rs]=null;for(;e===ma;)ma=cn[--un],cn[un]=null,kn=cn[--un],cn[un]=null,En=cn[--un],cn[un]=null}function pm(e,t){cn[un++]=En,cn[un++]=kn,cn[un++]=ma,En=t.id,kn=t.overflow,ma=e}var Rt=null,We=null,De=!1,ha=null,fn=!1,dc=Error(o(519));function pa(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw kl(on(t,e)),dc}function xm(e){var t=e.stateNode,a=e.type,l=e.memoizedProps;switch(t[ot]=e,t[wt]=l,a){case"dialog":Re("cancel",t),Re("close",t);break;case"iframe":case"object":case"embed":Re("load",t);break;case"video":case"audio":for(a=0;a<Il.length;a++)Re(Il[a],t);break;case"source":Re("error",t);break;case"img":case"image":case"link":Re("error",t),Re("load",t);break;case"details":Re("toggle",t);break;case"input":Re("invalid",t),Md(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Re("invalid",t);break;case"textarea":Re("invalid",t),qd(t,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||l.suppressHydrationWarning===!0||Dp(t.textContent,a)?(l.popover!=null&&(Re("beforetoggle",t),Re("toggle",t)),l.onScroll!=null&&Re("scroll",t),l.onScrollEnd!=null&&Re("scrollend",t),l.onClick!=null&&(t.onclick=Hn),t=!0):t=!1,t||pa(e,!0)}function gm(e){for(Rt=e.return;Rt;)switch(Rt.tag){case 5:case 31:case 13:fn=!1;return;case 27:case 3:fn=!0;return;default:Rt=Rt.return}}function qs(e){if(e!==Rt)return!1;if(!De)return gm(e),De=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Ru(e.type,e.memoizedProps)),a=!a),a&&We&&pa(e),gm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));We=$p(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));We=$p(e)}else t===27?(t=We,Ma(e.type)?(e=Ou,Ou=null,We=e):We=t):We=Rt?mn(e.stateNode.nextSibling):null;return!0}function Xa(){We=Rt=null,De=!1}function mc(){var e=ha;return e!==null&&($t===null?$t=e:$t.push.apply($t,e),ha=null),e}function kl(e){ha===null?ha=[e]:ha.push(e)}var hc=R(null),Qa=null,Yn=null;function xa(e,t,a){ee(hc,t._currentValue),t._currentValue=a}function Fn(e){e._currentValue=hc.current,U(hc)}function pc(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function xc(e,t,a,l){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var u=c.dependencies;if(u!==null){var y=c.child;u=u.firstContext;e:for(;u!==null;){var j=u;u=c;for(var D=0;D<t.length;D++)if(j.context===t[D]){u.lanes|=a,j=u.alternate,j!==null&&(j.lanes|=a),pc(u.return,a,e),l||(y=null);break e}u=j.next}}else if(c.tag===18){if(y=c.return,y===null)throw Error(o(341));y.lanes|=a,u=y.alternate,u!==null&&(u.lanes|=a),pc(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 Ts(e,t,a,l){e=null;for(var c=t,u=!1;c!==null;){if(!u){if((c.flags&524288)!==0)u=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var y=c.alternate;if(y===null)throw Error(o(387));if(y=y.memoizedProps,y!==null){var j=c.type;Xt(c.pendingProps.value,y.value)||(e!==null?e.push(j):e=[j])}}else if(c===oe.current){if(y=c.alternate,y===null)throw Error(o(387));y.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(ti):e=[ti])}c=c.return}e!==null&&xc(t,e,a,l),t.flags|=262144}function Zi(e){for(e=e.firstContext;e!==null;){if(!Xt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ka(e){Qa=e,Yn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function qt(e){return vm(Qa,e)}function Ii(e,t){return Qa===null&&Ka(e),vm(e,t)}function vm(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Yn===null){if(e===null)throw Error(o(308));Yn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Yn=Yn.next=t;return a}var Zv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Iv=n.unstable_scheduleCallback,Jv=n.unstable_NormalPriority,yt={$$typeof:q,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gc(){return{controller:new Zv,data:new Map,refCount:0}}function Ml(e){e.refCount--,e.refCount===0&&Iv(Jv,function(){e.controller.abort()})}var Rl=null,vc=0,Ds=0,_s=null;function Pv(e,t){if(Rl===null){var a=Rl=[];vc=0,Ds=Su(),_s={status:"pending",value:void 0,then:function(l){a.push(l)}}}return vc++,t.then(ym,ym),t}function ym(){if(--vc===0&&Rl!==null){_s!==null&&(_s.status="fulfilled");var e=Rl;Rl=null,Ds=0,_s=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Wv(e,t){var a=[],l={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return e.then(function(){l.status="fulfilled",l.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(l.status="rejected",l.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),l}var bm=T.S;T.S=function(e,t){ap=Ve(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Pv(e,t),bm!==null&&bm(e,t)};var Za=R(null);function yc(){var e=Za.current;return e!==null?e:Ie.pooledCache}function Ji(e,t){t===null?ee(Za,Za.current):ee(Za,t.pool)}function Sm(){var e=yc();return e===null?null:{parent:yt._currentValue,pool:e}}var Os=Error(o(460)),bc=Error(o(474)),Pi=Error(o(542)),Wi={then:function(){}};function jm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Am(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Hn,Hn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,wm(e),e;default:if(typeof t.status=="string")t.then(Hn,Hn);else{if(e=Ie,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(l){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=l}},function(l){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,wm(e),e}throw Ja=t,Os}}function Ia(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Ja=a,Os):a}}var Ja=null;function Nm(){if(Ja===null)throw Error(o(459));var e=Ja;return Ja=null,e}function wm(e){if(e===Os||e===Pi)throw Error(o(483))}var Bs=null,ql=0;function er(e){var t=ql;return ql+=1,Bs===null&&(Bs=[]),Am(Bs,e,t)}function Tl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function tr(e,t){throw t.$$typeof===S?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Cm(e){function t(L,O){if(e){var G=L.deletions;G===null?(L.deletions=[O],L.flags|=16):G.push(O)}}function a(L,O){if(!e)return null;for(;O!==null;)t(L,O),O=O.sibling;return null}function l(L){for(var O=new Map;L!==null;)L.key!==null?O.set(L.key,L):O.set(L.index,L),L=L.sibling;return O}function c(L,O){return L=$n(L,O),L.index=0,L.sibling=null,L}function u(L,O,G){return L.index=G,e?(G=L.alternate,G!==null?(G=G.index,G<O?(L.flags|=67108866,O):G):(L.flags|=67108866,O)):(L.flags|=1048576,O)}function y(L){return e&&L.alternate===null&&(L.flags|=67108866),L}function j(L,O,G,W){return O===null||O.tag!==6?(O=oc(G,L.mode,W),O.return=L,O):(O=c(O,G),O.return=L,O)}function D(L,O,G,W){var Se=G.type;return Se===E?I(L,O,G.props.children,W,G.key):O!==null&&(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===H&&Ia(Se)===O.type)?(O=c(O,G.props),Tl(O,G),O.return=L,O):(O=Qi(G.type,G.key,G.props,null,L.mode,W),Tl(O,G),O.return=L,O)}function F(L,O,G,W){return O===null||O.tag!==4||O.stateNode.containerInfo!==G.containerInfo||O.stateNode.implementation!==G.implementation?(O=cc(G,L.mode,W),O.return=L,O):(O=c(O,G.children||[]),O.return=L,O)}function I(L,O,G,W,Se){return O===null||O.tag!==7?(O=Fa(G,L.mode,W,Se),O.return=L,O):(O=c(O,G),O.return=L,O)}function ne(L,O,G){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=oc(""+O,L.mode,G),O.return=L,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case k:return G=Qi(O.type,O.key,O.props,null,L.mode,G),Tl(G,O),G.return=L,G;case C:return O=cc(O,L.mode,G),O.return=L,O;case H:return O=Ia(O),ne(L,O,G)}if(Y(O)||te(O))return O=Fa(O,L.mode,G,null),O.return=L,O;if(typeof O.then=="function")return ne(L,er(O),G);if(O.$$typeof===q)return ne(L,Ii(L,O),G);tr(L,O)}return null}function Q(L,O,G,W){var Se=O!==null?O.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Se!==null?null:j(L,O,""+G,W);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case k:return G.key===Se?D(L,O,G,W):null;case C:return G.key===Se?F(L,O,G,W):null;case H:return G=Ia(G),Q(L,O,G,W)}if(Y(G)||te(G))return Se!==null?null:I(L,O,G,W,null);if(typeof G.then=="function")return Q(L,O,er(G),W);if(G.$$typeof===q)return Q(L,O,Ii(L,G),W);tr(L,G)}return null}function Z(L,O,G,W,Se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return L=L.get(G)||null,j(O,L,""+W,Se);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case k:return L=L.get(W.key===null?G:W.key)||null,D(O,L,W,Se);case C:return L=L.get(W.key===null?G:W.key)||null,F(O,L,W,Se);case H:return W=Ia(W),Z(L,O,G,W,Se)}if(Y(W)||te(W))return L=L.get(G)||null,I(O,L,W,Se,null);if(typeof W.then=="function")return Z(L,O,G,er(W),Se);if(W.$$typeof===q)return Z(L,O,G,Ii(O,W),Se);tr(O,W)}return null}function he(L,O,G,W){for(var Se=null,Be=null,ge=O,Ee=O=0,Te=null;ge!==null&&Ee<G.length;Ee++){ge.index>Ee?(Te=ge,ge=null):Te=ge.sibling;var Le=Q(L,ge,G[Ee],W);if(Le===null){ge===null&&(ge=Te);break}e&&ge&&Le.alternate===null&&t(L,ge),O=u(Le,O,Ee),Be===null?Se=Le:Be.sibling=Le,Be=Le,ge=Te}if(Ee===G.length)return a(L,ge),De&&Gn(L,Ee),Se;if(ge===null){for(;Ee<G.length;Ee++)ge=ne(L,G[Ee],W),ge!==null&&(O=u(ge,O,Ee),Be===null?Se=ge:Be.sibling=ge,Be=ge);return De&&Gn(L,Ee),Se}for(ge=l(ge);Ee<G.length;Ee++)Te=Z(ge,L,Ee,G[Ee],W),Te!==null&&(e&&Te.alternate!==null&&ge.delete(Te.key===null?Ee:Te.key),O=u(Te,O,Ee),Be===null?Se=Te:Be.sibling=Te,Be=Te);return e&&ge.forEach(function(_a){return t(L,_a)}),De&&Gn(L,Ee),Se}function je(L,O,G,W){if(G==null)throw Error(o(151));for(var Se=null,Be=null,ge=O,Ee=O=0,Te=null,Le=G.next();ge!==null&&!Le.done;Ee++,Le=G.next()){ge.index>Ee?(Te=ge,ge=null):Te=ge.sibling;var _a=Q(L,ge,Le.value,W);if(_a===null){ge===null&&(ge=Te);break}e&&ge&&_a.alternate===null&&t(L,ge),O=u(_a,O,Ee),Be===null?Se=_a:Be.sibling=_a,Be=_a,ge=Te}if(Le.done)return a(L,ge),De&&Gn(L,Ee),Se;if(ge===null){for(;!Le.done;Ee++,Le=G.next())Le=ne(L,Le.value,W),Le!==null&&(O=u(Le,O,Ee),Be===null?Se=Le:Be.sibling=Le,Be=Le);return De&&Gn(L,Ee),Se}for(ge=l(ge);!Le.done;Ee++,Le=G.next())Le=Z(ge,L,Ee,Le.value,W),Le!==null&&(e&&Le.alternate!==null&&ge.delete(Le.key===null?Ee:Le.key),O=u(Le,O,Ee),Be===null?Se=Le:Be.sibling=Le,Be=Le);return e&&ge.forEach(function(ub){return t(L,ub)}),De&&Gn(L,Ee),Se}function Ke(L,O,G,W){if(typeof G=="object"&&G!==null&&G.type===E&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case k:e:{for(var Se=G.key;O!==null;){if(O.key===Se){if(Se=G.type,Se===E){if(O.tag===7){a(L,O.sibling),W=c(O,G.props.children),W.return=L,L=W;break e}}else if(O.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===H&&Ia(Se)===O.type){a(L,O.sibling),W=c(O,G.props),Tl(W,G),W.return=L,L=W;break e}a(L,O);break}else t(L,O);O=O.sibling}G.type===E?(W=Fa(G.props.children,L.mode,W,G.key),W.return=L,L=W):(W=Qi(G.type,G.key,G.props,null,L.mode,W),Tl(W,G),W.return=L,L=W)}return y(L);case C:e:{for(Se=G.key;O!==null;){if(O.key===Se)if(O.tag===4&&O.stateNode.containerInfo===G.containerInfo&&O.stateNode.implementation===G.implementation){a(L,O.sibling),W=c(O,G.children||[]),W.return=L,L=W;break e}else{a(L,O);break}else t(L,O);O=O.sibling}W=cc(G,L.mode,W),W.return=L,L=W}return y(L);case H:return G=Ia(G),Ke(L,O,G,W)}if(Y(G))return he(L,O,G,W);if(te(G)){if(Se=te(G),typeof Se!="function")throw Error(o(150));return G=Se.call(G),je(L,O,G,W)}if(typeof G.then=="function")return Ke(L,O,er(G),W);if(G.$$typeof===q)return Ke(L,O,Ii(L,G),W);tr(L,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,O!==null&&O.tag===6?(a(L,O.sibling),W=c(O,G),W.return=L,L=W):(a(L,O),W=oc(G,L.mode,W),W.return=L,L=W),y(L)):a(L,O)}return function(L,O,G,W){try{ql=0;var Se=Ke(L,O,G,W);return Bs=null,Se}catch(ge){if(ge===Os||ge===Pi)throw ge;var Be=Qt(29,ge,null,L.mode);return Be.lanes=W,Be.return=L,Be}finally{}}}var Pa=Cm(!0),Em=Cm(!1),ga=!1;function Sc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function jc(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 va(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ya(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ue&2)!==0){var c=l.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),l.pending=t,t=Xi(e),um(e,null,a),t}return Fi(e,l,t,a),Xi(e)}function Dl(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,an(e,a)}}function Ac(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var c=null,u=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};u===null?c=u=y:u=u.next=y,a=a.next}while(a!==null);u===null?c=u=t:u=u.next=t}else c=u=t;a={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:u,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Nc=!1;function _l(){if(Nc){var e=_s;if(e!==null)throw e}}function Ol(e,t,a,l){Nc=!1;var c=e.updateQueue;ga=!1;var u=c.firstBaseUpdate,y=c.lastBaseUpdate,j=c.shared.pending;if(j!==null){c.shared.pending=null;var D=j,F=D.next;D.next=null,y===null?u=F:y.next=F,y=D;var I=e.alternate;I!==null&&(I=I.updateQueue,j=I.lastBaseUpdate,j!==y&&(j===null?I.firstBaseUpdate=F:j.next=F,I.lastBaseUpdate=D))}if(u!==null){var ne=c.baseState;y=0,I=F=D=null,j=u;do{var Q=j.lane&-536870913,Z=Q!==j.lane;if(Z?(qe&Q)===Q:(l&Q)===Q){Q!==0&&Q===Ds&&(Nc=!0),I!==null&&(I=I.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var he=e,je=j;Q=t;var Ke=a;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){ne=he.call(Ke,ne,Q);break e}ne=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,Q=typeof he=="function"?he.call(Ke,ne,Q):he,Q==null)break e;ne=b({},ne,Q);break e;case 2:ga=!0}}Q=j.callback,Q!==null&&(e.flags|=64,Z&&(e.flags|=8192),Z=c.callbacks,Z===null?c.callbacks=[Q]:Z.push(Q))}else Z={lane:Q,tag:j.tag,payload:j.payload,callback:j.callback,next:null},I===null?(F=I=Z,D=ne):I=I.next=Z,y|=Q;if(j=j.next,j===null){if(j=c.shared.pending,j===null)break;Z=j,j=Z.next,Z.next=null,c.lastBaseUpdate=Z,c.shared.pending=null}}while(!0);I===null&&(D=ne),c.baseState=D,c.firstBaseUpdate=F,c.lastBaseUpdate=I,u===null&&(c.shared.lanes=0),Na|=y,e.lanes=y,e.memoizedState=ne}}function km(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function Mm(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)km(a[e],t)}var Ls=R(null),nr=R(0);function Rm(e,t){e=ea,ee(nr,e),ee(Ls,t),ea=e|t.baseLanes}function wc(){ee(nr,ea),ee(Ls,Ls.current)}function Cc(){ea=nr.current,U(Ls),U(nr)}var Kt=R(null),dn=null;function ba(e){var t=e.alternate;ee(xt,xt.current&1),ee(Kt,e),dn===null&&(t===null||Ls.current!==null||t.memoizedState!==null)&&(dn=e)}function Ec(e){ee(xt,xt.current),ee(Kt,e),dn===null&&(dn=e)}function qm(e){e.tag===22?(ee(xt,xt.current),ee(Kt,e),dn===null&&(dn=e)):Sa()}function Sa(){ee(xt,xt.current),ee(Kt,Kt.current)}function Zt(e){U(Kt),dn===e&&(dn=null),U(xt)}var xt=R(0);function ar(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Du(a)||_u(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 Xn=0,Ce=null,Xe=null,bt=null,sr=!1,zs=!1,Wa=!1,lr=0,Bl=0,Us=null,ey=0;function dt(){throw Error(o(321))}function kc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Xt(e[a],t[a]))return!1;return!0}function Mc(e,t,a,l,c,u){return Xn=u,Ce=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?hh:Yc,Wa=!1,u=a(l,c),Wa=!1,zs&&(u=Dm(t,a,l,c)),Tm(e),u}function Tm(e){T.H=Ul;var t=Xe!==null&&Xe.next!==null;if(Xn=0,bt=Xe=Ce=null,sr=!1,Bl=0,Us=null,t)throw Error(o(300));e===null||St||(e=e.dependencies,e!==null&&Zi(e)&&(St=!0))}function Dm(e,t,a,l){Ce=e;var c=0;do{if(zs&&(Us=null),Bl=0,zs=!1,25<=c)throw Error(o(301));if(c+=1,bt=Xe=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}T.H=ph,u=t(a,l)}while(zs);return u}function ty(){var e=T.H,t=e.useState()[0];return t=typeof t.then=="function"?Ll(t):t,e=e.useState()[0],(Xe!==null?Xe.memoizedState:null)!==e&&(Ce.flags|=1024),t}function Rc(){var e=lr!==0;return lr=0,e}function qc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Tc(e){if(sr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}sr=!1}Xn=0,bt=Xe=Ce=null,zs=!1,Bl=lr=0,Us=null}function Lt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bt===null?Ce.memoizedState=bt=e:bt=bt.next=e,bt}function gt(){if(Xe===null){var e=Ce.alternate;e=e!==null?e.memoizedState:null}else e=Xe.next;var t=bt===null?Ce.memoizedState:bt.next;if(t!==null)bt=t,Xe=e;else{if(e===null)throw Ce.alternate===null?Error(o(467)):Error(o(310));Xe=e,e={memoizedState:Xe.memoizedState,baseState:Xe.baseState,baseQueue:Xe.baseQueue,queue:Xe.queue,next:null},bt===null?Ce.memoizedState=bt=e:bt=bt.next=e}return bt}function ir(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ll(e){var t=Bl;return Bl+=1,Us===null&&(Us=[]),e=Am(Us,e,t),t=Ce,(bt===null?t.memoizedState:bt.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?hh:Yc),e}function rr(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ll(e);if(e.$$typeof===q)return qt(e)}throw Error(o(438,String(e)))}function Dc(e){var t=null,a=Ce.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var l=Ce.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=ir(),Ce.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),l=0;l<e;l++)a[l]=V;return t.index++,a}function Qn(e,t){return typeof t=="function"?t(e):t}function or(e){var t=gt();return _c(t,Xe,e)}function _c(e,t,a){var l=e.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=a;var c=e.baseQueue,u=l.pending;if(u!==null){if(c!==null){var y=c.next;c.next=u.next,u.next=y}t.baseQueue=c=u,l.pending=null}if(u=e.baseState,c===null)e.memoizedState=u;else{t=c.next;var j=y=null,D=null,F=t,I=!1;do{var ne=F.lane&-536870913;if(ne!==F.lane?(qe&ne)===ne:(Xn&ne)===ne){var Q=F.revertLane;if(Q===0)D!==null&&(D=D.next={lane:0,revertLane:0,gesture:null,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null}),ne===Ds&&(I=!0);else if((Xn&Q)===Q){F=F.next,Q===Ds&&(I=!0);continue}else ne={lane:0,revertLane:F.revertLane,gesture:null,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null},D===null?(j=D=ne,y=u):D=D.next=ne,Ce.lanes|=Q,Na|=Q;ne=F.action,Wa&&a(u,ne),u=F.hasEagerState?F.eagerState:a(u,ne)}else Q={lane:ne,revertLane:F.revertLane,gesture:F.gesture,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null},D===null?(j=D=Q,y=u):D=D.next=Q,Ce.lanes|=ne,Na|=ne;F=F.next}while(F!==null&&F!==t);if(D===null?y=u:D.next=j,!Xt(u,e.memoizedState)&&(St=!0,I&&(a=_s,a!==null)))throw a;e.memoizedState=u,e.baseState=y,e.baseQueue=D,l.lastRenderedState=u}return c===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Oc(e){var t=gt(),a=t.queue;if(a===null)throw Error(o(311));a.lastRenderedReducer=e;var l=a.dispatch,c=a.pending,u=t.memoizedState;if(c!==null){a.pending=null;var y=c=c.next;do u=e(u,y.action),y=y.next;while(y!==c);Xt(u,t.memoizedState)||(St=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),a.lastRenderedState=u}return[u,l]}function _m(e,t,a){var l=Ce,c=gt(),u=De;if(u){if(a===void 0)throw Error(o(407));a=a()}else a=t();var y=!Xt((Xe||c).memoizedState,a);if(y&&(c.memoizedState=a,St=!0),c=c.queue,zc(Lm.bind(null,l,c,e),[e]),c.getSnapshot!==t||y||bt!==null&&bt.memoizedState.tag&1){if(l.flags|=2048,Hs(9,{destroy:void 0},Bm.bind(null,l,c,a,t),null),Ie===null)throw Error(o(349));u||(Xn&127)!==0||Om(l,t,a)}return a}function Om(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ce.updateQueue,t===null?(t=ir(),Ce.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Bm(e,t,a,l){t.value=a,t.getSnapshot=l,zm(t)&&Um(e)}function Lm(e,t,a){return a(function(){zm(t)&&Um(e)})}function zm(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Xt(e,a)}catch{return!0}}function Um(e){var t=Ya(e,2);t!==null&&Gt(t,e,2)}function Bc(e){var t=Lt();if(typeof e=="function"){var a=e;if(e=a(),Wa){Ft(!0);try{a()}finally{Ft(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:e},t}function Hm(e,t,a,l){return e.baseState=a,_c(e,Xe,typeof l=="function"?l:Qn)}function ny(e,t,a,l,c){if(fr(e))throw Error(o(485));if(e=t.action,e!==null){var u={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){u.listeners.push(y)}};T.T!==null?a(!0):u.isTransition=!1,l(u),a=t.pending,a===null?(u.next=t.pending=u,Vm(t,u)):(u.next=a.next,t.pending=a.next=u)}}function Vm(e,t){var a=t.action,l=t.payload,c=e.state;if(t.isTransition){var u=T.T,y={};T.T=y;try{var j=a(c,l),D=T.S;D!==null&&D(y,j),$m(e,t,j)}catch(F){Lc(e,t,F)}finally{u!==null&&y.types!==null&&(u.types=y.types),T.T=u}}else try{u=a(c,l),$m(e,t,u)}catch(F){Lc(e,t,F)}}function $m(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Gm(e,t,l)},function(l){return Lc(e,t,l)}):Gm(e,t,a)}function Gm(e,t,a){t.status="fulfilled",t.value=a,Ym(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Vm(e,a)))}function Lc(e,t,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=a,Ym(t),t=t.next;while(t!==l)}e.action=null}function Ym(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Fm(e,t){return t}function Xm(e,t){if(De){var a=Ie.formState;if(a!==null){e:{var l=Ce;if(De){if(We){t:{for(var c=We,u=fn;c.nodeType!==8;){if(!u){c=null;break t}if(c=mn(c.nextSibling),c===null){c=null;break t}}u=c.data,c=u==="F!"||u==="F"?c:null}if(c){We=mn(c.nextSibling),l=c.data==="F!";break e}}pa(l)}l=!1}l&&(t=a[0])}}return a=Lt(),a.memoizedState=a.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fm,lastRenderedState:t},a.queue=l,a=fh.bind(null,Ce,l),l.dispatch=a,l=Bc(!1),u=Gc.bind(null,Ce,!1,l.queue),l=Lt(),c={state:t,dispatch:null,action:e,pending:null},l.queue=c,a=ny.bind(null,Ce,c,u,a),c.dispatch=a,l.memoizedState=e,[t,a,!1]}function Qm(e){var t=gt();return Km(t,Xe,e)}function Km(e,t,a){if(t=_c(e,t,Fm)[0],e=or(Qn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=Ll(t)}catch(y){throw y===Os?Pi:y}else l=t;t=gt();var c=t.queue,u=c.dispatch;return a!==t.memoizedState&&(Ce.flags|=2048,Hs(9,{destroy:void 0},ay.bind(null,c,a),null)),[l,u,e]}function ay(e,t){e.action=t}function Zm(e){var t=gt(),a=Xe;if(a!==null)return Km(t,a,e);gt(),t=t.memoizedState,a=gt();var l=a.queue.dispatch;return a.memoizedState=e,[t,l,!1]}function Hs(e,t,a,l){return e={tag:e,create:a,deps:l,inst:t,next:null},t=Ce.updateQueue,t===null&&(t=ir(),Ce.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e),e}function Im(){return gt().memoizedState}function cr(e,t,a,l){var c=Lt();Ce.flags|=e,c.memoizedState=Hs(1|t,{destroy:void 0},a,l===void 0?null:l)}function ur(e,t,a,l){var c=gt();l=l===void 0?null:l;var u=c.memoizedState.inst;Xe!==null&&l!==null&&kc(l,Xe.memoizedState.deps)?c.memoizedState=Hs(t,u,a,l):(Ce.flags|=e,c.memoizedState=Hs(1|t,u,a,l))}function Jm(e,t){cr(8390656,8,e,t)}function zc(e,t){ur(2048,8,e,t)}function sy(e){Ce.flags|=4;var t=Ce.updateQueue;if(t===null)t=ir(),Ce.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Pm(e){var t=gt().memoizedState;return sy({ref:t,nextImpl:e}),function(){if((Ue&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Wm(e,t){return ur(4,2,e,t)}function eh(e,t){return ur(4,4,e,t)}function th(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 nh(e,t,a){a=a!=null?a.concat([e]):null,ur(4,4,th.bind(null,t,e),a)}function Uc(){}function ah(e,t){var a=gt();t=t===void 0?null:t;var l=a.memoizedState;return t!==null&&kc(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function sh(e,t){var a=gt();t=t===void 0?null:t;var l=a.memoizedState;if(t!==null&&kc(t,l[1]))return l[0];if(l=e(),Wa){Ft(!0);try{e()}finally{Ft(!1)}}return a.memoizedState=[l,t],l}function Hc(e,t,a){return a===void 0||(Xn&1073741824)!==0&&(qe&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=lp(),Ce.lanes|=e,Na|=e,a)}function lh(e,t,a,l){return Xt(a,t)?a:Ls.current!==null?(e=Hc(e,a,l),Xt(e,t)||(St=!0),e):(Xn&42)===0||(Xn&1073741824)!==0&&(qe&261930)===0?(St=!0,e.memoizedState=a):(e=lp(),Ce.lanes|=e,Na|=e,t)}function ih(e,t,a,l,c){var u=$.p;$.p=u!==0&&8>u?u:8;var y=T.T,j={};T.T=j,Gc(e,!1,t,a);try{var D=c(),F=T.S;if(F!==null&&F(j,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var I=Wv(D,l);zl(e,t,I,Pt(e))}else zl(e,t,l,Pt(e))}catch(ne){zl(e,t,{then:function(){},status:"rejected",reason:ne},Pt())}finally{$.p=u,y!==null&&j.types!==null&&(y.types=j.types),T.T=y}}function ly(){}function Vc(e,t,a,l){if(e.tag!==5)throw Error(o(476));var c=rh(e).queue;ih(e,c,t,J,a===null?ly:function(){return oh(e),a(l)})}function rh(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:Qn,lastRenderedState:J},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function oh(e){var t=rh(e);t.next===null&&(t=e.alternate.memoizedState),zl(e,t.next.queue,{},Pt())}function $c(){return qt(ti)}function ch(){return gt().memoizedState}function uh(){return gt().memoizedState}function iy(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Pt();e=va(a);var l=ya(t,e,a);l!==null&&(Gt(l,t,a),Dl(l,t,a)),t={cache:gc()},e.payload=t;return}t=t.return}}function ry(e,t,a){var l=Pt();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},fr(e)?dh(t,a):(a=ic(e,t,a,l),a!==null&&(Gt(a,e,l),mh(a,t,l)))}function fh(e,t,a){var l=Pt();zl(e,t,a,l)}function zl(e,t,a,l){var c={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(fr(e))dh(t,c);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var y=t.lastRenderedState,j=u(y,a);if(c.hasEagerState=!0,c.eagerState=j,Xt(j,y))return Fi(e,t,c,0),Ie===null&&Yi(),!1}catch{}finally{}if(a=ic(e,t,c,l),a!==null)return Gt(a,e,l),mh(a,t,l),!0}return!1}function Gc(e,t,a,l){if(l={lane:2,revertLane:Su(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},fr(e)){if(t)throw Error(o(479))}else t=ic(e,a,l,2),t!==null&&Gt(t,e,2)}function fr(e){var t=e.alternate;return e===Ce||t!==null&&t===Ce}function dh(e,t){zs=sr=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function mh(e,t,a){if((a&4194048)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,an(e,a)}}var Ul={readContext:qt,use:rr,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useLayoutEffect:dt,useInsertionEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useSyncExternalStore:dt,useId:dt,useHostTransitionStatus:dt,useFormState:dt,useActionState:dt,useOptimistic:dt,useMemoCache:dt,useCacheRefresh:dt};Ul.useEffectEvent=dt;var hh={readContext:qt,use:rr,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:qt,useEffect:Jm,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,cr(4194308,4,th.bind(null,t,e),a)},useLayoutEffect:function(e,t){return cr(4194308,4,e,t)},useInsertionEffect:function(e,t){cr(4,2,e,t)},useMemo:function(e,t){var a=Lt();t=t===void 0?null:t;var l=e();if(Wa){Ft(!0);try{e()}finally{Ft(!1)}}return a.memoizedState=[l,t],l},useReducer:function(e,t,a){var l=Lt();if(a!==void 0){var c=a(t);if(Wa){Ft(!0);try{a(t)}finally{Ft(!1)}}}else c=t;return l.memoizedState=l.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},l.queue=e,e=e.dispatch=ry.bind(null,Ce,e),[l.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:function(e){e=Bc(e);var t=e.queue,a=fh.bind(null,Ce,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Uc,useDeferredValue:function(e,t){var a=Lt();return Hc(a,e,t)},useTransition:function(){var e=Bc(!1);return e=ih.bind(null,Ce,e.queue,!0,!1),Lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var l=Ce,c=Lt();if(De){if(a===void 0)throw Error(o(407));a=a()}else{if(a=t(),Ie===null)throw Error(o(349));(qe&127)!==0||Om(l,t,a)}c.memoizedState=a;var u={value:a,getSnapshot:t};return c.queue=u,Jm(Lm.bind(null,l,u,e),[e]),l.flags|=2048,Hs(9,{destroy:void 0},Bm.bind(null,l,u,a,t),null),a},useId:function(){var e=Lt(),t=Ie.identifierPrefix;if(De){var a=kn,l=En;a=(l&~(1<<32-Mt(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=lr++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=ey++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:$c,useFormState:Xm,useActionState:Xm,useOptimistic:function(e){var t=Lt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Gc.bind(null,Ce,!0,a),a.dispatch=t,[e,t]},useMemoCache:Dc,useCacheRefresh:function(){return Lt().memoizedState=iy.bind(null,Ce)},useEffectEvent:function(e){var t=Lt(),a={impl:e};return t.memoizedState=a,function(){if((Ue&2)!==0)throw Error(o(440));return a.impl.apply(void 0,arguments)}}},Yc={readContext:qt,use:rr,useCallback:ah,useContext:qt,useEffect:zc,useImperativeHandle:nh,useInsertionEffect:Wm,useLayoutEffect:eh,useMemo:sh,useReducer:or,useRef:Im,useState:function(){return or(Qn)},useDebugValue:Uc,useDeferredValue:function(e,t){var a=gt();return lh(a,Xe.memoizedState,e,t)},useTransition:function(){var e=or(Qn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:Ll(e),t]},useSyncExternalStore:_m,useId:ch,useHostTransitionStatus:$c,useFormState:Qm,useActionState:Qm,useOptimistic:function(e,t){var a=gt();return Hm(a,Xe,e,t)},useMemoCache:Dc,useCacheRefresh:uh};Yc.useEffectEvent=Pm;var ph={readContext:qt,use:rr,useCallback:ah,useContext:qt,useEffect:zc,useImperativeHandle:nh,useInsertionEffect:Wm,useLayoutEffect:eh,useMemo:sh,useReducer:Oc,useRef:Im,useState:function(){return Oc(Qn)},useDebugValue:Uc,useDeferredValue:function(e,t){var a=gt();return Xe===null?Hc(a,e,t):lh(a,Xe.memoizedState,e,t)},useTransition:function(){var e=Oc(Qn)[0],t=gt().memoizedState;return[typeof e=="boolean"?e:Ll(e),t]},useSyncExternalStore:_m,useId:ch,useHostTransitionStatus:$c,useFormState:Zm,useActionState:Zm,useOptimistic:function(e,t){var a=gt();return Xe!==null?Hm(a,Xe,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Dc,useCacheRefresh:uh};ph.useEffectEvent=Pm;function Fc(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:b({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Xc={enqueueSetState:function(e,t,a){e=e._reactInternals;var l=Pt(),c=va(l);c.payload=t,a!=null&&(c.callback=a),t=ya(e,c,l),t!==null&&(Gt(t,e,l),Dl(t,e,l))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=Pt(),c=va(l);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=ya(e,c,l),t!==null&&(Gt(t,e,l),Dl(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Pt(),l=va(a);l.tag=2,t!=null&&(l.callback=t),t=ya(e,l,a),t!==null&&(Gt(t,e,a),Dl(t,e,a))}};function xh(e,t,a,l,c,u,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,u,y):t.prototype&&t.prototype.isPureReactComponent?!wl(a,l)||!wl(c,u):!0}function gh(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Xc.enqueueReplaceState(t,t.state,null)}function es(e,t){var a=t;if("ref"in t){a={};for(var l in t)l!=="ref"&&(a[l]=t[l])}if(e=e.defaultProps){a===t&&(a=b({},a));for(var c in e)a[c]===void 0&&(a[c]=e[c])}return a}function vh(e){Gi(e)}function yh(e){console.error(e)}function bh(e){Gi(e)}function dr(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function Sh(e,t,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Qc(e,t,a){return a=va(a),a.tag=3,a.payload={element:null},a.callback=function(){dr(e,t)},a}function jh(e){return e=va(e),e.tag=3,e}function Ah(e,t,a,l){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var u=l.value;e.payload=function(){return c(u)},e.callback=function(){Sh(t,a,l)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Sh(t,a,l),typeof c!="function"&&(wa===null?wa=new Set([this]):wa.add(this));var j=l.stack;this.componentDidCatch(l.value,{componentStack:j!==null?j:""})})}function oy(e,t,a,l,c){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=a.alternate,t!==null&&Ts(t,a,c,!0),a=Kt.current,a!==null){switch(a.tag){case 31:case 13:return dn===null?Nr():a.alternate===null&&mt===0&&(mt=3),a.flags&=-257,a.flags|=65536,a.lanes=c,l===Wi?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([l]):t.add(l),vu(e,l,c)),!1;case 22:return a.flags|=65536,l===Wi?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([l]):a.add(l)),vu(e,l,c)),!1}throw Error(o(435,a.tag))}return vu(e,l,c),Nr(),!1}if(De)return t=Kt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,l!==dc&&(e=Error(o(422),{cause:l}),kl(on(e,a)))):(l!==dc&&(t=Error(o(423),{cause:l}),kl(on(t,a))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,l=on(l,a),c=Qc(e.stateNode,l,c),Ac(e,c),mt!==4&&(mt=2)),!1;var u=Error(o(520),{cause:l});if(u=on(u,a),Ql===null?Ql=[u]:Ql.push(u),mt!==4&&(mt=2),t===null)return!0;l=on(l,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=c&-c,a.lanes|=e,e=Qc(a.stateNode,l,e),Ac(a,e),!1;case 1:if(t=a.type,u=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(wa===null||!wa.has(u))))return a.flags|=65536,c&=-c,a.lanes|=c,c=jh(c),Ah(c,e,a,l),Ac(a,c),!1}a=a.return}while(a!==null);return!1}var Kc=Error(o(461)),St=!1;function Tt(e,t,a,l){t.child=e===null?Em(t,null,a,l):Pa(t,e.child,a,l)}function Nh(e,t,a,l,c){a=a.render;var u=t.ref;if("ref"in l){var y={};for(var j in l)j!=="ref"&&(y[j]=l[j])}else y=l;return Ka(t),l=Mc(e,t,a,y,u,c),j=Rc(),e!==null&&!St?(qc(e,t,c),Kn(e,t,c)):(De&&j&&uc(t),t.flags|=1,Tt(e,t,l,c),t.child)}function wh(e,t,a,l,c){if(e===null){var u=a.type;return typeof u=="function"&&!rc(u)&&u.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=u,Ch(e,t,u,l,c)):(e=Qi(a.type,null,l,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!nu(e,c)){var y=u.memoizedProps;if(a=a.compare,a=a!==null?a:wl,a(y,l)&&e.ref===t.ref)return Kn(e,t,c)}return t.flags|=1,e=$n(u,l),e.ref=t.ref,e.return=t,t.child=e}function Ch(e,t,a,l,c){if(e!==null){var u=e.memoizedProps;if(wl(u,l)&&e.ref===t.ref)if(St=!1,t.pendingProps=l=u,nu(e,c))(e.flags&131072)!==0&&(St=!0);else return t.lanes=e.lanes,Kn(e,t,c)}return Zc(e,t,a,l,c)}function Eh(e,t,a,l){var c=l.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|a:a,e!==null){for(l=t.child=e.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~u}else l=0,t.child=null;return kh(e,t,u,a,l)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ji(t,u!==null?u.cachePool:null),u!==null?Rm(t,u):wc(),qm(t);else return l=t.lanes=536870912,kh(e,t,u!==null?u.baseLanes|a:a,a,l)}else u!==null?(Ji(t,u.cachePool),Rm(t,u),Sa(),t.memoizedState=null):(e!==null&&Ji(t,null),wc(),Sa());return Tt(e,t,c,a),t.child}function Hl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function kh(e,t,a,l,c){var u=yc();return u=u===null?null:{parent:yt._currentValue,pool:u},t.memoizedState={baseLanes:a,cachePool:u},e!==null&&Ji(t,null),wc(),qm(t),e!==null&&Ts(e,t,l,!0),t.childLanes=c,null}function mr(e,t){return t=pr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Mh(e,t,a){return Pa(t,e.child,null,a),e=mr(t,t.pendingProps),e.flags|=2,Zt(t),t.memoizedState=null,e}function cy(e,t,a){var l=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(De){if(l.mode==="hidden")return e=mr(t,l),t.lanes=536870912,Hl(null,e);if(Ec(t),(e=We)?(e=Vp(e,fn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ma!==null?{id:En,overflow:kn}:null,retryLane:536870912,hydrationErrors:null},a=dm(e),a.return=t,t.child=a,Rt=t,We=null)):e=null,e===null)throw pa(t);return t.lanes=536870912,null}return mr(t,l)}var u=e.memoizedState;if(u!==null){var y=u.dehydrated;if(Ec(t),c)if(t.flags&256)t.flags&=-257,t=Mh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(St||Ts(e,t,a,!1),c=(a&e.childLanes)!==0,St||c){if(l=Ie,l!==null&&(y=be(l,a),y!==0&&y!==u.retryLane))throw u.retryLane=y,Ya(e,y),Gt(l,e,y),Kc;Nr(),t=Mh(e,t,a)}else e=u.treeContext,We=mn(y.nextSibling),Rt=t,De=!0,ha=null,fn=!1,e!==null&&pm(t,e),t=mr(t,l),t.flags|=4096;return t}return e=$n(e.child,{mode:l.mode,children:l.children}),e.ref=t.ref,t.child=e,e.return=t,e}function hr(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 Zc(e,t,a,l,c){return Ka(t),a=Mc(e,t,a,l,void 0,c),l=Rc(),e!==null&&!St?(qc(e,t,c),Kn(e,t,c)):(De&&l&&uc(t),t.flags|=1,Tt(e,t,a,c),t.child)}function Rh(e,t,a,l,c,u){return Ka(t),t.updateQueue=null,a=Dm(t,l,a,c),Tm(e),l=Rc(),e!==null&&!St?(qc(e,t,u),Kn(e,t,u)):(De&&l&&uc(t),t.flags|=1,Tt(e,t,a,u),t.child)}function qh(e,t,a,l,c){if(Ka(t),t.stateNode===null){var u=ks,y=a.contextType;typeof y=="object"&&y!==null&&(u=qt(y)),u=new a(l,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Xc,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=l,u.state=t.memoizedState,u.refs={},Sc(t),y=a.contextType,u.context=typeof y=="object"&&y!==null?qt(y):ks,u.state=t.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(Fc(t,a,y,l),u.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(y=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),y!==u.state&&Xc.enqueueReplaceState(u,u.state,null),Ol(t,l,u,c),_l(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(e===null){u=t.stateNode;var j=t.memoizedProps,D=es(a,j);u.props=D;var F=u.context,I=a.contextType;y=ks,typeof I=="object"&&I!==null&&(y=qt(I));var ne=a.getDerivedStateFromProps;I=typeof ne=="function"||typeof u.getSnapshotBeforeUpdate=="function",j=t.pendingProps!==j,I||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(j||F!==y)&&gh(t,u,l,y),ga=!1;var Q=t.memoizedState;u.state=Q,Ol(t,l,u,c),_l(),F=t.memoizedState,j||Q!==F||ga?(typeof ne=="function"&&(Fc(t,a,ne,l),F=t.memoizedState),(D=ga||xh(t,a,D,l,Q,F,y))?(I||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=F),u.props=l,u.state=F,u.context=y,l=D):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{u=t.stateNode,jc(e,t),y=t.memoizedProps,I=es(a,y),u.props=I,ne=t.pendingProps,Q=u.context,F=a.contextType,D=ks,typeof F=="object"&&F!==null&&(D=qt(F)),j=a.getDerivedStateFromProps,(F=typeof j=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(y!==ne||Q!==D)&&gh(t,u,l,D),ga=!1,Q=t.memoizedState,u.state=Q,Ol(t,l,u,c),_l();var Z=t.memoizedState;y!==ne||Q!==Z||ga||e!==null&&e.dependencies!==null&&Zi(e.dependencies)?(typeof j=="function"&&(Fc(t,a,j,l),Z=t.memoizedState),(I=ga||xh(t,a,I,l,Q,Z,D)||e!==null&&e.dependencies!==null&&Zi(e.dependencies))?(F||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(l,Z,D),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(l,Z,D)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=Z),u.props=l,u.state=Z,u.context=D,l=I):(typeof u.componentDidUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&Q===e.memoizedState||(t.flags|=1024),l=!1)}return u=l,hr(e,t),l=(t.flags&128)!==0,u||l?(u=t.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&l?(t.child=Pa(t,e.child,null,c),t.child=Pa(t,null,a,c)):Tt(e,t,a,c),t.memoizedState=u.state,e=t.child):e=Kn(e,t,c),e}function Th(e,t,a,l){return Xa(),t.flags|=256,Tt(e,t,a,l),t.child}var Ic={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Jc(e){return{baseLanes:e,cachePool:Sm()}}function Pc(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Jt),e}function Dh(e,t,a){var l=t.pendingProps,c=!1,u=(t.flags&128)!==0,y;if((y=u)||(y=e!==null&&e.memoizedState===null?!1:(xt.current&2)!==0),y&&(c=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(De){if(c?ba(t):Sa(),(e=We)?(e=Vp(e,fn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ma!==null?{id:En,overflow:kn}:null,retryLane:536870912,hydrationErrors:null},a=dm(e),a.return=t,t.child=a,Rt=t,We=null)):e=null,e===null)throw pa(t);return _u(e)?t.lanes=32:t.lanes=536870912,null}var j=l.children;return l=l.fallback,c?(Sa(),c=t.mode,j=pr({mode:"hidden",children:j},c),l=Fa(l,c,a,null),j.return=t,l.return=t,j.sibling=l,t.child=j,l=t.child,l.memoizedState=Jc(a),l.childLanes=Pc(e,y,a),t.memoizedState=Ic,Hl(null,l)):(ba(t),Wc(t,j))}var D=e.memoizedState;if(D!==null&&(j=D.dehydrated,j!==null)){if(u)t.flags&256?(ba(t),t.flags&=-257,t=eu(e,t,a)):t.memoizedState!==null?(Sa(),t.child=e.child,t.flags|=128,t=null):(Sa(),j=l.fallback,c=t.mode,l=pr({mode:"visible",children:l.children},c),j=Fa(j,c,a,null),j.flags|=2,l.return=t,j.return=t,l.sibling=j,t.child=l,Pa(t,e.child,null,a),l=t.child,l.memoizedState=Jc(a),l.childLanes=Pc(e,y,a),t.memoizedState=Ic,t=Hl(null,l));else if(ba(t),_u(j)){if(y=j.nextSibling&&j.nextSibling.dataset,y)var F=y.dgst;y=F,l=Error(o(419)),l.stack="",l.digest=y,kl({value:l,source:null,stack:null}),t=eu(e,t,a)}else if(St||Ts(e,t,a,!1),y=(a&e.childLanes)!==0,St||y){if(y=Ie,y!==null&&(l=be(y,a),l!==0&&l!==D.retryLane))throw D.retryLane=l,Ya(e,l),Gt(y,e,l),Kc;Du(j)||Nr(),t=eu(e,t,a)}else Du(j)?(t.flags|=192,t.child=e.child,t=null):(e=D.treeContext,We=mn(j.nextSibling),Rt=t,De=!0,ha=null,fn=!1,e!==null&&pm(t,e),t=Wc(t,l.children),t.flags|=4096);return t}return c?(Sa(),j=l.fallback,c=t.mode,D=e.child,F=D.sibling,l=$n(D,{mode:"hidden",children:l.children}),l.subtreeFlags=D.subtreeFlags&65011712,F!==null?j=$n(F,j):(j=Fa(j,c,a,null),j.flags|=2),j.return=t,l.return=t,l.sibling=j,t.child=l,Hl(null,l),l=t.child,j=e.child.memoizedState,j===null?j=Jc(a):(c=j.cachePool,c!==null?(D=yt._currentValue,c=c.parent!==D?{parent:D,pool:D}:c):c=Sm(),j={baseLanes:j.baseLanes|a,cachePool:c}),l.memoizedState=j,l.childLanes=Pc(e,y,a),t.memoizedState=Ic,Hl(e.child,l)):(ba(t),a=e.child,e=a.sibling,a=$n(a,{mode:"visible",children:l.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 Wc(e,t){return t=pr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function pr(e,t){return e=Qt(22,e,null,t),e.lanes=0,e}function eu(e,t,a){return Pa(t,e.child,null,a),e=Wc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _h(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),pc(e.return,t,a)}function tu(e,t,a,l,c,u){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:c,treeForkCount:u}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=l,y.tail=a,y.tailMode=c,y.treeForkCount=u)}function Oh(e,t,a){var l=t.pendingProps,c=l.revealOrder,u=l.tail;l=l.children;var y=xt.current,j=(y&2)!==0;if(j?(y=y&1|2,t.flags|=128):y&=1,ee(xt,y),Tt(e,t,l,a),l=De?El:0,!j&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_h(e,a,t);else if(e.tag===19)_h(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&&ar(e)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),tu(t,!1,c,a,u,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&ar(e)===null){t.child=c;break}e=c.sibling,c.sibling=a,a=c,c=e}tu(t,!0,a,null,u,l);break;case"together":tu(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function Kn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Na|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ts(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=$n(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=$n(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function nu(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Zi(e)))}function uy(e,t,a){switch(t.tag){case 3:ve(t,t.stateNode.containerInfo),xa(t,yt,e.memoizedState.cache),Xa();break;case 27:case 5:xe(t);break;case 4:ve(t,t.stateNode.containerInfo);break;case 10:xa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ec(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(ba(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Dh(e,t,a):(ba(t),e=Kn(e,t,a),e!==null?e.sibling:null);ba(t);break;case 19:var c=(e.flags&128)!==0;if(l=(a&t.childLanes)!==0,l||(Ts(e,t,a,!1),l=(a&t.childLanes)!==0),c){if(l)return Oh(e,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),ee(xt,xt.current),l)break;return null;case 22:return t.lanes=0,Eh(e,t,a,t.pendingProps);case 24:xa(t,yt,e.memoizedState.cache)}return Kn(e,t,a)}function Bh(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)St=!0;else{if(!nu(e,a)&&(t.flags&128)===0)return St=!1,uy(e,t,a);St=(e.flags&131072)!==0}else St=!1,De&&(t.flags&1048576)!==0&&hm(t,El,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(e=Ia(t.elementType),t.type=e,typeof e=="function")rc(e)?(l=es(e,l),t.tag=1,t=qh(null,t,e,l,a)):(t.tag=0,t=Zc(null,t,e,l,a));else{if(e!=null){var c=e.$$typeof;if(c===M){t.tag=11,t=Nh(null,t,e,l,a);break e}else if(c===_){t.tag=14,t=wh(null,t,e,l,a);break e}}throw t=ce(e)||e,Error(o(306,t,""))}}return t;case 0:return Zc(e,t,t.type,t.pendingProps,a);case 1:return l=t.type,c=es(l,t.pendingProps),qh(e,t,l,c,a);case 3:e:{if(ve(t,t.stateNode.containerInfo),e===null)throw Error(o(387));l=t.pendingProps;var u=t.memoizedState;c=u.element,jc(e,t),Ol(t,l,null,a);var y=t.memoizedState;if(l=y.cache,xa(t,yt,l),l!==u.cache&&xc(t,[yt],a,!0),_l(),l=y.element,u.isDehydrated)if(u={element:l,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=Th(e,t,l,a);break e}else if(l!==c){c=on(Error(o(424)),t),kl(c),t=Th(e,t,l,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(We=mn(e.firstChild),Rt=t,De=!0,ha=null,fn=!0,a=Em(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Xa(),l===c){t=Kn(e,t,a);break e}Tt(e,t,l,a)}t=t.child}return t;case 26:return hr(e,t),e===null?(a=Qp(t.type,null,t.pendingProps,null))?t.memoizedState=a:De||(a=t.type,e=t.pendingProps,l=qr(re.current).createElement(a),l[ot]=t,l[wt]=e,Dt(l,a,e),Et(l),t.stateNode=l):t.memoizedState=Qp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&De&&(l=t.stateNode=Yp(t.type,t.pendingProps,re.current),Rt=t,fn=!0,c=We,Ma(t.type)?(Ou=c,We=mn(l.firstChild)):We=c),Tt(e,t,t.pendingProps.children,a),hr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&De&&((c=l=We)&&(l=Hy(l,t.type,t.pendingProps,fn),l!==null?(t.stateNode=l,Rt=t,We=mn(l.firstChild),fn=!1,c=!0):c=!1),c||pa(t)),xe(t),c=t.type,u=t.pendingProps,y=e!==null?e.memoizedProps:null,l=u.children,Ru(c,u)?l=null:y!==null&&Ru(c,y)&&(t.flags|=32),t.memoizedState!==null&&(c=Mc(e,t,ty,null,null,a),ti._currentValue=c),hr(e,t),Tt(e,t,l,a),t.child;case 6:return e===null&&De&&((e=a=We)&&(a=Vy(a,t.pendingProps,fn),a!==null?(t.stateNode=a,Rt=t,We=null,e=!0):e=!1),e||pa(t)),null;case 13:return Dh(e,t,a);case 4:return ve(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Pa(t,null,l,a):Tt(e,t,l,a),t.child;case 11:return Nh(e,t,t.type,t.pendingProps,a);case 7:return Tt(e,t,t.pendingProps,a),t.child;case 8:return Tt(e,t,t.pendingProps.children,a),t.child;case 12:return Tt(e,t,t.pendingProps.children,a),t.child;case 10:return l=t.pendingProps,xa(t,t.type,l.value),Tt(e,t,l.children,a),t.child;case 9:return c=t.type._context,l=t.pendingProps.children,Ka(t),c=qt(c),l=l(c),t.flags|=1,Tt(e,t,l,a),t.child;case 14:return wh(e,t,t.type,t.pendingProps,a);case 15:return Ch(e,t,t.type,t.pendingProps,a);case 19:return Oh(e,t,a);case 31:return cy(e,t,a);case 22:return Eh(e,t,a,t.pendingProps);case 24:return Ka(t),l=qt(yt),e===null?(c=yc(),c===null&&(c=Ie,u=gc(),c.pooledCache=u,u.refCount++,u!==null&&(c.pooledCacheLanes|=a),c=u),t.memoizedState={parent:l,cache:c},Sc(t),xa(t,yt,c)):((e.lanes&a)!==0&&(jc(e,t),Ol(t,null,null,a),_l()),c=e.memoizedState,u=t.memoizedState,c.parent!==l?(c={parent:l,cache:l},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),xa(t,yt,l)):(l=u.cache,xa(t,yt,l),l!==c.cache&&xc(t,[yt],a,!0))),Tt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Zn(e){e.flags|=4}function au(e,t,a,l,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(cp())e.flags|=8192;else throw Ja=Wi,bc}else e.flags&=-16777217}function Lh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Pp(t))if(cp())e.flags|=8192;else throw Ja=Wi,bc}function xr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?ml():536870912,e.lanes|=t,Ys|=t)}function Vl(e,t){if(!De)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 l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function et(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function fy(e,t,a){var l=t.pendingProps;switch(fc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return et(t),null;case 1:return et(t),null;case 3:return a=t.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Fn(yt),ye(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(qs(t)?Zn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,mc())),et(t),null;case 26:var c=t.type,u=t.memoizedState;return e===null?(Zn(t),u!==null?(et(t),Lh(t,u)):(et(t),au(t,c,null,l,a))):u?u!==e.memoizedState?(Zn(t),et(t),Lh(t,u)):(et(t),t.flags&=-16777217):(e=e.memoizedProps,e!==l&&Zn(t),et(t),au(t,c,e,l,a)),null;case 27:if(Oe(t),a=re.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Zn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return et(t),null}e=ae.current,qs(t)?xm(t):(e=Yp(c,l,a),t.stateNode=e,Zn(t))}return et(t),null;case 5:if(Oe(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Zn(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return et(t),null}if(u=ae.current,qs(t))xm(t);else{var y=qr(re.current);switch(u){case 1:u=y.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:u=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":u=y.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":u=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":u=y.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof l.is=="string"?y.createElement("select",{is:l.is}):y.createElement("select"),l.multiple?u.multiple=!0:l.size&&(u.size=l.size);break;default:u=typeof l.is=="string"?y.createElement(c,{is:l.is}):y.createElement(c)}}u[ot]=t,u[wt]=l;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)u.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=u;e:switch(Dt(u,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Zn(t)}}return et(t),au(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==l&&Zn(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(o(166));if(e=re.current,qs(t)){if(e=t.stateNode,a=t.memoizedProps,l=null,c=Rt,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}e[ot]=t,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Dp(e.nodeValue,a)),e||pa(t,!0)}else e=qr(e).createTextNode(l),e[ot]=t,t.stateNode=e}return et(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(l=qs(t),a!==null){if(e===null){if(!l)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[ot]=t}else Xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;et(t),e=!1}else a=mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Zt(t),t):(Zt(t),null);if((t.flags&128)!==0)throw Error(o(558))}return et(t),null;case 13:if(l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=qs(t),l!==null&&l.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[ot]=t}else Xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;et(t),c=!1}else c=mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Zt(t),t):(Zt(t),null)}return Zt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=t.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),u=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(u=l.memoizedState.cachePool.pool),u!==c&&(l.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),xr(t,t.updateQueue),et(t),null);case 4:return ye(),e===null&&wu(t.stateNode.containerInfo),et(t),null;case 10:return Fn(t.type),et(t),null;case 19:if(U(xt),l=t.memoizedState,l===null)return et(t),null;if(c=(t.flags&128)!==0,u=l.rendering,u===null)if(c)Vl(l,!1);else{if(mt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=ar(e),u!==null){for(t.flags|=128,Vl(l,!1),e=u.updateQueue,t.updateQueue=e,xr(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)fm(a,e),a=a.sibling;return ee(xt,xt.current&1|2),De&&Gn(t,l.treeForkCount),t.child}e=e.sibling}l.tail!==null&&Ve()>Sr&&(t.flags|=128,c=!0,Vl(l,!1),t.lanes=4194304)}else{if(!c)if(e=ar(u),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,xr(t,e),Vl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!u.alternate&&!De)return et(t),null}else 2*Ve()-l.renderingStartTime>Sr&&a!==536870912&&(t.flags|=128,c=!0,Vl(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(e=l.last,e!==null?e.sibling=u:t.child=u,l.last=u)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=Ve(),e.sibling=null,a=xt.current,ee(xt,c?a&1|2:a&1),De&&Gn(t,l.treeForkCount),e):(et(t),null);case 22:case 23:return Zt(t),Cc(),l=t.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(et(t),t.subtreeFlags&6&&(t.flags|=8192)):et(t),a=t.updateQueue,a!==null&&xr(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),e!==null&&U(Za),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Fn(yt),et(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function dy(e,t){switch(fc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fn(yt),ye(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Oe(t),null;case 31:if(t.memoizedState!==null){if(Zt(t),t.alternate===null)throw Error(o(340));Xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Zt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return U(xt),null;case 4:return ye(),null;case 10:return Fn(t.type),null;case 22:case 23:return Zt(t),Cc(),e!==null&&U(Za),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fn(yt),null;case 25:return null;default:return null}}function zh(e,t){switch(fc(t),t.tag){case 3:Fn(yt),ye();break;case 26:case 27:case 5:Oe(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&Zt(t);break;case 13:Zt(t);break;case 19:U(xt);break;case 10:Fn(t.type);break;case 22:case 23:Zt(t),Cc(),e!==null&&U(Za);break;case 24:Fn(yt)}}function $l(e,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var c=l.next;a=c;do{if((a.tag&e)===e){l=void 0;var u=a.create,y=a.inst;l=u(),y.destroy=l}a=a.next}while(a!==c)}}catch(j){Ye(t,t.return,j)}}function ja(e,t,a){try{var l=t.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var u=c.next;l=u;do{if((l.tag&e)===e){var y=l.inst,j=y.destroy;if(j!==void 0){y.destroy=void 0,c=t;var D=a,F=j;try{F()}catch(I){Ye(c,D,I)}}}l=l.next}while(l!==u)}}catch(I){Ye(t,t.return,I)}}function Uh(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Mm(t,a)}catch(l){Ye(e,e.return,l)}}}function Hh(e,t,a){a.props=es(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){Ye(e,t,l)}}function Gl(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(c){Ye(e,t,c)}}function Mn(e,t){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(c){Ye(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){Ye(e,t,c)}else a.current=null}function Vh(e){var t=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(c){Ye(e,e.return,c)}}function su(e,t,a){try{var l=e.stateNode;_y(l,e.type,a,t),l[wt]=t}catch(c){Ye(e,e.return,c)}}function $h(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ma(e.type)||e.tag===4}function lu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||$h(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&&Ma(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 iu(e,t,a){var l=e.tag;if(l===5||l===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=Hn));else if(l!==4&&(l===27&&Ma(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(iu(e,t,a),e=e.sibling;e!==null;)iu(e,t,a),e=e.sibling}function gr(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(l===27&&Ma(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(gr(e,t,a),e=e.sibling;e!==null;)gr(e,t,a),e=e.sibling}function Gh(e){var t=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Dt(t,l,a),t[ot]=e,t[wt]=a}catch(u){Ye(e,e.return,u)}}var In=!1,jt=!1,ru=!1,Yh=typeof WeakSet=="function"?WeakSet:Set,kt=null;function my(e,t){if(e=e.containerInfo,ku=zr,e=nm(e),ec(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var c=l.anchorOffset,u=l.focusNode;l=l.focusOffset;try{a.nodeType,u.nodeType}catch{a=null;break e}var y=0,j=-1,D=-1,F=0,I=0,ne=e,Q=null;t:for(;;){for(var Z;ne!==a||c!==0&&ne.nodeType!==3||(j=y+c),ne!==u||l!==0&&ne.nodeType!==3||(D=y+l),ne.nodeType===3&&(y+=ne.nodeValue.length),(Z=ne.firstChild)!==null;)Q=ne,ne=Z;for(;;){if(ne===e)break t;if(Q===a&&++F===c&&(j=y),Q===u&&++I===l&&(D=y),(Z=ne.nextSibling)!==null)break;ne=Q,Q=ne.parentNode}ne=Z}a=j===-1||D===-1?null:{start:j,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Mu={focusedElem:e,selectionRange:a},zr=!1,kt=t;kt!==null;)if(t=kt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,kt=e;else for(;kt!==null;){switch(t=kt,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)c=e[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,a=t,c=u.memoizedProps,u=u.memoizedState,l=a.stateNode;try{var he=es(a.type,c);e=l.getSnapshotBeforeUpdate(he,u),l.__reactInternalSnapshotBeforeUpdate=e}catch(je){Ye(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Tu(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Tu(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,kt=e;break}kt=t.return}}function Fh(e,t,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Pn(e,a),l&4&&$l(5,a);break;case 1:if(Pn(e,a),l&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(y){Ye(a,a.return,y)}else{var c=es(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Ye(a,a.return,y)}}l&64&&Uh(a),l&512&&Gl(a,a.return);break;case 3:if(Pn(e,a),l&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{Mm(e,t)}catch(y){Ye(a,a.return,y)}}break;case 27:t===null&&l&4&&Gh(a);case 26:case 5:Pn(e,a),t===null&&l&4&&Vh(a),l&512&&Gl(a,a.return);break;case 12:Pn(e,a);break;case 31:Pn(e,a),l&4&&Kh(e,a);break;case 13:Pn(e,a),l&4&&Zh(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=jy.bind(null,a),$y(e,a))));break;case 22:if(l=a.memoizedState!==null||In,!l){t=t!==null&&t.memoizedState!==null||jt,c=In;var u=jt;In=l,(jt=t)&&!u?Wn(e,a,(a.subtreeFlags&8772)!==0):Pn(e,a),In=c,jt=u}break;case 30:break;default:Pn(e,a)}}function Xh(e){var t=e.alternate;t!==null&&(e.alternate=null,Xh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Lo(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var at=null,Ut=!1;function Jn(e,t,a){for(a=a.child;a!==null;)Qh(e,t,a),a=a.sibling}function Qh(e,t,a){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(On,a)}catch{}switch(a.tag){case 26:jt||Mn(a,t),Jn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:jt||Mn(a,t);var l=at,c=Ut;Ma(a.type)&&(at=a.stateNode,Ut=!1),Jn(e,t,a),Pl(a.stateNode),at=l,Ut=c;break;case 5:jt||Mn(a,t);case 6:if(l=at,c=Ut,at=null,Jn(e,t,a),at=l,Ut=c,at!==null)if(Ut)try{(at.nodeType===9?at.body:at.nodeName==="HTML"?at.ownerDocument.body:at).removeChild(a.stateNode)}catch(u){Ye(a,t,u)}else try{at.removeChild(a.stateNode)}catch(u){Ye(a,t,u)}break;case 18:at!==null&&(Ut?(e=at,Up(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ps(e)):Up(at,a.stateNode));break;case 4:l=at,c=Ut,at=a.stateNode.containerInfo,Ut=!0,Jn(e,t,a),at=l,Ut=c;break;case 0:case 11:case 14:case 15:ja(2,a,t),jt||ja(4,a,t),Jn(e,t,a);break;case 1:jt||(Mn(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Hh(a,t,l)),Jn(e,t,a);break;case 21:Jn(e,t,a);break;case 22:jt=(l=jt)||a.memoizedState!==null,Jn(e,t,a),jt=l;break;default:Jn(e,t,a)}}function Kh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ps(e)}catch(a){Ye(t,t.return,a)}}}function Zh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ps(e)}catch(a){Ye(t,t.return,a)}}function hy(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Yh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Yh),t;default:throw Error(o(435,e.tag))}}function vr(e,t){var a=hy(e);t.forEach(function(l){if(!a.has(l)){a.add(l);var c=Ay.bind(null,e,l);l.then(c,c)}})}function Ht(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var c=a[l],u=e,y=t,j=y;e:for(;j!==null;){switch(j.tag){case 27:if(Ma(j.type)){at=j.stateNode,Ut=!1;break e}break;case 5:at=j.stateNode,Ut=!1;break e;case 3:case 4:at=j.stateNode.containerInfo,Ut=!0;break e}j=j.return}if(at===null)throw Error(o(160));Qh(u,y,c),at=null,Ut=!1,u=c.alternate,u!==null&&(u.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Ih(t,e),t=t.sibling}var yn=null;function Ih(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ht(t,e),Vt(e),l&4&&(ja(3,e,e.return),$l(3,e),ja(5,e,e.return));break;case 1:Ht(t,e),Vt(e),l&512&&(jt||a===null||Mn(a,a.return)),l&64&&In&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var c=yn;if(Ht(t,e),Vt(e),l&512&&(jt||a===null||Mn(a,a.return)),l&4){var u=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,c=c.ownerDocument||c;t:switch(l){case"title":u=c.getElementsByTagName("title")[0],(!u||u[xl]||u[ot]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=c.createElement(l),c.head.insertBefore(u,c.querySelector("head > title"))),Dt(u,l,a),u[ot]=e,Et(u),l=u;break e;case"link":var y=Ip("link","href",c).get(l+(a.href||""));if(y){for(var j=0;j<y.length;j++)if(u=y[j],u.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&u.getAttribute("rel")===(a.rel==null?null:a.rel)&&u.getAttribute("title")===(a.title==null?null:a.title)&&u.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(j,1);break t}}u=c.createElement(l),Dt(u,l,a),c.head.appendChild(u);break;case"meta":if(y=Ip("meta","content",c).get(l+(a.content||""))){for(j=0;j<y.length;j++)if(u=y[j],u.getAttribute("content")===(a.content==null?null:""+a.content)&&u.getAttribute("name")===(a.name==null?null:a.name)&&u.getAttribute("property")===(a.property==null?null:a.property)&&u.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&u.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(j,1);break t}}u=c.createElement(l),Dt(u,l,a),c.head.appendChild(u);break;default:throw Error(o(468,l))}u[ot]=e,Et(u),l=u}e.stateNode=l}else Jp(c,e.type,e.stateNode);else e.stateNode=Zp(c,l,e.memoizedProps);else u!==l?(u===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):u.count--,l===null?Jp(c,e.type,e.stateNode):Zp(c,l,e.memoizedProps)):l===null&&e.stateNode!==null&&su(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ht(t,e),Vt(e),l&512&&(jt||a===null||Mn(a,a.return)),a!==null&&l&4&&su(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ht(t,e),Vt(e),l&512&&(jt||a===null||Mn(a,a.return)),e.flags&32){c=e.stateNode;try{Ss(c,"")}catch(he){Ye(e,e.return,he)}}l&4&&e.stateNode!=null&&(c=e.memoizedProps,su(e,c,a!==null?a.memoizedProps:c)),l&1024&&(ru=!0);break;case 6:if(Ht(t,e),Vt(e),l&4){if(e.stateNode===null)throw Error(o(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(he){Ye(e,e.return,he)}}break;case 3:if(_r=null,c=yn,yn=Tr(t.containerInfo),Ht(t,e),yn=c,Vt(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ps(t.containerInfo)}catch(he){Ye(e,e.return,he)}ru&&(ru=!1,Jh(e));break;case 4:l=yn,yn=Tr(e.stateNode.containerInfo),Ht(t,e),Vt(e),yn=l;break;case 12:Ht(t,e),Vt(e);break;case 31:Ht(t,e),Vt(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,vr(e,l)));break;case 13:Ht(t,e),Vt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(br=Ve()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,vr(e,l)));break;case 22:c=e.memoizedState!==null;var D=a!==null&&a.memoizedState!==null,F=In,I=jt;if(In=F||c,jt=I||D,Ht(t,e),jt=I,In=F,Vt(e),l&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||D||In||jt||ts(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){D=a=t;try{if(u=D.stateNode,c)y=u.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{j=D.stateNode;var ne=D.memoizedProps.style,Q=ne!=null&&ne.hasOwnProperty("display")?ne.display:null;j.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(he){Ye(D,D.return,he)}}}else if(t.tag===6){if(a===null){D=t;try{D.stateNode.nodeValue=c?"":D.memoizedProps}catch(he){Ye(D,D.return,he)}}}else if(t.tag===18){if(a===null){D=t;try{var Z=D.stateNode;c?Hp(Z,!0):Hp(D.stateNode,!1)}catch(he){Ye(D,D.return,he)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,vr(e,a))));break;case 19:Ht(t,e),Vt(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,vr(e,l)));break;case 30:break;case 21:break;default:Ht(t,e),Vt(e)}}function Vt(e){var t=e.flags;if(t&2){try{for(var a,l=e.return;l!==null;){if($h(l)){a=l;break}l=l.return}if(a==null)throw Error(o(160));switch(a.tag){case 27:var c=a.stateNode,u=lu(e);gr(e,u,c);break;case 5:var y=a.stateNode;a.flags&32&&(Ss(y,""),a.flags&=-33);var j=lu(e);gr(e,j,y);break;case 3:case 4:var D=a.stateNode.containerInfo,F=lu(e);iu(e,F,D);break;default:throw Error(o(161))}}catch(I){Ye(e,e.return,I)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Jh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Jh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Pn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Fh(e,t.alternate,t),t=t.sibling}function ts(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ja(4,t,t.return),ts(t);break;case 1:Mn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Hh(t,t.return,a),ts(t);break;case 27:Pl(t.stateNode);case 26:case 5:Mn(t,t.return),ts(t);break;case 22:t.memoizedState===null&&ts(t);break;case 30:ts(t);break;default:ts(t)}e=e.sibling}}function Wn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,c=e,u=t,y=u.flags;switch(u.tag){case 0:case 11:case 15:Wn(c,u,a),$l(4,u);break;case 1:if(Wn(c,u,a),l=u,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(F){Ye(l,l.return,F)}if(l=u,c=l.updateQueue,c!==null){var j=l.stateNode;try{var D=c.shared.hiddenCallbacks;if(D!==null)for(c.shared.hiddenCallbacks=null,c=0;c<D.length;c++)km(D[c],j)}catch(F){Ye(l,l.return,F)}}a&&y&64&&Uh(u),Gl(u,u.return);break;case 27:Gh(u);case 26:case 5:Wn(c,u,a),a&&l===null&&y&4&&Vh(u),Gl(u,u.return);break;case 12:Wn(c,u,a);break;case 31:Wn(c,u,a),a&&y&4&&Kh(c,u);break;case 13:Wn(c,u,a),a&&y&4&&Zh(c,u);break;case 22:u.memoizedState===null&&Wn(c,u,a),Gl(u,u.return);break;case 30:break;default:Wn(c,u,a)}t=t.sibling}}function ou(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&&Ml(a))}function cu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ml(e))}function bn(e,t,a,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ph(e,t,a,l),t=t.sibling}function Ph(e,t,a,l){var c=t.flags;switch(t.tag){case 0:case 11:case 15:bn(e,t,a,l),c&2048&&$l(9,t);break;case 1:bn(e,t,a,l);break;case 3:bn(e,t,a,l),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ml(e)));break;case 12:if(c&2048){bn(e,t,a,l),e=t.stateNode;try{var u=t.memoizedProps,y=u.id,j=u.onPostCommit;typeof j=="function"&&j(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(D){Ye(t,t.return,D)}}else bn(e,t,a,l);break;case 31:bn(e,t,a,l);break;case 13:bn(e,t,a,l);break;case 23:break;case 22:u=t.stateNode,y=t.alternate,t.memoizedState!==null?u._visibility&2?bn(e,t,a,l):Yl(e,t):u._visibility&2?bn(e,t,a,l):(u._visibility|=2,Vs(e,t,a,l,(t.subtreeFlags&10256)!==0||!1)),c&2048&&ou(y,t);break;case 24:bn(e,t,a,l),c&2048&&cu(t.alternate,t);break;default:bn(e,t,a,l)}}function Vs(e,t,a,l,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,y=t,j=a,D=l,F=y.flags;switch(y.tag){case 0:case 11:case 15:Vs(u,y,j,D,c),$l(8,y);break;case 23:break;case 22:var I=y.stateNode;y.memoizedState!==null?I._visibility&2?Vs(u,y,j,D,c):Yl(u,y):(I._visibility|=2,Vs(u,y,j,D,c)),c&&F&2048&&ou(y.alternate,y);break;case 24:Vs(u,y,j,D,c),c&&F&2048&&cu(y.alternate,y);break;default:Vs(u,y,j,D,c)}t=t.sibling}}function Yl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,l=t,c=l.flags;switch(l.tag){case 22:Yl(a,l),c&2048&&ou(l.alternate,l);break;case 24:Yl(a,l),c&2048&&cu(l.alternate,l);break;default:Yl(a,l)}t=t.sibling}}var Fl=8192;function $s(e,t,a){if(e.subtreeFlags&Fl)for(e=e.child;e!==null;)Wh(e,t,a),e=e.sibling}function Wh(e,t,a){switch(e.tag){case 26:$s(e,t,a),e.flags&Fl&&e.memoizedState!==null&&eb(a,yn,e.memoizedState,e.memoizedProps);break;case 5:$s(e,t,a);break;case 3:case 4:var l=yn;yn=Tr(e.stateNode.containerInfo),$s(e,t,a),yn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=Fl,Fl=16777216,$s(e,t,a),Fl=l):$s(e,t,a));break;default:$s(e,t,a)}}function ep(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 Xl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];kt=l,np(l,e)}ep(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)tp(e),e=e.sibling}function tp(e){switch(e.tag){case 0:case 11:case 15:Xl(e),e.flags&2048&&ja(9,e,e.return);break;case 3:Xl(e);break;case 12:Xl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,yr(e)):Xl(e);break;default:Xl(e)}}function yr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];kt=l,np(l,e)}ep(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ja(8,t,t.return),yr(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,yr(t));break;default:yr(t)}e=e.sibling}}function np(e,t){for(;kt!==null;){var a=kt;switch(a.tag){case 0:case 11:case 15:ja(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Ml(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,kt=l;else e:for(a=e;kt!==null;){l=kt;var c=l.sibling,u=l.return;if(Xh(l),l===a){kt=null;break e}if(c!==null){c.return=u,kt=c;break e}kt=u}}}var py={getCacheForType:function(e){var t=qt(yt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return qt(yt).controller.signal}},xy=typeof WeakMap=="function"?WeakMap:Map,Ue=0,Ie=null,Me=null,qe=0,Ge=0,It=null,Aa=!1,Gs=!1,uu=!1,ea=0,mt=0,Na=0,ns=0,fu=0,Jt=0,Ys=0,Ql=null,$t=null,du=!1,br=0,ap=0,Sr=1/0,jr=null,wa=null,Ct=0,Ca=null,Fs=null,ta=0,mu=0,hu=null,sp=null,Kl=0,pu=null;function Pt(){return(Ue&2)!==0&&qe!==0?qe&-qe:T.T!==null?Su():ke()}function lp(){if(Jt===0)if((qe&536870912)===0||De){var e=za;za<<=1,(za&3932160)===0&&(za=262144),Jt=e}else Jt=536870912;return e=Kt.current,e!==null&&(e.flags|=32),Jt}function Gt(e,t,a){(e===Ie&&(Ge===2||Ge===9)||e.cancelPendingCommit!==null)&&(Xs(e,0),Ea(e,qe,Jt,!1)),Ua(e,a),((Ue&2)===0||e!==Ie)&&(e===Ie&&((Ue&2)===0&&(ns|=a),mt===4&&Ea(e,qe,Jt,!1)),Rn(e))}function ip(e,t,a){if((Ue&6)!==0)throw Error(o(327));var l=!a&&(t&127)===0&&(t&e.expiredLanes)===0||Ln(e,t),c=l?yy(e,t):gu(e,t,!0),u=l;do{if(c===0){Gs&&!l&&Ea(e,t,0,!1);break}else{if(a=e.current.alternate,u&&!gy(a)){c=gu(e,t,!1),u=!1;continue}if(c===2){if(u=t,e.errorRecoveryDisabledLanes&u)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var j=e;c=Ql;var D=j.current.memoizedState.isDehydrated;if(D&&(Xs(j,y).flags|=256),y=gu(j,y,!1),y!==2){if(uu&&!D){j.errorRecoveryDisabledLanes|=u,ns|=u,c=4;break e}u=$t,$t=c,u!==null&&($t===null?$t=u:$t.push.apply($t,u))}c=y}if(u=!1,c!==2)continue}}if(c===1){Xs(e,0),Ea(e,t,0,!0);break}e:{switch(l=e,u=c,u){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:Ea(l,t,Jt,!Aa);break e;case 2:$t=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=br+300-Ve(),10<c)){if(Ea(l,t,Jt,!Aa),Cn(l,0,!0)!==0)break e;ta=t,l.timeoutHandle=Lp(rp.bind(null,l,a,$t,jr,du,t,Jt,ns,Ys,Aa,u,"Throttled",-0,0),c);break e}rp(l,a,$t,jr,du,t,Jt,ns,Ys,Aa,u,null,-0,0)}}break}while(!0);Rn(e)}function rp(e,t,a,l,c,u,y,j,D,F,I,ne,Q,Z){if(e.timeoutHandle=-1,ne=t.subtreeFlags,ne&8192||(ne&16785408)===16785408){ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Hn},Wh(t,u,ne);var he=(u&62914560)===u?br-Ve():(u&4194048)===u?ap-Ve():0;if(he=tb(ne,he),he!==null){ta=u,e.cancelPendingCommit=he(pp.bind(null,e,t,u,a,l,c,y,j,D,I,ne,null,Q,Z)),Ea(e,u,y,!F);return}}pp(e,t,u,a,l,c,y,j,D)}function gy(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 l=0;l<a.length;l++){var c=a[l],u=c.getSnapshot;c=c.value;try{if(!Xt(u(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ea(e,t,a,l){t&=~fu,t&=~ns,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var c=t;0<c;){var u=31-Mt(c),y=1<<u;l[u]=-1,c&=~y}a!==0&&pl(e,a,t)}function Ar(){return(Ue&6)===0?(Zl(0),!1):!0}function xu(){if(Me!==null){if(Ge===0)var e=Me.return;else e=Me,Yn=Qa=null,Tc(e),Bs=null,ql=0,e=Me;for(;e!==null;)zh(e.alternate,e),e=e.return;Me=null}}function Xs(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Ly(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),ta=0,xu(),Ie=e,Me=a=$n(e.current,null),qe=t,Ge=0,It=null,Aa=!1,Gs=Ln(e,t),uu=!1,Ys=Jt=fu=ns=Na=mt=0,$t=Ql=null,du=!1,(t&8)!==0&&(t|=t&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=t;0<l;){var c=31-Mt(l),u=1<<c;t|=e[c],l&=~u}return ea=t,Yi(),a}function op(e,t){Ce=null,T.H=Ul,t===Os||t===Pi?(t=Nm(),Ge=3):t===bc?(t=Nm(),Ge=4):Ge=t===Kc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,It=t,Me===null&&(mt=1,dr(e,on(t,e.current)))}function cp(){var e=Kt.current;return e===null?!0:(qe&4194048)===qe?dn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===dn:!1}function up(){var e=T.H;return T.H=Ul,e===null?Ul:e}function fp(){var e=T.A;return T.A=py,e}function Nr(){mt=4,Aa||(qe&4194048)!==qe&&Kt.current!==null||(Gs=!0),(Na&134217727)===0&&(ns&134217727)===0||Ie===null||Ea(Ie,qe,Jt,!1)}function gu(e,t,a){var l=Ue;Ue|=2;var c=up(),u=fp();(Ie!==e||qe!==t)&&(jr=null,Xs(e,t)),t=!1;var y=mt;e:do try{if(Ge!==0&&Me!==null){var j=Me,D=It;switch(Ge){case 8:xu(),y=6;break e;case 3:case 2:case 9:case 6:Kt.current===null&&(t=!0);var F=Ge;if(Ge=0,It=null,Qs(e,j,D,F),a&&Gs){y=0;break e}break;default:F=Ge,Ge=0,It=null,Qs(e,j,D,F)}}vy(),y=mt;break}catch(I){op(e,I)}while(!0);return t&&e.shellSuspendCounter++,Yn=Qa=null,Ue=l,T.H=c,T.A=u,Me===null&&(Ie=null,qe=0,Yi()),y}function vy(){for(;Me!==null;)dp(Me)}function yy(e,t){var a=Ue;Ue|=2;var l=up(),c=fp();Ie!==e||qe!==t?(jr=null,Sr=Ve()+500,Xs(e,t)):Gs=Ln(e,t);e:do try{if(Ge!==0&&Me!==null){t=Me;var u=It;t:switch(Ge){case 1:Ge=0,It=null,Qs(e,t,u,1);break;case 2:case 9:if(jm(u)){Ge=0,It=null,mp(t);break}t=function(){Ge!==2&&Ge!==9||Ie!==e||(Ge=7),Rn(e)},u.then(t,t);break e;case 3:Ge=7;break e;case 4:Ge=5;break e;case 7:jm(u)?(Ge=0,It=null,mp(t)):(Ge=0,It=null,Qs(e,t,u,7));break;case 5:var y=null;switch(Me.tag){case 26:y=Me.memoizedState;case 5:case 27:var j=Me;if(y?Pp(y):j.stateNode.complete){Ge=0,It=null;var D=j.sibling;if(D!==null)Me=D;else{var F=j.return;F!==null?(Me=F,wr(F)):Me=null}break t}}Ge=0,It=null,Qs(e,t,u,5);break;case 6:Ge=0,It=null,Qs(e,t,u,6);break;case 8:xu(),mt=6;break e;default:throw Error(o(462))}}by();break}catch(I){op(e,I)}while(!0);return Yn=Qa=null,T.H=l,T.A=c,Ue=a,Me!==null?0:(Ie=null,qe=0,Yi(),mt)}function by(){for(;Me!==null&&!Ne();)dp(Me)}function dp(e){var t=Bh(e.alternate,e,ea);e.memoizedProps=e.pendingProps,t===null?wr(e):Me=t}function mp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Rh(a,t,t.pendingProps,t.type,void 0,qe);break;case 11:t=Rh(a,t,t.pendingProps,t.type.render,t.ref,qe);break;case 5:Tc(t);default:zh(a,t),t=Me=fm(t,ea),t=Bh(a,t,ea)}e.memoizedProps=e.pendingProps,t===null?wr(e):Me=t}function Qs(e,t,a,l){Yn=Qa=null,Tc(t),Bs=null,ql=0;var c=t.return;try{if(oy(e,c,t,a,qe)){mt=1,dr(e,on(a,e.current)),Me=null;return}}catch(u){if(c!==null)throw Me=c,u;mt=1,dr(e,on(a,e.current)),Me=null;return}t.flags&32768?(De||l===1?e=!0:Gs||(qe&536870912)!==0?e=!1:(Aa=e=!0,(l===2||l===9||l===3||l===6)&&(l=Kt.current,l!==null&&l.tag===13&&(l.flags|=16384))),hp(t,e)):wr(t)}function wr(e){var t=e;do{if((t.flags&32768)!==0){hp(t,Aa);return}e=t.return;var a=fy(t.alternate,t,ea);if(a!==null){Me=a;return}if(t=t.sibling,t!==null){Me=t;return}Me=t=e}while(t!==null);mt===0&&(mt=5)}function hp(e,t){do{var a=dy(e.alternate,e);if(a!==null){a.flags&=32767,Me=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Me=e;return}Me=e=a}while(e!==null);mt=6,Me=null}function pp(e,t,a,l,c,u,y,j,D){e.cancelPendingCommit=null;do Cr();while(Ct!==0);if((Ue&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(u=t.lanes|t.childLanes,u|=lc,Bo(e,a,u,y,j,D),e===Ie&&(Me=Ie=null,qe=0),Fs=t,Ca=e,ta=a,mu=u,hu=c,sp=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Ny(it,function(){return bp(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=T.T,T.T=null,c=$.p,$.p=2,y=Ue,Ue|=4;try{my(e,t,a)}finally{Ue=y,$.p=c,T.T=l}}Ct=1,xp(),gp(),vp()}}function xp(){if(Ct===1){Ct=0;var e=Ca,t=Fs,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=T.T,T.T=null;var l=$.p;$.p=2;var c=Ue;Ue|=4;try{Ih(t,e);var u=Mu,y=nm(e.containerInfo),j=u.focusedElem,D=u.selectionRange;if(y!==j&&j&&j.ownerDocument&&tm(j.ownerDocument.documentElement,j)){if(D!==null&&ec(j)){var F=D.start,I=D.end;if(I===void 0&&(I=F),"selectionStart"in j)j.selectionStart=F,j.selectionEnd=Math.min(I,j.value.length);else{var ne=j.ownerDocument||document,Q=ne&&ne.defaultView||window;if(Q.getSelection){var Z=Q.getSelection(),he=j.textContent.length,je=Math.min(D.start,he),Ke=D.end===void 0?je:Math.min(D.end,he);!Z.extend&&je>Ke&&(y=Ke,Ke=je,je=y);var L=em(j,je),O=em(j,Ke);if(L&&O&&(Z.rangeCount!==1||Z.anchorNode!==L.node||Z.anchorOffset!==L.offset||Z.focusNode!==O.node||Z.focusOffset!==O.offset)){var G=ne.createRange();G.setStart(L.node,L.offset),Z.removeAllRanges(),je>Ke?(Z.addRange(G),Z.extend(O.node,O.offset)):(G.setEnd(O.node,O.offset),Z.addRange(G))}}}}for(ne=[],Z=j;Z=Z.parentNode;)Z.nodeType===1&&ne.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<ne.length;j++){var W=ne[j];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}zr=!!ku,Mu=ku=null}finally{Ue=c,$.p=l,T.T=a}}e.current=t,Ct=2}}function gp(){if(Ct===2){Ct=0;var e=Ca,t=Fs,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=T.T,T.T=null;var l=$.p;$.p=2;var c=Ue;Ue|=4;try{Fh(e,t.alternate,t)}finally{Ue=c,$.p=l,T.T=a}}Ct=3}}function vp(){if(Ct===4||Ct===3){Ct=0,pt();var e=Ca,t=Fs,a=ta,l=sp;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Ct=5:(Ct=0,Fs=Ca=null,yp(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(wa=null),Ze(a),t=t.stateNode,Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(On,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=T.T,c=$.p,$.p=2,T.T=null;try{for(var u=e.onRecoverableError,y=0;y<l.length;y++){var j=l[y];u(j.value,{componentStack:j.stack})}}finally{T.T=t,$.p=c}}(ta&3)!==0&&Cr(),Rn(e),c=e.pendingLanes,(a&261930)!==0&&(c&42)!==0?e===pu?Kl++:(Kl=0,pu=e):Kl=0,Zl(0)}}function yp(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ml(t)))}function Cr(){return xp(),gp(),vp(),bp()}function bp(){if(Ct!==5)return!1;var e=Ca,t=mu;mu=0;var a=Ze(ta),l=T.T,c=$.p;try{$.p=32>a?32:a,T.T=null,a=hu,hu=null;var u=Ca,y=ta;if(Ct=0,Fs=Ca=null,ta=0,(Ue&6)!==0)throw Error(o(331));var j=Ue;if(Ue|=4,tp(u.current),Ph(u,u.current,y,a),Ue=j,Zl(0,!1),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(On,u)}catch{}return!0}finally{$.p=c,T.T=l,yp(e,t)}}function Sp(e,t,a){t=on(a,t),t=Qc(e.stateNode,t,2),e=ya(e,t,2),e!==null&&(Ua(e,2),Rn(e))}function Ye(e,t,a){if(e.tag===3)Sp(e,e,a);else for(;t!==null;){if(t.tag===3){Sp(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(wa===null||!wa.has(l))){e=on(a,e),a=jh(2),l=ya(t,a,2),l!==null&&(Ah(a,l,t,e),Ua(l,2),Rn(l));break}}t=t.return}}function vu(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new xy;var c=new Set;l.set(t,c)}else c=l.get(t),c===void 0&&(c=new Set,l.set(t,c));c.has(a)||(uu=!0,c.add(a),e=Sy.bind(null,e,t,a),t.then(e,e))}function Sy(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,Ie===e&&(qe&a)===a&&(mt===4||mt===3&&(qe&62914560)===qe&&300>Ve()-br?(Ue&2)===0&&Xs(e,0):fu|=a,Ys===qe&&(Ys=0)),Rn(e)}function jp(e,t){t===0&&(t=ml()),e=Ya(e,t),e!==null&&(Ua(e,t),Rn(e))}function jy(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),jp(e,a)}function Ay(e,t){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,c=e.memoizedState;c!==null&&(a=c.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(o(314))}l!==null&&l.delete(t),jp(e,a)}function Ny(e,t){return P(e,t)}var Er=null,Ks=null,yu=!1,kr=!1,bu=!1,ka=0;function Rn(e){e!==Ks&&e.next===null&&(Ks===null?Er=Ks=e:Ks=Ks.next=e),kr=!0,yu||(yu=!0,Cy())}function Zl(e,t){if(!bu&&kr){bu=!0;do for(var a=!1,l=Er;l!==null;){if(e!==0){var c=l.pendingLanes;if(c===0)var u=0;else{var y=l.suspendedLanes,j=l.pingedLanes;u=(1<<31-Mt(42|e)+1)-1,u&=c&~(y&~j),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(a=!0,Cp(l,u))}else u=qe,u=Cn(l,l===Ie?u:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(u&3)===0||Ln(l,u)||(a=!0,Cp(l,u));l=l.next}while(a);bu=!1}}function wy(){Ap()}function Ap(){kr=yu=!1;var e=0;ka!==0&&By()&&(e=ka);for(var t=Ve(),a=null,l=Er;l!==null;){var c=l.next,u=Np(l,t);u===0?(l.next=null,a===null?Er=c:a.next=c,c===null&&(Ks=a)):(a=l,(e!==0||(u&3)!==0)&&(kr=!0)),l=c}Ct!==0&&Ct!==5||Zl(e),ka!==0&&(ka=0)}function Np(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,c=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var y=31-Mt(u),j=1<<y,D=c[y];D===-1?((j&a)===0||(j&l)!==0)&&(c[y]=ps(j,t)):D<=t&&(e.expiredLanes|=j),u&=~j}if(t=Ie,a=qe,a=Cn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===t&&(Ge===2||Ge===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&fe(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||Ln(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(l!==null&&fe(l),Ze(a)){case 2:case 8:a=Bt;break;case 32:a=it;break;case 268435456:a=Yt;break;default:a=it}return l=wp.bind(null,e),a=P(a,l),e.callbackPriority=t,e.callbackNode=a,t}return l!==null&&l!==null&&fe(l),e.callbackPriority=2,e.callbackNode=null,2}function wp(e,t){if(Ct!==0&&Ct!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Cr()&&e.callbackNode!==a)return null;var l=qe;return l=Cn(e,e===Ie?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(ip(e,l,t),Np(e,Ve()),e.callbackNode!=null&&e.callbackNode===a?wp.bind(null,e):null)}function Cp(e,t){if(Cr())return null;ip(e,t,!0)}function Cy(){zy(function(){(Ue&6)!==0?P(lt,wy):Ap()})}function Su(){if(ka===0){var e=Ds;e===0&&(e=hs,hs<<=1,(hs&261888)===0&&(hs=256)),ka=e}return ka}function Ep(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Bi(""+e)}function kp(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 Ey(e,t,a,l,c){if(t==="submit"&&a&&a.stateNode===c){var u=Ep((c[wt]||null).action),y=l.submitter;y&&(t=(t=y[wt]||null)?Ep(t.formAction):y.getAttribute("formAction"),t!==null&&(u=t,y=null));var j=new Hi("action","action",null,l,c);e.push({event:j,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ka!==0){var D=y?kp(c,y):new FormData(c);Vc(a,{pending:!0,data:D,method:c.method,action:u},null,D)}}else typeof u=="function"&&(j.preventDefault(),D=y?kp(c,y):new FormData(c),Vc(a,{pending:!0,data:D,method:c.method,action:u},u,D))},currentTarget:c}]})}}for(var ju=0;ju<sc.length;ju++){var Au=sc[ju],ky=Au.toLowerCase(),My=Au[0].toUpperCase()+Au.slice(1);vn(ky,"on"+My)}vn(lm,"onAnimationEnd"),vn(im,"onAnimationIteration"),vn(rm,"onAnimationStart"),vn("dblclick","onDoubleClick"),vn("focusin","onFocus"),vn("focusout","onBlur"),vn(Fv,"onTransitionRun"),vn(Xv,"onTransitionStart"),vn(Qv,"onTransitionCancel"),vn(om,"onTransitionEnd"),ys("onMouseEnter",["mouseout","mouseover"]),ys("onMouseLeave",["mouseout","mouseover"]),ys("onPointerEnter",["pointerout","pointerover"]),ys("onPointerLeave",["pointerout","pointerover"]),Ha("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ha("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ha("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ha("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ha("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ha("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Il="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ry=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Il));function Mp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],c=l.event;l=l.listeners;e:{var u=void 0;if(t)for(var y=l.length-1;0<=y;y--){var j=l[y],D=j.instance,F=j.currentTarget;if(j=j.listener,D!==u&&c.isPropagationStopped())break e;u=j,c.currentTarget=F;try{u(c)}catch(I){Gi(I)}c.currentTarget=null,u=D}else for(y=0;y<l.length;y++){if(j=l[y],D=j.instance,F=j.currentTarget,j=j.listener,D!==u&&c.isPropagationStopped())break e;u=j,c.currentTarget=F;try{u(c)}catch(I){Gi(I)}c.currentTarget=null,u=D}}}}function Re(e,t){var a=t[zn];a===void 0&&(a=t[zn]=new Set);var l=e+"__bubble";a.has(l)||(Rp(t,e,2,!1),a.add(l))}function Nu(e,t,a){var l=0;t&&(l|=4),Rp(a,e,l,t)}var Mr="_reactListening"+Math.random().toString(36).slice(2);function wu(e){if(!e[Mr]){e[Mr]=!0,Ad.forEach(function(a){a!=="selectionchange"&&(Ry.has(a)||Nu(a,!1,e),Nu(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Mr]||(t[Mr]=!0,Nu("selectionchange",!1,t))}}function Rp(e,t,a,l){switch(l0(t)){case 2:var c=sb;break;case 8:c=lb;break;default:c=Hu}a=c.bind(null,t,a,e),c=void 0,!Fo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),l?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 Cu(e,t,a,l,c){var u=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var y=l.tag;if(y===3||y===4){var j=l.stateNode.containerInfo;if(j===c)break;if(y===4)for(y=l.return;y!==null;){var D=y.tag;if((D===3||D===4)&&y.stateNode.containerInfo===c)return;y=y.return}for(;j!==null;){if(y=xs(j),y===null)return;if(D=y.tag,D===5||D===6||D===26||D===27){l=u=y;continue e}j=j.parentNode}}l=l.return}Od(function(){var F=u,I=Go(a),ne=[];e:{var Q=cm.get(e);if(Q!==void 0){var Z=Hi,he=e;switch(e){case"keypress":if(zi(a)===0)break e;case"keydown":case"keyup":Z=Av;break;case"focusin":he="focus",Z=Zo;break;case"focusout":he="blur",Z=Zo;break;case"beforeblur":case"afterblur":Z=Zo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=zd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=fv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=Cv;break;case lm:case im:case rm:Z=hv;break;case om:Z=kv;break;case"scroll":case"scrollend":Z=cv;break;case"wheel":Z=Rv;break;case"copy":case"cut":case"paste":Z=xv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=Hd;break;case"toggle":case"beforetoggle":Z=Tv}var je=(t&4)!==0,Ke=!je&&(e==="scroll"||e==="scrollend"),L=je?Q!==null?Q+"Capture":null:Q;je=[];for(var O=F,G;O!==null;){var W=O;if(G=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||G===null||L===null||(W=vl(O,L),W!=null&&je.push(Jl(O,W,G))),Ke)break;O=O.return}0<je.length&&(Q=new Z(Q,he,null,a,I),ne.push({event:Q,listeners:je}))}}if((t&7)===0){e:{if(Q=e==="mouseover"||e==="pointerover",Z=e==="mouseout"||e==="pointerout",Q&&a!==$o&&(he=a.relatedTarget||a.fromElement)&&(xs(he)||he[nt]))break e;if((Z||Q)&&(Q=I.window===I?I:(Q=I.ownerDocument)?Q.defaultView||Q.parentWindow:window,Z?(he=a.relatedTarget||a.toElement,Z=F,he=he?xs(he):null,he!==null&&(Ke=d(he),je=he.tag,he!==Ke||je!==5&&je!==27&&je!==6)&&(he=null)):(Z=null,he=F),Z!==he)){if(je=zd,W="onMouseLeave",L="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(je=Hd,W="onPointerLeave",L="onPointerEnter",O="pointer"),Ke=Z==null?Q:gl(Z),G=he==null?Q:gl(he),Q=new je(W,O+"leave",Z,a,I),Q.target=Ke,Q.relatedTarget=G,W=null,xs(I)===F&&(je=new je(L,O+"enter",he,a,I),je.target=G,je.relatedTarget=Ke,W=je),Ke=W,Z&&he)t:{for(je=qy,L=Z,O=he,G=0,W=L;W;W=je(W))G++;W=0;for(var Se=O;Se;Se=je(Se))W++;for(;0<G-W;)L=je(L),G--;for(;0<W-G;)O=je(O),W--;for(;G--;){if(L===O||O!==null&&L===O.alternate){je=L;break t}L=je(L),O=je(O)}je=null}else je=null;Z!==null&&qp(ne,Q,Z,je,!1),he!==null&&Ke!==null&&qp(ne,Ke,he,je,!0)}}e:{if(Q=F?gl(F):window,Z=Q.nodeName&&Q.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Q.type==="file")var Be=Kd;else if(Xd(Q))if(Zd)Be=$v;else{Be=Hv;var ge=Uv}else Z=Q.nodeName,!Z||Z.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?F&&Vo(F.elementType)&&(Be=Kd):Be=Vv;if(Be&&(Be=Be(e,F))){Qd(ne,Be,a,I);break e}ge&&ge(e,Q,F),e==="focusout"&&F&&Q.type==="number"&&F.memoizedProps.value!=null&&Ho(Q,"number",Q.value)}switch(ge=F?gl(F):window,e){case"focusin":(Xd(ge)||ge.contentEditable==="true")&&(ws=ge,tc=F,Cl=null);break;case"focusout":Cl=tc=ws=null;break;case"mousedown":nc=!0;break;case"contextmenu":case"mouseup":case"dragend":nc=!1,am(ne,a,I);break;case"selectionchange":if(Yv)break;case"keydown":case"keyup":am(ne,a,I)}var Ee;if(Jo)e:{switch(e){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else Ns?Yd(e,a)&&(Te="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Te="onCompositionStart");Te&&(Vd&&a.locale!=="ko"&&(Ns||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&Ns&&(Ee=Bd()):(da=I,Xo="value"in da?da.value:da.textContent,Ns=!0)),ge=Rr(F,Te),0<ge.length&&(Te=new Ud(Te,e,null,a,I),ne.push({event:Te,listeners:ge}),Ee?Te.data=Ee:(Ee=Fd(a),Ee!==null&&(Te.data=Ee)))),(Ee=_v?Ov(e,a):Bv(e,a))&&(Te=Rr(F,"onBeforeInput"),0<Te.length&&(ge=new Ud("onBeforeInput","beforeinput",null,a,I),ne.push({event:ge,listeners:Te}),ge.data=Ee)),Ey(ne,e,F,a,I)}Mp(ne,t)})}function Jl(e,t,a){return{instance:e,listener:t,currentTarget:a}}function Rr(e,t){for(var a=t+"Capture",l=[];e!==null;){var c=e,u=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||u===null||(c=vl(e,a),c!=null&&l.unshift(Jl(e,c,u)),c=vl(e,t),c!=null&&l.push(Jl(e,c,u))),e.tag===3)return l;e=e.return}return[]}function qy(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function qp(e,t,a,l,c){for(var u=t._reactName,y=[];a!==null&&a!==l;){var j=a,D=j.alternate,F=j.stateNode;if(j=j.tag,D!==null&&D===l)break;j!==5&&j!==26&&j!==27||F===null||(D=F,c?(F=vl(a,u),F!=null&&y.unshift(Jl(a,F,D))):c||(F=vl(a,u),F!=null&&y.push(Jl(a,F,D)))),a=a.return}y.length!==0&&e.push({event:t,listeners:y})}var Ty=/\r\n?/g,Dy=/\u0000|\uFFFD/g;function Tp(e){return(typeof e=="string"?e:""+e).replace(Ty,`
|
||
`).replace(Dy,"")}function Dp(e,t){return t=Tp(t),Tp(e)===t}function Qe(e,t,a,l,c,u){switch(a){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||Ss(e,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&Ss(e,""+l);break;case"className":_i(e,"class",l);break;case"tabIndex":_i(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":_i(e,a,l);break;case"style":Dd(e,l,u);break;case"data":if(t!=="object"){_i(e,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Bi(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(a==="formAction"?(t!=="input"&&Qe(e,t,"name",c.name,c,null),Qe(e,t,"formEncType",c.formEncType,c,null),Qe(e,t,"formMethod",c.formMethod,c,null),Qe(e,t,"formTarget",c.formTarget,c,null)):(Qe(e,t,"encType",c.encType,c,null),Qe(e,t,"method",c.method,c,null),Qe(e,t,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Bi(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=Hn);break;case"onScroll":l!=null&&Re("scroll",e);break;case"onScrollEnd":l!=null&&Re("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Bi(""+l),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":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):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":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Re("beforetoggle",e),Re("toggle",e),Di(e,"popover",l);break;case"xlinkActuate":Un(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Un(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Un(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Un(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Un(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Un(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Un(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Un(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Un(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Di(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=rv.get(a)||a,Di(e,a,l))}}function Eu(e,t,a,l,c,u){switch(a){case"style":Dd(e,l,u);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=a}}break;case"children":typeof l=="string"?Ss(e,l):(typeof l=="number"||typeof l=="bigint")&&Ss(e,""+l);break;case"onScroll":l!=null&&Re("scroll",e);break;case"onScrollEnd":l!=null&&Re("scrollend",e);break;case"onClick":l!=null&&(e.onclick=Hn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Nd.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),u=e[wt]||null,u=u!=null?u[a]:null,typeof u=="function"&&e.removeEventListener(t,u,c),typeof l=="function")){typeof u!="function"&&u!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,l,c);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Di(e,a,l)}}}function Dt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Re("error",e),Re("load",e);var l=!1,c=!1,u;for(u in a)if(a.hasOwnProperty(u)){var y=a[u];if(y!=null)switch(u){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Qe(e,t,u,y,a,null)}}c&&Qe(e,t,"srcSet",a.srcSet,a,null),l&&Qe(e,t,"src",a.src,a,null);return;case"input":Re("invalid",e);var j=u=y=c=null,D=null,F=null;for(l in a)if(a.hasOwnProperty(l)){var I=a[l];if(I!=null)switch(l){case"name":c=I;break;case"type":y=I;break;case"checked":D=I;break;case"defaultChecked":F=I;break;case"value":u=I;break;case"defaultValue":j=I;break;case"children":case"dangerouslySetInnerHTML":if(I!=null)throw Error(o(137,t));break;default:Qe(e,t,l,I,a,null)}}Md(e,u,j,D,F,y,c,!1);return;case"select":Re("invalid",e),l=y=u=null;for(c in a)if(a.hasOwnProperty(c)&&(j=a[c],j!=null))switch(c){case"value":u=j;break;case"defaultValue":y=j;break;case"multiple":l=j;default:Qe(e,t,c,j,a,null)}t=u,a=y,e.multiple=!!l,t!=null?bs(e,!!l,t,!1):a!=null&&bs(e,!!l,a,!0);return;case"textarea":Re("invalid",e),u=c=l=null;for(y in a)if(a.hasOwnProperty(y)&&(j=a[y],j!=null))switch(y){case"value":l=j;break;case"defaultValue":c=j;break;case"children":u=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(o(91));break;default:Qe(e,t,y,j,a,null)}qd(e,l,c,u);return;case"option":for(D in a)if(a.hasOwnProperty(D)&&(l=a[D],l!=null))switch(D){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Qe(e,t,D,l,a,null)}return;case"dialog":Re("beforetoggle",e),Re("toggle",e),Re("cancel",e),Re("close",e);break;case"iframe":case"object":Re("load",e);break;case"video":case"audio":for(l=0;l<Il.length;l++)Re(Il[l],e);break;case"image":Re("error",e),Re("load",e);break;case"details":Re("toggle",e);break;case"embed":case"source":case"link":Re("error",e),Re("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(F in a)if(a.hasOwnProperty(F)&&(l=a[F],l!=null))switch(F){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Qe(e,t,F,l,a,null)}return;default:if(Vo(t)){for(I in a)a.hasOwnProperty(I)&&(l=a[I],l!==void 0&&Eu(e,t,I,l,a,void 0));return}}for(j in a)a.hasOwnProperty(j)&&(l=a[j],l!=null&&Qe(e,t,j,l,a,null))}function _y(e,t,a,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,u=null,y=null,j=null,D=null,F=null,I=null;for(Z in a){var ne=a[Z];if(a.hasOwnProperty(Z)&&ne!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":D=ne;default:l.hasOwnProperty(Z)||Qe(e,t,Z,null,l,ne)}}for(var Q in l){var Z=l[Q];if(ne=a[Q],l.hasOwnProperty(Q)&&(Z!=null||ne!=null))switch(Q){case"type":u=Z;break;case"name":c=Z;break;case"checked":F=Z;break;case"defaultChecked":I=Z;break;case"value":y=Z;break;case"defaultValue":j=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(o(137,t));break;default:Z!==ne&&Qe(e,t,Q,Z,l,ne)}}Uo(e,y,j,D,F,I,u,c);return;case"select":Z=y=j=Q=null;for(u in a)if(D=a[u],a.hasOwnProperty(u)&&D!=null)switch(u){case"value":break;case"multiple":Z=D;default:l.hasOwnProperty(u)||Qe(e,t,u,null,l,D)}for(c in l)if(u=l[c],D=a[c],l.hasOwnProperty(c)&&(u!=null||D!=null))switch(c){case"value":Q=u;break;case"defaultValue":j=u;break;case"multiple":y=u;default:u!==D&&Qe(e,t,c,u,l,D)}t=j,a=y,l=Z,Q!=null?bs(e,!!a,Q,!1):!!l!=!!a&&(t!=null?bs(e,!!a,t,!0):bs(e,!!a,a?[]:"",!1));return;case"textarea":Z=Q=null;for(j in a)if(c=a[j],a.hasOwnProperty(j)&&c!=null&&!l.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:Qe(e,t,j,null,l,c)}for(y in l)if(c=l[y],u=a[y],l.hasOwnProperty(y)&&(c!=null||u!=null))switch(y){case"value":Q=c;break;case"defaultValue":Z=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==u&&Qe(e,t,y,c,l,u)}Rd(e,Q,Z);return;case"option":for(var he in a)if(Q=a[he],a.hasOwnProperty(he)&&Q!=null&&!l.hasOwnProperty(he))switch(he){case"selected":e.selected=!1;break;default:Qe(e,t,he,null,l,Q)}for(D in l)if(Q=l[D],Z=a[D],l.hasOwnProperty(D)&&Q!==Z&&(Q!=null||Z!=null))switch(D){case"selected":e.selected=Q&&typeof Q!="function"&&typeof Q!="symbol";break;default:Qe(e,t,D,Q,l,Z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var je in a)Q=a[je],a.hasOwnProperty(je)&&Q!=null&&!l.hasOwnProperty(je)&&Qe(e,t,je,null,l,Q);for(F in l)if(Q=l[F],Z=a[F],l.hasOwnProperty(F)&&Q!==Z&&(Q!=null||Z!=null))switch(F){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(o(137,t));break;default:Qe(e,t,F,Q,l,Z)}return;default:if(Vo(t)){for(var Ke in a)Q=a[Ke],a.hasOwnProperty(Ke)&&Q!==void 0&&!l.hasOwnProperty(Ke)&&Eu(e,t,Ke,void 0,l,Q);for(I in l)Q=l[I],Z=a[I],!l.hasOwnProperty(I)||Q===Z||Q===void 0&&Z===void 0||Eu(e,t,I,Q,l,Z);return}}for(var L in a)Q=a[L],a.hasOwnProperty(L)&&Q!=null&&!l.hasOwnProperty(L)&&Qe(e,t,L,null,l,Q);for(ne in l)Q=l[ne],Z=a[ne],!l.hasOwnProperty(ne)||Q===Z||Q==null&&Z==null||Qe(e,t,ne,Q,l,Z)}function _p(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Oy(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var c=a[l],u=c.transferSize,y=c.initiatorType,j=c.duration;if(u&&j&&_p(y)){for(y=0,j=c.responseEnd,l+=1;l<a.length;l++){var D=a[l],F=D.startTime;if(F>j)break;var I=D.transferSize,ne=D.initiatorType;I&&_p(ne)&&(D=D.responseEnd,y+=I*(D<j?1:(j-F)/(D-F)))}if(--l,t+=8*(u+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 ku=null,Mu=null;function qr(e){return e.nodeType===9?e:e.ownerDocument}function Op(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 Bp(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 Ru(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 qu=null;function By(){var e=window.event;return e&&e.type==="popstate"?e===qu?!1:(qu=e,!0):(qu=null,!1)}var Lp=typeof setTimeout=="function"?setTimeout:void 0,Ly=typeof clearTimeout=="function"?clearTimeout:void 0,zp=typeof Promise=="function"?Promise:void 0,zy=typeof queueMicrotask=="function"?queueMicrotask:typeof zp<"u"?function(e){return zp.resolve(null).then(e).catch(Uy)}:Lp;function Uy(e){setTimeout(function(){throw e})}function Ma(e){return e==="head"}function Up(e,t){var a=t,l=0;do{var c=a.nextSibling;if(e.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(c),Ps(t);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Pl(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Pl(a);for(var u=a.firstChild;u;){var y=u.nextSibling,j=u.nodeName;u[xl]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&u.rel.toLowerCase()==="stylesheet"||a.removeChild(u),u=y}}else a==="body"&&Pl(e.ownerDocument.body);a=c}while(a);Ps(t)}function Hp(e,t){var a=e;e=0;do{var l=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||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function Tu(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":Tu(a),Lo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Hy(e,t,a,l){for(;e.nodeType===1;){var c=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[xl])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=mn(e.nextSibling),e===null)break}return null}function Vy(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=mn(e.nextSibling),e===null))return null;return e}function Vp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=mn(e.nextSibling),e===null))return null;return e}function Du(e){return e.data==="$?"||e.data==="$~"}function _u(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function $y(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var l=function(){t(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function mn(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 Ou=null;function $p(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return mn(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Gp(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 Yp(e,t,a){switch(t=qr(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 Pl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Lo(e)}var hn=new Map,Fp=new Set;function Tr(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var na=$.d;$.d={f:Gy,r:Yy,D:Fy,C:Xy,L:Qy,m:Ky,X:Iy,S:Zy,M:Jy};function Gy(){var e=na.f(),t=Ar();return e||t}function Yy(e){var t=gs(e);t!==null&&t.tag===5&&t.type==="form"?oh(t):na.r(e)}var Zs=typeof document>"u"?null:document;function Xp(e,t,a){var l=Zs;if(l&&typeof t=="string"&&t){var c=ln(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Fp.has(c)||(Fp.add(c),e={rel:e,crossOrigin:a,href:t},l.querySelector(c)===null&&(t=l.createElement("link"),Dt(t,"link",e),Et(t),l.head.appendChild(t)))}}function Fy(e){na.D(e),Xp("dns-prefetch",e,null)}function Xy(e,t){na.C(e,t),Xp("preconnect",e,t)}function Qy(e,t,a){na.L(e,t,a);var l=Zs;if(l&&e&&t){var c='link[rel="preload"][as="'+ln(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+ln(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+ln(a.imageSizes)+'"]')):c+='[href="'+ln(e)+'"]';var u=c;switch(t){case"style":u=Is(e);break;case"script":u=Js(e)}hn.has(u)||(e=b({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),hn.set(u,e),l.querySelector(c)!==null||t==="style"&&l.querySelector(Wl(u))||t==="script"&&l.querySelector(ei(u))||(t=l.createElement("link"),Dt(t,"link",e),Et(t),l.head.appendChild(t)))}}function Ky(e,t){na.m(e,t);var a=Zs;if(a&&e){var l=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+ln(l)+'"][href="'+ln(e)+'"]',u=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Js(e)}if(!hn.has(u)&&(e=b({rel:"modulepreload",href:e},t),hn.set(u,e),a.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(ei(u)))return}l=a.createElement("link"),Dt(l,"link",e),Et(l),a.head.appendChild(l)}}}function Zy(e,t,a){na.S(e,t,a);var l=Zs;if(l&&e){var c=vs(l).hoistableStyles,u=Is(e);t=t||"default";var y=c.get(u);if(!y){var j={loading:0,preload:null};if(y=l.querySelector(Wl(u)))j.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},a),(a=hn.get(u))&&Bu(e,a);var D=y=l.createElement("link");Et(D),Dt(D,"link",e),D._p=new Promise(function(F,I){D.onload=F,D.onerror=I}),D.addEventListener("load",function(){j.loading|=1}),D.addEventListener("error",function(){j.loading|=2}),j.loading|=4,Dr(y,t,l)}y={type:"stylesheet",instance:y,count:1,state:j},c.set(u,y)}}}function Iy(e,t){na.X(e,t);var a=Zs;if(a&&e){var l=vs(a).hoistableScripts,c=Js(e),u=l.get(c);u||(u=a.querySelector(ei(c)),u||(e=b({src:e,async:!0},t),(t=hn.get(c))&&Lu(e,t),u=a.createElement("script"),Et(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function Jy(e,t){na.M(e,t);var a=Zs;if(a&&e){var l=vs(a).hoistableScripts,c=Js(e),u=l.get(c);u||(u=a.querySelector(ei(c)),u||(e=b({src:e,async:!0,type:"module"},t),(t=hn.get(c))&&Lu(e,t),u=a.createElement("script"),Et(u),Dt(u,"link",e),a.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},l.set(c,u))}}function Qp(e,t,a,l){var c=(c=re.current)?Tr(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=Is(a.href),a=vs(c).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Is(a.href);var u=vs(c).hoistableStyles,y=u.get(e);if(y||(c=c.ownerDocument||c,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,y),(u=c.querySelector(Wl(e)))&&!u._p&&(y.instance=u,y.state.loading=5),hn.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},hn.set(e,a),u||Py(c,e,a,y.state))),t&&l===null)throw Error(o(528,""));return y}if(t&&l!==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=Js(a),a=vs(c).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Is(e){return'href="'+ln(e)+'"'}function Wl(e){return'link[rel="stylesheet"]['+e+"]"}function Kp(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Py(e,t,a,l){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=e.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),Dt(t,"link",a),Et(t),e.head.appendChild(t))}function Js(e){return'[src="'+ln(e)+'"]'}function ei(e){return"script[async]"+e}function Zp(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=e.querySelector('style[data-href~="'+ln(a.href)+'"]');if(l)return t.instance=l,Et(l),l;var c=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),Et(l),Dt(l,"style",c),Dr(l,a.precedence,e),t.instance=l;case"stylesheet":c=Is(a.href);var u=e.querySelector(Wl(c));if(u)return t.state.loading|=4,t.instance=u,Et(u),u;l=Kp(a),(c=hn.get(c))&&Bu(l,c),u=(e.ownerDocument||e).createElement("link"),Et(u);var y=u;return y._p=new Promise(function(j,D){y.onload=j,y.onerror=D}),Dt(u,"link",l),t.state.loading|=4,Dr(u,a.precedence,e),t.instance=u;case"script":return u=Js(a.src),(c=e.querySelector(ei(u)))?(t.instance=c,Et(c),c):(l=a,(c=hn.get(u))&&(l=b({},a),Lu(l,c)),e=e.ownerDocument||e,c=e.createElement("script"),Et(c),Dt(c,"link",l),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&&(l=t.instance,t.state.loading|=4,Dr(l,a.precedence,e));return t.instance}function Dr(e,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,u=c,y=0;y<l.length;y++){var j=l[y];if(j.dataset.precedence===t)u=j;else if(u!==c)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function Bu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Lu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var _r=null;function Ip(e,t,a){if(_r===null){var l=new Map,c=_r=new Map;c.set(a,l)}else c=_r,l=c.get(a),l||(l=new Map,c.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),c=0;c<a.length;c++){var u=a[c];if(!(u[xl]||u[ot]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var y=u.getAttribute(t)||"";y=e+y;var j=l.get(y);j?j.push(u):l.set(y,[u])}}return l}function Jp(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function Wy(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 Pp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function eb(e,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=Is(l.href),u=t.querySelector(Wl(c));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Or.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=u,Et(u);return}u=t.ownerDocument||t,l=Kp(l),(c=hn.get(c))&&Bu(l,c),u=u.createElement("link"),Et(u);var y=u;y._p=new Promise(function(j,D){y.onload=j,y.onerror=D}),Dt(u,"link",l),a.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Or.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var zu=0;function tb(e,t){return e.stylesheets&&e.count===0&&Lr(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Lr(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&zu===0&&(zu=62500*Oy());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Lr(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>zu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function Or(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Lr(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Br=null;function Lr(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Br=new Map,t.forEach(nb,e),Br=null,Or.call(e))}function nb(e,t){if(!(t.state.loading&4)){var a=Br.get(e);if(a)var l=a.get(null);else{a=new Map,Br.set(e,a);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<c.length;u++){var y=c[u];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(a.set(y.dataset.precedence,y),l=y)}l&&a.set(null,l)}c=t.instance,y=c.getAttribute("data-precedence"),u=a.get(y)||l,u===l&&a.set(null,c),a.set(y,c),this.count++,l=Or.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),u?u.parentNode.insertBefore(c,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var ti={$$typeof:q,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function ab(e,t,a,l,c,u,y,j,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=hl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hl(0),this.hiddenUpdates=hl(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=u,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=D,this.incompleteTransitions=new Map}function Wp(e,t,a,l,c,u,y,j,D,F,I,ne){return e=new ab(e,t,a,y,D,F,I,ne,j),t=1,u===!0&&(t|=24),u=Qt(3,null,null,t),e.current=u,u.stateNode=e,t=gc(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:l,isDehydrated:a,cache:t},Sc(u),e}function e0(e){return e?(e=ks,e):ks}function t0(e,t,a,l,c,u){c=e0(c),l.context===null?l.context=c:l.pendingContext=c,l=va(t),l.payload={element:a},u=u===void 0?null:u,u!==null&&(l.callback=u),a=ya(e,l,t),a!==null&&(Gt(a,e,t),Dl(a,e,t))}function n0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Uu(e,t){n0(e,t),(e=e.alternate)&&n0(e,t)}function a0(e){if(e.tag===13||e.tag===31){var t=Ya(e,67108864);t!==null&&Gt(t,e,67108864),Uu(e,67108864)}}function s0(e){if(e.tag===13||e.tag===31){var t=Pt();t=Fe(t);var a=Ya(e,t);a!==null&&Gt(a,e,t),Uu(e,t)}}var zr=!0;function sb(e,t,a,l){var c=T.T;T.T=null;var u=$.p;try{$.p=2,Hu(e,t,a,l)}finally{$.p=u,T.T=c}}function lb(e,t,a,l){var c=T.T;T.T=null;var u=$.p;try{$.p=8,Hu(e,t,a,l)}finally{$.p=u,T.T=c}}function Hu(e,t,a,l){if(zr){var c=Vu(l);if(c===null)Cu(e,t,l,Ur,a),i0(e,l);else if(rb(c,e,t,a,l))l.stopPropagation();else if(i0(e,l),t&4&&-1<ib.indexOf(e)){for(;c!==null;){var u=gs(c);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var y=Bn(u.pendingLanes);if(y!==0){var j=u;for(j.pendingLanes|=2,j.entangledLanes|=2;y;){var D=1<<31-Mt(y);j.entanglements[1]|=D,y&=~D}Rn(u),(Ue&6)===0&&(Sr=Ve()+500,Zl(0))}}break;case 31:case 13:j=Ya(u,2),j!==null&&Gt(j,u,2),Ar(),Uu(u,2)}if(u=Vu(l),u===null&&Cu(e,t,l,Ur,a),u===c)break;c=u}c!==null&&l.stopPropagation()}else Cu(e,t,l,null,a)}}function Vu(e){return e=Go(e),$u(e)}var Ur=null;function $u(e){if(Ur=null,e=xs(e),e!==null){var t=d(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ur=e,null}function l0(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(st()){case lt:return 2;case Bt:return 8;case it:case ds:return 32;case Yt:return 268435456;default:return 32}default:return 32}}var Gu=!1,Ra=null,qa=null,Ta=null,ni=new Map,ai=new Map,Da=[],ib="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 i0(e,t){switch(e){case"focusin":case"focusout":Ra=null;break;case"dragenter":case"dragleave":qa=null;break;case"mouseover":case"mouseout":Ta=null;break;case"pointerover":case"pointerout":ni.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ai.delete(t.pointerId)}}function si(e,t,a,l,c,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:u,targetContainers:[c]},t!==null&&(t=gs(t),t!==null&&a0(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function rb(e,t,a,l,c){switch(t){case"focusin":return Ra=si(Ra,e,t,a,l,c),!0;case"dragenter":return qa=si(qa,e,t,a,l,c),!0;case"mouseover":return Ta=si(Ta,e,t,a,l,c),!0;case"pointerover":var u=c.pointerId;return ni.set(u,si(ni.get(u)||null,e,t,a,l,c)),!0;case"gotpointercapture":return u=c.pointerId,ai.set(u,si(ai.get(u)||null,e,t,a,l,c)),!0}return!1}function r0(e){var t=xs(e.target);if(t!==null){var a=d(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,$e(e.priority,function(){s0(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,$e(e.priority,function(){s0(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 Hr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Vu(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);$o=l,a.target.dispatchEvent(l),$o=null}else return t=gs(a),t!==null&&a0(t),e.blockedOn=a,!1;t.shift()}return!0}function o0(e,t,a){Hr(e)&&a.delete(t)}function ob(){Gu=!1,Ra!==null&&Hr(Ra)&&(Ra=null),qa!==null&&Hr(qa)&&(qa=null),Ta!==null&&Hr(Ta)&&(Ta=null),ni.forEach(o0),ai.forEach(o0)}function Vr(e,t){e.blockedOn===t&&(e.blockedOn=null,Gu||(Gu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ob)))}var $r=null;function c0(e){$r!==e&&($r=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){$r===e&&($r=null);for(var t=0;t<e.length;t+=3){var a=e[t],l=e[t+1],c=e[t+2];if(typeof l!="function"){if($u(l||a)===null)continue;break}var u=gs(a);u!==null&&(e.splice(t,3),t-=3,Vc(u,{pending:!0,data:c,method:a.method,action:l},l,c))}}))}function Ps(e){function t(D){return Vr(D,e)}Ra!==null&&Vr(Ra,e),qa!==null&&Vr(qa,e),Ta!==null&&Vr(Ta,e),ni.forEach(t),ai.forEach(t);for(var a=0;a<Da.length;a++){var l=Da[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Da.length&&(a=Da[0],a.blockedOn===null);)r0(a),a.blockedOn===null&&Da.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var c=a[l],u=a[l+1],y=c[wt]||null;if(typeof u=="function")y||c0(a);else if(y){var j=null;if(u&&u.hasAttribute("formAction")){if(c=u,y=u[wt]||null)j=y.formAction;else if($u(c)!==null)continue}else j=y.action;typeof j=="function"?a[l+1]=j:(a.splice(l,3),l-=3),c0(a)}}}function u0(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(y){return c=y})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function Yu(e){this._internalRoot=e}Gr.prototype.render=Yu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var a=t.current,l=Pt();t0(a,l,e,t,null,null)},Gr.prototype.unmount=Yu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;t0(e.current,2,null,e,null,null),Ar(),t[nt]=null}};function Gr(e){this._internalRoot=e}Gr.prototype.unstable_scheduleHydration=function(e){if(e){var t=ke();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Da.length&&t!==0&&t<Da[a].priority;a++);Da.splice(a,0,e),a===0&&r0(e)}};var f0=s.version;if(f0!=="19.2.0")throw Error(o(527,f0,"19.2.0"));$.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=g(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var cb={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yr.isDisabled&&Yr.supportsFiber)try{On=Yr.inject(cb),Nt=Yr}catch{}}return ii.createRoot=function(e,t){if(!f(e))throw Error(o(299));var a=!1,l="",c=vh,u=yh,y=bh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=Wp(e,1,!1,null,null,a,l,null,c,u,y,u0),e[nt]=t.current,wu(e),new Yu(t)},ii.hydrateRoot=function(e,t,a){if(!f(e))throw Error(o(299));var l=!1,c="",u=vh,y=yh,j=bh,D=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(u=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(j=a.onRecoverableError),a.formState!==void 0&&(D=a.formState)),t=Wp(e,1,!0,t,a??null,l,c,D,u,y,j,u0),t.context=e0(null),a=t.current,l=Pt(),l=Fe(l),c=va(l),c.callback=null,ya(a,c,l),a=l,t.current.lanes=a,Ua(t,a),Rn(t),e[nt]=t.current,wu(e),new Gr(t)},ii.version="19.2.0",ii}var S0;function bb(){if(S0)return Qu.exports;S0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),Qu.exports=yb(),Qu.exports}var Sb=bb();var j0="popstate";function jb(n={}){function s(o,f){let{pathname:d,search:h,hash:p}=o.location;return jf("",{pathname:d,search:h,hash:p},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function i(o,f){return typeof f=="string"?f:yi(f)}return Nb(s,i,null,n)}function ut(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function Nn(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Ab(){return Math.random().toString(36).substring(2,10)}function A0(n,s){return{usr:n.state,key:n.key,idx:s}}function jf(n,s,i=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?cl(s):s,state:i,key:s&&s.key||o||Ab()}}function yi({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function cl(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function Nb(n,s,i,o={}){let{window:f=document.defaultView,v5Compat:d=!1}=o,h=f.history,p="POP",x=null,g=v();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function v(){return(h.state||{idx:null}).idx}function b(){p="POP";let w=v(),A=w==null?null:w-g;g=w,x&&x({action:p,location:E.location,delta:A})}function S(w,A){p="PUSH";let N=jf(E.location,w,A);g=v()+1;let q=A0(N,g),M=E.createHref(N);try{h.pushState(q,"",M)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;f.location.assign(M)}d&&x&&x({action:p,location:E.location,delta:1})}function k(w,A){p="REPLACE";let N=jf(E.location,w,A);g=v();let q=A0(N,g),M=E.createHref(N);h.replaceState(q,"",M),d&&x&&x({action:p,location:E.location,delta:0})}function C(w){return wb(w)}let E={get action(){return p},get location(){return n(f,h)},listen(w){if(x)throw new Error("A history only accepts one active listener");return f.addEventListener(j0,b),x=w,()=>{f.removeEventListener(j0,b),x=null}},createHref(w){return s(f,w)},createURL:C,encodeLocation(w){let A=C(w);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:S,replace:k,go(w){return h.go(w)}};return E}function wb(n,s=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),ut(i,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:yi(n);return o=o.replace(/ $/,"%20"),!s&&o.startsWith("//")&&(o=i+o),new URL(o,i)}function Cx(n,s,i="/"){return Cb(n,s,i,!1)}function Cb(n,s,i,o){let f=typeof s=="string"?cl(s):s,d=oa(f.pathname||"/",i);if(d==null)return null;let h=Ex(n);Eb(h);let p=null;for(let x=0;p==null&&x<h.length;++x){let g=zb(d);p=Bb(h[x],g,o)}return p}function Ex(n,s=[],i=[],o="",f=!1){let d=(h,p,x=f,g)=>{let v={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:p,route:h};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&x)return;ut(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=ra([o,v.relativePath]),S=i.concat(v);h.children&&h.children.length>0&&(ut(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),Ex(h.children,s,S,b,x)),!(h.path==null&&!h.index)&&s.push({path:b,score:_b(b,h.index),routesMeta:S})};return n.forEach((h,p)=>{if(h.path===""||!h.path?.includes("?"))d(h,p);else for(let x of kx(h.path))d(h,p,!0,x)}),s}function kx(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,f=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return f?[d,""]:[d];let h=kx(o.join("/")),p=[];return p.push(...h.map(x=>x===""?d:[d,x].join("/"))),f&&p.push(...h),p.map(x=>n.startsWith("/")&&x===""?"/":x)}function Eb(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:Ob(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var kb=/^:[\w-]+$/,Mb=3,Rb=2,qb=1,Tb=10,Db=-2,N0=n=>n==="*";function _b(n,s){let i=n.split("/"),o=i.length;return i.some(N0)&&(o+=Db),s&&(o+=Rb),i.filter(f=>!N0(f)).reduce((f,d)=>f+(kb.test(d)?Mb:d===""?qb:Tb),o)}function Ob(n,s){return n.length===s.length&&n.slice(0,-1).every((o,f)=>o===s[f])?n[n.length-1]-s[s.length-1]:0}function Bb(n,s,i=!1){let{routesMeta:o}=n,f={},d="/",h=[];for(let p=0;p<o.length;++p){let x=o[p],g=p===o.length-1,v=d==="/"?s:s.slice(d.length)||"/",b=fo({path:x.relativePath,caseSensitive:x.caseSensitive,end:g},v),S=x.route;if(!b&&g&&i&&!o[o.length-1].route.index&&(b=fo({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!b)return null;Object.assign(f,b.params),h.push({params:f,pathname:ra([d,b.pathname]),pathnameBase:Gb(ra([d,b.pathnameBase])),route:S}),b.pathnameBase!=="/"&&(d=ra([d,b.pathnameBase]))}return h}function fo(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=Lb(n.path,n.caseSensitive,n.end),f=s.match(i);if(!f)return null;let d=f[0],h=d.replace(/(.)\/+$/,"$1"),p=f.slice(1);return{params:o.reduce((g,{paramName:v,isOptional:b},S)=>{if(v==="*"){let C=p[S]||"";h=d.slice(0,d.length-C.length).replace(/(.)\/+$/,"$1")}const k=p[S];return b&&!k?g[v]=void 0:g[v]=(k||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:n}}function Lb(n,s=!1,i=!0){Nn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],f="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,p,x)=>(o.push({paramName:p,isOptional:x!=null}),x?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),f+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?f+="\\/*$":n!==""&&n!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,s?void 0:"i"),o]}function zb(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Nn(!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 oa(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}var Ub=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Hb=n=>Ub.test(n);function Vb(n,s="/"){let{pathname:i,search:o="",hash:f=""}=typeof n=="string"?cl(n):n,d;if(i)if(Hb(i))d=i;else{if(i.includes("//")){let h=i;i=i.replace(/\/\/+/g,"/"),Nn(!1,`Pathnames cannot have embedded double slashes - normalizing ${h} -> ${i}`)}i.startsWith("/")?d=w0(i.substring(1),"/"):d=w0(i,s)}else d=s;return{pathname:d,search:Yb(o),hash:Fb(f)}}function w0(n,s){let i=s.replace(/\/+$/,"").split("/");return n.split("/").forEach(f=>{f===".."?i.length>1&&i.pop():f!=="."&&i.push(f)}),i.length>1?i.join("/"):"/"}function Ju(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function $b(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function Mx(n){let s=$b(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function Rx(n,s,i,o=!1){let f;typeof n=="string"?f=cl(n):(f={...n},ut(!f.pathname||!f.pathname.includes("?"),Ju("?","pathname","search",f)),ut(!f.pathname||!f.pathname.includes("#"),Ju("#","pathname","hash",f)),ut(!f.search||!f.search.includes("#"),Ju("#","search","hash",f)));let d=n===""||f.pathname==="",h=d?"/":f.pathname,p;if(h==null)p=i;else{let b=s.length-1;if(!o&&h.startsWith("..")){let S=h.split("/");for(;S[0]==="..";)S.shift(),b-=1;f.pathname=S.join("/")}p=b>=0?s[b]:"/"}let x=Vb(f,p),g=h&&h!=="/"&&h.endsWith("/"),v=(d||h===".")&&i.endsWith("/");return!x.pathname.endsWith("/")&&(g||v)&&(x.pathname+="/"),x}var ra=n=>n.join("/").replace(/\/\/+/g,"/"),Gb=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Yb=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Fb=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Xb(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 qx=["POST","PUT","PATCH","DELETE"];new Set(qx);var Qb=["GET",...qx];new Set(Qb);var ul=m.createContext(null);ul.displayName="DataRouter";var Ao=m.createContext(null);Ao.displayName="DataRouterState";m.createContext(!1);var Tx=m.createContext({isTransitioning:!1});Tx.displayName="ViewTransition";var Kb=m.createContext(new Map);Kb.displayName="Fetchers";var Zb=m.createContext(null);Zb.displayName="Await";var _n=m.createContext(null);_n.displayName="Navigation";var ki=m.createContext(null);ki.displayName="Location";var ua=m.createContext({outlet:null,matches:[],isDataRoute:!1});ua.displayName="Route";var Vf=m.createContext(null);Vf.displayName="RouteError";function Ib(n,{relative:s}={}){ut(Mi(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=m.useContext(_n),{hash:f,pathname:d,search:h}=Ri(n,{relative:s}),p=d;return i!=="/"&&(p=d==="/"?i:ra([i,d])),o.createHref({pathname:p,search:h,hash:f})}function Mi(){return m.useContext(ki)!=null}function fs(){return ut(Mi(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(ki).location}var Dx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function _x(n){m.useContext(_n).static||m.useLayoutEffect(n)}function Jb(){let{isDataRoute:n}=m.useContext(ua);return n?u1():Pb()}function Pb(){ut(Mi(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(ul),{basename:s,navigator:i}=m.useContext(_n),{matches:o}=m.useContext(ua),{pathname:f}=fs(),d=JSON.stringify(Mx(o)),h=m.useRef(!1);return _x(()=>{h.current=!0}),m.useCallback((x,g={})=>{if(Nn(h.current,Dx),!h.current)return;if(typeof x=="number"){i.go(x);return}let v=Rx(x,JSON.parse(d),f,g.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:ra([s,v.pathname])),(g.replace?i.replace:i.push)(v,g.state,g)},[s,i,d,f,n])}m.createContext(null);function Ri(n,{relative:s}={}){let{matches:i}=m.useContext(ua),{pathname:o}=fs(),f=JSON.stringify(Mx(i));return m.useMemo(()=>Rx(n,JSON.parse(f),o,s==="path"),[n,f,o,s])}function Wb(n,s){return Ox(n,s)}function Ox(n,s,i,o,f){ut(Mi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:d}=m.useContext(_n),{matches:h}=m.useContext(ua),p=h[h.length-1],x=p?p.params:{},g=p?p.pathname:"/",v=p?p.pathnameBase:"/",b=p&&p.route;{let N=b&&b.path||"";Bx(g,!b||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${N}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let S=fs(),k;if(s){let N=typeof s=="string"?cl(s):s;ut(v==="/"||N.pathname?.startsWith(v),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${v}" but pathname "${N.pathname}" was given in the \`location\` prop.`),k=N}else k=S;let C=k.pathname||"/",E=C;if(v!=="/"){let N=v.replace(/^\//,"").split("/");E="/"+C.replace(/^\//,"").split("/").slice(N.length).join("/")}let w=Cx(n,{pathname:E});Nn(b||w!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),Nn(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 "${k.pathname}${k.search}${k.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let A=s1(w&&w.map(N=>Object.assign({},N,{params:Object.assign({},x,N.params),pathname:ra([v,d.encodeLocation?d.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?v:ra([v,d.encodeLocation?d.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),h,i,o,f);return s&&A?m.createElement(ki.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},A):A}function e1(){let n=c1(),s=Xb(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",n),h=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:d},"ErrorBoundary")," or"," ",m.createElement("code",{style:d},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},s),i?m.createElement("pre",{style:f},i):null,h)}var t1=m.createElement(e1,null),n1=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(ua.Provider,{value:this.props.routeContext},m.createElement(Vf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function a1({routeContext:n,match:s,children:i}){let o=m.useContext(ul);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),m.createElement(ua.Provider,{value:n},i)}function s1(n,s=[],i=null,o=null,f=null){if(n==null){if(!i)return null;if(i.errors)n=i.matches;else if(s.length===0&&!i.initialized&&i.matches.length>0)n=i.matches;else return null}let d=n,h=i?.errors;if(h!=null){let v=d.findIndex(b=>b.route.id&&h?.[b.route.id]!==void 0);ut(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),d=d.slice(0,Math.min(d.length,v+1))}let p=!1,x=-1;if(i)for(let v=0;v<d.length;v++){let b=d[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(x=v),b.route.id){let{loaderData:S,errors:k}=i,C=b.route.loader&&!S.hasOwnProperty(b.route.id)&&(!k||k[b.route.id]===void 0);if(b.route.lazy||C){p=!0,x>=0?d=d.slice(0,x+1):d=[d[0]];break}}}let g=i&&o?(v,b)=>{o(v,{location:i.location,params:i.matches?.[0]?.params??{},errorInfo:b})}:void 0;return d.reduceRight((v,b,S)=>{let k,C=!1,E=null,w=null;i&&(k=h&&b.route.id?h[b.route.id]:void 0,E=b.route.errorElement||t1,p&&(x<0&&S===0?(Bx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,w=null):x===S&&(C=!0,w=b.route.hydrateFallbackElement||null)));let A=s.concat(d.slice(0,S+1)),N=()=>{let q;return k?q=E:C?q=w:b.route.Component?q=m.createElement(b.route.Component,null):b.route.element?q=b.route.element:q=v,m.createElement(a1,{match:b,routeContext:{outlet:v,matches:A,isDataRoute:i!=null},children:q})};return i&&(b.route.ErrorBoundary||b.route.errorElement||S===0)?m.createElement(n1,{location:i.location,revalidation:i.revalidation,component:E,error:k,children:N(),routeContext:{outlet:null,matches:A,isDataRoute:!0},onError:g}):N()},null)}function $f(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function l1(n){let s=m.useContext(ul);return ut(s,$f(n)),s}function i1(n){let s=m.useContext(Ao);return ut(s,$f(n)),s}function r1(n){let s=m.useContext(ua);return ut(s,$f(n)),s}function Gf(n){let s=r1(n),i=s.matches[s.matches.length-1];return ut(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function o1(){return Gf("useRouteId")}function c1(){let n=m.useContext(Vf),s=i1("useRouteError"),i=Gf("useRouteError");return n!==void 0?n:s.errors?.[i]}function u1(){let{router:n}=l1("useNavigate"),s=Gf("useNavigate"),i=m.useRef(!1);return _x(()=>{i.current=!0}),m.useCallback(async(f,d={})=>{Nn(i.current,Dx),i.current&&(typeof f=="number"?n.navigate(f):await n.navigate(f,{fromRouteId:s,...d}))},[n,s])}var C0={};function Bx(n,s,i){!s&&!C0[n]&&(C0[n]=!0,Nn(!1,i))}m.memo(f1);function f1({routes:n,future:s,state:i,unstable_onError:o}){return Ox(n,void 0,i,o,s)}function to(n){ut(!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 d1({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:f,static:d=!1}){ut(!Mi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=n.replace(/^\/*/,"/"),p=m.useMemo(()=>({basename:h,navigator:f,static:d,future:{}}),[h,f,d]);typeof i=="string"&&(i=cl(i));let{pathname:x="/",search:g="",hash:v="",state:b=null,key:S="default"}=i,k=m.useMemo(()=>{let C=oa(x,h);return C==null?null:{location:{pathname:C,search:g,hash:v,state:b,key:S},navigationType:o}},[h,x,g,v,b,S,o]);return Nn(k!=null,`<Router basename="${h}"> is not able to match the URL "${x}${g}${v}" because it does not start with the basename, so the <Router> won't render anything.`),k==null?null:m.createElement(_n.Provider,{value:p},m.createElement(ki.Provider,{children:s,value:k}))}function m1({children:n,location:s}){return Wb(Af(n),s)}function Af(n,s=[]){let i=[];return m.Children.forEach(n,(o,f)=>{if(!m.isValidElement(o))return;let d=[...s,f];if(o.type===m.Fragment){i.push.apply(i,Af(o.props.children,d));return}ut(o.type===to,`[${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>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=Af(o.props.children,d)),i.push(h)}),i}var no="get",ao="application/x-www-form-urlencoded";function No(n){return n!=null&&typeof n.tagName=="string"}function h1(n){return No(n)&&n.tagName.toLowerCase()==="button"}function p1(n){return No(n)&&n.tagName.toLowerCase()==="form"}function x1(n){return No(n)&&n.tagName.toLowerCase()==="input"}function g1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function v1(n,s){return n.button===0&&(!s||s==="_self")&&!g1(n)}var Fr=null;function y1(){if(Fr===null)try{new FormData(document.createElement("form"),0),Fr=!1}catch{Fr=!0}return Fr}var b1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Pu(n){return n!=null&&!b1.has(n)?(Nn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ao}"`),null):n}function S1(n,s){let i,o,f,d,h;if(p1(n)){let p=n.getAttribute("action");o=p?oa(p,s):null,i=n.getAttribute("method")||no,f=Pu(n.getAttribute("enctype"))||ao,d=new FormData(n)}else if(h1(n)||x1(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?oa(x,s):null,i=n.getAttribute("formmethod")||p.getAttribute("method")||no,f=Pu(n.getAttribute("formenctype"))||Pu(p.getAttribute("enctype"))||ao,d=new FormData(p,n),!y1()){let{name:g,type:v,value:b}=n;if(v==="image"){let S=g?`${g}.`:"";d.append(`${S}x`,"0"),d.append(`${S}y`,"0")}else g&&d.append(g,b)}}else{if(No(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=no,o=null,f=ao,h=n}return d&&f==="text/plain"&&(h=d,d=void 0),{action:o,method:i.toLowerCase(),encType:f,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Yf(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function j1(n,s,i){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${i}`:s&&oa(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${i}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${i}`,o}async function A1(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function N1(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 w1(n,s,i){let o=await Promise.all(n.map(async f=>{let d=s.routes[f.route.id];if(d){let h=await A1(d,i);return h.links?h.links():[]}return[]}));return M1(o.flat(1).filter(N1).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function E0(n,s,i,o,f,d){let h=(x,g)=>i[g]?x.route.id!==i[g].route.id:!0,p=(x,g)=>i[g].pathname!==x.pathname||i[g].route.path?.endsWith("*")&&i[g].params["*"]!==x.params["*"];return d==="assets"?s.filter((x,g)=>h(x,g)||p(x,g)):d==="data"?s.filter((x,g)=>{let v=o.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(h(x,g)||p(x,g))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:i[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function C1(n,s,{includeHydrateFallback:i}={}){return E1(n.map(o=>{let f=s.routes[o.route.id];if(!f)return[];let d=[f.module];return f.clientActionModule&&(d=d.concat(f.clientActionModule)),f.clientLoaderModule&&(d=d.concat(f.clientLoaderModule)),i&&f.hydrateFallbackModule&&(d=d.concat(f.hydrateFallbackModule)),f.imports&&(d=d.concat(f.imports)),d}).flat(1))}function E1(n){return[...new Set(n)]}function k1(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function M1(n,s){let i=new Set;return new Set(s),n.reduce((o,f)=>{let d=JSON.stringify(k1(f));return i.has(d)||(i.add(d),o.push({key:d,link:f})),o},[])}function Lx(){let n=m.useContext(ul);return Yf(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function R1(){let n=m.useContext(Ao);return Yf(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Ff=m.createContext(void 0);Ff.displayName="FrameworkContext";function zx(){let n=m.useContext(Ff);return Yf(n,"You must render this element inside a <HydratedRouter> element"),n}function q1(n,s){let i=m.useContext(Ff),[o,f]=m.useState(!1),[d,h]=m.useState(!1),{onFocus:p,onBlur:x,onMouseEnter:g,onMouseLeave:v,onTouchStart:b}=s,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&h(!0),n==="viewport"){let E=A=>{A.forEach(N=>{h(N.isIntersecting)})},w=new IntersectionObserver(E,{threshold:.5});return S.current&&w.observe(S.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let E=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(E)}}},[o]);let k=()=>{f(!0)},C=()=>{f(!1),h(!1)};return i?n!=="intent"?[d,S,{}]:[d,S,{onFocus:ri(p,k),onBlur:ri(x,C),onMouseEnter:ri(g,k),onMouseLeave:ri(v,C),onTouchStart:ri(b,k)}]:[!1,S,{}]}function ri(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function T1({page:n,...s}){let{router:i}=Lx(),o=m.useMemo(()=>Cx(i.routes,n,i.basename),[i.routes,n,i.basename]);return o?m.createElement(_1,{page:n,matches:o,...s}):null}function D1(n){let{manifest:s,routeModules:i}=zx(),[o,f]=m.useState([]);return m.useEffect(()=>{let d=!1;return w1(n,s,i).then(h=>{d||f(h)}),()=>{d=!0}},[n,s,i]),o}function _1({page:n,matches:s,...i}){let o=fs(),{manifest:f,routeModules:d}=zx(),{basename:h}=Lx(),{loaderData:p,matches:x}=R1(),g=m.useMemo(()=>E0(n,s,x,f,o,"data"),[n,s,x,f,o]),v=m.useMemo(()=>E0(n,s,x,f,o,"assets"),[n,s,x,f,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let C=new Set,E=!1;if(s.forEach(A=>{let N=f.routes[A.route.id];!N||!N.hasLoader||(!g.some(q=>q.route.id===A.route.id)&&A.route.id in p&&d[A.route.id]?.shouldRevalidate||N.hasClientLoader?E=!0:C.add(A.route.id))}),C.size===0)return[];let w=j1(n,h,"data");return E&&C.size>0&&w.searchParams.set("_routes",s.filter(A=>C.has(A.route.id)).map(A=>A.route.id).join(",")),[w.pathname+w.search]},[h,p,o,f,g,s,n,d]),S=m.useMemo(()=>C1(v,f),[v,f]),k=D1(v);return m.createElement(m.Fragment,null,b.map(C=>m.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...i})),S.map(C=>m.createElement("link",{key:C,rel:"modulepreload",href:C,...i})),k.map(({key:C,link:E})=>m.createElement("link",{key:C,nonce:i.nonce,...E})))}function O1(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var Ux=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ux&&(window.__reactRouterVersion="7.9.6")}catch{}function B1({basename:n,children:s,window:i}){let o=m.useRef();o.current==null&&(o.current=jb({window:i,v5Compat:!0}));let f=o.current,[d,h]=m.useState({action:f.action,location:f.location}),p=m.useCallback(x=>{m.startTransition(()=>h(x))},[h]);return m.useLayoutEffect(()=>f.listen(p),[f,p]),m.createElement(d1,{basename:n,children:s,location:d.location,navigationType:d.action,navigator:f})}var Hx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vx=m.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:f,reloadDocument:d,replace:h,state:p,target:x,to:g,preventScrollReset:v,viewTransition:b,...S},k){let{basename:C}=m.useContext(_n),E=typeof g=="string"&&Hx.test(g),w,A=!1;if(typeof g=="string"&&E&&(w=g,Ux))try{let z=new URL(window.location.href),V=g.startsWith("//")?new URL(z.protocol+g):new URL(g),X=oa(V.pathname,C);V.origin===z.origin&&X!=null?g=X+V.search+V.hash:A=!0}catch{Nn(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let N=Ib(g,{relative:f}),[q,M,B]=q1(o,S),K=H1(g,{replace:h,state:p,target:x,preventScrollReset:v,relative:f,viewTransition:b});function _(z){s&&s(z),z.defaultPrevented||K(z)}let H=m.createElement("a",{...S,...B,href:w||N,onClick:A||d?s:_,ref:O1(k,M),target:x,"data-discover":!E&&i==="render"?"true":void 0});return q&&!E?m.createElement(m.Fragment,null,H,m.createElement(T1,{page:N})):H});Vx.displayName="Link";var L1=m.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:f=!1,style:d,to:h,viewTransition:p,children:x,...g},v){let b=Ri(h,{relative:g.relative}),S=fs(),k=m.useContext(Ao),{navigator:C,basename:E}=m.useContext(_n),w=k!=null&&F1(b)&&p===!0,A=C.encodeLocation?C.encodeLocation(b).pathname:b.pathname,N=S.pathname,q=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;i||(N=N.toLowerCase(),q=q?q.toLowerCase():null,A=A.toLowerCase()),q&&E&&(q=oa(q,E)||q);const M=A!=="/"&&A.endsWith("/")?A.length-1:A.length;let B=N===A||!f&&N.startsWith(A)&&N.charAt(M)==="/",K=q!=null&&(q===A||!f&&q.startsWith(A)&&q.charAt(A.length)==="/"),_={isActive:B,isPending:K,isTransitioning:w},H=B?s:void 0,z;typeof o=="function"?z=o(_):z=[o,B?"active":null,K?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let V=typeof d=="function"?d(_):d;return m.createElement(Vx,{...g,"aria-current":H,className:z,ref:v,style:V,to:h,viewTransition:p},typeof x=="function"?x(_):x)});L1.displayName="NavLink";var z1=m.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:f,state:d,method:h=no,action:p,onSubmit:x,relative:g,preventScrollReset:v,viewTransition:b,...S},k)=>{let C=G1(),E=Y1(p,{relative:g}),w=h.toLowerCase()==="get"?"get":"post",A=typeof p=="string"&&Hx.test(p),N=q=>{if(x&&x(q),q.defaultPrevented)return;q.preventDefault();let M=q.nativeEvent.submitter,B=M?.getAttribute("formmethod")||h;C(M||q.currentTarget,{fetcherKey:s,method:B,navigate:i,replace:f,state:d,relative:g,preventScrollReset:v,viewTransition:b})};return m.createElement("form",{ref:k,method:w,action:E,onSubmit:o?x:N,...S,"data-discover":!A&&n==="render"?"true":void 0})});z1.displayName="Form";function U1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $x(n){let s=m.useContext(ul);return ut(s,U1(n)),s}function H1(n,{target:s,replace:i,state:o,preventScrollReset:f,relative:d,viewTransition:h}={}){let p=Jb(),x=fs(),g=Ri(n,{relative:d});return m.useCallback(v=>{if(v1(v,s)){v.preventDefault();let b=i!==void 0?i:yi(x)===yi(g);p(n,{replace:b,state:o,preventScrollReset:f,relative:d,viewTransition:h})}},[x,p,g,i,o,s,n,f,d,h])}var V1=0,$1=()=>`__${String(++V1)}__`;function G1(){let{router:n}=$x("useSubmit"),{basename:s}=m.useContext(_n),i=o1();return m.useCallback(async(o,f={})=>{let{action:d,method:h,encType:p,formData:x,body:g}=S1(o,s);if(f.navigate===!1){let v=f.fetcherKey||$1();await n.fetch(v,i,f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,flushSync:f.flushSync})}else await n.navigate(f.action||d,{preventScrollReset:f.preventScrollReset,formData:x,body:g,formMethod:f.method||h,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:i,flushSync:f.flushSync,viewTransition:f.viewTransition})},[n,s,i])}function Y1(n,{relative:s}={}){let{basename:i}=m.useContext(_n),o=m.useContext(ua);ut(o,"useFormAction must be used inside a RouteContext");let[f]=o.matches.slice(-1),d={...Ri(n||".",{relative:s})},h=fs();if(n==null){d.search=h.search;let p=new URLSearchParams(d.search),x=p.getAll("index");if(x.some(v=>v==="")){p.delete("index"),x.filter(b=>b).forEach(b=>p.append("index",b));let v=p.toString();d.search=v?`?${v}`:""}}return(!n||n===".")&&f.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:ra([i,d.pathname])),yi(d)}function F1(n,{relative:s}={}){let i=m.useContext(Tx);ut(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=$x("useViewTransitionState"),f=Ri(n,{relative:s});if(!i.isTransitioning)return!1;let d=oa(i.currentLocation.pathname,o)||i.currentLocation.pathname,h=oa(i.nextLocation.pathname,o)||i.nextLocation.pathname;return fo(f.pathname,h)!=null||fo(f.pathname,d)!=null}const Dn=Object.create(null);Dn.open="0";Dn.close="1";Dn.ping="2";Dn.pong="3";Dn.message="4";Dn.upgrade="5";Dn.noop="6";const so=Object.create(null);Object.keys(Dn).forEach(n=>{so[Dn[n]]=n});const Nf={type:"error",data:"parser error"},Gx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Yx=typeof ArrayBuffer=="function",Fx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Xf=({type:n,data:s},i,o)=>Gx&&s instanceof Blob?i?o(s):k0(s,o):Yx&&(s instanceof ArrayBuffer||Fx(s))?i?o(s):k0(new Blob([s]),o):o(Dn[n]+(s||"")),k0=(n,s)=>{const i=new FileReader;return i.onload=function(){const o=i.result.split(",")[1];s("b"+(o||""))},i.readAsDataURL(n)};function M0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Wu;function X1(n,s){if(Gx&&n.data instanceof Blob)return n.data.arrayBuffer().then(M0).then(s);if(Yx&&(n.data instanceof ArrayBuffer||Fx(n.data)))return s(M0(n.data));Xf(n,!1,i=>{Wu||(Wu=new TextEncoder),s(Wu.encode(i))})}const R0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<R0.length;n++)mi[R0.charCodeAt(n)]=n;const Q1=n=>{let s=n.length*.75,i=n.length,o,f=0,d,h,p,x;n[n.length-1]==="="&&(s--,n[n.length-2]==="="&&s--);const g=new ArrayBuffer(s),v=new Uint8Array(g);for(o=0;o<i;o+=4)d=mi[n.charCodeAt(o)],h=mi[n.charCodeAt(o+1)],p=mi[n.charCodeAt(o+2)],x=mi[n.charCodeAt(o+3)],v[f++]=d<<2|h>>4,v[f++]=(h&15)<<4|p>>2,v[f++]=(p&3)<<6|x&63;return g},K1=typeof ArrayBuffer=="function",Qf=(n,s)=>{if(typeof n!="string")return{type:"message",data:Xx(n,s)};const i=n.charAt(0);return i==="b"?{type:"message",data:Z1(n.substring(1),s)}:so[i]?n.length>1?{type:so[i],data:n.substring(1)}:{type:so[i]}:Nf},Z1=(n,s)=>{if(K1){const i=Q1(n);return Xx(i,s)}else return{base64:!0,data:n}},Xx=(n,s)=>{switch(s){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Qx="",I1=(n,s)=>{const i=n.length,o=new Array(i);let f=0;n.forEach((d,h)=>{Xf(d,!1,p=>{o[h]=p,++f===i&&s(o.join(Qx))})})},J1=(n,s)=>{const i=n.split(Qx),o=[];for(let f=0;f<i.length;f++){const d=Qf(i[f],s);if(o.push(d),d.type==="error")break}return o};function P1(){return new TransformStream({transform(n,s){X1(n,i=>{const o=i.length;let f;if(o<126)f=new Uint8Array(1),new DataView(f.buffer).setUint8(0,o);else if(o<65536){f=new Uint8Array(3);const d=new DataView(f.buffer);d.setUint8(0,126),d.setUint16(1,o)}else{f=new Uint8Array(9);const d=new DataView(f.buffer);d.setUint8(0,127),d.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(f[0]|=128),s.enqueue(f),s.enqueue(i)})}})}let ef;function Xr(n){return n.reduce((s,i)=>s+i.length,0)}function Qr(n,s){if(n[0].length===s)return n.shift();const i=new Uint8Array(s);let o=0;for(let f=0;f<s;f++)i[f]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),i}function W1(n,s){ef||(ef=new TextDecoder);const i=[];let o=0,f=-1,d=!1;return new TransformStream({transform(h,p){for(i.push(h);;){if(o===0){if(Xr(i)<1)break;const x=Qr(i,1);d=(x[0]&128)===128,f=x[0]&127,f<126?o=3:f===126?o=1:o=2}else if(o===1){if(Xr(i)<2)break;const x=Qr(i,2);f=new DataView(x.buffer,x.byteOffset,x.length).getUint16(0),o=3}else if(o===2){if(Xr(i)<8)break;const x=Qr(i,8),g=new DataView(x.buffer,x.byteOffset,x.length),v=g.getUint32(0);if(v>Math.pow(2,21)-1){p.enqueue(Nf);break}f=v*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Xr(i)<f)break;const x=Qr(i,f);p.enqueue(Qf(d?x:ef.decode(x),s)),o=0}if(f===0||f>n){p.enqueue(Nf);break}}}})}const Kx=4;function At(n){if(n)return eS(n)}function eS(n){for(var s in At.prototype)n[s]=At.prototype[s];return n}At.prototype.on=At.prototype.addEventListener=function(n,s){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(s),this};At.prototype.once=function(n,s){function i(){this.off(n,i),s.apply(this,arguments)}return i.fn=s,this.on(n,i),this};At.prototype.off=At.prototype.removeListener=At.prototype.removeAllListeners=At.prototype.removeEventListener=function(n,s){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,f=0;f<i.length;f++)if(o=i[f],o===s||o.fn===s){i.splice(f,1);break}return i.length===0&&delete this._callbacks["$"+n],this};At.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var s=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,f=i.length;o<f;++o)i[o].apply(this,s)}return this};At.prototype.emitReserved=At.prototype.emit;At.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};At.prototype.hasListeners=function(n){return!!this.listeners(n).length};const wo=typeof Promise=="function"&&typeof Promise.resolve=="function"?s=>Promise.resolve().then(s):(s,i)=>i(s,0),gn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),tS="arraybuffer";function Zx(n,...s){return s.reduce((i,o)=>(n.hasOwnProperty(o)&&(i[o]=n[o]),i),{})}const nS=gn.setTimeout,aS=gn.clearTimeout;function Co(n,s){s.useNativeTimers?(n.setTimeoutFn=nS.bind(gn),n.clearTimeoutFn=aS.bind(gn)):(n.setTimeoutFn=gn.setTimeout.bind(gn),n.clearTimeoutFn=gn.clearTimeout.bind(gn))}const sS=1.33;function lS(n){return typeof n=="string"?iS(n):Math.ceil((n.byteLength||n.size)*sS)}function iS(n){let s=0,i=0;for(let o=0,f=n.length;o<f;o++)s=n.charCodeAt(o),s<128?i+=1:s<2048?i+=2:s<55296||s>=57344?i+=3:(o++,i+=4);return i}function Ix(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function rS(n){let s="";for(let i in n)n.hasOwnProperty(i)&&(s.length&&(s+="&"),s+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return s}function oS(n){let s={},i=n.split("&");for(let o=0,f=i.length;o<f;o++){let d=i[o].split("=");s[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return s}class cS extends Error{constructor(s,i,o){super(s),this.description=i,this.context=o,this.type="TransportError"}}class Kf extends At{constructor(s){super(),this.writable=!1,Co(this,s),this.opts=s,this.query=s.query,this.socket=s.socket,this.supportsBinary=!s.forceBase64}onError(s,i,o){return super.emitReserved("error",new cS(s,i,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(s){this.readyState==="open"&&this.write(s)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(s){const i=Qf(s,this.socket.binaryType);this.onPacket(i)}onPacket(s){super.emitReserved("packet",s)}onClose(s){this.readyState="closed",super.emitReserved("close",s)}pause(s){}createUri(s,i={}){return s+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_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 i=rS(s);return i.length?"?"+i:""}}class uS extends Kf{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(s){this.readyState="pausing";const i=()=>{this.readyState="paused",s()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||i()})),this.writable||(o++,this.once("drain",function(){--o||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(s){const i=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};J1(s,this.socket.binaryType).forEach(i),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,I1(s,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const s=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=Ix()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(s,i)}}let Jx=!1;try{Jx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const fS=Jx;function dS(){}class mS extends uS{constructor(s){if(super(s),typeof location<"u"){const i=location.protocol==="https:";let o=location.port;o||(o=i?"443":"80"),this.xd=typeof location<"u"&&s.hostname!==location.hostname||o!==s.port}}doWrite(s,i){const o=this.request({method:"POST",data:s});o.on("success",i),o.on("error",(f,d)=>{this.onError("xhr post error",f,d)})}doPoll(){const s=this.request();s.on("data",this.onData.bind(this)),s.on("error",(i,o)=>{this.onError("xhr poll error",i,o)}),this.pollXhr=s}}class Tn extends At{constructor(s,i,o){super(),this.createRequest=s,Co(this,o),this._opts=o,this._method=o.method||"GET",this._uri=i,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var s;const i=Zx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(i);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let f in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(f)&&o.setRequestHeader(f,this._opts.extraHeaders[f])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(s=this._opts.cookieJar)===null||s===void 0||s.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var f;o.readyState===3&&((f=this._opts.cookieJar)===null||f===void 0||f.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(f){this.setTimeoutFn(()=>{this._onError(f)},0);return}typeof document<"u"&&(this._index=Tn.requestsCount++,Tn.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=dS,s)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Tn.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()}}Tn.requestsCount=0;Tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",q0);else if(typeof addEventListener=="function"){const n="onpagehide"in gn?"pagehide":"unload";addEventListener(n,q0,!1)}}function q0(){for(let n in Tn.requests)Tn.requests.hasOwnProperty(n)&&Tn.requests[n].abort()}const hS=(function(){const n=Px({xdomain:!1});return n&&n.responseType!==null})();class pS extends mS{constructor(s){super(s);const i=s&&s.forceBase64;this.supportsBinary=hS&&!i}request(s={}){return Object.assign(s,{xd:this.xd},this.opts),new Tn(Px,this.uri(),s)}}function Px(n){const s=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!s||fS))return new XMLHttpRequest}catch{}if(!s)try{return new gn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Wx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class xS extends Kf{get name(){return"websocket"}doOpen(){const s=this.uri(),i=this.opts.protocols,o=Wx?{}:Zx(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,i,o)}catch(f){return this.emitReserved("error",f)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=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 i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;Xf(o,this.supportsBinary,d=>{try{this.doWrite(o,d)}catch{}f&&wo(()=>{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",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=Ix()),this.supportsBinary||(i.b64=1),this.createUri(s,i)}}const tf=gn.WebSocket||gn.MozWebSocket;class gS extends xS{createSocket(s,i,o){return Wx?new tf(s,i,o):i?new tf(s,i):new tf(s)}doWrite(s,i){this.ws.send(i)}}class vS extends Kf{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 i=W1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=s.readable.pipeThrough(i).getReader(),f=P1();f.readable.pipeTo(s.writable),this._writer=f.writable.getWriter();const d=()=>{o.read().then(({done:p,value:x})=>{p||(this.onPacket(x),d())}).catch(p=>{})};d();const h={type:"open"};this.query.sid&&(h.data=`{"sid":"${this.query.sid}"}`),this._writer.write(h).then(()=>this.onOpen())})})}write(s){this.writable=!1;for(let i=0;i<s.length;i++){const o=s[i],f=i===s.length-1;this._writer.write(o).then(()=>{f&&wo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var s;(s=this._transport)===null||s===void 0||s.close()}}const yS={websocket:gS,webtransport:vS,polling:pS},bS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,SS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function wf(n){if(n.length>8e3)throw"URI too long";const s=n,i=n.indexOf("["),o=n.indexOf("]");i!=-1&&o!=-1&&(n=n.substring(0,i)+n.substring(i,o).replace(/:/g,";")+n.substring(o,n.length));let f=bS.exec(n||""),d={},h=14;for(;h--;)d[SS[h]]=f[h]||"";return i!=-1&&o!=-1&&(d.source=s,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),d.pathNames=jS(d,d.path),d.queryKey=AS(d,d.query),d}function jS(n,s){const i=/\/{2,9}/g,o=s.replace(i,"/").split("/");return(s.slice(0,1)=="/"||s.length===0)&&o.splice(0,1),s.slice(-1)=="/"&&o.splice(o.length-1,1),o}function AS(n,s){const i={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,f,d){f&&(i[f]=d)}),i}const Cf=typeof addEventListener=="function"&&typeof removeEventListener=="function",lo=[];Cf&&addEventListener("offline",()=>{lo.forEach(n=>n())},!1);class Ba extends At{constructor(s,i){if(super(),this.binaryType=tS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,s&&typeof s=="object"&&(i=s,s=null),s){const o=wf(s);i.hostname=o.host,i.secure=o.protocol==="https"||o.protocol==="wss",i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=wf(i.host).host);Co(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(o=>{const f=o.prototype.name;this.transports.push(f),this._transportsByName[f]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=oS(this.opts.query)),Cf&&(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"})},lo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(s){const i=Object.assign({},this.opts.query);i.EIO=Kx,i.transport=s,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[s]);return new this._transportsByName[s](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const s=this.opts.rememberUpgrade&&Ba.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(s);i.open(),this.setTransport(i)}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",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",Ba.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",s),this.emitReserved("heartbeat"),s.type){case"open":this.onHandshake(JSON.parse(s.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=s.data,this._onError(i);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 i=1;for(let o=0;o<this.writeBuffer.length;o++){const f=this.writeBuffer[o].data;if(f&&(i+=lS(f)),o>0&&i>this._maxPayload)return this.writeBuffer.slice(0,o);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const s=Date.now()>this._pingTimeoutTime;return s&&(this._pingTimeoutTime=0,wo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),s}write(s,i,o){return this._sendPacket("message",s,i,o),this}send(s,i,o){return this._sendPacket("message",s,i,o),this}_sendPacket(s,i,o,f){if(typeof i=="function"&&(f=i,i=void 0),typeof o=="function"&&(f=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const d={type:s,data:i,options:o};this.emitReserved("packetCreate",d),this.writeBuffer.push(d),f&&this.once("flush",f),this.flush()}close(){const s=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),s()},o=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():s()}):this.upgrading?o():s()),this}_onError(s){if(Ba.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",s),this._onClose("transport error",s)}_onClose(s,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Cf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=lo.indexOf(this._offlineEventListener);o!==-1&&lo.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",s,i),this.writeBuffer=[],this._prevBufferLen=0}}}Ba.protocol=Kx;class NS extends Ba{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let s=0;s<this._upgrades.length;s++)this._probe(this._upgrades[s])}_probe(s){let i=this.createTransport(s),o=!1;Ba.priorWebsocketSuccess=!1;const f=()=>{o||(i.send([{type:"ping",data:"probe"}]),i.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;Ba.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=i.name,this.emitReserved("upgradeError",S)}}))};function d(){o||(o=!0,v(),i.close(),i=null)}const h=b=>{const S=new Error("probe error: "+b);S.transport=i.name,d(),this.emitReserved("upgradeError",S)};function p(){h("transport closed")}function x(){h("socket closed")}function g(b){i&&b.name!==i.name&&d()}const v=()=>{i.removeListener("open",f),i.removeListener("error",h),i.removeListener("close",p),this.off("close",x),this.off("upgrading",g)};i.once("open",f),i.once("error",h),i.once("close",p),this.once("close",x),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&s!=="webtransport"?this.setTimeoutFn(()=>{o||i.open()},200):i.open()}onHandshake(s){this._upgrades=this._filterUpgrades(s.upgrades),super.onHandshake(s)}_filterUpgrades(s){const i=[];for(let o=0;o<s.length;o++)~this.transports.indexOf(s[o])&&i.push(s[o]);return i}}let wS=class extends NS{constructor(s,i={}){const o=typeof s=="object"?s:i;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(f=>yS[f]).filter(f=>!!f)),super(s,o)}};function CS(n,s="",i){let o=n;i=i||typeof location<"u"&&location,n==null&&(n=i.protocol+"//"+i.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=i.protocol+n:n=i.host+n),/^(https?|wss?):\/\//.test(n)||(typeof i<"u"?n=i.protocol+"//"+n:n="https://"+n),o=wf(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const d=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+d+":"+o.port+s,o.href=o.protocol+"://"+d+(i&&i.port===o.port?"":":"+o.port),o}const ES=typeof ArrayBuffer=="function",kS=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,eg=Object.prototype.toString,MS=typeof Blob=="function"||typeof Blob<"u"&&eg.call(Blob)==="[object BlobConstructor]",RS=typeof File=="function"||typeof File<"u"&&eg.call(File)==="[object FileConstructor]";function Zf(n){return ES&&(n instanceof ArrayBuffer||kS(n))||MS&&n instanceof Blob||RS&&n instanceof File}function io(n,s){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let i=0,o=n.length;i<o;i++)if(io(n[i]))return!0;return!1}if(Zf(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return io(n.toJSON(),!0);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&io(n[i]))return!0;return!1}function qS(n){const s=[],i=n.data,o=n;return o.data=Ef(i,s),o.attachments=s.length,{packet:o,buffers:s}}function Ef(n,s){if(!n)return n;if(Zf(n)){const i={_placeholder:!0,num:s.length};return s.push(n),i}else if(Array.isArray(n)){const i=new Array(n.length);for(let o=0;o<n.length;o++)i[o]=Ef(n[o],s);return i}else if(typeof n=="object"&&!(n instanceof Date)){const i={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=Ef(n[o],s));return i}return n}function TS(n,s){return n.data=kf(n.data,s),delete n.attachments,n}function kf(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 i=0;i<n.length;i++)n[i]=kf(n[i],s);else if(typeof n=="object")for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=kf(n[i],s));return n}const DS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],_S=5;var _e;(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"})(_e||(_e={}));class OS{constructor(s){this.replacer=s}encode(s){return(s.type===_e.EVENT||s.type===_e.ACK)&&io(s)?this.encodeAsBinary({type:s.type===_e.EVENT?_e.BINARY_EVENT:_e.BINARY_ACK,nsp:s.nsp,data:s.data,id:s.id}):[this.encodeAsString(s)]}encodeAsString(s){let i=""+s.type;return(s.type===_e.BINARY_EVENT||s.type===_e.BINARY_ACK)&&(i+=s.attachments+"-"),s.nsp&&s.nsp!=="/"&&(i+=s.nsp+","),s.id!=null&&(i+=s.id),s.data!=null&&(i+=JSON.stringify(s.data,this.replacer)),i}encodeAsBinary(s){const i=qS(s),o=this.encodeAsString(i.packet),f=i.buffers;return f.unshift(o),f}}function T0(n){return Object.prototype.toString.call(n)==="[object Object]"}class If extends At{constructor(s){super(),this.reviver=s}add(s){let i;if(typeof s=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(s);const o=i.type===_e.BINARY_EVENT;o||i.type===_e.BINARY_ACK?(i.type=o?_e.EVENT:_e.ACK,this.reconstructor=new BS(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Zf(s)||s.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(s),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+s)}decodeString(s){let i=0;const o={type:Number(s.charAt(0))};if(_e[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===_e.BINARY_EVENT||o.type===_e.BINARY_ACK){const d=i+1;for(;s.charAt(++i)!=="-"&&i!=s.length;);const h=s.substring(d,i);if(h!=Number(h)||s.charAt(i)!=="-")throw new Error("Illegal attachments");o.attachments=Number(h)}if(s.charAt(i+1)==="/"){const d=i+1;for(;++i&&!(s.charAt(i)===","||i===s.length););o.nsp=s.substring(d,i)}else o.nsp="/";const f=s.charAt(i+1);if(f!==""&&Number(f)==f){const d=i+1;for(;++i;){const h=s.charAt(i);if(h==null||Number(h)!=h){--i;break}if(i===s.length)break}o.id=Number(s.substring(d,i+1))}if(s.charAt(++i)){const d=this.tryParse(s.substr(i));if(If.isPayloadValid(o.type,d))o.data=d;else throw new Error("invalid payload")}return o}tryParse(s){try{return JSON.parse(s,this.reviver)}catch{return!1}}static isPayloadValid(s,i){switch(s){case _e.CONNECT:return T0(i);case _e.DISCONNECT:return i===void 0;case _e.CONNECT_ERROR:return typeof i=="string"||T0(i);case _e.EVENT:case _e.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&DS.indexOf(i[0])===-1);case _e.ACK:case _e.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class BS{constructor(s){this.packet=s,this.buffers=[],this.reconPack=s}takeBinaryData(s){if(this.buffers.push(s),this.buffers.length===this.reconPack.attachments){const i=TS(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const LS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:If,Encoder:OS,get PacketType(){return _e},protocol:_S},Symbol.toStringTag,{value:"Module"}));function jn(n,s,i){return n.on(s,i),function(){n.off(s,i)}}const zS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class tg extends At{constructor(s,i,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=s,this.nsp=i,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const s=this.io;this.subs=[jn(s,"open",this.onopen.bind(this)),jn(s,"packet",this.onpacket.bind(this)),jn(s,"error",this.onerror.bind(this)),jn(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,...i){var o,f,d;if(zS.hasOwnProperty(s))throw new Error('"'+s.toString()+'" is a reserved event name');if(i.unshift(s),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const h={type:_e.EVENT,data:i};if(h.options={},h.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const v=this.ids++,b=i.pop();this._registerAckCallback(v,b),h.id=v}const p=(f=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||f===void 0?void 0:f.writable,x=this.connected&&!(!((d=this.io.engine)===null||d===void 0)&&d._hasPingExpired());return this.flags.volatile&&!p||(x?(this.notifyOutgoingListeners(h),this.packet(h)):this.sendBuffer.push(h)),this.flags={},this}_registerAckCallback(s,i){var o;const f=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(f===void 0){this.acks[s]=i;return}const d=this.io.setTimeoutFn(()=>{delete this.acks[s];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===s&&this.sendBuffer.splice(p,1);i.call(this,new Error("operation has timed out"))},f),h=(...p)=>{this.io.clearTimeoutFn(d),i.apply(this,p)};h.withError=!0,this.acks[s]=h}emitWithAck(s,...i){return new Promise((o,f)=>{const d=(h,p)=>h?f(h):o(p);d.withError=!0,i.push(d),this.emit(s,...i)})}_addToQueue(s){let i;typeof s[s.length-1]=="function"&&(i=s.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:s,flags:Object.assign({fromQueue:!0},this.flags)};s.push((f,...d)=>o!==this._queue[0]?void 0:(f!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(f)):(this._queue.shift(),i&&i(null,...d)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(s=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!s||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.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:_e.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,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",s,i),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 _e.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 _e.EVENT:case _e.BINARY_EVENT:this.onevent(s);break;case _e.ACK:case _e.BINARY_ACK:this.onack(s);break;case _e.DISCONNECT:this.ondisconnect();break;case _e.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 i=s.data||[];s.id!=null&&i.push(this.ack(s.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(s){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const o of i)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 i=this;let o=!1;return function(...f){o||(o=!0,i.packet({type:_e.ACK,id:s,data:f}))}}onack(s){const i=this.acks[s.id];typeof i=="function"&&(delete this.acks[s.id],i.withError&&s.data.unshift(null),i.apply(this,s.data))}onconnect(s,i){this.id=s,this.recovered=i&&this._pid===i,this._pid=i,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:_e.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 i=this._anyListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.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 i=this._anyOutgoingListeners;for(let o=0;o<i.length;o++)if(s===i[o])return i.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(s){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const o of i)o.apply(this,s.data)}}}function fl(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}fl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var s=Math.random(),i=Math.floor(s*this.jitter*n);n=(Math.floor(s*10)&1)==0?n-i:n+i}return Math.min(n,this.max)|0};fl.prototype.reset=function(){this.attempts=0};fl.prototype.setMin=function(n){this.ms=n};fl.prototype.setMax=function(n){this.max=n};fl.prototype.setJitter=function(n){this.jitter=n};class Mf extends At{constructor(s,i){var o;super(),this.nsps={},this.subs=[],s&&typeof s=="object"&&(i=s,s=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,Co(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((o=i.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new fl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=s;const f=i.parser||LS;this.encoder=new f.Encoder,this.decoder=new f.Decoder,this._autoConnect=i.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 i;return s===void 0?this._reconnectionDelay:(this._reconnectionDelay=s,(i=this.backoff)===null||i===void 0||i.setMin(s),this)}randomizationFactor(s){var i;return s===void 0?this._randomizationFactor:(this._randomizationFactor=s,(i=this.backoff)===null||i===void 0||i.setJitter(s),this)}reconnectionDelayMax(s){var i;return s===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=s,(i=this.backoff)===null||i===void 0||i.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 wS(this.uri,this.opts);const i=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const f=jn(i,"open",function(){o.onopen(),s&&s()}),d=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),s?s(p):this.maybeReconnectOnOpen()},h=jn(i,"error",d);if(this._timeout!==!1){const p=this._timeout,x=this.setTimeoutFn(()=>{f(),d(new Error("timeout")),i.close()},p);this.opts.autoUnref&&x.unref(),this.subs.push(()=>{this.clearTimeoutFn(x)})}return this.subs.push(f),this.subs.push(h),this}connect(s){return this.open(s)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const s=this.engine;this.subs.push(jn(s,"ping",this.onping.bind(this)),jn(s,"data",this.ondata.bind(this)),jn(s,"error",this.onerror.bind(this)),jn(s,"close",this.onclose.bind(this)),jn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(s){try{this.decoder.add(s)}catch(i){this.onclose("parse error",i)}}ondecoded(s){wo(()=>{this.emitReserved("packet",s)},this.setTimeoutFn)}onerror(s){this.emitReserved("error",s)}socket(s,i){let o=this.nsps[s];return o?this._autoConnect&&!o.active&&o.connect():(o=new tg(this,s,i),this.nsps[s]=o),o}_destroy(s){const i=Object.keys(this.nsps);for(const o of i)if(this.nsps[o].active)return;this._close()}_packet(s){const i=this.encoder.encode(s);for(let o=0;o<i.length;o++)this.engine.write(i[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,i){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",s,i),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 i=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{s.skipReconnect||(this.emitReserved("reconnect_attempt",s.backoff.attempts),!s.skipReconnect&&s.open(f=>{f?(s._reconnecting=!1,s.reconnect(),this.emitReserved("reconnect_error",f)):s.onreconnect()}))},i);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 oi={};function ro(n,s){typeof n=="object"&&(s=n,n=void 0),s=s||{};const i=CS(n,s.path||"/socket.io"),o=i.source,f=i.id,d=i.path,h=oi[f]&&d in oi[f].nsps,p=s.forceNew||s["force new connection"]||s.multiplex===!1||h;let x;return p?x=new Mf(o,s):(oi[f]||(oi[f]=new Mf(o,s)),x=oi[f]),i.query&&!s.query&&(s.query=i.queryKey),x.socket(i.path,s)}Object.assign(ro,{Manager:Mf,Socket:tg,io:ro,connect:ro});const ng="roverSettings",US=3600*24*365;function HS(n){try{const s=decodeURIComponent(n??"");return JSON.parse(s)}catch(s){return console.warn("Failed to parse settings cookie",s),null}}function Rf(){if(typeof document>"u")return{};const n=`${ng}=`,s=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!s)return{};const i=s.substring(n.length);return HS(i)??{}}function D0(n){if(typeof document>"u")return!1;try{const s=encodeURIComponent(JSON.stringify(n??{})),i=`${ng}=${s}; path=/; max-age=${US}; samesite=strict`;return document.cookie=i,!0}catch(s){return console.warn("Failed to write settings cookie",s),!1}}const ag=window.location.origin;console.info("[socket] connecting to",ag);const VS=Rf(),$S=VS?.page?.connectionTransport||"websocket",GS=$S==="polling"?["polling"]:["websocket","polling"],Jf=ro(ag,{transports:GS,timeout:15e3});Jf.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const sg=m.createContext(Jf),YS=({children:n})=>r.jsx(sg.Provider,{value:Jf,children:n}),tn=()=>m.useContext(sg),FS={connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,alerts:[]},Pf=m.createContext(null);function XS(n){return m.useCallback((s,i={})=>new Promise((o,f)=>{n.emit(s,i,(d={})=>{d.error?f(new Error(d.error)):o(d)})}),[n])}function QS(n){return typeof n=="function"?n:s=>s}function KS({children:n}){const s=tn(),i=XS(s),o=m.useRef({...FS,connected:s.connected}),f=m.useRef(new Set),d=m.useCallback(()=>o.current,[]),h=m.useCallback(v=>{const b=o.current,S=typeof v=="function"?v(b):{...b,...v||{}};S!==b&&(o.current=S,f.current.forEach(k=>{const C=k.selector(S);k.equalityFn(k.current,C)||(k.current=C,k.listener(C))}))},[]),p=m.useCallback((v,b,S=Object.is)=>{const k=QS(v),C={selector:k,equalityFn:S,listener:b,current:k(o.current)};return f.current.add(C),()=>{f.current.delete(C)}},[]);m.useEffect(()=>{const v=()=>{h(S=>S.connected?S:{...S,connected:!0})},b=()=>{h(S=>S.connected?{...S,connected:!1}:S)};return s.on("connect",v),s.on("disconnect",b),()=>{s.off("connect",v),s.off("disconnect",b)}},[h,s]),m.useEffect(()=>{function v(A){h(N=>({...N,session:A}))}function b(A=[]){h(N=>({...N,logs:A}))}function S(A){h(N=>({...N,logs:[...N.logs.slice(-199),A]}))}function k(A=[]){h(N=>({...N,adminLogs:A}))}function C(A){h(N=>({...N,adminLogs:[...N.adminLogs.slice(-199),A]}))}function E(A=null){const N=A&&typeof A=="object"?A:null,q=N?.debug?.status&&typeof N.debug.status=="object"?N.debug.status:null;h(M=>({...M,llmCommentaryState:N,llmCommentaryStatus:q}))}function w(A={}){h(N=>({...N,alerts:[...N.alerts.slice(-49),{...A,receivedAt:Date.now()}]}))}return s.on("session:sync",v),s.on("log:init",b),s.on("log:entry",S),s.on("adminlog:init",k),s.on("adminlog:entry",C),s.on("llm:state",E),s.on("alert:new",w),()=>{s.off("session:sync",v),s.off("log:init",b),s.off("log:entry",S),s.off("adminlog:init",k),s.off("adminlog:entry",C),s.off("llm:state",E),s.off("alert:new",w)}},[h,s]);const x=m.useMemo(()=>({login:(v,b)=>i("auth:login",{username:v,password:b}),identifySession:({cookieUserId:v,nickname:b}={})=>i("session:identify",{cookieUserId:v,nickname:b}),setRole:v=>i("session:setRole",{role:v}),requestControl:(v,b={})=>i("session:requestControl",{roverId:v,...b}),releaseControl:v=>i("session:releaseControl",{roverId:v}),subscribeAll:()=>i("session:subscribeAll"),lockRover:(v,b)=>i("session:lockRover",{roverId:v,locked:b}),setMode:v=>i("setMode",{mode:v}),homeAssistantToggle:v=>i("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,b)=>i("homeAssistant:setState",{entityId:v,state:b}),homeAssistantSetLightColor:(v,b)=>i("homeAssistant:lightColor",{entityId:v,rgbColor:b}),homeAssistantSetLightWhite:v=>i("homeAssistant:lightWhite",{entityId:v}),setNickname:v=>i("nickname:set",{nickname:v}),requestVerification:()=>i("verification:request"),requestPrivateRoverAccess:v=>i("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[])=>i("replay:trigger",{sources:v}),setCommunityGoal:v=>i("communityGoal:set",{text:v}),setAdminReason:v=>i("adminReason:set",{text:v}),rebootRover:v=>i("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>i("server:reboot"),playUploadedAudio:({roverId:v,name:b,mime:S,dataBase64:k})=>i("audio:uploadPlay",{roverId:v,name:b,mime:S,dataBase64:k}),stopUploadedAudio:v=>i("audio:uploadStop",{roverId:v}),startMicWhip:v=>i("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>i("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>i("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>i("audioLevels:set",v),setPrivateSafety:(v,b={})=>i("session:privateSafety:set",{roverId:v,safety:b}),llmControl:(v,b={})=>i("llm:control",{controls:{action:v,...b}}),pushAlert:v=>h(b=>({...b,alerts:[...b.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[i,h]),g=m.useMemo(()=>({getState:d,subscribe:p,actions:x}),[x,d,p]);return r.jsx(Pf.Provider,{value:g,children:n})}function ft(n,s=Object.is){const i=m.useContext(Pf);if(!i)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const f=m.useRef(s);f.current=s;const[d,h]=m.useState(()=>n(i.getState()));return m.useEffect(()=>(h(p=>{const x=o.current(i.getState());return f.current(p,x)?p:x}),i.subscribe(p=>o.current(p),p=>{h(x=>f.current(x,p)?x:p)},(p,x)=>f.current(p,x))),[i]),d}function wn(){const n=m.useContext(Pf);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function nn(){const n=ft(i=>i),s=wn();return m.useMemo(()=>({...n,...s}),[s,n])}const lg=m.createContext({frames:{}});function ZS({children:n}){const s=tn(),[i,o]=m.useState({});m.useEffect(()=>{function d({roverId:h,sensors:p={},frame:x={}}){h&&o(g=>({...g,[h]:{roverId:h,sensors:p,raw:x?.data||null,receivedAt:Date.now()}}))}return s.on("sensorFrame",d),()=>{s.off("sensorFrame",d)}},[s]);const f=m.useMemo(()=>({frames:i}),[i]);return r.jsx(lg.Provider,{value:f,children:n})}function Wf(){return m.useContext(lg).frames}function dl(n){const s=Wf();return n?s[n]??null:null}const IS=650,JS={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 nf(n){if(typeof n!="number"||n<=0)return null;const s=JS[n];return s?{code:n,...s}:null}function PS(n,s={}){const i=s.holdMs||IS,[o,f]=m.useState({left:null,right:null,omni:null}),[d,h]=m.useState(0);return m.useEffect(()=>{const p=setInterval(()=>h(Date.now()),Math.max(i/2,100));return()=>clearInterval(p)},[i]),m.useEffect(()=>{const p=Date.now(),x=nf(n?.infraredCharacterLeft),g=nf(n?.infraredCharacterRight),v=nf(n?.infraredCharacterOmni);!x&&!g&&!v||f(b=>({left:x?{...x,ts:p}:b.left,right:g?{...g,ts:p}:b.right,omni:v?{...v,ts:p}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useEffect(()=>{const{left:p,right:x,omni:g}=o;if(!(p?.ts||x?.ts||g?.ts))return;const b=new Date().toISOString();console.debug("[DockIR]",b,{left:p?.code??0,omni:g?.code??0,right:x?.code??0})},[o.left?.code,o.right?.code,o.omni?.code]),m.useMemo(()=>{const p=Date.now(),x=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const A=p-w.ts,N=A<=i;return{active:N,age:A,code:w.code,red:!!(w.red&&N),green:!!(w.green&&N),force:!!(w.force&&N)}},g=x(o.left),v=x(o.right),b=x(o.omni),S=g.force||v.force||b.force,k=g.active||v.active||b.active,C=g.active&&!v.active?"right":v.active&&!g.active?"left":"center",E=(v.active?1:0)-(g.active?1:0);return{visible:k,forceDetected:S,left:g,right:v,omni:b,bias:C,balance:Math.max(-1,Math.min(1,E))}},[o.left,o.right,o.omni,i,d])}function WS(){ft(S=>S.connected);const n=ft(S=>S.session),s=n?.assignment?.roverId,i=dl(s),o=i?.sensors||{},f=PS(o),d=o.voltageMv!=null?`${(o.voltageMv/1e3).toFixed(2)} V`:null,h=o.currentMa!=null?`${o.currentMa} mA`:null,p=o.batteryTemperatureC!=null?`${o.batteryTemperatureC} °C`:null,x=o.batteryChargeMah,g=o.batteryCapacityMah;i?.receivedAt&&new Date(i.receivedAt).toLocaleTimeString();const v=i?.raw?i.raw:null,b=s?n?.activeDrivers?.[s]:null;return m.useMemo(()=>s?b?b===n?.socketId?"You":(n?.users||[]).find(k=>k.socketId===b)?.nickname||b.slice(0,6):"Available":"n/a",[b,s,n?.socketId,n?.users]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[s?i?r.jsxs(r.Fragment,{children:[r.jsx(ej,{sensors:o,voltage:d,current:h,batteryTemp:p,charge:x,capacity:g}),r.jsx(tj,{sensors:o,dockState:f})]}):r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):r.jsx("p",{className:"text-sm text-slate-500",children:"Assign a rover to view sensors."}),v&&r.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:v})]})}function ej({sensors:n,voltage:s,current:i,batteryTemp:o,charge:f,capacity:d}){const h=f!=null&&d?`${Math.round(f/d*100)}`:"--",p=n?.oiMode?.label||"--",x=n?.chargingSources?.homeBase?"Yes":"No",g=n?.chargingState?.label||"--";return r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[r.jsx(aa,{label:"Voltage",value:s??"--"}),r.jsx(aa,{label:"Current",value:i??"--"}),r.jsx(aa,{label:"Battery temp",value:o??"--"}),r.jsx(aa,{label:"Charge",value:f!=null?`${f} mAh`:"--"}),r.jsx(aa,{label:"Capacity",value:d!=null?`${d} mAh`:"--"}),r.jsx(aa,{label:"Charge",value:h}),r.jsx(aa,{label:"OI mode",value:p}),r.jsx(aa,{label:"Docked",value:x}),r.jsx(aa,{label:"Charging state",value:g})]})}function aa({label:n,value:s}){return r.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[r.jsx("span",{className:"text-slate-400",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function tj({sensors:n,dockState:s}){const i=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},f=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],d=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],h=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs(Ws,{title:"Dock IR",children:[r.jsx(nj,{sensors:n}),r.jsx(aj,{state:s})]}),r.jsxs(Ws,{title:"Bumps & drops",children:[r.jsx(sa,{label:"Bump L",value:r.jsx(ci,{active:i.bumpLeft})}),r.jsx(sa,{label:"Bump R",value:r.jsx(ci,{active:i.bumpRight})}),r.jsx(sa,{label:"Wheel drop L",value:r.jsx(ci,{active:i.wheelDropLeft,tone:"amber"})}),r.jsx(sa,{label:"Wheel drop R",value:r.jsx(ci,{active:i.wheelDropRight,tone:"amber"})})]}),r.jsx(Ws,{title:"Light bumps (raw)",children:f.map(p=>r.jsx(sa,{label:p.label,value:ui(p.value)},p.label))}),r.jsx(Ws,{title:"Cliff sensors",children:d.map(p=>r.jsx(sa,{label:p.label,value:`${ui(p.value)} · ${p.active?"bool: true":"bool: false"}`},p.label))}),r.jsx(Ws,{title:"Currents",children:h.map(p=>r.jsx(sa,{label:p.label,value:r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:ui(p.value,"mA")}),p.over?r.jsx(ci,{active:!0,tone:"red",label:"over"}):null]})},p.label))}),r.jsxs(Ws,{title:"Dirt detect",children:[r.jsx(sa,{label:"Left",value:ui(n?.dirtDetectLeft)}),r.jsx(sa,{label:"Right",value:ui(n?.dirtDetect)})]})]})}function Ws({title:n,children:s}){return r.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[r.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),r.jsx("div",{className:"space-y-0.5",children:s})]})}function sa({label:n,value:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-300",children:n}),r.jsx("span",{className:"text-slate-100",children:s})]})}function ci({active:n,tone:s="green",label:i}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",f=s==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":s==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return r.jsx("span",{className:`${o} ${f}`,children:i||(n?"true":"false")})}function ui(n,s){return n==null||Number.isNaN(n)?"--":s?`${n} ${s}`:n}function nj({sensors:n}){const s=n?.infraredCharacterLeft,i=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,f=d=>r.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${d?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:d||"--"});return r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"L"}),f(s)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"O"}),f(o)]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:"R"}),f(i)]})]})}function aj({state:n}){if(!n)return null;const s=o=>{const f=[];return o?.red&&f.push("R"),o?.green&&f.push("G"),o?.force&&f.push("F"),f.length?f.join(""):"none"},i=o=>o?.age!=null?`${o.age}ms`:"--";return r.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Left: ${n.left.code??"--"} (${s(n.left)}) · age ${i(n.left)}`}),r.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${s(n.omni)}) · age ${i(n.omni)}`}),r.jsx("div",{children:`Right: ${n.right.code??"--"} (${s(n.right)}) · age ${i(n.right)}`})]})}const ig=m.createContext(null);function sj({children:n}){const[s,i]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const p=Rf();i({status:"ready",data:p??{}})},[]);const o=m.useCallback(()=>{const p=Rf();i({status:"ready",data:p??{}})},[]),f=m.useCallback(p=>{const x=D0(p??{});return i(x?{status:"ready",data:p??{}}:g=>({...g,status:"error"})),x},[]),d=m.useCallback((p,x)=>{i(g=>{const v=g.data[p]||{},b=typeof x=="function"?x(v):{...v,...x??{}},S={...g.data,[p]:b};return D0(S)?{status:"ready",data:S}:{...g,status:"error"}})},[]),h=m.useMemo(()=>({data:s.data,status:s.status,reload:o,saveAll:f,setNamespace:d}),[s,o,f,d]);return r.jsx(ig.Provider,{value:h,children:n})}function lj(){const n=m.useContext(ig);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function He(n,s={}){const{data:i,status:o,setNamespace:f}=lj(),d=i[n]??s??{},h=m.useCallback(g=>{f(n,v=>{const b=v??{};return typeof g=="function"?g(b):{...b,...g??{}}})},[n,f]),p=m.useCallback(g=>{f(n,()=>g??{})},[n,f]),x=m.useCallback(()=>{const g=typeof s=="object"?{...s}:s;f(n,()=>g??{})},[s,n,f]);return{value:d,status:o,save:h,replace:p,reset:x}}const ij=/^#[0-9A-Fa-f]{6}$/;function ed(n){const s=typeof n=="string"?n.trim():"";return!s||!ij.test(s)?null:s.toUpperCase()}function ca(n,s=.2){const i=ed(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=rg(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.65)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function rj(n,s=.2){const i=ed(n);if(!i)return;const o=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.2,f=rg(i);if(f)return{borderColor:`rgba(${f.r}, ${f.g}, ${f.b}, 0.55)`,backgroundColor:`rgba(${f.r}, ${f.g}, ${f.b}, ${o})`}}function rg(n){const s=ed(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 oj(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 td({panelId:n="replay-sources",fillHeight:s=!1}){const{session:i,triggerReplay:o}=nn(),f=oj(i?.replaySources||[]),{value:d,save:h}=He("replaySources",{}),[p,x]=m.useState([]),[g,v]=m.useState(!1),[b,S]=m.useState(null),[k,C]=m.useState(null),E=i?.replay||null,[w,A]=m.useState(0),N=m.useMemo(()=>{const z=i?.assignment?.roverId;return z?[`rover:${z}`]:[]},[i?.assignment?.roverId]);m.useEffect(()=>{const z=d?.[n];if(Array.isArray(z)&&z.length){x(z);return}x(N)},[d?.[n],N,n]),m.useEffect(()=>{const z=new Set(f.map(V=>V.key));x(V=>V.filter(X=>z.has(X)))},[f]);const q=m.useMemo(()=>({rovers:f.filter(z=>z.type==="rover"),rooms:f.filter(z=>z.type==="room")}),[f]);m.useEffect(()=>{if(!E?.lastTriggeredAt||!E?.cooldownMs){A(0);return}const z=()=>{const X=E.lastTriggeredAt+E.cooldownMs-Date.now();A(Math.max(0,X))};z();const V=setInterval(z,250);return()=>clearInterval(V)},[E?.lastTriggeredAt,E?.cooldownMs,E?.remainingMs]);const M=g||i?.mode==="lockdown"||w>0||!p.length,B=z=>{x(V=>{const X=V.includes(z)?V.filter(te=>te!==z):[...V,z];return h(te=>({...te||{},[n]:X})),X}),C(null)},K=async()=>{if(!M){v(!0),S(null),C(null);try{const z=p.map(V=>{const[X,te]=V.split(":");return{type:X,id:te}});await o(z),C("Replay sent. Check the Discord replay channel.")}catch(z){S(z.message)}finally{v(!1)}}},_=s?"h-full flex flex-col":"",H=s?"flex-1 min-h-0 overflow-y-auto":"";return r.jsxs("section",{className:`panel-section p-0.75 text-sm ${_}`,children:[r.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[r.jsx("span",{children:"Replay Sources"}),r.jsx("span",{children:f.length})]}),r.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${H}`,children:[r.jsx(_0,{title:"Rovers",items:q.rovers,selected:p,onToggle:B}),r.jsx(_0,{title:"Room Cams",items:q.rooms,selected:p,onToggle:B})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:K,disabled:M,children:w>0?`Replay (${Math.ceil(w/1e3)}s)`:g?"Replay…":"Replay"}),b?r.jsx("div",{className:"text-xs text-amber-400",children:b}):null,k?r.jsx("div",{className:"text-xs text-emerald-300",children:k}):null]})]})}function _0({title:n,items:s,selected:i,onToggle:o}){return s.length?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs",children:n}),r.jsx("div",{className:"space-y-0.5",children:s.map(f=>r.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[r.jsx("input",{type:"checkbox",checked:i.includes(f.key),onChange:()=>o(f.key),className:"accent-emerald-400"}),r.jsx("span",{className:`truncate ${f.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:f.type==="rover"?ca(f.color,.16):void 0,children:f.label})]},f.key))})]}):null}var og={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},O0=us.createContext&&us.createContext(og),cj=["attr","size","title"];function uj(n,s){if(n==null)return{};var i=fj(n,s),o,f;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(n);for(f=0;f<d.length;f++)o=d[f],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(i[o]=n[o])}return i}function fj(n,s){if(n==null)return{};var i={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(s.indexOf(o)>=0)continue;i[o]=n[o]}return i}function mo(){return mo=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])}return n},mo.apply(this,arguments)}function B0(n,s){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);s&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(n,f).enumerable})),i.push.apply(i,o)}return i}function ho(n){for(var s=1;s<arguments.length;s++){var i=arguments[s]!=null?arguments[s]:{};s%2?B0(Object(i),!0).forEach(function(o){dj(n,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):B0(Object(i)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(i,o))})}return n}function dj(n,s,i){return s=mj(s),s in n?Object.defineProperty(n,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[s]=i,n}function mj(n){var s=hj(n,"string");return typeof s=="symbol"?s:s+""}function hj(n,s){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var o=i.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 cg(n){return n&&n.map((s,i)=>us.createElement(s.tag,ho({key:i},s.attr),cg(s.child)))}function qi(n){return s=>us.createElement(pj,mo({attr:ho({},n.attr)},s),cg(n.child))}function pj(n){var s=i=>{var{attr:o,size:f,title:d}=n,h=uj(n,cj),p=f||i.size||"1em",x;return i.className&&(x=i.className),n.className&&(x=(x?x+" ":"")+n.className),us.createElement("svg",mo({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,o,h,{className:x,style:ho(ho({color:n.color||i.color},i.style),n.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),d&&us.createElement("title",null,d),n.children)};return O0!==void 0?us.createElement(O0.Consumer,null,i=>s(i)):s(og)}function ug(n){return qi({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 xj(n){return qi({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 L0(n){return qi({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 gj(n){return qi({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 vj(n){return qi({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 yj(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 nd(n){return!!n?.system}function bj(n){const s=new Date(n);return`${s.getHours().toString().padStart(2,"0")}:${s.getMinutes().toString().padStart(2,"0")}`}function z0(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Sj({guildIconUrl:n,userAvatarUrl:s,label:i}){return!n&&!s?null:r.jsxs("span",{className:"flex h-4 w-4 overflow-hidden rounded-full border border-slate-700/80",title:i,children:[r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),r.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${s?"bg-cover":""}`,style:s?{backgroundImage:`url(${s})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function fg({message:n}){const s=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${z0(n)}`:null,i=nd(n),o=i?"text-emerald-300":yj(n.role);return r.jsxs(r.Fragment,{children:[n.fromDiscord?r.jsxs(r.Fragment,{children:[r.jsx(ug,{className:"h-3.5 w-3.5 text-indigo-200"}),r.jsx(Sj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:s})]}):null,r.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:z0(n)}),i?r.jsx("span",{className:"rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem]",style:rj(n.roverColor,.14),children:n.roverId})]})}function dg(n){return nd(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 ad({message:n}){const s=nd(n);return r.jsxs("div",{className:dg(n),children:[r.jsx(fg,{message:n}),r.jsx("span",{className:`break-words leading-tight whitespace-pre-wrap ${s?"text-emerald-100":"text-slate-100"}`,children:n.text}),r.jsx("span",{className:"absolute bottom-0.5 right-1 text-[0.65rem] text-slate-400/60",children:bj(n.ts)})]})}function mg({message:n}){return r.jsxs("div",{className:`${dg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[r.jsx(fg,{message:n}),r.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function hg({buttonId:n,count:s,goal:i,rewardNumber:o,rewardName:f,className:d=""}){return r.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",d].filter(Boolean).join(" "),children:[r.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),r.jsxs("p",{className:"text-sm font-semibold text-white",children:[s," / ",i]}),r.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",f]})]})}const jj=3e3,Aj=3500,Nj="#2196f3";function wj(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function sd({scale:n=1}){const s=ft(S=>S.alerts),i=ft(S=>S.session),{pushAlert:o}=wn(),f=tn(),[d,h]=m.useState(()=>Date.now());m.useEffect(()=>{function S(k={}){const C=Number(k.buttonId);if(!Number.isFinite(C)||C<1||C>4)return;const w=(Array.isArray(i?.buttonBox?.buttons)?i.buttonBox.buttons:[]).find(B=>Number(B?.id)===C)||{},A=Number.isFinite(k.count)?k.count:Number(w.count)||0,N=Number.isFinite(w.goal)?w.goal:0,q=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",M=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${C}`,kind:"buttonbox-active",lifetimeMs:Aj,payload:{buttonId:C,count:A,goal:N,rewardNumber:q,rewardName:M}})}return f.on("buttonBox:increment",S),()=>{f.off("buttonBox:increment",S)}},[o,i?.buttonBox?.buttons,f]);const p=m.useMemo(()=>s.slice(-12).map(S=>({alert:S,key:wj(S)})),[s]);m.useEffect(()=>{if(!p.length)return;const S=setInterval(()=>h(Date.now()),200);return()=>clearInterval(S)},[p.length]);const x=new Map;p.forEach(S=>{const k=d-(S.alert.receivedAt??S.alert.timestamp??0),C=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:jj;k<=C&&x.set(S.key,{...S,age:k})});const g=Array.from(x.values()).slice(-3);if(!g.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},b=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return r.jsx("div",{className:b,style:v,children:g.map(S=>r.jsx(Cj,{alert:S.alert},S.key))})}function U0(n){const s=typeof n=="string"?n.trim():"",i=/^#?([0-9a-fA-F]{6})$/.exec(s);if(!i)return null;const o=i[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function Cj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const f=n.payload;return r.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:r.jsx(hg,{buttonId:f.buttonId,count:f.count,goal:f.goal,rewardNumber:f.rewardNumber,rewardName:f.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return r.jsx(ad,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return r.jsx(mg,{message:n.payload});const s=U0(n.color)||U0(Nj),i=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=s?`rgba(${s.r}, ${s.g}, ${s.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return r.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:i,border:`1px solid ${o}`},children:r.jsxs("p",{className:"truncate text-slate-100",children:[r.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),r.jsx("span",{className:"text-slate-500",children:" · "}),r.jsx("span",{className:"text-white",children:n.message})]})})}const el={main:[-127,127],side:[-127,127],vacuum:[0,127]},af={maxSpeed:500,baseSpeed:250,boostSpeed:400},qf=100,ld=[31,127],ll=60,Tf=8,Ej=250,kj=4e3,Kr=.4,H0=.2,V0=.8,Mj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},xi={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"]},pg=[{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:qf},{type:"oi",command:"dock"},{type:"pause",duration:qf},{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 Df(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function _f(){return{main:0,side:0,vacuum:0}}function Rj(){return{enabled:!1,angle:null,config:null}}function oo(){return{note:ll}}function hi(){return{active:!1,heat:0,overheated:!1}}function co(){return{pttActive:!1}}const $0={roverId:null,mode:"drive",drive:Df(),aux:_f(),camera:Rj(),song:oo(),horn:hi(),mic:co(),lastControlIntentAt:0,macros:pg,keymap:xi,inputs:{}};function qj(n,s){switch(s.type){case"control/set-rover":return{...n,roverId:s.payload??null,drive:s.payload?n.drive:Df(),aux:s.payload?n.aux:_f(),song:s.payload?n.song:oo(),horn:s.payload?n.horn:hi(),mic:s.payload?n.mic:co(),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:i,speeds:o,source:f}=s.payload;return{...n,drive:{vector:i??n.drive.vector,speeds:o??n.drive.speeds,source:f??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...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 i=s.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[i]:{...n.inputs[i]??{},...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:Df(),aux:_f(),song:oo(),horn:hi(),mic:co(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||hi(),active:!!s.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||hi(),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||oo(),note:s.payload??ll}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||co(),pttActive:!!s.payload}};default:return n}}function il(n,s,i){return typeof n!="number"||Number.isNaN(n)?s:Math.max(s,Math.min(i,n))}function rl(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function pn(n,s){return!Array.isArray(s)||s.length!==2?n:il(n,s[0],s[1])}function Tj(n={}){const s=rl(n.x??0),i=rl(n.y??0);return{x:s,y:i,boost:!!n.boost}}function Dj(n={},s={}){const i=Tj(n),o=typeof s.maxSpeed=="number"?s.maxSpeed:af.maxSpeed,f=typeof s.baseSpeed=="number"?s.baseSpeed:af.baseSpeed,d=typeof s.boostSpeed=="number"?s.boostSpeed:af.boostSpeed,h=i.boost?d:f,p=i.y*h,x=i.x*h;return{vector:i,speeds:{left:il(Math.round(p+x),-o,o),right:il(Math.round(p-x),-o,o)}}}function _j(n){const s=Array.isArray(n)?n:[],i=String.fromCharCode(...s);if(typeof btoa=="function")return btoa(i);if(typeof Buffer<"u")return Buffer.from(s).toString("base64");throw new Error("No base64 encoder available")}function G0(n){return new Promise(s=>setTimeout(s,n))}function Oj(n={}){const{driveTransform:s,auxTransform:i}=n,o=tn(),f=ft(B=>B.session),d=f?.assignment?.roverId,h=m.useMemo(()=>!d||!Array.isArray(f?.roster)?null:f.roster.find(B=>String(B.id)===String(d))||null,[d,f?.roster]),p=m.useMemo(()=>!h?.cameraServo||!h.cameraServo.enabled?null:h.cameraServo,[h]),x=m.useMemo(()=>!h?.nightVision||!h.nightVision.enabled?null:h.nightVision,[h]),g=m.useMemo(()=>!h?.horn||!h.horn.enabled?null:h.horn,[h]),v=m.useMemo(()=>h?.nightVision?.state??null,[h]),b=m.useCallback((B,K)=>{d&&o.emit("command",{roverId:d,...B},K)},[o,d]),S=m.useCallback(()=>{d&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,d]),k=m.useCallback(B=>{if(!d)return null;const K={left:pn(B?.left??0,[-500,500]),right:pn(B?.right??0,[-500,500])},_=s?s(K):K,H={left:pn(_?.left??0,[-500,500]),right:pn(_?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:H}}),H},[s,b,d]),C=m.useCallback(({main:B=0,side:K=0,vacuum:_=0}={})=>{if(!d)return null;const H={main:pn(B,el.main),side:pn(K,el.side),vacuum:pn(_,el.vacuum)},z=i?i(H):H,V={main:pn(z?.main??0,el.main),side:pn(z?.side??0,el.side),vacuum:pn(z?.vacuum??0,el.vacuum)};return b({type:"motors",data:{motorPwm:V}}),V},[i,b,d]),E=m.useCallback(B=>!d||!p?null:(b({type:"servo",data:{servo:{angle:B}}}),B),[b,d,p]),w=m.useCallback(B=>{if(!d)return!1;const K=Array.isArray(B)?B:typeof B=="string"?Mj[B]:null;return K?(b({type:"raw",data:{raw:_j(K)}}),S(),!0):!1},[b,S,d]),A=m.useCallback(async B=>{if(!(!B||!Array.isArray(B.steps)||!d))for(const K of B.steps){if(!d)break;switch(K.type){case"oi":w(K.command);break;case"drive":k(K.speeds??{left:0,right:0});break;case"motors":C(K.values??{});break;case"servo":E(K.angle);break;case"pause":await G0(K.duration??qf);break}if(K.delay||K.delayMs){const _=K.delayMs??K.delay;typeof _=="number"&&_>0&&await G0(_)}}},[d,w,k,C,E]),N=m.useCallback((B="toggle")=>!d||!x?null:(b({type:"nightVision",data:{nightVision:{action:B}}}),B),[b,x,d]),q=m.useCallback(B=>d?(b({type:"horn",data:{horn:B}}),B):null,[b,d]),M=m.useCallback((B=[],K={})=>{if(!d)return null;const H=(Array.isArray(B)&&B.length>0?B:[{note:ll,duration:Tf}]).slice(0,16).map(z=>({note:pn(Math.round(z?.note??ll),ld),duration:pn(Math.round(z?.duration??Tf),[1,255])}));return b({type:"song",data:{song:{notes:H,slot:K.slot,loop:K.loop}}}),H},[b,d]);return m.useMemo(()=>({roverId:d,rosterEntry:h,servoConfig:p,nightVision:x,nightVisionState:v,horn:g,emitCommand:b,enableSensorStream:S,sendDriveDirect:k,sendAuxMotors:C,sendServoAngle:E,sendOiCommand:w,sendNightVision:N,sendHorn:q,sendSong:M,runMacroSteps:A}),[d,h,p,x,v,g,b,S,k,C,E,w,N,q,A])}const Bj={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Y0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Ti(n){if(typeof n!="string")return"";const s=n.toLowerCase();return Bj[s]??s}function Lj(n){const s=Ti(n);if(!s)return null;if(Y0[s])return Y0[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 xg(n){const s=Ti(n);return s?`key:${s}`:null}function zj(n){const s=Lj(n);return s?`code:${s}`:null}function F0(n){const s=new Set,i=xg(n?.key??"");i&&s.add(i);const o=n?.code?`code:${n.code}`:null;return o&&s.add(o),Array.from(s)}function Uj(n={}){return Object.fromEntries(Object.entries(n).map(([s,i])=>{const o=Array.isArray(i)?i:[i],f=new Set;return o.forEach(d=>{const h=xg(String(d));h&&f.add(h);const p=zj(String(d));p&&f.add(p)}),[s,f]}))}function An(n){const s=Ti(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 qn={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},ia={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}]}}},Oa={activeSignature:null,profiles:{},defaults:{profile:ia}},cs={waveform:"saw",freqs:[440,550,660,0]},ct={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},rs=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],Hj={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function X0(){return rs.reduce((n,s)=>(n[s.key]={cap:1,clearSec:0},n),{})}function Q0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function Vj(n,s={}){const i=ft(A=>A.session),d=(dl(n)?.sensors||{})?.wheelOvercurrents||{},h=m.useMemo(()=>({...Hj,...s.config||{}}),[s.config]),[p,x]=m.useState(()=>X0()),g=m.useRef(0),v=m.useRef(d);m.useEffect(()=>{v.current=d||{}},[d]),m.useEffect(()=>{x(X0()),g.current=0},[n]);const b=m.useMemo(()=>rs.some(A=>A.motors.some(N=>!!d?.[N])),[d]),S=m.useMemo(()=>Object.values(p||{}).some(A=>(Number.isFinite(A?.cap)?A.cap:1)<.999),[p]),k=!!n&&(b||S);m.useEffect(()=>{if(!k)return;g.current=typeof performance<"u"?performance.now():Date.now();const A=setInterval(()=>{const N=typeof performance<"u"?performance.now():Date.now(),q=Math.max(0,N-g.current);g.current=N;const M=Math.min(.25,q/1e3);M<=0||x(B=>{let K=!1;const _={},H=Number.isFinite(h.downRatePerSec)?Math.max(0,h.downRatePerSec):0,z=Number.isFinite(h.upRatePerSec)?Math.max(0,h.upRatePerSec):0,V=Number.isFinite(h.releaseDelaySec)?Math.max(0,h.releaseDelaySec):0;return rs.forEach(X=>{const te=B[X.key]||{cap:1,clearSec:0},ue=Number.isFinite(te.cap)?te.cap:1,ce=Number.isFinite(te.clearSec)?te.clearSec:0,Y=X.motors.some(ie=>!!v.current?.[ie]),T=Y?0:ce+M,$=!Y&&T>=V,J=Q0(Y?ue-H*M:$?ue+z*M:ue);(Math.abs(J-ue)>1e-4||Math.abs(T-ce)>1e-4)&&(K=!0),_[X.key]={cap:J,clearSec:T}}),K?_:B})},100);return()=>clearInterval(A)},[h.downRatePerSec,h.releaseDelaySec,h.upRatePerSec,n,k]);const C=m.useMemo(()=>{const A=rs.reduce((N,q)=>{const M=p?.[q.key],B=Number.isFinite(M?.cap)?M.cap:1;return N[q.key]=Q0(B),N},{});return{perGroup:A,drive:{left:A.drive??1,right:A.drive??1},aux:{main:A.aux??1,side:A.aux??1,vacuum:1}}},[p]),E=m.useMemo(()=>{const A={};rs.forEach(q=>{q.motors.forEach(M=>{A[M]=!!d?.[M]})});const N=rs.reduce((q,M)=>(q[M.key]=M.motors.some(B=>!!d?.[B]),q),{});return{motors:A,groups:N}},[d]),w=i?.role==="admin"||i?.role==="lockdown"||i?.role==="lockdown-admin";return m.useMemo(()=>({caps:p,overcurrent:E,scales:C,isActive:(C?.drive?.left??1)<1||(C?.drive?.right??1)<1||(C?.aux?.main??1)<1||(C?.aux?.side??1)<1,config:h,adminImmune:w}),[p,E,C,h,w])}function $j(n={},s,i=!1){if(i||!s?.drive)return n;const o=typeof s.drive.left=="number"?s.drive.left:1,f=typeof s.drive.right=="number"?s.drive.right:1;return o>=.999&&f>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*f)}}function Gj(n={},s,i=!1){if(i||!s?.aux)return n;const o=typeof s.aux.main=="number"?s.aux.main:1,f=typeof s.aux.side=="number"?s.aux.side:1,d=typeof s.aux.vacuum=="number"?s.aux.vacuum:1;return o>=.999&&f>=.999&&d>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*f),vacuum:Math.round((n.vacuum??0)*d)}}const gg=m.createContext(null);function K0(n){return Object.fromEntries(Object.entries(n||{}).map(([s,i])=>[s,Array.isArray(i)?[...i]:[]]))}function Yj(n,s){if(!n)return s;const i=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return il(s,i,o)}function Fj(n=[]){if(!Array.isArray(n)||n.length<3)return n;const s=n.slice(-3),[i,o,f]=s,d=i?.type==="drive"&&Number(i?.speeds?.left)===-300&&Number(i?.speeds?.right)===-300,h=o?.type==="pause"&&Number(o?.duration)===600,p=f?.type==="drive"&&Number(f?.speeds?.left)===0&&Number(f?.speeds?.right)===0;return!d||!h||!p?n:n.slice(0,-3)}function Xj({children:n}){const[s,i]=m.useReducer(qj,$0),o=m.useRef(null),f=m.useRef(!1),d=m.useRef($0.camera.angle),h=m.useRef(null),p=m.useRef(0),x=m.useRef(0),{value:g,save:v}=He("controls",{keymap:xi,macros:pg}),{value:b}=He("page",{driveMacroBackoffEnabled:!0}),{value:S}=He("horn",cs),k=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,C=ft(le=>le.session),{homeAssistantSetState:E}=wn(),w=C?.assignment?.roverId??null,A=Vj(w),N=m.useCallback(le=>$j(le,A.scales,A.adminImmune),[A.adminImmune,A.scales]),q=m.useCallback(le=>Gj(le,A.scales,A.adminImmune),[A.adminImmune,A.scales]),M=Oj({driveTransform:N,auxTransform:q}),B=m.useCallback(()=>{const me=(C?.homeAssistant?.entities||[]).filter(se=>(se.type==="light"||se.type==="switch")&&se.available!==!1&&se.state!=="on");if(me.length===0){f.current=!1;return}f.current=!0,me.forEach(se=>{E(se.id,"on").catch(()=>{})}),f.current=!1},[C?.homeAssistant?.entities,E]);m.useEffect(()=>{i({type:"control/set-rover",payload:M.roverId})},[M.roverId]),m.useEffect(()=>{const le=o.current;o.current=s.mode,le!=="drive"&&s.mode==="drive"&&C?.homeAssistant?.entities?B():le!=="drive"&&s.mode==="drive"&&(f.current=!0)},[s.mode,C?.homeAssistant?.entities,B]),m.useEffect(()=>{f.current&&C?.homeAssistant?.entities&&B()},[C?.homeAssistant?.entities,B]),m.useEffect(()=>{const le={...xi,...g?.keymap||{}};i({type:"control/set-keymap",payload:le}),g?.macros&&i({type:"control/set-macros",payload:g.macros})},[g?.keymap,g?.macros]),m.useEffect(()=>{const le=M.servoConfig;if(!le){i({type:"control/set-camera-config",payload:{config:null}}),d.current=null;return}const me=typeof le.minAngle=="number"?le.minAngle:-45,se=typeof le.maxAngle=="number"?le.maxAngle:45,P=typeof le.homeAngle=="number"?le.homeAngle:(me+se)/2,fe=typeof d.current=="number"?il(d.current,me,se):null,Ne=fe??il(P,me,se);i({type:"control/set-camera-config",payload:{config:le,angle:Ne}}),d.current=Ne},[M.servoConfig]),m.useEffect(()=>{d.current=typeof s.camera.angle=="number"?s.camera.angle:d.current},[s.camera.angle]),m.useEffect(()=>{M.roverId&&M.enableSensorStream()},[M.roverId,M.enableSensorStream]);const K=m.useCallback(le=>{i({type:"control/set-mode",payload:le})},[]),_=m.useCallback(()=>{i({type:"control/record-intent"})},[]),H=m.useRef(s.drive.speeds),z=m.useRef(s.aux),V=m.useMemo(()=>JSON.stringify(A.scales),[A.scales]),X=m.useRef(0),te=m.useRef(0);m.useEffect(()=>{H.current=s.drive.speeds},[s.drive.speeds]),m.useEffect(()=>{z.current=s.aux},[s.aux]),m.useEffect(()=>{if(!M.roverId||A.adminImmune||!A.isActive)return;const le=Math.max(0,Number(A?.config?.outputRateMs)||0),me=typeof performance<"u"?performance.now():Date.now(),se=H.current||{left:0,right:0},P=z.current||{main:0,side:0,vacuum:0},fe=!!(se.left||se.right),Ne=!!(P.main||P.side||P.vacuum);!fe&&!Ne||(fe&&me-X.current>=le&&(X.current=me,M.sendDriveDirect(se)),Ne&&me-te.current>=le&&(te.current=me,M.sendAuxMotors(P)))},[V,A.adminImmune,A.config,A.isActive,M]);const ue=m.useCallback((le,me={})=>{const se=Dj(le,me.speedOptions);i({type:"control/update-drive",payload:{...se,source:me.source??null}}),_(),M.sendDriveDirect(se.speeds)},[M,_]),ce=m.useCallback((le={})=>{const me=M.sendAuxMotors(le)??le;i({type:"control/set-aux-motors",payload:me}),_()},[M,_]),Y=m.useCallback((le,me)=>{if(!le)return!1;const se=Ti(me);if(!se)return!1;const P=K0(s.keymap);return P[le]=[se],i({type:"control/set-keymap",payload:P}),v(fe=>({...fe??{},keymap:P})),!0},[s.keymap,v]),T=m.useCallback(()=>{const le=K0(xi);i({type:"control/set-keymap",payload:le}),v(me=>({...me??{},keymap:le}))},[v]),$=m.useCallback(le=>{if(!M.servoConfig)return;const me=Yj(M.servoConfig,le);i({type:"control/set-camera-angle",payload:me}),M.sendServoAngle(me),d.current=me,_()},[M,_]),J=m.useCallback((le=0)=>{const me=M.servoConfig;if(!me)return;const se=typeof le=="number"&&le!==0?le:me.nudgeDegrees||1,P=typeof d.current=="number"?d.current:typeof me.homeAngle=="number"?me.homeAngle:0;$(P+se)},[M.servoConfig,$]),ie=m.useCallback(()=>{const le=M.servoConfig;if(!le)return;const me=typeof le.homeAngle=="number"?le.homeAngle:typeof le.minAngle=="number"&&typeof le.maxAngle=="number"?(le.minAngle+le.maxAngle)/2:0;$(me)},[M.servoConfig,$]),de=m.useCallback(async le=>{const me=s.macros.find(P=>P.id===le)||null;if(!me)return;let se=me;le==="drive-sequence"?(B(),C?.homeAssistant?.entities||(f.current=!0),_(),k||(se={...me,steps:Fj(me.steps)})):le==="seek-dock"&&_(),await M.runMacroSteps(se)},[k,M,_,C?.homeAssistant?.entities,s.macros,B]),R=m.useCallback(()=>{i({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),M.sendDriveDirect({left:0,right:0}),M.sendAuxMotors({main:0,side:0,vacuum:0})},[M]),U=m.useCallback(le=>{M.sendOiCommand(le)},[M]),ee=m.useCallback(le=>{M.roverId&&M.emitCommand({type:"sensorStream",data:{sensorStream:{enable:le}}})},[M]),ae=m.useCallback(le=>{if(M.nightVision){if(typeof le=="boolean"){const me=le?"off":"on";M.sendNightVision(me)}else M.sendNightVision("toggle");_()}},[M,_]),pe=m.useCallback(()=>{ae()},[ae]),re=m.useCallback(le=>{const me=typeof le=="number"?le:ll;return i({type:"control/set-song-note",payload:me}),me},[]),oe=m.useCallback((le,me)=>M.sendSong(le,me),[M]),ve=m.useMemo(()=>{const le=S??cs,me=le.waveform==="sine"?"sine":"saw",P=[...Array.isArray(le.freqs)?le.freqs:cs.freqs,0,0,0,0].slice(0,4).map(fe=>{const Ne=Number(fe);return Number.isFinite(Ne)?Ne<=0?0:Math.min(5e3,Math.round(Ne)):0});return{waveform:me,freqs:P}},[S]),ye=m.useCallback(()=>{if(!M.horn)return;if(s.horn?.overheated||(s.horn?.heat??0)>=1||s.horn?.active)return!1;const le=Date.now();return M.sendHorn({action:"start",...ve}),i({type:"control/set-horn-active",payload:!0}),p.current=le,x.current=le,h.current&&(clearTimeout(h.current),h.current=null),h.current=setTimeout(()=>{xe()},kj),_(),!0},[i,ve,M,_,s.horn?.active,s.horn?.heat,s.horn?.overheated]),xe=m.useCallback(()=>{if(!M.horn)return;M.sendHorn({action:"stop"}),i({type:"control/set-horn-active",payload:!1}),h.current&&(clearTimeout(h.current),h.current=null);const le=Date.now(),me=p.current||le,se=Math.max(0,le-me);if(p.current=0,se>0){const P=s.horn?.heat??0,fe=se/1e3*Kr;let Ne=Math.max(0,Math.min(1,P+fe)),pt=s.horn?.overheated??!1;Ne>=1&&(Ne=1,pt=!0),i({type:"control/set-horn-heat",payload:{heat:Ne,overheated:pt}})}},[i,M,s.horn?.heat,s.horn?.overheated,Kr]),Oe=m.useRef({active:!!s.horn?.active,heat:s.horn?.heat??0,overheated:!!s.horn?.overheated}),ze=m.useRef(xe);m.useEffect(()=>{Oe.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(()=>{ze.current=xe},[xe]);const Ae=!!s.horn?.active||(s.horn?.heat??0)>0||!!s.horn?.overheated;m.useEffect(()=>{if(!Ae)return;const me=setInterval(()=>{const se=Date.now(),P=x.current||se;x.current=se;const fe=Math.min(1e3,Math.max(0,se-P))/1e3,Ne=Oe.current,pt=Ne.heat??0,Ve=!!Ne.active,st=!!Ne.overheated,lt=fe*(Ve?Kr:-H0);let Bt=Math.max(0,Math.min(1,pt+lt)),it=st;Bt>=1?(Bt=1,it=!0,Ve&&ze.current()):it&&Bt<=V0&&(it=!1),(Bt!==pt||it!==st)&&i({type:"control/set-horn-heat",payload:{heat:Bt,overheated:it}})},100);return()=>clearInterval(me)},[i,Ae,H0,V0,Kr]);const tt=m.useCallback((le,me)=>{i({type:"control/register-input-state",payload:{source:le,state:me}})},[]),Je=m.useCallback(le=>{i({type:"control/set-mic-ptt",payload:!!le})},[]),vt=m.useMemo(()=>({state:s,dispatch:i,pipeline:M,overcurrentLimiter:A,actions:{setMode:K,setDriveVector:ue,setAuxMotors:ce,setServoAngle:$,nudgeServo:J,goServoHome:ie,runMacro:de,stopAllMotion:R,sendOiCommand:U,setSensorStream:ee,setNightVision:ae,toggleNightVision:pe,updateKeyBinding:Y,resetKeyBindings:T,registerInputState:tt,setSongNote:re,sendSong:oe,startHorn:ye,stopHorn:xe,setMicPttActive:Je}}),[s,M,A,K,ue,ce,$,J,ie,de,R,U,ee,ae,pe,Y,T,tt,re,oe,ye,xe,Je]);return r.jsx(gg.Provider,{value:vt,children:n})}function _t(){const n=m.useContext(gg);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const Qj="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=",vg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function Kj({children:n}){const s=tn(),i=ft(Y=>Y.session),{pushAlert:o}=wn(),{value:f}=He("audio",ct),[d,h]=m.useState([]),[p,x]=m.useState([]),[g,v]=m.useState(!1),b=m.useRef(null),S=m.useRef(null),k=m.useRef(null),C=m.useRef(new Map),E=m.useRef(new Map),w=m.useRef({isTyping:!1,lastSent:0}),A=Number.isFinite(f?.masterVolume)?f.masterVolume:ct.masterVolume,N=Number.isFinite(f?.alertVolume)?f.alertVolume:ct.alertVolume,q=Math.max(0,Math.min(1,A*N)),M=m.useCallback(()=>{const Y=Array.from(C.current.values()).sort((T,$)=>T.lastUpdate-$.lastUpdate).map(T=>T.payload);x(Y)},[]),B=m.useCallback(Y=>!Y||typeof Y!="object"?null:Y.typingId?Y.typingId:Y.fromDiscord?`discord:${Y.discordUserId||Y.discordUserName||Y.nickname||"unknown"}`:`socket:${Y.socketId||Y.nickname||"unknown"}`,[]);m.useEffect(()=>{k.current=new Audio(Qj),k.current.volume=q,k.current.load()},[q]);const K=m.useCallback(()=>{const Y=k.current;Y&&(Y.volume=q,Y.currentTime=0,Y.play().catch(()=>{}))},[q]);m.useEffect(()=>{function Y(T={}){h($=>[...$.slice(-99),T]),!(T?.socketId&&i?.socketId&&T.socketId===i.socketId)&&(K(),o?.({kind:"chat",payload:T,id:`chat-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return s.on("chat:message",Y),()=>{s.off("chat:message",Y)}},[K,i?.socketId,s]),m.useEffect(()=>{function Y(T={}){const $=B(T);if(!$)return;const J=Date.now();if(T?.socketId&&i?.socketId&&T.socketId===i.socketId){T.isTyping||(C.current.delete($),M());return}if(T.isTyping){C.current.set($,{payload:T,expiresAt:J+6e3,lastUpdate:J});const ie=E.current.get($)||0;J-ie>=2500&&(E.current.set($,J),o?.({kind:"chat-typing",payload:T,id:`chat-typing-${$}-${T.id||Math.random().toString(36).slice(2)}`,receivedAt:J}))}else C.current.delete($);M()}return s.on("chat:typing",Y),()=>{s.off("chat:typing",Y)}},[o,M,B,i?.socketId,s]),m.useEffect(()=>{const Y=setInterval(()=>{const T=Date.now();let $=!1;C.current.forEach((J,ie)=>{J.expiresAt<=T&&(C.current.delete(ie),$=!0)}),$&&M()},2e3);return()=>clearInterval(Y)},[M]),m.useEffect(()=>{function Y(T=[]){Array.isArray(T)&&h($=>{if($.length===0)return T.slice(-100);const J=new Set(T.map(de=>de?.id));return[...T,...$.filter(de=>de?.id&&!J.has(de.id))].slice(-100)})}return s.on("chat:init",Y),()=>{s.off("chat:init",Y)}},[s]);const _=m.useCallback(Y=>{const T=!!Y,$=Date.now(),J=w.current,ie=!T&&J.isTyping;!(T&&(!J.isTyping||$-J.lastSent>=3500))&&!ie||(w.current={isTyping:T,lastSent:$},s.emit("chat:typing",{isTyping:T}))},[s]),H=m.useCallback((Y,T=null)=>new Promise(($,J)=>{s.emit("chat:send",{text:Y,tts:T},(ie={})=>{ie.error?J(new Error(ie.error)):$(ie)})}),[s]),z=m.useCallback((Y,T={})=>{(T?.target==="hud"?"hud":"panel")==="hud"?S.current=Y:b.current=Y},[]),V=m.useCallback(()=>{v(!0),(S.current||b.current)?.focus()},[]),X=m.useCallback(()=>{v(!1),S.current?.blur(),b.current?.blur()},[]),te=m.useCallback(()=>v(!0),[]),ue=m.useCallback(()=>v(!1),[]),ce=m.useMemo(()=>({messages:d,sendMessage:H,focusChat:V,blurChat:X,registerInputRef:z,onInputFocus:te,onInputBlur:ue,setTypingActive:_,typing:p,isChatFocused:g,selfSocketId:i?.socketId||null}),[X,V,g,d,ue,te,z,H,i?.socketId,_,p]);return r.jsx(vg.Provider,{value:ce,children:n})}function id(){const n=m.useContext(vg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let yg=!1;function sf(n){yg=!!n}function Z0(){return yg}const Zj=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function bg(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 i=n.type?n.type.toLowerCase():"";return Zj.has(i)}function Ij(){return typeof document>"u"?!1:bg(document.activeElement)}const lf="keyboard",rf={x:0,y:0,boost:!1},of={main:0,side:0,vacuum:0},I0=ld[0],J0=ld[1],rd=5,bi=500,Si=1,od=100;function cf(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}function Jj(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(rd,Math.min(bi,i)):s}function Sg(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Si,Math.min(od,i)):s}function Pj(n){const i=(Sg(n,n)-Si)/(od-Si),o=bi-i*(bi-rd);return Math.round(o)}function Wj(n){const s=Jj(n,n),i=(bi-s)/(bi-rd),o=Si+i*(od-Si);return Math.round(o)}function eA(n){return bg(n?.target)}function ht(n,s){if(!n||n.size===0)return!1;for(const i of s)if(n.has(i))return!0;return!1}function tA(n,s){const i=ht(s.driveForward,n),o=ht(s.driveBackward,n),f=ht(s.driveLeft,n),d=ht(s.driveRight,n),h=ht(s.boostModifier,n),p=ht(s.slowModifier,n);let x=0;i&&!o?x=1:o&&!i&&(x=-1);let g=0;f&&!d?g=-1:d&&!f&&(g=1);const v=p?.4:1;return{x:g*v,y:x*v,boost:h&&!p}}function nA(n,s){if(ht(s.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=ht(s.auxMainForward,n)?127:ht(s.auxMainReverse,n)?-127:0,f=ht(s.auxSideForward,n)?127:ht(s.auxSideReverse,n)?-70:0,d=ht(s.auxVacuumFast,n)?127:ht(s.auxVacuumSlow,n)?50:0;return{main:o,side:f,vacuum:d}}function aA(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,nudgeServo:f,runMacro:d,stopAllMotion:h,registerInputState:p,toggleNightVision:x,startHorn:g,stopHorn:v,setMicPttActive:b,setSongNote:S,sendSong:k}}=_t(),C=ft(re=>re.session),{homeAssistantSetState:E}=wn(),{focusChat:w,blurChat:A,isChatFocused:N}=id(),{value:q}=He("inputs",qn),M=m.useMemo(()=>Uj(n.keymap),[n.keymap]),B=m.useMemo(()=>{const re=new Set;return Object.values(M).forEach(oe=>{oe&&oe.forEach(ve=>re.add(ve))}),re},[M]),K=m.useMemo(()=>{const re=qn.keyboard,oe=q?.keyboard??{};return{baseSpeed:cf(oe.baseSpeed,re.baseSpeed),turboSpeed:cf(oe.turboSpeed,re.turboSpeed),precisionSpeed:cf(oe.precisionSpeed,re.precisionSpeed)}},[q?.keyboard]),_=m.useMemo(()=>{const re=qn.keyboard,oe=q?.keyboard??{},ve=Sg(typeof oe.tiltSpeed=="number"?oe.tiltSpeed:typeof oe.tiltIntervalMs=="number"?Wj(oe.tiltIntervalMs):re.tiltSpeed,re.tiltSpeed);return Pj(ve)},[q?.keyboard]),H=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),z=m.useRef(new Set),V=m.useRef(rf),X=m.useRef(of),te=m.useRef(null),ue=m.useRef(null),ce=m.useRef(!1),Y=m.useCallback(()=>{const re=new Set(z.current);ht(M.boostModifier,re);const ve=ht(M.slowModifier,re)?{baseSpeed:K.precisionSpeed,boostSpeed:K.precisionSpeed}:{baseSpeed:K.baseSpeed,boostSpeed:K.turboSpeed},ye=tA(re,M),xe=nA(re,M);(ye.x!==V.current.x||ye.y!==V.current.y||ye.boost!==V.current.boost)&&(V.current=ye,i(ye,{source:lf,speedOptions:ve})),(xe.main!==X.current.main||xe.side!==X.current.side||xe.vacuum!==X.current.vacuum)&&(X.current=xe,o(xe)),p(lf,{keys:Array.from(re),vector:ye,aux:xe})},[M,K,p,o,i]),T=m.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=null)},[]),$=m.useCallback(()=>{const re=new Set(z.current),oe=ht(M.cameraUp,re),ve=ht(M.cameraDown,re);return(oe?1:0)-(ve?1:0)},[M]),J=m.useCallback(()=>{if($()===0){T();return}if(te.current)return;const oe=()=>{const ve=$();if(ve===0){T();return}f(ve*H),te.current=setTimeout(oe,_)};te.current=setTimeout(oe,0)},[$,f,_,H,T]),ie=m.useCallback(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),de=m.useCallback(()=>{const re=new Set(z.current),oe=ht(M.songNoteUp,re),ve=ht(M.songNoteDown,re);return(oe?1:0)-(ve?1:0)},[M]),R=m.useCallback(re=>{if(re===0)return;let ve=(typeof n.song?.note=="number"?n.song.note:ll)+re;ve>J0?ve=I0:ve<I0&&(ve=J0);const ye=S(ve);k([{note:ye,duration:Tf}],{slot:0})},[k,S,n.song?.note]),U=m.useCallback(()=>{if(de()===0){ie();return}if(ue.current)return;const oe=()=>{const ve=de();if(ve===0){ie();return}R(ve),ue.current=setTimeout(oe,Ej)};ue.current=setTimeout(oe,0)},[de,ie,R]),ee=m.useCallback(()=>{z.current.clear(),V.current=rf,X.current=of,T(),ie(),ce.current&&(ce.current=!1,v()),b(!1),h(),p(lf,{keys:[],vector:rf,aux:of})},[p,b,h,v,T,ie]),ae=m.useCallback(re=>{const oe=C?.homeAssistant;if(!oe?.enabled||!oe?.connected||oe?.lightPolicy?.locked||oe?.lightPolicy?.lockedOn)return;const ye=(oe.entities||[]).filter(xe=>(xe.type==="light"||xe.type==="switch")&&xe.available!==!1&&xe.state!=="unavailable");if(ye.length!==0){if(re==="on"){const xe=ye.find(Oe=>Oe.state!=="on");xe&&E(xe.id,"on").catch(()=>{});return}if(re==="off")for(let xe=ye.length-1;xe>=0;xe-=1){const Oe=ye[xe];if(Oe.state==="on"){E(Oe.id,"off").catch(()=>{});break}}}},[E,C?.homeAssistant]);m.useEffect(()=>{function re(ye){if(Z0()||eA(ye))return;const xe=F0(ye);if(xe.length===0)return;const Oe=new Set(xe);if(ht(M.chatFocus,Oe)){ye.preventDefault(),ee(),N||w();return}xe.some(Ae=>B.has(Ae))&&ye.preventDefault();const ze=xe.filter(Ae=>!z.current.has(Ae));if(ze.forEach(Ae=>z.current.add(Ae)),ze.length>0)if(ze.some(Ae=>M.driveMacro?.has(Ae)))s("drive"),d("drive-sequence");else if(ze.some(Ae=>M.dockMacro?.has(Ae)))s("dock"),d("seek-dock");else if(ze.some(Ae=>M.nightVisionToggle?.has(Ae)))x();else if(ze.some(Ae=>M.hornHonk?.has(Ae))){if(!ce.current){const Ae=g();ce.current=!!Ae}}else ze.some(Ae=>M.micPtt?.has(Ae))?b(!0):ze.some(Ae=>M.homeAssistantOn?.has(Ae))?ae("on"):ze.some(Ae=>M.homeAssistantOff?.has(Ae))&&ae("off");J(),U(),Y()}function oe(ye){if(Z0())return;F0(ye).forEach(Oe=>z.current.delete(Oe)),ce.current&&!ht(M.hornHonk,z.current)&&(ce.current=!1,v()),ht(M.micPtt,z.current)||b(!1),J(),U(),Y()}function ve(){ee()}return window.addEventListener("keydown",re,{capture:!0}),window.addEventListener("keyup",oe,{capture:!0}),window.addEventListener("blur",ve),()=>{window.removeEventListener("keydown",re,{capture:!0}),window.removeEventListener("keyup",oe,{capture:!0}),window.removeEventListener("blur",ve)}},[B,A,Y,J,U,w,N,M.chatFocus,M.dockMacro,M.driveMacro,M.hornHonk,M.micPtt,ee,d,b,s,h,ie,g,v,ae]);const pe=m.useRef(ee);return m.useEffect(()=>{pe.current=ee},[ee]),m.useEffect(()=>{pe.current()},[n.roverId]),m.useEffect(()=>{ce.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{T(),ie()},[T,ie]),null}const sA=1.6;function jg(n){if(!n)return"unknown::none::0::0";const s=n.id||"unknown",i=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,f=Array.isArray(n.buttons)?n.buttons.length:0;return`${s}::${i}::${o}::${f}`}function lA(n){return JSON.parse(JSON.stringify(n??{}))}function Ag(n,s){const i=lA(s);return i.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},i}function os(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function fi(n,s){if(!n)return 0;const i=Math.abs(n);return s==="expo"?Math.sign(n)*Math.pow(i,sA):n}function uf(n,s){const i=Math.abs(n);if(i<=s)return 0;const o=(i-s)/(1-s);return Math.sign(n)*o}function iA(n,s,i){const o=Math.hypot(n,s);if(o<=i)return{x:0,y:0};const d=(o-i)/(1-i)/o;return{x:n*d,y:s*d}}function po(n,s){if(!n||!Array.isArray(n.axes))return null;const i=n.axes[s];return Number.isFinite(i)?os(i):null}function Of(n,s){if(!n||!Array.isArray(n.buttons))return null;const i=n.buttons[s];if(!i)return null;const o=typeof i.value=="number"?i.value:i.pressed?1:0;return{pressed:!!(i.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function ff(n,s=[]){for(const i of s)if(i){if(i.kind==="axis"){const o=po(n,i.index);if(o===null)continue;return{value:i.invert?-o:o,source:i}}if(i.kind==="buttonAxis"){const o=Of(n,i.index);if(!o)continue;return{value:os(o.value),source:i}}}return{value:0,source:null}}function rA(n,s=[]){for(const i of s){if(!i||i.kind!=="axisPair")continue;const o=po(n,i.x),f=po(n,i.y);if(o===null||f===null)continue;const d=i.invertX?-o:o,h=i.invertY?-f:f;return{x:d,y:h,source:i}}return{x:0,y:0,source:null}}function as(n,s=[]){for(const i of s)if(i){if(i.kind==="button"){const o=Of(n,i.index);if(!o)continue;return{pressed:o.pressed,source:i}}if(i.kind==="axisButton"){const o=po(n,i.index);if(o===null)continue;const f=i.direction||1,d=typeof i.threshold=="number"?i.threshold:.6;return{pressed:o*f>d,source:i}}if(i.kind==="buttonAxis"){const o=Of(n,i.index);if(!o)continue;return{pressed:o.value>.5,source:i}}}return{pressed:!1,source:null}}function Ng(n,s){const i=s?.bindings??{},o=s?.calibration??{},f=i.drive??{},d=rA(n,f.sources);let h=os(d.x),p=os(d.y);const x=Math.min(Math.max(o.driveDeadzone??.18,0),.8),g=iA(h,p,x);h=fi(g.x,o.driveCurve),p=fi(g.y,o.driveCurve);const v=i.cameraTilt??{},b=ff(n,v.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let k=uf(os(b.value),S);k=fi(k,o.cameraCurve);const C=Math.min(Math.max(o.auxDeadzone??.05,0),.6),E=i.mainBrush??{},w=ff(n,E.sources);let A=uf(os(w.value),C);A=fi(A,o.auxCurve);const N=i.sideBrush??{},q=ff(n,N.sources);let M=uf(os(q.value),C);M=fi(M,o.auxCurve);const B=as(n,i.vacuum?.sources),K=as(n,i.allAux?.sources),_=as(n,i.mainReverse?.sources),H=as(n,i.sideReverse?.sources),z=as(n,i.driveMacro?.sources),V=as(n,i.dockMacro?.sources),X=as(n,i.nightVisionToggle?.sources);return{driveVector:{x:h,y:p,boost:!1},cameraAxis:k,auxAxis:{main:A,side:M},buttons:{vacuum:B.pressed,allAux:K.pressed,mainReverse:_.pressed,sideReverse:H.pressed,driveMacro:z.pressed,dockMacro:V.pressed,nightVisionToggle:X.pressed},sources:{drive:d.source,cameraTilt:b.source,mainBrush:w.source,sideBrush:q.source,vacuum:B.source,allAux:K.source,mainReverse:_.source,sideReverse:H.source,driveMacro:z.source,dockMacro:V.source,nightVisionToggle:X.source}}}const pi=new Set;let sl=null,ol={pads:[],timestamp:0},Zr=!1,Ir=null;function P0(){return wg().some(n=>n?.connected!==!1)}function wg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function oA(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:jg(n)}}function xo(){ol={pads:wg().map(oA),timestamp:typeof performance<"u"?performance.now():Date.now()},pi.forEach(s=>s(ol))}function Cg(){if(xo(),ol.pads.length===0){Bf();return}sl=requestAnimationFrame(Cg)}function W0(){sl||(xo(),ol.pads.length!==0&&(sl=requestAnimationFrame(Cg)))}function Bf(){sl&&(cancelAnimationFrame(sl),sl=null)}function Eg(n){if(pi.add(n),!Zr&&typeof window<"u"){const s=()=>{xo(),pi.size!==0&&(P0()?W0():Bf())};window.addEventListener("gamepadconnected",s),window.addEventListener("gamepaddisconnected",s),Ir=s,Zr=!0}return P0()?W0():xo(),n(ol),()=>{pi.delete(n),pi.size===0&&(Bf(),Zr&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Ir),window.removeEventListener("gamepaddisconnected",Ir),Ir=null,Zr=!1))}}function cA(){const[n,s]=m.useState(ol);return m.useEffect(()=>Eg(s),[]),n}const tl="gamepad",ss={x:0,y:0,boost:!1},ls={main:0,side:0,vacuum:0},uA=100,fA=100;function df(n,s){return n&&s&&n.x===s.x&&n.y===s.y&&n.boost===s.boost}function mf(n,s){return n&&s&&n.main===s.main&&n.side===s.side&&n.vacuum===s.vacuum}function dA(n){return n?Math.hypot(n.x||0,n.y||0):0}function mA(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function hA(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function pA(){const{state:n,actions:{setMode:s,setDriveVector:i,setAuxMotors:o,setServoAngle:f,runMacro:d,toggleNightVision:h,registerInputState:p}}=_t(),{value:x,save:g}=He("gamepad",Oa),v=m.useRef(new Set),b=m.useRef(ss),S=m.useRef(ls),k=m.useRef({main:!1,side:!1}),C=m.useRef(new Map),E=m.useRef(0),w=m.useRef(0),A=m.useRef(0),N=m.useRef(null),q=m.useCallback(_=>{const H=_.signature??jg(_);x?.profiles?.[H]||v.current.has(H)||(v.current.add(H),g(z=>{const V=z??Oa;if(V.profiles?.[H])return V;const X=V?.defaults?.profile??ia,te=Ag(_,X);return{...V,profiles:{...V.profiles??{},[H]:te}}}))},[x?.profiles,g]),M=m.useCallback((_,H)=>{const z=C.current.get(_)||!1;return C.current.set(_,H),H&&!z},[]),B=m.useCallback((_,H)=>{const z=n.camera?.config;if(!z)return;const V=typeof performance<"u"?performance.now():Date.now(),X=H?.cameraMode??"absolute",te=Math.max(1,Math.min(180,H?.cameraSensitivity??60));if(X==="velocity"){const $=Math.min(50,V-A.current||16),J=_*te*($/1e3);if(Math.abs(J)<.01)return;const de=(typeof N.current=="number"?N.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof z.homeAngle=="number"?z.homeAngle:0)+J;f(de),N.current=de,A.current=V;return}const ue=typeof z.minAngle=="number"?z.minAngle:-45,ce=typeof z.maxAngle=="number"?z.maxAngle:45,Y=typeof z.homeAngle=="number"?z.homeAngle:(ue+ce)/2,T=_<0?Y+_*(Y-ue):Y+_*(ce-Y);typeof N.current=="number"&&Math.abs(N.current-T)<.35&&V-A.current<80||(A.current=V,N.current=T,f(T))},[f,n.camera?.angle,n.camera?.config]),K=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>Eg(_=>{const H=hA(_.pads,K);if(!H){df(b.current,ss)||(b.current=ss,i(ss,{source:tl})),mf(S.current,ls)||(S.current=ls,o(ls)),C.current=new Map,k.current={main:!1,side:!1},E.current=0,w.current=0,p(tl,{connected:!1});return}if(Ij()){df(b.current,ss)||(b.current=ss,i(ss,{source:tl})),mf(S.current,ls)||(S.current=ls,o(ls)),C.current=new Map,k.current={main:!1,side:!1},p(tl,{connected:!0,blocked:!0});return}q(H);const z=H.signature,V=x?.profiles?.[z]??x?.defaults?.profile??ia,X=Ng(H,V);if(!df(X.driveVector,b.current)){const J=typeof performance<"u"?performance.now():Date.now();(dA(X.driveVector)<.02||J-E.current>=uA)&&(b.current=X.driveVector,E.current=J,i(X.driveVector,{source:tl}))}const te=V.calibration?.auxSideScale??.55,ue=Math.round(Math.min(Math.abs(X.auxAxis.main),1)*127),ce=Math.round(Math.min(Math.abs(X.auxAxis.side),1)*127),Y=k.current.main?-ue:ue,T=k.current.side?-Math.round(ce*te):Math.round(ce*te);let $={main:X.auxAxis.main!==0?Y:0,side:X.auxAxis.side!==0?T:0,vacuum:X.buttons.vacuum?127:0};if(X.buttons.allAux&&($={main:127,side:127,vacuum:127}),!mf($,S.current)){const J=typeof performance<"u"?performance.now():Date.now();(mA($)||J-w.current>=fA)&&(S.current=$,w.current=J,o($))}X.buttons.mainReverse&&M("mainReverse",!0)?k.current.main=!k.current.main:X.buttons.mainReverse||M("mainReverse",!1),X.buttons.sideReverse&&M("sideReverse",!0)?k.current.side=!k.current.side:X.buttons.sideReverse||M("sideReverse",!1),X.buttons.driveMacro&&M("driveMacro",!0)?(s("drive"),d("drive-sequence")):X.buttons.driveMacro||M("driveMacro",!1),X.buttons.dockMacro&&M("dockMacro",!0)?(s("dock"),d("seek-dock")):X.buttons.dockMacro||M("dockMacro",!1),X.buttons.nightVisionToggle&&M("nightVisionToggle",!0)?h():X.buttons.nightVisionToggle||M("nightVisionToggle",!1),Math.abs(X.cameraAxis)>.001&&B(X.cameraAxis,V.calibration),p(tl,{connected:!0,signature:z,id:H.id,index:H.index,axes:H.axes,buttons:H.buttons,drive:X.driveVector,aux:$,cameraAxis:X.cameraAxis,bindings:X.sources})}),[K,q,x?.defaults?.profile,x?.profiles,M,B,p,d,o,i,s,h]),null}function kg(n){const s=n?.sensors||{},i=s.oiMode?.label||"Unknown",o=i.toLowerCase(),f=s.chargingState?.label||"",d=!!s.chargingSources?.homeBase,h=d&&f.toLowerCase()!=="not charging"&&f!=="";return{driving:o==="full",docked:d,charging:h,dockedNotCharging:d&&!h,dockingInProgress:!d&&!h&&o==="passive",oiLabel:i,chargingLabel:f}}function Mg(n){const s=dl(n);return m.useMemo(()=>kg(s),[s])}function nl({label:n,value:s,tone:i="neutral"}){const o=i==="good"?"border-emerald-200 bg-emerald-600 text-white":i==="warn"?"border-amber-200 bg-amber-600 text-white":i==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return r.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:r.jsx("span",{className:"text-base font-semibold md:text-lg",children:s})})}function ex({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function hf({label:n,tone:s}){const i=s==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":s==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return r.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${i}`,children:n})}function xA({instructions:n,onConfirm:s,onCancel:i,pending:o}){return r.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Dock Rover"}),r.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),r.jsx(Lf,{steps:n.steps,tone:"indigo"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[r.jsx("button",{type:"button",onClick:i,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),r.jsx("button",{type:"button",disabled:o,onClick: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 Rg({layout:n="desktop",expand:s=!1,fill:i=!1,driveDockState:o,compactHeightClass:f=""}){const d=n==="mobile",{state:{roverId:h,keymap:p},actions:x}=_t(),g=dl(h),v=o??kg(g),{driving:b,docked:S,charging:k,dockingInProgress:C}=v,[E,w]=m.useState(null),[A,N]=m.useState(!1),[q,M]=m.useState(!1),B=!h||E!==null,K=!h||E!==null,_=An(p?.driveMacro?.[0]),H=An(p?.dockMacro?.[0]),z={summary:"You are about to trigger an automatic docking attempt! To have a successful dock:",steps:["Line up the rover straight in front of the dock","Make sure the rover is about one foot or half a meter away from the dock","Press Confirm Dock to begin the docking process"]},V="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"]},te=S?"Docked":"Undocked",ue=S?"good":"bad",ce=k?"Charging":S?"Charging in 5s":"—",Y=k?"good":S?"warn":"bad",T=async()=>{if(!(!h||E)){w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Je){alert(Je.message)}finally{w(null)}}},$=async()=>{if(!(!h||E)){N(!1),M(!1),w("drive");try{x.setMode("drive"),await x.runMacro("drive-sequence")}catch(Je){alert(Je.message)}finally{w(null)}}},J=async()=>{if(!(!h||E)){w("dock");try{x.setMode("dock"),await x.runMacro("seek-dock")}catch(Je){alert(Je.message)}finally{w(null),N(!1),M(!1)}}},ie=()=>{K||(M(!0),N(!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",U="items-center justify-between",ee="items-center justify-center",ae=d?"text-sm font-semibold":"",pe="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",re="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",oe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ve="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe=s||C,Oe=xe?"h-full flex-1":i?"flex-1":"",ze=d&&!xe?f:"",Ae=d&&!xe?ee:U,tt=d&&!xe&&b&&S;if(!b&&!C)return r.jsxs("button",{type:"button",onClick:$,onContextMenu:Je=>Je.preventDefault(),disabled:B,className:`${de} ${Oe} ${ze} ${R} ${Ae} ${ae} ${pe}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[_?r.jsx(ex,{label:_}):null,r.jsx(hf,{label:"Click to start",tone:"emerald"})]}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-emerald-50/90",children:X.summary}),r.jsx(Lf,{steps:X.steps,tone:"emerald"})]}):null]}),xe?r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:te,tone:ue}),r.jsx(nl,{label:"Charge",value:ce,tone:Y})]}):null]});if(C){const Je={summary:"If the rover is failing to dock, click to drive and try again.",steps:["The rover should be slowly wiggling towards the dock","If it is obviously not working, press this button to enter driving mode and try again"]};return r.jsxs("button",{type:"button",disabled:B,onClick:T,onContextMenu:vt=>vt.preventDefault(),className:`${de} ${Oe} ${ze} ${R} ${Ae} ${ae} ${re}`,children:[r.jsxs("div",{className:"space-y-0.5 w-full",children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Docking in Progress"}),xe?r.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:r.jsx(hf,{label:"Return to driving mode",tone:"emerald"})}):null]}),xe?r.jsx("p",{className:"text-sm text-amber-50/90",children:Je.summary}):null]}),xe?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:te,tone:ue}),r.jsx(nl,{label:"Charge",value:ce,tone:Y})]}),d?null:r.jsx(Lf,{steps:Je.steps,tone:"amber"})]}):null]})}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",disabled:K,onClick:ie,onContextMenu:Je=>Je.preventDefault(),className:d?`flex w-full ${de} ${ze} ${R} ${Ae} ${ae} ${tt?ve:oe}`:`${de} ${Oe} ${R} ${U} ${ae} ${oe}`,children:[r.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[r.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:tt?"Docked!":"Dock and Charge"}),!d&&xe?r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[H?r.jsx(ex,{label:H}):null,r.jsx(hf,{label:"Click to begin docking",tone:"indigo"})]}):null]}),!d&&xe&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm text-indigo-50/90",children:V}),r.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[r.jsx(nl,{label:"Dock",value:te,tone:ue}),r.jsx(nl,{label:"Charge",value:ce,tone:Y})]}),r.jsx("div",{className:"text-xs text-indigo-100/80",children:"Line up straight, about 1 foot away, before docking."})]})]}),q||!d&&A?r.jsx(xA,{instructions:z,pending:E==="dock",onCancel:()=>{M(!1),N(!1)},onConfirm:J}):null]})}function Lf({steps:n,tone:s="emerald"}){const i=s==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":s==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=s==="emerald"?"text-emerald-200":s==="amber"?"text-amber-200":"text-indigo-200";return r.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${i}`,children:n.map((f,d)=>r.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[r.jsxs("div",{className:"flex items-start",children:[r.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[d+1,"."]}),r.jsx("span",{className:"align-top",children:f})]}),d<n.length-1?r.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},f))})}function pf(n){return typeof n=="boolean"}function qg({nightVisionOn:n,disabled:s,onToggle:i,keyLabel:o,className:f="",heightClass:d=""}){const[h,p]=m.useState(pf(n)?n:null);m.useEffect(()=>{pf(n)&&p(n)},[n]);const x=pf(h),g=x?h:!1,v=x?g?"On":"Off":"—",b=g?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(s)return;const C=x?!g:!0;p(C),i?.(C)},k=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",g?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",d,f].filter(Boolean).join(" "),[f,g,d]);return r.jsxs("button",{type:"button",onClick:S,onContextMenu:C=>C.preventDefault(),disabled:s,"aria-pressed":g,className:k,children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?r.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:v})]})}function xf(n){const s=Number(n);return!Number.isFinite(s)||s<=0?0:Math.min(5e3,Math.round(s))}function Tg({disabled:n,onStart:s,onStop:i,keyLabel:o,active:f,heat:d=0,className:h="",defaultShowSettings:p=!0,showSettingsToggle:x=!1,compactSettings:g=!1}){const[v,b]=m.useState(!1),[S,k]=m.useState(p),{value:C,save:E}=He("horn",cs),[w,A]=m.useState(C?.waveform||cs.waveform),[N,q]=m.useState(()=>[...Array.isArray(C?.freqs)?C.freqs:cs.freqs,0,0,0,0].slice(0,4).map(T=>xf(T)));m.useEffect(()=>{A(C?.waveform||cs.waveform),Array.isArray(C?.freqs)&&q([...C.freqs,0,0,0,0].slice(0,4).map(Y=>xf(Y)))},[C?.freqs,C?.waveform]);const M=!!f,B=Math.max(0,Math.min(1,Number(d)||0)),K=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",M?"border-fuchsia-300/70 bg-fuchsia-700 text-fuchsia-50":"border-cyan-300/70 bg-cyan-900 text-cyan-50 hover:bg-cyan-800","disabled:opacity-50",h].filter(Boolean).join(" "),[h,M]),_=()=>{n||v||(b(!0),s?.())},H=()=>{v&&(b(!1),i?.())};m.useEffect(()=>{!M&&v&&b(!1)},[M,v]);const z=w==="sine"?"sine":"saw",V=m.useCallback(Y=>{const T=Y.target.value==="sine"?"sine":"saw";A(T),E($=>({...$??{},waveform:T}))},[E]),X=m.useCallback((Y,T)=>{q($=>{const J=[...$];return J[Y]=xf(T),E(ie=>({...ie??{},freqs:J})),J})},[E]),te=Y=>{if(n)return;const T=Y.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(Y.preventDefault(),_())},ue=Y=>{const T=Y.target?.tagName?.toLowerCase();T==="input"||T==="select"||T==="option"||T==="label"||T==="button"||(Y.preventDefault(),H())},ce=x?r.jsx("button",{type:"button",onClick:Y=>{Y.preventDefault(),k(T=>!T)},className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white/90 hover:text-white",children:S?"Hide":"Settings"}):null;return r.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:te,onPointerUp:ue,onPointerLeave:H,onPointerCancel:H,onContextMenu:Y=>Y.preventDefault(),onBlur:H,className:K,children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${B*100}%, rgba(0,0,0,0) ${B*100}%)`}}),r.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${M?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),r.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[r.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[r.jsx("span",{children:"Horn"}),o?r.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),ce,r.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${M?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:M?"Honk":"Hold"})]}),S?g?r.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:N.map((Y,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:Y,onChange:$=>X(T,$.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))})]}):r.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-slate-300",children:"Wave"}),r.jsxs("select",{value:z,onChange:V,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[r.jsx("option",{value:"saw",children:"Saw"}),r.jsx("option",{value:"sine",children:"Sine"})]})]}),N.map((Y,T)=>r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("span",{className:"text-[0.6rem] text-slate-400",children:T+1}),r.jsx("input",{type:"number",min:0,max:5e3,step:1,value:Y,onChange:$=>X(T,$.target.value),className:"w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"})]},`horn-freq-${T}`))]}):null]})}function Jr(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function tx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Dg({value:n,min:s,max:i,step:o=.5,label:f="Camera Tilt",orientation:d="horizontal",onChange:h,onCommit:p,throttleMs:x=0,disabled:g=!1,keyDownLabel:v,keyUpLabel:b,className:S="",labelRowClass:k="",labelClass:C="",valueClass:E="",sliderClass:w="",endpointClass:A="",endpointLabelClass:N="",accentClass:q="",showValue:M=!0,showEndpoints:B}){const K=d==="vertical",H=typeof B=="boolean"?B:!K,[z,V]=m.useState(n),X=m.useRef(!1),te=m.useRef(null);m.useEffect(()=>{X.current||V(n)},[n]),m.useEffect(()=>()=>{te.current&&clearTimeout(te.current)},[]);const ue=J=>{if(h){if(x>0){te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{h(J)},x);return}h(J)}},ce=J=>{const ie=Number.parseFloat(J.target.value);Number.isNaN(ie)||(X.current=!0,V(ie),ue(ie))},Y=()=>{X.current=!1,te.current&&(clearTimeout(te.current),te.current=null),p?p(z):x>0&&h?.(z)};if(typeof s!="number"||typeof i!="number")return null;const T=[K?"h-28 w-5":"w-full",q,w].filter(Boolean).join(" "),$=r.jsx("input",{type:"range",orient:K?"vertical":void 0,min:s,max:i,step:o,value:Number.isFinite(z)?z:s,onChange:ce,onMouseUp:Y,onTouchEnd:Y,onPointerUp:Y,disabled:g,className:T,style:K?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return K?r.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[M?r.jsx("div",{className:`flex flex-col items-center ${k}`.trim(),children:r.jsx("span",{className:E,children:Jr(n)})}):null,r.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[r.jsx("span",{className:C,children:f}),$]})]}):r.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[r.jsxs("div",{className:`flex items-center justify-between ${k}`.trim(),children:[r.jsx("span",{className:C,children:f}),M?r.jsx("span",{className:E,children:Jr(n)}):null]}),r.jsxs("div",{children:[$,H?r.jsxs("div",{className:`mt-0 flex items-center justify-between ${A}`.trim(),children:[r.jsxs("span",{className:`flex items-center gap-0.5 ${N}`.trim(),children:[v?r.jsx(tx,{label:v}):null,Jr(s)]}),r.jsxs("span",{className:`flex items-center gap-0.5 ${N}`.trim(),children:[Jr(i),b?r.jsx(tx,{label:b}):null]})]}):null]})]})}const Pr="mobile-joystick",gA=80,vA=.15,yA={main:0,side:0,vacuum:0},bA={main:127,side:127,vacuum:127},SA={main:-127,side:-127,vacuum:-127};function jA({disabled:n,layout:s,radius:i,onMove:o,onStop:f}){const d=m.useRef(null),h=m.useRef(null),p=m.useRef({x:0,y:0}),[x,g]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{h.current=null,g({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),f?.()},[f]),b=m.useCallback(E=>{if(n||h.current!==null)return;E.preventDefault();const w=d.current;if(!w)return;const A=w.getBoundingClientRect(),N=E.clientX-A.left,q=E.clientY-A.top;p.current={x:N,y:q},h.current=E.pointerId,w.setPointerCapture?.(E.pointerId),g({active:!0,base:{x:N,y:q},knob:{x:0,y:0}})},[n]),S=m.useCallback(E=>{if(n||h.current!==E.pointerId)return;E.preventDefault();const w=d.current;if(!w)return;const A=w.getBoundingClientRect(),N=E.clientX-A.left,q=E.clientY-A.top,M=N-p.current.x,B=q-p.current.y,K=Math.min(Math.hypot(M,B),i),_=Math.atan2(B,M),H=Math.cos(_)*K,z=Math.sin(_)*K,V={x:rl(H/i),y:rl(-z/i),boost:!1};g(X=>({...X,knob:{x:H,y:z}})),o?.(V)},[n,o]),k=m.useCallback(E=>{if(h.current!==E.pointerId)return;E.preventDefault(),d.current?.releasePointerCapture?.(E.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),r.jsxs("div",{ref:d,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:S,onPointerUp:k,onPointerLeave:k,onPointerCancel:k,onContextMenu:E=>E.preventDefault(),children:[!x.active&&r.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[r.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),r.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),x.active&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:x.base.x,top:x.base.y}}),r.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:x.base.x+x.knob.x,top:x.base.y+x.knob.y}})]})]})}function AA({layout:n}){const{state:{roverId:s},actions:{setDriveVector:i,registerInputState:o}}=_t(),f=Mg(s),d=f.docked&&!f.driving,h=d||f.dockingInProgress,p=!s,x=gA,g=vA,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{p&&(v.current={x:0,y:0,boost:!1})},[p]);const b=m.useCallback((E={})=>{if(p)return;const w={x:rl(E.x??0),y:rl(E.y??0),boost:!!E.boost},A={x:v.current.x+(w.x-v.current.x)*(1-g),y:v.current.y+(w.y-v.current.y)*(1-g),boost:w.boost};v.current=A,i(A,{source:Pr}),o(Pr,{vector:A,lastEvent:"move"})},[p,o,i,g]),S=m.useCallback(()=>{if(p)return;const E={x:0,y:0,boost:!1};v.current=E,i(E,{source:Pr}),o(Pr,{vector:E,lastEvent:"stop"})},[p,o,i]),C=`flex h-full flex-col gap-0.5 text-slate-100 ${d?"max-h-screen self-start":""}`;return r.jsxs("div",{className:C,children:[r.jsx(Rg,{layout:"mobile",expand:h,driveDockState:f,compactHeightClass:"min-h-[5rem]"}),h?null:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(jA,{disabled:p,layout:n,radius:x,onMove:b,onStop:S})})]})}function nx({id:n,label:s,values:i,color:o,disabled:f,onPress:d,onRelease:h}){return r.jsx("button",{type:"button",disabled:f,onPointerDown:p=>{p.preventDefault(),d(n,i)},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})}function NA({layout:n}){const{state:{roverId:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,setAuxMotors:p,startHorn:x,stopHorn:g}}=_t(),v=!s,b=m.useRef(null),S=i?.config,k=!!(s&&i?.enabled&&S),C=!!(s&&f?.nightVision),E=f?.nightVisionState,w=!!(s&&f?.horn),A=o?.overheated,N=typeof S?.minAngle=="number"?S.minAngle:-45,q=typeof S?.maxAngle=="number"?S.maxAngle:45,M=typeof i?.angle=="number"?i.angle:typeof S?.homeAngle=="number"?S.homeAngle:(N+q)/2,B=m.useCallback(H=>{C&&h(H)},[C,h]),K=m.useCallback((H,z)=>{v||(b.current=H,p(z))},[v,p]),_=m.useCallback(H=>{v||b.current===H&&(b.current=null,p(yA))},[v,p]);return r.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[r.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[r.jsx(nx,{id:"aux-vac-forward",label:"Vacuum Forward",values:bA,color:"bg-fuchsia-600",disabled:v,onPress:K,onRelease:_}),r.jsx(nx,{id:"aux-vac-backward",label:"Vacuum Backward",values:SA,color:"bg-fuchsia-800",disabled:v,onPress:K,onRelease:_})]}),r.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[k?r.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:r.jsx(Dg,{value:M,min:N,max:q,step:.5,onChange:d,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,C?r.jsx(qg,{nightVisionOn:E?.nightVisionOn,disabled:v,onToggle:B,heightClass:"h-full"}):null]}),r.jsx("div",{className:"min-h-0",children:w?r.jsx(Tg,{disabled:v||A,onStart:x,onStop:g,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function go({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(NA,{layout:n})})}function vo({layout:n,className:s=""}){return r.jsx("div",{className:`flex flex-col gap-0.5 ${s}`.trim(),children:r.jsx(AA,{layout:n==="landscape"?"landscape":"portrait"})})}function wA({swapColumns:n=!1}){const s="h-[min(60svh,24rem)]",i=n?r.jsx(vo,{layout:"portrait",className:s}):r.jsx(go,{layout:"portrait",className:s}),o=n?r.jsx(go,{layout:"portrait",className:s}):r.jsx(vo,{layout:"portrait",className:s});return r.jsx("section",{className:"panel",children:r.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[i,o]})})}function CA(n=[],s={}){const i=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(C=>typeof C=="string"?C:C.id),[n]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),v=m.useRef([]),[b,S]=m.useState(0),k=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>S(E=>E+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({});return}if(!v.current.length||!i)return;let C=!1;const E=v.current,w=(N={},q)=>{if(C||!N.id||!q)return;const M=q.byteLength??q.length??0,B=Date.now(),K=k.current.get(N.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!_.lastLogAt||B-_.lastLogAt>=1e4){const X=_.count?_.totalBytes/_.count:0;console.log("[roomCamera]",N.id,`frame=${M}B`,`avg=${Math.round(X)}B`,`count=${_.count}`),_.lastLogAt=B}k.current.set(N.id,_);const H=new Blob([q],{type:"image/jpeg"}),z=URL.createObjectURL(H),V=p.current.get(N.id);V&&URL.revokeObjectURL(V),p.current.set(N.id,z),h(X=>({...X,[N.id]:{status:"playing",ts:N.ts||Date.now(),error:null,objectUrl:z}}))},A=(N={})=>{C||!N.id||h(q=>({...q,[N.id]:{...q[N.id]||{},status:N.error?"error":q[N.id]?.status||"connecting",error:N.error||null,ts:N.ts||q[N.id]?.ts||null,objectUrl:q[N.id]?.objectUrl||null}}))};return i.on("roomCamera:frame",w),i.on("roomCamera:status",A),i.emit("roomCamera:subscribe",{ids:E},(N={})=>{N.error}),()=>{C=!0,i.emit("roomCamera:unsubscribe",{ids:E}),i.off("roomCamera:frame",w),i.off("roomCamera:status",A),p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear()}},[i,g,o,b]),d}function EA({feed:n,label:s}){const[i,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(d=>!d))},[n?.ts,n?.objectUrl]);const f=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return r.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?r.jsx("img",{src:n.objectUrl,alt:s,className:"h-full w-full object-cover"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:s}),r.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[r.jsx("span",{className:`h-2 w-2 rounded-full ${i?"bg-emerald-400":"bg-slate-500"}`}),r.jsx("span",{children:f})]})]})}function kA(){return r.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),r.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const _g=["horizontal","vertical"];function gf(n,s){return _g.includes(n)?n:s}function cd({defaultOrientation:n="horizontal",orientation:s,hideLayoutToggle:i=!1,hideHeader:o=!1,panelId:f=null}){const{session:d}=nn(),h=d?.roomCameras||[],p=CA(h.map(w=>({id:w.id}))),{value:x,save:g}=He("roomCameraPanels",{}),[v,b]=m.useState(()=>gf(f?x?.[f]:n,"horizontal"));m.useEffect(()=>{if(!f)return;const w=x?.[f];w&&b(gf(w,"horizontal"))},[f,x?.[f]]);const S=s?gf(s,"horizontal"):v,k=S==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!i&&!s&&h.length>0,E=w=>{b(w),f&&g(A=>({...A||{},[f]:w}))};return h.length===0?r.jsx(kA,{}):r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&r.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room cameras"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:C&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("span",{className:"text-slate-500",children:"Layout:"}),r.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:_g.map(w=>r.jsx("button",{type:"button",className:`px-1 py-0.5 ${S===w?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>E(w),children:w==="vertical"?"Vertical":"Grid"},w))})]})})]}),r.jsx("div",{className:k,children:h.map(w=>{const A=p[w.id]||null;return r.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:r.jsx(EA,{feed:A,label:w.name||w.id})},w.id)})})]})}function ud(){const n=ft(s=>s.logs);return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Server logs"}),r.jsx("span",{children:n.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?r.jsx("p",{children:"No logs yet."}):n.slice().reverse().map(s=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:s.timestamp})," ",r.jsxs("span",{className:"text-lime-400",children:["[",s.level,"]"]})," ",s.label&&r.jsxs("span",{className:"text-teal-400",children:["[",s.label,"]"]})," ",r.jsx("span",{children:s.message})]},s.id))})]})}function MA(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 i=n.key;return i||(i=n.type==="room"?`room:${s}`:s),{type:n.type,id:s,key:i}}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 RA(n=[]){const s=new Set,i=[];return n.forEach(o=>{!o?.key||s.has(o.key)||(s.add(o.key),i.push(o))}),i.sort((o,f)=>o.key.localeCompare(f.key))}function ji(n=[],s={}){const i=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useMemo(()=>Array.isArray(n)?RA(n.map(MA).filter(Boolean)):[],[n]),x=m.useMemo(()=>{const k=p.map(C=>`${C.type}:${C.id}:${C.key}`).join("|");return f?`${k}|v:${f}`:k},[p,f]),g=m.useRef([]),[v,b]=m.useState(0);return m.useEffect(()=>{if(!i)return;const k=()=>b(C=>C+1);return i.on("connect",k),()=>{i.off("connect",k)}},[i]),m.useEffect(()=>{g.current=p},[p]),m.useEffect(()=>{if(!x||!o){h({});return}const k=g.current;let C=!1;function E(w){const A=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};i.emit("video:request",A,(N={})=>{C||h(q=>({...q,[w.key]:N}))})}return k.forEach(w=>{E(w)}),()=>{C=!0}},[i,x,o,v]),m.useMemo(()=>{if(!x||!o)return{};const k={};return p.forEach(C=>{d[C.key]&&(k[C.key]=d[C.key])}),k},[x,d,p])}function fd(n=[],s={}){const i=tn(),{enabled:o=!0,version:f=null}=s,[d,h]=m.useState({}),p=m.useRef(new Map),x=m.useMemo(()=>n.map(C=>typeof C=="string"?C:C.id).filter(Boolean),[n]),g=m.useMemo(()=>{const C=x.join("|");return f?`${C}|v:${f}`:C},[x,f]),v=m.useRef([]),[b,S]=m.useState(0),k=m.useRef(new Map);return m.useEffect(()=>{if(!i)return;const C=()=>S(E=>E+1);return i.on("connect",C),()=>i.off("connect",C)},[i]),m.useEffect(()=>{v.current=x},[g,x]),m.useEffect(()=>{p.current.forEach(C=>URL.revokeObjectURL(C)),p.current.clear(),h({})},[g]),m.useEffect(()=>{if(!o){p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear(),h({});return}if(!v.current.length||!i)return;let C=!1;const E=v.current,w=(N={},q)=>{if(C||!N.id||!q)return;const M=q.byteLength??q.length??0,B=Date.now(),K=k.current.get(N.id)||{count:0,totalBytes:0,lastLogAt:0},_={count:K.count+1,totalBytes:K.totalBytes+M,lastLogAt:K.lastLogAt};if(!_.lastLogAt||B-_.lastLogAt>=1e4){const X=_.count?_.totalBytes/_.count:0;console.log("[roverSnapshot]",N.id,`frame=${M}B`,`avg=${Math.round(X)}B`,`count=${_.count}`),_.lastLogAt=B}k.current.set(N.id,_);const H=new Blob([q],{type:"image/jpeg"}),z=URL.createObjectURL(H),V=p.current.get(N.id);V&&URL.revokeObjectURL(V),p.current.set(N.id,z),h(X=>({...X,[N.id]:{status:"playing",ts:N.ts||Date.now(),error:null,objectUrl:z}}))},A=(N={})=>{C||!N.id||h(q=>({...q,[N.id]:{...q[N.id]||{},status:N.error?"error":q[N.id]?.status||"connecting",error:N.error||null,ts:N.ts||q[N.id]?.ts||null,objectUrl:q[N.id]?.objectUrl||null}}))};return i.on("roverSnapshot:frame",w),i.on("roverSnapshot:status",A),i.emit("roverSnapshot:subscribe",{ids:E},(N={})=>{N.error}),()=>{C=!0,i.emit("roverSnapshot:unsubscribe",{ids:E}),i.off("roverSnapshot:frame",w),i.off("roverSnapshot:status",A),p.current.forEach(N=>URL.revokeObjectURL(N)),p.current.clear()}},[i,g,o,b]),d}const qA={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function TA(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 DA(n){if(!n)return{};const s=`${n}:${n}`;return{Authorization:`Basic ${TA(s)}`}}class ax{constructor({url:s,token:i,video:o,onStatus:f,audioOnly:d=!1,receiveAudio:h=!0}){this.url=s,this.token=i,this.video=o,this.audioOnly=d,this.receiveAudio=h,this.pc=null,this.abortController=null,this.onStatus=f}notify(s,i){typeof this.onStatus=="function"&&this.onStatus(s,i)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const s=new RTCPeerConnection(qA);this.pc=s;const i=new MediaStream;s.ontrack=o=>{o.streams[0]?.getTracks().forEach(f=>i.addTrack(f)),this.video.srcObject=i,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?s.addTransceiver("audio",{direction:"recvonly"}):(s.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&s.addTransceiver("audio",{direction:"recvonly"})),s.onconnectionstatechange=()=>{this.notify(s.connectionState)},s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await s.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await s.setLocalDescription(o);const f=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...DA(this.token)},body:o.sdp,signal:this.abortController.signal});if(!f.ok)throw new Error(`WHEP request failed: ${f.status}`);const d=await f.text();await s.setRemoteDescription({type:"answer",sdp:d}),s.getReceivers().forEach(h=>{"playoutDelayHint"in h&&(h.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(s=>s.track?.stop()),this.pc.getReceivers().forEach(s=>s.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function zf({sensors:n={},variant:s="full",size:i,overlay:o=!1}){const f=i||(s==="mini"?190:260),d=f/2,h=f*.07,p=d,x=d+h,g=d*.8,v=g-4,b=g+4,S=g-14,k=g-6,C=g*.65,E=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},A=n?.wheelLeftCurrentMa??0,N=n?.wheelRightCurrentMa??0,q=n?.sideBrushCurrentMa??0,M=n?.mainBrushCurrentMa??0,B=6,K=E.bumpLeft?B:0,_=E.bumpRight?B:0,H=HA({count:6,totalSpan:140,gap:6,startAngle:-70}),z=["L","FL","CL","CR","FR","R"],V=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],X=H.map((Y,T)=>({label:z[T],start:Y.start,end:Y.end,value:V[T]})),te=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],ue=V.filter(Y=>Y!=null),ce=ue.length?Math.max(...ue,1200):1200;return r.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${f}px`,height:`${f}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),r.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",ce]})]}),r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${f}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[r.jsx("circle",{cx:p,cy:x,r:g,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),r.jsx(sx,{cx:p-C,cy:x,current:A,drop:E.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),r.jsx(sx,{cx:p+C,cy:x,current:N,drop:E.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),r.jsx(BA,{cx:p+g*.65,cy:x-g*.55,current:q,overcurrent:w.sideBrush}),r.jsx(LA,{cx:p,cy:x,current:M,overcurrent:w.mainBrush,variant:s,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),X.map(Y=>{const T=zA(Y.value,ce),$=b+4,J=$+28;return r.jsx(_A,{cx:p,cy:x,rBase:J,rTip:$,startDeg:Y.start,endDeg:Y.end,color:T,value:Y.value,max:ce},Y.label)}),te.map(Y=>{const T=UA(Y.value,Y.active);return r.jsx(vf,{cx:p,cy:x,rInner:S,rOuter:k,startDeg:Y.start,endDeg:Y.end,color:T,opacity:1,pulse:!!Y.active},Y.label)}),r.jsx(vf,{cx:p,cy:x,rInner:v-K,rOuter:b-K,startDeg:-70,endDeg:-6,color:E.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!E.bumpLeft}),r.jsx(vf,{cx:p,cy:x,rInner:v-_,rOuter:b-_,startDeg:6,endDeg:70,color:E.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!E.bumpRight})]})]})}function vf({cx:n,cy:s,rInner:i,rOuter:o,startDeg:f,endDeg:d,color:h,pulse:p=!1,opacity:x=1}){const g=(i+o)/2,v=o-i,b=OA(n,s,g,f,d);return r.jsxs(r.Fragment,{children:[r.jsx("path",{d:b,stroke:h,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:x}),p?r.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function _A({cx:n,cy:s,rBase:i,rTip:o,startDeg:f,endDeg:d,color:h,value:p,max:x}){const g=(f+d)/2,v=gi(n,s,o,g),b=Eo(p!=null?p/(x||1):0),S=Math.pow(b,.35),k=i-(i-o)*S,C=gi(n,s,k,f),E=gi(n,s,k,d),w=`M ${v.x} ${v.y} L ${C.x} ${C.y} L ${E.x} ${E.y} Z`;return r.jsx("path",{d:w,fill:h,opacity:1,stroke:"none"})}function OA(n,s,i,o,f){let d=o,h=f;h<=d&&(h+=360);const p=gi(n,s,i,d),x=gi(n,s,i,h);return["M",p.x,p.y,"A",i,i,0,0,1,x.x,x.y].join(" ")}function gi(n,s,i,o){const f=Og(o);return{x:n+i*Math.cos(f),y:s+i*Math.sin(f)}}function Og(n){return(n-90)*Math.PI/180}function dd(n,s){if(s)return"#ef4444";const i=Math.abs(n);return i>900?"#f59e0b":i>300?"#22c55e":"#64748b"}function Eo(n){return Math.max(0,Math.min(1,n))}function sx({cx:n,cy:s,current:i,drop:o,overcurrent:f,label:d}){const h=Math.abs(i),p=Eo(h/1200),x=dd(i,f),g=56,v=14,b=9,S=3,k=g*p,C=d==="L"?-1:1,E=C*(-b/2-S/2),w=C*(v/2+S/2),A=v+b+S+2,N=g+4;return r.jsxs("g",{transform:`translate(${n},${s})`,children:[r.jsx("rect",{x:-A/2,y:-N/2,width:A,height:N,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:E-v/2,y:-g/2,width:v,height:g,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),r.jsx("rect",{x:E-v/2,y:g/2-k,width:v,height:k,fill:x,className:f?"animate-pulse":""}),r.jsx("rect",{x:w-b/2,y:-g/2,width:b,height:g,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),r.jsx("text",{x:0,y:g/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:d})]})}function BA({cx:n,cy:s,current:i,overcurrent:o}){var f=Math.abs(i);f<10&&(f=0);const d=dd(i*3,o),h=43,p=f>0?.65:null;return r.jsxs("g",{style:{transformOrigin:`${n}px ${s}px`,animation:p?`spin ${p}s linear infinite`:"none",animationDirection:p?"reverse":"normal"},children:[r.jsx("circle",{cx:n,cy:s,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(g=>{const v=Og(g),b=n+h*Math.cos(v),S=s+h*Math.sin(v);return r.jsx("line",{x1:n,y1:s,x2:b,y2:S,stroke:d,strokeWidth:"4",strokeLinecap:"round"},g)}),o?r.jsx("circle",{cx:n,cy:s,r:h+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function LA({cx:n,cy:s,current:i,overcurrent:o,variant:f,dirtLeft:d,dirtRight:h}){const p=Math.abs(i),x=dd(i,o),g=1,v=96,b=12,S=`main-brush-pattern-a-${f}`,k=`main-brush-pattern-b-${f}`,C=p>0?.6:null,E=i>=0?1:-1;return r.jsxs("g",{children:[r.jsx("defs",{children:[S,k].map((w,A)=>r.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[r.jsx("rect",{width:"6",height:"6",fill:x,opacity:g}),r.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),C?r.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${E*(A===0?6:-6)}`,dur:`${C}s`,repeatCount:"indefinite"}):null]},w))}),r.jsx("rect",{x:n-v/2,y:s-14,width:v,height:b,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("rect",{x:n-v/2,y:s+4,width:v,height:b,rx:"3",fill:`url(#${k})`,stroke:"#64748b",strokeWidth:"1"}),r.jsx("circle",{cx:n-v/4,cy:s-8,r:3.5,fill:"#fbbf24"}),r.jsx("circle",{cx:n+v/4,cy:s+8,r:3.5,fill:"#fbbf24"}),o?r.jsx("rect",{x:n-v/2-4,y:s-16,width:v+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function zA(n,s){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Eo(n/(s||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function UA(n,s){if(s)return"#ef4444";const i=Eo(n==null?0:n/4095),o=[47,55,69],f=[245,158,11],[d,h,p]=o.map((x,g)=>Math.round(x+(f[g]-x)*i));return`rgb(${d}, ${h}, ${p})`}function HA({count:n,totalSpan:s,gap:i,startAngle:o}){const d=(s-i*(n-1))/n,h=[];let p=o;for(let x=0;x<n;x+=1){const g=p+d;h.push({start:p,end:g}),p=g+i}return h}function Bg(){const{value:n,save:s}=He("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,f=>{s({hudMapDesktop:!!f})}]}const VA={discord:ug,kofi:L0,"ko-fi":L0,wiki:xj,throne:gj},$A={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 GA(){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 YA(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 md({id:n,label:s,url:i,className:o=""}){if(!i)return null;GA();const f=YA(n,s),d=VA[f]||vj,h=$A[f]||null,p=s||n||"Link";return r.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer","aria-label":p,className:`inline-flex items-center w-full px-0.5 py-0.5 text-sm font-medium text-white transition justify-center gap-1 rounded-md ${h?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:h||void 0,children:[r.jsx(d,{className:"mr-0"}),p]})}const Ai=10;function Lg({batteryState:n=null,charge:s=null,config:i=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,f=n?.warnActive??null,d=n?.urgentActive??null,h=i?.Full??null,p=i?.Warn??null,x=i?.Urgent??null,g=s??n?.charge??null;let v=o;if(v==null&&(v=FA({charge:g,full:h,warn:p,urgent:x})),v==null)return{available:!1};const b=Math.max(0,Math.min(1,v/100)),S=f??(p!=null&&g!=null&&g<=p),k=d??(x!=null&&g!=null&&g<=x);return{available:!0,percent:b,percentDisplay:v,warnActive:S,urgentActive:k,warnDisplayPercent:Ai}}function FA({charge:n,full:s,warn:i,urgent:o}){if(n!=null&&s!=null&&i!=null&&o!=null&&s>i&&i>o){const f=Ai/100,d=1-f;if(n<=o)return 0;if(n<=i){const p=(n-o)/(i-o);return Math.round(Math.max(0,Math.min(1,p))*Ai)}if(n>=s)return 100;const h=(n-i)/(s-i);return Math.round((f+Math.max(0,Math.min(1,h))*d)*100)}return null}const XA=1600,QA=800;function Sn(...n){return n.filter(Boolean).join(" ")}function Uf({visual:n,orientation:s="horizontal",variant:i="inline",compact:o=!1,showLabel:f,className:d=""}){const h=i==="background",p=s==="vertical",x=f??!h;if(!n?.available){if(h){const te=Ai,ue=Sn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",k&&!S&&"battery-tick-warn"),ce=p?{bottom:`${te}%`}:{left:`${te}%`},Y=Sn("absolute inset-0 pointer-events-none",d);return r.jsxs("div",{className:Y,children:[r.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),r.jsx("div",{className:ue,style:ce})]})}return p?null:r.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const g=n.percentDisplay??0,v=Math.max(0,Math.min(100,g)),b=n.warnDisplayPercent??Ai,S=!!n.urgentActive,k=!!n.warnActive,C=S?`${QA}ms`:k?`${XA}ms`:void 0,w=h?S||k?"bg-red-500/45":"bg-emerald-500/45":S||k?"bg-red-500":"bg-emerald-500",A=S||k?"bg-red-900/35":"bg-slate-900/35",N=S||k?"bg-red-900/45":"bg-slate-900/35",q=Sn(h?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",p&&!h?"flex flex-col items-center justify-center":"w-full",d);if(h){const te=p?{height:`${v}%`}:{width:`${v}%`},ue=Sn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),ce=Sn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",k&&!S&&"battery-tick-warn"),Y=p?{bottom:`${b}%`}:{left:`${b}%`};return r.jsxs("div",{className:q,children:[r.jsx("div",{className:Sn("absolute inset-0",A,S&&"battery-urgent-flash")}),r.jsx("div",{className:ue,style:{...te,animationDuration:C}}),r.jsx("div",{className:ce,style:Y})]})}const M=Sn("relative overflow-hidden rounded-sm border border-slate-800",S||k?N:"bg-zinc-900/90",S&&"battery-urgent-flash",p?"w-full flex-1":o?"h-4":"h-5"),B=p?{height:`${v}%`}:{width:`${v}%`},K=Sn("absolute",p?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),_=Sn("absolute z-10",p?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",k&&!S&&"battery-tick-warn"),H=p?{bottom:`${b}%`}:{left:`${b}%`},z=`Battery ${g}%`,V=Sn("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=Sn("rounded px-1.5 py-0.5",h?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return r.jsxs("div",{className:q,children:[r.jsxs("div",{className:M,children:[r.jsx("div",{className:K,style:{...B,animationDuration:C}}),r.jsx("div",{className:_,style:H})]}),x&&!p?r.jsx("div",{className:V,children:r.jsx("span",{className:X,children:z})}):null,x&&p?r.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:r.jsxs("span",{className:X,children:[g,"%"]})}):null]})}const lx=2e3,KA=3e3,ZA=3e3,IA=40,JA=1e3;function Ni({sessionInfo:n,audioSessionInfo:s,videoMode:i="whep",snapshotFeed:o=null,qualityNotice:f=null,label:d,roverColor:h=null,forceMute:p=!1,telemetryFrame:x,batteryConfig:g,layoutFormat:v="desktop",hudVariant:b="default",driverLabel:S=null,hudForceMap:k=!1,hudMapPosition:C="top-center",hudLabelScale:E=1,fitParent:w=!1,overcurrentLimiter:A=null,showTurnCue:N=!1,turnTimerText:q=null,turnSeconds:M=null,isActiveDriver:B=!1,idleSkipSeconds:K=null}){const _=ft(be=>be.session),H=m.useRef(null),z=m.useRef(null),V=m.useRef(null),X=m.useRef(null),te=m.useRef(null),ue=m.useRef(null),ce=m.useRef(null),Y=m.useRef(null),[T,$]=m.useState("idle"),[J,ie]=m.useState(null),[de,R]=m.useState("idle"),[U,ee]=m.useState(null),[ae,pe]=m.useState(0),[re,oe]=m.useState(0),[ve,ye]=m.useState(!0),xe=!!s?.url,Oe=i==="snapshot",ze=x?.sensors,{value:Ae}=He("audio",ct),tt=Number.isFinite(Ae?.masterVolume)?Ae.masterVolume:ct.masterVolume,Je=Number.isFinite(Ae?.roverVolume)?Ae.roverVolume:ct.roverVolume,vt=typeof Ae?.mainBrushDuckEnabled=="boolean"?Ae.mainBrushDuckEnabled:typeof Ae?.autoLevelEnabled=="boolean"?Ae.autoLevelEnabled:ct.mainBrushDuckEnabled,le=Number.isFinite(Ae?.mainBrushDuckAmount)?Math.max(0,Math.min(1,Ae.mainBrushDuckAmount)):ct.mainBrushDuckAmount,me=Math.max(0,Math.min(1,tt*Je)),se=ze?.batteryChargeMah??null,P=v==="desktop",fe=!P,Ne=fe?"top-right":C,[pt]=Bg(),Ve=k||fe?!0:pt,st=Lg({charge:se,config:g}),lt=ze?.wheelOvercurrents||null,Bt=lt==null?[]:Object.entries(lt).filter(([,be])=>!!be).map(([be])=>be),it=A?.caps||null,ds=A?.overcurrent?.groups||null,Yt=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugAudio"),La=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugHud"),_o=m.useMemo(()=>{if(!it)return null;const be=Number.isFinite(it?.drive?.cap)?it.drive.cap:1,Fe=Number.isFinite(it?.aux?.cap)?it.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(be,Fe)))},[it]),On=!!A?.isActive,Nt=Bt.length?Bt:On?["limiter"]:[],Ft=_o??(Bt.length?1:0),Mt=!!Nt.length,fa=!!((Number(ze?.mainBrushCurrentMa)||0)>IA||ze?.wheelOvercurrents?.mainBrush),Oo=vt&&fa?1-le:1,ms=Math.max(0,Math.min(1,me*Oo)),hs=vt&&fa&&le>0?`Volume decreased ${Math.round(le*1e3)/10}%`:null,za=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{za.current={hasDedicatedAudio:xe,audioUrl:s?.url||null,mainBrushDuckEnabled:vt,mainBrushDuckAmount:le,mainBrushActive:fa,baseRoverGain:me,effectiveRoverGain:ms}},[xe,s?.url,vt,le,fa,me,ms]);const Pe=m.useCallback((be,Fe={})=>{if(!Yt)return;const Ze=z.current,ke=za.current,$e={event:be,ts:Date.now(),roverLabel:d||null,hasDedicatedAudio:ke.hasDedicatedAudio,audioUrl:ke.audioUrl,mainBrushDuckEnabled:ke.mainBrushDuckEnabled,mainBrushDuckAmount:ke.mainBrushDuckAmount,mainBrushActive:ke.mainBrushActive,baseRoverGain:ke.baseRoverGain,effectiveRoverGain:ke.effectiveRoverGain,element:Ze?{muted:Ze.muted,volume:Ze.volume,paused:Ze.paused,ended:Ze.ended,readyState:Ze.readyState,networkState:Ze.networkState}:null,...Fe};try{console.log(`[AudioDebug] ${be} ${JSON.stringify($e)}`)}catch{console.log("[AudioDebug]",be,$e)}},[Yt,d]),Bn=_?.socials?.find(be=>String(be?.id||be?.label||"").toLowerCase()==="discord")?.url||_?.discord?.invite||null;m.useEffect(()=>{La&&console.log("[OvercurrentHUD]",{overlayVisible:Mt,overlayMotors:Nt,overlayFill:Ft,limiterActive:On,limiterCaps:it,limiterGroups:ds,wheelOvercurrents:lt})},[La,Ft,Nt,Mt,On,it,ds,lt]),m.useEffect(()=>{Pe("settings/update")},[Pe]);const Cn=m.useCallback(()=>{clearTimeout(V.current),V.current=setTimeout(()=>pe(Date.now()),lx)},[]),Ln=m.useCallback(()=>{clearTimeout(X.current),X.current=setTimeout(()=>oe(Date.now()),lx)},[]),ps=m.useCallback(async()=>{const be=H.current;if(be)try{be.muted=!0,await be.play()}catch{}},[]),ml=m.useCallback((be=0)=>{if(p||xe)return;clearTimeout(ue.current);const Fe=()=>{clearTimeout(ue.current),ue.current=setTimeout(()=>{p||Ze()},KA)},Ze=async()=>{const ke=H.current;if(ke)try{await ps(),ke.muted=!1,await ke.play(),ye(!1)}catch{ke.muted=!0,ye(!0),Fe()}};ue.current=setTimeout(Ze,be)},[ps,p,xe]);m.useEffect(()=>()=>{clearTimeout(V.current),clearTimeout(X.current),clearTimeout(ue.current),clearInterval(te.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{T==="playing"&&ml(0)},[T,ml]),m.useEffect(()=>{Oe&&($("snapshot"),ie(null))},[Oe]),m.useEffect(()=>{if(Oe||!n?.url||!H.current)return;let be=!0,Fe;const Ze=setTimeout(()=>ye(!0),0),ke=($e,rt)=>{be&&(Pe("video/status",{nextStatus:$e,info:rt||null}),$($e),ie(rt||null),$e==="playing"&&ps(),["error","failed","disconnected","closed"].includes($e)&&Cn())};return Fe=new ax({url:n.url,token:n.token,video:H.current,receiveAudio:!xe,onStatus:ke}),Fe.start().catch($e=>{be&&($("error"),ie($e.message),Cn())}),()=>{be=!1,clearTimeout(Ze),Fe?.stop()}},[Oe,n?.url,n?.token,ae,Cn,ps,xe,Pe]),m.useEffect(()=>{T==="stopped"&&n?.url&&Cn()},[T,n?.url,Cn]),m.useEffect(()=>{const be=z.current;if(!be||!s?.url){Pe("route/no-audio-url"),Y.current=null;return}const Fe=Math.max(0,Math.min(1,ms)),Ze=Y.current==null?Math.max(0,Math.min(1,be.volume)):Y.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),Fe>Ze){const ke=performance.now(),$e=Ze,rt=Fe-$e,ot=wt=>{const nt=Math.min(1,(wt-ke)/JA),zn=$e+rt*nt;be.volume=zn,Y.current=zn,nt<1?ce.current=requestAnimationFrame(ot):ce.current=null};ce.current=requestAnimationFrame(ot)}else be.volume=Fe,Y.current=Fe;Pe("route/direct",{elementVolume:Fe,duckEnabled:vt,mainBrushActive:fa,duckAmount:le})},[s?.url,ms,vt,fa,le,Pe]),m.useEffect(()=>{if(!s?.url||!z.current)return;let be=!0,Fe;const Ze=(ke,$e)=>{be&&(Pe("audio/status",{nextStatus:ke,info:$e||null}),ee($e||(ke==="connected"?"connected":null)),R(rt=>ke==="connected"&&(rt==="playing"||rt==="connecting")||ke==="new"?rt:ke),["error","failed"].includes(ke)&&Ln())};return Fe=new ax({url:s.url,token:s.token,video:z.current,audioOnly:!0,onStatus:Ze}),Fe.start().catch(ke=>{be&&(R("error"),ee(ke.message),Ln())}),()=>{be=!1,Fe?.stop()}},[s?.url,s?.token,re,Ln,Pe]),m.useEffect(()=>{const be=z.current;if(!s?.url||!be){clearInterval(te.current);return}if(!["connecting","connected","playing","paused"].includes(de)){clearInterval(te.current);return}const Ze=async()=>{const ke=z.current;ke&&(ke.muted=!1,!(!ke.paused&&!ke.ended)&&(Pe("retry/play-attempt"),ke.play().then(()=>{Pe("retry/play-ok"),R($e=>$e==="connected"?"playing":$e),ee($e=>$e==="paused"?null:$e)}).catch($e=>{Pe("retry/play-fail",{error:$e?.message}),ee(rt=>rt||$e?.message||"autoplay blocked")})))};return Ze(),te.current=setInterval(Ze,ZA),()=>clearInterval(te.current)},[s?.url,de,Pe]),m.useEffect(()=>{const be=z.current;if(!be)return;const Fe=()=>{Pe("element/play"),R(nt=>nt==="error"?nt:"playing"),ee(null)},Ze=()=>{Pe("element/pause"),R(nt=>["error","failed","disconnected","closed","stopped"].includes(nt)?nt:"paused"),ee(nt=>nt||"paused")},ke=()=>{Pe("element/ended"),R(nt=>nt==="error"?nt:"stopped"),ee(nt=>nt||"ended")},$e=()=>{const{error:nt}=be,zn=nt?.message||"audio error";Pe("element/error",{error:zn}),R("error"),ee(zn)},rt=()=>Pe("element/waiting"),ot=()=>Pe("element/canplay"),wt=()=>Pe("element/stalled");return be.addEventListener("play",Fe),be.addEventListener("pause",Ze),be.addEventListener("ended",ke),be.addEventListener("error",$e),be.addEventListener("waiting",rt),be.addEventListener("canplay",ot),be.addEventListener("stalled",wt),()=>{be.removeEventListener("play",Fe),be.removeEventListener("pause",Ze),be.removeEventListener("ended",ke),be.removeEventListener("error",$e),be.removeEventListener("waiting",rt),be.removeEventListener("canplay",ot),be.removeEventListener("stalled",wt)}},[s?.url,Pe]);const hl=o?.error?`Error: ${o.error}`:o?.objectUrl?"snapshot":o?.status||"waiting",Ua=Oe?hl:n?.url?T==="error"?`Error: ${J||"unknown"}`:J?`${T} (${J})`:T:"waiting",Bo=s?.error?`Error: ${s.error}`:s?.url?de==="error"?`Error: ${U||"unknown"}`:U?`${de} (${U})`:de:null,pl=b==="spectator",an=b==="none";return r.jsxs("div",{className:`flex flex-col gap-0.5 ${w?"h-full":""}`,children:[r.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${w?"h-full flex-1":"aspect-[4/3]"}`,children:[Oe?o?.objectUrl?r.jsx("img",{src:o.objectUrl,alt:d,className:"h-full w-full object-contain",draggable:!1}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):r.jsx("video",{ref:H,muted:p||ve||xe,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),r.jsx("audio",{ref:z,autoPlay:!0,hidden:!0}),!an&&N?r.jsx(eN,{mobileHud:fe,turnSeconds:M,isActiveDriver:B,idleSkipSeconds:K}):null,an?null:r.jsx(WA,{frame:x,sensors:ze,label:d,roverColor:h,status:Ua,audioStatus:Bo,levelStatus:hs,desktopLayout:P,layoutFormat:v,variant:b,driverLabel:S,battery:st,showTopDown:Ve,mobileHud:fe,mapPosition:Ne,turnTimerText:q,labelScale:E}),an?null:r.jsx(sN,{compact:fe}),!an&&La?r.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-40 rounded bg-black/80 px-1 py-0.5 text-[0.6rem] text-lime-200",children:`OC vis:${Mt?1:0} motors:${Nt.length} fill:${Math.round(Ft*100)}%`}):null,an?null:r.jsx(nN,{motors:Nt,fill:Ft,compact:fe}),an?null:r.jsx(aN,{battery:st,compact:fe}),!an&&pl&&st.available?r.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:r.jsx(Uf,{visual:st,orientation:"vertical",variant:"inline",compact:fe,className:"h-full w-4"})}):null,!an&&f?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2",children:r.jsxs("div",{className:`mx-auto w-fit rounded border border-amber-300/80 bg-black/75 text-amber-200 ${fe?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[r.jsx("div",{className:"text-center",children:f}),r.jsx("div",{className:"pointer-events-auto mt-0",children:r.jsx(md,{id:"discord",label:"Join our Discord server while you wait!",url:Bn})})]})}):null]}),!an&&!pl&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(PA,{sensors:ze}),r.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:r.jsx(Uf,{visual:st,compact:fe})})]})]})}function PA({sensors:n}){const s=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],i=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)/i)),.35),f=p=>p==null||p<=0?"hsl(200 60% 18%)":`hsl(${(200+o(p)*360)%360} 100% 60%)`,d=6,h=12;return r.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:s.map((p,x)=>{const g=o(p),v=x<d/2?-1:1,b=`${g*100}%`,S=f(p);return r.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${h}px`},children:r.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:r.jsx("div",{className:"h-full",style:{width:b,background:S,float:v===-1?"right":"left"}})})},x)})})}function WA({frame:n,sensors:s,label:i,roverColor:o=null,status:f,audioStatus:d,levelStatus:h,desktopLayout:p=!0,layoutFormat:x="desktop",variant:g="default",driverLabel:v=null,battery:b,showTopDown:S=!1,mobileHud:k=!1,mapPosition:C="top-center",turnTimerText:E=null,labelScale:w=1}){s?.bumpsAndWheelDrops;const A=k,N=x==="mobile-portrait",q=A?"text-[0.45rem]":"text-[0.65rem]",M=A?"px-0.25 py-0.25":"px-1 py-0.5",B=A?"px-0.25 py-0.25":"px-0.5 py-0.5",K=A?"text-[0.55rem]":"text-[0.8rem]",_=A?"left-0.5 top-0.5":"left-1 top-1",H=A?"text-[0.5rem]":"text-[0.7rem]",z=A?"px-0.5 py-0.25":"px-1 py-0.5",V=A?"left-0.5 top-1/2":"left-1 top-1/2",X="bottom-0.5",te={transform:`translateX(-50%) scale(${w})`,transformOrigin:"center bottom"},ue="240px",ce=N?.3:A?.33:.7,T={width:ue,height:ue,opacity:A?.6:.7,transform:C==="top-center"?`translateX(-50%) scale(${ce})`:`scale(${ce})`,transformOrigin:C==="bottom-left"?"bottom left":C==="top-center"?"top center":"top right",...C==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:C==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};if(g==="none")return null;if(g==="spectator"){const $=[["Voltage",s?.voltageMv!=null?`${(s.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",s?.currentMa!=null?`${s.currentMa} mA`:"--"],["Charge",s?.batteryChargeMah!=null?`${s.batteryChargeMah}`:"--"],["OI",s?.oiMode?.label||"--"]],J=!!s?.chargingSources?.homeBase,ie=s?.chargingState?.label||"",de=!!(ie&&ie.toLowerCase()!=="not charging"),R=s?.oiMode?.label||"Unknown",U=R.toLowerCase(),ee=U==="full"?"bg-emerald-500/80 text-emerald-50":U==="safe"?"bg-amber-400/80 text-amber-950":U==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",ae=J?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",pe=de?"bg-emerald-500/80 text-emerald-50":J?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${_} font-medium text-slate-100 ${q}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),r.jsx("div",{className:`absolute ${V} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${q} ${M}`,children:r.jsxs("div",{className:"space-y-0.5 leading-tight",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[r.jsx("span",{className:`rounded px-1.5 py-0.5 ${ae}`,children:J?"Docked":"Undocked"}),r.jsx("span",{className:`rounded px-1.5 py-0.5 ${pe}`,children:de?"Charging":"Not charging"}),r.jsxs("span",{className:`rounded px-1.5 py-0.5 ${ee}`,children:["OI: ",R]})]}),$.map(([re,oe])=>r.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{className:"text-slate-400",children:re}),r.jsx("span",{className:"font-semibold text-white",children:oe})]},re))]})}),r.jsx("div",{className:`absolute ${X} left-1/2`,style:te,children:r.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${B} ${K}`,children:[r.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ca(o,.18),children:i||"Unnamed Rover"}),v?r.jsxs("span",{className:"text-slate-300",children:["• ",v]}):null]})})]}),S?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...T},children:r.jsx(zf,{sensors:s,size:240,overlay:!0})}):null]})}return r.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[r.jsx("div",{className:`absolute ${_} font-medium text-slate-100 ${q}`,children:r.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[r.jsxs("span",{children:["Status: ",f]}),d?r.jsxs("span",{children:["Audio: ",d]}):null,h?r.jsx("span",{className:"text-cyan-300",children:h}):null]})}),E?r.jsx("div",{className:`absolute left-1/2 top-0.5 -translate-x-1/2 rounded bg-black/70 text-slate-100 ${z} ${H}`,children:E}):null,r.jsx("div",{className:`absolute ${X} left-1/2`,style:te,children:r.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${B} ${K}`,children:r.jsxs("span",{children:["Rover:"," ",r.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ca(o,.18),children:['"',i||"Unnamed Rover",'"']})]})})}),S&&g!=="spectator"?r.jsx("div",{className:"pointer-events-none absolute rounded",style:{...T},children:r.jsx(zf,{sensors:s,size:240,overlay:!0})}):null]})}function eN({mobileHud:n=!1,turnSeconds:s=null,isActiveDriver:i=!1,idleSkipSeconds:o=null}){const f=n?"text-3xl":"text-5xl",d=n?"text-xs":"text-sm",h=n?"text-[0.55rem]":"text-[0.75rem]",p=n?"px-4 py-3":"px-6 py-4",x=i&&typeof o=="number";return r.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:r.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${p}`,children:[r.jsx("div",{className:`font-semibold text-amber-200 ${f}`,children:"IT IS YOUR TURN!"}),r.jsx("div",{className:`text-amber-200/80 ${d}`,children:"Start driving!"}),x?r.jsxs("div",{className:`text-red-100/90 ${h}`,children:["Idle skip in ",o,"s"]}):null]})})}const tN={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function nN({motors:n,fill:s=0,compact:i=!1}){if(!n?.length)return null;const o=n.map(v=>tN[v]||v),f=i?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",d=i?"px-2 py-1":"px-4 py-2",h=i?"text-lg":"text-4xl",p=i?"text-xs":"text-xl",x=Math.max(0,Math.min(1,s)),g=`${Math.round(x*100)}%`;return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${f}`,children:r.jsxs("div",{className:"relative h-full w-full",children:[r.jsx("div",{className:"absolute inset-0 overflow-hidden",children:r.jsx("div",{className:"h-full bg-red-700/60",style:{width:g}})}),r.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${h} ${d}`,children:[r.jsx("div",{children:"OVERCURRENT"}),r.jsx("div",{className:`mt-0 font-medium text-white ${p}`,children:o.join(", ")})]})]})})}function aN({battery:n,compact:s=!1}){if(!n?.available||!n.warnActive&&!n.urgentActive)return null;const i=n.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",o=s?"p-2 top-6":"p-4 top-10",f=s?"text-sm":"text-2xl";return r.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${o}`,children:r.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${f}`,children:r.jsx("div",{children:i})})})}function sN({compact:n=!1}){const s=ft(_=>_.session),{sendMessage:i,onInputFocus:o,onInputBlur:f,blurChat:d,registerInputRef:h,setTypingActive:p}=id(),{value:x}=He("tts",{engine:"flite",voice:"rms",pitch:50}),[g,v]=m.useState(""),[b,S]=m.useState(!1),k=s?.role!=="spectator",C=s?.role==="spectator",E=s?.assignment?.roverId||null,A=!!m.useMemo(()=>s?.roster?.find(_=>String(_.id)===String(E))||null,[E,s?.roster])?.audio?.ttsEnabled,N=m.useMemo(()=>{if(!A)return null;const _=x?.engine==="espeak"?"espeak":"flite";if(_==="espeak"){let z=Number.isFinite(x?.pitch)?Math.round(x.pitch):void 0;return typeof z=="number"&&(z=Math.max(0,Math.min(99,z))),{speak:!0,engine:_,pitch:z}}const H=typeof x?.voice=="string"?x.voice:void 0;return{speak:!0,engine:_,voice:H}},[x?.engine,x?.pitch,x?.voice,A]),q=n?"pointer-events-auto absolute bottom-0.5 right-0.5 flex w-[9rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.4 py-0.2":"pointer-events-auto absolute bottom-1 right-1 flex w-[12rem] max-w-[70vw] items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25",M=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",B=n?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function K(_){if(_.preventDefault(),!k)return;const H=g.trim();if(H){S(!0);try{await i(H,N),v(""),d(),p(!1)}catch(z){alert(z.message)}finally{S(!1)}}}return C?null:r.jsxs("form",{onSubmit:K,className:q,children:[r.jsx("input",{className:M,value:g,onChange:_=>{const H=_.target.value;v(H),p(!!H.trim())},onFocus:_=>{o(_),p(!!g.trim())},onBlur:_=>{f(_),p(!1)},onKeyDown:_=>{_.key==="Enter"&&!g.trim()&&(_.preventDefault(),d(),p(!1))},ref:_=>h(_,{target:"hud"}),placeholder:k?"Chat (TTS)":"Spectator",disabled:!k}),r.jsx("button",{type:"submit",disabled:!k||b,className:B,children:"Speak"})]})}function hd({layoutFormat:n="desktop"}){const s=ft(ae=>ae.session),{state:{song:i,lastControlIntentAt:o},overcurrentLimiter:f}=_t(),[d,h]=m.useState(()=>Date.now()),[p,x]=m.useState(!1),[g,v]=m.useState(null),b=m.useRef({active:!1,roverId:null});m.useEffect(()=>{if(s?.mode!=="turns")return;const ae=setInterval(()=>h(Date.now()),250);return()=>clearInterval(ae)},[s?.mode]);const S=s?.assignment?.roverId,C=!!(S&&s?.roster?s.roster.find(ae=>String(ae.id)===String(S)):null)?.media?.audioPublishUrl,E=S?s?.turnQueues?.[S]:null,w=s?.socketId||null,A=S?s?.activeDrivers?.[S]:null,N=!!(w&&A===w),q=m.useMemo(()=>{const ae=E?.queue||[];if(!ae.length||!E?.current||ae.length<=1)return null;const pe=ae.findIndex(re=>re===E.current);return pe===-1?ae[0]||null:ae[(pe+1)%ae.length]||null},[E?.queue,E?.current]),M=!!(w&&q===w),B=E?.deadline||null,K=E?.idleDeadline||null,_=B?B-d:null,H=K?K-d:null,z=s?.mode==="turns"&&M&&_!=null&&_<=5e3&&_>0,V=s?.mode!=="turns"||N||z,X=_!=null&&Number.isFinite(_)?Math.max(0,Math.ceil(_/1e3)):null,te=H!=null&&Number.isFinite(H)?Math.max(0,Math.ceil(H/1e3)):null,ue=N?X!=null?`${X}s left`:null:M&&X!=null?`Your turn in ${X}s`:null,ce=S?[...V?[{type:"rover",id:S,key:S}]:[],...C?[{type:"rover",id:`${S}-audio`,key:`${S}-audio`}]:[]]:[],Y=ji(ce),T=S&&V?Y[S]:null,$=S&&C?Y[`${S}-audio`]:null,J=fd(S?[S]:[],{enabled:!!S,version:s?.mode}),ie=S&&J[S]||null,de=dl(S),R=S&&s?.roster?s.roster.find(ae=>String(ae.id)===String(S)):null,U=R?.battery??null,ee=R?.name||(S?`Rover ${S}`:"");return m.useEffect(()=>{if(s?.mode!=="turns"){x(!1),v(null),b.current={active:!1,roverId:null};return}const ae=b.current,pe=N&&!ae.active,re=N&&S&&S!==ae.roverId;pe||re?(x(!0),v(Date.now())):!N&&ae.active&&(x(!1),v(null)),b.current={active:N,roverId:S}},[N,S,s?.mode]),m.useEffect(()=>{!p||!g||o>g&&x(!1)},[o,g,p]),r.jsx("section",{className:"panel",children:S?r.jsx(Ni,{sessionInfo:T,videoMode:V?"whep":"snapshot",snapshotFeed:ie,audioSessionInfo:$,label:ee,roverColor:R?.color||null,telemetryFrame:de,batteryConfig:U,layoutFormat:n,overcurrentLimiter:f,songNote:i?.note,qualityNotice:V?null:"Preview feed (low FPS) until your turn.",showTurnCue:p,turnTimerText:ue,turnSeconds:X,isActiveDriver:N,idleSkipSeconds:te}):r.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[r.jsx("p",{children:"You are not assigned to a rover."}),r.jsx("p",{className:"mt-0",children:r.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})})}function yo({label:n,tone:s="muted"}){const i=s==="success"?"bg-emerald-900 text-emerald-100":s==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return r.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${i}`,children:n})}function ko(n){if(!Number.isFinite(n))return 0;const s=n%360;return s<0?s+360:s}function lN(n){if(!Array.isArray(n)||n.length<3)return 0;const[s,i,o]=n,f=Math.max(0,Math.min(255,Number(s)))/255,d=Math.max(0,Math.min(255,Number(i)))/255,h=Math.max(0,Math.min(255,Number(o)))/255,p=Math.max(f,d,h),x=Math.min(f,d,h),g=p-x;if(g===0)return 0;let v=0;return p===f?v=(d-h)/g%6:p===d?v=(h-f)/g+2:v=(f-d)/g+4,ko(Math.round(v*60))}function ix(n){const s=ko(n),i=1,o=1-Math.abs(s/60%2-1);let f=0,d=0,h=0;return s<60?(f=i,d=o):s<120?(f=o,d=i):s<180?(d=i,h=o):s<240?(d=o,h=i):s<300?(f=o,h=i):(f=i,h=o),[Math.round(f*255),Math.round(d*255),Math.round(h*255)]}function rx(n){return n?Array.isArray(n.hsColor)?ko(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?lN(n.rgbColor):0:0}function iN({entity:n,connected:s,controlsLocked:i,onToggle:o,onSetColor:f,onSetWhite:d}){const h=n.state==="unavailable"||!n.available,p=n.state==="on",x=n.type==="light"&&n.supportsColor,g=h?"warn":p?"success":"muted",v=h?"Unavailable":p?"On":"Off",b=i||!s||h,S=b||!x,[k,C]=m.useState(()=>rx(n)),E=m.useRef(k),w=m.useRef(!1),A=h?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":i?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":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 H=rx(n);E.current=H,C(H)},[n.rgbColor,n.hsColor,x]);const N=H=>{const z=ko(Number(H.target.value));E.current=z,C(z)},q=()=>{S||!f||f(n.id,ix(E.current))},M=H=>{H.stopPropagation()},B=H=>{M(H),!(S||!d)&&d(n.id)},_=`rgb(${(x?ix(E.current):[255,255,255]).join(",")})`;return r.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:b,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${A} disabled:opacity-60 disabled:hover:bg-inherit`,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[r.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),x&&r.jsxs(r.Fragment,{children:[r.jsx(yo,{label:v,tone:g}),!s&&r.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),x?r.jsx("div",{className:"-mt-0.5 w-full",onClick:M,onPointerDown:H=>{M(H),w.current=!0},onPointerUp:H=>{M(H),w.current=!1,q()},onPointerCancel:H=>{M(H),w.current=!1,q()},onKeyUp:H=>{M(H),q()},onBlur:q,children:r.jsx("div",{className:"relative w-full",children:r.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:k,onChange:N,disabled:S,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsx(yo,{label:v,tone:g}),!s&&r.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),x&&r.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[r.jsx("span",{role:"button",tabIndex:S?-1:0,onClick:B,onPointerDown:M,onKeyDown:H=>{S||(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),B(H))},title:"Set white color temperature","aria-label":`Set ${n.name||n.id} to white`,"aria-disabled":S,className:`inline-flex items-center justify-center rounded border border-slate-200 bg-white px-1 py-0.5 text-xs font-semibold leading-none text-slate-900 ${S?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-slate-100"}`,children:"white"}),r.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:_}})]}),!x&&r.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:p?"Turn off":"Turn on"})]})}function zg(){const{state:{keymap:n}}=_t(),s=ft(k=>k.session),{homeAssistantToggle:i,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:f}=wn(),d=s?.homeAssistant,h=m.useMemo(()=>d?.entities||[],[d?.entities]),p=d?.lightPolicy||null,x=!!(p?.locked||p?.lockedOn),g=p?.lockState||(p?.lockedOn?"on":null),v=An(n?.homeAssistantOn?.[0]),b=An(n?.homeAssistantOff?.[0]);if(!d?.enabled)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(h.length===0)return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[r.jsx("p",{className:"text-slate-300",children:"Room Controls"}),r.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const S=!!d?.connected;return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{children:"Room Controls"}),r.jsx("span",{className:"text-xs text-slate-500",children:h.length}),x?r.jsx(yo,{label:g==="off"?"Locked Off":"Locked On",tone:"warn"}):null,r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"On"}),v?r.jsx(ox,{label:v}):null]}),r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx("span",{children:"Off"}),b?r.jsx(ox,{label:b}):null]})]})]}),r.jsx(yo,{label:S?"Connected":"Offline",tone:S?"success":"warn"})]}),x?r.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:g==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,r.jsx("div",{className:"flex flex-wrap gap-0.5",children:h.map(k=>r.jsx(iN,{entity:k,connected:S,controlsLocked:x,onToggle:i,onSetColor:o,onSetWhite:f},k.id))})]})}function ox({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Ug(){const{login:n,setRole:s}=wn(),[i,o]=m.useState(""),[f,d]=m.useState(""),[h,p]=m.useState(!1);async function x(g){g.preventDefault(),p(!0);try{await n(i,f),o(""),d("")}catch(v){alert(v.message)}finally{p(!1)}}return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),r.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:x,children:[r.jsx("input",{className:"field-input",placeholder:"Username",value:i,onChange:g=>o(g.target.value)}),r.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:f,onChange:g=>d(g.target.value)}),r.jsx("button",{type:"submit",disabled:h,className:"button-dark w-full disabled:opacity-50",children:h?"Logging in…":"Login"})]})]})}function cx(...n){return n.filter(Boolean).join(" ")}function rN(n){const s=n?.batteryState?.percentDisplay;return s==null?"--":`${s}%`}function oN(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function cN({title:n,roster:s=[],emptyText:i="No roster data.",renderActions:o=null}){return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),s.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:i}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:s.map(f=>{const d=!!(f?.private?.enabled&&f?.private?.open),h=!!f?.locked;return r.jsxs("li",{className:cx("surface flex flex-wrap items-center justify-between gap-0.5",h?"bg-red-900/40":d?"bg-amber-700/35 border border-amber-200/30":null),children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ca(f.color,.16),children:f.name})}),r.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[r.jsx("span",{children:f.locked?"locked":"free"}),f.lockReason&&r.jsx("span",{className:"rounded bg-black/30 px-1",children:f.lockReason}),r.jsxs("span",{className:cx("font-semibold",oN(f)),children:["Battery ",rN(f)]})]})]}),o?o(f):null]},f.id)})})]})}const uN=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function fN(){const{session:n,lockRover:s,setMode:i,requestControl:o,setCommunityGoal:f,setAdminReason:d,rebootRover:h,rebootServer:p,setAudioLevels:x,setPrivateSafety:g,llmControl:v,adminLogs:b,llmCommentaryState:S}=nn(),k=m.useMemo(()=>n?.roster??[],[n?.roster]),[C,E]=m.useState({}),[w,A]=m.useState({}),[N,q]=m.useState(!1),[M,B]=m.useState(!1),K=n?.health||null,_=n?.communityGoal?.text||"",H=n?.communityGoal?.updatedAt||null,[z,V]=m.useState(_),X=n?.adminReason?.text||"",te=n?.adminReason?.updatedAt||null,[ue,ce]=m.useState(X),Y=n?.audioLevels||{},[T,$]=m.useState({hornGain:Number.isFinite(Y.hornGain)?Y.hornGain:1,ttsGain:Number.isFinite(Y.ttsGain)?Y.ttsGain:1,forwardGain:Number.isFinite(Y.forwardGain)?Y.forwardGain:1}),[J,ie]=m.useState({}),de=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",R=n?.role==="lockdown"||n?.role==="lockdown-admin",U=n?.mode??"open",ee=async(se,P)=>{try{await s(se,P),E(fe=>({...fe,[se]:P}))}catch(fe){alert(fe.message)}},ae=async se=>{const P=se.target.value;try{await i(P)}catch(fe){alert(fe.message)}},pe=async se=>{try{await o(se,{force:!0})}catch(P){alert(P.message)}},re=async se=>{if(!(!se?.id||!window.confirm(`Reboot rover "${se.name||se.id}" now?`))){A(fe=>({...fe,[se.id]:!0}));try{await h(se.id)}catch(fe){alert(fe.message)}finally{A(fe=>({...fe,[se.id]:!1}))}}},oe=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){q(!0);try{await p()}catch(P){alert(P.message),q(!1)}}},ve=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){B(!0);try{await v("clearHistory")}catch(P){alert(P.message)}finally{B(!1)}}},ye=async()=>{try{await f(z)}catch(se){alert(se.message)}},xe=async()=>{try{await f(null)}catch(se){alert(se.message)}},Oe=async()=>{try{await d(ue)}catch(se){alert(se.message)}},ze=async()=>{try{await d(null)}catch(se){alert(se.message)}},Ae=se=>P=>{const fe=Number(P.target.value);$(Ne=>({...Ne||{},[se]:Number.isFinite(fe)?fe:1}))},tt=async()=>{try{await x(T)}catch(se){alert(se.message)}},Je=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{V(_)},[_]),m.useEffect(()=>{ce(X)},[X]),m.useEffect(()=>{$({hornGain:Number.isFinite(Y.hornGain)?Y.hornGain:1,ttsGain:Number.isFinite(Y.ttsGain)?Y.ttsGain:1,forwardGain:Number.isFinite(Y.forwardGain)?Y.forwardGain:1})},[Y.forwardGain,Y.hornGain,Y.ttsGain]),m.useEffect(()=>{const se={};(k||[]).forEach(P=>{P?.private?.enabled&&(se[P.id]={speedLimitEnabled:!!P?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(P?.private?.safety?.speedLimitMaxWheelSpeed)?P.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!P?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(P?.private?.safety?.overcurrentStopMs)?P.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!P?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(P?.private?.safety?.bumpBackoffSpeed)?P.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(P?.private?.safety?.bumpBackoffMs)?P.private.safety.bumpBackoffMs:350,cliffEnabled:!!P?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(P?.private?.safety?.cliffBackoffSpeed)?P.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(P?.private?.safety?.cliffBackoffMs)?P.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(P?.private?.safety?.triggerCooldownMs)?P.private.safety.triggerCooldownMs:800})}),ie(se)},[k]);const vt=m.useMemo(()=>{const se={};return k.forEach(P=>{se[P.id]=C[P.id]??P.locked}),se},[k,C]),le=(se,P={})=>{ie(fe=>({...fe||{},[se]:{...fe?.[se]||{},...P||{}}}))},me=async se=>{try{const P=J?.[se];if(!P)return;await g(se,P)}catch(P){alert(P.message)}};return de?r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[r.jsx("span",{children:"Admin controls"}),r.jsx("select",{value:U,onChange:ae,className:"field-input text-sm",children:uN.map(se=>r.jsx("option",{value:se.key,children:se.label},se.key))})]}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:oe,disabled:N,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:N?"Server rebooting...":"Reboot Server"}),r.jsx("button",{type:"button",onClick:Je,className:"button-dark",children:"Test Reward Popup"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?r.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Horn gain"}),r.jsxs("span",{children:[T.hornGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.hornGain,onChange:Ae("hornGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"TTS gain"}),r.jsxs("span",{children:[T.ttsGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.ttsGain,onChange:Ae("ttsGain"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Forward gain"}),r.jsxs("span",{children:[T.forwardGain.toFixed(2),"x"]})]}),r.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:T.forwardGain,onChange:Ae("forwardGain"),className:"w-full accent-emerald-500"})]}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:tt,className:"button-dark",children:"Apply audio levels"})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Community goal"}),H?r.jsxs("span",{children:["Updated ",new Date(H).toLocaleString()]}):null]}),r.jsx("input",{type:"text",value:z,onChange:se=>V(se.target.value),placeholder:"Set a community goal",className:"field-input text-sm"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:ye,className:"button-dark",children:"Set goal"}),r.jsx("button",{type:"button",onClick:xe,className:"button-danger",children:"Clear"})]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Admin mode reason"}),te?r.jsxs("span",{children:["Updated ",new Date(te).toLocaleString()]}):null]}),r.jsx("textarea",{value:ue,onChange:se=>ce(se.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),r.jsxs("div",{className:"flex gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:Oe,className:"button-dark",children:"Set reason"}),r.jsx("button",{type:"button",onClick:ze,className:"button-danger",children:"Clear"})]})]}),r.jsx(cN,{roster:k,renderActions:se=>r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>ee(se.id,!vt[se.id]),className:"button-dark",children:vt[se.id]?"Unlock":"Lock"}),r.jsx("button",{type:"button",onClick:()=>pe(se.id),className:"button-dark",children:"Force"}),r.jsx("button",{type:"button",onClick:()=>re(se),disabled:!!w[se.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:w[se.id]?"Rebooting...":"Reboot"}),se?.private?.enabled?r.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[r.jsx("div",{className:"text-slate-300",children:"Private safety"}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.speedLimitEnabled,disabled:!R,onChange:P=>le(se.id,{speedLimitEnabled:!!P.target.checked})}),r.jsx("span",{children:"Speed limit"})]}),r.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!R,value:J?.[se.id]?.speedLimitMaxWheelSpeed??250,onChange:P=>le(se.id,{speedLimitMaxWheelSpeed:Number(P.target.value)||250})}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.hardOvercurrentEnabled,disabled:!R,onChange:P=>le(se.id,{hardOvercurrentEnabled:!!P.target.checked})}),r.jsx("span",{children:"Hard overcurrent"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.hardBumpEnabled,disabled:!R,onChange:P=>le(se.id,{hardBumpEnabled:!!P.target.checked})}),r.jsx("span",{children:"Hard bump"})]}),r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!!J?.[se.id]?.cliffEnabled,disabled:!R,onChange:P=>le(se.id,{cliffEnabled:!!P.target.checked})}),r.jsx("span",{children:"Cliff safety"})]}),r.jsx("button",{type:"button",disabled:!R,onClick:()=>me(se.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),r.jsx(pN,{health:K,roster:k}),r.jsx(dN,{state:S,onClearHistory:ve,clearingHistory:M}),r.jsx(xN,{entries:b})]}):null}function dN({state:n,onClearHistory:s,clearingHistory:i}){const[o,f]=m.useState(null);if(!n)return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const d=n.runtime||{},h=n.counters||{},p=n.timings||{},x=n.input||{},g=n.output||{},v=n.errors||{},b=Array.isArray(n.history)?n.history:[],S=b.find(w=>w.runId===o)||(b.length?b[b.length-1]:null),k=mN(n),C=hN(x.modelMessages,g.raw),E=[{label:"running",value:d.running?"yes":"no"},{label:"in flight",value:d.inFlight?"yes":"no"},{label:"phase",value:d.phase||"--"},{label:"run id",value:d.currentRunId??"--"},{label:"tick count",value:d.tickCount??0},{label:"last tick",value:d.lastTickAt?new Date(d.lastTickAt).toLocaleString():"never"},{label:"next run",value:d.nextRunAt?new Date(d.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:d.outcome||"--"},{label:"reason",value:d.reason||"--"},{label:"skip streak",value:h.skipStreak??0},{label:"clear count",value:h.clearCount??0},{label:"last gen",value:p.lastGenerationMs!=null?`${p.lastGenerationMs} ms`:"--"},{label:"avg gen",value:p.avgGenerationMs!=null?`${p.avgGenerationMs} ms`:"--"},{label:"gen count",value:p.generationCount??0},{label:"prompt chars",value:h.promptChars??0},{label:"active drivers",value:h.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:h.snapshotSummary?.rovers??0},{label:"snapshot chat",value:h.snapshotSummary?.chatMessages??0}];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),r.jsx("div",{className:"flex gap-0.5 text-xs",children:r.jsx("button",{type:"button",onClick:s,disabled:!!i,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:i?"Clearing...":"Clear LLM History"})}),r.jsxs("div",{className:`surface border text-center ${k.className}`,children:[r.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:k.label}),r.jsx("div",{className:"text-xs text-slate-200",children:k.detail})]}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:E.map(w=>r.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[w.label,": ",w.value]},w.label))}),v.message?r.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.details?r.jsxs("details",{className:"surface text-xs text-red-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(v.details,null,2)})]}):null,g.generated?r.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",g.generated]}):null,g.posted?r.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",g.posted]}):null,r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),r.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:C.length?C.map(w=>r.jsx(ad,{message:w.message},w.id)):r.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{children:["Raw output: ",g.raw?.trim()?g.raw:"<none>"]}),r.jsxs("div",{children:["Posted: ",g.posted||"<none>"]}),r.jsxs("div",{children:["Output at:"," ",g.modelOutputAt?new Date(g.modelOutputAt).toLocaleString():"n/a"]}),r.jsxs("div",{children:["Failed at: ",v.failedAt?new Date(v.failedAt).toLocaleString():"n/a"]})]})]})]}),r.jsxs("details",{className:"surface text-xs text-slate-200",children:[r.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),r.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(w=>r.jsxs("button",{type:"button",onClick:()=>f(w.runId),className:`w-full text-left surface ${S?.runId===w.runId?"border border-sky-400/50":""}`,children:[r.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",r.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",r.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",r.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):r.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),S?r.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[r.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",S.runId," details"]}),r.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(S,null,2)})]}):null]})}function mN(n){const s=n?.runtime||{},i=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:i.posted?`Last: ${i.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:s.outcome==="skipped"?{label:"SKIPPED",detail:s.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:s.outcome==="failed"?{label:"FAILED",detail:o.message||s.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:s.running?"IDLE":"STOPPED",detail:s.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function hN(n,s){const i=Date.now(),f=(Array.isArray(n)?n:[]).map((d,h)=>{const p=String(d?.role||"").toLowerCase(),x=typeof d?.content=="string"?d.content:JSON.stringify(d?.content??null,null,2),g=p==="system"?"LLM System":p==="assistant"?"LLM Context":p==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${h}`,message:{ts:i+h,nickname:g,text:x,role:"spectator",system:p==="system"}}});if(s!=null){const d=String(s);f.push({id:"llm-output",message:{ts:i+f.length+1,nickname:"LLM Output",text:d.trim()?d:"<empty>",role:"spectator",system:!0}})}return f}function pN({health:n,roster:s=[]}){if(!n)return null;const i=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},f=x=>s.find(g=>String(g.id)===String(x))?.color||null,d=`${i.readyCount}/${i.totalCount} sources ready`,h=o.rovers.filter(x=>x.stale).length,p=o.rooms.filter(x=>x.stale).length;return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),r.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Replay segments"}),r.jsx("span",{className:"text-slate-400",children:d})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Rover snapshots"}),r.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rovers.length-h,"/",o.rovers.length," ok"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:"Room cameras"}),r.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rooms.length-p,"/",o.rooms.length," ok"]})]})]}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:i.sources.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:`${x.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:x.type==="rover"?ca(f(x.id),.16):void 0,children:x.label}),r.jsxs("span",{className:x.ready?"text-emerald-300":"text-amber-300",children:[x.recentCount,"/",x.neededCount]})]},`${x.type}:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ca(f(x.id),.16),children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.stale?"stale":"ok"})]},`rover:${x.id}`))}),r.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(x=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{children:x.name}),r.jsx("span",{className:x.stale?"text-amber-300":"text-emerald-300",children:x.error?"error":x.stale?"stale":"ok"})]},`room:${x.id}`))})]})}function xN({entries:n}){const s=n||[];return r.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Admin IP log"}),r.jsx("span",{children:s.length})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No admin log entries yet."}):s.slice().reverse().map(i=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-amber-400",children:i.ts?new Date(i.ts).toLocaleTimeString():"--"})," ",i.label&&r.jsxs("span",{className:"text-teal-400",children:["[",i.label,"]"]})," ",r.jsx("span",{className:"text-slate-200",children:i.message})," ",i.ip&&r.jsx("span",{className:"text-cyan-300",children:i.ip})," ",i.meta&&r.jsx("span",{className:"text-slate-500",children:JSON.stringify(i.meta)})]},i.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const gN=[{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 vN(n){return n.reduce((s,i)=>((s[i.group]||(s[i.group]=[])).push(i),s),{})}function yN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(0,Math.min(500,i)):s}const pd=5,wi=500,Ci=1,xd=100;function bN(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(pd,Math.min(wi,i)):s}function uo(n,s){const i=Number(n);return Number.isFinite(i)?Math.max(Ci,Math.min(xd,i)):s}function SN(n){const i=(uo(n,n)-Ci)/(xd-Ci),o=wi-i*(wi-pd);return Math.round(o)}function jN(n){const s=bN(n,n),i=(wi-s)/(wi-pd),o=Ci+i*(xd-Ci);return Math.round(o)}function AN(n){const[s,i]=m.useState(null),o=m.useCallback(h=>{sf(!0),i(h)},[]),f=m.useCallback(()=>{sf(!1),i(null)},[]),d=m.useCallback((h,p)=>{if(p.preventDefault(),p.stopPropagation(),p.key==="Escape"){f();return}const x=Ti(p.key??"");x&&(n(h,x,p),f())},[f,n]);return m.useEffect(()=>()=>sf(!1),[]),{active:s,startCapture:o,cancel:f,captureFromEvent:d}}function Wr({label:n,description:s,value:i,onChange:o,min:f=0,max:d=500,step:h=5}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("input",{type:"number",min:f,max:d,value:i,onChange:p=>o(p.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[r.jsx("input",{type:"range",min:f,max:d,step:h,value:i,onChange:p=>o(p.target.value),className:"h-2 flex-1 accent-emerald-400"}),r.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:i})]})]})}function NN(){const{state:{keymap:n},actions:{updateKeyBinding:s,resetKeyBindings:i}}=_t(),{value:o,save:f}=He("inputs",qn),d={...qn.keyboard,...o.keyboard??{}},h=m.useMemo(()=>typeof d.tiltSpeed=="number"?uo(d.tiltSpeed,qn.keyboard.tiltSpeed):typeof d.tiltIntervalMs=="number"?uo(jN(d.tiltIntervalMs),qn.keyboard.tiltSpeed):qn.keyboard.tiltSpeed,[d.tiltIntervalMs,d.tiltSpeed]),p=m.useMemo(()=>vN(gN),[]),{active:x,startCapture:g,cancel:v,captureFromEvent:b}=AN((E,w)=>{s(E,w)}),S=m.useCallback(E=>n?.[E]?.[0]||xi[E]?.[0]||"",[n]),k=m.useCallback((E,w)=>{const A=qn.keyboard,N=yN(w,A[E]);f(q=>({...q??{},keyboard:{...q?.keyboard??A,[E]:N}}))},[f]),C=m.useCallback(E=>{const w=qn.keyboard,A=uo(E,w.tiltSpeed),N=SN(A);f(q=>({...q??{},keyboard:{...q?.keyboard??w,tiltSpeed:A,tiltIntervalMs:N}}))},[f]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),r.jsx("button",{type:"button",onClick:()=>i(),className:"button-dark text-xs",children:"Reset defaults"})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Wr,{label:"Base speed",description:"Normal driving speed",value:d.baseSpeed,onChange:E=>k("baseSpeed",E)}),r.jsx(Wr,{label:"Turbo speed",description:"Used when holding the boost modifier",value:d.turboSpeed,onChange:E=>k("turboSpeed",E)}),r.jsx(Wr,{label:"Precision speed",description:"Used when holding the precision modifier",value:d.precisionSpeed,onChange:E=>k("precisionSpeed",E)})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),r.jsx(Wr,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:h,onChange:C,min:1,max:100,step:1})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([E,w])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.75rem] text-slate-400",children:E}),r.jsx("div",{className:"space-y-0.5",children:w.map(A=>{const N=S(A.id),q=x===A.id;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:A.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:An(N)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[q&&r.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>g(A.id),onKeyDown:q?M=>b(A.id,M):void 0,autoFocus:q,className:`${q?"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:q?"Press a key…":"Change"})]})]},A.id)})})]},E))})]})}const la=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),wN=[{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"}],ux=.45,CN=.6;function di({label:n,description:s,min:i,max:o,step:f,value:d,onChange:h}){return r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:n}),r.jsx("span",{className:"font-mono text-slate-400",children:la.format(d)})]}),s&&r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:s}),r.jsx("input",{type:"range",min:i,max:o,step:f,value:d,onChange:p=>h(Number(p.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function EN(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} ${la.format(n.threshold??.6)}`}return"Unassigned"}function kN(n){return n.reduce((s,i)=>((s[i.section]||(s[i.section]=[])).push(i),s),{})}function MN(n,s){if(!n||n.length===0)return null;if(s){const i=n.find(o=>o.signature===s);if(i)return i}return n[0]}function RN(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 qN(n,s,i){const o=(n.axes??[]).map((d,h)=>({index:h,delta:Math.abs((d??0)-(s.axes?.[h]??0)),value:d}));if(o.sort((d,h)=>h.delta-d.delta),i.kind==="axisPair"){const d=o.filter(h=>h.delta>ux).slice(0,2);return d.length<2?null:{kind:"axisPair",x:d[0].index,y:d[1].index,...i.invertDefaults??{}}}const f=o.find(d=>d.delta>ux);return f?{kind:"axis",index:f.index,...i.invertDefaults??{}}:null}function TN(n,s,i){const o=n.buttons??[];for(let d=0;d<o.length;d+=1){const h=o[d],p=typeof h?.value=="number"?h.value:h?.pressed?1:0;if(h?.pressed||p>CN)return i.kind==="axis"?{kind:"buttonAxis",index:d}:{kind:"button",index:d}}const f=n.axes??[];for(let d=0;d<f.length;d+=1){const h=f[d]??0,p=Math.abs(h-(s.axes?.[d]??0));if(Math.abs(h)>.7&&p>.5)return i.kind==="axis"?{kind:"axis",index:d,...i.invertDefaults??{}}:{kind:"axisButton",index:d,direction:h>=0?1:-1,threshold:.6}}return null}function DN(n,s,i){if(!n)return null;if(i.kind==="axis"||i.kind==="axisPair"){const o=qN(n,s,i);if(o)return o}return TN(n,s,i)}function _N(){const n=cA(),{value:s,save:i}=He("gamepad",Oa),[o,f]=m.useState(null),d=m.useRef(null),h=m.useMemo(()=>kN(wN),[]),p=m.useMemo(()=>MN(n.pads,s.activeSignature),[n.pads,s.activeSignature]),x=p?.signature??null,g=m.useMemo(()=>x?s?.profiles?.[x]??s?.defaults?.profile??ia:s?.defaults?.profile??ia,[x,s?.defaults?.profile,s?.profiles]);m.useEffect(()=>{!p||!x||s?.profiles?.[x]||i(w=>{const A=w??Oa;if(A.profiles?.[x])return A;const N=A?.defaults?.profile??ia,q=Ag(p,N);return{...A,profiles:{...A.profiles??{},[x]:q}}})},[p,x,s?.profiles,i]),m.useEffect(()=>{d.current=null},[o,x]),m.useEffect(()=>{if(!o||!p)return;if(!d.current){d.current=RN(p);return}const w=DN(p,d.current,o);w&&(i(A=>{const N=A??Oa,q=N.profiles?.[x]??N?.defaults?.profile??ia,M={...q,bindings:{...q.bindings??{},[o.id]:{...q.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...N,profiles:{...N.profiles??{},[x]:M}}}),f(null))},[p,x,o,i]);const v=m.useCallback(w=>{i(A=>({...A??Oa,activeSignature:w||null}))},[i]),b=m.useCallback(w=>{i(A=>{const N=A??Oa,q=(x&&N.profiles?.[x])??N?.defaults?.profile??ia,M={...q,calibration:{...q.calibration??{},...w}};return x?{...N,profiles:{...N.profiles??{},[x]:M}}:{...N,defaults:{...N.defaults??{},profile:M}}})},[x,i]),S=m.useCallback((w,A)=>{i(N=>{const q=N??Oa,M=(x&&q.profiles?.[x])??q?.defaults?.profile??ia,B=A(M.bindings?.[w]??{}),K={...M,bindings:{...M.bindings??{},[w]:B}};return x?{...q,profiles:{...q.profiles??{},[x]:K}}:{...q,defaults:{...q.defaults??{},profile:K}}})},[x,i]),k=m.useCallback(w=>{S(w.id,A=>({...A,sources:[]}))},[S]),C=m.useCallback((w,A)=>{S(w.id,N=>{const q=Array.isArray(N.sources)?[...N.sources]:[];if(!q[0])return N;const M={...q[0]};return A==="invertX"?M.invertX=!M.invertX:A==="invertY"?M.invertY=!M.invertY:M.invert=!M.invert,q[0]=M,{...N,sources:q}})},[S]),E=m.useMemo(()=>p?{outputs:Ng(p,g)}:null,[p,g]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:p?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&r.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):r.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[r.jsx("select",{value:x??"",onChange:w=>v(w.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(w=>r.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:p?.mapping??"unknown"})]})]}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(di,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:g.calibration?.driveDeadzone??.18,onChange:w=>b({driveDeadzone:w})}),r.jsx(di,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:g.calibration?.cameraDeadzone??.08,onChange:w=>b({cameraDeadzone:w})}),r.jsx(di,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:g.calibration?.auxDeadzone??.05,onChange:w=>b({auxDeadzone:w})}),r.jsx(di,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:g.calibration?.auxSideScale??.55,onChange:w=>b({auxSideScale:w})}),r.jsxs("label",{className:"surface-muted block p-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[r.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),r.jsxs("select",{value:g.calibration?.cameraMode??"absolute",onChange:w=>b({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[r.jsx("option",{value:"absolute",children:"Absolute"}),r.jsx("option",{value:"velocity",children:"Velocity"})]})]}),r.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),r.jsx(di,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:g.calibration?.cameraSensitivity??60,onChange:w=>b({cameraSensitivity:w})})]})]}),r.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([w,A])=>r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),r.jsx("div",{className:"space-y-0.5",children:A.map(N=>{const M=g.bindings?.[N.id]?.sources?.[0]??null;return r.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-slate-100",children:N.label}),r.jsx("p",{className:"text-[0.65rem] text-slate-400",children:EN(M)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[N.kind==="axisPair"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),N.kind==="axis"&&r.jsx("button",{type:"button",disabled:!M,onClick:()=>C(N),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),r.jsx("button",{type:"button",onClick:()=>k(N),className:"button-dark text-[0.7rem]",children:"Clear"}),r.jsx("button",{type:"button",onClick:()=>f(N),className:`${o?.id===N.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===N.id?"Waiting…":"Capture"})]})]},N.id)})})]},w))}),r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),p?r.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[r.jsx("p",{className:"text-slate-400",children:"Raw axes"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.axes.map((w,A)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["A",A,": ",la.format(w)]},`axis-${A}`))}),r.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),r.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:p.buttons.map((w,A)=>r.jsxs("span",{className:"font-mono text-slate-300",children:["B",A,": ",la.format(w.value)," ",w.pressed?"●":""]},`btn-${A}`))}),E?.outputs&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",la.format(E.outputs.driveVector.x),","," ",la.format(E.outputs.driveVector.y)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",la.format(E.outputs.cameraAxis)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",la.format(E.outputs.auxAxis.main)]}),r.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",la.format(E.outputs.auxAxis.side)]})]})]})]}):r.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const ON={drive:"Drive wheels",aux:"Aux motors"};function fx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function BN({value:n,color:s="bg-emerald-500"}){const i=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return r.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:r.jsx("div",{className:`h-full ${s}`,style:{width:i}})})}function LN(){const{state:{roverId:n},overcurrentLimiter:s}=_t(),i=m.useMemo(()=>rs.map(o=>o.key),[]);return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Overcurrent limiter"}),r.jsx("span",{children:s?.adminImmune?"Admin immune":"Active"})]}),n?r.jsxs("div",{className:"space-y-0.5",children:[i.map(o=>{const f=s?.caps?.[o]?.cap??0,d=s?.overcurrent?.groups?.[o]??!1,h=s?.scales?.perGroup?.[o]??1;return r.jsxs("div",{className:"surface space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-slate-200",children:ON[o]||o}),r.jsx("span",{className:d?"text-red-300":"text-slate-400",children:d?"overcurrent":"ok"})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Cap"}),r.jsx("span",{children:fx(f)})]}),r.jsx(BN,{value:f,color:"bg-amber-500"}),r.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[r.jsx("span",{children:"Scale"}),r.jsx("span",{children:fx(h)})]})]})]},o)}),r.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[r.jsx("div",{children:`Down rate ${s?.config?.downRatePerSec}/s · Up rate ${s?.config?.upRatePerSec}/s`}),r.jsx("div",{children:`Release delay ${s?.config?.releaseDelaySec}s`}),r.jsx("div",{children:`Output rate ${s?.config?.outputRateMs}ms`})]})]}):r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Hg=m.createContext(null);function Vg(){const n=m.useContext(Hg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const dx={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"}},mx={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"},$g="primary";function gd(...n){return n.filter(Boolean).join(" ")}function vd({children:n,defaultTab:s,currentTab:i,onTabChange:o,variant:f=$g}){const[d,h]=m.useState(s??null),[p,x]=m.useState([]),g=m.useCallback(k=>k?(x(C=>C.includes(k)?C:[...C,k]),()=>x(C=>C.includes(k)?C.filter(E=>E!==k):C)):()=>{},[]),v=i??d??p[0]??null;m.useEffect(()=>{s&&i===void 0&&h(s)},[s,i]);const b=m.useCallback(k=>{k&&(i===void 0&&h(k),o&&o(k))},[i,o]),S=m.useMemo(()=>({activeTab:v,setActiveTab:b,registerTab:g,variant:f}),[v,b,g,f]);return r.jsx(Hg.Provider,{value:S,children:n})}function yd({children:n,className:s=""}){return r.jsx("div",{className:gd("flex gap-0.5",s),children:n})}function Wt({id:n,children:s,className:i="",disabled:o=!1,highlight:f="none"}){const{activeTab:d,setActiveTab:h,registerTab:p,variant:x}=Vg();m.useEffect(()=>p(n),[n,p]);const g=dx[x]??dx[$g],v=d===n,b=mx[f]||mx.none,S=gd(g.base,b||(v?g.active:g.inactive),o?"cursor-not-allowed opacity-50":"",i);return r.jsx("button",{type:"button",className:S,onClick:()=>!o&&h(n),"aria-pressed":v,"aria-disabled":o,children:s})}function bd({children:n,className:s=""}){return r.jsx("div",{className:gd("mt-0 space-y-0.5",s),children:n})}function en({id:n,children:s,keepMounted:i=!1}){const{activeTab:o}=Vg(),f=o===n;return!f&&!i?null:!f&&i?r.jsx("div",{hidden:!0,"aria-hidden":"true",children:s}):r.jsx(r.Fragment,{children:s})}function zN(){const{session:n}=nn(),s=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return r.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[r.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),r.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:s})]})}const hx=300,px=240;function UN(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,(i,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function HN(n){const i=n.map(o=>UN(o)).join(" ");return i.length>px?`${i.slice(0,px)}…`:i}function VN(){const n=tn(),[s,i]=m.useState([]),o=m.useMemo(()=>s.reduce((f,d)=>(d.direction==="in"&&(f.in+=1),d.direction==="out"&&(f.out+=1),f),{in:0,out:0}),[s]);return m.useEffect(()=>{const f=(x,g,v)=>{i(b=>{const S=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:x,event:g,payload:HN(v),timestamp:new Date().toLocaleTimeString()}];return S.length>hx?S.slice(-hx):S})},d=(x,...g)=>f("in",x,g),h=(x,...g)=>f("out",x,g);n.onAny(d);let p=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(h),p=()=>n.offAnyOutgoing(h);else{const x=n.emit.bind(n);n.emit=(g,...v)=>(h(g,...v),x(g,...v)),p=()=>{n.emit=x}}return()=>{n.offAny(d),p&&p()}},[n]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[r.jsx("span",{children:"Socket activity"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[r.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),r.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),r.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>i([]),children:"Clear"})]})]}),r.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:s.length===0?r.jsx("p",{children:"No socket activity yet."}):s.slice().reverse().map(f=>r.jsxs("div",{className:"surface",children:[r.jsx("span",{className:"text-slate-400",children:f.timestamp})," ",r.jsxs("span",{className:f.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",f.direction.toUpperCase(),"]"]})," ",r.jsx("span",{className:"text-cyan-300",children:f.event})," ",r.jsx("span",{className:"text-slate-200",children:f.payload})]},f.id))}),r.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const $N=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function Gg(){const{state:{roverId:n},actions:{sendOiCommand:s,setSensorStream:i}}=_t(),o=!!n,[f,d]=Bg(),h=tn(),{value:p,save:x}=He("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:g,save:v}=He("audio",ct),b=p?.connectionTransport||"websocket",S=!!p?.swapMobileControlColumns,k=typeof p?.driveMacroBackoffEnabled=="boolean"?p.driveMacroBackoffEnabled:!0,C=Number.isFinite(g?.masterVolume)?g.masterVolume:ct.masterVolume,E=Number.isFinite(g?.alertVolume)?g.alertVolume:ct.alertVolume,w=Number.isFinite(g?.roverVolume)?g.roverVolume:ct.roverVolume,A=typeof g?.mainBrushDuckEnabled=="boolean"?g.mainBrushDuckEnabled:typeof g?.autoLevelEnabled=="boolean"?g.autoLevelEnabled:ct.mainBrushDuckEnabled,N=Number.isFinite(g?.mainBrushDuckAmount)?Math.max(0,Math.min(1,g.mainBrushDuckAmount)):ct.mainBrushDuckAmount,q=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),M=V=>{n&&i(V)},B=V=>{const X=V.target.value;x(te=>({...te??{},connectionTransport:X})),h?.io?.opts&&(h.io.opts.transports=X==="polling"?["polling"]:["websocket","polling"],h.disconnect(),h.connect())},K=V=>X=>{const te=Number(X.target.value),ue=Number.isFinite(te)?Math.max(0,Math.min(1,te)):0;v(ce=>({...ce??{},[V]:ue}))},_=V=>{const X=!!V.target.checked;v(te=>({...te??{},mainBrushDuckEnabled:X}))},H=V=>{const X=!!V.target.checked;x(te=>({...te??{},swapMobileControlColumns:X}))},z=V=>{const X=!!V.target.checked;x(te=>({...te??{},driveMacroBackoffEnabled:X}))};return r.jsxs(vd,{defaultTab:"keybindings",children:[r.jsxs(yd,{children:[r.jsx(Wt,{id:"keybindings",children:"Keybindings"}),r.jsx(Wt,{id:"controller",children:"Controller"}),r.jsx(Wt,{id:"page",children:"Page settings"}),r.jsx(Wt,{id:"admin",children:"Admin"})]}),r.jsxs(bd,{children:[r.jsx(en,{id:"keybindings",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(NN,{})})}),r.jsx(en,{id:"controller",children:r.jsx("div",{className:"space-y-0.5",children:r.jsx(_N,{})})}),r.jsx(en,{id:"page",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"HUD"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:f,onChange:V=>d(V.target.checked)}),r.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:S,onChange:H}),r.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Macros"}),r.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:k,onChange:z}),r.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Audio"}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Master volume"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(C*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:C,onChange:K("masterVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Alert/page sounds"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:K("alertVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Rover audio"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:K("roverVolume"),className:"w-full accent-emerald-500"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Main brush ducking"}),r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:A,onChange:_})]}),r.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsx("span",{children:"Main brush duck amount"}),r.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),r.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:K("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!A})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Connection"}),r.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[r.jsx("span",{children:"Transport"}),r.jsxs("select",{value:b,onChange:B,className:"field-input text-sm",children:[r.jsx("option",{value:"websocket",children:"WebSocket"}),r.jsx("option",{value:"polling",children:"Polling"})]})]}),r.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),r.jsx(en,{id:"admin",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),r.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:$N.map(V=>r.jsx("button",{type:"button",onClick:()=>s(V.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:V.label},V.key))})]}),r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),r.jsx("div",{className:"surface flex gap-0.5",children:q.map(V=>r.jsx("button",{type:"button",onClick:()=>M(V.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:V.label},V.key))}),!o&&r.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),r.jsx(Ug,{}),r.jsx(LN,{}),r.jsx(fN,{}),r.jsx(zN,{}),r.jsx(VN,{})]})})]})]})}const xx={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 GN(n){return xx[n]||xx.desktop}function Yg({actionId:n,keymap:s}){const i=s?.[n]?.[0]??"";return r.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:An(i)})}function gx(n,s){return n.map((i,o)=>typeof i=="string"?r.jsx("span",{children:i},`text-${o}`):i?.action?r.jsx(Yg,{actionId:i.action,keymap:s},`pill-${i.action}-${o}`):i?.text?r.jsx("span",{children:i.text},`span-${o}`):null)}function Mo(n,s,i){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return gx(n.segments,s);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return gx(n,s)}return String(n??"")}function YN({hero:n,keymap:s}){return n?r.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&r.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&r.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(i=>r.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:i},i))})]}),n.bullets&&r.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((i,o)=>{const f=Array.isArray(i?.segments)?`hero-${o}`:`hero-${o}`;return r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Mo(i,s)},f)})})]}):null}function FN({block:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((i,o)=>{const f=`item-${o}`;return r.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:Mo(i,s)},f)})})]})}function XN({block:n}){const s=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return r.jsxs("div",{className:`surface space-y-0.5 border ${s} px-0.5 py-0.5`,children:[r.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((i,o)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Mo(i,{})},`callout-${o}`))})]})}function QN({group:n,keymap:s}){return r.jsxs("div",{className:"space-y-0.5 surface",children:[r.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),r.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(i=>r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[r.jsx("span",{className:"text-slate-200",children:i.label}),r.jsx(Yg,{actionId:i.action,keymap:s})]},i.action))})]})}function KN({block:n,keymap:s}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&r.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(i=>r.jsx(QN,{group:i,keymap:s},i.id))})]}):null}function ZN({block:n}){return n?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),r.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((s,i)=>r.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Mo(s,{})},`gamepad-${i}`))})]}):null}function vx({block:n,keymap:s}){if(!n)return null;switch(n.type){case"list":return r.jsx(FN,{block:n,keymap:s});case"callout":return r.jsx(XN,{block:n});case"keyboard":return r.jsx(KN,{block:n,keymap:s});case"gamepad":return r.jsx(ZN,{block:n});default:return null}}function Fg({layout:n,keymap:s}){const i=m.useMemo(()=>GN(n),[n]),o=s||{},f=i.main||[],d=i.aside||[];return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(YN,{hero:i.hero,keymap:o}),r.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[r.jsx("div",{className:"space-y-0.5",children:f.map((h,p)=>r.jsx(vx,{block:h,keymap:o},h.title||p))}),r.jsx("div",{className:"space-y-0.5",children:d.map((h,p)=>r.jsx(vx,{block:h,keymap:o},h.title||p))})]})]})}function Xg({layout:n,onOpenOverlay:s}){const{state:i}=_t();return r.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[r.jsx("span",{children:"Help"}),r.jsx("button",{type:"button",onClick:s,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),r.jsx(Fg,{layout:n,keymap:i?.keymap||{}})]})}const IN=["kal","rms","slt","ksp","bdl"],JN=Array.from({length:10},(n,s)=>s*10);function Ro({hideInput:n=!1,hideSpectatorNotice:s=!1,fillHeight:i=!1,allowSpectatorInput:o=!1}){const f=ft(R=>R.session),{messages:d,typing:h,sendMessage:p,registerInputRef:x,onInputFocus:g,onInputBlur:v,blurChat:b,setTypingActive:S}=id(),{value:k,save:C}=He("tts",{engine:"flite",voice:"rms",pitch:50}),[E,w]=m.useState(""),[A,N]=m.useState(!1),[q,M]=m.useState(!1),[B,K]=m.useState(()=>k?.engine||"flite"),[_,H]=m.useState(()=>k?.voice||"rms"),[z,V]=m.useState(()=>Number.isFinite(k?.pitch)?k.pitch:50),X=f?.role!=="spectator"||o,te=m.useRef(null),ue=f?.assignment?.roverId||null,Y=!!m.useMemo(()=>f?.roster?.find(R=>String(R.id)===String(ue))||null,[ue,f?.roster])?.audio?.ttsEnabled,T=m.useMemo(()=>d.slice(-200),[d]),$=m.useMemo(()=>h||[],[h]);m.useEffect(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[T,$]),m.useEffect(()=>{const R=k?.engine||"flite",U=k?.voice||"rms",ee=Number.isFinite(k?.pitch)?k.pitch:50;B!==R&&K(R),_!==U&&H(U),z!==ee&&V(ee)},[B,z,k?.engine,k?.pitch,k?.voice,_]),m.useEffect(()=>{M(!!Y)},[Y]);const J=m.useMemo(()=>!Y||!q?null:B==="espeak"?{speak:!0,engine:B,pitch:z}:{speak:!0,engine:B,voice:_},[B,z,q,Y,_]);async function ie(R){if(R.preventDefault(),!X||n)return;const ee=E.replace(/\\n/g,`
|
||
`).trim();if(ee){N(!0);try{await p(ee,J),w(""),b(),S(!1)}catch(ae){alert(ae.message)}finally{N(!1)}}}const de=i?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${i?"flex h-full flex-col overflow-hidden":""}`,children:[r.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${de}`,ref:te,children:[T.length===0&&$.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):T.map(R=>r.jsx(ad,{message:R},R.id)),$.map(R=>r.jsx(mg,{message:R},`typing-${R.typingId||R.id}`))]}),!n&&r.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ie,children:[r.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:E,onChange:R=>{const U=R.target.value;w(U),S(!!U.trim())},onFocus:R=>{g(R),S(!!E.trim())},onBlur:R=>{v(R),S(!1)},onKeyDown:R=>{R.key==="Enter"&&!E.trim()&&(R.preventDefault(),b(),S(!1))},ref:R=>x(R,{target:"panel"}),placeholder:X?"Type a message…":s?"":"Spectators cannot chat",disabled:!X}),Y&&r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[r.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:q,onChange:R=>M(R.target.checked),className:"accent-cyan-500"}),r.jsx("span",{children:"Speak"})]}),r.jsxs("select",{value:B,onChange:R=>{const U=R.target.value;K(U),C(ee=>({...ee||{},engine:U}))},className:"field-input text-xs",children:[r.jsx("option",{value:"flite",children:"flite"}),r.jsx("option",{value:"espeak",children:"espeak"})]}),B==="flite"?r.jsx("select",{value:_,onChange:R=>{const U=R.target.value;H(U),C(ee=>({...ee||{},voice:U}))},className:"field-input text-xs",children:IN.map(R=>r.jsx("option",{value:R,children:R},R))}):r.jsx("select",{value:z,onChange:R=>{const U=Number(R.target.value);V(U),C(ee=>({...ee||{},pitch:U}))},className:"field-input text-xs",children:JN.map(R=>r.jsxs("option",{value:R,children:["pitch ",R]},R))})]}),r.jsx("button",{type:"submit",disabled:!X||A,className:"button-dark h-full disabled:opacity-50 self-stretch",children:A?"...":"Send"})]})]})}function qo({compact:n=!1}){const{session:s,setNickname:i}=nn(),{value:o,save:f}=He("profile",{nickname:""}),[d,h]=m.useState(o.nickname||""),[p,x]=m.useState(!1),g=s?.role!=="spectator";m.useEffect(()=>{h(o.nickname||"")},[o.nickname]);async function v(b){if(b.preventDefault(),!g)return;const S=(d||"").trim().slice(0,32);if(S){x(!0);try{await i(S),f({nickname:S})}catch(k){alert(k.message)}finally{x(!1)}}}return r.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[r.jsx("input",{className:"field-input flex-1 min-w-0",value:d,onChange:b=>h(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!g}),r.jsx("button",{type:"submit",disabled:!g||p,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:p?"Saving…":n?"Set":"Save"})]})}function PN(n){const s=Array.isArray(n?.socials)?n.socials:null;if(s&&s.length)return s;const i=[];return n?.discord?.invite&&i.push({id:"discord",label:"Discord",url:n.discord.invite}),n?.kofi?.link&&i.push({id:"kofi",label:"Ko-fi",url:n.kofi.link}),i}function WN(n){if(!n||typeof n!="object")return null;const s=n.id||n.service||n.key||n.name||null,i=n.label||n.title||n.name||s||"Link",o=n.url||n.link||n.href||null;return o?{id:s,label:i,url:o}:null}function Qg({className:n=""}){const{session:s}=nn(),i=PN(s).map(WN).filter(Boolean).slice(0,4);return i.length?r.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:i.map(o=>r.jsx(md,{...o},`${o.id||o.label}-${o.url}`))}):null}function ew({compact:n=!1}){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(qo,{compact:n})})})}function tw(){return r.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:r.jsx(Qg,{className:"flex-1 min-h-0"})})}function yf(...n){return n.filter(Boolean).join(" ")}function nw(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 sw(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 lw(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function To({title:n="Rovers"}){const s=ft(A=>A.session),{requestControl:i}=wn(),[o,f]=m.useState({}),[d,h]=m.useState(()=>Date.now()),p=m.useMemo(()=>s?.role&&s.role!=="spectator",[s?.role]),x=m.useMemo(()=>s?.role==="admin"||s?.role==="lockdown"||s?.role==="lockdown-admin",[s?.role]),g=s?.roster??[],v=s?.turnQueues??{},b=s?.users??[],S=s?.socketId||null,k=m.useMemo(()=>Object.values(v||{}).some(A=>A?.deadline||A?.idleDeadline),[v]);m.useEffect(()=>{if(!k)return;const A=setInterval(()=>{h(Date.now())},1e3);return()=>clearInterval(A)},[k]);const C=m.useMemo(()=>{const A=new Set(g.map(q=>String(q.id))),N=Object.keys(v||{}).filter(q=>!A.has(String(q))).map(q=>({id:q,name:q,locked:!1,batteryState:null}));return[...g,...N]},[g,v]);async function E(A){if(A){f(N=>({...N,[A]:!0}));try{await i(A)}catch(N){alert(N.message)}finally{f(N=>({...N,[A]:!1}))}}}const w=A=>b.find(N=>N.socketId===A)||{socketId:A,nickname:null,role:null};return r.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&r.jsx("p",{className:"text-sm text-slate-400",children:n}),C.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):r.jsx("ul",{className:"space-y-0.5 text-sm",children:C.map(A=>{const N=String(A.id),q=v?.[N]||null,M=q?.queue||[],B=q?.idleDeadline||q?.deadline||null,K=B&&B>d?Math.ceil((B-d)/1e3):B?0:null,_=q?.current||null,H=_?M.findIndex(ie=>ie===_):-1,z=M.length>1?H>=0?M[(H+1)%M.length]:M[0]:null,V=!!(S&&_&&_===S),X=!!(S&&z&&z===S),te=K!=null&&(V||X),ue=!!A.locked,ce=ue&&!x,Y=!!(A?.private?.enabled&&A?.private?.open),T=A.lockReason?`locked: ${A.lockReason}`:"locked",$=ue?T:o[N]?"...":"request",J=p&&!ce&&!o[N];return r.jsxs("li",{className:yf("surface flex flex-wrap items-start justify-between gap-0.5",J&&"cursor-pointer",ue?"bg-red-900/40":Y?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{J&&E(A.id)},children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("p",{className:"text-slate-200",children:r.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ca(A.color,.16),children:A.name})}),te?r.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:V?`${K}s left`:`Your turn in ${K}s`}):null]}),r.jsx("span",{className:yf("text-[0.75rem] font-semibold",aw(A)),children:nw(A)})]}),M.length===0?r.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):r.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:M.map((ie,de)=>{const R=w(ie),U=ie===_,ee=!!(z&&ie===z&&!U),ae=U?"bg-sky-600 text-white ring-2 ring-amber-300":ee?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return r.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${ae}`,children:[r.jsx("span",{className:`${sw(R.role)} font-semibold`,children:lw(R,S)}),U&&r.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),ee&&r.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${N}-${ie}-${de}`)})})]}),p?r.jsx("button",{type:"button",onClick:ie=>{ie.stopPropagation(),E(A.id)},disabled:o[N]||ce,className:yf("button-dark disabled:opacity-40",ue&&"bg-red-600/70 text-white hover:bg-red-600"),children:$}):null]},A.id)})})]})}function iw(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 rw(n,s){if(!n)return"";const i=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===s?`${i} (you)`:i}function bo({hideNicknameForm:n=!1,hideHeader:s=!1,className:i="",fillHeight:o=!1,compact:f=!1}){const{session:d}=nn(),h=d?.role!=="spectator",p=d?.users??[],x=d?.socketId||null,g=m.useMemo(()=>[...p].sort((b,S)=>b.socketId===x?-1:S.socketId===x?1:(b.nickname||"").localeCompare(S.nickname||"")),[x,p]),v=o?"flex-1 min-h-0 overflow-y-auto":f?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return r.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${i}`,children:[!n&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[r.jsx("div",{className:"min-w-0",children:r.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:r.jsx(qo,{compact:f})})}),r.jsx(Qg,{})]}),!h&&r.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),r.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!s&&r.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${f?"text-xs":""}`,children:[r.jsx("span",{children:"Users"}),r.jsx("span",{className:"text-xs text-slate-500",children:g.length})]}),r.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${v} ${f?"text-[0.8rem]":""}`,children:g.length===0?r.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):g.map(b=>r.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${iw(b.role)}`,children:rw(b,x)},b.socketId))})]})]})}const ow=/^cu_[a-f0-9]{32}$/,Ei="field-input w-full max-w-sm text-left focus:ring-emerald-500",Do="mx-auto w-full max-w-xl flex justify-center",vi="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function cw(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 yx=8*1024*1024,is=16e3,uw={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function bx(n){let s="";for(let o=0;o<n.length;o+=32768){const f=n.subarray(o,o+32768);s+=String.fromCharCode(...f)}return btoa(s)}function fw(n){return typeof btoa=="function"?btoa(n):""}function dw(n){if(!n)return{};const s=fw(`${n}:${n}`);return s?{Authorization:`Basic ${s}`}:{}}function mw(n,s=1500){return new Promise(i=>{if(!n||n.iceGatheringState==="complete"){i();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",f),i()},s);function f(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",f),i())}n.addEventListener("icegatheringstatechange",f)})}function Sx(n){if(!n)return!1;const s=n.connectionState,i=n.iceConnectionState;return s==="connected"||i==="connected"||i==="completed"}function hw(n,s=1e4){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Sx(n)){i();return}const f=setTimeout(()=>{h(),o(new Error("Peer connection timeout"))},s),d=()=>{Sx(n)?(h(),i()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(h(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function h(){clearTimeout(f),n.removeEventListener("connectionstatechange",d),n.removeEventListener("iceconnectionstatechange",d)}n.addEventListener("connectionstatechange",d),n.addEventListener("iceconnectionstatechange",d)})}async function pw(n){if(!n?.getParameters||!n?.setParameters)return;const s=n.getParameters()||{},i=s.encodings&&s.encodings[0]||{};s.encodings=[{...i,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(s)}catch{}}function xw(n,s=6e3){return new Promise((i,o)=>{if(!n){o(new Error("Peer connection missing"));return}const f=Date.now();let d=-1;const h=setInterval(async()=>{if(Date.now()-f>s){clearInterval(h),o(new Error("WHIP connected but no outbound audio flow"));return}try{const p=n.getSenders().filter(x=>x.track?.kind==="audio");for(const x of p){const g=await x.getStats();for(const v of g.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const b=Number(v.bytesSent||0),S=Number(v.packetsSent||0);if(d<0)d=b;else if(b>d+200||S>5){clearInterval(h),i();return}}}}catch{}},250)})}function xn({label:n,active:s,detail:i=""}){return r.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${s?"bg-emerald-500":"bg-slate-700"}`,children:[r.jsx("div",{className:"text-center font-medium",children:n}),r.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:i||(s?"active":"idle")})]})}function jx({label:n}){return n?r.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function gw(n){const s=n.reduce((f,d)=>f+d.length,0),i=new Float32Array(s);let o=0;for(const f of n)i.set(f,o),o+=f.length;return i}function vw(n){const s=new Int16Array(n.length);for(let i=0;i<n.length;i+=1){const o=Math.max(-1,Math.min(1,n[i]));s[i]=o<0?o*32768:o*32767}return s}function yw(n,s){const i=vw(n),o=i.length*2,f=new ArrayBuffer(44+o),d=new DataView(f),h=(x,g)=>{for(let v=0;v<g.length;v+=1)d.setUint8(x+v,g.charCodeAt(v))};h(0,"RIFF"),d.setUint32(4,36+o,!0),h(8,"WAVE"),h(12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,1,!0),d.setUint32(24,s,!0),d.setUint32(28,s*2,!0),d.setUint16(32,2,!0),d.setUint16(34,16,!0),h(36,"data"),d.setUint32(40,o,!0);let p=44;for(let x=0;x<i.length;x+=1,p+=2)d.setInt16(p,i[x],!0);return new Uint8Array(f)}function bw({ownRoverId:n="",audioForwardByRover:s={},playUploadedAudio:i,stopUploadedAudio:o,startMicWhip:f,readyMicWhip:d,stopMicWhip:h}){const{state:p}=_t(),{value:x,save:g}=He("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[b,S]=m.useState(null),[k,C]=m.useState(!1),E=!!x?.openMicEnabled,A=(x?.pttMode==="clip"?"clip":"live")==="clip",[N,q]=m.useState("idle"),[M,B]=m.useState("idle"),[K,_]=m.useState(""),H=m.useRef(null),z=m.useRef(null),V=m.useRef(null),X=m.useRef(!1),te=m.useRef(""),ue=m.useRef(null),ce=m.useRef(null),Y=m.useRef(null),T=m.useRef(null),$=m.useRef(null),J=m.useRef([]),ie=m.useRef(!1),de=m.useRef(is),R=!!p?.mic?.pttActive,U=m.useMemo(()=>v&&s?.[v]||null,[s,v]),ee=!!(U&&U.state!=="offline"&&!U.error),ae=U?.source==="upload"&&U?.state==="playing",pe=U?.source==="mic-whip"&&(U?.state==="starting"||U?.state==="playing"),re=!!(!A&&z.current&&(E||R)),oe=!A&&(N==="live"||N==="starting"),ve=A&&M==="recording",ye=A&&M==="sending",xe=An(p?.keymap?.micPtt?.[0])||"M",Oe=m.useCallback(P=>{const fe=P==="clip"?"clip":"live";g(Ne=>({...Ne||{},pttMode:fe}))},[g]),ze=async()=>{if(!v){_("Take control of your rover first.");return}if(!b){_("Select an audio file first.");return}if(b.size>yx){_(`File too large (max ${yx} bytes).`);return}C(!0),_("");try{const P=await b.arrayBuffer(),fe=bx(new Uint8Array(P));await i?.({roverId:v,name:b.name,mime:b.type||"",dataBase64:fe}),_("Upload playback started.")}catch(P){_(P?.message||"Failed to play upload.")}finally{C(!1)}},Ae=async()=>{if(!v){_("Take control of your rover first.");return}C(!0),_("");try{await o?.(v),_("Upload playback stopped.")}catch(P){_(P?.message||"Failed to stop upload.")}finally{C(!1)}},tt=m.useCallback(async P=>{const fe=String(P||te.current||"").trim();if(X.current=!1,q("idle"),V.current){try{V.current.getSenders().forEach(Ne=>Ne.track?.stop())}catch{}try{V.current.close()}catch{}}if(V.current=null,H.current)try{H.current.getTracks().forEach(Ne=>Ne.stop())}catch{}if(H.current=null,z.current=null,fe)try{await h?.(fe)}catch{}te.current=""},[h]),Je=m.useCallback(async P=>{const fe=await f?.(P),Ne=String(fe?.whipUrl||"").trim(),pt=String(fe?.token||"").trim();if(!Ne||!pt)throw new Error("WHIP endpoint unavailable");const Ve=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});H.current=Ve;const st=Ve.getAudioTracks()?.[0];if(z.current=st||null,st&&(st.enabled=!!(E||R)),st?.applyConstraints)try{await st.applyConstraints({channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const lt=new RTCPeerConnection(uw);V.current=lt,lt.onconnectionstatechange=()=>{if(!X.current)return;const Yt=lt.connectionState;if(Yt==="connected"){q("live");return}(Yt==="failed"||Yt==="disconnected"||Yt==="closed")&&(q("error"),_(`WHIP transport ${Yt}.`))},Ve.getAudioTracks().forEach(Yt=>{const La=lt.addTrack(Yt,Ve);pw(La)});const Bt=await lt.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await lt.setLocalDescription(Bt),await mw(lt,1800);const it=await fetch(Ne,{method:"POST",headers:{"Content-Type":"application/sdp",...dw(pt)},body:lt.localDescription?.sdp||Bt.sdp});if(!it.ok)throw new Error(`WHIP request failed: ${it.status}`);const ds=await it.text();await lt.setRemoteDescription({type:"answer",sdp:ds}),await hw(lt,1e4),await xw(lt,6e3),await d?.(P)},[E,R,d,f]),vt=m.useCallback(async()=>{if(ie.current=!1,T.current){try{T.current.disconnect()}catch{}T.current.onaudioprocess=null}if(Y.current)try{Y.current.disconnect()}catch{}if($.current)try{$.current.disconnect()}catch{}if(ue.current)try{ue.current.getTracks().forEach(P=>P.stop())}catch{}if(ce.current)try{await ce.current.close()}catch{}J.current=[],T.current=null,Y.current=null,$.current=null,ue.current=null,ce.current=null,de.current=is},[]),le=m.useCallback(async()=>{if(ue.current&&ce.current&&T.current)return;B(st=>st==="recording"?st:"arming");const P=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:is,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),fe=new AudioContext({latencyHint:"interactive"}),Ne=fe.createMediaStreamSource(P),pt=fe.createScriptProcessor(1024,1,1),Ve=fe.createGain();Ve.gain.value=0,pt.onaudioprocess=st=>{if(!ie.current)return;const lt=st.inputBuffer.getChannelData(0);J.current.push(new Float32Array(lt))},Ne.connect(pt),pt.connect(Ve),Ve.connect(fe.destination),ue.current=P,ce.current=fe,Y.current=Ne,T.current=pt,$.current=Ve,de.current=fe.sampleRate||is},[]),me=m.useCallback(async({send:P})=>{const fe=ie.current;if(ie.current=!1,!fe){P||B("idle");return}const Ne=J.current;if(J.current=[],!P){B("idle");return}if(!v){B("idle");return}if(!Ne.length){B("idle");return}B("sending");try{const pt=gw(Ne),Ve=yw(pt,de.current||is),st=bx(Ve);await i?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:st}),B("idle")}catch(pt){B("error"),_(pt?.message||"Failed to send PTT clip.")}},[i,v]),se=m.useCallback(async()=>{if(!v){_("Take control of your rover first.");return}await le(),J.current=[],ie.current=!0,B("recording")},[le,v]);return m.useEffect(()=>{let P=!1;async function fe(){if(A){await tt(te.current||v);return}if(!v){await tt(te.current);return}if(!(X.current&&te.current===v)&&!(!E&&!R))try{q("starting"),_(""),X.current=!0,te.current=v,await Je(v),P||q("live")}catch(Ne){P||(q("error"),_(Ne?.message||"Failed to start mic forwarding.")),await tt(v)}}return fe(),()=>{P=!0}},[A,E,R,v,Je,tt]),m.useEffect(()=>{const P=z.current;P&&(P.enabled=!!(!A&&(E||R)))},[A,E,R]),m.useEffect(()=>{let P=!1;async function fe(){if(!A||!v){ie.current&&await me({send:!1}),B("idle");return}try{await le(),!P&&!ie.current&&B("idle")}catch(Ne){P||(B("error"),_(Ne?.message||"Microphone access failed for clip mode."))}}return fe(),()=>{P=!0}},[A,le,me,v]),m.useEffect(()=>{let P=!1;async function fe(){if(A){if(!v){ie.current&&await me({send:!1});return}if(R){if(!ie.current)try{_(""),await se()}catch(Ne){P||(B("error"),_(Ne?.message||"Failed to start clip recording."))}}else ie.current&&await me({send:!0})}}return fe(),()=>{P=!0}},[A,me,R,v,se]),m.useEffect(()=>()=>{tt(te.current||v),vt()},[v,tt,vt]),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[r.jsx("span",{children:"Push-to-Talk Key"}),r.jsx(jx,{label:xe})]})}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),r.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),r.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${A?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>Oe("live"),children:"Live Mic (WHIP)"}),r.jsx("button",{type:"button",className:`button-dark w-full text-sm ${A?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>Oe("clip"),children:"Record Clip"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(xn,{label:"Mode",active:A,detail:A?"record clip":"live mic"}),r.jsx(xn,{label:"PTT hold",active:R,detail:R?"held":"released"}),r.jsx(xn,{label:"Recording",active:ve,detail:ve?"capturing":"idle"}),r.jsx(xn,{label:"Playback",active:A&&ae,detail:A&&ae?"playing":"idle"})]})]})})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),r.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),r.jsx("input",{className:`${Ei} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:k||!v,onChange:P=>S(P.target.files?.[0]||null)})]}),r.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?r.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):r.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:k||!v,onClick:ze,children:k?"Working...":"Play Upload"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:k||!v,onClick:Ae,children:"Stop"})]})]})}),r.jsx("section",{className:"surface h-full",children:r.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),r.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[r.jsx("input",{type:"checkbox",checked:E,disabled:!v||A,onChange:P=>g(fe=>({...fe||{},openMicEnabled:!!P.target.checked}))}),r.jsx("span",{children:A?"Open mic (live mode only)":"Open mic"})]}),r.jsxs("div",{className:"grid gap-0.5 content-start",children:[r.jsx(xn,{label:"WHIP link",active:oe,detail:N}),r.jsx(xn,{label:"Mic hot",active:re,detail:re?"transmitting":"muted"}),r.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",r.jsx(jx,{label:xe})," to talk"]})]})]})})]}),r.jsx("section",{className:"surface",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[r.jsx(xn,{label:"Forward pipe",active:ee,detail:ee?"connected":"offline"}),r.jsx(xn,{label:"Upload playback",active:ae,detail:ae?"playing":"idle"}),r.jsx(xn,{label:"Mic relay",active:pe,detail:pe?"active":"idle"}),r.jsx(xn,{label:"WHIP transport",active:oe,detail:N}),r.jsx(xn,{label:"Clip recording",active:ve,detail:ve?"recording":"idle"}),r.jsx(xn,{label:"Clip sending",active:ye,detail:ye?"sending":"idle"})]}),K?r.jsx("div",{className:"text-xs text-slate-400 text-center",children:K}):null]})})]})}function Sw({pendingRequestId:n,currentStoredKey:s,nickname:i,requestVerification:o,applyIdentityKey:f,onMessage:d,fullWidth:h=!1}){const[p,x]=m.useState(0),[g,v]=m.useState(""),[b,S]=m.useState(!1),[k,C]=m.useState(!1),E=()=>{x(1),v(s),S(!1),d?.("")},w=()=>{x(0),S(!1)},A=async q=>{if(q.preventDefault(),!b){d?.("Please confirm your nickname agreement before sending.");return}if(p<3){d?.("Complete all request steps before sending.");return}C(!0),d?.("");try{const M=await f(g);await o?.(),v(M),x(0),S(!1),d?.("Verification request sent to lockdown admins.")}catch(M){d?.(M.message||"Failed to submit request.")}finally{C(!1)}},N=h?"w-full":Do;return n?r.jsx("section",{className:`surface text-sm text-slate-300 ${N}`,children:r.jsxs("div",{className:vi,children:["Verification request pending: ",n]})}):p===0?r.jsx("section",{className:`surface ${N}`,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:E,disabled:k,children:"Request Verification"})]})}):r.jsx("form",{className:`surface ${N}`,onSubmit:A,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",p," of 3"]}),p===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),r.jsx("div",{className:"mx-auto w-full max-w-sm",children:r.jsx(qo,{compact:!0})}),r.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",r.jsx("span",{className:"font-semibold",children:i||"(not set)"})]}),r.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[r.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:q=>S(q.target.checked)}),r.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!i||!b,onClick:()=>x(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,p===2?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),r.jsx("input",{className:Ei,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:g,onChange:q=>v(q.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>navigator.clipboard?.writeText(g),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!g,onClick:()=>x(3),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(1),children:"Back"})]})]}):null,p===3?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),r.jsx("input",{className:Ei,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:g,onChange:q=>v(q.target.value.toLowerCase()),placeholder:"Identity key for this request"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:k||!g,children:"Confirm Request"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>x(2),children:"Back"})]})]}):null]})})}function jw({currentStoredKey:n,applyIdentityKey:s,onMessage:i,fullWidth:o=!1}){const[f,d]=m.useState(0),[h,p]=m.useState(""),[x,g]=m.useState(!1),v=()=>{d(1),p(""),i?.("")},b=()=>{d(0),p("")},S=async C=>{if(C.preventDefault(),!(f<2)){g(!0),i?.("");try{await s(h),d(0),p(""),i?.("Identity key restored.")}catch(E){i?.(E.message||"Failed to restore key.")}finally{g(!1)}}},k=o?"w-full":Do;return r.jsx("section",{className:`surface ${k}`,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),r.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",cw(n)||"not set yet"]}),r.jsx("input",{className:Ei,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),f===0?r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:v,disabled:x,children:"Restore Key"})]}):null,f===1?r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(2),children:"Continue"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,f===2?r.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[r.jsx("input",{className:Ei,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:h,onChange:C=>p(C.target.value.toLowerCase()),placeholder:"Paste key to restore"}),r.jsxs("div",{className:"flex justify-center gap-0.5",children:[r.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:x||!h,children:"Confirm Restore"}),r.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>d(1),children:"Back"})]})]}):null]})})}function Aw({requestableRovers:n=[],pendingRequests:s=[],requestPrivateRoverAccess:i,onMessage:o,fullWidth:f=!1}){const[d,h]=m.useState({}),p=m.useMemo(()=>{const v=new Map;return(s||[]).forEach(b=>{b?.roverId&&v.set(String(b.roverId),b)}),v},[s]),x=f?"w-full":Do,g=async v=>{if(v){h(b=>({...b,[v]:!0})),o?.("");try{(await i?.(v))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{h(b=>({...b,[v]:!1}))}}};return r.jsx("section",{className:`surface text-sm text-slate-300 ${x}`,children:r.jsxs("div",{className:vi,children:[r.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?r.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):r.jsx("div",{className:"w-full space-y-0.5",children:n.map(v=>{const b=String(v.id),S=!!d[b],k=p.get(b);return r.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:v.name||b}),r.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),k?r.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):r.jsx("button",{type:"button",onClick:()=>g(b),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},b)})})]})})}function Kg(){const{session:n,identifySession:s,requestVerification:i,requestPrivateRoverAccess:o,playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x}=nn(),{value:g,save:v}=He("identity",{cookieUserId:""}),{value:b}=He("profile",{nickname:""}),S=m.useMemo(()=>(g?.cookieUserId||"").trim(),[g?.cookieUserId]),k=(b?.nickname||"").trim(),C=!!n?.isVerified,E=n?.verification?.pendingRequestId||null,w=n?.privateRoverAccess?.requestableRovers||[],A=n?.privateRoverAccess?.pendingRequests||[],N=String(n?.assignment?.roverId||"").trim(),[q,M]=m.useState(""),B=async K=>{const _=String(K||"").trim().toLowerCase();if(!_)throw new Error("Identity key required.");if(!ow.test(_))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return v(H=>({...H||{},cookieUserId:_})),await s({cookieUserId:_,nickname:k}),_};return r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[r.jsx("div",{className:"lg:col-span-2",children:C?r.jsx("section",{className:"surface w-full",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center",children:[r.jsx("p",{className:"text-sm text-emerald-300",children:"Verification complete"}),r.jsx("p",{className:"text-xs text-slate-400",children:"VIP controls are unlocked for your assigned rover."})]})}):r.jsx(Sw,{pendingRequestId:E,currentStoredKey:S,nickname:k,requestVerification:i,applyIdentityKey:B,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:C?r.jsx(bw,{ownRoverId:N,audioForwardByRover:n?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:d,startMicWhip:h,readyMicWhip:p,stopMicWhip:x}):r.jsx("section",{className:"surface h-full",children:r.jsx("div",{className:"flex h-full flex-col items-center justify-center text-center text-xs text-slate-400",children:"Verify your account to unlock VIP controls."})})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(Aw,{requestableRovers:w,pendingRequests:A,requestPrivateRoverAccess:o,onMessage:M,fullWidth:!0})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsx(jw,{currentStoredKey:S,applyIdentityKey:B,onMessage:M,fullWidth:!0})})]}),q?r.jsx("div",{className:Do,children:r.jsx("p",{className:"text-xs text-slate-400 text-center",children:q})}):null]})}const Nw=420,ww=1200,Cw={1:262,2:330,3:392,4:523};function So(){const{session:n}=nn(),s=tn(),{value:i}=He("audio",ct),o=Number.isFinite(i?.masterVolume)?i.masterVolume:ct.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:ct.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=m.useMemo(()=>{const E=Array.isArray(n?.buttonBox?.buttons)?n.buttonBox.buttons:[];return E.length===4?E:[1,2,3,4].map(w=>E.find(A=>Number(A?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n?.buttonBox?.buttons]),[p,x]=m.useState({}),[g,v]=m.useState({}),b=m.useRef(new Map),S=m.useRef(new Map),k=m.useRef({}),C=m.useRef(null);return m.useEffect(()=>{const E={};h.forEach(A=>{E[A.id]=Number(A.lastRewardAt||0)});const w=k.current||{};h.forEach(A=>{const N=Number(A.id),q=E[N]||0,M=Number(w[N]||0);if(q>0&&q!==M){v(_=>({..._,[N]:!0}));const B=S.current.get(N);B&&clearTimeout(B);const K=setTimeout(()=>{v(_=>({..._,[N]:!1})),S.current.delete(N)},ww);S.current.set(N,K)}}),k.current=E},[h]),m.useEffect(()=>{function E(A){const N=Cw[A];if(!N||d<=0)return;let q=C.current;if(!q){const _=window.AudioContext||window.webkitAudioContext;if(!_)return;q=new _,C.current=q}const M=q.createOscillator(),B=q.createGain();M.type="square",M.frequency.value=N;const K=.14*d;B.gain.setValueAtTime(1e-4,q.currentTime),B.gain.exponentialRampToValueAtTime(Math.max(1e-4,K),q.currentTime+.01),B.gain.exponentialRampToValueAtTime(1e-4,q.currentTime+.2),M.connect(B),B.connect(q.destination),M.start(),M.stop(q.currentTime+.21)}function w(A={}){const N=Number(A.buttonId);if(!Number.isFinite(N)||N<1||N>4)return;x(B=>({...B,[N]:!0}));const q=b.current.get(N);q&&clearTimeout(q);const M=setTimeout(()=>{x(B=>({...B,[N]:!1})),b.current.delete(N)},Nw);b.current.set(N,M),E(N)}return s.on("buttonBox:increment",w),()=>{s.off("buttonBox:increment",w)}},[d,s]),r.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[r.jsx("header",{className:"panel-muted text-center text-sm",children:r.jsx("p",{children:"Button Box"})}),r.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:h.map(E=>{const w=Number(E.id),A=Number.isFinite(E.count)?E.count:0,N=Number.isFinite(E.goal)?E.goal:0,q=typeof E.rewardName=="string"&&E.rewardName.trim()?E.rewardName.trim():"Unassigned",M=Number.isFinite(E.rewardNumber)?E.rewardNumber:"?",B=!!p[w],K=!!g[w];return r.jsx(hg,{buttonId:w,count:A,goal:N,rewardNumber:M,rewardName:q,className:[B?"bg-cyan-900/45":"",K?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function Ew(){const{state:{roverId:n}}=_t(),i=dl(n)?.sensors||{};return r.jsx("section",{className:"panel-section",children:r.jsx("div",{className:"aspect-square w-full",children:r.jsx(zf,{sensors:i})})})}function kw(){const{state:{roverId:n,keymap:s,camera:i,horn:o},pipeline:f,actions:{setServoAngle:d,setNightVision:h,startHorn:p,stopHorn:x}}=_t(),g=Mg(n),v=g.docked&&!g.driving,b=i?.config,S=!!(n&&i?.enabled&&b),k=!!(n&&f?.nightVision),C=f?.nightVisionState,E=!!(n&&f?.horn),w=o?.overheated,A=typeof b?.minAngle=="number"?b.minAngle:-30,N=typeof b?.maxAngle=="number"?b.maxAngle:30,q=typeof i?.angle=="number"?i.angle:typeof b?.homeAngle=="number"?b.homeAngle:(A+N)/2,M=An(s?.nightVisionToggle?.[0]),B=An(s?.hornHonk?.[0]),K=An(s?.cameraUp?.[0]),_=An(s?.cameraDown?.[0]);return r.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[r.jsx(Rg,{layout:"desktop",expand:!0,driveDockState:g}),v?null:r.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[k&&r.jsx(qg,{nightVisionOn:C?.nightVisionOn,disabled:!n,onToggle:h,keyLabel:M}),E&&r.jsx(Tg,{disabled:!n||w,onStart:p,onStop:x,keyLabel:B,active:o?.active,heat:o?.heat}),S&&r.jsx(Dg,{value:q,min:A,max:N,onChange:d,keyDownLabel:_,keyUpLabel:K,className:"space-y-0.5 px-1 py-1",labelRowClass:"text-xs text-slate-300",labelClass:"",valueClass:"font-mono text-slate-100",sliderClass:"w-full",accentClass:"accent-emerald-400",endpointClass:"text-[0.7rem] text-slate-400"})]})]})}function Mw({layout:n,onOpenHelpOverlay:s}){const i=ft(k=>k.session),{state:o}=_t(),{value:f}=He("vipAudio",{openMicEnabled:!1,pttMode:"live"}),d=i?.isVerified?"bg-emerald-400":"bg-red-600",h=String(i?.assignment?.roverId||"").trim(),p=h?i?.audioForward?.[h]:null,x=!!o?.mic?.pttActive,g=!!f?.openMicEnabled,v=f?.pttMode==="clip"?"clip":"live",b=!!(h&&i?.isVerified&&(v==="clip"?x:g||x)),S=!!(h&&i?.isVerified&&v==="clip"&&p?.source==="upload"&&p?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(vd,{defaultTab:"telemetry",children:[r.jsxs(yd,{children:[r.jsx(Wt,{id:"telemetry",children:"Controls"}),r.jsx(Wt,{id:"vip",highlight:S?"green":b?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${d}`,"aria-hidden":"true",title:i?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(bd,{children:[r.jsx(en,{id:"telemetry",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[r.jsx(Ew,{}),r.jsx(kw,{})]}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[r.jsx(To,{}),r.jsx(td,{panelId:"replay-sources-desktop",fillHeight:!0}),r.jsx(tw,{})]}),r.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[r.jsx(Ro,{fillHeight:!0}),r.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[r.jsx(bo,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),r.jsx(ew,{compact:!0})]})]}),r.jsx(zg,{}),r.jsx(So,{}),r.jsx(cd,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Kg,{})}),r.jsx(en,{id:"help",children:r.jsx(Xg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsx(Gg,{})})]})]})})}const Rw=new Set(["admin","lockdown","lockdown-admin"]),qw=new Set(["lockdown","lockdown-admin"]),Tw=new Set(["admin","lockdown"]);function Dw(n="admin"){return n==="lockdown"?{title:"Lockdown mode active",description:"Only the server owners can access the interface at this time."}:{title:"Admin mode active"}}function _w(){const n=ft(S=>S.session),s=n?.mode,i=n?.role,o=n?.adminReason?.text||"";n?.adminReason?.updatedAt;const f=n?.timezone||"UTC",d=n?.socials?.find(S=>String(S?.id||S?.label||"").toLowerCase()==="discord")?.url||n?.discord?.invite||null,h=Tw.has(s),p=s==="lockdown"?qw.has(i):Rw.has(i),[x,g]=m.useState(()=>new Date),v=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:f,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(x)}catch{return x.toLocaleTimeString()}},[x,f]);if(m.useEffect(()=>{const S=setInterval(()=>g(new Date),1e3);return()=>clearInterval(S)},[]),!h||p)return null;const b=Dw(s);return r.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black/85 px-0.5 py-0.5",children:r.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-lg font-semibold",children:b.title}),r.jsx("p",{className:"text-sm text-slate-300",children:b.description})]}),r.jsxs("div",{className:"surface-muted space-y-0.5",children:[r.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),r.jsx("p",{className:"text-lg font-semibold text-slate-100",children:o||"No reason set."}),r.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",v]})]}),r.jsx("div",{className:"surface-muted",children:r.jsx(Ug,{})}),r.jsx("div",{className:"w-full justify-center items-center",children:r.jsx(md,{id:"discord",label:"Join our Discord server for updates!",url:d})}),"You can still use the chat while the server is locked:",r.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[r.jsx(Ro,{}),r.jsx(qo,{})]})]})})}const Ow="/assets/turn_alert-DVO8EZJa.mp3";function Bw(n,s=1){const i=m.useRef(null);return m.useEffect(()=>{i.current=new Audio(n),i.current.volume=s,i.current.load()},[n,s]),()=>{i.current&&(i.current.volume=s,i.current.currentTime=0,i.current.play().catch(()=>{}))}}function Lw(){const n=ft(v=>v.session),{pushAlert:s}=wn(),{value:i}=He("audio",ct),o=Number.isFinite(i?.masterVolume)?i.masterVolume:ct.masterVolume,f=Number.isFinite(i?.alertVolume)?i.alertVolume:ct.alertVolume,d=Math.max(0,Math.min(1,o*f)),h=Bw(Ow,d),p=m.useRef(new Set),x=m.useMemo(()=>n?.turnQueues||{},[n?.turnQueues]),g=n?.socketId||null;return m.useEffect(()=>{if(!g)return;const v=[];Object.entries(x).forEach(([b,S])=>{!S||!S.current||S.current!==g||p.current.has(b)||(v.push(b),p.current.add(b))}),Object.keys(x).forEach(b=>{(!x[b]||x[b].current!==g)&&p.current.delete(b)}),v.length!==0&&(v.forEach(b=>{const S=n?.roster?.find(k=>String(k.id)===String(b))?.name||b;s({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),h())},[x,h,s,n?.roster,g]),null}function zw({visible:n,mode:s,onEnterFullscreen:i,onDismiss:o}){if(!n)return null;const f=s==="pwa-hint";return r.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center p-2 pointer-events-none sm:items-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-sm rounded-lg border border-cyan-500/40 bg-zinc-950/95 shadow-xl",children:r.jsxs("div",{className:"space-y-0.5 p-4 text-sm text-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-white",children:"Better in fullscreen"}),f?r.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",r.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen removes the browser chrome."]}):r.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),r.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[r.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:f?"Got it":"Not now"}),!f&&r.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:i,children:"Enter fullscreen"})]})]})})})}function Uw({side:n="right",onClick:s}){const i=n==="left"?"left-2":"right-2";return r.jsx("button",{type:"button",onClick:s,className:`fixed bottom-2 ${i} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-cyan-200/50 bg-slate-900/70 text-cyan-100 shadow-lg backdrop-blur-sm transition hover:bg-slate-800/80 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:r.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:r.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Zg="fullscreenPromptDismissed",Hw=new Set(["mobile-portrait","mobile-landscape"]),Ig=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},Vw=()=>{const n=Ig();if(!n)return!1;try{return n.getItem(Zg)==="1"}catch{return!1}},Ax=()=>{const n=Ig();if(n)try{n.setItem(Zg,"1")}catch{}},$w=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Nx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function Gw(n){const s=Hw.has(n),[i,o]=m.useState(!1),[f,d]=m.useState("native"),[h,p]=m.useState(!1),x=m.useMemo(()=>$w(),[]),g=m.useMemo(()=>Nx(),[]),v=m.useCallback(()=>{if(!s){o(!1),p(!1);return}if(!h&&Vw()){o(!1);return}if(x){d("pwa-hint"),o(!0);return}if(!Nx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}d("native"),o(!0)},[h,x,s]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const C=()=>{if(document.fullscreenElement){p(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",C),document.addEventListener("webkitfullscreenchange",C),()=>{document.removeEventListener("fullscreenchange",C),document.removeEventListener("webkitfullscreenchange",C)}},[v]);const b=m.useCallback(()=>{Ax(),p(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!s||x||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const C=document.documentElement;if(!C)return!1;const E=C.requestFullscreen||C.webkitRequestFullscreen||C.mozRequestFullScreen||C.msRequestFullscreen;if(!E)return!1;try{const w=E.call(C);return w&&typeof w.then=="function"&&await w,Ax(),p(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[x,s]),k=m.useCallback(()=>{s&&(p(!0),d(x?"pwa-hint":"native"),o(!0))},[x,s]);return m.useEffect(()=>{s||(p(!1),o(!1))},[s]),{visible:i,mode:f,isIOS:x,nativeSupported:g,enterFullscreen:S,dismiss:b,showPrompt:k}}function Yw({visible:n,layout:s,onClose:i,showOnLoad:o,onToggleShowOnLoad:f}){if(!n)return null;const{state:d}=_t(),h=p=>{const x=!p.target.checked;f?.(x)};return r.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:r.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[r.jsx("span",{className:"font-semibold",children:"Help & controls"}),r.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[r.jsxs("label",{className:"flex items-center gap-0.5",children:[r.jsx("input",{type:"checkbox",checked:!o,onChange:h,className:"accent-cyan-500"}),r.jsx("span",{children:"Don't show again"})]}),r.jsx("button",{type:"button",onClick:i,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),r.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:r.jsx(Fg,{layout:s,keymap:d?.keymap||{}})})]})})}const Fw=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
`;function Xw(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function Qw(){const n=String(Fw).split(/\r?\n/).map(i=>i.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function Sd(){const{setNickname:n}=wn(),{value:s,status:i,save:o}=He("profile",{nickname:""}),f=m.useRef(!1);m.useEffect(()=>{if(i!=="ready"||f.current||(s.nickname||"").trim())return;f.current=!0;const h=Xw(Qw()).slice(0,32);if(!h)return;(async()=>{try{await n(h)}catch{}finally{o({nickname:h})}})()},[o,n,i,s.nickname])}function Kw(){const n=tn(),s=ft(w=>w.connected),{identifySession:i}=wn(),{value:o,status:f,save:d}=He("identity",{cookieUserId:""}),{value:h,status:p}=He("profile",{nickname:""}),x=m.useRef(!1),g=m.useRef(null),v=m.useRef(null),b=f==="ready"&&p==="ready",S=(o?.cookieUserId||"").trim(),k=(h?.nickname||"").trim(),C=m.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),E=m.useCallback(async()=>{if(!(!b||!s||!n?.id||x.current)){x.current=!0;try{const A=((await i({cookieUserId:S,nickname:k}))?.cookieUserId||"").trim();A&&A!==S&&d(N=>({...N||{},cookieUserId:A})),g.current=n.id,C()}catch{C(),v.current=setTimeout(()=>{E()},2e3)}finally{x.current=!1}}},[C,s,S,i,k,b,d,n?.id]);m.useEffect(()=>{!b||!s||!n?.id||g.current!==n.id&&E()},[s,b,E,n?.id]),m.useEffect(()=>{!b||!s||!n?.id||E()},[b,s,n?.id,S,k,E]),m.useEffect(()=>{const w=()=>{n?.connected&&E()},A=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&E()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",A)}},[E,n?.connected]),m.useEffect(()=>()=>C(),[C])}const bf=1e4,Sf=28,Zw=14;function jo({layout:n="desktop",className:s="",dismissable:i=!0}){const{session:o}=nn(),f=o?.communityGoal?.text?String(o.communityGoal.text).trim():"",d=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[h,p]=m.useState(!1),[x,g]=m.useState(Sf),[v,b]=m.useState(0),S=m.useRef(null),k=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!f){p(!1);return}if(p(!0),!d||!i)return;const N=Date.now();b(bf);const q=setTimeout(()=>p(!1),bf),M=setInterval(()=>{const B=Date.now()-N;b(Math.max(0,bf-B))},250);return()=>{clearTimeout(q),clearInterval(M)}},[f,d]),m.useEffect(()=>{if(!f)return;g(Sf);let N=0;const q=()=>{const B=C.current,K=k.current;if(!B||!K)return;const _=B.clientWidth;if(!_)return;const H=K.scrollWidth;if(!H)return;const z=Math.min(1,_/H),V=Math.max(Zw,Math.floor(Sf*z));g(V)};N=window.requestAnimationFrame(q);const M=new ResizeObserver(()=>{window.cancelAnimationFrame(N),N=window.requestAnimationFrame(q)});return S.current&&M.observe(S.current),()=>{window.cancelAnimationFrame(N),M.disconnect()}},[f]);const E=m.useMemo(()=>["panel-section flex w-full items-center justify-center",d?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",s].filter(Boolean).join(" "),[s,d]);if(!f||!h)return null;const w=d?Math.ceil(v/1e3):null,A=i?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return r.jsx("div",{ref:S,className:E,style:{fontSize:`${x}px`,lineHeight:1.1},...A,children:r.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[r.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[r.jsx("span",{children:"Community"}),r.jsx("span",{children:"Goal"})]}),r.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:r.jsx("span",{ref:k,className:"block",children:f})}),d?r.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[w,"s"]}):null]})})}const Iw=3200;function Jw(n={}){const s=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",i=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))):i;return{rewardName:s,goal:i,count:o,ts:Date.now()}}function Jg(){const n=tn(),{value:s}=He("audio",ct),i=Number.isFinite(s?.masterVolume)?s.masterVolume:ct.masterVolume,o=Number.isFinite(s?.alertVolume)?s.alertVolume:ct.alertVolume,f=Math.max(0,Math.min(1,i*o)),[d,h]=m.useState(null),p=m.useRef(null);return m.useEffect(()=>{p.current=new Audio("/tada.mp3"),p.current.volume=f,p.current.load()},[f]),m.useEffect(()=>{let x=null;function g(){const S=p.current;S&&(S.volume=f,S.currentTime=0,S.play().catch(()=>{}))}function v(S={}){const k=Jw(S);h(k),g(),x&&clearTimeout(x),x=setTimeout(()=>{h(null)},Iw)}function b(S){v(S?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",b),()=>{x&&clearTimeout(x),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",b)}},[f,n]),d?r.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:r.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:r.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[r.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",d.rewardName,"!"]}),r.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[d.count,"/",d.goal]})]}),r.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function Pw(){const[n,s]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function i(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:f}=window;o>=1024?s("desktop"):o>f?s("mobile-landscape"):s("mobile-portrait")}return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),n}function Ww({layout:n,onOpenHelpOverlay:s}){return r.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[r.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[r.jsx(hd,{}),r.jsx(WS,{}),r.jsx(ud,{})]}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[r.jsx(jo,{layout:n}),r.jsx(Mw,{layout:n,onOpenHelpOverlay:s})]})]})}function Pg({layout:n,onOpenHelpOverlay:s,roomPanelId:i,showTelemetry:o=!0}){const f=ft(E=>E.session),{state:d}=_t(),{value:h}=He("vipAudio",{openMicEnabled:!1,pttMode:"live"}),p=f?.isVerified?"bg-emerald-400":"bg-amber-400",x=String(f?.assignment?.roverId||"").trim(),g=x?f?.audioForward?.[x]:null,v=!!d?.mic?.pttActive,b=!!h?.openMicEnabled,S=h?.pttMode==="clip"?"clip":"live",k=!!(x&&f?.isVerified&&(S==="clip"?v:b||v)),C=!!(x&&f?.isVerified&&S==="clip"&&g?.source==="upload"&&g?.state==="playing");return r.jsx("section",{className:"panel text-base",children:r.jsxs(vd,{defaultTab:"chat",children:[r.jsxs(yd,{children:[r.jsx(Wt,{id:"chat",children:"Chat"}),r.jsx(Wt,{id:"vip",highlight:C?"green":k?"pink":"none",children:r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{children:"VIP"}),r.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${p}`,"aria-hidden":"true",title:f?.isVerified?"Verified":"Not verified"})]})}),r.jsx(Wt,{id:"roomcontrols",children:"Room Controls"}),r.jsx(Wt,{id:"help",children:"Help"}),r.jsx(Wt,{id:"settings",children:"Settings"})]}),r.jsxs(bd,{children:[r.jsx(en,{id:"chat",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ro,{}),r.jsx(bo,{})]})}),r.jsx(en,{id:"vip",keepMounted:!0,children:r.jsx(Kg,{})}),r.jsx(en,{id:"roomcontrols",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zg,{}),r.jsx(So,{}),r.jsx(cd,{panelId:i})]})}),r.jsx(en,{id:"help",children:r.jsx(Xg,{layout:n,onOpenOverlay:s})}),r.jsx(en,{id:"settings",children:r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Gg,{}),r.jsx(ud,{})]})})]})]})})}function e2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx(hd,{layoutFormat:"mobile-portrait"}),r.jsx(wA,{swapColumns:s}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(td,{panelId:"replay-sources-mobile-portrait"}),r.jsx(To,{})]}),r.jsx(Pg,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function t2({onOpenHelpOverlay:n,swapMobileControlColumns:s=!1}){const i="self-start h-[min(100svh,32rem)]",o=s?r.jsx(vo,{layout:"landscape",className:i}):r.jsx(go,{layout:"landscape",className:i}),f=s?r.jsx(go,{layout:"landscape",className:i}):r.jsx(vo,{layout:"landscape",className:i});return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,r.jsxs("div",{children:[r.jsx(hd,{layoutFormat:"mobile-landscape"}),r.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[r.jsx(td,{panelId:"replay-sources-mobile-landscape"}),r.jsx(To,{})]})]}),f]}),r.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:r.jsx(Pg,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function n2(){const n=Pw(),s=n==="desktop",i=Gw(n);return r.jsx("div",{className:`bg-black text-slate-100 ${s?"h-screen overflow-hidden":"min-h-screen"}`,children:r.jsx(a2,{layout:n,isDesktop:s,fullscreen:i})})}function a2({layout:n,isDesktop:s,fullscreen:i}){Sd(),Kw();const{visible:o,mode:f,isIOS:d,nativeSupported:h,enterFullscreen:p,dismiss:x,showPrompt:g}=i,{value:v,status:b,save:S}=He("help",{showOnLoad:!0}),{value:k}=He("page",{swapMobileControlColumns:!1}),C=!!k?.swapMobileControlColumns,E=C?"left":"right",w=!s&&(d||h),[A,N]=m.useState(!1);m.useEffect(()=>{b==="ready"&&N(v?.showOnLoad!==!1)},[b,v?.showOnLoad]);const q=m.useCallback(()=>N(!0),[]),M=m.useCallback(()=>N(!1),[]),B=m.useCallback(async()=>{if(d){g();return}await p()||g()},[p,d,g]),K=m.useCallback(H=>{const z=!!H;S(V=>({...V??{},showOnLoad:z})),z||N(!1)},[S]),_=m.useMemo(()=>s?r.jsx(Ww,{layout:n,onOpenHelpOverlay:q}):n==="mobile-landscape"?r.jsx(t2,{onOpenHelpOverlay:q,swapMobileControlColumns:C}):r.jsx(e2,{onOpenHelpOverlay:q,swapMobileControlColumns:C}),[s,n,q,C]);return r.jsxs(Xj,{children:[r.jsx(aA,{}),r.jsx(pA,{}),r.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${s?"h-full overflow-hidden":""}`,children:[s?null:r.jsx(jo,{layout:n}),_]}),r.jsx(sd,{}),r.jsx(Jg,{}),r.jsx(Lw,{}),r.jsx(_w,{}),r.jsx(Yw,{visible:A,layout:n,onClose:M,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:K}),r.jsx(zw,{visible:o,mode:f,onEnterFullscreen:p,onDismiss:x}),w?r.jsx(Uw,{side:E,onClick:B}):null]})}function Wg(){const{session:n,setRole:s,subscribeAll:i,connected:o}=nn(),[f,d]=m.useState(!1);return m.useEffect(()=>{let h=!1;async function p(){if(n?.mode==="lockdown"){d(!1);return}try{n?.role!=="spectator"&&await s("spectator"),await i(),h||d(!0)}catch(x){console.error("Failed to enter spectator mode",x),h||d(!1)}}return p(),()=>{h=!0}},[o,n?.mode,n?.role,s,i]),f}function s2(){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 i=window.matchMedia("(max-aspect-ratio: 4/3)"),o=f=>s(f.matches);return i.addEventListener?i.addEventListener("change",o):i.addListener(o),()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener(o)}},[]),n}function l2({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(x=>x.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f} (turns)`:f}function i2({rover:n,frame:s,sessionInfo:i,videoMode:o,snapshotFeed:f,audioInfo:d,session:h}){const p=l2({roverId:n.id,session:h});return r.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:r.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:r.jsx(Ni,{sessionInfo:i,videoMode:o,snapshotFeed:f,audioSessionInfo:d,label:n.name,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,hudVariant:"spectator",driverLabel:p,hudForceMap:!0,hudMapPosition:"top-center"})})})}function r2({roster:n,frames:s,videoSources:i,snapshotFeeds:o,audioSources:f,session:d,canSpectateVideo:h}){return n.length===0?r.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):r.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(p=>r.jsx(i2,{rover:p,frame:s[p.id],sessionInfo:h&&i[p.id]||null,videoMode:h?"whep":"snapshot",snapshotFeed:h?null:o[p.id],audioInfo:f[`${p.id}-audio`],session:d,showHudMap:!0,hudMapPosition:"bottom-left"},p.id))})}function o2(){return r.jsx("section",{className:"min-h-0",children:r.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:r.jsx(cd,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function c2({className:n=""}){return r.jsx("div",{className:`panel ${n}`,children:r.jsx(ud,{})})}function u2(){const{session:n}=nn(),s=n?.mode==="lockdown",i=!!n?.isLocalNetwork;Sd(),Wg();const o=s2(),f=Wf(),d=n?.roster??[],h=fd(d.map(w=>w.id),{enabled:!s&&!i,version:n?.mode}),p=i?d.map(w=>({type:"rover",id:w.id,key:w.id})):[],x=ji(p,{enabled:!s&&i,version:n?.mode}),g=d.flatMap(w=>w.media?.audioPublishUrl?[{type:"rover",id:`${w.id}-audio`,key:`${w.id}-audio`}]:[]),v=ji(g,{enabled:!s,version:n?.mode});if(s)return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),r.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const b=o?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",S=o?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",k=o?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",C="",E=o?"h-64":"";return r.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[r.jsxs("main",{className:b,children:[r.jsxs("section",{className:k,children:[o?r.jsxs("div",{className:`${C} ${E} flex flex-col gap-0.5`,children:[r.jsx(jo,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(So,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(bo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):r.jsxs("div",{className:C,children:[r.jsx(jo,{layout:"desktop",dismissable:!1,className:"text-sm"}),r.jsx(So,{})]}),r.jsx("div",{className:`${C} ${o?`${E} overflow-y-auto`:""}`,children:r.jsx("div",{className:"panel h-full",children:r.jsx(To,{title:"Rovers"})})}),o?null:r.jsx("div",{className:`${C} flex-1 min-h-0`,children:r.jsx(bo,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),r.jsx("div",{className:`${C} ${o?E:"flex-[1.1] min-h-0"}`,children:r.jsx(Ro,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),r.jsx("div",{className:`${C} ${o?E:""}`,children:r.jsx(c2,{className:`${o?"h-full":"h-40"} overflow-hidden`})})]}),r.jsxs("section",{className:S,children:[r.jsx(r2,{roster:d,frames:f,videoSources:x,snapshotFeeds:h,audioSources:v,session:n,canSpectateVideo:i}),r.jsx(o2,{})]})]}),r.jsx(sd,{}),r.jsx(Jg,{})]})}function f2(){return r.jsx(u2,{})}const d2=2e4,m2=3600*1e3;function h2({roverId:n,session:s}){const i=s?.activeDrivers?.[n]||null,f=(s?.users||[]).find(p=>p.socketId===i)?.nickname||(i?i.slice(0,6):"No driver"),d=s?.mode,h=s?.turnQueues?.[n];return d==="turns"&&h?.current?`${f}`:f}function p2({rover:n,frame:s}){const i=s?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Lg({batteryState:n?.batteryState??null,charge:i,config:o})}function wx({rover:n,frame:s,driverLabel:i,sessionInfo:o,videoMode:f="snapshot",snapshotFeed:d,withDivider:h=!1,showPreview:p=!0,variant:x="stacked"}){const g=p2({rover:n,frame:s}),v=g?.available?g.percentDisplay:null,b=x==="active";return r.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${h?"border-r border-slate-700/60":""}`,children:[r.jsx(Uf,{visual:g,orientation:b?"vertical":"horizontal",variant:"background"}),b?r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ca(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):r.jsx("div",{}),r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ca(n.color,.18),children:n.name||n.id})}),i?r.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:i})}):null,r.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:r.jsx("div",{className:"relative",children:r.jsx(al,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),r.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:r.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:p?r.jsx("div",{className:"mt-auto w-full",children:r.jsx("div",{className:"w-full aspect-[4/3]",children:r.jsx(Ni,{sessionInfo:o,videoMode:f,snapshotFeed:d,audioSessionInfo:null,label:n.name||n.id,roverColor:n.color||null,telemetryFrame:s,batteryConfig:n.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})})}):null})})]})]})}function al({children:n,className:s="",maxSize:i=1e3,minSize:o=14,style:f=void 0}){const d=m.useRef(null),h=m.useRef(null),[p,x]=m.useState(i);return m.useLayoutEffect(()=>{const g=d.current,v=h.current;if(!g||!v)return;let b=null;const S=()=>{const E=g.clientWidth;if(!E){k();return}let w=o,A=i,N=o;for(;w<=A;){const q=Math.floor((w+A)/2);v.style.fontSize=`${q}px`,v.scrollWidth<=E?(N=q,w=q+1):A=q-1}x(N)},k=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(S)};k();const C=new ResizeObserver(k);return C.observe(g),()=>{b&&cancelAnimationFrame(b),C.disconnect()}},[n,i,o]),r.jsx("div",{ref:d,className:"w-full min-w-0",children:r.jsx("div",{ref:h,className:`whitespace-nowrap ${s}`,style:{fontSize:`${p}px`,lineHeight:1.1,...f||{}},children:n})})}function x2(){const{session:n}=nn(),s=Wg();Sd();const i=n?.mode==="lockdown",o=!!n?.isLocalNetwork,f=Wf(),d=n?.roster??[],[h,p]=m.useState(0),x=n?.activeDrivers||{},g=m.useMemo(()=>d.filter(V=>x[V.id]),[d,x]),v=g.length?g:d,b=fd(v.map(V=>V.id),{enabled:!i&&!o,version:n?.mode}),S=m.useMemo(()=>o?v.map(V=>({type:"rover",id:V.id,key:V.id})):[],[o,v]),k=ji(S,{enabled:!i&&o,version:n?.mode}),C=m.useMemo(()=>g.flatMap(V=>{if(!V?.id||!V.media?.audioPublishUrl)return[];const X=String(V.id);return[{type:"rover",id:`${X}-audio`,key:`${X}-audio`}]}),[g]),E=ji(C,{enabled:!i,version:n?.mode}),w=m.useMemo(()=>{if(!g.length)return[];if(!o){const X=g.filter(te=>b[te.id]?.objectUrl);return X.length?X:g}const V=g.filter(X=>{const te=k[X.id];return te?.url&&!te?.error});return V.length?V:g},[g,b,k,o]),A=m.useMemo(()=>w.map(V=>({type:"rover",rover:V})),[w]),N=m.useMemo(()=>A.map(V=>`r:${V.rover.id}`).join("|"),[A]);m.useEffect(()=>{p(0)},[N]),m.useEffect(()=>{if(!A.length)return;const V=setInterval(()=>{p(X=>(X+1)%A.length)},d2);return()=>clearInterval(V)},[A.length,N]);const q=A.length?A[h%A.length]:null,M=q?.type==="rover"?q.rover:null,B=!o&&M&&b[M.id]||null,K=o&&M&&k[M.id]||null,_=M&&E[`${M.id}-audio`]||null,H=M&&f[M.id]||null,z=M?h2({roverId:M.id,session:n}):null;return i?r.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:r.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[r.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),r.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):g.length?r.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[r.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:s?M?r.jsx(v2,{children:o?r.jsx("div",{className:"relative h-full w-full",children:A.map(V=>{const X=V.rover,te=M?.id===X.id;return r.jsx("div",{className:`absolute inset-0 ${te?"opacity-100":"opacity-0 pointer-events-none"}`,children:r.jsx(Ni,{sessionInfo:k[X.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:te?_:null,forceMute:!te,label:X.name||X.id,roverColor:X.color||null,telemetryFrame:f[X.id]||null,batteryConfig:X.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})},X.id)})}):r.jsx(Ni,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:B,audioSessionInfo:_,label:M.name||M.id,roverColor:M.color||null,telemetryFrame:H,batteryConfig:M.battery,layoutFormat:"mobile",hudVariant:"none",fitParent:!0})}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:g.length?"No sources available.":"No active drivers."}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),r.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:M?r.jsx(wx,{rover:M,frame:H,driverLabel:z,sessionInfo:o?K:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[M.id]||null,showPreview:!1,variant:"active"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):r.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:r.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:d.length?d.map((V,X)=>r.jsx(wx,{rover:V,frame:f[V.id]||null,driverLabel:null,sessionInfo:o&&k[V.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[V.id]||null,showPreview:!0,withDivider:!1},V.id)):r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function g2(){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())},m2);return()=>clearTimeout(n)},[]),r.jsxs(r.Fragment,{children:[r.jsx(x2,{}),r.jsx(sd,{scale:3})]})}function v2({children:n}){return r.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:r.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:r.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}function eo(n){if(!n||!n.length)return null;const s=Math.floor(Math.random()*n.length);return n[s]||null}function y2(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const s=eo(n),i=eo(n),o=s?.classList?.[0]||null;if(o&&i?.classList)try{i.classList.add(o)}catch{}const f=eo(n),d=eo(n),h=f?.classList?.[1]||null;if(h&&d?.classList)try{d.classList.add(h)}catch{}}function b2(){const n=ft(s=>!!s.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const s=window.setInterval(()=>{y2()},1);return()=>{window.clearInterval(s)}},[n]),null}Sb.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(YS,{children:r.jsx(KS,{children:r.jsx(ZS,{children:r.jsx(sj,{children:r.jsxs(Kj,{children:[r.jsx(b2,{}),r.jsx(B1,{children:r.jsxs(m1,{children:[r.jsx(to,{path:"/",element:r.jsx(n2,{})}),r.jsx(to,{path:"/spectate",element:r.jsx(f2,{})}),r.jsx(to,{path:"/mini",element:r.jsx(g2,{})})]})})]})})})})})}));
|