mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
132 lines
580 KiB
JavaScript
132 lines
580 KiB
JavaScript
(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))o(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&o(p)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();function Ay(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Gu={exports:{}},Zl={};var g0;function Cy(){if(g0)return Zl;g0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(o,u,f){var p=null;if(f!==void 0&&(p=""+f),u.key!==void 0&&(p=""+u.key),"key"in u){f={};for(var h in u)h!=="key"&&(f[h]=u[h])}else f=u;return u=f.ref,{$$typeof:n,type:o,key:p,ref:u!==void 0?u:null,props:f}}return Zl.Fragment=a,Zl.jsx=r,Zl.jsxs=r,Zl}var v0;function ky(){return v0||(v0=1,Gu.exports=Cy()),Gu.exports}var l=ky(),Yu={exports:{}},Me={};var b0;function Ey(){if(b0)return Me;b0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),p=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function C(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,w={};function j(M,q,Z){this.props=M,this.context=q,this.refs=w,this.updater=Z||E}j.prototype.isReactComponent={},j.prototype.setState=function(M,q){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,q,"setState")},j.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function T(){}T.prototype=j.prototype;function k(M,q,Z){this.props=M,this.context=q,this.refs=w,this.updater=Z||E}var R=k.prototype=new T;R.constructor=k,N(R,j.prototype),R.isPureReactComponent=!0;var D=Array.isArray;function V(){}var O={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function Y(M,q,Z){var le=Z.ref;return{$$typeof:n,type:M,key:q,ref:le!==void 0?le:null,props:Z}}function U(M,q){return Y(M.type,q,M.props)}function X(M){return typeof M=="object"&&M!==null&&M.$$typeof===n}function Q(M){var q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(Z){return q[Z]})}var ce=/\/+/g;function ue(M,q){return typeof M=="object"&&M!==null&&M.key!=null?Q(""+M.key):q.toString(36)}function W(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(V,V):(M.status="pending",M.then(function(q){M.status==="pending"&&(M.status="fulfilled",M.value=q)},function(q){M.status==="pending"&&(M.status="rejected",M.reason=q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function B(M,q,Z,le,he){var we=typeof M;(we==="undefined"||we==="boolean")&&(M=null);var pe=!1;if(M===null)pe=!0;else switch(we){case"bigint":case"string":case"number":pe=!0;break;case"object":switch(M.$$typeof){case n:case a:pe=!0;break;case v:return pe=M._init,B(pe(M._payload),q,Z,le,he)}}if(pe)return he=he(M),pe=le===""?"."+ue(M,0):le,D(he)?(Z="",pe!=null&&(Z=pe.replace(ce,"$&/")+"/"),B(he,q,Z,"",function(Se){return Se})):he!=null&&(X(he)&&(he=U(he,Z+(he.key==null||M&&M.key===he.key?"":(""+he.key).replace(ce,"$&/")+"/")+pe)),q.push(he)),1;pe=0;var xe=le===""?".":le+":";if(D(M))for(var ge=0;ge<M.length;ge++)le=M[ge],we=xe+ue(le,ge),pe+=B(le,q,Z,we,he);else if(ge=C(M),typeof ge=="function")for(M=ge.call(M),ge=0;!(le=M.next()).done;)le=le.value,we=xe+ue(le,ge++),pe+=B(le,q,Z,we,he);else if(we==="object"){if(typeof M.then=="function")return B(W(M),q,Z,le,he);throw q=String(M),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return pe}function I(M,q,Z){if(M==null)return M;var le=[],he=0;return B(M,le,"","",function(we){return q.call(Z,we,he++)}),le}function K(M){if(M._status===-1){var q=M._result;q=q(),q.then(function(Z){(M._status===0||M._status===-1)&&(M._status=1,M._result=Z)},function(Z){(M._status===0||M._status===-1)&&(M._status=2,M._result=Z)}),M._status===-1&&(M._status=0,M._result=q)}if(M._status===1)return M._result.default;throw M._result}var P=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ie={map:I,forEach:function(M,q,Z){I(M,function(){q.apply(this,arguments)},Z)},count:function(M){var q=0;return I(M,function(){q++}),q},toArray:function(M){return I(M,function(q){return q})||[]},only:function(M){if(!X(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Me.Activity=b,Me.Children=ie,Me.Component=j,Me.Fragment=r,Me.Profiler=u,Me.PureComponent=k,Me.StrictMode=o,Me.Suspense=g,Me.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Me.__COMPILER_RUNTIME={__proto__:null,c:function(M){return O.H.useMemoCache(M)}},Me.cache=function(M){return function(){return M.apply(null,arguments)}},Me.cacheSignal=function(){return null},Me.cloneElement=function(M,q,Z){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var le=N({},M.props),he=M.key;if(q!=null)for(we in q.key!==void 0&&(he=""+q.key),q)!L.call(q,we)||we==="key"||we==="__self"||we==="__source"||we==="ref"&&q.ref===void 0||(le[we]=q[we]);var we=arguments.length-2;if(we===1)le.children=Z;else if(1<we){for(var pe=Array(we),xe=0;xe<we;xe++)pe[xe]=arguments[xe+2];le.children=pe}return Y(M.type,he,le)},Me.createContext=function(M){return M={$$typeof:p,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:f,_context:M},M},Me.createElement=function(M,q,Z){var le,he={},we=null;if(q!=null)for(le in q.key!==void 0&&(we=""+q.key),q)L.call(q,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(he[le]=q[le]);var pe=arguments.length-2;if(pe===1)he.children=Z;else if(1<pe){for(var xe=Array(pe),ge=0;ge<pe;ge++)xe[ge]=arguments[ge+2];he.children=xe}if(M&&M.defaultProps)for(le in pe=M.defaultProps,pe)he[le]===void 0&&(he[le]=pe[le]);return Y(M,we,he)},Me.createRef=function(){return{current:null}},Me.forwardRef=function(M){return{$$typeof:h,render:M}},Me.isValidElement=X,Me.lazy=function(M){return{$$typeof:v,_payload:{_status:-1,_result:M},_init:K}},Me.memo=function(M,q){return{$$typeof:x,type:M,compare:q===void 0?null:q}},Me.startTransition=function(M){var q=O.T,Z={};O.T=Z;try{var le=M(),he=O.S;he!==null&&he(Z,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(V,P)}catch(we){P(we)}finally{q!==null&&Z.types!==null&&(q.types=Z.types),O.T=q}},Me.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Me.use=function(M){return O.H.use(M)},Me.useActionState=function(M,q,Z){return O.H.useActionState(M,q,Z)},Me.useCallback=function(M,q){return O.H.useCallback(M,q)},Me.useContext=function(M){return O.H.useContext(M)},Me.useDebugValue=function(){},Me.useDeferredValue=function(M,q){return O.H.useDeferredValue(M,q)},Me.useEffect=function(M,q){return O.H.useEffect(M,q)},Me.useEffectEvent=function(M){return O.H.useEffectEvent(M)},Me.useId=function(){return O.H.useId()},Me.useImperativeHandle=function(M,q,Z){return O.H.useImperativeHandle(M,q,Z)},Me.useInsertionEffect=function(M,q){return O.H.useInsertionEffect(M,q)},Me.useLayoutEffect=function(M,q){return O.H.useLayoutEffect(M,q)},Me.useMemo=function(M,q){return O.H.useMemo(M,q)},Me.useOptimistic=function(M,q){return O.H.useOptimistic(M,q)},Me.useReducer=function(M,q,Z){return O.H.useReducer(M,q,Z)},Me.useRef=function(M){return O.H.useRef(M)},Me.useState=function(M){return O.H.useState(M)},Me.useSyncExternalStore=function(M,q,Z){return O.H.useSyncExternalStore(M,q,Z)},Me.useTransition=function(){return O.H.useTransition()},Me.version="19.2.0",Me}var y0;function Ud(){return y0||(y0=1,Yu.exports=Ey()),Yu.exports}var m=Ud();const Dt=Ay(m);var Fu={exports:{}},Jl={},Iu={exports:{}},Xu={};var S0;function My(){return S0||(S0=1,(function(n){function a(B,I){var K=B.length;B.push(I);e:for(;0<K;){var P=K-1>>>1,ie=B[P];if(0<u(ie,I))B[P]=I,B[K]=ie,K=P;else break e}}function r(B){return B.length===0?null:B[0]}function o(B){if(B.length===0)return null;var I=B[0],K=B.pop();if(K!==I){B[0]=K;e:for(var P=0,ie=B.length,M=ie>>>1;P<M;){var q=2*(P+1)-1,Z=B[q],le=q+1,he=B[le];if(0>u(Z,K))le<ie&&0>u(he,Z)?(B[P]=he,B[le]=K,P=le):(B[P]=Z,B[q]=K,P=q);else if(le<ie&&0>u(he,K))B[P]=he,B[le]=K,P=le;else break e}}return I}function u(B,I){var K=B.sortIndex-I.sortIndex;return K!==0?K:B.id-I.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var p=Date,h=p.now();n.unstable_now=function(){return p.now()-h}}var g=[],x=[],v=1,b=null,S=3,C=!1,E=!1,N=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function R(B){for(var I=r(x);I!==null;){if(I.callback===null)o(x);else if(I.startTime<=B)o(x),I.sortIndex=I.expirationTime,a(g,I);else break;I=r(x)}}function D(B){if(N=!1,R(B),!E)if(r(g)!==null)E=!0,V||(V=!0,Q());else{var I=r(x);I!==null&&W(D,I.startTime-B)}}var V=!1,O=-1,L=5,Y=-1;function U(){return w?!0:!(n.unstable_now()-Y<L)}function X(){if(w=!1,V){var B=n.unstable_now();Y=B;var I=!0;try{e:{E=!1,N&&(N=!1,T(O),O=-1),C=!0;var K=S;try{t:{for(R(B),b=r(g);b!==null&&!(b.expirationTime>B&&U());){var P=b.callback;if(typeof P=="function"){b.callback=null,S=b.priorityLevel;var ie=P(b.expirationTime<=B);if(B=n.unstable_now(),typeof ie=="function"){b.callback=ie,R(B),I=!0;break t}b===r(g)&&o(g),R(B)}else o(g);b=r(g)}if(b!==null)I=!0;else{var M=r(x);M!==null&&W(D,M.startTime-B),I=!1}}break e}finally{b=null,S=K,C=!1}I=void 0}}finally{I?Q():V=!1}}}var Q;if(typeof k=="function")Q=function(){k(X)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,ue=ce.port2;ce.port1.onmessage=X,Q=function(){ue.postMessage(null)}}else Q=function(){j(X,0)};function W(B,I){O=j(function(){B(n.unstable_now())},I)}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(B){B.callback=null},n.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<B?Math.floor(1e3/B):5},n.unstable_getCurrentPriorityLevel=function(){return S},n.unstable_next=function(B){switch(S){case 1:case 2:case 3:var I=3;break;default:I=S}var K=S;S=I;try{return B()}finally{S=K}},n.unstable_requestPaint=function(){w=!0},n.unstable_runWithPriority=function(B,I){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var K=S;S=B;try{return I()}finally{S=K}},n.unstable_scheduleCallback=function(B,I,K){var P=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?P+K:P):K=P,B){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,B={id:v++,callback:I,priorityLevel:B,startTime:K,expirationTime:ie,sortIndex:-1},K>P?(B.sortIndex=K,a(x,B),r(g)===null&&B===r(x)&&(N?(T(O),O=-1):N=!0,W(D,K-P))):(B.sortIndex=ie,a(g,B),E||C||(E=!0,V||(V=!0,Q()))),B},n.unstable_shouldYield=U,n.unstable_wrapCallback=function(B){var I=S;return function(){var K=S;S=I;try{return B.apply(this,arguments)}finally{S=K}}}})(Xu)),Xu}var j0;function Ry(){return j0||(j0=1,Iu.exports=My()),Iu.exports}var Qu={exports:{}},qt={};var N0;function Ty(){if(N0)return qt;N0=1;var n=Ud();function a(g){var x="https://react.dev/errors/"+g;if(1<arguments.length){x+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)x+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+g+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var o={d:{f:r,r:function(){throw Error(a(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function f(g,x,v){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:g,containerInfo:x,implementation:v}}var p=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,x){if(g==="font")return"";if(typeof x=="string")return x==="use-credentials"?x:""}return qt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,qt.createPortal=function(g,x){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)throw Error(a(299));return f(g,x,null,v)},qt.flushSync=function(g){var x=p.T,v=o.p;try{if(p.T=null,o.p=2,g)return g()}finally{p.T=x,o.p=v,o.d.f()}},qt.preconnect=function(g,x){typeof g=="string"&&(x?(x=x.crossOrigin,x=typeof x=="string"?x==="use-credentials"?x:"":void 0):x=null,o.d.C(g,x))},qt.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},qt.preinit=function(g,x){if(typeof g=="string"&&x&&typeof x.as=="string"){var v=x.as,b=h(v,x.crossOrigin),S=typeof x.integrity=="string"?x.integrity:void 0,C=typeof x.fetchPriority=="string"?x.fetchPriority:void 0;v==="style"?o.d.S(g,typeof x.precedence=="string"?x.precedence:void 0,{crossOrigin:b,integrity:S,fetchPriority:C}):v==="script"&&o.d.X(g,{crossOrigin:b,integrity:S,fetchPriority:C,nonce:typeof x.nonce=="string"?x.nonce:void 0})}},qt.preinitModule=function(g,x){if(typeof g=="string")if(typeof x=="object"&&x!==null){if(x.as==null||x.as==="script"){var v=h(x.as,x.crossOrigin);o.d.M(g,{crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0})}}else x==null&&o.d.M(g)},qt.preload=function(g,x){if(typeof g=="string"&&typeof x=="object"&&x!==null&&typeof x.as=="string"){var v=x.as,b=h(v,x.crossOrigin);o.d.L(g,v,{crossOrigin:b,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0,type:typeof x.type=="string"?x.type:void 0,fetchPriority:typeof x.fetchPriority=="string"?x.fetchPriority:void 0,referrerPolicy:typeof x.referrerPolicy=="string"?x.referrerPolicy:void 0,imageSrcSet:typeof x.imageSrcSet=="string"?x.imageSrcSet:void 0,imageSizes:typeof x.imageSizes=="string"?x.imageSizes:void 0,media:typeof x.media=="string"?x.media:void 0})}},qt.preloadModule=function(g,x){if(typeof g=="string")if(x){var v=h(x.as,x.crossOrigin);o.d.m(g,{as:typeof x.as=="string"&&x.as!=="script"?x.as:void 0,crossOrigin:v,integrity:typeof x.integrity=="string"?x.integrity:void 0})}else o.d.m(g)},qt.requestFormReset=function(g){o.d.r(g)},qt.unstable_batchedUpdates=function(g,x){return g(x)},qt.useFormState=function(g,x,v){return p.H.useFormState(g,x,v)},qt.useFormStatus=function(){return p.H.useHostTransitionStatus()},qt.version="19.2.0",qt}var w0;function qy(){if(w0)return Qu.exports;w0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Qu.exports=Ty(),Qu.exports}var A0;function Dy(){if(A0)return Jl;A0=1;var n=Ry(),a=Ud(),r=qy();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function p(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 h(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g(e){if(f(e)!==e)throw Error(o(188))}function x(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var s=e,i=t;;){var c=s.return;if(c===null)break;var d=c.alternate;if(d===null){if(i=c.return,i!==null){s=i;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===s)return g(c),e;if(d===i)return g(c),t;d=d.sibling}throw Error(o(188))}if(s.return!==i.return)s=c,i=d;else{for(var y=!1,A=c.child;A;){if(A===s){y=!0,s=c,i=d;break}if(A===i){y=!0,i=c,s=d;break}A=A.sibling}if(!y){for(A=d.child;A;){if(A===s){y=!0,s=d,i=c;break}if(A===i){y=!0,i=d,s=c;break}A=A.sibling}if(!y)throw Error(o(189))}}if(s.alternate!==i)throw Error(o(190))}if(s.tag!==3)throw Error(o(188));return s.stateNode.current===s?e:t}function v(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=v(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,S=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),k=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function Q(e){return e===null||typeof e!="object"?null:(e=X&&e[X]||e["@@iterator"],typeof e=="function"?e:null)}var ce=Symbol.for("react.client.reference");function ue(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case j:return"Profiler";case w:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case Y:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case k:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case R:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case O:return t=e.displayName||null,t!==null?t:ue(e.type)||"Memo";case L:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}var W=Array.isArray,B=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},P=[],ie=-1;function M(e){return{current:e}}function q(e){0>ie||(e.current=P[ie],P[ie]=null,ie--)}function Z(e,t){ie++,P[ie]=e.current,e.current=t}var le=M(null),he=M(null),we=M(null),pe=M(null);function xe(e,t){switch(Z(we,t),Z(he,e),Z(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hp(t),e=Vp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(le),Z(le,e)}function ge(){q(le),q(he),q(we)}function Se(e){e.memoizedState!==null&&Z(pe,e);var t=le.current,s=Vp(t,e.type);t!==s&&(Z(he,e),Z(le,s))}function be(e){he.current===e&&(q(le),q(he)),pe.current===e&&(q(pe),Il._currentValue=K)}var $e,Ze;function je(e){if($e===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);$e=t&&t[1]||"",Ze=-1<s.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+$e+e+Ze}var lt=!1;function Ie(e,t){if(!e||lt)return"";lt=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var se=function(){throw Error()};if(Object.defineProperty(se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(se,[])}catch(J){var F=J}Reflect.construct(e,[],se)}else{try{se.call()}catch(J){F=J}e.call(se.prototype)}}else{try{throw Error()}catch(J){F=J}(se=e())&&typeof se.catch=="function"&&se.catch(function(){})}}catch(J){if(J&&F&&typeof J.stack=="string")return[J.stack,F.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=i.DetermineComponentFrameRoot(),y=d[0],A=d[1];if(y&&A){var _=y.split(`
|
||
`),G=A.split(`
|
||
`);for(c=i=0;i<_.length&&!_[i].includes("DetermineComponentFrameRoot");)i++;for(;c<G.length&&!G[c].includes("DetermineComponentFrameRoot");)c++;if(i===_.length||c===G.length)for(i=_.length-1,c=G.length-1;1<=i&&0<=c&&_[i]!==G[c];)c--;for(;1<=i&&0<=c;i--,c--)if(_[i]!==G[c]){if(i!==1||c!==1)do if(i--,c--,0>c||_[i]!==G[c]){var ee=`
|
||
`+_[i].replace(" at new "," at ");return e.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",e.displayName)),ee}while(1<=i&&0<=c);break}}}finally{lt=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?je(s):""}function ft(e,t){switch(e.tag){case 26:case 27:case 5:return je(e.type);case 16:return je("Lazy");case 13:return e.child!==t&&t!==null?je("Suspense Fallback"):je("Suspense");case 19:return je("SuspenseList");case 0:case 15:return Ie(e.type,!1);case 11:return Ie(e.type.render,!1);case 1:return Ie(e.type,!0);case 31:return je("Activity");default:return""}}function Ae(e){try{var t="",s=null;do t+=ft(e,s),s=e,e=e.return;while(e);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var ae=Object.prototype.hasOwnProperty,re=n.unstable_scheduleCallback,de=n.unstable_cancelCallback,fe=n.unstable_shouldYield,Re=n.unstable_requestPaint,ne=n.unstable_now,me=n.unstable_getCurrentPriorityLevel,De=n.unstable_ImmediatePriority,en=n.unstable_UserBlockingPriority,tn=n.unstable_NormalPriority,nn=n.unstable_LowPriority,Nt=n.unstable_IdlePriority,Ce=n.log,tt=n.unstable_setDisableYieldValue,Xe=null,Ee=null;function Oe(e){if(typeof Ce=="function"&&tt(e),Ee&&typeof Ee.setStrictMode=="function")try{Ee.setStrictMode(Xe,e)}catch{}}var rt=Math.clz32?Math.clz32:St,Rs=Math.log,sa=Math.LN2;function St(e){return e>>>=0,e===0?32:31-(Rs(e)/sa|0)|0}var Nn=256,wr=262144,Ar=4194304;function Ts(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 Cr(e,t,s){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,y=e.pingedLanes;e=e.warmLanes;var A=i&134217727;return A!==0?(i=A&~d,i!==0?c=Ts(i):(y&=A,y!==0?c=Ts(y):s||(s=A&~e,s!==0&&(c=Ts(s))))):(A=i&~d,A!==0?c=Ts(A):y!==0?c=Ts(y):s||(s=i&~e,s!==0&&(c=Ts(s)))),c===0?0:t!==0&&t!==c&&(t&d)===0&&(d=c&-c,s=t&-t,d>=s||d===32&&(s&4194048)!==0)?t:c}function ll(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function fv(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 Sf(){var e=Ar;return Ar<<=1,(Ar&62914560)===0&&(Ar=4194304),e}function To(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function rl(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function mv(e,t,s,i,c,d){var y=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var A=e.entanglements,_=e.expirationTimes,G=e.hiddenUpdates;for(s=y&~s;0<s;){var ee=31-rt(s),se=1<<ee;A[ee]=0,_[ee]=-1;var F=G[ee];if(F!==null)for(G[ee]=null,ee=0;ee<F.length;ee++){var J=F[ee];J!==null&&(J.lane&=-536870913)}s&=~se}i!==0&&jf(e,i,0),d!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=d&~(y&~t))}function jf(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-rt(t);e.entangledLanes|=t,e.entanglements[i]=e.entanglements[i]|1073741824|s&261930}function Nf(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var i=31-rt(s),c=1<<i;c&t|e[i]&t&&(e[i]|=t),s&=~c}}function wf(e,t){var s=t&-t;return s=(s&42)!==0?1:qo(s),(s&(e.suspendedLanes|t))!==0?0:s}function qo(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 Do(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Af(){var e=I.p;return e!==0?e:(e=window.event,e===void 0?32:u0(e.type))}function Cf(e,t){var s=I.p;try{return I.p=e,t()}finally{I.p=s}}var as=Math.random().toString(36).slice(2),Ct="__reactFiber$"+as,Bt="__reactProps$"+as,aa="__reactContainer$"+as,_o="__reactEvents$"+as,hv="__reactListeners$"+as,pv="__reactHandles$"+as,kf="__reactResources$"+as,il="__reactMarker$"+as;function Bo(e){delete e[Ct],delete e[Bt],delete e[_o],delete e[hv],delete e[pv]}function la(e){var t=e[Ct];if(t)return t;for(var s=e.parentNode;s;){if(t=s[aa]||s[Ct]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=Qp(e);e!==null;){if(s=e[Ct])return s;e=Qp(e)}return t}e=s,s=e.parentNode}return null}function ra(e){if(e=e[Ct]||e[aa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ol(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function ia(e){var t=e[kf];return t||(t=e[kf]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function wt(e){e[il]=!0}var Ef=new Set,Mf={};function qs(e,t){oa(e,t),oa(e+"Capture",t)}function oa(e,t){for(Mf[e]=t,e=0;e<t.length;e++)Ef.add(t[e])}var xv=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]*$"),Rf={},Tf={};function gv(e){return ae.call(Tf,e)?!0:ae.call(Rf,e)?!1:xv.test(e)?Tf[e]=!0:(Rf[e]=!0,!1)}function kr(e,t,s){if(gv(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function Er(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function qn(e,t,s,i){if(i===null)e.removeAttribute(s);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+i)}}function sn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function qf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function vv(e,t,s){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,d=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return c.call(this)},set:function(y){s=""+y,d.call(this,y)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return s},setValue:function(y){s=""+y},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Oo(e){if(!e._valueTracker){var t=qf(e)?"checked":"value";e._valueTracker=vv(e,t,""+e[t])}}function Df(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),i="";return e&&(i=qf(e)?e.checked?"true":"false":e.value),e=i,e!==s?(t.setValue(e),!0):!1}function Mr(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 bv=/[\n"\\]/g;function an(e){return e.replace(bv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Lo(e,t,s,i,c,d,y,A){e.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.type=y:e.removeAttribute("type"),t!=null?y==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+sn(t)):e.value!==""+sn(t)&&(e.value=""+sn(t)):y!=="submit"&&y!=="reset"||e.removeAttribute("value"),t!=null?zo(e,y,sn(t)):s!=null?zo(e,y,sn(s)):i!=null&&e.removeAttribute("value"),c==null&&d!=null&&(e.defaultChecked=!!d),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+sn(A):e.removeAttribute("name")}function _f(e,t,s,i,c,d,y,A){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.type=d),t!=null||s!=null){if(!(d!=="submit"&&d!=="reset"||t!=null)){Oo(e);return}s=s!=null?""+sn(s):"",t=t!=null?""+sn(t):s,A||t===e.value||(e.value=t),e.defaultValue=t}i=i??c,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=A?e.checked:!!i,e.defaultChecked=!!i,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(e.name=y),Oo(e)}function zo(e,t,s){t==="number"&&Mr(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function ca(e,t,s,i){if(e=e.options,t){t={};for(var c=0;c<s.length;c++)t["$"+s[c]]=!0;for(s=0;s<e.length;s++)c=t.hasOwnProperty("$"+e[s].value),e[s].selected!==c&&(e[s].selected=c),c&&i&&(e[s].defaultSelected=!0)}else{for(s=""+sn(s),t=null,c=0;c<e.length;c++){if(e[c].value===s){e[c].selected=!0,i&&(e[c].defaultSelected=!0);return}t!==null||e[c].disabled||(t=e[c])}t!==null&&(t.selected=!0)}}function Bf(e,t,s){if(t!=null&&(t=""+sn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+sn(s):""}function Of(e,t,s,i){if(t==null){if(i!=null){if(s!=null)throw Error(o(92));if(W(i)){if(1<i.length)throw Error(o(93));i=i[0]}s=i}s==null&&(s=""),t=s}s=sn(t),e.defaultValue=s,i=e.textContent,i===s&&i!==""&&i!==null&&(e.value=i),Oo(e)}function ua(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var yv=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 Lf(e,t,s){var i=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?i?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":i?e.setProperty(t,s):typeof s!="number"||s===0||yv.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function zf(e,t,s){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,s!=null){for(var i in s)!s.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var c in t)i=t[c],t.hasOwnProperty(c)&&s[c]!==i&&Lf(e,c,i)}else for(var d in t)t.hasOwnProperty(d)&&Lf(e,d,t[d])}function Uo(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 Sv=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"]]),jv=/^[\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 Rr(e){return jv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Dn(){}var Ho=null;function Vo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var da=null,fa=null;function Uf(e){var t=ra(e);if(t&&(e=t.stateNode)){var s=e[Bt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Lo(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+an(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var i=s[t];if(i!==e&&i.form===e.form){var c=i[Bt]||null;if(!c)throw Error(o(90));Lo(i,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<s.length;t++)i=s[t],i.form===e.form&&Df(i)}break e;case"textarea":Bf(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&ca(e,!!s.multiple,t,!1)}}}var $o=!1;function Hf(e,t,s){if($o)return e(t,s);$o=!0;try{var i=e(t);return i}finally{if($o=!1,(da!==null||fa!==null)&&(gi(),da&&(t=da,e=fa,fa=da=null,Uf(t),e)))for(t=0;t<e.length;t++)Uf(e[t])}}function cl(e,t){var s=e.stateNode;if(s===null)return null;var i=s[Bt]||null;if(i===null)return null;s=i[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(o(231,t,typeof s));return s}var _n=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Go=!1;if(_n)try{var ul={};Object.defineProperty(ul,"passive",{get:function(){Go=!0}}),window.addEventListener("test",ul,ul),window.removeEventListener("test",ul,ul)}catch{Go=!1}var ls=null,Yo=null,Tr=null;function Vf(){if(Tr)return Tr;var e,t=Yo,s=t.length,i,c="value"in ls?ls.value:ls.textContent,d=c.length;for(e=0;e<s&&t[e]===c[e];e++);var y=s-e;for(i=1;i<=y&&t[s-i]===c[d-i];i++);return Tr=c.slice(e,1<i?1-i:void 0)}function qr(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 Dr(){return!0}function $f(){return!1}function Ot(e){function t(s,i,c,d,y){this._reactName=s,this._targetInst=c,this.type=i,this.nativeEvent=d,this.target=y,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(s=e[A],this[A]=s?s(d):d[A]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Dr:$f,this.isPropagationStopped=$f,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Dr)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Dr)},persist:function(){},isPersistent:Dr}),t}var Ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_r=Ot(Ds),dl=b({},Ds,{view:0,detail:0}),Nv=Ot(dl),Fo,Io,fl,Br=b({},dl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qo,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!==fl&&(fl&&e.type==="mousemove"?(Fo=e.screenX-fl.screenX,Io=e.screenY-fl.screenY):Io=Fo=0,fl=e),Fo)},movementY:function(e){return"movementY"in e?e.movementY:Io}}),Gf=Ot(Br),wv=b({},Br,{dataTransfer:0}),Av=Ot(wv),Cv=b({},dl,{relatedTarget:0}),Xo=Ot(Cv),kv=b({},Ds,{animationName:0,elapsedTime:0,pseudoElement:0}),Ev=Ot(kv),Mv=b({},Ds,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Rv=Ot(Mv),Tv=b({},Ds,{data:0}),Yf=Ot(Tv),qv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Dv={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"},_v={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=_v[e])?!!t[e]:!1}function Qo(){return Bv}var Ov=b({},dl,{key:function(e){if(e.key){var t=qv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Dv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qo,charCode:function(e){return e.type==="keypress"?qr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Lv=Ot(Ov),zv=b({},Br,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ff=Ot(zv),Uv=b({},dl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qo}),Hv=Ot(Uv),Vv=b({},Ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),$v=Ot(Vv),Gv=b({},Br,{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}),Yv=Ot(Gv),Fv=b({},Ds,{newState:0,oldState:0}),Iv=Ot(Fv),Xv=[9,13,27,32],Ko=_n&&"CompositionEvent"in window,ml=null;_n&&"documentMode"in document&&(ml=document.documentMode);var Qv=_n&&"TextEvent"in window&&!ml,If=_n&&(!Ko||ml&&8<ml&&11>=ml),Xf=" ",Qf=!1;function Kf(e,t){switch(e){case"keyup":return Xv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ma=!1;function Kv(e,t){switch(e){case"compositionend":return Zf(t);case"keypress":return t.which!==32?null:(Qf=!0,Xf);case"textInput":return e=t.data,e===Xf&&Qf?null:e;default:return null}}function Zv(e,t){if(ma)return e==="compositionend"||!Ko&&Kf(e,t)?(e=Vf(),Tr=Yo=ls=null,ma=!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 If&&t.locale!=="ko"?null:t.data;default:return null}}var Jv={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 Jf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Jv[e.type]:t==="textarea"}function Pf(e,t,s,i){da?fa?fa.push(i):fa=[i]:da=i,t=wi(t,"onChange"),0<t.length&&(s=new _r("onChange","change",null,s,i),e.push({event:s,listeners:t}))}var hl=null,pl=null;function Pv(e){_p(e,0)}function Or(e){var t=ol(e);if(Df(t))return e}function Wf(e,t){if(e==="change")return t}var em=!1;if(_n){var Zo;if(_n){var Jo="oninput"in document;if(!Jo){var tm=document.createElement("div");tm.setAttribute("oninput","return;"),Jo=typeof tm.oninput=="function"}Zo=Jo}else Zo=!1;em=Zo&&(!document.documentMode||9<document.documentMode)}function nm(){hl&&(hl.detachEvent("onpropertychange",sm),pl=hl=null)}function sm(e){if(e.propertyName==="value"&&Or(pl)){var t=[];Pf(t,pl,e,Vo(e)),Hf(Pv,t)}}function Wv(e,t,s){e==="focusin"?(nm(),hl=t,pl=s,hl.attachEvent("onpropertychange",sm)):e==="focusout"&&nm()}function eb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Or(pl)}function tb(e,t){if(e==="click")return Or(t)}function nb(e,t){if(e==="input"||e==="change")return Or(t)}function sb(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Gt=typeof Object.is=="function"?Object.is:sb;function xl(e,t){if(Gt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(i=0;i<s.length;i++){var c=s[i];if(!ae.call(t,c)||!Gt(e[c],t[c]))return!1}return!0}function am(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function lm(e,t){var s=am(e);e=0;for(var i;s;){if(s.nodeType===3){if(i=e+s.textContent.length,e<=t&&i>=t)return{node:s,offset:t-e};e=i}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=am(s)}}function rm(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?rm(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function im(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Mr(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Mr(e.document)}return t}function Po(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 ab=_n&&"documentMode"in document&&11>=document.documentMode,ha=null,Wo=null,gl=null,ec=!1;function om(e,t,s){var i=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;ec||ha==null||ha!==Mr(i)||(i=ha,"selectionStart"in i&&Po(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),gl&&xl(gl,i)||(gl=i,i=wi(Wo,"onSelect"),0<i.length&&(t=new _r("onSelect","select",null,t,s),e.push({event:t,listeners:i}),t.target=ha)))}function _s(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var pa={animationend:_s("Animation","AnimationEnd"),animationiteration:_s("Animation","AnimationIteration"),animationstart:_s("Animation","AnimationStart"),transitionrun:_s("Transition","TransitionRun"),transitionstart:_s("Transition","TransitionStart"),transitioncancel:_s("Transition","TransitionCancel"),transitionend:_s("Transition","TransitionEnd")},tc={},cm={};_n&&(cm=document.createElement("div").style,"AnimationEvent"in window||(delete pa.animationend.animation,delete pa.animationiteration.animation,delete pa.animationstart.animation),"TransitionEvent"in window||delete pa.transitionend.transition);function Bs(e){if(tc[e])return tc[e];if(!pa[e])return e;var t=pa[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in cm)return tc[e]=t[s];return e}var um=Bs("animationend"),dm=Bs("animationiteration"),fm=Bs("animationstart"),lb=Bs("transitionrun"),rb=Bs("transitionstart"),ib=Bs("transitioncancel"),mm=Bs("transitionend"),hm=new Map,nc="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(" ");nc.push("scrollEnd");function gn(e,t){hm.set(e,t),qs(t,[e])}var Lr=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)},ln=[],xa=0,sc=0;function zr(){for(var e=xa,t=sc=xa=0;t<e;){var s=ln[t];ln[t++]=null;var i=ln[t];ln[t++]=null;var c=ln[t];ln[t++]=null;var d=ln[t];if(ln[t++]=null,i!==null&&c!==null){var y=i.pending;y===null?c.next=c:(c.next=y.next,y.next=c),i.pending=c}d!==0&&pm(s,c,d)}}function Ur(e,t,s,i){ln[xa++]=e,ln[xa++]=t,ln[xa++]=s,ln[xa++]=i,sc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function ac(e,t,s,i){return Ur(e,t,s,i),Hr(e)}function Os(e,t){return Ur(e,null,null,t),Hr(e)}function pm(e,t,s){e.lanes|=s;var i=e.alternate;i!==null&&(i.lanes|=s);for(var c=!1,d=e.return;d!==null;)d.childLanes|=s,i=d.alternate,i!==null&&(i.childLanes|=s),d.tag===22&&(e=d.stateNode,e===null||e._visibility&1||(c=!0)),e=d,d=d.return;return e.tag===3?(d=e.stateNode,c&&t!==null&&(c=31-rt(s),e=d.hiddenUpdates,i=e[c],i===null?e[c]=[t]:i.push(t),t.lane=s|536870912),d):null}function Hr(e){if(50<Ul)throw Ul=0,mu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ga={};function ob(e,t,s,i){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(e,t,s,i){return new ob(e,t,s,i)}function lc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Bn(e,t){var s=e.alternate;return s===null?(s=Yt(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function xm(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Vr(e,t,s,i,c,d){var y=0;if(i=e,typeof e=="function")lc(e)&&(y=1);else if(typeof e=="string")y=my(e,s,le.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Y:return e=Yt(31,s,t,c),e.elementType=Y,e.lanes=d,e;case N:return Ls(s.children,c,d,t);case w:y=8,c|=24;break;case j:return e=Yt(12,s,t,c|2),e.elementType=j,e.lanes=d,e;case D:return e=Yt(13,s,t,c),e.elementType=D,e.lanes=d,e;case V:return e=Yt(19,s,t,c),e.elementType=V,e.lanes=d,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case k:y=10;break e;case T:y=9;break e;case R:y=11;break e;case O:y=14;break e;case L:y=16,i=null;break e}y=29,s=Error(o(130,e===null?"null":typeof e,"")),i=null}return t=Yt(y,s,t,c),t.elementType=e,t.type=i,t.lanes=d,t}function Ls(e,t,s,i){return e=Yt(7,e,i,t),e.lanes=s,e}function rc(e,t,s){return e=Yt(6,e,null,t),e.lanes=s,e}function gm(e){var t=Yt(18,null,null,0);return t.stateNode=e,t}function ic(e,t,s){return t=Yt(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vm=new WeakMap;function rn(e,t){if(typeof e=="object"&&e!==null){var s=vm.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Ae(t)},vm.set(e,t),t)}return{value:e,source:t,stack:Ae(t)}}var va=[],ba=0,$r=null,vl=0,on=[],cn=0,rs=null,wn=1,An="";function On(e,t){va[ba++]=vl,va[ba++]=$r,$r=e,vl=t}function bm(e,t,s){on[cn++]=wn,on[cn++]=An,on[cn++]=rs,rs=e;var i=wn;e=An;var c=32-rt(i)-1;i&=~(1<<c),s+=1;var d=32-rt(t)+c;if(30<d){var y=c-c%5;d=(i&(1<<y)-1).toString(32),i>>=y,c-=y,wn=1<<32-rt(t)+c|s<<c|i,An=d+e}else wn=1<<d|s<<c|i,An=e}function oc(e){e.return!==null&&(On(e,1),bm(e,1,0))}function cc(e){for(;e===$r;)$r=va[--ba],va[ba]=null,vl=va[--ba],va[ba]=null;for(;e===rs;)rs=on[--cn],on[cn]=null,An=on[--cn],on[cn]=null,wn=on[--cn],on[cn]=null}function ym(e,t){on[cn++]=wn,on[cn++]=An,on[cn++]=rs,wn=t.id,An=t.overflow,rs=e}var kt=null,nt=null,Ue=!1,is=null,un=!1,uc=Error(o(519));function os(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bl(rn(t,e)),uc}function Sm(e){var t=e.stateNode,s=e.type,i=e.memoizedProps;switch(t[Ct]=e,t[Bt]=i,s){case"dialog":Be("cancel",t),Be("close",t);break;case"iframe":case"object":case"embed":Be("load",t);break;case"video":case"audio":for(s=0;s<Vl.length;s++)Be(Vl[s],t);break;case"source":Be("error",t);break;case"img":case"image":case"link":Be("error",t),Be("load",t);break;case"details":Be("toggle",t);break;case"input":Be("invalid",t),_f(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Be("invalid",t);break;case"textarea":Be("invalid",t),Of(t,i.value,i.defaultValue,i.children)}s=i.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||i.suppressHydrationWarning===!0||zp(t.textContent,s)?(i.popover!=null&&(Be("beforetoggle",t),Be("toggle",t)),i.onScroll!=null&&Be("scroll",t),i.onScrollEnd!=null&&Be("scrollend",t),i.onClick!=null&&(t.onclick=Dn),t=!0):t=!1,t||os(e,!0)}function jm(e){for(kt=e.return;kt;)switch(kt.tag){case 5:case 31:case 13:un=!1;return;case 27:case 3:un=!0;return;default:kt=kt.return}}function ya(e){if(e!==kt)return!1;if(!Ue)return jm(e),Ue=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||Eu(e.type,e.memoizedProps)),s=!s),s&&nt&&os(e),jm(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Xp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));nt=Xp(e)}else t===27?(t=nt,js(e.type)?(e=Du,Du=null,nt=e):nt=t):nt=kt?fn(e.stateNode.nextSibling):null;return!0}function zs(){nt=kt=null,Ue=!1}function dc(){var e=is;return e!==null&&(Ht===null?Ht=e:Ht.push.apply(Ht,e),is=null),e}function bl(e){is===null?is=[e]:is.push(e)}var fc=M(null),Us=null,Ln=null;function cs(e,t,s){Z(fc,t._currentValue),t._currentValue=s}function zn(e){e._currentValue=fc.current,q(fc)}function mc(e,t,s){for(;e!==null;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===s)break;e=e.return}}function hc(e,t,s,i){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var d=c.dependencies;if(d!==null){var y=c.child;d=d.firstContext;e:for(;d!==null;){var A=d;d=c;for(var _=0;_<t.length;_++)if(A.context===t[_]){d.lanes|=s,A=d.alternate,A!==null&&(A.lanes|=s),mc(d.return,s,e),i||(y=null);break e}d=A.next}}else if(c.tag===18){if(y=c.return,y===null)throw Error(o(341));y.lanes|=s,d=y.alternate,d!==null&&(d.lanes|=s),mc(y,s,e),y=null}else y=c.child;if(y!==null)y.return=c;else for(y=c;y!==null;){if(y===e){y=null;break}if(c=y.sibling,c!==null){c.return=y.return,y=c;break}y=y.return}c=y}}function Sa(e,t,s,i){e=null;for(var c=t,d=!1;c!==null;){if(!d){if((c.flags&524288)!==0)d=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var y=c.alternate;if(y===null)throw Error(o(387));if(y=y.memoizedProps,y!==null){var A=c.type;Gt(c.pendingProps.value,y.value)||(e!==null?e.push(A):e=[A])}}else if(c===pe.current){if(y=c.alternate,y===null)throw Error(o(387));y.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Il):e=[Il])}c=c.return}e!==null&&hc(t,e,s,i),t.flags|=262144}function Gr(e){for(e=e.firstContext;e!==null;){if(!Gt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hs(e){Us=e,Ln=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Et(e){return Nm(Us,e)}function Yr(e,t){return Us===null&&Hs(e),Nm(e,t)}function Nm(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},Ln===null){if(e===null)throw Error(o(308));Ln=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ln=Ln.next=t;return s}var cb=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,i){e.push(i)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},ub=n.unstable_scheduleCallback,db=n.unstable_NormalPriority,pt={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pc(){return{controller:new cb,data:new Map,refCount:0}}function yl(e){e.refCount--,e.refCount===0&&ub(db,function(){e.controller.abort()})}var Sl=null,xc=0,ja=0,Na=null;function fb(e,t){if(Sl===null){var s=Sl=[];xc=0,ja=bu(),Na={status:"pending",value:void 0,then:function(i){s.push(i)}}}return xc++,t.then(wm,wm),t}function wm(){if(--xc===0&&Sl!==null){Na!==null&&(Na.status="fulfilled");var e=Sl;Sl=null,ja=0,Na=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function mb(e,t){var s=[],i={status:"pending",value:null,reason:null,then:function(c){s.push(c)}};return e.then(function(){i.status="fulfilled",i.value=t;for(var c=0;c<s.length;c++)(0,s[c])(t)},function(c){for(i.status="rejected",i.reason=c,c=0;c<s.length;c++)(0,s[c])(void 0)}),i}var Am=B.S;B.S=function(e,t){op=ne(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&fb(e,t),Am!==null&&Am(e,t)};var Vs=M(null);function gc(){var e=Vs.current;return e!==null?e:et.pooledCache}function Fr(e,t){t===null?Z(Vs,Vs.current):Z(Vs,t.pool)}function Cm(){var e=gc();return e===null?null:{parent:pt._currentValue,pool:e}}var wa=Error(o(460)),vc=Error(o(474)),Ir=Error(o(542)),Xr={then:function(){}};function km(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Em(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(Dn,Dn),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Rm(e),e;default:if(typeof t.status=="string")t.then(Dn,Dn);else{if(e=et,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(i){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=i}},function(i){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Rm(e),e}throw Gs=t,wa}}function $s(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(Gs=s,wa):s}}var Gs=null;function Mm(){if(Gs===null)throw Error(o(459));var e=Gs;return Gs=null,e}function Rm(e){if(e===wa||e===Ir)throw Error(o(483))}var Aa=null,jl=0;function Qr(e){var t=jl;return jl+=1,Aa===null&&(Aa=[]),Em(Aa,e,t)}function Nl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Kr(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 Tm(e){function t(H,z){if(e){var $=H.deletions;$===null?(H.deletions=[z],H.flags|=16):$.push(z)}}function s(H,z){if(!e)return null;for(;z!==null;)t(H,z),z=z.sibling;return null}function i(H){for(var z=new Map;H!==null;)H.key!==null?z.set(H.key,H):z.set(H.index,H),H=H.sibling;return z}function c(H,z){return H=Bn(H,z),H.index=0,H.sibling=null,H}function d(H,z,$){return H.index=$,e?($=H.alternate,$!==null?($=$.index,$<z?(H.flags|=67108866,z):$):(H.flags|=67108866,z)):(H.flags|=1048576,z)}function y(H){return e&&H.alternate===null&&(H.flags|=67108866),H}function A(H,z,$,te){return z===null||z.tag!==6?(z=rc($,H.mode,te),z.return=H,z):(z=c(z,$),z.return=H,z)}function _(H,z,$,te){var Ne=$.type;return Ne===N?ee(H,z,$.props.children,te,$.key):z!==null&&(z.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===L&&$s(Ne)===z.type)?(z=c(z,$.props),Nl(z,$),z.return=H,z):(z=Vr($.type,$.key,$.props,null,H.mode,te),Nl(z,$),z.return=H,z)}function G(H,z,$,te){return z===null||z.tag!==4||z.stateNode.containerInfo!==$.containerInfo||z.stateNode.implementation!==$.implementation?(z=ic($,H.mode,te),z.return=H,z):(z=c(z,$.children||[]),z.return=H,z)}function ee(H,z,$,te,Ne){return z===null||z.tag!==7?(z=Ls($,H.mode,te,Ne),z.return=H,z):(z=c(z,$),z.return=H,z)}function se(H,z,$){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=rc(""+z,H.mode,$),z.return=H,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case C:return $=Vr(z.type,z.key,z.props,null,H.mode,$),Nl($,z),$.return=H,$;case E:return z=ic(z,H.mode,$),z.return=H,z;case L:return z=$s(z),se(H,z,$)}if(W(z)||Q(z))return z=Ls(z,H.mode,$,null),z.return=H,z;if(typeof z.then=="function")return se(H,Qr(z),$);if(z.$$typeof===k)return se(H,Yr(H,z),$);Kr(H,z)}return null}function F(H,z,$,te){var Ne=z!==null?z.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return Ne!==null?null:A(H,z,""+$,te);if(typeof $=="object"&&$!==null){switch($.$$typeof){case C:return $.key===Ne?_(H,z,$,te):null;case E:return $.key===Ne?G(H,z,$,te):null;case L:return $=$s($),F(H,z,$,te)}if(W($)||Q($))return Ne!==null?null:ee(H,z,$,te,null);if(typeof $.then=="function")return F(H,z,Qr($),te);if($.$$typeof===k)return F(H,z,Yr(H,$),te);Kr(H,$)}return null}function J(H,z,$,te,Ne){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return H=H.get($)||null,A(z,H,""+te,Ne);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case C:return H=H.get(te.key===null?$:te.key)||null,_(z,H,te,Ne);case E:return H=H.get(te.key===null?$:te.key)||null,G(z,H,te,Ne);case L:return te=$s(te),J(H,z,$,te,Ne)}if(W(te)||Q(te))return H=H.get($)||null,ee(z,H,te,Ne,null);if(typeof te.then=="function")return J(H,z,$,Qr(te),Ne);if(te.$$typeof===k)return J(H,z,$,Yr(z,te),Ne);Kr(z,te)}return null}function ve(H,z,$,te){for(var Ne=null,Ge=null,ye=z,qe=z=0,ze=null;ye!==null&&qe<$.length;qe++){ye.index>qe?(ze=ye,ye=null):ze=ye.sibling;var Ye=F(H,ye,$[qe],te);if(Ye===null){ye===null&&(ye=ze);break}e&&ye&&Ye.alternate===null&&t(H,ye),z=d(Ye,z,qe),Ge===null?Ne=Ye:Ge.sibling=Ye,Ge=Ye,ye=ze}if(qe===$.length)return s(H,ye),Ue&&On(H,qe),Ne;if(ye===null){for(;qe<$.length;qe++)ye=se(H,$[qe],te),ye!==null&&(z=d(ye,z,qe),Ge===null?Ne=ye:Ge.sibling=ye,Ge=ye);return Ue&&On(H,qe),Ne}for(ye=i(ye);qe<$.length;qe++)ze=J(ye,H,qe,$[qe],te),ze!==null&&(e&&ze.alternate!==null&&ye.delete(ze.key===null?qe:ze.key),z=d(ze,z,qe),Ge===null?Ne=ze:Ge.sibling=ze,Ge=ze);return e&&ye.forEach(function(ks){return t(H,ks)}),Ue&&On(H,qe),Ne}function ke(H,z,$,te){if($==null)throw Error(o(151));for(var Ne=null,Ge=null,ye=z,qe=z=0,ze=null,Ye=$.next();ye!==null&&!Ye.done;qe++,Ye=$.next()){ye.index>qe?(ze=ye,ye=null):ze=ye.sibling;var ks=F(H,ye,Ye.value,te);if(ks===null){ye===null&&(ye=ze);break}e&&ye&&ks.alternate===null&&t(H,ye),z=d(ks,z,qe),Ge===null?Ne=ks:Ge.sibling=ks,Ge=ks,ye=ze}if(Ye.done)return s(H,ye),Ue&&On(H,qe),Ne;if(ye===null){for(;!Ye.done;qe++,Ye=$.next())Ye=se(H,Ye.value,te),Ye!==null&&(z=d(Ye,z,qe),Ge===null?Ne=Ye:Ge.sibling=Ye,Ge=Ye);return Ue&&On(H,qe),Ne}for(ye=i(ye);!Ye.done;qe++,Ye=$.next())Ye=J(ye,H,qe,Ye.value,te),Ye!==null&&(e&&Ye.alternate!==null&&ye.delete(Ye.key===null?qe:Ye.key),z=d(Ye,z,qe),Ge===null?Ne=Ye:Ge.sibling=Ye,Ge=Ye);return e&&ye.forEach(function(wy){return t(H,wy)}),Ue&&On(H,qe),Ne}function We(H,z,$,te){if(typeof $=="object"&&$!==null&&$.type===N&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case C:e:{for(var Ne=$.key;z!==null;){if(z.key===Ne){if(Ne=$.type,Ne===N){if(z.tag===7){s(H,z.sibling),te=c(z,$.props.children),te.return=H,H=te;break e}}else if(z.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===L&&$s(Ne)===z.type){s(H,z.sibling),te=c(z,$.props),Nl(te,$),te.return=H,H=te;break e}s(H,z);break}else t(H,z);z=z.sibling}$.type===N?(te=Ls($.props.children,H.mode,te,$.key),te.return=H,H=te):(te=Vr($.type,$.key,$.props,null,H.mode,te),Nl(te,$),te.return=H,H=te)}return y(H);case E:e:{for(Ne=$.key;z!==null;){if(z.key===Ne)if(z.tag===4&&z.stateNode.containerInfo===$.containerInfo&&z.stateNode.implementation===$.implementation){s(H,z.sibling),te=c(z,$.children||[]),te.return=H,H=te;break e}else{s(H,z);break}else t(H,z);z=z.sibling}te=ic($,H.mode,te),te.return=H,H=te}return y(H);case L:return $=$s($),We(H,z,$,te)}if(W($))return ve(H,z,$,te);if(Q($)){if(Ne=Q($),typeof Ne!="function")throw Error(o(150));return $=Ne.call($),ke(H,z,$,te)}if(typeof $.then=="function")return We(H,z,Qr($),te);if($.$$typeof===k)return We(H,z,Yr(H,$),te);Kr(H,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,z!==null&&z.tag===6?(s(H,z.sibling),te=c(z,$),te.return=H,H=te):(s(H,z),te=rc($,H.mode,te),te.return=H,H=te),y(H)):s(H,z)}return function(H,z,$,te){try{jl=0;var Ne=We(H,z,$,te);return Aa=null,Ne}catch(ye){if(ye===wa||ye===Ir)throw ye;var Ge=Yt(29,ye,null,H.mode);return Ge.lanes=te,Ge.return=H,Ge}finally{}}}var Ys=Tm(!0),qm=Tm(!1),us=!1;function bc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(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 ds(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function fs(e,t,s){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(Fe&2)!==0){var c=i.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),i.pending=t,t=Hr(e),pm(e,null,s),t}return Ur(e,i,t,s),Hr(e)}function wl(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,Nf(e,s)}}function Sc(e,t){var s=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,s===i)){var c=null,d=null;if(s=s.firstBaseUpdate,s!==null){do{var y={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};d===null?c=d=y:d=d.next=y,s=s.next}while(s!==null);d===null?c=d=t:d=d.next=t}else c=d=t;s={baseState:i.baseState,firstBaseUpdate:c,lastBaseUpdate:d,shared:i.shared,callbacks:i.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var jc=!1;function Al(){if(jc){var e=Na;if(e!==null)throw e}}function Cl(e,t,s,i){jc=!1;var c=e.updateQueue;us=!1;var d=c.firstBaseUpdate,y=c.lastBaseUpdate,A=c.shared.pending;if(A!==null){c.shared.pending=null;var _=A,G=_.next;_.next=null,y===null?d=G:y.next=G,y=_;var ee=e.alternate;ee!==null&&(ee=ee.updateQueue,A=ee.lastBaseUpdate,A!==y&&(A===null?ee.firstBaseUpdate=G:A.next=G,ee.lastBaseUpdate=_))}if(d!==null){var se=c.baseState;y=0,ee=G=_=null,A=d;do{var F=A.lane&-536870913,J=F!==A.lane;if(J?(Le&F)===F:(i&F)===F){F!==0&&F===ja&&(jc=!0),ee!==null&&(ee=ee.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var ve=e,ke=A;F=t;var We=s;switch(ke.tag){case 1:if(ve=ke.payload,typeof ve=="function"){se=ve.call(We,se,F);break e}se=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=ke.payload,F=typeof ve=="function"?ve.call(We,se,F):ve,F==null)break e;se=b({},se,F);break e;case 2:us=!0}}F=A.callback,F!==null&&(e.flags|=64,J&&(e.flags|=8192),J=c.callbacks,J===null?c.callbacks=[F]:J.push(F))}else J={lane:F,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ee===null?(G=ee=J,_=se):ee=ee.next=J,y|=F;if(A=A.next,A===null){if(A=c.shared.pending,A===null)break;J=A,A=J.next,J.next=null,c.lastBaseUpdate=J,c.shared.pending=null}}while(!0);ee===null&&(_=se),c.baseState=_,c.firstBaseUpdate=G,c.lastBaseUpdate=ee,d===null&&(c.shared.lanes=0),gs|=y,e.lanes=y,e.memoizedState=se}}function Dm(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function _m(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)Dm(s[e],t)}var Ca=M(null),Zr=M(0);function Bm(e,t){e=Xn,Z(Zr,e),Z(Ca,t),Xn=e|t.baseLanes}function Nc(){Z(Zr,Xn),Z(Ca,Ca.current)}function wc(){Xn=Zr.current,q(Ca),q(Zr)}var Ft=M(null),dn=null;function ms(e){var t=e.alternate;Z(mt,mt.current&1),Z(Ft,e),dn===null&&(t===null||Ca.current!==null||t.memoizedState!==null)&&(dn=e)}function Ac(e){Z(mt,mt.current),Z(Ft,e),dn===null&&(dn=e)}function Om(e){e.tag===22?(Z(mt,mt.current),Z(Ft,e),dn===null&&(dn=e)):hs()}function hs(){Z(mt,mt.current),Z(Ft,Ft.current)}function It(e){q(Ft),dn===e&&(dn=null),q(mt)}var mt=M(0);function Jr(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Tu(s)||qu(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Un=0,Te=null,Je=null,xt=null,Pr=!1,ka=!1,Fs=!1,Wr=0,kl=0,Ea=null,hb=0;function ct(){throw Error(o(321))}function Cc(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Gt(e[s],t[s]))return!1;return!0}function kc(e,t,s,i,c,d){return Un=d,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,B.H=e===null||e.memoizedState===null?bh:$c,Fs=!1,d=s(i,c),Fs=!1,ka&&(d=zm(t,s,i,c)),Lm(e),d}function Lm(e){B.H=Rl;var t=Je!==null&&Je.next!==null;if(Un=0,xt=Je=Te=null,Pr=!1,kl=0,Ea=null,t)throw Error(o(300));e===null||gt||(e=e.dependencies,e!==null&&Gr(e)&&(gt=!0))}function zm(e,t,s,i){Te=e;var c=0;do{if(ka&&(Ea=null),kl=0,ka=!1,25<=c)throw Error(o(301));if(c+=1,xt=Je=null,e.updateQueue!=null){var d=e.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}B.H=yh,d=t(s,i)}while(ka);return d}function pb(){var e=B.H,t=e.useState()[0];return t=typeof t.then=="function"?El(t):t,e=e.useState()[0],(Je!==null?Je.memoizedState:null)!==e&&(Te.flags|=1024),t}function Ec(){var e=Wr!==0;return Wr=0,e}function Mc(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function Rc(e){if(Pr){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Pr=!1}Un=0,xt=Je=Te=null,ka=!1,kl=Wr=0,Ea=null}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xt===null?Te.memoizedState=xt=e:xt=xt.next=e,xt}function ht(){if(Je===null){var e=Te.alternate;e=e!==null?e.memoizedState:null}else e=Je.next;var t=xt===null?Te.memoizedState:xt.next;if(t!==null)xt=t,Je=e;else{if(e===null)throw Te.alternate===null?Error(o(467)):Error(o(310));Je=e,e={memoizedState:Je.memoizedState,baseState:Je.baseState,baseQueue:Je.baseQueue,queue:Je.queue,next:null},xt===null?Te.memoizedState=xt=e:xt=xt.next=e}return xt}function ei(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function El(e){var t=kl;return kl+=1,Ea===null&&(Ea=[]),e=Em(Ea,e,t),t=Te,(xt===null?t.memoizedState:xt.next)===null&&(t=t.alternate,B.H=t===null||t.memoizedState===null?bh:$c),e}function ti(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return El(e);if(e.$$typeof===k)return Et(e)}throw Error(o(438,String(e)))}function Tc(e){var t=null,s=Te.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var i=Te.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=ei(),Te.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),i=0;i<e;i++)s[i]=U;return t.index++,s}function Hn(e,t){return typeof t=="function"?t(e):t}function ni(e){var t=ht();return qc(t,Je,e)}function qc(e,t,s){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=s;var c=e.baseQueue,d=i.pending;if(d!==null){if(c!==null){var y=c.next;c.next=d.next,d.next=y}t.baseQueue=c=d,i.pending=null}if(d=e.baseState,c===null)e.memoizedState=d;else{t=c.next;var A=y=null,_=null,G=t,ee=!1;do{var se=G.lane&-536870913;if(se!==G.lane?(Le&se)===se:(Un&se)===se){var F=G.revertLane;if(F===0)_!==null&&(_=_.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),se===ja&&(ee=!0);else if((Un&F)===F){G=G.next,F===ja&&(ee=!0);continue}else se={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},_===null?(A=_=se,y=d):_=_.next=se,Te.lanes|=F,gs|=F;se=G.action,Fs&&s(d,se),d=G.hasEagerState?G.eagerState:s(d,se)}else F={lane:se,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},_===null?(A=_=F,y=d):_=_.next=F,Te.lanes|=se,gs|=se;G=G.next}while(G!==null&&G!==t);if(_===null?y=d:_.next=A,!Gt(d,e.memoizedState)&&(gt=!0,ee&&(s=Na,s!==null)))throw s;e.memoizedState=d,e.baseState=y,e.baseQueue=_,i.lastRenderedState=d}return c===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Dc(e){var t=ht(),s=t.queue;if(s===null)throw Error(o(311));s.lastRenderedReducer=e;var i=s.dispatch,c=s.pending,d=t.memoizedState;if(c!==null){s.pending=null;var y=c=c.next;do d=e(d,y.action),y=y.next;while(y!==c);Gt(d,t.memoizedState)||(gt=!0),t.memoizedState=d,t.baseQueue===null&&(t.baseState=d),s.lastRenderedState=d}return[d,i]}function Um(e,t,s){var i=Te,c=ht(),d=Ue;if(d){if(s===void 0)throw Error(o(407));s=s()}else s=t();var y=!Gt((Je||c).memoizedState,s);if(y&&(c.memoizedState=s,gt=!0),c=c.queue,Oc($m.bind(null,i,c,e),[e]),c.getSnapshot!==t||y||xt!==null&&xt.memoizedState.tag&1){if(i.flags|=2048,Ma(9,{destroy:void 0},Vm.bind(null,i,c,s,t),null),et===null)throw Error(o(349));d||(Un&127)!==0||Hm(i,t,s)}return s}function Hm(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=Te.updateQueue,t===null?(t=ei(),Te.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Vm(e,t,s,i){t.value=s,t.getSnapshot=i,Gm(t)&&Ym(e)}function $m(e,t,s){return s(function(){Gm(t)&&Ym(e)})}function Gm(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Gt(e,s)}catch{return!0}}function Ym(e){var t=Os(e,2);t!==null&&Vt(t,e,2)}function _c(e){var t=_t();if(typeof e=="function"){var s=e;if(e=s(),Fs){Oe(!0);try{s()}finally{Oe(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:e},t}function Fm(e,t,s,i){return e.baseState=s,qc(e,Je,typeof i=="function"?i:Hn)}function xb(e,t,s,i,c){if(li(e))throw Error(o(485));if(e=t.action,e!==null){var d={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){d.listeners.push(y)}};B.T!==null?s(!0):d.isTransition=!1,i(d),s=t.pending,s===null?(d.next=t.pending=d,Im(t,d)):(d.next=s.next,t.pending=s.next=d)}}function Im(e,t){var s=t.action,i=t.payload,c=e.state;if(t.isTransition){var d=B.T,y={};B.T=y;try{var A=s(c,i),_=B.S;_!==null&&_(y,A),Xm(e,t,A)}catch(G){Bc(e,t,G)}finally{d!==null&&y.types!==null&&(d.types=y.types),B.T=d}}else try{d=s(c,i),Xm(e,t,d)}catch(G){Bc(e,t,G)}}function Xm(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(i){Qm(e,t,i)},function(i){return Bc(e,t,i)}):Qm(e,t,s)}function Qm(e,t,s){t.status="fulfilled",t.value=s,Km(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,Im(e,s)))}function Bc(e,t,s){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=s,Km(t),t=t.next;while(t!==i)}e.action=null}function Km(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zm(e,t){return t}function Jm(e,t){if(Ue){var s=et.formState;if(s!==null){e:{var i=Te;if(Ue){if(nt){t:{for(var c=nt,d=un;c.nodeType!==8;){if(!d){c=null;break t}if(c=fn(c.nextSibling),c===null){c=null;break t}}d=c.data,c=d==="F!"||d==="F"?c:null}if(c){nt=fn(c.nextSibling),i=c.data==="F!";break e}}os(i)}i=!1}i&&(t=s[0])}}return s=_t(),s.memoizedState=s.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zm,lastRenderedState:t},s.queue=i,s=xh.bind(null,Te,i),i.dispatch=s,i=_c(!1),d=Vc.bind(null,Te,!1,i.queue),i=_t(),c={state:t,dispatch:null,action:e,pending:null},i.queue=c,s=xb.bind(null,Te,c,d,s),c.dispatch=s,i.memoizedState=e,[t,s,!1]}function Pm(e){var t=ht();return Wm(t,Je,e)}function Wm(e,t,s){if(t=qc(e,t,Zm)[0],e=ni(Hn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=El(t)}catch(y){throw y===wa?Ir:y}else i=t;t=ht();var c=t.queue,d=c.dispatch;return s!==t.memoizedState&&(Te.flags|=2048,Ma(9,{destroy:void 0},gb.bind(null,c,s),null)),[i,d,e]}function gb(e,t){e.action=t}function eh(e){var t=ht(),s=Je;if(s!==null)return Wm(t,s,e);ht(),t=t.memoizedState,s=ht();var i=s.queue.dispatch;return s.memoizedState=e,[t,i,!1]}function Ma(e,t,s,i){return e={tag:e,create:s,deps:i,inst:t,next:null},t=Te.updateQueue,t===null&&(t=ei(),Te.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(i=s.next,s.next=e,e.next=i,t.lastEffect=e),e}function th(){return ht().memoizedState}function si(e,t,s,i){var c=_t();Te.flags|=e,c.memoizedState=Ma(1|t,{destroy:void 0},s,i===void 0?null:i)}function ai(e,t,s,i){var c=ht();i=i===void 0?null:i;var d=c.memoizedState.inst;Je!==null&&i!==null&&Cc(i,Je.memoizedState.deps)?c.memoizedState=Ma(t,d,s,i):(Te.flags|=e,c.memoizedState=Ma(1|t,d,s,i))}function nh(e,t){si(8390656,8,e,t)}function Oc(e,t){ai(2048,8,e,t)}function vb(e){Te.flags|=4;var t=Te.updateQueue;if(t===null)t=ei(),Te.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function sh(e){var t=ht().memoizedState;return vb({ref:t,nextImpl:e}),function(){if((Fe&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function ah(e,t){return ai(4,2,e,t)}function lh(e,t){return ai(4,4,e,t)}function rh(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ih(e,t,s){s=s!=null?s.concat([e]):null,ai(4,4,rh.bind(null,t,e),s)}function Lc(){}function oh(e,t){var s=ht();t=t===void 0?null:t;var i=s.memoizedState;return t!==null&&Cc(t,i[1])?i[0]:(s.memoizedState=[e,t],e)}function ch(e,t){var s=ht();t=t===void 0?null:t;var i=s.memoizedState;if(t!==null&&Cc(t,i[1]))return i[0];if(i=e(),Fs){Oe(!0);try{e()}finally{Oe(!1)}}return s.memoizedState=[i,t],i}function zc(e,t,s){return s===void 0||(Un&1073741824)!==0&&(Le&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=up(),Te.lanes|=e,gs|=e,s)}function uh(e,t,s,i){return Gt(s,t)?s:Ca.current!==null?(e=zc(e,s,i),Gt(e,t)||(gt=!0),e):(Un&42)===0||(Un&1073741824)!==0&&(Le&261930)===0?(gt=!0,e.memoizedState=s):(e=up(),Te.lanes|=e,gs|=e,t)}function dh(e,t,s,i,c){var d=I.p;I.p=d!==0&&8>d?d:8;var y=B.T,A={};B.T=A,Vc(e,!1,t,s);try{var _=c(),G=B.S;if(G!==null&&G(A,_),_!==null&&typeof _=="object"&&typeof _.then=="function"){var ee=mb(_,i);Ml(e,t,ee,Kt(e))}else Ml(e,t,i,Kt(e))}catch(se){Ml(e,t,{then:function(){},status:"rejected",reason:se},Kt())}finally{I.p=d,y!==null&&A.types!==null&&(y.types=A.types),B.T=y}}function bb(){}function Uc(e,t,s,i){if(e.tag!==5)throw Error(o(476));var c=fh(e).queue;dh(e,c,t,K,s===null?bb:function(){return mh(e),s(i)})}function fh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:K},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hn,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function mh(e){var t=fh(e);t.next===null&&(t=e.alternate.memoizedState),Ml(e,t.next.queue,{},Kt())}function Hc(){return Et(Il)}function hh(){return ht().memoizedState}function ph(){return ht().memoizedState}function yb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Kt();e=ds(s);var i=fs(t,e,s);i!==null&&(Vt(i,t,s),wl(i,t,s)),t={cache:pc()},e.payload=t;return}t=t.return}}function Sb(e,t,s){var i=Kt();s={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},li(e)?gh(t,s):(s=ac(e,t,s,i),s!==null&&(Vt(s,e,i),vh(s,t,i)))}function xh(e,t,s){var i=Kt();Ml(e,t,s,i)}function Ml(e,t,s,i){var c={lane:i,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(li(e))gh(t,c);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=t.lastRenderedReducer,d!==null))try{var y=t.lastRenderedState,A=d(y,s);if(c.hasEagerState=!0,c.eagerState=A,Gt(A,y))return Ur(e,t,c,0),et===null&&zr(),!1}catch{}finally{}if(s=ac(e,t,c,i),s!==null)return Vt(s,e,i),vh(s,t,i),!0}return!1}function Vc(e,t,s,i){if(i={lane:2,revertLane:bu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},li(e)){if(t)throw Error(o(479))}else t=ac(e,s,i,2),t!==null&&Vt(t,e,2)}function li(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function gh(e,t){ka=Pr=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function vh(e,t,s){if((s&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,s|=i,t.lanes=s,Nf(e,s)}}var Rl={readContext:Et,use:ti,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Rl.useEffectEvent=ct;var bh={readContext:Et,use:ti,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:Et,useEffect:nh,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,si(4194308,4,rh.bind(null,t,e),s)},useLayoutEffect:function(e,t){return si(4194308,4,e,t)},useInsertionEffect:function(e,t){si(4,2,e,t)},useMemo:function(e,t){var s=_t();t=t===void 0?null:t;var i=e();if(Fs){Oe(!0);try{e()}finally{Oe(!1)}}return s.memoizedState=[i,t],i},useReducer:function(e,t,s){var i=_t();if(s!==void 0){var c=s(t);if(Fs){Oe(!0);try{s(t)}finally{Oe(!1)}}}else c=t;return i.memoizedState=i.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},i.queue=e,e=e.dispatch=Sb.bind(null,Te,e),[i.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:function(e){e=_c(e);var t=e.queue,s=xh.bind(null,Te,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:Lc,useDeferredValue:function(e,t){var s=_t();return zc(s,e,t)},useTransition:function(){var e=_c(!1);return e=dh.bind(null,Te,e.queue,!0,!1),_t().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var i=Te,c=_t();if(Ue){if(s===void 0)throw Error(o(407));s=s()}else{if(s=t(),et===null)throw Error(o(349));(Le&127)!==0||Hm(i,t,s)}c.memoizedState=s;var d={value:s,getSnapshot:t};return c.queue=d,nh($m.bind(null,i,d,e),[e]),i.flags|=2048,Ma(9,{destroy:void 0},Vm.bind(null,i,d,s,t),null),s},useId:function(){var e=_t(),t=et.identifierPrefix;if(Ue){var s=An,i=wn;s=(i&~(1<<32-rt(i)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Wr++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=hb++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Hc,useFormState:Jm,useActionState:Jm,useOptimistic:function(e){var t=_t();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=Vc.bind(null,Te,!0,s),s.dispatch=t,[e,t]},useMemoCache:Tc,useCacheRefresh:function(){return _t().memoizedState=yb.bind(null,Te)},useEffectEvent:function(e){var t=_t(),s={impl:e};return t.memoizedState=s,function(){if((Fe&2)!==0)throw Error(o(440));return s.impl.apply(void 0,arguments)}}},$c={readContext:Et,use:ti,useCallback:oh,useContext:Et,useEffect:Oc,useImperativeHandle:ih,useInsertionEffect:ah,useLayoutEffect:lh,useMemo:ch,useReducer:ni,useRef:th,useState:function(){return ni(Hn)},useDebugValue:Lc,useDeferredValue:function(e,t){var s=ht();return uh(s,Je.memoizedState,e,t)},useTransition:function(){var e=ni(Hn)[0],t=ht().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:Um,useId:hh,useHostTransitionStatus:Hc,useFormState:Pm,useActionState:Pm,useOptimistic:function(e,t){var s=ht();return Fm(s,Je,e,t)},useMemoCache:Tc,useCacheRefresh:ph};$c.useEffectEvent=sh;var yh={readContext:Et,use:ti,useCallback:oh,useContext:Et,useEffect:Oc,useImperativeHandle:ih,useInsertionEffect:ah,useLayoutEffect:lh,useMemo:ch,useReducer:Dc,useRef:th,useState:function(){return Dc(Hn)},useDebugValue:Lc,useDeferredValue:function(e,t){var s=ht();return Je===null?zc(s,e,t):uh(s,Je.memoizedState,e,t)},useTransition:function(){var e=Dc(Hn)[0],t=ht().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:Um,useId:hh,useHostTransitionStatus:Hc,useFormState:eh,useActionState:eh,useOptimistic:function(e,t){var s=ht();return Je!==null?Fm(s,Je,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:Tc,useCacheRefresh:ph};yh.useEffectEvent=sh;function Gc(e,t,s,i){t=e.memoizedState,s=s(i,t),s=s==null?t:b({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Yc={enqueueSetState:function(e,t,s){e=e._reactInternals;var i=Kt(),c=ds(i);c.payload=t,s!=null&&(c.callback=s),t=fs(e,c,i),t!==null&&(Vt(t,e,i),wl(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var i=Kt(),c=ds(i);c.tag=1,c.payload=t,s!=null&&(c.callback=s),t=fs(e,c,i),t!==null&&(Vt(t,e,i),wl(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Kt(),i=ds(s);i.tag=2,t!=null&&(i.callback=t),t=fs(e,i,s),t!==null&&(Vt(t,e,s),wl(t,e,s))}};function Sh(e,t,s,i,c,d,y){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,d,y):t.prototype&&t.prototype.isPureReactComponent?!xl(s,i)||!xl(c,d):!0}function jh(e,t,s,i){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,i),t.state!==e&&Yc.enqueueReplaceState(t,t.state,null)}function Is(e,t){var s=t;if("ref"in t){s={};for(var i in t)i!=="ref"&&(s[i]=t[i])}if(e=e.defaultProps){s===t&&(s=b({},s));for(var c in e)s[c]===void 0&&(s[c]=e[c])}return s}function Nh(e){Lr(e)}function wh(e){console.error(e)}function Ah(e){Lr(e)}function ri(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function Ch(e,t,s){try{var i=e.onCaughtError;i(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Fc(e,t,s){return s=ds(s),s.tag=3,s.payload={element:null},s.callback=function(){ri(e,t)},s}function kh(e){return e=ds(e),e.tag=3,e}function Eh(e,t,s,i){var c=s.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;e.payload=function(){return c(d)},e.callback=function(){Ch(t,s,i)}}var y=s.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(e.callback=function(){Ch(t,s,i),typeof c!="function"&&(vs===null?vs=new Set([this]):vs.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})})}function jb(e,t,s,i,c){if(s.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=s.alternate,t!==null&&Sa(t,s,c,!0),s=Ft.current,s!==null){switch(s.tag){case 31:case 13:return dn===null?vi():s.alternate===null&&ut===0&&(ut=3),s.flags&=-257,s.flags|=65536,s.lanes=c,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([i]):t.add(i),xu(e,i,c)),!1;case 22:return s.flags|=65536,i===Xr?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([i]):s.add(i)),xu(e,i,c)),!1}throw Error(o(435,s.tag))}return xu(e,i,c),vi(),!1}if(Ue)return t=Ft.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,i!==uc&&(e=Error(o(422),{cause:i}),bl(rn(e,s)))):(i!==uc&&(t=Error(o(423),{cause:i}),bl(rn(t,s))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,i=rn(i,s),c=Fc(e.stateNode,i,c),Sc(e,c),ut!==4&&(ut=2)),!1;var d=Error(o(520),{cause:i});if(d=rn(d,s),zl===null?zl=[d]:zl.push(d),ut!==4&&(ut=2),t===null)return!0;i=rn(i,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=c&-c,s.lanes|=e,e=Fc(s.stateNode,i,e),Sc(s,e),!1;case 1:if(t=s.type,d=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(vs===null||!vs.has(d))))return s.flags|=65536,c&=-c,s.lanes|=c,c=kh(c),Eh(c,e,s,i),Sc(s,c),!1}s=s.return}while(s!==null);return!1}var Ic=Error(o(461)),gt=!1;function Mt(e,t,s,i){t.child=e===null?qm(t,null,s,i):Ys(t,e.child,s,i)}function Mh(e,t,s,i,c){s=s.render;var d=t.ref;if("ref"in i){var y={};for(var A in i)A!=="ref"&&(y[A]=i[A])}else y=i;return Hs(t),i=kc(e,t,s,y,d,c),A=Ec(),e!==null&&!gt?(Mc(e,t,c),Vn(e,t,c)):(Ue&&A&&oc(t),t.flags|=1,Mt(e,t,i,c),t.child)}function Rh(e,t,s,i,c){if(e===null){var d=s.type;return typeof d=="function"&&!lc(d)&&d.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=d,Th(e,t,d,i,c)):(e=Vr(s.type,null,i,t,t.mode,c),e.ref=t.ref,e.return=t,t.child=e)}if(d=e.child,!eu(e,c)){var y=d.memoizedProps;if(s=s.compare,s=s!==null?s:xl,s(y,i)&&e.ref===t.ref)return Vn(e,t,c)}return t.flags|=1,e=Bn(d,i),e.ref=t.ref,e.return=t,t.child=e}function Th(e,t,s,i,c){if(e!==null){var d=e.memoizedProps;if(xl(d,i)&&e.ref===t.ref)if(gt=!1,t.pendingProps=i=d,eu(e,c))(e.flags&131072)!==0&&(gt=!0);else return t.lanes=e.lanes,Vn(e,t,c)}return Xc(e,t,s,i,c)}function qh(e,t,s,i){var c=i.children,d=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(d=d!==null?d.baseLanes|s:s,e!==null){for(i=t.child=e.child,c=0;i!==null;)c=c|i.lanes|i.childLanes,i=i.sibling;i=c&~d}else i=0,t.child=null;return Dh(e,t,d,s,i)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Fr(t,d!==null?d.cachePool:null),d!==null?Bm(t,d):Nc(),Om(t);else return i=t.lanes=536870912,Dh(e,t,d!==null?d.baseLanes|s:s,s,i)}else d!==null?(Fr(t,d.cachePool),Bm(t,d),hs(),t.memoizedState=null):(e!==null&&Fr(t,null),Nc(),hs());return Mt(e,t,c,s),t.child}function Tl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Dh(e,t,s,i,c){var d=gc();return d=d===null?null:{parent:pt._currentValue,pool:d},t.memoizedState={baseLanes:s,cachePool:d},e!==null&&Fr(t,null),Nc(),Om(t),e!==null&&Sa(e,t,i,!0),t.childLanes=c,null}function ii(e,t){return t=ci({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function _h(e,t,s){return Ys(t,e.child,null,s),e=ii(t,t.pendingProps),e.flags|=2,It(t),t.memoizedState=null,e}function Nb(e,t,s){var i=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ue){if(i.mode==="hidden")return e=ii(t,i),t.lanes=536870912,Tl(null,e);if(Ac(t),(e=nt)?(e=Ip(e,un),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:rs!==null?{id:wn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},s=gm(e),s.return=t,t.child=s,kt=t,nt=null)):e=null,e===null)throw os(t);return t.lanes=536870912,null}return ii(t,i)}var d=e.memoizedState;if(d!==null){var y=d.dehydrated;if(Ac(t),c)if(t.flags&256)t.flags&=-257,t=_h(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(gt||Sa(e,t,s,!1),c=(s&e.childLanes)!==0,gt||c){if(i=et,i!==null&&(y=wf(i,s),y!==0&&y!==d.retryLane))throw d.retryLane=y,Os(e,y),Vt(i,e,y),Ic;vi(),t=_h(e,t,s)}else e=d.treeContext,nt=fn(y.nextSibling),kt=t,Ue=!0,is=null,un=!1,e!==null&&ym(t,e),t=ii(t,i),t.flags|=4096;return t}return e=Bn(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function oi(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(o(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function Xc(e,t,s,i,c){return Hs(t),s=kc(e,t,s,i,void 0,c),i=Ec(),e!==null&&!gt?(Mc(e,t,c),Vn(e,t,c)):(Ue&&i&&oc(t),t.flags|=1,Mt(e,t,s,c),t.child)}function Bh(e,t,s,i,c,d){return Hs(t),t.updateQueue=null,s=zm(t,i,s,c),Lm(e),i=Ec(),e!==null&&!gt?(Mc(e,t,d),Vn(e,t,d)):(Ue&&i&&oc(t),t.flags|=1,Mt(e,t,s,d),t.child)}function Oh(e,t,s,i,c){if(Hs(t),t.stateNode===null){var d=ga,y=s.contextType;typeof y=="object"&&y!==null&&(d=Et(y)),d=new s(i,d),t.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Yc,t.stateNode=d,d._reactInternals=t,d=t.stateNode,d.props=i,d.state=t.memoizedState,d.refs={},bc(t),y=s.contextType,d.context=typeof y=="object"&&y!==null?Et(y):ga,d.state=t.memoizedState,y=s.getDerivedStateFromProps,typeof y=="function"&&(Gc(t,s,y,i),d.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(y=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),y!==d.state&&Yc.enqueueReplaceState(d,d.state,null),Cl(t,i,d,c),Al(),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(e===null){d=t.stateNode;var A=t.memoizedProps,_=Is(s,A);d.props=_;var G=d.context,ee=s.contextType;y=ga,typeof ee=="object"&&ee!==null&&(y=Et(ee));var se=s.getDerivedStateFromProps;ee=typeof se=="function"||typeof d.getSnapshotBeforeUpdate=="function",A=t.pendingProps!==A,ee||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(A||G!==y)&&jh(t,d,i,y),us=!1;var F=t.memoizedState;d.state=F,Cl(t,i,d,c),Al(),G=t.memoizedState,A||F!==G||us?(typeof se=="function"&&(Gc(t,s,se,i),G=t.memoizedState),(_=us||Sh(t,s,_,i,F,G,y))?(ee||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(t.flags|=4194308)):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=G),d.props=i,d.state=G,d.context=y,i=_):(typeof d.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{d=t.stateNode,yc(e,t),y=t.memoizedProps,ee=Is(s,y),d.props=ee,se=t.pendingProps,F=d.context,G=s.contextType,_=ga,typeof G=="object"&&G!==null&&(_=Et(G)),A=s.getDerivedStateFromProps,(G=typeof A=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(y!==se||F!==_)&&jh(t,d,i,_),us=!1,F=t.memoizedState,d.state=F,Cl(t,i,d,c),Al();var J=t.memoizedState;y!==se||F!==J||us||e!==null&&e.dependencies!==null&&Gr(e.dependencies)?(typeof A=="function"&&(Gc(t,s,A,i),J=t.memoizedState),(ee=us||Sh(t,s,ee,i,F,J,_)||e!==null&&e.dependencies!==null&&Gr(e.dependencies))?(G||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(i,J,_),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(i,J,_)),typeof d.componentDidUpdate=="function"&&(t.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&F===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&F===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=J),d.props=i,d.state=J,d.context=_,i=ee):(typeof d.componentDidUpdate!="function"||y===e.memoizedProps&&F===e.memoizedState||(t.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||y===e.memoizedProps&&F===e.memoizedState||(t.flags|=1024),i=!1)}return d=i,oi(e,t),i=(t.flags&128)!==0,d||i?(d=t.stateNode,s=i&&typeof s.getDerivedStateFromError!="function"?null:d.render(),t.flags|=1,e!==null&&i?(t.child=Ys(t,e.child,null,c),t.child=Ys(t,null,s,c)):Mt(e,t,s,c),t.memoizedState=d.state,e=t.child):e=Vn(e,t,c),e}function Lh(e,t,s,i){return zs(),t.flags|=256,Mt(e,t,s,i),t.child}var Qc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Kc(e){return{baseLanes:e,cachePool:Cm()}}function Zc(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Qt),e}function zh(e,t,s){var i=t.pendingProps,c=!1,d=(t.flags&128)!==0,y;if((y=d)||(y=e!==null&&e.memoizedState===null?!1:(mt.current&2)!==0),y&&(c=!0,t.flags&=-129),y=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ue){if(c?ms(t):hs(),(e=nt)?(e=Ip(e,un),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:rs!==null?{id:wn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},s=gm(e),s.return=t,t.child=s,kt=t,nt=null)):e=null,e===null)throw os(t);return qu(e)?t.lanes=32:t.lanes=536870912,null}var A=i.children;return i=i.fallback,c?(hs(),c=t.mode,A=ci({mode:"hidden",children:A},c),i=Ls(i,c,s,null),A.return=t,i.return=t,A.sibling=i,t.child=A,i=t.child,i.memoizedState=Kc(s),i.childLanes=Zc(e,y,s),t.memoizedState=Qc,Tl(null,i)):(ms(t),Jc(t,A))}var _=e.memoizedState;if(_!==null&&(A=_.dehydrated,A!==null)){if(d)t.flags&256?(ms(t),t.flags&=-257,t=Pc(e,t,s)):t.memoizedState!==null?(hs(),t.child=e.child,t.flags|=128,t=null):(hs(),A=i.fallback,c=t.mode,i=ci({mode:"visible",children:i.children},c),A=Ls(A,c,s,null),A.flags|=2,i.return=t,A.return=t,i.sibling=A,t.child=i,Ys(t,e.child,null,s),i=t.child,i.memoizedState=Kc(s),i.childLanes=Zc(e,y,s),t.memoizedState=Qc,t=Tl(null,i));else if(ms(t),qu(A)){if(y=A.nextSibling&&A.nextSibling.dataset,y)var G=y.dgst;y=G,i=Error(o(419)),i.stack="",i.digest=y,bl({value:i,source:null,stack:null}),t=Pc(e,t,s)}else if(gt||Sa(e,t,s,!1),y=(s&e.childLanes)!==0,gt||y){if(y=et,y!==null&&(i=wf(y,s),i!==0&&i!==_.retryLane))throw _.retryLane=i,Os(e,i),Vt(y,e,i),Ic;Tu(A)||vi(),t=Pc(e,t,s)}else Tu(A)?(t.flags|=192,t.child=e.child,t=null):(e=_.treeContext,nt=fn(A.nextSibling),kt=t,Ue=!0,is=null,un=!1,e!==null&&ym(t,e),t=Jc(t,i.children),t.flags|=4096);return t}return c?(hs(),A=i.fallback,c=t.mode,_=e.child,G=_.sibling,i=Bn(_,{mode:"hidden",children:i.children}),i.subtreeFlags=_.subtreeFlags&65011712,G!==null?A=Bn(G,A):(A=Ls(A,c,s,null),A.flags|=2),A.return=t,i.return=t,i.sibling=A,t.child=i,Tl(null,i),i=t.child,A=e.child.memoizedState,A===null?A=Kc(s):(c=A.cachePool,c!==null?(_=pt._currentValue,c=c.parent!==_?{parent:_,pool:_}:c):c=Cm(),A={baseLanes:A.baseLanes|s,cachePool:c}),i.memoizedState=A,i.childLanes=Zc(e,y,s),t.memoizedState=Qc,Tl(e.child,i)):(ms(t),s=e.child,e=s.sibling,s=Bn(s,{mode:"visible",children:i.children}),s.return=t,s.sibling=null,e!==null&&(y=t.deletions,y===null?(t.deletions=[e],t.flags|=16):y.push(e)),t.child=s,t.memoizedState=null,s)}function Jc(e,t){return t=ci({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function ci(e,t){return e=Yt(22,e,null,t),e.lanes=0,e}function Pc(e,t,s){return Ys(t,e.child,null,s),e=Jc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Uh(e,t,s){e.lanes|=t;var i=e.alternate;i!==null&&(i.lanes|=t),mc(e.return,t,s)}function Wc(e,t,s,i,c,d){var y=e.memoizedState;y===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:s,tailMode:c,treeForkCount:d}:(y.isBackwards=t,y.rendering=null,y.renderingStartTime=0,y.last=i,y.tail=s,y.tailMode=c,y.treeForkCount=d)}function Hh(e,t,s){var i=t.pendingProps,c=i.revealOrder,d=i.tail;i=i.children;var y=mt.current,A=(y&2)!==0;if(A?(y=y&1|2,t.flags|=128):y&=1,Z(mt,y),Mt(e,t,i,s),i=Ue?vl:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Uh(e,s,t);else if(e.tag===19)Uh(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(s=t.child,c=null;s!==null;)e=s.alternate,e!==null&&Jr(e)===null&&(c=s),s=s.sibling;s=c,s===null?(c=t.child,t.child=null):(c=s.sibling,s.sibling=null),Wc(t,!1,c,s,d,i);break;case"backwards":case"unstable_legacy-backwards":for(s=null,c=t.child,t.child=null;c!==null;){if(e=c.alternate,e!==null&&Jr(e)===null){t.child=c;break}e=c.sibling,c.sibling=s,s=c,c=e}Wc(t,!0,s,null,d,i);break;case"together":Wc(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Vn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),gs|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Sa(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,s=Bn(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Bn(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function eu(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Gr(e)))}function wb(e,t,s){switch(t.tag){case 3:xe(t,t.stateNode.containerInfo),cs(t,pt,e.memoizedState.cache),zs();break;case 27:case 5:Se(t);break;case 4:xe(t,t.stateNode.containerInfo);break;case 10:cs(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ac(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(ms(t),t.flags|=128,null):(s&t.child.childLanes)!==0?zh(e,t,s):(ms(t),e=Vn(e,t,s),e!==null?e.sibling:null);ms(t);break;case 19:var c=(e.flags&128)!==0;if(i=(s&t.childLanes)!==0,i||(Sa(e,t,s,!1),i=(s&t.childLanes)!==0),c){if(i)return Hh(e,t,s);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),Z(mt,mt.current),i)break;return null;case 22:return t.lanes=0,qh(e,t,s,t.pendingProps);case 24:cs(t,pt,e.memoizedState.cache)}return Vn(e,t,s)}function Vh(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)gt=!0;else{if(!eu(e,s)&&(t.flags&128)===0)return gt=!1,wb(e,t,s);gt=(e.flags&131072)!==0}else gt=!1,Ue&&(t.flags&1048576)!==0&&bm(t,vl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(e=$s(t.elementType),t.type=e,typeof e=="function")lc(e)?(i=Is(e,i),t.tag=1,t=Oh(null,t,e,i,s)):(t.tag=0,t=Xc(null,t,e,i,s));else{if(e!=null){var c=e.$$typeof;if(c===R){t.tag=11,t=Mh(null,t,e,i,s);break e}else if(c===O){t.tag=14,t=Rh(null,t,e,i,s);break e}}throw t=ue(e)||e,Error(o(306,t,""))}}return t;case 0:return Xc(e,t,t.type,t.pendingProps,s);case 1:return i=t.type,c=Is(i,t.pendingProps),Oh(e,t,i,c,s);case 3:e:{if(xe(t,t.stateNode.containerInfo),e===null)throw Error(o(387));i=t.pendingProps;var d=t.memoizedState;c=d.element,yc(e,t),Cl(t,i,null,s);var y=t.memoizedState;if(i=y.cache,cs(t,pt,i),i!==d.cache&&hc(t,[pt],s,!0),Al(),i=y.element,d.isDehydrated)if(d={element:i,isDehydrated:!1,cache:y.cache},t.updateQueue.baseState=d,t.memoizedState=d,t.flags&256){t=Lh(e,t,i,s);break e}else if(i!==c){c=rn(Error(o(424)),t),bl(c),t=Lh(e,t,i,s);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(nt=fn(e.firstChild),kt=t,Ue=!0,is=null,un=!0,s=qm(t,null,i,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(zs(),i===c){t=Vn(e,t,s);break e}Mt(e,t,i,s)}t=t.child}return t;case 26:return oi(e,t),e===null?(s=Pp(t.type,null,t.pendingProps,null))?t.memoizedState=s:Ue||(s=t.type,e=t.pendingProps,i=Ai(we.current).createElement(s),i[Ct]=t,i[Bt]=e,Rt(i,s,e),wt(i),t.stateNode=i):t.memoizedState=Pp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Se(t),e===null&&Ue&&(i=t.stateNode=Kp(t.type,t.pendingProps,we.current),kt=t,un=!0,c=nt,js(t.type)?(Du=c,nt=fn(i.firstChild)):nt=c),Mt(e,t,t.pendingProps.children,s),oi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ue&&((c=i=nt)&&(i=ey(i,t.type,t.pendingProps,un),i!==null?(t.stateNode=i,kt=t,nt=fn(i.firstChild),un=!1,c=!0):c=!1),c||os(t)),Se(t),c=t.type,d=t.pendingProps,y=e!==null?e.memoizedProps:null,i=d.children,Eu(c,d)?i=null:y!==null&&Eu(c,y)&&(t.flags|=32),t.memoizedState!==null&&(c=kc(e,t,pb,null,null,s),Il._currentValue=c),oi(e,t),Mt(e,t,i,s),t.child;case 6:return e===null&&Ue&&((e=s=nt)&&(s=ty(s,t.pendingProps,un),s!==null?(t.stateNode=s,kt=t,nt=null,e=!0):e=!1),e||os(t)),null;case 13:return zh(e,t,s);case 4:return xe(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ys(t,null,i,s):Mt(e,t,i,s),t.child;case 11:return Mh(e,t,t.type,t.pendingProps,s);case 7:return Mt(e,t,t.pendingProps,s),t.child;case 8:return Mt(e,t,t.pendingProps.children,s),t.child;case 12:return Mt(e,t,t.pendingProps.children,s),t.child;case 10:return i=t.pendingProps,cs(t,t.type,i.value),Mt(e,t,i.children,s),t.child;case 9:return c=t.type._context,i=t.pendingProps.children,Hs(t),c=Et(c),i=i(c),t.flags|=1,Mt(e,t,i,s),t.child;case 14:return Rh(e,t,t.type,t.pendingProps,s);case 15:return Th(e,t,t.type,t.pendingProps,s);case 19:return Hh(e,t,s);case 31:return Nb(e,t,s);case 22:return qh(e,t,s,t.pendingProps);case 24:return Hs(t),i=Et(pt),e===null?(c=gc(),c===null&&(c=et,d=pc(),c.pooledCache=d,d.refCount++,d!==null&&(c.pooledCacheLanes|=s),c=d),t.memoizedState={parent:i,cache:c},bc(t),cs(t,pt,c)):((e.lanes&s)!==0&&(yc(e,t),Cl(t,null,null,s),Al()),c=e.memoizedState,d=t.memoizedState,c.parent!==i?(c={parent:i,cache:i},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),cs(t,pt,i)):(i=d.cache,cs(t,pt,i),i!==c.cache&&hc(t,[pt],s,!0))),Mt(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function $n(e){e.flags|=4}function tu(e,t,s,i,c){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(hp())e.flags|=8192;else throw Gs=Xr,vc}else e.flags&=-16777217}function $h(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!s0(t))if(hp())e.flags|=8192;else throw Gs=Xr,vc}function ui(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Sf():536870912,e.lanes|=t,Da|=t)}function ql(e,t){if(!Ue)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var i=null;s!==null;)s.alternate!==null&&(i=s),s=s.sibling;i===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function st(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,i=0;if(t)for(var c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags&65011712,i|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)s|=c.lanes|c.childLanes,i|=c.subtreeFlags,i|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=i,e.childLanes=s,t}function Ab(e,t,s){var i=t.pendingProps;switch(cc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return st(t),null;case 1:return st(t),null;case 3:return s=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),zn(pt),ge(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(ya(t)?$n(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,dc())),st(t),null;case 26:var c=t.type,d=t.memoizedState;return e===null?($n(t),d!==null?(st(t),$h(t,d)):(st(t),tu(t,c,null,i,s))):d?d!==e.memoizedState?($n(t),st(t),$h(t,d)):(st(t),t.flags&=-16777217):(e=e.memoizedProps,e!==i&&$n(t),st(t),tu(t,c,e,i,s)),null;case 27:if(be(t),s=we.current,c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return st(t),null}e=le.current,ya(t)?Sm(t):(e=Kp(c,i,s),t.stateNode=e,$n(t))}return st(t),null;case 5:if(be(t),c=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(!i){if(t.stateNode===null)throw Error(o(166));return st(t),null}if(d=le.current,ya(t))Sm(t);else{var y=Ai(we.current);switch(d){case 1:d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":d=y.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":d=y.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":d=y.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof i.is=="string"?y.createElement("select",{is:i.is}):y.createElement("select"),i.multiple?d.multiple=!0:i.size&&(d.size=i.size);break;default:d=typeof i.is=="string"?y.createElement(c,{is:i.is}):y.createElement(c)}}d[Ct]=t,d[Bt]=i;e:for(y=t.child;y!==null;){if(y.tag===5||y.tag===6)d.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===t)break e;for(;y.sibling===null;){if(y.return===null||y.return===t)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}t.stateNode=d;e:switch(Rt(d,c,i),c){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&$n(t)}}return st(t),tu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&$n(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(o(166));if(e=we.current,ya(t)){if(e=t.stateNode,s=t.memoizedProps,i=null,c=kt,c!==null)switch(c.tag){case 27:case 5:i=c.memoizedProps}e[Ct]=t,e=!!(e.nodeValue===s||i!==null&&i.suppressHydrationWarning===!0||zp(e.nodeValue,s)),e||os(t,!0)}else e=Ai(e).createTextNode(i),e[Ct]=t,t.stateNode=e}return st(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(i=ya(t),s!==null){if(e===null){if(!i)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Ct]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;st(t),e=!1}else s=dc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(It(t),t):(It(t),null);if((t.flags&128)!==0)throw Error(o(558))}return st(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=ya(t),i!==null&&i.dehydrated!==null){if(e===null){if(!c)throw Error(o(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(o(317));c[Ct]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;st(t),c=!1}else c=dc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(It(t),t):(It(t),null)}return It(t),(t.flags&128)!==0?(t.lanes=s,t):(s=i!==null,e=e!==null&&e.memoizedState!==null,s&&(i=t.child,c=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(c=i.alternate.memoizedState.cachePool.pool),d=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),d!==c&&(i.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),ui(t,t.updateQueue),st(t),null);case 4:return ge(),e===null&&Nu(t.stateNode.containerInfo),st(t),null;case 10:return zn(t.type),st(t),null;case 19:if(q(mt),i=t.memoizedState,i===null)return st(t),null;if(c=(t.flags&128)!==0,d=i.rendering,d===null)if(c)ql(i,!1);else{if(ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(d=Jr(e),d!==null){for(t.flags|=128,ql(i,!1),e=d.updateQueue,t.updateQueue=e,ui(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)xm(s,e),s=s.sibling;return Z(mt,mt.current&1|2),Ue&&On(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&ne()>pi&&(t.flags|=128,c=!0,ql(i,!1),t.lanes=4194304)}else{if(!c)if(e=Jr(d),e!==null){if(t.flags|=128,c=!0,e=e.updateQueue,t.updateQueue=e,ui(t,e),ql(i,!0),i.tail===null&&i.tailMode==="hidden"&&!d.alternate&&!Ue)return st(t),null}else 2*ne()-i.renderingStartTime>pi&&s!==536870912&&(t.flags|=128,c=!0,ql(i,!1),t.lanes=4194304);i.isBackwards?(d.sibling=t.child,t.child=d):(e=i.last,e!==null?e.sibling=d:t.child=d,i.last=d)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=ne(),e.sibling=null,s=mt.current,Z(mt,c?s&1|2:s&1),Ue&&On(t,i.treeForkCount),e):(st(t),null);case 22:case 23:return It(t),wc(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(s&536870912)!==0&&(t.flags&128)===0&&(st(t),t.subtreeFlags&6&&(t.flags|=8192)):st(t),s=t.updateQueue,s!==null&&ui(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==s&&(t.flags|=2048),e!==null&&q(Vs),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),zn(pt),st(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Cb(e,t){switch(cc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zn(pt),ge(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return be(t),null;case 31:if(t.memoizedState!==null){if(It(t),t.alternate===null)throw Error(o(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(It(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(mt),null;case 4:return ge(),null;case 10:return zn(t.type),null;case 22:case 23:return It(t),wc(),e!==null&&q(Vs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zn(pt),null;case 25:return null;default:return null}}function Gh(e,t){switch(cc(t),t.tag){case 3:zn(pt),ge();break;case 26:case 27:case 5:be(t);break;case 4:ge();break;case 31:t.memoizedState!==null&&It(t);break;case 13:It(t);break;case 19:q(mt);break;case 10:zn(t.type);break;case 22:case 23:It(t),wc(),e!==null&&q(Vs);break;case 24:zn(pt)}}function Dl(e,t){try{var s=t.updateQueue,i=s!==null?s.lastEffect:null;if(i!==null){var c=i.next;s=c;do{if((s.tag&e)===e){i=void 0;var d=s.create,y=s.inst;i=d(),y.destroy=i}s=s.next}while(s!==c)}}catch(A){Ke(t,t.return,A)}}function ps(e,t,s){try{var i=t.updateQueue,c=i!==null?i.lastEffect:null;if(c!==null){var d=c.next;i=d;do{if((i.tag&e)===e){var y=i.inst,A=y.destroy;if(A!==void 0){y.destroy=void 0,c=t;var _=s,G=A;try{G()}catch(ee){Ke(c,_,ee)}}}i=i.next}while(i!==d)}}catch(ee){Ke(t,t.return,ee)}}function Yh(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{_m(t,s)}catch(i){Ke(e,e.return,i)}}}function Fh(e,t,s){s.props=Is(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(i){Ke(e,t,i)}}function _l(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof s=="function"?e.refCleanup=s(i):s.current=i}}catch(c){Ke(e,t,c)}}function Cn(e,t){var s=e.ref,i=e.refCleanup;if(s!==null)if(typeof i=="function")try{i()}catch(c){Ke(e,t,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(c){Ke(e,t,c)}else s.current=null}function Ih(e){var t=e.type,s=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&i.focus();break e;case"img":s.src?i.src=s.src:s.srcSet&&(i.srcset=s.srcSet)}}catch(c){Ke(e,e.return,c)}}function nu(e,t,s){try{var i=e.stateNode;Qb(i,e.type,s,t),i[Bt]=t}catch(c){Ke(e,e.return,c)}}function Xh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&js(e.type)||e.tag===4}function su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Xh(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&&js(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 au(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Dn));else if(i!==4&&(i===27&&js(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(au(e,t,s),e=e.sibling;e!==null;)au(e,t,s),e=e.sibling}function di(e,t,s){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(i!==4&&(i===27&&js(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(di(e,t,s),e=e.sibling;e!==null;)di(e,t,s),e=e.sibling}function Qh(e){var t=e.stateNode,s=e.memoizedProps;try{for(var i=e.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Rt(t,i,s),t[Ct]=e,t[Bt]=s}catch(d){Ke(e,e.return,d)}}var Gn=!1,vt=!1,lu=!1,Kh=typeof WeakSet=="function"?WeakSet:Set,At=null;function kb(e,t){if(e=e.containerInfo,Cu=qi,e=im(e),Po(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var i=s.getSelection&&s.getSelection();if(i&&i.rangeCount!==0){s=i.anchorNode;var c=i.anchorOffset,d=i.focusNode;i=i.focusOffset;try{s.nodeType,d.nodeType}catch{s=null;break e}var y=0,A=-1,_=-1,G=0,ee=0,se=e,F=null;t:for(;;){for(var J;se!==s||c!==0&&se.nodeType!==3||(A=y+c),se!==d||i!==0&&se.nodeType!==3||(_=y+i),se.nodeType===3&&(y+=se.nodeValue.length),(J=se.firstChild)!==null;)F=se,se=J;for(;;){if(se===e)break t;if(F===s&&++G===c&&(A=y),F===d&&++ee===i&&(_=y),(J=se.nextSibling)!==null)break;se=F,F=se.parentNode}se=J}s=A===-1||_===-1?null:{start:A,end:_}}else s=null}s=s||{start:0,end:0}}else s=null;for(ku={focusedElem:e,selectionRange:s},qi=!1,At=t;At!==null;)if(t=At,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,At=e;else for(;At!==null;){switch(t=At,d=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(s=0;s<e.length;s++)c=e[s],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&d!==null){e=void 0,s=t,c=d.memoizedProps,d=d.memoizedState,i=s.stateNode;try{var ve=Is(s.type,c);e=i.getSnapshotBeforeUpdate(ve,d),i.__reactInternalSnapshotBeforeUpdate=e}catch(ke){Ke(s,s.return,ke)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)Ru(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ru(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,At=e;break}At=t.return}}function Zh(e,t,s){var i=s.flags;switch(s.tag){case 0:case 11:case 15:Fn(e,s),i&4&&Dl(5,s);break;case 1:if(Fn(e,s),i&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(y){Ke(s,s.return,y)}else{var c=Is(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(c,t,e.__reactInternalSnapshotBeforeUpdate)}catch(y){Ke(s,s.return,y)}}i&64&&Yh(s),i&512&&_l(s,s.return);break;case 3:if(Fn(e,s),i&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{_m(e,t)}catch(y){Ke(s,s.return,y)}}break;case 27:t===null&&i&4&&Qh(s);case 26:case 5:Fn(e,s),t===null&&i&4&&Ih(s),i&512&&_l(s,s.return);break;case 12:Fn(e,s);break;case 31:Fn(e,s),i&4&&Wh(e,s);break;case 13:Fn(e,s),i&4&&ep(e,s),i&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Ob.bind(null,s),ny(e,s))));break;case 22:if(i=s.memoizedState!==null||Gn,!i){t=t!==null&&t.memoizedState!==null||vt,c=Gn;var d=vt;Gn=i,(vt=t)&&!d?In(e,s,(s.subtreeFlags&8772)!==0):Fn(e,s),Gn=c,vt=d}break;case 30:break;default:Fn(e,s)}}function Jh(e){var t=e.alternate;t!==null&&(e.alternate=null,Jh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Bo(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,Lt=!1;function Yn(e,t,s){for(s=s.child;s!==null;)Ph(e,t,s),s=s.sibling}function Ph(e,t,s){if(Ee&&typeof Ee.onCommitFiberUnmount=="function")try{Ee.onCommitFiberUnmount(Xe,s)}catch{}switch(s.tag){case 26:vt||Cn(s,t),Yn(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:vt||Cn(s,t);var i=at,c=Lt;js(s.type)&&(at=s.stateNode,Lt=!1),Yn(e,t,s),Gl(s.stateNode),at=i,Lt=c;break;case 5:vt||Cn(s,t);case 6:if(i=at,c=Lt,at=null,Yn(e,t,s),at=i,Lt=c,at!==null)if(Lt)try{(at.nodeType===9?at.body:at.nodeName==="HTML"?at.ownerDocument.body:at).removeChild(s.stateNode)}catch(d){Ke(s,t,d)}else try{at.removeChild(s.stateNode)}catch(d){Ke(s,t,d)}break;case 18:at!==null&&(Lt?(e=at,Yp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Va(e)):Yp(at,s.stateNode));break;case 4:i=at,c=Lt,at=s.stateNode.containerInfo,Lt=!0,Yn(e,t,s),at=i,Lt=c;break;case 0:case 11:case 14:case 15:ps(2,s,t),vt||ps(4,s,t),Yn(e,t,s);break;case 1:vt||(Cn(s,t),i=s.stateNode,typeof i.componentWillUnmount=="function"&&Fh(s,t,i)),Yn(e,t,s);break;case 21:Yn(e,t,s);break;case 22:vt=(i=vt)||s.memoizedState!==null,Yn(e,t,s),vt=i;break;default:Yn(e,t,s)}}function Wh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Va(e)}catch(s){Ke(t,t.return,s)}}}function ep(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Va(e)}catch(s){Ke(t,t.return,s)}}function Eb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Kh),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Kh),t;default:throw Error(o(435,e.tag))}}function fi(e,t){var s=Eb(e);t.forEach(function(i){if(!s.has(i)){s.add(i);var c=Lb.bind(null,e,i);i.then(c,c)}})}function zt(e,t){var s=t.deletions;if(s!==null)for(var i=0;i<s.length;i++){var c=s[i],d=e,y=t,A=y;e:for(;A!==null;){switch(A.tag){case 27:if(js(A.type)){at=A.stateNode,Lt=!1;break e}break;case 5:at=A.stateNode,Lt=!1;break e;case 3:case 4:at=A.stateNode.containerInfo,Lt=!0;break e}A=A.return}if(at===null)throw Error(o(160));Ph(d,y,c),at=null,Lt=!1,d=c.alternate,d!==null&&(d.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)tp(t,e),t=t.sibling}var vn=null;function tp(e,t){var s=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:zt(t,e),Ut(e),i&4&&(ps(3,e,e.return),Dl(3,e),ps(5,e,e.return));break;case 1:zt(t,e),Ut(e),i&512&&(vt||s===null||Cn(s,s.return)),i&64&&Gn&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?i:s.concat(i))));break;case 26:var c=vn;if(zt(t,e),Ut(e),i&512&&(vt||s===null||Cn(s,s.return)),i&4){var d=s!==null?s.memoizedState:null;if(i=e.memoizedState,s===null)if(i===null)if(e.stateNode===null){e:{i=e.type,s=e.memoizedProps,c=c.ownerDocument||c;t:switch(i){case"title":d=c.getElementsByTagName("title")[0],(!d||d[il]||d[Ct]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=c.createElement(i),c.head.insertBefore(d,c.querySelector("head > title"))),Rt(d,i,s),d[Ct]=e,wt(d),i=d;break e;case"link":var y=t0("link","href",c).get(i+(s.href||""));if(y){for(var A=0;A<y.length;A++)if(d=y[A],d.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&d.getAttribute("rel")===(s.rel==null?null:s.rel)&&d.getAttribute("title")===(s.title==null?null:s.title)&&d.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){y.splice(A,1);break t}}d=c.createElement(i),Rt(d,i,s),c.head.appendChild(d);break;case"meta":if(y=t0("meta","content",c).get(i+(s.content||""))){for(A=0;A<y.length;A++)if(d=y[A],d.getAttribute("content")===(s.content==null?null:""+s.content)&&d.getAttribute("name")===(s.name==null?null:s.name)&&d.getAttribute("property")===(s.property==null?null:s.property)&&d.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&d.getAttribute("charset")===(s.charSet==null?null:s.charSet)){y.splice(A,1);break t}}d=c.createElement(i),Rt(d,i,s),c.head.appendChild(d);break;default:throw Error(o(468,i))}d[Ct]=e,wt(d),i=d}e.stateNode=i}else n0(c,e.type,e.stateNode);else e.stateNode=e0(c,i,e.memoizedProps);else d!==i?(d===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):d.count--,i===null?n0(c,e.type,e.stateNode):e0(c,i,e.memoizedProps)):i===null&&e.stateNode!==null&&nu(e,e.memoizedProps,s.memoizedProps)}break;case 27:zt(t,e),Ut(e),i&512&&(vt||s===null||Cn(s,s.return)),s!==null&&i&4&&nu(e,e.memoizedProps,s.memoizedProps);break;case 5:if(zt(t,e),Ut(e),i&512&&(vt||s===null||Cn(s,s.return)),e.flags&32){c=e.stateNode;try{ua(c,"")}catch(ve){Ke(e,e.return,ve)}}i&4&&e.stateNode!=null&&(c=e.memoizedProps,nu(e,c,s!==null?s.memoizedProps:c)),i&1024&&(lu=!0);break;case 6:if(zt(t,e),Ut(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,s=e.stateNode;try{s.nodeValue=i}catch(ve){Ke(e,e.return,ve)}}break;case 3:if(Ei=null,c=vn,vn=Ci(t.containerInfo),zt(t,e),vn=c,Ut(e),i&4&&s!==null&&s.memoizedState.isDehydrated)try{Va(t.containerInfo)}catch(ve){Ke(e,e.return,ve)}lu&&(lu=!1,np(e));break;case 4:i=vn,vn=Ci(e.stateNode.containerInfo),zt(t,e),Ut(e),vn=i;break;case 12:zt(t,e),Ut(e);break;case 31:zt(t,e),Ut(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));break;case 13:zt(t,e),Ut(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(hi=ne()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));break;case 22:c=e.memoizedState!==null;var _=s!==null&&s.memoizedState!==null,G=Gn,ee=vt;if(Gn=G||c,vt=ee||_,zt(t,e),vt=ee,Gn=G,Ut(e),i&8192)e:for(t=e.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(s===null||_||Gn||vt||Xs(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){_=s=t;try{if(d=_.stateNode,c)y=d.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{A=_.stateNode;var se=_.memoizedProps.style,F=se!=null&&se.hasOwnProperty("display")?se.display:null;A.style.display=F==null||typeof F=="boolean"?"":(""+F).trim()}}catch(ve){Ke(_,_.return,ve)}}}else if(t.tag===6){if(s===null){_=t;try{_.stateNode.nodeValue=c?"":_.memoizedProps}catch(ve){Ke(_,_.return,ve)}}}else if(t.tag===18){if(s===null){_=t;try{var J=_.stateNode;c?Fp(J,!0):Fp(_.stateNode,!1)}catch(ve){Ke(_,_.return,ve)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=e.updateQueue,i!==null&&(s=i.retryQueue,s!==null&&(i.retryQueue=null,fi(e,s))));break;case 19:zt(t,e),Ut(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,fi(e,i)));break;case 30:break;case 21:break;default:zt(t,e),Ut(e)}}function Ut(e){var t=e.flags;if(t&2){try{for(var s,i=e.return;i!==null;){if(Xh(i)){s=i;break}i=i.return}if(s==null)throw Error(o(160));switch(s.tag){case 27:var c=s.stateNode,d=su(e);di(e,d,c);break;case 5:var y=s.stateNode;s.flags&32&&(ua(y,""),s.flags&=-33);var A=su(e);di(e,A,y);break;case 3:case 4:var _=s.stateNode.containerInfo,G=su(e);au(e,G,_);break;default:throw Error(o(161))}}catch(ee){Ke(e,e.return,ee)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function np(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;np(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Fn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Zh(e,t.alternate,t),t=t.sibling}function Xs(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ps(4,t,t.return),Xs(t);break;case 1:Cn(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&Fh(t,t.return,s),Xs(t);break;case 27:Gl(t.stateNode);case 26:case 5:Cn(t,t.return),Xs(t);break;case 22:t.memoizedState===null&&Xs(t);break;case 30:Xs(t);break;default:Xs(t)}e=e.sibling}}function In(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,c=e,d=t,y=d.flags;switch(d.tag){case 0:case 11:case 15:In(c,d,s),Dl(4,d);break;case 1:if(In(c,d,s),i=d,c=i.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(G){Ke(i,i.return,G)}if(i=d,c=i.updateQueue,c!==null){var A=i.stateNode;try{var _=c.shared.hiddenCallbacks;if(_!==null)for(c.shared.hiddenCallbacks=null,c=0;c<_.length;c++)Dm(_[c],A)}catch(G){Ke(i,i.return,G)}}s&&y&64&&Yh(d),_l(d,d.return);break;case 27:Qh(d);case 26:case 5:In(c,d,s),s&&i===null&&y&4&&Ih(d),_l(d,d.return);break;case 12:In(c,d,s);break;case 31:In(c,d,s),s&&y&4&&Wh(c,d);break;case 13:In(c,d,s),s&&y&4&&ep(c,d);break;case 22:d.memoizedState===null&&In(c,d,s),_l(d,d.return);break;case 30:break;default:In(c,d,s)}t=t.sibling}}function ru(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&yl(s))}function iu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&yl(e))}function bn(e,t,s,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)sp(e,t,s,i),t=t.sibling}function sp(e,t,s,i){var c=t.flags;switch(t.tag){case 0:case 11:case 15:bn(e,t,s,i),c&2048&&Dl(9,t);break;case 1:bn(e,t,s,i);break;case 3:bn(e,t,s,i),c&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&yl(e)));break;case 12:if(c&2048){bn(e,t,s,i),e=t.stateNode;try{var d=t.memoizedProps,y=d.id,A=d.onPostCommit;typeof A=="function"&&A(y,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(_){Ke(t,t.return,_)}}else bn(e,t,s,i);break;case 31:bn(e,t,s,i);break;case 13:bn(e,t,s,i);break;case 23:break;case 22:d=t.stateNode,y=t.alternate,t.memoizedState!==null?d._visibility&2?bn(e,t,s,i):Bl(e,t):d._visibility&2?bn(e,t,s,i):(d._visibility|=2,Ra(e,t,s,i,(t.subtreeFlags&10256)!==0||!1)),c&2048&&ru(y,t);break;case 24:bn(e,t,s,i),c&2048&&iu(t.alternate,t);break;default:bn(e,t,s,i)}}function Ra(e,t,s,i,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var d=e,y=t,A=s,_=i,G=y.flags;switch(y.tag){case 0:case 11:case 15:Ra(d,y,A,_,c),Dl(8,y);break;case 23:break;case 22:var ee=y.stateNode;y.memoizedState!==null?ee._visibility&2?Ra(d,y,A,_,c):Bl(d,y):(ee._visibility|=2,Ra(d,y,A,_,c)),c&&G&2048&&ru(y.alternate,y);break;case 24:Ra(d,y,A,_,c),c&&G&2048&&iu(y.alternate,y);break;default:Ra(d,y,A,_,c)}t=t.sibling}}function Bl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,i=t,c=i.flags;switch(i.tag){case 22:Bl(s,i),c&2048&&ru(i.alternate,i);break;case 24:Bl(s,i),c&2048&&iu(i.alternate,i);break;default:Bl(s,i)}t=t.sibling}}var Ol=8192;function Ta(e,t,s){if(e.subtreeFlags&Ol)for(e=e.child;e!==null;)ap(e,t,s),e=e.sibling}function ap(e,t,s){switch(e.tag){case 26:Ta(e,t,s),e.flags&Ol&&e.memoizedState!==null&&hy(s,vn,e.memoizedState,e.memoizedProps);break;case 5:Ta(e,t,s);break;case 3:case 4:var i=vn;vn=Ci(e.stateNode.containerInfo),Ta(e,t,s),vn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=Ol,Ol=16777216,Ta(e,t,s),Ol=i):Ta(e,t,s));break;default:Ta(e,t,s)}}function lp(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 Ll(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];At=i,ip(i,e)}lp(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)rp(e),e=e.sibling}function rp(e){switch(e.tag){case 0:case 11:case 15:Ll(e),e.flags&2048&&ps(9,e,e.return);break;case 3:Ll(e);break;case 12:Ll(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,mi(e)):Ll(e);break;default:Ll(e)}}function mi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var i=t[s];At=i,ip(i,e)}lp(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ps(8,t,t.return),mi(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,mi(t));break;default:mi(t)}e=e.sibling}}function ip(e,t){for(;At!==null;){var s=At;switch(s.tag){case 0:case 11:case 15:ps(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var i=s.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:yl(s.memoizedState.cache)}if(i=s.child,i!==null)i.return=s,At=i;else e:for(s=e;At!==null;){i=At;var c=i.sibling,d=i.return;if(Jh(i),i===s){At=null;break e}if(c!==null){c.return=d,At=c;break e}At=d}}}var Mb={getCacheForType:function(e){var t=Et(pt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return Et(pt).controller.signal}},Rb=typeof WeakMap=="function"?WeakMap:Map,Fe=0,et=null,_e=null,Le=0,Qe=0,Xt=null,xs=!1,qa=!1,ou=!1,Xn=0,ut=0,gs=0,Qs=0,cu=0,Qt=0,Da=0,zl=null,Ht=null,uu=!1,hi=0,op=0,pi=1/0,xi=null,vs=null,jt=0,bs=null,_a=null,Qn=0,du=0,fu=null,cp=null,Ul=0,mu=null;function Kt(){return(Fe&2)!==0&&Le!==0?Le&-Le:B.T!==null?bu():Af()}function up(){if(Qt===0)if((Le&536870912)===0||Ue){var e=wr;wr<<=1,(wr&3932160)===0&&(wr=262144),Qt=e}else Qt=536870912;return e=Ft.current,e!==null&&(e.flags|=32),Qt}function Vt(e,t,s){(e===et&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)&&(Ba(e,0),ys(e,Le,Qt,!1)),rl(e,s),((Fe&2)===0||e!==et)&&(e===et&&((Fe&2)===0&&(Qs|=s),ut===4&&ys(e,Le,Qt,!1)),kn(e))}function dp(e,t,s){if((Fe&6)!==0)throw Error(o(327));var i=!s&&(t&127)===0&&(t&e.expiredLanes)===0||ll(e,t),c=i?Db(e,t):pu(e,t,!0),d=i;do{if(c===0){qa&&!i&&ys(e,t,0,!1);break}else{if(s=e.current.alternate,d&&!Tb(s)){c=pu(e,t,!1),d=!1;continue}if(c===2){if(d=t,e.errorRecoveryDisabledLanes&d)var y=0;else y=e.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){t=y;e:{var A=e;c=zl;var _=A.current.memoizedState.isDehydrated;if(_&&(Ba(A,y).flags|=256),y=pu(A,y,!1),y!==2){if(ou&&!_){A.errorRecoveryDisabledLanes|=d,Qs|=d,c=4;break e}d=Ht,Ht=c,d!==null&&(Ht===null?Ht=d:Ht.push.apply(Ht,d))}c=y}if(d=!1,c!==2)continue}}if(c===1){Ba(e,0),ys(e,t,0,!0);break}e:{switch(i=e,d=c,d){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ys(i,t,Qt,!xs);break e;case 2:Ht=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(c=hi+300-ne(),10<c)){if(ys(i,t,Qt,!xs),Cr(i,0,!0)!==0)break e;Qn=t,i.timeoutHandle=$p(fp.bind(null,i,s,Ht,xi,uu,t,Qt,Qs,Da,xs,d,"Throttled",-0,0),c);break e}fp(i,s,Ht,xi,uu,t,Qt,Qs,Da,xs,d,null,-0,0)}}break}while(!0);kn(e)}function fp(e,t,s,i,c,d,y,A,_,G,ee,se,F,J){if(e.timeoutHandle=-1,se=t.subtreeFlags,se&8192||(se&16785408)===16785408){se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Dn},ap(t,d,se);var ve=(d&62914560)===d?hi-ne():(d&4194048)===d?op-ne():0;if(ve=py(se,ve),ve!==null){Qn=d,e.cancelPendingCommit=ve(yp.bind(null,e,t,d,s,i,c,y,A,_,ee,se,null,F,J)),ys(e,d,y,!G);return}}yp(e,t,d,s,i,c,y,A,_)}function Tb(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var i=0;i<s.length;i++){var c=s[i],d=c.getSnapshot;c=c.value;try{if(!Gt(d(),c))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ys(e,t,s,i){t&=~cu,t&=~Qs,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var c=t;0<c;){var d=31-rt(c),y=1<<d;i[d]=-1,c&=~y}s!==0&&jf(e,s,t)}function gi(){return(Fe&6)===0?(Hl(0),!1):!0}function hu(){if(_e!==null){if(Qe===0)var e=_e.return;else e=_e,Ln=Us=null,Rc(e),Aa=null,jl=0,e=_e;for(;e!==null;)Gh(e.alternate,e),e=e.return;_e=null}}function Ba(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,Jb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Qn=0,hu(),et=e,_e=s=Bn(e.current,null),Le=t,Qe=0,Xt=null,xs=!1,qa=ll(e,t),ou=!1,Da=Qt=cu=Qs=gs=ut=0,Ht=zl=null,uu=!1,(t&8)!==0&&(t|=t&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=t;0<i;){var c=31-rt(i),d=1<<c;t|=e[c],i&=~d}return Xn=t,zr(),s}function mp(e,t){Te=null,B.H=Rl,t===wa||t===Ir?(t=Mm(),Qe=3):t===vc?(t=Mm(),Qe=4):Qe=t===Ic?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Xt=t,_e===null&&(ut=1,ri(e,rn(t,e.current)))}function hp(){var e=Ft.current;return e===null?!0:(Le&4194048)===Le?dn===null:(Le&62914560)===Le||(Le&536870912)!==0?e===dn:!1}function pp(){var e=B.H;return B.H=Rl,e===null?Rl:e}function xp(){var e=B.A;return B.A=Mb,e}function vi(){ut=4,xs||(Le&4194048)!==Le&&Ft.current!==null||(qa=!0),(gs&134217727)===0&&(Qs&134217727)===0||et===null||ys(et,Le,Qt,!1)}function pu(e,t,s){var i=Fe;Fe|=2;var c=pp(),d=xp();(et!==e||Le!==t)&&(xi=null,Ba(e,t)),t=!1;var y=ut;e:do try{if(Qe!==0&&_e!==null){var A=_e,_=Xt;switch(Qe){case 8:hu(),y=6;break e;case 3:case 2:case 9:case 6:Ft.current===null&&(t=!0);var G=Qe;if(Qe=0,Xt=null,Oa(e,A,_,G),s&&qa){y=0;break e}break;default:G=Qe,Qe=0,Xt=null,Oa(e,A,_,G)}}qb(),y=ut;break}catch(ee){mp(e,ee)}while(!0);return t&&e.shellSuspendCounter++,Ln=Us=null,Fe=i,B.H=c,B.A=d,_e===null&&(et=null,Le=0,zr()),y}function qb(){for(;_e!==null;)gp(_e)}function Db(e,t){var s=Fe;Fe|=2;var i=pp(),c=xp();et!==e||Le!==t?(xi=null,pi=ne()+500,Ba(e,t)):qa=ll(e,t);e:do try{if(Qe!==0&&_e!==null){t=_e;var d=Xt;t:switch(Qe){case 1:Qe=0,Xt=null,Oa(e,t,d,1);break;case 2:case 9:if(km(d)){Qe=0,Xt=null,vp(t);break}t=function(){Qe!==2&&Qe!==9||et!==e||(Qe=7),kn(e)},d.then(t,t);break e;case 3:Qe=7;break e;case 4:Qe=5;break e;case 7:km(d)?(Qe=0,Xt=null,vp(t)):(Qe=0,Xt=null,Oa(e,t,d,7));break;case 5:var y=null;switch(_e.tag){case 26:y=_e.memoizedState;case 5:case 27:var A=_e;if(y?s0(y):A.stateNode.complete){Qe=0,Xt=null;var _=A.sibling;if(_!==null)_e=_;else{var G=A.return;G!==null?(_e=G,bi(G)):_e=null}break t}}Qe=0,Xt=null,Oa(e,t,d,5);break;case 6:Qe=0,Xt=null,Oa(e,t,d,6);break;case 8:hu(),ut=6;break e;default:throw Error(o(462))}}_b();break}catch(ee){mp(e,ee)}while(!0);return Ln=Us=null,B.H=i,B.A=c,Fe=s,_e!==null?0:(et=null,Le=0,zr(),ut)}function _b(){for(;_e!==null&&!fe();)gp(_e)}function gp(e){var t=Vh(e.alternate,e,Xn);e.memoizedProps=e.pendingProps,t===null?bi(e):_e=t}function vp(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Bh(s,t,t.pendingProps,t.type,void 0,Le);break;case 11:t=Bh(s,t,t.pendingProps,t.type.render,t.ref,Le);break;case 5:Rc(t);default:Gh(s,t),t=_e=xm(t,Xn),t=Vh(s,t,Xn)}e.memoizedProps=e.pendingProps,t===null?bi(e):_e=t}function Oa(e,t,s,i){Ln=Us=null,Rc(t),Aa=null,jl=0;var c=t.return;try{if(jb(e,c,t,s,Le)){ut=1,ri(e,rn(s,e.current)),_e=null;return}}catch(d){if(c!==null)throw _e=c,d;ut=1,ri(e,rn(s,e.current)),_e=null;return}t.flags&32768?(Ue||i===1?e=!0:qa||(Le&536870912)!==0?e=!1:(xs=e=!0,(i===2||i===9||i===3||i===6)&&(i=Ft.current,i!==null&&i.tag===13&&(i.flags|=16384))),bp(t,e)):bi(t)}function bi(e){var t=e;do{if((t.flags&32768)!==0){bp(t,xs);return}e=t.return;var s=Ab(t.alternate,t,Xn);if(s!==null){_e=s;return}if(t=t.sibling,t!==null){_e=t;return}_e=t=e}while(t!==null);ut===0&&(ut=5)}function bp(e,t){do{var s=Cb(e.alternate,e);if(s!==null){s.flags&=32767,_e=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){_e=e;return}_e=e=s}while(e!==null);ut=6,_e=null}function yp(e,t,s,i,c,d,y,A,_){e.cancelPendingCommit=null;do yi();while(jt!==0);if((Fe&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(d=t.lanes|t.childLanes,d|=sc,mv(e,s,d,y,A,_),e===et&&(_e=et=null,Le=0),_a=t,bs=e,Qn=s,du=d,fu=c,cp=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,zb(tn,function(){return Ap(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=B.T,B.T=null,c=I.p,I.p=2,y=Fe,Fe|=4;try{kb(e,t,s)}finally{Fe=y,I.p=c,B.T=i}}jt=1,Sp(),jp(),Np()}}function Sp(){if(jt===1){jt=0;var e=bs,t=_a,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=B.T,B.T=null;var i=I.p;I.p=2;var c=Fe;Fe|=4;try{tp(t,e);var d=ku,y=im(e.containerInfo),A=d.focusedElem,_=d.selectionRange;if(y!==A&&A&&A.ownerDocument&&rm(A.ownerDocument.documentElement,A)){if(_!==null&&Po(A)){var G=_.start,ee=_.end;if(ee===void 0&&(ee=G),"selectionStart"in A)A.selectionStart=G,A.selectionEnd=Math.min(ee,A.value.length);else{var se=A.ownerDocument||document,F=se&&se.defaultView||window;if(F.getSelection){var J=F.getSelection(),ve=A.textContent.length,ke=Math.min(_.start,ve),We=_.end===void 0?ke:Math.min(_.end,ve);!J.extend&&ke>We&&(y=We,We=ke,ke=y);var H=lm(A,ke),z=lm(A,We);if(H&&z&&(J.rangeCount!==1||J.anchorNode!==H.node||J.anchorOffset!==H.offset||J.focusNode!==z.node||J.focusOffset!==z.offset)){var $=se.createRange();$.setStart(H.node,H.offset),J.removeAllRanges(),ke>We?(J.addRange($),J.extend(z.node,z.offset)):($.setEnd(z.node,z.offset),J.addRange($))}}}}for(se=[],J=A;J=J.parentNode;)J.nodeType===1&&se.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<se.length;A++){var te=se[A];te.element.scrollLeft=te.left,te.element.scrollTop=te.top}}qi=!!Cu,ku=Cu=null}finally{Fe=c,I.p=i,B.T=s}}e.current=t,jt=2}}function jp(){if(jt===2){jt=0;var e=bs,t=_a,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=B.T,B.T=null;var i=I.p;I.p=2;var c=Fe;Fe|=4;try{Zh(e,t.alternate,t)}finally{Fe=c,I.p=i,B.T=s}}jt=3}}function Np(){if(jt===4||jt===3){jt=0,Re();var e=bs,t=_a,s=Qn,i=cp;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?jt=5:(jt=0,_a=bs=null,wp(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(vs=null),Do(s),t=t.stateNode,Ee&&typeof Ee.onCommitFiberRoot=="function")try{Ee.onCommitFiberRoot(Xe,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=B.T,c=I.p,I.p=2,B.T=null;try{for(var d=e.onRecoverableError,y=0;y<i.length;y++){var A=i[y];d(A.value,{componentStack:A.stack})}}finally{B.T=t,I.p=c}}(Qn&3)!==0&&yi(),kn(e),c=e.pendingLanes,(s&261930)!==0&&(c&42)!==0?e===mu?Ul++:(Ul=0,mu=e):Ul=0,Hl(0)}}function wp(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,yl(t)))}function yi(){return Sp(),jp(),Np(),Ap()}function Ap(){if(jt!==5)return!1;var e=bs,t=du;du=0;var s=Do(Qn),i=B.T,c=I.p;try{I.p=32>s?32:s,B.T=null,s=fu,fu=null;var d=bs,y=Qn;if(jt=0,_a=bs=null,Qn=0,(Fe&6)!==0)throw Error(o(331));var A=Fe;if(Fe|=4,rp(d.current),sp(d,d.current,y,s),Fe=A,Hl(0,!1),Ee&&typeof Ee.onPostCommitFiberRoot=="function")try{Ee.onPostCommitFiberRoot(Xe,d)}catch{}return!0}finally{I.p=c,B.T=i,wp(e,t)}}function Cp(e,t,s){t=rn(s,t),t=Fc(e.stateNode,t,2),e=fs(e,t,2),e!==null&&(rl(e,2),kn(e))}function Ke(e,t,s){if(e.tag===3)Cp(e,e,s);else for(;t!==null;){if(t.tag===3){Cp(t,e,s);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(vs===null||!vs.has(i))){e=rn(s,e),s=kh(2),i=fs(t,s,2),i!==null&&(Eh(s,i,t,e),rl(i,2),kn(i));break}}t=t.return}}function xu(e,t,s){var i=e.pingCache;if(i===null){i=e.pingCache=new Rb;var c=new Set;i.set(t,c)}else c=i.get(t),c===void 0&&(c=new Set,i.set(t,c));c.has(s)||(ou=!0,c.add(s),e=Bb.bind(null,e,t,s),t.then(e,e))}function Bb(e,t,s){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,et===e&&(Le&s)===s&&(ut===4||ut===3&&(Le&62914560)===Le&&300>ne()-hi?(Fe&2)===0&&Ba(e,0):cu|=s,Da===Le&&(Da=0)),kn(e)}function kp(e,t){t===0&&(t=Sf()),e=Os(e,t),e!==null&&(rl(e,t),kn(e))}function Ob(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),kp(e,s)}function Lb(e,t){var s=0;switch(e.tag){case 31:case 13:var i=e.stateNode,c=e.memoizedState;c!==null&&(s=c.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(t),kp(e,s)}function zb(e,t){return re(e,t)}var Si=null,La=null,gu=!1,ji=!1,vu=!1,Ss=0;function kn(e){e!==La&&e.next===null&&(La===null?Si=La=e:La=La.next=e),ji=!0,gu||(gu=!0,Hb())}function Hl(e,t){if(!vu&&ji){vu=!0;do for(var s=!1,i=Si;i!==null;){if(e!==0){var c=i.pendingLanes;if(c===0)var d=0;else{var y=i.suspendedLanes,A=i.pingedLanes;d=(1<<31-rt(42|e)+1)-1,d&=c&~(y&~A),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(s=!0,Tp(i,d))}else d=Le,d=Cr(i,i===et?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(d&3)===0||ll(i,d)||(s=!0,Tp(i,d));i=i.next}while(s);vu=!1}}function Ub(){Ep()}function Ep(){ji=gu=!1;var e=0;Ss!==0&&Zb()&&(e=Ss);for(var t=ne(),s=null,i=Si;i!==null;){var c=i.next,d=Mp(i,t);d===0?(i.next=null,s===null?Si=c:s.next=c,c===null&&(La=s)):(s=i,(e!==0||(d&3)!==0)&&(ji=!0)),i=c}jt!==0&&jt!==5||Hl(e),Ss!==0&&(Ss=0)}function Mp(e,t){for(var s=e.suspendedLanes,i=e.pingedLanes,c=e.expirationTimes,d=e.pendingLanes&-62914561;0<d;){var y=31-rt(d),A=1<<y,_=c[y];_===-1?((A&s)===0||(A&i)!==0)&&(c[y]=fv(A,t)):_<=t&&(e.expiredLanes|=A),d&=~A}if(t=et,s=Le,s=Cr(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,s===0||e===t&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&de(i),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||ll(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(i!==null&&de(i),Do(s)){case 2:case 8:s=en;break;case 32:s=tn;break;case 268435456:s=Nt;break;default:s=tn}return i=Rp.bind(null,e),s=re(s,i),e.callbackPriority=t,e.callbackNode=s,t}return i!==null&&i!==null&&de(i),e.callbackPriority=2,e.callbackNode=null,2}function Rp(e,t){if(jt!==0&&jt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(yi()&&e.callbackNode!==s)return null;var i=Le;return i=Cr(e,e===et?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(dp(e,i,t),Mp(e,ne()),e.callbackNode!=null&&e.callbackNode===s?Rp.bind(null,e):null)}function Tp(e,t){if(yi())return null;dp(e,t,!0)}function Hb(){Pb(function(){(Fe&6)!==0?re(De,Ub):Ep()})}function bu(){if(Ss===0){var e=ja;e===0&&(e=Nn,Nn<<=1,(Nn&261888)===0&&(Nn=256)),Ss=e}return Ss}function qp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Rr(""+e)}function Dp(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function Vb(e,t,s,i,c){if(t==="submit"&&s&&s.stateNode===c){var d=qp((c[Bt]||null).action),y=i.submitter;y&&(t=(t=y[Bt]||null)?qp(t.formAction):y.getAttribute("formAction"),t!==null&&(d=t,y=null));var A=new _r("action","action",null,i,c);e.push({event:A,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ss!==0){var _=y?Dp(c,y):new FormData(c);Uc(s,{pending:!0,data:_,method:c.method,action:d},null,_)}}else typeof d=="function"&&(A.preventDefault(),_=y?Dp(c,y):new FormData(c),Uc(s,{pending:!0,data:_,method:c.method,action:d},d,_))},currentTarget:c}]})}}for(var yu=0;yu<nc.length;yu++){var Su=nc[yu],$b=Su.toLowerCase(),Gb=Su[0].toUpperCase()+Su.slice(1);gn($b,"on"+Gb)}gn(um,"onAnimationEnd"),gn(dm,"onAnimationIteration"),gn(fm,"onAnimationStart"),gn("dblclick","onDoubleClick"),gn("focusin","onFocus"),gn("focusout","onBlur"),gn(lb,"onTransitionRun"),gn(rb,"onTransitionStart"),gn(ib,"onTransitionCancel"),gn(mm,"onTransitionEnd"),oa("onMouseEnter",["mouseout","mouseover"]),oa("onMouseLeave",["mouseout","mouseover"]),oa("onPointerEnter",["pointerout","pointerover"]),oa("onPointerLeave",["pointerout","pointerover"]),qs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qs("onBeforeInput",["compositionend","keypress","textInput","paste"]),qs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vl="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(" "),Yb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Vl));function _p(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var i=e[s],c=i.event;i=i.listeners;e:{var d=void 0;if(t)for(var y=i.length-1;0<=y;y--){var A=i[y],_=A.instance,G=A.currentTarget;if(A=A.listener,_!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=G;try{d(c)}catch(ee){Lr(ee)}c.currentTarget=null,d=_}else for(y=0;y<i.length;y++){if(A=i[y],_=A.instance,G=A.currentTarget,A=A.listener,_!==d&&c.isPropagationStopped())break e;d=A,c.currentTarget=G;try{d(c)}catch(ee){Lr(ee)}c.currentTarget=null,d=_}}}}function Be(e,t){var s=t[_o];s===void 0&&(s=t[_o]=new Set);var i=e+"__bubble";s.has(i)||(Bp(t,e,2,!1),s.add(i))}function ju(e,t,s){var i=0;t&&(i|=4),Bp(s,e,i,t)}var Ni="_reactListening"+Math.random().toString(36).slice(2);function Nu(e){if(!e[Ni]){e[Ni]=!0,Ef.forEach(function(s){s!=="selectionchange"&&(Yb.has(s)||ju(s,!1,e),ju(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ni]||(t[Ni]=!0,ju("selectionchange",!1,t))}}function Bp(e,t,s,i){switch(u0(t)){case 2:var c=vy;break;case 8:c=by;break;default:c=zu}s=c.bind(null,t,s,e),c=void 0,!Go||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),i?c!==void 0?e.addEventListener(t,s,{capture:!0,passive:c}):e.addEventListener(t,s,!0):c!==void 0?e.addEventListener(t,s,{passive:c}):e.addEventListener(t,s,!1)}function wu(e,t,s,i,c){var d=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var y=i.tag;if(y===3||y===4){var A=i.stateNode.containerInfo;if(A===c)break;if(y===4)for(y=i.return;y!==null;){var _=y.tag;if((_===3||_===4)&&y.stateNode.containerInfo===c)return;y=y.return}for(;A!==null;){if(y=la(A),y===null)return;if(_=y.tag,_===5||_===6||_===26||_===27){i=d=y;continue e}A=A.parentNode}}i=i.return}Hf(function(){var G=d,ee=Vo(s),se=[];e:{var F=hm.get(e);if(F!==void 0){var J=_r,ve=e;switch(e){case"keypress":if(qr(s)===0)break e;case"keydown":case"keyup":J=Lv;break;case"focusin":ve="focus",J=Xo;break;case"focusout":ve="blur",J=Xo;break;case"beforeblur":case"afterblur":J=Xo;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=Gf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=Av;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=Hv;break;case um:case dm:case fm:J=Ev;break;case mm:J=$v;break;case"scroll":case"scrollend":J=Nv;break;case"wheel":J=Yv;break;case"copy":case"cut":case"paste":J=Rv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=Ff;break;case"toggle":case"beforetoggle":J=Iv}var ke=(t&4)!==0,We=!ke&&(e==="scroll"||e==="scrollend"),H=ke?F!==null?F+"Capture":null:F;ke=[];for(var z=G,$;z!==null;){var te=z;if($=te.stateNode,te=te.tag,te!==5&&te!==26&&te!==27||$===null||H===null||(te=cl(z,H),te!=null&&ke.push($l(z,te,$))),We)break;z=z.return}0<ke.length&&(F=new J(F,ve,null,s,ee),se.push({event:F,listeners:ke}))}}if((t&7)===0){e:{if(F=e==="mouseover"||e==="pointerover",J=e==="mouseout"||e==="pointerout",F&&s!==Ho&&(ve=s.relatedTarget||s.fromElement)&&(la(ve)||ve[aa]))break e;if((J||F)&&(F=ee.window===ee?ee:(F=ee.ownerDocument)?F.defaultView||F.parentWindow:window,J?(ve=s.relatedTarget||s.toElement,J=G,ve=ve?la(ve):null,ve!==null&&(We=f(ve),ke=ve.tag,ve!==We||ke!==5&&ke!==27&&ke!==6)&&(ve=null)):(J=null,ve=G),J!==ve)){if(ke=Gf,te="onMouseLeave",H="onMouseEnter",z="mouse",(e==="pointerout"||e==="pointerover")&&(ke=Ff,te="onPointerLeave",H="onPointerEnter",z="pointer"),We=J==null?F:ol(J),$=ve==null?F:ol(ve),F=new ke(te,z+"leave",J,s,ee),F.target=We,F.relatedTarget=$,te=null,la(ee)===G&&(ke=new ke(H,z+"enter",ve,s,ee),ke.target=$,ke.relatedTarget=We,te=ke),We=te,J&&ve)t:{for(ke=Fb,H=J,z=ve,$=0,te=H;te;te=ke(te))$++;te=0;for(var Ne=z;Ne;Ne=ke(Ne))te++;for(;0<$-te;)H=ke(H),$--;for(;0<te-$;)z=ke(z),te--;for(;$--;){if(H===z||z!==null&&H===z.alternate){ke=H;break t}H=ke(H),z=ke(z)}ke=null}else ke=null;J!==null&&Op(se,F,J,ke,!1),ve!==null&&We!==null&&Op(se,We,ve,ke,!0)}}e:{if(F=G?ol(G):window,J=F.nodeName&&F.nodeName.toLowerCase(),J==="select"||J==="input"&&F.type==="file")var Ge=Wf;else if(Jf(F))if(em)Ge=nb;else{Ge=eb;var ye=Wv}else J=F.nodeName,!J||J.toLowerCase()!=="input"||F.type!=="checkbox"&&F.type!=="radio"?G&&Uo(G.elementType)&&(Ge=Wf):Ge=tb;if(Ge&&(Ge=Ge(e,G))){Pf(se,Ge,s,ee);break e}ye&&ye(e,F,G),e==="focusout"&&G&&F.type==="number"&&G.memoizedProps.value!=null&&zo(F,"number",F.value)}switch(ye=G?ol(G):window,e){case"focusin":(Jf(ye)||ye.contentEditable==="true")&&(ha=ye,Wo=G,gl=null);break;case"focusout":gl=Wo=ha=null;break;case"mousedown":ec=!0;break;case"contextmenu":case"mouseup":case"dragend":ec=!1,om(se,s,ee);break;case"selectionchange":if(ab)break;case"keydown":case"keyup":om(se,s,ee)}var qe;if(Ko)e:{switch(e){case"compositionstart":var ze="onCompositionStart";break e;case"compositionend":ze="onCompositionEnd";break e;case"compositionupdate":ze="onCompositionUpdate";break e}ze=void 0}else ma?Kf(e,s)&&(ze="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(ze="onCompositionStart");ze&&(If&&s.locale!=="ko"&&(ma||ze!=="onCompositionStart"?ze==="onCompositionEnd"&&ma&&(qe=Vf()):(ls=ee,Yo="value"in ls?ls.value:ls.textContent,ma=!0)),ye=wi(G,ze),0<ye.length&&(ze=new Yf(ze,e,null,s,ee),se.push({event:ze,listeners:ye}),qe?ze.data=qe:(qe=Zf(s),qe!==null&&(ze.data=qe)))),(qe=Qv?Kv(e,s):Zv(e,s))&&(ze=wi(G,"onBeforeInput"),0<ze.length&&(ye=new Yf("onBeforeInput","beforeinput",null,s,ee),se.push({event:ye,listeners:ze}),ye.data=qe)),Vb(se,e,G,s,ee)}_p(se,t)})}function $l(e,t,s){return{instance:e,listener:t,currentTarget:s}}function wi(e,t){for(var s=t+"Capture",i=[];e!==null;){var c=e,d=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||d===null||(c=cl(e,s),c!=null&&i.unshift($l(e,c,d)),c=cl(e,t),c!=null&&i.push($l(e,c,d))),e.tag===3)return i;e=e.return}return[]}function Fb(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Op(e,t,s,i,c){for(var d=t._reactName,y=[];s!==null&&s!==i;){var A=s,_=A.alternate,G=A.stateNode;if(A=A.tag,_!==null&&_===i)break;A!==5&&A!==26&&A!==27||G===null||(_=G,c?(G=cl(s,d),G!=null&&y.unshift($l(s,G,_))):c||(G=cl(s,d),G!=null&&y.push($l(s,G,_)))),s=s.return}y.length!==0&&e.push({event:t,listeners:y})}var Ib=/\r\n?/g,Xb=/\u0000|\uFFFD/g;function Lp(e){return(typeof e=="string"?e:""+e).replace(Ib,`
|
||
`).replace(Xb,"")}function zp(e,t){return t=Lp(t),Lp(e)===t}function Pe(e,t,s,i,c,d){switch(s){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||ua(e,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&ua(e,""+i);break;case"className":Er(e,"class",i);break;case"tabIndex":Er(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Er(e,s,i);break;case"style":zf(e,i,d);break;case"data":if(t!=="object"){Er(e,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Rr(""+i),e.setAttribute(s,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(s==="formAction"?(t!=="input"&&Pe(e,t,"name",c.name,c,null),Pe(e,t,"formEncType",c.formEncType,c,null),Pe(e,t,"formMethod",c.formMethod,c,null),Pe(e,t,"formTarget",c.formTarget,c,null)):(Pe(e,t,"encType",c.encType,c,null),Pe(e,t,"method",c.method,c,null),Pe(e,t,"target",c.target,c,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(s);break}i=Rr(""+i),e.setAttribute(s,i);break;case"onClick":i!=null&&(e.onclick=Dn);break;case"onScroll":i!=null&&Be("scroll",e);break;case"onScrollEnd":i!=null&&Be("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}s=Rr(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""+i):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":i===!0?e.setAttribute(s,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(s,i):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(s,i):e.removeAttribute(s);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(s):e.setAttribute(s,i);break;case"popover":Be("beforetoggle",e),Be("toggle",e),kr(e,"popover",i);break;case"xlinkActuate":qn(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":qn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":qn(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":qn(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":qn(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":qn(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":qn(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":qn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":qn(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":kr(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=Sv.get(s)||s,kr(e,s,i))}}function Au(e,t,s,i,c,d){switch(s){case"style":zf(e,i,d);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(s=i.__html,s!=null){if(c.children!=null)throw Error(o(60));e.innerHTML=s}}break;case"children":typeof i=="string"?ua(e,i):(typeof i=="number"||typeof i=="bigint")&&ua(e,""+i);break;case"onScroll":i!=null&&Be("scroll",e);break;case"onScrollEnd":i!=null&&Be("scrollend",e);break;case"onClick":i!=null&&(e.onclick=Dn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Mf.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(c=s.endsWith("Capture"),t=s.slice(2,c?s.length-7:void 0),d=e[Bt]||null,d=d!=null?d[s]:null,typeof d=="function"&&e.removeEventListener(t,d,c),typeof i=="function")){typeof d!="function"&&d!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,i,c);break e}s in e?e[s]=i:i===!0?e.setAttribute(s,""):kr(e,s,i)}}}function Rt(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Be("error",e),Be("load",e);var i=!1,c=!1,d;for(d in s)if(s.hasOwnProperty(d)){var y=s[d];if(y!=null)switch(d){case"src":i=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,d,y,s,null)}}c&&Pe(e,t,"srcSet",s.srcSet,s,null),i&&Pe(e,t,"src",s.src,s,null);return;case"input":Be("invalid",e);var A=d=y=c=null,_=null,G=null;for(i in s)if(s.hasOwnProperty(i)){var ee=s[i];if(ee!=null)switch(i){case"name":c=ee;break;case"type":y=ee;break;case"checked":_=ee;break;case"defaultChecked":G=ee;break;case"value":d=ee;break;case"defaultValue":A=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,t));break;default:Pe(e,t,i,ee,s,null)}}_f(e,d,A,_,G,y,c,!1);return;case"select":Be("invalid",e),i=y=d=null;for(c in s)if(s.hasOwnProperty(c)&&(A=s[c],A!=null))switch(c){case"value":d=A;break;case"defaultValue":y=A;break;case"multiple":i=A;default:Pe(e,t,c,A,s,null)}t=d,s=y,e.multiple=!!i,t!=null?ca(e,!!i,t,!1):s!=null&&ca(e,!!i,s,!0);return;case"textarea":Be("invalid",e),d=c=i=null;for(y in s)if(s.hasOwnProperty(y)&&(A=s[y],A!=null))switch(y){case"value":i=A;break;case"defaultValue":c=A;break;case"children":d=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(o(91));break;default:Pe(e,t,y,A,s,null)}Of(e,i,c,d);return;case"option":for(_ in s)if(s.hasOwnProperty(_)&&(i=s[_],i!=null))switch(_){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Pe(e,t,_,i,s,null)}return;case"dialog":Be("beforetoggle",e),Be("toggle",e),Be("cancel",e),Be("close",e);break;case"iframe":case"object":Be("load",e);break;case"video":case"audio":for(i=0;i<Vl.length;i++)Be(Vl[i],e);break;case"image":Be("error",e),Be("load",e);break;case"details":Be("toggle",e);break;case"embed":case"source":case"link":Be("error",e),Be("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in s)if(s.hasOwnProperty(G)&&(i=s[G],i!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:Pe(e,t,G,i,s,null)}return;default:if(Uo(t)){for(ee in s)s.hasOwnProperty(ee)&&(i=s[ee],i!==void 0&&Au(e,t,ee,i,s,void 0));return}}for(A in s)s.hasOwnProperty(A)&&(i=s[A],i!=null&&Pe(e,t,A,i,s,null))}function Qb(e,t,s,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,d=null,y=null,A=null,_=null,G=null,ee=null;for(J in s){var se=s[J];if(s.hasOwnProperty(J)&&se!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":_=se;default:i.hasOwnProperty(J)||Pe(e,t,J,null,i,se)}}for(var F in i){var J=i[F];if(se=s[F],i.hasOwnProperty(F)&&(J!=null||se!=null))switch(F){case"type":d=J;break;case"name":c=J;break;case"checked":G=J;break;case"defaultChecked":ee=J;break;case"value":y=J;break;case"defaultValue":A=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(o(137,t));break;default:J!==se&&Pe(e,t,F,J,i,se)}}Lo(e,y,A,_,G,ee,d,c);return;case"select":J=y=A=F=null;for(d in s)if(_=s[d],s.hasOwnProperty(d)&&_!=null)switch(d){case"value":break;case"multiple":J=_;default:i.hasOwnProperty(d)||Pe(e,t,d,null,i,_)}for(c in i)if(d=i[c],_=s[c],i.hasOwnProperty(c)&&(d!=null||_!=null))switch(c){case"value":F=d;break;case"defaultValue":A=d;break;case"multiple":y=d;default:d!==_&&Pe(e,t,c,d,i,_)}t=A,s=y,i=J,F!=null?ca(e,!!s,F,!1):!!i!=!!s&&(t!=null?ca(e,!!s,t,!0):ca(e,!!s,s?[]:"",!1));return;case"textarea":J=F=null;for(A in s)if(c=s[A],s.hasOwnProperty(A)&&c!=null&&!i.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:Pe(e,t,A,null,i,c)}for(y in i)if(c=i[y],d=s[y],i.hasOwnProperty(y)&&(c!=null||d!=null))switch(y){case"value":F=c;break;case"defaultValue":J=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(o(91));break;default:c!==d&&Pe(e,t,y,c,i,d)}Bf(e,F,J);return;case"option":for(var ve in s)if(F=s[ve],s.hasOwnProperty(ve)&&F!=null&&!i.hasOwnProperty(ve))switch(ve){case"selected":e.selected=!1;break;default:Pe(e,t,ve,null,i,F)}for(_ in i)if(F=i[_],J=s[_],i.hasOwnProperty(_)&&F!==J&&(F!=null||J!=null))switch(_){case"selected":e.selected=F&&typeof F!="function"&&typeof F!="symbol";break;default:Pe(e,t,_,F,i,J)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ke in s)F=s[ke],s.hasOwnProperty(ke)&&F!=null&&!i.hasOwnProperty(ke)&&Pe(e,t,ke,null,i,F);for(G in i)if(F=i[G],J=s[G],i.hasOwnProperty(G)&&F!==J&&(F!=null||J!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(o(137,t));break;default:Pe(e,t,G,F,i,J)}return;default:if(Uo(t)){for(var We in s)F=s[We],s.hasOwnProperty(We)&&F!==void 0&&!i.hasOwnProperty(We)&&Au(e,t,We,void 0,i,F);for(ee in i)F=i[ee],J=s[ee],!i.hasOwnProperty(ee)||F===J||F===void 0&&J===void 0||Au(e,t,ee,F,i,J);return}}for(var H in s)F=s[H],s.hasOwnProperty(H)&&F!=null&&!i.hasOwnProperty(H)&&Pe(e,t,H,null,i,F);for(se in i)F=i[se],J=s[se],!i.hasOwnProperty(se)||F===J||F==null&&J==null||Pe(e,t,se,F,i,J)}function Up(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Kb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),i=0;i<s.length;i++){var c=s[i],d=c.transferSize,y=c.initiatorType,A=c.duration;if(d&&A&&Up(y)){for(y=0,A=c.responseEnd,i+=1;i<s.length;i++){var _=s[i],G=_.startTime;if(G>A)break;var ee=_.transferSize,se=_.initiatorType;ee&&Up(se)&&(_=_.responseEnd,y+=ee*(_<A?1:(A-G)/(_-G)))}if(--i,t+=8*(d+y)/(c.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Cu=null,ku=null;function Ai(e){return e.nodeType===9?e:e.ownerDocument}function Hp(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 Vp(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 Eu(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 Mu=null;function Zb(){var e=window.event;return e&&e.type==="popstate"?e===Mu?!1:(Mu=e,!0):(Mu=null,!1)}var $p=typeof setTimeout=="function"?setTimeout:void 0,Jb=typeof clearTimeout=="function"?clearTimeout:void 0,Gp=typeof Promise=="function"?Promise:void 0,Pb=typeof queueMicrotask=="function"?queueMicrotask:typeof Gp<"u"?function(e){return Gp.resolve(null).then(e).catch(Wb)}:$p;function Wb(e){setTimeout(function(){throw e})}function js(e){return e==="head"}function Yp(e,t){var s=t,i=0;do{var c=s.nextSibling;if(e.removeChild(s),c&&c.nodeType===8)if(s=c.data,s==="/$"||s==="/&"){if(i===0){e.removeChild(c),Va(t);return}i--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")i++;else if(s==="html")Gl(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,Gl(s);for(var d=s.firstChild;d;){var y=d.nextSibling,A=d.nodeName;d[il]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&d.rel.toLowerCase()==="stylesheet"||s.removeChild(d),d=y}}else s==="body"&&Gl(e.ownerDocument.body);s=c}while(s);Va(t)}function Fp(e,t){var s=e;e=0;do{var i=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=i}while(s)}function Ru(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":Ru(s),Bo(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function ey(e,t,s,i){for(;e.nodeType===1;){var c=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[il])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(d=e.getAttribute("rel"),d==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(d!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(d=e.getAttribute("src"),(d!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&d&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var d=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===d)return e}else return e;if(e=fn(e.nextSibling),e===null)break}return null}function ty(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=fn(e.nextSibling),e===null))return null;return e}function Ip(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=fn(e.nextSibling),e===null))return null;return e}function Tu(e){return e.data==="$?"||e.data==="$~"}function qu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function ny(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var i=function(){t(),s.removeEventListener("DOMContentLoaded",i)};s.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function fn(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 Du=null;function Xp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return fn(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function Qp(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function Kp(e,t,s){switch(t=Ai(s),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Gl(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Bo(e)}var mn=new Map,Zp=new Set;function Ci(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Kn=I.d;I.d={f:sy,r:ay,D:ly,C:ry,L:iy,m:oy,X:uy,S:cy,M:dy};function sy(){var e=Kn.f(),t=gi();return e||t}function ay(e){var t=ra(e);t!==null&&t.tag===5&&t.type==="form"?mh(t):Kn.r(e)}var za=typeof document>"u"?null:document;function Jp(e,t,s){var i=za;if(i&&typeof t=="string"&&t){var c=an(t);c='link[rel="'+e+'"][href="'+c+'"]',typeof s=="string"&&(c+='[crossorigin="'+s+'"]'),Zp.has(c)||(Zp.add(c),e={rel:e,crossOrigin:s,href:t},i.querySelector(c)===null&&(t=i.createElement("link"),Rt(t,"link",e),wt(t),i.head.appendChild(t)))}}function ly(e){Kn.D(e),Jp("dns-prefetch",e,null)}function ry(e,t){Kn.C(e,t),Jp("preconnect",e,t)}function iy(e,t,s){Kn.L(e,t,s);var i=za;if(i&&e&&t){var c='link[rel="preload"][as="'+an(t)+'"]';t==="image"&&s&&s.imageSrcSet?(c+='[imagesrcset="'+an(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(c+='[imagesizes="'+an(s.imageSizes)+'"]')):c+='[href="'+an(e)+'"]';var d=c;switch(t){case"style":d=Ua(e);break;case"script":d=Ha(e)}mn.has(d)||(e=b({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),mn.set(d,e),i.querySelector(c)!==null||t==="style"&&i.querySelector(Yl(d))||t==="script"&&i.querySelector(Fl(d))||(t=i.createElement("link"),Rt(t,"link",e),wt(t),i.head.appendChild(t)))}}function oy(e,t){Kn.m(e,t);var s=za;if(s&&e){var i=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+an(i)+'"][href="'+an(e)+'"]',d=c;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Ha(e)}if(!mn.has(d)&&(e=b({rel:"modulepreload",href:e},t),mn.set(d,e),s.querySelector(c)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Fl(d)))return}i=s.createElement("link"),Rt(i,"link",e),wt(i),s.head.appendChild(i)}}}function cy(e,t,s){Kn.S(e,t,s);var i=za;if(i&&e){var c=ia(i).hoistableStyles,d=Ua(e);t=t||"default";var y=c.get(d);if(!y){var A={loading:0,preload:null};if(y=i.querySelector(Yl(d)))A.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},s),(s=mn.get(d))&&_u(e,s);var _=y=i.createElement("link");wt(_),Rt(_,"link",e),_._p=new Promise(function(G,ee){_.onload=G,_.onerror=ee}),_.addEventListener("load",function(){A.loading|=1}),_.addEventListener("error",function(){A.loading|=2}),A.loading|=4,ki(y,t,i)}y={type:"stylesheet",instance:y,count:1,state:A},c.set(d,y)}}}function uy(e,t){Kn.X(e,t);var s=za;if(s&&e){var i=ia(s).hoistableScripts,c=Ha(e),d=i.get(c);d||(d=s.querySelector(Fl(c)),d||(e=b({src:e,async:!0},t),(t=mn.get(c))&&Bu(e,t),d=s.createElement("script"),wt(d),Rt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function dy(e,t){Kn.M(e,t);var s=za;if(s&&e){var i=ia(s).hoistableScripts,c=Ha(e),d=i.get(c);d||(d=s.querySelector(Fl(c)),d||(e=b({src:e,async:!0,type:"module"},t),(t=mn.get(c))&&Bu(e,t),d=s.createElement("script"),wt(d),Rt(d,"link",e),s.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},i.set(c,d))}}function Pp(e,t,s,i){var c=(c=we.current)?Ci(c):null;if(!c)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Ua(s.href),s=ia(c).hoistableStyles,i=s.get(t),i||(i={type:"style",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Ua(s.href);var d=ia(c).hoistableStyles,y=d.get(e);if(y||(c=c.ownerDocument||c,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(e,y),(d=c.querySelector(Yl(e)))&&!d._p&&(y.instance=d,y.state.loading=5),mn.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},mn.set(e,s),d||fy(c,e,s,y.state))),t&&i===null)throw Error(o(528,""));return y}if(t&&i!==null)throw Error(o(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ha(s),s=ia(c).hoistableScripts,i=s.get(t),i||(i={type:"script",instance:null,count:0,state:null},s.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Ua(e){return'href="'+an(e)+'"'}function Yl(e){return'link[rel="stylesheet"]['+e+"]"}function Wp(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function fy(e,t,s,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),Rt(t,"link",s),wt(t),e.head.appendChild(t))}function Ha(e){return'[src="'+an(e)+'"]'}function Fl(e){return"script[async]"+e}function e0(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+an(s.href)+'"]');if(i)return t.instance=i,wt(i),i;var c=b({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),wt(i),Rt(i,"style",c),ki(i,s.precedence,e),t.instance=i;case"stylesheet":c=Ua(s.href);var d=e.querySelector(Yl(c));if(d)return t.state.loading|=4,t.instance=d,wt(d),d;i=Wp(s),(c=mn.get(c))&&_u(i,c),d=(e.ownerDocument||e).createElement("link"),wt(d);var y=d;return y._p=new Promise(function(A,_){y.onload=A,y.onerror=_}),Rt(d,"link",i),t.state.loading|=4,ki(d,s.precedence,e),t.instance=d;case"script":return d=Ha(s.src),(c=e.querySelector(Fl(d)))?(t.instance=c,wt(c),c):(i=s,(c=mn.get(d))&&(i=b({},s),Bu(i,c)),e=e.ownerDocument||e,c=e.createElement("script"),wt(c),Rt(c,"link",i),e.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,ki(i,s.precedence,e));return t.instance}function ki(e,t,s){for(var i=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=i.length?i[i.length-1]:null,d=c,y=0;y<i.length;y++){var A=i[y];if(A.dataset.precedence===t)d=A;else if(d!==c)break}d?d.parentNode.insertBefore(e,d.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function _u(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Bu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Ei=null;function t0(e,t,s){if(Ei===null){var i=new Map,c=Ei=new Map;c.set(s,i)}else c=Ei,i=c.get(s),i||(i=new Map,c.set(s,i));if(i.has(e))return i;for(i.set(e,null),s=s.getElementsByTagName(e),c=0;c<s.length;c++){var d=s[c];if(!(d[il]||d[Ct]||e==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var y=d.getAttribute(t)||"";y=e+y;var A=i.get(y);A?A.push(d):i.set(y,[d])}}return i}function n0(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function my(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function s0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function hy(e,t,s,i){if(s.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var c=Ua(i.href),d=t.querySelector(Yl(c));if(d){t=d._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Mi.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=d,wt(d);return}d=t.ownerDocument||t,i=Wp(i),(c=mn.get(c))&&_u(i,c),d=d.createElement("link"),wt(d);var y=d;y._p=new Promise(function(A,_){y.onload=A,y.onerror=_}),Rt(d,"link",i),s.instance=d}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Mi.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var Ou=0;function py(e,t){return e.stylesheets&&e.count===0&&Ti(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var i=setTimeout(function(){if(e.stylesheets&&Ti(e,e.stylesheets),e.unsuspend){var d=e.unsuspend;e.unsuspend=null,d()}},6e4+t);0<e.imgBytes&&Ou===0&&(Ou=62500*Kb());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ti(e,e.stylesheets),e.unsuspend)){var d=e.unsuspend;e.unsuspend=null,d()}},(e.imgBytes>Ou?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(c)}}:null}function Mi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ti(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Ri=null;function Ti(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Ri=new Map,t.forEach(xy,e),Ri=null,Mi.call(e))}function xy(e,t){if(!(t.state.loading&4)){var s=Ri.get(e);if(s)var i=s.get(null);else{s=new Map,Ri.set(e,s);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<c.length;d++){var y=c[d];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(s.set(y.dataset.precedence,y),i=y)}i&&s.set(null,i)}c=t.instance,y=c.getAttribute("data-precedence"),d=s.get(y)||i,d===i&&s.set(null,c),s.set(y,c),this.count++,i=Mi.bind(this),c.addEventListener("load",i),c.addEventListener("error",i),d?d.parentNode.insertBefore(c,d.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),t.state.loading|=4}}var Il={$$typeof:k,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function gy(e,t,s,i,c,d,y,A,_){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=To(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=To(0),this.hiddenUpdates=To(null),this.identifierPrefix=i,this.onUncaughtError=c,this.onCaughtError=d,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_,this.incompleteTransitions=new Map}function a0(e,t,s,i,c,d,y,A,_,G,ee,se){return e=new gy(e,t,s,y,_,G,ee,se,A),t=1,d===!0&&(t|=24),d=Yt(3,null,null,t),e.current=d,d.stateNode=e,t=pc(),t.refCount++,e.pooledCache=t,t.refCount++,d.memoizedState={element:i,isDehydrated:s,cache:t},bc(d),e}function l0(e){return e?(e=ga,e):ga}function r0(e,t,s,i,c,d){c=l0(c),i.context===null?i.context=c:i.pendingContext=c,i=ds(t),i.payload={element:s},d=d===void 0?null:d,d!==null&&(i.callback=d),s=fs(e,i,t),s!==null&&(Vt(s,e,t),wl(s,e,t))}function i0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Lu(e,t){i0(e,t),(e=e.alternate)&&i0(e,t)}function o0(e){if(e.tag===13||e.tag===31){var t=Os(e,67108864);t!==null&&Vt(t,e,67108864),Lu(e,67108864)}}function c0(e){if(e.tag===13||e.tag===31){var t=Kt();t=qo(t);var s=Os(e,t);s!==null&&Vt(s,e,t),Lu(e,t)}}var qi=!0;function vy(e,t,s,i){var c=B.T;B.T=null;var d=I.p;try{I.p=2,zu(e,t,s,i)}finally{I.p=d,B.T=c}}function by(e,t,s,i){var c=B.T;B.T=null;var d=I.p;try{I.p=8,zu(e,t,s,i)}finally{I.p=d,B.T=c}}function zu(e,t,s,i){if(qi){var c=Uu(i);if(c===null)wu(e,t,i,Di,s),d0(e,i);else if(Sy(c,e,t,s,i))i.stopPropagation();else if(d0(e,i),t&4&&-1<yy.indexOf(e)){for(;c!==null;){var d=ra(c);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var y=Ts(d.pendingLanes);if(y!==0){var A=d;for(A.pendingLanes|=2,A.entangledLanes|=2;y;){var _=1<<31-rt(y);A.entanglements[1]|=_,y&=~_}kn(d),(Fe&6)===0&&(pi=ne()+500,Hl(0))}}break;case 31:case 13:A=Os(d,2),A!==null&&Vt(A,d,2),gi(),Lu(d,2)}if(d=Uu(i),d===null&&wu(e,t,i,Di,s),d===c)break;c=d}c!==null&&i.stopPropagation()}else wu(e,t,i,null,s)}}function Uu(e){return e=Vo(e),Hu(e)}var Di=null;function Hu(e){if(Di=null,e=la(e),e!==null){var t=f(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=p(t),e!==null)return e;e=null}else if(s===31){if(e=h(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Di=e,null}function u0(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(me()){case De:return 2;case en:return 8;case tn:case nn:return 32;case Nt:return 268435456;default:return 32}default:return 32}}var Vu=!1,Ns=null,ws=null,As=null,Xl=new Map,Ql=new Map,Cs=[],yy="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 d0(e,t){switch(e){case"focusin":case"focusout":Ns=null;break;case"dragenter":case"dragleave":ws=null;break;case"mouseover":case"mouseout":As=null;break;case"pointerover":case"pointerout":Xl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ql.delete(t.pointerId)}}function Kl(e,t,s,i,c,d){return e===null||e.nativeEvent!==d?(e={blockedOn:t,domEventName:s,eventSystemFlags:i,nativeEvent:d,targetContainers:[c]},t!==null&&(t=ra(t),t!==null&&o0(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),e)}function Sy(e,t,s,i,c){switch(t){case"focusin":return Ns=Kl(Ns,e,t,s,i,c),!0;case"dragenter":return ws=Kl(ws,e,t,s,i,c),!0;case"mouseover":return As=Kl(As,e,t,s,i,c),!0;case"pointerover":var d=c.pointerId;return Xl.set(d,Kl(Xl.get(d)||null,e,t,s,i,c)),!0;case"gotpointercapture":return d=c.pointerId,Ql.set(d,Kl(Ql.get(d)||null,e,t,s,i,c)),!0}return!1}function f0(e){var t=la(e.target);if(t!==null){var s=f(t);if(s!==null){if(t=s.tag,t===13){if(t=p(s),t!==null){e.blockedOn=t,Cf(e.priority,function(){c0(s)});return}}else if(t===31){if(t=h(s),t!==null){e.blockedOn=t,Cf(e.priority,function(){c0(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function _i(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=Uu(e.nativeEvent);if(s===null){s=e.nativeEvent;var i=new s.constructor(s.type,s);Ho=i,s.target.dispatchEvent(i),Ho=null}else return t=ra(s),t!==null&&o0(t),e.blockedOn=s,!1;t.shift()}return!0}function m0(e,t,s){_i(e)&&s.delete(t)}function jy(){Vu=!1,Ns!==null&&_i(Ns)&&(Ns=null),ws!==null&&_i(ws)&&(ws=null),As!==null&&_i(As)&&(As=null),Xl.forEach(m0),Ql.forEach(m0)}function Bi(e,t){e.blockedOn===t&&(e.blockedOn=null,Vu||(Vu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,jy)))}var Oi=null;function h0(e){Oi!==e&&(Oi=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Oi===e&&(Oi=null);for(var t=0;t<e.length;t+=3){var s=e[t],i=e[t+1],c=e[t+2];if(typeof i!="function"){if(Hu(i||s)===null)continue;break}var d=ra(s);d!==null&&(e.splice(t,3),t-=3,Uc(d,{pending:!0,data:c,method:s.method,action:i},i,c))}}))}function Va(e){function t(_){return Bi(_,e)}Ns!==null&&Bi(Ns,e),ws!==null&&Bi(ws,e),As!==null&&Bi(As,e),Xl.forEach(t),Ql.forEach(t);for(var s=0;s<Cs.length;s++){var i=Cs[s];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Cs.length&&(s=Cs[0],s.blockedOn===null);)f0(s),s.blockedOn===null&&Cs.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(i=0;i<s.length;i+=3){var c=s[i],d=s[i+1],y=c[Bt]||null;if(typeof d=="function")y||h0(s);else if(y){var A=null;if(d&&d.hasAttribute("formAction")){if(c=d,y=d[Bt]||null)A=y.formAction;else if(Hu(c)!==null)continue}else A=y.action;typeof A=="function"?s[i+1]=A:(s.splice(i,3),i-=3),h0(s)}}}function p0(){function e(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(y){return c=y})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),i||setTimeout(s,20)}function s(){if(!i&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function $u(e){this._internalRoot=e}Li.prototype.render=$u.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var s=t.current,i=Kt();r0(s,i,e,t,null,null)},Li.prototype.unmount=$u.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;r0(e.current,2,null,e,null,null),gi(),t[aa]=null}};function Li(e){this._internalRoot=e}Li.prototype.unstable_scheduleHydration=function(e){if(e){var t=Af();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Cs.length&&t!==0&&t<Cs[s].priority;s++);Cs.splice(s,0,e),s===0&&f0(e)}};var x0=a.version;if(x0!=="19.2.0")throw Error(o(527,x0,"19.2.0"));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=x(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var Ny={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zi.isDisabled&&zi.supportsFiber)try{Xe=zi.inject(Ny),Ee=zi}catch{}}return Jl.createRoot=function(e,t){if(!u(e))throw Error(o(299));var s=!1,i="",c=Nh,d=wh,y=Ah;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(d=t.onCaughtError),t.onRecoverableError!==void 0&&(y=t.onRecoverableError)),t=a0(e,1,!1,null,null,s,i,null,c,d,y,p0),e[aa]=t.current,Nu(e),new $u(t)},Jl.hydrateRoot=function(e,t,s){if(!u(e))throw Error(o(299));var i=!1,c="",d=Nh,y=wh,A=Ah,_=null;return s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(y=s.onCaughtError),s.onRecoverableError!==void 0&&(A=s.onRecoverableError),s.formState!==void 0&&(_=s.formState)),t=a0(e,1,!0,t,s??null,i,c,_,d,y,A,p0),t.context=l0(null),s=t.current,i=Kt(),i=qo(i),c=ds(i),c.callback=null,fs(s,c,i),s=i,t.current.lanes=s,rl(t,s),kn(t),e[aa]=t.current,Nu(e),new Li(t)},Jl.version="19.2.0",Jl}var C0;function _y(){if(C0)return Fu.exports;C0=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Fu.exports=Dy(),Fu.exports}var By=_y();var k0="popstate";function Oy(n={}){function a(o,u){let{pathname:f,search:p,hash:h}=o.location;return yd("",{pathname:f,search:p,hash:h},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function r(o,u){return typeof u=="string"?u:cr(u)}return zy(a,r,null,n)}function ot(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function jn(n,a){if(!n){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function Ly(){return Math.random().toString(36).substring(2,10)}function E0(n,a){return{usr:n.state,key:n.key,idx:a}}function yd(n,a,r=null,o){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof a=="string"?tl(a):a,state:r,key:a&&a.key||o||Ly()}}function cr({pathname:n="/",search:a="",hash:r=""}){return a&&a!=="?"&&(n+=a.charAt(0)==="?"?a:"?"+a),r&&r!=="#"&&(n+=r.charAt(0)==="#"?r:"#"+r),n}function tl(n){let a={};if(n){let r=n.indexOf("#");r>=0&&(a.hash=n.substring(r),n=n.substring(0,r));let o=n.indexOf("?");o>=0&&(a.search=n.substring(o),n=n.substring(0,o)),n&&(a.pathname=n)}return a}function zy(n,a,r,o={}){let{window:u=document.defaultView,v5Compat:f=!1}=o,p=u.history,h="POP",g=null,x=v();x==null&&(x=0,p.replaceState({...p.state,idx:x},""));function v(){return(p.state||{idx:null}).idx}function b(){h="POP";let w=v(),j=w==null?null:w-x;x=w,g&&g({action:h,location:N.location,delta:j})}function S(w,j){h="PUSH";let T=yd(N.location,w,j);x=v()+1;let k=E0(T,x),R=N.createHref(T);try{p.pushState(k,"",R)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;u.location.assign(R)}f&&g&&g({action:h,location:N.location,delta:1})}function C(w,j){h="REPLACE";let T=yd(N.location,w,j);x=v();let k=E0(T,x),R=N.createHref(T);p.replaceState(k,"",R),f&&g&&g({action:h,location:N.location,delta:0})}function E(w){return Uy(w)}let N={get action(){return h},get location(){return n(u,p)},listen(w){if(g)throw new Error("A history only accepts one active listener");return u.addEventListener(k0,b),g=w,()=>{u.removeEventListener(k0,b),g=null}},createHref(w){return a(u,w)},createURL:E,encodeLocation(w){let j=E(w);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:S,replace:C,go(w){return p.go(w)}};return N}function Uy(n,a=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),ot(r,"No window.location.(origin|href) available to create URL");let o=typeof n=="string"?n:cr(n);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=r+o),new URL(o,r)}function qx(n,a,r="/"){return Hy(n,a,r,!1)}function Hy(n,a,r,o){let u=typeof a=="string"?tl(a):a,f=ts(u.pathname||"/",r);if(f==null)return null;let p=Dx(n);Vy(p);let h=null;for(let g=0;h==null&&g<p.length;++g){let x=Py(f);h=Zy(p[g],x,o)}return h}function Dx(n,a=[],r=[],o="",u=!1){let f=(p,h,g=u,x)=>{let v={relativePath:x===void 0?p.path||"":x,caseSensitive:p.caseSensitive===!0,childrenIndex:h,route:p};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&g)return;ot(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let b=es([o,v.relativePath]),S=r.concat(v);p.children&&p.children.length>0&&(ot(p.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),Dx(p.children,a,S,b,g)),!(p.path==null&&!p.index)&&a.push({path:b,score:Qy(b,p.index),routesMeta:S})};return n.forEach((p,h)=>{if(p.path===""||!p.path?.includes("?"))f(p,h);else for(let g of _x(p.path))f(p,h,!0,g)}),a}function _x(n){let a=n.split("/");if(a.length===0)return[];let[r,...o]=a,u=r.endsWith("?"),f=r.replace(/\?$/,"");if(o.length===0)return u?[f,""]:[f];let p=_x(o.join("/")),h=[];return h.push(...p.map(g=>g===""?f:[f,g].join("/"))),u&&h.push(...p),h.map(g=>n.startsWith("/")&&g===""?"/":g)}function Vy(n){n.sort((a,r)=>a.score!==r.score?r.score-a.score:Ky(a.routesMeta.map(o=>o.childrenIndex),r.routesMeta.map(o=>o.childrenIndex)))}var $y=/^:[\w-]+$/,Gy=3,Yy=2,Fy=1,Iy=10,Xy=-2,M0=n=>n==="*";function Qy(n,a){let r=n.split("/"),o=r.length;return r.some(M0)&&(o+=Xy),a&&(o+=Yy),r.filter(u=>!M0(u)).reduce((u,f)=>u+($y.test(f)?Gy:f===""?Fy:Iy),o)}function Ky(n,a){return n.length===a.length&&n.slice(0,-1).every((o,u)=>o===a[u])?n[n.length-1]-a[a.length-1]:0}function Zy(n,a,r=!1){let{routesMeta:o}=n,u={},f="/",p=[];for(let h=0;h<o.length;++h){let g=o[h],x=h===o.length-1,v=f==="/"?a:a.slice(f.length)||"/",b=oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:x},v),S=g.route;if(!b&&x&&r&&!o[o.length-1].route.index&&(b=oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},v)),!b)return null;Object.assign(u,b.params),p.push({params:u,pathname:es([f,b.pathname]),pathnameBase:s1(es([f,b.pathnameBase])),route:S}),b.pathnameBase!=="/"&&(f=es([f,b.pathnameBase]))}return p}function oo(n,a){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[r,o]=Jy(n.path,n.caseSensitive,n.end),u=a.match(r);if(!u)return null;let f=u[0],p=f.replace(/(.)\/+$/,"$1"),h=u.slice(1);return{params:o.reduce((x,{paramName:v,isOptional:b},S)=>{if(v==="*"){let E=h[S]||"";p=f.slice(0,f.length-E.length).replace(/(.)\/+$/,"$1")}const C=h[S];return b&&!C?x[v]=void 0:x[v]=(C||"").replace(/%2F/g,"/"),x},{}),pathname:f,pathnameBase:p,pattern:n}}function Jy(n,a=!1,r=!0){jn(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],u="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(p,h,g)=>(o.push({paramName:h,isOptional:g!=null}),g?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),u+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?u+="\\/*$":n!==""&&n!=="/"&&(u+="(?:(?=\\/|$))"),[new RegExp(u,a?void 0:"i"),o]}function Py(n){try{return n.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return jn(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),n}}function ts(n,a){if(a==="/")return n;if(!n.toLowerCase().startsWith(a.toLowerCase()))return null;let r=a.endsWith("/")?a.length-1:a.length,o=n.charAt(r);return o&&o!=="/"?null:n.slice(r)||"/"}var Wy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,e1=n=>Wy.test(n);function t1(n,a="/"){let{pathname:r,search:o="",hash:u=""}=typeof n=="string"?tl(n):n,f;if(r)if(e1(r))f=r;else{if(r.includes("//")){let p=r;r=r.replace(/\/\/+/g,"/"),jn(!1,`Pathnames cannot have embedded double slashes - normalizing ${p} -> ${r}`)}r.startsWith("/")?f=R0(r.substring(1),"/"):f=R0(r,a)}else f=a;return{pathname:f,search:a1(o),hash:l1(u)}}function R0(n,a){let r=a.replace(/\/+$/,"").split("/");return n.split("/").forEach(u=>{u===".."?r.length>1&&r.pop():u!=="."&&r.push(u)}),r.length>1?r.join("/"):"/"}function Ku(n,a,r,o){return`Cannot include a '${n}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function n1(n){return n.filter((a,r)=>r===0||a.route.path&&a.route.path.length>0)}function Bx(n){let a=n1(n);return a.map((r,o)=>o===a.length-1?r.pathname:r.pathnameBase)}function Ox(n,a,r,o=!1){let u;typeof n=="string"?u=tl(n):(u={...n},ot(!u.pathname||!u.pathname.includes("?"),Ku("?","pathname","search",u)),ot(!u.pathname||!u.pathname.includes("#"),Ku("#","pathname","hash",u)),ot(!u.search||!u.search.includes("#"),Ku("#","search","hash",u)));let f=n===""||u.pathname==="",p=f?"/":u.pathname,h;if(p==null)h=r;else{let b=a.length-1;if(!o&&p.startsWith("..")){let S=p.split("/");for(;S[0]==="..";)S.shift(),b-=1;u.pathname=S.join("/")}h=b>=0?a[b]:"/"}let g=t1(u,h),x=p&&p!=="/"&&p.endsWith("/"),v=(f||p===".")&&r.endsWith("/");return!g.pathname.endsWith("/")&&(x||v)&&(g.pathname+="/"),g}var es=n=>n.join("/").replace(/\/\/+/g,"/"),s1=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),a1=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,l1=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function r1(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 Lx=["POST","PUT","PATCH","DELETE"];new Set(Lx);var i1=["GET",...Lx];new Set(i1);var nl=m.createContext(null);nl.displayName="DataRouter";var yo=m.createContext(null);yo.displayName="DataRouterState";m.createContext(!1);var zx=m.createContext({isTransitioning:!1});zx.displayName="ViewTransition";var o1=m.createContext(new Map);o1.displayName="Fetchers";var c1=m.createContext(null);c1.displayName="Await";var Tn=m.createContext(null);Tn.displayName="Navigation";var xr=m.createContext(null);xr.displayName="Location";var ss=m.createContext({outlet:null,matches:[],isDataRoute:!1});ss.displayName="Route";var Hd=m.createContext(null);Hd.displayName="RouteError";function u1(n,{relative:a}={}){ot(gr(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:o}=m.useContext(Tn),{hash:u,pathname:f,search:p}=vr(n,{relative:a}),h=f;return r!=="/"&&(h=f==="/"?r:es([r,f])),o.createHref({pathname:h,search:p,hash:u})}function gr(){return m.useContext(xr)!=null}function na(){return ot(gr(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(xr).location}var Ux="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Hx(n){m.useContext(Tn).static||m.useLayoutEffect(n)}function d1(){let{isDataRoute:n}=m.useContext(ss);return n?w1():f1()}function f1(){ot(gr(),"useNavigate() may be used only in the context of a <Router> component.");let n=m.useContext(nl),{basename:a,navigator:r}=m.useContext(Tn),{matches:o}=m.useContext(ss),{pathname:u}=na(),f=JSON.stringify(Bx(o)),p=m.useRef(!1);return Hx(()=>{p.current=!0}),m.useCallback((g,x={})=>{if(jn(p.current,Ux),!p.current)return;if(typeof g=="number"){r.go(g);return}let v=Ox(g,JSON.parse(f),u,x.relative==="path");n==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:es([a,v.pathname])),(x.replace?r.replace:r.push)(v,x.state,x)},[a,r,f,u,n])}m.createContext(null);function vr(n,{relative:a}={}){let{matches:r}=m.useContext(ss),{pathname:o}=na(),u=JSON.stringify(Bx(r));return m.useMemo(()=>Ox(n,JSON.parse(u),o,a==="path"),[n,u,o,a])}function m1(n,a){return Vx(n,a)}function Vx(n,a,r,o,u){ot(gr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:f}=m.useContext(Tn),{matches:p}=m.useContext(ss),h=p[p.length-1],g=h?h.params:{},x=h?h.pathname:"/",v=h?h.pathnameBase:"/",b=h&&h.route;{let T=b&&b.path||"";$x(x,!b||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${x}" (under <Route path="${T}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
||
|
||
Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let S=na(),C;if(a){let T=typeof a=="string"?tl(a):a;ot(v==="/"||T.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 "${T.pathname}" was given in the \`location\` prop.`),C=T}else C=S;let E=C.pathname||"/",N=E;if(v!=="/"){let T=v.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(T.length).join("/")}let w=qx(n,{pathname:N});jn(b||w!=null,`No routes matched location "${C.pathname}${C.search}${C.hash}" `),jn(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 "${C.pathname}${C.search}${C.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let j=v1(w&&w.map(T=>Object.assign({},T,{params:Object.assign({},g,T.params),pathname:es([v,f.encodeLocation?f.encodeLocation(T.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?v:es([v,f.encodeLocation?f.encodeLocation(T.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),p,r,o,u);return a&&j?m.createElement(xr.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...C},navigationType:"POP"}},j):j}function h1(){let n=N1(),a=r1(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),r=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",u={padding:"0.5rem",backgroundColor:o},f={padding:"2px 4px",backgroundColor:o},p=null;return console.error("Error handled by React Router default ErrorBoundary:",n),p=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:f},"ErrorBoundary")," or"," ",m.createElement("code",{style:f},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},a),r?m.createElement("pre",{style:u},r):null,p)}var p1=m.createElement(h1,null),x1=class extends m.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,a){return a.location!==n.location||a.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:a.error,location:a.location,revalidation:n.revalidation||a.revalidation}}componentDidCatch(n,a){this.props.onError?this.props.onError(n,a):console.error("React Router caught the following error during render",n)}render(){return this.state.error!==void 0?m.createElement(ss.Provider,{value:this.props.routeContext},m.createElement(Hd.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function g1({routeContext:n,match:a,children:r}){let o=m.useContext(nl);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(ss.Provider,{value:n},r)}function v1(n,a=[],r=null,o=null,u=null){if(n==null){if(!r)return null;if(r.errors)n=r.matches;else if(a.length===0&&!r.initialized&&r.matches.length>0)n=r.matches;else return null}let f=n,p=r?.errors;if(p!=null){let v=f.findIndex(b=>b.route.id&&p?.[b.route.id]!==void 0);ot(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(p).join(",")}`),f=f.slice(0,Math.min(f.length,v+1))}let h=!1,g=-1;if(r)for(let v=0;v<f.length;v++){let b=f[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(g=v),b.route.id){let{loaderData:S,errors:C}=r,E=b.route.loader&&!S.hasOwnProperty(b.route.id)&&(!C||C[b.route.id]===void 0);if(b.route.lazy||E){h=!0,g>=0?f=f.slice(0,g+1):f=[f[0]];break}}}let x=r&&o?(v,b)=>{o(v,{location:r.location,params:r.matches?.[0]?.params??{},errorInfo:b})}:void 0;return f.reduceRight((v,b,S)=>{let C,E=!1,N=null,w=null;r&&(C=p&&b.route.id?p[b.route.id]:void 0,N=b.route.errorElement||p1,h&&(g<0&&S===0?($x("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,w=null):g===S&&(E=!0,w=b.route.hydrateFallbackElement||null)));let j=a.concat(f.slice(0,S+1)),T=()=>{let k;return C?k=N:E?k=w:b.route.Component?k=m.createElement(b.route.Component,null):b.route.element?k=b.route.element:k=v,m.createElement(g1,{match:b,routeContext:{outlet:v,matches:j,isDataRoute:r!=null},children:k})};return r&&(b.route.ErrorBoundary||b.route.errorElement||S===0)?m.createElement(x1,{location:r.location,revalidation:r.revalidation,component:N,error:C,children:T(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:x}):T()},null)}function Vd(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function b1(n){let a=m.useContext(nl);return ot(a,Vd(n)),a}function y1(n){let a=m.useContext(yo);return ot(a,Vd(n)),a}function S1(n){let a=m.useContext(ss);return ot(a,Vd(n)),a}function $d(n){let a=S1(n),r=a.matches[a.matches.length-1];return ot(r.route.id,`${n} can only be used on routes that contain a unique "id"`),r.route.id}function j1(){return $d("useRouteId")}function N1(){let n=m.useContext(Hd),a=y1("useRouteError"),r=$d("useRouteError");return n!==void 0?n:a.errors?.[r]}function w1(){let{router:n}=b1("useNavigate"),a=$d("useNavigate"),r=m.useRef(!1);return Hx(()=>{r.current=!0}),m.useCallback(async(u,f={})=>{jn(r.current,Ux),r.current&&(typeof u=="number"?n.navigate(u):await n.navigate(u,{fromRouteId:a,...f}))},[n,a])}var T0={};function $x(n,a,r){!a&&!T0[n]&&(T0[n]=!0,jn(!1,r))}m.memo(A1);function A1({routes:n,future:a,state:r,unstable_onError:o}){return Vx(n,void 0,r,o,a)}function Zi(n){ot(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function C1({basename:n="/",children:a=null,location:r,navigationType:o="POP",navigator:u,static:f=!1}){ot(!gr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=n.replace(/^\/*/,"/"),h=m.useMemo(()=>({basename:p,navigator:u,static:f,future:{}}),[p,u,f]);typeof r=="string"&&(r=tl(r));let{pathname:g="/",search:x="",hash:v="",state:b=null,key:S="default"}=r,C=m.useMemo(()=>{let E=ts(g,p);return E==null?null:{location:{pathname:E,search:x,hash:v,state:b,key:S},navigationType:o}},[p,g,x,v,b,S,o]);return jn(C!=null,`<Router basename="${p}"> is not able to match the URL "${g}${x}${v}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:m.createElement(Tn.Provider,{value:h},m.createElement(xr.Provider,{children:a,value:C}))}function k1({children:n,location:a}){return m1(Sd(n),a)}function Sd(n,a=[]){let r=[];return m.Children.forEach(n,(o,u)=>{if(!m.isValidElement(o))return;let f=[...a,u];if(o.type===m.Fragment){r.push.apply(r,Sd(o.props.children,f));return}ot(o.type===Zi,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ot(!o.props.index||!o.props.children,"An index route cannot have child routes.");let p={id:o.props.id||f.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(p.children=Sd(o.props.children,f)),r.push(p)}),r}var Ji="get",Pi="application/x-www-form-urlencoded";function So(n){return n!=null&&typeof n.tagName=="string"}function E1(n){return So(n)&&n.tagName.toLowerCase()==="button"}function M1(n){return So(n)&&n.tagName.toLowerCase()==="form"}function R1(n){return So(n)&&n.tagName.toLowerCase()==="input"}function T1(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function q1(n,a){return n.button===0&&(!a||a==="_self")&&!T1(n)}var Ui=null;function D1(){if(Ui===null)try{new FormData(document.createElement("form"),0),Ui=!1}catch{Ui=!0}return Ui}var _1=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Zu(n){return n!=null&&!_1.has(n)?(jn(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Pi}"`),null):n}function B1(n,a){let r,o,u,f,p;if(M1(n)){let h=n.getAttribute("action");o=h?ts(h,a):null,r=n.getAttribute("method")||Ji,u=Zu(n.getAttribute("enctype"))||Pi,f=new FormData(n)}else if(E1(n)||R1(n)&&(n.type==="submit"||n.type==="image")){let h=n.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=n.getAttribute("formaction")||h.getAttribute("action");if(o=g?ts(g,a):null,r=n.getAttribute("formmethod")||h.getAttribute("method")||Ji,u=Zu(n.getAttribute("formenctype"))||Zu(h.getAttribute("enctype"))||Pi,f=new FormData(h,n),!D1()){let{name:x,type:v,value:b}=n;if(v==="image"){let S=x?`${x}.`:"";f.append(`${S}x`,"0"),f.append(`${S}y`,"0")}else x&&f.append(x,b)}}else{if(So(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Ji,o=null,u=Pi,p=n}return f&&u==="text/plain"&&(p=f,f=void 0),{action:o,method:r.toLowerCase(),encType:u,formData:f,body:p}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Gd(n,a){if(n===!1||n===null||typeof n>"u")throw new Error(a)}function O1(n,a,r){let o=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return o.pathname==="/"?o.pathname=`_root.${r}`:a&&ts(o.pathname,a)==="/"?o.pathname=`${a.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function L1(n,a){if(n.id in a)return a[n.id];try{let r=await import(n.module);return a[n.id]=r,r}catch(r){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function z1(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 U1(n,a,r){let o=await Promise.all(n.map(async u=>{let f=a.routes[u.route.id];if(f){let p=await L1(f,r);return p.links?p.links():[]}return[]}));return G1(o.flat(1).filter(z1).filter(u=>u.rel==="stylesheet"||u.rel==="preload").map(u=>u.rel==="stylesheet"?{...u,rel:"prefetch",as:"style"}:{...u,rel:"prefetch"}))}function q0(n,a,r,o,u,f){let p=(g,x)=>r[x]?g.route.id!==r[x].route.id:!0,h=(g,x)=>r[x].pathname!==g.pathname||r[x].route.path?.endsWith("*")&&r[x].params["*"]!==g.params["*"];return f==="assets"?a.filter((g,x)=>p(g,x)||h(g,x)):f==="data"?a.filter((g,x)=>{let v=o.routes[g.route.id];if(!v||!v.hasLoader)return!1;if(p(g,x)||h(g,x))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(u.pathname+u.search+u.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(n,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function H1(n,a,{includeHydrateFallback:r}={}){return V1(n.map(o=>{let u=a.routes[o.route.id];if(!u)return[];let f=[u.module];return u.clientActionModule&&(f=f.concat(u.clientActionModule)),u.clientLoaderModule&&(f=f.concat(u.clientLoaderModule)),r&&u.hydrateFallbackModule&&(f=f.concat(u.hydrateFallbackModule)),u.imports&&(f=f.concat(u.imports)),f}).flat(1))}function V1(n){return[...new Set(n)]}function $1(n){let a={},r=Object.keys(n).sort();for(let o of r)a[o]=n[o];return a}function G1(n,a){let r=new Set;return new Set(a),n.reduce((o,u)=>{let f=JSON.stringify($1(u));return r.has(f)||(r.add(f),o.push({key:f,link:u})),o},[])}function Gx(){let n=m.useContext(nl);return Gd(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function Y1(){let n=m.useContext(yo);return Gd(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Yd=m.createContext(void 0);Yd.displayName="FrameworkContext";function Yx(){let n=m.useContext(Yd);return Gd(n,"You must render this element inside a <HydratedRouter> element"),n}function F1(n,a){let r=m.useContext(Yd),[o,u]=m.useState(!1),[f,p]=m.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:x,onMouseLeave:v,onTouchStart:b}=a,S=m.useRef(null);m.useEffect(()=>{if(n==="render"&&p(!0),n==="viewport"){let N=j=>{j.forEach(T=>{p(T.isIntersecting)})},w=new IntersectionObserver(N,{threshold:.5});return S.current&&w.observe(S.current),()=>{w.disconnect()}}},[n]),m.useEffect(()=>{if(o){let N=setTimeout(()=>{p(!0)},100);return()=>{clearTimeout(N)}}},[o]);let C=()=>{u(!0)},E=()=>{u(!1),p(!1)};return r?n!=="intent"?[f,S,{}]:[f,S,{onFocus:Pl(h,C),onBlur:Pl(g,E),onMouseEnter:Pl(x,C),onMouseLeave:Pl(v,E),onTouchStart:Pl(b,C)}]:[!1,S,{}]}function Pl(n,a){return r=>{n&&n(r),r.defaultPrevented||a(r)}}function I1({page:n,...a}){let{router:r}=Gx(),o=m.useMemo(()=>qx(r.routes,n,r.basename),[r.routes,n,r.basename]);return o?m.createElement(Q1,{page:n,matches:o,...a}):null}function X1(n){let{manifest:a,routeModules:r}=Yx(),[o,u]=m.useState([]);return m.useEffect(()=>{let f=!1;return U1(n,a,r).then(p=>{f||u(p)}),()=>{f=!0}},[n,a,r]),o}function Q1({page:n,matches:a,...r}){let o=na(),{manifest:u,routeModules:f}=Yx(),{basename:p}=Gx(),{loaderData:h,matches:g}=Y1(),x=m.useMemo(()=>q0(n,a,g,u,o,"data"),[n,a,g,u,o]),v=m.useMemo(()=>q0(n,a,g,u,o,"assets"),[n,a,g,u,o]),b=m.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let E=new Set,N=!1;if(a.forEach(j=>{let T=u.routes[j.route.id];!T||!T.hasLoader||(!x.some(k=>k.route.id===j.route.id)&&j.route.id in h&&f[j.route.id]?.shouldRevalidate||T.hasClientLoader?N=!0:E.add(j.route.id))}),E.size===0)return[];let w=O1(n,p,"data");return N&&E.size>0&&w.searchParams.set("_routes",a.filter(j=>E.has(j.route.id)).map(j=>j.route.id).join(",")),[w.pathname+w.search]},[p,h,o,u,x,a,n,f]),S=m.useMemo(()=>H1(v,u),[v,u]),C=X1(v);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...r})),S.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...r})),C.map(({key:E,link:N})=>m.createElement("link",{key:E,nonce:r.nonce,...N})))}function K1(...n){return a=>{n.forEach(r=>{typeof r=="function"?r(a):r!=null&&(r.current=a)})}}var Fx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Fx&&(window.__reactRouterVersion="7.9.6")}catch{}function Z1({basename:n,children:a,window:r}){let o=m.useRef();o.current==null&&(o.current=Oy({window:r,v5Compat:!0}));let u=o.current,[f,p]=m.useState({action:u.action,location:u.location}),h=m.useCallback(g=>{m.startTransition(()=>p(g))},[p]);return m.useLayoutEffect(()=>u.listen(h),[u,h]),m.createElement(C1,{basename:n,children:a,location:f.location,navigationType:f.action,navigator:u})}var Ix=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Xx=m.forwardRef(function({onClick:a,discover:r="render",prefetch:o="none",relative:u,reloadDocument:f,replace:p,state:h,target:g,to:x,preventScrollReset:v,viewTransition:b,...S},C){let{basename:E}=m.useContext(Tn),N=typeof x=="string"&&Ix.test(x),w,j=!1;if(typeof x=="string"&&N&&(w=x,Fx))try{let Y=new URL(window.location.href),U=x.startsWith("//")?new URL(Y.protocol+x):new URL(x),X=ts(U.pathname,E);U.origin===Y.origin&&X!=null?x=X+U.search+U.hash:j=!0}catch{jn(!1,`<Link to="${x}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=u1(x,{relative:u}),[k,R,D]=F1(o,S),V=eS(x,{replace:p,state:h,target:g,preventScrollReset:v,relative:u,viewTransition:b});function O(Y){a&&a(Y),Y.defaultPrevented||V(Y)}let L=m.createElement("a",{...S,...D,href:w||T,onClick:j||f?a:O,ref:K1(C,R),target:g,"data-discover":!N&&r==="render"?"true":void 0});return k&&!N?m.createElement(m.Fragment,null,L,m.createElement(I1,{page:T})):L});Xx.displayName="Link";var J1=m.forwardRef(function({"aria-current":a="page",caseSensitive:r=!1,className:o="",end:u=!1,style:f,to:p,viewTransition:h,children:g,...x},v){let b=vr(p,{relative:x.relative}),S=na(),C=m.useContext(yo),{navigator:E,basename:N}=m.useContext(Tn),w=C!=null&&lS(b)&&h===!0,j=E.encodeLocation?E.encodeLocation(b).pathname:b.pathname,T=S.pathname,k=C&&C.navigation&&C.navigation.location?C.navigation.location.pathname:null;r||(T=T.toLowerCase(),k=k?k.toLowerCase():null,j=j.toLowerCase()),k&&N&&(k=ts(k,N)||k);const R=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let D=T===j||!u&&T.startsWith(j)&&T.charAt(R)==="/",V=k!=null&&(k===j||!u&&k.startsWith(j)&&k.charAt(j.length)==="/"),O={isActive:D,isPending:V,isTransitioning:w},L=D?a:void 0,Y;typeof o=="function"?Y=o(O):Y=[o,D?"active":null,V?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let U=typeof f=="function"?f(O):f;return m.createElement(Xx,{...x,"aria-current":L,className:Y,ref:v,style:U,to:p,viewTransition:h},typeof g=="function"?g(O):g)});J1.displayName="NavLink";var P1=m.forwardRef(({discover:n="render",fetcherKey:a,navigate:r,reloadDocument:o,replace:u,state:f,method:p=Ji,action:h,onSubmit:g,relative:x,preventScrollReset:v,viewTransition:b,...S},C)=>{let E=sS(),N=aS(h,{relative:x}),w=p.toLowerCase()==="get"?"get":"post",j=typeof h=="string"&&Ix.test(h),T=k=>{if(g&&g(k),k.defaultPrevented)return;k.preventDefault();let R=k.nativeEvent.submitter,D=R?.getAttribute("formmethod")||p;E(R||k.currentTarget,{fetcherKey:a,method:D,navigate:r,replace:u,state:f,relative:x,preventScrollReset:v,viewTransition:b})};return m.createElement("form",{ref:C,method:w,action:N,onSubmit:o?g:T,...S,"data-discover":!j&&n==="render"?"true":void 0})});P1.displayName="Form";function W1(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qx(n){let a=m.useContext(nl);return ot(a,W1(n)),a}function eS(n,{target:a,replace:r,state:o,preventScrollReset:u,relative:f,viewTransition:p}={}){let h=d1(),g=na(),x=vr(n,{relative:f});return m.useCallback(v=>{if(q1(v,a)){v.preventDefault();let b=r!==void 0?r:cr(g)===cr(x);h(n,{replace:b,state:o,preventScrollReset:u,relative:f,viewTransition:p})}},[g,h,x,r,o,a,n,u,f,p])}var tS=0,nS=()=>`__${String(++tS)}__`;function sS(){let{router:n}=Qx("useSubmit"),{basename:a}=m.useContext(Tn),r=j1();return m.useCallback(async(o,u={})=>{let{action:f,method:p,encType:h,formData:g,body:x}=B1(o,a);if(u.navigate===!1){let v=u.fetcherKey||nS();await n.fetch(v,r,u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync})}else await n.navigate(u.action||f,{preventScrollReset:u.preventScrollReset,formData:g,body:x,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:r,flushSync:u.flushSync,viewTransition:u.viewTransition})},[n,a,r])}function aS(n,{relative:a}={}){let{basename:r}=m.useContext(Tn),o=m.useContext(ss);ot(o,"useFormAction must be used inside a RouteContext");let[u]=o.matches.slice(-1),f={...vr(n||".",{relative:a})},p=na();if(n==null){f.search=p.search;let h=new URLSearchParams(f.search),g=h.getAll("index");if(g.some(v=>v==="")){h.delete("index"),g.filter(b=>b).forEach(b=>h.append("index",b));let v=h.toString();f.search=v?`?${v}`:""}}return(!n||n===".")&&u.route.index&&(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(f.pathname=f.pathname==="/"?r:es([r,f.pathname])),cr(f)}function lS(n,{relative:a}={}){let r=m.useContext(zx);ot(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Qx("useViewTransitionState"),u=vr(n,{relative:a});if(!r.isTransitioning)return!1;let f=ts(r.currentLocation.pathname,o)||r.currentLocation.pathname,p=ts(r.nextLocation.pathname,o)||r.nextLocation.pathname;return oo(u.pathname,p)!=null||oo(u.pathname,f)!=null}const Rn=Object.create(null);Rn.open="0";Rn.close="1";Rn.ping="2";Rn.pong="3";Rn.message="4";Rn.upgrade="5";Rn.noop="6";const Wi=Object.create(null);Object.keys(Rn).forEach(n=>{Wi[Rn[n]]=n});const jd={type:"error",data:"parser error"},Kx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Zx=typeof ArrayBuffer=="function",Jx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Fd=({type:n,data:a},r,o)=>Kx&&a instanceof Blob?r?o(a):D0(a,o):Zx&&(a instanceof ArrayBuffer||Jx(a))?r?o(a):D0(new Blob([a]),o):o(Rn[n]+(a||"")),D0=(n,a)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];a("b"+(o||""))},r.readAsDataURL(n)};function _0(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Ju;function rS(n,a){if(Kx&&n.data instanceof Blob)return n.data.arrayBuffer().then(_0).then(a);if(Zx&&(n.data instanceof ArrayBuffer||Jx(n.data)))return a(_0(n.data));Fd(n,!1,r=>{Ju||(Ju=new TextEncoder),a(Ju.encode(r))})}const B0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ar=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<B0.length;n++)ar[B0.charCodeAt(n)]=n;const iS=n=>{let a=n.length*.75,r=n.length,o,u=0,f,p,h,g;n[n.length-1]==="="&&(a--,n[n.length-2]==="="&&a--);const x=new ArrayBuffer(a),v=new Uint8Array(x);for(o=0;o<r;o+=4)f=ar[n.charCodeAt(o)],p=ar[n.charCodeAt(o+1)],h=ar[n.charCodeAt(o+2)],g=ar[n.charCodeAt(o+3)],v[u++]=f<<2|p>>4,v[u++]=(p&15)<<4|h>>2,v[u++]=(h&3)<<6|g&63;return x},oS=typeof ArrayBuffer=="function",Id=(n,a)=>{if(typeof n!="string")return{type:"message",data:Px(n,a)};const r=n.charAt(0);return r==="b"?{type:"message",data:cS(n.substring(1),a)}:Wi[r]?n.length>1?{type:Wi[r],data:n.substring(1)}:{type:Wi[r]}:jd},cS=(n,a)=>{if(oS){const r=iS(n);return Px(r,a)}else return{base64:!0,data:n}},Px=(n,a)=>{switch(a){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Wx="",uS=(n,a)=>{const r=n.length,o=new Array(r);let u=0;n.forEach((f,p)=>{Fd(f,!1,h=>{o[p]=h,++u===r&&a(o.join(Wx))})})},dS=(n,a)=>{const r=n.split(Wx),o=[];for(let u=0;u<r.length;u++){const f=Id(r[u],a);if(o.push(f),f.type==="error")break}return o};function fS(){return new TransformStream({transform(n,a){rS(n,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const f=new DataView(u.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{u=new Uint8Array(9);const f=new DataView(u.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(u[0]|=128),a.enqueue(u),a.enqueue(r)})}})}let Pu;function Hi(n){return n.reduce((a,r)=>a+r.length,0)}function Vi(n,a){if(n[0].length===a)return n.shift();const r=new Uint8Array(a);let o=0;for(let u=0;u<a;u++)r[u]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function mS(n,a){Pu||(Pu=new TextDecoder);const r=[];let o=0,u=-1,f=!1;return new TransformStream({transform(p,h){for(r.push(p);;){if(o===0){if(Hi(r)<1)break;const g=Vi(r,1);f=(g[0]&128)===128,u=g[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Hi(r)<2)break;const g=Vi(r,2);u=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(Hi(r)<8)break;const g=Vi(r,8),x=new DataView(g.buffer,g.byteOffset,g.length),v=x.getUint32(0);if(v>Math.pow(2,21)-1){h.enqueue(jd);break}u=v*Math.pow(2,32)+x.getUint32(4),o=3}else{if(Hi(r)<u)break;const g=Vi(r,u);h.enqueue(Id(f?g:Pu.decode(g),a)),o=0}if(u===0||u>n){h.enqueue(jd);break}}}})}const eg=4;function bt(n){if(n)return hS(n)}function hS(n){for(var a in bt.prototype)n[a]=bt.prototype[a];return n}bt.prototype.on=bt.prototype.addEventListener=function(n,a){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(a),this};bt.prototype.once=function(n,a){function r(){this.off(n,r),a.apply(this,arguments)}return r.fn=a,this.on(n,r),this};bt.prototype.off=bt.prototype.removeListener=bt.prototype.removeAllListeners=bt.prototype.removeEventListener=function(n,a){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,u=0;u<r.length;u++)if(o=r[u],o===a||o.fn===a){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+n],this};bt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var a=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)a[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,u=r.length;o<u;++o)r[o].apply(this,a)}return this};bt.prototype.emitReserved=bt.prototype.emit;bt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};bt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const jo=typeof Promise=="function"&&typeof Promise.resolve=="function"?a=>Promise.resolve().then(a):(a,r)=>r(a,0),xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),pS="arraybuffer";function tg(n,...a){return a.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const xS=xn.setTimeout,gS=xn.clearTimeout;function No(n,a){a.useNativeTimers?(n.setTimeoutFn=xS.bind(xn),n.clearTimeoutFn=gS.bind(xn)):(n.setTimeoutFn=xn.setTimeout.bind(xn),n.clearTimeoutFn=xn.clearTimeout.bind(xn))}const vS=1.33;function bS(n){return typeof n=="string"?yS(n):Math.ceil((n.byteLength||n.size)*vS)}function yS(n){let a=0,r=0;for(let o=0,u=n.length;o<u;o++)a=n.charCodeAt(o),a<128?r+=1:a<2048?r+=2:a<55296||a>=57344?r+=3:(o++,r+=4);return r}function ng(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function SS(n){let a="";for(let r in n)n.hasOwnProperty(r)&&(a.length&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return a}function jS(n){let a={},r=n.split("&");for(let o=0,u=r.length;o<u;o++){let f=r[o].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return a}class NS extends Error{constructor(a,r,o){super(a),this.description=r,this.context=o,this.type="TransportError"}}class Xd extends bt{constructor(a){super(),this.writable=!1,No(this,a),this.opts=a,this.query=a.query,this.socket=a.socket,this.supportsBinary=!a.forceBase64}onError(a,r,o){return super.emitReserved("error",new NS(a,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(a){this.readyState==="open"&&this.write(a)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(a){const r=Id(a,this.socket.binaryType);this.onPacket(r)}onPacket(a){super.emitReserved("packet",a)}onClose(a){this.readyState="closed",super.emitReserved("close",a)}pause(a){}createUri(a,r={}){return a+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const a=this.opts.hostname;return a.indexOf(":")===-1?a:"["+a+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(a){const r=SS(a);return r.length?"?"+r:""}}class wS extends Xd{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(a){this.readyState="pausing";const r=()=>{this.readyState="paused",a()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(a){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};dS(a,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const a=()=>{this.write([{type:"close"}])};this.readyState==="open"?a():this.once("open",a)}write(a){this.writable=!1,uS(a,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const a=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=ng()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(a,r)}}let sg=!1;try{sg=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const AS=sg;function CS(){}class kS extends wS{constructor(a){if(super(a),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&a.hostname!==location.hostname||o!==a.port}}doWrite(a,r){const o=this.request({method:"POST",data:a});o.on("success",r),o.on("error",(u,f)=>{this.onError("xhr post error",u,f)})}doPoll(){const a=this.request();a.on("data",this.onData.bind(this)),a.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=a}}class Mn extends bt{constructor(a,r,o){super(),this.createRequest=a,No(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var a;const r=tg(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(a=this._opts.cookieJar)===null||a===void 0||a.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=Mn.requestsCount++,Mn.requests[this._index]=this)}_onError(a){this.emitReserved("error",a,this._xhr),this._cleanup(!0)}_cleanup(a){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=CS,a)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Mn.requests[this._index],this._xhr=null}}_onLoad(){const a=this._xhr.responseText;a!==null&&(this.emitReserved("data",a),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Mn.requestsCount=0;Mn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",O0);else if(typeof addEventListener=="function"){const n="onpagehide"in xn?"pagehide":"unload";addEventListener(n,O0,!1)}}function O0(){for(let n in Mn.requests)Mn.requests.hasOwnProperty(n)&&Mn.requests[n].abort()}const ES=(function(){const n=ag({xdomain:!1});return n&&n.responseType!==null})();class MS extends kS{constructor(a){super(a);const r=a&&a.forceBase64;this.supportsBinary=ES&&!r}request(a={}){return Object.assign(a,{xd:this.xd},this.opts),new Mn(ag,this.uri(),a)}}function ag(n){const a=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!a||AS))return new XMLHttpRequest}catch{}if(!a)try{return new xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const lg=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class RS extends Xd{get name(){return"websocket"}doOpen(){const a=this.uri(),r=this.opts.protocols,o=lg?{}:tg(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(a,r,o)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=a=>this.onClose({description:"websocket connection closed",context:a}),this.ws.onmessage=a=>this.onData(a.data),this.ws.onerror=a=>this.onError("websocket error",a)}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;Fd(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}u&&jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const a=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=ng()),this.supportsBinary||(r.b64=1),this.createUri(a,r)}}const Wu=xn.WebSocket||xn.MozWebSocket;class TS extends RS{createSocket(a,r,o){return lg?new Wu(a,r,o):r?new Wu(a,r):new Wu(a)}doWrite(a,r){this.ws.send(r)}}class qS extends Xd{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(a){return this.emitReserved("error",a)}this._transport.closed.then(()=>{this.onClose()}).catch(a=>{this.onError("webtransport error",a)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(a=>{const r=mS(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=a.readable.pipeThrough(r).getReader(),u=fS();u.readable.pipeTo(a.writable),this._writer=u.writable.getWriter();const f=()=>{o.read().then(({done:h,value:g})=>{h||(this.onPacket(g),f())}).catch(h=>{})};f();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(a){this.writable=!1;for(let r=0;r<a.length;r++){const o=a[r],u=r===a.length-1;this._writer.write(o).then(()=>{u&&jo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var a;(a=this._transport)===null||a===void 0||a.close()}}const DS={websocket:TS,webtransport:qS,polling:MS},_S=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,BS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Nd(n){if(n.length>8e3)throw"URI too long";const a=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let u=_S.exec(n||""),f={},p=14;for(;p--;)f[BS[p]]=u[p]||"";return r!=-1&&o!=-1&&(f.source=a,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=OS(f,f.path),f.queryKey=LS(f,f.query),f}function OS(n,a){const r=/\/{2,9}/g,o=a.replace(r,"/").split("/");return(a.slice(0,1)=="/"||a.length===0)&&o.splice(0,1),a.slice(-1)=="/"&&o.splice(o.length-1,1),o}function LS(n,a){const r={};return a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,f){u&&(r[u]=f)}),r}const wd=typeof addEventListener=="function"&&typeof removeEventListener=="function",eo=[];wd&&addEventListener("offline",()=>{eo.forEach(n=>n())},!1);class Ms extends bt{constructor(a,r){if(super(),this.binaryType=pS,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,a&&typeof a=="object"&&(r=a,a=null),a){const o=Nd(a);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Nd(r.host).host);No(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{const u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=jS(this.opts.query)),wd&&(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"})},eo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(a){const r=Object.assign({},this.opts.query);r.EIO=eg,r.transport=a,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[a]);return new this._transportsByName[a](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const a=this.opts.rememberUpgrade&&Ms.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(a);r.open(),this.setTransport(r)}setTransport(a){this.transport&&this.transport.removeAllListeners(),this.transport=a,a.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Ms.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(a){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",a),this.emitReserved("heartbeat"),a.type){case"open":this.onHandshake(JSON.parse(a.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=a.data,this._onError(r);break;case"message":this.emitReserved("data",a.data),this.emitReserved("message",a.data);break}}onHandshake(a){this.emitReserved("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this._pingInterval=a.pingInterval,this._pingTimeout=a.pingTimeout,this._maxPayload=a.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const a=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+a,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},a),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const a=this._getWritablePackets();this.transport.send(a),this._prevBufferLen=a.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=bS(u)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const a=Date.now()>this._pingTimeoutTime;return a&&(this._pingTimeoutTime=0,jo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),a}write(a,r,o){return this._sendPacket("message",a,r,o),this}send(a,r,o){return this._sendPacket("message",a,r,o),this}_sendPacket(a,r,o,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:a,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),u&&this.once("flush",u),this.flush()}close(){const a=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),a()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():a()}):this.upgrading?o():a()),this}_onError(a){if(Ms.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",a),this._onClose("transport error",a)}_onClose(a,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),wd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=eo.indexOf(this._offlineEventListener);o!==-1&&eo.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",a,r),this.writeBuffer=[],this._prevBufferLen=0}}}Ms.protocol=eg;class zS extends Ms{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let a=0;a<this._upgrades.length;a++)this._probe(this._upgrades[a])}_probe(a){let r=this.createTransport(a),o=!1;Ms.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",b=>{if(!o)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Ms.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(v(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,v(),r.close(),r=null)}const p=b=>{const S=new Error("probe error: "+b);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function h(){p("transport closed")}function g(){p("socket closed")}function x(b){r&&b.name!==r.name&&f()}const v=()=>{r.removeListener("open",u),r.removeListener("error",p),r.removeListener("close",h),this.off("close",g),this.off("upgrading",x)};r.once("open",u),r.once("error",p),r.once("close",h),this.once("close",g),this.once("upgrading",x),this._upgrades.indexOf("webtransport")!==-1&&a!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(a){this._upgrades=this._filterUpgrades(a.upgrades),super.onHandshake(a)}_filterUpgrades(a){const r=[];for(let o=0;o<a.length;o++)~this.transports.indexOf(a[o])&&r.push(a[o]);return r}}let US=class extends zS{constructor(a,r={}){const o=typeof a=="object"?a:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(u=>DS[u]).filter(u=>!!u)),super(a,o)}};function HS(n,a="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=Nd(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+a,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const VS=typeof ArrayBuffer=="function",$S=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,rg=Object.prototype.toString,GS=typeof Blob=="function"||typeof Blob<"u"&&rg.call(Blob)==="[object BlobConstructor]",YS=typeof File=="function"||typeof File<"u"&&rg.call(File)==="[object FileConstructor]";function Qd(n){return VS&&(n instanceof ArrayBuffer||$S(n))||GS&&n instanceof Blob||YS&&n instanceof File}function to(n,a){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(to(n[r]))return!0;return!1}if(Qd(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return to(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&to(n[r]))return!0;return!1}function FS(n){const a=[],r=n.data,o=n;return o.data=Ad(r,a),o.attachments=a.length,{packet:o,buffers:a}}function Ad(n,a){if(!n)return n;if(Qd(n)){const r={_placeholder:!0,num:a.length};return a.push(n),r}else if(Array.isArray(n)){const r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=Ad(n[o],a);return r}else if(typeof n=="object"&&!(n instanceof Date)){const r={};for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=Ad(n[o],a));return r}return n}function IS(n,a){return n.data=Cd(n.data,a),delete n.attachments,n}function Cd(n,a){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<a.length)return a[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=Cd(n[r],a);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=Cd(n[r],a));return n}const XS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],QS=5;var He;(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"})(He||(He={}));class KS{constructor(a){this.replacer=a}encode(a){return(a.type===He.EVENT||a.type===He.ACK)&&to(a)?this.encodeAsBinary({type:a.type===He.EVENT?He.BINARY_EVENT:He.BINARY_ACK,nsp:a.nsp,data:a.data,id:a.id}):[this.encodeAsString(a)]}encodeAsString(a){let r=""+a.type;return(a.type===He.BINARY_EVENT||a.type===He.BINARY_ACK)&&(r+=a.attachments+"-"),a.nsp&&a.nsp!=="/"&&(r+=a.nsp+","),a.id!=null&&(r+=a.id),a.data!=null&&(r+=JSON.stringify(a.data,this.replacer)),r}encodeAsBinary(a){const r=FS(a),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function L0(n){return Object.prototype.toString.call(n)==="[object Object]"}class Kd extends bt{constructor(a){super(),this.reviver=a}add(a){let r;if(typeof a=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(a);const o=r.type===He.BINARY_EVENT;o||r.type===He.BINARY_ACK?(r.type=o?He.EVENT:He.ACK,this.reconstructor=new ZS(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Qd(a)||a.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(a),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+a)}decodeString(a){let r=0;const o={type:Number(a.charAt(0))};if(He[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===He.BINARY_EVENT||o.type===He.BINARY_ACK){const f=r+1;for(;a.charAt(++r)!=="-"&&r!=a.length;);const p=a.substring(f,r);if(p!=Number(p)||a.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(p)}if(a.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(a.charAt(r)===","||r===a.length););o.nsp=a.substring(f,r)}else o.nsp="/";const u=a.charAt(r+1);if(u!==""&&Number(u)==u){const f=r+1;for(;++r;){const p=a.charAt(r);if(p==null||Number(p)!=p){--r;break}if(r===a.length)break}o.id=Number(a.substring(f,r+1))}if(a.charAt(++r)){const f=this.tryParse(a.substr(r));if(Kd.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(a){try{return JSON.parse(a,this.reviver)}catch{return!1}}static isPayloadValid(a,r){switch(a){case He.CONNECT:return L0(r);case He.DISCONNECT:return r===void 0;case He.CONNECT_ERROR:return typeof r=="string"||L0(r);case He.EVENT:case He.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&XS.indexOf(r[0])===-1);case He.ACK:case He.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ZS{constructor(a){this.packet=a,this.buffers=[],this.reconPack=a}takeBinaryData(a){if(this.buffers.push(a),this.buffers.length===this.reconPack.attachments){const r=IS(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const JS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Kd,Encoder:KS,get PacketType(){return He},protocol:QS},Symbol.toStringTag,{value:"Module"}));function Sn(n,a,r){return n.on(a,r),function(){n.off(a,r)}}const PS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ig extends bt{constructor(a,r,o){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=a,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const a=this.io;this.subs=[Sn(a,"open",this.onopen.bind(this)),Sn(a,"packet",this.onpacket.bind(this)),Sn(a,"error",this.onerror.bind(this)),Sn(a,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...a){return a.unshift("message"),this.emit.apply(this,a),this}emit(a,...r){var o,u,f;if(PS.hasOwnProperty(a))throw new Error('"'+a.toString()+'" is a reserved event name');if(r.unshift(a),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const p={type:He.EVENT,data:r};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const v=this.ids++,b=r.pop();this._registerAckCallback(v,b),p.id=v}const h=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!h||(g?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(a,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[a]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[a];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===a&&this.sendBuffer.splice(h,1);r.call(this,new Error("operation has timed out"))},u),p=(...h)=>{this.io.clearTimeoutFn(f),r.apply(this,h)};p.withError=!0,this.acks[a]=p}emitWithAck(a,...r){return new Promise((o,u)=>{const f=(p,h)=>p?u(p):o(h);f.withError=!0,r.push(f),this.emit(a,...r)})}_addToQueue(a){let r;typeof a[a.length-1]=="function"&&(r=a.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:a,flags:Object.assign({fromQueue:!0},this.flags)};a.push((u,...f)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(a=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!a||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(a){a.nsp=this.nsp,this.io._packet(a)}onopen(){typeof this.auth=="function"?this.auth(a=>{this._sendConnectPacket(a)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(a){this.packet({type:He.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},a):a})}onerror(a){this.connected||this.emitReserved("connect_error",a)}onclose(a,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",a,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(a=>{if(!this.sendBuffer.some(o=>String(o.id)===a)){const o=this.acks[a];delete this.acks[a],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(a){if(a.nsp===this.nsp)switch(a.type){case He.CONNECT:a.data&&a.data.sid?this.onconnect(a.data.sid,a.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case He.EVENT:case He.BINARY_EVENT:this.onevent(a);break;case He.ACK:case He.BINARY_ACK:this.onack(a);break;case He.DISCONNECT:this.ondisconnect();break;case He.CONNECT_ERROR:this.destroy();const o=new Error(a.data.message);o.data=a.data.data,this.emitReserved("connect_error",o);break}}onevent(a){const r=a.data||[];a.id!=null&&r.push(this.ack(a.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(a){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,a)}super.emit.apply(this,a),this._pid&&a.length&&typeof a[a.length-1]=="string"&&(this._lastOffset=a[a.length-1])}ack(a){const r=this;let o=!1;return function(...u){o||(o=!0,r.packet({type:He.ACK,id:a,data:u}))}}onack(a){const r=this.acks[a.id];typeof r=="function"&&(delete this.acks[a.id],r.withError&&a.data.unshift(null),r.apply(this,a.data))}onconnect(a,r){this.id=a,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(a=>this.emitEvent(a)),this.receiveBuffer=[],this.sendBuffer.forEach(a=>{this.notifyOutgoingListeners(a),this.packet(a)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(a=>a()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:He.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(a){return this.flags.compress=a,this}get volatile(){return this.flags.volatile=!0,this}timeout(a){return this.flags.timeout=a,this}onAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(a),this}prependAny(a){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(a),this}offAny(a){if(!this._anyListeners)return this;if(a){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(a),this}prependAnyOutgoing(a){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(a),this}offAnyOutgoing(a){if(!this._anyOutgoingListeners)return this;if(a){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(a===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(a){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,a.data)}}}function sl(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}sl.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var a=Math.random(),r=Math.floor(a*this.jitter*n);n=(Math.floor(a*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};sl.prototype.reset=function(){this.attempts=0};sl.prototype.setMin=function(n){this.ms=n};sl.prototype.setMax=function(n){this.max=n};sl.prototype.setJitter=function(n){this.jitter=n};class kd extends bt{constructor(a,r){var o;super(),this.nsps={},this.subs=[],a&&typeof a=="object"&&(r=a,a=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,No(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new sl({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=a;const u=r.parser||JS;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(a){return arguments.length?(this._reconnection=!!a,a||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(a){return a===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=a,this)}reconnectionDelay(a){var r;return a===void 0?this._reconnectionDelay:(this._reconnectionDelay=a,(r=this.backoff)===null||r===void 0||r.setMin(a),this)}randomizationFactor(a){var r;return a===void 0?this._randomizationFactor:(this._randomizationFactor=a,(r=this.backoff)===null||r===void 0||r.setJitter(a),this)}reconnectionDelayMax(a){var r;return a===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=a,(r=this.backoff)===null||r===void 0||r.setMax(a),this)}timeout(a){return arguments.length?(this._timeout=a,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(a){if(~this._readyState.indexOf("open"))return this;this.engine=new US(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=Sn(r,"open",function(){o.onopen(),a&&a()}),f=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),a?a(h):this.maybeReconnectOnOpen()},p=Sn(r,"error",f);if(this._timeout!==!1){const h=this._timeout,g=this.setTimeoutFn(()=>{u(),f(new Error("timeout")),r.close()},h);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(u),this.subs.push(p),this}connect(a){return this.open(a)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const a=this.engine;this.subs.push(Sn(a,"ping",this.onping.bind(this)),Sn(a,"data",this.ondata.bind(this)),Sn(a,"error",this.onerror.bind(this)),Sn(a,"close",this.onclose.bind(this)),Sn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(a){try{this.decoder.add(a)}catch(r){this.onclose("parse error",r)}}ondecoded(a){jo(()=>{this.emitReserved("packet",a)},this.setTimeoutFn)}onerror(a){this.emitReserved("error",a)}socket(a,r){let o=this.nsps[a];return o?this._autoConnect&&!o.active&&o.connect():(o=new ig(this,a,r),this.nsps[a]=o),o}_destroy(a){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(a){const r=this.encoder.encode(a);for(let o=0;o<r.length;o++)this.engine.write(r[o],a.options)}cleanup(){this.subs.forEach(a=>a()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(a,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",a,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const a=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const o=this.setTimeoutFn(()=>{a.skipReconnect||(this.emitReserved("reconnect_attempt",a.backoff.attempts),!a.skipReconnect&&a.open(u=>{u?(a._reconnecting=!1,a.reconnect(),this.emitReserved("reconnect_error",u)):a.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const a=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",a)}}const Wl={};function no(n,a){typeof n=="object"&&(a=n,n=void 0),a=a||{};const r=HS(n,a.path||"/socket.io"),o=r.source,u=r.id,f=r.path,p=Wl[u]&&f in Wl[u].nsps,h=a.forceNew||a["force new connection"]||a.multiplex===!1||p;let g;return h?g=new kd(o,a):(Wl[u]||(Wl[u]=new kd(o,a)),g=Wl[u]),r.query&&!a.query&&(a.query=r.queryKey),g.socket(r.path,a)}Object.assign(no,{Manager:kd,Socket:ig,io:no,connect:no});const og="roverSettings",WS=3600*24*365;function ej(n){try{const a=decodeURIComponent(n??"");return JSON.parse(a)}catch(a){return console.warn("Failed to parse settings cookie",a),null}}function Ed(){if(typeof document>"u")return{};const n=`${og}=`,a=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(n));if(!a)return{};const r=a.substring(n.length);return ej(r)??{}}function z0(n){if(typeof document>"u")return!1;try{const a=encodeURIComponent(JSON.stringify(n??{})),r=`${og}=${a}; path=/; max-age=${WS}; samesite=strict`;return document.cookie=r,!0}catch(a){return console.warn("Failed to write settings cookie",a),!1}}const cg=window.location.origin;console.info("[socket] connecting to",cg);const tj=Ed(),nj=tj?.page?.connectionTransport||"websocket",sj=nj==="polling"?["polling"]:["websocket","polling"],Zd=no(cg,{transports:sj,timeout:15e3});Zd.on("connect_error",n=>console.error("connect_error",n.code,n.message,n.data));const ug=m.createContext(Zd),aj=({children:n})=>l.jsx(ug.Provider,{value:Zd,children:n}),Pt=()=>m.useContext(ug),lj={connected:!1,session:null,logs:[],adminLogs:[],llmCommentaryState:null,llmCommentaryStatus:null,overseerControlState:null,alerts:[]},Jd=m.createContext(null);function rj(n){return m.useCallback((a,r={})=>new Promise((o,u)=>{n.emit(a,r,(f={})=>{f.error?u(new Error(f.error)):o(f)})}),[n])}function ij(n){return typeof n=="function"?n:a=>a}function oj({children:n}){const a=Pt(),r=rj(a),o=m.useRef({...lj,connected:a.connected}),u=m.useRef(new Set),f=m.useCallback(()=>o.current,[]),p=m.useCallback(v=>{const b=o.current,S=typeof v=="function"?v(b):{...b,...v||{}};S!==b&&(o.current=S,u.current.forEach(C=>{const E=C.selector(S);C.equalityFn(C.current,E)||(C.current=E,C.listener(E))}))},[]),h=m.useCallback((v,b,S=Object.is)=>{const C=ij(v),E={selector:C,equalityFn:S,listener:b,current:C(o.current)};return u.current.add(E),()=>{u.current.delete(E)}},[]);m.useEffect(()=>{const v=()=>{p(S=>S.connected?S:{...S,connected:!0})},b=()=>{p(S=>S.connected?{...S,connected:!1}:S)};return a.on("connect",v),a.on("disconnect",b),()=>{a.off("connect",v),a.off("disconnect",b)}},[p,a]),m.useEffect(()=>{function v(T){p(k=>({...k,session:T}))}function b(T=[]){p(k=>({...k,logs:T}))}function S(T){p(k=>({...k,logs:[...k.logs.slice(-199),T]}))}function C(T=[]){p(k=>({...k,adminLogs:T}))}function E(T){p(k=>({...k,adminLogs:[...k.adminLogs.slice(-199),T]}))}function N(T=null){const k=T&&typeof T=="object"?T:null,R=k?.debug?.status&&typeof k.debug.status=="object"?k.debug.status:null;p(D=>({...D,llmCommentaryState:k,llmCommentaryStatus:R}))}function w(T={}){p(k=>({...k,alerts:[...k.alerts.slice(-49),{...T,receivedAt:Date.now()}]}))}function j(T=null){const k=T&&typeof T=="object"?T:null;p(R=>({...R,overseerControlState:k}))}return a.on("session:sync",v),a.on("log:init",b),a.on("log:entry",S),a.on("adminlog:init",C),a.on("adminlog:entry",E),a.on("llm:state",N),a.on("overseer:state",j),a.on("alert:new",w),()=>{a.off("session:sync",v),a.off("log:init",b),a.off("log:entry",S),a.off("adminlog:init",C),a.off("adminlog:entry",E),a.off("llm:state",N),a.off("overseer:state",j),a.off("alert:new",w)}},[p,a]);const g=m.useMemo(()=>({login:(v,b)=>r("auth:login",{username:v,password:b}),identifySession:({cookieUserId:v,nickname:b}={})=>r("session:identify",{cookieUserId:v,nickname:b}),setRole:v=>r("session:setRole",{role:v}),requestControl:(v,b={})=>r("session:requestControl",{roverId:v,...b}),releaseControl:v=>r("session:releaseControl",{roverId:v}),subscribeAll:()=>r("session:subscribeAll"),lockRover:(v,b)=>r("session:lockRover",{roverId:v,locked:b}),setMode:v=>r("setMode",{mode:v}),homeAssistantToggle:v=>r("homeAssistant:toggle",{entityId:v}),homeAssistantSetState:(v,b)=>r("homeAssistant:setState",{entityId:v,state:b}),homeAssistantSetLightColor:(v,b)=>r("homeAssistant:lightColor",{entityId:v,rgbColor:b}),homeAssistantSetLightWhite:v=>r("homeAssistant:lightWhite",{entityId:v}),neatoStart:()=>r("neato:start"),neatoSendHome:()=>r("neato:sendHome"),neatoLocate:()=>r("neato:locate"),neatoClearErrors:()=>r("neato:clearErrors"),neatoPowerCycle:()=>r("neato:powerCycle"),liftUp:()=>r("lift:up"),liftDown:()=>r("lift:down"),setNickname:v=>r("nickname:set",{nickname:v}),requestVerification:()=>r("verification:request"),requestPrivateRoverAccess:v=>r("session:privateRover:requestAccess",{roverId:v}),triggerReplay:(v=[],b="")=>v&&typeof v=="object"&&!Array.isArray(v)?r("replay:trigger",v):r("replay:trigger",{sources:v,title:b}),setGlobalObjective:v=>r("globalObjective:set",{text:v}),setAdminReason:v=>r("adminReason:set",{text:v}),rebootRover:v=>r("command",{roverId:v,type:"reboot",data:{reboot:{}}}),rebootServer:()=>r("server:reboot"),playUploadedAudio:({roverId:v,name:b,mime:S,dataBase64:C})=>r("audio:uploadPlay",{roverId:v,name:b,mime:S,dataBase64:C}),stopUploadedAudio:v=>r("audio:uploadStop",{roverId:v}),startMicWhip:v=>r("audio:micWhipStart",{roverId:v}),readyMicWhip:v=>r("audio:micWhipReady",{roverId:v}),stopMicWhip:v=>r("audio:micWhipStop",{roverId:v}),setAudioLevels:(v={})=>r("audioLevels:set",v),setPrivateSafety:(v,b={})=>r("session:privateSafety:set",{roverId:v,safety:b}),llmControl:(v,b={})=>r("llm:control",{controls:{action:v,...b}}),overseerControl:(v,b={})=>r("overseer:control",{controls:{action:v,...b}}),pushAlert:v=>p(b=>({...b,alerts:[...b.alerts.slice(-49),{...v,receivedAt:Date.now(),id:v.id||Math.random().toString(36).slice(2)}]}))}),[r,p]),x=m.useMemo(()=>({getState:f,subscribe:h,actions:g}),[g,f,h]);return l.jsx(Jd.Provider,{value:x,children:n})}function oe(n,a=Object.is){const r=m.useContext(Jd);if(!r)throw new Error("useSessionSelector must be used within SessionProvider");const o=m.useRef(n);o.current=n;const u=m.useRef(a);u.current=a;const[f,p]=m.useState(()=>n(r.getState()));return m.useEffect(()=>(p(h=>{const g=o.current(r.getState());return u.current(h,g)?h:g}),r.subscribe(h=>o.current(h),h=>{p(g=>u.current(g,h)?g:h)},(h,g)=>u.current(h,g))),[r]),f}function $t(){const n=m.useContext(Jd);if(!n)throw new Error("useSessionActions must be used within SessionProvider");return n.actions}function br(){const n=oe(r=>r),a=$t();return m.useMemo(()=>({...n,...a}),[a,n])}const cj=Object.freeze({}),Md=null,Pd=m.createContext(null);function uj({children:n}){const a=Pt(),r=m.useRef({}),o=m.useRef(new Map),u=m.useRef(new Set),f=h=>{const g=o.current.get(h);g&&g.forEach(x=>x()),u.current.forEach(x=>x())},p=m.useMemo(()=>({getFrames:()=>r.current,getFrame:h=>h?r.current[h]??Md:Md,subscribeAll:h=>(u.current.add(h),()=>{u.current.delete(h)}),subscribeRover:(h,g)=>{if(!h)return()=>{};let x=o.current.get(h);return x||(x=new Set,o.current.set(h,x)),x.add(g),()=>{const v=o.current.get(h);v&&(v.delete(g),v.size||o.current.delete(h))}}}),[]);return m.useEffect(()=>{function h({roverId:g,sensors:x={},frame:v={}}){g&&(r.current={...r.current,[g]:{roverId:g,sensors:x,raw:v?.data||null,receivedAt:Date.now()}},f(g))}return a.on("sensorFrame",h),()=>{a.off("sensorFrame",h)}},[a]),l.jsx(Pd.Provider,{value:p,children:n})}function dj(){const n=m.useContext(Pd);if(!n)throw new Error("useTelemetryFrames must be used within TelemetryProvider");return m.useSyncExternalStore(n.subscribeAll,n.getFrames,()=>cj)}function Wt(n){const a=m.useContext(Pd);if(!a)throw new Error("useTelemetryFrame must be used within TelemetryProvider");return m.useSyncExternalStore(r=>a.subscribeRover(n,r),()=>a.getFrame(n),()=>Md)}const fj=650,mj={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 ed(n){if(typeof n!="number"||n<=0)return null;const a=mj[n];return a?{code:n,...a}:null}function hj(n,a={}){const r=a.holdMs||fj,[o,u]=m.useState({left:null,right:null,omni:null}),[f,p]=m.useState(0);return m.useEffect(()=>{const h=setInterval(()=>p(Date.now()),Math.max(r/2,100));return()=>clearInterval(h)},[r]),m.useEffect(()=>{const h=Date.now(),g=ed(n?.infraredCharacterLeft),x=ed(n?.infraredCharacterRight),v=ed(n?.infraredCharacterOmni);!g&&!x&&!v||u(b=>({left:g?{...g,ts:h}:b.left,right:x?{...x,ts:h}:b.right,omni:v?{...v,ts:h}:b.omni}))},[n?.infraredCharacterLeft,n?.infraredCharacterRight,n?.infraredCharacterOmni]),m.useMemo(()=>{const h=Date.now(),g=w=>{if(!w)return{active:!1,red:!1,green:!1,force:!1,age:null,code:null};const j=h-w.ts,T=j<=r;return{active:T,age:j,code:w.code,red:!!(w.red&&T),green:!!(w.green&&T),force:!!(w.force&&T)}},x=g(o.left),v=g(o.right),b=g(o.omni),S=x.force||v.force||b.force,C=x.active||v.active||b.active,E=x.active&&!v.active?"right":v.active&&!x.active?"left":"center",N=(v.active?1:0)-(x.active?1:0);return{visible:C,forceDetected:S,left:x,right:v,omni:b,bias:E,balance:Math.max(-1,Math.min(1,N))}},[o.left,o.right,o.omni,r,f])}function pj(){oe(C=>C.connected);const n=oe(C=>C.session?.assignment?.roverId??null),a=oe(C=>{const E=C.session?.assignment?.roverId;return E&&C.session?.activeDrivers?.[E]||null}),r=oe(C=>C.session?.socketId||null),o=oe(C=>C.session?.users??[]),u=Wt(n),f=u?.sensors||{},p=hj(f),h=f.voltageMv!=null?`${(f.voltageMv/1e3).toFixed(2)} V`:null,g=f.currentMa!=null?`${f.currentMa} mA`:null,x=f.batteryTemperatureC!=null?`${f.batteryTemperatureC} °C`:null,v=f.batteryChargeMah,b=f.batteryCapacityMah;u?.receivedAt&&new Date(u.receivedAt).toLocaleTimeString();const S=u?.raw?u.raw:null;return m.useMemo(()=>n?a?a===r?"You":o.find(E=>E.socketId===a)?.nickname||a.slice(0,6):"Available":"n/a",[a,n,r,o]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base text-slate-100",children:[n?u?l.jsxs(l.Fragment,{children:[l.jsx(xj,{sensors:f,voltage:h,current:g,batteryTemp:x,charge:v,capacity:b}),l.jsx(gj,{sensors:f,dockState:p})]}):l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for sensor frames…"}):l.jsx("p",{className:"text-sm text-slate-500",children:"You are not assigned to a rover!!!!!!"}),S&&l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-xs text-lime-300",children:S})]})}function xj({sensors:n,voltage:a,current:r,batteryTemp:o,charge:u,capacity:f}){const p=u!=null&&f?`${Math.round(u/f*100)}`:"--",h=n?.oiMode?.label||"--",g=n?.chargingSources?.homeBase?"Yes":"No",x=n?.chargingState?.label||"--";return l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-3",children:[l.jsx(Zn,{label:"Voltage",value:a??"--"}),l.jsx(Zn,{label:"Current",value:r??"--"}),l.jsx(Zn,{label:"Battery temp",value:o??"--"}),l.jsx(Zn,{label:"Charge",value:u!=null?`${u} mAh`:"--"}),l.jsx(Zn,{label:"Capacity",value:f!=null?`${f} mAh`:"--"}),l.jsx(Zn,{label:"Charge",value:p}),l.jsx(Zn,{label:"OI mode",value:h}),l.jsx(Zn,{label:"Docked",value:g}),l.jsx(Zn,{label:"Charging state",value:x})]})}function Zn({label:n,value:a}){return l.jsxs("div",{className:"surface flex items-center justify-between gap-0.5 px-1 py-0.5 text-sm",children:[l.jsx("span",{className:"text-slate-400",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function gj({sensors:n,dockState:a}){const r=n?.bumpsAndWheelDrops||{},o=n?.wheelOvercurrents||{},u=[{label:"Left",value:n?.lightBumpLeftSignal},{label:"Front Left",value:n?.lightBumpFrontLeftSignal},{label:"Center Left",value:n?.lightBumpCenterLeftSignal},{label:"Center Right",value:n?.lightBumpCenterRightSignal},{label:"Front Right",value:n?.lightBumpFrontRightSignal},{label:"Right",value:n?.lightBumpRightSignal}],f=[{label:"Left",value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Front Left",value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Front Right",value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Right",value:n?.cliffRightSignal,active:n?.cliffRight}],p=[{label:"Wheel L",value:n?.wheelLeftCurrentMa,over:o.leftWheel},{label:"Wheel R",value:n?.wheelRightCurrentMa,over:o.rightWheel},{label:"Side brush",value:n?.sideBrushCurrentMa,over:o.sideBrush},{label:"Main brush",value:n?.mainBrushCurrentMa,over:o.mainBrush}];return l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs($a,{title:"Dock IR",children:[l.jsx(vj,{sensors:n}),l.jsx(bj,{state:a})]}),l.jsxs($a,{title:"Bumps & drops",children:[l.jsx(Jn,{label:"Bump L",value:l.jsx(er,{active:r.bumpLeft})}),l.jsx(Jn,{label:"Bump R",value:l.jsx(er,{active:r.bumpRight})}),l.jsx(Jn,{label:"Wheel drop L",value:l.jsx(er,{active:r.wheelDropLeft,tone:"amber"})}),l.jsx(Jn,{label:"Wheel drop R",value:l.jsx(er,{active:r.wheelDropRight,tone:"amber"})})]}),l.jsx($a,{title:"Light bumps (raw)",children:u.map(h=>l.jsx(Jn,{label:h.label,value:tr(h.value)},h.label))}),l.jsx($a,{title:"Cliff sensors",children:f.map(h=>l.jsx(Jn,{label:h.label,value:`${tr(h.value)} · ${h.active?"bool: true":"bool: false"}`},h.label))}),l.jsx($a,{title:"Currents",children:p.map(h=>l.jsx(Jn,{label:h.label,value:l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:tr(h.value,"mA")}),h.over?l.jsx(er,{active:!0,tone:"red",label:"over"}):null]})},h.label))}),l.jsxs($a,{title:"Dirt detect",children:[l.jsx(Jn,{label:"Left",value:tr(n?.dirtDetectLeft)}),l.jsx(Jn,{label:"Right",value:tr(n?.dirtDetect)})]})]})}function $a({title:n,children:a}){return l.jsxs("div",{className:"surface space-y-0.5 p-1 text-sm",children:[l.jsx("div",{className:"text-[0.8rem] uppercase tracking-wide text-slate-400",children:n}),l.jsx("div",{className:"space-y-0.5",children:a})]})}function Jn({label:n,value:a}){return l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-300",children:n}),l.jsx("span",{className:"text-slate-100",children:a})]})}function er({active:n,tone:a="green",label:r}){const o="rounded px-1.5 py-0.5 text-[0.7rem] font-semibold",u=a==="red"?n?"bg-red-600 text-white":"bg-slate-700 text-slate-300":a==="amber"?n?"bg-amber-500 text-slate-900":"bg-slate-700 text-slate-300":n?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300";return l.jsx("span",{className:`${o} ${u}`,children:r||(n?"true":"false")})}function tr(n,a){return n==null||Number.isNaN(n)?"--":a?`${n} ${a}`:n}function vj({sensors:n}){const a=n?.infraredCharacterLeft,r=n?.infraredCharacterRight,o=n?.infraredCharacterOmni,u=f=>l.jsx("span",{className:`rounded px-1 py-0.25 text-[0.7rem] font-semibold ${f?"bg-emerald-600 text-white":"bg-slate-700 text-slate-300"}`,children:f||"--"});return l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"L"}),u(a)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"O"}),u(o)]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:"R"}),u(r)]})]})}function bj({state:n}){if(!n)return null;const a=o=>{const u=[];return o?.red&&u.push("R"),o?.green&&u.push("G"),o?.force&&u.push("F"),u.length?u.join(""):"none"},r=o=>o?.age!=null?`${o.age}ms`:"--";return l.jsxs("div",{className:"text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Left: ${n.left.code??"--"} (${a(n.left)}) · age ${r(n.left)}`}),l.jsx("div",{children:`Omni: ${n.omni.code??"--"} (${a(n.omni)}) · age ${r(n.omni)}`}),l.jsx("div",{children:`Right: ${n.right.code??"--"} (${a(n.right)}) · age ${r(n.right)}`})]})}const dg=m.createContext(null);function yj({children:n}){const[a,r]=m.useState(()=>({status:"loading",data:{}}));m.useEffect(()=>{const h=Ed();r({status:"ready",data:h??{}})},[]);const o=m.useCallback(()=>{const h=Ed();r({status:"ready",data:h??{}})},[]),u=m.useCallback(h=>{const g=z0(h??{});return r(g?{status:"ready",data:h??{}}:x=>({...x,status:"error"})),g},[]),f=m.useCallback((h,g)=>{r(x=>{const v=x.data[h]||{},b=typeof g=="function"?g(v):{...v,...g??{}},S={...x.data,[h]:b};return z0(S)?{status:"ready",data:S}:{...x,status:"error"}})},[]),p=m.useMemo(()=>({data:a.data,status:a.status,reload:o,saveAll:u,setNamespace:f}),[a,o,u,f]);return l.jsx(dg.Provider,{value:p,children:n})}function Sj(){const n=m.useContext(dg);if(!n)throw new Error("useSettings must be used within SettingsProvider");return n}function Ve(n,a={}){const{data:r,status:o,setNamespace:u}=Sj(),f=r[n]??a??{},p=m.useCallback(x=>{u(n,v=>{const b=v??{};return typeof x=="function"?x(b):{...b,...x??{}}})},[n,u]),h=m.useCallback(x=>{u(n,()=>x??{})},[n,u]),g=m.useCallback(()=>{const x=typeof a=="object"?{...a}:a;u(n,()=>x??{})},[a,n,u]);return{value:f,status:o,save:p,replace:h,reset:g}}const jj=/^#[0-9A-Fa-f]{6}$/;function Wd(n){const a=typeof n=="string"?n.trim():"";return!a||!jj.test(a)?null:a.toUpperCase()}function ns(n,a=.2){const r=Wd(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=fg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.65)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function Nj(n,a=.2){const r=Wd(n);if(!r)return;const o=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.2,u=fg(r);if(u)return{borderColor:`rgba(${u.r}, ${u.g}, ${u.b}, 0.55)`,backgroundColor:`rgba(${u.r}, ${u.g}, ${u.b}, ${o})`}}function fg(n){const a=Wd(n);return a?{r:parseInt(a.slice(1,3),16),g:parseInt(a.slice(3,5),16),b:parseInt(a.slice(5,7),16)}:null}function wj(n=[]){return n.map(a=>!a?.type||!a?.id?null:{type:a.type,id:String(a.id),label:a.label||String(a.id),color:a.color||null,key:`${a.type}:${a.id}`}).filter(Boolean)}function ef({panelId:n="replay-sources",fillHeight:a=!1}){const r=oe(M=>M.session?.replaySources??[]),o=oe(M=>M.session?.mode||null),u=oe(M=>M.session?.assignment?.roverId??null),f=oe(M=>M.session?.users??[]),p=oe(M=>M.session?.socketId||null),h=oe(M=>M.session?.roster??[]),g=oe(M=>M.session?.replay||null),{triggerReplay:x}=$t(),v=wj(r||[]),{value:b,save:S}=Ve("replaySources",{}),[C,E]=m.useState([]),[N,w]=m.useState(!1),[j,T]=m.useState(null),[k,R]=m.useState(null),[D,V]=m.useState(""),[O,L]=m.useState(!1),[Y,U]=m.useState(!0),[X,Q]=m.useState(0),ce=m.useMemo(()=>{const M=u;return M?[`rover:${M}`]:[]},[u]),ue=m.useMemo(()=>{const q=((Array.isArray(f)?f.find(he=>he?.socketId===p):null)?.nickname||"Someone").trim()||"Someone",Z=u||null,le=Z&&Array.isArray(h)?h.find(he=>String(he?.id)===String(Z))?.name||Z:"a rover";return`${q} driving ${le}`},[f,p,u,h]);m.useEffect(()=>{const M=b?.[n];if(Array.isArray(M)&&M.length){E(M);return}E(ce)},[b?.[n],ce,n]),m.useEffect(()=>{const M=b?.[`${n}:includeSidebar`];if(typeof M=="boolean"){U(M);return}U(!0)},[b?.[`${n}:includeSidebar`],n]),m.useEffect(()=>{O||V(ue)},[ue,O]),m.useEffect(()=>{const M=new Set(v.map(q=>q.key));E(q=>q.filter(Z=>M.has(Z)))},[v]);const W=m.useMemo(()=>({rovers:v.filter(M=>M.type==="rover"),rooms:v.filter(M=>M.type==="room")}),[v]);m.useEffect(()=>{if(!g?.lastTriggeredAt||!g?.cooldownMs){Q(0);return}const M=()=>{const Z=g.lastTriggeredAt+g.cooldownMs-Date.now();Q(Math.max(0,Z))};M();const q=setInterval(M,250);return()=>clearInterval(q)},[g?.lastTriggeredAt,g?.cooldownMs,g?.remainingMs]);const B=N||o==="lockdown"||X>0||!C.length,I=M=>{E(q=>{const Z=q.includes(M)?q.filter(le=>le!==M):[...q,M];return S(le=>({...le||{},[n]:Z})),Z}),R(null)},K=async()=>{if(!B){w(!0),T(null),R(null);try{const M=C.map(Z=>{const[le,he]=Z.split(":");return{type:le,id:he}}),q=String(D||"").trim()||ue;await x({sources:M,title:q,includeSidebar:Y}),R("Replay sent. Check the Discord replay channel.")}catch(M){T(M.message)}finally{w(!1)}}},P=a?"h-full flex flex-col":"",ie=a?"flex-1 min-h-0 overflow-y-auto":"";return l.jsxs("section",{className:`panel-section p-0.75 text-sm ${P}`,children:[l.jsxs("header",{className:"panel-muted flex items-center justify-between text-xs",children:[l.jsx("span",{children:"Replay Sources"}),l.jsx("span",{children:v.length})]}),l.jsxs("div",{className:`grid gap-0.5 md:grid-cols-2 ${ie}`,children:[l.jsx(U0,{title:"Rovers",items:W.rovers,selected:C,onToggle:I}),l.jsx(U0,{title:"Room Cams",items:W.rooms,selected:C,onToggle:I})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("label",{className:"panel-muted block text-xs",htmlFor:`${n}-title`,children:"Replay title"}),l.jsx("input",{id:`${n}-title`,type:"text",className:"field-input w-full text-xs",value:D,onChange:M=>{V(M.target.value),L(!0)},placeholder:ue,maxLength:120}),l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:Y,onChange:M=>{const q=!!M.target.checked;U(q),S(Z=>({...Z||{},[`${n}:includeSidebar`]:q}))},className:"accent-emerald-400"}),l.jsx("span",{children:"Include replay sidebar"})]}),l.jsx("button",{type:"button",className:"button-dark w-full text-xs disabled:opacity-40",onClick:K,disabled:B,children:X>0?`Replay (${Math.ceil(X/1e3)}s)`:N?"Replay…":"Replay"}),j?l.jsx("div",{className:"text-xs text-amber-400",children:j}):null,k?l.jsx("div",{className:"text-xs text-emerald-300",children:k}):null]})]})}function U0({title:n,items:a,selected:r,onToggle:o}){return a.length?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs",children:n}),l.jsx("div",{className:"space-y-0.5",children:a.map(u=>l.jsxs("label",{className:"surface flex items-center gap-0.5 text-xs",children:[l.jsx("input",{type:"checkbox",checked:r.includes(u.key),onChange:()=>o(u.key),className:"accent-emerald-400"}),l.jsx("span",{className:`truncate ${u.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:u.type==="rover"?ns(u.color,.16):void 0,children:u.label})]},u.key))})]}):null}var mg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},H0=Dt.createContext&&Dt.createContext(mg),Aj=["attr","size","title"];function Cj(n,a){if(n==null)return{};var r=kj(n,a),o,u;if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(n);for(u=0;u<f.length;u++)o=f[u],!(a.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(n,o)&&(r[o]=n[o])}return r}function kj(n,a){if(n==null)return{};var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(a.indexOf(o)>=0)continue;r[o]=n[o]}return r}function co(){return co=Object.assign?Object.assign.bind():function(n){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])}return n},co.apply(this,arguments)}function V0(n,a){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);a&&(o=o.filter(function(u){return Object.getOwnPropertyDescriptor(n,u).enumerable})),r.push.apply(r,o)}return r}function uo(n){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?V0(Object(r),!0).forEach(function(o){Ej(n,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):V0(Object(r)).forEach(function(o){Object.defineProperty(n,o,Object.getOwnPropertyDescriptor(r,o))})}return n}function Ej(n,a,r){return a=Mj(a),a in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r,n}function Mj(n){var a=Rj(n,"string");return typeof a=="symbol"?a:a+""}function Rj(n,a){if(typeof n!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var o=r.call(n,a);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function hg(n){return n&&n.map((a,r)=>Dt.createElement(a.tag,uo({key:r},a.attr),hg(a.child)))}function yr(n){return a=>Dt.createElement(Tj,co({attr:uo({},n.attr)},a),hg(n.child))}function Tj(n){var a=r=>{var{attr:o,size:u,title:f}=n,p=Cj(n,Aj),h=u||r.size||"1em",g;return r.className&&(g=r.className),n.className&&(g=(g?g+" ":"")+n.className),Dt.createElement("svg",co({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,o,p,{className:g,style:uo(uo({color:n.color||r.color},r.style),n.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),f&&Dt.createElement("title",null,f),n.children)};return H0!==void 0?Dt.createElement(H0.Consumer,null,r=>a(r)):a(mg)}function pg(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"},child:[]}]})(n)}function qj(n){return yr({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function $0(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 384h192c53 0 96-43 96-96h32c70.6 0 128-57.4 128-128S582.6 32 512 32H120c-13.3 0-24 10.7-24 24v232c0 53 43 96 96 96zM512 96c35.3 0 64 28.7 64 64s-28.7 64-64 64h-32V96h32zm47.7 384H48.3c-47.6 0-61-64-36-64h583.3c25 0 11.8 64-35.9 64z"},child:[]}]})(n)}function Dj(n){return yr({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function _j(n){return yr({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function Bj(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 tf(n){return!!n?.bot}function Oj(n){const a=new Date(n);return`${a.getHours().toString().padStart(2,"0")}:${a.getMinutes().toString().padStart(2,"0")}`}function td(n){return n.nickname||n.socketId?.slice(0,6)||"unknown"}function Lj({guildIconUrl:n,userAvatarUrl:a,label:r}){return!n&&!a?null:l.jsxs("span",{className:"flex h-4 w-4 shrink-0 overflow-hidden rounded-none border border-slate-700/80",title:r,children:[l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${n?"bg-cover":""}`,style:n?{backgroundImage:`url(${n})`,backgroundPosition:"left center",backgroundSize:"200% 100%"}:void 0}),l.jsx("span",{className:`h-full w-1/2 bg-slate-700/70 ${a?"bg-cover":""}`,style:a?{backgroundImage:`url(${a})`,backgroundPosition:"right center",backgroundSize:"200% 100%"}:void 0})]})}function zj({imageUrl:n,label:a}){return n?l.jsx("span",{className:"flex h-4 w-4 shrink-0 overflow-hidden rounded-none border border-slate-700/80",title:a,children:l.jsx("span",{className:"h-full w-full bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${n})`}})}):null}function xg({message:n}){const a=n.fromDiscord?`${n.discordGuildName||"Discord"} · ${td(n)}`:null,r=tf(n),o=r?"text-emerald-300":Bj(n.role);return l.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5 align-middle",children:[n.fromDiscord?l.jsx(pg,{className:"h-4 w-4 shrink-0 text-indigo-200"}):null,l.jsx("span",{className:`font-semibold text-[0.85rem] ${o}`,children:td(n)}),l.jsx(zj,{imageUrl:n.profileImage,label:a||td(n)}),n.profileImage?null:l.jsx(Lj,{guildIconUrl:n.discordGuildIconUrl,userAvatarUrl:n.discordUserAvatarUrl,label:a}),r?l.jsx("span",{className:"shrink-0 rounded bg-emerald-900/60 px-1 text-[0.65rem] font-semibold uppercase tracking-wide text-white",children:"bot"}):null,n.roverId&&l.jsx("span",{className:"shrink-0 rounded bg-slate-800 px-1 text-[0.7rem]",style:Nj(n.roverColor,.14),children:n.roverId})]})}function gg(n){return tf(n)?"surface-muted flex items-center gap-0.5 border border-emerald-500/40 bg-emerald-900/15 text-sm":`surface-muted flex items-center 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 nf({message:n}){const a=tf(n);return l.jsxs("div",{className:gg(n),children:[l.jsxs("span",{className:`min-w-0 flex-1 break-words leading-tight whitespace-pre-wrap ${a?"text-emerald-100":"text-slate-100"}`,children:[l.jsx(xg,{message:n})," ",n.text]}),l.jsx("span",{className:"ml-auto shrink-0 text-[0.65rem] text-slate-400/60",children:Oj(n.ts)})]})}function vg({message:n}){return l.jsxs("div",{className:`${gg(n)} italic opacity-80 border-slate-600/40 bg-slate-900/40`,children:[l.jsx(xg,{message:n}),l.jsx("span",{className:"text-slate-300",children:"typing..."})]})}function bg({buttonId:n,count:a,goal:r,rewardNumber:o,rewardName:u,className:f=""}){return l.jsxs("article",{className:["surface px-0.5 py-0.5 text-center",f].filter(Boolean).join(" "),children:[l.jsxs("p",{className:"text-xs text-slate-400",children:["Button ",n]}),l.jsxs("p",{className:"text-sm font-semibold text-white",children:[a," / ",r]}),l.jsxs("p",{className:"truncate text-[0.7rem] text-slate-300",children:["#",o," ",u]})]})}const Uj=3e3,Hj=3500,Vj="#2196f3";function $j(n){return n.id?n.id:n.timestamp?`${n.timestamp}-${n.message}`:`${n.title||"alert"}-${n.message}`}function sf({scale:n=1}){const a=oe(S=>S.alerts),r=oe(S=>S.session?.buttonBox?.buttons??[]),{pushAlert:o}=$t(),u=Pt(),[f,p]=m.useState(()=>Date.now());m.useEffect(()=>{function S(C={}){const E=Number(C.buttonId);if(!Number.isFinite(E)||E<1||E>4)return;const w=(Array.isArray(r)?r:[]).find(D=>Number(D?.id)===E)||{},j=Number.isFinite(C.count)?C.count:Number(w.count)||0,T=Number.isFinite(w.goal)?w.goal:0,k=Number.isFinite(w.rewardNumber)?w.rewardNumber:"?",R=typeof w.rewardName=="string"&&w.rewardName.trim()?w.rewardName.trim():"Unassigned";o({id:`buttonbox-active-${E}`,kind:"buttonbox-active",lifetimeMs:Hj,payload:{buttonId:E,count:j,goal:T,rewardNumber:k,rewardName:R}})}return u.on("buttonBox:increment",S),()=>{u.off("buttonBox:increment",S)}},[o,r,u]);const h=m.useMemo(()=>a.slice(-12).map(S=>({alert:S,key:$j(S)})),[a]);m.useEffect(()=>{if(!h.length)return;const S=setInterval(()=>p(Date.now()),200);return()=>clearInterval(S)},[h.length]);const g=new Map;h.forEach(S=>{const C=f-(S.alert.receivedAt??S.alert.timestamp??0),E=Number.isFinite(S.alert.lifetimeMs)?S.alert.lifetimeMs:Uj;C<=E&&g.set(S.key,{...S,age:C})});const x=Array.from(g.values()).slice(-3);if(!x.length)return null;const v=n===1?void 0:{transform:`translateX(-50%) scale(${n})`,transformOrigin:"top center"},b=n===1?"pointer-events-none fixed top-0.5 left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0.5":"pointer-events-none fixed top-0.5 left-1/2 z-50 flex flex-col gap-0.5";return l.jsx("div",{className:b,style:v,children:x.map(S=>l.jsx(Gj,{alert:S.alert},S.key))})}function G0(n){const a=typeof n=="string"?n.trim():"",r=/^#?([0-9a-fA-F]{6})$/.exec(a);if(!r)return null;const o=r[1];return{r:parseInt(o.slice(0,2),16),g:parseInt(o.slice(2,4),16),b:parseInt(o.slice(4,6),16)}}function Gj({alert:n}){if(n.kind==="buttonbox-active"&&n.payload){const u=n.payload;return l.jsx("div",{className:"pointer-events-none w-[12.5rem]",children:l.jsx(bg,{buttonId:u.buttonId,count:u.count,goal:u.goal,rewardNumber:u.rewardNumber,rewardName:u.rewardName,className:"bg-cyan-900/45"})})}if(n.kind==="chat"&&n.payload)return l.jsx(nf,{message:n.payload});if(n.kind==="chat-typing"&&n.payload)return l.jsx(vg,{message:n.payload});const a=G0(n.color)||G0(Vj),r=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.18)`:"rgba(33, 150, 243, 0.18)",o=a?`rgba(${a.r}, ${a.g}, ${a.b}, 0.45)`:"rgba(33, 150, 243, 0.45)";return l.jsx("div",{className:"pointer-events-auto max-w-[80vw] rounded-full border px-2 py-0.5 text-[0.7rem] leading-tight text-slate-100 shadow-sm shadow-black/30",style:{backgroundColor:r,border:`1px solid ${o}`},children:l.jsxs("p",{className:"truncate text-slate-100",children:[l.jsx("span",{className:"text-slate-300",children:n.title||"Alert"}),l.jsx("span",{className:"text-slate-500",children:" · "}),l.jsx("span",{className:"text-white",children:n.message})]})})}const Ga={main:[-127,127],side:[-127,127],vacuum:[0,127]},nd={maxSpeed:500,baseSpeed:250,boostSpeed:400},Yj=60,Rd=100,af=[31,127],Za=60,Td=8,Fj=250,Ij=4e3,$i=.4,Y0=.2,F0=.8,Xj={start:[128],safe:[131],full:[132],passive:[128],dock:[143]},ir={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"]},yg=[{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:Rd},{type:"oi",command:"dock"},{type:"pause",duration:Rd},{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}}]}];function qd(){return{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:null,lastUpdatedAt:0}}function Dd(){return{main:0,side:0,vacuum:0}}function Qj(){return{enabled:!1,angle:null,config:null}}function so(){return{note:Za}}function lr(){return{active:!1,heat:0,overheated:!1}}function ao(){return{pttActive:!1}}function _d(){return{active:!1}}const I0={roverId:null,mode:"drive",drive:qd(),aux:Dd(),camera:Qj(),song:so(),horn:lr(),mic:ao(),manualDockAssist:_d(),lastControlIntentAt:0,macros:yg,keymap:ir,inputs:{}};function Kj(n,a){switch(a.type){case"control/set-rover":return{...n,roverId:a.payload??null,drive:a.payload?n.drive:qd(),aux:a.payload?n.aux:Dd(),song:a.payload?n.song:so(),horn:a.payload?n.horn:lr(),mic:a.payload?n.mic:ao(),manualDockAssist:a.payload?n.manualDockAssist:_d(),lastControlIntentAt:a.payload?n.lastControlIntentAt:0};case"control/set-mode":return n.mode===a.payload?n:{...n,mode:a.payload==="dock"?"dock":"drive"};case"control/update-drive":{const{vector:r,speeds:o,source:u}=a.payload;return{...n,drive:{vector:r??n.drive.vector,speeds:o??n.drive.speeds,source:u??n.drive.source,lastUpdatedAt:Date.now()}}}case"control/set-aux-motors":return{...n,aux:{...n.aux,...a.payload}};case"control/set-camera-config":return{...n,camera:{...n.camera,enabled:!!a.payload?.config,config:a.payload?.config??null,angle:typeof a.payload?.angle=="number"?a.payload.angle:a.payload?.config?a.payload.config.homeAngle??n.camera.angle:null}};case"control/set-camera-angle":return{...n,camera:{...n.camera,angle:a.payload}};case"control/register-input-state":{const r=a.payload?.source||"unknown";return{...n,inputs:{...n.inputs,[r]:{...n.inputs[r]??{},...a.payload?.state,updatedAt:Date.now()}}}}case"control/set-keymap":return{...n,keymap:{...n.keymap,...a.payload??{}}};case"control/set-macros":return{...n,macros:Array.isArray(a.payload)?a.payload:n.macros};case"control/reset":return{...n,drive:qd(),aux:Dd(),song:so(),horn:lr(),mic:ao(),lastControlIntentAt:0};case"control/set-horn-active":return{...n,horn:{...n.horn||lr(),active:!!a.payload}};case"control/set-horn-heat":return{...n,horn:{...n.horn||lr(),heat:typeof a.payload?.heat=="number"?a.payload.heat:0,overheated:!!a.payload?.overheated}};case"control/record-intent":return{...n,lastControlIntentAt:Date.now()};case"control/set-song-note":return{...n,song:{...n.song||so(),note:a.payload??Za}};case"control/set-mic-ptt":return{...n,mic:{...n.mic||ao(),pttActive:!!a.payload}};case"control/set-manual-dock-assist":return{...n,manualDockAssist:{...n.manualDockAssist||_d(),active:!!a.payload}};default:return n}}function Ja(n,a,r){return typeof n!="number"||Number.isNaN(n)?a:Math.max(a,Math.min(r,n))}function Pa(n){return typeof n!="number"||Number.isNaN(n)?0:Math.max(-1,Math.min(1,n))}function hn(n,a){return!Array.isArray(a)||a.length!==2?n:Ja(n,a[0],a[1])}function Zj(n={}){const a=Pa(n.x??0),r=Pa(n.y??0);return{x:a,y:r,boost:!!n.boost}}function Jj(n={},a={}){const r=Zj(n),o=typeof a.maxSpeed=="number"?a.maxSpeed:nd.maxSpeed,u=typeof a.baseSpeed=="number"?a.baseSpeed:nd.baseSpeed,f=typeof a.boostSpeed=="number"?a.boostSpeed:nd.boostSpeed,p=r.boost?f:u,h=r.y*p,g=r.x*p;return{vector:r,speeds:{left:Ja(Math.round(h+g),-o,o),right:Ja(Math.round(h-g),-o,o)}}}function Pj(n){const a=Array.isArray(n)?n:[],r=String.fromCharCode(...a);if(typeof btoa=="function")return btoa(r);if(typeof Buffer<"u")return Buffer.from(a).toString("base64");throw new Error("No base64 encoder available")}function X0(n){return new Promise(a=>setTimeout(a,n))}function Wj(n={}){const{driveTransform:a,auxTransform:r}=n,o=Pt(),u=oe(D=>D.session?.assignment?.roverId??null),f=oe(D=>D.session?.roster??[]),p=m.useMemo(()=>!u||!Array.isArray(f)?null:f.find(D=>String(D.id)===String(u))||null,[u,f]),h=m.useMemo(()=>!p?.cameraServo||!p.cameraServo.enabled?null:p.cameraServo,[p]),g=m.useMemo(()=>!p?.nightVision||!p.nightVision.enabled?null:p.nightVision,[p]),x=m.useMemo(()=>!p?.horn||!p.horn.enabled?null:p.horn,[p]),v=m.useMemo(()=>p?.nightVision?.state??null,[p]),b=m.useCallback((D,V)=>{u&&o.emit("command",{roverId:u,...D},V)},[o,u]),S=m.useCallback(()=>{u&&b({type:"sensorStream",data:{sensorStream:{enable:!0}}})},[b,u]),C=m.useCallback(D=>{if(!u)return null;const V={left:hn(D?.left??0,[-500,500]),right:hn(D?.right??0,[-500,500])},O=a?a(V):V,L={left:hn(O?.left??0,[-500,500]),right:hn(O?.right??0,[-500,500])};return b({type:"drive",data:{driveDirect:L}}),L},[a,b,u]),E=m.useCallback(({main:D=0,side:V=0,vacuum:O=0}={})=>{if(!u)return null;const L={main:hn(D,Ga.main),side:hn(V,Ga.side),vacuum:hn(O,Ga.vacuum)},Y=r?r(L):L,U={main:hn(Y?.main??0,Ga.main),side:hn(Y?.side??0,Ga.side),vacuum:hn(Y?.vacuum??0,Ga.vacuum)};return b({type:"motors",data:{motorPwm:U}}),U},[r,b,u]),N=m.useCallback(D=>!u||!h?null:(b({type:"servo",data:{servo:{angle:D}}}),D),[b,u,h]),w=m.useCallback(D=>{if(!u)return!1;const V=Array.isArray(D)?D:typeof D=="string"?Xj[D]:null;return V?(b({type:"raw",data:{raw:Pj(V)}}),S(),!0):!1},[b,S,u]),j=m.useCallback(async D=>{if(!(!D||!Array.isArray(D.steps)||!u))for(const V of D.steps){if(!u)break;switch(V.type){case"oi":w(V.command);break;case"drive":C(V.speeds??{left:0,right:0});break;case"motors":E(V.values??{});break;case"servo":N(V.angle);break;case"pause":await X0(V.duration??Rd);break}if(V.delay||V.delayMs){const O=V.delayMs??V.delay;typeof O=="number"&&O>0&&await X0(O)}}},[u,w,C,E,N]),T=m.useCallback((D="toggle")=>!u||!g?null:(b({type:"nightVision",data:{nightVision:{action:D}}}),D),[b,g,u]),k=m.useCallback(D=>u?(b({type:"horn",data:{horn:D}}),D):null,[b,u]),R=m.useCallback((D=[],V={})=>{if(!u)return null;const L=(Array.isArray(D)&&D.length>0?D:[{note:Za,duration:Td}]).slice(0,16).map(Y=>({note:hn(Math.round(Y?.note??Za),af),duration:hn(Math.round(Y?.duration??Td),[1,255])}));return b({type:"song",data:{song:{notes:L,slot:V.slot,loop:V.loop}}}),L},[b,u]);return m.useMemo(()=>({roverId:u,rosterEntry:p,servoConfig:h,nightVision:g,nightVisionState:v,horn:x,emitCommand:b,enableSensorStream:S,sendDriveDirect:C,sendAuxMotors:E,sendServoAngle:N,sendOiCommand:w,sendNightVision:T,sendHorn:k,sendSong:R,runMacroSteps:j}),[u,p,h,g,v,x,b,S,C,E,N,w,T,k,j])}const eN={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\",_:"-","+":"="},Q0={"[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash","-":"Minus","=":"Equal","`":"Backquote"};function Sr(n){if(typeof n!="string")return"";const a=n.toLowerCase();return eN[a]??a}function tN(n){const a=Sr(n);if(!a)return null;if(Q0[a])return Q0[a];if(a.length===1){if(/[a-z]/.test(a))return`Key${a.toUpperCase()}`;if(/[0-9]/.test(a))return`Digit${a}`}return null}function Sg(n){const a=Sr(n);return a?`key:${a}`:null}function nN(n){const a=tN(n);return a?`code:${a}`:null}function K0(n){const a=new Set,r=Sg(n?.key??"");r&&a.add(r);const o=n?.code?`code:${n.code}`:null;return o&&a.add(o),Array.from(a)}function sN(n={}){return Object.fromEntries(Object.entries(n).map(([a,r])=>{const o=Array.isArray(r)?r:[r],u=new Set;return o.forEach(f=>{const p=Sg(String(f));p&&u.add(p);const h=nN(String(f));h&&u.add(h)}),[a,u]}))}function Tt(n){const a=Sr(n);return a?a===" "?"Space":a==="\\"?"Backslash":a==="`"?"Backtick":a==="["?"[ or {":a==="]"?"] or }":a===";"?"; or :":a==="'"?`' or "`:a===","?", or <":a==="."?". or >":a==="/"?"/ or ?":a==="-"?"- or _":a==="="?"= or +":a==="arrowup"?"Arrow Up":a==="arrowdown"?"Arrow Down":a==="arrowleft"?"Arrow Left":a==="arrowright"?"Arrow Right":a.length===1?a.toUpperCase():a:"—"}const En={keyboard:{baseSpeed:250,turboSpeed:400,precisionSpeed:125,tiltSpeed:90,tiltIntervalMs:110}},Wn={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}]}}},Es={activeSignature:null,profiles:{},defaults:{profile:Wn}},ta={waveform:"saw",freqs:[440,550,660,0]},it={masterVolume:1,alertVolume:.5,roverVolume:1,mainBrushDuckEnabled:!0,mainBrushDuckAmount:.75},Ws=[{key:"drive",motors:["leftWheel","rightWheel"]},{key:"aux",motors:["mainBrush","sideBrush"]}],aN={downRatePerSec:.15,upRatePerSec:.7,releaseDelaySec:1,outputRateMs:250};function Z0(){return Ws.reduce((n,a)=>(n[a.key]={cap:1,clearSec:0},n),{})}function J0(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function jg(n,a={}){const r=oe(j=>j.session?.role||null),f=(Wt(n)?.sensors||{})?.wheelOvercurrents||{},p=m.useMemo(()=>({...aN,...a.config||{}}),[a.config]),[h,g]=m.useState(()=>Z0()),x=m.useRef(0),v=m.useRef(f);m.useEffect(()=>{v.current=f||{}},[f]),m.useEffect(()=>{g(Z0()),x.current=0},[n]);const b=m.useMemo(()=>Ws.some(j=>j.motors.some(T=>!!f?.[T])),[f]),S=m.useMemo(()=>Object.values(h||{}).some(j=>(Number.isFinite(j?.cap)?j.cap:1)<.999),[h]),C=!!n&&(b||S);m.useEffect(()=>{if(!C)return;x.current=typeof performance<"u"?performance.now():Date.now();const j=setInterval(()=>{const T=typeof performance<"u"?performance.now():Date.now(),k=Math.max(0,T-x.current);x.current=T;const R=Math.min(.25,k/1e3);R<=0||g(D=>{let V=!1;const O={},L=Number.isFinite(p.downRatePerSec)?Math.max(0,p.downRatePerSec):0,Y=Number.isFinite(p.upRatePerSec)?Math.max(0,p.upRatePerSec):0,U=Number.isFinite(p.releaseDelaySec)?Math.max(0,p.releaseDelaySec):0;return Ws.forEach(X=>{const Q=D[X.key]||{cap:1,clearSec:0},ce=Number.isFinite(Q.cap)?Q.cap:1,ue=Number.isFinite(Q.clearSec)?Q.clearSec:0,W=X.motors.some(P=>!!v.current?.[P]),B=W?0:ue+R,I=!W&&B>=U,K=J0(W?ce-L*R:I?ce+Y*R:ce);(Math.abs(K-ce)>1e-4||Math.abs(B-ue)>1e-4)&&(V=!0),O[X.key]={cap:K,clearSec:B}}),V?O:D})},100);return()=>clearInterval(j)},[p.downRatePerSec,p.releaseDelaySec,p.upRatePerSec,n,C]);const E=m.useMemo(()=>{const j=Ws.reduce((T,k)=>{const R=h?.[k.key],D=Number.isFinite(R?.cap)?R.cap:1;return T[k.key]=J0(D),T},{});return{perGroup:j,drive:{left:j.drive??1,right:j.drive??1},aux:{main:j.aux??1,side:j.aux??1,vacuum:1}}},[h]),N=m.useMemo(()=>{const j={};Ws.forEach(k=>{k.motors.forEach(R=>{j[R]=!!f?.[R]})});const T=Ws.reduce((k,R)=>(k[R.key]=R.motors.some(D=>!!f?.[D]),k),{});return{motors:j,groups:T}},[f]),w=r==="admin"||r==="lockdown"||r==="lockdown-admin";return m.useMemo(()=>({caps:h,overcurrent:N,scales:E,isActive:(E?.drive?.left??1)<1||(E?.drive?.right??1)<1||(E?.aux?.main??1)<1||(E?.aux?.side??1)<1,config:p,adminImmune:w}),[h,N,E,p,w])}function lN(n={},a,r=!1){if(r||!a?.drive)return n;const o=typeof a.drive.left=="number"?a.drive.left:1,u=typeof a.drive.right=="number"?a.drive.right:1;return o>=.999&&u>=.999?n:{left:Math.round((n.left??0)*o),right:Math.round((n.right??0)*u)}}function rN(n={},a,r=!1){if(r||!a?.aux)return n;const o=typeof a.aux.main=="number"?a.aux.main:1,u=typeof a.aux.side=="number"?a.aux.side:1,f=typeof a.aux.vacuum=="number"?a.aux.vacuum:1;return o>=.999&&u>=.999&&f>=.999?n:{main:Math.round((n.main??0)*o),side:Math.round((n.side??0)*u),vacuum:Math.round((n.vacuum??0)*f)}}const Ng=m.createContext(null);function P0(n){return Object.fromEntries(Object.entries(n||{}).map(([a,r])=>[a,Array.isArray(r)?[...r]:[]]))}function iN(n,a){if(!n)return a;const r=typeof n.minAngle=="number"?n.minAngle:-45,o=typeof n.maxAngle=="number"?n.maxAngle:45;return Ja(a,r,o)}function oN(n=[]){if(!Array.isArray(n)||n.length<3)return n;const a=n.slice(-3),[r,o,u]=a,f=r?.type==="drive"&&Number(r?.speeds?.left)===-300&&Number(r?.speeds?.right)===-300,p=o?.type==="pause"&&Number(o?.duration)===600,h=u?.type==="drive"&&Number(u?.speeds?.left)===0&&Number(u?.speeds?.right)===0;return!f||!p||!h?n:n.slice(0,-3)}function cN({children:n}){const[a,r]=m.useReducer(Kj,I0),o=m.useRef(null),u=m.useRef(!1),f=m.useRef(I0.camera.angle),p=m.useRef(null),h=m.useRef(0),g=m.useRef(0),{value:x,save:v}=Ve("controls",{keymap:ir,macros:yg}),{value:b}=Ve("page",{driveMacroBackoffEnabled:!0}),{value:S}=Ve("horn",ta),C=typeof b?.driveMacroBackoffEnabled=="boolean"?b.driveMacroBackoffEnabled:!0,E=oe(ae=>ae.session?.assignment?.roverId??null),N=oe(ae=>ae.session?.homeAssistant?.entities??[]),{homeAssistantSetState:w}=$t(),j=jg(E),T=m.useCallback(ae=>lN(ae,j.scales,j.adminImmune),[j.adminImmune,j.scales]),k=m.useCallback(ae=>rN(ae,j.scales,j.adminImmune),[j.adminImmune,j.scales]),R=Wj({driveTransform:T,auxTransform:k}),D=m.useCallback(()=>{const re=(N||[]).filter(de=>(de.type==="light"||de.type==="switch")&&de.available!==!1&&de.state!=="on");if(re.length===0){u.current=!1;return}u.current=!0,re.forEach(de=>{w(de.id,"on").catch(()=>{})}),u.current=!1},[N,w]);m.useEffect(()=>{r({type:"control/set-rover",payload:R.roverId})},[R.roverId]),m.useEffect(()=>{const ae=o.current;o.current=a.mode,ae!=="drive"&&a.mode==="drive"&&N?.length?D():ae!=="drive"&&a.mode==="drive"&&(u.current=!0)},[a.mode,N,D]),m.useEffect(()=>{u.current&&N?.length&&D()},[N,D]),m.useEffect(()=>{const ae={...ir,...x?.keymap||{}};r({type:"control/set-keymap",payload:ae}),x?.macros&&r({type:"control/set-macros",payload:x.macros})},[x?.keymap,x?.macros]),m.useEffect(()=>{const ae=R.servoConfig;if(!ae){r({type:"control/set-camera-config",payload:{config:null}}),f.current=null;return}const re=typeof ae.minAngle=="number"?ae.minAngle:-45,de=typeof ae.maxAngle=="number"?ae.maxAngle:45,fe=typeof ae.homeAngle=="number"?ae.homeAngle:(re+de)/2,Re=typeof f.current=="number"?Ja(f.current,re,de):null,ne=Re??Ja(fe,re,de);r({type:"control/set-camera-config",payload:{config:ae,angle:ne}}),f.current=ne},[R.servoConfig]),m.useEffect(()=>{f.current=typeof a.camera.angle=="number"?a.camera.angle:f.current},[a.camera.angle]),m.useEffect(()=>{R.roverId&&R.enableSensorStream()},[R.roverId,R.enableSensorStream]);const V=m.useCallback(ae=>{r({type:"control/set-mode",payload:ae})},[]),O=m.useCallback(()=>{r({type:"control/record-intent"})},[]),L=m.useRef(a.drive.speeds),Y=m.useRef(a.aux),U=m.useMemo(()=>JSON.stringify(j.scales),[j.scales]),X=m.useRef(0),Q=m.useRef(0);m.useEffect(()=>{L.current=a.drive.speeds},[a.drive.speeds]),m.useEffect(()=>{Y.current=a.aux},[a.aux]),m.useEffect(()=>{if(!R.roverId||j.adminImmune||!j.isActive)return;const ae=Math.max(0,Number(j?.config?.outputRateMs)||0),re=typeof performance<"u"?performance.now():Date.now(),de=L.current||{left:0,right:0},fe=Y.current||{main:0,side:0,vacuum:0},Re=!!(de.left||de.right),ne=!!(fe.main||fe.side||fe.vacuum);!Re&&!ne||(Re&&re-X.current>=ae&&(X.current=re,R.sendDriveDirect(de)),ne&&re-Q.current>=ae&&(Q.current=re,R.sendAuxMotors(fe)))},[U,j.adminImmune,j.config,j.isActive,R]);const ce=m.useCallback((ae,re={})=>{const de={...re.speedOptions||{}};if(a.manualDockAssist?.active){const Re=Math.max(1,Math.min(Yj,500));de.maxSpeed=Math.min(typeof de.maxSpeed=="number"?de.maxSpeed:Re,Re),de.baseSpeed=Math.min(typeof de.baseSpeed=="number"?de.baseSpeed:Re,Re),de.boostSpeed=Math.min(typeof de.boostSpeed=="number"?de.boostSpeed:Re,Re)}const fe=Jj(ae,de);r({type:"control/update-drive",payload:{...fe,source:re.source??null}}),O(),R.sendDriveDirect(fe.speeds)},[R,O,a.manualDockAssist?.active]),ue=m.useCallback((ae={})=>{const re=R.sendAuxMotors(ae)??ae;r({type:"control/set-aux-motors",payload:re}),O()},[R,O]),W=m.useCallback((ae,re)=>{if(!ae)return!1;const de=Sr(re);if(!de)return!1;const fe=P0(a.keymap);return fe[ae]=[de],r({type:"control/set-keymap",payload:fe}),v(Re=>({...Re??{},keymap:fe})),!0},[a.keymap,v]),B=m.useCallback(()=>{const ae=P0(ir);r({type:"control/set-keymap",payload:ae}),v(re=>({...re??{},keymap:ae}))},[v]),I=m.useCallback((ae,re={})=>{if(!R.servoConfig)return;const de=!!re?.force;if(a.manualDockAssist?.active&&!de)return;const fe=iN(R.servoConfig,ae);r({type:"control/set-camera-angle",payload:fe}),R.sendServoAngle(fe),f.current=fe,O()},[R,O,a.manualDockAssist?.active]),K=m.useCallback((ae=0)=>{const re=R.servoConfig;if(!re)return;const de=typeof ae=="number"&&ae!==0?ae:re.nudgeDegrees||1,fe=typeof f.current=="number"?f.current:typeof re.homeAngle=="number"?re.homeAngle:0;I(fe+de)},[R.servoConfig,I]),P=m.useCallback(()=>{const ae=R.servoConfig;if(!ae)return;const re=typeof ae.homeAngle=="number"?ae.homeAngle:typeof ae.minAngle=="number"&&typeof ae.maxAngle=="number"?(ae.minAngle+ae.maxAngle)/2:0;I(re)},[R.servoConfig,I]),ie=m.useCallback(async ae=>{const re=a.macros.find(fe=>fe.id===ae)||null;if(!re)return;let de=re;ae==="drive-sequence"&&(D(),N?.length||(u.current=!0),O(),C||(de={...re,steps:oN(re.steps)})),await R.runMacroSteps(de)},[C,R,O,N,a.macros,D]),M=m.useCallback(()=>{r({type:"control/update-drive",payload:{vector:{x:0,y:0,boost:!1},speeds:{left:0,right:0},source:"system-stop"}}),R.sendDriveDirect({left:0,right:0}),R.sendAuxMotors({main:0,side:0,vacuum:0})},[R]),q=m.useCallback(ae=>{R.sendOiCommand(ae)},[R]),Z=m.useCallback(ae=>{R.roverId&&R.emitCommand({type:"sensorStream",data:{sensorStream:{enable:ae}}})},[R]),le=m.useCallback(ae=>{if(R.nightVision){if(typeof ae=="boolean"){const re=ae?"off":"on";R.sendNightVision(re)}else R.sendNightVision("toggle");O()}},[R,O]),he=m.useCallback(()=>{le()},[le]),we=m.useCallback(ae=>{const re=typeof ae=="number"?ae:Za;return r({type:"control/set-song-note",payload:re}),re},[]),pe=m.useCallback((ae,re)=>R.sendSong(ae,re),[R]),xe=m.useMemo(()=>{const ae=S??ta,re=ae.waveform==="sine"?"sine":"saw",fe=[...Array.isArray(ae.freqs)?ae.freqs:ta.freqs,0,0,0,0].slice(0,4).map(Re=>{const ne=Number(Re);return Number.isFinite(ne)?ne<=0?0:Math.min(5e3,Math.round(ne)):0});return{waveform:re,freqs:fe}},[S]),ge=m.useCallback(()=>{if(!R.horn)return;if(a.horn?.overheated||(a.horn?.heat??0)>=1||a.horn?.active)return!1;const ae=Date.now();return R.sendHorn({action:"start",...xe}),r({type:"control/set-horn-active",payload:!0}),h.current=ae,g.current=ae,p.current&&(clearTimeout(p.current),p.current=null),p.current=setTimeout(()=>{Se()},Ij),O(),!0},[r,xe,R,O,a.horn?.active,a.horn?.heat,a.horn?.overheated]),Se=m.useCallback(()=>{if(!R.horn)return;R.sendHorn({action:"stop"}),r({type:"control/set-horn-active",payload:!1}),p.current&&(clearTimeout(p.current),p.current=null);const ae=Date.now(),re=h.current||ae,de=Math.max(0,ae-re);if(h.current=0,de>0){const fe=a.horn?.heat??0,Re=de/1e3*$i;let ne=Math.max(0,Math.min(1,fe+Re)),me=a.horn?.overheated??!1;ne>=1&&(ne=1,me=!0),r({type:"control/set-horn-heat",payload:{heat:ne,overheated:me}})}},[r,R,a.horn?.heat,a.horn?.overheated,$i]),be=m.useRef({active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}),$e=m.useRef(Se);m.useEffect(()=>{be.current={active:!!a.horn?.active,heat:a.horn?.heat??0,overheated:!!a.horn?.overheated}},[a.horn?.active,a.horn?.heat,a.horn?.overheated]),m.useEffect(()=>{$e.current=Se},[Se]);const Ze=!!a.horn?.active||(a.horn?.heat??0)>0||!!a.horn?.overheated;m.useEffect(()=>{if(!Ze)return;const re=setInterval(()=>{const de=Date.now(),fe=g.current||de;g.current=de;const Re=Math.min(1e3,Math.max(0,de-fe))/1e3,ne=be.current,me=ne.heat??0,De=!!ne.active,en=!!ne.overheated,tn=Re*(De?$i:-Y0);let nn=Math.max(0,Math.min(1,me+tn)),Nt=en;nn>=1?(nn=1,Nt=!0,De&&$e.current()):Nt&&nn<=F0&&(Nt=!1),(nn!==me||Nt!==en)&&r({type:"control/set-horn-heat",payload:{heat:nn,overheated:Nt}})},100);return()=>clearInterval(re)},[r,Ze,Y0,F0,$i]);const je=m.useCallback(ae=>{const re=!!ae;if(!!a.manualDockAssist?.active===re)return;if(r({type:"control/set-manual-dock-assist",payload:re}),!re){I(0,{force:!0});return}const fe=typeof R.servoConfig?.minAngle=="number"?R.servoConfig.minAngle:-45;I(fe,{force:!0}),R.sendSong([{note:76,duration:10},{note:83,duration:10}],{slot:0}),O()},[R,O,I,a.manualDockAssist?.active]),lt=m.useCallback(()=>{je(!a.manualDockAssist?.active)},[je,a.manualDockAssist?.active]),Ie=m.useCallback((ae,re)=>{r({type:"control/register-input-state",payload:{source:ae,state:re}})},[]),ft=m.useCallback(ae=>{r({type:"control/set-mic-ptt",payload:!!ae})},[]),Ae=m.useMemo(()=>({state:a,dispatch:r,pipeline:R,overcurrentLimiter:j,actions:{setMode:V,setDriveVector:ce,setAuxMotors:ue,setServoAngle:I,nudgeServo:K,goServoHome:P,runMacro:ie,stopAllMotion:M,sendOiCommand:q,setSensorStream:Z,setNightVision:le,toggleNightVision:he,updateKeyBinding:W,resetKeyBindings:B,registerInputState:Ie,setManualDockAssistActive:je,toggleManualDockAssist:lt,setSongNote:we,sendSong:pe,startHorn:ge,stopHorn:Se,setMicPttActive:ft}}),[a,R,j,V,ce,ue,I,K,P,ie,M,q,Z,le,he,W,B,Ie,je,lt,we,pe,ge,Se,ft]);return l.jsx(Ng.Provider,{value:Ae,children:n})}function yt(){const n=m.useContext(Ng);if(!n)throw new Error("useControlSystem must be used within ControlSystemProvider");return n}const uN="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=",wg=m.createContext({messages:[],typing:[],sendMessage:async()=>{},focusChat:()=>{},blurChat:()=>{},registerInputRef:()=>{},onInputFocus:()=>{},onInputBlur:()=>{},setTypingActive:()=>{},isChatFocused:!1});function dN({children:n}){const a=Pt(),r=oe(K=>K.session),{pushAlert:o}=$t(),{value:u}=Ve("audio",it),{value:f}=Ve("profile",{nickname:"",profileImageUrl:""}),[p,h]=m.useState([]),[g,x]=m.useState([]),[v,b]=m.useState(!1),S=m.useRef(null),C=m.useRef(null),E=m.useRef(null),N=m.useRef(new Map),w=m.useRef(new Map),j=m.useRef({isTyping:!1,lastSent:0}),T=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,k=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,R=Math.max(0,Math.min(1,T*k)),V=!!r?.isVerified?String(f?.profileImageUrl||"").trim():"",O=m.useCallback(()=>{const K=Array.from(N.current.values()).sort((P,ie)=>P.lastUpdate-ie.lastUpdate).map(P=>P.payload);x(K)},[]),L=m.useCallback(K=>!K||typeof K!="object"?null:K.typingId?K.typingId:K.fromDiscord?`discord:${K.discordUserId||K.discordUserName||K.nickname||"unknown"}`:`socket:${K.socketId||K.nickname||"unknown"}`,[]);m.useEffect(()=>{E.current=new Audio(uN),E.current.volume=R,E.current.load()},[R]);const Y=m.useCallback(()=>{const K=E.current;K&&(K.volume=R,K.currentTime=0,K.play().catch(()=>{}))},[R]);m.useEffect(()=>{function K(P={}){h(ie=>[...ie.slice(-99),P]),!(P?.socketId&&r?.socketId&&P.socketId===r.socketId)&&(Y(),o?.({kind:"chat",payload:P,id:`chat-${P.id||Math.random().toString(36).slice(2)}`,receivedAt:Date.now()}))}return a.on("chat:message",K),()=>{a.off("chat:message",K)}},[Y,r?.socketId,a]),m.useEffect(()=>{function K(P={}){const ie=L(P);if(!ie)return;const M=Date.now();if(P?.socketId&&r?.socketId&&P.socketId===r.socketId){P.isTyping||(N.current.delete(ie),O());return}if(P.isTyping){N.current.set(ie,{payload:P,expiresAt:M+6e3,lastUpdate:M});const q=w.current.get(ie)||0;M-q>=2500&&(w.current.set(ie,M),o?.({kind:"chat-typing",payload:P,id:`chat-typing-${ie}-${P.id||Math.random().toString(36).slice(2)}`,receivedAt:M}))}else N.current.delete(ie);O()}return a.on("chat:typing",K),()=>{a.off("chat:typing",K)}},[o,O,L,r?.socketId,a]),m.useEffect(()=>{const K=setInterval(()=>{const P=Date.now();let ie=!1;N.current.forEach((M,q)=>{M.expiresAt<=P&&(N.current.delete(q),ie=!0)}),ie&&O()},2e3);return()=>clearInterval(K)},[O]),m.useEffect(()=>{function K(P=[]){Array.isArray(P)&&h(ie=>{if(ie.length===0)return P.slice(-100);const M=new Set(P.map(Z=>Z?.id));return[...P,...ie.filter(Z=>Z?.id&&!M.has(Z.id))].slice(-100)})}return a.on("chat:init",K),()=>{a.off("chat:init",K)}},[a]);const U=m.useCallback(K=>{const P=!!K,ie=Date.now(),M=j.current,q=!P&&M.isTyping;!(P&&(!M.isTyping||ie-M.lastSent>=3500))&&!q||(j.current={isTyping:P,lastSent:ie},a.emit("chat:typing",{isTyping:P}))},[a]),X=m.useCallback((K,P=null)=>new Promise((ie,M)=>{const q={text:K,tts:P};V&&(q.profileImage=V),a.emit("chat:send",q,(Z={})=>{Z.error?M(new Error(Z.error)):ie(Z)})}),[V,a]),Q=m.useCallback((K,P={})=>{(P?.target==="hud"?"hud":"panel")==="hud"?C.current=K:S.current=K},[]),ce=m.useCallback(()=>{b(!0),(C.current||S.current)?.focus()},[]),ue=m.useCallback(()=>{b(!1),C.current?.blur(),S.current?.blur()},[]),W=m.useCallback(()=>b(!0),[]),B=m.useCallback(()=>b(!1),[]),I=m.useMemo(()=>({messages:p,sendMessage:X,focusChat:ce,blurChat:ue,registerInputRef:Q,onInputFocus:W,onInputBlur:B,setTypingActive:U,typing:g,isChatFocused:v,selfSocketId:r?.socketId||null}),[ue,ce,v,p,B,W,Q,X,r?.socketId,U,g]);return l.jsx(wg.Provider,{value:I,children:n})}function lf(){const n=m.useContext(wg);if(!n)throw new Error("useChat must be used inside ChatProvider");return n}let Ag=!1;function sd(n){Ag=!!n}function W0(){return Ag}const fN=new Set(["","text","search","email","password","url","tel","number","date","datetime-local","month","time","week"]);function Cg(n){if(!n||n.nodeType!==1)return!1;const a=n.tagName;if(a==="TEXTAREA"||n.isContentEditable)return!0;if(a!=="INPUT")return!1;const r=n.type?n.type.toLowerCase():"";return fN.has(r)}function mN(){return typeof document>"u"?!1:Cg(document.activeElement)}function al(n={}){const{manageLifecycle:a=!1}=n,{state:{roverId:r,manualDockAssist:o},actions:u}=yt(),p=Wt(r)?.sensors||{},h=p?.chargingState?.label||"",g=!!p?.chargingSources?.homeBase,x=g&&h.toLowerCase()!=="not charging"&&h!=="",v=!!o?.active,b=m.useRef(!1),S=m.useCallback(()=>{u.setManualDockAssistActive(!0)},[u]),C=m.useCallback(()=>{u.setManualDockAssistActive(!1)},[u]),E=m.useCallback(()=>{u.toggleManualDockAssist()},[u]);m.useEffect(()=>{if(!a)return;const T=g&&!b.current;v&&T&&u.sendSong([{note:84,duration:6}],{slot:1}),b.current=g},[u,v,g,a]),m.useEffect(()=>{!a||!v||!x||C()},[v,x,C,a]);const N=x?"Docked and charging":g?"Docked":"Docking assist active",w=x?"good":g?"warn":"active",j=v||g;return m.useMemo(()=>({active:v,docked:g,charging:x,cameraLocked:v,visible:j,statusLabel:N,statusTone:w,enterAssist:S,exitAssist:C,toggleAssist:E}),[v,x,g,S,C,N,w,E,j])}const ad="keyboard",ld={x:0,y:0,boost:!1},rd={main:0,side:0,vacuum:0},ex=af[0],tx=af[1],rf=5,ur=500,dr=1,of=100;function id(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}function hN(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(rf,Math.min(ur,r)):a}function kg(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(dr,Math.min(of,r)):a}function pN(n){const r=(kg(n,n)-dr)/(of-dr),o=ur-r*(ur-rf);return Math.round(o)}function xN(n){const a=hN(n,n),r=(ur-a)/(ur-rf),o=dr+r*(of-dr);return Math.round(o)}function gN(n){return Cg(n?.target)}function dt(n,a){if(!n||n.size===0)return!1;for(const r of a)if(n.has(r))return!0;return!1}function vN(n,a){const r=dt(a.driveForward,n),o=dt(a.driveBackward,n),u=dt(a.driveLeft,n),f=dt(a.driveRight,n),p=dt(a.boostModifier,n),h=dt(a.slowModifier,n);let g=0;r&&!o?g=1:o&&!r&&(g=-1);let x=0;u&&!f?x=-1:f&&!u&&(x=1);const v=h?.4:1;return{x:x*v,y:g*v,boost:p&&!h}}function bN(n,a){if(dt(a.auxAllForward,n))return{main:127,side:127,vacuum:127};const o=dt(a.auxMainForward,n)?127:dt(a.auxMainReverse,n)?-127:0,u=dt(a.auxSideForward,n)?127:dt(a.auxSideReverse,n)?-70:0,f=dt(a.auxVacuumFast,n)?127:dt(a.auxVacuumSlow,n)?50:0;return{main:o,side:u,vacuum:f}}function yN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,nudgeServo:u,runMacro:f,stopAllMotion:p,registerInputState:h,toggleNightVision:g,startHorn:x,stopHorn:v,setMicPttActive:b,setSongNote:S,sendSong:C}}=yt(),E=oe(pe=>pe.session?.homeAssistant||null),N=al(),{homeAssistantSetState:w}=$t(),{focusChat:j,blurChat:T,isChatFocused:k}=lf(),{value:R}=Ve("inputs",En),D=m.useMemo(()=>sN(n.keymap),[n.keymap]),V=m.useMemo(()=>{const pe=new Set;return Object.values(D).forEach(xe=>{xe&&xe.forEach(ge=>pe.add(ge))}),pe},[D]),O=m.useMemo(()=>{const pe=En.keyboard,xe=R?.keyboard??{};return{baseSpeed:id(xe.baseSpeed,pe.baseSpeed),turboSpeed:id(xe.turboSpeed,pe.turboSpeed),precisionSpeed:id(xe.precisionSpeed,pe.precisionSpeed)}},[R?.keyboard]),L=m.useMemo(()=>{const pe=En.keyboard,xe=R?.keyboard??{},ge=kg(typeof xe.tiltSpeed=="number"?xe.tiltSpeed:typeof xe.tiltIntervalMs=="number"?xN(xe.tiltIntervalMs):pe.tiltSpeed,pe.tiltSpeed);return pN(ge)},[R?.keyboard]),Y=m.useMemo(()=>Math.abs(n.camera?.config?.nudgeDegrees||1),[n.camera?.config?.nudgeDegrees]),U=m.useRef(new Set),X=m.useRef(ld),Q=m.useRef(rd),ce=m.useRef(null),ue=m.useRef(null),W=m.useRef(!1),B=m.useCallback(()=>{const pe=new Set(U.current);dt(D.boostModifier,pe);const ge=dt(D.slowModifier,pe)?{baseSpeed:O.precisionSpeed,boostSpeed:O.precisionSpeed}:{baseSpeed:O.baseSpeed,boostSpeed:O.turboSpeed},Se=vN(pe,D),be=bN(pe,D);(Se.x!==X.current.x||Se.y!==X.current.y||Se.boost!==X.current.boost)&&(X.current=Se,r(Se,{source:ad,speedOptions:ge})),(be.main!==Q.current.main||be.side!==Q.current.side||be.vacuum!==Q.current.vacuum)&&(Q.current=be,o(be)),h(ad,{keys:Array.from(pe),vector:Se,aux:be})},[D,O,h,o,r]),I=m.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),K=m.useCallback(()=>{const pe=new Set(U.current),xe=dt(D.cameraUp,pe),ge=dt(D.cameraDown,pe);return(xe?1:0)-(ge?1:0)},[D]),P=m.useCallback(()=>{if(K()===0){I();return}if(ce.current)return;const xe=()=>{const ge=K();if(ge===0){I();return}u(ge*Y),ce.current=setTimeout(xe,L)};ce.current=setTimeout(xe,0)},[K,u,L,Y,I]),ie=m.useCallback(()=>{ue.current&&(clearTimeout(ue.current),ue.current=null)},[]),M=m.useCallback(()=>{const pe=new Set(U.current),xe=dt(D.songNoteUp,pe),ge=dt(D.songNoteDown,pe);return(xe?1:0)-(ge?1:0)},[D]),q=m.useCallback(pe=>{if(pe===0)return;let ge=(typeof n.song?.note=="number"?n.song.note:Za)+pe;ge>tx?ge=ex:ge<ex&&(ge=tx);const Se=S(ge);C([{note:Se,duration:Td}],{slot:0})},[C,S,n.song?.note]),Z=m.useCallback(()=>{if(M()===0){ie();return}if(ue.current)return;const xe=()=>{const ge=M();if(ge===0){ie();return}q(ge),ue.current=setTimeout(xe,Fj)};ue.current=setTimeout(xe,0)},[M,ie,q]),le=m.useCallback(()=>{U.current.clear(),X.current=ld,Q.current=rd,I(),ie(),W.current&&(W.current=!1,v()),b(!1),p(),h(ad,{keys:[],vector:ld,aux:rd})},[h,b,p,v,I,ie]),he=m.useCallback(pe=>{const xe=E;if(!xe?.enabled||!xe?.connected||xe?.lightPolicy?.locked||xe?.lightPolicy?.lockedOn)return;const Se=(xe.entities||[]).filter(be=>(be.type==="light"||be.type==="switch")&&be.available!==!1&&be.state!=="unavailable");if(Se.length!==0){if(pe==="on"){const be=Se.find($e=>$e.state!=="on");be&&w(be.id,"on").catch(()=>{});return}if(pe==="off")for(let be=Se.length-1;be>=0;be-=1){const $e=Se[be];if($e.state==="on"){w($e.id,"off").catch(()=>{});break}}}},[w,E]);m.useEffect(()=>{function pe(Se){if(W0()||gN(Se))return;const be=K0(Se);if(be.length===0)return;const $e=new Set(be);if(dt(D.chatFocus,$e)){Se.preventDefault(),le(),k||j();return}be.some(je=>V.has(je))&&Se.preventDefault();const Ze=be.filter(je=>!U.current.has(je));if(Ze.forEach(je=>U.current.add(je)),Ze.length>0)if(Ze.some(je=>D.driveMacro?.has(je)))N.exitAssist(),a("drive"),f("drive-sequence");else if(Ze.some(je=>D.dockMacro?.has(je)))N.toggleAssist();else if(Ze.some(je=>D.nightVisionToggle?.has(je)))g();else if(Ze.some(je=>D.hornHonk?.has(je))){if(!W.current){const je=x();W.current=!!je}}else Ze.some(je=>D.micPtt?.has(je))?b(!0):Ze.some(je=>D.homeAssistantOn?.has(je))?he("on"):Ze.some(je=>D.homeAssistantOff?.has(je))&&he("off");P(),Z(),B()}function xe(Se){if(W0())return;K0(Se).forEach($e=>U.current.delete($e)),W.current&&!dt(D.hornHonk,U.current)&&(W.current=!1,v()),dt(D.micPtt,U.current)||b(!1),P(),Z(),B()}function ge(){le()}return window.addEventListener("keydown",pe,{capture:!0}),window.addEventListener("keyup",xe,{capture:!0}),window.addEventListener("blur",ge),()=>{window.removeEventListener("keydown",pe,{capture:!0}),window.removeEventListener("keyup",xe,{capture:!0}),window.removeEventListener("blur",ge)}},[V,T,B,P,Z,j,k,D.chatFocus,D.dockMacro,D.driveMacro,D.hornHonk,D.micPtt,le,f,b,a,p,ie,x,v,he,N]);const we=m.useRef(le);return m.useEffect(()=>{we.current=le},[le]),m.useEffect(()=>{we.current()},[n.roverId]),m.useEffect(()=>{W.current=!!n.horn?.active},[n.horn?.active]),m.useEffect(()=>()=>{I(),ie()},[I,ie]),null}const SN=1.6;function Eg(n){if(!n)return"unknown::none::0::0";const a=n.id||"unknown",r=n.mapping||"none",o=Array.isArray(n.axes)?n.axes.length:0,u=Array.isArray(n.buttons)?n.buttons.length:0;return`${a}::${r}::${o}::${u}`}function jN(n){return JSON.parse(JSON.stringify(n??{}))}function Mg(n,a){const r=jN(a);return r.meta={id:n?.id??"Unknown",mapping:n?.mapping??"none",axes:n?.axes?.length??0,buttons:n?.buttons?.length??0},r}function ea(n){return Number.isFinite(n)?Math.max(-1,Math.min(1,n)):0}function nr(n,a){if(!n)return 0;const r=Math.abs(n);return a==="expo"?Math.sign(n)*Math.pow(r,SN):n}function od(n,a){const r=Math.abs(n);if(r<=a)return 0;const o=(r-a)/(1-a);return Math.sign(n)*o}function NN(n,a,r){const o=Math.hypot(n,a);if(o<=r)return{x:0,y:0};const f=(o-r)/(1-r)/o;return{x:n*f,y:a*f}}function fo(n,a){if(!n||!Array.isArray(n.axes))return null;const r=n.axes[a];return Number.isFinite(r)?ea(r):null}function Bd(n,a){if(!n||!Array.isArray(n.buttons))return null;const r=n.buttons[a];if(!r)return null;const o=typeof r.value=="number"?r.value:r.pressed?1:0;return{pressed:!!(r.pressed||o>.5),value:Math.max(0,Math.min(1,o))}}function cd(n,a=[]){for(const r of a)if(r){if(r.kind==="axis"){const o=fo(n,r.index);if(o===null)continue;return{value:r.invert?-o:o,source:r}}if(r.kind==="buttonAxis"){const o=Bd(n,r.index);if(!o)continue;return{value:ea(o.value),source:r}}}return{value:0,source:null}}function wN(n,a=[]){for(const r of a){if(!r||r.kind!=="axisPair")continue;const o=fo(n,r.x),u=fo(n,r.y);if(o===null||u===null)continue;const f=r.invertX?-o:o,p=r.invertY?-u:u;return{x:f,y:p,source:r}}return{x:0,y:0,source:null}}function Ks(n,a=[]){for(const r of a)if(r){if(r.kind==="button"){const o=Bd(n,r.index);if(!o)continue;return{pressed:o.pressed,source:r}}if(r.kind==="axisButton"){const o=fo(n,r.index);if(o===null)continue;const u=r.direction||1,f=typeof r.threshold=="number"?r.threshold:.6;return{pressed:o*u>f,source:r}}if(r.kind==="buttonAxis"){const o=Bd(n,r.index);if(!o)continue;return{pressed:o.value>.5,source:r}}}return{pressed:!1,source:null}}function Rg(n,a){const r=a?.bindings??{},o=a?.calibration??{},u=r.drive??{},f=wN(n,u.sources);let p=ea(f.x),h=ea(f.y);const g=Math.min(Math.max(o.driveDeadzone??.18,0),.8),x=NN(p,h,g);p=nr(x.x,o.driveCurve),h=nr(x.y,o.driveCurve);const v=r.cameraTilt??{},b=cd(n,v.sources),S=Math.min(Math.max(o.cameraDeadzone??.08,0),.8);let C=od(ea(b.value),S);C=nr(C,o.cameraCurve);const E=Math.min(Math.max(o.auxDeadzone??.05,0),.6),N=r.mainBrush??{},w=cd(n,N.sources);let j=od(ea(w.value),E);j=nr(j,o.auxCurve);const T=r.sideBrush??{},k=cd(n,T.sources);let R=od(ea(k.value),E);R=nr(R,o.auxCurve);const D=Ks(n,r.vacuum?.sources),V=Ks(n,r.allAux?.sources),O=Ks(n,r.mainReverse?.sources),L=Ks(n,r.sideReverse?.sources),Y=Ks(n,r.driveMacro?.sources),U=Ks(n,r.dockMacro?.sources),X=Ks(n,r.nightVisionToggle?.sources);return{driveVector:{x:p,y:h,boost:!1},cameraAxis:C,auxAxis:{main:j,side:R},buttons:{vacuum:D.pressed,allAux:V.pressed,mainReverse:O.pressed,sideReverse:L.pressed,driveMacro:Y.pressed,dockMacro:U.pressed,nightVisionToggle:X.pressed},sources:{drive:f.source,cameraTilt:b.source,mainBrush:w.source,sideBrush:k.source,vacuum:D.source,allAux:V.source,mainReverse:O.source,sideReverse:L.source,driveMacro:Y.source,dockMacro:U.source,nightVisionToggle:X.source}}}const rr=new Set;let Qa=null,Wa={pads:[],timestamp:0},Gi=!1,Yi=null;function nx(){return Tg().some(n=>n?.connected!==!1)}function Tg(){if(typeof navigator>"u"||!navigator.getGamepads)return[];const n=navigator.getGamepads();return n?Array.from(n).filter(Boolean):[]}function AN(n){return{index:n.index,id:n.id,mapping:n.mapping,connected:n.connected!==!1,timestamp:n.timestamp,axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0})),signature:Eg(n)}}function mo(){Wa={pads:Tg().map(AN),timestamp:typeof performance<"u"?performance.now():Date.now()},rr.forEach(a=>a(Wa))}function qg(){if(mo(),Wa.pads.length===0){Od();return}Qa=requestAnimationFrame(qg)}function sx(){Qa||(mo(),Wa.pads.length!==0&&(Qa=requestAnimationFrame(qg)))}function Od(){Qa&&(cancelAnimationFrame(Qa),Qa=null)}function Dg(n){if(rr.add(n),!Gi&&typeof window<"u"){const a=()=>{mo(),rr.size!==0&&(nx()?sx():Od())};window.addEventListener("gamepadconnected",a),window.addEventListener("gamepaddisconnected",a),Yi=a,Gi=!0}return nx()?sx():mo(),n(Wa),()=>{rr.delete(n),rr.size===0&&(Od(),Gi&&typeof window<"u"&&(window.removeEventListener("gamepadconnected",Yi),window.removeEventListener("gamepaddisconnected",Yi),Yi=null,Gi=!1))}}function CN(){const[n,a]=m.useState(Wa);return m.useEffect(()=>Dg(a),[]),n}const Ya="gamepad",Zs={x:0,y:0,boost:!1},Js={main:0,side:0,vacuum:0},kN=100,EN=100;function ud(n,a){return n&&a&&n.x===a.x&&n.y===a.y&&n.boost===a.boost}function dd(n,a){return n&&a&&n.main===a.main&&n.side===a.side&&n.vacuum===a.vacuum}function MN(n){return n?Math.hypot(n.x||0,n.y||0):0}function RN(n){return n?!n.main&&!n.side&&!n.vacuum:!0}function TN(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function qN(){const{state:n,actions:{setMode:a,setDriveVector:r,setAuxMotors:o,setServoAngle:u,runMacro:f,toggleNightVision:p,registerInputState:h}}=yt(),g=al(),{value:x,save:v}=Ve("gamepad",Es),b=m.useRef(new Set),S=m.useRef(Zs),C=m.useRef(Js),E=m.useRef({main:!1,side:!1}),N=m.useRef(new Map),w=m.useRef(0),j=m.useRef(0),T=m.useRef(0),k=m.useRef(null),R=m.useCallback(L=>{const Y=L.signature??Eg(L);x?.profiles?.[Y]||b.current.has(Y)||(b.current.add(Y),v(U=>{const X=U??Es;if(X.profiles?.[Y])return X;const Q=X?.defaults?.profile??Wn,ce=Mg(L,Q);return{...X,profiles:{...X.profiles??{},[Y]:ce}}}))},[x?.profiles,v]),D=m.useCallback((L,Y)=>{const U=N.current.get(L)||!1;return N.current.set(L,Y),Y&&!U},[]),V=m.useCallback((L,Y)=>{const U=n.camera?.config;if(!U)return;const X=typeof performance<"u"?performance.now():Date.now(),Q=Y?.cameraMode??"absolute",ce=Math.max(1,Math.min(180,Y?.cameraSensitivity??60));if(Q==="velocity"){const K=Math.min(50,X-T.current||16),P=L*ce*(K/1e3);if(Math.abs(P)<.01)return;const M=(typeof k.current=="number"?k.current:typeof n.camera?.angle=="number"?n.camera.angle:typeof U.homeAngle=="number"?U.homeAngle:0)+P;u(M),k.current=M,T.current=X;return}const ue=typeof U.minAngle=="number"?U.minAngle:-45,W=typeof U.maxAngle=="number"?U.maxAngle:45,B=typeof U.homeAngle=="number"?U.homeAngle:(ue+W)/2,I=L<0?B+L*(B-ue):B+L*(W-B);typeof k.current=="number"&&Math.abs(k.current-I)<.35&&X-T.current<80||(T.current=X,k.current=I,u(I))},[u,n.camera?.angle,n.camera?.config]),O=m.useMemo(()=>x?.activeSignature??null,[x?.activeSignature]);return m.useEffect(()=>Dg(L=>{const Y=TN(L.pads,O);if(!Y){ud(S.current,Zs)||(S.current=Zs,r(Zs,{source:Ya})),dd(C.current,Js)||(C.current=Js,o(Js)),N.current=new Map,E.current={main:!1,side:!1},w.current=0,j.current=0,h(Ya,{connected:!1});return}if(mN()){ud(S.current,Zs)||(S.current=Zs,r(Zs,{source:Ya})),dd(C.current,Js)||(C.current=Js,o(Js)),N.current=new Map,E.current={main:!1,side:!1},h(Ya,{connected:!0,blocked:!0});return}R(Y);const U=Y.signature,X=x?.profiles?.[U]??x?.defaults?.profile??Wn,Q=Rg(Y,X);if(!ud(Q.driveVector,S.current)){const P=typeof performance<"u"?performance.now():Date.now();(MN(Q.driveVector)<.02||P-w.current>=kN)&&(S.current=Q.driveVector,w.current=P,r(Q.driveVector,{source:Ya}))}const ce=X.calibration?.auxSideScale??.55,ue=Math.round(Math.min(Math.abs(Q.auxAxis.main),1)*127),W=Math.round(Math.min(Math.abs(Q.auxAxis.side),1)*127),B=E.current.main?-ue:ue,I=E.current.side?-Math.round(W*ce):Math.round(W*ce);let K={main:Q.auxAxis.main!==0?B:0,side:Q.auxAxis.side!==0?I:0,vacuum:Q.buttons.vacuum?127:0};if(Q.buttons.allAux&&(K={main:127,side:127,vacuum:127}),!dd(K,C.current)){const P=typeof performance<"u"?performance.now():Date.now();(RN(K)||P-j.current>=EN)&&(C.current=K,j.current=P,o(K))}Q.buttons.mainReverse&&D("mainReverse",!0)?E.current.main=!E.current.main:Q.buttons.mainReverse||D("mainReverse",!1),Q.buttons.sideReverse&&D("sideReverse",!0)?E.current.side=!E.current.side:Q.buttons.sideReverse||D("sideReverse",!1),Q.buttons.driveMacro&&D("driveMacro",!0)?(g.exitAssist(),a("drive"),f("drive-sequence")):Q.buttons.driveMacro||D("driveMacro",!1),Q.buttons.dockMacro&&D("dockMacro",!0)?g.toggleAssist():Q.buttons.dockMacro||D("dockMacro",!1),Q.buttons.nightVisionToggle&&D("nightVisionToggle",!0)?p():Q.buttons.nightVisionToggle||D("nightVisionToggle",!1),Math.abs(Q.cameraAxis)>.001&&V(Q.cameraAxis,X.calibration),h(Ya,{connected:!0,signature:U,id:Y.id,index:Y.index,axes:Y.axes,buttons:Y.buttons,drive:Q.driveVector,aux:K,cameraAxis:Q.cameraAxis,bindings:Q.sources})}),[O,R,x?.defaults?.profile,x?.profiles,D,V,h,f,o,r,a,p,g]),null}function _g(n){const a=n?.sensors||{},r=a.oiMode?.label||"Unknown",o=r.toLowerCase(),u=a.chargingState?.label||"",f=!!a.chargingSources?.homeBase,p=f&&u.toLowerCase()!=="not charging"&&u!=="";return{driving:o==="full",docked:f,charging:p,dockedNotCharging:f&&!p,dockingInProgress:!f&&!p&&o==="passive",oiLabel:r,chargingLabel:u}}function Bg(n){const a=Wt(n);return m.useMemo(()=>_g(a),[a])}function Fa({label:n,value:a,tone:r="neutral"}){const o=r==="good"?"border-emerald-200 bg-emerald-600 text-white":r==="warn"?"border-amber-200 bg-amber-600 text-white":r==="bad"?"border-red-200 bg-red-600 text-white":"border-slate-200/30 bg-slate-700 text-slate-100";return l.jsx("div",{className:`flex flex-1 flex-col items-center justify-center rounded-lg border px-0.75 py-0.5 text-center ${o}`,children:l.jsx("span",{className:"text-base font-semibold md:text-lg",children:a})})}function ax({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function fd({label:n,tone:a}){const r=a==="emerald"?"border-emerald-200/70 bg-emerald-600/70 text-emerald-50":a==="amber"?"border-amber-200/70 bg-amber-600/70 text-amber-50":"border-indigo-200/70 bg-indigo-600/70 text-indigo-50";return l.jsx("span",{className:`rounded-full border px-0.5 py-0.15 text-[0.7rem] font-semibold ${r}`,children:n})}function DN({instructions:n,onConfirm:a,onCancel:r,pending:o}){return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/70 p-1",children:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 border border-indigo-700 bg-indigo-950/90 p-1 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold text-indigo-50",children:"Manual Docking Assist"}),l.jsx("p",{className:"text-sm text-slate-200",children:n.summary}),l.jsx(lo,{steps:n.steps,tone:"indigo"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 text-sm",children:[l.jsx("button",{type:"button",onClick:r,className:"bg-slate-700 px-0.5 py-1 font-semibold text-slate-100 transition hover:bg-slate-600",children:"Cancel"}),l.jsx("button",{type:"button",disabled:o,onClick:a,className:"bg-indigo-600 px-0.5 py-1 font-semibold text-indigo-50 transition hover:bg-indigo-500 disabled:opacity-50",children:o?"Starting…":"Enter Assist"})]})]})})}function Og({layout:n="desktop",expand:a=!1,fill:r=!1,driveDockState:o,compactHeightClass:u=""}){const f=n==="mobile",{state:{roverId:p,keymap:h},actions:g}=yt(),x=al(),v=Wt(p),b=o??_g(v),{driving:S,docked:C,charging:E,dockingInProgress:N}=b,[w,j]=m.useState(null),[T,k]=m.useState(!1),[R,D]=m.useState(!1),V=!!x.active,O=!p||w!==null,L=!p||w!==null,Y=Tt(h?.driveMacro?.[0]),U=Tt(h?.dockMacro?.[0]),X={summary:"Use assist mode to manually line up with the dock.",steps:["Line up the center dot of your rover with the center of the dock","The UI will indicate when you are successfully docked","When good contact is made, charging will start in about 5 seconds."]},Q={summary:"You must enable driving mode before you can move the rover.",steps:["Press the keybind or tap this button to enable driving mode","Once ready (should be instant), this dialog will change, and you will be able to move"]},ce=C?"Docked":"Undocked",ue=C?"good":"bad",W=E?"Charging":C?"Charging soon...":"—",B=E?"good":C?"warn":"bad",I=async()=>{if(!(!p||w)){j("drive");try{x.exitAssist(),g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ie){alert(Ie.message)}finally{j(null)}}},K=async()=>{if(!(!p||w)){k(!1),D(!1),j("drive");try{x.exitAssist(),g.setMode("drive"),await g.runMacro("drive-sequence")}catch(Ie){alert(Ie.message)}finally{j(null)}}},P=async()=>{if(!(!p||w)){j("dock");try{x.enterAssist()}catch(Ie){alert(Ie.message)}finally{j(null),k(!1),D(!1)}}},ie=()=>{if(!L){if(V){x.exitAssist();return}D(!0),k(!0)}},M="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",q="text-center",Z="items-center justify-between",le="items-center justify-center",he=f?"text-sm font-semibold":"",we="border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700 focus-visible:ring-emerald-300",pe="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",xe="border-indigo-300/70 bg-indigo-900 text-indigo-50 hover:bg-indigo-800 focus-visible:ring-indigo-300",ge="border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800 focus-visible:ring-amber-300",be=a||N,$e=be?"h-full flex-1":r?"flex-1":"",Ze=f&&!be?u:"",je=f&&!be?le:Z,lt=f&&!be&&S&&C;if(!S&&!N)return l.jsxs("button",{type:"button",onClick:K,onContextMenu:Ie=>Ie.preventDefault(),disabled:O,className:`${M} ${$e} ${Ze} ${q} ${je} ${he} ${we}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-emerald-50 md:text-lg",children:"Start Driving"}),!f&&be?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[Y?l.jsx(ax,{label:Y}):null,l.jsx(fd,{label:"Click to start",tone:"emerald"})]}):null]}),be?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-emerald-50/90",children:Q.summary}),l.jsx(lo,{steps:Q.steps,tone:"emerald"})]}):null]}),be?l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:W,tone:B})]}):null]});if(N){const Ie={summary:"The rover is currently attempting to dock itself due to being idle.",steps:["Click to return to driving mode."]};return l.jsxs("button",{type:"button",disabled:O,onClick:I,onContextMenu:ft=>ft.preventDefault(),className:`${M} ${$e} ${Ze} ${q} ${je} ${he} ${pe}`,children:[l.jsxs("div",{className:"space-y-0.5 w-full",children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-amber-50 md:text-lg",children:"Attempting to auto-dock..."}),be?l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:l.jsx(fd,{label:"Return to driving mode",tone:"emerald"})}):null]}),be?l.jsx("p",{className:"text-sm text-amber-50/90",children:Ie.summary}):null]}),be?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:W,tone:B})]}),f?null:l.jsx(lo,{steps:Ie.steps,tone:"amber"})]}):null]})}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",disabled:L,onClick:ie,onContextMenu:Ie=>Ie.preventDefault(),className:f?`flex w-full ${M} ${Ze} ${q} ${je} ${he} ${lt?ge:xe}`:`${M} ${$e} ${q} ${Z} ${he} ${xe}`,children:[l.jsxs("div",{className:"flex w-full flex-col items-center gap-0.25",children:[l.jsx("span",{className:"text-base font-semibold text-indigo-50 md:text-lg",children:lt?"Docked!":V?"Exit Docking Assist":"Dock and charge"}),!f&&be?l.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-0.5",children:[U?l.jsx(ax,{label:U}):null,l.jsx(fd,{label:V?"Click to exit assist":"Click to enable assist",tone:"indigo"})]}):null]}),!f&&be&&l.jsxs(l.Fragment,{children:[l.jsx(lo,{steps:X.steps,tone:"indigo"}),l.jsxs("div",{className:"flex w-full flex-1 flex-col gap-0.5 self-stretch",children:[l.jsx(Fa,{label:"Dock",value:ce,tone:ue}),l.jsx(Fa,{label:"Charge",value:W,tone:B})]})]})]}),R||!f&&T?l.jsx(DN,{instructions:X,pending:w==="dock",onCancel:()=>{D(!1),k(!1)},onConfirm:P}):null]})}function lo({steps:n,tone:a="emerald"}){const r=a==="emerald"?"bg-emerald-900/60 text-emerald-50/90 border-emerald-700/60":a==="amber"?"bg-amber-900/60 text-amber-50/90 border-amber-700/60":"bg-indigo-900/60 text-indigo-50/90 border-indigo-700/60",o=a==="emerald"?"text-emerald-200":a==="amber"?"text-amber-200":"text-indigo-200";return l.jsx("div",{className:`space-y-0.5 rounded border px-0.5 py-0.35 text-left ${r}`,children:n.map((u,f)=>l.jsxs("div",{className:"text-[0.85rem] leading-snug break-words",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsxs("span",{className:`mr-0 align-top text-[0.75rem] font-semibold ${o}`,children:[f+1,"."]}),l.jsx("span",{className:"align-top",children:u})]}),f<n.length-1?l.jsx("div",{className:"mt-0 h-px bg-white/10"}):null]},u))})}function md(n){return typeof n=="boolean"}function Lg({nightVisionOn:n,disabled:a,onToggle:r,keyLabel:o,className:u="",heightClass:f=""}){const[p,h]=m.useState(md(n)?n:null);m.useEffect(()=>{md(n)&&h(n)},[n]);const g=md(p),x=g?p:!1,v=g?x?"On":"Off":"—",b=x?"bg-emerald-500 text-emerald-950":"bg-slate-700 text-slate-200",S=()=>{if(a)return;const E=g?!x:!0;h(E),r?.(E)},C=m.useMemo(()=>["group flex w-full flex-col items-center justify-center gap-0.35 rounded-xl border-2 px-1 py-0.75 text-center select-none no-touch-select",x?"border-emerald-300/70 bg-emerald-800 text-emerald-50 hover:bg-emerald-700":"border-amber-300/70 bg-amber-900 text-amber-50 hover:bg-amber-800","disabled:opacity-50",f,u].filter(Boolean).join(" "),[u,x,f]);return l.jsxs("button",{type:"button",onClick:S,onContextMenu:E=>E.preventDefault(),disabled:a,"aria-pressed":x,className:C,children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-sm font-semibold",children:"Night Vision"}),o?l.jsx("span",{className:"rounded bg-slate-800 px-1 py-0.5 text-[0.6rem] font-semibold text-slate-200",children:o}):null]}),l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.7rem] font-semibold ${b}`,children:v})]})}function hd(n){const a=Number(n);return!Number.isFinite(a)||a<=0?0:Math.min(5e3,Math.round(a))}function zg({disabled:n,onStart:a,onStop:r,keyLabel:o,active:u,heat:f=0,className:p="",defaultShowSettings:h=!0,showSettingsToggle:g=!1,compactSettings:x=!1}){const[v,b]=m.useState(!1),[S,C]=m.useState(h),{value:E,save:N}=Ve("horn",ta),[w,j]=m.useState(E?.waveform||ta.waveform),[T,k]=m.useState(()=>[...Array.isArray(E?.freqs)?E.freqs:ta.freqs,0,0,0,0].slice(0,4).map(B=>hd(B)));m.useEffect(()=>{j(E?.waveform||ta.waveform),Array.isArray(E?.freqs)&&k([...E.freqs,0,0,0,0].slice(0,4).map(W=>hd(W)))},[E?.freqs,E?.waveform]);const R=!!u,D=Math.max(0,Math.min(1,Number(f)||0)),V=m.useMemo(()=>["group relative flex w-full flex-col gap-0.5 overflow-hidden rounded-xl border-2 px-1 py-1.5 text-xs font-semibold select-none no-touch-select",R?"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",p].filter(Boolean).join(" "),[p,R]),O=()=>{n||v||(b(!0),a?.())},L=()=>{v&&(b(!1),r?.())};m.useEffect(()=>{!R&&v&&b(!1)},[R,v]);const Y=w==="sine"?"sine":"saw",U=m.useCallback(W=>{const B=W.target.value==="sine"?"sine":"saw";j(B),N(I=>({...I??{},waveform:B}))},[N]),X=m.useCallback((W,B)=>{k(I=>{const K=[...I];return K[W]=hd(B),N(P=>({...P??{},freqs:K})),K})},[N]),Q=W=>{if(n)return;const B=W.target?.tagName?.toLowerCase();B==="input"||B==="select"||B==="option"||B==="label"||B==="button"||(W.preventDefault(),O())},ce=W=>{const B=W.target?.tagName?.toLowerCase();B==="input"||B==="select"||B==="option"||B==="label"||B==="button"||(W.preventDefault(),L())},ue=g?l.jsx("button",{type:"button",onClick:W=>{W.preventDefault(),C(B=>!B)},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 l.jsxs("div",{role:"button",tabIndex:0,"aria-pressed":v,onPointerDown:Q,onPointerUp:ce,onPointerLeave:L,onPointerCancel:L,onContextMenu:W=>W.preventDefault(),onBlur:L,className:V,children:[l.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-70",style:{background:`linear-gradient(90deg, rgba(14,116,144,0.7) ${D*100}%, rgba(0,0,0,0) ${D*100}%)`}}),l.jsx("div",{className:`pointer-events-none absolute inset-0 transition-opacity ${R?"opacity-40":"opacity-0"}`,style:{background:"linear-gradient(90deg, rgba(217,70,239,0.75), rgba(244,114,182,0.35))"}}),l.jsxs("div",{className:"relative z-10 flex items-center justify-between gap-0.5",children:[l.jsxs("span",{className:"flex items-center gap-0.5 text-sm font-semibold",children:[l.jsx("span",{children:"Horn"}),o?l.jsx("span",{className:"rounded bg-black/40 px-1 py-0.5 text-[0.6rem] font-semibold text-white",children:o}):null]}),ue,l.jsx("span",{className:`rounded px-1 py-0.5 text-[0.65rem] font-semibold ${R?"bg-fuchsia-200 text-fuchsia-900":"bg-slate-800 text-slate-200"}`,children:R?"Honk":"Hold"})]}),S?x?l.jsxs("div",{className:"relative z-10 flex flex-col gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:Y,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:T.map((W,B)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:B+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:W,onChange:I=>X(B,I.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-${B}`))})]}):l.jsxs("div",{className:"relative z-10 grid grid-cols-[minmax(0,1.2fr)_repeat(4,minmax(0,1fr))] items-center gap-0.5 text-[0.65rem]",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-slate-300",children:"Wave"}),l.jsxs("select",{value:Y,onChange:U,className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.65rem] text-slate-100",children:[l.jsx("option",{value:"saw",children:"Saw"}),l.jsx("option",{value:"sine",children:"Sine"})]})]}),T.map((W,B)=>l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("span",{className:"text-[0.6rem] text-slate-400",children:B+1}),l.jsx("input",{type:"number",min:0,max:5e3,step:1,value:W,onChange:I=>X(B,I.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-${B}`))]}):null]})}function Fi(n){return typeof n!="number"||Number.isNaN(n)?"—":`${n>0?"+":""}${n.toFixed(1)}°`}function lx({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Ug({value:n,min:a,max:r,step:o=.5,label:u="Camera Tilt",orientation:f="horizontal",onChange:p,onCommit:h,throttleMs:g=0,disabled:x=!1,keyDownLabel:v,keyUpLabel:b,className:S="",labelRowClass:C="",labelClass:E="",valueClass:N="",sliderClass:w="",endpointClass:j="",endpointLabelClass:T="",accentClass:k="",showValue:R=!0,showEndpoints:D}){const V=f==="vertical",L=typeof D=="boolean"?D:!V,[Y,U]=m.useState(n),X=m.useRef(!1),Q=m.useRef(null);m.useEffect(()=>{X.current||U(n)},[n]),m.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const ce=K=>{if(p){if(g>0){Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{p(K)},g);return}p(K)}},ue=K=>{const P=Number.parseFloat(K.target.value);Number.isNaN(P)||(X.current=!0,U(P),ce(P))},W=()=>{X.current=!1,Q.current&&(clearTimeout(Q.current),Q.current=null),h?h(Y):g>0&&p?.(Y)};if(typeof a!="number"||typeof r!="number")return null;const B=[V?"h-28 w-5":"w-full",k,w].filter(Boolean).join(" "),I=l.jsx("input",{type:"range",orient:V?"vertical":void 0,min:a,max:r,step:o,value:Number.isFinite(Y)?Y:a,onChange:ue,onMouseUp:W,onTouchEnd:W,onPointerUp:W,disabled:x,className:B,style:V?{writingMode:"bt-lr",WebkitAppearance:"slider-vertical"}:void 0});return V?l.jsxs("div",{className:`flex h-full flex-col items-center gap-0.5 ${S}`.trim(),children:[R?l.jsx("div",{className:`flex flex-col items-center ${C}`.trim(),children:l.jsx("span",{className:N,children:Fi(n)})}):null,l.jsxs("div",{className:"flex min-h-0 flex-1 items-center gap-0.5",children:[l.jsx("span",{className:E,children:u}),I]})]}):l.jsxs("div",{className:`space-y-0.5 ${S}`.trim(),children:[l.jsxs("div",{className:`flex items-center justify-between ${C}`.trim(),children:[l.jsx("span",{className:E,children:u}),R?l.jsx("span",{className:N,children:Fi(n)}):null]}),l.jsxs("div",{children:[I,L?l.jsxs("div",{className:`mt-0 flex items-center justify-between ${j}`.trim(),children:[l.jsxs("span",{className:`flex items-center gap-0.5 ${T}`.trim(),children:[v?l.jsx(lx,{label:v}):null,Fi(a)]}),l.jsxs("span",{className:`flex items-center gap-0.5 ${T}`.trim(),children:[Fi(r),b?l.jsx(lx,{label:b}):null]})]}):null]})]})}function _N({disabled:n,layout:a,radius:r,onMove:o,onStop:u}){const f=m.useRef(null),p=m.useRef(null),h=m.useRef({x:0,y:0}),[g,x]=m.useState({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),v=m.useCallback(()=>{p.current=null,x({active:!1,base:{x:0,y:0},knob:{x:0,y:0}}),u?.()},[u]),b=m.useCallback(N=>{if(n||p.current!==null)return;N.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),T=N.clientX-j.left,k=N.clientY-j.top;h.current={x:T,y:k},p.current=N.pointerId,w.setPointerCapture?.(N.pointerId),x({active:!0,base:{x:T,y:k},knob:{x:0,y:0}})},[n]),S=m.useCallback(N=>{if(n||p.current!==N.pointerId)return;N.preventDefault();const w=f.current;if(!w)return;const j=w.getBoundingClientRect(),T=N.clientX-j.left,k=N.clientY-j.top,R=T-h.current.x,D=k-h.current.y,V=Math.min(Math.hypot(R,D),r),O=Math.atan2(D,R),L=Math.cos(O)*V,Y=Math.sin(O)*V,U={x:Pa(L/r),y:Pa(-Y/r),boost:!1};x(X=>({...X,knob:{x:L,y:Y}})),o?.(U)},[n,o,r]),C=m.useCallback(N=>{if(p.current!==N.pointerId)return;N.preventDefault(),f.current?.releasePointerCapture?.(N.pointerId),v()},[v]);return m.useEffect(()=>{n&&v()},[n,v]),l.jsxs("div",{ref:f,role:"presentation",className:"relative w-full h-full select-none overflow-hidden rounded-xl border-2 border-slate-700 bg-slate-900/70 text-slate-100 shadow-md",style:{touchAction:"none"},onPointerDown:b,onPointerMove:S,onPointerUp:C,onPointerLeave:C,onPointerCancel:C,onContextMenu:N=>N.preventDefault(),children:[!g.active&&l.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col items-center gap-0 text-center pt-0.5",children:[l.jsx("span",{className:"font-semibold text-slate-200",children:"Joystick area"}),l.jsx("span",{className:"text-sm text-slate-300",children:"Touch and hold to use the joystick"})]}),g.active&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"pointer-events-none absolute h-28 w-28 -translate-x-1/2 -translate-y-1/2 bg-cyan-400/10 outline outline-2 outline-cyan-400/60 [clip-path:circle(50%)]",style:{left:g.base.x,top:g.base.y}}),l.jsx("div",{className:"pointer-events-none absolute h-12 w-12 -translate-x-1/2 -translate-y-1/2 bg-cyan-300/80 shadow-lg [clip-path:circle(50%)]",style:{left:g.base.x+g.knob.x,top:g.base.y+g.knob.y}})]})]})}function rx({id:n,label:a,values:r,color:o,disabled:u,onPress:f,onRelease:p}){return l.jsx("button",{type:"button",disabled:u,onPointerDown:h=>{h.preventDefault(),f(n,r)},onPointerUp:()=>p(n),onPointerLeave:()=>p(n),onPointerCancel:()=>p(n),onContextMenu:h=>h.preventDefault(),className:`flex h-full w-full items-center justify-center rounded-xl border-2 px-1 py-0.75 text-center text-sm font-semibold text-white transition select-none no-touch-select ${o} hover:brightness-110 active:brightness-125 active:scale-[0.99] disabled:opacity-30`,children:a})}const Ii="mobile-joystick",BN=80,ON=.15,LN={main:0,side:0,vacuum:0},zN={main:127,side:127,vacuum:127},UN={main:-127,side:-127,vacuum:-127};function HN({layout:n}){const{state:{roverId:a},actions:{setDriveVector:r,registerInputState:o}}=yt(),u=Bg(a),f=u.docked&&!u.driving,p=f||u.dockingInProgress,h=!a,g=BN,x=ON,v=m.useRef({x:0,y:0,boost:!1});m.useEffect(()=>{h&&(v.current={x:0,y:0,boost:!1})},[h]);const b=m.useCallback((N={})=>{if(h)return;const w={x:Pa(N.x??0),y:Pa(N.y??0),boost:!!N.boost},j={x:v.current.x+(w.x-v.current.x)*(1-x),y:v.current.y+(w.y-v.current.y)*(1-x),boost:w.boost};v.current=j,r(j,{source:Ii}),o(Ii,{vector:j,lastEvent:"move"})},[h,o,r,x]),S=m.useCallback(()=>{if(h)return;const N={x:0,y:0,boost:!1};v.current=N,r(N,{source:Ii}),o(Ii,{vector:N,lastEvent:"stop"})},[h,o,r]),E=`flex h-full flex-col gap-0.5 text-slate-100 ${f?"max-h-screen self-start":""}`;return l.jsxs("div",{className:E,children:[l.jsx(Og,{layout:"mobile",expand:p,driveDockState:u,compactHeightClass:"min-h-[5rem]"}),p?null:l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(_N,{disabled:h,layout:n,radius:g,onMove:b,onStop:S})})]})}function VN({layout:n}){const{state:{roverId:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,setAuxMotors:h,startHorn:g,stopHorn:x}}=yt(),v=al(),b=!a,S=m.useRef(null),C=r?.config,E=!!(a&&r?.enabled&&C),N=!!(a&&u?.nightVision),w=u?.nightVisionState,j=!!(a&&u?.horn),T=o?.overheated,k=typeof C?.minAngle=="number"?C.minAngle:-45,R=typeof C?.maxAngle=="number"?C.maxAngle:45,D=typeof r?.angle=="number"?r.angle:typeof C?.homeAngle=="number"?C.homeAngle:(k+R)/2,V=!!(b||v.cameraLocked),O=m.useCallback(U=>{N&&p(U)},[N,p]),L=m.useCallback((U,X)=>{b||(S.current=U,h(X))},[b,h]),Y=m.useCallback(U=>{b||S.current===U&&(S.current=null,h(LN))},[b,h]);return l.jsxs("div",{className:"grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-0.5 text-slate-100",children:[l.jsxs("div",{className:"grid min-h-0 grid-rows-2 gap-0.5",children:[l.jsx(rx,{id:"aux-vac-forward",label:"Vacuum Forward",values:zN,color:"bg-fuchsia-600",disabled:b,onPress:L,onRelease:Y}),l.jsx(rx,{id:"aux-vac-backward",label:"Vacuum Backward",values:UN,color:"bg-fuchsia-800",disabled:b,onPress:L,onRelease:Y})]}),l.jsxs("div",{className:"flex min-h-0 items-stretch gap-0.5",children:[E?l.jsx("div",{className:"flex-1 min-h-0 rounded bg-zinc-950 p-0.25",children:l.jsx(Ug,{value:D,min:k,max:R,step:.5,disabled:V,onChange:f,orientation:"vertical",label:"Camera Tilt",labelClass:"text-sm font-semibold text-white [writing-mode:vertical-rl] rotate-180",labelRowClass:"text-[0.7rem] text-slate-300",valueClass:"font-mono text-slate-200",className:"h-full gap-0",sliderClass:"h-full w-7",accentClass:"accent-cyan-400",showEndpoints:!1,showValue:!1})}):null,N?l.jsx(Lg,{nightVisionOn:w?.nightVisionOn,disabled:b,onToggle:O,heightClass:"h-full"}):null]}),l.jsx("div",{className:"min-h-0",children:j?l.jsx(zg,{disabled:b||T,onStart:g,onStop:x,active:o?.active,heat:o?.heat,defaultShowSettings:!1,showSettingsToggle:!0,compactSettings:!0,className:"h-full"}):null})]})}function ho({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx(VN,{layout:n})})}function po({layout:n,className:a=""}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${a}`.trim(),children:l.jsx(HN,{layout:n==="landscape"?"landscape":"portrait"})})}function $N({swapColumns:n=!1}){const a="h-[min(60svh,24rem)]",r=n?l.jsx(po,{layout:"portrait",className:a}):l.jsx(ho,{layout:"portrait",className:a}),o=n?l.jsx(ho,{layout:"portrait",className:a}):l.jsx(po,{layout:"portrait",className:a});return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"grid grid-cols-2 gap-0.5 items-stretch",children:[r,o]})})}function GN(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,S]=m.useState(0),C=m.useRef(new Map),E=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>S(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),p({})},[x]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,j=(k={},R)=>{if(N||!k.id||!R)return;const D=R.byteLength??R.length??0,V=Date.now(),O=C.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},L={count:O.count+1,totalBytes:O.totalBytes+D,lastLogAt:O.lastLogAt};if(E&&(!L.lastLogAt||V-L.lastLogAt>=1e4)){const Q=L.count?L.totalBytes/L.count:0;console.log("[roomCamera]",k.id,`frame=${D}B`,`avg=${Math.round(Q)}B`,`count=${L.count}`),L.lastLogAt=V}C.current.set(k.id,L);const Y=new Blob([R],{type:"image/jpeg"}),U=URL.createObjectURL(Y),X=h.current.get(k.id);X&&URL.revokeObjectURL(X),h.current.set(k.id,U),p(Q=>({...Q,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:U}}))},T=(k={})=>{N||!k.id||p(R=>({...R,[k.id]:{...R[k.id]||{},status:k.error?"error":R[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||R[k.id]?.ts||null,objectUrl:R[k.id]?.objectUrl||null}}))};return r.on("roomCamera:frame",j),r.on("roomCamera:status",T),r.emit("roomCamera:subscribe",{ids:w},(k={})=>{k.error}),()=>{N=!0,r.emit("roomCamera:unsubscribe",{ids:w}),r.off("roomCamera:frame",j),r.off("roomCamera:status",T),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,x,o,b,E]),f}function YN({feed:n,label:a}){const[r,o]=m.useState(!1);m.useEffect(()=>{n&&(!n.ts&&!n.objectUrl||o(f=>!f))},[n?.ts,n?.objectUrl]);const u=m.useMemo(()=>n?n.error?`Error: ${n.error}`:n.status||"Connecting…":"Connecting…",[n]);return l.jsxs("div",{className:"relative w-full overflow-hidden rounded bg-black",style:{aspectRatio:"4 / 3"},children:[n?.objectUrl?l.jsx("img",{src:n.objectUrl,alt:a,className:"h-full w-full object-cover"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}),l.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bg-black/70 px-0.5 py-0.5 text-xs font-semibold text-white",children:a}),l.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-0 m-0 flex items-center gap-0.5 rounded bg-black/70 px-0.5 py-0.25 text-[0.7rem] text-slate-100",children:[l.jsx("span",{className:`h-2 w-2 rounded-full ${r?"bg-emerald-400":"bg-slate-500"}`}),l.jsx("span",{children:u})]})]})}function FN(){return l.jsxs("div",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-center text-slate-400",children:"No room cameras configured."}),l.jsx("p",{className:"text-center text-slate-500",children:"Add entries to server config to populate this list."})]})}const Hg=["horizontal","vertical"];function pd(n,a){return Hg.includes(n)?n:a}function cf({defaultOrientation:n="horizontal",orientation:a,hideLayoutToggle:r=!1,hideHeader:o=!1,panelId:u=null}){const f=oe(N=>N.session?.roomCameras||[]),p=GN(f.map(N=>({id:N.id}))),{value:h,save:g}=Ve("roomCameraPanels",{}),[x,v]=m.useState(()=>pd(u?h?.[u]:n,"horizontal"));m.useEffect(()=>{if(!u)return;const N=h?.[u];N&&v(pd(N,"horizontal"))},[u,h?.[u]]);const b=a?pd(a,"horizontal"):x,S=b==="vertical"?"flex flex-col gap-0.5":"grid gap-0.5 md:grid-cols-2",C=!r&&!a&&f.length>0,E=N=>{v(N),u&&g(w=>({...w||{},[u]:N}))};return f.length===0?l.jsx(FN,{}):l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[!o&&l.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room cameras"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:C&&l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("span",{className:"text-slate-500",children:"Layout:"}),l.jsx("div",{className:"inline-flex overflow-hidden rounded border border-slate-700",children:Hg.map(N=>l.jsx("button",{type:"button",className:`px-1 py-0.5 ${b===N?"bg-slate-600 text-white":"bg-transparent text-slate-400 hover:text-white"}`,onClick:()=>E(N),children:N==="vertical"?"Vertical":"Grid"},N))})]})})]}),l.jsx("div",{className:S,children:f.map(N=>{const w=p[N.id]||null;return l.jsx("article",{className:"w-full space-y-0.5 rounded bg-zinc-950 p-0.5 shadow-inner shadow-black/40",children:l.jsx(YN,{feed:w,label:N.name||N.id})},N.id)})})]})}function uf(){const n=oe(r=>r.logs),a=m.useMemo(()=>n.slice().reverse(),[n]);return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Server logs"}),l.jsx("span",{children:n.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:n.length===0?l.jsx("p",{children:"No logs yet."}):a.map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.timestamp})," ",l.jsxs("span",{className:"text-lime-400",children:["[",r.level,"]"]})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{children:r.message})]},r.id))})]})}const IN={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"turn:your.turn.server:3478",username:"user",credential:"pass"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function XN(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 QN(n){if(!n)return{};const a=`${n}:${n}`;return{Authorization:`Basic ${XN(a)}`}}class ix{constructor({url:a,token:r,video:o,onStatus:u,audioOnly:f=!1,receiveAudio:p=!0}){this.url=a,this.token=r,this.video=o,this.audioOnly=f,this.receiveAudio=p,this.pc=null,this.abortController=null,this.onStatus=u}notify(a,r){typeof this.onStatus=="function"&&this.onStatus(a,r)}configureVideoElement(){this.video&&(this.video.playsInline=!0,this.video.autoplay=!0,this.video.muted=!this.audioOnly,typeof this.video.disableRemotePlayback<"u"&&(this.video.disableRemotePlayback=!0),"latencyHint"in HTMLMediaElement.prototype&&(this.video.latencyHint="interactive"))}async start(){if(!this.url||!this.video)throw new Error("Media target missing");this.stop(),this.notify("connecting"),this.configureVideoElement(),this.abortController=new AbortController;const a=new RTCPeerConnection(IN);this.pc=a;const r=new MediaStream;a.ontrack=o=>{o.streams[0]?.getTracks().forEach(u=>r.addTrack(u)),this.video.srcObject=r,o.track?.kind==="video"&&"playoutDelayHint"in o.receiver&&(o.receiver.playoutDelayHint=0)},this.audioOnly?a.addTransceiver("audio",{direction:"recvonly"}):(a.addTransceiver("video",{direction:"recvonly"}),this.receiveAudio&&a.addTransceiver("audio",{direction:"recvonly"})),a.onconnectionstatechange=()=>{this.notify(a.connectionState)},a.oniceconnectionstatechange=()=>{const o=a.iceConnectionState;(o==="failed"||o==="disconnected")&&this.notify(o)};try{const o=await a.createOffer({offerToReceiveAudio:this.audioOnly?!0:this.receiveAudio,offerToReceiveVideo:!this.audioOnly});await a.setLocalDescription(o);const u=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/sdp",...QN(this.token)},body:o.sdp,signal:this.abortController.signal});if(!u.ok)throw new Error(`WHEP request failed: ${u.status}`);const f=await u.text();await a.setRemoteDescription({type:"answer",sdp:f}),a.getReceivers().forEach(p=>{"playoutDelayHint"in p&&(p.playoutDelayHint=0)}),await this.video.play().catch(()=>{}),this.notify("playing")}catch(o){throw this.notify("error",o.message),this.stop(),o}}stop(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.pc&&(this.pc.getSenders().forEach(a=>a.track?.stop()),this.pc.getReceivers().forEach(a=>a.track?.stop()),this.pc.close(),this.pc=null),this.video&&(this.video.srcObject=null),this.notify("stopped")}}function KN(n){if(!n)return null;if(typeof n=="string"){const a=String(n).trim();return a?{type:"rover",id:a,key:a}:null}if(typeof n=="object"){if(n.type&&n.id){const a=String(n.id);let r=n.key;return r||(r=n.type==="room"?`room:${a}`:a),{type:n.type,id:a,key:r}}if(n.roverId){const a=String(n.roverId);return{type:"rover",id:a,key:n.key||a}}if(n.roomCameraId){const a=String(n.roomCameraId);return{type:"room",id:a,key:n.key||`room:${a}`}}}return null}function ZN(n=[]){const a=new Set,r=[];return n.forEach(o=>{!o?.key||a.has(o.key)||(a.add(o.key),r.push(o))}),r.sort((o,u)=>o.key.localeCompare(u.key))}function Ld(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useMemo(()=>Array.isArray(n)?ZN(n.map(KN).filter(Boolean)):[],[n]),g=m.useMemo(()=>{const C=h.map(E=>`${E.type}:${E.id}:${E.key}`).join("|");return u?`${C}|v:${u}`:C},[h,u]),x=m.useRef([]),[v,b]=m.useState(0);return m.useEffect(()=>{if(!r)return;const C=()=>b(E=>E+1);return r.on("connect",C),()=>{r.off("connect",C)}},[r]),m.useEffect(()=>{x.current=h},[h]),m.useEffect(()=>{if(!g||!o){p({});return}const C=x.current;let E=!1;function N(w){const j=w.type==="room"?{roomCameraId:w.id}:{roverId:w.id};r.emit("video:request",j,(T={})=>{E||p(k=>({...k,[w.key]:T}))})}return C.forEach(w=>{N(w)}),()=>{E=!0}},[r,g,o,v]),m.useMemo(()=>{if(!g||!o)return{};const C={};return h.forEach(E=>{f[E.key]&&(C[E.key]=f[E.key])}),C},[g,f,h])}function Vg(n=[],a={}){const r=Pt(),{enabled:o=!0,version:u=null}=a,[f,p]=m.useState({}),h=m.useRef(new Map),g=m.useMemo(()=>n.map(N=>typeof N=="string"?N:N.id).filter(Boolean),[n]),x=m.useMemo(()=>{const N=g.join("|");return u?`${N}|v:${u}`:N},[g,u]),v=m.useRef([]),[b,S]=m.useState(0),C=m.useRef(new Map),E=typeof window<"u"&&new URLSearchParams(window.location.search).has("debugSnapshots");return m.useEffect(()=>{if(!r)return;const N=()=>S(w=>w+1);return r.on("connect",N),()=>r.off("connect",N)},[r]),m.useEffect(()=>{v.current=g},[x,g]),m.useEffect(()=>{h.current.forEach(N=>URL.revokeObjectURL(N)),h.current.clear(),p({})},[x]),m.useEffect(()=>{if(!o){h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear(),p({});return}if(!v.current.length||!r)return;let N=!1;const w=v.current,j=(k={},R)=>{if(N||!k.id||!R)return;const D=R.byteLength??R.length??0,V=Date.now(),O=C.current.get(k.id)||{count:0,totalBytes:0,lastLogAt:0},L={count:O.count+1,totalBytes:O.totalBytes+D,lastLogAt:O.lastLogAt};if(E&&(!L.lastLogAt||V-L.lastLogAt>=1e4)){const Q=L.count?L.totalBytes/L.count:0;console.log("[roverSnapshot]",k.id,`frame=${D}B`,`avg=${Math.round(Q)}B`,`count=${L.count}`),L.lastLogAt=V}C.current.set(k.id,L);const Y=new Blob([R],{type:"image/jpeg"}),U=URL.createObjectURL(Y),X=h.current.get(k.id);X&&URL.revokeObjectURL(X),h.current.set(k.id,U),p(Q=>({...Q,[k.id]:{status:"playing",ts:k.ts||Date.now(),error:null,objectUrl:U}}))},T=(k={})=>{N||!k.id||p(R=>({...R,[k.id]:{...R[k.id]||{},status:k.error?"error":R[k.id]?.status||"connecting",error:k.error||null,ts:k.ts||R[k.id]?.ts||null,objectUrl:R[k.id]?.objectUrl||null}}))};return r.on("roverSnapshot:frame",j),r.on("roverSnapshot:status",T),r.emit("roverSnapshot:subscribe",{ids:w},(k={})=>{k.error}),()=>{N=!0,r.emit("roverSnapshot:unsubscribe",{ids:w}),r.off("roverSnapshot:frame",j),r.off("roverSnapshot:status",T),h.current.forEach(k=>URL.revokeObjectURL(k)),h.current.clear()}},[r,x,o,b,E]),f}const ox=2e3,JN=3e3,PN=3e3,WN=40,ew=1e3;function fr({roverId:n=null,sessionInfo:a=null,audioSessionInfo:r=null,videoMode:o=null,snapshotFeed:u=null,label:f,forceMute:p=!1,sensors:h}){const g=oe(Ce=>Ce.session?.assignment?.roverId??null),x=n??g,v=oe(Ce=>Ce.session?.mode||null),b=oe(Ce=>x&&Array.isArray(Ce.session?.roster)&&Ce.session.roster.find(tt=>String(tt.id)===String(x))||null),S=!!b?.media?.audioPublishUrl,C=o?o==="whep":!0,E=m.useMemo(()=>!x||!C?[]:[{type:"rover",id:x,key:x},...S?[{type:"rover",id:`${x}-audio`,key:`${x}-audio`}]:[]],[x,C,S]),N=Ld(E,{enabled:!!(x&&C),version:v}),w=a??(x&&N[x]||null),j=r??(x&&S&&N[`${x}-audio`]||null),T=Vg(x?[x]:[],{enabled:!!(x&&!w?.url),version:v}),k=u??(x&&T[x]||null),R=f||b?.name||(x?`Rover ${x}`:"Rover"),D=Wt(x),V=h??D?.sensors??null,O=m.useRef(null),L=m.useRef(null),Y=m.useRef(null),U=m.useRef(null),X=m.useRef(null),Q=m.useRef(null),ce=m.useRef(null),ue=m.useRef(null),[W,B]=m.useState("idle"),[I,K]=m.useState(null),[P,ie]=m.useState("idle"),[M,q]=m.useState(null),[Z,le]=m.useState(0),[he,we]=m.useState(0),[pe,xe]=m.useState(!0),ge=!!j?.url,Se=o==="snapshot"||!o&&!w?.url,{value:be}=Ve("audio",it),$e=Number.isFinite(be?.masterVolume)?be.masterVolume:it.masterVolume,Ze=Number.isFinite(be?.roverVolume)?be.roverVolume:it.roverVolume,je=typeof be?.mainBrushDuckEnabled=="boolean"?be.mainBrushDuckEnabled:typeof be?.autoLevelEnabled=="boolean"?be.autoLevelEnabled:it.mainBrushDuckEnabled,lt=Number.isFinite(be?.mainBrushDuckAmount)?Math.max(0,Math.min(1,be.mainBrushDuckAmount)):it.mainBrushDuckAmount,Ie=Math.max(0,Math.min(1,$e*Ze)),ft=!!((Number(V?.mainBrushCurrentMa)||0)>WN||V?.wheelOvercurrents?.mainBrush),Ae=je&&ft?1-lt:1,ae=Math.max(0,Math.min(1,Ie*Ae)),re=m.useMemo(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).has("debugAudio"),[]),de=m.useRef({hasDedicatedAudio:!1,audioUrl:null,mainBrushDuckEnabled:!1,mainBrushDuckAmount:0,mainBrushActive:!1,baseRoverGain:0,effectiveRoverGain:0});m.useEffect(()=>{de.current={hasDedicatedAudio:ge,audioUrl:j?.url||null,mainBrushDuckEnabled:je,mainBrushDuckAmount:lt,mainBrushActive:ft,baseRoverGain:Ie,effectiveRoverGain:ae}},[ge,j?.url,je,lt,ft,Ie,ae]);const fe=m.useCallback((Ce,tt={})=>{if(!re)return;const Xe=L.current,Ee=de.current,Oe={event:Ce,ts:Date.now(),roverLabel:R||null,hasDedicatedAudio:Ee.hasDedicatedAudio,audioUrl:Ee.audioUrl,mainBrushDuckEnabled:Ee.mainBrushDuckEnabled,mainBrushDuckAmount:Ee.mainBrushDuckAmount,mainBrushActive:Ee.mainBrushActive,baseRoverGain:Ee.baseRoverGain,effectiveRoverGain:Ee.effectiveRoverGain,element:Xe?{muted:Xe.muted,volume:Xe.volume,paused:Xe.paused,ended:Xe.ended,readyState:Xe.readyState,networkState:Xe.networkState}:null,...tt};try{console.log(`[AudioDebug] ${Ce} ${JSON.stringify(Oe)}`)}catch{console.log("[AudioDebug]",Ce,Oe)}},[re,R]);m.useEffect(()=>{fe("settings/update")},[fe]);const Re=m.useCallback(()=>{clearTimeout(Y.current),Y.current=setTimeout(()=>le(Date.now()),ox)},[]),ne=m.useCallback(()=>{clearTimeout(U.current),U.current=setTimeout(()=>we(Date.now()),ox)},[]),me=m.useCallback(async()=>{const Ce=O.current;if(Ce)try{Ce.muted=!0,await Ce.play()}catch{}},[]),De=m.useCallback((Ce=0)=>{if(p||ge)return;clearTimeout(Q.current);const tt=()=>{clearTimeout(Q.current),Q.current=setTimeout(()=>{p||Xe()},JN)},Xe=async()=>{const Ee=O.current;if(Ee)try{await me(),Ee.muted=!1,await Ee.play(),xe(!1)}catch{Ee.muted=!0,xe(!0),tt()}};Q.current=setTimeout(Xe,Ce)},[me,p,ge]);m.useEffect(()=>()=>{clearTimeout(Y.current),clearTimeout(U.current),clearTimeout(Q.current),clearInterval(X.current),ce.current&&(cancelAnimationFrame(ce.current),ce.current=null)},[]),m.useEffect(()=>{W==="playing"&&De(0)},[W,De]),m.useEffect(()=>{Se&&(B("snapshot"),K(null))},[Se]),m.useEffect(()=>{if(Se||!w?.url||!O.current)return;let Ce=!0,tt;const Xe=setTimeout(()=>xe(!0),0),Ee=(Oe,rt)=>{Ce&&(fe("video/status",{nextStatus:Oe,info:rt||null}),B(Oe),K(rt||null),Oe==="playing"&&me(),["error","failed","disconnected","closed"].includes(Oe)&&Re())};return tt=new ix({url:w.url,token:w.token,video:O.current,receiveAudio:!ge,onStatus:Ee}),tt.start().catch(Oe=>{Ce&&(B("error"),K(Oe.message),Re())}),()=>{Ce=!1,clearTimeout(Xe),tt?.stop()}},[Se,w?.url,w?.token,Z,Re,me,ge,fe]),m.useEffect(()=>{W==="stopped"&&w?.url&&Re()},[W,w?.url,Re]),m.useEffect(()=>{const Ce=L.current;if(!Ce||!j?.url){fe("route/no-audio-url"),ue.current=null;return}const tt=Math.max(0,Math.min(1,ae)),Xe=ue.current==null?Math.max(0,Math.min(1,Ce.volume)):ue.current;if(ce.current&&(cancelAnimationFrame(ce.current),ce.current=null),tt>Xe){const Ee=performance.now(),Oe=Xe,rt=tt-Oe,Rs=sa=>{const St=Math.min(1,(sa-Ee)/ew),Nn=Oe+rt*St;Ce.volume=Nn,ue.current=Nn,St<1?ce.current=requestAnimationFrame(Rs):ce.current=null};ce.current=requestAnimationFrame(Rs)}else Ce.volume=tt,ue.current=tt;fe("route/direct",{elementVolume:tt,duckEnabled:je,mainBrushActive:ft,duckAmount:lt})},[j?.url,ae,je,ft,lt,fe]),m.useEffect(()=>{if(!j?.url||!L.current)return;let Ce=!0,tt;const Xe=(Ee,Oe)=>{Ce&&(fe("audio/status",{nextStatus:Ee,info:Oe||null}),ie(Ee),q(Oe||null),["error","failed"].includes(Ee)&&ne())};return tt=new ix({url:j.url,token:j.token,video:L.current,audioOnly:!0,onStatus:Xe}),tt.start().catch(Ee=>{Ce&&(ie("error"),q(Ee.message),ne())}),()=>{Ce=!1,tt?.stop()}},[j?.url,j?.token,he,ne,fe]),m.useEffect(()=>{const Ce=L.current;if(!j?.url||!Ce){clearInterval(X.current);return}if(!["connecting","connected","playing","paused"].includes(P)){clearInterval(X.current);return}const Xe=async()=>{const Ee=L.current;Ee&&(Ee.muted=!1,!(!Ee.paused&&!Ee.ended)&&(fe("retry/play-attempt"),Ee.play().then(()=>{fe("retry/play-ok"),ie(Oe=>Oe==="connected"?"playing":Oe),q(Oe=>Oe==="paused"?null:Oe)}).catch(Oe=>{fe("retry/play-fail",{error:Oe?.message}),q(rt=>rt||Oe?.message||"autoplay blocked")})))};return Xe(),X.current=setInterval(Xe,PN),()=>clearInterval(X.current)},[j?.url,P,fe]),m.useEffect(()=>{const Ce=L.current;if(!Ce)return;const tt=()=>{fe("element/play"),ie(St=>St==="error"?St:"playing"),q(null)},Xe=()=>{fe("element/pause"),ie(St=>["error","failed","disconnected","closed","stopped"].includes(St)?St:"paused"),q(St=>St||"paused")},Ee=()=>{fe("element/ended"),ie(St=>St==="error"?St:"stopped"),q(St=>St||"ended")},Oe=()=>{const{error:St}=Ce,Nn=St?.message||"audio error";fe("element/error",{error:Nn}),ie("error"),q(Nn)},rt=()=>fe("element/waiting"),Rs=()=>fe("element/canplay"),sa=()=>fe("element/stalled");return Ce.addEventListener("play",tt),Ce.addEventListener("pause",Xe),Ce.addEventListener("ended",Ee),Ce.addEventListener("error",Oe),Ce.addEventListener("waiting",rt),Ce.addEventListener("canplay",Rs),Ce.addEventListener("stalled",sa),()=>{Ce.removeEventListener("play",tt),Ce.removeEventListener("pause",Xe),Ce.removeEventListener("ended",Ee),Ce.removeEventListener("error",Oe),Ce.removeEventListener("waiting",rt),Ce.removeEventListener("canplay",Rs),Ce.removeEventListener("stalled",sa)}},[j?.url,fe]);const en=k?.error?`Error: ${k.error}`:k?.objectUrl?"snapshot":k?.status||"waiting",tn=Se?en:w?.url?W==="error"?`Error: ${I||"unknown"}`:I?`${W} (${I})`:W:"waiting",nn=j?.error?`Error: ${j.error}`:j?.url?P==="error"?`Error: ${M||"unknown"}`:M?`${P} (${M})`:P:null,Nt=!Se&&!w?.error&&["idle","new","connecting"].includes(W);return l.jsxs(l.Fragment,{children:[Se?k?.objectUrl?l.jsx("img",{src:k.objectUrl,alt:R,className:"h-full w-full object-contain",draggable:!1}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-300",children:"Waiting for frame…"}):l.jsx("video",{ref:O,muted:p||pe||ge,playsInline:!0,autoPlay:!0,controls:!1,className:"h-full w-full object-contain"}),Nt?l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/45",children:l.jsx("div",{className:"rounded border border-slate-500/70 bg-black/70 px-3 py-1 text-sm font-semibold text-slate-100",children:"Connecting to video...."})}):null,l.jsx("audio",{ref:L,autoPlay:!0,hidden:!0}),l.jsx("div",{className:"pointer-events-none absolute left-1 top-1 z-20 font-medium text-slate-100 text-[0.65rem]",children:l.jsxs("div",{className:"flex flex-col gap-0.5 leading-none",children:[l.jsxs("span",{children:["Status: ",tn]}),nn?l.jsxs("span",{children:["Audio: ",nn]}):null]})})]})}function tw(n){const a=oe(O=>O.session?.mode||null),r=oe(O=>O.session?.roster??[]),o=oe(O=>O.session?.users??[]),u=oe(O=>O.session?.turnQueues??{}),f=oe(O=>O.session?.socketId||null),p=oe(O=>O.session?.activeDrivers??{}),[h,g]=m.useState(()=>Date.now()),x=n&&u?.[n]||null,v=n&&p?.[n]||null,b=!!(f&&v===f),S=m.useMemo(()=>{const O=x?.queue||[];if(!O.length||!x?.current||O.length<=1)return null;const L=O.findIndex(Y=>Y===x.current);return L===-1?O[0]||null:O[(L+1)%O.length]||null},[x?.queue,x?.current]),C=!!(f&&S===f),E=x?.deadline||null,N=E?E-h:null,w=a==="turns",j=r.length,T=m.useMemo(()=>{const O=new Set;return o.forEach(L=>{if(String(L?.role||"")==="spectator")return;const U=String(L?.roverId||"").trim(),X=String(L?.socketId||"").trim();!U||!X||O.add(X)}),O.size},[o]),k=w&&T>j,R=w&&C&&N!=null&&N<=5e3&&N>0,V=w&&!b&&!R&&k;return m.useEffect(()=>{if(a!=="turns")return;const O=setInterval(()=>g(Date.now()),250);return()=>clearInterval(O)},[a]),V?"snapshot":null}const nw={discord:pg,kofi:$0,"ko-fi":$0,wiki:qj,throne:Dj},sw={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 aw(){m.useEffect(()=>{if(typeof document>"u")return;const n="social-button-keyframes";if(document.getElementById(n))return;const a=document.createElement("style");a.id=n,a.textContent=`
|
||
@keyframes socialGradient {
|
||
0% { background-position: 0% 50%; }
|
||
50% { background-position: 100% 50%; }
|
||
100% { background-position: 0% 50%; }
|
||
}
|
||
`,document.head.appendChild(a)},[])}function lw(n,a){return typeof n=="string"&&n.trim()?n.trim().toLowerCase():typeof a=="string"&&a.trim()?a.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):""}function wo({id:n,label:a,url:r,className:o=""}){if(!r)return null;aw();const u=lw(n,a),f=nw[u]||_j,p=sw[u]||null,h=a||n||"Link";return l.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":h,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 ${p?"":"bg-slate-700 hover:bg-slate-600"} ${o}`,style:p||void 0,children:[l.jsx(f,{className:"mr-0"}),h]})}function rw({roverId:n=null,mobileHud:a=!1,discordUrl:r=null}){const o=oe(Ae=>Ae.session?.assignment?.roverId??null),u=n??o,f=oe(Ae=>Ae.session?.mode||null),p=oe(Ae=>Ae.session?.roster??[]),h=oe(Ae=>Ae.session?.users??[]),g=oe(Ae=>Ae.session?.turnQueues??{}),x=oe(Ae=>Ae.session?.socketId||null),v=oe(Ae=>Ae.session?.activeDrivers??{}),b=oe(Ae=>(Ae.session?.socials||[]).find(de=>String(de?.id||de?.label||"").toLowerCase()==="discord")?.url||null||Ae.session?.discord?.invite||null),{state:{lastControlIntentAt:S}}=yt(),C=r||b,[E,N]=m.useState(()=>Date.now()),[w,j]=m.useState(!1),[T,k]=m.useState(null),[R,D]=m.useState(!1),[V,O]=m.useState(0),L=m.useRef({initialized:!1,roverId:null,activeDriverId:null}),Y=m.useRef(S||0),U=a?"text-[0.5rem]":"text-[0.7rem]",X=a?"px-0.5 py-0.25":"px-1 py-0.5",Q=a?"text-3xl":"text-5xl",ce=a?"text-xs":"text-sm",ue=a?"text-[0.55rem]":"text-[0.75rem]",W=a?"px-4 py-3":"px-6 py-4",B=u?g?.[u]:null,I=u?v?.[u]:null,K=!!(x&&I===x),P=m.useMemo(()=>{const Ae=B?.queue||[];if(!Ae.length||!B?.current||Ae.length<=1)return null;const ae=Ae.findIndex(re=>re===B.current);return ae===-1?Ae[0]||null:Ae[(ae+1)%Ae.length]||null},[B?.queue,B?.current]),ie=!!(x&&P===x),M=B?.deadline||null,q=B?.idleDeadline||null,Z=M?M-E:null,le=q?q-E:null,he=f==="turns",we=p.length,pe=m.useMemo(()=>{const Ae=new Set;return h.forEach(ae=>{if(String(ae?.role||"")==="spectator")return;const de=String(ae?.roverId||"").trim(),fe=String(ae?.socketId||"").trim();!de||!fe||Ae.add(fe)}),Ae.size},[h]),xe=he&&pe>we,ge=he&&ie&&Z!=null&&Z<=5e3&&Z>0,Se=he&&!K,be=Se&&!ge&&xe,$e=Z!=null&&Number.isFinite(Z)?Math.max(0,Math.ceil(Z/1e3)):null,Ze=le!=null&&Number.isFinite(le)?Math.max(0,Math.ceil(le/1e3)):null,je=m.useMemo(()=>!he||!K?null:$e!=null?`${$e}s left`:"Your turn",[he,K,$e]),lt=m.useMemo(()=>!Se||!ie||$e==null?null:`${$e} seconds until your turn.`,[Se,ie,$e]),Ie=K&&typeof Ze=="number",ft=R;return m.useEffect(()=>{if(f!=="turns")return;const Ae=setInterval(()=>N(Date.now()),250);return()=>clearInterval(Ae)},[f]),m.useEffect(()=>{if(f!=="turns"){j(!1),k(null),L.current={initialized:!1,roverId:null,activeDriverId:null};return}const Ae=L.current,ae=I||null;if(!x||!u){j(!1),k(null),L.current={initialized:!1,roverId:null,activeDriverId:null};return}if(!Ae.initialized||Ae.roverId!==u){L.current={initialized:!0,roverId:u,activeDriverId:ae};return}!!Ae.activeDriverId&&Ae.activeDriverId!==x&&ae===x?(j(!0),k(Date.now())):ae!==x&&w&&(j(!1),k(null)),L.current={initialized:!0,roverId:u,activeDriverId:ae}},[I,f,u,x,w]),m.useEffect(()=>{!w||!T||S>T&&j(!1)},[S,w,T]),m.useEffect(()=>{const Ae=Number(Y.current)||0,ae=Number(S)||0;ae>Ae&&Se&&O(Date.now()),Y.current=ae},[S,Se]),m.useEffect(()=>{if(!Se||!V)return;D(!0);const Ae=setTimeout(()=>D(!1),650);return()=>clearTimeout(Ae)},[Se,V]),l.jsxs(l.Fragment,{children:[w?l.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-black/55",children:l.jsxs("div",{className:`flex flex-col items-center gap-0.5 rounded border border-amber-300/80 bg-black/70 ${W}`,children:[l.jsx("div",{className:`font-semibold text-amber-200 ${Q}`,children:"IT IS YOUR TURN!"}),l.jsx("div",{className:`text-amber-200/80 ${ce}`,children:"Start driving!"}),Ie?l.jsxs("div",{className:`text-red-100/90 ${ue}`,children:["Idle skip in ",Ze,"s"]}):null]})}):null,je?l.jsx("div",{className:`pointer-events-none absolute bottom-1 left-1 rounded border ${ft?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${X} ${U}`,children:je}):null,Se?l.jsx("div",{className:"pointer-events-none absolute bottom-1 left-1 z-40",children:l.jsxs("div",{className:`w-fit rounded border ${R?"border-red-300/90 bg-red-900/80 text-red-100":"border-amber-300/80 bg-black/75 text-amber-200"} ${a?"px-2 py-1 text-[0.6rem]":"px-3 py-1.5 text-sm"}`,children:[l.jsx("div",{className:R?"text-[0.82rem] font-semibold text-red-50":"text-[0.82rem] font-semibold text-white",children:"Not your turn to drive!"}),lt?l.jsx("div",{className:R?"text-red-100/95":"text-amber-100",children:lt}):null,be?l.jsx("div",{className:R?"text-red-100/90":"text-amber-200/85",children:"Video switched to preview mode to save bandwidth."}):null,l.jsx("div",{className:"pointer-events-auto mt-0.5",children:l.jsx(wo,{id:"discord",label:"Join our Discord while you wait!",url:C})})]})}):null]})}const iw=Dt.memo(rw);function $g(){const{value:n,save:a}=Ve("page",{hudMapDesktop:!1});return[!!n?.hudMapDesktop,u=>{a({hudMapDesktop:!!u})}]}function cx({variant:n="default",label:a,roverColor:r=null,driverLabel:o=null,mobileHud:u=!1,labelScale:f=1}){const p=u?"px-0.25 py-0.25":"px-0.5 py-0.5",h=u?"text-[0.55rem]":"text-[0.8rem]",g="bottom-0.5",x={transform:`translateX(-50%) scale(${f})`,transformOrigin:"center bottom"};return n==="spectator"?l.jsx("div",{className:`absolute ${g} left-1/2`,style:x,children:l.jsxs("div",{className:`flex items-center gap-0.5 bg-black/80 text-slate-100 ${p} ${h}`,children:[l.jsx("span",{className:"font-semibold text-white rounded px-1 py-[1px] border border-transparent",style:ns(r,.18),children:a||"No rover"}),o?l.jsxs("span",{className:"text-slate-300",children:["• ",o]}):null]})}):l.jsx("div",{className:`absolute ${g} left-1/2`,style:x,children:l.jsx("div",{className:`flex gap-0.5 bg-black/80 text-slate-100 ${p} ${h}`,children:l.jsxs("span",{children:["Rover:"," ",l.jsxs("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(r,.18),children:['"',a||"No rover",'"']})]})})})}function ow({sensors:n,mobileHud:a=!1}){const r=a?"px-0.25 py-0.25":"px-1 py-0.5",o=a?"left-0.5 top-1/2":"left-1 top-1/2",u=a?"text-[0.45rem]":"text-[0.65rem]",f=[["Voltage",n?.voltageMv!=null?`${(n.voltageMv/1e3).toFixed(2)} V`:"--"],["Current",n?.currentMa!=null?`${n.currentMa} mA`:"--"],["Charge",n?.batteryChargeMah!=null?`${n.batteryChargeMah}`:"--"],["OI",n?.oiMode?.label||"--"]],p=!!n?.chargingSources?.homeBase,h=n?.chargingState?.label||"",g=!!(h&&h.toLowerCase()!=="not charging"),x=n?.oiMode?.label||"Unknown",v=x.toLowerCase(),b=v==="full"?"bg-emerald-500/80 text-emerald-50":v==="safe"?"bg-amber-400/80 text-amber-950":v==="passive"?"bg-slate-700/80 text-slate-100":"bg-slate-700/60 text-slate-200",S=p?"bg-emerald-500/80 text-emerald-50":"bg-slate-700/70 text-slate-200",C=g?"bg-emerald-500/80 text-emerald-50":p?"bg-amber-400/80 text-amber-950":"bg-slate-700/70 text-slate-200";return l.jsx("div",{className:`absolute ${o} flex -translate-y-1/2 flex-col gap-0.5 bg-black/70 text-slate-100 ${u} ${r}`,children:l.jsxs("div",{className:"space-y-0.5 leading-tight",children:[l.jsxs("div",{className:"flex flex-col gap-0.5 text-[0.75rem] font-semibold uppercase tracking-wide",children:[l.jsx("span",{className:`rounded px-1.5 py-0.5 ${S}`,children:p?"Docked":"Undocked"}),l.jsx("span",{className:`rounded px-1.5 py-0.5 ${C}`,children:g?"Charging":"Not charging"}),l.jsxs("span",{className:`rounded px-1.5 py-0.5 ${b}`,children:["OI: ",x]})]}),f.map(([E,N])=>l.jsxs("span",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{className:"text-slate-400",children:E}),l.jsx("span",{className:"font-semibold text-white",children:N})]},E))]})})}function Ao(n){return Math.max(0,Math.min(1,n))}function Gg(n){return(n-90)*Math.PI/180}function or(n,a,r,o){const u=Gg(o);return{x:n+r*Math.cos(u),y:a+r*Math.sin(u)}}function cw(n,a,r,o,u){let f=o,p=u;p<=f&&(p+=360);const h=or(n,a,r,f),g=or(n,a,r,p);return["M",h.x,h.y,"A",r,r,0,0,1,g.x,g.y].join(" ")}function df(n,a){if(a)return"#ef4444";const r=Math.abs(n);return r>900?"#f59e0b":r>300?"#22c55e":"#64748b"}function uw(n,a){if(n==null||n<=0)return"hsl(200 60% 18%)";const o=Ao(n/(a||1));return`hsl(${(200+Math.pow(o,.45)*360)%360} 100% 60%)`}function dw(n,a){if(a)return"#ef4444";const r=Ao(n==null?0:n/4095),o=[47,55,69],u=[245,158,11],[f,p,h]=o.map((g,x)=>Math.round(g+(u[x]-g)*r));return`rgb(${f}, ${p}, ${h})`}function fw({count:n,totalSpan:a,gap:r,startAngle:o}){const f=(a-r*(n-1))/n,p=[];let h=o;for(let g=0;g<n;g+=1){const x=h+f;p.push({start:h,end:x}),h=x+r}return p}function xd({cx:n,cy:a,rInner:r,rOuter:o,startDeg:u,endDeg:f,color:p,pulse:h=!1,opacity:g=1}){const x=(r+o)/2,v=o-r,b=cw(n,a,x,u,f);return l.jsxs(l.Fragment,{children:[l.jsx("path",{d:b,stroke:p,strokeWidth:v,strokeLinecap:"round",fill:"none",opacity:g}),h?l.jsx("path",{d:b,stroke:"#ef4444",strokeWidth:v,strokeLinecap:"round",fill:"none",className:"animate-pulse",opacity:1}):null]})}function mw({cx:n,cy:a,rBase:r,rTip:o,startDeg:u,endDeg:f,color:p,value:h,max:g}){const x=(u+f)/2,v=or(n,a,o,x),b=Ao(h!=null?h/(g||1):0),S=Math.pow(b,.35),C=r-(r-o)*S,E=Math.max(o,Math.min(C,r)),N=or(n,a,E,u),w=or(n,a,E,f),j=`M ${v.x} ${v.y} L ${N.x} ${N.y} L ${w.x} ${w.y} Z`;return l.jsx("path",{d:j,fill:p,opacity:1,stroke:"none"})}function ux({cx:n,cy:a,current:r,drop:o,overcurrent:u,label:f}){const p=Math.abs(r),h=Ao(p/1200),g=df(r,u),x=56,v=14,b=9,S=3,C=x*h,E=f==="L"?-1:1,N=E*(-b/2-S/2),w=E*(v/2+S/2),j=v+b+S+2,T=x+4;return l.jsxs("g",{transform:`translate(${n},${a})`,children:[l.jsx("rect",{x:-j/2,y:-T/2,width:j,height:T,rx:"4",fill:"none",stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:N-v/2,y:-x/2,width:v,height:x,fill:"#0f172a",stroke:"#0f172a",strokeWidth:"1",rx:"2"}),l.jsx("rect",{x:N-v/2,y:x/2-C,width:v,height:C,fill:g,className:u?"animate-pulse":""}),l.jsx("rect",{x:w-b/2,y:-x/2,width:b,height:x,fill:o?"#ef4444":"#475569",className:o?"animate-pulse":"",rx:"2"}),l.jsx("text",{x:0,y:x/2+10,textAnchor:"middle",className:"fill-slate-200 text-[0.7rem]",children:f})]})}function hw({cx:n,cy:a,current:r,overcurrent:o}){let u=Math.abs(r);u<10&&(u=0);const f=df(r*3,o),p=43,h=u>0?.65:null;return l.jsxs("g",{style:{transformOrigin:`${n}px ${a}px`,animation:h?`spin ${h}s linear infinite`:"none",animationDirection:h?"reverse":"normal"},children:[l.jsx("circle",{cx:n,cy:a,r:10,fill:"#64748b",stroke:"#64748b",strokeWidth:"1"}),[0,120,240].map(x=>{const v=Gg(x),b=n+p*Math.cos(v),S=a+p*Math.sin(v);return l.jsx("line",{x1:n,y1:a,x2:b,y2:S,stroke:f,strokeWidth:"4",strokeLinecap:"round"},x)}),o?l.jsx("circle",{cx:n,cy:a,r:p+8,stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function pw({cx:n,cy:a,current:r,overcurrent:o,variant:u,dirtLeft:f,dirtRight:p}){const h=Math.abs(r),g=df(r,o),x=1,v=96,b=12,S=`main-brush-pattern-a-${u}`,C=`main-brush-pattern-b-${u}`,E=h>0?.6:null,N=r>=0?1:-1;return l.jsxs("g",{children:[l.jsx("defs",{children:[S,C].map((w,j)=>l.jsxs("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"6",height:"6",children:[l.jsx("rect",{width:"6",height:"6",fill:g,opacity:x}),l.jsx("path",{d:"M0 6 L6 0",stroke:"#0f172a",strokeWidth:"1"}),E?l.jsx("animateTransform",{attributeName:"patternTransform",type:"translate",from:"0 0",to:`0 ${N*(j===0?6:-6)}`,dur:`${E}s`,repeatCount:"indefinite"}):null]},w))}),l.jsx("rect",{x:n-v/2,y:a-14,width:v,height:b,rx:"3",fill:`url(#${S})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("rect",{x:n-v/2,y:a+4,width:v,height:b,rx:"3",fill:`url(#${C})`,stroke:"#64748b",strokeWidth:"1"}),l.jsx("circle",{cx:n-v/4,cy:a-8,r:3.5,fill:"#fbbf24"}),l.jsx("circle",{cx:n+v/4,cy:a+8,r:3.5,fill:"#fbbf24"}),o?l.jsx("rect",{x:n-v/2-4,y:a-16,width:v+8,height:b*2+16,rx:"6",stroke:"#ef4444",strokeWidth:"3",fill:"none",className:"animate-pulse"}):null]})}function xw({sensors:n={},variant:a="full",size:r,overlay:o=!1}){const u=r||(a==="mini"?190:260),f=u/2,p=u*.07,h=f,g=f+p,x=f*.8,v=x-4,b=x+4,S=x-14,C=x-6,E=x*.65,N=n?.bumpsAndWheelDrops||{},w=n?.wheelOvercurrents||{},j=n?.wheelLeftCurrentMa??0,T=n?.wheelRightCurrentMa??0,k=n?.sideBrushCurrentMa??0,R=n?.mainBrushCurrentMa??0,D=6,V=N.bumpLeft?D:0,O=N.bumpRight?D:0,L=fw({count:6,totalSpan:140,gap:6,startAngle:-70}),Y=["L","FL","CL","CR","FR","R"],U=[n?.lightBumpLeftSignal,n?.lightBumpFrontLeftSignal,n?.lightBumpCenterLeftSignal,n?.lightBumpCenterRightSignal,n?.lightBumpFrontRightSignal,n?.lightBumpRightSignal],X=L.map((W,B)=>({label:Y[B],start:W.start,end:W.end,value:U[B]})),Q=[{label:"Cliff L",start:-60,end:-46,value:n?.cliffLeftSignal,active:n?.cliffLeft},{label:"Cliff FL",start:-32,end:-16,value:n?.cliffFrontLeftSignal,active:n?.cliffFrontLeft},{label:"Cliff FR",start:16,end:32,value:n?.cliffFrontRightSignal,active:n?.cliffFrontRight},{label:"Cliff R",start:46,end:60,value:n?.cliffRightSignal,active:n?.cliffRight}],ce=U.filter(W=>W!=null),ue=ce.length?Math.max(...ce,1200):1200;return l.jsxs("div",{className:`${o?"relative":"surface relative p-1"}`,style:o?{width:`${u}px`,height:`${u}px`}:{height:"100%",width:"100%",aspectRatio:"1 / 1"},children:[o?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"absolute left-1 top-1 text-xs text-slate-400",children:"Top-down"}),l.jsxs("div",{className:"absolute right-1 top-1 text-[0.65rem] text-slate-500",children:["0–",ue]})]}),l.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${u} ${u}`,preserveAspectRatio:"xMidYMid meet",className:"mx-auto block",children:[l.jsx("circle",{cx:h,cy:g,r:x,fill:"#0f172a",stroke:"#334155",strokeWidth:"2"}),l.jsx(ux,{cx:h-E,cy:g,current:j,drop:N.wheelDropLeft,overcurrent:w.leftWheel,label:"L"}),l.jsx(ux,{cx:h+E,cy:g,current:T,drop:N.wheelDropRight,overcurrent:w.rightWheel,label:"R"}),l.jsx(hw,{cx:h+x*.65,cy:g-x*.55,current:k,overcurrent:w.sideBrush}),l.jsx(pw,{cx:h,cy:g,current:R,overcurrent:w.mainBrush,variant:a,dirtLeft:n?.dirtDetectLeft,dirtRight:n?.dirtDetect}),X.map(W=>{const B=uw(W.value,ue),I=b+4,K=I+28;return l.jsx(mw,{cx:h,cy:g,rBase:K,rTip:I,startDeg:W.start,endDeg:W.end,color:B,value:W.value,max:ue},W.label)}),Q.map(W=>l.jsx(xd,{cx:h,cy:g,rInner:S,rOuter:C,startDeg:W.start,endDeg:W.end,color:dw(W.value,W.active),opacity:1,pulse:!!W.active},W.label)),l.jsx(xd,{cx:h,cy:g,rInner:v-V,rOuter:b-V,startDeg:-70,endDeg:-6,color:N.bumpLeft?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpLeft}),l.jsx(xd,{cx:h,cy:g,rInner:v-O,rOuter:b-O,startDeg:6,endDeg:70,color:N.bumpRight?"#ef4444":"#475569",opacity:1,pulse:!!N.bumpRight})]})]})}const Yg=Dt.memo(xw);function dx({sensors:n,show:a=!0,mapPosition:r="top-center",layoutFormat:o="desktop",mobileHud:u=!1}){if(!a)return null;const f=o==="mobile-portrait",p="240px",h=f?.3:u?.33:.7,x={width:p,height:p,opacity:u?.6:.7,transform:r==="top-center"?`translateX(-50%) scale(${h})`:`scale(${h})`,transformOrigin:r==="bottom-left"?"bottom left":r==="top-center"?"top center":"top right",...r==="bottom-left"?{left:"0.25rem",bottom:"0.25rem"}:r==="top-center"?{left:"50%",top:"0.25rem"}:{right:"0.25rem",top:"0.25rem"}};return l.jsx("div",{className:"pointer-events-none absolute rounded",style:x,children:l.jsx(Yg,{sensors:n,size:240,overlay:!0})})}function gw({roverId:n=null,sensors:a,label:r,roverColor:o=null,layoutFormat:u="desktop",variant:f="default",driverLabel:p=null,showTopDown:h=void 0,mobileHud:g=!1,mapPosition:x=null,labelScale:v=1}){const b=oe(L=>L.session?.assignment?.roverId??null),S=n??b,C=Wt(S),E=oe(L=>{if(!S)return{label:null,roverColor:null};const U=(L.session?.roster||[]).find(X=>String(X.id)===String(S));return{label:U?.name||null,roverColor:U?.color||null}}),N=oe(L=>{if(!S||f!=="spectator")return null;const Y=L.session?.activeDrivers?.[S]||null,X=(L.session?.users||[]).find(Q=>String(Q.socketId||"")===String(Y||""));return X?.nickname||X?.name||null}),w=a??C?.sensors??null,j=r??E.label??null,T=o??E.roverColor??null,k=p??N,R=g,[D]=$g(),V=typeof h=="boolean"?h:f==="spectator"||R?!0:D,O=x||(f==="spectator"?"top-center":R?"top-right":"top-center");return f==="none"?null:f==="spectator"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx(ow,{sensors:w,mobileHud:R}),l.jsx(cx,{variant:"spectator",label:j,roverColor:T,driverLabel:k,mobileHud:R,labelScale:v})]}),l.jsx(dx,{sensors:w,show:V,mapPosition:O,layoutFormat:u,mobileHud:R})]}):l.jsxs("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:[l.jsx(cx,{variant:"default",label:j,roverColor:T,mobileHud:R,labelScale:v}),l.jsx(dx,{sensors:w,show:V&&f!=="spectator",mapPosition:O,layoutFormat:u,mobileHud:R})]})}const Fg=Dt.memo(gw);function vw({mobileHud:n=!1}){const{visible:a,statusLabel:r,statusTone:o}=al({manageLifecycle:!0});if(!a)return null;const u=o==="good"?"border-emerald-200/70 bg-emerald-900/85 text-emerald-50":o==="warn"?"border-amber-200/70 bg-amber-900/85 text-amber-50":"border-indigo-200/70 bg-indigo-900/85 text-indigo-50";return l.jsx("div",{className:"pointer-events-none absolute inset-0",children:l.jsx("div",{className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-lg border px-2 py-1 font-semibold shadow-lg ${u} ${n?"text-[0.65rem]":"text-xs"}`,children:r})})}const bw=Dt.memo(vw),fx=5e3,yw=700;function Ig({roverId:n=null,description:a,variant:r="default",mobileHud:o=!1,displayKey:u="",controlIntentAt:f}){const p=oe(T=>T.session?.assignment?.roverId??null),h=n??p,g=oe(T=>h&&(T.session?.roster||[]).find(D=>String(D.id)===String(h))?.description||null),x=a??g,v=typeof f=="number"?f:0,b=u||`${h||""}::${x||""}`,[S,C]=m.useState(!1),[E,N]=m.useState(!1),w=m.useRef(null),j=m.useRef(null);return m.useEffect(()=>()=>{clearTimeout(w.current),clearTimeout(j.current)},[]),m.useEffect(()=>{if(r!=="default"||!x){C(!1),N(!1),clearTimeout(w.current),clearTimeout(j.current);return}clearTimeout(w.current),clearTimeout(j.current),C(!0),N(!1)},[x,b,r]),m.useEffect(()=>{r!=="default"||!x||!S||E||(Number(v)||0)<=0||w.current||j.current||(w.current=setTimeout(()=>{N(!0),w.current=null},fx),j.current=setTimeout(()=>{C(!1),j.current=null},fx+yw))},[v,x,E,S,r]),x?r==="spectator"?l.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1 z-50 flex justify-center",children:l.jsx("div",{className:"surface max-w-[92%] border border-slate-600/80 px-1 py-0.5 text-center text-[0.62rem] leading-tight text-slate-100 shadow-lg",children:x})}):r!=="default"||!S?null:l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center",children:l.jsxs("div",{className:`surface max-w-[94%] border border-slate-400 bg-neutral-900 px-2 py-1 text-center font-semibold text-slate-100 shadow-xl transition-opacity duration-700 ${E?"opacity-0":"opacity-100"} ${o?"text-[1rem] leading-tight":"text-[1.5rem] leading-tight"}`,children:[l.jsx("p",{children:"Just so you know, this rover"}),l.jsx("p",{children:x}),l.jsx("p",{className:`${o?"text-[0.58rem]":"text-[0.72rem]"} mt-0.5 font-normal text-slate-300`,children:"This fades 5 seconds after your first control input."})]})}):null}const Sw={leftWheel:"Left wheel",rightWheel:"Right wheel",mainBrush:"Main brush",sideBrush:"Side brush",limiter:"Overcurrent limit"};function jw({roverId:n=null,sensors:a,overcurrentLimiter:r=null,compact:o=!1}){const u=oe(L=>L.session?.assignment?.roverId??null),f=n??u,p=Wt(f),h=jg(f),g=a??p?.sensors??null,x=r??h??null,v=g?.wheelOvercurrents||null,b=m.useMemo(()=>v==null?[]:Object.entries(v).filter(([,L])=>!!L).map(([L])=>L),[v]),S=x?.caps||null,C=m.useMemo(()=>{if(!S)return null;const L=Number.isFinite(S?.drive?.cap)?S.drive.cap:1,Y=Number.isFinite(S?.aux?.cap)?S.aux.cap:1;return Math.max(0,Math.min(1,1-Math.min(L,Y)))},[S]),E=!!x?.isActive,N=m.useMemo(()=>b.length?b:E?["limiter"]:[],[b,E]),w=C??(b.length?1:0);if(!N?.length)return null;const j=N.map(L=>Sw[L]||L),T=o?"w-[12rem] h-[3.5rem]":"w-[20rem] h-[7rem]",k=o?"px-2 py-1":"px-4 py-2",R=o?"text-lg":"text-4xl",D=o?"text-xs":"text-xl",V=Math.max(0,Math.min(1,w)),O=`${Math.round(V*100)}%`;return l.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-red-900/50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 ${T}`,children:l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx("div",{className:"absolute inset-0 overflow-hidden",children:l.jsx("div",{className:"h-full bg-red-700/60",style:{width:O}})}),l.jsxs("div",{className:`relative z-10 flex h-full w-full flex-col items-center justify-center text-center font-semibold text-white animate-pulse ${R} ${k}`,children:[l.jsx("div",{children:"OVERCURRENT"}),l.jsx("div",{className:`mt-0 font-medium text-white ${D}`,children:j.join(", ")})]})]})})}const Xg=Dt.memo(jw),mr=10;function Co({batteryState:n=null,charge:a=null,config:r=null}){const o=n?.percentDisplay!=null&&Number.isFinite(n.percentDisplay)?Math.round(n.percentDisplay):null,u=n?.warnActive??null,f=n?.urgentActive??null,p=r?.Full??null,h=r?.Warn??null,g=r?.Urgent??null,x=a??n?.charge??null;let v=o;if(v==null&&(v=Nw({charge:x,full:p,warn:h,urgent:g})),v==null)return{available:!1};const b=Math.max(0,Math.min(1,v/100)),S=u??(h!=null&&x!=null&&x<=h),C=f??(g!=null&&x!=null&&x<=g);return{available:!0,percent:b,percentDisplay:v,warnActive:S,urgentActive:C,warnDisplayPercent:mr}}function Nw({charge:n,full:a,warn:r,urgent:o}){if(n!=null&&a!=null&&r!=null&&o!=null&&a>r&&r>o){const u=mr/100,f=1-u;if(n<=o)return 0;if(n<=r){const h=(n-o)/(r-o);return Math.round(Math.max(0,Math.min(1,h))*mr)}if(n>=a)return 100;const p=(n-r)/(a-r);return Math.round((u+Math.max(0,Math.min(1,p))*f)*100)}return null}function ww({roverId:n=null,sensors:a,batteryConfig:r,compact:o=!1}){const u=oe(E=>E.session?.assignment?.roverId??null),f=n??u,p=Wt(f),h=oe(E=>f?(E.session?.roster||[]).find(j=>String(j.id)===String(f))?.battery??null:null),g=a??p?.sensors??null,x=r??h,v=Co({charge:g?.batteryChargeMah??null,config:x});if(!v?.available||!v.warnActive&&!v.urgentActive)return null;const b=v.urgentActive?"BATTERY VERY LOW, DOCK THE ROVER AND CHARGE IMMEDIATELY!!":"Battery low! please dock and charge the rover soon.",S=o?"p-2 top-6":"p-4 top-10",C=o?"text-sm":"text-2xl";return l.jsx("div",{className:`pointer-events-none absolute flex items-center justify-center bg-amber-900/60 left-1/2 -translate-x-1/2 ${S}`,children:l.jsx("div",{className:`text-center font-semibold text-white animate-pulse ${C}`,children:l.jsx("div",{children:b})})})}const Qg=Dt.memo(ww);function Aw({roverId:n=null,sensors:a}){const r=oe(S=>S.session?.assignment?.roverId??null),u=Wt(n??r),f=a??u?.sensors??null,p=[f?.lightBumpLeftSignal,f?.lightBumpFrontLeftSignal,f?.lightBumpCenterLeftSignal,f?.lightBumpCenterRightSignal,f?.lightBumpFrontRightSignal,f?.lightBumpRightSignal],h=p.filter(S=>S!=null).reduce((S,C)=>Math.max(S,C),1200),g=S=>Math.pow(Math.max(0,Math.min(1,(S??0)/h)),.35),x=S=>S==null||S<=0?"hsl(200 60% 18%)":`hsl(${(200+g(S)*360)%360} 100% 60%)`,v=6,b=12;return l.jsx("div",{className:"flex w-full items-center justify-center gap-0.5",children:p.map((S,C)=>{const E=g(S),N=C<v/2?-1:1,w=`${E*100}%`,j=x(S);return l.jsx("div",{className:"relative flex-1 min-w-[0]",style:{height:`${b}px`},children:l.jsx("div",{className:"h-full w-full overflow-hidden bg-slate-800",style:{borderRadius:0},children:l.jsx("div",{className:"h-full",style:{width:w,background:j,float:N===-1?"right":"left"}})})},C)})})}const Cw=Dt.memo(Aw),kw=1600,Ew=800;function yn(...n){return n.filter(Boolean).join(" ")}function Mw({visual:n,orientation:a="horizontal",variant:r="inline",compact:o=!1,showLabel:u,className:f=""}){const p=r==="background",h=a==="vertical",g=u??!p;if(!n?.available){if(p){const Q=mr,ce=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),ue=h?{bottom:`${Q}%`}:{left:`${Q}%`},W=yn("absolute inset-0 pointer-events-none",f);return l.jsxs("div",{className:W,children:[l.jsx("div",{className:"absolute inset-0 bg-slate-900/35"}),l.jsx("div",{className:ce,style:ue})]})}return h?null:l.jsx("p",{className:"text-xs text-slate-500",children:"Battery telemetry unavailable"})}const x=n.percentDisplay??0,v=Math.max(0,Math.min(100,x)),b=n.warnDisplayPercent??mr,S=!!n.urgentActive,C=!!n.warnActive,E=S?`${Ew}ms`:C?`${kw}ms`:void 0,w=p?S||C?"bg-red-500/45":"bg-emerald-500/45":S||C?"bg-red-500":"bg-emerald-500",j=S||C?"bg-red-900/35":"bg-slate-900/35",T=S||C?"bg-red-900/45":"bg-slate-900/35",k=yn(p?"absolute inset-0 pointer-events-none":"relative pointer-events-auto",h&&!p?"flex flex-col items-center justify-center":"w-full",f);if(p){const Q=h?{height:`${v}%`}:{width:`${v}%`},ce=yn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),ue=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),W=h?{bottom:`${b}%`}:{left:`${b}%`};return l.jsxs("div",{className:k,children:[l.jsx("div",{className:yn("absolute inset-0",j,S&&"battery-urgent-flash")}),l.jsx("div",{className:ce,style:{...Q,animationDuration:E}}),l.jsx("div",{className:ue,style:W})]})}const R=yn("relative overflow-hidden rounded-sm border border-slate-800",S||C?T:"bg-zinc-900/90",S&&"battery-urgent-flash",h?"w-full flex-1":o?"h-4":"h-5"),D=h?{height:`${v}%`}:{width:`${v}%`},V=yn("absolute",h?"bottom-0 left-0 right-0":"left-0 top-0 bottom-0",w,"transition-[width,height]",S&&"battery-urgent-flash"),O=yn("absolute z-10",h?"left-0 right-0 h-[2px]":"top-0 bottom-0 w-[2px]","bg-black/70",C&&!S&&"battery-tick-warn"),L=h?{bottom:`${b}%`}:{left:`${b}%`},Y=`Battery ${x}%`,U=yn("pointer-events-none absolute inset-0 flex items-center justify-center text-center font-semibold",h?o?"text-[0.55rem]":"text-[0.65rem]":"text-xs"),X=yn("rounded px-1.5 py-0.5",p?"bg-black/30 text-slate-100":"bg-black/50 text-slate-100");return l.jsxs("div",{className:k,children:[l.jsxs("div",{className:R,children:[l.jsx("div",{className:V,style:{...D,animationDuration:E}}),l.jsx("div",{className:O,style:L})]}),g&&!h?l.jsx("div",{className:U,children:l.jsx("span",{className:X,children:Y})}):null,g&&h?l.jsx("div",{className:"mt-0.5 text-[0.65rem] font-semibold text-slate-100",children:l.jsxs("span",{className:X,children:[x,"%"]})}):null]})}const ff=Dt.memo(Mw);function Rw({roverId:n=null,mobileHud:a=!1}){const r=oe(g=>g.session?.assignment?.roverId??null),o=n??r,f=Wt(o)?.sensors??null,p=oe(g=>o?(g.session?.roster||[]).find(b=>String(b.id)===String(o))?.battery??null:null),h=Co({charge:f?.batteryChargeMah??null,config:p});return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Cw,{roverId:o}),l.jsx("div",{className:"panel-section space-y-0.5 text-sm",children:l.jsx(ff,{visual:h,compact:a})})]})}function Tw({compact:n=!1}){const a=oe(L=>L.session?.role||null),r=oe(L=>L.session?.assignment?.roverId||null),o=oe(L=>L.session?.roster||[]),{sendMessage:u,onInputFocus:f,onInputBlur:p,blurChat:h,registerInputRef:g,setTypingActive:x}=lf(),{value:v}=Ve("tts",{engine:"flite",voice:"rms",pitch:50}),[b,S]=m.useState(""),[C,E]=m.useState(!1),N=a!=="spectator",w=a==="spectator",T=!!m.useMemo(()=>o.find(L=>String(L.id)===String(r))||null,[r,o])?.audio?.ttsEnabled,k=m.useMemo(()=>{if(!T)return null;const L=v?.engine==="espeak"?"espeak":"flite";if(L==="espeak"){let U=Number.isFinite(v?.pitch)?Math.round(v.pitch):void 0;return typeof U=="number"&&(U=Math.max(0,Math.min(99,U))),{speak:!0,engine:L,pitch:U}}const Y=typeof v?.voice=="string"?v.voice:void 0;return{speak:!0,engine:L,voice:Y}},[v?.engine,v?.pitch,v?.voice,T]),R=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",D=n?"min-w-0 flex-1 bg-transparent text-[0.55rem] text-slate-100 placeholder:text-slate-400 focus:outline-none":"min-w-0 flex-1 bg-transparent text-[0.7rem] text-slate-100 placeholder:text-slate-400 focus:outline-none",V=n?"rounded bg-cyan-500/80 px-0.35 py-0.2 text-[0.55rem] font-semibold text-black disabled:opacity-50":"rounded bg-cyan-500/80 px-0.5 py-0.25 text-[0.7rem] font-semibold text-black disabled:opacity-50";async function O(L){if(L.preventDefault(),!N)return;const Y=b.trim();if(Y){E(!0);try{await u(Y,k),S(""),h(),x(!1)}catch(U){alert(U.message)}finally{E(!1)}}}return w?null:l.jsxs("form",{onSubmit:O,className:R,children:[l.jsx("input",{className:D,value:b,onChange:L=>{const Y=L.target.value;S(Y),x(!!Y.trim())},onFocus:L=>{f(L),x(!!b.trim())},onBlur:L=>{p(L),x(!1)},onKeyDown:L=>{L.key==="Enter"&&!b.trim()&&(L.preventDefault(),h(),x(!1))},ref:L=>g(L,{target:"hud"}),placeholder:N?"Chat (TTS)":"Spectator",disabled:!N}),l.jsx("button",{type:"submit",disabled:!N||C,className:V,children:"Speak"})]})}const qw=m.memo(Tw);function mf({layoutFormat:n="desktop"}){const a=oe(f=>f.session?.assignment?.roverId??null),r=tw(a),{state:{lastControlIntentAt:o}}=yt();if(!a)return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"panel-muted content-center text-center text-sm text-slate-400 aspect-[4/3]",children:[l.jsx("p",{children:"You are not assigned to a rover."}),l.jsx("p",{className:"mt-0",children:l.jsx("a",{href:"/spectate",className:"text-blue-400 underline hover:text-blue-500",children:"Click here to visit the spectator page."})})]})});const u=n!=="desktop";return l.jsx("section",{className:"panel",children:l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsxs("div",{className:"relative w-full overflow-hidden bg-black aspect-[4/3]",children:[l.jsx(fr,{roverId:a,videoMode:r}),l.jsx(iw,{mobileHud:u}),l.jsx(Ig,{variant:"default",mobileHud:u,controlIntentAt:o}),l.jsx(Fg,{layoutFormat:n,variant:"default",mobileHud:u,labelScale:1}),l.jsx(bw,{mobileHud:u}),l.jsx(qw,{compact:u}),l.jsx(Xg,{compact:u}),l.jsx(Qg,{compact:u})]}),l.jsx(Rw,{mobileHud:u})]})})}function xo({label:n,tone:a="muted"}){const r=a==="success"?"bg-emerald-900 text-emerald-100":a==="warn"?"bg-amber-900 text-amber-100":"bg-slate-800 text-slate-200";return l.jsx("span",{className:`rounded px-1 py-0.5 text-xs font-semibold leading-none ${r}`,children:n})}function ko(n){if(!Number.isFinite(n))return 0;const a=n%360;return a<0?a+360:a}function Dw(n){if(!Array.isArray(n)||n.length<3)return 0;const[a,r,o]=n,u=Math.max(0,Math.min(255,Number(a)))/255,f=Math.max(0,Math.min(255,Number(r)))/255,p=Math.max(0,Math.min(255,Number(o)))/255,h=Math.max(u,f,p),g=Math.min(u,f,p),x=h-g;if(x===0)return 0;let v=0;return h===u?v=(f-p)/x%6:h===f?v=(p-u)/x+2:v=(u-f)/x+4,ko(Math.round(v*60))}function mx(n){const a=ko(n),r=1,o=1-Math.abs(a/60%2-1);let u=0,f=0,p=0;return a<60?(u=r,f=o):a<120?(u=o,f=r):a<180?(f=r,p=o):a<240?(f=o,p=r):a<300?(u=o,p=r):(u=r,p=o),[Math.round(u*255),Math.round(f*255),Math.round(p*255)]}function hx(n){return n?Array.isArray(n.hsColor)?ko(Number(n.hsColor[0])):Array.isArray(n.rgbColor)?Dw(n.rgbColor):0:0}function _w({entity:n,connected:a,controlsLocked:r,onToggle:o,onSetColor:u,onSetWhite:f}){const p=n.state==="unavailable"||!n.available,h=n.state==="on",g=n.type==="light"&&n.supportsColor,x=p?"warn":h?"success":"muted",v=p?"Unavailable":h?"On":"Off",b=r||!a||p,S=b||!g,[C,E]=m.useState(()=>hx(n)),N=m.useRef(C),w=m.useRef(!1),j=p?"border-slate-800 bg-slate-900 text-slate-400 cursor-not-allowed":r?"border-slate-800 bg-slate-900 text-slate-300 cursor-not-allowed":h?"border-emerald-700 bg-emerald-900/80 text-emerald-50 hover:bg-emerald-800":"border-rose-800 bg-rose-900/80 text-rose-50 hover:bg-rose-800";m.useEffect(()=>{if(!g||w.current)return;const L=hx(n);N.current=L,E(L)},[n.rgbColor,n.hsColor,g]);const T=L=>{const Y=ko(Number(L.target.value));N.current=Y,E(Y)},k=()=>{S||!u||u(n.id,mx(N.current))},R=L=>{L.stopPropagation()},D=L=>{R(L),!(S||!f)&&f(n.id)},O=`rgb(${(g?mx(N.current):[255,255,255]).join(",")})`;return l.jsxs("button",{type:"button",onClick:()=>o(n.id),disabled:b,className:`relative flex min-w-[12rem] flex-[1_1_12rem] items-start justify-between gap-0.5 rounded px-1 py-0.5 text-left transition-colors ${j} disabled:opacity-60 disabled:hover:bg-inherit`,children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-0.5 text-sm leading-normal",children:[l.jsx("span",{className:"truncate font-semibold text-white",children:n.name||n.id}),g&&l.jsxs(l.Fragment,{children:[l.jsx(xo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-xs text-amber-200",children:"Offline"})]})]}),g?l.jsx("div",{className:"-mt-0.5 w-full",onClick:R,onPointerDown:L=>{R(L),w.current=!0},onPointerUp:L=>{R(L),w.current=!1,k()},onPointerCancel:L=>{R(L),w.current=!1,k()},onKeyUp:L=>{R(L),k()},onBlur:k,children:l.jsx("div",{className:"relative w-full",children:l.jsx("input",{type:"range",min:"0",max:"360",step:"1",value:C,onChange:T,disabled:S,"aria-label":`Set color for ${n.name||n.id}`,className:"ha-hue-slider w-full"})})}):l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsx(xo,{label:v,tone:x}),!a&&l.jsx("span",{className:"text-amber-200",children:" · Offline"})]})]}),g&&l.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-0.5",children:[l.jsx("span",{role:"button",tabIndex:S?-1:0,onClick:D,onPointerDown:R,onKeyDown:L=>{S||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),D(L))},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"}),l.jsx("span",{className:"pointer-events-none h-2.5 w-2.5 rounded-full border border-white/60",style:{backgroundColor:O}})]}),!g&&l.jsx("div",{className:"self-center text-xs font-semibold text-white/90",children:h?"Turn off":"Turn on"})]})}function Kg(){const{state:{keymap:n}}=yt(),a=oe(S=>S.session?.homeAssistant||null),{homeAssistantToggle:r,homeAssistantSetLightColor:o,homeAssistantSetLightWhite:u}=$t(),f=m.useMemo(()=>a?.entities||[],[a?.entities]),p=a?.lightPolicy||null,h=!!(p?.locked||p?.lockedOn),g=p?.lockState||(p?.lockedOn?"on":null),x=Tt(n?.homeAssistantOn?.[0]),v=Tt(n?.homeAssistantOff?.[0]);if(!a?.enabled)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"Not configured on the server."})]});if(f.length===0)return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm text-slate-400",children:[l.jsx("p",{className:"text-slate-300",children:"Room Controls"}),l.jsx("p",{className:"text-slate-500",children:"No lights or switches configured."})]});const b=!!a?.connected;return l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("header",{className:"flex items-center justify-between gap-0.5 text-sm text-slate-400",children:[l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("p",{children:"Room Controls"}),l.jsx("span",{className:"text-xs text-slate-500",children:f.length}),h?l.jsx(xo,{label:g==="off"?"Locked Off":"Locked On",tone:"warn"}):null,l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-300 background-black",children:[l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"On"}),x?l.jsx(px,{label:x}):null]}),l.jsxs("span",{className:"flex items-center gap-0.5",children:[l.jsx("span",{children:"Off"}),v?l.jsx(px,{label:v}):null]})]})]}),l.jsx(xo,{label:b?"Connected":"Offline",tone:b?"success":"warn"})]}),h?l.jsx("p",{className:"rounded border border-amber-600/60 bg-amber-900/40 px-1 py-0.5 text-xs text-amber-100",children:g==="off"?"Lights are locked off. Room controls are disabled.":"Lights are locked on. Room controls are disabled."}):null,l.jsx("div",{className:"flex flex-wrap gap-0.5",children:f.map(S=>l.jsx(_w,{entity:S,connected:b,controlsLocked:h,onToggle:r,onSetColor:o,onSetWhite:u},S.id))})]})}function px({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function Zg(){const{login:n,setRole:a}=$t(),[r,o]=m.useState(""),[u,f]=m.useState(""),[p,h]=m.useState(!1);async function g(x){x.preventDefault(),h(!0);try{await n(r,u),o(""),f("")}catch(v){alert(v.message)}finally{h(!1)}}return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Admin login"}),l.jsxs("form",{className:"flex flex-col gap-0.5",onSubmit:g,children:[l.jsx("input",{className:"field-input",placeholder:"Username",value:r,onChange:x=>o(x.target.value)}),l.jsx("input",{className:"field-input",placeholder:"Password",type:"password",value:u,onChange:x=>f(x.target.value)}),l.jsx("button",{type:"submit",disabled:p,className:"button-dark w-full disabled:opacity-50",children:p?"Logging in…":"Login"})]})]})}function xx(...n){return n.filter(Boolean).join(" ")}function Bw(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function Ow(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function Lw({title:n,roster:a=[],emptyText:r="No roster data.",renderActions:o=null}){return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),a.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:r}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:a.map(u=>{const f=!!(u?.private?.enabled&&u?.private?.open),p=!!u?.locked;return l.jsxs("li",{className:xx("surface flex flex-wrap items-center justify-between gap-0.5",p?"bg-red-900/40":f?"bg-amber-700/35 border border-amber-200/30":null),children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-slate-200",children:l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(u.color,.16),children:u.name})}),l.jsxs("p",{className:"text-xs text-slate-500 flex flex-wrap items-center gap-0.5",children:[l.jsx("span",{children:u.locked?"locked":"free"}),u.lockReason&&l.jsx("span",{className:"rounded bg-black/30 px-1",children:u.lockReason}),l.jsxs("span",{className:xx("font-semibold",Ow(u)),children:["Battery ",Bw(u)]})]})]}),o?o(u):null]},u.id)})})]})}function zw(n){const a=n?.runtime||{},r=n?.output||{},o=n?.errors||{};return a.inFlight?{label:"IN FLIGHT",detail:a.reason||"Generating commentary now",className:"border-amber-400/60 bg-amber-700/20 text-amber-200"}:a.outcome==="posted"?{label:"POSTED",detail:r.posted?`Last: ${r.posted}`:"Commentary posted",className:"border-emerald-400/60 bg-emerald-700/20 text-emerald-200"}:a.outcome==="skipped"?{label:"SKIPPED",detail:a.reason||"Model chose to skip",className:"border-slate-400/60 bg-slate-700/30 text-slate-200"}:a.outcome==="failed"?{label:"FAILED",detail:o.message||a.reason||"Tick failed",className:"border-red-400/60 bg-red-700/20 text-red-200"}:{label:a.running?"IDLE":"STOPPED",detail:a.reason||"Waiting for next tick",className:"border-sky-400/50 bg-sky-700/20 text-sky-200"}}function Uw(n,a){const r=Date.now(),u=(Array.isArray(n)?n:[]).map((f,p)=>{const h=String(f?.role||"").toLowerCase(),g=typeof f?.content=="string"?f.content:JSON.stringify(f?.content??null,null,2),x=h==="system"?"LLM System":h==="assistant"?"LLM Context":h==="user"?"LLM Input":"LLM Message";return{id:`llm-msg-${p}`,message:{ts:r+p,nickname:x,text:g,role:"spectator",bot:h==="system"}}});if(a!=null){const f=String(a);u.push({id:"llm-output",message:{ts:r+u.length+1,nickname:"LLM Output",text:f.trim()?f:"<empty>",role:"spectator",bot:!0}})}return u}function Hw({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(null);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.counters||{},h=n.timings||{},g=n.input||{},x=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),C=zw(n),E=Uw(g.modelMessages,x.raw),N=[{label:"running",value:f.running?"yes":"no"},{label:"in flight",value:f.inFlight?"yes":"no"},{label:"phase",value:f.phase||"--"},{label:"run id",value:f.currentRunId??"--"},{label:"tick count",value:f.tickCount??0},{label:"last tick",value:f.lastTickAt?new Date(f.lastTickAt).toLocaleString():"never"},{label:"next run",value:f.nextRunAt?new Date(f.nextRunAt).toLocaleString():"n/a"},{label:"outcome",value:f.outcome||"--"},{label:"reason",value:f.reason||"--"},{label:"skip streak",value:p.skipStreak??0},{label:"clear count",value:p.clearCount??0},{label:"last gen",value:h.lastGenerationMs!=null?`${h.lastGenerationMs} ms`:"--"},{label:"avg gen",value:h.avgGenerationMs!=null?`${h.avgGenerationMs} ms`:"--"},{label:"gen count",value:h.generationCount??0},{label:"prompt chars",value:p.promptChars??0},{label:"active drivers",value:p.snapshotSummary?.activeDrivers??0},{label:"snapshot rovers",value:p.snapshotSummary?.rovers??0},{label:"snapshot chat",value:p.snapshotSummary?.chatMessages??0}];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"LLM Commentary"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear LLM History"})}),l.jsxs("div",{className:`surface border text-center ${C.className}`,children:[l.jsx("div",{className:"text-[1.1rem] font-bold tracking-wide",children:C.label}),l.jsx("div",{className:"text-xs text-slate-200",children:C.detail})]}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:N.map(w=>l.jsxs("span",{className:"rounded border border-slate-600/60 bg-slate-800/70 px-0.5 py-0.25 text-[0.72rem] leading-tight text-slate-200",children:[w.label,": ",w.value]},w.label))}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300 break-words",children:["Error: ",v.message]}):null,v.details?l.jsxs("details",{className:"surface text-xs text-red-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-red-300",children:"Failure details"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-red-200",children:JSON.stringify(v.details,null,2)})]}):null,x.generated?l.jsxs("div",{className:"surface text-xs text-slate-200 break-words",children:["Generated: ",x.generated]}):null,x.posted?l.jsxs("div",{className:"surface text-xs text-emerald-200 break-words",children:["Posted: ",x.posted]}):null,l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-2",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Live Input Conversation"}),l.jsx("div",{className:"surface max-h-72 space-y-0.5 overflow-y-auto",children:E.length?E.map(w=>l.jsx(nf,{message:w.message},w.id)):l.jsx("div",{className:"text-xs text-slate-300",children:"No model conversation captured yet."})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Output + Error"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{children:["Raw output: ",x.raw?.trim()?x.raw:"<none>"]}),l.jsxs("div",{children:["Posted: ",x.posted||"<none>"]}),l.jsxs("div",{children:["Output at: ",x.modelOutputAt?new Date(x.modelOutputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Failed at: ",v.failedAt?new Date(v.failedAt).toLocaleString():"n/a"]})]})]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Full Monitor Payload"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Recent Runs"}),l.jsx("div",{className:"surface max-h-52 space-y-0.5 overflow-y-auto text-xs",children:b.length?b.slice().reverse().map(w=>l.jsxs("button",{type:"button",onClick:()=>u(w.runId),className:`w-full text-left surface ${S?.runId===w.runId?"border border-sky-400/50":""}`,children:[l.jsxs("span",{className:"text-slate-300",children:["#",w.runId]})," ",l.jsx("span",{className:"text-slate-200",children:w.outcome||w.phase||"--"})," ",l.jsx("span",{className:"text-slate-400",children:w.durationMs!=null?`${w.durationMs}ms`:"--"})," ",l.jsx("span",{className:"text-slate-500",children:w.reason||""})]},w.runId)):l.jsx("div",{className:"text-slate-300",children:"No runs recorded yet."})})]}),S?l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsxs("summary",{className:"cursor-pointer select-none text-slate-300",children:["Run #",S.runId," details"]}),l.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 Vw({state:n,onClearHistory:a,clearingHistory:r}){const[o,u]=m.useState(!1);if(!n)return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"surface text-xs text-slate-300",children:"No status received yet."})]});const f=n.runtime||{},p=n.config||{},h=n.output||{},g=n.timings||{},x=n.input||{},v=n.errors||{},b=()=>{const S=Array.isArray(x.modelMessages)?x.modelMessages:[];return S.length?S.map((C,E)=>{const N=String(C?.role||"unknown").toUpperCase(),w=String(C?.content||"");return`#${E+1} ${N}
|
||
${w}`}).join(`
|
||
|
||
----------------------------------------
|
||
|
||
`):"<none>"};return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Overseer Control"}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:a,disabled:!!r,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:r?"Clearing...":"Clear Overseer History"})}),l.jsxs("div",{className:"surface flex flex-wrap gap-0.5 text-xs",children:[l.jsxs("span",{className:"surface-muted",children:["running: ",f.running?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["phase: ",f.phase||"--"]}),l.jsxs("span",{className:"surface-muted",children:["tick: ",f.tickCount??0]}),l.jsxs("span",{className:"surface-muted",children:["trigger: ",f.lastTriggerReason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["name: ",p.name||"--"]}),l.jsxs("span",{className:"surface-muted",children:["model: ",p.model||"--"]}),l.jsxs("span",{className:"surface-muted",children:["observeOnly: ",p.observeOnly?"yes":"no"]}),l.jsxs("span",{className:"surface-muted",children:["decision: ",h.normalized||"--"]}),l.jsxs("span",{className:"surface-muted",children:["outcome: ",h.outcome||"--"]}),l.jsxs("span",{className:"surface-muted",children:["reason: ",h.reason||"--"]}),l.jsxs("span",{className:"surface-muted",children:["last gen: ",g.lastGenerationMs!=null?`${g.lastGenerationMs}ms`:"--"]})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Latest Context"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.stateUpdate||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Input (messages[])"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:b()})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact System Prompt"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:x.systemPrompt||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Transcript Rows"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(x.transcript||[],null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Tool Availability"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify({available:x.availableTools,blocked:x.blockedTools},null,2)})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Exact Model Output"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:h.raw||"<none>"})]}),l.jsxs("details",{className:"surface text-xs text-slate-200",open:!0,children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Live Tool Calls"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(h.liveToolCalls||[],null,2)})]}),l.jsxs("div",{className:"surface text-xs text-slate-200",children:[l.jsxs("div",{children:["Normalized decision: ",h.normalized||"--"]}),l.jsxs("div",{children:["Model input at: ",x.modelInputAt?new Date(x.modelInputAt).toLocaleString():"n/a"]}),l.jsxs("div",{children:["Model output at: ",h.outputAt?new Date(h.outputAt).toLocaleString():"n/a"]})]}),v.message?l.jsxs("div",{className:"surface text-xs text-red-300",children:["Error: ",v.message]}):null,l.jsxs("details",{className:"surface text-xs text-slate-200",children:[l.jsx("summary",{className:"cursor-pointer select-none text-slate-300",children:"Recent Runs"}),l.jsx("pre",{className:"mt-0.5 whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n.history||[],null,2)})]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>u(S=>!S),children:o?"Hide Full Payload":"Show Full Payload"}),o?l.jsx("pre",{className:"surface whitespace-pre-wrap break-words text-[0.72rem] text-slate-200",children:JSON.stringify(n,null,2)}):null]})}function $w({health:n,roster:a=[]}){if(!n)return null;const r=n.replay||{sources:[],readyCount:0,totalCount:0},o=n.snapshots||{rovers:[],rooms:[]},u=g=>a.find(x=>String(x.id)===String(g))?.color||null,f=`${r.readyCount}/${r.totalCount} sources ready`,p=o.rovers.filter(g=>g.stale).length,h=o.rooms.filter(g=>g.stale).length;return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"panel-muted text-xs uppercase",children:"Health"}),l.jsxs("div",{className:"surface space-y-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Replay segments"}),l.jsx("span",{className:"text-slate-400",children:f})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Rover snapshots"}),l.jsxs("span",{className:p?"text-amber-300":"text-emerald-300",children:[o.rovers.length-p,"/",o.rovers.length," ok"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Room cameras"}),l.jsxs("span",{className:h?"text-amber-300":"text-emerald-300",children:[o.rooms.length-h,"/",o.rooms.length," ok"]})]})]}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:r.sources.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:`${g.type==="rover"?"rounded px-1 py-[1px] border border-transparent":""}`,style:g.type==="rover"?ns(u(g.id),.16):void 0,children:g.label}),l.jsxs("span",{className:g.ready?"text-emerald-300":"text-amber-300",children:[g.recentCount,"/",g.neededCount]})]},`${g.type}:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rovers.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(u(g.id),.16),children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.stale?"stale":"ok"})]},`rover:${g.id}`))}),l.jsx("div",{className:"space-y-0.5 text-xs text-slate-300",children:o.rooms.map(g=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{children:g.name}),l.jsx("span",{className:g.stale?"text-amber-300":"text-emerald-300",children:g.error?"error":g.stale?"stale":"ok"})]},`room:${g.id}`))})]})}function Gw({entries:n}){const a=n||[];return l.jsxs("div",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Admin IP log"}),l.jsx("span",{children:a.length})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No admin log entries yet."}):a.slice().reverse().map(r=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-amber-400",children:r.ts?new Date(r.ts).toLocaleTimeString():"--"})," ",r.label&&l.jsxs("span",{className:"text-teal-400",children:["[",r.label,"]"]})," ",l.jsx("span",{className:"text-slate-200",children:r.message})," ",r.ip&&l.jsx("span",{className:"text-cyan-300",children:r.ip})," ",r.meta&&l.jsx("span",{className:"text-slate-500",children:JSON.stringify(r.meta)})]},r.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Admin-only log stream; IPs never appear in user data."})]})}const Yw=[{key:"open",label:"Open"},{key:"turns",label:"Turns"},{key:"admin",label:"Admin"},{key:"lockdown",label:"Lockdown"}];function Fw(){const{session:n,lockRover:a,setMode:r,requestControl:o,setGlobalObjective:u,setAdminReason:f,rebootRover:p,rebootServer:h,setAudioLevels:g,setPrivateSafety:x,llmControl:v,overseerControl:b,adminLogs:S,llmCommentaryState:C,overseerControlState:E}=br(),N=m.useMemo(()=>n?.roster??[],[n?.roster]),[w,j]=m.useState({}),[T,k]=m.useState({}),[R,D]=m.useState(!1),[V,O]=m.useState(!1),[L,Y]=m.useState(!1),U=n?.health||null,X=n?.globalObjective?.text||"",Q=n?.globalObjective?.updatedAt||null,[ce,ue]=m.useState(X),W=n?.adminReason?.text||"",B=n?.adminReason?.updatedAt||null,[I,K]=m.useState(W),P=n?.audioLevels||{},[ie,M]=m.useState({hornGain:Number.isFinite(P.hornGain)?P.hornGain:1,ttsGain:Number.isFinite(P.ttsGain)?P.ttsGain:1,forwardGain:Number.isFinite(P.forwardGain)?P.forwardGain:1}),[q,Z]=m.useState({}),le=n?.role==="admin"||n?.role==="lockdown"||n?.role==="lockdown-admin",he=n?.role==="lockdown"||n?.role==="lockdown-admin",we=n?.mode??"open",pe=async(ne,me)=>{try{await a(ne,me),j(De=>({...De,[ne]:me}))}catch(De){alert(De.message)}},xe=async ne=>{const me=ne.target.value;try{await r(me)}catch(De){alert(De.message)}},ge=async ne=>{try{await o(ne,{force:!0})}catch(me){alert(me.message)}},Se=async ne=>{if(!(!ne?.id||!window.confirm(`Reboot rover "${ne.name||ne.id}" now?`))){k(De=>({...De,[ne.id]:!0}));try{await p(ne.id)}catch(De){alert(De.message)}finally{k(De=>({...De,[ne.id]:!1}))}}},be=async()=>{if(window.confirm("Reboot the server host now? This will disconnect all users.")){D(!0);try{await h()}catch(me){alert(me.message),D(!1)}}},$e=async()=>{if(window.confirm("Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.")){O(!0);try{await v("clearHistory")}catch(me){alert(me.message)}finally{O(!1)}}},Ze=async()=>{if(window.confirm("Clear Overseer Control history now?")){Y(!0);try{await b("clearHistory")}catch(me){alert(me.message)}finally{Y(!1)}}},je=async()=>{try{await u(ce)}catch(ne){alert(ne.message)}},lt=async()=>{try{await u(null)}catch(ne){alert(ne.message)}},Ie=async()=>{try{await f(I)}catch(ne){alert(ne.message)}},ft=async()=>{try{await f(null)}catch(ne){alert(ne.message)}},Ae=ne=>me=>{const De=Number(me.target.value);M(en=>({...en||{},[ne]:Number.isFinite(De)?De:1}))},ae=async()=>{try{await g(ie)}catch(ne){alert(ne.message)}},re=async()=>{window.dispatchEvent(new CustomEvent("buttonBox:rewardRunLocalTest",{detail:{rewardName:"Admin Mode",count:1e3,goal:1e3}}))};m.useEffect(()=>{ue(X)},[X]),m.useEffect(()=>{K(W)},[W]),m.useEffect(()=>{M({hornGain:Number.isFinite(P.hornGain)?P.hornGain:1,ttsGain:Number.isFinite(P.ttsGain)?P.ttsGain:1,forwardGain:Number.isFinite(P.forwardGain)?P.forwardGain:1})},[P.forwardGain,P.hornGain,P.ttsGain]),m.useEffect(()=>{const ne={};(N||[]).forEach(me=>{me?.private?.enabled&&(ne[me.id]={speedLimitEnabled:!!me?.private?.safety?.speedLimitEnabled,speedLimitMaxWheelSpeed:Number.isFinite(me?.private?.safety?.speedLimitMaxWheelSpeed)?me.private.safety.speedLimitMaxWheelSpeed:250,hardOvercurrentEnabled:!!me?.private?.safety?.hardOvercurrentEnabled,overcurrentStopMs:Number.isFinite(me?.private?.safety?.overcurrentStopMs)?me.private.safety.overcurrentStopMs:300,hardBumpEnabled:!!me?.private?.safety?.hardBumpEnabled,bumpBackoffSpeed:Number.isFinite(me?.private?.safety?.bumpBackoffSpeed)?me.private.safety.bumpBackoffSpeed:250,bumpBackoffMs:Number.isFinite(me?.private?.safety?.bumpBackoffMs)?me.private.safety.bumpBackoffMs:350,cliffEnabled:!!me?.private?.safety?.cliffEnabled,cliffBackoffSpeed:Number.isFinite(me?.private?.safety?.cliffBackoffSpeed)?me.private.safety.cliffBackoffSpeed:250,cliffBackoffMs:Number.isFinite(me?.private?.safety?.cliffBackoffMs)?me.private.safety.cliffBackoffMs:500,triggerCooldownMs:Number.isFinite(me?.private?.safety?.triggerCooldownMs)?me.private.safety.triggerCooldownMs:800})}),Z(ne)},[N]);const de=m.useMemo(()=>{const ne={};return N.forEach(me=>{ne[me.id]=w[me.id]??me.locked}),ne},[N,w]),fe=(ne,me={})=>{Z(De=>({...De||{},[ne]:{...De?.[ne]||{},...me||{}}}))},Re=async ne=>{try{const me=q?.[ne];if(!me)return;await x(ne,me)}catch(me){alert(me.message)}};return le?l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-sm",children:[l.jsx("span",{children:"Admin controls"}),l.jsx("select",{value:we,onChange:xe,className:"field-input text-sm",children:Yw.map(ne=>l.jsx("option",{value:ne.key,children:ne.label},ne.key))})]}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:be,disabled:R,className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:R?"Server rebooting...":"Reboot Server"}),l.jsx("button",{type:"button",onClick:re,className:"button-dark",children:"Test Reward Popup"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global audio levels"}),n?.audioLevels?.updatedAt?l.jsxs("span",{children:["Updated ",new Date(n.audioLevels.updatedAt).toLocaleString()]}):null]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Horn gain"}),l.jsxs("span",{children:[ie.hornGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.hornGain,onChange:Ae("hornGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"TTS gain"}),l.jsxs("span",{children:[ie.ttsGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.ttsGain,onChange:Ae("ttsGain"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-xs text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Forward gain"}),l.jsxs("span",{children:[ie.forwardGain.toFixed(2),"x"]})]}),l.jsx("input",{type:"range",min:"0",max:"4",step:"0.01",value:ie.forwardGain,onChange:Ae("forwardGain"),className:"w-full accent-emerald-500"})]}),l.jsx("div",{className:"flex gap-0.5 text-xs",children:l.jsx("button",{type:"button",onClick:ae,className:"button-dark",children:"Apply audio levels"})})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Global objective"}),Q?l.jsxs("span",{children:["Updated ",new Date(Q).toLocaleString()]}):null]}),l.jsx("input",{type:"text",value:ce,onChange:ne=>ue(ne.target.value),placeholder:"Set a global objective",className:"field-input text-sm"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:je,className:"button-dark",children:"Set objective"}),l.jsx("button",{type:"button",onClick:lt,className:"button-danger",children:"Clear"})]})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Admin mode reason"}),B?l.jsxs("span",{children:["Updated ",new Date(B).toLocaleString()]}):null]}),l.jsx("textarea",{value:I,onChange:ne=>K(ne.target.value),placeholder:"Set an admin mode reason",className:"field-input text-sm min-h-[3.5rem]"}),l.jsxs("div",{className:"flex gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:Ie,className:"button-dark",children:"Set reason"}),l.jsx("button",{type:"button",onClick:ft,className:"button-danger",children:"Clear"})]})]}),l.jsx(Lw,{roster:N,renderActions:ne=>l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 text-xs",children:[l.jsx("button",{type:"button",onClick:()=>pe(ne.id,!de[ne.id]),className:"button-dark",children:de[ne.id]?"Unlock":"Lock"}),l.jsx("button",{type:"button",onClick:()=>ge(ne.id),className:"button-dark",children:"Force"}),l.jsx("button",{type:"button",onClick:()=>Se(ne),disabled:!!T[ne.id],className:"button-danger disabled:cursor-not-allowed disabled:opacity-60",children:T[ne.id]?"Rebooting...":"Reboot"}),ne?.private?.enabled?l.jsxs("div",{className:"w-full rounded border border-slate-700/70 p-0.5 space-y-0.5 text-[0.7rem]",children:[l.jsx("div",{className:"text-slate-300",children:"Private safety"}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!q?.[ne.id]?.speedLimitEnabled,disabled:!he,onChange:me=>fe(ne.id,{speedLimitEnabled:!!me.target.checked})}),l.jsx("span",{children:"Speed limit"})]}),l.jsx("input",{type:"number",min:"1",max:"500",className:"field-input text-xs w-20",disabled:!he,value:q?.[ne.id]?.speedLimitMaxWheelSpeed??250,onChange:me=>fe(ne.id,{speedLimitMaxWheelSpeed:Number(me.target.value)||250})}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!q?.[ne.id]?.hardOvercurrentEnabled,disabled:!he,onChange:me=>fe(ne.id,{hardOvercurrentEnabled:!!me.target.checked})}),l.jsx("span",{children:"Hard overcurrent"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!q?.[ne.id]?.hardBumpEnabled,disabled:!he,onChange:me=>fe(ne.id,{hardBumpEnabled:!!me.target.checked})}),l.jsx("span",{children:"Hard bump"})]}),l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!!q?.[ne.id]?.cliffEnabled,disabled:!he,onChange:me=>fe(ne.id,{cliffEnabled:!!me.target.checked})}),l.jsx("span",{children:"Cliff safety"})]}),l.jsx("button",{type:"button",disabled:!he,onClick:()=>Re(ne.id),className:"button-dark disabled:opacity-50",children:"Apply Safety"})]}):null]})}),l.jsx($w,{health:U,roster:N}),l.jsx(Hw,{state:C,onClearHistory:$e,clearingHistory:V}),l.jsx(Vw,{state:E,onClearHistory:Ze,clearingHistory:L}),l.jsx(Gw,{entries:S})]}):null}const Iw=[{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 Xw(n){return n.reduce((a,r)=>((a[r.group]||(a[r.group]=[])).push(r),a),{})}function Qw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(0,Math.min(500,r)):a}const hf=5,hr=500,pr=1,pf=100;function Kw(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(hf,Math.min(hr,r)):a}function ro(n,a){const r=Number(n);return Number.isFinite(r)?Math.max(pr,Math.min(pf,r)):a}function Zw(n){const r=(ro(n,n)-pr)/(pf-pr),o=hr-r*(hr-hf);return Math.round(o)}function Jw(n){const a=Kw(n,n),r=(hr-a)/(hr-hf),o=pr+r*(pf-pr);return Math.round(o)}function Pw(n){const[a,r]=m.useState(null),o=m.useCallback(p=>{sd(!0),r(p)},[]),u=m.useCallback(()=>{sd(!1),r(null)},[]),f=m.useCallback((p,h)=>{if(h.preventDefault(),h.stopPropagation(),h.key==="Escape"){u();return}const g=Sr(h.key??"");g&&(n(p,g,h),u())},[u,n]);return m.useEffect(()=>()=>sd(!1),[]),{active:a,startCapture:o,cancel:u,captureFromEvent:f}}function Xi({label:n,description:a,value:r,onChange:o,min:u=0,max:f=500,step:p=5}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("input",{type:"number",min:u,max:f,value:r,onChange:h=>o(h.target.value),className:"w-16 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.75rem] font-mono text-slate-100"})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsxs("div",{className:"mt-0 flex items-center gap-0.5",children:[l.jsx("input",{type:"range",min:u,max:f,step:p,value:r,onChange:h=>o(h.target.value),className:"h-2 flex-1 accent-emerald-400"}),l.jsx("span",{className:"w-12 text-right text-[0.75rem] font-mono text-slate-400",children:r})]})]})}function Ww(){const{state:{keymap:n},actions:{updateKeyBinding:a,resetKeyBindings:r}}=yt(),{value:o,save:u}=Ve("inputs",En),f={...En.keyboard,...o.keyboard??{}},p=m.useMemo(()=>typeof f.tiltSpeed=="number"?ro(f.tiltSpeed,En.keyboard.tiltSpeed):typeof f.tiltIntervalMs=="number"?ro(Jw(f.tiltIntervalMs),En.keyboard.tiltSpeed):En.keyboard.tiltSpeed,[f.tiltIntervalMs,f.tiltSpeed]),h=m.useMemo(()=>Xw(Iw),[]),{active:g,startCapture:x,cancel:v,captureFromEvent:b}=Pw((N,w)=>{a(N,w)}),S=m.useCallback(N=>n?.[N]?.[0]||ir[N]?.[0]||"",[n]),C=m.useCallback((N,w)=>{const j=En.keyboard,T=Qw(w,j[N]);u(k=>({...k??{},keyboard:{...k?.keyboard??j,[N]:T}}))},[u]),E=m.useCallback(N=>{const w=En.keyboard,j=ro(N,w.tiltSpeed),T=Zw(j);u(k=>({...k??{},keyboard:{...k?.keyboard??w,tiltSpeed:j,tiltIntervalMs:T}}))},[u]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Keyboard layout"}),l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Per-browser · click to change a binding"})]}),l.jsx("button",{type:"button",onClick:()=>r(),className:"button-dark text-xs",children:"Reset defaults"})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Keyboard speeds"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Xi,{label:"Base speed",description:"Normal driving speed",value:f.baseSpeed,onChange:N=>C("baseSpeed",N)}),l.jsx(Xi,{label:"Turbo speed",description:"Used when holding the boost modifier",value:f.turboSpeed,onChange:N=>C("turboSpeed",N)}),l.jsx(Xi,{label:"Precision speed",description:"Used when holding the precision modifier",value:f.precisionSpeed,onChange:N=>C("precisionSpeed",N)})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Camera tilt"}),l.jsx(Xi,{label:"Tilt speed",description:"Higher = faster when holding tilt keys",value:p,onChange:E,min:1,max:100,step:1})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(h).map(([N,w])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.75rem] text-slate-400",children:N}),l.jsx("div",{className:"space-y-0.5",children:w.map(j=>{const T=S(j.id),k=g===j.id;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:j.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:Tt(T)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[k&&l.jsx("button",{type:"button",onClick:()=>v(),className:"button-danger text-[0.7rem]",children:"Cancel"}),l.jsx("button",{type:"button",onClick:()=>x(j.id),onKeyDown:k?R=>b(j.id,R):void 0,autoFocus:k,className:`${k?"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:k?"Press a key…":"Change"})]})]},j.id)})})]},N))})]})}const Pn=new Intl.NumberFormat(void 0,{maximumFractionDigits:2}),eA=[{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"}],gx=.45,tA=.6;function sr({label:n,description:a,min:r,max:o,step:u,value:f,onChange:p}){return l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:n}),l.jsx("span",{className:"font-mono text-slate-400",children:Pn.format(f)})]}),a&&l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:a}),l.jsx("input",{type:"range",min:r,max:o,step:u,value:f,onChange:h=>p(Number(h.target.value)),className:"mt-0 w-full accent-emerald-400"})]})}function nA(n){if(!n)return"Unassigned";if(n.kind==="axisPair"){const a=`${n.invertX?"X inv ":""}${n.invertY?"Y inv":""}`.trim();return`Axes ${n.x}/${n.y}${a?` (${a})`:""}`}if(n.kind==="axis")return`Axis ${n.index}${n.invert?" (inv)":""}`;if(n.kind==="button")return`Button ${n.index}`;if(n.kind==="buttonAxis")return`Button ${n.index} (analog)`;if(n.kind==="axisButton"){const a=n.direction<0?"<":">";return`Axis ${n.index} ${a} ${Pn.format(n.threshold??.6)}`}return"Unassigned"}function sA(n){return n.reduce((a,r)=>((a[r.section]||(a[r.section]=[])).push(r),a),{})}function aA(n,a){if(!n||n.length===0)return null;if(a){const r=n.find(o=>o.signature===a);if(r)return r}return n[0]}function lA(n){return{axes:Array.from(n.axes??[]),buttons:(n.buttons??[]).map(a=>({pressed:!!a?.pressed,value:typeof a?.value=="number"?a.value:a?.pressed?1:0}))}}function rA(n,a,r){const o=(n.axes??[]).map((f,p)=>({index:p,delta:Math.abs((f??0)-(a.axes?.[p]??0)),value:f}));if(o.sort((f,p)=>p.delta-f.delta),r.kind==="axisPair"){const f=o.filter(p=>p.delta>gx).slice(0,2);return f.length<2?null:{kind:"axisPair",x:f[0].index,y:f[1].index,...r.invertDefaults??{}}}const u=o.find(f=>f.delta>gx);return u?{kind:"axis",index:u.index,...r.invertDefaults??{}}:null}function iA(n,a,r){const o=n.buttons??[];for(let f=0;f<o.length;f+=1){const p=o[f],h=typeof p?.value=="number"?p.value:p?.pressed?1:0;if(p?.pressed||h>tA)return r.kind==="axis"?{kind:"buttonAxis",index:f}:{kind:"button",index:f}}const u=n.axes??[];for(let f=0;f<u.length;f+=1){const p=u[f]??0,h=Math.abs(p-(a.axes?.[f]??0));if(Math.abs(p)>.7&&h>.5)return r.kind==="axis"?{kind:"axis",index:f,...r.invertDefaults??{}}:{kind:"axisButton",index:f,direction:p>=0?1:-1,threshold:.6}}return null}function oA(n,a,r){if(!n)return null;if(r.kind==="axis"||r.kind==="axisPair"){const o=rA(n,a,r);if(o)return o}return iA(n,a,r)}function cA(){const n=CN(),{value:a,save:r}=Ve("gamepad",Es),[o,u]=m.useState(null),f=m.useRef(null),p=m.useMemo(()=>sA(eA),[]),h=m.useMemo(()=>aA(n.pads,a.activeSignature),[n.pads,a.activeSignature]),g=h?.signature??null,x=m.useMemo(()=>g?a?.profiles?.[g]??a?.defaults?.profile??Wn:a?.defaults?.profile??Wn,[g,a?.defaults?.profile,a?.profiles]);m.useEffect(()=>{!h||!g||a?.profiles?.[g]||r(w=>{const j=w??Es;if(j.profiles?.[g])return j;const T=j?.defaults?.profile??Wn,k=Mg(h,T);return{...j,profiles:{...j.profiles??{},[g]:k}}})},[h,g,a?.profiles,r]),m.useEffect(()=>{f.current=null},[o,g]),m.useEffect(()=>{if(!o||!h)return;if(!f.current){f.current=lA(h);return}const w=oA(h,f.current,o);w&&(r(j=>{const T=j??Es,k=T.profiles?.[g]??T?.defaults?.profile??Wn,R={...k,bindings:{...k.bindings??{},[o.id]:{...k.bindings?.[o.id]??{},kind:o.kind,sources:[w]}}};return{...T,profiles:{...T.profiles??{},[g]:R}}}),u(null))},[h,g,o,r]);const v=m.useCallback(w=>{r(j=>({...j??Es,activeSignature:w||null}))},[r]),b=m.useCallback(w=>{r(j=>{const T=j??Es,k=(g&&T.profiles?.[g])??T?.defaults?.profile??Wn,R={...k,calibration:{...k.calibration??{},...w}};return g?{...T,profiles:{...T.profiles??{},[g]:R}}:{...T,defaults:{...T.defaults??{},profile:R}}})},[g,r]),S=m.useCallback((w,j)=>{r(T=>{const k=T??Es,R=(g&&k.profiles?.[g])??k?.defaults?.profile??Wn,D=j(R.bindings?.[w]??{}),V={...R,bindings:{...R.bindings??{},[w]:D}};return g?{...k,profiles:{...k.profiles??{},[g]:V}}:{...k,defaults:{...k.defaults??{},profile:V}}})},[g,r]),C=m.useCallback(w=>{S(w.id,j=>({...j,sources:[]}))},[S]),E=m.useCallback((w,j)=>{S(w.id,T=>{const k=Array.isArray(T.sources)?[...T.sources]:[];if(!k[0])return T;const R={...k[0]};return j==="invertX"?R.invertX=!R.invertX:j==="invertY"?R.invertY=!R.invertY:R.invert=!R.invert,k[0]=R,{...T,sources:k}})},[S]),N=m.useMemo(()=>h?{outputs:Rg(h,x)}:null,[h,x]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Controller"}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:h?"Move sticks or press buttons to bind":"Connect a controller to configure."}),o&&l.jsxs("p",{className:"mt-0 text-[0.7rem] text-emerald-400",children:["Capturing ",o.label,"…"]})]})}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Connected controller"}),n.pads.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."}):l.jsxs("div",{className:"flex items-center justify-between gap-0.5 text-xs",children:[l.jsx("select",{value:g??"",onChange:w=>v(w.target.value),className:"flex-1 rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:n.pads.map(w=>l.jsx("option",{value:w.signature,children:w.id||"Unknown controller"},w.signature))}),l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:h?.mapping??"unknown"})]})]}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Calibration"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(sr,{label:"Drive deadzone",description:"Ignore small drive stick drift",min:0,max:.6,step:.01,value:x.calibration?.driveDeadzone??.18,onChange:w=>b({driveDeadzone:w})}),l.jsx(sr,{label:"Camera deadzone",description:"Ignore small camera tilt drift",min:0,max:.4,step:.01,value:x.calibration?.cameraDeadzone??.08,onChange:w=>b({cameraDeadzone:w})}),l.jsx(sr,{label:"Aux deadzone",description:"Ignore small trigger noise",min:0,max:.4,step:.01,value:x.calibration?.auxDeadzone??.05,onChange:w=>b({auxDeadzone:w})}),l.jsx(sr,{label:"Side brush scale",description:"Scale side brush output",min:.3,max:1,step:.05,value:x.calibration?.auxSideScale??.55,onChange:w=>b({auxSideScale:w})}),l.jsxs("label",{className:"surface-muted block p-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-300",children:[l.jsx("span",{className:"font-semibold text-slate-100",children:"Camera mode"}),l.jsxs("select",{value:x.calibration?.cameraMode??"absolute",onChange:w=>b({cameraMode:w.target.value}),className:"rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-[0.75rem] text-slate-100",children:[l.jsx("option",{value:"absolute",children:"Absolute"}),l.jsx("option",{value:"velocity",children:"Velocity"})]})]}),l.jsx("p",{className:"text-[0.65rem] text-slate-500",children:"Absolute maps stick to angle; velocity moves over time."})]}),l.jsx(sr,{label:"Camera sensitivity",description:"Velocity mode degrees per second",min:10,max:180,step:5,value:x.calibration?.cameraSensitivity??60,onChange:w=>b({cameraSensitivity:w})})]})]}),l.jsx("div",{className:"space-y-0.5",children:Object.entries(p).map(([w,j])=>l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:w}),l.jsx("div",{className:"space-y-0.5",children:j.map(T=>{const R=x.bindings?.[T.id]?.sources?.[0]??null;return l.jsxs("div",{className:"surface-muted flex items-center justify-between text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-slate-100",children:T.label}),l.jsx("p",{className:"text-[0.65rem] text-slate-400",children:nA(R)})]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[T.kind==="axisPair"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:!R,onClick:()=>E(T,"invertX"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert X"}),l.jsx("button",{type:"button",disabled:!R,onClick:()=>E(T,"invertY"),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert Y"})]}),T.kind==="axis"&&l.jsx("button",{type:"button",disabled:!R,onClick:()=>E(T),className:"button-dark text-[0.7rem] font-medium disabled:opacity-50",children:"Invert"}),l.jsx("button",{type:"button",onClick:()=>C(T),className:"button-dark text-[0.7rem]",children:"Clear"}),l.jsx("button",{type:"button",onClick:()=>u(T),className:`${o?.id===T.id?"px-0.5 py-0.5 bg-emerald-500 text-emerald-950 hover:bg-emerald-400":"button-dark"} text-[0.7rem] font-medium`,children:o?.id===T.id?"Waiting…":"Capture"})]})]},T.id)})})]},w))}),l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"Diagnostics"}),h?l.jsxs("div",{className:"space-y-0.5 text-[0.7rem] text-slate-300",children:[l.jsx("p",{className:"text-slate-400",children:"Raw axes"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.axes.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["A",j,": ",Pn.format(w)]},`axis-${j}`))}),l.jsx("p",{className:"text-slate-400",children:"Raw buttons"}),l.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:h.buttons.map((w,j)=>l.jsxs("span",{className:"font-mono text-slate-300",children:["B",j,": ",Pn.format(w.value)," ",w.pressed?"●":""]},`btn-${j}`))}),N?.outputs&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-slate-400",children:"Mapped outputs"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsxs("span",{className:"font-mono text-slate-300",children:["Drive: ",Pn.format(N.outputs.driveVector.x),","," ",Pn.format(N.outputs.driveVector.y)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Camera: ",Pn.format(N.outputs.cameraAxis)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Main: ",Pn.format(N.outputs.auxAxis.main)]}),l.jsxs("span",{className:"font-mono text-slate-300",children:["Side: ",Pn.format(N.outputs.auxAxis.side)]})]})]})]}):l.jsx("p",{className:"text-[0.7rem] text-slate-400",children:"No controller detected."})]})]})}const uA={drive:"Drive wheels",aux:"Aux motors"};function vx(n){return Number.isFinite(n)?`${Math.round(n*100)}%`:"--"}function dA({value:n,color:a="bg-emerald-500"}){const r=`${Math.round(Math.max(0,Math.min(1,n))*100)}%`;return l.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-slate-800",children:l.jsx("div",{className:`h-full ${a}`,style:{width:r}})})}function fA(){const{state:{roverId:n},overcurrentLimiter:a}=yt(),r=m.useMemo(()=>Ws.map(o=>o.key),[]);return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Overcurrent limiter"}),l.jsx("span",{children:a?.adminImmune?"Admin immune":"Active"})]}),n?l.jsxs("div",{className:"space-y-0.5",children:[r.map(o=>{const u=a?.caps?.[o]?.cap??0,f=a?.overcurrent?.groups?.[o]??!1,p=a?.scales?.perGroup?.[o]??1;return l.jsxs("div",{className:"surface space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-slate-200",children:uA[o]||o}),l.jsx("span",{className:f?"text-red-300":"text-slate-400",children:f?"overcurrent":"ok"})]}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Cap"}),l.jsx("span",{children:vx(u)})]}),l.jsx(dA,{value:u,color:"bg-amber-500"}),l.jsxs("div",{className:"flex items-center justify-between text-[0.7rem] text-slate-400",children:[l.jsx("span",{children:"Scale"}),l.jsx("span",{children:vx(p)})]})]})]},o)}),l.jsxs("div",{className:"surface text-[0.7rem] text-slate-400",children:[l.jsx("div",{children:`Down rate ${a?.config?.downRatePerSec}/s · Up rate ${a?.config?.upRatePerSec}/s`}),l.jsx("div",{children:`Release delay ${a?.config?.releaseDelaySec}s`}),l.jsx("div",{children:`Output rate ${a?.config?.outputRateMs}ms`})]})]}):l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to view limiter status."})]})}const Jg=m.createContext(null);function Pg(){const n=m.useContext(Jg);if(!n)throw new Error("Tabs components must be used within a <Tabs> provider.");return n}const bx={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"}},yx={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"},Wg="primary";function xf(...n){return n.filter(Boolean).join(" ")}function gf({children:n,defaultTab:a,currentTab:r,onTabChange:o,variant:u=Wg}){const[f,p]=m.useState(a??null),[h,g]=m.useState([]),x=m.useCallback(C=>C?(g(E=>E.includes(C)?E:[...E,C]),()=>g(E=>E.includes(C)?E.filter(N=>N!==C):E)):()=>{},[]),v=r??f??h[0]??null;m.useEffect(()=>{a&&r===void 0&&p(a)},[a,r]);const b=m.useCallback(C=>{C&&(r===void 0&&p(C),o&&o(C))},[r,o]),S=m.useMemo(()=>({activeTab:v,setActiveTab:b,registerTab:x,variant:u}),[v,b,x,u]);return l.jsx(Jg.Provider,{value:S,children:n})}function vf({children:n,className:a=""}){return l.jsx("div",{className:xf("flex gap-0.5",a),children:n})}function Zt({id:n,children:a,className:r="",disabled:o=!1,highlight:u="none"}){const{activeTab:f,setActiveTab:p,registerTab:h,variant:g}=Pg();m.useEffect(()=>h(n),[n,h]);const x=bx[g]??bx[Wg],v=f===n,b=yx[u]||yx.none,S=xf(x.base,b||(v?x.active:x.inactive),o?"cursor-not-allowed opacity-50":"",r);return l.jsx("button",{type:"button",className:S,onClick:()=>!o&&p(n),"aria-pressed":v,"aria-disabled":o,children:a})}function bf({children:n,className:a=""}){return l.jsx("div",{className:xf("mt-0 space-y-0.5",a),children:n})}function Jt({id:n,children:a,keepMounted:r=!1}){const{activeTab:o}=Pg(),u=o===n;return!u&&!r?null:!u&&r?l.jsx("div",{hidden:!0,"aria-hidden":"true",children:a}):l.jsx(l.Fragment,{children:a})}function mA(){const{session:n}=br(),a=m.useMemo(()=>JSON.stringify(n??{},null,2),[n]);return l.jsxs("div",{className:"panel-section flex min-h-0 flex-col gap-0.5 text-xs",children:[l.jsx("p",{className:"text-sm text-slate-400",children:"Session snapshot"}),l.jsx("pre",{className:"surface min-h-0 flex-1 overflow-y-auto font-mono text-[0.7rem] text-lime-300",children:a})]})}const Sx=300,jx=240;function hA(n,a){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="function")return"[Function]";if(n instanceof Error)return`${n.name}: ${n.message}`;if(n instanceof Date)return n.toISOString();if(a||(a=new WeakSet),typeof n=="object"){if(a.has(n))return"[Circular]";a.add(n)}try{return JSON.stringify(n,(r,o)=>typeof o=="function"?"[Function]":o instanceof Error?`${o.name}: ${o.message}`:o,0)}catch{return String(n)}}function pA(n){const r=n.map(o=>hA(o)).join(" ");return r.length>jx?`${r.slice(0,jx)}…`:r}function xA(){const n=Pt(),[a,r]=m.useState([]),o=m.useMemo(()=>a.reduce((u,f)=>(f.direction==="in"&&(u.in+=1),f.direction==="out"&&(u.out+=1),u),{in:0,out:0}),[a]);return m.useEffect(()=>{const u=(g,x,v)=>{r(b=>{const S=[...b,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,direction:g,event:x,payload:pA(v),timestamp:new Date().toLocaleTimeString()}];return S.length>Sx?S.slice(-Sx):S})},f=(g,...x)=>u("in",g,x),p=(g,...x)=>u("out",g,x);n.onAny(f);let h=null;if(typeof n.onAnyOutgoing=="function")n.onAnyOutgoing(p),h=()=>n.offAnyOutgoing(p);else{const g=n.emit.bind(n);n.emit=(x,...v)=>(p(x,...v),g(x,...v)),h=()=>{n.emit=g}}return()=>{n.offAny(f),h&&h()}},[n]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-slate-400",children:[l.jsx("span",{children:"Socket activity"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-slate-400",children:[l.jsxs("span",{className:"surface-muted",children:["in ",o.in]}),l.jsxs("span",{className:"surface-muted",children:["out ",o.out]}),l.jsx("button",{type:"button",className:"button-dark text-xs",onClick:()=>r([]),children:"Clear"})]})]}),l.jsx("div",{className:"surface h-64 overflow-y-auto font-mono text-xs",children:a.length===0?l.jsx("p",{children:"No socket activity yet."}):a.slice().reverse().map(u=>l.jsxs("div",{className:"surface",children:[l.jsx("span",{className:"text-slate-400",children:u.timestamp})," ",l.jsxs("span",{className:u.direction==="in"?"text-emerald-400":"text-amber-400",children:["[",u.direction.toUpperCase(),"]"]})," ",l.jsx("span",{className:"text-cyan-300",children:u.event})," ",l.jsx("span",{className:"text-slate-200",children:u.payload})]},u.id))}),l.jsx("p",{className:"text-xs text-slate-500",children:"Logs are collected only while this panel is open."})]})}const gA=[{key:"start",label:"Start OI"},{key:"safe",label:"Safe"},{key:"full",label:"Full"},{key:"passive",label:"Passive"},{key:"dock",label:"Dock"}];function ev(){const{state:{roverId:n},actions:{sendOiCommand:a,setSensorStream:r}}=yt(),o=!!n,[u,f]=$g(),p=Pt(),{value:h,save:g}=Ve("page",{hudMapDesktop:!1,connectionTransport:"websocket",swapMobileControlColumns:!1,driveMacroBackoffEnabled:!0}),{value:x,save:v}=Ve("audio",it),b=h?.connectionTransport||"websocket",S=!!h?.swapMobileControlColumns,C=typeof h?.driveMacroBackoffEnabled=="boolean"?h.driveMacroBackoffEnabled:!0,E=Number.isFinite(x?.masterVolume)?x.masterVolume:it.masterVolume,N=Number.isFinite(x?.alertVolume)?x.alertVolume:it.alertVolume,w=Number.isFinite(x?.roverVolume)?x.roverVolume:it.roverVolume,j=typeof x?.mainBrushDuckEnabled=="boolean"?x.mainBrushDuckEnabled:typeof x?.autoLevelEnabled=="boolean"?x.autoLevelEnabled:it.mainBrushDuckEnabled,T=Number.isFinite(x?.mainBrushDuckAmount)?Math.max(0,Math.min(1,x.mainBrushDuckAmount)):it.mainBrushDuckAmount,k=m.useMemo(()=>[{key:"start",label:"Enable stream",enable:!0},{key:"stop",label:"Disable stream",enable:!1}],[]),R=U=>{n&&r(U)},D=U=>{const X=U.target.value;g(Q=>({...Q??{},connectionTransport:X})),p?.io?.opts&&(p.io.opts.transports=X==="polling"?["polling"]:["websocket","polling"],p.disconnect(),p.connect())},V=U=>X=>{const Q=Number(X.target.value),ce=Number.isFinite(Q)?Math.max(0,Math.min(1,Q)):0;v(ue=>({...ue??{},[U]:ce}))},O=U=>{const X=!!U.target.checked;v(Q=>({...Q??{},mainBrushDuckEnabled:X}))},L=U=>{const X=!!U.target.checked;g(Q=>({...Q??{},swapMobileControlColumns:X}))},Y=U=>{const X=!!U.target.checked;g(Q=>({...Q??{},driveMacroBackoffEnabled:X}))};return l.jsxs(gf,{defaultTab:"keybindings",children:[l.jsxs(vf,{children:[l.jsx(Zt,{id:"keybindings",children:"Keybindings"}),l.jsx(Zt,{id:"controller",children:"Controller"}),l.jsx(Zt,{id:"page",children:"Page settings"}),l.jsx(Zt,{id:"admin",children:"Admin"})]}),l.jsxs(bf,{children:[l.jsx(Jt,{id:"keybindings",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(Ww,{})})}),l.jsx(Jt,{id:"controller",children:l.jsx("div",{className:"space-y-0.5",children:l.jsx(cA,{})})}),l.jsx(Jt,{id:"page",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"HUD"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:u,onChange:U=>f(U.target.checked)}),l.jsx("span",{children:"Show top-down map in HUD (desktop)"})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Mobile HUD keeps the map on by default."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Mobile controls"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:S,onChange:L}),l.jsx("span",{children:"Swap control columns (put joystick on the left)"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Macros"}),l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-200",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:C,onChange:Y}),l.jsx("span",{children:"Enable backward bump in drive macro"})]})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Audio"}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Master volume"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(E*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:E,onChange:V("masterVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Alert/page sounds"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(N*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:N,onChange:V("alertVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Rover audio"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(w*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:w,onChange:V("roverVolume"),className:"w-full accent-emerald-500"})]}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Main brush ducking"}),l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:j,onChange:O})]}),l.jsxs("label",{className:"grid gap-0.5 text-slate-200",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsx("span",{children:"Main brush duck amount"}),l.jsxs("span",{className:"text-xs text-slate-400",children:[Math.round(T*100),"%"]})]}),l.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:T,onChange:V("mainBrushDuckAmount"),className:"w-full accent-emerald-500",disabled:!j})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Lowers rover audio only while the main brush is running."})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Connection"}),l.jsxs("label",{className:"flex items-center justify-between gap-0.5 text-slate-200",children:[l.jsx("span",{children:"Transport"}),l.jsxs("select",{value:b,onChange:D,className:"field-input text-sm",children:[l.jsx("option",{value:"websocket",children:"WebSocket"}),l.jsx("option",{value:"polling",children:"Polling"})]})]}),l.jsx("p",{className:"text-xs text-slate-500",children:"Switching reconnects your session."})]})]})}),l.jsx(Jt,{id:"admin",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Manual OI commands"}),l.jsx("div",{className:"surface flex flex-wrap gap-0.5",children:gA.map(U=>l.jsx("button",{type:"button",onClick:()=>a(U.key),disabled:!o,className:"button-dark text-xs disabled:opacity-30",children:U.label},U.key))})]}),l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsx("p",{className:"text-slate-400",children:"Sensor stream"}),l.jsx("div",{className:"surface flex gap-0.5",children:k.map(U=>l.jsx("button",{type:"button",onClick:()=>R(U.enable),disabled:!o,className:"flex-1 button-dark text-xs disabled:opacity-30",children:U.label},U.key))}),!o&&l.jsx("p",{className:"text-xs text-slate-500",children:"Assign a rover to toggle streams."})]}),l.jsx(Zg,{}),l.jsx(fA,{}),l.jsx(Fw,{}),l.jsx(mA,{}),l.jsx(xA,{})]})})]})]})}const Nx={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:['If the rover shows "Docking in Progress", it is already auto-seeking the dock.',"To dock manually, enter Docking Assist from the drive panel.",{segments:['Press "Enter Docking Assist", or press ',{action:"dockMacro"},"."]},"In assist mode, camera tilts down and driving speed is limited for precise alignment."]}],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:"Docking assist toggle"},{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:['If you see "Docking in Progress", the rover is currently auto-seeking the dock.',{segments:['For manual docking, press "Enter Docking Assist".']},"Assist mode tilts camera down and limits speed for precise alignment."]}]},"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:['If you see "Docking in Progress", the rover is currently auto-seeking the dock.',{segments:['For manual docking, press "Enter Docking Assist" (or "Dock" button).']},"Assist mode tilts camera down and limits speed for precise alignment."]}]}};function vA(n){return Nx[n]||Nx.desktop}function tv({actionId:n,keymap:a}){const r=a?.[n]?.[0]??"";return l.jsx("span",{className:"rounded border border-slate-600 bg-slate-900/40 px-1 text-[0.7rem] text-slate-200",children:Tt(r)})}function wx(n,a){return n.map((r,o)=>typeof r=="string"?l.jsx("span",{children:r},`text-${o}`):r?.action?l.jsx(tv,{actionId:r.action,keymap:a},`pill-${r.action}-${o}`):r?.text?l.jsx("span",{children:r.text},`span-${o}`):null)}function Eo(n,a,r){if(typeof n=="string")return n;if(Array.isArray(n?.segments))return wx(n.segments,a);if(n&&typeof n=="object"){if(typeof n.text=="string")return n.text;if(Array.isArray(n))return wx(n,a)}return String(n??"")}function bA({hero:n,keymap:a}){return n?l.jsxs("div",{className:"surface space-y-0.5 px-0.5 py-0.5",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-white",children:n.title}),n.subtitle&&l.jsx("p",{className:"text-xs text-slate-300",children:n.subtitle})]}),n.chips&&l.jsx("div",{className:"flex flex-wrap gap-0.5 text-[0.7rem] text-slate-200",children:n.chips.map(r=>l.jsx("span",{className:"rounded border border-slate-700 px-1 py-[2px]",children:r},r))})]}),n.bullets&&l.jsx("ul",{className:"space-y-0.5 text-[0.85rem] text-slate-200",children:n.bullets.map((r,o)=>{const u=Array.isArray(r?.segments)?`hero-${o}`:`hero-${o}`;return l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(r,a)},u)})})]}):null}function yA({block:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items.map((r,o)=>{const u=`item-${o}`;return l.jsx("li",{className:"surface-muted flex flex-wrap items-center gap-0.5 px-0.5 py-0.25",children:Eo(r,a)},u)})})]})}function SA({block:n}){const a=n.tone==="info"?"border-cyan-500/40":"border-slate-700";return l.jsxs("div",{className:`surface space-y-0.5 border ${a} px-0.5 py-0.5`,children:[l.jsx("p",{className:"text-xs font-semibold text-slate-100",children:n.title}),n.body&&l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.body.map((r,o)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(r,{})},`callout-${o}`))})]})}function jA({group:n,keymap:a}){return l.jsxs("div",{className:"space-y-0.5 surface",children:[l.jsx("p",{className:"px-0.5 py-0.25 text-[0.75rem] font-semibold text-slate-200",children:n.title}),l.jsx("div",{className:"space-y-0.5 px-0.5 pb-0.25",children:n.items.map(r=>l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.25 text-[0.8rem]",children:[l.jsx("span",{className:"text-slate-200",children:r.label}),l.jsx(tv,{actionId:r.action,keymap:a})]},r.action))})]})}function NA({block:n,keymap:a}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:n.title}),n.footnote&&l.jsx("span",{className:"text-[0.7rem] text-slate-400",children:n.footnote})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-0.5",children:n.groups?.map(r=>l.jsx(jA,{group:r,keymap:a},r.id))})]}):null}function wA({block:n}){return n?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs font-semibold text-slate-200",children:n.title}),l.jsx("ul",{className:"space-y-0.5 text-[0.8rem] text-slate-300",children:n.items?.map((a,r)=>l.jsx("li",{className:"surface-muted px-0.5 py-0.25",children:Eo(a,{})},`gamepad-${r}`))})]}):null}function Ax({block:n,keymap:a}){if(!n)return null;switch(n.type){case"list":return l.jsx(yA,{block:n,keymap:a});case"callout":return l.jsx(SA,{block:n});case"keyboard":return l.jsx(NA,{block:n,keymap:a});case"gamepad":return l.jsx(wA,{block:n});default:return null}}function nv({layout:n,keymap:a}){const r=m.useMemo(()=>vA(n),[n]),o=a||{},u=r.main||[],f=r.aside||[];return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(bA,{hero:r.hero,keymap:o}),l.jsxs("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(auto-fit, minmax(360px, 1fr))"},children:[l.jsx("div",{className:"space-y-0.5",children:u.map((p,h)=>l.jsx(Ax,{block:p,keymap:o},p.title||h))}),l.jsx("div",{className:"space-y-0.5",children:f.map((p,h)=>l.jsx(Ax,{block:p,keymap:o},p.title||h))})]})]})}function sv({layout:n,onOpenOverlay:a}){const{state:r}=yt();return l.jsxs("section",{className:"panel-section space-y-0.5 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[l.jsx("span",{children:"Help"}),l.jsx("button",{type:"button",onClick:a,className:"button-dark px-1 py-0.25 text-[0.75rem]",children:"Open full help"})]}),l.jsx(nv,{layout:n,keymap:r?.keymap||{}})]})}const AA=["kal","rms","slt","ksp","bdl"],CA=Array.from({length:10},(n,a)=>a*10);function Mo({hideInput:n=!1,hideSpectatorNotice:a=!1,fillHeight:r=!1,allowSpectatorInput:o=!1}){const u=oe(q=>q.session?.role||null),f=oe(q=>q.session?.assignment?.roverId||null),p=oe(q=>q.session?.roster??[]),{messages:h,typing:g,sendMessage:x,registerInputRef:v,onInputFocus:b,onInputBlur:S,blurChat:C,setTypingActive:E}=lf(),{value:N,save:w}=Ve("tts",{engine:"flite",voice:"rms",pitch:50}),[j,T]=m.useState(""),[k,R]=m.useState(!1),[D,V]=m.useState(!1),[O,L]=m.useState(()=>N?.engine||"flite"),[Y,U]=m.useState(()=>N?.voice||"rms"),[X,Q]=m.useState(()=>Number.isFinite(N?.pitch)?N.pitch:50),ce=u!=="spectator"||o,ue=m.useRef(null),B=!!m.useMemo(()=>p.find(q=>String(q.id)===String(f))||null,[f,p])?.audio?.ttsEnabled,I=m.useMemo(()=>h.slice(-200),[h]),K=m.useMemo(()=>g||[],[g]);m.useEffect(()=>{ue.current&&(ue.current.scrollTop=ue.current.scrollHeight)},[I,K]),m.useEffect(()=>{const q=N?.engine||"flite",Z=N?.voice||"rms",le=Number.isFinite(N?.pitch)?N.pitch:50;O!==q&&L(q),Y!==Z&&U(Z),X!==le&&Q(le)},[O,X,N?.engine,N?.pitch,N?.voice,Y]),m.useEffect(()=>{V(!!B)},[B]);const P=m.useMemo(()=>!B||!D?null:O==="espeak"?{speak:!0,engine:O,pitch:X}:{speak:!0,engine:O,voice:Y},[O,X,D,B,Y]);async function ie(q){if(q.preventDefault(),!ce||n)return;const le=j.replace(/\\n/g,`
|
||
`).trim();if(le){R(!0);try{await x(le,P),T(""),C(),E(!1)}catch(he){alert(he.message)}finally{R(!1)}}}const M=r?"flex-1 min-h-0 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${r?"flex h-full flex-col overflow-hidden":""}`,children:[l.jsxs("div",{className:`surface overflow-y-auto space-y-0.5 px-0 ${M}`,ref:ue,children:[I.length===0&&K.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No messages yet."}):I.map(q=>l.jsx(nf,{message:q},q.id)),K.map(q=>l.jsx(vg,{message:q},`typing-${q.typingId||q.id}`))]}),!n&&l.jsxs("form",{className:"flex flex-wrap items-stretch gap-0.5",onSubmit:ie,children:[l.jsx("input",{className:"field-input flex-1 min-w-[10rem]",value:j,onChange:q=>{const Z=q.target.value;T(Z),E(!!Z.trim())},onFocus:q=>{b(q),E(!!j.trim())},onBlur:q=>{S(q),E(!1)},onKeyDown:q=>{q.key==="Enter"&&!j.trim()&&(q.preventDefault(),C(),E(!1))},ref:q=>v(q,{target:"panel"}),placeholder:ce?"Type a message…":a?"":"Spectators cannot chat",disabled:!ce}),B&&l.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 basis-full sm:basis-auto",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:D,onChange:q=>V(q.target.checked),className:"accent-cyan-500"}),l.jsx("span",{children:"Speak"})]}),l.jsxs("select",{value:O,onChange:q=>{const Z=q.target.value;L(Z),w(le=>({...le||{},engine:Z}))},className:"field-input text-xs",children:[l.jsx("option",{value:"flite",children:"flite"}),l.jsx("option",{value:"espeak",children:"espeak"})]}),O==="flite"?l.jsx("select",{value:Y,onChange:q=>{const Z=q.target.value;U(Z),w(le=>({...le||{},voice:Z}))},className:"field-input text-xs",children:AA.map(q=>l.jsx("option",{value:q,children:q},q))}):l.jsx("select",{value:X,onChange:q=>{const Z=Number(q.target.value);Q(Z),w(le=>({...le||{},pitch:Z}))},className:"field-input text-xs",children:CA.map(q=>l.jsxs("option",{value:q,children:["pitch ",q]},q))})]}),l.jsx("button",{type:"submit",disabled:!ce||k,className:"button-dark h-full disabled:opacity-50 self-stretch",children:k?"...":"Send"})]})]})}function jr({compact:n=!1}){const a=oe(b=>b.session?.role||null),{setNickname:r}=$t(),{value:o,save:u}=Ve("profile",{nickname:""}),[f,p]=m.useState(o.nickname||""),[h,g]=m.useState(!1),x=a!=="spectator";m.useEffect(()=>{p(o.nickname||"")},[o.nickname]);async function v(b){if(b.preventDefault(),!x)return;const S=(f||"").trim().slice(0,32);if(S){g(!0);try{await r(S),u({nickname:S})}catch(C){alert(C.message)}finally{g(!1)}}}return l.jsxs("form",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-stretch gap-0.5",onSubmit:v,children:[l.jsx("input",{className:"field-input flex-1 min-w-0",value:f,onChange:b=>p(b.target.value),maxLength:32,placeholder:"Enter a nickname",disabled:!x}),l.jsx("button",{type:"submit",disabled:!x||h,className:"button-dark h-full shrink-0 whitespace-nowrap px-0.5 py-0 disabled:opacity-50",children:h?"Saving…":n?"Set":"Save"})]})}function kA({socials:n,discordInvite:a,kofiLink:r}){const o=Array.isArray(n)?n:null;if(o&&o.length)return o;const u=[];return a&&u.push({id:"discord",label:"Discord",url:a}),r&&u.push({id:"kofi",label:"Ko-fi",url:r}),u}function EA(n){if(!n||typeof n!="object")return null;const a=n.id||n.service||n.key||n.name||null,r=n.label||n.title||n.name||a||"Link",o=n.url||n.link||n.href||null;return o?{id:a,label:r,url:o}:null}function av({className:n=""}){const a=oe(o=>({socials:o.session?.socials??[],discordInvite:o.session?.discord?.invite||null,kofiLink:o.session?.kofi?.link||null})),r=kA(a).map(EA).filter(Boolean).slice(0,4);return r.length?l.jsx("div",{className:`grid grid-cols-2 grid-rows-2 gap-0.5 ${n}`,children:r.map(o=>l.jsx(wo,{...o},`${o.id||o.label}-${o.url}`))}):null}function MA({compact:n=!1}){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:n})})})}function RA(){return l.jsx("section",{className:"panel-section flex h-full min-h-0 flex-col gap-0.5 text-base",children:l.jsx(av,{className:"flex-1 min-h-0"})})}function gd(...n){return n.filter(Boolean).join(" ")}function TA(n){const a=n?.batteryState?.percentDisplay;return a==null?"--":`${a}%`}function qA(n){return n?.batteryState?n.batteryState.urgentActive?"text-red-400":n.batteryState.warnActive?"text-amber-300":"text-emerald-300":"text-slate-400"}function DA(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 _A(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function Ro({title:n="Rovers"}){const a=oe(j=>j.session?.role||null),r=oe(j=>j.session?.roster??[]),o=oe(j=>j.session?.turnQueues??{}),u=oe(j=>j.session?.users??[]),f=oe(j=>j.session?.socketId||null),{requestControl:p}=$t(),[h,g]=m.useState({}),[x,v]=m.useState(()=>Date.now()),b=m.useMemo(()=>a&&a!=="spectator",[a]),S=m.useMemo(()=>a==="admin"||a==="lockdown"||a==="lockdown-admin",[a]),C=m.useMemo(()=>Object.values(o||{}).some(j=>j?.deadline||j?.idleDeadline),[o]);m.useEffect(()=>{if(!C)return;const j=setInterval(()=>{v(Date.now())},1e3);return()=>clearInterval(j)},[C]);const E=m.useMemo(()=>{const j=new Set(r.map(k=>String(k.id))),T=Object.keys(o||{}).filter(k=>!j.has(String(k))).map(k=>({id:k,name:k,locked:!1,batteryState:null}));return[...r,...T]},[r,o]);async function N(j){if(j){g(T=>({...T,[j]:!0}));try{await p(j)}catch(T){alert(T.message)}finally{g(T=>({...T,[j]:!1}))}}}const w=j=>u.find(T=>T.socketId===j)||{socketId:j,nickname:null,role:null};return l.jsxs("div",{className:"space-y-0.5 text-sm",children:[n&&l.jsx("p",{className:"text-sm text-slate-400",children:n}),E.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"No rovers registered."}):l.jsx("ul",{className:"space-y-0.5 text-sm",children:E.map(j=>{const T=String(j.id),k=o?.[T]||null,R=k?.queue||[],D=k?.idleDeadline||k?.deadline||null,V=D&&D>x?Math.ceil((D-x)/1e3):D?0:null,O=k?.current||null,L=O?R.findIndex(P=>P===O):-1,Y=R.length>1?L>=0?R[(L+1)%R.length]:R[0]:null,U=!!(f&&O&&O===f),X=!!(f&&Y&&Y===f),Q=V!=null&&(U||X),ce=!!j.locked,ue=ce&&!S,W=!!(j?.private?.enabled&&j?.private?.open),B=j.lockReason?`locked: ${j.lockReason}`:"locked",I=ce?B:h[T]?"...":"request",K=b&&!ue&&!h[T];return l.jsxs("li",{className:gd("surface flex flex-wrap items-start justify-between gap-0.5",K&&"cursor-pointer",ce?"bg-red-900/40":W?"bg-amber-700/35 border border-amber-200/30":null),onClick:()=>{K&&N(j.id)},children:[l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[l.jsxs("p",{className:"min-w-0 flex items-center gap-0.5 whitespace-nowrap text-slate-200",children:[l.jsx("span",{className:"rounded px-1 py-[1px] border border-transparent",style:ns(j.color,.16),children:j.name}),j.description?l.jsx("span",{className:"min-w-0 flex-1 truncate text-[0.7rem] text-slate-400",children:j.description}):null]}),Q?l.jsx("span",{className:"rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200",children:U?`${V}s left`:`Your turn in ${V}s`}):null]}),l.jsx("span",{className:gd("text-[0.75rem] font-semibold",qA(j)),children:TA(j)})]}),R.length===0?l.jsx("p",{className:"text-[0.7rem] text-slate-500",children:"No queue."}):l.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:R.map((P,ie)=>{const M=w(P),q=P===O,Z=!!(Y&&P===Y&&!q),le=q?"bg-sky-600 text-white ring-2 ring-amber-300":Z?"bg-emerald-700/60 text-emerald-100 ring-1 ring-emerald-300/70":"bg-slate-800 text-slate-200";return l.jsxs("span",{className:`flex items-center gap-0.5 rounded px-1 text-[0.7rem] ${le}`,children:[l.jsx("span",{className:`${DA(M.role)} font-semibold`,children:_A(M,f)}),q&&l.jsx("span",{className:"text-[0.65rem] text-slate-200",children:"now"}),Z&&l.jsx("span",{className:"text-[0.65rem] text-emerald-100",children:"next"})]},`${T}-${P}-${ie}`)})})]}),b?l.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),N(j.id)},disabled:h[T]||ue,className:gd("button-dark disabled:opacity-40",ce&&"bg-red-600/70 text-white hover:bg-red-600"),children:I}):null]},j.id)})})]})}function BA(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 OA(n,a){if(!n)return"";const r=n.nickname||n.socketId?.slice(0,6)||"unknown";return n.socketId&&n.socketId===a?`${r} (you)`:r}function go({hideNicknameForm:n=!1,hideHeader:a=!1,className:r="",fillHeight:o=!1,compact:u=!1}){const f=oe(b=>b.session?.role||null),p=oe(b=>b.session?.users??[]),h=oe(b=>b.session?.socketId||null),g=f!=="spectator",x=m.useMemo(()=>[...p].sort((b,S)=>b.socketId===h?-1:S.socketId===h?1:(b.nickname||"").localeCompare(S.nickname||"")),[h,p]),v=o?"flex-1 min-h-0 overflow-y-auto":u?"h-28 overflow-y-auto":"h-48 overflow-y-auto";return l.jsxs("section",{className:`panel-section space-y-0.5 text-base ${o?"flex h-full min-h-0 flex-col overflow-hidden":""} ${r}`,children:[!n&&l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid gap-0.5 md:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"surface flex w-full items-center px-0 py-0",children:l.jsx(jr,{compact:u})})}),l.jsx(av,{})]}),!g&&l.jsx("p",{className:"text-xs text-slate-500",children:"Spectators cannot set nicknames."})]}),l.jsxs("div",{className:`space-y-0.5 ${o?"flex flex-1 min-h-0 flex-col":""}`,children:[!a&&l.jsxs("div",{className:`flex items-center justify-between text-sm text-slate-400 ${u?"text-xs":""}`,children:[l.jsx("span",{children:"Users"}),l.jsx("span",{className:"text-xs text-slate-500",children:x.length})]}),l.jsx("div",{className:`surface flex flex-wrap content-start items-start gap-0.5 px-0 pb-0 ${v} ${u?"text-[0.8rem]":""}`,children:x.length===0?l.jsx("p",{className:"text-sm text-slate-500",children:"Waiting for users…"}):x.map(b=>l.jsx("span",{className:`rounded bg-slate-800/80 px-1 py-0.25 text-[0.7rem] ${BA(b.role)}`,children:OA(b,h)},b.socketId))})]})]})}const LA=/^cu_[a-f0-9]{32}$/,el="field-input w-full max-w-sm text-left focus:ring-emerald-500",Nr="mx-auto w-full max-w-xl flex justify-center",Ka="mx-auto flex w-full max-w-md flex-col items-center space-y-0.5 text-center";function zA(n){const a=String(n||"").trim();return a?a.length<=10?`${a.slice(0,2)}***${a.slice(-2)}`:`${a.slice(0,6)}...${a.slice(-6)}`:""}const Cx=8*1024*1024,Ps=16e3,UA={iceServers:[{urls:"stun:stun.l.google.com:19302"}],bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"};function kx(n){let a="";for(let o=0;o<n.length;o+=32768){const u=n.subarray(o,o+32768);a+=String.fromCharCode(...u)}return btoa(a)}function HA(n){return typeof btoa=="function"?btoa(n):""}function VA(n){if(!n)return{};const a=HA(`${n}:${n}`);return a?{Authorization:`Basic ${a}`}:{}}function $A(n,a=1500){return new Promise(r=>{if(!n||n.iceGatheringState==="complete"){r();return}const o=setTimeout(()=>{n.removeEventListener("icegatheringstatechange",u),r()},a);function u(){n.iceGatheringState==="complete"&&(clearTimeout(o),n.removeEventListener("icegatheringstatechange",u),r())}n.addEventListener("icegatheringstatechange",u)})}function Ex(n){if(!n)return!1;const a=n.connectionState,r=n.iceConnectionState;return a==="connected"||r==="connected"||r==="completed"}function GA(n,a=1e4){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}if(Ex(n)){r();return}const u=setTimeout(()=>{p(),o(new Error("Peer connection timeout"))},a),f=()=>{Ex(n)?(p(),r()):(n.connectionState==="failed"||n.connectionState==="closed"||n.iceConnectionState==="failed")&&(p(),o(new Error(`Peer connection ${n.connectionState||n.iceConnectionState}`)))};function p(){clearTimeout(u),n.removeEventListener("connectionstatechange",f),n.removeEventListener("iceconnectionstatechange",f)}n.addEventListener("connectionstatechange",f),n.addEventListener("iceconnectionstatechange",f)})}async function YA(n){if(!n?.getParameters||!n?.setParameters)return;const a=n.getParameters()||{},r=a.encodings&&a.encodings[0]||{};a.encodings=[{...r,maxBitrate:64e3,dtx:"disabled"}];try{await n.setParameters(a)}catch{}}function FA(n,a=6e3){return new Promise((r,o)=>{if(!n){o(new Error("Peer connection missing"));return}const u=Date.now();let f=-1;const p=setInterval(async()=>{if(Date.now()-u>a){clearInterval(p),o(new Error("WHIP connected but no outbound audio flow"));return}try{const h=n.getSenders().filter(g=>g.track?.kind==="audio");for(const g of h){const x=await g.getStats();for(const v of x.values()){if(v.type!=="outbound-rtp"||v.kind!=="audio")continue;const b=Number(v.bytesSent||0),S=Number(v.packetsSent||0);if(f<0)f=b;else if(b>f+200||S>5){clearInterval(p),r();return}}}}catch{}},250)})}function IA(n){const a=n.reduce((u,f)=>u+f.length,0),r=new Float32Array(a);let o=0;for(const u of n)r.set(u,o),o+=u.length;return r}function XA(n){const a=new Int16Array(n.length);for(let r=0;r<n.length;r+=1){const o=Math.max(-1,Math.min(1,n[r]));a[r]=o<0?o*32768:o*32767}return a}function QA(n,a){const r=XA(n),o=r.length*2,u=new ArrayBuffer(44+o),f=new DataView(u),p=(g,x)=>{for(let v=0;v<x.length;v+=1)f.setUint8(g+v,x.charCodeAt(v))};p(0,"RIFF"),f.setUint32(4,36+o,!0),p(8,"WAVE"),p(12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,1,!0),f.setUint32(24,a,!0),f.setUint32(28,a*2,!0),f.setUint16(32,2,!0),f.setUint16(34,16,!0),p(36,"data"),f.setUint32(40,o,!0);let h=44;for(let g=0;g<r.length;g+=1,h+=2)f.setInt16(h,r[g],!0);return new Uint8Array(u)}function pn({label:n,active:a,detail:r=""}){return l.jsxs("div",{className:`rounded-md px-0.5 py-0.5 text-xs text-slate-100 ${a?"bg-emerald-500":"bg-slate-700"}`,children:[l.jsx("div",{className:"text-center font-medium",children:n}),l.jsx("div",{className:"text-center text-[0.72rem] opacity-90",children:r||(a?"active":"idle")})]})}function zd({label:n}){return n?l.jsx("span",{className:"rounded border border-white/40 px-1 text-[0.7rem] text-white",children:n}):null}function KA({ownRoverId:n="",audioForwardByRover:a={},playUploadedAudio:r,stopUploadedAudio:o,startMicWhip:u,readyMicWhip:f,stopMicWhip:p}){const{state:h}=yt(),{value:g,save:x}=Ve("vipAudio",{openMicEnabled:!1,pttMode:"live"}),v=String(n||"").trim(),[b,S]=m.useState(null),[C,E]=m.useState(!1),N=!!g?.openMicEnabled,j=(g?.pttMode==="clip"?"clip":"live")==="clip",[T,k]=m.useState("idle"),[R,D]=m.useState("idle"),[V,O]=m.useState(""),L=m.useRef(null),Y=m.useRef(null),U=m.useRef(null),X=m.useRef(!1),Q=m.useRef(""),ce=m.useRef(null),ue=m.useRef(null),W=m.useRef(null),B=m.useRef(null),I=m.useRef(null),K=m.useRef([]),P=m.useRef(!1),ie=m.useRef(Ps),M=!!h?.mic?.pttActive,q=m.useMemo(()=>v&&a?.[v]||null,[a,v]),Z=!!(q&&q.state!=="offline"&&!q.error),le=q?.source==="upload"&&q?.state==="playing",he=q?.source==="mic-whip"&&(q?.state==="starting"||q?.state==="playing"),we=!!(!j&&Y.current&&(N||M)),pe=!j&&(T==="live"||T==="starting"),xe=j&&R==="recording",ge=j&&R==="sending",Se=Tt(h?.keymap?.micPtt?.[0])||"M",be=m.useCallback(re=>{const de=re==="clip"?"clip":"live";x(fe=>({...fe||{},pttMode:de}))},[x]),$e=async()=>{if(!v){O("Take control of your rover first.");return}if(!b){O("Select an audio file first.");return}if(b.size>Cx){O(`File too large (max ${Cx} bytes).`);return}E(!0),O("");try{const re=await b.arrayBuffer(),de=kx(new Uint8Array(re));await r?.({roverId:v,name:b.name,mime:b.type||"",dataBase64:de}),O("Upload playback started.")}catch(re){O(re?.message||"Failed to play upload.")}finally{E(!1)}},Ze=async()=>{if(!v){O("Take control of your rover first.");return}E(!0),O("");try{await o?.(v),O("Upload playback stopped.")}catch(re){O(re?.message||"Failed to stop upload.")}finally{E(!1)}},je=m.useCallback(async re=>{const de=String(re||Q.current||"").trim();if(X.current=!1,k("idle"),U.current){try{U.current.getSenders().forEach(fe=>fe.track?.stop())}catch{}try{U.current.close()}catch{}}if(U.current=null,L.current)try{L.current.getTracks().forEach(fe=>fe.stop())}catch{}if(L.current=null,Y.current=null,de)try{await p?.(de)}catch{}Q.current=""},[p]),lt=m.useCallback(async re=>{const de=await u?.(re),fe=String(de?.whipUrl||"").trim(),Re=String(de?.token||"").trim();if(!fe||!Re)throw new Error("WHIP endpoint unavailable");const ne=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});L.current=ne;const me=ne.getAudioTracks()?.[0];if(Y.current=me||null,me&&(me.enabled=!!(N||M)),me?.applyConstraints)try{await me.applyConstraints({channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1})}catch{}const De=new RTCPeerConnection(UA);U.current=De,De.onconnectionstatechange=()=>{if(!X.current)return;const Nt=De.connectionState;if(Nt==="connected"){k("live");return}(Nt==="failed"||Nt==="disconnected"||Nt==="closed")&&(k("error"),O(`WHIP transport ${Nt}.`))},ne.getAudioTracks().forEach(Nt=>{const Ce=De.addTrack(Nt,ne);YA(Ce)});const en=await De.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});await De.setLocalDescription(en),await $A(De,1800);const tn=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp",...VA(Re)},body:De.localDescription?.sdp||en.sdp});if(!tn.ok)throw new Error(`WHIP request failed: ${tn.status}`);const nn=await tn.text();await De.setRemoteDescription({type:"answer",sdp:nn}),await GA(De,1e4),await FA(De,6e3),await f?.(re)},[N,M,f,u]),Ie=m.useCallback(async()=>{if(P.current=!1,B.current){try{B.current.disconnect()}catch{}B.current.onaudioprocess=null}if(W.current)try{W.current.disconnect()}catch{}if(I.current)try{I.current.disconnect()}catch{}if(ce.current)try{ce.current.getTracks().forEach(re=>re.stop())}catch{}if(ue.current)try{await ue.current.close()}catch{}K.current=[],B.current=null,W.current=null,I.current=null,ce.current=null,ue.current=null,ie.current=Ps},[]),ft=m.useCallback(async()=>{if(ce.current&&ue.current&&B.current)return;D(me=>me==="recording"?me:"arming");const re=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:Ps,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),de=new AudioContext({latencyHint:"interactive"}),fe=de.createMediaStreamSource(re),Re=de.createScriptProcessor(1024,1,1),ne=de.createGain();ne.gain.value=0,Re.onaudioprocess=me=>{if(!P.current)return;const De=me.inputBuffer.getChannelData(0);K.current.push(new Float32Array(De))},fe.connect(Re),Re.connect(ne),ne.connect(de.destination),ce.current=re,ue.current=de,W.current=fe,B.current=Re,I.current=ne,ie.current=de.sampleRate||Ps},[]),Ae=m.useCallback(async({send:re})=>{const de=P.current;if(P.current=!1,!de){re||D("idle");return}const fe=K.current;if(K.current=[],!re){D("idle");return}if(!v){D("idle");return}if(!fe.length){D("idle");return}D("sending");try{const Re=IA(fe),ne=QA(Re,ie.current||Ps),me=kx(ne);await r?.({roverId:v,name:`ptt-${Date.now()}.wav`,mime:"audio/wav",dataBase64:me}),D("idle")}catch(Re){D("error"),O(Re?.message||"Failed to send PTT clip.")}},[r,v]),ae=m.useCallback(async()=>{if(!v){O("Take control of your rover first.");return}await ft(),K.current=[],P.current=!0,D("recording")},[ft,v]);return m.useEffect(()=>{let re=!1;async function de(){if(j){await je(Q.current||v);return}if(!v){await je(Q.current);return}if(!(X.current&&Q.current===v)&&!(!N&&!M))try{k("starting"),O(""),X.current=!0,Q.current=v,await lt(v),re||k("live")}catch(fe){re||(k("error"),O(fe?.message||"Failed to start mic forwarding.")),await je(v)}}return de(),()=>{re=!0}},[j,N,M,v,lt,je]),m.useEffect(()=>{const re=Y.current;re&&(re.enabled=!!(!j&&(N||M)))},[j,N,M]),m.useEffect(()=>{let re=!1;async function de(){if(!j||!v){P.current&&await Ae({send:!1}),D("idle");return}try{await ft(),!re&&!P.current&&D("idle")}catch(fe){re||(D("error"),O(fe?.message||"Microphone access failed for clip mode."))}}return de(),()=>{re=!0}},[j,ft,Ae,v]),m.useEffect(()=>{let re=!1;async function de(){if(j){if(!v){P.current&&await Ae({send:!1});return}if(M){if(!P.current)try{O(""),await ae()}catch(fe){re||(D("error"),O(fe?.message||"Failed to start clip recording."))}}else P.current&&await Ae({send:!0})}}return de(),()=>{re=!0}},[j,Ae,M,v,ae]),m.useEffect(()=>()=>{je(Q.current||v),Ie()},[v,je,Ie]),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"grid gap-1",children:[l.jsx("p",{className:"text-sm text-slate-100 text-center",children:"Audio Controls"}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"flex items-center justify-center gap-0.5 py-0.25 text-xs text-slate-300",children:[l.jsx("span",{children:"Push-to-Talk Key"}),l.jsx(zd,{label:Se})]})}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Mode"}),l.jsx("p",{className:"text-xs text-slate-400 text-center",children:"Choose how holding your PTT key behaves: live mic stream, or record-and-send clip. If the live stream doesn't work, switch to clip mode."}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"":"bg-emerald-500 text-white hover:bg-emerald-500"}`,onClick:()=>be("live"),children:"Live Mic (WHIP)"}),l.jsx("button",{type:"button",className:`button-dark w-full text-sm ${j?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,onClick:()=>be("clip"),children:"Record Clip"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"PTT Clip Status"}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(pn,{label:"Mode",active:j,detail:j?"record clip":"live mic"}),l.jsx(pn,{label:"PTT hold",active:M,detail:M?"held":"released"}),l.jsx(pn,{label:"Recording",active:xe,detail:xe?"capturing":"idle"}),l.jsx(pn,{label:"Playback",active:j&&le,detail:j&&le?"playing":"idle"})]})]})})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 lg:grid-cols-2",children:[l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr_auto]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Upload"}),l.jsxs("label",{className:"mx-auto grid w-full max-w-sm gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("span",{children:"Audio file (mp3 / wav / ogg)"}),l.jsx("input",{className:`${el} text-center`,type:"file",accept:".mp3,.wav,.ogg,audio/mpeg,audio/wav,audio/ogg",disabled:C||!v,onChange:re=>S(re.target.files?.[0]||null)})]}),l.jsx("div",{className:"mx-auto w-full max-w-sm text-center",children:b?l.jsxs("div",{className:"surface-muted text-xs text-slate-300",children:[b.name," (",b.size," bytes)"]}):l.jsx("div",{className:"surface-muted text-xs text-slate-500",children:"No file selected"})}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:C||!v,onClick:$e,children:C?"Working...":"Play Upload"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:C||!v,onClick:Ze,children:"Stop"})]})]})}),l.jsx("section",{className:"surface h-full",children:l.jsxs("div",{className:"grid h-full gap-0.5 grid-rows-[auto_auto_1fr]",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Live Microphone"}),l.jsxs("label",{className:"surface-muted mx-auto flex w-full max-w-sm items-center justify-center gap-0.5 px-0.5 py-0.5 text-xs text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:N,disabled:!v||j,onChange:re=>x(de=>({...de||{},openMicEnabled:!!re.target.checked}))}),l.jsx("span",{children:j?"Open mic (live mode only)":"Open mic"})]}),l.jsxs("div",{className:"grid gap-0.5 content-start",children:[l.jsx(pn,{label:"WHIP link",active:pe,detail:T}),l.jsx(pn,{label:"Mic hot",active:we,detail:we?"transmitting":"muted"}),l.jsxs("div",{className:"surface-muted text-center text-xs text-slate-400",children:["Hold ",l.jsx(zd,{label:Se})," to talk"]})]})]})})]}),l.jsx("section",{className:"surface",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200 text-center",children:"Audio Status"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-6",children:[l.jsx(pn,{label:"Forward pipe",active:Z,detail:Z?"connected":"offline"}),l.jsx(pn,{label:"Upload playback",active:le,detail:le?"playing":"idle"}),l.jsx(pn,{label:"Mic relay",active:he,detail:he?"active":"idle"}),l.jsx(pn,{label:"WHIP transport",active:pe,detail:T}),l.jsx(pn,{label:"Clip recording",active:xe,detail:xe?"recording":"idle"}),l.jsx(pn,{label:"Clip sending",active:ge,detail:ge?"sending":"idle"})]}),V?l.jsx("div",{className:"text-xs text-slate-400 text-center",children:V}):null]})})]})})}function ZA({pendingRequestId:n,currentStoredKey:a,nickname:r,requestVerification:o,applyIdentityKey:u,onMessage:f,fullWidth:p=!1}){const[h,g]=m.useState(0),[x,v]=m.useState(""),[b,S]=m.useState(!1),[C,E]=m.useState(!1),N=()=>{g(1),v(a),S(!1),f?.("")},w=()=>{g(0),S(!1)},j=async k=>{if(k.preventDefault(),!b){f?.("Please confirm your nickname agreement before sending.");return}if(h<3){f?.("Complete all request steps before sending.");return}E(!0),f?.("");try{const R=await u(x);await o?.(),v(R),g(0),S(!1),f?.("Verification request sent to lockdown admins.")}catch(R){f?.(R.message||"Failed to submit request.")}finally{E(!1)}},T=p?"w-full":Nr;return n?l.jsx("section",{className:`surface text-sm text-slate-300 ${T}`,children:l.jsxs("div",{className:Ka,children:["Verification request pending: ",n]})}):h===0?l.jsx("section",{className:`surface ${T}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Verification"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:N,disabled:C,children:"Request Verification"})]})}):l.jsx("form",{className:`surface ${T}`,onSubmit:j,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Request verification"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Step ",h," of 3"]}),h===1?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Confirm your nickname, which is used as part of the verification process. You can edit it here before requesting."}),l.jsx("div",{className:"mx-auto w-full max-w-sm",children:l.jsx(jr,{compact:!0})}),l.jsxs("div",{className:"surface-muted mx-auto w-full max-w-sm text-xs text-slate-300 text-center",children:["Current nickname: ",l.jsx("span",{className:"font-semibold",children:r||"(not set)"})]}),l.jsxs("label",{className:"flex items-center justify-center gap-0.5 text-xs text-slate-300 text-center",children:[l.jsx("input",{type:"checkbox",className:"accent-emerald-500",checked:b,onChange:k=>S(k.target.checked)}),l.jsx("span",{children:"I understand this nickname is tied to my verification."})]}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!r||!b,onClick:()=>g(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:w,children:"Cancel"})]})]}):null,h===2?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Save your identity key in a safe place. You can use it to restore your identity in another browser."}),l.jsx("input",{className:el,type:"password",name:"identity_key_request",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>navigator.clipboard?.writeText(x),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!x,onClick:()=>g(3),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(1),children:"Back"})]})]}):null,h===3?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Final step: confirm and send your verification request."}),l.jsx("input",{className:el,type:"password",name:"identity_key_request_final",autoComplete:"current-password",maxLength:35,value:x,onChange:k=>v(k.target.value.toLowerCase()),placeholder:"Identity key for this request"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:C||!x,children:"Confirm Request"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>g(2),children:"Back"})]})]}):null]})})}function JA({currentStoredKey:n,applyIdentityKey:a,onMessage:r,fullWidth:o=!1}){const[u,f]=m.useState(0),[p,h]=m.useState(""),[g,x]=m.useState(!1),v=()=>{f(1),h(""),r?.("")},b=()=>{f(0),h("")},S=async E=>{if(E.preventDefault(),!(u<2)){x(!0),r?.("");try{await a(p),f(0),h(""),r?.("Identity key restored.")}catch(N){r?.(N.message||"Failed to restore key.")}finally{x(!1)}}},C=o?"w-full":Nr;return l.jsx("section",{className:`surface ${C}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Identity key"}),l.jsxs("p",{className:"text-xs text-slate-500",children:["Current: ",zA(n)||"not set yet"]}),l.jsx("input",{className:el,type:"password",name:"identity_key_current",autoComplete:"current-password",maxLength:35,value:n,readOnly:!0,placeholder:"Identity key"}),u===0?l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",disabled:!n,onClick:()=>navigator.clipboard?.writeText(n),children:"Copy Key"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:v,disabled:g,children:"Restore Key"})]}):null,u===1?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-xs text-slate-400",children:"Restoring your key should only be done when needed. Use this to move your identity to another browser."}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(2),children:"Continue"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:b,children:"Cancel"})]})]}):null,u===2?l.jsxs("form",{className:"space-y-0.5",onSubmit:S,children:[l.jsx("input",{className:el,type:"password",name:"identity_key_restore",autoComplete:"current-password",maxLength:35,value:p,onChange:E=>h(E.target.value.toLowerCase()),placeholder:"Paste key to restore"}),l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm",disabled:g||!p,children:"Confirm Restore"}),l.jsx("button",{type:"button",className:"button-dark text-sm",onClick:()=>f(1),children:"Back"})]})]}):null]})})}function PA({requestableRovers:n=[],pendingRequests:a=[],requestPrivateRoverAccess:r,onMessage:o,fullWidth:u=!1}){const[f,p]=m.useState({}),h=m.useMemo(()=>{const v=new Map;return(a||[]).forEach(b=>{b?.roverId&&v.set(String(b.roverId),b)}),v},[a]),g=u?"w-full":Nr,x=async v=>{if(v){p(b=>({...b,[v]:!0})),o?.("");try{(await r?.(v))?.existing?o?.("You already have a pending request for that rover."):o?.("Private rover access request sent to lockdown admins.")}catch(b){o?.(b.message||"Failed to send request.")}finally{p(b=>({...b,[v]:!1}))}}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${g}`,children:l.jsxs("div",{className:Ka,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Private rover access requests"}),n.length===0?l.jsx("p",{className:"text-xs text-slate-500",children:"No closed private rovers are available to request right now."}):l.jsx("div",{className:"w-full space-y-0.5",children:n.map(v=>{const b=String(v.id),S=!!f[b],C=h.get(b);return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-1 py-0.5",children:[l.jsxs("div",{className:"min-w-0 text-left",children:[l.jsx("p",{className:"truncate text-xs font-semibold text-slate-100",children:v.name||b}),l.jsx("p",{className:"truncate text-[0.7rem] text-slate-500",children:b})]}),C?l.jsx("span",{className:"rounded bg-amber-700/30 px-1 py-0.5 text-[0.7rem] text-amber-200",children:"Pending"}):l.jsx("button",{type:"button",onClick:()=>x(b),disabled:S,className:"button-dark text-xs disabled:opacity-50",children:S?"Sending...":"Request"})]},b)})})]})})}function io(n){return String(n||"").trim()}function WA(n){const a=io(n);return a?a.includes("DOCKINGRUNNING")?"Returning":a.includes("PAUSED")?"Paused":a.includes("HOUSECLEANINGRUNNING")?"Cleaning":a.includes("SPOTCLEANINGRUNNING")?"Spot cleaning":a.includes("STATE_START")?"Starting":a.includes("STATE_IDLE")||a.includes("STATE_STANDBY")?"Idle":a:"--"}function lv(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function Qi({label:n,value:a,tone:r="muted",valueClass:o="",hideLabel:u=!1}){return l.jsxs("div",{className:`rounded-md px-1 py-0.75 text-center ${lv(r)}`,children:[u?null:l.jsx("div",{className:"text-[0.72rem] opacity-90",children:n}),l.jsx("div",{className:`text-sm font-semibold ${o}`,title:String(a||""),children:a})]})}function e2({neato:n,onStart:a,onSendHome:r,onLocate:o,onClearErrors:u,onPowerCycle:f,fullWidth:p=!1}){const[h,g]=m.useState(""),x=p?"w-full":"w-full max-w-xl",v=!!n?.configured,b=!!(n?.enabled&&n?.connected),S=!!n?.telemetry?.extPowerPresent,C=!!n?.telemetry?.chargingActive,E=WA(n?.telemetry?.uiState),N=io(n?.telemetry?.robotState)||"--",w=n?.telemetry?.batteryPercent,j=Number.isFinite(w)?`${w}%`:"--",T=n?.telemetry?.batteryVoltage,k=Number.isFinite(T)?`${T.toFixed(2)} V`:"--",R=io(n?.telemetry?.robotError)||"--",D=io(n?.telemetry?.robotAlert)||"--",V=n?.controls||{},O=!!V?.start?.available,L=!!V?.sendHome?.available,Y=!!V?.locate?.available,U=!!V?.clearErrors?.available,X=!!V?.powerCycle?.available,Q=v&&b&&O,ce=v&&b&&L,ue=v&&b&&Y,W=v&&b&&U,B=v&&b&&X,I=async(q,Z)=>{if(Z){g(q);try{await Z()}catch{}finally{g("")}}},K=v?b?"Online":"Offline":"Not configured",P=v?b?"good":"danger":"warn",ie=w==null?"muted":w>=60?"good":w>=25?"warn":"danger",M=S?"Docked":E!=="--"?E:"Away from dock";return l.jsx("section",{className:`surface text-sm text-slate-200 ${x}`,children:l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Neato Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Control the autonomous Neato robovac. Be nice to him."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${lv(P)}`,children:K})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-0.5",children:[l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Controls"}),l.jsx("button",{type:"button",disabled:!Q||!!h,onClick:()=>I("start",a),className:"rounded-md border border-sky-300 bg-emerald-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-emerald-500 disabled:opacity-50",children:h==="start"?"Starting...":"Start cleaning"}),l.jsx("button",{type:"button",disabled:!ce||!!h,onClick:()=>I("sendHome",r),className:"rounded-md border border-sky-300 bg-sky-600 px-1 py-1 text-base font-semibold text-white transition hover:border-sky-500 hover:bg-sky-500 disabled:opacity-50",children:h==="sendHome"?"Sending...":"Send to dock"}),l.jsxs("div",{className:"grid grid-cols-3 gap-0.5",children:[l.jsx("button",{type:"button",disabled:!ue||!!h,onClick:()=>I("locate",o),className:"w-full rounded-md border border-sky-300 bg-fuchsia-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-sky-500 hover:bg-fuchsia-500 disabled:opacity-50",children:h==="locate"?"Playing...":"Play sound"}),l.jsx("button",{type:"button",disabled:!W||!!h,onClick:()=>I("clearErrors",u),className:"w-full rounded-md border border-sky-300 bg-amber-500 px-1 py-0.5 text-xs font-semibold text-slate-900 transition hover:border-sky-500 hover:bg-amber-400 disabled:opacity-50",children:h==="clearErrors"?"Clearing...":"Clear errors"}),l.jsx("button",{type:"button",disabled:!B||!!h,onClick:()=>I("powerCycle",f),className:"w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50",children:h==="powerCycle"?"Cycling...":"Power cycle"})]}),l.jsxs("div",{className:"surface-muted grid gap-0.5 pt-0.25",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Power status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-0.5",children:[l.jsx(Qi,{label:"Battery",value:j,tone:ie}),l.jsx(Qi,{label:"Voltage",value:k,tone:"muted"}),l.jsx(Qi,{label:"Docked",value:S?"Docked":"Not docked",tone:S?"good":"muted",hideLabel:!0}),l.jsx(Qi,{label:"Charging",value:C?"charging":"not charging",tone:C?"good":"muted",hideLabel:!0})]})]})]}),l.jsx("div",{className:"grid gap-0.5",children:l.jsxs("div",{className:"surface-muted grid gap-0.5",children:[l.jsx("p",{className:"text-xs text-slate-300 text-center",children:"Robot Status"}),l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot state (raw)"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:N})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Basic state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:M})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"UI state"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:E})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot error"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:R})]}),l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.5",children:[l.jsx("div",{className:"text-[0.72rem] text-slate-300",children:"Robot alert"}),l.jsx("div",{className:"font-mono text-sm text-slate-100 break-all",children:D})]})]})]})})]}),!v||!b||!O||!L||!Y||!U||!X?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:v?b?"Waiting for required Neato entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.neato.device in server config to enable Neato controls."}):null]})})}function t2(n){return n==="good"?"bg-emerald-600 text-white":n==="warn"?"bg-amber-500 text-slate-900":n==="danger"?"bg-rose-600 text-white":"bg-slate-700 text-slate-100"}function n2(n){return n==="up"?"Up":n==="down"?"Down":n==="stopped"?"Transitioning...":n==="conflict"?"Conflict":"--"}function s2({lift:n,onUp:a,onDown:r,fullWidth:o=!1}){const[u,f]=m.useState(""),[p,h]=m.useState(()=>Date.now()),g=o?"w-full":"w-full max-w-xl",x=!!n?.configured,v=!!(n?.enabled&&n?.connected),b=!!n?.busy,S=String(n?.target||"").toLowerCase(),C=String(n?.position||"").toLowerCase(),E=!!n?.availability?.upSwitch,N=!!n?.availability?.downSwitch,w=Number(n?.lastActionAt||0),j=Math.max(0,Number(n?.commandCooldownMs||0)),T=Math.max(0,w+j-p),k=!b&&T>0,R=b||k;m.useEffect(()=>{if(!R)return;const U=setInterval(()=>{h(Date.now())},100);return()=>clearInterval(U)},[R]),m.useEffect(()=>{h(Date.now())},[w,j,b]);const D=x?v?R?"Busy":"Ready":"Offline":"Not configured",V=x?v?R?"warn":"good":"danger":"warn",O=x&&v&&!R&&!u&&E&&N,L=m.useMemo(()=>Math.ceil(T/1e3),[T]),Y=async(U,X)=>{if(X){f(U);try{await X()}catch{}finally{f("")}}};return l.jsxs("section",{className:`surface relative text-sm text-slate-200 ${g}`,children:[R?l.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center rounded-md bg-slate-950/80 px-1.5 text-center",children:l.jsxs("div",{className:"space-y-0.25",children:[l.jsx("p",{className:"text-sm font-semibold text-slate-100",children:b?"Preparing to move":"Moving!"}),l.jsx("p",{className:"text-xs text-slate-300",children:"Controls are disabled while the lift is moving, otherwise its tiny brain would get confused."}),!b&&k?l.jsxs("p",{className:"text-xs text-slate-400",children:["About ",L,"s remaining."]}):null]})}):null,l.jsxs("div",{className:"grid gap-0.5",children:[l.jsxs("div",{className:"relative flex items-center justify-center min-h-[1.5rem]",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm text-slate-100",children:"Lift Controls"}),l.jsx("p",{className:"text-xs text-slate-400",children:"Move the lift up and down. Please don't break anything..."})]}),l.jsx("span",{className:`absolute right-0 inline-flex w-auto rounded px-1 py-0.25 text-xs font-semibold ${t2(V)}`,children:D})]}),l.jsx("section",{className:"surface-muted px-0.5 py-0.5",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-0.5",children:[l.jsxs("div",{className:"rounded-md bg-slate-800 px-1 py-0.75 text-center",children:[l.jsx("div",{className:"text-xs text-slate-300",children:"Position"}),l.jsx("div",{className:"text-base font-semibold text-slate-100",children:n2(C)})]}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>Y("down",r),className:`button-dark w-full text-sm disabled:opacity-50 ${C==="down"||S==="down"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="down"||S==="down"?"Lowering...":"Down"}),l.jsx("button",{type:"button",disabled:!O,onClick:()=>Y("up",a),className:`button-dark w-full text-sm disabled:opacity-50 ${C==="up"||S==="up"?"bg-emerald-500 text-white hover:bg-emerald-500":""}`,children:u==="up"||S==="up"?"Raising...":"Up"})]})}),!x||!v||!E||!N?l.jsx("p",{className:"text-xs text-slate-400 text-center",children:x?v?"Waiting for required lift switch entities in Home Assistant.":"Home Assistant is offline.":"Set homeAssistant.lift.upSwitch and homeAssistant.lift.downSwitch in server config."}):null,n?.lastError?l.jsxs("p",{className:"text-xs text-rose-300 text-center",children:["Last error: ",n.lastError]}):null]})]})}function a2(n){const a=String(n||"").trim();if(!a)return"";try{const r=new URL(a),o=String(r.protocol||"").toLowerCase();return o!=="http:"&&o!=="https:"?"":r.toString()}catch{return""}}function l2({isVerified:n=!1,fullWidth:a=!1,onMessage:r}){const{value:o,save:u}=Ve("profile",{nickname:"",profileImageUrl:""}),f=String(o?.profileImageUrl||"").trim(),[p,h]=m.useState(f),[g,x]=m.useState(!1);m.useEffect(()=>{h(f)},[f]);const v=m.useMemo(()=>a2(p),[p]),b=String(p||"").trim()!==f,S=!!(n&&b&&(v||!String(p||"").trim())),C=a?"w-full":Nr,E=async N=>{if(N.preventDefault(),!n){r?.("Verify your account before setting a profile image URL.");return}x(!0),r?.("");try{const w=v||"";u(j=>({...j||{},profileImageUrl:w})),r?.(w?"Profile image URL saved.":"Profile image URL cleared.")}finally{x(!1)}};return l.jsx("section",{className:`surface text-sm text-slate-300 ${C}`,children:l.jsxs("form",{className:Ka,onSubmit:E,children:[l.jsx("p",{className:"text-sm text-slate-300",children:"Chat profile image URL"}),l.jsx("p",{className:"text-xs text-slate-500",children:"Verified users can set a custom avatar for chat and Discord bridge messages."}),l.jsx("input",{className:el,type:"url",name:"vip_profile_image_url",placeholder:"https://example.com/avatar.png",value:p,onChange:N=>h(N.target.value),disabled:!n||g}),!v&&String(p||"").trim()?l.jsx("p",{className:"text-xs text-amber-300",children:"Enter a valid http/https image URL."}):null,l.jsxs("div",{className:"flex justify-center gap-0.5",children:[l.jsx("button",{type:"submit",className:"button-dark text-sm disabled:opacity-50",disabled:!S||g,children:g?"Saving...":"Save URL"}),l.jsx("button",{type:"button",className:"button-dark text-sm disabled:opacity-50",disabled:!n||g||!f,onClick:()=>h(""),children:"Clear"})]})]})})}function rv({isActive:n=!0}){const a=oe(ue=>ue.session),{identifySession:r,requestVerification:o,requestPrivateRoverAccess:u,playUploadedAudio:f,stopUploadedAudio:p,startMicWhip:h,readyMicWhip:g,stopMicWhip:x,neatoStart:v,neatoSendHome:b,neatoLocate:S,neatoClearErrors:C,neatoPowerCycle:E,liftUp:N,liftDown:w}=$t(),{value:j,save:T}=Ve("identity",{cookieUserId:""}),{value:k}=Ve("profile",{nickname:""}),R=m.useMemo(()=>(j?.cookieUserId||"").trim(),[j?.cookieUserId]),D=(k?.nickname||"").trim(),V=!!a?.isVerified,O=a?.verification?.pendingRequestId||null,L=a?.privateRoverAccess?.requestableRovers||[],Y=a?.privateRoverAccess?.pendingRequests||[],U=String(a?.assignment?.roverId||"").trim(),[X,Q]=m.useState(""),ce=async ue=>{const W=String(ue||"").trim().toLowerCase();if(!W)throw new Error("Identity key required.");if(!LA.test(W))throw new Error("Identity key must match format: cu_ + 32 lowercase hex chars.");return T(B=>({...B||{},cookieUserId:W})),await r({cookieUserId:W,nickname:D}),W};return l.jsxs("section",{className:"space-y-2 text-base",children:[l.jsxs("div",{className:"grid gap-2 grid-cols-1 lg:grid-cols-[minmax(0,1.25fr)_minmax(0,0.9fr)]",children:[V?null:l.jsx("div",{className:"lg:col-span-2",children:l.jsx(ZA,{pendingRequestId:O,currentStoredKey:R,nickname:D,requestVerification:o,applyIdentityKey:ce,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:V?l.jsxs("div",{className:"space-y-2",children:[l.jsx(e2,{neato:a?.neato||null,onStart:v,onSendHome:b,onLocate:S,onClearErrors:C,onPowerCycle:E,fullWidth:!0}),l.jsx(s2,{lift:a?.lift||null,onUp:N,onDown:w,fullWidth:!0}),l.jsx(KA,{ownRoverId:U,audioForwardByRover:a?.audioForward||{},playUploadedAudio:f,stopUploadedAudio:p,startMicWhip:h,readyMicWhip:g,stopMicWhip:x})]}):l.jsx("section",{className:"surface h-full",children:l.jsx("div",{className:"flex h-full flex-col items-center justify-center text-center text-xs text-slate-400",children:"Verify your account to unlock VIP controls."})})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(PA,{requestableRovers:L,pendingRequests:Y,requestPrivateRoverAccess:u,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(JA,{currentStoredKey:R,applyIdentityKey:ce,onMessage:Q,fullWidth:!0})}),l.jsx("div",{className:"lg:col-span-2",children:l.jsx(l2,{isVerified:V,onMessage:Q,fullWidth:!0})})]}),X?l.jsx("div",{className:Nr,children:l.jsx("p",{className:"text-xs text-slate-400 text-center",children:X})}):null]})}const r2=420,i2=1200,o2={1:262,2:330,3:392,4:523};function vo(){const n=oe(N=>N.session?.buttonBox?.buttons??[]),a=Pt(),{value:r}=Ve("audio",it),o=Number.isFinite(r?.masterVolume)?r.masterVolume:it.masterVolume,u=Number.isFinite(r?.alertVolume)?r.alertVolume:it.alertVolume,f=Math.max(0,Math.min(1,o*u)),p=m.useMemo(()=>{const N=Array.isArray(n)?n:[];return N.length===4?N:[1,2,3,4].map(w=>N.find(j=>Number(j?.id)===w)||{id:w,count:0,goal:0,rewardName:null,rewardId:null,rewardNumber:null,lastRewardAt:null})},[n]),[h,g]=m.useState({}),[x,v]=m.useState({}),b=m.useRef(new Map),S=m.useRef(new Map),C=m.useRef({}),E=m.useRef(null);return m.useEffect(()=>{const N={};p.forEach(j=>{N[j.id]=Number(j.lastRewardAt||0)});const w=C.current||{};p.forEach(j=>{const T=Number(j.id),k=N[T]||0,R=Number(w[T]||0);if(k>0&&k!==R){v(O=>({...O,[T]:!0}));const D=S.current.get(T);D&&clearTimeout(D);const V=setTimeout(()=>{v(O=>({...O,[T]:!1})),S.current.delete(T)},i2);S.current.set(T,V)}}),C.current=N},[p]),m.useEffect(()=>{function N(j){const T=o2[j];if(!T||f<=0)return;let k=E.current;if(!k){const O=window.AudioContext||window.webkitAudioContext;if(!O)return;k=new O,E.current=k}const R=k.createOscillator(),D=k.createGain();R.type="square",R.frequency.value=T;const V=.14*f;D.gain.setValueAtTime(1e-4,k.currentTime),D.gain.exponentialRampToValueAtTime(Math.max(1e-4,V),k.currentTime+.01),D.gain.exponentialRampToValueAtTime(1e-4,k.currentTime+.2),R.connect(D),D.connect(k.destination),R.start(),R.stop(k.currentTime+.21)}function w(j={}){const T=Number(j.buttonId);if(!Number.isFinite(T)||T<1||T>4)return;g(D=>({...D,[T]:!0}));const k=b.current.get(T);k&&clearTimeout(k);const R=setTimeout(()=>{g(D=>({...D,[T]:!1})),b.current.delete(T)},r2);b.current.set(T,R),N(T)}return a.on("buttonBox:increment",w),()=>{a.off("buttonBox:increment",w)}},[f,a]),l.jsxs("section",{className:"panel-section space-y-0.5 text-base",children:[l.jsx("header",{className:"panel-muted text-center text-sm",children:l.jsx("p",{children:"Button Box"})}),l.jsx("div",{className:"grid grid-cols-4 gap-0.5",children:p.map(N=>{const w=Number(N.id),j=Number.isFinite(N.count)?N.count:0,T=Number.isFinite(N.goal)?N.goal:0,k=typeof N.rewardName=="string"&&N.rewardName.trim()?N.rewardName.trim():"Unassigned",R=Number.isFinite(N.rewardNumber)?N.rewardNumber:"?",D=!!h[w],V=!!x[w];return l.jsx(bg,{buttonId:w,count:j,goal:T,rewardNumber:R,rewardName:k,className:[D?"bg-cyan-900/45":"",V?"bg-fuchsia-900/45":""].filter(Boolean).join(" ")},w)})})]})}function c2(){const{state:{roverId:n}}=yt(),r=Wt(n)?.sensors||{};return l.jsx("section",{className:"panel-section",children:l.jsx("div",{className:"aspect-square w-full",children:l.jsx(Yg,{sensors:r})})})}function u2(){const{state:{roverId:n,keymap:a,camera:r,horn:o},pipeline:u,actions:{setServoAngle:f,setNightVision:p,startHorn:h,stopHorn:g}}=yt(),x=al(),v=Bg(n),b=v.docked&&!v.driving,S=r?.config,C=!!(n&&r?.enabled&&S),E=!!(n&&u?.nightVision),N=u?.nightVisionState,w=!!(n&&u?.horn),j=o?.overheated,T=typeof S?.minAngle=="number"?S.minAngle:-30,k=typeof S?.maxAngle=="number"?S.maxAngle:30,R=typeof r?.angle=="number"?r.angle:typeof S?.homeAngle=="number"?S.homeAngle:(T+k)/2,D=Tt(a?.nightVisionToggle?.[0]),V=Tt(a?.hornHonk?.[0]),O=Tt(a?.cameraUp?.[0]),L=Tt(a?.cameraDown?.[0]),Y=!!(!n||x.cameraLocked);return l.jsxs("section",{className:"panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5",children:[l.jsx(Og,{layout:"desktop",expand:!0,driveDockState:v}),b?null:l.jsxs("div",{className:"surface space-y-0.5 p-0 text-sm text-slate-200",children:[E&&l.jsx(Lg,{nightVisionOn:N?.nightVisionOn,disabled:!n,onToggle:p,keyLabel:D}),w&&l.jsx(zg,{disabled:!n||j,onStart:h,onStop:g,keyLabel:V,active:o?.active,heat:o?.heat}),C&&l.jsx(Ug,{value:R,min:T,max:k,disabled:Y,onChange:f,keyDownLabel:L,keyUpLabel:O,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 d2({layout:n,onOpenHelpOverlay:a}){const[r,o]=m.useState("telemetry"),u=oe(N=>!!N.session?.isVerified),f=oe(N=>String(N.session?.assignment?.roverId||"").trim()),p=oe(N=>{const w=String(N.session?.assignment?.roverId||"").trim();return w&&N.session?.audioForward?.[w]||null}),{state:h}=yt(),{value:g}=Ve("vipAudio",{openMicEnabled:!1,pttMode:"live"}),x=u?"bg-emerald-400":"bg-red-600",v=!!h?.mic?.pttActive,b=!!g?.openMicEnabled,S=g?.pttMode==="clip"?"clip":"live",C=!!(f&&u&&(S==="clip"?v:b||v)),E=!!(f&&u&&S==="clip"&&p?.source==="upload"&&p?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(gf,{defaultTab:"telemetry",currentTab:r,onTabChange:o,children:[l.jsxs(vf,{children:[l.jsx(Zt,{id:"telemetry",children:"Controls"}),l.jsx(Zt,{id:"vip",highlight:E?"green":C?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-2",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-3 w-3 rounded-full ${x}`,"aria-hidden":"true",title:u?"Verified":"Not verified"})]})}),l.jsx(Zt,{id:"help",children:"Help"}),l.jsx(Zt,{id:"settings",children:"Settings"})]}),l.jsxs(bf,{children:[l.jsx(Jt,{id:"telemetry",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.35fr)_minmax(0,0.95fr)]",children:[l.jsx(c2,{}),l.jsx(u2,{})]}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.9fr)_minmax(0,0.75fr)]",children:[l.jsx(Ro,{}),l.jsx(ef,{panelId:"replay-sources-desktop",fillHeight:!0}),l.jsx(RA,{})]}),l.jsxs("div",{className:"grid items-stretch gap-0.5 grid-cols-[minmax(0,1.3fr)_minmax(0,0.22fr)] h-[14rem]",children:[l.jsx(Mo,{fillHeight:!0}),l.jsxs("div",{className:"grid min-h-0 gap-0.5 grid-rows-[minmax(0,1fr)_auto]",children:[l.jsx(go,{compact:!0,hideNicknameForm:!0,fillHeight:!0}),l.jsx(MA,{compact:!0})]})]}),l.jsx(Kg,{}),l.jsx(vo,{}),l.jsx(cf,{defaultOrientation:"horizontal",panelId:"rightpane-telemetry"})]})}),l.jsx(Jt,{id:"vip",keepMounted:!0,children:l.jsx(rv,{isActive:r==="vip"})}),l.jsx(Jt,{id:"help",children:l.jsx(sv,{layout:n,onOpenOverlay:a})}),l.jsx(Jt,{id:"settings",children:l.jsx(ev,{})})]})]})})}const f2=new Set(["admin","lockdown","lockdown-admin"]),m2=new Set(["lockdown","lockdown-admin"]),h2=new Set(["admin","lockdown"]);function p2(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 x2(){const n=oe(b=>b.session?.mode||null),a=oe(b=>b.session?.role||null),r=oe(b=>b.session?.adminReason?.text||"");oe(b=>b.session?.adminReason?.updatedAt||null);const o=oe(b=>b.session?.timezone||"UTC"),u=oe(b=>(b.session?.socials||[]).find(E=>String(E?.id||E?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),f=h2.has(n),p=n==="lockdown"?m2.has(a):f2.has(a),[h,g]=m.useState(()=>new Date),x=m.useMemo(()=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:o,hour:"numeric",minute:"2-digit",second:"2-digit"}).format(h)}catch{return h.toLocaleTimeString()}},[h,o]);if(m.useEffect(()=>{const b=setInterval(()=>g(new Date),1e3);return()=>clearInterval(b)},[]),!f||p)return null;const v=p2(n);return l.jsx("div",{className:"pointer-events-auto fixed inset-0 z-50 flex items-center justify-center bg-black px-0.5 py-0.5",children:l.jsxs("div",{className:"surface w-full max-w-md space-y-0.5 text-slate-100 shadow-2xl",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-lg font-semibold",children:v.title}),l.jsx("p",{className:"text-sm text-slate-300",children:v.description})]}),l.jsxs("div",{className:"surface-muted space-y-0.5",children:[l.jsx("p",{className:"text-[0.7rem] tracking-wide text-slate-400",children:"Reason for locking:"}),l.jsx("p",{className:"text-lg font-semibold text-slate-100",children:r||"No reason set."}),l.jsxs("p",{className:"text-center text-sm text-slate-300",children:["Server time: ",x]})]}),l.jsx("div",{className:"surface-muted",children:l.jsx(Zg,{})}),l.jsx("div",{className:"w-full justify-center items-center",children:l.jsx(wo,{id:"discord",label:"Join our Discord server for updates!",url:u})}),"You can still use the chat while the server is locked:",l.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[l.jsx(Mo,{}),l.jsx(jr,{})]})]})})}const g2="/assets/turn_alert-DVO8EZJa.mp3";function v2(n,a=1){const r=m.useRef(null);return m.useEffect(()=>{r.current=new Audio(n),r.current.volume=a,r.current.load()},[n,a]),()=>{r.current&&(r.current.volume=a,r.current.currentTime=0,r.current.play().catch(()=>{}))}}function b2(){const n=oe(v=>v.session?.socketId||null),a=oe(v=>v.session?.turnQueues||{}),r=oe(v=>v.session?.roster||[]),{pushAlert:o}=$t(),{value:u}=Ve("audio",it),f=Number.isFinite(u?.masterVolume)?u.masterVolume:it.masterVolume,p=Number.isFinite(u?.alertVolume)?u.alertVolume:it.alertVolume,h=Math.max(0,Math.min(1,f*p)),g=v2(g2,h),x=m.useRef(new Set);return m.useEffect(()=>{if(!n)return;const v=[];Object.entries(a).forEach(([b,S])=>{!S||!S.current||S.current!==n||x.current.has(b)||(v.push(b),x.current.add(b))}),Object.keys(a).forEach(b=>{(!a[b]||a[b].current!==n)&&x.current.delete(b)}),v.length!==0&&(v.forEach(b=>{const S=r.find(C=>String(C.id)===String(b))?.name||b;o({title:"Your turn!",message:`You now control ${S}.`,color:"#ff5722"})}),g())},[a,g,o,r,n]),null}function y2({visible:n,mode:a,onEnterFullscreen:r,onDismiss:o}){if(!n)return null;const u=a==="pwa-hint";return l.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center p-1 pointer-events-none bg-black/20",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-sm surface center",children:l.jsxs("div",{className:"space-y-0.5 p-1 text-sm text-slate-100",children:[l.jsx("h2",{className:"text-base font-semibold text-white border-b border-slate-700",children:"Better in fullscreen!"}),u?l.jsxs("p",{className:"text-slate-300",children:["For fullscreen on iOS, open Safari's share menu and pick ",l.jsx("strong",{children:"Add to Home Screen"}),". Launching from the home screen then makes it fullscreen."]}):l.jsx("p",{className:"text-slate-300",children:"Enable fullscreen to free up more space for the video feed and controls. You can exit fullscreen at any time via the system back or home gesture."}),l.jsx("p",{className:"text-xs border-t border-b border-slate-700 p-0.5 text-blue-300 text-center",children:"This will only show once just to let you know. There is a fullscreen button in the bottom right for later use."}),l.jsxs("div",{className:"flex justify-end gap-0.5 pt-1 text-sm",children:[l.jsx("button",{type:"button",className:"rounded border border-slate-600 px-3 py-1 text-slate-200",onClick:o,children:u?"Got it":"Not now"}),!u&&l.jsx("button",{type:"button",className:"rounded bg-cyan-500 px-3 py-1 font-semibold text-black hover:bg-cyan-400",onClick:r,children:"Enter fullscreen"})]})]})})})}function S2({side:n="right",onClick:a}){const r=n==="left"?"left-2":"right-2";return l.jsx("button",{type:"button",onClick:a,className:`fixed bottom-2 ${r} z-30 flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-black text-slate-200 transition hover:bg-zinc-900 active:scale-95`,"aria-label":"Enter fullscreen",title:"Enter fullscreen",children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",className:"pointer-events-none",children:l.jsx("path",{d:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const iv="fullscreenPromptDismissed",j2=new Set(["mobile-portrait","mobile-landscape"]),ov=()=>{if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}},N2=()=>{const n=ov();if(!n)return!1;try{return n.getItem(iv)==="1"}catch{return!1}},Mx=()=>{const n=ov();if(n)try{n.setItem(iv,"1")}catch{}},w2=()=>{if(typeof navigator>"u")return!1;const n=navigator.userAgent||navigator.platform||"";return/iphone|ipad|ipod/i.test(n)},Rx=()=>{if(typeof document>"u")return!1;const n=document;return!!(n.fullscreenEnabled||n.webkitFullscreenEnabled||n.mozFullScreenEnabled||n.msFullscreenEnabled)};function A2(n){const a=j2.has(n),[r,o]=m.useState(!1),[u,f]=m.useState("native"),[p,h]=m.useState(!1),g=m.useMemo(()=>w2(),[]),x=m.useMemo(()=>Rx(),[]),v=m.useCallback(()=>{if(!a){o(!1),h(!1);return}if(!p&&N2()){o(!1);return}if(g){f("pwa-hint"),o(!0);return}if(!Rx()){o(!1);return}if(typeof document<"u"&&document.fullscreenElement){o(!1);return}f("native"),o(!0)},[p,g,a]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(typeof document>"u")return;const E=()=>{if(document.fullscreenElement){h(!1),o(!1);return}v()};return document.addEventListener("fullscreenchange",E),document.addEventListener("webkitfullscreenchange",E),()=>{document.removeEventListener("fullscreenchange",E),document.removeEventListener("webkitfullscreenchange",E)}},[v]);const b=m.useCallback(()=>{Mx(),h(!1),o(!1)},[]),S=m.useCallback(async()=>{if(!a||g||typeof document>"u")return!1;if(document.fullscreenElement)return!0;const E=document.documentElement;if(!E)return!1;const N=E.requestFullscreen||E.webkitRequestFullscreen||E.mozRequestFullScreen||E.msRequestFullscreen;if(!N)return!1;try{const w=N.call(E);return w&&typeof w.then=="function"&&await w,Mx(),h(!1),o(!1),!0}catch(w){return console.warn("Failed to enter fullscreen",w),!1}},[g,a]),C=m.useCallback(()=>{a&&(h(!0),f(g?"pwa-hint":"native"),o(!0))},[g,a]);return m.useEffect(()=>{a||(h(!1),o(!1))},[a]),{visible:r,mode:u,isIOS:g,nativeSupported:x,enterFullscreen:S,dismiss:b,showPrompt:C}}function C2({visible:n,layout:a,onClose:r,showOnLoad:o,onToggleShowOnLoad:u}){if(!n)return null;const{state:f}=yt(),p=h=>{const g=!h.target.checked;u?.(g)};return l.jsx("div",{className:"fixed inset-0 z-30 flex items-center justify-center bg-black/80 px-0.5 py-0.5",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-2xl",children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.25 text-sm text-slate-200",children:[l.jsx("span",{className:"font-semibold",children:"Help & controls"}),l.jsxs("div",{className:"flex items-center gap-0.5 text-[0.8rem] text-slate-300",children:[l.jsxs("label",{className:"flex items-center gap-0.5",children:[l.jsx("input",{type:"checkbox",checked:!o,onChange:p,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("button",{type:"button",onClick:r,className:"button-dark px-2 py-0.25 text-[0.8rem]",children:"Close"})]})]}),l.jsx("div",{className:"max-h-[85vh] overflow-y-auto p-0.5",children:l.jsx(nv,{layout:a,keymap:f?.keymap||{}})})]})})}function Ia({label:n,keyLabel:a}){return l.jsxs("div",{className:"surface-muted flex items-center justify-between gap-0.5 px-0.5 py-0.35 text-[0.8rem] text-slate-200",children:[l.jsx("span",{children:n}),l.jsx(zd,{label:a})]})}function k2({keymap:n}){return l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-sm text-slate-200",children:"2. Use the drive controls to move your rover:"}),l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Ia,{label:"Forward",keyLabel:Tt(n?.driveForward?.[0])}),l.jsx(Ia,{label:"Backward",keyLabel:Tt(n?.driveBackward?.[0])}),l.jsx(Ia,{label:"Turn Left",keyLabel:Tt(n?.driveLeft?.[0])}),l.jsx(Ia,{label:"Turn Right",keyLabel:Tt(n?.driveRight?.[0])}),l.jsx(Ia,{label:"Move faster",keyLabel:Tt(n?.boostModifier?.[0])}),l.jsx(Ia,{label:"Move slower",keyLabel:Tt(n?.slowModifier?.[0])})]})]}),l.jsx("p",{className:"text-sm text-slate-200",children:'3. When done, enter "Docking Assist" and line up the front sensor with the dock sensor.'})]})}function E2(){return l.jsxs("div",{className:"space-y-0.5 text-sm text-slate-200",children:[l.jsx("p",{children:'1. Press "Start Driving" put your rover into driving mode.'}),l.jsx("p",{children:"2. Touch and hold in Joystick area to move."}),l.jsx("p",{children:"3. Use the other column for motor, horn, and camera controls."}),l.jsx("p",{children:'4. When done, enter "Docking Assist" and line up the front sensor with the dock sensor.'})]})}function M2({visible:n,layout:a,showOnLoad:r,onToggleShowOnLoad:o,onOpenHelp:u,onClose:f}){const{state:p}=yt(),h=a==="desktop",g=oe(b=>(b.session?.socials||[]).find(E=>String(E?.id||E?.label||"").toLowerCase()==="discord")?.url||b.session?.discord?.invite||null),x=m.useMemo(()=>p?.keymap||{},[p?.keymap]);if(!n)return null;const v=b=>{const S=!b.target.checked;o?.(S)};return l.jsx("div",{className:"fixed inset-0 z-40 flex items-end justify-center bg-black/75 p-0.5 items-center",children:l.jsxs("div",{className:"pointer-events-auto surface w-full max-w-3xl overflow-hidden shadow-2xl",children:[l.jsx("div",{className:"flex items-center justify-between border-b border-slate-700 px-0.5 py-0.35 text-sm text-slate-200",children:l.jsx("span",{className:"font-semibold text-xl",children:"Welcome! To get started:"})}),l.jsxs("div",{className:`grid gap-0.5 p-0.5 ${h?"md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]":"grid-cols-1"}`,children:[l.jsx("section",{className:"space-y-0.5 border-b border-slate-700",children:h?l.jsx(k2,{keymap:x}):l.jsx(E2,{})}),l.jsxs("section",{className:"space-y-0.5",children:[l.jsx("p",{className:"text-left",children:"Next..."}),l.jsxs("div",{className:"surface space-y-0.5 p-0.5 border-b border-slate-700",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Set your nickname"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"Nicknames are assigned randomly by default, you can change yours here."}),l.jsx(jr,{compact:!0})]}),l.jsxs("div",{className:"surface p-0.5",children:[l.jsx("p",{className:"text-xl font-semibold text-slate-200",children:"Join our Discord server!"}),l.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"We have an active and welcoming community :3"}),l.jsx(wo,{id:"discord",label:"Join Discord",url:g})]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-0.5 border-t border-slate-700 px-0.5 py-0.35 text-[0.8rem]",children:[l.jsxs("label",{className:"flex items-center gap-0.5 text-slate-300",children:[l.jsx("input",{type:"checkbox",checked:!r,onChange:v,className:"accent-cyan-500"}),l.jsx("span",{children:"Don't show again"})]}),l.jsx("div",{className:"flex items-center gap-0.5",children:l.jsx("button",{type:"button",onClick:f,className:"button-dark px-1 py-0.25 text-2xl bg-green-600 hover:bg-green-400 hover:border-green-100 border-green-400",children:"Got it! Let me in!"})})]})]})})}const R2=`aroma
|
||
bagel
|
||
batter
|
||
beans
|
||
beer
|
||
biscuit
|
||
bread
|
||
broth
|
||
burger
|
||
burrito
|
||
butter
|
||
cake
|
||
candy
|
||
caramel
|
||
caviar
|
||
cheese
|
||
chili
|
||
chimichanga
|
||
chocolate
|
||
cider
|
||
cobbler
|
||
cocoa
|
||
coffee
|
||
cookie
|
||
cream
|
||
croissant
|
||
crumble
|
||
cuisine
|
||
curd
|
||
dessert
|
||
dish
|
||
drink
|
||
eggs
|
||
empanada
|
||
enchilada
|
||
entree
|
||
filet
|
||
fish
|
||
flour
|
||
foie gras
|
||
food
|
||
glaze
|
||
grill
|
||
hamburger
|
||
ice
|
||
juice
|
||
ketchup
|
||
kitchen
|
||
lard
|
||
liquor
|
||
margarine
|
||
marinade
|
||
mayo
|
||
mayonnaise
|
||
meat
|
||
milk
|
||
mousse
|
||
muffin
|
||
mushroom
|
||
noodle
|
||
nut
|
||
oil
|
||
olive
|
||
omelette
|
||
pan
|
||
pasta
|
||
paste
|
||
pastry
|
||
pie
|
||
pizza
|
||
plate
|
||
pot
|
||
poutine
|
||
pudding
|
||
queso
|
||
raclette
|
||
recipe
|
||
rice
|
||
salad
|
||
salsa
|
||
sandwich
|
||
sauce
|
||
seasoning
|
||
skillet
|
||
soda
|
||
sopapillas
|
||
soup
|
||
soy
|
||
spice
|
||
steak
|
||
stew
|
||
syrup
|
||
taco
|
||
taquito
|
||
tartar
|
||
taste
|
||
tea
|
||
toast
|
||
tostada
|
||
vinegar
|
||
waffle
|
||
water
|
||
wheat
|
||
wine
|
||
wok
|
||
yeast
|
||
yogurt
|
||
shrimp
|
||
fling`;function T2(n){return n?n.charAt(0).toUpperCase()+n.slice(1):""}function q2(){const n=String(R2).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);return n.length?(n[Math.floor(Math.random()*n.length)]||"").trim():""}function yf(){const{setNickname:n}=$t(),{value:a,status:r,save:o}=Ve("profile",{nickname:""}),u=m.useRef(!1);m.useEffect(()=>{if(r!=="ready"||u.current||(a.nickname||"").trim())return;u.current=!0;const p=T2(q2()).slice(0,32);if(!p)return;(async()=>{try{await n(p)}catch{}finally{o({nickname:p})}})()},[o,n,r,a.nickname])}function D2(){const n=Pt(),a=oe(w=>w.connected),{identifySession:r}=$t(),{value:o,status:u,save:f}=Ve("identity",{cookieUserId:""}),{value:p,status:h}=Ve("profile",{nickname:""}),g=m.useRef(!1),x=m.useRef(null),v=m.useRef(null),b=u==="ready"&&h==="ready",S=(o?.cookieUserId||"").trim(),C=(p?.nickname||"").trim(),E=m.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),N=m.useCallback(async()=>{if(!(!b||!a||!n?.id||g.current)){g.current=!0;try{const j=((await r({cookieUserId:S,nickname:C}))?.cookieUserId||"").trim();j&&j!==S&&f(T=>({...T||{},cookieUserId:j})),x.current=n.id,E()}catch{E(),v.current=setTimeout(()=>{N()},2e3)}finally{g.current=!1}}},[E,a,S,r,C,b,f,n?.id]);m.useEffect(()=>{!b||!a||!n?.id||x.current!==n.id&&N()},[a,b,N,n?.id]),m.useEffect(()=>{!b||!a||!n?.id||N()},[b,a,n?.id,S,C,N]),m.useEffect(()=>{const w=()=>{n?.connected&&N()},j=()=>{typeof document>"u"||document.visibilityState!=="visible"||n?.connected&&N()};return window.addEventListener("online",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("online",w),document.removeEventListener("visibilitychange",j)}},[N,n?.connected]),m.useEffect(()=>()=>E(),[E])}const vd=1e4,bd=28,_2=14;function bo({layout:n="desktop",className:a="",dismissable:r=!0}){const o=oe(j=>{const T=j.session?.globalObjective?.text;return T?String(T).trim():""}),u=n==="mobile-portrait"||n==="mobile-landscape"||n==="mobile",[f,p]=m.useState(!1),[h,g]=m.useState(bd),[x,v]=m.useState(0),b=m.useRef(null),S=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!o){p(!1);return}if(p(!0),!u||!r)return;const j=Date.now();v(vd);const T=setTimeout(()=>p(!1),vd),k=setInterval(()=>{const R=Date.now()-j;v(Math.max(0,vd-R))},250);return()=>{clearTimeout(T),clearInterval(k)}},[o,u]),m.useEffect(()=>{if(!o)return;g(bd);let j=0;const T=()=>{const R=C.current,D=S.current;if(!R||!D)return;const V=R.clientWidth;if(!V)return;const O=D.scrollWidth;if(!O)return;const L=Math.min(1,V/O),Y=Math.max(_2,Math.floor(bd*L));g(Y)};j=window.requestAnimationFrame(T);const k=new ResizeObserver(()=>{window.cancelAnimationFrame(j),j=window.requestAnimationFrame(T)});return b.current&&k.observe(b.current),()=>{window.cancelAnimationFrame(j),k.disconnect()}},[o]);const E=m.useMemo(()=>["panel-section flex w-full items-center justify-center",u?"rounded-none":"rounded","px-1 py-1 text-center font-semibold tracking-tight",a].filter(Boolean).join(" "),[a,u]);if(!o||!f)return null;const N=u?Math.ceil(x/1e3):null,w=r?{onClick:()=>p(!1),role:"button",tabIndex:0}:{};return l.jsx("div",{ref:b,className:E,style:{fontSize:`${h}px`,lineHeight:1.1},...w,children:l.jsxs("span",{className:"flex w-full items-stretch gap-0.5 whitespace-nowrap rounded-md",children:[l.jsxs("span",{className:"flex flex-col justify-center border-r border-slate-700/60 px-0.5 text-[0.55em] font-semibold leading-tight text-slate-400",children:[l.jsx("span",{children:"Global"}),l.jsx("span",{children:"Objective"})]}),l.jsx("span",{ref:C,className:"flex-1 overflow-hidden text-slate-100",children:l.jsx("span",{ref:S,className:"block",children:o})}),u?l.jsxs("span",{className:"flex items-center border-l border-slate-700/60 px-0.5 text-[0.55em] font-semibold uppercase tracking-wide text-slate-400",children:[N,"s"]}):null]})})}const B2=3200;function O2(n={}){const a=typeof n.rewardName=="string"&&n.rewardName.trim()?n.rewardName.trim():"Unknown Event",r=Number.isFinite(Number(n.goal))?Math.max(1,Math.floor(Number(n.goal))):0,o=Number.isFinite(Number(n.count))?Math.max(0,Math.floor(Number(n.count))):r;return{rewardName:a,goal:r,count:o,ts:Date.now()}}function cv(){const n=Pt(),{value:a}=Ve("audio",it),r=Number.isFinite(a?.masterVolume)?a.masterVolume:it.masterVolume,o=Number.isFinite(a?.alertVolume)?a.alertVolume:it.alertVolume,u=Math.max(0,Math.min(1,r*o)),[f,p]=m.useState(null),h=m.useRef(null);return m.useEffect(()=>{h.current=new Audio("/tada.mp3"),h.current.volume=u,h.current.load()},[u]),m.useEffect(()=>{let g=null;function x(){const S=h.current;S&&(S.volume=u,S.currentTime=0,S.play().catch(()=>{}))}function v(S={}){const C=O2(S);p(C),x(),g&&clearTimeout(g),g=setTimeout(()=>{p(null)},B2)}function b(S){v(S?.detail||{})}return n.on("buttonBox:rewardRun",v),window.addEventListener("buttonBox:rewardRunLocalTest",b),()=>{g&&clearTimeout(g),n.off("buttonBox:rewardRun",v),window.removeEventListener("buttonBox:rewardRunLocalTest",b)}},[u,n]),f?l.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120] flex items-center justify-center bg-black/75 px-1 py-1",children:l.jsx("div",{className:"pointer-events-auto w-full max-w-2xl",children:l.jsx("div",{className:"surface rounded-none border-2 border-cyan-300 bg-amber-100/95 px-1 py-1 text-center text-black shadow-2xl",children:l.jsxs("div",{className:"flex items-center justify-center gap-1 border-2 border-blue-600 bg-yellow-100 px-0.5 py-1",children:[l.jsx("img",{src:"/party1.gif",alt:"",className:"hidden shrink-0 sm:block"}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-mono text-2xl font-bold text-red-700 sm:text-3xl",children:["Running event: ",f.rewardName,"!"]}),l.jsxs("p",{className:"font-mono text-xl font-bold text-blue-800 sm:text-2xl",children:[f.count,"/",f.goal]})]}),l.jsx("img",{src:"/party2.gif",alt:"",className:"hidden shrink-0 sm:block"})]})})})}):null}function L2(){const[n,a]=m.useState(()=>typeof window>"u"||window.innerWidth>=1024?"desktop":window.innerWidth>window.innerHeight?"mobile-landscape":"mobile-portrait");return m.useEffect(()=>{function r(){if(typeof window>"u")return;const{innerWidth:o,innerHeight:u}=window;o>=1024?a("desktop"):o>u?a("mobile-landscape"):a("mobile-portrait")}return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),n}function z2({layout:n,onOpenHelpOverlay:a}){return l.jsxs("div",{className:"flex h-full gap-0.5 overflow-hidden",children:[l.jsxs("div",{className:"flex min-w-0 flex-[1.22] flex-col gap-0.5 overflow-y-auto pr-0",children:[l.jsx(mf,{}),l.jsx(pj,{}),l.jsx(uf,{})]}),l.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto",children:[l.jsx(bo,{layout:n}),l.jsx(d2,{layout:n,onOpenHelpOverlay:a})]})]})}function uv({layout:n,onOpenHelpOverlay:a,roomPanelId:r,showTelemetry:o=!0}){const[u,f]=m.useState("chat"),p=oe(j=>!!j.session?.isVerified),h=oe(j=>String(j.session?.assignment?.roverId||"").trim()),g=oe(j=>{const T=String(j.session?.assignment?.roverId||"").trim();return T&&j.session?.audioForward?.[T]||null}),{state:x}=yt(),{value:v}=Ve("vipAudio",{openMicEnabled:!1,pttMode:"live"}),b=p?"bg-emerald-400":"bg-amber-400",S=!!x?.mic?.pttActive,C=!!v?.openMicEnabled,E=v?.pttMode==="clip"?"clip":"live",N=!!(h&&p&&(E==="clip"?S:C||S)),w=!!(h&&p&&E==="clip"&&g?.source==="upload"&&g?.state==="playing");return l.jsx("section",{className:"panel text-base",children:l.jsxs(gf,{defaultTab:"chat",currentTab:u,onTabChange:f,children:[l.jsxs(vf,{children:[l.jsx(Zt,{id:"chat",children:"Chat"}),l.jsx(Zt,{id:"vip",highlight:w?"green":N?"pink":"none",children:l.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[l.jsx("span",{children:"VIP"}),l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${b}`,"aria-hidden":"true",title:p?"Verified":"Not verified"})]})}),l.jsx(Zt,{id:"roomcontrols",children:"Room Controls"}),l.jsx(Zt,{id:"help",children:"Help"}),l.jsx(Zt,{id:"settings",children:"Settings"})]}),l.jsxs(bf,{children:[l.jsx(Jt,{id:"chat",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Mo,{}),l.jsx(go,{})]})}),l.jsx(Jt,{id:"vip",keepMounted:!0,children:l.jsx(rv,{isActive:u==="vip"})}),l.jsx(Jt,{id:"roomcontrols",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(Kg,{}),l.jsx(vo,{}),l.jsx(cf,{panelId:r})]})}),l.jsx(Jt,{id:"help",children:l.jsx(sv,{layout:n,onOpenOverlay:a})}),l.jsx(Jt,{id:"settings",children:l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(ev,{}),l.jsx(uf,{})]})})]})]})})}function U2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsx(mf,{layoutFormat:"mobile-portrait"}),l.jsx($N,{swapColumns:a}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(ef,{panelId:"replay-sources-mobile-portrait"}),l.jsx(Ro,{})]}),l.jsx(uv,{layout:"mobile-portrait",onOpenHelpOverlay:n,roomPanelId:"mobile-portrait-room"})]})}function H2({onOpenHelpOverlay:n,swapMobileControlColumns:a=!1}){const r="self-start h-[min(100svh,32rem)]",o=a?l.jsx(po,{layout:"landscape",className:r}):l.jsx(ho,{layout:"landscape",className:r}),u=a?l.jsx(ho,{layout:"landscape",className:r}):l.jsx(po,{layout:"landscape",className:r});return l.jsxs("div",{className:"flex flex-col gap-0.5",children:[l.jsxs("section",{className:"grid min-h-screen grid-cols-[minmax(0,0.7fr)_minmax(0,2.1fr)_minmax(0,0.7fr)] gap-0.5",children:[o,l.jsxs("div",{children:[l.jsx(mf,{layoutFormat:"mobile-landscape"}),l.jsxs("div",{className:"grid gap-0.5 grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[l.jsx(ef,{panelId:"replay-sources-mobile-landscape"}),l.jsx(Ro,{})]})]}),u]}),l.jsx("div",{className:"flex flex-col gap-0.5 pb-0",children:l.jsx(uv,{layout:"mobile-landscape",onOpenHelpOverlay:n,roomPanelId:"mobile-landscape-room",showTelemetry:!1})})]})}function V2(){const n=L2(),a=n==="desktop",r=A2(n);return l.jsx("div",{className:`bg-black text-slate-100 ${a?"h-screen overflow-hidden":"min-h-screen"}`,children:l.jsx($2,{layout:n,isDesktop:a,fullscreen:r})})}function $2({layout:n,isDesktop:a,fullscreen:r}){yf(),D2();const{visible:o,mode:u,isIOS:f,nativeSupported:p,enterFullscreen:h,dismiss:g,showPrompt:x}=r,{value:v,save:b}=Ve("help",{showOnLoad:!0}),{value:S,status:C,save:E}=Ve("quickstart",{showOnLoad:!0}),{value:N}=Ve("page",{swapMobileControlColumns:!1}),w=!!N?.swapMobileControlColumns,j=w?"left":"right",T=!a&&(f||p),[k,R]=m.useState(!1),[D,V]=m.useState(!1);m.useEffect(()=>{C==="ready"&&V(S?.showOnLoad!==!1)},[C,S?.showOnLoad]);const O=m.useCallback(()=>R(!0),[]),L=m.useCallback(()=>R(!1),[]),Y=m.useCallback(()=>V(!1),[]),U=m.useCallback(async()=>{if(f){x();return}await h()||x()},[h,f,x]),X=m.useCallback(ue=>{const W=!!ue;E(B=>({...B??{},showOnLoad:W})),W||V(!1)},[E]),Q=m.useCallback(()=>{V(!1),R(!0)},[]),ce=m.useMemo(()=>a?l.jsx(z2,{layout:n,onOpenHelpOverlay:O}):n==="mobile-landscape"?l.jsx(H2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}):l.jsx(U2,{onOpenHelpOverlay:O,swapMobileControlColumns:w}),[a,n,O,w]);return l.jsxs(cN,{children:[l.jsx(yN,{}),l.jsx(qN,{}),l.jsxs("main",{className:`flex w-full flex-col gap-0.5 text-base ${a?"h-full overflow-hidden":""}`,children:[a?null:l.jsx(bo,{layout:n}),ce]}),l.jsx(sf,{}),l.jsx(cv,{}),l.jsx(b2,{}),l.jsx(x2,{}),l.jsx(C2,{visible:k,layout:n,onClose:L,showOnLoad:v?.showOnLoad!==!1,onToggleShowOnLoad:ue=>b(W=>({...W??{},showOnLoad:!!ue}))}),l.jsx(y2,{visible:o,mode:u,onEnterFullscreen:h,onDismiss:g}),l.jsx(M2,{visible:D,layout:n,showOnLoad:S?.showOnLoad!==!1,onToggleShowOnLoad:X,onOpenHelp:Q,onClose:Y}),T?l.jsx(S2,{side:j,onClick:U}):null]})}function dv(){const{session:n,setRole:a,subscribeAll:r,connected:o}=br(),[u,f]=m.useState(!1);return m.useEffect(()=>{let p=!1;async function h(){if(n?.mode==="lockdown"){f(!1);return}try{n?.role!=="spectator"&&await a("spectator"),await r(),p||f(!0)}catch(g){console.error("Failed to enter spectator mode",g),p||f(!1)}}return h(),()=>{p=!0}},[o,n?.mode,n?.role,a,r]),u}function G2(){const[n,a]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-aspect-ratio: 4/3)").matches);return m.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia("(max-aspect-ratio: 4/3)"),o=u=>a(u.matches);return r.addEventListener?r.addEventListener("change",o):r.addListener(o),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener(o)}},[]),n}function Y2({show:n=!1,roverId:a=null,sensors:r,batteryConfig:o,mobileHud:u=!1}){const f=Wt(a),p=oe(v=>a?(v.session?.roster||[]).find(C=>String(C.id)===String(a))?.battery??null:null),h=r??f?.sensors??null,g=o??p,x=Co({charge:h?.batteryChargeMah??null,config:g});return!n||!x?.available?null:l.jsx("div",{className:"pointer-events-none absolute right-1 top-1/2 flex h-[70%] -translate-y-1/2 flex-col items-center justify-center rounded bg-black/60 px-0.5 pb-1 pt-1",children:l.jsx(ff,{visual:x,orientation:"vertical",variant:"inline",compact:u,className:"h-full w-4"})})}const F2=Dt.memo(Y2);function I2({roverId:n=null,label:a,fitParent:r=!1,layoutFormat:o="desktop"}){return l.jsx("div",{className:`flex flex-col gap-0.5 ${r?"h-full":""}`,children:l.jsxs("div",{className:`relative w-full overflow-hidden bg-black ${r?"h-full flex-1":"aspect-[4/3]"}`,children:[l.jsx(fr,{roverId:n,label:a}),l.jsx(Ig,{roverId:n,variant:"spectator",mobileHud:!1}),l.jsx(Fg,{roverId:n,layoutFormat:o,variant:"spectator",mobileHud:!1,labelScale:1}),l.jsx(Xg,{roverId:n,compact:!1}),l.jsx(Qg,{roverId:n,compact:!1}),l.jsx(F2,{show:!0,roverId:n,mobileHud:!1})]})})}function X2({rover:n}){return l.jsx("article",{className:"min-h-[16rem] rounded bg-zinc-900 p-0 sm:min-h-[18rem]",children:l.jsx("div",{className:"min-h-0 overflow-hidden rounded bg-black/20",children:l.jsx(I2,{roverId:n.id,label:n.name})})})}function Q2({roster:n}){return n.length===0?l.jsx("p",{className:"col-span-full text-slate-400",children:"No rovers registered."}):l.jsx("section",{className:"grid grid-cols-1 gap-0.5 md:grid-cols-2",children:n.map(a=>l.jsx(X2,{rover:a},a.id))})}function K2(){return l.jsx("section",{className:"min-h-0",children:l.jsx("div",{className:"surface min-h-[14rem] overflow-hidden",children:l.jsx(cf,{defaultOrientation:"horizontal",hideLayoutToggle:!0,hideHeader:!0,panelId:"spectator-secondary"})})})}function Z2({className:n=""}){return l.jsx("div",{className:`panel ${n}`,children:l.jsx(uf,{})})}function J2(){const{session:n}=br(),a=n?.mode==="lockdown";yf(),dv();const r=G2(),o=n?.roster??[];if(a)return l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-md space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Spectate disabled during lockdown."}),l.jsx("p",{className:"text-slate-300",children:"Please wait until the server leaves lockdown to view streams."})]})});const u=r?"flex min-h-screen flex-col bg-black text-slate-100 md:h-screen md:overflow-hidden":"grid min-h-screen grid-cols-1 gap-0.5 bg-black text-slate-100 md:h-full md:min-h-0 md:grid-cols-[minmax(0,1fr)_18rem] lg:grid-cols-[minmax(0,1fr)_20rem]",f=r?"order-2 flex min-h-0 min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto":"order-1 flex min-h-0 min-w-0 flex-col gap-0.5 md:overflow-y-auto",p=r?"order-1 grid w-full min-h-0 items-stretch gap-0.5 border-b border-slate-800/60 bg-slate-950/90 p-0.5 grid-cols-[minmax(0,1fr)_minmax(0,0.7fr)_minmax(0,1.9fr)_minmax(0,0.7fr)]":"order-2 flex min-h-0 min-w-0 flex-col gap-0.5 border-l border-slate-800/60 bg-slate-950/90 md:h-full md:overflow-y-auto",h="",g=r?"h-64":"";return l.jsxs("div",{className:"min-h-screen bg-black text-slate-100 md:h-screen md:overflow-hidden",children:[l.jsxs("main",{className:u,children:[l.jsxs("section",{className:p,children:[r?l.jsxs("div",{className:`${h} ${g} flex flex-col gap-0.5`,children:[l.jsx(bo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(vo,{}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(go,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})})]}):l.jsxs("div",{className:h,children:[l.jsx(bo,{layout:"desktop",dismissable:!1,className:"text-sm"}),l.jsx(vo,{})]}),l.jsx("div",{className:`${h} ${r?`${g} overflow-y-auto`:""}`,children:l.jsx("div",{className:"panel h-full",children:l.jsx(Ro,{title:"Rovers"})})}),r?null:l.jsx("div",{className:`${h} flex-1 min-h-0`,children:l.jsx(go,{hideNicknameForm:!0,hideHeader:!0,compact:!0,fillHeight:!0,className:"h-full"})}),l.jsx("div",{className:`${h} ${r?g:"flex-[1.1] min-h-0"}`,children:l.jsx(Mo,{allowSpectatorInput:!0,hideSpectatorNotice:!0,fillHeight:!0})}),l.jsx("div",{className:`${h} ${r?g:""}`,children:l.jsx(Z2,{className:`${r?"h-full":"h-40"} overflow-hidden`})})]}),l.jsxs("section",{className:f,children:[l.jsx(Q2,{roster:o}),l.jsx(K2,{})]})]}),l.jsx(sf,{}),l.jsx(cv,{})]})}function P2(){return l.jsx(J2,{})}function W2({children:n}){return l.jsx("div",{className:"flex h-full w-full items-center justify-start overflow-hidden bg-black",children:l.jsx("div",{className:"relative flex items-center justify-center overflow-hidden bg-black",style:{width:"min(100%, calc(100vh * 4 / 3))",height:"min(100%, calc(100vw * 3 / 4))",maxWidth:"100%",maxHeight:"100%",aspectRatio:"4 / 3"},children:l.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden",children:n})})})}function e5({roverId:n,session:a}){const r=a?.activeDrivers?.[n]||null,u=(a?.users||[]).find(h=>h.socketId===r)?.nickname||(r?r.slice(0,6):"No driver"),f=a?.mode,p=a?.turnQueues?.[n];return f==="turns"&&p?.current?`${u}`:u}function t5({rover:n,frame:a}){const r=a?.sensors?.batteryChargeMah??null,o=n?.battery??null;return Co({batteryState:n?.batteryState??null,charge:r,config:o})}function Xa({children:n,className:a="",maxSize:r=1e3,minSize:o=14,style:u=void 0}){const f=m.useRef(null),p=m.useRef(null),[h,g]=m.useState(r);return m.useLayoutEffect(()=>{const x=f.current,v=p.current;if(!x||!v)return;let b=null;const S=()=>{const N=x.clientWidth;if(!N){C();return}let w=o,j=r,T=o;for(;w<=j;){const k=Math.floor((w+j)/2);v.style.fontSize=`${k}px`,v.scrollWidth<=N?(T=k,w=k+1):j=k-1}g(T)},C=()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(S)};C();const E=new ResizeObserver(C);return E.observe(x),()=>{b&&cancelAnimationFrame(b),E.disconnect()}},[n,r,o]),l.jsx("div",{ref:f,className:"w-full min-w-0",children:l.jsx("div",{ref:p,className:`whitespace-nowrap ${a}`,style:{fontSize:`${h}px`,lineHeight:1.1,...u||{}},children:n})})}function Tx({rover:n,frame:a,driverLabel:r,sessionInfo:o,videoMode:u="snapshot",snapshotFeed:f,withDivider:p=!1,showPreview:h=!0,variant:g="stacked"}){const x=t5({rover:n,frame:a}),v=x?.available?x.percentDisplay:null,b=g==="active";return l.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col gap-4 overflow-hidden bg-black px-0 py-0 ${p?"border-r border-slate-700/60":""}`,children:[l.jsx(ff,{visual:x,orientation:b?"vertical":"horizontal",variant:"background"}),b?l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col justify-between text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ns(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):l.jsx("div",{}),l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:v==null?"--%":`${v}%`})})})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative z-10 flex min-w-0 flex-col gap-1 text-center",children:[l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white rounded border border-transparent px-1 py-[1px]",maxSize:1e3,minSize:18,style:ns(n.color,.18),children:n.name||n.id})}),r?l.jsx("div",{className:"min-w-0 bg-transparent px-0 py-0 leading-none",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:1e3,minSize:16,children:r})}):null,l.jsx("div",{className:"relative min-w-0 overflow-hidden bg-transparent px-0 py-0 leading-none",children:l.jsx("div",{className:"relative",children:l.jsx(Xa,{className:"font-semibold leading-none text-white",maxSize:80,minSize:16,children:v==null?"--%":`${v}%`})})})]}),l.jsx("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-4",children:l.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col items-center gap-4",children:h?l.jsx("div",{className:"mt-auto w-full",children:l.jsx("div",{className:"w-full aspect-[4/3]",children:l.jsx(fr,{sessionInfo:o,videoMode:u,snapshotFeed:f,audioSessionInfo:null,label:n.name||n.id,sensors:a?.sensors||null})})}):null})})]})]})}const n5=2e4,s5=3600*1e3;function a5(){const{session:n}=br(),a=dv();yf();const r=n?.mode==="lockdown",o=!!n?.isLocalNetwork,u=dj(),f=n?.roster??[],[p,h]=m.useState(0),g=n?.activeDrivers||{},x=m.useMemo(()=>f.filter(U=>g[U.id]),[f,g]),v=x.length?x:f,b=Vg(v.map(U=>U.id),{enabled:!r&&!o,version:n?.mode}),S=m.useMemo(()=>o?v.map(U=>({type:"rover",id:U.id,key:U.id})):[],[o,v]),C=Ld(S,{enabled:!r&&o,version:n?.mode}),E=m.useMemo(()=>x.flatMap(U=>{if(!U?.id||!U.media?.audioPublishUrl)return[];const X=String(U.id);return[{type:"rover",id:`${X}-audio`,key:`${X}-audio`}]}),[x]),N=Ld(E,{enabled:!r,version:n?.mode}),w=m.useMemo(()=>{if(!x.length)return[];if(!o){const X=x.filter(Q=>b[Q.id]?.objectUrl);return X.length?X:x}const U=x.filter(X=>{const Q=C[X.id];return Q?.url&&!Q?.error});return U.length?U:x},[x,b,C,o]),j=m.useMemo(()=>w.map(U=>({type:"rover",rover:U})),[w]),T=m.useMemo(()=>j.map(U=>`r:${U.rover.id}`).join("|"),[j]);m.useEffect(()=>{h(0)},[T]),m.useEffect(()=>{if(!j.length)return;const U=setInterval(()=>{h(X=>(X+1)%j.length)},n5);return()=>clearInterval(U)},[j.length,T]);const k=j.length?j[p%j.length]:null,R=k?.type==="rover"?k.rover:null,D=!o&&R&&b[R.id]||null,V=o&&R&&C[R.id]||null,O=R&&N[`${R.id}-audio`]||null,L=R&&u[R.id]||null,Y=R?e5({roverId:R.id,session:n}):null;return r?l.jsx("div",{className:"relative flex h-screen w-screen items-center justify-center bg-black text-slate-200",children:l.jsxs("div",{className:"surface max-w-sm space-y-0.5 p-1 text-center text-sm",children:[l.jsx("p",{className:"text-lg font-semibold text-white",children:"Mini spectator is disabled in lockdown."}),l.jsx("p",{className:"text-slate-300",children:"It will automatically resume once lockdown ends."})]})}):x.length?l.jsxs("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:[l.jsx("section",{className:"relative flex h-full shrink-0 items-center justify-start overflow-hidden bg-black",style:{width:"min(100vw, calc(100vh * 4 / 3))"},children:a?R?l.jsx(W2,{children:o?l.jsx("div",{className:"relative h-full w-full",children:j.map(U=>{const X=U.rover,Q=R?.id===X.id;return l.jsx("div",{className:`absolute inset-0 ${Q?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsx(fr,{sessionInfo:C[X.id]||null,videoMode:"whep",snapshotFeed:null,audioSessionInfo:Q?O:null,forceMute:!Q,label:X.name||X.id,sensors:u[X.id]?.sensors||null})},X.id)})}):l.jsx(fr,{sessionInfo:null,videoMode:"snapshot",snapshotFeed:D,audioSessionInfo:O,label:R.name||R.id,sensors:L?.sensors||null})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:x.length?"No sources available.":"No active drivers."}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"Switching to spectator…"})}),l.jsx("aside",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-slate-800/60 bg-black",children:R?l.jsx(Tx,{rover:R,frame:L,driverLabel:Y,sessionInfo:o?V:null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[R.id]||null,showPreview:!1,variant:"active"}):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No active rover."})})]}):l.jsx("div",{className:"relative flex h-screen w-screen overflow-hidden bg-black text-slate-100",children:l.jsx("section",{className:"flex h-full w-full gap-x-3 bg-slate-900 px-0",children:f.length?f.map(U=>l.jsx(Tx,{rover:U,frame:u[U.id]||null,driverLabel:null,sessionInfo:o&&C[U.id]||null,videoMode:o?"whep":"snapshot",snapshotFeed:o?null:b[U.id]||null,showPreview:!0,withDivider:!1},U.id)):l.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-slate-500",children:"No rovers available."})})})}function l5(){return m.useEffect(()=>{if(typeof window>"u")return;const n=setTimeout(()=>{const a=new URL(window.location.href);a.searchParams.set("refresh",Date.now().toString()),window.location.replace(a.toString())},s5);return()=>clearTimeout(n)},[]),l.jsxs(l.Fragment,{children:[l.jsx(a5,{}),l.jsx(sf,{scale:3})]})}function Ki(n){if(!n||!n.length)return null;const a=Math.floor(Math.random()*n.length);return n[a]||null}function r5(){if(typeof document>"u"||!document.body)return;const n=document.body.getElementsByTagName("*");if(!n||n.length<2)return;const a=Ki(n),r=Ki(n),o=a?.classList?.[0]||null;if(o&&r?.classList)try{r.classList.add(o)}catch{}const u=Ki(n),f=Ki(n),p=u?.classList?.[1]||null;if(p&&f?.classList)try{f.classList.add(p)}catch{}}function i5(){const n=oe(a=>!!a.session?.moderation?.isDeterred);return m.useEffect(()=>{if(!n)return;const a=window.setInterval(()=>{r5()},1);return()=>{window.clearInterval(a)}},[n]),null}By.createRoot(document.getElementById("root")).render(l.jsx(m.StrictMode,{children:l.jsx(aj,{children:l.jsx(oj,{children:l.jsx(uj,{children:l.jsx(yj,{children:l.jsxs(dN,{children:[l.jsx(i5,{}),l.jsx(Z1,{children:l.jsxs(k1,{children:[l.jsx(Zi,{path:"/",element:l.jsx(V2,{})}),l.jsx(Zi,{path:"/spectate",element:l.jsx(P2,{})}),l.jsx(Zi,{path:"/mini",element:l.jsx(l5,{})})]})})]})})})})})}));
|