herdr-remote-relay 0.3.12 → 0.3.13

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.
Files changed (64) hide show
  1. package/bin/herdr-remote-relay.js +20 -20
  2. package/dist/auth-store.d.ts +114 -0
  3. package/dist/auth-store.js +276 -0
  4. package/dist/metrics.d.ts +76 -0
  5. package/dist/metrics.js +249 -0
  6. package/dist/protocol/frames.d.ts +27 -0
  7. package/dist/protocol/frames.js +110 -0
  8. package/dist/protocol/http.d.ts +161 -0
  9. package/dist/protocol/http.js +3 -0
  10. package/dist/protocol/index.d.ts +5 -0
  11. package/dist/protocol/index.js +7 -0
  12. package/dist/protocol/messages.d.ts +321 -0
  13. package/dist/protocol/messages.js +18 -0
  14. package/dist/protocol/paste.d.ts +14 -0
  15. package/dist/protocol/paste.js +50 -0
  16. package/dist/protocol/terminal.d.ts +79 -0
  17. package/dist/protocol/terminal.js +150 -0
  18. package/dist/relay-config.d.ts +74 -0
  19. package/dist/relay-config.js +316 -0
  20. package/dist/relay-server.d.ts +64 -0
  21. package/dist/relay-server.js +194 -0
  22. package/dist/scroll-input.d.ts +17 -0
  23. package/dist/scroll-input.js +124 -0
  24. package/dist/server/client-channel.d.ts +3 -0
  25. package/dist/server/client-channel.js +365 -0
  26. package/dist/server/font-proxy.d.ts +19 -0
  27. package/dist/server/font-proxy.js +155 -0
  28. package/dist/server/host-broadcasts.d.ts +25 -0
  29. package/dist/server/host-broadcasts.js +79 -0
  30. package/dist/server/host-channel.d.ts +3 -0
  31. package/dist/server/host-channel.js +266 -0
  32. package/dist/server/http-api.d.ts +3 -0
  33. package/dist/server/http-api.js +214 -0
  34. package/dist/server/maintenance.d.ts +5 -0
  35. package/dist/server/maintenance.js +64 -0
  36. package/dist/server/requests.d.ts +34 -0
  37. package/dist/server/requests.js +142 -0
  38. package/dist/server/sessions.d.ts +36 -0
  39. package/dist/server/sessions.js +225 -0
  40. package/dist/server/sockets.d.ts +12 -0
  41. package/dist/server/sockets.js +64 -0
  42. package/dist/server/status.d.ts +11 -0
  43. package/dist/server/status.js +95 -0
  44. package/dist/server/transport.d.ts +16 -0
  45. package/dist/server/transport.js +110 -0
  46. package/dist/server/types.d.ts +123 -0
  47. package/dist/server/types.js +3 -0
  48. package/dist/server/version.d.ts +2 -0
  49. package/dist/server/version.js +5 -0
  50. package/dist/state.d.ts +6 -0
  51. package/dist/state.js +47 -0
  52. package/package.json +32 -8
  53. package/web/dist/assets/index-B-5zRmL_.js +61 -0
  54. package/web/dist/assets/{index-CPVUfBt4.css → index-DKt8KLog.css} +1 -1
  55. package/web/dist/assets/{vendor-xterm-Bbu8R_5E.js → vendor-xterm-BhCxil_4.js} +2 -2
  56. package/web/dist/index.html +3 -3
  57. package/src/auth-store.js +0 -256
  58. package/src/metrics.js +0 -241
  59. package/src/relay-config.js +0 -312
  60. package/src/relay-server.js +0 -1799
  61. package/src/scroll-input.js +0 -139
  62. package/src/state.js +0 -47
  63. package/src/stream-frame.js +0 -238
  64. package/web/dist/assets/index-6WucmdNP.js +0 -61
@@ -1,61 +0,0 @@
1
- var Ov=Object.defineProperty;var zv=(l,i,s)=>i in l?Ov(l,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[i]=s;var Z=(l,i,s)=>zv(l,typeof i!="symbol"?i+"":i,s);import{r as lb,g as ab,a as sb}from"./vendor-react-CYSfZuHu.js";import{r as Bv,a as Hv}from"./vendor-xterm-Bbu8R_5E.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const f of c)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function s(c){const f={};return c.integrity&&(f.integrity=c.integrity),c.referrerPolicy&&(f.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?f.credentials="include":c.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function r(c){if(c.ep)return;c.ep=!0;const f=s(c);fetch(c.href,f)}})();var td={exports:{}},ir={};/**
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 Ip;function Uv(){if(Ip)return ir;Ip=1;var l=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function s(r,c,f){var h=null;if(f!==void 0&&(h=""+f),c.key!==void 0&&(h=""+c.key),"key"in c){f={};for(var m in c)m!=="key"&&(f[m]=c[m])}else f=c;return c=f.ref,{$$typeof:l,type:r,key:h,ref:c!==void 0?c:null,props:f}}return ir.Fragment=i,ir.jsx=s,ir.jsxs=s,ir}var Fp;function Kv(){return Fp||(Fp=1,td.exports=Uv()),td.exports}var d=Kv(),S=lb();const Li=ab(S);var nd={exports:{}},lr={},id={exports:{}},ld={};/**
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 Gp;function Iv(){return Gp||(Gp=1,(function(l){function i(k,I){var le=k.length;k.push(I);e:for(;0<le;){var re=le-1>>>1,V=k[re];if(0<c(V,I))k[re]=I,k[le]=V,le=re;else break e}}function s(k){return k.length===0?null:k[0]}function r(k){if(k.length===0)return null;var I=k[0],le=k.pop();if(le!==I){k[0]=le;e:for(var re=0,V=k.length,Re=V>>>1;re<Re;){var Ae=2*(re+1)-1,xe=k[Ae],Se=Ae+1,Le=k[Se];if(0>c(xe,le))Se<V&&0>c(Le,xe)?(k[re]=Le,k[Se]=le,re=Se):(k[re]=xe,k[Ae]=le,re=Ae);else if(Se<V&&0>c(Le,le))k[re]=Le,k[Se]=le,re=Se;else break e}}return I}function c(k,I){var le=k.sortIndex-I.sortIndex;return le!==0?le:k.id-I.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;l.unstable_now=function(){return f.now()}}else{var h=Date,m=h.now();l.unstable_now=function(){return h.now()-m}}var b=[],p=[],y=1,v=null,w=3,T=!1,A=!1,$=!1,R=!1,O=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function se(k){for(var I=s(p);I!==null;){if(I.callback===null)r(p);else if(I.startTime<=k)r(p),I.sortIndex=I.expirationTime,i(b,I);else break;I=s(p)}}function fe(k){if($=!1,se(k),!A)if(s(b)!==null)A=!0,Q||(Q=!0,ie());else{var I=s(p);I!==null&&pe(fe,I.startTime-k)}}var Q=!1,K=-1,q=5,ue=-1;function ye(){return R?!0:!(l.unstable_now()-ue<q)}function Ne(){if(R=!1,Q){var k=l.unstable_now();ue=k;var I=!0;try{e:{A=!1,$&&($=!1,j(K),K=-1),T=!0;var le=w;try{t:{for(se(k),v=s(b);v!==null&&!(v.expirationTime>k&&ye());){var re=v.callback;if(typeof re=="function"){v.callback=null,w=v.priorityLevel;var V=re(v.expirationTime<=k);if(k=l.unstable_now(),typeof V=="function"){v.callback=V,se(k),I=!0;break t}v===s(b)&&r(b),se(k)}else r(b);v=s(b)}if(v!==null)I=!0;else{var Re=s(p);Re!==null&&pe(fe,Re.startTime-k),I=!1}}break e}finally{v=null,w=le,T=!1}I=void 0}}finally{I?ie():Q=!1}}}var ie;if(typeof Y=="function")ie=function(){Y(Ne)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,oe=he.port2;he.port1.onmessage=Ne,ie=function(){oe.postMessage(null)}}else ie=function(){O(Ne,0)};function pe(k,I){K=O(function(){k(l.unstable_now())},I)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(k){k.callback=null},l.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<k?Math.floor(1e3/k):5},l.unstable_getCurrentPriorityLevel=function(){return w},l.unstable_next=function(k){switch(w){case 1:case 2:case 3:var I=3;break;default:I=w}var le=w;w=I;try{return k()}finally{w=le}},l.unstable_requestPaint=function(){R=!0},l.unstable_runWithPriority=function(k,I){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var le=w;w=k;try{return I()}finally{w=le}},l.unstable_scheduleCallback=function(k,I,le){var re=l.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?re+le:re):le=re,k){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=le+V,k={id:y++,callback:I,priorityLevel:k,startTime:le,expirationTime:V,sortIndex:-1},le>re?(k.sortIndex=le,i(p,k),s(b)===null&&k===s(p)&&($?(j(K),K=-1):$=!0,pe(fe,le-re))):(k.sortIndex=V,i(b,k),A||T||(A=!0,Q||(Q=!0,ie()))),k},l.unstable_shouldYield=ye,l.unstable_wrapCallback=function(k){var I=w;return function(){var le=w;w=I;try{return k.apply(this,arguments)}finally{w=le}}}})(ld)),ld}var Yp;function Fv(){return Yp||(Yp=1,id.exports=Iv()),id.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 $p;function Gv(){if($p)return lr;$p=1;var l=Fv(),i=lb(),s=sb();function r(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 c(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 h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function 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(r(188))}function p(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(r(188));return t!==e?null:e}for(var n=e,a=t;;){var o=n.return;if(o===null)break;var u=o.alternate;if(u===null){if(a=o.return,a!==null){n=a;continue}break}if(o.child===u.child){for(u=o.child;u;){if(u===n)return b(o),e;if(u===a)return b(o),t;u=u.sibling}throw Error(r(188))}if(n.return!==a.return)n=o,a=u;else{for(var g=!1,x=o.child;x;){if(x===n){g=!0,n=o,a=u;break}if(x===a){g=!0,a=o,n=u;break}x=x.sibling}if(!g){for(x=u.child;x;){if(x===n){g=!0,n=u,a=o;break}if(x===a){g=!0,a=u,n=o;break}x=x.sibling}if(!g)throw Error(r(189))}}if(n.alternate!==a)throw Error(r(190))}if(n.tag!==3)throw Error(r(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 v=Object.assign,w=Symbol.for("react.element"),T=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),se=Symbol.for("react.forward_ref"),fe=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),K=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),ye=Symbol.for("react.memo_cache_sentinel"),Ne=Symbol.iterator;function ie(e){return e===null||typeof e!="object"?null:(e=Ne&&e[Ne]||e["@@iterator"],typeof e=="function"?e:null)}var he=Symbol.for("react.client.reference");function oe(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===he?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case $:return"Fragment";case O:return"Profiler";case R:return"StrictMode";case fe:return"Suspense";case Q:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case A:return"Portal";case Y:return e.displayName||"Context";case j:return(e._context.displayName||"Context")+".Consumer";case se:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case K:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case q:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}var pe=Array.isArray,k=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},re=[],V=-1;function Re(e){return{current:e}}function Ae(e){0>V||(e.current=re[V],re[V]=null,V--)}function xe(e,t){V++,re[V]=e.current,e.current=t}var Se=Re(null),Le=Re(null),Be=Re(null),ot=Re(null);function Xe(e,t){switch(xe(Be,t),xe(Le,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ae(Se),xe(Se,e)}function ze(){Ae(Se),Ae(Le),Ae(Be)}function yt(e){e.memoizedState!==null&&xe(ot,e);var t=Se.current,n=dp(t,e.type);t!==n&&(xe(Le,e),xe(Se,n))}function Tt(e){Le.current===e&&(Ae(Se),Ae(Le)),ot.current===e&&(Ae(ot),Js._currentValue=le)}var Ue,G;function me(e){if(Ue===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Ue=t&&t[1]||"",G=-1<n.stack.indexOf(`
26
- at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
27
- `+Ue+e+G}var $e=!1;function _t(e,t){if(!e||$e)return"";$e=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(F){var U=F}Reflect.construct(e,[],W)}else{try{W.call()}catch(F){U=F}e.call(W.prototype)}}else{try{throw Error()}catch(F){U=F}(W=e())&&typeof W.catch=="function"&&W.catch(function(){})}}catch(F){if(F&&U&&typeof F.stack=="string")return[F.stack,U.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=a.DetermineComponentFrameRoot(),g=u[0],x=u[1];if(g&&x){var M=g.split(`
28
- `),H=x.split(`
29
- `);for(o=a=0;a<M.length&&!M[a].includes("DetermineComponentFrameRoot");)a++;for(;o<H.length&&!H[o].includes("DetermineComponentFrameRoot");)o++;if(a===M.length||o===H.length)for(a=M.length-1,o=H.length-1;1<=a&&0<=o&&M[a]!==H[o];)o--;for(;1<=a&&0<=o;a--,o--)if(M[a]!==H[o]){if(a!==1||o!==1)do if(a--,o--,0>o||M[a]!==H[o]){var X=`
30
- `+M[a].replace(" at new "," at ");return e.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",e.displayName)),X}while(1<=a&&0<=o);break}}}finally{$e=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?me(n):""}function Kt(e,t){switch(e.tag){case 26:case 27:case 5:return me(e.type);case 16:return me("Lazy");case 13:return e.child!==t&&t!==null?me("Suspense Fallback"):me("Suspense");case 19:return me("SuspenseList");case 0:case 15:return _t(e.type,!1);case 11:return _t(e.type.render,!1);case 1:return _t(e.type,!0);case 31:return me("Activity");default:return""}}function hn(e){try{var t="",n=null;do t+=Kt(e,n),n=e,e=e.return;while(e);return t}catch(a){return`
31
- Error generating stack: `+a.message+`
32
- `+a.stack}}var Yt=Object.prototype.hasOwnProperty,ct=l.unstable_scheduleCallback,Ke=l.unstable_cancelCallback,bn=l.unstable_shouldYield,ut=l.unstable_requestPaint,qe=l.unstable_now,wt=l.unstable_getCurrentPriorityLevel,yn=l.unstable_ImmediatePriority,We=l.unstable_UserBlockingPriority,Pe=l.unstable_NormalPriority,Mt=l.unstable_LowPriority,E=l.unstable_IdlePriority,ce=l.log,de=l.unstable_setDisableYieldValue,_e=null,mt=null;function $t(e){if(typeof ce=="function"&&de(e),mt&&typeof mt.setStrictMode=="function")try{mt.setStrictMode(_e,e)}catch{}}var dt=Math.clz32?Math.clz32:ln,rn=Math.log,Wt=Math.LN2;function ln(e){return e>>>=0,e===0?32:31-(rn(e)/Wt|0)|0}var It=256,Ge=262144,vn=4194304;function Cn(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 jt(e,t,n){var a=e.pendingLanes;if(a===0)return 0;var o=0,u=e.suspendedLanes,g=e.pingedLanes;e=e.warmLanes;var x=a&134217727;return x!==0?(a=x&~u,a!==0?o=Cn(a):(g&=x,g!==0?o=Cn(g):n||(n=x&~e,n!==0&&(o=Cn(n))))):(x=a&~u,x!==0?o=Cn(x):g!==0?o=Cn(g):n||(n=a&~e,n!==0&&(o=Cn(n)))),o===0?0:t!==0&&t!==o&&(t&u)===0&&(u=o&-o,n=t&-t,u>=n||u===32&&(n&4194048)!==0)?t:o}function on(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ga(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 St(){var e=vn;return vn<<=1,(vn&62914560)===0&&(vn=4194304),e}function tl(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function $n(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ba(e,t,n,a,o,u){var g=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 x=e.entanglements,M=e.expirationTimes,H=e.hiddenUpdates;for(n=g&~n;0<n;){var X=31-dt(n),W=1<<X;x[X]=0,M[X]=-1;var U=H[X];if(U!==null)for(H[X]=null,X=0;X<U.length;X++){var F=U[X];F!==null&&(F.lane&=-536870913)}n&=~W}a!==0&&Fl(e,a,0),u!==0&&o===0&&e.tag!==0&&(e.suspendedLanes|=u&~(g&~t))}function Fl(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-dt(t);e.entangledLanes|=t,e.entanglements[a]=e.entanglements[a]|1073741824|n&261930}function nl(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var a=31-dt(n),o=1<<a;o&t|e[a]&t&&(e[a]|=t),n&=~o}}function jn(e,t){var n=t&-t;return n=(n&42)!==0?1:xn(n),(n&(e.suspendedLanes|t))!==0?0:n}function xn(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 qn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function qt(){var e=I.p;return e!==0?e:(e=window.event,e===void 0?32:Dp(e.type))}function ya(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var Dn=Math.random().toString(36).slice(2),Dt="__reactFiber$"+Dn,Jt="__reactProps$"+Dn,On="__reactContainer$"+Dn,bi="__reactEvents$"+Dn,il="__reactListeners$"+Dn,ps="__reactHandles$"+Dn,va="__reactResources$"+Dn,_i="__reactMarker$"+Dn;function Gl(e){delete e[Dt],delete e[Jt],delete e[bi],delete e[il],delete e[ps]}function yi(e){var t=e[Dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[On]||n[Dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=yp(e);e!==null;){if(n=e[Dt])return n;e=yp(e)}return t}e=n,n=e.parentNode}return null}function vi(e){if(e=e[Dt]||e[On]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function xi(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function ai(e){var t=e[va];return t||(t=e[va]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ct(e){e[_i]=!0}var Vn=new Set,wi={};function Xn(e,t){si(e,t),si(e+"Capture",t)}function si(e,t){for(wi[e]=t,e=0;e<t.length;e++)Vn.add(t[e])}var xa=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]*$"),ji={},Yl={};function wa(e){return Yt.call(Yl,e)?!0:Yt.call(ji,e)?!1:xa.test(e)?Yl[e]=!0:(ji[e]=!0,!1)}function Di(e,t,n){if(wa(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var a=t.toLowerCase().slice(0,5);if(a!=="data-"&&a!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Si(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 z(e,t,n,a){if(a===null)e.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+a)}}function C(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function D(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function te(e,t,n){var a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var o=a.get,u=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(g){n=""+g,u.call(this,g)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return n},setValue:function(g){n=""+g},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function J(e){if(!e._valueTracker){var t=D(e)?"checked":"value";e._valueTracker=te(e,t,""+e[t])}}function be(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=D(e)?e.checked?"true":"false":e.value),e=a,e!==n?(t.setValue(e),!0):!1}function ee(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 vt=/[\n"\\]/g;function je(e){return e.replace(vt,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function At(e,t,n,a,o,u,g,x){e.name="",g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"?e.type=g:e.removeAttribute("type"),t!=null?g==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+C(t)):e.value!==""+C(t)&&(e.value=""+C(t)):g!=="submit"&&g!=="reset"||e.removeAttribute("value"),t!=null?Ot(e,g,C(t)):n!=null?Ot(e,g,C(n)):a!=null&&e.removeAttribute("value"),o==null&&u!=null&&(e.defaultChecked=!!u),o!=null&&(e.checked=o&&typeof o!="function"&&typeof o!="symbol"),x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?e.name=""+C(x):e.removeAttribute("name")}function nt(e,t,n,a,o,u,g,x){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||n!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){J(e);return}n=n!=null?""+C(n):"",t=t!=null?""+C(t):n,x||t===e.value||(e.value=t),e.defaultValue=t}a=a??o,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=x?e.checked:!!a,e.defaultChecked=!!a,g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.name=g),J(e)}function Ot(e,t,n){t==="number"&&ee(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function mn(e,t,n,a){if(e=e.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<e.length;n++)o=t.hasOwnProperty("$"+e[n].value),e[n].selected!==o&&(e[n].selected=o),o&&a&&(e[n].defaultSelected=!0)}else{for(n=""+C(n),t=null,o=0;o<e.length;o++){if(e[o].value===n){e[o].selected=!0,a&&(e[o].defaultSelected=!0);return}t!==null||e[o].disabled||(t=e[o])}t!==null&&(t.selected=!0)}}function Oi(e,t,n){if(t!=null&&(t=""+C(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+C(n):""}function $l(e,t,n,a){if(t==null){if(a!=null){if(n!=null)throw Error(r(92));if(pe(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}n==null&&(n=""),t=n}n=C(t),e.defaultValue=n,a=e.textContent,a===n&&a!==""&&a!==null&&(e.value=a),J(e)}function ri(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ll=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 wr(e,t,n){var a=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?a?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":a?e.setProperty(t,n):typeof n!="number"||n===0||ll.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Sr(e,t,n){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,n!=null){for(var a in n)!n.hasOwnProperty(a)||t!=null&&t.hasOwnProperty(a)||(a.indexOf("--")===0?e.setProperty(a,""):a==="float"?e.cssFloat="":e[a]="");for(var o in t)a=t[o],t.hasOwnProperty(o)&&n[o]!==a&&wr(e,o,a)}else for(var u in t)t.hasOwnProperty(u)&&wr(e,u,t[u])}function gs(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 ic=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"]]),lc=/^[\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 Sa(e){return lc.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function oi(){}var bs=null;function pn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var al=null,sl=null;function rl(e){var t=vi(e);if(t&&(e=t.stateNode)){var n=e[Jt]||null;e:switch(e=t.stateNode,t.type){case"input":if(At(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="'+je(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var o=a[Jt]||null;if(!o)throw Error(r(90));At(a,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name)}}for(t=0;t<n.length;t++)a=n[t],a.form===e.form&&be(a)}break e;case"textarea":Oi(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&mn(e,!!n.multiple,t,!1)}}}var zn=!1;function ys(e,t,n){if(zn)return e(t,n);zn=!0;try{var a=e(t);return a}finally{if(zn=!1,(al!==null||sl!==null)&&(lo(),al&&(t=al,e=sl,sl=al=null,rl(t),e)))for(t=0;t<e.length;t++)rl(e[t])}}function ol(e,t){var n=e.stateNode;if(n===null)return null;var a=n[Jt]||null;if(a===null)return null;n=a[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":(a=!a.disabled)||(e=e.type,a=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!a;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(r(231,t,typeof n));return n}var Tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cl=!1;if(Tn)try{var Ci={};Object.defineProperty(Ci,"passive",{get:function(){cl=!0}}),window.addEventListener("test",Ci,Ci),window.removeEventListener("test",Ci,Ci)}catch{cl=!1}var ci=null,Ca=null,ql=null;function ae(){if(ql)return ql;var e,t=Ca,n=t.length,a,o="value"in ci?ci.value:ci.textContent,u=o.length;for(e=0;e<n&&t[e]===o[e];e++);var g=n-e;for(a=1;a<=g&&t[n-a]===o[u-a];a++);return ql=o.slice(e,1<a?1-a:void 0)}function ge(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 He(){return!0}function zt(){return!1}function at(e){function t(n,a,o,u,g){this._reactName=n,this._targetInst=o,this.type=a,this.nativeEvent=u,this.target=g,this.currentTarget=null;for(var x in e)e.hasOwnProperty(x)&&(n=e[x],this[x]=n?n(u):u[x]);return this.isDefaultPrevented=(u.defaultPrevented!=null?u.defaultPrevented:u.returnValue===!1)?He:zt,this.isPropagationStopped=zt,this}return v(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=He)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=He)},persist:function(){},isPersistent:He}),t}var Rt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ee=at(Rt),en=v({},Rt,{view:0,detail:0}),Bt=at(en),Mn,ui,Bn,Pn=v({},en,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sc,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!==Bn&&(Bn&&e.type==="mousemove"?(Mn=e.screenX-Bn.screenX,ui=e.screenY-Bn.screenY):ui=Mn=0,Bn=e),Mn)},movementY:function(e){return"movementY"in e?e.movementY:ui}}),vs=at(Pn),Dy=v({},Pn,{dataTransfer:0}),Oy=at(Dy),zy=v({},en,{relatedTarget:0}),ac=at(zy),By=v({},Rt,{animationName:0,elapsedTime:0,pseudoElement:0}),Hy=at(By),Uy=v({},Rt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Ky=at(Uy),Iy=v({},Rt,{data:0}),mf=at(Iy),Fy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gy={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"},Yy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $y(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Yy[e])?!!t[e]:!1}function sc(){return $y}var qy=v({},en,{key:function(e){if(e.key){var t=Fy[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ge(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Gy[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sc,charCode:function(e){return e.type==="keypress"?ge(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ge(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Vy=at(qy),Xy=v({},Pn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),pf=at(Xy),Py=v({},en,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sc}),Zy=at(Py),Qy=v({},Rt,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wy=at(Qy),Jy=v({},Pn,{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}),e0=at(Jy),t0=v({},Rt,{newState:0,oldState:0}),n0=at(t0),i0=[9,13,27,32],rc=Tn&&"CompositionEvent"in window,xs=null;Tn&&"documentMode"in document&&(xs=document.documentMode);var l0=Tn&&"TextEvent"in window&&!xs,gf=Tn&&(!rc||xs&&8<xs&&11>=xs),bf=" ",yf=!1;function vf(e,t){switch(e){case"keyup":return i0.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ta=!1;function a0(e,t){switch(e){case"compositionend":return xf(t);case"keypress":return t.which!==32?null:(yf=!0,bf);case"textInput":return e=t.data,e===bf&&yf?null:e;default:return null}}function s0(e,t){if(Ta)return e==="compositionend"||!rc&&vf(e,t)?(e=ae(),ql=Ca=ci=null,Ta=!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 gf&&t.locale!=="ko"?null:t.data;default:return null}}var r0={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function wf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!r0[e.type]:t==="textarea"}function Sf(e,t,n,a){al?sl?sl.push(a):sl=[a]:al=a,t=fo(t,"onChange"),0<t.length&&(n=new Ee("onChange","change",null,n,a),e.push({event:n,listeners:t}))}var ws=null,Ss=null;function o0(e){lp(e,0)}function Cr(e){var t=xi(e);if(be(t))return e}function Cf(e,t){if(e==="change")return t}var Tf=!1;if(Tn){var oc;if(Tn){var cc="oninput"in document;if(!cc){var Mf=document.createElement("div");Mf.setAttribute("oninput","return;"),cc=typeof Mf.oninput=="function"}oc=cc}else oc=!1;Tf=oc&&(!document.documentMode||9<document.documentMode)}function Af(){ws&&(ws.detachEvent("onpropertychange",Ef),Ss=ws=null)}function Ef(e){if(e.propertyName==="value"&&Cr(Ss)){var t=[];Sf(t,Ss,e,pn(e)),ys(o0,t)}}function c0(e,t,n){e==="focusin"?(Af(),ws=t,Ss=n,ws.attachEvent("onpropertychange",Ef)):e==="focusout"&&Af()}function u0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Cr(Ss)}function d0(e,t){if(e==="click")return Cr(t)}function f0(e,t){if(e==="input"||e==="change")return Cr(t)}function h0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Hn=typeof Object.is=="function"?Object.is:h0;function Cs(e,t){if(Hn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var o=n[a];if(!Yt.call(t,o)||!Hn(e[o],t[o]))return!1}return!0}function Nf(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function kf(e,t){var n=Nf(e);e=0;for(var a;n;){if(n.nodeType===3){if(a=e+n.textContent.length,e<=t&&a>=t)return{node:n,offset:t-e};e=a}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Nf(n)}}function Rf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Rf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Lf(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ee(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=ee(e.document)}return t}function uc(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 m0=Tn&&"documentMode"in document&&11>=document.documentMode,Ma=null,dc=null,Ts=null,fc=!1;function _f(e,t,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fc||Ma==null||Ma!==ee(a)||(a=Ma,"selectionStart"in a&&uc(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Ts&&Cs(Ts,a)||(Ts=a,a=fo(dc,"onSelect"),0<a.length&&(t=new Ee("onSelect","select",null,t,n),e.push({event:t,listeners:a}),t.target=Ma)))}function Vl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Aa={animationend:Vl("Animation","AnimationEnd"),animationiteration:Vl("Animation","AnimationIteration"),animationstart:Vl("Animation","AnimationStart"),transitionrun:Vl("Transition","TransitionRun"),transitionstart:Vl("Transition","TransitionStart"),transitioncancel:Vl("Transition","TransitionCancel"),transitionend:Vl("Transition","TransitionEnd")},hc={},jf={};Tn&&(jf=document.createElement("div").style,"AnimationEvent"in window||(delete Aa.animationend.animation,delete Aa.animationiteration.animation,delete Aa.animationstart.animation),"TransitionEvent"in window||delete Aa.transitionend.transition);function Xl(e){if(hc[e])return hc[e];if(!Aa[e])return e;var t=Aa[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in jf)return hc[e]=t[n];return e}var Df=Xl("animationend"),Of=Xl("animationiteration"),zf=Xl("animationstart"),p0=Xl("transitionrun"),g0=Xl("transitionstart"),b0=Xl("transitioncancel"),Bf=Xl("transitionend"),Hf=new Map,mc="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(" ");mc.push("scrollEnd");function di(e,t){Hf.set(e,t),Xn(t,[e])}var Tr=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)},Zn=[],Ea=0,pc=0;function Mr(){for(var e=Ea,t=pc=Ea=0;t<e;){var n=Zn[t];Zn[t++]=null;var a=Zn[t];Zn[t++]=null;var o=Zn[t];Zn[t++]=null;var u=Zn[t];if(Zn[t++]=null,a!==null&&o!==null){var g=a.pending;g===null?o.next=o:(o.next=g.next,g.next=o),a.pending=o}u!==0&&Uf(n,o,u)}}function Ar(e,t,n,a){Zn[Ea++]=e,Zn[Ea++]=t,Zn[Ea++]=n,Zn[Ea++]=a,pc|=a,e.lanes|=a,e=e.alternate,e!==null&&(e.lanes|=a)}function gc(e,t,n,a){return Ar(e,t,n,a),Er(e)}function Pl(e,t){return Ar(e,null,null,t),Er(e)}function Uf(e,t,n){e.lanes|=n;var a=e.alternate;a!==null&&(a.lanes|=n);for(var o=!1,u=e.return;u!==null;)u.childLanes|=n,a=u.alternate,a!==null&&(a.childLanes|=n),u.tag===22&&(e=u.stateNode,e===null||e._visibility&1||(o=!0)),e=u,u=u.return;return e.tag===3?(u=e.stateNode,o&&t!==null&&(o=31-dt(n),e=u.hiddenUpdates,a=e[o],a===null?e[o]=[t]:a.push(t),t.lane=n|536870912),u):null}function Er(e){if(50<qs)throw qs=0,Mu=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Na={};function y0(e,t,n,a){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=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Un(e,t,n,a){return new y0(e,t,n,a)}function bc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function zi(e,t){var n=e.alternate;return n===null?(n=Un(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 Kf(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 Nr(e,t,n,a,o,u){var g=0;if(a=e,typeof e=="function")bc(e)&&(g=1);else if(typeof e=="string")g=Cv(e,n,Se.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ue:return e=Un(31,n,t,o),e.elementType=ue,e.lanes=u,e;case $:return Zl(n.children,o,u,t);case R:g=8,o|=24;break;case O:return e=Un(12,n,t,o|2),e.elementType=O,e.lanes=u,e;case fe:return e=Un(13,n,t,o),e.elementType=fe,e.lanes=u,e;case Q:return e=Un(19,n,t,o),e.elementType=Q,e.lanes=u,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Y:g=10;break e;case j:g=9;break e;case se:g=11;break e;case K:g=14;break e;case q:g=16,a=null;break e}g=29,n=Error(r(130,e===null?"null":typeof e,"")),a=null}return t=Un(g,n,t,o),t.elementType=e,t.type=a,t.lanes=u,t}function Zl(e,t,n,a){return e=Un(7,e,a,t),e.lanes=n,e}function yc(e,t,n){return e=Un(6,e,null,t),e.lanes=n,e}function If(e){var t=Un(18,null,null,0);return t.stateNode=e,t}function vc(e,t,n){return t=Un(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ff=new WeakMap;function Qn(e,t){if(typeof e=="object"&&e!==null){var n=Ff.get(e);return n!==void 0?n:(t={value:e,source:t,stack:hn(t)},Ff.set(e,t),t)}return{value:e,source:t,stack:hn(t)}}var ka=[],Ra=0,kr=null,Ms=0,Wn=[],Jn=0,ul=null,Ti=1,Mi="";function Bi(e,t){ka[Ra++]=Ms,ka[Ra++]=kr,kr=e,Ms=t}function Gf(e,t,n){Wn[Jn++]=Ti,Wn[Jn++]=Mi,Wn[Jn++]=ul,ul=e;var a=Ti;e=Mi;var o=32-dt(a)-1;a&=~(1<<o),n+=1;var u=32-dt(t)+o;if(30<u){var g=o-o%5;u=(a&(1<<g)-1).toString(32),a>>=g,o-=g,Ti=1<<32-dt(t)+o|n<<o|a,Mi=u+e}else Ti=1<<u|n<<o|a,Mi=e}function xc(e){e.return!==null&&(Bi(e,1),Gf(e,1,0))}function wc(e){for(;e===kr;)kr=ka[--Ra],ka[Ra]=null,Ms=ka[--Ra],ka[Ra]=null;for(;e===ul;)ul=Wn[--Jn],Wn[Jn]=null,Mi=Wn[--Jn],Wn[Jn]=null,Ti=Wn[--Jn],Wn[Jn]=null}function Yf(e,t){Wn[Jn++]=Ti,Wn[Jn++]=Mi,Wn[Jn++]=ul,Ti=t.id,Mi=t.overflow,ul=e}var cn=null,Et=null,tt=!1,dl=null,ei=!1,Sc=Error(r(519));function fl(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw As(Qn(t,e)),Sc}function $f(e){var t=e.stateNode,n=e.type,a=e.memoizedProps;switch(t[Dt]=e,t[Jt]=a,n){case"dialog":Qe("cancel",t),Qe("close",t);break;case"iframe":case"object":case"embed":Qe("load",t);break;case"video":case"audio":for(n=0;n<Xs.length;n++)Qe(Xs[n],t);break;case"source":Qe("error",t);break;case"img":case"image":case"link":Qe("error",t),Qe("load",t);break;case"details":Qe("toggle",t);break;case"input":Qe("invalid",t),nt(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":Qe("invalid",t);break;case"textarea":Qe("invalid",t),$l(t,a.value,a.defaultValue,a.children)}n=a.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||a.suppressHydrationWarning===!0||op(t.textContent,n)?(a.popover!=null&&(Qe("beforetoggle",t),Qe("toggle",t)),a.onScroll!=null&&Qe("scroll",t),a.onScrollEnd!=null&&Qe("scrollend",t),a.onClick!=null&&(t.onclick=oi),t=!0):t=!1,t||fl(e,!0)}function qf(e){for(cn=e.return;cn;)switch(cn.tag){case 5:case 31:case 13:ei=!1;return;case 27:case 3:ei=!0;return;default:cn=cn.return}}function La(e){if(e!==cn)return!1;if(!tt)return qf(e),tt=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||Ku(e.type,e.memoizedProps)),n=!n),n&&Et&&fl(e),qf(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Et=bp(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Et=bp(e)}else t===27?(t=Et,Al(e.type)?(e=$u,$u=null,Et=e):Et=t):Et=cn?ni(e.stateNode.nextSibling):null;return!0}function Ql(){Et=cn=null,tt=!1}function Cc(){var e=dl;return e!==null&&(kn===null?kn=e:kn.push.apply(kn,e),dl=null),e}function As(e){dl===null?dl=[e]:dl.push(e)}var Tc=Re(null),Wl=null,Hi=null;function hl(e,t,n){xe(Tc,t._currentValue),t._currentValue=n}function Ui(e){e._currentValue=Tc.current,Ae(Tc)}function Mc(e,t,n){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function Ac(e,t,n,a){var o=e.child;for(o!==null&&(o.return=e);o!==null;){var u=o.dependencies;if(u!==null){var g=o.child;u=u.firstContext;e:for(;u!==null;){var x=u;u=o;for(var M=0;M<t.length;M++)if(x.context===t[M]){u.lanes|=n,x=u.alternate,x!==null&&(x.lanes|=n),Mc(u.return,n,e),a||(g=null);break e}u=x.next}}else if(o.tag===18){if(g=o.return,g===null)throw Error(r(341));g.lanes|=n,u=g.alternate,u!==null&&(u.lanes|=n),Mc(g,n,e),g=null}else g=o.child;if(g!==null)g.return=o;else for(g=o;g!==null;){if(g===e){g=null;break}if(o=g.sibling,o!==null){o.return=g.return,g=o;break}g=g.return}o=g}}function _a(e,t,n,a){e=null;for(var o=t,u=!1;o!==null;){if(!u){if((o.flags&524288)!==0)u=!0;else if((o.flags&262144)!==0)break}if(o.tag===10){var g=o.alternate;if(g===null)throw Error(r(387));if(g=g.memoizedProps,g!==null){var x=o.type;Hn(o.pendingProps.value,g.value)||(e!==null?e.push(x):e=[x])}}else if(o===ot.current){if(g=o.alternate,g===null)throw Error(r(387));g.memoizedState.memoizedState!==o.memoizedState.memoizedState&&(e!==null?e.push(Js):e=[Js])}o=o.return}e!==null&&Ac(t,e,n,a),t.flags|=262144}function Rr(e){for(e=e.firstContext;e!==null;){if(!Hn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Jl(e){Wl=e,Hi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function un(e){return Vf(Wl,e)}function Lr(e,t){return Wl===null&&Jl(e),Vf(e,t)}function Vf(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Hi===null){if(e===null)throw Error(r(308));Hi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Hi=Hi.next=t;return n}var v0=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,a){e.push(a)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},x0=l.unstable_scheduleCallback,w0=l.unstable_NormalPriority,Vt={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ec(){return{controller:new v0,data:new Map,refCount:0}}function Es(e){e.refCount--,e.refCount===0&&x0(w0,function(){e.controller.abort()})}var Ns=null,Nc=0,ja=0,Da=null;function S0(e,t){if(Ns===null){var n=Ns=[];Nc=0,ja=Lu(),Da={status:"pending",value:void 0,then:function(a){n.push(a)}}}return Nc++,t.then(Xf,Xf),t}function Xf(){if(--Nc===0&&Ns!==null){Da!==null&&(Da.status="fulfilled");var e=Ns;Ns=null,ja=0,Da=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function C0(e,t){var n=[],a={status:"pending",value:null,reason:null,then:function(o){n.push(o)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var o=0;o<n.length;o++)(0,n[o])(t)},function(o){for(a.status="rejected",a.reason=o,o=0;o<n.length;o++)(0,n[o])(void 0)}),a}var Pf=k.S;k.S=function(e,t){_m=qe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&S0(e,t),Pf!==null&&Pf(e,t)};var ea=Re(null);function kc(){var e=ea.current;return e!==null?e:xt.pooledCache}function _r(e,t){t===null?xe(ea,ea.current):xe(ea,t.pool)}function Zf(){var e=kc();return e===null?null:{parent:Vt._currentValue,pool:e}}var Oa=Error(r(460)),Rc=Error(r(474)),jr=Error(r(542)),Dr={then:function(){}};function Qf(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Wf(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(oi,oi),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,eh(e),e;default:if(typeof t.status=="string")t.then(oi,oi);else{if(e=xt,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(a){if(t.status==="pending"){var o=t;o.status="fulfilled",o.value=a}},function(a){if(t.status==="pending"){var o=t;o.status="rejected",o.reason=a}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,eh(e),e}throw na=t,Oa}}function ta(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(na=n,Oa):n}}var na=null;function Jf(){if(na===null)throw Error(r(459));var e=na;return na=null,e}function eh(e){if(e===Oa||e===jr)throw Error(r(483))}var za=null,ks=0;function Or(e){var t=ks;return ks+=1,za===null&&(za=[]),Wf(za,e,t)}function Rs(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function zr(e,t){throw t.$$typeof===w?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function th(e){function t(_,N){if(e){var B=_.deletions;B===null?(_.deletions=[N],_.flags|=16):B.push(N)}}function n(_,N){if(!e)return null;for(;N!==null;)t(_,N),N=N.sibling;return null}function a(_){for(var N=new Map;_!==null;)_.key!==null?N.set(_.key,_):N.set(_.index,_),_=_.sibling;return N}function o(_,N){return _=zi(_,N),_.index=0,_.sibling=null,_}function u(_,N,B){return _.index=B,e?(B=_.alternate,B!==null?(B=B.index,B<N?(_.flags|=67108866,N):B):(_.flags|=67108866,N)):(_.flags|=1048576,N)}function g(_){return e&&_.alternate===null&&(_.flags|=67108866),_}function x(_,N,B,P){return N===null||N.tag!==6?(N=yc(B,_.mode,P),N.return=_,N):(N=o(N,B),N.return=_,N)}function M(_,N,B,P){var ke=B.type;return ke===$?X(_,N,B.props.children,P,B.key):N!==null&&(N.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===q&&ta(ke)===N.type)?(N=o(N,B.props),Rs(N,B),N.return=_,N):(N=Nr(B.type,B.key,B.props,null,_.mode,P),Rs(N,B),N.return=_,N)}function H(_,N,B,P){return N===null||N.tag!==4||N.stateNode.containerInfo!==B.containerInfo||N.stateNode.implementation!==B.implementation?(N=vc(B,_.mode,P),N.return=_,N):(N=o(N,B.children||[]),N.return=_,N)}function X(_,N,B,P,ke){return N===null||N.tag!==7?(N=Zl(B,_.mode,P,ke),N.return=_,N):(N=o(N,B),N.return=_,N)}function W(_,N,B){if(typeof N=="string"&&N!==""||typeof N=="number"||typeof N=="bigint")return N=yc(""+N,_.mode,B),N.return=_,N;if(typeof N=="object"&&N!==null){switch(N.$$typeof){case T:return B=Nr(N.type,N.key,N.props,null,_.mode,B),Rs(B,N),B.return=_,B;case A:return N=vc(N,_.mode,B),N.return=_,N;case q:return N=ta(N),W(_,N,B)}if(pe(N)||ie(N))return N=Zl(N,_.mode,B,null),N.return=_,N;if(typeof N.then=="function")return W(_,Or(N),B);if(N.$$typeof===Y)return W(_,Lr(_,N),B);zr(_,N)}return null}function U(_,N,B,P){var ke=N!==null?N.key:null;if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return ke!==null?null:x(_,N,""+B,P);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case T:return B.key===ke?M(_,N,B,P):null;case A:return B.key===ke?H(_,N,B,P):null;case q:return B=ta(B),U(_,N,B,P)}if(pe(B)||ie(B))return ke!==null?null:X(_,N,B,P,null);if(typeof B.then=="function")return U(_,N,Or(B),P);if(B.$$typeof===Y)return U(_,N,Lr(_,B),P);zr(_,B)}return null}function F(_,N,B,P,ke){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return _=_.get(B)||null,x(N,_,""+P,ke);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case T:return _=_.get(P.key===null?B:P.key)||null,M(N,_,P,ke);case A:return _=_.get(P.key===null?B:P.key)||null,H(N,_,P,ke);case q:return P=ta(P),F(_,N,B,P,ke)}if(pe(P)||ie(P))return _=_.get(B)||null,X(N,_,P,ke,null);if(typeof P.then=="function")return F(_,N,B,Or(P),ke);if(P.$$typeof===Y)return F(_,N,B,Lr(N,P),ke);zr(N,P)}return null}function Te(_,N,B,P){for(var ke=null,it=null,Me=N,Ye=N=0,et=null;Me!==null&&Ye<B.length;Ye++){Me.index>Ye?(et=Me,Me=null):et=Me.sibling;var lt=U(_,Me,B[Ye],P);if(lt===null){Me===null&&(Me=et);break}e&&Me&&lt.alternate===null&&t(_,Me),N=u(lt,N,Ye),it===null?ke=lt:it.sibling=lt,it=lt,Me=et}if(Ye===B.length)return n(_,Me),tt&&Bi(_,Ye),ke;if(Me===null){for(;Ye<B.length;Ye++)Me=W(_,B[Ye],P),Me!==null&&(N=u(Me,N,Ye),it===null?ke=Me:it.sibling=Me,it=Me);return tt&&Bi(_,Ye),ke}for(Me=a(Me);Ye<B.length;Ye++)et=F(Me,_,Ye,B[Ye],P),et!==null&&(e&&et.alternate!==null&&Me.delete(et.key===null?Ye:et.key),N=u(et,N,Ye),it===null?ke=et:it.sibling=et,it=et);return e&&Me.forEach(function(Ll){return t(_,Ll)}),tt&&Bi(_,Ye),ke}function De(_,N,B,P){if(B==null)throw Error(r(151));for(var ke=null,it=null,Me=N,Ye=N=0,et=null,lt=B.next();Me!==null&&!lt.done;Ye++,lt=B.next()){Me.index>Ye?(et=Me,Me=null):et=Me.sibling;var Ll=U(_,Me,lt.value,P);if(Ll===null){Me===null&&(Me=et);break}e&&Me&&Ll.alternate===null&&t(_,Me),N=u(Ll,N,Ye),it===null?ke=Ll:it.sibling=Ll,it=Ll,Me=et}if(lt.done)return n(_,Me),tt&&Bi(_,Ye),ke;if(Me===null){for(;!lt.done;Ye++,lt=B.next())lt=W(_,lt.value,P),lt!==null&&(N=u(lt,N,Ye),it===null?ke=lt:it.sibling=lt,it=lt);return tt&&Bi(_,Ye),ke}for(Me=a(Me);!lt.done;Ye++,lt=B.next())lt=F(Me,_,Ye,lt.value,P),lt!==null&&(e&&lt.alternate!==null&&Me.delete(lt.key===null?Ye:lt.key),N=u(lt,N,Ye),it===null?ke=lt:it.sibling=lt,it=lt);return e&&Me.forEach(function(Dv){return t(_,Dv)}),tt&&Bi(_,Ye),ke}function bt(_,N,B,P){if(typeof B=="object"&&B!==null&&B.type===$&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case T:e:{for(var ke=B.key;N!==null;){if(N.key===ke){if(ke=B.type,ke===$){if(N.tag===7){n(_,N.sibling),P=o(N,B.props.children),P.return=_,_=P;break e}}else if(N.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===q&&ta(ke)===N.type){n(_,N.sibling),P=o(N,B.props),Rs(P,B),P.return=_,_=P;break e}n(_,N);break}else t(_,N);N=N.sibling}B.type===$?(P=Zl(B.props.children,_.mode,P,B.key),P.return=_,_=P):(P=Nr(B.type,B.key,B.props,null,_.mode,P),Rs(P,B),P.return=_,_=P)}return g(_);case A:e:{for(ke=B.key;N!==null;){if(N.key===ke)if(N.tag===4&&N.stateNode.containerInfo===B.containerInfo&&N.stateNode.implementation===B.implementation){n(_,N.sibling),P=o(N,B.children||[]),P.return=_,_=P;break e}else{n(_,N);break}else t(_,N);N=N.sibling}P=vc(B,_.mode,P),P.return=_,_=P}return g(_);case q:return B=ta(B),bt(_,N,B,P)}if(pe(B))return Te(_,N,B,P);if(ie(B)){if(ke=ie(B),typeof ke!="function")throw Error(r(150));return B=ke.call(B),De(_,N,B,P)}if(typeof B.then=="function")return bt(_,N,Or(B),P);if(B.$$typeof===Y)return bt(_,N,Lr(_,B),P);zr(_,B)}return typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint"?(B=""+B,N!==null&&N.tag===6?(n(_,N.sibling),P=o(N,B),P.return=_,_=P):(n(_,N),P=yc(B,_.mode,P),P.return=_,_=P),g(_)):n(_,N)}return function(_,N,B,P){try{ks=0;var ke=bt(_,N,B,P);return za=null,ke}catch(Me){if(Me===Oa||Me===jr)throw Me;var it=Un(29,Me,null,_.mode);return it.lanes=P,it.return=_,it}finally{}}}var ia=th(!0),nh=th(!1),ml=!1;function Lc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _c(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 pl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function gl(e,t,n){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(st&2)!==0){var o=a.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),a.pending=t,t=Er(e),Uf(e,null,n),t}return Ar(e,a,t,n),Er(e)}function Ls(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,nl(e,n)}}function jc(e,t){var n=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var o=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var g={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};u===null?o=u=g:u=u.next=g,n=n.next}while(n!==null);u===null?o=u=t:u=u.next=t}else o=u=t;n={baseState:a.baseState,firstBaseUpdate:o,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Dc=!1;function _s(){if(Dc){var e=Da;if(e!==null)throw e}}function js(e,t,n,a){Dc=!1;var o=e.updateQueue;ml=!1;var u=o.firstBaseUpdate,g=o.lastBaseUpdate,x=o.shared.pending;if(x!==null){o.shared.pending=null;var M=x,H=M.next;M.next=null,g===null?u=H:g.next=H,g=M;var X=e.alternate;X!==null&&(X=X.updateQueue,x=X.lastBaseUpdate,x!==g&&(x===null?X.firstBaseUpdate=H:x.next=H,X.lastBaseUpdate=M))}if(u!==null){var W=o.baseState;g=0,X=H=M=null,x=u;do{var U=x.lane&-536870913,F=U!==x.lane;if(F?(Je&U)===U:(a&U)===U){U!==0&&U===ja&&(Dc=!0),X!==null&&(X=X.next={lane:0,tag:x.tag,payload:x.payload,callback:null,next:null});e:{var Te=e,De=x;U=t;var bt=n;switch(De.tag){case 1:if(Te=De.payload,typeof Te=="function"){W=Te.call(bt,W,U);break e}W=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=De.payload,U=typeof Te=="function"?Te.call(bt,W,U):Te,U==null)break e;W=v({},W,U);break e;case 2:ml=!0}}U=x.callback,U!==null&&(e.flags|=64,F&&(e.flags|=8192),F=o.callbacks,F===null?o.callbacks=[U]:F.push(U))}else F={lane:U,tag:x.tag,payload:x.payload,callback:x.callback,next:null},X===null?(H=X=F,M=W):X=X.next=F,g|=U;if(x=x.next,x===null){if(x=o.shared.pending,x===null)break;F=x,x=F.next,F.next=null,o.lastBaseUpdate=F,o.shared.pending=null}}while(!0);X===null&&(M=W),o.baseState=M,o.firstBaseUpdate=H,o.lastBaseUpdate=X,u===null&&(o.shared.lanes=0),wl|=g,e.lanes=g,e.memoizedState=W}}function ih(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function lh(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)ih(n[e],t)}var Ba=Re(null),Br=Re(0);function ah(e,t){e=Xi,xe(Br,e),xe(Ba,t),Xi=e|t.baseLanes}function Oc(){xe(Br,Xi),xe(Ba,Ba.current)}function zc(){Xi=Br.current,Ae(Ba),Ae(Br)}var Kn=Re(null),ti=null;function bl(e){var t=e.alternate;xe(Ft,Ft.current&1),xe(Kn,e),ti===null&&(t===null||Ba.current!==null||t.memoizedState!==null)&&(ti=e)}function Bc(e){xe(Ft,Ft.current),xe(Kn,e),ti===null&&(ti=e)}function sh(e){e.tag===22?(xe(Ft,Ft.current),xe(Kn,e),ti===null&&(ti=e)):yl()}function yl(){xe(Ft,Ft.current),xe(Kn,Kn.current)}function In(e){Ae(Kn),ti===e&&(ti=null),Ae(Ft)}var Ft=Re(0);function Hr(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Gu(n)||Yu(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 Ki=0,Ie=null,pt=null,Xt=null,Ur=!1,Ha=!1,la=!1,Kr=0,Ds=0,Ua=null,T0=0;function Ht(){throw Error(r(321))}function Hc(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Hn(e[n],t[n]))return!1;return!0}function Uc(e,t,n,a,o,u){return Ki=u,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,k.H=e===null||e.memoizedState===null?Gh:eu,la=!1,u=n(a,o),la=!1,Ha&&(u=oh(t,n,a,o)),rh(e),u}function rh(e){k.H=Bs;var t=pt!==null&&pt.next!==null;if(Ki=0,Xt=pt=Ie=null,Ur=!1,Ds=0,Ua=null,t)throw Error(r(300));e===null||Pt||(e=e.dependencies,e!==null&&Rr(e)&&(Pt=!0))}function oh(e,t,n,a){Ie=e;var o=0;do{if(Ha&&(Ua=null),Ds=0,Ha=!1,25<=o)throw Error(r(301));if(o+=1,Xt=pt=null,e.updateQueue!=null){var u=e.updateQueue;u.lastEffect=null,u.events=null,u.stores=null,u.memoCache!=null&&(u.memoCache.index=0)}k.H=Yh,u=t(n,a)}while(Ha);return u}function M0(){var e=k.H,t=e.useState()[0];return t=typeof t.then=="function"?Os(t):t,e=e.useState()[0],(pt!==null?pt.memoizedState:null)!==e&&(Ie.flags|=1024),t}function Kc(){var e=Kr!==0;return Kr=0,e}function Ic(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Fc(e){if(Ur){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ur=!1}Ki=0,Xt=pt=Ie=null,Ha=!1,Ds=Kr=0,Ua=null}function wn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xt===null?Ie.memoizedState=Xt=e:Xt=Xt.next=e,Xt}function Gt(){if(pt===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var t=Xt===null?Ie.memoizedState:Xt.next;if(t!==null)Xt=t,pt=e;else{if(e===null)throw Ie.alternate===null?Error(r(467)):Error(r(310));pt=e,e={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},Xt===null?Ie.memoizedState=Xt=e:Xt=Xt.next=e}return Xt}function Ir(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Os(e){var t=Ds;return Ds+=1,Ua===null&&(Ua=[]),e=Wf(Ua,e,t),t=Ie,(Xt===null?t.memoizedState:Xt.next)===null&&(t=t.alternate,k.H=t===null||t.memoizedState===null?Gh:eu),e}function Fr(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Os(e);if(e.$$typeof===Y)return un(e)}throw Error(r(438,String(e)))}function Gc(e){var t=null,n=Ie.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var a=Ie.alternate;a!==null&&(a=a.updateQueue,a!==null&&(a=a.memoCache,a!=null&&(t={data:a.data.map(function(o){return o.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Ir(),Ie.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),a=0;a<e;a++)n[a]=ye;return t.index++,n}function Ii(e,t){return typeof t=="function"?t(e):t}function Gr(e){var t=Gt();return Yc(t,pt,e)}function Yc(e,t,n){var a=e.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var o=e.baseQueue,u=a.pending;if(u!==null){if(o!==null){var g=o.next;o.next=u.next,u.next=g}t.baseQueue=o=u,a.pending=null}if(u=e.baseState,o===null)e.memoizedState=u;else{t=o.next;var x=g=null,M=null,H=t,X=!1;do{var W=H.lane&-536870913;if(W!==H.lane?(Je&W)===W:(Ki&W)===W){var U=H.revertLane;if(U===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null}),W===ja&&(X=!0);else if((Ki&U)===U){H=H.next,U===ja&&(X=!0);continue}else W={lane:0,revertLane:H.revertLane,gesture:null,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null},M===null?(x=M=W,g=u):M=M.next=W,Ie.lanes|=U,wl|=U;W=H.action,la&&n(u,W),u=H.hasEagerState?H.eagerState:n(u,W)}else U={lane:W,revertLane:H.revertLane,gesture:H.gesture,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null},M===null?(x=M=U,g=u):M=M.next=U,Ie.lanes|=W,wl|=W;H=H.next}while(H!==null&&H!==t);if(M===null?g=u:M.next=x,!Hn(u,e.memoizedState)&&(Pt=!0,X&&(n=Da,n!==null)))throw n;e.memoizedState=u,e.baseState=g,e.baseQueue=M,a.lastRenderedState=u}return o===null&&(a.lanes=0),[e.memoizedState,a.dispatch]}function $c(e){var t=Gt(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var a=n.dispatch,o=n.pending,u=t.memoizedState;if(o!==null){n.pending=null;var g=o=o.next;do u=e(u,g.action),g=g.next;while(g!==o);Hn(u,t.memoizedState)||(Pt=!0),t.memoizedState=u,t.baseQueue===null&&(t.baseState=u),n.lastRenderedState=u}return[u,a]}function ch(e,t,n){var a=Ie,o=Gt(),u=tt;if(u){if(n===void 0)throw Error(r(407));n=n()}else n=t();var g=!Hn((pt||o).memoizedState,n);if(g&&(o.memoizedState=n,Pt=!0),o=o.queue,Xc(fh.bind(null,a,o,e),[e]),o.getSnapshot!==t||g||Xt!==null&&Xt.memoizedState.tag&1){if(a.flags|=2048,Ka(9,{destroy:void 0},dh.bind(null,a,o,n,t),null),xt===null)throw Error(r(349));u||(Ki&127)!==0||uh(a,t,n)}return n}function uh(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ie.updateQueue,t===null?(t=Ir(),Ie.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function dh(e,t,n,a){t.value=n,t.getSnapshot=a,hh(t)&&mh(e)}function fh(e,t,n){return n(function(){hh(t)&&mh(e)})}function hh(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Hn(e,n)}catch{return!0}}function mh(e){var t=Pl(e,2);t!==null&&Rn(t,e,2)}function qc(e){var t=wn();if(typeof e=="function"){var n=e;if(e=n(),la){$t(!0);try{n()}finally{$t(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ii,lastRenderedState:e},t}function ph(e,t,n,a){return e.baseState=n,Yc(e,pt,typeof a=="function"?a:Ii)}function A0(e,t,n,a,o){if(qr(e))throw Error(r(485));if(e=t.action,e!==null){var u={payload:o,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(g){u.listeners.push(g)}};k.T!==null?n(!0):u.isTransition=!1,a(u),n=t.pending,n===null?(u.next=t.pending=u,gh(t,u)):(u.next=n.next,t.pending=n.next=u)}}function gh(e,t){var n=t.action,a=t.payload,o=e.state;if(t.isTransition){var u=k.T,g={};k.T=g;try{var x=n(o,a),M=k.S;M!==null&&M(g,x),bh(e,t,x)}catch(H){Vc(e,t,H)}finally{u!==null&&g.types!==null&&(u.types=g.types),k.T=u}}else try{u=n(o,a),bh(e,t,u)}catch(H){Vc(e,t,H)}}function bh(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(a){yh(e,t,a)},function(a){return Vc(e,t,a)}):yh(e,t,n)}function yh(e,t,n){t.status="fulfilled",t.value=n,vh(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,gh(e,n)))}function Vc(e,t,n){var a=e.pending;if(e.pending=null,a!==null){a=a.next;do t.status="rejected",t.reason=n,vh(t),t=t.next;while(t!==a)}e.action=null}function vh(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function xh(e,t){return t}function wh(e,t){if(tt){var n=xt.formState;if(n!==null){e:{var a=Ie;if(tt){if(Et){t:{for(var o=Et,u=ei;o.nodeType!==8;){if(!u){o=null;break t}if(o=ni(o.nextSibling),o===null){o=null;break t}}u=o.data,o=u==="F!"||u==="F"?o:null}if(o){Et=ni(o.nextSibling),a=o.data==="F!";break e}}fl(a)}a=!1}a&&(t=n[0])}}return n=wn(),n.memoizedState=n.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xh,lastRenderedState:t},n.queue=a,n=Kh.bind(null,Ie,a),a.dispatch=n,a=qc(!1),u=Jc.bind(null,Ie,!1,a.queue),a=wn(),o={state:t,dispatch:null,action:e,pending:null},a.queue=o,n=A0.bind(null,Ie,o,u,n),o.dispatch=n,a.memoizedState=e,[t,n,!1]}function Sh(e){var t=Gt();return Ch(t,pt,e)}function Ch(e,t,n){if(t=Yc(e,t,xh)[0],e=Gr(Ii)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var a=Os(t)}catch(g){throw g===Oa?jr:g}else a=t;t=Gt();var o=t.queue,u=o.dispatch;return n!==t.memoizedState&&(Ie.flags|=2048,Ka(9,{destroy:void 0},E0.bind(null,o,n),null)),[a,u,e]}function E0(e,t){e.action=t}function Th(e){var t=Gt(),n=pt;if(n!==null)return Ch(t,n,e);Gt(),t=t.memoizedState,n=Gt();var a=n.queue.dispatch;return n.memoizedState=e,[t,a,!1]}function Ka(e,t,n,a){return e={tag:e,create:n,deps:a,inst:t,next:null},t=Ie.updateQueue,t===null&&(t=Ir(),Ie.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(a=n.next,n.next=e,e.next=a,t.lastEffect=e),e}function Mh(){return Gt().memoizedState}function Yr(e,t,n,a){var o=wn();Ie.flags|=e,o.memoizedState=Ka(1|t,{destroy:void 0},n,a===void 0?null:a)}function $r(e,t,n,a){var o=Gt();a=a===void 0?null:a;var u=o.memoizedState.inst;pt!==null&&a!==null&&Hc(a,pt.memoizedState.deps)?o.memoizedState=Ka(t,u,n,a):(Ie.flags|=e,o.memoizedState=Ka(1|t,u,n,a))}function Ah(e,t){Yr(8390656,8,e,t)}function Xc(e,t){$r(2048,8,e,t)}function N0(e){Ie.flags|=4;var t=Ie.updateQueue;if(t===null)t=Ir(),Ie.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Eh(e){var t=Gt().memoizedState;return N0({ref:t,nextImpl:e}),function(){if((st&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function Nh(e,t){return $r(4,2,e,t)}function kh(e,t){return $r(4,4,e,t)}function Rh(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 Lh(e,t,n){n=n!=null?n.concat([e]):null,$r(4,4,Rh.bind(null,t,e),n)}function Pc(){}function _h(e,t){var n=Gt();t=t===void 0?null:t;var a=n.memoizedState;return t!==null&&Hc(t,a[1])?a[0]:(n.memoizedState=[e,t],e)}function jh(e,t){var n=Gt();t=t===void 0?null:t;var a=n.memoizedState;if(t!==null&&Hc(t,a[1]))return a[0];if(a=e(),la){$t(!0);try{e()}finally{$t(!1)}}return n.memoizedState=[a,t],a}function Zc(e,t,n){return n===void 0||(Ki&1073741824)!==0&&(Je&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Dm(),Ie.lanes|=e,wl|=e,n)}function Dh(e,t,n,a){return Hn(n,t)?n:Ba.current!==null?(e=Zc(e,n,a),Hn(e,t)||(Pt=!0),e):(Ki&42)===0||(Ki&1073741824)!==0&&(Je&261930)===0?(Pt=!0,e.memoizedState=n):(e=Dm(),Ie.lanes|=e,wl|=e,t)}function Oh(e,t,n,a,o){var u=I.p;I.p=u!==0&&8>u?u:8;var g=k.T,x={};k.T=x,Jc(e,!1,t,n);try{var M=o(),H=k.S;if(H!==null&&H(x,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var X=C0(M,a);zs(e,t,X,Yn(e))}else zs(e,t,a,Yn(e))}catch(W){zs(e,t,{then:function(){},status:"rejected",reason:W},Yn())}finally{I.p=u,g!==null&&x.types!==null&&(g.types=x.types),k.T=g}}function k0(){}function Qc(e,t,n,a){if(e.tag!==5)throw Error(r(476));var o=zh(e).queue;Oh(e,o,t,le,n===null?k0:function(){return Bh(e),n(a)})}function zh(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ii,lastRenderedState:le},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ii,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Bh(e){var t=zh(e);t.next===null&&(t=e.alternate.memoizedState),zs(e,t.next.queue,{},Yn())}function Wc(){return un(Js)}function Hh(){return Gt().memoizedState}function Uh(){return Gt().memoizedState}function R0(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Yn();e=pl(n);var a=gl(t,e,n);a!==null&&(Rn(a,t,n),Ls(a,t,n)),t={cache:Ec()},e.payload=t;return}t=t.return}}function L0(e,t,n){var a=Yn();n={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},qr(e)?Ih(t,n):(n=gc(e,t,n,a),n!==null&&(Rn(n,e,a),Fh(n,t,a)))}function Kh(e,t,n){var a=Yn();zs(e,t,n,a)}function zs(e,t,n,a){var o={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(qr(e))Ih(t,o);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var g=t.lastRenderedState,x=u(g,n);if(o.hasEagerState=!0,o.eagerState=x,Hn(x,g))return Ar(e,t,o,0),xt===null&&Mr(),!1}catch{}finally{}if(n=gc(e,t,o,a),n!==null)return Rn(n,e,a),Fh(n,t,a),!0}return!1}function Jc(e,t,n,a){if(a={lane:2,revertLane:Lu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},qr(e)){if(t)throw Error(r(479))}else t=gc(e,n,a,2),t!==null&&Rn(t,e,2)}function qr(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function Ih(e,t){Ha=Ur=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if((n&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,n|=a,t.lanes=n,nl(e,n)}}var Bs={readContext:un,use:Fr,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};Bs.useEffectEvent=Ht;var Gh={readContext:un,use:Fr,useCallback:function(e,t){return wn().memoizedState=[e,t===void 0?null:t],e},useContext:un,useEffect:Ah,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,Yr(4194308,4,Rh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Yr(4194308,4,e,t)},useInsertionEffect:function(e,t){Yr(4,2,e,t)},useMemo:function(e,t){var n=wn();t=t===void 0?null:t;var a=e();if(la){$t(!0);try{e()}finally{$t(!1)}}return n.memoizedState=[a,t],a},useReducer:function(e,t,n){var a=wn();if(n!==void 0){var o=n(t);if(la){$t(!0);try{n(t)}finally{$t(!1)}}}else o=t;return a.memoizedState=a.baseState=o,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:o},a.queue=e,e=e.dispatch=L0.bind(null,Ie,e),[a.memoizedState,e]},useRef:function(e){var t=wn();return e={current:e},t.memoizedState=e},useState:function(e){e=qc(e);var t=e.queue,n=Kh.bind(null,Ie,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Pc,useDeferredValue:function(e,t){var n=wn();return Zc(n,e,t)},useTransition:function(){var e=qc(!1);return e=Oh.bind(null,Ie,e.queue,!0,!1),wn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Ie,o=wn();if(tt){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),xt===null)throw Error(r(349));(Je&127)!==0||uh(a,t,n)}o.memoizedState=n;var u={value:n,getSnapshot:t};return o.queue=u,Ah(fh.bind(null,a,u,e),[e]),a.flags|=2048,Ka(9,{destroy:void 0},dh.bind(null,a,u,n,t),null),n},useId:function(){var e=wn(),t=xt.identifierPrefix;if(tt){var n=Mi,a=Ti;n=(a&~(1<<32-dt(a)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Kr++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=T0++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Wc,useFormState:wh,useActionState:wh,useOptimistic:function(e){var t=wn();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Jc.bind(null,Ie,!0,n),n.dispatch=t,[e,t]},useMemoCache:Gc,useCacheRefresh:function(){return wn().memoizedState=R0.bind(null,Ie)},useEffectEvent:function(e){var t=wn(),n={impl:e};return t.memoizedState=n,function(){if((st&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},eu={readContext:un,use:Fr,useCallback:_h,useContext:un,useEffect:Xc,useImperativeHandle:Lh,useInsertionEffect:Nh,useLayoutEffect:kh,useMemo:jh,useReducer:Gr,useRef:Mh,useState:function(){return Gr(Ii)},useDebugValue:Pc,useDeferredValue:function(e,t){var n=Gt();return Dh(n,pt.memoizedState,e,t)},useTransition:function(){var e=Gr(Ii)[0],t=Gt().memoizedState;return[typeof e=="boolean"?e:Os(e),t]},useSyncExternalStore:ch,useId:Hh,useHostTransitionStatus:Wc,useFormState:Sh,useActionState:Sh,useOptimistic:function(e,t){var n=Gt();return ph(n,pt,e,t)},useMemoCache:Gc,useCacheRefresh:Uh};eu.useEffectEvent=Eh;var Yh={readContext:un,use:Fr,useCallback:_h,useContext:un,useEffect:Xc,useImperativeHandle:Lh,useInsertionEffect:Nh,useLayoutEffect:kh,useMemo:jh,useReducer:$c,useRef:Mh,useState:function(){return $c(Ii)},useDebugValue:Pc,useDeferredValue:function(e,t){var n=Gt();return pt===null?Zc(n,e,t):Dh(n,pt.memoizedState,e,t)},useTransition:function(){var e=$c(Ii)[0],t=Gt().memoizedState;return[typeof e=="boolean"?e:Os(e),t]},useSyncExternalStore:ch,useId:Hh,useHostTransitionStatus:Wc,useFormState:Th,useActionState:Th,useOptimistic:function(e,t){var n=Gt();return pt!==null?ph(n,pt,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Gc,useCacheRefresh:Uh};Yh.useEffectEvent=Eh;function tu(e,t,n,a){t=e.memoizedState,n=n(a,t),n=n==null?t:v({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var nu={enqueueSetState:function(e,t,n){e=e._reactInternals;var a=Yn(),o=pl(a);o.payload=t,n!=null&&(o.callback=n),t=gl(e,o,a),t!==null&&(Rn(t,e,a),Ls(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var a=Yn(),o=pl(a);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=gl(e,o,a),t!==null&&(Rn(t,e,a),Ls(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Yn(),a=pl(n);a.tag=2,t!=null&&(a.callback=t),t=gl(e,a,n),t!==null&&(Rn(t,e,n),Ls(t,e,n))}};function $h(e,t,n,a,o,u,g){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(a,u,g):t.prototype&&t.prototype.isPureReactComponent?!Cs(n,a)||!Cs(o,u):!0}function qh(e,t,n,a){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,a),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,a),t.state!==e&&nu.enqueueReplaceState(t,t.state,null)}function aa(e,t){var n=t;if("ref"in t){n={};for(var a in t)a!=="ref"&&(n[a]=t[a])}if(e=e.defaultProps){n===t&&(n=v({},n));for(var o in e)n[o]===void 0&&(n[o]=e[o])}return n}function Vh(e){Tr(e)}function Xh(e){console.error(e)}function Ph(e){Tr(e)}function Vr(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(a){setTimeout(function(){throw a})}}function Zh(e,t,n){try{var a=e.onCaughtError;a(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(o){setTimeout(function(){throw o})}}function iu(e,t,n){return n=pl(n),n.tag=3,n.payload={element:null},n.callback=function(){Vr(e,t)},n}function Qh(e){return e=pl(e),e.tag=3,e}function Wh(e,t,n,a){var o=n.type.getDerivedStateFromError;if(typeof o=="function"){var u=a.value;e.payload=function(){return o(u)},e.callback=function(){Zh(t,n,a)}}var g=n.stateNode;g!==null&&typeof g.componentDidCatch=="function"&&(e.callback=function(){Zh(t,n,a),typeof o!="function"&&(Sl===null?Sl=new Set([this]):Sl.add(this));var x=a.stack;this.componentDidCatch(a.value,{componentStack:x!==null?x:""})})}function _0(e,t,n,a,o){if(n.flags|=32768,a!==null&&typeof a=="object"&&typeof a.then=="function"){if(t=n.alternate,t!==null&&_a(t,n,o,!0),n=Kn.current,n!==null){switch(n.tag){case 31:case 13:return ti===null?ao():n.alternate===null&&Ut===0&&(Ut=3),n.flags&=-257,n.flags|=65536,n.lanes=o,a===Dr?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([a]):t.add(a),Nu(e,a,o)),!1;case 22:return n.flags|=65536,a===Dr?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([a]):n.add(a)),Nu(e,a,o)),!1}throw Error(r(435,n.tag))}return Nu(e,a,o),ao(),!1}if(tt)return t=Kn.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=o,a!==Sc&&(e=Error(r(422),{cause:a}),As(Qn(e,n)))):(a!==Sc&&(t=Error(r(423),{cause:a}),As(Qn(t,n))),e=e.current.alternate,e.flags|=65536,o&=-o,e.lanes|=o,a=Qn(a,n),o=iu(e.stateNode,a,o),jc(e,o),Ut!==4&&(Ut=2)),!1;var u=Error(r(520),{cause:a});if(u=Qn(u,n),$s===null?$s=[u]:$s.push(u),Ut!==4&&(Ut=2),t===null)return!0;a=Qn(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=o&-o,n.lanes|=e,e=iu(n.stateNode,a,e),jc(n,e),!1;case 1:if(t=n.type,u=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||u!==null&&typeof u.componentDidCatch=="function"&&(Sl===null||!Sl.has(u))))return n.flags|=65536,o&=-o,n.lanes|=o,o=Qh(o),Wh(o,e,n,a),jc(n,o),!1}n=n.return}while(n!==null);return!1}var lu=Error(r(461)),Pt=!1;function dn(e,t,n,a){t.child=e===null?nh(t,null,n,a):ia(t,e.child,n,a)}function Jh(e,t,n,a,o){n=n.render;var u=t.ref;if("ref"in a){var g={};for(var x in a)x!=="ref"&&(g[x]=a[x])}else g=a;return Jl(t),a=Uc(e,t,n,g,u,o),x=Kc(),e!==null&&!Pt?(Ic(e,t,o),Fi(e,t,o)):(tt&&x&&xc(t),t.flags|=1,dn(e,t,a,o),t.child)}function em(e,t,n,a,o){if(e===null){var u=n.type;return typeof u=="function"&&!bc(u)&&u.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=u,tm(e,t,u,a,o)):(e=Nr(n.type,null,a,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(u=e.child,!fu(e,o)){var g=u.memoizedProps;if(n=n.compare,n=n!==null?n:Cs,n(g,a)&&e.ref===t.ref)return Fi(e,t,o)}return t.flags|=1,e=zi(u,a),e.ref=t.ref,e.return=t,t.child=e}function tm(e,t,n,a,o){if(e!==null){var u=e.memoizedProps;if(Cs(u,a)&&e.ref===t.ref)if(Pt=!1,t.pendingProps=a=u,fu(e,o))(e.flags&131072)!==0&&(Pt=!0);else return t.lanes=e.lanes,Fi(e,t,o)}return au(e,t,n,a,o)}function nm(e,t,n,a){var o=a.children,u=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.mode==="hidden"){if((t.flags&128)!==0){if(u=u!==null?u.baseLanes|n:n,e!==null){for(a=t.child=e.child,o=0;a!==null;)o=o|a.lanes|a.childLanes,a=a.sibling;a=o&~u}else a=0,t.child=null;return im(e,t,u,n,a)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&_r(t,u!==null?u.cachePool:null),u!==null?ah(t,u):Oc(),sh(t);else return a=t.lanes=536870912,im(e,t,u!==null?u.baseLanes|n:n,n,a)}else u!==null?(_r(t,u.cachePool),ah(t,u),yl(),t.memoizedState=null):(e!==null&&_r(t,null),Oc(),yl());return dn(e,t,o,n),t.child}function Hs(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function im(e,t,n,a,o){var u=kc();return u=u===null?null:{parent:Vt._currentValue,pool:u},t.memoizedState={baseLanes:n,cachePool:u},e!==null&&_r(t,null),Oc(),sh(t),e!==null&&_a(e,t,a,!0),t.childLanes=o,null}function Xr(e,t){return t=Zr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function lm(e,t,n){return ia(t,e.child,null,n),e=Xr(t,t.pendingProps),e.flags|=2,In(t),t.memoizedState=null,e}function j0(e,t,n){var a=t.pendingProps,o=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(tt){if(a.mode==="hidden")return e=Xr(t,a),t.lanes=536870912,Hs(null,e);if(Bc(t),(e=Et)?(e=gp(e,ei),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:Ti,overflow:Mi}:null,retryLane:536870912,hydrationErrors:null},n=If(e),n.return=t,t.child=n,cn=t,Et=null)):e=null,e===null)throw fl(t);return t.lanes=536870912,null}return Xr(t,a)}var u=e.memoizedState;if(u!==null){var g=u.dehydrated;if(Bc(t),o)if(t.flags&256)t.flags&=-257,t=lm(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(Pt||_a(e,t,n,!1),o=(n&e.childLanes)!==0,Pt||o){if(a=xt,a!==null&&(g=jn(a,n),g!==0&&g!==u.retryLane))throw u.retryLane=g,Pl(e,g),Rn(a,e,g),lu;ao(),t=lm(e,t,n)}else e=u.treeContext,Et=ni(g.nextSibling),cn=t,tt=!0,dl=null,ei=!1,e!==null&&Yf(t,e),t=Xr(t,a),t.flags|=4096;return t}return e=zi(e.child,{mode:a.mode,children:a.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Pr(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(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function au(e,t,n,a,o){return Jl(t),n=Uc(e,t,n,a,void 0,o),a=Kc(),e!==null&&!Pt?(Ic(e,t,o),Fi(e,t,o)):(tt&&a&&xc(t),t.flags|=1,dn(e,t,n,o),t.child)}function am(e,t,n,a,o,u){return Jl(t),t.updateQueue=null,n=oh(t,a,n,o),rh(e),a=Kc(),e!==null&&!Pt?(Ic(e,t,u),Fi(e,t,u)):(tt&&a&&xc(t),t.flags|=1,dn(e,t,n,u),t.child)}function sm(e,t,n,a,o){if(Jl(t),t.stateNode===null){var u=Na,g=n.contextType;typeof g=="object"&&g!==null&&(u=un(g)),u=new n(a,u),t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=nu,t.stateNode=u,u._reactInternals=t,u=t.stateNode,u.props=a,u.state=t.memoizedState,u.refs={},Lc(t),g=n.contextType,u.context=typeof g=="object"&&g!==null?un(g):Na,u.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(tu(t,n,g,a),u.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(g=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),g!==u.state&&nu.enqueueReplaceState(u,u.state,null),js(t,a,u,o),_s(),u.state=t.memoizedState),typeof u.componentDidMount=="function"&&(t.flags|=4194308),a=!0}else if(e===null){u=t.stateNode;var x=t.memoizedProps,M=aa(n,x);u.props=M;var H=u.context,X=n.contextType;g=Na,typeof X=="object"&&X!==null&&(g=un(X));var W=n.getDerivedStateFromProps;X=typeof W=="function"||typeof u.getSnapshotBeforeUpdate=="function",x=t.pendingProps!==x,X||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(x||H!==g)&&qh(t,u,a,g),ml=!1;var U=t.memoizedState;u.state=U,js(t,a,u,o),_s(),H=t.memoizedState,x||U!==H||ml?(typeof W=="function"&&(tu(t,n,W,a),H=t.memoizedState),(M=ml||$h(t,n,M,a,U,H,g))?(X||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount()),typeof u.componentDidMount=="function"&&(t.flags|=4194308)):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=H),u.props=a,u.state=H,u.context=g,a=M):(typeof u.componentDidMount=="function"&&(t.flags|=4194308),a=!1)}else{u=t.stateNode,_c(e,t),g=t.memoizedProps,X=aa(n,g),u.props=X,W=t.pendingProps,U=u.context,H=n.contextType,M=Na,typeof H=="object"&&H!==null&&(M=un(H)),x=n.getDerivedStateFromProps,(H=typeof x=="function"||typeof u.getSnapshotBeforeUpdate=="function")||typeof u.UNSAFE_componentWillReceiveProps!="function"&&typeof u.componentWillReceiveProps!="function"||(g!==W||U!==M)&&qh(t,u,a,M),ml=!1,U=t.memoizedState,u.state=U,js(t,a,u,o),_s();var F=t.memoizedState;g!==W||U!==F||ml||e!==null&&e.dependencies!==null&&Rr(e.dependencies)?(typeof x=="function"&&(tu(t,n,x,a),F=t.memoizedState),(X=ml||$h(t,n,X,a,U,F,M)||e!==null&&e.dependencies!==null&&Rr(e.dependencies))?(H||typeof u.UNSAFE_componentWillUpdate!="function"&&typeof u.componentWillUpdate!="function"||(typeof u.componentWillUpdate=="function"&&u.componentWillUpdate(a,F,M),typeof u.UNSAFE_componentWillUpdate=="function"&&u.UNSAFE_componentWillUpdate(a,F,M)),typeof u.componentDidUpdate=="function"&&(t.flags|=4),typeof u.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof u.componentDidUpdate!="function"||g===e.memoizedProps&&U===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||g===e.memoizedProps&&U===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=F),u.props=a,u.state=F,u.context=M,a=X):(typeof u.componentDidUpdate!="function"||g===e.memoizedProps&&U===e.memoizedState||(t.flags|=4),typeof u.getSnapshotBeforeUpdate!="function"||g===e.memoizedProps&&U===e.memoizedState||(t.flags|=1024),a=!1)}return u=a,Pr(e,t),a=(t.flags&128)!==0,u||a?(u=t.stateNode,n=a&&typeof n.getDerivedStateFromError!="function"?null:u.render(),t.flags|=1,e!==null&&a?(t.child=ia(t,e.child,null,o),t.child=ia(t,null,n,o)):dn(e,t,n,o),t.memoizedState=u.state,e=t.child):e=Fi(e,t,o),e}function rm(e,t,n,a){return Ql(),t.flags|=256,dn(e,t,n,a),t.child}var su={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ru(e){return{baseLanes:e,cachePool:Zf()}}function ou(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Gn),e}function om(e,t,n){var a=t.pendingProps,o=!1,u=(t.flags&128)!==0,g;if((g=u)||(g=e!==null&&e.memoizedState===null?!1:(Ft.current&2)!==0),g&&(o=!0,t.flags&=-129),g=(t.flags&32)!==0,t.flags&=-33,e===null){if(tt){if(o?bl(t):yl(),(e=Et)?(e=gp(e,ei),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:Ti,overflow:Mi}:null,retryLane:536870912,hydrationErrors:null},n=If(e),n.return=t,t.child=n,cn=t,Et=null)):e=null,e===null)throw fl(t);return Yu(e)?t.lanes=32:t.lanes=536870912,null}var x=a.children;return a=a.fallback,o?(yl(),o=t.mode,x=Zr({mode:"hidden",children:x},o),a=Zl(a,o,n,null),x.return=t,a.return=t,x.sibling=a,t.child=x,a=t.child,a.memoizedState=ru(n),a.childLanes=ou(e,g,n),t.memoizedState=su,Hs(null,a)):(bl(t),cu(t,x))}var M=e.memoizedState;if(M!==null&&(x=M.dehydrated,x!==null)){if(u)t.flags&256?(bl(t),t.flags&=-257,t=uu(e,t,n)):t.memoizedState!==null?(yl(),t.child=e.child,t.flags|=128,t=null):(yl(),x=a.fallback,o=t.mode,a=Zr({mode:"visible",children:a.children},o),x=Zl(x,o,n,null),x.flags|=2,a.return=t,x.return=t,a.sibling=x,t.child=a,ia(t,e.child,null,n),a=t.child,a.memoizedState=ru(n),a.childLanes=ou(e,g,n),t.memoizedState=su,t=Hs(null,a));else if(bl(t),Yu(x)){if(g=x.nextSibling&&x.nextSibling.dataset,g)var H=g.dgst;g=H,a=Error(r(419)),a.stack="",a.digest=g,As({value:a,source:null,stack:null}),t=uu(e,t,n)}else if(Pt||_a(e,t,n,!1),g=(n&e.childLanes)!==0,Pt||g){if(g=xt,g!==null&&(a=jn(g,n),a!==0&&a!==M.retryLane))throw M.retryLane=a,Pl(e,a),Rn(g,e,a),lu;Gu(x)||ao(),t=uu(e,t,n)}else Gu(x)?(t.flags|=192,t.child=e.child,t=null):(e=M.treeContext,Et=ni(x.nextSibling),cn=t,tt=!0,dl=null,ei=!1,e!==null&&Yf(t,e),t=cu(t,a.children),t.flags|=4096);return t}return o?(yl(),x=a.fallback,o=t.mode,M=e.child,H=M.sibling,a=zi(M,{mode:"hidden",children:a.children}),a.subtreeFlags=M.subtreeFlags&65011712,H!==null?x=zi(H,x):(x=Zl(x,o,n,null),x.flags|=2),x.return=t,a.return=t,a.sibling=x,t.child=a,Hs(null,a),a=t.child,x=e.child.memoizedState,x===null?x=ru(n):(o=x.cachePool,o!==null?(M=Vt._currentValue,o=o.parent!==M?{parent:M,pool:M}:o):o=Zf(),x={baseLanes:x.baseLanes|n,cachePool:o}),a.memoizedState=x,a.childLanes=ou(e,g,n),t.memoizedState=su,Hs(e.child,a)):(bl(t),n=e.child,e=n.sibling,n=zi(n,{mode:"visible",children:a.children}),n.return=t,n.sibling=null,e!==null&&(g=t.deletions,g===null?(t.deletions=[e],t.flags|=16):g.push(e)),t.child=n,t.memoizedState=null,n)}function cu(e,t){return t=Zr({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Zr(e,t){return e=Un(22,e,null,t),e.lanes=0,e}function uu(e,t,n){return ia(t,e.child,null,n),e=cu(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function cm(e,t,n){e.lanes|=t;var a=e.alternate;a!==null&&(a.lanes|=t),Mc(e.return,t,n)}function du(e,t,n,a,o,u){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:o,treeForkCount:u}:(g.isBackwards=t,g.rendering=null,g.renderingStartTime=0,g.last=a,g.tail=n,g.tailMode=o,g.treeForkCount=u)}function um(e,t,n){var a=t.pendingProps,o=a.revealOrder,u=a.tail;a=a.children;var g=Ft.current,x=(g&2)!==0;if(x?(g=g&1|2,t.flags|=128):g&=1,xe(Ft,g),dn(e,t,a,n),a=tt?Ms:0,!x&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&cm(e,n,t);else if(e.tag===19)cm(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(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&Hr(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),du(t,!1,o,n,u,a);break;case"backwards":case"unstable_legacy-backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&Hr(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}du(t,!0,n,null,u,a);break;case"together":du(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function Fi(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),wl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(_a(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=zi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=zi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function fu(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Rr(e)))}function D0(e,t,n){switch(t.tag){case 3:Xe(t,t.stateNode.containerInfo),hl(t,Vt,e.memoizedState.cache),Ql();break;case 27:case 5:yt(t);break;case 4:Xe(t,t.stateNode.containerInfo);break;case 10:hl(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Bc(t),null;break;case 13:var a=t.memoizedState;if(a!==null)return a.dehydrated!==null?(bl(t),t.flags|=128,null):(n&t.child.childLanes)!==0?om(e,t,n):(bl(t),e=Fi(e,t,n),e!==null?e.sibling:null);bl(t);break;case 19:var o=(e.flags&128)!==0;if(a=(n&t.childLanes)!==0,a||(_a(e,t,n,!1),a=(n&t.childLanes)!==0),o){if(a)return um(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),xe(Ft,Ft.current),a)break;return null;case 22:return t.lanes=0,nm(e,t,n,t.pendingProps);case 24:hl(t,Vt,e.memoizedState.cache)}return Fi(e,t,n)}function dm(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)Pt=!0;else{if(!fu(e,n)&&(t.flags&128)===0)return Pt=!1,D0(e,t,n);Pt=(e.flags&131072)!==0}else Pt=!1,tt&&(t.flags&1048576)!==0&&Gf(t,Ms,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=ta(t.elementType),t.type=e,typeof e=="function")bc(e)?(a=aa(e,a),t.tag=1,t=sm(null,t,e,a,n)):(t.tag=0,t=au(null,t,e,a,n));else{if(e!=null){var o=e.$$typeof;if(o===se){t.tag=11,t=Jh(null,t,e,a,n);break e}else if(o===K){t.tag=14,t=em(null,t,e,a,n);break e}}throw t=oe(e)||e,Error(r(306,t,""))}}return t;case 0:return au(e,t,t.type,t.pendingProps,n);case 1:return a=t.type,o=aa(a,t.pendingProps),sm(e,t,a,o,n);case 3:e:{if(Xe(t,t.stateNode.containerInfo),e===null)throw Error(r(387));a=t.pendingProps;var u=t.memoizedState;o=u.element,_c(e,t),js(t,a,null,n);var g=t.memoizedState;if(a=g.cache,hl(t,Vt,a),a!==u.cache&&Ac(t,[Vt],n,!0),_s(),a=g.element,u.isDehydrated)if(u={element:a,isDehydrated:!1,cache:g.cache},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){t=rm(e,t,a,n);break e}else if(a!==o){o=Qn(Error(r(424)),t),As(o),t=rm(e,t,a,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(Et=ni(e.firstChild),cn=t,tt=!0,dl=null,ei=!0,n=nh(t,null,a,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ql(),a===o){t=Fi(e,t,n);break e}dn(e,t,a,n)}t=t.child}return t;case 26:return Pr(e,t),e===null?(n=Sp(t.type,null,t.pendingProps,null))?t.memoizedState=n:tt||(n=t.type,e=t.pendingProps,a=ho(Be.current).createElement(n),a[Dt]=t,a[Jt]=e,fn(a,n,e),Ct(a),t.stateNode=a):t.memoizedState=Sp(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return yt(t),e===null&&tt&&(a=t.stateNode=vp(t.type,t.pendingProps,Be.current),cn=t,ei=!0,o=Et,Al(t.type)?($u=o,Et=ni(a.firstChild)):Et=o),dn(e,t,t.pendingProps.children,n),Pr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&tt&&((o=a=Et)&&(a=uv(a,t.type,t.pendingProps,ei),a!==null?(t.stateNode=a,cn=t,Et=ni(a.firstChild),ei=!1,o=!0):o=!1),o||fl(t)),yt(t),o=t.type,u=t.pendingProps,g=e!==null?e.memoizedProps:null,a=u.children,Ku(o,u)?a=null:g!==null&&Ku(o,g)&&(t.flags|=32),t.memoizedState!==null&&(o=Uc(e,t,M0,null,null,n),Js._currentValue=o),Pr(e,t),dn(e,t,a,n),t.child;case 6:return e===null&&tt&&((e=n=Et)&&(n=dv(n,t.pendingProps,ei),n!==null?(t.stateNode=n,cn=t,Et=null,e=!0):e=!1),e||fl(t)),null;case 13:return om(e,t,n);case 4:return Xe(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=ia(t,null,a,n):dn(e,t,a,n),t.child;case 11:return Jh(e,t,t.type,t.pendingProps,n);case 7:return dn(e,t,t.pendingProps,n),t.child;case 8:return dn(e,t,t.pendingProps.children,n),t.child;case 12:return dn(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,hl(t,t.type,a.value),dn(e,t,a.children,n),t.child;case 9:return o=t.type._context,a=t.pendingProps.children,Jl(t),o=un(o),a=a(o),t.flags|=1,dn(e,t,a,n),t.child;case 14:return em(e,t,t.type,t.pendingProps,n);case 15:return tm(e,t,t.type,t.pendingProps,n);case 19:return um(e,t,n);case 31:return j0(e,t,n);case 22:return nm(e,t,n,t.pendingProps);case 24:return Jl(t),a=un(Vt),e===null?(o=kc(),o===null&&(o=xt,u=Ec(),o.pooledCache=u,u.refCount++,u!==null&&(o.pooledCacheLanes|=n),o=u),t.memoizedState={parent:a,cache:o},Lc(t),hl(t,Vt,o)):((e.lanes&n)!==0&&(_c(e,t),js(t,null,null,n),_s()),o=e.memoizedState,u=t.memoizedState,o.parent!==a?(o={parent:a,cache:a},t.memoizedState=o,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=o),hl(t,Vt,a)):(a=u.cache,hl(t,Vt,a),a!==o.cache&&Ac(t,[Vt],n,!0))),dn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function Gi(e){e.flags|=4}function hu(e,t,n,a,o){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(o&335544128)===o)if(e.stateNode.complete)e.flags|=8192;else if(Hm())e.flags|=8192;else throw na=Dr,Rc}else e.flags&=-16777217}function fm(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Ep(t))if(Hm())e.flags|=8192;else throw na=Dr,Rc}function Qr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?St():536870912,e.lanes|=t,Ya|=t)}function Us(e,t){if(!tt)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 a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:a.sibling=null}}function Nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,a=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,a|=o.subtreeFlags&65011712,a|=o.flags&65011712,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,a|=o.subtreeFlags,a|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=a,e.childLanes=n,t}function O0(e,t,n){var a=t.pendingProps;switch(wc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nt(t),null;case 1:return Nt(t),null;case 3:return n=t.stateNode,a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Ui(Vt),ze(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(La(t)?Gi(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Cc())),Nt(t),null;case 26:var o=t.type,u=t.memoizedState;return e===null?(Gi(t),u!==null?(Nt(t),fm(t,u)):(Nt(t),hu(t,o,null,a,n))):u?u!==e.memoizedState?(Gi(t),Nt(t),fm(t,u)):(Nt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==a&&Gi(t),Nt(t),hu(t,o,e,a,n)),null;case 27:if(Tt(t),n=Be.current,o=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Gi(t);else{if(!a){if(t.stateNode===null)throw Error(r(166));return Nt(t),null}e=Se.current,La(t)?$f(t):(e=vp(o,a,n),t.stateNode=e,Gi(t))}return Nt(t),null;case 5:if(Tt(t),o=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==a&&Gi(t);else{if(!a){if(t.stateNode===null)throw Error(r(166));return Nt(t),null}if(u=Se.current,La(t))$f(t);else{var g=ho(Be.current);switch(u){case 1:u=g.createElementNS("http://www.w3.org/2000/svg",o);break;case 2:u=g.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;default:switch(o){case"svg":u=g.createElementNS("http://www.w3.org/2000/svg",o);break;case"math":u=g.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;case"script":u=g.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?g.createElement("select",{is:a.is}):g.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?g.createElement(o,{is:a.is}):g.createElement(o)}}u[Dt]=t,u[Jt]=a;e:for(g=t.child;g!==null;){if(g.tag===5||g.tag===6)u.appendChild(g.stateNode);else if(g.tag!==4&&g.tag!==27&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===t)break e;for(;g.sibling===null;){if(g.return===null||g.return===t)break e;g=g.return}g.sibling.return=g.return,g=g.sibling}t.stateNode=u;e:switch(fn(u,o,a),o){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Gi(t)}}return Nt(t),hu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Gi(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=Be.current,La(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,o=cn,o!==null)switch(o.tag){case 27:case 5:a=o.memoizedProps}e[Dt]=t,e=!!(e.nodeValue===n||a!==null&&a.suppressHydrationWarning===!0||op(e.nodeValue,n)),e||fl(t,!0)}else e=ho(e).createTextNode(a),e[Dt]=t,t.stateNode=e}return Nt(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(a=La(t),n!==null){if(e===null){if(!a)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[Dt]=t}else Ql(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Nt(t),e=!1}else n=Cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(In(t),t):(In(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Nt(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(o=La(t),a!==null&&a.dehydrated!==null){if(e===null){if(!o)throw Error(r(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(r(317));o[Dt]=t}else Ql(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Nt(t),o=!1}else o=Cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=o),o=!0;if(!o)return t.flags&256?(In(t),t):(In(t),null)}return In(t),(t.flags&128)!==0?(t.lanes=n,t):(n=a!==null,e=e!==null&&e.memoizedState!==null,n&&(a=t.child,o=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(o=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==o&&(a.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Qr(t,t.updateQueue),Nt(t),null);case 4:return ze(),e===null&&Ou(t.stateNode.containerInfo),Nt(t),null;case 10:return Ui(t.type),Nt(t),null;case 19:if(Ae(Ft),a=t.memoizedState,a===null)return Nt(t),null;if(o=(t.flags&128)!==0,u=a.rendering,u===null)if(o)Us(a,!1);else{if(Ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=Hr(e),u!==null){for(t.flags|=128,Us(a,!1),e=u.updateQueue,t.updateQueue=e,Qr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Kf(n,e),n=n.sibling;return xe(Ft,Ft.current&1|2),tt&&Bi(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&qe()>no&&(t.flags|=128,o=!0,Us(a,!1),t.lanes=4194304)}else{if(!o)if(e=Hr(u),e!==null){if(t.flags|=128,o=!0,e=e.updateQueue,t.updateQueue=e,Qr(t,e),Us(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!tt)return Nt(t),null}else 2*qe()-a.renderingStartTime>no&&n!==536870912&&(t.flags|=128,o=!0,Us(a,!1),t.lanes=4194304);a.isBackwards?(u.sibling=t.child,t.child=u):(e=a.last,e!==null?e.sibling=u:t.child=u,a.last=u)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=qe(),e.sibling=null,n=Ft.current,xe(Ft,o?n&1|2:n&1),tt&&Bi(t,a.treeForkCount),e):(Nt(t),null);case 22:case 23:return In(t),zc(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(n&536870912)!==0&&(t.flags&128)===0&&(Nt(t),t.subtreeFlags&6&&(t.flags|=8192)):Nt(t),n=t.updateQueue,n!==null&&Qr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),e!==null&&Ae(ea),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ui(Vt),Nt(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function z0(e,t){switch(wc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ui(Vt),ze(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Tt(t),null;case 31:if(t.memoizedState!==null){if(In(t),t.alternate===null)throw Error(r(340));Ql()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(In(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ql()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ae(Ft),null;case 4:return ze(),null;case 10:return Ui(t.type),null;case 22:case 23:return In(t),zc(),e!==null&&Ae(ea),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ui(Vt),null;case 25:return null;default:return null}}function hm(e,t){switch(wc(t),t.tag){case 3:Ui(Vt),ze();break;case 26:case 27:case 5:Tt(t);break;case 4:ze();break;case 31:t.memoizedState!==null&&In(t);break;case 13:In(t);break;case 19:Ae(Ft);break;case 10:Ui(t.type);break;case 22:case 23:In(t),zc(),e!==null&&Ae(ea);break;case 24:Ui(Vt)}}function Ks(e,t){try{var n=t.updateQueue,a=n!==null?n.lastEffect:null;if(a!==null){var o=a.next;n=o;do{if((n.tag&e)===e){a=void 0;var u=n.create,g=n.inst;a=u(),g.destroy=a}n=n.next}while(n!==o)}}catch(x){ht(t,t.return,x)}}function vl(e,t,n){try{var a=t.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&e)===e){var g=a.inst,x=g.destroy;if(x!==void 0){g.destroy=void 0,o=t;var M=n,H=x;try{H()}catch(X){ht(o,M,X)}}}a=a.next}while(a!==u)}}catch(X){ht(t,t.return,X)}}function mm(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{lh(t,n)}catch(a){ht(e,e.return,a)}}}function pm(e,t,n){n.props=aa(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(a){ht(e,t,a)}}function Is(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof n=="function"?e.refCleanup=n(a):n.current=a}}catch(o){ht(e,t,o)}}function Ai(e,t){var n=e.ref,a=e.refCleanup;if(n!==null)if(typeof a=="function")try{a()}catch(o){ht(e,t,o)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(o){ht(e,t,o)}else n.current=null}function gm(e){var t=e.type,n=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&a.focus();break e;case"img":n.src?a.src=n.src:n.srcSet&&(a.srcset=n.srcSet)}}catch(o){ht(e,e.return,o)}}function mu(e,t,n){try{var a=e.stateNode;lv(a,e.type,n,t),a[Jt]=t}catch(o){ht(e,e.return,o)}}function bm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Al(e.type)||e.tag===4}function pu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bm(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&&Al(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 gu(e,t,n){var a=e.tag;if(a===5||a===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=oi));else if(a!==4&&(a===27&&Al(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(gu(e,t,n),e=e.sibling;e!==null;)gu(e,t,n),e=e.sibling}function Wr(e,t,n){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(a!==4&&(a===27&&Al(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Wr(e,t,n),e=e.sibling;e!==null;)Wr(e,t,n),e=e.sibling}function ym(e){var t=e.stateNode,n=e.memoizedProps;try{for(var a=e.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);fn(t,a,n),t[Dt]=e,t[Jt]=n}catch(u){ht(e,e.return,u)}}var Yi=!1,Zt=!1,bu=!1,vm=typeof WeakSet=="function"?WeakSet:Set,an=null;function B0(e,t){if(e=e.containerInfo,Hu=xo,e=Lf(e),uc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var a=n.getSelection&&n.getSelection();if(a&&a.rangeCount!==0){n=a.anchorNode;var o=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var g=0,x=-1,M=-1,H=0,X=0,W=e,U=null;t:for(;;){for(var F;W!==n||o!==0&&W.nodeType!==3||(x=g+o),W!==u||a!==0&&W.nodeType!==3||(M=g+a),W.nodeType===3&&(g+=W.nodeValue.length),(F=W.firstChild)!==null;)U=W,W=F;for(;;){if(W===e)break t;if(U===n&&++H===o&&(x=g),U===u&&++X===a&&(M=g),(F=W.nextSibling)!==null)break;W=U,U=W.parentNode}W=F}n=x===-1||M===-1?null:{start:x,end:M}}else n=null}n=n||{start:0,end:0}}else n=null;for(Uu={focusedElem:e,selectionRange:n},xo=!1,an=t;an!==null;)if(t=an,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,an=e;else for(;an!==null;){switch(t=an,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)o=e[n],o.ref.impl=o.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&u!==null){e=void 0,n=t,o=u.memoizedProps,u=u.memoizedState,a=n.stateNode;try{var Te=aa(n.type,o);e=a.getSnapshotBeforeUpdate(Te,u),a.__reactInternalSnapshotBeforeUpdate=e}catch(De){ht(n,n.return,De)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)Fu(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Fu(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(r(163))}if(e=t.sibling,e!==null){e.return=t.return,an=e;break}an=t.return}}function xm(e,t,n){var a=n.flags;switch(n.tag){case 0:case 11:case 15:qi(e,n),a&4&&Ks(5,n);break;case 1:if(qi(e,n),a&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(g){ht(n,n.return,g)}else{var o=aa(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(o,t,e.__reactInternalSnapshotBeforeUpdate)}catch(g){ht(n,n.return,g)}}a&64&&mm(n),a&512&&Is(n,n.return);break;case 3:if(qi(e,n),a&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{lh(e,t)}catch(g){ht(n,n.return,g)}}break;case 27:t===null&&a&4&&ym(n);case 26:case 5:qi(e,n),t===null&&a&4&&gm(n),a&512&&Is(n,n.return);break;case 12:qi(e,n);break;case 31:qi(e,n),a&4&&Cm(e,n);break;case 13:qi(e,n),a&4&&Tm(e,n),a&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=q0.bind(null,n),fv(e,n))));break;case 22:if(a=n.memoizedState!==null||Yi,!a){t=t!==null&&t.memoizedState!==null||Zt,o=Yi;var u=Zt;Yi=a,(Zt=t)&&!u?Vi(e,n,(n.subtreeFlags&8772)!==0):qi(e,n),Yi=o,Zt=u}break;case 30:break;default:qi(e,n)}}function wm(e){var t=e.alternate;t!==null&&(e.alternate=null,wm(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Gl(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 Lt=null,An=!1;function $i(e,t,n){for(n=n.child;n!==null;)Sm(e,t,n),n=n.sibling}function Sm(e,t,n){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(_e,n)}catch{}switch(n.tag){case 26:Zt||Ai(n,t),$i(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Zt||Ai(n,t);var a=Lt,o=An;Al(n.type)&&(Lt=n.stateNode,An=!1),$i(e,t,n),Zs(n.stateNode),Lt=a,An=o;break;case 5:Zt||Ai(n,t);case 6:if(a=Lt,o=An,Lt=null,$i(e,t,n),Lt=a,An=o,Lt!==null)if(An)try{(Lt.nodeType===9?Lt.body:Lt.nodeName==="HTML"?Lt.ownerDocument.body:Lt).removeChild(n.stateNode)}catch(u){ht(n,t,u)}else try{Lt.removeChild(n.stateNode)}catch(u){ht(n,t,u)}break;case 18:Lt!==null&&(An?(e=Lt,mp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Wa(e)):mp(Lt,n.stateNode));break;case 4:a=Lt,o=An,Lt=n.stateNode.containerInfo,An=!0,$i(e,t,n),Lt=a,An=o;break;case 0:case 11:case 14:case 15:vl(2,n,t),Zt||vl(4,n,t),$i(e,t,n);break;case 1:Zt||(Ai(n,t),a=n.stateNode,typeof a.componentWillUnmount=="function"&&pm(n,t,a)),$i(e,t,n);break;case 21:$i(e,t,n);break;case 22:Zt=(a=Zt)||n.memoizedState!==null,$i(e,t,n),Zt=a;break;default:$i(e,t,n)}}function Cm(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wa(e)}catch(n){ht(t,t.return,n)}}}function Tm(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wa(e)}catch(n){ht(t,t.return,n)}}function H0(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new vm),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new vm),t;default:throw Error(r(435,e.tag))}}function Jr(e,t){var n=H0(e);t.forEach(function(a){if(!n.has(a)){n.add(a);var o=V0.bind(null,e,a);a.then(o,o)}})}function En(e,t){var n=t.deletions;if(n!==null)for(var a=0;a<n.length;a++){var o=n[a],u=e,g=t,x=g;e:for(;x!==null;){switch(x.tag){case 27:if(Al(x.type)){Lt=x.stateNode,An=!1;break e}break;case 5:Lt=x.stateNode,An=!1;break e;case 3:case 4:Lt=x.stateNode.containerInfo,An=!0;break e}x=x.return}if(Lt===null)throw Error(r(160));Sm(u,g,o),Lt=null,An=!1,u=o.alternate,u!==null&&(u.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Mm(t,e),t=t.sibling}var fi=null;function Mm(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:En(t,e),Nn(e),a&4&&(vl(3,e,e.return),Ks(3,e),vl(5,e,e.return));break;case 1:En(t,e),Nn(e),a&512&&(Zt||n===null||Ai(n,n.return)),a&64&&Yi&&(e=e.updateQueue,e!==null&&(a=e.callbacks,a!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?a:n.concat(a))));break;case 26:var o=fi;if(En(t,e),Nn(e),a&512&&(Zt||n===null||Ai(n,n.return)),a&4){var u=n!==null?n.memoizedState:null;if(a=e.memoizedState,n===null)if(a===null)if(e.stateNode===null){e:{a=e.type,n=e.memoizedProps,o=o.ownerDocument||o;t:switch(a){case"title":u=o.getElementsByTagName("title")[0],(!u||u[_i]||u[Dt]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=o.createElement(a),o.head.insertBefore(u,o.querySelector("head > title"))),fn(u,a,n),u[Dt]=e,Ct(u),a=u;break e;case"link":var g=Mp("link","href",o).get(a+(n.href||""));if(g){for(var x=0;x<g.length;x++)if(u=g[x],u.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&u.getAttribute("rel")===(n.rel==null?null:n.rel)&&u.getAttribute("title")===(n.title==null?null:n.title)&&u.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){g.splice(x,1);break t}}u=o.createElement(a),fn(u,a,n),o.head.appendChild(u);break;case"meta":if(g=Mp("meta","content",o).get(a+(n.content||""))){for(x=0;x<g.length;x++)if(u=g[x],u.getAttribute("content")===(n.content==null?null:""+n.content)&&u.getAttribute("name")===(n.name==null?null:n.name)&&u.getAttribute("property")===(n.property==null?null:n.property)&&u.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&u.getAttribute("charset")===(n.charSet==null?null:n.charSet)){g.splice(x,1);break t}}u=o.createElement(a),fn(u,a,n),o.head.appendChild(u);break;default:throw Error(r(468,a))}u[Dt]=e,Ct(u),a=u}e.stateNode=a}else Ap(o,e.type,e.stateNode);else e.stateNode=Tp(o,a,e.memoizedProps);else u!==a?(u===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):u.count--,a===null?Ap(o,e.type,e.stateNode):Tp(o,a,e.memoizedProps)):a===null&&e.stateNode!==null&&mu(e,e.memoizedProps,n.memoizedProps)}break;case 27:En(t,e),Nn(e),a&512&&(Zt||n===null||Ai(n,n.return)),n!==null&&a&4&&mu(e,e.memoizedProps,n.memoizedProps);break;case 5:if(En(t,e),Nn(e),a&512&&(Zt||n===null||Ai(n,n.return)),e.flags&32){o=e.stateNode;try{ri(o,"")}catch(Te){ht(e,e.return,Te)}}a&4&&e.stateNode!=null&&(o=e.memoizedProps,mu(e,o,n!==null?n.memoizedProps:o)),a&1024&&(bu=!0);break;case 6:if(En(t,e),Nn(e),a&4){if(e.stateNode===null)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(Te){ht(e,e.return,Te)}}break;case 3:if(go=null,o=fi,fi=mo(t.containerInfo),En(t,e),fi=o,Nn(e),a&4&&n!==null&&n.memoizedState.isDehydrated)try{Wa(t.containerInfo)}catch(Te){ht(e,e.return,Te)}bu&&(bu=!1,Am(e));break;case 4:a=fi,fi=mo(e.stateNode.containerInfo),En(t,e),Nn(e),fi=a;break;case 12:En(t,e),Nn(e);break;case 31:En(t,e),Nn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Jr(e,a)));break;case 13:En(t,e),Nn(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(to=qe()),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Jr(e,a)));break;case 22:o=e.memoizedState!==null;var M=n!==null&&n.memoizedState!==null,H=Yi,X=Zt;if(Yi=H||o,Zt=X||M,En(t,e),Zt=X,Yi=H,Nn(e),a&8192)e:for(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,o&&(n===null||M||Yi||Zt||sa(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){M=n=t;try{if(u=M.stateNode,o)g=u.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none";else{x=M.stateNode;var W=M.memoizedProps.style,U=W!=null&&W.hasOwnProperty("display")?W.display:null;x.style.display=U==null||typeof U=="boolean"?"":(""+U).trim()}}catch(Te){ht(M,M.return,Te)}}}else if(t.tag===6){if(n===null){M=t;try{M.stateNode.nodeValue=o?"":M.memoizedProps}catch(Te){ht(M,M.return,Te)}}}else if(t.tag===18){if(n===null){M=t;try{var F=M.stateNode;o?pp(F,!0):pp(M.stateNode,!1)}catch(Te){ht(M,M.return,Te)}}}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}a&4&&(a=e.updateQueue,a!==null&&(n=a.retryQueue,n!==null&&(a.retryQueue=null,Jr(e,n))));break;case 19:En(t,e),Nn(e),a&4&&(a=e.updateQueue,a!==null&&(e.updateQueue=null,Jr(e,a)));break;case 30:break;case 21:break;default:En(t,e),Nn(e)}}function Nn(e){var t=e.flags;if(t&2){try{for(var n,a=e.return;a!==null;){if(bm(a)){n=a;break}a=a.return}if(n==null)throw Error(r(160));switch(n.tag){case 27:var o=n.stateNode,u=pu(e);Wr(e,u,o);break;case 5:var g=n.stateNode;n.flags&32&&(ri(g,""),n.flags&=-33);var x=pu(e);Wr(e,x,g);break;case 3:case 4:var M=n.stateNode.containerInfo,H=pu(e);gu(e,H,M);break;default:throw Error(r(161))}}catch(X){ht(e,e.return,X)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Am(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Am(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function qi(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)xm(e,t.alternate,t),t=t.sibling}function sa(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:vl(4,t,t.return),sa(t);break;case 1:Ai(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&pm(t,t.return,n),sa(t);break;case 27:Zs(t.stateNode);case 26:case 5:Ai(t,t.return),sa(t);break;case 22:t.memoizedState===null&&sa(t);break;case 30:sa(t);break;default:sa(t)}e=e.sibling}}function Vi(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var a=t.alternate,o=e,u=t,g=u.flags;switch(u.tag){case 0:case 11:case 15:Vi(o,u,n),Ks(4,u);break;case 1:if(Vi(o,u,n),a=u,o=a.stateNode,typeof o.componentDidMount=="function")try{o.componentDidMount()}catch(H){ht(a,a.return,H)}if(a=u,o=a.updateQueue,o!==null){var x=a.stateNode;try{var M=o.shared.hiddenCallbacks;if(M!==null)for(o.shared.hiddenCallbacks=null,o=0;o<M.length;o++)ih(M[o],x)}catch(H){ht(a,a.return,H)}}n&&g&64&&mm(u),Is(u,u.return);break;case 27:ym(u);case 26:case 5:Vi(o,u,n),n&&a===null&&g&4&&gm(u),Is(u,u.return);break;case 12:Vi(o,u,n);break;case 31:Vi(o,u,n),n&&g&4&&Cm(o,u);break;case 13:Vi(o,u,n),n&&g&4&&Tm(o,u);break;case 22:u.memoizedState===null&&Vi(o,u,n),Is(u,u.return);break;case 30:break;default:Vi(o,u,n)}t=t.sibling}}function yu(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&&Es(n))}function vu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Es(e))}function hi(e,t,n,a){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Em(e,t,n,a),t=t.sibling}function Em(e,t,n,a){var o=t.flags;switch(t.tag){case 0:case 11:case 15:hi(e,t,n,a),o&2048&&Ks(9,t);break;case 1:hi(e,t,n,a);break;case 3:hi(e,t,n,a),o&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Es(e)));break;case 12:if(o&2048){hi(e,t,n,a),e=t.stateNode;try{var u=t.memoizedProps,g=u.id,x=u.onPostCommit;typeof x=="function"&&x(g,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(M){ht(t,t.return,M)}}else hi(e,t,n,a);break;case 31:hi(e,t,n,a);break;case 13:hi(e,t,n,a);break;case 23:break;case 22:u=t.stateNode,g=t.alternate,t.memoizedState!==null?u._visibility&2?hi(e,t,n,a):Fs(e,t):u._visibility&2?hi(e,t,n,a):(u._visibility|=2,Ia(e,t,n,a,(t.subtreeFlags&10256)!==0||!1)),o&2048&&yu(g,t);break;case 24:hi(e,t,n,a),o&2048&&vu(t.alternate,t);break;default:hi(e,t,n,a)}}function Ia(e,t,n,a,o){for(o=o&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var u=e,g=t,x=n,M=a,H=g.flags;switch(g.tag){case 0:case 11:case 15:Ia(u,g,x,M,o),Ks(8,g);break;case 23:break;case 22:var X=g.stateNode;g.memoizedState!==null?X._visibility&2?Ia(u,g,x,M,o):Fs(u,g):(X._visibility|=2,Ia(u,g,x,M,o)),o&&H&2048&&yu(g.alternate,g);break;case 24:Ia(u,g,x,M,o),o&&H&2048&&vu(g.alternate,g);break;default:Ia(u,g,x,M,o)}t=t.sibling}}function Fs(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,a=t,o=a.flags;switch(a.tag){case 22:Fs(n,a),o&2048&&yu(a.alternate,a);break;case 24:Fs(n,a),o&2048&&vu(a.alternate,a);break;default:Fs(n,a)}t=t.sibling}}var Gs=8192;function Fa(e,t,n){if(e.subtreeFlags&Gs)for(e=e.child;e!==null;)Nm(e,t,n),e=e.sibling}function Nm(e,t,n){switch(e.tag){case 26:Fa(e,t,n),e.flags&Gs&&e.memoizedState!==null&&Tv(n,fi,e.memoizedState,e.memoizedProps);break;case 5:Fa(e,t,n);break;case 3:case 4:var a=fi;fi=mo(e.stateNode.containerInfo),Fa(e,t,n),fi=a;break;case 22:e.memoizedState===null&&(a=e.alternate,a!==null&&a.memoizedState!==null?(a=Gs,Gs=16777216,Fa(e,t,n),Gs=a):Fa(e,t,n));break;default:Fa(e,t,n)}}function km(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 Ys(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var a=t[n];an=a,Lm(a,e)}km(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Rm(e),e=e.sibling}function Rm(e){switch(e.tag){case 0:case 11:case 15:Ys(e),e.flags&2048&&vl(9,e,e.return);break;case 3:Ys(e);break;case 12:Ys(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,eo(e)):Ys(e);break;default:Ys(e)}}function eo(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var a=t[n];an=a,Lm(a,e)}km(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:vl(8,t,t.return),eo(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,eo(t));break;default:eo(t)}e=e.sibling}}function Lm(e,t){for(;an!==null;){var n=an;switch(n.tag){case 0:case 11:case 15:vl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var a=n.memoizedState.cachePool.pool;a!=null&&a.refCount++}break;case 24:Es(n.memoizedState.cache)}if(a=n.child,a!==null)a.return=n,an=a;else e:for(n=e;an!==null;){a=an;var o=a.sibling,u=a.return;if(wm(a),a===n){an=null;break e}if(o!==null){o.return=u,an=o;break e}an=u}}}var U0={getCacheForType:function(e){var t=un(Vt),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return un(Vt).controller.signal}},K0=typeof WeakMap=="function"?WeakMap:Map,st=0,xt=null,Ze=null,Je=0,ft=0,Fn=null,xl=!1,Ga=!1,xu=!1,Xi=0,Ut=0,wl=0,ra=0,wu=0,Gn=0,Ya=0,$s=null,kn=null,Su=!1,to=0,_m=0,no=1/0,io=null,Sl=null,tn=0,Cl=null,$a=null,Pi=0,Cu=0,Tu=null,jm=null,qs=0,Mu=null;function Yn(){return(st&2)!==0&&Je!==0?Je&-Je:k.T!==null?Lu():qt()}function Dm(){if(Gn===0)if((Je&536870912)===0||tt){var e=Ge;Ge<<=1,(Ge&3932160)===0&&(Ge=262144),Gn=e}else Gn=536870912;return e=Kn.current,e!==null&&(e.flags|=32),Gn}function Rn(e,t,n){(e===xt&&(ft===2||ft===9)||e.cancelPendingCommit!==null)&&(qa(e,0),Tl(e,Je,Gn,!1)),$n(e,n),((st&2)===0||e!==xt)&&(e===xt&&((st&2)===0&&(ra|=n),Ut===4&&Tl(e,Je,Gn,!1)),Ei(e))}function Om(e,t,n){if((st&6)!==0)throw Error(r(327));var a=!n&&(t&127)===0&&(t&e.expiredLanes)===0||on(e,t),o=a?G0(e,t):Eu(e,t,!0),u=a;do{if(o===0){Ga&&!a&&Tl(e,t,0,!1);break}else{if(n=e.current.alternate,u&&!I0(n)){o=Eu(e,t,!1),u=!1;continue}if(o===2){if(u=t,e.errorRecoveryDisabledLanes&u)var g=0;else g=e.pendingLanes&-536870913,g=g!==0?g:g&536870912?536870912:0;if(g!==0){t=g;e:{var x=e;o=$s;var M=x.current.memoizedState.isDehydrated;if(M&&(qa(x,g).flags|=256),g=Eu(x,g,!1),g!==2){if(xu&&!M){x.errorRecoveryDisabledLanes|=u,ra|=u,o=4;break e}u=kn,kn=o,u!==null&&(kn===null?kn=u:kn.push.apply(kn,u))}o=g}if(u=!1,o!==2)continue}}if(o===1){qa(e,0),Tl(e,t,0,!0);break}e:{switch(a=e,u=o,u){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:Tl(a,t,Gn,!xl);break e;case 2:kn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(o=to+300-qe(),10<o)){if(Tl(a,t,Gn,!xl),jt(a,0,!0)!==0)break e;Pi=t,a.timeoutHandle=fp(zm.bind(null,a,n,kn,io,Su,t,Gn,ra,Ya,xl,u,"Throttled",-0,0),o);break e}zm(a,n,kn,io,Su,t,Gn,ra,Ya,xl,u,null,-0,0)}}break}while(!0);Ei(e)}function zm(e,t,n,a,o,u,g,x,M,H,X,W,U,F){if(e.timeoutHandle=-1,W=t.subtreeFlags,W&8192||(W&16785408)===16785408){W={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:oi},Nm(t,u,W);var Te=(u&62914560)===u?to-qe():(u&4194048)===u?_m-qe():0;if(Te=Mv(W,Te),Te!==null){Pi=u,e.cancelPendingCommit=Te(Ym.bind(null,e,t,u,n,a,o,g,x,M,X,W,null,U,F)),Tl(e,u,g,!H);return}}Ym(e,t,u,n,a,o,g,x,M)}function I0(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 a=0;a<n.length;a++){var o=n[a],u=o.getSnapshot;o=o.value;try{if(!Hn(u(),o))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 Tl(e,t,n,a){t&=~wu,t&=~ra,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var o=t;0<o;){var u=31-dt(o),g=1<<u;a[u]=-1,o&=~g}n!==0&&Fl(e,n,t)}function lo(){return(st&6)===0?(Vs(0),!1):!0}function Au(){if(Ze!==null){if(ft===0)var e=Ze.return;else e=Ze,Hi=Wl=null,Fc(e),za=null,ks=0,e=Ze;for(;e!==null;)hm(e.alternate,e),e=e.return;Ze=null}}function qa(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,rv(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Pi=0,Au(),xt=e,Ze=n=zi(e.current,null),Je=t,ft=0,Fn=null,xl=!1,Ga=on(e,t),xu=!1,Ya=Gn=wu=ra=wl=Ut=0,kn=$s=null,Su=!1,(t&8)!==0&&(t|=t&32);var a=e.entangledLanes;if(a!==0)for(e=e.entanglements,a&=t;0<a;){var o=31-dt(a),u=1<<o;t|=e[o],a&=~u}return Xi=t,Mr(),n}function Bm(e,t){Ie=null,k.H=Bs,t===Oa||t===jr?(t=Jf(),ft=3):t===Rc?(t=Jf(),ft=4):ft=t===lu?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Fn=t,Ze===null&&(Ut=1,Vr(e,Qn(t,e.current)))}function Hm(){var e=Kn.current;return e===null?!0:(Je&4194048)===Je?ti===null:(Je&62914560)===Je||(Je&536870912)!==0?e===ti:!1}function Um(){var e=k.H;return k.H=Bs,e===null?Bs:e}function Km(){var e=k.A;return k.A=U0,e}function ao(){Ut=4,xl||(Je&4194048)!==Je&&Kn.current!==null||(Ga=!0),(wl&134217727)===0&&(ra&134217727)===0||xt===null||Tl(xt,Je,Gn,!1)}function Eu(e,t,n){var a=st;st|=2;var o=Um(),u=Km();(xt!==e||Je!==t)&&(io=null,qa(e,t)),t=!1;var g=Ut;e:do try{if(ft!==0&&Ze!==null){var x=Ze,M=Fn;switch(ft){case 8:Au(),g=6;break e;case 3:case 2:case 9:case 6:Kn.current===null&&(t=!0);var H=ft;if(ft=0,Fn=null,Va(e,x,M,H),n&&Ga){g=0;break e}break;default:H=ft,ft=0,Fn=null,Va(e,x,M,H)}}F0(),g=Ut;break}catch(X){Bm(e,X)}while(!0);return t&&e.shellSuspendCounter++,Hi=Wl=null,st=a,k.H=o,k.A=u,Ze===null&&(xt=null,Je=0,Mr()),g}function F0(){for(;Ze!==null;)Im(Ze)}function G0(e,t){var n=st;st|=2;var a=Um(),o=Km();xt!==e||Je!==t?(io=null,no=qe()+500,qa(e,t)):Ga=on(e,t);e:do try{if(ft!==0&&Ze!==null){t=Ze;var u=Fn;t:switch(ft){case 1:ft=0,Fn=null,Va(e,t,u,1);break;case 2:case 9:if(Qf(u)){ft=0,Fn=null,Fm(t);break}t=function(){ft!==2&&ft!==9||xt!==e||(ft=7),Ei(e)},u.then(t,t);break e;case 3:ft=7;break e;case 4:ft=5;break e;case 7:Qf(u)?(ft=0,Fn=null,Fm(t)):(ft=0,Fn=null,Va(e,t,u,7));break;case 5:var g=null;switch(Ze.tag){case 26:g=Ze.memoizedState;case 5:case 27:var x=Ze;if(g?Ep(g):x.stateNode.complete){ft=0,Fn=null;var M=x.sibling;if(M!==null)Ze=M;else{var H=x.return;H!==null?(Ze=H,so(H)):Ze=null}break t}}ft=0,Fn=null,Va(e,t,u,5);break;case 6:ft=0,Fn=null,Va(e,t,u,6);break;case 8:Au(),Ut=6;break e;default:throw Error(r(462))}}Y0();break}catch(X){Bm(e,X)}while(!0);return Hi=Wl=null,k.H=a,k.A=o,st=n,Ze!==null?0:(xt=null,Je=0,Mr(),Ut)}function Y0(){for(;Ze!==null&&!bn();)Im(Ze)}function Im(e){var t=dm(e.alternate,e,Xi);e.memoizedProps=e.pendingProps,t===null?so(e):Ze=t}function Fm(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=am(n,t,t.pendingProps,t.type,void 0,Je);break;case 11:t=am(n,t,t.pendingProps,t.type.render,t.ref,Je);break;case 5:Fc(t);default:hm(n,t),t=Ze=Kf(t,Xi),t=dm(n,t,Xi)}e.memoizedProps=e.pendingProps,t===null?so(e):Ze=t}function Va(e,t,n,a){Hi=Wl=null,Fc(t),za=null,ks=0;var o=t.return;try{if(_0(e,o,t,n,Je)){Ut=1,Vr(e,Qn(n,e.current)),Ze=null;return}}catch(u){if(o!==null)throw Ze=o,u;Ut=1,Vr(e,Qn(n,e.current)),Ze=null;return}t.flags&32768?(tt||a===1?e=!0:Ga||(Je&536870912)!==0?e=!1:(xl=e=!0,(a===2||a===9||a===3||a===6)&&(a=Kn.current,a!==null&&a.tag===13&&(a.flags|=16384))),Gm(t,e)):so(t)}function so(e){var t=e;do{if((t.flags&32768)!==0){Gm(t,xl);return}e=t.return;var n=O0(t.alternate,t,Xi);if(n!==null){Ze=n;return}if(t=t.sibling,t!==null){Ze=t;return}Ze=t=e}while(t!==null);Ut===0&&(Ut=5)}function Gm(e,t){do{var n=z0(e.alternate,e);if(n!==null){n.flags&=32767,Ze=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ze=e;return}Ze=e=n}while(e!==null);Ut=6,Ze=null}function Ym(e,t,n,a,o,u,g,x,M){e.cancelPendingCommit=null;do ro();while(tn!==0);if((st&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(u=t.lanes|t.childLanes,u|=pc,ba(e,n,u,g,x,M),e===xt&&(Ze=xt=null,Je=0),$a=t,Cl=e,Pi=n,Cu=u,Tu=o,jm=a,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,X0(Pe,function(){return Pm(),null})):(e.callbackNode=null,e.callbackPriority=0),a=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||a){a=k.T,k.T=null,o=I.p,I.p=2,g=st,st|=4;try{B0(e,t,n)}finally{st=g,I.p=o,k.T=a}}tn=1,$m(),qm(),Vm()}}function $m(){if(tn===1){tn=0;var e=Cl,t=$a,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=k.T,k.T=null;var a=I.p;I.p=2;var o=st;st|=4;try{Mm(t,e);var u=Uu,g=Lf(e.containerInfo),x=u.focusedElem,M=u.selectionRange;if(g!==x&&x&&x.ownerDocument&&Rf(x.ownerDocument.documentElement,x)){if(M!==null&&uc(x)){var H=M.start,X=M.end;if(X===void 0&&(X=H),"selectionStart"in x)x.selectionStart=H,x.selectionEnd=Math.min(X,x.value.length);else{var W=x.ownerDocument||document,U=W&&W.defaultView||window;if(U.getSelection){var F=U.getSelection(),Te=x.textContent.length,De=Math.min(M.start,Te),bt=M.end===void 0?De:Math.min(M.end,Te);!F.extend&&De>bt&&(g=bt,bt=De,De=g);var _=kf(x,De),N=kf(x,bt);if(_&&N&&(F.rangeCount!==1||F.anchorNode!==_.node||F.anchorOffset!==_.offset||F.focusNode!==N.node||F.focusOffset!==N.offset)){var B=W.createRange();B.setStart(_.node,_.offset),F.removeAllRanges(),De>bt?(F.addRange(B),F.extend(N.node,N.offset)):(B.setEnd(N.node,N.offset),F.addRange(B))}}}}for(W=[],F=x;F=F.parentNode;)F.nodeType===1&&W.push({element:F,left:F.scrollLeft,top:F.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<W.length;x++){var P=W[x];P.element.scrollLeft=P.left,P.element.scrollTop=P.top}}xo=!!Hu,Uu=Hu=null}finally{st=o,I.p=a,k.T=n}}e.current=t,tn=2}}function qm(){if(tn===2){tn=0;var e=Cl,t=$a,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=k.T,k.T=null;var a=I.p;I.p=2;var o=st;st|=4;try{xm(e,t.alternate,t)}finally{st=o,I.p=a,k.T=n}}tn=3}}function Vm(){if(tn===4||tn===3){tn=0,ut();var e=Cl,t=$a,n=Pi,a=jm;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?tn=5:(tn=0,$a=Cl=null,Xm(e,e.pendingLanes));var o=e.pendingLanes;if(o===0&&(Sl=null),qn(n),t=t.stateNode,mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(_e,t,void 0,(t.current.flags&128)===128)}catch{}if(a!==null){t=k.T,o=I.p,I.p=2,k.T=null;try{for(var u=e.onRecoverableError,g=0;g<a.length;g++){var x=a[g];u(x.value,{componentStack:x.stack})}}finally{k.T=t,I.p=o}}(Pi&3)!==0&&ro(),Ei(e),o=e.pendingLanes,(n&261930)!==0&&(o&42)!==0?e===Mu?qs++:(qs=0,Mu=e):qs=0,Vs(0)}}function Xm(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Es(t)))}function ro(){return $m(),qm(),Vm(),Pm()}function Pm(){if(tn!==5)return!1;var e=Cl,t=Cu;Cu=0;var n=qn(Pi),a=k.T,o=I.p;try{I.p=32>n?32:n,k.T=null,n=Tu,Tu=null;var u=Cl,g=Pi;if(tn=0,$a=Cl=null,Pi=0,(st&6)!==0)throw Error(r(331));var x=st;if(st|=4,Rm(u.current),Em(u,u.current,g,n),st=x,Vs(0,!1),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(_e,u)}catch{}return!0}finally{I.p=o,k.T=a,Xm(e,t)}}function Zm(e,t,n){t=Qn(n,t),t=iu(e.stateNode,t,2),e=gl(e,t,2),e!==null&&($n(e,2),Ei(e))}function ht(e,t,n){if(e.tag===3)Zm(e,e,n);else for(;t!==null;){if(t.tag===3){Zm(t,e,n);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Sl===null||!Sl.has(a))){e=Qn(n,e),n=Qh(2),a=gl(t,n,2),a!==null&&(Wh(n,a,t,e),$n(a,2),Ei(a));break}}t=t.return}}function Nu(e,t,n){var a=e.pingCache;if(a===null){a=e.pingCache=new K0;var o=new Set;a.set(t,o)}else o=a.get(t),o===void 0&&(o=new Set,a.set(t,o));o.has(n)||(xu=!0,o.add(n),e=$0.bind(null,e,t,n),t.then(e,e))}function $0(e,t,n){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,xt===e&&(Je&n)===n&&(Ut===4||Ut===3&&(Je&62914560)===Je&&300>qe()-to?(st&2)===0&&qa(e,0):wu|=n,Ya===Je&&(Ya=0)),Ei(e)}function Qm(e,t){t===0&&(t=St()),e=Pl(e,t),e!==null&&($n(e,t),Ei(e))}function q0(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Qm(e,n)}function V0(e,t){var n=0;switch(e.tag){case 31:case 13:var a=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}a!==null&&a.delete(t),Qm(e,n)}function X0(e,t){return ct(e,t)}var oo=null,Xa=null,ku=!1,co=!1,Ru=!1,Ml=0;function Ei(e){e!==Xa&&e.next===null&&(Xa===null?oo=Xa=e:Xa=Xa.next=e),co=!0,ku||(ku=!0,Z0())}function Vs(e,t){if(!Ru&&co){Ru=!0;do for(var n=!1,a=oo;a!==null;){if(e!==0){var o=a.pendingLanes;if(o===0)var u=0;else{var g=a.suspendedLanes,x=a.pingedLanes;u=(1<<31-dt(42|e)+1)-1,u&=o&~(g&~x),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(n=!0,tp(a,u))}else u=Je,u=jt(a,a===xt?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||on(a,u)||(n=!0,tp(a,u));a=a.next}while(n);Ru=!1}}function P0(){Wm()}function Wm(){co=ku=!1;var e=0;Ml!==0&&sv()&&(e=Ml);for(var t=qe(),n=null,a=oo;a!==null;){var o=a.next,u=Jm(a,t);u===0?(a.next=null,n===null?oo=o:n.next=o,o===null&&(Xa=n)):(n=a,(e!==0||(u&3)!==0)&&(co=!0)),a=o}tn!==0&&tn!==5||Vs(e),Ml!==0&&(Ml=0)}function Jm(e,t){for(var n=e.suspendedLanes,a=e.pingedLanes,o=e.expirationTimes,u=e.pendingLanes&-62914561;0<u;){var g=31-dt(u),x=1<<g,M=o[g];M===-1?((x&n)===0||(x&a)!==0)&&(o[g]=ga(x,t)):M<=t&&(e.expiredLanes|=x),u&=~x}if(t=xt,n=Je,n=jt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a=e.callbackNode,n===0||e===t&&(ft===2||ft===9)||e.cancelPendingCommit!==null)return a!==null&&a!==null&&Ke(a),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||on(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(a!==null&&Ke(a),qn(n)){case 2:case 8:n=We;break;case 32:n=Pe;break;case 268435456:n=E;break;default:n=Pe}return a=ep.bind(null,e),n=ct(n,a),e.callbackPriority=t,e.callbackNode=n,t}return a!==null&&a!==null&&Ke(a),e.callbackPriority=2,e.callbackNode=null,2}function ep(e,t){if(tn!==0&&tn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(ro()&&e.callbackNode!==n)return null;var a=Je;return a=jt(e,e===xt?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),a===0?null:(Om(e,a,t),Jm(e,qe()),e.callbackNode!=null&&e.callbackNode===n?ep.bind(null,e):null)}function tp(e,t){if(ro())return null;Om(e,t,!0)}function Z0(){ov(function(){(st&6)!==0?ct(yn,P0):Wm()})}function Lu(){if(Ml===0){var e=ja;e===0&&(e=It,It<<=1,(It&261888)===0&&(It=256)),Ml=e}return Ml}function np(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Sa(""+e)}function ip(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 Q0(e,t,n,a,o){if(t==="submit"&&n&&n.stateNode===o){var u=np((o[Jt]||null).action),g=a.submitter;g&&(t=(t=g[Jt]||null)?np(t.formAction):g.getAttribute("formAction"),t!==null&&(u=t,g=null));var x=new Ee("action","action",null,a,o);e.push({event:x,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(Ml!==0){var M=g?ip(o,g):new FormData(o);Qc(n,{pending:!0,data:M,method:o.method,action:u},null,M)}}else typeof u=="function"&&(x.preventDefault(),M=g?ip(o,g):new FormData(o),Qc(n,{pending:!0,data:M,method:o.method,action:u},u,M))},currentTarget:o}]})}}for(var _u=0;_u<mc.length;_u++){var ju=mc[_u],W0=ju.toLowerCase(),J0=ju[0].toUpperCase()+ju.slice(1);di(W0,"on"+J0)}di(Df,"onAnimationEnd"),di(Of,"onAnimationIteration"),di(zf,"onAnimationStart"),di("dblclick","onDoubleClick"),di("focusin","onFocus"),di("focusout","onBlur"),di(p0,"onTransitionRun"),di(g0,"onTransitionStart"),di(b0,"onTransitionCancel"),di(Bf,"onTransitionEnd"),si("onMouseEnter",["mouseout","mouseover"]),si("onMouseLeave",["mouseout","mouseover"]),si("onPointerEnter",["pointerout","pointerover"]),si("onPointerLeave",["pointerout","pointerover"]),Xn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Xn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Xn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Xn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Xn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Xn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xs="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(" "),ev=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xs));function lp(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var a=e[n],o=a.event;a=a.listeners;e:{var u=void 0;if(t)for(var g=a.length-1;0<=g;g--){var x=a[g],M=x.instance,H=x.currentTarget;if(x=x.listener,M!==u&&o.isPropagationStopped())break e;u=x,o.currentTarget=H;try{u(o)}catch(X){Tr(X)}o.currentTarget=null,u=M}else for(g=0;g<a.length;g++){if(x=a[g],M=x.instance,H=x.currentTarget,x=x.listener,M!==u&&o.isPropagationStopped())break e;u=x,o.currentTarget=H;try{u(o)}catch(X){Tr(X)}o.currentTarget=null,u=M}}}}function Qe(e,t){var n=t[bi];n===void 0&&(n=t[bi]=new Set);var a=e+"__bubble";n.has(a)||(ap(t,e,2,!1),n.add(a))}function Du(e,t,n){var a=0;t&&(a|=4),ap(n,e,a,t)}var uo="_reactListening"+Math.random().toString(36).slice(2);function Ou(e){if(!e[uo]){e[uo]=!0,Vn.forEach(function(n){n!=="selectionchange"&&(ev.has(n)||Du(n,!1,e),Du(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[uo]||(t[uo]=!0,Du("selectionchange",!1,t))}}function ap(e,t,n,a){switch(Dp(t)){case 2:var o=Nv;break;case 8:o=kv;break;default:o=Zu}n=o.bind(null,t,n,e),o=void 0,!cl||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),a?o!==void 0?e.addEventListener(t,n,{capture:!0,passive:o}):e.addEventListener(t,n,!0):o!==void 0?e.addEventListener(t,n,{passive:o}):e.addEventListener(t,n,!1)}function zu(e,t,n,a,o){var u=a;if((t&1)===0&&(t&2)===0&&a!==null)e:for(;;){if(a===null)return;var g=a.tag;if(g===3||g===4){var x=a.stateNode.containerInfo;if(x===o)break;if(g===4)for(g=a.return;g!==null;){var M=g.tag;if((M===3||M===4)&&g.stateNode.containerInfo===o)return;g=g.return}for(;x!==null;){if(g=yi(x),g===null)return;if(M=g.tag,M===5||M===6||M===26||M===27){a=u=g;continue e}x=x.parentNode}}a=a.return}ys(function(){var H=u,X=pn(n),W=[];e:{var U=Hf.get(e);if(U!==void 0){var F=Ee,Te=e;switch(e){case"keypress":if(ge(n)===0)break e;case"keydown":case"keyup":F=Vy;break;case"focusin":Te="focus",F=ac;break;case"focusout":Te="blur",F=ac;break;case"beforeblur":case"afterblur":F=ac;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":F=vs;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":F=Oy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":F=Zy;break;case Df:case Of:case zf:F=Hy;break;case Bf:F=Wy;break;case"scroll":case"scrollend":F=Bt;break;case"wheel":F=e0;break;case"copy":case"cut":case"paste":F=Ky;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":F=pf;break;case"toggle":case"beforetoggle":F=n0}var De=(t&4)!==0,bt=!De&&(e==="scroll"||e==="scrollend"),_=De?U!==null?U+"Capture":null:U;De=[];for(var N=H,B;N!==null;){var P=N;if(B=P.stateNode,P=P.tag,P!==5&&P!==26&&P!==27||B===null||_===null||(P=ol(N,_),P!=null&&De.push(Ps(N,P,B))),bt)break;N=N.return}0<De.length&&(U=new F(U,Te,null,n,X),W.push({event:U,listeners:De}))}}if((t&7)===0){e:{if(U=e==="mouseover"||e==="pointerover",F=e==="mouseout"||e==="pointerout",U&&n!==bs&&(Te=n.relatedTarget||n.fromElement)&&(yi(Te)||Te[On]))break e;if((F||U)&&(U=X.window===X?X:(U=X.ownerDocument)?U.defaultView||U.parentWindow:window,F?(Te=n.relatedTarget||n.toElement,F=H,Te=Te?yi(Te):null,Te!==null&&(bt=f(Te),De=Te.tag,Te!==bt||De!==5&&De!==27&&De!==6)&&(Te=null)):(F=null,Te=H),F!==Te)){if(De=vs,P="onMouseLeave",_="onMouseEnter",N="mouse",(e==="pointerout"||e==="pointerover")&&(De=pf,P="onPointerLeave",_="onPointerEnter",N="pointer"),bt=F==null?U:xi(F),B=Te==null?U:xi(Te),U=new De(P,N+"leave",F,n,X),U.target=bt,U.relatedTarget=B,P=null,yi(X)===H&&(De=new De(_,N+"enter",Te,n,X),De.target=B,De.relatedTarget=bt,P=De),bt=P,F&&Te)t:{for(De=tv,_=F,N=Te,B=0,P=_;P;P=De(P))B++;P=0;for(var ke=N;ke;ke=De(ke))P++;for(;0<B-P;)_=De(_),B--;for(;0<P-B;)N=De(N),P--;for(;B--;){if(_===N||N!==null&&_===N.alternate){De=_;break t}_=De(_),N=De(N)}De=null}else De=null;F!==null&&sp(W,U,F,De,!1),Te!==null&&bt!==null&&sp(W,bt,Te,De,!0)}}e:{if(U=H?xi(H):window,F=U.nodeName&&U.nodeName.toLowerCase(),F==="select"||F==="input"&&U.type==="file")var it=Cf;else if(wf(U))if(Tf)it=f0;else{it=u0;var Me=c0}else F=U.nodeName,!F||F.toLowerCase()!=="input"||U.type!=="checkbox"&&U.type!=="radio"?H&&gs(H.elementType)&&(it=Cf):it=d0;if(it&&(it=it(e,H))){Sf(W,it,n,X);break e}Me&&Me(e,U,H),e==="focusout"&&H&&U.type==="number"&&H.memoizedProps.value!=null&&Ot(U,"number",U.value)}switch(Me=H?xi(H):window,e){case"focusin":(wf(Me)||Me.contentEditable==="true")&&(Ma=Me,dc=H,Ts=null);break;case"focusout":Ts=dc=Ma=null;break;case"mousedown":fc=!0;break;case"contextmenu":case"mouseup":case"dragend":fc=!1,_f(W,n,X);break;case"selectionchange":if(m0)break;case"keydown":case"keyup":_f(W,n,X)}var Ye;if(rc)e:{switch(e){case"compositionstart":var et="onCompositionStart";break e;case"compositionend":et="onCompositionEnd";break e;case"compositionupdate":et="onCompositionUpdate";break e}et=void 0}else Ta?vf(e,n)&&(et="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(et="onCompositionStart");et&&(gf&&n.locale!=="ko"&&(Ta||et!=="onCompositionStart"?et==="onCompositionEnd"&&Ta&&(Ye=ae()):(ci=X,Ca="value"in ci?ci.value:ci.textContent,Ta=!0)),Me=fo(H,et),0<Me.length&&(et=new mf(et,e,null,n,X),W.push({event:et,listeners:Me}),Ye?et.data=Ye:(Ye=xf(n),Ye!==null&&(et.data=Ye)))),(Ye=l0?a0(e,n):s0(e,n))&&(et=fo(H,"onBeforeInput"),0<et.length&&(Me=new mf("onBeforeInput","beforeinput",null,n,X),W.push({event:Me,listeners:et}),Me.data=Ye)),Q0(W,e,H,n,X)}lp(W,t)})}function Ps(e,t,n){return{instance:e,listener:t,currentTarget:n}}function fo(e,t){for(var n=t+"Capture",a=[];e!==null;){var o=e,u=o.stateNode;if(o=o.tag,o!==5&&o!==26&&o!==27||u===null||(o=ol(e,n),o!=null&&a.unshift(Ps(e,o,u)),o=ol(e,t),o!=null&&a.push(Ps(e,o,u))),e.tag===3)return a;e=e.return}return[]}function tv(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function sp(e,t,n,a,o){for(var u=t._reactName,g=[];n!==null&&n!==a;){var x=n,M=x.alternate,H=x.stateNode;if(x=x.tag,M!==null&&M===a)break;x!==5&&x!==26&&x!==27||H===null||(M=H,o?(H=ol(n,u),H!=null&&g.unshift(Ps(n,H,M))):o||(H=ol(n,u),H!=null&&g.push(Ps(n,H,M)))),n=n.return}g.length!==0&&e.push({event:t,listeners:g})}var nv=/\r\n?/g,iv=/\u0000|\uFFFD/g;function rp(e){return(typeof e=="string"?e:""+e).replace(nv,`
33
- `).replace(iv,"")}function op(e,t){return t=rp(t),rp(e)===t}function gt(e,t,n,a,o,u){switch(n){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||ri(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&ri(e,""+a);break;case"className":Si(e,"class",a);break;case"tabIndex":Si(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":Si(e,n,a);break;case"style":Sr(e,a,u);break;case"data":if(t!=="object"){Si(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(n);break}a=Sa(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if(typeof a=="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 u=="function"&&(n==="formAction"?(t!=="input"&&gt(e,t,"name",o.name,o,null),gt(e,t,"formEncType",o.formEncType,o,null),gt(e,t,"formMethod",o.formMethod,o,null),gt(e,t,"formTarget",o.formTarget,o,null)):(gt(e,t,"encType",o.encType,o,null),gt(e,t,"method",o.method,o,null),gt(e,t,"target",o.target,o,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(n);break}a=Sa(""+a),e.setAttribute(n,a);break;case"onClick":a!=null&&(e.onclick=oi);break;case"onScroll":a!=null&&Qe("scroll",e);break;case"onScrollEnd":a!=null&&Qe("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(n=a.__html,n!=null){if(o.children!=null)throw Error(r(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}n=Sa(""+a),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":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,""+a):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":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":a===!0?e.setAttribute(n,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Qe("beforetoggle",e),Qe("toggle",e),Di(e,"popover",a);break;case"xlinkActuate":z(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":z(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":z(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":z(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":z(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":z(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":z(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":z(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":z(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Di(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=ic.get(n)||n,Di(e,n,a))}}function Bu(e,t,n,a,o,u){switch(n){case"style":Sr(e,a,u);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(n=a.__html,n!=null){if(o.children!=null)throw Error(r(60));e.innerHTML=n}}break;case"children":typeof a=="string"?ri(e,a):(typeof a=="number"||typeof a=="bigint")&&ri(e,""+a);break;case"onScroll":a!=null&&Qe("scroll",e);break;case"onScrollEnd":a!=null&&Qe("scrollend",e);break;case"onClick":a!=null&&(e.onclick=oi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wi.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(o=n.endsWith("Capture"),t=n.slice(2,o?n.length-7:void 0),u=e[Jt]||null,u=u!=null?u[n]:null,typeof u=="function"&&e.removeEventListener(t,u,o),typeof a=="function")){typeof u!="function"&&u!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,o);break e}n in e?e[n]=a:a===!0?e.setAttribute(n,""):Di(e,n,a)}}}function fn(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Qe("error",e),Qe("load",e);var a=!1,o=!1,u;for(u in n)if(n.hasOwnProperty(u)){var g=n[u];if(g!=null)switch(u){case"src":a=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:gt(e,t,u,g,n,null)}}o&&gt(e,t,"srcSet",n.srcSet,n,null),a&&gt(e,t,"src",n.src,n,null);return;case"input":Qe("invalid",e);var x=u=g=o=null,M=null,H=null;for(a in n)if(n.hasOwnProperty(a)){var X=n[a];if(X!=null)switch(a){case"name":o=X;break;case"type":g=X;break;case"checked":M=X;break;case"defaultChecked":H=X;break;case"value":u=X;break;case"defaultValue":x=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(r(137,t));break;default:gt(e,t,a,X,n,null)}}nt(e,u,x,M,H,g,o,!1);return;case"select":Qe("invalid",e),a=g=u=null;for(o in n)if(n.hasOwnProperty(o)&&(x=n[o],x!=null))switch(o){case"value":u=x;break;case"defaultValue":g=x;break;case"multiple":a=x;default:gt(e,t,o,x,n,null)}t=u,n=g,e.multiple=!!a,t!=null?mn(e,!!a,t,!1):n!=null&&mn(e,!!a,n,!0);return;case"textarea":Qe("invalid",e),u=o=a=null;for(g in n)if(n.hasOwnProperty(g)&&(x=n[g],x!=null))switch(g){case"value":a=x;break;case"defaultValue":o=x;break;case"children":u=x;break;case"dangerouslySetInnerHTML":if(x!=null)throw Error(r(91));break;default:gt(e,t,g,x,n,null)}$l(e,a,o,u);return;case"option":for(M in n)if(n.hasOwnProperty(M)&&(a=n[M],a!=null))switch(M){case"selected":e.selected=a&&typeof a!="function"&&typeof a!="symbol";break;default:gt(e,t,M,a,n,null)}return;case"dialog":Qe("beforetoggle",e),Qe("toggle",e),Qe("cancel",e),Qe("close",e);break;case"iframe":case"object":Qe("load",e);break;case"video":case"audio":for(a=0;a<Xs.length;a++)Qe(Xs[a],e);break;case"image":Qe("error",e),Qe("load",e);break;case"details":Qe("toggle",e);break;case"embed":case"source":case"link":Qe("error",e),Qe("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(H in n)if(n.hasOwnProperty(H)&&(a=n[H],a!=null))switch(H){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:gt(e,t,H,a,n,null)}return;default:if(gs(t)){for(X in n)n.hasOwnProperty(X)&&(a=n[X],a!==void 0&&Bu(e,t,X,a,n,void 0));return}}for(x in n)n.hasOwnProperty(x)&&(a=n[x],a!=null&&gt(e,t,x,a,n,null))}function lv(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,u=null,g=null,x=null,M=null,H=null,X=null;for(F in n){var W=n[F];if(n.hasOwnProperty(F)&&W!=null)switch(F){case"checked":break;case"value":break;case"defaultValue":M=W;default:a.hasOwnProperty(F)||gt(e,t,F,null,a,W)}}for(var U in a){var F=a[U];if(W=n[U],a.hasOwnProperty(U)&&(F!=null||W!=null))switch(U){case"type":u=F;break;case"name":o=F;break;case"checked":H=F;break;case"defaultChecked":X=F;break;case"value":g=F;break;case"defaultValue":x=F;break;case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(r(137,t));break;default:F!==W&&gt(e,t,U,F,a,W)}}At(e,g,x,M,H,X,u,o);return;case"select":F=g=x=U=null;for(u in n)if(M=n[u],n.hasOwnProperty(u)&&M!=null)switch(u){case"value":break;case"multiple":F=M;default:a.hasOwnProperty(u)||gt(e,t,u,null,a,M)}for(o in a)if(u=a[o],M=n[o],a.hasOwnProperty(o)&&(u!=null||M!=null))switch(o){case"value":U=u;break;case"defaultValue":x=u;break;case"multiple":g=u;default:u!==M&&gt(e,t,o,u,a,M)}t=x,n=g,a=F,U!=null?mn(e,!!n,U,!1):!!a!=!!n&&(t!=null?mn(e,!!n,t,!0):mn(e,!!n,n?[]:"",!1));return;case"textarea":F=U=null;for(x in n)if(o=n[x],n.hasOwnProperty(x)&&o!=null&&!a.hasOwnProperty(x))switch(x){case"value":break;case"children":break;default:gt(e,t,x,null,a,o)}for(g in a)if(o=a[g],u=n[g],a.hasOwnProperty(g)&&(o!=null||u!=null))switch(g){case"value":U=o;break;case"defaultValue":F=o;break;case"children":break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(r(91));break;default:o!==u&&gt(e,t,g,o,a,u)}Oi(e,U,F);return;case"option":for(var Te in n)if(U=n[Te],n.hasOwnProperty(Te)&&U!=null&&!a.hasOwnProperty(Te))switch(Te){case"selected":e.selected=!1;break;default:gt(e,t,Te,null,a,U)}for(M in a)if(U=a[M],F=n[M],a.hasOwnProperty(M)&&U!==F&&(U!=null||F!=null))switch(M){case"selected":e.selected=U&&typeof U!="function"&&typeof U!="symbol";break;default:gt(e,t,M,U,a,F)}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 De in n)U=n[De],n.hasOwnProperty(De)&&U!=null&&!a.hasOwnProperty(De)&&gt(e,t,De,null,a,U);for(H in a)if(U=a[H],F=n[H],a.hasOwnProperty(H)&&U!==F&&(U!=null||F!=null))switch(H){case"children":case"dangerouslySetInnerHTML":if(U!=null)throw Error(r(137,t));break;default:gt(e,t,H,U,a,F)}return;default:if(gs(t)){for(var bt in n)U=n[bt],n.hasOwnProperty(bt)&&U!==void 0&&!a.hasOwnProperty(bt)&&Bu(e,t,bt,void 0,a,U);for(X in a)U=a[X],F=n[X],!a.hasOwnProperty(X)||U===F||U===void 0&&F===void 0||Bu(e,t,X,U,a,F);return}}for(var _ in n)U=n[_],n.hasOwnProperty(_)&&U!=null&&!a.hasOwnProperty(_)&&gt(e,t,_,null,a,U);for(W in a)U=a[W],F=n[W],!a.hasOwnProperty(W)||U===F||U==null&&F==null||gt(e,t,W,U,a,F)}function cp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function av(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),a=0;a<n.length;a++){var o=n[a],u=o.transferSize,g=o.initiatorType,x=o.duration;if(u&&x&&cp(g)){for(g=0,x=o.responseEnd,a+=1;a<n.length;a++){var M=n[a],H=M.startTime;if(H>x)break;var X=M.transferSize,W=M.initiatorType;X&&cp(W)&&(M=M.responseEnd,g+=X*(M<x?1:(x-H)/(M-H)))}if(--a,t+=8*(u+g)/(o.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 Hu=null,Uu=null;function ho(e){return e.nodeType===9?e:e.ownerDocument}function up(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 dp(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 Ku(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 sv(){var e=window.event;return e&&e.type==="popstate"?e===Iu?!1:(Iu=e,!0):(Iu=null,!1)}var fp=typeof setTimeout=="function"?setTimeout:void 0,rv=typeof clearTimeout=="function"?clearTimeout:void 0,hp=typeof Promise=="function"?Promise:void 0,ov=typeof queueMicrotask=="function"?queueMicrotask:typeof hp<"u"?function(e){return hp.resolve(null).then(e).catch(cv)}:fp;function cv(e){setTimeout(function(){throw e})}function Al(e){return e==="head"}function mp(e,t){var n=t,a=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"||n==="/&"){if(a===0){e.removeChild(o),Wa(t);return}a--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")a++;else if(n==="html")Zs(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Zs(n);for(var u=n.firstChild;u;){var g=u.nextSibling,x=u.nodeName;u[_i]||x==="SCRIPT"||x==="STYLE"||x==="LINK"&&u.rel.toLowerCase()==="stylesheet"||n.removeChild(u),u=g}}else n==="body"&&Zs(e.ownerDocument.body);n=o}while(n);Wa(t)}function pp(e,t){var n=e;e=0;do{var a=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||""),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=a}while(n)}function Fu(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":Fu(n),Gl(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function uv(e,t,n,a){for(;e.nodeType===1;){var o=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(a){if(!e[_i])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(u=e.getAttribute("rel"),u==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(u!==o.rel||e.getAttribute("href")!==(o.href==null||o.href===""?null:o.href)||e.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin)||e.getAttribute("title")!==(o.title==null?null:o.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(u=e.getAttribute("src"),(u!==(o.src==null?null:o.src)||e.getAttribute("type")!==(o.type==null?null:o.type)||e.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin))&&u&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var u=o.name==null?null:""+o.name;if(o.type==="hidden"&&e.getAttribute("name")===u)return e}else return e;if(e=ni(e.nextSibling),e===null)break}return null}function dv(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=ni(e.nextSibling),e===null))return null;return e}function gp(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=ni(e.nextSibling),e===null))return null;return e}function Gu(e){return e.data==="$?"||e.data==="$~"}function Yu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function fv(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var a=function(){t(),n.removeEventListener("DOMContentLoaded",a)};n.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}function ni(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var $u=null;function bp(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return ni(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function yp(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 vp(e,t,n){switch(t=ho(n),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function Zs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Gl(e)}var ii=new Map,xp=new Set;function mo(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Zi=I.d;I.d={f:hv,r:mv,D:pv,C:gv,L:bv,m:yv,X:xv,S:vv,M:wv};function hv(){var e=Zi.f(),t=lo();return e||t}function mv(e){var t=vi(e);t!==null&&t.tag===5&&t.type==="form"?Bh(t):Zi.r(e)}var Pa=typeof document>"u"?null:document;function wp(e,t,n){var a=Pa;if(a&&typeof t=="string"&&t){var o=je(t);o='link[rel="'+e+'"][href="'+o+'"]',typeof n=="string"&&(o+='[crossorigin="'+n+'"]'),xp.has(o)||(xp.add(o),e={rel:e,crossOrigin:n,href:t},a.querySelector(o)===null&&(t=a.createElement("link"),fn(t,"link",e),Ct(t),a.head.appendChild(t)))}}function pv(e){Zi.D(e),wp("dns-prefetch",e,null)}function gv(e,t){Zi.C(e,t),wp("preconnect",e,t)}function bv(e,t,n){Zi.L(e,t,n);var a=Pa;if(a&&e&&t){var o='link[rel="preload"][as="'+je(t)+'"]';t==="image"&&n&&n.imageSrcSet?(o+='[imagesrcset="'+je(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(o+='[imagesizes="'+je(n.imageSizes)+'"]')):o+='[href="'+je(e)+'"]';var u=o;switch(t){case"style":u=Za(e);break;case"script":u=Qa(e)}ii.has(u)||(e=v({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),ii.set(u,e),a.querySelector(o)!==null||t==="style"&&a.querySelector(Qs(u))||t==="script"&&a.querySelector(Ws(u))||(t=a.createElement("link"),fn(t,"link",e),Ct(t),a.head.appendChild(t)))}}function yv(e,t){Zi.m(e,t);var n=Pa;if(n&&e){var a=t&&typeof t.as=="string"?t.as:"script",o='link[rel="modulepreload"][as="'+je(a)+'"][href="'+je(e)+'"]',u=o;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Qa(e)}if(!ii.has(u)&&(e=v({rel:"modulepreload",href:e},t),ii.set(u,e),n.querySelector(o)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Ws(u)))return}a=n.createElement("link"),fn(a,"link",e),Ct(a),n.head.appendChild(a)}}}function vv(e,t,n){Zi.S(e,t,n);var a=Pa;if(a&&e){var o=ai(a).hoistableStyles,u=Za(e);t=t||"default";var g=o.get(u);if(!g){var x={loading:0,preload:null};if(g=a.querySelector(Qs(u)))x.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":t},n),(n=ii.get(u))&&qu(e,n);var M=g=a.createElement("link");Ct(M),fn(M,"link",e),M._p=new Promise(function(H,X){M.onload=H,M.onerror=X}),M.addEventListener("load",function(){x.loading|=1}),M.addEventListener("error",function(){x.loading|=2}),x.loading|=4,po(g,t,a)}g={type:"stylesheet",instance:g,count:1,state:x},o.set(u,g)}}}function xv(e,t){Zi.X(e,t);var n=Pa;if(n&&e){var a=ai(n).hoistableScripts,o=Qa(e),u=a.get(o);u||(u=n.querySelector(Ws(o)),u||(e=v({src:e,async:!0},t),(t=ii.get(o))&&Vu(e,t),u=n.createElement("script"),Ct(u),fn(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(o,u))}}function wv(e,t){Zi.M(e,t);var n=Pa;if(n&&e){var a=ai(n).hoistableScripts,o=Qa(e),u=a.get(o);u||(u=n.querySelector(Ws(o)),u||(e=v({src:e,async:!0,type:"module"},t),(t=ii.get(o))&&Vu(e,t),u=n.createElement("script"),Ct(u),fn(u,"link",e),n.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(o,u))}}function Sp(e,t,n,a){var o=(o=Be.current)?mo(o):null;if(!o)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Za(n.href),n=ai(o).hoistableStyles,a=n.get(t),a||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Za(n.href);var u=ai(o).hoistableStyles,g=u.get(e);if(g||(o=o.ownerDocument||o,g={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,g),(u=o.querySelector(Qs(e)))&&!u._p&&(g.instance=u,g.state.loading=5),ii.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},ii.set(e,n),u||Sv(o,e,n,g.state))),t&&a===null)throw Error(r(528,""));return g}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Qa(n),n=ai(o).hoistableScripts,a=n.get(t),a||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Za(e){return'href="'+je(e)+'"'}function Qs(e){return'link[rel="stylesheet"]['+e+"]"}function Cp(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function Sv(e,t,n,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),fn(t,"link",n),Ct(t),e.head.appendChild(t))}function Qa(e){return'[src="'+je(e)+'"]'}function Ws(e){return"script[async]"+e}function Tp(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+je(n.href)+'"]');if(a)return t.instance=a,Ct(a),a;var o=v({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Ct(a),fn(a,"style",o),po(a,n.precedence,e),t.instance=a;case"stylesheet":o=Za(n.href);var u=e.querySelector(Qs(o));if(u)return t.state.loading|=4,t.instance=u,Ct(u),u;a=Cp(n),(o=ii.get(o))&&qu(a,o),u=(e.ownerDocument||e).createElement("link"),Ct(u);var g=u;return g._p=new Promise(function(x,M){g.onload=x,g.onerror=M}),fn(u,"link",a),t.state.loading|=4,po(u,n.precedence,e),t.instance=u;case"script":return u=Qa(n.src),(o=e.querySelector(Ws(u)))?(t.instance=o,Ct(o),o):(a=n,(o=ii.get(u))&&(a=v({},n),Vu(a,o)),e=e.ownerDocument||e,o=e.createElement("script"),Ct(o),fn(o,"link",a),e.head.appendChild(o),t.instance=o);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,po(a,n.precedence,e));return t.instance}function po(e,t,n){for(var a=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),o=a.length?a[a.length-1]:null,u=o,g=0;g<a.length;g++){var x=a[g];if(x.dataset.precedence===t)u=x;else if(u!==o)break}u?u.parentNode.insertBefore(e,u.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function qu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Vu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var go=null;function Mp(e,t,n){if(go===null){var a=new Map,o=go=new Map;o.set(n,a)}else o=go,a=o.get(n),a||(a=new Map,o.set(n,a));if(a.has(e))return a;for(a.set(e,null),n=n.getElementsByTagName(e),o=0;o<n.length;o++){var u=n[o];if(!(u[_i]||u[Dt]||e==="link"&&u.getAttribute("rel")==="stylesheet")&&u.namespaceURI!=="http://www.w3.org/2000/svg"){var g=u.getAttribute(t)||"";g=e+g;var x=a.get(g);x?x.push(u):a.set(g,[u])}}return a}function Ap(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Cv(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 Ep(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Tv(e,t,n,a){if(n.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var o=Za(a.href),u=t.querySelector(Qs(o));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=bo.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=u,Ct(u);return}u=t.ownerDocument||t,a=Cp(a),(o=ii.get(o))&&qu(a,o),u=u.createElement("link"),Ct(u);var g=u;g._p=new Promise(function(x,M){g.onload=x,g.onerror=M}),fn(u,"link",a),n.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=bo.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var Xu=0;function Mv(e,t){return e.stylesheets&&e.count===0&&vo(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var a=setTimeout(function(){if(e.stylesheets&&vo(e,e.stylesheets),e.unsuspend){var u=e.unsuspend;e.unsuspend=null,u()}},6e4+t);0<e.imgBytes&&Xu===0&&(Xu=62500*av());var o=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&vo(e,e.stylesheets),e.unsuspend)){var u=e.unsuspend;e.unsuspend=null,u()}},(e.imgBytes>Xu?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(o)}}:null}function bo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)vo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var yo=null;function vo(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,yo=new Map,t.forEach(Av,e),yo=null,bo.call(e))}function Av(e,t){if(!(t.state.loading&4)){var n=yo.get(e);if(n)var a=n.get(null);else{n=new Map,yo.set(e,n);for(var o=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u<o.length;u++){var g=o[u];(g.nodeName==="LINK"||g.getAttribute("media")!=="not all")&&(n.set(g.dataset.precedence,g),a=g)}a&&n.set(null,a)}o=t.instance,g=o.getAttribute("data-precedence"),u=n.get(g)||a,u===a&&n.set(null,o),n.set(g,o),this.count++,a=bo.bind(this),o.addEventListener("load",a),o.addEventListener("error",a),u?u.parentNode.insertBefore(o,u.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(o,e.firstChild)),t.state.loading|=4}}var Js={$$typeof:Y,Provider:null,Consumer:null,_currentValue:le,_currentValue2:le,_threadCount:0};function Ev(e,t,n,a,o,u,g,x,M){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=tl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tl(0),this.hiddenUpdates=tl(null),this.identifierPrefix=a,this.onUncaughtError=o,this.onCaughtError=u,this.onRecoverableError=g,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function Np(e,t,n,a,o,u,g,x,M,H,X,W){return e=new Ev(e,t,n,g,M,H,X,W,x),t=1,u===!0&&(t|=24),u=Un(3,null,null,t),e.current=u,u.stateNode=e,t=Ec(),t.refCount++,e.pooledCache=t,t.refCount++,u.memoizedState={element:a,isDehydrated:n,cache:t},Lc(u),e}function kp(e){return e?(e=Na,e):Na}function Rp(e,t,n,a,o,u){o=kp(o),a.context===null?a.context=o:a.pendingContext=o,a=pl(t),a.payload={element:n},u=u===void 0?null:u,u!==null&&(a.callback=u),n=gl(e,a,t),n!==null&&(Rn(n,e,t),Ls(n,e,t))}function Lp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Pu(e,t){Lp(e,t),(e=e.alternate)&&Lp(e,t)}function _p(e){if(e.tag===13||e.tag===31){var t=Pl(e,67108864);t!==null&&Rn(t,e,67108864),Pu(e,67108864)}}function jp(e){if(e.tag===13||e.tag===31){var t=Yn();t=xn(t);var n=Pl(e,t);n!==null&&Rn(n,e,t),Pu(e,t)}}var xo=!0;function Nv(e,t,n,a){var o=k.T;k.T=null;var u=I.p;try{I.p=2,Zu(e,t,n,a)}finally{I.p=u,k.T=o}}function kv(e,t,n,a){var o=k.T;k.T=null;var u=I.p;try{I.p=8,Zu(e,t,n,a)}finally{I.p=u,k.T=o}}function Zu(e,t,n,a){if(xo){var o=Qu(a);if(o===null)zu(e,t,a,wo,n),Op(e,a);else if(Lv(o,e,t,n,a))a.stopPropagation();else if(Op(e,a),t&4&&-1<Rv.indexOf(e)){for(;o!==null;){var u=vi(o);if(u!==null)switch(u.tag){case 3:if(u=u.stateNode,u.current.memoizedState.isDehydrated){var g=Cn(u.pendingLanes);if(g!==0){var x=u;for(x.pendingLanes|=2,x.entangledLanes|=2;g;){var M=1<<31-dt(g);x.entanglements[1]|=M,g&=~M}Ei(u),(st&6)===0&&(no=qe()+500,Vs(0))}}break;case 31:case 13:x=Pl(u,2),x!==null&&Rn(x,u,2),lo(),Pu(u,2)}if(u=Qu(a),u===null&&zu(e,t,a,wo,n),u===o)break;o=u}o!==null&&a.stopPropagation()}else zu(e,t,a,null,n)}}function Qu(e){return e=pn(e),Wu(e)}var wo=null;function Wu(e){if(wo=null,e=yi(e),e!==null){var t=f(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=h(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 wo=e,null}function Dp(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(wt()){case yn:return 2;case We:return 8;case Pe:case Mt:return 32;case E:return 268435456;default:return 32}default:return 32}}var Ju=!1,El=null,Nl=null,kl=null,er=new Map,tr=new Map,Rl=[],Rv="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 Op(e,t){switch(e){case"focusin":case"focusout":El=null;break;case"dragenter":case"dragleave":Nl=null;break;case"mouseover":case"mouseout":kl=null;break;case"pointerover":case"pointerout":er.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":tr.delete(t.pointerId)}}function nr(e,t,n,a,o,u){return e===null||e.nativeEvent!==u?(e={blockedOn:t,domEventName:n,eventSystemFlags:a,nativeEvent:u,targetContainers:[o]},t!==null&&(t=vi(t),t!==null&&_p(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function Lv(e,t,n,a,o){switch(t){case"focusin":return El=nr(El,e,t,n,a,o),!0;case"dragenter":return Nl=nr(Nl,e,t,n,a,o),!0;case"mouseover":return kl=nr(kl,e,t,n,a,o),!0;case"pointerover":var u=o.pointerId;return er.set(u,nr(er.get(u)||null,e,t,n,a,o)),!0;case"gotpointercapture":return u=o.pointerId,tr.set(u,nr(tr.get(u)||null,e,t,n,a,o)),!0}return!1}function zp(e){var t=yi(e.target);if(t!==null){var n=f(t);if(n!==null){if(t=n.tag,t===13){if(t=h(n),t!==null){e.blockedOn=t,ya(e.priority,function(){jp(n)});return}}else if(t===31){if(t=m(n),t!==null){e.blockedOn=t,ya(e.priority,function(){jp(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 So(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Qu(e.nativeEvent);if(n===null){n=e.nativeEvent;var a=new n.constructor(n.type,n);bs=a,n.target.dispatchEvent(a),bs=null}else return t=vi(n),t!==null&&_p(t),e.blockedOn=n,!1;t.shift()}return!0}function Bp(e,t,n){So(e)&&n.delete(t)}function _v(){Ju=!1,El!==null&&So(El)&&(El=null),Nl!==null&&So(Nl)&&(Nl=null),kl!==null&&So(kl)&&(kl=null),er.forEach(Bp),tr.forEach(Bp)}function Co(e,t){e.blockedOn===t&&(e.blockedOn=null,Ju||(Ju=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,_v)))}var To=null;function Hp(e){To!==e&&(To=e,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){To===e&&(To=null);for(var t=0;t<e.length;t+=3){var n=e[t],a=e[t+1],o=e[t+2];if(typeof a!="function"){if(Wu(a||n)===null)continue;break}var u=vi(n);u!==null&&(e.splice(t,3),t-=3,Qc(u,{pending:!0,data:o,method:n.method,action:a},a,o))}}))}function Wa(e){function t(M){return Co(M,e)}El!==null&&Co(El,e),Nl!==null&&Co(Nl,e),kl!==null&&Co(kl,e),er.forEach(t),tr.forEach(t);for(var n=0;n<Rl.length;n++){var a=Rl[n];a.blockedOn===e&&(a.blockedOn=null)}for(;0<Rl.length&&(n=Rl[0],n.blockedOn===null);)zp(n),n.blockedOn===null&&Rl.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(a=0;a<n.length;a+=3){var o=n[a],u=n[a+1],g=o[Jt]||null;if(typeof u=="function")g||Hp(n);else if(g){var x=null;if(u&&u.hasAttribute("formAction")){if(o=u,g=u[Jt]||null)x=g.formAction;else if(Wu(o)!==null)continue}else x=g.action;typeof x=="function"?n[a+1]=x:(n.splice(a,3),a-=3),Hp(n)}}}function Up(){function e(u){u.canIntercept&&u.info==="react-transition"&&u.intercept({handler:function(){return new Promise(function(g){return o=g})},focusReset:"manual",scroll:"manual"})}function t(){o!==null&&(o(),o=null),a||setTimeout(n,20)}function n(){if(!a&&!navigation.transition){var u=navigation.currentEntry;u&&u.url!=null&&navigation.navigate(u.url,{state:u.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var a=!1,o=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){a=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),o!==null&&(o(),o=null)}}}function ed(e){this._internalRoot=e}Mo.prototype.render=ed.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var n=t.current,a=Yn();Rp(n,a,e,t,null,null)},Mo.prototype.unmount=ed.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Rp(e.current,2,null,e,null,null),lo(),t[On]=null}};function Mo(e){this._internalRoot=e}Mo.prototype.unstable_scheduleHydration=function(e){if(e){var t=qt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Rl.length&&t!==0&&t<Rl[n].priority;n++);Rl.splice(n,0,e),n===0&&zp(e)}};var Kp=i.version;if(Kp!=="19.2.8")throw Error(r(527,Kp,"19.2.8"));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=p(t),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var jv={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:k,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ao=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ao.isDisabled&&Ao.supportsFiber)try{_e=Ao.inject(jv),mt=Ao}catch{}}return lr.createRoot=function(e,t){if(!c(e))throw Error(r(299));var n=!1,a="",o=Vh,u=Xh,g=Ph;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(u=t.onCaughtError),t.onRecoverableError!==void 0&&(g=t.onRecoverableError)),t=Np(e,1,!1,null,null,n,a,null,o,u,g,Up),e[On]=t.current,Ou(e),new ed(t)},lr.hydrateRoot=function(e,t,n){if(!c(e))throw Error(r(299));var a=!1,o="",u=Vh,g=Xh,x=Ph,M=null;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(x=n.onRecoverableError),n.formState!==void 0&&(M=n.formState)),t=Np(e,1,!0,t,n??null,a,o,M,u,g,x,Up),t.context=kp(null),n=t.current,a=Yn(),a=xn(a),o=pl(a),o.callback=null,gl(n,o,a),n=a,t.current.lanes=n,$n(t,n),Ei(t),e[On]=t.current,Ou(e),new Mo(t)},lr.version="19.2.8",lr}var qp;function Yv(){if(qp)return nd.exports;qp=1;function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(i){console.error(i)}}return l(),nd.exports=Gv(),nd.exports}var $v=Yv();const qv=ab($v),ve={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~"},Vv=new TextEncoder;function Pd(l){return Vv.encode(l)}function rb(l){if(!l||l.length===0)return"";const s=l.toUpperCase().charCodeAt(0);return s>=65&&s<=90?String.fromCharCode(s-64):l==="@"||l===" "?"\0":l==="["?"\x1B":l==="\\"?"":l==="]"?"":l==="^"?"":l==="_"?"":l==="?"?"":l}function Xv(l){return`\x1B${l}`}function Vp({ctrl:l,alt:i,shift:s}){return 1+(s?1:0)+(i?2:0)+(l?4:0)}const ob=/^\x1b[[O]([ABCDHF])$/,cb=/^\x1bO([PQRS])$/,ub=/^\x1b\[(\d+)~$/;function $o(l,i){const{ctrl:s=!1,alt:r=!1,shift:c=!1}=i;if(!s&&!r&&!c)return l;const f=Vp(i),h=r&&!s&&!c,m=ob.exec(l);if(m)return`\x1B[1;${f}${m[1]}`;const b=cb.exec(l);if(b)return`\x1B[1;${f}${b[1]}`;const p=ub.exec(l);if(p)return`\x1B[${p[1]};${f}~`;switch(l){case ve.TAB:return c&&!s&&!r?ve.SHIFT_TAB:h?`\x1B${l}`:`\x1B[9;${f}u`;case ve.SHIFT_TAB:return!s&&!r?l:`\x1B[9;${Vp({...i,shift:!0})}u`;case ve.ENTER:return h?`\x1B${l}`:`\x1B[13;${f}u`;case ve.BACKSPACE:return s&&!r&&!c?"\b":h?`\x1B${l}`:`\x1B[127;${f}u`;case ve.ESC:return h?`\x1B${l}`:`\x1B[27;${f}u`}let y=l;return c&&l.length===1&&!s&&(y=l.toUpperCase()),s&&(y=rb(y)),r&&(y=Xv(y)),y}function Pv(l){return[...l].length===1?!0:ob.test(l)||cb.test(l)||ub.test(l)||l===ve.SHIFT_TAB}const db=27,fb=91,Zv=60,Xp=59,hb=77,mb=48,Qv=57,Wv=64,Jv=-30,ad=32,Pp=255;function pb(l){return Number.isInteger(l)&&(l&Jv)===Wv}function ex(l){return l>=mb&&l<=Qv}function sd(l,i){let s=i,r=0;for(;s<l.length&&ex(l[s]);){if(r=r*10+(l[s]-mb),r>65535)return null;s+=1}return s===i?null:{value:r,next:s}}function tx(l,i){if(l[i]!==db||l[i+1]!==fb||l[i+2]!==Zv)return-1;const s=sd(l,i+3);if(!s||!pb(s.value)||l[s.next]!==Xp)return-1;const r=sd(l,s.next+1);if(!r||l[r.next]!==Xp)return-1;const c=sd(l,r.next+1);return!c||l[c.next]!==hb?-1:c.next+1}function nx(l,i){if(l[i]!==db||l[i+1]!==fb||l[i+2]!==hb||i+6>l.length)return-1;const s=l[i+3]-ad,r=l[i+4],c=l[i+5];return!pb(s)||r<ad||r>Pp||c<ad||c>Pp?-1:i+6}function qo(l){if(!l)return!1;const i=l instanceof Uint8Array?l:new Uint8Array(l);if(i.length===0)return!1;let s=0;for(;s<i.length;){const r=tx(i,s);if(r>s){s=r;continue}const c=nx(i,s);if(c>s){s=c;continue}return!1}return!0}const ix=3e3,lx=1e4,ax=1500;class sx{constructor(i){Z(this,"ws",null);Z(this,"config");Z(this,"state","disconnected");Z(this,"currentRole","viewer");Z(this,"controllerId");Z(this,"hostId");Z(this,"assignedClientId");Z(this,"reconnectAttempts",0);Z(this,"reconnectTimer",null);Z(this,"pingTimer",null);Z(this,"pingTimestamp",null);Z(this,"lastInboundAt",0);Z(this,"pingSentAt",null);Z(this,"connectStartedAt",0);Z(this,"lastWakeConnectAt",0);Z(this,"probeTimer",null);Z(this,"rejectedByRelay",!1);Z(this,"isManuallyClosed",!1);Z(this,"authFailureDetail",null);Z(this,"authFailureCode",null);Z(this,"temporaryFailureCode",null);Z(this,"pendingInputSegments",[]);Z(this,"isFlushScheduled",!1);Z(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,updateStatus:new Set,terminalFont:new Set,hostFontChunk:new Set,hostFontSubset:new Set});Z(this,"terminalCols",80);Z(this,"terminalRows",24);this.config={...i}}updateConfig(i){this.config={...this.config,...i}}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(i,s){return this.listeners[i].add(s),()=>{this.listeners[i].delete(s)}}emit(i,...s){this.listeners[i].forEach(c=>{try{c(...s)}catch(f){console.error(`Error in event listener for ${i}:`,f)}})}setState(i,s,r){this.state!==i&&(this.state=i,this.emit("stateChange",i,s,r))}connect(i){if(i&&(this.terminalCols=i.cols,this.terminalRows=i.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 s=this.resolveWsUrl(this.config.wsUrl),r=new WebSocket(s);this.ws=r,this.connectStartedAt=Date.now(),r.binaryType="arraybuffer",r.onopen=()=>{this.isStaleSocket(r)||this.handleOpen()},r.onmessage=c=>{this.isStaleSocket(r)||this.handleMessage(c)},r.onerror=c=>{this.isStaleSocket(r)||this.handleError(c)},r.onclose=c=>{this.isStaleSocket(r)||this.handleClose(c)}}catch(s){this.setState("error",s instanceof Error?s.message:"Connection failed","connection_failed"),this.scheduleReconnect()}}}isStaleSocket(i){return this.ws!==i}teardownSocket(i=1e3,s="Client closed the connection"){this.pendingInputSegments=[],this.isFlushScheduled=!1;const r=this.ws;if(r){this.ws=null,r.onopen=null,r.onmessage=null,r.onerror=null,r.onclose=null;try{(r.readyState===WebSocket.OPEN||r.readyState===WebSocket.CONNECTING)&&r.close(i,s)}catch{}}}disconnect(){this.isManuallyClosed=!0,this.clearTimers(),this.pendingInputSegments=[],this.isFlushScheduled=!1,this.teardownSocket(1e3,"User initiated disconnect"),this.setState("disconnected")}reconnectWith(i){this.updateConfig(i),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(i){if(this.isManuallyClosed||!this.config.autoReconnect||this.authFailureDetail||this.rejectedByRelay)return;const s=Date.now(),r=this.ws;if(!r){if(s-this.lastWakeConnectAt<ax)return;this.lastWakeConnectAt=s,this.reconnectAttempts=0,this.connect();return}if(r.readyState===WebSocket.CONNECTING){s-this.connectStartedAt>lx&&this.dropStaleSocket("connection_stalled");return}r.readyState===WebSocket.OPEN&&s-this.lastInboundAt>this.pingIntervalMs()+2e3&&this.probeLiveness()}pingIntervalMs(){return this.config.pingIntervalMs||1e4}probeLiveness(){const i=this.ws;if(!i||i.readyState!==WebSocket.OPEN||this.probeTimer)return;const s=Date.now();this.sendPing(),this.probeTimer=setTimeout(()=>{this.probeTimer=null,this.ws===i&&this.lastInboundAt<s&&this.dropStaleSocket("connection_stale")},ix)}dropStaleSocket(i){this.clearTimers(),this.teardownSocket(4e3,"Connection went silent"),this.setState("reconnecting","The connection went silent. Reconnecting...",i),this.reconnectAttempts=0,this.lastWakeConnectAt=Date.now(),this.connect()}handleOpen(){this.lastInboundAt=Date.now(),this.sendHello(),this.startHeartbeat()}async handleMessage(i){if(this.lastInboundAt=Date.now(),typeof i.data=="string")try{const s=JSON.parse(i.data);this.processJsonMessage(s)}catch(s){console.warn("Received unparseable text frame from server:",s)}else if(i.data instanceof ArrayBuffer)this.emit("binaryData",new Uint8Array(i.data));else if(typeof Blob<"u"&&i.data instanceof Blob)try{const s=await i.data.arrayBuffer();this.emit("binaryData",new Uint8Array(s))}catch(s){console.error("Failed to convert Blob to ArrayBuffer:",s)}}processJsonMessage(i){switch(i.type){case"ready":{this.reconnectAttempts=0,this.setState("connected"),this.currentRole=i.role,this.controllerId=i.controllerId,this.hostId=i.hostId,this.assignedClientId=i.clientId,this.emit("ready",i),this.emit("roleChange",i.role,i.controllerId,i.hostId,i.clientId),typeof i.clientCount=="number"&&this.emit("peerCount",i.clientCount),this.emit("terminalFont",i.terminalFont??null);break}case"paired":{this.emit("paired",{token:i.token,deviceId:i.deviceId,hostId:i.hostId,expiresAt:i.expiresAt});break}case"control_state":{this.currentRole=i.role,this.controllerId=i.controllerId,this.emit("controlState",i.role,i.controllerId),this.emit("roleChange",i.role,i.controllerId,this.hostId,this.assignedClientId),typeof i.clientCount=="number"&&this.emit("peerCount",i.clientCount);break}case"host_reconnecting":{this.temporaryFailureCode="host_reconnecting",this.setState("reconnecting","Herdr host is reconnecting",i.code||"host_reconnecting"),this.emit("hostReconnecting",i.code);break}case"session_restarted":{this.setState("reconnecting","Herdr session is restarting","session_restarted"),this.emit("sessionRestarted",i.cols,i.rows,i.terminalPalette,i.hostname),this.emit("terminalFont",i.terminalFont??null);break}case"control_revoked":{this.currentRole="viewer",this.emit("controlRevoked",i.reason),this.emit("roleChange","viewer",this.controllerId,this.hostId,this.assignedClientId);break}case"session_ready":{this.setState("connected"),this.emit("sessionReady",i);break}case"exit":{this.emit("exit",i.code,i.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",i.message);break}case"status":{this.emit("status",i);break}case"error":{i.code==="host_offline"||i.code==="host_reconnecting"||i.code==="host_reconnect_timeout"||i.code==="rate_limited"?(this.temporaryFailureCode=String(i.code),this.setState("reconnecting",i.message,String(i.code))):(i.code==="auth_required"||i.code==="unauthorized"||i.code==="device_revoked"||i.code==="invalid_handshake"||i.code==="too_many_hosts"||i.code===401||i.code===403)&&(this.authFailureDetail=i.message,this.authFailureCode=String(i.code),this.setState("error",i.message,this.authFailureCode)),this.emit("error",{code:i.code,message:i.message});break}case"pong":{if(this.pingTimestamp){const s=Math.max(0,performance.now()-this.pingTimestamp);this.pingTimestamp=null,this.emit("rttUpdate",Math.round(s))}break}case"paste_file_ready":{this.emit("pasteFileReady",i.path);break}case"agent_status":{this.emit("agentStatus",i);break}case"update_status":{this.emit("updateStatus",i);break}case"terminal_font":{this.emit("terminalFont",i.terminalFont??null);break}case"host_font_chunk":{this.emit("hostFontChunk",i);break}case"host_font_subset_ready":{this.emit("hostFontSubset",i);break}}}handleError(i){console.error("WebSocket error:",i),this.emit("error",{code:"WS_ERROR",message:"WebSocket connection error"})}handleClose(i){if(this.clearTimers(),this.ws=null,this.authFailureDetail){this.setState("error",this.authFailureDetail,this.authFailureCode??void 0);return}if(i.code===1008&&this.temporaryFailureCode){this.setState("reconnecting",i.reason||"The relay is temporarily unavailable",this.temporaryFailureCode),this.scheduleReconnect();return}if(i.code===1008){this.rejectedByRelay=!0,this.setState("error",i.reason||"The relay rejected the connection",String(i.code));return}!this.isManuallyClosed&&this.config.autoReconnect?(this.setState("reconnecting",`Connection closed (${i.code}). Retrying...`,"connection_closed"),this.scheduleReconnect()):this.setState("disconnected",`Closed: ${i.reason||i.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 i=this.config.reconnectIntervalMs||2e3,r=Math.min(3e4,Math.floor(i*Math.pow(1.5,this.reconnectAttempts-1)+Math.random()*500));this.reconnectTimer=setTimeout(()=>{this.connect()},r)}startHeartbeat(){this.pingTimer&&clearInterval(this.pingTimer);const i=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>=i){this.probeLiveness();return}this.sendPing()}},i)}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 i={type:"hello",protocol:1,clientId:this.config.clientId,cols:this.terminalCols,rows:this.terminalRows,capabilities:["host_handoff"]};this.config.token&&(i.token=this.config.token),this.config.pairCode&&(i.pairCode=this.config.pairCode),this.sendJson(i)}claimControl(i=!1){const s={type:"claim_control",...i?{force:!0}:{}};this.sendJson(s)}releaseControl(){const i={type:"release_control"};this.sendJson(i)}sendResize(i,s){this.terminalCols=i,this.terminalRows=s;const r={type:"resize",cols:i,rows:s};this.sendJson(r)}sendPing(){this.pingTimestamp=performance.now(),this.pingSentAt=Date.now();const i={type:"ping"};this.sendJson(i)}sendPasteFile(i,s){this.sendJson({type:"paste_file",mime:i,dataBase64:s})}sendHostFontChunkRequest(i,s){this.sendJson({type:"host_font_chunk_request",sha256:i,index:s})}sendHostFontSubsetRequest(i,s,r){this.sendJson({type:"host_font_subset_request",sha256:i,text:s,requestId:r})}sendHostFontRefresh(){this.sendJson({type:"host_font_refresh"})}sendHerdrStart(){this.sendJson({type:"herdr_start"})}sendJson(i){this.flushInput(),this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(i))}sendInput(i){const s=i instanceof Uint8Array?i:new Uint8Array(i);s.length!==0&&(this.pendingInputSegments.push(s),this.isFlushScheduled||(this.isFlushScheduled=!0,queueMicrotask(()=>this.flushInput())))}flushInput(){if(this.isFlushScheduled=!1,this.pendingInputSegments.length===0)return;let i=this.pendingInputSegments;if(this.pendingInputSegments=[],this.ws&&(this.ws.bufferedAmount??0)>256*1024&&(i=i.filter(r=>!qo(r))),i.length===0)return;let s;if(i.length===1)s=i[0];else{let r=0;for(let f=0;f<i.length;f++)r+=i[f].byteLength;s=new Uint8Array(r);let c=0;for(let f=0;f<i.length;f++)s.set(i[f],c),c+=i[f].byteLength}this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(s)}sendBinary(i){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(i)}sendText(i){const s=Pd(i);this.sendInput(s)}resolveWsUrl(i){if(/^wss?:\/\//i.test(i))return i;if(/^https?:\/\//i.test(i)){const s=new URL(i);return s.protocol=s.protocol==="https:"?"wss:":"ws:",(!s.pathname||s.pathname==="/")&&(s.pathname="/ws/client"),s.toString()}if(typeof window<"u"&&window.location){const r=window.location.protocol==="https:"?"wss:":"ws:",c=window.location.host,f=i.startsWith("/")?i:`/${i}`;return`${r}//${c}${f}`}return"ws://127.0.0.1:8787/ws/client"}}function rx(l,i=window,s=document){const r=p=>{var y;((y=i.navigator)==null?void 0:y.onLine)!==!1&&l.wake(p)},c=()=>{s.visibilityState==="visible"&&r("visible")},f=()=>r("pageshow"),h=()=>r("online"),m=()=>r("focus"),b=()=>r("resume");return s.addEventListener("visibilitychange",c),s.addEventListener("resume",b),i.addEventListener("pageshow",f),i.addEventListener("online",h),i.addEventListener("focus",m),()=>{s.removeEventListener("visibilitychange",c),s.removeEventListener("resume",b),i.removeEventListener("pageshow",f),i.removeEventListener("online",h),i.removeEventListener("focus",m)}}const ox=10,cx=24,pr=15,Vo=13,Zd=640;function ux(){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 ss()<Zd}function ss(){return typeof window>"u"?1024:window.visualViewport&&typeof window.visualViewport.width=="number"&&window.visualViewport.width>0?window.visualViewport.width:window.innerWidth||1024}function rd(){return typeof window>"u"?768:window.visualViewport&&typeof window.visualViewport.height=="number"&&window.visualViewport.height>0?window.visualViewport.height:window.innerHeight||768}function cs(l,i=pr){const s=typeof l=="number"?l:Number(l);return!Number.isFinite(s)||s<=0?i:Math.min(cx,Math.max(ox,Math.round(s)))}function Zp(l,i=ss()){if(i<Zd){const r=cs(l,Vo);return Math.min(15,Math.max(12,r))}return cs(l,pr)}const gb=[{id:"esc",label:"ESC",code:ve.ESC,type:"key",enabled:!0,title:"Escape"},{id:"tab",label:"TAB",code:ve.TAB,type:"key",enabled:!0,title:"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:ve.LEFT,type:"key",enabled:!0,title:"Arrow Left"},{id:"up",label:"↑",code:ve.UP,type:"key",enabled:!0,title:"Arrow Up"},{id:"down",label:"↓",code:ve.DOWN,type:"key",enabled:!0,title:"Arrow Down"},{id:"right",label:"→",code:ve.RIGHT,type:"key",enabled:!0,title:"Arrow Right"},{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:ve.ENTER,type:"key",enabled:!0,title:"Enter / Return"}],dx=[{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:ve.ESC,type:"key",enabled:!0,title:"Escape"},{id:"tab",label:"TAB",code:ve.TAB,type:"key",enabled:!0,title:"Tab"},{id:"shift_tab",label:"⇧TAB",code:ve.SHIFT_TAB,type:"key",enabled:!0,title:"Shift+Tab"},{id:"enter",label:"Enter",code:ve.ENTER,type:"key",enabled:!0,title:"Enter / Return"},{id:"backspace",label:"⌫",code:ve.BACKSPACE,type:"key",enabled:!0,title:"Backspace"},{id:"delete",label:"Del",code:ve.DELETE,type:"key",enabled:!0,title:"Delete"},{id:"left",label:"←",code:ve.LEFT,type:"key",enabled:!0,title:"Arrow Left"},{id:"up",label:"↑",code:ve.UP,type:"key",enabled:!0,title:"Arrow Up"},{id:"down",label:"↓",code:ve.DOWN,type:"key",enabled:!0,title:"Arrow Down"},{id:"right",label:"→",code:ve.RIGHT,type:"key",enabled:!0,title:"Arrow Right"},{id:"home",label:"Home",code:ve.HOME,type:"key",enabled:!0,title:"Home"},{id:"end",label:"End",code:ve.END,type:"key",enabled:!0,title:"End"},{id:"page_up",label:"PgUp",code:ve.PAGE_UP,type:"key",enabled:!0,title:"Page Up"},{id:"page_down",label:"PgDn",code:ve.PAGE_DOWN,type:"key",enabled:!0,title:"Page Down"},{id:"insert",label:"Ins",code:ve.INSERT,type:"key",enabled:!0,title:"Insert"},{id:"ctrl_c",label:"^C",code:ve.CTRL_C,type:"chord",enabled:!0,title:"Ctrl+C (SIGINT)"},{id:"ctrl_d",label:"^D",code:ve.CTRL_D,type:"chord",enabled:!0,title:"Ctrl+D (EOF/Exit)"},{id:"ctrl_z",label:"^Z",code:ve.CTRL_Z,type:"chord",enabled:!0,title:"Ctrl+Z (SIGTSTP)"},{id:"ctrl_l",label:"^L",code:ve.CTRL_L,type:"chord",enabled:!0,title:"Ctrl+L (Clear Screen)"},{id:"ctrl_a",label:"^A",code:ve.CTRL_A,type:"chord",enabled:!0,title:"Ctrl+A (Beginning of Line)"},{id:"ctrl_e",label:"^E",code:ve.CTRL_E,type:"chord",enabled:!0,title:"Ctrl+E (End of Line)"},{id:"ctrl_k",label:"^K",code:ve.CTRL_K,type:"chord",enabled:!0,title:"Ctrl+K (Kill to End)"},{id:"ctrl_r",label:"^R",code:ve.CTRL_R,type:"chord",enabled:!0,title:"Ctrl+R (Reverse Search)"},{id:"f1",label:"F1",code:ve.F1,type:"fn",enabled:!0,title:"F1"},{id:"f2",label:"F2",code:ve.F2,type:"fn",enabled:!0,title:"F2"},{id:"f3",label:"F3",code:ve.F3,type:"fn",enabled:!0,title:"F3"},{id:"f4",label:"F4",code:ve.F4,type:"fn",enabled:!0,title:"F4"},{id:"f5",label:"F5",code:ve.F5,type:"fn",enabled:!0,title:"F5"},{id:"f6",label:"F6",code:ve.F6,type:"fn",enabled:!0,title:"F6"},{id:"f7",label:"F7",code:ve.F7,type:"fn",enabled:!0,title:"F7"},{id:"f8",label:"F8",code:ve.F8,type:"fn",enabled:!0,title:"F8"},{id:"f9",label:"F9",code:ve.F9,type:"fn",enabled:!0,title:"F9"},{id:"f10",label:"F10",code:ve.F10,type:"fn",enabled:!0,title:"F10"},{id:"f11",label:"F11",code:ve.F11,type:"fn",enabled:!0,title:"F11"},{id:"f12",label:"F12",code:ve.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 gr(){return JSON.parse(JSON.stringify(gb))}const fx=[["esc","tab","shift_tab","ctrl","alt","left","up","down","right","drawer_chords","drawer_symbols","drawer_fn","enter"],["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"],["esc","tab","ctrl","alt","left","up","down","right","drawer_agent","drawer_symbols","drawer_fn","enter"]];function hx(l){return fx.some(i=>l.length===i.length&&l.every((s,r)=>s.id===i[r]&&s.enabled!==!1))}function mx(l){if(!Array.isArray(l)||l.length===0)return gr();const i=l.filter(s=>typeof s=="object"&&s!==null&&typeof s.id=="string"&&typeof s.label=="string"&&typeof s.code=="string");return hx(i)?gr():i.filter(s=>s.id!=="drawer_agent")}function Ld(l,i){if(i){const s=`keyTitles.${l.id}`,r=i(s);if(r&&r!==s)return r}return l.title||l.label}class ki extends Error{constructor(s,r={}){super(s);Z(this,"code");Z(this,"params");this.name="KeyComboError",this.code=s,this.params=r}}const px={escape:"esc",return:"enter",pgup:"pageup",pgdn:"pagedown",backslash:"\\",plus:"+"},Qp={esc:ve.ESC,tab:ve.TAB,enter:ve.ENTER,backspace:ve.BACKSPACE,delete:ve.DELETE,left:ve.LEFT,right:ve.RIGHT,up:ve.UP,down:ve.DOWN,home:ve.HOME,end:ve.END,pageup:ve.PAGE_UP,pagedown:ve.PAGE_DOWN,insert:ve.INSERT,space:" ","+":"+"},gx={esc:"ESC",tab:"TAB",enter:"⏎",backspace:"⌫",delete:"DEL",left:"←",right:"→",up:"↑",down:"↓",home:"HOME",end:"END",pageup:"PGUP",pagedown:"PGDN",insert:"INS",space:"SPACE","+":"+"},bx={2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹"};function bb(l,i){const s=l.toLowerCase().split("+");if(s.some(b=>!b))throw new ki("invalidStepSyntax",{step:i+1});const r={};let c;for(const b of s)if(b==="ctrl"||b==="control"){if(r.ctrl)throw new ki("duplicateModifier",{step:i+1,modifier:"Ctrl"});r.ctrl=!0}else if(b==="alt"||b==="option"){if(r.alt)throw new ki("duplicateModifier",{step:i+1,modifier:"Alt"});r.alt=!0}else if(b==="shift"){if(r.shift)throw new ki("duplicateModifier",{step:i+1,modifier:"Shift"});r.shift=!0}else if(c===void 0)c=b;else throw new ki("multipleKeys",{step:i+1});if(!c)throw new ki("missingKey",{step:i+1});const f=px[c]||c,h=/^f(?:[1-9]|1[0-2])$/.exec(f);let m;if(h)m=ve[f.toUpperCase()];else if(Object.hasOwn(Qp,f))m=Qp[f];else if([...f].length===1&&/^[\x21-\x7e]$/.test(f))m=f;else throw new ki("unsupportedKey",{step:i+1,key:f});return{key:m,keyName:f,modifiers:r,sequence:vx(m,f,r)}}function yx(l){return 1+(l.shift?1:0)+(l.alt?2:0)+(l.ctrl?4:0)}function Wp(l,i){const s=[...l][0].codePointAt(0);return s===void 0?"":`\x1B[${s};${yx(i)}u`}function vx(l,i,s){if(!s.ctrl)return $o(l,s);if(i.length===1&&/^[\x20-\x7e]$/.test(i)){const r=i.toLowerCase();if(s.alt||s.shift||r==="m"||r==="i")return Wp(r,s);if(r==="-"||r==="/"||r==="_")return"";const c=rb(r);return c!==r?c:Wp(r,s)}return $o(l,s)}function Ri(l){if(typeof l!="string"||!l.trim())throw new ki("empty");const i=l.trim().split(/\s+/);if(i.length>8)throw new ki("tooManySteps",{count:8});return i.map((s,r)=>bb(s,r).sequence)}function ur(l){const i=l.trim().split(/\s+/);return i.length>1&&i.every(s=>["esc","escape"].includes(s.toLowerCase()))?`ESC${bx[i.length]||` ×${i.length}`}`:i.map((s,r)=>{const{keyName:c,modifiers:f}=bb(s,r),h=gx[c]||(/^f\d+$/.test(c),c.toUpperCase());return f.ctrl&&f.alt&&f.shift?`Ctrl+Alt+⇧${h}`:f.ctrl&&f.alt?`Ctrl+Alt+${h}`:f.ctrl&&f.shift?`^⇧${h}`:f.ctrl?`^${h}`:f.alt&&f.shift?`Alt+⇧${h}`:f.alt?`Alt+${h}`:f.shift?`⇧${h}`:h}).join(" ")}const yb="host",xx='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", "Symbols Nerd Font Mono", monospace',wx='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',Sx="JetBrains Mono, Menlo, Monaco, Consolas, monospace",Cx={[xx]:"host",[wx]:"host",[Sx]:"host",'SFMono-Regular, Menlo, Monaco, "Symbols Nerd Font Mono", monospace':"system",'Consolas, "Lucida Console", "Symbols Nerd Font Mono", monospace':"system",'"Liberation Mono", "DejaVu Sans Mono", "Symbols Nerd Font Mono", monospace':"system",'"Courier New", Courier, "Symbols Nerd Font Mono", monospace':"system",'"Fira Code", "Symbols Nerd Font Mono", monospace':"fira-code"};function od(l){return typeof l!="string"||!l.trim()?yb:Cx[l]??l}const rs="herdr_remote_settings_v1",fr="herdr_remote_session_view_v1",vb=64,br=4096,_d={local:{},session:{}};function yr(l,i){if(typeof window>"u")return _d[l][i]||null;try{return(l==="local"?window.localStorage:window.sessionStorage).getItem(i)}catch{return _d[l][i]||null}}function Hl(l,i,s){if(_d[l][i]=s,!(typeof window>"u"))try{(l==="local"?window.localStorage:window.sessionStorage).setItem(i,s)}catch(r){console.warn(`Failed to write to ${l}Storage:`,r)}}const xb="herdr-remote.ignoredUpdate";function Tx(){return yr("local",xb)}function Mx(l){Hl("local",xb,l)}function Ax(){return`client-${Math.random().toString(36).substring(2,8)}`}function Qd(){const l=Math.random().toString(36).substring(2,10);return`profile-${Date.now().toString(36)}-${l}`}function Ex(l,i){return(typeof l=="string"?l.trim().slice(0,vb):"")||i}function Xo(l,i){if(!l||typeof l!="object"||Array.isArray(l))return null;const s=l,r=typeof s.wsUrl=="string"?s.wsUrl.trim().slice(0,2048):"",c=typeof s.token=="string"?s.token.slice(0,br):"",f=typeof s.pairCode=="string"?s.pairCode.trim().toUpperCase().slice(0,32):"";if(!r||!r.startsWith("/")&&!/^(?:wss?|https?):\/\//i.test(r)||!c&&!f)return null;const h=Date.now(),m=typeof s.id=="string"&&s.id.length>0?s.id.slice(0,128):Qd(),b=typeof s.hostname=="string"&&s.hostname.trim()?s.hostname.trim().slice(0,vb):`Herdr ${i+1}`;return{id:m,displayName:Ex(s.displayName,b),wsUrl:r,token:c,...f?{pairCode:f}:{},...typeof s.hostId=="string"&&s.hostId.trim()?{hostId:s.hostId.trim().slice(0,128)}:{},...typeof s.hostname=="string"&&s.hostname.trim()?{hostname:s.hostname.trim().slice(0,128)}:{},...typeof s.deviceId=="string"&&s.deviceId.trim()?{deviceId:s.deviceId.trim().slice(0,128)}:{},autoReconnect:s.autoReconnect!==!1,createdAt:Number.isFinite(s.createdAt)?Number(s.createdAt):h,lastUsedAt:Number.isFinite(s.lastUsedAt)?Number(s.lastUsedAt):h}}function Jp(l,i=0){const s=Xo({...l,id:l.id||Qd()},i);if(!s)throw new Error("a connection profile requires a relay URL and token or pairing code");return s}function eg(l){let i=l.wsUrl.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"").toLowerCase();if(typeof window<"u")try{const s=new URL(l.wsUrl,window.location.origin);s.protocol=s.protocol==="wss:"?"https:":"http:",s.pathname=s.pathname.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"")||"/",s.search="",s.hash="",i=s.toString().replace(/\/$/,"").toLowerCase()}catch{}return`${i}::${l.hostId||""}`}function wb(){return typeof navigator<"u"&&navigator.language&&navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}function Sb(){const l=typeof window<"u"&&window.innerWidth<640;return{wsUrl:"/ws/client",token:"",pairCode:"",clientId:Ax(),autoReconnect:!0,profiles:[],activeProfileId:"",fontSize:l?Vo:pr,fontSizeFollowsHost:!0,fontFamily:yb,toolbarVisible:!0,toolbarPosition:"bottom",vibrateOnKeyPress:!0,predictiveEcho:"auto",agentAlertBadge:!0,agentAlertSound:!1,agentAlertVibrate:!1,agentAlertNotify:!1,language:wb(),virtualKeys:gr(),agentKeymaps:{},adminToken:"",adminTokens:{}}}const Nx=["wsUrl","token","pairCode","clientId","autoReconnect","language","agentKeymaps"],kx=["wsUrl","token","pairCode","autoReconnect"],Wd=["fontSize","fontSizeFollowsHost","fontFamily","toolbarVisible","toolbarPosition","vibrateOnKeyPress","predictiveEcho","virtualKeys","agentAlertBadge","agentAlertSound","agentAlertVibrate","agentAlertNotify","adminToken","adminTokens"],Rx=Wd.filter(l=>l!=="adminToken"&&l!=="adminTokens"),tg=["theme","colorMode"];function jd(l){const i=l;if(!tg.some(c=>i[c]!==void 0))return{data:l,changed:!1};const r={...i};for(const c of tg)delete r[c];return{data:r,changed:!0}}function Cb(l){if(!l||typeof l!="object"||Array.isArray(l))return{};const i={};for(const[s,r]of Object.entries(l).slice(0,32))typeof r!="string"||r.length===0||(i[s.slice(0,512)]=r.slice(0,br));return i}function Tb(l){if(!l||typeof l!="object"||Array.isArray(l))return{};const i=Object.create(null);for(const[s,r]of Object.entries(l).slice(0,32)){if(!/^[a-z][a-z0-9_-]{0,31}$/i.test(s)||["__proto__","constructor","prototype"].includes(s)||!r||typeof r!="object"||Array.isArray(r))continue;const c=r,f={};if(Array.isArray(c.order)&&(f.order=[...new Set(c.order.filter(h=>typeof h=="string"&&/^[a-zA-Z0-9_-]{1,64}$/.test(h)))].slice(0,256)),c.actions&&typeof c.actions=="object"&&!Array.isArray(c.actions)){const h=Object.create(null);for(const[m,b]of Object.entries(c.actions).slice(0,256)){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(m)||!b||typeof b!="object"||Array.isArray(b))continue;const p=b,y={};if(typeof p.keys=="string"&&p.keys.trim()){const v=p.keys.trim().slice(0,80);try{Ri(v),y.keys=v}catch{}}typeof p.hidden=="boolean"&&(y.hidden=p.hidden),Object.keys(y).length>0&&(h[m]=y)}f.actions=h}if(Array.isArray(c.custom)){const h=new Set;f.custom=c.custom.slice(0,64).flatMap(m=>{if(!m||typeof m!="object"||Array.isArray(m))return[];const b=m;if(typeof b.id!="string"||!/^[a-zA-Z0-9_-]{1,64}$/.test(b.id)||["__proto__","constructor","prototype"].includes(b.id)||h.has(b.id))return[];if(typeof b.label!="string"||!b.label.trim()||typeof b.keys!="string"||!b.keys.trim())return[];const p=b.keys.trim().slice(0,80);try{Ri(p)}catch{return[]}return h.add(b.id),[{id:b.id,label:b.label.trim().slice(0,64),keys:p}]})}i[s]=f}return i}function Mb(l){var f;const i=[];if((Array.isArray(l.profiles)?l.profiles.slice(0,64):[]).forEach((h,m)=>{const b=Xo(h,m);b&&!i.some(p=>p.id===b.id)&&i.push(b)}),i.length===0&&(typeof l.token=="string"&&l.token||typeof l.pairCode=="string"&&l.pairCode)){const h=Xo({id:"profile-migrated",displayName:"Herdr 1",wsUrl:typeof l.wsUrl=="string"&&l.wsUrl.trim()?l.wsUrl:"/ws/client",token:l.token||"",pairCode:l.pairCode||"",autoReconnect:l.autoReconnect!==!1},0);h&&i.push(h)}const r=typeof l.activeProfileId=="string"?l.activeProfileId:"",c=i.some(h=>h.id===r)?r:((f=i[0])==null?void 0:f.id)||"";return{profiles:i,activeProfileId:c}}function Ab(){const l=Sb();if(typeof window>"u")return l;let i={};const s=yr("local",rs);if(s)try{i=JSON.parse(s)}catch(ie){console.warn("Failed to parse localStorage settings:",ie)}const r=jd(i);r.changed&&(i=r.data,Hl("local",rs,JSON.stringify(i)));let c=null;const f=yr("session",fr);if(f)try{c=JSON.parse(f)}catch(ie){console.warn("Failed to parse sessionStorage settings:",ie)}if(!c){const ie={};for(const he of Wd)i[he]!==void 0&&(ie[he]=i[he]);c=ie,Hl("session",fr,JSON.stringify(c))}const h=od(c.fontFamily??i.fontFamily??l.fontFamily),m=window.innerWidth<640?Vo:pr,b=c.fontSize??i.fontSize??l.fontSize,p=cs(b,m),y=c.fontSizeFollowsHost??i.fontSizeFollowsHost,v=typeof y=="boolean"?y:b===void 0||p===pr||p===Vo,w=c.virtualKeys??i.virtualKeys??l.virtualKeys,T=mx(w),A=i.language??l.language,$=A==="zh"||A==="en"?A:wb(),R=Mb(i),O=R.profiles.find(ie=>ie.id===R.activeProfileId),j=jd(c);j.changed&&(c=j.data,Hl("session",fr,JSON.stringify(c)));const Y=c.toolbarVisible??i.toolbarVisible??l.toolbarVisible,se=c.toolbarPosition??i.toolbarPosition??l.toolbarPosition,fe=c.vibrateOnKeyPress??i.vibrateOnKeyPress??l.vibrateOnKeyPress,Q=ie=>{const he=c[ie]??i[ie];return typeof he=="boolean"?he:l[ie]},K=(c==null?void 0:c.predictiveEcho)??(i==null?void 0:i.predictiveEcho)??l.predictiveEcho,q=K==="always"||K==="off"||K==="auto"?K:"auto",ue=typeof c.adminToken=="string"?c.adminToken.slice(0,br):typeof i.adminToken=="string"?i.adminToken.slice(0,br):l.adminToken,ye=Cb(c.adminTokens),Ne={...l,...i,...c,wsUrl:(O==null?void 0:O.wsUrl)||(typeof i.wsUrl=="string"?i.wsUrl:l.wsUrl),token:(O==null?void 0:O.token)||"",pairCode:(O==null?void 0:O.pairCode)||"",autoReconnect:(O==null?void 0:O.autoReconnect)??l.autoReconnect,profiles:R.profiles,activeProfileId:R.activeProfileId,clientId:typeof i.clientId=="string"&&i.clientId.trim()?i.clientId.trim().slice(0,128):l.clientId,fontFamily:h,fontSize:p,fontSizeFollowsHost:v,toolbarVisible:Y,toolbarPosition:se,vibrateOnKeyPress:fe,predictiveEcho:q,virtualKeys:T,agentKeymaps:Tb(i.agentKeymaps),agentAlertBadge:Q("agentAlertBadge"),agentAlertSound:Q("agentAlertSound"),agentAlertVibrate:Q("agentAlertVibrate"),agentAlertNotify:Q("agentAlertNotify"),language:$,adminToken:ue,adminTokens:ye};return typeof i.fontFamily=="string"&&od(i.fontFamily)!==i.fontFamily&&(i.fontFamily=od(i.fontFamily),Hl("local",rs,JSON.stringify(i))),Ne}function _l(l){var w;const s={...Ab(),...l};s.agentKeymaps=Tb(s.agentKeymaps),s.adminTokens=Cb(s.adminTokens),typeof s.adminToken=="string"&&(s.adminToken=s.adminToken.slice(0,br)),l.fontSize!==void 0&&(s.fontSize=cs(l.fontSize)),l.predictiveEcho!==void 0&&(l.predictiveEcho==="auto"||l.predictiveEcho==="always"||l.predictiveEcho==="off"?s.predictiveEcho=l.predictiveEcho:s.predictiveEcho="auto");const r=Mb(s);let c=r.profiles,f=r.activeProfileId;if(kx.some(T=>l[T]!==void 0)){const T=c.findIndex(R=>R.id===f),A=T>=0?{...c[T]}:{id:Qd(),displayName:`Herdr ${c.length+1}`,wsUrl:s.wsUrl,token:"",autoReconnect:!0,createdAt:Date.now(),lastUsedAt:Date.now()};A.wsUrl=s.wsUrl,A.token=s.token,A.pairCode=s.pairCode||void 0,A.autoReconnect=s.autoReconnect,A.lastUsedAt=Date.now();const $=Xo(A,Math.max(T,0));$?T>=0?c[T]=$:(c.push($),f=$.id):T>=0&&(c=c.filter(R=>R.id!==f),f=((w=c[0])==null?void 0:w.id)||"")}c.length>0&&!c.some(T=>T.id===f)&&(f=c[0].id);const m=c.find(T=>T.id===f);s.profiles=c,s.activeProfileId=f,s.wsUrl=(m==null?void 0:m.wsUrl)||s.wsUrl||"/ws/client",s.token=(m==null?void 0:m.token)||"",s.pairCode=(m==null?void 0:m.pairCode)||"",s.autoReconnect=(m==null?void 0:m.autoReconnect)??s.autoReconnect;const b=yr("local",rs);let p={};if(b)try{p=JSON.parse(b)}catch{}p=jd(p).data;for(const T of Nx)s[T]!==void 0&&(p[T]=s[T]);p.profiles=c,p.activeProfileId=f,Hl("local",rs,JSON.stringify(p));const y=yr("session",fr);let v={};if(y)try{v=JSON.parse(y)}catch{}for(const T of Wd)s[T]!==void 0&&(v[T]=s[T]);Hl("session",fr,JSON.stringify(v));for(const T of Rx)s[T]!==void 0&&(p[T]=s[T]);return Hl("local",rs,JSON.stringify(p)),s}const Lx={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"},update:{chip:"↑ herdr-remote {version}",chipCompact:"↑ {version}",chipRestart:"↻ restart for {version}",toast:"herdr-remote {version} is out for this workstation",toastRestart:"herdr-remote {version} is installed; restart it to apply",title:"herdr-remote update",running:"Running",installed:"Installed",latest:"Latest",restartPending:"{version} is installed but not running yet. Restart herdr-remote on the workstation:",stepTui:'On the workstation, open herdr-remote (the TUI), go to "Language & about" and press Enter on the update row.',stepCli:"Or run on the workstation:",restartNote:"Restarting reconnects this window after a few seconds.",ignore:"Skip this version"},herdrLaunch:{title:"Herdr is not running",body:"Herdr is not running on {host}. Start it on that workstation?",scope:"Only this paired workstation's own Herdr starts, as that workstation's user. No other machine is touched.",start:"Start Herdr",starting:"Starting Herdr on {host}…",failedTitle:"Herdr did not start",timeout:"The workstation did not answer within 30 seconds. Its herdr-remote may be too old to start Herdr from a browser.",thisHost:"this workstation"},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:",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:"Interface, font, input and alerts",tabGeneral:"General",sectionInterface:"Interface",sectionFont:"Font",sectionInput:"Input",sectionAdmin:"Administration",toggleOn:"On",toggleOff:"Off",hostFontLabel:"Workstation font",adminEntry:"Relay dashboard",adminEntryHint:"Hosts, devices and traffic; needs the admin token",adminEntryOpen:"Open",tabVirtualKeys:"Virtual Keys",tabAgentKeymaps:"Agent Keys",fontFamilyLabel:"Monospace Font",fontSizeHint:"This window only",fontSizeLabel:"Terminal Text Size ({size}px)",predictiveEchoLabel:"Predictive Echo",predictiveEchoAuto:"Auto",predictiveEchoAlways:"Always On",predictiveEchoOff:"Off",predictiveEchoDesc:"Show typing before the echo returns on slow links",touchKeyToolbar:"Touch Key Toolbar",touchKeyToolbarDesc:"Modifier and arrow keys",touchHaptics:"Haptic Feedback",touchHapticsDesc:"Vibrate on key press",agentAlertsLabel:"Agent alerts",agentAlertBadge:"Title and icon badge",agentAlertBadgeDesc:"Count waiting and finished agents in the tab title",agentAlertVibrate:"Vibrate",agentAlertVibrateDesc:"When an agent waits or finishes (page on screen)",agentAlertSound:"Chime",agentAlertSoundDesc:"In the background; works after your next tap",agentAlertNotify:"System notification",agentAlertNotifyDesc:"In the background (HTTPS only)",languageLabel:"Language",resetDefaults:"Reset to Defaults",resetDefaultsToast:"Settings reset to defaults",fontSizeFollowHost:"Same size as the workstation terminal ({size}px)",fontSizeFollowHostUnknown:"Same size as the workstation terminal (not reported)",hostFontSync:"Sync host font",hostGlyphLine:"CJK: {family} · {status}",hostGlyphStatus:{none:"",checking:"Checking…",installed:"Installed on this device",available:"Not loaded",declined:"Not loaded — using this device’s fonts",loading:"Loading common characters",ready:"{count} characters on this device; others load as they appear",failed:"Could not be loaded"},hostFontStatus:{none:"The workstation did not report its terminal font",checking:"Checking…",installed:"Installed on this device",loaded:"Loaded from the workstation",available:"Not loaded",declined:"Not loaded — using this device’s fonts",loading:"Loading {percent}%",failed:"Could not be loaded",unavailable:"No font file to load; drawn by name where installed"}},agentKeymaps:{keymapLabel:"Keymap",auto:"Auto",shell:"Shell",agentGroup:"Agent",listGroup:"{profile} shortcuts",genericGroup:"General",profileRowLabel:"Agent to edit",settingsProfileLabel:"Agent profile",autoProfile:"Auto · {profile}",pinnedProfile:"Pinned · {profile}",barGroup:"Key bar",barHint:"Tap to choose which {profile} shortcuts appear on the key bar ({count} shown); base keys are on the Virtual Keys tab.",restoreBar:"Restore default keys",customizeBar:"Choose which shortcuts the key bar shows",customizeBarShort:"Edit",shortcutLabel:"Shortcut",comboPlaceholder:"e.g. ctrl+e or esc esc",invalidCombo:"Invalid shortcut: {error}",defaultCombo:"Default: {combo}",resetAction:"Reset",moveUp:"Move up",moveDown:"Move down",unverified:"Unverified",addCustom:"Custom key",customLabel:"Function name",customCombo:"Key combo",addAction:"Add custom key",restoreProfile:"Restore this agent defaults",removeCustom:"Remove custom key",configHint:"Agent config: {path}",noAgentActions:"No agent-specific shortcuts.",errors:{empty:"Enter at least one key.",tooManySteps:"A shortcut can have at most {count} steps.",invalidStepSyntax:"Step {step} has invalid syntax. Use ctrl+o or esc esc.",duplicateModifier:"Step {step} repeats {modifier}.",missingKey:"Step {step} needs a key after the modifiers.",multipleKeys:"Step {step} can have only one key.",unsupportedKey:"Step {step} does not support “{key}”."}},agentActions:{mode:"Mode",rewind:"Rewind",details:"Details",model:"Model",thinking:"Thinking",todos:"Tasks",background:"Background",editor:"Editor",history:"History",stash:"Stash",pasteImage:"Paste image",newline:"New line",interrupt:"Interrupt",editPrevious:"Edit previous",queue:"Queue prompt",copy:"Copy",clear:"Clear",yolo:"YOLO mode",expand:"Expand",undo:"Undo",agent:"Next agent",agentBack:"Previous agent",palette:"Command palette",recentModel:"Recent model",variant:"Model variant",newSession:"New session",sessions:"Sessions",thinkingMode:"Thinking mode",nextModel:"Next model",modelPicker:"Model picker",tools:"Tools",thinkingBlocks:"Thinking blocks",followup:"Follow-up",dequeue:"Remove from queue",plan:"Plan mode",temporaryModel:"Temporary model",expandAll:"Expand all",reasoning:"Reasoning effort",review:"Review",specMode:"Spec mode",autonomy:"Autonomy",undoPicker:"Undo picker",steer:"Steer",sidebar:"Sidebar",agents:"Agents",permissionMode:"Permission mode",bypass:"Bypass permissions",tasks:"Tasks",interject:"Interject",multiline:"Multiline input",shortcuts:"Shortcuts",approve:"Approve",eof:"End of input",suspend:"Suspend",startOfLine:"Line start",endOfLine:"Line end",killToEnd:"Delete to line end",agentSwap:"Switch agent",activity:"Activity",planAct:"Plan / Act",autoApprove:"Auto-approve",search:"Search"},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",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_agent:"Agent shortcuts",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:{returnToTerminal:"Return to Terminal",terminalShells:"terminal sessions",startedAt:"Started at {time}",acrossWindows:"across {count} windows",perSecond:"{value}/s",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})",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",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",remoteRelayNotice:"Connected to remote relay. For server metrics, access the operator dashboard.",remoteRelayEndpoint:"Remote WebSocket Endpoint:",remoteRelayAdminUrl:"Remote Admin URL:",openRemoteAdminBtn:"Open Remote Admin",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",relJustNow:"just now",relMinutes:"{count}m ago",relHours:"{count}h ago",relDays:"{count}d ago",statInbound:"Inbound",statOutbound:"Outbound",statTotal:"{value} total",hostsOfflineSub:"{count} more offline",colHost:"Host",colStatus:"Status",deviceWindows:"{count} windows open",hostPtys:"{count} PTY",relayAdminPrompt:"Enter RELAY_ADMIN_TOKEN to see this relay's hosts, devices and traffic."},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:{host:"Workstation terminal font (default)",system:"System monospace"},hostFont:{title:"Workstation terminal font",body:"The terminal on {host} uses {family}{detail}. This device does not have it.",bodyGlyphsOnly:"The terminal on {host} draws Chinese with {family}. This device does not have it.",glyphs:"Chinese in {family}: about 2 MB of common characters first; any other character loads the first time it appears.",glyphsAll:"{family} is too large to send whole: about 2 MB of common characters first; any other character loads the first time it appears.",detail:" ({detail})",detailSeparator:", ",download:"Load {count} font file(s), {size} in total. Downloaded once, then kept in this browser.",load:"Load font",decline:"Use this device’s fonts",loading:"Loading {received} of {total}",failed:"The font could not be loaded: {reason}",loaded:"Workstation font loaded",reasons:{host_font_unavailable:"the font changed on the workstation. Sync it again from Settings",host_font_timeout:"the workstation stopped answering",disconnected:"the connection dropped",font_api_unavailable:"this browser cannot load fonts",other:"the browser could not read the font file"}},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"}},_x={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:"会话已断开"},update:{chip:"↑ herdr-remote {version}",chipCompact:"↑ {version}",chipRestart:"↻ 重启以应用 {version}",toast:"宿主机的 herdr-remote 有新版本 {version}",toastRestart:"herdr-remote {version} 已安装,重启后生效",title:"herdr-remote 更新",running:"正在运行",installed:"已安装",latest:"最新版本",restartPending:"{version} 已安装但尚未运行。在宿主机上重启 herdr-remote:",stepTui:"在宿主机打开 herdr-remote(TUI),进入「语言与关于」,在更新一行按 Enter。",stepCli:"或在宿主机上执行:",restartNote:"重启后这个窗口会在几秒内自动重连。",ignore:"忽略此版本"},herdrLaunch:{title:"Herdr 未运行",body:"{host} 上没有正在运行的 Herdr。要在这台宿主机上启动吗?",scope:"只会以这台已配对宿主机自己的用户身份,启动它自己的 Herdr,不会碰其他任何机器。",start:"启动 Herdr",starting:"正在 {host} 上启动 Herdr…",failedTitle:"Herdr 没有启动",timeout:"宿主机 30 秒内没有回应。它的 herdr-remote 可能版本过旧,不支持从浏览器启动 Herdr。",thisHost:"这台宿主机"},onboarding:{title:"配对 Herdr Remote",subtitle:"连接手机或浏览器至本地终端会话",description:"在浏览器或移动设备中控制 Herdr 会话。",firstTimeSetup:"首次配对",authRequired:"需要认证",authRequiredDesc:"使用配对码配对设备,或提供有效访问令牌。",step1Title:"在 Herdr 宿主机生成配对码",step1Desc:"在运行 Herdr 的主机终端执行:",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:"通用",sectionInterface:"界面",sectionFont:"字体",sectionInput:"输入",sectionAdmin:"管理",toggleOn:"开",toggleOff:"关",hostFontLabel:"宿主机字体",adminEntry:"Relay 管理面板",adminEntryHint:"主机、设备与流量;需要管理员令牌",adminEntryOpen:"打开",tabVirtualKeys:"虚拟按键",tabAgentKeymaps:"智能体按键",fontFamilyLabel:"等宽字体",fontSizeHint:"只影响当前窗口",fontSizeLabel:"终端字号 ({size}px)",predictiveEchoLabel:"预测回显",predictiveEchoAuto:"自动",predictiveEchoAlways:"始终开启",predictiveEchoOff:"关闭",predictiveEchoDesc:"高延迟时先显示输入,回显到达后校正",touchKeyToolbar:"底部触控按键条",touchKeyToolbarDesc:"修饰键与方向键",touchHaptics:"触控振动反馈",touchHapticsDesc:"按键时轻微震动",agentAlertsLabel:"智能体提醒",agentAlertBadge:"标题与图标角标",agentAlertBadgeDesc:"标签页标题显示等待与完成数",agentAlertVibrate:"震动",agentAlertVibrateDesc:"等待确认或完成时(页面在前台)",agentAlertSound:"提示音",agentAlertSoundDesc:"页面在后台时播放,下次点击后生效",agentAlertNotify:"系统通知",agentAlertNotifyDesc:"页面在后台时通知(仅 HTTPS)",languageLabel:"显示语言",resetDefaults:"恢复默认设置",resetDefaultsToast:"设置已恢复默认",fontSizeFollowHost:"与宿主机终端同字号({size}px)",fontSizeFollowHostUnknown:"与宿主机终端同字号(宿主机未报告)",hostFontSync:"同步宿主机字体",hostGlyphLine:"中文:{family} · {status}",hostGlyphStatus:{none:"",checking:"检查中…",installed:"本机已安装",available:"未加载",declined:"未加载,正在使用本机字体",loading:"正在加载常用字",ready:"本机已有 {count} 字,其余出现时自动补齐",failed:"加载失败"},hostFontStatus:{none:"宿主机未报告终端字体",checking:"检查中…",installed:"本机已安装",loaded:"已从宿主机加载",available:"未加载",declined:"未加载,正在使用本机字体",loading:"加载中 {percent}%",failed:"加载失败",unavailable:"没有可传输的字体文件,已安装该字体的设备按名称显示"}},agentKeymaps:{keymapLabel:"按键方案",auto:"自动",shell:"Shell",agentGroup:"智能体",listGroup:"{profile} 快捷键",genericGroup:"通用",profileRowLabel:"编辑的智能体",settingsProfileLabel:"智能体方案",autoProfile:"自动 · {profile}",pinnedProfile:"固定 · {profile}",barGroup:"按键栏显示",barHint:"点选要在按键栏显示的 {profile} 快捷键(已显示 {count} 个);ESC、方向键在「虚拟按键」页。",restoreBar:"恢复默认显示",customizeBar:"自定义按键栏显示哪些快捷键",customizeBarShort:"自定义",shortcutLabel:"快捷键",comboPlaceholder:"例如 ctrl+e 或 esc esc",invalidCombo:"快捷键无效:{error}",defaultCombo:"默认:{combo}",resetAction:"重置",moveUp:"上移",moveDown:"下移",unverified:"未验证",addCustom:"自定义按键",customLabel:"功能名称",customCombo:"按键组合",addAction:"添加自定义按键",restoreProfile:"恢复此智能体默认设置",removeCustom:"删除自定义按键",configHint:"智能体配置:{path}",noAgentActions:"此智能体没有专用快捷键。",errors:{empty:"至少输入一个按键。",tooManySteps:"快捷键最多包含 {count} 个步骤。",invalidStepSyntax:"第 {step} 步格式无效。可输入 ctrl+o 或 esc esc。",duplicateModifier:"第 {step} 步重复使用了 {modifier}。",missingKey:"第 {step} 步需要在修饰键后输入一个按键。",multipleKeys:"第 {step} 步只能包含一个按键。",unsupportedKey:"第 {step} 步不支持按键“{key}”。"}},agentActions:{mode:"模式",rewind:"回退",details:"详情",model:"模型",thinking:"思考",todos:"任务",background:"后台运行",editor:"编辑器",history:"历史",stash:"暂存",pasteImage:"粘贴图片",newline:"换行",interrupt:"中断",editPrevious:"编辑上一条",queue:"排队发送",copy:"复制",clear:"清屏",yolo:"YOLO 模式",expand:"展开",undo:"撤销",agent:"下一个智能体",agentBack:"上一个智能体",palette:"命令面板",recentModel:"最近模型",variant:"模型变体",newSession:"新会话",sessions:"会话列表",thinkingMode:"思考模式",nextModel:"下一个模型",modelPicker:"模型选择器",tools:"工具",thinkingBlocks:"思考内容",followup:"后续提问",dequeue:"移出队列",plan:"计划模式",temporaryModel:"临时模型",expandAll:"全部展开",reasoning:"推理强度",review:"代码审查",specMode:"规格模式",autonomy:"自主模式",undoPicker:"撤销菜单",steer:"引导",sidebar:"侧栏",agents:"智能体列表",permissionMode:"权限模式",bypass:"绕过权限",tasks:"任务",interject:"插话",multiline:"多行输入",shortcuts:"快捷键",approve:"批准",eof:"结束输入",suspend:"挂起",startOfLine:"行首",endOfLine:"行尾",killToEnd:"删除至行尾",agentSwap:"切换智能体",activity:"活动面板",planAct:"计划 / 执行",autoApprove:"自动批准",search:"搜索"},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:"终端设置",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_agent:"智能体快捷键",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:{returnToTerminal:"返回终端",terminalShells:"终端会话",startedAt:"启动于 {time}",acrossWindows:"共 {count} 个窗口",perSecond:"{value}/秒",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})",hostsTitle:"主机 ({count})",noHosts:"暂无接入或配对的主机",hostConnectedDevices:"{count} 台在线",hostPairedDevices:"{count} 台已配对",hostStatusOnline:"在线",hostStatusBusy:"使用中",hostStatusReconnecting:"重连中",hostStatusOffline:"离线",hostRosterOperatorOnly:"设备清单仅 Relay 操作员可见。",connectedClientsTitle:"已连接客户端 ({count})",noClients:"当前暂无客户端连接",colClientId:"客户端 ID",colDevice:"设备",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 服务管理",remoteRelayNotice:"当前连接至远程独立 Relay 服务。如需查看服务端指标,请使用操作员后台。",remoteRelayEndpoint:"远程端点:",remoteRelayAdminUrl:"远程后台地址:",openRemoteAdminBtn:"前往远程管理后台",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:"返回终端",relJustNow:"刚刚",relMinutes:"{count} 分钟前",relHours:"{count} 小时前",relDays:"{count} 天前",statInbound:"入站流量",statOutbound:"出站流量",statTotal:"累计 {value}",hostsOfflineSub:"另有 {count} 台离线",colHost:"主机",colStatus:"状态",deviceWindows:"{count} 个窗口在线",hostPtys:"PTY {count}",relayAdminPrompt:"输入 RELAY_ADMIN_TOKEN,查看本 Relay 的主机、设备与流量。"},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:{host:"宿主机终端字体(默认)",system:"系统等宽字体"},hostFont:{title:"宿主机终端字体",body:"{host} 的终端使用 {family}{detail}。这台设备没有安装该字体。",bodyGlyphsOnly:"{host} 的终端显示中文用 {family},这台设备没有安装该字体。",glyphs:"中文使用 {family}:先下载常用字约 2 MB,其余的字第一次出现时再补。",glyphsAll:"{family} 太大,不整包传输:先下载常用字符约 2 MB,其余字符第一次出现时再补。",detail:"({detail})",detailSeparator:",",download:"加载 {count} 个字体文件,共 {size}。只下载一次,之后保存在本浏览器。",load:"加载字体",decline:"使用本机字体",loading:"正在加载 {received} / {total}",failed:"字体加载失败:{reason}",loaded:"宿主机字体已加载",reasons:{host_font_unavailable:"宿主机上的字体已变化,请在设置里重新同步",host_font_timeout:"宿主机没有响应",disconnected:"连接已断开",font_api_unavailable:"此浏览器不支持加载字体",other:"浏览器无法解析该字体文件"}},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:"移除图片"}},cd={en:Lx,zh:_x};function Jd(l,i,s){const r=cd[l]||cd.en,c=i.split(".");let f=r;for(const h of c)if(f&&typeof f=="object"&&h in f)f=f[h];else{let m=cd.en;for(const b of c)if(m&&typeof m=="object"&&b in m)m=m[b];else return i;f=m;break}if(typeof f!="string")return i;if(s){let h=f;for(const[m,b]of Object.entries(s))h=h.replaceAll(`{${m}}`,String(b));return h}return f}const ng="#11111b",jx=['"Symbols Nerd Font Mono"','"Sarasa Mono SC"','"Noto Sans Mono CJK SC"','"Noto Sans Mono CJK TC"','"Microsoft YaHei Mono"','"PingFang SC"',"monospace"],Po=["ui-monospace","SFMono-Regular","Menlo","Monaco","Consolas",'"Liberation Mono"','"Courier New"'],Dd=[{id:"host",name:"Host terminal font",faces:[]},{id:"system",name:"System monospace",faces:Po},{id:"jetbrains-mono",name:"JetBrains Mono",faces:['"JetBrains Mono"','"Herdr JetBrains Mono"']},{id:"fira-code",name:"Fira Code",faces:['"Fira Code"','"Herdr Fira Code"']},{id:"cascadia-code",name:"Cascadia Code",faces:['"Cascadia Code"','"Herdr Cascadia Code"']},{id:"source-code-pro",name:"Source Code Pro",faces:['"Source Code Pro"','"Herdr Source Code Pro"']},{id:"ibm-plex-mono",name:"IBM Plex Mono",faces:['"IBM Plex Mono"','"Herdr IBM Plex Mono"']}],Dx=[[/^jetbrains\s*mono/i,'"Herdr JetBrains Mono"'],[/^fira\s*code/i,'"Herdr Fira Code"'],[/^(cascadia\s*(code|mono)|caskaydia\s*(cove|mono))/i,'"Herdr Cascadia Code"'],[/^(source\s*code\s*pro|sauce\s*code\s*pro)/i,'"Herdr Source Code Pro"'],[/^(ibm\s*plex\s*mono|blex\s*mono)/i,'"Herdr IBM Plex Mono"']];function Ox(l){const i=Dx.find(([s])=>s.test(l.trim()));return i?i[1]:null}function ar(l){return`"${l.replace(/["\\]/g,"")}"`}function Od(l){return[...new Set([...l,...jx])].join(", ")}const zx=Od(Po);function Bx(l,i){const s=typeof l=="string"?l.trim():"";if(!s||s==="host"){if(!(i!=null&&i.family))return zx;const f=[],h=i.glyphs;(h==null?void 0:h.scope)==="all"&&h.alias&&f.push(ar(h.alias)),i.alias&&f.push(ar(i.alias)),f.push(ar(i.family));const m=Ox(i.family);return m&&f.push(m),(h==null?void 0:h.scope)==="cjk"&&(h.alias&&f.push(ar(h.alias)),f.push(ar(h.family))),Od([...f,...Po])}const r=Dd.find(f=>f.id===s);if(r)return Od([...r.faces,...Po]);if(s.includes("Symbols Nerd Font"))return s;if(/^['"]?monospace['"]?$/i.test(s))return'"Symbols Nerd Font Mono", monospace';const c=/,\s*['"]?monospace['"]?\s*$/i;return c.test(s)?s.replace(c,', "Symbols Nerd Font Mono", monospace'):`${s}, "Symbols Nerd Font Mono", monospace`}function Hx(l){if(!l)return null;const i={};return l.background&&(i.background=l.background,i.cursorAccent=l.background),l.foreground&&(i.foreground=l.foreground),l.cursor&&(i.cursor=l.cursor),l.ansi&&Object.assign(i,l.ansi),Object.keys(i).length===0?null:i}function Eb(){if(typeof document>"u")return;const l=document.querySelector('meta[name="theme-color"]');document.documentElement.style.colorScheme="dark",l==null||l.setAttribute("content",ng),document.documentElement.classList.add("dark"),document.documentElement.classList.remove("light"),document.body.classList.add("dark"),document.body.classList.remove("light"),document.body.style.backgroundColor=ng}const ig=["啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班搬扳般颁板版扮拌伴瓣半办绊邦帮梆","榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁","便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材才财睬踩采彩菜蔡餐参蚕残惭惨灿苍","舱仓沧藏操糙槽曹草厕策侧册测层蹭插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称","城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川穿椽传船喘串疮窗幢床闯创吹炊捶锤","垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮","但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递缔颠掂滇碘点典靛垫电佃甸店惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟","蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅","俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺废沸费芬酚吩氛分纷坟焚汾粉奋份忿","愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感","秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共钩勾沟苟狗垢构购够辜菇咕箍估沽孤","姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍","旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪","户花哗华猾滑画划化话槐徊怀淮坏欢环桓还缓换患唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸","击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几脊己蓟技冀季伎祭剂悸济寄寂计记既忌际妓继纪嘉枷夹佳家加荚颊贾甲钾假稼价架驾嫁歼监坚尖笺间煎兼肩艰","奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节","桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋禁近烬浸尽劲荆兢茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯窘揪究纠玖韭久灸九酒厩救旧臼舅咎","就疚鞠拘狙疽居驹菊局咀矩举沮聚拒据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵觉决诀绝均菌钧军君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤","靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊","辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾历利傈例俐痢立","粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱零龄铃伶羚凌灵陵岭领另令溜琉榴硫","馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落","洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥","米秘觅泌蜜密幂棉眠绵冕免勉娩缅面苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜","纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕","呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨烹澎彭蓬棚硼篷膨朋鹏捧碰坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬篇偏片","骗飘漂瓢票撇瞥拼频贫品聘乒坪苹萍平凭瓶评屏坡泼颇婆破魄迫粕剖扑铺仆莆葡菩蒲埔朴圃普浦谱曝瀑期欺栖戚妻七凄漆柒沏其棋奇歧畦崎脐齐旗祈祁骑起岂乞企启契砌器气迄弃汽泣","讫掐恰洽牵扦钎铅千迁签仟谦乾黔钱钳前潜遣浅谴堑嵌欠歉枪呛腔羌墙蔷强抢橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍切茄且怯窃钦侵亲秦琴勤芹擒禽寝沁青轻氢倾卿清擎晴氰情顷请庆琼穷","秋丘邱球求囚酋泅趋区蛆曲躯屈驱渠取娶龋趣去圈颧权醛泉全痊拳犬券劝缺炔瘸却鹊榷确雀裙群然燃冉染瓤壤攘嚷让饶扰绕惹热壬仁人忍韧任认刃妊纫扔仍日戎茸蓉荣融熔溶容绒冗揉","柔肉茹蠕儒孺如辱乳汝入褥软阮蕊瑞锐闰润若弱撒洒萨腮鳃塞赛三叁伞散桑嗓丧搔骚扫嫂瑟色涩森僧莎砂杀刹沙纱傻啥煞筛晒珊苫杉山删煽衫闪陕擅赡膳善汕扇缮墒伤商赏晌上尚裳梢","捎稍烧芍勺韶少哨邵绍奢赊蛇舌舍赦摄射慑涉社设砷申呻伸身深娠绅神沈审婶甚肾慎渗声生甥牲升绳省盛剩胜圣师失狮施湿诗尸虱十石拾时什食蚀实识史矢使屎驶始式示士世柿事拭誓","逝势是嗜噬适仕侍释饰氏市恃室视试收手首守寿授售受瘦兽蔬枢梳殊抒输叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠属术述树束戍竖墅庶数漱恕刷耍摔衰甩帅栓拴霜双爽谁水睡税吮瞬顺舜说硕","朔烁斯撕嘶思私司丝死肆寺嗣四伺似饲巳松耸怂颂送宋讼诵搜艘擞嗽苏酥俗素速粟僳塑溯宿诉肃酸蒜算虽隋随绥髓碎岁穗遂隧祟孙损笋蓑梭唆缩琐索锁所塌他它她塔獭挞蹋踏胎苔抬台","泰酞太态汰坍摊贪瘫滩坛檀痰潭谭谈坦毯袒碳探叹炭汤塘搪堂棠膛唐糖倘躺淌趟烫掏涛滔绦萄桃逃淘陶讨套特藤腾疼誊梯剔踢锑提题蹄啼体替嚏惕涕剃屉天添填田甜恬舔腆挑条迢眺跳","贴铁帖厅听烃汀廷停亭庭挺艇通桐酮瞳同铜彤童桶捅筒统痛偷投头透凸秃突图徒途涂屠土吐兔湍团推颓腿蜕褪退吞屯臀拖托脱鸵陀驮驼椭妥拓唾挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完","碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬","屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误昔熙析西硒矽晰嘻吸锡牺稀息希悉膝夕惜熄烯溪汐犀檄袭席习媳喜铣洗系隙戏细瞎虾匣霞辖暇峡侠狭下厦夏吓掀锨先仙鲜纤咸贤衔","舷闲涎弦嫌显险现献县腺馅羡宪陷限线相厢镶香箱襄湘乡翔祥详想响享项巷橡像向象萧硝霄削哮嚣销消宵淆晓小孝校肖啸笑效楔些歇蝎鞋协挟携邪斜胁谐写械卸蟹懈泄泻谢屑薪芯锌欣","辛新忻心信衅星腥猩惺兴刑型形邢行醒幸杏性姓兄凶胸匈汹雄熊休修羞朽嗅锈秀袖绣墟戌需虚嘘须徐许蓄酗叙旭序畜恤絮婿绪续轩喧宣悬旋玄选癣眩绚靴薛学穴雪血勋熏循旬询寻驯巡","殉汛训讯逊迅压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧仰痒养样漾邀腰妖瑶摇尧遥窑","谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音","阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔","隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕匝砸杂栽哉灾宰载","再在咱攒暂赞赃脏葬遭糟凿藻枣早澡蚤躁噪造皂灶燥责择则泽贼怎增憎曾赠扎喳渣札轧铡闸眨栅榨咋乍炸诈摘斋宅窄债寨瞻毡詹粘沾盏斩辗崭展蘸栈占战站湛绽樟章彰漳张掌涨杖丈帐","账仗胀瘴障招昭找沼赵照罩兆肇召遮折哲蛰辙者锗蔗这浙珍斟真甄砧臻贞针侦枕疹诊震振镇阵蒸挣睁征狰争怔整拯正政帧症郑证芝枝支吱蜘知肢脂汁之织职直植殖执值侄址指止趾只旨","纸志挚掷至致置帜峙制智秩稚质炙痔滞治窒中盅忠钟衷终种肿重仲众舟周州洲诌粥轴肘帚咒皱宙昼骤珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱主著柱助蛀贮铸筑住注祝驻抓爪拽专砖转撰赚篆桩","庄装妆撞壮状椎锥追赘坠缀谆准捉拙卓桌琢茁酌啄着灼浊兹咨资姿滋淄孜紫仔籽滓子自渍字鬃棕踪宗综总纵邹走奏揍租足卒族祖诅阻组钻纂嘴醉最罪尊遵昨左佐柞做作坐座"," 、。〃〄々〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟〠〡〢〣〤〥〦〧〨〩〪〭〮〯〫〬〰〱〲〳〴〵〶〷〸〹〺〻〼〽〾〿!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¢£¬ ̄¦¥₩"].join(""),ud=256*1024,Ux=2,Kx={regular:{weight:"400",style:"normal"},bold:{weight:"700",style:"normal"},italic:{weight:"400",style:"italic"},boldItalic:{weight:"700",style:"italic"}};function oa(l){return l?[l.family,...l.faces.map(i=>i.sha256),...(l.subsets||[]).map(i=>i.sha256)].join("|"):null}function lg(l){const i=l==null?void 0:l.faces.find(s=>s.style==="regular");return i?`Herdr Host ${i.sha256.slice(0,12)}`:null}function ag(l){return l?l.faces.reduce((i,s)=>i+s.bytes,0):0}function dd(l){return l>=1024*1024?`${(l/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(l/1024))} KB`}function Ix(l){if(typeof document>"u")return!1;let i=null;try{i=document.createElement("canvas").getContext("2d")}catch{return!1}if(!i)return!1;const s="mmmmmmmmmmlli10OQ@#WWww";for(const r of["serif","sans-serif"]){i.font=`72px ${r}`;const c=i.measureText(s).width;if(i.font=`72px "${l}", ${r}`,i.measureText(s).width!==c)return!0}return!1}const Fx="herdr-remote-fonts",us="faces",ds="subsets",Nb=new Map,zd=new Map;function Jo(){return new Promise(l=>{if(typeof indexedDB>"u"){l(null);return}try{const i=indexedDB.open(Fx,2);i.onupgradeneeded=()=>{i.result.objectStoreNames.contains(us)||i.result.createObjectStore(us),i.result.objectStoreNames.contains(ds)||i.result.createObjectStore(ds)},i.onsuccess=()=>l(i.result),i.onerror=()=>l(null),i.onblocked=()=>l(null)}catch{l(null)}})}async function Gx(l){const i=Nb.get(l);if(i)return i;const s=await Jo();return s?new Promise(r=>{try{const c=s.transaction(us,"readonly").objectStore(us).get(l);c.onsuccess=()=>{const f=c.result;r(f instanceof ArrayBuffer?f:null)},c.onerror=()=>r(null)}catch{r(null)}finally{s.close()}}):null}async function Yx(l,i){Nb.set(l,i);const s=await Jo();s&&await new Promise(r=>{try{const c=s.transaction(us,"readwrite");c.objectStore(us).put(i,l),c.oncomplete=()=>r(),c.onerror=()=>r(),c.onabort=()=>r()}catch{r()}finally{s.close()}})}async function $x(l){const i=await Jo();return i?new Promise(s=>{try{const r=IDBKeyRange.bound(`${l}:`,`${l}:￿`),c=i.transaction(ds,"readonly").objectStore(ds).getAll(r);c.onsuccess=()=>{const f=Array.isArray(c.result)?c.result:[];s(f.filter(h=>h&&h.data instanceof ArrayBuffer&&Array.isArray(h.codepoints)))},c.onerror=()=>s([])}catch{s([])}finally{i.close()}}):zd.get(l)??[]}async function qx(l,i){zd.set(l,[...zd.get(l)??[],i]);const s=await Jo();s&&await new Promise(r=>{try{const c=s.transaction(ds,"readwrite");c.objectStore(ds).put(i,`${l}:${i.subsetSha}`),c.oncomplete=()=>r(),c.onerror=()=>r(),c.onabort=()=>r()}catch{r()}finally{s.close()}})}function fd(l){return l?`Herdr Glyphs ${l.sha256.slice(0,12)}`:null}function Vx(l){return l>=11904&&l<=12255||l>=12288&&l<=13311||l>=13312&&l<=19903||l>=19968&&l<=40959||l>=44032&&l<=55215||l>=63744&&l<=64255||l>=65072&&l<=65103||l>=65280&&l<=65519||l>=131072&&l<=201551}function kb(l,i){return i<32||i>=127&&i<160||i>=9472&&i<=9631?!1:l==="all"||Vx(i)}function Xx(l){const i=[...new Set(l)].sort((r,c)=>r-c),s=[];for(let r=0;r<i.length;r+=1){const c=i[r];let f=c;for(;r+1<i.length&&i[r+1]===f+1;)f=i[r+1],r+=1;const h=m=>m.toString(16).toUpperCase();s.push(c===f?`U+${h(c)}`:`U+${h(c)}-${h(f)}`)}return s.join(", ")}async function Px(l,i){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)throw new Error("font_api_unavailable");const s=new FontFace(l,i.data,{weight:"400",style:"normal",unicodeRange:Xx(i.codepoints)});document.fonts.add(await s.load())}const Bd=new Set;function Zx(l){return!!(l&&Bd.has(l))}async function Qx(l,i){if(Bd.has(l))return;if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)throw new Error("font_api_unavailable");const s=await Promise.all(i.map(({face:r,data:c})=>new FontFace(l,c,Kx[r.style]).load()));for(const r of s)document.fonts.add(r);Bd.add(l)}function sg(l){const i=atob(l),s=new Uint8Array(i.length);for(let r=0;r<i.length;r+=1)s[r]=i.charCodeAt(r);return s}async function rg(l,i,s){const r=Math.ceil(l.bytes/ud),c=new Uint8Array(l.bytes);let f=0;const h=async()=>{for(;f<r;){const m=f;f+=1;const b=await i(l.sha256,m),p=m*ud,y=Math.min(ud,l.bytes-p);if(b.length!==y)throw new Error("host_font_corrupt");c.set(b,p),s(b.length)}};return await Promise.all(Array.from({length:Math.min(Ux,r)},h)),c.buffer}const ef="herdr_remote_host_font_consent_v1";function Rb(){try{const l=JSON.parse(localStorage.getItem(ef)||"{}");return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return{}}}function og(l,i){const s=Rb()[l];return s&&s.fingerprint===i?s.decision:null}function cg(l,i,s){try{const r=Rb();r[l]={fingerprint:i,decision:s},localStorage.setItem(ef,JSON.stringify(r))}catch{}}const Wx=ef,Lb={source:null,status:"none",alias:null,covered:0},hd={font:null,status:"none",alias:null,receivedBytes:0,totalBytes:0,error:null,glyphs:Lb,interactive:!1,glyphRevision:0},ug=3e4,Jx=15e3,ew=80,tw=2e3,nw=String.fromCodePoint(...Array.from({length:95},(l,i)=>32+i),...Array.from({length:96},(l,i)=>160+i),...Array.from({length:112},(l,i)=>8192+i));function dg(l){const i=(l==null?void 0:l.subsets)??[];return i.find(s=>s.scope==="all")??i.find(s=>s.scope==="cjk")??null}function iw(l,i){const s=new Set;for(const r of l){const c=r.codePointAt(0);kb(i,c)&&s.add(c)}return[...s]}function lw(l,i={}){const[s,r]=S.useState(hd),c=S.useRef(s);c.current=s;const f=S.useRef(i);f.current=i;const h=S.useRef(0),m=S.useRef(new Map),b=S.useRef(new Map),p=S.useRef(new Map),y=S.useRef(0),v=S.useRef(new Set),w=S.useRef(new Set),T=S.useRef(new Set),A=S.useRef(null),$=()=>({isInstalled:f.current.isInstalled??Ix,readCached:f.current.readCached??Gx,writeCached:f.current.writeCached??Yx,register:f.current.register??Qx,isRegistered:f.current.isRegistered??Zx,readSubsets:f.current.readSubsets??$x,writeSubset:f.current.writeSubset??qx,registerGlyphs:f.current.registerGlyphs??Px}),R=()=>(l==null?void 0:l.getHostId())||"default",O=(ie,he)=>{ie===h.current&&r(oe=>({...oe,glyphs:{...oe.glyphs,...he}}))},j=S.useCallback(ie=>{for(const he of[m.current,b.current]){for(const oe of he.values())clearTimeout(oe.timer),oe.reject(new Error(ie));he.clear()}},[]),Y=S.useCallback((ie,he)=>new Promise((oe,pe)=>{if(!l){pe(new Error("disconnected"));return}const k=`${ie}:${he}`,I=setTimeout(()=>{m.current.delete(k),pe(new Error("host_font_timeout"))},ug);m.current.set(k,{resolve:oe,reject:pe,timer:I}),l.sendHostFontChunkRequest(ie,he)}),[l]),se=S.useCallback((ie,he,oe)=>new Promise((pe,k)=>{if(!l){k(new Error("disconnected"));return}const I=Math.random().toString(36).slice(2,12),le=setTimeout(()=>{b.current.delete(I),k(new Error("host_font_timeout"))},ug);b.current.set(I,{resolve:re=>pe({...re,codepoints:he}),reject:k,timer:le}),p.current.set(I,oe),l.sendHostFontSubsetRequest(ie.sha256,String.fromCodePoint(...he),I)}),[l]),fe=async(ie,he,oe)=>{const{registerGlyphs:pe}=$();for(const k of oe){if(await pe(he,k),ie!==h.current)return;for(const I of k.codepoints)v.current.add(I)}ie!==h.current||!oe.length||r(k=>({...k,glyphs:{...k.glyphs,alias:he,covered:v.current.size},glyphRevision:k.glyphRevision+1}))},Q=async(ie,he,oe)=>{const pe=fd(he),k=he.scope==="all"?nw+ig:ig,I=iw(k,he.scope).filter(re=>!v.current.has(re));if(!I.length)return;for(const re of I)w.current.add(re);const le=await se(he,I,oe);ie===h.current&&(await $().writeSubset(he.sha256,le),await fe(ie,pe,[le]))},K=S.useCallback(async(ie,{interactive:he=!0}={})=>{const oe=ie??c.current.font,pe=oa(oe);if(!oe||!pe)return;const k=c.current,I=oa(k.font)===pe;if(I&&(k.status==="loading"||k.glyphs.status==="loading"))return;const le=h.current,{isInstalled:re,isRegistered:V,readCached:Re,writeCached:Ae,register:xe}=$();cg(R(),pe,"accepted");const Se=lg(oe),Le=dg(oe),Be=!!(Se&&!V(Se)&&!re(oe.family)),ot=I?k.glyphs:{...Lb,source:Le},Xe=!!(Le&&!["installed","ready","none"].includes(ot.status));let ze=Be?ag(oe):0,yt=0;const Tt=()=>{le===h.current&&r(Ue=>({...Ue,receivedBytes:yt,totalBytes:ze}))};if(r(Ue=>({...Ue,font:oe,interactive:he,receivedBytes:0,totalBytes:ze,error:null,status:Be?"loading":Ue.status,glyphs:Xe?{...ot,status:"loading"}:ot})),Be&&Se)try{const Ue=[];for(const G of oe.faces){let me=await Re(G.sha256);if(me?(yt+=G.bytes,Tt()):(me=await rg(G,Y,$e=>{yt+=$e,Tt()}),await Ae(G.sha256,me)),le!==h.current)return;Ue.push({face:G,data:me})}if(await xe(Se,Ue),le!==h.current)return;r(G=>({...G,status:"loaded",alias:Se}))}catch(Ue){if(le!==h.current)return;const G=Ue instanceof Error&&Ue.message?Ue.message:"host_font_failed";r(me=>({...me,status:"failed",alias:null,error:G}))}if(Xe&&Le){let Ue=0;try{await Q(le,Le,(G,me)=>{me&&!Ue&&(Ue=me,ze+=me),yt+=G,Tt()}),O(le,{status:"ready"})}catch(G){if(le!==h.current)return;const me=G instanceof Error&&G.message?G.message:"host_font_failed";r($e=>({...$e,error:$e.error??me,glyphs:{...$e.glyphs,status:"failed"}}))}}},[Y,se]),q=S.useCallback(async ie=>{const he=oa(ie)!==oa(c.current.font);he&&(j("superseded"),v.current=new Set,w.current=new Set,T.current=new Set);const oe=++h.current;if(!ie){r(hd);return}const{isInstalled:pe,readCached:k,register:I,isRegistered:le,readSubsets:re}=$(),V=lg(ie),Re=oa(ie),Ae=dg(ie);let xe="checking";V&&le(V)?xe="loaded":pe(ie.family)?xe="installed":V||(xe="unavailable");let Se="checking";if(Ae?(Ae.scope==="cjk"?pe(Ae.family):xe==="installed")&&(Se="installed"):Se="none",r(Xe=>({...hd,font:ie,status:xe==="checking"?"checking":xe,alias:xe==="loaded"?V:null,totalBytes:ag(ie),glyphs:{source:Ae,status:Se,alias:he?null:Xe.glyphs.alias,covered:v.current.size},glyphRevision:Xe.glyphRevision})),xe==="checking"&&V){const Xe=await Promise.all(ie.faces.map(ze=>k(ze.sha256)));if(oe!==h.current)return;if(xe="needs",Xe.every(Boolean))try{if(await I(V,ie.faces.map((ze,yt)=>({face:ze,data:Xe[yt]}))),oe!==h.current)return;xe="loaded",r(ze=>({...ze,status:"loaded",alias:V}))}catch{}}if(Se==="checking"&&Ae){const Xe=await re(Ae.sha256);if(oe!==h.current)return;if(Xe.length)try{await fe(oe,fd(Ae),Xe),Se="cached"}catch{Se="needs"}else Se="needs";if(oe!==h.current)return}const Le=og(R(),Re),Be=Le==="accepted"||Se==="cached"||Date.now()<y.current;if(Se==="cached"&&(Se="ready",O(oe,{status:"ready"}),Q(oe,Ae,()=>{}).catch(()=>{})),xe!=="needs"&&Se!=="needs")return;if(Be){K(ie,{interactive:!1});return}const ot=Le==="declined"?"declined":"available";r(Xe=>({...Xe,status:xe==="needs"?ot:Xe.status,glyphs:Se==="needs"?{...Xe.glyphs,status:ot}:Xe.glyphs}))},[K,j]),ue=S.useCallback(()=>{const ie=oa(c.current.font);ie&&cg(R(),ie,"declined"),r(he=>({...he,interactive:!1,status:["available","failed"].includes(he.status)?"declined":he.status,glyphs:["available","failed"].includes(he.glyphs.status)?{...he.glyphs,status:"declined"}:he.glyphs}))},[]),ye=S.useCallback(()=>{y.current=Date.now()+Jx,l==null||l.sendHostFontRefresh();const ie=c.current,he=["available","declined","failed"];ie.font&&(he.includes(ie.status)||he.includes(ie.glyphs.status))&&K(ie.font,{interactive:!1})},[l,K]),Ne=S.useCallback(ie=>{const{glyphs:he}=c.current;if(he.status!=="ready"||!he.source)return;const oe=he.source;for(const pe of ie){const k=pe.codePointAt(0);k<128&&oe.scope!=="all"||kb(oe.scope,k)&&(v.current.has(k)||w.current.has(k)||T.current.add(k))}!T.current.size||A.current||(A.current=setTimeout(()=>{A.current=null;const pe=h.current,k=[...T.current].slice(0,tw);for(const I of k)T.current.delete(I),w.current.add(I);(async()=>{const I=await se(oe,k,()=>{});pe===h.current&&(await $().writeSubset(oe.sha256,I),await fe(pe,fd(oe),[I]))})().catch(()=>{})},ew))},[se]);return S.useEffect(()=>{if(!l)return;const ie=m.current,he=b.current,oe=l.on("terminalFont",re=>{q(re)}),pe=l.on("hostFontChunk",re=>{const V=`${re.sha256}:${re.index}`,Re=ie.get(V);if(Re){ie.delete(V),clearTimeout(Re.timer);try{Re.resolve(sg(re.dataBase64))}catch{Re.reject(new Error("host_font_corrupt"))}}}),k=l.on("hostFontSubset",re=>{const V=he.get(re.requestId);if(!V)return;he.delete(re.requestId),clearTimeout(V.timer);const Re=p.current.get(re.requestId)??(()=>{});if(p.current.delete(re.requestId),re.dataBase64!==void 0){try{const xe=sg(re.dataBase64);Re(xe.length,xe.length),V.resolve({subsetSha:re.subsetSha,data:xe.buffer,codepoints:[]})}catch{V.reject(new Error("host_font_corrupt"))}return}Re(0,re.bytes);const Ae={bytes:re.bytes,sha256:re.subsetSha};rg(Ae,Y,xe=>Re(xe,re.bytes)).then(xe=>V.resolve({subsetSha:re.subsetSha,data:xe,codepoints:[]})).catch(xe=>V.reject(xe instanceof Error?xe:new Error("host_font_failed")))}),I=l.on("error",re=>{(re.code==="host_font_unavailable"||re.code==="host_font_subset_failed")&&j(String(re.code))}),le=l.on("stateChange",re=>{re!=="connected"&&j("disconnected")});return()=>{oe(),pe(),k(),I(),le(),j("disconnected"),A.current&&clearTimeout(A.current),A.current=null}},[l,q,j,Y]),S.useEffect(()=>{const ie=he=>{if(he.key!==Wx)return;const oe=c.current,pe=oa(oe.font),k=oe.status==="available"||oe.glyphs.status==="available";if(!pe||!k)return;const I=og(R(),pe);I==="accepted"?K(oe.font,{interactive:!1}):I==="declined"&&ue()};return window.addEventListener("storage",ie),()=>window.removeEventListener("storage",ie)},[K,ue]),{hostFont:s,loadHostFont:K,declineHostFont:ue,syncHostFont:ye,ensureHostGlyphs:Ne}}const L=(l,i,s,r=!0)=>({id:l,labelKey:i,combo:s,verified:r}),_b={claude:{id:"claude",name:"Claude Code",shortName:"Claude",configHint:"~/.claude/keybindings.json",bar:["mode","rewind","details","model"],actions:[L("mode","mode","shift+tab"),L("rewind","rewind","esc esc"),L("details","details","ctrl+o"),L("model","model","alt+p"),L("thinking","thinking","alt+t"),L("todos","todos","ctrl+t"),L("background","background","ctrl+b"),L("editor","editor","ctrl+g"),L("history","history","ctrl+r"),L("stash","stash","ctrl+s"),L("pasteImage","pasteImage","ctrl+v"),L("newline","newline","ctrl+j"),L("interrupt","interrupt","esc")]},codex:{id:"codex",name:"Codex",shortName:"Codex",configHint:"~/.codex/config.toml [tui.keymap]",bar:["mode","editPrevious","details"],actions:[L("mode","mode","shift+tab"),L("editPrevious","editPrevious","esc esc"),L("details","details","ctrl+t"),L("queue","queue","tab"),L("history","history","ctrl+r"),L("copy","copy","ctrl+o"),L("editor","editor","ctrl+g"),L("newline","newline","ctrl+j"),L("clear","clear","ctrl+l"),L("interrupt","interrupt","esc")]},gemini:{id:"gemini",name:"Gemini CLI",shortName:"Gemini",configHint:"~/.gemini/keybindings.json",bar:["mode","yolo","rewind"],actions:[L("mode","mode","shift+tab"),L("yolo","yolo","ctrl+y"),L("rewind","rewind","esc esc"),L("todos","todos","ctrl+t"),L("expand","expand","ctrl+o"),L("background","background","ctrl+b"),L("editor","editor","ctrl+g"),L("history","history","ctrl+r"),L("undo","undo","ctrl+z"),L("newline","newline","ctrl+j"),L("interrupt","interrupt","esc")]},qwen:{id:"qwen",name:"Qwen Code",shortName:"Qwen",bar:["mode","history"],actions:[L("mode","mode","shift+tab"),L("interrupt","interrupt","esc"),L("history","history","ctrl+r"),L("newline","newline","ctrl+j"),L("todos","todos","ctrl+t",!1),L("rewind","rewind","esc esc",!1)]},opencode:{id:"opencode",name:"OpenCode",shortName:"OpenCode",configHint:"tui.json keybinds",bar:["palette","model","sessions"],actions:[L("agent","agent","tab"),L("agentBack","agentBack","shift+tab"),L("interrupt","interrupt","esc"),L("palette","palette","ctrl+p"),L("model","model","ctrl+x m"),L("recentModel","recentModel","f2"),L("variant","variant","ctrl+t"),L("newSession","newSession","ctrl+x n"),L("sessions","sessions","ctrl+x l"),L("undo","undo","ctrl+x u"),L("editor","editor","ctrl+x e"),L("newline","newline","ctrl+j")]},kilo:{id:"kilo",name:"Kilo Code",shortName:"Kilo",configHint:"~/.config/kilo/tui.jsonc",bar:["palette","model","sessions"],actions:[L("agent","agent","tab",!1),L("agentBack","agentBack","shift+tab",!1),L("interrupt","interrupt","esc"),L("palette","palette","ctrl+p"),L("model","model","ctrl+x m"),L("recentModel","recentModel","f2"),L("variant","variant","ctrl+t"),L("newSession","newSession","ctrl+x n"),L("sessions","sessions","ctrl+x l"),L("undo","undo","ctrl+x u"),L("editor","editor","ctrl+x e"),L("newline","newline","ctrl+j")]},pi:{id:"pi",name:"Pi",shortName:"Pi",configHint:"~/.pi/agent/keybindings.json",bar:["thinkingMode","modelPicker","tools"],actions:[L("thinkingMode","thinkingMode","shift+tab"),L("interrupt","interrupt","esc"),L("nextModel","nextModel","ctrl+p"),L("modelPicker","modelPicker","ctrl+l"),L("tools","tools","ctrl+o"),L("thinkingBlocks","thinkingBlocks","ctrl+t"),L("editor","editor","ctrl+g"),L("followup","followup","alt+enter"),L("dequeue","dequeue","alt+up"),L("newline","newline","shift+enter")]},omp:{id:"omp",name:"Oh My Pi",shortName:"OMP",configHint:"~/.omp/agent/keybindings.yml",bar:["thinkingMode","plan","model"],actions:[L("thinkingMode","thinkingMode","shift+tab"),L("plan","plan","alt+shift+p"),L("model","model","alt+m"),L("temporaryModel","temporaryModel","alt+p"),L("nextModel","nextModel","ctrl+p"),L("tools","tools","ctrl+o"),L("thinking","thinking","ctrl+t"),L("history","history","ctrl+r"),L("editor","editor","ctrl+g"),L("followup","followup","ctrl+enter"),L("interrupt","interrupt","esc")]},copilot:{id:"copilot",name:"GitHub Copilot",shortName:"Copilot",bar:["mode","expand","reasoning"],actions:[L("mode","mode","shift+tab"),L("interrupt","interrupt","esc"),L("expand","expand","ctrl+o"),L("expandAll","expandAll","ctrl+e"),L("reasoning","reasoning","ctrl+t"),L("editor","editor","ctrl+g"),L("clear","clear","ctrl+l")]},cursor:{id:"cursor",name:"Cursor",shortName:"Cursor",bar:["mode","review"],actions:[L("mode","mode","shift+tab"),L("review","review","ctrl+r"),L("newline","newline","ctrl+j"),L("interrupt","interrupt","esc",!1)]},droid:{id:"droid",name:"Factory Droid",shortName:"Droid",configHint:"In-app settings",bar:["specMode","autonomy"],actions:[L("specMode","specMode","shift+tab"),L("autonomy","autonomy","ctrl+l"),L("details","details","ctrl+o",!1),L("queue","queue","ctrl+enter"),L("interrupt","interrupt","esc",!1)]},kimi:{id:"kimi",name:"Kimi Code",shortName:"Kimi",bar:["plan","undoPicker","expand"],actions:[L("plan","plan","shift+tab"),L("interrupt","interrupt","esc"),L("undoPicker","undoPicker","esc esc"),L("expand","expand","ctrl+o"),L("editor","editor","ctrl+g"),L("steer","steer","ctrl+s"),L("undo","undo","ctrl+-"),L("newline","newline","ctrl+j"),L("pasteImage","pasteImage","ctrl+v")]},amp:{id:"amp",name:"Amp",shortName:"Amp",bar:["palette","reasoning","mode"],actions:[L("palette","palette","ctrl+o"),L("reasoning","reasoning","alt+d"),L("mode","mode","ctrl+s",!1),L("editor","editor","ctrl+g"),L("history","history","ctrl+r"),L("sidebar","sidebar","ctrl+backslash"),L("pasteImage","pasteImage","ctrl+v"),L("interrupt","interrupt","esc",!1)]},hermes:{id:"hermes",name:"Hermes",shortName:"Hermes",bar:["interrupt","agents","sessions"],actions:[L("interrupt","interrupt","ctrl+c"),L("newline","newline","ctrl+j"),L("editor","editor","ctrl+g"),L("agents","agents","ctrl+t"),L("sessions","sessions","ctrl+x")]},qodercli:{id:"qodercli",name:"Qoder CLI",shortName:"Qoder",configHint:"/shortcuts in-app",bar:["permissionMode","bypass","tasks","interrupt"],actions:[L("permissionMode","permissionMode","shift+tab"),L("bypass","bypass","ctrl+y"),L("tasks","tasks","ctrl+t"),L("editor","editor","ctrl+x"),L("history","history","ctrl+r"),L("queue","queue","ctrl+enter"),L("newline","newline","ctrl+j"),L("pasteImage","pasteImage","alt+v"),L("interrupt","interrupt","ctrl+c")]},devin:{id:"devin",name:"Devin",shortName:"Devin",configHint:"~/.config/devin/config.json keymap",bar:["mode","thinking","interrupt"],actions:[L("mode","mode","shift+tab"),L("interrupt","interrupt","ctrl+c"),L("thinking","thinking","alt+t"),L("newline","newline","ctrl+j"),L("pasteImage","pasteImage","ctrl+v")]},grok:{id:"grok",name:"Grok CLI",shortName:"Grok",bar:["mode","rewind","interrupt"],actions:[L("mode","mode","shift+tab"),L("interrupt","interrupt","ctrl+c"),L("rewind","rewind","esc esc"),L("interject","interject","ctrl+enter"),L("multiline","multiline","ctrl+m"),L("newline","newline","alt+enter"),L("shortcuts","shortcuts","ctrl+.")]},agy:{id:"agy",name:"Antigravity",shortName:"Antigravity",configHint:"~/.gemini/antigravity-cli/keybindings.json",bar:["mode","approve","interrupt"],actions:[L("mode","mode","shift+tab"),L("interrupt","interrupt","ctrl+c"),L("background","background","ctrl+b"),L("approve","approve","ctrl+k"),L("clear","clear","esc esc")]},mastracode:{id:"mastracode",name:"MastraCode",shortName:"MastraCode",bar:["interrupt","thinking","expand"],actions:[L("interrupt","interrupt","ctrl+c"),L("thinking","thinking","ctrl+t"),L("expand","expand","ctrl+e"),L("followup","followup","ctrl+f")]},letta:{id:"letta",name:"Letta Code",shortName:"Letta",bar:["permissionMode"],actions:[L("permissionMode","permissionMode","shift+tab"),L("interrupt","interrupt","esc",!1)]},kiro:{id:"kiro",name:"Kiro CLI",shortName:"Kiro",configHint:"kiro-cli settings chat.keybindings.*",bar:["agentSwap","details","steer"],actions:[L("agentSwap","agentSwap","shift+tab"),L("interrupt","interrupt","esc"),L("details","details","ctrl+t"),L("steer","steer","ctrl+s"),L("expand","expand","ctrl+o"),L("activity","activity","ctrl+x"),L("newline","newline","ctrl+j")]},cline:{id:"cline",name:"Cline",shortName:"Cline",bar:["autoApprove"],actions:[L("planAct","planAct","tab"),L("autoApprove","autoApprove","shift+tab"),L("interrupt","interrupt","esc",!1)]},maki:{id:"maki",name:"Maki",shortName:"Maki",bar:["rewind","search"],actions:[L("rewind","rewind","esc esc"),L("search","search","ctrl+f"),L("interrupt","interrupt","esc",!1)]},muse:{id:"muse",name:"Muse",shortName:"Muse",configHint:"/keymap in-app",bar:["queue","interruptCtrl"],actions:[L("interrupt","interrupt","esc"),L("queue","queue","alt+enter"),L("interruptCtrl","interrupt","ctrl+c")]},shell:{id:"shell",name:"Shell",shortName:"Shell",actions:[]}},da=_b,aw=Object.keys(_b),fg={pi:"pi",claude:"claude","claude-code":"claude",codex:"codex",gemini:"gemini",cursor:"cursor","cursor-agent":"cursor",devin:"devin","devin-cli":"devin","devin cli":"devin",agy:"agy",antigravity:"agy","antigravity-cli":"agy",cline:"cline",".cline":"cline",omp:"omp",mastracode:"mastracode","mastra-code":"mastracode","mastra code":"mastracode",opencode:"opencode",opencode2:"opencode","open-code":"opencode",copilot:"copilot","github-copilot":"copilot",ghcs:"copilot",kimi:"kimi","kimi-code":"kimi","kimi code":"kimi",kiro:"kiro","kiro-cli":"kiro",droid:"droid",amp:"amp","amp-local":"amp",grok:"grok","grok-build":"grok",hermes:"hermes","hermes-agent":"hermes",kilo:"kilo","kilo-code":"kilo","kilo code":"kilo",qodercli:"qodercli",qoderclicn:"qodercli",qoder:"qodercli",qodercn:"qodercli",qwen:"qwen","qwen-code":"qwen","qwen code":"qwen",letta:"letta","letta-code":"letta","letta code":"letta",maki:"maki",muse:"muse","muse-code":"muse","muse-cli":"muse",shell:"shell"},sw=[L("genericCtrlC","interrupt","ctrl+c"),L("genericCtrlD","eof","ctrl+d"),L("genericCtrlZ","suspend","ctrl+z"),L("genericCtrlL","clear","ctrl+l"),L("genericCtrlR","history","ctrl+r"),L("genericCtrlA","startOfLine","ctrl+a"),L("genericCtrlE","endOfLine","ctrl+e"),L("genericCtrlK","killToEnd","ctrl+k")],rw=["genericCtrlC","genericCtrlD","genericCtrlL","genericCtrlR"],ow=["genericCtrlC"];function cw(l){return l&&l.trim().toLowerCase().replace(/\\/g,"/").split("/").at(-1)||""}function hg(l){const i=cw(l);return fg[i]?fg[i]:/^muse-bin-\d/.test(i)?"muse":null}function uw(l,i="auto"){return i&&i!=="auto"?hg(i)||"shell":hg(l)||"shell"}function dw(l,i){var c,f;const s=l.map(h=>{var p;const m=(p=i==null?void 0:i.actions)==null?void 0:p[h.id];let b=typeof(m==null?void 0:m.keys)=="string"?m.keys:h.combo;try{Ri(b)}catch{b=h.combo}return{...h,defaultCombo:h.combo,combo:b,hidden:typeof(m==null?void 0:m.hidden)=="boolean"?m.hidden:h.defaultHidden===!0,custom:!1}}),r=new Set(s.map(h=>h.id));for(const h of(i==null?void 0:i.custom)||[]){if(!h||typeof h.id!="string"||r.has(h.id))continue;let m=h.keys;try{Ri(m)}catch{continue}s.push({id:h.id,labelKey:"custom",defaultCombo:m,combo:m,verified:!0,hidden:((f=(c=i==null?void 0:i.actions)==null?void 0:c[h.id])==null?void 0:f.hidden)===!0,custom:!0,customLabel:h.label}),r.add(h.id)}if(Array.isArray(i==null?void 0:i.order)){const h=new Map(i.order.map((m,b)=>[m,b]));s.sort((m,b)=>(h.get(m.id)??Number.MAX_SAFE_INTEGER)-(h.get(b.id)??Number.MAX_SAFE_INTEGER))}return s}function fw(l,i){const s=new Set(l.map(r=>r.combo.trim().toLowerCase()));return i.filter(r=>!s.has(r.combo.trim().toLowerCase()))}const hr=l=>l.id.startsWith("generic");function jb(l,i){const s=da[l],r=new Set([...s.bar||[],...l==="shell"?rw:ow]),c=[...s.actions,...sw].map(f=>({...f,defaultHidden:!r.has(f.id)}));return dw(c,i)}function Db(l,i){const s=jb(l,i),r=s.filter(f=>!hr(f)),c=new Set(fw(r,s.filter(hr)));return s.filter(f=>!hr(f)||c.has(f))}function hw(l,i){const s=Db(l,i).filter(r=>!r.hidden);return{agentActions:s.filter(r=>!hr(r)),genericActions:s.filter(hr)}}function mw(l){const i={};for(const[s,r]of Object.entries(l.actions||{})){const c={...r};delete c.hidden,Object.keys(c).length>0&&(i[s]=c)}return{...l,actions:i}}const Ob=1568,pw=3*1024*1024,gw=[.85,.7,.55,.4],mi={active:!1,phase:"idle",ratio:0,percent:0,statusText:""};function bw(l,i,s=Ob){if(l<=0||i<=0)return{width:Math.max(1,l),height:Math.max(1,i)};const r=Math.max(l,i);if(r<=s)return{width:l,height:i};const c=s/r;return{width:Math.max(1,Math.round(l*c)),height:Math.max(1,Math.round(i*c))}}function yw(l){if(typeof l!="string"||l.length===0)return 0;const i=l.length;let s=0;l.endsWith("==")?s=2:l.endsWith("=")&&(s=1);const r=Math.floor(i*3/4)-s;return Number.isFinite(r)&&r>0?r:0}function vw(l){return l<1024?`${l} B`:l<1024*1024?`${(l/1024).toFixed(1)} KB`:`${(l/(1024*1024)).toFixed(1)} MB`}async function xw(l){if(typeof createImageBitmap=="function")try{const i=await createImageBitmap(l,{imageOrientation:"from-image"});return{source:i,width:i.width,height:i.height,cleanup:()=>{typeof i.close=="function"&&i.close()}}}catch{try{const i=await createImageBitmap(l);return{source:i,width:i.width,height:i.height,cleanup:()=>{typeof i.close=="function"&&i.close()}}}catch{}}return new Promise((i,s)=>{if(typeof Image>"u")return s(new Error("Image decoding not supported in this environment"));const r=new Image,c=URL.createObjectURL(l);r.onload=()=>{i({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,cleanup:()=>{try{URL.revokeObjectURL(c)}catch{}}})},r.onerror=()=>{try{URL.revokeObjectURL(c)}catch{}s(new Error("Failed to decode image source"))},r.src=c})}async function zb(l,i=Ob,s=pw){var c;if(!l||l.size===0||l.type&&!l.type.startsWith("image/"))return null;let r;try{r=await xw(l)}catch(f){return console.warn("Failed to decode image for paste:",f),null}try{const{width:f,height:h}=bw(r.width,r.height,i),m=document.createElement("canvas");m.width=f,m.height=h;const b=m.getContext("2d");if(!b)return null;b.drawImage(r.source,0,0,f,h);let p="image/webp";try{m.toDataURL("image/webp",.85).startsWith("data:image/webp")||(p="image/jpeg")}catch{p="image/jpeg"}for(const y of gw){let v;try{v=m.toDataURL(p,y)}catch{continue}if(!v||!v.startsWith("data:"))continue;const w=v.indexOf(","),T=w!==-1?v.slice(w+1):"",A=yw(T);if(A<=s)return{mime:p,dataBase64:T,dataUrl:v,byteLength:A,width:f,height:h}}return null}finally{(c=r.cleanup)==null||c.call(r)}}const ww=4e3,Sw=3,Cw=4096,Tw=8*1024*1024,Eo={ctrl:!1,alt:!1,shift:!1},Mw=3e4,Bb=S.createContext(null);function Ja(l){return{wsUrl:l.wsUrl,token:l.token||void 0,pairCode:l.pairCode||void 0,clientId:l.clientId,autoReconnect:l.autoReconnect,reconnectIntervalMs:2e3,maxReconnectAttempts:0,pingIntervalMs:1e4}}const Aw=({children:l})=>{var Si;const[i,s]=S.useState(Ab),[r,c]=S.useState("disconnected"),[f,h]=S.useState(),[m,b]=S.useState(),[p,y]=S.useState("viewer"),[v,w]=S.useState(),[T,A]=S.useState(),[$,R]=S.useState(),[O,j]=S.useState(null),[Y,se]=S.useState(null),[fe,Q]=S.useState(Tx),K=S.useRef(fe),q=S.useRef(new Set),ue=S.useRef(null),ye=S.useRef(null),Ne=S.useCallback(z=>{(z==null?void 0:z.phase)!=="starting"&&ye.current&&(clearTimeout(ye.current),ye.current=null),ue.current=z,j(z)},[]),[ie,he]=S.useState(null),[oe,pe]=S.useState(),[k,I]=S.useState(null),[le,re]=S.useState(1),[V,Re]=S.useState(0),[Ae,xe]=S.useState(null),[Se,Le]=S.useState(null),[Be,ot]=S.useState(null),[Xe,ze]=S.useState({cols:80,rows:24}),[yt,Tt]=S.useState([]),Ue=uw(Se==null?void 0:Se.focusedAgent,"auto");S.useEffect(()=>{Eb()},[]);const G=S.useRef(i);G.current=i;const me=S.useRef(null),$e=S.useRef(!1),_t=S.useRef(Xe);_t.current=Xe;const Kt=S.useRef(new Set),hn=S.useRef(new Set),[Yt,ct]=S.useState(mi),Ke=S.useRef(null),bn=S.useRef(0),ut=S.useRef(null),qe=S.useCallback((z,C)=>Jd(i.language,z,C),[i.language]),wt=S.useRef(qe);wt.current=qe;const yn=S.useRef(null),We=S.useRef([]),Pe=S.useRef(0),Mt=S.useCallback(z=>{for(We.current.push(z),Pe.current+=z.byteLength;We.current.length>Cw||Pe.current>Tw;){const C=We.current.shift();if(!C)break;Pe.current-=C.byteLength}},[]),E=S.useCallback(z=>{const C=yn.current;if(C)try{C(z);return}catch(D){console.debug("Terminal output sink threw, buffering chunk instead:",D)}Mt(z)},[Mt]),ce=S.useRef(E);ce.current=E;const de=S.useCallback(z=>{yn.current=z;const C=We.current;We.current=[],Pe.current=0;for(let D=0;D<C.length;D++)try{z(C[D])}catch(te){console.debug("Terminal sink threw while flushing, re-buffering the tail:",te);for(let J=D;J<C.length;J++)Mt(C[J]);break}return()=>{yn.current===z&&(yn.current=null)}},[Mt]),_e=S.useCallback(()=>We.current.length,[]),mt=S.useCallback(()=>{We.current=[],Pe.current=0},[]),$t=S.useCallback((z=!0)=>{y("viewer"),w(void 0),A(void 0),R(void 0),he(null),pe(void 0),I(null),re(1),xe(null),mt(),z&&Re(C=>C+1)},[mt]),dt=S.useRef([]),rn=S.useRef(new Map),Wt=S.useCallback(z=>{dt.current=z,Tt(z)},[]),ln=S.useCallback(z=>{const C=rn.current.get(z);C&&(clearTimeout(C),rn.current.delete(z)),Wt(dt.current.filter(D=>D.id!==z))},[Wt]),It=S.useRef(ln);It.current=ln;const Ge=S.useCallback((z,C)=>{const D=Date.now(),te=dt.current,J=te.find(je=>je.type===z&&je.message===C),be=J?J.id:`${D}-${Math.random().toString(36).substring(2,6)}`;let ee;if(J)ee=te.map(je=>je.id===be?{...je,count:je.count+1,timestamp:D}:je);else for(ee=[...te,{id:be,type:z,message:C,timestamp:D,count:1}];ee.length>Sw;){const[je,...At]=ee,nt=rn.current.get(je.id);nt&&(clearTimeout(nt),rn.current.delete(je.id)),ee=At}Wt(ee);const vt=rn.current.get(be);vt&&clearTimeout(vt),rn.current.set(be,setTimeout(()=>It.current(be),ww))},[Wt]),vn=S.useCallback(z=>{It.current(z)},[]),Cn=S.useRef(!0);S.useEffect(()=>{p==="controller"&&(Cn.current=!0)},[p]);const jt=S.useCallback(()=>{Cn.current&&(Cn.current=!1,Ge("warning",wt.current("toasts.viewerModeWarning")))},[Ge]);S.useEffect(()=>{const z=rn.current;return()=>{for(const C of z.values())clearTimeout(C);z.clear()}},[]);const on=S.useCallback(z=>{const C=_l(z);G.current=C,s(C)},[]),ga=S.useCallback(z=>{on({language:z})},[on]),St=S.useCallback(z=>{G.current=z,s(z)},[]),tl=S.useCallback(z=>{var J;const C=G.current,D=Jp({...z,wsUrl:z.wsUrl||"/ws/client",token:z.token||"",displayName:z.displayName||`Herdr ${C.profiles.length+1}`,autoReconnect:z.autoReconnect!==!1},C.profiles.length),te=_l({profiles:[...C.profiles,D],activeProfileId:D.id,wsUrl:D.wsUrl,token:D.token,pairCode:D.pairCode||"",autoReconnect:D.autoReconnect});St(te),$t(),(J=me.current)==null||J.reconnectWith(Ja(te))},[St,$t]),$n=S.useCallback(z=>{var J;const C=G.current,D=C.profiles.find(be=>be.id===z);if(!D||D.id===C.activeProfileId)return;const te=_l({activeProfileId:D.id,wsUrl:D.wsUrl,token:D.token,pairCode:D.pairCode||"",autoReconnect:D.autoReconnect,profiles:C.profiles.map(be=>be.id===D.id?{...be,lastUsedAt:Date.now()}:be)});St(te),$t(),(J=me.current)==null||J.reconnectWith(Ja(te))},[St,$t]),ba=S.useCallback((z,C)=>{const D=G.current;if(!D.profiles.find(ee=>ee.id===z))return;const J=C.trim().slice(0,64);if(!J)return;const be=_l({profiles:D.profiles.map(ee=>ee.id===z?{...ee,displayName:J}:ee)});St(be)},[St]),Fl=S.useCallback(z=>{var be;const C=G.current;if(!C.profiles.some(ee=>ee.id===z))return;const D=C.profiles.filter(ee=>ee.id!==z),te=D.find(ee=>ee.id===C.activeProfileId)||D[0],J=_l(te?{profiles:D,activeProfileId:te.id,wsUrl:te.wsUrl,token:te.token,pairCode:te.pairCode||"",autoReconnect:te.autoReconnect}:{profiles:[],activeProfileId:"",wsUrl:"/ws/client",token:"",pairCode:""});St(J),z===C.activeProfileId&&($t(),(be=me.current)==null||be.reconnectWith(Ja(J)))},[St,$t]),nl=S.useCallback(z=>{const C=G.current,D=C.profiles.find(Ot=>Ot.id===C.activeProfileId),te=z.hostId?eg({wsUrl:C.wsUrl,hostId:z.hostId}):null,J=te?C.profiles.findIndex(Ot=>eg(Ot)===te):-1,be=J>=0?J:Math.max(0,C.profiles.findIndex(Ot=>Ot.id===C.activeProfileId)),vt={...C.profiles[be]||D||Jp({wsUrl:C.wsUrl||"/ws/client",token:"",pairCode:C.pairCode||"PENDING",displayName:`Herdr ${C.profiles.length+1}`},C.profiles.length),token:z.token,pairCode:void 0,...z.hostId?{hostId:z.hostId}:{},...z.deviceId?{deviceId:z.deviceId}:{},lastUsedAt:Date.now()};let je=[...C.profiles];be>=0&&be<je.length?je[be]=vt:je.push(vt);const At=D==null?void 0:D.id;je=je.filter((Ot,mn)=>mn===be||Ot.id===vt.id?!0:!(J>=0&&At&&Ot.id===At));const nt=_l({profiles:je,activeProfileId:vt.id,wsUrl:vt.wsUrl,token:vt.token,pairCode:"",autoReconnect:vt.autoReconnect});return St(nt),nt},[St]),jn=S.useCallback(z=>{const C=G.current,D=C.profiles.find(ee=>ee.id===C.activeProfileId);if(!D||!z.hostId&&!z.hostname)return;const te=/^Herdr \d+$/.test(D.displayName),J={...D,...z.hostId?{hostId:z.hostId}:{},...z.hostname?{hostname:z.hostname}:{},...z.hostname&&te?{displayName:z.hostname}:{}},be=_l({profiles:C.profiles.map(ee=>ee.id===D.id?J:ee)});St(be)},[St]);if(!me.current){const z=new sx(Ja(i));me.current=z,z.on("stateChange",(C,D,te)=>{c(C),b(te);const J=te?`serverErrors.${te}`:null,be=J?wt.current(J):null,ee=be&&be!==J?be:D;h(ee),C==="connected"?Ge("success",wt.current("toasts.connected")):C==="error"&&Ge("error",ee||wt.current("toasts.connectionError")),C!=="connected"&&Le(null),C!=="connected"&&Ne(null)}),z.on("ready",C=>{$e.current&&(mt(),Re(D=>D+1)),$e.current=!0,Ne(null),se(null),y(C.role),w(C.controllerId),A(C.hostId),R(C.hostname),jn(C),C.clientId&&pe(C.clientId),he(C.terminalPalette||null)}),z.on("hostReconnecting",C=>{b(C||"host_reconnecting"),h(wt.current(`serverErrors.${C||"host_reconnecting"}`)),y("viewer"),w(void 0),R(void 0),he(null),I(null),re(1),xe(null),mt()}),z.on("sessionRestarted",(C,D,te,J)=>{mt(),R(J),jn({hostId:z.getHostId(),hostname:J}),he(te||null),Re(be=>be+1)}),z.on("roleChange",(C,D,te,J)=>{y(C),w(D),te&&A(te),J&&pe(J)}),z.on("controlGranted",()=>{y("controller"),Ge("success",wt.current("toasts.controlGranted"))}),z.on("controlDenied",C=>{Ge("warning",C||wt.current("toasts.controlDenied"))}),z.on("controlRevoked",C=>{y("viewer"),Ge("warning",C||wt.current("toasts.controlRevoked"))}),z.on("paired",C=>{const D=nl(C);Ge("success",wt.current("toasts.pairedSuccess")),ot(Date.now()),z.reconnectWith(Ja(D))}),z.on("exit",(C,D)=>{Ge("info",`${wt.current("toasts.sessionEnded")}${D?`: ${D}`:""}${C!==void 0?` (${C})`:""}`)}),z.on("status",C=>{xe(C)}),z.on("error",C=>{var ee;if(C.code==="herdr_not_running"){((ee=ue.current)==null?void 0:ee.phase)!=="starting"&&Ne({phase:"stopped"});return}if(C.code==="herdr_start_failed"&&ue.current){Ne({phase:"failed",message:C.message||""});return}if(C.code==="host_font_unavailable")return;Ke.current!==null&&(ut.current&&(clearTimeout(ut.current),ut.current=null),Ke.current=null,ct(mi));const te=`serverErrors.${String(C.code)}`,J=wt.current(te),be=J&&J!==te?J:C.message||`[${C.code}]`;Ge("error",be)}),z.on("pasteFileReady",C=>{const D=Ke.current;D!==null&&(ut.current&&(clearTimeout(ut.current),ut.current=null),ct({active:!0,phase:"completed",ratio:1,percent:100,statusText:wt.current("virtualKeyboard.uploadProgressCompleted")}),setTimeout(()=>{Ke.current===D&&(Ke.current=null,ct(mi))},1200));for(const te of Kt.current)try{te(C)}catch(J){console.error("Error in pasteFileReady listener:",J)}}),z.on("rttUpdate",C=>{I(C)}),z.on("peerCount",C=>{re(Math.max(1,C))}),z.on("sessionReady",()=>{c("connected"),Ne(null)}),z.on("agentStatus",C=>{Le(C)}),z.on("updateStatus",C=>{if(se(C),!C.updateAvailable||K.current===C.latest)return;const D=`${C.latest}:${C.restartPending?"restart":"update"}`;q.current.has(D)||(q.current.add(D),Ge("info",C.restartPending?wt.current("update.toastRestart",{version:C.latest}):wt.current("update.toast",{version:C.latest})))}),z.on("binaryData",C=>{ce.current(C)})}const xn=me.current,qn=i.profiles.find(z=>z.id===i.activeProfileId),{hostFont:qt,loadHostFont:ya,declineHostFont:Dn,syncHostFont:Dt,ensureHostGlyphs:Jt}=lw(xn),On=Bx(i.fontFamily,qt.font?{family:qt.font.family,alias:qt.status==="loaded"?qt.alias:null,glyphs:qt.glyphs.source?{family:qt.glyphs.source.family,scope:qt.glyphs.source.scope,alias:qt.glyphs.alias}:null}:null),bi=i.fontSizeFollowsHost&&((Si=qt.font)!=null&&Si.sizePx)?cs(qt.font.sizePx,i.fontSize):i.fontSize;S.useEffect(()=>{document.documentElement.style.setProperty("--tui-font",On)},[On]),S.useEffect(()=>{var z;(z=me.current)==null||z.updateConfig(Ja(i))},[i]);const il=S.useCallback(z=>{me.current&&(z&&me.current.updateConfig(z),me.current.connect(_t.current))},[]),ps=S.useCallback(()=>{me.current&&me.current.disconnect()},[]),va=S.useCallback(z=>{K.current=z,Q(z),Mx(z)},[]),_i=S.useCallback(()=>{const z=me.current;z&&(Ne({phase:"starting"}),z.sendHerdrStart(),ye.current=setTimeout(()=>{var C;ye.current=null,((C=ue.current)==null?void 0:C.phase)==="starting"&&Ne({phase:"failed",message:wt.current("herdrLaunch.timeout")})},Mw))},[Ne]);S.useEffect(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);const Gl=S.useCallback((z=!1)=>{me.current&&me.current.claimControl(z)},[]),yi=S.useCallback(()=>{var z;(z=me.current)==null||z.releaseControl()},[]),vi=S.useCallback(z=>{if(p!=="controller"){jt();return}const C=me.current;if(!C)return;const D=Pd(z);for(const te of hn.current)try{te(D)}catch(J){console.debug("Key input observer threw:",J)}C.sendInput(D)},[p,jt]),xi=S.useCallback(z=>(hn.current.add(z),()=>{hn.current.delete(z)}),[]),[ai,Ct]=S.useState(Eo),Vn=S.useRef(Eo),wi=S.useCallback(z=>{const C={...Vn.current,[z]:!Vn.current[z]};Vn.current=C,Ct(C)},[]),Xn=S.useCallback(()=>{const z=Vn.current;return!z.ctrl&&!z.alt&&!z.shift?null:(Vn.current=Eo,Ct(Eo),z)},[]);S.useEffect(()=>{const z=me.current;return z?rx(z):void 0},[]);const si=S.useCallback(z=>{p!=="controller"&&!qo(z)||me.current&&me.current.sendInput(z)},[p]),xa=S.useCallback((z,C)=>{_t.current={cols:z,rows:C},ze({cols:z,rows:C}),me.current&&me.current.sendResize(z,C)},[]),ji=S.useCallback((z,C)=>p!=="controller"?(jt(),!1):me.current?(me.current.sendPasteFile(z,C),!0):!1,[p,jt]),Yl=S.useCallback(z=>(Kt.current.add(z),()=>{Kt.current.delete(z)}),[]),wa=S.useCallback(()=>{ut.current&&(clearTimeout(ut.current),ut.current=null),Ke.current=null,ct(mi)},[]);S.useEffect(()=>{r!=="connected"&&Ke.current!==null&&(ut.current&&(clearTimeout(ut.current),ut.current=null),Ke.current=null,ct(mi))},[r]),S.useEffect(()=>()=>{ut.current&&clearTimeout(ut.current)},[]);const Di=S.useCallback(async z=>{if(p!=="controller")return jt(),!1;if(!me.current||r!=="connected")return Ge("error",qe("serverErrors.host_offline")),!1;if(Ke.current!==null)return!1;const C=++bn.current;Ke.current=C,ut.current&&(clearTimeout(ut.current),ut.current=null);const D="dataBase64"in z&&typeof z.dataBase64=="string";try{let te;if(D)te=z;else{const be=z;if(ct({active:!0,phase:"reading",ratio:.1,percent:10,statusText:qe("virtualKeyboard.uploadProgressReading")}),!be||be.size===0)return Ge("error",qe("clipboard.fileEmpty")),Ke.current=null,ct(mi),!1;if(be.type&&!be.type.startsWith("image/"))return Ge("error",qe("clipboard.unsupportedType")),Ke.current=null,ct(mi),!1;ct({active:!0,phase:"processing",ratio:.35,percent:35,statusText:qe("virtualKeyboard.uploadProgressProcessing")});const ee=await zb(be);if(Ke.current!==C)return!1;if(!ee)return Ge("error",qe("clipboard.imageTooLarge")),Ke.current=null,ct(mi),!1;te=ee,ct({active:!0,phase:"processing",ratio:.6,percent:60,statusText:qe("virtualKeyboard.uploadProgressProcessing")})}ct({active:!0,phase:"sending",ratio:.75,percent:75,statusText:qe("virtualKeyboard.uploadProgressSending")});const J=ji(te.mime,te.dataBase64);return Ke.current!==C?!1:J?(ct({active:!0,phase:"waitingHost",ratio:.88,percent:88,statusText:qe("virtualKeyboard.uploadProgressWaitingHost")}),ut.current=setTimeout(()=>{Ke.current===C&&(Ke.current=null,Ge("error",qe("serverErrors.paste_file_write_failed")),ct(mi))},3e4),!0):(Ke.current=null,ct(mi),!1)}catch(te){return console.error("Failed to process/upload image:",te),Ke.current===C&&(Ke.current=null,Ge("error",qe("clipboard.imageTooLarge")),ct(mi)),!1}},[p,r,jt,Ge,qe,ji]);return d.jsx(Bb.Provider,{value:{connectionState:r,stateDetail:f,stateCode:m,role:p,controllerId:v,hostId:T,hostname:$,assignedClientId:oe,profiles:i.profiles,activeProfileId:i.activeProfileId,activeProfile:qn,isController:p==="controller",sharedWindowCount:le,terminalResetVersion:V,rttMs:k,statusPayload:Ae,agentStatus:Se,agentProfile:Ue,lastPairedAt:Be,settings:i,hostPalette:ie,hostFont:qt,loadHostFont:()=>{ya()},declineHostFont:Dn,syncHostFont:Dt,ensureHostGlyphs:Jt,terminalFontFamily:On,terminalFontSize:bi,terminalDimensions:Xe,toasts:yt,adapter:xn,language:i.language,t:qe,setLanguage:ga,connect:il,disconnect:ps,switchProfile:$n,addProfileAndConnect:tl,renameProfile:ba,removeProfile:Fl,claimControl:Gl,releaseControl:yi,sendKey:vi,observeKeyInput:xi,modifierLatch:ai,toggleModifierLatch:wi,consumeModifierLatch:Xn,sendBinary:si,sendResize:xa,updateSettings:on,addToast:Ge,removeToast:vn,warnViewerMode:jt,subscribeToOutput:de,getPendingOutputChunkCount:_e,sendPasteFile:ji,subscribeToPasteFileReady:Yl,uploadProgress:Yt,uploadImage:Di,resetUploadProgress:wa,herdrLaunch:O,startHerdr:_i,updateStatus:Y,ignoredUpdate:fe,ignoreUpdate:va},children:l})};function rt(){const l=S.useContext(Bb);if(!l)throw new Error("useTerminal must be used within a TerminalProvider");return l}function vr(l){var i,s;return l?{blocked:((i=l.counts)==null?void 0:i.blocked)??0,done:((s=l.counts)==null?void 0:s.done)??0}:null}function Ew(l){return l?l.blocked>0?"blocked":l.done>0?"done":null:null}function Nw(l){if(!l)return"";const i=[];return l.blocked>0&&i.push(`${l.blocked}⚠`),l.done>0&&i.push(`${l.done}✓`),i.length>0?`(${i.join(" ")})`:""}function kw(l,i){if(!l||!i)return null;const s=new Map(l.agents.map(h=>[h.paneId,h.status]));let r=null;for(const h of i.agents)if(!(h.status!=="blocked"&&h.status!=="done")&&s.get(h.paneId)!==h.status){if(h.status==="blocked")return"blocked";r="done"}const c=vr(l),f=vr(i);return f.blocked>c.blocked?"blocked":(!r&&f.done>c.done&&(r="done"),r)}const Rw={blocked:"%23f9e2af",done:"%23a6e3a1"};function Lw(l){return`<circle cx='19' cy='5' r='4.5' fill='${Rw[l]}' stroke='%2311111b' stroke-width='1.5'/>`}function _w(l,i){return!i||!l.includes("</svg>")?l:l.replace("</svg>",`${Lw(i)}</svg>`)}function mg(l,i=document){const s=i.querySelector('link[rel~="icon"]');if(!s)return;s.dataset.baseHref===void 0&&(s.dataset.baseHref=s.getAttribute("href")??"");const r=_w(s.dataset.baseHref,l);s.getAttribute("href")!==r&&s.setAttribute("href",r)}let gi=null;function jw(){if(typeof window>"u")return null;const l=window;return l.AudioContext??l.webkitAudioContext??null}function Hb(){const l=jw();if(l)try{gi=gi??new l,gi.state==="suspended"&&gi.resume()}catch{gi=null}}function Dw(l=window){const i=()=>{Hb(),s()},s=()=>{l.removeEventListener("pointerdown",i),l.removeEventListener("keydown",i)};return l.addEventListener("pointerdown",i),l.addEventListener("keydown",i),s}const Ow={blocked:[880,660],done:[660,880]};function Ub(l){if(!(!gi||gi.state!=="running"))try{const i=gi.currentTime;Ow[l].forEach((s,r)=>{const c=gi.createOscillator(),f=gi.createGain(),h=i+r*.11;c.type="sine",c.frequency.value=s,f.gain.setValueAtTime(1e-4,h),f.gain.exponentialRampToValueAtTime(.06,h+.01),f.gain.exponentialRampToValueAtTime(1e-4,h+.09),c.connect(f),f.connect(gi.destination),c.start(h),c.stop(h+.1)})}catch{}}const zw=15e3,Bw={blocked:[70,50,70],done:[40]};function Hw(){const{agentStatus:l,settings:i,t:s}=rt(),r=S.useRef(i);r.current=i;const c=S.useRef(s);c.current=s;const f=S.useRef(null),h=S.useRef(Number.NEGATIVE_INFINITY);S.useEffect(()=>{mg(i.agentAlertBadge?Ew(vr(l)):null)},[l,i.agentAlertBadge]),S.useEffect(()=>()=>mg(null),[]),S.useEffect(()=>{if(!(!i.agentAlertSound||typeof window>"u"))return Dw(window)},[i.agentAlertSound]),S.useEffect(()=>{const m=f.current;f.current=l;const b=kw(m,l);if(!b)return;const p=Date.now();if(p-h.current<zw)return;h.current=p;const y=r.current,v=typeof document<"u"&&document.visibilityState==="hidden",w=v||typeof document<"u"&&!document.hasFocus();if(y.agentAlertVibrate&&!v&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(Bw[b])}catch{}if(y.agentAlertSound&&w&&Ub(b),y.agentAlertNotify&&v&&typeof window<"u"&&window.isSecureContext&&"Notification"in window&&Notification.permission==="granted"){const T=vr(l),A=b==="blocked"?c.current("agents.notifyBlocked",{count:T.blocked}):c.current("agents.notifyDone",{count:T.done});try{new Notification("Herdr Remote",{body:A,tag:"herdr-agents"})}catch{}}},[l])}function Kb(l){var i,s,r="";if(typeof l=="string"||typeof l=="number")r+=l;else if(typeof l=="object")if(Array.isArray(l)){var c=l.length;for(i=0;i<c;i++)l[i]&&(s=Kb(l[i]))&&(r&&(r+=" "),r+=s)}else for(s in l)l[s]&&(r&&(r+=" "),r+=s);return r}function Uw(){for(var l,i,s=0,r="",c=arguments.length;s<c;s++)(l=arguments[s])&&(i=Kb(l))&&(r&&(r+=" "),r+=i);return r}const Kw=(l,i)=>{const s=new Array(l.length+i.length);for(let r=0;r<l.length;r++)s[r]=l[r];for(let r=0;r<i.length;r++)s[l.length+r]=i[r];return s},Iw=(l,i)=>({classGroupId:l,validator:i}),Ib=(l=new Map,i=null,s)=>({nextPart:l,validators:i,classGroupId:s}),Zo="-",pg=[],Fw="arbitrary..",Gw=l=>{const i=$w(l),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=l;return{getClassGroupId:h=>{if(h.startsWith("[")&&h.endsWith("]"))return Yw(h);const m=h.split(Zo),b=m[0]===""&&m.length>1?1:0;return Fb(m,b,i)},getConflictingClassGroupIds:(h,m)=>{if(m){const b=r[h],p=s[h];return b?p?Kw(p,b):b:p||pg}return s[h]||pg}}},Fb=(l,i,s)=>{if(l.length-i===0)return s.classGroupId;const c=l[i],f=s.nextPart.get(c);if(f){const p=Fb(l,i+1,f);if(p)return p}const h=s.validators;if(h===null)return;const m=i===0?l.join(Zo):l.slice(i).join(Zo),b=h.length;for(let p=0;p<b;p++){const y=h[p];if(y.validator(m))return y.classGroupId}},Yw=l=>l.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const i=l.slice(1,-1),s=i.indexOf(":"),r=i.slice(0,s);return r?Fw+r:void 0})(),$w=l=>{const{theme:i,classGroups:s}=l;return qw(s,i)},qw=(l,i)=>{const s=Ib();for(const r in l){const c=l[r];tf(c,s,r,i)}return s},tf=(l,i,s,r)=>{const c=l.length;for(let f=0;f<c;f++){const h=l[f];Vw(h,i,s,r)}},Vw=(l,i,s,r)=>{if(typeof l=="string"){Xw(l,i,s);return}if(typeof l=="function"){Pw(l,i,s,r);return}Zw(l,i,s,r)},Xw=(l,i,s)=>{const r=l===""?i:Gb(i,l);r.classGroupId=s},Pw=(l,i,s,r)=>{if(Qw(l)){tf(l(r),i,s,r);return}i.validators===null&&(i.validators=[]),i.validators.push(Iw(s,l))},Zw=(l,i,s,r)=>{const c=Object.entries(l),f=c.length;for(let h=0;h<f;h++){const[m,b]=c[h];tf(b,Gb(i,m),s,r)}},Gb=(l,i)=>{let s=l;const r=i.split(Zo),c=r.length;for(let f=0;f<c;f++){const h=r[f];let m=s.nextPart.get(h);m||(m=Ib(),s.nextPart.set(h,m)),s=m}return s},Qw=l=>"isThemeGetter"in l&&l.isThemeGetter===!0,Ww=l=>{if(l<1)return{get:()=>{},set:()=>{}};let i=0,s=Object.create(null),r=Object.create(null);const c=(f,h)=>{s[f]=h,i++,i>l&&(i=0,r=s,s=Object.create(null))};return{get(f){let h=s[f];if(h!==void 0)return h;if((h=r[f])!==void 0)return c(f,h),h},set(f,h){f in s?s[f]=h:c(f,h)}}},Hd="!",gg=":",Jw=[],bg=(l,i,s,r,c)=>({modifiers:l,hasImportantModifier:i,baseClassName:s,maybePostfixModifierPosition:r,isExternal:c}),e1=l=>{const{prefix:i,experimentalParseClassName:s}=l;let r=c=>{const f=[];let h=0,m=0,b=0,p;const y=c.length;for(let $=0;$<y;$++){const R=c[$];if(h===0&&m===0){if(R===gg){f.push(c.slice(b,$)),b=$+1;continue}if(R==="/"){p=$;continue}}R==="["?h++:R==="]"?h--:R==="("?m++:R===")"&&m--}const v=f.length===0?c:c.slice(b);let w=v,T=!1;v.endsWith(Hd)?(w=v.slice(0,-1),T=!0):v.startsWith(Hd)&&(w=v.slice(1),T=!0);const A=p&&p>b?p-b:void 0;return bg(f,T,w,A)};if(i){const c=i+gg,f=r;r=h=>h.startsWith(c)?f(h.slice(c.length)):bg(Jw,!1,h,void 0,!0)}if(s){const c=r;r=f=>s({className:f,parseClassName:c})}return r},t1=l=>{const i=new Map;return l.orderSensitiveModifiers.forEach((s,r)=>{i.set(s,1e6+r)}),s=>{const r=[];let c=[];for(let f=0;f<s.length;f++){const h=s[f],m=h[0]==="[",b=i.has(h);m||b?(c.length>0&&(c.sort(),r.push(...c),c=[]),r.push(h)):c.push(h)}return c.length>0&&(c.sort(),r.push(...c)),r}},n1=l=>({cache:Ww(l.cacheSize),parseClassName:e1(l),sortModifiers:t1(l),postfixLookupClassGroupIds:i1(l),...Gw(l)}),i1=l=>{const i=Object.create(null),s=l.postfixLookupClassGroups;if(s)for(let r=0;r<s.length;r++)i[s[r]]=!0;return i},l1=/\s+/,a1=(l,i)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:c,sortModifiers:f,postfixLookupClassGroupIds:h}=i,m=[],b=l.trim().split(l1);let p="";for(let y=b.length-1;y>=0;y-=1){const v=b[y],{isExternal:w,modifiers:T,hasImportantModifier:A,baseClassName:$,maybePostfixModifierPosition:R}=s(v);if(w){p=v+(p.length>0?" "+p:p);continue}let O=!!R,j;if(O){const K=$.substring(0,R);j=r(K);const q=j&&h[j]?r($):void 0;q&&q!==j&&(j=q,O=!1)}else j=r($);if(!j){if(!O){p=v+(p.length>0?" "+p:p);continue}if(j=r($),!j){p=v+(p.length>0?" "+p:p);continue}O=!1}const Y=T.length===0?"":T.length===1?T[0]:f(T).join(":"),se=A?Y+Hd:Y,fe=se+j;if(m.indexOf(fe)>-1)continue;m.push(fe);const Q=c(j,O);for(let K=0;K<Q.length;++K){const q=Q[K];m.push(se+q)}p=v+(p.length>0?" "+p:p)}return p},s1=(...l)=>{let i=0,s,r,c="";for(;i<l.length;)(s=l[i++])&&(r=Yb(s))&&(c&&(c+=" "),c+=r);return c},Yb=l=>{if(typeof l=="string")return l;let i,s="";for(let r=0;r<l.length;r++)l[r]&&(i=Yb(l[r]))&&(s&&(s+=" "),s+=i);return s},yg=(l,...i)=>{let s,r,c,f;const h=b=>{const p=i.reduce((y,v)=>v(y),l());return s=n1(p),r=s.cache.get,c=s.cache.set,f=m,m(b)},m=b=>{const p=r(b);if(p)return p;const y=a1(b,s);return c(b,y),y};return f=h,(...b)=>f(s1(...b))},r1=[],nn=l=>{const i=s=>s[l]||r1;return i.isThemeGetter=!0,i},$b=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,qb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,o1=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,c1=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,u1=/\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$/,d1=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,f1=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,h1=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jl=l=>o1.test(l),Ve=l=>!!l&&!Number.isNaN(Number(l)),Ni=l=>!!l&&Number.isInteger(Number(l)),md=l=>l.endsWith("%")&&Ve(l.slice(0,-1)),Qi=l=>c1.test(l),Vb=()=>!0,m1=l=>u1.test(l)&&!d1.test(l),nf=()=>!1,p1=l=>f1.test(l),g1=l=>h1.test(l),b1=l=>!we(l)&&!Ce(l),y1=l=>l.startsWith("@container")&&(l[10]==="/"&&l[11]!==void 0||l[11]==="s"&&l[16]!==void 0&&l.startsWith("-size/",10)||l[11]==="n"&&l[18]!==void 0&&l.startsWith("-normal/",10)),v1=l=>Il(l,Zb,nf),we=l=>$b.test(l),ca=l=>Il(l,Qb,m1),vg=l=>Il(l,E1,Ve),x1=l=>Il(l,Jb,Vb),w1=l=>Il(l,Wb,nf),xg=l=>Il(l,Xb,nf),S1=l=>Il(l,Pb,g1),No=l=>Il(l,ey,p1),Ce=l=>qb.test(l),sr=l=>pa(l,Qb),C1=l=>pa(l,Wb),wg=l=>pa(l,Xb),T1=l=>pa(l,Zb),M1=l=>pa(l,Pb),ko=l=>pa(l,ey,!0),A1=l=>pa(l,Jb,!0),Il=(l,i,s)=>{const r=$b.exec(l);return r?r[1]?i(r[1]):s(r[2]):!1},pa=(l,i,s=!1)=>{const r=qb.exec(l);return r?r[1]?i(r[1]):s:!1},Xb=l=>l==="position"||l==="percentage",Pb=l=>l==="image"||l==="url",Zb=l=>l==="length"||l==="size"||l==="bg-size",Qb=l=>l==="length",E1=l=>l==="number",Wb=l=>l==="family-name",Jb=l=>l==="number"||l==="weight",ey=l=>l==="shadow",Sg=()=>{const l=nn("color"),i=nn("font"),s=nn("text"),r=nn("font-weight"),c=nn("tracking"),f=nn("leading"),h=nn("breakpoint"),m=nn("container"),b=nn("spacing"),p=nn("radius"),y=nn("shadow"),v=nn("inset-shadow"),w=nn("text-shadow"),T=nn("drop-shadow"),A=nn("blur"),$=nn("perspective"),R=nn("aspect"),O=nn("ease"),j=nn("animate"),Y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],se=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],fe=()=>[...se(),Ce,we],Q=()=>["auto","hidden","clip","visible","scroll"],K=()=>["auto","contain","none"],q=()=>[Ce,we,b],ue=()=>[jl,"full","auto",...q()],ye=()=>[Ni,"none","subgrid",Ce,we],Ne=()=>["auto",{span:["full",Ni,Ce,we]},Ni,Ce,we],ie=()=>[Ni,"auto",Ce,we],he=()=>["auto","min","max","fr",Ce,we],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],pe=()=>["start","end","center","stretch","center-safe","end-safe"],k=()=>["auto",...q()],I=()=>[jl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...q()],le=()=>[jl,"screen","full","dvw","lvw","svw","min","max","fit",...q()],re=()=>[jl,"screen","full","lh","dvh","lvh","svh","min","max","fit",...q()],V=()=>[l,Ce,we],Re=()=>[...se(),wg,xg,{position:[Ce,we]}],Ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],xe=()=>["auto","cover","contain",T1,v1,{size:[Ce,we]}],Se=()=>[md,sr,ca],Le=()=>["","none","full",p,Ce,we],Be=()=>["",Ve,sr,ca],ot=()=>["solid","dashed","dotted","double"],Xe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ze=()=>[Ve,md,wg,xg],yt=()=>["","none",A,Ce,we],Tt=()=>["none",Ve,Ce,we],Ue=()=>["none",Ve,Ce,we],G=()=>[Ve,Ce,we],me=()=>[jl,"full",...q()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qi],breakpoint:[Qi],color:[Vb],container:[Qi],"drop-shadow":[Qi],ease:["in","out","in-out"],font:[b1],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qi],shadow:[Qi],spacing:["px",Ve],text:[Qi],"text-shadow":[Qi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",jl,we,Ce,R]}],container:["container"],"container-type":[{"@container":["","normal","size",Ce,we]}],"container-named":[y1],columns:[{columns:[Ve,we,Ce,m]}],"break-after":[{"break-after":Y()}],"break-before":[{"break-before":Y()}],"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:fe()}],overflow:[{overflow:Q()}],"overflow-x":[{"overflow-x":Q()}],"overflow-y":[{"overflow-y":Q()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:ue()}],"inset-x":[{"inset-x":ue()}],"inset-y":[{"inset-y":ue()}],start:[{"inset-s":ue(),start:ue()}],end:[{"inset-e":ue(),end:ue()}],"inset-bs":[{"inset-bs":ue()}],"inset-be":[{"inset-be":ue()}],top:[{top:ue()}],right:[{right:ue()}],bottom:[{bottom:ue()}],left:[{left:ue()}],visibility:["visible","invisible","collapse"],z:[{z:[Ni,"auto",Ce,we]}],basis:[{basis:[jl,"full","auto",m,...q()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ve,jl,"auto","initial","none",we]}],grow:[{grow:["",Ve,Ce,we]}],shrink:[{shrink:["",Ve,Ce,we]}],order:[{order:[Ni,"first","last","none",Ce,we]}],"grid-cols":[{"grid-cols":ye()}],"col-start-end":[{col:Ne()}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":ye()}],"row-start-end":[{row:Ne()}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":he()}],"auto-rows":[{"auto-rows":he()}],gap:[{gap:q()}],"gap-x":[{"gap-x":q()}],"gap-y":[{"gap-y":q()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...pe(),"normal"]}],"justify-self":[{"justify-self":["auto",...pe()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...pe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...pe(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...pe(),"baseline"]}],"place-self":[{"place-self":["auto",...pe()]}],p:[{p:q()}],px:[{px:q()}],py:[{py:q()}],ps:[{ps:q()}],pe:[{pe:q()}],pbs:[{pbs:q()}],pbe:[{pbe:q()}],pt:[{pt:q()}],pr:[{pr:q()}],pb:[{pb:q()}],pl:[{pl:q()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":q()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":q()}],"space-y-reverse":["space-y-reverse"],size:[{size:I()}],"inline-size":[{inline:["auto",...le()]}],"min-inline-size":[{"min-inline":["auto",...le()]}],"max-inline-size":[{"max-inline":["none",...le()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[m,"screen",...I()]}],"min-w":[{"min-w":[m,"screen","none",...I()]}],"max-w":[{"max-w":[m,"screen","none","prose",{screen:[h]},...I()]}],h:[{h:["screen","lh",...I()]}],"min-h":[{"min-h":["screen","lh","none",...I()]}],"max-h":[{"max-h":["screen","lh",...I()]}],"font-size":[{text:["base",s,sr,ca]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,A1,x1]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",md,we]}],"font-family":[{font:[C1,w1,i]}],"font-features":[{"font-features":[we]}],"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:[c,Ce,we]}],"line-clamp":[{"line-clamp":[Ve,"none",Ce,vg]}],leading:[{leading:[f,...q()]}],"list-image":[{"list-image":["none",Ce,we]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ce,we]}],"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:[...ot(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ve,"from-font","auto",Ce,ca]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Ve,"auto",Ce,we]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:q()}],"tab-size":[{tab:[Ni,Ce,we]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ce,we]}],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,we]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Re()}],"bg-repeat":[{bg:Ae()}],"bg-size":[{bg:xe()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ni,Ce,we],radial:["",Ce,we],conic:[Ni,Ce,we]},M1,S1]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:Se()}],"gradient-via-pos":[{via:Se()}],"gradient-to-pos":[{to:Se()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:Le()}],"rounded-s":[{"rounded-s":Le()}],"rounded-e":[{"rounded-e":Le()}],"rounded-t":[{"rounded-t":Le()}],"rounded-r":[{"rounded-r":Le()}],"rounded-b":[{"rounded-b":Le()}],"rounded-l":[{"rounded-l":Le()}],"rounded-ss":[{"rounded-ss":Le()}],"rounded-se":[{"rounded-se":Le()}],"rounded-ee":[{"rounded-ee":Le()}],"rounded-es":[{"rounded-es":Le()}],"rounded-tl":[{"rounded-tl":Le()}],"rounded-tr":[{"rounded-tr":Le()}],"rounded-br":[{"rounded-br":Le()}],"rounded-bl":[{"rounded-bl":Le()}],"border-w":[{border:Be()}],"border-w-x":[{"border-x":Be()}],"border-w-y":[{"border-y":Be()}],"border-w-s":[{"border-s":Be()}],"border-w-e":[{"border-e":Be()}],"border-w-bs":[{"border-bs":Be()}],"border-w-be":[{"border-be":Be()}],"border-w-t":[{"border-t":Be()}],"border-w-r":[{"border-r":Be()}],"border-w-b":[{"border-b":Be()}],"border-w-l":[{"border-l":Be()}],"divide-x":[{"divide-x":Be()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Be()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ot(),"hidden","none"]}],"divide-style":[{divide:[...ot(),"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:[...ot(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ve,Ce,we]}],"outline-w":[{outline:["",Ve,sr,ca]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",y,ko,No]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",v,ko,No]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:Be()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Ve,ca]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":Be()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",w,ko,No]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Ve,Ce,we]}],"mix-blend":[{"mix-blend":[...Xe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Xe()}],"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":[Ve]}],"mask-image-linear-from-pos":[{"mask-linear-from":ze()}],"mask-image-linear-to-pos":[{"mask-linear-to":ze()}],"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":ze()}],"mask-image-t-to-pos":[{"mask-t-to":ze()}],"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":ze()}],"mask-image-r-to-pos":[{"mask-r-to":ze()}],"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":ze()}],"mask-image-b-to-pos":[{"mask-b-to":ze()}],"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":ze()}],"mask-image-l-to-pos":[{"mask-l-to":ze()}],"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":ze()}],"mask-image-x-to-pos":[{"mask-x-to":ze()}],"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":ze()}],"mask-image-y-to-pos":[{"mask-y-to":ze()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Ce,we]}],"mask-image-radial-from-pos":[{"mask-radial-from":ze()}],"mask-image-radial-to-pos":[{"mask-radial-to":ze()}],"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":se()}],"mask-image-conic-pos":[{"mask-conic":[Ve]}],"mask-image-conic-from-pos":[{"mask-conic-from":ze()}],"mask-image-conic-to-pos":[{"mask-conic-to":ze()}],"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:Re()}],"mask-repeat":[{mask:Ae()}],"mask-size":[{mask:xe()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ce,we]}],filter:[{filter:["","none",Ce,we]}],blur:[{blur:yt()}],brightness:[{brightness:[Ve,Ce,we]}],contrast:[{contrast:[Ve,Ce,we]}],"drop-shadow":[{"drop-shadow":["","none",T,ko,No]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Ve,Ce,we]}],"hue-rotate":[{"hue-rotate":[Ve,Ce,we]}],invert:[{invert:["",Ve,Ce,we]}],saturate:[{saturate:[Ve,Ce,we]}],sepia:[{sepia:["",Ve,Ce,we]}],"backdrop-filter":[{"backdrop-filter":["","none",Ce,we]}],"backdrop-blur":[{"backdrop-blur":yt()}],"backdrop-brightness":[{"backdrop-brightness":[Ve,Ce,we]}],"backdrop-contrast":[{"backdrop-contrast":[Ve,Ce,we]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ve,Ce,we]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ve,Ce,we]}],"backdrop-invert":[{"backdrop-invert":["",Ve,Ce,we]}],"backdrop-opacity":[{"backdrop-opacity":[Ve,Ce,we]}],"backdrop-saturate":[{"backdrop-saturate":[Ve,Ce,we]}],"backdrop-sepia":[{"backdrop-sepia":["",Ve,Ce,we]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":q()}],"border-spacing-x":[{"border-spacing-x":q()}],"border-spacing-y":[{"border-spacing-y":q()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ce,we]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ve,"initial",Ce,we]}],ease:[{ease:["linear","initial",O,Ce,we]}],delay:[{delay:[Ve,Ce,we]}],animate:[{animate:["none",j,Ce,we]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[$,Ce,we]}],"perspective-origin":[{"perspective-origin":fe()}],rotate:[{rotate:Tt()}],"rotate-x":[{"rotate-x":Tt()}],"rotate-y":[{"rotate-y":Tt()}],"rotate-z":[{"rotate-z":Tt()}],scale:[{scale:Ue()}],"scale-x":[{"scale-x":Ue()}],"scale-y":[{"scale-y":Ue()}],"scale-z":[{"scale-z":Ue()}],"scale-3d":["scale-3d"],skew:[{skew:G()}],"skew-x":[{"skew-x":G()}],"skew-y":[{"skew-y":G()}],transform:[{transform:[Ce,we,"","none","gpu","cpu"]}],"transform-origin":[{origin:fe()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:me()}],"translate-x":[{"translate-x":me()}],"translate-y":[{"translate-y":me()}],"translate-z":[{"translate-z":me()}],"translate-none":["translate-none"],zoom:[{zoom:[Ni,Ce,we]}],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,we]}],"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":q()}],"scroll-mx":[{"scroll-mx":q()}],"scroll-my":[{"scroll-my":q()}],"scroll-ms":[{"scroll-ms":q()}],"scroll-me":[{"scroll-me":q()}],"scroll-mbs":[{"scroll-mbs":q()}],"scroll-mbe":[{"scroll-mbe":q()}],"scroll-mt":[{"scroll-mt":q()}],"scroll-mr":[{"scroll-mr":q()}],"scroll-mb":[{"scroll-mb":q()}],"scroll-ml":[{"scroll-ml":q()}],"scroll-p":[{"scroll-p":q()}],"scroll-px":[{"scroll-px":q()}],"scroll-py":[{"scroll-py":q()}],"scroll-ps":[{"scroll-ps":q()}],"scroll-pe":[{"scroll-pe":q()}],"scroll-pbs":[{"scroll-pbs":q()}],"scroll-pbe":[{"scroll-pbe":q()}],"scroll-pt":[{"scroll-pt":q()}],"scroll-pr":[{"scroll-pr":q()}],"scroll-pb":[{"scroll-pb":q()}],"scroll-pl":[{"scroll-pl":q()}],"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,we]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Ve,sr,ca,vg]}],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"]}},N1=(l,{cacheSize:i,prefix:s,experimentalParseClassName:r,extend:c={},override:f={}})=>(is(l,"cacheSize",i),is(l,"prefix",s),is(l,"experimentalParseClassName",r),Ro(l.theme,f.theme),Ro(l.classGroups,f.classGroups),Ro(l.conflictingClassGroups,f.conflictingClassGroups),Ro(l.conflictingClassGroupModifiers,f.conflictingClassGroupModifiers),is(l,"postfixLookupClassGroups",f.postfixLookupClassGroups),is(l,"orderSensitiveModifiers",f.orderSensitiveModifiers),Lo(l.theme,c.theme),Lo(l.classGroups,c.classGroups),Lo(l.conflictingClassGroups,c.conflictingClassGroups),Lo(l.conflictingClassGroupModifiers,c.conflictingClassGroupModifiers),Ud(l,c,"postfixLookupClassGroups"),Ud(l,c,"orderSensitiveModifiers"),l),is=(l,i,s)=>{s!==void 0&&(l[i]=s)},Ro=(l,i)=>{if(i)for(const s in i)is(l,s,i[s])},Lo=(l,i)=>{if(i)for(const s in i)Ud(l,i,s)},Ud=(l,i,s)=>{const r=i[s];r!==void 0&&(l[s]=l[s]?l[s].concat(r):r)},k1=(l,...i)=>typeof l=="function"?yg(Sg,l,...i):yg(()=>N1(Sg(),l),...i),R1=k1({extend:{classGroups:{"font-size":[{text:["tui","tui-sm","tui-lg"]}]}}});function ne(...l){return R1(Uw(l))}var L1=sb();const Fe={cursor:"▸",on:"●",off:"○",dot:"·",check:"✓",cross:"✗",warn:"!",arrowRight:"→",arrowLeft:"←",chevronDown:"▾",chevronRight:"▸",ellipsis:"…",meterFull:"█",meterEmpty:"░",tabDivider:"│"},li={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"}},ms={ok:li.ok.text,warn:li.warn.text,bad:li.bad.text,idle:li.idle.text,accent:li.accent.text,alt:li.alt.text,info:li.info.text},_n=({level:l,className:i})=>d.jsx("span",{"aria-hidden":"true",className:ne("select-none leading-none",ms[l],i),children:l==="idle"?Fe.off:Fe.on}),lf=({className:l})=>d.jsx("span",{"aria-hidden":"true",className:ne("select-none text-tui-faint",l),children:Fe.dot}),gn=({title:l,aside:i,tone:s="accent",className:r,bodyClassName:c,children:f,...h})=>d.jsxs("fieldset",{className:ne("tui-panel tui-block relative min-w-0 border border-tui-border bg-tui-base",l?"px-3 pb-3 pt-1":"p-3",r),...h,children:[l?d.jsx("legend",{className:ne("flex items-center gap-2 text-tui font-bold",ms[s]),children:d.jsx("span",{children:l})}):null,i?d.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:i}):null,d.jsx("div",{className:ne("min-w-0",c),children:f})]}),Ul=({label:l,labelWidth:i=16,className:s,children:r})=>d.jsxs("div",{className:ne("flex items-baseline gap-2 text-tui",s),children:[d.jsx("span",{className:"shrink-0 truncate text-tui-muted",style:{width:`${i}ch`},title:typeof l=="string"?l:void 0,children:l}),d.jsx("span",{className:"min-w-0 flex-1 text-tui-text",children:r})]}),_1=({className:l,label:i})=>i?d.jsxs("div",{className:ne("flex items-center gap-2",l),children:[d.jsx("span",{className:"h-px w-3 bg-tui-border-dim","aria-hidden":"true"}),d.jsx("span",{className:"text-tui-sm text-tui-faint",children:i}),d.jsx("span",{className:"h-px flex-1 bg-tui-border-dim","aria-hidden":"true"})]}):d.jsx("div",{className:ne("h-px w-full bg-tui-border-dim",l),"aria-hidden":"true"}),j1={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 disabled:border-transparent"},Oe=({variant:l="default",brackets:i=!0,glyph:s,block:r=!1,className:c,children:f,type:h="button",...m})=>d.jsxs("button",{type:h,className:ne("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",j1[l],r&&"w-full",c),...m,children:[i?d.jsx("span",{"aria-hidden":"true",className:"opacity-60",children:"["}):null,s?d.jsx("span",{"aria-hidden":"true",className:"leading-none",children:s}):null,d.jsx("span",{className:"truncate",children:f}),i?d.jsx("span",{"aria-hidden":"true",className:"opacity-60",children:"]"}):null]}),af=({tone:l="accent",dot:i=!1,className:s,children:r})=>d.jsxs("span",{className:ne("inline-flex select-none items-center gap-1 whitespace-nowrap text-tui font-bold uppercase",ms[l],s),children:[i?d.jsx(_n,{level:l}):null,r]}),sf=({tabs:l,activeId:i,onSelect:s,ariaLabel:r,className:c,labelClassName:f})=>d.jsx("nav",{className:ne("flex items-center gap-2",c),"aria-label":r,children:l.map((h,m)=>{const b=h.id===i;return d.jsxs(Li.Fragment,{children:[m>0?d.jsx("span",{"aria-hidden":"true",className:"select-none text-tui-border",children:Fe.tabDivider}):null,d.jsxs("button",{type:"button",onClick:()=>s(h.id),"aria-current":b?"page":void 0,"aria-label":h.ariaLabel??h.label,title:h.title,className:ne("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:[h.index!==void 0?d.jsx("span",{"aria-hidden":"true",className:ne("text-tui-faint",b&&"text-tui-accent"),children:h.index}):null,d.jsx("span",{"aria-hidden":"true",className:ne("ml-1",f),children:h.label})]})]},h.id)})}),ty=({hints:l,className:i})=>d.jsx("div",{className:ne("flex flex-wrap items-center gap-x-3 gap-y-0.5 text-tui-sm text-tui-faint",i),children:l.map((s,r)=>d.jsxs("span",{className:"flex items-center gap-1",children:[d.jsx("kbd",{className:"border border-tui-border-dim px-1 not-italic text-tui-muted",children:s.keys}),d.jsx("span",{children:s.action})]},`${s.keys}-${r}`))}),Ji=({htmlFor:l,hint:i,className:s,children:r})=>d.jsxs("label",{htmlFor:l,className:ne("block text-tui-sm font-bold text-tui-muted",s),children:[r,i?d.jsx("span",{className:"ml-2 font-normal text-tui-faint",children:i}):null]}),Sn=Li.forwardRef(({className:l,...i},s)=>d.jsx("input",{ref:s,className:ne("tui-input w-full px-2 py-1 text-tui",l),...i}));Sn.displayName="Input";const Qo=Li.forwardRef(({className:l,children:i,...s},r)=>d.jsx("select",{ref:r,className:ne("tui-input w-full px-2 py-1 text-tui",l),...s,children:i}));Qo.displayName="Select";const D1=({checked:l,onChange:i,disabled:s=!1,label:r,description:c,className:f,id:h})=>d.jsxs("label",{className:ne("group flex cursor-pointer select-none items-start gap-2 py-0.5 text-tui",s&&"cursor-not-allowed opacity-60",f),children:[d.jsx("input",{id:h,type:"checkbox",className:"sr-only",checked:l,disabled:s,onChange:m=>i(m.target.checked)}),d.jsx("span",{"aria-hidden":"true",className:ne("mt-px shrink-0 font-bold leading-tight",l?"text-tui-ok":"text-tui-faint",!s&&"group-hover:text-tui-accent"),children:l?"[x]":"[ ]"}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:ne("block",l?"text-tui-text":"text-tui-muted"),children:r}),c?d.jsx("span",{className:"mt-0.5 block text-tui-sm leading-snug text-tui-faint",children:c}):null]})]}),ec="h-8",pi=({title:l,aside:i,className:s,children:r})=>d.jsxs("section",{className:ne("min-w-0",s),children:[d.jsxs("div",{className:"flex min-h-[var(--tui-row)] items-center gap-2 border-b border-tui-border pb-1",children:[d.jsx("h3",{className:"text-tui font-bold text-tui-accent",children:l}),i?d.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:i}):null]}),d.jsx("div",{className:"divide-y divide-tui-border-dim",children:r})]}),Ln=({label:l,hint:i,htmlFor:s,control:r,className:c})=>d.jsxs("div",{className:ne("flex flex-col gap-1 py-1.5 sm:flex-row sm:items-center sm:gap-4",c),children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[s?d.jsx("label",{htmlFor:s,className:"block text-tui text-tui-text",children:l}):d.jsx("span",{className:"block text-tui text-tui-text",children:l}),i?d.jsx("span",{className:"block text-tui-sm leading-snug text-tui-faint",children:i}):null]}),d.jsx("div",{className:"w-full shrink-0 sm:w-[18rem]",children:r})]}),Kd="flex min-w-0 cursor-pointer select-none items-center justify-center px-1 text-tui transition-colors has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:-outline-offset-2 has-[:focus-visible]:outline-tui-text",Id="text-tui-muted hover:bg-tui-selection hover:text-tui-text";function Cg({name:l,value:i,options:s,onChange:r,tone:c="accent",className:f,"aria-label":h}){return d.jsx("div",{role:"radiogroup","aria-label":h,className:ne("grid w-full border border-tui-border bg-tui-mantle",ec,f),style:{gridTemplateColumns:`repeat(${s.length}, minmax(0, 1fr))`},children:s.map((m,b)=>{const p=m.value===i;return d.jsxs("label",{className:ne(Kd,b>0&&"border-l border-tui-border",p?ne(ny[c],"font-bold text-tui-crust"):Id),children:[d.jsx("input",{type:"radio",name:l,value:m.value,className:"sr-only",checked:p,onChange:()=>r(m.value)}),d.jsx("span",{className:"truncate",children:m.label})]},m.value)})})}const Dl=({checked:l,onChange:i,label:s,offLabel:r,onLabel:c,disabled:f=!1,className:h})=>{const m=b=>p=>{p.preventDefault(),!(f||b===l)&&i(b)};return d.jsxs("label",{className:ne("grid w-full grid-cols-2 border border-tui-border bg-tui-mantle has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-tui-accent",ec,f&&"cursor-not-allowed opacity-60",h),children:[d.jsx("input",{type:"checkbox",className:"sr-only","aria-label":s,checked:l,disabled:f,onChange:b=>i(b.target.checked)}),d.jsx("span",{"aria-hidden":"true",onClick:m(!1),className:ne(Kd,l?Id:"bg-tui-selection font-bold text-tui-text"),children:r}),d.jsx("span",{"aria-hidden":"true",onClick:m(!0),className:ne(Kd,"border-l border-tui-border",l?"bg-tui-ok font-bold text-tui-crust":Id),children:c})]})},ua=({variant:l="neutral",className:i,type:s="button",children:r,...c})=>d.jsx("button",{type:s,className:ne("tui-focusable inline-flex h-7 w-7 shrink-0 select-none items-center justify-center border border-transparent text-tui transition-colors","disabled:cursor-not-allowed disabled:text-tui-border disabled:hover:border-transparent disabled:hover:bg-transparent",l==="danger"?"text-tui-bad hover:border-tui-bad":"text-tui-muted hover:border-tui-border hover:text-tui-accent",i),...c,children:r}),O1=({value:l,width:i=20,tone:s="accent",className:r})=>{const c=Number.isFinite(l)?Math.min(1,Math.max(0,l)):0,f=Math.round(c*i);return d.jsxs("span",{className:ne("inline-flex select-none whitespace-pre font-mono leading-none",r),role:"presentation",children:[d.jsx("span",{className:ms[s],children:Fe.meterFull.repeat(f)}),d.jsx("span",{className:"text-tui-border",children:Fe.meterEmpty.repeat(Math.max(0,i-f))})]})},ny={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"},z1=({ratio:l,label:i,tone:s="accent",className:r,...c})=>{const f=Number.isFinite(l)?Math.min(1,Math.max(0,l)):0;return d.jsxs("div",{className:ne("relative h-[var(--tui-row)] w-full overflow-hidden border border-tui-border bg-tui-mantle",r),role:"progressbar","aria-valuenow":Math.round(f*100),"aria-valuemin":0,"aria-valuemax":100,...c,children:[d.jsx("div",{className:ne("absolute inset-y-0 left-0",ny[s]),style:{width:`${f*100}%`},"aria-hidden":"true"}),i!==void 0?d.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:i}):null]})},es=({label:l,value:i,sub:s,tone:r,title:c,className:f})=>d.jsxs("div",{className:ne("min-w-0 border border-tui-border bg-tui-base px-2.5 py-1.5",f),title:c,children:[d.jsx("div",{className:"truncate text-tui-sm text-tui-muted",children:l}),d.jsx("div",{className:ne("truncate text-tui-lg font-bold",r?ms[r]:"text-tui-text"),children:i}),d.jsx("div",{className:"truncate text-tui-sm text-tui-faint",children:s||" "})]});function rf({columns:l,items:i,rowKey:s,empty:r,className:c}){return i.length===0?d.jsx("div",{className:ne("px-1 py-4 text-center text-tui text-tui-faint",c),children:r}):d.jsx("div",{className:ne("w-full overflow-x-auto",c),children:d.jsxs("table",{className:"w-full border-collapse text-tui",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-tui-border",children:l.map(f=>d.jsx("th",{scope:"col",style:f.width?{width:`${f.width}ch`}:void 0,className:ne("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))})}),d.jsx("tbody",{children:i.map((f,h)=>d.jsx("tr",{className:"border-b border-tui-border-dim last:border-b-0 hover:bg-tui-selection",children:l.map(m=>d.jsx("td",{className:ne("px-2 py-1 align-top text-tui-text",m.align==="right"?"text-right":"text-left",m.className),children:m.render(f,h)},m.key))},s(f,h)))})]})})}const tc=({isOpen:l,onClose:i,title:s,subtitle:r,closeLabel:c,footer:f,hints:h,size:m="md",fixedHeight:b=!1,className:p,children:y})=>{if(!l)return null;const v=m==="sm"?"max-w-md":m==="lg"?"max-w-3xl":"max-w-xl",w=`tui-modal-${s.replace(/\s+/g,"-").toLowerCase()}`,T=d.jsx("div",{className:"fixed inset-0 inset-x-0 z-50 flex items-center justify-center overflow-hidden bg-tui-crust/85 p-3 sm:p-6",style:{height:"var(--app-height, 100dvh)",width:"100vw"},role:"dialog","aria-modal":"true","aria-labelledby":w,onMouseDown:A=>{A.target===A.currentTarget&&i()},children:d.jsxs("div",{className:ne("relative flex max-h-full w-full flex-col border border-tui-border bg-tui-base",v,b&&"h-[46rem]",p),children:[d.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-tui-border bg-tui-mantle px-3 py-1.5",children:[d.jsx("h2",{id:w,className:"truncate text-tui font-bold text-tui-accent",children:s}),r?d.jsx("span",{className:"min-w-0 flex-1 truncate text-tui-sm text-tui-faint",children:r}):d.jsx("span",{className:"flex-1"}),d.jsx(Oe,{variant:"ghost",onClick:i,"aria-label":c,title:c,children:"esc"})]}),d.jsx("div",{className:"relative min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3",children:y}),f||h?d.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:[h?d.jsx(ty,{hints:h}):d.jsx("span",{}),f?d.jsx("div",{className:"flex items-center gap-2",children:f}):null]}):null]})});return typeof document>"u"?T:L1.createPortal(T,document.body)},Bl=({tone:l="accent",className:i,children:s,action:r})=>{const c=l==="ok"?Fe.check:l==="bad"?Fe.cross:l==="warn"?Fe.warn:"›",f=li[l].edgeL;return d.jsxs("div",{className:ne("flex items-start gap-2 border border-tui-border-dim border-l-2 bg-tui-mantle px-2 py-1.5 text-tui",f,i),children:[d.jsx("span",{"aria-hidden":"true",className:ne("shrink-0 font-bold",ms[l]),children:c}),d.jsx("div",{className:"min-w-0 flex-1 leading-snug text-tui-text",children:s}),r?d.jsx("div",{className:"shrink-0",children:r}):null]})},Tg=({active:l=!1,className:i,children:s})=>d.jsx("span",{className:ne("inline-flex min-w-[2ch] select-none items-center justify-center border px-1 text-tui",l?"border-tui-accent bg-tui-accent text-tui-crust":"border-tui-border bg-tui-surface text-tui-muted",i),children:s}),Fd=({items:l,className:i})=>{const s=l.filter(Boolean);return d.jsx("span",{className:ne("flex min-w-0 items-center gap-1.5",i),children:s.map((r,c)=>d.jsxs(Li.Fragment,{children:[c>0?d.jsx(lf,{className:"shrink-0"}):null,r]},c))})},iy=({left:l,right:i,className:s})=>d.jsxs("footer",{className:ne("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",s),children:[d.jsx("div",{className:"flex min-w-0 items-center gap-1.5 text-tui-muted",children:l}),d.jsx("div",{className:"flex shrink-0 items-center gap-3",children:i})]}),B1=({name:l,tagline:i,aside:s,tabs:r,activeTabId:c,onSelectTab:f,tabsAriaLabel:h,toolbarStart:m,toolbarAside:b,hints:p,footerAside:y,bodyClassName:v,className:w,children:T})=>{const A=!!(r&&r.length>0&&c!==void 0&&f);return d.jsxs("div",{className:ne("flex h-full min-h-0 w-full flex-col bg-tui-crust",w),children:[l?d.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:[d.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[d.jsx("span",{className:"shrink-0 font-bold text-tui-accent",children:l}),i?d.jsx("span",{className:"hidden truncate text-tui-sm text-tui-faint sm:block",children:i}):null]}),s?d.jsx("span",{className:"flex shrink-0 items-center gap-2",children:s}):null]}):null,A||m||b?d.jsxs("div",{className:"flex min-h-[var(--tui-row)] shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-tui-border bg-tui-mantle px-2 py-1",children:[m?d.jsx("div",{className:"flex shrink-0 items-center",children:m}):null,A?d.jsx("div",{className:"scrollbar-none order-last min-w-0 basis-full overflow-x-auto sm:order-none sm:basis-auto",children:d.jsx(sf,{tabs:r,activeId:c,onSelect:f,ariaLabel:h,className:"gap-3"})}):null,b?d.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:b}):null]}):null,d.jsx("div",{className:ne("min-h-0 flex-1 overflow-y-auto p-2",v),children:T}),p||y?d.jsx(iy,{left:p?d.jsx(ty,{hints:p}):null,right:y}):null]})},Mg=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ma=({className:l,label:i})=>{const[s,r]=Li.useState(0);return Li.useEffect(()=>{const c=setInterval(()=>r(f=>(f+1)%Mg.length),90);return()=>clearInterval(c)},[]),d.jsxs("span",{className:ne("inline-flex items-center gap-1.5",l),role:"status",children:[d.jsx("span",{"aria-hidden":"true",className:"text-tui-accent",children:Mg[s]}),i?d.jsx("span",{children:i}):null]})},_o="tui-focusable select-none border border-transparent px-1.5 text-tui uppercase transition-colors",jo="text-tui-muted hover:border-tui-border hover:text-tui-accent",H1="border-tui-accent bg-tui-accent text-tui-crust",U1=({currentView:l,onNavigate:i,onOpenPairing:s,onOpenSettings:r,onToggleVirtualKeyboard:c,isVirtualKeyboardOpen:f})=>{const{addToast:h,language:m,setLanguage:b,t:p}=rt(),y=()=>{const w=m==="zh"?"en":"zh";b(w),h("info",Jd(w,"toasts.switchedLanguage",{lang:w==="zh"?"简体中文":"English"}))},v=[{id:"terminal",label:p("header.terminalTab"),index:1,ariaLabel:p("header.terminalTab")},...l==="admin"?[{id:"admin",label:p("header.adminTab"),index:2,ariaLabel:p("header.adminTab")}]:[]];return d.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:d.jsxs("div",{className:"scrollbar-none flex min-h-[var(--tui-row)] items-center gap-2 overflow-x-auto text-tui",children:[d.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[d.jsx("span",{className:"font-bold text-tui-accent",children:"herdr-remote"}),d.jsx("span",{className:"hidden text-tui-sm text-tui-faint sm:inline",children:p("header.tagline")})]}),d.jsx("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-tui-border"}),d.jsx(sf,{tabs:v,activeId:l,onSelect:w=>i(w),ariaLabel:p("header.mainNavigationAria"),className:"shrink-0 gap-3"}),d.jsx("span",{"aria-hidden":"true",className:"h-4 w-px shrink-0 bg-tui-border"}),d.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[d.jsx("button",{type:"button",onClick:y,className:ne(_o,jo),title:p("header.languageToggleTitle"),"aria-label":p("header.languageToggleTitle"),children:p("header.languageShort")}),l==="terminal"&&d.jsx("button",{type:"button",onClick:c,className:ne(_o,f?H1:jo),title:p("header.virtualKeyboardTitle"),"aria-label":p("header.virtualKeyboardTitle"),children:p("header.actionKeyboard")}),d.jsx("button",{type:"button",onClick:s,className:ne(_o,jo),title:p("header.pairingTitle"),"aria-label":p("header.pairingTitle"),children:p("header.actionPairing")}),d.jsx("button",{type:"button",onClick:r,className:ne(_o,jo),title:p("header.settingsTitle"),"aria-label":p("header.settingsTitle"),children:p("header.actionSettings")})]})]})})},Do=({tone:l,glyph:i,message:s,assertive:r=!1,action:c})=>d.jsxs("aside",{className:ne("flex w-full items-center justify-between gap-3 border-b bg-tui-mantle px-2 py-0.5 text-tui sm:px-3",li[l].edgeB),"aria-live":r?"assertive":"polite",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[d.jsx("span",{"aria-hidden":"true",className:ne("shrink-0",li[l].text),children:i}),d.jsx("span",{className:"truncate text-tui-text",children:s})]}),c]}),K1=()=>{const{connectionState:l,stateDetail:i,connect:s,settings:r,t:c}=rt();return l==="connected"||!r.token&&!r.pairCode&&l==="disconnected"?null:l==="connecting"?d.jsx(Do,{tone:"accent",glyph:d.jsx(ma,{}),message:c("statusBanner.connecting")}):l==="reconnecting"?d.jsx(Do,{tone:"warn",glyph:d.jsx(ma,{}),assertive:!0,message:i||c("statusBanner.reconnectingDefault"),action:d.jsx(Oe,{variant:"warn",onClick:()=>s(),className:"shrink-0",children:c("statusBanner.reconnectNow")})}):l==="error"?d.jsx(Do,{tone:"bad",glyph:Fe.cross,assertive:!0,message:i||c("statusBanner.errorDefault"),action:d.jsx(Oe,{variant:"danger",onClick:()=>s(),className:"shrink-0",children:c("common.retry")})}):l==="disconnected"?d.jsx(Do,{tone:"idle",glyph:Fe.off,message:c("statusBanner.disconnected"),action:d.jsx(Oe,{variant:"primary",onClick:()=>s(),className:"shrink-0",children:c("common.connect")})}):null};var I1=Bv(),F1=Hv(),pd={exports:{}},Ag;function G1(){return Ag||(Ag=1,(function(l,i){(function(s,r){l.exports=r()})(self,(()=>(()=>{var s={6:(h,m)=>{function b(y){try{const v=new URL(y),w=v.password&&v.username?`${v.protocol}//${v.username}:${v.password}@${v.host}`:v.username?`${v.protocol}//${v.username}@${v.host}`:`${v.protocol}//${v.host}`;return y.toLocaleLowerCase().startsWith(w.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(m,"__esModule",{value:!0}),m.LinkComputer=m.WebLinkProvider=void 0,m.WebLinkProvider=class{constructor(y,v,w,T={}){this._terminal=y,this._regex=v,this._handler=w,this._options=T}provideLinks(y,v){const w=p.computeLink(y,this._regex,this._terminal,this._handler);v(this._addCallbacks(w))}_addCallbacks(y){return y.map((v=>(v.leave=this._options.leave,v.hover=(w,T)=>{if(this._options.hover){const{range:A}=v;this._options.hover(w,T,A)}},v)))}};class p{static computeLink(v,w,T,A){const $=new RegExp(w.source,(w.flags||"")+"g"),[R,O]=p._getWindowedLineStrings(v-1,T),j=R.join("");let Y;const se=[];for(;Y=$.exec(j);){const fe=Y[0];if(!b(fe))continue;const[Q,K]=p._mapStrIdx(T,O,0,Y.index),[q,ue]=p._mapStrIdx(T,Q,K,fe.length);if(Q===-1||K===-1||q===-1||ue===-1)continue;const ye={start:{x:K+1,y:Q+1},end:{x:ue,y:q+1}};se.push({range:ye,text:fe,activate:A})}return se}static _getWindowedLineStrings(v,w){let T,A=v,$=v,R=0,O="";const j=[];if(T=w.buffer.active.getLine(v)){const Y=T.translateToString(!0);if(T.isWrapped&&Y[0]!==" "){for(R=0;(T=w.buffer.active.getLine(--A))&&R<2048&&(O=T.translateToString(!0),R+=O.length,j.push(O),T.isWrapped&&O.indexOf(" ")===-1););j.reverse()}for(j.push(Y),R=0;(T=w.buffer.active.getLine(++$))&&T.isWrapped&&R<2048&&(O=T.translateToString(!0),R+=O.length,j.push(O),O.indexOf(" ")===-1););}return[j,A]}static _mapStrIdx(v,w,T,A){const $=v.buffer.active,R=$.getNullCell();let O=T;for(;A;){const j=$.getLine(w);if(!j)return[-1,-1];for(let Y=O;Y<j.length;++Y){j.getCell(Y,R);const se=R.getChars();if(R.getWidth()&&(A-=se.length||1,Y===j.length-1&&se==="")){const fe=$.getLine(w+1);fe&&fe.isWrapped&&(fe.getCell(0,R),R.getWidth()===2&&(A+=1))}if(A<0)return[w,Y]}w++,O=0}return[w,O]}}m.LinkComputer=p}},r={};function c(h){var m=r[h];if(m!==void 0)return m.exports;var b=r[h]={exports:{}};return s[h](b,b.exports,c),b.exports}var f={};return(()=>{var h=f;Object.defineProperty(h,"__esModule",{value:!0}),h.WebLinksAddon=void 0;const m=c(6),b=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function p(y,v){const w=window.open();if(w){try{w.opener=null}catch{}w.location.href=v}else console.warn("Opening link blocked as opener could not be cleared")}h.WebLinksAddon=class{constructor(y=p,v={}){this._handler=y,this._options=v}activate(y){this._terminal=y;const v=this._options,w=v.urlRegex||b;this._linkProvider=this._terminal.registerLinkProvider(new m.WebLinkProvider(this._terminal,w,this._handler,v))}dispose(){var y;(y=this._linkProvider)==null||y.dispose()}}})(),f})()))})(pd)),pd.exports}var Y1=G1();const ly="\x1B",$1=/^\x1b\[[IO]/,ay=/^\x1b\[<(\d+);\d+;\d+[Mm]/,q1=/^\x1b\[M[\s\S]{3}/,V1=[/^\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\\/],X1=/^\x1b\[1;[2-8]R/;function Eg(l){if(X1.test(l))return 0;const i=$1.exec(l);if(i)return i[0].length;const s=ay.exec(l);if(s){const r=Number(s[1]);return(r&32)!==0&&(r&3)===3&&(r&64)===0?s[0].length:0}for(const r of V1){const c=r.exec(l);if(c)return c[0].length}return 0}function sy(l){if(!l.startsWith(ly))return"keys";if(ay.test(l)||q1.test(l)){let s=l;for(;s.length>0;){const r=Eg(s);if(r===0)return"pointer";s=s.slice(r)}return"passive"}let i=l;for(;i.length>0;){const s=Eg(i);if(s===0)return"keys";i=i.slice(s)}return"passive"}function P1(l){return l===ly}const Z1=20,Q1=6,W1=500,J1=300,fs=13,ry=.602,oy=1.3;function el(l,i){return Number.isFinite(l)&&l>0?l:i}function Ng(l,i,s){return Math.min(s,Math.max(i,l))}function kg(l){const{width:i,height:s,cellWidth:r,cellHeight:c,minCols:f=Z1,minRows:h=Q1,maxCols:m=W1,maxRows:b=J1}=l,p=el(r,fs*ry),y=el(c,fs*oy);return{cols:Ng(Math.floor(el(i,0)/p),f,m),rows:Ng(Math.floor(el(s,0)/y),h,b)}}function fa(l,i=fs){var r,c,f;if(l)try{const h=l._core,m=(f=(c=(r=h==null?void 0:h._renderService)==null?void 0:r.dimensions)==null?void 0:c.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 s=el(i,fs);return{cellWidth:Math.round(s*ry*100)/100,cellHeight:Math.round(s*oy*100)/100,measured:!1}}function eS(l){var r;const i=(r=l==null?void 0:l.querySelector)==null?void 0:r.call(l,".xterm-viewport");if(!i)return 0;const s=(i.offsetWidth||0)-(i.clientWidth||0);return Number.isFinite(s)&&s>0?s:0}function gd(l,i,s){if(!l)return{width:i,height:s};let r=0,c=0;if(typeof l.getBoundingClientRect=="function"){const f=l.getBoundingClientRect();r=(f==null?void 0:f.width)||0,c=(f==null?void 0:f.height)||0}return{width:el(r,el(l.clientWidth,i)),height:el(c,el(l.clientHeight,s))}}function cy(l,i,s,r){const c=Number.isFinite(r)&&r>.01?r:1;return{clientX:s.left+(l-s.left)/c,clientY:s.top+(i-s.top)/c}}function rr(l){var i,s;if(!l)return!1;try{const r=l.modes;if(r&&typeof r.mouseTrackingMode=="string"&&r.mouseTrackingMode!=="none")return!0;const c=l._core;if((i=c==null?void 0:c._coreMouseService)!=null&&i.areMouseEventsActive||(s=c==null?void 0:c.coreMouseService)!=null&&s.areMouseEventsActive||c!=null&&c.mouseMode&&c.mouseMode!=="none")return!0}catch{}return!1}function tS(l,i){const s=i.button??0,r=i.buttons??(l==="mouseup"?0:1);return new MouseEvent(l,{bubbles:!0,cancelable:!0,clientX:i.clientX,clientY:i.clientY,screenX:i.clientX,screenY:i.clientY,button:s,buttons:r})}function Rg(l,i,s){const r=tS(i,s);return l.dispatchEvent(r)}class nS{constructor(i){Z(this,"options");Z(this,"state","idle");Z(this,"startX",0);Z(this,"startY",0);Z(this,"lastX",0);Z(this,"lastY",0);Z(this,"activeTarget",null);Z(this,"longPressTimer",null);Z(this,"capturedPointerId",null);Z(this,"captureElement",null);Z(this,"scrollRemainderY",0);this.options={longPressDelayMs:500,dragThresholdPx:8,scrollLineHeightPx:18,...i}}getState(){return this.state}setGestureState(i){var s,r;this.state!==i&&(this.state=i,(r=(s=this.options).onGestureStateChange)==null||r.call(s,i))}getActiveBuffer(i){var s;try{return((s=i.buffer)==null?void 0:s.active)||null}catch{return null}}getViewportY(i){var r;const s=(r=this.getActiveBuffer(i))==null?void 0:r.viewportY;return typeof s=="number"&&Number.isFinite(s)?s:null}blurTerminal(i){var s;try{(s=i.blur)==null||s.call(i)}catch{}}getLogicalCoordinates(i,s){const r=this.options.getScale?this.options.getScale():1,c=this.options.getSurfaceElement?this.options.getSurfaceElement():null;if(r!==1&&c&&typeof c.getBoundingClientRect=="function"){const f=c.getBoundingClientRect();return cy(i,s,f,r)}return{clientX:i,clientY:s}}getViewportElement(i){var c;const s=this.options.getSurfaceElement?this.options.getSurfaceElement():null;return(s==null?void 0:s.querySelector(".xterm-viewport"))||((c=i.element)==null?void 0:c.querySelector(".xterm-viewport"))||null}isInputLineHit(i,s){var j;const r=(j=s.buffer)==null?void 0:j.active,c=this.options.getSurfaceElement?this.options.getSurfaceElement():null,f=(c==null?void 0:c.querySelector(".xterm-screen"))||s.element||c,h=fa(s);if(!f||typeof f.getBoundingClientRect!="function"||h.cellHeight<=0)return!1;const m=f.getBoundingClientRect(),b=this.getLogicalCoordinates(i.clientX,i.clientY),p=m.width>0&&m.height>0;if(![r==null?void 0:r.cursorY,r==null?void 0:r.viewportY,r==null?void 0:r.baseY].every(Y=>typeof Y=="number"&&Number.isFinite(Y)))return!1;const v=r==null?void 0:r.cursorY,w=r==null?void 0:r.viewportY,A=(r==null?void 0:r.baseY)+v-w,$=m.top+A*h.cellHeight,R=$+h.cellHeight,O=Number(s.rows);return A>=0&&(!Number.isFinite(O)||A<O)&&b.clientY>=$-2&&b.clientY<=R+2&&(!p||b.clientX>=m.left&&b.clientX<=m.right)}resolveDispatchTarget(i,s){var m;const r=this.options.getSurfaceElement?this.options.getSurfaceElement():null,c=(r==null?void 0:r.querySelector(".xterm-screen"))||s.querySelector(".xterm-screen")||null,f=((m=c==null?void 0:c.closest)==null?void 0:m.call(c,".xterm"))||null;let h=null;return typeof document<"u"&&typeof document.elementFromPoint=="function"&&(h=document.elementFromPoint(i.clientX,i.clientY)),h&&f&&(h===f||f.contains(h))?h:c||r||s}getMouseReport(i,s){const r=this.options.getSurfaceElement?this.options.getSurfaceElement():null,c=(r==null?void 0:r.querySelector(".xterm-screen"))||s.element;if(!c||typeof c.getBoundingClientRect!="function")return null;const f=c.getBoundingClientRect(),h=this.getLogicalCoordinates(i.clientX,i.clientY),m=fa(s);if(m.cellWidth<=0||m.cellHeight<=0)return null;const b=Math.max(1,f.width||s.cols*m.cellWidth),p=Math.max(1,f.height||s.rows*m.cellHeight),y=Math.max(0,Math.min(b-1,h.clientX-f.left)),v=Math.max(0,Math.min(p-1,h.clientY-f.top)),w=Math.max(0,Math.min(s.cols-1,Math.floor(y/m.cellWidth))),T=Math.max(0,Math.min(s.rows-1,Math.floor(v/m.cellHeight)));return{col:w,row:T,x:Math.floor(y),y:Math.floor(v),button:0,action:0}}getCoreMouseService(i){var r,c;const s=i;return s.coreMouseService||((r=s._core)==null?void 0:r.coreMouseService)||((c=s._core)==null?void 0:c._coreMouseService)||null}getCoreService(i){var r;const s=i;return s.coreService||((r=s._core)==null?void 0:r.coreService)||null}getWheelDispatchTarget(i){const s=this.options.getSurfaceElement?this.options.getSurfaceElement():null;return(s==null?void 0:s.querySelector(".xterm"))||i.element||null}dispatchWheel(i,s,r,c){const f=this.getWheelDispatchTarget(r);if(!f||typeof WheelEvent>"u"||s===0)return!1;const h=this.getLogicalCoordinates(i.clientX,i.clientY),m=s<0?-1:1;let b=0;for(let p=0;p<Math.abs(s);p+=1)try{const y=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:h.clientX,clientY:h.clientY,deltaX:0,deltaY:m,deltaMode:1,ctrlKey:!!(c!=null&&c.ctrlKey),altKey:!!(c!=null&&c.altKey),shiftKey:!!(c!=null&&c.shiftKey)});f.dispatchEvent(y),b+=1}catch{return b>0}return b>0}emitWheel(i,s,r,c){if(s===0)return!1;if(this.dispatchWheel(i,s,r,c))return!0;const f=this.getCoreMouseService(r);if(!(f!=null&&f.triggerMouseEvent))return!1;let h=0;for(let m=0;m<Math.abs(s);m+=1){const b=this.getMouseReport(i,r);b&&(b.button=4,b.action=s<0?0:1,b.ctrl=!!(c!=null&&c.ctrlKey),b.alt=!!(c!=null&&c.altKey),b.shift=!!(c!=null&&c.shiftKey),f.triggerMouseEvent(b)&&(h+=1))}return h>0}scrollAlternateBuffer(i,s,r,c){var h;if(s===0)return"none";const f=rr(r);if(!f&&!this.options.getIsController())return"none";if(this.emitWheel(i,s,r,c))return f?"application-mouse":"application-keys";if(!f){const m=this.getCoreService(r);if(!(m!=null&&m.triggerDataEvent))return"none";const p=`\x1B${!!((h=m.decPrivateModes)!=null&&h.applicationCursorKeys)?"O":"["}${s<0?"A":"B"}`;return m.triggerDataEvent(p.repeat(Math.abs(s)),!0),"application-keys"}return"none"}emitMouse(i,s,r){const c=this.options.getTerminal();if(!c)return;const f=this.getCoreMouseService(c);if(f!=null&&f.triggerMouseEvent){const m=this.getMouseReport(s,c);m&&(m.action=i==="mousedown"?1:i==="mouseup"?0:32,m.ctrl=!!(r!=null&&r.ctrlKey),m.alt=!!(r!=null&&r.altKey),m.shift=!!(r!=null&&r.shiftKey),f.triggerMouseEvent(m));return}if(this.options.allowSyntheticMouseFallback===!1||!this.activeTarget)return;const h=this.getLogicalCoordinates(s.clientX,s.clientY);Rg(this.activeTarget,i,{clientX:h.clientX,clientY:h.clientY,button:0,buttons:i==="mouseup"?0:1})}beginGesture(i,s){this.startX=i.clientX,this.startY=i.clientY,this.lastX=i.clientX,this.lastY=i.clientY,this.setGestureState("pending"),this.scrollRemainderY=0,this.activeTarget=this.resolveDispatchTarget(i,s),this.clearLongPressTimer(),this.longPressTimer=setTimeout(()=>{var r,c;this.state==="pending"&&(this.setGestureState("longpress"),(c=(r=this.options).onLongPress)==null||c.call(r,{clientX:this.startX,clientY:this.startY}))},this.options.longPressDelayMs)}moveGesture(i,s){var p,y,v,w;if(this.state==="longpress"){(y=(p=this.options).onSelectionExtend)==null||y.call(p,{clientX:i.clientX,clientY:i.clientY}),s!=null&&s.cancelable&&((v=s.preventDefault)==null||v.call(s));return}if(this.state==="idle")return;const r=i.clientX-this.startX,c=i.clientY-this.startY,f=Math.hypot(r,c);if(this.state==="scrolling"){this.scrollGesture(i,s);return}const h=this.options.getTerminal(),m=this.options.getIsController(),b=rr(h);if(!(f<=(this.options.dragThresholdPx||8))){if(this.clearLongPressTimer(),Math.abs(c)>=Math.abs(r)||!b||!m){this.setGestureState("scrolling"),h&&this.blurTerminal(h),this.lastX=i.clientX,this.lastY=this.startY,this.scrollRemainderY=0,this.scrollGesture(i,s);return}if(b&&m){this.state==="pending"&&(this.setGestureState("dragging"),this.emitMouse("mousedown",{clientX:this.startX,clientY:this.startY},s)),this.state==="dragging"&&(this.lastX=i.clientX,this.lastY=i.clientY,this.emitMouse("mousemove",i,s),s!=null&&s.cancelable&&((w=s.preventDefault)==null||w.call(s)));return}this.lastX=i.clientX,this.lastY=i.clientY}}scrollGesture(i,s){var A,$,R;const r=this.options.getTerminal();if(!r)return;const c=i.clientY-this.lastY;this.lastX=i.clientX,this.lastY=i.clientY;const f=fa(r),h=f.measured?f.cellHeight:this.options.scrollLineHeightPx||f.cellHeight||18;this.scrollRemainderY+=c;const m=Math.trunc(this.scrollRemainderY/h),b=-m;let p=!1,y="none";const v=this.getActiveBuffer(r),w=rr(r);if(b!==0){if((v==null?void 0:v.type)==="alternate")y=this.scrollAlternateBuffer(i,b,r,s),p=y!=="none";else{const O=this.getViewportY(r);r.scrollLines(b);const j=this.getViewportY(r);y="buffer",p=O===null||j===null||O!==j}this.scrollRemainderY-=m*h}const T=this.getViewportElement(r);($=(A=this.options).onGestureScroll)==null||$.call(A,{deltaY:c,lines:b,viewportY:this.getViewportY(r),scrollTop:(T==null?void 0:T.scrollTop)??null,scrollHeight:(T==null?void 0:T.scrollHeight)??null,clientHeight:(T==null?void 0:T.clientHeight)??null,moved:p,bufferType:(v==null?void 0:v.type)||null,baseY:typeof(v==null?void 0:v.baseY)=="number"?v.baseY:null,cursorY:typeof(v==null?void 0:v.cursorY)=="number"?v.cursorY:null,hasScrollback:typeof(v==null?void 0:v.hasScrollback)=="boolean"?v.hasScrollback:null,mouseTracking:w,scrollMode:y}),s!=null&&s.cancelable&&((R=s.preventDefault)==null||R.call(s))}endGesture(i,s){var h,m,b;this.clearLongPressTimer();const r=this.options.getTerminal(),c=this.options.getIsController(),f=rr(r);if(this.state==="pending"){if(f&&c){const y={clientX:this.startX,clientY:this.startY};this.emitMouse("mousedown",y,s),this.emitMouse("mouseup",y,s)}const p={clientX:this.startX,clientY:this.startY};c&&r&&this.isInputLineHit(p,r)&&((m=(h=this.options).onFocus)==null||m.call(h))}else if(this.state==="dragging"&&f&&c){const p=i??{clientX:this.lastX,clientY:this.lastY};this.emitMouse("mouseup",p,s),s!=null&&s.cancelable&&((b=s.preventDefault)==null||b.call(s))}this.reset()}handlePointerDown(i,s){if(i.pointerType==="mouse")return!1;if(!i.isPrimary)return this.releasePointerCapture(),this.reset(),!1;if(i.cancelable&&i.preventDefault(),this.beginGesture(i,s),i.pointerType!=="touch")try{typeof s.setPointerCapture=="function"&&(s.setPointerCapture(i.pointerId),this.capturedPointerId=i.pointerId,this.captureElement=s)}catch{}return!0}handlePointerMove(i){i.pointerType==="mouse"||this.state==="idle"||this.moveGesture(i,i)}handlePointerUp(i){i.pointerType==="mouse"||this.state==="idle"||(this.releasePointerCapture(),this.endGesture(i,i))}handlePointerCancel(i){i&&i.pointerType==="mouse"||(this.releasePointerCapture(),this.cancelGesture())}handleTouchStart(i,s){if(i.touches.length!==1){this.reset();return}i.cancelable&&i.preventDefault(),this.beginGesture(i.touches[0],s)}handleTouchMove(i){i.touches.length===1&&this.moveGesture(i.touches[0],i)}handleTouchEnd(i){i.cancelable&&i.preventDefault(),this.endGesture(null,i)}handleTouchCancel(){this.cancelGesture()}cancelGesture(){this.clearLongPressTimer();const i=this.options.getTerminal(),s=this.options.getIsController(),r=rr(i);if(this.state==="dragging"&&r&&s&&this.activeTarget){const c=this.getLogicalCoordinates(this.lastX,this.lastY);Rg(this.activeTarget,"mouseup",{clientX:c.clientX,clientY:c.clientY,button:0,buttons:0})}this.reset()}releasePointerCapture(){const i=this.captureElement,s=this.capturedPointerId;if(this.captureElement=null,this.capturedPointerId=null,!(!i||s===null))try{typeof i.releasePointerCapture=="function"&&(typeof i.hasPointerCapture!="function"||i.hasPointerCapture(s))&&i.releasePointerCapture(s)}catch{}}clearLongPressTimer(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}reset(){this.clearLongPressTimer(),this.releasePointerCapture(),this.setGestureState("idle"),this.activeTarget=null}}var Qt=(l=>(l[l.CODEPOINT_MASK=2097151]="CODEPOINT_MASK",l[l.IS_COMBINED_MASK=2097152]="IS_COMBINED_MASK",l[l.WIDTH_SHIFT=22]="WIDTH_SHIFT",l))(Qt||{}),kt=(l=>(l[l.PCOLOR_MASK=255]="PCOLOR_MASK",l[l.CM_MASK=50331648]="CM_MASK",l[l.CM_DEFAULT=0]="CM_DEFAULT",l[l.CM_P16=16777216]="CM_P16",l[l.CM_P256=33554432]="CM_P256",l[l.CM_RGB=50331648]="CM_RGB",l[l.RGB_MASK=16777215]="RGB_MASK",l))(kt||{}),sn=(l=>(l[l.INVERSE=67108864]="INVERSE",l[l.BOLD=134217728]="BOLD",l[l.UNDERLINE=268435456]="UNDERLINE",l[l.BLINK=536870912]="BLINK",l[l.INVISIBLE=1073741824]="INVISIBLE",l[l.STRIKETHROUGH=2147483648]="STRIKETHROUGH",l))(sn||{}),ha=(l=>(l[l.ITALIC=67108864]="ITALIC",l[l.DIM=134217728]="DIM",l[l.HAS_EXTENDED=268435456]="HAS_EXTENDED",l[l.PROTECTED=536870912]="PROTECTED",l[l.OVERLINE=1073741824]="OVERLINE",l))(ha||{}),ls=(l=>(l[l.NONE=0]="NONE",l[l.SINGLE=1]="SINGLE",l[l.DOUBLE=2]="DOUBLE",l[l.CURLY=3]="CURLY",l[l.DOTTED=4]="DOTTED",l[l.DASHED=5]="DASHED",l))(ls||{});function iS(){return{content:0,fg:0,bg:0,combinedData:"",extended:void 0}}const uy={fg:0,bg:0,ext:0};function dy(l){return l.bg&268435456&&l.extended?l.extended.ext>>>0:0}function lS(l){return l>>>26&7}function aS(l){return l&67108863}function sS(l,i){const s=l.codePointAt(0)??0;return l.length>0&&String.fromCodePoint(s).length===l.length?{content:s|i<<22,combinedData:""}:{content:2097152|i<<22,combinedData:l}}function fy(l){const i=l;return!i||typeof i.fg!="number"||typeof i.bg!="number"?null:{fg:i.fg>>>0,bg:i.bg>>>0,ext:dy(i)}}const Oo=new Map;function hy(l){let i=Oo.get(l);return i===void 0&&(i=`#${(l&kt.RGB_MASK).toString(16).padStart(6,"0")}`,Oo.size>4096&&Oo.clear(),Oo.set(l,i)),i}function my(l,i,s){var r;switch(l&kt.CM_MASK){case kt.CM_P16:case kt.CM_P256:return((r=i.ansi[l&kt.PCOLOR_MASK])==null?void 0:r.css)??s;case kt.CM_RGB:return hy(l&kt.RGB_MASK);default:return s}}function Lg(l,i,s,r){var v;const c=(l&sn.INVERSE)!==0,f=c?i:l,h=c?l:i;let m;const b=f&kt.CM_MASK;if(b===kt.CM_P16||b===kt.CM_P256){let w=f&kt.PCOLOR_MASK;r&&l&sn.BOLD&&w<8&&(w+=8),m=((v=s.ansi[w])==null?void 0:v.css)??s.foreground.css}else b===kt.CM_RGB?m=hy(f&kt.RGB_MASK):m=c?s.background.css:s.foreground.css;const p=h&kt.CM_MASK,y=p===kt.CM_DEFAULT?c?s.foreground.css:s.background.css:my(h,s,s.background.css);return{fg:m,bg:y,bgIsDefault:!c&&p===kt.CM_DEFAULT}}function zo(l){return(l&sn.BOLD)!==0}function bd(l){return(l&ha.ITALIC)!==0}function yd(l){return(l&ha.DIM)!==0}function Bo(l){return(l&sn.INVISIBLE)!==0}/**
34
- * Box drawing, block element and Powerline glyphs, drawn as shapes rather than
35
- * taken from the font.
36
- *
37
- * Vendored verbatim from @xterm/xterm 5.5.0,
38
- * src/browser/renderer/shared/CustomGlyphs.ts. The only edits are the one
39
- * helper it imported, inlined below, and underscores on parameters the strict
40
- * compiler flags as unused.
41
- *
42
- * Copyright (c) 2021 The xterm.js authors. All rights reserved.
43
- * @license MIT
44
- */function _g(l){if(!l)throw new Error("value must not be falsy");return l}const rS={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},oS={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},cS={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(l,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"║":{1:(l,i)=>`M${.5-l},0 L${.5-l},1 M${.5+l},0 L${.5+l},1`},"╒":{1:(l,i)=>`M.5,1 L.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╓":{1:(l,i)=>`M${.5-l},1 L${.5-l},.5 L1,.5 M${.5+l},.5 L${.5+l},1`},"╔":{1:(l,i)=>`M1,${.5-i} L${.5-l},${.5-i} L${.5-l},1 M1,${.5+i} L${.5+l},${.5+i} L${.5+l},1`},"╕":{1:(l,i)=>`M0,${.5-i} L.5,${.5-i} L.5,1 M0,${.5+i} L.5,${.5+i}`},"╖":{1:(l,i)=>`M${.5+l},1 L${.5+l},.5 L0,.5 M${.5-l},.5 L${.5-l},1`},"╗":{1:(l,i)=>`M0,${.5+i} L${.5-l},${.5+i} L${.5-l},1 M0,${.5-i} L${.5+l},${.5-i} L${.5+l},1`},"╘":{1:(l,i)=>`M.5,0 L.5,${.5+i} L1,${.5+i} M.5,${.5-i} L1,${.5-i}`},"╙":{1:(l,i)=>`M1,.5 L${.5-l},.5 L${.5-l},0 M${.5+l},.5 L${.5+l},0`},"╚":{1:(l,i)=>`M1,${.5-i} L${.5+l},${.5-i} L${.5+l},0 M1,${.5+i} L${.5-l},${.5+i} L${.5-l},0`},"╛":{1:(l,i)=>`M0,${.5+i} L.5,${.5+i} L.5,0 M0,${.5-i} L.5,${.5-i}`},"╜":{1:(l,i)=>`M0,.5 L${.5+l},.5 L${.5+l},0 M${.5-l},.5 L${.5-l},0`},"╝":{1:(l,i)=>`M0,${.5-i} L${.5-l},${.5-i} L${.5-l},0 M0,${.5+i} L${.5+l},${.5+i} L${.5+l},0`},"╞":{1:(l,i)=>`M.5,0 L.5,1 M.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╟":{1:(l,i)=>`M${.5-l},0 L${.5-l},1 M${.5+l},0 L${.5+l},1 M${.5+l},.5 L1,.5`},"╠":{1:(l,i)=>`M${.5-l},0 L${.5-l},1 M1,${.5+i} L${.5+l},${.5+i} L${.5+l},1 M1,${.5-i} L${.5+l},${.5-i} L${.5+l},0`},"╡":{1:(l,i)=>`M.5,0 L.5,1 M0,${.5-i} L.5,${.5-i} M0,${.5+i} L.5,${.5+i}`},"╢":{1:(l,i)=>`M0,.5 L${.5-l},.5 M${.5-l},0 L${.5-l},1 M${.5+l},0 L${.5+l},1`},"╣":{1:(l,i)=>`M${.5+l},0 L${.5+l},1 M0,${.5+i} L${.5-l},${.5+i} L${.5-l},1 M0,${.5-i} L${.5-l},${.5-i} L${.5-l},0`},"╤":{1:(l,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i} M.5,${.5+i} L.5,1`},"╥":{1:(l,i)=>`M0,.5 L1,.5 M${.5-l},.5 L${.5-l},1 M${.5+l},.5 L${.5+l},1`},"╦":{1:(l,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L${.5-l},${.5+i} L${.5-l},1 M1,${.5+i} L${.5+l},${.5+i} L${.5+l},1`},"╧":{1:(l,i)=>`M.5,0 L.5,${.5-i} M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╨":{1:(l,i)=>`M0,.5 L1,.5 M${.5-l},.5 L${.5-l},0 M${.5+l},.5 L${.5+l},0`},"╩":{1:(l,i)=>`M0,${.5+i} L1,${.5+i} M0,${.5-i} L${.5-l},${.5-i} L${.5-l},0 M1,${.5-i} L${.5+l},${.5-i} L${.5+l},0`},"╪":{1:(l,i)=>`M.5,0 L.5,1 M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╫":{1:(l,i)=>`M0,.5 L1,.5 M${.5-l},0 L${.5-l},1 M${.5+l},0 L${.5+l},1`},"╬":{1:(l,i)=>`M0,${.5+i} L${.5-l},${.5+i} L${.5-l},1 M1,${.5+i} L${.5+l},${.5+i} L${.5+l},1 M0,${.5-i} L${.5-l},${.5-i} L${.5-l},0 M1,${.5-i} L${.5+l},${.5-i} L${.5+l},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(l,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,1,.5`},"╮":{1:(l,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,0,.5`},"╯":{1:(l,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,0,.5`},"╰":{1:(l,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,1,.5`}},xr={"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};xr[""]=xr[""];xr[""]=xr[""];function uS(l,i,s,r,c,f,h,m){const b=rS[i];if(b)return dS(l,b,s,r,c,f),!0;const p=oS[i];if(p)return fS(l,p,s,r,c,f),!0;const y=cS[i];if(y)return hS(l,y,s,r,c,f,m),!0;const v=xr[i];return v?(mS(l,v,s,r,c,f,h,m),!0):!1}function dS(l,i,s,r,c,f){for(let h=0;h<i.length;h++){const m=i[h],b=c/8,p=f/8;l.fillRect(s+m.x*b,r+m.y*p,m.w*b,m.h*p)}}const jg=new Map;function fS(l,i,s,r,c,f){let h=jg.get(i);h||(h=new Map,jg.set(i,h));const m=l.fillStyle;if(typeof m!="string")throw new Error(`Unexpected fillStyle type "${m}"`);let b=h.get(m);if(!b){const p=i[0].length,y=i.length,v=l.canvas.ownerDocument.createElement("canvas");v.width=p,v.height=y;const w=_g(v.getContext("2d")),T=new ImageData(p,y);let A,$,R,O;if(m.startsWith("#"))A=parseInt(m.slice(1,3),16),$=parseInt(m.slice(3,5),16),R=parseInt(m.slice(5,7),16),O=m.length>7&&parseInt(m.slice(7,9),16)||1;else if(m.startsWith("rgba"))[A,$,R,O]=m.substring(5,m.length-1).split(",").map(j=>parseFloat(j));else throw new Error(`Unexpected fillStyle color format "${m}" when drawing pattern glyph`);for(let j=0;j<y;j++)for(let Y=0;Y<p;Y++)T.data[(j*p+Y)*4]=A,T.data[(j*p+Y)*4+1]=$,T.data[(j*p+Y)*4+2]=R,T.data[(j*p+Y)*4+3]=i[j][Y]*(O*255);w.putImageData(T,0,0),b=_g(l.createPattern(v,null)),h.set(m,b)}l.fillStyle=b,l.fillRect(s,r,c,f)}function hS(l,i,s,r,c,f,h){l.strokeStyle=l.fillStyle;for(const[m,b]of Object.entries(i)){l.beginPath(),l.lineWidth=h*Number.parseInt(m);let p;if(typeof b=="function"){const v=.15/f*c;p=b(.15,v)}else p=b;for(const y of p.split(" ")){const v=y[0],w=py[v];if(!w){console.error(`Could not find drawing instructions for "${v}"`);continue}const T=y.substring(1).split(",");!T[0]||!T[1]||w(l,gy(T,c,f,s,r,!0,h))}l.stroke(),l.closePath()}}function mS(l,i,s,r,c,f,h,m){const b=new Path2D;b.rect(s,r,c,f),l.clip(b),l.beginPath();const p=h/12;l.lineWidth=m*p;for(const y of i.d.split(" ")){const v=y[0],w=py[v];if(!w){console.error(`Could not find drawing instructions for "${v}"`);continue}const T=y.substring(1).split(",");!T[0]||!T[1]||w(l,gy(T,c,f,s,r,!1,m,(i.leftPadding??0)*(p/2),(i.rightPadding??0)*(p/2)))}i.type===1?(l.strokeStyle=l.fillStyle,l.stroke()):l.fill(),l.closePath()}function Dg(l,i,s=0){return Math.max(Math.min(l,i),s)}const py={C:(l,i)=>l.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]),L:(l,i)=>l.lineTo(i[0],i[1]),M:(l,i)=>l.moveTo(i[0],i[1])};function gy(l,i,s,r,c,f,h,m=0,b=0){const p=l.map(y=>parseFloat(y)||parseInt(y));if(p.length<2)throw new Error("Too few arguments for instruction");for(let y=0;y<p.length;y+=2)p[y]*=i-m*h-b*h,f&&p[y]!==0&&(p[y]=Dg(Math.round(p[y]+.5)-.5,i,0)),p[y]+=r+m*h;for(let y=1;y<p.length;y+=2)p[y]*=s,f&&p[y]!==0&&(p[y]=Dg(Math.round(p[y]+.5)-.5,s,0)),p[y]+=c;return p}const Gd=.5,pS=1024,gS=6;function bS(l){return/Firefox\//.test(l)||/Edge\/\d/.test(l)?"bottom":"ideographic"}class yS{constructor(i,s=typeof navigator<"u"?navigator.userAgent:""){Z(this,"pages",[]);Z(this,"slots",new Map);Z(this,"inkCache",new Map);Z(this,"metrics",null);Z(this,"font",null);Z(this,"baseline");Z(this,"generation",0);Z(this,"scratch");this.document=i,this.baseline=bS(s)}configure(i,s){const r=this.metrics&&this.font&&this.metrics.cellWidth===i.cellWidth&&this.metrics.cellHeight===i.cellHeight&&this.metrics.charWidth===i.charWidth&&this.metrics.charHeight===i.charHeight&&this.metrics.charLeft===i.charLeft&&this.metrics.charTop===i.charTop&&this.metrics.dpr===i.dpr&&this.font.fontFamily===s.fontFamily&&this.font.fontSize===s.fontSize&&this.font.fontWeight===s.fontWeight&&this.font.fontWeightBold===s.fontWeightBold&&this.font.customGlyphs===s.customGlyphs;this.metrics={...i},this.font={...s},r||this.clear()}clear(){this.slots.clear(),this.inkCache.clear();for(const i of this.pages)i.shelfX=0,i.shelfY=0;this.generation++}dispose(){this.slots.clear(),this.inkCache.clear();for(const i of this.pages)i.canvas.width=0,i.canvas.height=0;this.pages=[]}get pageCount(){return this.pages.length}fontString(i,s){const r=this.font,c=i?r.fontWeightBold:r.fontWeight;return`${s?"italic ":""}${c} ${r.fontSize*this.metrics.dpr}px ${r.fontFamily}`}overflow(i,s,r){if(!this.metrics||!this.font||i.length===1&&i.charCodeAt(0)<128)return 0;const c=`${s?1:0}${r?1:0}${i}`,f=this.inkCache.get(c);if(f!==void 0)return f;let h=0;const m=this.scratchContext();if(m&&!(this.font.customGlyphs&&by(i))){m.font=this.fontString(s,r),m.textBaseline=this.baseline;const b=m.measureText(i),p=typeof b.actualBoundingBoxRight=="number"?b.actualBoundingBoxRight:b.width;h=Math.max(0,Math.ceil(this.metrics.charLeft+p-this.metrics.cellWidth))}return this.inkCache.set(c,h),h}get(i){const s=this.metrics,r=this.font;if(!s||!r||s.cellWidth<=0||s.cellHeight<=0)return null;const c=`${i.cells}${i.bold?1:0}${i.italic?1:0}${i.dim?1:0}${i.fg}\0${i.bg}\0${i.chars}`,f=this.slots.get(c);if(f)return f;const h=s.cellWidth*i.cells,m=s.cellHeight,b=this.allocate(h,m);if(!b)return null;const{page:p,x:y,y:v}=b,w=p.ctx;w.save(),w.beginPath(),w.rect(y,v,h,m),w.clip(),w.globalAlpha=1,w.fillStyle=i.bg,w.fillRect(y,v,h,m),w.fillStyle=i.fg,i.dim&&(w.globalAlpha=Gd);let T=!1;r.customGlyphs&&(T=uS(w,i.chars,y,v,s.cellWidth,s.cellHeight,r.fontSize,s.dpr)),T||(w.font=this.fontString(i.bold,i.italic),w.textBaseline=this.baseline,w.fillText(i.chars,y+s.charLeft,v+s.charTop+s.charHeight)),w.restore();const A={source:p.canvas,x:y,y:v,width:h,height:m};return this.slots.set(c,A),A}allocate(i,s){for(const r of this.pages){const c=this.fit(r,i,s);if(c)return c}if(this.pages.length<gS){const r=this.createPage(Math.max(pS,i,s));return r?(this.pages.push(r),this.fit(r,i,s)):null}return this.clear(),this.pages[0]?this.fit(this.pages[0],i,s):null}fit(i,s,r){if(i.shelfX+s>i.canvas.width&&(i.shelfX=0,i.shelfY+=r),i.shelfY+r>i.canvas.height||s>i.canvas.width)return null;const c={page:i,x:i.shelfX,y:i.shelfY};return i.shelfX+=s,c}createPage(i){const s=this.document.createElement("canvas");s.width=i,s.height=i;const r=s.getContext("2d",{alpha:!1});return r?{canvas:s,ctx:r,shelfX:0,shelfY:0}:null}scratchContext(){if(this.scratch===void 0){const i=this.document.createElement("canvas");i.width=1,i.height=1,this.scratch=i.getContext("2d")}return this.scratch}}function by(l){if(l.length!==1)return!1;const i=l.charCodeAt(0);return i>=9472&&i<=9631||i>=57504&&i<=57558}function vS(l){var s,r,c,f;const i=l._core;return!i||!i.screenElement||!i.coreService||!((s=i.optionsService)!=null&&s.rawOptions)||!((r=i._bufferService)!=null&&r.buffer)||!i._charSizeService||!i._coreBrowserService||!((c=i._themeService)!=null&&c.colors)||typeof((f=i._renderService)==null?void 0:f.setRenderer)!="function"?null:i}const xS=150,wS=600,or=4294967295;function SS(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}class CS{constructor(){Z(this,"listeners",new Set);Z(this,"event",i=>(this.listeners.add(i),{dispose:()=>this.listeners.delete(i)}))}fire(i){for(const s of[...this.listeners])s(i)}dispose(){this.listeners.clear()}}class of{constructor(i,s){Z(this,"dimensions",SS());Z(this,"redraw",new CS);Z(this,"onRequestRedraw",this.redraw.event);Z(this,"stats",{frames:0,heldFrames:0,lastPaintMs:0,lastCells:0,lastInputToPaintMs:null});Z(this,"canvas");Z(this,"ctx");Z(this,"decorCanvas");Z(this,"decorCtx");Z(this,"atlas");Z(this,"disposables",[]);Z(this,"now");Z(this,"maxSyncHoldMs");Z(this,"cols",0);Z(this,"rows",0);Z(this,"painted",{content:new Uint32Array(0),fg:new Uint32Array(0),bg:new Uint32Array(0),ext:new Uint32Array(0),meta:new Uint32Array(0),combined:[]});Z(this,"row",{content:new Uint32Array(0),fg:new Uint32Array(0),bg:new Uint32Array(0),ext:new Uint32Array(0),combined:[]});Z(this,"work",iS());Z(this,"overlayProvider",null);Z(this,"paintedOverlayRows",new Set);Z(this,"paintedCursorRow",-1);Z(this,"lastYdisp",0);Z(this,"holdStartedAt",null);Z(this,"held",null);Z(this,"holdTimer",null);Z(this,"selection",null);Z(this,"link",null);Z(this,"inputAt",null);Z(this,"blinkVisible",!0);Z(this,"blinkTimer",null);Z(this,"disposed",!1);Z(this,"isSynchronizing");Z(this,"dprUsed",0);this.core=i,this.now=s.now??(()=>performance.now()),this.maxSyncHoldMs=s.maxSyncHoldMs??xS,this.isSynchronizing=s.isSynchronizing??(()=>!1);const r=i._coreBrowserService.mainDocument,c=i.screenElement;this.canvas=r.createElement("canvas"),this.canvas.classList.add("xterm-text-layer"),this.canvas.style.zIndex="0";const f=this.canvas.getContext("2d",{alpha:!1});if(!f)throw new Error("2D canvas unavailable");this.ctx=f,this.decorCanvas=r.createElement("canvas"),this.decorCanvas.classList.add("xterm-decor-layer"),this.decorCanvas.style.zIndex="2";const h=this.decorCanvas.getContext("2d");if(!h)throw new Error("2D canvas unavailable");this.decorCtx=h,c.appendChild(this.canvas),c.appendChild(this.decorCanvas),this.atlas=new yS(r),this.disposables.push(i._themeService.onChangeColors(()=>{this.atlas.clear(),this.invalidateAll(),this.redrawDecor()}),i.optionsService.onOptionChange(m=>{(m==="cursorBlink"||m==="cursorStyle")&&this.restartBlink()})),i.linkifier&&this.disposables.push(i.linkifier.onShowLinkUnderline(m=>{this.link=m,this.redrawDecor()}),i.linkifier.onHideLinkUnderline(()=>{this.link=null,this.redrawDecor()})),this.observeDevicePixels(),this.observeFonts(r),this.restartBlink()}static install(i,s={}){const r=vS(i);if(!r)return null;const c=new of(r,s);return r._renderService.setRenderer(c),r._renderService.handleResize(r._bufferService.cols,r._bufferService.rows),c}setOverlayProvider(i){this.overlayProvider=i,this.invalidateOverlay()}invalidateOverlay(){var r;const i=((r=this.overlayProvider)==null?void 0:r.call(this))??null,s=new Set(this.paintedOverlayRows);for(const c of TS(i))s.add(c);this.paintedCursorRow>=0&&s.add(this.paintedCursorRow+this.buffer().ydisp),this.requestAbsoluteRows(s)}markInput(){this.inputAt=this.now()}flushHeld(){if(!this.held)return;const{start:i,end:s}=this.held;this.redraw.fire({start:i,end:s})}handleDevicePixelRatioChange(){this.dimensions.device.cell.width&&this.dprUsed!==this.core._coreBrowserService.dpr&&this.handleResize(this.core._bufferService.cols,this.core._bufferService.rows)}handleResize(i,s){this.updateDimensions(i,s);const r=this.dimensions;for(const f of[this.canvas,this.decorCanvas])f.width=r.device.canvas.width,f.height=r.device.canvas.height,f.style.width=`${r.css.canvas.width}px`,f.style.height=`${r.css.canvas.height}px`;const c=this.core.screenElement;c&&(c.style.width=`${r.css.canvas.width}px`,c.style.height=`${r.css.canvas.height}px`),this.resizeGrid(i,s),this.configureAtlas(),this.fillBackground(),this.redrawDecor()}handleCharSizeChanged(){this.handleResize(this.core._bufferService.cols,this.core._bufferService.rows)}handleBlur(){this.stopBlink(),this.requestCursorRow(),this.redrawDecor()}handleFocus(){this.restartBlink(),this.requestCursorRow(),this.redrawDecor()}handleSelectionChanged(i,s,r){this.selection=i&&s&&!(i[0]===s[0]&&i[1]===s[1])?{start:[i[0],i[1]],end:[s[0],s[1]],columnSelectMode:r}:null,this.redrawDecor()}handleCursorMove(){this.blinkTimer&&this.restartBlink()}clear(){this.invalidateAll(),this.fillBackground()}clearTextureAtlas(){this.atlas.clear(),this.invalidateAll(),this.redraw.fire({start:0,end:Math.max(0,this.rows-1)})}renderRows(i,s){if(!(this.disposed||!this.cols||!this.rows||!this.dimensions.device.cell.width)){if(this.isSynchronizing()){const r=this.now();if(this.holdStartedAt===null&&(this.holdStartedAt=r),r-this.holdStartedAt<this.maxSyncHoldMs){this.held=this.held?{start:Math.min(this.held.start,i),end:Math.max(this.held.end,s)}:{start:i,end:s},this.stats.heldFrames++,this.holdTimer||(this.holdTimer=setTimeout(()=>{this.holdTimer=null,this.flushHeld()},this.maxSyncHoldMs));return}}this.held&&(i=Math.min(i,this.held.start),s=Math.max(s,this.held.end)),this.held=null,this.holdStartedAt=null,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=null),this.paint(Math.max(0,i),Math.min(this.rows-1,s))}}dispose(){if(!this.disposed){this.disposed=!0,this.stopBlink(),this.holdTimer&&clearTimeout(this.holdTimer);for(const i of this.disposables)i.dispose();this.disposables.length=0,this.redraw.dispose(),this.atlas.dispose(),this.canvas.remove(),this.decorCanvas.remove()}}uninstall(){const i=this.core._createRenderer;typeof i=="function"&&(this.core._renderService.setRenderer(i.call(this.core)),this.core._renderService.handleResize(this.core._bufferService.cols,this.core._bufferService.rows)),this.dispose()}get textCanvas(){return this.canvas}hasPaintedInk(i,s){const r=this.dimensions.device;if(!r.cell.width||!r.cell.height)return!1;const c=Math.min(this.cols,Math.floor(i/r.cell.width)),f=Math.min(this.rows,Math.floor(s/r.cell.height)),h=this.painted;for(let m=0;m<f;m++)for(let b=0;b<c;b++){const p=m*this.cols+b,y=h.content[p];if(y===or||h.meta[p]===4||Bo(h.fg[p]))continue;const v=y&Qt.CODEPOINT_MASK;if(y&Qt.IS_COMBINED_MASK?h.combined[p]!=="":v!==0&&v!==32)return!0}return!1}paint(i,s){var v;const r=this.now(),f=this.buffer().ydisp;f!==this.lastYdisp&&(this.lastYdisp=f,this.redrawDecor());const h=((v=this.overlayProvider)==null?void 0:v.call(this))??null,m=new Map;for(const w of(h==null?void 0:h.cells)??[]){const T=m.get(w.row);T?T.push(w):m.set(w.row,[w])}const b=this.cursorState(h),p=new Set;for(let w=i;w<=s;w++)p.add(w);for(const w of this.paintedOverlayRows)Ho(p,w-f,this.rows);for(const w of m.keys())Ho(p,w-f,this.rows);this.paintedCursorRow>=0&&Ho(p,this.paintedCursorRow,this.rows),b&&Ho(p,b.y,this.rows);let y=0;for(const w of p)this.loadRow(w,f,m.get(w+f)),y+=this.paintRow(w,b);this.paintedOverlayRows=new Set(m.keys()),this.paintedCursorRow=b?b.y:-1,this.stats.frames++,this.stats.lastCells=y,this.stats.lastPaintMs=this.now()-r,this.inputAt!==null&&y>0&&(this.stats.lastInputToPaintMs=this.now()-this.inputAt,this.inputAt=null)}loadRow(i,s,r){const{content:c,fg:f,bg:h,ext:m,combined:b}=this.row,p=this.buffer().lines.get(s+i),y=this.work;for(let v=0;v<this.cols;v++)p&&v<p.length?(p.loadCell(v,y),c[v]=y.content,f[v]=y.fg,h[v]=y.bg,m[v]=dy(y),b[v]=y.content&Qt.IS_COMBINED_MASK?y.combinedData:""):(c[v]=1<<Qt.WIDTH_SHIFT,f[v]=0,h[v]=0,m[v]=0,b[v]="");if(r)for(const v of r){const w=v.col;if(w<0||w+v.width>this.cols)continue;w>0&&!(c[w]>>>Qt.WIDTH_SHIFT)&&this.blankAt(w-1);const T=w+v.width;T<this.cols&&!(c[T]>>>Qt.WIDTH_SHIFT)&&c[T-1]>>>Qt.WIDTH_SHIFT===2&&this.blankAt(T);const A=sS(v.chars,v.width);c[w]=A.content,b[w]=A.combinedData,f[w]=v.style.fg,h[w]=v.style.bg,m[w]=v.style.ext,v.width===2&&(c[w+1]=0,b[w+1]="",f[w+1]=v.style.fg,h[w+1]=v.style.bg,m[w+1]=v.style.ext)}}blankAt(i){this.row.content[i]=32|1<<Qt.WIDTH_SHIFT,this.row.combined[i]=""}paintRow(i,s){const r=this.cols,{content:c,fg:f,bg:h,ext:m,combined:b}=this.row,p=this.painted,y=i*r;let v=0,w=-1,T=-1,A="";const $=()=>{w<0||(this.fillCells(w,i,T-w,A),w=-1)};let R=0;for(;R<r;){let j=c[R]>>>Qt.WIDTH_SHIFT;j===0&&(j=1),R+j>r&&(j=r-R),j===1&&R+1<r&&this.overflowsInto(R)&&(j=2);const Y=s&&s.y===i&&s.x>=R&&s.x<R+j?s.shape:0,se=j|Y<<3;let fe=this.differs(y+R,R,se);for(let Q=1;Q<j;Q++)this.differs(y+R+Q,R+Q,4)&&(fe=!0);if(fe){for(let K=0;K<j;K++){const q=y+R+K;p.content[q]=c[R+K],p.fg[q]=f[R+K],p.bg[q]=h[R+K],p.ext[q]=m[R+K],p.meta[q]=K===0?se:4,p.combined[q]=b[R+K]}v+=j;const Q=this.plainFill(R,Y);Q!==null?w>=0&&T===R&&A===Q?T=R+j:($(),w=R,T=R+j,A=Q):($(),this.paintCell(R,i,j,Y))}R+=j}return $(),v}differs(i,s,r){const c=this.painted,f=this.row;return c.meta[i]!==r||c.content[i]!==f.content[s]||c.fg[i]!==f.fg[s]||c.bg[i]!==f.bg[s]||c.ext[i]!==f.ext[s]||c.combined[i]!==f.combined[s]}overflowsInto(i){const{content:s,fg:r,bg:c,ext:f}=this.row,h=s[i];if((h&Qt.CODEPOINT_MASK)<128&&!(h&Qt.IS_COMBINED_MASK)||h>>>Qt.WIDTH_SHIFT!==1||Bo(r[i]))return!1;const b=s[i+1],p=b&Qt.CODEPOINT_MASK;if(b>>>Qt.WIDTH_SHIFT!==1||b&Qt.IS_COMBINED_MASK||p!==0&&p!==32||c[i]!==c[i+1]||f[i+1]!==0||(r[i]&sn.INVERSE)!==(r[i+1]&sn.INVERSE)||r[i]&sn.INVERSE&&r[i]!==r[i+1]||r[i+1]&(sn.UNDERLINE|sn.STRIKETHROUGH)||c[i+1]&ha.OVERLINE)return!1;const y=this.charsAt(i);return this.core.optionsService.rawOptions.customGlyphs!==!1&&by(y)?!1:this.atlas.overflow(y,zo(r[i]),bd(c[i]))>0}charsAt(i){const s=this.row.content[i];if(s&Qt.IS_COMBINED_MASK)return this.row.combined[i];const r=s&Qt.CODEPOINT_MASK;return r?String.fromCodePoint(r):""}plainFill(i,s){if(s!==0)return null;const{content:r,fg:c,bg:f}=this.row,h=r[i],m=h&Qt.CODEPOINT_MASK,b=!(h&Qt.IS_COMBINED_MASK)&&(m===0||m===32),p=Bo(c[i]);return!b&&!p||(c[i]&(sn.UNDERLINE|sn.STRIKETHROUGH)||f[i]&ha.OVERLINE)&&!p?null:Lg(c[i],f[i],this.colors(),this.boldBright()).bg}paintCell(i,s,r,c){const f=this.ctx,h=this.dimensions.device,m=this.colors(),b=this.row.fg[i],p=this.row.bg[i],y=this.row.ext[i],v=Lg(b,p,m,this.boldBright());let w=v.fg,T=v.bg;c===1&&(T=m.cursor.css,w=m.cursorAccent.css);const A=Bo(b),$=this.charsAt(i),R=i*h.cell.width,O=s*h.cell.height,j=r*h.cell.width,Y=h.cell.height,se=A||$===""||$===" ",fe=se?null:this.atlas.get({chars:$,bold:zo(b),italic:bd(p),dim:yd(p),fg:w,bg:T,cells:r});fe?f.drawImage(fe.source,fe.x,fe.y,fe.width,fe.height,R,O,j,Y):(f.fillStyle=T,f.fillRect(R,O,j,Y),se||(f.save(),f.beginPath(),f.rect(R,O,j,Y),f.clip(),f.fillStyle=w,yd(p)&&(f.globalAlpha=Gd),f.font=this.atlas.fontString(zo(b),bd(p)),f.fillText($,R+h.char.left,O+h.char.top+h.char.height),f.restore())),A||this.paintDecorations(R,O,r,b,p,y,w),c!==0&&c!==1&&this.paintCursorShape(R,O,j,c)}paintDecorations(i,s,r,c,f,h,m){const b=(c&sn.UNDERLINE)!==0,p=(c&sn.STRIKETHROUGH)!==0,y=(f&ha.OVERLINE)!==0;if(!b&&!p&&!y)return;const v=this.ctx,w=this.dimensions.device,T=this.core.optionsService.rawOptions,A=this.core._coreBrowserService.dpr,$=r*w.cell.width;v.save(),v.beginPath(),v.rect(i,s,$,w.cell.height),v.clip(),yd(f)&&(v.globalAlpha=Gd);const R=Math.max(1,Math.floor(T.fontSize*A/15)),O=R%2===1?.5:0;if(b){const j=aS(h);let Y=m;if(j){let Q=j;this.boldBright()&&zo(c)&&(Q&50331648)!==50331648&&(Q&255)<8&&(Q+=8),Y=my(Q,this.colors(),m)}v.strokeStyle=Y,v.lineWidth=R;const se=s+w.char.top+Math.ceil(w.char.height)-O-R*2,fe=h?lS(h):ls.SINGLE;switch(v.beginPath(),fe){case ls.DOUBLE:v.moveTo(i,se),v.lineTo(i+$,se),v.moveTo(i,se+R*2),v.lineTo(i+$,se+R*2);break;case ls.CURLY:{const Q=se+R,K=Math.max(1,R);for(let q=0;q<r;q++){const ue=i+q*w.cell.width,ye=ue+w.cell.width/2,Ne=ue+w.cell.width;v.moveTo(ue,Q),v.bezierCurveTo(ue,Q-K,ye,Q-K,ye,Q),v.bezierCurveTo(ye,Q+K,Ne,Q+K,Ne,Q)}break}case ls.DOTTED:v.setLineDash([R,R]),v.moveTo(i,se),v.lineTo(i+$,se);break;case ls.DASHED:{const Q=Math.floor(.6*w.cell.width),K=Math.floor(.3*w.cell.width);v.setLineDash([Q,K,w.cell.width-Q-K]),v.moveTo(i,se),v.lineTo(i+$,se);break}default:v.moveTo(i,se),v.lineTo(i+$,se)}v.stroke(),v.setLineDash([])}if(y&&(v.strokeStyle=m,v.lineWidth=R,v.beginPath(),v.moveTo(i,s+w.char.top+O),v.lineTo(i+$,s+w.char.top+O),v.stroke()),p){const j=Math.max(1,Math.floor(T.fontSize*A/10)),Y=s+w.char.top+Math.floor(w.char.height/2)-(j%2===1?.5:0);v.strokeStyle=m,v.lineWidth=j,v.beginPath(),v.moveTo(i,Y),v.lineTo(i+$,Y),v.stroke()}v.restore()}paintCursorShape(i,s,r,c){const f=this.ctx,h=this.dimensions.device,m=this.core._coreBrowserService.dpr,b=this.colors();switch(f.save(),f.fillStyle=b.cursor.css,f.strokeStyle=b.cursor.css,c){case 2:f.fillRect(i,s,Math.max(1,Math.round(this.core.optionsService.rawOptions.cursorWidth*m)),h.cell.height);break;case 3:f.fillRect(i,s+h.cell.height-Math.max(1,Math.round(m))-1,r,Math.max(1,Math.round(m)));break;case 4:{const p=Math.max(1,Math.round(m));f.lineWidth=p,f.strokeRect(i+p/2,s+p/2,r-p,h.cell.height-p);break}}f.restore()}fillCells(i,s,r,c){const f=this.dimensions.device;this.ctx.fillStyle=c,this.ctx.fillRect(i*f.cell.width,s*f.cell.height,r*f.cell.width,f.cell.height)}fillBackground(){this.ctx.fillStyle=this.colors().background.css,this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}cursorState(i){const s=this.core,r=this.buffer();let c,f;if(i&&i.cursor!==void 0){if(i.cursor===null)return null;c=i.cursor.row,f=i.cursor.col}else{if(!s.coreService.isCursorInitialized||s.coreService.isCursorHidden)return null;c=r.ybase+r.y,f=r.x}const h=c-r.ydisp;if(h<0||h>=this.rows)return null;const m=Math.min(Math.max(0,f),this.cols-1),b=s.optionsService.rawOptions;let p;if(s._coreBrowserService.isFocused)this.blinkTimer&&!this.blinkVisible?p=0:p=Og(b.cursorStyle||"block");else{const y=b.cursorInactiveStyle??"outline";p=y==="none"?0:Og(y)}return p===0?null:{x:m,y:h,shape:p}}restartBlink(){if(this.stopBlink(),this.blinkVisible=!0,this.disposed||!this.core.optionsService.rawOptions.cursorBlink||!this.core._coreBrowserService.isFocused){this.requestCursorRow();return}this.blinkTimer=setInterval(()=>{this.blinkVisible=!this.blinkVisible,this.requestCursorRow()},wS),this.requestCursorRow()}stopBlink(){this.blinkTimer&&clearInterval(this.blinkTimer),this.blinkTimer=null,this.blinkVisible=!0}requestCursorRow(){if(!this.rows)return;const i=this.buffer(),s=new Set;s.add(i.ybase+i.y),this.paintedCursorRow>=0&&s.add(this.paintedCursorRow+i.ydisp),this.requestAbsoluteRows(s)}redrawDecor(){var b;const i=this.decorCtx;i.clearRect(0,0,this.decorCanvas.width,this.decorCanvas.height);const s=this.dimensions.device;if(!s.cell.width||!this.rows)return;const r=this.colors(),c=this.buffer().ydisp,f=(p,y,v,w)=>i.fillRect(p*s.cell.width,y*s.cell.height,v*s.cell.width,w*s.cell.height),h=this.selection;if(h){const p=h.start[1]-c,y=h.end[1]-c,v=Math.max(p,0),w=Math.min(y,this.rows-1);if(v<this.rows&&w>=0)if(i.fillStyle=(this.core._coreBrowserService.isFocused?r.selectionBackgroundTransparent:r.selectionInactiveBackgroundTransparent).css,h.columnSelectMode)f(h.start[0],v,h.end[0]-h.start[0],w-v+1);else{const T=p===v?h.start[0]:0,A=v===y?h.end[0]:this.cols;f(T,v,A-T,1),f(0,v+1,this.cols,Math.max(w-v-1,0)),v!==w&&f(0,w,y===w?h.end[0]:this.cols,1)}}const m=this.link;if(m){const p=this.core._coreBrowserService.dpr;i.fillStyle=m.fg===257?r.background.css:m.fg!==void 0&&m.fg<256?((b=r.ansi[m.fg])==null?void 0:b.css)??r.foreground.css:r.foreground.css;const y=(v,w,T)=>i.fillRect(v*s.cell.width,(w+1)*s.cell.height-p-1,T*s.cell.width,p);if(m.y1===m.y2)y(m.x1,m.y1,m.x2-m.x1);else{y(m.x1,m.y1,m.cols-m.x1);for(let v=m.y1+1;v<m.y2;v++)y(0,v,m.cols);y(0,m.y2,m.x2)}}}updateDimensions(i,s){const r=this.core._charSizeService;if(!r.hasValidSize)return;const c=this.core._coreBrowserService.dpr,f=this.core.optionsService.rawOptions,h=this.dimensions;h.device.char.width=Math.floor(r.width*c),h.device.char.height=Math.ceil(r.height*c),h.device.cell.height=Math.floor(h.device.char.height*f.lineHeight),h.device.char.top=f.lineHeight===1?0:Math.round((h.device.cell.height-h.device.char.height)/2),h.device.cell.width=h.device.char.width+Math.round(f.letterSpacing),h.device.char.left=Math.floor(f.letterSpacing/2),h.device.canvas.height=s*h.device.cell.height,h.device.canvas.width=i*h.device.cell.width,h.css.canvas.height=Math.round(h.device.canvas.height/c),h.css.canvas.width=Math.round(h.device.canvas.width/c),h.css.cell.height=h.css.canvas.height/s,h.css.cell.width=h.css.canvas.width/i,this.dprUsed=c}resizeGrid(i,s){this.cols=i,this.rows=s;const r=i*s;this.painted={content:new Uint32Array(r).fill(or),fg:new Uint32Array(r),bg:new Uint32Array(r),ext:new Uint32Array(r),meta:new Uint32Array(r).fill(or),combined:new Array(r).fill("")},this.row={content:new Uint32Array(i),fg:new Uint32Array(i),bg:new Uint32Array(i),ext:new Uint32Array(i),combined:new Array(i).fill("")},this.paintedOverlayRows.clear(),this.paintedCursorRow=-1}configureAtlas(){const i=this.dimensions.device,s=this.core.optionsService.rawOptions;this.atlas.configure({cellWidth:i.cell.width,cellHeight:i.cell.height,charWidth:i.char.width,charHeight:i.char.height,charLeft:i.char.left,charTop:i.char.top,dpr:this.core._coreBrowserService.dpr},{fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,customGlyphs:s.customGlyphs!==!1})}invalidateAll(){this.painted.content.fill(or),this.painted.meta.fill(or),this.paintedCursorRow=-1}observeDevicePixels(){const i=this.core._coreBrowserService.window;if(!i||typeof i.ResizeObserver!="function")return;let s=new i.ResizeObserver(r=>{var p;const c=r.find(y=>y.target===this.canvas);if(!c)return;if(!("devicePixelContentBoxSize"in c)||!((p=c.devicePixelContentBoxSize)!=null&&p[0])){s==null||s.disconnect(),s=null;return}const f=c.devicePixelContentBoxSize[0].inlineSize,h=c.devicePixelContentBoxSize[0].blockSize;if(f<=0||h<=0||f===this.canvas.width&&h===this.canvas.height)return;const m=this.core._coreBrowserService.dpr,b=this.dimensions.css.canvas;if(!(Math.abs(f-b.width*m)>2||Math.abs(h-b.height*m)>2)){this.dimensions.device.canvas.width=f,this.dimensions.device.canvas.height=h;for(const y of[this.canvas,this.decorCanvas])y.width=f,y.height=h;this.invalidateAll(),this.fillBackground(),this.redrawDecor(),this.redraw.fire({start:0,end:Math.max(0,this.rows-1)})}});try{s.observe(this.canvas,{box:"device-pixel-content-box"})}catch{s.disconnect(),s=null}this.disposables.push({dispose:()=>s==null?void 0:s.disconnect()})}observeFonts(i){const s=i.fonts;if(!s||typeof s.addEventListener!="function")return;const r=()=>this.clearTextureAtlas();s.addEventListener("loadingdone",r),this.disposables.push({dispose:()=>s.removeEventListener("loadingdone",r)})}buffer(){return this.core._bufferService.buffer}colors(){return this.core._themeService.colors}boldBright(){return this.core.optionsService.rawOptions.drawBoldTextInBrightColors!==!1}requestAbsoluteRows(i){if(!this.rows)return;const s=this.buffer().ydisp;let r=1/0,c=-1/0;for(const f of i){const h=f-s;h<0||h>=this.rows||(r=Math.min(r,h),c=Math.max(c,h))}r<=c&&this.redraw.fire({start:r,end:c})}}function Og(l){switch(l){case"bar":return 2;case"underline":return 3;case"outline":return 4;default:return 1}}function TS(l){if(!l)return[];const i=l.cells.map(s=>s.row);return l.cursor&&i.push(l.cursor.row),i}function Ho(l,i,s){i>=0&&i<s&&l.add(i)}const mr="herdr_remote_renderer_probe_v3",MS=30,yy=640,vy=240,Uo=1,AS=720*60*60*1e3,Yd={};function xy(){let l=null;if(typeof window>"u")l=Yd[mr]||null;else try{l=window.localStorage?window.localStorage.getItem(mr):null}catch{l=Yd[mr]||null}if(!l)return{v:Uo,ua:{}};try{const i=JSON.parse(l);return typeof i=="object"&&i!==null&&i.v===Uo&&typeof i.ua=="object"&&i.ua!==null?i:{v:Uo,ua:{}}}catch{return{v:Uo,ua:{}}}}function ES(l,i=Date.now()){var c;const s=xy();s.ua[l]={failedAt:i};const r=JSON.stringify(s);if(Yd[mr]=r,typeof window<"u")try{(c=window.localStorage)==null||c.setItem(mr,r)}catch(f){console.warn("Failed to write renderer probe result to localStorage:",f)}}function NS(l,i=Date.now()){const s=typeof navigator<"u"?navigator.userAgent:"";if(!s)return!1;const c=xy().ua[s];return!(!c||typeof c.failedAt!="number"||i-c.failedAt>AS)}function zg(l,i=Date.now()){const s=typeof navigator<"u"?navigator.userAgent:"";s&&ES(s,i)}function kS(l){if(l.length<4)return!0;const i=l[0],s=l[1],r=l[2],c=l[3];for(let f=4;f<l.length;f+=4)if(l[f]!==i||l[f+1]!==s||l[f+2]!==r||l[f+3]!==c)return!1;return!0}function RS(l){if(!l||l.width<=0||l.height<=0)return console.debug("Canvas probe inconclusive: text layer canvas missing or zero dimensions"),"inconclusive";let i=null;try{i=l.getContext("2d",{willReadFrequently:!0})||l.getContext("2d")}catch(c){return console.debug("Canvas probe inconclusive: failed to acquire 2D context:",c),"inconclusive"}if(!i)return console.debug("Canvas probe inconclusive: 2D context is null"),"inconclusive";const s=Math.min(l.width,yy),r=Math.min(l.height,vy);if(s<=0||r<=0)return console.debug("Canvas probe inconclusive: calculated sample dimensions are zero"),"inconclusive";try{const c=i.getImageData(0,0,s,r);return kS(c.data)?"blank":"healthy"}catch(c){return console.debug("Canvas probe inconclusive: getImageData threw exception:",c),"inconclusive"}}function Bg(l=2){return new Promise(i=>{if(typeof requestAnimationFrame!="function"){setTimeout(i,32);return}let s=l;const r=()=>{s--,s<=0?i():requestAnimationFrame(r)};requestAnimationFrame(r)})}const vd={kind:"dom",canvas:null,dispose:()=>{},verify:async()=>{}};function LS(l,i={}){if(NS())return vd;let s;try{s=of.install(l,{isSynchronizing:i.isSynchronizing})}catch(m){return console.debug("Canvas renderer unavailable, using the DOM renderer:",m),zg(),vd}if(!s)return vd;let r=s,c=null;const f=()=>{var b;if(!r)return;zg();const m=r;r=null;try{m.uninstall()}catch{}(b=i.onRendererSwapped)==null||b.call(i,"dom")};return{get kind(){return r?"canvas":"dom"},get canvas(){return r},dispose:()=>{const m=r;r=null;try{m==null||m.dispose()}catch{}},verify:async()=>{if(r)return c||(c=(async()=>{try{const m=r.stats.frames;await Bg(2);for(let p=0;p<MS&&r&&r.stats.frames===m;p++)await Bg(1);if(!r)return;const b=RS(r.textCanvas);b==="blank"&&r.hasPaintedInk(yy,vy)?f():b==="blank"?console.debug("Canvas probe inconclusive: uniform, but no character was painted there"):b==="inconclusive"&&console.debug("Canvas probe inconclusive; retaining canvas renderer without blacklisting")}catch(m){console.debug("Canvas probe inconclusive: unexpected error during verify():",m)}finally{c=null}})(),c)}}}function Hg(l,i){const s=typeof window<"u"?window:void 0,r=s&&typeof s.devicePixelRatio=="number"&&s.devicePixelRatio>0?s.devicePixelRatio:1,c=s&&s.visualViewport&&typeof s.visualViewport.scale=="number"&&s.visualViewport.scale>0?s.visualViewport.scale:1,f=Math.max(0,l.width),h=Math.max(0,l.height),m=Math.round(f*r*100)/100,b=Math.round(h*r*100)/100;return{dpr:r,scale:c,cssWidth:f,cssHeight:h,physicalWidth:m,physicalHeight:b}}function _S(l){const{lastSnapshot:i,currentSnapshot:s,physicalTolerancePx:r=6}=l;if(!i)return{shouldIgnore:!1,isVisualZoom:!1,reason:"initial"};const c=Math.abs(s.scale-i.scale)>.01,f=Math.abs(s.scale-1)>.01;if(c||f)return{shouldIgnore:!0,isVisualZoom:!0,reason:"visual_pinch_zoom"};if(Math.abs(s.dpr-i.dpr)>.01){const p=Math.abs(s.physicalWidth-i.physicalWidth),y=Math.abs(s.physicalHeight-i.physicalHeight);if(p<=r&&y<=r)return{shouldIgnore:!0,isVisualZoom:!0,reason:"dpr_zoom"}}const m=Math.abs(s.cssWidth-i.cssWidth),b=Math.abs(s.cssHeight-i.cssHeight);return m<1&&b<1?{shouldIgnore:!0,isVisualZoom:!1,reason:"no_box_change"}:{shouldIgnore:!1,isVisualZoom:!1,reason:"genuine_resize"}}const jS=" ()[]{}'\"\\`";function xd(l,i,s,r=1){var R,O;if(!i||!((R=i.buffer)!=null&&R.active)||i.cols<=0||i.rows<=0)return null;const c=s||((O=i.element)==null?void 0:O.querySelector(".xterm-screen"))||i.element;if(!c||typeof c.getBoundingClientRect!="function")return null;const f=c.getBoundingClientRect(),h=cy(l.clientX,l.clientY,f,r),m=fa(i);if(m.cellWidth<=0||m.cellHeight<=0)return null;const b=Math.max(1,f.width||i.cols*m.cellWidth),p=Math.max(1,f.height||i.rows*m.cellHeight),y=Math.max(0,Math.min(b-1,h.clientX-f.left)),v=Math.max(0,Math.min(p-1,h.clientY-f.top)),w=Math.max(0,Math.min(i.cols-1,Math.floor(y/m.cellWidth))),T=Math.max(0,Math.min(i.rows-1,Math.floor(v/m.cellHeight))),$=(i.buffer.active.viewportY??0)+T;return{col:w,bufferRow:$}}function DS(l,i){if(!l||l.length===0||l==="\0")return!0;for(const s of l)if(s==="\0"||/\s/.test(s)||i.includes(s))return!0;return!1}function OS(l,i,s){var w,T;if(!l||!((w=l.buffer)!=null&&w.active)||i<0||i>=l.cols)return null;const r=l.buffer.active.getLine(s);if(!r)return null;const c=((T=l.options)==null?void 0:T.wordSeparator)??jS,f=new Array(l.cols).fill(null),h=Math.min(l.cols,r.length);let m=0;for(;m<h;){const A=r.getCell(m);if(!A){f[m]={startCol:m,endCol:m+1,isSeparator:!0},m++;continue}const $=A.getWidth();if($===0){f[m]||(f[m]={startCol:m,endCol:m+1,isSeparator:!0}),m++;continue}const R=A.getChars(),O=DS(R,c),j=Math.min(l.cols,m+$),Y={startCol:m,endCol:j,isSeparator:O};for(let se=m;se<j;se++)f[se]=Y;m+=Math.max(1,$)}for(let A=h;A<l.cols;A++)f[A]||(f[A]={startCol:A,endCol:A+1,isSeparator:!0});const b=f[i];if(!b||b.isSeparator)return null;let p=b.startCol;for(;p>0;){const A=f[p-1];if(A&&!A.isSeparator)p=A.startCol;else break}let y=b.endCol;for(;y<l.cols;){const A=f[y];if(A&&!A.isSeparator)y=A.endCol;else break}const v=y-p;return v<=0?null:{startCol:p,length:v}}function zS(l){var f;if(!l||!((f=l.buffer)!=null&&f.active))return"";const i=l.buffer.active,s=i.viewportY??0,r=l.rows,c=[];for(let h=0;h<r;h++){const m=i.getLine(s+h);c.push(m?m.translateToString(!0):"")}for(;c.length>0&&c[c.length-1]==="";)c.pop();return c.join(`
45
- `)}const Ug=new Set(["│","┃","╎","╏","┆","┇","┊","┋","║","▏","▕","|"]),BS=.6,HS=new Set(["─","━","═","┄","┅","┈","┉","-"]),US=.8;function wd(l,i){if(!l)return!1;let s=0;const r=Math.min(i,l.length);for(let c=0;c<r;c++){const f=l.getCell(c);if(f){const h=f.getChars();h&&HS.has(h)&&s++}}return s>=Math.max(5,Math.min(i*.25,10))}function Sd(l,i,s){var T;if(!l||!((T=l.buffer)!=null&&T.active)||l.cols<=0)return{startCol:0,endCol:0};const r=l.buffer.active,c=l.cols,f=Math.max(0,Math.min(c-1,i)),h=r.viewportY??0,m=l.rows>0?l.rows:1,b=new Int32Array(c);let p=0;for(let A=0;A<m;A++){const $=r.getLine(h+A);if(p++,!$)continue;const R=Math.min(c,$.length);for(let O=0;O<R;O++){const j=$.getCell(O);if(j){const Y=j.getChars();Y&&Ug.has(Y)&&b[O]++}}}if(p===0)return{startCol:0,endCol:c-1};const y=p*BS,v=A=>b[A]>=y;let w=!1;for(let A=0;A<c;A++)if(v(A)){w=!0;break}if(w){if(v(f))return{startCol:f,endCol:f};let A=-1;for(let R=f-1;R>=0;R--)if(v(R)){A=R;break}let $=c;for(let R=f+1;R<c;R++)if(v(R)){$=R;break}return{startCol:A+1,endCol:$-1}}if(s!==void 0){const A=Math.max(h,Math.min(h+m-1,s)),$=r.getLine(A);if(!wd($,c)){let R=h;for(let Y=A-1;Y>=h;Y--)if(wd(r.getLine(Y),c)){R=Y+1;break}let O=h+m-1;for(let Y=A+1;Y<=h+m-1;Y++)if(wd(r.getLine(Y),c)){O=Y-1;break}const j=O-R+1;if(j>=2){const Y=new Int32Array(c);for(let K=R;K<=O;K++){const q=r.getLine(K);if(!q)continue;const ue=Math.min(c,q.length);for(let ye=0;ye<ue;ye++){const Ne=q.getCell(ye);if(Ne){const ie=Ne.getChars();ie&&Ug.has(ie)&&Y[ye]++}}}const se=j*US,fe=K=>Y[K]>=se;let Q=!1;for(let K=0;K<c;K++)if(fe(K)){Q=!0;break}if(Q){if(fe(f))return{startCol:f,endCol:f};let K=-1;for(let ue=f-1;ue>=0;ue--)if(fe(ue)){K=ue;break}let q=c;for(let ue=f+1;ue<c;ue++)if(fe(ue)){q=ue;break}return{startCol:K+1,endCol:q-1}}}}}return{startCol:0,endCol:c-1}}function Kg(l,i){const s=Math.min(l.startCol,l.endCol),r=Math.max(l.startCol,l.endCol),c=Math.min(l.startRow,l.endRow),f=Math.max(l.startRow,l.endRow);return{startCol:Math.max(i.startCol,Math.min(i.endCol,s)),endCol:Math.max(i.startCol,Math.min(i.endCol,r)),startRow:c,endRow:f}}function Cd(l,i){var p;if(!l||!((p=l.buffer)!=null&&p.active)||l.cols<=0)return"";const s=l.buffer.active,r=l.cols,c=Math.min(i.startRow,i.endRow),f=Math.max(i.startRow,i.endRow),h=Math.max(0,Math.min(i.startCol,i.endCol)),m=Math.min(r-1,Math.max(i.startCol,i.endCol));if(h>m||c>f)return"";const b=[];for(let y=c;y<=f;y++){const v=s.getLine(y);if(!v){b.push("");continue}const w=v.translateToString(!0,h,m+1);b.push(w.trimEnd())}return b.join(`
46
- `)}async function Kl(l){if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(l),"clipboard"}catch{}if(typeof document<"u"&&typeof document.execCommand=="function"){let i=null,s=null,r=null;try{if(i=document.createElement("textarea"),i.style.userSelect="text",i.style.webkitUserSelect="text",i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.width="1px",i.style.height="1px",i.style.padding="0",i.style.border="none",i.style.outline="none",i.style.boxShadow="none",i.style.background="transparent",i.style.opacity="0",i.style.fontSize="16px",i.setAttribute("readonly",""),i.setAttribute("aria-hidden","true"),i.value=l,typeof window<"u"&&typeof window.getSelection=="function"&&(r=window.getSelection(),r&&r.rangeCount>0&&(s=r.getRangeAt(0))),document.body.appendChild(i),typeof navigator<"u"&&(/iPad|iPhone|iPod/.test(navigator.userAgent||"")||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1)){const h=document.createRange();h.selectNodeContents(i),r&&(r.removeAllRanges(),r.addRange(h)),i.setSelectionRange(0,l.length)}else i.focus({preventScroll:!0}),i.select();if(document.execCommand("copy"))return"exec"}catch{}finally{i&&i.parentNode&&i.parentNode.removeChild(i),r&&(r.removeAllRanges(),s&&r.addRange(s))}}return"failed"}async function KS(){if(!(typeof window>"u"||window.isSecureContext!==!1)||typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.readText!="function")return{ok:!1,reason:"insecure"};try{const i=await navigator.clipboard.readText();return!i||i.length===0?{ok:!1,reason:"empty"}:{ok:!0,text:i}}catch(i){return typeof window<"u"&&window.isSecureContext===!1?{ok:!1,reason:"insecure"}:(i==null?void 0:i.name)==="SecurityError"?{ok:!1,reason:"insecure"}:{ok:!1,reason:"denied"}}}async function IS(){if(!(typeof window>"u"||window.isSecureContext!==!1)||typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.read!="function")return{ok:!1,reason:"insecure"};try{const i=await navigator.clipboard.read();if(!i||i.length===0)return{ok:!1,reason:"empty"};for(const s of i){const r=s.types.find(c=>c.startsWith("image/"));if(r){const c=await s.getType(r);if(c&&c.size>0)return{ok:!0,blob:c}}}return{ok:!1,reason:"empty"}}catch(i){if(typeof window<"u"&&window.isSecureContext===!1)return{ok:!1,reason:"insecure"};const s=i==null?void 0:i.name;return s==="SecurityError"?{ok:!1,reason:"insecure"}:s==="NotAllowedError"?{ok:!1,reason:"denied"}:{ok:!1,reason:"empty"}}}function wy(l){const i=l.clipboardData;if(!i)return null;if(i.files&&i.files.length>0)for(let s=0;s<i.files.length;s++){const r=i.files[s];if(r&&r.type.startsWith("image/"))return r}if(i.items&&i.items.length>0)for(let s=0;s<i.items.length;s++){const r=i.items[s];if(r&&r.type.startsWith("image/")){const c=r.getAsFile();if(c)return c}}return null}function FS(l){if(!l||l.length===0)return null;for(let i=0;i<l.length;i++){const s=l[i];if(s&&(s.type.startsWith("image/")||/\.(png|jpe?g|webp|gif)$/i.test(s.name)))return s}return null}const Td="Herdr Remote",Ig=80,GS=/[\u0000-\u001F\u007F-\u009F]/g;function $d(l){if(typeof l!="string")return"";const i=l.replace(GS," ").replace(/\s+/g," ").trim();return i.length<=Ig?i:`${i.slice(0,Ig-1).trimEnd()}…`}function YS(l,i,s){const r=Nw(s??null),c=r?`${r} `:"",f=$d(l);if(f)return`${c}${f} · ${Td}`;const h=$d(i);return h?`${c}${h} · ${Td}`:`${c}${Td}`}function $S(l,i,s){const r=YS(l,i,s);return typeof document<"u"&&(document.title=r),r}const qS=new Set(["http:","https:","mailto:"]),Md=/(?:https?:\/\/|mailto:|www\.)[^\s"'<>`]+/gi,VS=/[.,;:!?'"]+$/,Fg=8;function cf(l){return/^www\./i.test(l)?`https://${l}`:l}function XS(l){const i=(c,f)=>c.split(f).length-1;let s=l.replace(VS,"");const r=[["(",")"],["[","]"],["{","}"]];for(const[c,f]of r)for(;s.endsWith(f)&&i(s,f)>i(s,c);)s=s.slice(0,-1);return s}function Sy(l){if(typeof l!="string"||l.length===0)return!1;try{return qS.has(new URL(cf(l)).protocol)}catch{return!1}}function PS(l,i){if(typeof l!="string"||i<0)return null;Md.lastIndex=0;for(let s=Md.exec(l);s;s=Md.exec(l)){const r=XS(s[0]);if(!r)continue;const c=s.index,f=c+r.length;if(i>=c&&i<f&&Sy(r))return r}return null}function ZS(l,i,s){var m;const r=(m=l==null?void 0:l.buffer)==null?void 0:m.active;if(!r||typeof r.getLine!="function"||!r.getLine(s))return null;let c=s;for(let b=0;b<Fg;b+=1){const p=r.getLine(c);if(!(p!=null&&p.isWrapped)||c===0)break;c-=1}let f="",h=-1;for(let b=c;b<c+Fg;b+=1){const p=r.getLine(b);if(!p||b>c&&!p.isWrapped)break;b===s&&(h=f.length+i),f+=p.translateToString(!1)}return h<0?null:{text:f,index:h}}function QS(l,i,s){const r=ZS(l,i,s);return r?PS(r.text,r.index):null}function WS(l){try{const i=new URL(cf(l));return i.host||i.pathname}catch{return""}}function Ad(l){return!Sy(l)||typeof window>"u"||typeof window.open!="function"?!1:(window.open(cf(l),"_blank","noopener,noreferrer"),!0)}const ts="tui-focusable group flex h-11 w-full select-none items-center gap-2 border px-2 text-left text-tui transition-colors",ns="border-tui-border text-tui-muted hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",JS=({anchorPoint:l,hasSelection:i,isController:s,vibrateOnKeyPress:r=!1,linkUrl:c=null,onOpenLink:f,onCopySelection:h,onCopyLine:m,onCopyScreen:b,onPaste:p,onClose:y})=>{const{t:v}=rt(),w=S.useRef(null),[T,A]=S.useState(null);S.useEffect(()=>{if(r&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(8)}catch{}},[r]),S.useLayoutEffect(()=>{const j=w.current;if(!j||!j.parentElement)return;const Y=j.parentElement.getBoundingClientRect(),se=j.getBoundingClientRect(),fe=se.width||208,Q=se.height||220,K=Y.width,q=Y.height;let ue=l.x-fe/2;ue=Math.max(8,Math.min(Math.max(8,K-fe-8),ue));let ye=l.y-Q-8;ye<8&&(ye=l.y+8),ye=Math.max(8,Math.min(Math.max(8,q-Q-8),ye)),A({x:ue,y:ye})},[l.x,l.y,i,s,c]);const $=Math.max(8,l.x-104),R=Math.max(8,l.y-200),O={position:"absolute",left:`${T?T.x:$}px`,top:`${T?T.y:R}px`,visibility:T?"visible":"hidden"};return d.jsx("div",{ref:w,role:"menu","aria-label":"终端选择操作",className:"z-50 w-52 select-none font-mono",style:O,onMouseDown:j=>j.stopPropagation(),onTouchStart:j=>j.stopPropagation(),onPointerDown:j=>j.stopPropagation(),children:d.jsxs(gn,{tone:"accent",className:"border border-tui-border bg-tui-base p-1.5 shadow-lg",bodyClassName:"flex flex-col gap-1",children:[c&&f&&d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:()=>{f(c),y()},children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.openLink")}),d.jsx("span",{className:"ml-auto max-w-[45%] truncate text-tui-faint",children:WS(c)})]}),i&&d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:()=>{h(),y()},children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.copySelection")})]}),d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:()=>{m(),y()},children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.copyLine")})]}),d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:()=>{b(),y()},children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.copyScreen")})]}),s&&d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:()=>{p(),y()},children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.paste")})]}),d.jsxs("button",{type:"button",role:"menuitem",className:ne(ts,ns),onClick:y,children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint group-hover:text-tui-accent",children:Fe.cursor}),d.jsx("span",{className:"truncate",children:v("clipboard.cancel")})]})]})})},eC=({isOpen:l,onClose:i,onSend:s,onSendImage:r})=>{const{t:c,addToast:f}=rt(),[h,m]=S.useState(""),[b,p]=S.useState(null),[y,v]=S.useState(!1),w=S.useRef(null),T=S.useRef(null),A=S.useRef(null);S.useEffect(()=>{l&&(m(""),p(null),v(!1),w.current&&(w.current.value=""),T.current&&(T.current.value=""))},[l]);const $=async Q=>{if(Q.size===0){f("error",c("clipboard.fileEmpty"));return}v(!0);try{const K=await zb(Q);K?(p(K),m("")):f("error",c("clipboard.imageTooLarge"))}catch(K){console.error("Failed to process image:",K),f("error",c("clipboard.imageTooLarge"))}finally{v(!1)}},R=async Q=>{const K=wy(Q);K&&(Q.preventDefault(),await $(K))},O=async Q=>{const K=FS(Q.target.files);Q.target.value="",K&&await $(K)},j=Q=>{const K=Q.target.value;m(K),K&&b&&p(null)},Y=()=>{p(null),w.current&&(w.current.value=""),T.current&&(T.current.value="")},se=()=>{b?(r==null||r(b),i()):h.trim()&&(s(h),i())},fe=!!(h.trim()||b);return d.jsx(tc,{isOpen:l,onClose:i,title:c("clipboard.pasteTitle"),closeLabel:c("clipboard.cancel"),size:"sm",footer:d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[d.jsx(Oe,{variant:"ghost",onClick:i,children:c("clipboard.cancel")}),d.jsx(Oe,{variant:"primary",onClick:se,disabled:!fe||y,children:c("clipboard.pasteSend")})]}),children:d.jsxs("div",{className:"flex flex-col gap-3 p-3 font-mono select-text",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{htmlFor:"paste-fallback-input",className:"text-tui-sm text-tui-muted font-sans font-medium",children:c("clipboard.pasteHint")}),d.jsx("textarea",{ref:A,id:"paste-fallback-input","data-testid":"paste-fallback-input",rows:4,autoFocus:!0,placeholder:c("clipboard.pasteHint"),value:h,onChange:j,onPaste:R,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"})]}),d.jsxs("div",{className:"relative my-1",children:[d.jsx("div",{className:"absolute inset-0 flex items-center",children:d.jsx("div",{className:"w-full border-t border-tui-border"})}),d.jsx("div",{className:"relative flex justify-center text-tui-xs uppercase",children:d.jsx("span",{className:"bg-tui-bg px-2 text-tui-muted font-sans",children:c("clipboard.imageSectionTitle")})})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("input",{ref:w,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",className:"hidden","data-testid":"paste-fallback-file-input",onChange:O}),d.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",capture:"environment",className:"hidden","data-testid":"paste-fallback-camera-input",onChange:O}),b?d.jsxs("div",{className:"flex flex-col items-center gap-2 p-3 border border-tui-border bg-tui-bg rounded",children:[d.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"}),d.jsxs("div",{className:"flex items-center justify-between w-full text-tui-xs text-tui-muted pt-1",children:[d.jsx("span",{children:c("clipboard.imageCompressedSize",{size:vw(b.byteLength)})}),d.jsx(Oe,{variant:"ghost",onClick:Y,"aria-label":c("clipboard.removeImage"),children:c("clipboard.cancel")})]})]}):d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx(Oe,{variant:"default",onClick:()=>{var Q;return(Q=w.current)==null?void 0:Q.click()},disabled:y||!!h.trim(),className:"min-h-[44px] px-3 touch-manipulation text-tui-sm font-sans flex-1","aria-label":c("clipboard.chooseImage"),children:c("clipboard.chooseImage")}),d.jsx(Oe,{variant:"default",onClick:()=>{var Q;return(Q=T.current)==null?void 0:Q.click()},disabled:y||!!h.trim(),className:"min-h-[44px] px-3 touch-manipulation text-tui-sm font-sans flex-1","aria-label":c("clipboard.takePhoto"),children:c("clipboard.takePhoto")})]}),y&&d.jsx("div",{className:"flex items-center gap-2 text-tui-xs text-tui-muted animate-pulse",children:d.jsx("span",{children:c("clipboard.imageCompressing")})})]})]})})},tC=[[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 Gg(l){if(l>=32&&l<=126)return 1;if(l<12288)return 0;for(const[i,s]of tC){if(l<i)return 0;if(l<=s)return 2}return 0}const nC=2,iC="?!#",Yg=8,lC=1500,aC=4e3,sC=20;function Wi(l){return l===""||l===" "?" ":l}function rC(l,i,s,r=64){var h;const c=l.buffer.active.getLine(i),f=[];for(let m=s-1;m>=0&&f.length<r;m--){const b=c==null?void 0:c.getCell(m);if(!b)break;((h=b.getWidth)==null?void 0:h.call(b))!==0&&f.unshift(Wi(b.getChars()))}return f}function oC(l,i){for(let s=Math.min(l.length,i.length);s>0;s--){let r=!0;for(let c=0;c<s&&r;c++)r=i[i.length-s+c]===Wi(l[c]);if(r)return s}return 0}function cC(l){const i=l.buffer.active;return{key:"legacy",row:i.baseY+i.cursorY,caretCol:i.cursorX,startCol:i.cursorX,endCol:l.cols,empty:!1,agentLike:!1}}class uC{constructor(i){Z(this,"getTerminal");Z(this,"getFieldOption");Z(this,"charWidth");Z(this,"now");Z(this,"textDecoder",new TextDecoder("utf-8"));Z(this,"confidentKeys",new Set);Z(this,"fieldStyles",new Map);Z(this,"field",null);Z(this,"runStartedEmpty",!1);Z(this,"predictions",[]);Z(this,"predictedCursor",null);Z(this,"srtt",null);Z(this,"isSuppressed",!1);Z(this,"suppressCursor",null);Z(this,"suppressSentAt",0);Z(this,"inFlight",[]);Z(this,"inFlightUnknown",!1);Z(this,"runInFlight",[]);Z(this,"probationRun",!1);Z(this,"runSent",[]);Z(this,"lastSentUndrawn",!1);Z(this,"awaitingPrefixCommand",!1);Z(this,"mismatches",0);Z(this,"trace",[]);this.getTerminal=i.getTerminal,this.getFieldOption=i.getField,this.charWidth=i.charWidth,this.now=i.now??(typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now())}handleUserInput(i){var h;if(this.pruneExpired(),i.length===0)return;const s=this.textDecoder.decode(i,{stream:!1});if(!s)return;const r=sy(s);if(r==="passive")return;if(r==="pointer"){this.freeze("pointer");return}if(this.awaitingPrefixCommand){this.awaitingPrefixCommand=!1,this.freeze("Herdr prefix command",{demote:!0});return}if(P1(s)){const m=this.field??((h=this.getFieldOption)==null?void 0:h.call(this))??null;this.freeze("escape",{demote:!m||m.modal!==!1});return}const c=this.getTerminal();if(!c){this.reset("terminal unavailable",!0);return}const f=Array.from(s);for(let m=0;m<f.length;m++){const b=f[m],p=b.codePointAt(0);if(p===void 0)continue;if(p===nC){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(c))return;continue}if(this.stillSuppressed()){this.inFlight.push(b),this.note("refused: waiting for the caret to move");continue}const y=Gg(p);if(y===0){if(!this.skipUnpredictable(b,p,c)){m<f.length-1&&(this.inFlightUnknown=!0);return}continue}if(!this.handlePrintable(b,y,c)){m<f.length-1&&(this.inFlightUnknown=!0);return}}}onServerOutput(){const i=this.getTerminal(),s=i?{row:i.buffer.active.baseY+i.buffer.active.cursorY,col:i.buffer.active.cursorX}:null;this.pruneExpired(),i&&s&&this.predictions.length>0&&this.settle(i,s),this.updateSuppression(s)}updateSuppression(i){if(!this.isSuppressed)return;if(this.predictions.some(r=>r.frozenFrom)){this.suppressSentAt=this.now();return}!!i&&!!this.suppressCursor&&(i.row!==this.suppressCursor.row||i.col!==this.suppressCursor.col)?this.liftSuppression():this.stillSuppressed()}settle(i,s){var f,h;const r=this.field;if(this.getFieldOption){const m=this.getFieldOption();if(!m||m.key!==(r==null?void 0:r.key)){if(this.predictions.every(b=>b.frozenFrom||b.echoed)){this.predictions=[],this.predictedCursor=null;return}this.mismatch("field changed");return}if(m.layout!==r.layout){this.predictions=[],this.predictedCursor=null,this.field=m,this.note("layout changed");return}}const c=[];for(const m of this.predictions){const b=(f=i.buffer.active.getLine(m.row))==null?void 0:f.getCell(m.col),p=Wi(b?b.getChars():""),y=m.kind==="char"?p===m.char&&(m.width===1||(((h=b==null?void 0:b.getWidth)==null?void 0:h.call(b))??2)===2):p===" ",v=m.kind==="char"?s.row>m.row||s.row===m.row&&s.col>=m.col+m.width:s.row<m.row||s.row===m.row&&s.col<=m.col,w=m.before.includes(p),T=m.kind==="char"&&p===m.char&&!y;if(!(m.echoed&&!y))if(y&&(v||!w)){if(m.echoed||this.confirm(m,r),v){m.kind==="char"&&r&&!m.frozenFrom&&this.learnStyle(r.key,b);continue}m.echoed=!0,c.push(m)}else if(m.frozenFrom){const A=m.frozenFrom;!v&&s.row===A.row&&s.col>=A.col?c.push(m):v&&m.probation&&(this.inFlightUnknown=!0)}else if(!v&&!T)c.push(m);else if(m.probation){this.note("probation guess dropped"),this.predictions.some(A=>!A.frozenFrom&&A.kind==="erase")&&(this.inFlightUnknown=!0),this.inFlight=[...this.runInFlight,...this.runSent,...this.inFlight],this.runInFlight=[],this.runSent=[],this.probationRun=!1,this.predictions=this.predictions.filter(A=>A.frozenFrom),this.predictedCursor=null;return}else{this.mismatch(`cell shows ${JSON.stringify(p)} for ${JSON.stringify(m.char)}`);return}}this.predictions=c,c.length===0&&(this.predictedCursor=null)}reset(i,s){var f;this.predictions=[],this.predictedCursor=null;const r=typeof s=="boolean"?s:(s==null?void 0:s.suppress)??!0,c=typeof s=="object"&&(s==null?void 0:s.demote)===!0;if(this.note(`reset: ${i??"unspecified"}`),c){const h=this.field??((f=this.getFieldOption)==null?void 0:f.call(this))??null;h&&this.confidentKeys.delete(h.key)}if(this.forgetInFlight(),r){this.isSuppressed=!0,this.suppressSentAt=this.now();const h=this.getTerminal();h?this.suppressCursor={row:h.buffer.active.baseY+h.buffer.active.cursorY,col:h.buffer.active.cursorX}:this.suppressCursor=null}else this.isSuppressed=!1,this.suppressCursor=null}forgetConfidence(){this.confidentKeys.clear(),this.fieldStyles.clear(),this.field=null}getVisiblePredictions(){return this.pruneExpired(),this.visiblePredictions().filter(i=>!i.echoed).map(i=>({row:i.row,col:i.col,char:i.char}))}getOverlayItems(){var w,T,A,$,R;this.pruneExpired();const i=this.visiblePredictions();if(i.length===0)return[];const s=this.field?this.fieldStyles.get(this.field.key):void 0,r=i.map(O=>{const j={row:O.row,col:O.col,char:O.char,width:O.width,kind:O.kind};return s&&(j.style=s),j}),c=i[i.length-1],f=this.predictedCursor??{row:c.row,col:c.kind==="erase"?c.col:c.col+c.width},h=(O,j)=>r.some(Y=>Y.row===O&&Y.col<=j&&j<Y.col+Y.width),m=this.getTerminal(),b=m==null?void 0:m.buffer.active,p=this.field;if(b&&p&&this.runStartedEmpty&&p.agentLike&&f.row===p.row){const O=b.getLine(f.row);for(let j=f.col;j<p.endCol;j++){if(h(f.row,j)||Wi(((w=O==null?void 0:O.getCell(j))==null?void 0:w.getChars())??"")===" ")continue;const Y={row:f.row,col:j,char:" ",width:1,kind:"erase"};s&&(Y.style=s),r.push(Y)}}if(b){const O={row:b.baseY+b.cursorY,col:b.cursorX};if(!h(O.row,O.col)&&(O.row!==f.row||O.col!==f.col)){const j=((A=(T=b.getLine(O.row))==null?void 0:T.getCell(O.col))==null?void 0:A.getChars())??"",Y={row:O.row,col:O.col,char:Wi(j),width:1,kind:"mask"};s&&(Y.style=s),r.push(Y)}}const y=r.find(O=>O.row===f.row&&O.col===f.col&&O.kind!=="mask"),v=y?y.char:Wi(((R=($=b==null?void 0:b.getLine(f.row))==null?void 0:$.getCell(f.col))==null?void 0:R.getChars())??"");return r.push({row:f.row,col:f.col,char:v,width:1,kind:"caret"}),r}getState(){return this.field&&this.confidentKeys.has(this.field.key)?"confident":"tentative"}getField(){return this.field}getMismatchCount(){return this.mismatches}getEchoSrttMs(){return this.srtt}getTrace(){return this.trace}visiblePredictions(){const i=this.getState()==="confident";return this.predictions.filter(s=>s.frozenFrom?s.shownWhenFrozen:i&&!s.probation)}freeze(i,s={}){var b;const r=this.getTerminal(),c=r?{row:r.buffer.active.baseY+r.buffer.active.cursorY,col:r.buffer.active.cursorX}:null,f=this.getState()==="confident";for(const p of this.predictions)p.frozenFrom||(p.frozenFrom=c??{row:p.row,col:p.col},p.shownWhenFrozen=f&&!p.probation);const h=this.predictedCursor?{...this.predictedCursor}:c,m=this.inFlight.length>0||this.inFlightUnknown||this.lastSentUndrawn;if(this.predictedCursor=null,this.note(`freeze: ${i}${s.demote?" (demote)":""}`),s.demote){const p=this.field??((b=this.getFieldOption)==null?void 0:b.call(this))??null;p&&this.confidentKeys.delete(p.key)}this.isSuppressed=!0,this.suppressSentAt=this.now(),this.suppressCursor=h,this.forgetInFlight(),this.inFlightUnknown=m}forgetInFlight(){this.inFlight=[],this.inFlightUnknown=!1,this.runInFlight=[],this.runSent=[],this.probationRun=!1,this.lastSentUndrawn=!1}suppressTimeout(){return Math.max(300,(this.srtt??300)*1.5)}predictionTimeout(){return Math.min(aC,Math.max(lC,(this.srtt??0)*4))}stillSuppressed(){return this.isSuppressed?this.now()-this.suppressSentAt>=this.suppressTimeout()?(this.liftSuppression(),!1):!0:!1}liftSuppression(){this.isSuppressed=!1,this.suppressCursor=null}handlePrintable(i,s,r){var v;const c=this.ensureField(r);if(!c||!this.predictedCursor)return this.note("refused: caret is not in an input field"),!1;const f=this.predictedCursor,h=this.predictions.every(w=>w.frozenFrom)&&f.col===c.caretCol;if(c.agentLike&&c.empty&&h&&iC.includes(i))return this.freeze("agent mode switch"),!1;if(f.col+s>c.endCol-1)return this.freeze("cursor would reach the edge of the field"),!1;const m=(v=r.buffer.active.getLine(f.row))==null?void 0:v.getCell(f.col),b=[Wi(m?m.getChars():"")],p=this.predictions[this.predictions.length-1];let y;return p&&p.kind==="erase"&&!p.frozenFrom&&p.row===f.row&&p.col===f.col&&(y=this.predictions.pop(),b.push(...p.before," ")),this.predictions.push({row:f.row,col:f.col,char:i,width:s,kind:"char",before:b,sentAt:this.now(),replaces:y,probation:this.probationRun||void 0}),this.probationRun&&this.runSent.push(i),this.lastSentUndrawn=!1,f.col+=s,!0}skipUnpredictable(i,s,r){const c=this.ensureField(r),f=this.predictedCursor;if(!c||!f)return this.note("refused: caret is not in an input field"),!1;const h=this.assumedWidth(s);return f.col+h>c.endCol-1?(this.freeze("cursor would reach the edge of the field"),!1):(this.probationRun||(this.probationRun=!0,this.runSent=[]),this.runSent.push(i),this.lastSentUndrawn=!0,f.col+=h,this.note("width unknown: guessing"),!0)}assumedWidth(i){var r;const s=(r=this.charWidth)==null?void 0:r.call(this,i);return s===0||s===1||s===2?s:1}handleBackspace(i){var r,c,f;const s=this.predictions[this.predictions.length-1];if(this.predictedCursor&&s&&!s.frozenFrom&&!s.echoed&&s.kind==="char"&&s.row===this.predictedCursor.row&&s.col+s.width===this.predictedCursor.col)return this.predictions.pop(),s.probation&&this.runSent.pop(),this.predictedCursor.col=s.col,s.replaces&&this.predictions.push(s.replaces),!0;if(this.stillSuppressed())this.inFlightUnknown=!0;else{const h=this.ensureField(i),m=this.predictedCursor;if(h&&m){const b=i.buffer.active.getLine(m.row),p=b==null?void 0:b.getCell(m.col-1),y=p&&((r=p.getWidth)==null?void 0:r.call(p))===0?2:1,v=m.col-y;let w=!0;for(let A=m.col;A<h.endCol&&w;A++)w=this.coveredByPrediction(m.row,A)||Wi(((c=b==null?void 0:b.getCell(A))==null?void 0:c.getChars())??"")===" ";const T=Wi(((f=b==null?void 0:b.getCell(v))==null?void 0:f.getChars())??"");if(v>h.startCol&&w&&T!==" ")return this.predictions=this.predictions.filter(A=>!(A.echoed&&A.row===m.row&&A.col+A.width>v)),this.predictions.push({row:m.row,col:v,char:" ",width:y,kind:"erase",before:[T],sentAt:this.now(),probation:this.probationRun||void 0}),this.lastSentUndrawn=!1,m.col=v,!0}}return this.freeze("backspace into server content"),!1}coveredByPrediction(i,s){return this.predictions.some(r=>r.echoed&&r.row===i&&r.col<=s&&s<r.col+r.width)}ensureField(i){if(this.predictedCursor&&this.field)return this.field;const s=this.getFieldOption?this.getFieldOption():cC(i);if(!s)return null;let r=s.caretCol,c=[],f=this.inFlightUnknown;if(this.inFlight.length>0&&!this.inFlightUnknown){c=this.inFlight.slice(oC(this.inFlight,rC(i,s.row,r)));for(const h of c){const m=h.codePointAt(0)??0;r+=Gg(m)||this.assumedWidth(m)}f=c.length>0}return this.inFlight=[],this.inFlightUnknown=!1,this.field=s,this.runStartedEmpty=s.empty&&c.length===0,this.predictions=this.predictions.filter(h=>h.frozenFrom),this.predictedCursor={row:s.row,col:r},this.runInFlight=c,this.probationRun=f,this.runSent=[],s}confirm(i,s){if(this.updateSrtt(Math.max(0,this.now()-i.sentAt)),s&&!i.frozenFrom&&this.markConfident(s.key),i.probation){for(const r of this.predictions)r.probation=void 0;this.probationRun=!1,this.runInFlight=[],this.runSent=[]}}learnStyle(i,s){const r=fy(s);if(r)for(this.fieldStyles.delete(i),this.fieldStyles.set(i,r);this.fieldStyles.size>Yg;){const c=this.fieldStyles.keys().next().value;if(c===void 0)break;this.fieldStyles.delete(c)}}markConfident(i){for(this.confidentKeys.delete(i),this.confidentKeys.add(i);this.confidentKeys.size>Yg;){const s=this.confidentKeys.values().next().value;if(s===void 0)break;this.confidentKeys.delete(s)}}mismatch(i){this.mismatches++,this.note(`mismatch: ${i}`),this.predictions=[],this.predictedCursor=null,this.field&&this.confidentKeys.delete(this.field.key),this.isSuppressed=!1,this.suppressCursor=null}note(i){const s=this.trace[this.trace.length-1];if(s&&s.event===i){s.count++,s.at=this.now();return}this.trace.push({at:this.now(),event:i,count:1}),this.trace.length>sC&&this.trace.shift()}pruneExpired(){if(this.predictions.length===0)return;const i=this.now(),s=this.predictionTimeout(),r=this.predictions.filter(c=>i-c.sentAt<=s);r.length!==this.predictions.length&&(this.note("expired without an echo"),this.predictions=r,this.predictions.length===0&&(this.predictedCursor=null))}updateSrtt(i){this.srtt===null?this.srtt=i:this.srtt=this.srtt*.8+i*.2}}class dC{constructor(i){Z(this,"items",[]);Z(this,"target",null);Z(this,"provider",()=>this.paint());this.options=i}attach(i){var s;this.target!==i&&((s=this.target)==null||s.setOverlayProvider(null),this.target=i,i==null||i.setOverlayProvider(this.provider))}sync(i){var s;i.length===0&&this.items.length===0||(this.items=i,(s=this.target)==null||s.invalidateOverlay())}clear(){var i;this.items.length!==0&&(this.items=[],(i=this.target)==null||i.invalidateOverlay())}hasItems(){return this.items.length>0}dispose(){this.attach(null),this.items=[]}paint(){if(this.items.length===0)return null;const i=this.options.getTerminal(),s=i==null?void 0:i.buffer.active;if(!i||!s)return null;const r=[],c=this.options.isCursorHidden(),f=s.baseY+s.cursorY,h=s.cursorX,m=qd(i,f,h),b=c&&!!m&&Cy(m);let p;for(const y of this.items)switch(y.kind){case"char":r.push({row:y.row,col:y.col,chars:y.char,width:y.width,style:y.style??mC(i,y.row,y.col)});break;case"erase":r.push({row:y.row,col:y.col,chars:" ",width:y.width,style:hC(y.style??qd(i,y.row,y.col)??uy)});break;case"mask":b&&y.row===f&&y.col===h&&r.push({row:y.row,col:y.col,chars:y.char,width:1,style:y.style??fC(m)});break;case"caret":c?b&&r.push({row:y.row,col:y.col,chars:y.char,width:1,style:m}):p={row:y.row,col:y.col};break}return p===void 0?{cells:r}:{cells:r,cursor:p}}}function qd(l,i,s){var r;return s<0||s>=l.cols?null:fy((r=l.buffer.active.getLine(i))==null?void 0:r.getCell(s))}function Cy(l){return(l.fg&sn.INVERSE)!==0||(l.bg&kt.CM_MASK)!==kt.CM_DEFAULT}function fC(l){return{fg:l.fg&~sn.INVERSE,bg:l.bg&~(kt.CM_MASK|kt.RGB_MASK),ext:l.ext}}function hC(l){return{fg:l.fg&sn.INVERSE?l.fg&(sn.INVERSE|kt.CM_MASK|kt.RGB_MASK):0,bg:l.bg&(kt.CM_MASK|kt.RGB_MASK),ext:0}}function mC(l,i,s){const r=qd(l,i,s-1);return r&&!Cy(r)&&!(r.bg&ha.DIM)?r:uy}const Yo=new Set(["│","┃","║","▐","▕","▏","▌"]),Wo=new Set(["┌","┐","└","┘","╭","╮","╰","╯","├","┤","┬","┴","┼","┏","┓","┗","┛","╔","╗","╚","╝","╠","╣","╟","╢","╞","╡"]),pC=new Set(["╭","┌","┏","╔"]),gC=new Set(["╭","┌","┏","╔","├","┣","┠","┝","╟","╠","┞","┟","┡","┢"]),bC=new Set(["╮","┐","┓","╗"]),yC=new Set(["╰","└","┗","╚"]),vC=new Set(["╯","┘","┛","╝"]),Ed=new Set(["─","━","═","╌","┄"]),xC=new Set(["❯","›",">","!"]),$g=new Set(["$","#","%",">","❯","›","➜","λ","»"]),Vd=8,wC=12,qg=2,Vg=1,SC=4,CC=3,Xg=/-- INSERT --/,TC=/-- (?:NORMAL|VISUAL(?: LINE| BLOCK)?|REPLACE) --/,MC=/Esc to cancel|Enter to (?:confirm|select)|to navigate|Space to (?:change|toggle|select)/i,AC=/^\s*\d+[.)]\s/;function os(l){return l===""||l===" "||l===" "}class EC{constructor(i){Z(this,"cell");Z(this,"top");Z(this,"bottom");var s;this.screen=i,this.cell=(s=i.getNullCell)==null?void 0:s.call(i),this.top=i.baseY,this.bottom=i.baseY+i.rows-1}get cols(){return this.screen.cols}at(i,s){var r;if(!(i<this.top||i>this.bottom||s<0||s>=this.screen.cols))return(r=this.screen.getLine(i))==null?void 0:r.getCell(s,this.cell)}char(i,s){var r;return((r=this.at(i,s))==null?void 0:r.getChars())??""}dim(i,s){var r,c;return!!((c=(r=this.at(i,s))==null?void 0:r.isDim)!=null&&c.call(r))}text(i,s,r){var c;return i<this.top||i>this.bottom?"":((c=this.screen.getLine(i))==null?void 0:c.translateToString(!0,s,r))??""}isEdge(i,s){if(!Yo.has(this.char(i,s)))return!1;const r=this.char(i-1,s),c=this.char(i+1,s);return Yo.has(r)||Wo.has(r)||Yo.has(c)||Wo.has(c)}blankOrDim(i,s,r){var c;for(let f=s;f<r;f++){const h=this.at(i,f);if(h&&!os(h.getChars())&&!((c=h.isDim)!=null&&c.call(h)))return!1}return!0}}function NC(l,i,s){if(l.isEdge(i,s))return null;let r=0;for(let f=s-1;f>=0;f--)if(l.isEdge(i,f)){r=f+1;break}let c=l.cols;for(let f=s+1;f<l.cols;f++)if(l.isEdge(i,f)){c=f;break}return r<c?{start:r,end:c}:null}function Pg(l,i,s){if(!Ed.has(l.char(i,s.start))||!Ed.has(l.char(i,s.end-1))||Wo.has(l.char(i,s.start-1)))return!1;const r=s.end-s.start;let c=0;for(let f=s.start;f<s.end;f++)if(Ed.has(l.char(i,f)))c++;else if(f-s.start-c>r*.1)return!1;return c>=r*.9}function hs(l){return`${l.start}-${l.end}`}function Ty(l,i,s){if(s.start===0)return l.top;for(let r=i-1;r>=l.top;r--)if(gC.has(l.char(r,s.start-1)))return r;return l.top}function kC(l,i,s){const r=s.start-1,c=s.end,{row:f}=i;if(r<0||c>=l.cols)return null;const h=l.char(f,r);if(!Yo.has(h)||l.char(f,c)!==h)return null;let m=f-1;for(;m>=l.top&&l.char(m,r)===h;)m--;let b=f+1;for(;b<=l.bottom&&l.char(b,r)===h;)b++;if(b-m-1>Vd||!pC.has(l.char(m,r))||!bC.has(l.char(m,c))||!yC.has(l.char(b,r))||!vC.has(l.char(b,c))||l.dim(f,r))return null;const p=s.start+Vg,y=s.end-Vg;return i.col<p||i.col>=y?null:{kind:"frame",key:`frame:${hs(s)}`,region:hs(s),layout:`${m}`,row:f,caretCol:i.col,startCol:p,endCol:y,empty:m+2===b&&i.col===p&&l.blankOrDim(f,p,y),agentLike:!0,vimInsert:null,modal:!1}}function RC(l,i,s){const{row:r}=i;let c=-1;for(let y=r-1;y>=Math.max(l.top,r-Vd);y--)if(Pg(l,y,s)){c=y;break}if(c<0)return null;let f=-1;for(let y=r+1;y<=Math.min(l.bottom,r+Vd);y++)if(Pg(l,y,s)){f=y;break}if(f<0)return null;const h=c+1;let m=-1;for(let y=s.start;y<Math.min(s.end,s.start+3);y++){const v=l.char(h,y);if(!os(v)){xC.has(v)&&os(l.char(h,y+1))&&(m=y);break}}if(m<0||l.dim(h,m)||AC.test(l.text(h,m+1,s.end)))return null;for(let y=h+1;y<f;y++)for(let v=s.start;v<s.start+qg;v++)if(!os(l.char(y,v)))return null;let b="";for(let y=f+1;y<=Math.min(l.bottom,f+wC)&&!Wo.has(l.char(y,s.start-1));y++)b+=`${l.text(y,s.start,s.end)}
47
- `;if(MC.test(b)||TC.test(b))return null;const p=r===h?m+2:s.start+qg;return i.col<p||i.col>=s.end?null:{kind:"rule",key:`rule:${hs(s)}:${Ty(l,c,s)}`,region:hs(s),layout:`${c}`,row:r,caretCol:i.col,startCol:p,endCol:s.end,empty:f-c===2&&i.col===p&&l.blankOrDim(r,p,s.end),agentLike:!0,vimInsert:Xg.test(b),modal:Xg.test(b)}}function LC(l,i,s){if(i.hidden)return null;const{row:r,col:c}=i;for(let f=c-2;f>=s.start;f--)if(!(!$g.has(l.char(r,f))||!os(l.char(r,f+1))))return l.dim(r,f)?null:Zg(l,i,s,r,f+2,f===s.start);for(let f=r-1;f>=Math.max(l.top,r-CC);f--){let h=s.end-1;for(;h>=s.start&&os(l.char(f,h));)h--;if(h>=s.end-1-SC&&$g.has(l.char(f,h)))return l.dim(f,h)?null:Zg(l,i,s,f,s.start,!1);if(h<s.end-1)return null}return null}function Zg(l,i,s,r,c,f){const h=i.row===r?c:s.start;return i.col<h||i.col>=s.end?null:{kind:"prompt",key:`prompt:${hs(s)}:${Ty(l,r,s)}`,region:hs(s),layout:`${r}`,row:i.row,caretCol:i.col,startCol:h,endCol:s.end,empty:i.row===r&&i.col===h&&l.blankOrDim(i.row,h,s.end),agentLike:f,vimInsert:null,modal:!1}}function _C(l,i){const s=new EC(l);if(i.row<s.top||i.row>s.bottom||i.col<0||i.col>=l.cols)return null;const r=NC(s,i.row,i.col);return r?kC(s,i,r)??RC(s,i,r)??LC(s,i,r):null}class jC{constructor(){Z(this,"insertSeen",new Set)}detect(i,s){const r=_C(i,s);return!r||r.vimInsert===null?r:r.vimInsert?(this.insertSeen.add(r.region),r):this.insertSeen.has(r.region)?null:r}reset(){this.insertSeen.clear()}}class DC{constructor(i){Z(this,"tracker",new jC);Z(this,"cached");Z(this,"lastComplete",null);Z(this,"detect",()=>{var i,s;if((s=(i=this.options).isSynchronizing)!=null&&s.call(i))return this.lastComplete;if(this.cached===void 0){const r=this.options.getScreen(),c=this.options.getCursor();this.cached=r&&c?this.tracker.detect(r,c):null,this.lastComplete=this.cached}return this.cached});this.options=i}invalidate(){this.cached=void 0}reset(){this.tracker.reset(),this.cached=void 0,this.lastComplete=null}}const OC=25,zC=2026,BC=1e3;function HC(l,i=()=>performance.now()){let s=!1,r=null;const c=new Set,f=y=>(c.add(y),{dispose:()=>void c.delete(y)}),h=()=>{s=!1,r=null},m=l.parser;if(!m||typeof m.registerCsiHandler!="function")return{isCursorHidden:()=>!1,isSynchronizing:()=>!1,onSyncEnd:f,reset:h,dispose:()=>{}};const b=y=>v=>{for(const w of v.flat())if(w===OC&&(s=!y),w===zC){const T=!y&&r!==null;if(r=y?i():null,T)for(const A of[...c])A()}return!1},p=[m.registerCsiHandler({prefix:"?",final:"h"},b(!0)),m.registerCsiHandler({prefix:"?",final:"l"},b(!1)),m.registerCsiHandler({intermediates:"!",final:"p"},()=>(h(),!1))];return typeof m.registerEscHandler=="function"&&p.push(m.registerEscHandler({final:"c"},()=>(h(),!1))),{isCursorHidden:()=>s,isSynchronizing:()=>r!==null&&i()-r<BC,onSyncEnd:f,reset:h,dispose:()=>{for(const y of p)y.dispose();c.clear()}}}const UC=40;function KC(l){return l?`${l.kind} row ${l.row} cols ${l.startCol}-${l.endCol} caret ${l.caretCol}`:"none"}function IC(l){var r;const i=(r=l==null?void 0:l.canvas)==null?void 0:r.stats;if(!i)return`paint: ${(l==null?void 0:l.kind)??"-"} renderer
48
- `;const s=i.lastInputToPaintMs!==null?`${i.lastInputToPaintMs.toFixed(1)}ms`:"-";return`paint: ${i.lastPaintMs.toFixed(2)}ms cells: ${i.lastCells} frames: ${i.frames} held: ${i.heldFrames} key→paint: ${s}
49
- `}function FC(l){const i=(l==null?void 0:l.getTrace())??[];return i.length===0?"trace: -":`trace:
50
- ${i.slice(-6).map(s=>` ${s.event}${s.count>1?` ×${s.count}`:""}`).join(`
51
- `)}`}function Qg(l,i){return l==="off"?!1:l==="always"?!0:i!==null&&i>UC}const GC=250,YC=({onTerminalFocus:l,isActive:i=!0})=>{var ji,Yl,wa,Di,Si,z;const s=S.useRef(null),r=S.useRef(null),c=S.useRef(null),f=S.useRef(null),h=S.useRef(1),m=S.useRef({cols:0,rows:0}),b=S.useRef(null),p=S.useRef(null),y=S.useRef(null),v=S.useRef(null),w=S.useRef({width:0,height:0}),T=S.useRef(null),A=ux(),$=A||typeof navigator<"u"&&navigator.maxTouchPoints>0||typeof window<"u"&&"ontouchstart"in window,R=typeof window<"u"&&new URLSearchParams(window.location.search).get("debug")==="1",[O,j]=S.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}),[Y,se]=S.useState({framesPerSec:0,bytesPerSec:0}),[fe,Q]=S.useState(null),K=S.useRef(null),q=S.useRef(!1),ue=S.useRef(!1),ye=S.useRef([]);S.useEffect(()=>{if(!R)return;const C=setInterval(()=>{const te=performance.now()-1e3,J=ye.current;for(;J.length>0&&J[0].time<te;)J.shift();let be=0;for(let ee=0;ee<J.length;ee++)be+=J[ee].bytes;se({framesPerSec:J.length,bytesPerSec:be})},1e3);return()=>clearInterval(C)},[R]);const{isController:Ne,connectionState:ie,settings:he,hostPalette:oe,terminalFontFamily:pe,terminalFontSize:k,hostFont:I,ensureHostGlyphs:le,terminalResetVersion:re,sendResize:V,sendBinary:Re,observeKeyInput:Ae,consumeModifierLatch:xe,agentStatus:Se,addToast:Le,warnViewerMode:Be,connect:ot,subscribeToOutput:Xe,subscribeToPasteFileReady:ze,uploadImage:yt,profiles:Tt,activeProfileId:Ue,t:G,rttMs:me}=rt(),$e=Li.useMemo(()=>Hx(oe),[oe]),_t=S.useRef($e);_t.current=$e;const Kt=S.useRef(le);Kt.current=le;const hn=S.useRef(!1);hn.current=I.glyphs.status==="ready";const Yt=S.useRef(Ne);Yt.current=Ne;const ct=S.useRef(Re);ct.current=Re;const Ke=S.useRef(Le);Ke.current=Le;const bn=S.useRef(Be);bn.current=Be;const ut=S.useRef(V);ut.current=V;const qe=S.useRef(yt);qe.current=yt;const wt=S.useRef(i);wt.current=i;const yn=S.useRef(he);yn.current=he;const We=S.useRef(G);We.current=G;const Pe=S.useRef(null),Mt=S.useRef(null),E=S.useRef(null),ce=S.useRef(xe);ce.current=xe;const de=S.useRef(()=>{}),_e=S.useRef(C=>{var D,te,J,be;(D=Pe.current)==null||D.reset(C),(te=Pe.current)==null||te.forgetConfidence(),(J=E.current)==null||J.reset(),(be=Mt.current)==null||be.clear()}),[mt,$t]=S.useState(null),dt=S.useRef(null),[rn,Wt]=S.useState(null),ln=S.useRef(null);ln.current=rn;const[It,Ge]=S.useState(null),vn=S.useRef(null);vn.current=It;const[Cn,jt]=S.useState(""),on=S.useRef("");on.current=Cn;const[ga,St]=S.useState(!1),tl=S.useRef(!1);tl.current=ga;const $n=S.useRef(!1),[ba,Fl]=S.useState(0),nl=S.useRef(0),jn=S.useRef(null),xn=S.useRef(null),qn=S.useRef(null),qt=S.useRef(null),[ya,Dn]=S.useState(!1),Dt=S.useCallback(C=>{var be;const D=f.current;if(!D)return null;const te=((be=c.current)==null?void 0:be.querySelector(".xterm-screen"))||c.current,J=xd(C,D,te,h.current);return J?QS(D,J.col,J.bufferRow):null},[]),Jt=S.useCallback(C=>{var be;const D=f.current;if(!D)return;const te=((be=c.current)==null?void 0:be.querySelector(".xterm-screen"))||c.current,J=xd(C,D,te,h.current);if(J){qn.current=J;const ee=Sd(D,J.col,J.bufferRow);qt.current=ee;const vt=OS(D,J.col,J.bufferRow);if(vt){const je={startCol:vt.startCol,endCol:vt.startCol+vt.length-1,startRow:J.bufferRow,endRow:J.bufferRow},At=Kg(je,ee),nt=Cd(D,At);Ge(At),jt(nt),St(!0)}else Ge(null),jt(""),St(!1),qn.current=null,qt.current=null}else Ge(null),jt(""),St(!1),qn.current=null,qt.current=null;jn.current=C,xn.current=null},[]),On=S.useCallback(C=>{var nt;const D=f.current,te=qn.current;if(!D||!te)return;xn.current=C;const J=((nt=c.current)==null?void 0:nt.querySelector(".xterm-screen"))||c.current,be=xd(C,D,J,h.current);if(!be)return;const ee=qt.current??Sd(D,te.col,te.bufferRow),vt={startCol:Math.min(te.col,be.col),endCol:Math.max(te.col,be.col),startRow:Math.min(te.bufferRow,be.bufferRow),endRow:Math.max(te.bufferRow,be.bufferRow)},je=Kg(vt,ee),At=Cd(D,je);Ge(je),jt(At),St(!0)},[]),bi=S.useRef(Jt);bi.current=Jt;const il=S.useRef(On);il.current=On;const ps=S.useCallback(async()=>{const C=on.current;if(!C)return;await Kl(C)==="failed"?Ke.current("error",We.current("clipboard.copyFailed")):Ke.current("success",We.current("clipboard.copied"))},[]),va=S.useCallback(async()=>{var je,At,nt,Ot;const C=f.current;if(!C)return;const D=(je=C.buffer)==null?void 0:je.active;if(!D)return;const te=((At=vn.current)==null?void 0:At.startRow)??((nt=qn.current)==null?void 0:nt.bufferRow)??D.viewportY,J=qt.current??Sd(C,((Ot=qn.current)==null?void 0:Ot.col)??0,te),be={startCol:J.startCol,endCol:J.endCol,startRow:te,endRow:te},ee=Cd(C,be);await Kl(ee)==="failed"?Ke.current("error",We.current("clipboard.copyFailed")):Ke.current("success",We.current("clipboard.copied"))},[]),_i=S.useCallback(async()=>{const C=f.current;if(!C)return;const D=zS(C);await Kl(D)==="failed"?Ke.current("error",We.current("clipboard.copyFailed")):Ke.current("success",We.current("clipboard.copied"))},[]),Gl=S.useCallback(async()=>{var D,te;const C=f.current;if(C){if(!Yt.current){bn.current();return}try{const J=await IS();if(J.ok){await qe.current(J.blob);return}}catch{}try{const J=await KS();if(J.ok){(D=Pe.current)==null||D.reset("paste"),(te=Mt.current)==null||te.clear(),C.paste(J.text),Ke.current("success",We.current("clipboard.pasted"));return}else if(J.reason==="empty"){Ke.current("info",We.current("clipboard.pasteUnavailable"));return}}catch{}Dn(!0)}},[]),yi=S.useCallback(C=>{var te,J;const D=f.current;if(D){if(!Yt.current){bn.current();return}(te=Pe.current)==null||te.reset("paste"),(J=Mt.current)==null||J.clear(),D.paste(C),Ke.current("success",We.current("clipboard.pasted"))}},[]),vi=S.useCallback(C=>{if(f.current){if(!Yt.current){bn.current();return}qe.current(C)}},[]);S.useEffect(()=>ze(D=>{var J,be;const te=f.current;te&&((J=Pe.current)==null||J.reset("paste"),(be=Mt.current)==null||be.clear(),te.paste(D),Ke.current("success",We.current("clipboard.pasted")))}),[ze]);const xi=S.useCallback((C,D)=>{!Number.isFinite(C)||!Number.isFinite(D)||C<=0||D<=0||C===m.current.cols&&D===m.current.rows||(b.current={cols:C,rows:D},!p.current&&(p.current=setTimeout(()=>{p.current=null;const te=b.current;b.current=null,te&&(te.cols===m.current.cols&&te.rows===m.current.rows||(m.current=te,ut.current(te.cols,te.rows),_e.current("resize")))},GC)))},[]),ai=S.useCallback((C=!1)=>{var Oi;const D=f.current,te=s.current,J=c.current,be=r.current;if(!D||!te||!J||!be)return;const ee=gd(te,ss(),rd());if(ee.width<=0||ee.height<=0)return;be.style.width="100%",be.style.height="100%",J.style.width="100%",J.style.height="100%",J.style.transform="none",J.style.transformOrigin="top left",h.current=1;const vt=Hg(ee),je=_S({lastSnapshot:T.current,currentSnapshot:vt});if(je.isVisualZoom&&!C){T.current=vt;try{D.refresh(0,Math.max(0,D.rows-1))}catch{}return}if(je.shouldIgnore&&!C)return;T.current=vt;const At=fa(D,fs),nt=kg({width:ee.width-eS(J),height:ee.height,cellWidth:At.cellWidth,cellHeight:At.cellHeight}),Ot=Math.abs(ee.width-w.current.width)>1||Math.abs(ee.height-w.current.height)>1;if(D.cols!==nt.cols||D.rows!==nt.rows)try{D.resize(nt.cols,nt.rows)}catch($l){console.debug("Error resizing terminal grid:",$l)}q.current&&!ue.current&&(Ot||D.cols!==nt.cols||D.rows!==nt.rows)&&(ue.current=!0,(Oi=K.current)==null||Oi.verify());const mn=nt.cols!==m.current.cols||nt.rows!==m.current.rows;wt.current&&(Ot||C||mn)&&(w.current={width:ee.width,height:ee.height},xi(nt.cols,nt.rows));try{D.refresh(0,Math.max(0,D.rows-1))}catch{}},[xi]),Ct=S.useRef(ai);Ct.current=ai;const Vn=S.useCallback(()=>{if(y.current===null){if(typeof requestAnimationFrame!="function"){Ct.current();return}y.current=requestAnimationFrame(()=>{y.current=null,Ct.current()})}},[]),wi=S.useCallback((C=30)=>{v.current!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(v.current),v.current=null);let D=0;const te=()=>{v.current=null,D++;const J=D>=C;Ct.current(!0),!J&&D<2&&typeof requestAnimationFrame=="function"&&(v.current=requestAnimationFrame(te))};typeof requestAnimationFrame=="function"?v.current=requestAnimationFrame(te):te()},[]);S.useEffect(()=>{var ci,Ca,ql;if(!s.current||!c.current)return;const C=s.current,D=gd(C,ss(),rd()),te=fa(null,fs),J=kg({width:D.width,height:D.height,cellWidth:te.cellWidth,cellHeight:te.cellHeight});ut.current(J.cols,J.rows),w.current={width:D.width,height:D.height},T.current=Hg(D);const be=Zp(k,D.width),ee=new I1.Terminal({fontSize:be,fontFamily:pe,lineHeight:1.15,..._t.current?{theme:{..._t.current}}:{},allowProposedApi:!0,convertEol:!0,scrollback:5e3,cols:J.cols,rows:J.rows,screenReaderMode:!1,linkHandler:{activate:(ae,ge)=>{Ad(ge)}}});try{const ae=new F1.Unicode11Addon;ee.loadAddon(ae),ee.unicode.activeVersion="11"}catch(ae){console.debug("Unicode11 addon unavailable, using default width table:",ae)}try{ee.loadAddon(new Y1.WebLinksAddon((ae,ge)=>{Ad(ge)}))}catch(ae){console.debug("WebLinks addon unavailable, URLs stay plain text:",ae)}ee.open(c.current),f.current=ee;const vt=ee.onTitleChange(ae=>{$t($d(ae)||null)}),je=HC(ee),At=new DC({getScreen:()=>{const ae=f.current;if(!ae)return null;const ge=ae.buffer.active;return{cols:ae.cols,rows:ae.rows,baseY:ge.baseY,getLine:He=>ge.getLine(He),getNullCell:typeof ge.getNullCell=="function"?()=>ge.getNullCell():void 0}},getCursor:()=>{var ge;const ae=(ge=f.current)==null?void 0:ge.buffer.active;return ae?{row:ae.baseY+ae.cursorY,col:ae.cursorX,hidden:je.isCursorHidden()}:null},isSynchronizing:je.isSynchronizing});E.current=At;const nt=(ci=ee._core)==null?void 0:ci.unicodeService,Ot=new uC({getTerminal:()=>f.current,getField:At.detect,charWidth:typeof(nt==null?void 0:nt.wcwidth)=="function"?ae=>nt.wcwidth(ae):void 0});Pe.current=Ot;const mn=new dC({getTerminal:()=>f.current,isCursorHidden:()=>je.isCursorHidden()});Mt.current=mn;const Oi=()=>{const ae=Pe.current,ge=Mt.current;if(!ae||!ge)return;const He=yn.current.predictiveEcho,zt=ae.getEchoSrttMs();if(!Qg(He,zt)){ge.clear();return}ge.sync(ae.getOverlayItems())};de.current=Oi,A&&ee.textarea&&(ee.textarea.readOnly=!1,ee.textarea.tabIndex=0,ee.textarea.inputMode="text");let $l=()=>{};if(R&&ee.textarea){const ae=()=>{j(ge=>({...ge,focused:document.activeElement===ee.textarea}))};ee.textarea.addEventListener("focus",ae),ee.textarea.addEventListener("blur",ae),$l=()=>{var ge,He;(ge=ee.textarea)==null||ge.removeEventListener("focus",ae),(He=ee.textarea)==null||He.removeEventListener("blur",ae)},ae()}const ri=async ae=>{var He,zt;(He=Pe.current)==null||He.reset("paste"),(zt=Mt.current)==null||zt.clear();const ge=wy(ae);if(ge){if(ae.preventDefault(),ae.stopPropagation(),!Yt.current){bn.current();return}await qe.current(ge)}};(Ca=ee.textarea)==null||Ca.addEventListener("paste",ri),C.addEventListener("paste",ri);const ll=LS(ee,{isSynchronizing:je.isSynchronizing,onRendererSwapped:ae=>{var ge;C&&(C.dataset.renderer=ae),Q(ae),(ge=Mt.current)==null||ge.attach(null);try{ee.refresh(0,Math.max(0,ee.rows-1))}catch{}}});mn.attach(ll.canvas);const wr=je.onSyncEnd(()=>{var ae,ge;return(ge=(ae=K.current)==null?void 0:ae.canvas)==null?void 0:ge.flushHeld()});K.current=ll,C&&(C.dataset.renderer=ll.kind),Q(ll.kind);const Sr=We.current("terminal.bannerTitle"),gs=We.current("terminal.bannerSubtitle");if(ee.writeln(" ___ ___ .___ "),ee.writeln(` / | \\ ____ _______| _/______ \x1B[1m${Sr}\x1B[0m`),ee.writeln(`/ ~ \\/ __ \\\\_ __ \\ __/ ___/ \x1B[2m${gs}\x1B[0m`),ee.writeln("\\ Y / ___/ | | \\/|_ \\___ \\ "),ee.writeln(" \\___|_ / \\___ >|__| /___/____ >"),ee.writeln(" \\/ \\/ \\/ "),ee.writeln(""),q.current=!0,ee.write("",()=>void ll.verify()),!A)try{ee.focus()}catch{}typeof document<"u"&&"fonts"in document&&typeof((ql=document.fonts)==null?void 0:ql.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{}wi(5)}}).catch(()=>{});const ic=ee.onData(ae=>{var zt,at,Rt;let ge=ae;if(Yt.current&&sy(ae)==="keys"&&Pv(ae)){const Ee=ce.current();Ee&&(ge=$o(ae,Ee))}const He=Pd(ge);if(!Yt.current&&!qo(He)){bn.current();return}(zt=Pe.current)==null||zt.handleUserInput(He),Oi(),(Rt=(at=K.current)==null?void 0:at.canvas)==null||Rt.markInput(),ct.current(He)}),lc=ee.onBinary(ae=>{const ge=new Uint8Array(ae.length);for(let He=0;He<ae.length;He++)ge[He]=ae.charCodeAt(He)&255;!Yt.current&&!qo(ge)||ct.current(ge)}),Sa=typeof ee.onWriteParsed=="function"?ee.onWriteParsed(()=>{var ae;$n.current=!0,At.invalidate(),!je.isSynchronizing()&&((ae=Pe.current)==null||ae.onServerOutput(),Oi())}):{dispose:()=>{}},oi=typeof ee.onRender=="function"?ee.onRender(ae=>{var zt;const ge=ee.buffer.active.viewportY??0;if(hn.current){let at="";for(let Rt=ae.start;Rt<=ae.end;Rt+=1)at+=((zt=ee.buffer.active.getLine(ge+Rt))==null?void 0:zt.translateToString(!0))??"";/[^\x00-\x7f]/.test(at)&&Kt.current(at)}ge!==nl.current&&(nl.current=ge,Fl(ge));const He=vn.current;if(He&&tl.current){const at=He.startRow-ge,Rt=He.endRow-ge;$n.current&&ae.start<=Rt&&ae.end>=at&&(St(!1),$n.current=!1)}else $n.current=!1}):{dispose:()=>{}},bs=typeof ee.onScroll=="function"?ee.onScroll(()=>{var ge,He;const ae=ee.buffer.active.viewportY??0;nl.current=ae,Fl(ae),(ge=Pe.current)==null||ge.reset("scroll"),(He=Mt.current)==null||He.clear()}):{dispose:()=>{}},pn=new nS({getTerminal:()=>f.current,getIsController:()=>Yt.current,getScale:()=>h.current,getSurfaceElement:()=>c.current,allowSyntheticMouseFallback:!1,onFocus:()=>{try{ee.focus()}catch{}R&&j(ae=>({...ae,focused:document.activeElement===ee.textarea})),l==null||l()},onGestureStateChange:ae=>{R&&j(ge=>({...ge,state:ae}))},onGestureScroll:({deltaY:ae,lines:ge,viewportY:He,scrollTop:zt,scrollHeight:at,clientHeight:Rt,moved:Ee,bufferType:en,baseY:Bt,cursorY:Mn,hasScrollback:ui,mouseTracking:Bn,scrollMode:Pn})=>{R&&j(vs=>({...vs,deltaY:ae,lines:ge,viewportY:He,scrollTop:zt,scrollHeight:at,clientHeight:Rt,moved:Ee,focused:document.activeElement===ee.textarea,bufferType:en,baseY:Bt,cursorY:Mn,hasScrollback:ui,mouseTracking:Bn,scrollMode:Pn,scrollCalls:vs.scrollCalls+(ge!==0?1:0),lastScrollLines:ge}))},longPressDelayMs:500,dragThresholdPx:8,scrollLineHeightPx:18,onLongPress:A?(ae=>{var ge;return(ge=bi.current)==null?void 0:ge.call(bi,ae)}):void 0,onSelectionExtend:A?(ae=>{var ge;return(ge=il.current)==null?void 0:ge.call(il,ae)}):void 0}),al=typeof window<"u"&&"PointerEvent"in window,sl=typeof TouchEvent<"u",rl=[],zn=(ae,ge=!1)=>{const He=ae.target;return He instanceof Node&&C.contains(He)||ge&&pn.getState()!=="idle"};if(al){const ae={passive:!1,capture:!0},ge=Ee=>{R&&j(en=>({...en,pointerEvents:en.pointerEvents+1,lastInputEvent:Ee}))},He=Ee=>{if(!zn(Ee))return;if(ge("pointerdown"),ln.current){Wt(null),ln.current=null,Ge(null),vn.current=null,jt(""),on.current="",St(!1),jn.current=null,xn.current=null,Ee.cancelable&&Ee.preventDefault(),Ee.stopPropagation();return}pn.handlePointerDown(Ee,C)&&Ee.stopPropagation()},zt=Ee=>{zn(Ee,!0)&&(ge("pointermove"),pn.handlePointerMove(Ee),Ee.pointerType!=="mouse"&&Ee.stopPropagation())},at=Ee=>{if(!zn(Ee,!0))return;if(ge("pointerup"),pn.getState()==="longpress"&&dt.current){const Bt=xn.current??jn.current;if(Bt){const Mn=dt.current.getBoundingClientRect(),ui=Bt.clientX-Mn.left,Bn=Bt.clientY-Mn.top,Pn=Dt(Bt);Wt({x:ui,y:Bn,link:Pn}),ln.current={x:ui,y:Bn,link:Pn}}}pn.handlePointerUp(Ee),Ee.pointerType!=="mouse"&&Ee.stopPropagation()},Rt=Ee=>{zn(Ee,!0)&&(ge("pointercancel"),Wt(null),ln.current=null,Ge(null),vn.current=null,jt(""),on.current="",St(!1),jn.current=null,xn.current=null,pn.handlePointerCancel(Ee),Ee.pointerType!=="mouse"&&Ee.stopPropagation())};if(document.addEventListener("pointerdown",He,ae),document.addEventListener("pointermove",zt,ae),document.addEventListener("pointerup",at,ae),document.addEventListener("pointercancel",Rt,ae),rl.push(()=>{document.removeEventListener("pointerdown",He,ae),document.removeEventListener("pointermove",zt,ae),document.removeEventListener("pointerup",at,ae),document.removeEventListener("pointercancel",Rt,ae)}),sl){const Ee=Bt=>{zn(Bt,!0)&&(R&&j(Mn=>({...Mn,touchEvents:Mn.touchEvents+1})),Bt.cancelable&&Bt.preventDefault(),Bt.stopPropagation())},en=["touchstart","touchmove","touchend","touchcancel"];for(const Bt of en)document.addEventListener(Bt,Ee,ae);rl.push(()=>{for(const Bt of en)document.removeEventListener(Bt,Ee,ae)})}}else{const ae={passive:!1,capture:!0},ge=Ee=>{R&&j(en=>({...en,touchEvents:en.touchEvents+1,lastInputEvent:Ee}))},He=Ee=>{if(zn(Ee)){if(ge("touchstart"),ln.current){Wt(null),ln.current=null,Ge(null),vn.current=null,jt(""),on.current="",St(!1),jn.current=null,xn.current=null,Ee.cancelable&&Ee.preventDefault(),Ee.stopPropagation();return}Ee.touches.length===1&&Ee.stopPropagation(),pn.handleTouchStart(Ee,C)}},zt=Ee=>{zn(Ee,!0)&&(ge("touchmove"),Ee.touches.length===1&&Ee.stopPropagation(),pn.handleTouchMove(Ee))},at=Ee=>{if(!zn(Ee,!0))return;if(ge("touchend"),pn.getState()==="longpress"&&dt.current){const Bt=xn.current??jn.current;if(Bt){const Mn=dt.current.getBoundingClientRect(),ui=Bt.clientX-Mn.left,Bn=Bt.clientY-Mn.top,Pn=Dt(Bt);Wt({x:ui,y:Bn,link:Pn}),ln.current={x:ui,y:Bn,link:Pn}}}Ee.stopPropagation(),pn.handleTouchEnd(Ee)},Rt=Ee=>{zn(Ee,!0)&&(ge("touchcancel"),Wt(null),ln.current=null,Ge(null),vn.current=null,jt(""),on.current="",St(!1),jn.current=null,xn.current=null,Ee.stopPropagation(),pn.handleTouchCancel())};document.addEventListener("touchstart",He,ae),document.addEventListener("touchmove",zt,ae),document.addEventListener("touchend",at,ae),document.addEventListener("touchcancel",Rt,ae),rl.push(()=>{document.removeEventListener("touchstart",He,ae),document.removeEventListener("touchmove",zt,ae),document.removeEventListener("touchend",at,ae),document.removeEventListener("touchcancel",Rt,ae)})}const ys=ae=>{ae.preventDefault()};C.addEventListener("contextmenu",ys),rl.push(()=>{C.removeEventListener("contextmenu",ys)});const ol=new ResizeObserver(()=>{Vn()});ol.observe(C);const Tn=()=>{Vn()},cl=()=>{var ae,ge;if(document.visibilityState==="visible"){wi(10);try{(ge=f.current)==null||ge.refresh(0,Math.max(0,(((ae=f.current)==null?void 0:ae.rows)||1)-1))}catch{}}};window.addEventListener("resize",Tn),window.addEventListener("orientationchange",Tn),document.addEventListener("visibilitychange",cl),window.addEventListener("pageshow",cl);const Ci=()=>{Vn()};return typeof window<"u"&&window.visualViewport&&(window.visualViewport.addEventListener("resize",Ci),window.visualViewport.addEventListener("scroll",Ci)),()=>{var ae,ge;ic.dispose(),lc.dispose(),oi.dispose(),bs.dispose(),Sa.dispose(),vt.dispose(),wr.dispose(),(ae=Mt.current)==null||ae.dispose(),Mt.current=null,Pe.current=null,E.current=null,de.current=()=>{},je.dispose(),pn.handlePointerCancel();for(const He of rl)He();ol.disconnect(),window.removeEventListener("resize",Tn),window.removeEventListener("orientationchange",Tn),document.removeEventListener("visibilitychange",cl),window.removeEventListener("pageshow",cl),typeof window<"u"&&window.visualViewport&&(window.visualViewport.removeEventListener("resize",Ci),window.visualViewport.removeEventListener("scroll",Ci)),p.current&&(clearTimeout(p.current),p.current=null),y.current!==null&&(cancelAnimationFrame(y.current),y.current=null),v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),$l(),(ge=ee.textarea)==null||ge.removeEventListener("paste",ri),C.removeEventListener("paste",ri),ll.dispose(),K.current=null,ee.dispose(),f.current=null}},[]);const Xn=Li.useMemo(()=>{var C;return((C=Tt.find(D=>D.id===Ue))==null?void 0:C.displayName)??null},[Tt,Ue]);S.useEffect(()=>{ie!=="connected"&&$t(null)},[ie]),S.useEffect(()=>{const C=i&&ie==="connected",D=he.agentAlertBadge?vr(Se):null;$S(C?mt:null,Xn,D)},[i,ie,mt,Xn,Se,he.agentAlertBadge]),S.useEffect(()=>{const C=f.current;if(!C)return;const D=gd(s.current,ss(),rd());C.options.fontSize=Zp(k,D.width),C.options.fontFamily=pe;try{C.refresh(0,Math.max(0,C.rows-1))}catch{}wi(10)},[k,pe]),S.useEffect(()=>{var D,te;const C=f.current;if(!(!C||!I.glyphRevision)){(te=(D=K.current)==null?void 0:D.canvas)==null||te.clearTextureAtlas();try{C.refresh(0,Math.max(0,C.rows-1))}catch{}}},[I.glyphRevision]),S.useEffect(()=>Ae(C=>{var D,te,J;(D=Pe.current)==null||D.handleUserInput(C),de.current(),(J=(te=K.current)==null?void 0:te.canvas)==null||J.markInput()}),[Ae]),S.useEffect(()=>{const C=Pe.current,D=Mt.current;if(!C||!D)return;const te=C.getEchoSrttMs();Qg(he.predictiveEcho,te)?D.sync(C.getOverlayItems()):D.clear()},[he.predictiveEcho]);const si=S.useRef(re);S.useEffect(()=>{var D;if(si.current===re)return;si.current=re,_e.current("resetVersion");const C=f.current;if(C)try{(D=C.reset)==null||D.call(C),C.clear(),C.refresh(0,Math.max(0,C.rows-1))}catch{}},[re]),S.useEffect(()=>{_e.current("connectionState")},[ie]),S.useEffect(()=>{const C=f.current;if(!(!C||!$e)){C.options.theme={...$e};try{C.refresh(0,Math.max(0,C.rows-1))}catch{}}},[$e]),S.useEffect(()=>Xe(D=>{const te=f.current;if(!te)throw new Error("terminal not ready");if(te.write(D),R){const J=performance.now(),be=ye.current;be.push({time:J,bytes:D.byteLength});const ee=J-1e3;for(;be.length>0&&be[0].time<ee;)be.shift()}}),[Xe,R]),S.useEffect(()=>{if(!i)return;wi(10);const C=f.current;if(C){try{C.refresh(0,Math.max(0,C.rows-1))}catch{}if(!A)try{C.focus()}catch{}}},[i,A,wi]),S.useEffect(()=>{ie==="disconnected"&&ot()},[]);const xa=C=>{C.preventDefault()};return d.jsxs("main",{ref:dt,className:"flex-1 w-full min-w-0 min-h-0 overflow-hidden relative flex flex-col",onContextMenu:xa,"aria-label":G("terminal.windowAriaLabel"),children:[d.jsx("div",{id:"terminal-container",ref:s,className:"absolute inset-0 overflow-hidden cursor-text",style:{touchAction:$?"none":"auto"},tabIndex:0,onContextMenu:xa,"aria-label":G("terminal.bufferAriaLabel"),role:"region",children:d.jsx("div",{id:"terminal-frame",ref:r,className:"relative overflow-hidden",style:{width:"100%",height:"100%"},children:d.jsx("div",{id:"terminal-surface",ref:c,className:"absolute top-0 left-0",style:{transformOrigin:"top left",width:"100%",height:"100%"}})})}),R&&d.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: ${O.state}
52
- `,`deltaY: ${O.deltaY} lines: ${O.lines}
53
- `,`viewportY: ${O.viewportY??"-"} focus: ${O.focused}
54
- `,`buffer: ${O.bufferType??"-"} base: ${O.baseY??"-"} cursor: ${O.cursorY??"-"} scrollback: ${O.hasScrollback??"-"}
55
- `,`scroll: ${O.scrollTop??"-"} / ${O.scrollHeight??"-"} (h ${O.clientHeight??"-"}) moved: ${O.moved}
56
- `,`mode: ${O.scrollMode} calls: ${O.scrollCalls} lines: ${O.lastScrollLines??"-"} mouse: ${O.mouseTracking}
57
- `,`event: ${O.lastInputEvent||"-"} pointer: ${O.pointerEvents} touch: ${O.touchEvents}
58
- `,`rtt: ${me!==null?`${me}ms`:"-"} frames/s: ${Y.framesPerSec} bytes/s: ${Y.bytesPerSec} renderer: ${fe??"-"}
59
- `,`prediction: ${((ji=Pe.current)==null?void 0:ji.getState())??"-"} mode: ${he.predictiveEcho} pending: ${((Yl=Pe.current)==null?void 0:Yl.getVisiblePredictions().length)??0} srtt: ${((wa=Pe.current)==null?void 0:wa.getEchoSrttMs())!==null&&((Di=Pe.current)==null?void 0:Di.getEchoSrttMs())!==void 0?`${Math.round(Pe.current.getEchoSrttMs())}ms`:"-"}
60
- `,`field: ${KC(((Si=E.current)==null?void 0:Si.detect())??null)} mismatches: ${((z=Pe.current)==null?void 0:z.getMismatchCount())??0}
61
- `,IC(K.current),FC(Pe.current)]}),A&&It&&ga&&(()=>{var mn;const C=f.current;if(!C||!dt.current)return null;const D=fa(C);if(D.cellWidth<=0||D.cellHeight<=0)return null;const te=((mn=c.current)==null?void 0:mn.querySelector(".xterm-screen"))||c.current;if(!te)return null;const J=te.getBoundingClientRect(),be=dt.current.getBoundingClientRect(),ee=It.startRow-ba;if(It.endRow-ba<0||ee>=C.rows)return null;const je=J.top-be.top+ee*D.cellHeight,At=J.left-be.left+It.startCol*D.cellWidth,nt=(It.endCol-It.startCol+1)*D.cellWidth,Ot=(It.endRow-It.startRow+1)*D.cellHeight;return d.jsx("div",{"data-testid":"terminal-selection-overlay",className:"pointer-events-none absolute z-20 bg-tui-accent/35",style:{top:`${je}px`,left:`${At}px`,width:`${nt}px`,height:`${Ot}px`}})})(),A&&rn&&d.jsx(JS,{anchorPoint:rn,hasSelection:!!Cn,isController:Ne,vibrateOnKeyPress:he.vibrateOnKeyPress,linkUrl:rn.link??null,onOpenLink:C=>{Ad(C)||Le("warning",G("clipboard.openLinkFailed"))},onCopySelection:ps,onCopyLine:va,onCopyScreen:_i,onPaste:Gl,onClose:()=>{Wt(null),ln.current=null,Ge(null),vn.current=null,jt(""),on.current="",St(!1)}}),A&&d.jsx(eC,{isOpen:ya,onClose:()=>Dn(!1),onSend:yi,onSendImage:vi})]})},$C=({onPairedSuccess:l})=>{const{settings:i,updateSettings:s,connect:r,connectionState:c,stateDetail:f,addToast:h,t:m}=rt(),[b,p]=S.useState(""),[y,v]=S.useState(null),[w,T]=S.useState(!1),[A,$]=S.useState(i.wsUrl||"/ws/client"),[R,O]=S.useState(i.token||""),[j,Y]=S.useState(i.clientId||""),se="node bin/service.js pair",fe="node bin/config-tui.js",Q=ye=>{Kl(ye).then(Ne=>{if(Ne==="failed"){h("error",m("clipboard.copyFailed"));return}v(ye),h("success",m("toasts.commandCopied")),setTimeout(()=>v(null),2e3)})},K=ye=>{ye.preventDefault();const Ne=b.trim().toUpperCase();if(!Ne&&!R.trim()){h("warning",m("toasts.connectionError"));return}const ie={pairCode:Ne,wsUrl:A.trim()||"/ws/client",clientId:j.trim()||i.clientId};R.trim()&&(ie.token=R.trim()),s(ie),r({pairCode:Ne||void 0,token:R.trim()||void 0,wsUrl:A.trim()||"/ws/client",clientId:j.trim()||i.clientId}),l&&l()},q=c==="connecting"||c==="reconnecting",ue=({n:ye})=>d.jsxs("span",{"aria-hidden":"true",className:"shrink-0 font-bold text-tui-accent",children:["[",ye,"]"]});return d.jsx("div",{className:"flex h-full w-full flex-1 justify-center overflow-y-auto bg-tui-crust p-2 sm:p-4",children:d.jsxs("div",{className:"my-auto w-full max-w-3xl space-y-3",children:[d.jsxs("div",{className:"border border-tui-border bg-tui-base px-3 py-2",children:[d.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[d.jsx("span",{"aria-hidden":"true",className:"font-bold text-tui-accent",children:"herdr-remote"}),d.jsx("h1",{className:"text-tui font-bold text-tui-text",children:m("onboarding.title")}),d.jsx("span",{className:"text-tui uppercase text-tui-warn",children:m("onboarding.firstTimeSetup")})]}),d.jsx("p",{className:"mt-0.5 text-tui leading-snug text-tui-muted",children:m("onboarding.description")})]}),c==="error"&&d.jsxs(Bl,{tone:"warn",action:d.jsx(Oe,{variant:"warn",onClick:()=>r(),children:m("common.retry")}),children:[d.jsx("span",{className:"block font-bold",children:m("onboarding.authRequired")}),d.jsx("span",{className:"block text-tui-muted",children:f||m("onboarding.authRequiredDesc")})]}),d.jsxs("form",{onSubmit:K,className:"grid gap-3",children:[d.jsx(gn,{title:m("onboarding.step1Title"),className:"min-w-0",children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("p",{className:"flex items-start gap-2 text-tui text-tui-muted",children:[d.jsx(ue,{n:1}),d.jsx("span",{className:"leading-snug",children:m("onboarding.step1Desc")})]}),d.jsxs("div",{className:"flex items-center gap-2 border border-tui-border bg-tui-mantle px-2 py-1",children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none text-tui-ok",children:"$"}),d.jsx("code",{className:"min-w-0 flex-1 truncate text-tui text-tui-text",children:se}),d.jsx(Oe,{onClick:()=>Q(se),glyph:y===se?Fe.check:"⧉",className:ne("shrink-0",y===se&&"border-tui-ok text-tui-ok"),children:m(y===se?"common.copied":"common.copy")})]}),d.jsx("div",{className:"space-y-0.5 text-tui-sm",children:d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"truncate text-tui-faint",children:m("onboarding.step1TuiNote")}),d.jsx("code",{onClick:()=>Q(fe),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:fe})]})})]})}),d.jsx(gn,{title:m("onboarding.step2Title"),className:"min-w-0",children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ue,{n:2}),d.jsx(Sn,{type:"text",value:b,onChange:ye=>p(ye.target.value.toUpperCase()),placeholder:m("onboarding.step2Placeholder"),maxLength:12,autoFocus:!0,"aria-label":m("onboarding.step2Title"),className:"font-bold uppercase"})]}),d.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:m("onboarding.step2Note")})]})}),d.jsx(Oe,{variant:"primary",type:"submit",block:!0,disabled:q,className:"py-1.5",children:q?d.jsx(ma,{label:m("onboarding.connectingAndPairing")}):m("onboarding.connectAndPair")}),d.jsxs("div",{className:"border border-tui-border bg-tui-base",children:[d.jsxs("button",{type:"button",onClick:()=>T(!w),"aria-expanded":w,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:[d.jsx("span",{"aria-hidden":"true",className:"text-tui-accent",children:w?Fe.chevronDown:Fe.chevronRight}),d.jsx("span",{className:"uppercase",children:m("onboarding.advancedTitle")})]}),w&&d.jsxs("div",{className:"space-y-2.5 border-t border-tui-border-dim px-2 py-2",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"onboarding-token",children:m("onboarding.manualTokenLabel")}),d.jsx(Sn,{id:"onboarding-token",type:"password",value:R,onChange:ye=>O(ye.target.value),placeholder:m("onboarding.manualTokenPlaceholder")})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"onboarding-ws",children:m("onboarding.wsEndpointLabel")}),d.jsx(Sn,{id:"onboarding-ws",type:"text",value:A,onChange:ye=>$(ye.target.value),placeholder:m("onboarding.wsEndpointPlaceholder")})]}),d.jsx(_1,{}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"onboarding-client-id",children:m("onboarding.clientIdLabel")}),d.jsx(Sn,{id:"onboarding-client-id",type:"text",value:j,onChange:ye=>Y(ye.target.value)})]})]})]})]})]})})},Ol="tui-focusable inline-flex shrink-0 select-none items-center justify-center border text-tui font-medium transition-colors",dr="border-tui-border bg-tui-surface text-tui-text hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",qC="border-tui-accent bg-tui-accent text-tui-crust font-bold",VC="border-tui-ok bg-transparent text-tui-ok hover:bg-tui-ok hover:text-tui-crust font-bold",Wg={default:dr,bad:"border-tui-bad text-tui-bad hover:bg-tui-bad hover:text-tui-crust",warn:"border-tui-warn text-tui-warn hover:bg-tui-warn hover:text-tui-crust"},XC=({compact:l=!1,onCustomize:i})=>{const{sendKey:s,settings:r,updateSettings:c,isController:f,warnViewerMode:h,t:m,uploadProgress:b,uploadImage:p,modifierLatch:y,toggleModifierLatch:v,consumeModifierLatch:w,agentProfile:T}=rt(),A=l?"h-8":"h-7",$=l?"h-8 min-w-[2rem] px-1.5":"h-7 min-w-[1.75rem] px-1.5",R=l?"h-8 w-8":"h-7 w-7",O=l?"h-8 px-1.5":"h-7 px-1.5",j=S.useRef(null),Y=S.useRef(null),se=S.useCallback(()=>{if(r.vibrateOnKeyPress&&typeof navigator<"u"&&navigator.vibrate)try{navigator.vibrate(8)}catch{}},[r.vibrateOnKeyPress]),fe=S.useCallback(()=>{var G;if(se(),!f){h();return}b.active||(G=j.current)==null||G.click()},[se,f,h,b.active]),Q=S.useCallback(G=>{const me=G.target.files,$e=me&&me[0];G.target.value="",$e&&p($e)},[p]),K=()=>d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",className:"hidden","data-testid":"key-toolbar-file-input",onChange:Q}),d.jsx("input",{ref:Y,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/*",capture:"environment",className:"hidden","data-testid":"key-toolbar-camera-input",onChange:Q})]}),q=(G=!1)=>b.active?d.jsx("div",{"data-testid":G?"key-toolbar-progress-collapsed":"key-toolbar-progress",className:"w-full border-b border-tui-border-dim bg-tui-crust px-2 py-1",children:d.jsx(z1,{ratio:b.ratio,label:b.statusText,tone:b.phase==="completed"?"ok":b.phase==="error"?"bad":"accent","aria-label":b.statusText})}):null,ue=()=>{const G=b.active;return d.jsx("button",{type:"button","data-testid":"image-upload-btn",onClick:fe,disabled:G,className:ne(Ol,$,G?"border-tui-border-dim bg-tui-surface opacity-60 cursor-not-allowed":dr),title:G?b.statusText:m("virtualKeyboard.uploadImageTitle"),"aria-label":m("virtualKeyboard.uploadImage"),children:d.jsx("span",{className:"font-medium",children:G?`${b.percent}%`:m("virtualKeyboard.image")})})},[ye,Ne]=S.useState(!1),[ie,he]=S.useState(!1),[oe,pe]=S.useState(!1),k=S.useRef([]);S.useEffect(()=>()=>{k.current.forEach(G=>clearTimeout(G)),k.current=[]},[]);const I=S.useRef(null),[le,re]=S.useState(!1),V=S.useCallback(()=>{const G=I.current;re(!!G&&G.scrollLeft+G.clientWidth<G.scrollWidth-1)},[]);S.useEffect(V),S.useEffect(()=>{const G=I.current;if(!G||typeof ResizeObserver!="function")return;const me=new ResizeObserver(V);return me.observe(G),()=>me.disconnect()},[V,r.toolbarVisible]);const Re=S.useCallback(G=>{if(se(),!f){h();return}let me;try{me=Ri(G)}catch{return}if(w(),me.length===1){s(me[0]);return}me.forEach(($e,_t)=>{const Kt=setTimeout(()=>{k.current=k.current.filter(hn=>hn!==Kt),s($e)},_t*120);k.current.push(Kt)})},[w,f,s,se,h]),Ae=hw(T,r.agentKeymaps[T]),xe=G=>{let me="";try{me=ur(G.combo)}catch{}const $e=G.custom?G.customLabel||"":m(`agentActions.${G.labelKey}`),_t=G.labelKey==="interrupt"&&G.combo.trim().toLowerCase()==="ctrl+c"?"bad":G.combo.trim().toLowerCase()==="ctrl+z"?"warn":"default";return d.jsxs("button",{type:"button","data-testid":`agent-key-${G.id}`,onClick:()=>Re(G.combo),className:ne(Ol,A,"max-w-[10rem] gap-1 px-1.5",Wg[_t]),title:`${me} ${$e}`.trim(),"aria-label":`${me} ${$e}`.trim(),children:[d.jsx("span",{className:"font-bold",children:me}),d.jsx("span",{className:"max-w-[5rem] truncate text-tui-sm opacity-70",children:$e})]},G.id)},Se=()=>{const G=[...Ae.agentActions,...Ae.genericActions];return G.length===0&&!i?null:d.jsxs("div",{"data-testid":"agent-key-actions",role:"group","aria-label":`${da[T].name} ${m("agentKeymaps.agentGroup")}`,className:"flex shrink-0 items-center gap-1",children:[d.jsx("span",{"aria-hidden":"true",className:"mx-1 h-5 w-px shrink-0 bg-tui-border-dim"}),G.map(xe),i&&d.jsx("button",{type:"button","data-testid":"agent-key-customize",onClick:i,className:ne(Ol,A,"px-1.5 text-tui-sm border-tui-border-dim bg-transparent text-tui-faint hover:border-tui-accent hover:text-tui-accent"),title:m("agentKeymaps.customizeBar"),"aria-label":m("agentKeymaps.customizeBar"),children:m("agentKeymaps.customizeBarShort")})]})},Le=S.useCallback((G,me=!0)=>{if(se(),!f){h();return}const $e=w();s(me&&$e?$o(G,$e):G)},[f,s,h,se,w]);if(!r.toolbarVisible)return d.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:[K(),q(!0),d.jsx("div",{className:"flex items-center justify-center px-2 py-0.5",children:d.jsxs("button",{type:"button",onClick:()=>c({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:m("virtualKeyboard.expandToolbar"),"aria-label":m("virtualKeyboard.expandToolbar"),"aria-expanded":!1,children:[d.jsx("span",{"aria-hidden":"true",children:"▴"}),d.jsx("span",{"aria-hidden":"true",children:m("common.keyBar")})]})})]});const Be=r.virtualKeys&&r.virtualKeys.length>0?r.virtualKeys.filter(G=>G.enabled):gb,ot=G=>G.id==="left"?d.jsx("span",{"aria-hidden":"true",children:"←"}):G.id==="up"?d.jsx("span",{"aria-hidden":"true",children:"↑"}):G.id==="down"?d.jsx("span",{"aria-hidden":"true",children:"↓"}):G.id==="right"?d.jsx("span",{"aria-hidden":"true",children:"→"}):G.id==="enter"?d.jsxs("span",{className:"flex items-center gap-1",children:[d.jsx("span",{"aria-hidden":"true",children:"⏎"}),d.jsx("span",{className:"hidden sm:inline",children:m("virtualKeyboard.keyEnter")})]}):G.id==="drawer_chords"?d.jsx("span",{children:"^C"}):G.id==="drawer_fn"?d.jsxs("span",{className:"flex items-center gap-0.5",children:[d.jsx("span",{children:"Fn"}),d.jsx("span",{"aria-hidden":"true",children:ye?"▾":"▴"})]}):d.jsx("span",{children:G.label}),Xe=G=>{if(se(),G.type==="modifier"){G.modifierType==="ctrl"||G.modifierType==="alt"||G.modifierType==="shift"?v(G.modifierType):G.modifierType==="meta"&&Le(ve.ESC);return}if(G.type==="drawer"){G.drawerType==="fn"?(Ne(!ye),he(!1),pe(!1)):G.drawerType==="chords"?(pe(!oe),Ne(!1),he(!1)):G.drawerType==="symbols"&&(he(!ie),Ne(!1),pe(!1));return}Le(G.code,G.type!=="chord")},ze=G=>{if(G.type==="modifier"){if(G.modifierType==="ctrl")return y.ctrl;if(G.modifierType==="alt")return y.alt;if(G.modifierType==="shift")return y.shift}if(G.type==="drawer"){if(G.drawerType==="fn")return ye;if(G.drawerType==="chords")return oe;if(G.drawerType==="symbols")return ie}return!1},yt=G=>{const me=ze(G),$e=["left","up","down","right"].includes(G.id),_t=G.type==="drawer",Kt=Ld(G,m);return d.jsx("button",{type:"button",onClick:()=>Xe(G),className:ne(Ol,$e?R:_t?O:$,G.id==="enter"?VC:me?qC:dr),title:Kt,"aria-label":Kt,"aria-pressed":me,children:ot(G)},G.id)},Tt=Be.find(G=>G.id==="enter"),Ue=(G,me,$e,_t,Kt="default")=>d.jsxs("button",{type:"button",onClick:()=>Le(G,!1),className:ne(Ol,A,"gap-1.5 px-2",Wg[Kt]),title:$e,children:[d.jsx("span",{className:"font-bold",children:me}),d.jsx("span",{className:"text-tui-sm opacity-70",children:_t})]});return d.jsxs("div",{"data-testid":"key-toolbar",className:ne("z-20 flex shrink-0 select-none flex-col border-t border-tui-border bg-tui-mantle",l?"pb-[max(env(safe-area-inset-bottom,0px),0.125rem)]":"pb-[max(env(safe-area-inset-bottom,0px),0.25rem)]"),role:"toolbar","aria-label":m("virtualKeyboard.touchKeyboardShortcuts"),children:[K(),q(!1),ye&&d.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(G=>{const me=`F${G}`;return d.jsxs("button",{type:"button",onClick:()=>Le(ve[me]),className:ne(Ol,dr,A),children:["F",G]},me)})}),oe&&d.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:[Ue(ve.CTRL_C,"^C",m("virtualKeyboard.ctrlCTitle"),m("virtualKeyboard.badgeSigint"),"bad"),Ue(ve.CTRL_D,"^D",m("virtualKeyboard.ctrlDTitle"),m("virtualKeyboard.badgeEof")),Ue(ve.CTRL_Z,"^Z",m("virtualKeyboard.ctrlZTitle"),m("virtualKeyboard.badgeTstp"),"warn"),Ue(ve.CTRL_L,"^L",m("virtualKeyboard.ctrlLTitle"),m("virtualKeyboard.badgeClear")),Ue(ve.CTRL_R,"^R",m("virtualKeyboard.ctrlRTitle"),m("virtualKeyboard.badgeSearch")),Ue(ve.CTRL_A,"^A",m("virtualKeyboard.ctrlATitle"),m("virtualKeyboard.badgeStart")),Ue(ve.CTRL_E,"^E",m("virtualKeyboard.ctrlETitle"),m("virtualKeyboard.badgeEnd")),Ue(ve.CTRL_K,"^K",m("virtualKeyboard.ctrlKTitle"),m("virtualKeyboard.badgeKill"))]}),ie&&d.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(G=>d.jsx("button",{type:"button",onClick:()=>Le(G,!0),className:ne(Ol,dr,R,"font-bold"),children:G},G))}),d.jsxs("div",{"data-testid":"key-toolbar-row",className:ne("flex flex-nowrap items-center justify-start gap-1",l?"px-1.5 py-1":"px-2 py-1.5"),children:[d.jsxs("div",{className:"relative min-w-0",children:[d.jsxs("div",{ref:I,"data-testid":"key-toolbar-scroll",onScroll:V,className:"scrollbar-none flex flex-nowrap touch-pan-x items-center gap-1 overflow-x-auto overscroll-x-contain",children:[d.jsx("button",{type:"button",onClick:()=>c({toolbarVisible:!1}),className:ne(Ol,R,"mr-1 border-tui-border-dim bg-transparent text-tui-faint hover:border-tui-border hover:text-tui-text"),title:m("virtualKeyboard.collapseToolbar"),"aria-label":m("virtualKeyboard.collapseToolbar"),"aria-expanded":!0,children:d.jsx("span",{"aria-hidden":"true",children:"▾"})}),Be.filter(G=>G.id!=="enter").map(yt),Se(),ue()]}),le&&d.jsx("span",{"aria-hidden":"true","data-testid":"key-toolbar-more",className:"pointer-events-none absolute inset-y-0 right-0 w-4 bg-gradient-to-l from-tui-mantle"})]}),Tt&&yt(Tt)]})]})},PC=["ls -la","clear","git status","pwd","top","exit","cat"],ZC=({isOpen:l,onClose:i})=>{const{sendKey:s,isController:r,warnViewerMode:c,t:f}=rt(),[h,m]=S.useState("");if(!l)return null;const b=y=>{if(y&&y.preventDefault(),!r){c();return}h.length>0?(s(h+"\r"),m("")):s("\r")},p=y=>{if(!r){c();return}s(y+"\r")};return d.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:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-tui font-bold uppercase text-tui-accent",children:f("virtualKeyboard.helperTitle")}),d.jsx(Oe,{variant:"ghost",onClick:i,"aria-label":f("virtualKeyboard.closeHelper"),children:"esc"})]}),d.jsx("div",{className:"scrollbar-none flex items-center gap-1 overflow-x-auto py-0.5",children:PC.map(y=>d.jsx("button",{type:"button",onClick:()=>p(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))}),d.jsxs("form",{onSubmit:b,className:"flex items-center gap-1.5",children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none font-bold text-tui-ok",children:"$"}),d.jsxs("div",{className:"relative flex-1",children:[d.jsx("label",{htmlFor:"virtual-keyboard-input",className:"sr-only",children:f("virtualKeyboard.placeholder")}),d.jsx(Sn,{id:"virtual-keyboard-input",name:"terminal-input",type:"text",value:h,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"}),h.length>0&&d.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:d.jsx("span",{"aria-hidden":"true",children:Fe.cross})})]}),d.jsx(Oe,{variant:"primary",type:"submit",title:f("virtualKeyboard.sendButton"),glyph:"⏎",className:"h-9 shrink-0",children:d.jsx("span",{className:"hidden sm:inline",children:f("virtualKeyboard.sendButton")})})]})]})};function nc(l,i){const s=(r,c)=>i?i(r):c;switch(l){case"connected":return{label:s("connection.live","Live"),level:"ok",needsAttention:!1};case"connecting":return{label:s("connection.connecting","Connecting"),level:"warn",needsAttention:!0};case"reconnecting":return{label:s("connection.reconnecting","Reconnecting"),level:"warn",needsAttention:!0,actionLabel:s("connection.reconnectNow","Reconnect now")};case"error":return{label:s("connection.error","Error"),level:"bad",needsAttention:!0,actionLabel:s("connection.retry","Retry")};default:return{label:s("connection.offline","Offline"),level:"idle",needsAttention:!0,actionLabel:s("connection.connect","Connect")}}}const QC={connected:"ok",connecting:"warn",reconnecting:"warn",error:"bad",disconnected:"idle"},WC=({isOpen:l,onClose:i,isAddMode:s=!1})=>{const{settings:r,updateSettings:c,connect:f,disconnect:h,connectionState:m,hostId:b,addToast:p,t:y,activeProfile:v,activeProfileId:w,addProfileAndConnect:T,renameProfile:A}=rt(),[$,R]=S.useState(r.wsUrl),[O,j]=S.useState(r.token),[Y,se]=S.useState(r.pairCode),[fe,Q]=S.useState(r.clientId),[K,q]=S.useState((v==null?void 0:v.displayName)||""),[ue,ye]=S.useState(r.autoReconnect),[Ne,ie]=S.useState(!1);if(S.useEffect(()=>{l&&(R(r.wsUrl),j(s?"":r.token),se(s?"":r.pairCode),Q(r.clientId),q(s?"":(v==null?void 0:v.displayName)||""),ye(r.autoReconnect))},[l,s,r,v]),!l)return null;const he=I=>{I.preventDefault();const le={wsUrl:$.trim()||"/ws/client",token:O.trim(),pairCode:Y.trim().toUpperCase(),clientId:fe.trim()||r.clientId,autoReconnect:ue};if(!le.token&&!le.pairCode){p("warning",y("pairing.credentialsRequired"));return}s?T({...le,displayName:K.trim()||void 0}):(c(le),w&&K.trim()&&A(w,K),h(),f({wsUrl:le.wsUrl,token:le.token||void 0,pairCode:le.pairCode||void 0,clientId:le.clientId,autoReconnect:ue})),i()},oe=()=>{const I=`client-${Math.random().toString(36).substring(2,8)}`;Q(I)},pe=()=>{const I=new URL(window.location.href);I.search="",Y.trim()&&I.searchParams.set("pairCode",Y.trim().toUpperCase()),Kl(I.toString()).then(le=>{if(le==="failed"){p("error",y("clipboard.copyFailed"));return}ie(!0),p("success",y("toasts.pairingLinkCopied")),setTimeout(()=>ie(!1),2e3)})},k=QC[m]??"idle";return d.jsxs(tc,{isOpen:l,onClose:i,title:y(s?"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:d.jsxs(d.Fragment,{children:[m==="connected"&&d.jsx(Oe,{variant:"danger",onClick:()=>{h(),i()},children:y("common.disconnect")}),d.jsx(Oe,{variant:"primary",type:"submit",form:"pairing-form",children:y("pairing.saveAndConnect")})]}),children:[d.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:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(_n,{level:k}),d.jsx("span",{className:"text-tui-muted",children:y("common.status")}),d.jsx("span",{className:ne(k==="ok"?"text-tui-ok":k==="bad"?"text-tui-bad":k==="warn"?"text-tui-warn":"text-tui-faint"),children:nc(m,y).label})]}),b&&d.jsxs("span",{className:"flex items-center gap-1.5 text-tui-muted",children:[y("common.host")," ",d.jsx("span",{className:"text-tui-text",children:b})]})]}),d.jsxs("form",{id:"pairing-form",onSubmit:he,className:"space-y-3",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"pairing-name",children:y("pairing.displayNameLabel")}),d.jsx(Sn,{id:"pairing-name",type:"text",value:K,onChange:I=>q(I.target.value),placeholder:y("pairing.displayNamePlaceholder"),maxLength:64,autoComplete:"off"}),d.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.displayNameHelp")})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"pairing-code",hint:y("pairing.pairCodeNote"),children:y("pairing.pairCodeLabel")}),d.jsx(Sn,{id:"pairing-code",type:"text",value:Y,onChange:I=>se(I.target.value.toUpperCase()),placeholder:y("pairing.pairCodePlaceholder"),maxLength:12,className:"uppercase"}),d.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.pairCodeHelp")})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"pairing-token",hint:y("pairing.tokenNote"),children:y("pairing.tokenLabel")}),d.jsx(Sn,{id:"pairing-token",type:"password",value:O,onChange:I=>j(I.target.value),placeholder:y("pairing.tokenPlaceholder")})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"pairing-ws",children:y("pairing.wsUrlLabel")}),d.jsx(Sn,{id:"pairing-ws",type:"text",value:$,onChange:I=>R(I.target.value),placeholder:y("pairing.wsUrlPlaceholder")}),d.jsx("p",{className:"text-tui-sm text-tui-faint",children:y("pairing.wsUrlDefaultNote")})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"pairing-client-id",children:y("pairing.clientIdLabel")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Sn,{id:"pairing-client-id",type:"text",value:fe,onChange:I=>Q(I.target.value),className:"flex-1"}),d.jsx(Oe,{onClick:oe,title:y("pairing.regenerateClientIdTitle"),className:"shrink-0",children:y("pairing.newIdButton")})]})]}),d.jsx("div",{className:"border-t border-tui-border-dim pt-2",children:d.jsx(D1,{checked:ue,onChange:ye,label:y("pairing.autoReconnectLabel"),description:y("pairing.autoReconnectDesc")})}),d.jsx("div",{className:"border-t border-tui-border-dim pt-2",children:d.jsx(Oe,{onClick:pe,block:!0,glyph:Ne?Fe.check:"⧉",className:ne(Ne&&"border-tui-ok text-tui-ok"),children:y("pairing.copyDirectLink")})})]})]})},My={"gnome-terminal":"GNOME Terminal",ptyxis:"Ptyxis",tilix:"Tilix",konsole:"Konsole","xfce4-terminal":"Xfce Terminal",kitty:"kitty",alacritty:"Alacritty",ghostty:"Ghostty",wezterm:"WezTerm",foot:"foot",vscode:"VS Code",iterm2:"iTerm2","apple-terminal":"Terminal",xterm:"xterm",urxvt:"urxvt"},JC=["host_font_unavailable","host_font_timeout","disconnected","font_api_unavailable"],eT=()=>{const{hostFont:l,loadHostFont:i,declineHostFont:s,settings:r,herdrLaunch:c,hostname:f,activeProfile:h,addToast:m,t:b}=rt(),{font:p,status:y,glyphs:v}=l,w=y==="loading"||v.status==="loading",T=y==="failed"||v.status==="failed",A=S.useRef(!1);S.useEffect(()=>{A.current&&!w&&!T&&l.interactive&&m("success",b("hostFont.loaded")),A.current=w&&l.interactive},[w,T,l.interactive,m,b]);const $=y==="available"||v.status==="available",R=l.interactive&&(w||T);if(!(p&&r.fontFamily==="host"&&!c&&($||R)))return null;const j=y==="available"||l.interactive&&(y==="loading"||y==="failed"),Y=v.source&&(v.status==="available"||l.interactive&&(v.status==="loading"||v.status==="failed")),se=f||(h==null?void 0:h.displayName)||b("herdrLaunch.thisHost"),fe=[p.sizePx?`${Math.round(p.sizePx)}px`:null,p.source?My[p.source]||p.source:null].filter(Boolean).join(b("hostFont.detailSeparator")),Q=l.error&&JC.includes(l.error)?l.error:"other",K=l.totalBytes?l.receivedBytes/l.totalBytes:0;return d.jsx("div",{"data-testid":"host-font-prompt",className:"absolute inset-0 z-30 flex items-center justify-center bg-tui-crust/85 p-3",children:d.jsxs(gn,{title:b("hostFont.title"),tone:y==="failed"?"bad":"accent",className:"w-full max-w-md",bodyClassName:"space-y-3","aria-label":b("hostFont.title"),children:[d.jsx("p",{className:"leading-snug text-tui-text",children:j||!v.source?b("hostFont.body",{host:se,family:p.family,detail:fe?b("hostFont.detail",{detail:fe}):""}):b("hostFont.bodyGlyphsOnly",{host:se,family:v.source.family})}),w?d.jsxs("div",{className:"space-y-1",role:"status",children:[d.jsx(O1,{value:K,width:32,className:"max-w-full overflow-hidden"}),d.jsx("p",{className:"text-tui-sm text-tui-muted",children:b("hostFont.loading",{received:dd(l.receivedBytes),total:dd(l.totalBytes)})})]}):d.jsxs(d.Fragment,{children:[T?d.jsx(Bl,{tone:"bad",children:b("hostFont.failed",{reason:b(`hostFont.reasons.${Q}`)})}):d.jsxs("div",{className:"space-y-1 text-tui-sm leading-snug text-tui-faint",children:[j&&p.faces.length?d.jsx("p",{children:b("hostFont.download",{count:p.faces.length,size:dd(l.totalBytes)})}):null,Y&&v.source?d.jsx("p",{children:b(v.source.scope==="all"?"hostFont.glyphsAll":"hostFont.glyphs",{family:v.source.family})}):null]}),d.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[d.jsx(Oe,{onClick:s,children:b("hostFont.decline")}),d.jsx(Oe,{variant:"primary",onClick:i,autoFocus:!0,children:b(T?"common.retry":"hostFont.load")})]})]})]})})},zl=ne(ec,"py-0"),tT="h-7 py-0",Nd="h-7 py-0 px-1.5",Ko="text-tui-bad hover:border-tui-bad hover:text-tui-bad",nT=["grid items-center gap-x-2 gap-y-1 py-1","grid-cols-[4rem_minmax(0,1fr)_7rem] [grid-template-areas:'cap_label_actions'_'combo_combo_default']","sm:grid-cols-[4rem_minmax(0,1fr)_9rem_7rem_7rem] sm:[grid-template-areas:'cap_label_combo_default_actions']"].join(" "),iT=({isOpen:l,onClose:i,initialTab:s,onOpenAdmin:r})=>{var Mt;const{settings:c,updateSettings:f,addToast:h,language:m,setLanguage:b,t:p,agentProfile:y,connectionState:v,hostFont:w,syncHostFont:T,terminalFontFamily:A,terminalFontSize:$}=rt(),[R,O]=S.useState("general"),[j,Y]=S.useState(null),[se,fe]=S.useState({}),Q=S.useRef({}),[K,q]=S.useState(""),[ue,ye]=S.useState(""),[Ne,ie]=S.useState(!1);if(S.useEffect(()=>{!l||!s||(O(s),Y(null))},[l,s]),!l)return null;const he=Dd.find(E=>E.id===c.fontFamily),oe=(E,ce)=>E==="host"||E==="system"?p(`fontPresets.${E}`):ce,pe=(()=>{const{font:E,status:ce}=w,de=w.totalBytes?Math.round(w.receivedBytes/w.totalBytes*100):0,_e=p(`settings.hostFontStatus.${ce}`,{percent:de});return E?[E.family,E.sizePx?`${Math.round(E.sizePx)}px`:null,E.source?My[E.source]||E.source:null,_e].filter(Boolean).join(" · "):_e})(),k=(Mt=w.font)!=null&&Mt.sizePx?cs(w.font.sizePx):null,I=w.glyphs.source&&w.glyphs.status!=="none"?p("settings.hostGlyphLine",{family:w.glyphs.source.family,status:p(`settings.hostGlyphStatus.${w.glyphs.status}`,{count:w.glyphs.covered.toLocaleString()})}):null,le=c.virtualKeys&&c.virtualKeys.length>0?c.virtualKeys:gr(),re=j||y,V=c.agentKeymaps[re]||{},Re=jb(re,V),Ae=Db(re,V),xe=Ae.filter(E=>!E.hidden).length,Se=E=>E.custom?E.customLabel||"":p(`agentActions.${E.labelKey}`),Le=E=>{try{return ur(E.combo)}catch{return E.combo}},Be=E=>{f({agentKeymaps:{...c.agentKeymaps,[re]:E}})},ot=(E,ce)=>{var de;Be({...V,actions:{...V.actions,[E]:{...(de=V.actions)==null?void 0:de[E],...ce}}})},Xe=E=>{ot(E.id,{keys:E.defaultCombo})},ze=(E,ce)=>{const de=E+(ce==="up"?-1:1);if(de<0||de>=Re.length)return;const _e=Re.map(mt=>mt.id);[_e[E],_e[de]]=[_e[de],_e[E]],Be({...V,order:_e})},yt=E=>{var ce;Be({...V,custom:(V.custom||[]).filter(de=>de.id!==E),order:(ce=V.order)==null?void 0:ce.filter(de=>de!==E)})},Tt=()=>Be(mw(V)),Ue=()=>{const E={...c.agentKeymaps};delete E[re],f({agentKeymaps:E})},G=()=>{const E=K.trim();if(!E)return;try{Ri(ue)}catch{return}const ce=`custom-${Date.now().toString(36)}`;Be({...V,custom:[...V.custom||[],{id:ce,label:E,keys:ue.trim()}],order:[...Re.map(de=>de.id),ce]}),q(""),ye("")},me=E=>E instanceof ki?p(`agentKeymaps.errors.${E.code}`,E.params):String(E),$e=(E,ce)=>`${E}:${ce}`,_t=(E,ce)=>{const de=$e(re,E);Q.current={...Q.current,[de]:ce},fe(Q.current);try{Ri(ce),ot(E,{keys:ce})}catch{}},Kt=E=>{const ce=$e(re,E),de=Q.current[ce];if(de!==void 0){delete Q.current[ce],fe({...Q.current});try{Ri(de),ot(E,{keys:de})}catch{}}},hn=typeof window<"u"&&window.isSecureContext&&"Notification"in window,Yt=()=>{const E=Sb();f({fontSize:E.fontSize,fontSizeFollowsHost:E.fontSizeFollowsHost,fontFamily:E.fontFamily,toolbarVisible:E.toolbarVisible,vibrateOnKeyPress:E.vibrateOnKeyPress,predictiveEcho:E.predictiveEcho,agentAlertBadge:E.agentAlertBadge,agentAlertSound:E.agentAlertSound,agentAlertVibrate:E.agentAlertVibrate,agentAlertNotify:E.agentAlertNotify,language:E.language,virtualKeys:E.virtualKeys}),h("info",p("settings.resetDefaultsToast"))},ct=E=>{const ce=le.map(de=>de.id===E?{...de,enabled:!de.enabled}:de);f({virtualKeys:ce})},Ke=(E,ce)=>{const de=ce==="up"?E-1:E+1;if(de<0||de>=le.length)return;const _e=[...le],mt=_e[E];_e[E]=_e[de],_e[de]=mt,f({virtualKeys:_e})},bn=E=>{if(le.some(de=>de.id===E.id)){const de=le.map(_e=>_e.id===E.id?{..._e,enabled:!0}:_e);f({virtualKeys:de})}else{const de=[...le,{...E,enabled:!0}];f({virtualKeys:de})}ie(!1)},ut=E=>{const ce=le.filter(de=>de.id!==E);f({virtualKeys:ce})},qe=()=>{f({virtualKeys:gr()}),h("info",p("toasts.keyLayoutReset"))},wt=10,yn=24,We={offLabel:p("settings.toggleOff"),onLabel:p("settings.toggleOn")},Pe=k?p("settings.fontSizeFollowHost",{size:k}):p("settings.fontSizeFollowHostUnknown");return d.jsxs(tc,{isOpen:l,onClose:i,title:p("settings.title"),subtitle:p("settings.subtitle"),closeLabel:p("common.closeDialog"),size:"lg",fixedHeight:!0,hints:[{keys:"esc",action:p("common.close")}],footer:d.jsxs(d.Fragment,{children:[d.jsx(Oe,{variant:"ghost",onClick:Yt,className:Ko,children:p("settings.resetDefaults")}),d.jsx(Oe,{variant:"primary",onClick:i,children:p("common.done")})]}),children:[d.jsx(sf,{tabs:[{id:"general",label:p("settings.tabGeneral"),index:1},{id:"virtualKeys",label:p("settings.tabVirtualKeys"),index:2},{id:"agentKeymaps",label:p("settings.tabAgentKeymaps"),index:3}],activeId:R,onSelect:E=>O(E),className:"mb-3 border-b border-tui-border-dim pb-1"}),R==="general"&&d.jsxs("div",{className:"space-y-4",children:[d.jsx(pi,{title:p("settings.sectionInterface"),children:d.jsx(Ln,{label:p("settings.languageLabel"),control:d.jsx(Cg,{name:"ui-language","aria-label":p("settings.languageLabel"),value:m,onChange:b,options:[{value:"zh",label:"简体中文"},{value:"en",label:"English"}]})})}),d.jsxs(pi,{title:p("settings.sectionFont"),children:[d.jsx(Ln,{label:p("settings.fontFamilyLabel"),htmlFor:"terminal-font-select",control:d.jsxs(Qo,{id:"terminal-font-select",value:c.fontFamily,onChange:E=>f({fontFamily:E.target.value}),"aria-label":p("settings.fontFamilyLabel"),className:zl,children:[!he&&d.jsx("option",{value:c.fontFamily,children:c.fontFamily}),Dd.map(E=>d.jsx("option",{value:E.id,children:oe(E.id,E.name)},E.id))]})}),c.fontFamily==="host"&&d.jsx(Ln,{label:p("settings.hostFontLabel"),hint:d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-testid":"host-font-status",className:"block break-words text-tui-info",children:pe}),I?d.jsx("span",{"data-testid":"host-glyph-status",className:"block break-words",children:I}):null]}),control:d.jsx(Oe,{block:!0,onClick:T,disabled:v!=="connected"||w.status==="loading"||w.glyphs.status==="loading",className:zl,children:p("settings.hostFontSync")})}),d.jsx(Ln,{label:p("settings.fontSizeLabel",{size:$}),hint:p("settings.fontSizeHint"),htmlFor:"terminal-font-size",control:d.jsx("div",{className:ne("flex items-center",ec),children:d.jsx("input",{id:"terminal-font-size",type:"range",min:wt,max:yn,step:1,value:$,onChange:E=>f({fontSize:Number(E.target.value),fontSizeFollowsHost:!1}),className:"h-1 w-full cursor-pointer appearance-none bg-tui-border accent-tui-accent"})})}),d.jsx(Ln,{label:Pe,control:d.jsx(Dl,{label:Pe,...We,checked:c.fontSizeFollowsHost,onChange:E=>f(E?{fontSizeFollowsHost:!0}:{fontSizeFollowsHost:!1,fontSize:$})})}),d.jsx("div",{className:"py-1.5",children:d.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:A,fontSize:`${$}px`},children:[d.jsx("span",{className:"text-tui-ok",children:"$"}),' echo "Herdr 0O 1lI ',' [] () -> => !="']})})]}),d.jsxs(pi,{title:p("settings.sectionInput"),children:[d.jsx(Ln,{label:p("settings.predictiveEchoLabel"),hint:p("settings.predictiveEchoDesc"),control:d.jsx(Cg,{name:"predictive-echo","aria-label":p("settings.predictiveEchoLabel"),value:c.predictiveEcho,onChange:E=>f({predictiveEcho:E}),options:[{value:"auto",label:p("settings.predictiveEchoAuto")},{value:"always",label:p("settings.predictiveEchoAlways")},{value:"off",label:p("settings.predictiveEchoOff")}]})}),d.jsx(Ln,{label:p("settings.touchKeyToolbar"),hint:p("settings.touchKeyToolbarDesc"),control:d.jsx(Dl,{label:p("settings.touchKeyToolbar"),...We,checked:c.toolbarVisible,onChange:E=>f({toolbarVisible:E})})}),d.jsx(Ln,{label:p("settings.touchHaptics"),hint:p("settings.touchHapticsDesc"),control:d.jsx(Dl,{label:p("settings.touchHaptics"),...We,checked:c.vibrateOnKeyPress,onChange:E=>f({vibrateOnKeyPress:E})})})]}),d.jsxs(pi,{title:p("settings.agentAlertsLabel"),children:[d.jsx(Ln,{label:p("settings.agentAlertBadge"),hint:p("settings.agentAlertBadgeDesc"),control:d.jsx(Dl,{label:p("settings.agentAlertBadge"),...We,checked:c.agentAlertBadge,onChange:E=>f({agentAlertBadge:E})})}),d.jsx(Ln,{label:p("settings.agentAlertVibrate"),hint:p("settings.agentAlertVibrateDesc"),control:d.jsx(Dl,{label:p("settings.agentAlertVibrate"),...We,checked:c.agentAlertVibrate,onChange:E=>f({agentAlertVibrate:E})})}),d.jsx(Ln,{label:p("settings.agentAlertSound"),hint:p("settings.agentAlertSoundDesc"),control:d.jsx(Dl,{label:p("settings.agentAlertSound"),...We,checked:c.agentAlertSound,onChange:E=>{f({agentAlertSound:E}),E&&(Hb(),Ub("done"))}})}),hn&&d.jsx(Ln,{label:p("settings.agentAlertNotify"),hint:p("settings.agentAlertNotifyDesc"),control:d.jsx(Dl,{label:p("settings.agentAlertNotify"),...We,checked:c.agentAlertNotify,onChange:E=>{if(E&&Notification.permission!=="granted"){Notification.requestPermission().then(ce=>f({agentAlertNotify:ce==="granted"}));return}f({agentAlertNotify:E})}})})]}),r&&d.jsx(pi,{title:p("settings.sectionAdmin"),children:d.jsx(Ln,{label:p("settings.adminEntry"),hint:p("settings.adminEntryHint"),control:d.jsx(Oe,{block:!0,variant:"primary",glyph:Fe.arrowRight,onClick:r,className:zl,children:p("settings.adminEntryOpen")})})})]}),R==="virtualKeys"&&d.jsxs("div",{className:"space-y-3",children:[d.jsx(pi,{title:p("virtualKeyboard.customizeTitle"),aside:d.jsx(Oe,{variant:"ghost",onClick:qe,className:ne(Ko,Nd),children:p("virtualKeyboard.resetLayout")}),children:le.map((E,ce)=>{const de=Ld(E,p);return d.jsxs("div",{className:"flex items-center gap-2 py-1",children:[d.jsx(Tg,{className:ne("w-16 shrink-0 truncate",!E.enabled&&"opacity-50"),children:E.label}),d.jsx("span",{className:ne("min-w-0 flex-1 truncate text-tui",E.enabled?"text-tui-text":"text-tui-faint"),children:de}),d.jsx(Dl,{label:`${p("virtualKeyboard.enableKey")} ${E.label}`,...We,checked:E.enabled,onChange:()=>ct(E.id),className:"h-7 w-24 shrink-0"}),d.jsx(ua,{disabled:ce===0,onClick:()=>Ke(ce,"up"),title:p("virtualKeyboard.moveUp"),"aria-label":p("virtualKeyboard.moveUp"),children:"↑"}),d.jsx(ua,{disabled:ce===le.length-1,onClick:()=>Ke(ce,"down"),title:p("virtualKeyboard.moveDown"),"aria-label":p("virtualKeyboard.moveDown"),children:"↓"}),d.jsx(ua,{variant:"danger",onClick:()=>ut(E.id),title:p("virtualKeyboard.deleteKeyTitle"),"aria-label":p("virtualKeyboard.deleteKeyTitle"),children:Fe.cross})]},E.id)})}),d.jsx(Oe,{block:!0,glyph:"+",onClick:()=>ie(!Ne),className:ne("border-dashed",zl),children:p("virtualKeyboard.addKey")}),Ne&&d.jsx(pi,{title:p("virtualKeyboard.availableKeys"),children:d.jsx("div",{className:"flex flex-wrap gap-1 py-1.5",children:dx.map(E=>{const ce=le.some(de=>de.id===E.id);return d.jsxs("button",{type:"button",onClick:()=>bn(E),title:Ld(E,p),className:ne("tui-focusable flex h-7 select-none items-center gap-1 border px-1.5 text-tui-sm transition-colors",ce?"border-tui-border-dim text-tui-faint":"border-tui-border text-tui-text hover:border-tui-accent hover:text-tui-accent"),children:[d.jsx("span",{children:E.label}),d.jsx("span",{"aria-hidden":"true",className:ce?"text-tui-ok":"text-tui-accent",children:ce?Fe.check:"+"})]},E.id)})})})]}),R==="agentKeymaps"&&d.jsxs("div",{className:"space-y-4",children:[d.jsx(pi,{title:p("agentKeymaps.settingsProfileLabel"),aside:d.jsx(Oe,{variant:"ghost",onClick:Ue,className:ne(Ko,Nd),children:p("agentKeymaps.restoreProfile")}),children:d.jsx(Ln,{label:p("agentKeymaps.profileRowLabel"),htmlFor:"agent-keymap-profile",hint:da[re].configHint?p("agentKeymaps.configHint",{path:da[re].configHint}):void 0,control:d.jsx(Qo,{id:"agent-keymap-profile","aria-label":p("agentKeymaps.settingsProfileLabel"),value:re,onChange:E=>Y(E.target.value),className:zl,children:aw.map(E=>d.jsx("option",{value:E,children:da[E].name},E))})})}),d.jsx(pi,{title:p("agentKeymaps.barGroup"),aside:d.jsx(Oe,{variant:"ghost",onClick:Tt,className:ne(Ko,Nd),children:p("agentKeymaps.restoreBar")}),children:d.jsxs("div",{className:"space-y-2 py-1.5",children:[d.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:p("agentKeymaps.barHint",{profile:da[re].name,count:xe})}),d.jsx("div",{role:"group","aria-label":p("agentKeymaps.barGroup"),"data-testid":"agent-bar-choices",className:"flex flex-wrap gap-1",children:Ae.map(E=>{const ce=Se(E),de=Le(E),_e=!E.hidden;return d.jsxs("button",{type:"button","data-testid":`agent-bar-toggle-${E.id}`,"aria-pressed":_e,onClick:()=>ot(E.id,{hidden:_e}),title:`${de} ${ce}`.trim(),className:ne("tui-focusable inline-flex h-7 select-none items-center gap-1 border px-1.5 text-tui-sm transition-colors",_e?"border-tui-accent bg-tui-accent text-tui-crust":"border-tui-border text-tui-muted hover:border-tui-accent hover:text-tui-accent"),children:[d.jsx("span",{"aria-hidden":"true",className:"font-bold",children:_e?Fe.check:"+"}),d.jsx("span",{className:"font-bold",children:de}),d.jsx("span",{className:_e?void 0:"opacity-80",children:ce})]},E.id)})})]})}),d.jsx(pi,{title:p("agentKeymaps.listGroup",{profile:da[re].name}),children:Re.map((E,ce)=>{var ln,It;const de=Se(E),_e=p("agentKeymaps.defaultCombo",{combo:ur(E.defaultCombo)}),mt=((It=(ln=V.actions)==null?void 0:ln[E.id])==null?void 0:It.keys)??E.combo,$t=$e(re,E.id),dt=se[$t]??mt;let rn="",Wt=null;try{Ri(dt),rn=ur(dt)}catch(Ge){Wt=me(Ge)}return d.jsxs("div",{"data-testid":`agent-setting-row-${E.id}`,className:nT,children:[d.jsx(Tg,{className:"w-full overflow-hidden whitespace-nowrap font-bold [grid-area:cap]",children:rn||"—"}),d.jsxs("span",{className:"min-w-0 truncate text-tui text-tui-text [grid-area:label]",title:de,children:[de,!E.verified&&d.jsx("span",{className:"ml-1 text-tui-sm text-tui-faint",children:p("agentKeymaps.unverified")})]}),d.jsxs("label",{className:"sr-only",htmlFor:`agent-combo-${E.id}`,children:[p("agentKeymaps.shortcutLabel")," ",de]}),d.jsx(Sn,{id:`agent-combo-${E.id}`,"aria-label":`${p("agentKeymaps.shortcutLabel")} ${de}`,value:dt,onChange:Ge=>_t(E.id,Ge.target.value),onBlur:()=>Kt(E.id),onKeyDown:Ge=>{Ge.key==="Enter"&&Ge.currentTarget.blur()},placeholder:p("agentKeymaps.comboPlaceholder"),"aria-invalid":!!Wt,className:ne("w-full min-w-0 [grid-area:combo]",tT)}),d.jsx("span",{className:"min-w-0 truncate text-tui-sm text-tui-faint [grid-area:default]",title:_e,children:_e}),d.jsxs("div",{className:"flex items-center justify-end [grid-area:actions]",children:[d.jsx(ua,{onClick:()=>Xe(E),title:p("agentKeymaps.resetAction"),"aria-label":`${p("agentKeymaps.resetAction")} ${de}`,children:"↺"}),d.jsx(ua,{disabled:ce===0,onClick:()=>ze(ce,"up"),title:p("agentKeymaps.moveUp"),"aria-label":`${p("agentKeymaps.moveUp")} ${de}`,children:"↑"}),d.jsx(ua,{disabled:ce===Re.length-1,onClick:()=>ze(ce,"down"),title:p("agentKeymaps.moveDown"),"aria-label":`${p("agentKeymaps.moveDown")} ${de}`,children:"↓"}),E.custom?d.jsx(ua,{variant:"danger",onClick:()=>yt(E.id),title:p("agentKeymaps.removeCustom"),"aria-label":`${p("agentKeymaps.removeCustom")} ${de}`,children:Fe.cross}):d.jsx("span",{"aria-hidden":"true",className:"h-7 w-7 shrink-0"})]}),Wt&&d.jsx("p",{className:"col-span-full text-tui-sm text-tui-bad",role:"alert",children:p("agentKeymaps.invalidCombo",{error:Wt})})]},E.id)})}),d.jsx(pi,{title:p("agentKeymaps.addCustom"),children:d.jsxs("div",{className:"space-y-1 py-1.5",children:[d.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[d.jsxs("label",{className:"min-w-[9rem] flex-1 space-y-1 text-tui-sm text-tui-muted",children:[d.jsx("span",{children:p("agentKeymaps.customLabel")}),d.jsx(Sn,{value:K,onChange:E=>q(E.target.value),className:zl})]}),d.jsxs("label",{className:"min-w-[9rem] flex-1 space-y-1 text-tui-sm text-tui-muted",children:[d.jsx("span",{children:p("agentKeymaps.customCombo")}),d.jsx(Sn,{value:ue,onChange:E=>ye(E.target.value),placeholder:p("agentKeymaps.comboPlaceholder"),className:zl})]}),d.jsx(Oe,{variant:"primary",glyph:"+",onClick:G,disabled:!K.trim()||!ue.trim(),className:zl,children:p("agentKeymaps.addAction")})]}),ue.trim()&&(()=>{try{return Ri(ue),d.jsx("p",{className:"text-tui-sm text-tui-info",children:ur(ue)})}catch(E){const ce=me(E);return d.jsx("p",{className:"text-tui-sm text-tui-bad",role:"alert",children:ce})}})()]})})]})]})},lT={success:"ok",warning:"warn",error:"bad",info:"accent"},aT={success:Fe.check,warning:Fe.warn,error:Fe.cross,info:"›"},sT=()=>{const{toasts:l,removeToast:i,t:s}=rt();return l.length===0?null:d.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:l.map(r=>{const c=lT[r.type];return d.jsxs("div",{className:ne("pointer-events-auto flex items-start gap-2 border border-tui-border border-l-2 bg-tui-base px-2 py-1 text-tui",li[c].edgeL),role:"alert",children:[d.jsx("span",{"aria-hidden":"true",className:ne("shrink-0 font-bold",li[c].text),children:aT[r.type]}),d.jsx("div",{className:"min-w-0 flex-1 break-words leading-snug text-tui-text",children:r.message}),r.count>1&&d.jsxs("span",{className:"shrink-0 border border-tui-border-dim px-1 text-tui-sm text-tui-muted","aria-label":`×${r.count}`,children:["×",r.count]}),d.jsx("button",{type:"button",onClick:()=>i(r.id),className:"tui-focusable shrink-0 select-none px-0.5 text-tui-faint transition-colors hover:text-tui-bad","aria-label":s("common.dismissNotification"),children:d.jsx("span",{"aria-hidden":"true",children:Fe.cross})})]},r.id)})})},Ay=[{status:"blocked",level:"warn"},{status:"done",level:"ok"},{status:"working",level:"accent"}];function rT(l){return l?l.total>0||Ay.some(({status:i})=>{var s;return(((s=l.counts)==null?void 0:s[i])??0)>0}):!1}const Ey=({className:l,compact:i=!1})=>{const{agentStatus:s,t:r}=rt();if(!s)return null;const c=Ay.map(({status:h,level:m})=>{var b;return{status:h,level:m,count:((b=s.counts)==null?void 0:b[h])??0}}).filter(h=>h.count>0),f=i?c.slice(0,1):c;return f.length===0?s.total===0?null:d.jsxs("span",{"data-testid":"agent-status-chip",className:ne("flex shrink-0 items-center gap-1 px-1 text-tui-muted",l),title:r("agents.title"),children:[d.jsx(_n,{level:"idle"}),d.jsx("span",{className:"text-tui-faint",children:r("agents.allIdle")})]}):d.jsx("span",{"data-testid":"agent-status-chip",className:ne("flex shrink-0 items-center gap-2 px-1",l),title:r("agents.title"),children:f.map(({status:h,level:m,count:b})=>d.jsxs("span",{className:"flex items-center gap-1 text-tui-muted",children:[d.jsx(_n,{level:m}),d.jsx("span",{className:"text-tui-text",children:b}),d.jsx("span",{className:"text-tui-faint",children:r(`agents.${h}`)})]},h))})},uf=({onAddProfile:l,mobile:i=!1,statusBar:s=!1})=>{const{profiles:r,activeProfileId:c,activeProfile:f,connectionState:h,switchProfile:m,renameProfile:b,removeProfile:p,t:y}=rt(),[v,w]=S.useState(!1),[T,A]=S.useState(null),[$,R]=S.useState(""),O=S.useRef(null);S.useEffect(()=>{if(!v)return;const K=q=>{O.current&&!O.current.contains(q.target)&&w(!1)};return document.addEventListener("pointerdown",K),()=>document.removeEventListener("pointerdown",K)},[v]);const j=(K,q)=>{A(K),R(q)},Y=K=>{const q=$.trim();q&&b(K,q),A(null)},se=K=>{typeof window<"u"&&!window.confirm(y("profiles.removeConfirm"))||(p(K),A(null))},fe=(f==null?void 0:f.displayName)||y("profiles.addHost"),Q=h==="connected"?"ok":h==="connecting"||h==="reconnecting"?"warn":h==="error"?"bad":"idle";return d.jsxs("div",{ref:O,className:ne("relative min-w-0",i&&"w-full",s&&"flex-1"),children:[d.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":v,"aria-label":y("profiles.switcherLabel"),onClick:()=>w(K=>!K),className:ne("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",s?"min-h-11 w-full max-w-none px-2":i?"min-h-11 w-full px-2":"min-h-[24px] max-w-[18rem] px-1"),children:[d.jsx(_n,{level:Q}),d.jsx("span",{className:ne("truncate text-tui-text",s&&"min-w-0 flex-1"),children:fe}),d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-faint",children:v?Fe.chevronDown:Fe.chevronRight})]}),v&&d.jsxs("div",{role:"menu","aria-label":y("profiles.switcherLabel"),className:ne("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",s?"w-80 max-w-[calc(100vw-1rem)]":i?"inset-x-0 bottom-auto top-full mt-1 mb-0 w-full":"w-80 max-w-[calc(100vw-1rem)]"),children:[d.jsx("div",{className:"border-b border-tui-border-dim px-2 py-1 text-tui-sm uppercase text-tui-faint",children:y("profiles.title")}),r.length===0?d.jsx("p",{className:"px-2 py-2 text-tui-sm text-tui-muted",children:y("profiles.empty")}):r.map(K=>{const q=K.id===c,ue=K.id===T;return d.jsxs("div",{role:"none",className:"border-b border-tui-border-dim last:border-b-0",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs("button",{type:"button",role:"menuitem","aria-current":q?"true":void 0,onClick:()=>{m(K.id),w(!1)},className:ne("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",q?"text-tui-accent":"text-tui-text"),children:[d.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0",children:q?Fe.cursor:""}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block truncate font-bold",children:K.displayName}),d.jsx("span",{className:"block truncate text-tui-sm text-tui-faint",title:K.hostname||K.hostId,children:K.hostname||K.hostId||K.wsUrl})]}),q&&d.jsx("span",{className:"shrink-0 text-tui-sm text-tui-ok",children:y("profiles.current")})]}),d.jsx("button",{type:"button",role:"menuitem","aria-label":y("profiles.rename"),title:y("profiles.rename"),onClick:()=>j(K.id,K.displayName),className:"tui-focusable min-h-11 min-w-11 px-2 text-tui-muted hover:text-tui-accent",children:Fe.ellipsis})]}),ue&&d.jsxs("div",{className:"flex items-center gap-1 px-2 pb-2",children:[d.jsx("input",{autoFocus:!0,value:$,maxLength:64,onChange:ye=>R(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&Y(K.id),ye.key==="Escape"&&A(null)},"aria-label":y("profiles.rename"),className:"tui-input min-w-0 flex-1 px-2 py-1 text-tui"}),d.jsx(Oe,{onClick:()=>Y(K.id),variant:"primary",className:"min-h-11",children:y("common.save")}),d.jsx(Oe,{onClick:()=>se(K.id),variant:"danger",className:"min-h-11",children:y("profiles.remove")})]})]},K.id)}),d.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{w(!1),l()},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:[d.jsx("span",{"aria-hidden":"true",children:"+"}),d.jsx("span",{children:y("profiles.addHost")})]})]})]})};function Ny(){const{updateStatus:l,ignoredUpdate:i}=rt();return!!(l!=null&&l.updateAvailable)&&i!==(l==null?void 0:l.latest)}const ky=({compact:l=!1,className:i})=>{const{updateStatus:s,t:r}=rt(),c=Ny(),[f,h]=S.useState(!1);if(!c||!s)return null;const{latest:m,restartPending:b}=s,p=b?r("update.chipRestart",{version:m}):l?r("update.chipCompact",{version:m}):r("update.chip",{version:m});return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button","data-testid":"update-chip",onClick:()=>h(!0),title:r("update.title"),className:ne("tui-focusable shrink-0 whitespace-nowrap px-1 text-tui-warn hover:underline",i),children:p}),d.jsx(oT,{isOpen:f,onClose:()=>h(!1)})]})},kd=({command:l})=>{const{addToast:i,t:s}=rt();return d.jsxs("div",{className:"flex items-center gap-2 border border-tui-border bg-tui-mantle px-2 py-1",children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none text-tui-ok",children:"$"}),d.jsx("code",{className:"min-w-0 flex-1 break-all text-tui-text",children:l}),d.jsx(Oe,{glyph:"⧉",className:"shrink-0",onClick:()=>{Kl(l).then(r=>{i(r==="failed"?"error":"success",s(r==="failed"?"clipboard.copyFailed":"toasts.commandCopied"))})},children:s("common.copy")})]})},oT=({isOpen:l,onClose:i})=>{const{updateStatus:s,ignoreUpdate:r,hostname:c,hostId:f,t:h}=rt();if(!s)return null;const{current:m,installed:b,latest:p,restartPending:y}=s;return d.jsx(tc,{isOpen:l,onClose:i,title:h("update.title"),closeLabel:h("common.closeDialog"),size:"md",footer:d.jsxs(d.Fragment,{children:[d.jsx(Oe,{variant:"ghost",onClick:()=>{r(p),i()},children:h("update.ignore")}),d.jsx(Oe,{variant:"primary",onClick:i,children:h("common.done")})]}),children:d.jsxs("div",{className:"space-y-3","data-testid":"update-modal",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(Ul,{label:h("common.host"),labelWidth:10,children:c||f||"—"}),d.jsx(Ul,{label:h("update.running"),labelWidth:10,children:m}),b!==m?d.jsx(Ul,{label:h("update.installed"),labelWidth:10,children:b}):null,d.jsx(Ul,{label:h("update.latest"),labelWidth:10,children:d.jsx("span",{className:"text-tui-ok",children:p})})]}),y?d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"leading-snug text-tui-text",children:h("update.restartPending",{version:b})}),d.jsx(kd,{command:"herdr-remote restart"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"leading-snug text-tui-text",children:[d.jsx("span",{"aria-hidden":"true",className:"mr-1 text-tui-accent",children:Fe.arrowRight}),h("update.stepTui")]}),d.jsx("p",{className:"leading-snug text-tui-muted",children:h("update.stepCli")}),d.jsx(kd,{command:`npm install -g herdr-remote@${p} --prefer-online`}),d.jsx(kd,{command:"herdr-remote restart"}),d.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:h("update.restartNote")})]})]})})},cT=({onAddProfile:l=()=>{}})=>{const{connectionState:i,role:s,hostId:r,assignedClientId:c,sharedWindowCount:f,settings:h,rttMs:m,agentStatus:b,t:p}=rt(),y=nc(i,p),v=i==="connected",w=Ny();return d.jsx(iy,{left:d.jsxs(d.Fragment,{children:[d.jsx(uf,{onAddProfile:l}),d.jsx(Fd,{items:[d.jsxs("span",{className:"flex items-center gap-1",children:[d.jsx(_n,{level:y.level}),d.jsx("span",{className:"text-tui-text",children:y.label})]},"status"),v?d.jsx(af,{tone:s==="controller"?"ok":"warn",children:p(s==="controller"?"role.sharedControl":"common.viewer")},"role"):null,v&&f>1?d.jsx("span",{className:"text-tui-muted",children:p("role.sharedWindows",{count:f})},"windows"):null,r?d.jsxs("span",{children:[d.jsxs("span",{className:"text-tui-faint",children:[p("common.host"),":"]})," ",d.jsx("span",{className:"text-tui-text",children:r})]},"host"):null,d.jsxs("span",{children:[d.jsx("span",{className:"text-tui-faint",children:p("header.clientIdLabel")})," ",d.jsx("span",{className:"text-tui-text",children:c||h.clientId})]},"client")]})]}),right:d.jsx(Fd,{items:[w?d.jsx(ky,{},"update"):null,v&&rT(b)?d.jsx(Ey,{},"agents"):null,m!==null?d.jsxs("span",{className:"text-tui-muted",children:[p("header.latencyTitle"),": ",d.jsxs("span",{className:"text-tui-text",children:[m,"ms"]})]},"rtt"):null,d.jsx("span",{className:"hidden text-tui-faint sm:inline",children:p("header.tagline")},"mode")]})})},uT=[[/\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"]],dT=[[/\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 Jg(l,i){for(const[s,r]of l)if(s.test(i))return r;return null}function df(l){const i=typeof l=="string"?l.trim():"";if(!i)return{label:"",raw:""};const s=Jg(uT,i),r=Jg(dT,i);return s&&r?{label:`${s} · ${r}`,raw:i}:s?{label:s,raw:i}:r?{label:r,raw:i}:{label:i.length>32?`${i.slice(0,32)}…`:i,raw:i}}function as(l){if(!l||l<=0)return"0 B";const i=1024,s=["B","KB","MB","GB","TB"],r=Math.min(s.length-1,Math.floor(Math.log(l)/Math.log(i)));return`${(l/Math.pow(i,r)).toFixed(1)} ${s[r]}`}function eb(l,i,s=!1){const r=Math.max(0,Math.floor(l)),c=Math.floor(r/86400),f=Math.floor(r%86400/3600),h=Math.floor(r%3600/60),m=r%60,b=(y,v)=>`${y}${i(`admin.unit${v}`)}`,p=c>0?[b(c,"Day"),b(f,"Hour"),b(h,"Minute")]:f>0?[b(f,"Hour"),b(h,"Minute"),b(m,"Second")]:[b(h,"Minute"),b(m,"Second")];return(s?p.slice(0,2):p).join(" ")}function ff(l,i,s=Date.now()){if(!l)return"—";const r=new Date(l).getTime();if(Number.isNaN(r))return"—";const c=Math.max(0,Math.floor((s-r)/1e3));return c<60?i("admin.relJustNow"):c<3600?i("admin.relMinutes",{count:Math.floor(c/60)}):c<86400?i("admin.relHours",{count:Math.floor(c/3600)}):i("admin.relDays",{count:Math.floor(c/86400)})}function hf(l){if(!l)return"";const i=new Date(l);return Number.isNaN(i.getTime())?"":i.toLocaleString()}function Ry(l=[]){const i=new Map;for(const s of l)s.deviceId&&i.set(s.deviceId,(i.get(s.deviceId)||0)+1);return i}const fT=({clients:l})=>{const{t:i}=rt(),s=l.some(c=>c.hostId),r=[{key:"id",header:i("admin.colClientId"),render:c=>d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(_n,{level:"ok"}),d.jsx("span",{className:"font-bold text-tui-text",children:c.id})]})},...s?[{key:"host",header:i("admin.colHost"),render:c=>d.jsx("span",{className:"text-tui-text",children:c.hostId||"—"})}]:[],{key:"role",header:i("admin.colRole"),width:10,render:c=>{const f=c.role==="controller";return d.jsx(af,{tone:f?"ok":"warn",className:"text-tui-sm",children:i(f?"common.controller":"common.viewer")})}},{key:"device",header:i("admin.colDevice"),render:c=>{const f=df(c.userAgent);return d.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[d.jsx("span",{className:f.label?"text-tui-text":"text-tui-faint",title:f.raw,children:f.label||i("admin.unknownDevice")}),c.deviceId?d.jsx("code",{className:"text-tui-sm text-tui-faint",children:c.deviceId}):null]})}},{key:"ip",header:i("admin.colIp"),render:c=>d.jsx("span",{className:"text-tui-muted",children:c.ip||"127.0.0.1"})},{key:"connectedAt",header:i("admin.colConnectedAt"),render:c=>d.jsx("span",{className:"whitespace-nowrap text-tui-muted",title:hf(c.connectedAt),children:c.connectedAt?ff(c.connectedAt,i):i("admin.startedRecently")})},{key:"traffic",header:i("admin.colTraffic"),align:"right",render:c=>d.jsxs("span",{className:"whitespace-nowrap",children:[d.jsxs("span",{className:"text-tui-accent",children:["↓",as(c.bytesReceived||0)]}),d.jsx("span",{"aria-hidden":"true",className:"mx-1 text-tui-faint",children:"/"}),d.jsxs("span",{className:"text-tui-ok",children:["↑",as(c.bytesSent||0)]})]})}];return d.jsx(gn,{title:i("admin.connectedClientsTitle",{count:l.length}),bodyClassName:"-mx-1",children:d.jsx(rf,{columns:r,items:l,rowKey:c=>c.id,empty:i("admin.noClients")})})},tb={online:"ok",busy:"ok",reconnecting:"warn",offline:"idle"};function hT(l=[],i=[]){const s=new Map;for(const f of i){if(!(f!=null&&f.hostId))continue;const h=s.get(f.hostId);h?h.push(f):s.set(f.hostId,[f])}const r=l.map(f=>{const h=s.get(f.id)||[];return{id:f.id,hostname:f.hostname||f.id,status:f.status||"online",connectedDeviceCount:f.connectedDeviceCount??0,pairedDeviceCount:f.pairedDeviceCount??h.length,activePtyCount:f.activePtyCount??0,devices:h,fromRosterOnly:!1}}),c=new Set(r.map(f=>f.id));for(const[f,h]of s)c.has(f)||r.push({id:f,hostname:f,status:"offline",connectedDeviceCount:0,pairedDeviceCount:h.length,activePtyCount:0,devices:h,fromRosterOnly:!0});return r.sort((f,h)=>f.fromRosterOnly!==h.fromRosterOnly?f.fromRosterOnly?1:-1:f.hostname.localeCompare(h.hostname))}const mT=({hosts:l,devices:i,clients:s})=>{const{t:r}=rt(),c=hT(l,i),f=Ry(s),h={online:r("admin.hostStatusOnline"),busy:r("admin.hostStatusBusy"),reconnecting:r("admin.hostStatusReconnecting"),offline:r("admin.hostStatusOffline")};return d.jsx(gn,{title:r("admin.hostsTitle",{count:c.length}),bodyClassName:"space-y-2",children:c.length===0?d.jsx("p",{className:"px-1 py-2 text-tui text-tui-faint",children:r("admin.noHosts")}):c.map(m=>d.jsxs("div",{className:"border border-tui-border-dim bg-tui-mantle",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-tui-border-dim px-2 py-1",children:[d.jsxs("span",{className:"flex min-w-0 flex-auto items-center gap-1.5 text-tui",children:[d.jsx(_n,{level:tb[m.status]}),d.jsx("span",{className:"truncate font-bold text-tui-text",children:m.hostname}),m.hostname!==m.id?d.jsx("code",{className:"truncate text-tui-sm text-tui-faint",children:m.id}):null,d.jsx(af,{tone:tb[m.status],className:"ml-1 text-tui-sm",children:h[m.status]})]}),d.jsx(Fd,{className:"shrink-0 text-tui-sm",items:[d.jsx("span",{className:m.connectedDeviceCount?"text-tui-ok":"text-tui-faint",children:r("admin.hostConnectedDevices",{count:m.connectedDeviceCount})},"connected"),d.jsx("span",{className:"text-tui-muted",children:r("admin.hostPairedDevices",{count:m.pairedDeviceCount})},"paired"),m.fromRosterOnly?null:d.jsx("span",{className:m.activePtyCount?"text-tui-info":"text-tui-faint",children:r("admin.hostPtys",{count:m.activePtyCount})},"ptys")]})]}),m.devices.length>0?d.jsx("ul",{className:"divide-y divide-tui-border-dim",children:m.devices.map(b=>{const p=df(b.userAgent),y=f.get(b.deviceId)||0;return d.jsxs("li",{className:"grid grid-cols-[1ch_minmax(0,1fr)_auto] items-baseline gap-x-2 px-2 py-0.5 text-tui sm:grid-cols-[1ch_minmax(0,18ch)_minmax(0,1fr)_16ch_12ch]",children:[d.jsx(_n,{level:y?"ok":"idle"}),d.jsx("span",{className:"truncate text-tui-text",title:p.raw,children:p.label||r("admin.unknownDevice")}),d.jsx("code",{className:"hidden truncate text-tui-sm text-tui-faint sm:block",children:b.deviceId}),d.jsx("span",{className:"hidden truncate text-tui-sm text-tui-muted sm:block",children:b.lastIp||"—"}),d.jsx("span",{className:ne("truncate text-right text-tui-sm",y?"text-tui-ok":"text-tui-faint"),title:hf(b.lastSeenAt),children:y?r("admin.deviceWindows",{count:y}):ff(b.lastSeenAt,r)})]},b.deviceId)})}):d.jsx("p",{className:"px-2 py-1 text-tui-sm text-tui-faint",children:m.pairedDeviceCount>0?r("admin.hostRosterOperatorOnly"):r("admin.noDevices")})]},m.id))})},pT=({ptys:l})=>{const{t:i}=rt(),s=l.some(c=>c.hostId),r=[{key:"id",header:i("admin.colPtyId"),render:c=>d.jsx("span",{className:"font-bold text-tui-accent",children:c.id})},...s?[{key:"host",header:i("admin.colHost"),render:c=>d.jsx("span",{className:"text-tui-text",children:c.hostId})}]:[],{key:"pid",header:i("admin.colPid"),width:9,render:c=>d.jsx("span",{className:"text-tui-muted",children:c.pid})},{key:"command",header:i("admin.colCommand"),render:c=>d.jsx("code",{className:"border border-tui-border-dim bg-tui-mantle px-1 text-tui-text",children:c.command})},{key:"grid",header:i("admin.colGrid"),width:11,render:c=>d.jsxs("span",{className:"whitespace-nowrap text-tui-muted",children:[c.cols,d.jsx("span",{"aria-hidden":"true",className:"mx-0.5 text-tui-faint",children:"×"}),c.rows]})},{key:"cwd",header:i("admin.colCwd"),className:"max-w-xs truncate",render:c=>d.jsx("span",{className:"text-tui-muted",children:c.cwd||"~"})},{key:"viewers",header:i("admin.colViewers"),align:"right",width:9,render:c=>d.jsx("span",{className:"font-bold text-tui-ok",children:c.activeClients})}];return d.jsx(gn,{title:i("admin.activePtysTitle",{count:l.length}),bodyClassName:"-mx-1",children:d.jsx(rf,{columns:r,items:l,rowKey:c=>c.id,empty:i("admin.noPtys")})})},gT=({devices:l,clients:i,onRevoke:s})=>{const{t:r}=rt(),[c,f]=S.useState(null),[h,m]=S.useState(null),b=Ry(i),p=[...l].sort((w,T)=>{const A=+!!b.get(T.deviceId)-+!!b.get(w.deviceId);return A||(Date.parse(T.lastSeenAt)||0)-(Date.parse(w.lastSeenAt)||0)}),y=async w=>{if(c!==w){f(w);return}m(w);try{await s(w)}finally{m(null),f(null)}},v=[{key:"status",header:r("admin.colStatus"),width:12,render:w=>{const T=b.get(w.deviceId)||0;return d.jsxs("span",{className:ne("flex items-center gap-1.5 whitespace-nowrap",T?"text-tui-ok":"text-tui-faint"),children:[d.jsx(_n,{level:T?"ok":"idle"}),r(T?"admin.hostStatusOnline":"admin.hostStatusOffline")]})}},{key:"device",header:r("admin.colDevice"),render:w=>{const T=df(w.userAgent);return d.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[d.jsx("span",{className:"text-tui-text",title:T.raw,children:T.label||r("admin.unknownDevice")}),d.jsx("code",{className:"text-tui-sm text-tui-faint",children:w.deviceId})]})}},{key:"host",header:r("admin.colHost"),render:w=>d.jsx("span",{className:"text-tui-text",children:w.hostId||"—"})},{key:"ip",header:r("admin.colIp"),render:w=>d.jsx("span",{className:"text-tui-muted",children:w.lastIp||"—"})},{key:"lastSeen",header:r("admin.colLastSeen"),render:w=>{const T=b.get(w.deviceId)||0;return d.jsx("span",{className:ne("whitespace-nowrap",T?"text-tui-ok":"text-tui-muted"),title:hf(w.lastSeenAt),children:T?r("admin.deviceWindows",{count:T}):ff(w.lastSeenAt,r)})}},{key:"actions",header:r("admin.colActions"),align:"right",render:w=>{const T=c===w.deviceId,A=h===w.deviceId;return d.jsx(Oe,{variant:"danger",disabled:A,onClick:()=>void y(w.deviceId),onBlur:()=>f($=>$===w.deviceId?null:$),"aria-label":r("admin.revokeDevice"),className:ne("h-6 py-0 text-tui-sm",T&&"bg-tui-bad text-tui-crust"),children:A?d.jsx(ma,{}):r(T?"admin.revokeConfirm":"admin.revokeDevice")})}}];return d.jsx(gn,{title:r("admin.pairedDevicesTitle",{count:l.length}),bodyClassName:"-mx-1",children:d.jsx(rf,{columns:v,items:p,rowKey:w=>w.deviceId,empty:r("admin.noDevices")})})};function Xd(l){if(typeof window>"u"||!l||l.startsWith("/"))return"";try{const i=new URL(l.replace(/^ws/,"http")),s=i.pathname.replace(/\/ws\/client\/?$/,"").replace(/\/+$/,"");return i.origin===window.location.origin&&!s?"":`${i.origin}${s}`}catch{return""}}function cr(l,i){const s=Xd(l);return s?`${s}${i.startsWith("/")?i:`/${i}`}`:i}const Rd="h-7 py-0",bT=({onBackToTerminal:l,onOpenPairing:i,showBack:s=!1})=>{var Kt,hn,Yt,ct,Ke,bn,ut,qe,wt,yn,We,Pe,Mt;const{settings:r,updateSettings:c,addToast:f,t:h}=rt(),m=Xd(r.wsUrl)||(typeof window<"u"?window.location.origin:"local"),b=((Kt=r.adminTokens)==null?void 0:Kt[m])||(m===(typeof window<"u"?window.location.origin:"local")?r.adminToken:"")||"",[p,y]=S.useState(null),[v,w]=S.useState(null),[T,A]=S.useState(!1),[$,R]=S.useState(!0),[O,j]=S.useState(null),[Y,se]=S.useState(!1),[fe,Q]=S.useState(3e3),[K,q]=S.useState(null),[ue,ye]=S.useState("overview"),[Ne,ie]=S.useState(!1),[he,oe]=S.useState(b),[pe,k]=S.useState(b),[I,le]=S.useState(!!b),re=!Xd(r.wsUrl),V="node bin/service.js pair";S.useEffect(()=>{oe(b),k(b),le(!!b),y(null),w(null),A(!1)},[m]);const Re=()=>{Kl(V).then(E=>{if(E==="failed"){f("error",h("clipboard.copyFailed"));return}ie(!0),f("success",h("toasts.commandCopied")),setTimeout(()=>ie(!1),2e3)})};S.useEffect(()=>{let E=!0;R(!0);async function ce(){try{const de=await fetch(cr(r.wsUrl,"/api/info"),{headers:{Accept:"application/json"}});if(de.ok){const _e=await de.json();E&&(w(_e),A(!0));return}}catch{}if(E){const de=!!(r.wsUrl&&!r.wsUrl.startsWith("/")&&!r.wsUrl.includes("localhost")&&!r.wsUrl.includes("127.0.0.1")&&typeof window<"u"&&!r.wsUrl.startsWith(window.location.origin.replace("http","ws")));w({ok:!0,version:"0.1.0",protocol:1,relayMode:de?"remote":"local",adminConfigured:!1,adminPath:"/admin",adminStatusPath:"/api/admin/status"}),A(!0)}}return ce(),()=>{E=!1}},[r.wsUrl,m]);const Ae=(v==null?void 0:v.relayMode)==="remote",xe=()=>{if(v!=null&&v.adminPath)return v.publicUrl?`${v.publicUrl.replace(/\/$/,"")}${v.adminPath}`:cr(r.wsUrl,v.adminPath);if(p!=null&&p.remoteAdminUrl)return p.remoteAdminUrl;if(r.wsUrl)try{return cr(r.wsUrl,"/admin")}catch{}return"/admin"},Se=S.useCallback(async()=>{if(T){if(Ae){if(!pe){y(null),R(!1),j(null),se(!1);return}try{R(!0);const E=cr(r.wsUrl,(v==null?void 0:v.adminStatusPath)||"/api/admin/status"),de=await fetch(E,{headers:{Accept:"application/json","X-Relay-Admin-Token":pe}});if(de.status===401||de.status===403){se(!0),j(h("admin.relayAdminAuthError")),y(null);return}if(!de.ok)throw new Error(`HTTP ${de.status}: ${de.statusText}`);const _e=await de.json();y(_e),j(null),se(!1),q(new Date)}catch(E){console.warn("GET /api/admin/status request failed:",E),se(!1),j(E instanceof Error?E.message:"Failed to fetch remote admin status"),y(null)}finally{R(!1)}return}try{R(!0);const E={Accept:"application/json"};r.token&&(E.Authorization=`Bearer ${r.token}`);const ce=await fetch("/api/status",{headers:E});if(ce.status===401||ce.status===403){se(!0),j(`Authentication failed (HTTP ${ce.status}): Access denied. Please configure an authorized token or pair with the host.`),y(null);return}if(!ce.ok)throw new Error(`HTTP ${ce.status}: ${ce.statusText}`);const de=await ce.json();y(de),j(null),se(!1),q(new Date)}catch(E){console.warn("GET /api/status request failed:",E),se(!1),j(E instanceof Error?E.message:"Failed to fetch status"),y(null)}finally{R(!1)}}},[T,Ae,pe,v,r.token,r.wsUrl,m,h]),Le=S.useCallback(async E=>{try{if(!(await fetch(cr(r.wsUrl,`/api/admin/devices/${encodeURIComponent(E)}`),{method:"DELETE",headers:{Accept:"application/json","X-Relay-Admin-Token":pe}})).ok){j(h("admin.revokeFailed"));return}await Se()}catch{j(h("admin.revokeFailed"))}},[pe,Se,r.wsUrl,h]);S.useEffect(()=>{if(!T)return;Se();let E=null;const ce=()=>{fe>0&&!E&&(E=setInterval(()=>{document.visibilityState==="visible"&&Se()},fe))},de=()=>{E&&(clearInterval(E),E=null)},_e=()=>{document.visibilityState==="visible"?(Se(),ce()):de()};return ce(),document.addEventListener("visibilitychange",_e),()=>{de(),document.removeEventListener("visibilitychange",_e)}},[T,Se,fe]);const Be=E=>{E.preventDefault();const ce=he.trim();c({adminToken:ce,adminTokens:{...r.adminTokens||{},[m]:ce}}),k(ce),le(!!ce)},ot=()=>{const E=xe();window.open(E,"_blank","noopener,noreferrer")},Xe=p?p.activeUserCount??((hn=p.clients)==null?void 0:hn.length)??0:0,ze=p?[{id:"overview",label:h("admin.tabOverview"),index:1},{id:"clients",label:h("admin.tabClients",{count:((Yt=p.clients)==null?void 0:Yt.length)||0}),index:2},{id:"ptys",label:h("admin.tabPtys",{count:((ct=p.ptys)==null?void 0:ct.length)||0}),index:3},...p.devices?[{id:"devices",label:h("admin.tabDevices",{count:p.devices.length}),index:4}]:[]]:[],yt=ze.map(E=>E.id);S.useEffect(()=>{const E=ce=>{if(ce.ctrlKey||ce.altKey||ce.metaKey)return;const de=ce.target;if(de instanceof HTMLInputElement||de instanceof HTMLTextAreaElement||de instanceof HTMLSelectElement||de!=null&&de.isContentEditable||document.querySelector('[role="dialog"]'))return;if(ce.key==="Escape"&&l){ce.preventDefault(),l();return}if(ce.key.toLowerCase()==="r"){ce.preventDefault(),Se();return}const _e=Number.parseInt(ce.key,10)-1;Number.isInteger(_e)&&_e>=0&&_e<yt.length&&(ce.preventDefault(),ye(yt[_e]))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[Se,yt.join("|")]);const Tt=(v==null?void 0:v.version)||(p==null?void 0:p.version)||"0.1.0",Ue=p?new Set((p.devices||[]).map(E=>E.hostId).filter(E=>E&&!(p.hosts||[]).some(ce=>ce.id===E))).size:0,G=s&&l?d.jsx(Oe,{variant:"ghost",onClick:l,title:h("admin.returnToTerminal"),"aria-label":h("admin.returnToTerminal"),glyph:Fe.arrowLeft,brackets:!1,className:Rd,children:d.jsx("span",{className:"sr-only",children:h("admin.returnToTerminal")})}):null,me=d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"hidden items-center gap-1.5 whitespace-nowrap text-tui-sm sm:flex",children:[d.jsxs("span",{className:"text-tui-faint",children:["v",Tt]}),d.jsx(lf,{}),d.jsx("span",{className:Ae?"text-tui-alt":"text-tui-ok",children:h(Ae?"admin.modeRemote":"admin.localWorkstationBadge")})]}),p?d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"hidden items-center gap-1.5 text-tui-sm text-tui-muted md:flex",children:[d.jsx("span",{children:h("admin.autoRefresh")}),d.jsxs(Qo,{value:fe,onChange:E=>Q(Number(E.target.value)),"aria-label":h("admin.autoRefresh"),className:ne("w-auto",Rd),children:[d.jsx("option",{value:0,children:h("admin.paused")}),d.jsx("option",{value:1e3,children:"1s"}),d.jsx("option",{value:3e3,children:"3s"}),d.jsx("option",{value:5e3,children:"5s"}),d.jsx("option",{value:1e4,children:"10s"})]})]}),d.jsx(Oe,{variant:"primary",onClick:Se,disabled:$,title:h("admin.refreshNow"),className:Rd,children:$?d.jsx(ma,{}):h("admin.refreshNow")})]}):null]}),$e=T&&Ae&&!I&&!re,_t=T&&Ae&&(I||re)&&!p;return d.jsxs(B1,{tabs:ze,activeTabId:ue,onSelectTab:E=>ye(E),tabsAriaLabel:h("header.mainNavigationAria"),toolbarStart:G,toolbarAside:me,hints:[...p?[{keys:"1–4",action:h("admin.hintTabs")},{keys:"r",action:h("admin.hintRefresh")}]:[],...l?[{keys:"esc",action:h("admin.hintBack")}]:[]],footerAside:K?d.jsx("span",{className:"text-tui-faint",children:h("admin.updatedAt",{time:K.toLocaleTimeString()})}):null,bodyClassName:"space-y-3 pb-2",children:[!T&&d.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:d.jsx(ma,{label:h("admin.loadingStatus")})}),$e&&d.jsxs(gn,{title:h("admin.remoteRelayTitle"),bodyClassName:"space-y-2",children:[d.jsx("p",{className:"text-tui leading-snug text-tui-muted",children:h("admin.remoteRelayNotice")}),d.jsxs("div",{className:"space-y-0.5 border border-tui-border-dim bg-tui-mantle px-2 py-1.5",children:[d.jsx(Ul,{label:h("admin.remoteRelayEndpoint"),labelWidth:18,children:d.jsx("code",{className:"break-all text-tui-accent",children:r.wsUrl})}),d.jsx(Ul,{label:h("admin.remoteRelayAdminUrl"),labelWidth:18,children:d.jsx("code",{className:"break-all text-tui-ok",children:xe()})})]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx(Oe,{variant:"primary",onClick:ot,glyph:Fe.arrowRight,children:h("admin.openRemoteAdminBtn")}),d.jsx(Oe,{onClick:()=>le(!0),children:h("admin.relayAdminLoginBtn")})]})]}),_t&&d.jsxs(gn,{title:h("admin.relayAdminTitle"),bodyClassName:"space-y-2",children:[(v==null?void 0:v.adminConfigured)===!1?d.jsx(Bl,{tone:"warn",children:h("admin.relayAdminNotConfigured")}):Y?d.jsx(Bl,{tone:"bad",children:h("admin.relayAdminAuthError")}):d.jsx(Bl,{tone:"accent",children:h("admin.relayAdminPrompt")}),d.jsxs("form",{onSubmit:Be,className:"space-y-2",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx(Ji,{htmlFor:"relay-admin-token",children:h("admin.relayAdminTokenLabel")}),d.jsx(Sn,{id:"relay-admin-token",type:"password",autoComplete:"current-password",value:he,onChange:E=>oe(E.target.value),placeholder:h("admin.relayAdminTokenPlaceholder")})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Oe,{variant:"primary",type:"submit",disabled:!he.trim(),children:h("admin.relayAdminLoginBtn")}),re?l&&!s?d.jsx(Oe,{variant:"ghost",onClick:l,children:h("admin.returnToTerminal")}):null:d.jsx(Oe,{variant:"ghost",onClick:()=>le(!1),children:h("common.cancel")})]})]})]}),T&&!Ae&&Y&&d.jsxs(gn,{title:h("admin.unauthorizedTitle"),tone:"bad",bodyClassName:"space-y-2",children:[d.jsx(Bl,{tone:"bad",children:h("admin.unauthorizedDesc")}),d.jsxs("div",{className:"space-y-1.5 border border-tui-border-dim bg-tui-mantle px-2 py-1.5",children:[d.jsx("span",{className:"block text-tui-sm uppercase text-tui-muted",children:h("admin.pairingStepsTitle")}),d.jsxs("div",{className:"flex items-center gap-2 border border-tui-border bg-tui-crust px-2 py-1",children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 select-none text-tui-ok",children:"$"}),d.jsx("code",{className:"min-w-0 flex-1 truncate text-tui-text",children:V}),d.jsx(Oe,{onClick:Re,glyph:Ne?Fe.check:"⧉",className:ne("shrink-0",Ne&&"border-tui-ok text-tui-ok"),children:h(Ne?"admin.copiedJson":"common.copy")})]}),d.jsx("p",{className:"text-tui-sm text-tui-faint",children:h("admin.pairingStepsHelp")})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[i&&d.jsx(Oe,{variant:"primary",onClick:i,children:h("admin.enterPairCodeBtn")}),d.jsx(Oe,{onClick:Se,children:h("admin.retryFetchBtn")})]})]}),T&&O&&!Y&&d.jsx(Bl,{tone:"warn",action:d.jsx(Oe,{variant:"warn",onClick:Se,children:h("common.retry")}),children:h("admin.errorConnecting",{error:O})}),p&&d.jsxs(d.Fragment,{children:[ue==="overview"&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 xl:grid-cols-6",children:[d.jsx(es,{label:h("admin.connectedHosts"),value:((Ke=p.hosts)==null?void 0:Ke.length)||0,sub:Ue?h("admin.hostsOfflineSub",{count:Ue}):void 0,tone:(bn=p.hosts)!=null&&bn.length?"ok":"idle"}),d.jsx(es,{label:h("admin.activeUsers"),value:Xe,sub:h("admin.acrossWindows",{count:((ut=p.clients)==null?void 0:ut.length)||0}),tone:Xe?"accent":"idle"}),d.jsx(es,{label:h("admin.activePtys"),value:((qe=p.ptys)==null?void 0:qe.length)||0,sub:h("admin.terminalShells"),tone:(wt=p.ptys)!=null&&wt.length?"info":"idle"}),d.jsx(es,{label:h("admin.statInbound"),value:h("admin.perSecond",{value:as(((yn=p.throughput)==null?void 0:yn.bytesInPerSec)||0)}),sub:h("admin.statTotal",{value:as(((We=p.throughput)==null?void 0:We.bytesIn)||0)}),tone:"accent"}),d.jsx(es,{label:h("admin.statOutbound"),value:h("admin.perSecond",{value:as(((Pe=p.throughput)==null?void 0:Pe.bytesOutPerSec)||0)}),sub:h("admin.statTotal",{value:as(((Mt=p.throughput)==null?void 0:Mt.bytesOut)||0)}),tone:"ok"}),d.jsx(es,{label:h("admin.uptime"),value:eb(p.uptimeSeconds||0,h,!0),title:eb(p.uptimeSeconds||0,h),sub:p.startTime?h("admin.startedAt",{time:new Date(p.startTime).toLocaleTimeString()}):h("admin.startedRecently")})]}),d.jsx(mT,{hosts:p.hosts||[],devices:p.devices,clients:p.clients||[]})]}),ue==="clients"&&d.jsx(fT,{clients:p.clients||[]}),ue==="ptys"&&d.jsx(pT,{ptys:p.ptys||[]}),ue==="devices"&&d.jsx(gT,{devices:p.devices||[],clients:p.clients||[],onRevoke:Le})]})]})},yT=({compact:l=!1})=>{const{role:i,connectionState:s,sharedWindowCount:r,assignedClientId:c,t:f}=rt();if(!(s==="connected"))return d.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:[d.jsx(_n,{level:"idle"}),d.jsx("span",{children:f("common.offline")})]});const m=i==="controller",b=r>1,p=d.jsxs("div",{className:ne("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:[d.jsx(_n,{level:m?"ok":"warn"}),d.jsx("span",{className:"truncate",children:f(m?"role.sharedControl":"role.viewerReadOnly")}),b?d.jsx("span",{className:"shrink-0 normal-case text-tui-muted",children:f("role.sharedWindows",{count:r})}):null]});return l?p:d.jsxs("div",{className:"flex w-full flex-col gap-1",children:[p,d.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:f("role.sharedControlDesc")}),c?d.jsx(Ul,{label:f("role.thisWindow"),labelWidth:9,className:"text-tui-sm",children:d.jsx("span",{className:"truncate text-tui-muted",children:c})}):null]})},Io="tui-focusable group flex h-11 w-full select-none items-center gap-2 border px-2 text-left text-tui transition-colors",Fo="border-tui-border text-tui-muted hover:border-tui-accent hover:text-tui-accent active:bg-tui-selection",vT="border-tui-accent bg-tui-selection text-tui-accent",Go=({active:l=!1})=>d.jsx("span",{"aria-hidden":"true",className:ne("shrink-0",l?"text-tui-accent":"text-tui-faint group-hover:text-tui-accent"),children:Fe.cursor}),xT=({onClose:l,onOpenPairing:i,onOpenSettings:s,onAddProfile:r=()=>{}})=>{const{connectionState:c,stateDetail:f,rttMs:h,hostId:m,settings:b,updateSettings:p,connect:y,addToast:v,language:w,setLanguage:T,t:A}=rt(),[$,R]=Li.useState(!1),O=nc(c,A),j=fe=>()=>{var K;const Q=document.activeElement;(K=Q==null?void 0:Q.blur)==null||K.call(Q),fe()},Y=()=>{Kl(b.clientId).then(fe=>{if(fe==="failed"){v("error",A("clipboard.copyFailed"));return}R(!0),v("info",A("toasts.clientIdCopied",{id:b.clientId})),setTimeout(()=>R(!1),2e3)})},se=()=>{const fe=w==="zh"?"en":"zh";T(fe),v("info",Jd(fe,"toasts.switchedLanguage",{lang:fe==="zh"?"简体中文":"English"}))};return d.jsxs("div",{className:"flex flex-col gap-3 px-3 pb-2 pt-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-tui-border pb-1.5",children:[d.jsx("h2",{className:"text-tui font-bold uppercase text-tui-accent",children:A("mobile.sessionControls")}),d.jsx(Oe,{variant:"ghost",onClick:l,"aria-label":A("mobile.closeSessionControls"),children:"esc"})]}),d.jsx(gn,{title:A("profiles.title"),tone:"accent",bodyClassName:"space-y-1",children:d.jsx(uf,{mobile:!0,onAddProfile:r})}),d.jsxs(gn,{title:A("common.status"),tone:O.level==="ok"?"ok":O.level==="bad"?"bad":"warn",bodyClassName:"space-y-1.5",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2","aria-label":A("mobile.connectionStatusAria"),children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[d.jsx(_n,{level:O.level}),d.jsx("span",{className:"truncate text-tui uppercase text-tui-text",children:O.label}),c==="connected"&&h!==null&&d.jsxs("span",{className:"text-tui-sm text-tui-muted",children:[h,"ms"]})]}),O.actionLabel&&d.jsx(Oe,{variant:"primary",onClick:()=>y(),className:"shrink-0",children:O.actionLabel})]}),O.needsAttention&&f&&d.jsx("p",{className:"text-tui-sm leading-snug text-tui-muted",children:f}),m&&d.jsx(Ul,{label:A("common.host"),labelWidth:9,children:m}),d.jsxs("button",{type:"button",onClick:Y,className:"tui-focusable flex w-full items-baseline gap-2 text-left text-tui",title:A("header.copyClientIdTitle"),children:[d.jsx("span",{className:"shrink-0 text-tui-muted",style:{width:"9ch"},children:A("header.clientIdLabel")}),d.jsx("span",{className:"min-w-0 flex-1 truncate text-tui-text",children:b.clientId}),d.jsx("span",{"aria-hidden":"true",className:ne("shrink-0",$?"text-tui-ok":"text-tui-faint"),children:$?Fe.check:"⧉"})]})]}),d.jsx(gn,{title:A("mobile.inputControl"),tone:"accent","aria-label":A("mobile.terminalControlAria"),children:d.jsx(yT,{})}),d.jsxs(gn,{title:A("mobile.menu"),tone:"accent",bodyClassName:"flex flex-col gap-1",children:[d.jsxs("button",{type:"button",onClick:se,className:ne(Io,Fo),"aria-label":A("header.languageToggleTitle"),children:[d.jsx(Go,{}),d.jsx("span",{className:"truncate",children:w==="zh"?"English":"中文"})]}),d.jsxs("button",{type:"button",onClick:j(s),className:ne(Io,Fo),"aria-label":A("mobile.settingsAria"),children:[d.jsx(Go,{}),d.jsx("span",{className:"truncate",children:A("common.settings")})]}),d.jsxs("button",{type:"button",onClick:j(i),className:ne(Io,Fo),"aria-label":A("mobile.pairingAria"),children:[d.jsx(Go,{}),d.jsx("span",{className:"truncate",children:A("common.pairing")})]}),d.jsxs("button",{type:"button",onClick:()=>p({toolbarVisible:!b.toolbarVisible}),className:ne(Io,b.toolbarVisible?vT:Fo),"aria-label":A("mobile.keybarAria"),"aria-pressed":b.toolbarVisible,children:[d.jsx(Go,{active:b.toolbarVisible}),d.jsx("span",{className:"truncate",children:A("common.keyBar")}),d.jsx("span",{"aria-hidden":"true",className:"ml-auto shrink-0 text-tui-sm",children:b.toolbarVisible?"[x]":"[ ]"})]})]})]})},wT=({onAddProfile:l})=>{const{rttMs:i,t:s}=rt();return d.jsxs("footer",{"data-testid":"mobile-status-bar",role:"status","aria-label":s("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:[d.jsx(uf,{statusBar:!0,onAddProfile:l}),d.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-tui-border",children:"│"}),d.jsx(Ey,{compact:!0}),d.jsx(ky,{compact:!0}),d.jsxs("span",{className:"flex shrink-0 items-center gap-1 px-1 text-tui-muted",title:s("header.latencyTitle"),children:[d.jsx("span",{className:"text-tui-faint",children:"RTT"}),d.jsx("span",{className:ne(i===null?"text-tui-faint":"text-tui-text"),children:i===null?"—":`${i}ms`})]})]})},ST=({onOpenPairing:l,onOpenSettings:i,onAddProfile:s=()=>{}})=>{const{connectionState:r,isController:c,t:f}=rt(),[h,m]=S.useState(!1),b=S.useRef(null),p=S.useCallback(()=>m(!1),[]);S.useEffect(()=>{if(!h)return;const v=w=>{if(!(w.ctrlKey||w.altKey||w.metaKey)&&w.key==="Escape"){const T=w.target;T&&typeof T.closest=="function"&&!!T.closest("#terminal-container")||(w.stopPropagation(),w.preventDefault(),p())}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[h,p]),S.useEffect(()=>{var v;h&&((v=b.current)==null||v.focus({preventScroll:!0}))},[h]);const y=nc(r,f);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{"data-testid":"mobile-topbar",role:"toolbar","aria-label":f("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:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-tui-sm text-tui-muted",children:[d.jsx("span",{"aria-hidden":"true",className:"shrink-0 font-bold text-tui-accent",children:"herdr"}),d.jsx(lf,{className:"shrink-0"}),d.jsx(_n,{level:y.level}),d.jsx("span",{className:"truncate uppercase",children:y.label})]}),d.jsxs("button",{type:"button","data-testid":"mobile-chrome-trigger",onClick:()=>m(!0),"aria-label":f("mobile.sessionControls"),"aria-expanded":h,"aria-haspopup":"dialog",className:ne("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",y.needsAttention?"border-tui-warn text-tui-warn":c?"border-tui-border text-tui-muted":"border-tui-accent text-tui-accent"),children:[!c&&!y.needsAttention&&d.jsx("span",{className:"max-w-[8rem] truncate",children:f("common.viewer")}),d.jsx("span",{"aria-hidden":"true",className:"text-tui",children:Fe.chevronDown}),d.jsx("span",{"aria-hidden":"true",children:f("mobile.menu")})]})]}),h&&d.jsxs(d.Fragment,{children:[d.jsx("div",{"data-testid":"mobile-sheet-scrim",className:"absolute inset-0 z-40 bg-tui-crust/70",onClick:p,"aria-hidden":"true"}),d.jsx("div",{ref:b,"data-testid":"mobile-control-sheet",role:"dialog","aria-modal":"true","aria-label":f("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:d.jsx(xT,{onClose:p,onOpenPairing:()=>{p(),l()},onOpenSettings:()=>{p(),i()},onAddProfile:()=>{p(),s()}})})]}),d.jsx(wT,{onAddProfile:s})]})},CT=()=>{const{herdrLaunch:l,startHerdr:i,hostname:s,activeProfile:r,t:c}=rt();if(!l)return null;const f=s||(r==null?void 0:r.displayName)||c("herdrLaunch.thisHost"),h=l.phase==="failed";return d.jsx("div",{"data-testid":"herdr-start-prompt",className:"absolute inset-0 z-30 flex items-center justify-center bg-tui-crust/85 p-3",children:d.jsx(gn,{title:c(h?"herdrLaunch.failedTitle":"herdrLaunch.title"),tone:h?"bad":"warn",className:"w-full max-w-md",bodyClassName:"space-y-3","aria-label":c("herdrLaunch.title"),children:l.phase==="starting"?d.jsxs("p",{className:"flex items-center gap-2 text-tui-text",role:"status",children:[d.jsx(ma,{}),d.jsx("span",{children:c("herdrLaunch.starting",{host:f})})]}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"leading-snug text-tui-text",children:c("herdrLaunch.body",{host:f})}),h&&l.message?d.jsx(Bl,{tone:"bad",children:d.jsx("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono text-tui-sm",children:l.message})}):null,d.jsx("p",{className:"text-tui-sm leading-snug text-tui-faint",children:c("herdrLaunch.scope")}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Oe,{variant:"primary",onClick:i,autoFocus:!0,children:c(h?"common.retry":"herdrLaunch.start")})})]})})})},Ly="--app-height",_y="--keyboard-inset",TT=80;function MT(){if(typeof window>"u")return{height:768,keyboardInset:0};const l=window.innerHeight||768,i=window.visualViewport;if(i&&typeof i.height=="number"&&i.height>0){const s=l-i.height-(i.offsetTop||0),r=s>=TT?Math.round(s):0;return{height:Math.round(i.height),keyboardInset:r}}return{height:l,keyboardInset:0}}function nb(l,i=MT()){return l.style.setProperty(Ly,`${i.height}px`),l.style.setProperty(_y,`${i.keyboardInset}px`),i}function AT(l=typeof document<"u"?document.documentElement:null){if(!l||typeof window>"u")return()=>{};let i=null;const s=()=>{i=null,nb(l)},r=()=>{if(i===null){if(typeof requestAnimationFrame!="function"){s();return}i=requestAnimationFrame(s)}};nb(l);const c=window.visualViewport;return c==null||c.addEventListener("resize",r),c==null||c.addEventListener("scroll",r),window.addEventListener("resize",r),window.addEventListener("orientationchange",r),()=>{i!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(i),i=null),c==null||c.removeEventListener("resize",r),c==null||c.removeEventListener("scroll",r),window.removeEventListener("resize",r),window.removeEventListener("orientationchange",r),l.style.removeProperty(Ly),l.style.removeProperty(_y)}}const ET=900;function ib(){if(typeof window>"u")return!1;const l=ss();return l<Zd?!0:l<=ET}function NT(){const[l,i]=S.useState(ib);return S.useEffect(()=>{var c,f;const s=()=>{const h=ib();i(m=>m===h?m:h)};s();let r=null;try{r=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null}catch{r=null}return(c=r==null?void 0:r.addEventListener)==null||c.call(r,"change",s),window.addEventListener("resize",s),window.addEventListener("orientationchange",s),(f=window.visualViewport)==null||f.addEventListener("resize",s),()=>{var h,m;(h=r==null?void 0:r.removeEventListener)==null||h.call(r,"change",s),window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),(m=window.visualViewport)==null||m.removeEventListener("resize",s)}},[]),l}function kT(l){const i=l.target;if(!i)return!1;if(i.id==="terminal-container"||i.id==="terminal-frame"||i.id==="terminal-surface"||i.classList.contains("xterm-helper-textarea")||i.classList.contains("xterm")||i.closest("#terminal-container")||i.closest(".xterm"))return!0;if(typeof document<"u"&&document.activeElement){const s=document.activeElement;if(s.id==="terminal-container"||s.classList.contains("xterm-helper-textarea")||s.closest("#terminal-container")||s.closest(".xterm"))return!0}return!1}function RT(l,i={}){if(typeof window>"u")return()=>{};const s=r=>{var c;r.ctrlKey||r.altKey||r.metaKey||r.key==="Escape"&&(i.isModalOpen||i.isSheetOpen)&&(kT(r)||(r.preventDefault(),r.stopPropagation(),(c=l.onCloseModals)==null||c.call(l)))};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}}function LT(){const[l,i]=S.useState("terminal"),[s,r]=S.useState(!1),[c,f]=S.useState(!1),[h,m]=S.useState(!1),[b,p]=S.useState(void 0),y=oe=>{p(oe),m(!0)},[v,w]=S.useState(!1),{updateSettings:T,settings:A,connectionState:$,stateDetail:R,stateCode:O,lastPairedAt:j}=rt();Hw();const Y=NT();S.useEffect(()=>AT(),[]),S.useEffect(()=>{Eb()},[]),S.useEffect(()=>{const oe=s||h||v;if(oe)return RT({onCloseModals:()=>{r(!1),m(!1),w(!1)}},{isModalOpen:oe})},[s,h,v]),S.useEffect(()=>{const oe=()=>{const pe=window.location.pathname,k=window.location.hash;i(pe==="/admin"||k==="#admin"?"admin":"terminal")};oe(),window.addEventListener("popstate",oe),window.addEventListener("hashchange",oe);try{const pe=new URL(window.location.href),k=pe.searchParams.get("token"),I=pe.searchParams.get("pairCode"),le=pe.searchParams.get("ws")||pe.searchParams.get("wsUrl"),re={};k&&(re.token=k),I&&(re.pairCode=I.toUpperCase()),le&&(re.wsUrl=le),Object.keys(re).length>0&&T(re);let V=!1;if(pe.searchParams.has("token")&&(pe.searchParams.delete("token"),V=!0),pe.searchParams.has("pairCode")&&(pe.searchParams.delete("pairCode"),V=!0),V){const Re=pe.searchParams.toString(),Ae=pe.pathname+(Re?`?${Re}`:"")+pe.hash;window.history.replaceState({},"",Ae)}}catch(pe){console.warn("Failed to parse URL query params:",pe)}return()=>{window.removeEventListener("popstate",oe),window.removeEventListener("hashchange",oe)}},[]);const se=(oe=!1)=>{f(oe),r(!0)},fe=()=>{r(!1),f(!1)},Q=oe=>{i(oe),oe==="admin"?window.history.pushState({},"","/admin"):window.history.pushState({},"","/")},K=!A.token&&!A.pairCode&&$!=="connected",q=$==="error"&&(["auth_required","unauthorized","device_revoked"].includes(O||"")||/auth|unauthor|forbidden|permission|token|pair/i.test(R||"")),ue=K||q,[ye,Ne]=S.useState(!ue);S.useEffect(()=>{ue||Ne(!0)},[ue]),S.useEffect(()=>{j&&(r(!1),Ne(!0),i("terminal"))},[j]);const ie=l==="terminal"&&!ue,he=oe=>({visibility:oe?"visible":"hidden",opacity:oe?1:0,pointerEvents:oe?"auto":"none",zIndex:oe?1:0});return d.jsxs("div",{"data-testid":"app-shell",style:Y?{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:oe=>{oe.preventDefault(),oe.stopPropagation()},children:[!Y&&d.jsx(U1,{currentView:l,onNavigate:Q,onOpenPairing:()=>se(!1),onOpenSettings:()=>y(),onToggleVirtualKeyboard:()=>w(!v),isVirtualKeyboardOpen:v}),!Y&&!ue&&d.jsx(K1,{}),d.jsxs("div",{className:"flex-1 min-h-0 w-full overflow-hidden relative",children:[ye&&d.jsxs("div",{"data-testid":"terminal-layer",className:`absolute ${Y?"inset-x-0 top-12 bottom-11":"inset-0"} flex flex-col min-h-0 w-full overflow-hidden`,style:he(ie),"aria-hidden":!ie,children:[d.jsx(YC,{isActive:ie}),!Y&&d.jsx(ZC,{isOpen:v,onClose:()=>w(!1)}),d.jsx(XC,{compact:Y,onCustomize:()=>y("agentKeymaps")}),d.jsx(CT,{}),d.jsx(eT,{})]}),l==="terminal"&&ue&&d.jsx("div",{"data-testid":"onboarding-layer",className:"absolute inset-0 flex flex-col min-h-0 w-full overflow-hidden z-10",children:d.jsx($C,{onPairedSuccess:()=>{}})}),l==="admin"&&d.jsx("div",{"data-testid":"admin-layer",className:"absolute inset-0 flex flex-col min-h-0 w-full overflow-hidden z-20",children:d.jsx(bT,{onBackToTerminal:()=>Q("terminal"),onOpenPairing:()=>se(!1),showBack:Y})}),Y&&ie&&d.jsx(ST,{onOpenPairing:()=>se(!1),onOpenSettings:()=>y(),onAddProfile:()=>se(!0)})]}),!Y&&l!=="admin"&&d.jsx(cT,{onAddProfile:()=>se(!0)}),d.jsx(WC,{isOpen:s,isAddMode:c,onClose:fe}),d.jsx(iT,{isOpen:h,initialTab:b,onClose:()=>m(!1),onOpenAdmin:()=>{m(!1),Q("admin")}}),d.jsx(sT,{})]})}function _T(){return d.jsx(Aw,{children:d.jsx(LT,{})})}const jy=document.getElementById("root");if(!jy)throw new Error("Root element not found");qv.createRoot(jy).render(d.jsx(Li.StrictMode,{children:d.jsx(_T,{})}));