tmex-cli 0.9.1 → 0.10.0
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/runtime/server.js +1407 -127
- package/package.json +1 -1
- package/resources/fe-dist/assets/{DevicePage-D44i3G_t.js → DevicePage-5vkaNOjl.js} +8 -8
- package/resources/fe-dist/assets/DevicesPage-CKnRUGQm.js +2 -0
- package/resources/fe-dist/assets/FilePage-Dj0cszD4.css +1 -0
- package/resources/fe-dist/assets/FilePage-Uj-tzGW7.js +283 -0
- package/resources/fe-dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/resources/fe-dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/resources/fe-dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/resources/fe-dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/resources/fe-dist/assets/SettingsPage-Cfzr_Phh.js +22 -0
- package/resources/fe-dist/assets/arc-Wv219fq_.js +2 -0
- package/resources/fe-dist/assets/architectureDiagram-3BPJPVTR-DkPPo2hY.js +37 -0
- package/resources/fe-dist/assets/blockDiagram-GPEHLZMM-DPAThozG.js +133 -0
- package/resources/fe-dist/assets/c4Diagram-AAUBKEIU-DBs_N-_p.js +11 -0
- package/resources/fe-dist/assets/card-Dl0HC88A.js +2 -0
- package/resources/fe-dist/assets/channel-DyLhDM_y.js +2 -0
- package/resources/fe-dist/assets/chunk-2J33WTMH-D3mrUPCp.js +2 -0
- package/resources/fe-dist/assets/chunk-4BX2VUAB-C0DRv58j.js +2 -0
- package/resources/fe-dist/assets/chunk-55IACEB6-DheUp7iQ.js +2 -0
- package/resources/fe-dist/assets/chunk-727SXJPM-Cvew2yIJ.js +207 -0
- package/resources/fe-dist/assets/chunk-AQP2D5EJ-DUoa4Wdg.js +232 -0
- package/resources/fe-dist/assets/chunk-FMBD7UC4-Bt9Oi52P.js +16 -0
- package/resources/fe-dist/assets/chunk-ND2GUHAM-DlWpyDaS.js +2 -0
- package/resources/fe-dist/assets/chunk-QZHKN3VN-BZtXwgRW.js +2 -0
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-DA8DiM06.js +2 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-DA8DiM06.js +2 -0
- package/resources/fe-dist/assets/cose-bilkent-S5V4N54A-yKy6sTY_.js +2 -0
- package/resources/fe-dist/assets/cytoscape.esm-DTSO7Bv0.js +332 -0
- package/resources/fe-dist/assets/dagre-BM42HDAG-DL4fpno6.js +5 -0
- package/resources/fe-dist/assets/defaultLocale-DX6XiGOO.js +2 -0
- package/resources/fe-dist/assets/diagram-2AECGRRQ-BueYws-9.js +44 -0
- package/resources/fe-dist/assets/diagram-5GNKFQAL-GQEQSUeb.js +11 -0
- package/resources/fe-dist/assets/diagram-KO2AKTUF-LE3yI4ed.js +4 -0
- package/resources/fe-dist/assets/diagram-LMA3HP47-BkHjYrU4.js +25 -0
- package/resources/fe-dist/assets/diagram-OG6HWLK6-DrnHic-P.js +25 -0
- package/resources/fe-dist/assets/erDiagram-TEJ5UH35-BCwWv-rO.js +86 -0
- package/resources/fe-dist/assets/flowDiagram-I6XJVG4X-DEC2Z_fh.js +163 -0
- package/resources/fe-dist/assets/ganttDiagram-6RSMTGT7-H1T5bCsY.js +293 -0
- package/resources/fe-dist/assets/gitGraphDiagram-PVQCEYII-DmZUfKfl.js +107 -0
- package/resources/fe-dist/assets/graph-CAnANduQ.js +2 -0
- package/resources/fe-dist/assets/index-OpBFduyh.js +466 -0
- package/resources/fe-dist/assets/index-yMgNjHUH.css +1 -0
- package/resources/fe-dist/assets/infoDiagram-5YYISTIA-fDOg9Qr5.js +3 -0
- package/resources/fe-dist/assets/init-Gi6I4Gst.js +2 -0
- package/resources/fe-dist/assets/ishikawaDiagram-YF4QCWOH-QIvSJI3q.js +71 -0
- package/resources/fe-dist/assets/journeyDiagram-JHISSGLW-Iz7u4iH8.js +140 -0
- package/resources/fe-dist/assets/kanban-definition-UN3LZRKU-BYiFSFgn.js +90 -0
- package/resources/fe-dist/assets/layout-DGIYPm2g.js +2 -0
- package/resources/fe-dist/assets/linear-DNHZFKop.js +2 -0
- package/resources/fe-dist/assets/mermaid.core-DUipsjFg.js +310 -0
- package/resources/fe-dist/assets/mindmap-definition-RKZ34NQL-tPbrKC3m.js +97 -0
- package/resources/fe-dist/assets/ordinal-BENe2yWM.js +2 -0
- package/resources/fe-dist/assets/pieDiagram-4H26LBE5-26o8qBzb.js +31 -0
- package/resources/fe-dist/assets/quadrantDiagram-W4KKPZXB-BgpGo9Ak.js +8 -0
- package/resources/fe-dist/assets/{refresh-cw-DaPtMs2v.js → refresh-cw-DdcimDhs.js} +3 -3
- package/resources/fe-dist/assets/requirementDiagram-4Y6WPE33-BEfrxsDZ.js +85 -0
- package/resources/fe-dist/assets/sankeyDiagram-5OEKKPKP-BuIeHyjh.js +41 -0
- package/resources/fe-dist/assets/sequenceDiagram-3UESZ5HK-CL0sinOn.js +163 -0
- package/resources/fe-dist/assets/stateDiagram-AJRCARHV-BCq5X6hO.js +2 -0
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-DH2ctCND.js +2 -0
- package/resources/fe-dist/assets/timeline-definition-PNZ67QCA-CnqqA91O.js +121 -0
- package/resources/fe-dist/assets/vennDiagram-CIIHVFJN-BqFG3JXB.js +35 -0
- package/resources/fe-dist/assets/wardley-L42UT6IY-DvfZKNwT.js +174 -0
- package/resources/fe-dist/assets/wardleyDiagram-YWT4CUSO-DlABpMGt.js +79 -0
- package/resources/fe-dist/assets/xychartDiagram-2RQKCTM6-BDiyUuus.js +8 -0
- package/resources/fe-dist/fonts/GeistMono-Bold.woff2 +0 -0
- package/resources/fe-dist/fonts/GeistMono-Regular.woff2 +0 -0
- package/resources/fe-dist/fonts/NotoSansSymbols2-Regular.woff2 +0 -0
- package/resources/fe-dist/index.html +2 -2
- package/resources/gateway-drizzle/0007_fearless_pestilence.sql +8 -0
- package/resources/gateway-drizzle/0008_perfect_ozymandias.sql +7 -0
- package/resources/gateway-drizzle/meta/_journal.json +14 -0
- package/resources/fe-dist/assets/DevicesPage-CRK5IQTj.js +0 -2
- package/resources/fe-dist/assets/SettingsPage-B6oIYlyE.js +0 -22
- package/resources/fe-dist/assets/card-DzykTTqt.js +0 -2
- package/resources/fe-dist/assets/index-mGJ46K2A.css +0 -1
- package/resources/fe-dist/assets/index-mf4NroE4.js +0 -400
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{W as Y,u as M,r as d,b as $,j as e,B as w,P as be,a as D,d as b,t as u,Y as es,_ as ve,$ as hs,a0 as A,q as ss,T as z,A as ee,e as se,f as te,g as us,h as ae,i as ne,k as ie,l as le,m as re,a1 as gs,y as Ne,z as ke,C as Ce,F as Se,H as Ee,J as H,K as V,N as J,O as W,Q as U,I as C,U as Fe,a2 as O,G as xs,M as fs,a3 as ps,v as ts,a4 as js,a5 as as,a6 as Je,a7 as We,a8 as ns,a9 as ys,aa as ws}from"./index-OpBFduyh.js";import{C as R,b as _,c as I,a as L}from"./card-Dl0HC88A.js";import{R as vs}from"./refresh-cw-DdcimDhs.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const bs=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Ns=Y("boxes",bs);/**
|
|
7
|
+
* @license lucide-react v0.564.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ks=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Cs=Y("rotate-ccw",ks);/**
|
|
12
|
+
* @license lucide-react v0.564.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Ss=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],q=Y("save",Ss);/**
|
|
17
|
+
* @license lucide-react v0.564.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Es=[["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"}]],Ge=Y("shield",Es);function X({type:s,className:l}){return s==="ssh"?e.jsx(xs,{className:l}):e.jsx(fs,{className:l})}function Fs(){var m,p;const{t:s}=M(),[l,t]=d.useState(!1),[a,o]=d.useState(void 0),h=$({queryKey:["files","roots"],queryFn:ps}),f=$({queryKey:["devices"],queryFn:async()=>{const v=await fetch("/api/devices");if(!v.ok)throw new Error(`HTTP ${v.status}`);return await v.json()},throwOnError:!1}),x=((m=h.data)==null?void 0:m.roots)??[],r=((p=f.data)==null?void 0:p.devices)??[],g=()=>{o(void 0),t(!0)},y=v=>{o(v),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(R,{className:"border-0 ring-0","data-testid":"settings-files-section",children:[e.jsxs(_,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(I,{children:s("settings.files.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settings.files.description")})]}),e.jsxs(w,{"data-testid":"settings-files-root-add",onClick:g,children:[e.jsx(be,{className:"h-4 w-4"}),s("settings.files.addRoot")]})]}),e.jsxs(L,{className:"space-y-3",children:[h.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!h.isLoading&&x.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"settings-files-empty",children:s("settings.files.empty")}),x.map(v=>e.jsx(Ps,{root:v,onEdit:y},v.id))]})]}),e.jsx(Ts,{open:l,onOpenChange:t,root:a,devices:r})]})}function Ps({root:s,onEdit:l}){const{t}=M(),a=D(),[o,h]=d.useState(!1),f=b({mutationFn:({id:r,enabled:g})=>es(r,{enabled:g}),onSuccess:async()=>{await a.invalidateQueries({queryKey:["files"]})},onError:()=>{u.error(t("settings.files.toggleFailed"))}}),x=b({mutationFn:r=>hs(r),onSuccess:async()=>{await a.invalidateQueries({queryKey:["files"]}),u.success(t("common.success"))},onError:r=>{const g=r instanceof ve?r.message:t("settings.files.deleteFailed");u.error(g)}});return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-3","data-testid":`settings-files-root-${s.id}`,children:[e.jsx(A,{checked:s.enabled,disabled:f.isPending,onCheckedChange:r=>f.mutate({id:s.id,enabled:!!r}),"data-testid":`settings-files-root-enabled-${s.id}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(X,{type:s.deviceType,className:"h-3.5 w-3.5 shrink-0"}),s.deviceName===null?e.jsx("span",{className:"text-destructive",children:t("settings.files.missing")}):e.jsx("span",{className:"truncate",children:s.deviceName})]}),e.jsx("div",{className:"truncate font-mono text-xs",children:s.path}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.edit"),"data-testid":`settings-files-root-edit-${s.id}`,onClick:()=>l(s),children:e.jsx(ss,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.delete"),"data-testid":`settings-files-root-delete-${s.id}`,onClick:()=>h(!0),disabled:x.isPending,children:e.jsx(z,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(ee,{open:o,onOpenChange:h,children:e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(us,{className:"bg-destructive/10",children:e.jsx(z,{className:"h-5 w-5 text-destructive"})}),e.jsx(ae,{children:t("settings.files.deleteTitle")}),e.jsx(ne,{children:t("settings.files.deleteDesc",{path:s.path})})]}),e.jsxs(ie,{children:[e.jsx(le,{children:t("common.cancel")}),e.jsx(re,{variant:"destructive","data-testid":`settings-files-root-delete-confirm-${s.id}`,onClick:()=>{x.mutate(s.id),h(!1)},children:t("common.delete")})]})]})})]})}const Ze="h-9 w-full";function Ts({open:s,onOpenChange:l,root:t,devices:a}){const{t:o}=M(),h=D(),f=!!t,[x,r]=d.useState(""),[g,y]=d.useState(""),[m,p]=d.useState(!0);d.useEffect(()=>{s&&(r((t==null?void 0:t.deviceId)??""),y((t==null?void 0:t.path)??""),p((t==null?void 0:t.enabled)??!0))},[s,t]);const v=b({mutationFn:()=>{const i={deviceId:x,path:g.trim(),enabled:m};return gs(i)},onSuccess:async()=>{await h.invalidateQueries({queryKey:["files"]}),u.success(o("common.success")),l(!1)},onError:i=>{const k=i instanceof ve?i.message:o("settings.files.addFailed");u.error(k)}}),N=b({mutationFn:()=>{if(!t)throw new Error(o("settings.files.updateFailed"));const i={path:g.trim(),enabled:m};return es(t.id,i)},onSuccess:async()=>{await h.invalidateQueries({queryKey:["files"]}),u.success(o("common.success")),l(!1)},onError:i=>{const k=i instanceof ve?i.message:o("settings.files.updateFailed");u.error(k)}}),S=v.isPending||N.isPending,E=g.trim().startsWith("/")&&(f||x.length>0),j=()=>{!E||S||(f?N.mutate():v.mutate())},P=a.find(i=>i.id===x);return e.jsx(Ne,{open:s,onOpenChange:l,children:e.jsxs(ke,{className:"sm:max-w-lg","data-testid":f?`settings-files-edit-modal-${t==null?void 0:t.id}`:"settings-files-add-modal",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:o(f?"settings.files.modalEditTitle":"settings.files.modalAddTitle")}),e.jsx(Ee,{children:o("settings.files.description")})]}),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:"files-form-device",children:o("settings.files.device")}),f?e.jsxs("div",{className:"flex h-9 items-center gap-1.5 rounded-lg border border-input bg-muted/30 px-2.5 text-sm",children:[e.jsx(X,{type:(t==null?void 0:t.deviceType)??null,className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:(t==null?void 0:t.deviceName)??o("settings.files.missing")})]}):e.jsxs(H,{value:x,onValueChange:i=>{i&&r(i)},children:[e.jsx(V,{id:"files-form-device","data-testid":"settings-files-device-select",className:Ze,disabled:a.length===0,children:e.jsx(J,{children:P?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(X,{type:P.type,className:"h-4 w-4 shrink-0"}),P.name]}):e.jsx("span",{className:"text-muted-foreground",children:o("settings.files.devicePlaceholder")})})}),e.jsx(W,{children:a.map(i=>e.jsxs(U,{value:i.id,children:[e.jsx(X,{type:i.type,className:"h-4 w-4 shrink-0"}),i.name]},i.id))})]}),!f&&a.length===0&&e.jsx("p",{className:"text-xs text-destructive",children:o("settings.files.noDevices")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"files-form-path",children:o("settings.files.path")}),e.jsx(C,{id:"files-form-path","data-testid":"settings-files-path-input",value:g,onChange:i=>y(i.target.value),placeholder:o("settings.files.pathPlaceholder"),className:`${Ze} font-mono`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o("settings.files.pathHint")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{checked:m,onCheckedChange:i=>p(!!i),"data-testid":"settings-files-enabled-switch"}),e.jsx("label",{className:"text-sm font-medium",htmlFor:"settings-files-enabled-switch",children:o("settings.files.enabled")})]})]}),e.jsxs(Fe,{children:[e.jsx(w,{variant:"outline",onClick:()=>l(!1),disabled:S,children:o("common.cancel")}),e.jsxs(w,{"data-testid":"settings-files-form-submit",onClick:j,disabled:!E||S,children:[S?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),o("common.save")]})]})]})})}async function B(s,l){try{return(await s.json()).error??l}catch{return l}}const Ms=["openai-chat","openai-responses"],Z="h-9 w-full";function Ks({open:s,onOpenChange:l,provider:t}){const{t:a}=M(),o=D(),h=!!t,[f,x]=d.useState(""),[r,g]=d.useState(""),[y,m]=d.useState("openai-chat"),[p,v]=d.useState("");d.useEffect(()=>{s&&(x((t==null?void 0:t.name)??""),g((t==null?void 0:t.baseUrl)??""),m((t==null?void 0:t.protocol)??"openai-chat"),v(""))},[s,t]);const N=b({mutationFn:async()=>{const j={name:f.trim(),protocol:y,baseUrl:r.trim(),apiKey:p.trim(),enabled:!0},P=await fetch("/api/llm/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)});if(!P.ok)throw new Error(await B(P,a("settings.llm.createFailed")));return await P.json()},onSuccess:async j=>{await o.invalidateQueries({queryKey:["llm-providers"]}),j.modelsError?u.warning(a("settings.llm.modelsFetchFailed",{error:j.modelsError})):u.success(a("common.success")),l(!1)},onError:j=>{u.error(j instanceof Error?j.message:a("common.error"))}}),S=b({mutationFn:async()=>{if(!t)throw new Error(a("settings.llm.updateFailed"));const j={name:f.trim(),baseUrl:r.trim(),protocol:y};p.trim()&&(j.apiKey=p.trim());const P=await fetch(`/api/llm/providers/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)});if(!P.ok)throw new Error(await B(P,a("settings.llm.updateFailed")));return await P.json()},onSuccess:async j=>{await o.invalidateQueries({queryKey:["llm-providers"]}),j.modelsError?u.warning(a("settings.llm.modelsFetchFailed",{error:j.modelsError})):u.success(a("common.success")),l(!1)},onError:j=>{u.error(j instanceof Error?j.message:a("common.error"))}}),T=N.isPending||S.isPending,c=f.trim().length>0&&r.trim().length>0&&(h||p.trim().length>0),E=()=>{!c||T||(h?S.mutate():N.mutate())};return e.jsx(Ne,{open:s,onOpenChange:l,children:e.jsxs(ke,{className:"sm:max-w-lg","data-testid":h?`llm-provider-edit-modal-${t==null?void 0:t.id}`:"llm-provider-add-modal",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:a(h?"settings.llm.editProvider":"settings.llm.addProvider")}),e.jsx(Ee,{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:f,onChange:j=>x(j.target.value),placeholder:a("settings.llm.namePlaceholder"),className:Z})]}),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:r,onChange:j=>g(j.target.value),placeholder:a("settings.llm.baseUrlPlaceholder"),className:Z}),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(H,{value:y,onValueChange:j=>{j&&m(j)},children:[e.jsx(V,{id:"llm-form-protocol","data-testid":"llm-provider-protocol-select",className:Z,children:e.jsx(J,{})}),e.jsx(W,{children:Ms.map(j=>e.jsx(U,{value:j,children:j},j))})]})]}),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":t!=null&&t.hasApiKey?"true":"false",type:"password",value:p,onChange:j=>v(j.target.value),placeholder:t!=null&&t.hasApiKey?a("settings.llm.apiKeySetPlaceholder"):a("settings.llm.apiKeyPlaceholder"),className:Z})]})]}),e.jsxs(Fe,{children:[e.jsx(w,{variant:"outline",onClick:()=>l(!1),disabled:T,children:a("common.cancel")}),e.jsxs(w,{"data-testid":"llm-provider-form-submit",onClick:E,disabled:!c||T,children:[T?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),a("common.save")]})]})]})})}function As({models:s,onChange:l}){const{t}=M(),[a,o]=d.useState(""),h=(r,g)=>{l(s.map(y=>y.id===r?{...y,enabled:g}:y))},f=r=>{l(s.filter(g=>g.id!==r))},x=()=>{const r=a.trim();if(r){if(s.some(g=>g.id===r)){o("");return}l([...s,{id:r,source:"manual",enabled:!0}]),o("")}};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:r=>o(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),x())},placeholder:t("settings.llm.addModelPlaceholder"),className:"h-9","data-testid":"llm-provider-add-model-input"}),e.jsxs(w,{type:"button",variant:"outline",size:"lg",onClick:x,disabled:!a.trim(),"data-testid":"llm-provider-add-model",children:[e.jsx(be,{className:"h-4 w-4"}),t("common.add")]})]}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:t("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(r=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-md px-2 py-1.5","data-testid":`llm-provider-model-${r.id}`,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(A,{checked:r.enabled,onCheckedChange:g=>h(r.id,!!g),"data-testid":`llm-provider-model-toggle-${r.id}`}),e.jsx("span",{className:"truncate font-mono text-xs",children:r.id}),r.source==="manual"&&e.jsx(ts,{variant:"secondary",children:t("settings.llm.modelManual")})]}),r.source==="manual"&&e.jsx(w,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>f(r.id),"data-testid":`llm-provider-model-remove-${r.id}`,children:e.jsx(js,{className:"h-4 w-4"})})]},r.id))})]})}function $s(s){return s.modelDetails.map(l=>({id:l.id,source:l.source,enabled:l.enabled}))}function qs({open:s,onOpenChange:l,provider:t}){const{t:a}=M(),o=D(),[h,f]=d.useState([]);d.useEffect(()=>{s&&f($s(t))},[s,t]);const x=b({mutationFn:async()=>{const r=h.filter(p=>p.source==="manual").map(p=>p.id),g=h.filter(p=>!p.enabled).map(p=>p.id),y={manualModels:r,disabledModels:g},m=await fetch(`/api/llm/providers/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(!m.ok)throw new Error(await B(m,a("settings.llm.updateFailed")));return await m.json()},onSuccess:async r=>{await o.invalidateQueries({queryKey:["llm-providers"]}),r.modelsError?u.warning(a("settings.llm.modelsFetchFailed",{error:r.modelsError})):u.success(a("common.success")),l(!1)},onError:r=>{u.error(r instanceof Error?r.message:a("common.error"))}});return e.jsx(Ne,{open:s,onOpenChange:l,children:e.jsxs(ke,{className:"sm:max-w-lg","data-testid":`llm-provider-models-modal-${t.id}`,children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:a("settings.llm.modelsTitle",{name:t.name})}),e.jsx(Ee,{children:a("settings.llm.modelsHint")})]}),e.jsx(As,{models:h,onChange:f}),e.jsxs(Fe,{children:[e.jsx(w,{variant:"outline",onClick:()=>l(!1),disabled:x.isPending,children:a("common.cancel")}),e.jsxs(w,{"data-testid":`llm-provider-models-save-${t.id}`,onClick:()=>x.mutate(),disabled:x.isPending,children:[x.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),a("common.save")]})]})]})})}function Bs(s){try{const l=new URL(s);return`${l.protocol}//${l.host}${l.pathname==="/"?"":l.pathname}`}catch{return s}}function Ds({provider:s,onEdit:l}){const{t}=M(),a=D(),[o,h]=d.useState(!1),[f,x]=d.useState(!1),r=b({mutationFn:async m=>{const p=await fetch(`/api/llm/providers/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:m})});if(!p.ok)throw new Error(await B(p,t("settings.llm.updateFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]})},onError:m=>{u.error(m instanceof Error?m.message:t("common.error"))}}),g=b({mutationFn:async()=>{const m=await fetch(`/api/llm/providers/${s.id}/refresh-models`,{method:"POST"});if(!m.ok)throw new Error(await B(m,t("settings.llm.refreshModelsFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]}),u.success(t("common.success"))},onError:m=>{u.error(m instanceof Error?m.message:t("common.error"))}}),y=b({mutationFn:async()=>{const m=await fetch(`/api/llm/providers/${s.id}`,{method:"DELETE"});if(!m.ok)throw new Error(await B(m,t("settings.llm.deleteFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-providers"]}),await a.invalidateQueries({queryKey:["llm-settings"]}),u.success(t("common.success"))},onError:m=>{u.error(m instanceof Error?m.message:t("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:r.isPending,onCheckedChange:m=>r.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(ts,{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:Bs(s.baseUrl)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"whitespace-nowrap",children:t("settings.llm.modelsCount",{total:s.models.length})})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("settings.llm.refreshModels"),"data-testid":`llm-provider-refresh-models-${s.id}`,onClick:()=>g.mutate(),disabled:g.isPending,children:g.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(vs,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("settings.llm.models"),"data-testid":`llm-provider-models-${s.id}`,onClick:()=>x(!0),children:e.jsx(Ns,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.edit"),"data-testid":`llm-provider-edit-${s.id}`,onClick:()=>l(s),children:e.jsx(ss,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.delete"),"data-testid":`llm-provider-delete-${s.id}`,onClick:()=>h(!0),disabled:y.isPending,children:e.jsx(z,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(qs,{open:f,onOpenChange:x,provider:s}),e.jsx(ee,{open:o,onOpenChange:h,children:e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:t("settings.llm.deleteProvider")}),e.jsx(ne,{children:t("settings.llm.deleteConfirm",{name:s.name})})]}),e.jsxs(ie,{children:[e.jsx(le,{onClick:()=>h(!1),children:t("common.cancel")}),e.jsx(re,{variant:"destructive","data-testid":`llm-provider-delete-confirm-${s.id}`,onClick:()=>{y.mutate(),h(!1)},children:t("common.confirm")})]})]})})]})}function Rs(){var g;const{t:s}=M(),[l,t]=d.useState(!1),[a,o]=d.useState(void 0),h=$({queryKey:["llm-providers"],queryFn:async()=>{const y=await fetch("/api/llm/providers");if(!y.ok)throw new Error(await B(y,s("settings.llm.loadFailed")));return await y.json()}}),f=((g=h.data)==null?void 0:g.providers)??[],x=()=>{o(void 0),t(!0)},r=y=>{o(y),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(R,{className:"border-0 ring-0","data-testid":"llm-providers-section",children:[e.jsxs(_,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsx(I,{children:s("settings.llm.title")}),e.jsxs(w,{"data-testid":"llm-provider-add",onClick:x,children:[e.jsx(be,{className:"h-4 w-4"}),s("settings.llm.addProvider")]})]}),e.jsxs(L,{className:"space-y-3",children:[h.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!h.isLoading&&f.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"llm-providers-empty",children:s("settings.llm.empty")}),f.map(y=>e.jsx(Ds,{provider:y,onEdit:r},y.id))]})]}),e.jsx(Ks,{open:l,onOpenChange:t,provider:a}),e.jsx(_s,{providers:f})]})}const je="__none__";function _s({providers:s}){var S,T;const{t:l}=M(),t=D(),[a,o]=d.useState(null),[h,f]=d.useState(""),x=$({queryKey:["llm-settings"],queryFn:async()=>{const c=await fetch("/api/llm/settings");if(!c.ok)throw new Error(await B(c,l("settings.llm.settingsLoadFailed")));return await c.json()}}),r=((S=x.data)==null?void 0:S.settings.defaultProviderId)??null,g=((T=x.data)==null?void 0:T.settings.defaultModelId)??"",y=!!x.data;d.useEffect(()=>{y&&(o(r),f(g))},[y,r,g]);const m=b({mutationFn:async()=>{const c={defaultProviderId:a,defaultModelId:h.trim()||null},E=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!E.ok)throw new Error(await B(E,l("settings.llm.settingsSaveFailed")))},onSuccess:async()=>{await t.invalidateQueries({queryKey:["llm-settings"]}),u.success(l("common.success"))},onError:c=>{u.error(c instanceof Error?c.message:l("common.error"))}}),p=s.filter(c=>c.enabled),v=s.find(c=>c.id===a),N=(v==null?void 0:v.models)??[];return e.jsxs(R,{className:"border-0 ring-0","data-testid":"llm-defaults-section",children:[e.jsx(_,{children:e.jsx(I,{children:l("settings.llm.defaults")})}),e.jsxs(L,{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:l("settings.llm.defaultProvider")}),e.jsxs(H,{value:a??je,onValueChange:c=>{c&&o(c===je?null:c)},children:[e.jsx(V,{id:"llm-default-provider-select","data-testid":"llm-default-provider-select",className:"h-9 w-full",children:e.jsx(J,{children:(v==null?void 0:v.name)??l("settings.llm.defaultProviderNone")})}),e.jsxs(W,{children:[e.jsx(U,{value:je,children:l("settings.llm.defaultProviderNone")}),p.map(c=>e.jsx(U,{value:c.id,children:c.name},c.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-default-model-input",children:l("settings.llm.defaultModel")}),e.jsx(C,{id:"llm-default-model-input","data-testid":"llm-default-model-input",list:"llm-default-model-options",value:h,onChange:c=>f(c.target.value),placeholder:l("settings.llm.defaultModelPlaceholder"),className:"h-9"}),e.jsx("datalist",{id:"llm-default-model-options",children:N.map(c=>e.jsx("option",{value:c},c))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{variant:"default","data-testid":"llm-defaults-save",onClick:()=>m.mutate(),disabled:m.isPending||x.isLoading,className:"w-full sm:w-auto",children:[m.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),l("settings.llm.saveDefaults")]})})]})]})}const Is=["none","tavily","brave"];async function ye(s,l){try{return(await s.json()).error??l}catch{return l}}function Ls(){var T;const{t:s}=M(),l=D(),[t,a]=d.useState("none"),[o,h]=d.useState(""),[f,x]=d.useState(""),[r,g]=d.useState(null),y=$({queryKey:["llm-settings"],queryFn:async()=>{const c=await fetch("/api/llm/settings");if(!c.ok)throw new Error(await ye(c,s("settings.search.loadFailed")));return await c.json()}}),m=(T=y.data)==null?void 0:T.settings,p=m==null?void 0:m.searchProvider;d.useEffect(()=>{p&&a(p)},[p]);const v=b({mutationFn:async()=>{const c={searchProvider:t};o.trim()&&(c.tavilyApiKey=o.trim()),f.trim()&&(c.braveApiKey=f.trim());const E=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!E.ok)throw new Error(await ye(E,s("settings.search.saveFailed")))},onSuccess:async()=>{h(""),x(""),await l.invalidateQueries({queryKey:["llm-settings"]}),u.success(s("common.success"))},onError:c=>{u.error(c instanceof Error?c.message:s("common.error"))}}),N=b({mutationFn:async c=>{const E={[c]:""},j=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!j.ok)throw new Error(await ye(j,s("settings.search.saveFailed")))},onSuccess:async()=>{await l.invalidateQueries({queryKey:["llm-settings"]}),u.success(s("common.success"))},onError:c=>{u.error(c instanceof Error?c.message:s("common.error"))}}),S=c=>c==="none"?s("settings.search.providerNone"):c==="tavily"?"Tavily":"Brave";return e.jsxs(R,{className:"border-0 ring-0","data-testid":"settings-search-section",children:[e.jsx(_,{children:e.jsx(I,{children:s("settings.search.title")})}),e.jsxs(L,{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(H,{value:t,onValueChange:c=>{c&&a(c)},children:[e.jsx(V,{id:"search-provider-select","data-testid":"settings-search-provider-select",className:"w-full min-h-10",children:e.jsx(J,{children:S(t)})}),e.jsx(W,{children:Is.map(c=>e.jsx(U,{value:c,children:S(c)},c))})]})]}),e.jsx(Xe,{id:"search-tavily-key-input",testId:"settings-search-tavily",label:s("settings.search.tavilyApiKey"),value:o,hasKey:(m==null?void 0:m.hasTavilyApiKey)??!1,onChange:h,onClear:()=>g("tavilyApiKey"),clearing:N.isPending&&N.variables==="tavilyApiKey"}),e.jsx(Xe,{id:"search-brave-key-input",testId:"settings-search-brave",label:s("settings.search.braveApiKey"),value:f,hasKey:(m==null?void 0:m.hasBraveApiKey)??!1,onChange:x,onClear:()=>g("braveApiKey"),clearing:N.isPending&&N.variables==="braveApiKey"}),e.jsx(ee,{open:r!==null,onOpenChange:c=>{c||g(null)},children:e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:s("settings.search.clearKey")}),e.jsx(ne,{children:s("settings.search.clearKeyConfirm")})]}),e.jsxs(ie,{children:[e.jsx(le,{children:s("common.cancel")}),e.jsx(re,{"data-testid":"settings-search-clear-confirm",onClick:()=>{r&&N.mutate(r),g(null)},children:s("settings.search.clearKey")})]})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{variant:"default","data-testid":"settings-search-save",onClick:()=>v.mutate(),disabled:v.isPending||y.isLoading,className:"w-full sm:w-auto",children:[v.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),s("common.save")]})})]})]})}function Xe({id:s,testId:l,label:t,value:a,hasKey:o,onChange:h,onClear:f,clearing:x}){const{t:r}=M();return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:s,children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{id:s,"data-testid":`${l}-input`,"data-key-set":o?"true":"false",type:"password",value:a,onChange:g=>h(g.target.value),placeholder:r(o?"settings.search.keySetPlaceholder":"settings.search.keyPlaceholder"),className:"min-h-10"}),o&&e.jsxs(w,{variant:"outline",size:"sm","data-testid":`${l}-clear`,onClick:f,disabled:x,className:"shrink-0",children:[e.jsx(z,{className:"h-4 w-4"}),r("settings.search.clearKey")]})]})]})}const we=["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 K(s,l){try{return(await s.json()).error??l}catch{return l}}function Hs(){var ze,Ue,He,Ve;const{t:s}=M(),l=D(),{refreshSettings:t}=as(),[a,o]=d.useState("site"),h=Je(n=>n.theme),f=Je(n=>n.setTheme),x=h==="dark",[r,g]=d.useState("tmex"),[y,m]=d.useState(window.location.origin),[p,v]=d.useState("en_US"),[N,S]=d.useState(6),[T,c]=d.useState(3),[E,j]=d.useState(!0),[P,i]=d.useState(!0),[k,Q]=d.useState(!0),[Pe,Te]=d.useState(!0),[Me,Ke]=d.useState(2),[Ae,$e]=d.useState(10),[is,ls]=d.useState(!1),[oe,qe]=d.useState(""),[ce,Be]=d.useState(""),[rs,os]=d.useState(null),[de,De]=d.useState(""),[me,Re]=d.useState(""),[he,_e]=d.useState(we),cs=n=>{const F=n?"dark":"light";f(F),document.documentElement.classList.toggle("dark",F==="dark")},ue=$({queryKey:["site-settings"],queryFn:async()=>{const n=await fetch("/api/settings/site");if(!n.ok)throw new Error(await K(n,s("settings.loadFailed")));return await n.json()}}),ge=$({queryKey:["telegram-bots"],queryFn:async()=>{const n=await fetch("/api/settings/telegram/bots");if(!n.ok)throw new Error(await K(n,s("telegram.loadBotsFailed")));return await n.json()}});d.useEffect(()=>{var F;const n=(F=ue.data)==null?void 0:F.settings;n&&(g(n.siteName),m(n.siteUrl),v(n.language??"en_US"),S(n.bellThrottleSeconds),c(n.notificationThrottleSeconds??3),j(n.enableBrowserBellToast??!0),i(n.enableBrowserNotificationToast??!0),Q(n.enableTelegramBellPush??!0),Te(n.enableTelegramNotificationPush??!0),Ke(n.sshReconnectMaxRetries),$e(n.sshReconnectDelaySeconds))},[(ze=ue.data)==null?void 0:ze.settings]);const Ie=b({mutationFn:async()=>{const F=await fetch("/api/settings/site",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:r,siteUrl:y,language:p,bellThrottleSeconds:N,notificationThrottleSeconds:T,enableBrowserBellToast:E,enableBrowserNotificationToast:P,enableTelegramBellPush:k,enableTelegramNotificationPush:Pe,sshReconnectMaxRetries:Me,sshReconnectDelaySeconds:Ae})});if(!F.ok)throw new Error(await K(F,s("settings.saveFailed")))},onSuccess:async()=>{var n,F;await Promise.all([l.invalidateQueries({queryKey:["site-settings"]}),t()]),u.success(s("settings.settingsSaved")),((F=(n=ue.data)==null?void 0:n.settings)==null?void 0:F.language)!==p&&(ys.changeLanguage(p),ls(!0))},onError:n=>{u.error(n instanceof Error?n.message:s("common.error"))}}),xe=b({mutationFn:async()=>{const n=await fetch("/api/settings/telegram/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:oe,token:ce,enabled:!0,allowAuthRequests:!0})});if(!n.ok)throw new Error(await K(n,s("telegram.createFailed")))},onSuccess:async()=>{qe(""),Be(""),await l.invalidateQueries({queryKey:["telegram-bots"]}),u.success(s("common.success"))},onError:n=>{u.error(n instanceof Error?n.message:s("common.error"))}}),Le=((Ue=ge.data)==null?void 0:Ue.bots)??[],fe=$({queryKey:["webhooks"],queryFn:async()=>{const n=await fetch("/api/webhooks");if(!n.ok)throw new Error(await K(n,s("webhook.loadFailed")));return await n.json()}}),pe=b({mutationFn:async()=>{const n=await fetch("/api/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:de,secret:me,eventMask:he})});if(!n.ok)throw new Error(await K(n,s("webhook.createFailed")))},onSuccess:async()=>{De(""),Re(""),_e(we),await l.invalidateQueries({queryKey:["webhooks"]}),u.success(s("common.success"))},onError:n=>{u.error(n instanceof Error?n.message:s("common.error"))}}),Oe=b({mutationFn:async n=>{const F=await fetch(`/api/webhooks/${n}`,{method:"DELETE"});if(!F.ok)throw new Error(await K(F,s("webhook.deleteFailed")))},onSuccess:async()=>{await l.invalidateQueries({queryKey:["webhooks"]}),u.success(s("common.success"))},onError:n=>{u.error(n instanceof Error?n.message:s("common.error"))}}),Qe=((He=fe.data)==null?void 0:He.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(w,{type:"button",size:"sm",variant:a==="site"?"default":"outline","data-testid":"settings-tab-site",onClick:()=>o("site"),children:s("settings.siteSettings")}),e.jsx(w,{type:"button",size:"sm",variant:a==="notifications"?"default":"outline","data-testid":"settings-tab-notifications",onClick:()=>o("notifications"),children:s("settings.notificationsTab")}),e.jsx(w,{type:"button",size:"sm",variant:a==="telegram"?"default":"outline","data-testid":"settings-tab-telegram",onClick:()=>o("telegram"),children:s("telegram.title")}),e.jsx(w,{type:"button",size:"sm",variant:a==="webhooks"?"default":"outline","data-testid":"settings-tab-webhooks",onClick:()=>o("webhooks"),children:s("webhook.title")}),e.jsx(w,{type:"button",size:"sm",variant:a==="llm"?"default":"outline","data-testid":"settings-tab-llm",onClick:()=>o("llm"),children:s("settings.llm.title")}),e.jsx(w,{type:"button",size:"sm",variant:a==="search"?"default":"outline","data-testid":"settings-tab-search",onClick:()=>o("search"),children:s("settings.search.title")}),e.jsx(w,{type:"button",size:"sm",variant:a==="files"?"default":"outline","data-testid":"settings-tab-files",onClick:()=>o("files"),children:s("settings.files.title")})]}),a==="site"&&e.jsxs(R,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(I,{children:s("settings.siteSettings")})}),e.jsxs(L,{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:r,onChange:n=>g(n.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:y,onChange:n=>m(n.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(H,{value:p,onValueChange:n=>{n&&v(n)},children:[e.jsx(V,{id:"language-select","data-testid":"settings-language-select",className:"w-full min-h-10",children:e.jsx(J,{placeholder:s("settings.language"),children:((Ve=We.locales.find(n=>n.code===p))==null?void 0:Ve.nativeName)??p})}),e.jsx(W,{className:"max-h-[var(--tmex-viewport-height)]",children:We.locales.map(n=>e.jsx(U,{value:n.code,children:n.nativeName},n.code))})]}),is&&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:x,onCheckedChange:n=>cs(!!n),"data-testid":"settings-theme-toggle"})]})})]})]}),a==="notifications"&&e.jsxs(R,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(I,{children:s("settings.notificationsTab")})}),e.jsxs(L,{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:E,onCheckedChange:n=>j(!!n),"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:k,onCheckedChange:n=>Q(!!n),"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:P,onCheckedChange:n=>i(!!n),"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:Pe,onCheckedChange:n=>Te(!!n),"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:n=>S(Number(n.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:T,min:0,max:300,onChange:n=>c(Number(n.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:Me,min:0,max:20,onChange:n=>Ke(Number(n.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:Ae,min:1,max:300,onChange:n=>$e(Number(n.target.value)),className:"min-h-10"})]})]})]})]}),a==="telegram"&&e.jsxs(R,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(I,{children:s("telegram.title")})}),e.jsxs(L,{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:oe,onChange:n=>qe(n.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:ce,onChange:n=>Be(n.target.value),placeholder:s("telegram.botTokenPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(w,{variant:"default",className:"w-full md:w-auto","data-testid":"telegram-add-bot",onClick:()=>xe.mutate(),disabled:xe.isPending||!oe.trim()||!ce.trim(),children:[xe.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}),s("telegram.addBot")]})})]})}),e.jsxs("div",{className:"space-y-3",children:[ge.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!ge.isLoading&&Le.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("telegram.addBot")}),Le.map(n=>e.jsx(Os,{bot:n,expanded:rs===n.id,onToggleExpand:()=>{os(F=>F===n.id?null:n.id)}},n.id))]})]})]}),a==="webhooks"&&e.jsxs(R,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(I,{children:s("webhook.title")})}),e.jsxs(L,{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:de,onChange:n=>De(n.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:me,onChange:n=>Re(n.target.value),placeholder:s("webhook.secretPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(w,{variant:"default",className:"w-full md:w-auto","data-testid":"webhook-add",onClick:()=>pe.mutate(),disabled:pe.isPending||!de.trim()||!me.trim()||he.length===0,children:[pe.isPending?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{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:we.map(n=>{const F=he.includes(n);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.${n}`)}),e.jsx(A,{checked:F,"data-testid":`webhook-event-${n}`,onCheckedChange:ds=>{_e(G=>ds?G.includes(n)?G:[...G,n]:G.filter(ms=>ms!==n))}})]},n)})})]}),e.jsxs("div",{className:"space-y-2",children:[fe.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!fe.isLoading&&Qe.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("webhook.empty")}),Qe.map(n=>e.jsxs("div",{"data-testid":"webhook-item","data-webhook-url":n.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:n.url}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(n.createdAt).toLocaleString(ns(p))})]}),e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":"webhook-delete",onClick:()=>Oe.mutate(n.id),disabled:Oe.isPending,"aria-label":s("common.delete"),title:s("common.delete"),children:e.jsx(z,{className:"h-4 w-4"})})]},n.id))]})]})]}),a==="llm"&&e.jsx(Rs,{}),a==="search"&&e.jsx(Ls,{}),a==="files"&&e.jsx(Fs,{}),(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(w,{variant:"default","data-testid":"settings-save",onClick:()=>Ie.mutate(),disabled:Ie.isPending,className:"w-full sm:w-auto",children:[e.jsx(q,{className:"h-4 w-4"}),s("common.save")]})})]})}function Os({bot:s,expanded:l,onToggleExpand:t}){var P;const{t:a}=M(),o=D(),[h,f]=d.useState(s.name),[x,r]=d.useState(""),[g,y]=d.useState(s.enabled),[m,p]=d.useState(s.allowAuthRequests);d.useEffect(()=>{f(s.name),y(s.enabled),p(s.allowAuthRequests)},[s.allowAuthRequests,s.enabled,s.name]);const v=$({queryKey:["telegram-bot-chats",s.id],enabled:l,queryFn:async()=>{const i=await fetch(`/api/settings/telegram/bots/${s.id}/chats`);if(!i.ok)throw new Error(await K(i,a("telegram.loadChatsFailed")));return await i.json()}}),N=d.useMemo(()=>{var k;const i=((k=v.data)==null?void 0:k.chats)??[];return{pending:i.filter(Q=>Q.status==="pending"),authorized:i.filter(Q=>Q.status==="authorized")}},[(P=v.data)==null?void 0:P.chats]),S=b({mutationFn:async()=>{const i={name:h,enabled:g,allowAuthRequests:m};x.trim()&&(i.token=x.trim());const k=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!k.ok)throw new Error(await K(k,a("telegram.updateFailed")))},onSuccess:async()=>{r(""),await o.invalidateQueries({queryKey:["telegram-bots"]}),u.success(a("common.success"))},onError:i=>{u.error(i instanceof Error?i.message:a("common.error"))}}),T=b({mutationFn:async()=>{const i=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"DELETE"});if(!i.ok)throw new Error(await K(i,a("telegram.deleteFailed")))},onSuccess:async()=>{await o.invalidateQueries({queryKey:["telegram-bots"]}),u.success(a("common.success"))},onError:i=>{u.error(i instanceof Error?i.message:a("common.error"))}}),c=b({mutationFn:async i=>{const k=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(i)}/approve`,{method:"POST"});if(!k.ok)throw new Error(await K(k,a("telegram.approveFailed")))},onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:["telegram-bots"]}),o.invalidateQueries({queryKey:["telegram-bot-chats",s.id]})]),u.success(a("common.success"))},onError:i=>{u.error(i instanceof Error?i.message:a("common.error"))}}),E=b({mutationFn:async i=>{const k=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(i)}`,{method:"DELETE"});if(!k.ok)throw new Error(await K(k,a("telegram.removeFailed")))},onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:["telegram-bots"]}),o.invalidateQueries({queryKey:["telegram-bot-chats",s.id]})]),u.success(a("common.success"))},onError:i=>{u.error(i instanceof Error?i.message:a("common.error"))}}),j=b({mutationFn:async i=>{const k=await fetch(`/api/settings/telegram/bots/${s.id}/chats/${encodeURIComponent(i)}/test`,{method:"POST"});if(!k.ok)throw new Error(await K(k,a("telegram.testMessageFailed")))},onSuccess:()=>{u.success(a("common.success"))},onError:i=>{u.error(i instanceof Error?i.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(w,{variant:"ghost","data-testid":`telegram-bot-toggle-${s.id}`,onClick:t,children:a(l?"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:h,onChange:i=>f(i.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:x,onChange:i=>r(i.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:g,onCheckedChange:i=>y(!!i)})]})}),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:i=>p(!!i)})]})})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end",children:[e.jsxs(w,{variant:"destructive","data-testid":`telegram-bot-delete-${s.id}`,onClick:()=>T.mutate(),className:"w-full sm:w-auto",children:[e.jsx(z,{className:"h-4 w-4"}),a("telegram.deleteBot")]}),e.jsxs(w,{variant:"default","data-testid":`telegram-bot-save-${s.id}`,onClick:()=>S.mutate(),className:"w-full sm:w-auto",children:[e.jsx(q,{className:"h-4 w-4"}),a("common.save")]})]}),l&&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(Ge,{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(i=>e.jsx(Ye,{chat:i,pending:!0,onApprove:()=>c.mutate(i.chatId),onDelete:()=>E.mutate(i.chatId)},`${i.botId}-${i.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(Ge,{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(i=>e.jsx(Ye,{chat:i,pending:!1,onTest:()=>j.mutate(i.chatId),onDelete:()=>E.mutate(i.chatId)},`${i.botId}-${i.chatId}`))]}),v.isLoading&&e.jsx("div",{className:"lg:col-span-2 text-xs text-muted-foreground",children:a("common.loading")})]})]})}function Ye({chat:s,pending:l,onApprove:t,onDelete:a,onTest:o}){const{t:h}=M(),f=as(x=>{var r;return((r=x.settings)==null?void 0:r.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:[h("telegram.chatId"),":",s.chatId]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(s.appliedAt).toLocaleString(ns(f))}),e.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:l?e.jsxs(e.Fragment,{children:[e.jsx(w,{variant:"outline",size:"sm",onClick:a,children:h("telegram.reject")}),e.jsx(w,{variant:"default",size:"sm",onClick:t,children:h("telegram.authorize")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(w,{variant:"secondary",size:"sm",onClick:o,children:[e.jsx(ws,{className:"h-3.5 w-3.5"}),h("telegram.sendTestMessage")]}),e.jsx(w,{variant:"destructive",size:"sm",onClick:a,children:h("common.delete")})]})})]})}function Vs(){const{t:s}=M();return e.jsx(e.Fragment,{children:s("sidebar.settings")})}function Js(){const{t:s}=M(),[l,t]=d.useState(!1),a=b({mutationFn:async()=>{const o=await fetch("/api/settings/restart",{method:"POST"});if(!o.ok)throw new Error(await K(o,s("settings.restartFailed")))},onSuccess:()=>{u.success(s("settings.restartScheduled"))},onError:o=>{u.error(o instanceof Error?o.message:s("common.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(w,{variant:"ghost",size:"icon-sm",onClick:()=>t(!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(Cs,{className:"h-4 w-4"})}),e.jsx(ee,{open:l,onOpenChange:t,children:e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:s("settings.restartGateway")}),e.jsx(ne,{children:s("settings.restartConfirm")})]}),e.jsxs(ie,{children:[e.jsx(le,{onClick:()=>t(!1),children:s("common.cancel")}),e.jsx(re,{variant:"destructive",onClick:()=>{a.mutate(),t(!1)},children:s("common.confirm")})]})]})})]})}export{Js as PageActions,Vs as PageTitle,Hs as default};
|
|
22
|
+
//# sourceMappingURL=SettingsPage-Cfzr_Phh.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-DUipsjFg.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(on(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<an)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|
|
2
|
+
//# sourceMappingURL=arc-Wv219fq_.js.map
|