tmex-cli 0.8.1 → 0.9.0-test-1
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.
- package/dist/cli-node.js +3 -0
- package/dist/runtime/{cpufeatures-dxrn1j88.node → cpufeatures-j6gtp52k.node} +0 -0
- package/dist/runtime/server.js +25 -6
- package/dist/runtime/{sshcrypto-fjcj736m.node → sshcrypto-k4w22zcv.node} +0 -0
- package/package.json +1 -1
- package/resources/fe-dist/assets/{DevicePage-Byph1K3m.js → DevicePage-D44i3G_t.js} +2 -2
- package/resources/fe-dist/assets/{DevicesPage-BtUqV_Oo.js → DevicesPage-CRK5IQTj.js} +2 -2
- package/resources/fe-dist/assets/{SettingsPage-CNSAuMwZ.js → SettingsPage-B6oIYlyE.js} +2 -2
- package/resources/fe-dist/assets/{card-CgiYiquV.js → card-DzykTTqt.js} +2 -2
- package/resources/fe-dist/assets/index-mGJ46K2A.css +1 -0
- package/resources/fe-dist/assets/index-mf4NroE4.js +400 -0
- package/resources/fe-dist/assets/{refresh-cw-EoN3nWHT.js → refresh-cw-DaPtMs2v.js} +2 -2
- package/resources/fe-dist/index.html +3 -2
- package/resources/fe-dist/assets/index-CCZW6Klo.css +0 -1
- package/resources/fe-dist/assets/index-DNdArpmQ.js +0 -400
package/dist/cli-node.js
CHANGED
|
@@ -556,6 +556,7 @@ After=network.target
|
|
|
556
556
|
|
|
557
557
|
[Service]
|
|
558
558
|
Type=simple
|
|
559
|
+
KillMode=process
|
|
559
560
|
WorkingDirectory=${escapedInstallDir}
|
|
560
561
|
SyslogIdentifier=tmex
|
|
561
562
|
StandardOutput=journal
|
|
@@ -595,6 +596,8 @@ function buildLaunchdPlist({
|
|
|
595
596
|
<true/>
|
|
596
597
|
<key>KeepAlive</key>
|
|
597
598
|
<true/>
|
|
599
|
+
<key>AbandonProcessGroup</key>
|
|
600
|
+
<true/>
|
|
598
601
|
<key>StandardOutPath</key>
|
|
599
602
|
<string>${escapeXml(join3(installDir, "tmex.log"))}</string>
|
|
600
603
|
<key>StandardErrorPath</key>
|
|
Binary file
|
package/dist/runtime/server.js
CHANGED
|
@@ -7721,7 +7721,7 @@ var require_bcrypt_pbkdf = __commonJS((exports, module) => {
|
|
|
7721
7721
|
|
|
7722
7722
|
// ../../node_modules/.bun/cpu-features@0.0.10/node_modules/cpu-features/build/Release/cpufeatures.node
|
|
7723
7723
|
var require_cpufeatures = __commonJS((exports, module) => {
|
|
7724
|
-
module.exports = __require("./cpufeatures-
|
|
7724
|
+
module.exports = __require("./cpufeatures-j6gtp52k.node");
|
|
7725
7725
|
});
|
|
7726
7726
|
|
|
7727
7727
|
// ../../node_modules/.bun/cpu-features@0.0.10/node_modules/cpu-features/lib/index.js
|
|
@@ -8334,12 +8334,12 @@ var require_utils3 = __commonJS((exports, module) => {
|
|
|
8334
8334
|
|
|
8335
8335
|
// ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node
|
|
8336
8336
|
var require_sshcrypto = __commonJS((exports, module) => {
|
|
8337
|
-
module.exports = __require("./sshcrypto-
|
|
8337
|
+
module.exports = __require("./sshcrypto-k4w22zcv.node");
|
|
8338
8338
|
});
|
|
8339
8339
|
|
|
8340
8340
|
// ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js
|
|
8341
8341
|
var require_poly1305 = __commonJS((exports, module) => {
|
|
8342
|
-
var __dirname = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto", __filename = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js";
|
|
8342
|
+
var __dirname = "/Users/krhougs/LocalCodes/tmex/.claude/worktrees/prod-crash-hardening/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto", __filename = "/Users/krhougs/LocalCodes/tmex/.claude/worktrees/prod-crash-hardening/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js";
|
|
8343
8343
|
var createPoly1305 = function() {
|
|
8344
8344
|
var _scriptDir = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : undefined;
|
|
8345
8345
|
if (typeof __filename !== "undefined")
|
|
@@ -11112,7 +11112,7 @@ ${formatted}-----END ${type} KEY-----`;
|
|
|
11112
11112
|
|
|
11113
11113
|
// ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/agent.js
|
|
11114
11114
|
var require_agent = __commonJS((exports, module) => {
|
|
11115
|
-
var __dirname = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib";
|
|
11115
|
+
var __dirname = "/Users/krhougs/LocalCodes/tmex/.claude/worktrees/prod-crash-hardening/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib";
|
|
11116
11116
|
var { Socket } = __require("net");
|
|
11117
11117
|
var { Duplex } = __require("stream");
|
|
11118
11118
|
var { resolve: resolve3 } = __require("path");
|
|
@@ -23090,6 +23090,10 @@ Time: {{time}}`,
|
|
|
23090
23090
|
retry: "Retry",
|
|
23091
23091
|
scrollToBottom: "Scroll to bottom"
|
|
23092
23092
|
},
|
|
23093
|
+
welcome: {
|
|
23094
|
+
title: "New Agent chat",
|
|
23095
|
+
subtitle: "Describe your task to start working in the selected terminal"
|
|
23096
|
+
},
|
|
23093
23097
|
session: {
|
|
23094
23098
|
none: "No session selected",
|
|
23095
23099
|
new: "New agent session",
|
|
@@ -23787,6 +23791,10 @@ Bot\uFF1A{{botName}}
|
|
|
23787
23791
|
retry: "\u91CD\u8BD5",
|
|
23788
23792
|
scrollToBottom: "\u56DE\u5230\u5E95\u90E8"
|
|
23789
23793
|
},
|
|
23794
|
+
welcome: {
|
|
23795
|
+
title: "\u65B0\u5EFA Agent \u5BF9\u8BDD",
|
|
23796
|
+
subtitle: "\u5411 Agent \u63CF\u8FF0\u4F60\u7684\u9700\u6C42\uFF0C\u5F00\u59CB\u5728\u6240\u9009\u7EC8\u7AEF\u4E2D\u534F\u4F5C"
|
|
23797
|
+
},
|
|
23790
23798
|
session: {
|
|
23791
23799
|
none: "\u672A\u9009\u62E9\u4F1A\u8BDD",
|
|
23792
23800
|
new: "\u65B0\u5EFA Agent \u4F1A\u8BDD",
|
|
@@ -24484,6 +24492,10 @@ Bot\uFF1A{{botName}}
|
|
|
24484
24492
|
retry: "\u518D\u8A66\u884C",
|
|
24485
24493
|
scrollToBottom: "\u6700\u4E0B\u90E8\u3078"
|
|
24486
24494
|
},
|
|
24495
|
+
welcome: {
|
|
24496
|
+
title: "\u65B0\u3057\u3044 Agent \u30C1\u30E3\u30C3\u30C8",
|
|
24497
|
+
subtitle: "\u30BF\u30B9\u30AF\u3092\u5165\u529B\u3057\u3066\u3001\u9078\u629E\u3057\u305F\u7AEF\u672B\u3067\u306E\u4F5C\u696D\u3092\u59CB\u3081\u307E\u3057\u3087\u3046"
|
|
24498
|
+
},
|
|
24487
24499
|
session: {
|
|
24488
24500
|
none: "\u30BB\u30C3\u30B7\u30E7\u30F3\u672A\u9078\u629E",
|
|
24489
24501
|
new: "\u65B0\u898F\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30BB\u30C3\u30B7\u30E7\u30F3",
|
|
@@ -32401,10 +32413,16 @@ var telegramBotChats = sqliteTable("telegram_bot_chats", {
|
|
|
32401
32413
|
// ../../apps/gateway/src/db/client.ts
|
|
32402
32414
|
var sqliteClient = null;
|
|
32403
32415
|
var db = null;
|
|
32416
|
+
function applyPragmas(database) {
|
|
32417
|
+
database.run("PRAGMA foreign_keys = ON");
|
|
32418
|
+
database.run("PRAGMA journal_mode = WAL");
|
|
32419
|
+
database.run("PRAGMA busy_timeout = 5000");
|
|
32420
|
+
database.run("PRAGMA synchronous = NORMAL");
|
|
32421
|
+
}
|
|
32404
32422
|
function ensureSqliteClient() {
|
|
32405
32423
|
if (!sqliteClient) {
|
|
32406
32424
|
sqliteClient = new Database2(config.databaseUrl);
|
|
32407
|
-
sqliteClient
|
|
32425
|
+
applyPragmas(sqliteClient);
|
|
32408
32426
|
}
|
|
32409
32427
|
return sqliteClient;
|
|
32410
32428
|
}
|
|
@@ -79541,7 +79559,7 @@ async function standardizePrompt({
|
|
|
79541
79559
|
function wrapGatewayError(error51) {
|
|
79542
79560
|
if (!GatewayAuthenticationError.isInstance(error51))
|
|
79543
79561
|
return error51;
|
|
79544
|
-
const isProductionEnv = (process == null ? undefined : "
|
|
79562
|
+
const isProductionEnv = (process == null ? undefined : "development") === "production";
|
|
79545
79563
|
const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
|
|
79546
79564
|
if (isProductionEnv) {
|
|
79547
79565
|
return new AISDKError({
|
|
@@ -105055,6 +105073,7 @@ class SwitchBarrier {
|
|
|
105055
105073
|
console.warn(`[switch-barrier] Transaction timeout at stage: ${stage} for ${deviceId}`);
|
|
105056
105074
|
if (stage === "history") {
|
|
105057
105075
|
this.sendLiveResume(ws, deviceId, expectedToken);
|
|
105076
|
+
sessionStateStore.stopOutputBuffering(ws, deviceId);
|
|
105058
105077
|
pending.callbacks.onTimeout?.(stage);
|
|
105059
105078
|
return;
|
|
105060
105079
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var jt=Object.defineProperty;var $t=(n,e,t)=>e in n?jt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var p=(n,e,t)=>$t(n,typeof e!="symbol"?e+"":e,t);import{c as Ye,u as Ke,j as f,X as qt,r as d,M as J,a5 as At,a6 as Ot,a7 as dt,t as xe,a8 as Xt,a9 as it,aa as Qt,E as kt,ab as ot,F as ce,ac as Jt,C as It,ad as Nt,ae as _e,af as Zt,L as $e,n as en,B as fe,T as tn,K as ut,ag as nn,ah as sn,ai as rn,A as on,q as ln,s as an,v as cn,w as dn,x as un,y as hn,z as fn,aj as mn,ak as pn}from"./index-
|
|
1
|
+
var jt=Object.defineProperty;var $t=(n,e,t)=>e in n?jt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var p=(n,e,t)=>$t(n,typeof e!="symbol"?e+"":e,t);import{c as Ye,u as Ke,j as f,X as qt,r as d,M as J,a5 as At,a6 as Ot,a7 as dt,t as xe,a8 as Xt,a9 as it,aa as Qt,E as kt,ab as ot,F as ce,ac as Jt,C as It,ad as Nt,ae as _e,af as Zt,L as $e,n as en,B as fe,T as tn,K as ut,ag as nn,ah as sn,ai as rn,A as on,q as ln,s as an,v as cn,w as dn,x as un,y as hn,z as fn,aj as mn,ak as pn}from"./index-mf4NroE4.js";import{R as wn}from"./refresh-cw-DaPtMs2v.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -23,4 +23,4 @@ var jt=Object.defineProperty;var $t=(n,e,t)=>e in n?jt(n,e,{enumerable:!0,config
|
|
|
23
23
|
`);return(e.endsWith(`
|
|
24
24
|
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
25
25
|
`)}const yr="\x1B[?1049h\x1B[H\x1B[2J";function gr(n){return yr+Kt(n)}function Mt(n,e){let t=e,s=0;for(const l of n)l===10&&!t&&(s+=1),t=l===13;const i=t;if(s===0)return{normalized:n,endedWithCR:i};const r=new Uint8Array(n.length+s);let o=0;t=e;for(const l of n)l===10&&!t&&(r[o]=13,o+=1),r[o]=l,o+=1,t=l===13;return{normalized:r,endedWithCR:i}}const Sr=1.3,_r=36,xr=500,Tr=12;function br(n,e){const t=d.useRef(!1);return d.useEffect(()=>{const s=n.current;if(!s||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;t.current=!0;let r=0,o=null,l=!1,u=0,h=0,a=0,x=null,v=!1;const O=()=>{x!==null&&(clearTimeout(x),x=null)},E=T=>T?!!(T.closest(".scrollbar")||T.closest(".slider")||T.closest(".xterm-scroll-area")):!1,b=(T,R,P)=>{const U=P instanceof Element?P:null;if(E(U))return!0;const Q=document.elementFromPoint(T,R);if(E(Q))return!0;const S=s.querySelector(".xterm");if(!(S instanceof HTMLElement))return!1;const C=S.getBoundingClientRect(),F=T>=C.left&&T<=C.right,j=R>=C.top&&R<=C.bottom;return!F||!j?!1:T>=C.right-_r},z=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(R=>R instanceof HTMLElement),w=T=>{if(o===null)return null;for(let R=0;R<T.length;R+=1){const P=T.item(R);if(P&&P.identifier===o)return P}return null},N=T=>{if(O(),T.touches.length!==1)return;const R=T.touches.item(0);R&&(o=R.identifier,r=R.clientY,u=0,l=b(R.clientX,R.clientY,T.target),h=R.clientX,a=R.clientY,v=!1,l||(x=setTimeout(()=>{var U;x=null;const P=(e==null?void 0:e())??null;(U=P==null?void 0:P.startTouchSelection)!=null&&U.call(P,h,a,"word")&&(v=!0)},xr)))},Y=T=>{var F,j,M,X,q,te,ne,D,re;const R=w(T.touches)??T.touches.item(0);if(!R)return;if(v){const B=(e==null?void 0:e())??null;(F=B==null?void 0:B.updateTouchSelection)==null||F.call(B,R.clientX,R.clientY),T.cancelable&&T.preventDefault();return}if(x!==null&&Math.hypot(R.clientX-h,R.clientY-a)>Tr&&O(),l||(l=b(R.clientX,R.clientY,T.target),l&&(u=0)),l)return;const P=R.clientY,U=r-P;if(r=P,U===0)return;let Q=!1,S=!1;const C=(e==null?void 0:e())??null;if(C){const B=C==null?void 0:C._core,V=((q=(X=(M=(j=B==null?void 0:B._renderService)==null?void 0:j.dimensions)==null?void 0:M.css)==null?void 0:X.cell)==null?void 0:q.height)??18;u+=U*Sr;const L=u>0?Math.floor(u/V):Math.ceil(u/V);if(typeof C.handleViewportGesture=="function")L!==0&&(Q=C.handleViewportGesture({source:"touch",deltaY:L*V,clientX:R.clientX,clientY:R.clientY}),u-=L*V);else if(L!==0){const $=((ne=(te=C.buffer)==null?void 0:te.active)==null?void 0:ne.viewportY)??0;C.scrollLines(L);const le=((re=(D=C.buffer)==null?void 0:D.active)==null?void 0:re.viewportY)??0;Q=$!==le,S=L<0&&$<=0&&le<=0,u-=L*V}}else{const B=z();if(B.length===0)return;for(const V of B){const L=V.scrollTop;V.scrollTop+=U;const $=V.scrollTop;Math.abs($-L)>0&&(Q=!0),U<0&&$<=0&&(S=!0)}if(!Q){const V=s.querySelector(".xterm");if(V instanceof HTMLElement){const L=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:U}),$=V.dispatchEvent(L);Q=L.defaultPrevented||!$}}}T.cancelable&&(Q||S)&&T.preventDefault()},K=T=>{var P;if(O(),!(o===null||!w(T.changedTouches))&&(o=null,u=0,l=!1,v)){v=!1;const U=(e==null?void 0:e())??null;(P=U==null?void 0:U.endTouchSelection)==null||P.call(U)}},H=T=>{v&&T.preventDefault()};return s.addEventListener("touchstart",N,{passive:!0}),s.addEventListener("touchmove",Y,{passive:!1}),s.addEventListener("touchend",K,{passive:!0}),s.addEventListener("touchcancel",K,{passive:!0}),s.addEventListener("contextmenu",H),()=>{t.current=!1,O(),s.removeEventListener("touchstart",N),s.removeEventListener("touchmove",Y),s.removeEventListener("touchend",K),s.removeEventListener("touchcancel",K),s.removeEventListener("contextmenu",H)}},[n,e]),t}function Er({now:n,remoteSize:e,pendingLocalSize:t,ttlMs:s=2e3}){return!t||n-t.at>s?!0:t.cols===e.cols&&t.rows===e.rows}function Rr({currentSize:n,containerSize:e,force:t=!1}){return t?!0:n.cols!==e.cols||n.rows!==e.rows}function Cr({deviceId:n,paneId:e,deviceConnected:t,isSelectionInvalid:s,onResize:i,onSync:r,getContainerRect:o}){const l=d.useRef(null),u=d.useRef(null),h=d.useRef(null),a=d.useRef(null),x=d.useRef(0),v=d.useRef([]),O=d.useRef(null),E=d.useRef(null),b=d.useRef(o),z=d.useRef(!1),w=d.useRef(i),N=d.useRef(r);d.useEffect(()=>{w.current=i},[i]),d.useEffect(()=>{N.current=r},[r]),d.useEffect(()=>{b.current=o},[o]);const Y=d.useCallback(()=>{var te,ne,D,re,B,V,L,$,le,_;const S=E.current,C=O.current;if(!S||!C||!S.element)return null;let F;try{const g=C.proposeDimensions();if(!g)throw new Error("fitAddon.proposeDimensions() returned null");F=Math.max(2,g.cols)}catch{const g=S._core,k=((re=(D=(ne=(te=g==null?void 0:g._renderService)==null?void 0:te.dimensions)==null?void 0:ne.css)==null?void 0:D.cell)==null?void 0:re.width)??9,W=(B=b.current)==null?void 0:B.call(b);if(!W||W.width===0)return null;F=Math.max(2,Math.floor(W.width/k))}const j=(V=b.current)==null?void 0:V.call(b);if(!j||j.height===0)return null;const M=S._core,X=((_=(le=($=(L=M==null?void 0:M._renderService)==null?void 0:L.dimensions)==null?void 0:$.css)==null?void 0:le.cell)==null?void 0:_.height)??17,q=Math.max(2,Math.floor(j.height/X));return{cols:F,rows:q}},[]),K=d.useCallback((S,C)=>{const F=E.current;F&&(F.cols===S&&F.rows===C||F.resize(S,C))},[]),H=d.useCallback((S,C=!1)=>{if(!n||!e||!t||s&&S!=="sync"||!C&&Date.now()<x.current||!E.current)return!1;const j=Y();if(!j)return!1;const{cols:M,rows:X}=j,q=h.current;return!C&&q&&q.cols===M&&q.rows===X?(K(M,X),!0):(K(M,X),S==="sync"?N.current(M,X):w.current(M,X),h.current={cols:M,rows:X},a.current={cols:M,rows:X,at:Date.now()},!0)},[K,t,n,s,Y,e]),T=d.useCallback((S="resize",C={})=>{const{immediate:F=!1,force:j=!1}=C;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const M=()=>{l.current=requestAnimationFrame(()=>{l.current=null,H(S,j)})};if(F){M();return}u.current=window.setTimeout(()=>{u.current=null,M()},150)},[H]),R=d.useCallback(()=>{for(const S of v.current)window.clearTimeout(S);v.current=[]},[]),P=d.useCallback(()=>{var C;R(),T("sync",{immediate:!0,force:!0});const S=window.setTimeout(()=>{T("sync",{immediate:!0,force:!0})},60);v.current.push(S),typeof document<"u"&&"fonts"in document&&((C=document.fonts)!=null&&C.ready)&&document.fonts.ready.then(()=>{T("sync",{immediate:!0,force:!0})}).catch(()=>{})},[R,T]);d.useEffect(()=>{let S=null;const C=()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,T("resize")})};return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C),S!==null&&cancelAnimationFrame(S)}},[T]),d.useEffect(()=>{const S=()=>{var te;const M=E.current,X=Y();if(!M||!X)return;if(!Rr({currentSize:{cols:Math.max(2,M.cols),rows:Math.max(2,M.rows)},containerSize:X})){(te=M.refresh)==null||te.call(M);return}T("sync",{force:!0})},C=()=>{if(document.visibilityState!=="visible"){z.current=!0;return}z.current&&(z.current=!1,S())},F=()=>{z.current=!0},j=()=>{z.current&&(z.current=!1,S())};return document.addEventListener("visibilitychange",C),window.addEventListener("blur",F),window.addEventListener("focus",j),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("blur",F),window.removeEventListener("focus",j)}},[Y,T]),d.useEffect(()=>()=>{R(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[R]);const U=d.useCallback(S=>{O.current=S},[]),Q=d.useCallback(S=>{E.current=S},[]);return{scheduleResize:T,runPostSelectResize:P,clearPostSelectResizeTimers:R,setFitAddon:U,setTerminal:Q,lastReportedSize:h,pendingLocalSize:a,suppressLocalResizeUntil:x}}const vr={fontFamily:Xt,fontSize:13,scrollback:1e4},rt="tmex:terminal-mode-cache";function Mr(n,e){try{const t=sessionStorage.getItem(rt);return t?JSON.parse(t)[`${n}:${e}`]??null:null}catch{return null}}function Dr(n,e,t){try{const s=sessionStorage.getItem(rt),i=s?JSON.parse(s):{},r=`${n}:${e}`;t?i[r]=t:delete i[r],sessionStorage.setItem(rt,JSON.stringify(i))}catch{}}function Ar(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Or(n,e){if(!e)return n?{...n,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const t=Ar();if(!n)return t;const s=n.mouseNormal||n.mouseButton||n.mouseAny;return{...n,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:s?n.mouseNormal:t.mouseNormal}}function kr(n){var t;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Yt,e.__tmexE2eTerminalRenderer=((t=n.getRendererKind)==null?void 0:t.call(n))??null}function Ir(n){if(!n)return;const e=globalThis;e.__tmexE2eTerminal!==n&&e.__tmexE2eXterm!==n||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Vt=d.forwardRef(({deviceId:n,paneId:e,theme:t,inputMode:s,deviceConnected:i,isSelectionInvalid:r,onResize:o,onSync:l,children:u},h)=>{const[a,x]=d.useState(null),[v,O]=d.useState(!1),E=J(_=>_.sendInput),{t:b}=Ke(),z=d.useMemo(()=>{switch(t){case"light":return Ot;default:return At}},[t]),w=d.useRef(null),N=d.useRef(null),Y=d.useRef(null),K=d.useRef(n),H=d.useRef(e),T=d.useRef(n),R=d.useRef(e),P=d.useRef(i&&!r),U=d.useRef(s),Q=d.useRef(z),S=d.useRef(!1),C=d.useRef(!1),F=d.useRef(null),j=d.useRef(!1),M=d.useCallback((_,g,k)=>{!(_!=null&&_.exportModeSnapshot)||!g||!k||Dr(g,k,_.exportModeSnapshot())},[]),X=d.useCallback(()=>a,[a]);br(w,X),d.useEffect(()=>{K.current=n,H.current=e,C.current=!1},[n,e]),d.useEffect(()=>{P.current=i&&!r},[i,r]),d.useEffect(()=>{U.current=s},[s]),d.useEffect(()=>{Q.current=z},[z]);const q=d.useCallback(_=>{if(!_||s!=="direct"||!P.current)return;const g=K.current,k=H.current;!g||!k||E(g,k,_,!1)},[s,E]),{pendingLocalSize:te,scheduleResize:ne,runPostSelectResize:D,setFitAddon:re,setTerminal:B}=Cr({deviceId:n,paneId:e,deviceConnected:i,isSelectionInvalid:r,onResize:o,onSync:l,getContainerRect:()=>{const _=w.current;if(!_)return null;const g=_.getBoundingClientRect();return{width:g.width,height:g.height}}});d.useEffect(()=>{let _=!1,g=null;return pr({...vr,theme:Q.current,disableStdin:U.current==="editor"}).then(k=>{if(_){k.dispose();return}g=k,N.current&&k.open(N.current),kr(k),x(k)}),()=>{_=!0,x(null),Ir(g),g==null||g.dispose()}},[]),d.useEffect(()=>{!a||!("setTheme"in a)||a.setTheme(z)},[a,z]),d.useEffect(()=>{!a||!("setDisableStdin"in a)||a.setDisableStdin(s==="editor")},[a,s]),d.useEffect(()=>{!a||s!=="direct"||window.innerWidth<768||"ontouchstart"in window||a.focus()},[a,s]);const V=d.useMemo(()=>a?{onResetTerminal:_=>{K.current===_&&(M(a,T.current,R.current),j.current=!0,a.reset(),S.current=!1,D())},onApplyHistory:(_,g,k)=>{var ie;if(K.current!==_)return;const W=Or(Mr(K.current,H.current),k);W&&((ie=a.restoreModeSnapshot)==null||ie.call(a,W));const G=k?gr(g):Kt(g);C.current=!0,a.write(G),j.current=!1,T.current=K.current,R.current=H.current,M(a,K.current,H.current)},onFlushBuffer:(_,g)=>{if(K.current===_){for(const k of g){const W=Mt(k,S.current);S.current=W.endedWithCR,a.write(W.normalized)}C.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),C.current=!1),T.current=K.current,R.current=H.current,M(a,K.current,H.current)}},onOutput:(_,g,k)=>{if(K.current!==_||H.current!==g)return;const W=Mt(k,S.current);S.current=W.endedWithCR,a.write(W.normalized),C.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),C.current=!1),T.current=K.current,R.current=H.current,M(a,K.current,H.current)}}:{},[a,M,D]);d.useEffect(()=>{a?F.current!==a&&(S.current=!1,T.current=K.current,R.current=H.current,F.current=a):F.current=null},[a]),d.useEffect(()=>{if(!(!a||!n||!e))return()=>{if(j.current){j.current=!1;return}M(a,T.current,R.current)}},[n,a,e,M]),d.useEffect(()=>{dt(V)},[V]),d.useEffect(()=>()=>{dt({})},[]),d.useEffect(()=>{if(!a){Y.current=null,re(null),B(null);return}const _=new mr;return a.loadAddon(_),Y.current=_,re(_),B(a),D(),()=>{try{_.dispose()}finally{Y.current=null,re(null),B(null)}}},[a,D,re,B]),d.useEffect(()=>{const _=w.current;if(!_)return;let g=null;const k=new ResizeObserver(()=>{g!==null&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{g=null,ne("resize")})});return k.observe(_),()=>{k.disconnect(),g!==null&&cancelAnimationFrame(g)}},[ne]),d.useEffect(()=>{if(!a||!n||!e)return;const _=a.onData(g=>{!i||r||q(g)});return a.attachCustomKeyEventHandler(g=>!i||r||g.type!=="keydown"||s!=="direct"?!0:g.shiftKey&&g.key==="Enter"?(g.preventDefault(),q("\x1B[13;2u"),!1):!0),()=>{_.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,i,r,s,q,n,e]),d.useEffect(()=>{if(!(a!=null&&a.onSelectionChange)){O(!1);return}const _=a.onSelectionChange(g=>{O(!!g)});return()=>{_.dispose(),O(!1)}},[a]);const L=d.useCallback(()=>{var g;if(!a)return;const _=((g=a.getSelection)==null?void 0:g.call(a))??"";_&&Gt(_).then(()=>{xe.success(b("terminal.copied"))}).catch(()=>{xe.error(b("terminal.copyFailed"))}).finally(()=>{var k;(k=a.clearSelection)==null||k.call(a),a.focus()})},[a,b]),$=d.useCallback(()=>{var g;if(!a)return;((g=navigator.clipboard)!=null&&g.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(k=>{var W;k&&a.paste(k),(W=a.clearSelection)==null||W.call(a),a.focus()}).catch(()=>{xe.error(b("terminal.pasteFailed"))})},[a,b]),le=d.useCallback(()=>{var _;(_=a==null?void 0:a.clearSelection)==null||_.call(a),a==null||a.focus()},[a]);return d.useImperativeHandle(h,()=>({write:_=>a==null?void 0:a.write(_),reset:()=>{a==null||a.reset(),S.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(_,g)=>a==null?void 0:a.resize(_,g),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>D(),scheduleResize:(_,g)=>ne(_,g),calculateSizeFromContainer:()=>{var Me,oe,ye,ue,ae,Z,ge,he,Se,be,De,Ae,Oe,ke,Ee,c;const _=w.current,g=a,k=Y.current;if(!_||!g)return null;const W=_.getBoundingClientRect();if(W.width===0||W.height===0)return null;const G=g._core;let ie;if(k)try{const m=k.proposeDimensions();if(m)ie=Math.max(2,m.cols);else{const y=((ue=(ye=(oe=(Me=G==null?void 0:G._renderService)==null?void 0:Me.dimensions)==null?void 0:oe.css)==null?void 0:ye.cell)==null?void 0:ue.width)??9;ie=Math.max(2,Math.floor(W.width/y))}}catch{const m=((he=(ge=(Z=(ae=G==null?void 0:G._renderService)==null?void 0:ae.dimensions)==null?void 0:Z.css)==null?void 0:ge.cell)==null?void 0:he.width)??9;ie=Math.max(2,Math.floor(W.width/m))}else{const m=((Ae=(De=(be=(Se=G==null?void 0:G._renderService)==null?void 0:Se.dimensions)==null?void 0:be.css)==null?void 0:De.cell)==null?void 0:Ae.width)??9;ie=Math.max(2,Math.floor(W.width/m))}const pe=((c=(Ee=(ke=(Oe=G==null?void 0:G._renderService)==null?void 0:Oe.dimensions)==null?void 0:ke.css)==null?void 0:Ee.cell)==null?void 0:c.height)??17,We=Math.max(2,Math.floor(W.height/pe));return{cols:ie,rows:We}},getPendingLocalSize:()=>te.current}),[a,te,D,ne]),f.jsxs("div",{className:"flex h-full w-full flex-col",style:{backgroundColor:z.background},"data-terminal-engine":Yt,children:[f.jsxs("div",{ref:w,className:"relative min-h-0 w-full flex-1",children:[f.jsx("div",{ref:N,className:"absolute inset-0"}),f.jsx(wr,{visible:v,canPaste:s==="direct"&&i&&!r,onCopy:L,onPaste:$,onDismiss:le})]}),u]})});Vt.displayName="Terminal";const Nr=1200,Hr=2e3;function me(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Wt(n,e){const t=n.filter(s=>e-s.at<Nr);return t.length===0?null:t.reduce((s,i)=>i.at>s.at?i:s)}function ve(n,e=Date.now()){return!n||e-n.at>Hr?null:n}function Pr(n){const e=n.now??Date.now(),t=Wt(n.recentSelectRequests,e);if(t&&!me(t,n.activePaneFromEvent)||me(n.currentRoute,n.activePaneFromEvent)||me(n.lastHandledActive,n.activePaneFromEvent))return!0;const s=ve(n.pendingUserSelection,e);return!!(s&&!me(s,n.activePaneFromEvent))}function Br(n){const e=n.now??Date.now(),t=Wt(n.recentSelectRequests,e),s=ve(n.pendingUserSelection,e);return!!(s&&!me(s,n.snapshotActive)||t&&!me(t,n.snapshotActive))}function Lr(n){const e=n.now??Date.now(),t=ve(n.pendingUserSelection,e);return!(t&&me(t,n.routeTarget)||n.snapshotActive&&me(n.snapshotActive,n.routeTarget))}const Fr=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Dt=d.memo(function({onSend:e,onFocusEditor:t,disabled:s,isMobile:i,inputMode:r}){return f.jsx("div",{className:"terminal-shortcuts-strip","data-testid":"terminal-shortcuts-strip",children:f.jsx("div",{className:"shortcut-row flex items-center gap-1.5 py-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Fr.map(o=>f.jsx(fe,{variant:"ghost",size:"sm",className:"terminal-shortcut-btn h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onMouseDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),i&&r==="editor"&&(t==null||t())},disabled:s,children:o.label},o.key))})})});function Yr(){var Ee;const{t:n}=Ke(),{deviceId:e,windowId:t,paneId:s}=it(),i=Qt(),r=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),h=d.useRef(!1),a=d.useRef(!1),x=d.useRef(null),v=J(c=>c.selectPane),O=J(c=>e?c.snapshots[e]:void 0),E=J(c=>{var m;return e?(m=c.deviceErrors)==null?void 0:m[e]:void 0}),b=J(c=>{var m;return e?((m=c.deviceConnected)==null?void 0:m[e])??!1:!1}),z=kt(c=>{var m;return((m=c.settings)==null?void 0:m.siteName)??"tmex"}),w=d.useMemo(()=>ot(s),[s]),N=d.useMemo(()=>e&&w?`${e}:${w}`:null,[e,w]),[Y,K]=d.useState(!1),[H,T]=d.useState(""),R=d.useRef(!1),P=!b||!w,[U,Q]=d.useState(!1),S=ce(c=>c.inputMode),C=ce(c=>c.theme),F=ce(c=>c.editorSendWithEnter),j=ce(c=>c.setEditorSendWithEnter),M=ce(c=>c.addEditorHistory),X=ce(c=>c.setEditorDraft),q=ce(c=>c.removeEditorDraft),te=ce(c=>N?c.editorDrafts[N]??"":""),ne=d.useMemo(()=>Jt(),[]),D=(Ee=O==null?void 0:O.session)==null?void 0:Ee.windows,re=C==="light"?Ot:At,{data:B}=It({queryKey:["devices"],queryFn:async()=>{const c=await fetch("/api/devices");if(!c.ok)throw new Error("Failed to fetch devices");return c.json()},throwOnError:!1}),V=d.useMemo(()=>{if(e)return B==null?void 0:B.devices.find(c=>c.id===e)},[e,B==null?void 0:B.devices]),L=d.useMemo(()=>{if(!(!t||!D))return D.find(c=>c.id===t)},[t,D]),$=d.useMemo(()=>{if(!(!w||!L))return L.panes.find(c=>c.id===w)},[w,L]),le=!!D,W=!!(le&&!!t&&!L||le&&!!t&&!!w&&!!L&&!$?n("wsError.checkGateway"):null),G=!!(b&&w&&!W),ie=d.useMemo(()=>{if(!L||!$)return null;const c=(V==null?void 0:V.name)??e;return Nt({paneIdx:$.index,windowIdx:L.index,paneTitle:$.title,windowName:L.name,windowCustomName:L.customName,deviceName:c})},[V==null?void 0:V.name,e,$,L]),pe=d.useMemo(()=>{if(!D||D.length===0)return null;const c=D.find(y=>y.active),m=c==null?void 0:c.panes.find(y=>y.active);return!c||!m?null:{windowId:c.id,paneId:m.id}},[D]),We=d.useCallback((c,m)=>{!e||!w||J.getState().resizePane(e,w,c,m)},[e,w]),Me=d.useCallback((c,m)=>{!e||!w||J.getState().syncPaneSize(e,w,c,m)},[e,w]),oe=d.useCallback((c,m)=>{const y=u.current,A=(y==null?void 0:y.calculateSizeFromContainer())??(y==null?void 0:y.getSize())??void 0;if(A)return A;if(!c||!m||!D)return;const ee=D.find(we=>we.id===c),se=ee==null?void 0:ee.panes.find(we=>we.id===m);if(!(!se||se.width<=1||se.height<=1))return{cols:se.width,rows:se.height}},[D]);d.useEffect(()=>{const c=()=>{K(window.innerWidth<768||"ontouchstart"in window)};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),d.useEffect(()=>{if(!Y||!ne||a.current)return;a.current=!0;const c=()=>{window.scrollTo(0,1)},m=window.requestAnimationFrame(c),y=window.setTimeout(c,120),A=window.setTimeout(c,420);return()=>{window.cancelAnimationFrame(m),window.clearTimeout(y),window.clearTimeout(A)}},[ne,Y]),d.useEffect(()=>{e&&(h.current=!1,ge.current=null,he.current=null,x.current=null,ue.current=[])},[e]),d.useEffect(()=>{b||(h.current=!1)},[b]),d.useEffect(()=>{if(!e||!b||!t||!D)return;if(D.length===0){i("/devices",{replace:!0});return}const c=D.find(y=>y.id===t);if(!c)return;if(!w){const y=c.panes.find(A=>A.active)??c.panes[0];y&&i(`/devices/${e}/windows/${t}/panes/${_e(y.id)}`,{replace:!0});return}if(!c.panes.find(y=>y.id===w)){const y=c.panes.find(A=>A.active)??c.panes[0];y&&i(`/devices/${e}/windows/${t}/panes/${_e(y.id)}`,{replace:!0});return}},[e,b,D,t,w,i]),d.useEffect(()=>{if(!e||!b||!D||D.length===0||t&&w||h.current)return;const c=D.find(y=>y.active)??D[0],m=c.panes.find(y=>y.active)??c.panes[0];m&&(h.current=!0,i(`/devices/${e}/windows/${c.id}/panes/${_e(m.id)}`,{replace:!0}))},[b,e,i,w,t,D]);const ye=d.useRef(null);d.useEffect(()=>{ye.current=null},[e,w]),d.useEffect(()=>{if(!e||!t||!w||P||!b)return;const c=`${e}:${t}:${w}`;if(ye.current===c)return;ye.current=c;const m=oe(t,w);ae(t,w),v(e,t,w,m)},[b,e,oe,P,w,v,t]),d.useEffect(()=>{if(!e||!b||!t||!w)return;const c={windowId:t,paneId:w};Lr({routeTarget:c,snapshotActive:pe,pendingUserSelection:x.current})&&(x.current={windowId:c.windowId,paneId:c.paneId,at:Date.now()})},[b,e,w,pe,t]);const ue=d.useRef([]),ae=d.useCallback((c,m)=>{const y=Date.now(),A=[...ue.current.filter(ee=>y-ee.at<2e3),{windowId:c,paneId:m,at:y}];ue.current=A.slice(-8)},[]),Z=J(c=>e?c.activePaneFromEvent[e]:void 0),ge=d.useRef(null);d.useEffect(()=>{if(!e||!b||!t||!w||!Z)return;const c=Date.now(),m=ve(x.current,c);if(x.current=m,Pr({now:c,pendingUserSelection:m,activePaneFromEvent:Z,currentRoute:{windowId:t,paneId:w},recentSelectRequests:ue.current,lastHandledActive:ge.current}))return;ge.current={...Z},m&&m.windowId===Z.windowId&&m.paneId===Z.paneId&&(x.current=null);const y=oe(Z.windowId,Z.paneId);ae(Z.windowId,Z.paneId),v(e,Z.windowId,Z.paneId,y),i(`/devices/${e}/windows/${Z.windowId}/panes/${_e(Z.paneId)}`,{replace:!0})},[e,b,t,w,Z,ae,oe,v,i]);const he=d.useRef(null);d.useEffect(()=>{if(!e||!b||!D||D.length===0)return;const c=ue.current,m=D.find(je=>je.active);if(!m)return;const y=m.panes.find(je=>je.active);if(!y)return;const A={windowId:m.id,paneId:y.id},ee=Date.now(),se=ve(x.current,ee);if(x.current=se,Br({now:ee,pendingUserSelection:se,snapshotActive:A,recentSelectRequests:c})||he.current&&he.current.windowId===A.windowId&&he.current.paneId===A.paneId||(he.current={...A},se&&se.windowId===A.windowId&&se.paneId===A.paneId&&(x.current=null),t===A.windowId&&w===A.paneId))return;const we=oe(A.windowId,A.paneId);ae(A.windowId,A.paneId),v(e,A.windowId,A.paneId,we),i(`/devices/${e}/windows/${A.windowId}/panes/${_e(A.paneId)}`,{replace:!0})},[e,b,D,t,w,ae,oe,v,i]);const Se=J(c=>e?c.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!b||!Se)return;const c=5e3,m=Date.now()-Se;if(m>c){J.getState().clearPendingCreateWindow(e);return}if(!pe){const ee=window.setTimeout(()=>{J.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ee)}const y=pe;if(t===y.windowId&&w===y.paneId){const ee=window.setTimeout(()=>{J.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ee)}x.current={windowId:y.windowId,paneId:y.paneId,at:Date.now()};const A=oe(y.windowId,y.paneId);ae(y.windowId,y.paneId),v(e,y.windowId,y.paneId,A),i(`/devices/${e}/windows/${y.windowId}/panes/${_e(y.paneId)}`,{replace:!0}),J.getState().clearPendingCreateWindow(e)},[e,b,Se,pe,t,w,ae,oe,v,i]),d.useEffect(()=>{if(!G||!$||P)return;const c=u.current,m=c==null?void 0:c.getTerminal();if(!m)return;const y=Math.max(2,Math.floor($.width||0)),A=Math.max(2,Math.floor($.height||0));if(!y||!A)return;const ee=Date.now(),se={cols:y,rows:A},we=(c==null?void 0:c.getPendingLocalSize())??null;Er({now:ee,remoteSize:se,pendingLocalSize:we})&&(m.cols===y&&m.rows===A||m.resize(y,A))},[G,P,$]),d.useEffect(()=>{const c=window.requestAnimationFrame(()=>{var y;(y=u.current)==null||y.scrollToBottom()}),m=window.setTimeout(()=>{var y;(y=u.current)==null||y.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(c),window.clearTimeout(m)}},[S]),d.useEffect(()=>{E!=null&&E.message&&xe.error(E.message)},[E==null?void 0:E.message]),d.useEffect(()=>(document.title=Zt(ie),()=>{document.title=z}),[z,ie]),d.useEffect(()=>{const c=()=>{var m;(m=u.current)==null||m.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",c),()=>{window.removeEventListener("tmex:jump-to-latest",c)}},[]),d.useEffect(()=>{const c=m=>{const{deviceId:y,windowId:A,paneId:ee}=m.detail;y===e&&(x.current={windowId:A,paneId:ee,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",c),()=>{window.removeEventListener("tmex:user-initiated-selection",c)}},[e]),d.useEffect(()=>{T(te)},[te]);const be=d.useCallback(c=>{if(!e||!w||!G)return;J.getState().sendInput(e,w,c,!1)},[G,e,w]),De=d.useCallback(()=>{if(!G){xe.error(n("wsError.checkGateway"));return}if(!e||!w||!H.trim())return;Q(!0),window.setTimeout(()=>Q(!1),150);const c=F?`${H}\r`:H;J.getState().sendInput(e,w,c,!1),M(H),N&&q(N),T("")},[M,G,e,N,F,H,q,w,n]),Ae=d.useCallback(()=>{if(!G){xe.error(n("wsError.checkGateway"));return}if(!e||!w||!H.trim())return;Q(!0),window.setTimeout(()=>Q(!1),150);const c=H.split(/\r?\n/),m=J.getState();for(const y of c)y.trim()&&m.sendInput(e,w,`${y}\r`,!1);M(H),N&&q(N),T("")},[M,G,e,N,H,q,w,n]),Oe=d.useCallback(()=>{var c;(c=l.current)==null||c.focus({preventScroll:!0})},[]);if(!e)return f.jsx("div",{className:"flex h-full items-center justify-center p-4",children:f.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const ke=!b&&!E;return f.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[f.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${Y&&S==="editor"?"pb-1":""}`,children:[f.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:re.background},children:b&&w?f.jsx("div",{ref:r,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:f.jsx(Vt,{ref:u,deviceId:e,paneId:w,theme:C,inputMode:S,deviceConnected:b,isSelectionInvalid:W,onResize:We,onSync:Me,children:S==="direct"&&f.jsx(Dt,{onSend:be,disabled:!G,isMobile:Y,inputMode:S})},`${e}:${w}`)}):f.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:f.jsx("div",{className:"max-w-sm space-y-4",children:b?t?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:f.jsx($e,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),f.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:f.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),f.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:f.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),f.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),f.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),ke&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:f.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[f.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),f.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),S==="editor"&&f.jsxs("div",{ref:o,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[Y&&f.jsx(Dt,{onSend:be,onFocusEditor:Oe,disabled:!G,isMobile:Y,inputMode:S}),f.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:H,onChange:c=>{const m=c.target.value;if(T(m),!!N){if(m){X(N,m);return}q(N)}},placeholder:n("terminal.inputPlaceholder"),onCompositionStart:()=>{R.current=!0},onCompositionEnd:()=>{R.current=!1}}),f.jsx("div",{className:"actions mt-2",children:f.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[f.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[f.jsx(en,{size:"sm",checked:F,onCheckedChange:c=>j(!!c)}),f.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),f.jsxs(fe,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;T(""),N&&q(N),Y&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[f.jsx(tn,{className:"h-4 w-4"}),n("terminal.clear")]}),f.jsxs(fe,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Ae(),Y&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!G||U,children:[U?f.jsx($e,{className:"h-4 w-4 animate-spin"}):f.jsx(ut,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),f.jsxs(fe,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;De(),Y&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!G||U,children:[U?f.jsx($e,{className:"h-4 w-4 animate-spin"}):f.jsx(ut,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function Kr(){const{deviceId:n,windowId:e,paneId:t}=it(),s=t?ot(t):void 0,i=J(a=>a.snapshots),r=kt(a=>{var x;return((x=a.settings)==null?void 0:x.siteName)??"tmex"}),o=n?i[n]:void 0,l=d.useMemo(()=>{var a;if(!(!e||!((a=o==null?void 0:o.session)!=null&&a.windows)))return o.session.windows.find(x=>x.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!s||!l))return l.panes.find(a=>a.id===s)},[s,l]),h=d.useMemo(()=>l&&u?Nt({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,windowCustomName:l.customName,deviceName:r}):n??"",[l,u,r,n]);return f.jsx(f.Fragment,{children:h})}function Vr(){const{t:n}=Ke(),{deviceId:e,paneId:t}=it(),s=t?ot(t):void 0,i=ce(N=>N.inputMode),r=ce(N=>N.setInputMode),o=J(N=>{var Y;return e?((Y=N.deviceConnected)==null?void 0:Y[e])??!1:!1}),[l,u]=d.useState(!1),[h,a]=d.useState(!1),x=!!(s&&o),O=(It({queryKey:pn(e??"",s??""),queryFn:()=>mn(e??"",s??""),enabled:!!(e&&s),throwOnError:!1}).data??[]).some(N=>N.enabled),E=()=>{r(i==="direct"?"editor":"direct")},b=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},z=()=>{u(!0)},w=()=>{window.location.reload()};return f.jsxs(f.Fragment,{children:[f.jsx(fe,{variant:"ghost",size:"icon-sm",onClick:z,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:f.jsx(wn,{className:"h-4 w-4"})}),f.jsx(fe,{variant:"ghost",size:"icon-sm",onClick:E,disabled:!x,"data-testid":"terminal-input-mode-toggle","aria-label":n(i==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:n(i==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:i==="direct"?f.jsx(nn,{className:"h-4 w-4"}):f.jsx(En,{className:"h-4 w-4"})}),f.jsx(fe,{variant:"ghost",size:"icon-sm",onClick:b,disabled:!x,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:f.jsx(gn,{className:"h-4 w-4"})}),f.jsxs(fe,{variant:"ghost",size:"icon-sm",className:"relative",onClick:()=>a(!0),disabled:!s,"data-testid":"watch-open-button","aria-label":n("watch.title"),title:n("watch.title"),children:[f.jsx(sn,{className:"h-4 w-4"}),O&&f.jsx("span",{className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-primary","data-testid":"watch-active-indicator"})]}),e&&s&&f.jsx(rn,{open:h,onOpenChange:a,deviceId:e,paneId:s}),f.jsx(on,{open:l,onOpenChange:u,children:f.jsxs(ln,{children:[f.jsxs(an,{children:[f.jsx(cn,{children:n("nav.refreshPage")}),f.jsx(dn,{children:n("nav.refreshPageConfirm")})]}),f.jsxs(un,{children:[f.jsx(hn,{onClick:()=>u(!1),children:n("common.cancel")}),f.jsx(fn,{onClick:w,children:n("common.confirm")})]})]})})]})}export{Vr as PageActions,Kr as PageTitle,Yr as default};
|
|
26
|
-
//# sourceMappingURL=DevicePage-
|
|
26
|
+
//# sourceMappingURL=DevicePage-D44i3G_t.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as N,r as j,a as Z,C as ee,M as se,b as M,j as e,N as G,B as w,P as W,A as ae,q as te,s as ie,O as ne,T as Y,v as re,w as ce,x as oe,y as de,z as le,Q as me,t as v,R as he,U as pe,V as ue,W as xe,Y as $,p as ve,Z as ye,_ as je,o as O,$ as ge,a0 as fe,a1 as we,a2 as Ne,D as De,d as Ce,e as be,f as Se,g as Ee,I as x,S as B,h as Q,i as z,k as V,l as g,a3 as Me,m as Pe}from"./index-DNdArpmQ.js";import{C as S,c as E,a as Ke,b as Ie,d as $e}from"./card-CgiYiquV.js";function p(s){const c=s.trim();return c||void 0}function ke(s){return s?{name:s.name,type:s.type,host:s.host??"",port:s.port??22,username:s.username??"",sshConfigRef:s.sshConfigRef??"",session:s.session??"tmex",authMode:s.type==="local"?"auto":s.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"",sshConfigRef:"",session:"tmex",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Ae(s){if(s.type==="local")return{name:s.name.trim(),type:"local",session:p(s.session)??"tmex",authMode:"auto"};const c={name:s.name.trim(),type:"ssh",host:p(s.host),port:s.port,username:p(s.username),sshConfigRef:p(s.sshConfigRef),session:p(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&(c.password=s.password),s.authMode==="key"&&(c.privateKey=s.privateKey,c.privateKeyPassphrase=s.privateKeyPassphrase||void 0),c}function Te(s){if(s.type==="local")return{name:s.name.trim(),session:p(s.session)??"tmex",authMode:"auto"};const c={name:s.name.trim(),host:p(s.host),port:s.port,username:p(s.username),sshConfigRef:p(s.sshConfigRef),session:p(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&s.password&&(c.password=s.password),s.authMode==="key"&&s.privateKey&&(c.privateKey=s.privateKey,c.privateKeyPassphrase=s.privateKeyPassphrase||void 0),c}async function U(s,c){try{return(await s.json()).error??c}catch{return c}}function Le(){const{t:s}=N(),[c,m]=j.useState(!1),[a,y]=j.useState(null),[n,o]=j.useState(null),l=Z();j.useEffect(()=>{const r=()=>m(!0);return window.addEventListener("tmex:open-add-device",r),()=>window.removeEventListener("tmex:open-add-device",r)},[]);const{data:d,isLoading:u,isError:P}=ee({queryKey:["devices"],queryFn:async()=>{const r=await fetch("/api/devices");if(!r.ok)throw new Error(s("device.loadFailed"));return r.json()},throwOnError:!1}),D=se(r=>r.hydrateDeviceErrors);j.useEffect(()=>{d!=null&&d.devices&&D(d.devices.map(r=>({deviceId:r.id,lastError:r.lastError??null,lastErrorType:r.lastErrorType??null})))},[d,D]);const C=M({mutationFn:async r=>{if(!(await fetch(`/api/devices/${r}`,{method:"DELETE"})).ok)throw new Error(s("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),v.success(s("common.success"))},onError:r=>{v.error(r instanceof Error?r.message:s("common.error"))}}),b=(d==null?void 0:d.devices)??[];return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[u?e.jsx(S,{children:e.jsx(E,{className:"py-16 text-center text-sm text-muted-foreground",children:s("common.loading")})}):P?e.jsx(S,{children:e.jsx(E,{className:"py-16 text-center text-sm text-destructive",children:s("device.loadFailed")})}):b.length===0?e.jsx(S,{children:e.jsxs(E,{className:"space-y-4 py-14 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:e.jsx(G,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-medium",children:s("device.noDevices")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("device.addDevice")})]}),e.jsxs(w,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[e.jsx(W,{className:"h-4 w-4"}),s("device.addDevice")]})]})}):e.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:b.map(r=>e.jsx(Fe,{device:r,onEdit:()=>y(r),onDelete:()=>o(r)},r.id))}),c&&e.jsx(J,{mode:"create",onClose:()=>m(!1)}),a&&e.jsx(J,{mode:"edit",device:a,onClose:()=>y(null)}),e.jsx(ae,{open:n!==null,onOpenChange:r=>!r&&o(null),children:e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(ne,{className:"bg-destructive/10",children:e.jsx(Y,{className:"h-5 w-5 text-destructive"})}),e.jsx(re,{children:s("device.deleteConfirm")}),e.jsx(ce,{children:s("device.deleteDescription",{name:(n==null?void 0:n.name)??""})})]}),e.jsxs(oe,{children:[e.jsx(de,{children:s("common.cancel")}),e.jsx(le,{variant:"destructive",disabled:!n||C.isPending,onClick:()=>{n&&(C.mutate(n.id),o(null))},children:s("common.delete")})]})]})})]})}function Fe({device:s,onEdit:c,onDelete:m}){const{t:a}=N(),y=s.type==="local"?e.jsx(G,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"}),n=s.type==="local"?a("device.typeLocal"):`${s.username??"-"}@${s.host??"-"}:${s.port??22}`,o=M({mutationFn:async()=>{const l=await fetch(`/api/devices/${s.id}/test-connection`,{method:"POST"});let d=null;try{d=await l.json()}catch{d=null}if(!l.ok){const u=d;throw new Error((u==null?void 0:u.error)??a("common.error"))}return d},onSuccess:l=>{v.success(l.message??a("common.success"))},onError:l=>{v.error(l instanceof Error?l.message:a("common.error"))}});return e.jsxs(S,{"data-testid":"device-card","data-device-id":s.id,"data-device-name":s.name,className:"overflow-hidden",children:[e.jsxs(Ke,{className:"space-y-2 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx(Ie,{className:"line-clamp-1 text-sm",title:s.name,children:s.name}),e.jsx($e,{className:"line-clamp-1 text-xs",children:n})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e.jsxs(he,{children:[e.jsx(pe,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${s.id}`,"aria-label":a("common.edit"),title:a("common.edit")}),children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsxs(xe,{align:"end",children:[e.jsxs($,{"data-testid":`device-card-edit-${s.id}`,onClick:c,children:[e.jsx(ve,{className:"h-4 w-4"}),a("common.edit")]}),s.type==="ssh"&&e.jsxs($,{"data-testid":`device-card-test-${s.id}`,onClick:()=>o.mutate(),disabled:o.isPending,children:[e.jsx(ye,{className:"h-4 w-4"}),a("common.test")]}),e.jsx(je,{}),e.jsxs($,{"data-testid":`device-card-delete-${s.id}`,variant:"destructive",onClick:m,children:[e.jsx(Y,{className:"h-4 w-4"}),a("common.delete")]})]})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(O,{variant:"outline",className:"text-[11px] font-normal",children:s.type==="local"?a("device.typeLocal"):a("device.typeSSHBadge")}),s.session&&e.jsx(O,{variant:"outline",className:"text-[11px] font-normal",children:s.session}),e.jsx(ge,{deviceId:s.id})]})]}),e.jsxs(E,{className:"pt-0",children:[e.jsx(fe,{className:"mb-2"}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(we,{to:`/devices/${s.id}`,"data-testid":`device-card-connect-${s.id}`,className:Ne({variant:"default",size:"sm"}),children:a("device.connect")})})]})]})}function J({mode:s,device:c,onClose:m}){const{t:a}=N(),y=Z(),[n,o]=j.useState(ke(c)),[l,d]=j.useState(!1),u=s==="edit",P=n.type==="ssh",D=M({mutationFn:async t=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok)throw new Error(await U(i,a("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(a("common.success")),m()},onError:t=>{v.error(t instanceof Error?t.message:a("common.error"))}}),C=M({mutationFn:async t=>{if(!c)throw new Error(a("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${c.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok)throw new Error(await U(i,a("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(a("common.success")),m()},onError:t=>{v.error(t instanceof Error?t.message:a("common.error"))}}),b=async t=>{t.preventDefault(),d(!0);try{s==="create"?await D.mutateAsync(Ae(n)):await C.mutateAsync(Te(n))}catch{}finally{d(!1)}},r=`${s}-device-name`,K=`${s}-device-type`,k=`${s}-device-host`,A=`${s}-device-port`,T=`${s}-device-username`,F=`${s}-device-session`,H=`${s}-device-auth-mode`,R=`${s}-device-password`,L=`${s}-device-private-key`,q=`${s}-device-private-key-passphrase`,_={local:a("device.typeLocal"),ssh:a("device.typeSSH")},X={password:a("device.authPassword"),key:a("device.authKey"),agent:a("device.authAgent"),configRef:"SSH Config"},I=t=>e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),h=(t,i,f)=>e.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:t,children:[i,f&&e.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return e.jsx(De,{open:!0,onOpenChange:t=>!t&&m(),children:e.jsxs(Ce,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[e.jsxs(be,{children:[e.jsx(Se,{children:a(u?"device.editDevice":"device.addDevice")}),e.jsx(Ee,{children:a(u?"device.editDeviceDescription":"device.addDeviceDescription")})]}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"-mr-2 max-h-[min(70vh,720px)] space-y-5 overflow-y-auto pr-2",children:[e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionBasic")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(r,a("device.name"),!0),e.jsx(x,{id:r,"data-testid":"device-name-input",type:"text",value:n.name,onChange:t=>o(i=>({...i,name:t.target.value})),placeholder:a("device.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(K,a("device.type")),e.jsxs(B,{value:n.type,onValueChange:t=>{if(!t)return;const i=t;o(f=>({...f,type:i,authMode:i==="local"?"auto":f.authMode==="auto"?"password":f.authMode}))},disabled:u,children:[e.jsx(Q,{id:K,"data-testid":"device-type-select",className:"w-full",children:e.jsx(z,{placeholder:a("device.type"),children:t=>_[t]??""})}),e.jsxs(V,{children:[e.jsx(g,{value:"local",children:a("device.typeLocal")}),e.jsx(g,{value:"ssh",children:a("device.typeSSH")})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(F,a("device.session")),e.jsx(x,{id:F,"data-testid":"device-session-input",type:"text",value:n.session,onChange:t=>o(i=>({...i,session:t.target.value})),placeholder:a("device.sessionPlaceholder")})]})]})]}),P&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionConnection")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(k,a("device.host")),e.jsx(x,{id:k,type:"text",value:n.host,onChange:t=>o(i=>({...i,host:t.target.value})),placeholder:a("device.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(A,a("device.port")),e.jsx(x,{id:A,type:"number",value:n.port,onChange:t=>o(i=>({...i,port:Number.parseInt(t.target.value||"22",10)})),min:1,max:65535})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(T,a("device.username")),e.jsx(x,{id:T,type:"text",value:n.username,onChange:t=>o(i=>({...i,username:t.target.value})),placeholder:a("device.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(`${s}-device-ssh-config-ref`,"SSH Config"),e.jsx(x,{id:`${s}-device-ssh-config-ref`,type:"text",value:n.sshConfigRef,onChange:t=>o(i=>({...i,sshConfigRef:t.target.value})),placeholder:"~/.ssh/config"})]})]})]}),e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionAuth")),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[h(H,a("device.authMode")),e.jsxs(B,{value:n.authMode,onValueChange:t=>{t&&o(i=>({...i,authMode:t}))},children:[e.jsx(Q,{id:H,className:"w-full",children:e.jsx(z,{placeholder:a("device.authMode"),children:t=>X[t]??""})}),e.jsxs(V,{children:[e.jsx(g,{value:"password",children:a("device.authPassword")}),e.jsx(g,{value:"key",children:a("device.authKey")}),e.jsx(g,{value:"agent",children:a("device.authAgent")}),e.jsx(g,{value:"configRef",children:"SSH Config"})]})]})]}),n.authMode==="password"&&e.jsxs("div",{className:"space-y-1.5",children:[h(R,a("device.password")),e.jsx(x,{id:R,type:"password",value:n.password,onChange:t=>o(i=>({...i,password:t.target.value}))})]}),n.authMode==="key"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[h(L,a("device.privateKey")),e.jsx(Me,{id:L,value:n.privateKey,onChange:t=>o(i=>({...i,privateKey:t.target.value})),className:"h-28 font-mono text-xs",placeholder:a("device.privateKeyPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(q,a("device.passphrase")),e.jsx(x,{id:q,type:"password",value:n.privateKeyPassphrase,onChange:t=>o(i=>({...i,privateKeyPassphrase:t.target.value}))})]})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:m,children:a("common.cancel")}),e.jsx(w,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:a(l?"common.saving":"common.save")})]})]})]})})}function qe(){const{t:s}=N();return e.jsx(e.Fragment,{children:s("sidebar.manageDevices")})}function Oe(){const{t:s}=N(),c=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:c,"aria-label":s("sidebar.addDevice"),title:s("sidebar.addDevice"),children:e.jsx(W,{className:"h-4 w-4"})})}export{Oe as PageActions,qe as PageTitle,Le as default};
|
|
2
|
-
//# sourceMappingURL=DevicesPage-
|
|
1
|
+
import{u as N,r as j,a as Z,C as ee,M as se,b as M,j as e,N as G,B as w,P as W,A as ae,q as te,s as ie,O as ne,T as Y,v as re,w as ce,x as oe,y as de,z as le,Q as me,t as v,R as he,U as pe,V as ue,W as xe,Y as $,p as ve,Z as ye,_ as je,o as O,$ as ge,a0 as fe,a1 as we,a2 as Ne,D as De,d as Ce,e as be,f as Se,g as Ee,I as x,S as B,h as Q,i as z,k as V,l as g,a3 as Me,m as Pe}from"./index-mf4NroE4.js";import{C as S,c as E,a as Ke,b as Ie,d as $e}from"./card-DzykTTqt.js";function p(s){const c=s.trim();return c||void 0}function ke(s){return s?{name:s.name,type:s.type,host:s.host??"",port:s.port??22,username:s.username??"",sshConfigRef:s.sshConfigRef??"",session:s.session??"tmex",authMode:s.type==="local"?"auto":s.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"",sshConfigRef:"",session:"tmex",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Ae(s){if(s.type==="local")return{name:s.name.trim(),type:"local",session:p(s.session)??"tmex",authMode:"auto"};const c={name:s.name.trim(),type:"ssh",host:p(s.host),port:s.port,username:p(s.username),sshConfigRef:p(s.sshConfigRef),session:p(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&(c.password=s.password),s.authMode==="key"&&(c.privateKey=s.privateKey,c.privateKeyPassphrase=s.privateKeyPassphrase||void 0),c}function Te(s){if(s.type==="local")return{name:s.name.trim(),session:p(s.session)??"tmex",authMode:"auto"};const c={name:s.name.trim(),host:p(s.host),port:s.port,username:p(s.username),sshConfigRef:p(s.sshConfigRef),session:p(s.session)??"tmex",authMode:s.authMode};return s.authMode==="password"&&s.password&&(c.password=s.password),s.authMode==="key"&&s.privateKey&&(c.privateKey=s.privateKey,c.privateKeyPassphrase=s.privateKeyPassphrase||void 0),c}async function U(s,c){try{return(await s.json()).error??c}catch{return c}}function Le(){const{t:s}=N(),[c,m]=j.useState(!1),[a,y]=j.useState(null),[n,o]=j.useState(null),l=Z();j.useEffect(()=>{const r=()=>m(!0);return window.addEventListener("tmex:open-add-device",r),()=>window.removeEventListener("tmex:open-add-device",r)},[]);const{data:d,isLoading:u,isError:P}=ee({queryKey:["devices"],queryFn:async()=>{const r=await fetch("/api/devices");if(!r.ok)throw new Error(s("device.loadFailed"));return r.json()},throwOnError:!1}),D=se(r=>r.hydrateDeviceErrors);j.useEffect(()=>{d!=null&&d.devices&&D(d.devices.map(r=>({deviceId:r.id,lastError:r.lastError??null,lastErrorType:r.lastErrorType??null})))},[d,D]);const C=M({mutationFn:async r=>{if(!(await fetch(`/api/devices/${r}`,{method:"DELETE"})).ok)throw new Error(s("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),v.success(s("common.success"))},onError:r=>{v.error(r instanceof Error?r.message:s("common.error"))}}),b=(d==null?void 0:d.devices)??[];return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[u?e.jsx(S,{children:e.jsx(E,{className:"py-16 text-center text-sm text-muted-foreground",children:s("common.loading")})}):P?e.jsx(S,{children:e.jsx(E,{className:"py-16 text-center text-sm text-destructive",children:s("device.loadFailed")})}):b.length===0?e.jsx(S,{children:e.jsxs(E,{className:"space-y-4 py-14 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:e.jsx(G,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-medium",children:s("device.noDevices")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("device.addDevice")})]}),e.jsxs(w,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[e.jsx(W,{className:"h-4 w-4"}),s("device.addDevice")]})]})}):e.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:b.map(r=>e.jsx(Fe,{device:r,onEdit:()=>y(r),onDelete:()=>o(r)},r.id))}),c&&e.jsx(J,{mode:"create",onClose:()=>m(!1)}),a&&e.jsx(J,{mode:"edit",device:a,onClose:()=>y(null)}),e.jsx(ae,{open:n!==null,onOpenChange:r=>!r&&o(null),children:e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(ne,{className:"bg-destructive/10",children:e.jsx(Y,{className:"h-5 w-5 text-destructive"})}),e.jsx(re,{children:s("device.deleteConfirm")}),e.jsx(ce,{children:s("device.deleteDescription",{name:(n==null?void 0:n.name)??""})})]}),e.jsxs(oe,{children:[e.jsx(de,{children:s("common.cancel")}),e.jsx(le,{variant:"destructive",disabled:!n||C.isPending,onClick:()=>{n&&(C.mutate(n.id),o(null))},children:s("common.delete")})]})]})})]})}function Fe({device:s,onEdit:c,onDelete:m}){const{t:a}=N(),y=s.type==="local"?e.jsx(G,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"}),n=s.type==="local"?a("device.typeLocal"):`${s.username??"-"}@${s.host??"-"}:${s.port??22}`,o=M({mutationFn:async()=>{const l=await fetch(`/api/devices/${s.id}/test-connection`,{method:"POST"});let d=null;try{d=await l.json()}catch{d=null}if(!l.ok){const u=d;throw new Error((u==null?void 0:u.error)??a("common.error"))}return d},onSuccess:l=>{v.success(l.message??a("common.success"))},onError:l=>{v.error(l instanceof Error?l.message:a("common.error"))}});return e.jsxs(S,{"data-testid":"device-card","data-device-id":s.id,"data-device-name":s.name,className:"overflow-hidden",children:[e.jsxs(Ke,{className:"space-y-2 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx(Ie,{className:"line-clamp-1 text-sm",title:s.name,children:s.name}),e.jsx($e,{className:"line-clamp-1 text-xs",children:n})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e.jsxs(he,{children:[e.jsx(pe,{render:e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${s.id}`,"aria-label":a("common.edit"),title:a("common.edit")}),children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsxs(xe,{align:"end",children:[e.jsxs($,{"data-testid":`device-card-edit-${s.id}`,onClick:c,children:[e.jsx(ve,{className:"h-4 w-4"}),a("common.edit")]}),s.type==="ssh"&&e.jsxs($,{"data-testid":`device-card-test-${s.id}`,onClick:()=>o.mutate(),disabled:o.isPending,children:[e.jsx(ye,{className:"h-4 w-4"}),a("common.test")]}),e.jsx(je,{}),e.jsxs($,{"data-testid":`device-card-delete-${s.id}`,variant:"destructive",onClick:m,children:[e.jsx(Y,{className:"h-4 w-4"}),a("common.delete")]})]})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(O,{variant:"outline",className:"text-[11px] font-normal",children:s.type==="local"?a("device.typeLocal"):a("device.typeSSHBadge")}),s.session&&e.jsx(O,{variant:"outline",className:"text-[11px] font-normal",children:s.session}),e.jsx(ge,{deviceId:s.id})]})]}),e.jsxs(E,{className:"pt-0",children:[e.jsx(fe,{className:"mb-2"}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(we,{to:`/devices/${s.id}`,"data-testid":`device-card-connect-${s.id}`,className:Ne({variant:"default",size:"sm"}),children:a("device.connect")})})]})]})}function J({mode:s,device:c,onClose:m}){const{t:a}=N(),y=Z(),[n,o]=j.useState(ke(c)),[l,d]=j.useState(!1),u=s==="edit",P=n.type==="ssh",D=M({mutationFn:async t=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok)throw new Error(await U(i,a("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(a("common.success")),m()},onError:t=>{v.error(t instanceof Error?t.message:a("common.error"))}}),C=M({mutationFn:async t=>{if(!c)throw new Error(a("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${c.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok)throw new Error(await U(i,a("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),v.success(a("common.success")),m()},onError:t=>{v.error(t instanceof Error?t.message:a("common.error"))}}),b=async t=>{t.preventDefault(),d(!0);try{s==="create"?await D.mutateAsync(Ae(n)):await C.mutateAsync(Te(n))}catch{}finally{d(!1)}},r=`${s}-device-name`,K=`${s}-device-type`,k=`${s}-device-host`,A=`${s}-device-port`,T=`${s}-device-username`,F=`${s}-device-session`,H=`${s}-device-auth-mode`,R=`${s}-device-password`,L=`${s}-device-private-key`,q=`${s}-device-private-key-passphrase`,_={local:a("device.typeLocal"),ssh:a("device.typeSSH")},X={password:a("device.authPassword"),key:a("device.authKey"),agent:a("device.authAgent"),configRef:"SSH Config"},I=t=>e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),h=(t,i,f)=>e.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:t,children:[i,f&&e.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return e.jsx(De,{open:!0,onOpenChange:t=>!t&&m(),children:e.jsxs(Ce,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[e.jsxs(be,{children:[e.jsx(Se,{children:a(u?"device.editDevice":"device.addDevice")}),e.jsx(Ee,{children:a(u?"device.editDeviceDescription":"device.addDeviceDescription")})]}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"-mr-2 max-h-[min(70vh,720px)] space-y-5 overflow-y-auto pr-2",children:[e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionBasic")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(r,a("device.name"),!0),e.jsx(x,{id:r,"data-testid":"device-name-input",type:"text",value:n.name,onChange:t=>o(i=>({...i,name:t.target.value})),placeholder:a("device.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(K,a("device.type")),e.jsxs(B,{value:n.type,onValueChange:t=>{if(!t)return;const i=t;o(f=>({...f,type:i,authMode:i==="local"?"auto":f.authMode==="auto"?"password":f.authMode}))},disabled:u,children:[e.jsx(Q,{id:K,"data-testid":"device-type-select",className:"w-full",children:e.jsx(z,{placeholder:a("device.type"),children:t=>_[t]??""})}),e.jsxs(V,{children:[e.jsx(g,{value:"local",children:a("device.typeLocal")}),e.jsx(g,{value:"ssh",children:a("device.typeSSH")})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(F,a("device.session")),e.jsx(x,{id:F,"data-testid":"device-session-input",type:"text",value:n.session,onChange:t=>o(i=>({...i,session:t.target.value})),placeholder:a("device.sessionPlaceholder")})]})]})]}),P&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionConnection")),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(k,a("device.host")),e.jsx(x,{id:k,type:"text",value:n.host,onChange:t=>o(i=>({...i,host:t.target.value})),placeholder:a("device.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(A,a("device.port")),e.jsx(x,{id:A,type:"number",value:n.port,onChange:t=>o(i=>({...i,port:Number.parseInt(t.target.value||"22",10)})),min:1,max:65535})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[h(T,a("device.username")),e.jsx(x,{id:T,type:"text",value:n.username,onChange:t=>o(i=>({...i,username:t.target.value})),placeholder:a("device.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(`${s}-device-ssh-config-ref`,"SSH Config"),e.jsx(x,{id:`${s}-device-ssh-config-ref`,type:"text",value:n.sshConfigRef,onChange:t=>o(i=>({...i,sshConfigRef:t.target.value})),placeholder:"~/.ssh/config"})]})]})]}),e.jsxs("section",{className:"space-y-2.5",children:[I(a("device.sectionAuth")),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[h(H,a("device.authMode")),e.jsxs(B,{value:n.authMode,onValueChange:t=>{t&&o(i=>({...i,authMode:t}))},children:[e.jsx(Q,{id:H,className:"w-full",children:e.jsx(z,{placeholder:a("device.authMode"),children:t=>X[t]??""})}),e.jsxs(V,{children:[e.jsx(g,{value:"password",children:a("device.authPassword")}),e.jsx(g,{value:"key",children:a("device.authKey")}),e.jsx(g,{value:"agent",children:a("device.authAgent")}),e.jsx(g,{value:"configRef",children:"SSH Config"})]})]})]}),n.authMode==="password"&&e.jsxs("div",{className:"space-y-1.5",children:[h(R,a("device.password")),e.jsx(x,{id:R,type:"password",value:n.password,onChange:t=>o(i=>({...i,password:t.target.value}))})]}),n.authMode==="key"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[h(L,a("device.privateKey")),e.jsx(Me,{id:L,value:n.privateKey,onChange:t=>o(i=>({...i,privateKey:t.target.value})),className:"h-28 font-mono text-xs",placeholder:a("device.privateKeyPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[h(q,a("device.passphrase")),e.jsx(x,{id:q,type:"password",value:n.privateKeyPassphrase,onChange:t=>o(i=>({...i,privateKeyPassphrase:t.target.value}))})]})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:m,children:a("common.cancel")}),e.jsx(w,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:a(l?"common.saving":"common.save")})]})]})]})})}function qe(){const{t:s}=N();return e.jsx(e.Fragment,{children:s("sidebar.manageDevices")})}function Oe(){const{t:s}=N(),c=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:c,"aria-label":s("sidebar.addDevice"),title:s("sidebar.addDevice"),children:e.jsx(W,{className:"h-4 w-4"})})}export{Oe as PageActions,qe as PageTitle,Le as default};
|
|
2
|
+
//# sourceMappingURL=DevicesPage-CRK5IQTj.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as V,u as K,a as O,r as c,b as v,t as h,j as e,D as Qe,d as Ue,e as He,f as Ve,g as Je,I as C,S as J,h as W,i as G,k as Z,l as Q,m as We,B as y,L,P as Ge,n as A,o as Ze,X as rs,p as os,T as X,A as he,q as ue,s as ge,v as xe,w as pe,x as fe,y as je,z as ye,C as R,E as Xe,F as Ie,G as Re,H as Ye,J as cs,K as ds}from"./index-
|
|
1
|
+
import{c as V,u as K,a as O,r as c,b as v,t as h,j as e,D as Qe,d as Ue,e as He,f as Ve,g as Je,I as C,S as J,h as W,i as G,k as Z,l as Q,m as We,B as y,L,P as Ge,n as A,o as Ze,X as rs,p as os,T as X,A as he,q as ue,s as ge,v as xe,w as pe,x as fe,y as je,z as ye,C as R,E as Xe,F as Ie,G as Re,H as Ye,J as cs,K as ds}from"./index-mf4NroE4.js";import{C as q,a as D,b as _,c as I}from"./card-DzykTTqt.js";import{R as ms}from"./refresh-cw-DaPtMs2v.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -19,4 +19,4 @@ import{c as V,u as K,a as O,r as c,b as v,t as h,j as e,D as Qe,d as Ue,e as He,
|
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
21
|
*/const fs=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Le=V("shield",fs);async function B(s,i){try{return(await s.json()).error??i}catch{return i}}const js=["openai-chat","openai-responses"],H="h-9 w-full";function ys({open:s,onOpenChange:i,provider:n}){const{t:a}=K(),d=O(),u=!!n,[w,p]=c.useState(""),[l,x]=c.useState(""),[f,m]=c.useState("openai-chat"),[j,b]=c.useState("");c.useEffect(()=>{s&&(p((n==null?void 0:n.name)??""),x((n==null?void 0:n.baseUrl)??""),m((n==null?void 0:n.protocol)??"openai-chat"),b(""))},[s,n]);const N=v({mutationFn:async()=>{const g={name:w.trim(),protocol:f,baseUrl:l.trim(),apiKey:j.trim(),enabled:!0},M=await fetch("/api/llm/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!M.ok)throw new Error(await B(M,a("settings.llm.createFailed")));return await M.json()},onSuccess:async g=>{await d.invalidateQueries({queryKey:["llm-providers"]}),g.modelsError?h.warning(a("settings.llm.modelsFetchFailed",{error:g.modelsError})):h.success(a("common.success")),i(!1)},onError:g=>{h.error(g instanceof Error?g.message:a("common.error"))}}),T=v({mutationFn:async()=>{if(!n)throw new Error(a("settings.llm.updateFailed"));const g={name:w.trim(),baseUrl:l.trim(),protocol:f};j.trim()&&(g.apiKey=j.trim());const M=await fetch(`/api/llm/providers/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!M.ok)throw new Error(await B(M,a("settings.llm.updateFailed")));return await M.json()},onSuccess:async g=>{await d.invalidateQueries({queryKey:["llm-providers"]}),g.modelsError?h.warning(a("settings.llm.modelsFetchFailed",{error:g.modelsError})):h.success(a("common.success")),i(!1)},onError:g=>{h.error(g instanceof Error?g.message:a("common.error"))}}),E=N.isPending||T.isPending,r=w.trim().length>0&&l.trim().length>0&&(u||j.trim().length>0),P=()=>{!r||E||(u?T.mutate():N.mutate())};return e.jsx(Qe,{open:s,onOpenChange:i,children:e.jsxs(Ue,{className:"sm:max-w-lg","data-testid":u?`llm-provider-edit-modal-${n==null?void 0:n.id}`:"llm-provider-add-modal",children:[e.jsxs(He,{children:[e.jsx(Ve,{children:a(u?"settings.llm.editProvider":"settings.llm.addProvider")}),e.jsx(Je,{children:a("settings.llm.formHint")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-name",children:a("settings.llm.name")}),e.jsx(C,{id:"llm-form-name","data-testid":"llm-provider-name-input",value:w,onChange:g=>p(g.target.value),placeholder:a("settings.llm.namePlaceholder"),className:H})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-baseurl",children:a("settings.llm.baseUrl")}),e.jsx(C,{id:"llm-form-baseurl","data-testid":"llm-provider-baseurl-input",value:l,onChange:g=>x(g.target.value),placeholder:a("settings.llm.baseUrlPlaceholder"),className:H}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.llm.baseUrlHint")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-protocol",children:a("settings.llm.protocol")}),e.jsxs(J,{value:f,onValueChange:g=>{g&&m(g)},children:[e.jsx(W,{id:"llm-form-protocol","data-testid":"llm-provider-protocol-select",className:H,children:e.jsx(G,{})}),e.jsx(Z,{children:js.map(g=>e.jsx(Q,{value:g,children:g},g))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-apikey",children:a("settings.llm.apiKey")}),e.jsx(C,{id:"llm-form-apikey","data-testid":"llm-provider-apikey-input","data-key-set":n!=null&&n.hasApiKey?"true":"false",type:"password",value:j,onChange:g=>b(g.target.value),placeholder:n!=null&&n.hasApiKey?a("settings.llm.apiKeySetPlaceholder"):a("settings.llm.apiKeyPlaceholder"),className:H})]})]}),e.jsxs(We,{children:[e.jsx(y,{variant:"outline",onClick:()=>i(!1),disabled:E,children:a("common.cancel")}),e.jsxs(y,{"data-testid":"llm-provider-form-submit",onClick:P,disabled:!r||E,children:[E?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),a("common.save")]})]})]})})}function ws({models:s,onChange:i}){const{t:n}=K(),[a,d]=c.useState(""),u=(l,x)=>{i(s.map(f=>f.id===l?{...f,enabled:x}:f))},w=l=>{i(s.filter(x=>x.id!==l))},p=()=>{const l=a.trim();if(l){if(s.some(x=>x.id===l)){d("");return}i([...s,{id:l,source:"manual",enabled:!0}]),d("")}};return e.jsxs("div",{className:"space-y-3","data-testid":"llm-provider-models",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{value:a,onChange:l=>d(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),p())},placeholder:n("settings.llm.addModelPlaceholder"),className:"h-9","data-testid":"llm-provider-add-model-input"}),e.jsxs(y,{type:"button",variant:"outline",size:"lg",onClick:p,disabled:!a.trim(),"data-testid":"llm-provider-add-model",children:[e.jsx(Ge,{className:"h-4 w-4"}),n("common.add")]})]}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.llm.modelsNotFetched")}):e.jsx("ul",{className:"max-h-56 space-y-1 overflow-y-auto rounded-lg border border-border bg-background p-2",children:s.map(l=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-md px-2 py-1.5","data-testid":`llm-provider-model-${l.id}`,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(A,{checked:l.enabled,onCheckedChange:x=>u(l.id,!!x),"data-testid":`llm-provider-model-toggle-${l.id}`}),e.jsx("span",{className:"truncate font-mono text-xs",children:l.id}),l.source==="manual"&&e.jsx(Ze,{variant:"secondary",children:n("settings.llm.modelManual")})]}),l.source==="manual"&&e.jsx(y,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>w(l.id),"data-testid":`llm-provider-model-remove-${l.id}`,children:e.jsx(rs,{className:"h-4 w-4"})})]},l.id))})]})}function bs(s){return s.modelDetails.map(i=>({id:i.id,source:i.source,enabled:i.enabled}))}function vs({open:s,onOpenChange:i,provider:n}){const{t:a}=K(),d=O(),[u,w]=c.useState([]);c.useEffect(()=>{s&&w(bs(n))},[s,n]);const p=v({mutationFn:async()=>{const l=u.filter(j=>j.source==="manual").map(j=>j.id),x=u.filter(j=>!j.enabled).map(j=>j.id),f={manualModels:l,disabledModels:x},m=await fetch(`/api/llm/providers/${n.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!m.ok)throw new Error(await B(m,a("settings.llm.updateFailed")));return await m.json()},onSuccess:async l=>{await d.invalidateQueries({queryKey:["llm-providers"]}),l.modelsError?h.warning(a("settings.llm.modelsFetchFailed",{error:l.modelsError})):h.success(a("common.success")),i(!1)},onError:l=>{h.error(l instanceof Error?l.message:a("common.error"))}});return e.jsx(Qe,{open:s,onOpenChange:i,children:e.jsxs(Ue,{className:"sm:max-w-lg","data-testid":`llm-provider-models-modal-${n.id}`,children:[e.jsxs(He,{children:[e.jsx(Ve,{children:a("settings.llm.modelsTitle",{name:n.name})}),e.jsx(Je,{children:a("settings.llm.modelsHint")})]}),e.jsx(ws,{models:u,onChange:w}),e.jsxs(We,{children:[e.jsx(y,{variant:"outline",onClick:()=>i(!1),disabled:p.isPending,children:a("common.cancel")}),e.jsxs(y,{"data-testid":`llm-provider-models-save-${n.id}`,onClick:()=>p.mutate(),disabled:p.isPending,children:[p.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),a("common.save")]})]})]})})}function Ns(s){try{const i=new URL(s);return`${i.protocol}//${i.host}${i.pathname==="/"?"":i.pathname}`}catch{return s}}function ks({provider:s,onEdit:i}){const{t:n}=K(),a=O(),[d,u]=c.useState(!1),[w,p]=c.useState(!1),l=v({mutationFn:async m=>{const j=await fetch(`/api/llm/providers/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:m})});if(!j.ok)throw new Error(await B(j,n("settings.llm.updateFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]})},onError:m=>{h.error(m instanceof Error?m.message:n("common.error"))}}),x=v({mutationFn:async()=>{const m=await fetch(`/api/llm/providers/${s.id}/refresh-models`,{method:"POST"});if(!m.ok)throw new Error(await B(m,n("settings.llm.refreshModelsFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]}),h.success(n("common.success"))},onError:m=>{h.error(m instanceof Error?m.message:n("common.error"))}}),f=v({mutationFn:async()=>{const m=await fetch(`/api/llm/providers/${s.id}`,{method:"DELETE"});if(!m.ok)throw new Error(await B(m,n("settings.llm.deleteFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]}),await a.invalidateQueries({queryKey:["llm-settings"]}),h.success(n("common.success"))},onError:m=>{h.error(m instanceof Error?m.message:n("common.error"))}});return e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3 sm:flex-row sm:items-center sm:justify-between","data-testid":`llm-provider-row-${s.id}`,"data-provider-name":s.name,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(A,{checked:s.enabled,disabled:l.isPending,onCheckedChange:m=>l.mutate(!!m),"data-testid":`llm-provider-enabled-${s.id}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium",children:s.name}),e.jsx(Ze,{variant:"outline",children:s.protocol})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"truncate font-mono",children:Ns(s.baseUrl)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"whitespace-nowrap",children:n("settings.llm.modelsCount",{total:s.models.length})})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(y,{variant:"ghost",size:"icon-sm",title:n("settings.llm.refreshModels"),"data-testid":`llm-provider-refresh-models-${s.id}`,onClick:()=>x.mutate(),disabled:x.isPending,children:x.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx(ms,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",size:"icon-sm",title:n("settings.llm.models"),"data-testid":`llm-provider-models-${s.id}`,onClick:()=>p(!0),children:e.jsx(us,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",size:"icon-sm",title:n("common.edit"),"data-testid":`llm-provider-edit-${s.id}`,onClick:()=>i(s),children:e.jsx(os,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",size:"icon-sm",title:n("common.delete"),"data-testid":`llm-provider-delete-${s.id}`,onClick:()=>u(!0),disabled:f.isPending,children:e.jsx(X,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(vs,{open:w,onOpenChange:p,provider:s}),e.jsx(he,{open:d,onOpenChange:u,children:e.jsxs(ue,{children:[e.jsxs(ge,{children:[e.jsx(xe,{children:n("settings.llm.deleteProvider")}),e.jsx(pe,{children:n("settings.llm.deleteConfirm",{name:s.name})})]}),e.jsxs(fe,{children:[e.jsx(je,{onClick:()=>u(!1),children:n("common.cancel")}),e.jsx(ye,{variant:"destructive","data-testid":`llm-provider-delete-confirm-${s.id}`,onClick:()=>{f.mutate(),u(!1)},children:n("common.confirm")})]})]})})]})}function Cs(){var x;const{t:s}=K(),[i,n]=c.useState(!1),[a,d]=c.useState(void 0),u=R({queryKey:["llm-providers"],queryFn:async()=>{const f=await fetch("/api/llm/providers");if(!f.ok)throw new Error(await B(f,s("settings.llm.loadFailed")));return await f.json()}}),w=((x=u.data)==null?void 0:x.providers)??[],p=()=>{d(void 0),n(!0)},l=f=>{d(f),n(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(q,{className:"border-0 ring-0","data-testid":"llm-providers-section",children:[e.jsxs(D,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsx(_,{children:s("settings.llm.title")}),e.jsxs(y,{"data-testid":"llm-provider-add",onClick:p,children:[e.jsx(Ge,{className:"h-4 w-4"}),s("settings.llm.addProvider")]})]}),e.jsxs(I,{className:"space-y-3",children:[u.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!u.isLoading&&w.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"llm-providers-empty",children:s("settings.llm.empty")}),w.map(f=>e.jsx(ks,{provider:f,onEdit:l},f.id))]})]}),e.jsx(ys,{open:i,onOpenChange:n,provider:a}),e.jsx(Ss,{providers:w})]})}const ce="__none__";function Ss({providers:s}){var T,E;const{t:i}=K(),n=O(),[a,d]=c.useState(null),[u,w]=c.useState(""),p=R({queryKey:["llm-settings"],queryFn:async()=>{const r=await fetch("/api/llm/settings");if(!r.ok)throw new Error(await B(r,i("settings.llm.settingsLoadFailed")));return await r.json()}}),l=((T=p.data)==null?void 0:T.settings.defaultProviderId)??null,x=((E=p.data)==null?void 0:E.settings.defaultModelId)??"",f=!!p.data;c.useEffect(()=>{f&&(d(l),w(x))},[f,l,x]);const m=v({mutationFn:async()=>{const r={defaultProviderId:a,defaultModelId:u.trim()||null},P=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!P.ok)throw new Error(await B(P,i("settings.llm.settingsSaveFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["llm-settings"]}),h.success(i("common.success"))},onError:r=>{h.error(r instanceof Error?r.message:i("common.error"))}}),j=s.filter(r=>r.enabled),b=s.find(r=>r.id===a),N=(b==null?void 0:b.models)??[];return e.jsxs(q,{className:"border-0 ring-0","data-testid":"llm-defaults-section",children:[e.jsx(D,{children:e.jsx(_,{children:i("settings.llm.defaults")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-default-provider-select",children:i("settings.llm.defaultProvider")}),e.jsxs(J,{value:a??ce,onValueChange:r=>{r&&d(r===ce?null:r)},children:[e.jsx(W,{id:"llm-default-provider-select","data-testid":"llm-default-provider-select",className:"h-9 w-full",children:e.jsx(G,{children:(b==null?void 0:b.name)??i("settings.llm.defaultProviderNone")})}),e.jsxs(Z,{children:[e.jsx(Q,{value:ce,children:i("settings.llm.defaultProviderNone")}),j.map(r=>e.jsx(Q,{value:r.id,children:r.name},r.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-default-model-input",children:i("settings.llm.defaultModel")}),e.jsx(C,{id:"llm-default-model-input","data-testid":"llm-default-model-input",list:"llm-default-model-options",value:u,onChange:r=>w(r.target.value),placeholder:i("settings.llm.defaultModelPlaceholder"),className:"h-9"}),e.jsx("datalist",{id:"llm-default-model-options",children:N.map(r=>e.jsx("option",{value:r},r))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(y,{variant:"default","data-testid":"llm-defaults-save",onClick:()=>m.mutate(),disabled:m.isPending||p.isLoading,className:"w-full sm:w-auto",children:[m.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),i("settings.llm.saveDefaults")]})})]})]})}const Es=["none","tavily","brave"];async function de(s,i){try{return(await s.json()).error??i}catch{return i}}function Ps(){var E;const{t:s}=K(),i=O(),[n,a]=c.useState("none"),[d,u]=c.useState(""),[w,p]=c.useState(""),[l,x]=c.useState(null),f=R({queryKey:["llm-settings"],queryFn:async()=>{const r=await fetch("/api/llm/settings");if(!r.ok)throw new Error(await de(r,s("settings.search.loadFailed")));return await r.json()}}),m=(E=f.data)==null?void 0:E.settings,j=m==null?void 0:m.searchProvider;c.useEffect(()=>{j&&a(j)},[j]);const b=v({mutationFn:async()=>{const r={searchProvider:n};d.trim()&&(r.tavilyApiKey=d.trim()),w.trim()&&(r.braveApiKey=w.trim());const P=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!P.ok)throw new Error(await de(P,s("settings.search.saveFailed")))},onSuccess:async()=>{u(""),p(""),await i.invalidateQueries({queryKey:["llm-settings"]}),h.success(s("common.success"))},onError:r=>{h.error(r instanceof Error?r.message:s("common.error"))}}),N=v({mutationFn:async r=>{const P={[r]:""},g=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)});if(!g.ok)throw new Error(await de(g,s("settings.search.saveFailed")))},onSuccess:async()=>{await i.invalidateQueries({queryKey:["llm-settings"]}),h.success(s("common.success"))},onError:r=>{h.error(r instanceof Error?r.message:s("common.error"))}}),T=r=>r==="none"?s("settings.search.providerNone"):r==="tavily"?"Tavily":"Brave";return e.jsxs(q,{className:"border-0 ring-0","data-testid":"settings-search-section",children:[e.jsx(D,{children:e.jsx(_,{children:s("settings.search.title")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"search-provider-select",children:s("settings.search.provider")}),e.jsxs(J,{value:n,onValueChange:r=>{r&&a(r)},children:[e.jsx(W,{id:"search-provider-select","data-testid":"settings-search-provider-select",className:"w-full min-h-10",children:e.jsx(G,{children:T(n)})}),e.jsx(Z,{children:Es.map(r=>e.jsx(Q,{value:r,children:T(r)},r))})]})]}),e.jsx(Oe,{id:"search-tavily-key-input",testId:"settings-search-tavily",label:s("settings.search.tavilyApiKey"),value:d,hasKey:(m==null?void 0:m.hasTavilyApiKey)??!1,onChange:u,onClear:()=>x("tavilyApiKey"),clearing:N.isPending&&N.variables==="tavilyApiKey"}),e.jsx(Oe,{id:"search-brave-key-input",testId:"settings-search-brave",label:s("settings.search.braveApiKey"),value:w,hasKey:(m==null?void 0:m.hasBraveApiKey)??!1,onChange:p,onClear:()=>x("braveApiKey"),clearing:N.isPending&&N.variables==="braveApiKey"}),e.jsx(he,{open:l!==null,onOpenChange:r=>{r||x(null)},children:e.jsxs(ue,{children:[e.jsxs(ge,{children:[e.jsx(xe,{children:s("settings.search.clearKey")}),e.jsx(pe,{children:s("settings.search.clearKeyConfirm")})]}),e.jsxs(fe,{children:[e.jsx(je,{children:s("common.cancel")}),e.jsx(ye,{"data-testid":"settings-search-clear-confirm",onClick:()=>{l&&N.mutate(l),x(null)},children:s("settings.search.clearKey")})]})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(y,{variant:"default","data-testid":"settings-search-save",onClick:()=>b.mutate(),disabled:b.isPending||f.isLoading,className:"w-full sm:w-auto",children:[b.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),s("common.save")]})})]})]})}function Oe({id:s,testId:i,label:n,value:a,hasKey:d,onChange:u,onClear:w,clearing:p}){const{t:l}=K();return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:s,children:n}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{id:s,"data-testid":`${i}-input`,"data-key-set":d?"true":"false",type:"password",value:a,onChange:x=>u(x.target.value),placeholder:l(d?"settings.search.keySetPlaceholder":"settings.search.keyPlaceholder"),className:"min-h-10"}),d&&e.jsxs(y,{variant:"outline",size:"sm","data-testid":`${i}-clear`,onClick:w,disabled:p,className:"shrink-0",children:[e.jsx(X,{className:"h-4 w-4"}),l("settings.search.clearKey")]})]})]})}const me=["terminal_bell","terminal_notification","tmux_window_close","tmux_pane_close","device_tmux_missing","device_disconnect","session_created","session_closed","agent_confirmation_pending","agent_turn_finished","agent_error","watch_triggered","watch_model_unavailable","watch_rule_error"];async function F(s,i){try{return(await s.json()).error??i}catch{return i}}function As(){var $e,qe,De,_e;const{t:s}=K(),i=O(),{refreshSettings:n}=Xe(),[a,d]=c.useState("site"),u=Ie(t=>t.theme),w=Ie(t=>t.setTheme),p=u==="dark",[l,x]=c.useState("tmex"),[f,m]=c.useState(window.location.origin),[j,b]=c.useState("en_US"),[N,T]=c.useState(6),[E,r]=c.useState(3),[P,g]=c.useState(!0),[M,o]=c.useState(!0),[S,z]=c.useState(!0),[we,be]=c.useState(!0),[ve,Ne]=c.useState(2),[ke,Ce]=c.useState(10),[es,ss]=c.useState(!1),[Y,Se]=c.useState(""),[ee,Ee]=c.useState(""),[ts,as]=c.useState(null),[se,Pe]=c.useState(""),[te,Fe]=c.useState(""),[ae,Te]=c.useState(me),ns=t=>{const k=t?"dark":"light";w(k),document.documentElement.classList.toggle("dark",k==="dark")},ne=R({queryKey:["site-settings"],queryFn:async()=>{const t=await fetch("/api/settings/site");if(!t.ok)throw new Error(await F(t,s("settings.loadFailed")));return await t.json()}}),ie=R({queryKey:["telegram-bots"],queryFn:async()=>{const t=await fetch("/api/settings/telegram/bots");if(!t.ok)throw new Error(await F(t,s("telegram.loadBotsFailed")));return await t.json()}});c.useEffect(()=>{var k;const t=(k=ne.data)==null?void 0:k.settings;t&&(x(t.siteName),m(t.siteUrl),b(t.language??"en_US"),T(t.bellThrottleSeconds),r(t.notificationThrottleSeconds??3),g(t.enableBrowserBellToast??!0),o(t.enableBrowserNotificationToast??!0),z(t.enableTelegramBellPush??!0),be(t.enableTelegramNotificationPush??!0),Ne(t.sshReconnectMaxRetries),Ce(t.sshReconnectDelaySeconds))},[($e=ne.data)==null?void 0:$e.settings]);const Me=v({mutationFn:async()=>{const k=await fetch("/api/settings/site",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:l,siteUrl:f,language:j,bellThrottleSeconds:N,notificationThrottleSeconds:E,enableBrowserBellToast:P,enableBrowserNotificationToast:M,enableTelegramBellPush:S,enableTelegramNotificationPush:we,sshReconnectMaxRetries:ve,sshReconnectDelaySeconds:ke})});if(!k.ok)throw new Error(await F(k,s("settings.saveFailed")))},onSuccess:async()=>{var t,k;await Promise.all([i.invalidateQueries({queryKey:["site-settings"]}),n()]),h.success(s("settings.settingsSaved")),((k=(t=ne.data)==null?void 0:t.settings)==null?void 0:k.language)!==j&&(cs.changeLanguage(j),ss(!0))},onError:t=>{h.error(t instanceof Error?t.message:s("common.error"))}}),le=v({mutationFn:async()=>{const t=await fetch("/api/settings/telegram/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Y,token:ee,enabled:!0,allowAuthRequests:!0})});if(!t.ok)throw new Error(await F(t,s("telegram.createFailed")))},onSuccess:async()=>{Se(""),Ee(""),await i.invalidateQueries({queryKey:["telegram-bots"]}),h.success(s("common.success"))},onError:t=>{h.error(t instanceof Error?t.message:s("common.error"))}}),Ke=((qe=ie.data)==null?void 0:qe.bots)??[],re=R({queryKey:["webhooks"],queryFn:async()=>{const t=await fetch("/api/webhooks");if(!t.ok)throw new Error(await F(t,s("webhook.loadFailed")));return await t.json()}}),oe=v({mutationFn:async()=>{const t=await fetch("/api/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:se,secret:te,eventMask:ae})});if(!t.ok)throw new Error(await F(t,s("webhook.createFailed")))},onSuccess:async()=>{Pe(""),Fe(""),Te(me),await i.invalidateQueries({queryKey:["webhooks"]}),h.success(s("common.success"))},onError:t=>{h.error(t instanceof Error?t.message:s("common.error"))}}),Ae=v({mutationFn:async t=>{const k=await fetch(`/api/webhooks/${t}`,{method:"DELETE"});if(!k.ok)throw new Error(await F(k,s("webhook.deleteFailed")))},onSuccess:async()=>{await i.invalidateQueries({queryKey:["webhooks"]}),h.success(s("common.success"))},onError:t=>{h.error(t instanceof Error?t.message:s("common.error"))}}),Be=((De=re.data)==null?void 0:De.webhooks)??[];return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-4 p-3 pb-[calc(2rem+env(safe-area-inset-bottom))] sm:gap-6 sm:p-5","data-testid":"settings-page",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:a==="site"?"default":"outline","data-testid":"settings-tab-site",onClick:()=>d("site"),children:s("settings.siteSettings")}),e.jsx(y,{type:"button",size:"sm",variant:a==="notifications"?"default":"outline","data-testid":"settings-tab-notifications",onClick:()=>d("notifications"),children:s("settings.notificationsTab")}),e.jsx(y,{type:"button",size:"sm",variant:a==="telegram"?"default":"outline","data-testid":"settings-tab-telegram",onClick:()=>d("telegram"),children:s("telegram.title")}),e.jsx(y,{type:"button",size:"sm",variant:a==="webhooks"?"default":"outline","data-testid":"settings-tab-webhooks",onClick:()=>d("webhooks"),children:s("webhook.title")}),e.jsx(y,{type:"button",size:"sm",variant:a==="llm"?"default":"outline","data-testid":"settings-tab-llm",onClick:()=>d("llm"),children:s("settings.llm.title")}),e.jsx(y,{type:"button",size:"sm",variant:a==="search"?"default":"outline","data-testid":"settings-tab-search",onClick:()=>d("search"),children:s("settings.search.title")})]}),a==="site"&&e.jsxs(q,{className:"border-0 ring-0",children:[e.jsx(D,{children:e.jsx(_,{children:s("settings.siteSettings")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-name-input",children:s("settings.siteName")}),e.jsx(C,{id:"site-name-input",value:l,onChange:t=>x(t.target.value),placeholder:s("settings.siteNamePlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-url-input",children:s("settings.siteUrl")}),e.jsx(C,{id:"site-url-input",value:f,onChange:t=>m(t.target.value),placeholder:s("settings.siteUrlPlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"language-select",children:s("settings.language")}),e.jsxs(J,{value:j,onValueChange:t=>{t&&b(t)},children:[e.jsx(W,{id:"language-select","data-testid":"settings-language-select",className:"w-full min-h-10",children:e.jsx(G,{placeholder:s("settings.language"),children:((_e=Re.locales.find(t=>t.code===j))==null?void 0:_e.nativeName)??j})}),e.jsx(Z,{className:"max-h-[var(--tmex-viewport-height)]",children:Re.locales.map(t=>e.jsx(Q,{value:t.code,children:t.nativeName},t.code))})]}),es&&e.jsx("p",{className:"mt-1 text-xs text-primary","data-testid":"settings-refresh-notice",children:s("settings.refreshToApply")})]}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.theme")})}),e.jsx(A,{checked:p,onCheckedChange:t=>ns(!!t),"data-testid":"settings-theme-toggle"})]})})]})]}),a==="notifications"&&e.jsxs(q,{className:"border-0 ring-0",children:[e.jsx(D,{children:e.jsx(_,{children:s("settings.notificationsTab")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableBrowserBellToast")})}),e.jsx(A,{checked:P,onCheckedChange:t=>g(!!t),"data-testid":"settings-enable-browser-bell-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableTelegramBellPush")})}),e.jsx(A,{checked:S,onCheckedChange:t=>z(!!t),"data-testid":"settings-enable-telegram-bell-push"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableBrowserNotificationToast")})}),e.jsx(A,{checked:M,onCheckedChange:t=>o(!!t),"data-testid":"settings-enable-browser-notification-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableTelegramNotificationPush")})}),e.jsx(A,{checked:we,onCheckedChange:t=>be(!!t),"data-testid":"settings-enable-telegram-notification-push"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"bell-throttle-input",children:s("settings.bellThrottle")}),e.jsx(C,{id:"bell-throttle-input",type:"number",value:N,min:0,max:300,onChange:t=>T(Number(t.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"notification-throttle-input",children:s("settings.notificationThrottle")}),e.jsx(C,{id:"notification-throttle-input",type:"number",value:E,min:0,max:300,onChange:t=>r(Number(t.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-retries-input",children:s("settings.sshReconnectMaxRetries")}),e.jsx(C,{id:"ssh-reconnect-retries-input",type:"number",value:ve,min:0,max:20,onChange:t=>Ne(Number(t.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-delay-input",children:s("settings.sshReconnectDelay")}),e.jsx(C,{id:"ssh-reconnect-delay-input",type:"number",value:ke,min:1,max:300,onChange:t=>Ce(Number(t.target.value)),className:"min-h-10"})]})]})]})]}),a==="telegram"&&e.jsxs(q,{className:"border-0 ring-0",children:[e.jsx(D,{children:e.jsx(_,{children:s("telegram.title")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"new-bot-name",children:s("telegram.botName")}),e.jsx(C,{id:"new-bot-name",value:Y,onChange:t=>Se(t.target.value),placeholder:s("telegram.botNamePlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-6 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"new-bot-token",children:s("telegram.botToken")}),e.jsx(C,{id:"new-bot-token",type:"password",value:ee,onChange:t=>Ee(t.target.value),placeholder:s("telegram.botTokenPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(y,{variant:"default",className:"w-full md:w-auto","data-testid":"telegram-add-bot",onClick:()=>le.mutate(),disabled:le.isPending||!Y.trim()||!ee.trim(),children:[le.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),s("telegram.addBot")]})})]})}),e.jsxs("div",{className:"space-y-3",children:[ie.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!ie.isLoading&&Ke.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("telegram.addBot")}),Ke.map(t=>e.jsx(Fs,{bot:t,expanded:ts===t.id,onToggleExpand:()=>{as(k=>k===t.id?null:t.id)}},t.id))]})]})]}),a==="webhooks"&&e.jsxs(q,{className:"border-0 ring-0",children:[e.jsx(D,{children:e.jsx(_,{children:s("webhook.title")})}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-6 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-url-input",children:s("webhook.url")}),e.jsx(C,{id:"webhook-url-input","data-testid":"webhook-url-input",value:se,onChange:t=>Pe(t.target.value),placeholder:"https://example.com/webhook",className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-secret-input",children:s("webhook.secret")}),e.jsx(C,{id:"webhook-secret-input","data-testid":"webhook-secret-input",value:te,onChange:t=>Fe(t.target.value),placeholder:s("webhook.secretPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(y,{variant:"default",className:"w-full md:w-auto","data-testid":"webhook-add",onClick:()=>oe.mutate(),disabled:oe.isPending||!se.trim()||!te.trim()||ae.length===0,children:[oe.isPending?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),s("webhook.add")]})})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium",children:s("webhook.eventMask")}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:me.map(t=>{const k=ae.includes(t);return e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"min-w-0 pr-2 text-sm font-medium",children:s(`notification.eventType.${t}`)}),e.jsx(A,{checked:k,"data-testid":`webhook-event-${t}`,onCheckedChange:is=>{Te(U=>is?U.includes(t)?U:[...U,t]:U.filter(ls=>ls!==t))}})]},t)})})]}),e.jsxs("div",{className:"space-y-2",children:[re.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!re.isLoading&&Be.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("webhook.empty")}),Be.map(t=>e.jsxs("div",{"data-testid":"webhook-item","data-webhook-url":t.url,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:t.url}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleString(Ye(j))})]}),e.jsx(y,{variant:"ghost",size:"icon-sm","data-testid":"webhook-delete",onClick:()=>Ae.mutate(t.id),disabled:Ae.isPending,"aria-label":s("common.delete"),title:s("common.delete"),children:e.jsx(X,{className:"h-4 w-4"})})]},t.id))]})]})]}),a==="llm"&&e.jsx(Cs,{}),a==="search"&&e.jsx(Ps,{}),(a==="site"||a==="notifications")&&e.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end",children:e.jsxs(y,{variant:"default","data-testid":"settings-save",onClick:()=>Me.mutate(),disabled:Me.isPending,className:"w-full sm:w-auto",children:[e.jsx($,{className:"h-4 w-4"}),s("common.save")]})})]})}function Fs({bot:s,expanded:i,onToggleExpand:n}){var M;const{t:a}=K(),d=O(),[u,w]=c.useState(s.name),[p,l]=c.useState(""),[x,f]=c.useState(s.enabled),[m,j]=c.useState(s.allowAuthRequests);c.useEffect(()=>{w(s.name),f(s.enabled),j(s.allowAuthRequests)},[s.allowAuthRequests,s.enabled,s.name]);const b=R({queryKey:["telegram-bot-chats",s.id],enabled:i,queryFn:async()=>{const o=await fetch(`/api/settings/telegram/bots/${s.id}/chats`);if(!o.ok)throw new Error(await F(o,a("telegram.loadChatsFailed")));return await o.json()}}),N=c.useMemo(()=>{var S;const o=((S=b.data)==null?void 0:S.chats)??[];return{pending:o.filter(z=>z.status==="pending"),authorized:o.filter(z=>z.status==="authorized")}},[(M=b.data)==null?void 0:M.chats]),T=v({mutationFn:async()=>{const o={name:u,enabled:x,allowAuthRequests:m};p.trim()&&(o.token=p.trim());const S=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!S.ok)throw new Error(await F(S,a("telegram.updateFailed")))},onSuccess:async()=>{l(""),await d.invalidateQueries({queryKey:["telegram-bots"]}),h.success(a("common.success"))},onError:o=>{h.error(o instanceof Error?o.message:a("common.error"))}}),E=v({mutationFn:async()=>{const o=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"DELETE"});if(!o.ok)throw new Error(await F(o,a("telegram.deleteFailed")))},onSuccess:async()=>{await d.invalidateQueries({queryKey:["telegram-bots"]}),h.success(a("common.success"))},onError:o=>{h.error(o instanceof Error?o.message:a("common.error"))}}),r=v({mutationFn:async o=>{const S=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(o)}/approve`,{method:"POST"});if(!S.ok)throw new Error(await F(S,a("telegram.approveFailed")))},onSuccess:async()=>{await Promise.all([d.invalidateQueries({queryKey:["telegram-bots"]}),d.invalidateQueries({queryKey:["telegram-bot-chats",s.id]})]),h.success(a("common.success"))},onError:o=>{h.error(o instanceof Error?o.message:a("common.error"))}}),P=v({mutationFn:async o=>{const S=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(o)}`,{method:"DELETE"});if(!S.ok)throw new Error(await F(S,a("telegram.removeFailed")))},onSuccess:async()=>{await Promise.all([d.invalidateQueries({queryKey:["telegram-bots"]}),d.invalidateQueries({queryKey:["telegram-bot-chats",s.id]})]),h.success(a("common.success"))},onError:o=>{h.error(o instanceof Error?o.message:a("common.error"))}}),g=v({mutationFn:async o=>{const S=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(o)}/test`,{method:"POST"});if(!S.ok)throw new Error(await F(S,a("telegram.testMessageFailed")))},onSuccess:()=>{h.success(a("common.success"))},onError:o=>{h.error(o instanceof Error?o.message:a("common.error"))}});return e.jsxs("div",{className:"space-y-4 rounded-md border-0 bg-card p-4","data-testid":`telegram-bot-card-${s.id}`,"data-bot-name":s.name,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.authorizedCount," / ",s.pendingCount]})]}),e.jsx(y,{variant:"ghost","data-testid":`telegram-bot-toggle-${s.id}`,onClick:n,children:a(i?"common.collapse":"common.expand")})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-3 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:`bot-name-${s.id}`,children:a("telegram.botName")}),e.jsx(C,{id:`bot-name-${s.id}`,value:u,onChange:o=>w(o.target.value),className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:`bot-token-${s.id}`,children:a("telegram.botToken")}),e.jsx(C,{id:`bot-token-${s.id}`,type:"password",value:p,onChange:o=>l(o.target.value),placeholder:a("telegram.tokenPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium",children:a("common.enabled")}),e.jsx(A,{checked:x,onCheckedChange:o=>f(!!o)})]})}),e.jsx("div",{className:"md:col-span-3",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium",children:a("telegram.allowAuthRequests")}),e.jsx(A,{checked:m,onCheckedChange:o=>j(!!o)})]})})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end",children:[e.jsxs(y,{variant:"destructive","data-testid":`telegram-bot-delete-${s.id}`,onClick:()=>E.mutate(),className:"w-full sm:w-auto",children:[e.jsx(X,{className:"h-4 w-4"}),a("telegram.deleteBot")]}),e.jsxs(y,{variant:"default","data-testid":`telegram-bot-save-${s.id}`,onClick:()=>T.mutate(),className:"w-full sm:w-auto",children:[e.jsx($,{className:"h-4 w-4"}),a("common.save")]})]}),i&&e.jsxs("div",{className:"grid grid-cols-1 gap-4 border-t border-border pt-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-1",children:[e.jsx(Le,{className:"h-4 w-4"}),a("telegram.pendingChats")]}),N.pending.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"-"}),N.pending.map(o=>e.jsx(ze,{chat:o,pending:!0,onApprove:()=>r.mutate(o.chatId),onDelete:()=>P.mutate(o.chatId)},`${o.botId}-${o.chatId}`))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-1",children:[e.jsx(Le,{className:"h-4 w-4"}),a("telegram.chats")]}),N.authorized.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"-"}),N.authorized.map(o=>e.jsx(ze,{chat:o,pending:!1,onTest:()=>g.mutate(o.chatId),onDelete:()=>P.mutate(o.chatId)},`${o.botId}-${o.chatId}`))]}),b.isLoading&&e.jsx("div",{className:"lg:col-span-2 text-xs text-muted-foreground",children:a("common.loading")})]})]})}function ze({chat:s,pending:i,onApprove:n,onDelete:a,onTest:d}){const{t:u}=K(),w=Xe(p=>{var l;return((l=p.settings)==null?void 0:l.language)??"en_US"});return e.jsxs("div",{className:"space-y-2 rounded border-0 bg-background p-3",children:[e.jsx("div",{className:"text-sm font-medium truncate",title:s.displayName,children:s.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[u("telegram.chatId"),":",s.chatId]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(s.appliedAt).toLocaleString(Ye(w))}),e.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:i?e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",size:"sm",onClick:a,children:u("telegram.reject")}),e.jsx(y,{variant:"default",size:"sm",onClick:n,children:u("telegram.authorize")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(y,{variant:"secondary",size:"sm",onClick:d,children:[e.jsx(ds,{className:"h-3.5 w-3.5"}),u("telegram.sendTestMessage")]}),e.jsx(y,{variant:"destructive",size:"sm",onClick:a,children:u("common.delete")})]})})]})}function Bs(){const{t:s}=K();return e.jsx(e.Fragment,{children:s("sidebar.settings")})}function $s(){const{t:s}=K(),[i,n]=c.useState(!1),a=v({mutationFn:async()=>{const d=await fetch("/api/settings/restart",{method:"POST"});if(!d.ok)throw new Error(await F(d,s("settings.restartFailed")))},onSuccess:()=>{h.success(s("settings.restartScheduled"))},onError:d=>{h.error(d instanceof Error?d.message:s("common.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>n(!0),disabled:a.isPending,"aria-label":s("settings.restartGateway"),title:s("settings.restartGateway"),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(xs,{className:"h-4 w-4"})}),e.jsx(he,{open:i,onOpenChange:n,children:e.jsxs(ue,{children:[e.jsxs(ge,{children:[e.jsx(xe,{children:s("settings.restartGateway")}),e.jsx(pe,{children:s("settings.restartConfirm")})]}),e.jsxs(fe,{children:[e.jsx(je,{onClick:()=>n(!1),children:s("common.cancel")}),e.jsx(ye,{variant:"destructive",onClick:()=>{a.mutate(),n(!1)},children:s("common.confirm")})]})]})})]})}export{$s as PageActions,Bs as PageTitle,As as default};
|
|
22
|
-
//# sourceMappingURL=SettingsPage-
|
|
22
|
+
//# sourceMappingURL=SettingsPage-B6oIYlyE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as r,a4 as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=card-
|
|
1
|
+
import{j as r,a4 as d}from"./index-mf4NroE4.js";function o({className:a,size:t="default",...s}){return r.jsx("div",{"data-slot":"card","data-size":t,className:d("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col",a),...s})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",a),...t})}function n({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-4 group-data-[size=sm]/card:px-3",a),...t})}export{o as C,i as a,c as b,u as c,n as d};
|
|
2
|
+
//# sourceMappingURL=card-DzykTTqt.js.map
|