tmex-cli 0.10.0 → 0.12.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/CHANGELOG.md +43 -0
- package/dist/runtime/server.js +1339 -135
- package/package.json +4 -3
- package/resources/fe-dist/assets/DevicePage-B2xsa-ys.js +21 -0
- package/resources/fe-dist/assets/DevicesPage-Bm7E9QAf.js +2 -0
- package/resources/fe-dist/assets/FilePage-DtXS6Krk.js +16 -0
- package/resources/fe-dist/assets/SettingsPage-Bxat-d_V.js +32 -0
- package/resources/fe-dist/assets/{arc-Wv219fq_.js → arc-CWkT1O24.js} +2 -2
- package/resources/fe-dist/assets/{architectureDiagram-3BPJPVTR-DkPPo2hY.js → architectureDiagram-3BPJPVTR-nu1LX68y.js} +2 -2
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-DPAThozG.js → blockDiagram-GPEHLZMM-DLFLNzT_.js} +2 -2
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-DBs_N-_p.js → c4Diagram-AAUBKEIU-BE8aWxc1.js} +2 -2
- package/resources/fe-dist/assets/{card-Dl0HC88A.js → card-Duis2VHj.js} +2 -2
- package/resources/fe-dist/assets/channel-zKL2OH3S.js +2 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-D3mrUPCp.js → chunk-2J33WTMH-Dlc3MV0y.js} +2 -2
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-C0DRv58j.js → chunk-4BX2VUAB-E9XGobks.js} +2 -2
- package/resources/fe-dist/assets/{chunk-55IACEB6-DheUp7iQ.js → chunk-55IACEB6-Bp7ueFZf.js} +2 -2
- package/resources/fe-dist/assets/{chunk-727SXJPM-Cvew2yIJ.js → chunk-727SXJPM-CQrvyHfQ.js} +2 -2
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-DUoa4Wdg.js → chunk-AQP2D5EJ-c0B1XNZr.js} +2 -2
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-Bt9Oi52P.js → chunk-FMBD7UC4-BWQBkKWs.js} +2 -2
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-DlWpyDaS.js → chunk-ND2GUHAM-D9TROogS.js} +2 -2
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-BZtXwgRW.js → chunk-QZHKN3VN-DRXr6zVP.js} +2 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-Drw216KI.js +2 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-Drw216KI.js +2 -0
- package/resources/fe-dist/assets/{cose-bilkent-S5V4N54A-yKy6sTY_.js → cose-bilkent-S5V4N54A-CBgJRn7g.js} +2 -2
- package/resources/fe-dist/assets/{dagre-BM42HDAG-DL4fpno6.js → dagre-BM42HDAG-ClYznWvX.js} +2 -2
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-BueYws-9.js → diagram-2AECGRRQ-Br_41uIc.js} +2 -2
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-GQEQSUeb.js → diagram-5GNKFQAL-BD9o1BrS.js} +2 -2
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-LE3yI4ed.js → diagram-KO2AKTUF-Diq2zS9Y.js} +2 -2
- package/resources/fe-dist/assets/{diagram-LMA3HP47-BkHjYrU4.js → diagram-LMA3HP47-CLaOalPy.js} +2 -2
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-DrnHic-P.js → diagram-OG6HWLK6-BcSlvdPy.js} +2 -2
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-BCwWv-rO.js → erDiagram-TEJ5UH35-BNlad0c4.js} +2 -2
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-DEC2Z_fh.js → flowDiagram-I6XJVG4X-Zb1FLY00.js} +2 -2
- package/resources/fe-dist/assets/{ganttDiagram-6RSMTGT7-H1T5bCsY.js → ganttDiagram-6RSMTGT7-DPRPR5Is.js} +2 -2
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-DmZUfKfl.js → gitGraphDiagram-PVQCEYII-BENU2uEN.js} +2 -2
- package/resources/fe-dist/assets/index-CRCD4gPw.css +1 -0
- package/resources/fe-dist/assets/index-Den36xcn.js +488 -0
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-fDOg9Qr5.js → infoDiagram-5YYISTIA-NfMlH21e.js} +2 -2
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-QIvSJI3q.js → ishikawaDiagram-YF4QCWOH-CzK9-7uY.js} +2 -2
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-Iz7u4iH8.js → journeyDiagram-JHISSGLW-CIX5Ahuw.js} +2 -2
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-BYiFSFgn.js → kanban-definition-UN3LZRKU-C5Ccl5Cw.js} +2 -2
- package/resources/fe-dist/assets/{linear-DNHZFKop.js → linear-CBC08yeS.js} +2 -2
- package/resources/fe-dist/assets/markdown-preview-Bf_6UH9R.css +1 -0
- package/resources/fe-dist/assets/markdown-preview-Drd503bU.js +269 -0
- package/resources/fe-dist/assets/{mermaid.core-DUipsjFg.js → mermaid.core-DYl6mxS0.js} +6 -6
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-tPbrKC3m.js → mindmap-definition-RKZ34NQL-ACR2SUDm.js} +2 -2
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-26o8qBzb.js → pieDiagram-4H26LBE5-BuDDdwwy.js} +2 -2
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-BgpGo9Ak.js → quadrantDiagram-W4KKPZXB-CzM2Ydhy.js} +2 -2
- package/resources/fe-dist/assets/{refresh-cw-DdcimDhs.js → refresh-cw-DhzvbVDA.js} +2 -2
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-BEfrxsDZ.js → requirementDiagram-4Y6WPE33-BveKh_kW.js} +2 -2
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-BuIeHyjh.js → sankeyDiagram-5OEKKPKP-BGQ6jtyE.js} +2 -2
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-CL0sinOn.js → sequenceDiagram-3UESZ5HK-D2fdqire.js} +2 -2
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-BCq5X6hO.js → stateDiagram-AJRCARHV-DtuVBIq9.js} +2 -2
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-gun__PvU.js +2 -0
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-CnqqA91O.js → timeline-definition-PNZ67QCA-Dslo0JFS.js} +2 -2
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-BqFG3JXB.js → vennDiagram-CIIHVFJN-BLcoN4xU.js} +2 -2
- package/resources/fe-dist/assets/{wardley-L42UT6IY-DvfZKNwT.js → wardley-L42UT6IY-OsbD5r1L.js} +2 -2
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-DlABpMGt.js → wardleyDiagram-YWT4CUSO-B_33zIif.js} +2 -2
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-BDiyUuus.js → xychartDiagram-2RQKCTM6-DcB27Ap1.js} +2 -2
- package/resources/fe-dist/fonts/GeistMonoNerdFontMono-Bold.woff2 +0 -0
- package/resources/fe-dist/fonts/GeistMonoNerdFontMono-Regular.woff2 +0 -0
- package/resources/fe-dist/index.html +2 -2
- package/resources/fe-dist/tmex-maskable.png +0 -0
- package/resources/fe-dist/tmex.png +0 -0
- package/resources/fe-dist/assets/DevicePage-5vkaNOjl.js +0 -26
- package/resources/fe-dist/assets/DevicesPage-CKnRUGQm.js +0 -2
- package/resources/fe-dist/assets/FilePage-Dj0cszD4.css +0 -1
- package/resources/fe-dist/assets/FilePage-Uj-tzGW7.js +0 -283
- package/resources/fe-dist/assets/SettingsPage-Cfzr_Phh.js +0 -22
- package/resources/fe-dist/assets/channel-DyLhDM_y.js +0 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-DA8DiM06.js +0 -2
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-DA8DiM06.js +0 -2
- package/resources/fe-dist/assets/index-OpBFduyh.js +0 -466
- package/resources/fe-dist/assets/index-yMgNjHUH.css +0 -1
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-DH2ctCND.js +0 -2
- package/resources/fe-dist/fonts/GeistMono-Bold.woff2 +0 -0
- package/resources/fe-dist/fonts/GeistMono-Regular.woff2 +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-Cvew2yIJ.js";import{_ as i}from"./mermaid.core-DUipsjFg.js";import"./chunk-FMBD7UC4-Bt9Oi52P.js";import"./chunk-ND2GUHAM-DlWpyDaS.js";import"./chunk-55IACEB6-DheUp7iQ.js";import"./chunk-2J33WTMH-D3mrUPCp.js";import"./index-OpBFduyh.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
2
|
-
//# sourceMappingURL=classDiagram-4FO5ZUOK-DA8DiM06.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-Cvew2yIJ.js";import{_ as i}from"./mermaid.core-DUipsjFg.js";import"./chunk-FMBD7UC4-Bt9Oi52P.js";import"./chunk-ND2GUHAM-DlWpyDaS.js";import"./chunk-55IACEB6-DheUp7iQ.js";import"./chunk-2J33WTMH-D3mrUPCp.js";import"./index-OpBFduyh.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
2
|
-
//# sourceMappingURL=classDiagram-v2-Q7XG4LA2-DA8DiM06.js.map
|