local-operator-ui 0.35.0 → 0.35.2
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/out/main/index.js +614 -16
- package/out/renderer/assets/{_basePickBy-DXcdlCne.js → _basePickBy-NBZVf3x_.js} +1 -1
- package/out/renderer/assets/{_baseUniq-59s2A3Xi.js → _baseUniq-BpOXfy9b.js} +1 -1
- package/out/renderer/assets/{agent-details-page-DzCMByBi.js → agent-details-page-CI5V0mco.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-DJCaMoAj.js → agent-hub-page-C7UV5Z02.js} +1 -1
- package/out/renderer/assets/{agents-page-jAx30gRr.js → agents-page-BHUCzpZE.js} +3 -3
- package/out/renderer/assets/{arc-DTGY_Lgi.js → arc-DTlm2-sN.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-C1eZGb9i.js → architectureDiagram-IEHRJDOE-uA5hYBWO.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-DcFFqP3h.js → blockDiagram-JOT3LUYC-Awo08lrR.js} +1 -1
- package/out/renderer/assets/{book-open-Bi2GxPj-.js → book-open-DBUibLWP.js} +1 -1
- package/out/renderer/assets/browser-page-DuKCLrh5.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DcHbqaLn.js → browser-webauthn-prompt-egKdqzbk.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-CzUO0Dxd.js → c4Diagram-VJAJSXHY-DAHoIxNf.js} +1 -1
- package/out/renderer/assets/channel-BZ9uCAQo.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-mCAjVMxO.js → chunk-4BMEZGHF-QvFtu74J.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-D6-zo_Fr.js → chunk-A2AXSNBT-EcRDJZN6.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-B3ngikm8.js → chunk-AEK57VVT-CKf_yBAg.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-ChTXeHBQ.js → chunk-D6G4REZN-CoixV4aq.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D2c3_Jya.js → chunk-RZ5BOZE2-CtEEDTp-.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BTrxUgxT.js → chunk-XZIHB7SX-BOgT03N8.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D6kkk-4_.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D6kkk-4_.js +1 -0
- package/out/renderer/assets/clone-BgCd73kI.js +1 -0
- package/out/renderer/assets/{console-mirror-Dc1bE9Vm.js → console-mirror-D7dfGxrD.js} +1 -1
- package/out/renderer/assets/{consoleCapture-Wr6s4sLo.js → consoleCapture-DczATgZh.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-C-0MXqyt.js → conversation-input-sync-GlFEQKuo.js} +265 -259
- package/out/renderer/assets/{dagre-OKDRZEBW-B9TiRiqo.js → dagre-OKDRZEBW-CijtV3o0.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-1SfE1-5B.js → diagram-SSKATNLV-Dxx1RpmY.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-l4dzkACu.js → diagram-VNBRO52H-DZg2hjvO.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CUgpeoFK.js → erDiagram-Q7BY3M3F-CjvMMGLo.js} +1 -1
- package/out/renderer/assets/{error-boundary-C9PRNlmT.js → error-boundary-CLT6U8jT.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-T5JJ4Xtw.js → flowDiagram-4HSFHLVR-EjagIE01.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DQ2mySlQ.js → ganttDiagram-APWFNJXF-OfsWfUyW.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-C9DZfwGd.js → gitGraphDiagram-7IBYFJ6S-nYTyKs0s.js} +1 -1
- package/out/renderer/assets/{graph-TsL6qeA-.js → graph-BnL8m22f.js} +1 -1
- package/out/renderer/assets/{index-rSXvFxM8.js → index-C866kR_k.js} +1 -1
- package/out/renderer/assets/index-CGcU9-Py.css +1 -0
- package/out/renderer/assets/{index-P4i-q0KF.js → index-CO7sxKWb.js} +1 -1
- package/out/renderer/assets/index-Cj2bZws8.js +57 -0
- package/out/renderer/assets/{index-D8u5NmIa.js → index-p3NO0LL-.js} +204 -204
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-U47NbuL3.js → infoDiagram-PH2N3AL5-LE2dCnxc.js} +1 -1
- package/out/renderer/assets/{installer-fluCVssE.js → installer-Wpfa8xHM.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-Bo7dozG5.js → journeyDiagram-U35MCT3I-BhpegMd0.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-Bn0hKA3l.js → kanban-definition-NDS4AKOZ-OoMW68Bt.js} +1 -1
- package/out/renderer/assets/{layout-CnIEnr3t.js → layout-BdaXfJXz.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-pxEj7cjk.js → legacy-agents-page-lVj0d18U.js} +1 -1
- package/out/renderer/assets/{mermaid.core-lUsLZpuU.js → mermaid.core-DmdT5IgP.js} +5 -5
- package/out/renderer/assets/{mesh-page-vihuNvox.js → mesh-page-D0-4HVNk.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DtB-t5TL.js → mindmap-definition-ALO5MXBD-BCXX8n68.js} +1 -1
- package/out/renderer/assets/{mini--p2d2BoB.js → mini-DsJCW_H3.js} +1 -1
- package/out/renderer/assets/{notebook-pen-C-602S82.js → notebook-pen-CAZF-xgd.js} +1 -1
- package/out/renderer/assets/{org-access-DwKpT4sY.js → org-access-DCQGHh2Y.js} +1 -1
- package/out/renderer/assets/{org-surface-gate--inYykb1.js → org-surface-gate-Cq3kOR7u.js} +1 -1
- package/out/renderer/assets/{page-header-Cz4WU8y6.js → page-header-CQ6qN4O4.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-kHXX0Qj3.js → pieDiagram-IB7DONF6-BRK1MBQO.js} +1 -1
- package/out/renderer/assets/{projects-page-B9Y4di7i.js → projects-page-DpAhuoA7.js} +2 -2
- package/out/renderer/assets/{publication-validation-LQ7dKLdu.js → publication-validation-CZn6wbD0.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Da2X85Fu.js → quadrantDiagram-7GDLP6J5-CtQwUI4m.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-C0d75XBo.js → radar-MK3ICKWK-o9_lRR0v.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DQVWpG8o.js → radient-auth-buttons-BWhD8ldO.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CL-Kku_X.js → requirementDiagram-KVF5MWMF-aEEiUjHx.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DWUg1eAE.js → sankeyDiagram-QLVOVGJD-CtjAQQYG.js} +1 -1
- package/out/renderer/assets/{schedules-page-B7tSQfbG.js → schedules-page-C4-FWwsb.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Bn0FlGHo.js → sequenceDiagram-X6HHIX6F-QOpgwrwA.js} +1 -1
- package/out/renderer/assets/{settings-page-Dty0ZTmK.js → settings-page-BJZ7ozTY.js} +59 -64
- package/out/renderer/assets/{stateDiagram-DGXRK772-CkdY_hLZ.js → stateDiagram-DGXRK772-D99A_n2H.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D0CTAsLQ.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-DodPShzl.js → timeline-definition-BDJGKUSR-C_Op_i7D.js} +1 -1
- package/out/renderer/assets/{ui-preferences-store-B_KwjcMZ.js → ui-preferences-store-Dz1Kg_SA.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-CIiU8sRW.js → use-download-agent-mutation-PP3ZbZ7V.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-BMOJPwWD.js → use-memberships-query-TOFQHH-q.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-B0aCKABJ.js → use-session-snapshot-BOMni_bJ.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BRifY3vn.js → xychartDiagram-VJFVF3MP-Bq2H6JYU.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-Bnzl2Fck.js +0 -1
- package/out/renderer/assets/channel-CBLzxDK-.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BnE_q2SF.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BnE_q2SF.js +0 -1
- package/out/renderer/assets/clone-Ctta4hua.js +0 -1
- package/out/renderer/assets/index-8yv29dzU.js +0 -57
- package/out/renderer/assets/index-Bk16DqRh.css +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CWy168Js.js +0 -1
|
@@ -1,292 +1,287 @@
|
|
|
1
|
-
import{r,t as n,j as t,c as ue,e as xs,L as ys}from"./index-
|
|
1
|
+
import{r,t as n,j as t,c as ue,e as xs,L as ys}from"./index-Cj2bZws8.js";import{cw as It,cx as ks,cy as sn,cz as Ce,bQ as bs,C as be,ah as Rn,ai as Bt,a4 as En,u as Ht,aK as vs,aL as js,cA as ws,cB as Ns,cC as Ss,cD as Cs,cE as Tn,cF as Vt,af as Ln,cG as Ms,cH as As,aP as it,cI as an,cJ as Fe,a as Gt,c as Rt,cK as Is,cL as ot,cM as Rs,bm as Es,cN as Ts,cO as Ls,cP as Os,cQ as Fs,d as de,cR as Et,bE as On,cS as qt,cT as rt,bq as Ds,cU as Fn,ad as zs,cV as Ps,cW as $s,cX as Ks,cY as Us,Z as Yt,cZ as Bs,c_ as Hs,a3 as Dn,aR as Tt,aS as Lt,c$ as Vs,aW as Gs,cb as Ot,ar as lt,d0 as qs,d1 as Ys,d2 as Qs,d3 as Ft,d4 as Ws,d5 as Zs,d6 as Js,aN as Xs,d7 as zn,d8 as ea,d9 as ta,da as na,B as sa,db as Pn,aQ as $n,dc as Kn,dd as aa,de as ia,df as oa,dg as ra,dh as la,di as ca,dj as da,dk as ua,D as ma,bL as Un,aX as ga,bl as _a,dl as He,dm as Dt,dn as on,dp as pa,dq as ha,dr as fa,ds as xa,by as ya,dt as ka,bT as ba,du as va,bS as ja,dv as wa,dw as Na,dx as rn,dy as Sa,dz as Ca,dA as Ma,dB as Aa}from"./conversation-input-sync-GlFEQKuo.js";import{K as Ia,u as Me,n as Ra,o as Ea,q as Ta,T as La,r as Bn}from"./ui-preferences-store-Dz1Kg_SA.js";import{bh as Hn,bi as Oa,bj as Fa,bk as ce,b1 as ht,b2 as _e,bl as Da,bg as za,bm as Pa,aH as ln,bn as $a,bo as Ka,bp as Xe,S as Ua,b0 as Ba,bq as Ha,br as Va,bs as Ga,bt as qa,bu as Ya,bv as Qa,aS as cn,bw as Wa,aN as Za,aZ as dn,bx as Ja,a_ as Xa,a$ as ei,by as ti,bz as ni}from"./index-p3NO0LL-.js";import{P as si}from"./page-header-CQ6qN4O4.js";import{c as M,u as ee,B as G,S as he,M as ai,l as Ke,Y as gt,Z as _t,_ as $e,F as ii,G as oi,H as ri,J as li,K as ci,a0 as pt,N as di,A as oe,m as ui,n as et,k as Oe,z as qe,I as Ae,C as zt,ab as mi,g as Vn,L as we,ac as un,T as Gn,q as gi,r as _i,s as pi,v as hi,w as mn,p as fi,E as xi,ad as yi,a4 as ki}from"./error-boundary-CLT6U8jT.js";import{R as bi}from"./radient-auth-buttons-BWhD8ldO.js";import{N as vi}from"./notebook-pen-CAZF-xgd.js";import{B as ji}from"./book-open-DBUibLWP.js";import{a as wi,p as jt}from"./parseISO-BHJWTxrA.js";import{i as Ni,a as Le,f as Si}from"./format-esAOn2VS.js";import{t as Ci}from"./en-US-CHJkXXr4.js";import"./console-mirror-D7dfGxrD.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Mi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]],Ai=M("aperture",Mi);/**
|
|
7
7
|
* @license lucide-react v0.507.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Ii=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]],Ri=M("atom",Ii);/**
|
|
12
12
|
* @license lucide-react v0.507.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Ei=[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]],Ti=M("audio-waveform",Ei);/**
|
|
17
17
|
* @license lucide-react v0.507.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Li=[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]],Oi=M("binary",Li);/**
|
|
22
22
|
* @license lucide-react v0.507.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Fi=[["path",{d:"M10 7v10.9",key:"1gynux"}],["path",{d:"M14 6.1V17",key:"116kdf"}],["path",{d:"M16 7V3a1 1 0 0 1 1.707-.707 2.5 2.5 0 0 0 2.152.717 1 1 0 0 1 1.131 1.131 2.5 2.5 0 0 0 .717 2.152A1 1 0 0 1 21 8h-4",key:"gpb6xx"}],["path",{d:"M16.536 7.465a5 5 0 0 0-7.072 0l-2 2a5 5 0 0 0 0 7.07 5 5 0 0 0 7.072 0l2-2a5 5 0 0 0 0-7.07",key:"1tsln4"}],["path",{d:"M8 17v4a1 1 0 0 1-1.707.707 2.5 2.5 0 0 0-2.152-.717 1 1 0 0 1-1.131-1.131 2.5 2.5 0 0 0-.717-2.152A1 1 0 0 1 3 16h4",key:"qexcha"}]],Di=M("candy",Fi);/**
|
|
27
27
|
* @license lucide-react v0.507.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const zi=[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]],Pi=M("car-front",zi);/**
|
|
32
32
|
* @license lucide-react v0.507.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const $i=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]],Ki=M("cassette-tape",$i);/**
|
|
37
37
|
* @license lucide-react v0.507.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Ui=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Bi=M("chart-line",Ui);/**
|
|
42
42
|
* @license lucide-react v0.507.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Hi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Vi=M("circle-plus",Hi);/**
|
|
47
47
|
* @license lucide-react v0.507.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const Gi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]],qi=M("circuit-board",Gi);/**
|
|
52
52
|
* @license lucide-react v0.507.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const Yi=[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]],Qi=M("cloud-lightning",Yi);/**
|
|
57
57
|
* @license lucide-react v0.507.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const Wi=[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]],Zi=M("cloud-moon",Wi);/**
|
|
62
62
|
* @license lucide-react v0.507.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const Ji=[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]],Xi=M("cloud-snow",Ji);/**
|
|
67
67
|
* @license lucide-react v0.507.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const eo=[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]],to=M("cloud-sun",eo);/**
|
|
72
72
|
* @license lucide-react v0.507.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const no=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],so=M("coffee",no);/**
|
|
77
77
|
* @license lucide-react v0.507.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const ao=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]],qn=M("contrast",ao);/**
|
|
82
82
|
* @license lucide-react v0.507.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const io=[["
|
|
86
|
+
*/const io=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],oo=M("credit-card",io);/**
|
|
87
87
|
* @license lucide-react v0.507.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const ro=[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]],lo=M("cup-soda",ro);/**
|
|
92
92
|
* @license lucide-react v0.507.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
96
|
+
*/const co=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]],uo=M("disc-3",co);/**
|
|
97
97
|
* @license lucide-react v0.507.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const mo=[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]],go=M("droplet",mo);/**
|
|
102
102
|
* @license lucide-react v0.507.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const _o=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],po=M("droplets",_o);/**
|
|
107
107
|
* @license lucide-react v0.507.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const ho=[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]],fo=M("fish",ho);/**
|
|
112
112
|
* @license lucide-react v0.507.0 - ISC
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
116
|
+
*/const xo=[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]],yo=M("flame",xo);/**
|
|
117
117
|
* @license lucide-react v0.507.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const ko=[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]],bo=M("flower-2",ko);/**
|
|
122
122
|
* @license lucide-react v0.507.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
125
125
|
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const
|
|
126
|
+
*/const vo=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]],jo=M("flower",vo);/**
|
|
127
127
|
* @license lucide-react v0.507.0 - ISC
|
|
128
128
|
*
|
|
129
129
|
* This source code is licensed under the ISC license.
|
|
130
130
|
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const
|
|
131
|
+
*/const wo=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],No=M("ghost",wo);/**
|
|
132
132
|
* @license lucide-react v0.507.0 - ISC
|
|
133
133
|
*
|
|
134
134
|
* This source code is licensed under the ISC license.
|
|
135
135
|
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const
|
|
136
|
+
*/const So=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Co=M("github",So);/**
|
|
137
137
|
* @license lucide-react v0.507.0 - ISC
|
|
138
138
|
*
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
140
140
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const
|
|
141
|
+
*/const Mo=[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.23 9.85A3 3 0 0 1 11 8a5 5 0 0 1 5 5 3 3 0 0 1-1.85 2.77l-.92.38A2 2 0 0 0 12 18a4 4 0 0 1-4 4 6 6 0 0 1-6-6 4 4 0 0 1 4-4 2 2 0 0 0 1.85-1.23z",key:"1de1vg"}]],Ao=M("guitar",Mo);/**
|
|
142
142
|
* @license lucide-react v0.507.0 - ISC
|
|
143
143
|
*
|
|
144
144
|
* This source code is licensed under the ISC license.
|
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const
|
|
146
|
+
*/const Io=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],Ro=M("hexagon",Io);/**
|
|
147
147
|
* @license lucide-react v0.507.0 - ISC
|
|
148
148
|
*
|
|
149
149
|
* This source code is licensed under the ISC license.
|
|
150
150
|
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const
|
|
151
|
+
*/const Eo=[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]],To=M("ice-cream-bowl",Eo);/**
|
|
152
152
|
* @license lucide-react v0.507.0 - ISC
|
|
153
153
|
*
|
|
154
154
|
* This source code is licensed under the ISC license.
|
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const
|
|
156
|
+
*/const Lo=[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]],Oo=M("joystick",Lo);/**
|
|
157
157
|
* @license lucide-react v0.507.0 - ISC
|
|
158
158
|
*
|
|
159
159
|
* This source code is licensed under the ISC license.
|
|
160
160
|
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const
|
|
161
|
+
*/const Fo=[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]],Do=M("leaf",Fo);/**
|
|
162
162
|
* @license lucide-react v0.507.0 - ISC
|
|
163
163
|
*
|
|
164
164
|
* This source code is licensed under the ISC license.
|
|
165
165
|
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const
|
|
166
|
+
*/const zo=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Po=M("lightbulb",zo);/**
|
|
167
167
|
* @license lucide-react v0.507.0 - ISC
|
|
168
168
|
*
|
|
169
169
|
* This source code is licensed under the ISC license.
|
|
170
170
|
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const
|
|
171
|
+
*/const $o=[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]],Ko=M("milk",$o);/**
|
|
172
172
|
* @license lucide-react v0.507.0 - ISC
|
|
173
173
|
*
|
|
174
174
|
* This source code is licensed under the ISC license.
|
|
175
175
|
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const
|
|
176
|
+
*/const Uo=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]],Bo=M("moon-star",Uo);/**
|
|
177
177
|
* @license lucide-react v0.507.0 - ISC
|
|
178
178
|
*
|
|
179
179
|
* This source code is licensed under the ISC license.
|
|
180
180
|
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const
|
|
181
|
+
*/const Ho=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Vo=M("moon",Ho);/**
|
|
182
182
|
* @license lucide-react v0.507.0 - ISC
|
|
183
183
|
*
|
|
184
184
|
* This source code is licensed under the ISC license.
|
|
185
185
|
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const
|
|
186
|
+
*/const Go=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]],qo=M("mountain-snow",Go);/**
|
|
187
187
|
* @license lucide-react v0.507.0 - ISC
|
|
188
188
|
*
|
|
189
189
|
* This source code is licensed under the ISC license.
|
|
190
190
|
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const
|
|
191
|
+
*/const Yo=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Qo=M("mountain",Yo);/**
|
|
192
192
|
* @license lucide-react v0.507.0 - ISC
|
|
193
193
|
*
|
|
194
194
|
* This source code is licensed under the ISC license.
|
|
195
195
|
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const
|
|
196
|
+
*/const Wo=[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]],Zo=M("radio",Wo);/**
|
|
197
197
|
* @license lucide-react v0.507.0 - ISC
|
|
198
198
|
*
|
|
199
199
|
* This source code is licensed under the ISC license.
|
|
200
200
|
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const
|
|
201
|
+
*/const Jo=[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]],Xo=M("sailboat",Jo);/**
|
|
202
202
|
* @license lucide-react v0.507.0 - ISC
|
|
203
203
|
*
|
|
204
204
|
* This source code is licensed under the ISC license.
|
|
205
205
|
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const
|
|
206
|
+
*/const er=[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]],tr=M("shirt",er);/**
|
|
207
207
|
* @license lucide-react v0.507.0 - ISC
|
|
208
208
|
*
|
|
209
209
|
* This source code is licensed under the ISC license.
|
|
210
210
|
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const
|
|
211
|
+
*/const nr=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],sr=M("skull",nr);/**
|
|
212
212
|
* @license lucide-react v0.507.0 - ISC
|
|
213
213
|
*
|
|
214
214
|
* This source code is licensed under the ISC license.
|
|
215
215
|
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const
|
|
216
|
+
*/const ar=[["path",{d:"m10 20-1.25-2.5L6 18",key:"18frcb"}],["path",{d:"M10 4 8.75 6.5 6 6",key:"7mghy3"}],["path",{d:"m14 20 1.25-2.5L18 18",key:"1chtki"}],["path",{d:"m14 4 1.25 2.5L18 6",key:"1b4wsy"}],["path",{d:"m17 21-3-6h-4",key:"15hhxa"}],["path",{d:"m17 3-3 6 1.5 3",key:"11697g"}],["path",{d:"M2 12h6.5L10 9",key:"kv9z4n"}],["path",{d:"m20 10-1.5 2 1.5 2",key:"1swlpi"}],["path",{d:"M22 12h-6.5L14 15",key:"1mxi28"}],["path",{d:"m4 10 1.5 2L4 14",key:"k9enpj"}],["path",{d:"m7 21 3-6-1.5-3",key:"j8hb9u"}],["path",{d:"m7 3 3 6h4",key:"1otusx"}]],ir=M("snowflake",ar);/**
|
|
217
217
|
* @license lucide-react v0.507.0 - ISC
|
|
218
218
|
*
|
|
219
219
|
* This source code is licensed under the ISC license.
|
|
220
220
|
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const
|
|
221
|
+
*/const or=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]],rr=M("sparkle",or);/**
|
|
222
222
|
* @license lucide-react v0.507.0 - ISC
|
|
223
223
|
*
|
|
224
224
|
* This source code is licensed under the ISC license.
|
|
225
225
|
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const
|
|
226
|
+
*/const lr=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]],cr=M("sun-dim",lr);/**
|
|
227
227
|
* @license lucide-react v0.507.0 - ISC
|
|
228
228
|
*
|
|
229
229
|
* This source code is licensed under the ISC license.
|
|
230
230
|
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const
|
|
231
|
+
*/const dr=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ur=M("sun",dr);/**
|
|
232
232
|
* @license lucide-react v0.507.0 - ISC
|
|
233
233
|
*
|
|
234
234
|
* This source code is licensed under the ISC license.
|
|
235
235
|
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const
|
|
236
|
+
*/const mr=[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],gr=M("sunrise",mr);/**
|
|
237
237
|
* @license lucide-react v0.507.0 - ISC
|
|
238
238
|
*
|
|
239
239
|
* This source code is licensed under the ISC license.
|
|
240
240
|
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const
|
|
241
|
+
*/const _r=[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],pr=M("sunset",_r);/**
|
|
242
242
|
* @license lucide-react v0.507.0 - ISC
|
|
243
243
|
*
|
|
244
244
|
* This source code is licensed under the ISC license.
|
|
245
245
|
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
-
*/const
|
|
246
|
+
*/const hr=[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]],fr=M("tent",hr);/**
|
|
247
247
|
* @license lucide-react v0.507.0 - ISC
|
|
248
248
|
*
|
|
249
249
|
* This source code is licensed under the ISC license.
|
|
250
250
|
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const
|
|
251
|
+
*/const xr=[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]],yr=M("tree-deciduous",xr);/**
|
|
252
252
|
* @license lucide-react v0.507.0 - ISC
|
|
253
253
|
*
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
255
255
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const
|
|
256
|
+
*/const kr=[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]],br=M("tree-palm",kr);/**
|
|
257
257
|
* @license lucide-react v0.507.0 - ISC
|
|
258
258
|
*
|
|
259
259
|
* This source code is licensed under the ISC license.
|
|
260
260
|
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
-
*/const
|
|
261
|
+
*/const vr=[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]],jr=M("tree-pine",vr);/**
|
|
262
262
|
* @license lucide-react v0.507.0 - ISC
|
|
263
263
|
*
|
|
264
264
|
* This source code is licensed under the ISC license.
|
|
265
265
|
* See the LICENSE file in the root directory of this source tree.
|
|
266
|
-
*/const
|
|
266
|
+
*/const wr=[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]],Nr=M("trees",wr);/**
|
|
267
267
|
* @license lucide-react v0.507.0 - ISC
|
|
268
268
|
*
|
|
269
269
|
* This source code is licensed under the ISC license.
|
|
270
270
|
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
-
*/const
|
|
271
|
+
*/const Sr=[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]],Cr=M("umbrella",Sr);/**
|
|
272
272
|
* @license lucide-react v0.507.0 - ISC
|
|
273
273
|
*
|
|
274
274
|
* This source code is licensed under the ISC license.
|
|
275
275
|
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
-
*/const
|
|
276
|
+
*/const Mr=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],Ar=M("waves",Mr);/**
|
|
277
277
|
* @license lucide-react v0.507.0 - ISC
|
|
278
278
|
*
|
|
279
279
|
* This source code is licensed under the ISC license.
|
|
280
280
|
* See the LICENSE file in the root directory of this source tree.
|
|
281
|
-
*/const
|
|
281
|
+
*/const Ir=[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]],Rr=M("wheat",Ir);/**
|
|
282
282
|
* @license lucide-react v0.507.0 - ISC
|
|
283
283
|
*
|
|
284
284
|
* This source code is licensed under the ISC license.
|
|
285
285
|
* See the LICENSE file in the root directory of this source tree.
|
|
286
|
-
*/const Rr=[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]],Er=S("wheat",Rr);/**
|
|
287
|
-
* @license lucide-react v0.507.0 - ISC
|
|
288
|
-
*
|
|
289
|
-
* This source code is licensed under the ISC license.
|
|
290
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
291
|
-
*/const Tr=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],Lr=S("wind",Tr),Or=({appVersion:e=null,slowWaitHintMs:s})=>{ee();const a="https://local-operator.com/download",[i,o]=r.useState(!1),l=Hn(i,s??La),[d,u]=r.useState(!1),[c,m]=r.useState(null),[p,f]=r.useState("info"),[b,h]=r.useState(null),[_,w]=r.useState(null),A=e?.trim()?e.trim():null,K=r.useRef(!1),C=It(z=>z.openDetail),O=r.useRef(!1),T=r.useRef(0),L=r.useRef(!1),I=r.useCallback((z,P)=>{O.current=!1,m(z),f(P),u(!0)},[]),W=r.useCallback(z=>{O.current=!0,m(z),f("success"),u(!0)},[]),X=r.useCallback(()=>{O.current&&(O.current=!1,u(!1),m(null))},[]),{clearDeferredUpdate:J}=ks();r.useEffect(()=>{const z=window.api.updater.onUpdateError(y=>{K.current&&y.includes("manually")&&(h({message:n("ui.common.updates.check_for_updates_button.the_server_is_installed_outside_the_app_so_use_the_tool_you_insta"),command:""}),O.current=!1,m(null),f("warning"),u(!0))}),P=window.api.updater.onBackendUpdateDevMode(y=>{K.current&&I(y,"info")}),H=()=>{L.current=!0,X()},U=window.api.updater.onUpdateAvailable(H),R=window.api.updater.onUpdateNpxAvailable(H),Y=window.api.updater.onBackendUpdateAvailable(H);return()=>{z(),P(),U(),R(),Y()}},[X,I]),r.useEffect(()=>{let z=!1;const P=()=>{window.api.updater.getLastInstallAttempt().then(U=>{z||w(U)}).catch(()=>{})};P();const H=window.api.updater.onUpdateInstallFailed(()=>P());return()=>{z=!0,H()}},[]);const D=async()=>{const z=++T.current;X(),L.current=!1;try{o(!0),K.current=!0,J(Ce.UI),J(Ce.BACKEND);const P=await window.api.updater.checkForAllUpdates({manual:!0});if(z!==T.current)return;P.app==="available"&&C(Ce.UI),P.server==="available"&&C(Ce.BACKEND),P?.affirmation&&!L.current?W(P.affirmation):X()}catch(P){if(z!==T.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Oa(P)}`)}finally{z===T.current&&o(!1),setTimeout(()=>{K.current=!1},2e3)}},te=()=>{O.current=!1,u(!1),m(null)};return t.jsxs(t.Fragment,{children:[_&&t.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[t.jsxs("p",{className:"text-body-sm text-ink",children:[n("ui.common.updates.check_for_updates_button.the_last_update_to_version"),_.targetVersion," ",n("ui.common.updates.check_for_updates_button.didn_t_finish"),_.attempts>1?n("ui.common.updates.check_for_updates_button.detail",{attempts:_.attempts,attemptsText:String(_.attempts)}):"",".",A?n("ui.common.updates.check_for_updates_button.version",{liveversion:String(A)}):null]}),t.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:[n("ui.common.updates.check_for_updates_button.detected")," ",_.detectedAt?new Date(_.detectedAt).toLocaleString():"at an unknown time",". ",_.detail]}),t.jsx(G,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(a),children:n("ui.common.updates.check_for_updates_button.download_a_fresh_copy")})]}),t.jsxs(G,{variant:"outline",onClick:()=>void D(),disabled:i,children:[i?t.jsx(he,{size:"sm"}):null,i?n("ui.common.updates.check_for_updates_button.checking"):n("ui.common.updates.check_for_updates_button.check_for_updates")]}),l&&t.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.common.updates.check_for_updates_button.still_checking_a_slow_or_stalled_connection_can_hold_this_for_abo")}),b&&t.jsxs(sn,{open:d,autoHideDuration:1e4,onClose:te,variant:"warning",children:[t.jsx("p",{className:"text-body-sm",children:b.message}),b.command&&t.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:b.command})]}),c&&p!=="danger"&&t.jsx(sn,{open:d,autoHideDuration:6e3,onClose:te,variant:p,children:c})]})},ct=["system-prompt"],Fr=()=>{const{shouldEnableQuery:e}=bs();return be({enabled:e({bypassInternetCheck:!0}),queryKey:ct,queryFn:async()=>{try{const a=await Rn(Bt.baseUrl).config.getSystemPrompt();if(a===null)return null;if(a.status>=400)throw new Error(a.message||"Failed to fetch system prompt");return a.result}catch(s){const a=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw En(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},Dr=()=>{const e=Ht(),s=Rn(Bt.baseUrl);return vs({mutationFn:async a=>{try{const i=await s.config.updateSystemPrompt(a);if(i.status>=400)throw new Error(i.message||"Failed to update system prompt");return i.result}catch(i){const o=i instanceof Error?i.message:"An unknown error occurred while updating system prompt";throw En(o),i}},onSuccess:async a=>{await e.invalidateQueries({queryKey:ct,refetchType:"none"}),e.setQueryData(ct,i=>i&&{...i,...a}),await e.refetchQueries({queryKey:ct,type:"all"}),js("System prompt updated")},onError:a=>{console.error("Error updating system prompt:",a)}})},Yn=({value:e,label:s,description:a,onChange:i,icon:o,isSaving:l=!1,disabled:d=!1})=>{const[u,c]=r.useState(e),m=r.useId(),p=`${m}-label`,f=`${m}-description`,b=async h=>{if(!(l||d)){c(h);try{await i(h)}catch(_){c(!h),console.error("Error toggling setting:",_)}}};return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{id:p,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[o&&t.jsx(o,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),a&&t.jsx("p",{id:f,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:a})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:l?t.jsx(he,{size:"md",label:`Saving ${s}`}):t.jsx(si,{checked:u,onCheckedChange:b,disabled:d,"aria-labelledby":p,"aria-describedby":a?f:void 0})})]})};function gn(e,s){const a=Si(e,s?.in);if(!wi(a))throw new RangeError("Invalid time value");const i=Le(a.getDate(),2),o=Le(a.getMonth()+1,2),l=a.getFullYear(),d=Le(a.getHours(),2),u=Le(a.getMinutes(),2),c=Le(a.getSeconds(),2);let m="",p="";const f=a.getTimezoneOffset();if(f!==0){const b=Math.abs(f),h=Le(Math.trunc(b/60),2),_=Le(b%60,2);p=`${f<0?"+":"-"}${h}:${_}`}else p="Z";return`${l}-${o}-${i}T${d}:${u}:${c}${m}${p}`}function zr(e,s,a){return ji(e,-30,a)}var Pr=ws({chartName:"LineChart",GraphicalChild:Tn,axisComponents:[{axisType:"xAxis",AxisComp:Ns},{axisType:"yAxis",AxisComp:Ss}],formatAxisMap:Cs});const $r=["radient","creditBalance"],Kr=e=>{const{user:s,isAuthenticated:a}=Vt(),i=s?.account?.tenant_id,o=a&&!!i&&e?.enabled;return be({queryKey:[$r,i],queryFn:async()=>{if(!i)throw new Error("Tenant ID not available");const l=await Ln({operation:"credits",tenantId:i});if(!l||typeof l.balance!="number")throw new Error("Invalid credit balance response format");return l},enabled:o,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Ur=["radient","usageRollup"],Br=(e,s)=>{const{user:a,isAuthenticated:i}=Vt(),o=a?.account?.tenant_id,l=i&&!!o&&s?.enabled;return be({queryKey:[...Ur,o,e],queryFn:async()=>{if(!o)throw new Error("Tenant ID not available");const d={};for(const[c,m]of Object.entries(e))m!=null&&(d[c]=String(m));const u=await Ln({operation:"usage",tenantId:o,query:d});if(!u)throw new Error("Invalid usage rollup response format");return u},enabled:l,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Hr=e=>e==="sidebars"?n("ui.settings.appearance.window_glass.coverage_sidebars"):n("ui.settings.appearance.window_glass.coverage_full"),Vr=e=>{switch(e){case"window":return n("ui.settings.appearance.window_glass.material_window");case"menu":return n("ui.settings.appearance.window_glass.material_menu");case"popover":return n("ui.settings.appearance.window_glass.material_popover");case"mica":return n("ui.settings.appearance.window_glass.material_mica");case"acrylic":return n("ui.settings.appearance.window_glass.material_acrylic");case"tabbed":return n("ui.settings.appearance.window_glass.material_tabbed")}},Gr=e=>{switch(e){case"reduced-transparency":return n("ui.settings.appearance.window_glass.unsupported_reduced_transparency");case"windows-too-old":return n("ui.settings.appearance.window_glass.unsupported_windows_too_old");case"windows-unverified":return n("ui.settings.appearance.window_glass.unsupported_windows_unverified");case"linux-compositor-dependent":return n("ui.settings.appearance.window_glass.unsupported_linux");case"hardware-acceleration-disabled":return n("ui.settings.appearance.window_glass.unsupported_acceleration");case"gpu-unavailable":return n("ui.settings.appearance.window_glass.unsupported_gpu");case"backdrop-filter-unavailable":return n("ui.settings.appearance.window_glass.unsupported_backdrop_filter");default:return n("ui.settings.appearance.window_glass.unsupported_other")}},_n=({label:e,description:s,value:a,onValueChange:i,options:o})=>{const l=r.useId();return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{id:l,className:"flex min-h-6 items-center text-body text-ink",children:e}),t.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:s})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsx(gt,{value:a,onValueChange:i,children:t.jsx(_t,{"aria-labelledby":l,children:o.map(d=>t.jsx($e,{value:d.value,children:d.label},d.value))})})})]})},qr=({state:e,onChange:s})=>{ee();const a=r.useId(),i=`${a}-description`,[o,l]=r.useState(null),d=r.useRef(!1),u=r.useRef(null),c=e?.settings.intensity??0;if(!e)return null;const m=!e.capability.supported,p=m?Gr(e.capability.reason):null,f=async _=>{if(d.current){u.current=_;return}d.current=!0;try{await s({intensity:_})}finally{d.current=!1;const w=u.current;u.current=null,w!==null&&w!==_?f(w):l(null)}},b=e.settings.enabled,h=o??c;return t.jsxs("div",{className:"flex flex-col gap-4","data-window-glass":"","data-glass-gate":e.capability.reason,children:[t.jsx(Ke,{content:p,disabled:!m,children:t.jsx("div",{className:m?"opacity-60":void 0,children:t.jsx(Yn,{value:m?!1:b,disabled:m,label:n("ui.settings.appearance.window_glass.label"),description:n("ui.settings.appearance.window_glass.description"),onChange:async _=>s({enabled:_})},m?"unavailable":"available")})}),p&&t.jsx("p",{"data-glass-unsupported":e.capability.reason,className:"max-w-2xl text-body-sm text-ink-muted",children:p}),e.restartRequired&&t.jsx("output",{className:"block max-w-2xl text-body-sm text-ink","data-glass-restart":"",children:n("ui.settings.appearance.window_glass.restart_needed")}),b&&!m&&t.jsxs(t.Fragment,{children:[t.jsx(_n,{label:n("ui.settings.appearance.window_glass.coverage_label"),description:n("ui.settings.appearance.window_glass.coverage_description"),value:e.settings.coverage,onValueChange:_=>void s({coverage:_}),options:Ms.map(_=>({value:_,label:Hr(_)}))}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[t.jsx("label",{htmlFor:a,className:"text-body text-ink",children:n("ui.settings.appearance.window_glass.intensity_label")}),t.jsx("span",{"data-glass-readout":"",className:"shrink-0 text-meta text-ink-dim tabular-nums",children:n("ui.settings.appearance.window_glass.intensity_value",{value:String(h)})})]}),t.jsx("p",{id:i,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.window_glass.intensity_description")}),t.jsx("input",{id:a,type:"range",min:0,max:100,step:5,value:h,"aria-describedby":i,"aria-valuetext":n("ui.settings.appearance.window_glass.intensity_value",{value:String(h)}),onChange:_=>{const w=Number(_.target.value);l(w),f(w)},style:{"--fill":`${h}%`},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover"}),t.jsxs("div",{"aria-hidden":"true",className:"mt-1 flex justify-between text-meta text-ink-dim",children:[t.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_start")}),t.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_end")})]})]}),t.jsx(_n,{label:n("ui.settings.appearance.window_glass.material_label"),description:n("ui.settings.appearance.window_glass.material_description"),value:e.settings.material,onValueChange:_=>void s({material:_}),options:e.capability.materials.map(_=>({value:_,label:Vr(_)}))})]})]})},pn={get[Ce.UI](){return n("ui.settings.updates.update_following.application_updates")},get[Ce.BACKEND](){return n("ui.settings.updates.update_following.server_updates")}},tt={patch:{get label(){return n("ui.settings.updates.update_following.patch_label")},get description(){return n("ui.settings.updates.update_following.patch_help")}},minor:{get label(){return n("ui.settings.updates.update_following.minor_label")},get description(){return n("ui.settings.updates.update_following.minor_help")}},major:{get label(){return n("ui.settings.updates.update_following.major_label")},get description(){return n("ui.settings.updates.update_following.major_help")}}},hn=({type:e})=>{ee();const s=It(i=>i.followed[e]),a=It(i=>i.setFollowedSegment);return t.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-body-sm text-ink",children:pn[e]}),t.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:tt[s].description})]}),t.jsxs(ai,{value:s,onValueChange:i=>a(e,i),children:[t.jsx(ii,{"aria-label":n("ui.settings.updates.update_following.surface_choice",{surface:pn[e],choice:tt[s].label}),className:"w-full sm:w-56","data-followed-segment":e,children:t.jsx(oi,{})}),t.jsx(ri,{children:As.map(i=>t.jsx(li,{value:i,title:tt[i].description,children:tt[i].label},i))})]})]})},Yr=()=>(ee(),t.jsxs("div",{className:ue("flex flex-col gap-3"),children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.updates.update_following.update_notifications")}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.updates.update_following.how_much_of_a_version_change_shows_the_update_notice_at_the_botto")})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(hn,{type:Ce.UI}),t.jsx(hn,{type:Ce.BACKEND})]})]})),Qr=({appVersion:e})=>t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(Yr,{}),t.jsx(Or,{appVersion:e})]}),Wr=e=>{if(!e)return null;try{return new URL(e).host}catch{return null}};function wt(e){switch(e){case"Loading...":return n("ui.settings.updates.app_updates_section.state_loading");case"Not connected":return n("ui.settings.updates.app_updates_section.state_not_connected");case"Not attached":return n("ui.settings.updates.app_updates_section.state_not_attached");case"Version unknown":return n("ui.settings.updates.app_updates_section.state_version_unknown");case"Unavailable":return n("ui.settings.updates.app_updates_section.state_unavailable");default:return e}}const Zr=()=>{ee();const[e,s]=r.useState(null),[a,i]=r.useState({value:"Loading...",detail:null,degraded:!1}),[o,l]=r.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});r.useEffect(()=>{let u=!0;const c=h=>{if(!u)return;const _=Wr(h.url);if(h.state==="connecting"){i({value:"Loading...",detail:null,degraded:!1});return}if(h.state==="detached"){i({value:"Not connected",detail:h.detail||null,degraded:!1});return}if(h.state==="wedged"){i({value:"Not attached",detail:h.detail||null,degraded:!1});return}const w=h.version||"Version unknown";i({value:_?`${w} · ${_}`:w,detail:h.detail||null,degraded:h.state==="degraded"})};let m=!1;const p=window.api?.backend?.onStatusChange(h=>{m=!0,c(h)}),f=async()=>{try{const[h,_]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);u&&(s(h),l(_))}catch(h){console.error("Error fetching app information:",h)}},b=async()=>{try{const h=window.api?.backend;if(h){const A=await h.getStatus();m||c(A);return}const _=await an.healthCheck(Bt.baseUrl),w=an.getServerVersion(_);u&&i({value:w,detail:null,degraded:!1})}catch(h){console.error("Error fetching server version:",h),u&&i({value:"Unavailable",detail:null,degraded:!1})}};return f(),b(),()=>{u=!1,p?.()}},[]);const d=(u,c,m,p={})=>t.jsx(_e,{label:t.jsx(Ke,{content:m,children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(pt,{size:12,className:"shrink-0"}),u]})}),valueClassName:p.valueClassName,value:t.jsxs(t.Fragment,{children:[p.valueTooltip?t.jsx(Ke,{content:p.valueTooltip,children:t.jsx("span",{"data-backend-version":p.valueHoverTarget?"":void 0,children:c})}):c,p.statusNote?t.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:p.statusNote}):null]})});return t.jsx(ce,{title:n("ui.settings.updates.app_updates_section.application_updates_and_info"),icon:it,description:n("ui.settings.updates.app_updates_section.check_for_updates_and_view_information_about_your_local_operator_"),dataTourTag:"settings-app-updates-section",children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs(ht,{children:[d(n("ui.settings.updates.app_updates_section.application_version"),e??n("ui.settings.updates.app_updates_section.state_loading"),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_user_interface_application")),d(n("ui.settings.updates.app_updates_section.server_version"),wt(a.value),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_api_server_backend_and_the_addr"),{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?n("ui.settings.updates.app_updates_section.not_answering"):void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),d(n("ui.settings.updates.app_updates_section.platform"),`${o.platform} (${o.arch})`,n("ui.settings.updates.app_updates_section.the_operating_system_and_architecture_your_application_is_running")),d(n("ui.settings.updates.app_updates_section.node_js_version"),wt(o.nodeVersion),n("ui.settings.updates.app_updates_section.the_javascript_runtime_environment_version")),d(n("ui.settings.updates.app_updates_section.electron_version"),wt(o.electronVersion),n("ui.settings.updates.app_updates_section.the_framework_version_enabling_this_desktop_application"))]}),t.jsx(Qr,{appVersion:e})]})})};function Qn(e){const s={id:"",name:n("ui.settings.model.default_effort.model_default")};return e.resolvedLevel&&e.stored.trim()===""&&Qt(e.resolvedLevel,e.storable)!==null&&(s.description=n("ui.settings.model.default_effort.model_default_resolves",{level:Fe(e.resolvedLevel)})),[s,...Wn(e.ladder,e.storable)]}function Qt(e,s){const a=e.trim().toLowerCase();return a===""?null:s.find(i=>i.trim().toLowerCase()===a)??null}function Wn(e,s){return e.flatMap(a=>{const i=Qt(a,s);return i===null?[]:[{id:i,name:Fe(a)}]})}function Jr(e,s){const a=e.trim().toLowerCase();return a!==""&&s.some(i=>i.toLowerCase()===a)?s.find(i=>i.toLowerCase()===a)??"":""}function Xr(e){if(!e.resolved||e.ladder===null)return null;const s=e.stored.trim().toLowerCase();if(s===""||e.ladder.some(o=>o.toLowerCase()===s))return null;const a=(e.resolvedLevel??"").trim(),i=a===""?"":Qt(a,e.storable)??"";return i.trim().toLowerCase()===s?null:i}const dt="\0unread";function nt(e){return e.trim()===""?"":dt}function el(e){if(!e.supported)return{kind:"unsupported",options:[],selectedId:"",disabled:!0,helper:""};if(!e.hasHome)return Se("no-home",n("ui.settings.model.default_effort.no_home"));if(!e.hasModel)return Se("no-model",n("ui.settings.model.default_effort.no_model"),dt);if(e.settings==="loading")return Se("settings-loading",n("ui.settings.model.default_effort.settings_loading"),dt);if(e.settings==="error")return Se("settings-error",n("ui.settings.model.default_effort.settings_error"),dt);if(e.preview==="loading")return Se("loading",n("ui.settings.model.default_effort.loading"),nt(e.stored));if(e.preview==="error")return Se("error",n("ui.settings.model.default_effort.error"),nt(e.stored));if(e.ladder===null||!e.specResolved)return Se("unresolved",n("ui.settings.model.default_effort.unresolved"),nt(e.stored));const s=e.ladder;if(s.length===0)return Se("empty",n("ui.settings.model.default_effort.empty"),nt(e.stored));const a=Wn(s,e.storable);if(a.length===0){const i=Fe(s[0]),o=s.length===1&&s[0].trim().toLowerCase()==="auto";return{kind:"one-level",options:[{id:"",name:i}],selectedId:"",disabled:!0,helper:o?n("ui.settings.model.default_effort.one_level_sentinel"):n("ui.settings.model.default_effort.one_level",{level:i})}}if(s.length===1){const[i]=a;return{kind:"one-level",options:[i],selectedId:i.id,disabled:!0,helper:n("ui.settings.model.default_effort.one_level",{level:i.name})}}return{kind:"ready",options:Qn({ladder:s,resolvedLevel:e.resolvedLevel,stored:e.stored,storable:e.storable}),selectedId:Jr(e.stored,a.map(i=>i.id)),disabled:!1,helper:n("ui.settings.model.default_effort.helper_ready")}}function Se(e,s,a=""){return{kind:e,options:Qn({ladder:[],resolvedLevel:null,stored:"",storable:[]}),selectedId:a,disabled:!0,helper:s}}const tl=({hosting:e,modelName:s,focus:a=!1})=>{ee();const i=Gt(),o=Rt(i.data,"draft_preview"),l=Is(),d=e!==""&&s!=="",u=be({queryKey:Et.all,queryFn:()=>de({op:"settings.list"}),enabled:o,staleTime:1e4}),c=u.data?.settings.find(V=>V.key===ot),m=typeof c?.value=="string"?c.value:"",p=(c?.choices??[]).map(V=>V.value).filter(V=>typeof V=="string"),f={cwd:l??"",model:d?{provider:e,model_id:s,reasoning_effort:null}:null},b=u.isSuccess?m:null,h=be({...Es(f),queryKey:[...Rs(f),"model_effort",b],enabled:o&&!!l&&d}),_=h.isSuccess&&!h.isPlaceholderData,w=_?Ts(h.data?.snapshot,null).effort:null,A=_&&Array.isArray(w?.reasoning_efforts)?Ls(w):null,K=_?Os(w):null,C=w!==null&&!Fs(w),[O,T]=r.useState(!1),[L,I]=r.useState(!1),[W,X]=r.useState(null),[J,D]=r.useState(null),te=`${e}\0${s}`,z=Ht(),P=r.useRef(null),H=r.useRef(!1),U=r.useCallback(async(V,se)=>{T(!0),X(V),I(!1),se===null&&D(null);try{await de({op:"settings.edit",key:ot,value:V}),await z.invalidateQueries({queryKey:Et.all}),se!==null&&D(se)}catch{I(!0)}finally{T(!1),X(null)}},[z]),R=typeof w?.display_name=="string"&&w.display_name.trim()||s,Y=el({supported:o,hasHome:!!l,hasModel:d,settings:u.isError?"error":u.isSuccess?"ready":"loading",preview:h.isError?"error":_?"ready":"loading",ladder:A,specResolved:C,stored:m,resolvedLevel:K,storable:p}),y=Xr({stored:m,ladder:A,resolvedLevel:K,resolved:_&&C&&u.isSuccess,storable:p}),x=r.useRef(null);r.useEffect(()=>{if(y===null||O)return;const V=`${e}\0${s}\0${m}\0${y}`;if(x.current===V)return;x.current=V;const se=y===""?n("ui.settings.model.default_effort.clamped_unset",{level:Fe(m),model:R}):n("ui.settings.model.default_effort.clamped",{level:Fe(m),model:R,resolved:Fe(y)});U(y,{text:se,model:te})},[y,m,O,U,e,s,R,te]);const v=r.useMemo(()=>Y.options.map(nl),[Y.options]);r.useEffect(()=>{if(!a){H.current=!1;return}Y.disabled||H.current||(P.current?.querySelector("[role=combobox]")?.focus(),H.current=!0)},[a,Y.disabled]);const Q=W??Y.selectedId,$=v.find(V=>V.id===Q)??(W!==null?{id:W,name:Fe(W)}:null),ne=t.jsxs("span",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{children:Y.helper}),L&&t.jsx("span",{className:"text-danger",children:n("ui.settings.model.default_effort.save_failed")}),t.jsx("output",{"aria-live":"polite",children:J?.model===te?J.text:""})]});return Y.kind==="unsupported"?null:t.jsx("div",{ref:P,"data-setting-key":ot,children:t.jsx(ci,{label:n("ui.settings.model.default_effort.label"),icon:t.jsx(Fa,{size:16,"aria-hidden":"true"}),placeholder:n("ui.settings.model.default_effort.placeholder"),options:v,selected:$,onSelect:V=>{U(V.id,null)},helperText:ne,busy:O,busyLabel:n("ui.settings.model.default_effort.busy"),disabled:Y.disabled||O})})};function nl(e){return{id:e.id,name:e.name,description:e.description}}const sl=e=>e.replace(/[\p{Co}\p{Cc}]/gu," ").replace(/\s+/g," ").trim(),Zn=(e,s)=>{const a=s.trim().toLocaleLowerCase();return a?e.filter(i=>`${i.title} ${i.cwd} ${i.sourceId}`.toLocaleLowerCase().includes(a)):e},al=(e,s)=>`${e??""}\0${[...s].sort().join("\0")}`,Jn=5e3,il=(e,s,a,i=Jn)=>{const o=new Set(a);let l=!1;for(const d of Zn(e,s))if(!o.has(d.sourceId)){if(o.size>=i){l=!0;break}o.add(d.sourceId)}return{selected:o,capped:l}},ol=/cancel/i,rl=new Set(["done","failed","cancelled"]),fn=e=>{switch(e){case"metadata_only":return"ui.settings.imports.availability_metadata_only";case"unsupported":return"ui.settings.imports.availability_unsupported";default:return"ui.settings.imports.availability_full"}},Nt=e=>{switch(e){case"queued":return"ui.settings.imports.state_queued";case"done":return"ui.settings.imports.state_done";case"failed":return"ui.settings.imports.state_failed";case"cancelled":return"ui.settings.imports.state_cancelled";default:return"ui.settings.imports.state_running"}},ll=e=>{switch(e){case"selecting":return"ui.settings.imports.phase_selecting";case"memory":return"ui.settings.imports.phase_memory";case"done":return"ui.settings.imports.phase_done";case"cancelled":return"ui.settings.imports.phase_cancelled";case"queued":return"ui.settings.imports.phase_queued";default:return"ui.settings.imports.phase_importing"}},cl=e=>{switch(e){case"resumed":return"ui.settings.imports.outcome_resumed";case"skipped_already_imported":return"ui.settings.imports.outcome_skipped";case"metadata_only":return"ui.settings.imports.outcome_metadata";case"failed":return"ui.settings.imports.outcome_failed";case"cancelled":return"ui.settings.imports.outcome_cancelled";default:return"ui.settings.imports.outcome_imported"}},dl=e=>e==="failed"?"danger":e==="metadata_only"||e==="skipped_already_imported"?"neutral":e==="cancelled"?"warning":"success",Pt=e=>sl(e.title)||e.sourceId,xn=({path:e,label:s,onCopyPath:a})=>{const[i,o]=r.useState(!1);return t.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-hairline bg-surface p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-body-sm text-ink",children:s}),t.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:e})]}),t.jsxs(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a(e).then(l=>{l&&(o(!0),window.setTimeout(()=>o(!1),1500))})},children:[i?t.jsx(Vn,{size:14}):t.jsx(Fn,{size:14}),i?n("ui.settings.imports.copied"):n("ui.settings.imports.copy_path")]})]})},ul=({progress:e,sessions:s,selected:a})=>{const i=new Map(e.results.map(u=>[u.sourceId,u])),o=e.sessionId,l=Math.max(0,e.total-e.completed-(o&&!i.has(o)?1:0)),d=s.filter(u=>a.has(u.sourceId));return t.jsxs("div",{className:"flex flex-col gap-2",children:[e.results.map(u=>t.jsx(Xn,{row:u,jobCancelled:e.state==="cancelled"},`${u.source}:${u.sourceId}`)),d.filter(u=>!i.has(u.sourceId)&&u.sourceId!==o).map(u=>t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[t.jsx("span",{className:"min-w-0 truncate",children:Pt(u)}),t.jsx(qe,{variant:"neutral",children:n("ui.settings.imports.session_pending")})]},u.sourceId)),o&&!i.has(o)&&t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[t.jsx(rt,{size:14,className:"animate-spin"}),t.jsx("span",{children:n("ui.settings.imports.session_importing")}),t.jsx("span",{className:"min-w-0 truncate",children:o})]}),l>0&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.progress_pending",{count:l})}),e.warnings.map(u=>t.jsx("p",{className:"text-meta text-warning",children:u.message},`${u.code}:${u.sessionId}:${u.message}`))]})},Xn=({row:e,jobCancelled:s=!1})=>{const i=s&&e.outcome==="failed"&&e.warnings.some(o=>ol.test(o))?"cancelled":e.outcome;return t.jsxs("div",{className:"rounded-md border border-hairline bg-surface p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:e.sourceId}),t.jsx(qe,{variant:dl(i),children:n(cl(i))}),t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.session_meta",{messages:e.messages,compactions:e.compactions})})]}),e.targetSessionId&&(e.messages>0||e.outcome==="skipped_already_imported")&&t.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:n("ui.settings.imports.result_target",{target:e.targetSessionId})}),e.warnings.map(o=>t.jsx("p",{className:"mt-1 text-meta text-warning",children:o},o))]})},ml=({sources:e,activeSource:s,sessions:a,query:i,selected:o,preview:l,previewStale:d,confirmed:u,busy:c,error:m,progress:p,result:f,cancelling:b,onSelectSource:h,onQueryChange:_,onToggleSession:w,onSelectAll:A,onClearSelection:K,onPreview:C,onConfirmChange:O,onImport:T,onCancel:L,onRetry:I,onImportAnother:W,onRefresh:X,selectionNotice:J,onCopyPath:D})=>{ee();const te=r.useRef(null),z=e.find(x=>x.source===s),P=p!==null&&!rl.has(p.state),H=p?.total??o.size;r.useEffect(()=>{l&&!d&&!p&&!f&&te.current?.scrollIntoView({block:"start",inline:"nearest"})},[l,d,p,f]);const U=r.useMemo(()=>Zn(a,i),[i,a]),R=U.length>0&&U.every(x=>o.has(x.sourceId)),Y=o.size,y=Y>0&&l!==null&&!d&&u&&!c&&!p&&!f;return t.jsx(ce,{title:n("ui.settings.imports.title"),icon:it,description:n("ui.settings.imports.description"),dataTourTag:"settings-import-section",children:t.jsxs("div",{className:"flex flex-col gap-5",children:[m&&t.jsxs(oe,{variant:"warning",children:[t.jsx(di,{children:n("ui.settings.imports.title")}),t.jsx(et,{children:t.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("span",{children:m}),t.jsx(G,{variant:"secondary",size:"sm",onClick:I,children:n("ui.settings.imports.retry")})]})})]}),c==="sources"&&e.length===0?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Oe,{className:"h-20 w-full"}),t.jsx(Oe,{className:"h-20 w-full"}),t.jsx(Oe,{className:"h-20 w-full"}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sources")})]}):e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}):t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.source_heading")}),t.jsxs(G,{variant:"ghost",size:"sm",onClick:X,disabled:P||c==="sources"||c==="sessions",children:[t.jsx(Da,{size:14,className:ue(c==="sources"&&"animate-spin")}),n("ui.settings.imports.refresh")]})]}),!e.some(x=>x.detected)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}),t.jsx("div",{className:"grid gap-2 lg:grid-cols-3",children:e.map(x=>{const v=x.source===s,Q=x.detected?n(fn(x.availability)):n("ui.settings.imports.source_not_found");return t.jsxs("button",{type:"button","aria-pressed":v,disabled:P,onClick:()=>h(x.source),className:ue("rounded-lg border p-3 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60","focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",v?"border-accent bg-accent-wash":"border-hairline bg-surface hover:bg-sunken"),children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-body-sm font-medium text-ink",children:x.label}),t.jsx(qe,{variant:x.detected&&x.availability==="full"?"success":"neutral",children:Q})]}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.imports.source_sessions",{count:x.sessionCount})}),t.jsx("p",{className:"mt-1 break-all text-meta text-ink-dim",children:x.detail||x.root})]},x.source)})})]}),z&&!p&&!f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("h3",{className:"text-heading text-ink",children:[n("ui.settings.imports.source_heading")," · ",z.label]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",size:"sm",onClick:R?K:A,disabled:U.length===0,children:R?n("ui.settings.imports.clear_all"):n("ui.settings.imports.select_all")}),t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.selected",{count:Y})})]})]}),J&&t.jsx("output",{className:"text-meta text-warning",children:J}),t.jsxs("div",{className:"relative",children:[t.jsx(On,{size:15,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim"}),t.jsx(Ae,{value:i,onChange:x=>_(x.target.value),placeholder:n("ui.settings.imports.search_placeholder"),className:"pl-9"})]}),c==="sessions"?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Oe,{className:"h-12 w-full"}),t.jsx(Oe,{className:"h-12 w-full"}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sessions",{source:z.label})})]}):a.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sessions",{source:z.label})}):U.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_filter")}):t.jsx("div",{className:"flex max-h-80 flex-col gap-1 overflow-y-auto",children:U.map(x=>t.jsxs("div",{className:"flex items-start gap-3 rounded-md border border-hairline bg-surface p-3 hover:bg-sunken",children:[t.jsx(zt,{checked:o.has(x.sourceId),onCheckedChange:()=>w(x.sourceId),"aria-label":Pt(x),className:"mt-0.5"}),t.jsxs("button",{type:"button",onClick:()=>w(x.sourceId),className:"min-w-0 flex-1 text-left",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:Pt(x)}),t.jsx(qe,{variant:x.availability==="full"?"neutral":"warning",children:n(fn(x.availability))})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-meta text-ink-muted",children:[t.jsx("span",{children:n("ui.settings.imports.session_meta",{messages:x.messageCount??0,compactions:x.compactionCount})}),t.jsx("span",{children:n("ui.settings.imports.session_updated",{date:qt(new Date((x.updatedTs||x.createdTs)*1e3))})})]}),x.cwd&&t.jsx("span",{className:"mt-1 block break-all font-mono text-meta text-ink-dim",children:x.cwd}),x.availability==="metadata_only"&&t.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.metadata_only_explain")}),x.availability==="unsupported"&&t.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.session_index_only")})]})]},x.sourceId))})]}),z&&Y>0&&!p&&!f&&t.jsxs("div",{ref:te,className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.preview_heading")}),t.jsxs(G,{variant:"secondary",size:"sm",onClick:C,disabled:c==="preview"||c==="start",children:[c==="preview"?t.jsx(rt,{size:14,className:"animate-spin"}):t.jsx(it,{size:14}),c==="preview"?n("ui.settings.imports.loading_preview"):n("ui.settings.imports.preview_heading")]})]}),d&&t.jsx(oe,{variant:"warning",children:t.jsx(et,{children:n("ui.settings.imports.preview_required")})}),l&&!d&&t.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-hairline bg-surface p-4",children:[t.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.imports.preview_summary",{sessions:l.totalSessions,messages:l.totalMessages,compactions:l.totalCompactions})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_memory",{records:l.totalMemoryRecords,tokens:l.projectedMemoryTokens.toLocaleString()})}),l.warnings.slice(0,4).map((x,v)=>t.jsx("p",{className:"text-meta text-warning",children:x.message},`${x.code}:${x.sessionId}:${v}`)),l.warnings.length>4&&t.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.imports.warnings_heading",{count:l.warnings.length})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_confirm")})]}),t.jsxs("div",{className:"flex items-start gap-2 text-body-sm text-ink",children:[t.jsx(zt,{checked:u,onCheckedChange:x=>O(x===!0),disabled:!l||d,"aria-label":n("ui.settings.imports.confirm_label"),className:"mt-0.5"}),t.jsx("span",{children:n("ui.settings.imports.confirm_label")})]}),t.jsxs(G,{variant:"primary",onClick:T,disabled:!y,className:"self-start",children:[c==="start"?t.jsx(rt,{size:14,className:"animate-spin"}):t.jsx(it,{size:14}),n("ui.settings.imports.import_button",{count:Y})]})]}),p&&!f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.progress_heading")}),t.jsxs(G,{variant:"secondary",size:"sm",onClick:L,disabled:b||p.state==="done"||p.state==="cancelled"||p.state==="failed",children:[t.jsx(Ds,{size:12}),b?n("ui.settings.imports.cancelling"):n("ui.settings.imports.cancel")]})]}),t.jsxs("p",{className:"text-meta text-ink-muted",children:[n("ui.settings.imports.progress_job",{job:p.jobId,state:n(Nt(p.state))})," · ",n(ll(p.phase))]}),t.jsx(ui,{value:p.total?p.completed/p.total*100:0,className:"h-1.5"}),t.jsx(ul,{progress:p,sessions:a,selected:o})]}),f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.result_heading")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:W,children:n("ui.settings.imports.import_another")})]}),t.jsx("p",{className:"text-body-sm text-ink",children:f.state==="cancelled"?n("ui.settings.imports.result_summary_cancelled",{state:n(Nt(f.state)),sessions:f.sessions.length,total:H,messages:f.messages}):n("ui.settings.imports.result_summary",{state:n(Nt(f.state)),sessions:f.sessions.length,messages:f.messages})}),f.sessions.map(x=>t.jsx(Xn,{row:x,jobCancelled:f.state==="cancelled"},`${x.source}:${x.sourceId}:${x.targetSessionId}`)),(f.instructionReviewPath||f.memoryReviewPath)&&t.jsxs("div",{className:"flex flex-col gap-2",children:[f.instructionReviewPath&&t.jsx(xn,{path:f.instructionReviewPath,label:n("ui.settings.imports.review_instructions"),onCopyPath:D}),f.memoryReviewPath&&t.jsx(xn,{path:f.memoryReviewPath,label:n("ui.settings.imports.review_memory"),onCopyPath:D})]}),f.warnings.length>0&&t.jsx(oe,{variant:"warning",children:t.jsx(et,{children:t.jsxs("span",{className:"flex flex-col gap-1",children:[t.jsx("span",{children:n("ui.settings.imports.warnings_heading",{count:f.warnings.length})}),f.warnings.slice(0,4).map((x,v)=>t.jsx("span",{children:x.message},`${x.code}:${v}`))]})})}),f.error&&t.jsx(oe,{variant:"danger",children:t.jsx(et,{children:f.error})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.rerun_safe")})]}),c==="start"&&!p&&t.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[t.jsx(rt,{size:14,className:"animate-spin"}),n("ui.settings.imports.importing")]})]})})},Wt=e=>({source:e.source,sessionId:e.session_id,code:e.code,message:e.message}),es=e=>({source:e.source,sourceId:e.source_id,targetSessionId:e.target_session_id,outcome:e.outcome,messages:e.messages,compactions:e.compactions,redactions:e.redactions,skipped:e.skipped,warnings:e.warnings}),gl=e=>({jobId:e.job_id,state:e.state,sessions:e.sessions.map(es),messages:e.messages,compactions:e.compactions,memoryImported:e.memory_imported,memorySkipped:e.memory_skipped,memoryReviewPath:e.memory_review_path,instructionReviewPath:e.instruction_review_path,redactions:e.redactions,warnings:e.warnings.map(Wt),error:e.error});async function _l(){return(await de({op:"imports.sources"})).sources.map(s=>({source:s.source,label:s.label,root:s.root,detected:s.detected,sessionCount:s.session_count,availability:s.availability,detail:s.detail}))}async function pl(e,s=!1){return(await de({op:"imports.sessions",source:e,includeSubagents:s})).sessions.map(i=>({source:i.source,sourceId:i.source_id,title:i.title??"",cwd:i.cwd??"",createdTs:i.created_ts,updatedTs:i.updated_ts,messageCount:i.message_count,compactionCount:i.compaction_count,kind:i.kind,availability:i.availability,parentSourceId:i.parent_source_id}))}async function hl(e){const s=await de({op:"imports.preview",sources:e.sources,sessionIds:e.sessionIds,includeMemory:e.includeMemory??!0,includeInstructions:e.includeInstructions??!0});return{totalSessions:s.total_sessions,totalMessages:s.total_messages,messageCountsEstimated:s.message_counts_estimated,totalCompactions:s.total_compactions,totalMemoryRecords:s.total_memory_records,projectedMemoryTokens:s.projected_memory_tokens,projectedGlobalTokens:s.projected_global_tokens,warnings:s.warnings.map(Wt),instructionReviewPaths:s.instruction_review_paths}}async function fl(e){return(await de({op:"imports.start",sources:e.sources,sessionIds:e.sessionIds,includeMemory:e.includeMemory??!0,includeInstructions:e.includeInstructions??!0})).job_id}async function xl(e){const s=await de({op:"imports.status",jobId:e});return{jobId:s.job_id,state:s.state,phase:s.phase,source:s.source,sessionId:s.session_id,completed:s.completed,total:s.total,results:s.results.map(es),warnings:s.warnings.map(Wt),error:s.error,startedAt:s.started_at,updatedAt:s.updated_at,result:s.result?gl(s.result):void 0}}async function yl(e){await de({op:"imports.cancel",jobId:e})}const st=new Set(["done","failed","cancelled"]),Pe=e=>e instanceof Error?e.message:String(e),kl=()=>{ee();const[e,s]=r.useState([]),[a,i]=r.useState(null),[o,l]=r.useState([]),[d,u]=r.useState(""),[c,m]=r.useState(new Set),[p,f]=r.useState(null),[b,h]=r.useState(null),[_,w]=r.useState(!1),[A,K]=r.useState(null),[C,O]=r.useState(null),[T,L]=r.useState(null),[I,W]=r.useState(null),[X,J]=r.useState(!1),[D,te]=r.useState(null),[z,P]=r.useState(0),H=r.useRef(0),U=r.useRef(null),R=T!==null&&!st.has(T.state),Y=r.useCallback(async()=>{K("sources"),O(null);try{const M=await _l();s(M),i(F=>M.some(ie=>ie.source===F&&ie.detected)?F:M.find(ie=>ie.detected)?.source??null)}catch(M){O(n("ui.settings.imports.error_sources",{reason:Pe(M)}))}finally{K(null)}},[]);r.useEffect(()=>{Y()},[Y]);const y=r.useCallback(async M=>{const F=++H.current;K("sessions"),O(null);try{const re=await pl(M);if(F!==H.current)return;l(re)}catch(re){if(F!==H.current)return;l([]),O(n("ui.settings.imports.error_sessions",{source:M,reason:Pe(re)}))}finally{F===H.current&&K(null)}},[]);r.useEffect(()=>{if(!a){l([]);return}l([]),m(new Set),f(null),h(null),w(!1),W(null),L(null),y(a)},[a,y]);const x=r.useCallback(M=>{m(M),f(null),h(null),w(!1),te(null)},[]),v=r.useCallback(M=>{R||(i(M),u(""))},[R]),Q=r.useCallback(M=>{const F=new Set(c);F.has(M)?F.delete(M):F.add(M),x(F)},[x,c]),$=r.useCallback(()=>{const M=il(o,d,c);x(M.selected),M.capped&&te(n("ui.settings.imports.selection_limit",{max:Jn}))},[d,x,c,o]),ne=r.useCallback(()=>{x(new Set)},[x]),V=r.useMemo(()=>al(a,c),[a,c]),se=p!==null&&b!==V,ve=r.useCallback(async()=>{if(!(!a||c.size===0)){K("preview"),O(null);try{const M=await hl({sources:[a],sessionIds:{[a]:[...c].sort()}});f(M),h(V)}catch(M){f(null),h(null),O(n("ui.settings.imports.error_preview",{reason:Pe(M)}))}finally{K(null)}}},[a,V,c]),pe=r.useCallback(async()=>{if(!(!a||c.size===0||!p||se||!_||T)){K("start"),O(null),W(null);try{const M=await fl({sources:[a],sessionIds:{[a]:[...c].sort()}}),F=Date.now()/1e3;L({jobId:M,state:"queued",phase:"queued",source:a,sessionId:"",completed:0,total:c.size,results:[],warnings:[],error:"",startedAt:F,updatedAt:F})}catch(M){O(n("ui.settings.imports.error_start",{reason:Pe(M)}))}finally{K(null)}}},[a,_,p,se,T,c]),me=T?.jobId??null,fe=T?.state??null;r.useEffect(()=>{if(!me||!fe||st.has(fe))return;let M=!0,F;const re=async()=>{try{const ie=await xl(me);if(!M)return;if(U.current){const le=U.current;U.current=null,O(ye=>ye===le?null:ye)}L(ie),ie.result&&W({...ie.result,jobId:ie.jobId}),st.has(ie.state)||(F=setTimeout(re,900))}catch(ie){if(!M)return;const le=n("ui.settings.imports.error_job",{reason:Pe(ie)});U.current=le,O(le),F=setTimeout(re,2e3)}};return F=setTimeout(re,z>0?0:700),()=>{M=!1,F&&clearTimeout(F)}},[me,fe,z]);const j=r.useCallback(async()=>{if(!(!T||st.has(T.state))){J(!0),O(null);try{await yl(T.jobId)}catch(M){O(n("ui.settings.imports.error_cancel",{reason:Pe(M)}))}finally{J(!1)}}},[T]),B=r.useCallback(()=>{m(new Set),f(null),h(null),w(!1),te(null),W(null),L(null),O(null),a&&y(a)},[a,y]),q=r.useCallback(async M=>{try{return await navigator.clipboard.writeText(M),!0}catch{return!1}},[]),ae=r.useCallback(async()=>{R||(te(null),await Y(),a&&await y(a))},[a,R,y,Y]),N=r.useCallback(()=>{if(R){O(null),P(M=>M+1);return}ae()},[R,ae]);return t.jsx(ml,{sources:e,activeSource:a,sessions:o,query:d,selected:c,preview:p,previewStale:se,confirmed:_,busy:A,error:C,progress:T,result:I,cancelling:X,onSelectSource:v,onQueryChange:u,onToggleSession:Q,onSelectAll:$,onClearSelection:ne,onPreview:()=>void ve(),onConfirmChange:w,onImport:()=>void pe(),onCancel:()=>void j(),onRetry:N,onImportAnother:B,onRefresh:ae,selectionNotice:D,onCopyPath:q})},bl=e=>{const s=e.label.replace(/^Open\s+/,"");return s.charAt(0).toUpperCase()+s.slice(1)},vl=({action:e})=>{ee();const s=r.useId(),a=r.useRef(null),i=Me(_=>_.shortcutBindings),o=i[e.id],l=Me(_=>_.setShortcutBinding),d=Me(_=>_.clearShortcutBinding),[u,c]=r.useState(!1),[m,p]=r.useState(null),f=r.useMemo(zs,[]),b=Ia(e.id,i),h=bl(e);return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(we,{htmlFor:s,className:"w-32 text-body-sm text-ink",children:h}),t.jsx(Ae,{id:s,readOnly:!0,value:b===null?n("ui.settings.shortcuts.keyboard_shortcuts_section.no_shortcut"):Ra(b,f),"aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.label_press_the_keys_you_want",{label:String(h)}),"data-shortcut-action":e.id,ref:a,className:ue("w-52",b===null?"text-body-sm":"font-mono text-body-sm"),onFocus:()=>c(!0),onBlur:()=>{c(!1),p(null)},onKeyDown:_=>{if(Ps.has(_.key))return;if($s.has(_.key)){c(!1),p(null);return}if(Ks.has(_.key)||_.nativeEvent.isComposing)return;const w=Us({key:_.key,metaKey:_.metaKey,ctrlKey:_.ctrlKey,altKey:_.altKey,shiftKey:_.shiftKey}),A=Ea(w,e.id,i,f);if(A!==null){_.preventDefault(),c(!0),p(A);return}if(w===b){c(!0),p(null);return}_.preventDefault(),c(!0),p(null),w===e.defaultChord?l(e.id,null):w!==null&&l(e.id,w)}}),b!==null&&t.jsx(G,{variant:"secondary",size:"sm","aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.clear_label_s_shortcut",{label:String(h)}),onClick:()=>{d(e.id),a.current?.focus()},children:n("ui.settings.shortcuts.keyboard_shortcuts_section.clear")}),o!==void 0&&t.jsx(G,{variant:"secondary",size:"sm","aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.reset_label_to_its_default",{label:String(h)}),onClick:()=>{l(e.id,null),a.current?.focus()},children:n("ui.settings.shortcuts.keyboard_shortcuts_section.reset")})]}),u&&t.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.shortcuts.keyboard_shortcuts_section.press_the_keys_you_want_esc_cancels")}),m!==null&&t.jsx("output",{className:"text-meta text-danger",children:m})]})},jl=({sectionRef:e})=>(ee(),t.jsx(ce,{title:n("ui.settings.shortcuts.keyboard_shortcuts_section.keyboard_shortcuts"),icon:za,description:n("ui.settings.shortcuts.keyboard_shortcuts_section.shortcuts_for_the_panel_rail_focus_a_field_and_press_the_keys_you"),sectionRef:e,children:t.jsx("div",{className:"flex flex-col gap-4",children:Aa.map(s=>t.jsx(vl,{action:s},s.id))})})),wl=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function ts(e){if(!e)return null;const s=e.split("\\").join("/").split("/").filter(Boolean);for(const[a,i]of wl)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return i;return null}const ut=e=>n("ui.settings.integrations.integration_model.tool_count",{count:e}),Nl=e=>n("ui.settings.integrations.integration_model.integration_count",{count:e}),Sl=["connected","needs_sign_in","not_started","connecting","error"],ns=e=>Sl.includes(e),Ue=(e,s)=>[...s].filter(a=>a.name===e&&a.status==="running").sort((a,i)=>i.created_at-a.created_at)[0]??null,Cl={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},Ml=1e12,Al=1e9,Il=60*60*1e3,ss=(e,s=Date.now())=>{if(typeof e!="number"||!Number.isFinite(e))return null;const a=e>=Ml?e:e<Al?null:e*1e3;return a===null||a>s+Il?null:Math.min(a,s)},De=(e,s)=>e?.[s]??Cl,Qe=(e,s,a)=>Tl(e,s)??a?.lastDecisive??null,Rl=e=>({id:e.id,name:e.name,action:e.action,status:e.status,created_at:e.created_at,credential_removed:e.credential_removed,...e.message?{message:e.message}:{}}),Zt=(e,s)=>e.status==="not_started"&&typeof e.tool_count=="number"&&(s.connectedAt!==null||e.status_basis==="stored"&&e.tool_count_basis==="last_seen"),El=(e,s)=>[...s].filter(a=>a.name===e).sort((a,i)=>i.created_at-a.created_at)[0]??null,Tl=(e,s)=>El(e,s.filter(a=>a.status!=="cancelled")),ft=e=>e.actions.includes("set_key")||e.actions.includes("add_key");function Ll(e,s){const a=Math.max(0,Math.round((e-s)/1e3));if(a<60)return n("ui.settings.integrations.integration_model.just_now");const i=Math.round(a/60);if(i<60)return n("ui.settings.integrations.integration_model.minutes_min_ago",{minutes:i});const o=Math.round(i/60);return o<24?n("ui.settings.integrations.integration_model.hours_h_ago",{hours:o}):n("ui.settings.integrations.integration_model.days_ago",{days:Math.round(o/24)})}function St(e){if(!e)return null;const s=e.trim();if(!s||/^\/\w/.test(s)||/\/mcp\s+\w+/.test(s))return null;let a=s;for(let i=0;i<3;i+=1){const o=a.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(o===a)break;a=o}return a=a.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),a||null}function Ol(e,s=[],a,i=Date.now()){const o=De(a,e.name),l=Ue(e.name,s);if(l){if(l.action==="login"||l.action==="reauth")return{label:n("ui.settings.integrations.integration_model.signing_in"),tone:"info",detail:null,busy:!0};if(l.action==="logout")return{label:n("ui.settings.integrations.integration_model.signing_out"),tone:"info",detail:null,busy:!0}}if(!ns(e.status))return{label:n("ui.settings.integrations.integration_model.status_unavailable"),tone:"neutral",detail:null,busy:!1};const d=Qe(e.name,s,o),u=xt(d)&&e.status!=="connected",c=Zt(e,o),m=en(d)&&e.status!=="connected",p=(d?.action==="login"||d?.action==="reauth")&&d.status==="failed";if(o.disconnectedAt!==null)return{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1};switch(e.status){case"connected":return{label:typeof e.tool_count=="number"?n("ui.settings.integrations.integration_model.connected_with_tools",{tools:String(ut(e.tool_count))}):n("ui.settings.integrations.integration_model.connected"),tone:"success",detail:null,busy:!1};case"connecting":return{label:n("ui.settings.integrations.integration_model.connecting"),tone:"info",detail:null,busy:!0};case"needs_sign_in":return{label:e.auth.kind==="api_key"||Ge(e,s,o)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:St(e.status_reason),busy:!1};case"error":return{label:n("ui.settings.integrations.integration_model.couldn_t_start"),tone:"danger",detail:St(e.status_reason)??n("ui.settings.integrations.integration_model.no_reason_was_given"),busy:!1};default:if(u)return{label:n("ui.settings.integrations.integration_model.signed_out"),tone:"warning",detail:null,busy:!1};if(m)return{label:n("ui.settings.integrations.integration_model.sign_out_didn_t_finish"),tone:"warning",detail:n("ui.settings.integrations.integration_model.the_sign_in_is_still_saved"),busy:!1};if(Ge(e,s,o))return{label:n("ui.settings.integrations.integration_model.needs_a_key"),tone:"warning",detail:null,busy:!1};if(p)return{label:n("ui.settings.integrations.integration_model.sign_in_didn_t_finish"),tone:"warning",detail:null,busy:!1};if(o.needsSignIn)return{label:e.auth.kind==="api_key"||Ge(e,s,o)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:St(e.status_reason),busy:!1};if(e.status_basis==="stored"&&c&&o.disconnectedAt===null){const f=o.connectedAt??ss(e.last_seen_at,i);return{label:f!==null?n("ui.settings.integrations.integration_model.worked_when_with_tools",{when:String(Ll(i,f)),tools:String(ut(e.tool_count))}):n("ui.settings.integrations.integration_model.worked_earlier_with_tools",{tools:String(ut(e.tool_count))}),tone:"success",detail:null,busy:!1}}return e.status_basis==="live"?{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1}:{label:n("ui.settings.integrations.integration_model.ready"),tone:"neutral",detail:null,busy:!1}}}const as=e=>n("ui.settings.integrations.integration_model.replace_keys",{count:e}),Fl=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Dl(e,s){const a=e?.trim()??"";if(!a)return null;if(s)return a;const i=a.replace(Fl,"").trim();return i?/\.$/.test(i)?i:`${i}.`:a}const zl="ui.settings.integrations.integration_model.copy_ready_explanation",Pl="ui.settings.integrations.integration_model.copy_not_connected_explanation",$l=e=>e.transport==="local_command"?n("ui.settings.integrations.integration_model.local_command"):n("ui.settings.integrations.integration_model.remote_url");function is(e){switch(e.source.kind){case"local-operator":case"project-mcp-json":return null;case"claude-code":return n("ui.settings.integrations.integration_model.claude_code");case"cursor":return"Cursor";case"vscode":return n("ui.settings.integrations.integration_model.vs_code");case"codex":return n("ui.settings.integrations.integration_model.codex_cli");default:return ts(e.source.path)}}function Kl(e,s){const a=[$l(e)];e.status!=="connected"&&e.tool_count_basis==="last_seen"&&typeof e.tool_count=="number"&&a.push(n("ui.settings.integrations.integration_model.tools_when_last_checked",{tools:String(ut(e.tool_count))})),s&&a.push(e.scope==="project"?n("ui.settings.integrations.integration_model.this_project"):n("ui.settings.integrations.integration_model.global"));const i=is(e);return i?a.push(n("ui.settings.integrations.integration_model.imported_from_origin",{origin:String(i)})):e.source.editable||a.push(n("ui.settings.integrations.integration_model.imported_from_a_project_file")),a}const Jt=(e,s)=>s.disconnectedAt!==null?"not_started":e.status;function Xt(e,s=[],a){const i=De(a,e.name),o=Ue(e.name,s);if(o)return o.action==="login"||o.action==="reauth"?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.continue_sign_in")}:null;const l=p=>e.actions.includes(p),d=ft(e),u=Ge(e,s,i);if(!ns(e.status))return l("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.check_again")}:null;const c=Qe(e.name,s,i),m=c?.status==="failed"&&We(c);switch(Jt(e,i)){case"connected":case"connecting":return null;case"needs_sign_in":return u?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:l("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}:d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:l("reauth")?{kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};case"error":return l("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}:l("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.retry")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};default:{if(xt(c)&&l("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")};if(en(c)&&l("sign_out"))return{kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out_again")};if(i.disconnectedAt!==null&&l("connect"))return{kind:"connect",label:n("ui.settings.integrations.integration_model.connect")};if(i.needsSignIn){if(u&&d)return{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")};if(l("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}}return u&&d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:m&&l("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.try_again")}:Zt(e,i)&&!l("connect")?null:l("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.connect"),...i.connectedAt===null&&e.status_basis!=="live"?{variant:"ghost"}:{}}:l("test")&&e.tool_count===null&&e.tool_count_basis===null?{kind:"test",label:n("ui.settings.integrations.integration_model.test"),variant:"ghost"}:null}}}const We=e=>e.action==="login"||e.action==="reauth",xt=e=>!!(e&&e.action==="logout"&&e.status==="complete"),en=e=>!!(e&&e.action==="logout"&&e.status!=="running"&&e.status!=="complete"),os=/no oauth authorization server/i;function Ge(e,s,a){if(!ft(e))return!1;const i=Qe(e.name,s,a);return i&&We(i)&&i.status==="failed"&&os.test(i.message??"")?!0:a.needsKey}function Ul(e,s=[],a){const i=Xt(e,s,a)?.kind,o=Jt(e,De(a,e.name)),l=c=>e.actions.includes(c),d=[],u=Ue(e.name,s);if(u&&d.push({kind:"cancel",label:n("ui.settings.integrations.integration_model.cancel")}),!u&&l("test")&&i!=="test"&&d.push({kind:"test",label:n("ui.settings.integrations.integration_model.test_connection")}),l("connect")&&i!=="connect"&&o!=="connected"&&d.push({kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}),!u&&l("sign_in")&&i!=="sign_in"&&o!=="connected"&&d.push({kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}),l("reload")&&d.push({kind:"reload",label:n("ui.settings.integrations.integration_model.reload")}),!u&&l("reauth")&&i!=="reauth"&&d.push({kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}),ft(e)&&i!=="set_key"&&d.push({kind:"set_key",label:e.auth.secret_refs.length>0?n("ui.settings.integrations.integration_model.update_key"):n("ui.settings.integrations.integration_model.add_key")}),l("sign_out")&&d.push({kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out")}),l("disconnect")&&o==="connected"&&d.push({kind:"disconnect",label:n("ui.settings.integrations.integration_model.disconnect")}),l("copy_setup")&&e.setup_prompt&&d.push({kind:"copy_setup",label:n("ui.settings.integrations.integration_model.copy_setup_prompt")}),i!=="fix"&&d.push({kind:"open_config",label:n("ui.settings.integrations.integration_model.open_config_file")}),l("remove"))d.push({kind:"remove",label:n("ui.settings.integrations.integration_model.remove"),destructive:!0});else if(!e.source.editable){const c=is(e);d.push({kind:"remove_elsewhere",label:c?n("ui.settings.integrations.integration_model.remove_in_origin",{origin:String(c)}):n("ui.settings.integrations.integration_model.remove_in_its_own_file"),hint:c?n("ui.settings.integrations.integration_model.defined_in_origin_s_config_remove_it_there",{origin:String(c)}):n("ui.settings.integrations.integration_model.defined_in_a_file_this_app_doesn_t_write_remove_it_there")})}return d}const Bl={get attention(){return n("ui.settings.integrations.integration_model.needs_attention")},get connected(){return n("ui.settings.integrations.integration_model.connected")},get ready(){return n("ui.settings.integrations.integration_model.available")}};function rs(e,s=[],a){const i=De(a,e.name),o=Ue(e.name,s),l=Jt(e,i);if(o&&i.pinnedGroup&&i.pinnedOperationId===o.id)return i.pinnedGroup;if(l==="needs_sign_in"||l==="error")return"attention";const d=Qe(e.name,s,i);return xt(d)&&l!=="connected"||en(d)&&l!=="connected"?"attention":i.disconnectedAt!==null?"ready":Ge(e,s,i)||i.needsSignIn&&l!=="connected"||d?.status==="failed"&&We(d)&&l!=="connected"?"attention":l==="connected"||e.status_basis==="stored"&&Zt(e,i)?"connected":o&&o.action!=="test"?"attention":"ready"}function Hl(e,s=[],a){return["attention","connected","ready"].map(o=>({id:o,title:Bl[o],rows:e.filter(l=>rs(l,s,a)===o)})).filter(o=>o.rows.length>0)}function Vl(e,s,a=Date.now()){if(!s)return e??{};const i={};for(const o of s.servers){const l=De(e,o.name),d=Ue(o.name,s.operations),u=Qe(o.name,s.operations,l),c=xt(u),m=o.status==="connected"&&(o.status_basis==="probe"||o.status_basis==="live"),p=l.holdUntil!==null&&a<l.holdUntil,f=!p&&!c&&l.connectedAt===null&&o.status_basis==="stored"&&o.tool_count_basis==="last_seen"?ss(o.last_seen_at,a):null,b=!c,h=u?.status==="failed"&&We(u)&&os.test(u.message??""),_={connectedAt:m&&!p?a:f!==null?f:b?l.connectedAt:null,connectedToolCount:m&&!p||f!==null?o.tool_count??l.connectedToolCount:b?l.connectedToolCount:null,settledGroup:l.settledGroup,pinnedGroup:d&&l.pinnedOperationId===d.id?l.pinnedGroup:d?l.settledGroup:null,pinnedOperationId:d?d.id:null,needsKey:m?!1:l.needsKey||h,needsSignIn:m||c?!1:l.needsSignIn||o.status==="needs_sign_in",disconnectedAt:m&&!p?null:l.disconnectedAt,holdUntil:p?l.holdUntil:null,lastDecisive:u?Rl(u):null};d||(_.settledGroup=rs(o,s.operations,{...i,[o.name]:_})),i[o.name]=_}return i}const Gl=(e,s)=>e!==null&&s===e,$t="local-operator.settings.integrations.row-memory",ls=(e,s)=>`${e}#${s}`;function ql(e,s){const a={};if(!s)return a;for(const i of s.servers){const o=e[i.name];o&&(a[ls(i.source.path,i.name)]=o)}return a}function Yl(e,s,a){if(!s)return e;let i=null;for(const o of s.servers){if(Object.prototype.hasOwnProperty.call(e,o.name))continue;const l=Zl(a[ls(o.source.path,o.name)]);l&&(i=i??{...e},i[o.name]=l)}return i??e}const Ql=["attention","connected","ready"],cs=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),tn=e=>typeof e=="number"&&Number.isFinite(e)?e:null,yn=e=>Ql.includes(e)?e:null,Ct=e=>{const s=tn(e);return s!==null&&s>=1e12?s:null};function Wl(e){if(!cs(e)||typeof e.id!="string"||typeof e.name!="string")return null;const s=e.action,a=e.status;return s!=="login"&&s!=="logout"&&s!=="reauth"&&s!=="test"||a!=="running"&&a!=="complete"&&a!=="cancelled"&&a!=="failed"?null:{id:e.id,name:e.name,action:s,status:a,created_at:tn(e.created_at)??0,credential_removed:e.credential_removed===!0,...typeof e.message=="string"?{message:e.message}:{}}}function Zl(e){if(!cs(e))return null;const s=Ct(e.connectedAt),a=Ct(e.disconnectedAt),i=e.needsKey===!0,o=e.needsSignIn===!0,l=Wl(e.lastDecisive);return s===null&&a===null&&!i&&!o&&!l?null:{connectedAt:s,connectedToolCount:tn(e.connectedToolCount),settledGroup:yn(e.settledGroup),pinnedGroup:yn(e.pinnedGroup),pinnedOperationId:typeof e.pinnedOperationId=="string"?e.pinnedOperationId:null,needsKey:i,needsSignIn:o,disconnectedAt:a,holdUntil:Ct(e.holdUntil),lastDecisive:l}}const ds=2e3,kn=8e3;function Jl(e){return e&&(e.servers.some(a=>a.status==="connecting")||e.operations.some(a=>a.status==="running"))?ds:!1}const Xl=/^[A-Za-z0-9_.:-]{1,100}$/,ec=/:\/\//;function tc(e,s){const a=e.trim();return a?Xl.test(a)?s.includes(a)?n("ui.settings.integrations.integration_model.an_integration_named_trimmed_already_exists",{trimmed:String(a)}):null:n("ui.settings.integrations.integration_model.use_letters_numbers_dots_dashes_underscores_or_colons_with_no_spa"):n("ui.settings.integrations.integration_model.give_it_a_name")}function nc(e){const s=e.trim();if(!s)return n("ui.settings.integrations.integration_model.enter_the_server_s_url");let a;try{a=new URL(s)}catch{return n("ui.settings.integrations.integration_model.enter_a_full_url_like_https_mcp_example_com_mcp")}return a.protocol!=="https:"&&a.protocol!=="http:"?n("ui.settings.integrations.integration_model.the_url_must_start_with_https_or_http"):a.hostname?a.username||a.password?n("ui.settings.integrations.integration_model.remove_the_username_or_password_from_the_url_keys_are_added_after"):a.search||a.hash?n("ui.settings.integrations.integration_model.remove_the_or_part_of_the_url_keys_are_added_after_it_s_saved"):ec.test(s.slice(a.protocol.length+2))?n("ui.settings.integrations.integration_model.this_looks_like_two_urls_pasted_together_enter_just_one"):null:n("ui.settings.integrations.integration_model.the_url_needs_a_host_name")}const sc=e=>e.split(`
|
|
292
|
-
`).map(s=>s.trim()).filter(Boolean);function Kt(e,s){const a=!!e?.cold,i=(e?.servers??[]).map(o=>{const l=o.transport==="http",d=o.secret_refs??[],u=o.status==="connected"?"connected":o.status==="connecting"?"connecting":o.status==="auth-required"?"needs_sign_in":"not_started",c=[];u!=="connected"&&c.push("connect"),u==="connected"&&c.push("disconnect"),a||c.push("reload"),l&&o.transport_oauth_supported!==!1&&c.push("sign_in"),d.length>0&&c.push("set_key"),o.owned_scope&&c.push("remove"),o.setup?.text&&c.push("copy_setup");const m=ts(o.source);return{id:o.name,name:o.name,scope:o.owned_scope??"global",project_cwd:null,source:{kind:ac(o.source,m,o.owned_scope),path:o.source??"",editable:o.owned_scope!==null,owned_scope:o.owned_scope},transport:l?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:u,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:a?"stored":"live",auth:{kind:d.length?"api_key":l?"unknown":"none",signed_in:null,secret_refs:d.map(p=>({id:p.id,state:"missing"}))},tool_count:typeof o.tool_count=="number"?o.tool_count:null,tool_count_basis:typeof o.tool_count=="number"?"live":null,actions:c,setup_prompt:o.setup?.text??null}});return{cwd:"",project_scope_available:i.some(o=>o.source.owned_scope==="project"),global_path:"",project_path:null,status_source:a?"config":"live",session_id:s,servers:i,operations:(e?.operations??[]).map(o=>({...o}))}}const ac=(e,s,a)=>s==="Claude Code"?"claude-code":s==="Cursor"?"cursor":s==="VS Code"?"vscode":s==="Codex CLI"?"codex":a?"local-operator":e?"project-mcp-json":"local-operator",bn={get invalid_config(){return n("ui.settings.integrations.integration_model.that_configuration_isn_t_valid_check_the_command_or_the_url_then_")},get operation_unavailable(){return n("ui.settings.integrations.integration_model.that_sign_in_or_test_isn_t_running_any_more_try_again")},get exists(){return n("ui.settings.integrations.integration_model.an_integration_with_this_name_already_exists_choose_another_name")},get not_owned(){return n("ui.settings.integrations.integration_model.it_s_defined_in_another_tool_s_config_so_it_can_t_be_changed_here")},get project_scope_unavailable(){return n("ui.settings.integrations.integration_model.there_s_no_separate_project_config_here_so_it_can_only_be_added_g")},get unknown_server(){return n("ui.settings.integrations.integration_model.it_no_longer_exists_the_list_has_been_refreshed")},get oauth_unsupported(){return n("ui.settings.integrations.integration_model.it_doesn_t_use_browser_sign_in")},get grant_running(){return n("ui.settings.integrations.integration_model.a_sign_in_or_test_is_already_running_wait_for_it_to_finish_or_can")},get too_many_operations(){return n("ui.settings.integrations.integration_model.too_many_sign_ins_and_tests_are_waiting_try_again_in_a_moment")},get write_failed(){return n("ui.settings.integrations.integration_model.the_config_file_couldn_t_be_written_check_that_it_isn_t_read_only")},get mcp_starting(){return n("ui.settings.integrations.integration_model.integrations_are_still_starting_try_again_in_a_moment")},get mcp_control_refused(){return n("ui.settings.integrations.integration_model.the_server_refused_it_so_nothing_was_changed")}},ic="ui.settings.integrations.integration_model.copy_catalog_refusal_fallback";function at(e,s,a){if(s instanceof Yt&&s.status===409){const i=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(bn,s.code)?bn[s.code]:n(ic);return`${Bs[e]}. ${i}`}return Hs(e,s,a).message}const oc="ui.settings.integrations.add_integration_form.copy_add_integration_pickup_note",rc="ui.settings.integrations.add_integration_form.copy_transport_hint",lc=({existingNames:e,projectScopeAvailable:s,projectLabel:a,onSubmit:i,onCancel:o,initial:l})=>{ee();const[d,u]=r.useState(l?.name??""),[c,m]=r.useState(l?.mode??"command"),[p,f]=r.useState(l?.command??""),[b,h]=r.useState(l?.args??""),[_,w]=r.useState(l?.url??""),[A,K]=r.useState("global"),[C,O]=r.useState(l?.touched?{name:!0,command:!0,url:!0}:{}),[T,L]=r.useState(!!l?.touched),[I,W]=r.useState(!1),[X,J]=r.useState(null),D=r.useRef(null),te=r.useRef(null),z=r.useRef(null);r.useEffect(()=>{D.current?.focus()},[]);const P=tc(d,e),H=c==="command"&&!p.trim()?n("ui.settings.integrations.add_integration_form.enter_the_command_to_run"):null,U=c==="url"?nc(_):null,R=v=>T||C[v],Y=async v=>{if(v.preventDefault(),L(!0),P||H||U){P?D.current?.focus():H?te.current?.focus():z.current?.focus();return}W(!0),J(null);const Q=s?A:"global",$=c==="command"?{name:d.trim(),scope:Q,mode:c,command:p.trim(),args:sc(b)}:{name:d.trim(),scope:Q,mode:c,url:_.trim()},ne=await i($);W(!1),J(ne)},y=(v,Q,$)=>Q&&R($)?t.jsx("p",{id:v,className:"text-body-sm text-danger",children:Q}):null,x=v=>v.preventDefault();return t.jsxs("form",{noValidate:!0,"aria-label":n("ui.settings.integrations.add_integration_form.add_integration"),className:"flex flex-col gap-4 rounded-lg bg-surface p-4",onSubmit:v=>void Y(v),onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),o())},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-name",children:n("ui.settings.integrations.add_integration_form.name")}),t.jsx(Ae,{ref:D,id:"integration-add-name",value:d,placeholder:n("ui.settings.integrations.add_integration_form.e_g_notion"),autoComplete:"off","aria-invalid":!!(P&&R("name")),"aria-describedby":P&&R("name")?"integration-add-name-error":void 0,onChange:v=>u(v.target.value),onBlur:()=>O(v=>({...v,name:!0}))}),y("integration-add-name-error",P,"name")]}),t.jsxs(gt,{value:c,onValueChange:v=>m(v==="url"?"url":"command"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-transport-label",className:"font-medium text-body-sm text-ink",children:n("ui.settings.integrations.add_integration_form.how_it_runs")}),t.jsxs(_t,{"aria-labelledby":"integration-add-transport-label",children:[t.jsx($e,{value:"command","data-integration-transport":"command",children:n("ui.settings.integrations.add_integration_form.local_command")}),t.jsx($e,{value:"url","data-integration-transport":"url",children:n("ui.settings.integrations.add_integration_form.remote_url")})]}),t.jsx("p",{className:"text-ink-dim text-meta",children:n(rc)}),t.jsxs(un,{value:"command",className:"mt-0 flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-command",children:n("ui.settings.integrations.add_integration_form.command")}),t.jsx(Ae,{ref:te,id:"integration-add-command",value:p,placeholder:n("ui.settings.integrations.add_integration_form.e_g_npx"),autoComplete:"off",className:"font-mono","aria-invalid":!!(H&&R("command")),"aria-describedby":H&&R("command")?"integration-add-command-error":void 0,onChange:v=>f(v.target.value),onBlur:()=>O(v=>({...v,command:!0}))}),y("integration-add-command-error",H,"command")]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs(we,{htmlFor:"integration-add-args",children:[n("ui.settings.integrations.add_integration_form.arguments")," ",t.jsx("span",{className:"font-normal text-ink-dim",children:n("ui.settings.integrations.add_integration_form.one_per_line")})]}),t.jsx(Gn,{id:"integration-add-args",value:b,rows:2,className:"font-mono",onChange:v=>h(v.target.value)})]})]}),t.jsx(un,{value:"url",className:"mt-0 flex flex-col gap-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-url",children:n("ui.settings.integrations.add_integration_form.url")}),t.jsx(Ae,{ref:z,id:"integration-add-url",type:"url",value:_,placeholder:n("ui.settings.integrations.add_integration_form.https_mcp_example_com_mcp"),autoComplete:"off",className:"font-mono","aria-invalid":!!(U&&R("url")),"aria-describedby":U&&R("url")?"integration-add-url-error":"integration-add-url-help",onChange:v=>w(v.target.value),onBlur:()=>O(v=>({...v,url:!0}))}),y("integration-add-url-error",U,"url")??t.jsx("p",{id:"integration-add-url-help",className:"text-ink-dim text-meta",children:n("ui.settings.integrations.add_integration_form.if_it_needs_a_sign_in_or_a_key_you_ll_be_asked_after_it_s_added")})]})})]}),s?t.jsxs(gt,{value:A,onValueChange:v=>K(v==="project"?"project":"global"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-scope-label",className:"font-medium text-body-sm text-ink",children:n("ui.settings.integrations.add_integration_form.available_in")}),t.jsxs(_t,{"aria-labelledby":"integration-add-scope-label",children:[t.jsx($e,{value:"global","data-integration-scope":"global",children:n("ui.settings.integrations.add_integration_form.all_chats")}),t.jsx($e,{value:"project","data-integration-scope":"project",children:n("ui.settings.integrations.add_integration_form.this_project")})]}),a?t.jsx("p",{className:"text-ink-dim text-meta",children:A==="project"?n("ui.settings.integrations.add_integration_form.only_chats_working_in_projectlabel",{projectLabel:String(a)}):n("ui.settings.integrations.add_integration_form.every_chat_in_any_folder")}):null]}):null,X?t.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:X}):null,t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("p",{className:ue("text-body-sm text-ink-dim"),children:n(oc)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(G,{type:"button",variant:"ghost",size:"md",onMouseDown:x,onClick:o,children:n("ui.settings.integrations.add_integration_form.cancel")}),t.jsxs(G,{type:"submit",variant:"primary",size:"md",disabled:I,onMouseDown:x,children:[I?t.jsx(he,{size:"xs"}):null,n("ui.settings.integrations.add_integration_form.add_integration")]})]})]})]})},cc=4;function dc(e){return e.rowMoving?e.now+e.windowMs:Math.max(e.hold.until,e.lastMovingAt+e.windowMs)}function uc(e){return e.now>e.hold.until||e.hold.reanchors>=cc?"drop":e.hold.landedOn.isConnected&&(!e.candidate||e.candidate===e.hold.landedOn)?"settled":e.active&&e.active!==e.body&&e.active!==e.hold.landedOn?"drop":e.candidate?.isConnected?"restore":"drop"}function mc(e){const s=dc({hold:e.hold,now:e.now,windowMs:e.windowMs,rowMoving:e.rowMoving,lastMovingAt:e.lastMovingAt});if(e.now>s)return{hold:null,land:null};const a=e.hold.landedOn??null,i=e.candidate;if(!i)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:null};if(!a)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:i},land:i};const o=uc({hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},candidate:i,active:e.active,body:e.body,now:e.now});if(o==="settled")return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:null};if(o==="drop")return{hold:null,land:null};const l=!a.isConnected;return{hold:{until:l?e.now+e.windowMs:s,reanchors:l?e.hold.reanchors+1:e.hold.reanchors,landedOn:i},land:i}}function gc(e){const{row:s,target:a}=e;return!s||!a||typeof a.nodeType!="number"?!1:!s.contains(a)}const vn=250;function jn(e){return e?!e.disabled:!1}function _c(e){return jn(e.primary)?e.primary??null:jn(e.overflow)?e.overflow??null:null}function pc(e){return e.verdict==="finished"?null:e.watchMs}const us="key";function hc(e){const{name:s,keyless:a,freeName:i,names:o,values:l,replace:d,canReplace:u}=e;if(a){const c=Ut(s,i);return{values:{[c]:(l[us]??"").trim()},confirmedReplace:d&&u?[c]:[],header:i.trim()}}return{values:Object.fromEntries(o.map(c=>[c,(l[c]??"").trim()])),confirmedReplace:d&&u?o:[],header:void 0}}function Ut(e,s){const a=wn(e),i=wn(s);if(!i)return"";const o=[a,i].filter(Boolean).join("_"),l=/^[A-Za-z_]/.test(o)?o:`K_${o}`;if(l.length<=Mt)return l;const d=fc(a),u=Mt-i.length-d.length-2,c=[a.slice(0,Math.max(u,0)),d,i].filter(Boolean).join("_");return c.length<=Mt?c:c.slice(-128)}const Mt=128,wn=e=>e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),fc=e=>{let s=2166136261;for(let a=0;a<e.length;a+=1)s^=e.charCodeAt(a),s=Math.imul(s,16777619)>>>0;return s.toString(36).toUpperCase().slice(0,5)},xc=({name:e,keyNames:s,keyless:a=!1,savedKeys:i=[],saving:o,failure:l,onSave:d,onClose:u})=>{ee();const[c,m]=r.useState({}),[p,f]=r.useState(!1),[b,h]=r.useState(""),_=a?[Ut(e,b)]:[...s],w=a?[us]:_,A=(a?Ut(e,b).length>0:!0)&&w.every(C=>(c[C]??"").trim()),K=_.some(C=>i.includes(C));return t.jsx(Dn,{open:!0,onClose:u,maxWidth:"xs",title:n("ui.settings.integrations.integration_key_dialog.add_keys_heading",{count:a?1:s.length,name:e}),actions:t.jsxs(t.Fragment,{children:[t.jsx(Tt,{onClick:u,children:n("ui.settings.integrations.integration_key_dialog.cancel")}),t.jsx(Lt,{disabled:!A||o,onClick:()=>{const C=hc({name:e,keyless:a,freeName:b,names:_,values:c,replace:p,canReplace:K});d(C.values,C.confirmedReplace,C.header)},children:o?n("ui.settings.integrations.integration_key_dialog.saving"):n("ui.settings.integrations.integration_key_dialog.save_and_test")})]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[t.jsx("p",{className:"-mx-1.5",children:a?n("ui.settings.integrations.integration_key_dialog.keys_are_saved_encrypted_on_this_computer_this_one_is_stored_unde"):n("ui.settings.integrations.integration_key_dialog.keys_are_saved_encrypted_on_this_computer_other_integrations_that")}),a?t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-key-name",children:n("ui.settings.integrations.integration_key_dialog.the_header_this_server_wants_the_key_in")}),t.jsx(Ae,{id:"integration-key-name",autoComplete:"off",placeholder:n("ui.settings.integrations.integration_key_dialog.e_g_authorization_or_x_api_key"),value:b,onChange:C=>h(C.target.value)}),t.jsx("p",{className:"-mx-1.5 text-ink-dim text-meta",children:n("ui.settings.integrations.integration_key_dialog.this_server_declares_no_key_of_its_own_so_local_operator_adds_one")})]}):null,w.filter(C=>a!==!0||C.trim().length>0).map(C=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:`integration-key-${C}`,className:"font-mono",children:a?"Key":C}),t.jsx(Ae,{id:`integration-key-${C}`,type:"password",autoComplete:"off",value:c[C]??"",onChange:O=>m(T=>({...T,[C]:O.target.value}))})]},C)),K?t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(zt,{id:"integration-key-replace",checked:p,onCheckedChange:C=>f(C===!0)}),t.jsx(we,{htmlFor:"integration-key-replace",className:"font-normal",children:as(_.length)})]}):null,l?t.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:l}):null]})})},yc={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},kc={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"};function Nn(e){if(e===n("ui.settings.integrations.integration_model.ready"))return n(zl);if(e===n("ui.settings.integrations.integration_model.not_connected"))return n(Pl)}const bc=({row:e,operations:s,memories:a,now:i,projectScopeAvailable:o,highlighted:l=!1,rowRef:d,primaryRef:u,overflowRef:c,pending:m,failure:p,confirm:f,onPrimary:b,onOverflow:h,onConfirm:_,onCancelConfirm:w})=>{ee();const A=Ol(e,s,a,i),K=l&&A.tone==="danger"?"text-ink":kc[A.tone],C=Xt(e,s,a),O=Ul(e,s,a),T=Kl(e,o),L=O.findIndex(I=>I.kind==="remove"||I.kind==="remove_elsewhere");return t.jsxs("li",{ref:d,"data-integration":e.name,"data-status":e.status,className:ue("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",l&&"bg-row-selected"),onKeyDown:I=>{!f||I.key!=="Escape"||(I.stopPropagation(),w())},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:A.busy?t.jsx(he,{size:"xs"}):t.jsx("span",{"aria-hidden":"true","data-tone":A.tone,className:ue("size-2 rounded-full",yc[A.tone])})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsx("span",{className:"truncate font-medium text-body text-ink",title:e.name,children:e.name}),t.jsx("span",{className:"truncate text-ink-dim text-meta",children:T.map((I,W)=>t.jsxs("span",{children:[W>0?" · ":null,I.startsWith("Imported from")&&e.source.path?t.jsx(Ke,{content:Vs(e.source.path),children:t.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:I})}):I]},I))})]}),Nn(A.label)?t.jsx(Ke,{content:Nn(A.label),children:t.jsx("span",{className:ue("shrink-0 text-body-sm",K),children:A.label})}):t.jsx("span",{className:ue("shrink-0 text-body-sm",K),children:A.label}),C?t.jsxs(G,{ref:u,variant:C.variant??"secondary",size:"sm","aria-label":`${C.label} ${e.name}`,disabled:m,"data-integration-action":C.kind,onClick:()=>b(C),children:[m?t.jsx(he,{size:"xs"}):null,C.label]}):null,t.jsxs(mi,{children:[t.jsx(gi,{asChild:!0,children:t.jsx(G,{ref:c,variant:"ghost",size:"icon-sm","aria-label":n("ui.settings.integrations.integration_row.more_actions_for_name",{name:String(e.name)}),disabled:m,children:t.jsx(Gs,{"aria-hidden":"true"})})}),t.jsx(_i,{align:"end",className:"min-w-48",children:O.map((I,W)=>t.jsx(vc,{item:I,separated:W===L&&W>0,onSelect:()=>h(I)},I.kind))})]})]}),A.detail?t.jsx("p",{className:ue("pl-7 text-body-sm",A.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:A.detail}):null,p?t.jsx("p",{className:ue("pl-7 text-body-sm",l?"text-ink":"text-danger"),role:"alert",children:p}):null,f?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-7",children:[t.jsx("span",{className:"text-body-sm text-ink",children:f.kind==="remove"?n("ui.settings.integrations.integration_row.remove_name",{name:String(e.name)}):n("ui.settings.integrations.integration_row.sign_out_of_name",{name:String(e.name)})}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:f.kind==="remove"?n("ui.settings.integrations.integration_row.agents_in_every_chat_lose_access_to_name",{name:String(e.name)}):e.auth.kind==="oauth"?n("ui.settings.integrations.integration_row.the_saved_sign_in_is_removed_too"):n("ui.settings.integrations.integration_row.its_saved_credential_is_removed_too")}),t.jsx(G,{variant:"danger",size:"sm",onClick:_,"data-integration-confirm":f.kind,children:f.kind==="remove"?n("ui.settings.integrations.integration_row.remove"):n("ui.settings.integrations.integration_row.sign_out")}),t.jsx(G,{variant:"ghost",size:"sm",onClick:w,children:n("ui.settings.integrations.integration_row.keep")})]}):null]})},vc=({item:e,separated:s,onSelect:a})=>(ee(),t.jsxs(t.Fragment,{children:[s?t.jsx(pi,{}):null,e.kind==="remove_elsewhere"?t.jsxs(mn,{disabled:!0,className:"flex-col items-start gap-0.5",children:[t.jsx("span",{children:e.label}),t.jsx("span",{className:"text-meta text-ink-dim",children:e.hint})]}):t.jsx(mn,{destructive:e.kind==="remove",onSelect:a,"data-integration-menu":e.kind,children:e.label})]}));function jc(e,s,a){return!s||s.status==="running"?s?.browser_opened===!0?{message:n("ui.settings.integrations.integration_sign_in_dialog.your_browser_opened_approve_access_to_name_there_then_come_back_h",{name:String(e)}),tone:"progress",link:s.authorization_url??null}:s?.browser_opened===!1?{message:s.authorization_url?n("ui.settings.integrations.integration_sign_in_dialog.your_browser_didn_t_open_open_this_link_to_approve_access"):n("ui.settings.integrations.integration_sign_in_dialog.your_browser_didn_t_open_and_no_link_was_provided_cancel_and_try_"),tone:"progress",link:s.authorization_url??null}:{message:n("ui.settings.integrations.integration_sign_in_dialog.waiting_for_you_to_approve_access_to_name",{name:String(e)}),tone:"progress",link:s?.authorization_url??null}:s.status==="complete"?{message:n("ui.settings.integrations.integration_sign_in_dialog.signed_in_to_name_agents_can_use_it_now",{name:String(e)}),tone:"success",link:null}:s.status==="cancelled"?{message:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_cancelled"),tone:"failure",link:null,reason:null,nextStep:n("ui.settings.integrations.integration_sign_in_dialog.press_try_again_when_you_are_ready")}:{message:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_didn_t_finish"),tone:"failure",link:null,reason:Dl(s.message,a)??n("ui.settings.integrations.integration_sign_in_dialog.the_server_didn_t_say_why"),nextStep:wc(s.message??null,a)}}function wc(e,s){const a=(e??"").toLowerCase();return a.includes("redirect")?s?n("ui.settings.integrations.integration_sign_in_dialog.this_server_may_not_accept_sign_ins_from_local_operator_check_the"):n("ui.settings.integrations.integration_sign_in_dialog.this_server_may_not_accept_sign_ins_from_local_operator_check_the_2"):a.includes("no oauth")||a.includes("authorization server")?s?n("ui.settings.integrations.integration_sign_in_dialog.this_server_doesn_t_publish_a_browser_sign_in_add_its_key_instead"):n("ui.settings.integrations.integration_sign_in_dialog.this_server_doesn_t_publish_a_browser_sign_in_check_the_server_s_"):a.includes("network")||a.includes("connect")?n("ui.settings.integrations.integration_sign_in_dialog.check_the_server_s_url_and_your_network_then_try_again"):n("ui.settings.integrations.integration_sign_in_dialog.check_the_server_s_settings_then_try_again")}function Nc(e,s){return e.kind==="ready"?"ready":e.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const Sc=({name:e,action:s,keyRoute:a,phase:i,onStart:o,onCancel:l,onOpenLink:d,onClose:u})=>{ee();const c=i.kind==="running"?i.operation:null,m=i.kind==="running"?jc(e,c,a):null,p=i.kind==="starting"||i.kind==="running"&&m?.tone==="progress",f=m&&m.tone!=="progress",b=r.useRef(null),h=r.useRef(!1),_=Nc(i,m);r.useEffect(()=>{if(!h.current){h.current=!0;return}_&&b.current?.focus()},[_]);const w=()=>u(m?.tone==="success"?"signed-in":"dismissed");return t.jsx(Dn,{open:!0,onClose:w,maxWidth:"xs",fullWidth:!0,title:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_to_name",{name:String(e)}),dialogProps:{onOpenAutoFocus:A=>{A.preventDefault(),b.current?.focus()}},actions:t.jsxs(t.Fragment,{children:[p&&c?t.jsx(Tt,{ref:b,onClick:()=>l(c.id),children:n("ui.settings.integrations.integration_sign_in_dialog.cancel_sign_in")}):t.jsx(Tt,{ref:i.kind==="ready"?void 0:b,onClick:w,children:m?.tone==="success"?n("ui.settings.integrations.integration_sign_in_dialog.done"):n("ui.settings.integrations.integration_sign_in_dialog.close")}),i.kind==="ready"?t.jsx(Lt,{ref:b,onClick:o,children:n("ui.settings.integrations.integration_sign_in_dialog.continue_in_browser")}):null,i.kind==="refused"||m?.tone==="failure"?t.jsx(Lt,{ref:m?.tone==="failure"?b:void 0,onClick:o,children:n("ui.settings.integrations.integration_sign_in_dialog.try_again")}):null]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted","aria-live":"polite",children:[i.kind==="ready"?t.jsx("p",{className:"-mx-1.5",children:n("ui.settings.integrations.integration_sign_in_dialog.browser_approval_notice",{name:e,replaces:s==="reauth"?"yes":"no"})}):null,i.kind==="starting"?t.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[t.jsx(he,{size:"xs"}),n("ui.settings.integrations.integration_sign_in_dialog.starting_sign_in")]}):null,m?t.jsxs("div",{className:"flex flex-col gap-1",role:f?"status":void 0,children:[t.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?t.jsx(he,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?t.jsx(hi,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-danger"}):null,t.jsx("span",{children:m.message})]}),m.reason?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.reason}):null,m.nextStep?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.nextStep}):null]}):null,m?.link&&m.tone==="progress"?t.jsxs("div",{className:"flex flex-col items-start gap-1",children:[t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-dim text-mono-sm",title:m.link,children:m.link}),t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":n("ui.settings.integrations.integration_sign_in_dialog.copy_the_sign_in_link"),title:n("ui.settings.integrations.integration_sign_in_dialog.copy_the_sign_in_link"),onClick:()=>{navigator.clipboard.writeText(m.link??"").then(()=>Ot(n("ui.settings.integrations.integration_sign_in_dialog.sign_in_link_copied"))).catch(()=>{})},children:t.jsx(Fn,{"aria-hidden":"true"})})]}),t.jsx(G,{variant:"link",size:"sm",onClick:()=>d(m.link??""),children:n("ui.settings.integrations.integration_sign_in_dialog.open_the_sign_in_page")})]}):null,i.kind==="refused"?t.jsx("p",{className:"text-danger",role:"alert",children:i.message}):null]})})},Cc=e=>e.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),Mc=/^[A-Za-z]:[\\/]/,mt=e=>{const s=e?.trim();return s&&(s.startsWith("/")||Mc.test(s))?s:null};function Ac(e){const o=e?.payload?.frontend?.snapshot?.cwd;return typeof o=="string"&&o.trim()?o:null}const Ye="local-operator.settings.integrations.last-cwd";function Ic(e,s,a=typeof localStorage>"u"?null:localStorage){const i=mt(s);if(!(!e||!i||!a))try{const o=a.getItem(Ye),l=o?JSON.parse(o):{};if(l[e]===i)return;a.setItem(Ye,JSON.stringify({...l,[e]:i}))}catch{}}const ms=()=>typeof localStorage>"u"?null:localStorage;function gs(e=ms()){if(!e)return{};try{const s=e.getItem($t);if(!s)return{};const a=JSON.parse(s);return!a||typeof a!="object"||Array.isArray(a)?{}:a}catch{return{}}}const Sn=256;function Rc(e,s=ms()){if(s)try{const a={...gs(s),...e},i=Object.keys(a);if(i.length>Sn){const o={};for(const l of i.slice(-Sn))o[l]=a[l];s.setItem($t,JSON.stringify(o));return}s.setItem($t,JSON.stringify(a))}catch{}}function Cn(e,s,a){if(e==="saved")return null;if(e==="replace_confirmation_required"){const o=as(Object.keys(a).length);return n("ui.settings.integrations.use_integrations.a_saved_value_already_exists_for_this_key_tick_label_to_overwrite",{label:String(o)})}if(e==="invalid_target")return n("ui.settings.integrations.use_integrations.that_header_can_t_carry_this_key_it_may_already_be_set_on_the_ser");const i=s.length?s:Object.keys(a);return n("ui.settings.integrations.use_integrations.keys_not_saved",{keys:String(i.join(", "))})}function Ec(e,s=typeof localStorage>"u"?null:localStorage){if(!(!e||!s))try{const a=s.getItem(Ye);if(!a)return;const i=JSON.parse(a);if(!(e in i))return;const o={...i};delete o[e],s.setItem(Ye,JSON.stringify(o))}catch{}}const Tc=e=>!!(e&&typeof e=="object"&&"code"in e&&e.code==="invalid_cwd"),Lc=(e,s)=>s!==null&&e===s?null:e;function Oc(e,s=typeof localStorage>"u"?null:localStorage){if(!e||!s)return null;try{const a=s.getItem(Ye);if(!a)return null;const o=JSON.parse(a)[e];return typeof o=="string"?o:null}catch{return null}}const Fc=e=>e.action==="disconnect"?"disconnected":"connected";function Dc(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"connect":case"disconnect":case"reload":return null;case"test":return{action:"test",name:e.name};default:return{...e,confirmed:!0}}}function zc(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"test":case"connect":return{action:"connect",name:e.name};case"reload":return{action:"reload",name:e.name};case"add":return e;case"remove":return{...e,confirmed:!0};default:return{action:e.action,name:e.name,confirmed:!0}}}function Pc({sessionId:e}){const s=Gt(),a=Rt(s.data,"mcp_catalog"),i=Rt(s.data,"mcp"),o=a?"catalog":i?"session":null,[l,d]=r.useState(null),u=Ht(),c=lt(j=>j.sessions),m=lt(j=>j.fetchSessions),p=lt(j=>j.loading),f=r.useMemo(()=>c.find(j=>j.session_id===e)??null,[c,e]),b=r.useMemo(()=>o==="session"&&!e?Cc(c):null,[o,e,c]),h=o==="session"?e??b?.session_id??null:null;r.useEffect(()=>{o!=="session"||e||c.length>0||m(qs)},[o,e,c.length,m]);const _=o==="catalog"?mt(f?.cwd):null,w=o==="catalog"&&!!e&&_===null,A=be({queryKey:["desktop","session-cwd",e??""],queryFn:()=>de({op:"sessions.get",sessionId:e??""}),enabled:w,staleTime:Number.POSITIVE_INFINITY,retry:!1}),K=w&&!A.isFetched,C=_??mt(Ac(A.data))??(A.isFetched?mt(Oc(e)):null),O=Lc(C,l),T=o==="catalog"?O:null,L=o==="catalog"?e??null:null,I=Ys.catalog(T,L);r.useEffect(()=>{o!=="catalog"||!e||!T||Ic(e,T)},[o,e,T]);const W=r.useRef(0),[X,J]=r.useState(0),D=r.useRef(null),te=r.useCallback((j,B)=>{const q=Date.now()+kn;W.current=q,D.current={name:j,expect:B},J(q)},[]),z=r.useCallback(j=>Date.now()<W.current?ds:Jl(j),[]),P=be({queryKey:I,queryFn:()=>Zs(T,L),enabled:o==="catalog"&&!K,staleTime:1e4,refetchInterval:j=>z(j.state.data)}),H=Tc(P.error);r.useEffect(()=>{!H||!C||l===C||(d(C),Ec(e))},[H,C,l,e]);const U=be({queryKey:Ft.list(h??""),queryFn:()=>Js(h??""),enabled:o==="session"&&!!h,staleTime:1e4,refetchInterval:j=>z(j.state.data?Kt(j.state.data,h??""):void 0)}),R=r.useMemo(()=>{if(o==="catalog")return P.data;if(o==="session"&&U.data&&h)return Kt(U.data,h)},[o,P.data,U.data,h]),Y=r.useCallback(()=>$c({queryClient:u,route:o,catalogKey:I,sessionId:h}),[o,I,u,h]);r.useEffect(()=>{if(!X)return;const j=D.current;if(!j)return;const B=R?.servers.find(ae=>ae.name===j.name);!B||!(j.expect==="connected"?B.status==="connected":B.status_basis==="live"&&B.status!=="connected")||(W.current=0,D.current=null,J(0))},[R,X]);const y=r.useRef({}),[x,v]=r.useState(0),Q=r.useMemo(()=>(y.current=Vl(Yl(y.current,R,gs()),R),y.current),[R,x]),$=r.useRef("");r.useEffect(()=>{const j=ql(Q,R);if(!Object.keys(j).length)return;const B=JSON.stringify(j);B!==$.current&&($.current=B,Rc(j))},[Q,R]);const ne=r.useCallback(j=>{const B=De(y.current,j);B.needsKey||(y.current={...y.current,[j]:{...B,needsKey:!0}},v(q=>q+1))},[]),V=r.useCallback(j=>{if(j.action!=="disconnect"&&j.action!=="connect"&&j.action!=="reload")return;const B=De(y.current,j.name),q=Date.now()+kn,ae=j.action==="disconnect"?{...B,connectedAt:null,disconnectedAt:Date.now(),holdUntil:q}:{...B,disconnectedAt:null,holdUntil:q};y.current={...y.current,[j.name]:ae},te(j.name,Fc(j)),v(N=>N+1)},[te]),se=r.useCallback(async j=>{if(o==="catalog"){const B=Dc(j);if(!B)return null;try{const q=await Qs(T,B);return u.setQueryData(I,q),V(j),q.operation?.id??null}catch(q){throw q instanceof Yt&&q.status===409&&u.invalidateQueries({queryKey:I}),q}}if(o==="session"&&h){const B=await de({op:"mcp.control",sessionId:h,control:zc(j)});V(j);const q=Ft.list(h),ae=B?.data;return ae&&"servers"in ae&&Array.isArray(ae.servers)?(u.setQueryData(q,ae),null):(u.invalidateQueries({queryKey:q}),ae&&"id"in ae&&typeof ae.id=="string"?ae.id:null)}return null},[o,T,I,u,h,V]),ve=r.useCallback(async j=>{if(o==="catalog"&&L&&(j.action==="connect"||j.action==="disconnect"||j.action==="reload")){try{await de({op:"mcp.control",sessionId:L,control:{action:j.action,name:j.name,...j.action==="disconnect"?{confirmed:!0}:{}}})}catch(B){throw u.invalidateQueries({queryKey:I}),B}return V(j),await u.invalidateQueries({queryKey:I}),null}return se(j)},[o,L,u,I,se,V]),pe=r.useCallback(async(j,B,q,ae)=>{if(o==="catalog"){const N=await Ws(T,j,B,q,ae);if(N.catalog&&u.setQueryData(I,N.catalog),N.code!=="saved")return{saved:!1,message:Cn(N.code,N.failed_ids,B)};try{await se({action:"test",name:j})}catch{}return{saved:!0,message:null}}if(o==="session"&&h){const N=await de({op:"mcp.credentials.store",sessionId:h,name:j,values:B,confirmedReplace:q});if(N.data?.code!=="saved")return{saved:!1,message:Cn(N.data?.code,N.data?.failed_ids??[],B)};try{await se({action:"connect",name:j})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[o,T,I,u,se,h]),me=o==="catalog"?P:U,fe=r.useCallback(()=>{me.refetch()},[me]);return{enabled:o!==null,route:o,sessionId:o==="catalog"?L:h,borrowed:b,noConversation:o==="session"&&!h&&!p,document:R,isLoading:s.isLoading||o==="catalog"&&(K||P.isLoading)||o==="session"&&(h?U.isLoading:p),isError:me.isError,folderUnavailable:Gl(l,C),refetch:fe,readDocument:Y,control:ve,storeKeys:pe,memories:Q,markNeedsKey:ne}}function $c(e){if(e.route==="catalog")return e.queryClient.getQueryData(e.catalogKey);if(e.route==="session"&&e.sessionId){const s=e.queryClient.getQueryData(Ft.list(e.sessionId));return s?Kt(s,e.sessionId):void 0}}const Kc=(e,s)=>{const a=e?.trim();if(!a)return null;const i=ta(a,s);return i.kind==="auth"?{kind:"matched",name:i.name,unresolved:null}:{kind:"miss",asked:a}},Uc=6,At="ui.settings.integrations.mcp_management_section.copy_section_title",Bc="ui.settings.integrations.mcp_management_section.copy_section_description",Hc={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},Vc=({sessionId:e,sectionRef:s,highlightServer:a})=>{ee();const i=Pc({sessionId:e}),{document:o,control:l,readDocument:d}=i,u=Xs(),c=o?.servers??[],m=o?.operations??[],p=o?.project_scope_available??!1,[f,b]=r.useState(!1),[h,_]=r.useState(""),[w,A]=r.useState(null),[K,C]=r.useState({}),[O,T]=r.useState(null),[L,I]=r.useState(null),[W,X]=r.useState({kind:"ready"}),[J,D]=r.useState(null),[te,z]=r.useState(null),[P,H]=r.useState(!1),U=r.useRef({}),R=r.useRef({}),Y=r.useRef({}),y=r.useRef(0),x=r.useRef(null),v=r.useRef(null),Q=r.useRef(null),[$,ne]=r.useState(null),[V,se]=r.useState(null),[ve,pe]=r.useState(null),me=r.useCallback(()=>{const g=Q.current;Q.current=null,I(null),D(null),window.setTimeout(()=>{g?.isConnected&&g.focus()},0)},[]),fe=r.useCallback(g=>{const k=window.document.activeElement;Q.current=k instanceof HTMLElement?k:null,I(g)},[]),j=r.useCallback((g,k)=>{se({name:g,waitForSignIn:k==="signed-in",until:Date.now()+Ve,reanchors:0}),me()},[me]),B=r.useMemo(()=>Kc(a,c.map(g=>g.name)),[a,c]),q=B?.kind==="matched"?B.name:null,ae=r.useRef(null),N=r.useRef(null),M=h.trim().toLowerCase(),F=r.useMemo(()=>M?c.filter(g=>g.name.toLowerCase().includes(M)):c,[c,M]),re=Hl(F,m,i.memories),ie=L?.kind==="sign_in"?c.find(g=>g.name===L.name)??null:null;r.useEffect(()=>{!q||N.current===q||!h||_("")},[q,h]),r.useEffect(()=>{!q||N.current===q||F.some(g=>g.name===q)&&(N.current=q,ae.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[q,F]),r.useEffect(()=>{if(!J)return;const g=m.find(k=>k.id===J)??null;X({kind:"running",operation:g})},[m,J]);const le=m.some(g=>g.status==="running"),ye=g=>{const k=window.document.activeElement;k&&k!==window.document.body&&k.isConnected||se({name:g,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})},ge=async(g,k,E)=>{A(g),C(({[g]:Ee,...Te})=>Te);let Z=null,ke=!1;try{Z=await E()}catch(Ee){ke=!0,C(Te=>({...Te,[g]:at(Hc[k]??"status",Ee,le)}))}finally{A(null),k!=="sign_out"&&(k!=="remove"||ke)&&ye(g)}return{operationId:Z,failed:ke}},Ie=g=>c.find(k=>k.name===g),xe=g=>{g.source.path&&na(g.source.path)},je=async(g,k)=>{X({kind:"starting"}),D(null);try{const E=await l({action:k,name:g});E?D(E):X({kind:"running",operation:null})}catch(E){E instanceof Yt&&E.code==="oauth_unsupported"&&i.markNeedsKey(g),X({kind:"refused",message:at("grant",E,le)})}},Ne=(g,k)=>{switch(k.kind){case"sign_in":case"reauth":{const E=m.find(Z=>Z.name===g.name&&Z.status==="running");E&&We(E)?(X({kind:"running",operation:E}),D(E.id)):(X({kind:"ready"}),D(null)),fe({kind:"sign_in",name:g.name,action:k.kind==="reauth"?"reauth":"login"});return}case"set_key":z(null),fe({kind:"key",name:g.name,keyNames:g.auth.secret_refs.map(E=>E.id)});return;case"fix":xe(g);return;case"sign_out":T({name:g.name,kind:"sign_out"});return;default:{const E=k.kind;ge(g.name,E,()=>l({action:E,name:g.name}))}}},Re=(g,k)=>{switch(k.kind){case"remove":case"sign_out":T({name:g.name,kind:k.kind});return;case"sign_in":case"reauth":case"set_key":Ne(g,{kind:k.kind,label:k.label});return;case"open_config":xe(g);return;case"copy_setup":navigator.clipboard.writeText(g.setup_prompt??"").then(()=>Ot(n("ui.settings.integrations.mcp_management_section.setup_steps_copied_paste_them_into_a_chat"))).catch(()=>{});return;case"cancel":{const E=m.find(Z=>Z.name===g.name&&Z.status==="running");E&&ge(g.name,"cancel",()=>l({action:"cancel",operationId:E.id}));return}case"test":case"connect":case"disconnect":case"reload":{const E=k.kind;ge(g.name,E,()=>l({action:E,name:g.name}));return}default:return}},yt=(g,k)=>{if(T(null),k==="remove"){const E=g.source.owned_scope;if(!E)return;const Z=F.findIndex(ke=>ke.name===g.name);ge(g.name,"remove",()=>l({action:"remove",name:g.name,scope:E})).then(({operationId:ke,failed:Ee})=>{Ee||ke!==null||(Ot(n("ui.settings.integrations.mcp_management_section.removed_name",{name:String(g.name)})),Z>=0&&pe({index:Z}))});return}ge(g.name,"sign_out",()=>l({action:"logout",name:g.name})).then(()=>{se({name:g.name,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})})},kt=async g=>{try{return await l({action:"add",name:g.name,scope:g.scope,...g.mode==="command"?{command:g.command,args:g.args}:{url:g.url}}),b(!1),ne(g.name),null}catch(k){return at("add",k,!1)}},Ze=t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-heading text-ink",children:n(At)}),t.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n(Bc)})]}),i.enabled&&c.length>0&&!f?t.jsxs(G,{ref:x,variant:"secondary",size:"sm",onClick:()=>b(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(ln,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]}):null]});if(!i.enabled&&!i.isLoading)return t.jsx(ce,{title:n(At),titleComponent:Ze,sectionRef:s,children:t.jsx(oe,{variant:"warning",children:n("ui.settings.integrations.mcp_management_section.integrations_need_a_newer_local_operator_backend_update_it_and_re")})});const bt=t.jsx(lc,{existingNames:c.map(g=>g.name),projectScopeAvailable:p,projectLabel:o?.cwd?qc(o.cwd):null,onSubmit:kt,onCancel:()=>{b(!1),window.setTimeout(()=>x.current?.focus(),0)}}),Be=L?Ie(L.name):void 0,Je=Object.entries(K).filter(([g])=>!c.some(k=>k.name===g)),hs=g=>C(({[g]:k,...E})=>E);r.useEffect(()=>{if(!$)return;const g=U.current[$];if(!g){c.some(k=>k.name===$)&&(R.current[$]?.focus(),ne(null));return}g.focus(),ne(null)},[$,c]),r.useEffect(()=>{if(!ve)return;const k=F[Math.min(ve.index,F.length-1)]??F.at(-1);if(k){const E=U.current[k.name]??R.current[k.name];if(!E)return;E.focus()}else x.current?.focus();pe(null)},[ve,F]);const vt=r.useCallback((g,k)=>{const E=d()??o,Z=E?.servers.find(fs=>fs.name===g.name),ke=E?.operations??[],Ee=Z?Z.status==="connecting"||Ue(Z.name,ke)!==null:!1;Ee&&Z&&(y.current=k);const Te=Z?Xt(Z,ke,i.memories):null;if(Z&&g.waitForSignIn&&(Te?.kind==="sign_in"||Te?.kind==="reauth"))return"kept";const ze=mc({hold:g,now:k,windowMs:Ve,rowMoving:Ee,lastMovingAt:y.current,candidate:Z?_c({primary:Te?U.current[Z.name]:null,overflow:R.current[Z.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!ze.hold)return se(null),"finished";if(!ze.land)return"kept";se({name:g.name,waitForSignIn:!1,until:ze.hold.until,landedOn:ze.land,reanchors:ze.hold.reanchors});const nn=ze.land;return window.setTimeout(()=>{nn.isConnected&&nn.focus()},0),"landed"},[d,o,i.memories]);return r.useEffect(()=>{if(!V)return;vt(V,Date.now());let g=0,k=!1;const E=()=>{if(k)return;const Z=pc({verdict:vt(V,Date.now()),watchMs:vn});Z!==null&&(g=window.setTimeout(E,Z))};return g=window.setTimeout(E,vn),()=>{k=!0,window.clearTimeout(g)}},[V,vt]),r.useEffect(()=>{if(!V)return;const g=k=>{gc({target:k.target,row:Y.current[V.name]})&&se(null)};return window.document.addEventListener("pointerdown",g,!0),()=>{window.document.removeEventListener("pointerdown",g,!0)}},[V]),t.jsxs(ce,{title:n(At),titleComponent:Ze,sectionRef:s,children:[t.jsxs("div",{className:"flex flex-col gap-4",children:[i.route==="session"&&i.borrowed?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.borrowed_chat_notice",{chat:i.borrowed.title?.trim()||i.borrowed.session_id.slice(0,6)})}):null,i.noConversation?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.integrations_can_be_managed_here_once_a_chat_has_started")}),t.jsx(G,{variant:"primary",size:"sm",onClick:()=>u("/chat"),children:n("ui.settings.integrations.mcp_management_section.start_a_chat")}),t.jsx("p",{className:"text-ink-dim text-meta",children:n("ui.settings.integrations.mcp_management_section.updating_local_operator_removes_this_step")})]}):null,i.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(he,{size:"lg",label:n("ui.settings.integrations.mcp_management_section.loading_integrations")})}):null,i.folderUnavailable?t.jsx(oe,{variant:"warning",children:t.jsx("span",{children:n("ui.settings.integrations.mcp_management_section.this_chat_s_folder_no_longer_exists_so_only_global_integrations_a")})}):null,i.isError?t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:n("ui.settings.integrations.mcp_management_section.integrations_couldn_t_be_loaded")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:i.refetch,children:n("ui.settings.integrations.mcp_management_section.retry")})]})}):null,Je.map(([g,k])=>t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:k}),t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>hs(g),children:n("ui.settings.integrations.mcp_management_section.dismiss")})]})},g)),f&&c.length>0?bt:null,c.length>=Uc?t.jsxs("div",{className:"relative",children:[t.jsx(On,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),t.jsx(Ae,{ref:v,value:h,onChange:g=>_(g.target.value),onKeyDown:g=>{g.key!=="Escape"||!h||(g.preventDefault(),_(""))},placeholder:n("ui.settings.integrations.mcp_management_section.search_integrations_placeholder",{integrations:Nl(c.length)}),"aria-label":n("ui.settings.integrations.mcp_management_section.search_integrations"),className:"pl-9"})]}):null,B?.kind==="miss"&&c.length>0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_match_for_name",{asked:String(B.asked)})}):null,B?.kind==="matched"&&B.unresolved?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.showing_fallback_for_unknown",{shown:String(B.name),asked:String(B.unresolved)})}):null,o&&c.length===0&&!i.isLoading?f?bt:t.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[t.jsx(zn,{"aria-hidden":"true",className:"size-5 text-ink-muted"}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.integrations.mcp_management_section.no_integrations_yet")}),t.jsx("p",{className:"max-w-xl text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.integrations_let_agents_read_and_act_in_your_other_tools_like_not")})]}),t.jsxs(G,{variant:"primary",size:"md",onClick:()=>b(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(ln,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]})]}):null,c.length>0&&F.length===0?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_integrations_match_this_search")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>{_(""),window.setTimeout(()=>{(v.current??x.current)?.focus()},0)},children:n("ui.settings.integrations.mcp_management_section.clear_search")})]}):null,re.map(g=>t.jsxs("section",{"aria-labelledby":`integrations-group-${g.id}`,className:"flex flex-col gap-1.5",children:[t.jsxs("h3",{id:`integrations-group-${g.id}`,className:"px-1 text-ink-dim text-meta",children:[g.title," · ",g.rows.length]}),t.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:g.rows.map(k=>t.jsx(bc,{row:k,operations:m,memories:i.memories,projectScopeAvailable:p,highlighted:k.name===q,rowRef:E=>{Y.current[k.name]=E,k.name===q&&(ae.current=E)},primaryRef:E=>{U.current[k.name]=E},overflowRef:E=>{R.current[k.name]=E},pending:w===k.name,failure:K[k.name]??null,confirm:O?.name===k.name?{kind:O.kind}:null,onPrimary:E=>Ne(k,E),onOverflow:E=>Re(k,E),onConfirm:()=>O&&yt(k,O.kind),onCancelConfirm:()=>{T(null),window.setTimeout(()=>{R.current[k.name]?.focus()},0)}},k.id))})]},g.id))]}),L?.kind==="sign_in"?t.jsx(Sc,{name:L.name,action:L.action,keyRoute:ie?ft(ie):!1,phase:W,onStart:()=>void je(L.name,L.action),onCancel:g=>void l({action:"cancel",operationId:g}).catch(()=>{}),onOpenLink:g=>void ea(g),onClose:g=>j(L.name,g)}):null,L?.kind==="key"?t.jsx(xc,{name:L.name,keyNames:L.keyNames.length?L.keyNames:Be?.auth.secret_refs.map(g=>g.id)??[],keyless:L.keyNames.length===0,savedKeys:Be?.auth.secret_refs.filter(g=>g.state==="encrypted").map(g=>g.id),saving:P,failure:te,onClose:me,onSave:(g,k,E)=>{H(!0),z(null),i.storeKeys(L.name,g,k,E).then(Z=>{if(!Z.saved){z(Z.message);return}I(null),se({name:L.name,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})}).catch(Z=>z(at("key",Z,!1))).finally(()=>H(!1))}}):null]})},Ve=4e3,Gc=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,qc=e=>e.replace(Gc,"~"),Yc=({verification:e})=>{ee();const{prices:s}=aa(),a=e.grant_amount??s?.default_new_credits,{sentence:i,action:o}=ia(e.signup_grant,oa(a)),l=ra(e.claim_url,la);return t.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[t.jsx(pt,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink",children:i}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>ca(l),children:o})]})]})},Qc=({onAfterCredentialUpdate:e})=>{ee();const{isAuthenticated:s,user:a,isLoading:i,accountRead:o,signOut:l}=sa(),d=Pn(f=>f.isSigningOut),u=r.useCallback(async()=>{try{await l()}catch(f){console.error("Error signing out:",f)}},[l]),c=(()=>{if(!s||!a?.radientUser)return null;const{account:f,identity:b,verification:h}=a.radientUser,_=h!=null&&!h.email_verified&&h.signup_grant!=="claimed";return t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.account.radient_account_section.status"),value:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[n("ui.settings.account.radient_account_section.connected"),t.jsx(qe,{variant:"success",className:"capitalize",children:f.status})]})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.name"),value:f.name||n("ui.settings.account.radient_account_section.not_provided")}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.email"),value:f.email}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.account_id"),value:t.jsx("span",{className:"text-mono-sm",children:f.id})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.tenant_id"),value:t.jsx("span",{className:"text-mono-sm",children:f.tenant_id})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.provider"),value:t.jsx("span",{className:"capitalize",children:b.provider})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.created"),value:$n(f.created_at)})]}),_&&h?t.jsx(Yc,{verification:h}):null,t.jsx("div",{className:"mt-8",children:t.jsx(Pa,{offerSignIn:!0})}),t.jsxs("div",{className:"mt-8",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.radient_account_section.need_to_sign_out_or_switch_accounts")}),t.jsxs(G,{variant:"danger",className:"mt-3",onClick:u,children:[t.jsx($a,{}),n("ui.settings.account.radient_account_section.sign_out_from_radient")]})]})]})})(),m=o==="refused"?n("ui.settings.account.radient_account_section.radient_refused_the_sign_in_this_app_is_holding_so_your_account_d"):Kn(o)?n("ui.settings.account.radient_account_section.your_radient_account_could_not_be_read_so_this_app_cannot_show_yo"):n("ui.settings.account.radient_account_section.you_are_not_currently_signed_in_to_radient"),p=s&&a?null:t.jsxs("div",{children:[t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[m," ",n("ui.settings.account.radient_account_section.sign_in_to_access_your_account_details_or_sign_up_to_get_free_cre")]}),t.jsx("div",{className:"mt-6",children:t.jsx(ki,{titleText:"",onAfterCredentialUpdate:e,descriptionText:"",onSignInSuccess:()=>{}})})]});return i||d?t.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[t.jsx(he,{size:"lg",label:n("ui.settings.account.radient_account_section.loading_account")}),!d&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.account.radient_account_section.loading_your_radient_account_details")})]}):s&&a?.radientUser?c:t.jsx("div",{className:"flex flex-col gap-4",children:p})};function Wc({metric:e,data:s}){return ee(),t.jsx(da,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:e==="credits"?"credits":"tokens",srSummary:e==="credits"?n("ui.settings.account.settings_usage_chart.credits_summary",{days:s.length}):n("ui.settings.account.settings_usage_chart.tokens_summary",{days:s.length}),xTickFormatter:a=>a,yTickFormatter:a=>e==="credits"?`$${a.toFixed(2)}`:ua(a),children:t.jsx(Pr,{data:s,children:t.jsx(Tn,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:e==="credits"?n("ui.settings.account.settings_usage_chart.credits_consumed"):n("ui.settings.account.settings_usage_chart.tokens_used")})})})}const Zc={all:["desktop","tts-path-resolution"]};function Jc(e){return be({queryKey:Zc.all,queryFn:()=>de({op:"tts.paths"}),enabled:e,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:ma})}const Xc=["speech.voice.gender","speech.voice.tone","speech.voice.expressiveness","speech.voice.pace","speech.voice.language","speech.voice.accent","speech.voice.instructions"];function Mn(e){const s=new Map(e.map(o=>[o.key,o])),a=[],i=[];for(const o of Xc){const l=s.get(o);l?a.push(l):i.push(o)}return{rows:a,missing:i}}const ed=["provider_tts_radient","provider_tts_elevenlabs","provider_tts_openai","none"];function An(e){return typeof e=="string"&&ed.includes(e)}function td(e){if(e===null||typeof e!="object")return null;const s=e;if(!An(s.path)||typeof s.reason!="string"||typeof s.servable!="boolean"||!Array.isArray(s.rungs))return null;const a=[];for(const i of s.rungs){if(i===null||typeof i!="object")return null;const o=i;if(!An(o.path)||typeof o.available!="boolean"||typeof o.reason!="string")return null;a.push({path:o.path,available:o.available,reason:o.reason})}return{path:s.path,reason:s.reason,servable:s.servable,rungs:a}}const nd={get provider_tts_radient(){return n("ui.settings.speech.speech_settings_model.radient_pass")},provider_tts_elevenlabs:"ElevenLabs",provider_tts_openai:"OpenAI",get none(){return n("ui.settings.speech.speech_settings_model.no_provider")}};function _s(e){return nd[e]}function sd(e){return{servable:e.servable,serving:e.path==="none"?null:e.path,reason:e.reason,rungs:e.rungs.map(s=>({path:s.path,name:_s(s.path),available:s.available,reason:s.reason}))}}const ad="ui.settings.speech.speech_section.copy_backend_older_sentence",ps="ui.settings.speech.speech_section.copy_unavailable_sentence",id=({resetErrorBoundary:e})=>(ee(),t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex flex-col items-start gap-3",children:[t.jsx("span",{children:n(ps)}),t.jsxs(G,{variant:"secondary",onClick:e,children:[t.jsx(xi,{"aria-hidden":"true"}),n("ui.settings.speech.speech_section.try_again")]})]})}));function od(e){return e==="enabled"?"ready":e==="below-version"?"older":"pairing"}const rd=({sectionRef:e})=>{ee();const s=Gt(),a=Un(),i=ga(s.data,"tts"),o=od(i),l=be({queryKey:Et.all,queryFn:()=>de({op:"settings.list"}),enabled:o==="ready",staleTime:1e4}),d=Jc(o==="ready"),{hasRadientApiKey:u,hasRadientSession:c,speechBlock:m}=_a(),p=`${c}:${u}`,f=r.useRef(p),b=d.refetch;r.useEffect(()=>{f.current!==p&&(f.current=p,b())},[p,b]);const h=l.data,_=r.useMemo(()=>Mn(h?.settings??[]),[h]),[w,A]=r.useState({}),[K,C]=r.useState({}),[O,T]=r.useState({});r.useEffect(()=>{h&&A(y=>{let x=!1;const v={...y};for(const Q of Mn(h.settings).rows){const $=y[Q.key];if($&&$.value!==He(Q).value)continue;const ne=He(Q);$&&$.value===ne.value&&$.cascadeBase===ne.cascadeBase||(v[Q.key]=ne,x=!0)}return x?v:y})},[h]);const L=(y,x)=>C(v=>({...v,[y]:x})),I=(y,x)=>T(v=>({...v,[y]:x})),W=async y=>{const x=w[y.key];if(!x)return;const v=fa(y,x);if(!v.ok){I(y.key,v.error);return}L(y.key,!0),I(y.key,null);try{await de(v.request),L(y.key,!1);const $=(await l.refetch()).data?.settings.find(ne=>ne.key===y.key);$&&A(ne=>{const V=ne[y.key];return V&&V.value===x.value&&V.cascadeBase===x.cascadeBase?{...ne,[y.key]:He($)}:ne})}catch(Q){L(y.key,!1),I(y.key,Q instanceof Error?Q.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_saved"))}},X=async y=>{L(y.key,!0),I(y.key,null);try{await de({op:"settings.reset",key:y.key}),A(x=>({...x,[y.key]:He({...y,value:y.default,is_default:!0})})),L(y.key,!1),await l.refetch()}catch(x){L(y.key,!1),I(y.key,x instanceof Error?x.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_reset"))}},J=r.useMemo(()=>td(d.data),[d.data]),D=J?sd(J):null,te=d.isSuccess&&J===null,z=(s.data?null:s.error)??null,P=l.error,H=n("ui.settings.speech.speech_section.speech_voicing"),U=n("ui.settings.speech.speech_section.how_the_assistant_sounds_when_it_speaks_aloud");if(o==="pairing"){const{sentence:y}=Dt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),z);return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:y})})}if(o==="older")return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:n(ad)})});if(P||!h){const{sentence:y,remedy:x}=Dt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),P);return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:y}),x&&t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{l.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})})})}const R=D?!D.servable:m==="offline",Y=D?D.rungs.find(y=>y.path===D.serving)??null:null;return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs("section",{className:"flex flex-col gap-3",children:[d.isPending&&t.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[t.jsx(he,{}),on("checking")]}),(d.isError||te)&&!D&&m!=="offline"&&t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{children:[n(ps)," ",d.error instanceof Error?d.error.message:""]}),t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})}),t.jsx(fi,{fallbackRender:id,resetKeys:[d.dataUpdatedAt],children:D&&t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.speech.speech_section.speaks_through"),value:D.serving?_s(D.serving):n("ui.settings.speech.speech_section.nothing_yet")}),t.jsx(_e,{label:n("ui.settings.speech.speech_section.availability"),value:D.servable?n("ui.settings.speech.speech_section.ready"):n("ui.settings.speech.speech_section.no_provider")})]}),D.reason&&D.reason!==Y?.reason&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:D.reason}),t.jsx("ul",{className:"flex flex-col gap-1",children:D.rungs.map(y=>t.jsxs("li",{className:"flex flex-col gap-0.5 text-body-sm",children:[t.jsxs("span",{className:y.path===D.serving?"text-ink":"text-ink-muted",children:[y.name,t.jsxs("span",{className:y.path===D.serving?"text-ink-muted":"text-ink-dim",children:[" ",y.available?n("ui.settings.speech.speech_section.available"):n("ui.settings.speech.speech_section.not_available")]})]}),t.jsx("span",{className:"text-meta text-ink-dim",children:y.reason})]},y.path))})]})})]}),R&&t.jsx(oe,{variant:"warning",children:on(m)}),t.jsx("div",{className:"flex flex-col gap-1",children:_.rows.map(y=>t.jsx(pa,{setting:y,draft:w[y.key]??He(y),tier:ha(y),saving:!!K[y.key],error:O[y.key]??null,onDraftChange:x=>A(v=>({...v,[y.key]:x})),onSave:()=>{W(y)},onReset:()=>{X(y)}},y.key))}),_.missing.length>0&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.speech.speech_section.missing_voice_rows",{count:_.missing.length,rows:_.missing.join(", ")})})]})})},ld=()=>{ee();const{data:e,isLoading:s,error:a,refetch:i}=Fr(),o=Dr(),[l,d]=r.useState(""),[u,c]=r.useState(!1);r.useEffect(()=>{d(e?.content??""),c(!1)},[e]);const m=_=>{const w=_.target.value;d(w),c(w!==(e?.content??""))},p=async()=>{if(!(!u||o.isPending))try{const _={content:l};await o.mutateAsync(_),await i(),c(!1)}catch(_){console.error("Error updating system prompt:",_)}},f=()=>{d(e?.content??""),c(!1)},b=o.isPending,h=()=>t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(we,{htmlFor:"app-system-prompt",children:n("ui.settings.model.system_prompt.instructions")}),t.jsx(Gn,{id:"app-system-prompt",name:"systemPrompt",value:l,onChange:m,placeholder:n("ui.settings.model.system_prompt.enter_instructions_for_how_all_agents_should_behave_and_respond_t"),className:"min-h-50"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs(G,{variant:"primary",onClick:p,disabled:!u||b,children:[b?t.jsx(he,{size:"sm"}):t.jsx(Ka,{}),b?n("ui.settings.model.system_prompt.saving"):n("ui.settings.model.system_prompt.save_changes")]}),t.jsx(G,{onClick:f,disabled:!u||b,children:n("ui.settings.model.system_prompt.cancel")})]}),e?.last_modified&&t.jsxs("p",{className:"text-ink-dim text-meta",children:[n("ui.settings.model.system_prompt.last_modified")," ",t.jsx("span",{className:"font-mono text-mono-sm",children:qt(e.last_modified)})]})]});return t.jsx(ce,{title:n("ui.settings.model.system_prompt.system_prompt"),icon:bi,description:n("ui.settings.model.system_prompt.every_local_operator_agent_receives_this_prompt_in_addition_to_it"),children:s?t.jsx("div",{className:"flex min-h-50 items-center justify-center",children:t.jsx(he,{size:"lg",label:n("ui.settings.model.system_prompt.loading_system_prompt")})}):a?t.jsx(oe,{variant:"danger",children:n("ui.settings.model.system_prompt.load_failed",{reason:a instanceof Error?a.message:n("ui.settings.model.system_prompt.unknown_error")})}):h()})},cd=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],dd=e=>cd.includes(e),ud=e=>{const s=[];let a=0;for(const i of e){const o=Math.max(0,Math.floor(i.count)),l=Math.max(1,Math.floor(i.columns));for(let d=0;d<o;d+=l)s.push({start:a+d,count:Math.min(l,o-d)});a+=o}return s},md=({index:e,key:s,groups:a})=>{const i=ud(a),o=i.reduce((l,d)=>l+d.count,0);if(!Number.isInteger(e)||e<0||e>=o)return e;switch(s){case"Home":return 0;case"End":return o-1;case"ArrowLeft":return Math.max(0,e-1);case"ArrowRight":return Math.min(o-1,e+1);case"ArrowUp":case"ArrowDown":{const l=i.findIndex(c=>e>=c.start&&e<c.start+c.count),d=i[l+(s==="ArrowDown"?1:-1)];if(!d)return e;const u=e-i[l].start;return d.start+Math.min(u,d.count-1)}default:return e}},gd={localOperatorDark:Go,localOperatorLight:mr,dracula:ar,dune:ko,sage:zo,monokai:Ha,tokyoNight:Wo,iceberg:or,radient:Eo,neon:xa,obsidian:qn,synth:Ei,catppuccinMocha:ao,catppuccinLatte:Uo,tokyoNightStorm:Wi,gruvbox:$i,nord:Lr,oneDark:Ii,solarizedDark:dr,rosePine:wo,rosePineMoon:Ho,rosePineDawn:no,alucard:So,gruvboxLight:mo,tokyoNightDay:Yo,oneLight:$o,catppuccinFrappe:co,catppuccinMacchiato:Lo,palenight:Ba,everforest:Sr,everforestLight:wr,kanagawaWave:Ir,kanagawaLotus:vo,ayuDark:_o,ayuMirage:ho,ayuLight:er,nightfox:Ji,duskfox:hr,synthwave:Jo,matrix:Li,tron:Yi,cyberpunk:Ua,vaporwave:vr,outrun:zi,neonNoir:Mr,arcade:Fo,forest:kr,ocean:xo,desert:xr,autumn:Er,lavender:lr,arctic:eo,rosewood:Io,solarizedLight:_r,githubLight:Mo,paper:vi,linen:nr,highContrastLight:Mi,mintLight:Fi},In="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",_d=({id:e})=>t.jsxs("div",{"data-theme":e,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[t.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[t.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:t.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),t.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),t.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[t.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[t.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),t.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),t.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),pd=({id:e,name:s,description:a,isSelected:i,isTabStop:o,onSelect:l,onFocusTile:d})=>{const u=gd[e];return t.jsx(Ke,{side:"bottom",align:"start",content:a,children:t.jsxs("button",{type:"button","data-theme-tile":e,"aria-pressed":i,tabIndex:o?0:-1,onFocus:d,onClick:l,className:ue("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",i?In:"hover:bg-surface"),children:[t.jsxs("span",{className:ue("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",i?"border-accent":"border-hairline"),children:[t.jsx(_d,{id:e}),i&&t.jsx("span",{className:ue("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",In),children:t.jsx(Vn,{size:12,className:"text-accent","aria-hidden":"true"})})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(u,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},hd=e=>[...e.querySelectorAll("[data-theme-grid]")].map(s=>{const a=[...s.querySelectorAll("[data-theme-tile]")],i=a[0]?.getBoundingClientRect().top??0;return{count:a.length,columns:Math.max(1,a.filter(o=>Math.abs(o.getBoundingClientRect().top-i)<1).length)}}),fd=()=>{ee();const{themeName:e,setTheme:s}=Me(),a=Object.values(xs),i=[{label:n("ui.settings.appearance.theme_selector.dark"),items:a.filter(c=>c.theme.palette.mode==="dark")},{label:n("ui.settings.appearance.theme_selector.light"),items:a.filter(c=>c.theme.palette.mode==="light")}].filter(c=>c.items.length>0),[o,l]=r.useState(null),d=r.useMemo(()=>{const c=i.flatMap(m=>m.items.map(p=>p.id));return o&&c.includes(o)?o:c.includes(e)?e:c[0]},[i,o,e]),u=c=>{if(!dd(c.key))return;const m=[...c.currentTarget.querySelectorAll("[data-theme-tile]")],p=m.indexOf(c.target);if(p<0)return;c.preventDefault();const f=md({index:p,key:c.key,groups:hd(c.currentTarget)});f!==p&&m[f]?.focus()};return t.jsx(yi,{children:t.jsx("div",{onKeyDown:u,className:"flex flex-col gap-6",children:i.map(c=>t.jsxs("div",{children:[t.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:c.label}),t.jsx("div",{"data-theme-grid":c.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:c.items.map(({id:m,name:p,description:f})=>t.jsx(pd,{id:m,name:p,description:f,isSelected:m===e,isTabStop:m===d,onSelect:()=>s(m),onFocusTile:()=>l(m)},m))})]},c.label))})})},xd=({value:e,onChange:s})=>{ee();const a=r.useId();return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{id:a,className:"flex min-h-6 items-center text-body text-ink",children:n("ui.settings.appearance.transcript_display_mode_setting.transcript_display")}),t.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.transcript_display_mode_setting.by_turn_condenses_each_turn_to_its_answer_by_response_keeps_every")})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsx(gt,{value:e,onValueChange:i=>s(Bn(i)),children:t.jsx(_t,{"aria-labelledby":a,children:Ta.map(i=>t.jsx($e,{value:i.value,children:i.value==="by-turn"?n("ui.settings.appearance.transcript_display_mode_setting.by_turn"):n("ui.settings.appearance.transcript_display_mode_setting.by_response")},i.value))})})})]})},yd=()=>{ee();const{data:e,isLoading:s,error:a}=Kr({enabled:!0});return t.jsxs("div",{children:[t.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[t.jsx(ro,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_pass")]}),s&&t.jsx(Oe,{className:"h-6 w-36"}),a&&t.jsx(oe,{variant:"warning",children:n("ui.settings.account.settings_page.credit_balance_load_failed",{reason:a.message})}),e&&!s&&!a&&t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:[n("ui.settings.account.settings_page.available_credits")," ",t.jsx("span",{className:"font-medium text-ink",children:e.balance.toFixed(2)})]}),t.jsx(G,{variant:"secondary",size:"sm",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(Gi,{}),n("ui.settings.account.settings_page.add_credits")]})})]})]})},kd=[{id:"credits",get label(){return n("ui.settings.account.settings_page.credits")}},{id:"tokens",get label(){return n("ui.settings.account.settings_page.tokens")}}],bd=()=>{ee();const[e,s]=r.useState("credits"),a=r.useMemo(()=>{const u=new Date,c=zr(u);return{start_date:gn(c),end_date:gn(u),rollup:"daily"}},[]),{data:i,isLoading:o,error:l}=Br(a,{enabled:!0}),d=r.useMemo(()=>i?.data_points?[...i.data_points].sort((c,m)=>jt(c.timestamp).getTime()-jt(m.timestamp).getTime()).map(c=>({bucket:Ca(Ni(jt(c.timestamp),"yyyy-MM-dd")),value:e==="credits"?Number.parseFloat(c.total_cost.toFixed(2)):c.total_tokens})):[],[i,e]);return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(Ui,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.usage_last_30_days")]}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.settings.account.settings_page.usage_metric")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:kd.map(({id:u,label:c})=>t.jsx(G,{variant:"ghost",size:"sm","aria-pressed":e===u,onClick:()=>s(u),className:ue(e===u&&"bg-surface text-ink hover:bg-surface"),children:c},u))})]})]}),o&&t.jsx(Oe,{className:"h-62 w-full"}),l&&t.jsx(oe,{variant:"warning",children:n("ui.settings.account.settings_page.usage_load_failed",{reason:l.message})}),!o&&!l&&i&&d.length>0&&t.jsx(Wc,{metric:e,data:d}),!o&&!l&&(!i||d.length===0)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.settings_page.no_usage_recorded_in_the_last_30_days")})]})},vd=()=>(ee(),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(ti,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_account")]}),t.jsx(G,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:[n("ui.settings.account.settings_page.go_to_radient_console"),t.jsx(Ma,{})]})})]})),Fd=()=>{ee();const e=ya("surface"),s=ka(),a=Me(N=>N.showAgentReasoning),i=Me(N=>N.setShowAgentReasoning),o=Me(N=>N.transcriptDisplayMode),l=Me(N=>N.setTranscriptDisplayMode),{data:d,isLoading:u,isFetching:c,error:m,refetch:p}=ba(),{needsProvider:f}=va(),b=Un(),{sentence:h,remedy:_}=Dt(b??null,n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded"),m),w=Va(),[A,K]=r.useState(null),C=Pn(),{isAuthenticated:O,accountRead:T,isFetching:L,isRefreshing:I,refreshUser:W}=Vt(),X=lt(N=>N.activeSessionId),[J,D]=r.useState("general"),[te,z]=r.useState(!1),P=r.useRef(null),H=r.useRef(null),{startTour:U}=Ga(),R=ja(),{data:Y,refetch:y}=wa(),{refreshModels:x}=Na(),v=r.useMemo(()=>Y?.keys?[...Y.keys].sort():[],[Y?.keys]),Q=r.useRef({keys:"",hosting:void 0});r.useEffect(()=>{const N=v.join(","),M=d?.values?.hosting;(Q.current.keys!==N||Q.current.hosting!==M)&&(Q.current={keys:N,hosting:M},x().catch(F=>{console.error("Failed to refresh models after credentials or hosting change:",F)}))},[v,d?.values?.hosting,x]);const $=r.useRef({general:r.useRef(null),radient:r.useRef(null),integrations:r.useRef(null),appearance:r.useRef(null),speech:r.useRef(null),keyboard:r.useRef(null),providers:r.useRef(null),backend:r.useRef(null),imports:r.useRef(null),updates:r.useRef(null)}).current,ne=r.useMemo(()=>new URLSearchParams(R.search).get("setting"),[R.search]),V=r.useMemo(()=>new URLSearchParams(R.search).get("filter")??"",[R.search]),se=r.useMemo(()=>new URLSearchParams(R.search).get("mcp")??void 0,[R.search]),ve=r.useMemo(()=>new URLSearchParams(R.search).get("provider"),[R.search]),pe=r.useCallback(N=>{D(N),z(!0);const M=$[N],F=H.current;if(M?.current&&F){const ie=M.current.getBoundingClientRect().top-F.getBoundingClientRect().top;F.scrollHeight>F.clientHeight?F.scrollTo({top:Math.max(0,F.scrollTop+ie-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,M.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(P.current??void 0),P.current=setTimeout(()=>{z(!1),P.current=null},800)}else z(!1)},[$]);r.useEffect(()=>{const N=setTimeout(()=>{const M=H.current;if(!M)return;const F=()=>{if(te)return;const re=M.getBoundingClientRect(),ie=re.height;let le="",ye=0;for(const[ge,Ie]of Object.entries($))if(Ie.current){const xe=Ie.current.getBoundingClientRect(),je=re.top,Ne=xe.top-je,Re=xe.bottom-je,yt=xe.height,kt=Math.max(0,Ne),Ze=Math.min(ie,Re),Be=Math.max(0,Ze-kt)/yt,Je=Be+(Ne<ie*.3?.1:0);Je>ye&&Be>.1&&(ye=Je,le=ge)}le&&le!==J&&D(le)};return F(),M.addEventListener("scroll",F,{passive:!0}),()=>{M.removeEventListener("scroll",F),clearTimeout(P.current??void 0)}},100);return()=>clearTimeout(N)},[$,J,te]),r.useEffect(()=>{const N=new URLSearchParams(R.search),M=N.get("section"),F=N.get("setting"),re=F?rn(F,"backend"):M,ie=re?$[re]:void 0;if(!re||!ie)return;let le=!1,ye=Number.NaN,ge=0;const Ie=window.setTimeout(()=>{le||(le=!0,je.disconnect(),pe(re))},2e3),xe=()=>{if(le)return;const Ne=ie.current;if(!Ne){ge=requestAnimationFrame(xe);return}const Re=Math.round(Ne.getBoundingClientRect().top+window.scrollY);if(Re===ye&&Re>0){le=!0,je.disconnect(),window.clearTimeout(Ie),pe(re);return}ye=Re,ge=requestAnimationFrame(xe)},je=new ResizeObserver(()=>{le||(cancelAnimationFrame(ge),ge=requestAnimationFrame(xe))});return H.current&&je.observe(H.current),ge=requestAnimationFrame(xe),()=>{le=!0,cancelAnimationFrame(ge),je.disconnect(),window.clearTimeout(Ie)}},[R.search,$,pe]);const me=async(N,M)=>{K(N);try{await w.mutateAsync({[N]:M}),await p()}catch(F){console.error(`Error updating ${N}:`,F)}finally{K(null)}},fe=u,j=T==="checking",B=Kn(T),q=T==="ready"||T==="checking"||L,ae=Hn(fe,4e3);return m?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(oe,{variant:"warning",className:"w-full max-w-xl",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:h}),_&&t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void p(),disabled:c,children:c?n("ui.settings.navigation.settings_page.retrying"):n("ui.settings.navigation.settings_page.retry")})]})})}):fe?t.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[t.jsx(he,{size:"lg",label:ae?void 0:n("ui.settings.navigation.settings_page.loading_settings")}),ae&&t.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:n("ui.settings.navigation.settings_page.the_local_operator_server_is_taking_longer_than_usual_to_answer_i")})]}):d?t.jsxs("div",{"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full w-full overflow-hidden bg-canvas",children:[t.jsx("div",{ref:e,className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:t.jsx(qa,{activeSection:J,onSelectSection:pe,sections:Ya})}),t.jsx("div",{ref:H,"data-settings-content":!0,"data-glass-region":"canvas-content","data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[t.jsx(ni,{title:n("ui.settings.page.title"),icon:cn}),t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{ref:$.general,className:"flex flex-col gap-8",children:[t.jsx(Qa,{focus:ne===ys}),t.jsxs(ce,{title:n("ui.settings.profile.title"),icon:Wa,description:n(O?"ui.settings.profile.description_authenticated":"ui.settings.profile.description_anonymous"),children:[j&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.profile.account_checking")}),B&&t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:n(T==="refused"?"ui.settings.profile.account_read_failed_refused":"ui.settings.profile.account_read_failed_retry")}),t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>W(),disabled:I,children:I?n("ui.settings.profile.retrying"):n("ui.settings.profile.retry")})]})}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(dn,{value:C.profile.name,label:n("ui.settings.profile.display_name.label"),placeholder:n("ui.settings.profile.display_name.placeholder"),isSaving:A==="user_name",onSave:async N=>{K("user_name");try{C.updateName(N)}finally{K(null)}},readOnly:q}),t.jsx(dn,{value:C.profile.email,label:n("ui.settings.profile.email.label"),placeholder:n("ui.settings.profile.email.placeholder"),isSaving:A==="user_email",onSave:async N=>{K("user_email");try{C.updateEmail(N)}finally{K(null)}},readOnly:q})]})]}),t.jsx(ce,{title:n("ui.settings.tour.title"),description:n("ui.settings.tour.description"),children:t.jsxs(G,{variant:"secondary",onClick:()=>{U({forceModalCompleted:!0})},children:[t.jsx(Hi,{}),n("ui.settings.tour.action")]})}),t.jsx(ce,{id:"model-settings",title:n("ui.settings.model.settings_page.model_settings"),icon:Za,description:n("ui.settings.model.settings_page.configure_the_default_ai_model_and_hosting_providers_used_for_gen"),children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Ja,{value:d.values.hosting,isSaving:A==="hosting",onSave:N=>me("hosting",N),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:n("ui.settings.model.settings_page.no_hosting_options")}),t.jsx(Xa,{value:d.values.model_name,hostingId:d.values.hosting,isSaving:A==="model_name",onSave:N=>me("model_name",N),allowCustom:!0,allowDefault:!1}),t.jsx(tl,{hosting:d.values.hosting,modelName:d.values.model_name,focus:ne===ot}),f&&t.jsx(oe,{variant:"neutral",icon:t.jsx(pt,{className:"size-4","aria-hidden":"true"}),children:t.jsxs("span",{children:[n("ui.settings.model.provider_callout.sentence"),t.jsx("button",{type:"button",className:"text-accent underline underline-offset-2",onClick:()=>{pe("providers"),$.providers.current?.focus({preventScroll:!0})},children:n("ui.settings.model.provider_callout.providers_link")}),"."]})})]})}),t.jsx(ld,{}),t.jsx(ce,{title:n("ui.settings.configuration.settings_page.configuration_information"),icon:pt,description:n("ui.settings.configuration.settings_page.system_information_about_the_current_configuration"),children:t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.configuration.settings_page.version"),value:t.jsx("span",{className:"text-mono-sm",children:d.version})}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.created"),value:$n(d.metadata.created_at)}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.last_modified"),value:qt(d.metadata.last_modified)}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.description"),value:d.metadata.description||n("ui.settings.configuration.settings_page.no_description_available")})]})})]}),t.jsx(ce,{title:n("ui.settings.appearance.settings_page.appearance"),icon:qn,description:n("ui.settings.appearance.settings_page.customize_the_look_and_feel_of_local_operator"),sectionRef:$.appearance,dataTourTag:"settings-appearance-section",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(fd,{}),t.jsx(Yn,{value:a,label:n("ui.settings.appearance.settings_page.show_agent_reasoning"),description:n("ui.settings.appearance.settings_page.adds_the_agent_s_reasoning_and_thinking_rows_to_conversations_the"),onChange:async N=>i(N)}),t.jsx(xd,{value:Bn(o),onChange:N=>l(N)}),t.jsx(qr,{state:s.state,onChange:s.set})]})}),t.jsx(rd,{sectionRef:$.speech}),t.jsx(jl,{sectionRef:$.keyboard}),t.jsx(ce,{title:n("ui.settings.model.settings_page.model_providers"),icon:zn,description:n("ui.settings.navigation.settings_page.sign_in_to_the_services_your_agents_think_with_new_chats_use_your"),sectionRef:$.providers,id:"model-providers",className:"focus-visible:outline-none!",children:t.jsx(ei,{initialProviderId:ve,onChangeModel:()=>pe("general")})}),t.jsx(Vc,{sessionId:X??void 0,sectionRef:$.integrations,highlightServer:se}),t.jsx(ce,{title:n("ui.settings.account.settings_page.radient_account"),titleComponent:t.jsx(vd,{}),description:n("ui.settings.account.settings_page.your_radient_account_radient_pass_details_and_credits_to_use_radi"),sectionRef:$.radient,dataTourTag:"settings-radient-account-section",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsx(Qc,{onAfterCredentialUpdate:()=>{x(),y()}}),O&&t.jsxs(t.Fragment,{children:[t.jsx(yd,{}),t.jsx(bd,{})]})]})}),t.jsx(ce,{title:n("ui.settings.navigation.settings_page.backend_settings"),icon:cn,description:n("ui.settings.navigation.settings_page.every_setting_the_backend_registry_owns_searchable_with_typed_edi"),sectionRef:$.backend,children:t.jsx(Sa,{hideInterfaceLanguage:!0,hideModelEffort:!0,focusKey:ne&&rn(ne,"backend")==="backend"?ne:null,initialFilter:V})}),t.jsx("div",{ref:$.imports,children:t.jsx(kl,{})}),t.jsx("div",{ref:$.updates,children:t.jsx(Zr,{})})]})]})})]}):t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(oe,{variant:"warning",className:"w-full max-w-xl",children:n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded")})})};export{Fd as SettingsPage};
|
|
286
|
+
*/const Er=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],Tr=M("wind",Er),Lr=({appVersion:e=null,slowWaitHintMs:s})=>{ee();const a="https://local-operator.com/download",[i,o]=r.useState(!1),l=Hn(i,s??Oa),[d,u]=r.useState(!1),[c,m]=r.useState(null),[p,f]=r.useState("info"),[b,h]=r.useState(null),[_,w]=r.useState(null),A=e?.trim()?e.trim():null,K=r.useRef(!1),S=It(z=>z.openDetail),O=r.useRef(!1),T=r.useRef(0),L=r.useRef(!1),I=r.useCallback((z,P)=>{O.current=!1,m(z),f(P),u(!0)},[]),W=r.useCallback(z=>{O.current=!0,m(z),f("success"),u(!0)},[]),X=r.useCallback(()=>{O.current&&(O.current=!1,u(!1),m(null))},[]),{clearDeferredUpdate:J}=ks();r.useEffect(()=>{const z=window.api.updater.onUpdateError(y=>{K.current&&y.includes("manually")&&(h({message:n("ui.common.updates.check_for_updates_button.the_server_is_installed_outside_the_app_so_use_the_tool_you_insta"),command:""}),O.current=!1,m(null),f("warning"),u(!0))}),P=window.api.updater.onBackendUpdateDevMode(y=>{K.current&&I(y,"info")}),H=()=>{L.current=!0,X()},U=window.api.updater.onUpdateAvailable(H),R=window.api.updater.onUpdateNpxAvailable(H),Y=window.api.updater.onBackendUpdateAvailable(H);return()=>{z(),P(),U(),R(),Y()}},[X,I]),r.useEffect(()=>{let z=!1;const P=()=>{window.api.updater.getLastInstallAttempt().then(U=>{z||w(U)}).catch(()=>{})};P();const H=window.api.updater.onUpdateInstallFailed(()=>P());return()=>{z=!0,H()}},[]);const D=async()=>{const z=++T.current;X(),L.current=!1;try{o(!0),K.current=!0,J(Ce.UI),J(Ce.BACKEND);const P=await window.api.updater.checkForAllUpdates({manual:!0});if(z!==T.current)return;P.app==="available"&&S(Ce.UI),P.server==="available"&&S(Ce.BACKEND),P?.affirmation&&!L.current?W(P.affirmation):X()}catch(P){if(z!==T.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Fa(P)}`)}finally{z===T.current&&o(!1),setTimeout(()=>{K.current=!1},2e3)}},te=()=>{O.current=!1,u(!1),m(null)};return t.jsxs(t.Fragment,{children:[_&&t.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[t.jsxs("p",{className:"text-body-sm text-ink",children:[n("ui.common.updates.check_for_updates_button.the_last_update_to_version"),_.targetVersion," ",n("ui.common.updates.check_for_updates_button.didn_t_finish"),_.attempts>1?n("ui.common.updates.check_for_updates_button.detail",{attempts:_.attempts,attemptsText:String(_.attempts)}):"",".",A?n("ui.common.updates.check_for_updates_button.version",{liveversion:String(A)}):null]}),t.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:[n("ui.common.updates.check_for_updates_button.detected")," ",_.detectedAt?new Date(_.detectedAt).toLocaleString():"at an unknown time",". ",_.detail]}),t.jsx(G,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(a),children:n("ui.common.updates.check_for_updates_button.download_a_fresh_copy")})]}),t.jsxs(G,{variant:"outline",onClick:()=>void D(),disabled:i,children:[i?t.jsx(he,{size:"sm"}):null,i?n("ui.common.updates.check_for_updates_button.checking"):n("ui.common.updates.check_for_updates_button.check_for_updates")]}),l&&t.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.common.updates.check_for_updates_button.still_checking_a_slow_or_stalled_connection_can_hold_this_for_abo")}),b&&t.jsxs(sn,{open:d,autoHideDuration:1e4,onClose:te,variant:"warning",children:[t.jsx("p",{className:"text-body-sm",children:b.message}),b.command&&t.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:b.command})]}),c&&p!=="danger"&&t.jsx(sn,{open:d,autoHideDuration:6e3,onClose:te,variant:p,children:c})]})},ct=["system-prompt"],Or=()=>{const{shouldEnableQuery:e}=bs();return be({enabled:e({bypassInternetCheck:!0}),queryKey:ct,queryFn:async()=>{try{const a=await Rn(Bt.baseUrl).config.getSystemPrompt();if(a===null)return null;if(a.status>=400)throw new Error(a.message||"Failed to fetch system prompt");return a.result}catch(s){const a=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw En(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},Fr=()=>{const e=Ht(),s=Rn(Bt.baseUrl);return vs({mutationFn:async a=>{try{const i=await s.config.updateSystemPrompt(a);if(i.status>=400)throw new Error(i.message||"Failed to update system prompt");return i.result}catch(i){const o=i instanceof Error?i.message:"An unknown error occurred while updating system prompt";throw En(o),i}},onSuccess:async a=>{await e.invalidateQueries({queryKey:ct,refetchType:"none"}),e.setQueryData(ct,i=>i&&{...i,...a}),await e.refetchQueries({queryKey:ct,type:"all"}),js("System prompt updated")},onError:a=>{console.error("Error updating system prompt:",a)}})},Yn=({value:e,label:s,description:a,onChange:i,icon:o,isSaving:l=!1,disabled:d=!1})=>{const[u,c]=r.useState(e),m=r.useId(),p=`${m}-label`,f=`${m}-description`,b=async h=>{if(!(l||d)){c(h);try{await i(h)}catch(_){c(!h),console.error("Error toggling setting:",_)}}};return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{id:p,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[o&&t.jsx(o,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),a&&t.jsx("p",{id:f,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:a})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:l?t.jsx(he,{size:"md",label:`Saving ${s}`}):t.jsx(ai,{checked:u,onCheckedChange:b,disabled:d,"aria-labelledby":p,"aria-describedby":a?f:void 0})})]})};function gn(e,s){const a=Ci(e,s?.in);if(!Ni(a))throw new RangeError("Invalid time value");const i=Le(a.getDate(),2),o=Le(a.getMonth()+1,2),l=a.getFullYear(),d=Le(a.getHours(),2),u=Le(a.getMinutes(),2),c=Le(a.getSeconds(),2);let m="",p="";const f=a.getTimezoneOffset();if(f!==0){const b=Math.abs(f),h=Le(Math.trunc(b/60),2),_=Le(b%60,2);p=`${f<0?"+":"-"}${h}:${_}`}else p="Z";return`${l}-${o}-${i}T${d}:${u}:${c}${m}${p}`}function Dr(e,s,a){return wi(e,-30,a)}var zr=ws({chartName:"LineChart",GraphicalChild:Tn,axisComponents:[{axisType:"xAxis",AxisComp:Ns},{axisType:"yAxis",AxisComp:Ss}],formatAxisMap:Cs});const Pr=["radient","creditBalance"],$r=e=>{const{user:s,isAuthenticated:a}=Vt(),i=s?.account?.tenant_id,o=a&&!!i&&e?.enabled;return be({queryKey:[Pr,i],queryFn:async()=>{if(!i)throw new Error("Tenant ID not available");const l=await Ln({operation:"credits",tenantId:i});if(!l||typeof l.balance!="number")throw new Error("Invalid credit balance response format");return l},enabled:o,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Kr=["radient","usageRollup"],Ur=(e,s)=>{const{user:a,isAuthenticated:i}=Vt(),o=a?.account?.tenant_id,l=i&&!!o&&s?.enabled;return be({queryKey:[...Kr,o,e],queryFn:async()=>{if(!o)throw new Error("Tenant ID not available");const d={};for(const[c,m]of Object.entries(e))m!=null&&(d[c]=String(m));const u=await Ln({operation:"usage",tenantId:o,query:d});if(!u)throw new Error("Invalid usage rollup response format");return u},enabled:l,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Br=e=>e==="sidebars"?n("ui.settings.appearance.window_glass.coverage_sidebars"):n("ui.settings.appearance.window_glass.coverage_full"),Hr=e=>{switch(e){case"window":return n("ui.settings.appearance.window_glass.material_window");case"menu":return n("ui.settings.appearance.window_glass.material_menu");case"popover":return n("ui.settings.appearance.window_glass.material_popover");case"mica":return n("ui.settings.appearance.window_glass.material_mica");case"acrylic":return n("ui.settings.appearance.window_glass.material_acrylic");case"tabbed":return n("ui.settings.appearance.window_glass.material_tabbed")}},Vr=e=>{switch(e){case"reduced-transparency":return n("ui.settings.appearance.window_glass.unsupported_reduced_transparency");case"windows-too-old":return n("ui.settings.appearance.window_glass.unsupported_windows_too_old");case"windows-unverified":return n("ui.settings.appearance.window_glass.unsupported_windows_unverified");case"linux-compositor-dependent":return n("ui.settings.appearance.window_glass.unsupported_linux");case"hardware-acceleration-disabled":return n("ui.settings.appearance.window_glass.unsupported_acceleration");case"gpu-unavailable":return n("ui.settings.appearance.window_glass.unsupported_gpu");case"backdrop-filter-unavailable":return n("ui.settings.appearance.window_glass.unsupported_backdrop_filter");default:return n("ui.settings.appearance.window_glass.unsupported_other")}},_n=({label:e,description:s,value:a,onValueChange:i,options:o})=>{const l=r.useId();return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{id:l,className:"flex min-h-6 items-center text-body text-ink",children:e}),t.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:s})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsx(gt,{value:a,onValueChange:i,children:t.jsx(_t,{"aria-labelledby":l,children:o.map(d=>t.jsx($e,{value:d.value,children:d.label},d.value))})})})]})},Gr=({state:e,onChange:s})=>{ee();const a=r.useId(),i=`${a}-description`,[o,l]=r.useState(null),d=r.useRef(!1),u=r.useRef(null),c=e?.settings.intensity??0;if(!e)return null;const m=!e.capability.supported,p=m?Vr(e.capability.reason):null,f=async _=>{if(d.current){u.current=_;return}d.current=!0;try{await s({intensity:_})}finally{d.current=!1;const w=u.current;u.current=null,w!==null&&w!==_?f(w):l(null)}},b=e.settings.enabled,h=o??c;return t.jsxs("div",{className:"flex flex-col gap-4","data-window-glass":"","data-glass-gate":e.capability.reason,children:[t.jsx(Ke,{content:p,disabled:!m,children:t.jsx("div",{className:m?"opacity-60":void 0,children:t.jsx(Yn,{value:m?!1:b,disabled:m,label:n("ui.settings.appearance.window_glass.label"),description:n("ui.settings.appearance.window_glass.description"),onChange:async _=>s({enabled:_})},m?"unavailable":"available")})}),p&&t.jsx("p",{"data-glass-unsupported":e.capability.reason,className:"max-w-2xl text-body-sm text-ink-muted",children:p}),e.restartRequired&&t.jsx("output",{className:"block max-w-2xl text-body-sm text-ink","data-glass-restart":"",children:n("ui.settings.appearance.window_glass.restart_needed")}),b&&!m&&t.jsxs(t.Fragment,{children:[t.jsx(_n,{label:n("ui.settings.appearance.window_glass.coverage_label"),description:n("ui.settings.appearance.window_glass.coverage_description"),value:e.settings.coverage,onValueChange:_=>void s({coverage:_}),options:Ms.map(_=>({value:_,label:Br(_)}))}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[t.jsx("label",{htmlFor:a,className:"text-body text-ink",children:n("ui.settings.appearance.window_glass.intensity_label")}),t.jsx("span",{"data-glass-readout":"",className:"shrink-0 text-meta text-ink-dim tabular-nums",children:n("ui.settings.appearance.window_glass.intensity_value",{value:String(h)})})]}),t.jsx("p",{id:i,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.window_glass.intensity_description")}),t.jsx("input",{id:a,type:"range",min:0,max:100,step:5,value:h,"aria-describedby":i,"aria-valuetext":n("ui.settings.appearance.window_glass.intensity_value",{value:String(h)}),onChange:_=>{const w=Number(_.target.value);l(w),f(w)},style:{"--fill":`${h}%`},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover"}),t.jsxs("div",{"aria-hidden":"true",className:"mt-1 flex justify-between text-meta text-ink-dim",children:[t.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_start")}),t.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_end")})]})]}),t.jsx(_n,{label:n("ui.settings.appearance.window_glass.material_label"),description:n("ui.settings.appearance.window_glass.material_description"),value:e.settings.material,onValueChange:_=>void s({material:_}),options:e.capability.materials.map(_=>({value:_,label:Hr(_)}))})]})]})},pn={get[Ce.UI](){return n("ui.settings.updates.update_following.application_updates")},get[Ce.BACKEND](){return n("ui.settings.updates.update_following.server_updates")}},tt={patch:{get label(){return n("ui.settings.updates.update_following.patch_label")},get description(){return n("ui.settings.updates.update_following.patch_help")}},minor:{get label(){return n("ui.settings.updates.update_following.minor_label")},get description(){return n("ui.settings.updates.update_following.minor_help")}},major:{get label(){return n("ui.settings.updates.update_following.major_label")},get description(){return n("ui.settings.updates.update_following.major_help")}}},hn=({type:e})=>{ee();const s=It(i=>i.followed[e]),a=It(i=>i.setFollowedSegment);return t.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-body-sm text-ink",children:pn[e]}),t.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:tt[s].description})]}),t.jsxs(ii,{value:s,onValueChange:i=>a(e,i),children:[t.jsx(oi,{"aria-label":n("ui.settings.updates.update_following.surface_choice",{surface:pn[e],choice:tt[s].label}),className:"w-full sm:w-56","data-followed-segment":e,children:t.jsx(ri,{})}),t.jsx(li,{children:As.map(i=>t.jsx(ci,{value:i,title:tt[i].description,children:tt[i].label},i))})]})]})},qr=()=>(ee(),t.jsxs("div",{className:ue("flex flex-col gap-3"),children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.updates.update_following.update_notifications")}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.updates.update_following.how_much_of_a_version_change_shows_the_update_notice_at_the_botto")})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(hn,{type:Ce.UI}),t.jsx(hn,{type:Ce.BACKEND})]})]})),Yr=({appVersion:e})=>t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(qr,{}),t.jsx(Lr,{appVersion:e})]}),Qr=e=>{if(!e)return null;try{return new URL(e).host}catch{return null}};function wt(e){switch(e){case"Loading...":return n("ui.settings.updates.app_updates_section.state_loading");case"Not connected":return n("ui.settings.updates.app_updates_section.state_not_connected");case"Not attached":return n("ui.settings.updates.app_updates_section.state_not_attached");case"Version unknown":return n("ui.settings.updates.app_updates_section.state_version_unknown");case"Unavailable":return n("ui.settings.updates.app_updates_section.state_unavailable");default:return e}}const Wr=()=>{ee();const[e,s]=r.useState(null),[a,i]=r.useState({value:"Loading...",detail:null,degraded:!1}),[o,l]=r.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});r.useEffect(()=>{let u=!0;const c=h=>{if(!u)return;const _=Qr(h.url);if(h.state==="connecting"){i({value:"Loading...",detail:null,degraded:!1});return}if(h.state==="detached"){i({value:"Not connected",detail:h.detail||null,degraded:!1});return}if(h.state==="wedged"){i({value:"Not attached",detail:h.detail||null,degraded:!1});return}const w=h.version||"Version unknown";i({value:_?`${w} · ${_}`:w,detail:h.detail||null,degraded:h.state==="degraded"})};let m=!1;const p=window.api?.backend?.onStatusChange(h=>{m=!0,c(h)}),f=async()=>{try{const[h,_]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);u&&(s(h),l(_))}catch(h){console.error("Error fetching app information:",h)}},b=async()=>{try{const h=window.api?.backend;if(h){const A=await h.getStatus();m||c(A);return}const _=await an.healthCheck(Bt.baseUrl),w=an.getServerVersion(_);u&&i({value:w,detail:null,degraded:!1})}catch(h){console.error("Error fetching server version:",h),u&&i({value:"Unavailable",detail:null,degraded:!1})}};return f(),b(),()=>{u=!1,p?.()}},[]);const d=(u,c,m,p={})=>t.jsx(_e,{label:t.jsx(Ke,{content:m,children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(pt,{size:12,className:"shrink-0"}),u]})}),valueClassName:p.valueClassName,value:t.jsxs(t.Fragment,{children:[p.valueTooltip?t.jsx(Ke,{content:p.valueTooltip,children:t.jsx("span",{"data-backend-version":p.valueHoverTarget?"":void 0,children:c})}):c,p.statusNote?t.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:p.statusNote}):null]})});return t.jsx(ce,{title:n("ui.settings.updates.app_updates_section.application_updates_and_info"),icon:it,description:n("ui.settings.updates.app_updates_section.check_for_updates_and_view_information_about_your_local_operator_"),dataTourTag:"settings-app-updates-section",children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs(ht,{children:[d(n("ui.settings.updates.app_updates_section.application_version"),e??n("ui.settings.updates.app_updates_section.state_loading"),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_user_interface_application")),d(n("ui.settings.updates.app_updates_section.server_version"),wt(a.value),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_api_server_backend_and_the_addr"),{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?n("ui.settings.updates.app_updates_section.not_answering"):void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),d(n("ui.settings.updates.app_updates_section.platform"),`${o.platform} (${o.arch})`,n("ui.settings.updates.app_updates_section.the_operating_system_and_architecture_your_application_is_running")),d(n("ui.settings.updates.app_updates_section.node_js_version"),wt(o.nodeVersion),n("ui.settings.updates.app_updates_section.the_javascript_runtime_environment_version")),d(n("ui.settings.updates.app_updates_section.electron_version"),wt(o.electronVersion),n("ui.settings.updates.app_updates_section.the_framework_version_enabling_this_desktop_application"))]}),t.jsx(Yr,{appVersion:e})]})})};function Qn(e){const s={id:"",name:n("ui.settings.model.default_effort.model_default")};return e.resolvedLevel&&e.stored.trim()===""&&Qt(e.resolvedLevel,e.storable)!==null&&(s.description=n("ui.settings.model.default_effort.model_default_resolves",{level:Fe(e.resolvedLevel)})),[s,...Wn(e.ladder,e.storable)]}function Qt(e,s){const a=e.trim().toLowerCase();return a===""?null:s.find(i=>i.trim().toLowerCase()===a)??null}function Wn(e,s){return e.flatMap(a=>{const i=Qt(a,s);return i===null?[]:[{id:i,name:Fe(a)}]})}function Zr(e,s){const a=e.trim().toLowerCase();return a!==""&&s.some(i=>i.toLowerCase()===a)?s.find(i=>i.toLowerCase()===a)??"":""}function Jr(e){if(!e.resolved||e.ladder===null)return null;const s=e.stored.trim().toLowerCase();if(s===""||e.ladder.some(o=>o.toLowerCase()===s))return null;const a=(e.resolvedLevel??"").trim(),i=a===""?"":Qt(a,e.storable)??"";return i.trim().toLowerCase()===s?null:i}const dt="\0unread";function nt(e){return e.trim()===""?"":dt}function Xr(e){if(!e.supported)return{kind:"unsupported",options:[],selectedId:"",disabled:!0,helper:""};if(!e.hasHome)return Se("no-home",n("ui.settings.model.default_effort.no_home"));if(!e.hasModel)return Se("no-model",n("ui.settings.model.default_effort.no_model"),dt);if(e.settings==="loading")return Se("settings-loading",n("ui.settings.model.default_effort.settings_loading"),dt);if(e.settings==="error")return Se("settings-error",n("ui.settings.model.default_effort.settings_error"),dt);if(e.preview==="loading")return Se("loading",n("ui.settings.model.default_effort.loading"),nt(e.stored));if(e.preview==="error")return Se("error",n("ui.settings.model.default_effort.error"),nt(e.stored));if(e.ladder===null||!e.specResolved)return Se("unresolved",n("ui.settings.model.default_effort.unresolved"),nt(e.stored));const s=e.ladder;if(s.length===0)return Se("empty",n("ui.settings.model.default_effort.empty"),nt(e.stored));const a=Wn(s,e.storable);if(a.length===0){const i=Fe(s[0]),o=s.length===1&&s[0].trim().toLowerCase()==="auto";return{kind:"one-level",options:[{id:"",name:i}],selectedId:"",disabled:!0,helper:o?n("ui.settings.model.default_effort.one_level_sentinel"):n("ui.settings.model.default_effort.one_level",{level:i})}}if(s.length===1){const[i]=a;return{kind:"one-level",options:[i],selectedId:i.id,disabled:!0,helper:n("ui.settings.model.default_effort.one_level",{level:i.name})}}return{kind:"ready",options:Qn({ladder:s,resolvedLevel:e.resolvedLevel,stored:e.stored,storable:e.storable}),selectedId:Zr(e.stored,a.map(i=>i.id)),disabled:!1,helper:n("ui.settings.model.default_effort.helper_ready")}}function Se(e,s,a=""){return{kind:e,options:Qn({ladder:[],resolvedLevel:null,stored:"",storable:[]}),selectedId:a,disabled:!0,helper:s}}const el=({hosting:e,modelName:s,focus:a=!1})=>{ee();const i=Gt(),o=Rt(i.data,"draft_preview"),l=Is(),d=e!==""&&s!=="",u=be({queryKey:Et.all,queryFn:()=>de({op:"settings.list"}),enabled:o,staleTime:1e4}),c=u.data?.settings.find(V=>V.key===ot),m=typeof c?.value=="string"?c.value:"",p=(c?.choices??[]).map(V=>V.value).filter(V=>typeof V=="string"),f={cwd:l??"",model:d?{provider:e,model_id:s,reasoning_effort:null}:null},b=u.isSuccess?m:null,h=be({...Es(f),queryKey:[...Rs(f),"model_effort",b],enabled:o&&!!l&&d}),_=h.isSuccess&&!h.isPlaceholderData,w=_?Ts(h.data?.snapshot,null).effort:null,A=_&&Array.isArray(w?.reasoning_efforts)?Ls(w):null,K=_?Os(w):null,S=w!==null&&!Fs(w),[O,T]=r.useState(!1),[L,I]=r.useState(!1),[W,X]=r.useState(null),[J,D]=r.useState(null),te=`${e}\0${s}`,z=Ht(),P=r.useRef(null),H=r.useRef(!1),U=r.useCallback(async(V,se)=>{T(!0),X(V),I(!1),se===null&&D(null);try{await de({op:"settings.edit",key:ot,value:V}),await z.invalidateQueries({queryKey:Et.all}),se!==null&&D(se)}catch{I(!0)}finally{T(!1),X(null)}},[z]),R=typeof w?.display_name=="string"&&w.display_name.trim()||s,Y=Xr({supported:o,hasHome:!!l,hasModel:d,settings:u.isError?"error":u.isSuccess?"ready":"loading",preview:h.isError?"error":_?"ready":"loading",ladder:A,specResolved:S,stored:m,resolvedLevel:K,storable:p}),y=Jr({stored:m,ladder:A,resolvedLevel:K,resolved:_&&S&&u.isSuccess,storable:p}),x=r.useRef(null);r.useEffect(()=>{if(y===null||O)return;const V=`${e}\0${s}\0${m}\0${y}`;if(x.current===V)return;x.current=V;const se=y===""?n("ui.settings.model.default_effort.clamped_unset",{level:Fe(m),model:R}):n("ui.settings.model.default_effort.clamped",{level:Fe(m),model:R,resolved:Fe(y)});U(y,{text:se,model:te})},[y,m,O,U,e,s,R,te]);const v=r.useMemo(()=>Y.options.map(tl),[Y.options]);r.useEffect(()=>{if(!a){H.current=!1;return}Y.disabled||H.current||(P.current?.querySelector("[role=combobox]")?.focus(),H.current=!0)},[a,Y.disabled]);const Q=W??Y.selectedId,$=v.find(V=>V.id===Q)??(W!==null?{id:W,name:Fe(W)}:null),ne=t.jsxs("span",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{children:Y.helper}),L&&t.jsx("span",{className:"text-danger",children:n("ui.settings.model.default_effort.save_failed")}),t.jsx("output",{"aria-live":"polite",children:J?.model===te?J.text:""})]});return Y.kind==="unsupported"?null:t.jsx("div",{ref:P,"data-setting-key":ot,children:t.jsx(di,{label:n("ui.settings.model.default_effort.label"),icon:t.jsx(Da,{size:16,"aria-hidden":"true"}),placeholder:n("ui.settings.model.default_effort.placeholder"),options:v,selected:$,onSelect:V=>{U(V.id,null)},helperText:ne,busy:O,busyLabel:n("ui.settings.model.default_effort.busy"),disabled:Y.disabled||O})})};function tl(e){return{id:e.id,name:e.name,description:e.description}}const nl=e=>e.replace(/[\p{Co}\p{Cc}]/gu," ").replace(/\s+/g," ").trim(),Zn=(e,s)=>{const a=s.trim().toLocaleLowerCase();return a?e.filter(i=>`${i.title} ${i.cwd} ${i.sourceId}`.toLocaleLowerCase().includes(a)):e},sl=(e,s)=>`${e??""}\0${[...s].sort().join("\0")}`,Jn=5e3,al=(e,s,a,i=Jn)=>{const o=new Set(a);let l=!1;for(const d of Zn(e,s))if(!o.has(d.sourceId)){if(o.size>=i){l=!0;break}o.add(d.sourceId)}return{selected:o,capped:l}},il=/cancel/i,ol=new Set(["done","failed","cancelled"]),fn=e=>{switch(e){case"metadata_only":return"ui.settings.imports.availability_metadata_only";case"unsupported":return"ui.settings.imports.availability_unsupported";default:return"ui.settings.imports.availability_full"}},Nt=e=>{switch(e){case"queued":return"ui.settings.imports.state_queued";case"done":return"ui.settings.imports.state_done";case"failed":return"ui.settings.imports.state_failed";case"cancelled":return"ui.settings.imports.state_cancelled";default:return"ui.settings.imports.state_running"}},rl=e=>{switch(e){case"selecting":return"ui.settings.imports.phase_selecting";case"memory":return"ui.settings.imports.phase_memory";case"done":return"ui.settings.imports.phase_done";case"cancelled":return"ui.settings.imports.phase_cancelled";case"queued":return"ui.settings.imports.phase_queued";default:return"ui.settings.imports.phase_importing"}},ll=e=>{switch(e){case"resumed":return"ui.settings.imports.outcome_resumed";case"skipped_already_imported":return"ui.settings.imports.outcome_skipped";case"metadata_only":return"ui.settings.imports.outcome_metadata";case"failed":return"ui.settings.imports.outcome_failed";case"cancelled":return"ui.settings.imports.outcome_cancelled";default:return"ui.settings.imports.outcome_imported"}},cl=e=>e==="failed"?"danger":e==="metadata_only"||e==="skipped_already_imported"?"neutral":e==="cancelled"?"warning":"success",Pt=e=>nl(e.title)||e.sourceId,xn=({path:e,label:s,onCopyPath:a})=>{const[i,o]=r.useState(!1);return t.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-hairline bg-surface p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-body-sm text-ink",children:s}),t.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:e})]}),t.jsxs(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a(e).then(l=>{l&&(o(!0),window.setTimeout(()=>o(!1),1500))})},children:[i?t.jsx(Vn,{size:14}):t.jsx(Fn,{size:14}),i?n("ui.settings.imports.copied"):n("ui.settings.imports.copy_path")]})]})},dl=({progress:e,sessions:s,selected:a})=>{const i=new Map(e.results.map(u=>[u.sourceId,u])),o=e.sessionId,l=Math.max(0,e.total-e.completed-(o&&!i.has(o)?1:0)),d=s.filter(u=>a.has(u.sourceId));return t.jsxs("div",{className:"flex flex-col gap-2",children:[e.results.map(u=>t.jsx(Xn,{row:u,jobCancelled:e.state==="cancelled"},`${u.source}:${u.sourceId}`)),d.filter(u=>!i.has(u.sourceId)&&u.sourceId!==o).map(u=>t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[t.jsx("span",{className:"min-w-0 truncate",children:Pt(u)}),t.jsx(qe,{variant:"neutral",children:n("ui.settings.imports.session_pending")})]},u.sourceId)),o&&!i.has(o)&&t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[t.jsx(rt,{size:14,className:"animate-spin"}),t.jsx("span",{children:n("ui.settings.imports.session_importing")}),t.jsx("span",{className:"min-w-0 truncate",children:o})]}),l>0&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.progress_pending",{count:l})}),e.warnings.map(u=>t.jsx("p",{className:"text-meta text-warning",children:u.message},`${u.code}:${u.sessionId}:${u.message}`))]})},Xn=({row:e,jobCancelled:s=!1})=>{const i=s&&e.outcome==="failed"&&e.warnings.some(o=>il.test(o))?"cancelled":e.outcome;return t.jsxs("div",{className:"rounded-md border border-hairline bg-surface p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:e.sourceId}),t.jsx(qe,{variant:cl(i),children:n(ll(i))}),t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.session_meta",{messages:e.messages,compactions:e.compactions})})]}),e.targetSessionId&&(e.messages>0||e.outcome==="skipped_already_imported")&&t.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:n("ui.settings.imports.result_target",{target:e.targetSessionId})}),e.warnings.map(o=>t.jsx("p",{className:"mt-1 text-meta text-warning",children:o},o))]})},ul=({sources:e,activeSource:s,sessions:a,query:i,selected:o,preview:l,previewStale:d,confirmed:u,busy:c,error:m,progress:p,result:f,cancelling:b,onSelectSource:h,onQueryChange:_,onToggleSession:w,onSelectAll:A,onClearSelection:K,onPreview:S,onConfirmChange:O,onImport:T,onCancel:L,onRetry:I,onImportAnother:W,onRefresh:X,selectionNotice:J,onCopyPath:D})=>{ee();const te=r.useRef(null),z=e.find(x=>x.source===s),P=p!==null&&!ol.has(p.state),H=p?.total??o.size;r.useEffect(()=>{l&&!d&&!p&&!f&&te.current?.scrollIntoView({block:"start",inline:"nearest"})},[l,d,p,f]);const U=r.useMemo(()=>Zn(a,i),[i,a]),R=U.length>0&&U.every(x=>o.has(x.sourceId)),Y=o.size,y=Y>0&&l!==null&&!d&&u&&!c&&!p&&!f;return t.jsx(ce,{title:n("ui.settings.imports.title"),icon:it,description:n("ui.settings.imports.description"),dataTourTag:"settings-import-section",children:t.jsxs("div",{className:"flex flex-col gap-5",children:[m&&t.jsxs(oe,{variant:"warning",children:[t.jsx(ui,{children:n("ui.settings.imports.title")}),t.jsx(et,{children:t.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("span",{children:m}),t.jsx(G,{variant:"secondary",size:"sm",onClick:I,children:n("ui.settings.imports.retry")})]})})]}),c==="sources"&&e.length===0?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Oe,{className:"h-20 w-full"}),t.jsx(Oe,{className:"h-20 w-full"}),t.jsx(Oe,{className:"h-20 w-full"}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sources")})]}):e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}):t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.source_heading")}),t.jsxs(G,{variant:"ghost",size:"sm",onClick:X,disabled:P||c==="sources"||c==="sessions",children:[t.jsx(za,{size:14,className:ue(c==="sources"&&"animate-spin")}),n("ui.settings.imports.refresh")]})]}),!e.some(x=>x.detected)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}),t.jsx("div",{className:"grid gap-2 lg:grid-cols-3",children:e.map(x=>{const v=x.source===s,Q=x.detected?n(fn(x.availability)):n("ui.settings.imports.source_not_found");return t.jsxs("button",{type:"button","aria-pressed":v,disabled:P,onClick:()=>h(x.source),className:ue("rounded-lg border p-3 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60","focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",v?"border-accent bg-accent-wash":"border-hairline bg-surface hover:bg-sunken"),children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-body-sm font-medium text-ink",children:x.label}),t.jsx(qe,{variant:x.detected&&x.availability==="full"?"success":"neutral",children:Q})]}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.imports.source_sessions",{count:x.sessionCount})}),t.jsx("p",{className:"mt-1 break-all text-meta text-ink-dim",children:x.detail||x.root})]},x.source)})})]}),z&&!p&&!f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("h3",{className:"text-heading text-ink",children:[n("ui.settings.imports.source_heading")," · ",z.label]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",size:"sm",onClick:R?K:A,disabled:U.length===0,children:R?n("ui.settings.imports.clear_all"):n("ui.settings.imports.select_all")}),t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.selected",{count:Y})})]})]}),J&&t.jsx("output",{className:"text-meta text-warning",children:J}),t.jsxs("div",{className:"relative",children:[t.jsx(On,{size:15,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim"}),t.jsx(Ae,{value:i,onChange:x=>_(x.target.value),placeholder:n("ui.settings.imports.search_placeholder"),className:"pl-9"})]}),c==="sessions"?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Oe,{className:"h-12 w-full"}),t.jsx(Oe,{className:"h-12 w-full"}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sessions",{source:z.label})})]}):a.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sessions",{source:z.label})}):U.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_filter")}):t.jsx("div",{className:"flex max-h-80 flex-col gap-1 overflow-y-auto",children:U.map(x=>t.jsxs("div",{className:"flex items-start gap-3 rounded-md border border-hairline bg-surface p-3 hover:bg-sunken",children:[t.jsx(zt,{checked:o.has(x.sourceId),onCheckedChange:()=>w(x.sourceId),"aria-label":Pt(x),className:"mt-0.5"}),t.jsxs("button",{type:"button",onClick:()=>w(x.sourceId),className:"min-w-0 flex-1 text-left",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:Pt(x)}),t.jsx(qe,{variant:x.availability==="full"?"neutral":"warning",children:n(fn(x.availability))})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-meta text-ink-muted",children:[t.jsx("span",{children:n("ui.settings.imports.session_meta",{messages:x.messageCount??0,compactions:x.compactionCount})}),t.jsx("span",{children:n("ui.settings.imports.session_updated",{date:qt(new Date((x.updatedTs||x.createdTs)*1e3))})})]}),x.cwd&&t.jsx("span",{className:"mt-1 block break-all font-mono text-meta text-ink-dim",children:x.cwd}),x.availability==="metadata_only"&&t.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.metadata_only_explain")}),x.availability==="unsupported"&&t.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.session_index_only")})]})]},x.sourceId))})]}),z&&Y>0&&!p&&!f&&t.jsxs("div",{ref:te,className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.preview_heading")}),t.jsxs(G,{variant:"secondary",size:"sm",onClick:S,disabled:c==="preview"||c==="start",children:[c==="preview"?t.jsx(rt,{size:14,className:"animate-spin"}):t.jsx(it,{size:14}),c==="preview"?n("ui.settings.imports.loading_preview"):n("ui.settings.imports.preview_heading")]})]}),d&&t.jsx(oe,{variant:"warning",children:t.jsx(et,{children:n("ui.settings.imports.preview_required")})}),l&&!d&&t.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-hairline bg-surface p-4",children:[t.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.imports.preview_summary",{sessions:l.totalSessions,messages:l.totalMessages,compactions:l.totalCompactions})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_memory",{records:l.totalMemoryRecords,tokens:l.projectedMemoryTokens.toLocaleString()})}),l.warnings.slice(0,4).map((x,v)=>t.jsx("p",{className:"text-meta text-warning",children:x.message},`${x.code}:${x.sessionId}:${v}`)),l.warnings.length>4&&t.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.imports.warnings_heading",{count:l.warnings.length})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_confirm")})]}),t.jsxs("div",{className:"flex items-start gap-2 text-body-sm text-ink",children:[t.jsx(zt,{checked:u,onCheckedChange:x=>O(x===!0),disabled:!l||d,"aria-label":n("ui.settings.imports.confirm_label"),className:"mt-0.5"}),t.jsx("span",{children:n("ui.settings.imports.confirm_label")})]}),t.jsxs(G,{variant:"primary",onClick:T,disabled:!y,className:"self-start",children:[c==="start"?t.jsx(rt,{size:14,className:"animate-spin"}):t.jsx(it,{size:14}),n("ui.settings.imports.import_button",{count:Y})]})]}),p&&!f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.progress_heading")}),t.jsxs(G,{variant:"secondary",size:"sm",onClick:L,disabled:b||p.state==="done"||p.state==="cancelled"||p.state==="failed",children:[t.jsx(Ds,{size:12}),b?n("ui.settings.imports.cancelling"):n("ui.settings.imports.cancel")]})]}),t.jsxs("p",{className:"text-meta text-ink-muted",children:[n("ui.settings.imports.progress_job",{job:p.jobId,state:n(Nt(p.state))})," · ",n(rl(p.phase))]}),t.jsx(mi,{value:p.total?p.completed/p.total*100:0,className:"h-1.5"}),t.jsx(dl,{progress:p,sessions:a,selected:o})]}),f&&t.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.result_heading")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:W,children:n("ui.settings.imports.import_another")})]}),t.jsx("p",{className:"text-body-sm text-ink",children:f.state==="cancelled"?n("ui.settings.imports.result_summary_cancelled",{state:n(Nt(f.state)),sessions:f.sessions.length,total:H,messages:f.messages}):n("ui.settings.imports.result_summary",{state:n(Nt(f.state)),sessions:f.sessions.length,messages:f.messages})}),f.sessions.map(x=>t.jsx(Xn,{row:x,jobCancelled:f.state==="cancelled"},`${x.source}:${x.sourceId}:${x.targetSessionId}`)),(f.instructionReviewPath||f.memoryReviewPath)&&t.jsxs("div",{className:"flex flex-col gap-2",children:[f.instructionReviewPath&&t.jsx(xn,{path:f.instructionReviewPath,label:n("ui.settings.imports.review_instructions"),onCopyPath:D}),f.memoryReviewPath&&t.jsx(xn,{path:f.memoryReviewPath,label:n("ui.settings.imports.review_memory"),onCopyPath:D})]}),f.warnings.length>0&&t.jsx(oe,{variant:"warning",children:t.jsx(et,{children:t.jsxs("span",{className:"flex flex-col gap-1",children:[t.jsx("span",{children:n("ui.settings.imports.warnings_heading",{count:f.warnings.length})}),f.warnings.slice(0,4).map((x,v)=>t.jsx("span",{children:x.message},`${x.code}:${v}`))]})})}),f.error&&t.jsx(oe,{variant:"danger",children:t.jsx(et,{children:f.error})}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.rerun_safe")})]}),c==="start"&&!p&&t.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[t.jsx(rt,{size:14,className:"animate-spin"}),n("ui.settings.imports.importing")]})]})})},Wt=e=>({source:e.source,sessionId:e.session_id,code:e.code,message:e.message}),es=e=>({source:e.source,sourceId:e.source_id,targetSessionId:e.target_session_id,outcome:e.outcome,messages:e.messages,compactions:e.compactions,redactions:e.redactions,skipped:e.skipped,warnings:e.warnings}),ml=e=>({jobId:e.job_id,state:e.state,sessions:e.sessions.map(es),messages:e.messages,compactions:e.compactions,memoryImported:e.memory_imported,memorySkipped:e.memory_skipped,memoryReviewPath:e.memory_review_path,instructionReviewPath:e.instruction_review_path,redactions:e.redactions,warnings:e.warnings.map(Wt),error:e.error});async function gl(){return(await de({op:"imports.sources"})).sources.map(s=>({source:s.source,label:s.label,root:s.root,detected:s.detected,sessionCount:s.session_count,availability:s.availability,detail:s.detail}))}async function _l(e,s=!1){return(await de({op:"imports.sessions",source:e,includeSubagents:s})).sessions.map(i=>({source:i.source,sourceId:i.source_id,title:i.title??"",cwd:i.cwd??"",createdTs:i.created_ts,updatedTs:i.updated_ts,messageCount:i.message_count,compactionCount:i.compaction_count,kind:i.kind,availability:i.availability,parentSourceId:i.parent_source_id}))}async function pl(e){const s=await de({op:"imports.preview",sources:e.sources,sessionIds:e.sessionIds,includeMemory:e.includeMemory??!0,includeInstructions:e.includeInstructions??!0});return{totalSessions:s.total_sessions,totalMessages:s.total_messages,messageCountsEstimated:s.message_counts_estimated,totalCompactions:s.total_compactions,totalMemoryRecords:s.total_memory_records,projectedMemoryTokens:s.projected_memory_tokens,projectedGlobalTokens:s.projected_global_tokens,warnings:s.warnings.map(Wt),instructionReviewPaths:s.instruction_review_paths}}async function hl(e){return(await de({op:"imports.start",sources:e.sources,sessionIds:e.sessionIds,includeMemory:e.includeMemory??!0,includeInstructions:e.includeInstructions??!0})).job_id}async function fl(e){const s=await de({op:"imports.status",jobId:e});return{jobId:s.job_id,state:s.state,phase:s.phase,source:s.source,sessionId:s.session_id,completed:s.completed,total:s.total,results:s.results.map(es),warnings:s.warnings.map(Wt),error:s.error,startedAt:s.started_at,updatedAt:s.updated_at,result:s.result?ml(s.result):void 0}}async function xl(e){await de({op:"imports.cancel",jobId:e})}const st=new Set(["done","failed","cancelled"]),Pe=e=>e instanceof Error?e.message:String(e),yl=()=>{ee();const[e,s]=r.useState([]),[a,i]=r.useState(null),[o,l]=r.useState([]),[d,u]=r.useState(""),[c,m]=r.useState(new Set),[p,f]=r.useState(null),[b,h]=r.useState(null),[_,w]=r.useState(!1),[A,K]=r.useState(null),[S,O]=r.useState(null),[T,L]=r.useState(null),[I,W]=r.useState(null),[X,J]=r.useState(!1),[D,te]=r.useState(null),[z,P]=r.useState(0),H=r.useRef(0),U=r.useRef(null),R=T!==null&&!st.has(T.state),Y=r.useCallback(async()=>{K("sources"),O(null);try{const C=await gl();s(C),i(F=>C.some(ie=>ie.source===F&&ie.detected)?F:C.find(ie=>ie.detected)?.source??null)}catch(C){O(n("ui.settings.imports.error_sources",{reason:Pe(C)}))}finally{K(null)}},[]);r.useEffect(()=>{Y()},[Y]);const y=r.useCallback(async C=>{const F=++H.current;K("sessions"),O(null);try{const re=await _l(C);if(F!==H.current)return;l(re)}catch(re){if(F!==H.current)return;l([]),O(n("ui.settings.imports.error_sessions",{source:C,reason:Pe(re)}))}finally{F===H.current&&K(null)}},[]);r.useEffect(()=>{if(!a){l([]);return}l([]),m(new Set),f(null),h(null),w(!1),W(null),L(null),y(a)},[a,y]);const x=r.useCallback(C=>{m(C),f(null),h(null),w(!1),te(null)},[]),v=r.useCallback(C=>{R||(i(C),u(""))},[R]),Q=r.useCallback(C=>{const F=new Set(c);F.has(C)?F.delete(C):F.add(C),x(F)},[x,c]),$=r.useCallback(()=>{const C=al(o,d,c);x(C.selected),C.capped&&te(n("ui.settings.imports.selection_limit",{max:Jn}))},[d,x,c,o]),ne=r.useCallback(()=>{x(new Set)},[x]),V=r.useMemo(()=>sl(a,c),[a,c]),se=p!==null&&b!==V,ve=r.useCallback(async()=>{if(!(!a||c.size===0)){K("preview"),O(null);try{const C=await pl({sources:[a],sessionIds:{[a]:[...c].sort()}});f(C),h(V)}catch(C){f(null),h(null),O(n("ui.settings.imports.error_preview",{reason:Pe(C)}))}finally{K(null)}}},[a,V,c]),pe=r.useCallback(async()=>{if(!(!a||c.size===0||!p||se||!_||T)){K("start"),O(null),W(null);try{const C=await hl({sources:[a],sessionIds:{[a]:[...c].sort()}}),F=Date.now()/1e3;L({jobId:C,state:"queued",phase:"queued",source:a,sessionId:"",completed:0,total:c.size,results:[],warnings:[],error:"",startedAt:F,updatedAt:F})}catch(C){O(n("ui.settings.imports.error_start",{reason:Pe(C)}))}finally{K(null)}}},[a,_,p,se,T,c]),me=T?.jobId??null,fe=T?.state??null;r.useEffect(()=>{if(!me||!fe||st.has(fe))return;let C=!0,F;const re=async()=>{try{const ie=await fl(me);if(!C)return;if(U.current){const le=U.current;U.current=null,O(ye=>ye===le?null:ye)}L(ie),ie.result&&W({...ie.result,jobId:ie.jobId}),st.has(ie.state)||(F=setTimeout(re,900))}catch(ie){if(!C)return;const le=n("ui.settings.imports.error_job",{reason:Pe(ie)});U.current=le,O(le),F=setTimeout(re,2e3)}};return F=setTimeout(re,z>0?0:700),()=>{C=!1,F&&clearTimeout(F)}},[me,fe,z]);const j=r.useCallback(async()=>{if(!(!T||st.has(T.state))){J(!0),O(null);try{await xl(T.jobId)}catch(C){O(n("ui.settings.imports.error_cancel",{reason:Pe(C)}))}finally{J(!1)}}},[T]),B=r.useCallback(()=>{m(new Set),f(null),h(null),w(!1),te(null),W(null),L(null),O(null),a&&y(a)},[a,y]),q=r.useCallback(async C=>{try{return await navigator.clipboard.writeText(C),!0}catch{return!1}},[]),ae=r.useCallback(async()=>{R||(te(null),await Y(),a&&await y(a))},[a,R,y,Y]),N=r.useCallback(()=>{if(R){O(null),P(C=>C+1);return}ae()},[R,ae]);return t.jsx(ul,{sources:e,activeSource:a,sessions:o,query:d,selected:c,preview:p,previewStale:se,confirmed:_,busy:A,error:S,progress:T,result:I,cancelling:X,onSelectSource:v,onQueryChange:u,onToggleSession:Q,onSelectAll:$,onClearSelection:ne,onPreview:()=>void ve(),onConfirmChange:w,onImport:()=>void pe(),onCancel:()=>void j(),onRetry:N,onImportAnother:B,onRefresh:ae,selectionNotice:D,onCopyPath:q})},kl=e=>{const s=e.label.replace(/^Open\s+/,"");return s.charAt(0).toUpperCase()+s.slice(1)},bl=({action:e})=>{ee();const s=r.useId(),a=r.useRef(null),i=Me(_=>_.shortcutBindings),o=i[e.id],l=Me(_=>_.setShortcutBinding),d=Me(_=>_.clearShortcutBinding),[u,c]=r.useState(!1),[m,p]=r.useState(null),f=r.useMemo(zs,[]),b=Ra(e.id,i),h=kl(e);return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(we,{htmlFor:s,className:"w-32 text-body-sm text-ink",children:h}),t.jsx(Ae,{id:s,readOnly:!0,value:b===null?n("ui.settings.shortcuts.keyboard_shortcuts_section.no_shortcut"):Ea(b,f),"aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.label_press_the_keys_you_want",{label:String(h)}),"data-shortcut-action":e.id,ref:a,className:ue("w-52",b===null?"text-body-sm":"font-mono text-body-sm"),onFocus:()=>c(!0),onBlur:()=>{c(!1),p(null)},onKeyDown:_=>{if(Ps.has(_.key))return;if($s.has(_.key)){c(!1),p(null);return}if(Ks.has(_.key)||_.nativeEvent.isComposing)return;const w=Us({key:_.key,metaKey:_.metaKey,ctrlKey:_.ctrlKey,altKey:_.altKey,shiftKey:_.shiftKey}),A=Ta(w,e.id,i,f);if(A!==null){_.preventDefault(),c(!0),p(A);return}if(w===b){c(!0),p(null);return}_.preventDefault(),c(!0),p(null),w===e.defaultChord?l(e.id,null):w!==null&&l(e.id,w)}}),b!==null&&t.jsx(G,{variant:"secondary",size:"sm","aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.clear_label_s_shortcut",{label:String(h)}),onClick:()=>{d(e.id),a.current?.focus()},children:n("ui.settings.shortcuts.keyboard_shortcuts_section.clear")}),o!==void 0&&t.jsx(G,{variant:"secondary",size:"sm","aria-label":n("ui.settings.shortcuts.keyboard_shortcuts_section.reset_label_to_its_default",{label:String(h)}),onClick:()=>{l(e.id,null),a.current?.focus()},children:n("ui.settings.shortcuts.keyboard_shortcuts_section.reset")})]}),u&&t.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.shortcuts.keyboard_shortcuts_section.press_the_keys_you_want_esc_cancels")}),m!==null&&t.jsx("output",{className:"text-meta text-danger",children:m})]})},vl=({sectionRef:e})=>(ee(),t.jsx(ce,{title:n("ui.settings.shortcuts.keyboard_shortcuts_section.keyboard_shortcuts"),icon:Pa,description:n("ui.settings.shortcuts.keyboard_shortcuts_section.shortcuts_for_the_panel_rail_focus_a_field_and_press_the_keys_you"),sectionRef:e,children:t.jsx("div",{className:"flex flex-col gap-4",children:Ia.map(s=>t.jsx(bl,{action:s},s.id))})})),jl=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function ts(e){if(!e)return null;const s=e.split("\\").join("/").split("/").filter(Boolean);for(const[a,i]of jl)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return i;return null}const ut=e=>n("ui.settings.integrations.integration_model.tool_count",{count:e}),wl=e=>n("ui.settings.integrations.integration_model.integration_count",{count:e}),Nl=["connected","needs_sign_in","not_started","connecting","error"],ns=e=>Nl.includes(e),Ue=(e,s)=>[...s].filter(a=>a.name===e&&a.status==="running").sort((a,i)=>i.created_at-a.created_at)[0]??null,Sl={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},Cl=1e12,Ml=1e9,Al=60*60*1e3,ss=(e,s=Date.now())=>{if(typeof e!="number"||!Number.isFinite(e))return null;const a=e>=Cl?e:e<Ml?null:e*1e3;return a===null||a>s+Al?null:Math.min(a,s)},De=(e,s)=>e?.[s]??Sl,Qe=(e,s,a)=>El(e,s)??a?.lastDecisive??null,Il=e=>({id:e.id,name:e.name,action:e.action,status:e.status,created_at:e.created_at,credential_removed:e.credential_removed,...e.message?{message:e.message}:{}}),Zt=(e,s)=>e.status==="not_started"&&typeof e.tool_count=="number"&&(s.connectedAt!==null||e.status_basis==="stored"&&e.tool_count_basis==="last_seen"),Rl=(e,s)=>[...s].filter(a=>a.name===e).sort((a,i)=>i.created_at-a.created_at)[0]??null,El=(e,s)=>Rl(e,s.filter(a=>a.status!=="cancelled")),ft=e=>e.actions.includes("set_key")||e.actions.includes("add_key");function Tl(e,s){const a=Math.max(0,Math.round((e-s)/1e3));if(a<60)return n("ui.settings.integrations.integration_model.just_now");const i=Math.round(a/60);if(i<60)return n("ui.settings.integrations.integration_model.minutes_min_ago",{minutes:i});const o=Math.round(i/60);return o<24?n("ui.settings.integrations.integration_model.hours_h_ago",{hours:o}):n("ui.settings.integrations.integration_model.days_ago",{days:Math.round(o/24)})}function St(e){if(!e)return null;const s=e.trim();if(!s||/^\/\w/.test(s)||/\/mcp\s+\w+/.test(s))return null;let a=s;for(let i=0;i<3;i+=1){const o=a.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(o===a)break;a=o}return a=a.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),a||null}function Ll(e,s=[],a,i=Date.now()){const o=De(a,e.name),l=Ue(e.name,s);if(l){if(l.action==="login"||l.action==="reauth")return{label:n("ui.settings.integrations.integration_model.signing_in"),tone:"info",detail:null,busy:!0};if(l.action==="logout")return{label:n("ui.settings.integrations.integration_model.signing_out"),tone:"info",detail:null,busy:!0}}if(!ns(e.status))return{label:n("ui.settings.integrations.integration_model.status_unavailable"),tone:"neutral",detail:null,busy:!1};const d=Qe(e.name,s,o),u=xt(d)&&e.status!=="connected",c=Zt(e,o),m=en(d)&&e.status!=="connected",p=(d?.action==="login"||d?.action==="reauth")&&d.status==="failed";if(o.disconnectedAt!==null)return{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1};switch(e.status){case"connected":return{label:typeof e.tool_count=="number"?n("ui.settings.integrations.integration_model.connected_with_tools",{tools:String(ut(e.tool_count))}):n("ui.settings.integrations.integration_model.connected"),tone:"success",detail:null,busy:!1};case"connecting":return{label:n("ui.settings.integrations.integration_model.connecting"),tone:"info",detail:null,busy:!0};case"needs_sign_in":return{label:e.auth.kind==="api_key"||Ge(e,s,o)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:St(e.status_reason),busy:!1};case"error":return{label:n("ui.settings.integrations.integration_model.couldn_t_start"),tone:"danger",detail:St(e.status_reason)??n("ui.settings.integrations.integration_model.no_reason_was_given"),busy:!1};default:if(u)return{label:n("ui.settings.integrations.integration_model.signed_out"),tone:"warning",detail:null,busy:!1};if(m)return{label:n("ui.settings.integrations.integration_model.sign_out_didn_t_finish"),tone:"warning",detail:n("ui.settings.integrations.integration_model.the_sign_in_is_still_saved"),busy:!1};if(Ge(e,s,o))return{label:n("ui.settings.integrations.integration_model.needs_a_key"),tone:"warning",detail:null,busy:!1};if(p)return{label:n("ui.settings.integrations.integration_model.sign_in_didn_t_finish"),tone:"warning",detail:null,busy:!1};if(o.needsSignIn)return{label:e.auth.kind==="api_key"||Ge(e,s,o)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:St(e.status_reason),busy:!1};if(e.status_basis==="stored"&&c&&o.disconnectedAt===null){const f=o.connectedAt??ss(e.last_seen_at,i);return{label:f!==null?n("ui.settings.integrations.integration_model.worked_when_with_tools",{when:String(Tl(i,f)),tools:String(ut(e.tool_count))}):n("ui.settings.integrations.integration_model.worked_earlier_with_tools",{tools:String(ut(e.tool_count))}),tone:"success",detail:null,busy:!1}}return e.status_basis==="live"?{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1}:{label:n("ui.settings.integrations.integration_model.ready"),tone:"neutral",detail:null,busy:!1}}}const as=e=>n("ui.settings.integrations.integration_model.replace_keys",{count:e}),Ol=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Fl(e,s){const a=e?.trim()??"";if(!a)return null;if(s)return a;const i=a.replace(Ol,"").trim();return i?/\.$/.test(i)?i:`${i}.`:a}const Dl="ui.settings.integrations.integration_model.copy_ready_explanation",zl="ui.settings.integrations.integration_model.copy_not_connected_explanation",Pl=e=>e.transport==="local_command"?n("ui.settings.integrations.integration_model.local_command"):n("ui.settings.integrations.integration_model.remote_url");function is(e){switch(e.source.kind){case"local-operator":case"project-mcp-json":return null;case"claude-code":return n("ui.settings.integrations.integration_model.claude_code");case"cursor":return"Cursor";case"vscode":return n("ui.settings.integrations.integration_model.vs_code");case"codex":return n("ui.settings.integrations.integration_model.codex_cli");default:return ts(e.source.path)}}function $l(e,s){const a=[Pl(e)];e.status!=="connected"&&e.tool_count_basis==="last_seen"&&typeof e.tool_count=="number"&&a.push(n("ui.settings.integrations.integration_model.tools_when_last_checked",{tools:String(ut(e.tool_count))})),s&&a.push(e.scope==="project"?n("ui.settings.integrations.integration_model.this_project"):n("ui.settings.integrations.integration_model.global"));const i=is(e);return i?a.push(n("ui.settings.integrations.integration_model.imported_from_origin",{origin:String(i)})):e.source.editable||a.push(n("ui.settings.integrations.integration_model.imported_from_a_project_file")),a}const Jt=(e,s)=>s.disconnectedAt!==null?"not_started":e.status;function Xt(e,s=[],a){const i=De(a,e.name),o=Ue(e.name,s);if(o)return o.action==="login"||o.action==="reauth"?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.continue_sign_in")}:null;const l=p=>e.actions.includes(p),d=ft(e),u=Ge(e,s,i);if(!ns(e.status))return l("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.check_again")}:null;const c=Qe(e.name,s,i),m=c?.status==="failed"&&We(c);switch(Jt(e,i)){case"connected":case"connecting":return null;case"needs_sign_in":return u?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:l("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}:d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:l("reauth")?{kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};case"error":return l("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}:l("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.retry")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};default:{if(xt(c)&&l("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")};if(en(c)&&l("sign_out"))return{kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out_again")};if(i.disconnectedAt!==null&&l("connect"))return{kind:"connect",label:n("ui.settings.integrations.integration_model.connect")};if(i.needsSignIn){if(u&&d)return{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")};if(l("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}}return u&&d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:m&&l("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.try_again")}:Zt(e,i)&&!l("connect")?null:l("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.connect"),...i.connectedAt===null&&e.status_basis!=="live"?{variant:"ghost"}:{}}:l("test")&&e.tool_count===null&&e.tool_count_basis===null?{kind:"test",label:n("ui.settings.integrations.integration_model.test"),variant:"ghost"}:null}}}const We=e=>e.action==="login"||e.action==="reauth",xt=e=>!!(e&&e.action==="logout"&&e.status==="complete"),en=e=>!!(e&&e.action==="logout"&&e.status!=="running"&&e.status!=="complete"),os=/no oauth authorization server/i;function Ge(e,s,a){if(!ft(e))return!1;const i=Qe(e.name,s,a);return i&&We(i)&&i.status==="failed"&&os.test(i.message??"")?!0:a.needsKey}function Kl(e,s=[],a){const i=Xt(e,s,a)?.kind,o=Jt(e,De(a,e.name)),l=c=>e.actions.includes(c),d=[],u=Ue(e.name,s);if(u&&d.push({kind:"cancel",label:n("ui.settings.integrations.integration_model.cancel")}),!u&&l("test")&&i!=="test"&&d.push({kind:"test",label:n("ui.settings.integrations.integration_model.test_connection")}),l("connect")&&i!=="connect"&&o!=="connected"&&d.push({kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}),!u&&l("sign_in")&&i!=="sign_in"&&o!=="connected"&&d.push({kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}),l("reload")&&d.push({kind:"reload",label:n("ui.settings.integrations.integration_model.reload")}),!u&&l("reauth")&&i!=="reauth"&&d.push({kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}),ft(e)&&i!=="set_key"&&d.push({kind:"set_key",label:e.auth.secret_refs.length>0?n("ui.settings.integrations.integration_model.update_key"):n("ui.settings.integrations.integration_model.add_key")}),l("sign_out")&&d.push({kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out")}),l("disconnect")&&o==="connected"&&d.push({kind:"disconnect",label:n("ui.settings.integrations.integration_model.disconnect")}),l("copy_setup")&&e.setup_prompt&&d.push({kind:"copy_setup",label:n("ui.settings.integrations.integration_model.copy_setup_prompt")}),i!=="fix"&&d.push({kind:"open_config",label:n("ui.settings.integrations.integration_model.open_config_file")}),l("remove"))d.push({kind:"remove",label:n("ui.settings.integrations.integration_model.remove"),destructive:!0});else if(!e.source.editable){const c=is(e);d.push({kind:"remove_elsewhere",label:c?n("ui.settings.integrations.integration_model.remove_in_origin",{origin:String(c)}):n("ui.settings.integrations.integration_model.remove_in_its_own_file"),hint:c?n("ui.settings.integrations.integration_model.defined_in_origin_s_config_remove_it_there",{origin:String(c)}):n("ui.settings.integrations.integration_model.defined_in_a_file_this_app_doesn_t_write_remove_it_there")})}return d}const Ul={get attention(){return n("ui.settings.integrations.integration_model.needs_attention")},get connected(){return n("ui.settings.integrations.integration_model.connected")},get ready(){return n("ui.settings.integrations.integration_model.available")}};function rs(e,s=[],a){const i=De(a,e.name),o=Ue(e.name,s),l=Jt(e,i);if(o&&i.pinnedGroup&&i.pinnedOperationId===o.id)return i.pinnedGroup;if(l==="needs_sign_in"||l==="error")return"attention";const d=Qe(e.name,s,i);return xt(d)&&l!=="connected"||en(d)&&l!=="connected"?"attention":i.disconnectedAt!==null?"ready":Ge(e,s,i)||i.needsSignIn&&l!=="connected"||d?.status==="failed"&&We(d)&&l!=="connected"?"attention":l==="connected"||e.status_basis==="stored"&&Zt(e,i)?"connected":o&&o.action!=="test"?"attention":"ready"}function Bl(e,s=[],a){return["attention","connected","ready"].map(o=>({id:o,title:Ul[o],rows:e.filter(l=>rs(l,s,a)===o)})).filter(o=>o.rows.length>0)}function Hl(e,s,a=Date.now()){if(!s)return e??{};const i={};for(const o of s.servers){const l=De(e,o.name),d=Ue(o.name,s.operations),u=Qe(o.name,s.operations,l),c=xt(u),m=o.status==="connected"&&(o.status_basis==="probe"||o.status_basis==="live"),p=l.holdUntil!==null&&a<l.holdUntil,f=!p&&!c&&l.connectedAt===null&&o.status_basis==="stored"&&o.tool_count_basis==="last_seen"?ss(o.last_seen_at,a):null,b=!c,h=u?.status==="failed"&&We(u)&&os.test(u.message??""),_={connectedAt:m&&!p?a:f!==null?f:b?l.connectedAt:null,connectedToolCount:m&&!p||f!==null?o.tool_count??l.connectedToolCount:b?l.connectedToolCount:null,settledGroup:l.settledGroup,pinnedGroup:d&&l.pinnedOperationId===d.id?l.pinnedGroup:d?l.settledGroup:null,pinnedOperationId:d?d.id:null,needsKey:m?!1:l.needsKey||h,needsSignIn:m||c?!1:l.needsSignIn||o.status==="needs_sign_in",disconnectedAt:m&&!p?null:l.disconnectedAt,holdUntil:p?l.holdUntil:null,lastDecisive:u?Il(u):null};d||(_.settledGroup=rs(o,s.operations,{...i,[o.name]:_})),i[o.name]=_}return i}const Vl=(e,s)=>e!==null&&s===e,$t="local-operator.settings.integrations.row-memory",ls=(e,s)=>`${e}#${s}`;function Gl(e,s){const a={};if(!s)return a;for(const i of s.servers){const o=e[i.name];o&&(a[ls(i.source.path,i.name)]=o)}return a}function ql(e,s,a){if(!s)return e;let i=null;for(const o of s.servers){if(Object.prototype.hasOwnProperty.call(e,o.name))continue;const l=Wl(a[ls(o.source.path,o.name)]);l&&(i=i??{...e},i[o.name]=l)}return i??e}const Yl=["attention","connected","ready"],cs=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),tn=e=>typeof e=="number"&&Number.isFinite(e)?e:null,yn=e=>Yl.includes(e)?e:null,Ct=e=>{const s=tn(e);return s!==null&&s>=1e12?s:null};function Ql(e){if(!cs(e)||typeof e.id!="string"||typeof e.name!="string")return null;const s=e.action,a=e.status;return s!=="login"&&s!=="logout"&&s!=="reauth"&&s!=="test"||a!=="running"&&a!=="complete"&&a!=="cancelled"&&a!=="failed"?null:{id:e.id,name:e.name,action:s,status:a,created_at:tn(e.created_at)??0,credential_removed:e.credential_removed===!0,...typeof e.message=="string"?{message:e.message}:{}}}function Wl(e){if(!cs(e))return null;const s=Ct(e.connectedAt),a=Ct(e.disconnectedAt),i=e.needsKey===!0,o=e.needsSignIn===!0,l=Ql(e.lastDecisive);return s===null&&a===null&&!i&&!o&&!l?null:{connectedAt:s,connectedToolCount:tn(e.connectedToolCount),settledGroup:yn(e.settledGroup),pinnedGroup:yn(e.pinnedGroup),pinnedOperationId:typeof e.pinnedOperationId=="string"?e.pinnedOperationId:null,needsKey:i,needsSignIn:o,disconnectedAt:a,holdUntil:Ct(e.holdUntil),lastDecisive:l}}const ds=2e3,kn=8e3;function Zl(e){return e&&(e.servers.some(a=>a.status==="connecting")||e.operations.some(a=>a.status==="running"))?ds:!1}const Jl=/^[A-Za-z0-9_.:-]{1,100}$/,Xl=/:\/\//;function ec(e,s){const a=e.trim();return a?Jl.test(a)?s.includes(a)?n("ui.settings.integrations.integration_model.an_integration_named_trimmed_already_exists",{trimmed:String(a)}):null:n("ui.settings.integrations.integration_model.use_letters_numbers_dots_dashes_underscores_or_colons_with_no_spa"):n("ui.settings.integrations.integration_model.give_it_a_name")}function tc(e){const s=e.trim();if(!s)return n("ui.settings.integrations.integration_model.enter_the_server_s_url");let a;try{a=new URL(s)}catch{return n("ui.settings.integrations.integration_model.enter_a_full_url_like_https_mcp_example_com_mcp")}return a.protocol!=="https:"&&a.protocol!=="http:"?n("ui.settings.integrations.integration_model.the_url_must_start_with_https_or_http"):a.hostname?a.username||a.password?n("ui.settings.integrations.integration_model.remove_the_username_or_password_from_the_url_keys_are_added_after"):a.search||a.hash?n("ui.settings.integrations.integration_model.remove_the_or_part_of_the_url_keys_are_added_after_it_s_saved"):Xl.test(s.slice(a.protocol.length+2))?n("ui.settings.integrations.integration_model.this_looks_like_two_urls_pasted_together_enter_just_one"):null:n("ui.settings.integrations.integration_model.the_url_needs_a_host_name")}const nc=e=>e.split(`
|
|
287
|
+
`).map(s=>s.trim()).filter(Boolean);function Kt(e,s){const a=!!e?.cold,i=(e?.servers??[]).map(o=>{const l=o.transport==="http",d=o.secret_refs??[],u=o.status==="connected"?"connected":o.status==="connecting"?"connecting":o.status==="auth-required"?"needs_sign_in":"not_started",c=[];u!=="connected"&&c.push("connect"),u==="connected"&&c.push("disconnect"),a||c.push("reload"),l&&o.transport_oauth_supported!==!1&&c.push("sign_in"),d.length>0&&c.push("set_key"),o.owned_scope&&c.push("remove"),o.setup?.text&&c.push("copy_setup");const m=ts(o.source);return{id:o.name,name:o.name,scope:o.owned_scope??"global",project_cwd:null,source:{kind:sc(o.source,m,o.owned_scope),path:o.source??"",editable:o.owned_scope!==null,owned_scope:o.owned_scope},transport:l?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:u,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:a?"stored":"live",auth:{kind:d.length?"api_key":l?"unknown":"none",signed_in:null,secret_refs:d.map(p=>({id:p.id,state:"missing"}))},tool_count:typeof o.tool_count=="number"?o.tool_count:null,tool_count_basis:typeof o.tool_count=="number"?"live":null,actions:c,setup_prompt:o.setup?.text??null}});return{cwd:"",project_scope_available:i.some(o=>o.source.owned_scope==="project"),global_path:"",project_path:null,status_source:a?"config":"live",session_id:s,servers:i,operations:(e?.operations??[]).map(o=>({...o}))}}const sc=(e,s,a)=>s==="Claude Code"?"claude-code":s==="Cursor"?"cursor":s==="VS Code"?"vscode":s==="Codex CLI"?"codex":a?"local-operator":e?"project-mcp-json":"local-operator",bn={get invalid_config(){return n("ui.settings.integrations.integration_model.that_configuration_isn_t_valid_check_the_command_or_the_url_then_")},get operation_unavailable(){return n("ui.settings.integrations.integration_model.that_sign_in_or_test_isn_t_running_any_more_try_again")},get exists(){return n("ui.settings.integrations.integration_model.an_integration_with_this_name_already_exists_choose_another_name")},get not_owned(){return n("ui.settings.integrations.integration_model.it_s_defined_in_another_tool_s_config_so_it_can_t_be_changed_here")},get project_scope_unavailable(){return n("ui.settings.integrations.integration_model.there_s_no_separate_project_config_here_so_it_can_only_be_added_g")},get unknown_server(){return n("ui.settings.integrations.integration_model.it_no_longer_exists_the_list_has_been_refreshed")},get oauth_unsupported(){return n("ui.settings.integrations.integration_model.it_doesn_t_use_browser_sign_in")},get grant_running(){return n("ui.settings.integrations.integration_model.a_sign_in_or_test_is_already_running_wait_for_it_to_finish_or_can")},get too_many_operations(){return n("ui.settings.integrations.integration_model.too_many_sign_ins_and_tests_are_waiting_try_again_in_a_moment")},get write_failed(){return n("ui.settings.integrations.integration_model.the_config_file_couldn_t_be_written_check_that_it_isn_t_read_only")},get mcp_starting(){return n("ui.settings.integrations.integration_model.integrations_are_still_starting_try_again_in_a_moment")},get mcp_control_refused(){return n("ui.settings.integrations.integration_model.the_server_refused_it_so_nothing_was_changed")}},ac="ui.settings.integrations.integration_model.copy_catalog_refusal_fallback";function at(e,s,a){if(s instanceof Yt&&s.status===409){const i=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(bn,s.code)?bn[s.code]:n(ac);return`${Bs[e]}. ${i}`}return Hs(e,s,a).message}const ic="ui.settings.integrations.add_integration_form.copy_add_integration_pickup_note",oc="ui.settings.integrations.add_integration_form.copy_transport_hint",rc=({existingNames:e,projectScopeAvailable:s,projectLabel:a,onSubmit:i,onCancel:o,initial:l})=>{ee();const[d,u]=r.useState(l?.name??""),[c,m]=r.useState(l?.mode??"command"),[p,f]=r.useState(l?.command??""),[b,h]=r.useState(l?.args??""),[_,w]=r.useState(l?.url??""),[A,K]=r.useState("global"),[S,O]=r.useState(l?.touched?{name:!0,command:!0,url:!0}:{}),[T,L]=r.useState(!!l?.touched),[I,W]=r.useState(!1),[X,J]=r.useState(null),D=r.useRef(null),te=r.useRef(null),z=r.useRef(null);r.useEffect(()=>{D.current?.focus()},[]);const P=ec(d,e),H=c==="command"&&!p.trim()?n("ui.settings.integrations.add_integration_form.enter_the_command_to_run"):null,U=c==="url"?tc(_):null,R=v=>T||S[v],Y=async v=>{if(v.preventDefault(),L(!0),P||H||U){P?D.current?.focus():H?te.current?.focus():z.current?.focus();return}W(!0),J(null);const Q=s?A:"global",$=c==="command"?{name:d.trim(),scope:Q,mode:c,command:p.trim(),args:nc(b)}:{name:d.trim(),scope:Q,mode:c,url:_.trim()},ne=await i($);W(!1),J(ne)},y=(v,Q,$)=>Q&&R($)?t.jsx("p",{id:v,className:"text-body-sm text-danger",children:Q}):null,x=v=>v.preventDefault();return t.jsxs("form",{noValidate:!0,"aria-label":n("ui.settings.integrations.add_integration_form.add_integration"),className:"flex flex-col gap-4 rounded-lg bg-surface p-4",onSubmit:v=>void Y(v),onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),o())},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-name",children:n("ui.settings.integrations.add_integration_form.name")}),t.jsx(Ae,{ref:D,id:"integration-add-name",value:d,placeholder:n("ui.settings.integrations.add_integration_form.e_g_notion"),autoComplete:"off","aria-invalid":!!(P&&R("name")),"aria-describedby":P&&R("name")?"integration-add-name-error":void 0,onChange:v=>u(v.target.value),onBlur:()=>O(v=>({...v,name:!0}))}),y("integration-add-name-error",P,"name")]}),t.jsxs(gt,{value:c,onValueChange:v=>m(v==="url"?"url":"command"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-transport-label",className:"font-medium text-body-sm text-ink",children:n("ui.settings.integrations.add_integration_form.how_it_runs")}),t.jsxs(_t,{"aria-labelledby":"integration-add-transport-label",children:[t.jsx($e,{value:"command","data-integration-transport":"command",children:n("ui.settings.integrations.add_integration_form.local_command")}),t.jsx($e,{value:"url","data-integration-transport":"url",children:n("ui.settings.integrations.add_integration_form.remote_url")})]}),t.jsx("p",{className:"text-ink-dim text-meta",children:n(oc)}),t.jsxs(un,{value:"command",className:"mt-0 flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-command",children:n("ui.settings.integrations.add_integration_form.command")}),t.jsx(Ae,{ref:te,id:"integration-add-command",value:p,placeholder:n("ui.settings.integrations.add_integration_form.e_g_npx"),autoComplete:"off",className:"font-mono","aria-invalid":!!(H&&R("command")),"aria-describedby":H&&R("command")?"integration-add-command-error":void 0,onChange:v=>f(v.target.value),onBlur:()=>O(v=>({...v,command:!0}))}),y("integration-add-command-error",H,"command")]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs(we,{htmlFor:"integration-add-args",children:[n("ui.settings.integrations.add_integration_form.arguments")," ",t.jsx("span",{className:"font-normal text-ink-dim",children:n("ui.settings.integrations.add_integration_form.one_per_line")})]}),t.jsx(Gn,{id:"integration-add-args",value:b,rows:2,className:"font-mono",onChange:v=>h(v.target.value)})]})]}),t.jsx(un,{value:"url",className:"mt-0 flex flex-col gap-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-add-url",children:n("ui.settings.integrations.add_integration_form.url")}),t.jsx(Ae,{ref:z,id:"integration-add-url",type:"url",value:_,placeholder:n("ui.settings.integrations.add_integration_form.https_mcp_example_com_mcp"),autoComplete:"off",className:"font-mono","aria-invalid":!!(U&&R("url")),"aria-describedby":U&&R("url")?"integration-add-url-error":"integration-add-url-help",onChange:v=>w(v.target.value),onBlur:()=>O(v=>({...v,url:!0}))}),y("integration-add-url-error",U,"url")??t.jsx("p",{id:"integration-add-url-help",className:"text-ink-dim text-meta",children:n("ui.settings.integrations.add_integration_form.if_it_needs_a_sign_in_or_a_key_you_ll_be_asked_after_it_s_added")})]})})]}),s?t.jsxs(gt,{value:A,onValueChange:v=>K(v==="project"?"project":"global"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-scope-label",className:"font-medium text-body-sm text-ink",children:n("ui.settings.integrations.add_integration_form.available_in")}),t.jsxs(_t,{"aria-labelledby":"integration-add-scope-label",children:[t.jsx($e,{value:"global","data-integration-scope":"global",children:n("ui.settings.integrations.add_integration_form.all_chats")}),t.jsx($e,{value:"project","data-integration-scope":"project",children:n("ui.settings.integrations.add_integration_form.this_project")})]}),a?t.jsx("p",{className:"text-ink-dim text-meta",children:A==="project"?n("ui.settings.integrations.add_integration_form.only_chats_working_in_projectlabel",{projectLabel:String(a)}):n("ui.settings.integrations.add_integration_form.every_chat_in_any_folder")}):null]}):null,X?t.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:X}):null,t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("p",{className:ue("text-body-sm text-ink-dim"),children:n(ic)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(G,{type:"button",variant:"ghost",size:"md",onMouseDown:x,onClick:o,children:n("ui.settings.integrations.add_integration_form.cancel")}),t.jsxs(G,{type:"submit",variant:"primary",size:"md",disabled:I,onMouseDown:x,children:[I?t.jsx(he,{size:"xs"}):null,n("ui.settings.integrations.add_integration_form.add_integration")]})]})]})]})},lc=4;function cc(e){return e.rowMoving?e.now+e.windowMs:Math.max(e.hold.until,e.lastMovingAt+e.windowMs)}function dc(e){return e.now>e.hold.until||e.hold.reanchors>=lc?"drop":e.hold.landedOn.isConnected&&(!e.candidate||e.candidate===e.hold.landedOn)?"settled":e.active&&e.active!==e.body&&e.active!==e.hold.landedOn?"drop":e.candidate?.isConnected?"restore":"drop"}function uc(e){const s=cc({hold:e.hold,now:e.now,windowMs:e.windowMs,rowMoving:e.rowMoving,lastMovingAt:e.lastMovingAt});if(e.now>s)return{hold:null,land:null};const a=e.hold.landedOn??null,i=e.candidate;if(!i)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:null};if(!a)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:i},land:i};const o=dc({hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},candidate:i,active:e.active,body:e.body,now:e.now});if(o==="settled")return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:null};if(o==="drop")return{hold:null,land:null};const l=!a.isConnected;return{hold:{until:l?e.now+e.windowMs:s,reanchors:l?e.hold.reanchors+1:e.hold.reanchors,landedOn:i},land:i}}function mc(e){const{row:s,target:a}=e;return!s||!a||typeof a.nodeType!="number"?!1:!s.contains(a)}const vn=250;function jn(e){return e?!e.disabled:!1}function gc(e){return jn(e.primary)?e.primary??null:jn(e.overflow)?e.overflow??null:null}function _c(e){return e.verdict==="finished"?null:e.watchMs}const us="key";function pc(e){const{name:s,keyless:a,freeName:i,names:o,values:l,replace:d,canReplace:u}=e;if(a){const c=Ut(s,i);return{values:{[c]:(l[us]??"").trim()},confirmedReplace:d&&u?[c]:[],header:i.trim()}}return{values:Object.fromEntries(o.map(c=>[c,(l[c]??"").trim()])),confirmedReplace:d&&u?o:[],header:void 0}}function Ut(e,s){const a=wn(e),i=wn(s);if(!i)return"";const o=[a,i].filter(Boolean).join("_"),l=/^[A-Za-z_]/.test(o)?o:`K_${o}`;if(l.length<=Mt)return l;const d=hc(a),u=Mt-i.length-d.length-2,c=[a.slice(0,Math.max(u,0)),d,i].filter(Boolean).join("_");return c.length<=Mt?c:c.slice(-128)}const Mt=128,wn=e=>e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),hc=e=>{let s=2166136261;for(let a=0;a<e.length;a+=1)s^=e.charCodeAt(a),s=Math.imul(s,16777619)>>>0;return s.toString(36).toUpperCase().slice(0,5)},fc=({name:e,keyNames:s,keyless:a=!1,savedKeys:i=[],saving:o,failure:l,onSave:d,onClose:u})=>{ee();const[c,m]=r.useState({}),[p,f]=r.useState(!1),[b,h]=r.useState(""),_=a?[Ut(e,b)]:[...s],w=a?[us]:_,A=(a?Ut(e,b).length>0:!0)&&w.every(S=>(c[S]??"").trim()),K=_.some(S=>i.includes(S));return t.jsx(Dn,{open:!0,onClose:u,maxWidth:"xs",title:n("ui.settings.integrations.integration_key_dialog.add_keys_heading",{count:a?1:s.length,name:e}),actions:t.jsxs(t.Fragment,{children:[t.jsx(Tt,{onClick:u,children:n("ui.settings.integrations.integration_key_dialog.cancel")}),t.jsx(Lt,{disabled:!A||o,onClick:()=>{const S=pc({name:e,keyless:a,freeName:b,names:_,values:c,replace:p,canReplace:K});d(S.values,S.confirmedReplace,S.header)},children:o?n("ui.settings.integrations.integration_key_dialog.saving"):n("ui.settings.integrations.integration_key_dialog.save_and_test")})]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[t.jsx("p",{className:"-mx-1.5",children:a?n("ui.settings.integrations.integration_key_dialog.keys_are_saved_encrypted_on_this_computer_this_one_is_stored_unde"):n("ui.settings.integrations.integration_key_dialog.keys_are_saved_encrypted_on_this_computer_other_integrations_that")}),a?t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:"integration-key-name",children:n("ui.settings.integrations.integration_key_dialog.the_header_this_server_wants_the_key_in")}),t.jsx(Ae,{id:"integration-key-name",autoComplete:"off",placeholder:n("ui.settings.integrations.integration_key_dialog.e_g_authorization_or_x_api_key"),value:b,onChange:S=>h(S.target.value)}),t.jsx("p",{className:"-mx-1.5 text-ink-dim text-meta",children:n("ui.settings.integrations.integration_key_dialog.this_server_declares_no_key_of_its_own_so_local_operator_adds_one")})]}):null,w.filter(S=>a!==!0||S.trim().length>0).map(S=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(we,{htmlFor:`integration-key-${S}`,className:"font-mono",children:a?"Key":S}),t.jsx(Ae,{id:`integration-key-${S}`,type:"password",autoComplete:"off",value:c[S]??"",onChange:O=>m(T=>({...T,[S]:O.target.value}))})]},S)),K?t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(zt,{id:"integration-key-replace",checked:p,onCheckedChange:S=>f(S===!0)}),t.jsx(we,{htmlFor:"integration-key-replace",className:"font-normal",children:as(_.length)})]}):null,l?t.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:l}):null]})})},xc={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},yc={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"};function Nn(e){if(e===n("ui.settings.integrations.integration_model.ready"))return n(Dl);if(e===n("ui.settings.integrations.integration_model.not_connected"))return n(zl)}const kc=({row:e,operations:s,memories:a,now:i,projectScopeAvailable:o,highlighted:l=!1,rowRef:d,primaryRef:u,overflowRef:c,pending:m,failure:p,confirm:f,onPrimary:b,onOverflow:h,onConfirm:_,onCancelConfirm:w})=>{ee();const A=Ll(e,s,a,i),K=l&&A.tone==="danger"?"text-ink":yc[A.tone],S=Xt(e,s,a),O=Kl(e,s,a),T=$l(e,o),L=O.findIndex(I=>I.kind==="remove"||I.kind==="remove_elsewhere");return t.jsxs("li",{ref:d,"data-integration":e.name,"data-status":e.status,className:ue("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",l&&"bg-row-selected"),onKeyDown:I=>{!f||I.key!=="Escape"||(I.stopPropagation(),w())},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:A.busy?t.jsx(he,{size:"xs"}):t.jsx("span",{"aria-hidden":"true","data-tone":A.tone,className:ue("size-2 rounded-full",xc[A.tone])})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsx("span",{className:"truncate font-medium text-body text-ink",title:e.name,children:e.name}),t.jsx("span",{className:"truncate text-ink-dim text-meta",children:T.map((I,W)=>t.jsxs("span",{children:[W>0?" · ":null,I.startsWith("Imported from")&&e.source.path?t.jsx(Ke,{content:Vs(e.source.path),children:t.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:I})}):I]},I))})]}),Nn(A.label)?t.jsx(Ke,{content:Nn(A.label),children:t.jsx("span",{className:ue("shrink-0 text-body-sm",K),children:A.label})}):t.jsx("span",{className:ue("shrink-0 text-body-sm",K),children:A.label}),S?t.jsxs(G,{ref:u,variant:S.variant??"secondary",size:"sm","aria-label":`${S.label} ${e.name}`,disabled:m,"data-integration-action":S.kind,onClick:()=>b(S),children:[m?t.jsx(he,{size:"xs"}):null,S.label]}):null,t.jsxs(gi,{children:[t.jsx(_i,{asChild:!0,children:t.jsx(G,{ref:c,variant:"ghost",size:"icon-sm","aria-label":n("ui.settings.integrations.integration_row.more_actions_for_name",{name:String(e.name)}),disabled:m,children:t.jsx(Gs,{"aria-hidden":"true"})})}),t.jsx(pi,{align:"end",className:"min-w-48",children:O.map((I,W)=>t.jsx(bc,{item:I,separated:W===L&&W>0,onSelect:()=>h(I)},I.kind))})]})]}),A.detail?t.jsx("p",{className:ue("pl-7 text-body-sm",A.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:A.detail}):null,p?t.jsx("p",{className:ue("pl-7 text-body-sm",l?"text-ink":"text-danger"),role:"alert",children:p}):null,f?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-7",children:[t.jsx("span",{className:"text-body-sm text-ink",children:f.kind==="remove"?n("ui.settings.integrations.integration_row.remove_name",{name:String(e.name)}):n("ui.settings.integrations.integration_row.sign_out_of_name",{name:String(e.name)})}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:f.kind==="remove"?n("ui.settings.integrations.integration_row.agents_in_every_chat_lose_access_to_name",{name:String(e.name)}):e.auth.kind==="oauth"?n("ui.settings.integrations.integration_row.the_saved_sign_in_is_removed_too"):n("ui.settings.integrations.integration_row.its_saved_credential_is_removed_too")}),t.jsx(G,{variant:"danger",size:"sm",onClick:_,"data-integration-confirm":f.kind,children:f.kind==="remove"?n("ui.settings.integrations.integration_row.remove"):n("ui.settings.integrations.integration_row.sign_out")}),t.jsx(G,{variant:"ghost",size:"sm",onClick:w,children:n("ui.settings.integrations.integration_row.keep")})]}):null]})},bc=({item:e,separated:s,onSelect:a})=>(ee(),t.jsxs(t.Fragment,{children:[s?t.jsx(hi,{}):null,e.kind==="remove_elsewhere"?t.jsxs(mn,{disabled:!0,className:"flex-col items-start gap-0.5",children:[t.jsx("span",{children:e.label}),t.jsx("span",{className:"text-meta text-ink-dim",children:e.hint})]}):t.jsx(mn,{destructive:e.kind==="remove",onSelect:a,"data-integration-menu":e.kind,children:e.label})]}));function vc(e,s,a){return!s||s.status==="running"?s?.browser_opened===!0?{message:n("ui.settings.integrations.integration_sign_in_dialog.your_browser_opened_approve_access_to_name_there_then_come_back_h",{name:String(e)}),tone:"progress",link:s.authorization_url??null}:s?.browser_opened===!1?{message:s.authorization_url?n("ui.settings.integrations.integration_sign_in_dialog.your_browser_didn_t_open_open_this_link_to_approve_access"):n("ui.settings.integrations.integration_sign_in_dialog.your_browser_didn_t_open_and_no_link_was_provided_cancel_and_try_"),tone:"progress",link:s.authorization_url??null}:{message:n("ui.settings.integrations.integration_sign_in_dialog.waiting_for_you_to_approve_access_to_name",{name:String(e)}),tone:"progress",link:s?.authorization_url??null}:s.status==="complete"?{message:n("ui.settings.integrations.integration_sign_in_dialog.signed_in_to_name_agents_can_use_it_now",{name:String(e)}),tone:"success",link:null}:s.status==="cancelled"?{message:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_cancelled"),tone:"failure",link:null,reason:null,nextStep:n("ui.settings.integrations.integration_sign_in_dialog.press_try_again_when_you_are_ready")}:{message:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_didn_t_finish"),tone:"failure",link:null,reason:Fl(s.message,a)??n("ui.settings.integrations.integration_sign_in_dialog.the_server_didn_t_say_why"),nextStep:jc(s.message??null,a)}}function jc(e,s){const a=(e??"").toLowerCase();return a.includes("redirect")?s?n("ui.settings.integrations.integration_sign_in_dialog.this_server_may_not_accept_sign_ins_from_local_operator_check_the"):n("ui.settings.integrations.integration_sign_in_dialog.this_server_may_not_accept_sign_ins_from_local_operator_check_the_2"):a.includes("no oauth")||a.includes("authorization server")?s?n("ui.settings.integrations.integration_sign_in_dialog.this_server_doesn_t_publish_a_browser_sign_in_add_its_key_instead"):n("ui.settings.integrations.integration_sign_in_dialog.this_server_doesn_t_publish_a_browser_sign_in_check_the_server_s_"):a.includes("network")||a.includes("connect")?n("ui.settings.integrations.integration_sign_in_dialog.check_the_server_s_url_and_your_network_then_try_again"):n("ui.settings.integrations.integration_sign_in_dialog.check_the_server_s_settings_then_try_again")}function wc(e,s){return e.kind==="ready"?"ready":e.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const Nc=({name:e,action:s,keyRoute:a,phase:i,onStart:o,onCancel:l,onOpenLink:d,onClose:u})=>{ee();const c=i.kind==="running"?i.operation:null,m=i.kind==="running"?vc(e,c,a):null,p=i.kind==="starting"||i.kind==="running"&&m?.tone==="progress",f=m&&m.tone!=="progress",b=r.useRef(null),h=r.useRef(!1),_=wc(i,m);r.useEffect(()=>{if(!h.current){h.current=!0;return}_&&b.current?.focus()},[_]);const w=()=>u(m?.tone==="success"?"signed-in":"dismissed");return t.jsx(Dn,{open:!0,onClose:w,maxWidth:"xs",fullWidth:!0,title:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_to_name",{name:String(e)}),dialogProps:{onOpenAutoFocus:A=>{A.preventDefault(),b.current?.focus()}},actions:t.jsxs(t.Fragment,{children:[p&&c?t.jsx(Tt,{ref:b,onClick:()=>l(c.id),children:n("ui.settings.integrations.integration_sign_in_dialog.cancel_sign_in")}):t.jsx(Tt,{ref:i.kind==="ready"?void 0:b,onClick:w,children:m?.tone==="success"?n("ui.settings.integrations.integration_sign_in_dialog.done"):n("ui.settings.integrations.integration_sign_in_dialog.close")}),i.kind==="ready"?t.jsx(Lt,{ref:b,onClick:o,children:n("ui.settings.integrations.integration_sign_in_dialog.continue_in_browser")}):null,i.kind==="refused"||m?.tone==="failure"?t.jsx(Lt,{ref:m?.tone==="failure"?b:void 0,onClick:o,children:n("ui.settings.integrations.integration_sign_in_dialog.try_again")}):null]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted","aria-live":"polite",children:[i.kind==="ready"?t.jsx("p",{className:"-mx-1.5",children:n("ui.settings.integrations.integration_sign_in_dialog.browser_approval_notice",{name:e,replaces:s==="reauth"?"yes":"no"})}):null,i.kind==="starting"?t.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[t.jsx(he,{size:"xs"}),n("ui.settings.integrations.integration_sign_in_dialog.starting_sign_in")]}):null,m?t.jsxs("div",{className:"flex flex-col gap-1",role:f?"status":void 0,children:[t.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?t.jsx(he,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?t.jsx(fi,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-danger"}):null,t.jsx("span",{children:m.message})]}),m.reason?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.reason}):null,m.nextStep?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.nextStep}):null]}):null,m?.link&&m.tone==="progress"?t.jsxs("div",{className:"flex flex-col items-start gap-1",children:[t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-dim text-mono-sm",title:m.link,children:m.link}),t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":n("ui.settings.integrations.integration_sign_in_dialog.copy_the_sign_in_link"),title:n("ui.settings.integrations.integration_sign_in_dialog.copy_the_sign_in_link"),onClick:()=>{navigator.clipboard.writeText(m.link??"").then(()=>Ot(n("ui.settings.integrations.integration_sign_in_dialog.sign_in_link_copied"))).catch(()=>{})},children:t.jsx(Fn,{"aria-hidden":"true"})})]}),t.jsx(G,{variant:"link",size:"sm",onClick:()=>d(m.link??""),children:n("ui.settings.integrations.integration_sign_in_dialog.open_the_sign_in_page")})]}):null,i.kind==="refused"?t.jsx("p",{className:"text-danger",role:"alert",children:i.message}):null]})})},Sc=e=>e.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),Cc=/^[A-Za-z]:[\\/]/,mt=e=>{const s=e?.trim();return s&&(s.startsWith("/")||Cc.test(s))?s:null};function Mc(e){const o=e?.payload?.frontend?.snapshot?.cwd;return typeof o=="string"&&o.trim()?o:null}const Ye="local-operator.settings.integrations.last-cwd";function Ac(e,s,a=typeof localStorage>"u"?null:localStorage){const i=mt(s);if(!(!e||!i||!a))try{const o=a.getItem(Ye),l=o?JSON.parse(o):{};if(l[e]===i)return;a.setItem(Ye,JSON.stringify({...l,[e]:i}))}catch{}}const ms=()=>typeof localStorage>"u"?null:localStorage;function gs(e=ms()){if(!e)return{};try{const s=e.getItem($t);if(!s)return{};const a=JSON.parse(s);return!a||typeof a!="object"||Array.isArray(a)?{}:a}catch{return{}}}const Sn=256;function Ic(e,s=ms()){if(s)try{const a={...gs(s),...e},i=Object.keys(a);if(i.length>Sn){const o={};for(const l of i.slice(-Sn))o[l]=a[l];s.setItem($t,JSON.stringify(o));return}s.setItem($t,JSON.stringify(a))}catch{}}function Cn(e,s,a){if(e==="saved")return null;if(e==="replace_confirmation_required"){const o=as(Object.keys(a).length);return n("ui.settings.integrations.use_integrations.a_saved_value_already_exists_for_this_key_tick_label_to_overwrite",{label:String(o)})}if(e==="invalid_target")return n("ui.settings.integrations.use_integrations.that_header_can_t_carry_this_key_it_may_already_be_set_on_the_ser");const i=s.length?s:Object.keys(a);return n("ui.settings.integrations.use_integrations.keys_not_saved",{keys:String(i.join(", "))})}function Rc(e,s=typeof localStorage>"u"?null:localStorage){if(!(!e||!s))try{const a=s.getItem(Ye);if(!a)return;const i=JSON.parse(a);if(!(e in i))return;const o={...i};delete o[e],s.setItem(Ye,JSON.stringify(o))}catch{}}const Ec=e=>!!(e&&typeof e=="object"&&"code"in e&&e.code==="invalid_cwd"),Tc=(e,s)=>s!==null&&e===s?null:e;function Lc(e,s=typeof localStorage>"u"?null:localStorage){if(!e||!s)return null;try{const a=s.getItem(Ye);if(!a)return null;const o=JSON.parse(a)[e];return typeof o=="string"?o:null}catch{return null}}const Oc=e=>e.action==="disconnect"?"disconnected":"connected";function Fc(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"connect":case"disconnect":case"reload":return null;case"test":return{action:"test",name:e.name};default:return{...e,confirmed:!0}}}function Dc(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"test":case"connect":return{action:"connect",name:e.name};case"reload":return{action:"reload",name:e.name};case"add":return e;case"remove":return{...e,confirmed:!0};default:return{action:e.action,name:e.name,confirmed:!0}}}function zc({sessionId:e}){const s=Gt(),a=Rt(s.data,"mcp_catalog"),i=Rt(s.data,"mcp"),o=a?"catalog":i?"session":null,[l,d]=r.useState(null),u=Ht(),c=lt(j=>j.sessions),m=lt(j=>j.fetchSessions),p=lt(j=>j.loading),f=r.useMemo(()=>c.find(j=>j.session_id===e)??null,[c,e]),b=r.useMemo(()=>o==="session"&&!e?Sc(c):null,[o,e,c]),h=o==="session"?e??b?.session_id??null:null;r.useEffect(()=>{o!=="session"||e||c.length>0||m(qs)},[o,e,c.length,m]);const _=o==="catalog"?mt(f?.cwd):null,w=o==="catalog"&&!!e&&_===null,A=be({queryKey:["desktop","session-cwd",e??""],queryFn:()=>de({op:"sessions.get",sessionId:e??""}),enabled:w,staleTime:Number.POSITIVE_INFINITY,retry:!1}),K=w&&!A.isFetched,S=_??mt(Mc(A.data))??(A.isFetched?mt(Lc(e)):null),O=Tc(S,l),T=o==="catalog"?O:null,L=o==="catalog"?e??null:null,I=Ys.catalog(T,L);r.useEffect(()=>{o!=="catalog"||!e||!T||Ac(e,T)},[o,e,T]);const W=r.useRef(0),[X,J]=r.useState(0),D=r.useRef(null),te=r.useCallback((j,B)=>{const q=Date.now()+kn;W.current=q,D.current={name:j,expect:B},J(q)},[]),z=r.useCallback(j=>Date.now()<W.current?ds:Zl(j),[]),P=be({queryKey:I,queryFn:()=>Zs(T,L),enabled:o==="catalog"&&!K,staleTime:1e4,refetchInterval:j=>z(j.state.data)}),H=Ec(P.error);r.useEffect(()=>{!H||!S||l===S||(d(S),Rc(e))},[H,S,l,e]);const U=be({queryKey:Ft.list(h??""),queryFn:()=>Js(h??""),enabled:o==="session"&&!!h,staleTime:1e4,refetchInterval:j=>z(j.state.data?Kt(j.state.data,h??""):void 0)}),R=r.useMemo(()=>{if(o==="catalog")return P.data;if(o==="session"&&U.data&&h)return Kt(U.data,h)},[o,P.data,U.data,h]),Y=r.useCallback(()=>Pc({queryClient:u,route:o,catalogKey:I,sessionId:h}),[o,I,u,h]);r.useEffect(()=>{if(!X)return;const j=D.current;if(!j)return;const B=R?.servers.find(ae=>ae.name===j.name);!B||!(j.expect==="connected"?B.status==="connected":B.status_basis==="live"&&B.status!=="connected")||(W.current=0,D.current=null,J(0))},[R,X]);const y=r.useRef({}),[x,v]=r.useState(0),Q=r.useMemo(()=>(y.current=Hl(ql(y.current,R,gs()),R),y.current),[R,x]),$=r.useRef("");r.useEffect(()=>{const j=Gl(Q,R);if(!Object.keys(j).length)return;const B=JSON.stringify(j);B!==$.current&&($.current=B,Ic(j))},[Q,R]);const ne=r.useCallback(j=>{const B=De(y.current,j);B.needsKey||(y.current={...y.current,[j]:{...B,needsKey:!0}},v(q=>q+1))},[]),V=r.useCallback(j=>{if(j.action!=="disconnect"&&j.action!=="connect"&&j.action!=="reload")return;const B=De(y.current,j.name),q=Date.now()+kn,ae=j.action==="disconnect"?{...B,connectedAt:null,disconnectedAt:Date.now(),holdUntil:q}:{...B,disconnectedAt:null,holdUntil:q};y.current={...y.current,[j.name]:ae},te(j.name,Oc(j)),v(N=>N+1)},[te]),se=r.useCallback(async j=>{if(o==="catalog"){const B=Fc(j);if(!B)return null;try{const q=await Qs(T,B);return u.setQueryData(I,q),V(j),q.operation?.id??null}catch(q){throw q instanceof Yt&&q.status===409&&u.invalidateQueries({queryKey:I}),q}}if(o==="session"&&h){const B=await de({op:"mcp.control",sessionId:h,control:Dc(j)});V(j);const q=Ft.list(h),ae=B?.data;return ae&&"servers"in ae&&Array.isArray(ae.servers)?(u.setQueryData(q,ae),null):(u.invalidateQueries({queryKey:q}),ae&&"id"in ae&&typeof ae.id=="string"?ae.id:null)}return null},[o,T,I,u,h,V]),ve=r.useCallback(async j=>{if(o==="catalog"&&L&&(j.action==="connect"||j.action==="disconnect"||j.action==="reload")){try{await de({op:"mcp.control",sessionId:L,control:{action:j.action,name:j.name,...j.action==="disconnect"?{confirmed:!0}:{}}})}catch(B){throw u.invalidateQueries({queryKey:I}),B}return V(j),await u.invalidateQueries({queryKey:I}),null}return se(j)},[o,L,u,I,se,V]),pe=r.useCallback(async(j,B,q,ae)=>{if(o==="catalog"){const N=await Ws(T,j,B,q,ae);if(N.catalog&&u.setQueryData(I,N.catalog),N.code!=="saved")return{saved:!1,message:Cn(N.code,N.failed_ids,B)};try{await se({action:"test",name:j})}catch{}return{saved:!0,message:null}}if(o==="session"&&h){const N=await de({op:"mcp.credentials.store",sessionId:h,name:j,values:B,confirmedReplace:q});if(N.data?.code!=="saved")return{saved:!1,message:Cn(N.data?.code,N.data?.failed_ids??[],B)};try{await se({action:"connect",name:j})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[o,T,I,u,se,h]),me=o==="catalog"?P:U,fe=r.useCallback(()=>{me.refetch()},[me]);return{enabled:o!==null,route:o,sessionId:o==="catalog"?L:h,borrowed:b,noConversation:o==="session"&&!h&&!p,document:R,isLoading:s.isLoading||o==="catalog"&&(K||P.isLoading)||o==="session"&&(h?U.isLoading:p),isError:me.isError,folderUnavailable:Vl(l,S),refetch:fe,readDocument:Y,control:ve,storeKeys:pe,memories:Q,markNeedsKey:ne}}function Pc(e){if(e.route==="catalog")return e.queryClient.getQueryData(e.catalogKey);if(e.route==="session"&&e.sessionId){const s=e.queryClient.getQueryData(Ft.list(e.sessionId));return s?Kt(s,e.sessionId):void 0}}const $c=(e,s)=>{const a=e?.trim();if(!a)return null;const i=ta(a,s);return i.kind==="auth"?{kind:"matched",name:i.name,unresolved:null}:{kind:"miss",asked:a}},Kc=6,At="ui.settings.integrations.mcp_management_section.copy_section_title",Uc="ui.settings.integrations.mcp_management_section.copy_section_description",Bc={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},Hc=({sessionId:e,sectionRef:s,highlightServer:a})=>{ee();const i=zc({sessionId:e}),{document:o,control:l,readDocument:d}=i,u=Xs(),c=o?.servers??[],m=o?.operations??[],p=o?.project_scope_available??!1,[f,b]=r.useState(!1),[h,_]=r.useState(""),[w,A]=r.useState(null),[K,S]=r.useState({}),[O,T]=r.useState(null),[L,I]=r.useState(null),[W,X]=r.useState({kind:"ready"}),[J,D]=r.useState(null),[te,z]=r.useState(null),[P,H]=r.useState(!1),U=r.useRef({}),R=r.useRef({}),Y=r.useRef({}),y=r.useRef(0),x=r.useRef(null),v=r.useRef(null),Q=r.useRef(null),[$,ne]=r.useState(null),[V,se]=r.useState(null),[ve,pe]=r.useState(null),me=r.useCallback(()=>{const g=Q.current;Q.current=null,I(null),D(null),window.setTimeout(()=>{g?.isConnected&&g.focus()},0)},[]),fe=r.useCallback(g=>{const k=window.document.activeElement;Q.current=k instanceof HTMLElement?k:null,I(g)},[]),j=r.useCallback((g,k)=>{se({name:g,waitForSignIn:k==="signed-in",until:Date.now()+Ve,reanchors:0}),me()},[me]),B=r.useMemo(()=>$c(a,c.map(g=>g.name)),[a,c]),q=B?.kind==="matched"?B.name:null,ae=r.useRef(null),N=r.useRef(null),C=h.trim().toLowerCase(),F=r.useMemo(()=>C?c.filter(g=>g.name.toLowerCase().includes(C)):c,[c,C]),re=Bl(F,m,i.memories),ie=L?.kind==="sign_in"?c.find(g=>g.name===L.name)??null:null;r.useEffect(()=>{!q||N.current===q||!h||_("")},[q,h]),r.useEffect(()=>{!q||N.current===q||F.some(g=>g.name===q)&&(N.current=q,ae.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[q,F]),r.useEffect(()=>{if(!J)return;const g=m.find(k=>k.id===J)??null;X({kind:"running",operation:g})},[m,J]);const le=m.some(g=>g.status==="running"),ye=g=>{const k=window.document.activeElement;k&&k!==window.document.body&&k.isConnected||se({name:g,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})},ge=async(g,k,E)=>{A(g),S(({[g]:Ee,...Te})=>Te);let Z=null,ke=!1;try{Z=await E()}catch(Ee){ke=!0,S(Te=>({...Te,[g]:at(Bc[k]??"status",Ee,le)}))}finally{A(null),k!=="sign_out"&&(k!=="remove"||ke)&&ye(g)}return{operationId:Z,failed:ke}},Ie=g=>c.find(k=>k.name===g),xe=g=>{g.source.path&&na(g.source.path)},je=async(g,k)=>{X({kind:"starting"}),D(null);try{const E=await l({action:k,name:g});E?D(E):X({kind:"running",operation:null})}catch(E){E instanceof Yt&&E.code==="oauth_unsupported"&&i.markNeedsKey(g),X({kind:"refused",message:at("grant",E,le)})}},Ne=(g,k)=>{switch(k.kind){case"sign_in":case"reauth":{const E=m.find(Z=>Z.name===g.name&&Z.status==="running");E&&We(E)?(X({kind:"running",operation:E}),D(E.id)):(X({kind:"ready"}),D(null)),fe({kind:"sign_in",name:g.name,action:k.kind==="reauth"?"reauth":"login"});return}case"set_key":z(null),fe({kind:"key",name:g.name,keyNames:g.auth.secret_refs.map(E=>E.id)});return;case"fix":xe(g);return;case"sign_out":T({name:g.name,kind:"sign_out"});return;default:{const E=k.kind;ge(g.name,E,()=>l({action:E,name:g.name}))}}},Re=(g,k)=>{switch(k.kind){case"remove":case"sign_out":T({name:g.name,kind:k.kind});return;case"sign_in":case"reauth":case"set_key":Ne(g,{kind:k.kind,label:k.label});return;case"open_config":xe(g);return;case"copy_setup":navigator.clipboard.writeText(g.setup_prompt??"").then(()=>Ot(n("ui.settings.integrations.mcp_management_section.setup_steps_copied_paste_them_into_a_chat"))).catch(()=>{});return;case"cancel":{const E=m.find(Z=>Z.name===g.name&&Z.status==="running");E&&ge(g.name,"cancel",()=>l({action:"cancel",operationId:E.id}));return}case"test":case"connect":case"disconnect":case"reload":{const E=k.kind;ge(g.name,E,()=>l({action:E,name:g.name}));return}default:return}},yt=(g,k)=>{if(T(null),k==="remove"){const E=g.source.owned_scope;if(!E)return;const Z=F.findIndex(ke=>ke.name===g.name);ge(g.name,"remove",()=>l({action:"remove",name:g.name,scope:E})).then(({operationId:ke,failed:Ee})=>{Ee||ke!==null||(Ot(n("ui.settings.integrations.mcp_management_section.removed_name",{name:String(g.name)})),Z>=0&&pe({index:Z}))});return}ge(g.name,"sign_out",()=>l({action:"logout",name:g.name})).then(()=>{se({name:g.name,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})})},kt=async g=>{try{return await l({action:"add",name:g.name,scope:g.scope,...g.mode==="command"?{command:g.command,args:g.args}:{url:g.url}}),b(!1),ne(g.name),null}catch(k){return at("add",k,!1)}},Ze=t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-heading text-ink",children:n(At)}),t.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n(Uc)})]}),i.enabled&&c.length>0&&!f?t.jsxs(G,{ref:x,variant:"secondary",size:"sm",onClick:()=>b(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(ln,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]}):null]});if(!i.enabled&&!i.isLoading)return t.jsx(ce,{title:n(At),titleComponent:Ze,sectionRef:s,children:t.jsx(oe,{variant:"warning",children:n("ui.settings.integrations.mcp_management_section.integrations_need_a_newer_local_operator_backend_update_it_and_re")})});const bt=t.jsx(rc,{existingNames:c.map(g=>g.name),projectScopeAvailable:p,projectLabel:o?.cwd?Gc(o.cwd):null,onSubmit:kt,onCancel:()=>{b(!1),window.setTimeout(()=>x.current?.focus(),0)}}),Be=L?Ie(L.name):void 0,Je=Object.entries(K).filter(([g])=>!c.some(k=>k.name===g)),hs=g=>S(({[g]:k,...E})=>E);r.useEffect(()=>{if(!$)return;const g=U.current[$];if(!g){c.some(k=>k.name===$)&&(R.current[$]?.focus(),ne(null));return}g.focus(),ne(null)},[$,c]),r.useEffect(()=>{if(!ve)return;const k=F[Math.min(ve.index,F.length-1)]??F.at(-1);if(k){const E=U.current[k.name]??R.current[k.name];if(!E)return;E.focus()}else x.current?.focus();pe(null)},[ve,F]);const vt=r.useCallback((g,k)=>{const E=d()??o,Z=E?.servers.find(fs=>fs.name===g.name),ke=E?.operations??[],Ee=Z?Z.status==="connecting"||Ue(Z.name,ke)!==null:!1;Ee&&Z&&(y.current=k);const Te=Z?Xt(Z,ke,i.memories):null;if(Z&&g.waitForSignIn&&(Te?.kind==="sign_in"||Te?.kind==="reauth"))return"kept";const ze=uc({hold:g,now:k,windowMs:Ve,rowMoving:Ee,lastMovingAt:y.current,candidate:Z?gc({primary:Te?U.current[Z.name]:null,overflow:R.current[Z.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!ze.hold)return se(null),"finished";if(!ze.land)return"kept";se({name:g.name,waitForSignIn:!1,until:ze.hold.until,landedOn:ze.land,reanchors:ze.hold.reanchors});const nn=ze.land;return window.setTimeout(()=>{nn.isConnected&&nn.focus()},0),"landed"},[d,o,i.memories]);return r.useEffect(()=>{if(!V)return;vt(V,Date.now());let g=0,k=!1;const E=()=>{if(k)return;const Z=_c({verdict:vt(V,Date.now()),watchMs:vn});Z!==null&&(g=window.setTimeout(E,Z))};return g=window.setTimeout(E,vn),()=>{k=!0,window.clearTimeout(g)}},[V,vt]),r.useEffect(()=>{if(!V)return;const g=k=>{mc({target:k.target,row:Y.current[V.name]})&&se(null)};return window.document.addEventListener("pointerdown",g,!0),()=>{window.document.removeEventListener("pointerdown",g,!0)}},[V]),t.jsxs(ce,{title:n(At),titleComponent:Ze,sectionRef:s,children:[t.jsxs("div",{className:"flex flex-col gap-4",children:[i.route==="session"&&i.borrowed?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.borrowed_chat_notice",{chat:i.borrowed.title?.trim()||i.borrowed.session_id.slice(0,6)})}):null,i.noConversation?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.integrations_can_be_managed_here_once_a_chat_has_started")}),t.jsx(G,{variant:"primary",size:"sm",onClick:()=>u("/chat"),children:n("ui.settings.integrations.mcp_management_section.start_a_chat")}),t.jsx("p",{className:"text-ink-dim text-meta",children:n("ui.settings.integrations.mcp_management_section.updating_local_operator_removes_this_step")})]}):null,i.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(he,{size:"lg",label:n("ui.settings.integrations.mcp_management_section.loading_integrations")})}):null,i.folderUnavailable?t.jsx(oe,{variant:"warning",children:t.jsx("span",{children:n("ui.settings.integrations.mcp_management_section.this_chat_s_folder_no_longer_exists_so_only_global_integrations_a")})}):null,i.isError?t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:n("ui.settings.integrations.mcp_management_section.integrations_couldn_t_be_loaded")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:i.refetch,children:n("ui.settings.integrations.mcp_management_section.retry")})]})}):null,Je.map(([g,k])=>t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:k}),t.jsx(G,{variant:"ghost",size:"sm",onClick:()=>hs(g),children:n("ui.settings.integrations.mcp_management_section.dismiss")})]})},g)),f&&c.length>0?bt:null,c.length>=Kc?t.jsxs("div",{className:"relative",children:[t.jsx(On,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),t.jsx(Ae,{ref:v,value:h,onChange:g=>_(g.target.value),onKeyDown:g=>{g.key!=="Escape"||!h||(g.preventDefault(),_(""))},placeholder:n("ui.settings.integrations.mcp_management_section.search_integrations_placeholder",{integrations:wl(c.length)}),"aria-label":n("ui.settings.integrations.mcp_management_section.search_integrations"),className:"pl-9"})]}):null,B?.kind==="miss"&&c.length>0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_match_for_name",{asked:String(B.asked)})}):null,B?.kind==="matched"&&B.unresolved?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.showing_fallback_for_unknown",{shown:String(B.name),asked:String(B.unresolved)})}):null,o&&c.length===0&&!i.isLoading?f?bt:t.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[t.jsx(zn,{"aria-hidden":"true",className:"size-5 text-ink-muted"}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.integrations.mcp_management_section.no_integrations_yet")}),t.jsx("p",{className:"max-w-xl text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.integrations_let_agents_read_and_act_in_your_other_tools_like_not")})]}),t.jsxs(G,{variant:"primary",size:"md",onClick:()=>b(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(ln,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]})]}):null,c.length>0&&F.length===0?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_integrations_match_this_search")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>{_(""),window.setTimeout(()=>{(v.current??x.current)?.focus()},0)},children:n("ui.settings.integrations.mcp_management_section.clear_search")})]}):null,re.map(g=>t.jsxs("section",{"aria-labelledby":`integrations-group-${g.id}`,className:"flex flex-col gap-1.5",children:[t.jsxs("h3",{id:`integrations-group-${g.id}`,className:"px-1 text-ink-dim text-meta",children:[g.title," · ",g.rows.length]}),t.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:g.rows.map(k=>t.jsx(kc,{row:k,operations:m,memories:i.memories,projectScopeAvailable:p,highlighted:k.name===q,rowRef:E=>{Y.current[k.name]=E,k.name===q&&(ae.current=E)},primaryRef:E=>{U.current[k.name]=E},overflowRef:E=>{R.current[k.name]=E},pending:w===k.name,failure:K[k.name]??null,confirm:O?.name===k.name?{kind:O.kind}:null,onPrimary:E=>Ne(k,E),onOverflow:E=>Re(k,E),onConfirm:()=>O&&yt(k,O.kind),onCancelConfirm:()=>{T(null),window.setTimeout(()=>{R.current[k.name]?.focus()},0)}},k.id))})]},g.id))]}),L?.kind==="sign_in"?t.jsx(Nc,{name:L.name,action:L.action,keyRoute:ie?ft(ie):!1,phase:W,onStart:()=>void je(L.name,L.action),onCancel:g=>void l({action:"cancel",operationId:g}).catch(()=>{}),onOpenLink:g=>void ea(g),onClose:g=>j(L.name,g)}):null,L?.kind==="key"?t.jsx(fc,{name:L.name,keyNames:L.keyNames.length?L.keyNames:Be?.auth.secret_refs.map(g=>g.id)??[],keyless:L.keyNames.length===0,savedKeys:Be?.auth.secret_refs.filter(g=>g.state==="encrypted").map(g=>g.id),saving:P,failure:te,onClose:me,onSave:(g,k,E)=>{H(!0),z(null),i.storeKeys(L.name,g,k,E).then(Z=>{if(!Z.saved){z(Z.message);return}I(null),se({name:L.name,waitForSignIn:!1,until:Date.now()+Ve,reanchors:0})}).catch(Z=>z(at("key",Z,!1))).finally(()=>H(!1))}}):null]})},Ve=4e3,Vc=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,Gc=e=>e.replace(Vc,"~"),qc=({verification:e})=>{ee();const{prices:s}=aa(),a=e.grant_amount??s?.default_new_credits,{sentence:i,action:o}=ia(e.signup_grant,oa(a)),l=ra(e.claim_url,la);return t.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[t.jsx(pt,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink",children:i}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>ca(l),children:o})]})]})},Yc=({onAfterCredentialUpdate:e})=>{ee();const{isAuthenticated:s,user:a,isLoading:i,accountRead:o,signOut:l}=sa(),d=Pn(f=>f.isSigningOut),u=r.useCallback(async()=>{try{await l()}catch(f){console.error("Error signing out:",f)}},[l]),c=(()=>{if(!s||!a?.radientUser)return null;const{account:f,identity:b,verification:h}=a.radientUser,_=h!=null&&!h.email_verified&&h.signup_grant!=="claimed";return t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.account.radient_account_section.status"),value:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[n("ui.settings.account.radient_account_section.connected"),t.jsx(qe,{variant:"success",className:"capitalize",children:f.status})]})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.name"),value:f.name||n("ui.settings.account.radient_account_section.not_provided")}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.email"),value:f.email}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.account_id"),value:t.jsx("span",{className:"text-mono-sm",children:f.id})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.tenant_id"),value:t.jsx("span",{className:"text-mono-sm",children:f.tenant_id})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.provider"),value:t.jsx("span",{className:"capitalize",children:b.provider})}),t.jsx(_e,{label:n("ui.settings.account.radient_account_section.created"),value:$n(f.created_at)})]}),_&&h?t.jsx(qc,{verification:h}):null,t.jsx("div",{className:"mt-8",children:t.jsx($a,{offerSignIn:!0})}),t.jsxs("div",{className:"mt-8",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.radient_account_section.need_to_sign_out_or_switch_accounts")}),t.jsxs(G,{variant:"danger",className:"mt-3",onClick:u,children:[t.jsx(Ka,{}),n("ui.settings.account.radient_account_section.sign_out_from_radient")]})]})]})})(),m=o==="refused"?n("ui.settings.account.radient_account_section.radient_refused_the_sign_in_this_app_is_holding_so_your_account_d"):Kn(o)?n("ui.settings.account.radient_account_section.your_radient_account_could_not_be_read_so_this_app_cannot_show_yo"):n("ui.settings.account.radient_account_section.you_are_not_currently_signed_in_to_radient"),p=s&&a?null:t.jsxs("div",{children:[t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[m," ",n("ui.settings.account.radient_account_section.sign_in_to_access_your_account_details_or_sign_up_to_get_free_cre")]}),t.jsx("div",{className:"mt-6",children:t.jsx(bi,{titleText:"",onAfterCredentialUpdate:e,descriptionText:"",onSignInSuccess:()=>{}})})]});return i||d?t.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[t.jsx(he,{size:"lg",label:n("ui.settings.account.radient_account_section.loading_account")}),!d&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.account.radient_account_section.loading_your_radient_account_details")})]}):s&&a?.radientUser?c:t.jsx("div",{className:"flex flex-col gap-4",children:p})};function Qc({metric:e,data:s}){return ee(),t.jsx(da,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:e==="credits"?"credits":"tokens",srSummary:e==="credits"?n("ui.settings.account.settings_usage_chart.credits_summary",{days:s.length}):n("ui.settings.account.settings_usage_chart.tokens_summary",{days:s.length}),xTickFormatter:a=>a,yTickFormatter:a=>e==="credits"?`$${a.toFixed(2)}`:ua(a),children:t.jsx(zr,{data:s,children:t.jsx(Tn,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:e==="credits"?n("ui.settings.account.settings_usage_chart.credits_consumed"):n("ui.settings.account.settings_usage_chart.tokens_used")})})})}const Wc={all:["desktop","tts-path-resolution"]};function Zc(e){return be({queryKey:Wc.all,queryFn:()=>de({op:"tts.paths"}),enabled:e,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:ma})}const Jc=["speech.voice.gender","speech.voice.tone","speech.voice.expressiveness","speech.voice.pace","speech.voice.language","speech.voice.accent","speech.voice.instructions"];function Mn(e){const s=new Map(e.map(o=>[o.key,o])),a=[],i=[];for(const o of Jc){const l=s.get(o);l?a.push(l):i.push(o)}return{rows:a,missing:i}}const Xc=["provider_tts_radient","provider_tts_elevenlabs","provider_tts_openai","none"];function An(e){return typeof e=="string"&&Xc.includes(e)}function ed(e){if(e===null||typeof e!="object")return null;const s=e;if(!An(s.path)||typeof s.reason!="string"||typeof s.servable!="boolean"||!Array.isArray(s.rungs))return null;const a=[];for(const i of s.rungs){if(i===null||typeof i!="object")return null;const o=i;if(!An(o.path)||typeof o.available!="boolean"||typeof o.reason!="string")return null;a.push({path:o.path,available:o.available,reason:o.reason})}return{path:s.path,reason:s.reason,servable:s.servable,rungs:a}}const td={get provider_tts_radient(){return n("ui.settings.speech.speech_settings_model.radient_pass")},provider_tts_elevenlabs:"ElevenLabs",provider_tts_openai:"OpenAI",get none(){return n("ui.settings.speech.speech_settings_model.no_provider")}};function _s(e){return td[e]}function nd(e){return{servable:e.servable,serving:e.path==="none"?null:e.path,reason:e.reason,rungs:e.rungs.map(s=>({path:s.path,name:_s(s.path),available:s.available,reason:s.reason}))}}const sd="ui.settings.speech.speech_section.copy_backend_older_sentence",ps="ui.settings.speech.speech_section.copy_unavailable_sentence",ad=({resetErrorBoundary:e})=>(ee(),t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex flex-col items-start gap-3",children:[t.jsx("span",{children:n(ps)}),t.jsxs(G,{variant:"secondary",onClick:e,children:[t.jsx(yi,{"aria-hidden":"true"}),n("ui.settings.speech.speech_section.try_again")]})]})}));function id(e){return e==="enabled"?"ready":e==="below-version"?"older":"pairing"}const od=({sectionRef:e})=>{ee();const s=Gt(),a=Un(),i=ga(s.data,"tts"),o=id(i),l=be({queryKey:Et.all,queryFn:()=>de({op:"settings.list"}),enabled:o==="ready",staleTime:1e4}),d=Zc(o==="ready"),{hasRadientApiKey:u,hasRadientSession:c,speechBlock:m}=_a(),p=`${c}:${u}`,f=r.useRef(p),b=d.refetch;r.useEffect(()=>{f.current!==p&&(f.current=p,b())},[p,b]);const h=l.data,_=r.useMemo(()=>Mn(h?.settings??[]),[h]),[w,A]=r.useState({}),[K,S]=r.useState({}),[O,T]=r.useState({});r.useEffect(()=>{h&&A(y=>{let x=!1;const v={...y};for(const Q of Mn(h.settings).rows){const $=y[Q.key];if($&&$.value!==He(Q).value)continue;const ne=He(Q);$&&$.value===ne.value&&$.cascadeBase===ne.cascadeBase||(v[Q.key]=ne,x=!0)}return x?v:y})},[h]);const L=(y,x)=>S(v=>({...v,[y]:x})),I=(y,x)=>T(v=>({...v,[y]:x})),W=async y=>{const x=w[y.key];if(!x)return;const v=fa(y,x);if(!v.ok){I(y.key,v.error);return}L(y.key,!0),I(y.key,null);try{await de(v.request),L(y.key,!1);const $=(await l.refetch()).data?.settings.find(ne=>ne.key===y.key);$&&A(ne=>{const V=ne[y.key];return V&&V.value===x.value&&V.cascadeBase===x.cascadeBase?{...ne,[y.key]:He($)}:ne})}catch(Q){L(y.key,!1),I(y.key,Q instanceof Error?Q.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_saved"))}},X=async y=>{L(y.key,!0),I(y.key,null);try{await de({op:"settings.reset",key:y.key}),A(x=>({...x,[y.key]:He({...y,value:y.default,is_default:!0})})),L(y.key,!1),await l.refetch()}catch(x){L(y.key,!1),I(y.key,x instanceof Error?x.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_reset"))}},J=r.useMemo(()=>ed(d.data),[d.data]),D=J?nd(J):null,te=d.isSuccess&&J===null,z=(s.data?null:s.error)??null,P=l.error,H=n("ui.settings.speech.speech_section.speech_voicing"),U=n("ui.settings.speech.speech_section.how_the_assistant_sounds_when_it_speaks_aloud");if(o==="pairing"){const{sentence:y}=Dt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),z);return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:y})})}if(o==="older")return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:n(sd)})});if(P||!h){const{sentence:y,remedy:x}=Dt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),P);return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:y}),x&&t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{l.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})})})}const R=D?!D.servable:m==="offline",Y=D?D.rungs.find(y=>y.path===D.serving)??null:null;return t.jsx(ce,{title:H,icon:Xe,description:U,sectionRef:e,children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs("section",{className:"flex flex-col gap-3",children:[d.isPending&&t.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[t.jsx(he,{}),on("checking")]}),(d.isError||te)&&!D&&m!=="offline"&&t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{children:[n(ps)," ",d.error instanceof Error?d.error.message:""]}),t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})}),t.jsx(xi,{fallbackRender:ad,resetKeys:[d.dataUpdatedAt],children:D&&t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.speech.speech_section.speaks_through"),value:D.serving?_s(D.serving):n("ui.settings.speech.speech_section.nothing_yet")}),t.jsx(_e,{label:n("ui.settings.speech.speech_section.availability"),value:D.servable?n("ui.settings.speech.speech_section.ready"):n("ui.settings.speech.speech_section.no_provider")})]}),D.reason&&D.reason!==Y?.reason&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:D.reason}),t.jsx("ul",{className:"flex flex-col gap-1",children:D.rungs.map(y=>t.jsxs("li",{className:"flex flex-col gap-0.5 text-body-sm",children:[t.jsxs("span",{className:y.path===D.serving?"text-ink":"text-ink-muted",children:[y.name,t.jsxs("span",{className:y.path===D.serving?"text-ink-muted":"text-ink-dim",children:[" ",y.available?n("ui.settings.speech.speech_section.available"):n("ui.settings.speech.speech_section.not_available")]})]}),t.jsx("span",{className:"text-meta text-ink-dim",children:y.reason})]},y.path))})]})})]}),R&&t.jsx(oe,{variant:"warning",children:on(m)}),t.jsx("div",{className:"flex flex-col gap-1",children:_.rows.map(y=>t.jsx(pa,{setting:y,draft:w[y.key]??He(y),tier:ha(y),saving:!!K[y.key],error:O[y.key]??null,onDraftChange:x=>A(v=>({...v,[y.key]:x})),onSave:()=>{W(y)},onReset:()=>{X(y)}},y.key))}),_.missing.length>0&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.speech.speech_section.missing_voice_rows",{count:_.missing.length,rows:_.missing.join(", ")})})]})})},rd=()=>{ee();const{data:e,isLoading:s,error:a,refetch:i}=Or(),o=Fr(),[l,d]=r.useState(""),[u,c]=r.useState(!1);r.useEffect(()=>{d(e?.content??""),c(!1)},[e]);const m=_=>{const w=_.target.value;d(w),c(w!==(e?.content??""))},p=async()=>{if(!(!u||o.isPending))try{const _={content:l};await o.mutateAsync(_),await i(),c(!1)}catch(_){console.error("Error updating system prompt:",_)}},f=()=>{d(e?.content??""),c(!1)},b=o.isPending,h=()=>t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(we,{htmlFor:"app-system-prompt",children:n("ui.settings.model.system_prompt.instructions")}),t.jsx(Gn,{id:"app-system-prompt",name:"systemPrompt",value:l,onChange:m,placeholder:n("ui.settings.model.system_prompt.enter_instructions_for_how_all_agents_should_behave_and_respond_t"),className:"min-h-50"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs(G,{variant:"primary",onClick:p,disabled:!u||b,children:[b?t.jsx(he,{size:"sm"}):t.jsx(Ua,{}),b?n("ui.settings.model.system_prompt.saving"):n("ui.settings.model.system_prompt.save_changes")]}),t.jsx(G,{onClick:f,disabled:!u||b,children:n("ui.settings.model.system_prompt.cancel")})]}),e?.last_modified&&t.jsxs("p",{className:"text-ink-dim text-meta",children:[n("ui.settings.model.system_prompt.last_modified")," ",t.jsx("span",{className:"font-mono text-mono-sm",children:qt(e.last_modified)})]})]});return t.jsx(ce,{title:n("ui.settings.model.system_prompt.system_prompt"),icon:vi,description:n("ui.settings.model.system_prompt.every_local_operator_agent_receives_this_prompt_in_addition_to_it"),children:s?t.jsx("div",{className:"flex min-h-50 items-center justify-center",children:t.jsx(he,{size:"lg",label:n("ui.settings.model.system_prompt.loading_system_prompt")})}):a?t.jsx(oe,{variant:"danger",children:n("ui.settings.model.system_prompt.load_failed",{reason:a instanceof Error?a.message:n("ui.settings.model.system_prompt.unknown_error")})}):h()})},ld=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],cd=e=>ld.includes(e),dd=e=>{const s=[];let a=0;for(const i of e){const o=Math.max(0,Math.floor(i.count)),l=Math.max(1,Math.floor(i.columns));for(let d=0;d<o;d+=l)s.push({start:a+d,count:Math.min(l,o-d)});a+=o}return s},ud=({index:e,key:s,groups:a})=>{const i=dd(a),o=i.reduce((l,d)=>l+d.count,0);if(!Number.isInteger(e)||e<0||e>=o)return e;switch(s){case"Home":return 0;case"End":return o-1;case"ArrowLeft":return Math.max(0,e-1);case"ArrowRight":return Math.min(o-1,e+1);case"ArrowUp":case"ArrowDown":{const l=i.findIndex(c=>e>=c.start&&e<c.start+c.count),d=i[l+(s==="ArrowDown"?1:-1)];if(!d)return e;const u=e-i[l].start;return d.start+Math.min(u,d.count-1)}default:return e}},md={localOperatorDark:Vo,localOperatorLight:ur,dracula:sr,dune:yo,sage:Do,monokai:Va,tokyoNight:Qo,iceberg:ir,radient:Ro,neon:xa,obsidian:qn,synth:Ti,catppuccinMocha:so,catppuccinLatte:Ko,tokyoNightStorm:Qi,gruvbox:Ki,nord:Tr,oneDark:Ri,solarizedDark:cr,rosePine:jo,rosePineMoon:Bo,rosePineDawn:to,alucard:No,gruvboxLight:uo,tokyoNightDay:qo,oneLight:Po,catppuccinFrappe:lo,catppuccinMacchiato:To,palenight:Ha,everforest:Nr,everforestLight:jr,kanagawaWave:Ar,kanagawaLotus:bo,ayuDark:go,ayuMirage:po,ayuLight:Xo,nightfox:Zi,duskfox:pr,synthwave:Zo,matrix:Oi,tron:qi,cyberpunk:Ba,vaporwave:br,outrun:Pi,neonNoir:Cr,arcade:Oo,forest:yr,ocean:fo,desert:fr,autumn:Rr,lavender:rr,arctic:Xi,rosewood:Ao,solarizedLight:gr,githubLight:Co,paper:ji,linen:tr,highContrastLight:Ai,mintLight:Di},In="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",gd=({id:e})=>t.jsxs("div",{"data-theme":e,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[t.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[t.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:t.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),t.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),t.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[t.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[t.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),t.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),t.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),_d=({id:e,name:s,description:a,isSelected:i,isTabStop:o,onSelect:l,onFocusTile:d})=>{const u=md[e];return t.jsx(Ke,{side:"bottom",align:"start",content:a,children:t.jsxs("button",{type:"button","data-theme-tile":e,"aria-pressed":i,tabIndex:o?0:-1,onFocus:d,onClick:l,className:ue("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",i?In:"hover:bg-surface"),children:[t.jsxs("span",{className:ue("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",i?"border-accent":"border-hairline"),children:[t.jsx(gd,{id:e}),i&&t.jsx("span",{className:ue("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",In),children:t.jsx(Vn,{size:12,className:"text-accent","aria-hidden":"true"})})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(u,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},pd=e=>[...e.querySelectorAll("[data-theme-grid]")].map(s=>{const a=[...s.querySelectorAll("[data-theme-tile]")],i=a[0]?.getBoundingClientRect().top??0;return{count:a.length,columns:Math.max(1,a.filter(o=>Math.abs(o.getBoundingClientRect().top-i)<1).length)}}),hd=()=>{ee();const{themeName:e,setTheme:s}=Me(),a=Object.values(xs),i=[{label:n("ui.settings.appearance.theme_selector.dark"),items:a.filter(c=>c.theme.palette.mode==="dark")},{label:n("ui.settings.appearance.theme_selector.light"),items:a.filter(c=>c.theme.palette.mode==="light")}].filter(c=>c.items.length>0),[o,l]=r.useState(null),d=r.useMemo(()=>{const c=i.flatMap(m=>m.items.map(p=>p.id));return o&&c.includes(o)?o:c.includes(e)?e:c[0]},[i,o,e]),u=c=>{if(!cd(c.key))return;const m=[...c.currentTarget.querySelectorAll("[data-theme-tile]")],p=m.indexOf(c.target);if(p<0)return;c.preventDefault();const f=ud({index:p,key:c.key,groups:pd(c.currentTarget)});f!==p&&m[f]?.focus()};return t.jsx(ki,{children:t.jsx("div",{onKeyDown:u,className:"flex flex-col gap-6",children:i.map(c=>t.jsxs("div",{children:[t.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:c.label}),t.jsx("div",{"data-theme-grid":c.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:c.items.map(({id:m,name:p,description:f})=>t.jsx(_d,{id:m,name:p,description:f,isSelected:m===e,isTabStop:m===d,onSelect:()=>s(m),onFocusTile:()=>l(m)},m))})]},c.label))})})},fd=({value:e,onChange:s})=>{ee();const a=r.useId();return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{id:a,className:"flex min-h-6 items-center text-body text-ink",children:n("ui.settings.appearance.transcript_display_mode_setting.transcript_display")}),t.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.transcript_display_mode_setting.by_turn_condenses_each_turn_to_its_answer_by_response_keeps_every")})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsx(gt,{value:e,onValueChange:i=>s(Bn(i)),children:t.jsx(_t,{"aria-labelledby":a,children:La.map(i=>t.jsx($e,{value:i.value,children:i.value==="by-turn"?n("ui.settings.appearance.transcript_display_mode_setting.by_turn"):n("ui.settings.appearance.transcript_display_mode_setting.by_response")},i.value))})})})]})},xd=()=>{ee();const{data:e,isLoading:s,error:a}=$r({enabled:!0});return t.jsxs("div",{children:[t.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[t.jsx(oo,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_pass")]}),s&&t.jsx(Oe,{className:"h-6 w-36"}),a&&t.jsx(oe,{variant:"warning",children:n("ui.settings.account.settings_page.credit_balance_load_failed",{reason:a.message})}),e&&!s&&!a&&t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:[n("ui.settings.account.settings_page.available_credits")," ",t.jsx("span",{className:"font-medium text-ink",children:e.balance.toFixed(2)})]}),t.jsx(G,{variant:"secondary",size:"sm",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(Vi,{}),n("ui.settings.account.settings_page.add_credits")]})})]})]})},yd=[{id:"credits",get label(){return n("ui.settings.account.settings_page.credits")}},{id:"tokens",get label(){return n("ui.settings.account.settings_page.tokens")}}],kd=()=>{ee();const[e,s]=r.useState("credits"),a=r.useMemo(()=>{const u=new Date,c=Dr(u);return{start_date:gn(c),end_date:gn(u),rollup:"daily"}},[]),{data:i,isLoading:o,error:l}=Ur(a,{enabled:!0}),d=r.useMemo(()=>i?.data_points?[...i.data_points].sort((c,m)=>jt(c.timestamp).getTime()-jt(m.timestamp).getTime()).map(c=>({bucket:Ma(Si(jt(c.timestamp),"yyyy-MM-dd")),value:e==="credits"?Number.parseFloat(c.total_cost.toFixed(2)):c.total_tokens})):[],[i,e]);return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(Bi,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.usage_last_30_days")]}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.settings.account.settings_page.usage_metric")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:yd.map(({id:u,label:c})=>t.jsx(G,{variant:"ghost",size:"sm","aria-pressed":e===u,onClick:()=>s(u),className:ue(e===u&&"bg-surface text-ink hover:bg-surface"),children:c},u))})]})]}),o&&t.jsx(Oe,{className:"h-62 w-full"}),l&&t.jsx(oe,{variant:"warning",children:n("ui.settings.account.settings_page.usage_load_failed",{reason:l.message})}),!o&&!l&&i&&d.length>0&&t.jsx(Qc,{metric:e,data:d}),!o&&!l&&(!i||d.length===0)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.settings_page.no_usage_recorded_in_the_last_30_days")})]})},bd=()=>(ee(),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(ni,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_account")]}),t.jsx(G,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:[n("ui.settings.account.settings_page.go_to_radient_console"),t.jsx(Aa,{})]})})]})),Od=()=>{ee();const e=ya("surface"),s=ka(),a=Me(N=>N.showAgentReasoning),i=Me(N=>N.setShowAgentReasoning),o=Me(N=>N.transcriptDisplayMode),l=Me(N=>N.setTranscriptDisplayMode),{data:d,isLoading:u,isFetching:c,error:m,refetch:p}=ba(),{needsProvider:f}=va(),b=Un(),{sentence:h,remedy:_}=Dt(b??null,n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded"),m),w=Ga(),[A,K]=r.useState(null),S=Pn(),{isAuthenticated:O,accountRead:T,isFetching:L,isRefreshing:I,refreshUser:W}=Vt(),X=lt(N=>N.activeSessionId),[J,D]=r.useState("general"),[te,z]=r.useState(!1),P=r.useRef(null),H=r.useRef(null),{startTour:U}=qa(),R=ja(),{data:Y,refetch:y}=wa(),{refreshModels:x}=Na(),v=r.useMemo(()=>Y?.keys?[...Y.keys].sort():[],[Y?.keys]),Q=r.useRef({keys:"",hosting:void 0});r.useEffect(()=>{const N=v.join(","),C=d?.values?.hosting;(Q.current.keys!==N||Q.current.hosting!==C)&&(Q.current={keys:N,hosting:C},x().catch(F=>{console.error("Failed to refresh models after credentials or hosting change:",F)}))},[v,d?.values?.hosting,x]);const $=r.useRef({general:r.useRef(null),radient:r.useRef(null),integrations:r.useRef(null),appearance:r.useRef(null),speech:r.useRef(null),keyboard:r.useRef(null),providers:r.useRef(null),backend:r.useRef(null),imports:r.useRef(null),updates:r.useRef(null)}).current,ne=r.useMemo(()=>new URLSearchParams(R.search).get("setting"),[R.search]),V=r.useMemo(()=>new URLSearchParams(R.search).get("filter")??"",[R.search]),se=r.useMemo(()=>new URLSearchParams(R.search).get("mcp")??void 0,[R.search]),ve=r.useMemo(()=>new URLSearchParams(R.search).get("provider"),[R.search]),pe=r.useCallback(N=>{D(N),z(!0);const C=$[N],F=H.current;if(C?.current&&F){const ie=C.current.getBoundingClientRect().top-F.getBoundingClientRect().top;F.scrollHeight>F.clientHeight?F.scrollTo({top:Math.max(0,F.scrollTop+ie-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,C.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(P.current??void 0),P.current=setTimeout(()=>{z(!1),P.current=null},800)}else z(!1)},[$]);r.useEffect(()=>{const N=setTimeout(()=>{const C=H.current;if(!C)return;const F=()=>{if(te)return;const re=C.getBoundingClientRect(),ie=re.height;let le="",ye=0;for(const[ge,Ie]of Object.entries($))if(Ie.current){const xe=Ie.current.getBoundingClientRect(),je=re.top,Ne=xe.top-je,Re=xe.bottom-je,yt=xe.height,kt=Math.max(0,Ne),Ze=Math.min(ie,Re),Be=Math.max(0,Ze-kt)/yt,Je=Be+(Ne<ie*.3?.1:0);Je>ye&&Be>.1&&(ye=Je,le=ge)}le&&le!==J&&D(le)};return F(),C.addEventListener("scroll",F,{passive:!0}),()=>{C.removeEventListener("scroll",F),clearTimeout(P.current??void 0)}},100);return()=>clearTimeout(N)},[$,J,te]),r.useEffect(()=>{const N=new URLSearchParams(R.search),C=N.get("section"),F=N.get("setting"),re=F?rn(F,"backend"):C,ie=re?$[re]:void 0;if(!re||!ie)return;let le=!1,ye=Number.NaN,ge=0;const Ie=window.setTimeout(()=>{le||(le=!0,je.disconnect(),pe(re))},2e3),xe=()=>{if(le)return;const Ne=ie.current;if(!Ne){ge=requestAnimationFrame(xe);return}const Re=Math.round(Ne.getBoundingClientRect().top+window.scrollY);if(Re===ye&&Re>0){le=!0,je.disconnect(),window.clearTimeout(Ie),pe(re);return}ye=Re,ge=requestAnimationFrame(xe)},je=new ResizeObserver(()=>{le||(cancelAnimationFrame(ge),ge=requestAnimationFrame(xe))});return H.current&&je.observe(H.current),ge=requestAnimationFrame(xe),()=>{le=!0,cancelAnimationFrame(ge),je.disconnect(),window.clearTimeout(Ie)}},[R.search,$,pe]);const me=async(N,C)=>{K(N);try{await w.mutateAsync({[N]:C}),await p()}catch(F){console.error(`Error updating ${N}:`,F)}finally{K(null)}},fe=u,j=T==="checking",B=Kn(T),q=T==="ready"||T==="checking"||L,ae=Hn(fe,4e3);return m?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(oe,{variant:"warning",className:"w-full max-w-xl",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:h}),_&&t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void p(),disabled:c,children:c?n("ui.settings.navigation.settings_page.retrying"):n("ui.settings.navigation.settings_page.retry")})]})})}):fe?t.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[t.jsx(he,{size:"lg",label:ae?void 0:n("ui.settings.navigation.settings_page.loading_settings")}),ae&&t.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:n("ui.settings.navigation.settings_page.the_local_operator_server_is_taking_longer_than_usual_to_answer_i")})]}):d?t.jsxs("div",{"data-glass-region":"canvas","data-glass-split":"",className:"flex h-full w-full overflow-hidden bg-canvas",children:[t.jsx("div",{ref:e,className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:t.jsx(Ya,{activeSection:J,onSelectSection:pe,sections:Qa})}),t.jsx("div",{ref:H,"data-settings-content":!0,"data-glass-region":"canvas-content","data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[t.jsx(si,{title:n("ui.settings.page.title"),icon:cn}),t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{ref:$.general,className:"flex flex-col gap-8",children:[t.jsx(Wa,{focus:ne===ys}),t.jsxs(ce,{title:n("ui.settings.profile.title"),icon:Za,description:n(O?"ui.settings.profile.description_authenticated":"ui.settings.profile.description_anonymous"),children:[j&&t.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.profile.account_checking")}),B&&t.jsx(oe,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:n(T==="refused"?"ui.settings.profile.account_read_failed_refused":"ui.settings.profile.account_read_failed_retry")}),t.jsx(G,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>W(),disabled:I,children:I?n("ui.settings.profile.retrying"):n("ui.settings.profile.retry")})]})}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(dn,{value:S.profile.name,label:n("ui.settings.profile.display_name.label"),placeholder:n("ui.settings.profile.display_name.placeholder"),isSaving:A==="user_name",onSave:async N=>{K("user_name");try{S.updateName(N)}finally{K(null)}},readOnly:q}),t.jsx(dn,{value:S.profile.email,label:n("ui.settings.profile.email.label"),placeholder:n("ui.settings.profile.email.placeholder"),isSaving:A==="user_email",onSave:async N=>{K("user_email");try{S.updateEmail(N)}finally{K(null)}},readOnly:q})]})]}),t.jsx(ce,{title:n("ui.settings.tour.title"),description:n("ui.settings.tour.description"),children:t.jsxs(G,{variant:"secondary",onClick:()=>{U({forceModalCompleted:!0})},children:[t.jsx(Sa,{}),n("ui.settings.tour.action")]})}),t.jsx(ce,{id:"model-settings",title:n("ui.settings.model.settings_page.model_settings"),icon:Ja,description:n("ui.settings.model.settings_page.configure_the_default_ai_model_and_hosting_providers_used_for_gen"),children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Xa,{value:d.values.hosting,isSaving:A==="hosting",onSave:N=>me("hosting",N),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:n("ui.settings.model.settings_page.no_hosting_options")}),t.jsx(ei,{value:d.values.model_name,hostingId:d.values.hosting,isSaving:A==="model_name",onSave:N=>me("model_name",N),allowCustom:!0,allowDefault:!1}),t.jsx(el,{hosting:d.values.hosting,modelName:d.values.model_name,focus:ne===ot}),f&&t.jsx(oe,{variant:"neutral",icon:t.jsx(pt,{className:"size-4","aria-hidden":"true"}),children:t.jsxs("span",{children:[n("ui.settings.model.provider_callout.sentence"),t.jsx("button",{type:"button",className:"text-accent underline underline-offset-2",onClick:()=>{pe("providers"),$.providers.current?.focus({preventScroll:!0})},children:n("ui.settings.model.provider_callout.providers_link")}),"."]})})]})}),t.jsx(rd,{}),t.jsx(ce,{title:n("ui.settings.configuration.settings_page.configuration_information"),icon:pt,description:n("ui.settings.configuration.settings_page.system_information_about_the_current_configuration"),children:t.jsxs(ht,{children:[t.jsx(_e,{label:n("ui.settings.configuration.settings_page.version"),value:t.jsx("span",{className:"text-mono-sm",children:d.version})}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.created"),value:$n(d.metadata.created_at)}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.last_modified"),value:qt(d.metadata.last_modified)}),t.jsx(_e,{label:n("ui.settings.configuration.settings_page.description"),value:d.metadata.description||n("ui.settings.configuration.settings_page.no_description_available")})]})})]}),t.jsx(ce,{title:n("ui.settings.appearance.settings_page.appearance"),icon:qn,description:n("ui.settings.appearance.settings_page.customize_the_look_and_feel_of_local_operator"),sectionRef:$.appearance,dataTourTag:"settings-appearance-section",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(hd,{}),t.jsx(Yn,{value:a,label:n("ui.settings.appearance.settings_page.show_agent_reasoning"),description:n("ui.settings.appearance.settings_page.adds_the_agent_s_reasoning_and_thinking_rows_to_conversations_the"),onChange:async N=>i(N)}),t.jsx(fd,{value:Bn(o),onChange:N=>l(N)}),t.jsx(Gr,{state:s.state,onChange:s.set})]})}),t.jsx(od,{sectionRef:$.speech}),t.jsx(vl,{sectionRef:$.keyboard}),t.jsx(ce,{title:n("ui.settings.model.settings_page.model_providers"),icon:zn,description:n("ui.settings.navigation.settings_page.sign_in_to_the_services_your_agents_think_with_new_chats_use_your"),sectionRef:$.providers,id:"model-providers",className:"focus-visible:outline-none!",children:t.jsx(ti,{initialProviderId:ve,onChangeModel:()=>pe("general")})}),t.jsx(Hc,{sessionId:X??void 0,sectionRef:$.integrations,highlightServer:se}),t.jsx(ce,{title:n("ui.settings.account.settings_page.radient_account"),titleComponent:t.jsx(bd,{}),description:n("ui.settings.account.settings_page.your_radient_account_radient_pass_details_and_credits_to_use_radi"),sectionRef:$.radient,dataTourTag:"settings-radient-account-section",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsx(Yc,{onAfterCredentialUpdate:()=>{x(),y()}}),O&&t.jsxs(t.Fragment,{children:[t.jsx(xd,{}),t.jsx(kd,{})]})]})}),t.jsx(ce,{title:n("ui.settings.navigation.settings_page.backend_settings"),icon:cn,description:n("ui.settings.navigation.settings_page.every_setting_the_backend_registry_owns_searchable_with_typed_edi"),sectionRef:$.backend,children:t.jsx(Ca,{hideInterfaceLanguage:!0,hideModelEffort:!0,focusKey:ne&&rn(ne,"backend")==="backend"?ne:null,initialFilter:V})}),t.jsx("div",{ref:$.imports,children:t.jsx(yl,{})}),t.jsx("div",{ref:$.updates,children:t.jsx(Wr,{})})]})]})})]}):t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(oe,{variant:"warning",className:"w-full max-w-xl",children:n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded")})})};export{Od as SettingsPage};
|