herdr-remote-relay 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ var Oy=Object.defineProperty;var Uy=(r,a,i)=>a in r?Oy(r,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[a]=i;var se=(r,a,i)=>Uy(r,typeof a!="symbol"?a+"":a,i);import{r as Mp,g as _p,a as zp}from"./vendor-react-CYSfZuHu.js";import{r as By,a as Hy,b as Yy}from"./vendor-xterm-Yo7-doCv.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))o(d);new MutationObserver(d=>{for(const f of d)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 i(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function o(d){if(d.ep)return;d.ep=!0;const f=i(d);fetch(d.href,f)}})();var vu={exports:{}},Mr={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Um;function Ky(){if(Um)return Mr;Um=1;var r=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function i(o,d,f){var p=null;if(f!==void 0&&(p=""+f),d.key!==void 0&&(p=""+d.key),"key"in d){f={};for(var m in d)m!=="key"&&(f[m]=d[m])}else f=d;return d=f.ref,{$$typeof:r,type:o,key:p,ref:d!==void 0?d:null,props:f}}return Mr.Fragment=a,Mr.jsx=i,Mr.jsxs=i,Mr}var Bm;function Gy(){return Bm||(Bm=1,vu.exports=Ky()),vu.exports}var u=Gy(),x=Mp();const dl=_p(x);var xu={exports:{}},_r={},Su={exports:{}},wu={};/**
10
+ * @license React
11
+ * scheduler.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Hm;function qy(){return Hm||(Hm=1,(function(r){function a(D,F){var J=D.length;D.push(F);e:for(;0<J;){var q=J-1>>>1,V=D[q];if(0<d(V,F))D[q]=F,D[J]=V,J=q;else break e}}function i(D){return D.length===0?null:D[0]}function o(D){if(D.length===0)return null;var F=D[0],J=D.pop();if(J!==F){D[0]=J;e:for(var q=0,V=D.length,je=V>>>1;q<je;){var pe=2*(q+1)-1,ke=D[pe],Ye=pe+1,Ke=D[Ye];if(0>d(ke,J))Ye<V&&0>d(Ke,ke)?(D[q]=Ke,D[Ye]=J,q=Ye):(D[q]=ke,D[pe]=J,q=pe);else if(Ye<V&&0>d(Ke,J))D[q]=Ke,D[Ye]=J,q=Ye;else break e}}return F}function d(D,F){var J=D.sortIndex-F.sortIndex;return J!==0?J:D.id-F.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;r.unstable_now=function(){return f.now()}}else{var p=Date,m=p.now();r.unstable_now=function(){return p.now()-m}}var b=[],v=[],y=1,S=null,A=3,E=!1,R=!1,H=!1,z=!1,G=typeof setTimeout=="function"?setTimeout:null,Q=typeof clearTimeout=="function"?clearTimeout:null,X=typeof setImmediate<"u"?setImmediate:null;function re(D){for(var F=i(v);F!==null;){if(F.callback===null)o(v);else if(F.startTime<=D)o(v),F.sortIndex=F.expirationTime,a(b,F);else break;F=i(v)}}function de(D){if(H=!1,re(D),!R)if(i(b)!==null)R=!0,ee||(ee=!0,Se());else{var F=i(v);F!==null&&Ge(de,F.startTime-D)}}var ee=!1,T=-1,_=5,P=-1;function le(){return z?!0:!(r.unstable_now()-P<_)}function ve(){if(z=!1,ee){var D=r.unstable_now();P=D;var F=!0;try{e:{R=!1,H&&(H=!1,Q(T),T=-1),E=!0;var J=A;try{t:{for(re(D),S=i(b);S!==null&&!(S.expirationTime>D&&le());){var q=S.callback;if(typeof q=="function"){S.callback=null,A=S.priorityLevel;var V=q(S.expirationTime<=D);if(D=r.unstable_now(),typeof V=="function"){S.callback=V,re(D),F=!0;break t}S===i(b)&&o(b),re(D)}else o(b);S=i(b)}if(S!==null)F=!0;else{var je=i(v);je!==null&&Ge(de,je.startTime-D),F=!1}}break e}finally{S=null,A=J,E=!1}F=void 0}}finally{F?Se():ee=!1}}}var Se;if(typeof X=="function")Se=function(){X(ve)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,Re=fe.port2;fe.port1.onmessage=ve,Se=function(){Re.postMessage(null)}}else Se=function(){G(ve,0)};function Ge(D,F){T=G(function(){D(r.unstable_now())},F)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(D){D.callback=null},r.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<D?Math.floor(1e3/D):5},r.unstable_getCurrentPriorityLevel=function(){return A},r.unstable_next=function(D){switch(A){case 1:case 2:case 3:var F=3;break;default:F=A}var J=A;A=F;try{return D()}finally{A=J}},r.unstable_requestPaint=function(){z=!0},r.unstable_runWithPriority=function(D,F){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var J=A;A=D;try{return F()}finally{A=J}},r.unstable_scheduleCallback=function(D,F,J){var q=r.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?q+J:q):J=q,D){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=J+V,D={id:y++,callback:F,priorityLevel:D,startTime:J,expirationTime:V,sortIndex:-1},J>q?(D.sortIndex=J,a(v,D),i(b)===null&&D===i(v)&&(H?(Q(T),T=-1):H=!0,Ge(de,J-q))):(D.sortIndex=V,a(b,D),R||E||(R=!0,ee||(ee=!0,Se()))),D},r.unstable_shouldYield=le,r.unstable_wrapCallback=function(D){var F=A;return function(){var J=A;A=F;try{return D.apply(this,arguments)}finally{A=J}}}})(wu)),wu}var Ym;function Vy(){return Ym||(Ym=1,Su.exports=qy()),Su.exports}/**
18
+ * @license React
19
+ * react-dom-client.production.js
20
+ *
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Km;function Fy(){if(Km)return _r;Km=1;var r=Vy(),a=Mp(),i=zp();function o(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function 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 m(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 b(e){if(f(e)!==e)throw Error(o(188))}function v(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(o(188));return t!==e?null:e}for(var n=e,l=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(l=s.return,l!==null){n=l;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return b(s),e;if(c===l)return b(s),t;c=c.sibling}throw Error(o(188))}if(n.return!==l.return)n=s,l=c;else{for(var h=!1,g=s.child;g;){if(g===n){h=!0,n=s,l=c;break}if(g===l){h=!0,l=s,n=c;break}g=g.sibling}if(!h){for(g=c.child;g;){if(g===n){h=!0,n=c,l=s;break}if(g===l){h=!0,l=c,n=s;break}g=g.sibling}if(!h)throw Error(o(189))}}if(n.alternate!==l)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function y(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=y(e),t!==null)return t;e=e.sibling}return null}var S=Object.assign,A=Symbol.for("react.element"),E=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),X=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),le=Symbol.for("react.memo_cache_sentinel"),ve=Symbol.iterator;function Se(e){return e===null||typeof e!="object"?null:(e=ve&&e[ve]||e["@@iterator"],typeof e=="function"?e:null)}var fe=Symbol.for("react.client.reference");function Re(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case G:return"Profiler";case z:return"StrictMode";case de:return"Suspense";case ee:return"SuspenseList";case P:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case R:return"Portal";case X:return e.displayName||"Context";case Q:return(e._context.displayName||"Context")+".Consumer";case re:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case T:return t=e.displayName||null,t!==null?t:Re(e.type)||"Memo";case _:t=e._payload,e=e._init;try{return Re(e(t))}catch{}}return null}var Ge=Array.isArray,D=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},q=[],V=-1;function je(e){return{current:e}}function pe(e){0>V||(e.current=q[V],q[V]=null,V--)}function ke(e,t){V++,q[V]=e.current,e.current=t}var Ye=je(null),Ke=je(null),Qe=je(null),$t=je(null);function tt(e,t){switch(ke(Qe,t),ke(Ke,e),ke(Ye,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?rm(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=rm(t),e=sm(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}pe(Ye),ke(Ye,e)}function we(){pe(Ye),pe(Ke),pe(Qe)}function hn(e){e.memoizedState!==null&&ke($t,e);var t=Ye.current,n=sm(t,e.type);t!==n&&(ke(Ke,e),ke(Ye,n))}function qe(e){Ke.current===e&&(pe(Ye),pe(Ke)),$t.current===e&&(pe($t),Er._currentValue=J)}var Je,We;function wt(e){if(Je===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Je=t&&t[1]||"",We=-1<n.stack.indexOf(`
26
+ at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
27
+ `+Je+e+We}var gt=!1;function qt(e,t){if(!e||gt)return"";gt=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(O){var M=O}Reflect.construct(e,[],K)}else{try{K.call()}catch(O){M=O}e.call(K.prototype)}}else{try{throw Error()}catch(O){M=O}(K=e())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(O){if(O&&M&&typeof O.stack=="string")return[O.stack,M.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var s=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");s&&s.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=l.DetermineComponentFrameRoot(),h=c[0],g=c[1];if(h&&g){var w=h.split(`
28
+ `),k=g.split(`
29
+ `);for(s=l=0;l<w.length&&!w[l].includes("DetermineComponentFrameRoot");)l++;for(;s<k.length&&!k[s].includes("DetermineComponentFrameRoot");)s++;if(l===w.length||s===k.length)for(l=w.length-1,s=k.length-1;1<=l&&0<=s&&w[l]!==k[s];)s--;for(;1<=l&&0<=s;l--,s--)if(w[l]!==k[s]){if(l!==1||s!==1)do if(l--,s--,0>s||w[l]!==k[s]){var B=`
30
+ `+w[l].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),B}while(1<=l&&0<=s);break}}}finally{gt=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?wt(n):""}function Tn(e,t){switch(e.tag){case 26:case 27:case 5:return wt(e.type);case 16:return wt("Lazy");case 13:return e.child!==t&&t!==null?wt("Suspense Fallback"):wt("Suspense");case 19:return wt("SuspenseList");case 0:case 15:return qt(e.type,!1);case 11:return qt(e.type.render,!1);case 1:return qt(e.type,!0);case 31:return wt("Activity");default:return""}}function Nn(e){try{var t="",n=null;do t+=Tn(e,n),n=e,e=e.return;while(e);return t}catch(l){return`
31
+ Error generating stack: `+l.message+`
32
+ `+l.stack}}var Hn=Object.prototype.hasOwnProperty,$n=r.unstable_scheduleCallback,kt=r.unstable_cancelCallback,Pe=r.unstable_shouldYield,Ct=r.unstable_requestPaint,ae=r.unstable_now,Ae=r.unstable_getCurrentPriorityLevel,Le=r.unstable_ImmediatePriority,ot=r.unstable_UserBlockingPriority,sn=r.unstable_NormalPriority,bt=r.unstable_LowPriority,zt=r.unstable_IdlePriority,Yn=r.log,Vt=r.unstable_setDisableYieldValue,Ut=null,yt=null;function nt(e){if(typeof Yn=="function"&&Vt(e),yt&&typeof yt.setStrictMode=="function")try{yt.setStrictMode(Ut,e)}catch{}}var Tt=Math.clz32?Math.clz32:el,ei=Math.log,An=Math.LN2;function el(e){return e>>>=0,e===0?32:31-(ei(e)/An|0)|0}var wl=256,Zt=262144,Cl=4194304;function mn(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 Tl(e,t,n){var l=e.pendingLanes;if(l===0)return 0;var s=0,c=e.suspendedLanes,h=e.pingedLanes;e=e.warmLanes;var g=l&134217727;return g!==0?(l=g&~c,l!==0?s=mn(l):(h&=g,h!==0?s=mn(h):n||(n=g&~e,n!==0&&(s=mn(n))))):(g=l&~c,g!==0?s=mn(g):h!==0?s=mn(h):n||(n=l&~e,n!==0&&(s=mn(n)))),s===0?0:t!==0&&t!==s&&(t&c)===0&&(c=s&-s,n=t&-t,c>=n||c===32&&(n&4194048)!==0)?t:s}function fl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tl(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 En(){var e=Cl;return Cl<<=1,(Cl&62914560)===0&&(Cl=4194304),e}function Kn(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Rn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qi(e,t,n,l,s,c){var h=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var g=e.entanglements,w=e.expirationTimes,k=e.hiddenUpdates;for(n=h&~n;0<n;){var B=31-Tt(n),K=1<<B;g[B]=0,w[B]=-1;var M=k[B];if(M!==null)for(k[B]=null,B=0;B<M.length;B++){var O=M[B];O!==null&&(O.lane&=-536870913)}n&=~K}l!==0&&Il(e,l,0),c!==0&&s===0&&e.tag!==0&&(e.suspendedLanes|=c&~(h&~t))}function Il(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-Tt(t);e.entangledLanes|=t,e.entanglements[l]=e.entanglements[l]|1073741824|n&261930}function nl(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var l=31-Tt(n),s=1<<l;s&t|e[l]&t&&(e[l]|=t),n&=~s}}function ja(e,t){var n=t&-t;return n=(n&42)!==0?1:Zl(n),(n&(e.suspendedLanes|t))!==0?0:n}function Zl(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 hl(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Nl(){var e=F.p;return e!==0?e:(e=window.event,e===void 0?32:km(e.type))}function Ql(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var Gn=Math.random().toString(36).slice(2),Dt="__reactFiber$"+Gn,Qt="__reactProps$"+Gn,L="__reactContainer$"+Gn,U="__reactEvents$"+Gn,ie="__reactListeners$"+Gn,Te="__reactHandles$"+Gn,Ce="__reactResources$"+Gn,Ee="__reactMarker$"+Gn;function Oe(e){delete e[Dt],delete e[Qt],delete e[U],delete e[ie],delete e[Te]}function Bt(e){var t=e[Dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[L]||n[Dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[Dt])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function ft(e){if(e=e[Dt]||e[L]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function jn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function on(e){var t=e[Ce];return t||(t=e[Ce]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function at(e){e[Ee]=!0}var ka=new Set,Vi={};function ml(e,t){Al(e,t),Al(e+"Capture",t)}function Al(e,t){for(Vi[e]=t,e=0;e<t.length;e++)ka.add(t[e])}var I=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]*$"),W={},be={};function he(e){return Hn.call(be,e)?!0:Hn.call(W,e)?!1:I.test(e)?be[e]=!0:(W[e]=!0,!1)}function ze(e,t,n){if(he(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function te(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Nt(e,t,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+l)}}function it(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ft(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function At(e,t,n){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var s=l.get,c=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(h){n=""+h,c.call(this,h)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return n},setValue:function(h){n=""+h},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function kn(e){if(!e._valueTracker){var t=Ft(e)?"checked":"value";e._valueTracker=At(e,t,""+e[t])}}function ll(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),l="";return e&&(l=Ft(e)?e.checked?"true":"false":e.value),e=l,e!==n?(t.setValue(e),!0):!1}function pl(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 Jl=/[\n"\\]/g;function Jt(e){return e.replace(Jl,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Fi(e,t,n,l,s,c,h,g){e.name="",h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.type=h:e.removeAttribute("type"),t!=null?h==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+it(t)):e.value!==""+it(t)&&(e.value=""+it(t)):h!=="submit"&&h!=="reset"||e.removeAttribute("value"),t!=null?Xi(e,h,it(t)):n!=null?Xi(e,h,it(n)):l!=null&&e.removeAttribute("value"),s==null&&c!=null&&(e.defaultChecked=!!c),s!=null&&(e.checked=s&&typeof s!="function"&&typeof s!="symbol"),g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"?e.name=""+it(g):e.removeAttribute("name")}function Ir(e,t,n,l,s,c,h,g){if(c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(e.type=c),t!=null||n!=null){if(!(c!=="submit"&&c!=="reset"||t!=null)){kn(e);return}n=n!=null?""+it(n):"",t=t!=null?""+it(t):n,g||t===e.value||(e.value=t),e.defaultValue=t}l=l??s,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=g?e.checked:!!l,e.defaultChecked=!!l,h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.name=h),kn(e)}function Xi(e,t,n){t==="number"&&pl(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Wl(e,t,n,l){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&l&&(e[n].defaultSelected=!0)}else{for(n=""+it(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,l&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Zr(e,t,n){if(t!=null&&(t=""+it(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+it(n):""}function Qr(e,t,n,l){if(t==null){if(l!=null){if(n!=null)throw Error(o(92));if(Ge(l)){if(1<l.length)throw Error(o(93));l=l[0]}n=l}n==null&&(n=""),t=n}n=it(t),e.defaultValue=n,l=e.textContent,l===n&&l!==""&&l!==null&&(e.value=l),kn(e)}function Pl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pn=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 Jr(e,t,n){var l=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?l?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":l?e.setProperty(t,n):typeof n!="number"||n===0||pn.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Wr(e,t,n){if(t!=null&&typeof t!="object")throw Error(o(62));if(e=e.style,n!=null){for(var l in n)!n.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var s in t)l=t[s],t.hasOwnProperty(s)&&n[s]!==l&&Jr(e,s,l)}else for(var c in t)t.hasOwnProperty(c)&&Jr(e,c,t[c])}function El(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 al=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"]]),Pr=/^[\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 Ma(e){return Pr.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function gn(){}var $l=null;function ea(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rl=null,jl=null;function Z(e){var t=ft(e);if(t&&(e=t.stateNode)){var n=e[Qt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Fi(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Jt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var l=n[t];if(l!==e&&l.form===e.form){var s=l[Qt]||null;if(!s)throw Error(o(90));Fi(l,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name)}}for(t=0;t<n.length;t++)l=n[t],l.form===e.form&&ll(l)}break e;case"textarea":Zr(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Wl(e,!!n.multiple,t,!1)}}}var ne=!1;function Me(e,t,n){if(ne)return e(t,n);ne=!0;try{var l=e(t);return l}finally{if(ne=!1,(Rl!==null||jl!==null)&&(Os(),Rl&&(t=Rl,e=jl,jl=Rl=null,Z(t),e)))for(t=0;t<e.length;t++)Z(e[t])}}function ht(e,t){var n=e.stateNode;if(n===null)return null;var l=n[Qt]||null;if(l===null)return null;n=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(o(231,t,typeof n));return n}var Et=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cn=!1;if(Et)try{var ye={};Object.defineProperty(ye,"passive",{get:function(){cn=!0}}),window.addEventListener("test",ye,ye),window.removeEventListener("test",ye,ye)}catch{cn=!1}var Rt=null,mt=null,Wt=null;function Mn(){if(Wt)return Wt;var e,t=mt,n=t.length,l,s="value"in Rt?Rt.value:Rt.textContent,c=s.length;for(e=0;e<n&&t[e]===s[e];e++);var h=n-e;for(l=1;l<=h&&t[n-l]===s[c-l];l++);return Wt=s.slice(e,1<l?1-l:void 0)}function un(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 dn(){return!0}function ta(){return!1}function en(e){function t(n,l,s,c,h){this._reactName=n,this._targetInst=s,this.type=l,this.nativeEvent=c,this.target=h,this.currentTarget=null;for(var g in e)e.hasOwnProperty(g)&&(n=e[g],this[g]=n?n(c):c[g]);return this.isDefaultPrevented=(c.defaultPrevented!=null?c.defaultPrevented:c.returnValue===!1)?dn:ta,this.isPropagationStopped=ta,this}return S(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=dn)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=dn)},persist:function(){},isPersistent:dn}),t}var gl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_a=en(gl),na=S({},gl,{view:0,detail:0}),$r=en(na),ti,ni,Ii,es=S({},na,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:To,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!==Ii&&(Ii&&e.type==="mousemove"?(ti=e.screenX-Ii.screenX,ni=e.screenY-Ii.screenY):ni=ti=0,Ii=e),ti)},movementY:function(e){return"movementY"in e?e.movementY:ni}}),od=en(es),Lg=S({},es,{dataTransfer:0}),Og=en(Lg),Ug=S({},na,{relatedTarget:0}),Co=en(Ug),Bg=S({},gl,{animationName:0,elapsedTime:0,pseudoElement:0}),Hg=en(Bg),Yg=S({},gl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Kg=en(Yg),Gg=S({},gl,{data:0}),cd=en(Gg),qg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Vg={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"},Fg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Xg(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Fg[e])?!!t[e]:!1}function To(){return Xg}var Ig=S({},na,{key:function(e){if(e.key){var t=qg[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=un(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Vg[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:To,charCode:function(e){return e.type==="keypress"?un(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?un(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Zg=en(Ig),Qg=S({},es,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ud=en(Qg),Jg=S({},na,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:To}),Wg=en(Jg),Pg=S({},gl,{propertyName:0,elapsedTime:0,pseudoElement:0}),$g=en(Pg),eb=S({},es,{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}),tb=en(eb),nb=S({},gl,{newState:0,oldState:0}),lb=en(nb),ab=[9,13,27,32],No=Et&&"CompositionEvent"in window,Zi=null;Et&&"documentMode"in document&&(Zi=document.documentMode);var ib=Et&&"TextEvent"in window&&!Zi,dd=Et&&(!No||Zi&&8<Zi&&11>=Zi),fd=" ",hd=!1;function md(e,t){switch(e){case"keyup":return ab.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var li=!1;function rb(e,t){switch(e){case"compositionend":return pd(t);case"keypress":return t.which!==32?null:(hd=!0,fd);case"textInput":return e=t.data,e===fd&&hd?null:e;default:return null}}function sb(e,t){if(li)return e==="compositionend"||!No&&md(e,t)?(e=Mn(),Wt=mt=Rt=null,li=!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 dd&&t.locale!=="ko"?null:t.data;default:return null}}var ob={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 gd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!ob[e.type]:t==="textarea"}function bd(e,t,n,l){Rl?jl?jl.push(l):jl=[l]:Rl=l,t=qs(t,"onChange"),0<t.length&&(n=new _a("onChange","change",null,n,l),e.push({event:n,listeners:t}))}var Qi=null,Ji=null;function cb(e){em(e,0)}function ts(e){var t=jn(e);if(ll(t))return e}function yd(e,t){if(e==="change")return t}var vd=!1;if(Et){var Ao;if(Et){var Eo="oninput"in document;if(!Eo){var xd=document.createElement("div");xd.setAttribute("oninput","return;"),Eo=typeof xd.oninput=="function"}Ao=Eo}else Ao=!1;vd=Ao&&(!document.documentMode||9<document.documentMode)}function Sd(){Qi&&(Qi.detachEvent("onpropertychange",wd),Ji=Qi=null)}function wd(e){if(e.propertyName==="value"&&ts(Ji)){var t=[];bd(t,Ji,e,ea(e)),Me(cb,t)}}function ub(e,t,n){e==="focusin"?(Sd(),Qi=t,Ji=n,Qi.attachEvent("onpropertychange",wd)):e==="focusout"&&Sd()}function db(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ts(Ji)}function fb(e,t){if(e==="click")return ts(t)}function hb(e,t){if(e==="input"||e==="change")return ts(t)}function mb(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var _n=typeof Object.is=="function"?Object.is:mb;function Wi(e,t){if(_n(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),l=Object.keys(t);if(n.length!==l.length)return!1;for(l=0;l<n.length;l++){var s=n[l];if(!Hn.call(t,s)||!_n(e[s],t[s]))return!1}return!0}function Cd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Td(e,t){var n=Cd(e);e=0;for(var l;n;){if(n.nodeType===3){if(l=e+n.textContent.length,e<=t&&l>=t)return{node:n,offset:t-e};e=l}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Cd(n)}}function Nd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ad(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=pl(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=pl(e.document)}return t}function Ro(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 pb=Et&&"documentMode"in document&&11>=document.documentMode,ai=null,jo=null,Pi=null,ko=!1;function Ed(e,t,n){var l=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ko||ai==null||ai!==pl(l)||(l=ai,"selectionStart"in l&&Ro(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Pi&&Wi(Pi,l)||(Pi=l,l=qs(jo,"onSelect"),0<l.length&&(t=new _a("onSelect","select",null,t,n),e.push({event:t,listeners:l}),t.target=ai)))}function za(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ii={animationend:za("Animation","AnimationEnd"),animationiteration:za("Animation","AnimationIteration"),animationstart:za("Animation","AnimationStart"),transitionrun:za("Transition","TransitionRun"),transitionstart:za("Transition","TransitionStart"),transitioncancel:za("Transition","TransitionCancel"),transitionend:za("Transition","TransitionEnd")},Mo={},Rd={};Et&&(Rd=document.createElement("div").style,"AnimationEvent"in window||(delete ii.animationend.animation,delete ii.animationiteration.animation,delete ii.animationstart.animation),"TransitionEvent"in window||delete ii.transitionend.transition);function Da(e){if(Mo[e])return Mo[e];if(!ii[e])return e;var t=ii[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Rd)return Mo[e]=t[n];return e}var jd=Da("animationend"),kd=Da("animationiteration"),Md=Da("animationstart"),gb=Da("transitionrun"),bb=Da("transitionstart"),yb=Da("transitioncancel"),_d=Da("transitionend"),zd=new Map,_o="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(" ");_o.push("scrollEnd");function il(e,t){zd.set(e,t),ml(t,[e])}var ns=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)},qn=[],ri=0,zo=0;function ls(){for(var e=ri,t=zo=ri=0;t<e;){var n=qn[t];qn[t++]=null;var l=qn[t];qn[t++]=null;var s=qn[t];qn[t++]=null;var c=qn[t];if(qn[t++]=null,l!==null&&s!==null){var h=l.pending;h===null?s.next=s:(s.next=h.next,h.next=s),l.pending=s}c!==0&&Dd(n,s,c)}}function as(e,t,n,l){qn[ri++]=e,qn[ri++]=t,qn[ri++]=n,qn[ri++]=l,zo|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function Do(e,t,n,l){return as(e,t,n,l),is(e)}function La(e,t){return as(e,null,null,t),is(e)}function Dd(e,t,n){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n);for(var s=!1,c=e.return;c!==null;)c.childLanes|=n,l=c.alternate,l!==null&&(l.childLanes|=n),c.tag===22&&(e=c.stateNode,e===null||e._visibility&1||(s=!0)),e=c,c=c.return;return e.tag===3?(c=e.stateNode,s&&t!==null&&(s=31-Tt(n),e=c.hiddenUpdates,l=e[s],l===null?e[s]=[t]:l.push(t),t.lane=n|536870912),c):null}function is(e){if(50<xr)throw xr=0,qc=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var si={};function vb(e,t,n,l){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(e,t,n,l){return new vb(e,t,n,l)}function Lo(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kl(e,t){var n=e.alternate;return n===null?(n=zn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Ld(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function rs(e,t,n,l,s,c){var h=0;if(l=e,typeof e=="function")Lo(e)&&(h=1);else if(typeof e=="string")h=Ty(e,n,Ye.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case P:return e=zn(31,n,t,s),e.elementType=P,e.lanes=c,e;case H:return Oa(n.children,s,c,t);case z:h=8,s|=24;break;case G:return e=zn(12,n,t,s|2),e.elementType=G,e.lanes=c,e;case de:return e=zn(13,n,t,s),e.elementType=de,e.lanes=c,e;case ee:return e=zn(19,n,t,s),e.elementType=ee,e.lanes=c,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case X:h=10;break e;case Q:h=9;break e;case re:h=11;break e;case T:h=14;break e;case _:h=16,l=null;break e}h=29,n=Error(o(130,e===null?"null":typeof e,"")),l=null}return t=zn(h,n,t,s),t.elementType=e,t.type=l,t.lanes=c,t}function Oa(e,t,n,l){return e=zn(7,e,l,t),e.lanes=n,e}function Oo(e,t,n){return e=zn(6,e,null,t),e.lanes=n,e}function Od(e){var t=zn(18,null,null,0);return t.stateNode=e,t}function Uo(e,t,n){return t=zn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ud=new WeakMap;function Vn(e,t){if(typeof e=="object"&&e!==null){var n=Ud.get(e);return n!==void 0?n:(t={value:e,source:t,stack:Nn(t)},Ud.set(e,t),t)}return{value:e,source:t,stack:Nn(t)}}var oi=[],ci=0,ss=null,$i=0,Fn=[],Xn=0,la=null,bl=1,yl="";function Ml(e,t){oi[ci++]=$i,oi[ci++]=ss,ss=e,$i=t}function Bd(e,t,n){Fn[Xn++]=bl,Fn[Xn++]=yl,Fn[Xn++]=la,la=e;var l=bl;e=yl;var s=32-Tt(l)-1;l&=~(1<<s),n+=1;var c=32-Tt(t)+s;if(30<c){var h=s-s%5;c=(l&(1<<h)-1).toString(32),l>>=h,s-=h,bl=1<<32-Tt(t)+s|n<<s|l,yl=c+e}else bl=1<<c|n<<s|l,yl=e}function Bo(e){e.return!==null&&(Ml(e,1),Bd(e,1,0))}function Ho(e){for(;e===ss;)ss=oi[--ci],oi[ci]=null,$i=oi[--ci],oi[ci]=null;for(;e===la;)la=Fn[--Xn],Fn[Xn]=null,yl=Fn[--Xn],Fn[Xn]=null,bl=Fn[--Xn],Fn[Xn]=null}function Hd(e,t){Fn[Xn++]=bl,Fn[Xn++]=yl,Fn[Xn++]=la,bl=t.id,yl=t.overflow,la=e}var tn=null,vt=null,Ze=!1,aa=null,In=!1,Yo=Error(o(519));function ia(e){var t=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw er(Vn(t,e)),Yo}function Yd(e){var t=e.stateNode,n=e.type,l=e.memoizedProps;switch(t[Dt]=e,t[Qt]=l,n){case"dialog":Fe("cancel",t),Fe("close",t);break;case"iframe":case"object":case"embed":Fe("load",t);break;case"video":case"audio":for(n=0;n<wr.length;n++)Fe(wr[n],t);break;case"source":Fe("error",t);break;case"img":case"image":case"link":Fe("error",t),Fe("load",t);break;case"details":Fe("toggle",t);break;case"input":Fe("invalid",t),Ir(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Fe("invalid",t);break;case"textarea":Fe("invalid",t),Qr(t,l.value,l.defaultValue,l.children)}n=l.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||l.suppressHydrationWarning===!0||am(t.textContent,n)?(l.popover!=null&&(Fe("beforetoggle",t),Fe("toggle",t)),l.onScroll!=null&&Fe("scroll",t),l.onScrollEnd!=null&&Fe("scrollend",t),l.onClick!=null&&(t.onclick=gn),t=!0):t=!1,t||ia(e,!0)}function Kd(e){for(tn=e.return;tn;)switch(tn.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:tn=tn.return}}function ui(e){if(e!==tn)return!1;if(!Ze)return Kd(e),Ze=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||au(e.type,e.memoizedProps)),n=!n),n&&vt&&ia(e),Kd(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=hm(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=hm(e)}else t===27?(t=vt,va(e.type)?(e=cu,cu=null,vt=e):vt=t):vt=tn?Qn(e.stateNode.nextSibling):null;return!0}function Ua(){vt=tn=null,Ze=!1}function Ko(){var e=aa;return e!==null&&(xn===null?xn=e:xn.push.apply(xn,e),aa=null),e}function er(e){aa===null?aa=[e]:aa.push(e)}var Go=je(null),Ba=null,_l=null;function ra(e,t,n){ke(Go,t._currentValue),t._currentValue=n}function zl(e){e._currentValue=Go.current,pe(Go)}function qo(e,t,n){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===n)break;e=e.return}}function Vo(e,t,n,l){var s=e.child;for(s!==null&&(s.return=e);s!==null;){var c=s.dependencies;if(c!==null){var h=s.child;c=c.firstContext;e:for(;c!==null;){var g=c;c=s;for(var w=0;w<t.length;w++)if(g.context===t[w]){c.lanes|=n,g=c.alternate,g!==null&&(g.lanes|=n),qo(c.return,n,e),l||(h=null);break e}c=g.next}}else if(s.tag===18){if(h=s.return,h===null)throw Error(o(341));h.lanes|=n,c=h.alternate,c!==null&&(c.lanes|=n),qo(h,n,e),h=null}else h=s.child;if(h!==null)h.return=s;else for(h=s;h!==null;){if(h===e){h=null;break}if(s=h.sibling,s!==null){s.return=h.return,h=s;break}h=h.return}s=h}}function di(e,t,n,l){e=null;for(var s=t,c=!1;s!==null;){if(!c){if((s.flags&524288)!==0)c=!0;else if((s.flags&262144)!==0)break}if(s.tag===10){var h=s.alternate;if(h===null)throw Error(o(387));if(h=h.memoizedProps,h!==null){var g=s.type;_n(s.pendingProps.value,h.value)||(e!==null?e.push(g):e=[g])}}else if(s===$t.current){if(h=s.alternate,h===null)throw Error(o(387));h.memoizedState.memoizedState!==s.memoizedState.memoizedState&&(e!==null?e.push(Er):e=[Er])}s=s.return}e!==null&&Vo(t,e,n,l),t.flags|=262144}function os(e){for(e=e.firstContext;e!==null;){if(!_n(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ha(e){Ba=e,_l=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function nn(e){return Gd(Ba,e)}function cs(e,t){return Ba===null&&Ha(e),Gd(e,t)}function Gd(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},_l===null){if(e===null)throw Error(o(308));_l=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else _l=_l.next=t;return n}var xb=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},Sb=r.unstable_scheduleCallback,wb=r.unstable_NormalPriority,Ht={$$typeof:X,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Fo(){return{controller:new xb,data:new Map,refCount:0}}function tr(e){e.refCount--,e.refCount===0&&Sb(wb,function(){e.controller.abort()})}var nr=null,Xo=0,fi=0,hi=null;function Cb(e,t){if(nr===null){var n=nr=[];Xo=0,fi=Qc(),hi={status:"pending",value:void 0,then:function(l){n.push(l)}}}return Xo++,t.then(qd,qd),t}function qd(){if(--Xo===0&&nr!==null){hi!==null&&(hi.status="fulfilled");var e=nr;nr=null,fi=0,hi=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Tb(e,t){var n=[],l={status:"pending",value:null,reason:null,then:function(s){n.push(s)}};return e.then(function(){l.status="fulfilled",l.value=t;for(var s=0;s<n.length;s++)(0,n[s])(t)},function(s){for(l.status="rejected",l.reason=s,s=0;s<n.length;s++)(0,n[s])(void 0)}),l}var Vd=D.S;D.S=function(e,t){Rh=ae(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Cb(e,t),Vd!==null&&Vd(e,t)};var Ya=je(null);function Io(){var e=Ya.current;return e!==null?e:pt.pooledCache}function us(e,t){t===null?ke(Ya,Ya.current):ke(Ya,t.pool)}function Fd(){var e=Io();return e===null?null:{parent:Ht._currentValue,pool:e}}var mi=Error(o(460)),Zo=Error(o(474)),ds=Error(o(542)),fs={then:function(){}};function Xd(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Id(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(gn,gn),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Qd(e),e;default:if(typeof t.status=="string")t.then(gn,gn);else{if(e=pt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status="pending",e.then(function(l){if(t.status==="pending"){var s=t;s.status="fulfilled",s.value=l}},function(l){if(t.status==="pending"){var s=t;s.status="rejected",s.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Qd(e),e}throw Ga=t,mi}}function Ka(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Ga=n,mi):n}}var Ga=null;function Zd(){if(Ga===null)throw Error(o(459));var e=Ga;return Ga=null,e}function Qd(e){if(e===mi||e===ds)throw Error(o(483))}var pi=null,lr=0;function hs(e){var t=lr;return lr+=1,pi===null&&(pi=[]),Id(pi,e,t)}function ar(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function ms(e,t){throw t.$$typeof===A?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Jd(e){function t(N,C){if(e){var j=N.deletions;j===null?(N.deletions=[C],N.flags|=16):j.push(C)}}function n(N,C){if(!e)return null;for(;C!==null;)t(N,C),C=C.sibling;return null}function l(N){for(var C=new Map;N!==null;)N.key!==null?C.set(N.key,N):C.set(N.index,N),N=N.sibling;return C}function s(N,C){return N=kl(N,C),N.index=0,N.sibling=null,N}function c(N,C,j){return N.index=j,e?(j=N.alternate,j!==null?(j=j.index,j<C?(N.flags|=67108866,C):j):(N.flags|=67108866,C)):(N.flags|=1048576,C)}function h(N){return e&&N.alternate===null&&(N.flags|=67108866),N}function g(N,C,j,Y){return C===null||C.tag!==6?(C=Oo(j,N.mode,Y),C.return=N,C):(C=s(C,j),C.return=N,C)}function w(N,C,j,Y){var xe=j.type;return xe===H?B(N,C,j.props.children,Y,j.key):C!==null&&(C.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===_&&Ka(xe)===C.type)?(C=s(C,j.props),ar(C,j),C.return=N,C):(C=rs(j.type,j.key,j.props,null,N.mode,Y),ar(C,j),C.return=N,C)}function k(N,C,j,Y){return C===null||C.tag!==4||C.stateNode.containerInfo!==j.containerInfo||C.stateNode.implementation!==j.implementation?(C=Uo(j,N.mode,Y),C.return=N,C):(C=s(C,j.children||[]),C.return=N,C)}function B(N,C,j,Y,xe){return C===null||C.tag!==7?(C=Oa(j,N.mode,Y,xe),C.return=N,C):(C=s(C,j),C.return=N,C)}function K(N,C,j){if(typeof C=="string"&&C!==""||typeof C=="number"||typeof C=="bigint")return C=Oo(""+C,N.mode,j),C.return=N,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case E:return j=rs(C.type,C.key,C.props,null,N.mode,j),ar(j,C),j.return=N,j;case R:return C=Uo(C,N.mode,j),C.return=N,C;case _:return C=Ka(C),K(N,C,j)}if(Ge(C)||Se(C))return C=Oa(C,N.mode,j,null),C.return=N,C;if(typeof C.then=="function")return K(N,hs(C),j);if(C.$$typeof===X)return K(N,cs(N,C),j);ms(N,C)}return null}function M(N,C,j,Y){var xe=C!==null?C.key:null;if(typeof j=="string"&&j!==""||typeof j=="number"||typeof j=="bigint")return xe!==null?null:g(N,C,""+j,Y);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case E:return j.key===xe?w(N,C,j,Y):null;case R:return j.key===xe?k(N,C,j,Y):null;case _:return j=Ka(j),M(N,C,j,Y)}if(Ge(j)||Se(j))return xe!==null?null:B(N,C,j,Y,null);if(typeof j.then=="function")return M(N,C,hs(j),Y);if(j.$$typeof===X)return M(N,C,cs(N,j),Y);ms(N,j)}return null}function O(N,C,j,Y,xe){if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return N=N.get(j)||null,g(C,N,""+Y,xe);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case E:return N=N.get(Y.key===null?j:Y.key)||null,w(C,N,Y,xe);case R:return N=N.get(Y.key===null?j:Y.key)||null,k(C,N,Y,xe);case _:return Y=Ka(Y),O(N,C,j,Y,xe)}if(Ge(Y)||Se(Y))return N=N.get(j)||null,B(C,N,Y,xe,null);if(typeof Y.then=="function")return O(N,C,j,hs(Y),xe);if(Y.$$typeof===X)return O(N,C,j,cs(C,Y),xe);ms(C,Y)}return null}function ue(N,C,j,Y){for(var xe=null,$e=null,me=C,De=C=0,Ie=null;me!==null&&De<j.length;De++){me.index>De?(Ie=me,me=null):Ie=me.sibling;var et=M(N,me,j[De],Y);if(et===null){me===null&&(me=Ie);break}e&&me&&et.alternate===null&&t(N,me),C=c(et,C,De),$e===null?xe=et:$e.sibling=et,$e=et,me=Ie}if(De===j.length)return n(N,me),Ze&&Ml(N,De),xe;if(me===null){for(;De<j.length;De++)me=K(N,j[De],Y),me!==null&&(C=c(me,C,De),$e===null?xe=me:$e.sibling=me,$e=me);return Ze&&Ml(N,De),xe}for(me=l(me);De<j.length;De++)Ie=O(me,N,De,j[De],Y),Ie!==null&&(e&&Ie.alternate!==null&&me.delete(Ie.key===null?De:Ie.key),C=c(Ie,C,De),$e===null?xe=Ie:$e.sibling=Ie,$e=Ie);return e&&me.forEach(function(Ta){return t(N,Ta)}),Ze&&Ml(N,De),xe}function Ne(N,C,j,Y){if(j==null)throw Error(o(151));for(var xe=null,$e=null,me=C,De=C=0,Ie=null,et=j.next();me!==null&&!et.done;De++,et=j.next()){me.index>De?(Ie=me,me=null):Ie=me.sibling;var Ta=M(N,me,et.value,Y);if(Ta===null){me===null&&(me=Ie);break}e&&me&&Ta.alternate===null&&t(N,me),C=c(Ta,C,De),$e===null?xe=Ta:$e.sibling=Ta,$e=Ta,me=Ie}if(et.done)return n(N,me),Ze&&Ml(N,De),xe;if(me===null){for(;!et.done;De++,et=j.next())et=K(N,et.value,Y),et!==null&&(C=c(et,C,De),$e===null?xe=et:$e.sibling=et,$e=et);return Ze&&Ml(N,De),xe}for(me=l(me);!et.done;De++,et=j.next())et=O(me,N,De,et.value,Y),et!==null&&(e&&et.alternate!==null&&me.delete(et.key===null?De:et.key),C=c(et,C,De),$e===null?xe=et:$e.sibling=et,$e=et);return e&&me.forEach(function(Ly){return t(N,Ly)}),Ze&&Ml(N,De),xe}function dt(N,C,j,Y){if(typeof j=="object"&&j!==null&&j.type===H&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case E:e:{for(var xe=j.key;C!==null;){if(C.key===xe){if(xe=j.type,xe===H){if(C.tag===7){n(N,C.sibling),Y=s(C,j.props.children),Y.return=N,N=Y;break e}}else if(C.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===_&&Ka(xe)===C.type){n(N,C.sibling),Y=s(C,j.props),ar(Y,j),Y.return=N,N=Y;break e}n(N,C);break}else t(N,C);C=C.sibling}j.type===H?(Y=Oa(j.props.children,N.mode,Y,j.key),Y.return=N,N=Y):(Y=rs(j.type,j.key,j.props,null,N.mode,Y),ar(Y,j),Y.return=N,N=Y)}return h(N);case R:e:{for(xe=j.key;C!==null;){if(C.key===xe)if(C.tag===4&&C.stateNode.containerInfo===j.containerInfo&&C.stateNode.implementation===j.implementation){n(N,C.sibling),Y=s(C,j.children||[]),Y.return=N,N=Y;break e}else{n(N,C);break}else t(N,C);C=C.sibling}Y=Uo(j,N.mode,Y),Y.return=N,N=Y}return h(N);case _:return j=Ka(j),dt(N,C,j,Y)}if(Ge(j))return ue(N,C,j,Y);if(Se(j)){if(xe=Se(j),typeof xe!="function")throw Error(o(150));return j=xe.call(j),Ne(N,C,j,Y)}if(typeof j.then=="function")return dt(N,C,hs(j),Y);if(j.$$typeof===X)return dt(N,C,cs(N,j),Y);ms(N,j)}return typeof j=="string"&&j!==""||typeof j=="number"||typeof j=="bigint"?(j=""+j,C!==null&&C.tag===6?(n(N,C.sibling),Y=s(C,j),Y.return=N,N=Y):(n(N,C),Y=Oo(j,N.mode,Y),Y.return=N,N=Y),h(N)):n(N,C)}return function(N,C,j,Y){try{lr=0;var xe=dt(N,C,j,Y);return pi=null,xe}catch(me){if(me===mi||me===ds)throw me;var $e=zn(29,me,null,N.mode);return $e.lanes=Y,$e.return=N,$e}finally{}}}var qa=Jd(!0),Wd=Jd(!1),sa=!1;function Qo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Jo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function oa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ca(e,t,n){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(lt&2)!==0){var s=l.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),l.pending=t,t=is(e),Dd(e,null,n),t}return as(e,l,t,n),is(e)}function ir(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var l=t.lanes;l&=e.pendingLanes,n|=l,t.lanes=n,nl(e,n)}}function Wo(e,t){var n=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,n===l)){var s=null,c=null;if(n=n.firstBaseUpdate,n!==null){do{var h={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};c===null?s=c=h:c=c.next=h,n=n.next}while(n!==null);c===null?s=c=t:c=c.next=t}else s=c=t;n={baseState:l.baseState,firstBaseUpdate:s,lastBaseUpdate:c,shared:l.shared,callbacks:l.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Po=!1;function rr(){if(Po){var e=hi;if(e!==null)throw e}}function sr(e,t,n,l){Po=!1;var s=e.updateQueue;sa=!1;var c=s.firstBaseUpdate,h=s.lastBaseUpdate,g=s.shared.pending;if(g!==null){s.shared.pending=null;var w=g,k=w.next;w.next=null,h===null?c=k:h.next=k,h=w;var B=e.alternate;B!==null&&(B=B.updateQueue,g=B.lastBaseUpdate,g!==h&&(g===null?B.firstBaseUpdate=k:g.next=k,B.lastBaseUpdate=w))}if(c!==null){var K=s.baseState;h=0,B=k=w=null,g=c;do{var M=g.lane&-536870913,O=M!==g.lane;if(O?(Xe&M)===M:(l&M)===M){M!==0&&M===fi&&(Po=!0),B!==null&&(B=B.next={lane:0,tag:g.tag,payload:g.payload,callback:null,next:null});e:{var ue=e,Ne=g;M=t;var dt=n;switch(Ne.tag){case 1:if(ue=Ne.payload,typeof ue=="function"){K=ue.call(dt,K,M);break e}K=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=Ne.payload,M=typeof ue=="function"?ue.call(dt,K,M):ue,M==null)break e;K=S({},K,M);break e;case 2:sa=!0}}M=g.callback,M!==null&&(e.flags|=64,O&&(e.flags|=8192),O=s.callbacks,O===null?s.callbacks=[M]:O.push(M))}else O={lane:M,tag:g.tag,payload:g.payload,callback:g.callback,next:null},B===null?(k=B=O,w=K):B=B.next=O,h|=M;if(g=g.next,g===null){if(g=s.shared.pending,g===null)break;O=g,g=O.next,O.next=null,s.lastBaseUpdate=O,s.shared.pending=null}}while(!0);B===null&&(w=K),s.baseState=w,s.firstBaseUpdate=k,s.lastBaseUpdate=B,c===null&&(s.shared.lanes=0),ma|=h,e.lanes=h,e.memoizedState=K}}function Pd(e,t){if(typeof e!="function")throw Error(o(191,e));e.call(t)}function $d(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Pd(n[e],t)}var gi=je(null),ps=je(0);function ef(e,t){e=Gl,ke(ps,e),ke(gi,t),Gl=e|t.baseLanes}function $o(){ke(ps,Gl),ke(gi,gi.current)}function ec(){Gl=ps.current,pe(gi),pe(ps)}var Dn=je(null),Zn=null;function ua(e){var t=e.alternate;ke(Lt,Lt.current&1),ke(Dn,e),Zn===null&&(t===null||gi.current!==null||t.memoizedState!==null)&&(Zn=e)}function tc(e){ke(Lt,Lt.current),ke(Dn,e),Zn===null&&(Zn=e)}function tf(e){e.tag===22?(ke(Lt,Lt.current),ke(Dn,e),Zn===null&&(Zn=e)):da()}function da(){ke(Lt,Lt.current),ke(Dn,Dn.current)}function Ln(e){pe(Dn),Zn===e&&(Zn=null),pe(Lt)}var Lt=je(0);function gs(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||su(n)||ou(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Dl=0,_e=null,ct=null,Yt=null,bs=!1,bi=!1,Va=!1,ys=0,or=0,yi=null,Nb=0;function Mt(){throw Error(o(321))}function nc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!_n(e[n],t[n]))return!1;return!0}function lc(e,t,n,l,s,c){return Dl=c,_e=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,D.H=e===null||e.memoizedState===null?Hf:yc,Va=!1,c=n(l,s),Va=!1,bi&&(c=lf(t,n,l,s)),nf(e),c}function nf(e){D.H=dr;var t=ct!==null&&ct.next!==null;if(Dl=0,Yt=ct=_e=null,bs=!1,or=0,yi=null,t)throw Error(o(300));e===null||Kt||(e=e.dependencies,e!==null&&os(e)&&(Kt=!0))}function lf(e,t,n,l){_e=e;var s=0;do{if(bi&&(yi=null),or=0,bi=!1,25<=s)throw Error(o(301));if(s+=1,Yt=ct=null,e.updateQueue!=null){var c=e.updateQueue;c.lastEffect=null,c.events=null,c.stores=null,c.memoCache!=null&&(c.memoCache.index=0)}D.H=Yf,c=t(n,l)}while(bi);return c}function Ab(){var e=D.H,t=e.useState()[0];return t=typeof t.then=="function"?cr(t):t,e=e.useState()[0],(ct!==null?ct.memoizedState:null)!==e&&(_e.flags|=1024),t}function ac(){var e=ys!==0;return ys=0,e}function ic(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function rc(e){if(bs){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}bs=!1}Dl=0,Yt=ct=_e=null,bi=!1,or=ys=0,yi=null}function fn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?_e.memoizedState=Yt=e:Yt=Yt.next=e,Yt}function Ot(){if(ct===null){var e=_e.alternate;e=e!==null?e.memoizedState:null}else e=ct.next;var t=Yt===null?_e.memoizedState:Yt.next;if(t!==null)Yt=t,ct=e;else{if(e===null)throw _e.alternate===null?Error(o(467)):Error(o(310));ct=e,e={memoizedState:ct.memoizedState,baseState:ct.baseState,baseQueue:ct.baseQueue,queue:ct.queue,next:null},Yt===null?_e.memoizedState=Yt=e:Yt=Yt.next=e}return Yt}function vs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function cr(e){var t=or;return or+=1,yi===null&&(yi=[]),e=Id(yi,e,t),t=_e,(Yt===null?t.memoizedState:Yt.next)===null&&(t=t.alternate,D.H=t===null||t.memoizedState===null?Hf:yc),e}function xs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return cr(e);if(e.$$typeof===X)return nn(e)}throw Error(o(438,String(e)))}function sc(e){var t=null,n=_e.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var l=_e.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(s){return s.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=vs(),_e.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),l=0;l<e;l++)n[l]=le;return t.index++,n}function Ll(e,t){return typeof t=="function"?t(e):t}function Ss(e){var t=Ot();return oc(t,ct,e)}function oc(e,t,n){var l=e.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=n;var s=e.baseQueue,c=l.pending;if(c!==null){if(s!==null){var h=s.next;s.next=c.next,c.next=h}t.baseQueue=s=c,l.pending=null}if(c=e.baseState,s===null)e.memoizedState=c;else{t=s.next;var g=h=null,w=null,k=t,B=!1;do{var K=k.lane&-536870913;if(K!==k.lane?(Xe&K)===K:(Dl&K)===K){var M=k.revertLane;if(M===0)w!==null&&(w=w.next={lane:0,revertLane:0,gesture:null,action:k.action,hasEagerState:k.hasEagerState,eagerState:k.eagerState,next:null}),K===fi&&(B=!0);else if((Dl&M)===M){k=k.next,M===fi&&(B=!0);continue}else K={lane:0,revertLane:k.revertLane,gesture:null,action:k.action,hasEagerState:k.hasEagerState,eagerState:k.eagerState,next:null},w===null?(g=w=K,h=c):w=w.next=K,_e.lanes|=M,ma|=M;K=k.action,Va&&n(c,K),c=k.hasEagerState?k.eagerState:n(c,K)}else M={lane:K,revertLane:k.revertLane,gesture:k.gesture,action:k.action,hasEagerState:k.hasEagerState,eagerState:k.eagerState,next:null},w===null?(g=w=M,h=c):w=w.next=M,_e.lanes|=K,ma|=K;k=k.next}while(k!==null&&k!==t);if(w===null?h=c:w.next=g,!_n(c,e.memoizedState)&&(Kt=!0,B&&(n=hi,n!==null)))throw n;e.memoizedState=c,e.baseState=h,e.baseQueue=w,l.lastRenderedState=c}return s===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function cc(e){var t=Ot(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var l=n.dispatch,s=n.pending,c=t.memoizedState;if(s!==null){n.pending=null;var h=s=s.next;do c=e(c,h.action),h=h.next;while(h!==s);_n(c,t.memoizedState)||(Kt=!0),t.memoizedState=c,t.baseQueue===null&&(t.baseState=c),n.lastRenderedState=c}return[c,l]}function af(e,t,n){var l=_e,s=Ot(),c=Ze;if(c){if(n===void 0)throw Error(o(407));n=n()}else n=t();var h=!_n((ct||s).memoizedState,n);if(h&&(s.memoizedState=n,Kt=!0),s=s.queue,fc(of.bind(null,l,s,e),[e]),s.getSnapshot!==t||h||Yt!==null&&Yt.memoizedState.tag&1){if(l.flags|=2048,vi(9,{destroy:void 0},sf.bind(null,l,s,n,t),null),pt===null)throw Error(o(349));c||(Dl&127)!==0||rf(l,t,n)}return n}function rf(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=_e.updateQueue,t===null?(t=vs(),_e.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function sf(e,t,n,l){t.value=n,t.getSnapshot=l,cf(t)&&uf(e)}function of(e,t,n){return n(function(){cf(t)&&uf(e)})}function cf(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!_n(e,n)}catch{return!0}}function uf(e){var t=La(e,2);t!==null&&Sn(t,e,2)}function uc(e){var t=fn();if(typeof e=="function"){var n=e;if(e=n(),Va){nt(!0);try{n()}finally{nt(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ll,lastRenderedState:e},t}function df(e,t,n,l){return e.baseState=n,oc(e,ct,typeof l=="function"?l:Ll)}function Eb(e,t,n,l,s){if(Ts(e))throw Error(o(485));if(e=t.action,e!==null){var c={payload:s,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(h){c.listeners.push(h)}};D.T!==null?n(!0):c.isTransition=!1,l(c),n=t.pending,n===null?(c.next=t.pending=c,ff(t,c)):(c.next=n.next,t.pending=n.next=c)}}function ff(e,t){var n=t.action,l=t.payload,s=e.state;if(t.isTransition){var c=D.T,h={};D.T=h;try{var g=n(s,l),w=D.S;w!==null&&w(h,g),hf(e,t,g)}catch(k){dc(e,t,k)}finally{c!==null&&h.types!==null&&(c.types=h.types),D.T=c}}else try{c=n(s,l),hf(e,t,c)}catch(k){dc(e,t,k)}}function hf(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(l){mf(e,t,l)},function(l){return dc(e,t,l)}):mf(e,t,n)}function mf(e,t,n){t.status="fulfilled",t.value=n,pf(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,ff(e,n)))}function dc(e,t,n){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=n,pf(t),t=t.next;while(t!==l)}e.action=null}function pf(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function gf(e,t){return t}function bf(e,t){if(Ze){var n=pt.formState;if(n!==null){e:{var l=_e;if(Ze){if(vt){t:{for(var s=vt,c=In;s.nodeType!==8;){if(!c){s=null;break t}if(s=Qn(s.nextSibling),s===null){s=null;break t}}c=s.data,s=c==="F!"||c==="F"?s:null}if(s){vt=Qn(s.nextSibling),l=s.data==="F!";break e}}ia(l)}l=!1}l&&(t=n[0])}}return n=fn(),n.memoizedState=n.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gf,lastRenderedState:t},n.queue=l,n=Of.bind(null,_e,l),l.dispatch=n,l=uc(!1),c=bc.bind(null,_e,!1,l.queue),l=fn(),s={state:t,dispatch:null,action:e,pending:null},l.queue=s,n=Eb.bind(null,_e,s,c,n),s.dispatch=n,l.memoizedState=e,[t,n,!1]}function yf(e){var t=Ot();return vf(t,ct,e)}function vf(e,t,n){if(t=oc(e,t,gf)[0],e=Ss(Ll)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=cr(t)}catch(h){throw h===mi?ds:h}else l=t;t=Ot();var s=t.queue,c=s.dispatch;return n!==t.memoizedState&&(_e.flags|=2048,vi(9,{destroy:void 0},Rb.bind(null,s,n),null)),[l,c,e]}function Rb(e,t){e.action=t}function xf(e){var t=Ot(),n=ct;if(n!==null)return vf(t,n,e);Ot(),t=t.memoizedState,n=Ot();var l=n.queue.dispatch;return n.memoizedState=e,[t,l,!1]}function vi(e,t,n,l){return e={tag:e,create:n,deps:l,inst:t,next:null},t=_e.updateQueue,t===null&&(t=vs(),_e.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(l=n.next,n.next=e,e.next=l,t.lastEffect=e),e}function Sf(){return Ot().memoizedState}function ws(e,t,n,l){var s=fn();_e.flags|=e,s.memoizedState=vi(1|t,{destroy:void 0},n,l===void 0?null:l)}function Cs(e,t,n,l){var s=Ot();l=l===void 0?null:l;var c=s.memoizedState.inst;ct!==null&&l!==null&&nc(l,ct.memoizedState.deps)?s.memoizedState=vi(t,c,n,l):(_e.flags|=e,s.memoizedState=vi(1|t,c,n,l))}function wf(e,t){ws(8390656,8,e,t)}function fc(e,t){Cs(2048,8,e,t)}function jb(e){_e.flags|=4;var t=_e.updateQueue;if(t===null)t=vs(),_e.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Cf(e){var t=Ot().memoizedState;return jb({ref:t,nextImpl:e}),function(){if((lt&2)!==0)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Tf(e,t){return Cs(4,2,e,t)}function Nf(e,t){return Cs(4,4,e,t)}function Af(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ef(e,t,n){n=n!=null?n.concat([e]):null,Cs(4,4,Af.bind(null,t,e),n)}function hc(){}function Rf(e,t){var n=Ot();t=t===void 0?null:t;var l=n.memoizedState;return t!==null&&nc(t,l[1])?l[0]:(n.memoizedState=[e,t],e)}function jf(e,t){var n=Ot();t=t===void 0?null:t;var l=n.memoizedState;if(t!==null&&nc(t,l[1]))return l[0];if(l=e(),Va){nt(!0);try{e()}finally{nt(!1)}}return n.memoizedState=[l,t],l}function mc(e,t,n){return n===void 0||(Dl&1073741824)!==0&&(Xe&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=kh(),_e.lanes|=e,ma|=e,n)}function kf(e,t,n,l){return _n(n,t)?n:gi.current!==null?(e=mc(e,n,l),_n(e,t)||(Kt=!0),e):(Dl&42)===0||(Dl&1073741824)!==0&&(Xe&261930)===0?(Kt=!0,e.memoizedState=n):(e=kh(),_e.lanes|=e,ma|=e,t)}function Mf(e,t,n,l,s){var c=F.p;F.p=c!==0&&8>c?c:8;var h=D.T,g={};D.T=g,bc(e,!1,t,n);try{var w=s(),k=D.S;if(k!==null&&k(g,w),w!==null&&typeof w=="object"&&typeof w.then=="function"){var B=Tb(w,l);ur(e,t,B,Bn(e))}else ur(e,t,l,Bn(e))}catch(K){ur(e,t,{then:function(){},status:"rejected",reason:K},Bn())}finally{F.p=c,h!==null&&g.types!==null&&(h.types=g.types),D.T=h}}function kb(){}function pc(e,t,n,l){if(e.tag!==5)throw Error(o(476));var s=_f(e).queue;Mf(e,s,t,J,n===null?kb:function(){return zf(e),n(l)})}function _f(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ll,lastRenderedState:J},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ll,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function zf(e){var t=_f(e);t.next===null&&(t=e.alternate.memoizedState),ur(e,t.next.queue,{},Bn())}function gc(){return nn(Er)}function Df(){return Ot().memoizedState}function Lf(){return Ot().memoizedState}function Mb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Bn();e=oa(n);var l=ca(t,e,n);l!==null&&(Sn(l,t,n),ir(l,t,n)),t={cache:Fo()},e.payload=t;return}t=t.return}}function _b(e,t,n){var l=Bn();n={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Uf(t,n):(n=Do(e,t,n,l),n!==null&&(Sn(n,e,l),Bf(n,t,l)))}function Of(e,t,n){var l=Bn();ur(e,t,n,l)}function ur(e,t,n,l){var s={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Uf(t,s);else{var c=e.alternate;if(e.lanes===0&&(c===null||c.lanes===0)&&(c=t.lastRenderedReducer,c!==null))try{var h=t.lastRenderedState,g=c(h,n);if(s.hasEagerState=!0,s.eagerState=g,_n(g,h))return as(e,t,s,0),pt===null&&ls(),!1}catch{}finally{}if(n=Do(e,t,s,l),n!==null)return Sn(n,e,l),Bf(n,t,l),!0}return!1}function bc(e,t,n,l){if(l={lane:2,revertLane:Qc(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(t)throw Error(o(479))}else t=Do(e,n,l,2),t!==null&&Sn(t,e,2)}function Ts(e){var t=e.alternate;return e===_e||t!==null&&t===_e}function Uf(e,t){bi=bs=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Bf(e,t,n){if((n&4194048)!==0){var l=t.lanes;l&=e.pendingLanes,n|=l,t.lanes=n,nl(e,n)}}var dr={readContext:nn,use:xs,useCallback:Mt,useContext:Mt,useEffect:Mt,useImperativeHandle:Mt,useLayoutEffect:Mt,useInsertionEffect:Mt,useMemo:Mt,useReducer:Mt,useRef:Mt,useState:Mt,useDebugValue:Mt,useDeferredValue:Mt,useTransition:Mt,useSyncExternalStore:Mt,useId:Mt,useHostTransitionStatus:Mt,useFormState:Mt,useActionState:Mt,useOptimistic:Mt,useMemoCache:Mt,useCacheRefresh:Mt};dr.useEffectEvent=Mt;var Hf={readContext:nn,use:xs,useCallback:function(e,t){return fn().memoizedState=[e,t===void 0?null:t],e},useContext:nn,useEffect:wf,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,ws(4194308,4,Af.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ws(4194308,4,e,t)},useInsertionEffect:function(e,t){ws(4,2,e,t)},useMemo:function(e,t){var n=fn();t=t===void 0?null:t;var l=e();if(Va){nt(!0);try{e()}finally{nt(!1)}}return n.memoizedState=[l,t],l},useReducer:function(e,t,n){var l=fn();if(n!==void 0){var s=n(t);if(Va){nt(!0);try{n(t)}finally{nt(!1)}}}else s=t;return l.memoizedState=l.baseState=s,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:s},l.queue=e,e=e.dispatch=_b.bind(null,_e,e),[l.memoizedState,e]},useRef:function(e){var t=fn();return e={current:e},t.memoizedState=e},useState:function(e){e=uc(e);var t=e.queue,n=Of.bind(null,_e,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:hc,useDeferredValue:function(e,t){var n=fn();return mc(n,e,t)},useTransition:function(){var e=uc(!1);return e=Mf.bind(null,_e,e.queue,!0,!1),fn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var l=_e,s=fn();if(Ze){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),pt===null)throw Error(o(349));(Xe&127)!==0||rf(l,t,n)}s.memoizedState=n;var c={value:n,getSnapshot:t};return s.queue=c,wf(of.bind(null,l,c,e),[e]),l.flags|=2048,vi(9,{destroy:void 0},sf.bind(null,l,c,n,t),null),n},useId:function(){var e=fn(),t=pt.identifierPrefix;if(Ze){var n=yl,l=bl;n=(l&~(1<<32-Tt(l)-1)).toString(32)+n,t="_"+t+"R_"+n,n=ys++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Nb++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:gc,useFormState:bf,useActionState:bf,useOptimistic:function(e){var t=fn();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=bc.bind(null,_e,!0,n),n.dispatch=t,[e,t]},useMemoCache:sc,useCacheRefresh:function(){return fn().memoizedState=Mb.bind(null,_e)},useEffectEvent:function(e){var t=fn(),n={impl:e};return t.memoizedState=n,function(){if((lt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},yc={readContext:nn,use:xs,useCallback:Rf,useContext:nn,useEffect:fc,useImperativeHandle:Ef,useInsertionEffect:Tf,useLayoutEffect:Nf,useMemo:jf,useReducer:Ss,useRef:Sf,useState:function(){return Ss(Ll)},useDebugValue:hc,useDeferredValue:function(e,t){var n=Ot();return kf(n,ct.memoizedState,e,t)},useTransition:function(){var e=Ss(Ll)[0],t=Ot().memoizedState;return[typeof e=="boolean"?e:cr(e),t]},useSyncExternalStore:af,useId:Df,useHostTransitionStatus:gc,useFormState:yf,useActionState:yf,useOptimistic:function(e,t){var n=Ot();return df(n,ct,e,t)},useMemoCache:sc,useCacheRefresh:Lf};yc.useEffectEvent=Cf;var Yf={readContext:nn,use:xs,useCallback:Rf,useContext:nn,useEffect:fc,useImperativeHandle:Ef,useInsertionEffect:Tf,useLayoutEffect:Nf,useMemo:jf,useReducer:cc,useRef:Sf,useState:function(){return cc(Ll)},useDebugValue:hc,useDeferredValue:function(e,t){var n=Ot();return ct===null?mc(n,e,t):kf(n,ct.memoizedState,e,t)},useTransition:function(){var e=cc(Ll)[0],t=Ot().memoizedState;return[typeof e=="boolean"?e:cr(e),t]},useSyncExternalStore:af,useId:Df,useHostTransitionStatus:gc,useFormState:xf,useActionState:xf,useOptimistic:function(e,t){var n=Ot();return ct!==null?df(n,ct,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:sc,useCacheRefresh:Lf};Yf.useEffectEvent=Cf;function vc(e,t,n,l){t=e.memoizedState,n=n(l,t),n=n==null?t:S({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var xc={enqueueSetState:function(e,t,n){e=e._reactInternals;var l=Bn(),s=oa(l);s.payload=t,n!=null&&(s.callback=n),t=ca(e,s,l),t!==null&&(Sn(t,e,l),ir(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var l=Bn(),s=oa(l);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=ca(e,s,l),t!==null&&(Sn(t,e,l),ir(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Bn(),l=oa(n);l.tag=2,t!=null&&(l.callback=t),t=ca(e,l,n),t!==null&&(Sn(t,e,n),ir(t,e,n))}};function Kf(e,t,n,l,s,c,h){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,c,h):t.prototype&&t.prototype.isPureReactComponent?!Wi(n,l)||!Wi(s,c):!0}function Gf(e,t,n,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,l),t.state!==e&&xc.enqueueReplaceState(t,t.state,null)}function Fa(e,t){var n=t;if("ref"in t){n={};for(var l in t)l!=="ref"&&(n[l]=t[l])}if(e=e.defaultProps){n===t&&(n=S({},n));for(var s in e)n[s]===void 0&&(n[s]=e[s])}return n}function qf(e){ns(e)}function Vf(e){console.error(e)}function Ff(e){ns(e)}function Ns(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function Xf(e,t,n){try{var l=e.onCaughtError;l(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(s){setTimeout(function(){throw s})}}function Sc(e,t,n){return n=oa(n),n.tag=3,n.payload={element:null},n.callback=function(){Ns(e,t)},n}function If(e){return e=oa(e),e.tag=3,e}function Zf(e,t,n,l){var s=n.type.getDerivedStateFromError;if(typeof s=="function"){var c=l.value;e.payload=function(){return s(c)},e.callback=function(){Xf(t,n,l)}}var h=n.stateNode;h!==null&&typeof h.componentDidCatch=="function"&&(e.callback=function(){Xf(t,n,l),typeof s!="function"&&(pa===null?pa=new Set([this]):pa.add(this));var g=l.stack;this.componentDidCatch(l.value,{componentStack:g!==null?g:""})})}function zb(e,t,n,l,s){if(n.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=n.alternate,t!==null&&di(t,n,s,!0),n=Dn.current,n!==null){switch(n.tag){case 31:case 13:return Zn===null?Us():n.alternate===null&&_t===0&&(_t=3),n.flags&=-257,n.flags|=65536,n.lanes=s,l===fs?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([l]):t.add(l),Xc(e,l,s)),!1;case 22:return n.flags|=65536,l===fs?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([l]):n.add(l)),Xc(e,l,s)),!1}throw Error(o(435,n.tag))}return Xc(e,l,s),Us(),!1}if(Ze)return t=Dn.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=s,l!==Yo&&(e=Error(o(422),{cause:l}),er(Vn(e,n)))):(l!==Yo&&(t=Error(o(423),{cause:l}),er(Vn(t,n))),e=e.current.alternate,e.flags|=65536,s&=-s,e.lanes|=s,l=Vn(l,n),s=Sc(e.stateNode,l,s),Wo(e,s),_t!==4&&(_t=2)),!1;var c=Error(o(520),{cause:l});if(c=Vn(c,n),vr===null?vr=[c]:vr.push(c),_t!==4&&(_t=2),t===null)return!0;l=Vn(l,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=s&-s,n.lanes|=e,e=Sc(n.stateNode,l,e),Wo(n,e),!1;case 1:if(t=n.type,c=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||c!==null&&typeof c.componentDidCatch=="function"&&(pa===null||!pa.has(c))))return n.flags|=65536,s&=-s,n.lanes|=s,s=If(s),Zf(s,e,n,l),Wo(n,s),!1}n=n.return}while(n!==null);return!1}var wc=Error(o(461)),Kt=!1;function ln(e,t,n,l){t.child=e===null?Wd(t,null,n,l):qa(t,e.child,n,l)}function Qf(e,t,n,l,s){n=n.render;var c=t.ref;if("ref"in l){var h={};for(var g in l)g!=="ref"&&(h[g]=l[g])}else h=l;return Ha(t),l=lc(e,t,n,h,c,s),g=ac(),e!==null&&!Kt?(ic(e,t,s),Ol(e,t,s)):(Ze&&g&&Bo(t),t.flags|=1,ln(e,t,l,s),t.child)}function Jf(e,t,n,l,s){if(e===null){var c=n.type;return typeof c=="function"&&!Lo(c)&&c.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=c,Wf(e,t,c,l,s)):(e=rs(n.type,null,l,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(c=e.child,!kc(e,s)){var h=c.memoizedProps;if(n=n.compare,n=n!==null?n:Wi,n(h,l)&&e.ref===t.ref)return Ol(e,t,s)}return t.flags|=1,e=kl(c,l),e.ref=t.ref,e.return=t,t.child=e}function Wf(e,t,n,l,s){if(e!==null){var c=e.memoizedProps;if(Wi(c,l)&&e.ref===t.ref)if(Kt=!1,t.pendingProps=l=c,kc(e,s))(e.flags&131072)!==0&&(Kt=!0);else return t.lanes=e.lanes,Ol(e,t,s)}return Cc(e,t,n,l,s)}function Pf(e,t,n,l){var s=l.children,c=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(c=c!==null?c.baseLanes|n:n,e!==null){for(l=t.child=e.child,s=0;l!==null;)s=s|l.lanes|l.childLanes,l=l.sibling;l=s&~c}else l=0,t.child=null;return $f(e,t,c,n,l)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&us(t,c!==null?c.cachePool:null),c!==null?ef(t,c):$o(),tf(t);else return l=t.lanes=536870912,$f(e,t,c!==null?c.baseLanes|n:n,n,l)}else c!==null?(us(t,c.cachePool),ef(t,c),da(),t.memoizedState=null):(e!==null&&us(t,null),$o(),da());return ln(e,t,s,n),t.child}function fr(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function $f(e,t,n,l,s){var c=Io();return c=c===null?null:{parent:Ht._currentValue,pool:c},t.memoizedState={baseLanes:n,cachePool:c},e!==null&&us(t,null),$o(),tf(t),e!==null&&di(e,t,l,!0),t.childLanes=s,null}function As(e,t){return t=Rs({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function eh(e,t,n){return qa(t,e.child,null,n),e=As(t,t.pendingProps),e.flags|=2,Ln(t),t.memoizedState=null,e}function Db(e,t,n){var l=t.pendingProps,s=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ze){if(l.mode==="hidden")return e=As(t,l),t.lanes=536870912,fr(null,e);if(tc(t),(e=vt)?(e=fm(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:la!==null?{id:bl,overflow:yl}:null,retryLane:536870912,hydrationErrors:null},n=Od(e),n.return=t,t.child=n,tn=t,vt=null)):e=null,e===null)throw ia(t);return t.lanes=536870912,null}return As(t,l)}var c=e.memoizedState;if(c!==null){var h=c.dehydrated;if(tc(t),s)if(t.flags&256)t.flags&=-257,t=eh(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(Kt||di(e,t,n,!1),s=(n&e.childLanes)!==0,Kt||s){if(l=pt,l!==null&&(h=ja(l,n),h!==0&&h!==c.retryLane))throw c.retryLane=h,La(e,h),Sn(l,e,h),wc;Us(),t=eh(e,t,n)}else e=c.treeContext,vt=Qn(h.nextSibling),tn=t,Ze=!0,aa=null,In=!1,e!==null&&Hd(t,e),t=As(t,l),t.flags|=4096;return t}return e=kl(e.child,{mode:l.mode,children:l.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Es(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Cc(e,t,n,l,s){return Ha(t),n=lc(e,t,n,l,void 0,s),l=ac(),e!==null&&!Kt?(ic(e,t,s),Ol(e,t,s)):(Ze&&l&&Bo(t),t.flags|=1,ln(e,t,n,s),t.child)}function th(e,t,n,l,s,c){return Ha(t),t.updateQueue=null,n=lf(t,l,n,s),nf(e),l=ac(),e!==null&&!Kt?(ic(e,t,c),Ol(e,t,c)):(Ze&&l&&Bo(t),t.flags|=1,ln(e,t,n,c),t.child)}function nh(e,t,n,l,s){if(Ha(t),t.stateNode===null){var c=si,h=n.contextType;typeof h=="object"&&h!==null&&(c=nn(h)),c=new n(l,c),t.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=xc,t.stateNode=c,c._reactInternals=t,c=t.stateNode,c.props=l,c.state=t.memoizedState,c.refs={},Qo(t),h=n.contextType,c.context=typeof h=="object"&&h!==null?nn(h):si,c.state=t.memoizedState,h=n.getDerivedStateFromProps,typeof h=="function"&&(vc(t,n,h,l),c.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof c.getSnapshotBeforeUpdate=="function"||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(h=c.state,typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount(),h!==c.state&&xc.enqueueReplaceState(c,c.state,null),sr(t,l,c,s),rr(),c.state=t.memoizedState),typeof c.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(e===null){c=t.stateNode;var g=t.memoizedProps,w=Fa(n,g);c.props=w;var k=c.context,B=n.contextType;h=si,typeof B=="object"&&B!==null&&(h=nn(B));var K=n.getDerivedStateFromProps;B=typeof K=="function"||typeof c.getSnapshotBeforeUpdate=="function",g=t.pendingProps!==g,B||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(g||k!==h)&&Gf(t,c,l,h),sa=!1;var M=t.memoizedState;c.state=M,sr(t,l,c,s),rr(),k=t.memoizedState,g||M!==k||sa?(typeof K=="function"&&(vc(t,n,K,l),k=t.memoizedState),(w=sa||Kf(t,n,w,l,M,k,h))?(B||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount()),typeof c.componentDidMount=="function"&&(t.flags|=4194308)):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=k),c.props=l,c.state=k,c.context=h,l=w):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{c=t.stateNode,Jo(e,t),h=t.memoizedProps,B=Fa(n,h),c.props=B,K=t.pendingProps,M=c.context,k=n.contextType,w=si,typeof k=="object"&&k!==null&&(w=nn(k)),g=n.getDerivedStateFromProps,(k=typeof g=="function"||typeof c.getSnapshotBeforeUpdate=="function")||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(h!==K||M!==w)&&Gf(t,c,l,w),sa=!1,M=t.memoizedState,c.state=M,sr(t,l,c,s),rr();var O=t.memoizedState;h!==K||M!==O||sa||e!==null&&e.dependencies!==null&&os(e.dependencies)?(typeof g=="function"&&(vc(t,n,g,l),O=t.memoizedState),(B=sa||Kf(t,n,B,l,M,O,w)||e!==null&&e.dependencies!==null&&os(e.dependencies))?(k||typeof c.UNSAFE_componentWillUpdate!="function"&&typeof c.componentWillUpdate!="function"||(typeof c.componentWillUpdate=="function"&&c.componentWillUpdate(l,O,w),typeof c.UNSAFE_componentWillUpdate=="function"&&c.UNSAFE_componentWillUpdate(l,O,w)),typeof c.componentDidUpdate=="function"&&(t.flags|=4),typeof c.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof c.componentDidUpdate!="function"||h===e.memoizedProps&&M===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||h===e.memoizedProps&&M===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=O),c.props=l,c.state=O,c.context=w,l=B):(typeof c.componentDidUpdate!="function"||h===e.memoizedProps&&M===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||h===e.memoizedProps&&M===e.memoizedState||(t.flags|=1024),l=!1)}return c=l,Es(e,t),l=(t.flags&128)!==0,c||l?(c=t.stateNode,n=l&&typeof n.getDerivedStateFromError!="function"?null:c.render(),t.flags|=1,e!==null&&l?(t.child=qa(t,e.child,null,s),t.child=qa(t,null,n,s)):ln(e,t,n,s),t.memoizedState=c.state,e=t.child):e=Ol(e,t,s),e}function lh(e,t,n,l){return Ua(),t.flags|=256,ln(e,t,n,l),t.child}var Tc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Nc(e){return{baseLanes:e,cachePool:Fd()}}function Ac(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Un),e}function ah(e,t,n){var l=t.pendingProps,s=!1,c=(t.flags&128)!==0,h;if((h=c)||(h=e!==null&&e.memoizedState===null?!1:(Lt.current&2)!==0),h&&(s=!0,t.flags&=-129),h=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ze){if(s?ua(t):da(),(e=vt)?(e=fm(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:la!==null?{id:bl,overflow:yl}:null,retryLane:536870912,hydrationErrors:null},n=Od(e),n.return=t,t.child=n,tn=t,vt=null)):e=null,e===null)throw ia(t);return ou(e)?t.lanes=32:t.lanes=536870912,null}var g=l.children;return l=l.fallback,s?(da(),s=t.mode,g=Rs({mode:"hidden",children:g},s),l=Oa(l,s,n,null),g.return=t,l.return=t,g.sibling=l,t.child=g,l=t.child,l.memoizedState=Nc(n),l.childLanes=Ac(e,h,n),t.memoizedState=Tc,fr(null,l)):(ua(t),Ec(t,g))}var w=e.memoizedState;if(w!==null&&(g=w.dehydrated,g!==null)){if(c)t.flags&256?(ua(t),t.flags&=-257,t=Rc(e,t,n)):t.memoizedState!==null?(da(),t.child=e.child,t.flags|=128,t=null):(da(),g=l.fallback,s=t.mode,l=Rs({mode:"visible",children:l.children},s),g=Oa(g,s,n,null),g.flags|=2,l.return=t,g.return=t,l.sibling=g,t.child=l,qa(t,e.child,null,n),l=t.child,l.memoizedState=Nc(n),l.childLanes=Ac(e,h,n),t.memoizedState=Tc,t=fr(null,l));else if(ua(t),ou(g)){if(h=g.nextSibling&&g.nextSibling.dataset,h)var k=h.dgst;h=k,l=Error(o(419)),l.stack="",l.digest=h,er({value:l,source:null,stack:null}),t=Rc(e,t,n)}else if(Kt||di(e,t,n,!1),h=(n&e.childLanes)!==0,Kt||h){if(h=pt,h!==null&&(l=ja(h,n),l!==0&&l!==w.retryLane))throw w.retryLane=l,La(e,l),Sn(h,e,l),wc;su(g)||Us(),t=Rc(e,t,n)}else su(g)?(t.flags|=192,t.child=e.child,t=null):(e=w.treeContext,vt=Qn(g.nextSibling),tn=t,Ze=!0,aa=null,In=!1,e!==null&&Hd(t,e),t=Ec(t,l.children),t.flags|=4096);return t}return s?(da(),g=l.fallback,s=t.mode,w=e.child,k=w.sibling,l=kl(w,{mode:"hidden",children:l.children}),l.subtreeFlags=w.subtreeFlags&65011712,k!==null?g=kl(k,g):(g=Oa(g,s,n,null),g.flags|=2),g.return=t,l.return=t,l.sibling=g,t.child=l,fr(null,l),l=t.child,g=e.child.memoizedState,g===null?g=Nc(n):(s=g.cachePool,s!==null?(w=Ht._currentValue,s=s.parent!==w?{parent:w,pool:w}:s):s=Fd(),g={baseLanes:g.baseLanes|n,cachePool:s}),l.memoizedState=g,l.childLanes=Ac(e,h,n),t.memoizedState=Tc,fr(e.child,l)):(ua(t),n=e.child,e=n.sibling,n=kl(n,{mode:"visible",children:l.children}),n.return=t,n.sibling=null,e!==null&&(h=t.deletions,h===null?(t.deletions=[e],t.flags|=16):h.push(e)),t.child=n,t.memoizedState=null,n)}function Ec(e,t){return t=Rs({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Rs(e,t){return e=zn(22,e,null,t),e.lanes=0,e}function Rc(e,t,n){return qa(t,e.child,null,n),e=Ec(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ih(e,t,n){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),qo(e.return,t,n)}function jc(e,t,n,l,s,c){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:n,tailMode:s,treeForkCount:c}:(h.isBackwards=t,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=n,h.tailMode=s,h.treeForkCount=c)}function rh(e,t,n){var l=t.pendingProps,s=l.revealOrder,c=l.tail;l=l.children;var h=Lt.current,g=(h&2)!==0;if(g?(h=h&1|2,t.flags|=128):h&=1,ke(Lt,h),ln(e,t,l,n),l=Ze?$i:0,!g&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ih(e,n,t);else if(e.tag===19)ih(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&gs(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),jc(t,!1,s,n,c,l);break;case"backwards":case"unstable_legacy-backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&gs(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}jc(t,!0,n,null,c,l);break;case"together":jc(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function Ol(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ma|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(di(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=kl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=kl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&os(e)))}function Lb(e,t,n){switch(t.tag){case 3:tt(t,t.stateNode.containerInfo),ra(t,Ht,e.memoizedState.cache),Ua();break;case 27:case 5:hn(t);break;case 4:tt(t,t.stateNode.containerInfo);break;case 10:ra(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,tc(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(ua(t),t.flags|=128,null):(n&t.child.childLanes)!==0?ah(e,t,n):(ua(t),e=Ol(e,t,n),e!==null?e.sibling:null);ua(t);break;case 19:var s=(e.flags&128)!==0;if(l=(n&t.childLanes)!==0,l||(di(e,t,n,!1),l=(n&t.childLanes)!==0),s){if(l)return rh(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),ke(Lt,Lt.current),l)break;return null;case 22:return t.lanes=0,Pf(e,t,n,t.pendingProps);case 24:ra(t,Ht,e.memoizedState.cache)}return Ol(e,t,n)}function sh(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Kt=!0;else{if(!kc(e,n)&&(t.flags&128)===0)return Kt=!1,Lb(e,t,n);Kt=(e.flags&131072)!==0}else Kt=!1,Ze&&(t.flags&1048576)!==0&&Bd(t,$i,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(e=Ka(t.elementType),t.type=e,typeof e=="function")Lo(e)?(l=Fa(e,l),t.tag=1,t=nh(null,t,e,l,n)):(t.tag=0,t=Cc(null,t,e,l,n));else{if(e!=null){var s=e.$$typeof;if(s===re){t.tag=11,t=Qf(null,t,e,l,n);break e}else if(s===T){t.tag=14,t=Jf(null,t,e,l,n);break e}}throw t=Re(e)||e,Error(o(306,t,""))}}return t;case 0:return Cc(e,t,t.type,t.pendingProps,n);case 1:return l=t.type,s=Fa(l,t.pendingProps),nh(e,t,l,s,n);case 3:e:{if(tt(t,t.stateNode.containerInfo),e===null)throw Error(o(387));l=t.pendingProps;var c=t.memoizedState;s=c.element,Jo(e,t),sr(t,l,null,n);var h=t.memoizedState;if(l=h.cache,ra(t,Ht,l),l!==c.cache&&Vo(t,[Ht],n,!0),rr(),l=h.element,c.isDehydrated)if(c={element:l,isDehydrated:!1,cache:h.cache},t.updateQueue.baseState=c,t.memoizedState=c,t.flags&256){t=lh(e,t,l,n);break e}else if(l!==s){s=Vn(Error(o(424)),t),er(s),t=lh(e,t,l,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(vt=Qn(e.firstChild),tn=t,Ze=!0,aa=null,In=!0,n=Wd(t,null,l,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ua(),l===s){t=Ol(e,t,n);break e}ln(e,t,l,n)}t=t.child}return t;case 26:return Es(e,t),e===null?(n=ym(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ze||(n=t.type,e=t.pendingProps,l=Vs(Qe.current).createElement(n),l[Dt]=t,l[Qt]=e,an(l,n,e),at(l),t.stateNode=l):t.memoizedState=ym(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return hn(t),e===null&&Ze&&(l=t.stateNode=pm(t.type,t.pendingProps,Qe.current),tn=t,In=!0,s=vt,va(t.type)?(cu=s,vt=Qn(l.firstChild)):vt=s),ln(e,t,t.pendingProps.children,n),Es(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ze&&((s=l=vt)&&(l=dy(l,t.type,t.pendingProps,In),l!==null?(t.stateNode=l,tn=t,vt=Qn(l.firstChild),In=!1,s=!0):s=!1),s||ia(t)),hn(t),s=t.type,c=t.pendingProps,h=e!==null?e.memoizedProps:null,l=c.children,au(s,c)?l=null:h!==null&&au(s,h)&&(t.flags|=32),t.memoizedState!==null&&(s=lc(e,t,Ab,null,null,n),Er._currentValue=s),Es(e,t),ln(e,t,l,n),t.child;case 6:return e===null&&Ze&&((e=n=vt)&&(n=fy(n,t.pendingProps,In),n!==null?(t.stateNode=n,tn=t,vt=null,e=!0):e=!1),e||ia(t)),null;case 13:return ah(e,t,n);case 4:return tt(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=qa(t,null,l,n):ln(e,t,l,n),t.child;case 11:return Qf(e,t,t.type,t.pendingProps,n);case 7:return ln(e,t,t.pendingProps,n),t.child;case 8:return ln(e,t,t.pendingProps.children,n),t.child;case 12:return ln(e,t,t.pendingProps.children,n),t.child;case 10:return l=t.pendingProps,ra(t,t.type,l.value),ln(e,t,l.children,n),t.child;case 9:return s=t.type._context,l=t.pendingProps.children,Ha(t),s=nn(s),l=l(s),t.flags|=1,ln(e,t,l,n),t.child;case 14:return Jf(e,t,t.type,t.pendingProps,n);case 15:return Wf(e,t,t.type,t.pendingProps,n);case 19:return rh(e,t,n);case 31:return Db(e,t,n);case 22:return Pf(e,t,n,t.pendingProps);case 24:return Ha(t),l=nn(Ht),e===null?(s=Io(),s===null&&(s=pt,c=Fo(),s.pooledCache=c,c.refCount++,c!==null&&(s.pooledCacheLanes|=n),s=c),t.memoizedState={parent:l,cache:s},Qo(t),ra(t,Ht,s)):((e.lanes&n)!==0&&(Jo(e,t),sr(t,null,null,n),rr()),s=e.memoizedState,c=t.memoizedState,s.parent!==l?(s={parent:l,cache:l},t.memoizedState=s,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=s),ra(t,Ht,l)):(l=c.cache,ra(t,Ht,l),l!==s.cache&&Vo(t,[Ht],n,!0))),ln(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Ul(e){e.flags|=4}function Mc(e,t,n,l,s){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(s&335544128)===s)if(e.stateNode.complete)e.flags|=8192;else if(Dh())e.flags|=8192;else throw Ga=fs,Zo}else e.flags&=-16777217}function oh(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Cm(t))if(Dh())e.flags|=8192;else throw Ga=fs,Zo}function js(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?En():536870912,e.lanes|=t,Ci|=t)}function hr(e,t){if(!Ze)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function xt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,l=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,l|=s.subtreeFlags&65011712,l|=s.flags&65011712,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,l|=s.subtreeFlags,l|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=l,e.childLanes=n,t}function Ob(e,t,n){var l=t.pendingProps;switch(Ho(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xt(t),null;case 1:return xt(t),null;case 3:return n=t.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),zl(Ht),we(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ui(t)?Ul(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Ko())),xt(t),null;case 26:var s=t.type,c=t.memoizedState;return e===null?(Ul(t),c!==null?(xt(t),oh(t,c)):(xt(t),Mc(t,s,null,l,n))):c?c!==e.memoizedState?(Ul(t),xt(t),oh(t,c)):(xt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==l&&Ul(t),xt(t),Mc(t,s,e,l,n)),null;case 27:if(qe(t),n=Qe.current,s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Ul(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return xt(t),null}e=Ye.current,ui(t)?Yd(t):(e=pm(s,l,n),t.stateNode=e,Ul(t))}return xt(t),null;case 5:if(qe(t),s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&Ul(t);else{if(!l){if(t.stateNode===null)throw Error(o(166));return xt(t),null}if(c=Ye.current,ui(t))Yd(t);else{var h=Vs(Qe.current);switch(c){case 1:c=h.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:c=h.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":c=h.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":c=h.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":c=h.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild);break;case"select":c=typeof l.is=="string"?h.createElement("select",{is:l.is}):h.createElement("select"),l.multiple?c.multiple=!0:l.size&&(c.size=l.size);break;default:c=typeof l.is=="string"?h.createElement(s,{is:l.is}):h.createElement(s)}}c[Dt]=t,c[Qt]=l;e:for(h=t.child;h!==null;){if(h.tag===5||h.tag===6)c.appendChild(h.stateNode);else if(h.tag!==4&&h.tag!==27&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}t.stateNode=c;e:switch(an(c,s,l),s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Ul(t)}}return xt(t),Mc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==l&&Ul(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(o(166));if(e=Qe.current,ui(t)){if(e=t.stateNode,n=t.memoizedProps,l=null,s=tn,s!==null)switch(s.tag){case 27:case 5:l=s.memoizedProps}e[Dt]=t,e=!!(e.nodeValue===n||l!==null&&l.suppressHydrationWarning===!0||am(e.nodeValue,n)),e||ia(t,!0)}else e=Vs(e).createTextNode(l),e[Dt]=t,t.stateNode=e}return xt(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(l=ui(t),n!==null){if(e===null){if(!l)throw Error(o(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Dt]=t}else Ua(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),e=!1}else n=Ko(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ln(t),t):(Ln(t),null);if((t.flags&128)!==0)throw Error(o(558))}return xt(t),null;case 13:if(l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(s=ui(t),l!==null&&l.dehydrated!==null){if(e===null){if(!s)throw Error(o(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(o(317));s[Dt]=t}else Ua(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),s=!1}else s=Ko(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),s=!0;if(!s)return t.flags&256?(Ln(t),t):(Ln(t),null)}return Ln(t),(t.flags&128)!==0?(t.lanes=n,t):(n=l!==null,e=e!==null&&e.memoizedState!==null,n&&(l=t.child,s=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(s=l.alternate.memoizedState.cachePool.pool),c=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(c=l.memoizedState.cachePool.pool),c!==s&&(l.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),js(t,t.updateQueue),xt(t),null);case 4:return we(),e===null&&$c(t.stateNode.containerInfo),xt(t),null;case 10:return zl(t.type),xt(t),null;case 19:if(pe(Lt),l=t.memoizedState,l===null)return xt(t),null;if(s=(t.flags&128)!==0,c=l.rendering,c===null)if(s)hr(l,!1);else{if(_t!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(c=gs(e),c!==null){for(t.flags|=128,hr(l,!1),e=c.updateQueue,t.updateQueue=e,js(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ld(n,e),n=n.sibling;return ke(Lt,Lt.current&1|2),Ze&&Ml(t,l.treeForkCount),t.child}e=e.sibling}l.tail!==null&&ae()>Ds&&(t.flags|=128,s=!0,hr(l,!1),t.lanes=4194304)}else{if(!s)if(e=gs(c),e!==null){if(t.flags|=128,s=!0,e=e.updateQueue,t.updateQueue=e,js(t,e),hr(l,!0),l.tail===null&&l.tailMode==="hidden"&&!c.alternate&&!Ze)return xt(t),null}else 2*ae()-l.renderingStartTime>Ds&&n!==536870912&&(t.flags|=128,s=!0,hr(l,!1),t.lanes=4194304);l.isBackwards?(c.sibling=t.child,t.child=c):(e=l.last,e!==null?e.sibling=c:t.child=c,l.last=c)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ae(),e.sibling=null,n=Lt.current,ke(Lt,s?n&1|2:n&1),Ze&&Ml(t,l.treeForkCount),e):(xt(t),null);case 22:case 23:return Ln(t),ec(),l=t.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(n&536870912)!==0&&(t.flags&128)===0&&(xt(t),t.subtreeFlags&6&&(t.flags|=8192)):xt(t),n=t.updateQueue,n!==null&&js(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==n&&(t.flags|=2048),e!==null&&pe(Ya),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zl(Ht),xt(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Ub(e,t){switch(Ho(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zl(Ht),we(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return qe(t),null;case 31:if(t.memoizedState!==null){if(Ln(t),t.alternate===null)throw Error(o(340));Ua()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ln(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ua()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return pe(Lt),null;case 4:return we(),null;case 10:return zl(t.type),null;case 22:case 23:return Ln(t),ec(),e!==null&&pe(Ya),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zl(Ht),null;case 25:return null;default:return null}}function ch(e,t){switch(Ho(t),t.tag){case 3:zl(Ht),we();break;case 26:case 27:case 5:qe(t);break;case 4:we();break;case 31:t.memoizedState!==null&&Ln(t);break;case 13:Ln(t);break;case 19:pe(Lt);break;case 10:zl(t.type);break;case 22:case 23:Ln(t),ec(),e!==null&&pe(Ya);break;case 24:zl(Ht)}}function mr(e,t){try{var n=t.updateQueue,l=n!==null?n.lastEffect:null;if(l!==null){var s=l.next;n=s;do{if((n.tag&e)===e){l=void 0;var c=n.create,h=n.inst;l=c(),h.destroy=l}n=n.next}while(n!==s)}}catch(g){st(t,t.return,g)}}function fa(e,t,n){try{var l=t.updateQueue,s=l!==null?l.lastEffect:null;if(s!==null){var c=s.next;l=c;do{if((l.tag&e)===e){var h=l.inst,g=h.destroy;if(g!==void 0){h.destroy=void 0,s=t;var w=n,k=g;try{k()}catch(B){st(s,w,B)}}}l=l.next}while(l!==c)}}catch(B){st(t,t.return,B)}}function uh(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{$d(t,n)}catch(l){st(e,e.return,l)}}}function dh(e,t,n){n.props=Fa(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(l){st(e,t,l)}}function pr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof n=="function"?e.refCleanup=n(l):n.current=l}}catch(s){st(e,t,s)}}function vl(e,t){var n=e.ref,l=e.refCleanup;if(n!==null)if(typeof l=="function")try{l()}catch(s){st(e,t,s)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(s){st(e,t,s)}else n.current=null}function fh(e){var t=e.type,n=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&l.focus();break e;case"img":n.src?l.src=n.src:n.srcSet&&(l.srcset=n.srcSet)}}catch(s){st(e,e.return,s)}}function _c(e,t,n){try{var l=e.stateNode;iy(l,e.type,n,t),l[Qt]=t}catch(s){st(e,e.return,s)}}function hh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&va(e.type)||e.tag===4}function zc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||hh(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&&va(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 Dc(e,t,n){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=gn));else if(l!==4&&(l===27&&va(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Dc(e,t,n),e=e.sibling;e!==null;)Dc(e,t,n),e=e.sibling}function ks(e,t,n){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(l!==4&&(l===27&&va(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ks(e,t,n),e=e.sibling;e!==null;)ks(e,t,n),e=e.sibling}function mh(e){var t=e.stateNode,n=e.memoizedProps;try{for(var l=e.type,s=t.attributes;s.length;)t.removeAttributeNode(s[0]);an(t,l,n),t[Dt]=e,t[Qt]=n}catch(c){st(e,e.return,c)}}var Bl=!1,Gt=!1,Lc=!1,ph=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function Bb(e,t){if(e=e.containerInfo,nu=Ws,e=Ad(e),Ro(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var l=n.getSelection&&n.getSelection();if(l&&l.rangeCount!==0){n=l.anchorNode;var s=l.anchorOffset,c=l.focusNode;l=l.focusOffset;try{n.nodeType,c.nodeType}catch{n=null;break e}var h=0,g=-1,w=-1,k=0,B=0,K=e,M=null;t:for(;;){for(var O;K!==n||s!==0&&K.nodeType!==3||(g=h+s),K!==c||l!==0&&K.nodeType!==3||(w=h+l),K.nodeType===3&&(h+=K.nodeValue.length),(O=K.firstChild)!==null;)M=K,K=O;for(;;){if(K===e)break t;if(M===n&&++k===s&&(g=h),M===c&&++B===l&&(w=h),(O=K.nextSibling)!==null)break;K=M,M=K.parentNode}K=O}n=g===-1||w===-1?null:{start:g,end:w}}else n=null}n=n||{start:0,end:0}}else n=null;for(lu={focusedElem:e,selectionRange:n},Ws=!1,Pt=t;Pt!==null;)if(t=Pt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Pt=e;else for(;Pt!==null;){switch(t=Pt,c=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)s=e[n],s.ref.impl=s.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&c!==null){e=void 0,n=t,s=c.memoizedProps,c=c.memoizedState,l=n.stateNode;try{var ue=Fa(n.type,s);e=l.getSnapshotBeforeUpdate(ue,c),l.__reactInternalSnapshotBeforeUpdate=e}catch(Ne){st(n,n.return,Ne)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ru(e);else if(n===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,Pt=e;break}Pt=t.return}}function gh(e,t,n){var l=n.flags;switch(n.tag){case 0:case 11:case 15:Yl(e,n),l&4&&mr(5,n);break;case 1:if(Yl(e,n),l&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(h){st(n,n.return,h)}else{var s=Fa(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(s,t,e.__reactInternalSnapshotBeforeUpdate)}catch(h){st(n,n.return,h)}}l&64&&uh(n),l&512&&pr(n,n.return);break;case 3:if(Yl(e,n),l&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{$d(e,t)}catch(h){st(n,n.return,h)}}break;case 27:t===null&&l&4&&mh(n);case 26:case 5:Yl(e,n),t===null&&l&4&&fh(n),l&512&&pr(n,n.return);break;case 12:Yl(e,n);break;case 31:Yl(e,n),l&4&&vh(e,n);break;case 13:Yl(e,n),l&4&&xh(e,n),l&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ib.bind(null,n),hy(e,n))));break;case 22:if(l=n.memoizedState!==null||Bl,!l){t=t!==null&&t.memoizedState!==null||Gt,s=Bl;var c=Gt;Bl=l,(Gt=t)&&!c?Kl(e,n,(n.subtreeFlags&8772)!==0):Yl(e,n),Bl=s,Gt=c}break;case 30:break;default:Yl(e,n)}}function bh(e){var t=e.alternate;t!==null&&(e.alternate=null,bh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Oe(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 jt=null,bn=!1;function Hl(e,t,n){for(n=n.child;n!==null;)yh(e,t,n),n=n.sibling}function yh(e,t,n){if(yt&&typeof yt.onCommitFiberUnmount=="function")try{yt.onCommitFiberUnmount(Ut,n)}catch{}switch(n.tag){case 26:Gt||vl(n,t),Hl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Gt||vl(n,t);var l=jt,s=bn;va(n.type)&&(jt=n.stateNode,bn=!1),Hl(e,t,n),Tr(n.stateNode),jt=l,bn=s;break;case 5:Gt||vl(n,t);case 6:if(l=jt,s=bn,jt=null,Hl(e,t,n),jt=l,bn=s,jt!==null)if(bn)try{(jt.nodeType===9?jt.body:jt.nodeName==="HTML"?jt.ownerDocument.body:jt).removeChild(n.stateNode)}catch(c){st(n,t,c)}else try{jt.removeChild(n.stateNode)}catch(c){st(n,t,c)}break;case 18:jt!==null&&(bn?(e=jt,um(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Mi(e)):um(jt,n.stateNode));break;case 4:l=jt,s=bn,jt=n.stateNode.containerInfo,bn=!0,Hl(e,t,n),jt=l,bn=s;break;case 0:case 11:case 14:case 15:fa(2,n,t),Gt||fa(4,n,t),Hl(e,t,n);break;case 1:Gt||(vl(n,t),l=n.stateNode,typeof l.componentWillUnmount=="function"&&dh(n,t,l)),Hl(e,t,n);break;case 21:Hl(e,t,n);break;case 22:Gt=(l=Gt)||n.memoizedState!==null,Hl(e,t,n),Gt=l;break;default:Hl(e,t,n)}}function vh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Mi(e)}catch(n){st(t,t.return,n)}}}function xh(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Mi(e)}catch(n){st(t,t.return,n)}}function Hb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ph),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ph),t;default:throw Error(o(435,e.tag))}}function Ms(e,t){var n=Hb(e);t.forEach(function(l){if(!n.has(l)){n.add(l);var s=Zb.bind(null,e,l);l.then(s,s)}})}function yn(e,t){var n=t.deletions;if(n!==null)for(var l=0;l<n.length;l++){var s=n[l],c=e,h=t,g=h;e:for(;g!==null;){switch(g.tag){case 27:if(va(g.type)){jt=g.stateNode,bn=!1;break e}break;case 5:jt=g.stateNode,bn=!1;break e;case 3:case 4:jt=g.stateNode.containerInfo,bn=!0;break e}g=g.return}if(jt===null)throw Error(o(160));yh(c,h,s),jt=null,bn=!1,c=s.alternate,c!==null&&(c.return=null),s.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Sh(t,e),t=t.sibling}var rl=null;function Sh(e,t){var n=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:yn(t,e),vn(e),l&4&&(fa(3,e,e.return),mr(3,e),fa(5,e,e.return));break;case 1:yn(t,e),vn(e),l&512&&(Gt||n===null||vl(n,n.return)),l&64&&Bl&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?l:n.concat(l))));break;case 26:var s=rl;if(yn(t,e),vn(e),l&512&&(Gt||n===null||vl(n,n.return)),l&4){var c=n!==null?n.memoizedState:null;if(l=e.memoizedState,n===null)if(l===null)if(e.stateNode===null){e:{l=e.type,n=e.memoizedProps,s=s.ownerDocument||s;t:switch(l){case"title":c=s.getElementsByTagName("title")[0],(!c||c[Ee]||c[Dt]||c.namespaceURI==="http://www.w3.org/2000/svg"||c.hasAttribute("itemprop"))&&(c=s.createElement(l),s.head.insertBefore(c,s.querySelector("head > title"))),an(c,l,n),c[Dt]=e,at(c),l=c;break e;case"link":var h=Sm("link","href",s).get(l+(n.href||""));if(h){for(var g=0;g<h.length;g++)if(c=h[g],c.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&c.getAttribute("rel")===(n.rel==null?null:n.rel)&&c.getAttribute("title")===(n.title==null?null:n.title)&&c.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){h.splice(g,1);break t}}c=s.createElement(l),an(c,l,n),s.head.appendChild(c);break;case"meta":if(h=Sm("meta","content",s).get(l+(n.content||""))){for(g=0;g<h.length;g++)if(c=h[g],c.getAttribute("content")===(n.content==null?null:""+n.content)&&c.getAttribute("name")===(n.name==null?null:n.name)&&c.getAttribute("property")===(n.property==null?null:n.property)&&c.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&c.getAttribute("charset")===(n.charSet==null?null:n.charSet)){h.splice(g,1);break t}}c=s.createElement(l),an(c,l,n),s.head.appendChild(c);break;default:throw Error(o(468,l))}c[Dt]=e,at(c),l=c}e.stateNode=l}else wm(s,e.type,e.stateNode);else e.stateNode=xm(s,l,e.memoizedProps);else c!==l?(c===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):c.count--,l===null?wm(s,e.type,e.stateNode):xm(s,l,e.memoizedProps)):l===null&&e.stateNode!==null&&_c(e,e.memoizedProps,n.memoizedProps)}break;case 27:yn(t,e),vn(e),l&512&&(Gt||n===null||vl(n,n.return)),n!==null&&l&4&&_c(e,e.memoizedProps,n.memoizedProps);break;case 5:if(yn(t,e),vn(e),l&512&&(Gt||n===null||vl(n,n.return)),e.flags&32){s=e.stateNode;try{Pl(s,"")}catch(ue){st(e,e.return,ue)}}l&4&&e.stateNode!=null&&(s=e.memoizedProps,_c(e,s,n!==null?n.memoizedProps:s)),l&1024&&(Lc=!0);break;case 6:if(yn(t,e),vn(e),l&4){if(e.stateNode===null)throw Error(o(162));l=e.memoizedProps,n=e.stateNode;try{n.nodeValue=l}catch(ue){st(e,e.return,ue)}}break;case 3:if(Is=null,s=rl,rl=Fs(t.containerInfo),yn(t,e),rl=s,vn(e),l&4&&n!==null&&n.memoizedState.isDehydrated)try{Mi(t.containerInfo)}catch(ue){st(e,e.return,ue)}Lc&&(Lc=!1,wh(e));break;case 4:l=rl,rl=Fs(e.stateNode.containerInfo),yn(t,e),vn(e),rl=l;break;case 12:yn(t,e),vn(e);break;case 31:yn(t,e),vn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Ms(e,l)));break;case 13:yn(t,e),vn(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(zs=ae()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Ms(e,l)));break;case 22:s=e.memoizedState!==null;var w=n!==null&&n.memoizedState!==null,k=Bl,B=Gt;if(Bl=k||s,Gt=B||w,yn(t,e),Gt=B,Bl=k,vn(e),l&8192)e:for(t=e.stateNode,t._visibility=s?t._visibility&-2:t._visibility|1,s&&(n===null||w||Bl||Gt||Xa(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){w=n=t;try{if(c=w.stateNode,s)h=c.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none";else{g=w.stateNode;var K=w.memoizedProps.style,M=K!=null&&K.hasOwnProperty("display")?K.display:null;g.style.display=M==null||typeof M=="boolean"?"":(""+M).trim()}}catch(ue){st(w,w.return,ue)}}}else if(t.tag===6){if(n===null){w=t;try{w.stateNode.nodeValue=s?"":w.memoizedProps}catch(ue){st(w,w.return,ue)}}}else if(t.tag===18){if(n===null){w=t;try{var O=w.stateNode;s?dm(O,!0):dm(w.stateNode,!1)}catch(ue){st(w,w.return,ue)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=e.updateQueue,l!==null&&(n=l.retryQueue,n!==null&&(l.retryQueue=null,Ms(e,n))));break;case 19:yn(t,e),vn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Ms(e,l)));break;case 30:break;case 21:break;default:yn(t,e),vn(e)}}function vn(e){var t=e.flags;if(t&2){try{for(var n,l=e.return;l!==null;){if(hh(l)){n=l;break}l=l.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var s=n.stateNode,c=zc(e);ks(e,c,s);break;case 5:var h=n.stateNode;n.flags&32&&(Pl(h,""),n.flags&=-33);var g=zc(e);ks(e,g,h);break;case 3:case 4:var w=n.stateNode.containerInfo,k=zc(e);Dc(e,k,w);break;default:throw Error(o(161))}}catch(B){st(e,e.return,B)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;wh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Yl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)gh(e,t.alternate,t),t=t.sibling}function Xa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:fa(4,t,t.return),Xa(t);break;case 1:vl(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&dh(t,t.return,n),Xa(t);break;case 27:Tr(t.stateNode);case 26:case 5:vl(t,t.return),Xa(t);break;case 22:t.memoizedState===null&&Xa(t);break;case 30:Xa(t);break;default:Xa(t)}e=e.sibling}}function Kl(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,s=e,c=t,h=c.flags;switch(c.tag){case 0:case 11:case 15:Kl(s,c,n),mr(4,c);break;case 1:if(Kl(s,c,n),l=c,s=l.stateNode,typeof s.componentDidMount=="function")try{s.componentDidMount()}catch(k){st(l,l.return,k)}if(l=c,s=l.updateQueue,s!==null){var g=l.stateNode;try{var w=s.shared.hiddenCallbacks;if(w!==null)for(s.shared.hiddenCallbacks=null,s=0;s<w.length;s++)Pd(w[s],g)}catch(k){st(l,l.return,k)}}n&&h&64&&uh(c),pr(c,c.return);break;case 27:mh(c);case 26:case 5:Kl(s,c,n),n&&l===null&&h&4&&fh(c),pr(c,c.return);break;case 12:Kl(s,c,n);break;case 31:Kl(s,c,n),n&&h&4&&vh(s,c);break;case 13:Kl(s,c,n),n&&h&4&&xh(s,c);break;case 22:c.memoizedState===null&&Kl(s,c,n),pr(c,c.return);break;case 30:break;default:Kl(s,c,n)}t=t.sibling}}function Oc(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&tr(n))}function Uc(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&tr(e))}function sl(e,t,n,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ch(e,t,n,l),t=t.sibling}function Ch(e,t,n,l){var s=t.flags;switch(t.tag){case 0:case 11:case 15:sl(e,t,n,l),s&2048&&mr(9,t);break;case 1:sl(e,t,n,l);break;case 3:sl(e,t,n,l),s&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&tr(e)));break;case 12:if(s&2048){sl(e,t,n,l),e=t.stateNode;try{var c=t.memoizedProps,h=c.id,g=c.onPostCommit;typeof g=="function"&&g(h,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(w){st(t,t.return,w)}}else sl(e,t,n,l);break;case 31:sl(e,t,n,l);break;case 13:sl(e,t,n,l);break;case 23:break;case 22:c=t.stateNode,h=t.alternate,t.memoizedState!==null?c._visibility&2?sl(e,t,n,l):gr(e,t):c._visibility&2?sl(e,t,n,l):(c._visibility|=2,xi(e,t,n,l,(t.subtreeFlags&10256)!==0||!1)),s&2048&&Oc(h,t);break;case 24:sl(e,t,n,l),s&2048&&Uc(t.alternate,t);break;default:sl(e,t,n,l)}}function xi(e,t,n,l,s){for(s=s&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var c=e,h=t,g=n,w=l,k=h.flags;switch(h.tag){case 0:case 11:case 15:xi(c,h,g,w,s),mr(8,h);break;case 23:break;case 22:var B=h.stateNode;h.memoizedState!==null?B._visibility&2?xi(c,h,g,w,s):gr(c,h):(B._visibility|=2,xi(c,h,g,w,s)),s&&k&2048&&Oc(h.alternate,h);break;case 24:xi(c,h,g,w,s),s&&k&2048&&Uc(h.alternate,h);break;default:xi(c,h,g,w,s)}t=t.sibling}}function gr(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,l=t,s=l.flags;switch(l.tag){case 22:gr(n,l),s&2048&&Oc(l.alternate,l);break;case 24:gr(n,l),s&2048&&Uc(l.alternate,l);break;default:gr(n,l)}t=t.sibling}}var br=8192;function Si(e,t,n){if(e.subtreeFlags&br)for(e=e.child;e!==null;)Th(e,t,n),e=e.sibling}function Th(e,t,n){switch(e.tag){case 26:Si(e,t,n),e.flags&br&&e.memoizedState!==null&&Ny(n,rl,e.memoizedState,e.memoizedProps);break;case 5:Si(e,t,n);break;case 3:case 4:var l=rl;rl=Fs(e.stateNode.containerInfo),Si(e,t,n),rl=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=br,br=16777216,Si(e,t,n),br=l):Si(e,t,n));break;default:Si(e,t,n)}}function Nh(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 yr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var l=t[n];Pt=l,Eh(l,e)}Nh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ah(e),e=e.sibling}function Ah(e){switch(e.tag){case 0:case 11:case 15:yr(e),e.flags&2048&&fa(9,e,e.return);break;case 3:yr(e);break;case 12:yr(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,_s(e)):yr(e);break;default:yr(e)}}function _s(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var l=t[n];Pt=l,Eh(l,e)}Nh(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:fa(8,t,t.return),_s(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,_s(t));break;default:_s(t)}e=e.sibling}}function Eh(e,t){for(;Pt!==null;){var n=Pt;switch(n.tag){case 0:case 11:case 15:fa(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var l=n.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:tr(n.memoizedState.cache)}if(l=n.child,l!==null)l.return=n,Pt=l;else e:for(n=e;Pt!==null;){l=Pt;var s=l.sibling,c=l.return;if(bh(l),l===n){Pt=null;break e}if(s!==null){s.return=c,Pt=s;break e}Pt=c}}}var Yb={getCacheForType:function(e){var t=nn(Ht),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return nn(Ht).controller.signal}},Kb=typeof WeakMap=="function"?WeakMap:Map,lt=0,pt=null,Ve=null,Xe=0,rt=0,On=null,ha=!1,wi=!1,Bc=!1,Gl=0,_t=0,ma=0,Ia=0,Hc=0,Un=0,Ci=0,vr=null,xn=null,Yc=!1,zs=0,Rh=0,Ds=1/0,Ls=null,pa=null,Xt=0,ga=null,Ti=null,ql=0,Kc=0,Gc=null,jh=null,xr=0,qc=null;function Bn(){return(lt&2)!==0&&Xe!==0?Xe&-Xe:D.T!==null?Qc():Nl()}function kh(){if(Un===0)if((Xe&536870912)===0||Ze){var e=Zt;Zt<<=1,(Zt&3932160)===0&&(Zt=262144),Un=e}else Un=536870912;return e=Dn.current,e!==null&&(e.flags|=32),Un}function Sn(e,t,n){(e===pt&&(rt===2||rt===9)||e.cancelPendingCommit!==null)&&(Ni(e,0),ba(e,Xe,Un,!1)),Rn(e,n),((lt&2)===0||e!==pt)&&(e===pt&&((lt&2)===0&&(Ia|=n),_t===4&&ba(e,Xe,Un,!1)),xl(e))}function Mh(e,t,n){if((lt&6)!==0)throw Error(o(327));var l=!n&&(t&127)===0&&(t&e.expiredLanes)===0||fl(e,t),s=l?Vb(e,t):Fc(e,t,!0),c=l;do{if(s===0){wi&&!l&&ba(e,t,0,!1);break}else{if(n=e.current.alternate,c&&!Gb(n)){s=Fc(e,t,!1),c=!1;continue}if(s===2){if(c=t,e.errorRecoveryDisabledLanes&c)var h=0;else h=e.pendingLanes&-536870913,h=h!==0?h:h&536870912?536870912:0;if(h!==0){t=h;e:{var g=e;s=vr;var w=g.current.memoizedState.isDehydrated;if(w&&(Ni(g,h).flags|=256),h=Fc(g,h,!1),h!==2){if(Bc&&!w){g.errorRecoveryDisabledLanes|=c,Ia|=c,s=4;break e}c=xn,xn=s,c!==null&&(xn===null?xn=c:xn.push.apply(xn,c))}s=h}if(c=!1,s!==2)continue}}if(s===1){Ni(e,0),ba(e,t,0,!0);break}e:{switch(l=e,c=s,c){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:ba(l,t,Un,!ha);break e;case 2:xn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(s=zs+300-ae(),10<s)){if(ba(l,t,Un,!ha),Tl(l,0,!0)!==0)break e;ql=t,l.timeoutHandle=om(_h.bind(null,l,n,xn,Ls,Yc,t,Un,Ia,Ci,ha,c,"Throttled",-0,0),s);break e}_h(l,n,xn,Ls,Yc,t,Un,Ia,Ci,ha,c,null,-0,0)}}break}while(!0);xl(e)}function _h(e,t,n,l,s,c,h,g,w,k,B,K,M,O){if(e.timeoutHandle=-1,K=t.subtreeFlags,K&8192||(K&16785408)===16785408){K={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gn},Th(t,c,K);var ue=(c&62914560)===c?zs-ae():(c&4194048)===c?Rh-ae():0;if(ue=Ay(K,ue),ue!==null){ql=c,e.cancelPendingCommit=ue(Yh.bind(null,e,t,c,n,l,s,h,g,w,B,K,null,M,O)),ba(e,c,h,!k);return}}Yh(e,t,c,n,l,s,h,g,w)}function Gb(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var l=0;l<n.length;l++){var s=n[l],c=s.getSnapshot;s=s.value;try{if(!_n(c(),s))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ba(e,t,n,l){t&=~Hc,t&=~Ia,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var s=t;0<s;){var c=31-Tt(s),h=1<<c;l[c]=-1,s&=~h}n!==0&&Il(e,n,t)}function Os(){return(lt&6)===0?(Sr(0),!1):!0}function Vc(){if(Ve!==null){if(rt===0)var e=Ve.return;else e=Ve,_l=Ba=null,rc(e),pi=null,lr=0,e=Ve;for(;e!==null;)ch(e.alternate,e),e=e.return;Ve=null}}function Ni(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,oy(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ql=0,Vc(),pt=e,Ve=n=kl(e.current,null),Xe=t,rt=0,On=null,ha=!1,wi=fl(e,t),Bc=!1,Ci=Un=Hc=Ia=ma=_t=0,xn=vr=null,Yc=!1,(t&8)!==0&&(t|=t&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=t;0<l;){var s=31-Tt(l),c=1<<s;t|=e[s],l&=~c}return Gl=t,ls(),n}function zh(e,t){_e=null,D.H=dr,t===mi||t===ds?(t=Zd(),rt=3):t===Zo?(t=Zd(),rt=4):rt=t===wc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,On=t,Ve===null&&(_t=1,Ns(e,Vn(t,e.current)))}function Dh(){var e=Dn.current;return e===null?!0:(Xe&4194048)===Xe?Zn===null:(Xe&62914560)===Xe||(Xe&536870912)!==0?e===Zn:!1}function Lh(){var e=D.H;return D.H=dr,e===null?dr:e}function Oh(){var e=D.A;return D.A=Yb,e}function Us(){_t=4,ha||(Xe&4194048)!==Xe&&Dn.current!==null||(wi=!0),(ma&134217727)===0&&(Ia&134217727)===0||pt===null||ba(pt,Xe,Un,!1)}function Fc(e,t,n){var l=lt;lt|=2;var s=Lh(),c=Oh();(pt!==e||Xe!==t)&&(Ls=null,Ni(e,t)),t=!1;var h=_t;e:do try{if(rt!==0&&Ve!==null){var g=Ve,w=On;switch(rt){case 8:Vc(),h=6;break e;case 3:case 2:case 9:case 6:Dn.current===null&&(t=!0);var k=rt;if(rt=0,On=null,Ai(e,g,w,k),n&&wi){h=0;break e}break;default:k=rt,rt=0,On=null,Ai(e,g,w,k)}}qb(),h=_t;break}catch(B){zh(e,B)}while(!0);return t&&e.shellSuspendCounter++,_l=Ba=null,lt=l,D.H=s,D.A=c,Ve===null&&(pt=null,Xe=0,ls()),h}function qb(){for(;Ve!==null;)Uh(Ve)}function Vb(e,t){var n=lt;lt|=2;var l=Lh(),s=Oh();pt!==e||Xe!==t?(Ls=null,Ds=ae()+500,Ni(e,t)):wi=fl(e,t);e:do try{if(rt!==0&&Ve!==null){t=Ve;var c=On;t:switch(rt){case 1:rt=0,On=null,Ai(e,t,c,1);break;case 2:case 9:if(Xd(c)){rt=0,On=null,Bh(t);break}t=function(){rt!==2&&rt!==9||pt!==e||(rt=7),xl(e)},c.then(t,t);break e;case 3:rt=7;break e;case 4:rt=5;break e;case 7:Xd(c)?(rt=0,On=null,Bh(t)):(rt=0,On=null,Ai(e,t,c,7));break;case 5:var h=null;switch(Ve.tag){case 26:h=Ve.memoizedState;case 5:case 27:var g=Ve;if(h?Cm(h):g.stateNode.complete){rt=0,On=null;var w=g.sibling;if(w!==null)Ve=w;else{var k=g.return;k!==null?(Ve=k,Bs(k)):Ve=null}break t}}rt=0,On=null,Ai(e,t,c,5);break;case 6:rt=0,On=null,Ai(e,t,c,6);break;case 8:Vc(),_t=6;break e;default:throw Error(o(462))}}Fb();break}catch(B){zh(e,B)}while(!0);return _l=Ba=null,D.H=l,D.A=s,lt=n,Ve!==null?0:(pt=null,Xe=0,ls(),_t)}function Fb(){for(;Ve!==null&&!Pe();)Uh(Ve)}function Uh(e){var t=sh(e.alternate,e,Gl);e.memoizedProps=e.pendingProps,t===null?Bs(e):Ve=t}function Bh(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=th(n,t,t.pendingProps,t.type,void 0,Xe);break;case 11:t=th(n,t,t.pendingProps,t.type.render,t.ref,Xe);break;case 5:rc(t);default:ch(n,t),t=Ve=Ld(t,Gl),t=sh(n,t,Gl)}e.memoizedProps=e.pendingProps,t===null?Bs(e):Ve=t}function Ai(e,t,n,l){_l=Ba=null,rc(t),pi=null,lr=0;var s=t.return;try{if(zb(e,s,t,n,Xe)){_t=1,Ns(e,Vn(n,e.current)),Ve=null;return}}catch(c){if(s!==null)throw Ve=s,c;_t=1,Ns(e,Vn(n,e.current)),Ve=null;return}t.flags&32768?(Ze||l===1?e=!0:wi||(Xe&536870912)!==0?e=!1:(ha=e=!0,(l===2||l===9||l===3||l===6)&&(l=Dn.current,l!==null&&l.tag===13&&(l.flags|=16384))),Hh(t,e)):Bs(t)}function Bs(e){var t=e;do{if((t.flags&32768)!==0){Hh(t,ha);return}e=t.return;var n=Ob(t.alternate,t,Gl);if(n!==null){Ve=n;return}if(t=t.sibling,t!==null){Ve=t;return}Ve=t=e}while(t!==null);_t===0&&(_t=5)}function Hh(e,t){do{var n=Ub(e.alternate,e);if(n!==null){n.flags&=32767,Ve=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ve=e;return}Ve=e=n}while(e!==null);_t=6,Ve=null}function Yh(e,t,n,l,s,c,h,g,w){e.cancelPendingCommit=null;do Hs();while(Xt!==0);if((lt&6)!==0)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(c=t.lanes|t.childLanes,c|=zo,qi(e,n,c,h,g,w),e===pt&&(Ve=pt=null,Xe=0),Ti=t,ga=e,ql=n,Kc=c,Gc=s,jh=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Qb(sn,function(){return Fh(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=D.T,D.T=null,s=F.p,F.p=2,h=lt,lt|=4;try{Bb(e,t,n)}finally{lt=h,F.p=s,D.T=l}}Xt=1,Kh(),Gh(),qh()}}function Kh(){if(Xt===1){Xt=0;var e=ga,t=Ti,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=D.T,D.T=null;var l=F.p;F.p=2;var s=lt;lt|=4;try{Sh(t,e);var c=lu,h=Ad(e.containerInfo),g=c.focusedElem,w=c.selectionRange;if(h!==g&&g&&g.ownerDocument&&Nd(g.ownerDocument.documentElement,g)){if(w!==null&&Ro(g)){var k=w.start,B=w.end;if(B===void 0&&(B=k),"selectionStart"in g)g.selectionStart=k,g.selectionEnd=Math.min(B,g.value.length);else{var K=g.ownerDocument||document,M=K&&K.defaultView||window;if(M.getSelection){var O=M.getSelection(),ue=g.textContent.length,Ne=Math.min(w.start,ue),dt=w.end===void 0?Ne:Math.min(w.end,ue);!O.extend&&Ne>dt&&(h=dt,dt=Ne,Ne=h);var N=Td(g,Ne),C=Td(g,dt);if(N&&C&&(O.rangeCount!==1||O.anchorNode!==N.node||O.anchorOffset!==N.offset||O.focusNode!==C.node||O.focusOffset!==C.offset)){var j=K.createRange();j.setStart(N.node,N.offset),O.removeAllRanges(),Ne>dt?(O.addRange(j),O.extend(C.node,C.offset)):(j.setEnd(C.node,C.offset),O.addRange(j))}}}}for(K=[],O=g;O=O.parentNode;)O.nodeType===1&&K.push({element:O,left:O.scrollLeft,top:O.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<K.length;g++){var Y=K[g];Y.element.scrollLeft=Y.left,Y.element.scrollTop=Y.top}}Ws=!!nu,lu=nu=null}finally{lt=s,F.p=l,D.T=n}}e.current=t,Xt=2}}function Gh(){if(Xt===2){Xt=0;var e=ga,t=Ti,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=D.T,D.T=null;var l=F.p;F.p=2;var s=lt;lt|=4;try{gh(e,t.alternate,t)}finally{lt=s,F.p=l,D.T=n}}Xt=3}}function qh(){if(Xt===4||Xt===3){Xt=0,Ct();var e=ga,t=Ti,n=ql,l=jh;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Xt=5:(Xt=0,Ti=ga=null,Vh(e,e.pendingLanes));var s=e.pendingLanes;if(s===0&&(pa=null),hl(n),t=t.stateNode,yt&&typeof yt.onCommitFiberRoot=="function")try{yt.onCommitFiberRoot(Ut,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=D.T,s=F.p,F.p=2,D.T=null;try{for(var c=e.onRecoverableError,h=0;h<l.length;h++){var g=l[h];c(g.value,{componentStack:g.stack})}}finally{D.T=t,F.p=s}}(ql&3)!==0&&Hs(),xl(e),s=e.pendingLanes,(n&261930)!==0&&(s&42)!==0?e===qc?xr++:(xr=0,qc=e):xr=0,Sr(0)}}function Vh(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,tr(t)))}function Hs(){return Kh(),Gh(),qh(),Fh()}function Fh(){if(Xt!==5)return!1;var e=ga,t=Kc;Kc=0;var n=hl(ql),l=D.T,s=F.p;try{F.p=32>n?32:n,D.T=null,n=Gc,Gc=null;var c=ga,h=ql;if(Xt=0,Ti=ga=null,ql=0,(lt&6)!==0)throw Error(o(331));var g=lt;if(lt|=4,Ah(c.current),Ch(c,c.current,h,n),lt=g,Sr(0,!1),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(Ut,c)}catch{}return!0}finally{F.p=s,D.T=l,Vh(e,t)}}function Xh(e,t,n){t=Vn(n,t),t=Sc(e.stateNode,t,2),e=ca(e,t,2),e!==null&&(Rn(e,2),xl(e))}function st(e,t,n){if(e.tag===3)Xh(e,e,n);else for(;t!==null;){if(t.tag===3){Xh(t,e,n);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(pa===null||!pa.has(l))){e=Vn(n,e),n=If(2),l=ca(t,n,2),l!==null&&(Zf(n,l,t,e),Rn(l,2),xl(l));break}}t=t.return}}function Xc(e,t,n){var l=e.pingCache;if(l===null){l=e.pingCache=new Kb;var s=new Set;l.set(t,s)}else s=l.get(t),s===void 0&&(s=new Set,l.set(t,s));s.has(n)||(Bc=!0,s.add(n),e=Xb.bind(null,e,t,n),t.then(e,e))}function Xb(e,t,n){var l=e.pingCache;l!==null&&l.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,pt===e&&(Xe&n)===n&&(_t===4||_t===3&&(Xe&62914560)===Xe&&300>ae()-zs?(lt&2)===0&&Ni(e,0):Hc|=n,Ci===Xe&&(Ci=0)),xl(e)}function Ih(e,t){t===0&&(t=En()),e=La(e,t),e!==null&&(Rn(e,t),xl(e))}function Ib(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ih(e,n)}function Zb(e,t){var n=0;switch(e.tag){case 31:case 13:var l=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(o(314))}l!==null&&l.delete(t),Ih(e,n)}function Qb(e,t){return $n(e,t)}var Ys=null,Ei=null,Ic=!1,Ks=!1,Zc=!1,ya=0;function xl(e){e!==Ei&&e.next===null&&(Ei===null?Ys=Ei=e:Ei=Ei.next=e),Ks=!0,Ic||(Ic=!0,Wb())}function Sr(e,t){if(!Zc&&Ks){Zc=!0;do for(var n=!1,l=Ys;l!==null;){if(e!==0){var s=l.pendingLanes;if(s===0)var c=0;else{var h=l.suspendedLanes,g=l.pingedLanes;c=(1<<31-Tt(42|e)+1)-1,c&=s&~(h&~g),c=c&201326741?c&201326741|1:c?c|2:0}c!==0&&(n=!0,Wh(l,c))}else c=Xe,c=Tl(l,l===pt?c:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(c&3)===0||fl(l,c)||(n=!0,Wh(l,c));l=l.next}while(n);Zc=!1}}function Jb(){Zh()}function Zh(){Ks=Ic=!1;var e=0;ya!==0&&sy()&&(e=ya);for(var t=ae(),n=null,l=Ys;l!==null;){var s=l.next,c=Qh(l,t);c===0?(l.next=null,n===null?Ys=s:n.next=s,s===null&&(Ei=n)):(n=l,(e!==0||(c&3)!==0)&&(Ks=!0)),l=s}Xt!==0&&Xt!==5||Sr(e),ya!==0&&(ya=0)}function Qh(e,t){for(var n=e.suspendedLanes,l=e.pingedLanes,s=e.expirationTimes,c=e.pendingLanes&-62914561;0<c;){var h=31-Tt(c),g=1<<h,w=s[h];w===-1?((g&n)===0||(g&l)!==0)&&(s[h]=tl(g,t)):w<=t&&(e.expiredLanes|=g),c&=~g}if(t=pt,n=Xe,n=Tl(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,n===0||e===t&&(rt===2||rt===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&kt(l),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||fl(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(l!==null&&kt(l),hl(n)){case 2:case 8:n=ot;break;case 32:n=sn;break;case 268435456:n=zt;break;default:n=sn}return l=Jh.bind(null,e),n=$n(n,l),e.callbackPriority=t,e.callbackNode=n,t}return l!==null&&l!==null&&kt(l),e.callbackPriority=2,e.callbackNode=null,2}function Jh(e,t){if(Xt!==0&&Xt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Hs()&&e.callbackNode!==n)return null;var l=Xe;return l=Tl(e,e===pt?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(Mh(e,l,t),Qh(e,ae()),e.callbackNode!=null&&e.callbackNode===n?Jh.bind(null,e):null)}function Wh(e,t){if(Hs())return null;Mh(e,t,!0)}function Wb(){cy(function(){(lt&6)!==0?$n(Le,Jb):Zh()})}function Qc(){if(ya===0){var e=fi;e===0&&(e=wl,wl<<=1,(wl&261888)===0&&(wl=256)),ya=e}return ya}function Ph(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ma(""+e)}function $h(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Pb(e,t,n,l,s){if(t==="submit"&&n&&n.stateNode===s){var c=Ph((s[Qt]||null).action),h=l.submitter;h&&(t=(t=h[Qt]||null)?Ph(t.formAction):h.getAttribute("formAction"),t!==null&&(c=t,h=null));var g=new _a("action","action",null,l,s);e.push({event:g,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ya!==0){var w=h?$h(s,h):new FormData(s);pc(n,{pending:!0,data:w,method:s.method,action:c},null,w)}}else typeof c=="function"&&(g.preventDefault(),w=h?$h(s,h):new FormData(s),pc(n,{pending:!0,data:w,method:s.method,action:c},c,w))},currentTarget:s}]})}}for(var Jc=0;Jc<_o.length;Jc++){var Wc=_o[Jc],$b=Wc.toLowerCase(),ey=Wc[0].toUpperCase()+Wc.slice(1);il($b,"on"+ey)}il(jd,"onAnimationEnd"),il(kd,"onAnimationIteration"),il(Md,"onAnimationStart"),il("dblclick","onDoubleClick"),il("focusin","onFocus"),il("focusout","onBlur"),il(gb,"onTransitionRun"),il(bb,"onTransitionStart"),il(yb,"onTransitionCancel"),il(_d,"onTransitionEnd"),Al("onMouseEnter",["mouseout","mouseover"]),Al("onMouseLeave",["mouseout","mouseover"]),Al("onPointerEnter",["pointerout","pointerover"]),Al("onPointerLeave",["pointerout","pointerover"]),ml("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ml("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ml("onBeforeInput",["compositionend","keypress","textInput","paste"]),ml("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ml("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ml("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var wr="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(" "),ty=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(wr));function em(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var l=e[n],s=l.event;l=l.listeners;e:{var c=void 0;if(t)for(var h=l.length-1;0<=h;h--){var g=l[h],w=g.instance,k=g.currentTarget;if(g=g.listener,w!==c&&s.isPropagationStopped())break e;c=g,s.currentTarget=k;try{c(s)}catch(B){ns(B)}s.currentTarget=null,c=w}else for(h=0;h<l.length;h++){if(g=l[h],w=g.instance,k=g.currentTarget,g=g.listener,w!==c&&s.isPropagationStopped())break e;c=g,s.currentTarget=k;try{c(s)}catch(B){ns(B)}s.currentTarget=null,c=w}}}}function Fe(e,t){var n=t[U];n===void 0&&(n=t[U]=new Set);var l=e+"__bubble";n.has(l)||(tm(t,e,2,!1),n.add(l))}function Pc(e,t,n){var l=0;t&&(l|=4),tm(n,e,l,t)}var Gs="_reactListening"+Math.random().toString(36).slice(2);function $c(e){if(!e[Gs]){e[Gs]=!0,ka.forEach(function(n){n!=="selectionchange"&&(ty.has(n)||Pc(n,!1,e),Pc(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Gs]||(t[Gs]=!0,Pc("selectionchange",!1,t))}}function tm(e,t,n,l){switch(km(t)){case 2:var s=jy;break;case 8:s=ky;break;default:s=mu}n=s.bind(null,t,n,e),s=void 0,!cn||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),l?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function eu(e,t,n,l,s){var c=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var h=l.tag;if(h===3||h===4){var g=l.stateNode.containerInfo;if(g===s)break;if(h===4)for(h=l.return;h!==null;){var w=h.tag;if((w===3||w===4)&&h.stateNode.containerInfo===s)return;h=h.return}for(;g!==null;){if(h=Bt(g),h===null)return;if(w=h.tag,w===5||w===6||w===26||w===27){l=c=h;continue e}g=g.parentNode}}l=l.return}Me(function(){var k=c,B=ea(n),K=[];e:{var M=zd.get(e);if(M!==void 0){var O=_a,ue=e;switch(e){case"keypress":if(un(n)===0)break e;case"keydown":case"keyup":O=Zg;break;case"focusin":ue="focus",O=Co;break;case"focusout":ue="blur",O=Co;break;case"beforeblur":case"afterblur":O=Co;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":O=od;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":O=Og;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":O=Wg;break;case jd:case kd:case Md:O=Hg;break;case _d:O=$g;break;case"scroll":case"scrollend":O=$r;break;case"wheel":O=tb;break;case"copy":case"cut":case"paste":O=Kg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":O=ud;break;case"toggle":case"beforetoggle":O=lb}var Ne=(t&4)!==0,dt=!Ne&&(e==="scroll"||e==="scrollend"),N=Ne?M!==null?M+"Capture":null:M;Ne=[];for(var C=k,j;C!==null;){var Y=C;if(j=Y.stateNode,Y=Y.tag,Y!==5&&Y!==26&&Y!==27||j===null||N===null||(Y=ht(C,N),Y!=null&&Ne.push(Cr(C,Y,j))),dt)break;C=C.return}0<Ne.length&&(M=new O(M,ue,null,n,B),K.push({event:M,listeners:Ne}))}}if((t&7)===0){e:{if(M=e==="mouseover"||e==="pointerover",O=e==="mouseout"||e==="pointerout",M&&n!==$l&&(ue=n.relatedTarget||n.fromElement)&&(Bt(ue)||ue[L]))break e;if((O||M)&&(M=B.window===B?B:(M=B.ownerDocument)?M.defaultView||M.parentWindow:window,O?(ue=n.relatedTarget||n.toElement,O=k,ue=ue?Bt(ue):null,ue!==null&&(dt=f(ue),Ne=ue.tag,ue!==dt||Ne!==5&&Ne!==27&&Ne!==6)&&(ue=null)):(O=null,ue=k),O!==ue)){if(Ne=od,Y="onMouseLeave",N="onMouseEnter",C="mouse",(e==="pointerout"||e==="pointerover")&&(Ne=ud,Y="onPointerLeave",N="onPointerEnter",C="pointer"),dt=O==null?M:jn(O),j=ue==null?M:jn(ue),M=new Ne(Y,C+"leave",O,n,B),M.target=dt,M.relatedTarget=j,Y=null,Bt(B)===k&&(Ne=new Ne(N,C+"enter",ue,n,B),Ne.target=j,Ne.relatedTarget=dt,Y=Ne),dt=Y,O&&ue)t:{for(Ne=ny,N=O,C=ue,j=0,Y=N;Y;Y=Ne(Y))j++;Y=0;for(var xe=C;xe;xe=Ne(xe))Y++;for(;0<j-Y;)N=Ne(N),j--;for(;0<Y-j;)C=Ne(C),Y--;for(;j--;){if(N===C||C!==null&&N===C.alternate){Ne=N;break t}N=Ne(N),C=Ne(C)}Ne=null}else Ne=null;O!==null&&nm(K,M,O,Ne,!1),ue!==null&&dt!==null&&nm(K,dt,ue,Ne,!0)}}e:{if(M=k?jn(k):window,O=M.nodeName&&M.nodeName.toLowerCase(),O==="select"||O==="input"&&M.type==="file")var $e=yd;else if(gd(M))if(vd)$e=hb;else{$e=db;var me=ub}else O=M.nodeName,!O||O.toLowerCase()!=="input"||M.type!=="checkbox"&&M.type!=="radio"?k&&El(k.elementType)&&($e=yd):$e=fb;if($e&&($e=$e(e,k))){bd(K,$e,n,B);break e}me&&me(e,M,k),e==="focusout"&&k&&M.type==="number"&&k.memoizedProps.value!=null&&Xi(M,"number",M.value)}switch(me=k?jn(k):window,e){case"focusin":(gd(me)||me.contentEditable==="true")&&(ai=me,jo=k,Pi=null);break;case"focusout":Pi=jo=ai=null;break;case"mousedown":ko=!0;break;case"contextmenu":case"mouseup":case"dragend":ko=!1,Ed(K,n,B);break;case"selectionchange":if(pb)break;case"keydown":case"keyup":Ed(K,n,B)}var De;if(No)e:{switch(e){case"compositionstart":var Ie="onCompositionStart";break e;case"compositionend":Ie="onCompositionEnd";break e;case"compositionupdate":Ie="onCompositionUpdate";break e}Ie=void 0}else li?md(e,n)&&(Ie="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(Ie="onCompositionStart");Ie&&(dd&&n.locale!=="ko"&&(li||Ie!=="onCompositionStart"?Ie==="onCompositionEnd"&&li&&(De=Mn()):(Rt=B,mt="value"in Rt?Rt.value:Rt.textContent,li=!0)),me=qs(k,Ie),0<me.length&&(Ie=new cd(Ie,e,null,n,B),K.push({event:Ie,listeners:me}),De?Ie.data=De:(De=pd(n),De!==null&&(Ie.data=De)))),(De=ib?rb(e,n):sb(e,n))&&(Ie=qs(k,"onBeforeInput"),0<Ie.length&&(me=new cd("onBeforeInput","beforeinput",null,n,B),K.push({event:me,listeners:Ie}),me.data=De)),Pb(K,e,k,n,B)}em(K,t)})}function Cr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qs(e,t){for(var n=t+"Capture",l=[];e!==null;){var s=e,c=s.stateNode;if(s=s.tag,s!==5&&s!==26&&s!==27||c===null||(s=ht(e,n),s!=null&&l.unshift(Cr(e,s,c)),s=ht(e,t),s!=null&&l.push(Cr(e,s,c))),e.tag===3)return l;e=e.return}return[]}function ny(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function nm(e,t,n,l,s){for(var c=t._reactName,h=[];n!==null&&n!==l;){var g=n,w=g.alternate,k=g.stateNode;if(g=g.tag,w!==null&&w===l)break;g!==5&&g!==26&&g!==27||k===null||(w=k,s?(k=ht(n,c),k!=null&&h.unshift(Cr(n,k,w))):s||(k=ht(n,c),k!=null&&h.push(Cr(n,k,w)))),n=n.return}h.length!==0&&e.push({event:t,listeners:h})}var ly=/\r\n?/g,ay=/\u0000|\uFFFD/g;function lm(e){return(typeof e=="string"?e:""+e).replace(ly,`
33
+ `).replace(ay,"")}function am(e,t){return t=lm(t),lm(e)===t}function ut(e,t,n,l,s,c){switch(n){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||Pl(e,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&Pl(e,""+l);break;case"className":te(e,"class",l);break;case"tabIndex":te(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":te(e,n,l);break;case"style":Wr(e,l,c);break;case"data":if(t!=="object"){te(e,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(n);break}l=Ma(""+l),e.setAttribute(n,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof c=="function"&&(n==="formAction"?(t!=="input"&&ut(e,t,"name",s.name,s,null),ut(e,t,"formEncType",s.formEncType,s,null),ut(e,t,"formMethod",s.formMethod,s,null),ut(e,t,"formTarget",s.formTarget,s,null)):(ut(e,t,"encType",s.encType,s,null),ut(e,t,"method",s.method,s,null),ut(e,t,"target",s.target,s,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(n);break}l=Ma(""+l),e.setAttribute(n,l);break;case"onClick":l!=null&&(e.onclick=gn);break;case"onScroll":l!=null&&Fe("scroll",e);break;case"onScrollEnd":l!=null&&Fe("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(n=l.__html,n!=null){if(s.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}n=Ma(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(n,""+l):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":l===!0?e.setAttribute(n,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(n,l):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(n,l):e.removeAttribute(n);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(n):e.setAttribute(n,l);break;case"popover":Fe("beforetoggle",e),Fe("toggle",e),ze(e,"popover",l);break;case"xlinkActuate":Nt(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Nt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Nt(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Nt(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Nt(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Nt(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Nt(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Nt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Nt(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":ze(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=al.get(n)||n,ze(e,n,l))}}function tu(e,t,n,l,s,c){switch(n){case"style":Wr(e,l,c);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(o(61));if(n=l.__html,n!=null){if(s.children!=null)throw Error(o(60));e.innerHTML=n}}break;case"children":typeof l=="string"?Pl(e,l):(typeof l=="number"||typeof l=="bigint")&&Pl(e,""+l);break;case"onScroll":l!=null&&Fe("scroll",e);break;case"onScrollEnd":l!=null&&Fe("scrollend",e);break;case"onClick":l!=null&&(e.onclick=gn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Vi.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(s=n.endsWith("Capture"),t=n.slice(2,s?n.length-7:void 0),c=e[Qt]||null,c=c!=null?c[n]:null,typeof c=="function"&&e.removeEventListener(t,c,s),typeof l=="function")){typeof c!="function"&&c!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,l,s);break e}n in e?e[n]=l:l===!0?e.setAttribute(n,""):ze(e,n,l)}}}function an(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Fe("error",e),Fe("load",e);var l=!1,s=!1,c;for(c in n)if(n.hasOwnProperty(c)){var h=n[c];if(h!=null)switch(c){case"src":l=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:ut(e,t,c,h,n,null)}}s&&ut(e,t,"srcSet",n.srcSet,n,null),l&&ut(e,t,"src",n.src,n,null);return;case"input":Fe("invalid",e);var g=c=h=s=null,w=null,k=null;for(l in n)if(n.hasOwnProperty(l)){var B=n[l];if(B!=null)switch(l){case"name":s=B;break;case"type":h=B;break;case"checked":w=B;break;case"defaultChecked":k=B;break;case"value":c=B;break;case"defaultValue":g=B;break;case"children":case"dangerouslySetInnerHTML":if(B!=null)throw Error(o(137,t));break;default:ut(e,t,l,B,n,null)}}Ir(e,c,g,w,k,h,s,!1);return;case"select":Fe("invalid",e),l=h=c=null;for(s in n)if(n.hasOwnProperty(s)&&(g=n[s],g!=null))switch(s){case"value":c=g;break;case"defaultValue":h=g;break;case"multiple":l=g;default:ut(e,t,s,g,n,null)}t=c,n=h,e.multiple=!!l,t!=null?Wl(e,!!l,t,!1):n!=null&&Wl(e,!!l,n,!0);return;case"textarea":Fe("invalid",e),c=s=l=null;for(h in n)if(n.hasOwnProperty(h)&&(g=n[h],g!=null))switch(h){case"value":l=g;break;case"defaultValue":s=g;break;case"children":c=g;break;case"dangerouslySetInnerHTML":if(g!=null)throw Error(o(91));break;default:ut(e,t,h,g,n,null)}Qr(e,l,s,c);return;case"option":for(w in n)if(n.hasOwnProperty(w)&&(l=n[w],l!=null))switch(w){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:ut(e,t,w,l,n,null)}return;case"dialog":Fe("beforetoggle",e),Fe("toggle",e),Fe("cancel",e),Fe("close",e);break;case"iframe":case"object":Fe("load",e);break;case"video":case"audio":for(l=0;l<wr.length;l++)Fe(wr[l],e);break;case"image":Fe("error",e),Fe("load",e);break;case"details":Fe("toggle",e);break;case"embed":case"source":case"link":Fe("error",e),Fe("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(k in n)if(n.hasOwnProperty(k)&&(l=n[k],l!=null))switch(k){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,t));default:ut(e,t,k,l,n,null)}return;default:if(El(t)){for(B in n)n.hasOwnProperty(B)&&(l=n[B],l!==void 0&&tu(e,t,B,l,n,void 0));return}}for(g in n)n.hasOwnProperty(g)&&(l=n[g],l!=null&&ut(e,t,g,l,n,null))}function iy(e,t,n,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var s=null,c=null,h=null,g=null,w=null,k=null,B=null;for(O in n){var K=n[O];if(n.hasOwnProperty(O)&&K!=null)switch(O){case"checked":break;case"value":break;case"defaultValue":w=K;default:l.hasOwnProperty(O)||ut(e,t,O,null,l,K)}}for(var M in l){var O=l[M];if(K=n[M],l.hasOwnProperty(M)&&(O!=null||K!=null))switch(M){case"type":c=O;break;case"name":s=O;break;case"checked":k=O;break;case"defaultChecked":B=O;break;case"value":h=O;break;case"defaultValue":g=O;break;case"children":case"dangerouslySetInnerHTML":if(O!=null)throw Error(o(137,t));break;default:O!==K&&ut(e,t,M,O,l,K)}}Fi(e,h,g,w,k,B,c,s);return;case"select":O=h=g=M=null;for(c in n)if(w=n[c],n.hasOwnProperty(c)&&w!=null)switch(c){case"value":break;case"multiple":O=w;default:l.hasOwnProperty(c)||ut(e,t,c,null,l,w)}for(s in l)if(c=l[s],w=n[s],l.hasOwnProperty(s)&&(c!=null||w!=null))switch(s){case"value":M=c;break;case"defaultValue":g=c;break;case"multiple":h=c;default:c!==w&&ut(e,t,s,c,l,w)}t=g,n=h,l=O,M!=null?Wl(e,!!n,M,!1):!!l!=!!n&&(t!=null?Wl(e,!!n,t,!0):Wl(e,!!n,n?[]:"",!1));return;case"textarea":O=M=null;for(g in n)if(s=n[g],n.hasOwnProperty(g)&&s!=null&&!l.hasOwnProperty(g))switch(g){case"value":break;case"children":break;default:ut(e,t,g,null,l,s)}for(h in l)if(s=l[h],c=n[h],l.hasOwnProperty(h)&&(s!=null||c!=null))switch(h){case"value":M=s;break;case"defaultValue":O=s;break;case"children":break;case"dangerouslySetInnerHTML":if(s!=null)throw Error(o(91));break;default:s!==c&&ut(e,t,h,s,l,c)}Zr(e,M,O);return;case"option":for(var ue in n)if(M=n[ue],n.hasOwnProperty(ue)&&M!=null&&!l.hasOwnProperty(ue))switch(ue){case"selected":e.selected=!1;break;default:ut(e,t,ue,null,l,M)}for(w in l)if(M=l[w],O=n[w],l.hasOwnProperty(w)&&M!==O&&(M!=null||O!=null))switch(w){case"selected":e.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:ut(e,t,w,M,l,O)}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 Ne in n)M=n[Ne],n.hasOwnProperty(Ne)&&M!=null&&!l.hasOwnProperty(Ne)&&ut(e,t,Ne,null,l,M);for(k in l)if(M=l[k],O=n[k],l.hasOwnProperty(k)&&M!==O&&(M!=null||O!=null))switch(k){case"children":case"dangerouslySetInnerHTML":if(M!=null)throw Error(o(137,t));break;default:ut(e,t,k,M,l,O)}return;default:if(El(t)){for(var dt in n)M=n[dt],n.hasOwnProperty(dt)&&M!==void 0&&!l.hasOwnProperty(dt)&&tu(e,t,dt,void 0,l,M);for(B in l)M=l[B],O=n[B],!l.hasOwnProperty(B)||M===O||M===void 0&&O===void 0||tu(e,t,B,M,l,O);return}}for(var N in n)M=n[N],n.hasOwnProperty(N)&&M!=null&&!l.hasOwnProperty(N)&&ut(e,t,N,null,l,M);for(K in l)M=l[K],O=n[K],!l.hasOwnProperty(K)||M===O||M==null&&O==null||ut(e,t,K,M,l,O)}function im(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ry(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),l=0;l<n.length;l++){var s=n[l],c=s.transferSize,h=s.initiatorType,g=s.duration;if(c&&g&&im(h)){for(h=0,g=s.responseEnd,l+=1;l<n.length;l++){var w=n[l],k=w.startTime;if(k>g)break;var B=w.transferSize,K=w.initiatorType;B&&im(K)&&(w=w.responseEnd,h+=B*(w<g?1:(g-k)/(w-k)))}if(--l,t+=8*(c+h)/(s.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 nu=null,lu=null;function Vs(e){return e.nodeType===9?e:e.ownerDocument}function rm(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 sm(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 au(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 iu=null;function sy(){var e=window.event;return e&&e.type==="popstate"?e===iu?!1:(iu=e,!0):(iu=null,!1)}var om=typeof setTimeout=="function"?setTimeout:void 0,oy=typeof clearTimeout=="function"?clearTimeout:void 0,cm=typeof Promise=="function"?Promise:void 0,cy=typeof queueMicrotask=="function"?queueMicrotask:typeof cm<"u"?function(e){return cm.resolve(null).then(e).catch(uy)}:om;function uy(e){setTimeout(function(){throw e})}function va(e){return e==="head"}function um(e,t){var n=t,l=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"||n==="/&"){if(l===0){e.removeChild(s),Mi(t);return}l--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")l++;else if(n==="html")Tr(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Tr(n);for(var c=n.firstChild;c;){var h=c.nextSibling,g=c.nodeName;c[Ee]||g==="SCRIPT"||g==="STYLE"||g==="LINK"&&c.rel.toLowerCase()==="stylesheet"||n.removeChild(c),c=h}}else n==="body"&&Tr(e.ownerDocument.body);n=s}while(n);Mi(t)}function dm(e,t){var n=e;e=0;do{var l=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=l}while(n)}function ru(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":ru(n),Oe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function dy(e,t,n,l){for(;e.nodeType===1;){var s=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[Ee])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(c=e.getAttribute("rel"),c==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(c!==s.rel||e.getAttribute("href")!==(s.href==null||s.href===""?null:s.href)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin)||e.getAttribute("title")!==(s.title==null?null:s.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(c=e.getAttribute("src"),(c!==(s.src==null?null:s.src)||e.getAttribute("type")!==(s.type==null?null:s.type)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin))&&c&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var c=s.name==null?null:""+s.name;if(s.type==="hidden"&&e.getAttribute("name")===c)return e}else return e;if(e=Qn(e.nextSibling),e===null)break}return null}function fy(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Qn(e.nextSibling),e===null))return null;return e}function fm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Qn(e.nextSibling),e===null))return null;return e}function su(e){return e.data==="$?"||e.data==="$~"}function ou(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function hy(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var l=function(){t(),n.removeEventListener("DOMContentLoaded",l)};n.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function Qn(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 cu=null;function hm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Qn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function pm(e,t,n){switch(t=Vs(n),e){case"html":if(e=t.documentElement,!e)throw Error(o(452));return e;case"head":if(e=t.head,!e)throw Error(o(453));return e;case"body":if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Tr(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Oe(e)}var Jn=new Map,gm=new Set;function Fs(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Vl=F.d;F.d={f:my,r:py,D:gy,C:by,L:yy,m:vy,X:Sy,S:xy,M:wy};function my(){var e=Vl.f(),t=Os();return e||t}function py(e){var t=ft(e);t!==null&&t.tag===5&&t.type==="form"?zf(t):Vl.r(e)}var Ri=typeof document>"u"?null:document;function bm(e,t,n){var l=Ri;if(l&&typeof t=="string"&&t){var s=Jt(t);s='link[rel="'+e+'"][href="'+s+'"]',typeof n=="string"&&(s+='[crossorigin="'+n+'"]'),gm.has(s)||(gm.add(s),e={rel:e,crossOrigin:n,href:t},l.querySelector(s)===null&&(t=l.createElement("link"),an(t,"link",e),at(t),l.head.appendChild(t)))}}function gy(e){Vl.D(e),bm("dns-prefetch",e,null)}function by(e,t){Vl.C(e,t),bm("preconnect",e,t)}function yy(e,t,n){Vl.L(e,t,n);var l=Ri;if(l&&e&&t){var s='link[rel="preload"][as="'+Jt(t)+'"]';t==="image"&&n&&n.imageSrcSet?(s+='[imagesrcset="'+Jt(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(s+='[imagesizes="'+Jt(n.imageSizes)+'"]')):s+='[href="'+Jt(e)+'"]';var c=s;switch(t){case"style":c=ji(e);break;case"script":c=ki(e)}Jn.has(c)||(e=S({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Jn.set(c,e),l.querySelector(s)!==null||t==="style"&&l.querySelector(Nr(c))||t==="script"&&l.querySelector(Ar(c))||(t=l.createElement("link"),an(t,"link",e),at(t),l.head.appendChild(t)))}}function vy(e,t){Vl.m(e,t);var n=Ri;if(n&&e){var l=t&&typeof t.as=="string"?t.as:"script",s='link[rel="modulepreload"][as="'+Jt(l)+'"][href="'+Jt(e)+'"]',c=s;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":c=ki(e)}if(!Jn.has(c)&&(e=S({rel:"modulepreload",href:e},t),Jn.set(c,e),n.querySelector(s)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Ar(c)))return}l=n.createElement("link"),an(l,"link",e),at(l),n.head.appendChild(l)}}}function xy(e,t,n){Vl.S(e,t,n);var l=Ri;if(l&&e){var s=on(l).hoistableStyles,c=ji(e);t=t||"default";var h=s.get(c);if(!h){var g={loading:0,preload:null};if(h=l.querySelector(Nr(c)))g.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Jn.get(c))&&uu(e,n);var w=h=l.createElement("link");at(w),an(w,"link",e),w._p=new Promise(function(k,B){w.onload=k,w.onerror=B}),w.addEventListener("load",function(){g.loading|=1}),w.addEventListener("error",function(){g.loading|=2}),g.loading|=4,Xs(h,t,l)}h={type:"stylesheet",instance:h,count:1,state:g},s.set(c,h)}}}function Sy(e,t){Vl.X(e,t);var n=Ri;if(n&&e){var l=on(n).hoistableScripts,s=ki(e),c=l.get(s);c||(c=n.querySelector(Ar(s)),c||(e=S({src:e,async:!0},t),(t=Jn.get(s))&&du(e,t),c=n.createElement("script"),at(c),an(c,"link",e),n.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},l.set(s,c))}}function wy(e,t){Vl.M(e,t);var n=Ri;if(n&&e){var l=on(n).hoistableScripts,s=ki(e),c=l.get(s);c||(c=n.querySelector(Ar(s)),c||(e=S({src:e,async:!0,type:"module"},t),(t=Jn.get(s))&&du(e,t),c=n.createElement("script"),at(c),an(c,"link",e),n.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},l.set(s,c))}}function ym(e,t,n,l){var s=(s=Qe.current)?Fs(s):null;if(!s)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=ji(n.href),n=on(s).hoistableStyles,l=n.get(t),l||(l={type:"style",instance:null,count:0,state:null},n.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=ji(n.href);var c=on(s).hoistableStyles,h=c.get(e);if(h||(s=s.ownerDocument||s,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},c.set(e,h),(c=s.querySelector(Nr(e)))&&!c._p&&(h.instance=c,h.state.loading=5),Jn.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Jn.set(e,n),c||Cy(s,e,n,h.state))),t&&l===null)throw Error(o(528,""));return h}if(t&&l!==null)throw Error(o(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ki(n),n=on(s).hoistableScripts,l=n.get(t),l||(l={type:"script",instance:null,count:0,state:null},n.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function ji(e){return'href="'+Jt(e)+'"'}function Nr(e){return'link[rel="stylesheet"]['+e+"]"}function vm(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Cy(e,t,n,l){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=e.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),an(t,"link",n),at(t),e.head.appendChild(t))}function ki(e){return'[src="'+Jt(e)+'"]'}function Ar(e){return"script[async]"+e}function xm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var l=e.querySelector('style[data-href~="'+Jt(n.href)+'"]');if(l)return t.instance=l,at(l),l;var s=S({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),at(l),an(l,"style",s),Xs(l,n.precedence,e),t.instance=l;case"stylesheet":s=ji(n.href);var c=e.querySelector(Nr(s));if(c)return t.state.loading|=4,t.instance=c,at(c),c;l=vm(n),(s=Jn.get(s))&&uu(l,s),c=(e.ownerDocument||e).createElement("link"),at(c);var h=c;return h._p=new Promise(function(g,w){h.onload=g,h.onerror=w}),an(c,"link",l),t.state.loading|=4,Xs(c,n.precedence,e),t.instance=c;case"script":return c=ki(n.src),(s=e.querySelector(Ar(c)))?(t.instance=s,at(s),s):(l=n,(s=Jn.get(c))&&(l=S({},n),du(l,s)),e=e.ownerDocument||e,s=e.createElement("script"),at(s),an(s,"link",l),e.head.appendChild(s),t.instance=s);case"void":return null;default:throw Error(o(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,Xs(l,n.precedence,e));return t.instance}function Xs(e,t,n){for(var l=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),s=l.length?l[l.length-1]:null,c=s,h=0;h<l.length;h++){var g=l[h];if(g.dataset.precedence===t)c=g;else if(c!==s)break}c?c.parentNode.insertBefore(e,c.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function uu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function du(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Is=null;function Sm(e,t,n){if(Is===null){var l=new Map,s=Is=new Map;s.set(n,l)}else s=Is,l=s.get(n),l||(l=new Map,s.set(n,l));if(l.has(e))return l;for(l.set(e,null),n=n.getElementsByTagName(e),s=0;s<n.length;s++){var c=n[s];if(!(c[Ee]||c[Dt]||e==="link"&&c.getAttribute("rel")==="stylesheet")&&c.namespaceURI!=="http://www.w3.org/2000/svg"){var h=c.getAttribute(t)||"";h=e+h;var g=l.get(h);g?g.push(c):l.set(h,[c])}}return l}function wm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Ty(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Cm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Ny(e,t,n,l){if(n.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var s=ji(l.href),c=t.querySelector(Nr(s));if(c){t=c._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Zs.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=c,at(c);return}c=t.ownerDocument||t,l=vm(l),(s=Jn.get(s))&&uu(l,s),c=c.createElement("link"),at(c);var h=c;h._p=new Promise(function(g,w){h.onload=g,h.onerror=w}),an(c,"link",l),n.instance=c}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=Zs.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var fu=0;function Ay(e,t){return e.stylesheets&&e.count===0&&Js(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var l=setTimeout(function(){if(e.stylesheets&&Js(e,e.stylesheets),e.unsuspend){var c=e.unsuspend;e.unsuspend=null,c()}},6e4+t);0<e.imgBytes&&fu===0&&(fu=62500*ry());var s=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Js(e,e.stylesheets),e.unsuspend)){var c=e.unsuspend;e.unsuspend=null,c()}},(e.imgBytes>fu?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(s)}}:null}function Zs(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Js(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Qs=null;function Js(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Qs=new Map,t.forEach(Ey,e),Qs=null,Zs.call(e))}function Ey(e,t){if(!(t.state.loading&4)){var n=Qs.get(e);if(n)var l=n.get(null);else{n=new Map,Qs.set(e,n);for(var s=e.querySelectorAll("link[data-precedence],style[data-precedence]"),c=0;c<s.length;c++){var h=s[c];(h.nodeName==="LINK"||h.getAttribute("media")!=="not all")&&(n.set(h.dataset.precedence,h),l=h)}l&&n.set(null,l)}s=t.instance,h=s.getAttribute("data-precedence"),c=n.get(h)||l,c===l&&n.set(null,s),n.set(h,s),this.count++,l=Zs.bind(this),s.addEventListener("load",l),s.addEventListener("error",l),c?c.parentNode.insertBefore(s,c.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(s,e.firstChild)),t.state.loading|=4}}var Er={$$typeof:X,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function Ry(e,t,n,l,s,c,h,g,w){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=Kn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kn(0),this.hiddenUpdates=Kn(null),this.identifierPrefix=l,this.onUncaughtError=s,this.onCaughtError=c,this.onRecoverableError=h,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=w,this.incompleteTransitions=new Map}function Tm(e,t,n,l,s,c,h,g,w,k,B,K){return e=new Ry(e,t,n,h,w,k,B,K,g),t=1,c===!0&&(t|=24),c=zn(3,null,null,t),e.current=c,c.stateNode=e,t=Fo(),t.refCount++,e.pooledCache=t,t.refCount++,c.memoizedState={element:l,isDehydrated:n,cache:t},Qo(c),e}function Nm(e){return e?(e=si,e):si}function Am(e,t,n,l,s,c){s=Nm(s),l.context===null?l.context=s:l.pendingContext=s,l=oa(t),l.payload={element:n},c=c===void 0?null:c,c!==null&&(l.callback=c),n=ca(e,l,t),n!==null&&(Sn(n,e,t),ir(n,e,t))}function Em(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hu(e,t){Em(e,t),(e=e.alternate)&&Em(e,t)}function Rm(e){if(e.tag===13||e.tag===31){var t=La(e,67108864);t!==null&&Sn(t,e,67108864),hu(e,67108864)}}function jm(e){if(e.tag===13||e.tag===31){var t=Bn();t=Zl(t);var n=La(e,t);n!==null&&Sn(n,e,t),hu(e,t)}}var Ws=!0;function jy(e,t,n,l){var s=D.T;D.T=null;var c=F.p;try{F.p=2,mu(e,t,n,l)}finally{F.p=c,D.T=s}}function ky(e,t,n,l){var s=D.T;D.T=null;var c=F.p;try{F.p=8,mu(e,t,n,l)}finally{F.p=c,D.T=s}}function mu(e,t,n,l){if(Ws){var s=pu(l);if(s===null)eu(e,t,l,Ps,n),Mm(e,l);else if(_y(s,e,t,n,l))l.stopPropagation();else if(Mm(e,l),t&4&&-1<My.indexOf(e)){for(;s!==null;){var c=ft(s);if(c!==null)switch(c.tag){case 3:if(c=c.stateNode,c.current.memoizedState.isDehydrated){var h=mn(c.pendingLanes);if(h!==0){var g=c;for(g.pendingLanes|=2,g.entangledLanes|=2;h;){var w=1<<31-Tt(h);g.entanglements[1]|=w,h&=~w}xl(c),(lt&6)===0&&(Ds=ae()+500,Sr(0))}}break;case 31:case 13:g=La(c,2),g!==null&&Sn(g,c,2),Os(),hu(c,2)}if(c=pu(l),c===null&&eu(e,t,l,Ps,n),c===s)break;s=c}s!==null&&l.stopPropagation()}else eu(e,t,l,null,n)}}function pu(e){return e=ea(e),gu(e)}var Ps=null;function gu(e){if(Ps=null,e=Bt(e),e!==null){var t=f(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=p(t),e!==null)return e;e=null}else if(n===31){if(e=m(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ps=e,null}function km(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(Ae()){case Le:return 2;case ot:return 8;case sn:case bt:return 32;case zt:return 268435456;default:return 32}default:return 32}}var bu=!1,xa=null,Sa=null,wa=null,Rr=new Map,jr=new Map,Ca=[],My="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 Mm(e,t){switch(e){case"focusin":case"focusout":xa=null;break;case"dragenter":case"dragleave":Sa=null;break;case"mouseover":case"mouseout":wa=null;break;case"pointerover":case"pointerout":Rr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":jr.delete(t.pointerId)}}function kr(e,t,n,l,s,c){return e===null||e.nativeEvent!==c?(e={blockedOn:t,domEventName:n,eventSystemFlags:l,nativeEvent:c,targetContainers:[s]},t!==null&&(t=ft(t),t!==null&&Rm(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function _y(e,t,n,l,s){switch(t){case"focusin":return xa=kr(xa,e,t,n,l,s),!0;case"dragenter":return Sa=kr(Sa,e,t,n,l,s),!0;case"mouseover":return wa=kr(wa,e,t,n,l,s),!0;case"pointerover":var c=s.pointerId;return Rr.set(c,kr(Rr.get(c)||null,e,t,n,l,s)),!0;case"gotpointercapture":return c=s.pointerId,jr.set(c,kr(jr.get(c)||null,e,t,n,l,s)),!0}return!1}function _m(e){var t=Bt(e.target);if(t!==null){var n=f(t);if(n!==null){if(t=n.tag,t===13){if(t=p(n),t!==null){e.blockedOn=t,Ql(e.priority,function(){jm(n)});return}}else if(t===31){if(t=m(n),t!==null){e.blockedOn=t,Ql(e.priority,function(){jm(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function $s(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pu(e.nativeEvent);if(n===null){n=e.nativeEvent;var l=new n.constructor(n.type,n);$l=l,n.target.dispatchEvent(l),$l=null}else return t=ft(n),t!==null&&Rm(t),e.blockedOn=n,!1;t.shift()}return!0}function zm(e,t,n){$s(e)&&n.delete(t)}function zy(){bu=!1,xa!==null&&$s(xa)&&(xa=null),Sa!==null&&$s(Sa)&&(Sa=null),wa!==null&&$s(wa)&&(wa=null),Rr.forEach(zm),jr.forEach(zm)}function eo(e,t){e.blockedOn===t&&(e.blockedOn=null,bu||(bu=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,zy)))}var to=null;function Dm(e){to!==e&&(to=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){to===e&&(to=null);for(var t=0;t<e.length;t+=3){var n=e[t],l=e[t+1],s=e[t+2];if(typeof l!="function"){if(gu(l||n)===null)continue;break}var c=ft(n);c!==null&&(e.splice(t,3),t-=3,pc(c,{pending:!0,data:s,method:n.method,action:l},l,s))}}))}function Mi(e){function t(w){return eo(w,e)}xa!==null&&eo(xa,e),Sa!==null&&eo(Sa,e),wa!==null&&eo(wa,e),Rr.forEach(t),jr.forEach(t);for(var n=0;n<Ca.length;n++){var l=Ca[n];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Ca.length&&(n=Ca[0],n.blockedOn===null);)_m(n),n.blockedOn===null&&Ca.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(l=0;l<n.length;l+=3){var s=n[l],c=n[l+1],h=s[Qt]||null;if(typeof c=="function")h||Dm(n);else if(h){var g=null;if(c&&c.hasAttribute("formAction")){if(s=c,h=c[Qt]||null)g=h.formAction;else if(gu(s)!==null)continue}else g=h.action;typeof g=="function"?n[l+1]=g:(n.splice(l,3),l-=3),Dm(n)}}}function Lm(){function e(c){c.canIntercept&&c.info==="react-transition"&&c.intercept({handler:function(){return new Promise(function(h){return s=h})},focusReset:"manual",scroll:"manual"})}function t(){s!==null&&(s(),s=null),l||setTimeout(n,20)}function n(){if(!l&&!navigation.transition){var c=navigation.currentEntry;c&&c.url!=null&&navigation.navigate(c.url,{state:c.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,s=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),s!==null&&(s(),s=null)}}}function yu(e){this._internalRoot=e}no.prototype.render=yu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current,l=Bn();Am(n,l,e,t,null,null)},no.prototype.unmount=yu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Am(e.current,2,null,e,null,null),Os(),t[L]=null}};function no(e){this._internalRoot=e}no.prototype.unstable_scheduleHydration=function(e){if(e){var t=Nl();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ca.length&&t!==0&&t<Ca[n].priority;n++);Ca.splice(n,0,e),n===0&&_m(e)}};var Om=a.version;if(Om!=="19.2.8")throw Error(o(527,Om,"19.2.8"));F.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=v(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Dy={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lo.isDisabled&&lo.supportsFiber)try{Ut=lo.inject(Dy),yt=lo}catch{}}return _r.createRoot=function(e,t){if(!d(e))throw Error(o(299));var n=!1,l="",s=qf,c=Vf,h=Ff;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(s=t.onUncaughtError),t.onCaughtError!==void 0&&(c=t.onCaughtError),t.onRecoverableError!==void 0&&(h=t.onRecoverableError)),t=Tm(e,1,!1,null,null,n,l,null,s,c,h,Lm),e[L]=t.current,$c(e),new yu(t)},_r.hydrateRoot=function(e,t,n){if(!d(e))throw Error(o(299));var l=!1,s="",c=qf,h=Vf,g=Ff,w=null;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onUncaughtError!==void 0&&(c=n.onUncaughtError),n.onCaughtError!==void 0&&(h=n.onCaughtError),n.onRecoverableError!==void 0&&(g=n.onRecoverableError),n.formState!==void 0&&(w=n.formState)),t=Tm(e,1,!0,t,n??null,l,s,w,c,h,g,Lm),t.context=Nm(null),n=t.current,l=Bn(),l=Zl(l),s=oa(l),s.callback=null,ca(n,s,l),n=l,t.current.lanes=n,Rn(t,n),xl(t),e[L]=t.current,$c(e),new no(t)},_r.version="19.2.8",_r}var Gm;function Xy(){if(Gm)return xu.exports;Gm=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(a){console.error(a)}}return r(),xu.exports=Fy(),xu.exports}var Iy=Xy();const Zy=_p(Iy),ge={ESC:"\x1B",TAB:" ",SHIFT_TAB:"\x1B[Z",ENTER:"\r",BACKSPACE:"",UP:"\x1B[A",DOWN:"\x1B[B",RIGHT:"\x1B[C",LEFT:"\x1B[D",HOME:"\x1B[H",END:"\x1B[F",PAGE_UP:"\x1B[5~",PAGE_DOWN:"\x1B[6~",INSERT:"\x1B[2~",DELETE:"\x1B[3~",CTRL_C:"",CTRL_D:"",CTRL_Z:"",CTRL_L:"\f",CTRL_A:"",CTRL_E:"",CTRL_K:"\v",CTRL_R:"",CTRL_W:"",CTRL_U:"",CTRL_X:"",CTRL_N:"",CTRL_P:"",F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"},Qy=new TextEncoder;function Iu(r){return Qy.encode(r)}function Jy(r){if(!r||r.length===0)return"";const i=r.toUpperCase().charCodeAt(0);return i>=65&&i<=90?String.fromCharCode(i-64):r==="@"||r===" "?"\0":r==="["?"\x1B":r==="\\"?"":r==="]"?"":r==="^"?"":r==="_"?"":r==="?"?"":r}function Wy(r){return`\x1B${r}`}function qm({ctrl:r,alt:a,shift:i}){return 1+(i?1:0)+(a?2:0)+(r?4:0)}const Dp=/^\x1b[[O]([ABCDHF])$/,Lp=/^\x1bO([PQRS])$/,Op=/^\x1b\[(\d+)~$/;function Up(r,a){const{ctrl:i=!1,alt:o=!1,shift:d=!1}=a;if(!i&&!o&&!d)return r;const f=qm(a),p=o&&!i&&!d,m=Dp.exec(r);if(m)return`\x1B[1;${f}${m[1]}`;const b=Lp.exec(r);if(b)return`\x1B[1;${f}${b[1]}`;const v=Op.exec(r);if(v)return`\x1B[${v[1]};${f}~`;switch(r){case ge.TAB:return d&&!i&&!o?ge.SHIFT_TAB:p?`\x1B${r}`:`\x1B[9;${f}u`;case ge.SHIFT_TAB:return!i&&!o?r:`\x1B[9;${qm({...a,shift:!0})}u`;case ge.ENTER:return p?`\x1B${r}`:`\x1B[13;${f}u`;case ge.BACKSPACE:return i&&!o&&!d?"\b":p?`\x1B${r}`:`\x1B[127;${f}u`;case ge.ESC:return p?`\x1B${r}`:`\x1B[27;${f}u`}let y=r;return d&&r.length===1&&!i&&(y=r.toUpperCase()),i&&(y=Jy(y)),o&&(y=Wy(y)),y}function Py(r){return[...r].length===1?!0:Dp.test(r)||Lp.test(r)||Op.test(r)||r===ge.SHIFT_TAB}const Bp=27,Hp=91,$y=60,Vm=59,Yp=77,Kp=48,ev=57,tv=64,nv=-30,Cu=32,Fm=255;function Gp(r){return Number.isInteger(r)&&(r&nv)===tv}function lv(r){return r>=Kp&&r<=ev}function Tu(r,a){let i=a,o=0;for(;i<r.length&&lv(r[i]);){if(o=o*10+(r[i]-Kp),o>65535)return null;i+=1}return i===a?null:{value:o,next:i}}function av(r,a){if(r[a]!==Bp||r[a+1]!==Hp||r[a+2]!==$y)return-1;const i=Tu(r,a+3);if(!i||!Gp(i.value)||r[i.next]!==Vm)return-1;const o=Tu(r,i.next+1);if(!o||r[o.next]!==Vm)return-1;const d=Tu(r,o.next+1);return!d||r[d.next]!==Yp?-1:d.next+1}function iv(r,a){if(r[a]!==Bp||r[a+1]!==Hp||r[a+2]!==Yp||a+6>r.length)return-1;const i=r[a+3]-Cu,o=r[a+4],d=r[a+5];return!Gp(i)||o<Cu||o>Fm||d<Cu||d>Fm?-1:a+6}function mo(r){if(!r)return!1;const a=r instanceof Uint8Array?r:new Uint8Array(r);if(a.length===0)return!1;let i=0;for(;i<a.length;){const o=av(a,i);if(o>i){i=o;continue}const d=iv(a,i);if(d>i){i=d;continue}return!1}return!0}const rv=3e3,sv=1e4,ov=1500;class cv{constructor(a){se(this,"ws",null);se(this,"config");se(this,"state","disconnected");se(this,"currentRole","viewer");se(this,"controllerId");se(this,"hostId");se(this,"assignedClientId");se(this,"reconnectAttempts",0);se(this,"reconnectTimer",null);se(this,"pingTimer",null);se(this,"pingTimestamp",null);se(this,"lastInboundAt",0);se(this,"pingSentAt",null);se(this,"connectStartedAt",0);se(this,"lastWakeConnectAt",0);se(this,"probeTimer",null);se(this,"rejectedByRelay",!1);se(this,"isManuallyClosed",!1);se(this,"authFailureDetail",null);se(this,"authFailureCode",null);se(this,"temporaryFailureCode",null);se(this,"pendingInputSegments",[]);se(this,"isFlushScheduled",!1);se(this,"listeners",{stateChange:new Set,roleChange:new Set,ready:new Set,paired:new Set,controlState:new Set,controlRevoked:new Set,sessionReady:new Set,exit:new Set,controlGranted:new Set,controlDenied:new Set,status:new Set,peerCount:new Set,hostReconnecting:new Set,sessionRestarted:new Set,error:new Set,binaryData:new Set,rttUpdate:new Set,pasteFileReady:new Set,agentStatus:new Set});se(this,"terminalCols",80);se(this,"terminalRows",24);this.config={...a}}updateConfig(a){this.config={...this.config,...a}}getConfig(){return{...this.config}}getState(){return this.state}getRole(){return this.currentRole}getControllerId(){return this.controllerId}getHostId(){return this.hostId}getAssignedClientId(){return this.assignedClientId}on(a,i){return this.listeners[a].add(i),()=>{this.listeners[a].delete(i)}}emit(a,...i){this.listeners[a].forEach(d=>{try{d(...i)}catch(f){console.error(`Error in event listener for ${a}:`,f)}})}setState(a,i,o){this.state!==a&&(this.state=a,this.emit("stateChange",a,i,o))}connect(a){if(a&&(this.terminalCols=a.cols,this.terminalRows=a.rows),!(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))){this.teardownSocket(1e3,"Replaced by a new connection"),this.isManuallyClosed=!1,this.authFailureDetail=null,this.authFailureCode=null,this.temporaryFailureCode=null,this.rejectedByRelay=!1,this.clearTimers(),this.setState("connecting");try{const i=this.resolveWsUrl(this.config.wsUrl),o=new WebSocket(i);this.ws=o,this.connectStartedAt=Date.now(),o.binaryType="arraybuffer",o.onopen=()=>{this.isStaleSocket(o)||this.handleOpen()},o.onmessage=d=>{this.isStaleSocket(o)||this.handleMessage(d)},o.onerror=d=>{this.isStaleSocket(o)||this.handleError(d)},o.onclose=d=>{this.isStaleSocket(o)||this.handleClose(d)}}catch(i){this.setState("error",i instanceof Error?i.message:"Connection failed","connection_failed"),this.scheduleReconnect()}}}isStaleSocket(a){return this.ws!==a}teardownSocket(a=1e3,i="Client closed the connection"){this.pendingInputSegments=[],this.isFlushScheduled=!1;const o=this.ws;if(o){this.ws=null,o.onopen=null,o.onmessage=null,o.onerror=null,o.onclose=null;try{(o.readyState===WebSocket.OPEN||o.readyState===WebSocket.CONNECTING)&&o.close(a,i)}catch{}}}disconnect(){this.isManuallyClosed=!0,this.clearTimers(),this.pendingInputSegments=[],this.isFlushScheduled=!1,this.teardownSocket(1e3,"User initiated disconnect"),this.setState("disconnected")}reconnectWith(a){this.updateConfig(a),this.clearTimers(),this.teardownSocket(1e3,"Reconnecting with new credentials"),this.isManuallyClosed=!1,this.reconnectAttempts=0,this.authFailureDetail=null,this.authFailureCode=null,this.temporaryFailureCode=null,this.connect()}wake(a){if(this.isManuallyClosed||!this.config.autoReconnect||this.authFailureDetail||this.rejectedByRelay)return;const i=Date.now(),o=this.ws;if(!o){if(i-this.lastWakeConnectAt<ov)return;this.lastWakeConnectAt=i,this.reconnectAttempts=0,this.connect();return}if(o.readyState===WebSocket.CONNECTING){i-this.connectStartedAt>sv&&this.dropStaleSocket("connection_stalled");return}o.readyState===WebSocket.OPEN&&i-this.lastInboundAt>this.pingIntervalMs()+2e3&&this.probeLiveness()}pingIntervalMs(){return this.config.pingIntervalMs||1e4}probeLiveness(){const a=this.ws;if(!a||a.readyState!==WebSocket.OPEN||this.probeTimer)return;const i=Date.now();this.sendPing(),this.probeTimer=setTimeout(()=>{this.probeTimer=null,this.ws===a&&this.lastInboundAt<i&&this.dropStaleSocket("connection_stale")},rv)}dropStaleSocket(a){this.clearTimers(),this.teardownSocket(4e3,"Connection went silent"),this.setState("reconnecting","The connection went silent. Reconnecting...",a),this.reconnectAttempts=0,this.lastWakeConnectAt=Date.now(),this.connect()}handleOpen(){this.lastInboundAt=Date.now(),this.sendHello(),this.startHeartbeat()}async handleMessage(a){if(this.lastInboundAt=Date.now(),typeof a.data=="string")try{const i=JSON.parse(a.data);this.processJsonMessage(i)}catch(i){console.warn("Received unparseable text frame from server:",i)}else if(a.data instanceof ArrayBuffer)this.emit("binaryData",new Uint8Array(a.data));else if(typeof Blob<"u"&&a.data instanceof Blob)try{const i=await a.data.arrayBuffer();this.emit("binaryData",new Uint8Array(i))}catch(i){console.error("Failed to convert Blob to ArrayBuffer:",i)}}processJsonMessage(a){switch(a.type){case"ready":{this.reconnectAttempts=0,this.setState("connected"),this.currentRole=a.role,this.controllerId=a.controllerId,this.hostId=a.hostId,this.assignedClientId=a.clientId,this.emit("ready",a),this.emit("roleChange",a.role,a.controllerId,a.hostId,a.clientId),typeof a.clientCount=="number"&&this.emit("peerCount",a.clientCount);break}case"paired":{this.emit("paired",{token:a.token,deviceId:a.deviceId,hostId:a.hostId,expiresAt:a.expiresAt});break}case"control_state":{this.currentRole=a.role,this.controllerId=a.controllerId,this.emit("controlState",a.role,a.controllerId),this.emit("roleChange",a.role,a.controllerId,this.hostId,this.assignedClientId),typeof a.clientCount=="number"&&this.emit("peerCount",a.clientCount);break}case"host_reconnecting":{this.temporaryFailureCode="host_reconnecting",this.setState("reconnecting","Herdr host is reconnecting",a.code||"host_reconnecting"),this.emit("hostReconnecting",a.code);break}case"session_restarted":{this.setState("reconnecting","Herdr session is restarting","session_restarted"),this.emit("sessionRestarted",a.cols,a.rows,a.terminalPalette,a.hostname);break}case"control_revoked":{this.currentRole="viewer",this.emit("controlRevoked",a.reason),this.emit("roleChange","viewer",this.controllerId,this.hostId,this.assignedClientId);break}case"session_ready":{this.setState("connected"),this.emit("sessionReady",a);break}case"exit":{this.emit("exit",a.code,a.reason);break}case"control_granted":{this.currentRole="controller",this.controllerId=this.assignedClientId||this.config.clientId,this.emit("controlGranted"),this.emit("roleChange","controller",this.controllerId,this.hostId,this.assignedClientId);break}case"control_denied":{this.emit("controlDenied",a.message);break}case"status":{this.emit("status",a);break}case"error":{a.code==="host_offline"||a.code==="host_reconnecting"||a.code==="host_reconnect_timeout"||a.code==="rate_limited"?(this.temporaryFailureCode=String(a.code),this.setState("reconnecting",a.message,String(a.code))):(a.code==="auth_required"||a.code==="unauthorized"||a.code==="device_revoked"||a.code==="invalid_handshake"||a.code==="too_many_hosts"||a.code===401||a.code===403)&&(this.authFailureDetail=a.message,this.authFailureCode=String(a.code),this.setState("error",a.message,this.authFailureCode)),this.emit("error",{code:a.code,message:a.message});break}case"pong":{if(this.pingTimestamp){const i=Math.max(0,performance.now()-this.pingTimestamp);this.pingTimestamp=null,this.emit("rttUpdate",Math.round(i))}break}case"paste_file_ready":{this.emit("pasteFileReady",a.path);break}case"agent_status":{this.emit("agentStatus",a);break}}}handleError(a){console.error("WebSocket error:",a),this.emit("error",{code:"WS_ERROR",message:"WebSocket connection error"})}handleClose(a){if(this.clearTimers(),this.ws=null,this.authFailureDetail){this.setState("error",this.authFailureDetail,this.authFailureCode??void 0);return}if(a.code===1008&&this.temporaryFailureCode){this.setState("reconnecting",a.reason||"The relay is temporarily unavailable",this.temporaryFailureCode),this.scheduleReconnect();return}if(a.code===1008){this.rejectedByRelay=!0,this.setState("error",a.reason||"The relay rejected the connection",String(a.code));return}!this.isManuallyClosed&&this.config.autoReconnect?(this.setState("reconnecting",`Connection closed (${a.code}). Retrying...`,"connection_closed"),this.scheduleReconnect()):this.setState("disconnected",`Closed: ${a.reason||a.code}`,"connection_closed")}scheduleReconnect(){if(this.isManuallyClosed||!this.config.autoReconnect)return;if(this.config.maxReconnectAttempts>0&&this.reconnectAttempts>=this.config.maxReconnectAttempts){this.setState("error","Max reconnect attempts reached");return}this.reconnectAttempts++;const a=this.config.reconnectIntervalMs||2e3,o=Math.min(3e4,Math.floor(a*Math.pow(1.5,this.reconnectAttempts-1)+Math.random()*500));this.reconnectTimer=setTimeout(()=>{this.connect()},o)}startHeartbeat(){this.pingTimer&&clearInterval(this.pingTimer);const a=this.pingIntervalMs();this.pingSentAt=null,this.pingTimer=setInterval(()=>{if(!(!this.ws||this.ws.readyState!==WebSocket.OPEN)){if(this.pingSentAt!==null&&this.lastInboundAt<this.pingSentAt&&Date.now()-this.pingSentAt>=a){this.probeLiveness();return}this.sendPing()}},a)}clearTimers(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this.probeTimer&&(clearTimeout(this.probeTimer),this.probeTimer=null)}sendHello(){const a={type:"hello",protocol:1,clientId:this.config.clientId,cols:this.terminalCols,rows:this.terminalRows,capabilities:["host_handoff"]};this.config.token&&(a.token=this.config.token),this.config.pairCode&&(a.pairCode=this.config.pairCode),this.sendJson(a)}claimControl(a=!1){const i={type:"claim_control",...a?{force:!0}:{}};this.sendJson(i)}releaseControl(){const a={type:"release_control"};this.sendJson(a)}sendResize(a,i){this.terminalCols=a,this.terminalRows=i;const o={type:"resize",cols:a,rows:i};this.sendJson(o)}sendPing(){this.pingTimestamp=performance.now(),this.pingSentAt=Date.now();const a={type:"ping"};this.sendJson(a)}sendPasteFile(a,i){this.sendJson({type:"paste_file",mime:a,dataBase64:i})}sendJson(a){this.flushInput(),this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(a))}sendInput(a){const i=a instanceof Uint8Array?a:new Uint8Array(a);i.length!==0&&(this.pendingInputSegments.push(i),this.isFlushScheduled||(this.isFlushScheduled=!0,queueMicrotask(()=>this.flushInput())))}flushInput(){if(this.isFlushScheduled=!1,this.pendingInputSegments.length===0)return;let a=this.pendingInputSegments;if(this.pendingInputSegments=[],this.ws&&(this.ws.bufferedAmount??0)>256*1024&&(a=a.filter(o=>!mo(o))),a.length===0)return;let i;if(a.length===1)i=a[0];else{let o=0;for(let f=0;f<a.length;f++)o+=a[f].byteLength;i=new Uint8Array(o);let d=0;for(let f=0;f<a.length;f++)i.set(a[f],d),d+=a[f].byteLength}this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(i)}sendBinary(a){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(a)}sendText(a){const i=Iu(a);this.sendInput(i)}resolveWsUrl(a){if(/^wss?:\/\//i.test(a))return a;if(/^https?:\/\//i.test(a)){const i=new URL(a);return i.protocol=i.protocol==="https:"?"wss:":"ws:",(!i.pathname||i.pathname==="/")&&(i.pathname="/ws/client"),i.toString()}if(typeof window<"u"&&window.location){const o=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host,f=a.startsWith("/")?a:`/${a}`;return`${o}//${d}${f}`}return"ws://127.0.0.1:8787/ws/client"}}function uv(r,a=window,i=document){const o=v=>{var y;((y=a.navigator)==null?void 0:y.onLine)!==!1&&r.wake(v)},d=()=>{i.visibilityState==="visible"&&o("visible")},f=()=>o("pageshow"),p=()=>o("online"),m=()=>o("focus"),b=()=>o("resume");return i.addEventListener("visibilitychange",d),i.addEventListener("resume",b),a.addEventListener("pageshow",f),a.addEventListener("online",p),a.addEventListener("focus",m),()=>{i.removeEventListener("visibilitychange",d),i.removeEventListener("resume",b),a.removeEventListener("pageshow",f),a.removeEventListener("online",p),a.removeEventListener("focus",m)}}const dv=10,fv=24,xo=15,Zu=13,Qu=640;function hv(){if(typeof window>"u")return!1;try{if(typeof window.matchMedia=="function"&&(window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(hover: none)").matches))return!0}catch{}return Ui()<Qu}function Ui(){return typeof window>"u"?1024:window.visualViewport&&typeof window.visualViewport.width=="number"&&window.visualViewport.width>0?window.visualViewport.width:window.innerWidth||1024}function Nu(){return typeof window>"u"?768:window.visualViewport&&typeof window.visualViewport.height=="number"&&window.visualViewport.height>0?window.visualViewport.height:window.innerHeight||768}function po(r,a=xo){const i=typeof r=="number"?r:Number(r);return!Number.isFinite(i)||i<=0?a:Math.min(fv,Math.max(dv,Math.round(i)))}function Xm(r,a=Ui()){if(a<Qu){const o=po(r,Zu);return Math.min(15,Math.max(12,o))}return po(r,xo)}const qp=[{id:"esc",label:"ESC",code:ge.ESC,type:"key",enabled:!0,title:"Escape"},{id:"tab",label:"TAB",code:ge.TAB,type:"key",enabled:!0,title:"Tab"},{id:"shift_tab",label:"⇧TAB",code:ge.SHIFT_TAB,type:"key",enabled:!0,title:"Shift+Tab"},{id:"ctrl",label:"CTRL",code:"",type:"modifier",enabled:!0,modifierType:"ctrl",title:"Toggle Ctrl modifier latch"},{id:"alt",label:"ALT",code:"",type:"modifier",enabled:!0,modifierType:"alt",title:"Toggle Alt modifier latch"},{id:"left",label:"←",code:ge.LEFT,type:"key",enabled:!0,title:"Arrow Left"},{id:"up",label:"↑",code:ge.UP,type:"key",enabled:!0,title:"Arrow Up"},{id:"down",label:"↓",code:ge.DOWN,type:"key",enabled:!0,title:"Arrow Down"},{id:"right",label:"→",code:ge.RIGHT,type:"key",enabled:!0,title:"Arrow Right"},{id:"drawer_chords",label:"^C",code:"",type:"drawer",enabled:!0,drawerType:"chords",title:"Quick Ctrl Chords"},{id:"drawer_symbols",label:"~|/",code:"",type:"drawer",enabled:!0,drawerType:"symbols",title:"Special Symbols"},{id:"drawer_fn",label:"Fn",code:"",type:"drawer",enabled:!0,drawerType:"fn",title:"Function Keys (F1-F12)"},{id:"enter",label:"Enter",code:ge.ENTER,type:"key",enabled:!0,title:"Enter / Return"}],mv=[{id:"ctrl",label:"CTRL",code:"",type:"modifier",enabled:!0,modifierType:"ctrl",title:"Toggle Ctrl modifier latch"},{id:"alt",label:"ALT",code:"",type:"modifier",enabled:!0,modifierType:"alt",title:"Toggle Alt modifier latch"},{id:"shift",label:"SHIFT",code:"",type:"modifier",enabled:!0,modifierType:"shift",title:"Toggle Shift modifier latch"},{id:"meta",label:"META",code:"\x1B",type:"modifier",enabled:!0,modifierType:"meta",title:"Meta / Cmd key"},{id:"esc",label:"ESC",code:ge.ESC,type:"key",enabled:!0,title:"Escape"},{id:"tab",label:"TAB",code:ge.TAB,type:"key",enabled:!0,title:"Tab"},{id:"shift_tab",label:"⇧TAB",code:ge.SHIFT_TAB,type:"key",enabled:!0,title:"Shift+Tab"},{id:"enter",label:"Enter",code:ge.ENTER,type:"key",enabled:!0,title:"Enter / Return"},{id:"backspace",label:"⌫",code:ge.BACKSPACE,type:"key",enabled:!0,title:"Backspace"},{id:"delete",label:"Del",code:ge.DELETE,type:"key",enabled:!0,title:"Delete"},{id:"left",label:"←",code:ge.LEFT,type:"key",enabled:!0,title:"Arrow Left"},{id:"up",label:"↑",code:ge.UP,type:"key",enabled:!0,title:"Arrow Up"},{id:"down",label:"↓",code:ge.DOWN,type:"key",enabled:!0,title:"Arrow Down"},{id:"right",label:"→",code:ge.RIGHT,type:"key",enabled:!0,title:"Arrow Right"},{id:"home",label:"Home",code:ge.HOME,type:"key",enabled:!0,title:"Home"},{id:"end",label:"End",code:ge.END,type:"key",enabled:!0,title:"End"},{id:"page_up",label:"PgUp",code:ge.PAGE_UP,type:"key",enabled:!0,title:"Page Up"},{id:"page_down",label:"PgDn",code:ge.PAGE_DOWN,type:"key",enabled:!0,title:"Page Down"},{id:"insert",label:"Ins",code:ge.INSERT,type:"key",enabled:!0,title:"Insert"},{id:"ctrl_c",label:"^C",code:ge.CTRL_C,type:"chord",enabled:!0,title:"Ctrl+C (SIGINT)"},{id:"ctrl_d",label:"^D",code:ge.CTRL_D,type:"chord",enabled:!0,title:"Ctrl+D (EOF/Exit)"},{id:"ctrl_z",label:"^Z",code:ge.CTRL_Z,type:"chord",enabled:!0,title:"Ctrl+Z (SIGTSTP)"},{id:"ctrl_l",label:"^L",code:ge.CTRL_L,type:"chord",enabled:!0,title:"Ctrl+L (Clear Screen)"},{id:"ctrl_a",label:"^A",code:ge.CTRL_A,type:"chord",enabled:!0,title:"Ctrl+A (Beginning of Line)"},{id:"ctrl_e",label:"^E",code:ge.CTRL_E,type:"chord",enabled:!0,title:"Ctrl+E (End of Line)"},{id:"ctrl_k",label:"^K",code:ge.CTRL_K,type:"chord",enabled:!0,title:"Ctrl+K (Kill to End)"},{id:"ctrl_r",label:"^R",code:ge.CTRL_R,type:"chord",enabled:!0,title:"Ctrl+R (Reverse Search)"},{id:"f1",label:"F1",code:ge.F1,type:"fn",enabled:!0,title:"F1"},{id:"f2",label:"F2",code:ge.F2,type:"fn",enabled:!0,title:"F2"},{id:"f3",label:"F3",code:ge.F3,type:"fn",enabled:!0,title:"F3"},{id:"f4",label:"F4",code:ge.F4,type:"fn",enabled:!0,title:"F4"},{id:"f5",label:"F5",code:ge.F5,type:"fn",enabled:!0,title:"F5"},{id:"f6",label:"F6",code:ge.F6,type:"fn",enabled:!0,title:"F6"},{id:"f7",label:"F7",code:ge.F7,type:"fn",enabled:!0,title:"F7"},{id:"f8",label:"F8",code:ge.F8,type:"fn",enabled:!0,title:"F8"},{id:"f9",label:"F9",code:ge.F9,type:"fn",enabled:!0,title:"F9"},{id:"f10",label:"F10",code:ge.F10,type:"fn",enabled:!0,title:"F10"},{id:"f11",label:"F11",code:ge.F11,type:"fn",enabled:!0,title:"F11"},{id:"f12",label:"F12",code:ge.F12,type:"fn",enabled:!0,title:"F12"},{id:"drawer_chords",label:"^C",code:"",type:"drawer",enabled:!0,drawerType:"chords",title:"Quick Ctrl Chords"},{id:"drawer_symbols",label:"~|/",code:"",type:"drawer",enabled:!0,drawerType:"symbols",title:"Special Symbols"},{id:"drawer_fn",label:"Fn",code:"",type:"drawer",enabled:!0,drawerType:"fn",title:"Function Keys (F1-F12)"},{id:"sym_pipe",label:"|",code:"|",type:"symbol",enabled:!0,isPlainChar:!0,title:"Pipe (|)"},{id:"sym_tilde",label:"~",code:"~",type:"symbol",enabled:!0,isPlainChar:!0,title:"Tilde (~)"},{id:"sym_slash",label:"/",code:"/",type:"symbol",enabled:!0,isPlainChar:!0,title:"Slash (/)"},{id:"sym_backslash",label:"\\",code:"\\",type:"symbol",enabled:!0,isPlainChar:!0,title:"Backslash (\\)"},{id:"sym_dash",label:"-",code:"-",type:"symbol",enabled:!0,isPlainChar:!0,title:"Dash (-)"},{id:"sym_underscore",label:"_",code:"_",type:"symbol",enabled:!0,isPlainChar:!0,title:"Underscore (_)"},{id:"sym_dollar",label:"$",code:"$",type:"symbol",enabled:!0,isPlainChar:!0,title:"Dollar ($)"},{id:"sym_ampersand",label:"&",code:"&",type:"symbol",enabled:!0,isPlainChar:!0,title:"Ampersand (&)"},{id:"sym_quote",label:'"',code:'"',type:"symbol",enabled:!0,isPlainChar:!0,title:'Double Quote (")'},{id:"sym_backtick",label:"`",code:"`",type:"symbol",enabled:!0,isPlainChar:!0,title:"Backtick (`)"}];function qr(){return JSON.parse(JSON.stringify(qp))}const pv=[["esc","tab","ctrl","alt","left","up","down","right","enter","drawer_chords","drawer_symbols","drawer_fn"],["esc","tab","ctrl","alt","left","up","down","right","drawer_chords","drawer_symbols","drawer_fn","enter"]];function gv(r){return pv.some(a=>r.length===a.length&&r.every((i,o)=>i.id===a[o]&&i.enabled!==!1))}function bv(r){if(!Array.isArray(r)||r.length===0)return qr();const a=r.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.label=="string"&&typeof i.code=="string");return gv(a)?qr():a}function Bu(r,a){if(a){const i=`keyTitles.${r.id}`,o=a(i);if(o&&o!==i)return o}return r.title||r.label}const Hu='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", "Symbols Nerd Font Mono", monospace',yv='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',Im="JetBrains Mono, Menlo, Monaco, Consolas, monospace",Bi="herdr_remote_settings_v1",Kr="herdr_remote_session_view_v1",Vp=64,Vr=4096,Yu={local:{},session:{}};function go(r,a){if(typeof window>"u")return Yu[r][a]||null;try{return(r==="local"?window.localStorage:window.sessionStorage).getItem(a)}catch{return Yu[r][a]||null}}function Ja(r,a,i){if(Yu[r][a]=i,!(typeof window>"u"))try{(r==="local"?window.localStorage:window.sessionStorage).setItem(a,i)}catch(o){console.warn(`Failed to write to ${r}Storage:`,o)}}function vv(){return`client-${Math.random().toString(36).substring(2,8)}`}function Ju(){const r=Math.random().toString(36).substring(2,10);return`profile-${Date.now().toString(36)}-${r}`}function xv(r,a){return(typeof r=="string"?r.trim().slice(0,Vp):"")||a}function bo(r,a){if(!r||typeof r!="object"||Array.isArray(r))return null;const i=r,o=typeof i.wsUrl=="string"?i.wsUrl.trim().slice(0,2048):"",d=typeof i.token=="string"?i.token.slice(0,Vr):"",f=typeof i.pairCode=="string"?i.pairCode.trim().toUpperCase().slice(0,32):"";if(!o||!o.startsWith("/")&&!/^(?:wss?|https?):\/\//i.test(o)||!d&&!f)return null;const p=Date.now(),m=typeof i.id=="string"&&i.id.length>0?i.id.slice(0,128):Ju(),b=typeof i.hostname=="string"&&i.hostname.trim()?i.hostname.trim().slice(0,Vp):`Herdr ${a+1}`;return{id:m,displayName:xv(i.displayName,b),wsUrl:o,token:d,...f?{pairCode:f}:{},...typeof i.hostId=="string"&&i.hostId.trim()?{hostId:i.hostId.trim().slice(0,128)}:{},...typeof i.hostname=="string"&&i.hostname.trim()?{hostname:i.hostname.trim().slice(0,128)}:{},...typeof i.deviceId=="string"&&i.deviceId.trim()?{deviceId:i.deviceId.trim().slice(0,128)}:{},autoReconnect:i.autoReconnect!==!1,createdAt:Number.isFinite(i.createdAt)?Number(i.createdAt):p,lastUsedAt:Number.isFinite(i.lastUsedAt)?Number(i.lastUsedAt):p}}function Zm(r,a=0){const i=bo({...r,id:r.id||Ju()},a);if(!i)throw new Error("a connection profile requires a relay URL and token or pairing code");return i}function Qm(r){let a=r.wsUrl.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"").toLowerCase();if(typeof window<"u")try{const i=new URL(r.wsUrl,window.location.origin);i.protocol=i.protocol==="wss:"?"https:":"http:",i.pathname=i.pathname.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"")||"/",i.search="",i.hash="",a=i.toString().replace(/\/$/,"").toLowerCase()}catch{}return`${a}::${r.hostId||""}`}function Fp(){return typeof navigator<"u"&&navigator.language&&navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}function Xp(){const r=typeof window<"u"&&window.innerWidth<640;return{wsUrl:"/ws/client",token:"",pairCode:"",clientId:vv(),autoReconnect:!0,profiles:[],activeProfileId:"",fontSize:r?Zu:xo,fontFamily:Hu,toolbarVisible:!0,toolbarPosition:"bottom",vibrateOnKeyPress:!0,predictiveEcho:"auto",agentAlertBadge:!0,agentAlertSound:!1,agentAlertVibrate:!1,agentAlertNotify:!1,language:Fp(),virtualKeys:qr(),adminToken:"",adminTokens:{}}}const Sv=["wsUrl","token","pairCode","clientId","autoReconnect","language"],wv=["wsUrl","token","pairCode","autoReconnect"],Wu=["fontSize","fontFamily","toolbarVisible","toolbarPosition","vibrateOnKeyPress","predictiveEcho","virtualKeys","agentAlertBadge","agentAlertSound","agentAlertVibrate","agentAlertNotify","adminToken","adminTokens"],Cv=Wu.filter(r=>r!=="adminToken"&&r!=="adminTokens"),Jm=["theme","colorMode"];function Ku(r){const a=r;if(!Jm.some(d=>a[d]!==void 0))return{data:r,changed:!1};const o={...a};for(const d of Jm)delete o[d];return{data:o,changed:!0}}function Ip(r){if(!r||typeof r!="object"||Array.isArray(r))return{};const a={};for(const[i,o]of Object.entries(r).slice(0,32))typeof o!="string"||o.length===0||(a[i.slice(0,512)]=o.slice(0,Vr));return a}function Zp(r){var f;const a=[];if((Array.isArray(r.profiles)?r.profiles.slice(0,64):[]).forEach((p,m)=>{const b=bo(p,m);b&&!a.some(v=>v.id===b.id)&&a.push(b)}),a.length===0&&(typeof r.token=="string"&&r.token||typeof r.pairCode=="string"&&r.pairCode)){const p=bo({id:"profile-migrated",displayName:"Herdr 1",wsUrl:typeof r.wsUrl=="string"&&r.wsUrl.trim()?r.wsUrl:"/ws/client",token:r.token||"",pairCode:r.pairCode||"",autoReconnect:r.autoReconnect!==!1},0);p&&a.push(p)}const o=typeof r.activeProfileId=="string"?r.activeProfileId:"",d=a.some(p=>p.id===o)?o:((f=a[0])==null?void 0:f.id)||"";return{profiles:a,activeProfileId:d}}function Qp(){const r=Xp();if(typeof window>"u")return r;let a={};const i=go("local",Bi);if(i)try{a=JSON.parse(i)}catch(le){console.warn("Failed to parse localStorage settings:",le)}const o=Ku(a);o.changed&&(a=o.data,Ja("local",Bi,JSON.stringify(a)));let d=null;const f=go("session",Kr);if(f)try{d=JSON.parse(f)}catch(le){console.warn("Failed to parse sessionStorage settings:",le)}if(!d){const le={};for(const ve of Wu)a[ve]!==void 0&&(le[ve]=a[ve]);d=le,Ja("session",Kr,JSON.stringify(d))}let p=d.fontFamily??a.fontFamily??r.fontFamily;(!p||p===Im||p===yv)&&(p=Hu);const m=window.innerWidth<640?Zu:xo,b=d.fontSize??a.fontSize??r.fontSize,v=po(b,m),y=d.virtualKeys??a.virtualKeys??r.virtualKeys,S=bv(y),A=a.language??r.language,E=A==="zh"||A==="en"?A:Fp(),R=Zp(a),H=R.profiles.find(le=>le.id===R.activeProfileId),z=Ku(d);z.changed&&(d=z.data,Ja("session",Kr,JSON.stringify(d)));const G=d.toolbarVisible??a.toolbarVisible??r.toolbarVisible,Q=d.toolbarPosition??a.toolbarPosition??r.toolbarPosition,X=d.vibrateOnKeyPress??a.vibrateOnKeyPress??r.vibrateOnKeyPress,re=le=>{const ve=d[le]??a[le];return typeof ve=="boolean"?ve:r[le]},de=(d==null?void 0:d.predictiveEcho)??(a==null?void 0:a.predictiveEcho)??r.predictiveEcho,ee=de==="always"||de==="off"||de==="auto"?de:"auto",T=typeof d.adminToken=="string"?d.adminToken.slice(0,Vr):typeof a.adminToken=="string"?a.adminToken.slice(0,Vr):r.adminToken,_=Ip(d.adminTokens),P={...r,...a,...d,wsUrl:(H==null?void 0:H.wsUrl)||(typeof a.wsUrl=="string"?a.wsUrl:r.wsUrl),token:(H==null?void 0:H.token)||"",pairCode:(H==null?void 0:H.pairCode)||"",autoReconnect:(H==null?void 0:H.autoReconnect)??r.autoReconnect,profiles:R.profiles,activeProfileId:R.activeProfileId,clientId:typeof a.clientId=="string"&&a.clientId.trim()?a.clientId.trim().slice(0,128):r.clientId,fontFamily:p,fontSize:v,toolbarVisible:G,toolbarPosition:Q,vibrateOnKeyPress:X,predictiveEcho:ee,virtualKeys:S,agentAlertBadge:re("agentAlertBadge"),agentAlertSound:re("agentAlertSound"),agentAlertVibrate:re("agentAlertVibrate"),agentAlertNotify:re("agentAlertNotify"),language:E,adminToken:T,adminTokens:_};return a.fontFamily===Im&&(a.fontFamily=Hu,Ja("local",Bi,JSON.stringify(a))),P}function Na(r){var A;const i={...Qp(),...r};i.adminTokens=Ip(i.adminTokens),typeof i.adminToken=="string"&&(i.adminToken=i.adminToken.slice(0,Vr)),r.fontSize!==void 0&&(i.fontSize=po(r.fontSize)),r.predictiveEcho!==void 0&&(r.predictiveEcho==="auto"||r.predictiveEcho==="always"||r.predictiveEcho==="off"?i.predictiveEcho=r.predictiveEcho:i.predictiveEcho="auto");const o=Zp(i);let d=o.profiles,f=o.activeProfileId;if(wv.some(E=>r[E]!==void 0)){const E=d.findIndex(z=>z.id===f),R=E>=0?{...d[E]}:{id:Ju(),displayName:`Herdr ${d.length+1}`,wsUrl:i.wsUrl,token:"",autoReconnect:!0,createdAt:Date.now(),lastUsedAt:Date.now()};R.wsUrl=i.wsUrl,R.token=i.token,R.pairCode=i.pairCode||void 0,R.autoReconnect=i.autoReconnect,R.lastUsedAt=Date.now();const H=bo(R,Math.max(E,0));H?E>=0?d[E]=H:(d.push(H),f=H.id):E>=0&&(d=d.filter(z=>z.id!==f),f=((A=d[0])==null?void 0:A.id)||"")}d.length>0&&!d.some(E=>E.id===f)&&(f=d[0].id);const m=d.find(E=>E.id===f);i.profiles=d,i.activeProfileId=f,i.wsUrl=(m==null?void 0:m.wsUrl)||i.wsUrl||"/ws/client",i.token=(m==null?void 0:m.token)||"",i.pairCode=(m==null?void 0:m.pairCode)||"",i.autoReconnect=(m==null?void 0:m.autoReconnect)??i.autoReconnect;const b=go("local",Bi);let v={};if(b)try{v=JSON.parse(b)}catch{}v=Ku(v).data;for(const E of Sv)i[E]!==void 0&&(v[E]=i[E]);v.profiles=d,v.activeProfileId=f,Ja("local",Bi,JSON.stringify(v));const y=go("session",Kr);let S={};if(y)try{S=JSON.parse(y)}catch{}for(const E of Wu)i[E]!==void 0&&(S[E]=i[E]);Ja("session",Kr,JSON.stringify(S));for(const E of Cv)i[E]!==void 0&&(v[E]=i[E]);return Ja("local",Bi,JSON.stringify(v)),i}const Tv={header:{appName:"Herdr",tagline:"remote terminal client",terminalTab:"Terminal",adminTab:"Admin",rttMs:"{rtt}ms",hostLabel:"Host",clientIdLabel:"ID:",copyClientIdTitle:"Click to copy Client ID",languageToggleTitle:"Switch language (EN / 中文)",pairingTitle:"Connection & pairing",settingsTitle:"Terminal settings",virtualKeyboardTitle:"Quick command helper",latencyTitle:"Round-trip latency (RTT)",mainNavigationAria:"Main Navigation",actionKeyboard:"cmd",actionPairing:"link",actionSettings:"cfg",languageShort:"en"},common:{connecting:"Connecting...",connected:"Connected",reconnecting:"Reconnecting...",disconnected:"Disconnected",error:"Error",save:"Save",cancel:"Cancel",close:"Close",done:"Done",retry:"Retry",connect:"Connect",disconnect:"Disconnect",copy:"Copy",copied:"Copied",loading:"Loading...",offline:"Offline",role:"Role",host:"Host",status:"Status",settings:"Settings",admin:"Admin",terminal:"Terminal",pairing:"Pairing",keyBar:"Key bar",quickInput:"Quick input",dismissNotification:"Dismiss notification",closeDialog:"Close dialog",clickToCopy:"Click to copy",controller:"Controller",viewer:"Viewer",live:"Live"},connection:{live:"Live",connecting:"Connecting",reconnecting:"Reconnecting",reconnectNow:"Reconnect now",error:"Error",offline:"Offline",connect:"Connect",retry:"Retry"},role:{controllerMode:"Controller mode active",viewerMode:"Viewer mode",controlActive:"Full Control",viewerReadOnly:"Viewer",viewerWithController:"Viewer (Active: {controllerId})",sharedControl:"Full control",sharedControlDesc:"Every paired window shares this terminal and may type into it.",sharedWindows:"{count} windows",thisWindow:"Window",claimControl:"Claim Control",claimControlTitle:"Claim terminal control",releaseControl:"Release",releaseControlTitle:"Switch to viewer mode",takeoverControl:"Takeover",takeoverControlTitle:"Take over control from {controllerId}",takeoverModalTitle:"Confirm Control Takeover",takeoverModalDesc:"Another client is controlling this terminal.",takeoverModalWarning:"Input focus will transfer to this window.",confirmTakeover:"Confirm Takeover"},statusBanner:{connecting:"Connecting to relay...",reconnectingDefault:"Connection lost. Reconnecting...",reconnectNow:"Reconnect Now",errorDefault:"Unable to connect to relay",disconnected:"Terminal disconnected"},onboarding:{title:"Pair with Herdr Remote",subtitle:"Connect your mobile or browser to your local terminal session",description:"Control Herdr sessions from any browser or phone.",firstTimeSetup:"First-time Setup",authRequired:"Authorization Required",authRequiredDesc:"Pair your device or provide a valid access token.",step1Title:"Generate Pairing Code on Host",step1Desc:"Run on the host running Herdr:",step1CopyPlugin:"Using Herdr Plugin:",step1CopyCli:"Copy CLI Command",step1TuiNote:"Interactive TUI config:",step2Title:"Enter 6-character Pairing Code",step2Placeholder:"e.g. 7X9K2A",step2Note:"Pairing code expires in 5 minutes; credentials are saved automatically.",connectAndPair:"Connect & Pair",connectingAndPairing:"Pairing with Relay...",advancedTitle:"Advanced Options",manualTokenLabel:"Authentication Token",manualTokenPlaceholder:"Optional token (skips pairing code)",wsEndpointLabel:"Relay WebSocket Endpoint",wsEndpointPlaceholder:"/ws/client or wss://your-relay-host/ws/client",clientIdLabel:"Device Client Identifier"},pairing:{title:"Relay Connection & Pairing",addTitle:"Add Herdr Instance",displayNameLabel:"Host Name",displayNamePlaceholder:"e.g. Workstation",displayNameHelp:"This name is stored only in this browser.",credentialsRequired:"Enter a pairing code or device token.",subtitle:"Manage WebSocket endpoints and credentials",pairCodeLabel:"Pairing Code",pairCodeNote:"(6-char code)",pairCodePlaceholder:"e.g. A1B2C3",pairCodeHelp:'Run "herdr-remote pair" on host.',tokenLabel:"Access Token",tokenNote:"(Device secret)",tokenPlaceholder:"Device token...",wsUrlLabel:"Relay WebSocket Endpoint URL",wsUrlPlaceholder:"/ws/client",wsUrlDefaultNote:"Defaults to same-origin /ws/client",clientIdLabel:"Client Identifier",newIdButton:"New ID",regenerateClientIdTitle:"Regenerate client ID",autoReconnectLabel:"Auto-reconnect",autoReconnectDesc:"Automatically reconnect when disconnected",copyDirectLink:"Copy direct pairing link",saveAndConnect:"Save & Connect"},settings:{title:"Terminal Preferences",subtitle:"Font, size, and touch settings",tabGeneral:"General",tabAppearance:"Appearance & Font",tabVirtualKeys:"Virtual Keys",fontFamilyLabel:"Monospace Font",fontSizeLabel:"Terminal Text Size ({size}px)",fontSizeCompact:"10px (Compact)",fontSizeDefault:"15px (Default)",fontSizeLarge:"24px (Large)",mobileFontNote:"Terminal font scales automatically on small screens for 80-column layout.",colorPassthroughNote:"Terminal colors and cursor style pass through from the host.",predictiveEchoLabel:"Predictive Echo",predictiveEchoAuto:"Auto",predictiveEchoAlways:"Always On",predictiveEchoOff:"Off",predictiveEchoDesc:"Under high latency, show what you type in a shell prompt or an agent’s input box before the echo comes back. Menus and other screens are never predicted.",touchKeyToolbar:"Touch Key Toolbar",touchKeyToolbarDesc:"Show modifier and navigation keys",touchHaptics:"Haptic Feedback",touchHapticsDesc:"Vibrate on key press",agentAlertsLabel:"Agent alerts",agentAlertBadge:"Title and icon badge",agentAlertBadgeDesc:"Count blocked and finished agents in the tab title, and mark the tab icon",agentAlertVibrate:"Vibrate",agentAlertVibrateDesc:"When an agent stops to ask or finishes, while this page is on screen",agentAlertSound:"Chime",agentAlertSoundDesc:"A short sound while this page is in the background; starts working after your next tap",agentAlertNotify:"System notification",agentAlertNotifyDesc:"While this page is in the background (HTTPS only)",languageLabel:"Language",languageDesc:"Choose English or 简体中文",resetDefaults:"Reset to Defaults",resetDefaultsToast:"Settings reset to defaults",windowZoomSharedNote:"Host view isolation is not active; zoom applies locally.",fontSizeZoomHelp:"Adjusts font size in this window only."},virtualKeyboard:{collapseToolbar:"Collapse Toolbar",expandToolbar:"Expand Toolbar",helperTitle:"Quick Commands",closeHelper:"Close Helper",placeholder:"Type command and press Enter...",sendButton:"Send",clearInput:"Clear Input",customizeTitle:"Custom Key Toolbar",customizeDesc:"Reorder, enable, or disable keys for your toolbar.",enabledKeysCount:"{count} keys enabled",resetLayout:"Reset to Default",addKey:"Add Key",availableKeys:"Available Keys",moveUp:"Move Up",moveDown:"Move Down",enableKey:"Enable Key",disableKey:"Disable Key",deleteKeyTitle:"Remove Key",keyTypeModifier:"Modifier",keyTypeNav:"Navigation",keyTypeAction:"Action",keyTypeChord:"Chord",keyTypeFn:"Function",keyTypeSymbol:"Symbol",fnDrawerTitle:"Function Keys (F1-F12)",chordsDrawerTitle:"Control Chords (^C, ^D, ^Z)",symbolsDrawerTitle:"Symbols (~, |, /, \\)",touchKeyboardShortcuts:"Shortcuts Toolbar",ctrlCTitle:"Ctrl+C (SIGINT)",ctrlDTitle:"Ctrl+D (EOF)",ctrlZTitle:"Ctrl+Z (SIGTSTP)",ctrlLTitle:"Ctrl+L (Clear)",ctrlRTitle:"Ctrl+R (Search)",ctrlATitle:"Ctrl+A (Start of line)",ctrlETitle:"Ctrl+E (End of line)",ctrlKTitle:"Ctrl+K (Kill to end)",badgeSigint:"SIGINT",badgeEof:"EOF",badgeTstp:"SIGTSTP",badgeClear:"CLEAR",badgeSearch:"SEARCH",badgeStart:"START",badgeEnd:"END",badgeKill:"KILL",keyEnter:"Enter",uploadImage:"Upload Image",uploadImageTitle:"Select and upload image to terminal",image:"Image",uploadProgressReading:"Reading...",uploadProgressProcessing:"Compressing...",uploadProgressSending:"Uploading...",uploadProgressWaitingHost:"Waiting for host...",uploadProgressCompleted:"Completed",uploadProgressFailed:"Upload failed"},profiles:{title:"Herdr instances",switcherLabel:"Switch Herdr instance",current:"current",empty:"No paired Herdr instances yet.",addHost:"Add Herdr instance",rename:"Rename instance",remove:"Remove locally",removeConfirm:"Remove this saved connection from this browser?"},mobile:{sessionControls:"Session controls",closeSessionControls:"Close session controls",connectionStatusAria:"Connection status",terminalControlAria:"Terminal control",inputControl:"Input control",settingsAria:"Terminal settings",adminAria:"Admin dashboard",pairingAria:"Connection & pairing",keybarAria:"Toggle key toolbar",quickInputAria:"Toggle quick commands",menu:"Menu",statusBarAria:"Session status bar"},terminal:{bannerTitle:"Herdr Remote WebUI",bannerSubtitle:"Connected to Herdr session.",windowAriaLabel:"Terminal Window",bufferAriaLabel:"Terminal Buffer",offlineStatusAria:"Offline Status",releaseControlAria:"Release Control",takeoverControlAria:"Takeover Control",claimControlAria:"Claim Control"},keyTitles:{esc:"Escape (ESC)",tab:"Tab",shift_tab:"Shift+Tab (Claude Code: cycle modes)",ctrl:"Toggle Ctrl Lock",alt:"Toggle Alt Lock",shift:"Toggle Shift Lock",meta:"Meta / Cmd",enter:"Enter",backspace:"Backspace",delete:"Delete",left:"Left (←)",up:"Up (↑)",down:"Down (↓)",right:"Right (→)",home:"Home",end:"End",page_up:"Page Up",page_down:"Page Down",insert:"Insert",drawer_chords:"Ctrl Chords",drawer_symbols:"Symbols",drawer_fn:"Function Keys (F1-F12)",ctrl_c:"Ctrl+C (SIGINT)",ctrl_d:"Ctrl+D (EOF)",ctrl_z:"Ctrl+Z (SIGTSTP)",ctrl_l:"Ctrl+L (Clear)",ctrl_a:"Ctrl+A (Start of line)",ctrl_e:"Ctrl+E (End of line)",ctrl_k:"Ctrl+K (Kill to end)",ctrl_r:"Ctrl+R (Search history)",f1:"F1",f2:"F2",f3:"F3",f4:"F4",f5:"F5",f6:"F6",f7:"F7",f8:"F8",f9:"F9",f10:"F10",f11:"F11",f12:"F12",sym_pipe:"Pipe (|)",sym_tilde:"Tilde (~)",sym_slash:"Slash (/)",sym_backslash:"Backslash (\\)",sym_dash:"Dash (-)",sym_underscore:"Underscore (_)",sym_dollar:"Dollar ($)",sym_ampersand:"Ampersand (&)",sym_quote:'Quote (")',sym_backtick:"Backtick (`)"},admin:{title:"Admin Dashboard",subtitle:"Connected hosts, paired devices, and relay traffic",returnToTerminal:"Return to Terminal",terminalShells:"Terminal Shells",startedAt:"Started at {time}",accessPanel:"Access",acrossWindows:"across {count} windows",perSecond:"{value}/s",framesPerSecond:"{count} fps",unitDay:"d",unitHour:"h",unitMinute:"m",unitSecond:"s",startedRecently:"Started recently",updatedAt:"Updated at {time}",autoRefresh:"Auto Refresh:",paused:"Paused",refreshNow:"Refresh",connectedHosts:"Connected Hosts",activeUsers:"Active Users",activePtys:"Active PTYs",activeController:"Active Controller",uptime:"Uptime",none:"None",noHost:"No host connected",tabOverview:"Overview",tabClients:"Clients ({count})",tabPtys:"PTY Sessions ({count})",tabDevices:"Paired Devices ({count})",throughput:"Throughput",bytesInTotal:"Total Inbound:",bytesOutTotal:"Total Outbound:",frameRate:"Frame Rate:",hostsTitle:"Hosts ({count})",noHosts:"No hosts connected or paired",hostConnectedDevices:"{count} connected",hostPairedDevices:"{count} paired",hostStatusOnline:"Online",hostStatusBusy:"In use",hostStatusReconnecting:"Reconnecting",hostStatusOffline:"Offline",hostRosterOperatorOnly:"Device list is visible to the relay operator only.",connectedClientsTitle:"Connected Clients ({count})",noClients:"No clients connected",colClientId:"Client ID",colDevice:"Device",colDeviceId:"Device ID",colLastSeen:"Last Seen",colActions:"Actions",unknownDevice:"Unknown Device",pairedDevicesTitle:"Paired Devices ({count})",noDevices:"No paired devices",revokeDevice:"Revoke",revokeConfirm:"Confirm Revocation",revokeFailed:"Revocation failed",colRole:"Role",colIp:"IP Address",colConnectedAt:"Connected At",colTraffic:"Traffic (In/Out)",activePtysTitle:"Active PTY Sessions ({count})",noPtys:"No active PTY sessions",colPtyId:"PTY ID",colPid:"PID",colCommand:"Command",colGrid:"Grid",colCwd:"Working Directory",colViewers:"Windows",copiedJson:"Copied",unauthorizedTitle:"Unauthorized (401/403)",unauthorizedDesc:"GET /api/status requires an authorized device token.",pairingStepsTitle:"Device Pairing:",pairingStepsHelp:"Run pairing command on host to get a code, then enter it here.",enterPairCodeBtn:"Enter Pairing Code",retryFetchBtn:"Retry Status",errorConnecting:"Failed to fetch GET /api/status: {error}",loadingStatus:"Loading status from /api/status...",remoteRelayTitle:"Remote Relay Administration",remoteRelayBadge:"Connected to Remote Relay",remoteRelayNotice:"Connected to remote relay. For server metrics, access the operator dashboard.",remoteRelayEndpoint:"Remote WebSocket Endpoint:",remoteRelayAdminUrl:"Remote Admin URL:",openRemoteAdminBtn:"Open Remote Admin",remoteRelayHelp:"Open remote relay admin dashboard.",relayAdminTitle:"Relay Operator Dashboard",relayAdminTokenLabel:"Relay Admin Token (X-Relay-Admin-Token)",relayAdminTokenPlaceholder:"Enter RELAY_ADMIN_TOKEN...",relayAdminNotConfigured:"RELAY_ADMIN_TOKEN is not configured on this relay.",relayAdminLoginBtn:"Verify & View Metrics",relayAdminAuthError:"Invalid or unauthorized admin token.",remoteRelayClientNotice:"Terminal client connection. For server metrics, use the operator dashboard.",openOperatorPortal:"Open Operator Dashboard",localWorkstationBadge:"Local Relay",modeLocal:"Local Mode",modeRemote:"Remote Mode",hintTabs:"switch tabs",hintRefresh:"refresh status",hintBack:"return to terminal"},toasts:{connected:"Connected to relay",connectionError:"Connection error",controlGranted:"Control granted",controlDenied:"Request denied: another controller is active",controlRevoked:"Control transferred to another device",pairedSuccess:"Paired successfully",sessionEnded:"Session ended",controlReleased:"Control released",viewerModeWarning:'In viewer mode. Click "Claim Control" first.',clientIdCopied:"Client ID copied: {id}",pairingLinkCopied:"Pairing link copied",switchedLanguage:"Language switched to {lang}",settingsReset:"Settings reset to default",fontReset:"Font reset to default",commandCopied:"Command copied",keyLayoutReset:"Key layout reset"},shortcuts:{title:"Shortcuts",help:"Active outside terminal input area:",terminalInputNote:"Terminal shortcuts pass directly to host PTY."},serverErrors:{auth_required:"Pairing required: enter a pairing code, or a device token that is still valid.",unauthorized:"This device is not authorised for that workstation.",host_offline:"The paired workstation is not connected to this relay.",host_disconnected:"The workstation disconnected.",stale_host:"The workstation stopped answering and was dropped.",too_many_clients:"That workstation has reached its window limit.",rate_limited:"Too many pairing attempts. Wait a minute and try again.",invalid_handshake:"The relay rejected the handshake. Reload the page.",device_revoked:"This device was revoked by the relay operator.",connection_closed:"Connection closed. Reconnecting…",connection_stale:"The connection went quiet while the page was away. Reconnecting…",connection_stalled:"Connecting took too long. Trying again…",connection_failed:"Could not open a connection to the relay.",host_reconnecting:"The Herdr host is reconnecting.",host_reconnect_timeout:"The Herdr host did not reconnect in time.",host_replaced:"The Herdr host connection was replaced.",slow_client:"This browser was disconnected because it could not keep up.",client_send_failed:"The relay could not send data to this browser.",too_many_hosts:"This relay has reached its host limit.",paste_file_unsupported:"Unsupported image format for paste.",paste_file_too_large:"Pasted image exceeds 3 MB limit.",paste_file_write_failed:"Failed to save pasted image on host.",paste_file_empty:"Pasted image payload is empty.",paste_file_corrupt:"Pasted image data is corrupt or does not match declared MIME.",viewer_mode:"Viewer mode cannot paste to terminal.",no_session:"Terminal session is not ready."},fontPresets:{system:"System Default",apple:"SF Mono / Menlo",windows:"Consolas",linux:"Liberation Mono",courier:"Courier New",firacode:"Fira Code"},agents:{title:"Agents on this workstation",blocked:"blocked",done:"done",working:"working",allIdle:"agents idle",notifyBlocked:"{count} agent(s) waiting for you",notifyDone:"{count} agent(s) finished"},clipboard:{openLink:"Open Link",openLinkFailed:"This link cannot be opened from the browser",copySelection:"Copy Selection",copyLine:"Copy Line",copyScreen:"Copy Screen",paste:"Paste",cancel:"Cancel",copied:"Copied to clipboard",copyFailed:"Failed to copy",pasteHint:"Long-press here to paste, then tap Send",pasteSend:"Send",pasteUnavailable:"Clipboard is empty or unavailable",pasteTitle:"Paste Content",pasted:"Pasted",chooseImage:"Choose Image",takePhoto:"Take Photo",imageTooLarge:"Image exceeds 3 MB limit and cannot be compressed further.",imageCompressedSize:"Compressed: {size}",fileEmpty:"File is empty.",decodeFailed:"Failed to decode image file.",unsupportedType:"Unsupported format. Only PNG, JPEG, WebP, and GIF are supported.",imageSectionTitle:"Image",textSectionTitle:"Text",imageCompressing:"Processing image...",removeImage:"Remove image"}},Nv={header:{appName:"Herdr",tagline:"远程终端客户端",terminalTab:"终端",adminTab:"管理面板",rttMs:"{rtt}ms",hostLabel:"主机",clientIdLabel:"客户端 ID:",copyClientIdTitle:"点击复制客户端 ID",languageToggleTitle:"切换语言 (EN / 中文)",pairingTitle:"连接与配对",settingsTitle:"终端设置",virtualKeyboardTitle:"快捷命令",latencyTitle:"网络延迟 (RTT)",mainNavigationAria:"主导航菜单",actionKeyboard:"命令",actionPairing:"配对",actionSettings:"设置",languageShort:"中"},common:{connecting:"连接中...",connected:"已连接",reconnecting:"重连中...",disconnected:"已断开",error:"错误",save:"保存",cancel:"取消",close:"关闭",done:"完成",retry:"重试",connect:"连接",disconnect:"断开连接",copy:"复制",copied:"已复制",loading:"加载中...",offline:"离线",role:"角色",host:"主机",status:"连接状态",settings:"设置",admin:"管理面板",terminal:"终端",pairing:"配对",keyBar:"按键条",quickInput:"快捷输入",dismissNotification:"关闭通知",closeDialog:"关闭对话框",clickToCopy:"点击复制",controller:"控制端",viewer:"观察者",live:"运行中"},connection:{live:"在线",connecting:"连接中",reconnecting:"正在重连",reconnectNow:"立即重连",error:"连接错误",offline:"离线",connect:"发起连接",retry:"重试"},role:{controllerMode:"控制模式",viewerMode:"观察者模式",controlActive:"控制端",viewerReadOnly:"观察者",viewerWithController:"观察者(控制者: {controllerId})",sharedControl:"完全控制",sharedControlDesc:"所有已配对窗口共享同一个终端,均可输入。",sharedWindows:"{count} 个窗口",thisWindow:"本窗口",claimControl:"获取控制权",claimControlTitle:"获取终端控制权",releaseControl:"释放控制权",releaseControlTitle:"切回观察者模式",takeoverControl:"强占控制权",takeoverControlTitle:"从 {controllerId} 接管控制权",takeoverModalTitle:"确认接管终端控制权?",takeoverModalDesc:"当前已有其他客户端控制该终端。",takeoverModalWarning:"接管后输入焦点切换至当前窗口。",confirmTakeover:"确认接管"},statusBanner:{connecting:"连接 Relay 服务中...",reconnectingDefault:"连接断开,正在重连...",reconnectNow:"立即重连",errorDefault:"无法连接 Relay 服务",disconnected:"会话已断开"},onboarding:{title:"配对 Herdr Remote",subtitle:"连接手机或浏览器至本地终端会话",description:"在浏览器或移动设备中控制 Herdr 会话。",firstTimeSetup:"首次配对",authRequired:"需要认证",authRequiredDesc:"使用配对码配对设备,或提供有效访问令牌。",step1Title:"在 Herdr 宿主机生成配对码",step1Desc:"在运行 Herdr 的主机终端执行:",step1CopyPlugin:"使用 Herdr 插件:",step1CopyCli:"复制 CLI 命令",step1TuiNote:"交互式 TUI 配置:",step2Title:"输入 6 位配对码",step2Placeholder:"例如:7X9K2A",step2Note:"配对码 5 分钟内有效,连接后自动保存凭据。",connectAndPair:"连接并完成配对",connectingAndPairing:"配对中...",advancedTitle:"高级选项",manualTokenLabel:"认证 Token",manualTokenPlaceholder:"可选 Token(跳过配对码)",wsEndpointLabel:"Relay WebSocket 端点",wsEndpointPlaceholder:"/ws/client 或 wss://relay-host/ws/client",clientIdLabel:"客户端标识 (Client ID)"},pairing:{title:"Relay 连接与配对",addTitle:"添加 Herdr 实例",displayNameLabel:"主机名称",displayNamePlaceholder:"例如:工作电脑",displayNameHelp:"名称仅保存在此浏览器中。",credentialsRequired:"请输入配对码或设备令牌。",subtitle:"管理 WebSocket 服务端点与凭证",pairCodeLabel:"配对码",pairCodeNote:"(6 位代码)",pairCodePlaceholder:"例如:A1B2C3",pairCodeHelp:'在主机运行 "herdr-remote pair" 获取。',tokenLabel:"访问 Token",tokenNote:"(设备凭据)",tokenPlaceholder:"设备 Token...",wsUrlLabel:"Relay WebSocket 端点",wsUrlPlaceholder:"/ws/client",wsUrlDefaultNote:'默认同源端点 "/ws/client"',clientIdLabel:"客户端标识",newIdButton:"生成新 ID",regenerateClientIdTitle:"重新生成客户端 ID",autoReconnectLabel:"掉线自动重连",autoReconnectDesc:"连接断开时自动尝试重连",copyDirectLink:"复制配对链接(含配对码)",saveAndConnect:"保存并连接"},settings:{title:"终端设置",subtitle:"字体、字号与触控管理",tabGeneral:"常规设置",tabAppearance:"终端与字体",tabVirtualKeys:"虚拟按键",fontFamilyLabel:"等宽字体",fontSizeLabel:"终端字号 ({size}px)",fontSizeCompact:"10px (紧凑)",fontSizeDefault:"15px (默认)",fontSizeLarge:"24px (大字号)",mobileFontNote:"小屏设备自动适配字号,保持 80 列完整显示。",colorPassthroughNote:"终端配色与光标样式透传自宿主环境。",predictiveEchoLabel:"预测回显",predictiveEchoAuto:"自动",predictiveEchoAlways:"始终开启",predictiveEchoOff:"关闭",predictiveEchoDesc:"高延迟时,在 shell 提示符或智能体输入框里先行显示输入的字符,回显到达后自动校正。菜单等其他界面不做预测。",touchKeyToolbar:"底部触控按键条",touchKeyToolbarDesc:"显示移动端修饰键与方向键工具栏",touchHaptics:"触控振动反馈",touchHapticsDesc:"移动端按键时轻微震动",agentAlertsLabel:"智能体提醒",agentAlertBadge:"标题与图标角标",agentAlertBadgeDesc:"在标签页标题里显示等待确认和已完成的智能体数量,并在图标上加角标",agentAlertVibrate:"震动",agentAlertVibrateDesc:"智能体停下来等你确认或完成时震动(页面在前台时)",agentAlertSound:"提示音",agentAlertSoundDesc:"页面在后台时播放短提示音;下次点击页面后生效",agentAlertNotify:"系统通知",agentAlertNotifyDesc:"页面在后台时发系统通知(仅 HTTPS)",languageLabel:"显示语言",languageDesc:"选择 English 或 简体中文",resetDefaults:"恢复默认设置",resetDefaultsToast:"设置已恢复默认",windowZoomSharedNote:"当前宿主未启用视图隔离,字号调整仅影响本地窗口。",fontSizeZoomHelp:"仅调节当前窗口字号,不影响其他窗口。"},virtualKeyboard:{collapseToolbar:"收起按键栏",expandToolbar:"展开按键栏",helperTitle:"快捷命令",closeHelper:"关闭命令助手",placeholder:"输入终端命令并回车...",sendButton:"发送",clearInput:"清除输入内容",customizeTitle:"自定义虚拟按键",customizeDesc:"调整按键顺序与启禁用状态。",enabledKeysCount:"已启用 {count} 个按键",resetLayout:"恢复默认布局",addKey:"添加按键",availableKeys:"可选按键库",moveUp:"前移",moveDown:"后移",enableKey:"启用按键",disableKey:"禁用按键",deleteKeyTitle:"删除按键",keyTypeModifier:"修饰键",keyTypeNav:"导航键",keyTypeAction:"动作键",keyTypeChord:"组合键",keyTypeFn:"功能键",keyTypeSymbol:"符号",fnDrawerTitle:"功能键 (F1-F12)",chordsDrawerTitle:"控制组合键 (^C, ^D, ^Z)",symbolsDrawerTitle:"终端常用符号 (~, |, /, \\)",touchKeyboardShortcuts:"快捷键工具栏",ctrlCTitle:"Ctrl+C (中断)",ctrlDTitle:"Ctrl+D (退出)",ctrlZTitle:"Ctrl+Z (挂起)",ctrlLTitle:"Ctrl+L (清屏)",ctrlRTitle:"Ctrl+R (搜索)",ctrlATitle:"Ctrl+A (行首)",ctrlETitle:"Ctrl+E (行尾)",ctrlKTitle:"Ctrl+K (剪切)",badgeSigint:"中断",badgeEof:"退出",badgeTstp:"挂起",badgeClear:"清屏",badgeSearch:"搜索",badgeStart:"行首",badgeEnd:"行尾",badgeKill:"剪切",keyEnter:"回车",uploadImage:"上传图片",uploadImageTitle:"选择图片并上传至终端",image:"图片",uploadProgressReading:"读取中...",uploadProgressProcessing:"处理压缩中...",uploadProgressSending:"上传中...",uploadProgressWaitingHost:"等待工作站保存...",uploadProgressCompleted:"完成",uploadProgressFailed:"上传失败"},profiles:{title:"Herdr 实例",switcherLabel:"切换 Herdr 实例",current:"当前",empty:"还没有已配对的 Herdr 实例。",addHost:"添加 Herdr 实例",rename:"重命名实例",remove:"仅本地移除",removeConfirm:"确认从此浏览器移除已保存的连接?"},mobile:{sessionControls:"会话控制",closeSessionControls:"关闭会话控制面板",connectionStatusAria:"连接状态",terminalControlAria:"终端控制权",inputControl:"输入控制权",settingsAria:"终端设置",adminAria:"打开管理面板",pairingAria:"连接与配对设置",keybarAria:"切换触控按键条",quickInputAria:"切换快捷命令",menu:"菜单",statusBarAria:"会话状态栏"},terminal:{bannerTitle:"Herdr Remote WebUI",bannerSubtitle:"已连接至 Herdr 会话。",windowAriaLabel:"远程终端窗口",bufferAriaLabel:"xterm 终端缓冲区",offlineStatusAria:"离线状态",releaseControlAria:"释放终端控制权",takeoverControlAria:"强占终端控制权",claimControlAria:"获取终端控制权"},keyTitles:{esc:"Escape (ESC)",tab:"Tab",shift_tab:"Shift+Tab(Claude Code 切换模式)",ctrl:"切换 Ctrl 锁定",alt:"切换 Alt 锁定",shift:"切换 Shift 锁定",meta:"Meta / 命令键",enter:"回车 (Enter)",backspace:"退格 (Backspace)",delete:"删除 (Delete)",left:"左箭头 (←)",up:"上箭头 (↑)",down:"下箭头 (↓)",right:"右箭头 (→)",home:"行首 (Home)",end:"行尾 (End)",page_up:"向上翻页 (Page Up)",page_down:"向下翻页 (Page Down)",insert:"插入 (Insert)",drawer_chords:"常用 Ctrl 组合键",drawer_symbols:"常用特殊符号",drawer_fn:"功能键 (F1-F12)",ctrl_c:"Ctrl+C (中断)",ctrl_d:"Ctrl+D (退出)",ctrl_z:"Ctrl+Z (挂起)",ctrl_l:"Ctrl+L (清屏)",ctrl_a:"Ctrl+A (行首)",ctrl_e:"Ctrl+E (行尾)",ctrl_k:"Ctrl+K (剪切)",ctrl_r:"Ctrl+R (历史搜索)",f1:"F1",f2:"F2",f3:"F3",f4:"F4",f5:"F5",f6:"F6",f7:"F7",f8:"F8",f9:"F9",f10:"F10",f11:"F11",f12:"F12",sym_pipe:"管道符 (|)",sym_tilde:"波浪号 (~)",sym_slash:"正斜杠 (/)",sym_backslash:"反斜杠 (\\)",sym_dash:"连字符 (-)",sym_underscore:"下划线 (_)",sym_dollar:"美元符 ($)",sym_ampersand:"与符号 (&)",sym_quote:'双引号 (")',sym_backtick:"反引号 (`)"},admin:{title:"系统管理面板",subtitle:"接入主机、配对设备与中转流量",returnToTerminal:"返回终端",terminalShells:"个终端 Shell",startedAt:"启动于 {time}",accessPanel:"接入概览",acrossWindows:"共 {count} 个窗口",perSecond:"{value}/秒",framesPerSecond:"{count} 帧/秒",unitDay:" 天",unitHour:" 小时",unitMinute:" 分",unitSecond:" 秒",startedRecently:"最近启动",updatedAt:"更新于 {time}",autoRefresh:"自动刷新:",paused:"暂停刷新",refreshNow:"立即刷新",connectedHosts:"接入主机",activeUsers:"活跃用户",activePtys:"活动 PTY",activeController:"活跃控制者",uptime:"运行时间",none:"无",noHost:"未连接主机",tabOverview:"系统概览",tabClients:"客户端列表 ({count})",tabPtys:"PTY 会话 ({count})",tabDevices:"已配对设备 ({count})",throughput:"网络吞吐流量",bytesInTotal:"入站流量:",bytesOutTotal:"出站流量:",frameRate:"帧率统计:",hostsTitle:"主机 ({count})",noHosts:"暂无接入或配对的主机",hostConnectedDevices:"{count} 台在线",hostPairedDevices:"{count} 台已配对",hostStatusOnline:"在线",hostStatusBusy:"使用中",hostStatusReconnecting:"重连中",hostStatusOffline:"离线",hostRosterOperatorOnly:"设备清单仅 Relay 操作员可见。",connectedClientsTitle:"已连接客户端 ({count})",noClients:"当前暂无客户端连接",colClientId:"客户端 ID",colDevice:"设备",colDeviceId:"设备 ID",colLastSeen:"最近活动",colActions:"操作",unknownDevice:"未知设备",pairedDevicesTitle:"已配对设备 ({count})",noDevices:"尚未配对任何设备",revokeDevice:"撤销",revokeConfirm:"确认撤销",revokeFailed:"撤销失败",colRole:"角色",colIp:"IP 地址",colConnectedAt:"连接时间",colTraffic:"网络流量 (入/出)",activePtysTitle:"活动 PTY 终端会话 ({count})",noPtys:"当前无活跃的 PTY 会话",colPtyId:"PTY 标识",colPid:"进程 PID",colCommand:"运行命令",colGrid:"网格规格",colCwd:"工作目录",colViewers:"窗口数",copiedJson:"已复制",unauthorizedTitle:"管理接口未授权 (401/403)",unauthorizedDesc:"访问 GET /api/status 需要已授权的设备 Token。",pairingStepsTitle:"设备配对指引:",pairingStepsHelp:"在主机运行配对命令获取配对码后输入。",enterPairCodeBtn:"输入配对码",retryFetchBtn:"重新获取状态",errorConnecting:"连接 GET /api/status 失败:{error}",loadingStatus:"正在加载系统状态...",remoteRelayTitle:"远程 Relay 服务管理",remoteRelayBadge:"已连接远程 Relay 服务",remoteRelayNotice:"当前连接至远程独立 Relay 服务。如需查看服务端指标,请使用操作员后台。",remoteRelayEndpoint:"远程端点:",remoteRelayAdminUrl:"远程后台地址:",openRemoteAdminBtn:"前往远程管理后台",remoteRelayHelp:"直接访问远程 Relay 管理后台。",relayAdminTitle:"Relay 操作员管理后台",relayAdminTokenLabel:"Relay 管理员令牌 (X-Relay-Admin-Token)",relayAdminTokenPlaceholder:"请输入 RELAY_ADMIN_TOKEN...",relayAdminNotConfigured:"该 Relay 服务未配置 RELAY_ADMIN_TOKEN。",relayAdminLoginBtn:"验证并查看服务端指标",relayAdminAuthError:"管理员令牌无效或未授权。",remoteRelayClientNotice:"当前为终端客户端连接。如需查看服务端指标,请访问操作员后台。",openOperatorPortal:"打开服务端管理后台",localWorkstationBadge:"本地宿主 Relay",modeLocal:"本地模式",modeRemote:"远程模式",hintTabs:"切换标签页",hintRefresh:"刷新状态",hintBack:"返回终端"},toasts:{connected:"已连接至 Relay 服务",connectionError:"连接发生错误",controlGranted:"已获得控制权",controlDenied:"控制请求被拒绝:已有活跃控制者",controlRevoked:"控制权已转移",pairedSuccess:"设备配对成功,已保存凭证",sessionEnded:"终端会话已结束",controlReleased:"已释放控制权,切回观察者模式",viewerModeWarning:"处于观察者模式,请先获取控制权",clientIdCopied:"客户端 ID 已复制: {id}",pairingLinkCopied:"配对链接已复制",switchedLanguage:"语言已切换为 {lang}",settingsReset:"设置已恢复默认",fontReset:"字体已恢复默认",commandCopied:"命令已复制",keyLayoutReset:"虚拟按键布局已恢复默认"},shortcuts:{title:"WebUI 快捷键",help:"以下快捷键仅在非终端输入区域生效:",terminalInputNote:"终端操作快捷键直接透传至宿主 PTY。"},serverErrors:{auth_required:"需要配对:请输入配对码,或填写仍然有效的设备令牌。",unauthorized:"该设备无权访问此工作站。",host_offline:"已配对的工作站未连接到该 relay。",host_disconnected:"工作站已断开连接。",stale_host:"工作站长时间无响应,已被断开。",too_many_clients:"该工作站的窗口数量已达上限。",rate_limited:"配对尝试过于频繁,请稍后再试。",invalid_handshake:"relay 拒绝了握手,请刷新页面。",device_revoked:"该设备已被 relay 管理员撤销。",connection_closed:"连接已断开,正在重连…",connection_stale:"页面回到前台时连接已无响应,正在重连…",connection_stalled:"连接超时,正在重试…",connection_failed:"无法建立到 relay 的连接。",host_reconnecting:"Herdr 主机正在重连。",host_reconnect_timeout:"Herdr 主机未能及时恢复连接。",host_replaced:"Herdr 主机连接已被替换。",slow_client:"由于浏览器处理速度过慢,连接已关闭。",client_send_failed:"Relay 无法向此浏览器发送数据。",too_many_hosts:"此 relay 已达到主机数量上限。",paste_file_unsupported:"不支持的粘贴图片格式。",paste_file_too_large:"粘贴图片超过 3 MB 上限。",paste_file_write_failed:"工作站保存图片失败。",paste_file_empty:"粘贴图片内容为空。",paste_file_corrupt:"粘贴图片数据损坏或与声明格式不符。",viewer_mode:"观察者模式无法粘贴到终端。",no_session:"终端会话未准备就绪。"},fontPresets:{system:"系统默认",apple:"Apple SF Mono / Menlo",windows:"Windows Consolas",linux:"Linux Liberation Mono",courier:"Courier New",firacode:"Fira Code"},agents:{title:"本工作站的智能体",blocked:"待确认",done:"已完成",working:"运行中",allIdle:"智能体空闲",notifyBlocked:"{count} 个智能体在等你确认",notifyDone:"{count} 个智能体已完成"},clipboard:{openLink:"打开链接",openLinkFailed:"该链接无法在浏览器中打开",copySelection:"复制选中",copyLine:"复制本行",copyScreen:"复制整屏",paste:"粘贴",cancel:"取消",copied:"已复制到剪贴板",copyFailed:"复制失败",pasteHint:"长按此处粘贴,然后按发送",pasteSend:"发送",pasteUnavailable:"剪贴板为空或不可用",pasteTitle:"粘贴内容",pasted:"已粘贴",chooseImage:"选择图片",takePhoto:"拍照",imageTooLarge:"图片超过 3 MB 限制且无法进一步压缩。",imageCompressedSize:"压缩后大小:{size}",fileEmpty:"文件内容为空。",decodeFailed:"无法解析图片文件。",unsupportedType:"不支持的图片格式,仅支持 PNG、JPEG、WebP 和 GIF。",imageSectionTitle:"图片",textSectionTitle:"文本",imageCompressing:"正在处理图片...",removeImage:"移除图片"}},Au={en:Tv,zh:Nv};function Pu(r,a,i){const o=Au[r]||Au.en,d=a.split(".");let f=o;for(const p of d)if(f&&typeof f=="object"&&p in f)f=f[p];else{let m=Au.en;for(const b of d)if(m&&typeof m=="object"&&b in m)m=m[b];else return a;f=m;break}if(typeof f!="string")return a;if(i){let p=f;for(const[m,b]of Object.entries(i))p=p.replaceAll(`{${m}}`,String(b));return p}return f}const Wm="#11111b",Gu=[{id:"system",name:"System Default (Recommended)",font:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", "Symbols Nerd Font Mono", monospace'},{id:"apple",name:"Apple SF Mono / Menlo",font:'SFMono-Regular, Menlo, Monaco, "Symbols Nerd Font Mono", monospace'},{id:"windows",name:"Windows Consolas",font:'Consolas, "Lucida Console", "Symbols Nerd Font Mono", monospace'},{id:"linux",name:"Linux Liberation Mono",font:'"Liberation Mono", "DejaVu Sans Mono", "Symbols Nerd Font Mono", monospace'},{id:"courier",name:"Courier New",font:'"Courier New", Courier, "Symbols Nerd Font Mono", monospace'},{id:"firacode",name:"Fira Code (Ligatures)",font:'"Fira Code", "Symbols Nerd Font Mono", monospace'}];function Pm(r){if(!r||typeof r!="string")return Gu[0].font;const a=r.trim();if(a.includes("Symbols Nerd Font"))return a;if(/^['"]?monospace['"]?$/i.test(a))return'"Symbols Nerd Font Mono", monospace';const i=/,\s*['"]?monospace['"]?\s*$/i;return i.test(a)?a.replace(i,', "Symbols Nerd Font Mono", monospace'):`${a}, "Symbols Nerd Font Mono", monospace`}function Av(r){if(!r)return null;const a={};return r.background&&(a.background=r.background,a.cursorAccent=r.background),r.foreground&&(a.foreground=r.foreground),r.cursor&&(a.cursor=r.cursor),r.ansi&&Object.assign(a,r.ansi),Object.keys(a).length===0?null:a}function Jp(){if(typeof document>"u")return;const r=document.querySelector('meta[name="theme-color"]');document.documentElement.style.colorScheme="dark",r==null||r.setAttribute("content",Wm),document.documentElement.classList.add("dark"),document.documentElement.classList.remove("light"),document.body.classList.add("dark"),document.body.classList.remove("light"),document.body.style.backgroundColor=Wm}const Wp=1568,Ev=3*1024*1024,Rv=[.85,.7,.55,.4],ol={active:!1,phase:"idle",ratio:0,percent:0,statusText:""};function jv(r,a,i=Wp){if(r<=0||a<=0)return{width:Math.max(1,r),height:Math.max(1,a)};const o=Math.max(r,a);if(o<=i)return{width:r,height:a};const d=i/o;return{width:Math.max(1,Math.round(r*d)),height:Math.max(1,Math.round(a*d))}}function kv(r){if(typeof r!="string"||r.length===0)return 0;const a=r.length;let i=0;r.endsWith("==")?i=2:r.endsWith("=")&&(i=1);const o=Math.floor(a*3/4)-i;return Number.isFinite(o)&&o>0?o:0}function Mv(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}async function _v(r){if(typeof createImageBitmap=="function")try{const a=await createImageBitmap(r,{imageOrientation:"from-image"});return{source:a,width:a.width,height:a.height,cleanup:()=>{typeof a.close=="function"&&a.close()}}}catch{try{const a=await createImageBitmap(r);return{source:a,width:a.width,height:a.height,cleanup:()=>{typeof a.close=="function"&&a.close()}}}catch{}}return new Promise((a,i)=>{if(typeof Image>"u")return i(new Error("Image decoding not supported in this environment"));const o=new Image,d=URL.createObjectURL(r);o.onload=()=>{a({source:o,width:o.naturalWidth||o.width,height:o.naturalHeight||o.height,cleanup:()=>{try{URL.revokeObjectURL(d)}catch{}}})},o.onerror=()=>{try{URL.revokeObjectURL(d)}catch{}i(new Error("Failed to decode image source"))},o.src=d})}async function Pp(r,a=Wp,i=Ev){var d;if(!r||r.size===0||r.type&&!r.type.startsWith("image/"))return null;let o;try{o=await _v(r)}catch(f){return console.warn("Failed to decode image for paste:",f),null}try{const{width:f,height:p}=jv(o.width,o.height,a),m=document.createElement("canvas");m.width=f,m.height=p;const b=m.getContext("2d");if(!b)return null;b.drawImage(o.source,0,0,f,p);let v="image/webp";try{m.toDataURL("image/webp",.85).startsWith("data:image/webp")||(v="image/jpeg")}catch{v="image/jpeg"}for(const y of Rv){let S;try{S=m.toDataURL(v,y)}catch{continue}if(!S||!S.startsWith("data:"))continue;const A=S.indexOf(","),E=A!==-1?S.slice(A+1):"",R=kv(E);if(R<=i)return{mime:v,dataBase64:E,dataUrl:S,byteLength:R,width:f,height:p}}return null}finally{(d=o.cleanup)==null||d.call(o)}}const zv=4e3,Dv=3,Lv=4096,Ov=8*1024*1024,ao={ctrl:!1,alt:!1,shift:!1},$p=x.createContext(null);function _i(r){return{wsUrl:r.wsUrl,token:r.token||void 0,pairCode:r.pairCode||void 0,clientId:r.clientId,autoReconnect:r.autoReconnect,reconnectIntervalMs:2e3,maxReconnectAttempts:0,pingIntervalMs:1e4}}const Uv=({children:r})=>{const[a,i]=x.useState(Qp),[o,d]=x.useState("disconnected"),[f,p]=x.useState(),[m,b]=x.useState(),[v,y]=x.useState("viewer"),[S,A]=x.useState(),[E,R]=x.useState(),[H,z]=x.useState(),[G,Q]=x.useState(null),[X,re]=x.useState(),[de,ee]=x.useState(null),[T,_]=x.useState(1),[P,le]=x.useState(0),[ve,Se]=x.useState(null),[fe,Re]=x.useState(null),[Ge,D]=x.useState(null),[F,J]=x.useState({cols:80,rows:24}),[q,V]=x.useState([]);x.useEffect(()=>{Jp()},[]);const je=x.useRef(a);je.current=a;const pe=x.useRef(null),ke=x.useRef(!1),Ye=x.useRef(F);Ye.current=F;const Ke=x.useRef(new Set),Qe=x.useRef(new Set),[$t,tt]=x.useState(ol),we=x.useRef(null),hn=x.useRef(0),qe=x.useRef(null),Je=x.useCallback((L,U)=>Pu(a.language,L,U),[a.language]),We=x.useRef(Je);We.current=Je;const wt=x.useRef(null),gt=x.useRef([]),qt=x.useRef(0),Tn=x.useCallback(L=>{for(gt.current.push(L),qt.current+=L.byteLength;gt.current.length>Lv||qt.current>Ov;){const U=gt.current.shift();if(!U)break;qt.current-=U.byteLength}},[]),Nn=x.useCallback(L=>{const U=wt.current;if(U)try{U(L);return}catch(ie){console.debug("Terminal output sink threw, buffering chunk instead:",ie)}Tn(L)},[Tn]),Hn=x.useRef(Nn);Hn.current=Nn;const $n=x.useCallback(L=>{wt.current=L;const U=gt.current;gt.current=[],qt.current=0;for(let ie=0;ie<U.length;ie++)try{L(U[ie])}catch(Te){console.debug("Terminal sink threw while flushing, re-buffering the tail:",Te);for(let Ce=ie;Ce<U.length;Ce++)Tn(U[Ce]);break}return()=>{wt.current===L&&(wt.current=null)}},[Tn]),kt=x.useCallback(()=>gt.current.length,[]),Pe=x.useCallback(()=>{gt.current=[],qt.current=0},[]),Ct=x.useCallback((L=!0)=>{y("viewer"),A(void 0),R(void 0),z(void 0),Q(null),re(void 0),ee(null),_(1),Se(null),Pe(),L&&le(U=>U+1)},[Pe]),ae=x.useRef([]),Ae=x.useRef(new Map),Le=x.useCallback(L=>{ae.current=L,V(L)},[]),ot=x.useCallback(L=>{const U=Ae.current.get(L);U&&(clearTimeout(U),Ae.current.delete(L)),Le(ae.current.filter(ie=>ie.id!==L))},[Le]),sn=x.useRef(ot);sn.current=ot;const bt=x.useCallback((L,U)=>{const ie=Date.now(),Te=ae.current,Ce=Te.find(ft=>ft.type===L&&ft.message===U),Ee=Ce?Ce.id:`${ie}-${Math.random().toString(36).substring(2,6)}`;let Oe;if(Ce)Oe=Te.map(ft=>ft.id===Ee?{...ft,count:ft.count+1,timestamp:ie}:ft);else for(Oe=[...Te,{id:Ee,type:L,message:U,timestamp:ie,count:1}];Oe.length>Dv;){const[ft,...jn]=Oe,on=Ae.current.get(ft.id);on&&(clearTimeout(on),Ae.current.delete(ft.id)),Oe=jn}Le(Oe);const Bt=Ae.current.get(Ee);Bt&&clearTimeout(Bt),Ae.current.set(Ee,setTimeout(()=>sn.current(Ee),zv))},[Le]),zt=x.useCallback(L=>{sn.current(L)},[]),Yn=x.useRef(!0);x.useEffect(()=>{v==="controller"&&(Yn.current=!0)},[v]);const Vt=x.useCallback(()=>{Yn.current&&(Yn.current=!1,bt("warning",We.current("toasts.viewerModeWarning")))},[bt]);x.useEffect(()=>{const L=Ae.current;return()=>{for(const U of L.values())clearTimeout(U);L.clear()}},[]);const Ut=x.useCallback(L=>{const U=Na(L);je.current=U,i(U)},[]),yt=x.useCallback(L=>{Ut({language:L})},[Ut]),nt=x.useCallback(L=>{je.current=L,i(L)},[]),Tt=x.useCallback(L=>{var Ce;const U=je.current,ie=Zm({...L,wsUrl:L.wsUrl||"/ws/client",token:L.token||"",displayName:L.displayName||`Herdr ${U.profiles.length+1}`,autoReconnect:L.autoReconnect!==!1},U.profiles.length),Te=Na({profiles:[...U.profiles,ie],activeProfileId:ie.id,wsUrl:ie.wsUrl,token:ie.token,pairCode:ie.pairCode||"",autoReconnect:ie.autoReconnect});nt(Te),Ct(),(Ce=pe.current)==null||Ce.reconnectWith(_i(Te))},[nt,Ct]),ei=x.useCallback(L=>{var Ce;const U=je.current,ie=U.profiles.find(Ee=>Ee.id===L);if(!ie||ie.id===U.activeProfileId)return;const Te=Na({activeProfileId:ie.id,wsUrl:ie.wsUrl,token:ie.token,pairCode:ie.pairCode||"",autoReconnect:ie.autoReconnect,profiles:U.profiles.map(Ee=>Ee.id===ie.id?{...Ee,lastUsedAt:Date.now()}:Ee)});nt(Te),Ct(),(Ce=pe.current)==null||Ce.reconnectWith(_i(Te))},[nt,Ct]),An=x.useCallback((L,U)=>{const ie=je.current;if(!ie.profiles.find(Oe=>Oe.id===L))return;const Ce=U.trim().slice(0,64);if(!Ce)return;const Ee=Na({profiles:ie.profiles.map(Oe=>Oe.id===L?{...Oe,displayName:Ce}:Oe)});nt(Ee)},[nt]),el=x.useCallback(L=>{var Ee;const U=je.current;if(!U.profiles.some(Oe=>Oe.id===L))return;const ie=U.profiles.filter(Oe=>Oe.id!==L),Te=ie.find(Oe=>Oe.id===U.activeProfileId)||ie[0],Ce=Na(Te?{profiles:ie,activeProfileId:Te.id,wsUrl:Te.wsUrl,token:Te.token,pairCode:Te.pairCode||"",autoReconnect:Te.autoReconnect}:{profiles:[],activeProfileId:"",wsUrl:"/ws/client",token:"",pairCode:""});nt(Ce),L===U.activeProfileId&&(Ct(),(Ee=pe.current)==null||Ee.reconnectWith(_i(Ce)))},[nt,Ct]),wl=x.useCallback(L=>{const U=je.current,ie=U.profiles.find(at=>at.id===U.activeProfileId),Te=L.hostId?Qm({wsUrl:U.wsUrl,hostId:L.hostId}):null,Ce=Te?U.profiles.findIndex(at=>Qm(at)===Te):-1,Ee=Ce>=0?Ce:Math.max(0,U.profiles.findIndex(at=>at.id===U.activeProfileId)),Bt={...U.profiles[Ee]||ie||Zm({wsUrl:U.wsUrl||"/ws/client",token:"",pairCode:U.pairCode||"PENDING",displayName:`Herdr ${U.profiles.length+1}`},U.profiles.length),token:L.token,pairCode:void 0,...L.hostId?{hostId:L.hostId}:{},...L.deviceId?{deviceId:L.deviceId}:{},lastUsedAt:Date.now()};let ft=[...U.profiles];Ee>=0&&Ee<ft.length?ft[Ee]=Bt:ft.push(Bt);const jn=ie==null?void 0:ie.id;ft=ft.filter((at,ka)=>ka===Ee||at.id===Bt.id?!0:!(Ce>=0&&jn&&at.id===jn));const on=Na({profiles:ft,activeProfileId:Bt.id,wsUrl:Bt.wsUrl,token:Bt.token,pairCode:"",autoReconnect:Bt.autoReconnect});return nt(on),on},[nt]),Zt=x.useCallback(L=>{const U=je.current,ie=U.profiles.find(Oe=>Oe.id===U.activeProfileId);if(!ie||!L.hostId&&!L.hostname)return;const Te=/^Herdr \d+$/.test(ie.displayName),Ce={...ie,...L.hostId?{hostId:L.hostId}:{},...L.hostname?{hostname:L.hostname}:{},...L.hostname&&Te?{displayName:L.hostname}:{}},Ee=Na({profiles:U.profiles.map(Oe=>Oe.id===ie.id?Ce:Oe)});nt(Ee)},[nt]);if(!pe.current){const L=new cv(_i(a));pe.current=L,L.on("stateChange",(U,ie,Te)=>{d(U),b(Te);const Ce=Te?`serverErrors.${Te}`:null,Ee=Ce?We.current(Ce):null,Oe=Ee&&Ee!==Ce?Ee:ie;p(Oe),U==="connected"?bt("success",We.current("toasts.connected")):U==="error"&&bt("error",Oe||We.current("toasts.connectionError")),U!=="connected"&&Re(null)}),L.on("ready",U=>{ke.current&&(Pe(),le(ie=>ie+1)),ke.current=!0,y(U.role),A(U.controllerId),R(U.hostId),z(U.hostname),Zt(U),U.clientId&&re(U.clientId),Q(U.terminalPalette||null)}),L.on("hostReconnecting",U=>{b(U||"host_reconnecting"),p(We.current(`serverErrors.${U||"host_reconnecting"}`)),y("viewer"),A(void 0),z(void 0),Q(null),ee(null),_(1),Se(null),Pe()}),L.on("sessionRestarted",(U,ie,Te,Ce)=>{Pe(),z(Ce),Zt({hostId:L.getHostId(),hostname:Ce}),Q(Te||null),le(Ee=>Ee+1)}),L.on("roleChange",(U,ie,Te,Ce)=>{y(U),A(ie),Te&&R(Te),Ce&&re(Ce)}),L.on("controlGranted",()=>{y("controller"),bt("success",We.current("toasts.controlGranted"))}),L.on("controlDenied",U=>{bt("warning",U||We.current("toasts.controlDenied"))}),L.on("controlRevoked",U=>{y("viewer"),bt("warning",U||We.current("toasts.controlRevoked"))}),L.on("paired",U=>{const ie=wl(U);bt("success",We.current("toasts.pairedSuccess")),D(Date.now()),L.reconnectWith(_i(ie))}),L.on("exit",(U,ie)=>{bt("info",`${We.current("toasts.sessionEnded")}${ie?`: ${ie}`:""}${U!==void 0?` (${U})`:""}`)}),L.on("status",U=>{Se(U)}),L.on("error",U=>{we.current!==null&&(qe.current&&(clearTimeout(qe.current),qe.current=null),we.current=null,tt(ol));const Te=`serverErrors.${String(U.code)}`,Ce=We.current(Te),Ee=Ce&&Ce!==Te?Ce:U.message||`[${U.code}]`;bt("error",Ee)}),L.on("pasteFileReady",U=>{const ie=we.current;ie!==null&&(qe.current&&(clearTimeout(qe.current),qe.current=null),tt({active:!0,phase:"completed",ratio:1,percent:100,statusText:We.current("virtualKeyboard.uploadProgressCompleted")}),setTimeout(()=>{we.current===ie&&(we.current=null,tt(ol))},1200));for(const Te of Ke.current)try{Te(U)}catch(Ce){console.error("Error in pasteFileReady listener:",Ce)}}),L.on("rttUpdate",U=>{ee(U)}),L.on("peerCount",U=>{_(Math.max(1,U))}),L.on("sessionReady",()=>{d("connected")}),L.on("agentStatus",U=>{Re(U)}),L.on("binaryData",U=>{Hn.current(U)})}const Cl=pe.current,mn=a.profiles.find(L=>L.id===a.activeProfileId);x.useEffect(()=>{var L;(L=pe.current)==null||L.updateConfig(_i(a))},[a]);const Tl=x.useCallback(L=>{pe.current&&(L&&pe.current.updateConfig(L),pe.current.connect(Ye.current))},[]),fl=x.useCallback(()=>{pe.current&&pe.current.disconnect()},[]),tl=x.useCallback((L=!1)=>{pe.current&&pe.current.claimControl(L)},[]),En=x.useCallback(()=>{var L;(L=pe.current)==null||L.releaseControl()},[]),Kn=x.useCallback(L=>{if(v!=="controller"){Vt();return}const U=pe.current;if(!U)return;const ie=Iu(L);for(const Te of Qe.current)try{Te(ie)}catch(Ce){console.debug("Key input observer threw:",Ce)}U.sendInput(ie)},[v,Vt]),Rn=x.useCallback(L=>(Qe.current.add(L),()=>{Qe.current.delete(L)}),[]),[qi,Il]=x.useState(ao),nl=x.useRef(ao),ja=x.useCallback(L=>{const U={...nl.current,[L]:!nl.current[L]};nl.current=U,Il(U)},[]),Zl=x.useCallback(()=>{const L=nl.current;return!L.ctrl&&!L.alt&&!L.shift?null:(nl.current=ao,Il(ao),L)},[]);x.useEffect(()=>{const L=pe.current;return L?uv(L):void 0},[]);const hl=x.useCallback(L=>{v!=="controller"&&!mo(L)||pe.current&&pe.current.sendInput(L)},[v]),Nl=x.useCallback((L,U)=>{Ye.current={cols:L,rows:U},J({cols:L,rows:U}),pe.current&&pe.current.sendResize(L,U)},[]),Ql=x.useCallback((L,U)=>v!=="controller"?(Vt(),!1):pe.current?(pe.current.sendPasteFile(L,U),!0):!1,[v,Vt]),Gn=x.useCallback(L=>(Ke.current.add(L),()=>{Ke.current.delete(L)}),[]),Dt=x.useCallback(()=>{qe.current&&(clearTimeout(qe.current),qe.current=null),we.current=null,tt(ol)},[]);x.useEffect(()=>{o!=="connected"&&we.current!==null&&(qe.current&&(clearTimeout(qe.current),qe.current=null),we.current=null,tt(ol))},[o]),x.useEffect(()=>()=>{qe.current&&clearTimeout(qe.current)},[]);const Qt=x.useCallback(async L=>{if(v!=="controller")return Vt(),!1;if(!pe.current||o!=="connected")return bt("error",Je("serverErrors.host_offline")),!1;if(we.current!==null)return!1;const U=++hn.current;we.current=U,qe.current&&(clearTimeout(qe.current),qe.current=null);const ie="dataBase64"in L&&typeof L.dataBase64=="string";try{let Te;if(ie)Te=L;else{const Ee=L;if(tt({active:!0,phase:"reading",ratio:.1,percent:10,statusText:Je("virtualKeyboard.uploadProgressReading")}),!Ee||Ee.size===0)return bt("error",Je("clipboard.fileEmpty")),we.current=null,tt(ol),!1;if(Ee.type&&!Ee.type.startsWith("image/"))return bt("error",Je("clipboard.unsupportedType")),we.current=null,tt(ol),!1;tt({active:!0,phase:"processing",ratio:.35,percent:35,statusText:Je("virtualKeyboard.uploadProgressProcessing")});const Oe=await Pp(Ee);if(we.current!==U)return!1;if(!Oe)return bt("error",Je("clipboard.imageTooLarge")),we.current=null,tt(ol),!1;Te=Oe,tt({active:!0,phase:"processing",ratio:.6,percent:60,statusText:Je("virtualKeyboard.uploadProgressProcessing")})}tt({active:!0,phase:"sending",ratio:.75,percent:75,statusText:Je("virtualKeyboard.uploadProgressSending")});const Ce=Ql(Te.mime,Te.dataBase64);return we.current!==U?!1:Ce?(tt({active:!0,phase:"waitingHost",ratio:.88,percent:88,statusText:Je("virtualKeyboard.uploadProgressWaitingHost")}),qe.current=setTimeout(()=>{we.current===U&&(we.current=null,bt("error",Je("serverErrors.paste_file_write_failed")),tt(ol))},3e4),!0):(we.current=null,tt(ol),!1)}catch(Te){return console.error("Failed to process/upload image:",Te),we.current===U&&(we.current=null,bt("error",Je("clipboard.imageTooLarge")),tt(ol)),!1}},[v,o,Vt,bt,Je,Ql]);return u.jsx($p.Provider,{value:{connectionState:o,stateDetail:f,stateCode:m,role:v,controllerId:S,hostId:E,hostname:H,assignedClientId:X,profiles:a.profiles,activeProfileId:a.activeProfileId,activeProfile:mn,isController:v==="controller",sharedWindowCount:T,terminalResetVersion:P,rttMs:de,statusPayload:ve,agentStatus:fe,lastPairedAt:Ge,settings:a,hostPalette:G,terminalDimensions:F,toasts:q,adapter:Cl,language:a.language,t:Je,setLanguage:yt,connect:Tl,disconnect:fl,switchProfile:ei,addProfileAndConnect:Tt,renameProfile:An,removeProfile:el,claimControl:tl,releaseControl:En,sendKey:Kn,observeKeyInput:Rn,modifierLatch:qi,toggleModifierLatch:ja,consumeModifierLatch:Zl,sendBinary:hl,sendResize:Nl,updateSettings:Ut,addToast:bt,removeToast:zt,warnViewerMode:Vt,subscribeToOutput:$n,getPendingOutputChunkCount:kt,sendPasteFile:Ql,subscribeToPasteFileReady:Gn,uploadProgress:$t,uploadImage:Qt,resetUploadProgress:Dt},children:r})};function St(){const r=x.useContext($p);if(!r)throw new Error("useTerminal must be used within a TerminalProvider");return r}function Fr(r){var a,i;return r?{blocked:((a=r.counts)==null?void 0:a.blocked)??0,done:((i=r.counts)==null?void 0:i.done)??0}:null}function Bv(r){return r?r.blocked>0?"blocked":r.done>0?"done":null:null}function Hv(r){if(!r)return"";const a=[];return r.blocked>0&&a.push(`${r.blocked}⚠`),r.done>0&&a.push(`${r.done}✓`),a.length>0?`(${a.join(" ")})`:""}function Yv(r,a){if(!r||!a)return null;const i=new Map(r.agents.map(p=>[p.paneId,p.status]));let o=null;for(const p of a.agents)if(!(p.status!=="blocked"&&p.status!=="done")&&i.get(p.paneId)!==p.status){if(p.status==="blocked")return"blocked";o="done"}const d=Fr(r),f=Fr(a);return f.blocked>d.blocked?"blocked":(!o&&f.done>d.done&&(o="done"),o)}const Kv={blocked:"%23f9e2af",done:"%23a6e3a1"};function Gv(r){return`<circle cx='19' cy='5' r='4.5' fill='${Kv[r]}' stroke='%2311111b' stroke-width='1.5'/>`}function qv(r,a){return!a||!r.includes("</svg>")?r:r.replace("</svg>",`${Gv(a)}</svg>`)}function $m(r,a=document){const i=a.querySelector('link[rel~="icon"]');if(!i)return;i.dataset.baseHref===void 0&&(i.dataset.baseHref=i.getAttribute("href")??"");const o=qv(i.dataset.baseHref,r);i.getAttribute("href")!==o&&i.setAttribute("href",o)}let ul=null;function Vv(){if(typeof window>"u")return null;const r=window;return r.AudioContext??r.webkitAudioContext??null}function eg(){const r=Vv();if(r)try{ul=ul??new r,ul.state==="suspended"&&ul.resume()}catch{ul=null}}function Fv(r=window){const a=()=>{eg(),i()},i=()=>{r.removeEventListener("pointerdown",a),r.removeEventListener("keydown",a)};return r.addEventListener("pointerdown",a),r.addEventListener("keydown",a),i}const Xv={blocked:[880,660],done:[660,880]};function tg(r){if(!(!ul||ul.state!=="running"))try{const a=ul.currentTime;Xv[r].forEach((i,o)=>{const d=ul.createOscillator(),f=ul.createGain(),p=a+o*.11;d.type="sine",d.frequency.value=i,f.gain.setValueAtTime(1e-4,p),f.gain.exponentialRampToValueAtTime(.06,p+.01),f.gain.exponentialRampToValueAtTime(1e-4,p+.09),d.connect(f),f.connect(ul.destination),d.start(p),d.stop(p+.1)})}catch{}}const Iv=15e3,Zv={blocked:[70,50,70],done:[40]};function Qv(){const{agentStatus:r,settings:a,t:i}=St(),o=x.useRef(a);o.current=a;const d=x.useRef(i);d.current=i;const f=x.useRef(null),p=x.useRef(Number.NEGATIVE_INFINITY);x.useEffect(()=>{$m(a.agentAlertBadge?Bv(Fr(r)):null)},[r,a.agentAlertBadge]),x.useEffect(()=>()=>$m(null),[]),x.useEffect(()=>{if(!(!a.agentAlertSound||typeof window>"u"))return Fv(window)},[a.agentAlertSound]),x.useEffect(()=>{const m=f.current;f.current=r;const b=Yv(m,r);if(!b)return;const v=Date.now();if(v-p.current<Iv)return;p.current=v;const y=o.current,S=typeof document<"u"&&document.visibilityState==="hidden",A=S||typeof document<"u"&&!document.hasFocus();if(y.agentAlertVibrate&&!S&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(Zv[b])}catch{}if(y.agentAlertSound&&A&&tg(b),y.agentAlertNotify&&S&&typeof window<"u"&&window.isSecureContext&&"Notification"in window&&Notification.permission==="granted"){const E=Fr(r),R=b==="blocked"?d.current("agents.notifyBlocked",{count:E.blocked}):d.current("agents.notifyDone",{count:E.done});try{new Notification("Herdr Remote",{body:R,tag:"herdr-agents"})}catch{}}},[r])}function ng(r){var a,i,o="";if(typeof r=="string"||typeof r=="number")o+=r;else if(typeof r=="object")if(Array.isArray(r)){var d=r.length;for(a=0;a<d;a++)r[a]&&(i=ng(r[a]))&&(o&&(o+=" "),o+=i)}else for(i in r)r[i]&&(o&&(o+=" "),o+=i);return o}function Jv(){for(var r,a,i=0,o="",d=arguments.length;i<d;i++)(r=arguments[i])&&(a=ng(r))&&(o&&(o+=" "),o+=a);return o}const Wv=(r,a)=>{const i=new Array(r.length+a.length);for(let o=0;o<r.length;o++)i[o]=r[o];for(let o=0;o<a.length;o++)i[r.length+o]=a[o];return i},Pv=(r,a)=>({classGroupId:r,validator:a}),lg=(r=new Map,a=null,i)=>({nextPart:r,validators:a,classGroupId:i}),yo="-",ep=[],$v="arbitrary..",ex=r=>{const a=nx(r),{conflictingClassGroups:i,conflictingClassGroupModifiers:o}=r;return{getClassGroupId:p=>{if(p.startsWith("[")&&p.endsWith("]"))return tx(p);const m=p.split(yo),b=m[0]===""&&m.length>1?1:0;return ag(m,b,a)},getConflictingClassGroupIds:(p,m)=>{if(m){const b=o[p],v=i[p];return b?v?Wv(v,b):b:v||ep}return i[p]||ep}}},ag=(r,a,i)=>{if(r.length-a===0)return i.classGroupId;const d=r[a],f=i.nextPart.get(d);if(f){const v=ag(r,a+1,f);if(v)return v}const p=i.validators;if(p===null)return;const m=a===0?r.join(yo):r.slice(a).join(yo),b=p.length;for(let v=0;v<b;v++){const y=p[v];if(y.validator(m))return y.classGroupId}},tx=r=>r.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const a=r.slice(1,-1),i=a.indexOf(":"),o=a.slice(0,i);return o?$v+o:void 0})(),nx=r=>{const{theme:a,classGroups:i}=r;return lx(i,a)},lx=(r,a)=>{const i=lg();for(const o in r){const d=r[o];$u(d,i,o,a)}return i},$u=(r,a,i,o)=>{const d=r.length;for(let f=0;f<d;f++){const p=r[f];ax(p,a,i,o)}},ax=(r,a,i,o)=>{if(typeof r=="string"){ix(r,a,i);return}if(typeof r=="function"){rx(r,a,i,o);return}sx(r,a,i,o)},ix=(r,a,i)=>{const o=r===""?a:ig(a,r);o.classGroupId=i},rx=(r,a,i,o)=>{if(ox(r)){$u(r(o),a,i,o);return}a.validators===null&&(a.validators=[]),a.validators.push(Pv(i,r))},sx=(r,a,i,o)=>{const d=Object.entries(r),f=d.length;for(let p=0;p<f;p++){const[m,b]=d[p];$u(b,ig(a,m),i,o)}},ig=(r,a)=>{let i=r;const o=a.split(yo),d=o.length;for(let f=0;f<d;f++){const p=o[f];let m=i.nextPart.get(p);m||(m=lg(),i.nextPart.set(p,m)),i=m}return i},ox=r=>"isThemeGetter"in r&&r.isThemeGetter===!0,cx=r=>{if(r<1)return{get:()=>{},set:()=>{}};let a=0,i=Object.create(null),o=Object.create(null);const d=(f,p)=>{i[f]=p,a++,a>r&&(a=0,o=i,i=Object.create(null))};return{get(f){let p=i[f];if(p!==void 0)return p;if((p=o[f])!==void 0)return d(f,p),p},set(f,p){f in i?i[f]=p:d(f,p)}}},qu="!",tp=":",ux=[],np=(r,a,i,o,d)=>({modifiers:r,hasImportantModifier:a,baseClassName:i,maybePostfixModifierPosition:o,isExternal:d}),dx=r=>{const{prefix:a,experimentalParseClassName:i}=r;let o=d=>{const f=[];let p=0,m=0,b=0,v;const y=d.length;for(let H=0;H<y;H++){const z=d[H];if(p===0&&m===0){if(z===tp){f.push(d.slice(b,H)),b=H+1;continue}if(z==="/"){v=H;continue}}z==="["?p++:z==="]"?p--:z==="("?m++:z===")"&&m--}const S=f.length===0?d:d.slice(b);let A=S,E=!1;S.endsWith(qu)?(A=S.slice(0,-1),E=!0):S.startsWith(qu)&&(A=S.slice(1),E=!0);const R=v&&v>b?v-b:void 0;return np(f,E,A,R)};if(a){const d=a+tp,f=o;o=p=>p.startsWith(d)?f(p.slice(d.length)):np(ux,!1,p,void 0,!0)}if(i){const d=o;o=f=>i({className:f,parseClassName:d})}return o},fx=r=>{const a=new Map;return r.orderSensitiveModifiers.forEach((i,o)=>{a.set(i,1e6+o)}),i=>{const o=[];let d=[];for(let f=0;f<i.length;f++){const p=i[f],m=p[0]==="[",b=a.has(p);m||b?(d.length>0&&(d.sort(),o.push(...d),d=[]),o.push(p)):d.push(p)}return d.length>0&&(d.sort(),o.push(...d)),o}},hx=r=>({cache:cx(r.cacheSize),parseClassName:dx(r),sortModifiers:fx(r),postfixLookupClassGroupIds:mx(r),...ex(r)}),mx=r=>{const a=Object.create(null),i=r.postfixLookupClassGroups;if(i)for(let o=0;o<i.length;o++)a[i[o]]=!0;return a},px=/\s+/,gx=(r,a)=>{const{parseClassName:i,getClassGroupId:o,getConflictingClassGroupIds:d,sortModifiers:f,postfixLookupClassGroupIds:p}=a,m=[],b=r.trim().split(px);let v="";for(let y=b.length-1;y>=0;y-=1){const S=b[y],{isExternal:A,modifiers:E,hasImportantModifier:R,baseClassName:H,maybePostfixModifierPosition:z}=i(S);if(A){v=S+(v.length>0?" "+v:v);continue}let G=!!z,Q;if(G){const T=H.substring(0,z);Q=o(T);const _=Q&&p[Q]?o(H):void 0;_&&_!==Q&&(Q=_,G=!1)}else Q=o(H);if(!Q){if(!G){v=S+(v.length>0?" "+v:v);continue}if(Q=o(H),!Q){v=S+(v.length>0?" "+v:v);continue}G=!1}const X=E.length===0?"":E.length===1?E[0]:f(E).join(":"),re=R?X+qu:X,de=re+Q;if(m.indexOf(de)>-1)continue;m.push(de);const ee=d(Q,G);for(let T=0;T<ee.length;++T){const _=ee[T];m.push(re+_)}v=S+(v.length>0?" "+v:v)}return v},bx=(...r)=>{let a=0,i,o,d="";for(;a<r.length;)(i=r[a++])&&(o=rg(i))&&(d&&(d+=" "),d+=o);return d},rg=r=>{if(typeof r=="string")return r;let a,i="";for(let o=0;o<r.length;o++)r[o]&&(a=rg(r[o]))&&(i&&(i+=" "),i+=a);return i},yx=(r,...a)=>{let i,o,d,f;const p=b=>{const v=a.reduce((y,S)=>S(y),r());return i=hx(v),o=i.cache.get,d=i.cache.set,f=m,m(b)},m=b=>{const v=o(b);if(v)return v;const y=gx(b,i);return d(b,y),y};return f=p,(...b)=>f(bx(...b))},vx=[],It=r=>{const a=i=>i[r]||vx;return a.isThemeGetter=!0,a},sg=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,og=/^\((?:(\w[\w-]*):)?(.+)\)$/i,xx=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Sx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wx=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Cx=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Tx=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Nx=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Aa=r=>xx.test(r),Be=r=>!!r&&!Number.isNaN(Number(r)),Sl=r=>!!r&&Number.isInteger(Number(r)),Eu=r=>r.endsWith("%")&&Be(r.slice(0,-1)),Fl=r=>Sx.test(r),cg=()=>!0,Ax=r=>wx.test(r)&&!Cx.test(r),ed=()=>!1,Ex=r=>Tx.test(r),Rx=r=>Nx.test(r),jx=r=>!oe(r)&&!ce(r),kx=r=>r.startsWith("@container")&&(r[10]==="/"&&r[11]!==void 0||r[11]==="s"&&r[16]!==void 0&&r.startsWith("-size/",10)||r[11]==="n"&&r[18]!==void 0&&r.startsWith("-normal/",10)),Mx=r=>Ra(r,fg,ed),oe=r=>sg.test(r),Za=r=>Ra(r,hg,Ax),lp=r=>Ra(r,Hx,Be),_x=r=>Ra(r,pg,cg),zx=r=>Ra(r,mg,ed),ap=r=>Ra(r,ug,ed),Dx=r=>Ra(r,dg,Rx),io=r=>Ra(r,gg,Ex),ce=r=>og.test(r),zr=r=>$a(r,hg),Lx=r=>$a(r,mg),ip=r=>$a(r,ug),Ox=r=>$a(r,fg),Ux=r=>$a(r,dg),ro=r=>$a(r,gg,!0),Bx=r=>$a(r,pg,!0),Ra=(r,a,i)=>{const o=sg.exec(r);return o?o[1]?a(o[1]):i(o[2]):!1},$a=(r,a,i=!1)=>{const o=og.exec(r);return o?o[1]?a(o[1]):i:!1},ug=r=>r==="position"||r==="percentage",dg=r=>r==="image"||r==="url",fg=r=>r==="length"||r==="size"||r==="bg-size",hg=r=>r==="length",Hx=r=>r==="number",mg=r=>r==="family-name",pg=r=>r==="number"||r==="weight",gg=r=>r==="shadow",Yx=()=>{const r=It("color"),a=It("font"),i=It("text"),o=It("font-weight"),d=It("tracking"),f=It("leading"),p=It("breakpoint"),m=It("container"),b=It("spacing"),v=It("radius"),y=It("shadow"),S=It("inset-shadow"),A=It("text-shadow"),E=It("drop-shadow"),R=It("blur"),H=It("perspective"),z=It("aspect"),G=It("ease"),Q=It("animate"),X=()=>["auto","avoid","all","avoid-page","page","left","right","column"],re=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],de=()=>[...re(),ce,oe],ee=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],_=()=>[ce,oe,b],P=()=>[Aa,"full","auto",..._()],le=()=>[Sl,"none","subgrid",ce,oe],ve=()=>["auto",{span:["full",Sl,ce,oe]},Sl,ce,oe],Se=()=>[Sl,"auto",ce,oe],fe=()=>["auto","min","max","fr",ce,oe],Re=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Ge=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",..._()],F=()=>[Aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],J=()=>[Aa,"screen","full","dvw","lvw","svw","min","max","fit",..._()],q=()=>[Aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",..._()],V=()=>[r,ce,oe],je=()=>[...re(),ip,ap,{position:[ce,oe]}],pe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ke=()=>["auto","cover","contain",Ox,Mx,{size:[ce,oe]}],Ye=()=>[Eu,zr,Za],Ke=()=>["","none","full",v,ce,oe],Qe=()=>["",Be,zr,Za],$t=()=>["solid","dashed","dotted","double"],tt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],we=()=>[Be,Eu,ip,ap],hn=()=>["","none",R,ce,oe],qe=()=>["none",Be,ce,oe],Je=()=>["none",Be,ce,oe],We=()=>[Be,ce,oe],wt=()=>[Aa,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Fl],breakpoint:[Fl],color:[cg],container:[Fl],"drop-shadow":[Fl],ease:["in","out","in-out"],font:[jx],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Fl],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Fl],shadow:[Fl],spacing:["px",Be],text:[Fl],"text-shadow":[Fl],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Aa,oe,ce,z]}],container:["container"],"container-type":[{"@container":["","normal","size",ce,oe]}],"container-named":[kx],columns:[{columns:[Be,oe,ce,m]}],"break-after":[{"break-after":X()}],"break-before":[{"break-before":X()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:de()}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Sl,"auto",ce,oe]}],basis:[{basis:[Aa,"full","auto",m,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Be,Aa,"auto","initial","none",oe]}],grow:[{grow:["",Be,ce,oe]}],shrink:[{shrink:["",Be,ce,oe]}],order:[{order:[Sl,"first","last","none",ce,oe]}],"grid-cols":[{"grid-cols":le()}],"col-start-end":[{col:ve()}],"col-start":[{"col-start":Se()}],"col-end":[{"col-end":Se()}],"grid-rows":[{"grid-rows":le()}],"row-start-end":[{row:ve()}],"row-start":[{"row-start":Se()}],"row-end":[{"row-end":Se()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":fe()}],"auto-rows":[{"auto-rows":fe()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...Re(),"normal"]}],"justify-items":[{"justify-items":[...Ge(),"normal"]}],"justify-self":[{"justify-self":["auto",...Ge()]}],"align-content":[{content:["normal",...Re()]}],"align-items":[{items:[...Ge(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Ge(),{baseline:["","last"]}]}],"place-content":[{"place-content":Re()}],"place-items":[{"place-items":[...Ge(),"baseline"]}],"place-self":[{"place-self":["auto",...Ge()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pbs:[{pbs:_()}],pbe:[{pbe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...q()]}],"min-block-size":[{"min-block":["auto",...q()]}],"max-block-size":[{"max-block":["none",...q()]}],w:[{w:[m,"screen",...F()]}],"min-w":[{"min-w":[m,"screen","none",...F()]}],"max-w":[{"max-w":[m,"screen","none","prose",{screen:[p]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",i,zr,Za]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,Bx,_x]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Eu,oe]}],"font-family":[{font:[Lx,zx,a]}],"font-features":[{"font-features":[oe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,ce,oe]}],"line-clamp":[{"line-clamp":[Be,"none",ce,lp]}],leading:[{leading:[f,..._()]}],"list-image":[{"list-image":["none",ce,oe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ce,oe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$t(),"wavy"]}],"text-decoration-thickness":[{decoration:[Be,"from-font","auto",ce,Za]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Be,"auto",ce,oe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"tab-size":[{tab:[Sl,ce,oe]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ce,oe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ce,oe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:je()}],"bg-repeat":[{bg:pe()}],"bg-size":[{bg:ke()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Sl,ce,oe],radial:["",ce,oe],conic:[Sl,ce,oe]},Ux,Dx]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:Ye()}],"gradient-via-pos":[{via:Ye()}],"gradient-to-pos":[{to:Ye()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:Ke()}],"rounded-s":[{"rounded-s":Ke()}],"rounded-e":[{"rounded-e":Ke()}],"rounded-t":[{"rounded-t":Ke()}],"rounded-r":[{"rounded-r":Ke()}],"rounded-b":[{"rounded-b":Ke()}],"rounded-l":[{"rounded-l":Ke()}],"rounded-ss":[{"rounded-ss":Ke()}],"rounded-se":[{"rounded-se":Ke()}],"rounded-ee":[{"rounded-ee":Ke()}],"rounded-es":[{"rounded-es":Ke()}],"rounded-tl":[{"rounded-tl":Ke()}],"rounded-tr":[{"rounded-tr":Ke()}],"rounded-br":[{"rounded-br":Ke()}],"rounded-bl":[{"rounded-bl":Ke()}],"border-w":[{border:Qe()}],"border-w-x":[{"border-x":Qe()}],"border-w-y":[{"border-y":Qe()}],"border-w-s":[{"border-s":Qe()}],"border-w-e":[{"border-e":Qe()}],"border-w-bs":[{"border-bs":Qe()}],"border-w-be":[{"border-be":Qe()}],"border-w-t":[{"border-t":Qe()}],"border-w-r":[{"border-r":Qe()}],"border-w-b":[{"border-b":Qe()}],"border-w-l":[{"border-l":Qe()}],"divide-x":[{"divide-x":Qe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Qe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...$t(),"hidden","none"]}],"divide-style":[{divide:[...$t(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...$t(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Be,ce,oe]}],"outline-w":[{outline:["",Be,zr,Za]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",y,ro,io]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",S,ro,io]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:Qe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Be,Za]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":Qe()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",A,ro,io]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Be,ce,oe]}],"mix-blend":[{"mix-blend":[...tt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":tt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Be]}],"mask-image-linear-from-pos":[{"mask-linear-from":we()}],"mask-image-linear-to-pos":[{"mask-linear-to":we()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":we()}],"mask-image-t-to-pos":[{"mask-t-to":we()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":we()}],"mask-image-r-to-pos":[{"mask-r-to":we()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":we()}],"mask-image-b-to-pos":[{"mask-b-to":we()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":we()}],"mask-image-l-to-pos":[{"mask-l-to":we()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":we()}],"mask-image-x-to-pos":[{"mask-x-to":we()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":we()}],"mask-image-y-to-pos":[{"mask-y-to":we()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[ce,oe]}],"mask-image-radial-from-pos":[{"mask-radial-from":we()}],"mask-image-radial-to-pos":[{"mask-radial-to":we()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":re()}],"mask-image-conic-pos":[{"mask-conic":[Be]}],"mask-image-conic-from-pos":[{"mask-conic-from":we()}],"mask-image-conic-to-pos":[{"mask-conic-to":we()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:je()}],"mask-repeat":[{mask:pe()}],"mask-size":[{mask:ke()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ce,oe]}],filter:[{filter:["","none",ce,oe]}],blur:[{blur:hn()}],brightness:[{brightness:[Be,ce,oe]}],contrast:[{contrast:[Be,ce,oe]}],"drop-shadow":[{"drop-shadow":["","none",E,ro,io]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Be,ce,oe]}],"hue-rotate":[{"hue-rotate":[Be,ce,oe]}],invert:[{invert:["",Be,ce,oe]}],saturate:[{saturate:[Be,ce,oe]}],sepia:[{sepia:["",Be,ce,oe]}],"backdrop-filter":[{"backdrop-filter":["","none",ce,oe]}],"backdrop-blur":[{"backdrop-blur":hn()}],"backdrop-brightness":[{"backdrop-brightness":[Be,ce,oe]}],"backdrop-contrast":[{"backdrop-contrast":[Be,ce,oe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Be,ce,oe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Be,ce,oe]}],"backdrop-invert":[{"backdrop-invert":["",Be,ce,oe]}],"backdrop-opacity":[{"backdrop-opacity":[Be,ce,oe]}],"backdrop-saturate":[{"backdrop-saturate":[Be,ce,oe]}],"backdrop-sepia":[{"backdrop-sepia":["",Be,ce,oe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ce,oe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Be,"initial",ce,oe]}],ease:[{ease:["linear","initial",G,ce,oe]}],delay:[{delay:[Be,ce,oe]}],animate:[{animate:["none",Q,ce,oe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[H,ce,oe]}],"perspective-origin":[{"perspective-origin":de()}],rotate:[{rotate:qe()}],"rotate-x":[{"rotate-x":qe()}],"rotate-y":[{"rotate-y":qe()}],"rotate-z":[{"rotate-z":qe()}],scale:[{scale:Je()}],"scale-x":[{"scale-x":Je()}],"scale-y":[{"scale-y":Je()}],"scale-z":[{"scale-z":Je()}],"scale-3d":["scale-3d"],skew:[{skew:We()}],"skew-x":[{"skew-x":We()}],"skew-y":[{"skew-y":We()}],transform:[{transform:[ce,oe,"","none","gpu","cpu"]}],"transform-origin":[{origin:de()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:wt()}],"translate-x":[{"translate-x":wt()}],"translate-y":[{"translate-y":wt()}],"translate-z":[{"translate-z":wt()}],"translate-none":["translate-none"],zoom:[{zoom:[Sl,ce,oe]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ce,oe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mbs":[{"scroll-mbs":_()}],"scroll-mbe":[{"scroll-mbe":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pbs":[{"scroll-pbs":_()}],"scroll-pbe":[{"scroll-pbe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ce,oe]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Be,zr,Za,lp]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Kx=yx(Yx);function $(...r){return Kx(Jv(r))}var Gx=zp();const He={cursor:"▸",on:"●",off:"○",dot:"·",check:"✓",cross:"✗",warn:"!",arrowRight:"→",arrowLeft:"←",chevronDown:"▾",chevronRight:"▸",ellipsis:"…",meterFull:"█",meterEmpty:"░",tabDivider:"│"},Wn={ok:{text:"text-tui-ok",edgeL:"border-l-tui-ok",edgeB:"border-b-tui-ok"},warn:{text:"text-tui-warn",edgeL:"border-l-tui-warn",edgeB:"border-b-tui-warn"},bad:{text:"text-tui-bad",edgeL:"border-l-tui-bad",edgeB:"border-b-tui-bad"},idle:{text:"text-tui-faint",edgeL:"border-l-tui-border",edgeB:"border-b-tui-border"},accent:{text:"text-tui-accent",edgeL:"border-l-tui-accent",edgeB:"border-b-tui-accent"},alt:{text:"text-tui-alt",edgeL:"border-l-tui-alt",edgeB:"border-b-tui-alt"},info:{text:"text-tui-info",edgeL:"border-l-tui-info",edgeB:"border-b-tui-info"}},Xr={ok:Wn.ok.text,warn:Wn.warn.text,bad:Wn.bad.text,idle:Wn.idle.text,accent:Wn.accent.text,alt:Wn.alt.text,info:Wn.info.text},Cn=({level:r,className:a})=>u.jsx("span",{"aria-hidden":"true",className:$("select-none leading-none",Xr[r],a),children:r==="idle"?He.off:He.on}),bg=({className:r})=>u.jsx("span",{"aria-hidden":"true",className:$("select-none text-tui-faint",r),children:He.dot}),rn=({title:r,aside:a,tone:i="accent",className:o,bodyClassName:d,children:f,...p})=>u.jsxs("fieldset",{className:$("tui-panel tui-block relative min-w-0 border border-tui-border bg-tui-base",r?"px-3 pb-3 pt-1":"p-3",o),...p,children:[r?u.jsx("legend",{className:$("flex items-center gap-2 text-tui font-bold",Xr[i]),children:u.jsx("span",{children:r})}):null,a?u.jsx("span",{className:"pointer-events-none absolute -top-[10px] right-2 max-w-[60%] truncate bg-tui-base px-1 text-tui-sm text-tui-faint",children:a}):null,u.jsx("div",{className:$("min-w-0",d),children:f})]}),cl=({label:r,labelWidth:a=16,className:i,children:o})=>u.jsxs("div",{className:$("flex items-baseline gap-2 text-tui",i),children:[u.jsx("span",{className:"shrink-0 truncate text-tui-muted",style:{width:`${a}ch`},title:typeof r=="string"?r:void 0,children:r}),u.jsx("span",{className:"min-w-0 flex-1 text-tui-text",children:o})]}),Ea=({className:r,label:a})=>a?u.jsxs("div",{className:$("flex items-center gap-2",r),children:[u.jsx("span",{className:"h-px w-3 bg-tui-border-dim","aria-hidden":"true"}),u.jsx("span",{className:"text-tui-sm text-tui-faint",children:a}),u.jsx("span",{className:"h-px flex-1 bg-tui-border-dim","aria-hidden":"true"})]}):u.jsx("div",{className:$("h-px w-full bg-tui-border-dim",r),"aria-hidden":"true"}),qx={default:"border-tui-border text-tui-text hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",primary:"border-tui-accent text-tui-accent hover:bg-tui-accent hover:text-tui-crust active:bg-tui-accent-dim",danger:"border-tui-bad text-tui-bad hover:bg-tui-bad hover:text-tui-crust active:bg-tui-bad",warn:"border-tui-warn text-tui-warn hover:bg-tui-warn hover:text-tui-crust active:bg-tui-warn",ghost:"border-transparent text-tui-muted hover:text-tui-accent hover:border-tui-border active:bg-tui-selection"},Ue=({variant:r="default",brackets:a=!0,glyph:i,block:o=!1,className:d,children:f,type:p="button",...m})=>u.jsxs("button",{type:p,className:$("tui-focusable inline-flex select-none items-center justify-center gap-1.5 border bg-transparent px-2 py-0.5 text-tui font-medium transition-colors","disabled:cursor-not-allowed disabled:border-tui-border-dim disabled:text-tui-faint disabled:hover:bg-transparent",qx[r],o&&"w-full",d),...m,children:[a?u.jsx("span",{"aria-hidden":"true",className:"opacity-60",children:"["}):null,i?u.jsx("span",{"aria-hidden":"true",className:"leading-none",children:i}):null,u.jsx("span",{className:"truncate",children:f}),a?u.jsx("span",{"aria-hidden":"true",className:"opacity-60",children:"]"}):null]}),So=({tone:r="accent",dot:a=!1,className:i,children:o})=>u.jsxs("span",{className:$("inline-flex select-none items-center gap-1 whitespace-nowrap text-tui font-bold uppercase",Xr[r],i),children:[a?u.jsx(Cn,{level:r}):null,o]}),td=({tabs:r,activeId:a,onSelect:i,ariaLabel:o,className:d,labelClassName:f})=>u.jsx("nav",{className:$("flex items-center gap-2",d),"aria-label":o,children:r.map((p,m)=>{const b=p.id===a;return u.jsxs(dl.Fragment,{children:[m>0?u.jsx("span",{"aria-hidden":"true",className:"select-none text-tui-border",children:He.tabDivider}):null,u.jsxs("button",{type:"button",onClick:()=>i(p.id),"aria-current":b?"page":void 0,"aria-label":p.ariaLabel??p.label,title:p.title,className:$("tui-focusable select-none whitespace-nowrap border-b px-0.5 pb-0.5 text-tui transition-colors",b?"border-tui-accent font-bold text-tui-accent":"border-transparent text-tui-muted hover:border-tui-border-bright hover:text-tui-text"),children:[p.index!==void 0?u.jsx("span",{"aria-hidden":"true",className:$("text-tui-faint",b&&"text-tui-accent"),children:p.index}):null,u.jsx("span",{"aria-hidden":"true",className:$("ml-1",f),children:p.label})]})]},p.id)})}),yg=({hints:r,className:a})=>u.jsx("div",{className:$("flex flex-wrap items-center gap-x-3 gap-y-0.5 text-tui-sm text-tui-faint",a),children:r.map((i,o)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("kbd",{className:"border border-tui-border-dim px-1 not-italic text-tui-muted",children:i.keys}),u.jsx("span",{children:i.action})]},`${i.keys}-${o}`))}),wn=({htmlFor:r,hint:a,className:i,children:o})=>u.jsxs("label",{htmlFor:r,className:$("block text-tui-sm font-bold text-tui-muted",i),children:[o,a?u.jsx("span",{className:"ml-2 font-normal text-tui-faint",children:a}):null]}),Pn=dl.forwardRef(({className:r,...a},i)=>u.jsx("input",{ref:i,className:$("tui-input w-full px-2 py-1 text-tui",r),...a}));Pn.displayName="Input";const nd=dl.forwardRef(({className:r,children:a,...i},o)=>u.jsx("select",{ref:o,className:$("tui-input w-full px-2 py-1 text-tui",r),...i,children:a}));nd.displayName="Select";const Qa=({checked:r,onChange:a,disabled:i=!1,label:o,description:d,className:f,id:p})=>u.jsxs("label",{className:$("group flex cursor-pointer select-none items-start gap-2 py-0.5 text-tui",i&&"cursor-not-allowed opacity-60",f),children:[u.jsx("input",{id:p,type:"checkbox",className:"sr-only",checked:r,disabled:i,onChange:m=>a(m.target.checked)}),u.jsx("span",{"aria-hidden":"true",className:$("mt-px shrink-0 font-bold leading-tight",r?"text-tui-ok":"text-tui-faint",!i&&"group-hover:text-tui-accent"),children:r?"[x]":"[ ]"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:$("block",r?"text-tui-text":"text-tui-muted"),children:o}),d?u.jsx("span",{className:"mt-0.5 block text-tui-sm leading-snug text-tui-faint",children:d}):null]})]}),Dr=({checked:r,onChange:a,name:i,disabled:o=!1,label:d,description:f,className:p})=>u.jsxs("label",{className:$("group flex cursor-pointer select-none items-start gap-2 py-0.5 text-tui",o&&"cursor-not-allowed opacity-60",p),children:[u.jsx("input",{type:"radio",name:i,className:"sr-only",checked:r,disabled:o,onChange:a}),u.jsx("span",{"aria-hidden":"true",className:$("mt-px shrink-0 font-bold leading-tight",r?"text-tui-accent":"text-tui-faint",!o&&"group-hover:text-tui-accent"),children:r?"(•)":"( )"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:$("block",r?"text-tui-text":"text-tui-muted"),children:d}),f?u.jsx("span",{className:"mt-0.5 block text-tui-sm leading-snug text-tui-faint",children:f}):null]})]}),Vx=({value:r,width:a=20,tone:i="accent",className:o})=>{const d=Number.isFinite(r)?Math.min(1,Math.max(0,r)):0,f=Math.round(d*a);return u.jsxs("span",{className:$("inline-flex select-none whitespace-pre font-mono leading-none",o),role:"presentation",children:[u.jsx("span",{className:Xr[i],children:He.meterFull.repeat(f)}),u.jsx("span",{className:"text-tui-border",children:He.meterEmpty.repeat(Math.max(0,a-f))})]})},Fx={ok:"bg-tui-ok",warn:"bg-tui-warn",bad:"bg-tui-bad",idle:"bg-tui-border",accent:"bg-tui-accent",alt:"bg-tui-alt",info:"bg-tui-info"},Xx=({ratio:r,label:a,tone:i="accent",className:o,...d})=>{const f=Number.isFinite(r)?Math.min(1,Math.max(0,r)):0;return u.jsxs("div",{className:$("relative h-[var(--tui-row)] w-full overflow-hidden border border-tui-border bg-tui-mantle",o),role:"progressbar","aria-valuenow":Math.round(f*100),"aria-valuemin":0,"aria-valuemax":100,...d,children:[u.jsx("div",{className:$("absolute inset-y-0 left-0",Fx[i]),style:{width:`${f*100}%`},"aria-hidden":"true"}),a!==void 0?u.jsx("span",{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap px-1 text-tui font-bold text-tui-text mix-blend-difference",children:a}):null]})};function ld({columns:r,items:a,rowKey:i,empty:o,className:d}){return a.length===0?u.jsx("div",{className:$("px-1 py-4 text-center text-tui text-tui-faint",d),children:o}):u.jsx("div",{className:$("w-full overflow-x-auto",d),children:u.jsxs("table",{className:"w-full border-collapse text-tui",children:[u.jsx("thead",{children:u.jsx("tr",{className:"border-b border-tui-border",children:r.map(f=>u.jsx("th",{scope:"col",style:f.width?{width:`${f.width}ch`}:void 0,className:$("whitespace-nowrap px-2 py-1 text-tui-sm font-bold text-tui-muted",f.align==="right"?"text-right":"text-left",f.className),children:f.header},f.key))})}),u.jsx("tbody",{children:a.map((f,p)=>u.jsx("tr",{className:"border-b border-tui-border-dim last:border-b-0 hover:bg-tui-selection",children:r.map(m=>u.jsx("td",{className:$("px-2 py-1 align-top text-tui-text",m.align==="right"?"text-right":"text-left",m.className),children:m.render(f,p)},m.key))},i(f,p)))})]})})}const ad=({isOpen:r,onClose:a,title:i,subtitle:o,closeLabel:d,footer:f,hints:p,size:m="md",className:b,children:v})=>{if(!r)return null;const y=m==="sm"?"max-w-md":m==="lg"?"max-w-3xl":"max-w-xl",S=`tui-modal-${i.replace(/\s+/g,"-").toLowerCase()}`,A=u.jsx("div",{className:"fixed inset-0 inset-x-0 z-50 grid place-items-center overflow-y-auto bg-tui-crust/85 p-3 sm:p-6",style:{height:"var(--app-height, 100dvh)",width:"100vw"},role:"dialog","aria-modal":"true","aria-labelledby":S,onMouseDown:E=>{E.target===E.currentTarget&&a()},children:u.jsxs("div",{className:$("flex w-full flex-col border border-tui-border bg-tui-base",y,b),style:{maxHeight:"calc(var(--app-height, 100dvh) - 1.5rem)"},children:[u.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-tui-border bg-tui-mantle px-3 py-1.5",children:[u.jsx("h2",{id:S,className:"truncate text-tui font-bold text-tui-accent",children:i}),o?u.jsx("span",{className:"min-w-0 flex-1 truncate text-tui-sm text-tui-faint",children:o}):u.jsx("span",{className:"flex-1"}),u.jsx(Ue,{variant:"ghost",onClick:a,"aria-label":d,title:d,children:"esc"})]}),u.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:v}),f||p?u.jsxs("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-tui-border bg-tui-mantle px-3 py-1.5",children:[p?u.jsx(yg,{hints:p}):u.jsx("span",{}),f?u.jsx("div",{className:"flex items-center gap-2",children:f}):null]}):null]})});return typeof document>"u"?A:Gx.createPortal(A,document.body)},fo=({tone:r="accent",className:a,children:i,action:o})=>{const d=r==="ok"?He.check:r==="bad"?He.cross:r==="warn"?He.warn:"›",f=Wn[r].edgeL;return u.jsxs("div",{className:$("flex items-start gap-2 border border-tui-border-dim border-l-2 bg-tui-mantle px-2 py-1.5 text-tui",f,a),children:[u.jsx("span",{"aria-hidden":"true",className:$("shrink-0 font-bold",Xr[r]),children:d}),u.jsx("div",{className:"min-w-0 flex-1 leading-snug text-tui-text",children:i}),o?u.jsx("div",{className:"shrink-0",children:o}):null]})},Ix=({active:r=!1,className:a,children:i})=>u.jsx("span",{className:$("inline-flex min-w-[2ch] select-none items-center justify-center border px-1 text-tui",r?"border-tui-accent bg-tui-accent text-tui-crust":"border-tui-border bg-tui-surface text-tui-muted",a),children:i}),rp=({items:r,className:a})=>{const i=r.filter(Boolean);return u.jsx("span",{className:$("flex min-w-0 items-center gap-1.5",a),children:i.map((o,d)=>u.jsxs(dl.Fragment,{children:[d>0?u.jsx(bg,{className:"shrink-0"}):null,o]},d))})},vg=({left:r,right:a,className:i})=>u.jsxs("footer",{className:$("relative flex h-[var(--tui-row)] w-full shrink-0 items-center justify-between gap-3 overflow-visible border-t border-tui-border bg-tui-mantle px-2 text-tui-sm",i),children:[u.jsx("div",{className:"flex min-w-0 items-center gap-1.5 text-tui-muted",children:r}),u.jsx("div",{className:"flex shrink-0 items-center gap-3",children:a})]}),Zx=({name:r,tagline:a,aside:i,tabs:o,activeTabId:d,onSelectTab:f,tabsAriaLabel:p,hints:m,footerAside:b,bodyClassName:v,className:y,children:S})=>u.jsxs("div",{className:$("flex h-full min-h-0 w-full flex-col bg-tui-crust",y),children:[u.jsxs("div",{className:"flex h-[var(--tui-row)] shrink-0 items-center justify-between gap-3 overflow-hidden border-b border-tui-border bg-tui-mantle px-2 text-tui",children:[u.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("span",{className:"shrink-0 font-bold text-tui-accent",children:r}),a?u.jsx("span",{className:"hidden truncate text-tui-sm text-tui-faint sm:block",children:a}):null]}),i?u.jsx("span",{className:"flex shrink-0 items-center gap-2",children:i}):null]}),o&&o.length>0&&d!==void 0&&f?u.jsx("div",{className:"scrollbar-none shrink-0 overflow-x-auto border-b border-tui-border bg-tui-mantle px-2",children:u.jsx(td,{tabs:o,activeId:d,onSelect:f,ariaLabel:p,className:"gap-3"})}):null,u.jsx("div",{className:$("min-h-0 flex-1 overflow-y-auto p-2",v),children:S}),m||b?u.jsx(vg,{left:m?u.jsx(yg,{hints:m}):null,right:b}):null]}),sp=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Yi=({className:r,label:a})=>{const[i,o]=dl.useState(0);return dl.useEffect(()=>{const d=setInterval(()=>o(f=>(f+1)%sp.length),90);return()=>clearInterval(d)},[]),u.jsxs("span",{className:$("inline-flex items-center gap-1.5",r),role:"status",children:[u.jsx("span",{"aria-hidden":"true",className:"text-tui-accent",children:sp[i]}),a?u.jsx("span",{children:a}):null]})},so="tui-focusable select-none border border-transparent px-1.5 text-tui uppercase transition-colors",oo="text-tui-muted hover:border-tui-border hover:text-tui-accent",Qx="border-tui-accent bg-tui-accent text-tui-crust",Jx=({currentView:r,onNavigate:a,showAdminEntry:i=!0,onOpenPairing:o,onOpenSettings:d,onToggleVirtualKeyboard:f,isVirtualKeyboardOpen:p})=>{const{addToast:m,language:b,setLanguage:v,t:y}=St(),S=()=>{const E=b==="zh"?"en":"zh";v(E),m("info",Pu(E,"toasts.switchedLanguage",{lang:E==="zh"?"简体中文":"English"}))},A=[{id:"terminal",label:y("header.terminalTab"),index:1,ariaLabel:y("header.terminalTab")},...i||r==="admin"?[{id:"admin",label:y("header.adminTab"),index:2,ariaLabel:y("header.adminTab")}]:[]];return u.jsx("header",{role:"banner",className:"z-30 w-full shrink-0 select-none overflow-hidden border-b border-tui-border bg-tui-mantle px-2 pt-[max(env(safe-area-inset-top,0px),0.125rem)]",children:u.jsxs("div",{className:"scrollbar-none flex min-h-[var(--tui-row)] items-center gap-2 overflow-x-auto text-tui",children:[u.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[u.jsx("span",{className:"font-bold text-tui-accent",children:"herdr-remote"}),u.jsx("span",{className:"hidden text-tui-sm text-tui-faint sm:inline",children:y("header.tagline")})]}),u.jsx("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-tui-border"}),u.jsx(td,{tabs:A,activeId:r,onSelect:E=>a(E),ariaLabel:y("header.mainNavigationAria"),className:"shrink-0 gap-3"}),u.jsx("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-tui-border"}),u.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[u.jsx("button",{type:"button",onClick:S,className:$(so,oo),title:y("header.languageToggleTitle"),"aria-label":y("header.languageToggleTitle"),children:y("header.languageShort")}),r==="terminal"&&u.jsx("button",{type:"button",onClick:f,className:$(so,p?Qx:oo),title:y("header.virtualKeyboardTitle"),"aria-label":y("header.virtualKeyboardTitle"),children:y("header.actionKeyboard")}),u.jsx("button",{type:"button",onClick:o,className:$(so,oo),title:y("header.pairingTitle"),"aria-label":y("header.pairingTitle"),children:y("header.actionPairing")}),u.jsx("button",{type:"button",onClick:d,className:$(so,oo),title:y("header.settingsTitle"),"aria-label":y("header.settingsTitle"),children:y("header.actionSettings")})]})]})})},co=({tone:r,glyph:a,message:i,assertive:o=!1,action:d})=>u.jsxs("aside",{className:$("flex w-full items-center justify-between gap-3 border-b bg-tui-mantle px-2 py-0.5 text-tui sm:px-3",Wn[r].edgeB),"aria-live":o?"assertive":"polite",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:$("shrink-0",Wn[r].text),children:a}),u.jsx("span",{className:"truncate text-tui-text",children:i})]}),d]}),Wx=()=>{const{connectionState:r,stateDetail:a,connect:i,settings:o,t:d}=St();return r==="connected"||!o.token&&!o.pairCode&&r==="disconnected"?null:r==="connecting"?u.jsx(co,{tone:"accent",glyph:u.jsx(Yi,{}),message:d("statusBanner.connecting")}):r==="reconnecting"?u.jsx(co,{tone:"warn",glyph:u.jsx(Yi,{}),assertive:!0,message:a||d("statusBanner.reconnectingDefault"),action:u.jsx(Ue,{variant:"warn",onClick:()=>i(),className:"shrink-0",children:d("statusBanner.reconnectNow")})}):r==="error"?u.jsx(co,{tone:"bad",glyph:He.cross,assertive:!0,message:a||d("statusBanner.errorDefault"),action:u.jsx(Ue,{variant:"danger",onClick:()=>i(),className:"shrink-0",children:d("common.retry")})}):r==="disconnected"?u.jsx(co,{tone:"idle",glyph:He.off,message:d("statusBanner.disconnected"),action:u.jsx(Ue,{variant:"primary",onClick:()=>i(),className:"shrink-0",children:d("common.connect")})}):null};var Px=By(),$x=Hy(),Ru={exports:{}},op;function e0(){return op||(op=1,(function(r,a){(function(i,o){r.exports=o()})(self,(()=>(()=>{var i={6:(p,m)=>{function b(y){try{const S=new URL(y),A=S.password&&S.username?`${S.protocol}//${S.username}:${S.password}@${S.host}`:S.username?`${S.protocol}//${S.username}@${S.host}`:`${S.protocol}//${S.host}`;return y.toLocaleLowerCase().startsWith(A.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(m,"__esModule",{value:!0}),m.LinkComputer=m.WebLinkProvider=void 0,m.WebLinkProvider=class{constructor(y,S,A,E={}){this._terminal=y,this._regex=S,this._handler=A,this._options=E}provideLinks(y,S){const A=v.computeLink(y,this._regex,this._terminal,this._handler);S(this._addCallbacks(A))}_addCallbacks(y){return y.map((S=>(S.leave=this._options.leave,S.hover=(A,E)=>{if(this._options.hover){const{range:R}=S;this._options.hover(A,E,R)}},S)))}};class v{static computeLink(S,A,E,R){const H=new RegExp(A.source,(A.flags||"")+"g"),[z,G]=v._getWindowedLineStrings(S-1,E),Q=z.join("");let X;const re=[];for(;X=H.exec(Q);){const de=X[0];if(!b(de))continue;const[ee,T]=v._mapStrIdx(E,G,0,X.index),[_,P]=v._mapStrIdx(E,ee,T,de.length);if(ee===-1||T===-1||_===-1||P===-1)continue;const le={start:{x:T+1,y:ee+1},end:{x:P,y:_+1}};re.push({range:le,text:de,activate:R})}return re}static _getWindowedLineStrings(S,A){let E,R=S,H=S,z=0,G="";const Q=[];if(E=A.buffer.active.getLine(S)){const X=E.translateToString(!0);if(E.isWrapped&&X[0]!==" "){for(z=0;(E=A.buffer.active.getLine(--R))&&z<2048&&(G=E.translateToString(!0),z+=G.length,Q.push(G),E.isWrapped&&G.indexOf(" ")===-1););Q.reverse()}for(Q.push(X),z=0;(E=A.buffer.active.getLine(++H))&&E.isWrapped&&z<2048&&(G=E.translateToString(!0),z+=G.length,Q.push(G),G.indexOf(" ")===-1););}return[Q,R]}static _mapStrIdx(S,A,E,R){const H=S.buffer.active,z=H.getNullCell();let G=E;for(;R;){const Q=H.getLine(A);if(!Q)return[-1,-1];for(let X=G;X<Q.length;++X){Q.getCell(X,z);const re=z.getChars();if(z.getWidth()&&(R-=re.length||1,X===Q.length-1&&re==="")){const de=H.getLine(A+1);de&&de.isWrapped&&(de.getCell(0,z),z.getWidth()===2&&(R+=1))}if(R<0)return[A,X]}A++,G=0}return[A,G]}}m.LinkComputer=v}},o={};function d(p){var m=o[p];if(m!==void 0)return m.exports;var b=o[p]={exports:{}};return i[p](b,b.exports,d),b.exports}var f={};return(()=>{var p=f;Object.defineProperty(p,"__esModule",{value:!0}),p.WebLinksAddon=void 0;const m=d(6),b=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function v(y,S){const A=window.open();if(A){try{A.opener=null}catch{}A.location.href=S}else console.warn("Opening link blocked as opener could not be cleared")}p.WebLinksAddon=class{constructor(y=v,S={}){this._handler=y,this._options=S}activate(y){this._terminal=y;const S=this._options,A=S.urlRegex||b;this._linkProvider=this._terminal.registerLinkProvider(new m.WebLinkProvider(this._terminal,A,this._handler,S))}dispose(){var y;(y=this._linkProvider)==null||y.dispose()}}})(),f})()))})(Ru)),Ru.exports}var t0=e0();const xg="\x1B",n0=/^\x1b\[[IO]/,Sg=/^\x1b\[<(\d+);\d+;\d+[Mm]/,l0=/^\x1b\[M[\s\S]{3}/,a0=[/^\x1b\[\?[\d;]*c/,/^\x1b\[>[\d;]*c/,/^\x1b\[\d+;\d+R/,/^\x1b\[\?\d+;\d+R/,/^\x1b\[\d+n/,/^\x1b\[\?[\d;]*\$y/,/^\x1b\[[\d;]*t/,/^\x1b\[\?\d+u/,/^\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/,/^\x1bP[\s\S]*?\x1b\\/],i0=/^\x1b\[1;[2-8]R/;function cp(r){if(i0.test(r))return 0;const a=n0.exec(r);if(a)return a[0].length;const i=Sg.exec(r);if(i){const o=Number(i[1]);return(o&32)!==0&&(o&3)===3&&(o&64)===0?i[0].length:0}for(const o of a0){const d=o.exec(r);if(d)return d[0].length}return 0}function wg(r){if(!r.startsWith(xg))return"keys";if(Sg.test(r)||l0.test(r)){let i=r;for(;i.length>0;){const o=cp(i);if(o===0)return"pointer";i=i.slice(o)}return"passive"}let a=r;for(;a.length>0;){const i=cp(a);if(i===0)return"keys";a=a.slice(i)}return"passive"}function r0(r){return r===xg}const s0=20,o0=6,c0=500,u0=300,Ki=13,Cg=.602,Tg=1.3;function Xl(r,a){return Number.isFinite(r)&&r>0?r:a}function up(r,a,i){return Math.min(i,Math.max(a,r))}function dp(r){const{width:a,height:i,cellWidth:o,cellHeight:d,minCols:f=s0,minRows:p=o0,maxCols:m=c0,maxRows:b=u0}=r,v=Xl(o,Ki*Cg),y=Xl(d,Ki*Tg);return{cols:up(Math.floor(Xl(a,0)/v),f,m),rows:up(Math.floor(Xl(i,0)/y),p,b)}}function Wa(r,a=Ki){var o,d,f;if(r)try{const p=r._core,m=(f=(d=(o=p==null?void 0:p._renderService)==null?void 0:o.dimensions)==null?void 0:d.css)==null?void 0:f.cell;if(m&&m.width&&m.width>0&&m.height&&m.height>0)return{cellWidth:m.width,cellHeight:m.height,measured:!0}}catch{}const i=Xl(a,Ki);return{cellWidth:Math.round(i*Cg*100)/100,cellHeight:Math.round(i*Tg*100)/100,measured:!1}}function d0(r){var o;const a=(o=r==null?void 0:r.querySelector)==null?void 0:o.call(r,".xterm-viewport");if(!a)return 0;const i=(a.offsetWidth||0)-(a.clientWidth||0);return Number.isFinite(i)&&i>0?i:0}function ju(r,a,i){if(!r)return{width:a,height:i};let o=0,d=0;if(typeof r.getBoundingClientRect=="function"){const f=r.getBoundingClientRect();o=(f==null?void 0:f.width)||0,d=(f==null?void 0:f.height)||0}return{width:Xl(o,Xl(r.clientWidth,a)),height:Xl(d,Xl(r.clientHeight,i))}}function Ng(r,a,i,o){const d=Number.isFinite(o)&&o>.01?o:1;return{clientX:i.left+(r-i.left)/d,clientY:i.top+(a-i.top)/d}}function Lr(r){var a,i;if(!r)return!1;try{const o=r.modes;if(o&&typeof o.mouseTrackingMode=="string"&&o.mouseTrackingMode!=="none")return!0;const d=r._core;if((a=d==null?void 0:d._coreMouseService)!=null&&a.areMouseEventsActive||(i=d==null?void 0:d.coreMouseService)!=null&&i.areMouseEventsActive||d!=null&&d.mouseMode&&d.mouseMode!=="none")return!0}catch{}return!1}function f0(r,a){const i=a.button??0,o=a.buttons??(r==="mouseup"?0:1);return new MouseEvent(r,{bubbles:!0,cancelable:!0,clientX:a.clientX,clientY:a.clientY,screenX:a.clientX,screenY:a.clientY,button:i,buttons:o})}function fp(r,a,i){const o=f0(a,i);return r.dispatchEvent(o)}class h0{constructor(a){se(this,"options");se(this,"state","idle");se(this,"startX",0);se(this,"startY",0);se(this,"lastX",0);se(this,"lastY",0);se(this,"activeTarget",null);se(this,"longPressTimer",null);se(this,"capturedPointerId",null);se(this,"captureElement",null);se(this,"scrollRemainderY",0);this.options={longPressDelayMs:500,dragThresholdPx:8,scrollLineHeightPx:18,...a}}getState(){return this.state}setGestureState(a){var i,o;this.state!==a&&(this.state=a,(o=(i=this.options).onGestureStateChange)==null||o.call(i,a))}getActiveBuffer(a){var i;try{return((i=a.buffer)==null?void 0:i.active)||null}catch{return null}}getViewportY(a){var o;const i=(o=this.getActiveBuffer(a))==null?void 0:o.viewportY;return typeof i=="number"&&Number.isFinite(i)?i:null}blurTerminal(a){var i;try{(i=a.blur)==null||i.call(a)}catch{}}getLogicalCoordinates(a,i){const o=this.options.getScale?this.options.getScale():1,d=this.options.getSurfaceElement?this.options.getSurfaceElement():null;if(o!==1&&d&&typeof d.getBoundingClientRect=="function"){const f=d.getBoundingClientRect();return Ng(a,i,f,o)}return{clientX:a,clientY:i}}getViewportElement(a){var d;const i=this.options.getSurfaceElement?this.options.getSurfaceElement():null;return(i==null?void 0:i.querySelector(".xterm-viewport"))||((d=a.element)==null?void 0:d.querySelector(".xterm-viewport"))||null}isInputLineHit(a,i){var Q;const o=(Q=i.buffer)==null?void 0:Q.active,d=this.options.getSurfaceElement?this.options.getSurfaceElement():null,f=(d==null?void 0:d.querySelector(".xterm-screen"))||i.element||d,p=Wa(i);if(!f||typeof f.getBoundingClientRect!="function"||p.cellHeight<=0)return!1;const m=f.getBoundingClientRect(),b=this.getLogicalCoordinates(a.clientX,a.clientY),v=m.width>0&&m.height>0;if(![o==null?void 0:o.cursorY,o==null?void 0:o.viewportY,o==null?void 0:o.baseY].every(X=>typeof X=="number"&&Number.isFinite(X)))return!1;const S=o==null?void 0:o.cursorY,A=o==null?void 0:o.viewportY,R=(o==null?void 0:o.baseY)+S-A,H=m.top+R*p.cellHeight,z=H+p.cellHeight,G=Number(i.rows);return R>=0&&(!Number.isFinite(G)||R<G)&&b.clientY>=H-2&&b.clientY<=z+2&&(!v||b.clientX>=m.left&&b.clientX<=m.right)}resolveDispatchTarget(a,i){var m;const o=this.options.getSurfaceElement?this.options.getSurfaceElement():null,d=(o==null?void 0:o.querySelector(".xterm-screen"))||i.querySelector(".xterm-screen")||null,f=((m=d==null?void 0:d.closest)==null?void 0:m.call(d,".xterm"))||null;let p=null;return typeof document<"u"&&typeof document.elementFromPoint=="function"&&(p=document.elementFromPoint(a.clientX,a.clientY)),p&&f&&(p===f||f.contains(p))?p:d||o||i}getMouseReport(a,i){const o=this.options.getSurfaceElement?this.options.getSurfaceElement():null,d=(o==null?void 0:o.querySelector(".xterm-screen"))||i.element;if(!d||typeof d.getBoundingClientRect!="function")return null;const f=d.getBoundingClientRect(),p=this.getLogicalCoordinates(a.clientX,a.clientY),m=Wa(i);if(m.cellWidth<=0||m.cellHeight<=0)return null;const b=Math.max(1,f.width||i.cols*m.cellWidth),v=Math.max(1,f.height||i.rows*m.cellHeight),y=Math.max(0,Math.min(b-1,p.clientX-f.left)),S=Math.max(0,Math.min(v-1,p.clientY-f.top)),A=Math.max(0,Math.min(i.cols-1,Math.floor(y/m.cellWidth))),E=Math.max(0,Math.min(i.rows-1,Math.floor(S/m.cellHeight)));return{col:A,row:E,x:Math.floor(y),y:Math.floor(S),button:0,action:0}}getCoreMouseService(a){var o,d;const i=a;return i.coreMouseService||((o=i._core)==null?void 0:o.coreMouseService)||((d=i._core)==null?void 0:d._coreMouseService)||null}getCoreService(a){var o;const i=a;return i.coreService||((o=i._core)==null?void 0:o.coreService)||null}getWheelDispatchTarget(a){const i=this.options.getSurfaceElement?this.options.getSurfaceElement():null;return(i==null?void 0:i.querySelector(".xterm"))||a.element||null}dispatchWheel(a,i,o,d){const f=this.getWheelDispatchTarget(o);if(!f||typeof WheelEvent>"u"||i===0)return!1;const p=this.getLogicalCoordinates(a.clientX,a.clientY),m=i<0?-1:1;let b=0;for(let v=0;v<Math.abs(i);v+=1)try{const y=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:m,deltaMode:1,ctrlKey:!!(d!=null&&d.ctrlKey),altKey:!!(d!=null&&d.altKey),shiftKey:!!(d!=null&&d.shiftKey)});f.dispatchEvent(y),b+=1}catch{return b>0}return b>0}emitWheel(a,i,o,d){if(i===0)return!1;if(this.dispatchWheel(a,i,o,d))return!0;const f=this.getCoreMouseService(o);if(!(f!=null&&f.triggerMouseEvent))return!1;let p=0;for(let m=0;m<Math.abs(i);m+=1){const b=this.getMouseReport(a,o);b&&(b.button=4,b.action=i<0?0:1,b.ctrl=!!(d!=null&&d.ctrlKey),b.alt=!!(d!=null&&d.altKey),b.shift=!!(d!=null&&d.shiftKey),f.triggerMouseEvent(b)&&(p+=1))}return p>0}scrollAlternateBuffer(a,i,o,d){var p;if(i===0)return"none";const f=Lr(o);if(!f&&!this.options.getIsController())return"none";if(this.emitWheel(a,i,o,d))return f?"application-mouse":"application-keys";if(!f){const m=this.getCoreService(o);if(!(m!=null&&m.triggerDataEvent))return"none";const v=`\x1B${!!((p=m.decPrivateModes)!=null&&p.applicationCursorKeys)?"O":"["}${i<0?"A":"B"}`;return m.triggerDataEvent(v.repeat(Math.abs(i)),!0),"application-keys"}return"none"}emitMouse(a,i,o){const d=this.options.getTerminal();if(!d)return;const f=this.getCoreMouseService(d);if(f!=null&&f.triggerMouseEvent){const m=this.getMouseReport(i,d);m&&(m.action=a==="mousedown"?1:a==="mouseup"?0:32,m.ctrl=!!(o!=null&&o.ctrlKey),m.alt=!!(o!=null&&o.altKey),m.shift=!!(o!=null&&o.shiftKey),f.triggerMouseEvent(m));return}if(this.options.allowSyntheticMouseFallback===!1||!this.activeTarget)return;const p=this.getLogicalCoordinates(i.clientX,i.clientY);fp(this.activeTarget,a,{clientX:p.clientX,clientY:p.clientY,button:0,buttons:a==="mouseup"?0:1})}beginGesture(a,i){this.startX=a.clientX,this.startY=a.clientY,this.lastX=a.clientX,this.lastY=a.clientY,this.setGestureState("pending"),this.scrollRemainderY=0,this.activeTarget=this.resolveDispatchTarget(a,i),this.clearLongPressTimer(),this.longPressTimer=setTimeout(()=>{var o,d;this.state==="pending"&&(this.setGestureState("longpress"),(d=(o=this.options).onLongPress)==null||d.call(o,{clientX:this.startX,clientY:this.startY}))},this.options.longPressDelayMs)}moveGesture(a,i){var v,y,S,A;if(this.state==="longpress"){(y=(v=this.options).onSelectionExtend)==null||y.call(v,{clientX:a.clientX,clientY:a.clientY}),i!=null&&i.cancelable&&((S=i.preventDefault)==null||S.call(i));return}if(this.state==="idle")return;const o=a.clientX-this.startX,d=a.clientY-this.startY,f=Math.hypot(o,d);if(this.state==="scrolling"){this.scrollGesture(a,i);return}const p=this.options.getTerminal(),m=this.options.getIsController(),b=Lr(p);if(!(f<=(this.options.dragThresholdPx||8))){if(this.clearLongPressTimer(),Math.abs(d)>=Math.abs(o)||!b||!m){this.setGestureState("scrolling"),p&&this.blurTerminal(p),this.lastX=a.clientX,this.lastY=this.startY,this.scrollRemainderY=0,this.scrollGesture(a,i);return}if(b&&m){this.state==="pending"&&(this.setGestureState("dragging"),this.emitMouse("mousedown",{clientX:this.startX,clientY:this.startY},i)),this.state==="dragging"&&(this.lastX=a.clientX,this.lastY=a.clientY,this.emitMouse("mousemove",a,i),i!=null&&i.cancelable&&((A=i.preventDefault)==null||A.call(i)));return}this.lastX=a.clientX,this.lastY=a.clientY}}scrollGesture(a,i){var R,H,z;const o=this.options.getTerminal();if(!o)return;const d=a.clientY-this.lastY;this.lastX=a.clientX,this.lastY=a.clientY;const f=Wa(o),p=f.measured?f.cellHeight:this.options.scrollLineHeightPx||f.cellHeight||18;this.scrollRemainderY+=d;const m=Math.trunc(this.scrollRemainderY/p),b=-m;let v=!1,y="none";const S=this.getActiveBuffer(o),A=Lr(o);if(b!==0){if((S==null?void 0:S.type)==="alternate")y=this.scrollAlternateBuffer(a,b,o,i),v=y!=="none";else{const G=this.getViewportY(o);o.scrollLines(b);const Q=this.getViewportY(o);y="buffer",v=G===null||Q===null||G!==Q}this.scrollRemainderY-=m*p}const E=this.getViewportElement(o);(H=(R=this.options).onGestureScroll)==null||H.call(R,{deltaY:d,lines:b,viewportY:this.getViewportY(o),scrollTop:(E==null?void 0:E.scrollTop)??null,scrollHeight:(E==null?void 0:E.scrollHeight)??null,clientHeight:(E==null?void 0:E.clientHeight)??null,moved:v,bufferType:(S==null?void 0:S.type)||null,baseY:typeof(S==null?void 0:S.baseY)=="number"?S.baseY:null,cursorY:typeof(S==null?void 0:S.cursorY)=="number"?S.cursorY:null,hasScrollback:typeof(S==null?void 0:S.hasScrollback)=="boolean"?S.hasScrollback:null,mouseTracking:A,scrollMode:y}),i!=null&&i.cancelable&&((z=i.preventDefault)==null||z.call(i))}endGesture(a,i){var p,m,b;this.clearLongPressTimer();const o=this.options.getTerminal(),d=this.options.getIsController(),f=Lr(o);if(this.state==="pending"){if(f&&d){const y={clientX:this.startX,clientY:this.startY};this.emitMouse("mousedown",y,i),this.emitMouse("mouseup",y,i)}const v={clientX:this.startX,clientY:this.startY};d&&o&&this.isInputLineHit(v,o)&&((m=(p=this.options).onFocus)==null||m.call(p))}else if(this.state==="dragging"&&f&&d){const v=a??{clientX:this.lastX,clientY:this.lastY};this.emitMouse("mouseup",v,i),i!=null&&i.cancelable&&((b=i.preventDefault)==null||b.call(i))}this.reset()}handlePointerDown(a,i){if(a.pointerType==="mouse")return!1;if(!a.isPrimary)return this.releasePointerCapture(),this.reset(),!1;if(a.cancelable&&a.preventDefault(),this.beginGesture(a,i),a.pointerType!=="touch")try{typeof i.setPointerCapture=="function"&&(i.setPointerCapture(a.pointerId),this.capturedPointerId=a.pointerId,this.captureElement=i)}catch{}return!0}handlePointerMove(a){a.pointerType==="mouse"||this.state==="idle"||this.moveGesture(a,a)}handlePointerUp(a){a.pointerType==="mouse"||this.state==="idle"||(this.releasePointerCapture(),this.endGesture(a,a))}handlePointerCancel(a){a&&a.pointerType==="mouse"||(this.releasePointerCapture(),this.cancelGesture())}handleTouchStart(a,i){if(a.touches.length!==1){this.reset();return}a.cancelable&&a.preventDefault(),this.beginGesture(a.touches[0],i)}handleTouchMove(a){a.touches.length===1&&this.moveGesture(a.touches[0],a)}handleTouchEnd(a){a.cancelable&&a.preventDefault(),this.endGesture(null,a)}handleTouchCancel(){this.cancelGesture()}cancelGesture(){this.clearLongPressTimer();const a=this.options.getTerminal(),i=this.options.getIsController(),o=Lr(a);if(this.state==="dragging"&&o&&i&&this.activeTarget){const d=this.getLogicalCoordinates(this.lastX,this.lastY);fp(this.activeTarget,"mouseup",{clientX:d.clientX,clientY:d.clientY,button:0,buttons:0})}this.reset()}releasePointerCapture(){const a=this.captureElement,i=this.capturedPointerId;if(this.captureElement=null,this.capturedPointerId=null,!(!a||i===null))try{typeof a.releasePointerCapture=="function"&&(typeof a.hasPointerCapture!="function"||a.hasPointerCapture(i))&&a.releasePointerCapture(i)}catch{}}clearLongPressTimer(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}reset(){this.clearLongPressTimer(),this.releasePointerCapture(),this.setGestureState("idle"),this.activeTarget=null}}var m0=Yy();const Gr="herdr_remote_renderer_probe_v1",uo=1,p0=720*60*60*1e3,Vu={};function Ag(){let r=null;if(typeof window>"u")r=Vu[Gr]||null;else try{r=window.localStorage?window.localStorage.getItem(Gr):null}catch{r=Vu[Gr]||null}if(!r)return{v:uo,ua:{}};try{const a=JSON.parse(r);return typeof a=="object"&&a!==null&&a.v===uo&&typeof a.ua=="object"&&a.ua!==null?a:{v:uo,ua:{}}}catch{return{v:uo,ua:{}}}}function g0(r,a=Date.now()){var d;const i=Ag();i.ua[r]={failedAt:a};const o=JSON.stringify(i);if(Vu[Gr]=o,typeof window<"u")try{(d=window.localStorage)==null||d.setItem(Gr,o)}catch(f){console.warn("Failed to write renderer probe result to localStorage:",f)}}function b0(r,a=Date.now()){const i=typeof navigator<"u"?navigator.userAgent:"";if(!i)return!1;const d=Ag().ua[i];return!(!d||typeof d.failedAt!="number"||a-d.failedAt>p0)}function hp(r,a=Date.now()){const i=typeof navigator<"u"?navigator.userAgent:"";i&&g0(i,a)}function y0(r){if(r.length<4)return!0;const a=r[0],i=r[1],o=r[2],d=r[3];for(let f=4;f<r.length;f+=4)if(r[f]!==a||r[f+1]!==i||r[f+2]!==o||r[f+3]!==d)return!1;return!0}function v0(r){if(!r||r.width<=0||r.height<=0)return console.debug("Canvas probe inconclusive: text layer canvas missing or zero dimensions"),"inconclusive";let a=null;try{a=r.getContext("2d",{willReadFrequently:!0})||r.getContext("2d")}catch(d){return console.debug("Canvas probe inconclusive: failed to acquire 2D context:",d),"inconclusive"}if(!a)return console.debug("Canvas probe inconclusive: 2D context is null"),"inconclusive";const i=Math.min(r.width,640),o=Math.min(r.height,240);if(i<=0||o<=0)return console.debug("Canvas probe inconclusive: calculated sample dimensions are zero"),"inconclusive";try{const d=a.getImageData(0,0,i,o);return y0(d.data)?"blank":"healthy"}catch(d){return console.debug("Canvas probe inconclusive: getImageData threw exception:",d),"inconclusive"}}function x0(r=2){return new Promise(a=>{if(typeof requestAnimationFrame!="function"){setTimeout(a,32);return}let i=r;const o=()=>{i--,i<=0?a():requestAnimationFrame(o)};requestAnimationFrame(o)})}function S0(r,a={}){if(b0())return{kind:"dom",dispose:()=>{},verify:async()=>{}};try{const i=new m0.CanvasAddon;r.loadAddon(i);let o="canvas",d=!1,f=null;const p=()=>{var b;if(o!=="dom"){hp();try{i.dispose()}catch{}o="dom",(b=a.onRendererSwapped)==null||b.call(a,"dom")}};return{get kind(){return o},dispose:()=>{d=!0;try{i.dispose()}catch{}},verify:async()=>{if(!(d||o!=="canvas"))return f||(f=(async()=>{var b;try{if(await x0(2),d||o!=="canvas")return;const v=(b=r.element)==null?void 0:b.querySelector("canvas.xterm-text-layer"),y=v0(v);y==="blank"?p():y==="inconclusive"&&console.debug("Canvas probe inconclusive; retaining canvas renderer without blacklisting")}catch(v){console.debug("Canvas probe inconclusive: unexpected error during verify():",v)}finally{f=null}})(),f)}}}catch(i){console.debug("Canvas renderer unavailable, using the DOM renderer:",i),hp()}return{kind:"dom",dispose:()=>{},verify:async()=>{}}}function mp(r,a){const i=typeof window<"u"?window:void 0,o=i&&typeof i.devicePixelRatio=="number"&&i.devicePixelRatio>0?i.devicePixelRatio:1,d=i&&i.visualViewport&&typeof i.visualViewport.scale=="number"&&i.visualViewport.scale>0?i.visualViewport.scale:1,f=Math.max(0,r.width),p=Math.max(0,r.height),m=Math.round(f*o*100)/100,b=Math.round(p*o*100)/100;return{dpr:o,scale:d,cssWidth:f,cssHeight:p,physicalWidth:m,physicalHeight:b}}function w0(r){const{lastSnapshot:a,currentSnapshot:i,physicalTolerancePx:o=6}=r;if(!a)return{shouldIgnore:!1,isVisualZoom:!1,reason:"initial"};const d=Math.abs(i.scale-a.scale)>.01,f=Math.abs(i.scale-1)>.01;if(d||f)return{shouldIgnore:!0,isVisualZoom:!0,reason:"visual_pinch_zoom"};if(Math.abs(i.dpr-a.dpr)>.01){const v=Math.abs(i.physicalWidth-a.physicalWidth),y=Math.abs(i.physicalHeight-a.physicalHeight);if(v<=o&&y<=o)return{shouldIgnore:!0,isVisualZoom:!0,reason:"dpr_zoom"}}const m=Math.abs(i.cssWidth-a.cssWidth),b=Math.abs(i.cssHeight-a.cssHeight);return m<1&&b<1?{shouldIgnore:!0,isVisualZoom:!1,reason:"no_box_change"}:{shouldIgnore:!1,isVisualZoom:!1,reason:"genuine_resize"}}const C0=" ()[]{}'\"\\`";function ku(r,a,i,o=1){var z,G;if(!a||!((z=a.buffer)!=null&&z.active)||a.cols<=0||a.rows<=0)return null;const d=i||((G=a.element)==null?void 0:G.querySelector(".xterm-screen"))||a.element;if(!d||typeof d.getBoundingClientRect!="function")return null;const f=d.getBoundingClientRect(),p=Ng(r.clientX,r.clientY,f,o),m=Wa(a);if(m.cellWidth<=0||m.cellHeight<=0)return null;const b=Math.max(1,f.width||a.cols*m.cellWidth),v=Math.max(1,f.height||a.rows*m.cellHeight),y=Math.max(0,Math.min(b-1,p.clientX-f.left)),S=Math.max(0,Math.min(v-1,p.clientY-f.top)),A=Math.max(0,Math.min(a.cols-1,Math.floor(y/m.cellWidth))),E=Math.max(0,Math.min(a.rows-1,Math.floor(S/m.cellHeight))),H=(a.buffer.active.viewportY??0)+E;return{col:A,bufferRow:H}}function T0(r,a){if(!r||r.length===0||r==="\0")return!0;for(const i of r)if(i==="\0"||/\s/.test(i)||a.includes(i))return!0;return!1}function N0(r,a,i){var A,E;if(!r||!((A=r.buffer)!=null&&A.active)||a<0||a>=r.cols)return null;const o=r.buffer.active.getLine(i);if(!o)return null;const d=((E=r.options)==null?void 0:E.wordSeparator)??C0,f=new Array(r.cols).fill(null),p=Math.min(r.cols,o.length);let m=0;for(;m<p;){const R=o.getCell(m);if(!R){f[m]={startCol:m,endCol:m+1,isSeparator:!0},m++;continue}const H=R.getWidth();if(H===0){f[m]||(f[m]={startCol:m,endCol:m+1,isSeparator:!0}),m++;continue}const z=R.getChars(),G=T0(z,d),Q=Math.min(r.cols,m+H),X={startCol:m,endCol:Q,isSeparator:G};for(let re=m;re<Q;re++)f[re]=X;m+=Math.max(1,H)}for(let R=p;R<r.cols;R++)f[R]||(f[R]={startCol:R,endCol:R+1,isSeparator:!0});const b=f[a];if(!b||b.isSeparator)return null;let v=b.startCol;for(;v>0;){const R=f[v-1];if(R&&!R.isSeparator)v=R.startCol;else break}let y=b.endCol;for(;y<r.cols;){const R=f[y];if(R&&!R.isSeparator)y=R.endCol;else break}const S=y-v;return S<=0?null:{startCol:v,length:S}}function A0(r){var f;if(!r||!((f=r.buffer)!=null&&f.active))return"";const a=r.buffer.active,i=a.viewportY??0,o=r.rows,d=[];for(let p=0;p<o;p++){const m=a.getLine(i+p);d.push(m?m.translateToString(!0):"")}for(;d.length>0&&d[d.length-1]==="";)d.pop();return d.join(`
34
+ `)}const pp=new Set(["│","┃","╎","╏","┆","┇","┊","┋","║","▏","▕","|"]),E0=.6,R0=new Set(["─","━","═","┄","┅","┈","┉","-"]),j0=.8;function Mu(r,a){if(!r)return!1;let i=0;const o=Math.min(a,r.length);for(let d=0;d<o;d++){const f=r.getCell(d);if(f){const p=f.getChars();p&&R0.has(p)&&i++}}return i>=Math.max(5,Math.min(a*.25,10))}function _u(r,a,i){var E;if(!r||!((E=r.buffer)!=null&&E.active)||r.cols<=0)return{startCol:0,endCol:0};const o=r.buffer.active,d=r.cols,f=Math.max(0,Math.min(d-1,a)),p=o.viewportY??0,m=r.rows>0?r.rows:1,b=new Int32Array(d);let v=0;for(let R=0;R<m;R++){const H=o.getLine(p+R);if(v++,!H)continue;const z=Math.min(d,H.length);for(let G=0;G<z;G++){const Q=H.getCell(G);if(Q){const X=Q.getChars();X&&pp.has(X)&&b[G]++}}}if(v===0)return{startCol:0,endCol:d-1};const y=v*E0,S=R=>b[R]>=y;let A=!1;for(let R=0;R<d;R++)if(S(R)){A=!0;break}if(A){if(S(f))return{startCol:f,endCol:f};let R=-1;for(let z=f-1;z>=0;z--)if(S(z)){R=z;break}let H=d;for(let z=f+1;z<d;z++)if(S(z)){H=z;break}return{startCol:R+1,endCol:H-1}}if(i!==void 0){const R=Math.max(p,Math.min(p+m-1,i)),H=o.getLine(R);if(!Mu(H,d)){let z=p;for(let X=R-1;X>=p;X--)if(Mu(o.getLine(X),d)){z=X+1;break}let G=p+m-1;for(let X=R+1;X<=p+m-1;X++)if(Mu(o.getLine(X),d)){G=X-1;break}const Q=G-z+1;if(Q>=2){const X=new Int32Array(d);for(let T=z;T<=G;T++){const _=o.getLine(T);if(!_)continue;const P=Math.min(d,_.length);for(let le=0;le<P;le++){const ve=_.getCell(le);if(ve){const Se=ve.getChars();Se&&pp.has(Se)&&X[le]++}}}const re=Q*j0,de=T=>X[T]>=re;let ee=!1;for(let T=0;T<d;T++)if(de(T)){ee=!0;break}if(ee){if(de(f))return{startCol:f,endCol:f};let T=-1;for(let P=f-1;P>=0;P--)if(de(P)){T=P;break}let _=d;for(let P=f+1;P<d;P++)if(de(P)){_=P;break}return{startCol:T+1,endCol:_-1}}}}}return{startCol:0,endCol:d-1}}function gp(r,a){const i=Math.min(r.startCol,r.endCol),o=Math.max(r.startCol,r.endCol),d=Math.min(r.startRow,r.endRow),f=Math.max(r.startRow,r.endRow);return{startCol:Math.max(a.startCol,Math.min(a.endCol,i)),endCol:Math.max(a.startCol,Math.min(a.endCol,o)),startRow:d,endRow:f}}function zu(r,a){var v;if(!r||!((v=r.buffer)!=null&&v.active)||r.cols<=0)return"";const i=r.buffer.active,o=r.cols,d=Math.min(a.startRow,a.endRow),f=Math.max(a.startRow,a.endRow),p=Math.max(0,Math.min(a.startCol,a.endCol)),m=Math.min(o-1,Math.max(a.startCol,a.endCol));if(p>m||d>f)return"";const b=[];for(let y=d;y<=f;y++){const S=i.getLine(y);if(!S){b.push("");continue}const A=S.translateToString(!0,p,m+1);b.push(A.trimEnd())}return b.join(`
35
+ `)}async function Pa(r){if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(r),"clipboard"}catch{}if(typeof document<"u"&&typeof document.execCommand=="function"){let a=null,i=null,o=null;try{if(a=document.createElement("textarea"),a.style.userSelect="text",a.style.webkitUserSelect="text",a.style.position="fixed",a.style.top="0",a.style.left="0",a.style.width="1px",a.style.height="1px",a.style.padding="0",a.style.border="none",a.style.outline="none",a.style.boxShadow="none",a.style.background="transparent",a.style.opacity="0",a.style.fontSize="16px",a.setAttribute("readonly",""),a.setAttribute("aria-hidden","true"),a.value=r,typeof window<"u"&&typeof window.getSelection=="function"&&(o=window.getSelection(),o&&o.rangeCount>0&&(i=o.getRangeAt(0))),document.body.appendChild(a),typeof navigator<"u"&&(/iPad|iPhone|iPod/.test(navigator.userAgent||"")||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1)){const p=document.createRange();p.selectNodeContents(a),o&&(o.removeAllRanges(),o.addRange(p)),a.setSelectionRange(0,r.length)}else a.focus({preventScroll:!0}),a.select();if(document.execCommand("copy"))return"exec"}catch{}finally{a&&a.parentNode&&a.parentNode.removeChild(a),o&&(o.removeAllRanges(),i&&o.addRange(i))}}return"failed"}async function k0(){if(!(typeof window>"u"||window.isSecureContext!==!1)||typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.readText!="function")return{ok:!1,reason:"insecure"};try{const a=await navigator.clipboard.readText();return!a||a.length===0?{ok:!1,reason:"empty"}:{ok:!0,text:a}}catch(a){return typeof window<"u"&&window.isSecureContext===!1?{ok:!1,reason:"insecure"}:(a==null?void 0:a.name)==="SecurityError"?{ok:!1,reason:"insecure"}:{ok:!1,reason:"denied"}}}async function M0(){if(!(typeof window>"u"||window.isSecureContext!==!1)||typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.read!="function")return{ok:!1,reason:"insecure"};try{const a=await navigator.clipboard.read();if(!a||a.length===0)return{ok:!1,reason:"empty"};for(const i of a){const o=i.types.find(d=>d.startsWith("image/"));if(o){const d=await i.getType(o);if(d&&d.size>0)return{ok:!0,blob:d}}}return{ok:!1,reason:"empty"}}catch(a){if(typeof window<"u"&&window.isSecureContext===!1)return{ok:!1,reason:"insecure"};const i=a==null?void 0:a.name;return i==="SecurityError"?{ok:!1,reason:"insecure"}:i==="NotAllowedError"?{ok:!1,reason:"denied"}:{ok:!1,reason:"empty"}}}function Eg(r){const a=r.clipboardData;if(!a)return null;if(a.files&&a.files.length>0)for(let i=0;i<a.files.length;i++){const o=a.files[i];if(o&&o.type.startsWith("image/"))return o}if(a.items&&a.items.length>0)for(let i=0;i<a.items.length;i++){const o=a.items[i];if(o&&o.type.startsWith("image/")){const d=o.getAsFile();if(d)return d}}return null}function _0(r){if(!r||r.length===0)return null;for(let a=0;a<r.length;a++){const i=r[a];if(i&&(i.type.startsWith("image/")||/\.(png|jpe?g|webp|gif)$/i.test(i.name)))return i}return null}const Du="Herdr Remote",bp=80,z0=/[\u0000-\u001F\u007F-\u009F]/g;function Fu(r){if(typeof r!="string")return"";const a=r.replace(z0," ").replace(/\s+/g," ").trim();return a.length<=bp?a:`${a.slice(0,bp-1).trimEnd()}…`}function D0(r,a,i){const o=Hv(i??null),d=o?`${o} `:"",f=Fu(r);if(f)return`${d}${f} · ${Du}`;const p=Fu(a);return p?`${d}${p} · ${Du}`:`${d}${Du}`}function L0(r,a,i){const o=D0(r,a,i);return typeof document<"u"&&(document.title=o),o}const O0=new Set(["http:","https:","mailto:"]),Lu=/(?:https?:\/\/|mailto:|www\.)[^\s"'<>`]+/gi,U0=/[.,;:!?'"]+$/,yp=8;function id(r){return/^www\./i.test(r)?`https://${r}`:r}function B0(r){const a=(d,f)=>d.split(f).length-1;let i=r.replace(U0,"");const o=[["(",")"],["[","]"],["{","}"]];for(const[d,f]of o)for(;i.endsWith(f)&&a(i,f)>a(i,d);)i=i.slice(0,-1);return i}function Rg(r){if(typeof r!="string"||r.length===0)return!1;try{return O0.has(new URL(id(r)).protocol)}catch{return!1}}function H0(r,a){if(typeof r!="string"||a<0)return null;Lu.lastIndex=0;for(let i=Lu.exec(r);i;i=Lu.exec(r)){const o=B0(i[0]);if(!o)continue;const d=i.index,f=d+o.length;if(a>=d&&a<f&&Rg(o))return o}return null}function Y0(r,a,i){var m;const o=(m=r==null?void 0:r.buffer)==null?void 0:m.active;if(!o||typeof o.getLine!="function"||!o.getLine(i))return null;let d=i;for(let b=0;b<yp;b+=1){const v=o.getLine(d);if(!(v!=null&&v.isWrapped)||d===0)break;d-=1}let f="",p=-1;for(let b=d;b<d+yp;b+=1){const v=o.getLine(b);if(!v||b>d&&!v.isWrapped)break;b===i&&(p=f.length+a),f+=v.translateToString(!1)}return p<0?null:{text:f,index:p}}function K0(r,a,i){const o=Y0(r,a,i);return o?H0(o.text,o.index):null}function G0(r){try{const a=new URL(id(r));return a.host||a.pathname}catch{return""}}function Ou(r){return!Rg(r)||typeof window>"u"||typeof window.open!="function"?!1:(window.open(id(r),"_blank","noopener,noreferrer"),!0)}const zi="tui-focusable group flex h-11 w-full select-none items-center gap-2 border px-2 text-left text-tui transition-colors",Di="border-tui-border text-tui-muted hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",q0=({anchorPoint:r,hasSelection:a,isController:i,vibrateOnKeyPress:o=!1,linkUrl:d=null,onOpenLink:f,onCopySelection:p,onCopyLine:m,onCopyScreen:b,onPaste:v,onClose:y})=>{const{t:S}=St(),A=x.useRef(null),[E,R]=x.useState(null);x.useEffect(()=>{if(o&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(8)}catch{}},[o]),x.useLayoutEffect(()=>{const Q=A.current;if(!Q||!Q.parentElement)return;const X=Q.parentElement.getBoundingClientRect(),re=Q.getBoundingClientRect(),de=re.width||208,ee=re.height||220,T=X.width,_=X.height;let P=r.x-de/2;P=Math.max(8,Math.min(Math.max(8,T-de-8),P));let le=r.y-ee-8;le<8&&(le=r.y+8),le=Math.max(8,Math.min(Math.max(8,_-ee-8),le)),R({x:P,y:le})},[r.x,r.y,a,i,d]);const H=Math.max(8,r.x-104),z=Math.max(8,r.y-200),G={position:"absolute",left:`${E?E.x:H}px`,top:`${E?E.y:z}px`,visibility:E?"visible":"hidden"};return u.jsx("div",{ref:A,role:"menu","aria-label":"终端选择操作",className:"z-50 w-52 select-none font-mono",style:G,onMouseDown:Q=>Q.stopPropagation(),onTouchStart:Q=>Q.stopPropagation(),onPointerDown:Q=>Q.stopPropagation(),children:u.jsxs(rn,{tone:"accent",className:"border border-tui-border bg-tui-base p-1.5 shadow-lg",bodyClassName:"flex flex-col gap-1",children:[d&&f&&u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:()=>{f(d),y()},children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.openLink")}),u.jsx("span",{className:"ml-auto max-w-[45%] truncate text-tui-faint",children:G0(d)})]}),a&&u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:()=>{p(),y()},children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.copySelection")})]}),u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:()=>{m(),y()},children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.copyLine")})]}),u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:()=>{b(),y()},children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.copyScreen")})]}),i&&u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:()=>{v(),y()},children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.paste")})]}),u.jsxs("button",{type:"button",role:"menuitem",className:$(zi,Di),onClick:y,children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:He.cursor}),u.jsx("span",{className:"truncate",children:S("clipboard.cancel")})]})]})})},V0=({isOpen:r,onClose:a,onSend:i,onSendImage:o})=>{const{t:d,addToast:f}=St(),[p,m]=x.useState(""),[b,v]=x.useState(null),[y,S]=x.useState(!1),A=x.useRef(null),E=x.useRef(null),R=x.useRef(null);x.useEffect(()=>{r&&(m(""),v(null),S(!1),A.current&&(A.current.value=""),E.current&&(E.current.value=""))},[r]);const H=async ee=>{if(ee.size===0){f("error",d("clipboard.fileEmpty"));return}S(!0);try{const T=await Pp(ee);T?(v(T),m("")):f("error",d("clipboard.imageTooLarge"))}catch(T){console.error("Failed to process image:",T),f("error",d("clipboard.imageTooLarge"))}finally{S(!1)}},z=async ee=>{const T=Eg(ee);T&&(ee.preventDefault(),await H(T))},G=async ee=>{const T=_0(ee.target.files);ee.target.value="",T&&await H(T)},Q=ee=>{const T=ee.target.value;m(T),T&&b&&v(null)},X=()=>{v(null),A.current&&(A.current.value=""),E.current&&(E.current.value="")},re=()=>{b?(o==null||o(b),a()):p.trim()&&(i(p),a())},de=!!(p.trim()||b);return u.jsx(ad,{isOpen:r,onClose:a,title:d("clipboard.pasteTitle"),closeLabel:d("clipboard.cancel"),size:"sm",footer:u.jsxs("div",{className:"flex items-center justify-end gap-2",children:[u.jsx(Ue,{variant:"ghost",onClick:a,children:d("clipboard.cancel")}),u.jsx(Ue,{variant:"primary",onClick:re,disabled:!de||y,children:d("clipboard.pasteSend")})]}),children:u.jsxs("div",{className:"flex flex-col gap-3 p-3 font-mono select-text",children:[u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"paste-fallback-input",className:"text-tui-sm text-tui-muted font-sans font-medium",children:d("clipboard.pasteHint")}),u.jsx("textarea",{ref:R,id:"paste-fallback-input","data-testid":"paste-fallback-input",rows:4,autoFocus:!0,placeholder:d("clipboard.pasteHint"),value:p,onChange:Q,onPaste:z,disabled:!!b||y,className:"tui-input min-h-[90px] w-full resize-none p-2 text-tui font-mono rounded border border-tui-border bg-tui-bg focus:outline-none focus:ring-1 focus:ring-tui-accent disabled:opacity-50"})]}),u.jsxs("div",{className:"relative my-1",children:[u.jsx("div",{className:"absolute inset-0 flex items-center",children:u.jsx("div",{className:"w-full border-t border-tui-border"})}),u.jsx("div",{className:"relative flex justify-center text-tui-xs uppercase",children:u.jsx("span",{className:"bg-tui-bg px-2 text-tui-muted font-sans",children:d("clipboard.imageSectionTitle")})})]}),u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsx("input",{ref:A,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",className:"hidden","data-testid":"paste-fallback-file-input",onChange:G}),u.jsx("input",{ref:E,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",capture:"environment",className:"hidden","data-testid":"paste-fallback-camera-input",onChange:G}),b?u.jsxs("div",{className:"flex flex-col items-center gap-2 p-3 border border-tui-border bg-tui-bg rounded",children:[u.jsx("img",{src:b.dataUrl,alt:"Pasted preview","data-testid":"pasted-image-preview",className:"max-h-40 max-w-full object-contain rounded border border-tui-border"}),u.jsxs("div",{className:"flex items-center justify-between w-full text-tui-xs text-tui-muted pt-1",children:[u.jsx("span",{children:d("clipboard.imageCompressedSize",{size:Mv(b.byteLength)})}),u.jsx(Ue,{variant:"ghost",onClick:X,"aria-label":d("clipboard.removeImage"),children:d("clipboard.cancel")})]})]}):u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(Ue,{variant:"default",onClick:()=>{var ee;return(ee=A.current)==null?void 0:ee.click()},disabled:y||!!p.trim(),className:"min-h-[44px] px-3 touch-manipulation text-tui-sm font-sans flex-1","aria-label":d("clipboard.chooseImage"),children:d("clipboard.chooseImage")}),u.jsx(Ue,{variant:"default",onClick:()=>{var ee;return(ee=E.current)==null?void 0:ee.click()},disabled:y||!!p.trim(),className:"min-h-[44px] px-3 touch-manipulation text-tui-sm font-sans flex-1","aria-label":d("clipboard.takePhoto"),children:d("clipboard.takePhoto")})]}),y&&u.jsx("div",{className:"flex items-center gap-2 text-tui-xs text-tui-muted animate-pulse",children:u.jsx("span",{children:d("clipboard.imageCompressing")})})]})]})})},F0=[[12288,12329],[12334,12335],[12337,12348],[12350,12350],[12353,12438],[12443,12543],[13312,19903],[19968,40959],[44032,55203],[63744,64255],[65281,65376],[65504,65510],[131072,196605],[196608,262141]];function X0(r){if(r>=32&&r<=126)return 1;if(r<12288)return 0;for(const[a,i]of F0){if(r<a)return 0;if(r<=i)return 2}return 0}const I0=2,Z0="?!#",Q0=8,J0=1500;function Li(r){return r===""||r===" "?" ":r}function W0(r){const a=r.buffer.active;return{key:"legacy",row:a.baseY+a.cursorY,caretCol:a.cursorX,startCol:a.cursorX,endCol:r.cols,empty:!1,agentLike:!1}}class P0{constructor(a){se(this,"getTerminal");se(this,"getFieldOption");se(this,"now");se(this,"textDecoder",new TextDecoder("utf-8"));se(this,"confidentKeys",new Set);se(this,"field",null);se(this,"predictions",[]);se(this,"predictedCursor",null);se(this,"srtt",null);se(this,"isSuppressed",!1);se(this,"suppressCursor",null);se(this,"suppressSentAt",0);se(this,"awaitingPrefixCommand",!1);se(this,"mismatches",0);this.getTerminal=a.getTerminal,this.getFieldOption=a.getField,this.now=a.now??(typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now())}handleUserInput(a){if(this.pruneExpired(),a.length===0)return;const i=this.textDecoder.decode(a,{stream:!1});if(!i)return;const o=wg(i);if(o==="passive")return;if(o==="pointer"){this.freeze("pointer");return}if(this.awaitingPrefixCommand){this.awaitingPrefixCommand=!1,this.freeze("Herdr prefix command",{demote:!0});return}if(r0(i)){this.freeze("escape",{demote:!0});return}const d=this.getTerminal();if(!d){this.reset("terminal unavailable",!0);return}for(const f of i){const p=f.codePointAt(0);if(p===void 0)continue;if(p===I0){this.awaitingPrefixCommand=!0,this.freeze("Herdr prefix",{demote:!0});return}if(p===27||p===9||p===10||p===13||p<32&&p!==8){this.freeze("control or escape sequence");return}if(p===8||p===127){if(!this.handleBackspace(d))return;continue}const m=X0(p);if(m===0){this.freeze("unpredictable character");return}if(!this.handlePrintable(f,m,d))return}}onServerOutput(){var f,p;const a=this.getTerminal(),i=a?{row:a.buffer.active.baseY+a.buffer.active.cursorY,col:a.buffer.active.cursorX}:null;if(this.isSuppressed){const m=this.now()-this.suppressSentAt>=this.suppressTimeout();(!!i&&!!this.suppressCursor&&(i.row!==this.suppressCursor.row||i.col!==this.suppressCursor.col)||m)&&(this.isSuppressed=!1,this.suppressCursor=null)}if(this.pruneExpired(),this.predictions.length===0||!a||!i)return;const o=this.field;if(this.getFieldOption){const m=this.getFieldOption();if(!m||m.key!==(o==null?void 0:o.key)){if(this.predictions.every(b=>b.frozenFrom)){this.predictions=[],this.predictedCursor=null;return}this.mismatch();return}if(m.layout!==o.layout){this.predictions=[],this.predictedCursor=null,this.field=m;return}}const d=[];for(const m of this.predictions){const b=(f=a.buffer.active.getLine(m.row))==null?void 0:f.getCell(m.col),v=Li(b?b.getChars():""),y=m.kind==="char"?v===m.char&&(m.width===1||(((p=b==null?void 0:b.getWidth)==null?void 0:p.call(b))??2)===2):v===" ",S=m.kind==="char"?i.row>m.row||i.row===m.row&&i.col>=m.col+m.width:i.row<m.row||i.row===m.row&&i.col<=m.col,A=m.before.includes(v);if(y&&(S||!A))this.updateSrtt(Math.max(0,this.now()-m.sentAt)),o&&!m.frozenFrom&&this.markConfident(o.key);else if(m.frozenFrom){const E=m.frozenFrom;!S&&A&&i.row===E.row&&i.col>=E.col&&d.push(m)}else if(!S&&A)d.push(m);else{this.mismatch();return}}this.predictions=d,d.length===0&&(this.predictedCursor=null)}reset(a,i){var f;this.predictions=[],this.predictedCursor=null;const o=typeof i=="boolean"?i:(i==null?void 0:i.suppress)??!0;if(typeof i=="object"&&(i==null?void 0:i.demote)===!0){const p=this.field??((f=this.getFieldOption)==null?void 0:f.call(this))??null;p&&this.confidentKeys.delete(p.key)}if(o){this.isSuppressed=!0,this.suppressSentAt=this.now();const p=this.getTerminal();p?this.suppressCursor={row:p.buffer.active.baseY+p.buffer.active.cursorY,col:p.buffer.active.cursorX}:this.suppressCursor=null}else this.isSuppressed=!1,this.suppressCursor=null}forgetConfidence(){this.confidentKeys.clear(),this.field=null}getVisiblePredictions(){return this.pruneExpired(),this.visiblePredictions().map(a=>({row:a.row,col:a.col,char:a.char}))}getOverlayItems(){var y,S,A,E;this.pruneExpired();const a=this.visiblePredictions();if(a.length===0)return[];const i=a.map(R=>({row:R.row,col:R.col,char:R.char,width:R.width,kind:R.kind})),o=a[a.length-1],d=this.predictedCursor??{row:o.row,col:o.kind==="erase"?o.col:o.col+o.width},f=(R,H)=>a.some(z=>z.row===R&&z.col<=H&&H<z.col+z.width),p=this.getTerminal(),m=p==null?void 0:p.buffer.active;if(m){const R={row:m.baseY+m.cursorY,col:m.cursorX};if(!f(R.row,R.col)&&(R.row!==d.row||R.col!==d.col)){const H=((S=(y=m.getLine(R.row))==null?void 0:y.getCell(R.col))==null?void 0:S.getChars())??"";i.push({row:R.row,col:R.col,char:Li(H),width:1,kind:"mask"})}}const b=a.find(R=>R.row===d.row&&R.col===d.col),v=b?b.char:Li(((E=(A=m==null?void 0:m.getLine(d.row))==null?void 0:A.getCell(d.col))==null?void 0:E.getChars())??"");return i.push({row:d.row,col:d.col,char:v,width:1,kind:"caret"}),i}getState(){return this.field&&this.confidentKeys.has(this.field.key)?"confident":"tentative"}getField(){return this.field}getMismatchCount(){return this.mismatches}getEchoSrttMs(){return this.srtt}visiblePredictions(){const a=this.getState()==="confident";return this.predictions.filter(i=>i.frozenFrom?i.shownWhenFrozen:a)}freeze(a,i={}){var p;const o=this.getTerminal(),d=o?{row:o.buffer.active.baseY+o.buffer.active.cursorY,col:o.buffer.active.cursorX}:null,f=this.getState()==="confident";for(const m of this.predictions)m.frozenFrom||(m.frozenFrom=d??{row:m.row,col:m.col},m.shownWhenFrozen=f);if(this.predictedCursor=null,i.demote){const m=this.field??((p=this.getFieldOption)==null?void 0:p.call(this))??null;m&&this.confidentKeys.delete(m.key)}this.isSuppressed=!0,this.suppressSentAt=this.now(),this.suppressCursor=d}suppressTimeout(){return Math.max(300,(this.srtt??300)*1.5)}stillSuppressed(){return this.isSuppressed?this.now()-this.suppressSentAt>=this.suppressTimeout()?(this.isSuppressed=!1,this.suppressCursor=null,!1):!0:!1}handlePrintable(a,i,o){var S;if(this.stillSuppressed())return!1;const d=this.ensureField(o);if(!d||!this.predictedCursor)return!1;const f=this.predictedCursor,p=this.predictions.length===0&&f.col===d.caretCol;if(d.agentLike&&d.empty&&p&&Z0.includes(a))return this.freeze("agent mode switch"),!1;if(f.col+i>d.endCol-1)return this.freeze("cursor would reach the edge of the field"),!1;const m=(S=o.buffer.active.getLine(f.row))==null?void 0:S.getCell(f.col),b=[Li(m?m.getChars():"")],v=this.predictions[this.predictions.length-1];let y;return v&&v.kind==="erase"&&v.row===f.row&&v.col===f.col&&(y=this.predictions.pop(),b.push(...v.before," ")),this.predictions.push({row:f.row,col:f.col,char:a,width:i,kind:"char",before:b,sentAt:this.now(),replaces:y}),f.col+=i,!0}handleBackspace(a){var o,d,f;const i=this.predictions[this.predictions.length-1];if(this.predictedCursor&&i&&!i.frozenFrom&&i.kind==="char"&&i.row===this.predictedCursor.row&&i.col+i.width===this.predictedCursor.col)return this.predictions.pop(),this.predictedCursor.col=i.col,i.replaces&&this.predictions.push(i.replaces),!0;if(!this.stillSuppressed()){const p=this.ensureField(a),m=this.predictedCursor;if(p&&m){const b=a.buffer.active.getLine(m.row),v=b==null?void 0:b.getCell(m.col-1),y=v&&((o=v.getWidth)==null?void 0:o.call(v))===0?2:1,S=m.col-y;let A=!0;for(let R=m.col;R<p.endCol&&A;R++)A=Li(((d=b==null?void 0:b.getCell(R))==null?void 0:d.getChars())??"")===" ";const E=Li(((f=b==null?void 0:b.getCell(S))==null?void 0:f.getChars())??"");if(S>p.startCol&&A&&E!==" ")return this.predictions.push({row:m.row,col:S,char:" ",width:y,kind:"erase",before:[E],sentAt:this.now()}),m.col=S,!0}}return this.freeze("backspace into server content"),!1}ensureField(a){if(this.predictedCursor&&this.field)return this.field;const i=this.getFieldOption?this.getFieldOption():W0(a);return i?(this.field=i,this.predictions=this.predictions.filter(o=>o.frozenFrom),this.predictedCursor={row:i.row,col:i.caretCol},i):null}markConfident(a){for(this.confidentKeys.delete(a),this.confidentKeys.add(a);this.confidentKeys.size>Q0;){const i=this.confidentKeys.values().next().value;if(i===void 0)break;this.confidentKeys.delete(i)}}mismatch(){this.mismatches++,this.predictions=[],this.predictedCursor=null,this.field&&this.confidentKeys.delete(this.field.key),this.isSuppressed=!1,this.suppressCursor=null}pruneExpired(){if(this.predictions.length===0)return;const a=this.now(),i=this.predictions.filter(o=>a-o.sentAt<=J0);i.length!==this.predictions.length&&(this.predictions=i,this.predictions.length===0&&(this.predictedCursor=null))}updateSrtt(a){this.srtt===null?this.srtt=a:this.srtt=this.srtt*.8+a*.2}}const vp="hr-predicting";function $0(r){if(typeof requestAnimationFrame=="function"){const i=requestAnimationFrame(r);return()=>cancelAnimationFrame(i)}const a=setTimeout(r,16);return()=>clearTimeout(a)}function eS(r){var i,o,d,f;const a=(f=(d=(o=(i=r._core)==null?void 0:i._renderService)==null?void 0:o.dimensions)==null?void 0:d.css)==null?void 0:f.cell;return!(a!=null&&a.width)||!(a!=null&&a.height)?null:{width:a.width,height:a.height}}function tS(r){var i,o,d,f,p;const a=(o=(i=r==null?void 0:r._core)==null?void 0:i._themeService)==null?void 0:o.colors;return{foreground:(d=a==null?void 0:a.foreground)==null?void 0:d.css,background:(f=a==null?void 0:a.background)==null?void 0:f.css,cursor:(p=a==null?void 0:a.cursor)==null?void 0:p.css}}class nS{constructor(a){se(this,"options");se(this,"layer",null);se(this,"owner",null);se(this,"cells",new Map);se(this,"caret",null);se(this,"retiring",new Set);se(this,"cancelRetireFrame",null);this.options=a}sync(a){var y,S;const i=this.options.getTerminal(),o=i?this.ensureLayer(i):null,d=i?eS(i):null;if(!i||!o||!d){this.clear();return}const f=this.resolveStyle(),p=((S=(y=i.buffer)==null?void 0:y.active)==null?void 0:S.viewportY)??0,m=A=>A-p>=0&&A-p<i.rows,b=new Set;let v=null;for(const A of a){const E=A.kind??"char";if(!m(A.row))continue;if(E==="caret"){v=A;continue}const R=`${A.row}:${A.col}:${E}`;b.add(R);let H=this.cells.get(R);H||(H=this.createCell(o),this.cells.set(R,H)),this.retiring.delete(H),this.place(H,A,p,d,f),this.paintCell(H,A.char,E,A.width??1,f)}for(const[A,E]of this.cells)b.has(A)||(this.cells.delete(A),this.retire(E));v?(this.caret||(this.caret=this.createCell(o)),this.retiring.delete(this.caret),this.place(this.caret,v,p,d,f),this.paintCaret(this.caret,v.char,f)):this.caret&&(this.retire(this.caret),this.caret=null),this.updateOwnerClass()}afterRender(){this.flushRetired()}clear(){for(const a of this.cells.values())this.retire(a);this.cells.clear(),this.caret&&(this.retire(this.caret),this.caret=null),this.updateOwnerClass()}dispose(){var a,i,o;(a=this.cancelRetireFrame)==null||a.call(this),this.cancelRetireFrame=null,this.cells.clear(),this.retiring.clear(),this.caret=null,(i=this.layer)==null||i.remove(),this.layer=null,(o=this.owner)==null||o.classList.remove(vp),this.owner=null}ensureLayer(a){var f;const i=a.element??null,o=i==null?void 0:i.querySelector(".xterm-screen");if(!i||!o)return null;if(this.layer&&this.layer.parentElement===o)return this.layer;(f=this.layer)==null||f.remove();const d=document.createElement("div");return d.className="hr-prediction-layer",Object.assign(d.style,{position:"absolute",left:"0",top:"0",pointerEvents:"none",zIndex:"7"}),o.appendChild(d),this.layer=d,this.owner=i,d}createCell(a){const i=document.createElement("div");return Object.assign(i.style,{position:"absolute",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none",userSelect:"none"}),a.appendChild(i),i}place(a,i,o,d,f){const p=i.width??1;a.style.left=`${i.col*d.width}px`,a.style.top=`${(i.row-o)*d.height}px`,a.style.width=`${p*d.width}px`,a.style.height=`${d.height}px`,a.style.lineHeight=`${d.height}px`,a.style.fontFamily=f.fontFamily??"inherit",a.style.fontSize=f.fontSize?`${f.fontSize}px`:"inherit",a.style.textAlign=p===2?"center":"left"}paintCell(a,i,o,d,f){a.textContent=o==="erase"?" ":i,a.style.color=f.color??"",a.style.backgroundColor=f.background??"",a.style.boxShadow="none",a.style.textDecoration=o==="char"&&f.underline?"underline":"none"}paintCaret(a,i,o){const d=o.cursor??o.color;if(a.textContent=i,a.style.textDecoration="none",a.style.boxShadow="none",a.style.color=o.color??"",a.style.backgroundColor="transparent",!!d)switch(o.cursorShape??"block"){case"bar":a.style.boxShadow=`inset 2px 0 0 ${d}`;break;case"underline":a.style.boxShadow=`inset 0 -2px 0 ${d}`;break;default:a.style.backgroundColor=d,o.background&&(a.style.color=o.background)}}resolveStyle(){const a=this.options.getStyle();if(a.color&&a.background&&a.cursor)return a;const i=tS(this.options.getTerminal()),o=a.color??i.foreground;return{...a,color:o,background:a.background??i.background,cursor:a.cursor??i.cursor??o}}retire(a){this.retiring.add(a),this.cancelRetireFrame||(this.cancelRetireFrame=$0(()=>{this.cancelRetireFrame=null,this.flushRetired()}))}flushRetired(){var a;for(const i of this.retiring)i.remove();this.retiring.clear(),(a=this.cancelRetireFrame)==null||a.call(this),this.cancelRetireFrame=null,this.updateOwnerClass()}updateOwnerClass(){if(!this.owner)return;const a=this.cells.size>0||this.caret!==null||this.retiring.size>0;this.owner.classList.toggle(vp,a)}}const ho=new Set(["│","┃","║","▐","▕","▏","▌"]),vo=new Set(["┌","┐","└","┘","╭","╮","╰","╯","├","┤","┬","┴","┼","┏","┓","┗","┛","╔","╗","╚","╝","╠","╣","╟","╢","╞","╡"]),lS=new Set(["╭","┌","┏","╔"]),aS=new Set(["╮","┐","┓","╗"]),iS=new Set(["╰","└","┗","╚"]),rS=new Set(["╯","┘","┛","╝"]),Uu=new Set(["─","━","═","╌","┄"]),sS=new Set(["❯","›",">","!"]),xp=new Set(["$","#","%",">","❯","›","➜","λ","»"]),Xu=8,oS=12,Sp=2,wp=1,cS=4,uS=3,dS=/-- INSERT --/,fS=/-- (?:NORMAL|VISUAL(?: LINE| BLOCK)?|REPLACE) --/,hS=/Esc to cancel|Enter to (?:confirm|select)|to navigate|Space to (?:change|toggle|select)/i,mS=/^\s*\d+[.)]\s/;function Hi(r){return r===""||r===" "||r===" "}class pS{constructor(a){se(this,"cell");se(this,"top");se(this,"bottom");var i;this.screen=a,this.cell=(i=a.getNullCell)==null?void 0:i.call(a),this.top=a.baseY,this.bottom=a.baseY+a.rows-1}get cols(){return this.screen.cols}at(a,i){var o;if(!(a<this.top||a>this.bottom||i<0||i>=this.screen.cols))return(o=this.screen.getLine(a))==null?void 0:o.getCell(i,this.cell)}char(a,i){var o;return((o=this.at(a,i))==null?void 0:o.getChars())??""}dim(a,i){var o,d;return!!((d=(o=this.at(a,i))==null?void 0:o.isDim)!=null&&d.call(o))}text(a,i,o){var d;return a<this.top||a>this.bottom?"":((d=this.screen.getLine(a))==null?void 0:d.translateToString(!0,i,o))??""}isEdge(a,i){if(!ho.has(this.char(a,i)))return!1;const o=this.char(a-1,i),d=this.char(a+1,i);return ho.has(o)||vo.has(o)||ho.has(d)||vo.has(d)}blankOrDim(a,i,o){var d;for(let f=i;f<o;f++){const p=this.at(a,f);if(p&&!Hi(p.getChars())&&!((d=p.isDim)!=null&&d.call(p)))return!1}return!0}}function gS(r,a,i){if(r.isEdge(a,i))return null;let o=0;for(let f=i-1;f>=0;f--)if(r.isEdge(a,f)){o=f+1;break}let d=r.cols;for(let f=i+1;f<r.cols;f++)if(r.isEdge(a,f)){d=f;break}return o<d?{start:o,end:d}:null}function Cp(r,a,i){if(!Uu.has(r.char(a,i.start))||!Uu.has(r.char(a,i.end-1))||vo.has(r.char(a,i.start-1)))return!1;const o=i.end-i.start;let d=0;for(let f=i.start;f<i.end;f++)if(Uu.has(r.char(a,f)))d++;else if(f-i.start-d>o*.1)return!1;return d>=o*.9}function Gi(r){return`${r.start}-${r.end}`}function bS(r,a,i){const o=i.start-1,d=i.end,{row:f}=a;if(o<0||d>=r.cols)return null;const p=r.char(f,o);if(!ho.has(p)||r.char(f,d)!==p)return null;let m=f-1;for(;m>=r.top&&r.char(m,o)===p;)m--;let b=f+1;for(;b<=r.bottom&&r.char(b,o)===p;)b++;if(b-m-1>Xu||!lS.has(r.char(m,o))||!aS.has(r.char(m,d))||!iS.has(r.char(b,o))||!rS.has(r.char(b,d))||r.dim(f,o))return null;const v=i.start+wp,y=i.end-wp;return a.col<v||a.col>=y?null:{kind:"frame",key:`frame:${Gi(i)}:${b}`,region:Gi(i),layout:`${m}`,row:f,caretCol:a.col,startCol:v,endCol:y,empty:m+2===b&&a.col===v&&r.blankOrDim(f,v,y),agentLike:!0,vimInsert:null}}function yS(r,a,i){const{row:o}=a;let d=-1;for(let y=o-1;y>=Math.max(r.top,o-Xu);y--)if(Cp(r,y,i)){d=y;break}if(d<0)return null;let f=-1;for(let y=o+1;y<=Math.min(r.bottom,o+Xu);y++)if(Cp(r,y,i)){f=y;break}if(f<0)return null;const p=d+1;let m=-1;for(let y=i.start;y<Math.min(i.end,i.start+3);y++){const S=r.char(p,y);if(!Hi(S)){sS.has(S)&&Hi(r.char(p,y+1))&&(m=y);break}}if(m<0||r.dim(p,m)||mS.test(r.text(p,m+1,i.end)))return null;for(let y=p+1;y<f;y++)for(let S=i.start;S<i.start+Sp;S++)if(!Hi(r.char(y,S)))return null;let b="";for(let y=f+1;y<=Math.min(r.bottom,f+oS)&&!vo.has(r.char(y,i.start-1));y++)b+=`${r.text(y,i.start,i.end)}
36
+ `;if(hS.test(b)||fS.test(b))return null;const v=o===p?m+2:i.start+Sp;return a.col<v||a.col>=i.end?null:{kind:"rule",key:`rule:${Gi(i)}:${f}`,region:Gi(i),layout:`${d}`,row:o,caretCol:a.col,startCol:v,endCol:i.end,empty:f-d===2&&a.col===v&&r.blankOrDim(o,v,i.end),agentLike:!0,vimInsert:dS.test(b)}}function vS(r,a,i){if(a.hidden)return null;const{row:o,col:d}=a;for(let f=d-2;f>=i.start;f--)if(!(!xp.has(r.char(o,f))||!Hi(r.char(o,f+1))))return r.dim(o,f)?null:Tp(r,a,i,o,f+2,f===i.start);for(let f=o-1;f>=Math.max(r.top,o-uS);f--){let p=i.end-1;for(;p>=i.start&&Hi(r.char(f,p));)p--;if(p>=i.end-1-cS&&xp.has(r.char(f,p)))return r.dim(f,p)?null:Tp(r,a,i,f,i.start,!1);if(p<i.end-1)return null}return null}function Tp(r,a,i,o,d,f){const p=a.row===o?d:i.start;return a.col<p||a.col>=i.end?null:{kind:"prompt",key:`prompt:${Gi(i)}:${o}`,region:Gi(i),layout:`${o}`,row:a.row,caretCol:a.col,startCol:p,endCol:i.end,empty:a.row===o&&a.col===p&&r.blankOrDim(a.row,p,i.end),agentLike:f,vimInsert:null}}function xS(r,a){const i=new pS(r);if(a.row<i.top||a.row>i.bottom||a.col<0||a.col>=r.cols)return null;const o=gS(i,a.row,a.col);return o?bS(i,a,o)??yS(i,a,o)??vS(i,a,o):null}class SS{constructor(){se(this,"insertSeen",new Set)}detect(a,i){const o=xS(a,i);return!o||o.vimInsert===null?o:o.vimInsert?(this.insertSeen.add(o.region),o):this.insertSeen.has(o.region)?null:o}reset(){this.insertSeen.clear()}}class wS{constructor(a){se(this,"tracker",new SS);se(this,"cached");se(this,"lastComplete",null);se(this,"detect",()=>{var a,i;if((i=(a=this.options).isSynchronizing)!=null&&i.call(a))return this.lastComplete;if(this.cached===void 0){const o=this.options.getScreen(),d=this.options.getCursor();this.cached=o&&d?this.tracker.detect(o,d):null,this.lastComplete=this.cached}return this.cached});this.options=a}invalidate(){this.cached=void 0}reset(){this.tracker.reset(),this.cached=void 0,this.lastComplete=null}}const CS=25,TS=2026,NS=1e3;function AS(r,a=()=>performance.now()){let i=!1,o=null;const d=()=>{i=!1,o=null},f=r.parser;if(!f||typeof f.registerCsiHandler!="function")return{isCursorHidden:()=>!1,isSynchronizing:()=>!1,reset:d,dispose:()=>{}};const p=b=>v=>{for(const y of v.flat())y===CS&&(i=!b),y===TS&&(o=b?a():null);return!1},m=[f.registerCsiHandler({prefix:"?",final:"h"},p(!0)),f.registerCsiHandler({prefix:"?",final:"l"},p(!1)),f.registerCsiHandler({intermediates:"!",final:"p"},()=>(d(),!1))];return typeof f.registerEscHandler=="function"&&m.push(f.registerEscHandler({final:"c"},()=>(d(),!1))),{isCursorHidden:()=>i,isSynchronizing:()=>o!==null&&a()-o<NS,reset:d,dispose:()=>{for(const b of m)b.dispose()}}}const jg=40;function ES(r){return r?`${r.kind} row ${r.row} cols ${r.startCol}-${r.endCol} caret ${r.caretCol}`:"none"}function Np(r,a){return r==="off"?!1:r==="always"?!0:a!==null&&a>jg}const RS=250,jS=({onTerminalFocus:r,isActive:a=!0})=>{var on,at,ka,Vi,ml,Al;const i=x.useRef(null),o=x.useRef(null),d=x.useRef(null),f=x.useRef(null),p=x.useRef(1),m=x.useRef({cols:0,rows:0}),b=x.useRef(null),v=x.useRef(null),y=x.useRef(null),S=x.useRef(null),A=x.useRef({width:0,height:0}),E=x.useRef(null),R=hv(),H=R||typeof navigator<"u"&&navigator.maxTouchPoints>0||typeof window<"u"&&"ontouchstart"in window,z=typeof window<"u"&&new URLSearchParams(window.location.search).get("debug")==="1",[G,Q]=x.useState({state:"idle",deltaY:0,lines:0,viewportY:null,scrollTop:null,scrollHeight:null,clientHeight:null,moved:!1,focused:!1,bufferType:null,baseY:null,cursorY:null,hasScrollback:null,mouseTracking:!1,scrollMode:"none",scrollCalls:0,lastScrollLines:null,lastInputEvent:"",pointerEvents:0,touchEvents:0}),[X,re]=x.useState({framesPerSec:0,bytesPerSec:0}),[de,ee]=x.useState(null),T=x.useRef(null),_=x.useRef(!1),P=x.useRef(!1),le=x.useRef([]);x.useEffect(()=>{if(!z)return;const I=setInterval(()=>{const be=performance.now()-1e3,he=le.current;for(;he.length>0&&he[0].time<be;)he.shift();let ze=0;for(let te=0;te<he.length;te++)ze+=he[te].bytes;re({framesPerSec:he.length,bytesPerSec:ze})},1e3);return()=>clearInterval(I)},[z]);const{isController:ve,connectionState:Se,settings:fe,hostPalette:Re,terminalResetVersion:Ge,sendResize:D,sendBinary:F,observeKeyInput:J,consumeModifierLatch:q,agentStatus:V,addToast:je,warnViewerMode:pe,connect:ke,subscribeToOutput:Ye,subscribeToPasteFileReady:Ke,uploadImage:Qe,profiles:$t,activeProfileId:tt,t:we,rttMs:hn}=St(),qe=dl.useMemo(()=>Av(Re),[Re]),Je=x.useRef(qe);Je.current=qe;const We=x.useRef(ve);We.current=ve;const wt=x.useRef(F);wt.current=F;const gt=x.useRef(je);gt.current=je;const qt=x.useRef(pe);qt.current=pe;const Tn=x.useRef(D);Tn.current=D;const Nn=x.useRef(Qe);Nn.current=Qe;const Hn=x.useRef(a);Hn.current=a;const $n=x.useRef(fe);$n.current=fe;const kt=x.useRef(we);kt.current=we;const Pe=x.useRef(null),Ct=x.useRef(null),ae=x.useRef(null),Ae=x.useRef(q);Ae.current=q;const Le=x.useRef(()=>{}),ot=x.useRef(I=>{var W,be,he,ze;(W=Pe.current)==null||W.reset(I),(be=Pe.current)==null||be.forgetConfidence(),(he=ae.current)==null||he.reset(),(ze=Ct.current)==null||ze.clear()}),[sn,bt]=x.useState(null),zt=x.useRef(null),[Yn,Vt]=x.useState(null),Ut=x.useRef(null);Ut.current=Yn;const[yt,nt]=x.useState(null),Tt=x.useRef(null);Tt.current=yt;const[ei,An]=x.useState(""),el=x.useRef("");el.current=ei;const[wl,Zt]=x.useState(!1),Cl=x.useRef(!1);Cl.current=wl;const mn=x.useRef(!1),[Tl,fl]=x.useState(0),tl=x.useRef(null),En=x.useRef(null),Kn=x.useRef(null),Rn=x.useRef(null),[qi,Il]=x.useState(!1),nl=x.useCallback(I=>{var ze;const W=f.current;if(!W)return null;const be=((ze=d.current)==null?void 0:ze.querySelector(".xterm-screen"))||d.current,he=ku(I,W,be,p.current);return he?K0(W,he.col,he.bufferRow):null},[]),ja=x.useCallback(I=>{var ze;const W=f.current;if(!W)return;const be=((ze=d.current)==null?void 0:ze.querySelector(".xterm-screen"))||d.current,he=ku(I,W,be,p.current);if(he){Kn.current=he;const te=_u(W,he.col,he.bufferRow);Rn.current=te;const Nt=N0(W,he.col,he.bufferRow);if(Nt){const it={startCol:Nt.startCol,endCol:Nt.startCol+Nt.length-1,startRow:he.bufferRow,endRow:he.bufferRow},Ft=gp(it,te),At=zu(W,Ft);nt(Ft),An(At),Zt(!0)}else nt(null),An(""),Zt(!1),Kn.current=null,Rn.current=null}else nt(null),An(""),Zt(!1),Kn.current=null,Rn.current=null;tl.current=I,En.current=null},[]),Zl=x.useCallback(I=>{var At;const W=f.current,be=Kn.current;if(!W||!be)return;En.current=I;const he=((At=d.current)==null?void 0:At.querySelector(".xterm-screen"))||d.current,ze=ku(I,W,he,p.current);if(!ze)return;const te=Rn.current??_u(W,be.col,be.bufferRow),Nt={startCol:Math.min(be.col,ze.col),endCol:Math.max(be.col,ze.col),startRow:Math.min(be.bufferRow,ze.bufferRow),endRow:Math.max(be.bufferRow,ze.bufferRow)},it=gp(Nt,te),Ft=zu(W,it);nt(it),An(Ft),Zt(!0)},[]),hl=x.useRef(ja);hl.current=ja;const Nl=x.useRef(Zl);Nl.current=Zl;const Ql=x.useCallback(async()=>{const I=el.current;if(!I)return;await Pa(I)==="failed"?gt.current("error",kt.current("clipboard.copyFailed")):gt.current("success",kt.current("clipboard.copied"))},[]),Gn=x.useCallback(async()=>{var it,Ft,At,kn;const I=f.current;if(!I)return;const W=(it=I.buffer)==null?void 0:it.active;if(!W)return;const be=((Ft=Tt.current)==null?void 0:Ft.startRow)??((At=Kn.current)==null?void 0:At.bufferRow)??W.viewportY,he=Rn.current??_u(I,((kn=Kn.current)==null?void 0:kn.col)??0,be),ze={startCol:he.startCol,endCol:he.endCol,startRow:be,endRow:be},te=zu(I,ze);await Pa(te)==="failed"?gt.current("error",kt.current("clipboard.copyFailed")):gt.current("success",kt.current("clipboard.copied"))},[]),Dt=x.useCallback(async()=>{const I=f.current;if(!I)return;const W=A0(I);await Pa(W)==="failed"?gt.current("error",kt.current("clipboard.copyFailed")):gt.current("success",kt.current("clipboard.copied"))},[]),Qt=x.useCallback(async()=>{var W,be;const I=f.current;if(I){if(!We.current){qt.current();return}try{const he=await M0();if(he.ok){await Nn.current(he.blob);return}}catch{}try{const he=await k0();if(he.ok){(W=Pe.current)==null||W.reset("paste"),(be=Ct.current)==null||be.clear(),I.paste(he.text),gt.current("success",kt.current("clipboard.pasted"));return}else if(he.reason==="empty"){gt.current("info",kt.current("clipboard.pasteUnavailable"));return}}catch{}Il(!0)}},[]),L=x.useCallback(I=>{var be,he;const W=f.current;if(W){if(!We.current){qt.current();return}(be=Pe.current)==null||be.reset("paste"),(he=Ct.current)==null||he.clear(),W.paste(I),gt.current("success",kt.current("clipboard.pasted"))}},[]),U=x.useCallback(I=>{if(f.current){if(!We.current){qt.current();return}Nn.current(I)}},[]);x.useEffect(()=>Ke(W=>{var he,ze;const be=f.current;be&&((he=Pe.current)==null||he.reset("paste"),(ze=Ct.current)==null||ze.clear(),be.paste(W),gt.current("success",kt.current("clipboard.pasted")))}),[Ke]);const ie=x.useCallback((I,W)=>{!Number.isFinite(I)||!Number.isFinite(W)||I<=0||W<=0||I===m.current.cols&&W===m.current.rows||(b.current={cols:I,rows:W},!v.current&&(v.current=setTimeout(()=>{v.current=null;const be=b.current;b.current=null,be&&(be.cols===m.current.cols&&be.rows===m.current.rows||(m.current=be,Tn.current(be.cols,be.rows),ot.current("resize")))},RS)))},[]),Te=x.useCallback((I=!1)=>{var pl;const W=f.current,be=i.current,he=d.current,ze=o.current;if(!W||!be||!he||!ze)return;const te=ju(be,Ui(),Nu());if(te.width<=0||te.height<=0)return;ze.style.width="100%",ze.style.height="100%",he.style.width="100%",he.style.height="100%",he.style.transform="none",he.style.transformOrigin="top left",p.current=1;const Nt=mp(te),it=w0({lastSnapshot:E.current,currentSnapshot:Nt});if(it.isVisualZoom&&!I){E.current=Nt;try{W.refresh(0,Math.max(0,W.rows-1))}catch{}return}if(it.shouldIgnore&&!I)return;E.current=Nt;const Ft=Wa(W,Ki),At=dp({width:te.width-d0(he),height:te.height,cellWidth:Ft.cellWidth,cellHeight:Ft.cellHeight}),kn=Math.abs(te.width-A.current.width)>1||Math.abs(te.height-A.current.height)>1;if(W.cols!==At.cols||W.rows!==At.rows)try{W.resize(At.cols,At.rows)}catch(Jl){console.debug("Error resizing terminal grid:",Jl)}_.current&&!P.current&&(kn||W.cols!==At.cols||W.rows!==At.rows)&&(P.current=!0,(pl=T.current)==null||pl.verify());const ll=At.cols!==m.current.cols||At.rows!==m.current.rows;Hn.current&&(kn||I||ll)&&(A.current={width:te.width,height:te.height},ie(At.cols,At.rows));try{W.refresh(0,Math.max(0,W.rows-1))}catch{}},[ie]),Ce=x.useRef(Te);Ce.current=Te;const Ee=x.useCallback(()=>{if(y.current===null){if(typeof requestAnimationFrame!="function"){Ce.current();return}y.current=requestAnimationFrame(()=>{y.current=null,Ce.current()})}},[]),Oe=x.useCallback((I=30)=>{S.current!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(S.current),S.current=null);let W=0;const be=()=>{S.current=null,W++;const he=W>=I;Ce.current(!0),!he&&W<2&&typeof requestAnimationFrame=="function"&&(S.current=requestAnimationFrame(be))};typeof requestAnimationFrame=="function"?S.current=requestAnimationFrame(be):be()},[]);x.useEffect(()=>{var Rl,jl;if(!i.current||!d.current)return;const I=i.current,W=ju(I,Ui(),Nu()),be=Wa(null,Ki),he=dp({width:W.width,height:W.height,cellWidth:be.cellWidth,cellHeight:be.cellHeight});Tn.current(he.cols,he.rows),A.current={width:W.width,height:W.height},E.current=mp(W);const ze=Xm(fe.fontSize,W.width),te=new Px.Terminal({fontSize:ze,fontFamily:Pm(fe.fontFamily),lineHeight:1.15,...Je.current?{theme:{...Je.current}}:{},allowProposedApi:!0,convertEol:!0,scrollback:5e3,cols:he.cols,rows:he.rows,screenReaderMode:!1,linkHandler:{activate:(Z,ne)=>{Ou(ne)}}});try{const Z=new $x.Unicode11Addon;te.loadAddon(Z),te.unicode.activeVersion="11"}catch(Z){console.debug("Unicode11 addon unavailable, using default width table:",Z)}try{te.loadAddon(new t0.WebLinksAddon((Z,ne)=>{Ou(ne)}))}catch(Z){console.debug("WebLinks addon unavailable, URLs stay plain text:",Z)}te.open(d.current),f.current=te;const Nt=te.onTitleChange(Z=>{bt(Fu(Z)||null)}),it=AS(te),Ft=new wS({getScreen:()=>{const Z=f.current;if(!Z)return null;const ne=Z.buffer.active;return{cols:Z.cols,rows:Z.rows,baseY:ne.baseY,getLine:Me=>ne.getLine(Me),getNullCell:typeof ne.getNullCell=="function"?()=>ne.getNullCell():void 0}},getCursor:()=>{var ne;const Z=(ne=f.current)==null?void 0:ne.buffer.active;return Z?{row:Z.baseY+Z.cursorY,col:Z.cursorX,hidden:it.isCursorHidden()}:null},isSynchronizing:it.isSynchronizing});ae.current=Ft;const At=new P0({getTerminal:()=>f.current,getField:Ft.detect});Pe.current=At;const kn=new nS({getTerminal:()=>f.current,getStyle:()=>{var mt,Wt,Mn,un,dn,ta,en,gl,_a,na,$r,ti,ni;const Z=((mt=Je.current)==null?void 0:mt.foreground)??((Mn=(Wt=f.current)==null?void 0:Wt.options.theme)==null?void 0:Mn.foreground),ne=((un=Je.current)==null?void 0:un.background)??((ta=(dn=f.current)==null?void 0:dn.options.theme)==null?void 0:ta.background),Me=((en=Pe.current)==null?void 0:en.getEchoSrttMs())??null,ht=Me!==null&&Me>jg,Et=((gl=Je.current)==null?void 0:gl.cursor)??((na=(_a=f.current)==null?void 0:_a.options.theme)==null?void 0:na.cursor)??Z,cn=($r=f.current)==null?void 0:$r.options.cursorStyle,ye=(ti=f.current)==null?void 0:ti.options.fontFamily,Rt=(ni=f.current)==null?void 0:ni.options.fontSize;return{color:Z,background:ne,underline:ht,cursor:Et,cursorShape:cn,fontFamily:ye,fontSize:Rt}}});Ct.current=kn;const ll=()=>{const Z=Pe.current,ne=Ct.current;if(!Z||!ne)return;const Me=$n.current.predictiveEcho,ht=Z.getEchoSrttMs();if(!Np(Me,ht)){ne.clear();return}ne.sync(Z.getOverlayItems())};Le.current=ll,R&&te.textarea&&(te.textarea.readOnly=!1,te.textarea.tabIndex=0,te.textarea.inputMode="text");let pl=()=>{};if(z&&te.textarea){const Z=()=>{Q(ne=>({...ne,focused:document.activeElement===te.textarea}))};te.textarea.addEventListener("focus",Z),te.textarea.addEventListener("blur",Z),pl=()=>{var ne,Me;(ne=te.textarea)==null||ne.removeEventListener("focus",Z),(Me=te.textarea)==null||Me.removeEventListener("blur",Z)},Z()}const Jl=async Z=>{var Me,ht;(Me=Pe.current)==null||Me.reset("paste"),(ht=Ct.current)==null||ht.clear();const ne=Eg(Z);if(ne){if(Z.preventDefault(),Z.stopPropagation(),!We.current){qt.current();return}await Nn.current(ne)}};(Rl=te.textarea)==null||Rl.addEventListener("paste",Jl),I.addEventListener("paste",Jl);const Jt=S0(te,{onRendererSwapped:Z=>{I&&(I.dataset.renderer=Z),ee(Z);try{te.refresh(0,Math.max(0,te.rows-1))}catch{}}});T.current=Jt,I&&(I.dataset.renderer=Jt.kind),ee(Jt.kind);const Fi=kt.current("terminal.bannerTitle"),Ir=kt.current("terminal.bannerSubtitle");if(te.writeln(" ___ ___ .___ "),te.writeln(` / | \\ ____ _______| _/______ \x1B[1m${Fi}\x1B[0m`),te.writeln(`/ ~ \\/ __ \\\\_ __ \\ __/ ___/ \x1B[2m${Ir}\x1B[0m`),te.writeln("\\ Y / ___/ | | \\/|_ \\___ \\ "),te.writeln(" \\___|_ / \\___ >|__| /___/____ >"),te.writeln(" \\/ \\/ \\/ "),te.writeln(""),_.current=!0,Jt.verify(),!R)try{te.focus()}catch{}typeof document<"u"&&"fonts"in document&&typeof((jl=document.fonts)==null?void 0:jl.load)=="function"&&document.fonts.load('13px "Symbols Nerd Font Mono"').then(()=>{if(f.current){try{f.current.refresh(0,Math.max(0,f.current.rows-1))}catch{}Oe(5)}}).catch(()=>{});const Xi=te.onData(Z=>{var ht;let ne=Z;if(We.current&&wg(Z)==="keys"&&Py(Z)){const Et=Ae.current();Et&&(ne=Up(Z,Et))}const Me=Iu(ne);if(!We.current&&!mo(Me)){qt.current();return}(ht=Pe.current)==null||ht.handleUserInput(Me),ll(),wt.current(Me)}),Wl=te.onBinary(Z=>{const ne=new Uint8Array(Z.length);for(let Me=0;Me<Z.length;Me++)ne[Me]=Z.charCodeAt(Me)&255;!We.current&&!mo(ne)||wt.current(ne)}),Zr=typeof te.onWriteParsed=="function"?te.onWriteParsed(()=>{var Z;mn.current=!0,Ft.invalidate(),!it.isSynchronizing()&&((Z=Pe.current)==null||Z.onServerOutput(),ll())}):{dispose:()=>{}},Qr=typeof te.onRender=="function"?te.onRender(Z=>{var ht;(ht=Ct.current)==null||ht.afterRender();const ne=te.buffer.active.viewportY??0;fl(ne);const Me=Tt.current;if(Me&&Cl.current){const Et=Me.startRow-ne,cn=Me.endRow-ne;mn.current&&Z.start<=cn&&Z.end>=Et&&(Zt(!1),mn.current=!1)}else mn.current=!1}):{dispose:()=>{}},Pl=typeof te.onScroll=="function"?te.onScroll(()=>{var ne,Me;const Z=te.buffer.active.viewportY??0;fl(Z),(ne=Pe.current)==null||ne.reset("scroll"),(Me=Ct.current)==null||Me.clear()}):{dispose:()=>{}},pn=new h0({getTerminal:()=>f.current,getIsController:()=>We.current,getScale:()=>p.current,getSurfaceElement:()=>d.current,allowSyntheticMouseFallback:!1,onFocus:()=>{try{te.focus()}catch{}z&&Q(Z=>({...Z,focused:document.activeElement===te.textarea})),r==null||r()},onGestureStateChange:Z=>{z&&Q(ne=>({...ne,state:Z}))},onGestureScroll:({deltaY:Z,lines:ne,viewportY:Me,scrollTop:ht,scrollHeight:Et,clientHeight:cn,moved:ye,bufferType:Rt,baseY:mt,cursorY:Wt,hasScrollback:Mn,mouseTracking:un,scrollMode:dn})=>{z&&Q(ta=>({...ta,deltaY:Z,lines:ne,viewportY:Me,scrollTop:ht,scrollHeight:Et,clientHeight:cn,moved:ye,focused:document.activeElement===te.textarea,bufferType:Rt,baseY:mt,cursorY:Wt,hasScrollback:Mn,mouseTracking:un,scrollMode:dn,scrollCalls:ta.scrollCalls+(ne!==0?1:0),lastScrollLines:ne}))},longPressDelayMs:500,dragThresholdPx:8,scrollLineHeightPx:18,onLongPress:R?(Z=>{var ne;return(ne=hl.current)==null?void 0:ne.call(hl,Z)}):void 0,onSelectionExtend:R?(Z=>{var ne;return(ne=Nl.current)==null?void 0:ne.call(Nl,Z)}):void 0}),Jr=typeof window<"u"&&"PointerEvent"in window,Wr=typeof TouchEvent<"u",El=[],al=(Z,ne=!1)=>{const Me=Z.target;return Me instanceof Node&&I.contains(Me)||ne&&pn.getState()!=="idle"};if(Jr){const Z={passive:!1,capture:!0},ne=ye=>{z&&Q(Rt=>({...Rt,pointerEvents:Rt.pointerEvents+1,lastInputEvent:ye}))},Me=ye=>{if(!al(ye))return;if(ne("pointerdown"),Ut.current){Vt(null),Ut.current=null,nt(null),Tt.current=null,An(""),el.current="",Zt(!1),tl.current=null,En.current=null,ye.cancelable&&ye.preventDefault(),ye.stopPropagation();return}pn.handlePointerDown(ye,I)&&ye.stopPropagation()},ht=ye=>{al(ye,!0)&&(ne("pointermove"),pn.handlePointerMove(ye),ye.pointerType!=="mouse"&&ye.stopPropagation())},Et=ye=>{if(!al(ye,!0))return;if(ne("pointerup"),pn.getState()==="longpress"&&zt.current){const mt=En.current??tl.current;if(mt){const Wt=zt.current.getBoundingClientRect(),Mn=mt.clientX-Wt.left,un=mt.clientY-Wt.top,dn=nl(mt);Vt({x:Mn,y:un,link:dn}),Ut.current={x:Mn,y:un,link:dn}}}pn.handlePointerUp(ye),ye.pointerType!=="mouse"&&ye.stopPropagation()},cn=ye=>{al(ye,!0)&&(ne("pointercancel"),Vt(null),Ut.current=null,nt(null),Tt.current=null,An(""),el.current="",Zt(!1),tl.current=null,En.current=null,pn.handlePointerCancel(ye),ye.pointerType!=="mouse"&&ye.stopPropagation())};if(document.addEventListener("pointerdown",Me,Z),document.addEventListener("pointermove",ht,Z),document.addEventListener("pointerup",Et,Z),document.addEventListener("pointercancel",cn,Z),El.push(()=>{document.removeEventListener("pointerdown",Me,Z),document.removeEventListener("pointermove",ht,Z),document.removeEventListener("pointerup",Et,Z),document.removeEventListener("pointercancel",cn,Z)}),Wr){const ye=mt=>{al(mt,!0)&&(z&&Q(Wt=>({...Wt,touchEvents:Wt.touchEvents+1})),mt.cancelable&&mt.preventDefault(),mt.stopPropagation())},Rt=["touchstart","touchmove","touchend","touchcancel"];for(const mt of Rt)document.addEventListener(mt,ye,Z);El.push(()=>{for(const mt of Rt)document.removeEventListener(mt,ye,Z)})}}else{const Z={passive:!1,capture:!0},ne=ye=>{z&&Q(Rt=>({...Rt,touchEvents:Rt.touchEvents+1,lastInputEvent:ye}))},Me=ye=>{if(al(ye)){if(ne("touchstart"),Ut.current){Vt(null),Ut.current=null,nt(null),Tt.current=null,An(""),el.current="",Zt(!1),tl.current=null,En.current=null,ye.cancelable&&ye.preventDefault(),ye.stopPropagation();return}ye.touches.length===1&&ye.stopPropagation(),pn.handleTouchStart(ye,I)}},ht=ye=>{al(ye,!0)&&(ne("touchmove"),ye.touches.length===1&&ye.stopPropagation(),pn.handleTouchMove(ye))},Et=ye=>{if(!al(ye,!0))return;if(ne("touchend"),pn.getState()==="longpress"&&zt.current){const mt=En.current??tl.current;if(mt){const Wt=zt.current.getBoundingClientRect(),Mn=mt.clientX-Wt.left,un=mt.clientY-Wt.top,dn=nl(mt);Vt({x:Mn,y:un,link:dn}),Ut.current={x:Mn,y:un,link:dn}}}ye.stopPropagation(),pn.handleTouchEnd(ye)},cn=ye=>{al(ye,!0)&&(ne("touchcancel"),Vt(null),Ut.current=null,nt(null),Tt.current=null,An(""),el.current="",Zt(!1),tl.current=null,En.current=null,ye.stopPropagation(),pn.handleTouchCancel())};document.addEventListener("touchstart",Me,Z),document.addEventListener("touchmove",ht,Z),document.addEventListener("touchend",Et,Z),document.addEventListener("touchcancel",cn,Z),El.push(()=>{document.removeEventListener("touchstart",Me,Z),document.removeEventListener("touchmove",ht,Z),document.removeEventListener("touchend",Et,Z),document.removeEventListener("touchcancel",cn,Z)})}const Pr=Z=>{Z.preventDefault()};I.addEventListener("contextmenu",Pr),El.push(()=>{I.removeEventListener("contextmenu",Pr)});const Ma=new ResizeObserver(()=>{Ee()});Ma.observe(I);const gn=()=>{Ee()},$l=()=>{var Z,ne;if(document.visibilityState==="visible"){Oe(10);try{(ne=f.current)==null||ne.refresh(0,Math.max(0,(((Z=f.current)==null?void 0:Z.rows)||1)-1))}catch{}}};window.addEventListener("resize",gn),window.addEventListener("orientationchange",gn),document.addEventListener("visibilitychange",$l),window.addEventListener("pageshow",$l);const ea=()=>{Ee()};return typeof window<"u"&&window.visualViewport&&(window.visualViewport.addEventListener("resize",ea),window.visualViewport.addEventListener("scroll",ea)),()=>{var Z,ne;Xi.dispose(),Wl.dispose(),Qr.dispose(),Pl.dispose(),Zr.dispose(),Nt.dispose(),(Z=Ct.current)==null||Z.dispose(),Ct.current=null,Pe.current=null,ae.current=null,Le.current=()=>{},it.dispose(),pn.handlePointerCancel();for(const Me of El)Me();Ma.disconnect(),window.removeEventListener("resize",gn),window.removeEventListener("orientationchange",gn),document.removeEventListener("visibilitychange",$l),window.removeEventListener("pageshow",$l),typeof window<"u"&&window.visualViewport&&(window.visualViewport.removeEventListener("resize",ea),window.visualViewport.removeEventListener("scroll",ea)),v.current&&(clearTimeout(v.current),v.current=null),y.current!==null&&(cancelAnimationFrame(y.current),y.current=null),S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),pl(),(ne=te.textarea)==null||ne.removeEventListener("paste",Jl),I.removeEventListener("paste",Jl),Jt.dispose(),T.current=null,te.dispose(),f.current=null}},[]);const Bt=dl.useMemo(()=>{var I;return((I=$t.find(W=>W.id===tt))==null?void 0:I.displayName)??null},[$t,tt]);x.useEffect(()=>{Se!=="connected"&&bt(null)},[Se]),x.useEffect(()=>{const I=a&&Se==="connected",W=fe.agentAlertBadge?Fr(V):null;L0(I?sn:null,Bt,W)},[a,Se,sn,Bt,V,fe.agentAlertBadge]),x.useEffect(()=>{const I=f.current;if(!I)return;const W=ju(i.current,Ui(),Nu());I.options.fontSize=Xm(fe.fontSize,W.width),I.options.fontFamily=Pm(fe.fontFamily);try{I.refresh(0,Math.max(0,I.rows-1))}catch{}Oe(10)},[fe.fontSize,fe.fontFamily]),x.useEffect(()=>J(I=>{var W;(W=Pe.current)==null||W.handleUserInput(I),Le.current()}),[J]),x.useEffect(()=>{const I=Pe.current,W=Ct.current;if(!I||!W)return;const be=I.getEchoSrttMs();Np(fe.predictiveEcho,be)?W.sync(I.getOverlayItems()):W.clear()},[fe.predictiveEcho]);const ft=x.useRef(Ge);x.useEffect(()=>{var W;if(ft.current===Ge)return;ft.current=Ge,ot.current("resetVersion");const I=f.current;if(I)try{(W=I.reset)==null||W.call(I),I.clear(),I.refresh(0,Math.max(0,I.rows-1))}catch{}},[Ge]),x.useEffect(()=>{ot.current("connectionState")},[Se]),x.useEffect(()=>{const I=f.current;if(!(!I||!qe)){I.options.theme={...qe};try{I.refresh(0,Math.max(0,I.rows-1))}catch{}}},[qe]),x.useEffect(()=>Ye(W=>{const be=f.current;if(!be)throw new Error("terminal not ready");if(be.write(W),z){const he=performance.now(),ze=le.current;ze.push({time:he,bytes:W.byteLength});const te=he-1e3;for(;ze.length>0&&ze[0].time<te;)ze.shift()}}),[Ye,z]),x.useEffect(()=>{if(!a)return;Oe(10);const I=f.current;if(I){try{I.refresh(0,Math.max(0,I.rows-1))}catch{}if(!R)try{I.focus()}catch{}}},[a,R,Oe]),x.useEffect(()=>{Se==="disconnected"&&ke()},[]);const jn=I=>{I.preventDefault()};return u.jsxs("main",{ref:zt,className:"flex-1 w-full min-w-0 min-h-0 overflow-hidden relative flex flex-col",onContextMenu:jn,"aria-label":we("terminal.windowAriaLabel"),children:[u.jsx("div",{id:"terminal-container",ref:i,className:"absolute inset-0 overflow-hidden cursor-text",style:{touchAction:H?"none":"auto"},tabIndex:0,onContextMenu:jn,"aria-label":we("terminal.bufferAriaLabel"),role:"region",children:u.jsx("div",{id:"terminal-frame",ref:o,className:"relative overflow-hidden",style:{width:"100%",height:"100%"},children:u.jsx("div",{id:"terminal-surface",ref:d,className:"absolute top-0 left-0",style:{transformOrigin:"top left",width:"100%",height:"100%"}})})}),z&&u.jsxs("pre",{"data-testid":"terminal-touch-debug",className:"pointer-events-none absolute left-1 top-1 z-50 border border-tui-border bg-tui-crust/90 px-2 py-1 font-mono text-tui-sm leading-relaxed text-tui-muted","aria-hidden":"true",children:[`gesture: ${G.state}
37
+ `,`deltaY: ${G.deltaY} lines: ${G.lines}
38
+ `,`viewportY: ${G.viewportY??"-"} focus: ${G.focused}
39
+ `,`buffer: ${G.bufferType??"-"} base: ${G.baseY??"-"} cursor: ${G.cursorY??"-"} scrollback: ${G.hasScrollback??"-"}
40
+ `,`scroll: ${G.scrollTop??"-"} / ${G.scrollHeight??"-"} (h ${G.clientHeight??"-"}) moved: ${G.moved}
41
+ `,`mode: ${G.scrollMode} calls: ${G.scrollCalls} lines: ${G.lastScrollLines??"-"} mouse: ${G.mouseTracking}
42
+ `,`event: ${G.lastInputEvent||"-"} pointer: ${G.pointerEvents} touch: ${G.touchEvents}
43
+ `,`rtt: ${hn!==null?`${hn}ms`:"-"} frames/s: ${X.framesPerSec} bytes/s: ${X.bytesPerSec} renderer: ${de??"-"}
44
+ `,`prediction: ${((on=Pe.current)==null?void 0:on.getState())??"-"} mode: ${fe.predictiveEcho} pending: ${((at=Pe.current)==null?void 0:at.getVisiblePredictions().length)??0} srtt: ${((ka=Pe.current)==null?void 0:ka.getEchoSrttMs())!==null&&((Vi=Pe.current)==null?void 0:Vi.getEchoSrttMs())!==void 0?`${Math.round(Pe.current.getEchoSrttMs())}ms`:"-"}
45
+ `,`field: ${ES(((ml=ae.current)==null?void 0:ml.detect())??null)} mismatches: ${((Al=Pe.current)==null?void 0:Al.getMismatchCount())??0}`]}),R&&yt&&wl&&(()=>{var ll;const I=f.current;if(!I||!zt.current)return null;const W=Wa(I);if(W.cellWidth<=0||W.cellHeight<=0)return null;const be=((ll=d.current)==null?void 0:ll.querySelector(".xterm-screen"))||d.current;if(!be)return null;const he=be.getBoundingClientRect(),ze=zt.current.getBoundingClientRect(),te=yt.startRow-Tl;if(yt.endRow-Tl<0||te>=I.rows)return null;const it=he.top-ze.top+te*W.cellHeight,Ft=he.left-ze.left+yt.startCol*W.cellWidth,At=(yt.endCol-yt.startCol+1)*W.cellWidth,kn=(yt.endRow-yt.startRow+1)*W.cellHeight;return u.jsx("div",{"data-testid":"terminal-selection-overlay",className:"pointer-events-none absolute z-20 bg-tui-accent/35",style:{top:`${it}px`,left:`${Ft}px`,width:`${At}px`,height:`${kn}px`}})})(),R&&Yn&&u.jsx(q0,{anchorPoint:Yn,hasSelection:!!ei,isController:ve,vibrateOnKeyPress:fe.vibrateOnKeyPress,linkUrl:Yn.link??null,onOpenLink:I=>{Ou(I)||je("warning",we("clipboard.openLinkFailed"))},onCopySelection:Ql,onCopyLine:Gn,onCopyScreen:Dt,onPaste:Qt,onClose:()=>{Vt(null),Ut.current=null,nt(null),Tt.current=null,An(""),el.current="",Zt(!1)}}),R&&u.jsx(V0,{isOpen:qi,onClose:()=>Il(!1),onSend:L,onSendImage:U})]})},kS=({onPairedSuccess:r})=>{const{settings:a,updateSettings:i,connect:o,connectionState:d,stateDetail:f,addToast:p,t:m}=St(),[b,v]=x.useState(""),[y,S]=x.useState(null),[A,E]=x.useState(!1),[R,H]=x.useState(a.wsUrl||"/ws/client"),[z,G]=x.useState(a.token||""),[Q,X]=x.useState(a.clientId||""),re="node bin/service.js pair",de="node bin/config-tui.js",ee="herdr plugin pane open --plugin herdr.remote.web --entrypoint config --placement zoomed --focus",T=ve=>{Pa(ve).then(Se=>{if(Se==="failed"){p("error",m("clipboard.copyFailed"));return}S(ve),p("success",m("toasts.commandCopied")),setTimeout(()=>S(null),2e3)})},_=ve=>{ve.preventDefault();const Se=b.trim().toUpperCase();if(!Se&&!z.trim()){p("warning",m("toasts.connectionError"));return}const fe={pairCode:Se,wsUrl:R.trim()||"/ws/client",clientId:Q.trim()||a.clientId};z.trim()&&(fe.token=z.trim()),i(fe),o({pairCode:Se||void 0,token:z.trim()||void 0,wsUrl:R.trim()||"/ws/client",clientId:Q.trim()||a.clientId}),r&&r()},P=d==="connecting"||d==="reconnecting",le=({n:ve})=>u.jsxs("span",{"aria-hidden":"true",className:"shrink-0 font-bold text-tui-accent",children:["[",ve,"]"]});return u.jsx("div",{className:"flex h-full w-full flex-1 justify-center overflow-y-auto bg-tui-crust p-2 sm:p-4",children:u.jsxs("div",{className:"my-auto w-full max-w-3xl space-y-3",children:[u.jsxs("div",{className:"border border-tui-border bg-tui-base px-3 py-2",children:[u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[u.jsx("span",{"aria-hidden":"true",className:"font-bold text-tui-accent",children:"herdr-remote"}),u.jsx("h1",{className:"text-tui font-bold text-tui-text",children:m("onboarding.title")}),u.jsx("span",{className:"text-tui uppercase text-tui-warn",children:m("onboarding.firstTimeSetup")})]}),u.jsx("p",{className:"mt-0.5 text-tui leading-snug text-tui-muted",children:m("onboarding.description")})]}),d==="error"&&u.jsxs(fo,{tone:"warn",action:u.jsx(Ue,{variant:"warn",onClick:()=>o(),children:m("common.retry")}),children:[u.jsx("span",{className:"block font-bold",children:m("onboarding.authRequired")}),u.jsx("span",{className:"block text-tui-muted",children:f||m("onboarding.authRequiredDesc")})]}),u.jsxs("form",{onSubmit:_,className:"grid gap-3",children:[u.jsx(rn,{title:m("onboarding.step1Title"),className:"min-w-0",children:u.jsxs("div",{className:"space-y-2",children:[u.jsxs("p",{className:"flex items-start gap-2 text-tui text-tui-muted",children:[u.jsx(le,{n:1}),u.jsx("span",{className:"leading-snug",children:m("onboarding.step1Desc")})]}),u.jsxs("div",{className:"flex items-center gap-2 border border-tui-border bg-tui-mantle px-2 py-1",children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none text-tui-ok",children:"$"}),u.jsx("code",{className:"min-w-0 flex-1 truncate text-tui text-tui-text",children:re}),u.jsx(Ue,{onClick:()=>T(re),glyph:y===re?He.check:"⧉",className:$("shrink-0",y===re&&"border-tui-ok text-tui-ok"),children:m(y===re?"common.copied":"common.copy")})]}),u.jsxs("div",{className:"space-y-0.5 text-tui-sm",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("span",{className:"truncate text-tui-faint",children:m("onboarding.step1CopyPlugin")}),u.jsx("button",{type:"button",onClick:()=>T(ee),className:"tui-focusable shrink-0 text-tui-accent underline-offset-2 hover:underline",children:m(y===ee?"common.copied":"onboarding.step1CopyCli")})]}),u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("span",{className:"truncate text-tui-faint",children:m("onboarding.step1TuiNote")}),u.jsx("code",{onClick:()=>T(de),className:"shrink-0 cursor-pointer border border-tui-border-dim px-1 text-tui-muted hover:border-tui-accent hover:text-tui-accent",title:m("common.clickToCopy"),children:de})]})]})]})}),u.jsx(rn,{title:m("onboarding.step2Title"),className:"min-w-0",children:u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le,{n:2}),u.jsx(Pn,{type:"text",value:b,onChange:ve=>v(ve.target.value.toUpperCase()),placeholder:m("onboarding.step2Placeholder"),maxLength:12,autoFocus:!0,"aria-label":m("onboarding.step2Title"),className:"font-bold uppercase"})]}),u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("onboarding.step2Note")})]})}),u.jsx(Ue,{variant:"primary",type:"submit",block:!0,disabled:P,className:"py-1.5",children:P?u.jsx(Yi,{label:m("onboarding.connectingAndPairing")}):m("onboarding.connectAndPair")}),u.jsxs("div",{className:"border border-tui-border bg-tui-base",children:[u.jsxs("button",{type:"button",onClick:()=>E(!A),"aria-expanded":A,className:"tui-focusable flex w-full items-center gap-2 px-2 py-1 text-left text-tui text-tui-muted transition-colors hover:text-tui-accent",children:[u.jsx("span",{"aria-hidden":"true",className:"text-tui-accent",children:A?He.chevronDown:He.chevronRight}),u.jsx("span",{className:"uppercase",children:m("onboarding.advancedTitle")})]}),A&&u.jsxs("div",{className:"space-y-2.5 border-t border-tui-border-dim px-2 py-2",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"onboarding-token",children:m("onboarding.manualTokenLabel")}),u.jsx(Pn,{id:"onboarding-token",type:"password",value:z,onChange:ve=>G(ve.target.value),placeholder:m("onboarding.manualTokenPlaceholder")})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"onboarding-ws",children:m("onboarding.wsEndpointLabel")}),u.jsx(Pn,{id:"onboarding-ws",type:"text",value:R,onChange:ve=>H(ve.target.value),placeholder:m("onboarding.wsEndpointPlaceholder")})]}),u.jsx(Ea,{}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"onboarding-client-id",children:m("onboarding.clientIdLabel")}),u.jsx(Pn,{id:"onboarding-client-id",type:"text",value:Q,onChange:ve=>X(ve.target.value)})]})]})]})]})]})})},Oi="tui-focusable inline-flex shrink-0 select-none items-center justify-center border text-tui font-medium transition-colors",Or="border-tui-border bg-tui-surface text-tui-text hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",MS="border-tui-accent bg-tui-accent text-tui-crust font-bold",_S="border-tui-ok bg-transparent text-tui-ok hover:bg-tui-ok hover:text-tui-crust font-bold",zS=({compact:r=!1})=>{const{sendKey:a,settings:i,updateSettings:o,isController:d,warnViewerMode:f,t:p,uploadProgress:m,uploadImage:b,modifierLatch:v,toggleModifierLatch:y,consumeModifierLatch:S}=St(),A="h-9 min-w-[2.25rem] px-2",E="h-9 w-9",R="h-9 px-2",H=x.useRef(null),z=x.useRef(null),G=x.useCallback(()=>{if(i.vibrateOnKeyPress&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(8)}catch{}},[i.vibrateOnKeyPress]),Q=x.useCallback(()=>{var q;if(G(),!d){f();return}m.active||(q=H.current)==null||q.click()},[G,d,f,m.active]),X=x.useCallback(q=>{const V=q.target.files,je=V&&V[0];q.target.value="",je&&b(je)},[b]),re=()=>u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:H,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",className:"hidden","data-testid":"key-toolbar-file-input",onChange:X}),u.jsx("input",{ref:z,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",capture:"environment",className:"hidden","data-testid":"key-toolbar-camera-input",onChange:X})]}),de=(q=!1)=>m.active?u.jsx("div",{"data-testid":q?"key-toolbar-progress-collapsed":"key-toolbar-progress",className:"w-full border-b border-tui-border-dim bg-tui-crust px-2 py-1",children:u.jsx(Xx,{ratio:m.ratio,label:m.statusText,tone:m.phase==="completed"?"ok":m.phase==="error"?"bad":"accent","aria-label":m.statusText})}):null,ee=()=>{const q=m.active;return u.jsx("button",{type:"button","data-testid":"image-upload-btn",onClick:Q,disabled:q,className:$(Oi,A,q?"border-tui-border-dim bg-tui-surface opacity-60 cursor-not-allowed":Or),title:q?m.statusText:p("virtualKeyboard.uploadImageTitle"),"aria-label":p("virtualKeyboard.uploadImage"),children:u.jsx("span",{className:"font-medium",children:q?`${m.percent}%`:p("virtualKeyboard.image")})})},[T,_]=x.useState(!1),[P,le]=x.useState(!1),[ve,Se]=x.useState(!1),fe=x.useCallback((q,V=!0)=>{if(G(),!d){f();return}const je=S();a(V&&je?Up(q,je):q)},[d,a,f,G,S]);if(!i.toolbarVisible)return u.jsxs("div",{"data-testid":"key-toolbar-collapsed",className:"z-20 flex shrink-0 flex-col border-t border-tui-border bg-tui-mantle pb-[max(env(safe-area-inset-bottom,0px),0.125rem)]",children:[re(),de(!0),u.jsx("div",{className:"flex items-center justify-center px-2 py-0.5",children:u.jsxs("button",{type:"button",onClick:()=>o({toolbarVisible:!0}),className:"tui-focusable flex h-6 w-28 items-center justify-center gap-1 text-tui uppercase text-tui-faint transition-colors hover:text-tui-accent",title:p("virtualKeyboard.expandToolbar"),"aria-label":p("virtualKeyboard.expandToolbar"),"aria-expanded":!1,children:[u.jsx("span",{"aria-hidden":"true",children:"▴"}),u.jsx("span",{"aria-hidden":"true",children:p("common.keyBar")})]})})]});const Re=i.virtualKeys&&i.virtualKeys.length>0?i.virtualKeys.filter(q=>q.enabled):qp,Ge=q=>q.id==="left"?u.jsx("span",{"aria-hidden":"true",children:"←"}):q.id==="up"?u.jsx("span",{"aria-hidden":"true",children:"↑"}):q.id==="down"?u.jsx("span",{"aria-hidden":"true",children:"↓"}):q.id==="right"?u.jsx("span",{"aria-hidden":"true",children:"→"}):q.id==="enter"?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",children:"⏎"}),u.jsx("span",{className:"hidden sm:inline",children:p("virtualKeyboard.keyEnter")})]}):q.id==="drawer_chords"?u.jsx("span",{children:"^C"}):q.id==="drawer_fn"?u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx("span",{children:"Fn"}),u.jsx("span",{"aria-hidden":"true",children:T?"▾":"▴"})]}):u.jsx("span",{children:q.label}),D=q=>{if(G(),q.type==="modifier"){q.modifierType==="ctrl"||q.modifierType==="alt"||q.modifierType==="shift"?y(q.modifierType):q.modifierType==="meta"&&fe(ge.ESC);return}if(q.type==="drawer"){q.drawerType==="fn"?(_(!T),le(!1),Se(!1)):q.drawerType==="chords"?(Se(!ve),_(!1),le(!1)):q.drawerType==="symbols"&&(le(!P),_(!1),Se(!1));return}fe(q.code,q.type!=="chord")},F=q=>{if(q.type==="modifier"){if(q.modifierType==="ctrl")return v.ctrl;if(q.modifierType==="alt")return v.alt;if(q.modifierType==="shift")return v.shift}if(q.type==="drawer"){if(q.drawerType==="fn")return T;if(q.drawerType==="chords")return ve;if(q.drawerType==="symbols")return P}return!1},J=(q,V,je,pe,ke="default")=>u.jsxs("button",{type:"button",onClick:()=>fe(q,!1),className:$(Oi,"h-8 gap-1.5 px-2",ke==="bad"?"border-tui-bad text-tui-bad hover:bg-tui-bad hover:text-tui-crust":ke==="warn"?"border-tui-warn text-tui-warn hover:bg-tui-warn hover:text-tui-crust":Or),title:je,children:[u.jsx("span",{className:"font-bold",children:V}),u.jsx("span",{className:"text-tui-sm opacity-70",children:pe})]});return u.jsxs("div",{"data-testid":"key-toolbar",className:$("z-20 flex shrink-0 select-none flex-col border-t border-tui-border bg-tui-mantle",r?"pb-[max(env(safe-area-inset-bottom,0px),0.125rem)]":"pb-[max(env(safe-area-inset-bottom,0px),0.25rem)]"),role:"toolbar","aria-label":p("virtualKeyboard.touchKeyboardShortcuts"),children:[re(),de(!1),T&&u.jsx("div",{className:"grid grid-cols-6 gap-1 border-b border-tui-border-dim bg-tui-crust p-1.5 sm:grid-cols-12",children:[1,2,3,4,5,6,7,8,9,10,11,12].map(q=>{const V=`F${q}`;return u.jsxs("button",{type:"button",onClick:()=>fe(ge[V]),className:$(Oi,Or,"h-8"),children:["F",q]},V)})}),ve&&u.jsxs("div",{className:"scrollbar-none flex items-center gap-1 overflow-x-auto border-b border-tui-border-dim bg-tui-crust p-1.5",children:[J(ge.CTRL_C,"^C",p("virtualKeyboard.ctrlCTitle"),p("virtualKeyboard.badgeSigint"),"bad"),J(ge.CTRL_D,"^D",p("virtualKeyboard.ctrlDTitle"),p("virtualKeyboard.badgeEof")),J(ge.CTRL_Z,"^Z",p("virtualKeyboard.ctrlZTitle"),p("virtualKeyboard.badgeTstp"),"warn"),J(ge.CTRL_L,"^L",p("virtualKeyboard.ctrlLTitle"),p("virtualKeyboard.badgeClear")),J(ge.CTRL_R,"^R",p("virtualKeyboard.ctrlRTitle"),p("virtualKeyboard.badgeSearch")),J(ge.CTRL_A,"^A",p("virtualKeyboard.ctrlATitle"),p("virtualKeyboard.badgeStart")),J(ge.CTRL_E,"^E",p("virtualKeyboard.ctrlETitle"),p("virtualKeyboard.badgeEnd")),J(ge.CTRL_K,"^K",p("virtualKeyboard.ctrlKTitle"),p("virtualKeyboard.badgeKill"))]}),P&&u.jsx("div",{className:"scrollbar-none flex items-center gap-1 overflow-x-auto border-b border-tui-border-dim bg-tui-crust p-1.5",children:["|","~","/","\\","-","_","$","&",";",":","`",'"',"'",">","<","=","#","@","{","}","[","]"].map(q=>u.jsx("button",{type:"button",onClick:()=>fe(q,!0),className:$(Oi,Or,"h-8 w-8 font-bold"),children:q},q))}),u.jsxs("div",{"data-testid":"key-toolbar-row",className:$("flex flex-wrap items-center justify-center gap-1",r?"px-1.5 py-1":"px-2 py-1.5"),children:[u.jsx("button",{type:"button",onClick:()=>o({toolbarVisible:!1}),className:$(Oi,E,"mr-1 border-tui-border-dim bg-transparent text-tui-faint hover:border-tui-border hover:text-tui-text"),title:p("virtualKeyboard.collapseToolbar"),"aria-label":p("virtualKeyboard.collapseToolbar"),"aria-expanded":!0,children:u.jsx("span",{"aria-hidden":"true",children:"▾"})}),Re.map(q=>{const V=F(q),je=q.id==="enter",pe=["left","up","down","right"].includes(q.id),ke=q.type==="drawer",Ye=Bu(q,p),Ke=u.jsx("button",{type:"button",onClick:()=>D(q),className:$(Oi,pe?E:ke?R:A,je?_S:V?MS:Or),title:Ye,"aria-label":Ye,"aria-pressed":V,children:Ge(q)},q.id);return je?u.jsxs(dl.Fragment,{children:[ee(),Ke]},"enter-with-image"):Ke}),!Re.some(q=>q.id==="enter")&&ee()]})]})},DS=["ls -la","clear","git status","pwd","top","exit","cat"],LS=({isOpen:r,onClose:a})=>{const{sendKey:i,isController:o,warnViewerMode:d,t:f}=St(),[p,m]=x.useState("");if(!r)return null;const b=y=>{if(y&&y.preventDefault(),!o){d();return}p.length>0?(i(p+"\r"),m("")):i("\r")},v=y=>{if(!o){d();return}i(y+"\r")};return u.jsxs("div",{className:"z-20 flex flex-col gap-1.5 border-t border-tui-border bg-tui-mantle p-2",role:"region","aria-label":f("virtualKeyboard.helperTitle"),children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-tui font-bold uppercase text-tui-accent",children:f("virtualKeyboard.helperTitle")}),u.jsx(Ue,{variant:"ghost",onClick:a,"aria-label":f("virtualKeyboard.closeHelper"),children:"esc"})]}),u.jsx("div",{className:"scrollbar-none flex items-center gap-1 overflow-x-auto py-0.5",children:DS.map(y=>u.jsx("button",{type:"button",onClick:()=>v(y),className:"tui-focusable shrink-0 select-none border border-tui-border bg-tui-surface px-2 py-0.5 text-tui-sm text-tui-muted transition-colors hover:border-tui-accent hover:text-tui-accent",children:y},y))}),u.jsxs("form",{onSubmit:b,className:"flex items-center gap-1.5",children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none font-bold text-tui-ok",children:"$"}),u.jsxs("div",{className:"relative flex-1",children:[u.jsx("label",{htmlFor:"virtual-keyboard-input",className:"sr-only",children:f("virtualKeyboard.placeholder")}),u.jsx(Pn,{id:"virtual-keyboard-input",name:"terminal-input",type:"text",value:p,onChange:y=>m(y.target.value),placeholder:f("virtualKeyboard.placeholder"),inputMode:"text",enterKeyHint:"send",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"select-text pr-7"}),p.length>0&&u.jsx("button",{type:"button",onClick:()=>m(""),className:"tui-focusable absolute right-1 top-1/2 -translate-y-1/2 px-1 text-tui-faint hover:text-tui-bad","aria-label":f("virtualKeyboard.clearInput"),children:u.jsx("span",{"aria-hidden":"true",children:He.cross})})]}),u.jsx(Ue,{variant:"primary",type:"submit",title:f("virtualKeyboard.sendButton"),glyph:"⏎",className:"h-9 shrink-0",children:u.jsx("span",{className:"hidden sm:inline",children:f("virtualKeyboard.sendButton")})})]})]})};function wo(r,a){const i=(o,d)=>a?a(o):d;switch(r){case"connected":return{label:i("connection.live","Live"),level:"ok",needsAttention:!1};case"connecting":return{label:i("connection.connecting","Connecting"),level:"warn",needsAttention:!0};case"reconnecting":return{label:i("connection.reconnecting","Reconnecting"),level:"warn",needsAttention:!0,actionLabel:i("connection.reconnectNow","Reconnect now")};case"error":return{label:i("connection.error","Error"),level:"bad",needsAttention:!0,actionLabel:i("connection.retry","Retry")};default:return{label:i("connection.offline","Offline"),level:"idle",needsAttention:!0,actionLabel:i("connection.connect","Connect")}}}const OS={connected:"ok",connecting:"warn",reconnecting:"warn",error:"bad",disconnected:"idle"},US=({isOpen:r,onClose:a,isAddMode:i=!1})=>{const{settings:o,updateSettings:d,connect:f,disconnect:p,connectionState:m,hostId:b,addToast:v,t:y,activeProfile:S,activeProfileId:A,addProfileAndConnect:E,renameProfile:R}=St(),[H,z]=x.useState(o.wsUrl),[G,Q]=x.useState(o.token),[X,re]=x.useState(o.pairCode),[de,ee]=x.useState(o.clientId),[T,_]=x.useState((S==null?void 0:S.displayName)||""),[P,le]=x.useState(o.autoReconnect),[ve,Se]=x.useState(!1);if(x.useEffect(()=>{r&&(z(o.wsUrl),Q(i?"":o.token),re(i?"":o.pairCode),ee(o.clientId),_(i?"":(S==null?void 0:S.displayName)||""),le(o.autoReconnect))},[r,i,o,S]),!r)return null;const fe=F=>{F.preventDefault();const J={wsUrl:H.trim()||"/ws/client",token:G.trim(),pairCode:X.trim().toUpperCase(),clientId:de.trim()||o.clientId,autoReconnect:P};if(!J.token&&!J.pairCode){v("warning",y("pairing.credentialsRequired"));return}i?E({...J,displayName:T.trim()||void 0}):(d(J),A&&T.trim()&&R(A,T),p(),f({wsUrl:J.wsUrl,token:J.token||void 0,pairCode:J.pairCode||void 0,clientId:J.clientId,autoReconnect:P})),a()},Re=()=>{const F=`client-${Math.random().toString(36).substring(2,8)}`;ee(F)},Ge=()=>{const F=new URL(window.location.href);F.search="",X.trim()&&F.searchParams.set("pairCode",X.trim().toUpperCase()),Pa(F.toString()).then(J=>{if(J==="failed"){v("error",y("clipboard.copyFailed"));return}Se(!0),v("success",y("toasts.pairingLinkCopied")),setTimeout(()=>Se(!1),2e3)})},D=OS[m]??"idle";return u.jsxs(ad,{isOpen:r,onClose:a,title:y(i?"pairing.addTitle":"pairing.title"),subtitle:y("pairing.subtitle"),closeLabel:y("common.closeDialog"),hints:[{keys:"esc",action:y("common.close")},{keys:"⏎",action:y("pairing.saveAndConnect")}],footer:u.jsxs(u.Fragment,{children:[m==="connected"&&u.jsx(Ue,{variant:"danger",onClick:()=>{p(),a()},children:y("common.disconnect")}),u.jsx(Ue,{variant:"primary",type:"submit",form:"pairing-form",children:y("pairing.saveAndConnect")})]}),children:[u.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2 border-b border-tui-border-dim pb-2 text-tui",children:[u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Cn,{level:D}),u.jsx("span",{className:"text-tui-muted",children:y("common.status")}),u.jsx("span",{className:$(D==="ok"?"text-tui-ok":D==="bad"?"text-tui-bad":D==="warn"?"text-tui-warn":"text-tui-faint"),children:wo(m,y).label})]}),b&&u.jsxs("span",{className:"flex items-center gap-1.5 text-tui-muted",children:[y("common.host")," ",u.jsx("span",{className:"text-tui-text",children:b})]})]}),u.jsxs("form",{id:"pairing-form",onSubmit:fe,className:"space-y-3",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"pairing-name",children:y("pairing.displayNameLabel")}),u.jsx(Pn,{id:"pairing-name",type:"text",value:T,onChange:F=>_(F.target.value),placeholder:y("pairing.displayNamePlaceholder"),maxLength:64,autoComplete:"off"}),u.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.displayNameHelp")})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"pairing-code",hint:y("pairing.pairCodeNote"),children:y("pairing.pairCodeLabel")}),u.jsx(Pn,{id:"pairing-code",type:"text",value:X,onChange:F=>re(F.target.value.toUpperCase()),placeholder:y("pairing.pairCodePlaceholder"),maxLength:12,className:"uppercase"}),u.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.pairCodeHelp")})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"pairing-token",hint:y("pairing.tokenNote"),children:y("pairing.tokenLabel")}),u.jsx(Pn,{id:"pairing-token",type:"password",value:G,onChange:F=>Q(F.target.value),placeholder:y("pairing.tokenPlaceholder")})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"pairing-ws",children:y("pairing.wsUrlLabel")}),u.jsx(Pn,{id:"pairing-ws",type:"text",value:H,onChange:F=>z(F.target.value),placeholder:y("pairing.wsUrlPlaceholder")}),u.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.wsUrlDefaultNote")})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"pairing-client-id",children:y("pairing.clientIdLabel")}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Pn,{id:"pairing-client-id",type:"text",value:de,onChange:F=>ee(F.target.value),className:"flex-1"}),u.jsx(Ue,{onClick:Re,title:y("pairing.regenerateClientIdTitle"),className:"shrink-0",children:y("pairing.newIdButton")})]})]}),u.jsx("div",{className:"border-t border-tui-border-dim pt-2",children:u.jsx(Qa,{checked:P,onChange:le,label:y("pairing.autoReconnectLabel"),description:y("pairing.autoReconnectDesc")})}),u.jsx("div",{className:"border-t border-tui-border-dim pt-2",children:u.jsx(Ue,{onClick:Ge,block:!0,glyph:ve?He.check:"⧉",className:$(ve&&"border-tui-ok text-tui-ok"),children:y("pairing.copyDirectLink")})})]})]})},BS=({isOpen:r,onClose:a})=>{const{settings:i,updateSettings:o,addToast:d,language:f,setLanguage:p,t:m}=St(),[b,v]=x.useState("appearance"),[y,S]=x.useState(!1);if(!r)return null;const A=Gu.find(T=>T.font===i.fontFamily),E=i.virtualKeys&&i.virtualKeys.length>0?i.virtualKeys:qr(),R=typeof window<"u"&&window.isSecureContext&&"Notification"in window,H=()=>{const T=Xp();o({fontSize:T.fontSize,fontFamily:T.fontFamily,toolbarVisible:T.toolbarVisible,vibrateOnKeyPress:T.vibrateOnKeyPress,predictiveEcho:T.predictiveEcho,agentAlertBadge:T.agentAlertBadge,agentAlertSound:T.agentAlertSound,agentAlertVibrate:T.agentAlertVibrate,agentAlertNotify:T.agentAlertNotify,language:T.language,virtualKeys:T.virtualKeys}),d("info",m("settings.resetDefaultsToast"))},z=T=>{const _=E.map(P=>P.id===T?{...P,enabled:!P.enabled}:P);o({virtualKeys:_})},G=(T,_)=>{const P=_==="up"?T-1:T+1;if(P<0||P>=E.length)return;const le=[...E],ve=le[T];le[T]=le[P],le[P]=ve,o({virtualKeys:le})},Q=T=>{if(E.some(P=>P.id===T.id)){const P=E.map(le=>le.id===T.id?{...le,enabled:!0}:le);o({virtualKeys:P})}else{const P=[...E,{...T,enabled:!0}];o({virtualKeys:P})}S(!1)},X=T=>{const _=E.filter(P=>P.id!==T);o({virtualKeys:_})},re=()=>{o({virtualKeys:qr()}),d("info",m("toasts.keyLayoutReset"))},de=10,ee=24;return u.jsxs(ad,{isOpen:r,onClose:a,title:m("settings.title"),subtitle:m("settings.subtitle"),closeLabel:m("common.closeDialog"),size:"lg",hints:[{keys:"esc",action:m("common.close")}],footer:u.jsxs(u.Fragment,{children:[u.jsx(Ue,{variant:"ghost",onClick:H,children:m("settings.resetDefaults")}),u.jsx(Ue,{variant:"primary",onClick:a,children:m("common.done")})]}),children:[u.jsx(td,{tabs:[{id:"appearance",label:m("settings.tabAppearance"),index:1},{id:"virtualKeys",label:m("settings.tabVirtualKeys"),index:2}],activeId:b,onSelect:T=>v(T),className:"mb-3 border-b border-tui-border-dim pb-1"}),b==="appearance"&&u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{children:m("settings.languageLabel")}),u.jsxs("div",{className:"grid gap-0.5 sm:grid-cols-2",children:[u.jsx(Dr,{name:"ui-language",checked:f==="zh",onChange:()=>p("zh"),label:"简体中文"}),u.jsx(Dr,{name:"ui-language",checked:f==="en",onChange:()=>p("en"),label:"English"})]})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"terminal-font-select",children:m("settings.fontFamilyLabel")}),u.jsxs(nd,{id:"terminal-font-select",value:i.fontFamily,onChange:T=>o({fontFamily:T.target.value}),"aria-label":m("settings.fontFamilyLabel"),children:[!A&&u.jsx("option",{value:i.fontFamily,children:i.fontFamily}),Gu.map(T=>u.jsx("option",{value:T.font,children:m(`fontPresets.${T.id}`)||T.name},T.id))]}),u.jsxs("div",{className:"overflow-x-auto whitespace-nowrap border border-tui-border bg-tui-mantle px-2 py-1.5 leading-snug text-tui-text",style:{fontFamily:i.fontFamily,fontSize:`${i.fontSize}px`},children:[u.jsx("span",{className:"text-tui-ok",children:"$"}),' echo "Herdr 0O 1lI ',' [] () -> => !="']})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"terminal-font-size",children:m("settings.fontSizeLabel",{size:i.fontSize})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Vx,{value:(i.fontSize-de)/(ee-de),width:24,className:"hidden shrink-0 sm:inline-flex"}),u.jsx("input",{id:"terminal-font-size",type:"range",min:de,max:ee,step:1,value:i.fontSize,onChange:T=>o({fontSize:Number(T.target.value)}),className:"h-1 w-full cursor-pointer appearance-none bg-tui-border accent-tui-accent"})]}),u.jsxs("div",{className:"flex justify-between text-tui-sm text-tui-faint",children:[u.jsx("span",{children:m("settings.fontSizeCompact")}),u.jsx("span",{children:m("settings.fontSizeDefault")}),u.jsx("span",{children:m("settings.fontSizeLarge")})]}),u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("settings.mobileFontNote")}),u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("settings.windowZoomSharedNote")})]}),u.jsx(Ea,{}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{children:m("settings.predictiveEchoLabel")}),u.jsxs("div",{className:"grid gap-0.5 sm:grid-cols-3",children:[u.jsx(Dr,{name:"predictive-echo",checked:i.predictiveEcho==="auto",onChange:()=>o({predictiveEcho:"auto"}),label:m("settings.predictiveEchoAuto")}),u.jsx(Dr,{name:"predictive-echo",checked:i.predictiveEcho==="always",onChange:()=>o({predictiveEcho:"always"}),label:m("settings.predictiveEchoAlways")}),u.jsx(Dr,{name:"predictive-echo",checked:i.predictiveEcho==="off",onChange:()=>o({predictiveEcho:"off"}),label:m("settings.predictiveEchoOff")})]}),u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("settings.predictiveEchoDesc")})]}),u.jsx(Ea,{}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(Qa,{checked:i.toolbarVisible,onChange:T=>o({toolbarVisible:T}),label:m("settings.touchKeyToolbar"),description:m("settings.touchKeyToolbarDesc")}),u.jsx(Qa,{checked:i.vibrateOnKeyPress,onChange:T=>o({vibrateOnKeyPress:T}),label:m("settings.touchHaptics"),description:m("settings.touchHapticsDesc")})]}),u.jsx(Ea,{}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{children:m("settings.agentAlertsLabel")}),u.jsx(Qa,{checked:i.agentAlertBadge,onChange:T=>o({agentAlertBadge:T}),label:m("settings.agentAlertBadge"),description:m("settings.agentAlertBadgeDesc")}),u.jsx(Qa,{checked:i.agentAlertVibrate,onChange:T=>o({agentAlertVibrate:T}),label:m("settings.agentAlertVibrate"),description:m("settings.agentAlertVibrateDesc")}),u.jsx(Qa,{checked:i.agentAlertSound,onChange:T=>{o({agentAlertSound:T}),T&&(eg(),tg("done"))},label:m("settings.agentAlertSound"),description:m("settings.agentAlertSoundDesc")}),R&&u.jsx(Qa,{checked:i.agentAlertNotify,onChange:T=>{if(T&&Notification.permission!=="granted"){Notification.requestPermission().then(_=>o({agentAlertNotify:_==="granted"}));return}o({agentAlertNotify:T})},label:m("settings.agentAlertNotify"),description:m("settings.agentAlertNotifyDesc")})]}),u.jsx(Ea,{}),u.jsxs("p",{className:"text-tui-sm leading-snug text-tui-faint",children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1",children:He.arrowRight}),m("settings.colorPassthroughNote")]})]}),b==="virtualKeys"&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h3",{className:"text-tui font-bold uppercase text-tui-accent",children:m("virtualKeyboard.customizeTitle")}),u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("virtualKeyboard.customizeDesc")})]}),u.jsx(Ue,{variant:"ghost",onClick:re,className:"shrink-0",children:m("virtualKeyboard.resetLayout")})]}),u.jsx("div",{className:"max-h-72 overflow-y-auto border border-tui-border bg-tui-mantle",children:E.map((T,_)=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-tui-border-dim px-2 py-1 last:border-b-0 hover:bg-tui-selection",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("input",{type:"checkbox",checked:T.enabled,onChange:()=>z(T.id),className:"sr-only",id:`toggle-${T.id}`}),u.jsx("label",{htmlFor:`toggle-${T.id}`,className:$("shrink-0 cursor-pointer select-none font-bold",T.enabled?"text-tui-ok":"text-tui-faint"),"aria-hidden":"true",children:T.enabled?"[x]":"[ ]"}),u.jsx(Ix,{className:$(!T.enabled&&"opacity-50"),children:T.label}),u.jsx("span",{className:"truncate text-tui-sm text-tui-muted",children:Bu(T,m)})]}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[u.jsx(Ue,{variant:"ghost",brackets:!1,disabled:_===0,onClick:()=>G(_,"up"),title:m("virtualKeyboard.moveUp"),"aria-label":m("virtualKeyboard.moveUp"),className:"px-1",children:"↑"}),u.jsx(Ue,{variant:"ghost",brackets:!1,disabled:_===E.length-1,onClick:()=>G(_,"down"),title:m("virtualKeyboard.moveDown"),"aria-label":m("virtualKeyboard.moveDown"),className:"px-1",children:"↓"}),u.jsx(Ue,{variant:"ghost",brackets:!1,onClick:()=>X(T.id),title:m("virtualKeyboard.deleteKeyTitle"),"aria-label":m("virtualKeyboard.deleteKeyTitle"),className:"px-1 text-tui-bad hover:text-tui-bad",children:He.cross})]})]},T.id))}),u.jsx(Ue,{block:!0,glyph:"+",onClick:()=>S(!y),className:"border-dashed",children:m("virtualKeyboard.addKey")}),y&&u.jsxs("div",{className:"space-y-2 border border-tui-border bg-tui-mantle p-2",children:[u.jsx(Ea,{label:m("virtualKeyboard.availableKeys")}),u.jsx("div",{className:"flex max-h-48 flex-wrap gap-1 overflow-y-auto",children:mv.map(T=>{const _=E.some(P=>P.id===T.id);return u.jsxs("button",{type:"button",onClick:()=>Q(T),title:Bu(T,m),className:$("tui-focusable flex select-none items-center gap-1 border px-1.5 py-0.5 text-tui-sm transition-colors",_?"border-tui-border-dim text-tui-faint":"border-tui-border text-tui-text hover:border-tui-accent hover:text-tui-accent"),children:[u.jsx("span",{children:T.label}),u.jsx("span",{"aria-hidden":"true",className:_?"text-tui-ok":"text-tui-accent",children:_?He.check:"+"})]},T.id)})})]})]})]})},HS={success:"ok",warning:"warn",error:"bad",info:"accent"},YS={success:He.check,warning:He.warn,error:He.cross,info:"›"},KS=()=>{const{toasts:r,removeToast:a,t:i}=St();return r.length===0?null:u.jsx("div",{className:"pointer-events-none fixed right-2 top-12 z-50 flex w-[calc(100vw-16px)] max-w-sm flex-col gap-1","aria-live":"polite","aria-atomic":"true",children:r.map(o=>{const d=HS[o.type];return u.jsxs("div",{className:$("pointer-events-auto flex items-start gap-2 border border-tui-border border-l-2 bg-tui-base px-2 py-1 text-tui",Wn[d].edgeL),role:"alert",children:[u.jsx("span",{"aria-hidden":"true",className:$("shrink-0 font-bold",Wn[d].text),children:YS[o.type]}),u.jsx("div",{className:"min-w-0 flex-1 break-words leading-snug text-tui-text",children:o.message}),o.count>1&&u.jsxs("span",{className:"shrink-0 border border-tui-border-dim px-1 text-tui-sm text-tui-muted","aria-label":`×${o.count}`,children:["×",o.count]}),u.jsx("button",{type:"button",onClick:()=>a(o.id),className:"tui-focusable shrink-0 select-none px-0.5 text-tui-faint transition-colors hover:text-tui-bad","aria-label":i("common.dismissNotification"),children:u.jsx("span",{"aria-hidden":"true",children:He.cross})})]},o.id)})})},GS=[{status:"blocked",level:"warn"},{status:"done",level:"ok"},{status:"working",level:"accent"}],kg=({className:r,compact:a=!1})=>{const{agentStatus:i,t:o}=St();if(!i)return null;const d=GS.map(({status:p,level:m})=>{var b;return{status:p,level:m,count:((b=i.counts)==null?void 0:b[p])??0}}).filter(p=>p.count>0),f=a?d.slice(0,1):d;return f.length===0?i.total===0?null:u.jsxs("span",{"data-testid":"agent-status-chip",className:$("flex shrink-0 items-center gap-1 px-1 text-tui-muted",r),title:o("agents.title"),children:[u.jsx(Cn,{level:"idle"}),u.jsx("span",{className:"text-tui-faint",children:o("agents.allIdle")})]}):u.jsx("span",{"data-testid":"agent-status-chip",className:$("flex shrink-0 items-center gap-2 px-1",r),title:o("agents.title"),children:f.map(({status:p,level:m,count:b})=>u.jsxs("span",{className:"flex items-center gap-1 text-tui-muted",children:[u.jsx(Cn,{level:m}),u.jsx("span",{className:"text-tui-text",children:b}),u.jsx("span",{className:"text-tui-faint",children:o(`agents.${p}`)})]},p))})},rd=({onAddProfile:r,mobile:a=!1,statusBar:i=!1})=>{const{profiles:o,activeProfileId:d,activeProfile:f,connectionState:p,switchProfile:m,renameProfile:b,removeProfile:v,t:y}=St(),[S,A]=x.useState(!1),[E,R]=x.useState(null),[H,z]=x.useState(""),G=x.useRef(null);x.useEffect(()=>{if(!S)return;const T=_=>{G.current&&!G.current.contains(_.target)&&A(!1)};return document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[S]);const Q=(T,_)=>{R(T),z(_)},X=T=>{const _=H.trim();_&&b(T,_),R(null)},re=T=>{typeof window<"u"&&!window.confirm(y("profiles.removeConfirm"))||(v(T),R(null))},de=(f==null?void 0:f.displayName)||y("profiles.addHost"),ee=p==="connected"?"ok":p==="connecting"||p==="reconnecting"?"warn":p==="error"?"bad":"idle";return u.jsxs("div",{ref:G,className:$("relative min-w-0",a&&"w-full",i&&"flex-1"),children:[u.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":S,"aria-label":y("profiles.switcherLabel"),onClick:()=>A(T=>!T),className:$("tui-focusable flex min-w-0 items-center gap-1.5 border border-transparent text-left text-tui-muted transition-colors hover:border-tui-border hover:text-tui-accent",i?"min-h-11 w-full max-w-none px-2":a?"min-h-11 w-full px-2":"min-h-[24px] max-w-[18rem] px-1"),children:[u.jsx(Cn,{level:ee}),u.jsx("span",{className:$("truncate text-tui-text",i&&"min-w-0 flex-1"),children:de}),u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint",children:S?He.chevronDown:He.chevronRight})]}),S&&u.jsxs("div",{role:"menu","aria-label":y("profiles.switcherLabel"),className:$("absolute bottom-full left-0 z-[100] mb-1 max-h-[min(70vh,24rem)] overflow-y-auto border border-tui-border bg-tui-base p-1 shadow-lg",i?"w-80 max-w-[calc(100vw-1rem)]":a?"inset-x-0 bottom-auto top-full mt-1 mb-0 w-full":"w-80 max-w-[calc(100vw-1rem)]"),children:[u.jsx("div",{className:"border-b border-tui-border-dim px-2 py-1 text-tui-sm uppercase text-tui-faint",children:y("profiles.title")}),o.length===0?u.jsx("p",{className:"px-2 py-2 text-tui-sm text-tui-muted",children:y("profiles.empty")}):o.map(T=>{const _=T.id===d,P=T.id===E;return u.jsxs("div",{role:"none",className:"border-b border-tui-border-dim last:border-b-0",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs("button",{type:"button",role:"menuitem","aria-current":_?"true":void 0,onClick:()=>{m(T.id),A(!1)},className:$("tui-focusable flex min-h-11 min-w-0 flex-1 items-center gap-2 px-2 text-left text-tui transition-colors hover:bg-tui-selection",_?"text-tui-accent":"text-tui-text"),children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0",children:_?He.cursor:""}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate font-bold",children:T.displayName}),u.jsx("span",{className:"block truncate text-tui-sm text-tui-faint",title:T.hostname||T.hostId,children:T.hostname||T.hostId||T.wsUrl})]}),_&&u.jsx("span",{className:"shrink-0 text-tui-sm text-tui-ok",children:y("profiles.current")})]}),u.jsx("button",{type:"button",role:"menuitem","aria-label":y("profiles.rename"),title:y("profiles.rename"),onClick:()=>Q(T.id,T.displayName),className:"tui-focusable min-h-11 min-w-11 px-2 text-tui-muted hover:text-tui-accent",children:He.ellipsis})]}),P&&u.jsxs("div",{className:"flex items-center gap-1 px-2 pb-2",children:[u.jsx("input",{autoFocus:!0,value:H,maxLength:64,onChange:le=>z(le.target.value),onKeyDown:le=>{le.key==="Enter"&&X(T.id),le.key==="Escape"&&R(null)},"aria-label":y("profiles.rename"),className:"tui-input min-w-0 flex-1 px-2 py-1 text-tui"}),u.jsx(Ue,{onClick:()=>X(T.id),variant:"primary",className:"min-h-11",children:y("common.save")}),u.jsx(Ue,{onClick:()=>re(T.id),variant:"danger",className:"min-h-11",children:y("profiles.remove")})]})]},T.id)}),u.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{A(!1),r()},className:"tui-focusable flex min-h-11 w-full items-center gap-2 px-2 text-left text-tui-accent hover:bg-tui-selection",children:[u.jsx("span",{"aria-hidden":"true",children:"+"}),u.jsx("span",{children:y("profiles.addHost")})]})]})]})},qS=({onAddProfile:r=()=>{}})=>{const{connectionState:a,role:i,hostId:o,assignedClientId:d,sharedWindowCount:f,settings:p,rttMs:m,t:b}=St(),v=wo(a,b),y=a==="connected";return u.jsx(vg,{left:u.jsxs(u.Fragment,{children:[u.jsx(rd,{onAddProfile:r}),u.jsx(rp,{items:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Cn,{level:v.level}),u.jsx("span",{className:"text-tui-text",children:v.label})]},"status"),y?u.jsx(So,{tone:i==="controller"?"ok":"warn",children:b(i==="controller"?"role.sharedControl":"common.viewer")},"role"):null,y&&f>1?u.jsx("span",{className:"text-tui-muted",children:b("role.sharedWindows",{count:f})},"windows"):null,o?u.jsxs("span",{children:[u.jsxs("span",{className:"text-tui-faint",children:[b("common.host"),":"]})," ",u.jsx("span",{className:"text-tui-text",children:o})]},"host"):null,u.jsxs("span",{children:[u.jsx("span",{className:"text-tui-faint",children:b("header.clientIdLabel")})," ",u.jsx("span",{className:"text-tui-text",children:d||p.clientId})]},"client")]})]}),right:u.jsx(rp,{items:[y?u.jsx(kg,{},"agents"):null,m!==null?u.jsxs("span",{className:"text-tui-muted",children:[b("header.latencyTitle"),": ",u.jsxs("span",{className:"text-tui-text",children:[m,"ms"]})]},"rtt"):null,u.jsx("span",{className:"hidden text-tui-faint sm:inline",children:b("header.tagline")},"mode")]})})},VS=[[/\biPhone\b/i,"iPhone"],[/\biPad\b/i,"iPad"],[/\biPod\b/i,"iPod"],[/\bAndroid\b/i,"Android"],[/\bCrOS\b/i,"ChromeOS"],[/\bWindows NT\b/i,"Windows"],[/\bMac OS X\b|\bMacintosh\b/i,"macOS"],[/\bLinux\b/i,"Linux"]],FS=[[/\bEdgA?\/|\bEdge\//i,"Edge"],[/\bOPR\/|\bOpera\//i,"Opera"],[/\bSamsungBrowser\//i,"Samsung Internet"],[/\bFirefox\/|\bFxiOS\//i,"Firefox"],[/\bCriOS\//i,"Chrome"],[/\bChrome\//i,"Chrome"],[/\bSafari\//i,"Safari"]];function Ap(r,a){for(const[i,o]of r)if(i.test(a))return o;return null}function sd(r){const a=typeof r=="string"?r.trim():"";if(!a)return{label:"",raw:""};const i=Ap(VS,a),o=Ap(FS,a);return i&&o?{label:`${i} · ${o}`,raw:a}:i?{label:i,raw:a}:o?{label:o,raw:a}:{label:a.length>32?`${a.slice(0,32)}…`:a,raw:a}}function Ep(r){if(r===0)return"0 B";const a=1024,i=["B","KB","MB","GB"],o=Math.floor(Math.log(r)/Math.log(a));return`${(r/Math.pow(a,o)).toFixed(1)} ${i[o]}`}const XS=({clients:r})=>{const{t:a}=St(),i=[{key:"id",header:a("admin.colClientId"),render:o=>u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Cn,{level:"ok"}),u.jsx("span",{className:"font-bold text-tui-text",children:o.id})]})},{key:"role",header:a("admin.colRole"),width:12,render:o=>{const d=o.role==="controller";return u.jsx(So,{tone:d?"ok":"warn",children:a(d?"common.controller":"common.viewer")})}},{key:"device",header:a("admin.colDevice"),render:o=>{const d=sd(o.userAgent);return d.label?u.jsx("span",{className:"text-tui-muted",title:d.raw,children:d.label}):u.jsx("span",{className:"text-tui-faint",children:a("admin.unknownDevice")})}},{key:"ip",header:a("admin.colIp"),render:o=>u.jsx("span",{className:"text-tui-muted",children:o.ip||"127.0.0.1"})},{key:"connectedAt",header:a("admin.colConnectedAt"),render:o=>u.jsx("span",{className:"text-tui-muted",children:o.connectedAt?new Date(o.connectedAt).toLocaleTimeString():a("admin.startedRecently")})},{key:"traffic",header:a("admin.colTraffic"),align:"right",render:o=>u.jsxs("span",{className:"whitespace-nowrap",children:[u.jsx("span",{className:"text-tui-accent",children:Ep(o.bytesReceived||0)}),u.jsx("span",{"aria-hidden":"true",className:"mx-1 text-tui-faint",children:"/"}),u.jsx("span",{className:"text-tui-ok",children:Ep(o.bytesSent||0)})]})}];return u.jsx(rn,{title:a("admin.connectedClientsTitle",{count:r.length}),bodyClassName:"-mx-1",children:u.jsx(ld,{columns:i,items:r,rowKey:o=>o.id,empty:a("admin.noClients")})})},Rp={online:"ok",busy:"ok",reconnecting:"warn",offline:"idle"};function IS(r=[],a=[]){const i=new Map;for(const f of a){if(!(f!=null&&f.hostId))continue;const p=i.get(f.hostId);p?p.push(f):i.set(f.hostId,[f])}const o=r.map(f=>{const p=i.get(f.id)||[];return{id:f.id,hostname:f.hostname||f.id,status:f.status||"online",connectedDeviceCount:f.connectedDeviceCount??0,pairedDeviceCount:f.pairedDeviceCount??p.length,devices:p,fromRosterOnly:!1}}),d=new Set(o.map(f=>f.id));for(const[f,p]of i)d.has(f)||o.push({id:f,hostname:f,status:"offline",connectedDeviceCount:0,pairedDeviceCount:p.length,devices:p,fromRosterOnly:!0});return o.sort((f,p)=>f.fromRosterOnly!==p.fromRosterOnly?f.fromRosterOnly?1:-1:f.hostname.localeCompare(p.hostname))}const ZS=({hosts:r,devices:a})=>{const{t:i}=St(),o=IS(r,a),d={online:i("admin.hostStatusOnline"),busy:i("admin.hostStatusBusy"),reconnecting:i("admin.hostStatusReconnecting"),offline:i("admin.hostStatusOffline")};return u.jsx(rn,{title:i("admin.hostsTitle",{count:o.length}),bodyClassName:"space-y-2",children:o.length===0?u.jsx("p",{className:"px-1 py-2 text-tui text-tui-faint",children:i("admin.noHosts")}):o.map(f=>u.jsxs("div",{className:"border border-tui-border-dim bg-tui-mantle",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1 border-b border-tui-border-dim px-2 py-1",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-tui",children:[u.jsx(Cn,{level:Rp[f.status]}),u.jsx("span",{className:"truncate font-bold text-tui-text",children:f.hostname}),f.hostname!==f.id?u.jsx("code",{className:"truncate text-tui-sm text-tui-faint",children:f.id}):null]}),u.jsxs("span",{className:"flex shrink-0 items-center gap-3 text-tui-sm",children:[u.jsx(So,{tone:Rp[f.status],children:d[f.status]}),u.jsx("span",{className:"text-tui-accent",children:i("admin.hostConnectedDevices",{count:f.connectedDeviceCount})}),u.jsx("span",{className:"text-tui-muted",children:i("admin.hostPairedDevices",{count:f.pairedDeviceCount})})]})]}),f.devices.length>0?u.jsx("ul",{className:"divide-y divide-tui-border-dim",children:f.devices.map(p=>{const m=sd(p.userAgent);return u.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 px-2 py-0.5 text-tui",children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint",children:"·"}),u.jsx("span",{className:"truncate text-tui-text",title:m.raw,children:m.label||i("admin.unknownDevice")}),u.jsx("code",{className:"truncate text-tui-sm text-tui-muted",children:p.deviceId}),u.jsx("span",{className:"ml-auto shrink-0 text-tui-sm text-tui-faint",children:p.lastIp||"—"})]},p.deviceId)})}):u.jsx("p",{className:"px-2 py-1 text-tui-sm text-tui-faint",children:f.pairedDeviceCount>0?i("admin.hostRosterOperatorOnly"):i("admin.noDevices")})]},f.id))})},QS=({ptys:r})=>{const{t:a}=St(),i=[{key:"id",header:a("admin.colPtyId"),render:o=>u.jsx("span",{className:"font-bold text-tui-accent",children:o.id})},{key:"pid",header:a("admin.colPid"),width:9,render:o=>u.jsx("span",{className:"text-tui-muted",children:o.pid})},{key:"command",header:a("admin.colCommand"),render:o=>u.jsx("code",{className:"border border-tui-border-dim bg-tui-mantle px-1 text-tui-text",children:o.command})},{key:"grid",header:a("admin.colGrid"),width:11,render:o=>u.jsxs("span",{className:"whitespace-nowrap text-tui-muted",children:[o.cols,u.jsx("span",{"aria-hidden":"true",className:"mx-0.5 text-tui-faint",children:"×"}),o.rows]})},{key:"cwd",header:a("admin.colCwd"),className:"max-w-xs truncate",render:o=>u.jsx("span",{className:"text-tui-muted",children:o.cwd||"~"})},{key:"viewers",header:a("admin.colViewers"),align:"right",width:9,render:o=>u.jsx("span",{className:"font-bold text-tui-ok",children:o.activeClients})}];return u.jsx(rn,{title:a("admin.activePtysTitle",{count:r.length}),bodyClassName:"-mx-1",children:u.jsx(ld,{columns:i,items:r,rowKey:o=>o.id,empty:a("admin.noPtys")})})};function JS(r){if(!r)return"—";const a=new Date(r);return Number.isNaN(a.getTime())?"—":a.toLocaleString()}const WS=({devices:r,onRevoke:a})=>{const{t:i}=St(),[o,d]=x.useState(null),[f,p]=x.useState(null),m=async v=>{if(o!==v){d(v);return}p(v);try{await a(v)}finally{p(null),d(null)}},b=[{key:"device",header:i("admin.colDevice"),render:v=>{const y=sd(v.userAgent);return u.jsx("span",{className:"text-tui-text",title:y.raw,children:y.label||i("admin.unknownDevice")})}},{key:"deviceId",header:i("admin.colDeviceId"),render:v=>u.jsx("span",{className:"text-tui-muted",children:v.deviceId})},{key:"ip",header:i("admin.colIp"),render:v=>u.jsx("span",{className:"text-tui-muted",children:v.lastIp||"—"})},{key:"lastSeen",header:i("admin.colLastSeen"),render:v=>u.jsx("span",{className:"whitespace-nowrap text-tui-muted",children:JS(v.lastSeenAt)})},{key:"actions",header:i("admin.colActions"),align:"right",render:v=>{const y=o===v.deviceId,S=f===v.deviceId;return u.jsx(Ue,{variant:"danger",disabled:S,onClick:()=>void m(v.deviceId),onBlur:()=>d(A=>A===v.deviceId?null:A),"aria-label":i("admin.revokeDevice"),className:y?"bg-tui-bad text-tui-crust":void 0,children:S?u.jsx(Yi,{}):i(y?"admin.revokeConfirm":"admin.revokeDevice")})}}];return u.jsx(rn,{title:i("admin.pairedDevicesTitle",{count:r.length}),bodyClassName:"-mx-1",children:u.jsx(ld,{columns:b,items:r,rowKey:v=>v.deviceId,empty:i("admin.noDevices")})})};function Mg(r){if(typeof window>"u"||!r||r.startsWith("/"))return"";try{const a=new URL(r.replace(/^ws/,"http")),i=a.pathname.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"");return a.origin===window.location.origin&&!i?"":`${a.origin}${i}`}catch{return""}}function Ur(r,a){const i=Mg(r);return i?`${i}${a.startsWith("/")?a:`/${a}`}`:a}const PS=({onBackToTerminal:r,onOpenPairing:a})=>{var hn,qe,Je,We,wt,gt,qt,Tn,Nn,Hn,$n,kt,Pe,Ct;const{settings:i,updateSettings:o,addToast:d,t:f}=St(),p=Mg(i.wsUrl)||(typeof window<"u"?window.location.origin:"local"),m=((hn=i.adminTokens)==null?void 0:hn[p])||(p===(typeof window<"u"?window.location.origin:"local")?i.adminToken:"")||"",[b,v]=x.useState(null),[y,S]=x.useState(null),[A,E]=x.useState(!1),[R,H]=x.useState(!0),[z,G]=x.useState(null),[Q,X]=x.useState(!1),[re,de]=x.useState(3e3),[ee,T]=x.useState(null),[_,P]=x.useState("overview"),[le,ve]=x.useState(!1),[Se,fe]=x.useState(m),[Re,Ge]=x.useState(!!m),D="node bin/service.js pair";x.useEffect(()=>{fe(m),Ge(!!m),v(null),S(null),E(!1)},[p]);const F=()=>{Pa(D).then(ae=>{if(ae==="failed"){d("error",f("clipboard.copyFailed"));return}ve(!0),d("success",f("toasts.commandCopied")),setTimeout(()=>ve(!1),2e3)})};x.useEffect(()=>{let ae=!0;H(!0);async function Ae(){try{const Le=await fetch(Ur(i.wsUrl,"/api/info"),{headers:{Accept:"application/json"}});if(Le.ok){const ot=await Le.json();ae&&(S(ot),E(!0));return}}catch{}if(ae){const Le=!!(i.wsUrl&&!i.wsUrl.startsWith("/")&&!i.wsUrl.includes("localhost")&&!i.wsUrl.includes("127.0.0.1")&&typeof window<"u"&&!i.wsUrl.startsWith(window.location.origin.replace("http","ws")));S({ok:!0,version:"0.1.0",protocol:1,relayMode:Le?"remote":"local",adminConfigured:!1,adminPath:"/admin",adminStatusPath:"/api/admin/status"}),E(!0)}}return Ae(),()=>{ae=!1}},[i.wsUrl,p]);const J=(y==null?void 0:y.relayMode)==="remote",q=()=>{if(y!=null&&y.adminPath)return y.publicUrl?`${y.publicUrl.replace(/\/$/,"")}${y.adminPath}`:Ur(i.wsUrl,y.adminPath);if(b!=null&&b.remoteAdminUrl)return b.remoteAdminUrl;if(i.wsUrl)try{return Ur(i.wsUrl,"/admin")}catch{}return"/admin"},V=x.useCallback(async()=>{if(A){if(J){if(!Re&&!Se){v(null),H(!1),G(null),X(!1);return}try{H(!0);const ae=Ur(i.wsUrl,(y==null?void 0:y.adminStatusPath)||"/api/admin/status"),Le=await fetch(ae,{headers:{Accept:"application/json","X-Relay-Admin-Token":Se}});if(Le.status===401||Le.status===403){X(!0),G(f("admin.relayAdminAuthError")),v(null);return}if(!Le.ok)throw new Error(`HTTP ${Le.status}: ${Le.statusText}`);const ot=await Le.json();v(ot),G(null),X(!1),T(new Date)}catch(ae){console.warn("GET /api/admin/status request failed:",ae),X(!1),G(ae instanceof Error?ae.message:"Failed to fetch remote admin status"),v(null)}finally{H(!1)}return}try{H(!0);const ae={Accept:"application/json"};i.token&&(ae.Authorization=`Bearer ${i.token}`);const Ae=await fetch("/api/status",{headers:ae});if(Ae.status===401||Ae.status===403){X(!0),G(`Authentication failed (HTTP ${Ae.status}): Access denied. Please configure an authorized token or pair with the host.`),v(null);return}if(!Ae.ok)throw new Error(`HTTP ${Ae.status}: ${Ae.statusText}`);const Le=await Ae.json();v(Le),G(null),X(!1),T(new Date)}catch(ae){console.warn("GET /api/status request failed:",ae),X(!1),G(ae instanceof Error?ae.message:"Failed to fetch status"),v(null)}finally{H(!1)}}},[A,J,Re,Se,y,i.token,i.wsUrl,p,f]),je=x.useCallback(async ae=>{try{if(!(await fetch(Ur(i.wsUrl,`/api/admin/devices/${encodeURIComponent(ae)}`),{method:"DELETE",headers:{Accept:"application/json","X-Relay-Admin-Token":Se}})).ok){G(f("admin.revokeFailed"));return}await V()}catch{G(f("admin.revokeFailed"))}},[Se,V,i.wsUrl,f]);x.useEffect(()=>{if(!A)return;V();let ae=null;const Ae=()=>{re>0&&!ae&&(ae=setInterval(()=>{document.visibilityState==="visible"&&V()},re))},Le=()=>{ae&&(clearInterval(ae),ae=null)},ot=()=>{document.visibilityState==="visible"?(V(),Ae()):Le()};return Ae(),document.addEventListener("visibilitychange",ot),()=>{Le(),document.removeEventListener("visibilitychange",ot)}},[A,V,re]);const pe=ae=>{ae.preventDefault();const Ae=Se.trim();o({adminToken:Ae,adminTokens:{...i.adminTokens||{},[p]:Ae}}),Ge(!!Ae)},ke=ae=>{const Ae=Math.max(0,Math.floor(ae)),Le=Math.floor(Ae/86400),ot=Math.floor(Ae%86400/3600),sn=Math.floor(Ae%3600/60),bt=Ae%60,zt=(Yn,Vt)=>`${Yn}${f(`admin.unit${Vt}`)}`;return Le>0?[zt(Le,"Day"),zt(ot,"Hour"),zt(sn,"Minute")].join(" "):ot>0?[zt(ot,"Hour"),zt(sn,"Minute"),zt(bt,"Second")].join(" "):[zt(sn,"Minute"),zt(bt,"Second")].join(" ")},Ye=ae=>{if(!ae||ae===0)return"0 B";const Ae=1024,Le=["B","KB","MB","GB"],ot=Math.floor(Math.log(ae)/Math.log(Ae));return`${(ae/Math.pow(Ae,ot)).toFixed(1)} ${Le[ot]}`},Ke=()=>{const ae=q();window.open(ae,"_blank","noopener,noreferrer")},Qe=b?b.activeUserCount??((qe=b.clients)==null?void 0:qe.length)??0:0,$t=b?[{id:"overview",label:f("admin.tabOverview"),index:1},{id:"clients",label:f("admin.tabClients",{count:((Je=b.clients)==null?void 0:Je.length)||0}),index:2},{id:"ptys",label:f("admin.tabPtys",{count:((We=b.ptys)==null?void 0:We.length)||0}),index:3},...b.devices?[{id:"devices",label:f("admin.tabDevices",{count:b.devices.length}),index:4}]:[]]:[],tt=$t.map(ae=>ae.id);x.useEffect(()=>{const ae=Ae=>{if(Ae.ctrlKey||Ae.altKey||Ae.metaKey)return;const Le=Ae.target;if(Le instanceof HTMLInputElement||Le instanceof HTMLTextAreaElement||Le instanceof HTMLSelectElement||Le!=null&&Le.isContentEditable||document.querySelector('[role="dialog"]'))return;if(Ae.key==="Escape"&&r){Ae.preventDefault(),r();return}if(Ae.key.toLowerCase()==="r"){Ae.preventDefault(),V();return}const ot=Number.parseInt(Ae.key,10)-1;Number.isInteger(ot)&&ot>=0&&ot<tt.length&&(Ae.preventDefault(),P(tt[ot]))};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[V,tt.join("|")]);const we=u.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r&&u.jsx(Ue,{variant:"ghost",onClick:r,title:f("admin.returnToTerminal"),"aria-label":f("admin.returnToTerminal"),glyph:He.arrowLeft,brackets:!1,className:"shrink-0",children:u.jsx("span",{className:"sr-only",children:f("admin.returnToTerminal")})}),u.jsxs("span",{className:"hidden text-tui-sm text-tui-accent sm:inline",children:["v",(y==null?void 0:y.version)||(b==null?void 0:b.version)||"0.1.0"]}),u.jsx(So,{tone:J?"alt":"ok",children:f(J?"admin.modeRemote":"admin.localWorkstationBadge")}),u.jsxs("label",{className:"hidden items-center gap-1.5 text-tui-sm text-tui-muted md:flex",children:[u.jsx("span",{children:f("admin.autoRefresh")}),u.jsxs(nd,{value:re,onChange:ae=>de(Number(ae.target.value)),"aria-label":f("admin.autoRefresh"),className:"w-auto",children:[u.jsx("option",{value:0,children:f("admin.paused")}),u.jsx("option",{value:1e3,children:"1s"}),u.jsx("option",{value:3e3,children:"3s"}),u.jsx("option",{value:5e3,children:"5s"}),u.jsx("option",{value:1e4,children:"10s"})]})]}),u.jsx(Ue,{variant:"primary",onClick:V,disabled:R,title:f("admin.refreshNow"),children:R?u.jsx(Yi,{}):f("admin.refreshNow")})]});return u.jsxs(Zx,{name:f("admin.title"),tagline:f("admin.subtitle"),aside:we,tabs:$t,activeTabId:_,onSelectTab:ae=>P(ae),tabsAriaLabel:f("header.mainNavigationAria"),hints:[{keys:"1–4",action:f("admin.hintTabs")},{keys:"r",action:f("admin.hintRefresh")},...r?[{keys:"esc",action:f("admin.hintBack")}]:[]],footerAside:ee?u.jsx("span",{className:"text-tui-faint",children:f("admin.updatedAt",{time:ee.toLocaleTimeString()})}):null,bodyClassName:"space-y-3 pb-2",children:[!A&&u.jsx("div",{className:"flex items-center justify-center gap-2 border border-tui-border bg-tui-base px-3 py-8 text-tui text-tui-muted",children:u.jsx(Yi,{label:f("admin.loadingStatus")})}),A&&J&&!Re&&u.jsxs(rn,{title:f("admin.remoteRelayTitle"),aside:f("admin.remoteRelayBadge"),bodyClassName:"space-y-2",children:[u.jsx("p",{className:"text-tui leading-snug text-tui-muted",children:f("admin.remoteRelayNotice")}),u.jsxs("div",{className:"space-y-0.5 border border-tui-border-dim bg-tui-mantle px-2 py-1.5",children:[u.jsx(cl,{label:f("admin.remoteRelayEndpoint"),labelWidth:18,children:u.jsx("code",{className:"break-all text-tui-accent",children:i.wsUrl})}),u.jsx(cl,{label:f("admin.remoteRelayAdminUrl"),labelWidth:18,children:u.jsx("code",{className:"break-all text-tui-ok",children:q()})})]}),u.jsx(Ea,{}),u.jsxs("div",{className:"flex flex-col items-start justify-between gap-2 sm:flex-row sm:items-center",children:[u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:f("admin.remoteRelayHelp")}),u.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[u.jsx(Ue,{onClick:()=>Ge(!0),children:f("admin.relayAdminLoginBtn")}),u.jsx(Ue,{variant:"primary",onClick:Ke,glyph:He.arrowRight,children:f("admin.openRemoteAdminBtn")})]})]})]}),A&&J&&Re&&!b&&u.jsxs(rn,{title:f("admin.relayAdminTitle"),bodyClassName:"space-y-2",children:[u.jsx(fo,{tone:(y==null?void 0:y.adminConfigured)===!1?"warn":"bad",children:(y==null?void 0:y.adminConfigured)===!1?f("admin.relayAdminNotConfigured"):f("admin.relayAdminAuthError")}),u.jsxs("form",{onSubmit:pe,className:"space-y-2",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx(wn,{htmlFor:"relay-admin-token",children:f("admin.relayAdminTokenLabel")}),u.jsx(Pn,{id:"relay-admin-token",type:"password",value:Se,onChange:ae=>fe(ae.target.value),placeholder:f("admin.relayAdminTokenPlaceholder")})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ue,{variant:"primary",type:"submit",children:f("admin.relayAdminLoginBtn")}),u.jsx(Ue,{variant:"ghost",onClick:()=>Ge(!1),children:f("common.cancel")})]})]})]}),A&&!J&&Q&&u.jsxs(rn,{title:f("admin.unauthorizedTitle"),tone:"bad",bodyClassName:"space-y-2",children:[u.jsx(fo,{tone:"bad",children:f("admin.unauthorizedDesc")}),u.jsxs("div",{className:"space-y-1.5 border border-tui-border-dim bg-tui-mantle px-2 py-1.5",children:[u.jsx("span",{className:"block text-tui-sm uppercase text-tui-muted",children:f("admin.pairingStepsTitle")}),u.jsxs("div",{className:"flex items-center gap-2 border border-tui-border bg-tui-crust px-2 py-1",children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none text-tui-ok",children:"$"}),u.jsx("code",{className:"min-w-0 flex-1 truncate text-tui-text",children:D}),u.jsx(Ue,{onClick:F,glyph:le?He.check:"⧉",className:$("shrink-0",le&&"border-tui-ok text-tui-ok"),children:f(le?"admin.copiedJson":"common.copy")})]}),u.jsx("p",{className:"text-tui-sm text-tui-faint",children:f("admin.pairingStepsHelp")})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[a&&u.jsx(Ue,{variant:"primary",onClick:a,children:f("admin.enterPairCodeBtn")}),u.jsx(Ue,{onClick:V,children:f("admin.retryFetchBtn")})]})]}),A&&z&&!Q&&!(!J&&Q)&&u.jsx(fo,{tone:"warn",action:u.jsx(Ue,{variant:"warn",onClick:V,children:f("common.retry")}),children:f("admin.errorConnecting",{error:z})}),b&&u.jsxs(u.Fragment,{children:[_==="overview"&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[u.jsxs(rn,{title:f("admin.accessPanel"),aside:ke(b.uptimeSeconds||0),bodyClassName:"space-y-0.5",children:[u.jsx(cl,{label:f("admin.connectedHosts"),labelWidth:14,children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Cn,{level:(wt=b.hosts)!=null&&wt.length?"ok":"idle"}),u.jsx("span",{className:"font-bold",children:((gt=b.hosts)==null?void 0:gt.length)||0})]})}),u.jsx(cl,{label:f("admin.activeUsers"),labelWidth:14,children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Cn,{level:Qe?"ok":"idle"}),u.jsx("span",{className:"font-bold",children:Qe}),u.jsx("span",{className:"text-tui-faint",children:f("admin.acrossWindows",{count:((qt=b.clients)==null?void 0:qt.length)||0})})]})}),u.jsxs(cl,{label:f("admin.activePtys"),labelWidth:14,children:[u.jsx("span",{className:"font-bold",children:((Tn=b.ptys)==null?void 0:Tn.length)||0}),u.jsx("span",{className:"ml-1.5 text-tui-faint",children:f("admin.terminalShells")})]}),u.jsx(cl,{label:f("admin.uptime"),labelWidth:14,children:u.jsx("span",{className:"text-tui-muted",children:b.startTime?f("admin.startedAt",{time:new Date(b.startTime).toLocaleTimeString()}):f("admin.startedRecently")})})]}),u.jsxs(rn,{title:f("admin.throughput"),aside:f("admin.perSecond",{value:Ye(((Nn=b.throughput)==null?void 0:Nn.bytesOutPerSec)||0)}),bodyClassName:"space-y-0.5",children:[u.jsxs(cl,{label:f("admin.bytesInTotal"),labelWidth:13,children:[u.jsx("span",{className:"font-bold text-tui-accent",children:Ye(((Hn=b.throughput)==null?void 0:Hn.bytesIn)||0)}),u.jsx("span",{className:"ml-1.5 text-tui-faint",children:f("admin.perSecond",{value:Ye((($n=b.throughput)==null?void 0:$n.bytesInPerSec)||0)})})]}),u.jsxs(cl,{label:f("admin.bytesOutTotal"),labelWidth:13,children:[u.jsx("span",{className:"font-bold text-tui-ok",children:Ye(((kt=b.throughput)==null?void 0:kt.bytesOut)||0)}),u.jsx("span",{className:"ml-1.5 text-tui-faint",children:f("admin.perSecond",{value:Ye(((Pe=b.throughput)==null?void 0:Pe.bytesOutPerSec)||0)})})]}),u.jsx(Ea,{}),u.jsx(cl,{label:f("admin.frameRate"),labelWidth:13,children:u.jsx("span",{className:"font-bold",children:f("admin.framesPerSecond",{count:(((Ct=b.throughput)==null?void 0:Ct.framesOutPerSec)||0).toFixed(0)})})})]})]}),u.jsx(ZS,{hosts:b.hosts||[],devices:b.devices})]}),_==="clients"&&u.jsx(XS,{clients:b.clients||[]}),_==="ptys"&&u.jsx(QS,{ptys:b.ptys||[]}),_==="devices"&&u.jsx(WS,{devices:b.devices||[],onRevoke:je})]})]})},$S=({compact:r=!1})=>{const{role:a,connectionState:i,sharedWindowCount:o,assignedClientId:d,t:f}=St();if(!(i==="connected"))return u.jsxs("div",{className:"inline-flex select-none items-center gap-1.5 text-tui uppercase text-tui-faint",role:"status","aria-label":f("terminal.offlineStatusAria"),children:[u.jsx(Cn,{level:"idle"}),u.jsx("span",{children:f("common.offline")})]});const m=a==="controller",b=o>1,v=u.jsxs("div",{className:$("inline-flex min-w-0 select-none items-center gap-1.5 text-tui uppercase",m?"text-tui-ok":"text-tui-warn"),role:"status","aria-label":f(m?"role.controllerMode":"role.viewerMode"),children:[u.jsx(Cn,{level:m?"ok":"warn"}),u.jsx("span",{className:"truncate",children:f(m?"role.sharedControl":"role.viewerReadOnly")}),b?u.jsx("span",{className:"shrink-0 normal-case text-tui-muted",children:f("role.sharedWindows",{count:o})}):null]});return r?v:u.jsxs("div",{className:"flex w-full flex-col gap-1",children:[v,u.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:f("role.sharedControlDesc")}),d?u.jsx(cl,{label:f("role.thisWindow"),labelWidth:9,className:"text-tui-sm",children:u.jsx("span",{className:"truncate text-tui-muted",children:d})}):null]})},Br="tui-focusable group flex h-11 w-full select-none items-center gap-2 border px-2 text-left text-tui transition-colors",Hr="border-tui-border text-tui-muted hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",e1="border-tui-accent bg-tui-selection text-tui-accent",Yr=({active:r=!1})=>u.jsx("span",{"aria-hidden":"true",className:$("shrink-0",r?"text-tui-accent":"text-tui-faint group-hover:text-tui-accent"),children:He.cursor}),t1=({onClose:r,onNavigateAdmin:a,showAdminEntry:i=!0,onOpenPairing:o,onOpenSettings:d,onAddProfile:f=()=>{}})=>{const{connectionState:p,stateDetail:m,rttMs:b,hostId:v,settings:y,updateSettings:S,connect:A,addToast:E,language:R,setLanguage:H,t:z}=St(),[G,Q]=dl.useState(!1),X=wo(p,z),re=T=>()=>{var P;const _=document.activeElement;(P=_==null?void 0:_.blur)==null||P.call(_),T()},de=()=>{Pa(y.clientId).then(T=>{if(T==="failed"){E("error",z("clipboard.copyFailed"));return}Q(!0),E("info",z("toasts.clientIdCopied",{id:y.clientId})),setTimeout(()=>Q(!1),2e3)})},ee=()=>{const T=R==="zh"?"en":"zh";H(T),E("info",Pu(T,"toasts.switchedLanguage",{lang:T==="zh"?"简体中文":"English"}))};return u.jsxs("div",{className:"flex flex-col gap-3 px-3 pb-2 pt-2",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-tui-border pb-1.5",children:[u.jsx("h2",{className:"text-tui font-bold uppercase text-tui-accent",children:z("mobile.sessionControls")}),u.jsx(Ue,{variant:"ghost",onClick:r,"aria-label":z("mobile.closeSessionControls"),children:"esc"})]}),u.jsx(rn,{title:z("profiles.title"),tone:"accent",bodyClassName:"space-y-1",children:u.jsx(rd,{mobile:!0,onAddProfile:f})}),u.jsxs(rn,{title:z("common.status"),tone:X.level==="ok"?"ok":X.level==="bad"?"bad":"warn",bodyClassName:"space-y-1.5",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2","aria-label":z("mobile.connectionStatusAria"),children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[u.jsx(Cn,{level:X.level}),u.jsx("span",{className:"truncate text-tui uppercase text-tui-text",children:X.label}),p==="connected"&&b!==null&&u.jsxs("span",{className:"text-tui-sm text-tui-muted",children:[b,"ms"]})]}),X.actionLabel&&u.jsx(Ue,{variant:"primary",onClick:()=>A(),className:"shrink-0",children:X.actionLabel})]}),X.needsAttention&&m&&u.jsx("p",{className:"text-tui-sm leading-snug text-tui-muted",children:m}),v&&u.jsx(cl,{label:z("common.host"),labelWidth:9,children:v}),u.jsxs("button",{type:"button",onClick:de,className:"tui-focusable flex w-full items-baseline gap-2 text-left text-tui",title:z("header.copyClientIdTitle"),children:[u.jsx("span",{className:"shrink-0 text-tui-muted",style:{width:"9ch"},children:z("header.clientIdLabel")}),u.jsx("span",{className:"min-w-0 flex-1 truncate text-tui-text",children:y.clientId}),u.jsx("span",{"aria-hidden":"true",className:$("shrink-0",G?"text-tui-ok":"text-tui-faint"),children:G?He.check:"⧉"})]})]}),u.jsx(rn,{title:z("mobile.inputControl"),tone:"accent","aria-label":z("mobile.terminalControlAria"),children:u.jsx($S,{})}),u.jsxs(rn,{title:z("mobile.menu"),tone:"accent",bodyClassName:"flex flex-col gap-1",children:[u.jsxs("button",{type:"button",onClick:ee,className:$(Br,Hr),"aria-label":z("header.languageToggleTitle"),children:[u.jsx(Yr,{}),u.jsx("span",{className:"truncate",children:R==="zh"?"English":"中文"})]}),u.jsxs("button",{type:"button",onClick:re(d),className:$(Br,Hr),"aria-label":z("mobile.settingsAria"),children:[u.jsx(Yr,{}),u.jsx("span",{className:"truncate",children:z("common.settings")})]}),u.jsxs("button",{type:"button",onClick:re(o),className:$(Br,Hr),"aria-label":z("mobile.pairingAria"),children:[u.jsx(Yr,{}),u.jsx("span",{className:"truncate",children:z("common.pairing")})]}),i&&u.jsxs("button",{type:"button",onClick:re(a),className:$(Br,Hr),"aria-label":z("mobile.adminAria"),children:[u.jsx(Yr,{}),u.jsx("span",{className:"truncate",children:z("common.admin")})]}),u.jsxs("button",{type:"button",onClick:()=>S({toolbarVisible:!y.toolbarVisible}),className:$(Br,y.toolbarVisible?e1:Hr),"aria-label":z("mobile.keybarAria"),"aria-pressed":y.toolbarVisible,children:[u.jsx(Yr,{active:y.toolbarVisible}),u.jsx("span",{className:"truncate",children:z("common.keyBar")}),u.jsx("span",{"aria-hidden":"true",className:"ml-auto shrink-0 text-tui-sm",children:y.toolbarVisible?"[x]":"[ ]"})]})]})]})},n1=({onAddProfile:r})=>{const{rttMs:a,t:i}=St();return u.jsxs("footer",{"data-testid":"mobile-status-bar",role:"status","aria-label":i("mobile.statusBarAria"),className:"absolute inset-x-0 bottom-0 z-40 flex h-11 shrink-0 items-center gap-2 border-t border-tui-border bg-tui-mantle px-1 text-tui-sm",children:[u.jsx(rd,{statusBar:!0,onAddProfile:r}),u.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-border",children:"│"}),u.jsx(kg,{compact:!0}),u.jsxs("span",{className:"flex shrink-0 items-center gap-1 px-1 text-tui-muted",title:i("header.latencyTitle"),children:[u.jsx("span",{className:"text-tui-faint",children:"RTT"}),u.jsx("span",{className:$(a===null?"text-tui-faint":"text-tui-text"),children:a===null?"—":`${a}ms`})]})]})},l1=({onNavigateAdmin:r,showAdminEntry:a=!0,onOpenPairing:i,onOpenSettings:o,onAddProfile:d=()=>{}})=>{const{connectionState:f,isController:p,t:m}=St(),[b,v]=x.useState(!1),y=x.useRef(null),S=x.useCallback(()=>v(!1),[]);x.useEffect(()=>{if(!b)return;const E=R=>{if(!(R.ctrlKey||R.altKey||R.metaKey)&&R.key==="Escape"){const H=R.target;H&&typeof H.closest=="function"&&!!H.closest("#terminal-container")||(R.stopPropagation(),R.preventDefault(),S())}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[b,S]),x.useEffect(()=>{var E;b&&((E=y.current)==null||E.focus({preventScroll:!0}))},[b]);const A=wo(f,m);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{"data-testid":"mobile-topbar",role:"toolbar","aria-label":m("mobile.sessionControls"),className:"pointer-events-none absolute inset-x-0 top-0 z-40 flex h-12 items-center justify-between gap-2 border-b border-tui-border bg-tui-mantle px-2 text-tui",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-tui-sm text-tui-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"shrink-0 font-bold text-tui-accent",children:"herdr"}),u.jsx(bg,{className:"shrink-0"}),u.jsx(Cn,{level:A.level}),u.jsx("span",{className:"truncate uppercase",children:A.label})]}),u.jsxs("button",{type:"button","data-testid":"mobile-chrome-trigger",onClick:()=>v(!0),"aria-label":m("mobile.sessionControls"),"aria-expanded":b,"aria-haspopup":"dialog",className:$("tui-focusable pointer-events-auto flex h-9 shrink-0 select-none items-center gap-1.5 border px-2 text-tui uppercase transition-colors",A.needsAttention?"border-tui-warn text-tui-warn":p?"border-tui-border text-tui-muted":"border-tui-accent text-tui-accent"),children:[!p&&!A.needsAttention&&u.jsx("span",{className:"max-w-[8rem] truncate",children:m("common.viewer")}),u.jsx("span",{"aria-hidden":"true",className:"text-tui",children:He.chevronDown}),u.jsx("span",{"aria-hidden":"true",children:m("mobile.menu")})]})]}),b&&u.jsxs(u.Fragment,{children:[u.jsx("div",{"data-testid":"mobile-sheet-scrim",className:"absolute inset-0 z-40 bg-tui-crust/70",onClick:S,"aria-hidden":"true"}),u.jsx("div",{ref:y,"data-testid":"mobile-control-sheet",role:"dialog","aria-modal":"true","aria-label":m("mobile.sessionControls"),tabIndex:-1,className:"herdr-sheet absolute inset-x-0 bottom-0 z-50 max-h-[85%] overflow-y-auto border-t border-tui-border bg-tui-base pb-3 focus:outline-none",children:u.jsx(t1,{onClose:S,showAdminEntry:a,onNavigateAdmin:()=>{S(),r()},onOpenPairing:()=>{S(),i()},onOpenSettings:()=>{S(),o()},onAddProfile:()=>{S(),d()}})})]}),u.jsx(n1,{onAddProfile:d})]})},_g="--app-height",zg="--keyboard-inset",a1=80;function i1(){if(typeof window>"u")return{height:768,keyboardInset:0};const r=window.innerHeight||768,a=window.visualViewport;if(a&&typeof a.height=="number"&&a.height>0){const i=r-a.height-(a.offsetTop||0),o=i>=a1?Math.round(i):0;return{height:Math.round(a.height),keyboardInset:o}}return{height:r,keyboardInset:0}}function jp(r,a=i1()){return r.style.setProperty(_g,`${a.height}px`),r.style.setProperty(zg,`${a.keyboardInset}px`),a}function r1(r=typeof document<"u"?document.documentElement:null){if(!r||typeof window>"u")return()=>{};let a=null;const i=()=>{a=null,jp(r)},o=()=>{if(a===null){if(typeof requestAnimationFrame!="function"){i();return}a=requestAnimationFrame(i)}};jp(r);const d=window.visualViewport;return d==null||d.addEventListener("resize",o),d==null||d.addEventListener("scroll",o),window.addEventListener("resize",o),window.addEventListener("orientationchange",o),()=>{a!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(a),a=null),d==null||d.removeEventListener("resize",o),d==null||d.removeEventListener("scroll",o),window.removeEventListener("resize",o),window.removeEventListener("orientationchange",o),r.style.removeProperty(_g),r.style.removeProperty(zg)}}const s1=900;function kp(){if(typeof window>"u")return!1;const r=Ui();return r<Qu?!0:r<=s1}function o1(){const[r,a]=x.useState(kp);return x.useEffect(()=>{var d,f;const i=()=>{const p=kp();a(m=>m===p?m:p)};i();let o=null;try{o=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null}catch{o=null}return(d=o==null?void 0:o.addEventListener)==null||d.call(o,"change",i),window.addEventListener("resize",i),window.addEventListener("orientationchange",i),(f=window.visualViewport)==null||f.addEventListener("resize",i),()=>{var p,m;(p=o==null?void 0:o.removeEventListener)==null||p.call(o,"change",i),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),(m=window.visualViewport)==null||m.removeEventListener("resize",i)}},[]),r}function c1(r){const a=r.target;if(!a)return!1;if(a.id==="terminal-container"||a.id==="terminal-frame"||a.id==="terminal-surface"||a.classList.contains("xterm-helper-textarea")||a.classList.contains("xterm")||a.closest("#terminal-container")||a.closest(".xterm"))return!0;if(typeof document<"u"&&document.activeElement){const i=document.activeElement;if(i.id==="terminal-container"||i.classList.contains("xterm-helper-textarea")||i.closest("#terminal-container")||i.closest(".xterm"))return!0}return!1}function u1(r,a={}){if(typeof window>"u")return()=>{};const i=o=>{var d;o.ctrlKey||o.altKey||o.metaKey||o.key==="Escape"&&(a.isModalOpen||a.isSheetOpen)&&(c1(o)||(o.preventDefault(),o.stopPropagation(),(d=r.onCloseModals)==null||d.call(r)))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}}function d1(){const[r,a]=x.useState("terminal"),[i,o]=x.useState(!1),[d,f]=x.useState(!1),[p,m]=x.useState(!1),[b,v]=x.useState(!1),{updateSettings:y,settings:S,connectionState:A,stateDetail:E,stateCode:R,lastPairedAt:H}=St();Qv();const z=o1();x.useEffect(()=>r1(),[]);const[G,Q]=x.useState(!0);x.useEffect(()=>{let fe=!1;return fetch("/api/info",{headers:{Accept:"application/json"}}).then(Re=>Re.ok?Re.json():null).then(Re=>{fe||!Re||Q(!Re.isRemoteRelay)}).catch(()=>{}),()=>{fe=!0}},[]),x.useEffect(()=>{Jp()},[]),x.useEffect(()=>{const fe=i||p||b;if(fe)return u1({onCloseModals:()=>{o(!1),m(!1),v(!1)}},{isModalOpen:fe})},[i,p,b]),x.useEffect(()=>{const fe=()=>{const Re=window.location.pathname,Ge=window.location.hash;a(Re==="/admin"||Ge==="#admin"?"admin":"terminal")};fe(),window.addEventListener("popstate",fe),window.addEventListener("hashchange",fe);try{const Re=new URL(window.location.href),Ge=Re.searchParams.get("token"),D=Re.searchParams.get("pairCode"),F=Re.searchParams.get("ws")||Re.searchParams.get("wsUrl"),J={};Ge&&(J.token=Ge),D&&(J.pairCode=D.toUpperCase()),F&&(J.wsUrl=F),Object.keys(J).length>0&&y(J);let q=!1;if(Re.searchParams.has("token")&&(Re.searchParams.delete("token"),q=!0),Re.searchParams.has("pairCode")&&(Re.searchParams.delete("pairCode"),q=!0),q){const V=Re.searchParams.toString(),je=Re.pathname+(V?`?${V}`:"")+Re.hash;window.history.replaceState({},"",je)}}catch(Re){console.warn("Failed to parse URL query params:",Re)}return()=>{window.removeEventListener("popstate",fe),window.removeEventListener("hashchange",fe)}},[]);const X=(fe=!1)=>{f(fe),o(!0)},re=()=>{o(!1),f(!1)},de=fe=>{a(fe),fe==="admin"?window.history.pushState({},"","/admin"):window.history.pushState({},"","/")},ee=!S.token&&!S.pairCode&&A!=="connected",T=A==="error"&&(["auth_required","unauthorized","device_revoked"].includes(R||"")||/auth|unauthor|forbidden|permission|token|pair/i.test(E||"")),_=ee||T,[P,le]=x.useState(!_);x.useEffect(()=>{_||le(!0)},[_]),x.useEffect(()=>{H&&(o(!1),le(!0),a("terminal"))},[H]);const ve=r==="terminal"&&!_,Se=fe=>({visibility:fe?"visible":"hidden",opacity:fe?1:0,pointerEvents:fe?"auto":"none",zIndex:fe?1:0});return u.jsxs("div",{"data-testid":"app-shell",style:z?{paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0,className:"flex h-full w-full select-none flex-col overflow-hidden bg-tui-crust font-mono text-tui text-tui-text",onContextMenu:fe=>{fe.preventDefault(),fe.stopPropagation()},children:[!z&&u.jsx(Jx,{currentView:r,onNavigate:de,showAdminEntry:G,onOpenPairing:()=>X(!1),onOpenSettings:()=>m(!0),onToggleVirtualKeyboard:()=>v(!b),isVirtualKeyboardOpen:b}),!z&&!_&&u.jsx(Wx,{}),u.jsxs("div",{className:"flex-1 min-h-0 w-full overflow-hidden relative",children:[P&&u.jsxs("div",{"data-testid":"terminal-layer",className:`absolute ${z?"inset-x-0 top-12 bottom-11":"inset-0"} flex flex-col min-h-0 w-full overflow-hidden`,style:Se(ve),"aria-hidden":!ve,children:[u.jsx(jS,{isActive:ve}),!z&&u.jsx(LS,{isOpen:b,onClose:()=>v(!1)}),u.jsx(zS,{compact:z})]}),r==="terminal"&&_&&u.jsx("div",{"data-testid":"onboarding-layer",className:"absolute inset-0 flex flex-col min-h-0 w-full overflow-hidden z-10",children:u.jsx(kS,{onPairedSuccess:()=>{}})}),r==="admin"&&u.jsx("div",{"data-testid":"admin-layer",className:"absolute inset-0 flex flex-col min-h-0 w-full overflow-hidden z-20",children:u.jsx(PS,{onBackToTerminal:()=>de("terminal"),onOpenPairing:()=>X(!1)})}),z&&ve&&u.jsx(l1,{onNavigateAdmin:()=>de("admin"),showAdminEntry:G,onOpenPairing:()=>X(!1),onOpenSettings:()=>m(!0),onAddProfile:()=>X(!0)})]}),!z&&r!=="admin"&&u.jsx(qS,{onAddProfile:()=>X(!0)}),u.jsx(US,{isOpen:i,isAddMode:d,onClose:re}),u.jsx(BS,{isOpen:p,onClose:()=>m(!1)}),u.jsx(KS,{})]})}function f1(){return u.jsx(Uv,{children:u.jsx(d1,{})})}const Dg=document.getElementById("root");if(!Dg)throw new Error("Root element not found");Zy.createRoot(Dg).render(u.jsx(dl.StrictMode,{children:u.jsx(f1,{})}));